From 642ede55534c47135dfaa7f9e7a8f9b21173b6ad Mon Sep 17 00:00:00 2001 From: sethwv Date: Tue, 21 Jul 2026 16:39:42 +0000 Subject: [PATCH] [multiview] Update to v0.4.2 See release notes: https://github.com/swvn-dispatch/dispatcharr-multiview/releases/tag/v0.4.2 --- plugins/multiview/config.py | 29 ++++++++++++++++++- .../{index-D909_1-I.js => index-C4ShuQoB.js} | 6 ++-- plugins/multiview/dash/static/index.html | 2 +- plugins/multiview/parameters.py | 9 ++++-- plugins/multiview/plugin.json | 2 +- plugins/multiview/server.py | 1 + 6 files changed, 40 insertions(+), 9 deletions(-) rename plugins/multiview/dash/static/assets/{index-D909_1-I.js => index-C4ShuQoB.js} (99%) diff --git a/plugins/multiview/config.py b/plugins/multiview/config.py index ebb78e6..a0cb2d2 100644 --- a/plugins/multiview/config.py +++ b/plugins/multiview/config.py @@ -1,6 +1,7 @@ """Plugin configuration and field definitions for Dispatcharr Multiview.""" import datetime +import glob import json import os import secrets @@ -134,6 +135,31 @@ def _register_presets(encoder: str, fields_fn): return +def _render_device_field() -> dict: + """Render-device override for QSV/VAAPI, populated from detected DRM nodes. + + Auto (the default) preserves the historic behavior of picking the first + /dev/dri/renderD* node. In a VM or container with multiple render nodes the + first one can be the wrong GPU, so the user can pin a specific node here. + Options are globbed on the host at field-build time, so both the native + Dispatcharr settings page and the web dashboard list the real nodes. + """ + devices = sorted(glob.glob("/dev/dri/render*")) + options = [{"value": "auto", "label": "Auto (first detected)"}] + options += [{"value": d, "label": d} for d in devices] + return { + "id": "render_device", + "label": "Render Device", + "type": "select", + "default": "auto", + "options": options, + "description": ( + "GPU render node for QSV/VAAPI. Auto picks the first detected; " + "override if you have multiple GPUs." + ), + } + + def _x264_fields() -> list: return [ { @@ -189,11 +215,12 @@ def _qsv_fields() -> list: ], "description": "QSV encode speed vs quality. Medium is recommended for live multiview.", }, + _render_device_field(), ] def _vaapi_fields() -> list: - return [] + return [_render_device_field()] _ENCODER_EXTRA_FIELDS = { diff --git a/plugins/multiview/dash/static/assets/index-D909_1-I.js b/plugins/multiview/dash/static/assets/index-C4ShuQoB.js similarity index 99% rename from plugins/multiview/dash/static/assets/index-D909_1-I.js rename to plugins/multiview/dash/static/assets/index-C4ShuQoB.js index e102a96..1092f83 100644 --- a/plugins/multiview/dash/static/assets/index-D909_1-I.js +++ b/plugins/multiview/dash/static/assets/index-C4ShuQoB.js @@ -1,4 +1,4 @@ -function P2(e,o){for(var r=0;ra[l]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))a(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&a(u)}).observe(document,{childList:!0,subtree:!0});function r(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function a(l){if(l.ep)return;l.ep=!0;const c=r(l);fetch(l.href,c)}})();function Xp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var wh={exports:{}},Kl={};var m0;function V2(){if(m0)return Kl;m0=1;var e=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function r(a,l,c){var u=null;if(c!==void 0&&(u=""+c),l.key!==void 0&&(u=""+l.key),"key"in l){c={};for(var f in l)f!=="key"&&(c[f]=l[f])}else c=l;return l=c.ref,{$$typeof:e,type:a,key:u,ref:l!==void 0?l:null,props:c}}return Kl.Fragment=o,Kl.jsx=r,Kl.jsxs=r,Kl}var g0;function Y2(){return g0||(g0=1,wh.exports=V2()),wh.exports}var y=Y2(),Ch={exports:{}},ze={};var v0;function G2(){if(v0)return ze;v0=1;var e=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),x=Symbol.iterator;function S(D){return D===null||typeof D!="object"?null:(D=x&&D[x]||D["@@iterator"],typeof D=="function"?D:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,R={};function T(D,O,q){this.props=D,this.context=O,this.refs=R,this.updater=q||E}T.prototype.isReactComponent={},T.prototype.setState=function(D,O){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,O,"setState")},T.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function z(){}z.prototype=T.prototype;function A(D,O,q){this.props=D,this.context=O,this.refs=R,this.updater=q||E}var N=A.prototype=new z;N.constructor=A,C(N,T.prototype),N.isPureReactComponent=!0;var B=Array.isArray;function M(){}var $={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function H(D,O,q){var W=q.ref;return{$$typeof:e,type:D,key:O,ref:W!==void 0?W:null,props:q}}function I(D,O){return H(D.type,O,D.props)}function Y(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function X(D){var O={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(q){return O[q]})}var ee=/\/+/g;function ne(D,O){return typeof D=="object"&&D!==null&&D.key!=null?X(""+D.key):O.toString(36)}function re(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(M,M):(D.status="pending",D.then(function(O){D.status==="pending"&&(D.status="fulfilled",D.value=O)},function(O){D.status==="pending"&&(D.status="rejected",D.reason=O)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function j(D,O,q,W,ie){var ue=typeof D;(ue==="undefined"||ue==="boolean")&&(D=null);var ve=!1;if(D===null)ve=!0;else switch(ue){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(D.$$typeof){case e:case o:ve=!0;break;case g:return ve=D._init,j(ve(D._payload),O,q,W,ie)}}if(ve)return ie=ie(D),ve=W===""?"."+ne(D,0):W,B(ie)?(q="",ve!=null&&(q=ve.replace(ee,"$&/")+"/"),j(ie,O,q,"",function(ye){return ye})):ie!=null&&(Y(ie)&&(ie=I(ie,q+(ie.key==null||D&&D.key===ie.key?"":(""+ie.key).replace(ee,"$&/")+"/")+ve)),O.push(ie)),1;ve=0;var fe=W===""?".":W+":";if(B(D))for(var be=0;be>>1,Z=j[P];if(0>>1;Pl(q,V))Wl(ie,q)?(j[P]=ie,j[W]=V,P=W):(j[P]=q,j[O]=V,P=O);else if(Wl(ie,V))j[P]=ie,j[W]=V,P=W;else break e}}return k}function l(j,k){var V=j.sortIndex-k.sortIndex;return V!==0?V:j.id-k.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();e.unstable_now=function(){return u.now()-f}}var h=[],p=[],g=1,v=null,x=3,S=!1,E=!1,C=!1,R=!1,T=typeof setTimeout=="function"?setTimeout:null,z=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function N(j){for(var k=r(p);k!==null;){if(k.callback===null)a(p);else if(k.startTime<=j)a(p),k.sortIndex=k.expirationTime,o(h,k);else break;k=r(p)}}function B(j){if(C=!1,N(j),!E)if(r(h)!==null)E=!0,M||(M=!0,X());else{var k=r(p);k!==null&&re(B,k.startTime-j)}}var M=!1,$=-1,L=5,H=-1;function I(){return R?!0:!(e.unstable_now()-Hj&&I());){var P=v.callback;if(typeof P=="function"){v.callback=null,x=v.priorityLevel;var Z=P(v.expirationTime<=j);if(j=e.unstable_now(),typeof Z=="function"){v.callback=Z,N(j),k=!0;break t}v===r(h)&&a(h),N(j)}else a(h);v=r(h)}if(v!==null)k=!0;else{var D=r(p);D!==null&&re(B,D.startTime-j),k=!1}}break e}finally{v=null,x=V,S=!1}k=void 0}}finally{k?X():M=!1}}}var X;if(typeof A=="function")X=function(){A(Y)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,ne=ee.port2;ee.port1.onmessage=Y,X=function(){ne.postMessage(null)}}else X=function(){T(Y,0)};function re(j,k){$=T(function(){j(e.unstable_now())},k)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(j){j.callback=null},e.unstable_forceFrameRate=function(j){0>j||125P?(j.sortIndex=V,o(p,j),r(h)===null&&j===r(p)&&(C?(z($),$=-1):C=!0,re(B,V-P))):(j.sortIndex=Z,o(h,j),E||S||(E=!0,M||(M=!0,X()))),j},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(j){var k=x;return function(){var V=x;x=k;try{return j.apply(this,arguments)}finally{x=V}}}})(Th)),Th}var x0;function I2(){return x0||(x0=1,Rh.exports=q2()),Rh.exports}var _h={exports:{}},an={};var S0;function F2(){if(S0)return an;S0=1;var e=qp();function o(h){var p="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(o){console.error(o)}}return e(),_h.exports=F2(),_h.exports}var C0;function Z2(){if(C0)return Wl;C0=1;var e=I2(),o=qp(),r=lx();function a(t){var n="https://react.dev/errors/"+t;if(1Z||(t.current=P[Z],P[Z]=null,Z--)}function q(t,n){Z++,P[Z]=t.current,t.current=n}var W=D(null),ie=D(null),ue=D(null),ve=D(null);function fe(t,n){switch(q(ue,n),q(ie,t),q(W,null),n.nodeType){case 9:case 11:t=(t=n.documentElement)&&(t=t.namespaceURI)?kb(t):0;break;default:if(t=n.tagName,n=n.namespaceURI)n=kb(n),t=Hb(n,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}O(W),q(W,t)}function be(){O(W),O(ie),O(ue)}function ye(t){t.memoizedState!==null&&q(ve,t);var n=W.current,i=Hb(n,t.type);n!==i&&(q(ie,t),q(W,i))}function Xe(t){ie.current===t&&(O(W),O(ie)),ve.current===t&&(O(ve),Il._currentValue=V)}var Ne,We;function Be(t){if(Ne===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);Ne=n&&n[1]||"",We=-1a[l]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))a(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&a(u)}).observe(document,{childList:!0,subtree:!0});function r(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function a(l){if(l.ep)return;l.ep=!0;const c=r(l);fetch(l.href,c)}})();function Xp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var wh={exports:{}},Kl={};var m0;function V2(){if(m0)return Kl;m0=1;var e=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function r(a,l,c){var u=null;if(c!==void 0&&(u=""+c),l.key!==void 0&&(u=""+l.key),"key"in l){c={};for(var f in l)f!=="key"&&(c[f]=l[f])}else c=l;return l=c.ref,{$$typeof:e,type:a,key:u,ref:l!==void 0?l:null,props:c}}return Kl.Fragment=o,Kl.jsx=r,Kl.jsxs=r,Kl}var g0;function Y2(){return g0||(g0=1,wh.exports=V2()),wh.exports}var y=Y2(),Ch={exports:{}},ze={};var v0;function G2(){if(v0)return ze;v0=1;var e=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),x=Symbol.iterator;function S(D){return D===null||typeof D!="object"?null:(D=x&&D[x]||D["@@iterator"],typeof D=="function"?D:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,R={};function T(D,O,q){this.props=D,this.context=O,this.refs=R,this.updater=q||E}T.prototype.isReactComponent={},T.prototype.setState=function(D,O){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,O,"setState")},T.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function z(){}z.prototype=T.prototype;function A(D,O,q){this.props=D,this.context=O,this.refs=R,this.updater=q||E}var N=A.prototype=new z;N.constructor=A,C(N,T.prototype),N.isPureReactComponent=!0;var B=Array.isArray;function M(){}var $={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function H(D,O,q){var W=q.ref;return{$$typeof:e,type:D,key:O,ref:W!==void 0?W:null,props:q}}function I(D,O){return H(D.type,O,D.props)}function Y(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function X(D){var O={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(q){return O[q]})}var ee=/\/+/g;function ne(D,O){return typeof D=="object"&&D!==null&&D.key!=null?X(""+D.key):O.toString(36)}function re(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(M,M):(D.status="pending",D.then(function(O){D.status==="pending"&&(D.status="fulfilled",D.value=O)},function(O){D.status==="pending"&&(D.status="rejected",D.reason=O)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function j(D,O,q,W,ie){var ue=typeof D;(ue==="undefined"||ue==="boolean")&&(D=null);var ve=!1;if(D===null)ve=!0;else switch(ue){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(D.$$typeof){case e:case o:ve=!0;break;case g:return ve=D._init,j(ve(D._payload),O,q,W,ie)}}if(ve)return ie=ie(D),ve=W===""?"."+ne(D,0):W,B(ie)?(q="",ve!=null&&(q=ve.replace(ee,"$&/")+"/"),j(ie,O,q,"",function(ye){return ye})):ie!=null&&(Y(ie)&&(ie=I(ie,q+(ie.key==null||D&&D.key===ie.key?"":(""+ie.key).replace(ee,"$&/")+"/")+ve)),O.push(ie)),1;ve=0;var fe=W===""?".":W+":";if(B(D))for(var be=0;be>>1,Z=j[P];if(0>>1;Pl(q,V))Wl(ie,q)?(j[P]=ie,j[W]=V,P=W):(j[P]=q,j[O]=V,P=O);else if(Wl(ie,V))j[P]=ie,j[W]=V,P=W;else break e}}return k}function l(j,k){var V=j.sortIndex-k.sortIndex;return V!==0?V:j.id-k.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();e.unstable_now=function(){return u.now()-f}}var h=[],p=[],g=1,v=null,x=3,S=!1,E=!1,C=!1,R=!1,T=typeof setTimeout=="function"?setTimeout:null,z=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function N(j){for(var k=r(p);k!==null;){if(k.callback===null)a(p);else if(k.startTime<=j)a(p),k.sortIndex=k.expirationTime,o(h,k);else break;k=r(p)}}function B(j){if(C=!1,N(j),!E)if(r(h)!==null)E=!0,M||(M=!0,X());else{var k=r(p);k!==null&&re(B,k.startTime-j)}}var M=!1,$=-1,L=5,H=-1;function I(){return R?!0:!(e.unstable_now()-Hj&&I());){var P=v.callback;if(typeof P=="function"){v.callback=null,x=v.priorityLevel;var Z=P(v.expirationTime<=j);if(j=e.unstable_now(),typeof Z=="function"){v.callback=Z,N(j),k=!0;break t}v===r(h)&&a(h),N(j)}else a(h);v=r(h)}if(v!==null)k=!0;else{var D=r(p);D!==null&&re(B,D.startTime-j),k=!1}}break e}finally{v=null,x=V,S=!1}k=void 0}}finally{k?X():M=!1}}}var X;if(typeof A=="function")X=function(){A(Y)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,ne=ee.port2;ee.port1.onmessage=Y,X=function(){ne.postMessage(null)}}else X=function(){T(Y,0)};function re(j,k){$=T(function(){j(e.unstable_now())},k)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(j){j.callback=null},e.unstable_forceFrameRate=function(j){0>j||125P?(j.sortIndex=V,o(p,j),r(h)===null&&j===r(p)&&(C?(z($),$=-1):C=!0,re(B,V-P))):(j.sortIndex=Z,o(h,j),E||S||(E=!0,M||(M=!0,X()))),j},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(j){var k=x;return function(){var V=x;x=k;try{return j.apply(this,arguments)}finally{x=V}}}})(Th)),Th}var x0;function I2(){return x0||(x0=1,Rh.exports=q2()),Rh.exports}var _h={exports:{}},an={};var S0;function F2(){if(S0)return an;S0=1;var e=qp();function o(h){var p="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(o){console.error(o)}}return e(),_h.exports=F2(),_h.exports}var C0;function Z2(){if(C0)return Wl;C0=1;var e=I2(),o=qp(),r=lx();function a(t){var n="https://react.dev/errors/"+t;if(1Z||(t.current=P[Z],P[Z]=null,Z--)}function q(t,n){Z++,P[Z]=t.current,t.current=n}var W=D(null),ie=D(null),ue=D(null),ve=D(null);function fe(t,n){switch(q(ue,n),q(ie,t),q(W,null),n.nodeType){case 9:case 11:t=(t=n.documentElement)&&(t=t.namespaceURI)?kb(t):0;break;default:if(t=n.tagName,n=n.namespaceURI)n=kb(n),t=Hb(n,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}O(W),q(W,t)}function be(){O(W),O(ie),O(ue)}function ye(t){t.memoizedState!==null&&q(ve,t);var n=W.current,i=Hb(n,t.type);n!==i&&(q(ie,t),q(W,i))}function Xe(t){ie.current===t&&(O(W),O(ie)),ve.current===t&&(O(ve),Il._currentValue=V)}var Ne,We;function Be(t){if(Ne===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);Ne=n&&n[1]||"",We=-1)":-1")&&(ae=ae.replace("",t.displayName)),ae}while(1<=s&&0<=d);break}}}finally{nt=!1,Error.prepareStackTrace=i}return(i=t?t.displayName||t.name:"")?Be(i):""}function pe(t,n){switch(t.tag){case 26:case 27:case 5:return Be(t.type);case 16:return Be("Lazy");case 13:return t.child!==n&&n!==null?Be("Suspense Fallback"):Be("Suspense");case 19:return Be("SuspenseList");case 0:case 15:return vt(t.type,!1);case 11:return vt(t.type.render,!1);case 1:return vt(t.type,!0);case 31:return Be("Activity");default:return""}}function me(t){try{var n="",i=null;do n+=pe(t,i),i=t,t=t.return;while(t);return n}catch(s){return` Error generating stack: `+s.message+` `+s.stack}}var we=Object.prototype.hasOwnProperty,De=e.unstable_scheduleCallback,Ae=e.unstable_cancelCallback,xe=e.unstable_shouldYield,$e=e.unstable_requestPaint,de=e.unstable_now,Re=e.unstable_getCurrentPriorityLevel,dt=e.unstable_ImmediatePriority,ot=e.unstable_UserBlockingPriority,yt=e.unstable_NormalPriority,Je=e.unstable_LowPriority,wt=e.unstable_IdlePriority,on=e.log,Qr=e.unstable_setDisableYieldValue,jo=null,Gt=null;function st(t){if(typeof on=="function"&&Qr(t),Gt&&typeof Gt.setStrictMode=="function")try{Gt.setStrictMode(jo,t)}catch{}}var Ct=Math.clz32?Math.clz32:df,Kr=Math.log,Ms=Math.LN2;function df(t){return t>>>=0,t===0?32:31-(Kr(t)/Ms|0)|0}var Ba=256,$a=262144,Et=4194304;function Rt(t){var n=t&42;if(n!==0)return n;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Xt(t,n,i){var s=t.pendingLanes;if(s===0)return 0;var d=0,m=t.suspendedLanes,w=t.pingedLanes;t=t.warmLanes;var _=s&134217727;return _!==0?(s=_&~m,s!==0?d=Rt(s):(w&=_,w!==0?d=Rt(w):i||(i=_&~t,i!==0&&(d=Rt(i))))):(_=s&~m,_!==0?d=Rt(_):w!==0?d=Rt(w):i||(i=s&~t,i!==0&&(d=Rt(i)))),d===0?0:n!==0&&n!==d&&(n&m)===0&&(m=d&-d,i=n&-n,m>=i||m===32&&(i&4194048)!==0)?n:d}function hn(t,n){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&n)===0}function pn(t,n){switch(t){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function rn(){var t=Et;return Et<<=1,(Et&62914560)===0&&(Et=4194304),t}function mn(t){for(var n=[],i=0;31>i;i++)n.push(t);return n}function Ln(t,n){t.pendingLanes|=n,n!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Ht(t,n,i,s,d,m){var w=t.pendingLanes;t.pendingLanes=i,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=i,t.entangledLanes&=i,t.errorRecoveryDisabledLanes&=i,t.shellSuspendCounter=0;var _=t.entanglements,U=t.expirationTimes,K=t.hiddenUpdates;for(i=w&~i;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var BC=/[\n"\\]/g;function Pn(t){return t.replace(BC,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function gf(t,n,i,s,d,m,w,_){t.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?t.type=w:t.removeAttribute("type"),n!=null?w==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+Un(n)):t.value!==""+Un(n)&&(t.value=""+Un(n)):w!=="submit"&&w!=="reset"||t.removeAttribute("value"),n!=null?vf(t,w,Un(n)):i!=null?vf(t,w,Un(i)):s!=null&&t.removeAttribute("value"),d==null&&m!=null&&(t.defaultChecked=!!m),d!=null&&(t.checked=d&&typeof d!="function"&&typeof d!="symbol"),_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?t.name=""+Un(_):t.removeAttribute("name")}function Mg(t,n,i,s,d,m,w,_){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(t.type=m),n!=null||i!=null){if(!(m!=="submit"&&m!=="reset"||n!=null)){mf(t);return}i=i!=null?""+Un(i):"",n=n!=null?""+Un(n):i,_||n===t.value||(t.value=n),t.defaultValue=n}s=s??d,s=typeof s!="function"&&typeof s!="symbol"&&!!s,t.checked=_?t.checked:!!s,t.defaultChecked=!!s,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(t.name=w),mf(t)}function vf(t,n,i){n==="number"&&Bs(t.ownerDocument)===t||t.defaultValue===""+i||(t.defaultValue=""+i)}function Va(t,n,i,s){if(t=t.options,n){n={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wf=!1;if(Ho)try{var fl={};Object.defineProperty(fl,"passive",{get:function(){wf=!0}}),window.addEventListener("test",fl,fl),window.removeEventListener("test",fl,fl)}catch{wf=!1}var pr=null,Cf=null,Ls=null;function Hg(){if(Ls)return Ls;var t,n=Cf,i=n.length,s,d="value"in pr?pr.value:pr.textContent,m=d.length;for(t=0;t=pl),Xg=" ",qg=!1;function Ig(t,n){switch(t){case"keyup":return cE.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Fg(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var qa=!1;function fE(t,n){switch(t){case"compositionend":return Fg(n);case"keypress":return n.which!==32?null:(qg=!0,Xg);case"textInput":return t=n.data,t===Xg&&qg?null:t;default:return null}}function dE(t,n){if(qa)return t==="compositionend"||!Df&&Ig(t,n)?(t=Hg(),Ls=Cf=pr=null,qa=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-t};t=s}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=nv(i)}}function rv(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?rv(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function av(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var n=Bs(t.document);n instanceof t.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)t=n.contentWindow;else break;n=Bs(t.document)}return n}function zf(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n&&(n==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||n==="textarea"||t.contentEditable==="true")}var xE=Ho&&"documentMode"in document&&11>=document.documentMode,Ia=null,Mf=null,yl=null,Of=!1;function iv(t,n,i){var s=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Of||Ia==null||Ia!==Bs(s)||(s=Ia,"selectionStart"in s&&zf(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),yl&&vl(yl,s)||(yl=s,s=Ac(Mf,"onSelect"),0>=w,d-=w,bo=1<<32-Ct(n)+d|i<Oe?(Ue=Ce,Ce=null):Ue=Ce.sibling;var Fe=J(F,Ce,Q[Oe],le);if(Fe===null){Ce===null&&(Ce=Ue);break}t&&Ce&&Fe.alternate===null&&n(F,Ce),G=m(Fe,G,Oe),Ie===null?Ee=Fe:Ie.sibling=Fe,Ie=Fe,Ce=Ue}if(Oe===Q.length)return i(F,Ce),Ve&&Po(F,Oe),Ee;if(Ce===null){for(;OeOe?(Ue=Ce,Ce=null):Ue=Ce.sibling;var $r=J(F,Ce,Fe.value,le);if($r===null){Ce===null&&(Ce=Ue);break}t&&Ce&&$r.alternate===null&&n(F,Ce),G=m($r,G,Oe),Ie===null?Ee=$r:Ie.sibling=$r,Ie=$r,Ce=Ue}if(Fe.done)return i(F,Ce),Ve&&Po(F,Oe),Ee;if(Ce===null){for(;!Fe.done;Oe++,Fe=Q.next())Fe=se(F,Fe.value,le),Fe!==null&&(G=m(Fe,G,Oe),Ie===null?Ee=Fe:Ie.sibling=Fe,Ie=Fe);return Ve&&Po(F,Oe),Ee}for(Ce=s(Ce);!Fe.done;Oe++,Fe=Q.next())Fe=te(Ce,F,Oe,Fe.value,le),Fe!==null&&(t&&Fe.alternate!==null&&Ce.delete(Fe.key===null?Oe:Fe.key),G=m(Fe,G,Oe),Ie===null?Ee=Fe:Ie.sibling=Fe,Ie=Fe);return t&&Ce.forEach(function(U2){return n(F,U2)}),Ve&&Po(F,Oe),Ee}function it(F,G,Q,le){if(typeof Q=="object"&&Q!==null&&Q.type===C&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:e:{for(var Ee=Q.key;G!==null;){if(G.key===Ee){if(Ee=Q.type,Ee===C){if(G.tag===7){i(F,G.sibling),le=d(G,Q.props.children),le.return=F,F=le;break e}}else if(G.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===L&&sa(Ee)===G.type){i(F,G.sibling),le=d(G,Q.props),El(le,Q),le.return=F,F=le;break e}i(F,G);break}else n(F,G);G=G.sibling}Q.type===C?(le=oa(Q.props.children,F.mode,le,Q.key),le.return=F,F=le):(le=Is(Q.type,Q.key,Q.props,null,F.mode,le),El(le,Q),le.return=F,F=le)}return w(F);case E:e:{for(Ee=Q.key;G!==null;){if(G.key===Ee)if(G.tag===4&&G.stateNode.containerInfo===Q.containerInfo&&G.stateNode.implementation===Q.implementation){i(F,G.sibling),le=d(G,Q.children||[]),le.return=F,F=le;break e}else{i(F,G);break}else n(F,G);G=G.sibling}le=Uf(Q,F.mode,le),le.return=F,F=le}return w(F);case L:return Q=sa(Q),it(F,G,Q,le)}if(re(Q))return Se(F,G,Q,le);if(X(Q)){if(Ee=X(Q),typeof Ee!="function")throw Error(a(150));return Q=Ee.call(Q),Te(F,G,Q,le)}if(typeof Q.then=="function")return it(F,G,ec(Q),le);if(Q.$$typeof===A)return it(F,G,Qs(F,Q),le);tc(F,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint"?(Q=""+Q,G!==null&&G.tag===6?(i(F,G.sibling),le=d(G,Q),le.return=F,F=le):(i(F,G),le=Hf(Q,F.mode,le),le.return=F,F=le),w(F)):i(F,G)}return function(F,G,Q,le){try{Cl=0;var Ee=it(F,G,Q,le);return ri=null,Ee}catch(Ce){if(Ce===oi||Ce===Ws)throw Ce;var Ie=An(29,Ce,null,F.mode);return Ie.lanes=le,Ie.return=F,Ie}}}var ua=Nv(!0),Av=Nv(!1),br=!1;function Wf(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Jf(t,n){t=t.updateQueue,n.updateQueue===t&&(n.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function xr(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Sr(t,n,i){var s=t.updateQueue;if(s===null)return null;if(s=s.shared,(Ze&2)!==0){var d=s.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),s.pending=n,n=qs(t),hv(t,null,i),n}return Xs(t,s,n,i),qs(t)}function Rl(t,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194048)!==0)){var s=n.lanes;s&=t.pendingLanes,i|=s,n.lanes=i,Dn(t,i)}}function ed(t,n){var i=t.updateQueue,s=t.alternate;if(s!==null&&(s=s.updateQueue,i===s)){var d=null,m=null;if(i=i.firstBaseUpdate,i!==null){do{var w={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};m===null?d=m=w:m=m.next=w,i=i.next}while(i!==null);m===null?d=m=n:m=m.next=n}else d=m=n;i={baseState:s.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:s.shared,callbacks:s.callbacks},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=n:t.next=n,i.lastBaseUpdate=n}var td=!1;function Tl(){if(td){var t=ni;if(t!==null)throw t}}function _l(t,n,i,s){td=!1;var d=t.updateQueue;br=!1;var m=d.firstBaseUpdate,w=d.lastBaseUpdate,_=d.shared.pending;if(_!==null){d.shared.pending=null;var U=_,K=U.next;U.next=null,w===null?m=K:w.next=K,w=U;var ae=t.alternate;ae!==null&&(ae=ae.updateQueue,_=ae.lastBaseUpdate,_!==w&&(_===null?ae.firstBaseUpdate=K:_.next=K,ae.lastBaseUpdate=U))}if(m!==null){var se=d.baseState;w=0,ae=K=U=null,_=m;do{var J=_.lane&-536870913,te=J!==_.lane;if(te?(He&J)===J:(s&J)===J){J!==0&&J===ti&&(td=!0),ae!==null&&(ae=ae.next={lane:0,tag:_.tag,payload:_.payload,callback:null,next:null});e:{var Se=t,Te=_;J=n;var it=i;switch(Te.tag){case 1:if(Se=Te.payload,typeof Se=="function"){se=Se.call(it,se,J);break e}se=Se;break e;case 3:Se.flags=Se.flags&-65537|128;case 0:if(Se=Te.payload,J=typeof Se=="function"?Se.call(it,se,J):Se,J==null)break e;se=v({},se,J);break e;case 2:br=!0}}J=_.callback,J!==null&&(t.flags|=64,te&&(t.flags|=8192),te=d.callbacks,te===null?d.callbacks=[J]:te.push(J))}else te={lane:J,tag:_.tag,payload:_.payload,callback:_.callback,next:null},ae===null?(K=ae=te,U=se):ae=ae.next=te,w|=J;if(_=_.next,_===null){if(_=d.shared.pending,_===null)break;te=_,_=te.next,te.next=null,d.lastBaseUpdate=te,d.shared.pending=null}}while(!0);ae===null&&(U=se),d.baseState=U,d.firstBaseUpdate=K,d.lastBaseUpdate=ae,m===null&&(d.shared.lanes=0),Tr|=w,t.lanes=w,t.memoizedState=se}}function zv(t,n){if(typeof t!="function")throw Error(a(191,t));t.call(n)}function Mv(t,n){var i=t.callbacks;if(i!==null)for(t.callbacks=null,t=0;tm?m:8;var w=j.T,_={};j.T=_,xd(t,!1,n,i);try{var U=d(),K=j.S;if(K!==null&&K(_,U),U!==null&&typeof U=="object"&&typeof U.then=="function"){var ae=NE(U,s);Al(t,n,ae,Bn(t))}else Al(t,n,s,Bn(t))}catch(se){Al(t,n,{then:function(){},status:"rejected",reason:se},Bn())}finally{k.p=m,w!==null&&_.types!==null&&(w.types=_.types),j.T=w}}function BE(){}function yd(t,n,i,s){if(t.tag!==5)throw Error(a(476));var d=uy(t).queue;cy(t,d,n,V,i===null?BE:function(){return fy(t),i(s)})}function uy(t){var n=t.memoizedState;if(n!==null)return n;n={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xo,lastRenderedState:V},next:null};var i={};return n.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xo,lastRenderedState:i},next:null},t.memoizedState=n,t=t.alternate,t!==null&&(t.memoizedState=n),n}function fy(t){var n=uy(t);n.next===null&&(n=t.alternate.memoizedState),Al(t,n.next.queue,{},Bn())}function bd(){return Jt(Il)}function dy(){return _t().memoizedState}function hy(){return _t().memoizedState}function $E(t){for(var n=t.return;n!==null;){switch(n.tag){case 24:case 3:var i=Bn();t=xr(i);var s=Sr(n,t,i);s!==null&&(wn(s,n,i),Rl(s,n,i)),n={cache:Ff()},t.payload=n;return}n=n.return}}function LE(t,n,i){var s=Bn();i={lane:s,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},fc(t)?my(n,i):(i=Lf(t,n,i,s),i!==null&&(wn(i,t,s),gy(i,n,s)))}function py(t,n,i){var s=Bn();Al(t,n,i,s)}function Al(t,n,i,s){var d={lane:s,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(fc(t))my(n,d);else{var m=t.alternate;if(t.lanes===0&&(m===null||m.lanes===0)&&(m=n.lastRenderedReducer,m!==null))try{var w=n.lastRenderedState,_=m(w,i);if(d.hasEagerState=!0,d.eagerState=_,Nn(_,w))return Xs(t,n,d,0),ct===null&&Gs(),!1}catch{}if(i=Lf(t,n,d,s),i!==null)return wn(i,t,s),gy(i,n,s),!0}return!1}function xd(t,n,i,s){if(s={lane:2,revertLane:Wd(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},fc(t)){if(n)throw Error(a(479))}else n=Lf(t,i,s,2),n!==null&&wn(n,t,2)}function fc(t){var n=t.alternate;return t===Me||n!==null&&n===Me}function my(t,n){ii=rc=!0;var i=t.pending;i===null?n.next=n:(n.next=i.next,i.next=n),t.pending=n}function gy(t,n,i){if((i&4194048)!==0){var s=n.lanes;s&=t.pendingLanes,i|=s,n.lanes=i,Dn(t,i)}}var zl={readContext:Jt,use:lc,useCallback:bt,useContext:bt,useEffect:bt,useImperativeHandle:bt,useLayoutEffect:bt,useInsertionEffect:bt,useMemo:bt,useReducer:bt,useRef:bt,useState:bt,useDebugValue:bt,useDeferredValue:bt,useTransition:bt,useSyncExternalStore:bt,useId:bt,useHostTransitionStatus:bt,useFormState:bt,useActionState:bt,useOptimistic:bt,useMemoCache:bt,useCacheRefresh:bt};zl.useEffectEvent=bt;var vy={readContext:Jt,use:lc,useCallback:function(t,n){return fn().memoizedState=[t,n===void 0?null:n],t},useContext:Jt,useEffect:ey,useImperativeHandle:function(t,n,i){i=i!=null?i.concat([t]):null,cc(4194308,4,ry.bind(null,n,t),i)},useLayoutEffect:function(t,n){return cc(4194308,4,t,n)},useInsertionEffect:function(t,n){cc(4,2,t,n)},useMemo:function(t,n){var i=fn();n=n===void 0?null:n;var s=t();if(fa){st(!0);try{t()}finally{st(!1)}}return i.memoizedState=[s,n],s},useReducer:function(t,n,i){var s=fn();if(i!==void 0){var d=i(n);if(fa){st(!0);try{i(n)}finally{st(!1)}}}else d=n;return s.memoizedState=s.baseState=d,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:d},s.queue=t,t=t.dispatch=LE.bind(null,Me,t),[s.memoizedState,t]},useRef:function(t){var n=fn();return t={current:t},n.memoizedState=t},useState:function(t){t=hd(t);var n=t.queue,i=py.bind(null,Me,n);return n.dispatch=i,[t.memoizedState,i]},useDebugValue:gd,useDeferredValue:function(t,n){var i=fn();return vd(i,t,n)},useTransition:function(){var t=hd(!1);return t=cy.bind(null,Me,t.queue,!0,!1),fn().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,n,i){var s=Me,d=fn();if(Ve){if(i===void 0)throw Error(a(407));i=i()}else{if(i=n(),ct===null)throw Error(a(349));(He&127)!==0||kv(s,n,i)}d.memoizedState=i;var m={value:i,getSnapshot:n};return d.queue=m,ey(Uv.bind(null,s,m,t),[t]),s.flags|=2048,si(9,{destroy:void 0},Hv.bind(null,s,m,i,n),null),i},useId:function(){var t=fn(),n=ct.identifierPrefix;if(Ve){var i=xo,s=bo;i=(s&~(1<<32-Ct(s)-1)).toString(32)+i,n="_"+n+"R_"+i,i=ac++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof s.is=="string"?w.createElement("select",{is:s.is}):w.createElement("select"),s.multiple?m.multiple=!0:s.size&&(m.size=s.size);break;default:m=typeof s.is=="string"?w.createElement(d,{is:s.is}):w.createElement(d)}}m[Kt]=n,m[gn]=s;e:for(w=n.child;w!==null;){if(w.tag===5||w.tag===6)m.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===n)break e;for(;w.sibling===null;){if(w.return===null||w.return===n)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}n.stateNode=m;e:switch(tn(m,d,s),d){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}s&&Io(n)}}return ft(n),jd(n,n.type,t===null?null:t.memoizedProps,n.pendingProps,i),null;case 6:if(t&&n.stateNode!=null)t.memoizedProps!==s&&Io(n);else{if(typeof s!="string"&&n.stateNode===null)throw Error(a(166));if(t=ue.current,Ja(n)){if(t=n.stateNode,i=n.memoizedProps,s=null,d=Wt,d!==null)switch(d.tag){case 27:case 5:s=d.memoizedProps}t[Kt]=n,t=!!(t.nodeValue===i||s!==null&&s.suppressHydrationWarning===!0||$b(t.nodeValue,i)),t||vr(n,!0)}else t=zc(t).createTextNode(s),t[Kt]=n,n.stateNode=t}return ft(n),null;case 31:if(i=n.memoizedState,t===null||t.memoizedState!==null){if(s=Ja(n),i!==null){if(t===null){if(!s)throw Error(a(318));if(t=n.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(a(557));t[Kt]=n}else ra(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;ft(n),t=!1}else i=Gf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=i),t=!0;if(!t)return n.flags&256?(Mn(n),n):(Mn(n),null);if((n.flags&128)!==0)throw Error(a(558))}return ft(n),null;case 13:if(s=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(d=Ja(n),s!==null&&s.dehydrated!==null){if(t===null){if(!d)throw Error(a(318));if(d=n.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(a(317));d[Kt]=n}else ra(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;ft(n),d=!1}else d=Gf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=d),d=!0;if(!d)return n.flags&256?(Mn(n),n):(Mn(n),null)}return Mn(n),(n.flags&128)!==0?(n.lanes=i,n):(i=s!==null,t=t!==null&&t.memoizedState!==null,i&&(s=n.child,d=null,s.alternate!==null&&s.alternate.memoizedState!==null&&s.alternate.memoizedState.cachePool!==null&&(d=s.alternate.memoizedState.cachePool.pool),m=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(m=s.memoizedState.cachePool.pool),m!==d&&(s.flags|=2048)),i!==t&&i&&(n.child.flags|=8192),gc(n,n.updateQueue),ft(n),null);case 4:return be(),t===null&&nh(n.stateNode.containerInfo),ft(n),null;case 10:return Yo(n.type),ft(n),null;case 19:if(O(Tt),s=n.memoizedState,s===null)return ft(n),null;if(d=(n.flags&128)!==0,m=s.rendering,m===null)if(d)Ol(s,!1);else{if(xt!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(m=oc(t),m!==null){for(n.flags|=128,Ol(s,!1),t=m.updateQueue,n.updateQueue=t,gc(n,t),n.subtreeFlags=0,t=i,i=n.child;i!==null;)pv(i,t),i=i.sibling;return q(Tt,Tt.current&1|2),Ve&&Po(n,s.treeForkCount),n.child}t=t.sibling}s.tail!==null&&de()>Sc&&(n.flags|=128,d=!0,Ol(s,!1),n.lanes=4194304)}else{if(!d)if(t=oc(m),t!==null){if(n.flags|=128,d=!0,t=t.updateQueue,n.updateQueue=t,gc(n,t),Ol(s,!0),s.tail===null&&s.tailMode==="hidden"&&!m.alternate&&!Ve)return ft(n),null}else 2*de()-s.renderingStartTime>Sc&&i!==536870912&&(n.flags|=128,d=!0,Ol(s,!1),n.lanes=4194304);s.isBackwards?(m.sibling=n.child,n.child=m):(t=s.last,t!==null?t.sibling=m:n.child=m,s.last=m)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=de(),t.sibling=null,i=Tt.current,q(Tt,d?i&1|2:i&1),Ve&&Po(n,s.treeForkCount),t):(ft(n),null);case 22:case 23:return Mn(n),od(),s=n.memoizedState!==null,t!==null?t.memoizedState!==null!==s&&(n.flags|=8192):s&&(n.flags|=8192),s?(i&536870912)!==0&&(n.flags&128)===0&&(ft(n),n.subtreeFlags&6&&(n.flags|=8192)):ft(n),i=n.updateQueue,i!==null&&gc(n,i.retryQueue),i=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),s=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(s=n.memoizedState.cachePool.pool),s!==i&&(n.flags|=2048),t!==null&&O(la),null;case 24:return i=null,t!==null&&(i=t.memoizedState.cache),n.memoizedState.cache!==i&&(n.flags|=2048),Yo(Ot),ft(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function VE(t,n){switch(Vf(n),n.tag){case 1:return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return Yo(Ot),be(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 26:case 27:case 5:return Xe(n),null;case 31:if(n.memoizedState!==null){if(Mn(n),n.alternate===null)throw Error(a(340));ra()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 13:if(Mn(n),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(a(340));ra()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return O(Tt),null;case 4:return be(),null;case 10:return Yo(n.type),null;case 22:case 23:return Mn(n),od(),t!==null&&O(la),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 24:return Yo(Ot),null;case 25:return null;default:return null}}function Py(t,n){switch(Vf(n),n.tag){case 3:Yo(Ot),be();break;case 26:case 27:case 5:Xe(n);break;case 4:be();break;case 31:n.memoizedState!==null&&Mn(n);break;case 13:Mn(n);break;case 19:O(Tt);break;case 10:Yo(n.type);break;case 22:case 23:Mn(n),od(),t!==null&&O(la);break;case 24:Yo(Ot)}}function jl(t,n){try{var i=n.updateQueue,s=i!==null?i.lastEffect:null;if(s!==null){var d=s.next;i=d;do{if((i.tag&t)===t){s=void 0;var m=i.create,w=i.inst;s=m(),w.destroy=s}i=i.next}while(i!==d)}}catch(_){tt(n,n.return,_)}}function Er(t,n,i){try{var s=n.updateQueue,d=s!==null?s.lastEffect:null;if(d!==null){var m=d.next;s=m;do{if((s.tag&t)===t){var w=s.inst,_=w.destroy;if(_!==void 0){w.destroy=void 0,d=n;var U=i,K=_;try{K()}catch(ae){tt(d,U,ae)}}}s=s.next}while(s!==m)}}catch(ae){tt(n,n.return,ae)}}function Vy(t){var n=t.updateQueue;if(n!==null){var i=t.stateNode;try{Mv(n,i)}catch(s){tt(t,t.return,s)}}}function Yy(t,n,i){i.props=da(t.type,t.memoizedProps),i.state=t.memoizedState;try{i.componentWillUnmount()}catch(s){tt(t,n,s)}}function Bl(t,n){try{var i=t.ref;if(i!==null){switch(t.tag){case 26:case 27:case 5:var s=t.stateNode;break;case 30:s=t.stateNode;break;default:s=t.stateNode}typeof i=="function"?t.refCleanup=i(s):i.current=s}}catch(d){tt(t,n,d)}}function So(t,n){var i=t.ref,s=t.refCleanup;if(i!==null)if(typeof s=="function")try{s()}catch(d){tt(t,n,d)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(d){tt(t,n,d)}else i.current=null}function Gy(t){var n=t.type,i=t.memoizedProps,s=t.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":i.autoFocus&&s.focus();break e;case"img":i.src?s.src=i.src:i.srcSet&&(s.srcset=i.srcSet)}}catch(d){tt(t,t.return,d)}}function Bd(t,n,i){try{var s=t.stateNode;u2(s,t.type,i,n),s[gn]=n}catch(d){tt(t,t.return,d)}}function Xy(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&zr(t.type)||t.tag===4}function $d(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Xy(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&zr(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Ld(t,n,i){var s=t.tag;if(s===5||s===6)t=t.stateNode,n?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(t,n):(n=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,n.appendChild(t),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=ko));else if(s!==4&&(s===27&&zr(t.type)&&(i=t.stateNode,n=null),t=t.child,t!==null))for(Ld(t,n,i),t=t.sibling;t!==null;)Ld(t,n,i),t=t.sibling}function vc(t,n,i){var s=t.tag;if(s===5||s===6)t=t.stateNode,n?i.insertBefore(t,n):i.appendChild(t);else if(s!==4&&(s===27&&zr(t.type)&&(i=t.stateNode),t=t.child,t!==null))for(vc(t,n,i),t=t.sibling;t!==null;)vc(t,n,i),t=t.sibling}function qy(t){var n=t.stateNode,i=t.memoizedProps;try{for(var s=t.type,d=n.attributes;d.length;)n.removeAttributeNode(d[0]);tn(n,s,i),n[Kt]=t,n[gn]=i}catch(m){tt(t,t.return,m)}}var Fo=!1,$t=!1,kd=!1,Iy=typeof WeakSet=="function"?WeakSet:Set,It=null;function YE(t,n){if(t=t.containerInfo,ah=kc,t=av(t),zf(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var s=i.getSelection&&i.getSelection();if(s&&s.rangeCount!==0){i=s.anchorNode;var d=s.anchorOffset,m=s.focusNode;s=s.focusOffset;try{i.nodeType,m.nodeType}catch{i=null;break e}var w=0,_=-1,U=-1,K=0,ae=0,se=t,J=null;t:for(;;){for(var te;se!==i||d!==0&&se.nodeType!==3||(_=w+d),se!==m||s!==0&&se.nodeType!==3||(U=w+s),se.nodeType===3&&(w+=se.nodeValue.length),(te=se.firstChild)!==null;)J=se,se=te;for(;;){if(se===t)break t;if(J===i&&++K===d&&(_=w),J===m&&++ae===s&&(U=w),(te=se.nextSibling)!==null)break;se=J,J=se.parentNode}se=te}i=_===-1||U===-1?null:{start:_,end:U}}else i=null}i=i||{start:0,end:0}}else i=null;for(ih={focusedElem:t,selectionRange:i},kc=!1,It=n;It!==null;)if(n=It,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,It=t;else for(;It!==null;){switch(n=It,m=n.alternate,t=n.flags,n.tag){case 0:if((t&4)!==0&&(t=n.updateQueue,t=t!==null?t.events:null,t!==null))for(i=0;i title"))),tn(m,s,i),m[Kt]=t,qt(m),s=m;break e;case"link":var w=Jb("link","href",d).get(s+(i.href||""));if(w){for(var _=0;_it&&(w=it,it=Te,Te=w);var F=ov(_,Te),G=ov(_,it);if(F&&G&&(te.rangeCount!==1||te.anchorNode!==F.node||te.anchorOffset!==F.offset||te.focusNode!==G.node||te.focusOffset!==G.offset)){var Q=se.createRange();Q.setStart(F.node,F.offset),te.removeAllRanges(),Te>it?(te.addRange(Q),te.extend(G.node,G.offset)):(Q.setEnd(G.node,G.offset),te.addRange(Q))}}}}for(se=[],te=_;te=te.parentNode;)te.nodeType===1&&se.push({element:te,left:te.scrollLeft,top:te.scrollTop});for(typeof _.focus=="function"&&_.focus(),_=0;_i?32:i,j.T=null,i=Xd,Xd=null;var m=Dr,w=Jo;if(Ut=0,hi=Dr=null,Jo=0,(Ze&6)!==0)throw Error(a(331));var _=Ze;if(Ze|=4,rb(m.current),tb(m,m.current,w,i),Ze=_,Pl(0,!1),Gt&&typeof Gt.onPostCommitFiberRoot=="function")try{Gt.onPostCommitFiberRoot(jo,m)}catch{}return!0}finally{k.p=d,j.T=s,wb(t,n)}}function Eb(t,n,i){n=Yn(i,n),n=Ed(t.stateNode,n,2),t=Sr(t,n,2),t!==null&&(Ln(t,2),wo(t))}function tt(t,n,i){if(t.tag===3)Eb(t,t,i);else for(;n!==null;){if(n.tag===3){Eb(n,t,i);break}else if(n.tag===1){var s=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(_r===null||!_r.has(s))){t=Yn(i,t),i=Ry(2),s=Sr(n,i,2),s!==null&&(Ty(i,s,n,t),Ln(s,2),wo(s));break}}n=n.return}}function Zd(t,n,i){var s=t.pingCache;if(s===null){s=t.pingCache=new qE;var d=new Set;s.set(n,d)}else d=s.get(n),d===void 0&&(d=new Set,s.set(n,d));d.has(i)||(Pd=!0,d.add(i),t=KE.bind(null,t,n,i),n.then(t,t))}function KE(t,n,i){var s=t.pingCache;s!==null&&s.delete(n),t.pingedLanes|=t.suspendedLanes&i,t.warmLanes&=~i,ct===t&&(He&i)===i&&(xt===4||xt===3&&(He&62914560)===He&&300>de()-xc?(Ze&2)===0&&pi(t,0):Vd|=i,di===He&&(di=0)),wo(t)}function Rb(t,n){n===0&&(n=rn()),t=na(t,n),t!==null&&(Ln(t,n),wo(t))}function WE(t){var n=t.memoizedState,i=0;n!==null&&(i=n.retryLane),Rb(t,i)}function JE(t,n){var i=0;switch(t.tag){case 31:case 13:var s=t.stateNode,d=t.memoizedState;d!==null&&(i=d.retryLane);break;case 19:s=t.stateNode;break;case 22:s=t.stateNode._retryCache;break;default:throw Error(a(314))}s!==null&&s.delete(n),Rb(t,i)}function e2(t,n){return De(t,n)}var _c=null,gi=null,Qd=!1,Dc=!1,Kd=!1,Ar=0;function wo(t){t!==gi&&t.next===null&&(gi===null?_c=gi=t:gi=gi.next=t),Dc=!0,Qd||(Qd=!0,n2())}function Pl(t,n){if(!Kd&&Dc){Kd=!0;do for(var i=!1,s=_c;s!==null;){if(t!==0){var d=s.pendingLanes;if(d===0)var m=0;else{var w=s.suspendedLanes,_=s.pingedLanes;m=(1<<31-Ct(42|t)+1)-1,m&=d&~(w&~_),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(i=!0,Nb(s,m))}else m=He,m=Xt(s,s===ct?m:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(m&3)===0||hn(s,m)||(i=!0,Nb(s,m));s=s.next}while(i);Kd=!1}}function t2(){Tb()}function Tb(){Dc=Qd=!1;var t=0;Ar!==0&&d2()&&(t=Ar);for(var n=de(),i=null,s=_c;s!==null;){var d=s.next,m=_b(s,n);m===0?(s.next=null,i===null?_c=d:i.next=d,d===null&&(gi=i)):(i=s,(t!==0||(m&3)!==0)&&(Dc=!0)),s=d}Ut!==0&&Ut!==5||Pl(t),Ar!==0&&(Ar=0)}function _b(t,n){for(var i=t.suspendedLanes,s=t.pingedLanes,d=t.expirationTimes,m=t.pendingLanes&-62914561;0_)break;var ae=U.transferSize,se=U.initiatorType;ae&&Lb(se)&&(U=U.responseEnd,w+=ae*(U<_?1:(_-K)/(U-K)))}if(--s,n+=8*(m+w)/(d.duration/1e3),t++,10"u"?null:document;function Zb(t,n,i){var s=vi;if(s&&typeof n=="string"&&n){var d=Pn(n);d='link[rel="'+t+'"][href="'+d+'"]',typeof i=="string"&&(d+='[crossorigin="'+i+'"]'),Fb.has(d)||(Fb.add(d),t={rel:t,crossOrigin:i,href:n},s.querySelector(d)===null&&(n=s.createElement("link"),tn(n,"link",t),qt(n),s.head.appendChild(n)))}}function S2(t){er.D(t),Zb("dns-prefetch",t,null)}function w2(t,n){er.C(t,n),Zb("preconnect",t,n)}function C2(t,n,i){er.L(t,n,i);var s=vi;if(s&&t&&n){var d='link[rel="preload"][as="'+Pn(n)+'"]';n==="image"&&i&&i.imageSrcSet?(d+='[imagesrcset="'+Pn(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(d+='[imagesizes="'+Pn(i.imageSizes)+'"]')):d+='[href="'+Pn(t)+'"]';var m=d;switch(n){case"style":m=yi(t);break;case"script":m=bi(t)}Zn.has(m)||(t=v({rel:"preload",href:n==="image"&&i&&i.imageSrcSet?void 0:t,as:n},i),Zn.set(m,t),s.querySelector(d)!==null||n==="style"&&s.querySelector(Xl(m))||n==="script"&&s.querySelector(ql(m))||(n=s.createElement("link"),tn(n,"link",t),qt(n),s.head.appendChild(n)))}}function E2(t,n){er.m(t,n);var i=vi;if(i&&t){var s=n&&typeof n.as=="string"?n.as:"script",d='link[rel="modulepreload"][as="'+Pn(s)+'"][href="'+Pn(t)+'"]',m=d;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=bi(t)}if(!Zn.has(m)&&(t=v({rel:"modulepreload",href:t},n),Zn.set(m,t),i.querySelector(d)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(ql(m)))return}s=i.createElement("link"),tn(s,"link",t),qt(s),i.head.appendChild(s)}}}function R2(t,n,i){er.S(t,n,i);var s=vi;if(s&&t){var d=Ua(s).hoistableStyles,m=yi(t);n=n||"default";var w=d.get(m);if(!w){var _={loading:0,preload:null};if(w=s.querySelector(Xl(m)))_.loading=5;else{t=v({rel:"stylesheet",href:t,"data-precedence":n},i),(i=Zn.get(m))&&hh(t,i);var U=w=s.createElement("link");qt(U),tn(U,"link",t),U._p=new Promise(function(K,ae){U.onload=K,U.onerror=ae}),U.addEventListener("load",function(){_.loading|=1}),U.addEventListener("error",function(){_.loading|=2}),_.loading|=4,Oc(w,n,s)}w={type:"stylesheet",instance:w,count:1,state:_},d.set(m,w)}}}function T2(t,n){er.X(t,n);var i=vi;if(i&&t){var s=Ua(i).hoistableScripts,d=bi(t),m=s.get(d);m||(m=i.querySelector(ql(d)),m||(t=v({src:t,async:!0},n),(n=Zn.get(d))&&ph(t,n),m=i.createElement("script"),qt(m),tn(m,"link",t),i.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},s.set(d,m))}}function _2(t,n){er.M(t,n);var i=vi;if(i&&t){var s=Ua(i).hoistableScripts,d=bi(t),m=s.get(d);m||(m=i.querySelector(ql(d)),m||(t=v({src:t,async:!0,type:"module"},n),(n=Zn.get(d))&&ph(t,n),m=i.createElement("script"),qt(m),tn(m,"link",t),i.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},s.set(d,m))}}function Qb(t,n,i,s){var d=(d=ue.current)?Mc(d):null;if(!d)throw Error(a(446));switch(t){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(n=yi(i.href),i=Ua(d).hoistableStyles,s=i.get(n),s||(s={type:"style",instance:null,count:0,state:null},i.set(n,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){t=yi(i.href);var m=Ua(d).hoistableStyles,w=m.get(t);if(w||(d=d.ownerDocument||d,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(t,w),(m=d.querySelector(Xl(t)))&&!m._p&&(w.instance=m,w.state.loading=5),Zn.has(t)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},Zn.set(t,i),m||D2(d,t,i,w.state))),n&&s===null)throw Error(a(528,""));return w}if(n&&s!==null)throw Error(a(529,""));return null;case"script":return n=i.async,i=i.src,typeof i=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=bi(i),i=Ua(d).hoistableScripts,s=i.get(n),s||(s={type:"script",instance:null,count:0,state:null},i.set(n,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,t))}}function yi(t){return'href="'+Pn(t)+'"'}function Xl(t){return'link[rel="stylesheet"]['+t+"]"}function Kb(t){return v({},t,{"data-precedence":t.precedence,precedence:null})}function D2(t,n,i,s){t.querySelector('link[rel="preload"][as="style"]['+n+"]")?s.loading=1:(n=t.createElement("link"),s.preload=n,n.addEventListener("load",function(){return s.loading|=1}),n.addEventListener("error",function(){return s.loading|=2}),tn(n,"link",i),qt(n),t.head.appendChild(n))}function bi(t){return'[src="'+Pn(t)+'"]'}function ql(t){return"script[async]"+t}function Wb(t,n,i){if(n.count++,n.instance===null)switch(n.type){case"style":var s=t.querySelector('style[data-href~="'+Pn(i.href)+'"]');if(s)return n.instance=s,qt(s),s;var d=v({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return s=(t.ownerDocument||t).createElement("style"),qt(s),tn(s,"style",d),Oc(s,i.precedence,t),n.instance=s;case"stylesheet":d=yi(i.href);var m=t.querySelector(Xl(d));if(m)return n.state.loading|=4,n.instance=m,qt(m),m;s=Kb(i),(d=Zn.get(d))&&hh(s,d),m=(t.ownerDocument||t).createElement("link"),qt(m);var w=m;return w._p=new Promise(function(_,U){w.onload=_,w.onerror=U}),tn(m,"link",s),n.state.loading|=4,Oc(m,i.precedence,t),n.instance=m;case"script":return m=bi(i.src),(d=t.querySelector(ql(m)))?(n.instance=d,qt(d),d):(s=i,(d=Zn.get(m))&&(s=v({},i),ph(s,d)),t=t.ownerDocument||t,d=t.createElement("script"),qt(d),tn(d,"link",s),t.head.appendChild(d),n.instance=d);case"void":return null;default:throw Error(a(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(s=n.instance,n.state.loading|=4,Oc(s,i.precedence,t));return n.instance}function Oc(t,n,i){for(var s=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=s.length?s[s.length-1]:null,m=d,w=0;w title"):null)}function N2(t,n,i){if(i===1||n.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(t=n.disabled,typeof n.precedence=="string"&&t==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function t0(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function A2(t,n,i,s){if(i.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var d=yi(s.href),m=n.querySelector(Xl(d));if(m){n=m._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(t.count++,t=Bc.bind(t),n.then(t,t)),i.state.loading|=4,i.instance=m,qt(m);return}m=n.ownerDocument||n,s=Kb(s),(d=Zn.get(d))&&hh(s,d),m=m.createElement("link"),qt(m);var w=m;w._p=new Promise(function(_,U){w.onload=_,w.onerror=U}),tn(m,"link",s),i.instance=m}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(i,n),(n=i.state.preload)&&(i.state.loading&3)===0&&(t.count++,i=Bc.bind(t),n.addEventListener("load",i),n.addEventListener("error",i))}}var mh=0;function z2(t,n){return t.stylesheets&&t.count===0&&Lc(t,t.stylesheets),0mh?50:800)+n);return t.unsuspend=i,function(){t.unsuspend=null,clearTimeout(s),clearTimeout(d)}}:null}function Bc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Lc(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var $c=null;function Lc(t,n){t.stylesheets=null,t.unsuspend!==null&&(t.count++,$c=new Map,n.forEach(M2,t),$c=null,Bc.call(t))}function M2(t,n){if(!(n.state.loading&4)){var i=$c.get(t);if(i)var s=i.get(null);else{i=new Map,$c.set(t,i);for(var d=t.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(o){console.error(o)}}return e(),Eh.exports=Z2(),Eh.exports}var K2=Q2(),To=function(){return To=Object.assign||function(o){for(var r,a=1,l=arguments.length;a"u")return pR;var o=mR(e),r=document.documentElement.clientWidth,a=window.innerWidth;return{left:o[0],top:o[1],right:o[2],gap:Math.max(0,a-r+o[2]-o[0])}},vR=fx(),Mi="data-scroll-locked",yR=function(e,o,r,a){var l=e.left,c=e.top,u=e.right,f=e.gap;return r===void 0&&(r="margin"),` +`).replace(c2,"")}function $b(t,n){return n=Bb(n),Bb(t)===n}function at(t,n,i,s,d,m){switch(i){case"children":typeof s=="string"?n==="body"||n==="textarea"&&s===""||Ya(t,s):(typeof s=="number"||typeof s=="bigint")&&n!=="body"&&Ya(t,""+s);break;case"className":js(t,"class",s);break;case"tabIndex":js(t,"tabindex",s);break;case"dir":case"role":case"viewBox":case"width":case"height":js(t,i,s);break;case"style":$g(t,s,m);break;case"data":if(n!=="object"){js(t,"data",s);break}case"src":case"href":if(s===""&&(n!=="a"||i!=="href")){t.removeAttribute(i);break}if(s==null||typeof s=="function"||typeof s=="symbol"||typeof s=="boolean"){t.removeAttribute(i);break}s=$s(""+s),t.setAttribute(i,s);break;case"action":case"formAction":if(typeof s=="function"){t.setAttribute(i,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof m=="function"&&(i==="formAction"?(n!=="input"&&at(t,n,"name",d.name,d,null),at(t,n,"formEncType",d.formEncType,d,null),at(t,n,"formMethod",d.formMethod,d,null),at(t,n,"formTarget",d.formTarget,d,null)):(at(t,n,"encType",d.encType,d,null),at(t,n,"method",d.method,d,null),at(t,n,"target",d.target,d,null)));if(s==null||typeof s=="symbol"||typeof s=="boolean"){t.removeAttribute(i);break}s=$s(""+s),t.setAttribute(i,s);break;case"onClick":s!=null&&(t.onclick=ko);break;case"onScroll":s!=null&&ke("scroll",t);break;case"onScrollEnd":s!=null&&ke("scrollend",t);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(a(61));if(i=s.__html,i!=null){if(d.children!=null)throw Error(a(60));t.innerHTML=i}}break;case"multiple":t.multiple=s&&typeof s!="function"&&typeof s!="symbol";break;case"muted":t.muted=s&&typeof s!="function"&&typeof s!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(s==null||typeof s=="function"||typeof s=="boolean"||typeof s=="symbol"){t.removeAttribute("xlink:href");break}i=$s(""+s),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",i);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":s!=null&&typeof s!="function"&&typeof s!="symbol"?t.setAttribute(i,""+s):t.removeAttribute(i);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":s&&typeof s!="function"&&typeof s!="symbol"?t.setAttribute(i,""):t.removeAttribute(i);break;case"capture":case"download":s===!0?t.setAttribute(i,""):s!==!1&&s!=null&&typeof s!="function"&&typeof s!="symbol"?t.setAttribute(i,s):t.removeAttribute(i);break;case"cols":case"rows":case"size":case"span":s!=null&&typeof s!="function"&&typeof s!="symbol"&&!isNaN(s)&&1<=s?t.setAttribute(i,s):t.removeAttribute(i);break;case"rowSpan":case"start":s==null||typeof s=="function"||typeof s=="symbol"||isNaN(s)?t.removeAttribute(i):t.setAttribute(i,s);break;case"popover":ke("beforetoggle",t),ke("toggle",t),Os(t,"popover",s);break;case"xlinkActuate":Lo(t,"http://www.w3.org/1999/xlink","xlink:actuate",s);break;case"xlinkArcrole":Lo(t,"http://www.w3.org/1999/xlink","xlink:arcrole",s);break;case"xlinkRole":Lo(t,"http://www.w3.org/1999/xlink","xlink:role",s);break;case"xlinkShow":Lo(t,"http://www.w3.org/1999/xlink","xlink:show",s);break;case"xlinkTitle":Lo(t,"http://www.w3.org/1999/xlink","xlink:title",s);break;case"xlinkType":Lo(t,"http://www.w3.org/1999/xlink","xlink:type",s);break;case"xmlBase":Lo(t,"http://www.w3.org/XML/1998/namespace","xml:base",s);break;case"xmlLang":Lo(t,"http://www.w3.org/XML/1998/namespace","xml:lang",s);break;case"xmlSpace":Lo(t,"http://www.w3.org/XML/1998/namespace","xml:space",s);break;case"is":Os(t,"is",s);break;case"innerText":case"textContent":break;default:(!(2_)break;var ae=U.transferSize,se=U.initiatorType;ae&&Lb(se)&&(U=U.responseEnd,w+=ae*(U<_?1:(_-K)/(U-K)))}if(--s,n+=8*(m+w)/(d.duration/1e3),t++,10"u"?null:document;function Zb(t,n,i){var s=vi;if(s&&typeof n=="string"&&n){var d=Pn(n);d='link[rel="'+t+'"][href="'+d+'"]',typeof i=="string"&&(d+='[crossorigin="'+i+'"]'),Fb.has(d)||(Fb.add(d),t={rel:t,crossOrigin:i,href:n},s.querySelector(d)===null&&(n=s.createElement("link"),tn(n,"link",t),qt(n),s.head.appendChild(n)))}}function S2(t){er.D(t),Zb("dns-prefetch",t,null)}function w2(t,n){er.C(t,n),Zb("preconnect",t,n)}function C2(t,n,i){er.L(t,n,i);var s=vi;if(s&&t&&n){var d='link[rel="preload"][as="'+Pn(n)+'"]';n==="image"&&i&&i.imageSrcSet?(d+='[imagesrcset="'+Pn(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(d+='[imagesizes="'+Pn(i.imageSizes)+'"]')):d+='[href="'+Pn(t)+'"]';var m=d;switch(n){case"style":m=yi(t);break;case"script":m=bi(t)}Zn.has(m)||(t=v({rel:"preload",href:n==="image"&&i&&i.imageSrcSet?void 0:t,as:n},i),Zn.set(m,t),s.querySelector(d)!==null||n==="style"&&s.querySelector(Xl(m))||n==="script"&&s.querySelector(ql(m))||(n=s.createElement("link"),tn(n,"link",t),qt(n),s.head.appendChild(n)))}}function E2(t,n){er.m(t,n);var i=vi;if(i&&t){var s=n&&typeof n.as=="string"?n.as:"script",d='link[rel="modulepreload"][as="'+Pn(s)+'"][href="'+Pn(t)+'"]',m=d;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=bi(t)}if(!Zn.has(m)&&(t=v({rel:"modulepreload",href:t},n),Zn.set(m,t),i.querySelector(d)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(ql(m)))return}s=i.createElement("link"),tn(s,"link",t),qt(s),i.head.appendChild(s)}}}function R2(t,n,i){er.S(t,n,i);var s=vi;if(s&&t){var d=Ua(s).hoistableStyles,m=yi(t);n=n||"default";var w=d.get(m);if(!w){var _={loading:0,preload:null};if(w=s.querySelector(Xl(m)))_.loading=5;else{t=v({rel:"stylesheet",href:t,"data-precedence":n},i),(i=Zn.get(m))&&hh(t,i);var U=w=s.createElement("link");qt(U),tn(U,"link",t),U._p=new Promise(function(K,ae){U.onload=K,U.onerror=ae}),U.addEventListener("load",function(){_.loading|=1}),U.addEventListener("error",function(){_.loading|=2}),_.loading|=4,Oc(w,n,s)}w={type:"stylesheet",instance:w,count:1,state:_},d.set(m,w)}}}function T2(t,n){er.X(t,n);var i=vi;if(i&&t){var s=Ua(i).hoistableScripts,d=bi(t),m=s.get(d);m||(m=i.querySelector(ql(d)),m||(t=v({src:t,async:!0},n),(n=Zn.get(d))&&ph(t,n),m=i.createElement("script"),qt(m),tn(m,"link",t),i.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},s.set(d,m))}}function _2(t,n){er.M(t,n);var i=vi;if(i&&t){var s=Ua(i).hoistableScripts,d=bi(t),m=s.get(d);m||(m=i.querySelector(ql(d)),m||(t=v({src:t,async:!0,type:"module"},n),(n=Zn.get(d))&&ph(t,n),m=i.createElement("script"),qt(m),tn(m,"link",t),i.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},s.set(d,m))}}function Qb(t,n,i,s){var d=(d=ue.current)?Mc(d):null;if(!d)throw Error(a(446));switch(t){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(n=yi(i.href),i=Ua(d).hoistableStyles,s=i.get(n),s||(s={type:"style",instance:null,count:0,state:null},i.set(n,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){t=yi(i.href);var m=Ua(d).hoistableStyles,w=m.get(t);if(w||(d=d.ownerDocument||d,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(t,w),(m=d.querySelector(Xl(t)))&&!m._p&&(w.instance=m,w.state.loading=5),Zn.has(t)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},Zn.set(t,i),m||D2(d,t,i,w.state))),n&&s===null)throw Error(a(528,""));return w}if(n&&s!==null)throw Error(a(529,""));return null;case"script":return n=i.async,i=i.src,typeof i=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=bi(i),i=Ua(d).hoistableScripts,s=i.get(n),s||(s={type:"script",instance:null,count:0,state:null},i.set(n,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,t))}}function yi(t){return'href="'+Pn(t)+'"'}function Xl(t){return'link[rel="stylesheet"]['+t+"]"}function Kb(t){return v({},t,{"data-precedence":t.precedence,precedence:null})}function D2(t,n,i,s){t.querySelector('link[rel="preload"][as="style"]['+n+"]")?s.loading=1:(n=t.createElement("link"),s.preload=n,n.addEventListener("load",function(){return s.loading|=1}),n.addEventListener("error",function(){return s.loading|=2}),tn(n,"link",i),qt(n),t.head.appendChild(n))}function bi(t){return'[src="'+Pn(t)+'"]'}function ql(t){return"script[async]"+t}function Wb(t,n,i){if(n.count++,n.instance===null)switch(n.type){case"style":var s=t.querySelector('style[data-href~="'+Pn(i.href)+'"]');if(s)return n.instance=s,qt(s),s;var d=v({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return s=(t.ownerDocument||t).createElement("style"),qt(s),tn(s,"style",d),Oc(s,i.precedence,t),n.instance=s;case"stylesheet":d=yi(i.href);var m=t.querySelector(Xl(d));if(m)return n.state.loading|=4,n.instance=m,qt(m),m;s=Kb(i),(d=Zn.get(d))&&hh(s,d),m=(t.ownerDocument||t).createElement("link"),qt(m);var w=m;return w._p=new Promise(function(_,U){w.onload=_,w.onerror=U}),tn(m,"link",s),n.state.loading|=4,Oc(m,i.precedence,t),n.instance=m;case"script":return m=bi(i.src),(d=t.querySelector(ql(m)))?(n.instance=d,qt(d),d):(s=i,(d=Zn.get(m))&&(s=v({},i),ph(s,d)),t=t.ownerDocument||t,d=t.createElement("script"),qt(d),tn(d,"link",s),t.head.appendChild(d),n.instance=d);case"void":return null;default:throw Error(a(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(s=n.instance,n.state.loading|=4,Oc(s,i.precedence,t));return n.instance}function Oc(t,n,i){for(var s=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=s.length?s[s.length-1]:null,m=d,w=0;w title"):null)}function N2(t,n,i){if(i===1||n.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(t=n.disabled,typeof n.precedence=="string"&&t==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function t0(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function A2(t,n,i,s){if(i.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var d=yi(s.href),m=n.querySelector(Xl(d));if(m){n=m._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(t.count++,t=Bc.bind(t),n.then(t,t)),i.state.loading|=4,i.instance=m,qt(m);return}m=n.ownerDocument||n,s=Kb(s),(d=Zn.get(d))&&hh(s,d),m=m.createElement("link"),qt(m);var w=m;w._p=new Promise(function(_,U){w.onload=_,w.onerror=U}),tn(m,"link",s),i.instance=m}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(i,n),(n=i.state.preload)&&(i.state.loading&3)===0&&(t.count++,i=Bc.bind(t),n.addEventListener("load",i),n.addEventListener("error",i))}}var mh=0;function z2(t,n){return t.stylesheets&&t.count===0&&Lc(t,t.stylesheets),0mh?50:800)+n);return t.unsuspend=i,function(){t.unsuspend=null,clearTimeout(s),clearTimeout(d)}}:null}function Bc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Lc(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var $c=null;function Lc(t,n){t.stylesheets=null,t.unsuspend!==null&&(t.count++,$c=new Map,n.forEach(M2,t),$c=null,Bc.call(t))}function M2(t,n){if(!(n.state.loading&4)){var i=$c.get(t);if(i)var s=i.get(null);else{i=new Map,$c.set(t,i);for(var d=t.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(o){console.error(o)}}return e(),Eh.exports=Z2(),Eh.exports}var K2=Q2(),To=function(){return To=Object.assign||function(o){for(var r,a=1,l=arguments.length;a"u")return pR;var o=mR(e),r=document.documentElement.clientWidth,a=window.innerWidth;return{left:o[0],top:o[1],right:o[2],gap:Math.max(0,a-r+o[2]-o[0])}},vR=fx(),Mi="data-scroll-locked",yR=function(e,o,r,a){var l=e.left,c=e.top,u=e.right,f=e.gap;return r===void 0&&(r="margin"),` .`.concat(J2,` { overflow: hidden `).concat(a,`; padding-right: `).concat(f,"px ").concat(a,`; @@ -63,4 +63,4 @@ Error generating stack: `+s.message+` Press space again to drop the item in its new position, or press escape to cancel. `},e6={onDragStart(e){let{active:o}=e;return"Picked up draggable item "+o.id+"."},onDragOver(e){let{active:o,over:r}=e;return r?"Draggable item "+o.id+" was moved over droppable area "+r.id+".":"Draggable item "+o.id+" is no longer over a droppable area."},onDragEnd(e){let{active:o,over:r}=e;return r?"Draggable item "+o.id+" was dropped over droppable area "+r.id:"Draggable item "+o.id+" was dropped."},onDragCancel(e){let{active:o}=e;return"Dragging was cancelled. Draggable item "+o.id+" was dropped."}};function t6(e){let{announcements:o=e6,container:r,hiddenTextDescribedById:a,screenReaderInstructions:l=J5}=e;const{announce:c,announcement:u}=Q5(),f=As("DndLiveRegion"),[h,p]=b.useState(!1);if(b.useEffect(()=>{p(!0)},[]),K5(b.useMemo(()=>({onDragStart(v){let{active:x}=v;c(o.onDragStart({active:x}))},onDragMove(v){let{active:x,over:S}=v;o.onDragMove&&c(o.onDragMove({active:x,over:S}))},onDragOver(v){let{active:x,over:S}=v;c(o.onDragOver({active:x,over:S}))},onDragEnd(v){let{active:x,over:S}=v;c(o.onDragEnd({active:x,over:S}))},onDragCancel(v){let{active:x,over:S}=v;c(o.onDragCancel({active:x,over:S}))}}),[c,o])),!h)return null;const g=Ge.createElement(Ge.Fragment,null,Ge.createElement(F5,{id:a,value:l.draggable}),Ge.createElement(Z5,{id:f,announcement:u}));return r?co.createPortal(g,r):g}var Vt;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Vt||(Vt={}));function Ru(){}function n6(e,o){return b.useMemo(()=>({sensor:e,options:o??{}}),[e,o])}function o6(){for(var e=arguments.length,o=new Array(e),r=0;r[...o].filter(a=>a!=null),[...o])}const go=Object.freeze({x:0,y:0});function r6(e,o){return Math.sqrt(Math.pow(e.x-o.x,2)+Math.pow(e.y-o.y,2))}function a6(e,o){let{data:{value:r}}=e,{data:{value:a}}=o;return r-a}function i6(e,o){let{data:{value:r}}=e,{data:{value:a}}=o;return a-r}function l6(e,o){if(!e||e.length===0)return null;const[r]=e;return r[o]}function z1(e,o,r){return o===void 0&&(o=e.left),r===void 0&&(r=e.top),{x:o+e.width*.5,y:r+e.height*.5}}const s6=e=>{let{collisionRect:o,droppableRects:r,droppableContainers:a}=e;const l=z1(o,o.left,o.top),c=[];for(const u of a){const{id:f}=u,h=r.get(f);if(h){const p=r6(z1(h),l);c.push({id:f,data:{droppableContainer:u,value:p}})}}return c.sort(a6)};function c6(e,o){const r=Math.max(o.top,e.top),a=Math.max(o.left,e.left),l=Math.min(o.left+o.width,e.left+e.width),c=Math.min(o.top+o.height,e.top+e.height),u=l-a,f=c-r;if(a{let{collisionRect:o,droppableRects:r,droppableContainers:a}=e;const l=[];for(const c of a){const{id:u}=c,f=r.get(u);if(f){const h=c6(f,o);h>0&&l.push({id:u,data:{droppableContainer:c,value:h}})}}return l.sort(i6)};function f6(e,o,r){return{...e,scaleX:o&&r?o.width/r.width:1,scaleY:o&&r?o.height/r.height:1}}function Kw(e,o){return e&&o?{x:e.left-o.left,y:e.top-o.top}:go}function d6(e){return function(r){for(var a=arguments.length,l=new Array(a>1?a-1:0),c=1;c({...u,top:u.top+e*f.y,bottom:u.bottom+e*f.y,left:u.left+e*f.x,right:u.right+e*f.x}),{...r})}}const h6=d6(1);function p6(e){if(e.startsWith("matrix3d(")){const o=e.slice(9,-1).split(/, /);return{x:+o[12],y:+o[13],scaleX:+o[0],scaleY:+o[5]}}else if(e.startsWith("matrix(")){const o=e.slice(7,-1).split(/, /);return{x:+o[4],y:+o[5],scaleX:+o[0],scaleY:+o[3]}}return null}function m6(e,o,r){const a=p6(o);if(!a)return e;const{scaleX:l,scaleY:c,x:u,y:f}=a,h=e.left-u-(1-l)*parseFloat(r),p=e.top-f-(1-c)*parseFloat(r.slice(r.indexOf(" ")+1)),g=l?e.width/l:e.width,v=c?e.height/c:e.height;return{width:g,height:v,top:p,right:h+g,bottom:p+v,left:h}}const g6={ignoreTransform:!1};function il(e,o){o===void 0&&(o=g6);let r=e.getBoundingClientRect();if(o.ignoreTransform){const{transform:p,transformOrigin:g}=_n(e).getComputedStyle(e);p&&(r=m6(r,p,g))}const{top:a,left:l,width:c,height:u,bottom:f,right:h}=r;return{top:a,left:l,width:c,height:u,bottom:f,right:h}}function M1(e){return il(e,{ignoreTransform:!0})}function v6(e){const o=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:o,bottom:r,width:o,height:r}}function y6(e,o){return o===void 0&&(o=_n(e).getComputedStyle(e)),o.position==="fixed"}function b6(e,o){o===void 0&&(o=_n(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(l=>{const c=o[l];return typeof c=="string"?r.test(c):!1})}function bg(e,o){const r=[];function a(l){if(o!=null&&r.length>=o||!l)return r;if(gg(l)&&l.scrollingElement!=null&&!r.includes(l.scrollingElement))return r.push(l.scrollingElement),r;if(!Ds(l)||Fw(l)||r.includes(l))return r;const c=_n(e).getComputedStyle(l);return l!==e&&b6(l,c)&&r.push(l),y6(l,c)?r:a(l.parentNode)}return e?a(e):r}function Ww(e){const[o]=bg(e,1);return o??null}function np(e){return!sf||!e?null:rl(e)?e:mg(e)?gg(e)||e===al(e).scrollingElement?window:Ds(e)?e:null:null}function Jw(e){return rl(e)?e.scrollX:e.scrollLeft}function eC(e){return rl(e)?e.scrollY:e.scrollTop}function $p(e){return{x:Jw(e),y:eC(e)}}var Ft;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Ft||(Ft={}));function tC(e){return!sf||!e?!1:e===document.scrollingElement}function nC(e){const o={x:0,y:0},r=tC(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},l=e.scrollTop<=o.y,c=e.scrollLeft<=o.x,u=e.scrollTop>=a.y,f=e.scrollLeft>=a.x;return{isTop:l,isLeft:c,isBottom:u,isRight:f,maxScroll:a,minScroll:o}}const x6={x:.2,y:.2};function S6(e,o,r,a,l){let{top:c,left:u,right:f,bottom:h}=r;a===void 0&&(a=10),l===void 0&&(l=x6);const{isTop:p,isBottom:g,isLeft:v,isRight:x}=nC(e),S={x:0,y:0},E={x:0,y:0},C={height:o.height*l.y,width:o.width*l.x};return!p&&c<=o.top+C.height?(S.y=Ft.Backward,E.y=a*Math.abs((o.top+C.height-c)/C.height)):!g&&h>=o.bottom-C.height&&(S.y=Ft.Forward,E.y=a*Math.abs((o.bottom-C.height-h)/C.height)),!x&&f>=o.right-C.width?(S.x=Ft.Forward,E.x=a*Math.abs((o.right-C.width-f)/C.width)):!v&&u<=o.left+C.width&&(S.x=Ft.Backward,E.x=a*Math.abs((o.left+C.width-u)/C.width)),{direction:S,speed:E}}function w6(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:u}=window;return{top:0,left:0,right:c,bottom:u,width:c,height:u}}const{top:o,left:r,right:a,bottom:l}=e.getBoundingClientRect();return{top:o,left:r,right:a,bottom:l,width:e.clientWidth,height:e.clientHeight}}function oC(e){return e.reduce((o,r)=>$i(o,$p(r)),go)}function C6(e){return e.reduce((o,r)=>o+Jw(r),0)}function E6(e){return e.reduce((o,r)=>o+eC(r),0)}function R6(e,o){if(o===void 0&&(o=il),!e)return;const{top:r,left:a,bottom:l,right:c}=o(e);Ww(e)&&(l<=0||c<=0||r>=window.innerHeight||a>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const T6=[["x",["left","right"],C6],["y",["top","bottom"],E6]];class xg{constructor(o,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const a=bg(r),l=oC(a);this.rect={...o},this.width=o.width,this.height=o.height;for(const[c,u,f]of T6)for(const h of u)Object.defineProperty(this,h,{get:()=>{const p=f(a),g=l[c]-p;return this.rect[h]+g},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class ls{constructor(o){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...r)})},this.target=o}add(o,r,a){var l;(l=this.target)==null||l.addEventListener(o,r,a),this.listeners.push([o,r,a])}}function _6(e){const{EventTarget:o}=_n(e);return e instanceof o?e:al(e)}function op(e,o){const r=Math.abs(e.x),a=Math.abs(e.y);return typeof o=="number"?Math.sqrt(r**2+a**2)>o:"x"in o&&"y"in o?r>o.x&&a>o.y:"x"in o?r>o.x:"y"in o?a>o.y:!1}var Qn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Qn||(Qn={}));function O1(e){e.preventDefault()}function D6(e){e.stopPropagation()}var Ke;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Ke||(Ke={}));const rC={start:[Ke.Space,Ke.Enter],cancel:[Ke.Esc],end:[Ke.Space,Ke.Enter,Ke.Tab]},N6=(e,o)=>{let{currentCoordinates:r}=o;switch(e.code){case Ke.Right:return{...r,x:r.x+25};case Ke.Left:return{...r,x:r.x-25};case Ke.Down:return{...r,y:r.y+25};case Ke.Up:return{...r,y:r.y-25}}};class aC{constructor(o){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=o;const{event:{target:r}}=o;this.props=o,this.listeners=new ls(al(r)),this.windowListeners=new ls(_n(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Qn.Resize,this.handleCancel),this.windowListeners.add(Qn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Qn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:o,onStart:r}=this.props,a=o.node.current;a&&R6(a),r(go)}handleKeyDown(o){if(yg(o)){const{active:r,context:a,options:l}=this.props,{keyboardCodes:c=rC,coordinateGetter:u=N6,scrollBehavior:f="smooth"}=l,{code:h}=o;if(c.end.includes(h)){this.handleEnd(o);return}if(c.cancel.includes(h)){this.handleCancel(o);return}const{collisionRect:p}=a.current,g=p?{x:p.left,y:p.top}:go;this.referenceCoordinates||(this.referenceCoordinates=g);const v=u(o,{active:r,context:a.current,currentCoordinates:g});if(v){const x=Eu(v,g),S={x:0,y:0},{scrollableAncestors:E}=a.current;for(const C of E){const R=o.code,{isTop:T,isRight:z,isLeft:A,isBottom:N,maxScroll:B,minScroll:M}=nC(C),$=w6(C),L={x:Math.min(R===Ke.Right?$.right-$.width/2:$.right,Math.max(R===Ke.Right?$.left:$.left+$.width/2,v.x)),y:Math.min(R===Ke.Down?$.bottom-$.height/2:$.bottom,Math.max(R===Ke.Down?$.top:$.top+$.height/2,v.y))},H=R===Ke.Right&&!z||R===Ke.Left&&!A,I=R===Ke.Down&&!N||R===Ke.Up&&!T;if(H&&L.x!==v.x){const Y=C.scrollLeft+x.x,X=R===Ke.Right&&Y<=B.x||R===Ke.Left&&Y>=M.x;if(X&&!x.y){C.scrollTo({left:Y,behavior:f});return}X?S.x=C.scrollLeft-Y:S.x=R===Ke.Right?C.scrollLeft-B.x:C.scrollLeft-M.x,S.x&&C.scrollBy({left:-S.x,behavior:f});break}else if(I&&L.y!==v.y){const Y=C.scrollTop+x.y,X=R===Ke.Down&&Y<=B.y||R===Ke.Up&&Y>=M.y;if(X&&!x.x){C.scrollTo({top:Y,behavior:f});return}X?S.y=C.scrollTop-Y:S.y=R===Ke.Down?C.scrollTop-B.y:C.scrollTop-M.y,S.y&&C.scrollBy({top:-S.y,behavior:f});break}}this.handleMove(o,$i(Eu(v,this.referenceCoordinates),S))}}}handleMove(o,r){const{onMove:a}=this.props;o.preventDefault(),a(r)}handleEnd(o){const{onEnd:r}=this.props;o.preventDefault(),this.detach(),r()}handleCancel(o){const{onCancel:r}=this.props;o.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}aC.activators=[{eventName:"onKeyDown",handler:(e,o,r)=>{let{keyboardCodes:a=rC,onActivation:l}=o,{active:c}=r;const{code:u}=e.nativeEvent;if(a.start.includes(u)){const f=c.activatorNode.current;return f&&e.target!==f?!1:(e.preventDefault(),l?.({event:e.nativeEvent}),!0)}return!1}}];function j1(e){return!!(e&&"distance"in e)}function B1(e){return!!(e&&"delay"in e)}class Sg{constructor(o,r,a){var l;a===void 0&&(a=_6(o.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=o,this.events=r;const{event:c}=o,{target:u}=c;this.props=o,this.events=r,this.document=al(u),this.documentListeners=new ls(this.document),this.listeners=new ls(a),this.windowListeners=new ls(_n(u)),this.initialCoordinates=(l=Bp(c))!=null?l:go,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:o,props:{options:{activationConstraint:r,bypassActivationConstraint:a}}}=this;if(this.listeners.add(o.move.name,this.handleMove,{passive:!1}),this.listeners.add(o.end.name,this.handleEnd),o.cancel&&this.listeners.add(o.cancel.name,this.handleCancel),this.windowListeners.add(Qn.Resize,this.handleCancel),this.windowListeners.add(Qn.DragStart,O1),this.windowListeners.add(Qn.VisibilityChange,this.handleCancel),this.windowListeners.add(Qn.ContextMenu,O1),this.documentListeners.add(Qn.Keydown,this.handleKeydown),r){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(B1(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(j1(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(o,r){const{active:a,onPending:l}=this.props;l(a,o,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:o}=this,{onStart:r}=this.props;o&&(this.activated=!0,this.documentListeners.add(Qn.Click,D6,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Qn.SelectionChange,this.removeTextSelection),r(o))}handleMove(o){var r;const{activated:a,initialCoordinates:l,props:c}=this,{onMove:u,options:{activationConstraint:f}}=c;if(!l)return;const h=(r=Bp(o))!=null?r:go,p=Eu(l,h);if(!a&&f){if(j1(f)){if(f.tolerance!=null&&op(p,f.tolerance))return this.handleCancel();if(op(p,f.distance))return this.handleStart()}if(B1(f)&&op(p,f.tolerance))return this.handleCancel();this.handlePending(f,p);return}o.cancelable&&o.preventDefault(),u(h)}handleEnd(){const{onAbort:o,onEnd:r}=this.props;this.detach(),this.activated||o(this.props.active),r()}handleCancel(){const{onAbort:o,onCancel:r}=this.props;this.detach(),this.activated||o(this.props.active),r()}handleKeydown(o){o.code===Ke.Esc&&this.handleCancel()}removeTextSelection(){var o;(o=this.document.getSelection())==null||o.removeAllRanges()}}const A6={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class wg extends Sg{constructor(o){const{event:r}=o,a=al(r.target);super(o,A6,a)}}wg.activators=[{eventName:"onPointerDown",handler:(e,o)=>{let{nativeEvent:r}=e,{onActivation:a}=o;return!r.isPrimary||r.button!==0?!1:(a?.({event:r}),!0)}}];const z6={move:{name:"mousemove"},end:{name:"mouseup"}};var Lp;(function(e){e[e.RightClick=2]="RightClick"})(Lp||(Lp={}));class M6 extends Sg{constructor(o){super(o,z6,al(o.event.target))}}M6.activators=[{eventName:"onMouseDown",handler:(e,o)=>{let{nativeEvent:r}=e,{onActivation:a}=o;return r.button===Lp.RightClick?!1:(a?.({event:r}),!0)}}];const rp={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class O6 extends Sg{constructor(o){super(o,rp)}static setup(){return window.addEventListener(rp.move.name,o,{capture:!1,passive:!1}),function(){window.removeEventListener(rp.move.name,o)};function o(){}}}O6.activators=[{eventName:"onTouchStart",handler:(e,o)=>{let{nativeEvent:r}=e,{onActivation:a}=o;const{touches:l}=r;return l.length>1?!1:(a?.({event:r}),!0)}}];var ss;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(ss||(ss={}));var Tu;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Tu||(Tu={}));function j6(e){let{acceleration:o,activator:r=ss.Pointer,canScroll:a,draggingRect:l,enabled:c,interval:u=5,order:f=Tu.TreeOrder,pointerCoordinates:h,scrollableAncestors:p,scrollableAncestorRects:g,delta:v,threshold:x}=e;const S=$6({delta:v,disabled:!c}),[E,C]=Y5(),R=b.useRef({x:0,y:0}),T=b.useRef({x:0,y:0}),z=b.useMemo(()=>{switch(r){case ss.Pointer:return h?{top:h.y,bottom:h.y,left:h.x,right:h.x}:null;case ss.DraggableRect:return l}},[r,l,h]),A=b.useRef(null),N=b.useCallback(()=>{const M=A.current;if(!M)return;const $=R.current.x*T.current.x,L=R.current.y*T.current.y;M.scrollBy($,L)},[]),B=b.useMemo(()=>f===Tu.TreeOrder?[...p].reverse():p,[f,p]);b.useEffect(()=>{if(!c||!p.length||!z){C();return}for(const M of B){if(a?.(M)===!1)continue;const $=p.indexOf(M),L=g[$];if(!L)continue;const{direction:H,speed:I}=S6(M,L,z,o,x);for(const Y of["x","y"])S[Y][H[Y]]||(I[Y]=0,H[Y]=0);if(I.x>0||I.y>0){C(),A.current=M,E(N,u),R.current=I,T.current=H;return}}R.current={x:0,y:0},T.current={x:0,y:0},C()},[o,N,a,C,c,u,JSON.stringify(z),JSON.stringify(S),E,p,B,g,JSON.stringify(x)])}const B6={x:{[Ft.Backward]:!1,[Ft.Forward]:!1},y:{[Ft.Backward]:!1,[Ft.Forward]:!1}};function $6(e){let{delta:o,disabled:r}=e;const a=jp(o);return Ns(l=>{if(r||!a||!l)return B6;const c={x:Math.sign(o.x-a.x),y:Math.sign(o.y-a.y)};return{x:{[Ft.Backward]:l.x[Ft.Backward]||c.x===-1,[Ft.Forward]:l.x[Ft.Forward]||c.x===1},y:{[Ft.Backward]:l.y[Ft.Backward]||c.y===-1,[Ft.Forward]:l.y[Ft.Forward]||c.y===1}}},[r,o,a])}function L6(e,o){const r=o!=null?e.get(o):void 0,a=r?r.node.current:null;return Ns(l=>{var c;return o==null?null:(c=a??l)!=null?c:null},[a,o])}function k6(e,o){return b.useMemo(()=>e.reduce((r,a)=>{const{sensor:l}=a,c=l.activators.map(u=>({eventName:u.eventName,handler:o(u.handler,a)}));return[...r,...c]},[]),[e,o])}var bs;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(bs||(bs={}));var kp;(function(e){e.Optimized="optimized"})(kp||(kp={}));const $1=new Map;function H6(e,o){let{dragging:r,dependencies:a,config:l}=o;const[c,u]=b.useState(null),{frequency:f,measure:h,strategy:p}=l,g=b.useRef(e),v=R(),x=vs(v),S=b.useCallback(function(T){T===void 0&&(T=[]),!x.current&&u(z=>z===null?T:z.concat(T.filter(A=>!z.includes(A))))},[x]),E=b.useRef(null),C=Ns(T=>{if(v&&!r)return $1;if(!T||T===$1||g.current!==e||c!=null){const z=new Map;for(let A of e){if(!A)continue;if(c&&c.length>0&&!c.includes(A.id)&&A.rect.current){z.set(A.id,A.rect.current);continue}const N=A.node.current,B=N?new xg(h(N),N):null;A.rect.current=B,B&&z.set(A.id,B)}return z}return T},[e,c,r,v,h]);return b.useEffect(()=>{g.current=e},[e]),b.useEffect(()=>{v||S()},[r,v]),b.useEffect(()=>{c&&c.length>0&&u(null)},[JSON.stringify(c)]),b.useEffect(()=>{v||typeof f!="number"||E.current!==null||(E.current=setTimeout(()=>{S(),E.current=null},f))},[f,v,S,...a]),{droppableRects:C,measureDroppableContainers:S,measuringScheduled:c!=null};function R(){switch(p){case bs.Always:return!1;case bs.BeforeDragging:return r;default:return!r}}}function iC(e,o){return Ns(r=>e?r||(typeof o=="function"?o(e):e):null,[o,e])}function U6(e,o){return iC(e,o)}function P6(e){let{callback:o,disabled:r}=e;const a=vg(o),l=b.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(a)},[a,r]);return b.useEffect(()=>()=>l?.disconnect(),[l]),l}function cf(e){let{callback:o,disabled:r}=e;const a=vg(o),l=b.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(a)},[r]);return b.useEffect(()=>()=>l?.disconnect(),[l]),l}function V6(e){return new xg(il(e),e)}function L1(e,o,r){o===void 0&&(o=V6);const[a,l]=b.useState(null);function c(){l(h=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=h??r)!=null?p:null}const g=o(e);return JSON.stringify(h)===JSON.stringify(g)?h:g})}const u=P6({callback(h){if(e)for(const p of h){const{type:g,target:v}=p;if(g==="childList"&&v instanceof HTMLElement&&v.contains(e)){c();break}}}}),f=cf({callback:c});return Ao(()=>{c(),e?(f?.observe(e),u?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),u?.disconnect())},[e]),a}function Y6(e){const o=iC(e);return Kw(e,o)}const k1=[];function G6(e){const o=b.useRef(e),r=Ns(a=>e?a&&a!==k1&&e&&o.current&&e.parentNode===o.current.parentNode?a:bg(e):k1,[e]);return b.useEffect(()=>{o.current=e},[e]),r}function X6(e){const[o,r]=b.useState(null),a=b.useRef(e),l=b.useCallback(c=>{const u=np(c.target);u&&r(f=>f?(f.set(u,$p(u)),new Map(f)):null)},[]);return b.useEffect(()=>{const c=a.current;if(e!==c){u(c);const f=e.map(h=>{const p=np(h);return p?(p.addEventListener("scroll",l,{passive:!0}),[p,$p(p)]):null}).filter(h=>h!=null);r(f.length?new Map(f):null),a.current=e}return()=>{u(e),u(c)};function u(f){f.forEach(h=>{const p=np(h);p?.removeEventListener("scroll",l)})}},[l,e]),b.useMemo(()=>e.length?o?Array.from(o.values()).reduce((c,u)=>$i(c,u),go):oC(e):go,[e,o])}function H1(e,o){o===void 0&&(o=[]);const r=b.useRef(null);return b.useEffect(()=>{r.current=null},o),b.useEffect(()=>{const a=e!==go;a&&!r.current&&(r.current=e),!a&&r.current&&(r.current=null)},[e]),r.current?Eu(e,r.current):go}function q6(e){b.useEffect(()=>{if(!sf)return;const o=e.map(r=>{let{sensor:a}=r;return a.setup==null?void 0:a.setup()});return()=>{for(const r of o)r?.()}},e.map(o=>{let{sensor:r}=o;return r}))}function I6(e,o){return b.useMemo(()=>e.reduce((r,a)=>{let{eventName:l,handler:c}=a;return r[l]=u=>{c(u,o)},r},{}),[e,o])}function lC(e){return b.useMemo(()=>e?v6(e):null,[e])}const U1=[];function F6(e,o){o===void 0&&(o=il);const[r]=e,a=lC(r?_n(r):null),[l,c]=b.useState(U1);function u(){c(()=>e.length?e.map(h=>tC(h)?a:new xg(o(h),h)):U1)}const f=cf({callback:u});return Ao(()=>{f?.disconnect(),u(),e.forEach(h=>f?.observe(h))},[e]),l}function Z6(e){if(!e)return null;if(e.children.length>1)return e;const o=e.children[0];return Ds(o)?o:e}function Q6(e){let{measure:o}=e;const[r,a]=b.useState(null),l=b.useCallback(p=>{for(const{target:g}of p)if(Ds(g)){a(v=>{const x=o(g);return v?{...v,width:x.width,height:x.height}:x});break}},[o]),c=cf({callback:l}),u=b.useCallback(p=>{const g=Z6(p);c?.disconnect(),g&&c?.observe(g),a(g?o(g):null)},[o,c]),[f,h]=Cu(u);return b.useMemo(()=>({nodeRef:f,rect:r,setRef:h}),[r,f,h])}const K6=[{sensor:wg,options:{}},{sensor:aC,options:{}}],W6={current:{}},fu={draggable:{measure:M1},droppable:{measure:M1,strategy:bs.WhileDragging,frequency:kp.Optimized},dragOverlay:{measure:il}};class cs extends Map{get(o){var r;return o!=null&&(r=super.get(o))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(o=>{let{disabled:r}=o;return!r})}getNodeFor(o){var r,a;return(r=(a=this.get(o))==null?void 0:a.node.current)!=null?r:void 0}}const J6={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new cs,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ru},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:fu,measureDroppableContainers:Ru,windowRect:null,measuringScheduled:!1},e4={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ru,draggableNodes:new Map,over:null,measureDroppableContainers:Ru},uf=b.createContext(e4),sC=b.createContext(J6);function t4(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new cs}}}function n4(e,o){switch(o.type){case Vt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:o.initialCoordinates,active:o.active}};case Vt.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:o.coordinates.x-e.draggable.initialCoordinates.x,y:o.coordinates.y-e.draggable.initialCoordinates.y}}};case Vt.DragEnd:case Vt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Vt.RegisterDroppable:{const{element:r}=o,{id:a}=r,l=new cs(e.droppable.containers);return l.set(a,r),{...e,droppable:{...e.droppable,containers:l}}}case Vt.SetDroppableDisabled:{const{id:r,key:a,disabled:l}=o,c=e.droppable.containers.get(r);if(!c||a!==c.key)return e;const u=new cs(e.droppable.containers);return u.set(r,{...c,disabled:l}),{...e,droppable:{...e.droppable,containers:u}}}case Vt.UnregisterDroppable:{const{id:r,key:a}=o,l=e.droppable.containers.get(r);if(!l||a!==l.key)return e;const c=new cs(e.droppable.containers);return c.delete(r),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function o4(e){let{disabled:o}=e;const{active:r,activatorEvent:a,draggableNodes:l}=b.useContext(uf),c=jp(a),u=jp(r?.id);return b.useEffect(()=>{if(!o&&!a&&c&&u!=null){if(!yg(c)||document.activeElement===c.target)return;const f=l.get(u);if(!f)return;const{activatorNode:h,node:p}=f;if(!h.current&&!p.current)return;requestAnimationFrame(()=>{for(const g of[h.current,p.current]){if(!g)continue;const v=q5(g);if(v){v.focus();break}}})}},[a,o,l,u,c]),null}function r4(e,o){let{transform:r,...a}=o;return e!=null&&e.length?e.reduce((l,c)=>c({transform:l,...a}),r):r}function a4(e){return b.useMemo(()=>({draggable:{...fu.draggable,...e?.draggable},droppable:{...fu.droppable,...e?.droppable},dragOverlay:{...fu.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function i4(e){let{activeNode:o,measure:r,initialRect:a,config:l=!0}=e;const c=b.useRef(!1),{x:u,y:f}=typeof l=="boolean"?{x:l,y:l}:l;Ao(()=>{if(!u&&!f||!o){c.current=!1;return}if(c.current||!a)return;const p=o?.node.current;if(!p||p.isConnected===!1)return;const g=r(p),v=Kw(g,a);if(u||(v.x=0),f||(v.y=0),c.current=!0,Math.abs(v.x)>0||Math.abs(v.y)>0){const x=Ww(p);x&&x.scrollBy({top:v.y,left:v.x})}},[o,u,f,a,r])}const cC=b.createContext({...go,scaleX:1,scaleY:1});var Hr;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Hr||(Hr={}));const l4=b.memo(function(o){var r,a,l,c;let{id:u,accessibility:f,autoScroll:h=!0,children:p,sensors:g=K6,collisionDetection:v=u6,measuring:x,modifiers:S,...E}=o;const C=b.useReducer(n4,void 0,t4),[R,T]=C,[z,A]=W5(),[N,B]=b.useState(Hr.Uninitialized),M=N===Hr.Initialized,{draggable:{active:$,nodes:L,translate:H},droppable:{containers:I}}=R,Y=$!=null?L.get($):null,X=b.useRef({initial:null,translated:null}),ee=b.useMemo(()=>{var Et;return $!=null?{id:$,data:(Et=Y?.data)!=null?Et:W6,rect:X}:null},[$,Y]),ne=b.useRef(null),[re,j]=b.useState(null),[k,V]=b.useState(null),P=vs(E,Object.values(E)),Z=As("DndDescribedBy",u),D=b.useMemo(()=>I.getEnabled(),[I]),O=a4(x),{droppableRects:q,measureDroppableContainers:W,measuringScheduled:ie}=H6(D,{dragging:M,dependencies:[H.x,H.y],config:O.droppable}),ue=L6(L,$),ve=b.useMemo(()=>k?Bp(k):null,[k]),fe=$a(),be=U6(ue,O.draggable.measure);i4({activeNode:$!=null?L.get($):null,config:fe.layoutShiftCompensation,initialRect:be,measure:O.draggable.measure});const ye=L1(ue,O.draggable.measure,be),Xe=L1(ue?ue.parentElement:null),Ne=b.useRef({activatorEvent:null,active:null,activeNode:ue,collisionRect:null,collisions:null,droppableRects:q,draggableNodes:L,draggingNode:null,draggingNodeRect:null,droppableContainers:I,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),We=I.getNodeFor((r=Ne.current.over)==null?void 0:r.id),Be=Q6({measure:O.dragOverlay.measure}),nt=(a=Be.nodeRef.current)!=null?a:ue,vt=M?(l=Be.rect)!=null?l:ye:null,pe=!!(Be.nodeRef.current&&Be.rect),me=Y6(pe?null:ye),we=lC(nt?_n(nt):null),De=G6(M?We??ue:null),Ae=F6(De),xe=r4(S,{transform:{x:H.x-me.x,y:H.y-me.y,scaleX:1,scaleY:1},activatorEvent:k,active:ee,activeNodeRect:ye,containerNodeRect:Xe,draggingNodeRect:vt,over:Ne.current.over,overlayNodeRect:Be.rect,scrollableAncestors:De,scrollableAncestorRects:Ae,windowRect:we}),$e=ve?$i(ve,H):null,de=X6(De),Re=H1(de),dt=H1(de,[ye]),ot=$i(xe,Re),yt=vt?h6(vt,xe):null,Je=ee&&yt?v({active:ee,collisionRect:yt,droppableRects:q,droppableContainers:D,pointerCoordinates:$e}):null,wt=l6(Je,"id"),[on,Qr]=b.useState(null),jo=pe?xe:$i(xe,dt),Gt=f6(jo,(c=on?.rect)!=null?c:null,ye),st=b.useRef(null),Ct=b.useCallback((Et,Rt)=>{let{sensor:Xt,options:hn}=Rt;if(ne.current==null)return;const pn=L.get(ne.current);if(!pn)return;const rn=Et.nativeEvent,mn=new Xt({active:ne.current,activeNode:pn,event:rn,options:hn,context:Ne,onAbort(Ht){if(!L.get(Ht))return;const{onDragAbort:Dn}=P.current,kn={id:Ht};Dn?.(kn),z({type:"onDragAbort",event:kn})},onPending(Ht,oo,Dn,kn){if(!L.get(Ht))return;const{onDragPending:$o}=P.current,ro={id:Ht,constraint:oo,initialCoordinates:Dn,offset:kn};$o?.(ro),z({type:"onDragPending",event:ro})},onStart(Ht){const oo=ne.current;if(oo==null)return;const Dn=L.get(oo);if(!Dn)return;const{onDragStart:kn}=P.current,Bo={activatorEvent:rn,active:{id:oo,data:Dn.data,rect:X}};co.unstable_batchedUpdates(()=>{kn?.(Bo),B(Hr.Initializing),T({type:Vt.DragStart,initialCoordinates:Ht,active:oo}),z({type:"onDragStart",event:Bo}),j(st.current),V(rn)})},onMove(Ht){T({type:Vt.DragMove,coordinates:Ht})},onEnd:Ln(Vt.DragEnd),onCancel:Ln(Vt.DragCancel)});st.current=mn;function Ln(Ht){return async function(){const{active:Dn,collisions:kn,over:Bo,scrollAdjustedTranslate:$o}=Ne.current;let ro=null;if(Dn&&$o){const{cancelDrop:hr}=P.current;ro={activatorEvent:rn,active:Dn,collisions:kn,delta:$o,over:Bo},Ht===Vt.DragEnd&&typeof hr=="function"&&await Promise.resolve(hr(ro))&&(Ht=Vt.DragCancel)}ne.current=null,co.unstable_batchedUpdates(()=>{T({type:Ht}),B(Hr.Uninitialized),Qr(null),j(null),V(null),st.current=null;const hr=Ht===Vt.DragEnd?"onDragEnd":"onDragCancel";if(ro){const Hn=P.current[hr];Hn?.(ro),z({type:hr,event:ro})}})}}},[L]),Kr=b.useCallback((Et,Rt)=>(Xt,hn)=>{const pn=Xt.nativeEvent,rn=L.get(hn);if(ne.current!==null||!rn||pn.dndKit||pn.defaultPrevented)return;const mn={active:rn};Et(Xt,Rt.options,mn)===!0&&(pn.dndKit={capturedBy:Rt.sensor},ne.current=hn,Ct(Xt,Rt))},[L,Ct]),Ms=k6(g,Kr);q6(g),Ao(()=>{ye&&N===Hr.Initializing&&B(Hr.Initialized)},[ye,N]),b.useEffect(()=>{const{onDragMove:Et}=P.current,{active:Rt,activatorEvent:Xt,collisions:hn,over:pn}=Ne.current;if(!Rt||!Xt)return;const rn={active:Rt,activatorEvent:Xt,collisions:hn,delta:{x:ot.x,y:ot.y},over:pn};co.unstable_batchedUpdates(()=>{Et?.(rn),z({type:"onDragMove",event:rn})})},[ot.x,ot.y]),b.useEffect(()=>{const{active:Et,activatorEvent:Rt,collisions:Xt,droppableContainers:hn,scrollAdjustedTranslate:pn}=Ne.current;if(!Et||ne.current==null||!Rt||!pn)return;const{onDragOver:rn}=P.current,mn=hn.get(wt),Ln=mn&&mn.rect.current?{id:mn.id,rect:mn.rect.current,data:mn.data,disabled:mn.disabled}:null,Ht={active:Et,activatorEvent:Rt,collisions:Xt,delta:{x:pn.x,y:pn.y},over:Ln};co.unstable_batchedUpdates(()=>{Qr(Ln),rn?.(Ht),z({type:"onDragOver",event:Ht})})},[wt]),Ao(()=>{Ne.current={activatorEvent:k,active:ee,activeNode:ue,collisionRect:yt,collisions:Je,droppableRects:q,draggableNodes:L,draggingNode:nt,draggingNodeRect:vt,droppableContainers:I,over:on,scrollableAncestors:De,scrollAdjustedTranslate:ot},X.current={initial:vt,translated:yt}},[ee,ue,Je,yt,L,nt,vt,q,I,on,De,ot]),j6({...fe,delta:H,draggingRect:yt,pointerCoordinates:$e,scrollableAncestors:De,scrollableAncestorRects:Ae});const df=b.useMemo(()=>({active:ee,activeNode:ue,activeNodeRect:ye,activatorEvent:k,collisions:Je,containerNodeRect:Xe,dragOverlay:Be,draggableNodes:L,droppableContainers:I,droppableRects:q,over:on,measureDroppableContainers:W,scrollableAncestors:De,scrollableAncestorRects:Ae,measuringConfiguration:O,measuringScheduled:ie,windowRect:we}),[ee,ue,ye,k,Je,Xe,Be,L,I,q,on,W,De,Ae,O,ie,we]),Ba=b.useMemo(()=>({activatorEvent:k,activators:Ms,active:ee,activeNodeRect:ye,ariaDescribedById:{draggable:Z},dispatch:T,draggableNodes:L,over:on,measureDroppableContainers:W}),[k,Ms,ee,ye,T,Z,L,on,W]);return Ge.createElement(Qw.Provider,{value:A},Ge.createElement(uf.Provider,{value:Ba},Ge.createElement(sC.Provider,{value:df},Ge.createElement(cC.Provider,{value:Gt},p)),Ge.createElement(o4,{disabled:f?.restoreFocus===!1})),Ge.createElement(t6,{...f,hiddenTextDescribedById:Z}));function $a(){const Et=re?.autoScrollEnabled===!1,Rt=typeof h=="object"?h.enabled===!1:h===!1,Xt=M&&!Et&&!Rt;return typeof h=="object"?{...h,enabled:Xt}:{enabled:Xt}}}),s4=b.createContext(null),P1="button",c4="Draggable";function u4(e){let{id:o,data:r,disabled:a=!1,attributes:l}=e;const c=As(c4),{activators:u,activatorEvent:f,active:h,activeNodeRect:p,ariaDescribedById:g,draggableNodes:v,over:x}=b.useContext(uf),{role:S=P1,roleDescription:E="draggable",tabIndex:C=0}=l??{},R=h?.id===o,T=b.useContext(R?cC:s4),[z,A]=Cu(),[N,B]=Cu(),M=I6(u,o),$=vs(r);Ao(()=>(v.set(o,{id:o,key:c,node:z,activatorNode:N,data:$}),()=>{const H=v.get(o);H&&H.key===c&&v.delete(o)}),[v,o]);const L=b.useMemo(()=>({role:S,tabIndex:C,"aria-disabled":a,"aria-pressed":R&&S===P1?!0:void 0,"aria-roledescription":E,"aria-describedby":g.draggable}),[a,S,C,R,E,g.draggable]);return{active:h,activatorEvent:f,activeNodeRect:p,attributes:L,isDragging:R,listeners:a?void 0:M,node:z,over:x,setNodeRef:A,setActivatorNodeRef:B,transform:T}}function f4(){return b.useContext(sC)}const d4="Droppable",h4={timeout:25};function p4(e){let{data:o,disabled:r=!1,id:a,resizeObserverConfig:l}=e;const c=As(d4),{active:u,dispatch:f,over:h,measureDroppableContainers:p}=b.useContext(uf),g=b.useRef({disabled:r}),v=b.useRef(!1),x=b.useRef(null),S=b.useRef(null),{disabled:E,updateMeasurementsFor:C,timeout:R}={...h4,...l},T=vs(C??a),z=b.useCallback(()=>{if(!v.current){v.current=!0;return}S.current!=null&&clearTimeout(S.current),S.current=setTimeout(()=>{p(Array.isArray(T.current)?T.current:[T.current]),S.current=null},R)},[R]),A=cf({callback:z,disabled:E||!u}),N=b.useCallback((L,H)=>{A&&(H&&(A.unobserve(H),v.current=!1),L&&A.observe(L))},[A]),[B,M]=Cu(N),$=vs(o);return b.useEffect(()=>{!A||!B.current||(A.disconnect(),v.current=!1,A.observe(B.current))},[B,A]),b.useEffect(()=>(f({type:Vt.RegisterDroppable,element:{id:a,key:c,disabled:r,node:B,rect:x,data:$}}),()=>f({type:Vt.UnregisterDroppable,key:c,id:a})),[a]),b.useEffect(()=>{r!==g.current.disabled&&(f({type:Vt.SetDroppableDisabled,id:a,key:c,disabled:r}),g.current.disabled=r)},[a,c,r,f]),{active:u,rect:x,isOver:h?.id===a,node:B,over:h,setNodeRef:M}}function Cg(e,o,r){const a=e.slice();return a.splice(r<0?a.length+r:r,0,a.splice(o,1)[0]),a}function m4(e,o){return e.reduce((r,a,l)=>{const c=o.get(a);return c&&(r[l]=c),r},Array(e.length))}function Kc(e){return e!==null&&e>=0}function g4(e,o){if(e===o)return!0;if(e.length!==o.length)return!1;for(let r=0;r{let{rects:o,activeIndex:r,overIndex:a,index:l}=e;const c=Cg(o,a,r),u=o[l],f=c[l];return!f||!u?null:{x:f.left-u.left,y:f.top-u.top,scaleX:f.width/u.width,scaleY:f.height/u.height}},Wc={scaleX:1,scaleY:1},y4=e=>{var o;let{activeIndex:r,activeNodeRect:a,index:l,rects:c,overIndex:u}=e;const f=(o=c[r])!=null?o:a;if(!f)return null;if(l===r){const p=c[u];return p?{x:0,y:rr&&l<=u?{x:0,y:-f.height-h,...Wc}:l=u?{x:0,y:f.height+h,...Wc}:{x:0,y:0,...Wc}};function b4(e,o,r){const a=e[o],l=e[o-1],c=e[o+1];return a?ra.map(M=>typeof M=="object"&&"id"in M?M.id:M),[a]),E=u!=null,C=u?S.indexOf(u.id):-1,R=p?S.indexOf(p.id):-1,T=b.useRef(S),z=!g4(S,T.current),A=R!==-1&&C===-1||z,N=v4(c);Ao(()=>{z&&E&&g(S)},[z,S,E,g]),b.useEffect(()=>{T.current=S},[S]);const B=b.useMemo(()=>({activeIndex:C,containerId:v,disabled:N,disableTransforms:A,items:S,overIndex:R,useDragOverlay:x,sortedRects:m4(S,h),strategy:l}),[C,v,N.draggable,N.droppable,A,S,R,h,x,l]);return Ge.createElement(dC.Provider,{value:B},o)}const S4=e=>{let{id:o,items:r,activeIndex:a,overIndex:l}=e;return Cg(r,a,l).indexOf(o)},w4=e=>{let{containerId:o,isSorting:r,wasDragging:a,index:l,items:c,newIndex:u,previousItems:f,previousContainerId:h,transition:p}=e;return!p||!a||f!==c&&l===u?!1:r?!0:u!==l&&o===h},C4={duration:200,easing:"ease"},hC="transform",E4=ys.Transition.toString({property:hC,duration:0,easing:"linear"}),R4={roleDescription:"sortable"};function T4(e){let{disabled:o,index:r,node:a,rect:l}=e;const[c,u]=b.useState(null),f=b.useRef(r);return Ao(()=>{if(!o&&r!==f.current&&a.current){const h=l.current;if(h){const p=il(a.current,{ignoreTransform:!0}),g={x:h.left-p.left,y:h.top-p.top,scaleX:h.width/p.width,scaleY:h.height/p.height};(g.x||g.y)&&u(g)}}r!==f.current&&(f.current=r)},[o,r,a,l]),b.useEffect(()=>{c&&u(null)},[c]),c}function _4(e){let{animateLayoutChanges:o=w4,attributes:r,disabled:a,data:l,getNewIndex:c=S4,id:u,strategy:f,resizeObserverConfig:h,transition:p=C4}=e;const{items:g,containerId:v,activeIndex:x,disabled:S,disableTransforms:E,sortedRects:C,overIndex:R,useDragOverlay:T,strategy:z}=b.useContext(dC),A=D4(a,S),N=g.indexOf(u),B=b.useMemo(()=>({sortable:{containerId:v,index:N,items:g},...l}),[v,l,N,g]),M=b.useMemo(()=>g.slice(g.indexOf(u)),[g,u]),{rect:$,node:L,isOver:H,setNodeRef:I}=p4({id:u,data:B,disabled:A.droppable,resizeObserverConfig:{updateMeasurementsFor:M,...h}}),{active:Y,activatorEvent:X,activeNodeRect:ee,attributes:ne,setNodeRef:re,listeners:j,isDragging:k,over:V,setActivatorNodeRef:P,transform:Z}=u4({id:u,data:B,attributes:{...R4,...r},disabled:A.draggable}),D=V5(I,re),O=!!Y,q=O&&!E&&Kc(x)&&Kc(R),W=!T&&k,ie=W&&q?Z:null,ve=q?ie??(f??z)({rects:C,activeNodeRect:ee,activeIndex:x,overIndex:R,index:N}):null,fe=Kc(x)&&Kc(R)?c({id:u,items:g,activeIndex:x,overIndex:R}):N,be=Y?.id,ye=b.useRef({activeId:be,items:g,newIndex:fe,containerId:v}),Xe=g!==ye.current.items,Ne=o({active:Y,containerId:v,isDragging:k,isSorting:O,id:u,index:N,items:g,newIndex:ye.current.newIndex,previousItems:ye.current.items,previousContainerId:ye.current.containerId,transition:p,wasDragging:ye.current.activeId!=null}),We=T4({disabled:!Ne,index:N,node:L,rect:$});return b.useEffect(()=>{O&&ye.current.newIndex!==fe&&(ye.current.newIndex=fe),v!==ye.current.containerId&&(ye.current.containerId=v),g!==ye.current.items&&(ye.current.items=g)},[O,fe,v,g]),b.useEffect(()=>{if(be===ye.current.activeId)return;if(be!=null&&ye.current.activeId==null){ye.current.activeId=be;return}const nt=setTimeout(()=>{ye.current.activeId=be},50);return()=>clearTimeout(nt)},[be]),{active:Y,activeIndex:x,attributes:ne,data:B,rect:$,index:N,newIndex:fe,items:g,isOver:H,isSorting:O,isDragging:k,listeners:j,node:L,overIndex:R,over:V,setNodeRef:D,setActivatorNodeRef:P,setDroppableNodeRef:I,setDraggableNodeRef:re,transform:We??ve,transition:Be()};function Be(){if(We||Xe&&ye.current.newIndex===N)return E4;if(!(W&&!yg(X)||!p)&&(O||Ne))return ys.Transition.toString({...p,property:hC})}}function D4(e,o){var r,a;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e?.draggable)!=null?r:o.draggable,droppable:(a=e?.droppable)!=null?a:o.droppable}}Ke.Down,Ke.Right,Ke.Up,Ke.Left;const pC=""+new URL("../logo.png",import.meta.url).href;let mC=()=>{};function V1(e){mC=e}const zs=H5({tokenKey:"mv_token",onUnauthorized:e=>mC(e)}),N4=zs.login,A4=zs.logout,z4=zs.isAuthenticated,M4=zs.getUsername,{request:Oo}=zs,O4=()=>Oo("/fields"),Y1=()=>Oo("/config"),j4=()=>Oo("/channels"),B4=(e,o)=>Oo(`/styles/preview?layout=${encodeURIComponent(e)}&channel_count=${o}`),Ur=e=>Oo("/config",{method:"PATCH",body:JSON.stringify(e)}),$4=()=>Oo("/refresh",{method:"POST"}),gC=()=>Oo("/streams"),Hp=e=>Oo("/streams/restart",{method:"POST",body:JSON.stringify(e!=null?{n:e}:{})}),L4=(e,o)=>Oo("/streams/restart",{method:"POST",body:JSON.stringify({n:e,channel_idx:o})}),vC=(e,o,r)=>Oo("/styles/background",{method:"POST",body:JSON.stringify({style_id:e,filename:o,data_base64:r})});async function yC(e){const o=localStorage.getItem("mv_token"),r=await fetch(`/api/styles/background?style_id=${encodeURIComponent(e)}`,{headers:o?{Authorization:`Bearer ${o}`}:{}});return r.ok?r.blob():null}const k4=/^(video_encoder|multiview_[0-9a-f]{8}_(selector_type|channel_count|epg_source_mode))$/,bC=e=>k4.test(e),H4=/^Layout\s+\d+[:\s]*/i,U4=e=>({...e,label:e.label.replace(H4,"")});function P4(e,o){const r=[],a=[],l=[];let c=null,u=null;for(const f of e){const h=f.id.replace(`multiview_${o}_`,"");if(["name","layout","selector_type"].includes(h))r.push(f);else if(h==="channel_count")u=f;else if(h==="audio_source")c=f;else if(h.startsWith("epg_"))l.push(f);else{if(f.type==="info")continue;a.push(f)}}return{base:r,channels:a,epg:l,audioSource:c,channelCountField:u}}function Na(e=4){const o=new Uint8Array(e);return crypto.getRandomValues(o),Array.from(o,r=>r.toString(16).padStart(2,"0")).join("")}function xC(e,o){const r=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),a=URL.createObjectURL(r),l=document.createElement("a");l.href=a,l.download=o,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(a)}const Up=["center","top","bottom","left","right"];function Ta(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function V4(e,o){if(!Ta(e))throw new Error(`${o}: not an object`);if(!["static","row","grid"].includes(e.type))throw new Error(`${o}.type: invalid "${e.type}"`);for(const r of["x","y","w","h"])if(typeof e[r]!="number"||!Number.isFinite(e[r]))throw new Error(`${o}.${r}: must be a finite number`);if(e.name!=null&&typeof e.name!="string")throw new Error(`${o}.name: must be a string`);if(e.valign!=null&&!Up.includes(e.valign))throw new Error(`${o}.valign: invalid "${e.valign}"`);if(e.halign!=null&&!Up.includes(e.halign))throw new Error(`${o}.halign: invalid "${e.halign}"`);if(e.type==="row"&&e.direction!=null&&!["horizontal","vertical"].includes(e.direction))throw new Error(`${o}.direction: invalid "${e.direction}"`);if(e.max!=null&&(typeof e.max!="number"||!Number.isFinite(e.max)))throw new Error(`${o}.max: must be a number`);if(e.lockAspect!=null&&typeof e.lockAspect!="boolean")throw new Error(`${o}.lockAspect: must be a boolean`)}function Pp(e,o="style"){if(!Ta(e))throw new Error(`${o}: not an object`);if(e.name!=null&&typeof e.name!="string")throw new Error(`${o}.name: must be a string`);if(!Array.isArray(e.elements))throw new Error(`${o}.elements: must be an array`);if(e.elements.forEach((r,a)=>V4(r,`${o}.elements[${a}]`)),e.background_image_data!=null&&typeof e.background_image_data!="string")throw new Error(`${o}.background_image_data: must be a string`);if(e.background_image_filename!=null&&typeof e.background_image_filename!="string")throw new Error(`${o}.background_image_filename: must be a string`)}const Y4={name:"string",layout:"string",channel_count:"number",selector_type:"string",epg_source_mode:"string"};function G4(e,o){if(!Ta(e))throw new Error(`${o}: not an object`);for(const[r,a]of Object.entries(Y4))if(e[r]!=null&&typeof e[r]!==a)throw new Error(`${o}.${r}: must be a ${a}`);if(e.channels!=null){if(!Array.isArray(e.channels))throw new Error(`${o}.channels: must be an array`);e.channels.forEach((r,a)=>{if(r!=null&&typeof r!="string")throw new Error(`${o}.channels[${a}]: must be a string`)})}}function X4(e){if(!Ta(e))throw new Error("backup: not an object");if(!Array.isArray(e.layouts))throw new Error("backup.layouts: must be an array");if(e.layouts.forEach((o,r)=>G4(o,`backup.layouts[${r}]`)),e.global!=null&&!Ta(e.global))throw new Error("backup.global: must be an object");if(e.custom_styles!=null){if(!Ta(e.custom_styles))throw new Error("backup.custom_styles: must be an object");for(const[o,r]of Object.entries(e.custom_styles))Pp(r,`backup.custom_styles["${o}"]`)}}function q4(e){if(!Ta(e))throw new Error("backup: not an object");const o=e.multiview_order;if(!Array.isArray(o)||o.some(l=>typeof l!="string"))throw new Error("backup.multiview_order: must be an array of strings");const r=new Set(o),a=/^multiview_([0-9a-f]{8})_(.+)$/;for(const l of Object.keys(e)){const c=l.match(a);if(c&&!r.has(c[1]))throw new Error(`backup["${l}"]: id "${c[1]}" not present in multiview_order`)}}function I4({label:e,description:o,data:r,value:a,onChange:l}){const c=Ym({onDropdownClose:()=>c.resetSelectedOption()}),[u,f]=b.useState(""),h=r.find(g=>g.value===a),p=r.filter(g=>g.label.toLowerCase().includes(u.trim().toLowerCase()));return y.jsxs(Pe,{store:c,onOptionSubmit:g=>{l(g),f(""),c.closeDropdown()},children:[y.jsx(Pe.Target,{children:y.jsx(Mo,{label:e,description:o,component:"button",type:"button",pointer:!0,rightSection:y.jsx(Pe.Chevron,{}),onClick:()=>c.toggleDropdown(),children:h?.label??y.jsx(Ye,{component:"span",c:"dimmed",children:"Select channel"})})}),y.jsxs(Pe.Dropdown,{children:[y.jsx(Pe.Search,{value:u,onChange:g=>f(g.currentTarget.value),placeholder:"Search channels..."}),y.jsx(Pe.Options,{mah:260,style:{overflowY:"auto"},children:p.length===0?y.jsx(Pe.Empty,{children:"No channels found"}):p.map(g=>y.jsx(Pe.Option,{value:g.value,active:g.value===a,children:g.label},g.value))})]})]})}function F4({id:e,position:o,fields:r,settings:a,canRemove:l,hasActiveStream:c,dragHandleProps:u,onSettingsChange:f,onFieldsReload:h,onRemove:p,onChannelCountChange:g}){const[v,x]=b.useState(!1),S=qw(Ur,{onOptimisticChange:f,shouldReload:bC,onReload:h,onSaved:()=>Qe.show({message:"Saved",color:"green",autoClose:1500}),onError:I=>Qe.show({title:"Save failed",message:I.message,color:"red",autoClose:4e3})}),{base:E,channels:C,epg:R,audioSource:T,channelCountField:z}=P4(r.map(U4),e),A=a[`multiview_${e}_name`]||`Multiview ${o}`,N=a[`multiview_${e}_channel_count`]??z?.default??4,B=z?.min??2,M=z?.max??9;function $(I){return I.length?y.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"var(--mantine-spacing-sm)"},children:I.map(Y=>y.jsx(Op,{field:Y,value:a[Y.id],onChange:X=>S(Y.id,X,Y.type!=="string")},Y.id))}):null}function L(I){return I.length?y.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"var(--mantine-spacing-sm)"},children:I.map(Y=>{const X=new Set,ee=(Y.options??[]).reduce((ne,re)=>{const j=String(re.value);return X.has(j)||(X.add(j),ne.push({value:j,label:re.label})),ne},[]);return y.jsx(I4,{label:Y.label,description:Y.description,data:ee,value:String(a[Y.id]??Y.default??""),onChange:ne=>S(Y.id,ne,!0)},Y.id)})}):null}const H=y.jsxs(mt,{gap:4,wrap:"nowrap",children:[y.jsx(Yt,{size:"sm",variant:"subtle",color:"gray",style:{cursor:"grab",touchAction:"none"},onClick:I=>I.stopPropagation(),...u,children:y.jsx(v5,{size:16})}),y.jsx(Dt,{size:"xs",color:"red",variant:"subtle",leftSection:y.jsx(pg,{size:14}),style:{visibility:l?"visible":"hidden"},onClick:I=>{I.stopPropagation(),x(!0)},children:"Remove"})]});return y.jsxs(y.Fragment,{children:[y.jsx(Iw,{as:"Card",title:`Layout ${o}: ${A}`,trailingAction:H,children:y.jsxs(Qt,{gap:"md",p:"md",pt:0,children:[$(E),(C.length>0||z)&&y.jsxs(y.Fragment,{children:[y.jsx(Su,{label:y.jsxs(mt,{gap:4,align:"center",children:[y.jsx(Ye,{size:"xs",c:"dimmed",children:"Channels"}),y.jsx(Yt,{size:"xs",variant:"subtle",disabled:N<=B,onClick:()=>g(-1),children:y.jsx(S5,{size:10})}),y.jsx(Ye,{size:"xs",fw:600,w:14,ta:"center",children:N}),y.jsx(Yt,{size:"xs",variant:"subtle",disabled:N>=M,onClick:()=>g(1),children:y.jsx(is,{size:10})})]}),labelPosition:"left"}),L(C)]}),T&&y.jsx(Op,{field:T,value:a[T.id],onChange:I=>S(T.id,I,!0)}),R.length>0&&y.jsxs(y.Fragment,{children:[y.jsx(Su,{label:"EPG",labelPosition:"left"}),$(R)]})]})}),y.jsxs(Tn,{opened:v,onClose:()=>x(!1),title:`Remove Layout ${o}`,size:"xs",centered:!0,children:[y.jsxs(Ye,{size:"sm",children:["Remove Layout ",o,": ",A,"? This cannot be undone."]}),c&&y.jsx(Ye,{size:"sm",c:"orange",mt:"xs",children:"This layout has an active stream — removing it will disconnect that viewer."}),y.jsxs(mt,{mt:"md",justify:"flex-end",children:[y.jsx(Dt,{variant:"default",onClick:()=>x(!1),children:"Cancel"}),y.jsx(Dt,{color:"red",onClick:()=>{x(!1),p()},children:"Remove"})]})]})]})}function Z4({opened:e,onClose:o,settings:r}){const[a,l]=b.useState([]),[c,u]=b.useState({}),[f,h]=b.useState(null),p=b.useCallback(async()=>{try{const x=await gC();l(x.active??[])}catch{}},[]);b.useEffect(()=>{if(!e)return;p();const x=setInterval(p,4e3);return()=>clearInterval(x)},[e,p]);const g=async(x,S,E)=>{u(C=>({...C,[x]:!0}));try{await S(),Qe.show({message:E,color:"blue",autoClose:2e3}),await p()}catch(C){Qe.show({title:"Failed",message:C.message,color:"red",autoClose:4e3})}finally{u(C=>({...C,[x]:!1}))}},v=(x,S,E,C,R)=>h({title:x,message:S,confirmLabel:E,color:C,onConfirm:R});return y.jsxs(Tn,{opened:e,onClose:o,title:"Active Multiviews",size:"sm",centered:!0,children:[y.jsx(Xw,{action:f,onClose:()=>h(null)}),a.length===0?y.jsx(Ye,{size:"sm",c:"dimmed",children:"No multiviews currently active."}):y.jsx(Qt,{gap:"md",children:a.map(({n:x,channels:S})=>{const E=r[`multiview_${x}_name`]||`Multiview ${x}`;return y.jsxs("div",{children:[y.jsxs(mt,{justify:"space-between",mb:6,children:[y.jsx(Ye,{size:"sm",fw:600,children:E}),y.jsx(Dt,{size:"xs",color:"orange",variant:"subtle",leftSection:y.jsx(D1,{size:12}),loading:c[`${x}`],onClick:()=>v("Reload",`Reload ${E}? The compositor will restart and active players will reconnect. Some players may buffer, stutter, or require a manual refresh depending on how they handle stream interruptions.`,"Reload","orange",()=>g(`${x}`,()=>Hp(x),`${E} reloaded`)),children:"Reload"})]}),y.jsx(Qt,{gap:4,pl:"sm",children:(S??[]).map(({idx:C,name:R})=>y.jsxs(mt,{justify:"space-between",children:[y.jsx(Ye,{size:"xs",c:"dimmed",children:R}),y.jsx(Dt,{size:"xs",variant:"subtle",leftSection:y.jsx(Yw,{size:11}),loading:c[`${x}-${C}`],onClick:()=>v("Reconnect",`Reconnect ${R}?`,"Reconnect","blue",()=>g(`${x}-${C}`,()=>L4(x,C),`${R} reconnecting`)),children:"Reconnect"})]},C))})]},x)})}),a.length>1&&y.jsx(Dt,{fullWidth:!0,mt:"md",color:"orange",variant:"light",leftSection:y.jsx(D1,{size:14}),loading:c.all,onClick:()=>v("Reload All",`Reload all ${a.length} multiviews? All compositors will restart and active players will reconnect. Some players may buffer, stutter, or require a manual refresh depending on how they handle stream interruptions.`,"Reload All","orange",()=>g("all",()=>Hp(null),`${a.length} multiviews reloaded`)),children:"Reload All"})]})}var Q4={};function Vp(e,o){for(let r=0,a=e.length;r"u")return"";const a=(r=(o=window.document)==null?void 0:o.documentElement)==null?void 0:r.style;if(!a||e in a)return"";for(let l=0;lo===r.identifier)||e.changedTouches&&Vp(e.changedTouches,r=>o===r.identifier)}function cO(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function uO(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0}function fO(e,o){if(!e)return;let r=e.getElementById("react-draggable-style-el");if(!r){r=e.createElement("style"),r.type="text/css",r.id="react-draggable-style-el";const a=o??uO();a&&r.setAttribute("nonce",a),r.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;} `,r.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;} -`,e.getElementsByTagName("head")[0].appendChild(r)}e.body&&dO(e.body,"react-draggable-transparent-selection")}function q1(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{I1(e)}):I1(e)}function I1(e){if(e)try{e.body&&hO(e.body,"react-draggable-transparent-selection");const o=e.selection;if(o)o.empty();else{const r=(e.defaultView||window).getSelection();r&&r.type!=="Caret"&&r.removeAllRanges()}}catch{}}function dO(e,o){e.classList?e.classList.add(o):e.className.match(new RegExp(`(?:^|\\s)${o}(?!\\S)`))||(e.className+=` ${o}`)}function hO(e,o){e.classList?e.classList.remove(o):e.className=e.className.replace(new RegExp(`(?:^|\\s)${o}(?!\\S)`,"g"),"")}function pO(e,o,r){if(!e.props.bounds)return[o,r];let{bounds:a}=e.props;a=typeof a=="string"?a:vO(a);const l=Eg(e);if(typeof a=="string"){const{ownerDocument:c}=l,u=c.defaultView;if(!u)throw new Error("Cannot resolve the owner window of the draggable node.");let f;if(a==="parent"?f=l.parentNode:f=l.getRootNode().querySelector(a),!(f instanceof u.HTMLElement))throw new Error('Bounds selector "'+a+'" could not find an element.');const h=f,p=u.getComputedStyle(l),g=u.getComputedStyle(h);a={left:-l.offsetLeft+ln(g.paddingLeft)+ln(p.marginLeft),top:-l.offsetTop+ln(g.paddingTop)+ln(p.marginTop),right:rO(h)-nO(l)-l.offsetLeft+ln(g.paddingRight)-ln(p.marginRight),bottom:oO(h)-tO(l)-l.offsetTop+ln(g.paddingBottom)-ln(p.marginBottom)}}return rs(a.right)&&(o=Math.min(o,a.right)),rs(a.bottom)&&(r=Math.min(r,a.bottom)),rs(a.left)&&(o=Math.max(o,a.left)),rs(a.top)&&(r=Math.max(r,a.top)),[o,r]}function F1(e,o,r){const a=Math.round(o/e[0])*e[0],l=Math.round(r/e[1])*e[1];return[a,l]}function mO(e){return e.props.axis==="both"||e.props.axis==="x"}function gO(e){return e.props.axis==="both"||e.props.axis==="y"}function sp(e,o,r){const a=typeof o=="number"?sO(e,o):null;if(typeof o=="number"&&!a)return null;const l=Eg(r),c=r.props.offsetParent||l.offsetParent||l.ownerDocument.body;return aO(a||e,c,r.props.scale)}function cp(e,o,r){const a=!rs(e.lastX),l=Eg(e);return a?{node:l,deltaX:0,deltaY:0,lastX:o,lastY:r,x:o,y:r}:{node:l,deltaX:o-e.lastX,deltaY:r-e.lastY,lastX:e.lastX,lastY:e.lastY,x:o,y:r}}function up(e,o){const r=e.props.scale;return{node:o.node,x:e.state.x+o.deltaX/r,y:e.state.y+o.deltaY/r,deltaX:o.deltaX/r,deltaY:o.deltaY/r,lastX:e.state.x,lastY:e.state.y}}function vO(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function Eg(e){const o=e.findDOMNode();if(!o)throw new Error(": Unmounted during event!");return o}function Ro(...e){Q4.DRAGGABLE_DEBUG&&console.log(...e)}var so={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}},Lr=so.mouse,ll=class extends b.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button=="number"&&e.button!==0||e.ctrlKey))return!1;const o=this.findDOMNode();if(!o||!o.ownerDocument||!o.ownerDocument.body)throw new Error(" not mounted on DragStart!");const{ownerDocument:r}=o;if(this.props.disabled||!(e.target instanceof r.defaultView.Node)||this.props.handle&&!X1(e.target,this.props.handle,o)||this.props.cancel&&X1(e.target,this.props.cancel,o))return;e.type==="touchstart"&&!this.props.allowMobileScroll&&e.preventDefault();const a=cO(e);this.touchIdentifier=a;const l=sp(e,a,this);if(l==null)return;const{x:c,y:u}=l,f=cp(this,c,u);Ro("DraggableCore: handleDragStart: %j",f),Ro("calling",this.props.onStart),!(this.props.onStart(e,f)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&fO(r,this.props.nonce),this.dragging=!0,this.lastX=c,this.lastY=u,lp(r,Lr.move,this.handleDrag),lp(r,Lr.stop,this.handleDragStop))},this.handleDrag=e=>{const o=sp(e,this.touchIdentifier,this);if(o==null)return;let{x:r,y:a}=o;if(Array.isArray(this.props.grid)){let u=r-this.lastX,f=a-this.lastY;if([u,f]=F1(this.props.grid,u,f),!u&&!f)return;r=this.lastX+u,a=this.lastY+f}const l=cp(this,r,a);if(Ro("DraggableCore: handleDrag: %j",l),this.props.onDrag(e,l)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent("mouseup"))}catch{const u=document.createEvent("MouseEvents");u.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(u)}return}this.lastX=r,this.lastY=a},this.handleDragStop=e=>{if(!this.dragging)return;const o=sp(e,this.touchIdentifier,this);if(o==null)return;let{x:r,y:a}=o;if(Array.isArray(this.props.grid)){let f=r-this.lastX||0,h=a-this.lastY||0;[f,h]=F1(this.props.grid,f,h),r=this.lastX+f,a=this.lastY+h}const l=cp(this,r,a);if(this.props.onStop(e,l)===!1||this.mounted===!1)return!1;const u=this.findDOMNode();u&&this.props.enableUserSelectHack&&q1(u.ownerDocument),Ro("DraggableCore: handleDragStop: %j",l),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,u&&(Ro("DraggableCore: Removing handlers"),ga(u.ownerDocument,Lr.move,this.handleDrag),ga(u.ownerDocument,Lr.stop,this.handleDragStop))},this.onMouseDown=e=>(Lr=so.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(Lr=so.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(Lr=so.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(Lr=so.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;const e=this.findDOMNode();e&&lp(e,so.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const e=this.findDOMNode();if(e){const{ownerDocument:o}=e;ga(o,so.mouse.move,this.handleDrag),ga(o,so.touch.move,this.handleDrag),ga(o,so.mouse.stop,this.handleDragStop),ga(o,so.touch.stop,this.handleDragStop),ga(e,so.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&q1(o)}}findDOMNode(){var e;if((e=this.props)!=null&&e.nodeRef)return this.props.nodeRef.current;const o=Sa;return typeof o.findDOMNode=="function"?o.findDOMNode(this):(Ro("react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef"),null)}render(){return b.cloneElement(b.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};ll.displayName="DraggableCore";ll.propTypes={allowAnyClick:je.bool,allowMobileScroll:je.bool,children:je.node.isRequired,disabled:je.bool,enableUserSelectHack:je.bool,offsetParent:function(e,o){if(e[o]&&e[o].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:je.arrayOf(je.number),handle:je.string,cancel:je.string,nodeRef:je.object,nonce:je.string,onStart:je.func,onDrag:je.func,onStop:je.func,onMouseDown:je.func,scale:je.number,className:Li,style:Li,transform:Li};ll.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var ff=class extends b.Component{constructor(e){super(e),this.onDragStart=(o,r)=>{if(Ro("Draggable: onDragStart: %j",r),this.props.onStart(o,up(this,r))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(o,r)=>{if(!this.state.dragging)return!1;Ro("Draggable: onDrag: %j",r);const a=up(this,r),l={x:a.x,y:a.y,slackX:0,slackY:0};if(this.props.bounds){const{x:u,y:f}=l;l.x+=this.state.slackX,l.y+=this.state.slackY;const[h,p]=pO(this,l.x,l.y);l.x=h,l.y=p,l.slackX=this.state.slackX+(u-l.x),l.slackY=this.state.slackY+(f-l.y),a.x=l.x,a.y=l.y,a.deltaX=l.x-this.state.x,a.deltaY=l.y-this.state.y}if(this.props.onDrag(o,a)===!1)return!1;this.setState(l)},this.onDragStop=(o,r)=>{if(!this.state.dragging||this.props.onStop(o,up(this,r))===!1)return!1;Ro("Draggable: onDragStop: %j",r);const l={dragging:!1,slackX:0,slackY:0};if(!!this.props.position){const{x:u,y:f}=this.props.position;l.x=u,l.y=f}this.setState(l)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this , without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:o}){return e&&(!o||e.x!==o.x||e.y!==o.y)?(Ro("Draggable: getDerivedStateFromProps %j",{position:e,prevPropsPosition:o}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){var e;if((e=this.props)!=null&&e.nodeRef)return this.props.nodeRef.current;const o=Sa;return typeof o.findDOMNode=="function"?o.findDOMNode(this):null}render(){const{axis:e,bounds:o,children:r,defaultPosition:a,defaultClassName:l,defaultClassNameDragging:c,defaultClassNameDragged:u,position:f,positionOffset:h,scale:p,...g}=this.props;let v={},x=null;const E=!!!f||this.state.dragging,C=f||a,R={x:mO(this)&&E?this.state.x:C.x,y:gO(this)&&E?this.state.y:C.y};this.state.isElementSVG?x=lO(R,h):v=iO(R,h);const T=b.Children.only(r),z=zt(T.props.className||"",l,{[c]:this.state.dragging,[u]:this.state.dragged});return b.createElement(ll,{...g,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},b.cloneElement(T,{className:z,style:{...T.props.style,...v},transform:x}))}};ff.displayName="Draggable";ff.propTypes={...ll.propTypes,axis:je.oneOf(["both","x","y","none"]),bounds:je.oneOfType([je.shape({left:je.number,right:je.number,top:je.number,bottom:je.number}),je.string,je.oneOf([!1])]),defaultClassName:je.string,defaultClassNameDragging:je.string,defaultClassNameDragged:je.string,defaultPosition:je.shape({x:je.number,y:je.number}),positionOffset:je.shape({x:je.oneOfType([je.number,je.string]),y:je.oneOfType([je.number,je.string])}),position:je.shape({x:je.number,y:je.number}),className:Li,style:Li,transform:Li};ff.defaultProps={...ll.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1};var yO=ff,Lt=function(){return Lt=Object.assign||function(e){for(var o,r=1,a=arguments.length;r"u"?void 0:Number(a),maxHeight:typeof l>"u"?void 0:Number(l),minWidth:typeof c>"u"?void 0:Number(c),minHeight:typeof u>"u"?void 0:Number(u)}},RO=function(e){return Array.isArray(e)?e:[e,e]},TO=["as","ref","style","className","grid","gridGap","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],J1="__resizable_base__",_O=(function(e){SO(o,e);function o(r){var a,l,c,u,f=e.call(this,r)||this;return f.ratio=1,f.resizable=null,f.parentLeft=0,f.parentTop=0,f.resizableLeft=0,f.resizableRight=0,f.resizableTop=0,f.resizableBottom=0,f.targetLeft=0,f.targetTop=0,f.delta={width:0,height:0},f.appendBase=function(){if(!f.resizable||!f.window)return null;var h=f.parentNode;if(!h)return null;var p=f.window.document.createElement("div");return p.style.width="100%",p.style.height="100%",p.style.position="absolute",p.style.transform="scale(0, 0)",p.style.left="0",p.style.flex="0 0 100%",p.classList?p.classList.add(J1):p.className+=J1,h.appendChild(p),p},f.removeBase=function(h){var p=f.parentNode;p&&p.removeChild(h)},f.state={isResizing:!1,width:(l=(a=f.propsSize)===null||a===void 0?void 0:a.width)!==null&&l!==void 0?l:"auto",height:(u=(c=f.propsSize)===null||c===void 0?void 0:c.height)!==null&&u!==void 0?u:"auto",direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},f.onResizeStart=f.onResizeStart.bind(f),f.onMouseMove=f.onMouseMove.bind(f),f.onMouseUp=f.onMouseUp.bind(f),f}return Object.defineProperty(o.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"window",{get:function(){return!this.resizable||!this.resizable.ownerDocument?null:this.resizable.ownerDocument.defaultView},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||wO},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"size",{get:function(){var r=0,a=0;if(this.resizable&&this.window){var l=this.resizable.offsetWidth,c=this.resizable.offsetHeight,u=this.resizable.style.position;u!=="relative"&&(this.resizable.style.position="relative"),r=this.resizable.style.width!=="auto"?this.resizable.offsetWidth:l,a=this.resizable.style.height!=="auto"?this.resizable.offsetHeight:c,this.resizable.style.position=u}return{width:r,height:a}},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sizeStyle",{get:function(){var r=this,a=this.props.size,l=function(f){var h;if(typeof r.state[f]>"u"||r.state[f]==="auto")return"auto";if(r.propsSize&&r.propsSize[f]&&(!((h=r.propsSize[f])===null||h===void 0)&&h.toString().endsWith("%"))){if(r.state[f].toString().endsWith("%"))return r.state[f].toString();var p=r.getParentSize(),g=Number(r.state[f].toString().replace("px","")),v=g/p[f]*100;return"".concat(v,"%")}return fp(r.state[f])},c=a&&typeof a.width<"u"&&!this.state.isResizing?fp(a.width):l("width"),u=a&&typeof a.height<"u"&&!this.state.isResizing?fp(a.height):l("height");return{width:c,height:u}},enumerable:!1,configurable:!0}),o.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var r=this.appendBase();if(!r)return{width:0,height:0};var a=!1,l=this.parentNode.style.flexWrap;l!=="wrap"&&(a=!0,this.parentNode.style.flexWrap="wrap"),r.style.position="relative",r.style.minWidth="100%",r.style.minHeight="100%";var c={width:r.offsetWidth,height:r.offsetHeight};return a&&(this.parentNode.style.flexWrap=l),this.removeBase(r),c},o.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},o.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},o.prototype.componentDidMount=function(){if(!(!this.resizable||!this.window)){var r=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:r.flexBasis!=="auto"?r.flexBasis:void 0})}},o.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},o.prototype.createSizeForCssProperty=function(r,a){var l=this.propsSize&&this.propsSize[a];return this.state[a]==="auto"&&this.state.original[a]===r&&(typeof l>"u"||l==="auto")?"auto":r},o.prototype.calculateNewMaxFromBoundary=function(r,a){var l=this.props.boundsByDirection,c=this.state.direction,u=l&&_i("left",c),f=l&&_i("top",c),h,p;if(this.props.bounds==="parent"){var g=this.parentNode;g&&(h=u?this.resizableRight-this.parentLeft:g.offsetWidth+(this.parentLeft-this.resizableLeft),p=f?this.resizableBottom-this.parentTop:g.offsetHeight+(this.parentTop-this.resizableTop))}else this.props.bounds==="window"?this.window&&(h=u?this.resizableRight:this.window.innerWidth-this.resizableLeft,p=f?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(h=u?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),p=f?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return h&&Number.isFinite(h)&&(r=r&&r"u"?10:c.width,v=typeof l.width>"u"||l.width<0?r:l.width,x=typeof c.height>"u"?10:c.height,S=typeof l.height>"u"||l.height<0?a:l.height,E=h||0,C=p||0;if(f){var R=(x-E)*this.ratio+C,T=(S-E)*this.ratio+C,z=(g-C)/this.ratio+E,A=(v-C)/this.ratio+E,N=Math.max(g,R),B=Math.min(v,T),M=Math.max(x,z),$=Math.min(S,A);r=eu(r,N,B),a=eu(a,M,$)}else r=eu(r,g,v),a=eu(a,x,S);return{newWidth:r,newHeight:a}},o.prototype.setBoundingClientRect=function(){var r=1/(this.props.scale||1);if(this.props.bounds==="parent"){var a=this.parentNode;if(a){var l=a.getBoundingClientRect();this.parentLeft=l.left*r,this.parentTop=l.top*r}}if(this.props.bounds&&typeof this.props.bounds!="string"){var c=this.props.bounds.getBoundingClientRect();this.targetLeft=c.left*r,this.targetTop=c.top*r}if(this.resizable){var u=this.resizable.getBoundingClientRect(),f=u.left,h=u.top,p=u.right,g=u.bottom;this.resizableLeft=f*r,this.resizableRight=p*r,this.resizableTop=h*r,this.resizableBottom=g*r}},o.prototype.onResizeStart=function(r,a){if(!(!this.resizable||!this.window)){var l=0,c=0;if(r.nativeEvent&&CO(r.nativeEvent)?(l=r.nativeEvent.clientX,c=r.nativeEvent.clientY):r.nativeEvent&&tu(r.nativeEvent)&&(l=r.nativeEvent.touches[0].clientX,c=r.nativeEvent.touches[0].clientY),this.props.onResizeStart&&this.resizable){var u=this.props.onResizeStart(r,a,this.resizable);if(u===!1)return}this.props.size&&(typeof this.props.size.height<"u"&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),typeof this.props.size.width<"u"&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio=typeof this.props.lockAspectRatio=="number"?this.props.lockAspectRatio:this.size.width/this.size.height;var f,h=this.window.getComputedStyle(this.resizable);if(h.flexBasis!=="auto"){var p=this.parentNode;if(p){var g=this.window.getComputedStyle(p).flexDirection;this.flexDir=g.startsWith("row")?"row":"column",f=h.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var v={original:{x:l,y:c,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:Eo(Eo({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(r.target).cursor||"auto"}),direction:a,flexBasis:f};this.setState(v)}},o.prototype.onMouseMove=function(r){var a=this;if(!(!this.state.isResizing||!this.resizable||!this.window)){if(this.window.TouchEvent&&tu(r))try{r.preventDefault(),r.stopPropagation()}catch{}var l=this.props,c=l.maxWidth,u=l.maxHeight,f=l.minWidth,h=l.minHeight,p=tu(r)?r.touches[0].clientX:r.clientX,g=tu(r)?r.touches[0].clientY:r.clientY,v=this.state,x=v.direction,S=v.original,E=v.width,C=v.height,R=this.getParentSize(),T=EO(R,this.window.innerWidth,this.window.innerHeight,c,u,f,h);c=T.maxWidth,u=T.maxHeight,f=T.minWidth,h=T.minHeight;var z=this.calculateNewSizeFromDirection(p,g),A=z.newHeight,N=z.newWidth,B=this.calculateNewMaxFromBoundary(c,u);this.props.snap&&this.props.snap.x&&(N=W1(N,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(A=W1(A,this.props.snap.y,this.props.snapGap));var M=this.calculateNewSizeFromAspectRatio(N,A,{width:B.maxWidth,height:B.maxHeight},{width:f,height:h});if(N=M.newWidth,A=M.newHeight,this.props.grid){var $=K1(N,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),L=K1(A,this.props.grid[1],this.props.gridGap?this.props.gridGap[1]:0),H=this.props.snapGap||0,I=H===0||Math.abs($-N)<=H?$:N,Y=H===0||Math.abs(L-A)<=H?L:A;N=I,A=Y}var X={width:N-S.width,height:A-S.height};if(this.delta=X,E&&typeof E=="string"){if(E.endsWith("%")){var ee=N/R.width*100;N="".concat(ee,"%")}else if(E.endsWith("vw")){var ne=N/this.window.innerWidth*100;N="".concat(ne,"vw")}else if(E.endsWith("vh")){var re=N/this.window.innerHeight*100;N="".concat(re,"vh")}}if(C&&typeof C=="string"){if(C.endsWith("%")){var ee=A/R.height*100;A="".concat(ee,"%")}else if(C.endsWith("vw")){var ne=A/this.window.innerWidth*100;A="".concat(ne,"vw")}else if(C.endsWith("vh")){var re=A/this.window.innerHeight*100;A="".concat(re,"vh")}}var j={width:this.createSizeForCssProperty(N,"width"),height:this.createSizeForCssProperty(A,"height")};this.flexDir==="row"?j.flexBasis=j.width:this.flexDir==="column"&&(j.flexBasis=j.height);var k=this.state.width!==j.width,V=this.state.height!==j.height,P=this.state.flexBasis!==j.flexBasis,Z=k||V||P;Z&&co.flushSync(function(){a.setState(j)}),this.props.onResize&&Z&&this.props.onResize(r,x,this.resizable,X)}},o.prototype.onMouseUp=function(r){var a,l,c=this.state,u=c.isResizing,f=c.direction;c.original,!(!u||!this.resizable)&&(this.props.onResizeStop&&this.props.onResizeStop(r,f,this.resizable,this.delta),this.props.size&&this.setState({width:(a=this.props.size.width)!==null&&a!==void 0?a:"auto",height:(l=this.props.size.height)!==null&&l!==void 0?l:"auto"}),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:Eo(Eo({},this.state.backgroundStyle),{cursor:"auto"})}))},o.prototype.updateSize=function(r){var a,l;this.setState({width:(a=r.width)!==null&&a!==void 0?a:"auto",height:(l=r.height)!==null&&l!==void 0?l:"auto"})},o.prototype.renderResizer=function(){var r=this,a=this.props,l=a.enable,c=a.handleStyles,u=a.handleClasses,f=a.handleWrapperStyle,h=a.handleWrapperClass,p=a.handleComponent;if(!l)return null;var g=Object.keys(l).map(function(v){return l[v]!==!1?y.jsx(xO,{direction:v,onResizeStart:r.onResizeStart,replaceStyles:c&&c[v],className:u&&u[v],children:p&&p[v]?p[v]:null},v):null});return y.jsx("div",{className:h,style:f,children:g})},o.prototype.render=function(){var r=this,a=Object.keys(this.props).reduce(function(u,f){return TO.indexOf(f)!==-1||(u[f]=r.props[f]),u},{}),l=Eo(Eo(Eo({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(l.flexBasis=this.state.flexBasis);var c=this.props.as||"div";return y.jsxs(c,Eo({style:l,className:this.props.className},a,{ref:function(u){u&&(r.resizable=u)},children:[this.state.isResizing&&y.jsx("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer()]}))},o.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],gridGap:[0,0],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},o})(b.PureComponent);var Yp=function(e,o){return Yp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,a){r.__proto__=a}||function(r,a){for(var l in a)a.hasOwnProperty(l)&&(r[l]=a[l])},Yp(e,o)};function DO(e,o){Yp(e,o);function r(){this.constructor=e}e.prototype=o===null?Object.create(o):(r.prototype=o.prototype,new r)}var Pt=function(){return Pt=Object.assign||function(o){for(var r,a=1,l=arguments.length;a"u"?Number.MAX_SAFE_INTEGER:this.props.maxWidth,a=typeof this.props.maxHeight>"u"?Number.MAX_SAFE_INTEGER:this.props.maxHeight;return{maxWidth:r,maxHeight:a}},o.prototype.getSelfElement=function(){return this.resizable&&this.resizable.resizable},o.prototype.getOffsetHeight=function(r){var a=this.props.scale;switch(this.props.bounds){case"window":return window.innerHeight/a;case"body":return document.body.offsetHeight/a;default:return r.offsetHeight}},o.prototype.getOffsetWidth=function(r){var a=this.props.scale;switch(this.props.bounds){case"window":return window.innerWidth/a;case"body":return document.body.offsetWidth/a;default:return r.offsetWidth}},o.prototype.onDragStart=function(r,a){if(this.props.onDragStart&&this.props.onDragStart(r,a)===!1)return!1;var l=this.getDraggablePosition();if(this.originalPosition=l,!!this.props.bounds){var c=this.getParent(),u=this.props.scale,f;if(this.props.bounds==="parent")f=c;else if(this.props.bounds==="body"){var h=c.getBoundingClientRect(),p=h.left,g=h.top,v=document.body.getBoundingClientRect(),x=-(p-c.offsetLeft*u-v.left)/u,S=-(g-c.offsetTop*u-v.top)/u,E=(document.body.offsetWidth-this.resizable.size.width*u)/u+x,C=(document.body.offsetHeight-this.resizable.size.height*u)/u+S;return this.setState({bounds:{top:S,right:E,bottom:C,left:x}})}else if(this.props.bounds==="window"){if(!this.resizable)return;var R=c.getBoundingClientRect(),T=R.left,z=R.top,A=-(T-c.offsetLeft*u)/u,N=-(z-c.offsetTop*u)/u,E=(window.innerWidth-this.resizable.size.width*u)/u+A,C=(window.innerHeight-this.resizable.size.height*u)/u+N;return this.setState({bounds:{top:N,right:E,bottom:C,left:A}})}else typeof this.props.bounds=="string"?f=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(f=this.props.bounds);if(!(!(f instanceof HTMLElement)||!(c instanceof HTMLElement))){var B=f.getBoundingClientRect(),M=B.left,$=B.top,L=c.getBoundingClientRect(),H=L.left,I=L.top,Y=(M-H)/u,X=$-I;if(this.resizable){this.updateOffsetFromParent();var ee=this.offsetFromParent;this.setState({bounds:{top:X-ee.top,right:Y+(f.offsetWidth-this.resizable.size.width)-ee.left/u,bottom:X+(f.offsetHeight-this.resizable.size.height)-ee.top,left:Y-ee.left/u}})}}}},o.prototype.onDrag=function(r,a){if(this.props.onDrag){var l=this.offsetFromParent,c=l.left,u=l.top;if(!this.props.dragAxis||this.props.dragAxis==="both")return this.props.onDrag(r,Pt(Pt({},a),{x:a.x+c,y:a.y+u}));if(this.props.dragAxis==="x")return this.props.onDrag(r,Pt(Pt({},a),{x:a.x+c,y:this.originalPosition.y+u,deltaY:0}));if(this.props.dragAxis==="y")return this.props.onDrag(r,Pt(Pt({},a),{x:this.originalPosition.x+c,y:a.y+u,deltaX:0}))}},o.prototype.onDragStop=function(r,a){if(this.props.onDragStop){var l=this.offsetFromParent,c=l.left,u=l.top;if(!this.props.dragAxis||this.props.dragAxis==="both")return this.props.onDragStop(r,Pt(Pt({},a),{x:a.x+c,y:a.y+u}));if(this.props.dragAxis==="x")return this.props.onDragStop(r,Pt(Pt({},a),{x:a.x+c,y:this.originalPosition.y+u,deltaY:0}));if(this.props.dragAxis==="y")return this.props.onDragStop(r,Pt(Pt({},a),{x:this.originalPosition.x+c,y:a.y+u,deltaX:0}))}},o.prototype.onResizeStart=function(r,a,l){if(this.props.onResizeStart&&this.props.onResizeStart(r,a,l)===!1)return!1;r.stopPropagation(),this.setState({resizing:!0});var c=this.props.scale,u=this.offsetFromParent,f=this.getDraggablePosition();if(this.resizingPosition={x:f.x+u.left,y:f.y+u.top},this.originalPosition=f,this.props.bounds){var h=this.getParent(),p=void 0;this.props.bounds==="parent"?p=h:this.props.bounds==="body"?p=document.body:this.props.bounds==="window"?p=window:typeof this.props.bounds=="string"?p=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(p=this.props.bounds);var g=this.getSelfElement();if(g instanceof Element&&(p instanceof HTMLElement||p===window)&&h instanceof HTMLElement){var v=this.getMaxSizesFromProps(),x=v.maxWidth,S=v.maxHeight,E=this.getParentSize();if(x&&typeof x=="string")if(x.endsWith("%")){var C=Number(x.replace("%",""))/100;x=E.width*C}else x.endsWith("px")&&(x=Number(x.replace("px","")));if(S&&typeof S=="string")if(S.endsWith("%")){var C=Number(S.replace("%",""))/100;S=E.height*C}else S.endsWith("px")&&(S=Number(S.replace("px","")));var R=g.getBoundingClientRect(),T=R.left,z=R.top,A=this.props.bounds==="window"?{left:0,top:0}:p.getBoundingClientRect(),N=A.left,B=A.top,M=this.getOffsetWidth(p),$=this.getOffsetHeight(p),L=a.toLowerCase().endsWith("left"),H=a.toLowerCase().endsWith("right"),I=a.startsWith("top"),Y=a.startsWith("bottom");if((L||I)&&this.resizable){var X=(T-N)/c+this.resizable.size.width;this.setState({maxWidth:X>Number(x)?x:X})}if(H||this.props.lockAspectRatio&&!L&&!I){var X=M+(N-T)/c;this.setState({maxWidth:X>Number(x)?x:X})}if((I||L)&&this.resizable){var X=(z-B)/c+this.resizable.size.height;this.setState({maxHeight:X>Number(S)?S:X})}if(Y||this.props.lockAspectRatio&&!I&&!L){var X=$+(B-z)/c;this.setState({maxHeight:X>Number(S)?S:X})}}}else this.setState({maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight})},o.prototype.onResize=function(r,a,l,c){var u=this,f={x:this.originalPosition.x,y:this.originalPosition.y},h=-c.width,p=-c.height,g=["top","left","topLeft","bottomLeft","topRight"];g.includes(a)&&(a==="bottomLeft"?f.x+=h:(a==="topRight"||(f.x+=h),f.y+=p));var v=this.draggable.state;(f.x!==v.x||f.y!==v.y)&&co.flushSync(function(){u.draggable.setState(f)}),this.updateOffsetFromParent();var x=this.offsetFromParent,S=this.getDraggablePosition().x+x.left,E=this.getDraggablePosition().y+x.top;this.resizingPosition={x:S,y:E},this.props.onResize&&this.props.onResize(r,a,l,c,{x:S,y:E})},o.prototype.onResizeStop=function(r,a,l,c){this.setState({resizing:!1});var u=this.getMaxSizesFromProps(),f=u.maxWidth,h=u.maxHeight;this.setState({maxWidth:f,maxHeight:h}),this.props.onResizeStop&&this.props.onResizeStop(r,a,l,c,this.resizingPosition)},o.prototype.updateSize=function(r){this.resizable&&this.resizable.updateSize({width:r.width,height:r.height})},o.prototype.updatePosition=function(r){this.draggable.setState(r)},o.prototype.updateOffsetFromParent=function(){var r=this.props.scale,a=this.getParent(),l=this.getSelfElement();if(!a||l===null)return{top:0,left:0};var c=a.getBoundingClientRect(),u=c.left,f=c.top,h=l.getBoundingClientRect(),p=this.getDraggablePosition(),g=a.scrollLeft,v=a.scrollTop;this.offsetFromParent={left:h.left-u+g-p.x*r,top:h.top-f+v-p.y*r}},o.prototype.render=function(){var r=this,a=this.props,l=a.disableDragging,c=a.style,u=a.dragHandleClassName,f=a.position,h=a.onMouseDown,p=a.onMouseUp,g=a.dragAxis,v=a.dragGrid,x=a.bounds,S=a.enableUserSelectHack,E=a.cancel,C=a.children;a.onResizeStart,a.onResize,a.onResizeStop,a.onDragStart,a.onDrag,a.onDragStop;var R=a.resizeHandleStyles,T=a.resizeHandleClasses,z=a.resizeHandleComponent,A=a.enableResizing,N=a.resizeGrid,B=a.resizeHandleWrapperClass,M=a.resizeHandleWrapperStyle,$=a.scale,L=a.allowAnyClick,H=a.dragPositionOffset,I=NO(a,["disableDragging","style","dragHandleClassName","position","onMouseDown","onMouseUp","dragAxis","dragGrid","bounds","enableUserSelectHack","cancel","children","onResizeStart","onResize","onResizeStop","onDragStart","onDrag","onDragStop","resizeHandleStyles","resizeHandleClasses","resizeHandleComponent","enableResizing","resizeGrid","resizeHandleWrapperClass","resizeHandleWrapperStyle","scale","allowAnyClick","dragPositionOffset"]),Y=this.props.default?Pt({},this.props.default):void 0;delete I.default;var X=l||u?{cursor:"auto"}:{cursor:"move"},ee=Pt(Pt(Pt({},AO),X),c),ne=this.offsetFromParent,re=ne.left,j=ne.top,k;f&&(k={x:f.x-re,y:f.y-j});var V=this.state.resizing?void 0:k,P=this.state.resizing?"both":g;return b.createElement(yO,{ref:function(Z){Z&&(r.draggable=Z)},handle:u?".".concat(u):void 0,defaultPosition:Y,onMouseDown:h,onMouseUp:p,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,axis:P,disabled:l,grid:v,bounds:x?this.state.bounds:void 0,position:V,enableUserSelectHack:S,cancel:E,scale:$,allowAnyClick:L,nodeRef:this.resizableElement,positionOffset:H},b.createElement(_O,Pt({},I,{ref:function(Z){Z&&(r.resizable=Z,r.resizableElement.current=Z.resizable)},defaultSize:Y,size:this.props.size,enable:typeof A=="boolean"?zO(A):A,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,style:ee,minWidth:this.props.minWidth,minHeight:this.props.minHeight,maxWidth:this.state.resizing?this.state.maxWidth:this.props.maxWidth,maxHeight:this.state.resizing?this.state.maxHeight:this.props.maxHeight,grid:N,handleWrapperClass:B,handleWrapperStyle:M,lockAspectRatio:this.props.lockAspectRatio,lockAspectRatioExtraWidth:this.props.lockAspectRatioExtraWidth,lockAspectRatioExtraHeight:this.props.lockAspectRatioExtraHeight,handleStyles:R,handleClasses:T,handleComponent:z,scale:this.props.scale}),C))},o.defaultProps={maxWidth:Number.MAX_SAFE_INTEGER,maxHeight:Number.MAX_SAFE_INTEGER,scale:1,onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},onDragStart:function(){},onDrag:function(){},onDragStop:function(){}},o})(b.PureComponent);const CC=1920,EC=1080;function Di(e){const o=Math.round(e);return o-o%2}function RC(e,o,r=CC,a=EC){const{x:l,y:c,w:u,h:f,valign:h="center",halign:p="center"}=e,g=e.direction==="vertical",v=u*r,x=f*a,S=[];if(g){const E=Di(c*a),C=Di(Math.min(x/o,v*9/16)),R=C*o,T=x,z=Di(h==="top"?0:h==="bottom"?T-R:(T-R)/2),A=C/a;for(let N=0;N0?S*g/2:0,C=[];for(let R=0;R0,N=r+T*g+(A?E:0),B=a+z*v;C.push([N,B,g,v,u,f])}return C}function TC(e,o){const r=new Array(o.length).fill(0),a=o.map(u=>u.max!=null?u.max:null),l=new Set(o.map((u,f)=>f));let c=e;for(;c>0&&l.size>0;){const u=Math.floor(c/l.size);if(u===0){for(const h of[...l].sort((p,g)=>p-g).slice(0,c))r[h]+=1;break}let f=!1;for(const h of[...l]){const p=a[h],g=p!=null?p-r[h]:null,v=g!=null?Math.min(u,g):u;v>0&&(r[h]+=v,c-=v,f=!0),p!=null&&r[h]>=p&&l.delete(h)}if(!f)break}return r}function jO(e,o,r=CC,a=EC){const l=e.filter(v=>v.type==="static"),c=e.filter(v=>v.type==="row"||v.type==="grid"),u=Math.max(0,o-l.length);if(u>0&&c.length===0)return null;const f=TC(u,c),h=[];let p=0,g=0;for(const v of e){if(p>=o)break;if(v.type==="static")h.push([v.x,v.y,v.w,v.h,v.valign??"center",v.halign??"center"]),p+=1;else if(v.type==="row"||v.type==="grid"){const x=f[g];if(g+=1,x<=0)continue;h.push(...v.type==="row"?RC(v,x,r,a):OO(v,x)),p+=x}}return p({value:p,match:BO(p,r,a)})).filter(p=>p.match);if(!l.length)return{pos:e,guides:[]};const c=l.reduce((p,g)=>p.match.dist<=g.match.dist?p:g),u=c.match.target-c.value,f=e+u,h=[];for(const p of l)Math.abs(p.value+u-p.match.target)<=a&&h.push(p.match.target);return{pos:f,guides:h}}function $O(e,o,r,a=8){const{x:l,y:c,w:u,h:f}=e,h=[],p=ex(l,[l,l+u/2,l+u],o,a);for(const v of p.guides)h.push({axis:"x",pos:v});const g=ex(c,[c,c+f/2,c+f],r,a);for(const v of g.guides)h.push({axis:"y",pos:v});return{x:p.pos,y:g.pos,w:u,h:f,guides:h}}function LO({canvasW:e,canvasH:o,others:r,subdivisions:a,snapToCanvas:l,snapToElements:c}){const u=[],f=[];if(l&&(u.push(0,e/2,e),f.push(0,o/2,o)),c){for(const h of r)u.push(h.x,h.x+h.w/2,h.x+h.w),f.push(h.y,h.y+h.h/2,h.y+h.h);for(const h of a??[])h.axis==="x"?u.push(h.pos*e):f.push(h.pos*o)}return{targetsX:u,targetsY:f}}function _C(e){return new Promise((o,r)=>{const a=new FileReader;a.onload=()=>o(a.result.split(",")[1]),a.onerror=()=>r(new Error("Failed to read file")),a.readAsDataURL(e)})}const tx={static:"Static",row:"Auto Row",grid:"Auto Grid"},kO={static:{border:"1px solid var(--mantine-color-blue-5)",background:"rgba(51, 154, 240, 0.15)"},row:{border:"2px dashed var(--mantine-color-teal-5)",background:"rgba(18, 184, 134, 0.12)"},grid:{border:"2px dotted var(--mantine-color-orange-5)",background:"rgba(253, 126, 20, 0.12)"}},ou={background:"var(--mantine-color-yellow-5)",border:"1px solid rgba(0, 0, 0, 0.4)",borderRadius:"50%"},HO={topLeft:ou,topRight:ou,bottomLeft:ou,bottomRight:ou},ru=[{value:"auto",label:"Auto Grid"},{value:"featured",label:"Featured"},{value:"top_featured",label:"Top Featured"}],UO={auto:[{id:"b-grid",type:"grid",x:0,y:0,w:1,h:1,valign:"center",halign:"center"}],featured:[{id:"b-main",type:"static",x:0,y:0,w:.6,h:1,valign:"center",halign:"center"},{id:"b-side",type:"row",direction:"vertical",x:.6,y:0,w:.4,h:1,valign:"center",halign:"center"}],top_featured:[{id:"b-main",type:"static",x:0,y:0,w:1,h:.6,valign:"center",halign:"center"},{id:"b-bottom",type:"row",direction:"horizontal",x:0,y:.6,w:1,h:.4,valign:"center",halign:"center"}]},DC=4,nx=Up.map(e=>({value:e,label:e}));function ox(e,o){const r=e.filter(f=>f.type==="static"),a=e.filter(f=>f.type==="row"||f.type==="grid"),l=Math.max(0,o-r.length),c=TC(l,a),u=[];return a.forEach((f,h)=>{const p=c[h];if(p<=1)return;const g=f.x,v=f.y,x=f.x+f.w,S=f.y+f.h;if(f.type==="grid"){const M=Math.ceil(Math.sqrt(p)),$=Math.ceil(p/M);for(let L=1;LM-$),A=[...R].sort((M,$)=>M-$),N=z[0]??g,B=A[0]??v;for(const M of z)M>N+T&&u.push({axis:"x",pos:M,from:v,to:S});for(const M of A)M>B+T&&u.push({axis:"y",pos:M,from:g,to:x})}),u}function PO(){const[e,o]=b.useState(null),[r,a]=b.useState(null);return b.useEffect(()=>{if(!e)return;const l=new ResizeObserver(c=>{const{width:u,height:f}=c[0].contentRect;u>0&&f>0&&a({width:Math.round(u),height:Math.round(f)})});return l.observe(e),()=>l.disconnect()},[e]),[r,o]}function zi(e){return e<=.001?0:e>=1-.001?1:e}function rx({x:e,y:o,w:r,h:a}){return{x:zi(e),y:zi(o),w:zi(r),h:zi(a)}}function VO(e,o){const r=1.7777777777777777;let a=e,l=a/r;return l>o&&(l=o,a=l*r),{width:Math.round(a),height:Math.round(l)}}function NC({tiles:e}){return y.jsx("div",{style:{position:"relative",width:160,height:90,background:"var(--mantine-color-dark-6)",border:"1px solid var(--mantine-color-dark-4)",flexShrink:0},children:(e??[]).map((o,r)=>y.jsx("div",{style:{position:"absolute",left:`${o[0]*100}%`,top:`${o[1]*100}%`,width:`${o[2]*100}%`,height:`${o[3]*100}%`,border:"1px solid var(--mantine-color-blue-5)",background:"rgba(51, 154, 240, 0.15)",boxSizing:"border-box"}},r))})}function YO({elements:e,selectedIdx:o,onSelect:r,onElementChange:a,backgroundUrl:l,previewCountNum:c,snapToCanvas:u,snapToElements:f,canvasW:h,canvasH:p,isMobile:g,readOnly:v}){const[x,S]=b.useState([]),[E,C]=b.useState(null),R=E?e.map((B,M)=>M===E.idx?{...B,x:E.x,y:E.y,w:E.w,h:E.h}:B):e,T=ox(R,c);function z(B){return{x:B.x*h,y:B.y*p,w:B.w*h,h:B.h*p}}function A(B){return e.filter((M,$)=>$!==B).map(z)}function N(B,M){const $=ox(R.filter((I,Y)=>Y!==B),c),{targetsX:L,targetsY:H}=LO({canvasW:h,canvasH:p,others:A(B),subdivisions:$,snapToCanvas:u,snapToElements:f});return $O(M,L,H)}return y.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",background:"var(--mantine-color-dark-6)",border:"1px solid var(--mantine-color-dark-4)"},children:[l&&y.jsx("img",{src:l,alt:"",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none"}}),T.map((B,M)=>B.axis==="x"?y.jsx("div",{style:{position:"absolute",left:B.pos*h,top:B.from*p,width:1,height:(B.to-B.from)*p,background:"rgba(255, 255, 255, 0.3)",pointerEvents:"none"}},`sub-${M}`):y.jsx("div",{style:{position:"absolute",top:B.pos*p,left:B.from*h,height:1,width:(B.to-B.from)*h,background:"rgba(255, 255, 255, 0.3)",pointerEvents:"none"}},`sub-${M}`)),e.map((B,M)=>{const $=z(B),L=o===M;return y.jsx(MO,{bounds:"parent",size:{width:$.w,height:$.h},position:{x:$.x,y:$.y},minWidth:20,minHeight:20,lockAspectRatio:B.lockAspect?B.w*h/(B.h*p):!1,resizeHandleStyles:L&&g&&!v?HO:void 0,disableDragging:v,enableResizing:!v,onMouseDown:()=>r(M),onDrag:(H,I)=>{const Y=N(M,{x:I.x,y:I.y,w:$.w,h:$.h});S(Y.guides),C({idx:M,x:Y.x/h,y:Y.y/p,w:B.w,h:B.h})},onDragStop:(H,I)=>{const Y=N(M,{x:I.x,y:I.y,w:$.w,h:$.h});S([]),C(null),a(M,rx({x:Y.x/h,y:Y.y/p,w:B.w,h:B.h}))},onResize:(H,I,Y,X,ee)=>{const ne=N(M,{x:ee.x,y:ee.y,w:Y.offsetWidth,h:Y.offsetHeight});S(ne.guides),C({idx:M,x:ne.x/h,y:ne.y/p,w:ne.w/h,h:ne.h/p})},onResizeStop:(H,I,Y,X,ee)=>{const ne=N(M,{x:ee.x,y:ee.y,w:Y.offsetWidth,h:Y.offsetHeight});S([]),C(null),a(M,rx({x:ne.x/h,y:ne.y/p,w:ne.w/h,h:ne.h/p}))},style:{...kO[B.type],outline:L?"2px solid var(--mantine-color-yellow-5)":"none",outlineOffset:-2,display:"flex",alignItems:"center",justifyContent:"center"},children:y.jsx(Ye,{size:"xs",c:"dimmed",ta:"center",style:{userSelect:"none",pointerEvents:"none"},children:B.name||M+1})},B.id)}),x.map((B,M)=>B.axis==="x"?y.jsx("div",{style:{position:"absolute",left:B.pos,top:0,width:1,height:p,background:"var(--mantine-color-red-5)",pointerEvents:"none"}},`live-${M}`):y.jsx("div",{style:{position:"absolute",top:B.pos,left:0,height:1,width:h,background:"var(--mantine-color-red-5)",pointerEvents:"none"}},`live-${M}`))]})}function ax({style:e,styleId:o,onUpdate:r,readOnly:a=!1}){const[l,c]=b.useState(e),[u,f]=b.useState(!1);b.useEffect(()=>{c(e),f(!1)},[o]);const[h,p]=b.useState(4),[g,v]=b.useState(null),[x,S]=b.useState(null),[E,C]=b.useState(!1),[R,T]=b.useState(!1),[z,A]=b.useState(!0),[N,B]=b.useState(!0),M=b.useRef(null),[$,L]=PO(),H=Qp("(max-width: 48em)"),I=h||4,Y=l.elements??[],X=g!=null?Y[g]:null;b.useEffect(()=>{let O=!1,q=null;return l.background_image?yC(o).then(W=>{O||!W||(q=URL.createObjectURL(W),S(q))}):S(null),()=>{O=!0,q&&URL.revokeObjectURL(q)}},[o,l.background_image]);function ee(O){c(q=>({...q,elements:O})),f(!0)}async function ne(){T(!0);try{await r(l),f(!1)}finally{T(!1)}}async function re(O){const q=O.target.files?.[0];if(O.target.value="",!!q){C(!0);try{const W=await _C(q),ie=await vC(o,q.name,W);c(ue=>({...ue,background_image:ie.filename})),f(!0)}catch(W){Qe.show({title:"Upload failed",message:W.message,color:"red",autoClose:4e3})}finally{C(!1)}}}function j(){c(O=>({...O,background_image:null})),f(!0)}function k(O){const q={id:Na(),type:O,x:.1,y:.1,w:.3,h:.3,valign:"center",halign:"center"};O==="row"&&(q.direction="horizontal");const W=[...Y,q];ee(W),v(W.length-1)}function V(O){ee(Y.filter((q,W)=>W!==O)),g===O?v(null):g!=null&&g>O&&v(g-1)}function P(O){const q=Y[O],W={...q,id:Na(),x:zi(q.x+.02),y:zi(q.y+.02)},ie=[...Y.slice(0,O+1),W,...Y.slice(O+1)];ee(ie),v(O+1)}function Z(O,q){const W=O+q;if(W<0||W>=Y.length)return;const ie=[...Y];[ie[O],ie[W]]=[ie[W],ie[O]],ee(ie),g===O?v(W):g===W&&v(O)}function D(O,q){ee(Y.map((W,ie)=>ie===O?{...W,...q}:W))}return y.jsxs(Qt,{gap:"sm",style:{flex:1,minHeight:0},children:[y.jsxs(mt,{gap:"xs",align:"flex-end",wrap:"wrap",children:[y.jsx(Vi,{size:"xs",label:"Style name",value:l.name??"",onChange:O=>{c(q=>({...q,name:O.currentTarget.value})),f(!0)},placeholder:"Style name",disabled:a,style:{flex:H?"1 1 100%":"1 1 200px"}}),y.jsx(Ca,{size:"xs",label:"Preview channel count",min:2,max:9,value:h,onChange:O=>p(O||4),w:H?"100%":150}),y.jsx(Bi,{size:"xs",label:"Snap to elements",disabled:a,checked:z,onChange:O=>A(O.currentTarget.checked)}),y.jsx(Bi,{size:"xs",label:"Snap to canvas",disabled:a,checked:N,onChange:O=>B(O.currentTarget.checked)}),y.jsx(Dt,{size:"xs",leftSection:y.jsx(p5,{size:14}),disabled:a||!u,loading:R,color:u?"blue":"gray",variant:u?"filled":"default",onClick:ne,style:H?{flex:"1 1 100%"}:void 0,children:u?"Save":"Saved"})]}),y.jsxs(cg,{cols:H?2:4,spacing:"xs",children:[y.jsx(Dt,{size:"xs",variant:"default",leftSection:y.jsx(is,{size:12}),disabled:a,onClick:()=>k("static"),children:"Static Position"}),y.jsx(Dt,{size:"xs",variant:"default",leftSection:y.jsx(is,{size:12}),disabled:a,onClick:()=>k("row"),children:"Auto Row"}),y.jsx(Dt,{size:"xs",variant:"default",leftSection:y.jsx(is,{size:12}),disabled:a,onClick:()=>k("grid"),children:"Auto Grid"}),y.jsxs(mt,{gap:4,wrap:"nowrap",children:[y.jsx(Dt,{size:"xs",variant:"default",leftSection:y.jsx(R5,{size:12}),loading:E,disabled:a,onClick:()=>M.current?.click(),style:{flex:1},children:l.background_image?"Change Background":"Background Image"}),y.jsx(Yt,{size:"sm",variant:"subtle",color:"red",disabled:a||!l.background_image,onClick:j,"aria-label":"Remove background",children:y.jsx(j5,{size:14})})]}),y.jsx("input",{ref:M,type:"file",accept:"image/png,image/jpeg",style:{display:"none"},onChange:re})]}),y.jsx(Ye,{size:"xs",c:"dimmed",children:a?Y.length===0?"This style has no representable elements at this channel count.":"Click a box or list row to inspect its properties.":Y.length===0?"Add a Static Position, Auto Row, or Auto Grid to get started.":"Drag a box to move it, drag its edge/corner to resize it. Click a box or list row to select it."}),y.jsxs(mt,{align:"stretch",gap:"sm",wrap:H?"wrap":"nowrap",style:{flex:1,minHeight:0},children:[y.jsxs(Qt,{gap:6,p:"sm",w:H?"100%":260,style:{flexShrink:0,minHeight:0,overflowY:"auto",border:"1px solid var(--mantine-color-dark-4)",borderRadius:6},children:[y.jsx(Ye,{size:"xs",fw:600,children:X?X.name||tx[X.type]:"No element selected"}),y.jsx(lt,{withRowBorders:!1,verticalSpacing:4,horizontalSpacing:"xs",style:{tableLayout:"fixed",width:"100%"},children:y.jsxs(lt.Tbody,{children:[y.jsxs(lt.Tr,{children:[y.jsx(lt.Td,{w:80,children:y.jsx(Ye,{size:"xs",c:"dimmed",children:"Direction"})}),y.jsx(lt.Td,{children:y.jsx(sg,{size:"xs",fullWidth:!0,disabled:!X||a||X.type!=="row",data:[{label:"Horiz",value:"horizontal"},{label:"Vert",value:"vertical"}],value:X?.direction??"horizontal",onChange:O=>g!=null&&D(g,{direction:O})})})]}),y.jsxs(lt.Tr,{children:[y.jsx(lt.Td,{w:80,children:y.jsx(Ye,{size:"xs",c:"dimmed",children:"Max channels"})}),y.jsx(lt.Td,{children:y.jsx(Ca,{size:"xs",placeholder:"Unlimited",disabled:!X||a||!["row","grid"].includes(X.type),min:1,value:X?.max??"",onChange:O=>g!=null&&D(g,{max:O===""?null:O})})})]}),y.jsxs(lt.Tr,{children:[y.jsx(lt.Td,{w:80,children:y.jsx(Ye,{size:"xs",c:"dimmed",children:"Anchor"})}),y.jsx(lt.Td,{children:y.jsxs(mt,{grow:!0,gap:4,wrap:"nowrap",children:[y.jsx(gs,{size:"xs",placeholder:"V anchor",disabled:!X||a,data:nx,value:X?.valign??null,onChange:O=>O&&g!=null&&D(g,{valign:O})}),y.jsx(gs,{size:"xs",placeholder:"H anchor",disabled:!X||a,data:nx,value:X?.halign??null,onChange:O=>O&&g!=null&&D(g,{halign:O})})]})})]}),y.jsxs(lt.Tr,{children:[y.jsx(lt.Td,{w:80,children:y.jsx(Ye,{size:"xs",c:"dimmed",children:"Size"})}),y.jsx(lt.Td,{children:y.jsxs(mt,{grow:!0,gap:4,wrap:"nowrap",children:[y.jsx(Ca,{size:"xs",label:"Width (px)",description:"of 1920",disabled:!X||a,min:1,value:X?Math.round(X.w*1920):"",onChange:O=>{if(!O||g==null)return;const q=O/1920;if(X.lockAspect){const W=X.w*1920/(X.h*1080);D(g,{w:q,h:O/W/1080})}else D(g,{w:q})}}),y.jsx(Ca,{size:"xs",label:"Height (px)",description:"of 1080",disabled:!X||a,min:1,value:X?Math.round(X.h*1080):"",onChange:O=>{if(!O||g==null)return;const q=O/1080;if(X.lockAspect){const W=X.w*1920/(X.h*1080);D(g,{w:O*W/1920,h:q})}else D(g,{h:q})}})]})})]}),y.jsxs(lt.Tr,{children:[y.jsx(lt.Td,{w:80,children:y.jsx(Ye,{size:"xs",c:"dimmed",children:"Lock aspect"})}),y.jsx(lt.Td,{children:y.jsx(Bi,{size:"xs",disabled:!X||a,checked:!!X?.lockAspect,onChange:O=>g!=null&&D(g,{lockAspect:O.currentTarget.checked})})})]})]})})]}),y.jsx("div",{ref:L,style:H?{width:"100%",aspectRatio:"16 / 9"}:{flex:1,minWidth:0,minHeight:0,display:"flex",alignItems:"center",justifyContent:"center"},children:$&&(()=>{const O=VO($.width,$.height);return y.jsx("div",{style:{width:O.width,height:O.height},children:y.jsx(YO,{elements:Y,selectedIdx:g,onSelect:v,onElementChange:D,backgroundUrl:x,previewCountNum:I,snapToCanvas:N,snapToElements:z,canvasW:O.width,canvasH:O.height,isMobile:H,readOnly:a})})})()}),y.jsxs(Qt,{gap:6,p:"sm",w:H?"100%":220,style:{flexShrink:0,minHeight:0,overflowY:"auto",border:"1px solid var(--mantine-color-dark-4)",borderRadius:6},children:[y.jsx(Ye,{size:"xs",fw:600,c:"dimmed",children:"Elements"}),Y.map((O,q)=>y.jsxs(mt,{gap:4,wrap:"nowrap",onClick:()=>v(q),style:{cursor:"pointer",padding:4,borderRadius:4,background:g===q?"rgba(51, 154, 240, 0.18)":"transparent",borderLeft:g===q?"2px solid var(--mantine-color-blue-5)":"2px solid transparent"},children:[y.jsxs(Ye,{size:"xs",c:"dimmed",children:[q+1,"."]}),y.jsx(Vi,{size:"xs",variant:"unstyled",value:O.name??"",placeholder:tx[O.type],disabled:a,onChange:W=>D(q,{name:W.currentTarget.value}),onClick:W=>W.stopPropagation(),style:{flex:1,minWidth:0},styles:{input:{minHeight:"unset",height:"auto",padding:0}}}),y.jsx(Yt,{size:"xs",variant:"subtle",disabled:a,onClick:W=>{W.stopPropagation(),P(q)},"aria-label":"Duplicate element",children:y.jsx(d5,{size:12})}),y.jsx(Yt,{size:"xs",variant:"subtle",disabled:a||q===0,onClick:W=>{W.stopPropagation(),Z(q,-1)},children:y.jsx(t5,{size:12})}),y.jsx(Yt,{size:"xs",variant:"subtle",disabled:a||q===Y.length-1,onClick:W=>{W.stopPropagation(),Z(q,1)},children:y.jsx(JM,{size:12})}),y.jsx(Yt,{size:"xs",variant:"subtle",color:"red",disabled:a,onClick:W=>{W.stopPropagation(),V(q)},children:y.jsx(pg,{size:12})})]},O.id))]})]})]})}async function GO(e,o){const r={name:o.name,elements:o.elements??[]};if(o.background_image){const a=await yC(e);a&&(r.background_image_filename=o.background_image,r.background_image_data=await _C(a))}return r}async function ix(e){const o=Na(),r={name:e.name||"Imported Style",elements:e.elements??[]};if(e.background_image_data){const a=await vC(o,e.background_image_filename||"background.png",e.background_image_data);r.background_image=a.filename}return[o,r]}function XO(e){return e.some(r=>r.type==="row"||r.type==="grid")?DC:Math.max(e.length,1)}function qO({id:e,style:o,onOpen:r,onExport:a,onDelete:l}){const c=o.elements??[],u=jO(c,XO(c))??[];return y.jsxs(Qt,{gap:4,align:"center",style:{cursor:"pointer",flexShrink:0},onClick:()=>r(e),children:[y.jsx(NC,{tiles:u}),y.jsx(Ye,{size:"xs",children:o.name||"New Style"}),y.jsxs(mt,{gap:4,children:[y.jsx(Yt,{size:"xs",variant:"subtle",onClick:f=>{f.stopPropagation(),a(e,o)},"aria-label":"Export style",children:y.jsx(Vw,{size:12})}),y.jsx(Yt,{size:"xs",variant:"subtle",color:"red",onClick:f=>{f.stopPropagation(),l(e)},"aria-label":"Delete style",children:y.jsx(pg,{size:12})})]})]})}function IO({onClick:e}){return y.jsxs(Qt,{gap:4,align:"center",style:{cursor:"pointer",flexShrink:0},onClick:e,children:[y.jsx("div",{style:{width:160,height:90,display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed var(--mantine-color-dark-4)",color:"var(--mantine-color-dimmed)"},children:y.jsx(is,{size:24})}),y.jsx(Ye,{size:"xs",c:"dimmed",children:"New Style"})]})}function FO({settings:e,onFieldsReload:o}){const r=e.multiview_custom_layouts??{},a=e.multiview_custom_layouts_order??Object.keys(r),[l,c]=b.useState({}),[u,f]=b.useState(null),[h,p]=b.useState(null),[g,v]=b.useState(!0),x=b.useRef(null),S=Qp("(max-width: 48em)");b.useEffect(()=>{(u||h)&&S&&v(!1)},[u,h]),b.useEffect(()=>{let H=!1;return Promise.all(ru.map(I=>B4(I.value,DC).catch(()=>null))).then(I=>{if(H)return;const Y={};ru.forEach((X,ee)=>{I[ee]&&(Y[X.value]=I[ee].tiles)}),c(Y)}),()=>{H=!0}},[]);async function E(H,I){try{await Ur({multiview_custom_layouts:H,multiview_custom_layouts_order:I}),await o()}catch(Y){Qe.show({title:"Save failed",message:Y.message,color:"red",autoClose:4e3})}}async function C(){try{const H=Na();await E({...r,[H]:{name:"New Style",elements:[]}},[...a,H]),f(H)}catch(H){Qe.show({title:"Failed",message:H.message,color:"red",autoClose:4e3})}}function R(H){const I={...r};delete I[H],E(I,a.filter(Y=>Y!==H)),u===H&&f(null)}function T(H,I){return E({...r,[H]:I},a)}async function z(H,I){try{const Y=await GO(H,I);xC(Y,`multiview-style-${(I.name||"style").trim().replace(/\s+/g,"-")||"style"}.json`)}catch(Y){Qe.show({title:"Export failed",message:Y.message,color:"red",autoClose:4e3})}}async function A(H){const I=H.target.files?.[0];if(H.target.value="",!!I)try{const Y=JSON.parse(await I.text());if(!Y||typeof Y!="object"||Array.isArray(Y))throw new Error("Not a valid style file");if(Array.isArray(Y.elements)){Pp(Y);const[X,ee]=await ix(Y);await E({...r,[X]:ee},[...a,X]),Qe.show({message:`Style "${ee.name}" imported`,color:"green",autoClose:2e3})}else{const X=Object.entries(Y);X.forEach(([re,j])=>Pp(j,`style "${re}"`));const ee={},ne=[];for(const[,re]of X){const[j,k]=await ix(re);ee[j]=k,ne.push(j)}await E({...r,...ee},[...a,...ne]),Qe.show({message:`Imported ${ne.length} style(s)`,color:"green",autoClose:2e3})}}catch(Y){Qe.show({title:"Import failed",message:Y.message,color:"red",autoClose:4e3})}}const N=a.filter(H=>r[H]).map(H=>[H,r[H]]),B=u?r[u]:null,M=h?{name:h.label,elements:UO[h.value]}:null;function $(H){p(null),f(H)}function L(H){f(null),p(H)}return b.useEffect(()=>{B||M||(N.length>0?(p(null),f(N[0][0])):(f(null),p(ru[0])))},[B,M,N]),y.jsxs(Qt,{gap:"xs",style:{flex:1,minHeight:0},children:[y.jsxs(mt,{justify:"space-between",gap:"xs",children:[y.jsxs(mt,{gap:4,children:[y.jsx(Ye,{size:"xs",c:"dimmed",children:"Click a built-in to preview it, or a custom style to edit it."}),S&&y.jsx(Yt,{size:"xs",variant:"subtle",onClick:()=>v(H=>!H),"aria-label":g?"Collapse styles":"Expand styles",children:g?y.jsx(s5,{size:12}):y.jsx(Pw,{size:12})})]}),y.jsx(Dt,{size:"xs",variant:"default",leftSection:y.jsx(Gw,{size:12}),onClick:()=>x.current?.click(),children:"Import"}),y.jsx("input",{ref:x,type:"file",accept:"application/json",style:{display:"none"},onChange:A})]}),y.jsx(rm,{in:!S||g,children:y.jsxs(mt,{align:"flex-start",gap:"md",wrap:"nowrap",style:{overflowX:"auto",paddingBottom:4},children:[ru.map(H=>y.jsxs(Qt,{gap:4,align:"center",style:{flexShrink:0,cursor:"pointer"},onClick:()=>L(H),children:[y.jsx(NC,{tiles:l[H.value]}),y.jsx(Ye,{size:"xs",children:H.label})]},H.value)),N.map(([H,I])=>y.jsx(qO,{id:H,style:I,onOpen:$,onExport:z,onDelete:R},H)),y.jsx(IO,{onClick:C})]})}),B?y.jsx(ax,{style:B,styleId:u,onUpdate:H=>T(u,H)}):M?y.jsx(ax,{style:M,styleId:`builtin:${h.value}`,onUpdate:()=>{},readOnly:!0}):null]})}const Gp=/^multiview_([0-9a-f]{8})_(.+)$/;function ZO(e,o,r,a){const l=o.map(p=>{const g={id:p},v=[];for(const[x,S]of Object.entries(e)){const E=x.match(Gp);if(!E||E[1]!==p)continue;const C=E[2].match(/^channel_(\d+)$/);C?v[parseInt(C[1],10)-1]=S:g[E[2]]=S}return v.length&&(g.channels=v),g}),c={};for(const[p,g]of Object.entries(e))p==="multiview_order"||p==="multiview_count"||p==="multiview_custom_layouts"||p==="multiview_custom_layouts_order"||p==="multiview_pre_migration_backup"||p==="multiview_pre_reconcile_backup"||Gp.test(p)||(c[p]=g);const u=e.multiview_custom_layouts??{},f=e.multiview_custom_layouts_order??Object.keys(u),h={};for(const p of f)u[p]&&(h[p]=u[p]);return{global:c,layouts:l,custom_styles:h,plugin_version:r,dispatcharr_version:a}}function QO(e){const o={},r=[];for(const a of e.layouts){const l=Na();r.push(l);for(const[c,u]of Object.entries(a))c!=="id"&&(c==="channels"?u.forEach((f,h)=>{o[`multiview_${l}_channel_${h+1}`]=f}):o[`multiview_${l}_${c}`]=u)}return Object.assign(o,e.global??{}),o.multiview_order=r,o.multiview_custom_layouts=e.custom_styles??{},o.multiview_custom_layouts_order=Object.keys(e.custom_styles??{}),o}function KO({id:e,...o}){const{attributes:r,listeners:a,setNodeRef:l,transform:c,transition:u,isDragging:f}=_4({id:e}),h={transform:ys.Transform.toString(c),transition:u,opacity:f?.5:1};return y.jsx("div",{ref:l,style:h,children:y.jsx(F4,{id:e,dragHandleProps:{...r,...a},...o})})}function WO({onLoggedOut:e}){const[o,r]=b.useState(null),[a,l]=b.useState({}),[c,u]=b.useState(""),[f,h]=b.useState(!1),[p,g]=b.useState(!1),[v,x]=b.useState(!1),[S,E]=b.useState(0),[C,R]=b.useState(()=>new Set),[T,z]=b.useState(null),A=b.useRef(null),N=b.useCallback(async()=>{try{const[P,Z]=await Promise.all([O4(),Y1()]);r(P);const D=Z.settings??{},O=[...P.global??[],...(P.layouts??[]).flatMap(W=>W.fields)],q={...D};for(const W of O)!(W.id in q)&&W.default!==void 0&&(q[W.id]=W.default);l(q)}catch(P){P.status!==401&&u(P.message)}},[]);b.useEffect(()=>{N()},[N]),b.useEffect(()=>{const P=async()=>{try{const O=(await gC()).active??[];E(O.length),R(new Set(O.map(q=>q.n)))}catch{}};P();const Z=setInterval(P,5e3);return()=>clearInterval(Z)},[]),b.useEffect(()=>(V1(e),()=>V1(()=>{})),[e]);const B=b.useCallback(P=>l(Z=>({...Z,...P})),[]);function M(){return(o?.layouts??[]).map(P=>P.n)}async function $(P,Z){const D=`multiview_${P}_channel_count`,O=(a[D]??4)+Z;try{await Ur({[D]:O}),await N()}catch(q){Qe.show({title:"Failed",message:q.message,color:"red",autoClose:4e3})}}async function L(){try{const P=M(),Z=Na(),D=P.length+1,O={multiview_order:[...P,Z],[`multiview_${Z}_name`]:`Multiview ${D}`,[`multiview_${Z}_layout`]:"auto",[`multiview_${Z}_selector_type`]:"classic",[`multiview_${Z}_channel_count`]:4,[`multiview_${Z}_epg_source_mode`]:"dummy"};await Ur(O),await N(),Qe.show({message:`Layout ${D} added`,color:"green",autoClose:2e3})}catch(P){Qe.show({title:"Failed",message:P.message,color:"red",autoClose:4e3})}}async function H(P){const Z=M();if(Z.length<=1)return;const D={multiview_order:Z.filter(O=>O!==P)};for(const O of Object.keys(a))O.startsWith(`multiview_${P}_`)&&(D[O]=null);try{await Ur(D);try{await Hp(P)}catch{}await N(),Qe.show({message:"Layout removed",color:"green",autoClose:2e3})}catch(O){Qe.show({title:"Failed",message:O.message,color:"red",autoClose:4e3})}}const I=o6(n6(wg,{activationConstraint:{distance:4}}));async function Y(P){const{active:Z,over:D}=P;if(!D||Z.id===D.id)return;const O=M(),q=O.indexOf(Z.id),W=O.indexOf(D.id);if(q===-1||W===-1)return;const ie=Cg(O,q,W);try{await Ur({multiview_order:ie}),await N()}catch(ue){Qe.show({title:"Failed",message:ue.message,color:"red",autoClose:4e3})}}async function X(){h(!0);try{const P=await $4();Qe.show({message:P.message||"M3U & EPG refreshed",color:P.status==="success"?"green":"red",autoClose:3e3})}catch(P){Qe.show({title:"Refresh failed",message:P.message,color:"red",autoClose:4e3})}finally{h(!1)}}async function ee(){try{const P=await Y1(),Z=M(),D=ZO(P.settings??{},Z,P.plugin_version,P.dispatcharr_version);xC(D,`multiview-backup-${new Date().toISOString().slice(0,10)}.json`)}catch(P){Qe.show({title:"Export failed",message:P.message,color:"red",autoClose:4e3})}}async function ne(P){const Z=P.target.files?.[0];if(P.target.value="",!!Z)try{const D=JSON.parse(await Z.text());if(!D||typeof D!="object"||Array.isArray(D))throw new Error("Backup file is not a valid settings object");let O,q;if(Array.isArray(D.layouts))X4(D),O=QO(D),q=O.multiview_order;else{q4(D);const fe=Array.isArray(D.multiview_order)?D.multiview_order:[],be=Object.fromEntries(fe.map(ye=>[ye,Na()]));q=fe.map(ye=>be[ye]),O={};for(const[ye,Xe]of Object.entries(D)){if(ye==="multiview_order")continue;const Ne=ye.match(Gp);Ne&&be[Ne[1]]?O[`multiview_${be[Ne[1]]}_${Ne[2]}`]=Xe:Ne||(O[ye]=Xe)}O.multiview_order=q}let W=new Set;try{const fe=await j4();W=new Set(fe.map(be=>String(be.id)))}catch{W=new Set}const ie=[];q.forEach((fe,be)=>{const ye=O[`multiview_${fe}_name`]||`Multiview ${be+1}`,Xe=`multiview_${fe}_`;for(const Ne of Object.keys(O)){if(!Ne.startsWith(Xe))continue;const We=Ne.slice(Xe.length);if(We!=="epg_forward_channel"&&!/^channel_\d+$/.test(We))continue;const Be=O[Ne];Be&&Be!=="_none"&&W.size>0&&!W.has(String(Be))&&(O[Ne]="_none",ie.push(`${ye} (${We})`))}});const ue={};for(const fe of Object.keys(a))fe.startsWith("multiview_")&&(ue[fe]=null);Object.assign(ue,O),ue.multiview_order=q;const ve=ie.length?` ${ie.length} channel selection(s) could not be matched and were cleared (reselect manually): ${ie.join(", ")}.`:"";z({title:"Restore Backup",confirmLabel:"Restore",color:"red",message:`Restore will replace all current layouts and settings with this backup (${q.length} layout(s)).${ve} Continue?`,onConfirm:async()=>{try{await Ur(ue),await N(),Qe.show({message:"Backup restored",color:"green",autoClose:2e3})}catch(fe){Qe.show({title:"Restore failed",message:fe.message,color:"red",autoClose:4e3})}}})}catch(D){Qe.show({title:"Import failed",message:D.message,color:"red",autoClose:4e3})}}if(c)return y.jsx(ps,{mih:"100dvh",children:y.jsx(Ye,{c:"red",children:c})});if(!o)return y.jsx(ps,{mih:"100dvh",children:y.jsx(Ma,{})});const{warnings:re=[],global:j=[],layouts:k=[],layout_count:V}=o;return y.jsxs(mo,{header:{height:56},children:[y.jsx(L5,{logoUrl:pC,appName:"Multiview",version:"0.4.1",githubUrl:"https://github.com/swvn-dispatch/dispatcharr-multiview",username:M4(),onLogout:e,actions:[{key:"streams",label:"Streams",icon:QM,onClick:()=>g(!0),active:S>0,count:S,variant:"default"},{key:"refresh",label:"Refresh M3U & EPG",icon:Yw,loading:f,variant:"default",onClick:()=>z({title:"Refresh M3U & EPG",confirmLabel:"Refresh",color:"blue",message:"Regenerate the M3U playlist and sync EPG data now?",onConfirm:X})},{key:"style-builder",label:"Style Builder",icon:C5,variant:"default",onClick:()=>x(!0)}],extra:y.jsxs(Nt,{shadow:"md",width:190,position:"bottom-end",children:[y.jsx(Nt.Target,{children:y.jsx(Yt,{size:"lg",variant:"default","aria-label":"More actions",children:y.jsx(A5,{size:18})})}),y.jsxs(Nt.Dropdown,{children:[y.jsx(Nt.Item,{leftSection:y.jsx(Vw,{size:14}),onClick:ee,children:"Download Backup"}),y.jsx(Nt.Item,{leftSection:y.jsx(Gw,{size:14}),onClick:()=>A.current?.click(),children:"Restore Backup"})]})]})}),y.jsx("input",{ref:A,type:"file",accept:"application/json",style:{display:"none"},onChange:ne}),y.jsx(Tn,{opened:v,onClose:()=>x(!1),title:"Style Builder",fullScreen:!0,styles:{content:{display:"flex",flexDirection:"column"},body:{flex:1,minHeight:0,display:"flex",flexDirection:"column",overflowY:"auto"}},children:y.jsx(FO,{settings:a,onFieldsReload:N})}),y.jsx(mo.Main,{children:y.jsxs(Qt,{p:"md",maw:860,mx:"auto",children:[y.jsx(P5,{fields:j,warnings:re,values:a,onSave:Ur,onOptimisticChange:B,shouldReload:bC,onReload:N,onSaved:()=>Qe.show({message:"Saved",color:"green",autoClose:1500}),onError:P=>Qe.show({title:"Save failed",message:P.message,color:"red",autoClose:4e3})}),y.jsx(Ye,{size:"xs",tt:"uppercase",fw:700,c:"dimmed",mt:"sm",children:"Layouts"}),y.jsx(l4,{sensors:I,collisionDetection:s6,onDragEnd:Y,children:y.jsx(x4,{items:M(),strategy:y4,children:k.map(({n:P,position:Z,fields:D})=>y.jsx(KO,{id:P,position:Z,fields:D,settings:a,canRemove:V>1,hasActiveStream:C.has(P),onSettingsChange:B,onFieldsReload:N,onRemove:()=>H(P),onChannelCountChange:O=>$(P,O)},P))})}),y.jsx(Dt,{variant:"default",onClick:L,children:"+ Add Layout"})]})}),y.jsx(Z4,{opened:p,onClose:()=>g(!1),settings:a}),y.jsx(Xw,{action:T,onClose:()=>z(null)})]})}function JO(){const[e,o]=b.useState(z4());return e?y.jsx(WO,{onLoggedOut:()=>{A4(),o(!1)}}):y.jsx(k5,{logoUrl:pC,appName:"Multiview",description:"Sign in with your Dispatcharr credentials. The account must have permission to modify plugin settings.",onLogin:N4,onLoggedIn:()=>o(!0)})}K2.createRoot(document.getElementById("root")).render(y.jsx(b.StrictMode,{children:y.jsx($5,{children:y.jsx(JO,{})})})); +`,e.getElementsByTagName("head")[0].appendChild(r)}e.body&&dO(e.body,"react-draggable-transparent-selection")}function q1(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{I1(e)}):I1(e)}function I1(e){if(e)try{e.body&&hO(e.body,"react-draggable-transparent-selection");const o=e.selection;if(o)o.empty();else{const r=(e.defaultView||window).getSelection();r&&r.type!=="Caret"&&r.removeAllRanges()}}catch{}}function dO(e,o){e.classList?e.classList.add(o):e.className.match(new RegExp(`(?:^|\\s)${o}(?!\\S)`))||(e.className+=` ${o}`)}function hO(e,o){e.classList?e.classList.remove(o):e.className=e.className.replace(new RegExp(`(?:^|\\s)${o}(?!\\S)`,"g"),"")}function pO(e,o,r){if(!e.props.bounds)return[o,r];let{bounds:a}=e.props;a=typeof a=="string"?a:vO(a);const l=Eg(e);if(typeof a=="string"){const{ownerDocument:c}=l,u=c.defaultView;if(!u)throw new Error("Cannot resolve the owner window of the draggable node.");let f;if(a==="parent"?f=l.parentNode:f=l.getRootNode().querySelector(a),!(f instanceof u.HTMLElement))throw new Error('Bounds selector "'+a+'" could not find an element.');const h=f,p=u.getComputedStyle(l),g=u.getComputedStyle(h);a={left:-l.offsetLeft+ln(g.paddingLeft)+ln(p.marginLeft),top:-l.offsetTop+ln(g.paddingTop)+ln(p.marginTop),right:rO(h)-nO(l)-l.offsetLeft+ln(g.paddingRight)-ln(p.marginRight),bottom:oO(h)-tO(l)-l.offsetTop+ln(g.paddingBottom)-ln(p.marginBottom)}}return rs(a.right)&&(o=Math.min(o,a.right)),rs(a.bottom)&&(r=Math.min(r,a.bottom)),rs(a.left)&&(o=Math.max(o,a.left)),rs(a.top)&&(r=Math.max(r,a.top)),[o,r]}function F1(e,o,r){const a=Math.round(o/e[0])*e[0],l=Math.round(r/e[1])*e[1];return[a,l]}function mO(e){return e.props.axis==="both"||e.props.axis==="x"}function gO(e){return e.props.axis==="both"||e.props.axis==="y"}function sp(e,o,r){const a=typeof o=="number"?sO(e,o):null;if(typeof o=="number"&&!a)return null;const l=Eg(r),c=r.props.offsetParent||l.offsetParent||l.ownerDocument.body;return aO(a||e,c,r.props.scale)}function cp(e,o,r){const a=!rs(e.lastX),l=Eg(e);return a?{node:l,deltaX:0,deltaY:0,lastX:o,lastY:r,x:o,y:r}:{node:l,deltaX:o-e.lastX,deltaY:r-e.lastY,lastX:e.lastX,lastY:e.lastY,x:o,y:r}}function up(e,o){const r=e.props.scale;return{node:o.node,x:e.state.x+o.deltaX/r,y:e.state.y+o.deltaY/r,deltaX:o.deltaX/r,deltaY:o.deltaY/r,lastX:e.state.x,lastY:e.state.y}}function vO(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function Eg(e){const o=e.findDOMNode();if(!o)throw new Error(": Unmounted during event!");return o}function Ro(...e){Q4.DRAGGABLE_DEBUG&&console.log(...e)}var so={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}},Lr=so.mouse,ll=class extends b.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button=="number"&&e.button!==0||e.ctrlKey))return!1;const o=this.findDOMNode();if(!o||!o.ownerDocument||!o.ownerDocument.body)throw new Error(" not mounted on DragStart!");const{ownerDocument:r}=o;if(this.props.disabled||!(e.target instanceof r.defaultView.Node)||this.props.handle&&!X1(e.target,this.props.handle,o)||this.props.cancel&&X1(e.target,this.props.cancel,o))return;e.type==="touchstart"&&!this.props.allowMobileScroll&&e.preventDefault();const a=cO(e);this.touchIdentifier=a;const l=sp(e,a,this);if(l==null)return;const{x:c,y:u}=l,f=cp(this,c,u);Ro("DraggableCore: handleDragStart: %j",f),Ro("calling",this.props.onStart),!(this.props.onStart(e,f)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&fO(r,this.props.nonce),this.dragging=!0,this.lastX=c,this.lastY=u,lp(r,Lr.move,this.handleDrag),lp(r,Lr.stop,this.handleDragStop))},this.handleDrag=e=>{const o=sp(e,this.touchIdentifier,this);if(o==null)return;let{x:r,y:a}=o;if(Array.isArray(this.props.grid)){let u=r-this.lastX,f=a-this.lastY;if([u,f]=F1(this.props.grid,u,f),!u&&!f)return;r=this.lastX+u,a=this.lastY+f}const l=cp(this,r,a);if(Ro("DraggableCore: handleDrag: %j",l),this.props.onDrag(e,l)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent("mouseup"))}catch{const u=document.createEvent("MouseEvents");u.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(u)}return}this.lastX=r,this.lastY=a},this.handleDragStop=e=>{if(!this.dragging)return;const o=sp(e,this.touchIdentifier,this);if(o==null)return;let{x:r,y:a}=o;if(Array.isArray(this.props.grid)){let f=r-this.lastX||0,h=a-this.lastY||0;[f,h]=F1(this.props.grid,f,h),r=this.lastX+f,a=this.lastY+h}const l=cp(this,r,a);if(this.props.onStop(e,l)===!1||this.mounted===!1)return!1;const u=this.findDOMNode();u&&this.props.enableUserSelectHack&&q1(u.ownerDocument),Ro("DraggableCore: handleDragStop: %j",l),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,u&&(Ro("DraggableCore: Removing handlers"),ga(u.ownerDocument,Lr.move,this.handleDrag),ga(u.ownerDocument,Lr.stop,this.handleDragStop))},this.onMouseDown=e=>(Lr=so.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(Lr=so.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(Lr=so.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(Lr=so.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;const e=this.findDOMNode();e&&lp(e,so.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const e=this.findDOMNode();if(e){const{ownerDocument:o}=e;ga(o,so.mouse.move,this.handleDrag),ga(o,so.touch.move,this.handleDrag),ga(o,so.mouse.stop,this.handleDragStop),ga(o,so.touch.stop,this.handleDragStop),ga(e,so.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&q1(o)}}findDOMNode(){var e;if((e=this.props)!=null&&e.nodeRef)return this.props.nodeRef.current;const o=Sa;return typeof o.findDOMNode=="function"?o.findDOMNode(this):(Ro("react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef"),null)}render(){return b.cloneElement(b.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};ll.displayName="DraggableCore";ll.propTypes={allowAnyClick:je.bool,allowMobileScroll:je.bool,children:je.node.isRequired,disabled:je.bool,enableUserSelectHack:je.bool,offsetParent:function(e,o){if(e[o]&&e[o].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:je.arrayOf(je.number),handle:je.string,cancel:je.string,nodeRef:je.object,nonce:je.string,onStart:je.func,onDrag:je.func,onStop:je.func,onMouseDown:je.func,scale:je.number,className:Li,style:Li,transform:Li};ll.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var ff=class extends b.Component{constructor(e){super(e),this.onDragStart=(o,r)=>{if(Ro("Draggable: onDragStart: %j",r),this.props.onStart(o,up(this,r))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(o,r)=>{if(!this.state.dragging)return!1;Ro("Draggable: onDrag: %j",r);const a=up(this,r),l={x:a.x,y:a.y,slackX:0,slackY:0};if(this.props.bounds){const{x:u,y:f}=l;l.x+=this.state.slackX,l.y+=this.state.slackY;const[h,p]=pO(this,l.x,l.y);l.x=h,l.y=p,l.slackX=this.state.slackX+(u-l.x),l.slackY=this.state.slackY+(f-l.y),a.x=l.x,a.y=l.y,a.deltaX=l.x-this.state.x,a.deltaY=l.y-this.state.y}if(this.props.onDrag(o,a)===!1)return!1;this.setState(l)},this.onDragStop=(o,r)=>{if(!this.state.dragging||this.props.onStop(o,up(this,r))===!1)return!1;Ro("Draggable: onDragStop: %j",r);const l={dragging:!1,slackX:0,slackY:0};if(!!this.props.position){const{x:u,y:f}=this.props.position;l.x=u,l.y=f}this.setState(l)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this , without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:o}){return e&&(!o||e.x!==o.x||e.y!==o.y)?(Ro("Draggable: getDerivedStateFromProps %j",{position:e,prevPropsPosition:o}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){var e;if((e=this.props)!=null&&e.nodeRef)return this.props.nodeRef.current;const o=Sa;return typeof o.findDOMNode=="function"?o.findDOMNode(this):null}render(){const{axis:e,bounds:o,children:r,defaultPosition:a,defaultClassName:l,defaultClassNameDragging:c,defaultClassNameDragged:u,position:f,positionOffset:h,scale:p,...g}=this.props;let v={},x=null;const E=!!!f||this.state.dragging,C=f||a,R={x:mO(this)&&E?this.state.x:C.x,y:gO(this)&&E?this.state.y:C.y};this.state.isElementSVG?x=lO(R,h):v=iO(R,h);const T=b.Children.only(r),z=zt(T.props.className||"",l,{[c]:this.state.dragging,[u]:this.state.dragged});return b.createElement(ll,{...g,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},b.cloneElement(T,{className:z,style:{...T.props.style,...v},transform:x}))}};ff.displayName="Draggable";ff.propTypes={...ll.propTypes,axis:je.oneOf(["both","x","y","none"]),bounds:je.oneOfType([je.shape({left:je.number,right:je.number,top:je.number,bottom:je.number}),je.string,je.oneOf([!1])]),defaultClassName:je.string,defaultClassNameDragging:je.string,defaultClassNameDragged:je.string,defaultPosition:je.shape({x:je.number,y:je.number}),positionOffset:je.shape({x:je.oneOfType([je.number,je.string]),y:je.oneOfType([je.number,je.string])}),position:je.shape({x:je.number,y:je.number}),className:Li,style:Li,transform:Li};ff.defaultProps={...ll.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1};var yO=ff,Lt=function(){return Lt=Object.assign||function(e){for(var o,r=1,a=arguments.length;r"u"?void 0:Number(a),maxHeight:typeof l>"u"?void 0:Number(l),minWidth:typeof c>"u"?void 0:Number(c),minHeight:typeof u>"u"?void 0:Number(u)}},RO=function(e){return Array.isArray(e)?e:[e,e]},TO=["as","ref","style","className","grid","gridGap","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],J1="__resizable_base__",_O=(function(e){SO(o,e);function o(r){var a,l,c,u,f=e.call(this,r)||this;return f.ratio=1,f.resizable=null,f.parentLeft=0,f.parentTop=0,f.resizableLeft=0,f.resizableRight=0,f.resizableTop=0,f.resizableBottom=0,f.targetLeft=0,f.targetTop=0,f.delta={width:0,height:0},f.appendBase=function(){if(!f.resizable||!f.window)return null;var h=f.parentNode;if(!h)return null;var p=f.window.document.createElement("div");return p.style.width="100%",p.style.height="100%",p.style.position="absolute",p.style.transform="scale(0, 0)",p.style.left="0",p.style.flex="0 0 100%",p.classList?p.classList.add(J1):p.className+=J1,h.appendChild(p),p},f.removeBase=function(h){var p=f.parentNode;p&&p.removeChild(h)},f.state={isResizing:!1,width:(l=(a=f.propsSize)===null||a===void 0?void 0:a.width)!==null&&l!==void 0?l:"auto",height:(u=(c=f.propsSize)===null||c===void 0?void 0:c.height)!==null&&u!==void 0?u:"auto",direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},f.onResizeStart=f.onResizeStart.bind(f),f.onMouseMove=f.onMouseMove.bind(f),f.onMouseUp=f.onMouseUp.bind(f),f}return Object.defineProperty(o.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"window",{get:function(){return!this.resizable||!this.resizable.ownerDocument?null:this.resizable.ownerDocument.defaultView},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||wO},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"size",{get:function(){var r=0,a=0;if(this.resizable&&this.window){var l=this.resizable.offsetWidth,c=this.resizable.offsetHeight,u=this.resizable.style.position;u!=="relative"&&(this.resizable.style.position="relative"),r=this.resizable.style.width!=="auto"?this.resizable.offsetWidth:l,a=this.resizable.style.height!=="auto"?this.resizable.offsetHeight:c,this.resizable.style.position=u}return{width:r,height:a}},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sizeStyle",{get:function(){var r=this,a=this.props.size,l=function(f){var h;if(typeof r.state[f]>"u"||r.state[f]==="auto")return"auto";if(r.propsSize&&r.propsSize[f]&&(!((h=r.propsSize[f])===null||h===void 0)&&h.toString().endsWith("%"))){if(r.state[f].toString().endsWith("%"))return r.state[f].toString();var p=r.getParentSize(),g=Number(r.state[f].toString().replace("px","")),v=g/p[f]*100;return"".concat(v,"%")}return fp(r.state[f])},c=a&&typeof a.width<"u"&&!this.state.isResizing?fp(a.width):l("width"),u=a&&typeof a.height<"u"&&!this.state.isResizing?fp(a.height):l("height");return{width:c,height:u}},enumerable:!1,configurable:!0}),o.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var r=this.appendBase();if(!r)return{width:0,height:0};var a=!1,l=this.parentNode.style.flexWrap;l!=="wrap"&&(a=!0,this.parentNode.style.flexWrap="wrap"),r.style.position="relative",r.style.minWidth="100%",r.style.minHeight="100%";var c={width:r.offsetWidth,height:r.offsetHeight};return a&&(this.parentNode.style.flexWrap=l),this.removeBase(r),c},o.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},o.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},o.prototype.componentDidMount=function(){if(!(!this.resizable||!this.window)){var r=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:r.flexBasis!=="auto"?r.flexBasis:void 0})}},o.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},o.prototype.createSizeForCssProperty=function(r,a){var l=this.propsSize&&this.propsSize[a];return this.state[a]==="auto"&&this.state.original[a]===r&&(typeof l>"u"||l==="auto")?"auto":r},o.prototype.calculateNewMaxFromBoundary=function(r,a){var l=this.props.boundsByDirection,c=this.state.direction,u=l&&_i("left",c),f=l&&_i("top",c),h,p;if(this.props.bounds==="parent"){var g=this.parentNode;g&&(h=u?this.resizableRight-this.parentLeft:g.offsetWidth+(this.parentLeft-this.resizableLeft),p=f?this.resizableBottom-this.parentTop:g.offsetHeight+(this.parentTop-this.resizableTop))}else this.props.bounds==="window"?this.window&&(h=u?this.resizableRight:this.window.innerWidth-this.resizableLeft,p=f?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(h=u?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),p=f?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return h&&Number.isFinite(h)&&(r=r&&r"u"?10:c.width,v=typeof l.width>"u"||l.width<0?r:l.width,x=typeof c.height>"u"?10:c.height,S=typeof l.height>"u"||l.height<0?a:l.height,E=h||0,C=p||0;if(f){var R=(x-E)*this.ratio+C,T=(S-E)*this.ratio+C,z=(g-C)/this.ratio+E,A=(v-C)/this.ratio+E,N=Math.max(g,R),B=Math.min(v,T),M=Math.max(x,z),$=Math.min(S,A);r=eu(r,N,B),a=eu(a,M,$)}else r=eu(r,g,v),a=eu(a,x,S);return{newWidth:r,newHeight:a}},o.prototype.setBoundingClientRect=function(){var r=1/(this.props.scale||1);if(this.props.bounds==="parent"){var a=this.parentNode;if(a){var l=a.getBoundingClientRect();this.parentLeft=l.left*r,this.parentTop=l.top*r}}if(this.props.bounds&&typeof this.props.bounds!="string"){var c=this.props.bounds.getBoundingClientRect();this.targetLeft=c.left*r,this.targetTop=c.top*r}if(this.resizable){var u=this.resizable.getBoundingClientRect(),f=u.left,h=u.top,p=u.right,g=u.bottom;this.resizableLeft=f*r,this.resizableRight=p*r,this.resizableTop=h*r,this.resizableBottom=g*r}},o.prototype.onResizeStart=function(r,a){if(!(!this.resizable||!this.window)){var l=0,c=0;if(r.nativeEvent&&CO(r.nativeEvent)?(l=r.nativeEvent.clientX,c=r.nativeEvent.clientY):r.nativeEvent&&tu(r.nativeEvent)&&(l=r.nativeEvent.touches[0].clientX,c=r.nativeEvent.touches[0].clientY),this.props.onResizeStart&&this.resizable){var u=this.props.onResizeStart(r,a,this.resizable);if(u===!1)return}this.props.size&&(typeof this.props.size.height<"u"&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),typeof this.props.size.width<"u"&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio=typeof this.props.lockAspectRatio=="number"?this.props.lockAspectRatio:this.size.width/this.size.height;var f,h=this.window.getComputedStyle(this.resizable);if(h.flexBasis!=="auto"){var p=this.parentNode;if(p){var g=this.window.getComputedStyle(p).flexDirection;this.flexDir=g.startsWith("row")?"row":"column",f=h.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var v={original:{x:l,y:c,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:Eo(Eo({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(r.target).cursor||"auto"}),direction:a,flexBasis:f};this.setState(v)}},o.prototype.onMouseMove=function(r){var a=this;if(!(!this.state.isResizing||!this.resizable||!this.window)){if(this.window.TouchEvent&&tu(r))try{r.preventDefault(),r.stopPropagation()}catch{}var l=this.props,c=l.maxWidth,u=l.maxHeight,f=l.minWidth,h=l.minHeight,p=tu(r)?r.touches[0].clientX:r.clientX,g=tu(r)?r.touches[0].clientY:r.clientY,v=this.state,x=v.direction,S=v.original,E=v.width,C=v.height,R=this.getParentSize(),T=EO(R,this.window.innerWidth,this.window.innerHeight,c,u,f,h);c=T.maxWidth,u=T.maxHeight,f=T.minWidth,h=T.minHeight;var z=this.calculateNewSizeFromDirection(p,g),A=z.newHeight,N=z.newWidth,B=this.calculateNewMaxFromBoundary(c,u);this.props.snap&&this.props.snap.x&&(N=W1(N,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(A=W1(A,this.props.snap.y,this.props.snapGap));var M=this.calculateNewSizeFromAspectRatio(N,A,{width:B.maxWidth,height:B.maxHeight},{width:f,height:h});if(N=M.newWidth,A=M.newHeight,this.props.grid){var $=K1(N,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),L=K1(A,this.props.grid[1],this.props.gridGap?this.props.gridGap[1]:0),H=this.props.snapGap||0,I=H===0||Math.abs($-N)<=H?$:N,Y=H===0||Math.abs(L-A)<=H?L:A;N=I,A=Y}var X={width:N-S.width,height:A-S.height};if(this.delta=X,E&&typeof E=="string"){if(E.endsWith("%")){var ee=N/R.width*100;N="".concat(ee,"%")}else if(E.endsWith("vw")){var ne=N/this.window.innerWidth*100;N="".concat(ne,"vw")}else if(E.endsWith("vh")){var re=N/this.window.innerHeight*100;N="".concat(re,"vh")}}if(C&&typeof C=="string"){if(C.endsWith("%")){var ee=A/R.height*100;A="".concat(ee,"%")}else if(C.endsWith("vw")){var ne=A/this.window.innerWidth*100;A="".concat(ne,"vw")}else if(C.endsWith("vh")){var re=A/this.window.innerHeight*100;A="".concat(re,"vh")}}var j={width:this.createSizeForCssProperty(N,"width"),height:this.createSizeForCssProperty(A,"height")};this.flexDir==="row"?j.flexBasis=j.width:this.flexDir==="column"&&(j.flexBasis=j.height);var k=this.state.width!==j.width,V=this.state.height!==j.height,P=this.state.flexBasis!==j.flexBasis,Z=k||V||P;Z&&co.flushSync(function(){a.setState(j)}),this.props.onResize&&Z&&this.props.onResize(r,x,this.resizable,X)}},o.prototype.onMouseUp=function(r){var a,l,c=this.state,u=c.isResizing,f=c.direction;c.original,!(!u||!this.resizable)&&(this.props.onResizeStop&&this.props.onResizeStop(r,f,this.resizable,this.delta),this.props.size&&this.setState({width:(a=this.props.size.width)!==null&&a!==void 0?a:"auto",height:(l=this.props.size.height)!==null&&l!==void 0?l:"auto"}),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:Eo(Eo({},this.state.backgroundStyle),{cursor:"auto"})}))},o.prototype.updateSize=function(r){var a,l;this.setState({width:(a=r.width)!==null&&a!==void 0?a:"auto",height:(l=r.height)!==null&&l!==void 0?l:"auto"})},o.prototype.renderResizer=function(){var r=this,a=this.props,l=a.enable,c=a.handleStyles,u=a.handleClasses,f=a.handleWrapperStyle,h=a.handleWrapperClass,p=a.handleComponent;if(!l)return null;var g=Object.keys(l).map(function(v){return l[v]!==!1?y.jsx(xO,{direction:v,onResizeStart:r.onResizeStart,replaceStyles:c&&c[v],className:u&&u[v],children:p&&p[v]?p[v]:null},v):null});return y.jsx("div",{className:h,style:f,children:g})},o.prototype.render=function(){var r=this,a=Object.keys(this.props).reduce(function(u,f){return TO.indexOf(f)!==-1||(u[f]=r.props[f]),u},{}),l=Eo(Eo(Eo({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(l.flexBasis=this.state.flexBasis);var c=this.props.as||"div";return y.jsxs(c,Eo({style:l,className:this.props.className},a,{ref:function(u){u&&(r.resizable=u)},children:[this.state.isResizing&&y.jsx("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer()]}))},o.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],gridGap:[0,0],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},o})(b.PureComponent);var Yp=function(e,o){return Yp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,a){r.__proto__=a}||function(r,a){for(var l in a)a.hasOwnProperty(l)&&(r[l]=a[l])},Yp(e,o)};function DO(e,o){Yp(e,o);function r(){this.constructor=e}e.prototype=o===null?Object.create(o):(r.prototype=o.prototype,new r)}var Pt=function(){return Pt=Object.assign||function(o){for(var r,a=1,l=arguments.length;a"u"?Number.MAX_SAFE_INTEGER:this.props.maxWidth,a=typeof this.props.maxHeight>"u"?Number.MAX_SAFE_INTEGER:this.props.maxHeight;return{maxWidth:r,maxHeight:a}},o.prototype.getSelfElement=function(){return this.resizable&&this.resizable.resizable},o.prototype.getOffsetHeight=function(r){var a=this.props.scale;switch(this.props.bounds){case"window":return window.innerHeight/a;case"body":return document.body.offsetHeight/a;default:return r.offsetHeight}},o.prototype.getOffsetWidth=function(r){var a=this.props.scale;switch(this.props.bounds){case"window":return window.innerWidth/a;case"body":return document.body.offsetWidth/a;default:return r.offsetWidth}},o.prototype.onDragStart=function(r,a){if(this.props.onDragStart&&this.props.onDragStart(r,a)===!1)return!1;var l=this.getDraggablePosition();if(this.originalPosition=l,!!this.props.bounds){var c=this.getParent(),u=this.props.scale,f;if(this.props.bounds==="parent")f=c;else if(this.props.bounds==="body"){var h=c.getBoundingClientRect(),p=h.left,g=h.top,v=document.body.getBoundingClientRect(),x=-(p-c.offsetLeft*u-v.left)/u,S=-(g-c.offsetTop*u-v.top)/u,E=(document.body.offsetWidth-this.resizable.size.width*u)/u+x,C=(document.body.offsetHeight-this.resizable.size.height*u)/u+S;return this.setState({bounds:{top:S,right:E,bottom:C,left:x}})}else if(this.props.bounds==="window"){if(!this.resizable)return;var R=c.getBoundingClientRect(),T=R.left,z=R.top,A=-(T-c.offsetLeft*u)/u,N=-(z-c.offsetTop*u)/u,E=(window.innerWidth-this.resizable.size.width*u)/u+A,C=(window.innerHeight-this.resizable.size.height*u)/u+N;return this.setState({bounds:{top:N,right:E,bottom:C,left:A}})}else typeof this.props.bounds=="string"?f=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(f=this.props.bounds);if(!(!(f instanceof HTMLElement)||!(c instanceof HTMLElement))){var B=f.getBoundingClientRect(),M=B.left,$=B.top,L=c.getBoundingClientRect(),H=L.left,I=L.top,Y=(M-H)/u,X=$-I;if(this.resizable){this.updateOffsetFromParent();var ee=this.offsetFromParent;this.setState({bounds:{top:X-ee.top,right:Y+(f.offsetWidth-this.resizable.size.width)-ee.left/u,bottom:X+(f.offsetHeight-this.resizable.size.height)-ee.top,left:Y-ee.left/u}})}}}},o.prototype.onDrag=function(r,a){if(this.props.onDrag){var l=this.offsetFromParent,c=l.left,u=l.top;if(!this.props.dragAxis||this.props.dragAxis==="both")return this.props.onDrag(r,Pt(Pt({},a),{x:a.x+c,y:a.y+u}));if(this.props.dragAxis==="x")return this.props.onDrag(r,Pt(Pt({},a),{x:a.x+c,y:this.originalPosition.y+u,deltaY:0}));if(this.props.dragAxis==="y")return this.props.onDrag(r,Pt(Pt({},a),{x:this.originalPosition.x+c,y:a.y+u,deltaX:0}))}},o.prototype.onDragStop=function(r,a){if(this.props.onDragStop){var l=this.offsetFromParent,c=l.left,u=l.top;if(!this.props.dragAxis||this.props.dragAxis==="both")return this.props.onDragStop(r,Pt(Pt({},a),{x:a.x+c,y:a.y+u}));if(this.props.dragAxis==="x")return this.props.onDragStop(r,Pt(Pt({},a),{x:a.x+c,y:this.originalPosition.y+u,deltaY:0}));if(this.props.dragAxis==="y")return this.props.onDragStop(r,Pt(Pt({},a),{x:this.originalPosition.x+c,y:a.y+u,deltaX:0}))}},o.prototype.onResizeStart=function(r,a,l){if(this.props.onResizeStart&&this.props.onResizeStart(r,a,l)===!1)return!1;r.stopPropagation(),this.setState({resizing:!0});var c=this.props.scale,u=this.offsetFromParent,f=this.getDraggablePosition();if(this.resizingPosition={x:f.x+u.left,y:f.y+u.top},this.originalPosition=f,this.props.bounds){var h=this.getParent(),p=void 0;this.props.bounds==="parent"?p=h:this.props.bounds==="body"?p=document.body:this.props.bounds==="window"?p=window:typeof this.props.bounds=="string"?p=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(p=this.props.bounds);var g=this.getSelfElement();if(g instanceof Element&&(p instanceof HTMLElement||p===window)&&h instanceof HTMLElement){var v=this.getMaxSizesFromProps(),x=v.maxWidth,S=v.maxHeight,E=this.getParentSize();if(x&&typeof x=="string")if(x.endsWith("%")){var C=Number(x.replace("%",""))/100;x=E.width*C}else x.endsWith("px")&&(x=Number(x.replace("px","")));if(S&&typeof S=="string")if(S.endsWith("%")){var C=Number(S.replace("%",""))/100;S=E.height*C}else S.endsWith("px")&&(S=Number(S.replace("px","")));var R=g.getBoundingClientRect(),T=R.left,z=R.top,A=this.props.bounds==="window"?{left:0,top:0}:p.getBoundingClientRect(),N=A.left,B=A.top,M=this.getOffsetWidth(p),$=this.getOffsetHeight(p),L=a.toLowerCase().endsWith("left"),H=a.toLowerCase().endsWith("right"),I=a.startsWith("top"),Y=a.startsWith("bottom");if((L||I)&&this.resizable){var X=(T-N)/c+this.resizable.size.width;this.setState({maxWidth:X>Number(x)?x:X})}if(H||this.props.lockAspectRatio&&!L&&!I){var X=M+(N-T)/c;this.setState({maxWidth:X>Number(x)?x:X})}if((I||L)&&this.resizable){var X=(z-B)/c+this.resizable.size.height;this.setState({maxHeight:X>Number(S)?S:X})}if(Y||this.props.lockAspectRatio&&!I&&!L){var X=$+(B-z)/c;this.setState({maxHeight:X>Number(S)?S:X})}}}else this.setState({maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight})},o.prototype.onResize=function(r,a,l,c){var u=this,f={x:this.originalPosition.x,y:this.originalPosition.y},h=-c.width,p=-c.height,g=["top","left","topLeft","bottomLeft","topRight"];g.includes(a)&&(a==="bottomLeft"?f.x+=h:(a==="topRight"||(f.x+=h),f.y+=p));var v=this.draggable.state;(f.x!==v.x||f.y!==v.y)&&co.flushSync(function(){u.draggable.setState(f)}),this.updateOffsetFromParent();var x=this.offsetFromParent,S=this.getDraggablePosition().x+x.left,E=this.getDraggablePosition().y+x.top;this.resizingPosition={x:S,y:E},this.props.onResize&&this.props.onResize(r,a,l,c,{x:S,y:E})},o.prototype.onResizeStop=function(r,a,l,c){this.setState({resizing:!1});var u=this.getMaxSizesFromProps(),f=u.maxWidth,h=u.maxHeight;this.setState({maxWidth:f,maxHeight:h}),this.props.onResizeStop&&this.props.onResizeStop(r,a,l,c,this.resizingPosition)},o.prototype.updateSize=function(r){this.resizable&&this.resizable.updateSize({width:r.width,height:r.height})},o.prototype.updatePosition=function(r){this.draggable.setState(r)},o.prototype.updateOffsetFromParent=function(){var r=this.props.scale,a=this.getParent(),l=this.getSelfElement();if(!a||l===null)return{top:0,left:0};var c=a.getBoundingClientRect(),u=c.left,f=c.top,h=l.getBoundingClientRect(),p=this.getDraggablePosition(),g=a.scrollLeft,v=a.scrollTop;this.offsetFromParent={left:h.left-u+g-p.x*r,top:h.top-f+v-p.y*r}},o.prototype.render=function(){var r=this,a=this.props,l=a.disableDragging,c=a.style,u=a.dragHandleClassName,f=a.position,h=a.onMouseDown,p=a.onMouseUp,g=a.dragAxis,v=a.dragGrid,x=a.bounds,S=a.enableUserSelectHack,E=a.cancel,C=a.children;a.onResizeStart,a.onResize,a.onResizeStop,a.onDragStart,a.onDrag,a.onDragStop;var R=a.resizeHandleStyles,T=a.resizeHandleClasses,z=a.resizeHandleComponent,A=a.enableResizing,N=a.resizeGrid,B=a.resizeHandleWrapperClass,M=a.resizeHandleWrapperStyle,$=a.scale,L=a.allowAnyClick,H=a.dragPositionOffset,I=NO(a,["disableDragging","style","dragHandleClassName","position","onMouseDown","onMouseUp","dragAxis","dragGrid","bounds","enableUserSelectHack","cancel","children","onResizeStart","onResize","onResizeStop","onDragStart","onDrag","onDragStop","resizeHandleStyles","resizeHandleClasses","resizeHandleComponent","enableResizing","resizeGrid","resizeHandleWrapperClass","resizeHandleWrapperStyle","scale","allowAnyClick","dragPositionOffset"]),Y=this.props.default?Pt({},this.props.default):void 0;delete I.default;var X=l||u?{cursor:"auto"}:{cursor:"move"},ee=Pt(Pt(Pt({},AO),X),c),ne=this.offsetFromParent,re=ne.left,j=ne.top,k;f&&(k={x:f.x-re,y:f.y-j});var V=this.state.resizing?void 0:k,P=this.state.resizing?"both":g;return b.createElement(yO,{ref:function(Z){Z&&(r.draggable=Z)},handle:u?".".concat(u):void 0,defaultPosition:Y,onMouseDown:h,onMouseUp:p,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,axis:P,disabled:l,grid:v,bounds:x?this.state.bounds:void 0,position:V,enableUserSelectHack:S,cancel:E,scale:$,allowAnyClick:L,nodeRef:this.resizableElement,positionOffset:H},b.createElement(_O,Pt({},I,{ref:function(Z){Z&&(r.resizable=Z,r.resizableElement.current=Z.resizable)},defaultSize:Y,size:this.props.size,enable:typeof A=="boolean"?zO(A):A,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,style:ee,minWidth:this.props.minWidth,minHeight:this.props.minHeight,maxWidth:this.state.resizing?this.state.maxWidth:this.props.maxWidth,maxHeight:this.state.resizing?this.state.maxHeight:this.props.maxHeight,grid:N,handleWrapperClass:B,handleWrapperStyle:M,lockAspectRatio:this.props.lockAspectRatio,lockAspectRatioExtraWidth:this.props.lockAspectRatioExtraWidth,lockAspectRatioExtraHeight:this.props.lockAspectRatioExtraHeight,handleStyles:R,handleClasses:T,handleComponent:z,scale:this.props.scale}),C))},o.defaultProps={maxWidth:Number.MAX_SAFE_INTEGER,maxHeight:Number.MAX_SAFE_INTEGER,scale:1,onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},onDragStart:function(){},onDrag:function(){},onDragStop:function(){}},o})(b.PureComponent);const CC=1920,EC=1080;function Di(e){const o=Math.round(e);return o-o%2}function RC(e,o,r=CC,a=EC){const{x:l,y:c,w:u,h:f,valign:h="center",halign:p="center"}=e,g=e.direction==="vertical",v=u*r,x=f*a,S=[];if(g){const E=Di(c*a),C=Di(Math.min(x/o,v*9/16)),R=C*o,T=x,z=Di(h==="top"?0:h==="bottom"?T-R:(T-R)/2),A=C/a;for(let N=0;N0?S*g/2:0,C=[];for(let R=0;R0,N=r+T*g+(A?E:0),B=a+z*v;C.push([N,B,g,v,u,f])}return C}function TC(e,o){const r=new Array(o.length).fill(0),a=o.map(u=>u.max!=null?u.max:null),l=new Set(o.map((u,f)=>f));let c=e;for(;c>0&&l.size>0;){const u=Math.floor(c/l.size);if(u===0){for(const h of[...l].sort((p,g)=>p-g).slice(0,c))r[h]+=1;break}let f=!1;for(const h of[...l]){const p=a[h],g=p!=null?p-r[h]:null,v=g!=null?Math.min(u,g):u;v>0&&(r[h]+=v,c-=v,f=!0),p!=null&&r[h]>=p&&l.delete(h)}if(!f)break}return r}function jO(e,o,r=CC,a=EC){const l=e.filter(v=>v.type==="static"),c=e.filter(v=>v.type==="row"||v.type==="grid"),u=Math.max(0,o-l.length);if(u>0&&c.length===0)return null;const f=TC(u,c),h=[];let p=0,g=0;for(const v of e){if(p>=o)break;if(v.type==="static")h.push([v.x,v.y,v.w,v.h,v.valign??"center",v.halign??"center"]),p+=1;else if(v.type==="row"||v.type==="grid"){const x=f[g];if(g+=1,x<=0)continue;h.push(...v.type==="row"?RC(v,x,r,a):OO(v,x)),p+=x}}return p({value:p,match:BO(p,r,a)})).filter(p=>p.match);if(!l.length)return{pos:e,guides:[]};const c=l.reduce((p,g)=>p.match.dist<=g.match.dist?p:g),u=c.match.target-c.value,f=e+u,h=[];for(const p of l)Math.abs(p.value+u-p.match.target)<=a&&h.push(p.match.target);return{pos:f,guides:h}}function $O(e,o,r,a=8){const{x:l,y:c,w:u,h:f}=e,h=[],p=ex(l,[l,l+u/2,l+u],o,a);for(const v of p.guides)h.push({axis:"x",pos:v});const g=ex(c,[c,c+f/2,c+f],r,a);for(const v of g.guides)h.push({axis:"y",pos:v});return{x:p.pos,y:g.pos,w:u,h:f,guides:h}}function LO({canvasW:e,canvasH:o,others:r,subdivisions:a,snapToCanvas:l,snapToElements:c}){const u=[],f=[];if(l&&(u.push(0,e/2,e),f.push(0,o/2,o)),c){for(const h of r)u.push(h.x,h.x+h.w/2,h.x+h.w),f.push(h.y,h.y+h.h/2,h.y+h.h);for(const h of a??[])h.axis==="x"?u.push(h.pos*e):f.push(h.pos*o)}return{targetsX:u,targetsY:f}}function _C(e){return new Promise((o,r)=>{const a=new FileReader;a.onload=()=>o(a.result.split(",")[1]),a.onerror=()=>r(new Error("Failed to read file")),a.readAsDataURL(e)})}const tx={static:"Static",row:"Auto Row",grid:"Auto Grid"},kO={static:{border:"1px solid var(--mantine-color-blue-5)",background:"rgba(51, 154, 240, 0.15)"},row:{border:"2px dashed var(--mantine-color-teal-5)",background:"rgba(18, 184, 134, 0.12)"},grid:{border:"2px dotted var(--mantine-color-orange-5)",background:"rgba(253, 126, 20, 0.12)"}},ou={background:"var(--mantine-color-yellow-5)",border:"1px solid rgba(0, 0, 0, 0.4)",borderRadius:"50%"},HO={topLeft:ou,topRight:ou,bottomLeft:ou,bottomRight:ou},ru=[{value:"auto",label:"Auto Grid"},{value:"featured",label:"Featured"},{value:"top_featured",label:"Top Featured"}],UO={auto:[{id:"b-grid",type:"grid",x:0,y:0,w:1,h:1,valign:"center",halign:"center"}],featured:[{id:"b-main",type:"static",x:0,y:0,w:.6,h:1,valign:"center",halign:"center"},{id:"b-side",type:"row",direction:"vertical",x:.6,y:0,w:.4,h:1,valign:"center",halign:"center"}],top_featured:[{id:"b-main",type:"static",x:0,y:0,w:1,h:.6,valign:"center",halign:"center"},{id:"b-bottom",type:"row",direction:"horizontal",x:0,y:.6,w:1,h:.4,valign:"center",halign:"center"}]},DC=4,nx=Up.map(e=>({value:e,label:e}));function ox(e,o){const r=e.filter(f=>f.type==="static"),a=e.filter(f=>f.type==="row"||f.type==="grid"),l=Math.max(0,o-r.length),c=TC(l,a),u=[];return a.forEach((f,h)=>{const p=c[h];if(p<=1)return;const g=f.x,v=f.y,x=f.x+f.w,S=f.y+f.h;if(f.type==="grid"){const M=Math.ceil(Math.sqrt(p)),$=Math.ceil(p/M);for(let L=1;LM-$),A=[...R].sort((M,$)=>M-$),N=z[0]??g,B=A[0]??v;for(const M of z)M>N+T&&u.push({axis:"x",pos:M,from:v,to:S});for(const M of A)M>B+T&&u.push({axis:"y",pos:M,from:g,to:x})}),u}function PO(){const[e,o]=b.useState(null),[r,a]=b.useState(null);return b.useEffect(()=>{if(!e)return;const l=new ResizeObserver(c=>{const{width:u,height:f}=c[0].contentRect;u>0&&f>0&&a({width:Math.round(u),height:Math.round(f)})});return l.observe(e),()=>l.disconnect()},[e]),[r,o]}function zi(e){return e<=.001?0:e>=1-.001?1:e}function rx({x:e,y:o,w:r,h:a}){return{x:zi(e),y:zi(o),w:zi(r),h:zi(a)}}function VO(e,o){const r=1.7777777777777777;let a=e,l=a/r;return l>o&&(l=o,a=l*r),{width:Math.round(a),height:Math.round(l)}}function NC({tiles:e}){return y.jsx("div",{style:{position:"relative",width:160,height:90,background:"var(--mantine-color-dark-6)",border:"1px solid var(--mantine-color-dark-4)",flexShrink:0},children:(e??[]).map((o,r)=>y.jsx("div",{style:{position:"absolute",left:`${o[0]*100}%`,top:`${o[1]*100}%`,width:`${o[2]*100}%`,height:`${o[3]*100}%`,border:"1px solid var(--mantine-color-blue-5)",background:"rgba(51, 154, 240, 0.15)",boxSizing:"border-box"}},r))})}function YO({elements:e,selectedIdx:o,onSelect:r,onElementChange:a,backgroundUrl:l,previewCountNum:c,snapToCanvas:u,snapToElements:f,canvasW:h,canvasH:p,isMobile:g,readOnly:v}){const[x,S]=b.useState([]),[E,C]=b.useState(null),R=E?e.map((B,M)=>M===E.idx?{...B,x:E.x,y:E.y,w:E.w,h:E.h}:B):e,T=ox(R,c);function z(B){return{x:B.x*h,y:B.y*p,w:B.w*h,h:B.h*p}}function A(B){return e.filter((M,$)=>$!==B).map(z)}function N(B,M){const $=ox(R.filter((I,Y)=>Y!==B),c),{targetsX:L,targetsY:H}=LO({canvasW:h,canvasH:p,others:A(B),subdivisions:$,snapToCanvas:u,snapToElements:f});return $O(M,L,H)}return y.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",background:"var(--mantine-color-dark-6)",border:"1px solid var(--mantine-color-dark-4)"},children:[l&&y.jsx("img",{src:l,alt:"",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none"}}),T.map((B,M)=>B.axis==="x"?y.jsx("div",{style:{position:"absolute",left:B.pos*h,top:B.from*p,width:1,height:(B.to-B.from)*p,background:"rgba(255, 255, 255, 0.3)",pointerEvents:"none"}},`sub-${M}`):y.jsx("div",{style:{position:"absolute",top:B.pos*p,left:B.from*h,height:1,width:(B.to-B.from)*h,background:"rgba(255, 255, 255, 0.3)",pointerEvents:"none"}},`sub-${M}`)),e.map((B,M)=>{const $=z(B),L=o===M;return y.jsx(MO,{bounds:"parent",size:{width:$.w,height:$.h},position:{x:$.x,y:$.y},minWidth:20,minHeight:20,lockAspectRatio:B.lockAspect?B.w*h/(B.h*p):!1,resizeHandleStyles:L&&g&&!v?HO:void 0,disableDragging:v,enableResizing:!v,onMouseDown:()=>r(M),onDrag:(H,I)=>{const Y=N(M,{x:I.x,y:I.y,w:$.w,h:$.h});S(Y.guides),C({idx:M,x:Y.x/h,y:Y.y/p,w:B.w,h:B.h})},onDragStop:(H,I)=>{const Y=N(M,{x:I.x,y:I.y,w:$.w,h:$.h});S([]),C(null),a(M,rx({x:Y.x/h,y:Y.y/p,w:B.w,h:B.h}))},onResize:(H,I,Y,X,ee)=>{const ne=N(M,{x:ee.x,y:ee.y,w:Y.offsetWidth,h:Y.offsetHeight});S(ne.guides),C({idx:M,x:ne.x/h,y:ne.y/p,w:ne.w/h,h:ne.h/p})},onResizeStop:(H,I,Y,X,ee)=>{const ne=N(M,{x:ee.x,y:ee.y,w:Y.offsetWidth,h:Y.offsetHeight});S([]),C(null),a(M,rx({x:ne.x/h,y:ne.y/p,w:ne.w/h,h:ne.h/p}))},style:{...kO[B.type],outline:L?"2px solid var(--mantine-color-yellow-5)":"none",outlineOffset:-2,display:"flex",alignItems:"center",justifyContent:"center"},children:y.jsx(Ye,{size:"xs",c:"dimmed",ta:"center",style:{userSelect:"none",pointerEvents:"none"},children:B.name||M+1})},B.id)}),x.map((B,M)=>B.axis==="x"?y.jsx("div",{style:{position:"absolute",left:B.pos,top:0,width:1,height:p,background:"var(--mantine-color-red-5)",pointerEvents:"none"}},`live-${M}`):y.jsx("div",{style:{position:"absolute",top:B.pos,left:0,height:1,width:h,background:"var(--mantine-color-red-5)",pointerEvents:"none"}},`live-${M}`))]})}function ax({style:e,styleId:o,onUpdate:r,readOnly:a=!1}){const[l,c]=b.useState(e),[u,f]=b.useState(!1);b.useEffect(()=>{c(e),f(!1)},[o]);const[h,p]=b.useState(4),[g,v]=b.useState(null),[x,S]=b.useState(null),[E,C]=b.useState(!1),[R,T]=b.useState(!1),[z,A]=b.useState(!0),[N,B]=b.useState(!0),M=b.useRef(null),[$,L]=PO(),H=Qp("(max-width: 48em)"),I=h||4,Y=l.elements??[],X=g!=null?Y[g]:null;b.useEffect(()=>{let O=!1,q=null;return l.background_image?yC(o).then(W=>{O||!W||(q=URL.createObjectURL(W),S(q))}):S(null),()=>{O=!0,q&&URL.revokeObjectURL(q)}},[o,l.background_image]);function ee(O){c(q=>({...q,elements:O})),f(!0)}async function ne(){T(!0);try{await r(l),f(!1)}finally{T(!1)}}async function re(O){const q=O.target.files?.[0];if(O.target.value="",!!q){C(!0);try{const W=await _C(q),ie=await vC(o,q.name,W);c(ue=>({...ue,background_image:ie.filename})),f(!0)}catch(W){Qe.show({title:"Upload failed",message:W.message,color:"red",autoClose:4e3})}finally{C(!1)}}}function j(){c(O=>({...O,background_image:null})),f(!0)}function k(O){const q={id:Na(),type:O,x:.1,y:.1,w:.3,h:.3,valign:"center",halign:"center"};O==="row"&&(q.direction="horizontal");const W=[...Y,q];ee(W),v(W.length-1)}function V(O){ee(Y.filter((q,W)=>W!==O)),g===O?v(null):g!=null&&g>O&&v(g-1)}function P(O){const q=Y[O],W={...q,id:Na(),x:zi(q.x+.02),y:zi(q.y+.02)},ie=[...Y.slice(0,O+1),W,...Y.slice(O+1)];ee(ie),v(O+1)}function Z(O,q){const W=O+q;if(W<0||W>=Y.length)return;const ie=[...Y];[ie[O],ie[W]]=[ie[W],ie[O]],ee(ie),g===O?v(W):g===W&&v(O)}function D(O,q){ee(Y.map((W,ie)=>ie===O?{...W,...q}:W))}return y.jsxs(Qt,{gap:"sm",style:{flex:1,minHeight:0},children:[y.jsxs(mt,{gap:"xs",align:"flex-end",wrap:"wrap",children:[y.jsx(Vi,{size:"xs",label:"Style name",value:l.name??"",onChange:O=>{c(q=>({...q,name:O.currentTarget.value})),f(!0)},placeholder:"Style name",disabled:a,style:{flex:H?"1 1 100%":"1 1 200px"}}),y.jsx(Ca,{size:"xs",label:"Preview channel count",min:2,max:9,value:h,onChange:O=>p(O||4),w:H?"100%":150}),y.jsx(Bi,{size:"xs",label:"Snap to elements",disabled:a,checked:z,onChange:O=>A(O.currentTarget.checked)}),y.jsx(Bi,{size:"xs",label:"Snap to canvas",disabled:a,checked:N,onChange:O=>B(O.currentTarget.checked)}),y.jsx(Dt,{size:"xs",leftSection:y.jsx(p5,{size:14}),disabled:a||!u,loading:R,color:u?"blue":"gray",variant:u?"filled":"default",onClick:ne,style:H?{flex:"1 1 100%"}:void 0,children:u?"Save":"Saved"})]}),y.jsxs(cg,{cols:H?2:4,spacing:"xs",children:[y.jsx(Dt,{size:"xs",variant:"default",leftSection:y.jsx(is,{size:12}),disabled:a,onClick:()=>k("static"),children:"Static Position"}),y.jsx(Dt,{size:"xs",variant:"default",leftSection:y.jsx(is,{size:12}),disabled:a,onClick:()=>k("row"),children:"Auto Row"}),y.jsx(Dt,{size:"xs",variant:"default",leftSection:y.jsx(is,{size:12}),disabled:a,onClick:()=>k("grid"),children:"Auto Grid"}),y.jsxs(mt,{gap:4,wrap:"nowrap",children:[y.jsx(Dt,{size:"xs",variant:"default",leftSection:y.jsx(R5,{size:12}),loading:E,disabled:a,onClick:()=>M.current?.click(),style:{flex:1},children:l.background_image?"Change Background":"Background Image"}),y.jsx(Yt,{size:"sm",variant:"subtle",color:"red",disabled:a||!l.background_image,onClick:j,"aria-label":"Remove background",children:y.jsx(j5,{size:14})})]}),y.jsx("input",{ref:M,type:"file",accept:"image/png,image/jpeg",style:{display:"none"},onChange:re})]}),y.jsx(Ye,{size:"xs",c:"dimmed",children:a?Y.length===0?"This style has no representable elements at this channel count.":"Click a box or list row to inspect its properties.":Y.length===0?"Add a Static Position, Auto Row, or Auto Grid to get started.":"Drag a box to move it, drag its edge/corner to resize it. Click a box or list row to select it."}),y.jsxs(mt,{align:"stretch",gap:"sm",wrap:H?"wrap":"nowrap",style:{flex:1,minHeight:0},children:[y.jsxs(Qt,{gap:6,p:"sm",w:H?"100%":260,style:{flexShrink:0,minHeight:0,overflowY:"auto",border:"1px solid var(--mantine-color-dark-4)",borderRadius:6},children:[y.jsx(Ye,{size:"xs",fw:600,children:X?X.name||tx[X.type]:"No element selected"}),y.jsx(lt,{withRowBorders:!1,verticalSpacing:4,horizontalSpacing:"xs",style:{tableLayout:"fixed",width:"100%"},children:y.jsxs(lt.Tbody,{children:[y.jsxs(lt.Tr,{children:[y.jsx(lt.Td,{w:80,children:y.jsx(Ye,{size:"xs",c:"dimmed",children:"Direction"})}),y.jsx(lt.Td,{children:y.jsx(sg,{size:"xs",fullWidth:!0,disabled:!X||a||X.type!=="row",data:[{label:"Horiz",value:"horizontal"},{label:"Vert",value:"vertical"}],value:X?.direction??"horizontal",onChange:O=>g!=null&&D(g,{direction:O})})})]}),y.jsxs(lt.Tr,{children:[y.jsx(lt.Td,{w:80,children:y.jsx(Ye,{size:"xs",c:"dimmed",children:"Max channels"})}),y.jsx(lt.Td,{children:y.jsx(Ca,{size:"xs",placeholder:"Unlimited",disabled:!X||a||!["row","grid"].includes(X.type),min:1,value:X?.max??"",onChange:O=>g!=null&&D(g,{max:O===""?null:O})})})]}),y.jsxs(lt.Tr,{children:[y.jsx(lt.Td,{w:80,children:y.jsx(Ye,{size:"xs",c:"dimmed",children:"Anchor"})}),y.jsx(lt.Td,{children:y.jsxs(mt,{grow:!0,gap:4,wrap:"nowrap",children:[y.jsx(gs,{size:"xs",placeholder:"V anchor",disabled:!X||a,data:nx,value:X?.valign??null,onChange:O=>O&&g!=null&&D(g,{valign:O})}),y.jsx(gs,{size:"xs",placeholder:"H anchor",disabled:!X||a,data:nx,value:X?.halign??null,onChange:O=>O&&g!=null&&D(g,{halign:O})})]})})]}),y.jsxs(lt.Tr,{children:[y.jsx(lt.Td,{w:80,children:y.jsx(Ye,{size:"xs",c:"dimmed",children:"Size"})}),y.jsx(lt.Td,{children:y.jsxs(mt,{grow:!0,gap:4,wrap:"nowrap",children:[y.jsx(Ca,{size:"xs",label:"Width (px)",description:"of 1920",disabled:!X||a,min:1,value:X?Math.round(X.w*1920):"",onChange:O=>{if(!O||g==null)return;const q=O/1920;if(X.lockAspect){const W=X.w*1920/(X.h*1080);D(g,{w:q,h:O/W/1080})}else D(g,{w:q})}}),y.jsx(Ca,{size:"xs",label:"Height (px)",description:"of 1080",disabled:!X||a,min:1,value:X?Math.round(X.h*1080):"",onChange:O=>{if(!O||g==null)return;const q=O/1080;if(X.lockAspect){const W=X.w*1920/(X.h*1080);D(g,{w:O*W/1920,h:q})}else D(g,{h:q})}})]})})]}),y.jsxs(lt.Tr,{children:[y.jsx(lt.Td,{w:80,children:y.jsx(Ye,{size:"xs",c:"dimmed",children:"Lock aspect"})}),y.jsx(lt.Td,{children:y.jsx(Bi,{size:"xs",disabled:!X||a,checked:!!X?.lockAspect,onChange:O=>g!=null&&D(g,{lockAspect:O.currentTarget.checked})})})]})]})})]}),y.jsx("div",{ref:L,style:H?{width:"100%",aspectRatio:"16 / 9"}:{flex:1,minWidth:0,minHeight:0,display:"flex",alignItems:"center",justifyContent:"center"},children:$&&(()=>{const O=VO($.width,$.height);return y.jsx("div",{style:{width:O.width,height:O.height},children:y.jsx(YO,{elements:Y,selectedIdx:g,onSelect:v,onElementChange:D,backgroundUrl:x,previewCountNum:I,snapToCanvas:N,snapToElements:z,canvasW:O.width,canvasH:O.height,isMobile:H,readOnly:a})})})()}),y.jsxs(Qt,{gap:6,p:"sm",w:H?"100%":220,style:{flexShrink:0,minHeight:0,overflowY:"auto",border:"1px solid var(--mantine-color-dark-4)",borderRadius:6},children:[y.jsx(Ye,{size:"xs",fw:600,c:"dimmed",children:"Elements"}),Y.map((O,q)=>y.jsxs(mt,{gap:4,wrap:"nowrap",onClick:()=>v(q),style:{cursor:"pointer",padding:4,borderRadius:4,background:g===q?"rgba(51, 154, 240, 0.18)":"transparent",borderLeft:g===q?"2px solid var(--mantine-color-blue-5)":"2px solid transparent"},children:[y.jsxs(Ye,{size:"xs",c:"dimmed",children:[q+1,"."]}),y.jsx(Vi,{size:"xs",variant:"unstyled",value:O.name??"",placeholder:tx[O.type],disabled:a,onChange:W=>D(q,{name:W.currentTarget.value}),onClick:W=>W.stopPropagation(),style:{flex:1,minWidth:0},styles:{input:{minHeight:"unset",height:"auto",padding:0}}}),y.jsx(Yt,{size:"xs",variant:"subtle",disabled:a,onClick:W=>{W.stopPropagation(),P(q)},"aria-label":"Duplicate element",children:y.jsx(d5,{size:12})}),y.jsx(Yt,{size:"xs",variant:"subtle",disabled:a||q===0,onClick:W=>{W.stopPropagation(),Z(q,-1)},children:y.jsx(t5,{size:12})}),y.jsx(Yt,{size:"xs",variant:"subtle",disabled:a||q===Y.length-1,onClick:W=>{W.stopPropagation(),Z(q,1)},children:y.jsx(JM,{size:12})}),y.jsx(Yt,{size:"xs",variant:"subtle",color:"red",disabled:a,onClick:W=>{W.stopPropagation(),V(q)},children:y.jsx(pg,{size:12})})]},O.id))]})]})]})}async function GO(e,o){const r={name:o.name,elements:o.elements??[]};if(o.background_image){const a=await yC(e);a&&(r.background_image_filename=o.background_image,r.background_image_data=await _C(a))}return r}async function ix(e){const o=Na(),r={name:e.name||"Imported Style",elements:e.elements??[]};if(e.background_image_data){const a=await vC(o,e.background_image_filename||"background.png",e.background_image_data);r.background_image=a.filename}return[o,r]}function XO(e){return e.some(r=>r.type==="row"||r.type==="grid")?DC:Math.max(e.length,1)}function qO({id:e,style:o,onOpen:r,onExport:a,onDelete:l}){const c=o.elements??[],u=jO(c,XO(c))??[];return y.jsxs(Qt,{gap:4,align:"center",style:{cursor:"pointer",flexShrink:0},onClick:()=>r(e),children:[y.jsx(NC,{tiles:u}),y.jsx(Ye,{size:"xs",children:o.name||"New Style"}),y.jsxs(mt,{gap:4,children:[y.jsx(Yt,{size:"xs",variant:"subtle",onClick:f=>{f.stopPropagation(),a(e,o)},"aria-label":"Export style",children:y.jsx(Vw,{size:12})}),y.jsx(Yt,{size:"xs",variant:"subtle",color:"red",onClick:f=>{f.stopPropagation(),l(e)},"aria-label":"Delete style",children:y.jsx(pg,{size:12})})]})]})}function IO({onClick:e}){return y.jsxs(Qt,{gap:4,align:"center",style:{cursor:"pointer",flexShrink:0},onClick:e,children:[y.jsx("div",{style:{width:160,height:90,display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed var(--mantine-color-dark-4)",color:"var(--mantine-color-dimmed)"},children:y.jsx(is,{size:24})}),y.jsx(Ye,{size:"xs",c:"dimmed",children:"New Style"})]})}function FO({settings:e,onFieldsReload:o}){const r=e.multiview_custom_layouts??{},a=e.multiview_custom_layouts_order??Object.keys(r),[l,c]=b.useState({}),[u,f]=b.useState(null),[h,p]=b.useState(null),[g,v]=b.useState(!0),x=b.useRef(null),S=Qp("(max-width: 48em)");b.useEffect(()=>{(u||h)&&S&&v(!1)},[u,h]),b.useEffect(()=>{let H=!1;return Promise.all(ru.map(I=>B4(I.value,DC).catch(()=>null))).then(I=>{if(H)return;const Y={};ru.forEach((X,ee)=>{I[ee]&&(Y[X.value]=I[ee].tiles)}),c(Y)}),()=>{H=!0}},[]);async function E(H,I){try{await Ur({multiview_custom_layouts:H,multiview_custom_layouts_order:I}),await o()}catch(Y){Qe.show({title:"Save failed",message:Y.message,color:"red",autoClose:4e3})}}async function C(){try{const H=Na();await E({...r,[H]:{name:"New Style",elements:[]}},[...a,H]),f(H)}catch(H){Qe.show({title:"Failed",message:H.message,color:"red",autoClose:4e3})}}function R(H){const I={...r};delete I[H],E(I,a.filter(Y=>Y!==H)),u===H&&f(null)}function T(H,I){return E({...r,[H]:I},a)}async function z(H,I){try{const Y=await GO(H,I);xC(Y,`multiview-style-${(I.name||"style").trim().replace(/\s+/g,"-")||"style"}.json`)}catch(Y){Qe.show({title:"Export failed",message:Y.message,color:"red",autoClose:4e3})}}async function A(H){const I=H.target.files?.[0];if(H.target.value="",!!I)try{const Y=JSON.parse(await I.text());if(!Y||typeof Y!="object"||Array.isArray(Y))throw new Error("Not a valid style file");if(Array.isArray(Y.elements)){Pp(Y);const[X,ee]=await ix(Y);await E({...r,[X]:ee},[...a,X]),Qe.show({message:`Style "${ee.name}" imported`,color:"green",autoClose:2e3})}else{const X=Object.entries(Y);X.forEach(([re,j])=>Pp(j,`style "${re}"`));const ee={},ne=[];for(const[,re]of X){const[j,k]=await ix(re);ee[j]=k,ne.push(j)}await E({...r,...ee},[...a,...ne]),Qe.show({message:`Imported ${ne.length} style(s)`,color:"green",autoClose:2e3})}}catch(Y){Qe.show({title:"Import failed",message:Y.message,color:"red",autoClose:4e3})}}const N=a.filter(H=>r[H]).map(H=>[H,r[H]]),B=u?r[u]:null,M=h?{name:h.label,elements:UO[h.value]}:null;function $(H){p(null),f(H)}function L(H){f(null),p(H)}return b.useEffect(()=>{B||M||(N.length>0?(p(null),f(N[0][0])):(f(null),p(ru[0])))},[B,M,N]),y.jsxs(Qt,{gap:"xs",style:{flex:1,minHeight:0},children:[y.jsxs(mt,{justify:"space-between",gap:"xs",children:[y.jsxs(mt,{gap:4,children:[y.jsx(Ye,{size:"xs",c:"dimmed",children:"Click a built-in to preview it, or a custom style to edit it."}),S&&y.jsx(Yt,{size:"xs",variant:"subtle",onClick:()=>v(H=>!H),"aria-label":g?"Collapse styles":"Expand styles",children:g?y.jsx(s5,{size:12}):y.jsx(Pw,{size:12})})]}),y.jsx(Dt,{size:"xs",variant:"default",leftSection:y.jsx(Gw,{size:12}),onClick:()=>x.current?.click(),children:"Import"}),y.jsx("input",{ref:x,type:"file",accept:"application/json",style:{display:"none"},onChange:A})]}),y.jsx(rm,{in:!S||g,children:y.jsxs(mt,{align:"flex-start",gap:"md",wrap:"nowrap",style:{overflowX:"auto",paddingBottom:4},children:[ru.map(H=>y.jsxs(Qt,{gap:4,align:"center",style:{flexShrink:0,cursor:"pointer"},onClick:()=>L(H),children:[y.jsx(NC,{tiles:l[H.value]}),y.jsx(Ye,{size:"xs",children:H.label})]},H.value)),N.map(([H,I])=>y.jsx(qO,{id:H,style:I,onOpen:$,onExport:z,onDelete:R},H)),y.jsx(IO,{onClick:C})]})}),B?y.jsx(ax,{style:B,styleId:u,onUpdate:H=>T(u,H)}):M?y.jsx(ax,{style:M,styleId:`builtin:${h.value}`,onUpdate:()=>{},readOnly:!0}):null]})}const Gp=/^multiview_([0-9a-f]{8})_(.+)$/;function ZO(e,o,r,a){const l=o.map(p=>{const g={id:p},v=[];for(const[x,S]of Object.entries(e)){const E=x.match(Gp);if(!E||E[1]!==p)continue;const C=E[2].match(/^channel_(\d+)$/);C?v[parseInt(C[1],10)-1]=S:g[E[2]]=S}return v.length&&(g.channels=v),g}),c={};for(const[p,g]of Object.entries(e))p==="multiview_order"||p==="multiview_count"||p==="multiview_custom_layouts"||p==="multiview_custom_layouts_order"||p==="multiview_pre_migration_backup"||p==="multiview_pre_reconcile_backup"||Gp.test(p)||(c[p]=g);const u=e.multiview_custom_layouts??{},f=e.multiview_custom_layouts_order??Object.keys(u),h={};for(const p of f)u[p]&&(h[p]=u[p]);return{global:c,layouts:l,custom_styles:h,plugin_version:r,dispatcharr_version:a}}function QO(e){const o={},r=[];for(const a of e.layouts){const l=Na();r.push(l);for(const[c,u]of Object.entries(a))c!=="id"&&(c==="channels"?u.forEach((f,h)=>{o[`multiview_${l}_channel_${h+1}`]=f}):o[`multiview_${l}_${c}`]=u)}return Object.assign(o,e.global??{}),o.multiview_order=r,o.multiview_custom_layouts=e.custom_styles??{},o.multiview_custom_layouts_order=Object.keys(e.custom_styles??{}),o}function KO({id:e,...o}){const{attributes:r,listeners:a,setNodeRef:l,transform:c,transition:u,isDragging:f}=_4({id:e}),h={transform:ys.Transform.toString(c),transition:u,opacity:f?.5:1};return y.jsx("div",{ref:l,style:h,children:y.jsx(F4,{id:e,dragHandleProps:{...r,...a},...o})})}function WO({onLoggedOut:e}){const[o,r]=b.useState(null),[a,l]=b.useState({}),[c,u]=b.useState(""),[f,h]=b.useState(!1),[p,g]=b.useState(!1),[v,x]=b.useState(!1),[S,E]=b.useState(0),[C,R]=b.useState(()=>new Set),[T,z]=b.useState(null),A=b.useRef(null),N=b.useCallback(async()=>{try{const[P,Z]=await Promise.all([O4(),Y1()]);r(P);const D=Z.settings??{},O=[...P.global??[],...(P.layouts??[]).flatMap(W=>W.fields)],q={...D};for(const W of O)!(W.id in q)&&W.default!==void 0&&(q[W.id]=W.default);l(q)}catch(P){P.status!==401&&u(P.message)}},[]);b.useEffect(()=>{N()},[N]),b.useEffect(()=>{const P=async()=>{try{const O=(await gC()).active??[];E(O.length),R(new Set(O.map(q=>q.n)))}catch{}};P();const Z=setInterval(P,5e3);return()=>clearInterval(Z)},[]),b.useEffect(()=>(V1(e),()=>V1(()=>{})),[e]);const B=b.useCallback(P=>l(Z=>({...Z,...P})),[]);function M(){return(o?.layouts??[]).map(P=>P.n)}async function $(P,Z){const D=`multiview_${P}_channel_count`,O=(a[D]??4)+Z;try{await Ur({[D]:O}),await N()}catch(q){Qe.show({title:"Failed",message:q.message,color:"red",autoClose:4e3})}}async function L(){try{const P=M(),Z=Na(),D=P.length+1,O={multiview_order:[...P,Z],[`multiview_${Z}_name`]:`Multiview ${D}`,[`multiview_${Z}_layout`]:"auto",[`multiview_${Z}_selector_type`]:"classic",[`multiview_${Z}_channel_count`]:4,[`multiview_${Z}_epg_source_mode`]:"dummy"};await Ur(O),await N(),Qe.show({message:`Layout ${D} added`,color:"green",autoClose:2e3})}catch(P){Qe.show({title:"Failed",message:P.message,color:"red",autoClose:4e3})}}async function H(P){const Z=M();if(Z.length<=1)return;const D={multiview_order:Z.filter(O=>O!==P)};for(const O of Object.keys(a))O.startsWith(`multiview_${P}_`)&&(D[O]=null);try{await Ur(D);try{await Hp(P)}catch{}await N(),Qe.show({message:"Layout removed",color:"green",autoClose:2e3})}catch(O){Qe.show({title:"Failed",message:O.message,color:"red",autoClose:4e3})}}const I=o6(n6(wg,{activationConstraint:{distance:4}}));async function Y(P){const{active:Z,over:D}=P;if(!D||Z.id===D.id)return;const O=M(),q=O.indexOf(Z.id),W=O.indexOf(D.id);if(q===-1||W===-1)return;const ie=Cg(O,q,W);try{await Ur({multiview_order:ie}),await N()}catch(ue){Qe.show({title:"Failed",message:ue.message,color:"red",autoClose:4e3})}}async function X(){h(!0);try{const P=await $4();Qe.show({message:P.message||"M3U & EPG refreshed",color:P.status==="success"?"green":"red",autoClose:3e3})}catch(P){Qe.show({title:"Refresh failed",message:P.message,color:"red",autoClose:4e3})}finally{h(!1)}}async function ee(){try{const P=await Y1(),Z=M(),D=ZO(P.settings??{},Z,P.plugin_version,P.dispatcharr_version);xC(D,`multiview-backup-${new Date().toISOString().slice(0,10)}.json`)}catch(P){Qe.show({title:"Export failed",message:P.message,color:"red",autoClose:4e3})}}async function ne(P){const Z=P.target.files?.[0];if(P.target.value="",!!Z)try{const D=JSON.parse(await Z.text());if(!D||typeof D!="object"||Array.isArray(D))throw new Error("Backup file is not a valid settings object");let O,q;if(Array.isArray(D.layouts))X4(D),O=QO(D),q=O.multiview_order;else{q4(D);const fe=Array.isArray(D.multiview_order)?D.multiview_order:[],be=Object.fromEntries(fe.map(ye=>[ye,Na()]));q=fe.map(ye=>be[ye]),O={};for(const[ye,Xe]of Object.entries(D)){if(ye==="multiview_order")continue;const Ne=ye.match(Gp);Ne&&be[Ne[1]]?O[`multiview_${be[Ne[1]]}_${Ne[2]}`]=Xe:Ne||(O[ye]=Xe)}O.multiview_order=q}let W=new Set;try{const fe=await j4();W=new Set(fe.map(be=>String(be.id)))}catch{W=new Set}const ie=[];q.forEach((fe,be)=>{const ye=O[`multiview_${fe}_name`]||`Multiview ${be+1}`,Xe=`multiview_${fe}_`;for(const Ne of Object.keys(O)){if(!Ne.startsWith(Xe))continue;const We=Ne.slice(Xe.length);if(We!=="epg_forward_channel"&&!/^channel_\d+$/.test(We))continue;const Be=O[Ne];Be&&Be!=="_none"&&W.size>0&&!W.has(String(Be))&&(O[Ne]="_none",ie.push(`${ye} (${We})`))}});const ue={};for(const fe of Object.keys(a))fe.startsWith("multiview_")&&(ue[fe]=null);Object.assign(ue,O),ue.multiview_order=q;const ve=ie.length?` ${ie.length} channel selection(s) could not be matched and were cleared (reselect manually): ${ie.join(", ")}.`:"";z({title:"Restore Backup",confirmLabel:"Restore",color:"red",message:`Restore will replace all current layouts and settings with this backup (${q.length} layout(s)).${ve} Continue?`,onConfirm:async()=>{try{await Ur(ue),await N(),Qe.show({message:"Backup restored",color:"green",autoClose:2e3})}catch(fe){Qe.show({title:"Restore failed",message:fe.message,color:"red",autoClose:4e3})}}})}catch(D){Qe.show({title:"Import failed",message:D.message,color:"red",autoClose:4e3})}}if(c)return y.jsx(ps,{mih:"100dvh",children:y.jsx(Ye,{c:"red",children:c})});if(!o)return y.jsx(ps,{mih:"100dvh",children:y.jsx(Ma,{})});const{warnings:re=[],global:j=[],layouts:k=[],layout_count:V}=o;return y.jsxs(mo,{header:{height:56},children:[y.jsx(L5,{logoUrl:pC,appName:"Multiview",version:"0.4.2",githubUrl:"https://github.com/swvn-dispatch/dispatcharr-multiview",username:M4(),onLogout:e,actions:[{key:"streams",label:"Streams",icon:QM,onClick:()=>g(!0),active:S>0,count:S,variant:"default"},{key:"refresh",label:"Refresh M3U & EPG",icon:Yw,loading:f,variant:"default",onClick:()=>z({title:"Refresh M3U & EPG",confirmLabel:"Refresh",color:"blue",message:"Regenerate the M3U playlist and sync EPG data now?",onConfirm:X})},{key:"style-builder",label:"Style Builder",icon:C5,variant:"default",onClick:()=>x(!0)}],extra:y.jsxs(Nt,{shadow:"md",width:190,position:"bottom-end",children:[y.jsx(Nt.Target,{children:y.jsx(Yt,{size:"lg",variant:"default","aria-label":"More actions",children:y.jsx(A5,{size:18})})}),y.jsxs(Nt.Dropdown,{children:[y.jsx(Nt.Item,{leftSection:y.jsx(Vw,{size:14}),onClick:ee,children:"Download Backup"}),y.jsx(Nt.Item,{leftSection:y.jsx(Gw,{size:14}),onClick:()=>A.current?.click(),children:"Restore Backup"})]})]})}),y.jsx("input",{ref:A,type:"file",accept:"application/json",style:{display:"none"},onChange:ne}),y.jsx(Tn,{opened:v,onClose:()=>x(!1),title:"Style Builder",fullScreen:!0,styles:{content:{display:"flex",flexDirection:"column"},body:{flex:1,minHeight:0,display:"flex",flexDirection:"column",overflowY:"auto"}},children:y.jsx(FO,{settings:a,onFieldsReload:N})}),y.jsx(mo.Main,{children:y.jsxs(Qt,{p:"md",maw:860,mx:"auto",children:[y.jsx(P5,{fields:j,warnings:re,values:a,onSave:Ur,onOptimisticChange:B,shouldReload:bC,onReload:N,onSaved:()=>Qe.show({message:"Saved",color:"green",autoClose:1500}),onError:P=>Qe.show({title:"Save failed",message:P.message,color:"red",autoClose:4e3})}),y.jsx(Ye,{size:"xs",tt:"uppercase",fw:700,c:"dimmed",mt:"sm",children:"Layouts"}),y.jsx(l4,{sensors:I,collisionDetection:s6,onDragEnd:Y,children:y.jsx(x4,{items:M(),strategy:y4,children:k.map(({n:P,position:Z,fields:D})=>y.jsx(KO,{id:P,position:Z,fields:D,settings:a,canRemove:V>1,hasActiveStream:C.has(P),onSettingsChange:B,onFieldsReload:N,onRemove:()=>H(P),onChannelCountChange:O=>$(P,O)},P))})}),y.jsx(Dt,{variant:"default",onClick:L,children:"+ Add Layout"})]})}),y.jsx(Z4,{opened:p,onClose:()=>g(!1),settings:a}),y.jsx(Xw,{action:T,onClose:()=>z(null)})]})}function JO(){const[e,o]=b.useState(z4());return e?y.jsx(WO,{onLoggedOut:()=>{A4(),o(!1)}}):y.jsx(k5,{logoUrl:pC,appName:"Multiview",description:"Sign in with your Dispatcharr credentials. The account must have permission to modify plugin settings.",onLogin:N4,onLoggedIn:()=>o(!0)})}K2.createRoot(document.getElementById("root")).render(y.jsx(b.StrictMode,{children:y.jsx($5,{children:y.jsx(JO,{})})})); diff --git a/plugins/multiview/dash/static/index.html b/plugins/multiview/dash/static/index.html index ecb8a33..73e4d1f 100644 --- a/plugins/multiview/dash/static/index.html +++ b/plugins/multiview/dash/static/index.html @@ -10,7 +10,7 @@ Multiview - + diff --git a/plugins/multiview/parameters.py b/plugins/multiview/parameters.py index 3a3188f..0d7da89 100644 --- a/plugins/multiview/parameters.py +++ b/plugins/multiview/parameters.py @@ -21,7 +21,9 @@ def fps_fraction(fps: str) -> Fraction: return Fraction(int(fps), 1) -def _find_dri_device() -> str: +def _find_dri_device(override: str = "") -> str: + if override and override != "auto": + return override devices = sorted(glob.glob("/dev/dri/render*")) return devices[0] if devices else "/dev/dri/renderD128" @@ -60,14 +62,15 @@ def build_encoder_cmd(cfg, out_w, out_h, audio_read) -> list: gop = max(2, round(float(fps_fraction(cfg["fps"])) * 2)) encoder = cfg.get("video_encoder", "libx264") preset = resolve_preset(encoder, cfg.get("preset")) + render_device = cfg.get("render_device", "") cmd = ["ffmpeg", "-hide_banner", "-loglevel", "error"] # Hardware device init must precede inputs. if encoder == "h264_vaapi": - cmd += ["-vaapi_device", _find_dri_device()] + cmd += ["-vaapi_device", _find_dri_device(render_device)] elif encoder == "h264_qsv": - cmd += ["-init_hw_device", f"qsv=hw:{_find_dri_device()}", "-filter_hw_device", "hw"] + cmd += ["-init_hw_device", f"qsv=hw:{_find_dri_device(render_device)}", "-filter_hw_device", "hw"] # Cap muxer/filter threads so it doesn't grab every core and starve # the PyAV decoders (3x 1080p60 decode already loads the box). diff --git a/plugins/multiview/plugin.json b/plugins/multiview/plugin.json index 7a1c3c7..e6d6ba6 100644 --- a/plugins/multiview/plugin.json +++ b/plugins/multiview/plugin.json @@ -4,7 +4,7 @@ "description": "Tile multiple Dispatcharr channel streams into multi-view outputs using FFmpeg", "author": "sethwv", - "version": "0.4.1", + "version": "0.4.2", "min_dispatcharr_version": "v0.27.0", "discord_thread": "https://discord.com/channels/1340492560220684331/1509200002407465001", diff --git a/plugins/multiview/server.py b/plugins/multiview/server.py index 9de0d6d..f70928b 100644 --- a/plugins/multiview/server.py +++ b/plugins/multiview/server.py @@ -384,6 +384,7 @@ def _worker_config(self, tiles, layout, audio_source, settings) -> dict: "bitrate": int(settings.get("output_bitrate") or 8000), "preset": preset, "video_encoder": encoder, + "render_device": settings.get("render_device") or "auto", "background": background, "tiles": tile_cfg, }