@oh-just-another/diagram 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +4 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/oja-diagram.global.js +53 -23
- package/dist/oja-diagram.global.js.map +4 -4
- package/dist/render-worker.js +4 -4
- package/dist/render-worker.js.map +4 -4
- package/package.json +4 -4
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var dM=Object.create;var Ey=Object.defineProperty;var fM=Object.getOwnPropertyDescriptor;var pM=Object.getOwnPropertyNames;var hM=Object.getPrototypeOf,mM=Object.prototype.hasOwnProperty;var Dt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),no=(e,t)=>{for(var n in t)Ey(e,n,{get:t[n],enumerable:!0})},yM=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of pM(t))!mM.call(e,a)&&a!==n&&Ey(e,a,{get:()=>t[a],enumerable:!(o=fM(t,a))||o.enumerable});return e};var F=(e,t,n)=>(n=e!=null?dM(hM(e)):{},yM(t||!e||!e.__esModule?Ey(n,"default",{value:e,enumerable:!0}):n,e));var DL=Dt(Ue=>{"use strict";function Dy(e,t){var n=e.length;e.push(t);e:for(;0<n;){var o=n-1>>>1,a=e[o];if(0<Ip(a,t))e[o]=t,e[n]=a,n=o;else break e}}function vo(e){return e.length===0?null:e[0]}function Mp(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var o=0,a=e.length,r=a>>>1;o<r;){var s=2*(o+1)-1,i=e[s],l=s+1,c=e[l];if(0>Ip(i,n))l<a&&0>Ip(c,i)?(e[o]=c,e[l]=n,o=l):(e[o]=i,e[s]=n,o=s);else if(l<a&&0>Ip(c,n))e[o]=c,e[l]=n,o=l;else break e}}return t}function Ip(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}Ue.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(wL=performance,Ue.unstable_now=function(){return wL.now()}):(My=Date,_L=My.now(),Ue.unstable_now=function(){return My.now()-_L});var wL,My,_L,Xo=[],ja=[],gM=1,wn=null,Pt=3,Py=!1,Pc=!1,Bc=!1,By=!1,IL=typeof setTimeout=="function"?setTimeout:null,EL=typeof clearTimeout=="function"?clearTimeout:null,CL=typeof setImmediate<"u"?setImmediate:null;function Ep(e){for(var t=vo(ja);t!==null;){if(t.callback===null)Mp(ja);else if(t.startTime<=e)Mp(ja),t.sortIndex=t.expirationTime,Dy(Xo,t);else break;t=vo(ja)}}function zy(e){if(Bc=!1,Ep(e),!Pc)if(vo(Xo)!==null)Pc=!0,Mi||(Mi=!0,Ei());else{var t=vo(ja);t!==null&&Ny(zy,t.startTime-e)}}var Mi=!1,zc=-1,ML=5,OL=-1;function RL(){return By?!0:!(Ue.unstable_now()-OL<ML)}function Oy(){if(By=!1,Mi){var e=Ue.unstable_now();OL=e;var t=!0;try{e:{Pc=!1,Bc&&(Bc=!1,EL(zc),zc=-1),Py=!0;var n=Pt;try{t:{for(Ep(e),wn=vo(Xo);wn!==null&&!(wn.expirationTime>e&&RL());){var o=wn.callback;if(typeof o=="function"){wn.callback=null,Pt=wn.priorityLevel;var a=o(wn.expirationTime<=e);if(e=Ue.unstable_now(),typeof a=="function"){wn.callback=a,Ep(e),t=!0;break t}wn===vo(Xo)&&Mp(Xo),Ep(e)}else Mp(Xo);wn=vo(Xo)}if(wn!==null)t=!0;else{var r=vo(ja);r!==null&&Ny(zy,r.startTime-e),t=!1}}break e}finally{wn=null,Pt=n,Py=!1}t=void 0}}finally{t?Ei():Mi=!1}}}var Ei;typeof CL=="function"?Ei=function(){CL(Oy)}:typeof MessageChannel<"u"?(Ry=new MessageChannel,TL=Ry.port2,Ry.port1.onmessage=Oy,Ei=function(){TL.postMessage(null)}):Ei=function(){IL(Oy,0)};var Ry,TL;function Ny(e,t){zc=IL(function(){e(Ue.unstable_now())},t)}Ue.unstable_IdlePriority=5;Ue.unstable_ImmediatePriority=1;Ue.unstable_LowPriority=4;Ue.unstable_NormalPriority=3;Ue.unstable_Profiling=null;Ue.unstable_UserBlockingPriority=2;Ue.unstable_cancelCallback=function(e){e.callback=null};Ue.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ML=0<e?Math.floor(1e3/e):5};Ue.unstable_getCurrentPriorityLevel=function(){return Pt};Ue.unstable_next=function(e){switch(Pt){case 1:case 2:case 3:var t=3;break;default:t=Pt}var n=Pt;Pt=t;try{return e()}finally{Pt=n}};Ue.unstable_requestPaint=function(){By=!0};Ue.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=Pt;Pt=e;try{return t()}finally{Pt=n}};Ue.unstable_scheduleCallback=function(e,t,n){var o=Ue.unstable_now();switch(typeof n=="object"&&n!==null?(n=n.delay,n=typeof n=="number"&&0<n?o+n:o):n=o,e){case 1:var a=-1;break;case 2:a=250;break;case 5:a=1073741823;break;case 4:a=1e4;break;default:a=5e3}return a=n+a,e={id:gM++,callback:t,priorityLevel:e,startTime:n,expirationTime:a,sortIndex:-1},n>o?(e.sortIndex=n,Dy(ja,e),vo(Xo)===null&&e===vo(ja)&&(Bc?(EL(zc),zc=-1):Bc=!0,Ny(zy,n-o))):(e.sortIndex=a,Dy(Xo,e),Pc||Py||(Pc=!0,Mi||(Mi=!0,Ei()))),e};Ue.unstable_shouldYield=RL;Ue.unstable_wrapCallback=function(e){var t=Pt;return function(){var n=Pt;Pt=t;try{return e.apply(this,arguments)}finally{Pt=n}}}});var BL=Dt((Hj,PL)=>{"use strict";PL.exports=DL()});var ZL=Dt(ee=>{"use strict";var Uy=Symbol.for("react.transitional.element"),xM=Symbol.for("react.portal"),bM=Symbol.for("react.fragment"),AM=Symbol.for("react.strict_mode"),vM=Symbol.for("react.profiler"),LM=Symbol.for("react.consumer"),SM=Symbol.for("react.context"),kM=Symbol.for("react.forward_ref"),wM=Symbol.for("react.suspense"),_M=Symbol.for("react.memo"),UL=Symbol.for("react.lazy"),CM=Symbol.for("react.activity"),zL=Symbol.iterator;function TM(e){return e===null||typeof e!="object"?null:(e=zL&&e[zL]||e["@@iterator"],typeof e=="function"?e:null)}var GL={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},qL=Object.assign,WL={};function Ri(e,t,n){this.props=e,this.context=t,this.refs=WL,this.updater=n||GL}Ri.prototype.isReactComponent={};Ri.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};Ri.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function jL(){}jL.prototype=Ri.prototype;function Gy(e,t,n){this.props=e,this.context=t,this.refs=WL,this.updater=n||GL}var qy=Gy.prototype=new jL;qy.constructor=Gy;qL(qy,Ri.prototype);qy.isPureReactComponent=!0;var NL=Array.isArray;function Hy(){}var De={H:null,A:null,T:null,S:null},VL=Object.prototype.hasOwnProperty;function Wy(e,t,n){var o=n.ref;return{$$typeof:Uy,type:e,key:t,ref:o!==void 0?o:null,props:n}}function IM(e,t){return Wy(e.type,t,e.props)}function jy(e){return typeof e=="object"&&e!==null&&e.$$typeof===Uy}function EM(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var FL=/\/+/g;function Fy(e,t){return typeof e=="object"&&e!==null&&e.key!=null?EM(""+e.key):t.toString(36)}function MM(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(Hy,Hy):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function Oi(e,t,n,o,a){var r=typeof e;(r==="undefined"||r==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(r){case"bigint":case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case Uy:case xM:s=!0;break;case UL:return s=e._init,Oi(s(e._payload),t,n,o,a)}}if(s)return a=a(e),s=o===""?"."+Fy(e,0):o,NL(a)?(n="",s!=null&&(n=s.replace(FL,"$&/")+"/"),Oi(a,t,n,"",function(c){return c})):a!=null&&(jy(a)&&(a=IM(a,n+(a.key==null||e&&e.key===a.key?"":(""+a.key).replace(FL,"$&/")+"/")+s)),t.push(a)),1;s=0;var i=o===""?".":o+":";if(NL(e))for(var l=0;l<e.length;l++)o=e[l],r=i+Fy(o,l),s+=Oi(o,t,n,r,a);else if(l=TM(e),typeof l=="function")for(e=l.call(e),l=0;!(o=e.next()).done;)o=o.value,r=i+Fy(o,l++),s+=Oi(o,t,n,r,a);else if(r==="object"){if(typeof e.then=="function")return Oi(MM(e),t,n,o,a);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return s}function Op(e,t,n){if(e==null)return e;var o=[],a=0;return Oi(e,o,"","",function(r){return t.call(n,r,a++)}),o}function OM(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var HL=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},RM={map:Op,forEach:function(e,t,n){Op(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Op(e,function(){t++}),t},toArray:function(e){return Op(e,function(t){return t})||[]},only:function(e){if(!jy(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ee.Activity=CM;ee.Children=RM;ee.Component=Ri;ee.Fragment=bM;ee.Profiler=vM;ee.PureComponent=Gy;ee.StrictMode=AM;ee.Suspense=wM;ee.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=De;ee.__COMPILER_RUNTIME={__proto__:null,c:function(e){return De.H.useMemoCache(e)}};ee.cache=function(e){return function(){return e.apply(null,arguments)}};ee.cacheSignal=function(){return null};ee.cloneElement=function(e,t,n){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var o=qL({},e.props),a=e.key;if(t!=null)for(r in t.key!==void 0&&(a=""+t.key),t)!VL.call(t,r)||r==="key"||r==="__self"||r==="__source"||r==="ref"&&t.ref===void 0||(o[r]=t[r]);var r=arguments.length-2;if(r===1)o.children=n;else if(1<r){for(var s=Array(r),i=0;i<r;i++)s[i]=arguments[i+2];o.children=s}return Wy(e.type,a,o)};ee.createContext=function(e){return e={$$typeof:SM,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:LM,_context:e},e};ee.createElement=function(e,t,n){var o,a={},r=null;if(t!=null)for(o in t.key!==void 0&&(r=""+t.key),t)VL.call(t,o)&&o!=="key"&&o!=="__self"&&o!=="__source"&&(a[o]=t[o]);var s=arguments.length-2;if(s===1)a.children=n;else if(1<s){for(var i=Array(s),l=0;l<s;l++)i[l]=arguments[l+2];a.children=i}if(e&&e.defaultProps)for(o in s=e.defaultProps,s)a[o]===void 0&&(a[o]=s[o]);return Wy(e,r,a)};ee.createRef=function(){return{current:null}};ee.forwardRef=function(e){return{$$typeof:kM,render:e}};ee.isValidElement=jy;ee.lazy=function(e){return{$$typeof:UL,_payload:{_status:-1,_result:e},_init:OM}};ee.memo=function(e,t){return{$$typeof:_M,type:e,compare:t===void 0?null:t}};ee.startTransition=function(e){var t=De.T,n={};De.T=n;try{var o=e(),a=De.S;a!==null&&a(n,o),typeof o=="object"&&o!==null&&typeof o.then=="function"&&o.then(Hy,HL)}catch(r){HL(r)}finally{t!==null&&n.types!==null&&(t.types=n.types),De.T=t}};ee.unstable_useCacheRefresh=function(){return De.H.useCacheRefresh()};ee.use=function(e){return De.H.use(e)};ee.useActionState=function(e,t,n){return De.H.useActionState(e,t,n)};ee.useCallback=function(e,t){return De.H.useCallback(e,t)};ee.useContext=function(e){return De.H.useContext(e)};ee.useDebugValue=function(){};ee.useDeferredValue=function(e,t){return De.H.useDeferredValue(e,t)};ee.useEffect=function(e,t){return De.H.useEffect(e,t)};ee.useEffectEvent=function(e){return De.H.useEffectEvent(e)};ee.useId=function(){return De.H.useId()};ee.useImperativeHandle=function(e,t,n){return De.H.useImperativeHandle(e,t,n)};ee.useInsertionEffect=function(e,t){return De.H.useInsertionEffect(e,t)};ee.useLayoutEffect=function(e,t){return De.H.useLayoutEffect(e,t)};ee.useMemo=function(e,t){return De.H.useMemo(e,t)};ee.useOptimistic=function(e,t){return De.H.useOptimistic(e,t)};ee.useReducer=function(e,t,n){return De.H.useReducer(e,t,n)};ee.useRef=function(e){return De.H.useRef(e)};ee.useState=function(e){return De.H.useState(e)};ee.useSyncExternalStore=function(e,t,n){return De.H.useSyncExternalStore(e,t,n)};ee.useTransition=function(){return De.H.useTransition()};ee.version="19.2.6"});var he=Dt((Gj,XL)=>{"use strict";XL.exports=ZL()});var KL=Dt(Ft=>{"use strict";var DM=he();function YL(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function Va(){}var Nt={d:{f:Va,r:function(){throw Error(YL(522))},D:Va,C:Va,L:Va,m:Va,X:Va,S:Va,M:Va},p:0,findDOMNode:null},PM=Symbol.for("react.portal");function BM(e,t,n){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:PM,key:o==null?null:""+o,children:e,containerInfo:t,implementation:n}}var Nc=DM.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function Rp(e,t){if(e==="font")return"";if(typeof t=="string")return t==="use-credentials"?t:""}Ft.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Nt;Ft.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(YL(299));return BM(e,t,null,n)};Ft.flushSync=function(e){var t=Nc.T,n=Nt.p;try{if(Nc.T=null,Nt.p=2,e)return e()}finally{Nc.T=t,Nt.p=n,Nt.d.f()}};Ft.preconnect=function(e,t){typeof e=="string"&&(t?(t=t.crossOrigin,t=typeof t=="string"?t==="use-credentials"?t:"":void 0):t=null,Nt.d.C(e,t))};Ft.prefetchDNS=function(e){typeof e=="string"&&Nt.d.D(e)};Ft.preinit=function(e,t){if(typeof e=="string"&&t&&typeof t.as=="string"){var n=t.as,o=Rp(n,t.crossOrigin),a=typeof t.integrity=="string"?t.integrity:void 0,r=typeof t.fetchPriority=="string"?t.fetchPriority:void 0;n==="style"?Nt.d.S(e,typeof t.precedence=="string"?t.precedence:void 0,{crossOrigin:o,integrity:a,fetchPriority:r}):n==="script"&&Nt.d.X(e,{crossOrigin:o,integrity:a,fetchPriority:r,nonce:typeof t.nonce=="string"?t.nonce:void 0})}};Ft.preinitModule=function(e,t){if(typeof e=="string")if(typeof t=="object"&&t!==null){if(t.as==null||t.as==="script"){var n=Rp(t.as,t.crossOrigin);Nt.d.M(e,{crossOrigin:n,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0})}}else t==null&&Nt.d.M(e)};Ft.preload=function(e,t){if(typeof e=="string"&&typeof t=="object"&&t!==null&&typeof t.as=="string"){var n=t.as,o=Rp(n,t.crossOrigin);Nt.d.L(e,n,{crossOrigin:o,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0,type:typeof t.type=="string"?t.type:void 0,fetchPriority:typeof t.fetchPriority=="string"?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy=="string"?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet=="string"?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes=="string"?t.imageSizes:void 0,media:typeof t.media=="string"?t.media:void 0})}};Ft.preloadModule=function(e,t){if(typeof e=="string")if(t){var n=Rp(t.as,t.crossOrigin);Nt.d.m(e,{as:typeof t.as=="string"&&t.as!=="script"?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity=="string"?t.integrity:void 0})}else Nt.d.m(e)};Ft.requestFormReset=function(e){Nt.d.r(e)};Ft.unstable_batchedUpdates=function(e,t){return e(t)};Ft.useFormState=function(e,t,n){return Nc.H.useFormState(e,t,n)};Ft.useFormStatus=function(){return Nc.H.useHostTransitionStatus()};Ft.version="19.2.6"});var Yo=Dt((Wj,QL)=>{"use strict";function $L(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE($L)}catch(e){console.error(e)}}$L(),QL.exports=KL()});var u_=Dt(am=>{"use strict";var ut=BL(),k3=he(),zM=Yo();function O(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function w3(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ku(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function _3(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function C3(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function JL(e){if(ku(e)!==e)throw Error(O(188))}function NM(e){var t=e.alternate;if(!t){if(t=ku(e),t===null)throw Error(O(188));return t!==e?null:e}for(var n=e,o=t;;){var a=n.return;if(a===null)break;var r=a.alternate;if(r===null){if(o=a.return,o!==null){n=o;continue}break}if(a.child===r.child){for(r=a.child;r;){if(r===n)return JL(a),e;if(r===o)return JL(a),t;r=r.sibling}throw Error(O(188))}if(n.return!==o.return)n=a,o=r;else{for(var s=!1,i=a.child;i;){if(i===n){s=!0,n=a,o=r;break}if(i===o){s=!0,o=a,n=r;break}i=i.sibling}if(!s){for(i=r.child;i;){if(i===n){s=!0,n=r,o=a;break}if(i===o){s=!0,o=r,n=a;break}i=i.sibling}if(!s)throw Error(O(189))}}if(n.alternate!==o)throw Error(O(190))}if(n.tag!==3)throw Error(O(188));return n.stateNode.current===n?e:t}function T3(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=T3(e),t!==null)return t;e=e.sibling}return null}var ze=Object.assign,FM=Symbol.for("react.element"),Dp=Symbol.for("react.transitional.element"),Vc=Symbol.for("react.portal"),Fi=Symbol.for("react.fragment"),I3=Symbol.for("react.strict_mode"),wg=Symbol.for("react.profiler"),E3=Symbol.for("react.consumer"),oa=Symbol.for("react.context"),Ax=Symbol.for("react.forward_ref"),_g=Symbol.for("react.suspense"),Cg=Symbol.for("react.suspense_list"),vx=Symbol.for("react.memo"),Za=Symbol.for("react.lazy");Symbol.for("react.scope");var Tg=Symbol.for("react.activity");Symbol.for("react.legacy_hidden");Symbol.for("react.tracing_marker");var HM=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var eS=Symbol.iterator;function Fc(e){return e===null||typeof e!="object"?null:(e=eS&&e[eS]||e["@@iterator"],typeof e=="function"?e:null)}var UM=Symbol.for("react.client.reference");function Ig(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===UM?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Fi:return"Fragment";case wg:return"Profiler";case I3:return"StrictMode";case _g:return"Suspense";case Cg:return"SuspenseList";case Tg:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case Vc:return"Portal";case oa:return e.displayName||"Context";case E3:return(e._context.displayName||"Context")+".Consumer";case Ax:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case vx:return t=e.displayName||null,t!==null?t:Ig(e.type)||"Memo";case Za:t=e._payload,e=e._init;try{return Ig(e(t))}catch{}}return null}var Zc=Array.isArray,K=k3.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Le=zM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,cs={pending:!1,data:null,method:null,action:null},Eg=[],Hi=-1;function _o(e){return{current:e}}function At(e){0>Hi||(e.current=Eg[Hi],Eg[Hi]=null,Hi--)}function Me(e,t){Hi++,Eg[Hi]=e.current,e.current=t}var wo=_o(null),uu=_o(null),ar=_o(null),ph=_o(null);function hh(e,t){switch(Me(ar,t),Me(uu,e),Me(wo,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?i3(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=i3(t),e=Kw(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}At(wo),Me(wo,e)}function al(){At(wo),At(uu),At(ar)}function Mg(e){e.memoizedState!==null&&Me(ph,e);var t=wo.current,n=Kw(t,e.type);t!==n&&(Me(uu,e),Me(wo,n))}function mh(e){uu.current===e&&(At(wo),At(uu)),ph.current===e&&(At(ph),vu._currentValue=cs)}var Vy,tS;function rs(e){if(Vy===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Vy=t&&t[1]||"",tS=-1<n.stack.indexOf(`
|
|
1
|
+
var Q6=Object.create;var Kg=Object.defineProperty;var J6=Object.getOwnPropertyDescriptor;var eP=Object.getOwnPropertyNames;var tP=Object.getPrototypeOf,nP=Object.prototype.hasOwnProperty;var Ht=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ho=(e,t)=>{for(var n in t)Kg(e,n,{get:t[n],enumerable:!0})},oP=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of eP(t))!nP.call(e,a)&&a!==n&&Kg(e,a,{get:()=>t[a],enumerable:!(o=J6(t,a))||o.enumerable});return e};var P=(e,t,n)=>(n=e!=null?Q6(tP(e)):{},oP(t||!e||!e.__esModule?Kg(n,"default",{value:e,enumerable:!0}):n,e));var E3=Ht(je=>{"use strict";function ex(e,t){var n=e.length;e.push(t);e:for(;0<n;){var o=n-1>>>1,a=e[o];if(0<Ph(a,t))e[o]=t,e[n]=a,n=o;else break e}}function Do(e){return e.length===0?null:e[0]}function Nh(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var o=0,a=e.length,r=a>>>1;o<r;){var s=2*(o+1)-1,i=e[s],l=s+1,c=e[l];if(0>Ph(i,n))l<a&&0>Ph(c,i)?(e[o]=c,e[l]=n,o=l):(e[o]=i,e[s]=n,o=s);else if(l<a&&0>Ph(c,n))e[o]=c,e[l]=n,o=l;else break e}}return t}function Ph(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}je.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(b3=performance,je.unstable_now=function(){return b3.now()}):($g=Date,A3=$g.now(),je.unstable_now=function(){return $g.now()-A3});var b3,$g,A3,pa=[],fr=[],aP=1,Un=null,Ut=3,tx=!1,gu=!1,xu=!1,nx=!1,L3=typeof setTimeout=="function"?setTimeout:null,k3=typeof clearTimeout=="function"?clearTimeout:null,v3=typeof setImmediate<"u"?setImmediate:null;function Bh(e){for(var t=Do(fr);t!==null;){if(t.callback===null)Nh(fr);else if(t.startTime<=e)Nh(fr),t.sortIndex=t.expirationTime,ex(pa,t);else break;t=Do(fr)}}function ox(e){if(xu=!1,Bh(e),!gu)if(Do(pa)!==null)gu=!0,sl||(sl=!0,rl());else{var t=Do(fr);t!==null&&ax(ox,t.startTime-e)}}var sl=!1,bu=-1,w3=5,_3=-1;function C3(){return nx?!0:!(je.unstable_now()-_3<w3)}function Qg(){if(nx=!1,sl){var e=je.unstable_now();_3=e;var t=!0;try{e:{gu=!1,xu&&(xu=!1,k3(bu),bu=-1),tx=!0;var n=Ut;try{t:{for(Bh(e),Un=Do(pa);Un!==null&&!(Un.expirationTime>e&&C3());){var o=Un.callback;if(typeof o=="function"){Un.callback=null,Ut=Un.priorityLevel;var a=o(Un.expirationTime<=e);if(e=je.unstable_now(),typeof a=="function"){Un.callback=a,Bh(e),t=!0;break t}Un===Do(pa)&&Nh(pa),Bh(e)}else Nh(pa);Un=Do(pa)}if(Un!==null)t=!0;else{var r=Do(fr);r!==null&&ax(ox,r.startTime-e),t=!1}}break e}finally{Un=null,Ut=n,tx=!1}t=void 0}}finally{t?rl():sl=!1}}}var rl;typeof v3=="function"?rl=function(){v3(Qg)}:typeof MessageChannel<"u"?(Jg=new MessageChannel,S3=Jg.port2,Jg.port1.onmessage=Qg,rl=function(){S3.postMessage(null)}):rl=function(){L3(Qg,0)};var Jg,S3;function ax(e,t){bu=L3(function(){e(je.unstable_now())},t)}je.unstable_IdlePriority=5;je.unstable_ImmediatePriority=1;je.unstable_LowPriority=4;je.unstable_NormalPriority=3;je.unstable_Profiling=null;je.unstable_UserBlockingPriority=2;je.unstable_cancelCallback=function(e){e.callback=null};je.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):w3=0<e?Math.floor(1e3/e):5};je.unstable_getCurrentPriorityLevel=function(){return Ut};je.unstable_next=function(e){switch(Ut){case 1:case 2:case 3:var t=3;break;default:t=Ut}var n=Ut;Ut=t;try{return e()}finally{Ut=n}};je.unstable_requestPaint=function(){nx=!0};je.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=Ut;Ut=e;try{return t()}finally{Ut=n}};je.unstable_scheduleCallback=function(e,t,n){var o=je.unstable_now();switch(typeof n=="object"&&n!==null?(n=n.delay,n=typeof n=="number"&&0<n?o+n:o):n=o,e){case 1:var a=-1;break;case 2:a=250;break;case 5:a=1073741823;break;case 4:a=1e4;break;default:a=5e3}return a=n+a,e={id:aP++,callback:t,priorityLevel:e,startTime:n,expirationTime:a,sortIndex:-1},n>o?(e.sortIndex=n,ex(fr,e),Do(pa)===null&&e===Do(fr)&&(xu?(k3(bu),bu=-1):xu=!0,ax(ox,n-o))):(e.sortIndex=a,ex(pa,e),gu||tx||(gu=!0,sl||(sl=!0,rl()))),e};je.unstable_shouldYield=C3;je.unstable_wrapCallback=function(e){var t=Ut;return function(){var n=Ut;Ut=t;try{return e.apply(this,arguments)}finally{Ut=n}}}});var I3=Ht((f$,T3)=>{"use strict";T3.exports=E3()});var U3=Ht(te=>{"use strict";var ix=Symbol.for("react.transitional.element"),rP=Symbol.for("react.portal"),sP=Symbol.for("react.fragment"),iP=Symbol.for("react.strict_mode"),lP=Symbol.for("react.profiler"),cP=Symbol.for("react.consumer"),uP=Symbol.for("react.context"),dP=Symbol.for("react.forward_ref"),fP=Symbol.for("react.suspense"),pP=Symbol.for("react.memo"),P3=Symbol.for("react.lazy"),hP=Symbol.for("react.activity"),M3=Symbol.iterator;function mP(e){return e===null||typeof e!="object"?null:(e=M3&&e[M3]||e["@@iterator"],typeof e=="function"?e:null)}var B3={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N3=Object.assign,z3={};function ll(e,t,n){this.props=e,this.context=t,this.refs=z3,this.updater=n||B3}ll.prototype.isReactComponent={};ll.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};ll.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function F3(){}F3.prototype=ll.prototype;function lx(e,t,n){this.props=e,this.context=t,this.refs=z3,this.updater=n||B3}var cx=lx.prototype=new F3;cx.constructor=lx;N3(cx,ll.prototype);cx.isPureReactComponent=!0;var R3=Array.isArray;function sx(){}var Ue={H:null,A:null,T:null,S:null},H3=Object.prototype.hasOwnProperty;function ux(e,t,n){var o=n.ref;return{$$typeof:ix,type:e,key:t,ref:o!==void 0?o:null,props:n}}function yP(e,t){return ux(e.type,t,e.props)}function dx(e){return typeof e=="object"&&e!==null&&e.$$typeof===ix}function gP(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var O3=/\/+/g;function rx(e,t){return typeof e=="object"&&e!==null&&e.key!=null?gP(""+e.key):t.toString(36)}function xP(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(sx,sx):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function il(e,t,n,o,a){var r=typeof e;(r==="undefined"||r==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(r){case"bigint":case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case ix:case rP:s=!0;break;case P3:return s=e._init,il(s(e._payload),t,n,o,a)}}if(s)return a=a(e),s=o===""?"."+rx(e,0):o,R3(a)?(n="",s!=null&&(n=s.replace(O3,"$&/")+"/"),il(a,t,n,"",function(c){return c})):a!=null&&(dx(a)&&(a=yP(a,n+(a.key==null||e&&e.key===a.key?"":(""+a.key).replace(O3,"$&/")+"/")+s)),t.push(a)),1;s=0;var i=o===""?".":o+":";if(R3(e))for(var l=0;l<e.length;l++)o=e[l],r=i+rx(o,l),s+=il(o,t,n,r,a);else if(l=mP(e),typeof l=="function")for(e=l.call(e),l=0;!(o=e.next()).done;)o=o.value,r=i+rx(o,l++),s+=il(o,t,n,r,a);else if(r==="object"){if(typeof e.then=="function")return il(xP(e),t,n,o,a);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return s}function zh(e,t,n){if(e==null)return e;var o=[],a=0;return il(e,o,"","",function(r){return t.call(n,r,a++)}),o}function bP(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var D3=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},AP={map:zh,forEach:function(e,t,n){zh(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return zh(e,function(){t++}),t},toArray:function(e){return zh(e,function(t){return t})||[]},only:function(e){if(!dx(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};te.Activity=hP;te.Children=AP;te.Component=ll;te.Fragment=sP;te.Profiler=lP;te.PureComponent=lx;te.StrictMode=iP;te.Suspense=fP;te.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Ue;te.__COMPILER_RUNTIME={__proto__:null,c:function(e){return Ue.H.useMemoCache(e)}};te.cache=function(e){return function(){return e.apply(null,arguments)}};te.cacheSignal=function(){return null};te.cloneElement=function(e,t,n){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var o=N3({},e.props),a=e.key;if(t!=null)for(r in t.key!==void 0&&(a=""+t.key),t)!H3.call(t,r)||r==="key"||r==="__self"||r==="__source"||r==="ref"&&t.ref===void 0||(o[r]=t[r]);var r=arguments.length-2;if(r===1)o.children=n;else if(1<r){for(var s=Array(r),i=0;i<r;i++)s[i]=arguments[i+2];o.children=s}return ux(e.type,a,o)};te.createContext=function(e){return e={$$typeof:uP,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:cP,_context:e},e};te.createElement=function(e,t,n){var o,a={},r=null;if(t!=null)for(o in t.key!==void 0&&(r=""+t.key),t)H3.call(t,o)&&o!=="key"&&o!=="__self"&&o!=="__source"&&(a[o]=t[o]);var s=arguments.length-2;if(s===1)a.children=n;else if(1<s){for(var i=Array(s),l=0;l<s;l++)i[l]=arguments[l+2];a.children=i}if(e&&e.defaultProps)for(o in s=e.defaultProps,s)a[o]===void 0&&(a[o]=s[o]);return ux(e,r,a)};te.createRef=function(){return{current:null}};te.forwardRef=function(e){return{$$typeof:dP,render:e}};te.isValidElement=dx;te.lazy=function(e){return{$$typeof:P3,_payload:{_status:-1,_result:e},_init:bP}};te.memo=function(e,t){return{$$typeof:pP,type:e,compare:t===void 0?null:t}};te.startTransition=function(e){var t=Ue.T,n={};Ue.T=n;try{var o=e(),a=Ue.S;a!==null&&a(n,o),typeof o=="object"&&o!==null&&typeof o.then=="function"&&o.then(sx,D3)}catch(r){D3(r)}finally{t!==null&&n.types!==null&&(t.types=n.types),Ue.T=t}};te.unstable_useCacheRefresh=function(){return Ue.H.useCacheRefresh()};te.use=function(e){return Ue.H.use(e)};te.useActionState=function(e,t,n){return Ue.H.useActionState(e,t,n)};te.useCallback=function(e,t){return Ue.H.useCallback(e,t)};te.useContext=function(e){return Ue.H.useContext(e)};te.useDebugValue=function(){};te.useDeferredValue=function(e,t){return Ue.H.useDeferredValue(e,t)};te.useEffect=function(e,t){return Ue.H.useEffect(e,t)};te.useEffectEvent=function(e){return Ue.H.useEffectEvent(e)};te.useId=function(){return Ue.H.useId()};te.useImperativeHandle=function(e,t,n){return Ue.H.useImperativeHandle(e,t,n)};te.useInsertionEffect=function(e,t){return Ue.H.useInsertionEffect(e,t)};te.useLayoutEffect=function(e,t){return Ue.H.useLayoutEffect(e,t)};te.useMemo=function(e,t){return Ue.H.useMemo(e,t)};te.useOptimistic=function(e,t){return Ue.H.useOptimistic(e,t)};te.useReducer=function(e,t,n){return Ue.H.useReducer(e,t,n)};te.useRef=function(e){return Ue.H.useRef(e)};te.useState=function(e){return Ue.H.useState(e)};te.useSyncExternalStore=function(e,t,n){return Ue.H.useSyncExternalStore(e,t,n)};te.useTransition=function(){return Ue.H.useTransition()};te.version="19.2.6"});var re=Ht((h$,G3)=>{"use strict";G3.exports=U3()});var q3=Ht(Vt=>{"use strict";var vP=re();function W3(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function pr(){}var jt={d:{f:pr,r:function(){throw Error(W3(522))},D:pr,C:pr,L:pr,m:pr,X:pr,S:pr,M:pr},p:0,findDOMNode:null},SP=Symbol.for("react.portal");function LP(e,t,n){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:SP,key:o==null?null:""+o,children:e,containerInfo:t,implementation:n}}var Au=vP.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function Fh(e,t){if(e==="font")return"";if(typeof t=="string")return t==="use-credentials"?t:""}Vt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=jt;Vt.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(W3(299));return LP(e,t,null,n)};Vt.flushSync=function(e){var t=Au.T,n=jt.p;try{if(Au.T=null,jt.p=2,e)return e()}finally{Au.T=t,jt.p=n,jt.d.f()}};Vt.preconnect=function(e,t){typeof e=="string"&&(t?(t=t.crossOrigin,t=typeof t=="string"?t==="use-credentials"?t:"":void 0):t=null,jt.d.C(e,t))};Vt.prefetchDNS=function(e){typeof e=="string"&&jt.d.D(e)};Vt.preinit=function(e,t){if(typeof e=="string"&&t&&typeof t.as=="string"){var n=t.as,o=Fh(n,t.crossOrigin),a=typeof t.integrity=="string"?t.integrity:void 0,r=typeof t.fetchPriority=="string"?t.fetchPriority:void 0;n==="style"?jt.d.S(e,typeof t.precedence=="string"?t.precedence:void 0,{crossOrigin:o,integrity:a,fetchPriority:r}):n==="script"&&jt.d.X(e,{crossOrigin:o,integrity:a,fetchPriority:r,nonce:typeof t.nonce=="string"?t.nonce:void 0})}};Vt.preinitModule=function(e,t){if(typeof e=="string")if(typeof t=="object"&&t!==null){if(t.as==null||t.as==="script"){var n=Fh(t.as,t.crossOrigin);jt.d.M(e,{crossOrigin:n,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0})}}else t==null&&jt.d.M(e)};Vt.preload=function(e,t){if(typeof e=="string"&&typeof t=="object"&&t!==null&&typeof t.as=="string"){var n=t.as,o=Fh(n,t.crossOrigin);jt.d.L(e,n,{crossOrigin:o,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0,type:typeof t.type=="string"?t.type:void 0,fetchPriority:typeof t.fetchPriority=="string"?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy=="string"?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet=="string"?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes=="string"?t.imageSizes:void 0,media:typeof t.media=="string"?t.media:void 0})}};Vt.preloadModule=function(e,t){if(typeof e=="string")if(t){var n=Fh(t.as,t.crossOrigin);jt.d.m(e,{as:typeof t.as=="string"&&t.as!=="script"?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity=="string"?t.integrity:void 0})}else jt.d.m(e)};Vt.requestFormReset=function(e){jt.d.r(e)};Vt.unstable_batchedUpdates=function(e,t){return e(t)};Vt.useFormState=function(e,t,n){return Au.H.useFormState(e,t,n)};Vt.useFormStatus=function(){return Au.H.useHostTransitionStatus()};Vt.version="19.2.6"});var ha=Ht((y$,V3)=>{"use strict";function j3(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(j3)}catch(e){console.error(e)}}j3(),V3.exports=q3()});var aE=Ht(u0=>{"use strict";var ht=I3(),xw=re(),kP=ha();function O(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function bw(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function sd(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Aw(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function vw(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Z3(e){if(sd(e)!==e)throw Error(O(188))}function wP(e){var t=e.alternate;if(!t){if(t=sd(e),t===null)throw Error(O(188));return t!==e?null:e}for(var n=e,o=t;;){var a=n.return;if(a===null)break;var r=a.alternate;if(r===null){if(o=a.return,o!==null){n=o;continue}break}if(a.child===r.child){for(r=a.child;r;){if(r===n)return Z3(a),e;if(r===o)return Z3(a),t;r=r.sibling}throw Error(O(188))}if(n.return!==o.return)n=a,o=r;else{for(var s=!1,i=a.child;i;){if(i===n){s=!0,n=a,o=r;break}if(i===o){s=!0,o=a,n=r;break}i=i.sibling}if(!s){for(i=r.child;i;){if(i===n){s=!0,n=r,o=a;break}if(i===o){s=!0,o=r,n=a;break}i=i.sibling}if(!s)throw Error(O(189))}}if(n.alternate!==o)throw Error(O(190))}if(n.tag!==3)throw Error(O(188));return n.stateNode.current===n?e:t}function Sw(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=Sw(e),t!==null)return t;e=e.sibling}return null}var qe=Object.assign,_P=Symbol.for("react.element"),Hh=Symbol.for("react.transitional.element"),Eu=Symbol.for("react.portal"),hl=Symbol.for("react.fragment"),Lw=Symbol.for("react.strict_mode"),jx=Symbol.for("react.profiler"),kw=Symbol.for("react.consumer"),Sa=Symbol.for("react.context"),H1=Symbol.for("react.forward_ref"),Vx=Symbol.for("react.suspense"),Zx=Symbol.for("react.suspense_list"),U1=Symbol.for("react.memo"),hr=Symbol.for("react.lazy");Symbol.for("react.scope");var Xx=Symbol.for("react.activity");Symbol.for("react.legacy_hidden");Symbol.for("react.tracing_marker");var CP=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var X3=Symbol.iterator;function vu(e){return e===null||typeof e!="object"?null:(e=X3&&e[X3]||e["@@iterator"],typeof e=="function"?e:null)}var EP=Symbol.for("react.client.reference");function Yx(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===EP?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case hl:return"Fragment";case jx:return"Profiler";case Lw:return"StrictMode";case Vx:return"Suspense";case Zx:return"SuspenseList";case Xx:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case Eu:return"Portal";case Sa:return e.displayName||"Context";case kw:return(e._context.displayName||"Context")+".Consumer";case H1:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case U1:return t=e.displayName||null,t!==null?t:Yx(e.type)||"Memo";case hr:t=e._payload,e=e._init;try{return Yx(e(t))}catch{}}return null}var Tu=Array.isArray,K=xw.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,we=kP.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Os={pending:!1,data:null,method:null,action:null},Kx=[],ml=-1;function Fo(e){return{current:e}}function kt(e){0>ml||(e.current=Kx[ml],Kx[ml]=null,ml--)}function Ne(e,t){ml++,Kx[ml]=e.current,e.current=t}var zo=Fo(null),Vu=Fo(null),wr=Fo(null),bm=Fo(null);function Am(e,t){switch(Ne(wr,t),Ne(Vu,e),Ne(zo,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?tw(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=tw(t),e=qC(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}kt(zo),Ne(zo,e)}function Ol(){kt(zo),kt(Vu),kt(wr)}function $x(e){e.memoizedState!==null&&Ne(bm,e);var t=zo.current,n=qC(t,e.type);t!==n&&(Ne(Vu,e),Ne(zo,n))}function vm(e){Vu.current===e&&(kt(zo),kt(Vu)),bm.current===e&&(kt(bm),od._currentValue=Os)}var fx,Y3;function Ts(e){if(fx===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);fx=t&&t[1]||"",Y3=-1<n.stack.indexOf(`
|
|
2
2
|
at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
-
`+
|
|
3
|
+
`+fx+e+Y3}var px=!1;function hx(e,t){if(!e||px)return"";px=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(t){var d=function(){throw Error()};if(Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(p){var f=p}Reflect.construct(e,[],d)}else{try{d.call()}catch(p){f=p}e.call(d.prototype)}}else{try{throw Error()}catch(p){f=p}(d=e())&&typeof d.catch=="function"&&d.catch(function(){})}}catch(p){if(p&&f&&typeof p.stack=="string")return[p.stack,f.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var r=o.DetermineComponentFrameRoot(),s=r[0],i=r[1];if(s&&i){var l=s.split(`
|
|
4
4
|
`),c=i.split(`
|
|
5
5
|
`);for(a=o=0;o<l.length&&!l[o].includes("DetermineComponentFrameRoot");)o++;for(;a<c.length&&!c[a].includes("DetermineComponentFrameRoot");)a++;if(o===l.length||a===c.length)for(o=l.length-1,a=c.length-1;1<=o&&0<=a&&l[o]!==c[a];)a--;for(;1<=o&&0<=a;o--,a--)if(l[o]!==c[a]){if(o!==1||a!==1)do if(o--,a--,0>a||l[o]!==c[a]){var u=`
|
|
6
|
-
`+l[o].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{
|
|
6
|
+
`+l[o].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{px=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?Ts(n):""}function TP(e,t){switch(e.tag){case 26:case 27:case 5:return Ts(e.type);case 16:return Ts("Lazy");case 13:return e.child!==t&&t!==null?Ts("Suspense Fallback"):Ts("Suspense");case 19:return Ts("SuspenseList");case 0:case 15:return hx(e.type,!1);case 11:return hx(e.type.render,!1);case 1:return hx(e.type,!0);case 31:return Ts("Activity");default:return""}}function K3(e){try{var t="",n=null;do t+=TP(e,n),n=e,e=e.return;while(e);return t}catch(o){return`
|
|
7
7
|
Error generating stack: `+o.message+`
|
|
8
|
-
`+o.stack}}var Og=Object.prototype.hasOwnProperty,Lx=ut.unstable_scheduleCallback,Yy=ut.unstable_cancelCallback,qM=ut.unstable_shouldYield,WM=ut.unstable_requestPaint,dn=ut.unstable_now,jM=ut.unstable_getCurrentPriorityLevel,M3=ut.unstable_ImmediatePriority,O3=ut.unstable_UserBlockingPriority,yh=ut.unstable_NormalPriority,VM=ut.unstable_LowPriority,R3=ut.unstable_IdlePriority,ZM=ut.log,XM=ut.unstable_setDisableYieldValue,wu=null,fn=null;function Ja(e){if(typeof ZM=="function"&&XM(e),fn&&typeof fn.setStrictMode=="function")try{fn.setStrictMode(wu,e)}catch{}}var pn=Math.clz32?Math.clz32:$M,YM=Math.log,KM=Math.LN2;function $M(e){return e>>>=0,e===0?32:31-(YM(e)/KM|0)|0}var Pp=256,Bp=262144,zp=4194304;function ss(e){var t=e&42;if(t!==0)return t;switch(e&-e){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 e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Gh(e,t,n){var o=e.pendingLanes;if(o===0)return 0;var a=0,r=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var i=o&134217727;return i!==0?(o=i&~r,o!==0?a=ss(o):(s&=i,s!==0?a=ss(s):n||(n=i&~e,n!==0&&(a=ss(n))))):(i=o&~r,i!==0?a=ss(i):s!==0?a=ss(s):n||(n=o&~e,n!==0&&(a=ss(n)))),a===0?0:t!==0&&t!==a&&(t&r)===0&&(r=a&-a,n=t&-t,r>=n||r===32&&(n&4194048)!==0)?t:a}function _u(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function QM(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+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 D3(){var e=zp;return zp<<=1,(zp&62914560)===0&&(zp=4194304),e}function Ky(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Cu(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function JM(e,t,n,o,a,r){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var i=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=s&~n;0<n;){var u=31-pn(n),d=1<<u;i[u]=0,l[u]=-1;var f=c[u];if(f!==null)for(c[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}o!==0&&P3(e,o,0),r!==0&&a===0&&e.tag!==0&&(e.suspendedLanes|=r&~(s&~t))}function P3(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-pn(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|n&261930}function B3(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var o=31-pn(n),a=1<<o;a&t|e[o]&t&&(e[o]|=t),n&=~a}}function z3(e,t){var n=t&-t;return n=(n&42)!==0?1:Sx(n),(n&(e.suspendedLanes|t))!==0?0:n}function Sx(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function kx(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function N3(){var e=Le.p;return e!==0?e:(e=window.event,e===void 0?32:i_(e.type))}function oS(e,t){var n=Le.p;try{return Le.p=e,t()}finally{Le.p=n}}var gr=Math.random().toString(36).slice(2),_t="__reactFiber$"+gr,Yt="__reactProps$"+gr,ml="__reactContainer$"+gr,Rg="__reactEvents$"+gr,eO="__reactListeners$"+gr,tO="__reactHandles$"+gr,aS="__reactResources$"+gr,Tu="__reactMarker$"+gr;function wx(e){delete e[_t],delete e[Yt],delete e[Rg],delete e[eO],delete e[tO]}function Ui(e){var t=e[_t];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ml]||n[_t]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=f3(e);e!==null;){if(n=e[_t])return n;e=f3(e)}return t}e=n,n=e.parentNode}return null}function yl(e){if(e=e[_t]||e[ml]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Xc(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(O(33))}function $i(e){var t=e[aS];return t||(t=e[aS]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function bt(e){e[Tu]=!0}var F3=new Set,H3={};function bs(e,t){rl(e,t),rl(e+"Capture",t)}function rl(e,t){for(H3[e]=t,e=0;e<t.length;e++)F3.add(t[e])}var nO=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),rS={},sS={};function oO(e){return Og.call(sS,e)?!0:Og.call(rS,e)?!1:nO.test(e)?sS[e]=!0:(rS[e]=!0,!1)}function Qp(e,t,n){if(oO(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var o=t.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function Np(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function Ko(e,t,n,o){if(o===null)e.removeAttribute(n);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+o)}}function Cn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function U3(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function aO(e,t,n){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var a=o.get,r=o.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(s){n=""+s,r.call(this,s)}}),Object.defineProperty(e,t,{enumerable:o.enumerable}),{getValue:function(){return n},setValue:function(s){n=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Dg(e){if(!e._valueTracker){var t=U3(e)?"checked":"value";e._valueTracker=aO(e,t,""+e[t])}}function G3(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),o="";return e&&(o=U3(e)?e.checked?"true":"false":e.value),e=o,e!==n?(t.setValue(e),!0):!1}function gh(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var rO=/[\n"\\]/g;function En(e){return e.replace(rO,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Pg(e,t,n,o,a,r,s,i){e.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.type=s:e.removeAttribute("type"),t!=null?s==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Cn(t)):e.value!==""+Cn(t)&&(e.value=""+Cn(t)):s!=="submit"&&s!=="reset"||e.removeAttribute("value"),t!=null?Bg(e,s,Cn(t)):n!=null?Bg(e,s,Cn(n)):o!=null&&e.removeAttribute("value"),a==null&&r!=null&&(e.defaultChecked=!!r),a!=null&&(e.checked=a&&typeof a!="function"&&typeof a!="symbol"),i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"?e.name=""+Cn(i):e.removeAttribute("name")}function q3(e,t,n,o,a,r,s,i){if(r!=null&&typeof r!="function"&&typeof r!="symbol"&&typeof r!="boolean"&&(e.type=r),t!=null||n!=null){if(!(r!=="submit"&&r!=="reset"||t!=null)){Dg(e);return}n=n!=null?""+Cn(n):"",t=t!=null?""+Cn(t):n,i||t===e.value||(e.value=t),e.defaultValue=t}o=o??a,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=i?e.checked:!!o,e.defaultChecked=!!o,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(e.name=s),Dg(e)}function Bg(e,t,n){t==="number"&&gh(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function Qi(e,t,n,o){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&o&&(e[n].defaultSelected=!0)}else{for(n=""+Cn(n),t=null,a=0;a<e.length;a++){if(e[a].value===n){e[a].selected=!0,o&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function W3(e,t,n){if(t!=null&&(t=""+Cn(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+Cn(n):""}function j3(e,t,n,o){if(t==null){if(o!=null){if(n!=null)throw Error(O(92));if(Zc(o)){if(1<o.length)throw Error(O(93));o=o[0]}n=o}n==null&&(n=""),t=n}n=Cn(t),e.defaultValue=n,o=e.textContent,o===n&&o!==""&&o!==null&&(e.value=o),Dg(e)}function sl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var sO=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function iS(e,t,n){var o=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?o?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":o?e.setProperty(t,n):typeof n!="number"||n===0||sO.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function V3(e,t,n){if(t!=null&&typeof t!="object")throw Error(O(62));if(e=e.style,n!=null){for(var o in n)!n.hasOwnProperty(o)||t!=null&&t.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var a in t)o=t[a],t.hasOwnProperty(a)&&n[a]!==o&&iS(e,a,o)}else for(var r in t)t.hasOwnProperty(r)&&iS(e,r,t[r])}function _x(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var iO=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),lO=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Jp(e){return lO.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function aa(){}var zg=null;function Cx(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Gi=null,Ji=null;function lS(e){var t=yl(e);if(t&&(e=t.stateNode)){var n=e[Yt]||null;e:switch(e=t.stateNode,t.type){case"input":if(Pg(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+En(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var o=n[t];if(o!==e&&o.form===e.form){var a=o[Yt]||null;if(!a)throw Error(O(90));Pg(o,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)o=n[t],o.form===e.form&&G3(o)}break e;case"textarea":W3(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&Qi(e,!!n.multiple,t,!1)}}}var $y=!1;function Z3(e,t,n){if($y)return e(t,n);$y=!0;try{var o=e(t);return o}finally{if($y=!1,(Gi!==null||Ji!==null)&&(em(),Gi&&(t=Gi,e=Ji,Ji=Gi=null,lS(t),e)))for(t=0;t<e.length;t++)lS(e[t])}}function du(e,t){var n=e.stateNode;if(n===null)return null;var o=n[Yt]||null;if(o===null)return null;n=o[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(O(231,t,typeof n));return n}var ca=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ng=!1;if(ca)try{Di={},Object.defineProperty(Di,"passive",{get:function(){Ng=!0}}),window.addEventListener("test",Di,Di),window.removeEventListener("test",Di,Di)}catch{Ng=!1}var Di,er=null,Tx=null,eh=null;function X3(){if(eh)return eh;var e,t=Tx,n=t.length,o,a="value"in er?er.value:er.textContent,r=a.length;for(e=0;e<n&&t[e]===a[e];e++);var s=n-e;for(o=1;o<=s&&t[n-o]===a[r-o];o++);return eh=a.slice(e,1<o?1-o:void 0)}function th(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Fp(){return!0}function cS(){return!1}function Kt(e){function t(n,o,a,r,s){this._reactName=n,this._targetInst=a,this.type=o,this.nativeEvent=r,this.target=s,this.currentTarget=null;for(var i in e)e.hasOwnProperty(i)&&(n=e[i],this[i]=n?n(r):r[i]);return this.isDefaultPrevented=(r.defaultPrevented!=null?r.defaultPrevented:r.returnValue===!1)?Fp:cS,this.isPropagationStopped=cS,this}return ze(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Fp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Fp)},persist:function(){},isPersistent:Fp}),t}var As={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qh=Kt(As),Iu=ze({},As,{view:0,detail:0}),cO=Kt(Iu),Qy,Jy,Hc,Wh=ze({},Iu,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ix,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Hc&&(Hc&&e.type==="mousemove"?(Qy=e.screenX-Hc.screenX,Jy=e.screenY-Hc.screenY):Jy=Qy=0,Hc=e),Qy)},movementY:function(e){return"movementY"in e?e.movementY:Jy}}),uS=Kt(Wh),uO=ze({},Wh,{dataTransfer:0}),dO=Kt(uO),fO=ze({},Iu,{relatedTarget:0}),eg=Kt(fO),pO=ze({},As,{animationName:0,elapsedTime:0,pseudoElement:0}),hO=Kt(pO),mO=ze({},As,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),yO=Kt(mO),gO=ze({},As,{data:0}),dS=Kt(gO),xO={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},bO={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},AO={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vO(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=AO[e])?!!t[e]:!1}function Ix(){return vO}var LO=ze({},Iu,{key:function(e){if(e.key){var t=xO[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=th(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?bO[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ix,charCode:function(e){return e.type==="keypress"?th(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?th(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),SO=Kt(LO),kO=ze({},Wh,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),fS=Kt(kO),wO=ze({},Iu,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ix}),_O=Kt(wO),CO=ze({},As,{propertyName:0,elapsedTime:0,pseudoElement:0}),TO=Kt(CO),IO=ze({},Wh,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),EO=Kt(IO),MO=ze({},As,{newState:0,oldState:0}),OO=Kt(MO),RO=[9,13,27,32],Ex=ca&&"CompositionEvent"in window,$c=null;ca&&"documentMode"in document&&($c=document.documentMode);var DO=ca&&"TextEvent"in window&&!$c,Y3=ca&&(!Ex||$c&&8<$c&&11>=$c),pS=" ",hS=!1;function K3(e,t){switch(e){case"keyup":return RO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $3(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var qi=!1;function PO(e,t){switch(e){case"compositionend":return $3(t);case"keypress":return t.which!==32?null:(hS=!0,pS);case"textInput":return e=t.data,e===pS&&hS?null:e;default:return null}}function BO(e,t){if(qi)return e==="compositionend"||!Ex&&K3(e,t)?(e=X3(),eh=Tx=er=null,qi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Y3&&t.locale!=="ko"?null:t.data;default:return null}}var zO={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function mS(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!zO[e.type]:t==="textarea"}function Q3(e,t,n,o){Gi?Ji?Ji.push(o):Ji=[o]:Gi=o,t=Ph(t,"onChange"),0<t.length&&(n=new qh("onChange","change",null,n,o),e.push({event:n,listeners:t}))}var Qc=null,fu=null;function NO(e){Zw(e,0)}function jh(e){var t=Xc(e);if(G3(t))return e}function yS(e,t){if(e==="change")return t}var J3=!1;ca&&(ca?(Up="oninput"in document,Up||(tg=document.createElement("div"),tg.setAttribute("oninput","return;"),Up=typeof tg.oninput=="function"),Hp=Up):Hp=!1,J3=Hp&&(!document.documentMode||9<document.documentMode));var Hp,Up,tg;function gS(){Qc&&(Qc.detachEvent("onpropertychange",ek),fu=Qc=null)}function ek(e){if(e.propertyName==="value"&&jh(fu)){var t=[];Q3(t,fu,e,Cx(e)),Z3(NO,t)}}function FO(e,t,n){e==="focusin"?(gS(),Qc=t,fu=n,Qc.attachEvent("onpropertychange",ek)):e==="focusout"&&gS()}function HO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return jh(fu)}function UO(e,t){if(e==="click")return jh(t)}function GO(e,t){if(e==="input"||e==="change")return jh(t)}function qO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var mn=typeof Object.is=="function"?Object.is:qO;function pu(e,t){if(mn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(o=0;o<n.length;o++){var a=n[o];if(!Og.call(t,a)||!mn(e[a],t[a]))return!1}return!0}function xS(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function bS(e,t){var n=xS(e);e=0;for(var o;n;){if(n.nodeType===3){if(o=e+n.textContent.length,e<=t&&o>=t)return{node:n,offset:t-e};e=o}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=xS(n)}}function tk(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?tk(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function nk(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=gh(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=gh(e.document)}return t}function Mx(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var WO=ca&&"documentMode"in document&&11>=document.documentMode,Wi=null,Fg=null,Jc=null,Hg=!1;function AS(e,t,n){var o=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Hg||Wi==null||Wi!==gh(o)||(o=Wi,"selectionStart"in o&&Mx(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),Jc&&pu(Jc,o)||(Jc=o,o=Ph(Fg,"onSelect"),0<o.length&&(t=new qh("onSelect","select",null,t,n),e.push({event:t,listeners:o}),t.target=Wi)))}function as(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ji={animationend:as("Animation","AnimationEnd"),animationiteration:as("Animation","AnimationIteration"),animationstart:as("Animation","AnimationStart"),transitionrun:as("Transition","TransitionRun"),transitionstart:as("Transition","TransitionStart"),transitioncancel:as("Transition","TransitionCancel"),transitionend:as("Transition","TransitionEnd")},ng={},ok={};ca&&(ok=document.createElement("div").style,"AnimationEvent"in window||(delete ji.animationend.animation,delete ji.animationiteration.animation,delete ji.animationstart.animation),"TransitionEvent"in window||delete ji.transitionend.transition);function vs(e){if(ng[e])return ng[e];if(!ji[e])return e;var t=ji[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in ok)return ng[e]=t[n];return e}var ak=vs("animationend"),rk=vs("animationiteration"),sk=vs("animationstart"),jO=vs("transitionrun"),VO=vs("transitionstart"),ZO=vs("transitioncancel"),ik=vs("transitionend"),lk=new Map,Ug="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Ug.push("scrollEnd");function ro(e,t){lk.set(e,t),bs(t,[e])}var xh=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},_n=[],Vi=0,Ox=0;function Vh(){for(var e=Vi,t=Ox=Vi=0;t<e;){var n=_n[t];_n[t++]=null;var o=_n[t];_n[t++]=null;var a=_n[t];_n[t++]=null;var r=_n[t];if(_n[t++]=null,o!==null&&a!==null){var s=o.pending;s===null?a.next=a:(a.next=s.next,s.next=a),o.pending=a}r!==0&&ck(n,a,r)}}function Zh(e,t,n,o){_n[Vi++]=e,_n[Vi++]=t,_n[Vi++]=n,_n[Vi++]=o,Ox|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function Rx(e,t,n,o){return Zh(e,t,n,o),bh(e)}function Ls(e,t){return Zh(e,null,null,t),bh(e)}function ck(e,t,n){e.lanes|=n;var o=e.alternate;o!==null&&(o.lanes|=n);for(var a=!1,r=e.return;r!==null;)r.childLanes|=n,o=r.alternate,o!==null&&(o.childLanes|=n),r.tag===22&&(e=r.stateNode,e===null||e._visibility&1||(a=!0)),e=r,r=r.return;return e.tag===3?(r=e.stateNode,a&&t!==null&&(a=31-pn(n),e=r.hiddenUpdates,o=e[a],o===null?e[a]=[t]:o.push(t),t.lane=n|536870912),r):null}function bh(e){if(50<lu)throw lu=0,lx=null,Error(O(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Zi={};function XO(e,t,n,o){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function cn(e,t,n,o){return new XO(e,t,n,o)}function Dx(e){return e=e.prototype,!(!e||!e.isReactComponent)}function sa(e,t){var n=e.alternate;return n===null?(n=cn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function uk(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function nh(e,t,n,o,a,r){var s=0;if(o=e,typeof e=="function")Dx(e)&&(s=1);else if(typeof e=="string")s=$R(e,n,wo.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case Tg:return e=cn(31,n,t,a),e.elementType=Tg,e.lanes=r,e;case Fi:return us(n.children,a,r,t);case I3:s=8,a|=24;break;case wg:return e=cn(12,n,t,a|2),e.elementType=wg,e.lanes=r,e;case _g:return e=cn(13,n,t,a),e.elementType=_g,e.lanes=r,e;case Cg:return e=cn(19,n,t,a),e.elementType=Cg,e.lanes=r,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case oa:s=10;break e;case E3:s=9;break e;case Ax:s=11;break e;case vx:s=14;break e;case Za:s=16,o=null;break e}s=29,n=Error(O(130,e===null?"null":typeof e,"")),o=null}return t=cn(s,n,t,a),t.elementType=e,t.type=o,t.lanes=r,t}function us(e,t,n,o){return e=cn(7,e,o,t),e.lanes=n,e}function og(e,t,n){return e=cn(6,e,null,t),e.lanes=n,e}function dk(e){var t=cn(18,null,null,0);return t.stateNode=e,t}function ag(e,t,n){return t=cn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var vS=new WeakMap;function Mn(e,t){if(typeof e=="object"&&e!==null){var n=vS.get(e);return n!==void 0?n:(t={value:e,source:t,stack:nS(t)},vS.set(e,t),t)}return{value:e,source:t,stack:nS(t)}}var Xi=[],Yi=0,Ah=null,hu=0,Tn=[],In=0,pr=null,Lo=1,So="";function ta(e,t){Xi[Yi++]=hu,Xi[Yi++]=Ah,Ah=e,hu=t}function fk(e,t,n){Tn[In++]=Lo,Tn[In++]=So,Tn[In++]=pr,pr=e;var o=Lo;e=So;var a=32-pn(o)-1;o&=~(1<<a),n+=1;var r=32-pn(t)+a;if(30<r){var s=a-a%5;r=(o&(1<<s)-1).toString(32),o>>=s,a-=s,Lo=1<<32-pn(t)+a|n<<a|o,So=r+e}else Lo=1<<r|n<<a|o,So=e}function Px(e){e.return!==null&&(ta(e,1),fk(e,1,0))}function Bx(e){for(;e===Ah;)Ah=Xi[--Yi],Xi[Yi]=null,hu=Xi[--Yi],Xi[Yi]=null;for(;e===pr;)pr=Tn[--In],Tn[In]=null,So=Tn[--In],Tn[In]=null,Lo=Tn[--In],Tn[In]=null}function pk(e,t){Tn[In++]=Lo,Tn[In++]=So,Tn[In++]=pr,Lo=t.id,So=t.overflow,pr=e}var Ct=null,Be=null,ge=!1,rr=null,On=!1,Gg=Error(O(519));function hr(e){var t=Error(O(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw mu(Mn(t,e)),Gg}function LS(e){var t=e.stateNode,n=e.type,o=e.memoizedProps;switch(t[_t]=e,t[Yt]=o,n){case"dialog":de("cancel",t),de("close",t);break;case"iframe":case"object":case"embed":de("load",t);break;case"video":case"audio":for(n=0;n<bu.length;n++)de(bu[n],t);break;case"source":de("error",t);break;case"img":case"image":case"link":de("error",t),de("load",t);break;case"details":de("toggle",t);break;case"input":de("invalid",t),q3(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":de("invalid",t);break;case"textarea":de("invalid",t),j3(t,o.value,o.defaultValue,o.children)}n=o.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||o.suppressHydrationWarning===!0||Yw(t.textContent,n)?(o.popover!=null&&(de("beforetoggle",t),de("toggle",t)),o.onScroll!=null&&de("scroll",t),o.onScrollEnd!=null&&de("scrollend",t),o.onClick!=null&&(t.onclick=aa),t=!0):t=!1,t||hr(e,!0)}function SS(e){for(Ct=e.return;Ct;)switch(Ct.tag){case 5:case 31:case 13:On=!1;return;case 27:case 3:On=!0;return;default:Ct=Ct.return}}function Pi(e){if(e!==Ct)return!1;if(!ge)return SS(e),ge=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||px(e.type,e.memoizedProps)),n=!n),n&&Be&&hr(e),SS(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));Be=d3(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));Be=d3(e)}else t===27?(t=Be,xr(e.type)?(e=gx,gx=null,Be=e):Be=t):Be=Ct?Dn(e.stateNode.nextSibling):null;return!0}function hs(){Be=Ct=null,ge=!1}function rg(){var e=rr;return e!==null&&(Zt===null?Zt=e:Zt.push.apply(Zt,e),rr=null),e}function mu(e){rr===null?rr=[e]:rr.push(e)}var qg=_o(null),Ss=null,ra=null;function Ya(e,t,n){Me(qg,t._currentValue),t._currentValue=n}function ia(e){e._currentValue=qg.current,At(qg)}function Wg(e,t,n){for(;e!==null;){var o=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,o!==null&&(o.childLanes|=t)):o!==null&&(o.childLanes&t)!==t&&(o.childLanes|=t),e===n)break;e=e.return}}function jg(e,t,n,o){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var r=a.dependencies;if(r!==null){var s=a.child;r=r.firstContext;e:for(;r!==null;){var i=r;r=a;for(var l=0;l<t.length;l++)if(i.context===t[l]){r.lanes|=n,i=r.alternate,i!==null&&(i.lanes|=n),Wg(r.return,n,e),o||(s=null);break e}r=i.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(O(341));s.lanes|=n,r=s.alternate,r!==null&&(r.lanes|=n),Wg(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function gl(e,t,n,o){e=null;for(var a=t,r=!1;a!==null;){if(!r){if((a.flags&524288)!==0)r=!0;else if((a.flags&262144)!==0)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(O(387));if(s=s.memoizedProps,s!==null){var i=a.type;mn(a.pendingProps.value,s.value)||(e!==null?e.push(i):e=[i])}}else if(a===ph.current){if(s=a.alternate,s===null)throw Error(O(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e!==null?e.push(vu):e=[vu])}a=a.return}e!==null&&jg(t,e,n,o),t.flags|=262144}function vh(e){for(e=e.firstContext;e!==null;){if(!mn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function ms(e){Ss=e,ra=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Tt(e){return hk(Ss,e)}function Gp(e,t){return Ss===null&&ms(e),hk(e,t)}function hk(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ra===null){if(e===null)throw Error(O(308));ra=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ra=ra.next=t;return n}var YO=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,o){e.push(o)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},KO=ut.unstable_scheduleCallback,$O=ut.unstable_NormalPriority,ot={$$typeof:oa,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function zx(){return{controller:new YO,data:new Map,refCount:0}}function Eu(e){e.refCount--,e.refCount===0&&KO($O,function(){e.controller.abort()})}var eu=null,Vg=0,il=0,el=null;function QO(e,t){if(eu===null){var n=eu=[];Vg=0,il=l1(),el={status:"pending",value:void 0,then:function(o){n.push(o)}}}return Vg++,t.then(kS,kS),t}function kS(){if(--Vg===0&&eu!==null){el!==null&&(el.status="fulfilled");var e=eu;eu=null,il=0,el=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function JO(e,t){var n=[],o={status:"pending",value:null,reason:null,then:function(a){n.push(a)}};return e.then(function(){o.status="fulfilled",o.value=t;for(var a=0;a<n.length;a++)(0,n[a])(t)},function(a){for(o.status="rejected",o.reason=a,a=0;a<n.length;a++)(0,n[a])(void 0)}),o}var wS=K.S;K.S=function(e,t){Tw=dn(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&QO(e,t),wS!==null&&wS(e,t)};var ds=_o(null);function Nx(){var e=ds.current;return e!==null?e:Ee.pooledCache}function oh(e,t){t===null?Me(ds,ds.current):Me(ds,t.pool)}function mk(){var e=Nx();return e===null?null:{parent:ot._currentValue,pool:e}}var xl=Error(O(460)),Fx=Error(O(474)),Xh=Error(O(542)),Lh={then:function(){}};function _S(e){return e=e.status,e==="fulfilled"||e==="rejected"}function yk(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(aa,aa),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,TS(e),e;default:if(typeof t.status=="string")t.then(aa,aa);else{if(e=Ee,e!==null&&100<e.shellSuspendCounter)throw Error(O(482));e=t,e.status="pending",e.then(function(o){if(t.status==="pending"){var a=t;a.status="fulfilled",a.value=o}},function(o){if(t.status==="pending"){var a=t;a.status="rejected",a.reason=o}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,TS(e),e}throw fs=t,xl}}function is(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(fs=n,xl):n}}var fs=null;function CS(){if(fs===null)throw Error(O(459));var e=fs;return fs=null,e}function TS(e){if(e===xl||e===Xh)throw Error(O(483))}var tl=null,yu=0;function qp(e){var t=yu;return yu+=1,tl===null&&(tl=[]),yk(tl,e,t)}function Uc(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Wp(e,t){throw t.$$typeof===FM?Error(O(525)):(e=Object.prototype.toString.call(t),Error(O(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function gk(e){function t(y,g){if(e){var x=y.deletions;x===null?(y.deletions=[g],y.flags|=16):x.push(g)}}function n(y,g){if(!e)return null;for(;g!==null;)t(y,g),g=g.sibling;return null}function o(y){for(var g=new Map;y!==null;)y.key!==null?g.set(y.key,y):g.set(y.index,y),y=y.sibling;return g}function a(y,g){return y=sa(y,g),y.index=0,y.sibling=null,y}function r(y,g,x){return y.index=x,e?(x=y.alternate,x!==null?(x=x.index,x<g?(y.flags|=67108866,g):x):(y.flags|=67108866,g)):(y.flags|=1048576,g)}function s(y){return e&&y.alternate===null&&(y.flags|=67108866),y}function i(y,g,x,A){return g===null||g.tag!==6?(g=og(x,y.mode,A),g.return=y,g):(g=a(g,x),g.return=y,g)}function l(y,g,x,A){var C=x.type;return C===Fi?u(y,g,x.props.children,A,x.key):g!==null&&(g.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Za&&is(C)===g.type)?(g=a(g,x.props),Uc(g,x),g.return=y,g):(g=nh(x.type,x.key,x.props,null,y.mode,A),Uc(g,x),g.return=y,g)}function c(y,g,x,A){return g===null||g.tag!==4||g.stateNode.containerInfo!==x.containerInfo||g.stateNode.implementation!==x.implementation?(g=ag(x,y.mode,A),g.return=y,g):(g=a(g,x.children||[]),g.return=y,g)}function u(y,g,x,A,C){return g===null||g.tag!==7?(g=us(x,y.mode,A,C),g.return=y,g):(g=a(g,x),g.return=y,g)}function d(y,g,x){if(typeof g=="string"&&g!==""||typeof g=="number"||typeof g=="bigint")return g=og(""+g,y.mode,x),g.return=y,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Dp:return x=nh(g.type,g.key,g.props,null,y.mode,x),Uc(x,g),x.return=y,x;case Vc:return g=ag(g,y.mode,x),g.return=y,g;case Za:return g=is(g),d(y,g,x)}if(Zc(g)||Fc(g))return g=us(g,y.mode,x,null),g.return=y,g;if(typeof g.then=="function")return d(y,qp(g),x);if(g.$$typeof===oa)return d(y,Gp(y,g),x);Wp(y,g)}return null}function f(y,g,x,A){var C=g!==null?g.key:null;if(typeof x=="string"&&x!==""||typeof x=="number"||typeof x=="bigint")return C!==null?null:i(y,g,""+x,A);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Dp:return x.key===C?l(y,g,x,A):null;case Vc:return x.key===C?c(y,g,x,A):null;case Za:return x=is(x),f(y,g,x,A)}if(Zc(x)||Fc(x))return C!==null?null:u(y,g,x,A,null);if(typeof x.then=="function")return f(y,g,qp(x),A);if(x.$$typeof===oa)return f(y,g,Gp(y,x),A);Wp(y,x)}return null}function p(y,g,x,A,C){if(typeof A=="string"&&A!==""||typeof A=="number"||typeof A=="bigint")return y=y.get(x)||null,i(g,y,""+A,C);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case Dp:return y=y.get(A.key===null?x:A.key)||null,l(g,y,A,C);case Vc:return y=y.get(A.key===null?x:A.key)||null,c(g,y,A,C);case Za:return A=is(A),p(y,g,x,A,C)}if(Zc(A)||Fc(A))return y=y.get(x)||null,u(g,y,A,C,null);if(typeof A.then=="function")return p(y,g,x,qp(A),C);if(A.$$typeof===oa)return p(y,g,x,Gp(g,A),C);Wp(g,A)}return null}function h(y,g,x,A){for(var C=null,_=null,v=g,I=g=0,k=null;v!==null&&I<x.length;I++){v.index>I?(k=v,v=null):k=v.sibling;var T=f(y,v,x[I],A);if(T===null){v===null&&(v=k);break}e&&v&&T.alternate===null&&t(y,v),g=r(T,g,I),_===null?C=T:_.sibling=T,_=T,v=k}if(I===x.length)return n(y,v),ge&&ta(y,I),C;if(v===null){for(;I<x.length;I++)v=d(y,x[I],A),v!==null&&(g=r(v,g,I),_===null?C=v:_.sibling=v,_=v);return ge&&ta(y,I),C}for(v=o(v);I<x.length;I++)k=p(v,y,I,x[I],A),k!==null&&(e&&k.alternate!==null&&v.delete(k.key===null?I:k.key),g=r(k,g,I),_===null?C=k:_.sibling=k,_=k);return e&&v.forEach(function(P){return t(y,P)}),ge&&ta(y,I),C}function m(y,g,x,A){if(x==null)throw Error(O(151));for(var C=null,_=null,v=g,I=g=0,k=null,T=x.next();v!==null&&!T.done;I++,T=x.next()){v.index>I?(k=v,v=null):k=v.sibling;var P=f(y,v,T.value,A);if(P===null){v===null&&(v=k);break}e&&v&&P.alternate===null&&t(y,v),g=r(P,g,I),_===null?C=P:_.sibling=P,_=P,v=k}if(T.done)return n(y,v),ge&&ta(y,I),C;if(v===null){for(;!T.done;I++,T=x.next())T=d(y,T.value,A),T!==null&&(g=r(T,g,I),_===null?C=T:_.sibling=T,_=T);return ge&&ta(y,I),C}for(v=o(v);!T.done;I++,T=x.next())T=p(v,y,I,T.value,A),T!==null&&(e&&T.alternate!==null&&v.delete(T.key===null?I:T.key),g=r(T,g,I),_===null?C=T:_.sibling=T,_=T);return e&&v.forEach(function(N){return t(y,N)}),ge&&ta(y,I),C}function b(y,g,x,A){if(typeof x=="object"&&x!==null&&x.type===Fi&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case Dp:e:{for(var C=x.key;g!==null;){if(g.key===C){if(C=x.type,C===Fi){if(g.tag===7){n(y,g.sibling),A=a(g,x.props.children),A.return=y,y=A;break e}}else if(g.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Za&&is(C)===g.type){n(y,g.sibling),A=a(g,x.props),Uc(A,x),A.return=y,y=A;break e}n(y,g);break}else t(y,g);g=g.sibling}x.type===Fi?(A=us(x.props.children,y.mode,A,x.key),A.return=y,y=A):(A=nh(x.type,x.key,x.props,null,y.mode,A),Uc(A,x),A.return=y,y=A)}return s(y);case Vc:e:{for(C=x.key;g!==null;){if(g.key===C)if(g.tag===4&&g.stateNode.containerInfo===x.containerInfo&&g.stateNode.implementation===x.implementation){n(y,g.sibling),A=a(g,x.children||[]),A.return=y,y=A;break e}else{n(y,g);break}else t(y,g);g=g.sibling}A=ag(x,y.mode,A),A.return=y,y=A}return s(y);case Za:return x=is(x),b(y,g,x,A)}if(Zc(x))return h(y,g,x,A);if(Fc(x)){if(C=Fc(x),typeof C!="function")throw Error(O(150));return x=C.call(x),m(y,g,x,A)}if(typeof x.then=="function")return b(y,g,qp(x),A);if(x.$$typeof===oa)return b(y,g,Gp(y,x),A);Wp(y,x)}return typeof x=="string"&&x!==""||typeof x=="number"||typeof x=="bigint"?(x=""+x,g!==null&&g.tag===6?(n(y,g.sibling),A=a(g,x),A.return=y,y=A):(n(y,g),A=og(x,y.mode,A),A.return=y,y=A),s(y)):n(y,g)}return function(y,g,x,A){try{yu=0;var C=b(y,g,x,A);return tl=null,C}catch(v){if(v===xl||v===Xh)throw v;var _=cn(29,v,null,y.mode);return _.lanes=A,_.return=y,_}finally{}}}var ys=gk(!0),xk=gk(!1),Xa=!1;function Hx(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Zg(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function sr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ir(e,t,n){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(ve&2)!==0){var a=o.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),o.pending=t,t=bh(e),ck(e,null,n),t}return Zh(e,o,t,n),bh(e)}function tu(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var o=t.lanes;o&=e.pendingLanes,n|=o,t.lanes=n,B3(e,n)}}function sg(e,t){var n=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,n===o)){var a=null,r=null;if(n=n.firstBaseUpdate,n!==null){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};r===null?a=r=s:r=r.next=s,n=n.next}while(n!==null);r===null?a=r=t:r=r.next=t}else a=r=t;n={baseState:o.baseState,firstBaseUpdate:a,lastBaseUpdate:r,shared:o.shared,callbacks:o.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Xg=!1;function nu(){if(Xg){var e=el;if(e!==null)throw e}}function ou(e,t,n,o){Xg=!1;var a=e.updateQueue;Xa=!1;var r=a.firstBaseUpdate,s=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var l=i,c=l.next;l.next=null,s===null?r=c:s.next=c,s=l;var u=e.alternate;u!==null&&(u=u.updateQueue,i=u.lastBaseUpdate,i!==s&&(i===null?u.firstBaseUpdate=c:i.next=c,u.lastBaseUpdate=l))}if(r!==null){var d=a.baseState;s=0,u=c=l=null,i=r;do{var f=i.lane&-536870913,p=f!==i.lane;if(p?(me&f)===f:(o&f)===f){f!==0&&f===il&&(Xg=!0),u!==null&&(u=u.next={lane:0,tag:i.tag,payload:i.payload,callback:null,next:null});e:{var h=e,m=i;f=t;var b=n;switch(m.tag){case 1:if(h=m.payload,typeof h=="function"){d=h.call(b,d,f);break e}d=h;break e;case 3:h.flags=h.flags&-65537|128;case 0:if(h=m.payload,f=typeof h=="function"?h.call(b,d,f):h,f==null)break e;d=ze({},d,f);break e;case 2:Xa=!0}}f=i.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=a.callbacks,p===null?a.callbacks=[f]:p.push(f))}else p={lane:f,tag:i.tag,payload:i.payload,callback:i.callback,next:null},u===null?(c=u=p,l=d):u=u.next=p,s|=f;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;p=i,i=p.next,p.next=null,a.lastBaseUpdate=p,a.shared.pending=null}}while(!0);u===null&&(l=d),a.baseState=l,a.firstBaseUpdate=c,a.lastBaseUpdate=u,r===null&&(a.shared.lanes=0),yr|=s,e.lanes=s,e.memoizedState=d}}function bk(e,t){if(typeof e!="function")throw Error(O(191,e));e.call(t)}function Ak(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)bk(n[e],t)}var ll=_o(null),Sh=_o(0);function IS(e,t){e=pa,Me(Sh,e),Me(ll,t),pa=e|t.baseLanes}function Yg(){Me(Sh,pa),Me(ll,ll.current)}function Ux(){pa=Sh.current,At(ll),At(Sh)}var yn=_o(null),Rn=null;function Ka(e){var t=e.alternate;Me(Ke,Ke.current&1),Me(yn,e),Rn===null&&(t===null||ll.current!==null||t.memoizedState!==null)&&(Rn=e)}function Kg(e){Me(Ke,Ke.current),Me(yn,e),Rn===null&&(Rn=e)}function vk(e){e.tag===22?(Me(Ke,Ke.current),Me(yn,e),Rn===null&&(Rn=e)):$a(e)}function $a(){Me(Ke,Ke.current),Me(yn,yn.current)}function ln(e){At(yn),Rn===e&&(Rn=null),At(Ke)}var Ke=_o(0);function kh(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||mx(n)||yx(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var ua=0,oe=null,Ie=null,tt=null,wh=!1,nl=!1,gs=!1,_h=0,gu=0,ol=null,eR=0;function Ze(){throw Error(O(321))}function Gx(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!mn(e[n],t[n]))return!1;return!0}function qx(e,t,n,o,a,r){return ua=r,oe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,K.H=e===null||e.memoizedState===null?Qk:e1,gs=!1,r=n(o,a),gs=!1,nl&&(r=Sk(t,n,o,a)),Lk(e),r}function Lk(e){K.H=xu;var t=Ie!==null&&Ie.next!==null;if(ua=0,tt=Ie=oe=null,wh=!1,gu=0,ol=null,t)throw Error(O(300));e===null||at||(e=e.dependencies,e!==null&&vh(e)&&(at=!0))}function Sk(e,t,n,o){oe=e;var a=0;do{if(nl&&(ol=null),gu=0,nl=!1,25<=a)throw Error(O(301));if(a+=1,tt=Ie=null,e.updateQueue!=null){var r=e.updateQueue;r.lastEffect=null,r.events=null,r.stores=null,r.memoCache!=null&&(r.memoCache.index=0)}K.H=Jk,r=t(n,o)}while(nl);return r}function tR(){var e=K.H,t=e.useState()[0];return t=typeof t.then=="function"?Mu(t):t,e=e.useState()[0],(Ie!==null?Ie.memoizedState:null)!==e&&(oe.flags|=1024),t}function Wx(){var e=_h!==0;return _h=0,e}function jx(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Vx(e){if(wh){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}wh=!1}ua=0,tt=Ie=oe=null,nl=!1,gu=_h=0,ol=null}function Ht(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tt===null?oe.memoizedState=tt=e:tt=tt.next=e,tt}function $e(){if(Ie===null){var e=oe.alternate;e=e!==null?e.memoizedState:null}else e=Ie.next;var t=tt===null?oe.memoizedState:tt.next;if(t!==null)tt=t,Ie=e;else{if(e===null)throw oe.alternate===null?Error(O(467)):Error(O(310));Ie=e,e={memoizedState:Ie.memoizedState,baseState:Ie.baseState,baseQueue:Ie.baseQueue,queue:Ie.queue,next:null},tt===null?oe.memoizedState=tt=e:tt=tt.next=e}return tt}function Yh(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Mu(e){var t=gu;return gu+=1,ol===null&&(ol=[]),e=yk(ol,e,t),t=oe,(tt===null?t.memoizedState:tt.next)===null&&(t=t.alternate,K.H=t===null||t.memoizedState===null?Qk:e1),e}function Kh(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Mu(e);if(e.$$typeof===oa)return Tt(e)}throw Error(O(438,String(e)))}function Zx(e){var t=null,n=oe.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var o=oe.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(t={data:o.data.map(function(a){return a.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=Yh(),oe.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),o=0;o<e;o++)n[o]=HM;return t.index++,n}function da(e,t){return typeof t=="function"?t(e):t}function ah(e){var t=$e();return Xx(t,Ie,e)}function Xx(e,t,n){var o=e.queue;if(o===null)throw Error(O(311));o.lastRenderedReducer=n;var a=e.baseQueue,r=o.pending;if(r!==null){if(a!==null){var s=a.next;a.next=r.next,r.next=s}t.baseQueue=a=r,o.pending=null}if(r=e.baseState,a===null)e.memoizedState=r;else{t=a.next;var i=s=null,l=null,c=t,u=!1;do{var d=c.lane&-536870913;if(d!==c.lane?(me&d)===d:(ua&d)===d){var f=c.revertLane;if(f===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),d===il&&(u=!0);else if((ua&f)===f){c=c.next,f===il&&(u=!0);continue}else d={lane:0,revertLane:c.revertLane,gesture:null,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null},l===null?(i=l=d,s=r):l=l.next=d,oe.lanes|=f,yr|=f;d=c.action,gs&&n(r,d),r=c.hasEagerState?c.eagerState:n(r,d)}else f={lane:d,revertLane:c.revertLane,gesture:c.gesture,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null},l===null?(i=l=f,s=r):l=l.next=f,oe.lanes|=d,yr|=d;c=c.next}while(c!==null&&c!==t);if(l===null?s=r:l.next=i,!mn(r,e.memoizedState)&&(at=!0,u&&(n=el,n!==null)))throw n;e.memoizedState=r,e.baseState=s,e.baseQueue=l,o.lastRenderedState=r}return a===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function ig(e){var t=$e(),n=t.queue;if(n===null)throw Error(O(311));n.lastRenderedReducer=e;var o=n.dispatch,a=n.pending,r=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do r=e(r,s.action),s=s.next;while(s!==a);mn(r,t.memoizedState)||(at=!0),t.memoizedState=r,t.baseQueue===null&&(t.baseState=r),n.lastRenderedState=r}return[r,o]}function kk(e,t,n){var o=oe,a=$e(),r=ge;if(r){if(n===void 0)throw Error(O(407));n=n()}else n=t();var s=!mn((Ie||a).memoizedState,n);if(s&&(a.memoizedState=n,at=!0),a=a.queue,Yx(Ck.bind(null,o,a,e),[e]),a.getSnapshot!==t||s||tt!==null&&tt.memoizedState.tag&1){if(o.flags|=2048,cl(9,{destroy:void 0},_k.bind(null,o,a,n,t),null),Ee===null)throw Error(O(349));r||(ua&127)!==0||wk(o,t,n)}return n}function wk(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=oe.updateQueue,t===null?(t=Yh(),oe.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function _k(e,t,n,o){t.value=n,t.getSnapshot=o,Tk(t)&&Ik(e)}function Ck(e,t,n){return n(function(){Tk(t)&&Ik(e)})}function Tk(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!mn(e,n)}catch{return!0}}function Ik(e){var t=Ls(e,2);t!==null&&Xt(t,e,2)}function $g(e){var t=Ht();if(typeof e=="function"){var n=e;if(e=n(),gs){Ja(!0);try{n()}finally{Ja(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:da,lastRenderedState:e},t}function Ek(e,t,n,o){return e.baseState=n,Xx(e,Ie,typeof o=="function"?o:da)}function nR(e,t,n,o,a){if(Qh(e))throw Error(O(485));if(e=t.action,e!==null){var r={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(s){r.listeners.push(s)}};K.T!==null?n(!0):r.isTransition=!1,o(r),n=t.pending,n===null?(r.next=t.pending=r,Mk(t,r)):(r.next=n.next,t.pending=n.next=r)}}function Mk(e,t){var n=t.action,o=t.payload,a=e.state;if(t.isTransition){var r=K.T,s={};K.T=s;try{var i=n(a,o),l=K.S;l!==null&&l(s,i),ES(e,t,i)}catch(c){Qg(e,t,c)}finally{r!==null&&s.types!==null&&(r.types=s.types),K.T=r}}else try{r=n(a,o),ES(e,t,r)}catch(c){Qg(e,t,c)}}function ES(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(o){MS(e,t,o)},function(o){return Qg(e,t,o)}):MS(e,t,n)}function MS(e,t,n){t.status="fulfilled",t.value=n,Ok(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Mk(e,n)))}function Qg(e,t,n){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=n,Ok(t),t=t.next;while(t!==o)}e.action=null}function Ok(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Rk(e,t){return t}function OS(e,t){if(ge){var n=Ee.formState;if(n!==null){e:{var o=oe;if(ge){if(Be){t:{for(var a=Be,r=On;a.nodeType!==8;){if(!r){a=null;break t}if(a=Dn(a.nextSibling),a===null){a=null;break t}}r=a.data,a=r==="F!"||r==="F"?a:null}if(a){Be=Dn(a.nextSibling),o=a.data==="F!";break e}}hr(o)}o=!1}o&&(t=n[0])}}return n=Ht(),n.memoizedState=n.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rk,lastRenderedState:t},n.queue=o,n=Yk.bind(null,oe,o),o.dispatch=n,o=$g(!1),r=Jx.bind(null,oe,!1,o.queue),o=Ht(),a={state:t,dispatch:null,action:e,pending:null},o.queue=a,n=nR.bind(null,oe,a,r,n),a.dispatch=n,o.memoizedState=e,[t,n,!1]}function RS(e){var t=$e();return Dk(t,Ie,e)}function Dk(e,t,n){if(t=Xx(e,t,Rk)[0],e=ah(da)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=Mu(t)}catch(s){throw s===xl?Xh:s}else o=t;t=$e();var a=t.queue,r=a.dispatch;return n!==t.memoizedState&&(oe.flags|=2048,cl(9,{destroy:void 0},oR.bind(null,a,n),null)),[o,r,e]}function oR(e,t){e.action=t}function DS(e){var t=$e(),n=Ie;if(n!==null)return Dk(t,n,e);$e(),t=t.memoizedState,n=$e();var o=n.queue.dispatch;return n.memoizedState=e,[t,o,!1]}function cl(e,t,n,o){return e={tag:e,create:n,deps:o,inst:t,next:null},t=oe.updateQueue,t===null&&(t=Yh(),oe.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(o=n.next,n.next=e,e.next=o,t.lastEffect=e),e}function Pk(){return $e().memoizedState}function rh(e,t,n,o){var a=Ht();oe.flags|=e,a.memoizedState=cl(1|t,{destroy:void 0},n,o===void 0?null:o)}function $h(e,t,n,o){var a=$e();o=o===void 0?null:o;var r=a.memoizedState.inst;Ie!==null&&o!==null&&Gx(o,Ie.memoizedState.deps)?a.memoizedState=cl(t,r,n,o):(oe.flags|=e,a.memoizedState=cl(1|t,r,n,o))}function PS(e,t){rh(8390656,8,e,t)}function Yx(e,t){$h(2048,8,e,t)}function aR(e){oe.flags|=4;var t=oe.updateQueue;if(t===null)t=Yh(),oe.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Bk(e){var t=$e().memoizedState;return aR({ref:t,nextImpl:e}),function(){if((ve&2)!==0)throw Error(O(440));return t.impl.apply(void 0,arguments)}}function zk(e,t){return $h(4,2,e,t)}function Nk(e,t){return $h(4,4,e,t)}function Fk(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Hk(e,t,n){n=n!=null?n.concat([e]):null,$h(4,4,Fk.bind(null,t,e),n)}function Kx(){}function Uk(e,t){var n=$e();t=t===void 0?null:t;var o=n.memoizedState;return t!==null&&Gx(t,o[1])?o[0]:(n.memoizedState=[e,t],e)}function Gk(e,t){var n=$e();t=t===void 0?null:t;var o=n.memoizedState;if(t!==null&&Gx(t,o[1]))return o[0];if(o=e(),gs){Ja(!0);try{e()}finally{Ja(!1)}}return n.memoizedState=[o,t],o}function $x(e,t,n){return n===void 0||(ua&1073741824)!==0&&(me&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=Ew(),oe.lanes|=e,yr|=e,n)}function qk(e,t,n,o){return mn(n,t)?n:ll.current!==null?(e=$x(e,n,o),mn(e,t)||(at=!0),e):(ua&42)===0||(ua&1073741824)!==0&&(me&261930)===0?(at=!0,e.memoizedState=n):(e=Ew(),oe.lanes|=e,yr|=e,t)}function Wk(e,t,n,o,a){var r=Le.p;Le.p=r!==0&&8>r?r:8;var s=K.T,i={};K.T=i,Jx(e,!1,t,n);try{var l=a(),c=K.S;if(c!==null&&c(i,l),l!==null&&typeof l=="object"&&typeof l.then=="function"){var u=JO(l,o);au(e,t,u,hn(e))}else au(e,t,o,hn(e))}catch(d){au(e,t,{then:function(){},status:"rejected",reason:d},hn())}finally{Le.p=r,s!==null&&i.types!==null&&(s.types=i.types),K.T=s}}function rR(){}function Jg(e,t,n,o){if(e.tag!==5)throw Error(O(476));var a=jk(e).queue;Wk(e,a,t,cs,n===null?rR:function(){return Vk(e),n(o)})}function jk(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:cs,baseState:cs,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:da,lastRenderedState:cs},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:da,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Vk(e){var t=jk(e);t.next===null&&(t=e.alternate.memoizedState),au(e,t.next.queue,{},hn())}function Qx(){return Tt(vu)}function Zk(){return $e().memoizedState}function Xk(){return $e().memoizedState}function sR(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=hn();e=sr(n);var o=ir(t,e,n);o!==null&&(Xt(o,t,n),tu(o,t,n)),t={cache:zx()},e.payload=t;return}t=t.return}}function iR(e,t,n){var o=hn();n={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Qh(e)?Kk(t,n):(n=Rx(e,t,n,o),n!==null&&(Xt(n,e,o),$k(n,t,o)))}function Yk(e,t,n){var o=hn();au(e,t,n,o)}function au(e,t,n,o){var a={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Qh(e))Kk(t,a);else{var r=e.alternate;if(e.lanes===0&&(r===null||r.lanes===0)&&(r=t.lastRenderedReducer,r!==null))try{var s=t.lastRenderedState,i=r(s,n);if(a.hasEagerState=!0,a.eagerState=i,mn(i,s))return Zh(e,t,a,0),Ee===null&&Vh(),!1}catch{}finally{}if(n=Rx(e,t,a,o),n!==null)return Xt(n,e,o),$k(n,t,o),!0}return!1}function Jx(e,t,n,o){if(o={lane:2,revertLane:l1(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Qh(e)){if(t)throw Error(O(479))}else t=Rx(e,n,o,2),t!==null&&Xt(t,e,2)}function Qh(e){var t=e.alternate;return e===oe||t!==null&&t===oe}function Kk(e,t){nl=wh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function $k(e,t,n){if((n&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,n|=o,t.lanes=n,B3(e,n)}}var xu={readContext:Tt,use:Kh,useCallback:Ze,useContext:Ze,useEffect:Ze,useImperativeHandle:Ze,useLayoutEffect:Ze,useInsertionEffect:Ze,useMemo:Ze,useReducer:Ze,useRef:Ze,useState:Ze,useDebugValue:Ze,useDeferredValue:Ze,useTransition:Ze,useSyncExternalStore:Ze,useId:Ze,useHostTransitionStatus:Ze,useFormState:Ze,useActionState:Ze,useOptimistic:Ze,useMemoCache:Ze,useCacheRefresh:Ze};xu.useEffectEvent=Ze;var Qk={readContext:Tt,use:Kh,useCallback:function(e,t){return Ht().memoizedState=[e,t===void 0?null:t],e},useContext:Tt,useEffect:PS,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,rh(4194308,4,Fk.bind(null,t,e),n)},useLayoutEffect:function(e,t){return rh(4194308,4,e,t)},useInsertionEffect:function(e,t){rh(4,2,e,t)},useMemo:function(e,t){var n=Ht();t=t===void 0?null:t;var o=e();if(gs){Ja(!0);try{e()}finally{Ja(!1)}}return n.memoizedState=[o,t],o},useReducer:function(e,t,n){var o=Ht();if(n!==void 0){var a=n(t);if(gs){Ja(!0);try{n(t)}finally{Ja(!1)}}}else a=t;return o.memoizedState=o.baseState=a,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:a},o.queue=e,e=e.dispatch=iR.bind(null,oe,e),[o.memoizedState,e]},useRef:function(e){var t=Ht();return e={current:e},t.memoizedState=e},useState:function(e){e=$g(e);var t=e.queue,n=Yk.bind(null,oe,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Kx,useDeferredValue:function(e,t){var n=Ht();return $x(n,e,t)},useTransition:function(){var e=$g(!1);return e=Wk.bind(null,oe,e.queue,!0,!1),Ht().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var o=oe,a=Ht();if(ge){if(n===void 0)throw Error(O(407));n=n()}else{if(n=t(),Ee===null)throw Error(O(349));(me&127)!==0||wk(o,t,n)}a.memoizedState=n;var r={value:n,getSnapshot:t};return a.queue=r,PS(Ck.bind(null,o,r,e),[e]),o.flags|=2048,cl(9,{destroy:void 0},_k.bind(null,o,r,n,t),null),n},useId:function(){var e=Ht(),t=Ee.identifierPrefix;if(ge){var n=So,o=Lo;n=(o&~(1<<32-pn(o)-1)).toString(32)+n,t="_"+t+"R_"+n,n=_h++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=eR++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Qx,useFormState:OS,useActionState:OS,useOptimistic:function(e){var t=Ht();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Jx.bind(null,oe,!0,n),n.dispatch=t,[e,t]},useMemoCache:Zx,useCacheRefresh:function(){return Ht().memoizedState=sR.bind(null,oe)},useEffectEvent:function(e){var t=Ht(),n={impl:e};return t.memoizedState=n,function(){if((ve&2)!==0)throw Error(O(440));return n.impl.apply(void 0,arguments)}}},e1={readContext:Tt,use:Kh,useCallback:Uk,useContext:Tt,useEffect:Yx,useImperativeHandle:Hk,useInsertionEffect:zk,useLayoutEffect:Nk,useMemo:Gk,useReducer:ah,useRef:Pk,useState:function(){return ah(da)},useDebugValue:Kx,useDeferredValue:function(e,t){var n=$e();return qk(n,Ie.memoizedState,e,t)},useTransition:function(){var e=ah(da)[0],t=$e().memoizedState;return[typeof e=="boolean"?e:Mu(e),t]},useSyncExternalStore:kk,useId:Zk,useHostTransitionStatus:Qx,useFormState:RS,useActionState:RS,useOptimistic:function(e,t){var n=$e();return Ek(n,Ie,e,t)},useMemoCache:Zx,useCacheRefresh:Xk};e1.useEffectEvent=Bk;var Jk={readContext:Tt,use:Kh,useCallback:Uk,useContext:Tt,useEffect:Yx,useImperativeHandle:Hk,useInsertionEffect:zk,useLayoutEffect:Nk,useMemo:Gk,useReducer:ig,useRef:Pk,useState:function(){return ig(da)},useDebugValue:Kx,useDeferredValue:function(e,t){var n=$e();return Ie===null?$x(n,e,t):qk(n,Ie.memoizedState,e,t)},useTransition:function(){var e=ig(da)[0],t=$e().memoizedState;return[typeof e=="boolean"?e:Mu(e),t]},useSyncExternalStore:kk,useId:Zk,useHostTransitionStatus:Qx,useFormState:DS,useActionState:DS,useOptimistic:function(e,t){var n=$e();return Ie!==null?Ek(n,Ie,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:Zx,useCacheRefresh:Xk};Jk.useEffectEvent=Bk;function lg(e,t,n,o){t=e.memoizedState,n=n(o,t),n=n==null?t:ze({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var ex={enqueueSetState:function(e,t,n){e=e._reactInternals;var o=hn(),a=sr(o);a.payload=t,n!=null&&(a.callback=n),t=ir(e,a,o),t!==null&&(Xt(t,e,o),tu(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var o=hn(),a=sr(o);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=ir(e,a,o),t!==null&&(Xt(t,e,o),tu(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=hn(),o=sr(n);o.tag=2,t!=null&&(o.callback=t),t=ir(e,o,n),t!==null&&(Xt(t,e,n),tu(t,e,n))}};function BS(e,t,n,o,a,r,s){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,r,s):t.prototype&&t.prototype.isPureReactComponent?!pu(n,o)||!pu(a,r):!0}function zS(e,t,n,o){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,o),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,o),t.state!==e&&ex.enqueueReplaceState(t,t.state,null)}function xs(e,t){var n=t;if("ref"in t){n={};for(var o in t)o!=="ref"&&(n[o]=t[o])}if(e=e.defaultProps){n===t&&(n=ze({},n));for(var a in e)n[a]===void 0&&(n[a]=e[a])}return n}function ew(e){xh(e)}function tw(e){console.error(e)}function nw(e){xh(e)}function Ch(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function NS(e,t,n){try{var o=e.onCaughtError;o(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(a){setTimeout(function(){throw a})}}function tx(e,t,n){return n=sr(n),n.tag=3,n.payload={element:null},n.callback=function(){Ch(e,t)},n}function ow(e){return e=sr(e),e.tag=3,e}function aw(e,t,n,o){var a=n.type.getDerivedStateFromError;if(typeof a=="function"){var r=o.value;e.payload=function(){return a(r)},e.callback=function(){NS(t,n,o)}}var s=n.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(e.callback=function(){NS(t,n,o),typeof a!="function"&&(lr===null?lr=new Set([this]):lr.add(this));var i=o.stack;this.componentDidCatch(o.value,{componentStack:i!==null?i:""})})}function lR(e,t,n,o,a){if(n.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=n.alternate,t!==null&&gl(t,n,a,!0),n=yn.current,n!==null){switch(n.tag){case 31:case 13:return Rn===null?Oh():n.alternate===null&&Xe===0&&(Xe=3),n.flags&=-257,n.flags|=65536,n.lanes=a,o===Lh?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([o]):t.add(o),bg(e,o,a)),!1;case 22:return n.flags|=65536,o===Lh?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([o])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([o]):n.add(o)),bg(e,o,a)),!1}throw Error(O(435,n.tag))}return bg(e,o,a),Oh(),!1}if(ge)return t=yn.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=a,o!==Gg&&(e=Error(O(422),{cause:o}),mu(Mn(e,n)))):(o!==Gg&&(t=Error(O(423),{cause:o}),mu(Mn(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,o=Mn(o,n),a=tx(e.stateNode,o,a),sg(e,a),Xe!==4&&(Xe=2)),!1;var r=Error(O(520),{cause:o});if(r=Mn(r,n),iu===null?iu=[r]:iu.push(r),Xe!==4&&(Xe=2),t===null)return!0;o=Mn(o,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=tx(n.stateNode,o,e),sg(n,e),!1;case 1:if(t=n.type,r=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||r!==null&&typeof r.componentDidCatch=="function"&&(lr===null||!lr.has(r))))return n.flags|=65536,a&=-a,n.lanes|=a,a=ow(a),aw(a,e,n,o),sg(n,a),!1}n=n.return}while(n!==null);return!1}var t1=Error(O(461)),at=!1;function wt(e,t,n,o){t.child=e===null?xk(t,null,n,o):ys(t,e.child,n,o)}function FS(e,t,n,o,a){n=n.render;var r=t.ref;if("ref"in o){var s={};for(var i in o)i!=="ref"&&(s[i]=o[i])}else s=o;return ms(t),o=qx(e,t,n,s,r,a),i=Wx(),e!==null&&!at?(jx(e,t,a),fa(e,t,a)):(ge&&i&&Px(t),t.flags|=1,wt(e,t,o,a),t.child)}function HS(e,t,n,o,a){if(e===null){var r=n.type;return typeof r=="function"&&!Dx(r)&&r.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=r,rw(e,t,r,o,a)):(e=nh(n.type,null,o,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(r=e.child,!n1(e,a)){var s=r.memoizedProps;if(n=n.compare,n=n!==null?n:pu,n(s,o)&&e.ref===t.ref)return fa(e,t,a)}return t.flags|=1,e=sa(r,o),e.ref=t.ref,e.return=t,t.child=e}function rw(e,t,n,o,a){if(e!==null){var r=e.memoizedProps;if(pu(r,o)&&e.ref===t.ref)if(at=!1,t.pendingProps=o=r,n1(e,a))(e.flags&131072)!==0&&(at=!0);else return t.lanes=e.lanes,fa(e,t,a)}return nx(e,t,n,o,a)}function sw(e,t,n,o){var a=o.children,r=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((t.flags&128)!==0){if(r=r!==null?r.baseLanes|n:n,e!==null){for(o=t.child=e.child,a=0;o!==null;)a=a|o.lanes|o.childLanes,o=o.sibling;o=a&~r}else o=0,t.child=null;return US(e,t,r,n,o)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&oh(t,r!==null?r.cachePool:null),r!==null?IS(t,r):Yg(),vk(t);else return o=t.lanes=536870912,US(e,t,r!==null?r.baseLanes|n:n,n,o)}else r!==null?(oh(t,r.cachePool),IS(t,r),$a(t),t.memoizedState=null):(e!==null&&oh(t,null),Yg(),$a(t));return wt(e,t,a,n),t.child}function Yc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function US(e,t,n,o,a){var r=Nx();return r=r===null?null:{parent:ot._currentValue,pool:r},t.memoizedState={baseLanes:n,cachePool:r},e!==null&&oh(t,null),Yg(),vk(t),e!==null&&gl(e,t,o,!0),t.childLanes=a,null}function sh(e,t){return t=Th({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function GS(e,t,n){return ys(t,e.child,null,n),e=sh(t,t.pendingProps),e.flags|=2,ln(t),t.memoizedState=null,e}function cR(e,t,n){var o=t.pendingProps,a=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(ge){if(o.mode==="hidden")return e=sh(t,o),t.lanes=536870912,Yc(null,e);if(Kg(t),(e=Be)?(e=Qw(e,On),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pr!==null?{id:Lo,overflow:So}:null,retryLane:536870912,hydrationErrors:null},n=dk(e),n.return=t,t.child=n,Ct=t,Be=null)):e=null,e===null)throw hr(t);return t.lanes=536870912,null}return sh(t,o)}var r=e.memoizedState;if(r!==null){var s=r.dehydrated;if(Kg(t),a)if(t.flags&256)t.flags&=-257,t=GS(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(O(558));else if(at||gl(e,t,n,!1),a=(n&e.childLanes)!==0,at||a){if(o=Ee,o!==null&&(s=z3(o,n),s!==0&&s!==r.retryLane))throw r.retryLane=s,Ls(e,s),Xt(o,e,s),t1;Oh(),t=GS(e,t,n)}else e=r.treeContext,Be=Dn(s.nextSibling),Ct=t,ge=!0,rr=null,On=!1,e!==null&&pk(t,e),t=sh(t,o),t.flags|=4096;return t}return e=sa(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ih(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(O(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function nx(e,t,n,o,a){return ms(t),n=qx(e,t,n,o,void 0,a),o=Wx(),e!==null&&!at?(jx(e,t,a),fa(e,t,a)):(ge&&o&&Px(t),t.flags|=1,wt(e,t,n,a),t.child)}function qS(e,t,n,o,a,r){return ms(t),t.updateQueue=null,n=Sk(t,o,n,a),Lk(e),o=Wx(),e!==null&&!at?(jx(e,t,r),fa(e,t,r)):(ge&&o&&Px(t),t.flags|=1,wt(e,t,n,r),t.child)}function WS(e,t,n,o,a){if(ms(t),t.stateNode===null){var r=Zi,s=n.contextType;typeof s=="object"&&s!==null&&(r=Tt(s)),r=new n(o,r),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=ex,t.stateNode=r,r._reactInternals=t,r=t.stateNode,r.props=o,r.state=t.memoizedState,r.refs={},Hx(t),s=n.contextType,r.context=typeof s=="object"&&s!==null?Tt(s):Zi,r.state=t.memoizedState,s=n.getDerivedStateFromProps,typeof s=="function"&&(lg(t,n,s,o),r.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(s=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),s!==r.state&&ex.enqueueReplaceState(r,r.state,null),ou(t,o,r,a),nu(),r.state=t.memoizedState),typeof r.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){r=t.stateNode;var i=t.memoizedProps,l=xs(n,i);r.props=l;var c=r.context,u=n.contextType;s=Zi,typeof u=="object"&&u!==null&&(s=Tt(u));var d=n.getDerivedStateFromProps;u=typeof d=="function"||typeof r.getSnapshotBeforeUpdate=="function",i=t.pendingProps!==i,u||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(i||c!==s)&&zS(t,r,o,s),Xa=!1;var f=t.memoizedState;r.state=f,ou(t,o,r,a),nu(),c=t.memoizedState,i||f!==c||Xa?(typeof d=="function"&&(lg(t,n,d,o),c=t.memoizedState),(l=Xa||BS(t,n,l,o,f,c,s))?(u||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount()),typeof r.componentDidMount=="function"&&(t.flags|=4194308)):(typeof r.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=o,t.memoizedState=c),r.props=o,r.state=c,r.context=s,o=l):(typeof r.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{r=t.stateNode,Zg(e,t),s=t.memoizedProps,u=xs(n,s),r.props=u,d=t.pendingProps,f=r.context,c=n.contextType,l=Zi,typeof c=="object"&&c!==null&&(l=Tt(c)),i=n.getDerivedStateFromProps,(c=typeof i=="function"||typeof r.getSnapshotBeforeUpdate=="function")||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(s!==d||f!==l)&&zS(t,r,o,l),Xa=!1,f=t.memoizedState,r.state=f,ou(t,o,r,a),nu();var p=t.memoizedState;s!==d||f!==p||Xa||e!==null&&e.dependencies!==null&&vh(e.dependencies)?(typeof i=="function"&&(lg(t,n,i,o),p=t.memoizedState),(u=Xa||BS(t,n,u,o,f,p,l)||e!==null&&e.dependencies!==null&&vh(e.dependencies))?(c||typeof r.UNSAFE_componentWillUpdate!="function"&&typeof r.componentWillUpdate!="function"||(typeof r.componentWillUpdate=="function"&&r.componentWillUpdate(o,p,l),typeof r.UNSAFE_componentWillUpdate=="function"&&r.UNSAFE_componentWillUpdate(o,p,l)),typeof r.componentDidUpdate=="function"&&(t.flags|=4),typeof r.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof r.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=p),r.props=o,r.state=p,r.context=l,o=u):(typeof r.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),o=!1)}return r=o,ih(e,t),o=(t.flags&128)!==0,r||o?(r=t.stateNode,n=o&&typeof n.getDerivedStateFromError!="function"?null:r.render(),t.flags|=1,e!==null&&o?(t.child=ys(t,e.child,null,a),t.child=ys(t,null,n,a)):wt(e,t,n,a),t.memoizedState=r.state,e=t.child):e=fa(e,t,a),e}function jS(e,t,n,o){return hs(),t.flags|=256,wt(e,t,n,o),t.child}var cg={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function ug(e){return{baseLanes:e,cachePool:mk()}}function dg(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=un),e}function iw(e,t,n){var o=t.pendingProps,a=!1,r=(t.flags&128)!==0,s;if((s=r)||(s=e!==null&&e.memoizedState===null?!1:(Ke.current&2)!==0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!==0,t.flags&=-33,e===null){if(ge){if(a?Ka(t):$a(t),(e=Be)?(e=Qw(e,On),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:pr!==null?{id:Lo,overflow:So}:null,retryLane:536870912,hydrationErrors:null},n=dk(e),n.return=t,t.child=n,Ct=t,Be=null)):e=null,e===null)throw hr(t);return yx(e)?t.lanes=32:t.lanes=536870912,null}var i=o.children;return o=o.fallback,a?($a(t),a=t.mode,i=Th({mode:"hidden",children:i},a),o=us(o,a,n,null),i.return=t,o.return=t,i.sibling=o,t.child=i,o=t.child,o.memoizedState=ug(n),o.childLanes=dg(e,s,n),t.memoizedState=cg,Yc(null,o)):(Ka(t),ox(t,i))}var l=e.memoizedState;if(l!==null&&(i=l.dehydrated,i!==null)){if(r)t.flags&256?(Ka(t),t.flags&=-257,t=fg(e,t,n)):t.memoizedState!==null?($a(t),t.child=e.child,t.flags|=128,t=null):($a(t),i=o.fallback,a=t.mode,o=Th({mode:"visible",children:o.children},a),i=us(i,a,n,null),i.flags|=2,o.return=t,i.return=t,o.sibling=i,t.child=o,ys(t,e.child,null,n),o=t.child,o.memoizedState=ug(n),o.childLanes=dg(e,s,n),t.memoizedState=cg,t=Yc(null,o));else if(Ka(t),yx(i)){if(s=i.nextSibling&&i.nextSibling.dataset,s)var c=s.dgst;s=c,o=Error(O(419)),o.stack="",o.digest=s,mu({value:o,source:null,stack:null}),t=fg(e,t,n)}else if(at||gl(e,t,n,!1),s=(n&e.childLanes)!==0,at||s){if(s=Ee,s!==null&&(o=z3(s,n),o!==0&&o!==l.retryLane))throw l.retryLane=o,Ls(e,o),Xt(s,e,o),t1;mx(i)||Oh(),t=fg(e,t,n)}else mx(i)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Be=Dn(i.nextSibling),Ct=t,ge=!0,rr=null,On=!1,e!==null&&pk(t,e),t=ox(t,o.children),t.flags|=4096);return t}return a?($a(t),i=o.fallback,a=t.mode,l=e.child,c=l.sibling,o=sa(l,{mode:"hidden",children:o.children}),o.subtreeFlags=l.subtreeFlags&65011712,c!==null?i=sa(c,i):(i=us(i,a,n,null),i.flags|=2),i.return=t,o.return=t,o.sibling=i,t.child=o,Yc(null,o),o=t.child,i=e.child.memoizedState,i===null?i=ug(n):(a=i.cachePool,a!==null?(l=ot._currentValue,a=a.parent!==l?{parent:l,pool:l}:a):a=mk(),i={baseLanes:i.baseLanes|n,cachePool:a}),o.memoizedState=i,o.childLanes=dg(e,s,n),t.memoizedState=cg,Yc(e.child,o)):(Ka(t),n=e.child,e=n.sibling,n=sa(n,{mode:"visible",children:o.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function ox(e,t){return t=Th({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Th(e,t){return e=cn(22,e,null,t),e.lanes=0,e}function fg(e,t,n){return ys(t,e.child,null,n),e=ox(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function VS(e,t,n){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),Wg(e.return,t,n)}function pg(e,t,n,o,a,r){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:o,tail:n,tailMode:a,treeForkCount:r}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=o,s.tail=n,s.tailMode=a,s.treeForkCount=r)}function lw(e,t,n){var o=t.pendingProps,a=o.revealOrder,r=o.tail;o=o.children;var s=Ke.current,i=(s&2)!==0;if(i?(s=s&1|2,t.flags|=128):s&=1,Me(Ke,s),wt(e,t,o,n),o=ge?hu:0,!i&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&VS(e,n,t);else if(e.tag===19)VS(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(a){case"forwards":for(n=t.child,a=null;n!==null;)e=n.alternate,e!==null&&kh(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),pg(t,!1,a,n,r,o);break;case"backwards":case"unstable_legacy-backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&kh(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}pg(t,!0,n,null,r,o);break;case"together":pg(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function fa(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),yr|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(gl(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(O(153));if(t.child!==null){for(e=t.child,n=sa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=sa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function n1(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&vh(e)))}function uR(e,t,n){switch(t.tag){case 3:hh(t,t.stateNode.containerInfo),Ya(t,ot,e.memoizedState.cache),hs();break;case 27:case 5:Mg(t);break;case 4:hh(t,t.stateNode.containerInfo);break;case 10:Ya(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Kg(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(Ka(t),t.flags|=128,null):(n&t.child.childLanes)!==0?iw(e,t,n):(Ka(t),e=fa(e,t,n),e!==null?e.sibling:null);Ka(t);break;case 19:var a=(e.flags&128)!==0;if(o=(n&t.childLanes)!==0,o||(gl(e,t,n,!1),o=(n&t.childLanes)!==0),a){if(o)return lw(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),Me(Ke,Ke.current),o)break;return null;case 22:return t.lanes=0,sw(e,t,n,t.pendingProps);case 24:Ya(t,ot,e.memoizedState.cache)}return fa(e,t,n)}function cw(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)at=!0;else{if(!n1(e,n)&&(t.flags&128)===0)return at=!1,uR(e,t,n);at=(e.flags&131072)!==0}else at=!1,ge&&(t.flags&1048576)!==0&&fk(t,hu,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=is(t.elementType),t.type=e,typeof e=="function")Dx(e)?(o=xs(e,o),t.tag=1,t=WS(null,t,e,o,n)):(t.tag=0,t=nx(null,t,e,o,n));else{if(e!=null){var a=e.$$typeof;if(a===Ax){t.tag=11,t=FS(null,t,e,o,n);break e}else if(a===vx){t.tag=14,t=HS(null,t,e,o,n);break e}}throw t=Ig(e)||e,Error(O(306,t,""))}}return t;case 0:return nx(e,t,t.type,t.pendingProps,n);case 1:return o=t.type,a=xs(o,t.pendingProps),WS(e,t,o,a,n);case 3:e:{if(hh(t,t.stateNode.containerInfo),e===null)throw Error(O(387));o=t.pendingProps;var r=t.memoizedState;a=r.element,Zg(e,t),ou(t,o,null,n);var s=t.memoizedState;if(o=s.cache,Ya(t,ot,o),o!==r.cache&&jg(t,[ot],n,!0),nu(),o=s.element,r.isDehydrated)if(r={element:o,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=r,t.memoizedState=r,t.flags&256){t=jS(e,t,o,n);break e}else if(o!==a){a=Mn(Error(O(424)),t),mu(a),t=jS(e,t,o,n);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(Be=Dn(e.firstChild),Ct=t,ge=!0,rr=null,On=!0,n=xk(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(hs(),o===a){t=fa(e,t,n);break e}wt(e,t,o,n)}t=t.child}return t;case 26:return ih(e,t),e===null?(n=h3(t.type,null,t.pendingProps,null))?t.memoizedState=n:ge||(n=t.type,e=t.pendingProps,o=Bh(ar.current).createElement(n),o[_t]=t,o[Yt]=e,It(o,n,e),bt(o),t.stateNode=o):t.memoizedState=h3(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Mg(t),e===null&&ge&&(o=t.stateNode=Jw(t.type,t.pendingProps,ar.current),Ct=t,On=!0,a=Be,xr(t.type)?(gx=a,Be=Dn(o.firstChild)):Be=a),wt(e,t,t.pendingProps.children,n),ih(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&ge&&((a=o=Be)&&(o=NR(o,t.type,t.pendingProps,On),o!==null?(t.stateNode=o,Ct=t,Be=Dn(o.firstChild),On=!1,a=!0):a=!1),a||hr(t)),Mg(t),a=t.type,r=t.pendingProps,s=e!==null?e.memoizedProps:null,o=r.children,px(a,r)?o=null:s!==null&&px(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=qx(e,t,tR,null,null,n),vu._currentValue=a),ih(e,t),wt(e,t,o,n),t.child;case 6:return e===null&&ge&&((e=n=Be)&&(n=FR(n,t.pendingProps,On),n!==null?(t.stateNode=n,Ct=t,Be=null,e=!0):e=!1),e||hr(t)),null;case 13:return iw(e,t,n);case 4:return hh(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=ys(t,null,o,n):wt(e,t,o,n),t.child;case 11:return FS(e,t,t.type,t.pendingProps,n);case 7:return wt(e,t,t.pendingProps,n),t.child;case 8:return wt(e,t,t.pendingProps.children,n),t.child;case 12:return wt(e,t,t.pendingProps.children,n),t.child;case 10:return o=t.pendingProps,Ya(t,t.type,o.value),wt(e,t,o.children,n),t.child;case 9:return a=t.type._context,o=t.pendingProps.children,ms(t),a=Tt(a),o=o(a),t.flags|=1,wt(e,t,o,n),t.child;case 14:return HS(e,t,t.type,t.pendingProps,n);case 15:return rw(e,t,t.type,t.pendingProps,n);case 19:return lw(e,t,n);case 31:return cR(e,t,n);case 22:return sw(e,t,n,t.pendingProps);case 24:return ms(t),o=Tt(ot),e===null?(a=Nx(),a===null&&(a=Ee,r=zx(),a.pooledCache=r,r.refCount++,r!==null&&(a.pooledCacheLanes|=n),a=r),t.memoizedState={parent:o,cache:a},Hx(t),Ya(t,ot,a)):((e.lanes&n)!==0&&(Zg(e,t),ou(t,null,null,n),nu()),a=e.memoizedState,r=t.memoizedState,a.parent!==o?(a={parent:o,cache:o},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ya(t,ot,o)):(o=r.cache,Ya(t,ot,o),o!==a.cache&&jg(t,[ot],n,!0))),wt(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(O(156,t.tag))}function $o(e){e.flags|=4}function hg(e,t,n,o,a){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(a&335544128)===a)if(e.stateNode.complete)e.flags|=8192;else if(Rw())e.flags|=8192;else throw fs=Lh,Fx}else e.flags&=-16777217}function ZS(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!n_(t))if(Rw())e.flags|=8192;else throw fs=Lh,Fx}function jp(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?D3():536870912,e.lanes|=t,ul|=t)}function Gc(e,t){if(!ge)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var o=null;n!==null;)n.alternate!==null&&(o=n),n=n.sibling;o===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function Pe(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,o=0;if(t)for(var a=e.child;a!==null;)n|=a.lanes|a.childLanes,o|=a.subtreeFlags&65011712,o|=a.flags&65011712,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)n|=a.lanes|a.childLanes,o|=a.subtreeFlags,o|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=o,e.childLanes=n,t}function dR(e,t,n){var o=t.pendingProps;switch(Bx(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pe(t),null;case 1:return Pe(t),null;case 3:return n=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),ia(ot),al(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Pi(t)?$o(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,rg())),Pe(t),null;case 26:var a=t.type,r=t.memoizedState;return e===null?($o(t),r!==null?(Pe(t),ZS(t,r)):(Pe(t),hg(t,a,null,o,n))):r?r!==e.memoizedState?($o(t),Pe(t),ZS(t,r)):(Pe(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&$o(t),Pe(t),hg(t,a,e,o,n)),null;case 27:if(mh(t),n=ar.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&$o(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Pe(t),null}e=wo.current,Pi(t)?LS(t,e):(e=Jw(a,o,n),t.stateNode=e,$o(t))}return Pe(t),null;case 5:if(mh(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&$o(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Pe(t),null}if(r=wo.current,Pi(t))LS(t,r);else{var s=Bh(ar.current);switch(r){case 1:r=s.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:r=s.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":r=s.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":r=s.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":r=s.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild);break;case"select":r=typeof o.is=="string"?s.createElement("select",{is:o.is}):s.createElement("select"),o.multiple?r.multiple=!0:o.size&&(r.size=o.size);break;default:r=typeof o.is=="string"?s.createElement(a,{is:o.is}):s.createElement(a)}}r[_t]=t,r[Yt]=o;e:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)r.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break e;for(;s.sibling===null;){if(s.return===null||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=r;e:switch(It(r,a,o),a){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&$o(t)}}return Pe(t),hg(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&$o(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(O(166));if(e=ar.current,Pi(t)){if(e=t.stateNode,n=t.memoizedProps,o=null,a=Ct,a!==null)switch(a.tag){case 27:case 5:o=a.memoizedProps}e[_t]=t,e=!!(e.nodeValue===n||o!==null&&o.suppressHydrationWarning===!0||Yw(e.nodeValue,n)),e||hr(t,!0)}else e=Bh(e).createTextNode(o),e[_t]=t,t.stateNode=e}return Pe(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(o=Pi(t),n!==null){if(e===null){if(!o)throw Error(O(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(557));e[_t]=t}else hs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Pe(t),e=!1}else n=rg(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(ln(t),t):(ln(t),null);if((t.flags&128)!==0)throw Error(O(558))}return Pe(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Pi(t),o!==null&&o.dehydrated!==null){if(e===null){if(!a)throw Error(O(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(O(317));a[_t]=t}else hs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Pe(t),a=!1}else a=rg(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(ln(t),t):(ln(t),null)}return ln(t),(t.flags&128)!==0?(t.lanes=n,t):(n=o!==null,e=e!==null&&e.memoizedState!==null,n&&(o=t.child,a=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(a=o.alternate.memoizedState.cachePool.pool),r=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(r=o.memoizedState.cachePool.pool),r!==a&&(o.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),jp(t,t.updateQueue),Pe(t),null);case 4:return al(),e===null&&c1(t.stateNode.containerInfo),Pe(t),null;case 10:return ia(t.type),Pe(t),null;case 19:if(At(Ke),o=t.memoizedState,o===null)return Pe(t),null;if(a=(t.flags&128)!==0,r=o.rendering,r===null)if(a)Gc(o,!1);else{if(Xe!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(r=kh(e),r!==null){for(t.flags|=128,Gc(o,!1),e=r.updateQueue,t.updateQueue=e,jp(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)uk(n,e),n=n.sibling;return Me(Ke,Ke.current&1|2),ge&&ta(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&dn()>Eh&&(t.flags|=128,a=!0,Gc(o,!1),t.lanes=4194304)}else{if(!a)if(e=kh(r),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,jp(t,e),Gc(o,!0),o.tail===null&&o.tailMode==="hidden"&&!r.alternate&&!ge)return Pe(t),null}else 2*dn()-o.renderingStartTime>Eh&&n!==536870912&&(t.flags|=128,a=!0,Gc(o,!1),t.lanes=4194304);o.isBackwards?(r.sibling=t.child,t.child=r):(e=o.last,e!==null?e.sibling=r:t.child=r,o.last=r)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=dn(),e.sibling=null,n=Ke.current,Me(Ke,a?n&1|2:n&1),ge&&ta(t,o.treeForkCount),e):(Pe(t),null);case 22:case 23:return ln(t),Ux(),o=t.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(t.flags|=8192):o&&(t.flags|=8192),o?(n&536870912)!==0&&(t.flags&128)===0&&(Pe(t),t.subtreeFlags&6&&(t.flags|=8192)):Pe(t),n=t.updateQueue,n!==null&&jp(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),o=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),o!==n&&(t.flags|=2048),e!==null&&At(ds),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ia(ot),Pe(t),null;case 25:return null;case 30:return null}throw Error(O(156,t.tag))}function fR(e,t){switch(Bx(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ia(ot),al(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return mh(t),null;case 31:if(t.memoizedState!==null){if(ln(t),t.alternate===null)throw Error(O(340));hs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(ln(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(O(340));hs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return At(Ke),null;case 4:return al(),null;case 10:return ia(t.type),null;case 22:case 23:return ln(t),Ux(),e!==null&&At(ds),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ia(ot),null;case 25:return null;default:return null}}function uw(e,t){switch(Bx(t),t.tag){case 3:ia(ot),al();break;case 26:case 27:case 5:mh(t);break;case 4:al();break;case 31:t.memoizedState!==null&&ln(t);break;case 13:ln(t);break;case 19:At(Ke);break;case 10:ia(t.type);break;case 22:case 23:ln(t),Ux(),e!==null&&At(ds);break;case 24:ia(ot)}}function Ou(e,t){try{var n=t.updateQueue,o=n!==null?n.lastEffect:null;if(o!==null){var a=o.next;n=a;do{if((n.tag&e)===e){o=void 0;var r=n.create,s=n.inst;o=r(),s.destroy=o}n=n.next}while(n!==a)}}catch(i){Ce(t,t.return,i)}}function mr(e,t,n){try{var o=t.updateQueue,a=o!==null?o.lastEffect:null;if(a!==null){var r=a.next;o=r;do{if((o.tag&e)===e){var s=o.inst,i=s.destroy;if(i!==void 0){s.destroy=void 0,a=t;var l=n,c=i;try{c()}catch(u){Ce(a,l,u)}}}o=o.next}while(o!==r)}}catch(u){Ce(t,t.return,u)}}function dw(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ak(t,n)}catch(o){Ce(e,e.return,o)}}}function fw(e,t,n){n.props=xs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(o){Ce(e,t,o)}}function ru(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof n=="function"?e.refCleanup=n(o):n.current=o}}catch(a){Ce(e,t,a)}}function ko(e,t){var n=e.ref,o=e.refCleanup;if(n!==null)if(typeof o=="function")try{o()}catch(a){Ce(e,t,a)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(a){Ce(e,t,a)}else n.current=null}function pw(e){var t=e.type,n=e.memoizedProps,o=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&o.focus();break e;case"img":n.src?o.src=n.src:n.srcSet&&(o.srcset=n.srcSet)}}catch(a){Ce(e,e.return,a)}}function mg(e,t,n){try{var o=e.stateNode;OR(o,e.type,n,t),o[Yt]=t}catch(a){Ce(e,e.return,a)}}function hw(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&xr(e.type)||e.tag===4}function yg(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||hw(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&xr(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ax(e,t,n){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=aa));else if(o!==4&&(o===27&&xr(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(ax(e,t,n),e=e.sibling;e!==null;)ax(e,t,n),e=e.sibling}function Ih(e,t,n){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(o!==4&&(o===27&&xr(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Ih(e,t,n),e=e.sibling;e!==null;)Ih(e,t,n),e=e.sibling}function mw(e){var t=e.stateNode,n=e.memoizedProps;try{for(var o=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);It(t,o,n),t[_t]=e,t[Yt]=n}catch(r){Ce(e,e.return,r)}}var na=!1,nt=!1,gg=!1,XS=typeof WeakSet=="function"?WeakSet:Set,xt=null;function pR(e,t){if(e=e.containerInfo,dx=Hh,e=nk(e),Mx(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var o=n.getSelection&&n.getSelection();if(o&&o.rangeCount!==0){n=o.anchorNode;var a=o.anchorOffset,r=o.focusNode;o=o.focusOffset;try{n.nodeType,r.nodeType}catch{n=null;break e}var s=0,i=-1,l=-1,c=0,u=0,d=e,f=null;t:for(;;){for(var p;d!==n||a!==0&&d.nodeType!==3||(i=s+a),d!==r||o!==0&&d.nodeType!==3||(l=s+o),d.nodeType===3&&(s+=d.nodeValue.length),(p=d.firstChild)!==null;)f=d,d=p;for(;;){if(d===e)break t;if(f===n&&++c===a&&(i=s),f===r&&++u===o&&(l=s),(p=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=p}n=i===-1||l===-1?null:{start:i,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(fx={focusedElem:e,selectionRange:n},Hh=!1,xt=t;xt!==null;)if(t=xt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,xt=e;else for(;xt!==null;){switch(t=xt,r=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&r!==null){e=void 0,n=t,a=r.memoizedProps,r=r.memoizedState,o=n.stateNode;try{var h=xs(n.type,a);e=o.getSnapshotBeforeUpdate(h,r),o.__reactInternalSnapshotBeforeUpdate=e}catch(m){Ce(n,n.return,m)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)hx(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":hx(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(O(163))}if(e=t.sibling,e!==null){e.return=t.return,xt=e;break}xt=t.return}}function yw(e,t,n){var o=n.flags;switch(n.tag){case 0:case 11:case 15:Jo(e,n),o&4&&Ou(5,n);break;case 1:if(Jo(e,n),o&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(s){Ce(n,n.return,s)}else{var a=xs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){Ce(n,n.return,s)}}o&64&&dw(n),o&512&&ru(n,n.return);break;case 3:if(Jo(e,n),o&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Ak(e,t)}catch(s){Ce(n,n.return,s)}}break;case 27:t===null&&o&4&&mw(n);case 26:case 5:Jo(e,n),t===null&&o&4&&pw(n),o&512&&ru(n,n.return);break;case 12:Jo(e,n);break;case 31:Jo(e,n),o&4&&bw(e,n);break;case 13:Jo(e,n),o&4&&Aw(e,n),o&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=LR.bind(null,n),HR(e,n))));break;case 22:if(o=n.memoizedState!==null||na,!o){t=t!==null&&t.memoizedState!==null||nt,a=na;var r=nt;na=o,(nt=t)&&!r?ea(e,n,(n.subtreeFlags&8772)!==0):Jo(e,n),na=a,nt=r}break;case 30:break;default:Jo(e,n)}}function gw(e){var t=e.alternate;t!==null&&(e.alternate=null,gw(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&wx(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Ge=null,Vt=!1;function Qo(e,t,n){for(n=n.child;n!==null;)xw(e,t,n),n=n.sibling}function xw(e,t,n){if(fn&&typeof fn.onCommitFiberUnmount=="function")try{fn.onCommitFiberUnmount(wu,n)}catch{}switch(n.tag){case 26:nt||ko(n,t),Qo(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:nt||ko(n,t);var o=Ge,a=Vt;xr(n.type)&&(Ge=n.stateNode,Vt=!1),Qo(e,t,n),cu(n.stateNode),Ge=o,Vt=a;break;case 5:nt||ko(n,t);case 6:if(o=Ge,a=Vt,Ge=null,Qo(e,t,n),Ge=o,Vt=a,Ge!==null)if(Vt)try{(Ge.nodeType===9?Ge.body:Ge.nodeName==="HTML"?Ge.ownerDocument.body:Ge).removeChild(n.stateNode)}catch(r){Ce(n,t,r)}else try{Ge.removeChild(n.stateNode)}catch(r){Ce(n,t,r)}break;case 18:Ge!==null&&(Vt?(e=Ge,c3(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),hl(e)):c3(Ge,n.stateNode));break;case 4:o=Ge,a=Vt,Ge=n.stateNode.containerInfo,Vt=!0,Qo(e,t,n),Ge=o,Vt=a;break;case 0:case 11:case 14:case 15:mr(2,n,t),nt||mr(4,n,t),Qo(e,t,n);break;case 1:nt||(ko(n,t),o=n.stateNode,typeof o.componentWillUnmount=="function"&&fw(n,t,o)),Qo(e,t,n);break;case 21:Qo(e,t,n);break;case 22:nt=(o=nt)||n.memoizedState!==null,Qo(e,t,n),nt=o;break;default:Qo(e,t,n)}}function bw(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{hl(e)}catch(n){Ce(t,t.return,n)}}}function Aw(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{hl(e)}catch(n){Ce(t,t.return,n)}}function hR(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new XS),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new XS),t;default:throw Error(O(435,e.tag))}}function Vp(e,t){var n=hR(e);t.forEach(function(o){if(!n.has(o)){n.add(o);var a=SR.bind(null,e,o);o.then(a,a)}})}function Wt(e,t){var n=t.deletions;if(n!==null)for(var o=0;o<n.length;o++){var a=n[o],r=e,s=t,i=s;e:for(;i!==null;){switch(i.tag){case 27:if(xr(i.type)){Ge=i.stateNode,Vt=!1;break e}break;case 5:Ge=i.stateNode,Vt=!1;break e;case 3:case 4:Ge=i.stateNode.containerInfo,Vt=!0;break e}i=i.return}if(Ge===null)throw Error(O(160));xw(r,s,a),Ge=null,Vt=!1,r=a.alternate,r!==null&&(r.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)vw(t,e),t=t.sibling}var ao=null;function vw(e,t){var n=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Wt(t,e),jt(e),o&4&&(mr(3,e,e.return),Ou(3,e),mr(5,e,e.return));break;case 1:Wt(t,e),jt(e),o&512&&(nt||n===null||ko(n,n.return)),o&64&&na&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?o:n.concat(o))));break;case 26:var a=ao;if(Wt(t,e),jt(e),o&512&&(nt||n===null||ko(n,n.return)),o&4){var r=n!==null?n.memoizedState:null;if(o=e.memoizedState,n===null)if(o===null)if(e.stateNode===null){e:{o=e.type,n=e.memoizedProps,a=a.ownerDocument||a;t:switch(o){case"title":r=a.getElementsByTagName("title")[0],(!r||r[Tu]||r[_t]||r.namespaceURI==="http://www.w3.org/2000/svg"||r.hasAttribute("itemprop"))&&(r=a.createElement(o),a.head.insertBefore(r,a.querySelector("head > title"))),It(r,o,n),r[_t]=e,bt(r),o=r;break e;case"link":var s=y3("link","href",a).get(o+(n.href||""));if(s){for(var i=0;i<s.length;i++)if(r=s[i],r.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&r.getAttribute("rel")===(n.rel==null?null:n.rel)&&r.getAttribute("title")===(n.title==null?null:n.title)&&r.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(i,1);break t}}r=a.createElement(o),It(r,o,n),a.head.appendChild(r);break;case"meta":if(s=y3("meta","content",a).get(o+(n.content||""))){for(i=0;i<s.length;i++)if(r=s[i],r.getAttribute("content")===(n.content==null?null:""+n.content)&&r.getAttribute("name")===(n.name==null?null:n.name)&&r.getAttribute("property")===(n.property==null?null:n.property)&&r.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute("charset")===(n.charSet==null?null:n.charSet)){s.splice(i,1);break t}}r=a.createElement(o),It(r,o,n),a.head.appendChild(r);break;default:throw Error(O(468,o))}r[_t]=e,bt(r),o=r}e.stateNode=o}else g3(a,e.type,e.stateNode);else e.stateNode=m3(a,o,e.memoizedProps);else r!==o?(r===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):r.count--,o===null?g3(a,e.type,e.stateNode):m3(a,o,e.memoizedProps)):o===null&&e.stateNode!==null&&mg(e,e.memoizedProps,n.memoizedProps)}break;case 27:Wt(t,e),jt(e),o&512&&(nt||n===null||ko(n,n.return)),n!==null&&o&4&&mg(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Wt(t,e),jt(e),o&512&&(nt||n===null||ko(n,n.return)),e.flags&32){a=e.stateNode;try{sl(a,"")}catch(h){Ce(e,e.return,h)}}o&4&&e.stateNode!=null&&(a=e.memoizedProps,mg(e,a,n!==null?n.memoizedProps:a)),o&1024&&(gg=!0);break;case 6:if(Wt(t,e),jt(e),o&4){if(e.stateNode===null)throw Error(O(162));o=e.memoizedProps,n=e.stateNode;try{n.nodeValue=o}catch(h){Ce(e,e.return,h)}}break;case 3:if(uh=null,a=ao,ao=zh(t.containerInfo),Wt(t,e),ao=a,jt(e),o&4&&n!==null&&n.memoizedState.isDehydrated)try{hl(t.containerInfo)}catch(h){Ce(e,e.return,h)}gg&&(gg=!1,Lw(e));break;case 4:o=ao,ao=zh(e.stateNode.containerInfo),Wt(t,e),jt(e),ao=o;break;case 12:Wt(t,e),jt(e);break;case 31:Wt(t,e),jt(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Vp(e,o)));break;case 13:Wt(t,e),jt(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Jh=dn()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Vp(e,o)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,c=na,u=nt;if(na=c||a,nt=u||l,Wt(t,e),nt=u,na=c,jt(e),o&8192)e:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||na||nt||ls(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(r=l.stateNode,a)s=r.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none";else{i=l.stateNode;var d=l.memoizedProps.style,f=d!=null&&d.hasOwnProperty("display")?d.display:null;i.style.display=f==null||typeof f=="boolean"?"":(""+f).trim()}}catch(h){Ce(l,l.return,h)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?"":l.memoizedProps}catch(h){Ce(l,l.return,h)}}}else if(t.tag===18){if(n===null){l=t;try{var p=l.stateNode;a?u3(p,!0):u3(l.stateNode,!1)}catch(h){Ce(l,l.return,h)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}o&4&&(o=e.updateQueue,o!==null&&(n=o.retryQueue,n!==null&&(o.retryQueue=null,Vp(e,n))));break;case 19:Wt(t,e),jt(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Vp(e,o)));break;case 30:break;case 21:break;default:Wt(t,e),jt(e)}}function jt(e){var t=e.flags;if(t&2){try{for(var n,o=e.return;o!==null;){if(hw(o)){n=o;break}o=o.return}if(n==null)throw Error(O(160));switch(n.tag){case 27:var a=n.stateNode,r=yg(e);Ih(e,r,a);break;case 5:var s=n.stateNode;n.flags&32&&(sl(s,""),n.flags&=-33);var i=yg(e);Ih(e,i,s);break;case 3:case 4:var l=n.stateNode.containerInfo,c=yg(e);ax(e,c,l);break;default:throw Error(O(161))}}catch(u){Ce(e,e.return,u)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Lw(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Lw(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Jo(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)yw(e,t.alternate,t),t=t.sibling}function ls(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:mr(4,t,t.return),ls(t);break;case 1:ko(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&fw(t,t.return,n),ls(t);break;case 27:cu(t.stateNode);case 26:case 5:ko(t,t.return),ls(t);break;case 22:t.memoizedState===null&&ls(t);break;case 30:ls(t);break;default:ls(t)}e=e.sibling}}function ea(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var o=t.alternate,a=e,r=t,s=r.flags;switch(r.tag){case 0:case 11:case 15:ea(a,r,n),Ou(4,r);break;case 1:if(ea(a,r,n),o=r,a=o.stateNode,typeof a.componentDidMount=="function")try{a.componentDidMount()}catch(c){Ce(o,o.return,c)}if(o=r,a=o.updateQueue,a!==null){var i=o.stateNode;try{var l=a.shared.hiddenCallbacks;if(l!==null)for(a.shared.hiddenCallbacks=null,a=0;a<l.length;a++)bk(l[a],i)}catch(c){Ce(o,o.return,c)}}n&&s&64&&dw(r),ru(r,r.return);break;case 27:mw(r);case 26:case 5:ea(a,r,n),n&&o===null&&s&4&&pw(r),ru(r,r.return);break;case 12:ea(a,r,n);break;case 31:ea(a,r,n),n&&s&4&&bw(a,r);break;case 13:ea(a,r,n),n&&s&4&&Aw(a,r);break;case 22:r.memoizedState===null&&ea(a,r,n),ru(r,r.return);break;case 30:break;default:ea(a,r,n)}t=t.sibling}}function o1(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Eu(n))}function a1(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Eu(e))}function oo(e,t,n,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Sw(e,t,n,o),t=t.sibling}function Sw(e,t,n,o){var a=t.flags;switch(t.tag){case 0:case 11:case 15:oo(e,t,n,o),a&2048&&Ou(9,t);break;case 1:oo(e,t,n,o);break;case 3:oo(e,t,n,o),a&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Eu(e)));break;case 12:if(a&2048){oo(e,t,n,o),e=t.stateNode;try{var r=t.memoizedProps,s=r.id,i=r.onPostCommit;typeof i=="function"&&i(s,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(l){Ce(t,t.return,l)}}else oo(e,t,n,o);break;case 31:oo(e,t,n,o);break;case 13:oo(e,t,n,o);break;case 23:break;case 22:r=t.stateNode,s=t.alternate,t.memoizedState!==null?r._visibility&2?oo(e,t,n,o):su(e,t):r._visibility&2?oo(e,t,n,o):(r._visibility|=2,zi(e,t,n,o,(t.subtreeFlags&10256)!==0||!1)),a&2048&&o1(s,t);break;case 24:oo(e,t,n,o),a&2048&&a1(t.alternate,t);break;default:oo(e,t,n,o)}}function zi(e,t,n,o,a){for(a=a&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var r=e,s=t,i=n,l=o,c=s.flags;switch(s.tag){case 0:case 11:case 15:zi(r,s,i,l,a),Ou(8,s);break;case 23:break;case 22:var u=s.stateNode;s.memoizedState!==null?u._visibility&2?zi(r,s,i,l,a):su(r,s):(u._visibility|=2,zi(r,s,i,l,a)),a&&c&2048&&o1(s.alternate,s);break;case 24:zi(r,s,i,l,a),a&&c&2048&&a1(s.alternate,s);break;default:zi(r,s,i,l,a)}t=t.sibling}}function su(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,o=t,a=o.flags;switch(o.tag){case 22:su(n,o),a&2048&&o1(o.alternate,o);break;case 24:su(n,o),a&2048&&a1(o.alternate,o);break;default:su(n,o)}t=t.sibling}}var Kc=8192;function Bi(e,t,n){if(e.subtreeFlags&Kc)for(e=e.child;e!==null;)kw(e,t,n),e=e.sibling}function kw(e,t,n){switch(e.tag){case 26:Bi(e,t,n),e.flags&Kc&&e.memoizedState!==null&&QR(n,ao,e.memoizedState,e.memoizedProps);break;case 5:Bi(e,t,n);break;case 3:case 4:var o=ao;ao=zh(e.stateNode.containerInfo),Bi(e,t,n),ao=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=Kc,Kc=16777216,Bi(e,t,n),Kc=o):Bi(e,t,n));break;default:Bi(e,t,n)}}function ww(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function qc(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var o=t[n];xt=o,Cw(o,e)}ww(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)_w(e),e=e.sibling}function _w(e){switch(e.tag){case 0:case 11:case 15:qc(e),e.flags&2048&&mr(9,e,e.return);break;case 3:qc(e);break;case 12:qc(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,lh(e)):qc(e);break;default:qc(e)}}function lh(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var o=t[n];xt=o,Cw(o,e)}ww(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:mr(8,t,t.return),lh(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,lh(t));break;default:lh(t)}e=e.sibling}}function Cw(e,t){for(;xt!==null;){var n=xt;switch(n.tag){case 0:case 11:case 15:mr(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var o=n.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:Eu(n.memoizedState.cache)}if(o=n.child,o!==null)o.return=n,xt=o;else e:for(n=e;xt!==null;){o=xt;var a=o.sibling,r=o.return;if(gw(o),o===n){xt=null;break e}if(a!==null){a.return=r,xt=a;break e}xt=r}}}var mR={getCacheForType:function(e){var t=Tt(ot),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Tt(ot).controller.signal}},yR=typeof WeakMap=="function"?WeakMap:Map,ve=0,Ee=null,fe=null,me=0,_e=0,sn=null,tr=!1,bl=!1,r1=!1,pa=0,Xe=0,yr=0,ps=0,s1=0,un=0,ul=0,iu=null,Zt=null,rx=!1,Jh=0,Tw=0,Eh=1/0,Mh=null,lr=null,ct=0,cr=null,dl=null,la=0,sx=0,ix=null,Iw=null,lu=0,lx=null;function hn(){return(ve&2)!==0&&me!==0?me&-me:K.T!==null?l1():N3()}function Ew(){if(un===0)if((me&536870912)===0||ge){var e=Bp;Bp<<=1,(Bp&3932160)===0&&(Bp=262144),un=e}else un=536870912;return e=yn.current,e!==null&&(e.flags|=32),un}function Xt(e,t,n){(e===Ee&&(_e===2||_e===9)||e.cancelPendingCommit!==null)&&(fl(e,0),nr(e,me,un,!1)),Cu(e,n),((ve&2)===0||e!==Ee)&&(e===Ee&&((ve&2)===0&&(ps|=n),Xe===4&&nr(e,me,un,!1)),Co(e))}function Mw(e,t,n){if((ve&6)!==0)throw Error(O(327));var o=!n&&(t&127)===0&&(t&e.expiredLanes)===0||_u(e,t),a=o?bR(e,t):xg(e,t,!0),r=o;do{if(a===0){bl&&!o&&nr(e,t,0,!1);break}else{if(n=e.current.alternate,r&&!gR(n)){a=xg(e,t,!1),r=!1;continue}if(a===2){if(r=t,e.errorRecoveryDisabledLanes&r)var s=0;else s=e.pendingLanes&-536870913,s=s!==0?s:s&536870912?536870912:0;if(s!==0){t=s;e:{var i=e;a=iu;var l=i.current.memoizedState.isDehydrated;if(l&&(fl(i,s).flags|=256),s=xg(i,s,!1),s!==2){if(r1&&!l){i.errorRecoveryDisabledLanes|=r,ps|=r,a=4;break e}r=Zt,Zt=a,r!==null&&(Zt===null?Zt=r:Zt.push.apply(Zt,r))}a=s}if(r=!1,a!==2)continue}}if(a===1){fl(e,0),nr(e,t,0,!0);break}e:{switch(o=e,r=a,r){case 0:case 1:throw Error(O(345));case 4:if((t&4194048)!==t)break;case 6:nr(o,t,un,!tr);break e;case 2:Zt=null;break;case 3:case 5:break;default:throw Error(O(329))}if((t&62914560)===t&&(a=Jh+300-dn(),10<a)){if(nr(o,t,un,!tr),Gh(o,0,!0)!==0)break e;la=t,o.timeoutHandle=$w(YS.bind(null,o,n,Zt,Mh,rx,t,un,ps,ul,tr,r,"Throttled",-0,0),a);break e}YS(o,n,Zt,Mh,rx,t,un,ps,ul,tr,r,null,-0,0)}}break}while(!0);Co(e)}function YS(e,t,n,o,a,r,s,i,l,c,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)===16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:aa},kw(t,r,d);var h=(r&62914560)===r?Jh-dn():(r&4194048)===r?Tw-dn():0;if(h=JR(d,h),h!==null){la=r,e.cancelPendingCommit=h($S.bind(null,e,t,r,n,o,a,s,i,l,u,d,null,f,p)),nr(e,r,s,!c);return}}$S(e,t,r,n,o,a,s,i,l)}function gR(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var o=0;o<n.length;o++){var a=n[o],r=a.getSnapshot;a=a.value;try{if(!mn(r(),a))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function nr(e,t,n,o){t&=~s1,t&=~ps,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var a=t;0<a;){var r=31-pn(a),s=1<<r;o[r]=-1,a&=~s}n!==0&&P3(e,n,t)}function em(){return(ve&6)===0?(Ru(0,!1),!1):!0}function i1(){if(fe!==null){if(_e===0)var e=fe.return;else e=fe,ra=Ss=null,Vx(e),tl=null,yu=0,e=fe;for(;e!==null;)uw(e.alternate,e),e=e.return;fe=null}}function fl(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,PR(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),la=0,i1(),Ee=e,fe=n=sa(e.current,null),me=t,_e=0,sn=null,tr=!1,bl=_u(e,t),r1=!1,ul=un=s1=ps=yr=Xe=0,Zt=iu=null,rx=!1,(t&8)!==0&&(t|=t&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=t;0<o;){var a=31-pn(o),r=1<<a;t|=e[a],o&=~r}return pa=t,Vh(),n}function Ow(e,t){oe=null,K.H=xu,t===xl||t===Xh?(t=CS(),_e=3):t===Fx?(t=CS(),_e=4):_e=t===t1?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,sn=t,fe===null&&(Xe=1,Ch(e,Mn(t,e.current)))}function Rw(){var e=yn.current;return e===null?!0:(me&4194048)===me?Rn===null:(me&62914560)===me||(me&536870912)!==0?e===Rn:!1}function Dw(){var e=K.H;return K.H=xu,e===null?xu:e}function Pw(){var e=K.A;return K.A=mR,e}function Oh(){Xe=4,tr||(me&4194048)!==me&&yn.current!==null||(bl=!0),(yr&134217727)===0&&(ps&134217727)===0||Ee===null||nr(Ee,me,un,!1)}function xg(e,t,n){var o=ve;ve|=2;var a=Dw(),r=Pw();(Ee!==e||me!==t)&&(Mh=null,fl(e,t)),t=!1;var s=Xe;e:do try{if(_e!==0&&fe!==null){var i=fe,l=sn;switch(_e){case 8:i1(),s=6;break e;case 3:case 2:case 9:case 6:yn.current===null&&(t=!0);var c=_e;if(_e=0,sn=null,Ki(e,i,l,c),n&&bl){s=0;break e}break;default:c=_e,_e=0,sn=null,Ki(e,i,l,c)}}xR(),s=Xe;break}catch(u){Ow(e,u)}while(!0);return t&&e.shellSuspendCounter++,ra=Ss=null,ve=o,K.H=a,K.A=r,fe===null&&(Ee=null,me=0,Vh()),s}function xR(){for(;fe!==null;)Bw(fe)}function bR(e,t){var n=ve;ve|=2;var o=Dw(),a=Pw();Ee!==e||me!==t?(Mh=null,Eh=dn()+500,fl(e,t)):bl=_u(e,t);e:do try{if(_e!==0&&fe!==null){t=fe;var r=sn;t:switch(_e){case 1:_e=0,sn=null,Ki(e,t,r,1);break;case 2:case 9:if(_S(r)){_e=0,sn=null,KS(t);break}t=function(){_e!==2&&_e!==9||Ee!==e||(_e=7),Co(e)},r.then(t,t);break e;case 3:_e=7;break e;case 4:_e=5;break e;case 7:_S(r)?(_e=0,sn=null,KS(t)):(_e=0,sn=null,Ki(e,t,r,7));break;case 5:var s=null;switch(fe.tag){case 26:s=fe.memoizedState;case 5:case 27:var i=fe;if(s?n_(s):i.stateNode.complete){_e=0,sn=null;var l=i.sibling;if(l!==null)fe=l;else{var c=i.return;c!==null?(fe=c,tm(c)):fe=null}break t}}_e=0,sn=null,Ki(e,t,r,5);break;case 6:_e=0,sn=null,Ki(e,t,r,6);break;case 8:i1(),Xe=6;break e;default:throw Error(O(462))}}AR();break}catch(u){Ow(e,u)}while(!0);return ra=Ss=null,K.H=o,K.A=a,ve=n,fe!==null?0:(Ee=null,me=0,Vh(),Xe)}function AR(){for(;fe!==null&&!qM();)Bw(fe)}function Bw(e){var t=cw(e.alternate,e,pa);e.memoizedProps=e.pendingProps,t===null?tm(e):fe=t}function KS(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=qS(n,t,t.pendingProps,t.type,void 0,me);break;case 11:t=qS(n,t,t.pendingProps,t.type.render,t.ref,me);break;case 5:Vx(t);default:uw(n,t),t=fe=uk(t,pa),t=cw(n,t,pa)}e.memoizedProps=e.pendingProps,t===null?tm(e):fe=t}function Ki(e,t,n,o){ra=Ss=null,Vx(t),tl=null,yu=0;var a=t.return;try{if(lR(e,a,t,n,me)){Xe=1,Ch(e,Mn(n,e.current)),fe=null;return}}catch(r){if(a!==null)throw fe=a,r;Xe=1,Ch(e,Mn(n,e.current)),fe=null;return}t.flags&32768?(ge||o===1?e=!0:bl||(me&536870912)!==0?e=!1:(tr=e=!0,(o===2||o===9||o===3||o===6)&&(o=yn.current,o!==null&&o.tag===13&&(o.flags|=16384))),zw(t,e)):tm(t)}function tm(e){var t=e;do{if((t.flags&32768)!==0){zw(t,tr);return}e=t.return;var n=dR(t.alternate,t,pa);if(n!==null){fe=n;return}if(t=t.sibling,t!==null){fe=t;return}fe=t=e}while(t!==null);Xe===0&&(Xe=5)}function zw(e,t){do{var n=fR(e.alternate,e);if(n!==null){n.flags&=32767,fe=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){fe=e;return}fe=e=n}while(e!==null);Xe=6,fe=null}function $S(e,t,n,o,a,r,s,i,l){e.cancelPendingCommit=null;do nm();while(ct!==0);if((ve&6)!==0)throw Error(O(327));if(t!==null){if(t===e.current)throw Error(O(177));if(r=t.lanes|t.childLanes,r|=Ox,JM(e,n,r,s,i,l),e===Ee&&(fe=Ee=null,me=0),dl=t,cr=e,la=n,sx=r,ix=a,Iw=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,kR(yh,function(){return Gw(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=K.T,K.T=null,a=Le.p,Le.p=2,s=ve,ve|=4;try{pR(e,t,n)}finally{ve=s,Le.p=a,K.T=o}}ct=1,Nw(),Fw(),Hw()}}function Nw(){if(ct===1){ct=0;var e=cr,t=dl,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=K.T,K.T=null;var o=Le.p;Le.p=2;var a=ve;ve|=4;try{vw(t,e);var r=fx,s=nk(e.containerInfo),i=r.focusedElem,l=r.selectionRange;if(s!==i&&i&&i.ownerDocument&&tk(i.ownerDocument.documentElement,i)){if(l!==null&&Mx(i)){var c=l.start,u=l.end;if(u===void 0&&(u=c),"selectionStart"in i)i.selectionStart=c,i.selectionEnd=Math.min(u,i.value.length);else{var d=i.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),h=i.textContent.length,m=Math.min(l.start,h),b=l.end===void 0?m:Math.min(l.end,h);!p.extend&&m>b&&(s=b,b=m,m=s);var y=bS(i,m),g=bS(i,b);if(y&&g&&(p.rangeCount!==1||p.anchorNode!==y.node||p.anchorOffset!==y.offset||p.focusNode!==g.node||p.focusOffset!==g.offset)){var x=d.createRange();x.setStart(y.node,y.offset),p.removeAllRanges(),m>b?(p.addRange(x),p.extend(g.node,g.offset)):(x.setEnd(g.node,g.offset),p.addRange(x))}}}}for(d=[],p=i;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<d.length;i++){var A=d[i];A.element.scrollLeft=A.left,A.element.scrollTop=A.top}}Hh=!!dx,fx=dx=null}finally{ve=a,Le.p=o,K.T=n}}e.current=t,ct=2}}function Fw(){if(ct===2){ct=0;var e=cr,t=dl,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=K.T,K.T=null;var o=Le.p;Le.p=2;var a=ve;ve|=4;try{yw(e,t.alternate,t)}finally{ve=a,Le.p=o,K.T=n}}ct=3}}function Hw(){if(ct===4||ct===3){ct=0,WM();var e=cr,t=dl,n=la,o=Iw;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?ct=5:(ct=0,dl=cr=null,Uw(e,e.pendingLanes));var a=e.pendingLanes;if(a===0&&(lr=null),kx(n),t=t.stateNode,fn&&typeof fn.onCommitFiberRoot=="function")try{fn.onCommitFiberRoot(wu,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=K.T,a=Le.p,Le.p=2,K.T=null;try{for(var r=e.onRecoverableError,s=0;s<o.length;s++){var i=o[s];r(i.value,{componentStack:i.stack})}}finally{K.T=t,Le.p=a}}(la&3)!==0&&nm(),Co(e),a=e.pendingLanes,(n&261930)!==0&&(a&42)!==0?e===lx?lu++:(lu=0,lx=e):lu=0,Ru(0,!1)}}function Uw(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Eu(t)))}function nm(){return Nw(),Fw(),Hw(),Gw()}function Gw(){if(ct!==5)return!1;var e=cr,t=sx;sx=0;var n=kx(la),o=K.T,a=Le.p;try{Le.p=32>n?32:n,K.T=null,n=ix,ix=null;var r=cr,s=la;if(ct=0,dl=cr=null,la=0,(ve&6)!==0)throw Error(O(331));var i=ve;if(ve|=4,_w(r.current),Sw(r,r.current,s,n),ve=i,Ru(0,!1),fn&&typeof fn.onPostCommitFiberRoot=="function")try{fn.onPostCommitFiberRoot(wu,r)}catch{}return!0}finally{Le.p=a,K.T=o,Uw(e,t)}}function QS(e,t,n){t=Mn(n,t),t=tx(e.stateNode,t,2),e=ir(e,t,2),e!==null&&(Cu(e,2),Co(e))}function Ce(e,t,n){if(e.tag===3)QS(e,e,n);else for(;t!==null;){if(t.tag===3){QS(t,e,n);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(lr===null||!lr.has(o))){e=Mn(n,e),n=ow(2),o=ir(t,n,2),o!==null&&(aw(n,o,t,e),Cu(o,2),Co(o));break}}t=t.return}}function bg(e,t,n){var o=e.pingCache;if(o===null){o=e.pingCache=new yR;var a=new Set;o.set(t,a)}else a=o.get(t),a===void 0&&(a=new Set,o.set(t,a));a.has(n)||(r1=!0,a.add(n),e=vR.bind(null,e,t,n),t.then(e,e))}function vR(e,t,n){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ee===e&&(me&n)===n&&(Xe===4||Xe===3&&(me&62914560)===me&&300>dn()-Jh?(ve&2)===0&&fl(e,0):s1|=n,ul===me&&(ul=0)),Co(e)}function qw(e,t){t===0&&(t=D3()),e=Ls(e,t),e!==null&&(Cu(e,t),Co(e))}function LR(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),qw(e,n)}function SR(e,t){var n=0;switch(e.tag){case 31:case 13:var o=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(O(314))}o!==null&&o.delete(t),qw(e,n)}function kR(e,t){return Lx(e,t)}var Rh=null,Ni=null,cx=!1,Dh=!1,Ag=!1,or=0;function Co(e){e!==Ni&&e.next===null&&(Ni===null?Rh=Ni=e:Ni=Ni.next=e),Dh=!0,cx||(cx=!0,_R())}function Ru(e,t){if(!Ag&&Dh){Ag=!0;do for(var n=!1,o=Rh;o!==null;){if(!t)if(e!==0){var a=o.pendingLanes;if(a===0)var r=0;else{var s=o.suspendedLanes,i=o.pingedLanes;r=(1<<31-pn(42|e)+1)-1,r&=a&~(s&~i),r=r&201326741?r&201326741|1:r?r|2:0}r!==0&&(n=!0,JS(o,r))}else r=me,r=Gh(o,o===Ee?r:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(r&3)===0||_u(o,r)||(n=!0,JS(o,r));o=o.next}while(n);Ag=!1}}function wR(){Ww()}function Ww(){Dh=cx=!1;var e=0;or!==0&&DR()&&(e=or);for(var t=dn(),n=null,o=Rh;o!==null;){var a=o.next,r=jw(o,t);r===0?(o.next=null,n===null?Rh=a:n.next=a,a===null&&(Ni=n)):(n=o,(e!==0||(r&3)!==0)&&(Dh=!0)),o=a}ct!==0&&ct!==5||Ru(e,!1),or!==0&&(or=0)}function jw(e,t){for(var n=e.suspendedLanes,o=e.pingedLanes,a=e.expirationTimes,r=e.pendingLanes&-62914561;0<r;){var s=31-pn(r),i=1<<s,l=a[s];l===-1?((i&n)===0||(i&o)!==0)&&(a[s]=QM(i,t)):l<=t&&(e.expiredLanes|=i),r&=~i}if(t=Ee,n=me,n=Gh(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,n===0||e===t&&(_e===2||_e===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&Yy(o),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||_u(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(o!==null&&Yy(o),kx(n)){case 2:case 8:n=O3;break;case 32:n=yh;break;case 268435456:n=R3;break;default:n=yh}return o=Vw.bind(null,e),n=Lx(n,o),e.callbackPriority=t,e.callbackNode=n,t}return o!==null&&o!==null&&Yy(o),e.callbackPriority=2,e.callbackNode=null,2}function Vw(e,t){if(ct!==0&&ct!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(nm()&&e.callbackNode!==n)return null;var o=me;return o=Gh(e,e===Ee?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Mw(e,o,t),jw(e,dn()),e.callbackNode!=null&&e.callbackNode===n?Vw.bind(null,e):null)}function JS(e,t){if(nm())return null;Mw(e,t,!0)}function _R(){BR(function(){(ve&6)!==0?Lx(M3,wR):Ww()})}function l1(){if(or===0){var e=il;e===0&&(e=Pp,Pp<<=1,(Pp&261888)===0&&(Pp=256)),or=e}return or}function e3(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Jp(""+e)}function t3(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function CR(e,t,n,o,a){if(t==="submit"&&n&&n.stateNode===a){var r=e3((a[Yt]||null).action),s=o.submitter;s&&(t=(t=s[Yt]||null)?e3(t.formAction):s.getAttribute("formAction"),t!==null&&(r=t,s=null));var i=new qh("action","action",null,o,a);e.push({event:i,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(or!==0){var l=s?t3(a,s):new FormData(a);Jg(n,{pending:!0,data:l,method:a.method,action:r},null,l)}}else typeof r=="function"&&(i.preventDefault(),l=s?t3(a,s):new FormData(a),Jg(n,{pending:!0,data:l,method:a.method,action:r},r,l))},currentTarget:a}]})}}for(Zp=0;Zp<Ug.length;Zp++)Xp=Ug[Zp],n3=Xp.toLowerCase(),o3=Xp[0].toUpperCase()+Xp.slice(1),ro(n3,"on"+o3);var Xp,n3,o3,Zp;ro(ak,"onAnimationEnd");ro(rk,"onAnimationIteration");ro(sk,"onAnimationStart");ro("dblclick","onDoubleClick");ro("focusin","onFocus");ro("focusout","onBlur");ro(jO,"onTransitionRun");ro(VO,"onTransitionStart");ro(ZO,"onTransitionCancel");ro(ik,"onTransitionEnd");rl("onMouseEnter",["mouseout","mouseover"]);rl("onMouseLeave",["mouseout","mouseover"]);rl("onPointerEnter",["pointerout","pointerover"]);rl("onPointerLeave",["pointerout","pointerover"]);bs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));bs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));bs("onBeforeInput",["compositionend","keypress","textInput","paste"]);bs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));bs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));bs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var bu="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),TR=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(bu));function Zw(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var o=e[n],a=o.event;o=o.listeners;e:{var r=void 0;if(t)for(var s=o.length-1;0<=s;s--){var i=o[s],l=i.instance,c=i.currentTarget;if(i=i.listener,l!==r&&a.isPropagationStopped())break e;r=i,a.currentTarget=c;try{r(a)}catch(u){xh(u)}a.currentTarget=null,r=l}else for(s=0;s<o.length;s++){if(i=o[s],l=i.instance,c=i.currentTarget,i=i.listener,l!==r&&a.isPropagationStopped())break e;r=i,a.currentTarget=c;try{r(a)}catch(u){xh(u)}a.currentTarget=null,r=l}}}}function de(e,t){var n=t[Rg];n===void 0&&(n=t[Rg]=new Set);var o=e+"__bubble";n.has(o)||(Xw(t,e,2,!1),n.add(o))}function vg(e,t,n){var o=0;t&&(o|=4),Xw(n,e,o,t)}var Yp="_reactListening"+Math.random().toString(36).slice(2);function c1(e){if(!e[Yp]){e[Yp]=!0,F3.forEach(function(n){n!=="selectionchange"&&(TR.has(n)||vg(n,!1,e),vg(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Yp]||(t[Yp]=!0,vg("selectionchange",!1,t))}}function Xw(e,t,n,o){switch(i_(t)){case 2:var a=nD;break;case 8:a=oD;break;default:a=p1}n=a.bind(null,t,n,e),a=void 0,!Ng||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),o?a!==void 0?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):a!==void 0?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function Lg(e,t,n,o,a){var r=o;if((t&1)===0&&(t&2)===0&&o!==null)e:for(;;){if(o===null)return;var s=o.tag;if(s===3||s===4){var i=o.stateNode.containerInfo;if(i===a)break;if(s===4)for(s=o.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===a)return;s=s.return}for(;i!==null;){if(s=Ui(i),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){o=r=s;continue e}i=i.parentNode}}o=o.return}Z3(function(){var c=r,u=Cx(n),d=[];e:{var f=lk.get(e);if(f!==void 0){var p=qh,h=e;switch(e){case"keypress":if(th(n)===0)break e;case"keydown":case"keyup":p=SO;break;case"focusin":h="focus",p=eg;break;case"focusout":h="blur",p=eg;break;case"beforeblur":case"afterblur":p=eg;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=uS;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=dO;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=_O;break;case ak:case rk:case sk:p=hO;break;case ik:p=TO;break;case"scroll":case"scrollend":p=cO;break;case"wheel":p=EO;break;case"copy":case"cut":case"paste":p=yO;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=fS;break;case"toggle":case"beforetoggle":p=OO}var m=(t&4)!==0,b=!m&&(e==="scroll"||e==="scrollend"),y=m?f!==null?f+"Capture":null:f;m=[];for(var g=c,x;g!==null;){var A=g;if(x=A.stateNode,A=A.tag,A!==5&&A!==26&&A!==27||x===null||y===null||(A=du(g,y),A!=null&&m.push(Au(g,A,x))),b)break;g=g.return}0<m.length&&(f=new p(f,h,null,n,u),d.push({event:f,listeners:m}))}}if((t&7)===0){e:{if(f=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",f&&n!==zg&&(h=n.relatedTarget||n.fromElement)&&(Ui(h)||h[ml]))break e;if((p||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,p?(h=n.relatedTarget||n.toElement,p=c,h=h?Ui(h):null,h!==null&&(b=ku(h),m=h.tag,h!==b||m!==5&&m!==27&&m!==6)&&(h=null)):(p=null,h=c),p!==h)){if(m=uS,A="onMouseLeave",y="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(m=fS,A="onPointerLeave",y="onPointerEnter",g="pointer"),b=p==null?f:Xc(p),x=h==null?f:Xc(h),f=new m(A,g+"leave",p,n,u),f.target=b,f.relatedTarget=x,A=null,Ui(u)===c&&(m=new m(y,g+"enter",h,n,u),m.target=x,m.relatedTarget=b,A=m),b=A,p&&h)t:{for(m=IR,y=p,g=h,x=0,A=y;A;A=m(A))x++;A=0;for(var C=g;C;C=m(C))A++;for(;0<x-A;)y=m(y),x--;for(;0<A-x;)g=m(g),A--;for(;x--;){if(y===g||g!==null&&y===g.alternate){m=y;break t}y=m(y),g=m(g)}m=null}else m=null;p!==null&&a3(d,f,p,m,!1),h!==null&&b!==null&&a3(d,b,h,m,!0)}}e:{if(f=c?Xc(c):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var _=yS;else if(mS(f))if(J3)_=GO;else{_=HO;var v=FO}else p=f.nodeName,!p||p.toLowerCase()!=="input"||f.type!=="checkbox"&&f.type!=="radio"?c&&_x(c.elementType)&&(_=yS):_=UO;if(_&&(_=_(e,c))){Q3(d,_,n,u);break e}v&&v(e,f,c),e==="focusout"&&c&&f.type==="number"&&c.memoizedProps.value!=null&&Bg(f,"number",f.value)}switch(v=c?Xc(c):window,e){case"focusin":(mS(v)||v.contentEditable==="true")&&(Wi=v,Fg=c,Jc=null);break;case"focusout":Jc=Fg=Wi=null;break;case"mousedown":Hg=!0;break;case"contextmenu":case"mouseup":case"dragend":Hg=!1,AS(d,n,u);break;case"selectionchange":if(WO)break;case"keydown":case"keyup":AS(d,n,u)}var I;if(Ex)e:{switch(e){case"compositionstart":var k="onCompositionStart";break e;case"compositionend":k="onCompositionEnd";break e;case"compositionupdate":k="onCompositionUpdate";break e}k=void 0}else qi?K3(e,n)&&(k="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(k="onCompositionStart");k&&(Y3&&n.locale!=="ko"&&(qi||k!=="onCompositionStart"?k==="onCompositionEnd"&&qi&&(I=X3()):(er=u,Tx="value"in er?er.value:er.textContent,qi=!0)),v=Ph(c,k),0<v.length&&(k=new dS(k,e,null,n,u),d.push({event:k,listeners:v}),I?k.data=I:(I=$3(n),I!==null&&(k.data=I)))),(I=DO?PO(e,n):BO(e,n))&&(k=Ph(c,"onBeforeInput"),0<k.length&&(v=new dS("onBeforeInput","beforeinput",null,n,u),d.push({event:v,listeners:k}),v.data=I)),CR(d,e,c,n,u)}Zw(d,t)})}function Au(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ph(e,t){for(var n=t+"Capture",o=[];e!==null;){var a=e,r=a.stateNode;if(a=a.tag,a!==5&&a!==26&&a!==27||r===null||(a=du(e,n),a!=null&&o.unshift(Au(e,a,r)),a=du(e,t),a!=null&&o.push(Au(e,a,r))),e.tag===3)return o;e=e.return}return[]}function IR(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function a3(e,t,n,o,a){for(var r=t._reactName,s=[];n!==null&&n!==o;){var i=n,l=i.alternate,c=i.stateNode;if(i=i.tag,l!==null&&l===o)break;i!==5&&i!==26&&i!==27||c===null||(l=c,a?(c=du(n,r),c!=null&&s.unshift(Au(n,c,l))):a||(c=du(n,r),c!=null&&s.push(Au(n,c,l)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var ER=/\r\n?/g,MR=/\u0000|\uFFFD/g;function r3(e){return(typeof e=="string"?e:""+e).replace(ER,`
|
|
9
|
-
`).replace(MR,"")}function Yw(e,t){return t=r3(t),r3(e)===t}function Te(e,t,n,o,a,r){switch(n){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||sl(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&sl(e,""+o);break;case"className":Np(e,"class",o);break;case"tabIndex":Np(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":Np(e,n,o);break;case"style":V3(e,o,r);break;case"data":if(t!=="object"){Np(e,"data",o);break}case"src":case"href":if(o===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(n);break}o=Jp(""+o),e.setAttribute(n,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(n,"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 r=="function"&&(n==="formAction"?(t!=="input"&&Te(e,t,"name",a.name,a,null),Te(e,t,"formEncType",a.formEncType,a,null),Te(e,t,"formMethod",a.formMethod,a,null),Te(e,t,"formTarget",a.formTarget,a,null)):(Te(e,t,"encType",a.encType,a,null),Te(e,t,"method",a.method,a,null),Te(e,t,"target",a.target,a,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(n);break}o=Jp(""+o),e.setAttribute(n,o);break;case"onClick":o!=null&&(e.onclick=aa);break;case"onScroll":o!=null&&de("scroll",e);break;case"onScrollEnd":o!=null&&de("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(O(61));if(n=o.__html,n!=null){if(a.children!=null)throw Error(O(60));e.innerHTML=n}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}n=Jp(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,""+o):e.removeAttribute(n);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":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":o===!0?e.setAttribute(n,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,o):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(n,o):e.removeAttribute(n);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(n):e.setAttribute(n,o);break;case"popover":de("beforetoggle",e),de("toggle",e),Qp(e,"popover",o);break;case"xlinkActuate":Ko(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Ko(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Ko(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Ko(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Ko(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Ko(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Ko(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Ko(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Ko(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Qp(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=iO.get(n)||n,Qp(e,n,o))}}function ux(e,t,n,o,a,r){switch(n){case"style":V3(e,o,r);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(O(61));if(n=o.__html,n!=null){if(a.children!=null)throw Error(O(60));e.innerHTML=n}}break;case"children":typeof o=="string"?sl(e,o):(typeof o=="number"||typeof o=="bigint")&&sl(e,""+o);break;case"onScroll":o!=null&&de("scroll",e);break;case"onScrollEnd":o!=null&&de("scrollend",e);break;case"onClick":o!=null&&(e.onclick=aa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!H3.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(a=n.endsWith("Capture"),t=n.slice(2,a?n.length-7:void 0),r=e[Yt]||null,r=r!=null?r[n]:null,typeof r=="function"&&e.removeEventListener(t,r,a),typeof o=="function")){typeof r!="function"&&r!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,o,a);break e}n in e?e[n]=o:o===!0?e.setAttribute(n,""):Qp(e,n,o)}}}function It(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":de("error",e),de("load",e);var o=!1,a=!1,r;for(r in n)if(n.hasOwnProperty(r)){var s=n[r];if(s!=null)switch(r){case"src":o=!0;break;case"srcSet":a=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(O(137,t));default:Te(e,t,r,s,n,null)}}a&&Te(e,t,"srcSet",n.srcSet,n,null),o&&Te(e,t,"src",n.src,n,null);return;case"input":de("invalid",e);var i=r=s=a=null,l=null,c=null;for(o in n)if(n.hasOwnProperty(o)){var u=n[o];if(u!=null)switch(o){case"name":a=u;break;case"type":s=u;break;case"checked":l=u;break;case"defaultChecked":c=u;break;case"value":r=u;break;case"defaultValue":i=u;break;case"children":case"dangerouslySetInnerHTML":if(u!=null)throw Error(O(137,t));break;default:Te(e,t,o,u,n,null)}}q3(e,r,i,l,c,s,a,!1);return;case"select":de("invalid",e),o=s=r=null;for(a in n)if(n.hasOwnProperty(a)&&(i=n[a],i!=null))switch(a){case"value":r=i;break;case"defaultValue":s=i;break;case"multiple":o=i;default:Te(e,t,a,i,n,null)}t=r,n=s,e.multiple=!!o,t!=null?Qi(e,!!o,t,!1):n!=null&&Qi(e,!!o,n,!0);return;case"textarea":de("invalid",e),r=a=o=null;for(s in n)if(n.hasOwnProperty(s)&&(i=n[s],i!=null))switch(s){case"value":o=i;break;case"defaultValue":a=i;break;case"children":r=i;break;case"dangerouslySetInnerHTML":if(i!=null)throw Error(O(91));break;default:Te(e,t,s,i,n,null)}j3(e,o,a,r);return;case"option":for(l in n)if(n.hasOwnProperty(l)&&(o=n[l],o!=null))switch(l){case"selected":e.selected=o&&typeof o!="function"&&typeof o!="symbol";break;default:Te(e,t,l,o,n,null)}return;case"dialog":de("beforetoggle",e),de("toggle",e),de("cancel",e),de("close",e);break;case"iframe":case"object":de("load",e);break;case"video":case"audio":for(o=0;o<bu.length;o++)de(bu[o],e);break;case"image":de("error",e),de("load",e);break;case"details":de("toggle",e);break;case"embed":case"source":case"link":de("error",e),de("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(c in n)if(n.hasOwnProperty(c)&&(o=n[c],o!=null))switch(c){case"children":case"dangerouslySetInnerHTML":throw Error(O(137,t));default:Te(e,t,c,o,n,null)}return;default:if(_x(t)){for(u in n)n.hasOwnProperty(u)&&(o=n[u],o!==void 0&&ux(e,t,u,o,n,void 0));return}}for(i in n)n.hasOwnProperty(i)&&(o=n[i],o!=null&&Te(e,t,i,o,n,null))}function OR(e,t,n,o){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,r=null,s=null,i=null,l=null,c=null,u=null;for(p in n){var d=n[p];if(n.hasOwnProperty(p)&&d!=null)switch(p){case"checked":break;case"value":break;case"defaultValue":l=d;default:o.hasOwnProperty(p)||Te(e,t,p,null,o,d)}}for(var f in o){var p=o[f];if(d=n[f],o.hasOwnProperty(f)&&(p!=null||d!=null))switch(f){case"type":r=p;break;case"name":a=p;break;case"checked":c=p;break;case"defaultChecked":u=p;break;case"value":s=p;break;case"defaultValue":i=p;break;case"children":case"dangerouslySetInnerHTML":if(p!=null)throw Error(O(137,t));break;default:p!==d&&Te(e,t,f,p,o,d)}}Pg(e,s,i,l,c,u,r,a);return;case"select":p=s=i=f=null;for(r in n)if(l=n[r],n.hasOwnProperty(r)&&l!=null)switch(r){case"value":break;case"multiple":p=l;default:o.hasOwnProperty(r)||Te(e,t,r,null,o,l)}for(a in o)if(r=o[a],l=n[a],o.hasOwnProperty(a)&&(r!=null||l!=null))switch(a){case"value":f=r;break;case"defaultValue":i=r;break;case"multiple":s=r;default:r!==l&&Te(e,t,a,r,o,l)}t=i,n=s,o=p,f!=null?Qi(e,!!n,f,!1):!!o!=!!n&&(t!=null?Qi(e,!!n,t,!0):Qi(e,!!n,n?[]:"",!1));return;case"textarea":p=f=null;for(i in n)if(a=n[i],n.hasOwnProperty(i)&&a!=null&&!o.hasOwnProperty(i))switch(i){case"value":break;case"children":break;default:Te(e,t,i,null,o,a)}for(s in o)if(a=o[s],r=n[s],o.hasOwnProperty(s)&&(a!=null||r!=null))switch(s){case"value":f=a;break;case"defaultValue":p=a;break;case"children":break;case"dangerouslySetInnerHTML":if(a!=null)throw Error(O(91));break;default:a!==r&&Te(e,t,s,a,o,r)}W3(e,f,p);return;case"option":for(var h in n)if(f=n[h],n.hasOwnProperty(h)&&f!=null&&!o.hasOwnProperty(h))switch(h){case"selected":e.selected=!1;break;default:Te(e,t,h,null,o,f)}for(l in o)if(f=o[l],p=n[l],o.hasOwnProperty(l)&&f!==p&&(f!=null||p!=null))switch(l){case"selected":e.selected=f&&typeof f!="function"&&typeof f!="symbol";break;default:Te(e,t,l,f,o,p)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var m in n)f=n[m],n.hasOwnProperty(m)&&f!=null&&!o.hasOwnProperty(m)&&Te(e,t,m,null,o,f);for(c in o)if(f=o[c],p=n[c],o.hasOwnProperty(c)&&f!==p&&(f!=null||p!=null))switch(c){case"children":case"dangerouslySetInnerHTML":if(f!=null)throw Error(O(137,t));break;default:Te(e,t,c,f,o,p)}return;default:if(_x(t)){for(var b in n)f=n[b],n.hasOwnProperty(b)&&f!==void 0&&!o.hasOwnProperty(b)&&ux(e,t,b,void 0,o,f);for(u in o)f=o[u],p=n[u],!o.hasOwnProperty(u)||f===p||f===void 0&&p===void 0||ux(e,t,u,f,o,p);return}}for(var y in n)f=n[y],n.hasOwnProperty(y)&&f!=null&&!o.hasOwnProperty(y)&&Te(e,t,y,null,o,f);for(d in o)f=o[d],p=n[d],!o.hasOwnProperty(d)||f===p||f==null&&p==null||Te(e,t,d,f,o,p)}function s3(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function RR(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),o=0;o<n.length;o++){var a=n[o],r=a.transferSize,s=a.initiatorType,i=a.duration;if(r&&i&&s3(s)){for(s=0,i=a.responseEnd,o+=1;o<n.length;o++){var l=n[o],c=l.startTime;if(c>i)break;var u=l.transferSize,d=l.initiatorType;u&&s3(d)&&(l=l.responseEnd,s+=u*(l<i?1:(i-c)/(l-c)))}if(--o,t+=8*(r+s)/(a.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var dx=null,fx=null;function Bh(e){return e.nodeType===9?e:e.ownerDocument}function i3(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Kw(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function px(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Sg=null;function DR(){var e=window.event;return e&&e.type==="popstate"?e===Sg?!1:(Sg=e,!0):(Sg=null,!1)}var $w=typeof setTimeout=="function"?setTimeout:void 0,PR=typeof clearTimeout=="function"?clearTimeout:void 0,l3=typeof Promise=="function"?Promise:void 0,BR=typeof queueMicrotask=="function"?queueMicrotask:typeof l3<"u"?function(e){return l3.resolve(null).then(e).catch(zR)}:$w;function zR(e){setTimeout(function(){throw e})}function xr(e){return e==="head"}function c3(e,t){var n=t,o=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&a.nodeType===8)if(n=a.data,n==="/$"||n==="/&"){if(o===0){e.removeChild(a),hl(t);return}o--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")o++;else if(n==="html")cu(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,cu(n);for(var r=n.firstChild;r;){var s=r.nextSibling,i=r.nodeName;r[Tu]||i==="SCRIPT"||i==="STYLE"||i==="LINK"&&r.rel.toLowerCase()==="stylesheet"||n.removeChild(r),r=s}}else n==="body"&&cu(e.ownerDocument.body);n=a}while(n);hl(t)}function u3(e,t){var n=e;e=0;do{var o=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),o&&o.nodeType===8)if(n=o.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=o}while(n)}function hx(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":hx(n),wx(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function NR(e,t,n,o){for(;e.nodeType===1;){var a=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[Tu])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(r=e.getAttribute("rel"),r==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(r!==a.rel||e.getAttribute("href")!==(a.href==null||a.href===""?null:a.href)||e.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin)||e.getAttribute("title")!==(a.title==null?null:a.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(r=e.getAttribute("src"),(r!==(a.src==null?null:a.src)||e.getAttribute("type")!==(a.type==null?null:a.type)||e.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin))&&r&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var r=a.name==null?null:""+a.name;if(a.type==="hidden"&&e.getAttribute("name")===r)return e}else return e;if(e=Dn(e.nextSibling),e===null)break}return null}function FR(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Dn(e.nextSibling),e===null))return null;return e}function Qw(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Dn(e.nextSibling),e===null))return null;return e}function mx(e){return e.data==="$?"||e.data==="$~"}function yx(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function HR(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var o=function(){t(),n.removeEventListener("DOMContentLoaded",o)};n.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Dn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var gx=null;function d3(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return Dn(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function f3(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(t===0)return e;t--}else n!=="/$"&&n!=="/&"||t++}e=e.previousSibling}return null}function Jw(e,t,n){switch(t=Bh(n),e){case"html":if(e=t.documentElement,!e)throw Error(O(452));return e;case"head":if(e=t.head,!e)throw Error(O(453));return e;case"body":if(e=t.body,!e)throw Error(O(454));return e;default:throw Error(O(451))}}function cu(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);wx(e)}var Pn=new Map,p3=new Set;function zh(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var ha=Le.d;Le.d={f:UR,r:GR,D:qR,C:WR,L:jR,m:VR,X:XR,S:ZR,M:YR};function UR(){var e=ha.f(),t=em();return e||t}function GR(e){var t=yl(e);t!==null&&t.tag===5&&t.type==="form"?Vk(t):ha.r(e)}var Al=typeof document>"u"?null:document;function e_(e,t,n){var o=Al;if(o&&typeof t=="string"&&t){var a=En(t);a='link[rel="'+e+'"][href="'+a+'"]',typeof n=="string"&&(a+='[crossorigin="'+n+'"]'),p3.has(a)||(p3.add(a),e={rel:e,crossOrigin:n,href:t},o.querySelector(a)===null&&(t=o.createElement("link"),It(t,"link",e),bt(t),o.head.appendChild(t)))}}function qR(e){ha.D(e),e_("dns-prefetch",e,null)}function WR(e,t){ha.C(e,t),e_("preconnect",e,t)}function jR(e,t,n){ha.L(e,t,n);var o=Al;if(o&&e&&t){var a='link[rel="preload"][as="'+En(t)+'"]';t==="image"&&n&&n.imageSrcSet?(a+='[imagesrcset="'+En(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(a+='[imagesizes="'+En(n.imageSizes)+'"]')):a+='[href="'+En(e)+'"]';var r=a;switch(t){case"style":r=pl(e);break;case"script":r=vl(e)}Pn.has(r)||(e=ze({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),Pn.set(r,e),o.querySelector(a)!==null||t==="style"&&o.querySelector(Du(r))||t==="script"&&o.querySelector(Pu(r))||(t=o.createElement("link"),It(t,"link",e),bt(t),o.head.appendChild(t)))}}function VR(e,t){ha.m(e,t);var n=Al;if(n&&e){var o=t&&typeof t.as=="string"?t.as:"script",a='link[rel="modulepreload"][as="'+En(o)+'"][href="'+En(e)+'"]',r=a;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":r=vl(e)}if(!Pn.has(r)&&(e=ze({rel:"modulepreload",href:e},t),Pn.set(r,e),n.querySelector(a)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Pu(r)))return}o=n.createElement("link"),It(o,"link",e),bt(o),n.head.appendChild(o)}}}function ZR(e,t,n){ha.S(e,t,n);var o=Al;if(o&&e){var a=$i(o).hoistableStyles,r=pl(e);t=t||"default";var s=a.get(r);if(!s){var i={loading:0,preload:null};if(s=o.querySelector(Du(r)))i.loading=5;else{e=ze({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Pn.get(r))&&u1(e,n);var l=s=o.createElement("link");bt(l),It(l,"link",e),l._p=new Promise(function(c,u){l.onload=c,l.onerror=u}),l.addEventListener("load",function(){i.loading|=1}),l.addEventListener("error",function(){i.loading|=2}),i.loading|=4,ch(s,t,o)}s={type:"stylesheet",instance:s,count:1,state:i},a.set(r,s)}}}function XR(e,t){ha.X(e,t);var n=Al;if(n&&e){var o=$i(n).hoistableScripts,a=vl(e),r=o.get(a);r||(r=n.querySelector(Pu(a)),r||(e=ze({src:e,async:!0},t),(t=Pn.get(a))&&d1(e,t),r=n.createElement("script"),bt(r),It(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function YR(e,t){ha.M(e,t);var n=Al;if(n&&e){var o=$i(n).hoistableScripts,a=vl(e),r=o.get(a);r||(r=n.querySelector(Pu(a)),r||(e=ze({src:e,async:!0,type:"module"},t),(t=Pn.get(a))&&d1(e,t),r=n.createElement("script"),bt(r),It(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function h3(e,t,n,o){var a=(a=ar.current)?zh(a):null;if(!a)throw Error(O(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=pl(n.href),n=$i(a).hoistableStyles,o=n.get(t),o||(o={type:"style",instance:null,count:0,state:null},n.set(t,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=pl(n.href);var r=$i(a).hoistableStyles,s=r.get(e);if(s||(a=a.ownerDocument||a,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},r.set(e,s),(r=a.querySelector(Du(e)))&&!r._p&&(s.instance=r,s.state.loading=5),Pn.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Pn.set(e,n),r||KR(a,e,n,s.state))),t&&o===null)throw Error(O(528,""));return s}if(t&&o!==null)throw Error(O(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=vl(n),n=$i(a).hoistableScripts,o=n.get(t),o||(o={type:"script",instance:null,count:0,state:null},n.set(t,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(O(444,e))}}function pl(e){return'href="'+En(e)+'"'}function Du(e){return'link[rel="stylesheet"]['+e+"]"}function t_(e){return ze({},e,{"data-precedence":e.precedence,precedence:null})}function KR(e,t,n,o){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?o.loading=1:(t=e.createElement("link"),o.preload=t,t.addEventListener("load",function(){return o.loading|=1}),t.addEventListener("error",function(){return o.loading|=2}),It(t,"link",n),bt(t),e.head.appendChild(t))}function vl(e){return'[src="'+En(e)+'"]'}function Pu(e){return"script[async]"+e}function m3(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+En(n.href)+'"]');if(o)return t.instance=o,bt(o),o;var a=ze({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),bt(o),It(o,"style",a),ch(o,n.precedence,e),t.instance=o;case"stylesheet":a=pl(n.href);var r=e.querySelector(Du(a));if(r)return t.state.loading|=4,t.instance=r,bt(r),r;o=t_(n),(a=Pn.get(a))&&u1(o,a),r=(e.ownerDocument||e).createElement("link"),bt(r);var s=r;return s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),It(r,"link",o),t.state.loading|=4,ch(r,n.precedence,e),t.instance=r;case"script":return r=vl(n.src),(a=e.querySelector(Pu(r)))?(t.instance=a,bt(a),a):(o=n,(a=Pn.get(r))&&(o=ze({},n),d1(o,a)),e=e.ownerDocument||e,a=e.createElement("script"),bt(a),It(a,"link",o),e.head.appendChild(a),t.instance=a);case"void":return null;default:throw Error(O(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(o=t.instance,t.state.loading|=4,ch(o,n.precedence,e));return t.instance}function ch(e,t,n){for(var o=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=o.length?o[o.length-1]:null,r=a,s=0;s<o.length;s++){var i=o[s];if(i.dataset.precedence===t)r=i;else if(r!==a)break}r?r.parentNode.insertBefore(e,r.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function u1(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function d1(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var uh=null;function y3(e,t,n){if(uh===null){var o=new Map,a=uh=new Map;a.set(n,o)}else a=uh,o=a.get(n),o||(o=new Map,a.set(n,o));if(o.has(e))return o;for(o.set(e,null),n=n.getElementsByTagName(e),a=0;a<n.length;a++){var r=n[a];if(!(r[Tu]||r[_t]||e==="link"&&r.getAttribute("rel")==="stylesheet")&&r.namespaceURI!=="http://www.w3.org/2000/svg"){var s=r.getAttribute(t)||"";s=e+s;var i=o.get(s);i?i.push(r):o.set(s,[r])}}return o}function g3(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function $R(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function n_(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function QR(e,t,n,o){if(n.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var a=pl(o.href),r=t.querySelector(Du(a));if(r){t=r._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=r,bt(r);return}r=t.ownerDocument||t,o=t_(o),(a=Pn.get(a))&&u1(o,a),r=r.createElement("link"),bt(r);var s=r;s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),It(r,"link",o),n.instance=r}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(e.count++,n=Nh.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var kg=0;function JR(e,t){return e.stylesheets&&e.count===0&&dh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var o=setTimeout(function(){if(e.stylesheets&&dh(e,e.stylesheets),e.unsuspend){var r=e.unsuspend;e.unsuspend=null,r()}},6e4+t);0<e.imgBytes&&kg===0&&(kg=62500*RR());var a=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&dh(e,e.stylesheets),e.unsuspend)){var r=e.unsuspend;e.unsuspend=null,r()}},(e.imgBytes>kg?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(a)}}:null}function Nh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)dh(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Fh=null;function dh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Fh=new Map,t.forEach(eD,e),Fh=null,Nh.call(e))}function eD(e,t){if(!(t.state.loading&4)){var n=Fh.get(e);if(n)var o=n.get(null);else{n=new Map,Fh.set(e,n);for(var a=e.querySelectorAll("link[data-precedence],style[data-precedence]"),r=0;r<a.length;r++){var s=a[r];(s.nodeName==="LINK"||s.getAttribute("media")!=="not all")&&(n.set(s.dataset.precedence,s),o=s)}o&&n.set(null,o)}a=t.instance,s=a.getAttribute("data-precedence"),r=n.get(s)||o,r===o&&n.set(null,a),n.set(s,a),this.count++,o=Nh.bind(this),a.addEventListener("load",o),a.addEventListener("error",o),r?r.parentNode.insertBefore(a,r.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(a,e.firstChild)),t.state.loading|=4}}var vu={$$typeof:oa,Provider:null,Consumer:null,_currentValue:cs,_currentValue2:cs,_threadCount:0};function tD(e,t,n,o,a,r,s,i,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ky(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ky(0),this.hiddenUpdates=Ky(null),this.identifierPrefix=o,this.onUncaughtError=a,this.onCaughtError=r,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function o_(e,t,n,o,a,r,s,i,l,c,u,d){return e=new tD(e,t,n,s,l,c,u,d,i),t=1,r===!0&&(t|=24),r=cn(3,null,null,t),e.current=r,r.stateNode=e,t=zx(),t.refCount++,e.pooledCache=t,t.refCount++,r.memoizedState={element:o,isDehydrated:n,cache:t},Hx(r),e}function a_(e){return e?(e=Zi,e):Zi}function r_(e,t,n,o,a,r){a=a_(a),o.context===null?o.context=a:o.pendingContext=a,o=sr(t),o.payload={element:n},r=r===void 0?null:r,r!==null&&(o.callback=r),n=ir(e,o,t),n!==null&&(Xt(n,e,t),tu(n,e,t))}function x3(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function f1(e,t){x3(e,t),(e=e.alternate)&&x3(e,t)}function s_(e){if(e.tag===13||e.tag===31){var t=Ls(e,67108864);t!==null&&Xt(t,e,67108864),f1(e,67108864)}}function b3(e){if(e.tag===13||e.tag===31){var t=hn();t=Sx(t);var n=Ls(e,t);n!==null&&Xt(n,e,t),f1(e,t)}}var Hh=!0;function nD(e,t,n,o){var a=K.T;K.T=null;var r=Le.p;try{Le.p=2,p1(e,t,n,o)}finally{Le.p=r,K.T=a}}function oD(e,t,n,o){var a=K.T;K.T=null;var r=Le.p;try{Le.p=8,p1(e,t,n,o)}finally{Le.p=r,K.T=a}}function p1(e,t,n,o){if(Hh){var a=xx(o);if(a===null)Lg(e,t,o,Uh,n),A3(e,o);else if(rD(a,e,t,n,o))o.stopPropagation();else if(A3(e,o),t&4&&-1<aD.indexOf(e)){for(;a!==null;){var r=yl(a);if(r!==null)switch(r.tag){case 3:if(r=r.stateNode,r.current.memoizedState.isDehydrated){var s=ss(r.pendingLanes);if(s!==0){var i=r;for(i.pendingLanes|=2,i.entangledLanes|=2;s;){var l=1<<31-pn(s);i.entanglements[1]|=l,s&=~l}Co(r),(ve&6)===0&&(Eh=dn()+500,Ru(0,!1))}}break;case 31:case 13:i=Ls(r,2),i!==null&&Xt(i,r,2),em(),f1(r,2)}if(r=xx(o),r===null&&Lg(e,t,o,Uh,n),r===a)break;a=r}a!==null&&o.stopPropagation()}else Lg(e,t,o,null,n)}}function xx(e){return e=Cx(e),h1(e)}var Uh=null;function h1(e){if(Uh=null,e=Ui(e),e!==null){var t=ku(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=_3(t),e!==null)return e;e=null}else if(n===31){if(e=C3(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Uh=e,null}function i_(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(jM()){case M3:return 2;case O3:return 8;case yh:case VM:return 32;case R3:return 268435456;default:return 32}default:return 32}}var bx=!1,ur=null,dr=null,fr=null,Lu=new Map,Su=new Map,Qa=[],aD="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function A3(e,t){switch(e){case"focusin":case"focusout":ur=null;break;case"dragenter":case"dragleave":dr=null;break;case"mouseover":case"mouseout":fr=null;break;case"pointerover":case"pointerout":Lu.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Su.delete(t.pointerId)}}function Wc(e,t,n,o,a,r){return e===null||e.nativeEvent!==r?(e={blockedOn:t,domEventName:n,eventSystemFlags:o,nativeEvent:r,targetContainers:[a]},t!==null&&(t=yl(t),t!==null&&s_(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function rD(e,t,n,o,a){switch(t){case"focusin":return ur=Wc(ur,e,t,n,o,a),!0;case"dragenter":return dr=Wc(dr,e,t,n,o,a),!0;case"mouseover":return fr=Wc(fr,e,t,n,o,a),!0;case"pointerover":var r=a.pointerId;return Lu.set(r,Wc(Lu.get(r)||null,e,t,n,o,a)),!0;case"gotpointercapture":return r=a.pointerId,Su.set(r,Wc(Su.get(r)||null,e,t,n,o,a)),!0}return!1}function l_(e){var t=Ui(e.target);if(t!==null){var n=ku(t);if(n!==null){if(t=n.tag,t===13){if(t=_3(n),t!==null){e.blockedOn=t,oS(e.priority,function(){b3(n)});return}}else if(t===31){if(t=C3(n),t!==null){e.blockedOn=t,oS(e.priority,function(){b3(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function fh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=xx(e.nativeEvent);if(n===null){n=e.nativeEvent;var o=new n.constructor(n.type,n);zg=o,n.target.dispatchEvent(o),zg=null}else return t=yl(n),t!==null&&s_(t),e.blockedOn=n,!1;t.shift()}return!0}function v3(e,t,n){fh(e)&&n.delete(t)}function sD(){bx=!1,ur!==null&&fh(ur)&&(ur=null),dr!==null&&fh(dr)&&(dr=null),fr!==null&&fh(fr)&&(fr=null),Lu.forEach(v3),Su.forEach(v3)}function Kp(e,t){e.blockedOn===t&&(e.blockedOn=null,bx||(bx=!0,ut.unstable_scheduleCallback(ut.unstable_NormalPriority,sD)))}var $p=null;function L3(e){$p!==e&&($p=e,ut.unstable_scheduleCallback(ut.unstable_NormalPriority,function(){$p===e&&($p=null);for(var t=0;t<e.length;t+=3){var n=e[t],o=e[t+1],a=e[t+2];if(typeof o!="function"){if(h1(o||n)===null)continue;break}var r=yl(n);r!==null&&(e.splice(t,3),t-=3,Jg(r,{pending:!0,data:a,method:n.method,action:o},o,a))}}))}function hl(e){function t(l){return Kp(l,e)}ur!==null&&Kp(ur,e),dr!==null&&Kp(dr,e),fr!==null&&Kp(fr,e),Lu.forEach(t),Su.forEach(t);for(var n=0;n<Qa.length;n++){var o=Qa[n];o.blockedOn===e&&(o.blockedOn=null)}for(;0<Qa.length&&(n=Qa[0],n.blockedOn===null);)l_(n),n.blockedOn===null&&Qa.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(o=0;o<n.length;o+=3){var a=n[o],r=n[o+1],s=a[Yt]||null;if(typeof r=="function")s||L3(n);else if(s){var i=null;if(r&&r.hasAttribute("formAction")){if(a=r,s=r[Yt]||null)i=s.formAction;else if(h1(a)!==null)continue}else i=s.action;typeof i=="function"?n[o+1]=i:(n.splice(o,3),o-=3),L3(n)}}}function c_(){function e(r){r.canIntercept&&r.info==="react-transition"&&r.intercept({handler:function(){return new Promise(function(s){return a=s})},focusReset:"manual",scroll:"manual"})}function t(){a!==null&&(a(),a=null),o||setTimeout(n,20)}function n(){if(!o&&!navigation.transition){var r=navigation.currentEntry;r&&r.url!=null&&navigation.navigate(r.url,{state:r.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,a=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),a!==null&&(a(),a=null)}}}function m1(e){this._internalRoot=e}om.prototype.render=m1.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(O(409));var n=t.current,o=hn();r_(n,o,e,t,null,null)};om.prototype.unmount=m1.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;r_(e.current,2,null,e,null,null),em(),t[ml]=null}};function om(e){this._internalRoot=e}om.prototype.unstable_scheduleHydration=function(e){if(e){var t=N3();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Qa.length&&t!==0&&t<Qa[n].priority;n++);Qa.splice(n,0,e),n===0&&l_(e)}};var S3=k3.version;if(S3!=="19.2.6")throw Error(O(527,S3,"19.2.6"));Le.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(O(188)):(e=Object.keys(e).join(","),Error(O(268,e)));return e=NM(t),e=e!==null?T3(e):null,e=e===null?null:e.stateNode,e};var iD={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(jc=__REACT_DEVTOOLS_GLOBAL_HOOK__,!jc.isDisabled&&jc.supportsFiber))try{wu=jc.inject(iD),fn=jc}catch{}var jc;am.createRoot=function(e,t){if(!w3(e))throw Error(O(299));var n=!1,o="",a=ew,r=tw,s=nw;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(o=t.identifierPrefix),t.onUncaughtError!==void 0&&(a=t.onUncaughtError),t.onCaughtError!==void 0&&(r=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=o_(e,1,!1,null,null,n,o,null,a,r,s,c_),e[ml]=t.current,c1(e),new m1(t)};am.hydrateRoot=function(e,t,n){if(!w3(e))throw Error(O(299));var o=!1,a="",r=ew,s=tw,i=nw,l=null;return n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(a=n.identifierPrefix),n.onUncaughtError!==void 0&&(r=n.onUncaughtError),n.onCaughtError!==void 0&&(s=n.onCaughtError),n.onRecoverableError!==void 0&&(i=n.onRecoverableError),n.formState!==void 0&&(l=n.formState)),t=o_(e,1,!0,t,n??null,o,a,l,r,s,i,c_),t.context=a_(null),n=t.current,o=hn(),o=Sx(o),a=sr(o),a.callback=null,ir(n,a,o),n=o,t.current.lanes=n,Cu(t,n),Co(t),e[ml]=t.current,c1(e),new om(t)};am.version="19.2.6"});var p_=Dt((Vj,f_)=>{"use strict";function d_(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(d_)}catch(e){console.error(e)}}d_(),f_.exports=u_()});var m_=Dt(rm=>{"use strict";var lD=Symbol.for("react.transitional.element"),cD=Symbol.for("react.fragment");function h_(e,t,n){var o=null;if(n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),"key"in t){n={};for(var a in t)a!=="key"&&(n[a]=t[a])}else n=t;return t=n.ref,{$$typeof:lD,type:e,key:o,ref:t!==void 0?t:null,props:n}}rm.Fragment=cD;rm.jsx=h_;rm.jsxs=h_});var ye=Dt((Xj,y_)=>{"use strict";y_.exports=m_()});var cL=Dt(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.loop=Kr.conditional=Kr.parse=void 0;var OW=function e(t,n){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:o;if(Array.isArray(n))n.forEach(function(s){return e(t,s,o,a)});else if(typeof n=="function")n(t,o,a,e);else{var r=Object.keys(n)[0];Array.isArray(n[r])?(a[r]={},e(t,n[r],o,a[r])):a[r]=n[r](t,o,a,e)}return o};Kr.parse=OW;var RW=function(t,n){return function(o,a,r,s){n(o,a,r)&&s(o,t,a,r)}};Kr.conditional=RW;var DW=function(t,n){return function(o,a,r,s){for(var i=[],l=o.pos;n(o,a,r);){var c={};if(s(o,t,a,c),o.pos===l)break;l=o.pos,i.push(c)}return i}};Kr.loop=DW});var uL=Dt(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.readBits=lt.readArray=lt.readUnsigned=lt.readString=lt.peekBytes=lt.readBytes=lt.peekByte=lt.readByte=lt.buildStream=void 0;var PW=function(t){return{data:t,pos:0}};lt.buildStream=PW;var H6=function(){return function(t){return t.data[t.pos++]}};lt.readByte=H6;var BW=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(n){return n.data[n.pos+t]}};lt.peekByte=BW;var Ly=function(t){return function(n){return n.data.subarray(n.pos,n.pos+=t)}};lt.readBytes=Ly;var zW=function(t){return function(n){return n.data.subarray(n.pos,n.pos+t)}};lt.peekBytes=zW;var NW=function(t){return function(n){return Array.from(Ly(t)(n)).map(function(o){return String.fromCharCode(o)}).join("")}};lt.readString=NW;var FW=function(t){return function(n){var o=Ly(2)(n);return t?(o[1]<<8)+o[0]:(o[0]<<8)+o[1]}};lt.readUnsigned=FW;var HW=function(t,n){return function(o,a,r){for(var s=typeof n=="function"?n(o,a,r):n,i=Ly(t),l=new Array(s),c=0;c<s;c++)l[c]=i(o);return l}};lt.readArray=HW;var UW=function(t,n,o){for(var a=0,r=0;r<o;r++)a+=t[n+r]&&Math.pow(2,o-r-1);return a},GW=function(t){return function(n){for(var o=H6()(n),a=new Array(8),r=0;r<8;r++)a[7-r]=!!(o&1<<r);return Object.keys(t).reduce(function(s,i){var l=t[i];return l.length?s[i]=UW(a,l.index,l.length):s[i]=a[l.index],s},{})}};lt.readBits=GW});var U6=Dt(ky=>{"use strict";Object.defineProperty(ky,"__esModule",{value:!0});ky.default=void 0;var $r=cL(),ce=uL(),Sy={blocks:function(t){for(var n=0,o=[],a=t.data.length,r=0,s=(0,ce.readByte)()(t);s!==n&&s;s=(0,ce.readByte)()(t)){if(t.pos+s>=a){var i=a-t.pos;o.push((0,ce.readBytes)(i)(t)),r+=i;break}o.push((0,ce.readBytes)(s)(t)),r+=s}for(var l=new Uint8Array(r),c=0,u=0;u<o.length;u++)l.set(o[u],c),c+=o[u].length;return l}},qW=(0,$r.conditional)({gce:[{codes:(0,ce.readBytes)(2)},{byteSize:(0,ce.readByte)()},{extras:(0,ce.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,ce.readUnsigned)(!0)},{transparentColorIndex:(0,ce.readByte)()},{terminator:(0,ce.readByte)()}]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===249}),WW=(0,$r.conditional)({image:[{code:(0,ce.readByte)()},{descriptor:[{left:(0,ce.readUnsigned)(!0)},{top:(0,ce.readUnsigned)(!0)},{width:(0,ce.readUnsigned)(!0)},{height:(0,ce.readUnsigned)(!0)},{lct:(0,ce.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,$r.conditional)({lct:(0,ce.readArray)(3,function(e,t,n){return Math.pow(2,n.descriptor.lct.size+1)})},function(e,t,n){return n.descriptor.lct.exists}),{data:[{minCodeSize:(0,ce.readByte)()},Sy]}]},function(e){return(0,ce.peekByte)()(e)===44}),jW=(0,$r.conditional)({text:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{preData:function(t,n,o){return(0,ce.readBytes)(o.text.blockSize)(t)}},Sy]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===1}),VW=(0,$r.conditional)({application:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{id:function(t,n,o){return(0,ce.readString)(o.blockSize)(t)}},Sy]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===255}),ZW=(0,$r.conditional)({comment:[{codes:(0,ce.readBytes)(2)},Sy]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===254}),XW=[{header:[{signature:(0,ce.readString)(3)},{version:(0,ce.readString)(3)}]},{lsd:[{width:(0,ce.readUnsigned)(!0)},{height:(0,ce.readUnsigned)(!0)},{gct:(0,ce.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,ce.readByte)()},{pixelAspectRatio:(0,ce.readByte)()}]},(0,$r.conditional)({gct:(0,ce.readArray)(3,function(e,t){return Math.pow(2,t.lsd.gct.size+1)})},function(e,t){return t.lsd.gct.exists}),{frames:(0,$r.loop)([qW,VW,ZW,WW,jW],function(e){var t=(0,ce.peekByte)()(e);return t===33||t===44})}],YW=XW;ky.default=YW});var G6=Dt(wy=>{"use strict";Object.defineProperty(wy,"__esModule",{value:!0});wy.deinterlace=void 0;var KW=function(t,n){for(var o=new Array(t.length),a=t.length/n,r=function(f,p){var h=t.slice(p*n,(p+1)*n);o.splice.apply(o,[f*n,n].concat(h))},s=[0,4,2,1],i=[8,8,4,2],l=0,c=0;c<4;c++)for(var u=s[c];u<a;u+=i[c])r(u,l),l++;return o};wy.deinterlace=KW});var q6=Dt(_y=>{"use strict";Object.defineProperty(_y,"__esModule",{value:!0});_y.lzw=void 0;var $W=function(t,n,o){var a=4096,r=-1,s=o,i,l,c,u,d,f,p,_,h,m,C,b,I,k,P,T,y=new Array(o),g=new Array(a),x=new Array(a),A=new Array(a+1);for(b=t,l=1<<b,d=l+1,i=l+2,p=r,u=b+1,c=(1<<u)-1,h=0;h<l;h++)g[h]=0,x[h]=h;var C,_,v,I,k,T,P;for(C=_=v=I=k=T=P=0,m=0;m<s;){if(k===0){if(_<u){C+=n[P]<<_,_+=8,P++;continue}if(h=C&c,C>>=u,_-=u,h>i||h==d)break;if(h==l){u=b+1,c=(1<<u)-1,i=l+2,p=r;continue}if(p==r){A[k++]=x[h],p=h,I=h;continue}for(f=h,h==i&&(A[k++]=I,h=p);h>l;)A[k++]=x[h],h=g[h];I=x[h]&255,A[k++]=I,i<a&&(g[i]=p,x[i]=I,i++,(i&c)===0&&i<a&&(u++,c+=i)),p=f}k--,y[T++]=A[k],m++}for(m=T;m<s;m++)y[m]=0;return y};_y.lzw=$W});var j6=Dt(Qr=>{"use strict";Object.defineProperty(Qr,"__esModule",{value:!0});Qr.decompressFrames=Qr.decompressFrame=Qr.parseGIF=void 0;var QW=oj(U6()),JW=cL(),ej=uL(),tj=G6(),nj=q6();function oj(e){return e&&e.__esModule?e:{default:e}}var aj=function(t){var n=new Uint8Array(t);return(0,JW.parse)((0,ej.buildStream)(n),QW.default)};Qr.parseGIF=aj;var rj=function(t){for(var n=t.pixels.length,o=new Uint8ClampedArray(n*4),a=0;a<n;a++){var r=a*4,s=t.pixels[a],i=t.colorTable[s]||[0,0,0];o[r]=i[0],o[r+1]=i[1],o[r+2]=i[2],o[r+3]=s!==t.transparentIndex?255:0}return o},W6=function(t,n,o){if(!t.image){console.warn("gif frame does not have associated image.");return}var a=t.image,r=a.descriptor.width*a.descriptor.height,s=(0,nj.lzw)(a.data.minCodeSize,a.data.blocks,r);a.descriptor.lct.interlaced&&(s=(0,tj.deinterlace)(s,a.descriptor.width));var i={pixels:s,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return a.descriptor.lct&&a.descriptor.lct.exists?i.colorTable=a.lct:i.colorTable=n,t.gce&&(i.delay=(t.gce.delay||10)*10,i.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(i.transparentIndex=t.gce.transparentColorIndex)),o&&(i.patch=rj(i)),i};Qr.decompressFrame=W6;var sj=function(t,n){return t.frames.filter(function(o){return o.image}).map(function(o){return W6(o,t.gct,n)})};Qr.decompressFrames=sj});var Q6=F(p_(),1);var R=F(ye(),1),xe=F(he(),1);var lm=F(he(),1);var sm=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();var g_=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var x_=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase());var y1=e=>{let t=x_(e);return t.charAt(0).toUpperCase()+t.slice(1)};var Bu=F(he(),1);var im={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var b_=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var Ll=F(he(),1);var uD=(0,Ll.createContext)({});var A_=()=>(0,Ll.useContext)(uD);var v_=(0,Bu.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:o,className:a="",children:r,iconNode:s,...i},l)=>{let{size:c=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f="currentColor",className:p=""}=A_()??{},h=o??d?Number(n??u)*24/Number(t??c):n??u;return(0,Bu.createElement)("svg",{ref:l,...im,width:t??c??im.width,height:t??c??im.height,stroke:e??f,strokeWidth:h,className:sm("lucide",p,a),...!r&&!b_(i)&&{"aria-hidden":"true"},...i},[...s.map(([m,b])=>(0,Bu.createElement)(m,b)),...Array.isArray(r)?r:[r]])});var E=(e,t)=>{let n=(0,lm.forwardRef)(({className:o,...a},r)=>(0,lm.createElement)(v_,{ref:r,iconNode:t,className:sm(`lucide-${g_(y1(e))}`,`lucide-${e}`,o),...a}));return n.displayName=y1(e),n};var dD=[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4",key:"11f1s0"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4",key:"t14dx9"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1",key:"1w07xs"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1",key:"1apec2"}]],zu=E("align-center-horizontal",dD);var fD=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]],Sl=E("align-center-vertical",fD);var pD=[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2",key:"z5wdxg"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2",key:"um7a8w"}],["path",{d:"M22 22H2",key:"19qnx5"}]],Nu=E("align-end-horizontal",pD);var hD=[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]],Fu=E("align-end-vertical",hD);var mD=[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]],Hu=E("align-horizontal-distribute-center",mD);var yD=[["rect",{width:"6",height:"16",x:"4",y:"6",rx:"2",key:"1n4dg1"}],["rect",{width:"6",height:"9",x:"14",y:"6",rx:"2",key:"17khns"}],["path",{d:"M22 2H2",key:"fhrpnj"}]],Uu=E("align-start-horizontal",yD);var gD=[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]],Gu=E("align-start-vertical",gD);var xD=[["path",{d:"M22 17h-3",key:"1lwga1"}],["path",{d:"M22 7h-5",key:"o2endc"}],["path",{d:"M5 17H2",key:"1gx9xc"}],["path",{d:"M7 7H2",key:"6bq26l"}],["rect",{x:"5",y:"14",width:"14",height:"6",rx:"2",key:"1qrzuf"}],["rect",{x:"7",y:"4",width:"10",height:"6",rx:"2",key:"we8e9z"}]],qu=E("align-vertical-distribute-center",xD);var bD=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],Wu=E("bold",bD);var AD=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],ju=E("case-sensitive",AD);var vD=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Vu=E("check",vD);var LD=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Zu=E("chevron-down",LD);var SD=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ks=E("chevron-right",SD);var kD=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],Xu=E("chevrons-down",kD);var wD=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Yu=E("chevrons-up",wD);var _D=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],gn=E("circle-question-mark",_D);var CD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ku=E("circle",CD);var TD=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],$u=E("clipboard",TD);var ID=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],ws=E("copy",ID);var ED=[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]],Qu=E("delete",ED);var MD=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],kl=E("download",MD);var OD=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],br=E("ellipsis-vertical",OD);var RD=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Ar=E("ellipsis",RD);var DD=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ju=E("external-link",DD);var PD=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],ed=E("file-down",PD);var BD=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],td=E("file-up",BD);var zD=[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]],nd=E("flip-horizontal-2",zD);var ND=[["path",{d:"m17 3-5 5-5-5h10",key:"1ftt6x"}],["path",{d:"m17 21-5-5-5 5h10",key:"1m0wmu"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]],od=E("flip-vertical-2",ND);var FD=[["line",{x1:"22",x2:"2",y1:"6",y2:"6",key:"15w7dq"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18",key:"1ip48p"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22",key:"a2lnyx"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22",key:"8vb6jd"}]],ad=E("frame",FD);var HD=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],so=E("grid-3x3",HD);var UD=[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]],rd=E("grip",UD);var GD=[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]],sd=E("group",GD);var qD=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],id=E("hand",qD);var WD=[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],_s=E("image-down",WD);var jD=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Cs=E("image",jD);var VD=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],ld=E("italic",VD);var ZD=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],cd=E("library",ZD);var XD=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],ud=E("link",XD);var YD=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],dd=E("locate-fixed",YD);var KD=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],fd=E("lock",KD);var $D=[["path",{d:"m12 15 4 4",key:"lnac28"}],["path",{d:"M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z",key:"nlhkjb"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}]],pd=E("magnet",$D);var QD=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],wl=E("maximize",QD);var JD=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],hd=E("menu",JD);var e7=[["path",{d:"M5 12h14",key:"1ays0h"}]],ma=E("minus",e7);var t7=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],md=E("monitor",t7);var n7=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],yd=E("moon",n7);var o7=[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]],gd=E("mouse-pointer-2",o7);var a7=[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]],xd=E("mouse-pointer",a7);var r7=[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]],bd=E("move-down",r7);var s7=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Ad=E("move-right",s7);var i7=[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]],vd=E("move-up",i7);var l7=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],vr=E("pen-line",l7);var c7=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ts=E("plus",c7);var u7=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],Is=E("redo-2",u7);var d7=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Ld=E("rotate-ccw",d7);var f7=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],Sd=E("scissors",f7);var p7=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],kd=E("search",p7);var h7=[["path",{d:"M22 2 2 22",key:"y4kqgn"}]],wd=E("slash",h7);var m7=[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]],_d=E("spline",m7);var y7=[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]],ya=E("square-dashed",y7);var g7=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],ga=E("square-dot",g7);var x7=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],xa=E("square",x7);var b7=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],Cd=E("strikethrough",b7);var A7=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Td=E("sun",A7);var v7=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Lr=E("text-align-end",v7);var L7=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Sr=E("text-align-center",L7);var S7=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],io=E("text-align-start",S7);var k7=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],_l=E("trash-2",k7);var w7=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Id=E("type",w7);var _7=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Ed=E("underline",_7);var C7=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Es=E("undo-2",C7);var T7=[["rect",{width:"8",height:"6",x:"5",y:"4",rx:"1",key:"nzclkv"}],["rect",{width:"8",height:"6",x:"11",y:"14",rx:"1",key:"4tytwb"}]],Md=E("ungroup",T7);var I7=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Od=E("upload",I7);var E7=[["path",{d:"m10.586 5.414-5.172 5.172",key:"4mc350"}],["path",{d:"m18.586 13.414-5.172 5.172",key:"8c96vv"}],["path",{d:"M6 12h12",key:"8npq4p"}],["circle",{cx:"12",cy:"20",r:"2",key:"144qzu"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["circle",{cx:"20",cy:"12",r:"2",key:"1xzzfp"}],["circle",{cx:"4",cy:"12",r:"2",key:"1hvhnz"}]],Rd=E("waypoints",E7);var M7=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ba=E("x",M7);var O7=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Dd=E("zoom-out",O7);var R7=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Pd=E("zoom-in",R7);var D7=F(ye(),1),lo=F(he(),1),L_=(0,lo.createContext)(null);var S_=L_;var g1=()=>(0,lo.useContext)(L_),Aa=(e,t,n)=>{let o=g1(),[a,r]=(0,lo.useState)(()=>o?e(o):t),s=(0,lo.useRef)(e);s.current=e;let i=(0,lo.useRef)(t);return i.current=t,(0,lo.useEffect)(()=>{if(!o){r(i.current);return}let l=()=>{let c=s.current(o);r(u=>Object.is(u,c)?u:c)};return l(),n!==void 0?o.on(n,l):o.subscribe(l)},[o,n]),a};var w1=F(ye(),1);var Cl=F(ye(),1),Ye=F(he(),1),E_=F(Yo(),1);var k_=F(ye(),1),cm=F(he(),1),w_=(0,cm.createContext)(null),Bd=({container:e,children:t})=>(0,k_.jsx)(w_.Provider,{value:e,children:t}),Et=()=>(0,cm.useContext)(w_)??document.body;var x1=[{label:"S",value:16},{label:"M",value:24},{label:"L",value:36},{label:"XL",value:64}],__=8,C_=256,b1=[{label:"Sans",value:"system-ui, sans-serif"},{label:"Serif",value:"Georgia, 'Times New Roman', serif"},{label:"Mono",value:"ui-monospace, 'SF Mono', Menlo, monospace"}];var v1=new Set,zd=null,To=null,Io=null,S1=0,L1=!1,P7=()=>{for(let e of v1)e(zd)},um=e=>{zd=e,P7()},B7=e=>(v1.add(e),()=>{v1.delete(e)}),z7=e=>{if(L1)return;Io&&(clearTimeout(Io),Io=null),To&&clearTimeout(To);let t=Date.now()-S1;if(zd!==null||t<600){um(e);return}To=setTimeout(()=>{To=null,um(e)},600)},T_=e=>{To&&(clearTimeout(To),To=null),zd?.id===e&&(Io&&clearTimeout(Io),Io=setTimeout(()=>{Io=null,S1=Date.now(),um(null)},80))},I_=()=>{To&&(clearTimeout(To),To=null),Io&&(clearTimeout(Io),Io=null),zd&&(S1=Date.now(),um(null))},k1=({children:e})=>((0,Ye.useEffect)(()=>{let t=()=>{L1=!0,I_()},n=()=>{L1=!1},o=a=>{a.key==="Escape"&&I_()};return document.addEventListener("pointerdown",t,{capture:!0}),document.addEventListener("pointerup",n,{capture:!0}),document.addEventListener("keydown",o,{capture:!0}),()=>{document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointerup",n,{capture:!0}),document.removeEventListener("keydown",o,{capture:!0})}},[]),(0,Cl.jsxs)(M_.Provider,{value:!0,children:[e,(0,Cl.jsx)(F7,{})]})),M_=(0,Ye.createContext)(!1),N7=()=>(0,Ye.useContext)(M_),F7=()=>{let[e,t]=(0,Ye.useState)(null),n=Et();return(0,Ye.useEffect)(()=>B7(t),[]),!e||typeof document>"u"?null:(0,E_.createPortal)((0,Cl.jsx)(H7,{target:e}),n)},H7=({target:e})=>{let t=(0,Ye.useRef)(null),[n,o]=(0,Ye.useState)(null);(0,Ye.useLayoutEffect)(()=>{let r=t.current;if(!r)return;let s=r.getBoundingClientRect(),{rect:i,side:l}=e,c=i.left+i.width/2-s.width/2,u=i.top+i.height/2-s.height/2;switch(l){case"top":u=i.top-s.height-6;break;case"bottom":u=i.bottom+6;break;case"left":c=i.left-s.width-6;break;case"right":c=i.right+6;break}let d=4;c=Math.max(d,Math.min(c,window.innerWidth-s.width-d)),u=Math.max(d,Math.min(u,window.innerHeight-s.height-d)),o({left:c,top:u})},[e]);let a={position:"fixed",left:n?.left??-9999,top:n?.top??-9999,pointerEvents:"none",zIndex:1e4,visibility:n?"visible":"hidden"};return(0,Cl.jsx)("div",{ref:t,role:"tooltip",className:"du-tooltip",style:a,children:e.content})},Ms=({content:e,side:t="bottom",disabled:n,children:o})=>{let a=(0,Ye.useId)();if(!N7()||n||e===void 0||e===null)return(0,Ye.isValidElement)(o)&&typeof e=="string"&&!n?(0,Ye.cloneElement)(o,{title:e}):o;if(!(0,Ye.isValidElement)(o))return o;let s=o,i=f=>{z7({id:a,content:e,side:t,rect:f.getBoundingClientRect()})};return(0,Ye.cloneElement)(s,{onPointerEnter:f=>{s.props.onPointerEnter?.(f),f.pointerType!=="touch"&&i(f.currentTarget)},onPointerLeave:f=>{s.props.onPointerLeave?.(f),T_(a)},onFocus:f=>{s.props.onFocus?.(f),i(f.currentTarget)},onBlur:f=>{s.props.onBlur?.(f),T_(a)},title:void 0})};var Bn=({label:e,active:t,size:n="default",className:o,children:a,...r})=>{let s=["du-icon-button",n==="sm"?"du-icon-button-sm":"",t?"is-active":"",o??""].filter(Boolean).join(" ");return(0,w1.jsx)(Ms,{content:e,children:(0,w1.jsx)("button",{type:"button",className:s,"aria-label":e,"aria-pressed":t??void 0,...r,children:a})})};var O_=F(ye(),1),Os=({children:e,className:t,ariaLabel:n})=>(0,O_.jsx)("div",{className:`du-button-group ${t??""}`.trim(),role:"group","aria-label":n,children:e});var _1=F(ye(),1);var zn=({value:e,options:t,onChange:n,ariaLabel:o})=>(0,_1.jsx)(Os,{...o!==void 0?{ariaLabel:o}:{},children:t.map(a=>(0,_1.jsx)(Bn,{label:a.label,active:e===a.value,onClick:()=>{n(a.value)},size:"sm",children:a.icon},String(a.value)))});var Nd=F(ye(),1),Fd=({value:e,min:t,max:n,step:o=1,onChange:a,ariaLabel:r,valueLabel:s})=>{let i=c=>{a(Number(c.target.value))},l=e??(t+n)/2;return(0,Nd.jsxs)("div",{className:"du-slider",children:[(0,Nd.jsx)("input",{type:"range",min:t,max:n,step:o,value:l,onChange:i,"aria-label":r,className:"du-slider-track"}),(0,Nd.jsx)("span",{className:"du-slider-value",children:e===null?"\u2014":s??e})]})};var R_=F(ye(),1),C1=({children:e,className:t,style:n})=>(0,R_.jsx)("div",{className:`du-ui-layer ${t??""}`.trim(),style:n,children:e});var Nn=F(ye(),1),T1=({left:e,center:t,right:n})=>(0,Nn.jsxs)("div",{className:"du-bar du-bar-top",children:[(0,Nn.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,Nn.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,Nn.jsx)("div",{}),(0,Nn.jsx)("div",{className:"du-bar-zone",children:n})]}),I1=({left:e,center:t,right:n})=>(0,Nn.jsxs)("div",{className:"du-bar du-bar-bottom",children:[(0,Nn.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,Nn.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,Nn.jsx)("div",{}),(0,Nn.jsx)("div",{className:"du-bar-zone",children:n})]});var zr=F(ye(),1),F9=F(he(),1);var je=F(ye(),1),lc=F(he(),1);var D_="select";var va={};no(va,{EMPTY:()=>Ne,add:()=>xn,clear:()=>q7,equals:()=>Rs,has:()=>U7,remove:()=>P_,replace:()=>G7,single:()=>Mt,toggle:()=>O1});var Qe=e=>e,E1=e=>e,$t=e=>e,Hd=e=>e,Tl=e=>e,M1=e=>e;var L=e=>{if(e===void 0)throw new Error("required value is undefined");return e};var Ud=e=>{let t={};for(let[n,o]of Object.entries(e))o!==void 0&&(t[n]=o);return t};var dm=(e,t)=>{if(e===t)return!0;if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};var Ne=Object.freeze(new Set),Mt=e=>new Set([e]),U7=(e,t)=>e.has(t),xn=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},P_=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},O1=(e,t)=>e.has(t)?P_(e,t):xn(e,t),G7=e=>Mt(e),q7=()=>Ne,Rs=(e,t)=>dm(e,t);var Ae={};no(Ae,{ZERO:()=>B_,add:()=>j7,angle:()=>nP,cross:()=>$7,distance:()=>Q7,distanceSq:()=>F_,div:()=>X7,dot:()=>K7,equals:()=>sP,length:()=>N_,lengthSq:()=>z_,lerp:()=>eP,midpoint:()=>tP,mul:()=>Z7,negate:()=>Y7,normalize:()=>J7,of:()=>W7,perp:()=>rP,rotate:()=>oP,rotateAround:()=>aP,sub:()=>V7});var B_=Object.freeze({x:0,y:0}),W7=(e,t)=>({x:e,y:t}),j7=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),V7=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),Z7=(e,t)=>({x:e.x*t,y:e.y*t}),X7=(e,t)=>({x:e.x/t,y:e.y/t}),Y7=e=>({x:-e.x,y:-e.y}),K7=(e,t)=>e.x*t.x+e.y*t.y,$7=(e,t)=>e.x*t.y-e.y*t.x,z_=e=>e.x*e.x+e.y*e.y,N_=e=>Math.sqrt(z_(e)),F_=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o},Q7=(e,t)=>Math.sqrt(F_(e,t)),J7=e=>{let t=N_(e);return t===0?B_:{x:e.x/t,y:e.y/t}},eP=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),tP=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),nP=e=>Math.atan2(e.y,e.x),oP=(e,t)=>{let n=Math.cos(t),o=Math.sin(t);return{x:e.x*n-e.y*o,y:e.x*o+e.y*n}},aP=(e,t,n)=>{let o=Math.cos(n),a=Math.sin(n),r=e.x-t.x,s=e.y-t.y;return{x:t.x+(r*o-s*a),y:t.y+(r*a+s*o)}},rP=e=>({x:-e.y,y:e.x}),sP=(e,t,n=0)=>n===0?e.x===t.x&&e.y===t.y:Math.abs(e.x-t.x)<=n&&Math.abs(e.y-t.y)<=n;var Il={};no(Il,{clamp:()=>iP,clamp01:()=>lP});var iP=(e,t,n)=>Math.max(t,Math.min(n,e)),lP=e=>e<0?0:e>1?1:e;var B={};no(B,{IDENTITY:()=>cP,applyToBounds:()=>yP,applyToPoint:()=>Gd,decompose:()=>gP,equals:()=>xP,inverse:()=>mP,multiply:()=>hP,of:()=>uP,rotation:()=>pP,scaling:()=>fP,translation:()=>dP});var cP=Object.freeze({a:1,b:0,c:0,d:1,e:0,f:0}),uP=(e,t,n,o,a,r)=>({a:e,b:t,c:n,d:o,e:a,f:r}),dP=(e,t)=>({a:1,b:0,c:0,d:1,e,f:t}),fP=(e,t=e)=>({a:e,b:0,c:0,d:t,e:0,f:0}),pP=e=>{let t=Math.cos(e),n=Math.sin(e);return{a:t,b:n,c:-n,d:t,e:0,f:0}},hP=(e,t)=>({a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,e:e.a*t.e+e.c*t.f+e.e,f:e.b*t.e+e.d*t.f+e.f}),mP=e=>{let t=e.a*e.d-e.b*e.c;if(t===0)throw new Error("Cannot invert singular matrix");return{a:e.d/t,b:-e.b/t,c:-e.c/t,d:e.a/t,e:(e.c*e.f-e.d*e.e)/t,f:(e.b*e.e-e.a*e.f)/t}},Gd=(e,t)=>({x:e.a*t.x+e.c*t.y+e.e,y:e.b*t.x+e.d*t.y+e.f}),yP=(e,t)=>{let n=Gd(e,{x:t.x,y:t.y}),o=Gd(e,{x:t.x+t.width,y:t.y}),a=Gd(e,{x:t.x,y:t.y+t.height}),r=Gd(e,{x:t.x+t.width,y:t.y+t.height}),s=Math.min(n.x,o.x,a.x,r.x),i=Math.min(n.y,o.y,a.y,r.y),l=Math.max(n.x,o.x,a.x,r.x),c=Math.max(n.y,o.y,a.y,r.y);return{x:s,y:i,width:l-s,height:c-i}},gP=e=>{let t=Math.sqrt(e.a*e.a+e.b*e.b),n=Math.sqrt(e.c*e.c+e.d*e.d),a=e.a*e.d-e.b*e.c<0?-n:n;return{translation:{x:e.e,y:e.f},rotation:Math.atan2(e.b,e.a),scale:{x:t,y:a}}},xP=(e,t,n=0)=>{let o=["a","b","c","d","e","f"];return n===0?o.every(a=>e[a]===t[a]):o.every(a=>Math.abs(e[a]-t[a])<=n)};var X={};no(X,{EMPTY:()=>H_,centerOf:()=>vP,contains:()=>D1,containsBounds:()=>kP,equals:()=>CP,expand:()=>wP,fromCenter:()=>AP,fromPoints:()=>fm,intersection:()=>U_,intersects:()=>SP,isEmpty:()=>R1,maxX:()=>kr,maxY:()=>wr,normalize:()=>_P,of:()=>bP,union:()=>LP});var H_=Object.freeze({x:0,y:0,width:0,height:0}),bP=(e,t,n,o)=>({x:e,y:t,width:n,height:o}),fm=e=>{if(e.length===0)return H_;let t=1/0,n=1/0,o=-1/0,a=-1/0;for(let r of e)r.x<t&&(t=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>a&&(a=r.y);return{x:t,y:n,width:o-t,height:a-n}},AP=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,width:t,height:n}),vP=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),kr=e=>e.x+e.width,wr=e=>e.y+e.height,R1=e=>e.width<=0||e.height<=0,LP=(e,t)=>{if(R1(e))return t;if(R1(t))return e;let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(kr(e),kr(t)),r=Math.max(wr(e),wr(t));return{x:n,y:o,width:a-n,height:r-o}},U_=(e,t)=>{let n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),a=Math.min(kr(e),kr(t)),r=Math.min(wr(e),wr(t));return a<=n||r<=o?null:{x:n,y:o,width:a-n,height:r-o}},SP=(e,t)=>U_(e,t)!==null,D1=(e,t)=>t.x>=e.x&&t.x<=kr(e)&&t.y>=e.y&&t.y<=wr(e),kP=(e,t)=>t.x>=e.x&&t.y>=e.y&&kr(t)<=kr(e)&&wr(t)<=wr(e),wP=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),_P=e=>({x:e.width<0?e.x+e.width:e.x,y:e.height<0?e.y+e.height:e.y,width:Math.abs(e.width),height:Math.abs(e.height)}),CP=(e,t,n=0)=>n===0?e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height:Math.abs(e.x-t.x)<=n&&Math.abs(e.y-t.y)<=n&&Math.abs(e.width-t.width)<=n&&Math.abs(e.height-t.height)<=n;var Ml={};no(Ml,{distanceToSegment:()=>EP,distanceToSegmentSq:()=>El,pointInPolygon:()=>IP,pointInRect:()=>TP,pointOnPolyline:()=>MP,pointOnSegment:()=>G_});var TP=(e,t)=>D1(t,e),IP=(e,t)=>{if(t.length<3)return!1;let n=!1;for(let o=0,a=t.length-1;o<t.length;a=o++){let r=t[o],s=t[a];if(!r||!s)continue;r.y>e.y!=s.y>e.y&&e.x<(s.x-r.x)*(e.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n},El=(e,t,n)=>{let o=n.x-t.x,a=n.y-t.y,r=o*o+a*a;if(r===0){let d=e.x-t.x,f=e.y-t.y;return d*d+f*f}let s=((e.x-t.x)*o+(e.y-t.y)*a)/r;s<0?s=0:s>1&&(s=1);let i=t.x+s*o,l=t.y+s*a,c=e.x-i,u=e.y-l;return c*c+u*u},EP=(e,t,n)=>Math.sqrt(El(e,t,n)),G_=(e,t,n,o=1)=>El(e,t,n)<=o*o,MP=(e,t,n=1)=>{for(let o=0;o<t.length-1;o++){let a=t[o],r=t[o+1];if(a&&r&&G_(e,a,r,n))return!0}return!1};var Fn={};no(Fn,{cubicAt:()=>Ps,cubicBounds:()=>RP,flattenCubic:()=>zP,flattenQuadratic:()=>BP,pointOnCubic:()=>PP,pointOnQuadratic:()=>DP,quadraticAt:()=>Ds,quadraticBounds:()=>OP});var Ds=(e,t,n,o)=>{let a=1-o;return{x:a*a*e.x+2*a*o*t.x+o*o*n.x,y:a*a*e.y+2*a*o*t.y+o*o*n.y}},Ps=(e,t,n,o,a)=>{let r=1-a,s=r*r,i=s*r,l=a*a,c=l*a;return{x:i*e.x+3*s*a*t.x+3*r*l*n.x+c*o.x,y:i*e.y+3*s*a*t.y+3*r*l*n.y+c*o.y}},OP=(e,t,n)=>{let o=[e,n];for(let a of q_(e.x,t.x,n.x))o.push(Ds(e,t,n,a));for(let a of q_(e.y,t.y,n.y))o.push(Ds(e,t,n,a));return fm(o)},RP=(e,t,n,o)=>{let a=[e,o];for(let r of W_(e.x,t.x,n.x,o.x))a.push(Ps(e,t,n,o,r));for(let r of W_(e.y,t.y,n.y,o.y))a.push(Ps(e,t,n,o,r));return fm(a)},DP=(e,t,n,o,a=1,r=32)=>{let s=a*a,i=t;for(let l=1;l<=r;l++){let c=Ds(t,n,o,l/r);if(El(e,i,c)<=s)return!0;i=c}return!1},PP=(e,t,n,o,a,r=1,s=64)=>{let i=r*r,l=t;for(let c=1;c<=s;c++){let u=Ps(t,n,o,a,c/s);if(El(e,l,u)<=i)return!0;l=u}return!1},BP=(e,t,n,o=16)=>{let a=new Array(o+1);for(let r=0;r<=o;r++)a[r]=Ds(e,t,n,r/o);return a},zP=(e,t,n,o,a=32)=>{let r=new Array(a+1);for(let s=0;s<=a;s++)r[s]=Ps(e,t,n,o,s/a);return r},q_=(e,t,n)=>{let o=e-2*t+n;if(o===0)return[];let a=(e-t)/o;return a>0&&a<1?[a]:[]},W_=(e,t,n,o)=>{let a=-e+3*t-3*n+o,r=2*(e-2*t+n),s=t-e,i=[];if(Math.abs(a)<1e-12){if(Math.abs(r)>1e-12){let f=-s/r;f>0&&f<1&&i.push(f)}return i}let l=r*r-4*a*s;if(l<0)return i;let c=Math.sqrt(l),u=(-r+c)/(2*a),d=(-r-c)/(2*a);return u>0&&u<1&&i.push(u),d>0&&d<1&&i.push(d),i};var hm={};no(hm,{lineLine:()=>NP,segmentCubic:()=>HP,segmentQuadratic:()=>FP,segmentSegment:()=>j_});var pm=1e-12,NP=(e,t,n,o)=>{let a=t.x-e.x,r=t.y-e.y,s=o.x-n.x,i=o.y-n.y,l=a*i-r*s;if(Math.abs(l)<pm)return null;let c=n.x-e.x,u=n.y-e.y,d=(c*i-u*s)/l;return{x:e.x+d*a,y:e.y+d*r}},j_=(e,t,n,o)=>{let a=t.x-e.x,r=t.y-e.y,s=o.x-n.x,i=o.y-n.y,l=a*i-r*s;if(Math.abs(l)<pm)return null;let c=n.x-e.x,u=n.y-e.y,d=(c*i-u*s)/l,f=(c*r-u*a)/l;return d<0||d>1||f<0||f>1?null:{x:e.x+d*a,y:e.y+d*r}},FP=(e,t,n,o,a)=>{let r=t.y-e.y,s=-(t.x-e.x),i=-(r*e.x+s*e.y),l=r*n.x+s*n.y,c=r*o.x+s*o.y,u=r*a.x+s*a.y,d=l-2*c+u,f=-2*l+2*c,p=l+i,h=[];if(Math.abs(d)<pm){if(Math.abs(f)>pm){let x=-p/f;x>=0&&x<=1&&h.push(x)}}else{let x=f*f-4*d*p;if(x>=0){let A=Math.sqrt(x),C=(-f+A)/(2*d),_=(-f-A)/(2*d);C>=0&&C<=1&&h.push(C),_>=0&&_<=1&&h.push(_)}}let m=[],b=t.x-e.x,y=t.y-e.y,g=b*b+y*y;for(let x of h){let A=Ds(n,o,a,x);if(g===0){m.push(A);continue}let C=((A.x-e.x)*b+(A.y-e.y)*y)/g;C>=0&&C<=1&&m.push(A)}return m},HP=(e,t,n,o,a,r,s=64)=>{let i=[],l=n;for(let c=1;c<=s;c++){let u=Ps(n,o,a,r,c/s),d=j_(e,t,l,u);d!==null&&i.push(d),l=u}return i};var mm={};no(mm,{contrastRatio:()=>N1,format:()=>qP,luminance:()=>z1,meetsContrastAA:()=>VP,meetsContrastAAA:()=>ZP,mix:()=>WP,parse:()=>GP,withAlpha:()=>jP});var UP=Object.freeze({transparent:{r:0,g:0,b:0,a:0},black:{r:0,g:0,b:0,a:1},white:{r:255,g:255,b:255,a:1},red:{r:255,g:0,b:0,a:1},green:{r:0,g:128,b:0,a:1},blue:{r:0,g:0,b:255,a:1},yellow:{r:255,g:255,b:0,a:1},cyan:{r:0,g:255,b:255,a:1},magenta:{r:255,g:0,b:255,a:1},gray:{r:128,g:128,b:128,a:1},grey:{r:128,g:128,b:128,a:1}}),GP=e=>{let t=e.trim().toLowerCase(),n=UP[t];if(n!==void 0)return n;if(t.startsWith("#")){let a=t.slice(1);if(a.length===3||a.length===4){let r=_r(a.charAt(0)+a.charAt(0)),s=_r(a.charAt(1)+a.charAt(1)),i=_r(a.charAt(2)+a.charAt(2)),l=a.length===4?_r(a.charAt(3)+a.charAt(3))/255:1;if(Number.isNaN(r)||Number.isNaN(s)||Number.isNaN(i)||Number.isNaN(l))throw new Error(`Invalid hex color: ${e}`);return{r,g:s,b:i,a:l}}if(a.length===6||a.length===8){let r=_r(a.slice(0,2)),s=_r(a.slice(2,4)),i=_r(a.slice(4,6)),l=a.length===8?_r(a.slice(6,8))/255:1;if(Number.isNaN(r)||Number.isNaN(s)||Number.isNaN(i)||Number.isNaN(l))throw new Error(`Invalid hex color: ${e}`);return{r,g:s,b:i,a:l}}throw new Error(`Invalid hex color length: ${e}`)}let o=/^rgba?\(([^)]+)\)$/.exec(t);if(o){let a=(o[1]??"").split(",").map(c=>c.trim());if(a.length!==3&&a.length!==4)throw new Error(`Expected 3 or 4 components: ${e}`);let r=Math.round(Number(a[0])),s=Math.round(Number(a[1])),i=Math.round(Number(a[2])),l=a.length===4?Number(a[3]):1;if([r,s,i,l].some(Number.isNaN))throw new Error(`Invalid component: ${e}`);return{r,g:s,b:i,a:l}}throw new Error(`Cannot parse color: ${e}`)},qP=e=>{let t=P1(e.r),n=P1(e.g),o=P1(e.b),a=XP(e.a);return a===1?`#${B1(t)}${B1(n)}${B1(o)}`:`rgba(${t}, ${n}, ${o}, ${a})`},WP=(e,t,n)=>({r:e.r+(t.r-e.r)*n,g:e.g+(t.g-e.g)*n,b:e.b+(t.b-e.b)*n,a:e.a+(t.a-e.a)*n}),jP=(e,t)=>({...e,a:t}),z1=e=>{let t=n=>{let o=n/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)},N1=(e,t)=>{let n=z1(e),o=z1(t),[a,r]=n<o?[n,o]:[o,n];return(r+.05)/(a+.05)},VP=(e,t,n=!1)=>N1(e,t)>=(n?3:4.5),ZP=(e,t,n=!1)=>N1(e,t)>=(n?4.5:7),_r=e=>parseInt(e,16),P1=e=>{let t=Math.round(e);return t<0?0:t>255?255:t},XP=e=>e<0?0:e>1?1:e,B1=e=>e.toString(16).padStart(2,"0");var qd={};no(qd,{offsetClosedPath:()=>YP,signedArea:()=>KP});var YP=(e,t)=>{if(e.length<3||t===0)return e.map(l=>({x:l.x,y:l.y}));let n=0,o=0;for(let l of e)n+=l.x,o+=l.y;n/=e.length,o/=e.length;let a=e.length,r=new Array(a),s=new Array(a);for(let l=0;l<a;l++){let c=L(e[l]),u=L(e[(l+1)%a]),d=u.x-c.x,f=u.y-c.y,p=Math.hypot(d,f)||1;r[l]=-f/p,s[l]=d/p}let i=[];for(let l=0;l<a;l++){let c=(l-1+a)%a,u=L(r[c]),d=L(s[c]),f=L(r[l]),p=L(s[l]),h=u+f,m=d+p,b=Math.hypot(h,m);b<1e-6?(h=u,m=d):(h/=b,m/=b);let y=L(e[l]),g=n-y.x,x=o-y.y,C=h*g+m*x>=0?1:-1,_=h*u+m*d,v=_>1e-6?t/_:t;i.push({x:y.x+C*h*v,y:y.y+C*m*v})}return i},KP=e=>{let t=0;for(let n=0;n<e.length;n++){let o=L(e[n]),a=L(e[(n+1)%e.length]);t+=o.x*a.y-a.x*o.y}return t/2};var F1=e=>{if(!(e.stroke!==void 0&&e.stroke!=="transparent"))return 0;let n=e.strokeWidth??1;if(n<=0)return 0;switch(e.strokeAlign??"center"){case"outside":return n;case"inside":return 0;default:return n/2}},Wd=(e,t,n)=>{if(!e||e.type==="sharp")return 0;let o=Math.min(Math.abs(t),Math.abs(n));if(o<=0)return 0;if(e.value!==void 0)return Math.max(0,Math.min(e.value,o/2));let a=32/.25;return o<=a?o*.25:32};var V_=null,H1=e=>{V_=e},U1=()=>V_;var jd=e=>e.type==="rectangle",G1=e=>e.type==="ellipse",Bs=e=>e.type==="polygon",q1=e=>e.type==="path",Fe=e=>e.type==="text",Ut=e=>e.type==="image";var Oe=e=>e.type==="group",He=e=>e.type==="frame";var Z_=new Map,Hn=(e,t)=>{Z_.set(e,t)};var dt=e=>{let t=Z_.get(e.type);if(!t)throw new Error(`No bounder registered for shape type: ${e.type}`);return t(e)},z=e=>{let t=dt(e),n=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}],o=Math.sin(e.rotation),a=Math.cos(e.rotation),r=n.map(s=>{let i=s.x*e.scale.x,l=s.y*e.scale.y;return{x:e.position.x+(i*a-l*o),y:e.position.y+(i*o+l*a)}});return X.fromPoints(r)};Hn("rectangle",e=>({x:0,y:0,width:e.width,height:e.height}));Hn("ellipse",e=>({x:0,y:0,width:e.width,height:e.height}));Hn("polygon",e=>X.fromPoints(e.points));Hn("path",e=>{let t=[],n={x:0,y:0};for(let o of e.commands)switch(o.kind){case"M":case"L":t.push(o.to),n=o.to;break;case"Q":t.push(o.control,o.to),n=o.to;break;case"C":t.push(o.control1,o.control2,o.to),n=o.to;break;case"Z":break}return X.fromPoints(t)});Hn("text",e=>{let t=e.fontSize*1.2,n=e.text.split(`
|
|
10
|
-
`),o=U1(),a={bold:e.style.fontWeight==="bold",italic:e.style.fontStyle==="italic"},r=i=>{if(o){let l=o(i,e.fontFamily,e.fontSize,a);if(l!==null)return l}return i.length*e.fontSize*.6};if(e.maxWidth===void 0){let i=0;for(let l of n)i=Math.max(i,r(l));return i=Math.max(i,e.fontSize*.5),{x:0,y:0,width:i,height:Math.max(1,n.length)*t}}let s=0;for(let i of n)s+=Math.max(1,Math.ceil(r(i)/e.maxWidth));return{x:0,y:0,width:e.maxWidth,height:Math.max(1,s)*t}});Hn("image",e=>({x:0,y:0,width:e.width,height:e.height}));Hn("template",e=>({x:0,y:0,width:e.width,height:e.height}));Hn("brush",e=>{if(e.points.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,n=1/0,o=-1/0,a=-1/0;for(let r of e.points)r.x-r.width<t&&(t=r.x-r.width),r.y-r.width<n&&(n=r.y-r.width),r.x+r.width>o&&(o=r.x+r.width),r.y+r.width>a&&(a=r.y+r.width);return{x:t,y:n,width:o-t,height:a-n}});Hn("group",()=>({x:0,y:0,width:0,height:0}));Hn("frame",e=>({x:0,y:0,width:e.width,height:e.height}));Hn("block-arrow",e=>({x:0,y:0,width:e.width,height:e.height}));var ym=class{cellSize;cells=new Map;bounds=new Map;constructor(t=256){if(t<=0)throw new Error("cellSize must be positive");this.cellSize=t}get size(){return this.bounds.size}insert(t,n){if(this.bounds.has(t))throw new Error(`Element already indexed: ${t}`);this.bounds.set(t,n),this.eachCell(n,o=>{let a=this.cells.get(o);a||(a=new Set,this.cells.set(o,a)),a.add(t)})}remove(t){let n=this.bounds.get(t);n&&(this.bounds.delete(t),this.eachCell(n,o=>{let a=this.cells.get(o);a&&(a.delete(t),a.size===0&&this.cells.delete(o))}))}update(t,n){this.remove(t),this.insert(t,n)}query(t){let n=new Set;return this.eachCell(t,o=>{let a=this.cells.get(o);if(a)for(let r of a)n.add(r)}),n}clear(){this.cells.clear(),this.bounds.clear()}eachCell(t,n){let o=Math.floor(t.x/this.cellSize),a=Math.floor(t.y/this.cellSize),r=Math.floor((t.x+t.width)/this.cellSize),s=Math.floor((t.y+t.height)/this.cellSize);for(let i=a;i<=s;i++)for(let l=o;l<=r;l++)n(`${l},${i}`)}};var vt=(e,t)=>e.order<t.order?-1:e.order>t.order?1:0,Vd=(e,t)=>vt(t,e);var zs=(e,t)=>{let n=t.x*e.scale.x,o=t.y*e.scale.y,a=Math.cos(e.rotation),r=Math.sin(e.rotation);return{x:e.position.x+(n*a-o*r),y:e.position.y+(n*r+o*a)}};var gm=(e,t,n,o,a)=>{let r=a*Math.PI*2-Math.PI/2;return{x:e+n*Math.cos(r),y:t+o*Math.sin(r)}};var M=(e,t)=>e.elements.get(t),be=(e,t)=>e.links.get(t);var co=e=>[...e.layers.values()].sort(vt),La=(e,t)=>[...e.elements.values()].filter(n=>n.layerId===t).sort(vt),j1=(e,t)=>[...e.links.values()].filter(n=>n.layerId===t).sort(vt),X_=48,xm=10,W1=e=>[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],Y_=6,JP=(e,t)=>{let{x:n,y:o,width:a,height:r}=e,s=(l,c,u,d)=>{let f=[];for(let p=0;p<=Y_;p++){let h=u+(d-u)*(p/Y_);f.push({x:l+t*Math.cos(h),y:c+t*Math.sin(h)})}return f},i=Math.PI/2;return[...s(n+t,o+t,Math.PI,Math.PI+i),...s(n+a-t,o+t,-i,0),...s(n+a-t,o+r-t,0,i),...s(n+t,o+r-t,i,Math.PI)]},eB=e=>{let t=[],n={x:0,y:0};for(let o of e)if(o.kind==="M"||o.kind==="L")n=o.to,t.push({x:n.x,y:n.y});else if(o.kind==="Q"){for(let a=1;a<=xm;a++){let r=a/xm,s=1-r;t.push({x:s*s*n.x+2*s*r*o.control.x+r*r*o.to.x,y:s*s*n.y+2*s*r*o.control.y+r*r*o.to.y})}n=o.to}else if(o.kind==="C"){for(let a=1;a<=xm;a++){let r=a/xm,s=1-r;t.push({x:s**3*n.x+3*s*s*r*o.control1.x+3*s*r*r*o.control2.x+r**3*o.to.x,y:s**3*n.y+3*s*s*r*o.control1.y+3*s*r*r*o.control2.y+r**3*o.to.y})}n=o.to}return t},tB=new Map;var nB=e=>{if(Bs(e))return[e.points.map(t=>({x:t.x,y:t.y}))];if(G1(e)){let t=dt(e),n=t.x+t.width/2,o=t.y+t.height/2,a=t.width/2,r=t.height/2,s=[];for(let i=0;i<X_;i++)s.push(gm(n,o,a,r,i/X_));return[s]}if(jd(e)){let t=dt(e),n=Wd(e.style.roundness,t.width,t.height);return[n>0?JP(t,n):W1(t)]}return Ut(e)||Fe(e)?[W1(dt(e))]:q1(e)?[eB(e.commands)]:null},Zd=(e,t)=>{if(Oe(t)){let r=[];for(let s of V1(e,t.id))r.push(...Zd(e,s));return r}let n=nB(t);if(n)return n.map(r=>r.map(s=>zs(t,s)));let o=tB.get(t.type);if(o){let r=o(t).filter(s=>s.length>=2);if(r.length>0)return r.map(s=>s.map(i=>zs(t,i)))}let a=z(t);return[W1(a)]},V1=(e,t)=>{let n=[];for(let o of e.elements.values())o.parentId===t&&n.push(o);return n.sort(vt),n},Z1=(e,t)=>{let n=t;for(let o=0;n&&o<K_;o++){if(n.locked===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1},Ol=(e,t)=>{let n=t;for(let o=0;n&&o<K_;o++){if(n.hidden===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1};var X1=(e,t)=>{let n=e.elements.get(t);if(!n)return[];let o=new Set([t]),a=[n],r=[t];for(;r.length>0;){let s=r.pop();if(s===void 0)break;for(let i of V1(e,s))o.has(i.id)||(o.add(i.id),a.push(i),r.push(i.id))}return a},K_=64;var bm=(e,t,n=.5)=>{let o=[];for(let a of e.elements.values()){let r=z(a);if(!X.intersects(r,t))continue;let s=r.width*r.height;if(s<=0){o.push(a);continue}let i=Math.max(r.x,t.x),l=Math.max(r.y,t.y),c=Math.min(r.x+r.width,t.x+t.width),u=Math.min(r.y+r.height,t.y+t.height),d=c-i,f=u-l;if(d<=0||f<=0)continue;if(d*f/s>=n){o.push(a);continue}let h=t.width*t.height;h>0&&d*f/h>=n&&o.push(a)}return o},Xd=(e,t)=>{let n=co(e);for(let o=n.length-1;o>=0;o--){let a=n[o];if(!a?.visible)continue;let r=La(e,a.id);for(let s=r.length-1;s>=0;s--){let i=r[s];if(i!==void 0&&X.contains(z(i),t))return i}}},Y1=(e,t)=>{let n=new ym(t);for(let o of e.elements.values())n.insert(o.id,z(o));return n};var K1=(e,t,n)=>{let o={x:n.x,y:n.y,width:0,height:0},a=t.query(o);if(a.size===0)return;let r,s="",i="",l=!1;for(let c of a){let u=e.elements.get(c);if(!u||!X.contains(z(u),n))continue;let d=e.layers.get(u.layerId);if(!d?.visible)continue;let f=d.order;(!l||f>s||f===s&&u.order>i)&&(r=u,s=f,i=u.order,l=!0)}return r};var oB=[];var Yd=e=>Ns(e)!==null,Ns=e=>{for(let s of oB){let i=s(e);if(i)return i}let t=e.metadata,n=e;if(t?.autoLayout!=null&&typeof n.width=="number"&&typeof n.height=="number"){let s=t.container?.padding??aB,i=n.width,l=n.height;return{dropZone:{x:s,y:s,width:Math.max(0,i-2*s),height:Math.max(0,l-2*s)},padding:s}}let o=e.metadata?.container;if(!o||typeof o!="object")return null;let a=o;return a.dropZone?a.padding!==void 0?{dropZone:a.dropZone,padding:a.padding}:{dropZone:a.dropZone}:null},aB=0,Un=e=>{let t=Ns(e);return t?{x:e.position.x+t.dropZone.x,y:e.position.y+t.dropZone.y,width:t.dropZone.width,height:t.dropZone.height}:null},rB=[];var $1=e=>{for(let n of rB){let o=n(e);if(o)return o.map(a=>({x:e.position.x+a.x,y:e.position.y+a.y,width:a.width,height:a.height}))}let t=Un(e);return t?[t]:[]},Kd=(e,t,n=new Set)=>{let o=co(e);for(let a=o.length-1;a>=0;a--){let r=o[a];if(!r?.visible)continue;let s=La(e,r.id);for(let i=s.length-1;i>=0;i--){let l=s[i];if(l===void 0||n.has(l.id))continue;let c=Un(l);if(c&&X.contains(c,t))return l}}return null},Q1=(e,t)=>{let n=Ns(e);if(!n)return null;let o=n.padding??0,a={x:t.x-e.position.x,y:t.y-e.position.y,width:t.width,height:t.height},r=n.dropZone,s=a.x,i=a.y,l=a.x+a.width,c=a.y+a.height,u=r.x,d=r.y,f=r.x+r.width,p=r.y+r.height,h=s<u?s-o:u,m=i<d?i-o:d,b=l>f?l+o:f,y=c>p?c+o:p;return h===u&&m===d&&b===f&&y===p?null:{x:h,y:m,width:b-h,height:y-m}},J1=(e,t)=>{let n=e.spec.dropZone,o=n.x-t.x,a=n.y-t.y,r=t.x+t.width-(n.x+n.width),s=t.y+t.height-(n.y+n.height);return{width:e.width+o+r,height:e.height+a+s,positionOffset:{x:-o,y:-a}}};var $_=new Set,eb={"top-left":{x:0,y:0},top:{x:.5,y:0},"top-right":{x:1,y:0},right:{x:1,y:.5},"bottom-right":{x:1,y:1},bottom:{x:.5,y:1},"bottom-left":{x:0,y:1},left:{x:0,y:.5},center:{x:.5,y:.5}},Q_=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left","center"];var J_=(e,t)=>tb(e,t),Gt=(e,t)=>{let n=J_(e,t),o=n.x*e.scale.x,a=n.y*e.scale.y,r=Math.cos(e.rotation),s=Math.sin(e.rotation);return{x:e.position.x+(o*r-a*s),y:e.position.y+(o*s+a*r)}},Eo=(e,t)=>{let n=Gt(e,t),o=Gt(e,{kind:"named",name:"center"}),a=n.x-o.x,r=n.y-o.y,s=Math.hypot(a,r);return s<1e-6?{x:0,y:-1}:{x:a/s,y:r/s}},Sa=(e,t,n=$_)=>{let o=null;for(let[a,r]of Am(e)){if(n.has(a))continue;let s=sB(a),i=Gt(e,s),l=i.x-t.x,c=i.y-t.y,u=Math.hypot(l,c);(o===null||u<o.distance)&&(o={ref:s,world:i,distance:u})}return o||{ref:{kind:"named",name:"center"},world:Gt(e,{kind:"named",name:"center"}),distance:1/0}},sB=e=>{let t=/^edge-(\d+)$/.exec(e);return t?{kind:"edge",index:Number(t[1]),t:.5}:{kind:"named",name:e}},uo=e=>Yd(e)?iB:$_,iB=new Set(["center"]);var Am=e=>{let t=new Map;if(Bs(e))lB(e,t);else{let n=dt(e);for(let o of eC){let a=eb[o];t.set(o,{x:n.x+n.width*a.x,y:n.y+n.height*a.y})}}if(e.anchors)for(let[n,o]of Object.entries(e.anchors))t.set(n,tb(e,o));return t},eC=["top","right","bottom","left"],lB=(e,t)=>{let n=e.points;if(!(n.length<2))for(let o=0;o<n.length;o++){let a=n[o],r=n[(o+1)%n.length];a===void 0||r===void 0||t.set(`edge-${o}`,Ae.midpoint(a,r))}},tb=(e,t)=>{switch(t.kind){case"named":{let n=nC(e,t.name);if(!n)throw new Error(`Unknown anchor "${t.name}" on shape ${e.id} (type ${e.type}). Standard names: ${Q_.join(", ")}; custom anchors live on shape.anchors.`);return n}case"ratio":{let n=dt(e);return{x:n.x+n.width*t.position.x,y:n.y+n.height*t.position.y}}case"absolute":{let n=dt(e);return{x:n.x+t.offset.x,y:n.y+t.offset.y}}case"edge":return tC(e,t.index,t.t)}},tC=(e,t,n)=>{if(Bs(e)&&e.points.length>=2){let a=e.points,r=a.length,s=(t%r+r)%r,i=a[s],l=a[(s+1)%r];if(i!==void 0&&l!==void 0){let c=n<0?0:n>1?1:n;return{x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}}}let o=dt(e);return{x:o.x+o.width/2,y:o.y+o.height/2}},nC=(e,t)=>{let n=e.anchors?.[t];if(n!==void 0)return n.kind==="named"?nC(e,n.name):tb(e,n);if(Bs(e)&&t.startsWith("edge-")){let r=parseInt(t.slice(5),10);if(!isNaN(r))return tC(e,r,.5)}let o=eb[t];if(!o)return;let a=dt(e);return{x:a.x+a.width*o.x,y:a.y+a.height*o.y}};var nb=(e,t,n,o)=>{let a=Math.hypot(t.x-e.x,t.y-e.y),r=Math.min(a*.8,240);return{c1:{x:e.x+n.x*r,y:e.y+n.y*r},c2:{x:t.x+o.x*r,y:t.y+o.y*r},to:t}},ob=e=>{let t=[],n=6;for(let o=0;o<e.length-1;o++){let a=L(e[o]),r=L(e[o+1]),s=e[o-1]??a,i=e[o+2]??r;t.push({c1:{x:a.x+(r.x-s.x)/n,y:a.y+(r.y-s.y)/n},c2:{x:r.x-(i.x-a.x)/n,y:r.y-(i.y-a.y)/n},to:r})}return t},$d=(e,t,n=16)=>{let o=[e],a=e;for(let r of t){for(let s=1;s<=n;s++)o.push(Fn.cubicAt(a,r.c1,r.c2,r.to,s/n));a=r.to}return o};var Rl={x:1,y:0},Qd={x:0,y:1},Jd={x:-1,y:0},ef={x:0,y:-1},oC=e=>e.y===0;var cB=e=>{let t=Math.abs(e.x),n=Math.abs(e.y);return e.x>n?Rl:e.x<=-n?Jd:e.y>t?Qd:ef},tf=(e,t)=>cB({x:e.x-t.x,y:e.y-t.y}),vm=(e,t)=>{let n=z(e),o=Math.abs(t.x-n.x),a=Math.abs(n.x+n.width-t.x),r=Math.abs(t.y-n.y),s=Math.abs(n.y+n.height-t.y),i=Math.min(o,a,r,s);return i===o?Jd:i===a?Rl:i===r?ef:Qd},aC=(e,t)=>{let n=z(e),o=n.x+n.width/2,a=n.y+n.height/2,r=t.x-o,s=t.y-a;if(r===0&&s===0)return Rl;let i=n.width||1,l=n.height||1,c=r/(i/2),u=s/(l/2);return Math.abs(c)>=Math.abs(u)?c>=0?Rl:Jd:u>=0?Qd:ef};var Lm=new Map,ab=(e,t)=>{Lm.set(e,t)},rC=e=>Lm.get(e),Sm=(e,t)=>{let n=Lm.get(e.type);if(!n)throw new Error(`No outline sampler registered for shape type: ${e.type}`);let o=n(e,Il.clamp01(t));return zs(e,o)},sC=(e,t,n=64)=>{let o=Lm.get(e.type);if(!o)return null;let a=0,r=zs(e,o(e,0)),s=Ae.distance(t,r);for(let i=1;i<n;i++){let l=i/n,c=zs(e,o(e,l)),u=Ae.distance(t,c);u<s&&(s=u,a=l,r=c)}return{ratio:a,world:r,distance:s}},iC=(e,t)=>{if(e.length===0)return{x:0,y:0};if(e.length===1)return L(e[0]);let n=0,o=[];for(let r=0;r<e.length;r++){let s=L(e[r]),i=L(e[(r+1)%e.length]),l=Ae.distance(s,i);o.push(l),n+=l}if(n===0)return L(e[0]);let a=n*t;for(let r=0;r<e.length;r++){let s=L(o[r]);if(a<=s){let i=L(e[r]),l=L(e[(r+1)%e.length]),c=s===0?0:a/s;return{x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}}a-=s}return L(e[0])};ab("rectangle",(e,t)=>{let n=dt(e),o=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}];return iC(o,t)});ab("ellipse",(e,t)=>{let n=dt(e),o=n.x+n.width/2,a=n.y+n.height/2,r=n.width/2,s=n.height/2;return gm(o,a,r,s,t)});ab("polygon",(e,t)=>iC(e.points,t));var lC=e=>e.kind==="point"?null:e.elementId,cC=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:Math.sign(e.x)||0,y:0}:{x:0,y:Math.sign(e.y)},uC=(e,t,n)=>{if(t.kind==="anchor"){let a=cC(Eo(e,t.anchor));if(a.x!==0||a.y!==0)return a}let o=cC(vm(e,n));return o.x!==0||o.y!==0?o:{x:0,y:-1}},fB=(e,t)=>{let n=e.x+e.width/2,o=e.y+e.height/2;return t.y<0?{x:n,y:e.y}:t.y>0?{x:n,y:e.y+e.height}:t.x<0?{x:e.x,y:o}:{x:e.x+e.width,y:o}},sb=(e,t)=>{let n=lC(t.from);if(!n||n!==lC(t.to))return null;let o=M(e,n);if(!o)return null;let a=z(o),r=Gn(e,t.from),s=Gn(e,t.to);if(!r||!s)return null;let i=r,l=s,c=uC(o,t.from,i),u=uC(o,t.to,l);if(Math.hypot(l.x-i.x,l.y-i.y)<1){let d=c.x!==0||c.y!==0?c:{x:0,y:-1};c=d,u=d;let f={x:-d.y,y:d.x},p=d.x!==0?a.height:a.width,h=Math.min(24,p/3),m=fB(a,d);i={x:m.x-f.x*h,y:m.y-f.y*h},l={x:m.x+f.x*h,y:m.y+f.y*h}}return{p1:i,n1:c,p2:l,n2:u,bounds:a}},pB=e=>{let t=40,{p1:n,n1:o,p2:a,n2:r,bounds:s}=e,i={x:n.x+o.x*t,y:n.y+o.y*t},l={x:a.x+r.x*t,y:a.y+r.y*t},c=o.x===r.x&&o.y===r.y,u=o.x===-r.x&&o.y===-r.y;if(c)return[n,i,l,a];if(u){if(o.x===0){let p=s.x+s.width+t;return[n,i,{x:p,y:i.y},{x:p,y:l.y},l,a]}let f=s.y+s.height+t;return[n,i,{x:i.x,y:f},{x:l.x,y:f},l,a]}let d={x:o.y!==0?l.x:i.x,y:o.y!==0?i.y:l.y};return[n,i,d,l,a]},hB=e=>{let t=40*2.2,{p1:n,n1:o,p2:a,n2:r}=e;return{start:n,segments:[{c1:{x:n.x+o.x*t,y:n.y+o.y*t},c2:{x:a.x+r.x*t,y:a.y+r.y*t},to:a}]}},fC=e=>{let t=z(e);return{x:t.x+t.width/2,y:t.y+t.height/2}},mB=(e,t)=>{let n=fC(e),o=t.x-n.x,a=t.y-n.y;if(Math.abs(o)<1e-6&&Math.abs(a)<1e-6||!rC(e.type))return n;let s=Math.hypot(o,a),i={x:n.x+o/s*1e6,y:n.y+a/s*1e6},l=null,c=1/0,u=Sm(e,0);for(let d=1;d<=96;d++){let f=Sm(e,d/96),p=hm.segmentSegment(n,i,u,f);if(p){let h=Math.hypot(p.x-t.x,p.y-t.y);h<c&&(c=h,l=p)}u=f}return l??n},Gn=(e,t,n)=>{if(t.kind==="point")return t.position;let o=M(e,t.elementId);return o?t.kind==="anchor"?Gt(o,t.anchor):t.kind==="floating"?mB(o,n??fC(o)):Sm(o,t.ratio):null},rt=(e,t)=>{let n=sb(e,t);if(n)return pB(n);let o=Gn(e,t.from);if(!o)return null;let a=Gn(e,t.to);if(!a)return null;let r=t.from.kind==="floating"?Gn(e,t.from,a)??o:o,s=t.to.kind==="floating"?Gn(e,t.to,o)??a:a;if((t.routing??"straight")!=="orthogonal")return[r,...t.waypoints??[],s];if(t.routedPoints!==void 0)return[r,...t.routedPoints,s];let l=rb(t.from),c=rb(t.to),u=Math.min(40,Math.max(8,Math.abs(s.x-r.x)/4,Math.abs(s.y-r.y)/4));if(l||c){let m=[r],b=r,y=s;l&&(b={x:r.x+l.x*u,y:r.y+l.y*u},m.push(b));let g=null;c&&(g={x:s.x+c.x*u,y:s.y+c.y*u});let x=g??y,A=x.x-b.x,C=x.y-b.y,_=l?Math.abs(l.x)>Math.abs(l.y):Math.abs(A)>=Math.abs(C);if(Math.abs(A)>.5&&Math.abs(C)>.5){let v=_?{x:x.x,y:b.y}:{x:b.x,y:x.y};m.push(v)}return g&&m.push(g),m.push(s),m}let d=s.x-r.x,f=s.y-r.y,h=Math.abs(d)>=Math.abs(f)?{x:s.x,y:r.y}:{x:r.x,y:s.y};return[r,h,s]},rb=e=>{if(e.kind!=="anchor"||e.anchor.kind!=="named")return null;switch(e.anchor.name){case"top":return{x:0,y:-1};case"right":return{x:1,y:0};case"bottom":return{x:0,y:1};case"left":return{x:-1,y:0};default:return null}},dC=(e,t,n)=>{let o=rb(e);if(o)return o;let a=n.x-t.x,r=n.y-t.y;return Math.abs(a)>=Math.abs(r)?{x:Math.sign(a)||1,y:0}:{x:0,y:Math.sign(r)||1}},nf=(e,t)=>{if((t.routing??"straight")!=="bezier")return null;let n=sb(e,t);if(n)return hB(n);let o=rt(e,t);if(!o||o.length<2)return null;let a=L(o[0]),r=L(o[o.length-1]);if(o.length===2){let s=dC(t.from,a,r),i=dC(t.to,r,a);return{start:a,segments:[nb(a,r,s,i)]}}return{start:a,segments:ob(o)}},Dl=(e,t)=>{if((t.routing??"straight")!=="bezier")return rt(e,t);let n=nf(e,t);return n?$d(n.start,n.segments):null},of=(e,t)=>{let n=t.routing??"straight";if(n==="orthogonal")return null;if(n==="bezier"){let r=nf(e,t);if(!r)return null;let s=[],i=r.start;for(let l of r.segments)s.push(Fn.cubicAt(i,l.c1,l.c2,l.to,.5)),i=l.to;return s}let o=rt(e,t);if(!o||o.length<2)return null;let a=[];for(let r=0;r<o.length-1;r++){let s=L(o[r]),i=L(o[r+1]);a.push(Ae.midpoint(s,i))}return a},ib=(e,t,n=5)=>{let o=null;for(let a of e.links.values()){let r=Dl(e,a);if(!r)continue;let s=1/0;for(let i=1;i<r.length;i++){let l=Ml.distanceToSegment(t,L(r[i-1]),L(r[i]));l<s&&(s=l)}s>n||(!o||s<=o.distance)&&(o={edge:a,distance:s})}return o?.edge??null};var pC=new Map,lb=(e,t)=>{pC.set(e,t)},af=e=>{let t=z(e),n=pC.get(e.type);if(!n)return t;let o=n(e),a=o.top??0,r=o.right??0,s=o.bottom??0,i=o.left??0;return a===0&&r===0&&s===0&&i===0?t:{x:t.x-i,y:t.y-a,width:t.width+i+r,height:t.height+a+s}};var rf=class{contributors;constructor(t){this.contributors=t}snap(t){let n=[];for(let o of this.contributors)for(let a of o.contribute(t))a.distance<=t.threshold*t.threshold&&n.push(a);return n.sort((o,a)=>o.distance-a.distance),{best:n[0]??null,all:n}}},ub={id:"grid",contribute(e){if(!e.scene.viewport.gridEnabled)return[];let t=20,n={x:Math.round(e.probe.x/t)*t,y:Math.round(e.probe.y/t)*t},o=n.x-e.probe.x,a=n.y-e.probe.y;return[{snapped:n,distance:o*o+a*a,kind:"grid"}]}},db={id:"anchor",contribute(e){if(e.gesture!=="draw-edge"&&e.gesture!=="edit-edge-endpoint")return[];let t=[];for(let n of e.scene.elements.values()){if(e.excludeElementIds?.has(n.id)||!hC(n,e.probe,e.threshold))continue;let o=Sa(n,e.probe,uo(n)),a=o.world.x-e.probe.x,r=o.world.y-e.probe.y;t.push({snapped:o.world,distance:a*a+r*r,kind:"anchor",metadata:{elementId:n.id,ref:o.ref}})}return t}},fb={id:"outline",contribute(e){if(e.gesture!=="draw-edge"&&e.gesture!=="edit-edge-endpoint")return[];let t=[];for(let n of e.scene.elements.values()){if(e.excludeElementIds?.has(n.id)||!hC(n,e.probe,e.threshold))continue;let o=sC(n,e.probe);if(!o)continue;let a=o.world.x-e.probe.x,r=o.world.y-e.probe.y;t.push({snapped:o.world,distance:a*a+r*r,kind:"outline",metadata:{elementId:n.id,ratio:o.ratio}})}return t}},hC=(e,t,n)=>{let o=n,a=t.x-e.position.x,r=t.y-e.position.y;return Math.abs(a)<=1e3+o&&Math.abs(r)<=1e3+o};var pb=()=>20,km=e=>e.snapToGrid??!0,hb=Object.freeze({pan:{x:0,y:0},zoom:1,rotation:0,size:{width:0,height:0},gridEnabled:!1}),qn=e=>{let t=B.translation(-e.pan.x,-e.pan.y),n=B.rotation(e.rotation),o=B.scaling(e.zoom);return B.multiply(o,B.multiply(n,t))},ka=e=>B.inverse(qn(e)),mb=(e,t)=>({...e,pan:{x:e.pan.x-t.x/e.zoom,y:e.pan.y-t.y/e.zoom}}),wm=(e,t,n)=>{let o=e.zoom*t;return{...e,zoom:o,pan:{x:n.x-(n.x-e.pan.x)/t,y:n.y-(n.y-e.pan.y)/t}}},yb=(e,t,n)=>({...e,size:{width:t,height:n}});var Lt=class extends Error{name="FractionalIndexError"};var _m="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function mC(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw new Lt("invalid order key head: "+e)}function yC(e){let t=e.charAt(0);if(e.length!==mC(t))throw new Lt("invalid integer part of order key: "+e)}function Pl(e){let t=mC(e.charAt(0));if(t>e.length)throw new Lt("invalid order key: "+e);return e.slice(0,t)}function gb(e,t){yC(e);let n=t.charAt(0),[o,...a]=e.split("");if(o===void 0)throw new Lt("invalid integer part of order key: "+e);let r=!0;for(let s=a.length-1;r&&s>=0;s--){let i=a[s];if(i===void 0)continue;let l=t.indexOf(i)+1;l===t.length?a[s]=n:(a[s]=t.charAt(l),r=!1)}if(r){if(o==="Z")return"a"+n;if(o==="z")return null;let s=String.fromCharCode(o.charCodeAt(0)+1);return s>"a"?a.push(n):a.pop(),s+a.join("")}return o+a.join("")}function gC(e,t){yC(e);let[n,...o]=e.split("");if(n===void 0)throw new Lt("invalid integer part of order key: "+e);let a=t.slice(-1),r=!0;for(let s=o.length-1;r&&s>=0;s--){let i=o[s];if(i===void 0)continue;let l=t.indexOf(i)-1;l===-1?o[s]=a:(o[s]=t.charAt(l),r=!1)}if(r){if(n==="a")return"Z"+a;if(n==="A")return null;let s=String.fromCharCode(n.charCodeAt(0)-1);return s<"Z"?o.push(a):o.pop(),s+o.join("")}return n+o.join("")}function Fs(e,t,n){let o=n.charAt(0);if(t!==null&&e>=t)throw new Lt(e+" >= "+t);if(e.slice(-1)===o||t!==null&&t.slice(-1)===o)throw new Lt("trailing zero");if(t!==null){let s=0;for(;(e.charAt(s)||o)===t.charAt(s);)s++;if(s>0)return t.slice(0,s)+Fs(e.slice(s),t.slice(s),n)}let a=e?n.indexOf(e.charAt(0)):0,r=t!==null?n.indexOf(t.charAt(0)):n.length;if(r-a>1){let s=Math.round(.5*(a+r));return n.charAt(s)}return t!==null&&t.length>1?t.slice(0,1):n.charAt(a)+Fs(e.slice(1),null,n)}function xC(e){return"A"+e.charAt(0).repeat(26)}function gB(e){return"a"+e.charAt(0)}function xb(e,t=_m){if(e===xC(t))throw new Lt("invalid order key: "+e);let n=Pl(e);if(e.slice(n.length).slice(-1)===t.charAt(0))throw new Lt("invalid order key: "+e)}function Wn(e,t,n=_m){let o=e??null,a=t??null;if(o!==null&&xb(o,n),a!==null&&xb(a,n),o!==null&&a!==null&&o>=a)throw new Lt(o+" >= "+a);if(o===null&&a===null)return gB(n);if(o===null){let u=Pl(a),d=a.slice(u.length);if(u===xC(n))return u+Fs("",d,n);if(u<a)return u;let f=gC(u,n);if(f===null)throw new Lt("cannot decrement any more");return f}if(a===null){let u=Pl(o),d=o.slice(u.length),f=gb(u,n);return f===null?u+Fs(d,null,n):f}let r=Pl(o),s=o.slice(r.length),i=Pl(a),l=a.slice(i.length);if(r===i)return r+Fs(s,l,n);let c=gb(r,n);if(c===null)throw new Lt("cannot increment any more");return c<a?c:r+Fs(s,null,n)}function sf(e,t,n,o=_m){if(!Number.isInteger(n)||n<0)throw new Lt(`n must be a non-negative integer, got ${n}`);if(n===0)return[];if(n===1)return[Wn(e,t,o)];let a=e??null,r=t??null;if(r===null){let l=Wn(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=Wn(l,r,o),c.push(l);return c}if(a===null){let l=Wn(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=Wn(a,l,o),c.push(l);return c.reverse(),c}let s=Math.floor(n/2),i=Wn(a,r,o);return[...sf(a,i,s,o),i,...sf(i,r,n-s-1,o)]}var bn=$t("default"),xB=()=>({id:bn,name:"Default",visible:!0,locked:!1,order:Wn(null,null)}),Qt=Object.freeze({elements:new Map,links:new Map,layers:new Map([[bn,xB()]]),annotations:new Map,files:new Map,viewport:hb}),bb=()=>({elements:new Map(Qt.elements),links:new Map(Qt.links),layers:new Map(Qt.layers),annotations:new Map(Qt.annotations),files:new Map(Qt.files),viewport:Qt.viewport});var Ab=(e,t)=>e.files.get(t),J=(e,t)=>{switch(t.kind){case"element":{let n=new Map(e.elements);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,elements:n}}case"link":{let n=new Map(e.links);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,links:n}}case"layer":{let n=new Map(e.layers);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,layers:n}}case"annotation":{let n=new Map(e.annotations);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,annotations:n}}case"viewport":return{...e,viewport:t.after};case"file":{let n=new Map(e.files);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,files:n}}case"batch":return t.patches.reduce(J,e)}},we=e=>{let t=null;for(let n of e)(t===null||n>t)&&(t=n);return Wn(t,null)},Bl=e=>{let t=null;for(let n of e)(t===null||n<t)&&(t=n);return Wn(null,t)},Cm=(e,t)=>Wn(e,t),vb=(e,t,n)=>sf(e,t,n);var Lb={pan:"browser",zoom:"browser",rotation:"browser",size:"ephemeral",gridEnabled:"export",gridStyle:"export",snapToGrid:"export"},bC=Object.keys(Lb),RQ=bC.filter(e=>Lb[e]==="ephemeral"),bB=(e,...t)=>{let n=e;for(let o of t)if(o)for(let a of bC)o[a]!==void 0&&(n={...n,[a]:o[a]});return n},Sb=(e={})=>{let{saved:t,hostSettings:n}=e;return{elements:new Map(t?.elements??Qt.elements),links:new Map(t?.links??Qt.links),layers:new Map(t?.layers??Qt.layers),annotations:new Map(t?.annotations??Qt.annotations),files:new Map(t?.files??Qt.files),viewport:bB(Qt.viewport,n?.viewport,t?.viewport)}};var kb=(e,t,n={})=>({id:e,data:t,mime:n.mime??"application/octet-stream",createdAt:n.createdAt??Date.now(),...n.name!==void 0?{name:n.name}:{}});var zl=e=>{switch(e.kind){case"element":return{kind:"element",id:e.id,before:e.after,after:e.before};case"link":return{kind:"link",id:e.id,before:e.after,after:e.before};case"layer":return{kind:"layer",id:e.id,before:e.after,after:e.before};case"annotation":return{kind:"annotation",id:e.id,before:e.after,after:e.before};case"viewport":return{kind:"viewport",before:e.after,after:e.before};case"file":return{kind:"file",id:e.id,before:e.after,after:e.before};case"batch":return{kind:"batch",patches:e.patches.map(zl).reverse()}}},Mo=e=>{let t=[];for(let n of e)n.kind==="batch"?t.push(...n.patches):t.push(n);return{kind:"batch",patches:t}},Cr=e=>{switch(e.kind){case"element":case"link":case"layer":case"annotation":case"file":return e.before===e.after;case"viewport":return e.before===e.after;case"batch":return e.patches.length===0||e.patches.every(Cr)}};var Je=(e,t)=>{if(e.elements.has(t.id))throw new Error(`Element already exists: ${t.id}`);let n={kind:"element",id:t.id,before:null,after:t};return{scene:J(e,n),patch:n}},jn=(e,t)=>{let n=e.elements.get(t);if(!n)throw new Error(`Element not found: ${t}`);let o={kind:"element",id:t,before:n,after:null};return{scene:J(e,o),patch:o}},le=(e,t,n)=>{let o=e.elements.get(t);if(!o)throw new Error(`Element not found: ${t}`);let a=n(o),r={kind:"element",id:t,before:o,after:a};return{scene:J(e,r),patch:r}};var wb=(e,t)=>{if(e.links.has(t.id))throw new Error(`Link already exists: ${t.id}`);let n={kind:"link",id:t.id,before:null,after:t};return{scene:J(e,n),patch:n}},lf=(e,t)=>{let n=e.links.get(t);if(!n)throw new Error(`Link not found: ${t}`);let o={kind:"link",id:t,before:n,after:null};return{scene:J(e,o),patch:o}},et=(e,t,n)=>{let o=e.links.get(t);if(!o)throw new Error(`Link not found: ${t}`);let a=n(o),r={kind:"link",id:t,before:o,after:a};return{scene:J(e,r),patch:r}},_b=(e,t)=>{if(e.layers.has(t.id))throw new Error(`Layer already exists: ${t.id}`);let n={kind:"layer",id:t.id,before:null,after:t};return{scene:J(e,n),patch:n}},Cb=(e,t)=>{let n=e.layers.get(t);if(!n)throw new Error(`Layer not found: ${t}`);let o={kind:"layer",id:t,before:n,after:null};return{scene:J(e,o),patch:o}},cf=(e,t,n)=>{let o=e.layers.get(t);if(!o)throw new Error(`Layer not found: ${t}`);let a=n(o),r={kind:"layer",id:t,before:o,after:a};return{scene:J(e,r),patch:r}},Tb=(e,t)=>{if(e.annotations.has(t.id))throw new Error(`Annotation already exists: ${t.id}`);let n={kind:"annotation",id:t.id,before:null,after:t};return{scene:J(e,n),patch:n}},Ib=(e,t)=>{let n=e.annotations.get(t);if(!n)throw new Error(`Annotation not found: ${t}`);let o={kind:"annotation",id:t,before:n,after:null};return{scene:J(e,o),patch:o}},wa=(e,t,n)=>{let o=e.annotations.get(t);if(!o)throw new Error(`Annotation not found: ${t}`);let a=n(o),r={kind:"annotation",id:t,before:o,after:a};return{scene:J(e,r),patch:r}};var Tr=(e,t)=>{if(t.elementId===null)return t.position;let n=M(e,t.elementId);return n?{x:n.position.x+t.position.x,y:n.position.y+t.position.y}:t.position};var AC=new Map,Eb=(e,t)=>{AC.set(e,t)},Mb=e=>{let t=AC.get(e.type);if(t){let n=t(e).trim();if(n)return n}return vC(e.type)},vC=e=>e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).replace(/[-_]/g," ");Eb("text",e=>{let t=e.text.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,77)}\u2026`:t});Eb("template",e=>{let t=e.metadata?.label;return typeof t=="string"&&t.trim()?t.trim():vC(e.templateId)});var LC=new Map,Ob=e=>{LC.set(e.kind,e)};var Tm=e=>LC.get(e);var uf=e=>{try{let t=dt(e);return{width:t.width*Math.abs(e.scale.x),height:t.height*Math.abs(e.scale.y)}}catch{return{width:0,height:0}}},Im=(e,t)=>{if(t.shapeIds.length===0||t.cols<1)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=[];for(let d of t.shapeIds){let f=M(e,d);f&&a.push(f)}a.sort(vt);let r=a.map(uf),s=r.reduce((d,f)=>Math.max(d,f.width),0),i=r.reduce((d,f)=>Math.max(d,f.height),0),l={x:s+n,y:i+n},c=[],u=e;return a.forEach((d,f)=>{let p=f%t.cols,h=Math.floor(f/t.cols),m={x:o.x+p*l.x,y:o.y+h*l.y};if(d.position.x===m.x&&d.position.y===m.y)return;let b=le(u,d.id,y=>({...y,position:m}));u=b.scene,c.push(b.patch)}),c.length===0?null:Mo(c)},Em=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=[];for(let l of t.shapeIds){let c=M(e,l);c&&a.push(c)}a.sort(vt);let r=[],s=e,i={x:o.x,y:o.y};for(let l of a){let{width:c,height:u}=uf(l);if(l.position.x!==i.x||l.position.y!==i.y){let d=i,f=le(s,l.id,p=>({...p,position:d}));s=f.scene,r.push(f.patch)}t.direction==="horizontal"?i={x:i.x+c+n,y:i.y}:i={x:i.x,y:i.y+u+n}}return r.length===0?null:Mo(r)},SC=(e,t,n,o)=>{let a=[],r=o.x,s=o.y,i=0,l=0,c=0,u=!0;for(let d of e)l=Math.max(l,d.w),!u&&r-o.x+d.w>n+1e-6&&(c=Math.max(c,r-t-o.x),r=o.x,s+=i+t,i=0,u=!0),a.push({id:d.id,x:r,y:s}),r+=d.w+t,i=Math.max(i,d.h),u=!1;return c=Math.max(c,r-t-o.x),{placements:a,widest:l,contentWidth:Math.max(0,c),contentHeight:s+i-o.y}},kC=(e,t)=>{let n=[];for(let o of t){let a=M(e,o);a&&n.push(a)}return n.sort(vt),n.map(o=>{let a=uf(o);return{id:o.id,w:a.width,h:a.height}})},wC=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=kC(e,t.shapeIds),{placements:r}=SC(a,n,t.innerWidth,o),s=[],i=e;for(let l of r){let c=M(i,l.id);if(!c||c.position.x===l.x&&c.position.y===l.y)continue;let u=le(i,l.id,d=>({...d,position:{x:l.x,y:l.y}}));i=u.scene,s.push(u.patch)}return s.length===0?null:Mo(s)},Mm=(e,t,n)=>{let o=[];for(let l of e.elements.values())l.parentId===t&&o.push(l.id);if(o.length===0)return null;let a=kC(e,o),r=M(e,t),s=(r?An(r):null)?.gap??16,i=SC(a,s,n,{x:0,y:0});return{widest:i.widest,contentWidth:i.contentWidth,contentHeight:i.contentHeight}},An=e=>{let t=e.metadata?.autoLayout;if(!t||typeof t!="object")return null;let n=t;if(n.kind==="grid")return typeof n.cols!="number"||n.cols<1?null:{kind:"grid",cols:n.cols,...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="stack")return n.direction!=="horizontal"&&n.direction!=="vertical"?null:{kind:"stack",direction:n.direction,...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="wrap")return{kind:"wrap",...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="tree"){let o=t;return{kind:"tree",...typeof o.ranksep=="number"?{ranksep:o.ranksep}:{},...typeof o.nodesep=="number"?{nodesep:o.nodesep}:{}}}if(typeof n.kind=="string"){let o=Tm(n.kind);if(o){let a=o.parse(t);if(a!==null)return{...a,kind:n.kind}}}return null},df=(e,t)=>{let n=M(e,t);if(!n)return null;let o=An(n);if(!o)return null;let a=[];for(let c of e.elements.values())c.parentId===t&&a.push(c.id);if(a.length===0)return null;let r=Un(n),s=r?{x:r.x,y:r.y}:n.position;if(o.kind==="grid")return Im(e,{shapeIds:a,origin:s,cols:o.cols,...o.gap!==void 0?{gap:o.gap}:{}});if(o.kind==="stack")return Em(e,{shapeIds:a,origin:s,direction:o.direction,...o.gap!==void 0?{gap:o.gap}:{}});if(o.kind==="wrap"){let c=r?r.width:Number.POSITIVE_INFINITY;return wC(e,{shapeIds:a,origin:s,innerWidth:c,...o.gap!==void 0?{gap:o.gap}:{}})}if(o.kind==="tree")return _C(e,{shapeIds:a,origin:s,...o.ranksep!==void 0?{ranksep:o.ranksep}:{},...o.nodesep!==void 0?{nodesep:o.nodesep}:{}});let i=o,l=Tm(i.kind);return l?l.run(e,t,a,s,i):null},_C=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.ranksep??80,o=t.nodesep??24,a=t.origin??{x:0,y:0},r=m=>{let b=[];for(let y of e.elements.values())y.parentId===m&&b.push(y);return b.sort(vt),b},s=new Map,i=new Map,l=m=>uf(m).width,c=m=>uf(m).height,u=m=>{let b=s.get(m),y=i.get(m);if(b!==void 0&&y!==void 0)return{w:b,h:y};let g=M(e,m);if(!g)return s.set(m,0),i.set(m,0),{w:0,h:0};let x=l(g),A=c(g),C=r(m);if(C.length===0)return s.set(m,x),i.set(m,A),{w:x,h:A};let _=0,v=0;for(let T=0;T<C.length;T++){let P=u(L(C[T]).id);_+=P.w,T>0&&(_+=o),P.h>v&&(v=P.h)}let I=Math.max(x,_),k=A+n+v;return s.set(m,I),i.set(m,k),{w:I,h:k}};for(let m of t.shapeIds)u(m);let d=[],f=e,p=(m,b,y)=>{let g=M(f,m);if(!g)return;let x=u(m),A=l(g),C=c(g),_={x:b+(x.w-A)/2,y};if(g.position.x!==_.x||g.position.y!==_.y){let T=le(f,m,P=>({...P,position:_}));f=T.scene,d.push(T.patch)}let v=r(m);if(v.length===0)return;let I=b,k=y+C+n;for(let T of v)p(T.id,I,k),I+=u(T.id).w+o},h=a.x;for(let m of t.shapeIds)p(m,h,a.y),h+=u(m).w+o;return d.length===0?null:Mo(d)};var vB=20,Om=.5,LB=1e5,Db=(e,t,n,o={})=>{if(SB(e,t))return[e];let a=o.margin??vB,r=n.map(I=>kB(I,a)),s=o.startHeading,i=o.endHeading,l=new Set([e.x,t.x]),c=new Set([e.y,t.y]);for(let I of r)l.add(I.x),l.add(I.x+I.width),c.add(I.y),c.add(I.y+I.height);let u=[...l].sort((I,k)=>I-k),d=[...c].sort((I,k)=>I-k),f=(I,k)=>`${I},${k}`,p=I=>L(u[I]),h=I=>L(d[I]),m=u.indexOf(e.x),b=d.indexOf(e.y),y=u.indexOf(t.x),g=d.indexOf(t.y),x=(I,k)=>Math.abs(p(I)-p(y))+Math.abs(h(k)-h(g)),A=f(m,b),C=[{key:A,skey:`${A},0`,xi:m,yi:b,axis:0,g:0,f:x(m,b)}],_=new Map,v=new Map([[`${A},0`,0]]);for(;C.length>0;){C.sort((k,T)=>k.f-T.f||k.g-T.g||(k.skey<T.skey?-1:1));let I=L(C.shift());if(I.xi===y&&I.yi===g)return CB(_,I.skey,p,h);for(let k of wB(I.xi,I.yi,u.length,d.length)){let T={x:p(I.xi),y:h(I.yi)},P={x:p(k.xi),y:h(k.yi)};if(_B(T,P,r))continue;let N=Math.sign(P.x-T.x),U=Math.sign(P.y-T.y);if(I.axis===0&&s&&N===-Math.sign(s.x)&&U===-Math.sign(s.y)||k.xi===y&&k.yi===g&&i&&N===Math.sign(i.x)&&U===Math.sign(i.y))continue;let q=k.xi!==I.xi?1:2,te=Math.abs(T.x-P.x)+Math.abs(T.y-P.y),Z=I.axis!==0&&I.axis!==q?LB:0,ue=I.g+te+Z,$=f(k.xi,k.yi),re=`${$},${q}`,We=v.get(re);We!==void 0&&ue>=We||(v.set(re,ue),_.set(re,I.skey),C.push({key:$,skey:re,xi:k.xi,yi:k.yi,axis:q,g:ue,f:ue+x(k.xi,k.yi)}))}}return null},SB=(e,t)=>e.x===t.x&&e.y===t.y,kB=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),wB=(e,t,n,o)=>{let a=[];return e>0&&a.push({xi:e-1,yi:t}),e<n-1&&a.push({xi:e+1,yi:t}),t>0&&a.push({xi:e,yi:t-1}),t<o-1&&a.push({xi:e,yi:t+1}),a},_B=(e,t,n)=>{let o=Math.min(e.x,t.x),a=Math.max(e.x,t.x),r=Math.min(e.y,t.y),s=Math.max(e.y,t.y);for(let i of n){let l=i.x+i.width,c=i.y+i.height;if(!(a<=i.x||o>=l||s<=i.y||r>=c)&&!(a-i.x<=Om||l-o<=Om||s-i.y<=Om||c-r<=Om))return!0}return!1},CB=(e,t,n,o)=>{let a=[],r=new Set,s=t;for(;s&&!r.has(s);){r.add(s);let i=s.split(",").map(Number);a.unshift({x:n(L(i[0])),y:o(L(i[1]))}),s=e.get(s)}return TB(a)},TB=e=>{if(e.length<=2)return e;let t=[L(e[0])];for(let n=1;n<e.length-1;n++){let o=L(e[n-1]),a=L(e[n]),r=L(e[n+1]),s=o.y===a.y&&a.y===r.y,i=o.x===a.x&&a.x===r.x;s||i||t.push(a)}return t.push(L(e[e.length-1])),t};var pf=(e,t)=>{let n=Gn(e,t.from),o=Gn(e,t.to);if(!n||!o)return[];let a=t.from.kind==="floating"?Gn(e,t.from,o)??n:n,r=t.to.kind==="floating"?Gn(e,t.to,n)??o:o;if(a.x===r.x&&a.y===r.y)return[];let s=MC(e,t.from,a,r),i=MC(e,t.to,r,a),l=t.avoidObstacles===!0?IB(e,t):void 0,c=l&&l.length<=150?l:void 0,u=RC(a,r,s,i,t.routedPoints,c);return u=OB(u,t.fixedSegments),u},IB=(e,t)=>{let n=new Set;for(let a of[t.from,t.to])a.kind!=="point"&&n.add(a.elementId);let o=[];for(let a of e.elements.values())n.has(a.id)||o.push(z(a));return o},Pb=(e,t,n,o,a)=>{if(n.x===a.x&&n.y===a.y)return[n,a];let r=EC(e,t,n,a),s=EC(e,o,a,n);return[n,...RC(n,a,r,s),a]},RC=(e,t,n,o,a,r)=>{let s=30,i={x:e.x+n.heading.x*s,y:e.y+n.heading.y*s},l={x:t.x+o.heading.x*s,y:t.y+o.heading.y*s},c=[];if(n.obstacle&&c.push(n.obstacle),o.obstacle&&c.push(o.obstacle),r){let h=[...c,...r],m=Db(i,l,h,{startHeading:n.heading,endHeading:o.heading}),b=m&&m.length>=2?m:[i,OC(i,l,n.heading),l];return ff(b)}let u=EB(e,t,n,o,i,l);if(u&&!IC(u,c))return ff(u);let d=MB(e,t,n,o,i,l,c,a);if(d&&!IC(d,c))return ff(d);let f=Db(i,l,c,{startHeading:n.heading,endHeading:o.heading}),p=f&&f.length>=2?f:[i,OC(i,l,n.heading),l];return ff(p)},EB=(e,t,n,o,a,r)=>{if(n.heading.y!==0&&o.heading.y===-n.heading.y){if(Math.sign(a.y-r.y)===Math.sign(n.heading.y)){let l=(e.x+t.x)/2;return[a,{x:l,y:a.y},{x:l,y:r.y},r]}let i=(a.y+r.y)/2;return[a,{x:a.x,y:i},{x:r.x,y:i},r]}if(n.heading.x!==0&&o.heading.x===-n.heading.x){if(Math.sign(a.x-r.x)===Math.sign(n.heading.x)){let l=(e.y+t.y)/2;return[a,{x:a.x,y:l},{x:r.x,y:l},r]}let i=(a.x+r.x)/2;return[a,{x:i,y:a.y},{x:i,y:r.y},r]}return null},CC=(e,t,n,o,a)=>{let r=e<=t;return a!==null&&Math.abs(e-t)<24?a?n:o:r?n:o},MB=(e,t,n,o,a,r,s,i)=>{if(s.length===0)return null;let l=1/0,c=1/0,u=-1/0,d=-1/0;for(let p of s)l=Math.min(l,p.x),c=Math.min(c,p.y),u=Math.max(u,p.x+p.width),d=Math.max(d,p.y+p.height);let f=20;if(l-=f,c-=f,u+=f,d+=f,n.heading.y===0&&o.heading.y===0&&n.heading.x!==0&&o.heading.x===-n.heading.x){let p=(e.y+t.y)/2,h=CC(p,(c+d)/2,c,d,TC(i,"y"));return[a,{x:a.x,y:h},{x:r.x,y:h},r]}if(n.heading.x===0&&o.heading.x===0&&n.heading.y!==0&&o.heading.y===-n.heading.y){let p=(e.x+t.x)/2,h=CC(p,(l+u)/2,l,u,TC(i,"x"));return[a,{x:h,y:a.y},{x:h,y:r.y},r]}return null},TC=(e,t)=>{if(!e||e.length<3)return null;let n=d=>t==="y"?d.y:d.x,o=n(L(e[0])),a=n(L(e[e.length-1])),r=Math.min(o,a),s=Math.max(o,a),i=1/0,l=-1/0;for(let d of e){let f=n(d);f<i&&(i=f),f>l&&(l=f)}let c=r-i,u=l-s;return c<=0&&u<=0?null:c>=u},IC=(e,t)=>{let n=1;for(let o=1;o<e.length;o++){let a=L(e[o-1]),r=L(e[o]);for(let s=0;s<=1;s+=.1){let i=a.x+(r.x-a.x)*s,l=a.y+(r.y-a.y)*s;for(let c of t)if(i>c.x+n&&i<c.x+c.width-n&&l>c.y+n&&l<c.y+c.height-n)return!0}}return!1},EC=(e,t,n,o)=>{if(!t)return{heading:tf(o,n),obstacle:null};let a=M(e,t);return a?{heading:aC(a,n),obstacle:z(a)}:{heading:tf(o,n),obstacle:null}},OB=(e,t)=>{if(!t||t.length===0)return e;let n=e.map(o=>({...o}));for(let o of t){let a=n.length-2,r=-1,s=1/0;for(let c=1;c<a;c++){let u=L(n[c]),d=L(n[c+1]),f=Math.abs(u.y-d.y)<1e-6,p=Math.abs(u.x-d.x)<1e-6;if(o.axis==="h"!==f||o.axis==="v"!==p)continue;let h=o.axis==="h"?(u.x+d.x)/2:(u.y+d.y)/2,m=Math.abs(h-o.at);m<s&&(s=m,r=c)}if(r>=0){let c=L(n[r]),u=L(n[r+1]);o.axis==="h"?(c.y=o.pos,u.y=o.pos):(c.x=o.pos,u.x=o.pos);continue}let i=L(n[0]),l=L(n[n.length-1]);n=o.axis==="h"?[i,{x:i.x,y:o.pos},{x:l.x,y:o.pos},l]:[i,{x:o.pos,y:i.y},{x:o.pos,y:l.y},l]}return ff(n)},RB=e=>{switch(e){case"top":return ef;case"bottom":return Qd;case"left":return Jd;case"right":return Rl;default:return null}},MC=(e,t,n,o)=>{if(t.kind==="point")return{heading:tf(o,n),obstacle:null};let a=M(e,t.elementId);if(!a)return{heading:tf(o,n),obstacle:null};let r=z(a);if(t.kind==="anchor"&&t.anchor.kind==="named"){let s=RB(t.anchor.name);if(s)return{heading:s,obstacle:r}}return{heading:vm(a,n),obstacle:r}},OC=(e,t,n)=>oC(n)?{x:t.x,y:e.y}:{x:e.x,y:t.y},ff=e=>{if(e.length<=2)return[...e];let t=[L(e[0])];for(let n=1;n<e.length-1;n++){let o=L(t[t.length-1]),a=L(e[n]),r=L(e[n+1]),s=1e-6,i=Math.abs(o.y-a.y)<s&&Math.abs(a.y-r.y)<s,l=Math.abs(o.x-a.x)<s&&Math.abs(a.x-r.x)<s,c=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;i||l||c||t.push(a)}return t.push(L(e[e.length-1])),t};var Rm="orthogonal",DC="triangle";var Bb=Math.PI/12,Oo=11,PC=6,BC=4,zC=12,Dm=9,zb=4,NC="#1a73e8",FC="#fff",hf=3.5,Ro=5,HC=8,UC=1.5,GC=NC,Nb=FC,qC=FC,Fb=NC,fo=20,WC=0,jC="#ffffff",Pm=6,Bm=7,VC=18,Hb=40,Nl=.16,mf=.7,Ub="#e8118c",ZC="#f59e0b",yf="#2563eb",Gb="#16a34a",XC="#06b6d4",YC="#a855f7",KC="#eab308",$C="#dc2626",QC="#14b8a6",JC="#f43f5e",eT=16,qb=14,Wb=6,jb=3,Vb=11,tT=1.5,nT=[4,3],oT=3;var Zb=1,Xb=1.6,Yb=10,aT=1,rT=.05,sT=32,iT=.5,lT=500,Fl=8,Kb=300,$b=8,cT=.6,uT=.85,zm=.4,dT=22,fT=22,pT=18,hT=16,mT=16,yT=9,Nm=12,gT="#f9a825",xT="#fff",bT="#888",AT=10,Fm=2e3,Qb=.5,vT=.5,Jb=12,LT=6,ST=2,e2=480,kT=1e3/60,wT=1e3/12,_T=2,CT=2*1024*1024,TT=3e4,IT=24,ET="system-ui, sans-serif",MT="#1a1a1a",OT=1e3,RT=1,DT=10,PT=530,BT="#1a73e8",zT=.25,NT=1.5,Hm=4,t2=1.1,FT=256,HT=30,UT=16,n2=4,GT=4,qT="rgba(0,0,0,0.65)",WT=16,jT="#1a73e8",VT="#fff";var Hs=["nw","n","ne","e","se","s","sw","w"],Us=["nw","ne","se","sw"],ZT=e=>{switch(e){case"nw":case"se":return"nwse-resize";case"ne":case"sw":return"nesw-resize";case"n":case"s":return"ns-resize";case"e":case"w":return"ew-resize"}};var Gs=(e,t,n=1)=>{let o=t.x+t.width/2,a=t.y+t.height/2,r=t.x+t.width,s=t.y+t.height,i=3/n;switch(e){case"nw":return{x:t.x-i,y:t.y-i};case"n":return{x:o,y:t.y-i};case"ne":return{x:r+i,y:t.y-i};case"e":return{x:r+i,y:a};case"se":return{x:r+i,y:s+i};case"s":return{x:o,y:s+i};case"sw":return{x:t.x-i,y:s+i};case"w":return{x:t.x-i,y:a}}},o2=(e,t,n,o=11,a=Hs)=>{let r=o/n;for(let f of a){if(f.length!==2)continue;let p=Gs(f,t,n);if(Math.abs(e.x-p.x)<=r&&Math.abs(e.y-p.y)<=r)return f}let s=t.x,i=t.x+t.width,l=t.y,c=t.y+t.height,u=e.x>=s-r&&e.x<=i+r,d=e.y>=l-r&&e.y<=c+r;for(let f of a)switch(f){case"n":if(u&&Math.abs(e.y-l)<=r)return"n";break;case"s":if(u&&Math.abs(e.y-c)<=r)return"s";break;case"w":if(d&&Math.abs(e.x-s)<=r)return"w";break;case"e":if(d&&Math.abs(e.x-i)<=r)return"e";break}return null},Hl=(e,t)=>e.rotation===0?t:Ae.rotateAround(t,e.pivot,e.rotation),PB=(e,t)=>e.rotation===0?t:Ae.rotateAround(t,e.pivot,-e.rotation),qs=e=>{let t=dt(e),n=t.x*e.scale.x,o=(t.x+t.width)*e.scale.x,a=t.y*e.scale.y,r=(t.y+t.height)*e.scale.y;return{bounds:{x:e.position.x+Math.min(n,o),y:e.position.y+Math.min(a,r),width:Math.abs(o-n),height:Math.abs(r-a)},rotation:e.rotation,pivot:e.position}};var xf=e=>{let t=e.bounds;return[Hl(e,{x:t.x,y:t.y}),Hl(e,{x:t.x+t.width,y:t.y}),Hl(e,{x:t.x+t.width,y:t.y+t.height}),Hl(e,{x:t.x,y:t.y+t.height})]},XT=e=>Hl(e,{x:e.bounds.x+e.bounds.width/2,y:e.bounds.y+e.bounds.height/2}),YT=(e,t,n=1)=>Hl(t,Gs(e,t.bounds,n)),KT=(e,t,n,o=11,a=Hs)=>o2(PB(t,e),t.bounds,n,o,a),BB={kind:"ratio",position:{x:0,y:1}},zB=new Map;var NB=e=>zB.get(e)??BB,Um=(e,t=1)=>{let n=NB(e.type),o=Gt(e,n),a=Eo(e,n),r=26/t;return{x:o.x+a.x*r,y:o.y+a.y*r}},Gm=(e,t=1)=>{let n=26/t*Math.SQRT1_2;return{x:e.x-n,y:e.y+e.height+n}},a2=(e,t,n,o=11)=>{let a=o/n;return Math.abs(e.x-t.x)<=a&&Math.abs(e.y-t.y)<=a};function FB(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function HB(){let e=FB();if(e.__xstate__)return e.__xstate__}var $T=e=>{if(typeof window>"u")return;let t=HB();t&&t.register(e)};var qm=class{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){let n={value:t,next:null};if(this._current){this._last.next=n,this._last=n;return}this._current=n,this._last=n,this._active&&this.flush()}flush(){for(;this._current;){let t=this._current;this._process(t.value),this._current=t.next}this._last=null}},f2=".",UB="",p2="",GB="#",qB="*",oI="xstate.init",aI="xstate.error",i2="xstate.stop";function WB(e,t){return{type:`xstate.after.${e}.${t}`}}function l2(e,t){return{type:`xstate.done.state.${e}`,output:t}}function jB(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function h2(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function jm(e){return{type:oI,input:e}}function Do(e){setTimeout(()=>{throw e})}var VB=typeof Symbol=="function"&&Symbol.observable||"@@observable";function m2(e,t){let n=QT(e),o=QT(t);return typeof o=="string"?typeof n=="string"?o===n:!1:typeof n=="string"?n in o:Object.keys(n).every(a=>a in o?m2(n[a],o[a]):!1)}function Vm(e){if(iI(e))return e;let t=[],n="";for(let o=0;o<e.length;o++){switch(e.charCodeAt(o)){case 92:n+=e[o+1],o++;continue;case 46:t.push(n),n="";continue}n+=e[o]}return t.push(n),t}function QT(e){if(CI(e))return e.value;if(typeof e!="string")return e;let t=Vm(e);return rI(t)}function rI(e){if(e.length===1)return e[0];let t={},n=t;for(let o=0;o<e.length-1;o++)if(o===e.length-2)n[e[o]]=e[o+1];else{let a=n;n={},a[e[o]]=n}return t}function y2(e,t){let n={},o=Object.keys(e);for(let a=0;a<o.length;a++){let r=o[a];n[r]=t(e[r],r,e,a)}return n}function sI(e){return iI(e)?e:[e]}function Po(e){return e===void 0?[]:sI(e)}function c2(e,t,n,o){return typeof e=="function"?e({context:t,event:n,self:o}):e}function iI(e){return Array.isArray(e)}function ZB(e){return e.type.startsWith("xstate.error.actor")}function Ws(e){return sI(e).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function lI(e){if(!(e===void 0||e===UB))return Po(e)}function bf(e,t,n){let o=typeof e=="object",a=o?e:void 0;return{next:(o?e.next:e)?.bind(a),error:(o?e.error:t)?.bind(a),complete:(o?e.complete:n)?.bind(a)}}function g2(e,t){return`${t}.${e}`}function vf(e,t){let n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];let[,o,a]=n,s=e.getStateNodeById(a).config.invoke;return(Array.isArray(s)?s[o]:s).src}function cI(e,t){if(t===e||t===qB)return!0;if(!t.endsWith(".*"))return!1;let n=t.split("."),o=e.split(".");for(let a=0;a<n.length;a++){let r=n[a],s=o[a];if(r==="*")return a===n.length-1;if(r!==s)return!1}return!0}function JT(e,t){return`${e.sessionId}.${t}`}var XB=0;function YB(e,t){let n=new Map,o=new Map,a=new WeakMap,r=new Set,s={},{clock:i,logger:l}=t,c={schedule:(f,p,h,m,b=Math.random().toString(36).slice(2))=>{let y={source:f,target:p,event:h,delay:m,id:b,startedAt:Date.now()},g=JT(f,b);d._snapshot._scheduledEvents[g]=y;let x=i.setTimeout(()=>{delete s[g],delete d._snapshot._scheduledEvents[g],d._relay(f,p,h)},m);s[g]=x},cancel:(f,p)=>{let h=JT(f,p),m=s[h];delete s[h],delete d._snapshot._scheduledEvents[h],m!==void 0&&i.clearTimeout(m)},cancelAll:f=>{for(let p in d._snapshot._scheduledEvents){let h=d._snapshot._scheduledEvents[p];h.source===f&&c.cancel(f,h.id)}}},u=f=>{if(!r.size)return;let p={...f,rootId:e.sessionId};r.forEach(h=>h.next?.(p))},d={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${XB++}`,_register:(f,p)=>(n.set(f,p),f),_unregister:f=>{n.delete(f.sessionId);let p=a.get(f);p!==void 0&&(o.delete(p),a.delete(f))},get:f=>o.get(f),getAll:()=>Object.fromEntries(o.entries()),_set:(f,p)=>{let h=o.get(f);if(h&&h!==p)throw new Error(`Actor with system ID '${f}' already exists.`);o.set(f,p),a.set(p,f)},inspect:f=>{let p=bf(f);return r.add(p),{unsubscribe(){r.delete(p)}}},_sendInspectionEvent:u,_relay:(f,p,h)=>{d._sendInspectionEvent({type:"@xstate.event",sourceRef:f,actorRef:p,event:h}),p._send(h)},scheduler:c,getSnapshot:()=>({_scheduledEvents:{...d._snapshot._scheduledEvents}}),start:()=>{let f=d._snapshot._scheduledEvents;d._snapshot._scheduledEvents={};for(let p in f){let{source:h,target:m,event:b,delay:y,id:g}=f[p];c.schedule(h,m,b,y,g)}},_clock:i,_logger:l};return d}var r2=!1,Zm=1,qt=(function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e})({}),KB={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},Wm=class{constructor(t,n){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new qm(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=qt.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];let o={...KB,...n},{clock:a,logger:r,parent:s,syncSnapshot:i,id:l,systemId:c,inspect:u}=o;this.system=s?s.system:YB(this,{clock:a,logger:r}),u&&!s&&this.system.inspect(bf(u)),this.sessionId=this.system._bookId(),this.id=l??this.sessionId,this.logger=n?.logger??this.system._logger,this.clock=n?.clock??this.system._clock,this._parent=s,this._syncSnapshot=i,this.options=o,this.src=o.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:d=>{this._deferred.push(d)},system:this.system,stopChild:d=>{if(d._parent!==this)throw new Error(`Cannot stop child actor ${d.id} of ${this.id} because it is not a child`);d._stop()},emit:d=>{let f=this.eventListeners.get(d.type),p=this.eventListeners.get("*");if(!f&&!p)return;let h=[...f?f.values():[],...p?p.values():[]];for(let m of h)try{m(d)}catch(b){Do(b)}},actionExecutor:d=>{let f=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:d.type,params:d.params}}),!d.exec)return;let p=r2;try{r2=!0,d.exec(d.info,d.params)}finally{r2=p}};this._processingStatus===qt.Running?f():this._deferred.push(f)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),c&&(this.systemId=c,this.system._set(c,this)),this._initState(n?.snapshot??n?.state),c&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(t){try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(n){this._snapshot={status:"error",output:void 0,error:n}}}update(t,n){this._snapshot=t;let o;for(;o=this._deferred.shift();)try{o()}catch(a){this._deferred.length=0,this._snapshot={...t,status:"error",error:a}}switch(this._snapshot.status){case"active":for(let a of this.observers)try{a.next?.(t)}catch(r){Do(r)}break;case"done":for(let a of this.observers)try{a.next?.(t)}catch(r){Do(r)}this._stopProcedure(),this._complete(),this._doneEvent=jB(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:n,snapshot:t})}subscribe(t,n,o){let a=bf(t,n,o);if(this._processingStatus!==qt.Stopped)this.observers.add(a);else switch(this._snapshot.status){case"done":try{a.complete?.()}catch(r){Do(r)}break;case"error":{let r=this._snapshot.error;if(!a.error)Do(r);else try{a.error(r)}catch(s){Do(s)}break}}return{unsubscribe:()=>{this.observers.delete(a)}}}on(t,n){let o=this.eventListeners.get(t);o||(o=new Set,this.eventListeners.set(t,o));let a=n.bind(void 0);return o.add(a),{unsubscribe:()=>{o.delete(a)}}}select(t,n=Object.is){return{subscribe:o=>{let a=bf(o),r=this.getSnapshot(),s=t(r);return this.subscribe(i=>{let l=t(i);n(s,l)||(s=l,a.next?.(l))})},get:()=>t(this.getSnapshot())}}start(){if(this._processingStatus===qt.Running)return this;this._syncSnapshot&&this.subscribe({next:o=>{o.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:o})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=qt.Running;let t=jm(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(o){return this._snapshot={...this._snapshot,status:"error",error:o},this._error(o),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let n,o;try{n=this.logic.transition(this._snapshot,t,this._actorScope)}catch(a){o={err:a}}if(o){let{err:a}=o;this._snapshot={...this._snapshot,status:"error",error:a},this._error(a);return}this.update(n,t),t.type===i2&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===qt.Stopped?this:(this.mailbox.clear(),this._processingStatus===qt.NotStarted?(this._processingStatus=qt.Stopped,this):(this.mailbox.enqueue({type:i2}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(let t of this.observers)try{t.complete?.()}catch(n){Do(n)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||Do(t),this.eventListeners.clear();return}let n=!1;for(let o of this.observers){let a=o.error;n||=!a;try{a?.(t)}catch(r){Do(r)}}this.observers.clear(),this.eventListeners.clear(),n&&Do(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,h2(this.id,t))}_stopProcedure(){return this._processingStatus!==qt.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new qm(this._process.bind(this)),this._processingStatus=qt.Stopped,this.system._unregister(this),this)}_send(t){this._processingStatus!==qt.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){let{devTools:t}=this.options;t&&(typeof t=="function"?t:$T)(this)}toJSON(){return{xstate$$type:Zm,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[VB](){return this}getSnapshot(){return this._snapshot}};function Bo(e,...[t]){return new Wm(e,t)}function $B(e,t,n,o,{sendId:a}){let r=typeof a=="function"?a(n,o):a;return[t,{sendId:r},void 0]}function QB(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function Wl(e){function t(n,o){}return t.type="xstate.cancel",t.sendId=e,t.resolve=$B,t.execute=QB,t}function JB(e,t,n,o,{id:a,systemId:r,src:s,input:i,syncSnapshot:l}){let c=typeof s=="string"?vf(t.machine,s):s,u=typeof a=="function"?a(n):a,d,f;return c&&(f=typeof i=="function"?i({context:t.context,event:n.event,self:e.self}):i,d=Bo(c,{id:u,src:s,parent:e.self,syncSnapshot:l,systemId:r,input:f})),[Er(t,{children:{...t.children,[u]:d}}),{id:a,systemId:r,actorRef:d,src:s,input:f},void 0]}function ez(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==qt.Stopped&&t.start()})}function jl(...[e,{id:t,systemId:n,input:o,syncSnapshot:a=!1}={}]){function r(s,i){}return r.type="xstate.spawnChild",r.id=t,r.systemId=n,r.src=e,r.input=o,r.syncSnapshot=a,r.resolve=JB,r.execute=ez,r}function tz(e,t,n,o,{actorRef:a}){let r=typeof a=="function"?a(n,o):a,s=typeof r=="string"?t.children[r]:r,i=t.children;return s&&(i={...i},delete i[s.id]),[Er(t,{children:i}),s,void 0]}function uI(e,t){let n=t.getSnapshot();if(n&&"children"in n)for(let o of Object.values(n.children))uI(e,o);e.system._unregister(t)}function nz(e,t){if(t){if(uI(e,t),t._processingStatus!==qt.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Zs(e){function t(n,o){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=tz,t.execute=nz,t}function oz(e,{context:t,event:n},{guards:o}){return o.every(a=>Xs(a,t,n,e))}function dI(e){function t(n,o){return!1}return t.check=oz,t.guards=e,t}function Xs(e,t,n,o){let{machine:a}=o,r=typeof e=="function",s=r?e:a.implementations.guards[typeof e=="string"?e:e.type];if(!r&&!s)throw new Error(`Guard '${typeof e=="string"?e:e.type}' is not implemented.'.`);if(typeof s!="function")return Xs(s,t,n,o);let i={context:t,event:n},l=r||typeof e=="string"?void 0:"params"in e?typeof e.params=="function"?e.params({context:t,event:n}):e.params:void 0;return"check"in s?s.check(o,i,s):s(i,l)}function Xm(e){return e.type==="atomic"||e.type==="final"}function Gl(e){return Object.values(e.states).filter(t=>t.type!=="history")}function Vl(e,t){let n=[];if(t===e)return n;let o=e.parent;for(;o&&o!==t;)n.push(o),o=o.parent;return n}function Lf(e){let t=new Set(e),n=pI(t);for(let o of t)if(o.type==="compound"&&(!n.get(o)||!n.get(o).length))eI(o).forEach(a=>t.add(a));else if(o.type==="parallel"){for(let a of Gl(o))if(a.type!=="history"&&!t.has(a)){let r=eI(a);for(let s of r)t.add(s)}}for(let o of t){let a=o.parent;for(;a;)t.add(a),a=a.parent}return t}function fI(e,t){let n=t.get(e);if(!n)return{};if(e.type==="compound"){let a=n[0];if(a){if(Xm(a))return a.key}else return{}}let o={};for(let a of n)o[a.key]=fI(a,t);return o}function pI(e){let t=new Map;for(let n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function hI(e,t){let n=Lf(t);return fI(e,pI(n))}function Ym(e,t){return t.type==="compound"?Gl(t).some(n=>n.type==="final"&&e.has(n)):t.type==="parallel"?Gl(t).every(n=>Ym(e,n)):t.type==="final"}var Sf=e=>e[0]===GB;function mI(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(o=>cI(t,o)).sort((o,a)=>a.length-o.length).flatMap(o=>e.transitions.get(o))}function yI(e){let t=e.config.after;if(!t)return[];let n=a=>{let r=WB(a,e.id),s=r.type;return e.entry.push(Xl(r,{id:s,delay:a})),e.exit.push(Wl(s)),s};return Object.keys(t).flatMap(a=>{let r=t[a],s=typeof r=="string"?{target:r}:r,i=Number.isNaN(+a)?a:+a,l=n(i);return Po(s).map(c=>({...c,event:l,delay:i}))}).map(a=>{let{delay:r}=a;return{..._a(e,a.event,a),delay:r}})}function _a(e,t,n){let o=lI(n.target),a=n.reenter??!1,r=az(e,o),s={...n,actions:Po(n.actions),guard:n.guard,target:r,source:e,reenter:a,eventType:t,toJSON:()=>({...s,source:`#${e.id}`,target:r?r.map(i=>`#${i.id}`):void 0})};return s}function gI(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===p2)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let o=e.config.on[n];t.set(n,Ws(o).map(a=>_a(e,n,a)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,Ws(e.config.onDone).map(o=>_a(e,n,o)))}for(let n of e.invoke){if(n.onDone){let o=`xstate.done.actor.${n.id}`;t.set(o,Ws(n.onDone).map(a=>_a(e,o,a)))}if(n.onError){let o=`xstate.error.actor.${n.id}`;t.set(o,Ws(n.onError).map(a=>_a(e,o,a)))}if(n.onSnapshot){let o=`xstate.snapshot.${n.id}`;t.set(o,Ws(n.onSnapshot).map(a=>_a(e,o,a)))}}for(let n of e.after){let o=t.get(n.eventType);o||(o=[],t.set(n.eventType,o)),o.push(n)}return t}function xI(e){let t=[],n=o=>{Object.values(o).forEach(a=>{if(a.config.route&&a.config.id){let r=a.config.id,s=a.config.route.guard,i=({event:c})=>c.to===`#${r}`,l={...a.config.route,guard:s?dI([i,s]):i,target:`#${r}`};t.push(_a(e,"xstate.route",l))}a.states&&n(a.states)})};n(e.states),t.length>0&&e.transitions.set("xstate.route",t)}function bI(e,t){let n=typeof t=="string"?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let o={source:e,actions:!t||typeof t=="string"?[]:Po(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...o,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return o}function az(e,t){if(t!==void 0)return t.map(n=>{if(typeof n!="string")return n;if(Sf(n))return e.machine.getStateNodeById(n);let o=n[0]===f2;if(o&&!e.parent)return Af(e,n.slice(1));let a=o?e.key+n:n;if(e.parent)try{return Af(e.parent,a)}catch(r){throw new Error(`Invalid transition definition for state node '${e.id}':
|
|
11
|
-
${r.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function AI(e){let t=lI(e.config.target);return t?{target:t.map(n=>typeof n=="string"?Af(e.parent,n):n)}:e.parent.initial}function js(e){return e.type==="history"}function eI(e){let t=vI(e);for(let n of t)for(let o of Vl(n,e))t.add(o);return t}function vI(e){let t=new Set;function n(o){if(!t.has(o)){if(t.add(o),o.type==="compound")n(o.initial.target[0]);else if(o.type==="parallel")for(let a of Gl(o))n(a)}}return n(e),t}function ql(e,t){if(Sf(t))return e.machine.getStateNodeById(t);if(!e.states)throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let n=e.states[t];if(!n)throw new Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function Af(e,t){if(typeof t=="string"&&Sf(t))try{return e.machine.getStateNodeById(t)}catch{}let n=Vm(t).slice(),o=e;for(;n.length;){let a=n.shift();if(!a.length)break;o=ql(o,a)}return o}function Zl(e,t){if(typeof t=="string"){let a=e.states[t];if(!a)throw new Error(`State '${t}' does not exist on '${e.id}'`);return[e,a]}let n=Object.keys(t),o=n.map(a=>ql(e,a)).filter(Boolean);return[e.machine.root,e].concat(o,n.reduce((a,r)=>{let s=ql(e,r);if(!s)return a;let i=Zl(s,t[r]);return a.concat(i)},[]))}function rz(e,t,n,o){let r=ql(e,t).next(n,o);return!r||!r.length?e.next(n,o):r}function sz(e,t,n,o){let a=Object.keys(t),r=ql(e,a[0]),s=Km(r,t[a[0]],n,o);return!s||!s.length?e.next(n,o):s}function iz(e,t,n,o){let a=[];for(let r of Object.keys(t)){let s=t[r];if(!s)continue;let i=ql(e,r),l=Km(i,s,n,o);l&&a.push(...l)}return a.length?a:e.next(n,o)}function Km(e,t,n,o){return typeof t=="string"?rz(e,t,n,o):Object.keys(t).length===1?sz(e,t,n,o):iz(e,t,n,o)}function lz(e){return Object.keys(e.states).map(t=>e.states[t]).filter(t=>t.type==="history")}function Ir(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function cz(e,t){let n=new Set(e),o=new Set(t);for(let a of n)if(o.has(a))return!0;for(let a of o)if(n.has(a))return!0;return!1}function LI(e,t,n){let o=new Set;for(let a of e){let r=!1,s=new Set;for(let i of o)if(cz(u2([a],t,n),u2([i],t,n)))if(Ir(a.source,i.source))s.add(i);else{r=!0;break}if(!r){for(let i of s)o.delete(i);o.add(a)}}return Array.from(o)}function uz(e){let[t,...n]=e;for(let o of Vl(t,void 0))if(n.every(a=>Ir(a,o)))return o}function x2(e,t){if(!e.target)return[];let n=new Set;for(let o of e.target)if(js(o))if(t[o.id])for(let a of t[o.id])n.add(a);else for(let a of x2(AI(o),t))n.add(a);else n.add(o);return[...n]}function SI(e,t){let n=x2(e,t);if(!n)return;if(!e.reenter&&n.every(a=>a===e.source||Ir(a,e.source)))return e.source;let o=uz(n.concat(e.source));if(o)return o;if(!e.reenter)return e.source.machine.root}function u2(e,t,n){let o=new Set;for(let a of e)if(a.target?.length){let r=SI(a,n);a.reenter&&a.source===r&&o.add(r);for(let s of t)Ir(s,r)&&o.add(s)}return[...o]}function dz(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function b2(e,t,n,o,a){return d2([{target:[...vI(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,o,!0,a)}function d2(e,t,n,o,a,r){let s=[];if(!e.length)return[t,s];let i=n.actionExecutor;n.actionExecutor=l=>{s.push(l),i(l)};try{let l=new Set(t._nodes),c=t.historyValue,u=LI(e,l,c),d=t;a||([d,c]=mz(d,o,n,u,l,c,r,n.actionExecutor)),d=Vs(d,o,n,u.flatMap(p=>p.actions),r,void 0),d=pz(d,o,n,u,l,r,c,a);let f=[...l];d.status==="done"&&(d=Vs(d,o,n,f.sort((p,h)=>h.order-p.order).flatMap(p=>p.exit),r,void 0));try{return c===t.historyValue&&dz(t._nodes,l)?[d,s]:[Er(d,{_nodes:f,historyValue:c}),s]}catch(p){throw p}}finally{n.actionExecutor=i}}function fz(e,t,n,o,a){if(o.output===void 0)return;let r=l2(a.id,a.output!==void 0&&a.parent?c2(a.output,e.context,t,n.self):void 0);return c2(o.output,e.context,r,n.self)}function pz(e,t,n,o,a,r,s,i){let l=e,c=new Set,u=new Set;hz(o,s,u,c),i&&u.add(e.machine.root);let d=new Set;for(let f of[...c].sort((p,h)=>p.order-h.order)){a.add(f);let p=[];p.push(...f.entry);for(let h of f.invoke)p.push(jl(h.src,{...h,syncSnapshot:!!h.onSnapshot}));if(u.has(f)){let h=f.initial.actions;p.push(...h)}if(l=Vs(l,t,n,p,r,f.invoke.map(h=>h.id)),f.type==="final"){let h=f.parent,m=h?.type==="parallel"?h:h?.parent,b=m||f;for(h?.type==="compound"&&r.push(l2(h.id,f.output!==void 0?c2(f.output,l.context,t,n.self):void 0));m?.type==="parallel"&&!d.has(m)&&Ym(a,m);)d.add(m),r.push(l2(m.id)),b=m,m=m.parent;if(m)continue;l=Er(l,{status:"done",output:fz(l,t,n,l.machine.root,b)})}}return l}function hz(e,t,n,o){for(let a of e){let r=SI(a,t);for(let i of a.target||[])!js(i)&&(a.source!==i||a.source!==r||a.reenter)&&(o.add(i),n.add(i)),Ul(i,t,n,o);let s=x2(a,t);for(let i of s){let l=Vl(i,r);r?.type==="parallel"&&l.push(r),kI(o,t,n,l,!a.source.parent&&a.reenter?void 0:r)}}}function Ul(e,t,n,o){if(js(e))if(t[e.id]){let a=t[e.id];for(let r of a)o.add(r),Ul(r,t,n,o);for(let r of a)s2(r,e.parent,o,t,n)}else{let a=AI(e);for(let r of a.target)o.add(r),a===e.parent?.initial&&n.add(e.parent),Ul(r,t,n,o);for(let r of a.target)s2(r,e.parent,o,t,n)}else if(e.type==="compound"){let[a]=e.initial.target;js(a)||(o.add(a),n.add(a)),Ul(a,t,n,o),s2(a,e,o,t,n)}else if(e.type==="parallel")for(let a of Gl(e).filter(r=>!js(r)))[...o].some(r=>Ir(r,a))||(js(a)||(o.add(a),n.add(a)),Ul(a,t,n,o))}function kI(e,t,n,o,a){for(let r of o)if((!a||Ir(r,a))&&e.add(r),r.type==="parallel")for(let s of Gl(r).filter(i=>!js(i)))[...e].some(i=>Ir(i,s))||(e.add(s),Ul(s,t,n,e))}function s2(e,t,n,o,a){kI(n,o,a,Vl(e,t))}function mz(e,t,n,o,a,r,s,i){let l=e,c=u2(o,a,r);c.sort((d,f)=>f.order-d.order);let u;for(let d of c)for(let f of lz(d)){let p;f.history==="deep"?p=h=>Xm(h)&&Ir(h,d):p=h=>h.parent===d,u??={...r},u[f.id]=Array.from(a).filter(p)}for(let d of c)l=Vs(l,t,n,[...d.exit,...d.invoke.map(f=>Zs(f.id))],s,void 0),a.delete(d);return[l,u||r]}function yz(e,t){return e.implementations.actions[t]}function wI(e,t,n,o,a,r){let{machine:s}=e,i=e;for(let l of o){let c=typeof l=="function",u=c?l:yz(s,typeof l=="string"?l:l.type),d={context:i.context,event:t,self:n.self,system:n.system},f=c||typeof l=="string"?void 0:"params"in l?typeof l.params=="function"?l.params({context:i.context,event:t}):l.params:void 0;if(!u||!("resolve"in u)){n.actionExecutor({type:typeof l=="string"?l:typeof l=="object"?l.type:l.name||"(anonymous)",info:d,params:f,exec:u});continue}let p=u,[h,m,b]=p.resolve(n,i,d,f,u,a);i=h,"retryResolve"in p&&r?.push([p,m]),"execute"in p&&n.actionExecutor({type:p.type,info:d,params:m,exec:p.execute.bind(null,n,m)}),b&&(i=wI(i,t,n,b,a,r))}return i}function Vs(e,t,n,o,a,r){let s=r?[]:void 0,i=wI(e,t,n,o,{internalQueue:a,deferredActorIds:r},s);return s?.forEach(([l,c])=>{l.retryResolve(n,i,c)}),i}function kf(e,t,n,o){let a=e,r=[];function s(d,f,p){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:f,snapshot:d[0],_transitions:p}),r.push(d)}if(t.type===i2)return a=Er(tI(a,t,n),{status:"stopped"}),s([a,[]],t,[]),{snapshot:a,microsteps:r};let i=t;if(i.type!==oI){let d=i,f=ZB(d),p=nI(d,a);if(f&&!p.length)return a=Er(e,{status:"error",error:d.error}),s([a,[]],d,[]),{snapshot:a,microsteps:r};let h=d2(p,e,n,i,!1,o);a=h[0],s(h,d,p)}let l=!0,c=e.machine.options?.maxIterations??1/0,u=0;for(;a.status==="active";){if(u++,u>c)throw new Error(`Infinite loop detected: the machine has processed more than ${c} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let d=l?gz(a,i):[],f=d.length?a:void 0;if(!d.length){if(!o.length)break;i=o.shift(),d=nI(i,a)}let p=d2(d,a,n,i,!1,o);a=p[0],l=a!==f,s(p,i,d)}return a.status!=="active"&&tI(a,i,n),{snapshot:a,microsteps:r}}function tI(e,t,n){return Vs(e,t,n,Object.values(e.children).map(o=>Zs(o)),[],void 0)}function nI(e,t){return t.machine.getTransitionData(t,e)}function gz(e,t){let n=new Set,o=e._nodes.filter(Xm);for(let a of o)e:for(let r of[a].concat(Vl(a,void 0)))if(r.always){for(let s of r.always)if(s.guard===void 0||Xs(s.guard,e.context,t,e)){n.add(s);break e}}return LI(Array.from(n),new Set(e._nodes),e.historyValue)}function _I(e,t){let n=Lf(Zl(e,t));return hI(e,[...n])}function CI(e){return!!e&&typeof e=="object"&&"machine"in e&&"value"in e}var xz=function(t){return m2(t,this.value)},bz=function(t){return this.tags.has(t)},Az=function(t){let n=this.machine.getTransitionData(this,t);return!!n?.length&&n.some(o=>o.target!==void 0||o.actions.length)},vz=function(){let{_nodes:t,tags:n,machine:o,getMeta:a,toJSON:r,can:s,hasTag:i,matches:l,...c}=this;return{...c,tags:Array.from(n)}},Lz=function(){return this._nodes.reduce((t,n)=>(n.meta!==void 0&&(t[n.id]=n.meta),t),{})};function wf(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:hI(t.root,e._nodes),tags:new Set(e._nodes.flatMap(n=>n.tags)),children:e.children,historyValue:e.historyValue||{},matches:xz,hasTag:bz,can:Az,getMeta:Lz,toJSON:vz}}function Er(e,t={}){return wf({...e,...t},e.machine)}function Sz(e){if(typeof e!="object"||e===null)return{};let t={};for(let n in e){let o=e[n];Array.isArray(o)&&(t[n]=o.map(a=>({id:a.id})))}return t}function TI(e,t){let{_nodes:n,tags:o,machine:a,children:r,context:s,can:i,hasTag:l,matches:c,getMeta:u,toJSON:d,...f}=e,p={};for(let m in r){let b=r[m];p[m]={snapshot:b.getPersistedSnapshot(t),src:b.src,systemId:b.systemId,syncSnapshot:b._syncSnapshot}}return{...f,context:II(s),children:p,historyValue:Sz(f.historyValue)}}function II(e){let t;for(let n in e){let o=e[n];if(o&&typeof o=="object")if("sessionId"in o&&"send"in o&&"ref"in o)t??=Array.isArray(e)?e.slice():{...e},t[n]={xstate$$type:Zm,id:o.id};else{let a=II(o);a!==o&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=a)}}return t??e}function kz(e,t,n,o,{event:a,id:r,delay:s},{internalQueue:i}){let l=t.machine.implementations.delays;if(typeof a=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${a}" }) instead`);let c=typeof a=="function"?a(n,o):a,u;if(typeof s=="string"){let d=l&&l[s];u=typeof d=="function"?d(n,o):d}else u=typeof s=="function"?s(n,o):s;return typeof u!="number"&&i.push(c),[t,{event:c,id:r,delay:u},void 0]}function wz(e,t){let{event:n,delay:o,id:a}=t;if(typeof o=="number"){e.defer(()=>{let r=e.self;e.system.scheduler.schedule(r,r,n,o,a)});return}}function Xl(e,t){function n(o,a){}return n.type="xstate.raise",n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=kz,n.execute=wz,n}function EI(e,t){return{config:e,transition:(n,o,a)=>({...n,context:e(n.context,o,a)}),getInitialSnapshot:(n,o)=>({status:"active",output:void 0,error:void 0,context:typeof t=="function"?t({input:o}):t}),getPersistedSnapshot:n=>n,restoreSnapshot:n=>n}}var hee=EI(e=>{},void 0);function _z(e,{machine:t,context:n},o,a){let r=(s,i)=>{if(typeof s=="string"){let l=vf(t,s);if(!l)throw new Error(`Actor logic '${s}' not implemented in machine '${t.id}'`);let c=Bo(l,{id:i?.id,parent:e.self,syncSnapshot:i?.syncSnapshot,input:typeof i?.input=="function"?i.input({context:n,event:o,self:e.self}):i?.input,src:s,systemId:i?.systemId});return a[c.id]=c,c}else return Bo(s,{id:i?.id,parent:e.self,syncSnapshot:i?.syncSnapshot,input:i?.input,src:s,systemId:i?.systemId})};return(s,i)=>{let l=r(s,i);return a[l.id]=l,e.defer(()=>{l._processingStatus!==qt.Stopped&&l.start()}),l}}function Cz(e,t,n,o,{assignment:a}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let r={},s={context:t.context,event:n.event,spawn:_z(e,t,n.event,r),self:e.self,system:e.system},i={};if(typeof a=="function")i=a(s,o);else for(let c of Object.keys(a)){let u=a[c];i[c]=typeof u=="function"?u(s,o):u}let l=Object.assign({},t.context,i);return[Er(t,{context:l,children:Object.keys(r).length?{...t.children,...r}:t.children}),void 0,void 0]}function vn(e){function t(n,o){}return t.type="xstate.assign",t.assignment=e,t.resolve=Cz,t}var MI=new WeakMap;function Yl(e,t,n){let o=MI.get(e);return o?t in o||(o[t]=n()):(o={[t]:n()},MI.set(e,o)),o[t]}var Tz={},_f=e=>typeof e=="string"?{type:e}:typeof e=="function"?"resolve"in e?{type:e.type}:{type:e.name}:e,$m=class e{constructor(t,n){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(f2),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?y2(this.config.states,(o,a)=>new e(o,{_parent:this,_key:a,_machine:this.machine})):Tz,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=Po(this.config.entry).slice(),this.exit=Po(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=Po(t.tags).slice()}_initialize(){this.transitions=gI(this),this.config.always&&(this.always=Ws(this.config.always).map(t=>_a(this,p2,t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(_f),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(_f),eventType:null})}:void 0,history:this.history,states:y2(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(_f)})),entry:this.entry.map(_f),exit:this.exit.map(_f),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return Yl(this,"invoke",()=>Po(this.config.invoke).map((t,n)=>{let{src:o,systemId:a}=t,r=t.id??g2(this.id,n),s=typeof o=="string"?o:`xstate.invoke.${g2(this.id,n)}`;return{...t,src:s,id:r,systemId:a,toJSON(){let{onDone:i,onError:l,...c}=t;return{...c,type:"xstate.invoke",src:s,id:r}}}}))}get on(){return Yl(this,"on",()=>[...this.transitions].flatMap(([n,o])=>o.map(a=>[n,a])).reduce((n,[o,a])=>(n[o]=n[o]||[],n[o].push(a),n),{}))}get after(){return Yl(this,"delayedTransitions",()=>yI(this))}get initial(){return Yl(this,"initial",()=>bI(this,this.config.initial))}next(t,n){let o=n.type,a=[],r,s=Yl(this,`candidates-${o}`,()=>mI(this,o));for(let i of s){let{guard:l}=i,c=t.context,u=!1;try{u=!l||Xs(l,c,n,t)}catch(d){let f=typeof l=="string"?l:typeof l=="object"?l.type:void 0;throw new Error(`Unable to evaluate guard ${f?`'${f}' `:""}in transition for event '${o}' in state node '${this.id}':
|
|
12
|
-
${d.message}`)}if(u){a.push(...i.actions),r=i;break}}return r?[r]:void 0}get events(){return Yl(this,"events",()=>{let{states:t}=this,n=new Set(this.ownEvents);if(t)for(let o of Object.keys(t)){let a=t[o];if(a.states)for(let r of a.events)n.add(`${r}`)}return Array.from(n)})}get ownEvents(){let t=Object.keys(Object.fromEntries(this.transitions)),n=new Set(t.filter(o=>this.transitions.get(o).some(a=>!(!a.target&&!a.actions.length&&!a.reenter))));return Array.from(n)}},Iz="#",Qm=class e{constructor(t,n){this.config=t,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=t.id||"(machine)",this.implementations={actors:n?.actors??{},actions:n?.actions??{},delays:n?.delays??{},guards:n?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new $m(t,{_key:this.id,_machine:this}),this.root._initialize(),xI(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:n,guards:o,actors:a,delays:r}=this.implementations;return new e(this.config,{actions:{...n,...t.actions},guards:{...o,...t.guards},actors:{...a,...t.actors},delays:{...r,...t.delays}})}resolveState(t){let n=_I(this.root,t.value),o=Lf(Zl(this.root,n));return wf({_nodes:[...o],context:t.context||{},children:{},status:Ym(o,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,n,o){return kf(t,n,o,[]).snapshot}microstep(t,n,o){return kf(t,n,o,[]).microsteps.map(([a])=>a)}getTransitionData(t,n){return Km(this.root,t.value,t,n)||[]}_getPreInitialState(t,n,o){let{context:a}=this.config,r=wf({context:typeof a!="function"&&a?a:{},_nodes:[this.root],children:{},status:"active"},this);return typeof a=="function"?Vs(r,n,t,[vn(({spawn:i,event:l,self:c})=>a({spawn:i,input:l.input,self:c}))],o,void 0):r}getInitialSnapshot(t,n){let o=jm(n),a=[],r=this._getPreInitialState(t,o,a),[s]=b2(this.root,r,t,o,a),{snapshot:i}=kf(s,o,t,a);return i}start(t){Object.values(t.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(t){let n=Vm(t),o=n.slice(1),a=Sf(n[0])?n[0].slice(Iz.length):n[0],r=this.idMap.get(a);if(!r)throw new Error(`Child state node '#${a}' does not exist on machine '${this.id}'`);return Af(r,o)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,n){return TI(t,n)}restoreSnapshot(t,n){let o={},a=t.children;Object.keys(a).forEach(d=>{let f=a[d],p=f.snapshot,h=f.src,m=typeof h=="string"?vf(this,h):h;if(!m)return;let b=Bo(m,{id:d,parent:n.self,syncSnapshot:f.syncSnapshot,snapshot:p,src:h,systemId:f.systemId});o[d]=b});function r(d,f){if(f instanceof $m)return f;try{return d.machine.getStateNodeById(f.id)}catch{}}function s(d,f){if(!f||typeof f!="object")return{};let p={};for(let h in f){let m=f[h];for(let b of m){let y=r(d,b);y&&(p[h]??=[],p[h].push(y))}}return p}let i=s(this.root,t.historyValue),l=wf({...t,children:o,_nodes:Array.from(Lf(Zl(this.root,t.value))),historyValue:i},this),c=new Set;function u(d,f){if(!c.has(d)){c.add(d);for(let p in d){let h=d[p];if(h&&typeof h=="object"){if("xstate$$type"in h&&h.xstate$$type===Zm){d[p]=f[h.id];continue}u(h,f)}}}}return u(l.context,o),l}};function Ez(e,t,n,o,{event:a}){let r=typeof a=="function"?a(n,o):a;return[t,{event:r},void 0]}function Mz(e,{event:t}){e.defer(()=>e.emit(t))}function e0(e){function t(n,o){}return t.type="xstate.emit",t.event=e,t.resolve=Ez,t.execute=Mz,t}var Jm=(function(e){return e.Parent="#_parent",e.Internal="#_internal",e})({});function Oz(e,t,n,o,{to:a,event:r,id:s,delay:i},l){let c=t.machine.implementations.delays;if(typeof r=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${r}" }) instead`);let u=typeof r=="function"?r(n,o):r,d;if(typeof i=="string"){let h=c&&c[i];d=typeof h=="function"?h(n,o):h}else d=typeof i=="function"?i(n,o):i;let f=typeof a=="function"?a(n,o):a,p;if(typeof f=="string"){if(f===Jm.Parent?p=e.self._parent:f===Jm.Internal?p=e.self:f.startsWith("#_")?p=t.children[f.slice(2)]:p=l.deferredActorIds?.includes(f)?f:t.children[f],!p)throw new Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`)}else p=f||e.self;return[t,{to:p,targetId:typeof f=="string"?f:void 0,event:u,id:s,delay:d},void 0]}function Rz(e,t,n){typeof n.to=="string"&&(n.to=t.children[n.to])}function Dz(e,t){e.defer(()=>{let{to:n,event:o,delay:a,id:r}=t;if(typeof a=="number"){e.system.scheduler.schedule(e.self,n,o,a,r);return}e.system._relay(e.self,n,o.type===aI?h2(e.self.id,o.data):o)})}function Cf(e,t,n){function o(a,r){}return o.type="xstate.sendTo",o.to=e,o.event=t,o.id=n?.id,o.delay=n?.delay,o.resolve=Oz,o.retryResolve=Rz,o.execute=Dz,o}function OI(e,t){return Cf(Jm.Parent,e,t)}function Pz(e,t,n,o,{collect:a}){let r=[],s=function(l){r.push(l)};return s.assign=(...i)=>{r.push(vn(...i))},s.cancel=(...i)=>{r.push(Wl(...i))},s.raise=(...i)=>{r.push(Xl(...i))},s.sendTo=(...i)=>{r.push(Cf(...i))},s.sendParent=(...i)=>{r.push(OI(...i))},s.spawnChild=(...i)=>{r.push(jl(...i))},s.stopChild=(...i)=>{r.push(Zs(...i))},s.emit=(...i)=>{r.push(e0(...i))},a({context:n.context,event:n.event,enqueue:s,check:i=>Xs(i,t.context,n.event,t),self:e.self,system:e.system},o),[t,void 0,r]}function St(e){function t(n,o){}return t.type="xstate.enqueueActions",t.collect=e,t.resolve=Pz,t}function Bz(e,t,n,o,{value:a,label:r}){return[t,{value:typeof a=="function"?a(n,o):a,label:r},void 0]}function zz({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function A2(e=({context:n,event:o})=>({context:n,event:o}),t){function n(o,a){}return n.type="xstate.log",n.value=e,n.label=t,n.resolve=Bz,n.execute=zz,n}function Nz(e,t){return new Qm(e,t)}function v2({schemas:e,actors:t,actions:n,guards:o,delays:a}){return{assign:vn,sendTo:Cf,raise:Xl,log:A2,cancel:Wl,stopChild:Zs,enqueueActions:St,emit:e0,spawnChild:jl,createStateConfig:r=>r,createAction:r=>r,createMachine:r=>Nz({...r,schemas:e},{actors:t,actions:n,guards:o,delays:a}),extend:r=>v2({schemas:e,actors:t,actions:{...n,...r.actions},guards:{...o,...r.guards},delays:{...a,...r.delays}})}}var Fz=()=>({mode:D_,pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null}),Ys=4,zo=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o>=Ys*Ys},Tf=(e,t)=>{let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y);return{x:n,y:o,width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}},RI=v2({types:{context:{},events:{},emitted:{}},actions:{startPress:vn((e,t)=>({pressOrigin:t.point,pressLast:t.point,pressTarget:t.target,pressModifiers:t.modifiers})),updateLast:vn((e,t)=>({pressLast:t.point})),setDrawingType:vn((e,t)=>({drawingType:t.kind})),resetGesture:vn(()=>({pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null})),setMode:vn((e,t)=>({mode:t.mode})),emitMoveElement:St(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="element"||n.emit({type:"MOVE_SHAPE",id:e.pressTarget.id,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitMoveAnnotation:St(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="annotation"||n.emit({type:"MOVE_ANNOTATION",id:e.pressTarget.id,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalPosition:e.pressTarget.origin})}),emitCommitAnnotationDrag:St(({context:e,enqueue:t})=>{e.pressTarget?.kind==="annotation"&&t.emit({type:"COMMIT_ANNOTATION_DRAG",id:e.pressTarget.id})}),emitResizeElement:St(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="handle"||n.emit({type:"RESIZE_SHAPE",id:e.pressTarget.elementId,handle:e.pressTarget.handle,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitResizeGroup:St(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="group-handle"||n.emit({type:"RESIZE_GROUP",handle:e.pressTarget.handle,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitRotate:St(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="rotate-handle")return;let{pivot:o}=e.pressTarget,a=Math.atan2(e.pressOrigin.y-o.y,e.pressOrigin.x-o.x),r=Math.atan2(t.point.y-o.y,t.point.x-o.x);n.emit({type:"ROTATE",pivot:o,deltaAngle:r-a})}),maybeEmitCreate:St(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin||!e.drawingType)return;let o=Tf(e.pressOrigin,t.point);o.width<1||o.height<1||n.emit({type:"CREATE_SHAPE",shapeType:e.drawingType,bounds:o})}),emitLinkPreview:St(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||n.emit({type:"DRAW_EDGE_PREVIEW",fromElement:e.pressTarget?.kind==="element"?e.pressTarget.id:null,fromPoint:e.pressOrigin,toPoint:t.point})}),emitLinkPreviewClear:St(({enqueue:e})=>{e.emit({type:"DRAW_EDGE_PREVIEW_CLEAR"})}),emitLinkEndpointPreview:St(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind==="edge-endpoint"&&n.emit({type:"UPDATE_EDGE_ENDPOINT_PREVIEW",linkId:e.pressTarget.linkId,side:e.pressTarget.side,toPoint:t.point})}),emitLinkEndpointUpdate:St(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin||e.pressTarget?.kind!=="edge-endpoint")return;let o=t.target,a=o?.kind==="element"?o.id:null;n.emit({type:"UPDATE_EDGE_ENDPOINT",linkId:e.pressTarget.linkId,side:e.pressTarget.side,toPoint:t.point,toElement:a})}),emitLassoProgress:St(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_MOVE"||!e.pressOrigin)return;let o=e.pressModifiers,a=!!(o&&(o.shift||o.meta||o.ctrl));n.emit({type:"LASSO_PROGRESS",bounds:Tf(e.pressOrigin,t.point),mode:a?"add":"replace"})}),emitLassoCommit:St(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin)return;let o=Tf(e.pressOrigin,t.point);if(o.width<1&&o.height<1){n.emit({type:"LASSO_CLEAR"});return}let a=e.pressModifiers,r=!!(a&&(a.shift||a.meta||a.ctrl));n.emit({type:"SELECT_BY_BOUNDS",bounds:o,mode:r?"add":"replace"}),n.emit({type:"LASSO_CLEAR"})}),emitCreateLink:St(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin)return;let o=t.target,a=o?.kind==="element"?o.id:null,r=e.pressTarget?.kind==="element"?e.pressTarget.id:null,s=t.point.x-e.pressOrigin.x,i=t.point.y-e.pressOrigin.y;s*s+i*i<Ys*Ys||n.emit({type:"CREATE_EDGE",fromElement:r,toElement:a,fromPoint:e.pressOrigin,toPoint:t.point})})},guards:{movedAndOnElement:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="element"||e.mode!=="select"?!1:zo(e.pressOrigin,t.point),movedAndOnHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="handle"?!1:zo(e.pressOrigin,t.point),movedAndOnGroupHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="group-handle"?!1:zo(e.pressOrigin,t.point),movedAndOnRotateHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="rotate-handle"?!1:zo(e.pressOrigin,t.point),movedAndDrawing:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="draw-rect"&&e.mode!=="draw-ellipse"&&e.mode!=="draw-frame"?!1:zo(e.pressOrigin,t.point),movedAndDrawingLink:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="draw-edge"?!1:zo(e.pressOrigin,t.point),movedAndOnLinkEndpoint:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="edge-endpoint"?!1:zo(e.pressOrigin,t.point),movedAndOnAnnotation:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="annotation"||e.mode!=="select"?!1:zo(e.pressOrigin,t.point),movedAndLasso:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="select"||e.pressTarget?.kind!=="empty"?!1:zo(e.pressOrigin,t.point)}}).createMachine({id:"interaction",initial:"idle",context:Fz(),on:{SET_MODE:{target:".idle",actions:[{type:"setMode",params:({event:e})=>({mode:e.mode})},{type:"resetGesture"}]}},states:{idle:{on:{POINTER_DOWN:{target:"pressing",actions:[{type:"startPress",params:({event:e})=>({point:e.point,target:e.target,modifiers:e.modifiers??null})}]}}},pressing:{on:{POINTER_MOVE:[{guard:"movedAndOnHandle",target:"draggingHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeElement"}]},{guard:"movedAndOnGroupHandle",target:"draggingGroupHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeGroup"}]},{guard:"movedAndOnRotateHandle",target:"draggingRotateHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitRotate"}]},{guard:"movedAndOnElement",target:"draggingElement",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveElement"}]},{guard:"movedAndDrawing",target:"drawing",actions:[{type:"setDrawingType",params:({context:e})=>({kind:e.mode==="draw-rect"?"rect":e.mode==="draw-frame"?"frame":"ellipse"})},{type:"updateLast",params:({event:e})=>({point:e.point})}]},{guard:"movedAndDrawingLink",target:"drawingLink",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkPreview"}]},{guard:"movedAndOnLinkEndpoint",target:"draggingLinkEndpoint",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkEndpointPreview"}]},{guard:"movedAndOnAnnotation",target:"draggingAnnotation",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveAnnotation"}]},{guard:"movedAndLasso",target:"lassoing",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLassoProgress"}]},{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})}]}],POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingElement:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveElement"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeElement"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingGroupHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeGroup"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingRotateHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitRotate"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},drawing:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})}]},POINTER_UP:{target:"idle",actions:[{type:"maybeEmitCreate"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},drawingLink:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkPreview"}]},POINTER_UP:{target:"idle",actions:[{type:"emitCreateLink"},{type:"emitLinkPreviewClear"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"emitLinkPreviewClear"},{type:"resetGesture"}]}}},draggingLinkEndpoint:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkEndpointPreview"}]},POINTER_UP:{target:"idle",actions:[{type:"emitLinkEndpointUpdate"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingAnnotation:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveAnnotation"}]},POINTER_UP:{target:"idle",actions:[{type:"emitCommitAnnotationDrag"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},lassoing:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLassoProgress"}]},POINTER_UP:{target:"idle",actions:[{type:"emitLassoCommit"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"emitLassoCommit"},{type:"resetGesture"}]}}}}}),DI=(e,t)=>{if(!e.pressOrigin||!e.pressTarget||zo(e.pressOrigin,t)||e.mode==="draw-edge")return null;if(e.pressTarget.kind==="element"){let n=e.pressModifiers;return n&&(n.shift||n.meta||n.ctrl)?{type:"SELECT_TOGGLE",id:e.pressTarget.id}:{type:"SELECT_REPLACE",id:e.pressTarget.id}}if(e.pressTarget.kind==="link"){let n=e.pressModifiers;return n&&(n.shift||n.meta||n.ctrl)?{type:"SELECT_EDGE_TOGGLE",id:e.pressTarget.id}:{type:"SELECT_EDGE_REPLACE",id:e.pressTarget.id}}return e.pressTarget.kind==="empty"&&e.mode==="select"?{type:"SELECT_CLEAR"}:null};var PI=new Map,Vn=(e,t)=>{PI.set(e,t)},Kl=e=>PI.get(e);var Ks=["background","main","overlay"];var Mr=class{entries=new Map;get(t){let n=this.entries.get(t.id);if(n){if(n.ref!==t){this.entries.delete(t.id);return}return n.value}}set(t,n){return this.entries.set(t.id,{ref:t,value:n}),n}getOrCompute(t,n){let o=this.get(t);return o!==void 0?o:this.set(t,n(t))}invalidate(t){this.entries.delete(t)}clear(){this.entries.clear()}prune(t){for(let n of this.entries.keys())t.elements.has(n)||this.entries.delete(n)}get size(){return this.entries.size}},Hz=new Mr,$l=(e,t)=>e.getOrCompute(t,z);var L2={gray1:"#111111",gray2:"#191919",gray3:"#222222",gray4:"#2a2a2a",gray5:"#313131",gray6:"#3a3a3a",gray7:"#484848",gray8:"#606060",gray9:"#6e6e6e",gray10:"#7b7b7b",gray11:"#b4b4b4",gray12:"#eeeeee"};var t0={tomato1:"#181111",tomato2:"#1f1513",tomato3:"#391714",tomato4:"#4e1511",tomato5:"#5e1c16",tomato6:"#6e2920",tomato7:"#853a2d",tomato8:"#ac4d39",tomato9:"#e54d2e",tomato10:"#ec6142",tomato11:"#ff977d",tomato12:"#fbd3cb"};var S2={plum1:"#181118",plum2:"#201320",plum3:"#351a35",plum4:"#451d47",plum5:"#512454",plum6:"#5e3061",plum7:"#734079",plum8:"#92549c",plum9:"#ab4aba",plum10:"#b658c4",plum11:"#e796f3",plum12:"#f4d4f4"};var $s={iris1:"#13131e",iris2:"#171625",iris3:"#202248",iris4:"#262a65",iris5:"#303374",iris6:"#3d3e82",iris7:"#4a4a95",iris8:"#5958b1",iris9:"#5b5bd6",iris10:"#6e6ade",iris11:"#b1a9ff",iris12:"#e0dffe"};var k2={cyan1:"#0b161a",cyan2:"#101b20",cyan3:"#082c36",cyan4:"#003848",cyan5:"#004558",cyan6:"#045468",cyan7:"#12677e",cyan8:"#11809c",cyan9:"#00a2c7",cyan10:"#23afd0",cyan11:"#4ccce6",cyan12:"#b6ecf7"};var w2={grass1:"#0e1511",grass2:"#141a15",grass3:"#1b2a1e",grass4:"#1d3a24",grass5:"#25482d",grass6:"#2d5736",grass7:"#366740",grass8:"#3e7949",grass9:"#46a758",grass10:"#53b365",grass11:"#71d083",grass12:"#c2f0c2"};var _2={amber1:"#16120c",amber2:"#1d180f",amber3:"#302008",amber4:"#3f2700",amber5:"#4d3000",amber6:"#5c3d05",amber7:"#714f19",amber8:"#8f6424",amber9:"#ffc53d",amber10:"#ffd60a",amber11:"#ffca16",amber12:"#ffe7b3"};var Ql={gray1:"#fcfcfc",gray2:"#f9f9f9",gray3:"#f0f0f0",gray4:"#e8e8e8",gray5:"#e0e0e0",gray6:"#d9d9d9",gray7:"#cecece",gray8:"#bbbbbb",gray9:"#8d8d8d",gray10:"#838383",gray11:"#646464",gray12:"#202020"};var Qs={tomato1:"#fffcfc",tomato2:"#fff8f7",tomato3:"#feebe7",tomato4:"#ffdcd3",tomato5:"#ffcdc2",tomato6:"#fdbdaf",tomato7:"#f5a898",tomato8:"#ec8e7b",tomato9:"#e54d2e",tomato10:"#dd4425",tomato11:"#d13415",tomato12:"#5c271f"};var C2={plum1:"#fefcff",plum2:"#fdf7fd",plum3:"#fbebfb",plum4:"#f7def8",plum5:"#f2d1f3",plum6:"#e9c2ec",plum7:"#deade3",plum8:"#cf91d8",plum9:"#ab4aba",plum10:"#a144af",plum11:"#953ea3",plum12:"#53195d"};var Ca={iris1:"#fdfdff",iris2:"#f8f8ff",iris3:"#f0f1fe",iris4:"#e6e7ff",iris5:"#dadcff",iris6:"#cbcdff",iris7:"#b8baf8",iris8:"#9b9ef0",iris9:"#5b5bd6",iris10:"#5151cd",iris11:"#5753c6",iris12:"#272962"};var T2={cyan1:"#fafdfe",cyan2:"#f2fafb",cyan3:"#def7f9",cyan4:"#caf1f6",cyan5:"#b5e9f0",cyan6:"#9ddde7",cyan7:"#7dcedc",cyan8:"#3db9cf",cyan9:"#00a2c7",cyan10:"#0797b9",cyan11:"#107d98",cyan12:"#0d3c48"};var Jl={grass1:"#fbfefb",grass2:"#f5fbf5",grass3:"#e9f6e9",grass4:"#daf1db",grass5:"#c9e8ca",grass6:"#b2ddb5",grass7:"#94ce9a",grass8:"#65ba74",grass9:"#46a758",grass10:"#3e9b4f",grass11:"#2a7e3b",grass12:"#203c25"};var ec={amber1:"#fefdfb",amber2:"#fefbe9",amber3:"#fff7c2",amber4:"#ffee9c",amber5:"#fbe577",amber6:"#f3d673",amber7:"#e9c162",amber8:"#e2a336",amber9:"#ffc53d",amber10:"#ffba18",amber11:"#ab6400",amber12:"#4f3422"};var Or=["tomato","amber","grass","cyan","iris","plum","gray"],If=(e,t)=>{let n=e[t];if(n===void 0)throw new Error(`Missing color token: ${t}`);return n},Jt=(e,t)=>({fill:If(e,`${t}4`),solid:If(e,`${t}9`),solidHover:If(e,`${t}10`),textLow:If(e,`${t}11`),textHigh:If(e,`${t}12`)}),tc={light:{tomato:Jt(Qs,"tomato"),amber:Jt(ec,"amber"),grass:Jt(Jl,"grass"),cyan:Jt(T2,"cyan"),iris:Jt(Ca,"iris"),plum:Jt(C2,"plum"),gray:Jt(Ql,"gray")},dark:{tomato:Jt(t0,"tomato"),amber:Jt(_2,"amber"),grass:Jt(w2,"grass"),cyan:Jt(k2,"cyan"),iris:Jt($s,"iris"),plum:Jt(S2,"plum"),gray:Jt(L2,"gray")}},n0={light:{tomato:Qs.tomato2,amber:ec.amber2,grass:Jl.grass2,cyan:T2.cyan2,iris:Ca.iris2,plum:C2.plum2,gray:Ql.gray2},dark:{tomato:t0.tomato2,amber:_2.amber2,grass:w2.grass2,cyan:k2.cyan2,iris:$s.iris2,plum:S2.plum2,gray:L2.gray2}};var Uz={light:{accent:Ca.iris9,accentHover:Ca.iris10,selectedBg:Ca.iris4,selectedFg:Ca.iris11,danger:Qs.tomato9},dark:{accent:$s.iris9,accentHover:$s.iris10,selectedBg:$s.iris4,selectedFg:$s.iris11,danger:t0.tomato9}},I2=Ql.gray6,E2=Ql.gray9,Rr={rectangle:{fill:Ca.iris3,stroke:Ca.iris9,strokeWidth:2},ellipse:{fill:Qs.tomato3,stroke:Qs.tomato9,strokeWidth:2},flowchart:{fill:Jl.grass3,stroke:Jl.grass9,strokeWidth:2},sticky:{fill:ec.amber3,stroke:ec.amber9,strokeWidth:1}},M2={stroke:Ql.gray12,strokeWidth:1.5},Gz={added:Jl.grass9,removed:Qs.tomato9,modified:ec.amber9};var O2={placeholder:.15,hideText:.4},R2="#bbb";var BI=.06,zI=.92,NI=.5,nc=10,D2=I2,P2=E2,B2=1,z2=1,N2=4,F2=4,H2=3,U2=12,G2=56,q2=10,W2=20,FI=.4,HI=.5,j2=.1,V2=.9,UI="#888",GI="#ffffff",qI="#222",WI="#ddd",jI=18,VI=12,ZI="#444",XI="#222",YI=10,Z2="#000",KI=.5,$I=12,QI="#222",JI="#fff";var Ef=class{cap;onEvict;map=new Map;constructor(t,n){this.cap=t,this.onEvict=n}get(t){let n=this.map.get(t);if(n!==void 0)return this.map.delete(t),this.map.set(t,n),n}has(t){return this.map.has(t)}set(t,n){for(this.map.delete(t),this.map.set(t,n);this.map.size>this.cap;){let o=this.map.keys().next().value,a=this.map.get(o);this.map.delete(o),a!==void 0&&this.onEvict?.(o,a)}}delete(t){return this.map.delete(t)}clear(){this.map.clear()}get size(){return this.map.size}keys(){return this.map.keys()}values(){return this.map.values()}};var o0=e=>e<=0?1:2**Math.round(Math.log2(e));var Js=(e,t,n={})=>{let o=qn(e.viewport),a=n.dirtyWorld;if(!n.skipClear)if(a){let g=[B.applyToPoint(o,{x:a.x,y:a.y}),B.applyToPoint(o,{x:a.x+a.width,y:a.y+a.height})],x=X.expand(X.fromPoints(g),2);t.clear(x)}else t.clear();t.save(),t.setTransform(o);let r=n.boundsCache??new Mr,s=n.viewport,i=null;s&&n.spatialIndex&&(i=n.spatialIndex.query(s));let l=e.viewport.zoom,c=n.lod,u=c?.placeholder!==void 0&&l<c.placeholder,d=c?.hideText!==void 0&&l<c.hideText,f=n.placeholderFill??R2,p=n.layerCompositeCache,h=n.dirtyLayerIds,m=n.compositeLayerBitmap,b=o0(l),y=g=>{let x=null;for(let A of La(e,g)){let C=$l(r,A);x=x?X.union(x,C):C}return x};for(let g of co(e))if(g.visible){if(p&&m){h?.has(g.id)&&p.invalidateLayer(g.id);let x=p.get(g.id,b);if(x===void 0){let A=m(g.id,b,e);A!==null&&(p.set(g.id,b,A),x=A)}if(x!==void 0){let A=y(g.id);A&&t.drawImage(x,A.x,A.y,A.width,A.height);continue}}for(let x of La(e,g.id)){if(n.hideElements?.has(x.id)||i&&!i.has(x.id))continue;if(s){let C=$l(r,x);if(!X.intersects(C,s))continue}if(a){let C=$l(r,x);if(!X.intersects(C,a))continue}if(d&&Fe(x))continue;if(u){let C=$l(r,x);t.setFill(f),t.setStrokeWidth(0),t.beginPath(),t.rect(C.x,C.y,C.width,C.height),t.fill();continue}let A=Kl(x.type);if(!A){n.onUnknownElement?.(x);continue}t.save(),n.dimElements?.has(x.id)&&n.dimOpacity!==void 0&&t.setOpacity(n.dimOpacity),t.translate(x.position.x,x.position.y),x.rotation!==0&&t.rotate(x.rotation),(x.scale.x!==1||x.scale.y!==1)&&t.scale(x.scale.x,x.scale.y),A(x,t,{zoom:l}),t.restore()}}t.restore()};var a0=class{entries=new Map;get(t,n){let o=this.entries.get(n.id);if(o){if(o.edge!==n||o.scene!==t){this.entries.delete(n.id);return}return o.value}}set(t,n,o){return this.entries.set(n.id,{edge:n,scene:t,value:o}),o}getOrCompute(t,n){let o=this.get(t,n);return o!==void 0?o:this.set(t,n,Dr(t,n))}invalidate(t){this.entries.delete(t)}clear(){this.entries.clear()}prune(t){for(let n of this.entries.keys())t.links.has(n)||this.entries.delete(n)}get size(){return this.entries.size}},Dr=(e,t)=>{let n=Dl(e,t);if(!n||n.length===0)return null;let o=1/0,a=1/0,r=-1/0,s=-1/0;for(let u of n)u.x<o&&(o=u.x),u.y<a&&(a=u.y),u.x>r&&(r=u.x),u.y>s&&(s=u.y);let i=t.arrowheads,l=i?.from!==void 0&&i.from!=="none"||i?.to!==void 0&&i.to!=="none",c=Math.max(2,(t.style.strokeWidth??1)/2+(l?i.size??10:0));return{x:o-c,y:a-c,width:r-o+c*2,height:s-a+c*2}},X2=new a0;var No=(e,t,n={})=>{t.save(),t.setTransform(qn(e.viewport));let o=n.edgeBoundsCache??X2,a=n.viewportWorld,r=n.dirtyWorld,s=n.edgeBitmapCache,i=n.rasteriseLink,l=o0(n.zoom??e.viewport.zoom);for(let c of co(e))if(c.visible)for(let u of j1(e,c.id)){let d=null;if(a||r||s&&i){if(d=o.getOrCompute(e,u),d===null){n.onMissingEndpoint?.(u);continue}if(a&&!X.intersects(d,a)||r&&!X.intersects(d,r))continue}if(s&&i&&d){let f=s.get(u,l);if(f===void 0){let p=i(u,d,e,l);p!==null&&(s.set(u,l,p),f=p)}if(f!==void 0){t.drawImage(f,d.x,d.y,d.width,d.height);continue}}qz(e,u,t,n)}t.restore()},qz=(e,t,n,o)=>{let a=rt(e,t);if(!a||a.length<2){o.onMissingEndpoint?.(t);return}if(n.save(),(t.lineKind??"line")==="block-arrow")Wz(t,a,n);else{Zz(t,n);let r=(t.routing??"straight")==="bezier"?nf(e,t):null;if(n.beginPath(),r){n.moveTo(r.start.x,r.start.y);for(let s of r.segments)n.bezierCurveTo(s.c1.x,s.c1.y,s.c2.x,s.c2.y,s.to.x,s.to.y)}else if(a.length>=3&&nc>0)r0(n,a,nc);else{let s=L(a[0]);n.moveTo(s.x,s.y);for(let i=1;i<a.length;i++){let l=L(a[i]);n.lineTo(l.x,l.y)}}if(n.stroke(),t.arrowheads){let s=r?$d(r.start,r.segments):a;Xz(s,t.arrowheads,n,t.style.stroke??Z2)}}t.label&&Yz(a,t.label,n),n.restore()},Wz=(e,t,n)=>{let o=e.blockArrow?.headLength??jI,a=e.blockArrow?.bodyThickness??VI,r=e.style.fill??e.style.stroke??ZI,s=e.style.stroke??XI,i=e.style.strokeWidth??1;e.style.opacity!==void 0&&n.setOpacity(e.style.opacity);let l=jz(t,o);if(l.length<2)return;let c=eE(l,a/2),u=eE(l,-a/2),d=L(c[c.length-1]),f=L(u[u.length-1]),p=L(t[t.length-1]);n.setFill(r),n.setStroke(s),n.setStrokeWidth(i),n.beginPath();let h=L(c[0]);n.moveTo(h.x,h.y);for(let g=1;g<c.length;g++){let x=L(c[g]);n.lineTo(x.x,x.y)}let m=Math.max(0,a*.5),b=tE(d,p,m),y=tE(f,p,-m);n.lineTo(b.x,b.y),n.lineTo(p.x,p.y),n.lineTo(y.x,y.y);for(let g=u.length-1;g>=0;g--){let x=L(u[g]);n.lineTo(x.x,x.y)}n.closePath(),n.fill(),i>0&&n.stroke()},jz=(e,t)=>{if(e.length<2)return e;let n=t,o=[...e].reverse(),a=[L(o[0])];for(let r=1;r<o.length;r++){let s=L(a[a.length-1]),i=L(o[r]),l=i.x-s.x,c=i.y-s.y,u=Math.hypot(l,c);if(u>n){let d=n/u,f={x:s.x+l*d,y:s.y+c*d};return a[a.length-1]=f,a.push(...o.slice(r)),a.reverse()}n-=u,a[a.length-1]=i}return e},eE=(e,t)=>{if(e.length<2)return e;let n=[];for(let o=0;o<e.length;o++){let a=L(e[Math.max(0,o-1)]),r=L(e[Math.min(e.length-1,o+1)]),s=L(e[o]),i=r.x-a.x,l=r.y-a.y,c=Math.hypot(i,l)||1,u=-l/c,d=i/c;n.push({x:s.x+u*t,y:s.y+d*t})}return n},tE=(e,t,n)=>{let o=t.x-e.x,a=t.y-e.y,r=Math.hypot(o,a)||1,s=-a/r,i=o/r;return{x:e.x+s*n,y:e.y+i*n}},Vz=e=>{if(e.length<=2)return e;let t=[L(e[0])];for(let n=1;n<e.length-1;n++){let o=L(t[t.length-1]),a=L(e[n]),r=L(e[n+1]),s=Math.abs(o.y-a.y)<1e-6&&Math.abs(a.y-r.y)<1e-6,i=Math.abs(o.x-a.x)<1e-6&&Math.abs(a.x-r.x)<1e-6,l=Math.abs(o.x-a.x)<1e-6&&Math.abs(o.y-a.y)<1e-6;s||i||l||t.push(a)}return t.push(L(e[e.length-1])),t},r0=(e,t,n)=>{let o=Vz(t);if(o.length<3){let s=L(o[0]);e.moveTo(s.x,s.y);for(let i=1;i<o.length;i++){let l=L(o[i]);e.lineTo(l.x,l.y)}return}let a=L(o[0]);e.moveTo(a.x,a.y);for(let s=1;s<o.length-1;s++){let i=L(o[s-1]),l=L(o[s]),c=L(o[s+1]),u=Math.hypot(i.x-l.x,i.y-l.y),d=Math.hypot(c.x-l.x,c.y-l.y);if(u<1e-6||d<1e-6){e.lineTo(l.x,l.y);continue}let f=Math.min(n,u/2,d/2),p={x:l.x+(i.x-l.x)/u*f,y:l.y+(i.y-l.y)/u*f},h={x:l.x+(c.x-l.x)/d*f,y:l.y+(c.y-l.y)/d*f};e.lineTo(p.x,p.y),e.quadraticCurveTo(l.x,l.y,h.x,h.y)}let r=L(o[o.length-1]);e.lineTo(r.x,r.y)},Zz=(e,t)=>{let n=e.style.stroke??Z2;t.setStroke(n),t.setFill(null),t.setStrokeWidth(e.style.strokeWidth??1),e.style.opacity!==void 0&&t.setOpacity(e.style.opacity),e.style.lineCap!==void 0&&t.setLineCap(e.style.lineCap),e.style.lineJoin!==void 0&&t.setLineJoin(e.style.lineJoin),t.setDashArray(e.style.dashArray??null)},Xz=(e,t,n,o)=>{let a=t.size??YI;if(t.from&&t.from!=="none"){let r=e[0],s=e[1];r!==void 0&&s!==void 0&&nE(r,s,t.from,a,n,o)}if(t.to&&t.to!=="none"){let r=e[e.length-1],s=e[e.length-2];r!==void 0&&s!==void 0&&nE(r,s,t.to,a,n,o)}},nE=(e,t,n,o,a,r)=>{let s=t.x-e.x,i=t.y-e.y,l=Math.hypot(s,i)||1,c=s/l,u=i/l,d=-u,f=c,p=o*.5,h=y=>({x:e.x+c*y,y:e.y+u*y}),m=(y,g)=>({x:e.x+c*y+d*g,y:e.y+u*y+f*g}),b=()=>{a.setFill(r),a.fill(),a.setFill(null),a.stroke()};switch(n){case"arrow":case"openArrow":case"roundedArrow":{let y=n==="openArrow"?o*.65:p,g=n==="openArrow"?o*1.1:o;n==="roundedArrow"&&a.setLineCap("round"),a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(e.x+c*g+d*y,e.y+u*g+f*y),a.moveTo(e.x,e.y),a.lineTo(e.x+c*g-d*y,e.y+u*g-f*y),a.stroke(),n==="roundedArrow"&&a.setLineCap("butt");break}case"arcArrow":{let y=m(o,p),g=m(o,-p),x=h(o*.45);a.beginPath(),a.moveTo(y.x,y.y),a.lineTo(e.x,e.y),a.lineTo(g.x,g.y),a.quadraticCurveTo(x.x,x.y,y.x,y.y),a.stroke();break}case"triangle":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...po(m(o,p))),a.lineTo(...po(m(o,-p))),a.closePath(),a.stroke();break}case"filledArrow":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...po(m(o,p))),a.lineTo(...po(m(o,-p))),a.closePath(),b();break}case"circle":case"filledCircle":{let y=p,g=h(y);a.beginPath(),a.ellipse(g.x,g.y,y,y),n==="filledCircle"?b():a.stroke();break}case"diamond":case"rhombus":case"filledRhombus":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...po(m(o,p))),a.lineTo(...po(h(o*2))),a.lineTo(...po(m(o,-p))),a.closePath(),n==="filledRhombus"?b():a.stroke();break}case"erdOne":case"erdOnlyOne":case"erdMany":case"erdOneOrMany":case"erdZeroOrOne":case"erdZeroOrMany":{let y=n==="erdMany"||n==="erdOneOrMany"||n==="erdZeroOrMany",g=n==="erdZeroOrOne"||n==="erdZeroOrMany",x=n==="erdOnlyOne",A=n==="erdOne"||n==="erdOnlyOne"||n==="erdOneOrMany"||n==="erdZeroOrOne";if(y){let v=h(o);a.beginPath(),a.moveTo(v.x,v.y),a.lineTo(e.x,e.y),a.moveTo(v.x,v.y),a.lineTo(...po(m(0,p))),a.moveTo(v.x,v.y),a.lineTo(...po(m(0,-p))),a.stroke()}let C=y?o*1.15:o*.55,_=v=>{a.beginPath(),a.moveTo(...po(m(v,p))),a.lineTo(...po(m(v,-p))),a.stroke()};if(A&&_(C),x&&_(C+o*.4),g){let v=p*.6,I=h(o*(y?1.6:1)+v);a.beginPath(),a.ellipse(I.x,I.y,v,v),a.stroke()}break}}},po=e=>[e.x,e.y],Yz=(e,t,n)=>{let o=t.position??KI,a=t.fontSize??$I,r=t.fill??QI,s=t.background??JI,i=Kz(e,o),l=t.text.length*a*.3+4,c=a*.7;n.beginPath(),n.setFill(s),n.setStroke(null),n.rect(i.x-l,i.y-c,l*2,c*2),n.fill(),n.setFill(r),n.setFont("system-ui, sans-serif",a),n.setTextAlign("center"),n.setTextBaseline("middle"),n.fillText(t.text,i.x,i.y)},Kz=(e,t)=>{if(e.length===2){let[r,s]=e;return{x:r.x+(s.x-r.x)*t,y:r.y+(s.y-r.y)*t}}let n=[],o=0;for(let r=1;r<e.length;r++){let s=L(e[r]),i=L(e[r-1]),l=s.x-i.x,c=s.y-i.y,u=Math.hypot(l,c);n.push(u),o+=u}let a=o*t;for(let r=0;r<n.length;r++){let s=L(n[r]);if(a<=s){let i=s===0?0:a/s,l=L(e[r]),c=L(e[r+1]);return{x:l.x+(c.x-l.x)*i,y:l.y+(c.y-l.y)*i}}a-=s}return L(e[e.length-1])};var oE=(e,t,n,o,a=F2,r=H2)=>{let s=[];if(e<=0||t<=0)return s;let i=e*t,l=Math.ceil(Math.log(n/i)/Math.log(a));for(let c=0;c<r;c++){let u=l+c,d=e*a**u,f=d*t,p=Math.max(0,Math.min(1,(f-n)/(o-n)));p<=0||s.push({step:d,opacity:p})}return s},Mf=(e,t,n={})=>{if(n.skipClear||t.clear(),!e.viewport.gridEnabled)return;let o=20,r=(e.viewport.gridStyle??"lines")==="dots",s=n.color??(r?P2:D2),i=e.viewport.zoom,{width:l,height:c}=t.size;if(l<=0||c<=0)return;let u=eN(e,l,c);if(!u)return;let d=f=>{r?Qz(t,u,f,s,i):$z(t,u,f,s,i)};if(t.save(),t.setTransform(qn(e.viewport)),t.setDashArray(null),n.levels)for(let f of n.levels){let p=Jz(i,f);if(p<=0)continue;let h=f.step*o;h*i<N2||(t.setOpacity(p),d(h))}else{let f=r?q2:U2,p=r?W2:G2;for(let h of oE(o,i,f,p))t.setOpacity(h.opacity),d(h.step)}t.setOpacity(1),t.restore()},$z=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=aE(t,n),c=B2/a;e.setStroke(o),e.setStrokeWidth(c),e.beginPath();for(let u=r;u<=s;u+=n)e.moveTo(u,i),e.lineTo(u,l);for(let u=i;u<=l;u+=n)e.moveTo(r,u),e.lineTo(s,u);e.stroke()},Qz=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=aE(t,n);e.setStroke(null),e.setFill(o);let c=z2/a,u=c*2;for(let d=r;d<=s;d+=n)for(let f=i;f<=l;f+=n)e.beginPath(),e.rect(d-c,f-c,u,u),e.fill()},aE=(e,t)=>({minX:Math.floor(e.x/t)*t-t,maxX:Math.ceil((e.x+e.width)/t)*t+t,minY:Math.floor(e.y/t)*t-t,maxY:Math.ceil((e.y+e.height)/t)*t+t}),Jz=(e,t)=>e>=t.mid?1:e<=t.min?0:(e-t.min)/(t.mid-t.min),eN=(e,t,n)=>{let o=ka(e.viewport),a=[B.applyToPoint(o,{x:0,y:0}),B.applyToPoint(o,{x:t,y:0}),B.applyToPoint(o,{x:t,y:n}),B.applyToPoint(o,{x:0,y:n})],r=X.fromPoints(a);return Number.isFinite(r.x)?r:null};var rE=1.2,tN=(e,t,n,o,a)=>{if(e===""){a.push({text:"",start:t,end:t,width:0});return}let r=[],s=/\S+/g,i;for(;(i=s.exec(e))!==null;)r.push({s:i.index,e:i.index+i[0].length});if(r.length===0){a.push({text:e,start:t,end:t+e.length,width:o(e)});return}let l=0,c=(d,f)=>{let p=e.slice(d,f);a.push({text:p,start:t+d,end:t+f,width:o(p)})},u=0;for(;u<r.length;){let d=L(r[u]);if(o(e.slice(l,d.e))<=n){u++;continue}if(d.s>l){c(l,d.s),l=d.s;continue}let f=d.s+1;for(;f<d.e&&o(e.slice(l,f+1))<=n;)f++;if(f>=d.e){u++;continue}c(l,f),l=f,d.s=f}c(l,e.length)},Of=(e,t,n)=>{let o=n.fontSize*(n.lineHeightFactor??rE),a=[],r=0;for(let l=0;l<=e.length;l++)if(l===e.length||e[l]===`
|
|
13
|
-
`){let c=e.slice(r,l);n.maxWidth===void 0?a.push({text:c,start:r,end:l,width:t(c)}):
|
|
14
|
-
`))i=[{text:e.text,x:0,width:t.measureText(e.text).width,top:0}];else{let c=d=>t.measureText(d).width,u=Of(e.text,c,{fontSize:s,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{}});i=u.lines.map((d,f)=>({text:d.text,x:n==="center"?u.blockWidth/2-d.width/2:n==="right"?u.blockWidth-d.width:0,width:d.width,top:f*u.lineHeight}))}for(let c of i)t.fillText(c.text,c.x,c.top);let l=e.style.textDecoration;if(l?.underline||l?.strikethrough){let c=Math.max(1,s*BI);for(let u of i)u.width<=0||(l.underline&&(t.beginPath(),t.rect(u.x,u.top+s*zI,u.width,c),t.fill()),l.strikethrough&&(t.beginPath(),t.rect(u.x,u.top+s*NI-c/2,u.width,c),t.fill()))}},lN=(e,t)=>{let n=e.points;if(n.length===0)return;let o=e.style.fill??e.style.stroke??"#000";if(t.setFill(o),t.setStroke(null),n.length===1){let a=L(n[0]);t.beginPath(),t.ellipse(a.x,a.y,a.width,a.width),t.fill();return}for(let a=0;a<n.length-1;a++){let r=L(n[a]),s=L(n[a+1]),i=s.x-r.x,l=s.y-r.y,c=Math.hypot(i,l)||1,u=-l/c,d=i/c;t.beginPath(),t.moveTo(r.x+u*r.width,r.y+d*r.width),t.lineTo(s.x+u*s.width,s.y+d*s.width),t.lineTo(s.x-u*s.width,s.y-d*s.width),t.lineTo(r.x-u*r.width,r.y-d*r.width),t.closePath(),t.fill(),t.beginPath(),t.ellipse(s.x,s.y,s.width,s.width),t.fill()}},cN=(e,t)=>{let n=e.animationKind?s0(e):e.metadata?.image??s0(e),o=e.metadata?.animated===!0||e.animationKind!==void 0;t.drawImage(n,0,0,e.width,e.height,o)},oc=()=>{Vn("rectangle",oN),Vn("ellipse",aN),Vn("polygon",rN),Vn("path",sN),Vn("text",iN),Vn("image",cN),Vn("group",()=>{}),Vn("frame",pN),lb("frame",()=>({top:24})),Vn("block-arrow",uN),Vn("brush",lN)},uN=(e,t)=>{let{fill:n,stroke:o}=Pf(e.style,t),a=e.direction??"right",r=Math.max(j2,Math.min(V2,e.headRatio??FI)),s=Math.max(j2,Math.min(V2,e.bodyThickness??HI)),i=e.width,l=e.height,c=i*r,u=i-c,d=l*s/2,f=l/2,p=[[0,f-d],[u,f-d],[u,0],[i,f],[u,l],[u,f+d],[0,f+d]];a!=="right"&&(p=p.map(([m,b])=>dN([m,b],a,i,l)));let h=p.map(([m,b])=>({x:m,y:b}));if(n&&(t.beginPath(),i0(t,h),t.fill()),o){let m=l0(e.style),b=m!==0?qd.offsetClosedPath(h,m):h;t.beginPath(),i0(t,b),t.stroke()}},dN=([e,t],n,o,a)=>{switch(n){case"left":return[o-e,t];case"up":return[t*(o/a),a-e*(a/o)];case"down":return[(a-t)*(o/a),e*(a/o)]}},oA="\u2026",fN=(e,t,n)=>{if(t<=0)return"";if(n.measureText(e).width<=t)return e;let o=0,a=e.length;for(;o<a;){let r=Math.ceil((o+a)/2);n.measureText(e.slice(0,r)+oA).width<=t?o=r:a=r-1}return o>0?e.slice(0,o)+oA:oA},pN=(e,t,n)=>{t.setFill(e.style.fill??GI),t.setStroke(null),t.setDashArray(null),t.beginPath(),t.rect(0,0,e.width,e.height),t.fill();let o=(n?.zoom??1)*(e.scale.x||1);t.setFill(null),t.setStroke(UI),t.setStrokeWidth(1/(o||1)),t.setDashArray(null),t.beginPath(),t.rect(0,0,e.width,e.height),t.stroke();let a=e.name??"Frame";t.setFont("system-ui, sans-serif",12);let r=e.width-16,s=t.measureText(a).width<=r,i=s?a:fN(a,r,t),l=s?Math.min(t.measureText(a).width+16,e.width):e.width;t.setFill(qI),t.beginPath(),t.rect(0,-24,l,24),t.fill(),t.setFill(WI),t.setTextBaseline("middle"),t.setTextAlign("left"),t.fillText(i,8,-24/2)};var Bf=async(e,t)=>{if(e instanceof ArrayBuffer)return e;if(e instanceof Uint8Array)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if(e instanceof Response)return e.arrayBuffer();let n=typeof e=="string"?e:e.href;if(n.startsWith("file:")){let{readFile:a}=await import("node:fs/promises"),{fileURLToPath:r}=await import("node:url"),s=r(n),i=await a(s);return i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}let o=await fetch(e);if(!o.ok)throw new Error(`${t}: fetch failed (${o.status})`);return o.arrayBuffer()},Pr=(e,t)=>{let n=t.byteLength,o=e.alloc(n);return new Uint8Array(e.memory.buffer,o,n).set(t),{ptr:o,len:n,free:()=>{e.free(o,n)}}};var cE=null,zf=e=>{cE=e},rA=()=>cE;var uE=null,Nf=e=>{uE=e},c0=()=>uE;var u0={flatten(e,t){let n=r=>Math.min(128,Math.max(8,Math.ceil(r/Math.max(.1,t)))),o=[],a={x:0,y:0};for(let r of e)switch(r.kind){case"M":a=r.to,o.push(a);break;case"L":a=r.to,o.push(a);break;case"Q":{let s=Math.hypot(r.to.x-a.x,r.to.y-a.y),i=Fn.flattenQuadratic(a,r.control,r.to,n(s));for(let l=1;l<i.length;l++)o.push(L(i[l]));a=r.to;break}case"C":{let s=Math.hypot(r.to.x-a.x,r.to.y-a.y),i=Fn.flattenCubic(a,r.control1,r.control2,r.to,n(s));for(let l=1;l<i.length;l++)o.push(L(i[l]));a=r.to;break}case"Z":if(o.length>0){let s=L(o[0]);o.push(s),a=s}break}return o},strokeToFill(e,t,n){if(e.length<2)return e;let o=t/2,a=n?.cap??"butt";n?.join;let r=[],s=[];for(let i=0;i<e.length;i++){let l=L(e[Math.max(0,i-1)]),c=L(e[Math.min(e.length-1,i+1)]),u=L(e[i]),d=c.x-l.x,f=c.y-l.y,p=Math.hypot(d,f)||1,h=-f/p,m=d/p;r.push({x:u.x+h*o,y:u.y+m*o}),s.push({x:u.x-h*o,y:u.y-m*o})}return[...r,...s.reverse(),L(r[0])]}};var ei=e=>e.type==="rectangle"||e.type==="ellipse"||e.type==="image"||e.type==="template"||e.type==="frame",hN=new Set(["rectangle","ellipse","template","text","frame"]),ti=e=>hN.has(e.type),sA=e=>Hs;var ho=(e,t)=>{let n=uo(e),a=[...Am(e).keys()].filter(s=>!n.has(s)),r=a.map(s=>{let i={kind:"named",name:s},l=Gt(e,i);if(t===0)return l;let c=Eo(e,i);return{x:l.x+c.x*t,y:l.y+c.y*t}});return{names:a,worldPoints:r}};var pE=(e,t)=>{let n=t.scene.viewport.zoom,o=t.hitAnnotation(e);if(o!==null){let l=t.scene.annotations.get(o);if(l)return{kind:"annotation",id:o,origin:Tr(t.scene,l)}}let a=t.selection.size+t.selectedLinkCount>1||t.selectionIsAspectLocked();if(a){let l=t.combinedSelectionBounds();if(l){let u=t.selectionIsAspectLocked()?Us:Hs,d=o2(e,l,n,t.handleHitSlop,u);if(d)return{kind:"group-handle",handle:d,bounds:l}}}if(t.selection.size===1)for(let l of t.selection){let c=M(t.scene,l);if(!c||!ti(c)||c.locked===!0)continue;let u=qs(c),d=KT(e,u,n,t.handleHitSlop,sA(c));if(d)return{kind:"handle",elementId:l,handle:d,bounds:u.bounds}}let r=a?t.combinedSelectionBounds():null;if(r){let l=Gm(r,n);if(a2(e,l,n,t.handleHitSlop))return{kind:"rotate-handle",pivot:{x:r.x+r.width/2,y:r.y+r.height/2},bounds:r}}else if(t.selection.size===1)for(let l of t.selection){let c=M(t.scene,l);if(!c||!ti(c)||c.locked===!0)continue;let u=Um(c,n);if(a2(e,u,n,t.handleHitSlop)){let d=qs(c);return{kind:"rotate-handle",pivot:XT(d),bounds:d.bounds}}}if(t.selectedLink){let l=be(t.scene,t.selectedLink);if(l){let c=rt(t.scene,l);if(c&&c.length>=2){let u=t.edgeHandleHitSlop/n,d=L(c[0]),f=L(c[c.length-1]);if(Ae.distance(e,d)<=u)return{kind:"edge-endpoint",linkId:l.id,side:"from"};if(Ae.distance(e,f)<=u)return{kind:"edge-endpoint",linkId:l.id,side:"to"}}}}let s=t.acceleratedElementAt(e);if(s&&t.isElementInteractable(s)){let l=t.promoteToGroupRoot(s);return{kind:"element",id:l.id,bounds:z(l)}}let i=ib(t.scene,e,t.edgeHitThreshold/n);return i&&!t.isLayerLocked(i.layerId)?{kind:"link",id:i.id}:{kind:"empty"}},Ff=(e,t,n,o,a,r)=>{e.setStroke(null),e.setFill(r),e.setOpacity(Nl),e.beginPath(),e.rect(t,n,o,a),e.fill(),e.setFill(null),e.setStroke(r),e.setStrokeWidth(1),e.setOpacity(mf),e.beginPath(),e.rect(t,n,o,a),e.stroke()},ni=(e,t,n,o,a)=>{e.setStroke(null),e.setFill(a),e.setOpacity(Nl),e.beginPath(),e.ellipse(t,n,o,o),e.fill(),e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setOpacity(mf),e.beginPath(),e.ellipse(t,n,o,o),e.stroke()},mN=(e,t,n,o,a)=>{e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setDashArray([2,2]),e.setOpacity(mf),e.beginPath(),e.ellipse(t,n,o,o),e.stroke(),e.setDashArray(null)},dE=(e,t,n)=>{if(t.length<3)return;e.setStroke(null),e.setFill(n),e.setOpacity(Nl),e.beginPath();let o=L(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=L(t[a]);e.lineTo(r.x,r.y)}e.closePath(),e.fill(),e.setFill(null),e.setStroke(n),e.setStrokeWidth(1),e.setOpacity(mf),e.beginPath(),e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=L(t[a]);e.lineTo(r.x,r.y)}e.closePath(),e.stroke()},fE=(e,t,n,o,a,r)=>{let s=B.applyToPoint(t,{x:n.x,y:n.y}),i=B.applyToPoint(t,{x:n.x+n.width,y:n.y+n.height}),l=Math.min(s.x,i.x),c=Math.min(s.y,i.y),u=Math.abs(i.x-s.x),d=Math.abs(i.y-s.y),f=11;for(let p of a)switch(p){case"nw":case"ne":case"se":case"sw":{let h=B.applyToPoint(t,Gs(p,n,o));Ff(e,h.x-f,h.y-f,f*2,f*2,r);break}case"n":Ff(e,l-f,c-f,u+f*2,f*2,r);break;case"s":Ff(e,l-f,c+d-f,u+f*2,f*2,r);break;case"w":Ff(e,l-f,c-f,f*2,d+f*2,r);break;case"e":Ff(e,l+u-f,c-f,f*2,d+f*2,r);break}},d0=e=>{let t={resizeHandles:!1,linkBodies:!1,selectedEdgeHandles:!1,anchorDots:!1,attachDropZones:!1,containerDropZones:!1,groupHandles:!1,annotationPins:!1};return e.linkDragActive?{...t,attachDropZones:!0}:e.elementDragActive?{...t,containerDropZones:!0}:{...t,resizeHandles:!0,linkBodies:!0,selectedEdgeHandles:!0,anchorDots:!0,groupHandles:!0,annotationPins:!0}},hE=(e,t)=>{let{scene:n,w2s:o,zoom:a,selection:r,visibility:s,edgeSelection:i,attach:l,containers:c}=t,{groupBounds:u,groupAspectLocked:d}=t;if(e.save(),s.resizeHandles&&r.size===1){let f=L([...r][0]),p=M(n,f);p&&ti(p)&&p.locked!==!0&&fE(e,o,z(p),a,sA(p),Ub)}if(s.linkBodies)for(let f of n.links.values()){let p=rt(n,f);if(!p||p.length<2)continue;e.setFill(null),e.setStroke(ZC),e.setStrokeWidth(Dm*2),e.setOpacity(Nl),e.setLineCap("round"),e.setLineJoin("round"),e.beginPath();let h=B.applyToPoint(o,L(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let b=B.applyToPoint(o,L(p[m]));e.lineTo(b.x,b.y)}e.stroke()}if(s.selectedEdgeHandles&&i){let f=B.applyToPoint(o,i.from),p=B.applyToPoint(o,i.to);ni(e,f.x,f.y,Oo,yf),ni(e,p.x,p.y,Oo,yf);for(let h of i.waypoints??[]){let m=B.applyToPoint(o,h);ni(e,m.x,m.y,Oo,yf)}for(let h of i.midpoints??[]){let m=B.applyToPoint(o,h);ni(e,m.x,m.y,Oo,yf)}}if(s.anchorDots&&r.size===1){let f=L([...r][0]),p=M(n,f);if(p){let h=Ro+Pm,{worldPoints:m}=ho(p,fo/a);for(let b of m){let y=B.applyToPoint(o,b);ni(e,y.x,y.y,h,Gb),mN(e,y.x,y.y,Bm,Gb)}}}if(s.attachDropZones&&l){let f=l.thresholdWorld*a;for(let p of l.outlineLoops)dE(e,p.map(h=>B.applyToPoint(o,h)),KC);e.setFill(null),e.setStroke(YC),e.setStrokeWidth(f*2),e.setOpacity(Nl),e.setLineCap("round"),e.setLineJoin("round");for(let p of l.outlineLoops){if(p.length<2)continue;e.beginPath();let h=B.applyToPoint(o,L(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let b=B.applyToPoint(o,L(p[m]));e.lineTo(b.x,b.y)}e.closePath(),e.stroke()}for(let p of l.anchors){let h=B.applyToPoint(o,p);ni(e,h.x,h.y,f,XC)}}if(s.containerDropZones&&c){let f=(p,h)=>{let m=[{x:p.x,y:p.y},{x:p.x+p.width,y:p.y},{x:p.x+p.width,y:p.y+p.height},{x:p.x,y:p.y+p.height}].map(b=>B.applyToPoint(o,b));dE(e,m,h)};for(let p of c.frames)f(p,$C);for(let p of c.containers)f(p,QC)}if(s.groupHandles&&u&&fE(e,o,u,a,d?Us:Hs,Ub),s.annotationPins)for(let f of n.annotations.values()){let p=B.applyToPoint(o,Tr(n,f));ni(e,p.x,p.y,Nm,JC)}e.setOpacity(1),e.restore()};var xE=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=Oe(o)?xE(e,o.id):z(o);a&&(n=n?X.union(n,a):a)}return n},bE={selectionStroke:"#1a73e8",selectionStrokeWidth:1,handleFill:"#fff",handleStroke:"#1a73e8",drawingStroke:"#1a73e8",drawingDash:[4,4]},AE=.32,vE=(e,t,n,o,a=bE)=>{if(n.length===0)return;let s=zb/(o||1);e.setTransform(t),e.setStroke(a.selectionStroke),e.setOpacity(AE),e.setDashArray(null),e.setLineJoin("miter"),e.setLineCap("butt");for(let{loops:i,outsetWorld:l}of n){e.setStrokeWidth(2*(l+s));for(let c of i){if(c.length<2)continue;e.beginPath();let u=!1;for(let d of c)u?e.lineTo(d.x,d.y):(e.moveTo(d.x,d.y),u=!0);e.closePath(),e.stroke()}}e.setOpacity(1),e.setTransform(B.IDENTITY)},LE=(e,t,n,o={})=>{let a={...bE,...o.style};n.clear();let r=qn(e.viewport),s=e.viewport.zoom;n.save(),n.setTransform(B.IDENTITY),o.debugHitZones&&hE(n,{scene:e,w2s:r,zoom:s,selection:t,visibility:o.debugHitZoneVisibility??d0({linkDragActive:!1,elementDragActive:!1}),...o.edgeSelection?{edgeSelection:o.edgeSelection}:{},...o.debugAttachZones?{attach:o.debugAttachZones}:{},...o.debugContainerZones?{containers:o.debugContainerZones}:{},...o.groupBounds?{groupBounds:o.groupBounds}:{},...o.groupAspectLocked!==void 0?{groupAspectLocked:o.groupAspectLocked}:{}});let i=t.size>1;for(let l of t){let c=e.elements.get(l);if(!c)continue;if(Oe(c)){let d=xE(e,l);if(!d)continue;let f=Fo(d,r);if(iA(n,f,a),c.locked===!0){yE(n,f);continue}if(i||!ti(c))continue;for(let p of Us){let h=Gs(p,d,s);lA(n,B.applyToPoint(r,h),a)}gE(n,d,s,r,a);continue}let u=qs(c);if(u.rotation===0?iA(n,Fo(u.bounds,r),a):xN(n,u,r,a),c.locked===!0){yE(n,bN(u,r));continue}if(!(i||!ti(c))){for(let d of Us){let f=YT(d,u,s);lA(n,B.applyToPoint(r,f),a)}SE(n,B.applyToPoint(r,Um(c,s)),a)}}if(o.drawingPreview){let l=Fo(o.drawingPreview,r);AN(n,l,a)}if(o.drawingPreviewElement){let l=o.drawingPreviewElement,c=Kl(l.type);c&&(n.save(),n.setTransform(r),n.setOpacity(uT),n.setDashArray(null),n.translate(l.position.x,l.position.y),l.rotation!==0&&n.rotate(l.rotation),(l.scale.x!==1||l.scale.y!==1)&&n.scale(l.scale.x,l.scale.y),c(l,n),n.restore())}if(o.edgePreview){let l=o.edgePreview.points;if(l&&l.length>=2)LN(n,l.map(c=>B.applyToPoint(r,c)),a);else{let c=B.applyToPoint(r,o.edgePreview.from),u=B.applyToPoint(r,o.edgePreview.to);vN(n,c,u,a)}}if(o.ghostElement||o.ghostElementShape){n.setOpacity(zm);let l=o.ghostElementShape,c=l?Kl(l.type):void 0;if(l&&c)n.save(),n.setTransform(r),n.setDashArray(null),n.translate(l.position.x,l.position.y),l.rotation!==0&&n.rotate(l.rotation),(l.scale.x!==1||l.scale.y!==1)&&n.scale(l.scale.x,l.scale.y),c(l,n),n.restore();else if(o.ghostElement){let u=Fo(o.ghostElement,r);n.setStroke(a.selectionStroke),n.setStrokeWidth(1.5),n.setDashArray(null),n.setFill(null),n.beginPath(),n.rect(u.x,u.y,u.width,u.height),n.stroke()}n.setOpacity(1)}if(o.linkAttachHighlight){let l=Fo(o.linkAttachHighlight,r),c=2;n.setStroke(a.selectionStroke),n.setStrokeWidth(2),n.setDashArray(null),n.setFill(null),n.beginPath(),n.rect(l.x-c,l.y-c,l.width+c*2,l.height+c*2),n.stroke()}if(o.ports){let l=Array.isArray(o.ports)?o.ports:[o.ports];for(let c of l)for(let u=0;u<c.worldPoints.length;u++){let d=B.applyToPoint(r,L(c.worldPoints[u])),f=c.activeIndex===u;SN(n,d,a,f,c.role,f?c.activeRadius:void 0)}}if(o.selectedLinkPaths&&o.selectedLinkPaths.length>0){n.setTransform(r),n.setStroke(a.selectionStroke),n.setOpacity(AE),n.setDashArray(null),n.setLineJoin("round"),n.setLineCap("round");let l=zb/(s||1);for(let{path:c,width:u}of o.selectedLinkPaths)c.length<2||(n.setStrokeWidth(u+2*l),n.beginPath(),r0(n,c,nc),n.stroke());n.setOpacity(1),n.setLineJoin("miter"),n.setLineCap("butt"),n.setTransform(B.IDENTITY)}if(o.edgeSelection){let l=B.applyToPoint(r,o.edgeSelection.from),c=B.applyToPoint(r,o.edgeSelection.to);for(let u of o.edgeSelection.midpoints??[])kN(n,B.applyToPoint(r,u),a);cA(n,l,a),cA(n,c,a);for(let u of o.edgeSelection.waypoints??[])cA(n,B.applyToPoint(r,u),a)}if(o.peerSelections)for(let l of o.peerSelections)for(let c of l.bounds){let u=Fo(c,r);wN(n,u,l.color)}if(o.brushPreview&&o.brushPreview.points.length>0){let l=o.brushPreview;n.save(),n.setTransform(r),n.setFill(l.fill),n.setStroke(null);let c=l.points,u=l.origin.x,d=l.origin.y;if(c.length===1){let f=L(c[0]);n.beginPath(),n.ellipse(u+f.x,d+f.y,f.width,f.width),n.fill()}else for(let f=0;f<c.length-1;f++){let p=L(c[f]),h=L(c[f+1]),m=u+p.x,b=d+p.y,y=u+h.x,g=d+h.y,x=y-m,A=g-b,C=Math.hypot(x,A)||1,_=-A/C,v=x/C;n.beginPath(),n.moveTo(m+_*p.width,b+v*p.width),n.lineTo(y+_*h.width,g+v*h.width),n.lineTo(y-_*h.width,g-v*h.width),n.lineTo(m-_*p.width,b-v*p.width),n.closePath(),n.fill(),n.beginPath(),n.ellipse(y,g,h.width,h.width),n.fill()}n.restore()}if(o.containerDropZone){let l=Fo(o.containerDropZone,r);n.setFill("rgba(26, 115, 232, 0.10)"),n.setStroke("#1a73e8"),n.setStrokeWidth(2),n.setDashArray([6,3]),n.beginPath(),n.rect(l.x,l.y,l.width,l.height),n.fill(),n.stroke(),n.setDashArray(null)}if(o.groupBounds){let l=Fo(o.groupBounds,r);iA(n,l,a);let c=Us;for(let u of c){let d=Gs(u,o.groupBounds,s),f=B.applyToPoint(r,d);lA(n,f,a)}gE(n,o.groupBounds,s,r,a)}if(o.annotations&&o.annotations.length>0)for(let l of o.annotations){let c=Tr(e,l),u=B.applyToPoint(r,c);CN(n,u,l,o.selectedAnnotation??null)}if(o.peerCursors)for(let l of o.peerCursors){let c=B.applyToPoint(r,l.position);_N(n,c,l.color,l.name)}if(o.gifBadges)for(let l of o.gifBadges)gN(n,Fo(l,r));if(o.editingText){let l=o.editingText;if(l.selectionRects.length>0){n.setFill(BT),n.setOpacity(zT);for(let c of l.selectionRects){let u=Fo(c,r);n.beginPath(),n.rect(u.x,u.y,u.width,u.height),n.fill()}n.setOpacity(1)}if(l.caret){let c=B.applyToPoint(r,{x:l.caret.x,y:l.caret.y});n.setFill(l.caretColor),n.setOpacity(1),n.beginPath(),n.rect(c.x,c.y,NT,l.caret.height*s),n.fill()}}n.restore()},yE=(e,t)=>{let n=WT,o=t.x+t.width-n-2,a=t.y+2,r=jT;e.setStroke(r),e.setFill(null),e.setStrokeWidth(2),e.setDashArray(null),e.setOpacity(1),e.beginPath(),e.ellipse(o+n/2,a+n*.46,n*.22,n*.26),e.stroke(),e.setStroke(null),e.setFill(r),e.beginPath(),e.rect(o+n*.2,a+n*.44,n*.6,n*.48),e.fill(),e.setFill(VT),e.beginPath(),e.ellipse(o+n/2,a+n*.64,n*.07,n*.07),e.fill()},gN=(e,t)=>{let n=t.x+n2,o=t.y+n2,a=HT,r=UT,s=GT;e.setStroke(null),e.setFill(qT),e.beginPath(),e.moveTo(n+s,o),e.lineTo(n+a-s,o),e.quadraticCurveTo(n+a,o,n+a,o+s),e.lineTo(n+a,o+r-s),e.quadraticCurveTo(n+a,o+r,n+a-s,o+r),e.lineTo(n+s,o+r),e.quadraticCurveTo(n,o+r,n,o+r-s),e.lineTo(n,o+s),e.quadraticCurveTo(n,o,n+s,o),e.closePath(),e.fill(),e.setFill("#ffffff"),e.setFont("system-ui, sans-serif",10),e.setTextAlign("center"),e.setTextBaseline("middle"),e.fillText("gif",n+a/2,o+r/2)},Fo=(e,t)=>{let n=B.applyToPoint(t,{x:e.x,y:e.y}),o=B.applyToPoint(t,{x:e.x+e.width,y:e.y+e.height}),a=Math.min(n.x,o.x),r=Math.min(n.y,o.y);return{x:a,y:r,width:Math.abs(o.x-n.x),height:Math.abs(o.y-n.y)}},iA=(e,t,n)=>{e.setStroke(n.selectionStroke),e.setStrokeWidth(n.selectionStrokeWidth),e.setDashArray(null),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.stroke()},xN=(e,t,n,o)=>{let[a,r,s,i]=xf(t),l=B.applyToPoint(n,a),c=B.applyToPoint(n,r),u=B.applyToPoint(n,s),d=B.applyToPoint(n,i);e.setStroke(o.selectionStroke),e.setStrokeWidth(o.selectionStrokeWidth),e.setDashArray(null),e.beginPath(),e.moveTo(l.x,l.y),e.lineTo(c.x,c.y),e.lineTo(u.x,u.y),e.lineTo(d.x,d.y),e.closePath(),e.stroke()},bN=(e,t)=>{let n=xf(e).map(i=>B.applyToPoint(t,i)),o=1/0,a=1/0,r=-1/0,s=-1/0;for(let i of n)i.x<o&&(o=i.x),i.y<a&&(a=i.y),i.x>r&&(r=i.x),i.y>s&&(s=i.y);return{x:o,y:a,width:r-o,height:s-a}},lA=(e,t,n)=>{e.setFill(n.handleFill),e.setStroke(n.handleStroke),e.setStrokeWidth(1),e.setDashArray(null),e.beginPath(),e.ellipse(t.x,t.y,5,5),e.fill(),e.stroke()},SE=(e,t,n)=>{let o=7/9,a=(u,d)=>({x:t.x+(u-12)*o,y:t.y+(d-12)*o});e.setStroke(n.handleStroke),e.setFill(null),e.setStrokeWidth(2*o),e.setLineCap("round"),e.setLineJoin("round"),e.setDashArray(null);let r=336,s=30;e.beginPath();for(let u=0;u<=s;u++){let d=r*u/s*(Math.PI/180),f=a(12+9*Math.cos(d),12+9*Math.sin(d));u===0?e.moveTo(f.x,f.y):e.lineTo(f.x,f.y)}e.stroke();let i=a(21,3),l=a(21,8),c=a(16,8);e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.stroke(),e.setLineCap("butt"),e.setLineJoin("miter")},gE=(e,t,n,o,a)=>{let r=Gm(t,n);SE(e,B.applyToPoint(o,r),a)},AN=(e,t,n)=>{e.setStroke(n.drawingStroke),e.setStrokeWidth(1),e.setDashArray(n.drawingDash),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.stroke()},vN=(e,t,n,o)=>{e.setStroke(o.drawingStroke),e.setStrokeWidth(1.5),e.setDashArray(o.drawingDash),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(n.x,n.y),e.stroke()},LN=(e,t,n)=>{e.setStroke(n.drawingStroke),e.setStrokeWidth(1.5),e.setDashArray(n.drawingDash),e.beginPath();let o=L(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=L(t[a]);e.lineTo(r.x,r.y)}e.stroke()},SN=(e,t,n,o,a="link-start",r)=>{let s=o?r??Ro:hf,i=a==="link-start",l=o?i?Nb:Fb:i?GC:qC,c=i?Nb:Fb;e.setStroke(c),e.setStrokeWidth(UC),e.setDashArray(null),e.setFill(l),e.beginPath(),e.ellipse(t.x,t.y,s,s),e.fill(),e.stroke()},cA=(e,t,n)=>{let o=PC;e.setStroke(n.selectionStroke),e.setStrokeWidth(2),e.setDashArray(null),e.setFill(n.handleFill),e.beginPath(),e.ellipse(t.x,t.y,o,o),e.fill(),e.stroke()},kN=(e,t,n)=>{let o=BC;e.setOpacity(.55),e.setStroke(n.selectionStroke),e.setStrokeWidth(1.5),e.setDashArray(null),e.setFill(n.handleFill),e.beginPath(),e.ellipse(t.x,t.y,o,o),e.fill(),e.stroke(),e.setOpacity(1)},wN=(e,t,n)=>{let o=oT;e.setStroke(n),e.setStrokeWidth(tT),e.setDashArray(nT),e.beginPath(),e.rect(t.x-o,t.y-o,t.width+2*o,t.height+2*o),e.stroke()},_N=(e,t,n,o)=>{let a=eT;e.setFill(n),e.setStroke("#fff"),e.setStrokeWidth(1),e.setDashArray(null),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(t.x+a*.7,t.y+a*.25),e.lineTo(t.x+a*.35,t.y+a*.4),e.lineTo(t.x+a*.5,t.y+a*.95),e.lineTo(t.x+a*.35,t.y+a*1.05),e.lineTo(t.x+a*.2,t.y+a*.5),e.lineTo(t.x,t.y+a*.65),e.closePath(),e.fill(),e.stroke(),e.setFont("sans-serif",Vb),e.setTextBaseline("top"),e.setTextAlign("left");let r=e.measureText(o).width,s=t.x+qb,i=t.y+qb,l=r+2*Wb,c=Vb+2*jb;e.setFill(n),e.setStrokeWidth(0),e.beginPath(),e.rect(s,i,l,c),e.fill(),e.setFill("#fff"),e.fillText(o,s+Wb,i+jb)},CN=(e,t,n,o)=>{let a=yT,r=n.resolved?bT:gT,s=n.id===o;if(e.setFill(r),e.setStroke(s?"#1a73e8":xT),e.setStrokeWidth(s?2:1.5),e.setDashArray(null),e.beginPath(),e.ellipse(t.x,t.y,a,a),e.fill(),e.stroke(),n.thread.length>0){let i=n.thread.length,l=i>9?"9+":String(i);e.setFont("sans-serif",AT),e.setTextAlign("center"),e.setTextBaseline("middle"),e.setFill("#fff"),e.fillText(l,t.x,t.y)}};var ac=(e,t)=>{let n=t.getBoundingClientRect();return{kind:IN(e.pointerType),phase:EN(e.type),point:{x:e.clientX-n.left,y:e.clientY-n.top},buttons:e.buttons,modifiers:TN(e),pointerId:e.pointerId,timestamp:e.timeStamp}};var Ia=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable},TN=e=>({shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey}),IN=e=>e==="pen"?"pen":e==="touch"?"touch":"mouse",EN=e=>{switch(e){case"pointerdown":return"down";case"pointermove":return"move";case"pointerup":return"up";case"pointercancel":return"cancel";case"pointerenter":return"enter";case"pointerleave":return"leave";default:return"move"}};var uA=()=>typeof navigator<"u"?navigator.userAgent:"",Hf=()=>typeof navigator<"u"&&navigator.platform||"",Br=/Mac|iPod|iPhone|iPad/.test(Hf()),MN=Hf().startsWith("Win"),kE=/\b(android)\b/i.test(uA()),ON=/iPad|iPhone/i.test(Hf())||typeof navigator<"u"&&/Mac/i.test(Hf())&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1,RN=/Linux/i.test(Hf())&&!kE,DN=/Firefox/i.test(uA()),PN=/^((?!chrome|android).)*safari/i.test(uA());var BN={Enter:"\u23CE",Backspace:"\u232B",Delete:"\u2326",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"\u21E5"," ":"Space"},zN={Enter:"Enter",Backspace:"Backspace",Delete:"Del",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"Tab"," ":"Space"},f0=e=>{let t=[];Br?(e.ctrl&&t.push("\u2303"),e.alt&&t.push("\u2325"),e.shift&&t.push("\u21E7"),e.meta&&t.push("\u2318")):(e.meta&&t.push("Ctrl"),e.ctrl&&t.push("Ctrl"),e.alt&&t.push("Alt"),e.shift&&t.push("Shift"));let n=Br?BN:zN,o=e.key??e.code??"",a=n[o]??(o.length===1?o.toUpperCase():o);return t.push(a),t},Bt=e=>{let t=f0(e);return Br?t.join(""):t.join("+")};var wE={id:"undo",label:"Undo",category:"history",hotkey:{key:"z",meta:!0},iconId:"undo",predicate:({editor:e})=>e.canUndo,perform:({editor:e})=>e.undo()},_E={id:"redo",label:"Redo",category:"history",hotkey:[{key:"z",meta:!0,shift:!0},{key:"y",meta:!0}],iconId:"redo",predicate:({editor:e})=>e.canRedo,perform:({editor:e})=>e.redo()},dA=[wE,_E];var ft=e=>e.editor.selection.size>0,fA=e=>e.editor.selection.size>0||e.editor.selectedLinks.size>0;var CE={id:"select-all",label:"Select all",category:"selection",hotkey:{key:"a",meta:!0},perform:({editor:e})=>{e.selectAll()}},TE={id:"delete-selection",label:"Delete",category:"selection",hotkey:[{key:"Delete"},{key:"Backspace"}],predicate:fA,perform:({editor:e})=>{e.deleteSelected()}},IE={id:"duplicate-selection",label:"Duplicate",category:"selection",hotkey:{key:"d",meta:!0},predicate:ft,perform:({editor:e})=>{e.duplicateSelected()}},NN={id:"toggle-lock",label:"Lock / Unlock",category:"selection",hotkey:{key:"l",meta:!0,shift:!0},predicate:ft,perform:({editor:e})=>{e.toggleLockSelection()}},FN={id:"enter-container",label:"Enter container",category:"selection",hotkey:{key:"ArrowDown",meta:!0,shift:!0},predicate:({editor:e})=>e.selection.size===1,perform:({editor:e})=>{e.enterContainer()}},HN={id:"exit-container",label:"Exit container",category:"selection",hotkey:{key:"ArrowUp",meta:!0,shift:!0},predicate:ft,perform:({editor:e})=>{e.exitContainer()}},pA=[CE,TE,IE,NN,FN,HN];var EE={id:"copy",label:"Copy",category:"clipboard",hotkey:{key:"c",meta:!0},predicate:ft,perform:({editor:e})=>{e.copySelected()}},ME={id:"cut",label:"Cut",category:"clipboard",hotkey:{key:"x",meta:!0},predicate:ft,perform:({editor:e})=>{e.cutSelected()}},OE={id:"paste",label:"Paste",category:"clipboard",hotkey:{key:"v",meta:!0},perform:({editor:e})=>{e.paste()}},UN={id:"copy-style",label:"Copy style",category:"clipboard",hotkey:{key:"c",meta:!0,alt:!0},predicate:ft,perform:({editor:e})=>{e.copySelectionStyle()}},GN={id:"paste-style",label:"Paste style",category:"clipboard",hotkey:{key:"v",meta:!0,alt:!0},predicate:({editor:e})=>e.selection.size>0&&e.hasStyleClipboard,perform:({editor:e})=>{e.pasteSelectionStyle()}},hA=[EE,ME,OE,UN,GN];var RE={id:"bring-to-front",label:"Bring to front",category:"z-order",hotkey:{key:"]",meta:!0,shift:!0},predicate:ft,perform:({editor:e})=>{e.bringToFront()}},DE={id:"send-to-back",label:"Send to back",category:"z-order",hotkey:{key:"[",meta:!0,shift:!0},predicate:ft,perform:({editor:e})=>{e.sendToBack()}},qN={id:"bring-forward",label:"Bring forward",category:"z-order",hotkey:{key:"]",meta:!0},predicate:ft,perform:({editor:e})=>{e.bringForward()}},WN={id:"send-backward",label:"Send backward",category:"z-order",hotkey:{key:"[",meta:!0},predicate:ft,perform:({editor:e})=>{e.sendBackward()}},mA=[RE,qN,WN,DE];var PE={id:"group-selection",label:"Group",category:"grouping",hotkey:{key:"g",meta:!0},predicate:e=>e.editor.selection.size>=2,perform:({editor:e})=>{e.groupSelected()}},BE={id:"ungroup-selection",label:"Ungroup",category:"grouping",hotkey:{key:"g",meta:!0,shift:!0},predicate:e=>{for(let t of e.editor.selection)if(e.editor.scene.elements.get(t)?.type==="group")return!0;return!1},perform:({editor:e})=>{e.ungroup()}},yA=[PE,BE];var zE={id:"zoom-in",label:"Zoom in",category:"zoom",hotkey:[{key:"=",meta:!0},{key:"+",meta:!0},{key:"+"},{key:"="}],perform:({editor:e})=>{e.zoomIn()}},NE={id:"zoom-out",label:"Zoom out",category:"zoom",hotkey:[{key:"-",meta:!0},{key:"_",meta:!0},{key:"-"},{key:"_"}],perform:({editor:e})=>{e.zoomOut()}},FE={id:"zoom-reset",label:"Reset zoom",category:"zoom",hotkey:{key:"0",meta:!0},perform:({editor:e})=>{e.resetZoom()}},HE={id:"zoom-to-fit",label:"Fit to screen",category:"zoom",hotkey:[{key:"1",alt:!0},{key:"1",meta:!0}],perform:({editor:e})=>{e.zoomToFit()}},jN={id:"zoom-to-selection",label:"Zoom to selection",category:"zoom",hotkey:{key:"2",alt:!0},predicate:ft,perform:({editor:e})=>{e.zoomToSelection()}},gA=[zE,NE,FE,HE,jN];var UE={id:"mode-select",label:"Select tool",category:"mode",hotkey:{key:"v"},iconId:"mode-select",uiKind:"toggle",checked:({editor:e})=>e.mode==="select",perform:({editor:e})=>{e.setMode("select")}},GE={id:"mode-hand",label:"Hand tool",category:"mode",hotkey:{key:"h"},iconId:"mode-hand",uiKind:"toggle",checked:({editor:e})=>e.mode==="hand",perform:({editor:e})=>{e.setMode("hand")}},qE={id:"mode-rect",label:"Rectangle tool",category:"mode",hotkey:{key:"r"},iconId:"mode-rect",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-rect",perform:({editor:e})=>{e.setMode("draw-rect")}},WE={id:"mode-ellipse",label:"Ellipse tool",category:"mode",hotkey:{key:"o"},iconId:"mode-ellipse",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-ellipse",perform:({editor:e})=>{e.setMode("draw-ellipse")}},jE={id:"mode-text",label:"Text tool",category:"mode",hotkey:{key:"t"},iconId:"mode-text",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-text",perform:({editor:e})=>{e.setMode("draw-text")}},VE={id:"mode-edge",label:"Link tool",category:"mode",hotkey:{key:"l"},iconId:"mode-edge",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-edge",perform:({editor:e})=>{e.setMode("draw-edge")}},ZE={id:"mode-brush",label:"Brush tool",category:"mode",hotkey:{key:"b"},iconId:"mode-brush",uiKind:"toggle",checked:({editor:e})=>e.mode==="brush",perform:({editor:e})=>{e.setMode("brush")}},XE={id:"mode-frame",label:"Frame tool",category:"mode",hotkey:{key:"f"},iconId:"mode-frame",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-frame",perform:({editor:e})=>{e.setMode("draw-frame")}},YE={id:"toggle-tool-lock",label:"Toggle tool lock",category:"mode",iconId:"tool-lock",uiKind:"toggle",checked:({editor:e})=>e.toolLocked,perform:({editor:e})=>{e.setToolLocked(!e.toolLocked)}},KE={id:"cancel",label:"Cancel / clear selection",category:"edit",hotkey:{key:"Escape"},perform:({editor:e})=>{e.cancelInteraction()}},xA=[UE,GE,qE,WE,jE,VE,ZE,XE,YE,KE];var VN={id:"nudge-selection",label:"Nudge selection",category:"selection",keyTest:e=>(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"||e.key==="ArrowDown")&&!e.metaKey&&!e.ctrlKey&&!e.altKey,perform:({editor:e,event:t})=>{if(!t)return;let n=t.shiftKey?DT:RT;switch(t.key){case"ArrowLeft":e.moveSelectionBy({x:-n,y:0});return;case"ArrowRight":e.moveSelectionBy({x:n,y:0});return;case"ArrowUp":e.moveSelectionBy({x:0,y:-n});return;case"ArrowDown":e.moveSelectionBy({x:0,y:n});return}}},ZN={id:"select-closest",label:"Select closest in direction",category:"selection",keyTest:e=>(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"||e.key==="ArrowDown"),perform:({editor:e,event:t})=>{if(t)switch(t.key){case"ArrowLeft":e.selectClosest("left");return;case"ArrowRight":e.selectClosest("right");return;case"ArrowUp":e.selectClosest("up");return;case"ArrowDown":e.selectClosest("down");return}}},XN={id:"focus-next",label:"Focus next element",category:"selection",hotkey:{key:"Tab"},perform:({editor:e})=>{e.focusCycle("next")}},YN={id:"focus-prev",label:"Focus previous element",category:"selection",hotkey:{key:"Tab",shift:!0},perform:({editor:e})=>{e.focusCycle("prev")}},KN={id:"edit-or-create",label:"Edit / create",category:"edit",keyTest:e=>e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey,predicate:({editor:e})=>{if(e.selection.size===1){let[t]=[...e.selection];if(t&&e.scene.elements.get(t)?.type==="text")return!0}return e.mode==="draw-rect"||e.mode==="draw-ellipse"},perform:({editor:e})=>{if(e.selection.size===1){let[t]=[...e.selection];if(t&&e.scene.elements.get(t)?.type==="text"){e.beginTextEdit(t);return}}(e.mode==="draw-rect"||e.mode==="draw-ellipse")&&e.createElementAtCursor()}},$E=[VN,ZN,XN,YN,KN];var $N={id:"arrange-grid",label:"Arrange as grid",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsGrid()}},QN={id:"arrange-stack-h",label:"Stack horizontally",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"horizontal"})}},JN={id:"arrange-stack-v",label:"Stack vertically",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"vertical"})}},eF={id:"auto-arrange",label:"Auto-arrange children",category:"layout",predicate:({editor:e})=>{if(e.selection.size!==1)return!1;let[t]=[...e.selection];if(!t)return!1;let n=e.scene.elements.get(t);return n?An(n)!==null:!1},perform:({editor:e})=>{let[t]=[...e.selection];t&&e.runLayout(t)}},tF={id:"compact-z-order",label:"Compact z-order",category:"z-order",perform:({editor:e})=>{e.compactLayerZOrder()}},QE=[$N,QN,JN,eF,tF];var nF={id:"toggle-grid",label:"Toggle grid",category:"other",hotkey:{key:"g"},uiKind:"toggle",checked:({editor:e})=>e.gridEnabled,perform:({editor:e})=>{e.toggleGrid()}},JE=[nF];var rc=e=>e.editor.selection.size>=2,e4=e=>e.editor.selection.size>=3,oF={id:"flip-horizontal",label:"Flip horizontal",category:"arrange",hotkey:{key:"h",shift:!0},iconId:"flip-horizontal",predicate:ft,perform:({editor:e})=>{e.flipSelection("horizontal")}},aF={id:"flip-vertical",label:"Flip vertical",category:"arrange",hotkey:{key:"v",shift:!0},iconId:"flip-vertical",predicate:ft,perform:({editor:e})=>{e.flipSelection("vertical")}},rF={id:"align-left",label:"Align left",category:"arrange",hotkey:{key:"ArrowLeft",alt:!0},iconId:"align-left",predicate:rc,perform:({editor:e})=>{e.alignSelection("left")}},sF={id:"align-h-center",label:"Align horizontal centres",category:"arrange",iconId:"align-h-center",predicate:rc,perform:({editor:e})=>{e.alignSelection("h-center")}},iF={id:"align-right",label:"Align right",category:"arrange",hotkey:{key:"ArrowRight",alt:!0},iconId:"align-right",predicate:rc,perform:({editor:e})=>{e.alignSelection("right")}},lF={id:"align-top",label:"Align top",category:"arrange",hotkey:{key:"ArrowUp",alt:!0},iconId:"align-top",predicate:rc,perform:({editor:e})=>{e.alignSelection("top")}},cF={id:"align-v-center",label:"Align vertical centres",category:"arrange",iconId:"align-v-center",predicate:rc,perform:({editor:e})=>{e.alignSelection("v-center")}},uF={id:"align-bottom",label:"Align bottom",category:"arrange",hotkey:{key:"ArrowDown",alt:!0},iconId:"align-bottom",predicate:rc,perform:({editor:e})=>{e.alignSelection("bottom")}},dF={id:"distribute-horizontal",label:"Distribute horizontally",category:"arrange",hotkey:{key:"h",alt:!0},iconId:"distribute-horizontal",predicate:e4,perform:({editor:e})=>{e.distributeSelection("horizontal")}},fF={id:"distribute-vertical",label:"Distribute vertically",category:"arrange",hotkey:{key:"v",alt:!0},iconId:"distribute-vertical",predicate:e4,perform:({editor:e})=>{e.distributeSelection("vertical")}},t4=[oF,aF,rF,sF,iF,lF,cF,uF,dF,fF];var n4=e=>{let{editor:t}=e;for(let n of t.selection){let o=M(t.scene,n);if(o!==void 0&&Fe(o))return!0}return!1},pF={id:"increase-font-size",label:"Increase font size",category:"edit",hotkey:{code:"Period",meta:!0,shift:!0},predicate:n4,perform:({editor:e})=>{e.adjustSelectionFontSize("increase")}},hF={id:"decrease-font-size",label:"Decrease font size",category:"edit",hotkey:{code:"Comma",meta:!0,shift:!0},predicate:n4,perform:({editor:e})=>{e.adjustSelectionFontSize("decrease")}},o4=[pF,hF];var Uf=class{entries=new Map;order=[];seqBuffer=[];register(t){if(this.entries.has(t.id))throw new Error(`Action already registered: ${t.id}`);this.entries.set(t.id,t),this.order.push(t.id)}replace(t){if(this.entries.has(t.id)){this.entries.set(t.id,t);return}this.register(t)}unregister(t){if(!this.entries.delete(t))return;let n=this.order.indexOf(t);n!==-1&&this.order.splice(n,1)}get(t){return this.entries.get(t)}getAll(){return this.order.map(t=>this.entries.get(t)).filter(t=>t!==void 0)}dispatch(t,n){let o=this.entries.get(t);return!o||o.predicate&&!o.predicate(n)?!1:(o.perform(n),!0)}dispatchHotkey(t,n){let o={...n,event:t};if(this.trySequence(t,o))return!0;for(let a of this.order){let r=this.entries.get(a);if(!r)continue;if(r.keyTest?.(t,o)){if(r.predicate&&!r.predicate(o))continue;return r.perform(o),!0}if(!r.hotkey)continue;let s=Array.isArray(r.hotkey)?r.hotkey:[r.hotkey];for(let i of s)if(mF(t,i)&&!(r.predicate&&!r.predicate(o)))return r.perform(o),!0}return!1}trySequence(t,n){if(!(t.key.length===1&&!t.metaKey&&!t.ctrlKey&&!t.altKey))return this.seqBuffer=[],!1;let a=t.timeStamp;this.seqBuffer=this.seqBuffer.filter(r=>a-r.t<=OT),this.seqBuffer.push({key:t.key,code:t.code,t:a});for(let r of this.order){let s=this.entries.get(r);if(!s?.sequence||s.sequence.length===0)continue;let i=s.sequence,l=this.seqBuffer.slice(-i.length);if(l.length===i.length&&l.every((c,u)=>a4(c.key,c.code,i[u]??""))&&!(s.predicate&&!s.predicate(n)))return this.seqBuffer=[],s.perform(n),!0}return!1}},mF=(e,t)=>{if(t.key!==void 0&&!yF(e,t.key)||t.code!==void 0&&e.code!==t.code)return!1;let n=a=>a===!0,o=Br?e.metaKey:e.ctrlKey;return!(n(t.meta)!==o||n(t.shift)!==e.shiftKey||n(t.alt)!==e.altKey||t.ctrl!==void 0&&n(t.ctrl)!==e.ctrlKey)},yF=(e,t)=>a4(e.key,e.code,t),a4=(e,t,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;if(gF(e))return!1;let o=xF(n);return o!==null&&t===o},gF=e=>/^[a-z]$/i.test(e),xF=e=>{if(e.length!==1)return null;let t=e.toLowerCase();if(t>="a"&&t<="z")return`Key${t.toUpperCase()}`;if(t>="0"&&t<="9")return`Digit${t}`;switch(t){case"[":return"BracketLeft";case"]":return"BracketRight";case",":return"Comma";case".":return"Period";case"/":return"Slash";case";":return"Semicolon";case"'":return"Quote";case"`":return"Backquote";case"-":return"Minus";case"=":return"Equal";case"\\":return"Backslash";default:return null}},bA=e=>{let t=[...dA,...pA,...hA,...mA,...yA,...gA,...xA,...$E,...QE,...JE,...t4,...o4];for(let n of t)e.register(n)},st=new Uf;bA(st);var p0=(e,t={})=>{let n=t.target??window,o=t.registry??st,a=r=>{if(!(r instanceof KeyboardEvent))return;let s=r.composedPath()[0]??r.target;if(Ia(s)){if(r.key!=="Escape")return;s instanceof HTMLElement&&s.blur()}o.dispatchHotkey(r,{editor:e})&&r.preventDefault()};return n.addEventListener("keydown",a),()=>{n.removeEventListener("keydown",a)}};var bF=new Map;var r4=e=>bF.get(e);var AA=()=>{let e=new Map;return{on:(s,i)=>{let l=e.get(s);return l||(l=new Set,e.set(s,l)),l.add(i),()=>{let c=e.get(s);c&&(c.delete(i),c.size===0&&e.delete(s))}},off:(s,i)=>{let l=e.get(s);l&&(l.delete(i),l.size===0&&e.delete(s))},emit:(s,...i)=>{let l=e.get(s);if(!l||l.size===0)return 0;let c=Array.from(l),u=null,d=0;for(let f of c)try{f(...i),d++}catch(p){u??=p instanceof Error?p:new Error(String(p))}if(u!==null)throw u;return d},clear:s=>{if(s===void 0){e.clear();return}e.delete(s)},listenerCount:s=>{let i=e.get(s);return i?i.size:0}}};var vA=()=>{let e=new Set;return{add:t=>(e.add(t),()=>e.delete(t)),emit:t=>{for(let n of[...e])n(t)},clear:()=>{e.clear()},size:()=>e.size}};var s4=e=>{let t=new Map,n=new Map,o=new Map,a=new Map,r=new Map,s=null,i=()=>s,l=[],c=-1,u=p=>{if(p.kind==="batch"){for(let h of p.patches)u(h);return}if(p.kind==="element"){let h=t.get(p.id);h?h.latest={...h.latest,after:p.after}:(t.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="link"){let h=n.get(p.id);h?h.latest={...h.latest,after:p.after}:(n.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="layer"){let h=o.get(p.id);h?h.latest={...h.latest,after:p.after}:(o.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="annotation"){let h=a.get(p.id);h?h.latest={...h.latest,after:p.after}:(a.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="file"){let h=r.get(p.id);h?h.latest={...h.latest,after:p.after}:(r.set(p.id,{first:p,latest:p}),l.push(p));return}s?s={first:s.first,latest:{...s.latest,after:p.after}}:(s={first:p,latest:p},c=l.length,l.push(p))};for(let p of e)u(p);let d=i(),f=[];for(let p=0;p<l.length;p++){let h=L(l[p]),m;if(h.kind==="element"){let b=L(t.get(h.id));m={kind:"element",id:b.first.id,before:b.first.before,after:b.latest.after}}else if(h.kind==="link"){let b=L(n.get(h.id));m={kind:"link",id:b.first.id,before:b.first.before,after:b.latest.after}}else if(h.kind==="layer"){let b=L(o.get(h.id));m={kind:"layer",id:b.first.id,before:b.first.before,after:b.latest.after}}else if(h.kind==="annotation"){let b=L(a.get(h.id));m={kind:"annotation",id:b.first.id,before:b.first.before,after:b.latest.after}}else if(h.kind==="file"){let b=L(r.get(h.id));m={kind:"file",id:b.first.id,before:b.first.before,after:b.latest.after}}else if(p===c&&d!==null)m={kind:"viewport",before:d.first.before,after:d.latest.after};else continue;AF(m)||f.push(m)}return f},AF=e=>e.kind==="element"||e.kind==="link"||e.kind==="layer"||e.kind==="annotation"||e.kind==="file"||e.kind==="viewport"?e.before===e.after:!1;var Gf=class{past=[];future=[];limit;mergeTransactions;constructor(t={}){this.limit=t.limit??1/0,this.mergeTransactions=t.mergeTransactions??!0}push(t){Cr(t)||(this.past.push(t),this.future.length=0,this.trim())}undo(){let t=this.past.pop();return t?(this.future.push(t),zl(t)):null}redo(){let t=this.future.pop();return t?(this.past.push(t),t):null}get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}get size(){return this.past.length}get redoSize(){return this.future.length}get undoStack(){return this.past}get redoStack(){return this.future}clear(){this.past.length=0,this.future.length=0}transaction(){if(this.current!==null)throw new Error("A transaction is already open");let t=[];return this.current=t,{add:n=>{if(this.current!==t)throw new Error("Transaction is no longer open");Cr(n)||t.push(n)},commit:()=>{if(this.current!==t||(this.current=null,t.length===0))return;let n=this.mergeTransactions?s4(t):t;if(n.length===0)return;let o=n[0],a=n.length===1&&o!==void 0?o:Mo(n);Cr(a)||(this.past.push(a),this.future.length=0,this.trim())},cancel:()=>{this.current===t&&(this.current=null)},isOpen:()=>this.current===t}}hasOpenTransaction(){return this.current!==null}record(t,n){if(n?.transaction?.isOpen()){n.transaction.add(t);return}this.push(t)}current=null;trim(){if(Number.isFinite(this.limit))for(;this.past.length>this.limit;)this.past.shift()}};var qf=class{entries=[];register(t){let n=this.entries.findIndex(o=>o.id===t.id);if(n!==-1){this.entries[n]=t;return}this.entries.push(t)}unregister(t){let n=this.entries.findIndex(o=>o.id===t);n!==-1&&this.entries.splice(n,1)}getAll(){return this.entries}async dispatch(t,n){for(let o of this.entries)if(o.accept(t))return await o.handle(t,n),!0;return!1}},i4=["image/png","image/jpeg","image/svg+xml","image/gif","image/webp","image/bmp","image/x-icon","image/avif","image/jfif"];var LA=e=>{if(e.type.startsWith("video/"))return!0;let t=e.name.toLowerCase().split(".").pop();return t==="mp4"||t==="webm"||t==="ogv"||t==="mov"},SA=e=>{if(e.type&&i4.includes(e.type))return!0;let t=e.name.toLowerCase().split(".").pop();return t?{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",jfif:"image/jfif",svg:"image/svg+xml",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif"}[t]!==void 0:!1};var kA=e=>new Promise((t,n)=>{let o=new FileReader;o.onload=()=>{let a=o.result;typeof a=="string"?t(a):n(new Error(`Unexpected FileReader result type for ${e.name}`))},o.onerror=()=>{n(o.error??new Error(`Failed to read ${e.name}`))},o.readAsDataURL(e)});var vF=e=>e===".git"||e==="node_modules"||e==="__MACOSX"||e===".DS_Store"||e.startsWith("."),wA=async function*(e,t={}){let n=t.skipDirectory??vF,o=t.maxDepth??32,a=e.items,r=a!==null&&a.length>0&&typeof a[0]?.webkitGetAsEntry=="function";if(a===null||!r){for(let s of Array.from(e.files))yield s;return}for(let s of Array.from(a)){if(s.kind!=="file")continue;let i=s.webkitGetAsEntry?.();i&&(yield*l4(i,"",0,n,o,t.onError))}};async function*l4(e,t,n,o,a,r){let s=t?`${t}/${e.name}`:e.name;if(e.isFile){try{yield await new Promise((c,u)=>{e.file?.(c,u)})}catch(l){r?.(s,l)}return}if(!e.isDirectory||o(e.name))return;if(n>=a){r?.(s,new Error(`Folder depth exceeds ${a}`));return}let i=e.createReader?.();if(i)for(;;){let l;try{l=await new Promise((c,u)=>{i.readEntries(c,u)})}catch(c){r?.(s,c);return}if(l.length===0)return;for(let c of l)yield*l4(c,s,n+1,o,a,r)}}var LF=e=>new Promise((t,n)=>{if(typeof Image>"u"){n(new Error("Image() is not available in this environment"));return}let o=new Image;o.onload=()=>{t({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=()=>{n(new Error("Failed to decode image data URL"))},o.src=e}),u4={id:"image",accept:e=>SA(e),handle:async(e,{editor:t,worldPoint:n})=>{let o=typeof URL<"u"&&typeof URL.createObjectURL=="function",a=await t.addBinaryFile(e,e.name),r=o?URL.createObjectURL(e):await kA(e),s=await LF(r),i=e2,l=Math.max(s.width,s.height)>i?i/Math.max(s.width,s.height):1,c=Math.round(s.width*l),u=Math.round(s.height*l),d={x:n.x-c/2,y:n.y-u/2},f=e.type==="image/gif"||/\.gif$/i.test(e.name),p=null;if(typeof Image<"u"){if(p=new Image,p.src=r,typeof document<"u"){let y=d4();p.style.position="fixed",p.style.left="0",p.style.top="0",p.style.width="1px",p.style.height="1px",p.style.opacity="0.01",p.style.zIndex="-1",p.style.pointerEvents="none",y.appendChild(p)}let b=p;b.complete||await new Promise(y=>{b.onload=()=>{y()},b.onerror=()=>{y()}})}let h=f?await e.arrayBuffer():void 0,m=p??void 0;if(p&&!f&&typeof createImageBitmap=="function")try{m=await createImageBitmap(p)}catch{}t.insertImage({src:r,fileId:a,width:c,height:u,position:d,...m?{image:m}:{},animated:f,...f?{animationKind:"gif"}:{},...h?{animationData:h}:{}})}},c4="oh-just-another-animated-image-sink",d4=()=>{let e=document.getElementById(c4);if(e)return e;let t=document.createElement("div");return t.id=c4,t.setAttribute("aria-hidden","true"),t.style.position="fixed",t.style.left="0",t.style.top="0",t.style.width="0",t.style.height="0",t.style.overflow="visible",t.style.pointerEvents="none",t.style.zIndex="-1",document.body.appendChild(t),t},f4={id:"video",accept:e=>LA(e),handle:async(e,{editor:t,worldPoint:n})=>{if(typeof document>"u")return;let o=URL.createObjectURL(e),a=document.createElement("video");a.src=o,a.muted=!0,a.loop=!0,a.playsInline=!0,a.autoplay=!0;let r=d4();a.style.position="absolute",a.style.left="-99999px",a.style.top="-99999px",a.style.width="1px",a.style.height="1px",r.appendChild(a),await new Promise(p=>{let h=()=>{p()};a.onloadedmetadata=h,a.onerror=h});let s=a.videoWidth||480,i=a.videoHeight||270,l=e2,c=Math.max(s,i)>l?l/Math.max(s,i):1,u=Math.round(s*c),d=Math.round(i*c),f={x:n.x-u/2,y:n.y-d/2};a.play().catch(()=>{}),t.insertImage({src:o,width:u,height:d,position:f,image:a,animated:!0})}};var h0=64,p4=(e,t)=>{let n=null,o=t,a=0;for(;o.parentId&&a<h0;){let r=M(e,o.parentId);if(!r)break;Oe(r)&&(n=r),o=r,a++}return n},_A=(e,t,n)=>{let o=M(e,t),a=0;for(;o&&a<h0;){if(o.id===n)return!0;if(!o.parentId)return!1;o=M(e,o.parentId),a++}return!1},h4=(e,t,n)=>{let o=t,a=0;for(;o.parentId&&a<h0&&n!==o.parentId;){let r=M(e,o.parentId);if(!r||!Oe(r))break;o=r,a++}return o},m4=(e,t,n)=>{let o=new Set,a=new Set(t);for(let r of e.elements.values())a.has(r.id)||_A(e,r.id,n)||o.add(r.id);return o},y4=(e,t,n,o)=>{if(!n)return null;if(o!==n.id)return n;let a=t,r=null,s=0;for(;a.parentId&&s<h0;){let i=M(e,a.parentId);if(!i||i.id===n.id)break;Oe(i)&&(r=i),a=i,s++}return r};var SF=/^Frame (\d+)$/,g4=e=>{let t=0;for(let n of e.elements.values()){if(!He(n))continue;let o=SF.exec(n.name??"");o&&(t=Math.max(t,Number(o[1])))}return`Frame ${t+1}`},x4=(e,t,n,o)=>{let a=o.x,r=o.y,s=o.x+o.width,i=o.y+o.height,l=e;for(let c of e.elements.values()){if(c.id===n||He(c)||c.frameId!==void 0)continue;let u=z(c),d=u.x+u.width/2,f=u.y+u.height/2;if(d<a||d>s||f<r||f>i)continue;let p=le(l,c.id,h=>({...h,frameId:n}));l=p.scene,t.push(p.patch)}return l},b4=(e,t)=>{let n=[...e.elements.values()].filter(He).sort((a,r)=>a.order<r.order?1:a.order>r.order?-1:0).map(a=>({id:a.id,b:z(a)})),o=e;for(let a of e.elements.values()){if(He(a))continue;let r=z(a),s=r.x+r.width/2,i=r.y+r.height/2,l;for(let u of n)if(s>=u.b.x&&s<=u.b.x+u.b.width&&i>=u.b.y&&i<=u.b.y+u.b.height){l=u.id;break}if(a.frameId===l)continue;let c=le(o,a.id,u=>{let d={...u};return l===void 0?delete d.frameId:d.frameId=l,d});o=c.scene,t.push(c.patch)}return o};var m0=class{pending=!1;getScene;compact;constructor(t){this.getScene=t.getScene,this.compact=t.compact}schedule(){this.pending||(this.pending=!0,queueMicrotask(()=>{this.pending=!1,this.runCheck()}))}runCheck(){let t=this.getScene(),n=new Set;for(let o of t.elements.values())o.order.length>Jb&&n.add(o.layerId);for(let o of t.links.values())o.order.length>Jb&&n.add(o.layerId);for(let o of n)this.compact(o)}};var y0=class{opts;pending=!1;signatures=new Map;constructor(t){this.opts=t}schedule(){this.pending||(this.pending=!0,queueMicrotask(()=>{this.pending=!1,this.runCheck()}))}resetSignature(t){this.signatures.set(t,this.signatureFor(t))}runCheck(){let t=this.opts.getScene(),n=!1;for(let o of t.elements.values()){if(!An(o))continue;let a=this.signatureFor(o.id);if(this.signatures.get(o.id)===a)continue;this.signatures.set(o.id,a);let r=df(this.opts.getScene(),o.id);if(!r)continue;this.opts.applyPatch(r);let s=this.opts.getScene();for(let i of s.elements.values())i.parentId===o.id&&this.opts.growContainer(o.id,i.id);n=!0}n&&this.opts.onMutated()}signatureFor(t){let n=this.opts.getScene(),o=M(n,t),a=[...n.elements.values()].filter(s=>s.parentId===t);if(o&&An(o)?.kind==="wrap"){let s=Un(o),i=s?`${Math.round(s.x)},${Math.round(s.y)}`:"0,0",l=s?Math.round(s.width):0,c=a.map(u=>{let d=z(u);return`${u.id}:${Math.round(d.width)}x${Math.round(d.height)}`}).sort();return`o${i}|w${l}|${c.join(",")}`}let r=a.map(s=>s.id);return r.sort(),r.join(",")}};var A4=()=>({mode:null,selection:null,scene:null,viewport:null,canUndo:!1,canRedo:!1}),v4=(e,t,n)=>{n.mode!==e.mode&&(e.mode=n.mode,t.emit("mode",n.mode)),n.selection!==e.selection&&(e.selection=n.selection,t.emit("selection",n.selection)),n.scene!==e.scene&&(e.scene=n.scene,t.emit("scene",n.scene)),n.scene.viewport!==e.viewport&&(e.viewport=n.scene.viewport,t.emit("viewport",n.scene)),(n.canUndo!==e.canUndo||n.canRedo!==e.canRedo)&&(e.canUndo=n.canUndo,e.canRedo=n.canRedo,t.emit("history",{canUndo:n.canUndo,canRedo:n.canRedo})),t.emit("change")},L4=(e,t)=>{e.mode=t.mode,e.selection=t.selection,e.scene=t.scene,e.viewport=t.scene.viewport,e.canUndo=t.canUndo,e.canRedo=t.canRedo};var g0=class{frameId=null;isAnimated;onTick;constructor(t){this.isAnimated=t.isAnimated,this.onTick=t.onTick}start(){if(this.frameId!==null||typeof requestAnimationFrame>"u")return;let t=()=>{if(!this.isAnimated()){this.frameId=null;return}this.onTick(),this.frameId=requestAnimationFrame(t)};this.frameId=requestAnimationFrame(t)}stop(){this.frameId!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.frameId),this.frameId=null)}get running(){return this.frameId!==null}};var x0=class{host;tick;costEma=0;lastTickMs=0;onVisibilityChange=()=>{typeof document>"u"||(document.hidden?this.tick.stop():this.maybe())};constructor(t){this.host=t,this.tick=new g0({isAnimated:()=>this.host.hasVisibleAnimatedElement(),onTick:()=>{this.onTick()}})}onTick(){let t=typeof performance<"u"?performance.now():Date.now(),n=Math.min(wT,Math.max(kT,this.costEma*_T));if(t-this.lastTickMs<n)return;this.lastTickMs=t,this.host.autoStopHeavyGifs(),this.host.forceAnimationRepaint();let o=(typeof performance<"u"?performance.now():Date.now())-t;this.costEma=this.costEma*.8+o*.2}attach(){typeof document<"u"&&document.addEventListener("visibilitychange",this.onVisibilityChange)}detach(){this.tick.stop(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onVisibilityChange)}maybe(){this.host.hasVisibleAnimatedElement()&&this.tick.start()}};var b0=class{onTick;_on=!0;timer=null;constructor(t){this.onTick=t}get on(){return this._on}start(){this._on=!0,this.stop(),!(typeof window>"u")&&(this.timer=setInterval(()=>{this._on=!this._on,this.onTick()},PT))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}wake(){this._on=!0}};var A0=class{ref;constructor(t){this.ref=t}record(t){this.ref.gestureTx??=this.ref.history.transaction(),this.ref.gestureTx.add(t)}commit(){this.ref.groupMoveOrigin=null,this.ref.groupLinkMoveOrigin=null,this.ref.groupResizeOrigin=null,this.ref.dragElementId=null,this.ref.containerHover!==null&&(this.ref.containerHover=null),this.ref.gestureTx&&(this.ref.gestureTx.commit(),this.ref.gestureTx=null),this.ref.notify()}cancel(){this.ref.groupMoveOrigin=null,this.ref.groupLinkMoveOrigin=null,this.ref.groupResizeOrigin=null,this.ref.gestureTx&&(this.ref.gestureTx.cancel(),this.ref.gestureTx=null)}finalize(){if(this.ref.gestureTx){try{this.ref.gestureTx.commit()}catch{this.ref.gestureTx.cancel()}this.ref.gestureTx=null}}maybeRevertModeAfterCreate(){this.ref.toolLocked||this.ref.mode==="select"||this.ref.mode==="hand"||this.ref.setMode("select")}};function Wf(){return typeof performance<"u"?performance.now():Date.now()}function kF(){if(typeof matchMedia!="function")return!1;try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var v0=class{state=new Map;hoveredId=null;ensure(t){if(this.state.has(t))return;let n=Wf();this.state.set(t,{playing:!kF(),originMs:n,playStartMs:n,frozenMs:0})}clock(t){let n=this.state.get(t),o=Wf();return n?n.playing?o-n.originMs:n.frozenMs:o}toggle(t){let n=Wf(),o=this.state.get(t);o?o.playing?(o.frozenMs=n-o.originMs,o.playing=!1):(o.originMs=n-o.frozenMs,o.playStartMs=n,o.playing=!0):this.state.set(t,{playing:!0,originMs:n,playStartMs:n,frozenMs:0})}hoverEnter(t){if(this.hoveredId===t||(this.hoveredId=t,t===null))return!1;let n=this.state.get(t);if(n&&!n.playing){let o=Wf();return n.originMs=o-n.frozenMs,n.playStartMs=o,n.playing=!0,!0}return!1}isPaused(t){return this.state.get(t)?.playing===!1}autoStopHeavy(t){let n=Wf();for(let o of t){let a=this.state.get(o);if(a?.playing){if(o===this.hoveredId){a.playStartMs=n;continue}n-a.playStartMs>TT&&(a.frozenMs=n-a.originMs,a.playing=!1)}}}};var S4=(e,t,n,o)=>{let a=we(Array.from(e.elements.values()).filter(s=>s.layerId===o).map(s=>s.order)),r={};return t.image&&(r.image=t.image),t.animated&&(r.animated=!0),{id:n,layerId:o,type:"image",position:t.position,rotation:0,scale:{x:1,y:1},order:a,style:{},width:t.width,height:t.height,src:t.src,...t.fileId?{fileId:t.fileId}:{},...t.animationKind?{animationKind:t.animationKind}:{},...t.animationData!==void 0?{animationData:t.animationData}:{},...Object.keys(r).length>0?{metadata:r}:{}}},k4=async(e,t,n,o)=>{let a=await t.arrayBuffer(),r=M1(`file-${o()}-${Date.now().toString(36)}`),s=kb(r,a,{mime:t.type||"application/octet-stream",...n!==void 0?{name:n}:{}}),i={kind:"file",id:r,before:null,after:s};return{scene:J(e,i),patch:i,id:r}},L0=e=>{for(let t of e.elements.values())if(t.metadata?.animated===!0)return!0;return!1};var w4=e=>{if(!L0(e._scene))return!1;let t=e.computeViewportWorld();if(!t)return!0;for(let n of e._scene.elements.values())if(n.metadata?.animated===!0&&X.intersects(z(n),t))return!0;return!1},_4=e=>{let t=[];for(let n of e._scene.elements.values()){if(!Ut(n)||!n.animationKind)continue;n.animationData instanceof ArrayBuffer&&n.animationData.byteLength>CT&&t.push(n.id)}e.gifPlayback.autoStopHeavy(t)},CA=e=>{for(let t of e._scene.elements.values()){if(!Ut(t)||!t.animationKind||(e.gifPlayback.ensure(t.id),!t.fileId)||t.animationData instanceof ArrayBuffer)continue;let n=Ab(e._scene,t.fileId);n&&(e._scene=J(e._scene,{kind:"element",id:t.id,before:t,after:{...t,animationData:n.data}}))}};var C4={x:-1e9,y:-1e9,width:0,height:0},_F=4,T4=(e,t)=>{let n=new Map;if(e===t)return{world:C4,tileDirty:n};let o=null,a=u=>{o=o?X.union(o,u):u},r=new Set;for(let[u,d]of t.elements){let f=e.elements.get(u);if(f===d)continue;r.add(u);let p=af(d),h=f?af(f):null;a(p),h&&a(h),n.set(u,{before:h,after:p})}for(let[u,d]of e.elements)if(!t.elements.has(u)){r.add(u);let f=af(d);a(f),n.set(u,{before:f,after:null})}let s=u=>{for(let d of[u.from,u.to])if(d.kind!=="point"&&r.has(d.elementId))return!0;return!1};for(let[u,d]of t.links){let f=e.links.get(u);if(f===d&&!s(d))continue;let p=Dr(t,d);p&&a(p);let m=Dr(e,f??d);m&&a(m)}for(let[u,d]of e.links)if(!t.links.has(u)){let f=Dr(e,d);f&&a(f)}if(o===null)return{world:C4,tileDirty:n};let i=new Set,l=o,c=!0;for(;c;){c=!1;for(let u of t.elements.values()){if(i.has(u.id))continue;let d=z(u);if(!X.intersects(d,l))continue;i.add(u.id);let f=X.union(l,d);(f.x!==l.x||f.y!==l.y||f.width!==l.width||f.height!==l.height)&&(l=f,c=!0)}}return{world:X.expand(l,_F),tileDirty:n}};var S0=class{screenToWorld;onFire;timer=null;origin=null;constructor(t,n){this.screenToWorld=t,this.onFire=n}start(t){this.cancel(),this.origin=t,this.timer=setTimeout(()=>{this.timer=null;let n=this.origin;if(this.origin=null,!n)return;let o=this.screenToWorld(n);this.onFire({screenPoint:n,worldPoint:o})},lT)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.origin=null}cancelIfMovedBeyond(t,n){this.origin&&Ae.distance(this.origin,t)>n&&this.cancel()}};var k0=class{screenToWorld;zoomAt;panBy;origin=null;constructor(t,n,o){this.screenToWorld=t,this.zoomAt=n,this.panBy=o}isActive(){return this.origin!==null}begin(t){if(t.length<2)return;let[n,o]=t,a=Ae.midpoint(n,o);this.origin={midpointScreen:a,midpointWorld:this.screenToWorld(a),distance:Ae.distance(n,o)}}apply(t){if(!this.origin||t.length<2)return;let[n,o]=t,a=Ae.distance(n,o),r=Ae.midpoint(n,o);if(Ae.distance(r,this.origin.midpointScreen)+Math.abs(a-this.origin.distance)<iT)return;let i=a/this.origin.distance;if(i!==1){let u=this.screenToWorld(r);this.zoomAt(i,u)}let l=r.x-this.origin.midpointScreen.x,c=r.y-this.origin.midpointScreen.y;(l!==0||c!==0)&&this.panBy({x:l,y:c}),this.origin={midpointWorld:this.screenToWorld(r),distance:a,midpointScreen:r}}end(){this.origin=null}};var CF=(e,t)=>{let n=e.width*e.height;if(n<=0)return 0;let o=Math.max(e.x,t.x),a=Math.max(e.y,t.y),r=Math.min(e.x+e.width,t.x+t.width),s=Math.min(e.y+e.height,t.y+t.height),i=r-o,l=s-a;return i<=0||l<=0?0:i*l/n},TF=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=z(o);n=n?X.union(n,a):a}return n},I4=(e,t,n,o)=>{if(!Yd(t)||!ei(t))return n;if(An(t)?.kind==="wrap")return IF(e,t,n,o);let a=TF(e,t.id);if(!a)return n;let r={...t,position:{x:n.x,y:n.y},width:n.width,height:n.height},s=Un(r);if(!s)return n;let{x:i,y:l,width:c,height:u}=n,d=s.x,f=s.y,p=s.x+s.width,h=s.y+s.height,m=a.x,b=a.y,y=a.x+a.width,g=a.y+a.height;if(o.includes("e")&&p<y&&(c+=y-p),o.includes("s")&&h<g&&(u+=g-h),o.includes("w")&&d>m){let x=d-m;i-=x,c+=x}if(o.includes("n")&&f>b){let x=f-b;l-=x,u+=x}return{x:i,y:l,width:c,height:u}},IF=(e,t,n,o)=>{let a=Ns(t)?.padding??0,r=Math.max(0,n.width-2*a),s=Mm(e,t.id,r);if(!s)return n;let{x:i,y:l,width:c,height:u}=n,d=s.widest+2*a;if(c<d){let m=d-c;c=d,o.includes("w")&&(i-=m)}let f=Math.max(0,c-2*a),h=(f===r?s:Mm(e,t.id,f)??s).contentHeight+2*a;if(u<h){let m=h-u;u=h,o.includes("n")&&(l-=m)}return{x:i,y:l,width:c,height:u}},E4=(e,t)=>{let n=e.dragElementId;if(!n)return;let o=M(e.scene,n);if(!o)return;let a=e.containerHover;if(a&&a.id!==o.parentId){let r=we([...e.scene.elements.values()].filter(i=>i.layerId===o.layerId&&i.id!==n).map(i=>i.order)),s=le(e.scene,n,i=>({...i,parentId:a.id,order:r}));e.applyPatch(s.patch,s.scene),jf(e,a.id,n);return}if(a&&a.id===o.parentId){jf(e,o.parentId,n);return}if(o.parentId){let r=M(e.scene,o.parentId);if(r!==void 0&&Oe(r))return;let s=r?Un(r):null,i=z(o),l=s?CF(i,s):0;if(s&&l>=vT){jf(e,o.parentId,n);return}let c=le(e.scene,n,u=>{let d={...u};return delete d.parentId,d});e.applyPatch(c.patch,c.scene)}},jf=(e,t,n)=>{let o=M(e.scene,t),a=M(e.scene,n);if(!o||!a)return;let r=Ns(o);if(!r)return;let s=z(a),i=Q1(o,s);if(!i)return;if(ei(o)){let c=J1({width:o.width,height:o.height,spec:r},i),u=le(e.scene,t,d=>({...d,position:{x:d.position.x+c.positionOffset.x,y:d.position.y+c.positionOffset.y},width:c.width,height:c.height,metadata:{...d.metadata??{},container:{...r,dropZone:i}}}));e.applyPatch(u.patch,u.scene);return}let l=le(e.scene,t,c=>({...c,metadata:{...c.metadata??{},container:{...r,dropZone:i}}}));e.applyPatch(l.patch,l.scene)};var Vf=(e,t,n)=>{let o=e.x,a=e.y,r=e.width,s=e.height;switch(t){case"nw":o+=n.x,a+=n.y,r-=n.x,s-=n.y;break;case"n":a+=n.y,s-=n.y;break;case"ne":a+=n.y,r+=n.x,s-=n.y;break;case"e":r+=n.x;break;case"se":r+=n.x,s+=n.y;break;case"s":s+=n.y;break;case"sw":o+=n.x,r-=n.x,s+=n.y;break;case"w":o+=n.x,r-=n.x;break}return{x:o,y:a,width:r,height:s}},TA=(e,t)=>{let n=e.x+e.width/2,o=e.y+e.height/2,a=e.width+2*(t.width-e.width),r=e.height+2*(t.height-e.height);return{x:n-a/2,y:o-r/2,width:a,height:r}},IA=(e,t)=>{if(e.width===0||e.height===0)return t;let n=t.width/e.width,o=t.height/e.height,a=Math.abs(n-1)>=Math.abs(o-1)?n:o;return{x:t.x,y:t.y,width:e.width*a,height:e.height*a}},M4=e=>e==="nw"||e==="w"||e==="sw",O4=e=>e==="ne"||e==="e"||e==="se",R4=e=>e==="nw"||e==="n"||e==="ne",D4=e=>e==="sw"||e==="s"||e==="se",EA=(e,t,n,o,a=!1)=>{let r=o.noFlip?o.minWidth??0:o.minWidth,s=o.noFlip?o.minHeight??0:o.minHeight,i=o.maxWidth,l=o.maxHeight,c=(m,b,y)=>{let g=m;return b!==void 0&&g<b&&(g=b),y!==void 0&&g>y&&(g=y),g},u=t.width;o.noFlip?u=c(u,r,i):i!==void 0&&Math.abs(u)>i?u=u<0?-i:i:r!==void 0&&Math.abs(u)<r&&u!==0&&(u=u<0?-r:r);let d=t.height;if(o.noFlip?d=c(d,s,l):l!==void 0&&Math.abs(d)>l?d=d<0?-l:l:s!==void 0&&Math.abs(d)<s&&d!==0&&(d=d<0?-s:s),a){let m=o.noFlip?u:Math.abs(u),b=o.noFlip?d:Math.abs(d),y=e.x+e.width/2,g=e.y+e.height/2;return{x:y-m/2,y:g-b/2,width:m,height:b}}let f=t.x;M4(n)&&!O4(n)?f=e.x+e.width-u:O4(n)&&!M4(n)&&(f=e.x);let p=t.y;R4(n)&&!D4(n)?p=e.y+e.height-d:D4(n)&&!R4(n)&&(p=e.y);let h={x:f,y:p,width:u,height:d};return o.noFlip?h:X.normalize(h)};var P4=(e,t)=>e.kind!=="point"&&t.has(e.elementId),EF=(e,t)=>P4(e.from,t)&&P4(e.to,t),N4=e=>(e.waypoints?.length??0)>0||(e.fixedSegments?.length??0)>0||(e.routedPoints?.length??0)>0,B4=(e,t)=>e.map(n=>({x:n.x+t.x,y:n.y+t.y})),MF=(e,t)=>{if(!N4(e))return null;let n={};return e.waypoints?.length&&(n.waypoints=B4(e.waypoints,t)),e.fixedSegments?.length&&(n.fixedSegments=e.fixedSegments.map(o=>({axis:o.axis,pos:o.pos+(o.axis==="h"?t.y:t.x),at:o.at+(o.axis==="h"?t.x:t.y)}))),e.routedPoints?.length&&(n.routedPoints=B4(e.routedPoints,t)),n},z4=(e,t)=>e.kind==="point"?{kind:"point",position:{x:e.position.x+t.x,y:e.position.y+t.y}}:e,MA=(e,t)=>{let n=MF(e,t),o=e.from.kind==="point",a=e.to.kind==="point";if(!n&&!o&&!a)return null;let r={...n??{}};return o&&(r.from=z4(e.from,t)),a&&(r.to=z4(e.to,t)),r},F4=(e,t,n,o,a)=>{let r=c=>({x:t+(c.x-t)*o,y:n+(c.y-n)*a}),s=e.from.kind==="point",i=e.to.kind==="point";if(!N4(e)&&!s&&!i)return null;let l={};return e.waypoints?.length&&(l.waypoints=e.waypoints.map(r)),e.fixedSegments?.length&&(l.fixedSegments=e.fixedSegments.map(c=>({axis:c.axis,pos:c.axis==="h"?n+(c.pos-n)*a:t+(c.pos-t)*o,at:c.axis==="h"?t+(c.at-t)*o:n+(c.at-n)*a}))),e.routedPoints?.length&&(l.routedPoints=e.routedPoints.map(r)),e.from.kind==="point"&&(l.from={kind:"point",position:r(e.from.position)}),e.to.kind==="point"&&(l.to={kind:"point",position:r(e.to.position)}),l},H4=(e,t,n)=>n.has(e.id)||EF(e,t),OA=(e,t,n)=>{let o=new Map;for(let a of e.links.values())H4(a,t,n)&&MA(a,{x:0,y:0})!==null&&o.set(a.id,a);return o},U4=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=be(e,a);if(!s)continue;let i=MA(r,n);i&&o.push({kind:"link",id:a,before:s,after:{...s,...i}})}return o},G4=(e,t,n,o)=>{let a=e,r=[];for(let s of[...e.links.values()]){if(!H4(s,t,n))continue;let i=MA(s,o);if(!i)continue;let l=et(a,s.id,c=>({...c,...i}));a=l.scene,r.push(l.patch)}return{scene:a,patches:r}};var q4=(e,t,n,o,a,r,s=!1,i=!1)=>{let l=M(e,t);if(!l||!ei(l))return null;let c=Vf(a,n,o),u=s?IA(a,c):c,d=i?TA(a,u):u,p=l.noFlip===!0||An(l)!==null?{...l,noFlip:!0}:l,h=EA(a,d,n,p,i),m=r(l,h,n),b={...l,position:{x:m.x,y:m.y},scale:{x:1,y:1},width:m.width,height:m.height},y={kind:"element",id:t,before:l,after:b};return{scene:J(e,y),patch:y}},W4=(e,t,n,o,a=!1,r=!1)=>{let s=M(e,t.id);if(!s||!ei(t))return null;let i=qs(t),[l]=xf(i),c=Math.cos(i.rotation),u=Math.sin(i.rotation),d={x:c,y:u},f={x:-u,y:c},p={x:o.x*d.x+o.y*d.y,y:o.x*f.x+o.y*f.y},h={x:0,y:0,width:i.bounds.width,height:i.bounds.height},m=Vf(h,n,p),b=a?IA(h,m):m,y=r?TA(h,b):b,x=t.noFlip===!0||An(t)!==null?{...t,noFlip:!0}:t,A=EA(h,y,n,x,r),C={x:l.x+A.x*d.x+A.y*f.x,y:l.y+A.x*d.y+A.y*f.y},_={...t,position:C,scale:{x:1,y:1},width:A.width,height:A.height},v={kind:"element",id:t.id,before:s,after:_};return{scene:J(e,v),patch:v}},j4=(e,t,n,o,a,r=!1)=>{let s=M(e,t.id);if(!s)return null;let i=Vf(a,n,o),l=a.x+a.width/2,c=a.y+a.height/2;if(n==="e"||n==="w"){let I=Math.max(t.fontSize,Math.abs(i.width)),k=n==="w"?a.x+a.width:a.x,T=r?l-I/2:n==="w"?k-I:k,P={...t,position:{x:T,y:a.y},scale:{x:1,y:1},maxWidth:I},N={kind:"element",id:t.id,before:s,after:P};return{scene:J(e,N),patch:N}}let u=n==="n"||n==="s",d=a.width>0?Math.abs(i.width/a.width):1,f=a.height>0?Math.abs(i.height/a.height):1,p=u?f:Math.max(d,f),h=Math.max(Hm,t.fontSize*p),m=h/t.fontSize,b=a.width*m,y=a.height*m,g=n.includes("w")?a.x+a.width:a.x,x=n.includes("n")?a.y+a.height:a.y,A=r?l-b/2:n.includes("w")?g-b:g,C=r?c-y/2:n.includes("n")?x-y:x,_={...t,position:{x:A,y:C},scale:{x:1,y:1},fontSize:h,...t.maxWidth!==void 0?{maxWidth:t.maxWidth*m}:{}},v={kind:"element",id:t.id,before:s,after:_};return{scene:J(e,v),patch:v}},V4=(e,t,n,o,a,r,s=!1)=>{let i=Vf(a,n,o),l=1,c=a.width>0?i.width/a.width:1,u=a.height>0?i.height/a.height:1;if(r){let b=Math.max(Math.abs(c),Math.abs(u));c=b*(c>=0?1:-1),u=b*(u>=0?1:-1)}s&&(c=1+2*(c-1),u=1+2*(u-1));let d=Math.abs(c-1)>=Math.abs(u-1)?c:u,f=s?a.x+a.width/2:n.includes("w")?a.x+a.width:a.x,p=s?a.y+a.height/2:n.includes("n")?a.y+a.height:a.y,h=e,m=[];for(let[b,y]of t.elements){let g=M(h,b);if(!g)continue;let x=f+(y.position.x-f)*c,A=p+(y.position.y-p)*u;if(ei(g)){let k=g.type==="image",T=k?d:c,P=k?d:u,N=y.bounds.width*T,U=y.bounds.height*P;if(Math.abs(N)<l||Math.abs(U)<l)continue;let q={...g,position:{x,y:A},scale:{x:N>=0?1:-1,y:U>=0?1:-1},width:Math.abs(N),height:Math.abs(U)},te={kind:"element",id:b,before:g,after:q};h=J(h,te),m.push(te);continue}let C=y.scale.x*c,_=y.scale.y*u;if(Math.abs(C)<l/Math.max(1,y.bounds.width)||Math.abs(_)<l/Math.max(1,y.bounds.height))continue;let v={...g,position:{x,y:A},scale:{x:C,y:_}},I={kind:"element",id:b,before:g,after:v};h=J(h,I),m.push(I)}for(let[b,y]of t.links??[]){let g=be(h,b);if(!g)continue;let x=F4(y,f,p,c,u);if(!x)continue;let A={kind:"link",id:b,before:g,after:{...g,...x}};h=J(h,A),m.push(A)}return{scene:h,patches:m}};var kt=Object.freeze(new Set),RA=e=>new Set([e]),DA=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},OF=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},Z4=(e,t)=>e.has(t)?OF(e,t):DA(e,t),w0=(e,t)=>dm(e,t),X4=e=>{if(e.size!==1)return null;for(let t of e)return t;return null};var _0=e=>Math.min(sT,Math.max(rT,e)),Y4=(e,t)=>t.x===0&&t.y===0?null:{...e,viewport:mb(e.viewport,t)},K4=(e,t,n)=>{let o=e.viewport.zoom,r=_0(o*t)/o;return r===1?null:{...e,viewport:wm(e.viewport,r,n)}},$4=e=>{let t=e.viewport;if(t.zoom===1)return null;let n={x:t.pan.x+t.size.width/2/t.zoom,y:t.pan.y+t.size.height/2/t.zoom};return{...e,viewport:wm(t,1/t.zoom,n)}},BA=(e,t,n)=>{let o=e.viewport;if(o.size.width<=0||o.size.height<=0||t.width<=0||t.height<=0)return null;let a=o.size.width-n*2,r=o.size.height-n*2;if(a<=0||r<=0)return null;let s=_0(Math.min(a/t.width,r/t.height)),i={x:t.x+t.width/2,y:t.y+t.height/2},l={x:i.x-o.size.width/2/s,y:i.y-o.size.height/2/s};return{...e,viewport:{...o,zoom:s,pan:l}}},Q4=(e,t)=>{if(e.elements.size===0)return null;let n=null;for(let o of e.elements.values()){let a=z(o);n=n?X.union(n,a):a}return n?BA(e,n,t):null},J4=(e,t,n)=>{let o=e.viewport;return o.size.width===t&&o.size.height===n?null:{...e,viewport:yb(o,t,n)}},e5=(e,t)=>{let n=e.viewport,o=t.enabled??n.gridEnabled,a=t.style??n.gridStyle,r=t.snap??n.snapToGrid;if(o===n.gridEnabled&&a===n.gridStyle&&r===n.snapToGrid)return null;let s={...n,gridEnabled:o,...a===void 0?{}:{gridStyle:a},...r===void 0?{}:{snapToGrid:r}};return{...e,viewport:s}};var RF=(e,t)=>{let n=[];for(let o=e;o<=t;o++)n.push(o);return n},t5=e=>{let t=c=>{c.preventDefault(),e.host.setPointerCapture(c.pointerId),typeof e.host.focus=="function"&&!Ia(c.target)&&e.host.focus({preventScroll:!0});let u=ac(c,e.host);e.additivePressAdded=null;let d=c.button===2||c.button===1,f=c.button===0&&e.spaceHeld,p=c.button===0&&e.mode==="hand";if(d||f||p){d&&(e.suppressNextContextMenu=!0),e.beginPanGesture(c.pointerId,c.button,u.point);return}if(e.activePointers.set(c.pointerId,u.point),e.activePointers.size===2){e.actor.send({type:"POINTER_CANCEL"}),e.cancelGesture(),e.cancelLongPress(),e.panGesture=null,e.touchPanCandidate=null,e.beginPinch();return}if(e.activePointers.size>2)return;e.startLongPress(u.point);let h=e.screenToWorld(u.point);if(e.editingTextElement!==null){if(e.editedElementContainsPoint(h)){e.cancelLongPress(),e.setTextCaretFromPoint(h);return}e.commitTextEdit()}if(e.mode==="brush"){e.beginBrushStroke(h,c.pressure);return}if(e.mode==="draw-text"){e.cancelLongPress();let _=e.hitTest(h),v=_.kind==="element"?M(e._scene,_.id):void 0;v!==void 0&&Fe(v)?(e._selection=Mt(v.id),e.beginTextEdit(v.id),e.notify()):e.createTextAt(h);return}let m=e.hitAnnotation(h);if(m){let _=e._scene.annotations.get(m);if(_){e.annotationDrag={id:m,originPosition:{..._.position},originWorldPoint:h,moved:!1},e.setSelectedAnnotation(m);return}}let b=e.acceleratedElementAt(h);if(b){let _=r4(b.type);if(_){let v={x:h.x-b.position.x,y:h.y-b.position.y},I=_(b,v);if(I){e.applyEmit(I);return}}}let y=e.selectedLink;if(e.mode==="select"&&y){let _=be(e._scene,y);if(_&&(_.routing??"straight")==="orthogonal"){let v=rt(e._scene,_);if(v&&v.length>=2){let I=e._scene.viewport.zoom||1,k=Oo/I,T=k*k,P=v.length===2?[0]:RF(1,v.length-3);for(let N of P){let U=L(v[N]),q=L(v[N+1]),te=(U.x+q.x)/2,Z=(U.y+q.y)/2,ue=te-h.x,$=Z-h.y;if(ue*ue+$*$<=T){let re=Math.abs(U.y-q.y)<1e-6?"h":"v",We=re==="h"?(U.x+q.x)/2:(U.y+q.y)/2,Re=re==="h"?U.y:U.x;e.isHandleDoubleClick(h)?e.resetSegmentPin(y,re,Re,We):e.beginSegmentDrag(y,re,We),e.cancelLongPress();return}}}}}let g=e.selectedLink;if(e.mode==="select"&&g){let _=be(e._scene,g),v=_&&(_.routing??"straight")!=="orthogonal"?rt(e._scene,_):null;if(_&&v&&v.length>=2){let I=e._scene.viewport.zoom||1,k=Oo/I,T=k*k,P=[..._.waypoints??[]],N=q=>{let te=q.x-h.x,Z=q.y-h.y;return te*te+Z*Z<=T},U=!1;for(let q=0;q<P.length;q++)if(N(L(P[q]))){e.isHandleDoubleClick(h)?e.deleteWaypoint(g,q):e.beginWaypointDrag(g,q,!1),U=!0;break}if(!U){let q=of(e._scene,_)??[];for(let te=0;te<q.length;te++)if(N(L(q[te]))){e.beginWaypointDrag(g,te,!0),U=!0;break}}if(U){e.cancelLongPress();return}}}let x=e.hitTest(h);if(e.mode==="select"&&!u.modifiers.shift&&!u.modifiers.meta&&!u.modifiers.ctrl&&x.kind!=="rotate-handle"){let _=I=>{let k=M(e._scene,I);if(!k)return!1;let T=e._scene.viewport.zoom||1,{names:P,worldPoints:N}=ho(k,fo/T),U=(Ro+e.anchorStartHitSlop)/T,q=null,te=U*U;for(let Z=0;Z<N.length;Z++){let ue=L(N[Z]),$=ue.x-h.x,re=ue.y-h.y,We=$*$+re*re;We<=te&&(te=We,q=L(P[Z]))}return q===null?!1:(e.cancelLongPress(),e.linkDragFromAnchor={fromElement:I,fromWorld:Gt(k,{kind:"named",name:q}),anchorName:q,origin:h,moved:!1},!0)},v=e._selection.size===1?[...e._selection][0]:null;if(v&&_(v))return}if(!((u.modifiers.meta||u.modifiers.ctrl)&&x.kind==="element"&&e.elementLink(x.id)!==null)&&x.kind==="element"&&!e._selection.has(x.id)){let _=u.modifiers.shift||u.modifiers.meta||u.modifiers.ctrl;e._selection=_?xn(e._selection,x.id):Mt(x.id),_&&(e.additivePressAdded=x.id),!_&&e._selectedLinks.size>0&&(e._selectedLinks=kt),e.notify()}if(u.modifiers.alt&&e.mode==="select"&&x.kind==="element"&&e._selection.has(x.id)){let _=e.duplicateSelectedInPlace(x.id);_!==null&&(x={kind:"element",id:_,bounds:x.bounds})}if(e.dragElementId=x.kind==="element"?x.id:null,e.containerHover=null,x.kind==="element"){let _=M(e._scene,x.id),v=_!==void 0&&Oe(_),I=_!==void 0&&He(_),k=e._selection.has(x.id);if(k||v||I){let T=new Set;if(k)for(let N of e.expandSelectionWithDescendants()){let U=M(e._scene,N);U&&e.isElementManipulable(U)&&T.add(N)}if(v){let N=U=>{if(!T.has(U)){T.add(U);for(let q of e._scene.elements.values())q.parentId===U&&N(q.id)}};N(x.id)}if(I){T.add(x.id);for(let N of e._scene.elements.values())N.frameId===x.id&&T.add(N.id)}let P=OA(e._scene,T,e._selectedLinks);if(T.size>1||P.size>0){let N=new Map;for(let U of T){let q=M(e._scene,U);q&&N.set(U,q.position)}e.groupMoveOrigin=N,e.groupLinkMoveOrigin=P.size>0?P:null}else e.groupMoveOrigin=null,e.groupLinkMoveOrigin=null}else e.groupMoveOrigin=null,e.groupLinkMoveOrigin=null}else e.groupMoveOrigin=null;if(x.kind==="group-handle"){let _=new Map;for(let I of e.expandSelectionWithDescendants()){let k=M(e._scene,I);k&&_.set(I,{position:k.position,bounds:z(k),scale:k.scale})}let v=OA(e._scene,new Set(_.keys()),e._selectedLinks);e.groupResizeOrigin={combined:x.bounds,elements:_,links:v}}else e.groupResizeOrigin=null;if(x.kind==="rotate-handle"){let _=new Map;for(let v of e.expandSelectionWithDescendants()){let I=M(e._scene,v);I&&_.set(v,{position:I.position,rotation:I.rotation})}e.rotateGestureOrigin={pivot:x.pivot,origin:_}}else e.rotateGestureOrigin=null;e.touchPanCandidate=u.kind==="touch"&&e.mode==="select"&&x.kind==="empty"?u.point:null,e.actor.send({type:"POINTER_DOWN",point:h,target:x,modifiers:u.modifiers})},n=c=>{let u=ac(c,e.host);if(e.panGesture?.pointerId===c.pointerId){let p=u.point.x-e.panGesture.lastPoint.x,h=u.point.y-e.panGesture.lastPoint.y;e.panGesture.lastPoint=u.point,!e.panGesture.moved&&Ae.distance(e.panGesture.startPoint,u.point)>Fl&&(e.panGesture.moved=!0),e.panBy({x:p,y:h});return}if(e.activePointers.has(c.pointerId)&&e.activePointers.set(c.pointerId,u.point),e.pinch.isActive()){e.applyPinch();return}if(e.touchPanCandidate!==null&&e.activePointers.size===1&&Ae.distance(e.touchPanCandidate,u.point)>Fl){let p=e.touchPanCandidate;e.touchPanCandidate=null,e.beginPanGesture(c.pointerId,c.button,p);let h=e.panGesture;h&&(h.moved=!0,e.panBy({x:u.point.x-p.x,y:u.point.y-p.y}),h.lastPoint=u.point);return}e.longPress.cancelIfMovedBeyond(u.point,Fl);let d=e.screenToWorld(u.point);if(e.lastPointerWorld=d,e.refreshCursor(d),e.isDraggingSegment){e.updateSegmentDrag(d);return}if(e.isDraggingWaypoint){e.updateWaypointDrag(d);return}if(e.linkDragFromAnchor){let p=e.linkDragFromAnchor;if(!p.moved){let h=d.x-p.origin.x,m=d.y-p.origin.y;if(h*h+m*m<Ys*Ys)return;p.moved=!0}e.applyLinkPreview(p.fromElement,p.fromWorld,d),e.updateHoveredLinkTarget(d);return}if(e.editingTextElement!==null&&e.isTextDragging){e.extendTextSelectionToPoint(d);return}if(e.brushStroke){e.extendBrushStroke(d,c.pressure);return}if(e.dragElementId){let p=e.dragElementId,h=new Set([p]);for(let b of e._scene.elements.values()){let y=b.parentId;for(let g=0;y&&g<64;g++){if(y===p){h.add(b.id);break}y=e._scene.elements.get(y)?.parentId}}let m=Kd(e._scene,d,h);if(m){let b=Un(m);if(b){let y={id:m.id,dropZone:b};(e.containerHover?.id!==y.id||e.containerHover.dropZone!==y.dropZone)&&(e.containerHover=y,e.notify())}}else e.containerHover!==null&&(e.containerHover=null,e.notify())}if(e.annotationDrag){let p=e.annotationDrag,h=d.x-p.originWorldPoint.x,m=d.y-p.originWorldPoint.y;(h!==0||m!==0)&&(p.moved=!0);let b=e._scene.annotations.get(p.id);if(b){let y={x:p.originPosition.x+h,y:p.originPosition.y+m},g={...b,position:y},x=new Map(e._scene.annotations);x.set(p.id,g),e._scene={...e._scene,annotations:x},e.notify()}return}for(let p of e.cursorListeners)p(d);let f=e.actor.getSnapshot().context;if(f.pressOrigin&&f.mode!=="select"&&f.mode!=="draw-edge"&&e.isDrawingPhase(f)&&(e.drawingPreview=Tf(f.pressOrigin,d)),f.mode==="draw-edge"?e.updateHoveredLinkTarget(d):e.hoveredLinkTarget!==null&&(e.hoveredLinkTarget=null,e.notify()),!f.pressOrigin){let p=e.hitTest(d),h=p.kind==="element"?e._scene.elements.get(p.id):void 0;e.hoverAnimatedElement(h&&Ut(h)&&h.animationKind?h.id:null),e.setHoverCursorWorld(e.mode==="select"?d:null)}e.actor.send({type:"POINTER_MOVE",point:d})},o=c=>{if(e.host.hasPointerCapture(c.pointerId)&&e.host.releasePointerCapture(c.pointerId),e.activePointers.delete(c.pointerId),e.touchPanCandidate=null,e.panGesture?.pointerId===c.pointerId){e.endPanGesture();return}if(e.pinch.isActive()){e.activePointers.size<2&&e.pinch.end();return}if(e.cancelLongPress(),e.isDraggingSegment){e.endSegmentDrag();return}if(e.isDraggingWaypoint){e.endWaypointDrag();return}if(e.linkDragFromAnchor){let y=e.linkDragFromAnchor;e.linkDragFromAnchor=null;let g=ac(c,e.host),x=e.screenToWorld(g.point);if(y.moved){let A=e.hitTest(x),C=A.kind==="element"?A.id:null;e.applyEmit({type:"CREATE_EDGE",fromElement:y.fromElement,toElement:C,fromPoint:y.fromWorld,toPoint:x})}else{let A=M(e._scene,y.fromElement),C=e._scene.viewport.zoom||1,_=!1;if(A){let{names:v,worldPoints:I}=ho(A,fo/C),k=v.indexOf(y.anchorName);if(k>=0){let T=L(I[k]),P=e.anchorClickRadius/C,N=T.x-y.origin.x,U=T.y-y.origin.y;_=N*N+U*U<=P*P}}if(_)e.createLinkedElementFromAnchor(y.fromElement,y.anchorName);else{let v=e.hitTest(x);v.kind==="empty"?e.applyEmit({type:"SELECT_CLEAR"}):v.kind==="element"?e.applyEmit({type:"SELECT_REPLACE",id:v.id}):v.kind==="link"&&e.applyEmit({type:"SELECT_EDGE_REPLACE",id:v.id})}}e.edgePreview=null,e.hoveredLinkTarget=null,e.notify();return}if(e.editingTextElement!==null&&e.isTextDragging){e.endTextDragSelect();return}if(e.brushStroke){e.commitBrushStroke();return}if(e.annotationDrag){let y=e.annotationDrag;if(e.annotationDrag=null,y.moved){let g=e._scene.annotations.get(y.id);if(g){let x={...g,position:y.originPosition},A=new Map(e._scene.annotations);A.set(y.id,x),e._scene={...e._scene,annotations:A};let C=wa(e._scene,y.id,()=>g);e._scene=C.scene,e._history.push(C.patch),e.notify()}}return}let u=ac(c,e.host),d=e.screenToWorld(u.point);{let y=e.actor.getSnapshot().context.pressOrigin,g=u.modifiers.meta||u.modifiers.ctrl;if(y&&g){let x=e._scene.viewport.zoom||1;if(Math.hypot(d.x-y.x,d.y-y.y)*x<Fl){let C=e.hitTest(d);if(C.kind==="element"){let _=e.elementLink(C.id);if(_){e.openLink(_),e.actor.send({type:"POINTER_UP",point:d}),e.commitGesture();return}}}}}let f=e.actor.getSnapshot().context,p=DI(f,d);p?.type==="SELECT_TOGGLE"&&e.additivePressAdded===p.id&&(p=null),e.additivePressAdded=null,!e.routeIsolationClick(p,d)&&p&&e.applyEmit(p),e.drawingPreview=null;let m;f.mode==="draw-edge"?m=e.hitTest(d):f.pressTarget?.kind==="edge-endpoint"&&(m=e.linkAttachTargetAt(d)),e.actor.send(m!==void 0?{type:"POINTER_UP",point:d,target:m}:{type:"POINTER_UP",point:d}),e.applyContainerDrop(d),e.reconcileFrameMembership(),e.commitGesture();let b=f.pressOrigin;if(b){let y=e._scene.viewport.zoom||1;if(Math.hypot(d.x-b.x,d.y-b.y)*y<Fl){let x=e.hitTest(d);if(x.kind==="element"){let A=e._scene.elements.get(x.id);A&&Ut(A)&&A.animationKind&&e.togglePlayback(A.id)}}}e.refreshCursor(d)},a=c=>{if(e.activePointers.delete(c.pointerId),e.touchPanCandidate=null,e.panGesture?.pointerId===c.pointerId){e.endPanGesture();return}if(e.pinch.isActive()){e.activePointers.size<2&&e.pinch.end();return}if(e.cancelLongPress(),e.linkDragFromAnchor){e.linkDragFromAnchor=null,e.edgePreview=null,e.hoveredLinkTarget=null,e.notify();return}if(e.brushStroke){e.cancelBrushStroke();return}if(e.annotationDrag){let u=e.annotationDrag;e.annotationDrag=null;let d=e._scene.annotations.get(u.id);if(d){let f=new Map(e._scene.annotations);f.set(u.id,{...d,position:u.originPosition}),e._scene={...e._scene,annotations:f},e.notify()}return}e.drawingPreview=null,e.actor.send({type:"POINTER_CANCEL"}),e.cancelGesture()};e.host.addEventListener("pointerdown",t),e.host.addEventListener("pointermove",n),e.host.addEventListener("pointerup",o),e.host.addEventListener("pointercancel",a);let r=c=>{e.suppressNextContextMenu&&(e.suppressNextContextMenu=!1,c.preventDefault(),c.stopPropagation())};e.host.addEventListener("contextmenu",r,!0);let s=c=>{c.code!=="Space"&&c.key!==" "||Ia(c.target)||e.spaceHeld||(e.spaceHeld=!0,e.refreshCursor(),c.preventDefault())},i=c=>{c.code!=="Space"&&c.key!==" "||e.spaceHeld&&(e.spaceHeld=!1,e.refreshCursor())};typeof window<"u"&&(window.addEventListener("keydown",s),window.addEventListener("keyup",i));let l=c=>{c.preventDefault();let u=e.host.getBoundingClientRect(),d={x:c.clientX-u.left,y:c.clientY-u.top},f=()=>{if(c.deltaY===0)return;let m=1-(Math.abs(c.deltaY)>Yb?Yb*Math.sign(c.deltaY):c.deltaY)*aT/100;if(m<=0)return;let b=e._scene.viewport.zoom,y=_0(b*m);if(y===b)return;let g=e.screenToWorld(d);e.zoomAt(y/b,g)},p=()=>{let h=c.deltaX,m=c.deltaY;c.shiftKey&&h===0&&(h=m,m=0),e.panBy({x:-h*Zb,y:-m*Zb})};if(c.ctrlKey||c.metaKey){f();return}if(c.deltaX!==0){p();return}f()};return e.host.addEventListener("wheel",l,{passive:!1}),()=>{e.host.removeEventListener("pointerdown",t),e.host.removeEventListener("pointermove",n),e.host.removeEventListener("pointerup",o),e.host.removeEventListener("pointercancel",a),e.host.removeEventListener("contextmenu",r,!0),e.host.removeEventListener("wheel",l),typeof window<"u"&&(window.removeEventListener("keydown",s),window.removeEventListener("keyup",i))}};var n5=e=>e<=0?ST:Math.max(.5,e*LT),o5=(e,t)=>({points:[{x:0,y:0,width:n5(t)}],origin:e}),a5=(e,t,n)=>{let o=e.origin;e.points.push({x:t.x-o.x,y:t.y-o.y,width:n5(n)})},r5=(e,t,n,o)=>{if(!t||t.points.length===0)return null;let a=we([...e.elements.values()].filter(i=>i.layerId===n).map(i=>i.order)),r={id:o,layerId:n,type:"brush",position:t.origin,rotation:0,scale:{x:1,y:1},order:a,style:{fill:"#222"},points:t.points.slice()},s=Je(e,r);return{scene:s.scene,patch:s.patch,elementId:o}},s5=e=>Qe(`brush-${e}-${Date.now().toString(36)}`);var i5=e=>{let t=e.metadata,n=t&&"image"in t?t.image:void 0,o=e.animationData,a={...e};if(o!==void 0&&delete a.animationData,t){let s={...t};delete s.image,a.metadata=s}let r=structuredClone(a);return n!==void 0&&(r.metadata={...r.metadata,image:n}),o!==void 0&&(r.animationData=o),r},l5=(e,t)=>{let n=[];for(let o of t){let a=M(e,o);a&&n.push(i5(a))}return n},c5=(e,t,n,o,a)=>{if(n.length===0)return{scene:e,newIds:[]};let r=0,s=0;for(let f of n)r+=f.position.x,s+=f.position.y;r/=n.length,s/=n.length;let i=o?{x:o.x-r,y:o.y-s}:{x:10,y:10},l=[],c=[],u=e;for(let f of n){let p=a(),h=we([...u.elements.values()].filter(y=>y.layerId===f.layerId).map(y=>y.order)),m={...i5(f),id:p,position:{x:f.position.x+i.x,y:f.position.y+i.y},order:h},b=Je(u,m);u=b.scene,l.push(b.patch),c.push(p)}let d=l[0];return d!==void 0&&t.push(l.length===1?d:Mo(l)),{scene:u,newIds:c}};var u5=(e,t)=>l5(e,t),d5=(e,t,n,o,a)=>{let r=c5(e,t,n,o,()=>Qe(`shape-${a()}-${Date.now().toString(36)}`));return{scene:r.scene,newIds:r.newIds}},f5=e=>{let t=Ne;for(let n of e)t=xn(t,n);return t};var p5=(e,t,n)=>{let o=we([...e.layers.values()].map(s=>s.order)),r=_b(e,{id:n,name:t,visible:!0,locked:!1,order:o});return{scene:r.scene,patch:r.patch,layerId:n}},h5=(e,t,n)=>{if(!e.layers.has(t))return null;if(e.layers.size<=1)throw new Error("Cannot remove the only remaining layer.");let o=[],a=e;for(let i of[...a.elements.values()]){if(i.layerId!==t)continue;let l=jn(a,i.id);a=l.scene,o.push(l.patch)}for(let i of[...a.links.values()]){if(i.layerId!==t)continue;let l=lf(a,i.id);a=l.scene,o.push(l.patch)}let r=Cb(a,t);a=r.scene,o.push(r.patch);let s=n;if(n===t){let i=[...a.layers.values()].sort(Vd)[0];i&&(s=i.id)}return{scene:a,patches:o,nextActiveLayerId:s}},m5=(e,t,n)=>{let o=e.layers.get(t);if(!o||o.name===n)return null;let a=cf(e,t,r=>({...r,name:n}));return{scene:a.scene,patch:a.patch}},y5=(e,t)=>{if(!e.layers.has(t))return null;let n=cf(e,t,o=>({...o,visible:!o.visible}));return{scene:n.scene,patch:n.patch}},g5=(e,t)=>{if(!e.layers.has(t))return null;let n=cf(e,t,o=>({...o,locked:!o.locked}));return{scene:n.scene,patch:n.patch}},x5=(e,t,n)=>{if(!e.layers.has(n)||t.size===0)return null;let o=e,a=[];for(let r of t){let s=M(o,r);if(!s||s.layerId===n)continue;let i=le(o,r,l=>({...l,layerId:n}));o=i.scene,a.push(i.patch)}return a.length===0?null:{scene:o,patches:a}},b5=e=>$t(`layer-${e}-${Date.now().toString(36)}`);var A5=(e,t,n,o)=>{let a=new Date().toISOString(),r=Hd(o("ann")),s=[];t.firstComment?.trim()&&s.push({id:Tl(o("cmt")),authorId:n.id,authorName:n.name,body:t.firstComment.trim(),createdAt:a});let i={id:r,elementId:t.elementId??null,position:t.position,resolved:!1,thread:s,createdAt:a},l=Tb(e,i);return{scene:l.scene,patch:l.patch,id:r}},v5=(e,t)=>{if(!e.annotations.has(t))return null;let n=Ib(e,t);return{scene:n.scene,patch:n.patch}},L5=(e,t)=>{let n=e.annotations.get(t);if(!n)return null;let o=wa(e,t,a=>({...a,resolved:!a.resolved}));return{scene:o.scene,patch:o.patch,wasResolved:n.resolved}},S5=(e,t,n,o,a)=>{let r=n.trim();if(!r||!e.annotations.has(t))return null;let s={id:Tl(a("cmt")),authorId:o.id,authorName:o.name,body:r,createdAt:new Date().toISOString()},i=wa(e,t,l=>({...l,thread:[...l.thread,s]}));return{scene:i.scene,patch:i.patch}},k5=(e,t,n)=>{if(!e.annotations.get(t)?.thread.some(r=>r.id===n))return null;let a=wa(e,t,r=>({...r,thread:r.thread.filter(s=>s.id!==n)}));return{scene:a.scene,patch:a.patch}},w5=(e,t)=>{let n=e.viewport.zoom,o=Nm/n,a=[...e.annotations.values()];for(let r=a.length-1;r>=0;r--){let s=a[r];if(s===void 0)continue;let i=Tr(e,s),l=t.x-i.x,c=t.y-i.y;if(l*l+c*c<=o*o)return s.id}return null};var _5=(e,t,n)=>{let o=M(e,t);return!(o===void 0||!Fe(o)||n(o.layerId))};var C5=(e,t)=>{let n=null,o="";for(let a of e.elements.values()){if(!He(a))continue;let r=a.position.x,s=a.width*a.scale.x,i=24*a.scale.y,l=a.position.y-i;t.x>=r&&t.x<=r+s&&t.y>=l&&t.y<=l+i&&(n===null||a.order>o)&&(n=a.id,o=a.order)}return n},T5=(e,t,n)=>{let o=M(e,t);if(o===void 0||!He(o))return null;let a=n.trim(),r=o.name??"";if(a===r)return null;let s=le(e,t,i=>{let l={...i};return a===""?delete l.name:l.name=a,l});return{scene:s.scene,patch:s.patch}};var DF={nw:"resize-nwse",se:"resize-nwse",ne:"resize-nesw",sw:"resize-nesw",n:"resize-ns",s:"resize-ns",e:"resize-ew",w:"resize-ew"},PF=(e,t)=>{if(typeof e=="string")return e;let n=e.hotspot?.x??0,o=e.hotspot?.y??0;return`${e.url2x!==void 0?`image-set(url("${e.url}") 1x, url("${e.url2x}") 2x)`:`url("${e.url}")`} ${String(n)} ${String(o)}, ${e.fallback??t}`},BF=(e,t,n)=>{let o=e.getCursorOverride(t);return o===void 0?n:PF(o,n)},zF=(e,t)=>{if(e.mode!=="select"||e._selection.size!==1)return!1;let n=[...e._selection][0];if(n===void 0)return!1;let o=M(e._scene,n);if(!o)return!1;let a=e._scene.viewport.zoom||1,{worldPoints:r}=ho(o,fo/a),s=(Ro+e.anchorStartHitSlop)/a,i=s*s;for(let l of r){let c=l.x-t.x,u=l.y-t.y;if(c*c+u*u<=i)return!0}return!1},I5=(e,t)=>{let n=(a,r)=>BF(e,a,r),o=a=>n(DF[a],ZT(a));if(e.panGesture)return n("pan-active","grabbing");if(e.linkDragFromAnchor?.moved===!0)return n("draw","crosshair");if(e.isDraggingWaypoint||e.isDraggingSegment||e.annotationDrag?.moved===!0)return n("move","grabbing");if(e.brushStroke)return n("draw","crosshair");if(e.gestureTx){let a=e.actor.getSnapshot().context.pressTarget;if(a&&(a.kind==="handle"||a.kind==="group-handle"))return o(a.handle);if(a?.kind==="rotate-handle")return n("rotate","grabbing");if(a&&(a.kind==="element"||a.kind==="link"||a.kind==="edge-endpoint"))return n("move","grabbing")}if(e.editingTextElement!==null)return n("text","text");if(e.spaceHeld||e.mode==="hand")return n("pan-ready","grab");switch(e.mode){case"draw-rect":case"draw-ellipse":case"draw-frame":case"draw-edge":case"brush":return n("draw","crosshair");case"draw-text":return n("text","text");default:break}if(t){if(zF(e,t))return n("link-start","crosshair");let a=e.hitTest(t);switch(a.kind){case"handle":case"group-handle":return o(a.handle);case"rotate-handle":return n("rotate","grab");case"edge-endpoint":return n("link-handle","grab");case"annotation":return n("annotation","pointer");default:return n("default","default")}}return n("default","default")};var C0=(e,t,n)=>{let o=t??(n.size===1?[...n][0]??null:null);return o&&e.elements.has(o)?o:null},M5=(e,t,n)=>{let o=C0(e,t,n);if(!o)return null;let a=M(e,o);if(!a)return null;let r=we([...e.elements.values()].filter(i=>i.layerId===a.layerId&&i.id!==a.id).map(i=>i.order));if(r===a.order)return null;let s=le(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},O5=(e,t,n)=>{let o=C0(e,t,n);if(!o)return null;let a=M(e,o);if(!a)return null;let r=Bl([...e.elements.values()].filter(i=>i.layerId===a.layerId&&i.id!==a.id).map(i=>i.order));if(r===a.order)return null;let s=le(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},R5=(e,t,n)=>{let o=C0(e,t,n);if(!o)return null;let a=M(e,o);if(!a)return null;let r=[...e.elements.values()].filter(u=>u.layerId===a.layerId&&u.id!==a.id).sort(vt),s=r.find(u=>u.order>a.order)??null;if(!s)return null;let i=r.find(u=>u.order>s.order)??null,l=i?Cm(s.order,i.order):we(r.map(u=>u.order));if(l===a.order)return null;let c=le(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},D5=(e,t,n)=>{let o=C0(e,t,n);if(!o)return null;let a=M(e,o);if(!a)return null;let r=[...e.elements.values()].filter(u=>u.layerId===a.layerId&&u.id!==a.id).sort(Vd),s=r.find(u=>u.order<a.order)??null;if(!s)return null;let i=r.find(u=>u.order<s.order)??null,l=i?Cm(i.order,s.order):Bl(r.map(u=>u.order));if(l===a.order)return null;let c=le(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},E5=(e,t)=>{if(e.length===0)return 0;let n=[...e].sort(vt),o=vb(null,null,n.length),a=0;return n.forEach((r,s)=>{let i=o[s];i===void 0||i===r.order||(t(r,i),a++)}),a},P5=(e,t,n)=>{let o=e,a=0;for(let r of t)a+=E5([...o.elements.values()].filter(s=>s.layerId===r),(s,i)=>{let l=le(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)}),a+=E5([...o.links.values()].filter(s=>s.layerId===r),(s,i)=>{let l=et(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)});return a};var B5=(e,t,n,o)=>{let a=[...t];if(a.length<2)return null;let r=Math.max(1,n.cols??Math.ceil(Math.sqrt(a.length))),s=n.gap??16,i=Im(e,{shapeIds:a,origin:o,cols:r,gap:s});return i?{scene:J(e,i),patch:i,count:a.length,cols:r}:null},z5=(e,t,n,o)=>{let a=[...t];if(a.length<2)return null;let r=n.direction??"horizontal",s=n.gap??16,i=Em(e,{shapeIds:a,origin:o,direction:r,gap:s});return i?{scene:J(e,i),patch:i,count:a.length,direction:r}:null},zA=(e,t)=>{let n=[],o=new Set;for(let a of t){let r=M(e,a);if(!r)continue;let s=r,i=!1;for(let l=0;s?.parentId&&l<64;l++){if(t.has(s.parentId)){i=!0;break}s=M(e,s.parentId)}i||o.has(r.id)||(o.add(r.id),n.push(r))}return n},N5=(e,t)=>{let n=new Set,o=a=>{if(!(n.has(a)||!M(e,a))){n.add(a);for(let s of e.elements.values())s.parentId===a&&o(s.id)}};for(let a of t)o(a);return n},F5=(e,t,n)=>{let o=zA(e,t),a=o[0];if(o.length<2||a===void 0)return null;let r=a.layerId,s=we([...e.elements.values()].filter(d=>d.layerId===r).map(d=>d.order)),i={id:n,layerId:r,type:"group",position:{x:0,y:0},rotation:0,scale:{x:1,y:1},order:s,style:{}},l=e,c=[],u=Je(l,i);l=u.scene,c.push(u.patch);for(let d of o){let f=le(l,d.id,p=>({...p,parentId:n}));l=f.scene,c.push(f.patch)}return{scene:l,patches:c,groupId:n}},H5=(e,t)=>{let n=[...t].map(s=>M(e,s)).filter(s=>s!==void 0&&Oe(s));if(n.length===0)return null;let o=e,a=[],r=new Set;for(let s of n){let i=[...o.elements.values()].filter(c=>c.parentId===s.id);for(let c of i){let u=le(o,c.id,d=>{let f={...d};return delete f.parentId,f});o=u.scene,a.push(u.patch),r.add(c.id)}let l=jn(o,s.id);o=l.scene,a.push(l.patch)}return{scene:o,patches:a,nextSelection:r}},U5=(e,t,n)=>{let o=[...e.layers.values()].filter(l=>l.visible&&!l.locked).sort(vt),a=[];for(let l of o){let c=[...e.elements.values()].filter(u=>u.layerId===l.id).sort(vt);for(let u of c)a.push(u.id)}if(a.length===0)return null;let r=t?a.indexOf(t):-1;n==="next"?r=r===-1?0:(r+1)%a.length:r=r===-1?a.length-1:(r-1+a.length)%a.length;let s=a[r];if(!s)return null;let i=M(e,s);return{id:s,name:i?Mb(i):s}},G5=e=>Qe(`group-${e}-${Date.now().toString(36)}`);var q5=(e,t,n,o)=>{if(n.x===0&&n.y===0)return null;let a=e,r=[],s=0;for(let i of t){let l=M(a,i);if(!l||o(l.layerId))continue;let c=le(a,i,u=>({...u,position:{x:u.position.x+n.x,y:u.position.y+n.y}}));a=c.scene,r.push(c.patch),s++}return s===0?null:{scene:a,patches:r,moved:s}},W5=(e,t,n)=>{if(t.size===0&&n.size===0)return null;let o=e,a=[],r=new Set,s=i=>{if(r.has(i)||!o.links.has(i))return;let l=lf(o,i);o=l.scene,a.push(l.patch),r.add(i)};for(let i of t){for(let c of[...o.links.values()])(c.from.kind!=="point"&&c.from.elementId===i||c.to.kind!=="point"&&c.to.elementId===i)&&s(c.id);let l=jn(o,i);o=l.scene,a.push(l.patch)}for(let i of n)s(i);return{scene:o,patches:a}},j5=(e,t,n)=>{let o=[...t];if(o.length===0)return null;let a=e,r=[],s=[];for(let i of o){let l=M(a,i);if(!l)continue;let c=Qe(`shape-${n()}-${Date.now().toString(36)}`),u=we([...a.elements.values()].filter(p=>p.layerId===l.layerId).map(p=>p.order)),d={...l,id:c,position:{x:l.position.x+10,y:l.position.y+10},order:u},f=Je(a,d);a=f.scene,r.push(f.patch),s.push(c)}return{scene:a,patches:r,newIds:s}},V5=(e,t,n)=>{let o=Ne;for(let a of t)e.elements.has(a)&&(o=xn(o,a));return Rs(o,n)?null:o},Z5=(e,t)=>{let n=Ne;for(let o of e.elements.values()){let a=e.layers.get(o.layerId);!a||!a.visible||a.locked||(n=xn(n,o.id))}return Rs(n,t)?null:n},X5=e=>{let t=new Set;for(let n of e.links.values()){let o=e.layers.get(n.layerId);!o||!o.visible||o.locked||t.add(n.id)}return t},Y5=(e,t,n)=>{let o=[];for(let i of t)e.elements.has(i)&&o.push(i);if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=le(a,i,c=>({...c,style:{...c.style,...n}}));a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},K5=(e,t,n)=>{let o=[];for(let i of t){let l=M(e,i);l!==void 0&&Fe(l)&&o.push(i)}if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=le(a,i,c=>({...c,...n}));a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},$5=(e,t,n)=>{let o=n==="increase",a=o?t2:1/t2,r=e,s=[];for(let l of t){let c=M(r,l);if(c===void 0||!Fe(c))continue;let u=Math.round(c.fontSize*a),d=o?Math.max(c.fontSize+1,u):Math.min(c.fontSize-1,u),f=Math.min(FT,Math.max(Hm,d));if(f===c.fontSize)continue;let p=le(r,l,h=>({...h,fontSize:f}));r=p.scene,s.push(p.patch)}let i=s[0];return i===void 0?null:{scene:r,patch:s.length===1?i:{kind:"batch",patches:s}}},Q5=(e,t)=>{let n=[];return e.x>0?n.push(`${e.x} px right`):e.x<0&&n.push(`${-e.x} px left`),e.y>0?n.push(`${e.y} px down`):e.y<0&&n.push(`${-e.y} px up`),`Moved ${t===1?"shape":`${t} shapes`} ${n.join(" and ")}`},NA=e=>{let t=Ne;for(let n of e)t=xn(t,n);return t},J5=(e,t,n,o,a)=>{let r=n==="left"?{x:-1,y:0}:n==="right"?{x:1,y:0}:n==="up"?{x:0,y:-1}:{x:0,y:1},s=null,i=1/0;for(let l of e.elements.values()){if(l.parentId!==void 0||t.has(l.id)||!a(l))continue;let c=z(l),u=c.x+c.width/2-o.x,d=c.y+c.height/2-o.y,f=u*r.x+d*r.y;if(f<=0)continue;let p=Math.abs(u*r.y-d*r.x);if(p>f)continue;let h=f+p;h<i&&(i=h,s=l.id)}return s};var e9=/^(https?:|mailto:)/i,NF=/^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/,t9=e=>{let t=e.trim();return t===""?null:e9.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t)?null:NF.test(t)?`mailto:${t}`:`https://${t}`},T0=e=>e&&e9.test(e.trim())?e.trim():null,n9=(e,t,n)=>{let o=[];for(let i of t){let l=M(e,i);l&&(l.href??null)!==n&&o.push(i)}if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=le(a,i,c=>{let u={...c};return n===null?delete u.href:u.href=n,u});a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},FF=(e,t,n)=>{if(t.kind==="anchor"){let o=t.metadata?.ref;if(o)return{kind:"anchor",elementId:e,anchor:o}}return t.kind==="outline"&&typeof t.metadata?.ratio=="number"?{kind:"outline",elementId:e,ratio:t.metadata.ratio}:{kind:"point",position:t.snapped}},o9=(e,t,n,o,a)=>{let r=t.snap({scene:e,probe:a,threshold:n,gesture:"draw-edge"}),s=u=>{if(o!==null){let d=r.all.find(f=>f.kind===u&&f.metadata?.elementId===o);if(d)return d}return r.all.find(d=>d.kind===u)},i=(u,d)=>{if(!u)return null;let f=u.metadata?.elementId;if(f===void 0)return null;let p=M(e,f);if(!p)return null;let h=FF(f,u,p);return h.kind===d?h:null},l=i(s("anchor"),"anchor");if(l)return l;let c=i(s("outline"),"outline");return c||(o!==null&&M(e,o)?{kind:"floating",elementId:o}:{kind:"point",position:a})};var HF=Rr.rectangle,UF=Rr.ellipse,FA=(e,t,n,o,a,r)=>{let s=Array.from(e.elements.values()).filter(c=>c.layerId===a).map(c=>c.order),i=t==="frame"?Bl(s):we(s),l={id:o,layerId:a,position:{x:n.x,y:n.y},rotation:0,scale:{x:1,y:1},order:i,width:n.width,height:n.height};return t==="rect"?{...l,type:"rectangle",style:{...HF}}:t==="ellipse"?{...l,type:"ellipse",style:{...UF}}:{...l,type:"frame",style:{fill:jC},name:r()}},a9=(e,t,n,o,a)=>{let r=we(Array.from(e.links.values()).filter(s=>s.layerId===a).map(s=>s.order));return{id:o,layerId:a,from:t,to:n,order:r,routing:Rm,style:{...M2},arrowheads:{to:DC}}},r9=(e,t,n,o)=>{let a=a9(e,{kind:"point",position:t.from},{kind:"point",position:t.to},n,o);return t.points&&t.points.length>2?{...a,routedPoints:t.points.slice(1,-1)}:a},s9=(e,t,n,o,a,r)=>{let s=FA(e,t,n,o,a,r),i=Je(e,s);return{scene:i.scene,patch:i.patch,elementId:o}},Zf=(e,t,n,o,a)=>{let r=a9(e,t,n,o,a),s=wb(e,r);return{scene:s.scene,patch:s.patch,linkId:o}},I0=e=>`shape-${e}-${Date.now().toString(36)}`,HA=e=>`edge-${e}-${Date.now().toString(36)}`;var i9=(e,t,n,o,a)=>{let r=we([...e.elements.values()].filter(c=>c.layerId===o).map(c=>c.order)),s=t==="draw-ellipse"?"ellipse":"rectangle",i=120,l=80;return{id:a,layerId:o,type:s,position:{x:n.x-i/2,y:n.y-l/2},rotation:0,scale:{x:1,y:1},order:r,style:{fill:"#bbb",stroke:"#000",strokeWidth:1},width:i,height:l}},l9=(e,t,n,o)=>{let a=we([...e.elements.values()].filter(r=>r.layerId===n).map(r=>r.order));return{id:o,layerId:n,type:"text",position:{x:t.x,y:t.y},rotation:0,scale:{x:1,y:1},order:a,text:"",fontFamily:ET,fontSize:IT,style:{fill:MT,textAlign:"left",textBaseline:"top"}}},GA=e=>Qe(`shape-${e}-${Date.now().toString(36)}`),c9=(e,t,n)=>{let o={...t.current,position:{x:n.x-t.halfWidth,y:n.y-t.halfHeight}},a={kind:"element",id:t.current.id,before:t.current,after:o};return{scene:J(e,a),patch:a,next:o}},u9=(e,t)=>{let n={x:t.current.position.x+t.halfWidth,y:t.current.position.y+t.halfHeight},o=Kd(e,n,new Set([t.current.id]));if(!o)return null;let a={...t.current,parentId:o.id},r={kind:"element",id:t.current.id,before:t.current,after:a};return{scene:J(e,r),patch:r,next:a}},d9=e=>{let t=z(e);return{scene:n=>{let o=Je(n,e);return{scene:o.scene,patch:o.patch}},state:{current:e,halfWidth:t.width/2,halfHeight:t.height/2}}},f9=(e,t)=>({scene:jn(e,t).scene}),UA="__ghost-preview__",sc="__ghost-preview-link__",p9=(e,t,n,o)=>{let a=M(e,n);if(!a)return null;let r={kind:"named",name:o},s=Eo(a,r),i=z(a),l=Math.abs(s.x)*i.width+Math.abs(s.y)*i.height,c=l+Hb,u={x:s.x*c,y:s.y*c},d={x:i.x+u.x,y:i.y+u.y,width:i.width,height:i.height},f=Gt(a,r),p=d.x+d.width/2,h=d.y+d.height/2,m={x:p-s.x*(l/2),y:h-s.y*(l/2)},b={...a,id:UA,position:{x:a.position.x+u.x,y:a.position.y+u.y}};Fe(b)?b={...b,text:""}:He(b)&&(b={...b,name:""});let y={x:i.x+i.width/2,y:i.y+i.height/2},g=Je(e,b).scene,x=L(M(g,UA)),{ref:A}=Sa(x,y,uo(x)),_=Zf(g,{kind:"anchor",elementId:n,anchor:r},{kind:"anchor",elementId:UA,anchor:A},sc,t).scene,v=L(be(_,sc));if((v.routing??"straight")==="orthogonal"){let I=pf(_,v);_=et(_,sc,k=>({...k,routedPoints:I})).scene}return _={..._,links:new Map([[sc,L(be(_,sc))]])},{bounds:d,path:[f,m],element:b,ghostScene:_,ghostLinkId:sc}},h9=(e,t,n,o,a,r)=>{let s=M(e,n);if(!s)return null;let i={kind:"named",name:o},l=Eo(s,i),c=z(s),u={x:c.x+c.width/2,y:c.y+c.height/2},f=Math.abs(l.x)*c.width+Math.abs(l.y)*c.height+Hb,p={x:l.x*f,y:l.y*f},h=we([...e.elements.values()].filter(A=>A.layerId===s.layerId).map(A=>A.order)),m={...s,id:a,position:{x:s.position.x+p.x,y:s.position.y+p.y},order:h};Fe(m)?m={...m,text:""}:He(m)&&(m={...m,name:""});let b=Je(e,m),y=L(M(b.scene,a)),{ref:g}=Sa(y,u,uo(y)),x=Zf(b.scene,{kind:"anchor",elementId:n,anchor:i},{kind:"anchor",elementId:a,anchor:g},r,t);return{scene:x.scene,addPatch:b.patch,linkPatch:x.patch}},m9=(e,t,n)=>{let o=e,a=[];for(let r of t){let s=M(o,r);if(!s)continue;let i=n.get(r);if(i===void 0)continue;let l=we([...o.elements.values()].filter(d=>d.layerId===s.layerId).map(d=>d.order)),c={...s,id:i,order:l};if(c.parentId!==void 0){let d=n.get(c.parentId);d!==void 0&&(c.parentId=d)}if(c.frameId!==void 0){let d=n.get(c.frameId);d!==void 0&&(c.frameId=d)}let u=Je(o,c);o=u.scene,a.push(u.patch)}return{scene:o,patches:a}},y9=(e,t,n,o,a)=>{let r=we([...e.elements.values()].filter(d=>d.layerId===t).map(d=>d.order)),s=a({id:o,layerId:t,position:n.world,order:r}),i=z(s),l={...s,position:{x:s.position.x+(n.world.x-(i.x+i.width/2)),y:s.position.y+(n.world.y-(i.y+i.height/2))}},c=Je(e,l),u=et(c.scene,n.linkId,d=>({...d,[n.side]:{kind:"floating",elementId:o}}));return{scene:u.scene,addPatch:c.patch,linkPatch:u.patch}};var GF="__draw-preview__",g9="__draw-preview-link__",x9=e=>{if(e.backgroundTarget){e.gridEnabled?Mf(e._scene,e.backgroundTarget):e.backgroundTarget.clear();let d=[];for(let f of e._selection){let p=M(e._scene,f);if(!p)continue;let h=p.style??{};d.push({loops:Zd(e._scene,p),outsetWorld:F1(h)})}d.length>0&&vE(e.backgroundTarget,qn(e._scene.viewport),d,e._scene.viewport.zoom||1)}let t=e.computeViewportWorld(),n=e.computeDirtyWorld(),o=e._enteredGroup?e.computeDimElements(e._enteredGroup):void 0,a=e.computeHiddenElements();if(e.tileComposeFn&&t)e.mainTarget.clear(),e.tileComposeFn(e._scene,e.mainTarget,{viewport:t,changedElements:e.tileDirtyElements,zoomBucket:e._scene.viewport.zoom>0?2**Math.round(Math.log2(e._scene.viewport.zoom)):1}),e.tileDirtyElements=new Map,No(e._scene,e.mainTarget,{viewportWorld:t});else{let d=e._scene.elements.size>=Fm?e.ensureSpatialIndex():null;Js(e._scene,e.mainTarget,{...t?{viewport:t}:{},...n?{dirtyWorld:n}:{},boundsCache:e.boundsCache,lod:O2,...o?{dimElements:o,dimOpacity:cT}:{},...a?{hideElements:a}:{},...d?{spatialIndex:d}:{}}),No(e._scene,e.mainTarget,{...t?{viewportWorld:t}:{},...n?{dirtyWorld:n}:{}})}e.lastRenderedScene=e._scene,e.lastRenderedEnteredGroup=e._enteredGroup;let r={},s=null;if(e.lassoPreview)r.drawingPreview=e.lassoPreview;else if(e.drawingPreview){let d=e.mode==="draw-rect"?"rect":e.mode==="draw-ellipse"?"ellipse":null;d?r.drawingPreviewElement=FA(e._scene,d,e.drawingPreview,GF,e._activeLayerId,()=>""):r.drawingPreview=e.drawingPreview}let i=null;if(e.edgePreview){let d=r9(e._scene,e.edgePreview,g9,e._activeLayerId);i={...e._scene,links:new Map([[g9,d]])}}if(e.mode!=="brush"&&e.mode!=="hand"){let d=e._scene.viewport.zoom||1,f=(m,b,y,g)=>{let x=M(e._scene,m);if(!x)return null;let A=b==="link-start"?fo:WC,{names:C,worldPoints:_}=ho(x,A/d),v=[..._],I=y!==null?C.indexOf(y):-1;b==="link-attach"&&g&&v.push(g);let k=I>=0?I:b==="link-attach"&&g?v.length-1:-1;return{worldPoints:v,...k>=0?{activeIndex:k}:{},role:b}},p=[];if(e.linkDragFromAnchor){let m=f(e.linkDragFromAnchor.fromElement,"link-start",null);if(m&&p.push(m),e.hoveredLinkTarget){let b=e.hoveredLinkTarget,y=f(b.elementId,"link-attach",b.activeAnchor,b.outlinePoint);y&&p.push(y)}}else if(e.hoveredLinkTarget){let m=e.hoveredLinkTarget,b=f(m.elementId,"link-attach",m.activeAnchor,m.outlinePoint);b&&p.push(b)}else if(!e.panGesture&&!e.pinch?.isActive()&&!e.gestureTx&&!e.edgePreview&&!e.linkEndpointDrag){let m=e.hoverCursorWorld;if(e._selection.size===1&&m){let b=L([...e._selection][0]),y=M(e._scene,b);if(y){let g=z(y),x=(fo+Ro+e.anchorStartHitSlop)/d;if(m.x>=g.x-x&&m.x<=g.x+g.width+x&&m.y>=g.y-x&&m.y<=g.y+g.height+x){let C=f(b,"link-start",null);if(C){let T=VC/d,P=-1,N=T*T;if(C.worldPoints.forEach((U,q)=>{let te=U.x-m.x,Z=U.y-m.y,ue=te*te+Z*Z;ue<=N&&(N=ue,P=q)}),P>=0){let U=T>0?Math.max(0,1-Math.sqrt(N)/T):0,q=hf+(HC-hf)*U;p.push({...C,activeIndex:P,activeRadius:q})}else p.push(C)}let{names:_,worldPoints:v}=ho(y,fo/d),I=(e.anchorClickRadius/d)**2,k=null;for(let T=0;T<v.length;T++){let P=L(v[T]);if((P.x-m.x)**2+(P.y-m.y)**2<=I){k=L(_[T]);break}}if(k){let T=e.previewClickCreate(b,k);T&&(r.ghostElement=T.bounds,r.ghostElementShape=T.element,s=T.ghostScene)}}}}}p.length===1?r.ports=L(p[0]):p.length>1&&(r.ports=p);let h=e.hoveredLinkTarget;if(h?.mode==="element"){let m=M(e._scene,h.elementId);m&&(r.linkAttachHighlight=z(m))}}if(e._selection.size+e._selectedLinks.size>1||e.selectionIsAspectLocked()){let d=e.combinedSelectionBounds();d&&(r.groupBounds=d),e.selectionIsAspectLocked()&&(r.groupAspectLocked=!0)}if(e.containerHover&&(r.containerDropZone=e.containerHover.dropZone),e.brushStroke&&(r.brushPreview={origin:e.brushStroke.origin,points:e.brushStroke.points,fill:"#222"}),e._selectedLinks.size>0){let d=[];for(let f of e._selectedLinks){let p=be(e._scene,f);if(!p)continue;let h=Dl(e._scene,p);h&&h.length>=2&&d.push({path:h,width:p.style.strokeWidth??1})}d.length>0&&(r.selectedLinkPaths=d)}let l=e.selectedLink;if(l){let d=be(e._scene,l);if(d){let f=rt(e._scene,d);if(f&&f.length>=2){let p=L(f[0]),h=L(f[f.length-1]);if((d.routing??"straight")==="orthogonal"){let b=[];if(!e.linkSegmentDrag&&!e.linkEndpointDrag){let y=f.length===2?[0]:Array.from({length:Math.max(0,f.length-3)},(g,x)=>x+1);for(let g of y){let x=L(f[g]),A=L(f[g+1]);b.push({x:(x.x+A.x)/2,y:(x.y+A.y)/2})}}r.edgeSelection={from:p,to:h,midpoints:b}}else{let b=[...d.waypoints??[]],y=e.linkWaypointDrag?[]:of(e._scene,d)??[];r.edgeSelection={from:p,to:h,waypoints:b,midpoints:y}}}}}e._peerCursors.length>0&&(r.peerCursors=e._peerCursors),e._peerSelections.length>0&&(r.peerSelections=e._peerSelections),e._scene.annotations.size>0&&(r.annotations=[...e._scene.annotations.values()],r.selectedAnnotation=e._selectedAnnotation);let c=[];for(let d of e._scene.elements.values())Ut(d)&&d.animationKind&&e.isPlaybackPaused(d.id)&&c.push(z(d));c.length>0&&(r.gifBadges=c);let u=e.editingTextOverlay();if(u&&(r.editingText=u),e.debugHitZones){r.debugHitZones=!0;let d=e.linkDragFromAnchor!==null||e.edgePreview!==null||e.linkEndpointDrag!==null,f=e.groupMoveOrigin!==null&&e.gestureTx!==null,p=d0({linkDragActive:d,elementDragActive:f});if(r.debugHitZoneVisibility=p,p.attachDropZones){let h=e.linkDragFromAnchor?.fromElement,m=[],b=[];for(let y of e._scene.elements.values())if(y.id!==h){m.push(...ho(y,0).worldPoints);for(let g of Zd(e._scene,y))b.push(g)}r.debugAttachZones={anchors:m,outlineLoops:b,thresholdWorld:12}}if(p.containerDropZones){let h=e.groupMoveOrigin,m=[],b=[];for(let y of e._scene.elements.values())if(!h?.has(y.id)){if(He(y)){m.push(z(y));continue}b.push(...$1(y))}r.debugContainerZones={frames:m,containers:b}}}LE(e._scene,e._selection,e.overlayTarget,r),s&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(zm),No(s,e.overlayTarget,{}),e.overlayTarget.restore()),i&&No(i,e.overlayTarget,{})};var b9=e=>{let t=e.viewport,n=t.size.width,o=t.size.height;if(n<=0||o<=0)return null;let a=ka(t),r=[B.applyToPoint(a,{x:0,y:0}),B.applyToPoint(a,{x:n,y:0}),B.applyToPoint(a,{x:0,y:o}),B.applyToPoint(a,{x:n,y:o})],s=X.fromPoints(r);return X.expand(s,Math.max(s.width,s.height)*.05)},E0=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=Oe(o)?E0(e,o.id):z(o);a&&(n=n?X.union(n,a):a)}return n},A9=(e,t)=>{let n=null;for(let o of t){let a=M(e,o);if(!a)continue;let r=Oe(a)?E0(e,a.id):z(a);r&&(n=n?X.union(n,r):r)}return n};var v9=e=>{let t=null;for(let n of e.elements.values())Ol(e,n)&&(t??=new Set,t.add(n.id));return t??void 0};var L9=(e,t,n,o,a)=>{let r=bm(e,o,Qb),s=a==="replace"?Ne:t;for(let i of r)n(i.layerId)||(s=xn(s,i.id));return s},S9=(e,t,n,o,a)=>{let r=a==="replace"?Ne:t,s=bm(e,o,Qb);for(let i of s)n(i.layerId)||(r=xn(r,i.id));return r},qF=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,WA=(e,t,n,o,a)=>{let r=a==="replace"?kt:t;for(let s of e.links.values()){if(n(s.layerId))continue;let i=rt(e,s);!i||i.length<2||i.every(l=>qF(l,o))&&(r=DA(r,s.id))}return r};var k9=(e,t,n,o)=>{let a=n;if(t){let i=M(e,t);i&&(a=Sa(i,n,uo(i)).world)}let r=o,s=Xd(e,o);return s&&(r=Sa(s,o,uo(s)).world),{from:a,to:r}},w9=(e,t,n)=>{let o=be(e,t.linkId);if(!o)return null;let a=n(t.toElement,t.toPoint),r=et(e,o.id,s=>({...s,[t.side]:a}));return{scene:r.scene,patch:r.patch,linkId:o.id}},_9=(e,t)=>{let n=a=>{if(a.kind==="point")return`p:${a.position.x},${a.position.y}`;let r=M(e,a.elementId),s=r?z(r):null,i=a.kind==="anchor"?JSON.stringify(a.anchor):a.kind==="outline"?`o:${a.ratio}`:"f";return`${a.kind}:${a.elementId}:${i}:${s?`${s.x},${s.y},${s.width},${s.height}`:"x"}`},o=`${n(t.from)}|${n(t.to)}|${JSON.stringify(t.fixedSegments??null)}`;if(t.avoidObstacles===!0){let a="|avoid:";for(let r of e.elements.values()){let s=z(r);a+=`${r.id},${s.x},${s.y},${s.width},${s.height};`}return o+a}return o};var jA=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:e.x,y:0}:{x:0,y:e.y},C9=(e,t,n,o)=>{let a=M(e,t);if(!a)return null;let r=z(a),s=o.x-r.x,i=o.y-r.y,l={...a,position:{x:a.position.x+n.x+s,y:a.position.y+n.y+i}};return{kind:"element",id:t,before:a,after:l}},T9=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=M(e,a);if(!s)continue;let i={...s,position:{x:r.x+n.x,y:r.y+n.y}};i.position.x===s.position.x&&i.position.y===s.position.y||o.push({kind:"element",id:a,before:s,after:i})}return o},I9=(e,t,n,o)=>{let a=e.annotations.get(t);if(!a)return null;let r={x:o.x+n.x,y:o.y+n.y},s=r;if(a.elementId){let l=M(e,a.elementId);l&&(s={x:r.x-l.position.x,y:r.y-l.position.y})}if(s.x===a.position.x&&s.y===a.position.y)return null;let i=wa(e,t,l=>({...l,position:s}));return{scene:i.scene,patch:i.patch}};var VA=(e,t)=>{let n=[];for(let o of t){let a=M(e,o);a&&n.push(a)}return n},ZA=e=>e.map(t=>z(t)).reduce((t,n)=>X.union(t,n)),E9=(e,t,n)=>{let o=VA(e,t);if(o.length===0)return[];let a=ZA(o),r=a.x+a.width/2,s=a.y+a.height/2,i=n==="horizontal",l=[];for(let c of o){let u=i?{...c,position:{x:2*r-c.position.x,y:c.position.y},scale:{x:-c.scale.x,y:c.scale.y}}:{...c,position:{x:c.position.x,y:2*s-c.position.y},scale:{x:c.scale.x,y:-c.scale.y}};l.push({kind:"element",id:c.id,before:c,after:u})}return l},M9=(e,t,n)=>{let o=VA(e,t);if(o.length<2)return[];let a=ZA(o),r=[];for(let s of o){let i=z(s),l=0,c=0;switch(n){case"left":l=a.x-i.x;break;case"right":l=a.x+a.width-(i.x+i.width);break;case"h-center":l=a.x+a.width/2-(i.x+i.width/2);break;case"top":c=a.y-i.y;break;case"bottom":c=a.y+a.height-(i.y+i.height);break;case"v-center":c=a.y+a.height/2-(i.y+i.height/2);break}if(l===0&&c===0)continue;let u={...s,position:{x:s.position.x+l,y:s.position.y+c}};r.push({kind:"element",id:s.id,before:s,after:u})}return r},O9=(e,t,n)=>{let o=VA(e,t);if(o.length<3)return[];let a=n==="horizontal",r=m=>a?m.x:m.y,s=m=>a?m.width:m.height,i=o.map(m=>({el:m,b:z(m)})).sort((m,b)=>r(m.b)-r(b.b)),l=i[0],c=i[i.length-1];if(!l||!c)return[];let u=r(c.b)+s(c.b)-r(l.b),d=i.reduce((m,b)=>m+s(b.b),0),f=(u-d)/(i.length-1),p=[],h=r(l.b)+s(l.b)+f;for(let m=1;m<i.length-1;m++){let b=i[m];if(!b)continue;let y=h-r(b.b);if(y!==0){let g=a?{...b.el,position:{x:b.el.position.x+y,y:b.el.position.y}}:{...b.el,position:{x:b.el.position.x,y:b.el.position.y+y}};p.push({kind:"element",id:b.el.id,before:b.el,after:g})}h+=s(b.b)+f}return p},XA=(e,t,n,o)=>{let a=Math.cos(o),r=Math.sin(o),s=[];for(let[i,l]of t){let c=M(e,i);if(!c)continue;let u=l.position.x-n.x,d=l.position.y-n.y,f={...c,position:{x:n.x+(u*a-d*r),y:n.y+(u*r+d*a)},rotation:l.rotation+o};s.push({kind:"element",id:i,before:c,after:f})}return s},R9=e=>{let t=ZA(e);return{x:t.x+t.width/2,y:t.y+t.height/2}};var M0=(e,t)=>({x:Math.round(e.x/t)*t,y:Math.round(e.y/t)*t}),B9=(e,t,n)=>{let o=M0({x:e.x+t.x,y:e.y+t.y},n);return{x:o.x-e.x,y:o.y-e.y}},z9=(e,t,n)=>{let o=1/0,a=1/0;for(let s of e.values())s.x<o&&(o=s.x),s.y<a&&(a=s.y);if(!Number.isFinite(o))return t;let r=M0({x:o+t.x,y:a+t.y},n);return{x:r.x-o,y:r.y-a}},D9=new Set(["nw","w","sw"]),WF=new Set(["ne","e","se"]),P9=new Set(["nw","n","ne"]),jF=new Set(["sw","s","se"]),YA=(e,t,n,o)=>{let a=n.x,r=n.y;if(D9.has(t)||WF.has(t)){let s=D9.has(t)?e.x:e.x+e.width;a=Math.round((s+n.x)/o)*o-s}if(P9.has(t)||jF.has(t)){let s=P9.has(t)?e.y:e.y+e.height;r=Math.round((s+n.y)/o)*o-s}return{x:a,y:r}},N9=(e,t)=>{let n=M0({x:e.x,y:e.y},t),o=M0({x:e.x+e.width,y:e.y+e.height},t);return{x:n.x,y:n.y,width:Math.max(0,o.x-n.x),height:Math.max(0,o.y-n.y)}};var Xf=class{host;mainTarget;overlayTarget;backgroundTarget;onAfterRender;debugHitZones=!1;actor;listeners=new Set;events=AA();eventCache=A4();unbind;_scene;_selection=Ne;annotationDrag=null;drawingPreview=null;edgePreview=null;linkDragFromAnchor=null;hoveredLinkTarget=null;hoverCursorWorld=null;pendingLinkDropMenu=null;_selectedLinks=kt;_selectedAnnotation=null;commentAuthor={id:"local",name:"You"};linkEndpointDrag=null;linkWaypointDrag=null;linkSegmentDrag=null;lassoPreview=null;lassoBaseSelection=null;lassoBaseLinks=null;groupMoveOrigin=null;groupLinkMoveOrigin=null;groupResizeOrigin=null;rotateGestureOrigin=null;_resizeOriginElement=null;_activeLayerId=$t(bn);nextId=0;uniqueId(t){return`${t}-${++this.nextId}-${Date.now().toString(36)}`}snapEngine=new rf([ub,db,fb]);snapThreshold=12;snapSuppressed=!1;transformAltKey=!1;transformShiftKey=!1;styleClipboard=null;boundsCache=new Mr;spatialIndexCache=null;_enteredGroup=null;lastClickAt=0;lastClickWorldPoint=null;lastHandleClickAt=0;lastHandleClickWorld=null;brushStroke=null;lastPointerWorld=null;cursorOverrides=new Map;lastRenderedScene=null;lastRenderedEnteredGroup=null;autoCompactScheduler=new m0({getScene:()=>this._scene,compact:t=>{this.compactLayerZOrder(t,{recordHistory:!1})}});autoLayoutScheduler=new y0({getScene:()=>this._scene,applyPatch:t=>{this._scene=J(this._scene,t),this.gestureTx?this.gestureTx.add(t):this._history.push(t)},growContainer:(t,n)=>{this.maybeGrowContainer(t,n)},onMutated:()=>{this.scheduleRender();for(let t of this.listeners)t()}});dragElementId=null;additivePressAdded=null;containerHover=null;_peerCursors=[];_peerSelections=[];cursorListeners=new Set;activePointers=new Map;touchPanCandidate=null;pinch;containerOpsRef;spaceHeld=!1;tileComposeFn;tileDirtyElements=new Map;_toolLocked=!1;fileDropRegistry=new qf;panGesture=null;suppressNextContextMenu=!1;longPress;longPressListeners=new Set;announceListeners=new Set;inputMode;handleHitSlop;edgeHandleHitSlop;edgeHitThreshold;anchorStartHitSlop;anchorClickRadius;_history;gestureTx=null;gestureStartScene=null;gestures;constructor(t){this.host=t.host,this.mainTarget=t.mainTarget,this.overlayTarget=t.overlayTarget,this.backgroundTarget=t.backgroundTarget??null,this.onAfterRender=t.onAfterRender??null,this._scene=t.initialScene,this._history=VF(t.history)?t.history:new Gf(t.history??{});let n=this;this.gestures=new A0({get history(){return n._history},get gestureTx(){return n.gestureTx},set gestureTx(r){n.gestureTx=r},get groupMoveOrigin(){return n.groupMoveOrigin},set groupMoveOrigin(r){n.groupMoveOrigin=r},get groupLinkMoveOrigin(){return n.groupLinkMoveOrigin},set groupLinkMoveOrigin(r){n.groupLinkMoveOrigin=r},get groupResizeOrigin(){return n.groupResizeOrigin},set groupResizeOrigin(r){n.groupResizeOrigin=r},get dragElementId(){return n.dragElementId},set dragElementId(r){n.dragElementId=r},get containerHover(){return n.containerHover},set containerHover(r){n.containerHover=r},get toolLocked(){return n._toolLocked},get mode(){return n.mode},setMode:r=>{n.setMode(r)},notify:()=>{n.notify()}}),this.tileComposeFn=t.useTileCache===!0&&t.tileCompose?t.tileCompose:null,t.textShaper&&zf(t.textShaper),t.rasterizer&&Nf(t.rasterizer),H1((r,s,i,l)=>(this.mainTarget.setFont(s,i,{...l?.bold?{weight:"bold"}:{},...l?.italic?{style:"italic"}:{}}),this.mainTarget.measureText(r).width));let o=t.inputMode??"auto";o==="touch"?this.inputMode="touch":o==="mouse"?this.inputMode="mouse":typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?this.inputMode="touch":this.inputMode="mouse",this.handleHitSlop=this.inputMode==="touch"?dT:11,this.edgeHandleHitSlop=this.inputMode==="touch"?fT:Oo,this.edgeHitThreshold=this.inputMode==="touch"?pT:Dm,this.anchorStartHitSlop=this.inputMode==="touch"?hT:Pm,this.anchorClickRadius=this.inputMode==="touch"?mT:Bm,this.actor=Bo(RI),this.actor.subscribe({next:()=>{this.scheduleRender()}}),this.actor.on("*",r=>{this.applyEmit(r)}),this.actor.start(),this.fileDropRegistry.register(u4),this.fileDropRegistry.register(f4),t.initialMode&&this.actor.send({type:"SET_MODE",mode:t.initialMode}),this.longPress=new S0(r=>this.screenToWorld(r),r=>{for(let s of this.longPressListeners)s(r)}),this.pinch=new k0(r=>this.screenToWorld(r),(r,s)=>{this.zoomAt(r,s)},r=>{this.panBy(r)});let a=this;this.containerOpsRef={get scene(){return a._scene},get dragElementId(){return a.dragElementId},get containerHover(){return a.containerHover},applyPatch(r,s){a._scene=s,a.beginOrAttachGesture().add(r)}},this.unbind=this.bindPointerEvents(),this.animation.attach(),CA(this),this.maybeAnimate(),this.animationContentOff=eA(()=>{this.scheduleRender()}),this.forceRender(),L4(this.eventCache,this.observableSnapshot())}observableSnapshot(){return{mode:this.mode,selection:this._selection,selectedLinks:this._selectedLinks,scene:this._scene,canUndo:this.canUndo,canRedo:this.canRedo}}get scene(){return this._scene}get selection(){return this._selection}get mode(){return this.actor.getSnapshot().context.mode}get history(){return this._history}get canUndo(){return this._history.canUndo}get canRedo(){return this._history.canRedo}get hostElement(){return this.host}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}onCursorMove(t){return this.cursorListeners.add(t),()=>this.cursorListeners.delete(t)}setCommentAuthor(t){this.commentAuthor=t}get selectedAnnotation(){return this._selectedAnnotation}setSelectedAnnotation(t){this._selectedAnnotation!==t&&(this._selectedAnnotation=t,this.notify())}addAnnotation(t){let n=A5(this._scene,t,this.commentAuthor,o=>this.uniqueId(o));return this._scene=n.scene,this._history.push(n.patch),this._selectedAnnotation=n.id,this.notify(),this.announce("Annotation added"),n.id}removeAnnotation(t){let n=v5(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this._selectedAnnotation===t&&(this._selectedAnnotation=null),this.notify(),this.announce("Annotation removed"))}toggleAnnotationResolved(t){let n=L5(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify(),this.announce(n.wasResolved?"Annotation reopened":"Annotation resolved"))}addComment(t,n,o){let a=S5(this._scene,t,n,o??this.commentAuthor,r=>this.uniqueId(r));a&&(this._scene=a.scene,this._history.push(a.patch),this.notify())}removeComment(t,n){let o=k5(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}hitAnnotation(t){return w5(this._scene,t)}onLongPress(t){return this.longPressListeners.add(t),()=>this.longPressListeners.delete(t)}onAnnounce(t){return this.announceListeners.add(t),()=>this.announceListeners.delete(t)}announce(t){if(t)for(let n of this.announceListeners)n(t)}setPeerCursors(t){this._peerCursors=t,this.scheduleRender()}setPeerSelections(t){this._peerSelections=t,this.scheduleRender()}setDebugHitZones(t){this.debugHitZones!==t&&(this.debugHitZones=t,this.scheduleRender())}get gridEnabled(){return this._scene.viewport.gridEnabled}setGridVisible(t){this.setGrid({enabled:t})}toggleGrid(){this.setGrid({enabled:!this.gridEnabled})}get toolLocked(){return this._toolLocked}get selectedLinks(){return this._selectedLinks}get selectedLink(){return this._selection.size>0?null:X4(this._selectedLinks)}updateSelectedLink(t){let n=this.selectedLink;if(n===null)return;let o=et(this._scene,n,t);this._scene=o.scene,this._history.push(o.patch),this.notify()}registerFileDropHandler(t){this.fileDropRegistry.register(t)}unregisterFileDropHandler(t){this.fileDropRegistry.unregister(t)}async dispatchFileDrop(t,n){let o={editor:this,worldPoint:n};return this.fileDropRegistry.dispatch(t,o)}setToolLocked(t){this._toolLocked!==t&&(this._toolLocked=t,this.notify())}maybeRevertModeAfterCreate(){this.gestures.maybeRevertModeAfterCreate()}setMode(t){this._editingTextElement!==null&&this.commitTextEdit(),this.gestureTx&&(this.gestureTx.cancel(),this.gestureTx=null),t!=="draw-edge"&&this.hoveredLinkTarget!==null&&(this.hoveredLinkTarget=null),this.actor.send({type:"SET_MODE",mode:t}),this.refreshCursor(),this.notify()}undo(){let t=this._history.undo();return t?(this._scene=J(this._scene,t),this.pruneSelection(),this.notify(),!0):!1}redo(){let t=this._history.redo();return t?(this._scene=J(this._scene,t),this.pruneSelection(),this.notify(),!0):!1}addElement(t,n){let o=Je(this._scene,t);return this._scene=o.scene,(n?.select??!0)&&(this._selection=Mt(t.id)),this._history.push(o.patch),this.notify(),o.patch}insertImage(t){let n=Qe(this.uniqueId("img")),o=S4(this._scene,t,n,this._activeLayerId);return this.addElement(o),t.animated&&(this.gifPlayback.ensure(n),this.maybeAnimate()),n}async addBinaryFile(t,n){let o=await k4(this._scene,t,n,()=>++this.nextId);return this._scene=o.scene,this._history.push(o.patch),o.id}animation=new x0({hasVisibleAnimatedElement:()=>w4(this),autoStopHeavyGifs:()=>{_4(this)},forceAnimationRepaint:()=>{this.lastRenderedScene=null,this.render()}});hasAnimatedElement(){return L0(this._scene)}maybeAnimate(){this.animation.maybe()}gifPlayback=new v0;togglePlayback(t){this.gifPlayback.toggle(t),this.maybeAnimate(),this.scheduleRender()}hoverAnimatedElement(t){this.gifPlayback.hoverEnter(t)&&(this.maybeAnimate(),this.scheduleRender())}isPlaybackPaused(t){return this.gifPlayback.isPaused(t)}setHoverCursorWorld(t){this.hoverCursorWorld=t,this._selection.size===1&&this.notify()}get linkPreviewPath(){return this.edgePreview?.points??null}get linkAttachTarget(){let t=this.hoveredLinkTarget;return t?{elementId:t.elementId,mode:t.mode}:null}beginPlacement(t){let n=this._history.transaction(),{scene:o,state:a}=d9(t),r=o(this._scene);this._scene=r.scene,this._selection=Mt(t.id),this.notify();let s={...a};return{update:i=>{let l=c9(this._scene,s,i);this._scene=l.scene,s.current=l.next,this.notify()},commit:()=>{let i=u9(this._scene,s);i&&(this._scene=i.scene,s.current=i.next),n.add({kind:"element",id:t.id,before:null,after:s.current}),n.commit(),this.notify()},cancel:()=>{let{scene:i}=f9(this._scene,t.id);this._scene=i,n.cancel(),this._selection=Ne,this.notify()}}}deleteSelected(){let t=W5(this._scene,this._selection,this._selectedLinks);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),this._selection=Ne,this._selectedLinks=kt,this.notify()}_editingTextElement=null;get editingTextElement(){return this._editingTextElement}_editingLinkCaption=null;get editingLinkCaption(){return this._editingLinkCaption}_editingFrameName=null;get editingFrameName(){return this._editingFrameName}_pendingTextCreate=null;_textEditOrigin=null;_textSel=null;_textDragAnchor=null;caretBlink=new b0(()=>{this.notify()});get editingTextSelection(){return this._textSel}get editingTextCaret(){return this._textSel?this._textSel.dir==="backward"?this._textSel.start:this._textSel.end:null}get caretBlinkOn(){return this.caretBlink.on}get isTextDragging(){return this._textDragAnchor!==null}beginLinkCaptionEdit(t){be(this._scene,t)&&(this._editingTextElement!==null&&this.commitTextEdit(),this._editingLinkCaption=t,this.notify())}commitLinkCaptionEdit(t){let n=this._editingLinkCaption;if(this._editingLinkCaption=null,n===null){this.notify();return}let o=be(this._scene,n);if(o){let a=t.trim(),r=a===""?void 0:{...o.label??{},text:a};if(!((o.label?.text??"")===(r?.text??""))){let i=et(this._scene,n,l=>{let c={...l};return r?c.label=r:delete c.label,c});this._scene=i.scene,this._history.push(i.patch)}}this.notify()}cancelLinkCaptionEdit(){this._editingLinkCaption!==null&&(this._editingLinkCaption=null,this.notify())}linkLabelWorld(t){let n=be(this._scene,t);if(!n)return null;let o=rt(this._scene,n);if(!o||o.length<2)return null;let a=n.label?.position??.5,r=0;for(let i=1;i<o.length;i++)r+=Ae.distance(L(o[i-1]),L(o[i]));let s=r*a;for(let i=1;i<o.length;i++){let l=L(o[i-1]),c=L(o[i]),u=Ae.distance(l,c);if(s<=u){let d=u===0?0:s/u;return{x:l.x+(c.x-l.x)*d,y:l.y+(c.y-l.y)*d}}s-=u}return L(o[o.length-1])}beginTextEdit(t){if(!_5(this._scene,t,a=>this.isLayerLocked(a)))return;this._editingTextElement!==null&&this._editingTextElement!==t&&this.commitTextEdit(),this._editingTextElement=t,this._textEditOrigin=this._pendingTextCreate===t?null:M(this._scene,t)??null;let o=M(this._scene,t)?.text.length??0;this._textSel={start:o,end:o,dir:"forward"},this.caretBlink.start(),this.notify()}beginFrameNameEdit(t){let n=M(this._scene,t);n===void 0||!He(n)||this.isLayerLocked(n.layerId)||(this._editingTextElement!==null&&this.commitTextEdit(),this._editingFrameName=t,this.notify())}commitFrameNameEdit(t){let n=this._editingFrameName;if(n===null)return;this._editingFrameName=null;let o=T5(this._scene,n,t);o&&(this._scene=o.scene,this._history.push(o.patch)),this.notify()}cancelFrameNameEdit(){this._editingFrameName!==null&&(this._editingFrameName=null,this.notify())}frameHeaderAt(t){return C5(this._scene,t)}setEditingText(t,n,o,a="forward"){let r=this._editingTextElement;if(!r)return;let s=le(this._scene,r,i=>({...i,text:t}));this._scene=s.scene,this._textSel={start:n,end:o,dir:a},this.caretBlink.wake(),this.notify()}setEditingSelection(t,n,o="forward"){this._editingTextElement&&(this._textSel={start:t,end:n,dir:o},this.caretBlink.wake(),this.notify())}caretIndexAtWorldPoint(t){let n=this._editingTextElement;if(!n)return null;let o=M(this._scene,n);if(o?.type!=="text")return null;let a=this.editingTextLayout(o);if(!a)return null;let r=o.scale.x||1,s=o.scale.y||1,i={x:(t.x-o.position.x)/r,y:(t.y-o.position.y)/s},l=o.style.textAlign??"left";return $2(a,i,this.measureFor(o),l)}editedElementContainsPoint(t){let n=this._editingTextElement;if(!n)return!1;let o=M(this._scene,n);if(!o)return!1;let a=z(o);return t.x>=a.x&&t.x<=a.x+a.width&&t.y>=a.y&&t.y<=a.y+a.height}setTextCaretFromPoint(t){let n=this.caretIndexAtWorldPoint(t);n!==null&&(this._textDragAnchor=n,this.setEditingSelection(n,n,"forward"))}extendTextSelectionToPoint(t){if(this._textDragAnchor===null)return;let n=this.caretIndexAtWorldPoint(t);if(n===null)return;let o=this._textDragAnchor;n>=o?this.setEditingSelection(o,n,"forward"):this.setEditingSelection(n,o,"backward")}endTextDragSelect(){this._textDragAnchor=null}editingTextLayout(t){return Of(t.text,this.measureFor(t),{fontSize:t.fontSize,...t.maxWidth!==void 0?{maxWidth:t.maxWidth}:{}})}measureFor(t){let n=this.mainTarget;return n.setFont(t.fontFamily,t.fontSize,{...t.style.fontWeight==="bold"?{weight:"bold"}:{},...t.style.fontStyle==="italic"?{style:"italic"}:{}}),o=>n.measureText(o).width}editingTextOverlay(){let t=this._editingTextElement;if(!t||!this._textSel)return null;let n=M(this._scene,t);if(n?.type!=="text")return null;let o=this.editingTextLayout(n);if(!o)return null;let a=n.style.textAlign??"left",r=this.measureFor(n),{x:s,y:i}=n.position,l=n.scale.x,c=n.scale.y,d=Q2(o,this._textSel.start,this._textSel.end,r,a).map(p=>({x:s+Math.min(p.x*l,(p.x+p.width)*l),y:i+Math.min(p.y*c,(p.y+p.height)*c),width:Math.abs(p.width*l),height:Math.abs(p.height*c)})),f=null;if(this.caretBlink.on){let p=this._textSel.dir==="backward"?this._textSel.start:this._textSel.end,h=K2(o,p,r,n.fontSize,a);f={x:s+h.x*l,y:i+h.y*c,height:h.height*Math.abs(c)}}return{caret:f,caretColor:n.style.fill??"#1a1a1a",selectionRects:d}}commitTextEdit(t){let n=this._editingTextElement;if(!n)return;let o=this._pendingTextCreate===n,a=this._textEditOrigin;t!==void 0&&(this._scene=le(this._scene,n,i=>({...i,text:t})).scene),this._editingTextElement=null,this._pendingTextCreate=null,this._textEditOrigin=null,this._textSel=null,this.caretBlink.stop();let r=M(this._scene,n);if((r?.text??"").trim()===""){r&&(this._scene=jn(this._scene,n).scene,!o&&a&&this._history.push({kind:"element",id:n,before:a,after:null}),this._selection.has(n)&&(this._selection=Ne)),this.notify();return}if(o)r&&this._history.push({kind:"element",id:n,before:null,after:r});else if(a&&r){let i=a.text;if(i!==r.text){let l={...r,text:i};this._history.push({kind:"element",id:n,before:l,after:r})}}this.notify()}cancelTextEdit(){let t=this._editingTextElement;if(t===null)return;let n=this._pendingTextCreate===t,o=this._textEditOrigin;if(this._editingTextElement=null,this._pendingTextCreate=null,this._textEditOrigin=null,this._textSel=null,this.caretBlink.stop(),n)M(this._scene,t)&&(this._scene=jn(this._scene,t).scene,this._selection.has(t)&&(this._selection=Ne));else if(o){let a=o.text;this._scene=le(this._scene,t,r=>({...r,text:a})).scene}this.notify()}moveSelectionBy(t){if(this._selection.size===0&&this._selectedLinks.size===0)return;let n=new Set([...this.expandSelectionWithDescendants()].filter(i=>{let l=M(this._scene,i);return l?this.isElementManipulable(l):!1})),o=this._selection.size>0?q5(this._scene,n,t,i=>this.isLayerLocked(i)):null,a=o?o.scene:this._scene,r=G4(a,n,this._selectedLinks,t);if(!o&&r.patches.length===0)return;let s=this._history.transaction();if(this._scene=r.scene,o)for(let i of o.patches)s.add(i);for(let i of r.patches)s.add(i);s.commit(),this.notify(),this.announce(Q5(t,o?.moved??0))}createElementAtCursor(){let t=this._scene.viewport,n=this.screenToWorld({x:(t.size.width||200)/2,y:(t.size.height||200)/2}),o=GA(++this.nextId),a=i9(this._scene,this.mode,n,this._activeLayerId,o),r=Je(this._scene,a);return this._scene=r.scene,this._history.push(r.patch),this._selection=Mt(o),this.notify(),this.announce(`Created ${a.type} ${o}`),o}createTextAt(t){let n=GA(++this.nextId),o=l9(this._scene,t,this._activeLayerId,n),a=Je(this._scene,o);return this._scene=a.scene,this._pendingTextCreate=n,this._selection=Mt(n),this.maybeRevertModeAfterCreate(),this.notify(),this.announce(`Created text ${n}`),this.beginTextEdit(n),n}beginBrushStroke(t,n=.5){this.brushStroke=o5(t,n),this.notify()}extendBrushStroke(t,n=.5){this.brushStroke&&(a5(this.brushStroke,t,n),this.notify())}commitBrushStroke(){let t=r5(this._scene,this.brushStroke,this._activeLayerId,s5(++this.nextId));return t?(this._scene=t.scene,this._history.push(t.patch),this.brushStroke=null,this.notify(),t.elementId):(this.brushStroke=null,this.notify(),null)}cancelBrushStroke(){this.brushStroke&&(this.brushStroke=null,this.notify())}get pendingBrushStroke(){return this.brushStroke}arrangeAsGrid(t={}){let n=this.combinedSelectionBounds()??{x:0,y:0},o=B5(this._scene,this._selection,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify(),this.announce(`Arranged ${o.count} shapes on a ${o.cols}-column grid`))}arrangeAsStack(t={}){let n=this.combinedSelectionBounds()??{x:0,y:0},o=z5(this._scene,this._selection,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify(),this.announce(`Stacked ${o.count} shapes ${o.direction}`))}groupSelected(){let t=F5(this._scene,this._selection,G5(++this.nextId));if(!t)return{kind:"noop"};let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);return n.commit(),this._selection=Mt(t.groupId),this.notify(),{kind:"grouped",groupId:t.groupId}}ungroup(){let t=H5(this._scene,this._selection);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),this._selection=new Set(t.nextSelection),this.notify()}selectionRoots(){return zA(this._scene,this._selection)}expandSelectionWithDescendants(){return N5(this._scene,this._selection)}focusCycle(t){let n=[...this._selection][0],o=U5(this._scene,n,t);o&&(this._selection=Mt(o.id),this.notify(),this.announce(`Selected ${o.name}`))}cancelInteraction(){this.cancelGesture(),this.actor.send({type:"POINTER_CANCEL"}),this.drawingPreview=null,this.edgePreview=null,this.lassoPreview=null,this.linkDragFromAnchor=null,this.hoveredLinkTarget=null,this.hoverCursorWorld=null,this._editingLinkCaption=null,this.pendingLinkDropMenu=null,this.linkWaypointDrag=null,this.linkSegmentDrag=null,this.linkEndpointDrag=null,this._enteredGroup!==null&&(this._enteredGroup=null),this._selection=Ne,this._selectedLinks=kt,this.notify(),this.announce("Selection cleared")}duplicateSelected(){let t=j5(this._scene,this._selection,()=>++this.nextId);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),t.newIds.length>0&&(this._selection=NA(t.newIds)),this.notify()}duplicateSelectedInPlace(t=null){if(this._selection.size===0)return null;let n=new Set,o=l=>{if(!n.has(l)){n.add(l);for(let c of this._scene.elements.values())(c.parentId===l||c.frameId===l)&&o(c.id)}};for(let l of this._selection)o(l);let a=new Map;for(let l of n)a.set(l,Qe(this.uniqueId("shape")));let r=m9(this._scene,n,a),s=this._history.transaction();this._scene=r.scene;for(let l of r.patches)s.add(l);s.commit();let i=[];for(let l of this._selection){let c=a.get(l);c!==void 0&&i.push(c)}return i.length>0&&(this._selection=NA(i)),this.notify(),t!==null?a.get(t)??null:null}setSelection(t){let n=V5(this._scene,t,this._selection);n&&(this._selection=n,this._selectedLinks.size>0&&(this._selectedLinks=kt),this.notify())}selectAll(){let t=Z5(this._scene,this._selection),n=X5(this._scene),o=!w0(n,this._selectedLinks);if(!t&&!o)return;t&&(this._selection=t),this._selectedLinks=n,this.notify();let a=this._selection.size+this._selectedLinks.size;this.announce(`Selected ${a} objects`)}clipboard=[];copySelected(){let t=u5(this._scene,this._selection);t.length!==0&&(this.clipboard=[...t],this.announce(`Copied ${t.length} shapes`))}cutSelected(){this.copySelected(),this.deleteSelected()}paste(t){if(this.clipboard.length===0)return;this.finalizeOpenGestureTx();let n=t??this.lastPointerWorld,o=d5(this._scene,this._history,this.clipboard,n??null,()=>++this.nextId);this._scene=o.scene,this._selection=f5(o.newIds),this.notify(),this.announce(`Pasted ${o.newIds.length} shapes`)}copySelectionStyle(){for(let t of this._selection){let n=M(this._scene,t);if(n!==void 0){this.styleClipboard={...n.style};return}}}pasteSelectionStyle(){this.styleClipboard!==null&&this.updateStyle(this._selection,this.styleClipboard)}get hasStyleClipboard(){return this.styleClipboard!==null}updateStyle(t,n){let o=Y5(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}updateTextProps(t,n){let o=K5(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}adjustSelectionFontSize(t){let n=$5(this._scene,this._selection,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}setLink(t,n){let o=n===null?null:t9(n),a=n9(this._scene,t,o);a&&(this._scene=a.scene,this._history.push(a.patch),this.notify())}openLink(t){let n=T0(t);!n||typeof window>"u"||window.open(n,"_blank","noopener,noreferrer")}elementLink(t){return T0(M(this._scene,t)?.href)}linkAt(t){let n=this.acceleratedElementAt(t);if(!n||!this.isElementInteractable(n))return null;let o=T0(n.href);return o?{id:n.id,href:o,bounds:z(n)}:null}bringToFront(t){let n=M5(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}sendToBack(t){let n=O5(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}bringForward(t){let n=R5(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}sendBackward(t){let n=D5(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}flipSelection(t){this.commitArrange(E9(this._scene,this._selection,t))}alignSelection(t){this.commitArrange(M9(this._scene,this._selection,t))}distributeSelection(t){this.commitArrange(O9(this._scene,this._selection,t))}rotateSelection(t){let n=[],o=new Map;for(let r of this._selection){let s=M(this._scene,r);s!==void 0&&(n.push(s),o.set(r,{position:s.position,rotation:s.rotation}))}if(n.length===0)return;let a=R9(n);this.commitArrange(XA(this._scene,o,a,t))}commitArrange(t){if(t.length===0)return;let n=this._history.transaction();for(let o of t)this._scene=J(this._scene,o),n.add(o);n.commit(),this.notify()}compactLayerZOrder(t,n={}){let o=n.recordHistory??!0,a=t?[t]:[...this._scene.layers.keys()],r=o?this._history.transaction():null;if(P5(this._scene,a,(i,l)=>{this._scene=i,r?.add(l)})===0){r?.cancel();return}r?.commit(),this.notify(),o&&this.announce(`Compacted z-order across ${a.length} layer(s)`)}clear(){this._scene.elements.size===0&&this._scene.links.size===0||(this._scene={...this._scene,elements:new Map,links:new Map},this._selection=Ne,this._selectedLinks=kt,this._history.clear(),this.notify())}get activeLayerId(){return this._activeLayerId}setActiveLayer(t){this._scene.layers.has(t)&&this._activeLayerId!==t&&(this._activeLayerId=t,this.notify())}createLayer(t){let n=p5(this._scene,t,b5(++this.nextId));return this._scene=n.scene,this._history.push(n.patch),this._activeLayerId=n.layerId,this.notify(),n.layerId}removeLayer(t){let n=h5(this._scene,t,this._activeLayerId);if(!n)return;let o=this._history.transaction();this._scene=n.scene;for(let a of n.patches)o.add(a);o.commit(),this._activeLayerId=n.nextActiveLayerId,this._selection=Ne,this.notify()}renameLayer(t,n){let o=m5(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}toggleLayerVisibility(t){let n=y5(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}toggleLayerLock(t){let n=g5(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}moveSelectionToLayer(t){let n=x5(this._scene,this._selection,t);if(!n)return;let o=this._history.transaction();this._scene=n.scene;for(let a of n.patches)o.add(a);o.commit(),this.notify()}panBy(t){let n=Y4(this._scene,t);n&&(this._scene=n,this.notify())}zoomIn(){this.zoomStep(Xb)}zoomOut(){this.zoomStep(1/Xb)}zoomStep(t){let n=this._scene.viewport;if(n.size.width<=0||n.size.height<=0)return;let o=this.screenToWorld({x:n.size.width/2,y:n.size.height/2});this.zoomAt(t,o)}resetZoom(){let t=$4(this._scene);t&&(this._scene=t,this.notify())}zoomToFit(t=40){let n=Q4(this._scene,t);n&&(this._scene=n,this.notify())}zoomToSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=BA(this._scene,n,t);o&&(this._scene=o,this.notify())}selectClosest(t){let n=this.combinedSelectionBounds(),o=this._scene.viewport,a=n?{x:n.x+n.width/2,y:n.y+n.height/2}:{x:o.pan.x+o.size.width/2/o.zoom,y:o.pan.y+o.size.height/2/o.zoom},r=J5(this._scene,this._selection,t,a,s=>this.isElementInteractable(s));r!==null&&this.setSelection([r])}zoomAt(t,n){let o=K4(this._scene,t,n);o&&(this._scene=o,this.notify())}setViewportSize(t,n){let o=J4(this._scene,t,n);o&&(this._scene=o,this.notify())}setGrid(t){let n=e5(this._scene,t);n&&(this._scene=n,this.notify())}get snapToGridEnabled(){return km(this._scene.viewport)}setSnapToGrid(t){this.setGrid({snap:t})}setSnapSuppressed(t){this.snapSuppressed=t}setTransformModifiers(t){this.transformAltKey=t.alt,this.transformShiftKey=t.shift}snapActive(){let t=this._scene.viewport;return!this.snapSuppressed&&t.gridEnabled&&km(t)}snapSpacing(){return pb()}loadScene(t,n={}){if(this.gestureTx&&(this.gestureTx.cancel(),this.gestureTx=null),this._scene=t,!t.layers.has(this._activeLayerId)){let o=t.layers.keys().next().value;this._activeLayerId=o??$t(bn)}n.preserveHistory?this.pruneSelection():(this._selection=Ne,this._history.clear()),CA(this),this.notify(),this.maybeAnimate()}dispose(){this.cancelLongPress(),this.unbind(),this.actor.stop(),this.listeners.clear(),this.cursorListeners.clear(),this.longPressListeners.clear(),this.announceListeners.clear(),this.animation.detach(),this.animationContentOff?.(),this.renderRafId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this.renderRafId),this.renderRafId=null)}bindPointerEvents(){return t5(this)}beginPanGesture(t,n,o){this.actor.send({type:"POINTER_CANCEL"}),this.cancelGesture(),this.cancelLongPress(),this.host.setPointerCapture(t),this.panGesture={pointerId:t,button:n,startPoint:o,lastPoint:o,moved:!1},this.refreshCursor()}endPanGesture(){let t=this.panGesture;if(this.panGesture=null,t&&(t.button===2||t.button===1)&&!t.moved){let n=this.screenToWorld(t.startPoint);for(let o of this.longPressListeners)o({screenPoint:t.startPoint,worldPoint:n})}this.refreshCursor()}isDrawingPhase(t){return t.mode==="draw-rect"||t.mode==="draw-ellipse"||t.mode==="draw-edge"}startLongPress(t){this.longPress.start(t)}cancelLongPress(){this.longPress.cancel()}beginPinch(){this.pinch.begin([...this.activePointers.values()])}applyPinch(){this.pinch.apply([...this.activePointers.values()])}screenToWorld(t){return B.applyToPoint(ka(this._scene.viewport),t)}linkAttachTargetAt(t){let n=this.acceleratedElementAt(t);if(n&&this.isElementInteractable(n)){let o=this.promoteToGroupRoot(n);return{kind:"element",id:o.id,bounds:z(o)}}}hitTest(t){return pE(t,{scene:this._scene,selection:this._selection,selectedLink:this.selectedLink,selectedLinkCount:this._selectedLinks.size,enteredGroup:this._enteredGroup,handleHitSlop:this.handleHitSlop,edgeHandleHitSlop:this.edgeHandleHitSlop,edgeHitThreshold:this.edgeHitThreshold,hitAnnotation:n=>this.hitAnnotation(n),selectionIsAspectLocked:()=>this.selectionIsAspectLocked(),combinedSelectionBounds:()=>this.combinedSelectionBounds(),acceleratedElementAt:n=>this.acceleratedElementAt(n),isElementInteractable:n=>this.isElementInteractable(n),isLayerLocked:n=>this.isLayerLocked(n),promoteToGroupRoot:n=>this.promoteToGroupRoot(n)})}refreshCursor(t){let n=I5(this,t??this.lastPointerWorld);this.host.style.cursor!==n&&(this.host.style.cursor=n)}setCursorOverride(t,n){n===null?this.cursorOverrides.delete(t):this.cursorOverrides.set(t,n),this.refreshCursor()}getCursorOverride(t){return this.cursorOverrides.get(t)}isLayerLocked(t){return this._scene.layers.get(t)?.locked===!0}isElementInteractable(t){return!(this.isLayerLocked(t.layerId)||Ol(this._scene,t))}isElementManipulable(t){return!(this.isLayerLocked(t.layerId)||Z1(this._scene,t)||Ol(this._scene,t))}toggleLockSelection(){if(this._selection.size===0)return;let t=[...this._selection],n=t.some(a=>M(this._scene,a)?.locked!==!0),o=this._history.transaction();for(let a of t){let r=le(this._scene,a,s=>{let i={...s};return n?i.locked=!0:delete i.locked,i});this._scene=r.scene,o.add(r.patch)}o.commit(),this.notify()}promoteToGroupRoot(t){return h4(this._scene,t,this._enteredGroup)}topGroupAncestor(t){return p4(this._scene,t)}isDescendantOfGroup(t,n){return _A(this._scene,t,n)}computeHiddenElements(){return v9(this._scene)}computeDimElements(t){return m4(this._scene,this._selection,t)}enterGroup(t){this._enteredGroup=t,this.notify()}enterContainer(){if(this._selection.size!==1)return;let t=L([...this._selection][0]),n=M(this._scene,t);if(!n)return;let o=He(n),a=[];for(let r of this._scene.elements.values())(r.parentId===t||o&&r.frameId===t)&&a.push(r.id);a.length!==0&&(Oe(n)&&(this._enteredGroup=t),this.setSelection(a))}exitContainer(){if(this._selection.size===0)return;let t,n=!0;for(let o of this._selection){let a=M(this._scene,o),r=a?.parentId??a?.frameId;if(r===void 0){n=!1;break}if(t===void 0)t=r;else if(t!==r){n=!1;break}}this._enteredGroup=null,n&&t!==void 0?this.setSelection([t]):this.notify()}get enteredGroup(){return this._enteredGroup}acceleratedElementAt(t){return this._scene.elements.size<Fm?Xd(this._scene,t):K1(this._scene,this.ensureSpatialIndex(),t)}ensureSpatialIndex(){let t=this.spatialIndexCache;if(t?.scene===this._scene)return t.index;let n=Y1(this._scene);return this.spatialIndexCache={scene:this._scene,index:n},n}routeIsolationClick(t,n){let o=performance.now(),a=o-this.lastClickAt<Kb&&this.lastClickWorldPoint!==null&&Ae.distance(this.lastClickWorldPoint,n)<=$b;if(this.lastClickAt=o,this.lastClickWorldPoint=n,a){let r=this.frameHeaderAt(n);if(r!==null)return this.beginFrameNameEdit(r),!0}if(!t)return!1;if(this._enteredGroup!==null){let r=t.type==="SELECT_REPLACE"||t.type==="SELECT_TOGGLE"?t.id:null;if(!(r!==null&&this.isDescendantOfGroup(r,this._enteredGroup)))return this._enteredGroup=null,this.notify(),!1}if(a&&t.type==="SELECT_EDGE_REPLACE")return this._selectedLinks=RA(t.id),this._selection=Ne,this.beginLinkCaptionEdit(t.id),!0;if(a&&(t.type==="SELECT_REPLACE"||t.type==="SELECT_TOGGLE")){let r=this.acceleratedElementAt(n);if(r!==void 0&&Fe(r))return this.beginTextEdit(r.id),!0;if(r!==void 0&&He(r))return this.beginFrameNameEdit(r.id),!0;if(r){let s=this.topGroupAncestor(r),i=this.pickDrillTarget(r,s);if(i)return this._enteredGroup=i.id,this._selection=Mt(r.id),this._selectedLinks.size>0&&(this._selectedLinks=kt),this.notify(),!0}}return!1}pickDrillTarget(t,n){return y4(this._scene,t,n,this._enteredGroup)}applyEmit(t){switch(t.type){case"SELECT_REPLACE":this._selection=Mt(t.id),this._selectedLinks=kt,this.notify();return;case"SELECT_TOGGLE":this._selection=O1(this._selection,t.id),this.notify();return;case"SELECT_CLEAR":this._selection=Ne,this._selectedLinks=kt,this.notify();return;case"SELECT_EDGE_REPLACE":this._selectedLinks=RA(t.id),this._selection=Ne,this.notify();return;case"SELECT_EDGE_TOGGLE":this._selectedLinks=Z4(this._selectedLinks,t.id),this.notify();return;case"SELECT_EDGE_CLEAR":this._selectedLinks.size>0&&(this._selectedLinks=kt,this.notify());return;case"UPDATE_EDGE_ENDPOINT_PREVIEW":this.applyLinkEndpointMove(t.linkId,t.side,t.toPoint);return;case"UPDATE_EDGE_ENDPOINT":this.applyLinkEndpointUpdate(t);return;case"LASSO_PROGRESS":this.lassoBaseSelection??=this._selection,this.lassoBaseLinks??=this._selectedLinks,this.lassoPreview=t.bounds,this.applyLassoLiveSelection(t.bounds,t.mode),this.notify();return;case"LASSO_CLEAR":(this.lassoPreview!==null||this.lassoBaseSelection!==null||this.lassoBaseLinks!==null)&&(this.lassoPreview=null,this.lassoBaseSelection=null,this.lassoBaseLinks=null,this.notify());return;case"SELECT_BY_BOUNDS":this.lassoBaseSelection=null,this.lassoBaseLinks=null,this.applySelectByBounds(t.bounds,t.mode);return;case"MOVE_SHAPE":this.groupMoveOrigin?this.applyGroupMove(t.delta):this.applyMove(t.id,t.delta,t.originalBounds);return;case"RESIZE_GROUP":this.applyGroupResize(t.handle,t.delta,t.originalBounds);return;case"RESIZE_SHAPE":this.applyResize(t.id,t.handle,t.delta,t.originalBounds);return;case"ROTATE":this.applyRotate(t.deltaAngle);return;case"CREATE_SHAPE":this.applyCreate(t.shapeType,t.bounds);return;case"CREATE_EDGE":this.applyCreateLink(t);return;case"DRAW_EDGE_PREVIEW":this.applyLinkPreview(t.fromElement,t.fromPoint,t.toPoint);return;case"DRAW_EDGE_PREVIEW_CLEAR":this.edgePreview&&(this.edgePreview=null,this.notify());return;case"TEMPLATE_TAP":for(let n of this.templateTapListeners)n(t);return;case"TEMPLATE_DROP":for(let n of this.templateDropListeners)n(t);return;case"MOVE_ANNOTATION":this.applyAnnotationMove(t.id,t.delta,t.originalPosition);return;case"COMMIT_ANNOTATION_DRAG":this.finalizeOpenGestureTx();return}}applyAnnotationMove(t,n,o){let a=I9(this._scene,t,n,o);a&&(this._scene=a.scene,this.recordGesturePatch(a.patch),this.notify())}templateTapListeners=new Set;templateDropListeners=new Set;onTemplateTap(t){return this.templateTapListeners.add(t),()=>this.templateTapListeners.delete(t)}onTemplateDrop(t){return this.templateDropListeners.add(t),()=>this.templateDropListeners.delete(t)}dispatchTemplateDrop(t){this.applyEmit(t)}applyMove(t,n,o){let a=M(this._scene,t);if(a&&!this.isElementManipulable(a))return;let r=this.transformShiftKey?jA(n):n,s=this.snapActive()?B9(o,r,this.snapSpacing()):r,i=C9(this._scene,t,s,o);i&&(this._scene=J(this._scene,i),this.recordGesturePatch(i),this.notify())}applyGroupMove(t){if(!this.groupMoveOrigin)return;let n=this.transformShiftKey?jA(t):t,o=this.snapActive()?z9(this.groupMoveOrigin,n,this.snapSpacing()):n,a=T9(this._scene,this.groupMoveOrigin,o);for(let r of a)this._scene=J(this._scene,r),this.recordGesturePatch(r);if(this.groupLinkMoveOrigin){let r=U4(this._scene,this.groupLinkMoveOrigin,o);for(let s of r)this._scene=J(this._scene,s),this.recordGesturePatch(s)}this.notify()}computeViewportWorld(){return b9(this._scene)}computeDirtyWorld(){let t=this.lastRenderedScene,n=this._scene;if(!t||t.viewport.size.width<=0||t.viewport.size.height<=0||n.viewport.size.width<=0||n.viewport.size.height<=0||this.gestureTx!==null||this.dragElementId!==null||this.drawingPreview!==null||this.edgePreview!==null||this.brushStroke!==null||this.lassoPreview!==null||t.viewport!==n.viewport||t.layers!==n.layers||this.lastRenderedEnteredGroup!==this._enteredGroup)return null;let{world:o,tileDirty:a}=T4(t,n);if(this.tileComposeFn!==null)for(let[r,s]of a)this.tileDirtyElements.set(r,s);return o}combinedSelectionBounds(){let t=A9(this._scene,this._selection);for(let n of this._selectedLinks){let o=be(this._scene,n);if(!o)continue;let a=rt(this._scene,o);if(!a||a.length===0)continue;let r=1/0,s=1/0,i=-1/0,l=-1/0;for(let u of a)u.x<r&&(r=u.x),u.y<s&&(s=u.y),u.x>i&&(i=u.x),u.y>l&&(l=u.y);let c={x:r,y:s,width:i-r,height:l-s};t=t?X.union(t,c):c}return t}groupChildrenUnion(t){return E0(this._scene,t)}selectionIsAspectLocked(){if(this._selection.size===0)return!1;if(this._selection.size===1){let[t]=[...this._selection];if(!t)return!1;let n=M(this._scene,t)?.type;return n==="group"||n==="image"}for(let t of this._selection){let n=M(this._scene,t);if(n===void 0||!Ut(n))return!1}return!0}applyRotate(t){let n=this.rotateGestureOrigin;if(!n)return;let o=this.transformShiftKey?Math.round(t/Bb)*Bb:t,a=XA(this._scene,n.origin,n.pivot,o);for(let r of a)this._scene=J(this._scene,r),this.recordGesturePatch(r);this.notify()}applyGroupResize(t,n,o){if(!this.groupResizeOrigin)return;let a=this.snapActive()?YA(o,t,n,this.snapSpacing()):n,r=V4(this._scene,this.groupResizeOrigin,t,a,o,this.selectionIsAspectLocked()||this.transformShiftKey,this.transformAltKey);this._scene=r.scene;for(let s of r.patches)this.recordGesturePatch(s);this.notify()}applyResize(t,n,o,a){let r=M(this._scene,t);if(r!==void 0&&!Fe(r)&&r.rotation!==0){this._resizeOriginElement?.id!==t&&(this._resizeOriginElement=r);let l=W4(this._scene,this._resizeOriginElement,n,o,this.transformShiftKey,this.transformAltKey);if(!l)return;this._scene=l.scene,this.recordGesturePatch(l.patch),this.notify();return}let s=this.snapActive()?YA(a,n,o,this.snapSpacing()):o;if(r!==void 0&&Fe(r)){this._resizeOriginElement?.id!==t&&(this._resizeOriginElement=r);let l=j4(this._scene,this._resizeOriginElement,n,s,a,this.transformAltKey);if(!l)return;this._scene=l.scene,this.recordGesturePatch(l.patch),this.notify();return}let i=q4(this._scene,t,n,s,a,(l,c,u)=>this.clampContainerToChildren(l,c,u),this.transformShiftKey,this.transformAltKey);i&&(this._scene=i.scene,this.recordGesturePatch(i.patch),this.notify())}applyCreate(t,n){let o=I0(++this.nextId),a=this.snapActive()?N9(n,this.snapSpacing()):n,r=s9(this._scene,t,a,o,this._activeLayerId,()=>this.nextFrameName());this._scene=r.scene,this._selection=Mt(o),this._history.push(r.patch),t==="frame"&&this.assignFrameMembers(o,a),this.maybeRevertModeAfterCreate(),this.notify()}nextFrameName(){return g4(this._scene)}assignFrameMembers(t,n){this._scene=x4(this._scene,this._history,t,n)}reconcileFrameMembership(){this._scene=b4(this._scene,this._history)}applyCreateLink(t){let n=this.snapLinkEndpoint(t.fromElement,t.fromPoint),o=this.snapLinkEndpoint(t.toElement,t.toPoint),a=HA(++this.nextId),r=Zf(this._scene,n,o,a,this._activeLayerId);this._scene=r.scene,this._history.push(r.patch),this.edgePreview=null,this.maybeRevertModeAfterCreate(),o.kind==="point"&&(this.pendingLinkDropMenu={linkId:a,side:"to",world:o.position}),this.notify()}get linkDropMenu(){return this.pendingLinkDropMenu}placeShapeAtLinkDrop(t){let n=this.pendingLinkDropMenu;if(!n)return;if(!be(this._scene,n.linkId)){this.pendingLinkDropMenu=null,this.notify();return}let a=I0(++this.nextId),r=y9(this._scene,this._activeLayerId,n,a,t),s=this._history.transaction();this._scene=r.scene,s.add(r.addPatch),s.add(r.linkPatch),s.commit(),this.pendingLinkDropMenu=null,this._selection=Mt(a),this._selectedLinks=kt,this.notify()}dismissLinkDropMenu(){this.pendingLinkDropMenu&&(this.pendingLinkDropMenu=null,this.notify())}createLinkedElementFromAnchor(t,n){let o=I0(++this.nextId),a=HA(++this.nextId),r=h9(this._scene,this._activeLayerId,t,n,o,a);if(!r)return;let s=this._history.transaction();this._scene=r.scene,s.add(r.addPatch),s.add(r.linkPatch),s.commit(),this._selection=Mt(o),this._selectedLinks.size>0&&(this._selectedLinks=kt),this.notify()}previewClickCreate(t,n){return p9(this._scene,this._activeLayerId,t,n)}snapLinkEndpoint(t,n){return o9(this._scene,this.snapEngine,this.snapThreshold,t,n)}applySelectByBounds(t,n){let o=L9(this._scene,this._selection,s=>this.isLayerLocked(s),t,n),a=WA(this._scene,n==="add"?this._selectedLinks:kt,s=>this.isLayerLocked(s),t,n),r=!w0(a,this._selectedLinks);if(this._selectedLinks=a,Rs(o,this._selection)&&!r){this.notify();return}this._selection=o,this.notify()}applyLassoLiveSelection(t,n){let o=this.lassoBaseSelection??Ne,a=S9(this._scene,o,l=>this.isLayerLocked(l),t,n),r=this.lassoBaseLinks??kt,s=WA(this._scene,r,l=>this.isLayerLocked(l),t,n),i=!w0(s,this._selectedLinks);Rs(a,this._selection)&&!i||(this._selectedLinks=s,this._selection=a)}applyLinkEndpointMove(t,n,o){if(!be(this._scene,t))return;this.lastHandleClickAt=0;let r=this.linkAttachTargetAt(o),s=r?.kind==="element"?r.id:null,i=this.snapLinkEndpoint(s,o),l=et(this._scene,t,c=>n==="from"?{...c,from:i}:{...c,to:i});this._scene=l.scene,this.recordGesturePatch(l.patch),this.linkEndpointDrag={linkId:t,side:n,toPoint:o},this.updateHoveredLinkTarget(o),this.notify()}applyLinkEndpointUpdate(t){let n=this.gestureTx!==null,o=w9(this._scene,t,(a,r)=>this.snapLinkEndpoint(a,r));if(o===null){this.cancelGesture(),this.linkEndpointDrag=null,this.hoveredLinkTarget=null,this.notify();return}if(!n&&Cr(o.patch)){this.linkEndpointDrag=null,this.hoveredLinkTarget=null,this.notify();return}this._scene=o.scene,this.recordGesturePatch(o.patch),this.commitGesture(),this.linkEndpointDrag=null,this.hoveredLinkTarget=null}get isDraggingWaypoint(){return this.linkWaypointDrag!==null}beginWaypointDrag(t,n,o){be(this._scene,t)&&(this.linkWaypointDrag={linkId:t,index:n,pendingInsert:o})}updateWaypointDrag(t){let n=this.linkWaypointDrag;if(!n)return;this.lastHandleClickAt=0;let o=be(this._scene,n.linkId);if(!o)return;let a=[...o.waypoints??[]];if(n.pendingInsert)a.splice(n.index,0,t),n.pendingInsert=!1;else{if(n.index<0||n.index>=a.length)return;a[n.index]=t}let r=et(this._scene,n.linkId,s=>({...s,waypoints:a}));this._scene=r.scene,this.recordGesturePatch(r.patch),this.notify()}endWaypointDrag(){let t=this.linkWaypointDrag;if(this.linkWaypointDrag=null,!t)return;if(t.pendingInsert){this.commitGesture();return}let n=be(this._scene,t.linkId);if(n?.waypoints&&t.index>=0&&t.index<n.waypoints.length){let o=rt(this._scene,n),a=L(n.waypoints[t.index]),r=zC/(this._scene.viewport.zoom||1),s=o?.[t.index],i=o?.[t.index+2];if(s&&i&&Ml.distanceToSegment(a,s,i)<=r){let l=n.waypoints.filter((u,d)=>d!==t.index),c=et(this._scene,t.linkId,u=>({...u,waypoints:l}));this._scene=c.scene,this.recordGesturePatch(c.patch)}}this.commitGesture()}get isDraggingSegment(){return this.linkSegmentDrag!==null}beginSegmentDrag(t,n,o){be(this._scene,t)&&(this.linkSegmentDrag={linkId:t,axis:n,at:o})}updateSegmentDrag(t){let n=this.linkSegmentDrag;if(!n)return;this.lastHandleClickAt=0;let o=be(this._scene,n.linkId);if(!o)return;let a=n.axis==="h"?t.y:t.x,r=[...o.fixedSegments??[]],s={axis:n.axis,pos:a,at:n.at},i=r.findIndex(c=>c.axis===n.axis&&Math.abs(c.at-n.at)<.5);i>=0?r[i]=s:r.push(s);let l=et(this._scene,n.linkId,c=>({...c,fixedSegments:r}));this._scene=l.scene,this.recordGesturePatch(l.patch),this.notify()}endSegmentDrag(){this.linkSegmentDrag&&(this.linkSegmentDrag=null,this.commitGesture())}isHandleDoubleClick(t){let n=performance.now(),o=n-this.lastHandleClickAt<Kb&&this.lastHandleClickWorld!==null&&Ae.distance(this.lastHandleClickWorld,t)<=$b;return this.lastHandleClickAt=n,this.lastHandleClickWorld=t,o}deleteWaypoint(t,n){let o=be(this._scene,t);if(!o?.waypoints||n<0||n>=o.waypoints.length)return;let a=o.waypoints.filter((s,i)=>i!==n),r=et(this._scene,t,s=>({...s,waypoints:a}));this._scene=r.scene,this._history.push(r.patch),this.notify()}resetSegmentPin(t,n,o,a){let r=be(this._scene,t);if(!r?.fixedSegments||r.fixedSegments.length===0)return;let s=-1,i=1/0;for(let u=0;u<r.fixedSegments.length;u++){let d=L(r.fixedSegments[u]);if(d.axis!==n)continue;let f=Math.abs(d.pos-o)+Math.abs(d.at-a)*.001;f<i&&(i=f,s=u)}if(s<0)return;let l=r.fixedSegments.filter((u,d)=>d!==s),c=et(this._scene,t,u=>({...u,fixedSegments:l}));this._scene=c.scene,this._history.push(c.patch),this.notify()}get selectedLinkAvoidsObstacles(){let t=this.selectedLink;return t===null?!1:be(this._scene,t)?.avoidObstacles===!0}setSelectedLinkAvoidObstacles(t){let n=this.selectedLink;if(n===null)return;let o=be(this._scene,n);if(!o||o.avoidObstacles===t)return;let a=et(this._scene,n,r=>({...r,avoidObstacles:t,...t?{routing:"orthogonal"}:{}}));this._scene=a.scene,this._history.push(a.patch),this.elbowRouteSig.delete(n),this.notify()}updateHoveredLinkTarget(t){let n=this.acceleratedElementAt(t);if(!n){this.hoveredLinkTarget!==null&&(this.hoveredLinkTarget=null,this.notify());return}let a=this.snapEngine.snap({scene:this._scene,probe:t,threshold:this.snapThreshold,gesture:"draw-edge"}).all.filter(f=>f.metadata?.elementId===n.id),r=a.find(f=>f.kind==="anchor"),s=a.find(f=>f.kind==="outline"),i=r?.metadata?.ref,l=null;i?.kind==="named"?l=i.name:i?.kind==="edge"&&i.t===.5&&(l=`edge-${i.index}`);let c=!l&&s?s.snapped:void 0,u=this.hoveredLinkTarget;if(u?.elementId===n.id&&u.activeAnchor===l&&u.outlinePoint?.x===c?.x&&u.outlinePoint?.y===c?.y)return;let d=l!==null||c?"point":"element";this.hoveredLinkTarget={elementId:n.id,activeAnchor:l,outlinePoint:c,mode:d},this.notify()}applyLinkPreview(t,n,o){let a=k9(this._scene,t,n,o);if(Rm==="orthogonal"){let r=this.hitTest(a.to),s=r.kind==="element"?r.id:null,i=Pb(this._scene,t,a.from,s,a.to);this.edgePreview={...a,points:i}}else this.edgePreview=a;this.notify()}recordGesturePatch(t){this.gestureTx===null&&(this.gestureStartScene=J(this._scene,zl(t))),this.gestures.record(t)}commitGesture(){this._resizeOriginElement=null,this.rotateGestureOrigin=null,this.gestures.commit(),this.gestureStartScene=null}finalizeOpenGestureTx(){this.gestures.finalize()}applyContainerDrop(t){E4(this.containerOpsRef,t)}maybeGrowContainer(t,n){jf(this.containerOpsRef,t,n)}clampContainerToChildren(t,n,o){return I4(this._scene,t,n,o)}beginOrAttachGesture(){return this.gestureTx??=this._history.transaction(),this.gestureTx}cancelGesture(){this._resizeOriginElement=null,this.rotateGestureOrigin=null,this.gestures.cancel(),this.gestureStartScene!==null&&(this._scene=this.gestureStartScene,this.gestureStartScene=null)}pruneSelection(){let t=null;for(let n of this._selection)this._scene.elements.has(n)||(t??=new Set(this._selection),t.delete(n));t!==null&&(this._selection=t)}notify(){this.scheduleRender(),v4(this.eventCache,this.events,this.observableSnapshot());for(let t of this.listeners)t();this.autoCompactScheduler.schedule(),this.autoLayoutScheduler.schedule(),this.maybeAnimate()}renderRafId=null;animationContentOff=null;scheduleRender(){if(this.renderRafId===null){if(typeof requestAnimationFrame>"u"){this.render();return}this.renderRafId=requestAnimationFrame(()=>{this.renderRafId=null,this.render()})}}forceRender(){this.renderRafId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this.renderRafId),this.renderRafId=null),this.render()}on(t,n){return this.events.on(t,n)}off(t,n){this.events.off(t,n)}runLayout(t){let n=df(this._scene,t);return n?(this._scene=J(this._scene,n),this._history.push(n),this.autoLayoutScheduler.resetSignature(t),this.notify(),n):null}elbowRouteSig=new Map;rerouteElbows(){let t=this._scene;for(let[n,o]of this._scene.links){if((o.routing??"straight")!=="orthogonal")continue;let a=_9(this._scene,o);if(this.elbowRouteSig.get(n)===a)continue;this.elbowRouteSig.set(n,a);let r=pf(t,o);t=et(t,n,s=>({...s,routedPoints:r})).scene}this._scene=t}render(){this.rerouteElbows(),nA(t=>this.gifPlayback.clock(t.id)),x9(this),this.onAfterRender?.()}},VF=e=>!e||typeof e!="object"?!1:typeof e.push=="function"&&typeof e.undo=="function"&&typeof e.redo=="function"&&typeof e.transaction=="function";var KA=F(ye(),1),ic=F(he(),1),O0=({open:e,onClose:t,title:n="Dialog",children:o,dismissOnBackdrop:a=!0,className:r,style:s})=>{let i=(0,ic.useRef)(null),l=(0,ic.useRef)(null);if((0,ic.useEffect)(()=>{if(!e)return;l.current=document.activeElement;let d=p=>{p.key==="Escape"&&(p.preventDefault(),t())};window.addEventListener("keydown",d);let f=i.current;return f&&(f.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??f).focus(),()=>{window.removeEventListener("keydown",d),l.current?.focus()}},[e,t]),(0,ic.useEffect)(()=>{if(!e)return;let d=f=>{if(f.key!=="Tab")return;let p=i.current;if(!p)return;let h=p.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(h.length===0)return;let m=h[0],b=h[h.length-1];if(m===void 0||b===void 0)return;let y=document.activeElement;f.shiftKey&&y===m?(f.preventDefault(),b.focus()):!f.shiftKey&&y===b&&(f.preventDefault(),m.focus())};return window.addEventListener("keydown",d,!0),()=>{window.removeEventListener("keydown",d,!0)}},[e]),!e)return null;let c={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},u={background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",border:"1px solid var(--border, #2a2a2a)",borderRadius:8,boxShadow:"0 8px 32px rgba(0, 0, 0, 0.45)",maxWidth:"calc(100vw - 64px)",maxHeight:"calc(100vh - 64px)",overflow:"auto",outline:"none",...s};return(0,KA.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":n,style:c,onClick:d=>{a&&d.target===d.currentTarget&&t()},children:(0,KA.jsx)("div",{ref:i,tabIndex:-1,className:r,style:u,onClick:d=>{d.stopPropagation()},children:o})})};var ZF={history:"History",selection:"Selection",clipboard:"Clipboard","z-order":"Z-order",grouping:"Grouping",zoom:"Zoom",mode:"Tools",layout:"Layout",arrange:"Arrange",edit:"Editing",other:"Other"},XF=["mode","edit","selection","clipboard","history","z-order","grouping","layout","zoom","other"],$A=e=>{(0,lc.useEffect)(()=>{let t=n=>{let o=n.target;o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement||!(n.key==="?"||n.shiftKey&&n.key==="/")||(n.preventDefault(),e())};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[e])},YF=e=>{let t=[];if(e.hotkey){let n=Array.isArray(e.hotkey)?e.hotkey:[e.hotkey];for(let o of n)t.push(f0(o))}if(e.sequence&&e.sequence.length>0){let n=e.sequence.map(o=>o.length===1?o.toUpperCase():o).join(" ");t.push([n])}return t},Yf=({registry:e=st,open:t,onClose:n,title:o="Keyboard shortcuts",extraSections:a})=>{let r=(0,lc.useMemo)(()=>{let c=new Map;for(let d of e.getAll()){if(!d.label)continue;let f=d.category??"other",p=c.get(f)??[];p.push({label:d.label,keys:YF(d)}),c.set(f,p)}let u=[];for(let d of XF){let f=c.get(d);!f||f.length===0||u.push({title:ZF[d],rows:f})}return a&&u.push(...a),u},[e,a]),s={maxWidth:720,width:"calc(100vw - 64px)",display:"flex",flexDirection:"column"},i={padding:"16px 20px",borderBottom:"1px solid var(--du-ui-border)",display:"flex",alignItems:"center",justifyContent:"space-between"},l={padding:"16px 20px 20px",overflowY:"auto"};return(0,je.jsx)(O0,{open:t,onClose:n,title:o,style:s,children:(0,je.jsxs)("div",{children:[(0,je.jsxs)("div",{style:i,children:[(0,je.jsx)("h2",{style:{margin:0,fontSize:16,fontWeight:600},children:o}),(0,je.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,je.jsx)("span",{className:"du-help-platform-badge",children:Br?"macOS":"Win / Linux"}),(0,je.jsx)("button",{type:"button","aria-label":"Close help",onClick:n,style:{background:"transparent",border:"none",color:"var(--du-text)",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:4},children:(0,je.jsx)(ba,{size:18,strokeWidth:1.75})})]})]}),(0,je.jsx)("div",{style:l,children:(0,je.jsx)("div",{className:"du-help-islands",children:r.map(c=>(0,je.jsxs)("section",{className:"du-help-island",children:[(0,je.jsx)("h3",{className:"du-help-island-title",children:c.title}),(0,je.jsx)("div",{className:"du-help-island-rows",children:c.rows.map(u=>(0,je.jsxs)("div",{className:"du-help-row",children:[(0,je.jsx)("span",{className:"du-help-row-label",children:u.label}),(0,je.jsx)(KF,{combos:u.keys})]},u.label))})]},c.title))})})]})})},KF=({combos:e})=>e.length===0?(0,je.jsx)("span",{className:"du-help-keys-separator",children:"\u2014"}):(0,je.jsx)("span",{className:"du-help-keys",children:e.map((t,n)=>(0,je.jsxs)(lc.Fragment,{children:[n>0?(0,je.jsx)("span",{className:"du-help-keys-separator",children:"or"}):null,t.map((o,a)=>(0,je.jsx)("kbd",{className:"du-help-key",children:o},a))]},n))});var $F=16,QF=1.75,R0=({renderDialog:e})=>{let[t,n]=(0,F9.useState)(!1);return(0,zr.jsxs)(zr.Fragment,{children:[(0,zr.jsx)(Bn,{label:"Help",onClick:()=>{n(!0)},children:(0,zr.jsx)(gn,{size:$F,strokeWidth:QF})}),e?e({open:t,onClose:()=>{n(!1)}}):(0,zr.jsx)(Yf,{open:t,onClose:()=>{n(!1)}})]})};var Qf=F(ye(),1),U9=F(he(),1);var Kf=F(he(),1);var H9=`(pointer: coarse), (max-width: ${640}px)`,JF=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(H9).matches:!1,$f=()=>(0,Kf.useSyncExternalStore)(e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};let t=window.matchMedia(H9);return t.addEventListener("change",e),()=>{t.removeEventListener("change",e)}},JF,()=>!1),j=()=>g1(),eH=bb(),oi=()=>Aa(e=>e.scene,eH,"scene"),D0=()=>Aa(e=>e.selection,va.EMPTY,"selection"),QA=()=>Aa(e=>e.mode,"select","mode"),JA=()=>{let e=j(),t=Aa(r=>r.canUndo,!1,"history"),n=Aa(r=>r.canRedo,!1,"history"),o=(0,Kf.useCallback)(()=>{e?.undo()},[e]),a=(0,Kf.useCallback)(()=>{e?.redo()},[e]);return{canUndo:t,canRedo:n,undo:o,redo:a}};var $ie=$t(bn);var ev=()=>Aa(e=>e.selectedLink,null);var tH=14,nH=1.75,tv=()=>{let e=j(),t=oi(),n=(0,U9.useMemo)(()=>oH(t),[t]);return!e||t.elements.size===0||!n?null:(0,Qf.jsxs)("button",{type:"button",className:"du-pill-button",onClick:()=>{e.zoomToFit()},title:"Reset view to fit all content",children:[(0,Qf.jsx)(dd,{size:tH,strokeWidth:nH,"aria-hidden":!0}),(0,Qf.jsx)("span",{children:"Back to content"})]})},oH=e=>{if(e.elements.size===0)return!1;let t=e.viewport;if(t.size.width<=0||t.size.height<=0)return!1;let n=null;for(let c of e.elements.values()){let u=z(c);n=n?X.union(n,u):u}if(!n)return!1;let o=ka(t),a=B.applyToPoint(o,{x:0,y:0}),r=B.applyToPoint(o,{x:t.size.width,y:t.size.height}),s={x:Math.min(a.x,r.x),y:Math.min(a.y,r.y),width:Math.abs(r.x-a.x),height:Math.abs(r.y-a.y)},i=n.x<s.x+s.width&&s.x<n.x+n.width,l=n.y<s.y+s.height&&s.y<n.y+n.height;return!(i&&l)};var nn=F(ye(),1),vi=F(he(),1);var pt=F(ye(),1),Kn=F(he(),1);var P0=class{items=new Map;register(t){if(this.items.has(t.id))throw new Error(`Template already registered: ${t.id}`);this.items.set(t.id,t)}replace(t){this.items.set(t.id,t)}get(t){return this.items.get(t)}has(t){return this.items.has(t)}list(){return[...this.items.values()]}byCategory(t){return this.list().filter(n=>n.category===t)}categories(){let t=new Set;for(let n of this.items.values())t.add(n.category);return[...t]}clear(){this.items.clear()}},ai=new P0;var sle={...Rr.rectangle},ile={...Rr.sticky},lle={...Rr.flowchart};var nv=(e,t)=>{let n=t.trim().toLowerCase();if(!n||e.name.toLowerCase().includes(n)||typeof e.category=="string"&&e.category.toLowerCase().includes(n))return!0;if(e.tags){for(let o of e.tags)if(o.toLowerCase().includes(n))return!0}return!1};var w={};no(w,{BRAND:()=>IH,DIRTY:()=>ri,EMPTY_PATH:()=>iH,INVALID:()=>V,NEVER:()=>pU,OK:()=>zt,ParseStatus:()=>Ot,Schema:()=>ie,ZodAny:()=>Hr,ZodArray:()=>Ra,ZodBigInt:()=>ii,ZodBoolean:()=>li,ZodBranded:()=>ep,ZodCatch:()=>bi,ZodDate:()=>ci,ZodDefault:()=>xi,ZodDiscriminatedUnion:()=>N0,ZodEffects:()=>Yn,ZodEnum:()=>yi,ZodError:()=>en,ZodFirstPartyTypeKind:()=>Y,ZodFunction:()=>H0,ZodIntersection:()=>pi,ZodIssueCode:()=>D,ZodLazy:()=>hi,ZodLiteral:()=>mi,ZodMap:()=>hc,ZodNaN:()=>yc,ZodNativeEnum:()=>gi,ZodNever:()=>mo,ZodNull:()=>di,ZodNullable:()=>Go,ZodNumber:()=>si,ZodObject:()=>tn,ZodOptional:()=>Zn,ZodParsedType:()=>G,ZodPipeline:()=>tp,ZodPromise:()=>Ur,ZodReadonly:()=>Ai,ZodRecord:()=>F0,ZodSchema:()=>ie,ZodSet:()=>mc,ZodString:()=>Fr,ZodSymbol:()=>fc,ZodTransformer:()=>Yn,ZodTuple:()=>Uo,ZodType:()=>ie,ZodUndefined:()=>ui,ZodUnion:()=>fi,ZodUnknown:()=>Oa,ZodVoid:()=>pc,addIssueToContext:()=>H,any:()=>NH,array:()=>GH,bigint:()=>RH,boolean:()=>Q9,coerce:()=>fU,custom:()=>Y9,date:()=>DH,datetimeRegex:()=>Z9,defaultErrorMap:()=>Ea,discriminatedUnion:()=>VH,effect:()=>aU,enum:()=>tU,function:()=>QH,getErrorMap:()=>cc,getParsedType:()=>Ho,instanceof:()=>MH,intersection:()=>ZH,isAborted:()=>B0,isAsync:()=>uc,isDirty:()=>z0,isValid:()=>Nr,late:()=>EH,lazy:()=>JH,literal:()=>eU,makeIssue:()=>Jf,map:()=>KH,nan:()=>OH,nativeEnum:()=>nU,never:()=>HH,null:()=>zH,nullable:()=>sU,number:()=>$9,object:()=>qH,objectUtil:()=>ov,oboolean:()=>dU,onumber:()=>uU,optional:()=>rU,ostring:()=>cU,pipeline:()=>lU,preprocess:()=>iU,promise:()=>oU,quotelessJson:()=>aH,record:()=>YH,set:()=>$H,setErrorMap:()=>sH,strictObject:()=>WH,string:()=>K9,symbol:()=>PH,transformer:()=>aU,tuple:()=>XH,undefined:()=>BH,union:()=>jH,unknown:()=>FH,util:()=>pe,void:()=>UH});var pe;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function n(a){throw new Error}e.assertNever=n,e.arrayToEnum=a=>{let r={};for(let s of a)r[s]=s;return r},e.getValidEnumValues=a=>{let r=e.objectKeys(a).filter(i=>typeof a[a[i]]!="number"),s={};for(let i of r)s[i]=a[i];return e.objectValues(s)},e.objectValues=a=>e.objectKeys(a).map(function(r){return a[r]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let r=[];for(let s in a)Object.prototype.hasOwnProperty.call(a,s)&&r.push(s);return r},e.find=(a,r)=>{for(let s of a)if(r(s))return s},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function o(a,r=" | "){return a.map(s=>typeof s=="string"?`'${s}'`:s).join(r)}e.joinValues=o,e.jsonStringifyReplacer=(a,r)=>typeof r=="bigint"?r.toString():r})(pe||(pe={}));var ov;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(ov||(ov={}));var G=pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ho=e=>{switch(typeof e){case"undefined":return G.undefined;case"string":return G.string;case"number":return Number.isNaN(e)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(e)?G.array:e===null?G.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?G.promise:typeof Map<"u"&&e instanceof Map?G.map:typeof Set<"u"&&e instanceof Set?G.set:typeof Date<"u"&&e instanceof Date?G.date:G.object;default:return G.unknown}};var D=pe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),aH=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),en=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){let n=t||function(r){return r.message},o={_errors:[]},a=r=>{for(let s of r.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)o._errors.push(n(s));else{let i=o,l=0;for(;l<s.path.length;){let c=s.path[l];l===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(n(s))):i[c]=i[c]||{_errors:[]},i=i[c],l++}}};return a(this),o}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},o=[];for(let a of this.issues)if(a.path.length>0){let r=a.path[0];n[r]=n[r]||[],n[r].push(t(a))}else o.push(t(a));return{formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}};en.create=e=>new en(e);var rH=(e,t)=>{let n;switch(e.code){case D.invalid_type:e.received===G.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case D.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,pe.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:n=`Unrecognized key(s) in object: ${pe.joinValues(e.keys,", ")}`;break;case D.invalid_union:n="Invalid input";break;case D.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${pe.joinValues(e.options)}`;break;case D.invalid_enum_value:n=`Invalid enum value. Expected ${pe.joinValues(e.options)}, received '${e.received}'`;break;case D.invalid_arguments:n="Invalid function arguments";break;case D.invalid_return_type:n="Invalid function return type";break;case D.invalid_date:n="Invalid date";break;case D.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:pe.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case D.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case D.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case D.custom:n="Invalid input";break;case D.invalid_intersection_types:n="Intersection results could not be merged";break;case D.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case D.not_finite:n="Number must be finite";break;default:n=t.defaultError,pe.assertNever(e)}return{message:n}},Ea=rH;var G9=Ea;function sH(e){G9=e}function cc(){return G9}var Jf=e=>{let{data:t,path:n,errorMaps:o,issueData:a}=e,r=[...n,...a.path||[]],s={...a,path:r};if(a.message!==void 0)return{...a,path:r,message:a.message};let i="",l=o.filter(c=>!!c).slice().reverse();for(let c of l)i=c(s,{data:t,defaultError:i}).message;return{...a,path:r,message:i}},iH=[];function H(e,t){let n=cc(),o=Jf({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Ea?void 0:Ea].filter(a=>!!a)});e.common.issues.push(o)}var Ot=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){let o=[];for(let a of n){if(a.status==="aborted")return V;a.status==="dirty"&&t.dirty(),o.push(a.value)}return{status:t.value,value:o}}static async mergeObjectAsync(t,n){let o=[];for(let a of n){let r=await a.key,s=await a.value;o.push({key:r,value:s})}return e.mergeObjectSync(t,o)}static mergeObjectSync(t,n){let o={};for(let a of n){let{key:r,value:s}=a;if(r.status==="aborted"||s.status==="aborted")return V;r.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),r.value!=="__proto__"&&(typeof s.value<"u"||a.alwaysSet)&&(o[r.value]=s.value)}return{status:t.value,value:o}}},V=Object.freeze({status:"aborted"}),ri=e=>({status:"dirty",value:e}),zt=e=>({status:"valid",value:e}),B0=e=>e.status==="aborted",z0=e=>e.status==="dirty",Nr=e=>e.status==="valid",uc=e=>typeof Promise<"u"&&e instanceof Promise;var W;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(W||(W={}));var Xn=class{constructor(t,n,o,a){this._cachedPath=[],this.parent=t,this.data=n,this._path=o,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},q9=(e,t)=>{if(Nr(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new en(e.common.issues);return this._error=n,this._error}}};function ae(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:o,description:a}=e;if(t&&(n||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(s,i)=>{let{message:l}=e;return s.code==="invalid_enum_value"?{message:l??i.defaultError}:typeof i.data>"u"?{message:l??o??i.defaultError}:s.code!=="invalid_type"?{message:i.defaultError}:{message:l??n??i.defaultError}},description:a}}var ie=class{get description(){return this._def.description}_getType(t){return Ho(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Ho(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Ot,ctx:{common:t.parent.common,data:t.data,parsedType:Ho(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(uc(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){let n=this._parse(t);return Promise.resolve(n)}parse(t,n){let o=this.safeParse(t,n);if(o.success)return o.data;throw o.error}safeParse(t,n){let o={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ho(t)},a=this._parseSync({data:t,path:o.path,parent:o});return q9(o,a)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ho(t)};if(!this["~standard"].async)try{let o=this._parseSync({data:t,path:[],parent:n});return Nr(o)?{value:o.value}:{issues:n.common.issues}}catch(o){o?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(o=>Nr(o)?{value:o.value}:{issues:n.common.issues})}async parseAsync(t,n){let o=await this.safeParseAsync(t,n);if(o.success)return o.data;throw o.error}async safeParseAsync(t,n){let o={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ho(t)},a=this._parse({data:t,path:o.path,parent:o}),r=await(uc(a)?a:Promise.resolve(a));return q9(o,r)}refine(t,n){let o=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,r)=>{let s=t(a),i=()=>r.addIssue({code:D.custom,...o(a)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(i(),!1)):s?!0:(i(),!1)})}refinement(t,n){return this._refinement((o,a)=>t(o)?!0:(a.addIssue(typeof n=="function"?n(o,a):n),!1))}_refinement(t){return new Yn({schema:this,typeName:Y.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Zn.create(this,this._def)}nullable(){return Go.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ra.create(this)}promise(){return Ur.create(this,this._def)}or(t){return fi.create([this,t],this._def)}and(t){return pi.create(this,t,this._def)}transform(t){return new Yn({...ae(this._def),schema:this,typeName:Y.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new xi({...ae(this._def),innerType:this,defaultValue:n,typeName:Y.ZodDefault})}brand(){return new ep({typeName:Y.ZodBranded,type:this,...ae(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new bi({...ae(this._def),innerType:this,catchValue:n,typeName:Y.ZodCatch})}describe(t){let n=this.constructor;return new n({...this._def,description:t})}pipe(t){return tp.create(this,t)}readonly(){return Ai.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},lH=/^c[^\s-]{8,}$/i,cH=/^[0-9a-z]+$/,uH=/^[0-9A-HJKMNP-TV-Z]{26}$/i,dH=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,fH=/^[a-z0-9_-]{21}$/i,pH=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,hH=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,mH=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yH="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",av,gH=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xH=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,bH=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,AH=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,vH=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,LH=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,j9="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",SH=new RegExp(`^${j9}$`);function V9(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function kH(e){return new RegExp(`^${V9(e)}$`)}function Z9(e){let t=`${j9}T${V9(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function wH(e,t){return!!((t==="v4"||!t)&&gH.test(e)||(t==="v6"||!t)&&bH.test(e))}function _H(e,t){if(!pH.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(o));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function CH(e,t){return!!((t==="v4"||!t)&&xH.test(e)||(t==="v6"||!t)&&AH.test(e))}var Fr=class e extends ie{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==G.string){let r=this._getOrReturnCtx(t);return H(r,{code:D.invalid_type,expected:G.string,received:r.parsedType}),V}let o=new Ot,a;for(let r of this._def.checks)if(r.kind==="min")t.data.length<r.value&&(a=this._getOrReturnCtx(t,a),H(a,{code:D.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),o.dirty());else if(r.kind==="max")t.data.length>r.value&&(a=this._getOrReturnCtx(t,a),H(a,{code:D.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),o.dirty());else if(r.kind==="length"){let s=t.data.length>r.value,i=t.data.length<r.value;(s||i)&&(a=this._getOrReturnCtx(t,a),s?H(a,{code:D.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&H(a,{code:D.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),o.dirty())}else if(r.kind==="email")mH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"email",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="emoji")av||(av=new RegExp(yH,"u")),av.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"emoji",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="uuid")dH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"uuid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="nanoid")fH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"nanoid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid")lH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"cuid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid2")cH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"cuid2",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="ulid")uH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"ulid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="url")try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),H(a,{validation:"url",code:D.invalid_string,message:r.message}),o.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"regex",code:D.invalid_string,message:r.message}),o.dirty())):r.kind==="trim"?t.data=t.data.trim():r.kind==="includes"?t.data.includes(r.value,r.position)||(a=this._getOrReturnCtx(t,a),H(a,{code:D.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),o.dirty()):r.kind==="toLowerCase"?t.data=t.data.toLowerCase():r.kind==="toUpperCase"?t.data=t.data.toUpperCase():r.kind==="startsWith"?t.data.startsWith(r.value)||(a=this._getOrReturnCtx(t,a),H(a,{code:D.invalid_string,validation:{startsWith:r.value},message:r.message}),o.dirty()):r.kind==="endsWith"?t.data.endsWith(r.value)||(a=this._getOrReturnCtx(t,a),H(a,{code:D.invalid_string,validation:{endsWith:r.value},message:r.message}),o.dirty()):r.kind==="datetime"?Z9(r).test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{code:D.invalid_string,validation:"datetime",message:r.message}),o.dirty()):r.kind==="date"?SH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{code:D.invalid_string,validation:"date",message:r.message}),o.dirty()):r.kind==="time"?kH(r).test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{code:D.invalid_string,validation:"time",message:r.message}),o.dirty()):r.kind==="duration"?hH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"duration",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="ip"?wH(t.data,r.version)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"ip",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="jwt"?_H(t.data,r.alg)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"jwt",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="cidr"?CH(t.data,r.version)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"cidr",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64"?vH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"base64",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64url"?LH.test(t.data)||(a=this._getOrReturnCtx(t,a),H(a,{validation:"base64url",code:D.invalid_string,message:r.message}),o.dirty()):pe.assertNever(r);return{status:o.value,value:t.data}}_regex(t,n,o){return this.refinement(a=>t.test(a),{validation:n,code:D.invalid_string,...W.errToObj(o)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...W.errToObj(t)})}url(t){return this._addCheck({kind:"url",...W.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...W.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...W.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...W.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...W.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...W.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...W.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...W.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...W.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...W.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...W.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...W.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...W.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...W.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...W.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...W.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...W.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...W.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...W.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...W.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...W.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...W.errToObj(n)})}nonempty(t){return this.min(1,W.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};Fr.create=e=>new Fr({checks:[],typeName:Y.ZodString,coerce:e?.coerce??!1,...ae(e)});function TH(e,t){let n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,a=n>o?n:o,r=Number.parseInt(e.toFixed(a).replace(".","")),s=Number.parseInt(t.toFixed(a).replace(".",""));return r%s/10**a}var si=class e extends ie{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==G.number){let r=this._getOrReturnCtx(t);return H(r,{code:D.invalid_type,expected:G.number,received:r.parsedType}),V}let o,a=new Ot;for(let r of this._def.checks)r.kind==="int"?pe.isInteger(t.data)||(o=this._getOrReturnCtx(t,o),H(o,{code:D.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):r.kind==="min"?(r.inclusive?t.data<r.value:t.data<=r.value)&&(o=this._getOrReturnCtx(t,o),H(o,{code:D.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?t.data>r.value:t.data>=r.value)&&(o=this._getOrReturnCtx(t,o),H(o,{code:D.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?TH(t.data,r.value)!==0&&(o=this._getOrReturnCtx(t,o),H(o,{code:D.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):r.kind==="finite"?Number.isFinite(t.data)||(o=this._getOrReturnCtx(t,o),H(o,{code:D.not_finite,message:r.message}),a.dirty()):pe.assertNever(r);return{status:a.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,W.toString(n))}gt(t,n){return this.setLimit("min",t,!1,W.toString(n))}lte(t,n){return this.setLimit("max",t,!0,W.toString(n))}lt(t,n){return this.setLimit("max",t,!1,W.toString(n))}setLimit(t,n,o,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:W.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:W.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:W.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:W.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:W.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:W.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:W.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:W.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:W.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:W.toString(t)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&pe.isInteger(t.value))}get isFinite(){let t=null,n=null;for(let o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(n===null||o.value>n)&&(n=o.value):o.kind==="max"&&(t===null||o.value<t)&&(t=o.value)}return Number.isFinite(n)&&Number.isFinite(t)}};si.create=e=>new si({checks:[],typeName:Y.ZodNumber,coerce:e?.coerce||!1,...ae(e)});var ii=class e extends ie{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==G.bigint)return this._getInvalidInput(t);let o,a=new Ot;for(let r of this._def.checks)r.kind==="min"?(r.inclusive?t.data<r.value:t.data<=r.value)&&(o=this._getOrReturnCtx(t,o),H(o,{code:D.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?t.data>r.value:t.data>=r.value)&&(o=this._getOrReturnCtx(t,o),H(o,{code:D.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="multipleOf"?t.data%r.value!==BigInt(0)&&(o=this._getOrReturnCtx(t,o),H(o,{code:D.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):pe.assertNever(r);return{status:a.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return H(n,{code:D.invalid_type,expected:G.bigint,received:n.parsedType}),V}gte(t,n){return this.setLimit("min",t,!0,W.toString(n))}gt(t,n){return this.setLimit("min",t,!1,W.toString(n))}lte(t,n){return this.setLimit("max",t,!0,W.toString(n))}lt(t,n){return this.setLimit("max",t,!1,W.toString(n))}setLimit(t,n,o,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:W.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:W.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:W.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:W.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:W.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:W.toString(n)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};ii.create=e=>new ii({checks:[],typeName:Y.ZodBigInt,coerce:e?.coerce??!1,...ae(e)});var li=class extends ie{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==G.boolean){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.boolean,received:o.parsedType}),V}return zt(t.data)}};li.create=e=>new li({typeName:Y.ZodBoolean,coerce:e?.coerce||!1,...ae(e)});var ci=class e extends ie{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==G.date){let r=this._getOrReturnCtx(t);return H(r,{code:D.invalid_type,expected:G.date,received:r.parsedType}),V}if(Number.isNaN(t.data.getTime())){let r=this._getOrReturnCtx(t);return H(r,{code:D.invalid_date}),V}let o=new Ot,a;for(let r of this._def.checks)r.kind==="min"?t.data.getTime()<r.value&&(a=this._getOrReturnCtx(t,a),H(a,{code:D.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),o.dirty()):r.kind==="max"?t.data.getTime()>r.value&&(a=this._getOrReturnCtx(t,a),H(a,{code:D.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),o.dirty()):pe.assertNever(r);return{status:o.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:W.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:W.toString(n)})}get minDate(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};ci.create=e=>new ci({checks:[],coerce:e?.coerce||!1,typeName:Y.ZodDate,...ae(e)});var fc=class extends ie{_parse(t){if(this._getType(t)!==G.symbol){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.symbol,received:o.parsedType}),V}return zt(t.data)}};fc.create=e=>new fc({typeName:Y.ZodSymbol,...ae(e)});var ui=class extends ie{_parse(t){if(this._getType(t)!==G.undefined){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.undefined,received:o.parsedType}),V}return zt(t.data)}};ui.create=e=>new ui({typeName:Y.ZodUndefined,...ae(e)});var di=class extends ie{_parse(t){if(this._getType(t)!==G.null){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.null,received:o.parsedType}),V}return zt(t.data)}};di.create=e=>new di({typeName:Y.ZodNull,...ae(e)});var Hr=class extends ie{constructor(){super(...arguments),this._any=!0}_parse(t){return zt(t.data)}};Hr.create=e=>new Hr({typeName:Y.ZodAny,...ae(e)});var Oa=class extends ie{constructor(){super(...arguments),this._unknown=!0}_parse(t){return zt(t.data)}};Oa.create=e=>new Oa({typeName:Y.ZodUnknown,...ae(e)});var mo=class extends ie{_parse(t){let n=this._getOrReturnCtx(t);return H(n,{code:D.invalid_type,expected:G.never,received:n.parsedType}),V}};mo.create=e=>new mo({typeName:Y.ZodNever,...ae(e)});var pc=class extends ie{_parse(t){if(this._getType(t)!==G.undefined){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.void,received:o.parsedType}),V}return zt(t.data)}};pc.create=e=>new pc({typeName:Y.ZodVoid,...ae(e)});var Ra=class e extends ie{_parse(t){let{ctx:n,status:o}=this._processInputParams(t),a=this._def;if(n.parsedType!==G.array)return H(n,{code:D.invalid_type,expected:G.array,received:n.parsedType}),V;if(a.exactLength!==null){let s=n.data.length>a.exactLength.value,i=n.data.length<a.exactLength.value;(s||i)&&(H(n,{code:s?D.too_big:D.too_small,minimum:i?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),o.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(H(n,{code:D.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),o.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(H(n,{code:D.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),o.dirty()),n.common.async)return Promise.all([...n.data].map((s,i)=>a.type._parseAsync(new Xn(n,s,n.path,i)))).then(s=>Ot.mergeArray(o,s));let r=[...n.data].map((s,i)=>a.type._parseSync(new Xn(n,s,n.path,i)));return Ot.mergeArray(o,r)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:W.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:W.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:W.toString(n)}})}nonempty(t){return this.min(1,t)}};Ra.create=(e,t)=>new Ra({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Y.ZodArray,...ae(t)});function dc(e){if(e instanceof tn){let t={};for(let n in e.shape){let o=e.shape[n];t[n]=Zn.create(dc(o))}return new tn({...e._def,shape:()=>t})}else return e instanceof Ra?new Ra({...e._def,type:dc(e.element)}):e instanceof Zn?Zn.create(dc(e.unwrap())):e instanceof Go?Go.create(dc(e.unwrap())):e instanceof Uo?Uo.create(e.items.map(t=>dc(t))):e}var tn=class e extends ie{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=pe.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==G.object){let c=this._getOrReturnCtx(t);return H(c,{code:D.invalid_type,expected:G.object,received:c.parsedType}),V}let{status:o,ctx:a}=this._processInputParams(t),{shape:r,keys:s}=this._getCached(),i=[];if(!(this._def.catchall instanceof mo&&this._def.unknownKeys==="strip"))for(let c in a.data)s.includes(c)||i.push(c);let l=[];for(let c of s){let u=r[c],d=a.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new Xn(a,d,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof mo){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of i)l.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(c==="strict")i.length>0&&(H(a,{code:D.unrecognized_keys,keys:i}),o.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of i){let d=a.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new Xn(a,d,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Ot.mergeObjectSync(o,c)):Ot.mergeObjectSync(o,l)}get shape(){return this._def.shape()}strict(t){return W.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,o)=>{let a=this._def.errorMap?.(n,o).message??o.defaultError;return n.code==="unrecognized_keys"?{message:W.errToObj(t).message??a}:{message:a}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Y.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let o of pe.objectKeys(t))t[o]&&this.shape[o]&&(n[o]=this.shape[o]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let o of pe.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new e({...this._def,shape:()=>n})}deepPartial(){return dc(this)}partial(t){let n={};for(let o of pe.objectKeys(this.shape)){let a=this.shape[o];t&&!t[o]?n[o]=a:n[o]=a.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let o of pe.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let r=this.shape[o];for(;r instanceof Zn;)r=r._def.innerType;n[o]=r}return new e({...this._def,shape:()=>n})}keyof(){return X9(pe.objectKeys(this.shape))}};tn.create=(e,t)=>new tn({shape:()=>e,unknownKeys:"strip",catchall:mo.create(),typeName:Y.ZodObject,...ae(t)});tn.strictCreate=(e,t)=>new tn({shape:()=>e,unknownKeys:"strict",catchall:mo.create(),typeName:Y.ZodObject,...ae(t)});tn.lazycreate=(e,t)=>new tn({shape:e,unknownKeys:"strip",catchall:mo.create(),typeName:Y.ZodObject,...ae(t)});var fi=class extends ie{_parse(t){let{ctx:n}=this._processInputParams(t),o=this._def.options;function a(r){for(let i of r)if(i.result.status==="valid")return i.result;for(let i of r)if(i.result.status==="dirty")return n.common.issues.push(...i.ctx.common.issues),i.result;let s=r.map(i=>new en(i.ctx.common.issues));return H(n,{code:D.invalid_union,unionErrors:s}),V}if(n.common.async)return Promise.all(o.map(async r=>{let s={...n,common:{...n.common,issues:[]},parent:null};return{result:await r._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(a);{let r,s=[];for(let l of o){let c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!r&&(r={result:u,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(r)return n.common.issues.push(...r.ctx.common.issues),r.result;let i=s.map(l=>new en(l));return H(n,{code:D.invalid_union,unionErrors:i}),V}}get options(){return this._def.options}};fi.create=(e,t)=>new fi({options:e,typeName:Y.ZodUnion,...ae(t)});var Ma=e=>e instanceof hi?Ma(e.schema):e instanceof Yn?Ma(e.innerType()):e instanceof mi?[e.value]:e instanceof yi?e.options:e instanceof gi?pe.objectValues(e.enum):e instanceof xi?Ma(e._def.innerType):e instanceof ui?[void 0]:e instanceof di?[null]:e instanceof Zn?[void 0,...Ma(e.unwrap())]:e instanceof Go?[null,...Ma(e.unwrap())]:e instanceof ep||e instanceof Ai?Ma(e.unwrap()):e instanceof bi?Ma(e._def.innerType):[],N0=class e extends ie{_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==G.object)return H(n,{code:D.invalid_type,expected:G.object,received:n.parsedType}),V;let o=this.discriminator,a=n.data[o],r=this.optionsMap.get(a);return r?n.common.async?r._parseAsync({data:n.data,path:n.path,parent:n}):r._parseSync({data:n.data,path:n.path,parent:n}):(H(n,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[o]}),V)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,o){let a=new Map;for(let r of n){let s=Ma(r.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let i of s){if(a.has(i))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(i)}`);a.set(i,r)}}return new e({typeName:Y.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:a,...ae(o)})}};function rv(e,t){let n=Ho(e),o=Ho(t);if(e===t)return{valid:!0,data:e};if(n===G.object&&o===G.object){let a=pe.objectKeys(t),r=pe.objectKeys(e).filter(i=>a.indexOf(i)!==-1),s={...e,...t};for(let i of r){let l=rv(e[i],t[i]);if(!l.valid)return{valid:!1};s[i]=l.data}return{valid:!0,data:s}}else if(n===G.array&&o===G.array){if(e.length!==t.length)return{valid:!1};let a=[];for(let r=0;r<e.length;r++){let s=e[r],i=t[r],l=rv(s,i);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return n===G.date&&o===G.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var pi=class extends ie{_parse(t){let{status:n,ctx:o}=this._processInputParams(t),a=(r,s)=>{if(B0(r)||B0(s))return V;let i=rv(r.value,s.value);return i.valid?((z0(r)||z0(s))&&n.dirty(),{status:n.value,value:i.data}):(H(o,{code:D.invalid_intersection_types}),V)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([r,s])=>a(r,s)):a(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}};pi.create=(e,t,n)=>new pi({left:e,right:t,typeName:Y.ZodIntersection,...ae(n)});var Uo=class e extends ie{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==G.array)return H(o,{code:D.invalid_type,expected:G.array,received:o.parsedType}),V;if(o.data.length<this._def.items.length)return H(o,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),V;!this._def.rest&&o.data.length>this._def.items.length&&(H(o,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let r=[...o.data].map((s,i)=>{let l=this._def.items[i]||this._def.rest;return l?l._parse(new Xn(o,s,o.path,i)):null}).filter(s=>!!s);return o.common.async?Promise.all(r).then(s=>Ot.mergeArray(n,s)):Ot.mergeArray(n,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Uo.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Uo({items:e,typeName:Y.ZodTuple,rest:null,...ae(t)})};var F0=class e extends ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==G.object)return H(o,{code:D.invalid_type,expected:G.object,received:o.parsedType}),V;let a=[],r=this._def.keyType,s=this._def.valueType;for(let i in o.data)a.push({key:r._parse(new Xn(o,i,o.path,i)),value:s._parse(new Xn(o,o.data[i],o.path,i)),alwaysSet:i in o.data});return o.common.async?Ot.mergeObjectAsync(n,a):Ot.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(t,n,o){return n instanceof ie?new e({keyType:t,valueType:n,typeName:Y.ZodRecord,...ae(o)}):new e({keyType:Fr.create(),valueType:t,typeName:Y.ZodRecord,...ae(n)})}},hc=class extends ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==G.map)return H(o,{code:D.invalid_type,expected:G.map,received:o.parsedType}),V;let a=this._def.keyType,r=this._def.valueType,s=[...o.data.entries()].map(([i,l],c)=>({key:a._parse(new Xn(o,i,o.path,[c,"key"])),value:r._parse(new Xn(o,l,o.path,[c,"value"]))}));if(o.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let l of s){let c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return V;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(c.value,u.value)}return{status:n.value,value:i}})}else{let i=new Map;for(let l of s){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return V;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(c.value,u.value)}return{status:n.value,value:i}}}};hc.create=(e,t,n)=>new hc({valueType:t,keyType:e,typeName:Y.ZodMap,...ae(n)});var mc=class e extends ie{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==G.set)return H(o,{code:D.invalid_type,expected:G.set,received:o.parsedType}),V;let a=this._def;a.minSize!==null&&o.data.size<a.minSize.value&&(H(o,{code:D.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&o.data.size>a.maxSize.value&&(H(o,{code:D.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());let r=this._def.valueType;function s(l){let c=new Set;for(let u of l){if(u.status==="aborted")return V;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}let i=[...o.data.values()].map((l,c)=>r._parse(new Xn(o,l,o.path,c)));return o.common.async?Promise.all(i).then(l=>s(l)):s(i)}min(t,n){return new e({...this._def,minSize:{value:t,message:W.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:W.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};mc.create=(e,t)=>new mc({valueType:e,minSize:null,maxSize:null,typeName:Y.ZodSet,...ae(t)});var H0=class e extends ie{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==G.function)return H(n,{code:D.invalid_type,expected:G.function,received:n.parsedType}),V;function o(i,l){return Jf({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,cc(),Ea].filter(c=>!!c),issueData:{code:D.invalid_arguments,argumentsError:l}})}function a(i,l){return Jf({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,cc(),Ea].filter(c=>!!c),issueData:{code:D.invalid_return_type,returnTypeError:l}})}let r={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof Ur){let i=this;return zt(async function(...l){let c=new en([]),u=await i._def.args.parseAsync(l,r).catch(p=>{throw c.addIssue(o(l,p)),c}),d=await Reflect.apply(s,this,u);return await i._def.returns._def.type.parseAsync(d,r).catch(p=>{throw c.addIssue(a(d,p)),c})})}else{let i=this;return zt(function(...l){let c=i._def.args.safeParse(l,r);if(!c.success)throw new en([o(l,c.error)]);let u=Reflect.apply(s,this,c.data),d=i._def.returns.safeParse(u,r);if(!d.success)throw new en([a(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Uo.create(t).rest(Oa.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,o){return new e({args:t||Uo.create([]).rest(Oa.create()),returns:n||Oa.create(),typeName:Y.ZodFunction,...ae(o)})}},hi=class extends ie{get schema(){return this._def.getter()}_parse(t){let{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};hi.create=(e,t)=>new hi({getter:e,typeName:Y.ZodLazy,...ae(t)});var mi=class extends ie{_parse(t){if(t.data!==this._def.value){let n=this._getOrReturnCtx(t);return H(n,{received:n.data,code:D.invalid_literal,expected:this._def.value}),V}return{status:"valid",value:t.data}}get value(){return this._def.value}};mi.create=(e,t)=>new mi({value:e,typeName:Y.ZodLiteral,...ae(t)});function X9(e,t){return new yi({values:e,typeName:Y.ZodEnum,...ae(t)})}var yi=class e extends ie{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),o=this._def.values;return H(n,{expected:pe.joinValues(o),received:n.parsedType,code:D.invalid_type}),V}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),o=this._def.values;return H(n,{received:n.data,code:D.invalid_enum_value,options:o}),V}return zt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let n of this._def.values)t[n]=n;return t}get Values(){let t={};for(let n of this._def.values)t[n]=n;return t}get Enum(){let t={};for(let n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(o=>!t.includes(o)),{...this._def,...n})}};yi.create=X9;var gi=class extends ie{_parse(t){let n=pe.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==G.string&&o.parsedType!==G.number){let a=pe.objectValues(n);return H(o,{expected:pe.joinValues(a),received:o.parsedType,code:D.invalid_type}),V}if(this._cache||(this._cache=new Set(pe.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let a=pe.objectValues(n);return H(o,{received:o.data,code:D.invalid_enum_value,options:a}),V}return zt(t.data)}get enum(){return this._def.values}};gi.create=(e,t)=>new gi({values:e,typeName:Y.ZodNativeEnum,...ae(t)});var Ur=class extends ie{unwrap(){return this._def.type}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==G.promise&&n.common.async===!1)return H(n,{code:D.invalid_type,expected:G.promise,received:n.parsedType}),V;let o=n.parsedType===G.promise?n.data:Promise.resolve(n.data);return zt(o.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Ur.create=(e,t)=>new Ur({type:e,typeName:Y.ZodPromise,...ae(t)});var Yn=class extends ie{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:o}=this._processInputParams(t),a=this._def.effect||null,r={addIssue:s=>{H(o,s),s.fatal?n.abort():n.dirty()},get path(){return o.path}};if(r.addIssue=r.addIssue.bind(r),a.type==="preprocess"){let s=a.transform(o.data,r);if(o.common.async)return Promise.resolve(s).then(async i=>{if(n.value==="aborted")return V;let l=await this._def.schema._parseAsync({data:i,path:o.path,parent:o});return l.status==="aborted"?V:l.status==="dirty"?ri(l.value):n.value==="dirty"?ri(l.value):l});{if(n.value==="aborted")return V;let i=this._def.schema._parseSync({data:s,path:o.path,parent:o});return i.status==="aborted"?V:i.status==="dirty"?ri(i.value):n.value==="dirty"?ri(i.value):i}}if(a.type==="refinement"){let s=i=>{let l=a.refinement(i,r);if(o.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(o.common.async===!1){let i=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return i.status==="aborted"?V:(i.status==="dirty"&&n.dirty(),s(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(i=>i.status==="aborted"?V:(i.status==="dirty"&&n.dirty(),s(i.value).then(()=>({status:n.value,value:i.value}))))}if(a.type==="transform")if(o.common.async===!1){let s=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!Nr(s))return V;let i=a.transform(s.value,r);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:i}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(s=>Nr(s)?Promise.resolve(a.transform(s.value,r)).then(i=>({status:n.value,value:i})):V);pe.assertNever(a)}};Yn.create=(e,t,n)=>new Yn({schema:e,typeName:Y.ZodEffects,effect:t,...ae(n)});Yn.createWithPreprocess=(e,t,n)=>new Yn({schema:t,effect:{type:"preprocess",transform:e},typeName:Y.ZodEffects,...ae(n)});var Zn=class extends ie{_parse(t){return this._getType(t)===G.undefined?zt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Zn.create=(e,t)=>new Zn({innerType:e,typeName:Y.ZodOptional,...ae(t)});var Go=class extends ie{_parse(t){return this._getType(t)===G.null?zt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Go.create=(e,t)=>new Go({innerType:e,typeName:Y.ZodNullable,...ae(t)});var xi=class extends ie{_parse(t){let{ctx:n}=this._processInputParams(t),o=n.data;return n.parsedType===G.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};xi.create=(e,t)=>new xi({innerType:e,typeName:Y.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ae(t)});var bi=class extends ie{_parse(t){let{ctx:n}=this._processInputParams(t),o={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return uc(a)?a.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new en(o.common.issues)},input:o.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new en(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}};bi.create=(e,t)=>new bi({innerType:e,typeName:Y.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ae(t)});var yc=class extends ie{_parse(t){if(this._getType(t)!==G.nan){let o=this._getOrReturnCtx(t);return H(o,{code:D.invalid_type,expected:G.nan,received:o.parsedType}),V}return{status:"valid",value:t.data}}};yc.create=e=>new yc({typeName:Y.ZodNaN,...ae(e)});var IH=Symbol("zod_brand"),ep=class extends ie{_parse(t){let{ctx:n}=this._processInputParams(t),o=n.data;return this._def.type._parse({data:o,path:n.path,parent:n})}unwrap(){return this._def.type}},tp=class e extends ie{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.common.async)return(async()=>{let r=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return r.status==="aborted"?V:r.status==="dirty"?(n.dirty(),ri(r.value)):this._def.out._parseAsync({data:r.value,path:o.path,parent:o})})();{let a=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?V:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:o.path,parent:o})}}static create(t,n){return new e({in:t,out:n,typeName:Y.ZodPipeline})}},Ai=class extends ie{_parse(t){let n=this._def.innerType._parse(t),o=a=>(Nr(a)&&(a.value=Object.freeze(a.value)),a);return uc(n)?n.then(a=>o(a)):o(n)}unwrap(){return this._def.innerType}};Ai.create=(e,t)=>new Ai({innerType:e,typeName:Y.ZodReadonly,...ae(t)});function W9(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function Y9(e,t={},n){return e?Hr.create().superRefine((o,a)=>{let r=e(o);if(r instanceof Promise)return r.then(s=>{if(!s){let i=W9(t,o),l=i.fatal??n??!0;a.addIssue({code:"custom",...i,fatal:l})}});if(!r){let s=W9(t,o),i=s.fatal??n??!0;a.addIssue({code:"custom",...s,fatal:i})}}):Hr.create()}var EH={object:tn.lazycreate},Y;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Y||(Y={}));var MH=(e,t={message:`Input not instance of ${e.name}`})=>Y9(n=>n instanceof e,t),K9=Fr.create,$9=si.create,OH=yc.create,RH=ii.create,Q9=li.create,DH=ci.create,PH=fc.create,BH=ui.create,zH=di.create,NH=Hr.create,FH=Oa.create,HH=mo.create,UH=pc.create,GH=Ra.create,qH=tn.create,WH=tn.strictCreate,jH=fi.create,VH=N0.create,ZH=pi.create,XH=Uo.create,YH=F0.create,KH=hc.create,$H=mc.create,QH=H0.create,JH=hi.create,eU=mi.create,tU=yi.create,nU=gi.create,oU=Ur.create,aU=Yn.create,rU=Zn.create,sU=Go.create,iU=Yn.createWithPreprocess,lU=tp.create,cU=()=>K9().optional(),uU=()=>$9().optional(),dU=()=>Q9().optional(),fU={string:(e=>Fr.create({...e,coerce:!0})),number:(e=>si.create({...e,coerce:!0})),boolean:(e=>li.create({...e,coerce:!0})),bigint:(e=>ii.create({...e,coerce:!0})),date:(e=>ci.create({...e,coerce:!0}))};var pU=V;var mU=["basic","layout","flowchart","custom","rich"],sv=({registry:e=ai,categories:t=mU,collapsedByDefault:n=[],searchQuery:o,layout:a="grid",style:r,className:s})=>{let i=a==="list"?"du-palette-list":"du-palette-grid",l=(0,Kn.useMemo)(()=>new Set(e.categories()),[e]),c=(0,Kn.useMemo)(()=>t.filter(b=>l.has(b)),[t,l]),u=(0,Kn.useMemo)(()=>c.map(b=>({category:b,items:e.byCategory(b)})),[e,c]),[d,f]=(0,Kn.useState)(()=>new Set(n)),p=b=>{f(y=>{let g=new Set(y);return g.has(b)?g.delete(b):g.add(b),g})},h=o?.trim()??"",m=(0,Kn.useMemo)(()=>{if(!h)return[];let b=[];for(let{items:y}of u)for(let g of y)nv(g,h)&&b.push(g);return b},[u,h]);return(0,pt.jsx)("aside",{className:`du-palette ${s??""}`.trim(),style:r,children:(0,pt.jsx)("div",{className:"du-palette-body",children:h?m.length===0?(0,pt.jsxs)("div",{className:"du-palette-empty",children:["No templates match \u201C",h,"\u201D"]}):(0,pt.jsx)("div",{className:i,children:m.map(b=>(0,pt.jsx)(n8,{template:b},b.id))}):u.map(({category:b,items:y})=>(0,pt.jsx)(yU,{category:b,items:y,itemsClass:i,collapsed:d.has(b),onToggle:()=>{p(b)}},b))})})},yU=({category:e,items:t,itemsClass:n,collapsed:o,onToggle:a})=>t.length===0?null:(0,pt.jsxs)("section",{className:"du-palette-section",children:[(0,pt.jsxs)("button",{type:"button",onClick:a,"aria-expanded":!o,className:"du-palette-category",children:[(0,pt.jsx)("span",{children:e}),(0,pt.jsx)("span",{className:"du-palette-category-caret","aria-hidden":!0,children:o?(0,pt.jsx)(ks,{size:12,strokeWidth:1.75}):(0,pt.jsx)(Zu,{size:12,strokeWidth:1.75})})]}),o?null:(0,pt.jsx)("div",{className:n,children:t.map(r=>(0,pt.jsx)(n8,{template:r},r.id))})]}),np=null,e8=vA(),J9=e=>{np!==e&&(np=e,e8.emit())};var t8=e=>e8.add(e);var U0=null,gU=()=>{if(typeof document>"u")return null;if(U0&&document.body.contains(U0))return U0;let e=document.createElement("div");return e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;top:-1000px;left:-1000px;width:1px;height:1px;background:rgba(0,0,0,0.01)",document.body.appendChild(e),U0=e,e},n8=({template:e})=>{let t=j(),n=r=>{r.dataTransfer.setData("application/x-template-id",e.id),r.dataTransfer.effectAllowed="copy";let s=gU();s&&r.dataTransfer.setDragImage(s,0,0),J9(e)},o=()=>{J9(null)},a=()=>{if(!t||typeof window<"u"&&!window.matchMedia("(pointer: coarse)").matches)return;let s=t.hostElement.getBoundingClientRect(),i=t.screenToWorld({x:s.width/2,y:s.height/2}),l=Qe(`shape-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`),c=e.factory({id:l,layerId:bn,position:i,order:we([...t.scene.elements.values()].filter(d=>d.layerId===bn).map(d=>d.order))}),u=t.beginPlacement(c);u.update(i),u.commit()};return(0,pt.jsxs)("div",{role:"button",draggable:!0,title:e.name,onDragStart:n,onDragEnd:o,onClick:a,className:"du-palette-item",children:[(0,pt.jsx)("span",{className:"du-palette-item-icon",style:{width:28,height:28},dangerouslySetInnerHTML:{__html:e.icon}}),(0,pt.jsx)("span",{className:"du-palette-item-label",children:e.name})]})},iv=()=>{let e=j(),t=(0,Kn.useRef)(null);(0,Kn.useEffect)(()=>{let a=r=>{r.key!=="Escape"||!t.current||(t.current.cancel(),t.current=null)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[]),(0,Kn.useEffect)(()=>t8(()=>{np===null&&t.current&&(t.current.cancel(),t.current=null)}),[]);let n=a=>{if(t.current||!e||!np)return!1;let r=np,s=a.currentTarget.getBoundingClientRect(),i={x:a.clientX-s.left,y:a.clientY-s.top},l=e.screenToWorld(i),c=Qe(`shape-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`),u=r.factory({id:c,layerId:bn,position:l,order:we([...e.scene.elements.values()].filter(d=>d.layerId===bn).map(d=>d.order))});return t.current=e.beginPlacement(u),t.current.update(l),!0},o=a=>{if(!e)return null;let r=a.currentTarget.getBoundingClientRect();return e.screenToWorld({x:a.clientX-r.left,y:a.clientY-r.top})};return{onDragEnter:a=>{let r=a.dataTransfer.types,s=r.includes("application/x-template-id"),i=r.includes("Files");!s&&!i||(a.preventDefault(),s&&n(a))},onDragOver:a=>{let r=a.dataTransfer.types,s=r.includes("application/x-template-id"),i=r.includes("Files");if(!(!s&&!i)&&(a.preventDefault(),a.dataTransfer.dropEffect="copy",s)){t.current||n(a);let l=o(a);l&&t.current&&t.current.update(l)}},onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||t.current&&(t.current.cancel(),t.current=null)},onDrop:a=>{if(a.preventDefault(),t.current){let l=o(a);l&&t.current.update(l),t.current.commit(),t.current=null;return}let r=a.dataTransfer;if(!r)return;let i=o(a)??{x:0,y:0};e&&(async()=>{for await(let l of wA(r,{onError:(c,u)=>{console.warn(`[file-drop] failed at ${c}:`,u)}}))e.dispatchFileDrop(l,i)})()}}};var lv=14,cv=1.75,G0=({open:e,onClose:t,side:n="right",sheet:o=!1,onImport:a,style:r})=>{let[s,i]=(0,vi.useState)("");(0,vi.useEffect)(()=>{e||i("")},[e]);let l=(0,vi.useRef)(null);return(0,vi.useEffect)(()=>{e&&l.current?.focus()},[e]),e?(0,nn.jsxs)("aside",{className:`du-side-panel ${o?"du-side-panel-sheet":n==="right"?"du-side-panel-right":"du-side-panel-left"}`,style:r,children:[(0,nn.jsx)("header",{className:"du-side-panel-header",children:(0,nn.jsxs)("div",{style:{display:"inline-flex",gap:4},children:[a?(0,nn.jsx)(Bn,{label:"Import templates",size:"sm",onClick:a,children:(0,nn.jsx)(Od,{size:lv,strokeWidth:cv})}):null,(0,nn.jsx)(Bn,{label:"Close library",size:"sm",onClick:t,children:(0,nn.jsx)(ba,{size:lv,strokeWidth:cv})})]})}),(0,nn.jsxs)("div",{className:"du-side-panel-search",children:[(0,nn.jsx)(kd,{size:lv,strokeWidth:cv,className:"du-side-panel-search-icon","aria-hidden":!0}),(0,nn.jsx)("input",{ref:l,type:"search",value:s,placeholder:"Search templates\u2026","aria-label":"Search templates",onChange:u=>{i(u.target.value)},onKeyDown:u=>{u.key==="Escape"&&s&&(u.stopPropagation(),i(""))}})]}),(0,nn.jsx)("div",{className:"du-side-panel-body du-side-panel-body-flush",children:(0,nn.jsx)(sv,{searchQuery:s,layout:"list"})})]}):null};var dp=F(ye(),1);var gc=Math.min,Da=Math.max,ap=Math.round,rp=Math.floor,yo=e=>({x:e,y:e}),xU={left:"right",right:"left",bottom:"top",top:"bottom"};function uv(e,t,n){return Da(e,gc(t,n))}function sp(e,t){return typeof e=="function"?e(t):e}function Gr(e){return e.split("-")[0]}function ip(e){return e.split("-")[1]}function dv(e){return e==="x"?"y":"x"}function fv(e){return e==="y"?"height":"width"}function Pa(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function pv(e){return dv(Pa(e))}function r8(e,t,n){n===void 0&&(n=!1);let o=ip(e),a=pv(e),r=fv(a),s=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(s=op(s)),[s,op(s)]}function s8(e){let t=op(e);return[q0(e),t,q0(t)]}function q0(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var o8=["left","right"],a8=["right","left"],bU=["top","bottom"],AU=["bottom","top"];function vU(e,t,n){switch(e){case"top":case"bottom":return n?t?a8:o8:t?o8:a8;case"left":case"right":return t?bU:AU;default:return[]}}function i8(e,t,n,o){let a=ip(e),r=vU(Gr(e),n==="start",o);return a&&(r=r.map(s=>s+"-"+a),t&&(r=r.concat(r.map(q0)))),r}function op(e){let t=Gr(e);return xU[t]+e.slice(t.length)}function LU(e){return{top:0,right:0,bottom:0,left:0,...e}}function l8(e){return typeof e!="number"?LU(e):{top:e,right:e,bottom:e,left:e}}function Li(e){let{x:t,y:n,width:o,height:a}=e;return{width:o,height:a,top:n,left:t,right:t+o,bottom:n+a,x:t,y:n}}function c8(e,t,n){let{reference:o,floating:a}=e,r=Pa(t),s=pv(t),i=fv(s),l=Gr(t),c=r==="y",u=o.x+o.width/2-a.width/2,d=o.y+o.height/2-a.height/2,f=o[i]/2-a[i]/2,p;switch(l){case"top":p={x:u,y:o.y-a.height};break;case"bottom":p={x:u,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-a.width,y:d};break;default:p={x:o.x,y:o.y}}switch(ip(t)){case"start":p[s]-=f*(n&&c?-1:1);break;case"end":p[s]+=f*(n&&c?-1:1);break}return p}async function u8(e,t){var n;t===void 0&&(t={});let{x:o,y:a,platform:r,rects:s,elements:i,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=sp(t,e),h=l8(p),b=i[f?d==="floating"?"reference":"floating":d],y=Li(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(b)))==null||n?b:b.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(i.floating)),boundary:c,rootBoundary:u,strategy:l})),g=d==="floating"?{x:o,y:a,width:s.floating.width,height:s.floating.height}:s.reference,x=await(r.getOffsetParent==null?void 0:r.getOffsetParent(i.floating)),A=await(r.isElement==null?void 0:r.isElement(x))?await(r.getScale==null?void 0:r.getScale(x))||{x:1,y:1}:{x:1,y:1},C=Li(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:g,offsetParent:x,strategy:l}):g);return{top:(y.top-C.top+h.top)/A.y,bottom:(C.bottom-y.bottom+h.bottom)/A.y,left:(y.left-C.left+h.left)/A.x,right:(C.right-y.right+h.right)/A.x}}var SU=50,d8=async(e,t,n)=>{let{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:s}=n,i=s.detectOverflow?s:{...s,detectOverflow:u8},l=await(s.isRTL==null?void 0:s.isRTL(t)),c=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:u,y:d}=c8(c,o,l),f=o,p=0,h={};for(let m=0;m<r.length;m++){let b=r[m];if(!b)continue;let{name:y,fn:g}=b,{x,y:A,data:C,reset:_}=await g({x:u,y:d,initialPlacement:o,placement:f,strategy:a,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});u=x??u,d=A??d,h[y]={...h[y],...C},_&&p<SU&&(p++,typeof _=="object"&&(_.placement&&(f=_.placement),_.rects&&(c=_.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:a}):_.rects),{x:u,y:d}=c8(c,f,l)),m=-1)}return{x:u,y:d,placement:f,strategy:a,middlewareData:h}};var f8=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;let{placement:a,middlewareData:r,rects:s,initialPlacement:i,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:m=!0,...b}=sp(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let y=Gr(a),g=Pa(i),x=Gr(i)===i,A=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=f||(x||!m?[op(i)]:s8(i)),_=h!=="none";!f&&_&&C.push(...i8(i,m,h,A));let v=[i,...C],I=await l.detectOverflow(t,b),k=[],T=((o=r.flip)==null?void 0:o.overflows)||[];if(u&&k.push(I[y]),d){let q=r8(a,s,A);k.push(I[q[0]],I[q[1]])}if(T=[...T,{placement:a,overflows:k}],!k.every(q=>q<=0)){var P,N;let q=(((P=r.flip)==null?void 0:P.index)||0)+1,te=v[q];if(te&&(!(d==="alignment"?g!==Pa(te):!1)||T.every($=>Pa($.placement)===g?$.overflows[0]>0:!0)))return{data:{index:q,overflows:T},reset:{placement:te}};let Z=(N=T.filter(ue=>ue.overflows[0]<=0).sort((ue,$)=>ue.overflows[1]-$.overflows[1])[0])==null?void 0:N.placement;if(!Z)switch(p){case"bestFit":{var U;let ue=(U=T.filter($=>{if(_){let re=Pa($.placement);return re===g||re==="y"}return!0}).map($=>[$.placement,$.overflows.filter(re=>re>0).reduce((re,We)=>re+We,0)]).sort(($,re)=>$[1]-re[1])[0])==null?void 0:U[0];ue&&(Z=ue);break}case"initialPlacement":Z=i;break}if(a!==Z)return{reset:{placement:Z}}}return{}}}};var kU=new Set(["left","top"]);async function wU(e,t){let{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),s=Gr(n),i=ip(n),l=Pa(n)==="y",c=kU.has(s)?-1:1,u=r&&l?-1:1,d=sp(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:h}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return i&&typeof h=="number"&&(p=i==="end"?h*-1:h),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}var p8=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;let{x:a,y:r,placement:s,middlewareData:i}=t,l=await wU(t,e);return s===((n=i.offset)==null?void 0:n.placement)&&(o=i.arrow)!=null&&o.alignmentOffset?{}:{x:a+l.x,y:r+l.y,data:{...l,placement:s}}}}},h8=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:o,placement:a,platform:r}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:l={fn:y=>{let{x:g,y:x}=y;return{x:g,y:x}}},...c}=sp(e,t),u={x:n,y:o},d=await r.detectOverflow(t,c),f=Pa(Gr(a)),p=dv(f),h=u[p],m=u[f];if(s){let y=p==="y"?"top":"left",g=p==="y"?"bottom":"right",x=h+d[y],A=h-d[g];h=uv(x,h,A)}if(i){let y=f==="y"?"top":"left",g=f==="y"?"bottom":"right",x=m+d[y],A=m-d[g];m=uv(x,m,A)}let b=l.fn({...t,[p]:h,[f]:m});return{...b,data:{x:b.x-n,y:b.y-o,enabled:{[p]:s,[f]:i}}}}}};function W0(){return typeof window<"u"}function ki(e){return y8(e)?(e.nodeName||"").toLowerCase():"#document"}function on(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function go(e){var t;return(t=(y8(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function y8(e){return W0()?e instanceof Node||e instanceof on(e).Node:!1}function $n(e){return W0()?e instanceof Element||e instanceof on(e).Element:!1}function qo(e){return W0()?e instanceof HTMLElement||e instanceof on(e).HTMLElement:!1}function m8(e){return!W0()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof on(e).ShadowRoot}function bc(e){let{overflow:t,overflowX:n,overflowY:o,display:a}=Qn(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&a!=="inline"&&a!=="contents"}function g8(e){return/^(table|td|th)$/.test(ki(e))}function lp(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var _U=/transform|translate|scale|rotate|perspective|filter/,CU=/paint|layout|strict|content/,Si=e=>!!e&&e!=="none",hv;function j0(e){let t=$n(e)?Qn(e):e;return Si(t.transform)||Si(t.translate)||Si(t.scale)||Si(t.rotate)||Si(t.perspective)||!V0()&&(Si(t.backdropFilter)||Si(t.filter))||_U.test(t.willChange||"")||CU.test(t.contain||"")}function x8(e){let t=Ba(e);for(;qo(t)&&!wi(t);){if(j0(t))return t;if(lp(t))return null;t=Ba(t)}return null}function V0(){return hv==null&&(hv=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),hv}function wi(e){return/^(html|body|#document)$/.test(ki(e))}function Qn(e){return on(e).getComputedStyle(e)}function cp(e){return $n(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ba(e){if(ki(e)==="html")return e;let t=e.assignedSlot||e.parentNode||m8(e)&&e.host||go(e);return m8(t)?t.host:t}function b8(e){let t=Ba(e);return wi(t)?e.ownerDocument?e.ownerDocument.body:e.body:qo(t)&&bc(t)?t:b8(t)}function xc(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);let a=b8(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),s=on(a);if(r){let i=Z0(s);return t.concat(s,s.visualViewport||[],bc(a)?a:[],i&&n?xc(i):[])}else return t.concat(a,xc(a,[],n))}function Z0(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function S8(e){let t=Qn(e),n=parseFloat(t.width)||0,o=parseFloat(t.height)||0,a=qo(e),r=a?e.offsetWidth:n,s=a?e.offsetHeight:o,i=ap(n)!==r||ap(o)!==s;return i&&(n=r,o=s),{width:n,height:o,$:i}}function yv(e){return $n(e)?e:e.contextElement}function Ac(e){let t=yv(e);if(!qo(t))return yo(1);let n=t.getBoundingClientRect(),{width:o,height:a,$:r}=S8(t),s=(r?ap(n.width):n.width)/o,i=(r?ap(n.height):n.height)/a;return(!s||!Number.isFinite(s))&&(s=1),(!i||!Number.isFinite(i))&&(i=1),{x:s,y:i}}var TU=yo(0);function k8(e){let t=on(e);return!V0()||!t.visualViewport?TU:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function IU(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==on(e)?!1:t}function _i(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),r=yv(e),s=yo(1);t&&(o?$n(o)&&(s=Ac(o)):s=Ac(e));let i=IU(r,n,o)?k8(r):yo(0),l=(a.left+i.x)/s.x,c=(a.top+i.y)/s.y,u=a.width/s.x,d=a.height/s.y;if(r){let f=on(r),p=o&&$n(o)?on(o):o,h=f,m=Z0(h);for(;m&&o&&p!==h;){let b=Ac(m),y=m.getBoundingClientRect(),g=Qn(m),x=y.left+(m.clientLeft+parseFloat(g.paddingLeft))*b.x,A=y.top+(m.clientTop+parseFloat(g.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=x,c+=A,h=on(m),m=Z0(h)}}return Li({width:u,height:d,x:l,y:c})}function X0(e,t){let n=cp(e).scrollLeft;return t?t.left+n:_i(go(e)).left+n}function w8(e,t){let n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-X0(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function EU(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e,r=a==="fixed",s=go(o),i=t?lp(t.floating):!1;if(o===s||i&&r)return n;let l={scrollLeft:0,scrollTop:0},c=yo(1),u=yo(0),d=qo(o);if((d||!d&&!r)&&((ki(o)!=="body"||bc(s))&&(l=cp(o)),d)){let p=_i(o);c=Ac(o),u.x=p.x+o.clientLeft,u.y=p.y+o.clientTop}let f=s&&!d&&!r?w8(s,l):yo(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function MU(e){return Array.from(e.getClientRects())}function OU(e){let t=go(e),n=cp(e),o=e.ownerDocument.body,a=Da(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=Da(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight),s=-n.scrollLeft+X0(e),i=-n.scrollTop;return Qn(o).direction==="rtl"&&(s+=Da(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:s,y:i}}var A8=25;function RU(e,t){let n=on(e),o=go(e),a=n.visualViewport,r=o.clientWidth,s=o.clientHeight,i=0,l=0;if(a){r=a.width,s=a.height;let u=V0();(!u||u&&t==="fixed")&&(i=a.offsetLeft,l=a.offsetTop)}let c=X0(o);if(c<=0){let u=o.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,h=Math.abs(o.clientWidth-d.clientWidth-p);h<=A8&&(r-=h)}else c<=A8&&(r+=c);return{width:r,height:s,x:i,y:l}}function DU(e,t){let n=_i(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=qo(e)?Ac(e):yo(1),s=e.clientWidth*r.x,i=e.clientHeight*r.y,l=a*r.x,c=o*r.y;return{width:s,height:i,x:l,y:c}}function v8(e,t,n){let o;if(t==="viewport")o=RU(e,n);else if(t==="document")o=OU(go(e));else if($n(t))o=DU(t,n);else{let a=k8(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Li(o)}function _8(e,t){let n=Ba(e);return n===t||!$n(n)||wi(n)?!1:Qn(n).position==="fixed"||_8(n,t)}function PU(e,t){let n=t.get(e);if(n)return n;let o=xc(e,[],!1).filter(i=>$n(i)&&ki(i)!=="body"),a=null,r=Qn(e).position==="fixed",s=r?Ba(e):e;for(;$n(s)&&!wi(s);){let i=Qn(s),l=j0(s);!l&&i.position==="fixed"&&(a=null),(r?!l&&!a:!l&&i.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||bc(s)&&!l&&_8(e,s))?o=o.filter(u=>u!==s):a=i,s=Ba(s)}return t.set(e,o),o}function BU(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e,s=[...n==="clippingAncestors"?lp(t)?[]:PU(t,this._c):[].concat(n),o],i=v8(t,s[0],a),l=i.top,c=i.right,u=i.bottom,d=i.left;for(let f=1;f<s.length;f++){let p=v8(t,s[f],a);l=Da(p.top,l),c=gc(p.right,c),u=gc(p.bottom,u),d=Da(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function zU(e){let{width:t,height:n}=S8(e);return{width:t,height:n}}function NU(e,t,n){let o=qo(t),a=go(t),r=n==="fixed",s=_i(e,!0,r,t),i={scrollLeft:0,scrollTop:0},l=yo(0);function c(){l.x=X0(a)}if(o||!o&&!r)if((ki(t)!=="body"||bc(a))&&(i=cp(t)),o){let p=_i(t,!0,r,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else a&&c();r&&!o&&a&&c();let u=a&&!o&&!r?w8(a,i):yo(0),d=s.left+i.scrollLeft-l.x-u.x,f=s.top+i.scrollTop-l.y-u.y;return{x:d,y:f,width:s.width,height:s.height}}function mv(e){return Qn(e).position==="static"}function L8(e,t){if(!qo(e)||Qn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return go(e)===n&&(n=n.ownerDocument.body),n}function C8(e,t){let n=on(e);if(lp(e))return n;if(!qo(e)){let a=Ba(e);for(;a&&!wi(a);){if($n(a)&&!mv(a))return a;a=Ba(a)}return n}let o=L8(e,t);for(;o&&g8(o)&&mv(o);)o=L8(o,t);return o&&wi(o)&&mv(o)&&!j0(o)?n:o||x8(e)||n}var FU=async function(e){let t=this.getOffsetParent||C8,n=this.getDimensions,o=await n(e.floating);return{reference:NU(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function HU(e){return Qn(e).direction==="rtl"}var UU={convertOffsetParentRelativeRectToViewportRelativeRect:EU,getDocumentElement:go,getClippingRect:BU,getOffsetParent:C8,getElementRects:FU,getClientRects:MU,getDimensions:zU,getScale:Ac,isElement:$n,isRTL:HU};function T8(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function GU(e,t){let n=null,o,a=go(e);function r(){var i;clearTimeout(o),(i=n)==null||i.disconnect(),n=null}function s(i,l){i===void 0&&(i=!1),l===void 0&&(l=1),r();let c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(i||t(),!f||!p)return;let h=rp(d),m=rp(a.clientWidth-(u+f)),b=rp(a.clientHeight-(d+p)),y=rp(u),x={rootMargin:-h+"px "+-m+"px "+-b+"px "+-y+"px",threshold:Da(0,gc(1,l))||1},A=!0;function C(_){let v=_[0].intersectionRatio;if(v!==l){if(!A)return s();v?s(!1,v):o=setTimeout(()=>{s(!1,1e-7)},1e3)}v===1&&!T8(c,e.getBoundingClientRect())&&s(),A=!1}try{n=new IntersectionObserver(C,{...x,root:a.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return s(!0),r}function Y0(e,t,n,o){o===void 0&&(o={});let{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,c=yv(e),u=a||r?[...c?xc(c):[],...t?xc(t):[]]:[];u.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});let d=c&&i?GU(c,n):null,f=-1,p=null;s&&(p=new ResizeObserver(y=>{let[g]=y;g&&g.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let h,m=l?_i(e):null;l&&b();function b(){let y=_i(e);m&&!T8(m,y)&&n(),m=y,h=requestAnimationFrame(b)}return n(),()=>{var y;u.forEach(g=>{a&&g.removeEventListener("scroll",n),r&&g.removeEventListener("resize",n)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(h)}}var K0=p8;var $0=h8,Q0=f8;var J0=(e,t,n)=>{let o=new Map,a={platform:UU,...n},r={...a.platform,_c:o};return d8(e,t,{...a,platform:r})};var Wo=F(he(),1),Lv=F(Yo(),1);var S=F(ye(),1),Wr=F(he(),1);var I8=F(ye(),1),qr=F(he(),1),E8=(0,qr.createContext)(null),M8=({children:e})=>{let t=(0,qr.useRef)(null),n=(0,qr.useMemo)(()=>({open:o=>t.current?.(o),register:o=>(t.current=o,()=>{t.current===o&&(t.current=null)})}),[]);return(0,I8.jsx)(E8.Provider,{value:n,children:e})},ey=()=>(0,qr.useContext)(E8);var an=F(ye(),1),D8=F(he(),1);var qU=Or.map(e=>tc.light[e].fill),WU=Or.map(e=>tc.light[e].solid),jU=Or.map(e=>tc.dark[e].fill),VU=Or.map(e=>tc.dark[e].solid),ZU=Or.map(e=>n0.light[e]),XU=Or.map(e=>n0.dark[e]),ty=[...qU,...WU,"#ffffff","#1e1e1e","transparent"],gv=[...jU,...VU,"#1e1e1e","#ffffff","transparent"],Ace=["#ffffff",...ZU],vce=["#121113",...XU],O8=e=>e==="light"||e==="dark"?e:typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";var xv=({value:e,onChange:t,palette:n,allowCustom:o=!0,allowClear:a=!0})=>{let r=n??QU(),[s,i]=(0,D8.useState)(!1);return(0,an.jsxs)("div",{className:"du-swatch-grid",role:"radiogroup","aria-label":"Colour",children:[r.map(l=>(0,an.jsx)(YU,{color:l,selected:R8(l)===R8(e),onClick:()=>{t(l==="transparent"?null:l)}},l)),o?(0,an.jsx)(KU,{value:e,onChange:t,open:s,onOpenChange:i}):null,a?(0,an.jsx)("button",{type:"button","aria-label":"Clear colour",title:"Clear colour",onClick:()=>{t(null)},className:"du-swatch du-swatch-clear",children:(0,an.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,an.jsx)(ba,{size:12,strokeWidth:2})})}):null]})},YU=({color:e,selected:t,onClick:n})=>(0,an.jsx)("button",{type:"button",role:"radio","aria-checked":t,"aria-label":e,title:e,onClick:n,className:"du-swatch",children:(0,an.jsx)("span",{className:"du-swatch-fill",style:{background:e==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":e}})}),KU=({value:e,onChange:t,open:n,onOpenChange:o})=>{let a=!!e&&e!=="transparent";return(0,an.jsxs)("label",{className:"du-swatch du-swatch-custom",title:"Pick custom colour",children:[(0,an.jsx)("span",{className:"du-swatch-fill",style:a?{background:e}:void 0,children:a?null:(0,an.jsx)(Ts,{size:12,strokeWidth:2})}),(0,an.jsx)("input",{type:"color","aria-label":"Custom colour",value:$U(e),onChange:r=>{t(r.target.value),o(!1)},onClick:()=>{o(!n)},className:"du-swatch-color-input"})]})},R8=e=>e===null?"transparent":e.toLowerCase(),$U=e=>{if(!e||e==="transparent")return"#000000";if(/^#[0-9a-f]{6}$/i.test(e))return e.toLowerCase();if(/^#[0-9a-f]{3}$/i.test(e)){let t=e.slice(1);return`#${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`.toLowerCase()}return"#000000"},QU=()=>{if(typeof document>"u")return ty;let e=document.documentElement.getAttribute("data-theme");return e==="dark"?gv:e==="light"?ty:O8("system")==="dark"?gv:ty};var vc=F(ye(),1);var ht=F(he(),1),P8=F(Yo(),1);var xo=({trigger:e,children:t,placement:n="bottom-start",offset:o=6,className:a,open:r,onOpenChange:s,ariaLabel:i})=>{let l=Et(),[c,u]=(0,ht.useState)(!1),d=r!==void 0,f=d?r:c,p=(0,ht.useCallback)(g=>{d||u(g),s?.(g)},[d,s]),h=(0,ht.useId)(),m=(0,ht.useRef)(null),b=(0,ht.useRef)(null);(0,ht.useLayoutEffect)(()=>{if(!f)return;let g=m.current,x=b.current;if(!g||!x)return;let A=()=>{J0(g,x,{placement:n,middleware:[K0(o),Q0(),$0({padding:6})]}).then(({x:_,y:v})=>{x.style.transform=`translate(${Math.round(_)}px, ${Math.round(v)}px)`})};return A(),Y0(g,x,A)},[f,n,o]),(0,ht.useEffect)(()=>{if(!f)return;let g=A=>{let C=A.target;C&&(m.current?.contains(C)||b.current?.contains(C)||p(!1))},x=A=>{A.key==="Escape"&&(A.stopPropagation(),p(!1),m.current?.focus())};return document.addEventListener("pointerdown",g),document.addEventListener("keydown",x),()=>{document.removeEventListener("pointerdown",g),document.removeEventListener("keydown",x)}},[f,p]);let y=(0,ht.useMemo)(()=>{if(!(0,ht.isValidElement)(e))return e;let g=e.props;return(0,ht.cloneElement)(e,{ref:x=>{m.current=x;let A=e.ref;typeof A=="function"?A(x):A&&typeof A=="object"&&(A.current=x)},onClick:x=>{let A=g.onClick;A?.(x),!x.defaultPrevented&&p(!f)},"aria-haspopup":"dialog","aria-expanded":f,"aria-controls":f?h:void 0})},[e,f,p,h]);return(0,vc.jsxs)(vc.Fragment,{children:[y,f?(0,P8.createPortal)((0,vc.jsx)("div",{ref:b,id:h,role:"dialog","aria-label":i,className:`du-popover ${a??""}`.trim(),style:{position:"absolute",top:0,left:0,zIndex:1600},children:t}),l):null]})};var Av=({style:e,className:t,mobile:n=!1})=>{let o=D0(),a=ev(),r=oi();if(o.size>0){let s=[...o].map(f=>r.elements.get(f)).filter(f=>f!==void 0);if(s.length===0)return null;let i=s.every(f=>Fe(f)),l=s.every(f=>Ut(f)),c=s.every(f=>He(f)),u=[],d=[];return c?u.push((0,S.jsx)(N8,{shapes:s},"fill")):i?(u.push((0,S.jsx)(tG,{shapes:s},"size"),(0,S.jsx)(eG,{shapes:s},"color"),(0,S.jsx)(oG,{shapes:s},"align")),d.push((0,S.jsx)(nG,{shapes:s},"family"),(0,S.jsx)(aG,{shapes:s},"decor"))):l?u.push((0,S.jsx)(F8,{shapes:s},"opacity")):(u.push((0,S.jsx)(N8,{shapes:s},"fill"),(0,S.jsx)(rG,{shapes:s},"stroke"),(0,S.jsx)(sG,{shapes:s},"width")),d.push((0,S.jsx)(iG,{shapes:s},"dash"),(0,S.jsx)(lG,{shapes:s},"round"),(0,S.jsx)(F8,{shapes:s},"opacity"))),d.push((0,S.jsx)(cG,{},"z"),(0,S.jsx)(JU,{shapes:s},"link")),s.length>=2&&d.push((0,S.jsx)(fG,{},"align")),d.push((0,S.jsx)(uG,{shapes:s},"actions"),(0,S.jsx)(z8,{},"more")),(0,S.jsx)(B8,{mobile:n,primary:u,overflow:d,className:t,style:e})}if(a!==null){let s=r.links.get(a);if(!s)return null;let i=[(0,S.jsx)(pG,{edge:s},"color"),(0,S.jsx)(hG,{edge:s},"width"),(0,S.jsx)(H8,{edge:s,side:"to"},"arrow-to")],l=[(0,S.jsx)(mG,{edge:s},"dash"),(0,S.jsx)(gG,{edge:s},"routing"),(0,S.jsx)(yG,{edge:s},"kind"),(0,S.jsx)(H8,{edge:s,side:"from"},"arrow-from"),(0,S.jsx)(xG,{edge:s},"auto"),(0,S.jsx)(bG,{},"delete"),(0,S.jsx)(z8,{},"more")];return(0,S.jsx)(B8,{mobile:n,primary:i,overflow:l,className:t,style:e})}return null},B8=({mobile:e,primary:t,overflow:n,className:o,style:a})=>{let[r,s]=(0,Wr.useState)(!1),i=(0,Wr.useRef)(null);return(0,Wr.useEffect)(()=>{if(!e||!r)return;let l=c=>{let u=i.current;u&&c.target instanceof Node&&!u.contains(c.target)&&s(!1)};return document.addEventListener("pointerdown",l,!0),()=>{document.removeEventListener("pointerdown",l,!0)}},[e,r]),e?(0,S.jsxs)("div",{ref:i,className:`du-sel-panel du-sel-panel-mobile ${o??""}`.trim(),style:a,children:[(0,S.jsxs)("div",{className:"du-sel-mobile-row",children:[(0,S.jsx)("div",{className:"du-sel-mobile-primary",children:t}),n.length>0?(0,S.jsx)("button",{type:"button",className:`du-sel-icon-button du-sel-mobile-expand${r?" is-active":""}`,"aria-expanded":r,"aria-label":r?"Hide more properties":"More properties",title:"More properties",onClick:()=>{s(l=>!l)},children:(0,S.jsx)(br,{size:18,strokeWidth:1.75,"aria-hidden":!0})}):null]}),r&&n.length>0?(0,S.jsx)("div",{className:"du-sel-mobile-overflow",children:n}):null]}):(0,S.jsxs)("div",{className:`du-sel-panel ${o??""}`.trim(),style:a,children:[t,n.length>0?(0,S.jsx)(LG,{}):null,n]})},JU=({shapes:e})=>{let t=j(),n=(0,Wr.useRef)(null);if(!t)return null;let o=e.map(i=>i.id),a=up(e,i=>i.href),r=e.some(i=>!!i.href),s=i=>{t.setLink(o,i)};return(0,S.jsx)(xo,{ariaLabel:"Link",trigger:(0,S.jsx)("button",{type:"button",className:`du-sel-icon-button${r?" is-active":""}`,title:"Link","aria-label":"Link",children:(0,S.jsx)(ud,{size:14,strokeWidth:1.75,"aria-hidden":!0})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Link"}),(0,S.jsx)("input",{ref:n,className:"du-sel-link-input",type:"text",placeholder:"https://\u2026 \xB7 name@mail",defaultValue:a??"","aria-label":"Link URL",onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),s(i.currentTarget.value))}}),(0,S.jsxs)("div",{style:{display:"flex",gap:2},children:[(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{s(n.current?.value??"")},children:"Save"}),r?(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{t.openLink(a)},children:"Open"}):null,r?(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{t.setLink(o,null)},children:"Remove"}):null]})]})})},z8=()=>{let e=j(),t=ey();return!e||!t?null:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"More actions","aria-label":"More actions",onClick:n=>{let o=n.currentTarget.getBoundingClientRect(),a={x:o.left,y:o.bottom+4},s=e.hostElement?.getBoundingClientRect(),i=s?e.screenToWorld({x:a.x-s.left,y:a.y-s.top}):{x:0,y:0};t.open({screenPoint:a,worldPoint:i})},children:(0,S.jsx)(Ar,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},vv=({label:e,color:t,onChange:n,ariaLabel:o})=>(0,S.jsx)(xo,{ariaLabel:o,trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-color-trigger",title:e,"aria-label":o,children:(0,S.jsx)("span",{className:"du-sel-color-swatch",style:{background:!t||t==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":t}})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:e}),(0,S.jsx)(xv,{value:t,onChange:n})]})}),eG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.map(i=>i.id),o=up(e,i=>i.style.fill),a=za(e,i=>i.style.opacity??1),r=a===null?null:Math.round(a*100);return(0,S.jsx)(xo,{ariaLabel:"Text color and opacity",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-color-trigger",title:"Color & opacity","aria-label":"Text color and opacity",children:(0,S.jsx)("span",{className:"du-sel-color-swatch",style:{background:!o||o==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":o,opacity:a??1}})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Color"}),(0,S.jsx)(xv,{value:o,onChange:i=>{t.updateStyle(n,{fill:i??"transparent"})}}),(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Opacity"}),(0,S.jsx)(Fd,{value:r,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:r===null?"\u2014":`${r}%`,onChange:i=>{t.updateStyle(n,{opacity:i/100})}})]})})},N8=({shapes:e})=>{let t=j();if(!t||!e.some(SG))return null;let n=up(e,a=>a.style.fill),o=e.map(a=>a.id);return(0,S.jsx)(vv,{label:"Fill",ariaLabel:"Fill color",color:n,onChange:a=>{t.updateStyle(o,{fill:a??"transparent"})}})},tG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.map(r=>r.id),o=za(e,r=>r.fontSize??null),a=o!==null&&x1.some(r=>r.value===o)?o:null;return(0,S.jsx)(xo,{ariaLabel:"Font size",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Font size","aria-label":`Font size ${o??"mixed"}`,children:o===null?"\u2014":`${Math.round(o)}`}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Font size"}),(0,S.jsx)(zn,{ariaLabel:"Font size preset",value:a,options:x1.map(r=>({value:r.value,label:r.label,icon:(0,S.jsx)("span",{style:{fontSize:11,fontWeight:600},children:r.label})})),onChange:r=>{t.updateTextProps(n,{fontSize:r})}}),(0,S.jsx)(Fd,{value:o,min:__,max:C_,step:1,ariaLabel:"Font size",valueLabel:o===null?"\u2014":`${o}px`,onChange:r=>{t.updateTextProps(n,{fontSize:r})}})]})})},nG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.map(s=>s.id),o=up(e,s=>s.fontFamily),a=b1.find(s=>s.value===o),r=o===null?"Mixed":a?.label??"Custom";return(0,S.jsx)(xo,{ariaLabel:"Font family",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Font family","aria-label":`Font family ${r}`,style:o?{fontFamily:o}:void 0,children:r}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Font family"}),b1.map(s=>(0,S.jsx)("button",{type:"button",role:"menuitemradio","aria-checked":s.value===o,className:`du-sel-menu-row${s.value===o?" is-active":""}`,style:{fontFamily:s.value},onClick:()=>{t.updateTextProps(n,{fontFamily:s.value})},children:s.label},s.value))]})})},oG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.map(a=>a.id),o=za(e,a=>a.style.textAlign??"left");return(0,S.jsx)(zn,{ariaLabel:"Text alignment",value:o,options:[{value:"left",label:"Left",icon:(0,S.jsx)(io,{size:14,strokeWidth:1.75})},{value:"center",label:"Center",icon:(0,S.jsx)(Sr,{size:14,strokeWidth:1.75})},{value:"right",label:"Right",icon:(0,S.jsx)(Lr,{size:14,strokeWidth:1.75})}],onChange:a=>{t.updateStyle(n,{textAlign:a})}})},aG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.map(c=>c.id),o=e.every(c=>c.style?.fontWeight==="bold"),a=e.every(c=>c.style?.fontStyle==="italic"),r=e.every(c=>c.style?.textDecoration?.underline===!0),s=e.every(c=>c.style?.textDecoration?.strikethrough===!0),i=(c,u)=>{for(let d of e){let f=d.style?.textDecoration??{};t.updateStyle([d.id],{textDecoration:{...f,[c]:u}})}},l=({active:c,label:u,icon:d,onClick:f})=>(0,S.jsx)("button",{type:"button",className:`du-sel-icon-button${c?" is-active":""}`,title:u,"aria-label":u,"aria-pressed":c,onClick:f,children:d});return(0,S.jsx)(xo,{ariaLabel:"Text style",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Text style (bold / italic / \u2026)","aria-label":"Text style",children:(0,S.jsx)(ju,{size:16,strokeWidth:1.75,"aria-hidden":!0})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Style"}),(0,S.jsxs)("div",{style:{display:"flex",gap:2},children:[(0,S.jsx)(l,{active:o,label:"Bold",icon:(0,S.jsx)(Wu,{size:14,strokeWidth:1.75}),onClick:()=>{t.updateStyle(n,{fontWeight:o?"normal":"bold"})}}),(0,S.jsx)(l,{active:a,label:"Italic",icon:(0,S.jsx)(ld,{size:14,strokeWidth:1.75}),onClick:()=>{t.updateStyle(n,{fontStyle:a?"normal":"italic"})}}),(0,S.jsx)(l,{active:r,label:"Underline",icon:(0,S.jsx)(Ed,{size:14,strokeWidth:1.75}),onClick:()=>{i("underline",!r)}}),(0,S.jsx)(l,{active:s,label:"Strikethrough",icon:(0,S.jsx)(Cd,{size:14,strokeWidth:1.75}),onClick:()=>{i("strikethrough",!s)}})]})]})})},rG=({shapes:e})=>{let t=j();if(!t||!e.some(W8))return null;let n=up(e,a=>a.style.stroke),o=e.map(a=>a.id);return(0,S.jsx)(vv,{label:"Stroke",ariaLabel:"Stroke color",color:n,onChange:a=>{t.updateStyle(o,{stroke:a??"transparent"})}})},sG=({shapes:e})=>{let t=j();if(!t||!e.some(a=>a.style.stroke!==void 0))return null;let n=za(e,a=>a.style.strokeWidth??null),o=e.map(a=>a.id);return(0,S.jsx)(zn,{ariaLabel:"Stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,S.jsx)(Lc,{thickness:1})},{value:2,label:"Medium",icon:(0,S.jsx)(Lc,{thickness:2.5})},{value:4,label:"Thick",icon:(0,S.jsx)(Lc,{thickness:4})}],onChange:a=>{t.updateStyle(o,{strokeWidth:a})}})},iG=({shapes:e})=>{let t=j();if(!t||!e.some(W8))return null;let n=za(e,a=>{let r=a.style.dashArray;return!r||r.length===0?"solid":(r[0]??0)<=3?"dotted":"dashed"}),o=e.map(a=>a.id);return(0,S.jsx)(zn,{ariaLabel:"Stroke style",value:n,options:[{value:"solid",label:"Solid",icon:(0,S.jsx)(xa,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,S.jsx)(ya,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,S.jsx)(ga,{size:14,strokeWidth:1.75})}],onChange:a=>{let r=a==="solid"?[]:a==="dashed"?[8,4]:[2,4];t.updateStyle(o,{dashArray:r})}})},lG=({shapes:e})=>{let t=j();if(!t||!e.every(i=>jd(i)||i.type==="container"))return null;let o=za(e,i=>i.style.roundness?.type??"sharp"),a=za(e,i=>i.style.roundness?.value??null),r=e.map(i=>i.id),s=a===null;return(0,S.jsx)(xo,{ariaLabel:"Corners",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Corners","aria-label":"Corners",children:(0,S.jsx)(bv,{kind:o??"sharp"})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Corners"}),(0,S.jsx)(zn,{ariaLabel:"Corner roundness",value:o,options:[{value:"sharp",label:"Sharp",icon:(0,S.jsx)(bv,{kind:"sharp"})},{value:"round",label:"Round",icon:(0,S.jsx)(bv,{kind:"round"})}],onChange:i=>{t.updateStyle(r,{roundness:{type:i}})}}),o==="round"?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)("label",{className:"du-prop-checkbox",children:[(0,S.jsx)("input",{type:"checkbox",checked:s,onChange:i=>{i.target.checked?t.updateStyle(r,{roundness:{type:"round"}}):t.updateStyle(r,{roundness:{type:"round",value:a??8}})}}),(0,S.jsx)("span",{children:"Auto radius"})]}),s?null:(0,S.jsx)(Fd,{value:a,min:0,max:64,step:1,ariaLabel:"Corner radius",valueLabel:`${a}px`,onChange:i=>{t.updateStyle(r,{roundness:{type:"round",value:i}})}})]}):null]})})},F8=({shapes:e})=>{let t=j();if(!t)return null;let n=za(e,s=>s.style.opacity??1),o=e.map(s=>s.id),a=n===null?null:Math.round(n*100),r=a===null?"\u2014":`${a}%`;return(0,S.jsx)(xo,{ariaLabel:"Opacity",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Opacity","aria-label":`Opacity ${r}`,children:r}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Opacity"}),(0,S.jsx)(Fd,{value:a,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:r,onChange:s=>{t.updateStyle(o,{opacity:s/100})}})]})})},cG=()=>{let e=j();return e?(0,S.jsx)(zn,{ariaLabel:"Z-order",value:null,options:[{value:"back",label:"Send to back",icon:(0,S.jsx)(Xu,{size:14,strokeWidth:1.75})},{value:"backward",label:"Send backward",icon:(0,S.jsx)(bd,{size:14,strokeWidth:1.75})},{value:"forward",label:"Bring forward",icon:(0,S.jsx)(vd,{size:14,strokeWidth:1.75})},{value:"front",label:"Bring to front",icon:(0,S.jsx)(Yu,{size:14,strokeWidth:1.75})}],onChange:t=>{t==="back"?e.sendToBack():t==="backward"?e.sendBackward():t==="forward"?e.bringForward():e.bringToFront()}}):null},uG=({shapes:e})=>{let t=j();if(!t)return null;let n=e.length>=2,o=e.some(r=>Oe(r)),a=[{value:"duplicate",label:"Duplicate",icon:(0,S.jsx)(ws,{size:14,strokeWidth:1.75})},{value:"delete",label:"Delete",icon:(0,S.jsx)(_l,{size:14,strokeWidth:1.75})}];return n&&a.push({value:"group",label:"Group",icon:(0,S.jsx)(sd,{size:14,strokeWidth:1.75})}),o&&a.push({value:"ungroup",label:"Ungroup",icon:(0,S.jsx)(Md,{size:14,strokeWidth:1.75})}),a.push({value:"flip-h",label:"Flip horizontal",icon:(0,S.jsx)(nd,{size:14,strokeWidth:1.75})},{value:"flip-v",label:"Flip vertical",icon:(0,S.jsx)(od,{size:14,strokeWidth:1.75})}),(0,S.jsx)(zn,{ariaLabel:"Element actions",value:null,options:a,onChange:r=>{r==="duplicate"?t.duplicateSelected():r==="delete"?t.deleteSelected():r==="group"?t.groupSelected():r==="ungroup"?t.ungroup():r==="flip-h"?t.flipSelection("horizontal"):t.flipSelection("vertical")}})},dG=[{edge:"left",label:"Align left",icon:(0,S.jsx)(Gu,{size:16,strokeWidth:1.75})},{edge:"h-center",label:"Align horizontal centres",icon:(0,S.jsx)(Sl,{size:16,strokeWidth:1.75})},{edge:"right",label:"Align right",icon:(0,S.jsx)(Fu,{size:16,strokeWidth:1.75})},{edge:"top",label:"Align top",icon:(0,S.jsx)(Uu,{size:16,strokeWidth:1.75})},{edge:"v-center",label:"Align vertical centres",icon:(0,S.jsx)(zu,{size:16,strokeWidth:1.75})},{edge:"bottom",label:"Align bottom",icon:(0,S.jsx)(Nu,{size:16,strokeWidth:1.75})}],fG=()=>{let e=j(),t=D0();if(!e)return null;let n=t.size>=3;return(0,S.jsx)(xo,{ariaLabel:"Align and distribute",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Align","aria-label":"Align",children:(0,S.jsx)(Sl,{size:16,strokeWidth:1.75})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Align"}),(0,S.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:4},children:dG.map(o=>(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:o.label,"aria-label":o.label,onClick:()=>{e.alignSelection(o.edge)},children:o.icon},o.edge))}),n?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:"Distribute"}),(0,S.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Distribute horizontally","aria-label":"Distribute horizontally",onClick:()=>{e.distributeSelection("horizontal")},children:(0,S.jsx)(Hu,{size:16,strokeWidth:1.75})}),(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Distribute vertically","aria-label":"Distribute vertically",onClick:()=>{e.distributeSelection("vertical")},children:(0,S.jsx)(qu,{size:16,strokeWidth:1.75})})]})]}):null]})})},pG=({edge:e})=>{let t=j();if(!t)return null;let n=typeof e.style.stroke=="string"?e.style.stroke:null;return(0,S.jsx)(vv,{label:"Stroke",ariaLabel:"Link stroke color",color:n,onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,stroke:o??"transparent"}}))}})},hG=({edge:e})=>{let t=j();if(!t)return null;let n=typeof e.style.strokeWidth=="number"?e.style.strokeWidth:null;return(0,S.jsx)(zn,{ariaLabel:"Link stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,S.jsx)(Lc,{thickness:1})},{value:2,label:"Medium",icon:(0,S.jsx)(Lc,{thickness:2.5})},{value:4,label:"Thick",icon:(0,S.jsx)(Lc,{thickness:4})}],onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,strokeWidth:o}}))}})},mG=({edge:e})=>{let t=j();if(!t)return null;let n=e.style.dashArray,o=!n||n.length===0?"solid":(n[0]??0)<=3?"dotted":"dashed";return(0,S.jsx)(zn,{ariaLabel:"Link stroke style",value:o,options:[{value:"solid",label:"Solid",icon:(0,S.jsx)(xa,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,S.jsx)(ya,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,S.jsx)(ga,{size:14,strokeWidth:1.75})}],onChange:a=>{let r=a==="solid"?[]:a==="dashed"?[8,4]:[2,4];t.updateSelectedLink(s=>({...s,style:{...s.style,dashArray:r}}))}})},yG=({edge:e})=>{let t=j();if(!t)return null;let n=e.lineKind??"line";return(0,S.jsx)(zn,{ariaLabel:"Link body",value:n,options:[{value:"line",label:"Line",icon:(0,S.jsx)(ma,{size:14,strokeWidth:1.75})},{value:"block-arrow",label:"Block arrow",icon:(0,S.jsx)(Ad,{size:14,strokeWidth:2.5})}],onChange:o=>{t.updateSelectedLink(a=>({...a,lineKind:o}))}})},gG=({edge:e})=>{let t=j();if(!t)return null;let n=e.routing??"straight";return(0,S.jsx)(zn,{ariaLabel:"Link routing",value:n,options:[{value:"straight",label:"Straight",icon:(0,S.jsx)(U8,{kind:"straight"})},{value:"orthogonal",label:"Elbow",icon:(0,S.jsx)(U8,{kind:"orthogonal"})},{value:"bezier",label:"Curved",icon:(0,S.jsx)(_d,{size:14,strokeWidth:1.75})}],onChange:o=>{t.updateSelectedLink(a=>({...a,routing:o}))}})},H8=({edge:e,side:t})=>{let n=j(),[o,a]=(0,Wr.useState)(!1);if(!n)return null;let r=e.arrowheads?.[t]??"none",s=l=>{n.updateSelectedLink(c=>({...c,arrowheads:{...c.arrowheads??{},[t]:l}}))},i=({style:l})=>(0,S.jsx)("button",{type:"button",className:`du-arrowhead-option${l===r?" du-arrowhead-option--active":""}`,title:ny[l],"aria-label":ny[l],"aria-pressed":l===r,onClick:()=>{s(l)},children:l==="none"?(0,S.jsx)("span",{className:"du-arrowhead-none",children:"\u2205"}):q8(l)==="none"?(0,S.jsx)("span",{className:"du-arrowhead-erd-label",children:ny[l].replace(/^ERD /,"")}):(0,S.jsx)(G8,{kind:l,side:t})});return(0,S.jsx)(xo,{trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:`Arrow ${t}: ${ny[r]}`,"aria-label":`Arrow ${t}`,children:(0,S.jsx)(G8,{kind:r,side:t})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsxs)("header",{className:"du-sel-popover-label",children:["Arrow ",t]}),(0,S.jsx)("div",{className:"du-arrowhead-grid",children:AG.map(l=>(0,S.jsx)(i,{style:l},l))}),(0,S.jsxs)("button",{type:"button",className:"du-arrowhead-erd-toggle","aria-expanded":o,onClick:()=>{a(l=>!l)},children:[o?"\u25BE":"\u25B8"," ER diagram"]}),o&&(0,S.jsx)("div",{className:"du-arrowhead-grid",children:vG.map(l=>(0,S.jsx)(i,{style:l},l))})]})})},xG=({edge:e})=>{let t=j();if(!t||(e.routing??"straight")==="bezier")return null;let o=e.avoidObstacles===!0;return(0,S.jsx)("button",{type:"button",className:`du-sel-icon-button${o?" is-active":""}`,title:"Route around shapes","aria-label":"Route around shapes","aria-pressed":o,onClick:()=>{t.setSelectedLinkAvoidObstacles(!o)},children:(0,S.jsx)(Rd,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},bG=()=>{let e=j();return e?(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Delete edge","aria-label":"Delete edge",onClick:()=>{e.deleteSelected()},children:(0,S.jsx)(_l,{size:14,strokeWidth:1.75,"aria-hidden":!0})}):null},U8=({kind:e})=>e==="straight"?(0,S.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,S.jsx)("line",{x1:2,y1:11,x2:12,y2:3,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round"})}):(0,S.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,S.jsx)("path",{d:"M 2 11 L 2 7 L 12 7 L 12 3",stroke:"currentColor",strokeWidth:1.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}),q8=e=>{switch(e){case"arrow":case"openArrow":case"roundedArrow":case"arcArrow":return"open";case"triangle":case"filledArrow":return"triangle";case"diamond":case"rhombus":case"filledRhombus":return"diamond";case"circle":case"filledCircle":return"circle";default:return"none"}},AG=["none","arrow","openArrow","roundedArrow","arcArrow","filledArrow","triangle","circle","filledCircle","rhombus","filledRhombus"],vG=["erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"],ny={none:"None",arrow:"Arrow",openArrow:"Open arrow",roundedArrow:"Rounded arrow",arcArrow:"Arc arrow",triangle:"Triangle",filledArrow:"Filled arrow",circle:"Circle",filledCircle:"Filled circle",diamond:"Diamond",rhombus:"Rhombus",filledRhombus:"Filled rhombus",erdOne:"ERD one",erdOnlyOne:"ERD only one",erdMany:"ERD many",erdOneOrMany:"ERD one or many",erdZeroOrOne:"ERD zero or one",erdZeroOrMany:"ERD zero or many"},G8=({kind:e,side:t})=>{let n=t==="from",o=n?12:2,a=n?5:9,r=n?3:11,s=n?5:9,i=(0,S.jsx)("line",{x1:o,y1:7,x2:a,y2:7,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round"}),l=q8(e),c=null;return l==="open"?c=(0,S.jsx)("polyline",{points:n?`${r+3},4 ${r},7 ${r+3},10`:`${r-3},4 ${r},7 ${r-3},10`,stroke:"currentColor",strokeWidth:1.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}):l==="triangle"?c=(0,S.jsx)("polygon",{points:n?`${r},7 ${s},4 ${s},10`:`${r},7 ${s},4 ${s},10`,fill:"currentColor"}):l==="diamond"?c=(0,S.jsx)("polygon",{points:`${r},4 ${r+(n?-3:3)},7 ${r},10 ${r+(n?3:-3)},7`,fill:e==="filledRhombus"?"currentColor":"none",stroke:"currentColor",strokeWidth:1.2}):l==="circle"&&(c=(0,S.jsx)("circle",{cx:r,cy:7,r:2.2,fill:e==="filledCircle"?"currentColor":"none",stroke:"currentColor",strokeWidth:1.2})),(0,S.jsxs)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:[i,c]})},LG=()=>(0,S.jsx)("span",{className:"du-sel-divider","aria-hidden":!0}),Lc=({thickness:e})=>(0,S.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,S.jsx)("line",{x1:2,y1:7,x2:12,y2:7,stroke:"currentColor",strokeWidth:e,strokeLinecap:"round"})}),bv=({kind:e})=>e==="sharp"?(0,S.jsx)(xa,{size:14,strokeWidth:1.75,"aria-hidden":!0}):(0,S.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,S.jsx)("rect",{x:2,y:2,width:10,height:10,rx:3,ry:3,stroke:"currentColor",strokeWidth:1.5})}),za=(e,t)=>{let n=new Set;for(let a of e)n.add(t(a));return n.size!==1?null:n.values().next().value??null},up=(e,t)=>{let n=za(e,o=>t(o));return typeof n=="string"?n:null},SG=e=>e.style.fill!==void 0||He(e),W8=e=>e.style.stroke!==void 0;var Sv=({offset:e=48,placement:t="top",edgeInset:n}={})=>{let o={top:n?.top??66,right:n?.right??16,bottom:n?.bottom??66,left:n?.left??16},a=j(),r=Et(),s=$f(),[i,l]=(0,Wo.useState)(!1),c=(0,Wo.useRef)(null),[u,d]=(0,Wo.useState)(0),[f,p]=(0,Wo.useState)(!1);return(0,Wo.useEffect)(()=>{if(!a)return;let h=()=>{let m=a.selection,b=a.selection.size>0||a.selectedLink!==null;l(y=>(!y&&b&&p(!1),b)),d(y=>y+1)};return h(),a.on("change",h)},[a]),(0,Wo.useLayoutEffect)(()=>{if(!a||!i||s)return;let h=c.current;if(!h)return;let m=kG(a);if(!m)return;let b=()=>{J0(m,h,{placement:t,middleware:[K0(e),Q0({fallbackPlacements:["bottom","right","left"],padding:o}),$0({padding:o})]}).then(({x:g,y:x})=>{h.style.transform=`translate(${Math.round(g)}px, ${Math.round(x)}px)`,p(!0)})};return b(),Y0(m,h,b)},[a,i,s,u,e,t,o.top,o.right,o.bottom,o.left]),!a||!i?null:s?(0,Lv.createPortal)((0,dp.jsx)("div",{className:"du-sel-panel-dock",role:"toolbar","aria-label":"Selection actions",children:(0,dp.jsx)(Av,{mobile:!0})}),r):(0,Lv.createPortal)((0,dp.jsx)("div",{ref:c,className:"du-sel-panel-floating",role:"toolbar","aria-label":"Selection actions",style:{position:"absolute",top:0,left:0,zIndex:1500,pointerEvents:"auto",opacity:f?1:0,transition:f?"opacity 120ms ease":"none",...f?{}:{pointerEvents:"none"}},children:(0,dp.jsx)(Av,{})}),r)},kG=e=>{let t=e.hostElement;return t?{getBoundingClientRect:()=>{let n=wG(e);if(!n){let c=t.getBoundingClientRect();return new DOMRect(c.left,c.top,0,0)}let o=e.scene.viewport,a=(n.x-o.pan.x)*o.zoom,r=(n.y-o.pan.y)*o.zoom,s=Math.max(1,n.width*o.zoom),i=Math.max(1,n.height*o.zoom),l=t.getBoundingClientRect();return new DOMRect(l.left+a,l.top+r,s,i)},contextElement:t}:null},wG=e=>{let t=[];for(let o of e.selection){let a=e.scene.elements.get(o);a&&t.push(a)}if(t.length===0){let o=e.selectedLink;if(o){let a=e.scene.links.get(o);if(a)return Dr(e.scene,a)}return null}let n=null;for(let o of t){if(Oe(o)&&e.scene.elements.has(o.id)){let r=X1(e.scene,o.id);for(let s of r){if(Oe(s))continue;let i;try{i=z(s)}catch{continue}i.width===0&&i.height===0||(n=j8(n,i))}continue}let a;try{a=z(o)}catch{continue}n=j8(n,a)}return n},j8=(e,t)=>{if(!e)return{...t};let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(e.x+e.width,t.x+t.width),r=Math.max(e.y+e.height,t.y+t.height);return{x:n,y:o,width:a-n,height:r-o}};var jr=F(ye(),1),Se=F(he(),1);var Sc="Roboto",fp="PT Serif",pp="Roboto Mono",kc=e=>{let t=e.toLowerCase();return t.includes("mono")?pp:t.includes("sans")?Sc:t.includes("serif")||t.includes("slab")||t.includes("georgia")||t.includes("times")?fp:Sc},_G=[{family:Sc,weight:"400",style:"normal",url:new URL("../fonts/Roboto-Regular.woff2",import.meta.url)},{family:Sc,weight:"700",style:"normal",url:new URL("../fonts/Roboto-Bold.woff2",import.meta.url)},{family:Sc,weight:"400",style:"italic",url:new URL("../fonts/Roboto-Italic.woff2",import.meta.url)},{family:Sc,weight:"700",style:"italic",url:new URL("../fonts/Roboto-BoldItalic.woff2",import.meta.url)},{family:fp,weight:"400",style:"normal",url:new URL("../fonts/PTSerif-Regular.woff2",import.meta.url)},{family:fp,weight:"700",style:"normal",url:new URL("../fonts/PTSerif-Bold.woff2",import.meta.url)},{family:fp,weight:"400",style:"italic",url:new URL("../fonts/PTSerif-Italic.woff2",import.meta.url)},{family:fp,weight:"700",style:"italic",url:new URL("../fonts/PTSerif-BoldItalic.woff2",import.meta.url)},{family:pp,weight:"400",style:"normal",url:new URL("../fonts/RobotoMono-Regular.woff2",import.meta.url)},{family:pp,weight:"700",style:"normal",url:new URL("../fonts/RobotoMono-Bold.woff2",import.meta.url)},{family:pp,weight:"400",style:"italic",url:new URL("../fonts/RobotoMono-Italic.woff2",import.meta.url)},{family:pp,weight:"700",style:"italic",url:new URL("../fonts/RobotoMono-BoldItalic.woff2",import.meta.url)}],V8=async(e=globalThis)=>{let t=e.fonts;!t||typeof FontFace>"u"||await Promise.allSettled(_G.map(async n=>{let o=new FontFace(n.family,`url(${n.url.href})`,{weight:n.weight,style:n.style});await o.load(),t.add(o)}))};var CG=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],oy=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of CG){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},Z8=new Set,ay=e=>{if(typeof console>"u")return;let t=typeof e=="string"?e.startsWith("blob:")?"dead-blob-url":"string-src":e==null?"empty":"stale-object";Z8.has(t)||(Z8.add(t),console.warn(`[renderer] skipped a non-drawable image source (kind: ${t}). The shape's image handle isn't a live HTMLImageElement / canvas / bitmap \u2014 likely a scene restored from storage where the <img> was lost (metadata.image) and src is a dead blob: URL. The image won't render until rehydrated from Scene.files.`))};var wc=class{ctx;_width;_height;dpr;constructor(t,n,o,a=1){this.ctx=t,this._width=n,this._height=o,this.dpr=a}get size(){return{width:this._width,height:this._height}}resize(t,n,o){this._width=t,this._height=n,o!==void 0&&(this.dpr=o)}setFill(t){this.ctx.fillStyle=t??"transparent"}setStroke(t){this.ctx.strokeStyle=t??"transparent"}setStrokeWidth(t){this.ctx.lineWidth=t}setOpacity(t){this.ctx.globalAlpha=t}setLineCap(t){this.ctx.lineCap=t}setLineJoin(t){this.ctx.lineJoin=t}setDashArray(t){this.ctx.setLineDash(t?[...t]:[])}setFont(t,n,o){let a=o?.style==="italic"?"italic ":"",r=o?.weight==="bold"?"bold ":"";this.ctx.font=`${a}${r}${n}px "${kc(t)}", ${t}`}setTextAlign(t){this.ctx.textAlign=t==="center"?"center":t}setTextBaseline(t){this.ctx.textBaseline=t==="middle"?"middle":t==="top"?"top":"bottom"}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(t,n){this.ctx.translate(t,n)}rotate(t){this.ctx.rotate(t)}scale(t,n){this.ctx.scale(t,n)}setTransform(t){let n=this.dpr;this.ctx.setTransform(n*t.a,n*t.b,n*t.c,n*t.d,n*t.e,n*t.f)}resetTransform(){this.ctx.setTransform(this.dpr,0,0,this.dpr,0,0)}beginPath(){this.ctx.beginPath()}closePath(){this.ctx.closePath()}moveTo(t,n){this.ctx.moveTo(t,n)}lineTo(t,n){this.ctx.lineTo(t,n)}quadraticCurveTo(t,n,o,a){this.ctx.quadraticCurveTo(t,n,o,a)}bezierCurveTo(t,n,o,a,r,s){this.ctx.bezierCurveTo(t,n,o,a,r,s)}rect(t,n,o,a){this.ctx.rect(t,n,o,a)}ellipse(t,n,o,a){this.ctx.ellipse(t,n,o,a,0,0,Math.PI*2)}fill(t){this.ctx.fill(t)}stroke(){this.ctx.stroke()}fillText(t,n,o,a){a!==void 0?this.ctx.fillText(t,n,o,a):this.ctx.fillText(t,n,o)}measureText(t){return{width:this.ctx.measureText(t).width}}drawImage(t,n,o,a,r,s){if(!oy(t)){ay(t);return}this.ctx.drawImage(t,n,o,a,r)}clear(t){this.dirtyRect=null,t?this.ctx.clearRect(t.x,t.y,t.width,t.height):(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}dirtyRect=null;markDirty(t){if(!this.dirtyRect){this.dirtyRect=t;return}let n=Math.min(this.dirtyRect.x,t.x),o=Math.min(this.dirtyRect.y,t.y),a=Math.max(this.dirtyRect.x+this.dirtyRect.width,t.x+t.width),r=Math.max(this.dirtyRect.y+this.dirtyRect.height,t.y+t.height);this.dirtyRect={x:n,y:o,width:a-n,height:r-o}}getDirtyRect(){return this.dirtyRect}};var hp=class{shaper;atlasSize;tileSize;range;columns;capacity;glyphs=new Map;buffer;dirtyTiles=new Set;needsFullUpload=!0;nextSlot=0;texture=null;constructor(t,n={}){if(this.shaper=t,this.atlasSize=n.atlasSize??2048,this.tileSize=n.tileSize??64,this.range=n.range??8,this.atlasSize%this.tileSize!==0)throw new Error(`GlyphAtlas: atlasSize (${this.atlasSize}) must be a multiple of tileSize (${this.tileSize})`);this.columns=this.atlasSize/this.tileSize,this.capacity=this.columns*this.columns,this.buffer=new Uint8Array(this.atlasSize*this.atlasSize*3)}resolveFontId(t,n=!1,o=!1){return this.shaper.resolveFontId?.(t,n,o)??0}getOrRasterize(t,n=0){let o=n*1114112+t,a=this.glyphs.get(o);if(a)return a;if(this.nextSlot>=this.capacity)return null;let r=this.shaper.glyphMetrics(t,n);if(!r)return null;let s=this.nextSlot++,i=s%this.columns,l=Math.floor(s/this.columns),c=i*this.tileSize,u=l*this.tileSize,d=r.bboxW<=0||r.bboxH<=0;if(!d){let p=this.shaper.rasterizeGlyphMSDF(t,this.tileSize,this.range,n);if(p){for(let h=0;h<this.tileSize;h++){let m=h*this.tileSize*3,b=((u+h)*this.atlasSize+c)*3;this.buffer.set(p.data.subarray(m,m+this.tileSize*3),b)}this.dirtyTiles.add(s)}}let f={codePoint:t,atlasX:c,atlasY:u,tileSize:this.tileSize,range:this.range,advance:r.advance,bboxXMin:r.bboxXMin,bboxYMin:r.bboxYMin,bboxW:r.bboxW,bboxH:r.bboxH,unitsPerEm:r.unitsPerEm,empty:d};return this.glyphs.set(o,f),f}get glyphCount(){return this.glyphs.size}get cpuBuffer(){return this.buffer}uploadTo(t){if(this.texture)t.bindTexture(t.TEXTURE_2D,this.texture);else{let n=t.createTexture();if(!n)throw new Error("GlyphAtlas: gl.createTexture() returned null");this.texture=n,t.bindTexture(t.TEXTURE_2D,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}if(this.needsFullUpload)return t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGB8,this.atlasSize,this.atlasSize,0,t.RGB,t.UNSIGNED_BYTE,this.buffer),this.needsFullUpload=!1,this.dirtyTiles.clear(),this.texture;if(this.dirtyTiles.size===0)return this.texture;t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ROW_LENGTH,this.atlasSize);for(let n of this.dirtyTiles){let o=n%this.columns,a=Math.floor(n/this.columns),r=o*this.tileSize,s=a*this.tileSize,i=r,l=s;t.pixelStorei(t.UNPACK_SKIP_PIXELS,i),t.pixelStorei(t.UNPACK_SKIP_ROWS,l),t.texSubImage2D(t.TEXTURE_2D,0,r,s,this.tileSize,this.tileSize,t.RGB,t.UNSIGNED_BYTE,this.buffer)}return t.pixelStorei(t.UNPACK_ROW_LENGTH,0),t.pixelStorei(t.UNPACK_SKIP_PIXELS,0),t.pixelStorei(t.UNPACK_SKIP_ROWS,0),this.dirtyTiles.clear(),this.texture}dispose(t){this.texture&&t&&t.deleteTexture(this.texture),this.texture=null,this.needsFullUpload=!0}};function _v(e,t,n=2){let o=t&&t.length,a=o?t[0]*n:e.length,r=Y8(e,0,a,n,!0),s=[];if(!r||r.next===r.prev)return s;let i,l,c;if(o&&(r=OG(e,t,r,n)),e.length>80*n){i=e[0],l=e[1];let u=i,d=l;for(let f=n;f<a;f+=n){let p=e[f],h=e[f+1];p<i&&(i=p),h<l&&(l=h),p>u&&(u=p),h>d&&(d=h)}c=Math.max(u-i,d-l),c=c!==0?32767/c:0}return yp(r,s,n,i,l,c,0),s}function Y8(e,t,n,o,a){let r;if(a===qG(e,t,n,o)>0)for(let s=t;s<n;s+=o)r=X8(s/o|0,e[s],e[s+1],r);else for(let s=n-o;s>=t;s-=o)r=X8(s/o|0,e[s],e[s+1],r);return r&&_c(r,r.next)&&(xp(r),r=r.next),r}function Ci(e,t){if(!e)return e;t||(t=e);let n=e,o;do if(o=!1,!n.steiner&&(_c(n,n.next)||Ve(n.prev,n,n.next)===0)){if(xp(n),n=t=n.prev,n===n.next)break;o=!0}else n=n.next;while(o||n!==t);return t}function yp(e,t,n,o,a,r,s){if(!e)return;!s&&r&&zG(e,o,a,r);let i=e;for(;e.prev!==e.next;){let l=e.prev,c=e.next;if(r?IG(e,o,a,r):TG(e)){t.push(l.i,e.i,c.i),xp(e),e=c.next,i=c.next;continue}if(e=c,e===i){s?s===1?(e=EG(Ci(e),t),yp(e,t,n,o,a,r,2)):s===2&&MG(e,t,n,o,a,r):yp(Ci(e),t,n,o,a,r,1);break}}}function TG(e){let t=e.prev,n=e,o=e.next;if(Ve(t,n,o)>=0)return!1;let a=t.x,r=n.x,s=o.x,i=t.y,l=n.y,c=o.y,u=Math.min(a,r,s),d=Math.min(i,l,c),f=Math.max(a,r,s),p=Math.max(i,l,c),h=o.next;for(;h!==t;){if(h.x>=u&&h.x<=f&&h.y>=d&&h.y<=p&&mp(a,i,r,l,s,c,h.x,h.y)&&Ve(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function IG(e,t,n,o){let a=e.prev,r=e,s=e.next;if(Ve(a,r,s)>=0)return!1;let i=a.x,l=r.x,c=s.x,u=a.y,d=r.y,f=s.y,p=Math.min(i,l,c),h=Math.min(u,d,f),m=Math.max(i,l,c),b=Math.max(u,d,f),y=kv(p,h,t,n,o),g=kv(m,b,t,n,o),x=e.prevZ,A=e.nextZ;for(;x&&x.z>=y&&A&&A.z<=g;){if(x.x>=p&&x.x<=m&&x.y>=h&&x.y<=b&&x!==a&&x!==s&&mp(i,u,l,d,c,f,x.x,x.y)&&Ve(x.prev,x,x.next)>=0||(x=x.prevZ,A.x>=p&&A.x<=m&&A.y>=h&&A.y<=b&&A!==a&&A!==s&&mp(i,u,l,d,c,f,A.x,A.y)&&Ve(A.prev,A,A.next)>=0))return!1;A=A.nextZ}for(;x&&x.z>=y;){if(x.x>=p&&x.x<=m&&x.y>=h&&x.y<=b&&x!==a&&x!==s&&mp(i,u,l,d,c,f,x.x,x.y)&&Ve(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;A&&A.z<=g;){if(A.x>=p&&A.x<=m&&A.y>=h&&A.y<=b&&A!==a&&A!==s&&mp(i,u,l,d,c,f,A.x,A.y)&&Ve(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function EG(e,t){let n=e;do{let o=n.prev,a=n.next.next;!_c(o,a)&&$8(o,n,n.next,a)&&gp(o,a)&&gp(a,o)&&(t.push(o.i,n.i,a.i),xp(n),xp(n.next),n=e=a),n=n.next}while(n!==e);return Ci(n)}function MG(e,t,n,o,a,r){let s=e;do{let i=s.next.next;for(;i!==s.prev;){if(s.i!==i.i&&HG(s,i)){let l=Q8(s,i);s=Ci(s,s.next),l=Ci(l,l.next),yp(s,t,n,o,a,r,0),yp(l,t,n,o,a,r,0);return}i=i.next}s=s.next}while(s!==e)}function OG(e,t,n,o){let a=[];for(let r=0,s=t.length;r<s;r++){let i=t[r]*o,l=r<s-1?t[r+1]*o:e.length,c=Y8(e,i,l,o,!1);c===c.next&&(c.steiner=!0),a.push(FG(c))}a.sort(RG);for(let r=0;r<a.length;r++)n=DG(a[r],n);return n}function RG(e,t){let n=e.x-t.x;if(n===0&&(n=e.y-t.y,n===0)){let o=(e.next.y-e.y)/(e.next.x-e.x),a=(t.next.y-t.y)/(t.next.x-t.x);n=o-a}return n}function DG(e,t){let n=PG(e,t);if(!n)return t;let o=Q8(n,e);return Ci(o,o.next),Ci(n,n.next)}function PG(e,t){let n=t,o=e.x,a=e.y,r=-1/0,s;if(_c(e,n))return n;do{if(_c(e,n.next))return n.next;if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){let d=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(d<=o&&d>r&&(r=d,s=n.x<n.next.x?n:n.next,d===o))return s}n=n.next}while(n!==t);if(!s)return null;let i=s,l=s.x,c=s.y,u=1/0;n=s;do{if(o>=n.x&&n.x>=l&&o!==n.x&&K8(a<c?o:r,a,l,c,a<c?r:o,a,n.x,n.y)){let d=Math.abs(a-n.y)/(o-n.x);gp(n,e)&&(d<u||d===u&&(n.x>s.x||n.x===s.x&&BG(s,n)))&&(s=n,u=d)}n=n.next}while(n!==i);return s}function BG(e,t){return Ve(e.prev,e,t.prev)<0&&Ve(t.next,e,e.next)<0}function zG(e,t,n,o){let a=e;do a.z===0&&(a.z=kv(a.x,a.y,t,n,o)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==e);a.prevZ.nextZ=null,a.prevZ=null,NG(a)}function NG(e){let t,n=1;do{let o=e,a;e=null;let r=null;for(t=0;o;){t++;let s=o,i=0;for(let c=0;c<n&&(i++,s=s.nextZ,!!s);c++);let l=n;for(;i>0||l>0&&s;)i!==0&&(l===0||!s||o.z<=s.z)?(a=o,o=o.nextZ,i--):(a=s,s=s.nextZ,l--),r?r.nextZ=a:e=a,a.prevZ=r,r=a;o=s}r.nextZ=null,n*=2}while(t>1);return e}function kv(e,t,n,o,a){return e=(e-n)*a|0,t=(t-o)*a|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function FG(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function K8(e,t,n,o,a,r,s,i){return(a-s)*(t-i)>=(e-s)*(r-i)&&(e-s)*(o-i)>=(n-s)*(t-i)&&(n-s)*(r-i)>=(a-s)*(o-i)}function mp(e,t,n,o,a,r,s,i){return!(e===s&&t===i)&&K8(e,t,n,o,a,r,s,i)}function HG(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!UG(e,t)&&(gp(e,t)&&gp(t,e)&&GG(e,t)&&(Ve(e.prev,e,t.prev)||Ve(e,t.prev,t))||_c(e,t)&&Ve(e.prev,e,e.next)>0&&Ve(t.prev,t,t.next)>0)}function Ve(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function _c(e,t){return e.x===t.x&&e.y===t.y}function $8(e,t,n,o){let a=sy(Ve(e,t,n)),r=sy(Ve(e,t,o)),s=sy(Ve(n,o,e)),i=sy(Ve(n,o,t));return!!(a!==r&&s!==i||a===0&&ry(e,n,t)||r===0&&ry(e,o,t)||s===0&&ry(n,e,o)||i===0&&ry(n,t,o))}function ry(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sy(e){return e>0?1:e<0?-1:0}function UG(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&$8(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function gp(e,t){return Ve(e.prev,e,e.next)<0?Ve(e,t,e.next)>=0&&Ve(e,e.prev,t)>=0:Ve(e,t,e.prev)<0||Ve(e,e.next,t)<0}function GG(e,t){let n=e,o=!1,a=(e.x+t.x)/2,r=(e.y+t.y)/2;do n.y>r!=n.next.y>r&&n.next.y!==n.y&&a<(n.next.x-n.x)*(r-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==e);return o}function Q8(e,t){let n=wv(e.i,e.x,e.y),o=wv(t.i,t.x,t.y),a=e.next,r=t.prev;return e.next=t,t.prev=e,n.next=a,a.prev=n,o.next=n,n.prev=o,r.next=o,o.prev=r,o}function X8(e,t,n,o){let a=wv(e,t,n);return o?(a.next=o.next,a.prev=o,o.next.prev=a,o.next=a):(a.prev=a,a.next=a),a}function xp(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function wv(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function qG(e,t,n,o){let a=0;for(let r=t,s=n-o;r<n;r+=o)a+=(e[s]-e[r])*(e[r+1]+e[s+1]),s=r;return a}var Cv=e=>{if(e===null)return[0,0,0,0];try{let{r:t,g:n,b:o,a}=mm.parse(e);return[t/255,n/255,o/255,a]}catch{return typeof console<"u"&&console.warn(`[WebGL2Target] cannot parse color '${e}', falling back to black`),[0,0,0,1]}};var Jn=e=>{if(e===null)throw new Error("packages/renderer-canvas: WebGL resource creation failed");return e},rn=(e,t,n,o)=>{let a=Jn(e.createShader(t));if(e.shaderSource(a,n),e.compileShader(a),!e.getShaderParameter(a,e.COMPILE_STATUS)){let r=e.getShaderInfoLog(a);throw e.deleteShader(a),new Error(`${o} shader compile failed: ${r}`)}return a},Na=(e,t,n,o)=>{let a=Jn(e.createProgram());if(e.attachShader(a,t),e.attachShader(a,n),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){let r=e.getProgramInfoLog(a);throw e.deleteProgram(a),new Error(`${o} program link failed: ${r}`)}return a};var ly=class{gl;program;vbo;uTransform;uColor;uOpacity;uPxRange;uAtlas;aPos;aUV;constructor(t){this.gl=t;let n=rn(t,t.VERTEX_SHADER,XG,"MSDF"),o=rn(t,t.FRAGMENT_SHADER,YG,"MSDF");this.program=Na(t,n,o,"MSDF"),this.vbo=Jn(t.createBuffer()),this.aPos=t.getAttribLocation(this.program,"aPos"),this.aUV=t.getAttribLocation(this.program,"aUV"),this.uTransform=t.getUniformLocation(this.program,"uTransform"),this.uColor=t.getUniformLocation(this.program,"uColor"),this.uOpacity=t.getUniformLocation(this.program,"uOpacity"),this.uPxRange=t.getUniformLocation(this.program,"uPxRange"),this.uAtlas=t.getUniformLocation(this.program,"uAtlas")}drawText(t,n,o,a,r,s,i,l=0,c=0){if(t.length===0)return 0;let u=6,d=4,f=t.length*u*d;VG(f);let p=iy,h=0,m=n;for(let _ of t){let v=_.codePointAt(0);if(v===void 0)continue;let I=r.getOrRasterize(v,c);if(!I)break;let k=I.advance*a/I.unitsPerEm;if(I.empty){m+=k;continue}jG(p,h,I,m,o,a,r),h+=u*d,m+=k}if(h===0)return m-n;let b=r.uploadTo(this.gl),y=this.gl;y.useProgram(this.program),y.bindBuffer(y.ARRAY_BUFFER,this.vbo),y.bufferData(y.ARRAY_BUFFER,p.subarray(0,h),y.DYNAMIC_DRAW),y.enableVertexAttribArray(this.aPos),y.vertexAttribPointer(this.aPos,2,y.FLOAT,!1,16,0),y.enableVertexAttribArray(this.aUV),y.vertexAttribPointer(this.aUV,2,y.FLOAT,!1,16,8);let g=s.transform,x=g;if(l!==0){let _=-(m-n)*l;x={...g,e:g.e+g.a*_,f:g.f+g.b*_}}ZG(J8,x,i.width,i.height),y.uniformMatrix3fv(this.uTransform,!1,J8),y.uniform3f(this.uColor,s.color[0],s.color[1],s.color[2]),y.uniform1f(this.uOpacity,s.opacity);let A=r.tileSize-2*r.range,C=r.range*a/Math.max(1,A);return y.uniform1f(this.uPxRange,C),y.activeTexture(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b),y.uniform1i(this.uAtlas,0),y.drawArrays(y.TRIANGLES,0,h/d),m-n}dispose(){this.gl.deleteBuffer(this.vbo),this.gl.deleteProgram(this.program)}},WG=(e,t,n,o,a)=>{let r=o/e.unitsPerEm,s=Math.max(1,a.tileSize-2*a.range),i=Math.max(e.bboxW,e.bboxH)/s,l=e.bboxW/i+2*a.range,c=e.bboxH/i+2*a.range,u=a.range*i*r,d=e.bboxW*r+2*u,f=e.bboxH*r+2*u,p=t+e.bboxXMin*r-u,h=n+(-e.bboxYMin-e.bboxH)*r-u,m=p+d,b=h+f,y=.5,g=(e.atlasX+y)/a.atlasSize,x=(e.atlasY+y)/a.atlasSize,A=(e.atlasX+l-y)/a.atlasSize,C=(e.atlasY+c-y)/a.atlasSize;return{left:p,top:h,right:m,bottom:b,u0:g,v0:x,u1:A,v1:C}},jG=(e,t,n,o,a,r,s)=>{let{left:i,top:l,right:c,bottom:u,u0:d,v0:f,u1:p,v1:h}=WG(n,o,a,r,s);e.set([i,l,d,f,c,l,p,f,i,u,d,h,c,l,p,f,c,u,p,h,i,u,d,h],t)},iy=new Float32Array(512),J8=new Float32Array(9),VG=e=>{if(iy.length>=e)return;let t=iy.length;for(;t<e;)t*=2;iy=new Float32Array(t)},ZG=(e,t,n,o)=>{let a=2/n,r=-2/o;e[0]=t.a*a,e[1]=t.b*r,e[2]=0,e[3]=t.c*a,e[4]=t.d*r,e[5]=0,e[6]=t.e*a-1,e[7]=t.f*r+1,e[8]=1},XG=`#version 300 es
|
|
8
|
+
`+o.stack}}var Qx=Object.prototype.hasOwnProperty,G1=ht.unstable_scheduleCallback,mx=ht.unstable_cancelCallback,IP=ht.unstable_shouldYield,MP=ht.unstable_requestPaint,Ln=ht.unstable_now,RP=ht.unstable_getCurrentPriorityLevel,ww=ht.unstable_ImmediatePriority,_w=ht.unstable_UserBlockingPriority,Sm=ht.unstable_NormalPriority,OP=ht.unstable_LowPriority,Cw=ht.unstable_IdlePriority,DP=ht.log,PP=ht.unstable_setDisableYieldValue,id=null,kn=null;function Ar(e){if(typeof DP=="function"&&PP(e),kn&&typeof kn.setStrictMode=="function")try{kn.setStrictMode(id,e)}catch{}}var wn=Math.clz32?Math.clz32:zP,BP=Math.log,NP=Math.LN2;function zP(e){return e>>>=0,e===0?32:31-(BP(e)/NP|0)|0}var Uh=256,Gh=262144,Wh=4194304;function Is(e){var t=e&42;if(t!==0)return t;switch(e&-e){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 e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Xm(e,t,n){var o=e.pendingLanes;if(o===0)return 0;var a=0,r=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var i=o&134217727;return i!==0?(o=i&~r,o!==0?a=Is(o):(s&=i,s!==0?a=Is(s):n||(n=i&~e,n!==0&&(a=Is(n))))):(i=o&~r,i!==0?a=Is(i):s!==0?a=Is(s):n||(n=o&~e,n!==0&&(a=Is(n)))),a===0?0:t!==0&&t!==a&&(t&r)===0&&(r=a&-a,n=t&-t,r>=n||r===32&&(n&4194048)!==0)?t:a}function ld(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function FP(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+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 Ew(){var e=Wh;return Wh<<=1,(Wh&62914560)===0&&(Wh=4194304),e}function yx(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function cd(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function HP(e,t,n,o,a,r){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var i=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=s&~n;0<n;){var u=31-wn(n),d=1<<u;i[u]=0,l[u]=-1;var f=c[u];if(f!==null)for(c[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}o!==0&&Tw(e,o,0),r!==0&&a===0&&e.tag!==0&&(e.suspendedLanes|=r&~(s&~t))}function Tw(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-wn(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|n&261930}function Iw(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var o=31-wn(n),a=1<<o;a&t|e[o]&t&&(e[o]|=t),n&=~a}}function Mw(e,t){var n=t&-t;return n=(n&42)!==0?1:W1(n),(n&(e.suspendedLanes|t))!==0?0:n}function W1(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function q1(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Rw(){var e=we.p;return e!==0?e:(e=window.event,e===void 0?32:tE(e.type))}function $3(e,t){var n=we.p;try{return we.p=e,t()}finally{we.p=n}}var zr=Math.random().toString(36).slice(2),It="__reactFiber$"+zr,an="__reactProps$"+zr,ql="__reactContainer$"+zr,Jx="__reactEvents$"+zr,UP="__reactListeners$"+zr,GP="__reactHandles$"+zr,Q3="__reactResources$"+zr,ud="__reactMarker$"+zr;function j1(e){delete e[It],delete e[an],delete e[Jx],delete e[UP],delete e[GP]}function yl(e){var t=e[It];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ql]||n[It]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=sw(e);e!==null;){if(n=e[It])return n;e=sw(e)}return t}e=n,n=e.parentNode}return null}function jl(e){if(e=e[It]||e[ql]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Iu(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(O(33))}function _l(e){var t=e[Q3];return t||(t=e[Q3]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Lt(e){e[ud]=!0}var Ow=new Set,Dw={};function Ws(e,t){Dl(e,t),Dl(e+"Capture",t)}function Dl(e,t){for(Dw[e]=t,e=0;e<t.length;e++)Ow.add(t[e])}var WP=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),J3={},ek={};function qP(e){return Qx.call(ek,e)?!0:Qx.call(J3,e)?!1:WP.test(e)?ek[e]=!0:(J3[e]=!0,!1)}function am(e,t,n){if(qP(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var o=t.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function qh(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function ma(e,t,n,o){if(o===null)e.removeAttribute(n);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+o)}}function Wn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Pw(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function jP(e,t,n){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var a=o.get,r=o.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(s){n=""+s,r.call(this,s)}}),Object.defineProperty(e,t,{enumerable:o.enumerable}),{getValue:function(){return n},setValue:function(s){n=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function e1(e){if(!e._valueTracker){var t=Pw(e)?"checked":"value";e._valueTracker=jP(e,t,""+e[t])}}function Bw(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),o="";return e&&(o=Pw(e)?e.checked?"true":"false":e.value),e=o,e!==n?(t.setValue(e),!0):!1}function Lm(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var VP=/[\n"\\]/g;function Vn(e){return e.replace(VP,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function t1(e,t,n,o,a,r,s,i){e.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.type=s:e.removeAttribute("type"),t!=null?s==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Wn(t)):e.value!==""+Wn(t)&&(e.value=""+Wn(t)):s!=="submit"&&s!=="reset"||e.removeAttribute("value"),t!=null?n1(e,s,Wn(t)):n!=null?n1(e,s,Wn(n)):o!=null&&e.removeAttribute("value"),a==null&&r!=null&&(e.defaultChecked=!!r),a!=null&&(e.checked=a&&typeof a!="function"&&typeof a!="symbol"),i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"?e.name=""+Wn(i):e.removeAttribute("name")}function Nw(e,t,n,o,a,r,s,i){if(r!=null&&typeof r!="function"&&typeof r!="symbol"&&typeof r!="boolean"&&(e.type=r),t!=null||n!=null){if(!(r!=="submit"&&r!=="reset"||t!=null)){e1(e);return}n=n!=null?""+Wn(n):"",t=t!=null?""+Wn(t):n,i||t===e.value||(e.value=t),e.defaultValue=t}o=o??a,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=i?e.checked:!!o,e.defaultChecked=!!o,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(e.name=s),e1(e)}function n1(e,t,n){t==="number"&&Lm(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function Cl(e,t,n,o){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&o&&(e[n].defaultSelected=!0)}else{for(n=""+Wn(n),t=null,a=0;a<e.length;a++){if(e[a].value===n){e[a].selected=!0,o&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function zw(e,t,n){if(t!=null&&(t=""+Wn(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+Wn(n):""}function Fw(e,t,n,o){if(t==null){if(o!=null){if(n!=null)throw Error(O(92));if(Tu(o)){if(1<o.length)throw Error(O(93));o=o[0]}n=o}n==null&&(n=""),t=n}n=Wn(t),e.defaultValue=n,o=e.textContent,o===n&&o!==""&&o!==null&&(e.value=o),e1(e)}function Pl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ZP=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function tk(e,t,n){var o=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?o?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":o?e.setProperty(t,n):typeof n!="number"||n===0||ZP.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Hw(e,t,n){if(t!=null&&typeof t!="object")throw Error(O(62));if(e=e.style,n!=null){for(var o in n)!n.hasOwnProperty(o)||t!=null&&t.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var a in t)o=t[a],t.hasOwnProperty(a)&&n[a]!==o&&tk(e,a,o)}else for(var r in t)t.hasOwnProperty(r)&&tk(e,r,t[r])}function V1(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var XP=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),YP=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function rm(e){return YP.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function La(){}var o1=null;function Z1(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var gl=null,El=null;function nk(e){var t=jl(e);if(t&&(e=t.stateNode)){var n=e[an]||null;e:switch(e=t.stateNode,t.type){case"input":if(t1(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+Vn(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var o=n[t];if(o!==e&&o.form===e.form){var a=o[an]||null;if(!a)throw Error(O(90));t1(o,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)o=n[t],o.form===e.form&&Bw(o)}break e;case"textarea":zw(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&Cl(e,!!n.multiple,t,!1)}}}var gx=!1;function Uw(e,t,n){if(gx)return e(t,n);gx=!0;try{var o=e(t);return o}finally{if(gx=!1,(gl!==null||El!==null)&&(s0(),gl&&(t=gl,e=El,El=gl=null,nk(t),e)))for(t=0;t<e.length;t++)nk(e[t])}}function Zu(e,t){var n=e.stateNode;if(n===null)return null;var o=n[an]||null;if(o===null)return null;n=o[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(O(231,t,typeof n));return n}var Ea=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),a1=!1;if(Ea)try{cl={},Object.defineProperty(cl,"passive",{get:function(){a1=!0}}),window.addEventListener("test",cl,cl),window.removeEventListener("test",cl,cl)}catch{a1=!1}var cl,vr=null,X1=null,sm=null;function Gw(){if(sm)return sm;var e,t=X1,n=t.length,o,a="value"in vr?vr.value:vr.textContent,r=a.length;for(e=0;e<n&&t[e]===a[e];e++);var s=n-e;for(o=1;o<=s&&t[n-o]===a[r-o];o++);return sm=a.slice(e,1<o?1-o:void 0)}function im(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function jh(){return!0}function ok(){return!1}function rn(e){function t(n,o,a,r,s){this._reactName=n,this._targetInst=a,this.type=o,this.nativeEvent=r,this.target=s,this.currentTarget=null;for(var i in e)e.hasOwnProperty(i)&&(n=e[i],this[i]=n?n(r):r[i]);return this.isDefaultPrevented=(r.defaultPrevented!=null?r.defaultPrevented:r.returnValue===!1)?jh:ok,this.isPropagationStopped=ok,this}return qe(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=jh)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=jh)},persist:function(){},isPersistent:jh}),t}var qs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ym=rn(qs),dd=qe({},qs,{view:0,detail:0}),KP=rn(dd),xx,bx,Su,Km=qe({},dd,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Y1,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Su&&(Su&&e.type==="mousemove"?(xx=e.screenX-Su.screenX,bx=e.screenY-Su.screenY):bx=xx=0,Su=e),xx)},movementY:function(e){return"movementY"in e?e.movementY:bx}}),ak=rn(Km),$P=qe({},Km,{dataTransfer:0}),QP=rn($P),JP=qe({},dd,{relatedTarget:0}),Ax=rn(JP),e7=qe({},qs,{animationName:0,elapsedTime:0,pseudoElement:0}),t7=rn(e7),n7=qe({},qs,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),o7=rn(n7),a7=qe({},qs,{data:0}),rk=rn(a7),r7={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},s7={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},i7={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function l7(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=i7[e])?!!t[e]:!1}function Y1(){return l7}var c7=qe({},dd,{key:function(e){if(e.key){var t=r7[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=im(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?s7[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Y1,charCode:function(e){return e.type==="keypress"?im(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?im(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),u7=rn(c7),d7=qe({},Km,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),sk=rn(d7),f7=qe({},dd,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Y1}),p7=rn(f7),h7=qe({},qs,{propertyName:0,elapsedTime:0,pseudoElement:0}),m7=rn(h7),y7=qe({},Km,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),g7=rn(y7),x7=qe({},qs,{newState:0,oldState:0}),b7=rn(x7),A7=[9,13,27,32],K1=Ea&&"CompositionEvent"in window,Ou=null;Ea&&"documentMode"in document&&(Ou=document.documentMode);var v7=Ea&&"TextEvent"in window&&!Ou,Ww=Ea&&(!K1||Ou&&8<Ou&&11>=Ou),ik=" ",lk=!1;function qw(e,t){switch(e){case"keyup":return A7.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function jw(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var xl=!1;function S7(e,t){switch(e){case"compositionend":return jw(t);case"keypress":return t.which!==32?null:(lk=!0,ik);case"textInput":return e=t.data,e===ik&&lk?null:e;default:return null}}function L7(e,t){if(xl)return e==="compositionend"||!K1&&qw(e,t)?(e=Gw(),sm=X1=vr=null,xl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Ww&&t.locale!=="ko"?null:t.data;default:return null}}var k7={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ck(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!k7[e.type]:t==="textarea"}function Vw(e,t,n,o){gl?El?El.push(o):El=[o]:gl=o,t=Um(t,"onChange"),0<t.length&&(n=new Ym("onChange","change",null,n,o),e.push({event:n,listeners:t}))}var Du=null,Xu=null;function w7(e){UC(e,0)}function $m(e){var t=Iu(e);if(Bw(t))return e}function uk(e,t){if(e==="change")return t}var Zw=!1;Ea&&(Ea?(Zh="oninput"in document,Zh||(vx=document.createElement("div"),vx.setAttribute("oninput","return;"),Zh=typeof vx.oninput=="function"),Vh=Zh):Vh=!1,Zw=Vh&&(!document.documentMode||9<document.documentMode));var Vh,Zh,vx;function dk(){Du&&(Du.detachEvent("onpropertychange",Xw),Xu=Du=null)}function Xw(e){if(e.propertyName==="value"&&$m(Xu)){var t=[];Vw(t,Xu,e,Z1(e)),Uw(w7,t)}}function _7(e,t,n){e==="focusin"?(dk(),Du=t,Xu=n,Du.attachEvent("onpropertychange",Xw)):e==="focusout"&&dk()}function C7(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return $m(Xu)}function E7(e,t){if(e==="click")return $m(t)}function T7(e,t){if(e==="input"||e==="change")return $m(t)}function I7(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Cn=typeof Object.is=="function"?Object.is:I7;function Yu(e,t){if(Cn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(o=0;o<n.length;o++){var a=n[o];if(!Qx.call(t,a)||!Cn(e[a],t[a]))return!1}return!0}function fk(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function pk(e,t){var n=fk(e);e=0;for(var o;n;){if(n.nodeType===3){if(o=e+n.textContent.length,e<=t&&o>=t)return{node:n,offset:t-e};e=o}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=fk(n)}}function Yw(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Yw(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Kw(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Lm(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Lm(e.document)}return t}function $1(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var M7=Ea&&"documentMode"in document&&11>=document.documentMode,bl=null,r1=null,Pu=null,s1=!1;function hk(e,t,n){var o=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;s1||bl==null||bl!==Lm(o)||(o=bl,"selectionStart"in o&&$1(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),Pu&&Yu(Pu,o)||(Pu=o,o=Um(r1,"onSelect"),0<o.length&&(t=new Ym("onSelect","select",null,t,n),e.push({event:t,listeners:o}),t.target=bl)))}function Es(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Al={animationend:Es("Animation","AnimationEnd"),animationiteration:Es("Animation","AnimationIteration"),animationstart:Es("Animation","AnimationStart"),transitionrun:Es("Transition","TransitionRun"),transitionstart:Es("Transition","TransitionStart"),transitioncancel:Es("Transition","TransitionCancel"),transitionend:Es("Transition","TransitionEnd")},Sx={},$w={};Ea&&($w=document.createElement("div").style,"AnimationEvent"in window||(delete Al.animationend.animation,delete Al.animationiteration.animation,delete Al.animationstart.animation),"TransitionEvent"in window||delete Al.transitionend.transition);function js(e){if(Sx[e])return Sx[e];if(!Al[e])return e;var t=Al[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in $w)return Sx[e]=t[n];return e}var Qw=js("animationend"),Jw=js("animationiteration"),e_=js("animationstart"),R7=js("transitionrun"),O7=js("transitionstart"),D7=js("transitioncancel"),t_=js("transitionend"),n_=new Map,i1="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");i1.push("scrollEnd");function go(e,t){n_.set(e,t),Ws(t,[e])}var km=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Gn=[],vl=0,Q1=0;function Qm(){for(var e=vl,t=Q1=vl=0;t<e;){var n=Gn[t];Gn[t++]=null;var o=Gn[t];Gn[t++]=null;var a=Gn[t];Gn[t++]=null;var r=Gn[t];if(Gn[t++]=null,o!==null&&a!==null){var s=o.pending;s===null?a.next=a:(a.next=s.next,s.next=a),o.pending=a}r!==0&&o_(n,a,r)}}function Jm(e,t,n,o){Gn[vl++]=e,Gn[vl++]=t,Gn[vl++]=n,Gn[vl++]=o,Q1|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function J1(e,t,n,o){return Jm(e,t,n,o),wm(e)}function Vs(e,t){return Jm(e,null,null,t),wm(e)}function o_(e,t,n){e.lanes|=n;var o=e.alternate;o!==null&&(o.lanes|=n);for(var a=!1,r=e.return;r!==null;)r.childLanes|=n,o=r.alternate,o!==null&&(o.childLanes|=n),r.tag===22&&(e=r.stateNode,e===null||e._visibility&1||(a=!0)),e=r,r=r.return;return e.tag===3?(r=e.stateNode,a&&t!==null&&(a=31-wn(n),e=r.hiddenUpdates,o=e[a],o===null?e[a]=[t]:o.push(t),t.lane=n|536870912),r):null}function wm(e){if(50<qu)throw qu=0,E1=null,Error(O(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Sl={};function P7(e,t,n,o){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vn(e,t,n,o){return new P7(e,t,n,o)}function eb(e){return e=e.prototype,!(!e||!e.isReactComponent)}function wa(e,t){var n=e.alternate;return n===null?(n=vn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function a_(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function lm(e,t,n,o,a,r){var s=0;if(o=e,typeof e=="function")eb(e)&&(s=1);else if(typeof e=="string")s=zB(e,n,zo.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case Xx:return e=vn(31,n,t,a),e.elementType=Xx,e.lanes=r,e;case hl:return Ds(n.children,a,r,t);case Lw:s=8,a|=24;break;case jx:return e=vn(12,n,t,a|2),e.elementType=jx,e.lanes=r,e;case Vx:return e=vn(13,n,t,a),e.elementType=Vx,e.lanes=r,e;case Zx:return e=vn(19,n,t,a),e.elementType=Zx,e.lanes=r,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Sa:s=10;break e;case kw:s=9;break e;case H1:s=11;break e;case U1:s=14;break e;case hr:s=16,o=null;break e}s=29,n=Error(O(130,e===null?"null":typeof e,"")),o=null}return t=vn(s,n,t,a),t.elementType=e,t.type=o,t.lanes=r,t}function Ds(e,t,n,o){return e=vn(7,e,o,t),e.lanes=n,e}function Lx(e,t,n){return e=vn(6,e,null,t),e.lanes=n,e}function r_(e){var t=vn(18,null,null,0);return t.stateNode=e,t}function kx(e,t,n){return t=vn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var mk=new WeakMap;function Zn(e,t){if(typeof e=="object"&&e!==null){var n=mk.get(e);return n!==void 0?n:(t={value:e,source:t,stack:K3(t)},mk.set(e,t),t)}return{value:e,source:t,stack:K3(t)}}var Ll=[],kl=0,_m=null,Ku=0,qn=[],jn=0,Dr=null,Po=1,Bo="";function Aa(e,t){Ll[kl++]=Ku,Ll[kl++]=_m,_m=e,Ku=t}function s_(e,t,n){qn[jn++]=Po,qn[jn++]=Bo,qn[jn++]=Dr,Dr=e;var o=Po;e=Bo;var a=32-wn(o)-1;o&=~(1<<a),n+=1;var r=32-wn(t)+a;if(30<r){var s=a-a%5;r=(o&(1<<s)-1).toString(32),o>>=s,a-=s,Po=1<<32-wn(t)+a|n<<a|o,Bo=r+e}else Po=1<<r|n<<a|o,Bo=e}function tb(e){e.return!==null&&(Aa(e,1),s_(e,1,0))}function nb(e){for(;e===_m;)_m=Ll[--kl],Ll[kl]=null,Ku=Ll[--kl],Ll[kl]=null;for(;e===Dr;)Dr=qn[--jn],qn[jn]=null,Bo=qn[--jn],qn[jn]=null,Po=qn[--jn],qn[jn]=null}function i_(e,t){qn[jn++]=Po,qn[jn++]=Bo,qn[jn++]=Dr,Po=t.id,Bo=t.overflow,Dr=e}var Mt=null,We=null,xe=!1,_r=null,Xn=!1,l1=Error(O(519));function Pr(e){var t=Error(O(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw $u(Zn(t,e)),l1}function yk(e){var t=e.stateNode,n=e.type,o=e.memoizedProps;switch(t[It]=e,t[an]=o,n){case"dialog":ue("cancel",t),ue("close",t);break;case"iframe":case"object":case"embed":ue("load",t);break;case"video":case"audio":for(n=0;n<td.length;n++)ue(td[n],t);break;case"source":ue("error",t);break;case"img":case"image":case"link":ue("error",t),ue("load",t);break;case"details":ue("toggle",t);break;case"input":ue("invalid",t),Nw(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":ue("invalid",t);break;case"textarea":ue("invalid",t),Fw(t,o.value,o.defaultValue,o.children)}n=o.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||o.suppressHydrationWarning===!0||WC(t.textContent,n)?(o.popover!=null&&(ue("beforetoggle",t),ue("toggle",t)),o.onScroll!=null&&ue("scroll",t),o.onScrollEnd!=null&&ue("scrollend",t),o.onClick!=null&&(t.onclick=La),t=!0):t=!1,t||Pr(e,!0)}function gk(e){for(Mt=e.return;Mt;)switch(Mt.tag){case 5:case 31:case 13:Xn=!1;return;case 27:case 3:Xn=!0;return;default:Mt=Mt.return}}function ul(e){if(e!==Mt)return!1;if(!xe)return gk(e),xe=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||O1(e.type,e.memoizedProps)),n=!n),n&&We&&Pr(e),gk(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));We=rw(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));We=rw(e)}else t===27?(t=We,Fr(e.type)?(e=N1,N1=null,We=e):We=t):We=Mt?Kn(e.stateNode.nextSibling):null;return!0}function zs(){We=Mt=null,xe=!1}function wx(){var e=_r;return e!==null&&(nn===null?nn=e:nn.push.apply(nn,e),_r=null),e}function $u(e){_r===null?_r=[e]:_r.push(e)}var c1=Fo(null),Zs=null,ka=null;function yr(e,t,n){Ne(c1,t._currentValue),t._currentValue=n}function _a(e){e._currentValue=c1.current,kt(c1)}function u1(e,t,n){for(;e!==null;){var o=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,o!==null&&(o.childLanes|=t)):o!==null&&(o.childLanes&t)!==t&&(o.childLanes|=t),e===n)break;e=e.return}}function d1(e,t,n,o){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var r=a.dependencies;if(r!==null){var s=a.child;r=r.firstContext;e:for(;r!==null;){var i=r;r=a;for(var l=0;l<t.length;l++)if(i.context===t[l]){r.lanes|=n,i=r.alternate,i!==null&&(i.lanes|=n),u1(r.return,n,e),o||(s=null);break e}r=i.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(O(341));s.lanes|=n,r=s.alternate,r!==null&&(r.lanes|=n),u1(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Vl(e,t,n,o){e=null;for(var a=t,r=!1;a!==null;){if(!r){if((a.flags&524288)!==0)r=!0;else if((a.flags&262144)!==0)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(O(387));if(s=s.memoizedProps,s!==null){var i=a.type;Cn(a.pendingProps.value,s.value)||(e!==null?e.push(i):e=[i])}}else if(a===bm.current){if(s=a.alternate,s===null)throw Error(O(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e!==null?e.push(od):e=[od])}a=a.return}e!==null&&d1(t,e,n,o),t.flags|=262144}function Cm(e){for(e=e.firstContext;e!==null;){if(!Cn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Fs(e){Zs=e,ka=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Rt(e){return l_(Zs,e)}function Xh(e,t){return Zs===null&&Fs(e),l_(e,t)}function l_(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ka===null){if(e===null)throw Error(O(308));ka=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ka=ka.next=t;return n}var B7=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,o){e.push(o)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},N7=ht.unstable_scheduleCallback,z7=ht.unstable_NormalPriority,it={$$typeof:Sa,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ob(){return{controller:new B7,data:new Map,refCount:0}}function fd(e){e.refCount--,e.refCount===0&&N7(z7,function(){e.controller.abort()})}var Bu=null,f1=0,Bl=0,Tl=null;function F7(e,t){if(Bu===null){var n=Bu=[];f1=0,Bl=Eb(),Tl={status:"pending",value:void 0,then:function(o){n.push(o)}}}return f1++,t.then(xk,xk),t}function xk(){if(--f1===0&&Bu!==null){Tl!==null&&(Tl.status="fulfilled");var e=Bu;Bu=null,Bl=0,Tl=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function H7(e,t){var n=[],o={status:"pending",value:null,reason:null,then:function(a){n.push(a)}};return e.then(function(){o.status="fulfilled",o.value=t;for(var a=0;a<n.length;a++)(0,n[a])(t)},function(a){for(o.status="rejected",o.reason=a,a=0;a<n.length;a++)(0,n[a])(void 0)}),o}var bk=K.S;K.S=function(e,t){SC=Ln(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&F7(e,t),bk!==null&&bk(e,t)};var Ps=Fo(null);function ab(){var e=Ps.current;return e!==null?e:De.pooledCache}function cm(e,t){t===null?Ne(Ps,Ps.current):Ne(Ps,t.pool)}function c_(){var e=ab();return e===null?null:{parent:it._currentValue,pool:e}}var Zl=Error(O(460)),rb=Error(O(474)),e0=Error(O(542)),Em={then:function(){}};function Ak(e){return e=e.status,e==="fulfilled"||e==="rejected"}function u_(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(La,La),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Sk(e),e;default:if(typeof t.status=="string")t.then(La,La);else{if(e=De,e!==null&&100<e.shellSuspendCounter)throw Error(O(482));e=t,e.status="pending",e.then(function(o){if(t.status==="pending"){var a=t;a.status="fulfilled",a.value=o}},function(o){if(t.status==="pending"){var a=t;a.status="rejected",a.reason=o}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Sk(e),e}throw Bs=t,Zl}}function Ms(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Bs=n,Zl):n}}var Bs=null;function vk(){if(Bs===null)throw Error(O(459));var e=Bs;return Bs=null,e}function Sk(e){if(e===Zl||e===e0)throw Error(O(483))}var Il=null,Qu=0;function Yh(e){var t=Qu;return Qu+=1,Il===null&&(Il=[]),u_(Il,e,t)}function Lu(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Kh(e,t){throw t.$$typeof===_P?Error(O(525)):(e=Object.prototype.toString.call(t),Error(O(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function d_(e){function t(y,g){if(e){var b=y.deletions;b===null?(y.deletions=[g],y.flags|=16):b.push(g)}}function n(y,g){if(!e)return null;for(;g!==null;)t(y,g),g=g.sibling;return null}function o(y){for(var g=new Map;y!==null;)y.key!==null?g.set(y.key,y):g.set(y.index,y),y=y.sibling;return g}function a(y,g){return y=wa(y,g),y.index=0,y.sibling=null,y}function r(y,g,b){return y.index=b,e?(b=y.alternate,b!==null?(b=b.index,b<g?(y.flags|=67108866,g):b):(y.flags|=67108866,g)):(y.flags|=1048576,g)}function s(y){return e&&y.alternate===null&&(y.flags|=67108866),y}function i(y,g,b,A){return g===null||g.tag!==6?(g=Lx(b,y.mode,A),g.return=y,g):(g=a(g,b),g.return=y,g)}function l(y,g,b,A){var _=b.type;return _===hl?u(y,g,b.props.children,A,b.key):g!==null&&(g.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===hr&&Ms(_)===g.type)?(g=a(g,b.props),Lu(g,b),g.return=y,g):(g=lm(b.type,b.key,b.props,null,y.mode,A),Lu(g,b),g.return=y,g)}function c(y,g,b,A){return g===null||g.tag!==4||g.stateNode.containerInfo!==b.containerInfo||g.stateNode.implementation!==b.implementation?(g=kx(b,y.mode,A),g.return=y,g):(g=a(g,b.children||[]),g.return=y,g)}function u(y,g,b,A,_){return g===null||g.tag!==7?(g=Ds(b,y.mode,A,_),g.return=y,g):(g=a(g,b),g.return=y,g)}function d(y,g,b){if(typeof g=="string"&&g!==""||typeof g=="number"||typeof g=="bigint")return g=Lx(""+g,y.mode,b),g.return=y,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Hh:return b=lm(g.type,g.key,g.props,null,y.mode,b),Lu(b,g),b.return=y,b;case Eu:return g=kx(g,y.mode,b),g.return=y,g;case hr:return g=Ms(g),d(y,g,b)}if(Tu(g)||vu(g))return g=Ds(g,y.mode,b,null),g.return=y,g;if(typeof g.then=="function")return d(y,Yh(g),b);if(g.$$typeof===Sa)return d(y,Xh(y,g),b);Kh(y,g)}return null}function f(y,g,b,A){var _=g!==null?g.key:null;if(typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint")return _!==null?null:i(y,g,""+b,A);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case Hh:return b.key===_?l(y,g,b,A):null;case Eu:return b.key===_?c(y,g,b,A):null;case hr:return b=Ms(b),f(y,g,b,A)}if(Tu(b)||vu(b))return _!==null?null:u(y,g,b,A,null);if(typeof b.then=="function")return f(y,g,Yh(b),A);if(b.$$typeof===Sa)return f(y,g,Xh(y,b),A);Kh(y,b)}return null}function p(y,g,b,A,_){if(typeof A=="string"&&A!==""||typeof A=="number"||typeof A=="bigint")return y=y.get(b)||null,i(g,y,""+A,_);if(typeof A=="object"&&A!==null){switch(A.$$typeof){case Hh:return y=y.get(A.key===null?b:A.key)||null,l(g,y,A,_);case Eu:return y=y.get(A.key===null?b:A.key)||null,c(g,y,A,_);case hr:return A=Ms(A),p(y,g,b,A,_)}if(Tu(A)||vu(A))return y=y.get(b)||null,u(g,y,A,_,null);if(typeof A.then=="function")return p(y,g,b,Yh(A),_);if(A.$$typeof===Sa)return p(y,g,b,Xh(g,A),_);Kh(g,A)}return null}function h(y,g,b,A){for(var _=null,T=null,w=g,S=g=0,L=null;w!==null&&S<b.length;S++){w.index>S?(L=w,w=null):L=w.sibling;var M=f(y,w,b[S],A);if(M===null){w===null&&(w=L);break}e&&w&&M.alternate===null&&t(y,w),g=r(M,g,S),T===null?_=M:T.sibling=M,T=M,w=L}if(S===b.length)return n(y,w),xe&&Aa(y,S),_;if(w===null){for(;S<b.length;S++)w=d(y,b[S],A),w!==null&&(g=r(w,g,S),T===null?_=w:T.sibling=w,T=w);return xe&&Aa(y,S),_}for(w=o(w);S<b.length;S++)L=p(w,y,S,b[S],A),L!==null&&(e&&L.alternate!==null&&w.delete(L.key===null?S:L.key),g=r(L,g,S),T===null?_=L:T.sibling=L,T=L);return e&&w.forEach(function(B){return t(y,B)}),xe&&Aa(y,S),_}function m(y,g,b,A){if(b==null)throw Error(O(151));for(var _=null,T=null,w=g,S=g=0,L=null,M=b.next();w!==null&&!M.done;S++,M=b.next()){w.index>S?(L=w,w=null):L=w.sibling;var B=f(y,w,M.value,A);if(B===null){w===null&&(w=L);break}e&&w&&B.alternate===null&&t(y,w),g=r(B,g,S),T===null?_=B:T.sibling=B,T=B,w=L}if(M.done)return n(y,w),xe&&Aa(y,S),_;if(w===null){for(;!M.done;S++,M=b.next())M=d(y,M.value,A),M!==null&&(g=r(M,g,S),T===null?_=M:T.sibling=M,T=M);return xe&&Aa(y,S),_}for(w=o(w);!M.done;S++,M=b.next())M=p(w,y,S,M.value,A),M!==null&&(e&&M.alternate!==null&&w.delete(M.key===null?S:M.key),g=r(M,g,S),T===null?_=M:T.sibling=M,T=M);return e&&w.forEach(function(W){return t(y,W)}),xe&&Aa(y,S),_}function x(y,g,b,A){if(typeof b=="object"&&b!==null&&b.type===hl&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case Hh:e:{for(var _=b.key;g!==null;){if(g.key===_){if(_=b.type,_===hl){if(g.tag===7){n(y,g.sibling),A=a(g,b.props.children),A.return=y,y=A;break e}}else if(g.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===hr&&Ms(_)===g.type){n(y,g.sibling),A=a(g,b.props),Lu(A,b),A.return=y,y=A;break e}n(y,g);break}else t(y,g);g=g.sibling}b.type===hl?(A=Ds(b.props.children,y.mode,A,b.key),A.return=y,y=A):(A=lm(b.type,b.key,b.props,null,y.mode,A),Lu(A,b),A.return=y,y=A)}return s(y);case Eu:e:{for(_=b.key;g!==null;){if(g.key===_)if(g.tag===4&&g.stateNode.containerInfo===b.containerInfo&&g.stateNode.implementation===b.implementation){n(y,g.sibling),A=a(g,b.children||[]),A.return=y,y=A;break e}else{n(y,g);break}else t(y,g);g=g.sibling}A=kx(b,y.mode,A),A.return=y,y=A}return s(y);case hr:return b=Ms(b),x(y,g,b,A)}if(Tu(b))return h(y,g,b,A);if(vu(b)){if(_=vu(b),typeof _!="function")throw Error(O(150));return b=_.call(b),m(y,g,b,A)}if(typeof b.then=="function")return x(y,g,Yh(b),A);if(b.$$typeof===Sa)return x(y,g,Xh(y,b),A);Kh(y,b)}return typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint"?(b=""+b,g!==null&&g.tag===6?(n(y,g.sibling),A=a(g,b),A.return=y,y=A):(n(y,g),A=Lx(b,y.mode,A),A.return=y,y=A),s(y)):n(y,g)}return function(y,g,b,A){try{Qu=0;var _=x(y,g,b,A);return Il=null,_}catch(w){if(w===Zl||w===e0)throw w;var T=vn(29,w,null,y.mode);return T.lanes=A,T.return=y,T}finally{}}}var Hs=d_(!0),f_=d_(!1),mr=!1;function sb(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function p1(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Cr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Er(e,t,n){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(ke&2)!==0){var a=o.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),o.pending=t,t=wm(e),o_(e,null,n),t}return Jm(e,o,t,n),wm(e)}function Nu(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var o=t.lanes;o&=e.pendingLanes,n|=o,t.lanes=n,Iw(e,n)}}function _x(e,t){var n=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,n===o)){var a=null,r=null;if(n=n.firstBaseUpdate,n!==null){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};r===null?a=r=s:r=r.next=s,n=n.next}while(n!==null);r===null?a=r=t:r=r.next=t}else a=r=t;n={baseState:o.baseState,firstBaseUpdate:a,lastBaseUpdate:r,shared:o.shared,callbacks:o.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var h1=!1;function zu(){if(h1){var e=Tl;if(e!==null)throw e}}function Fu(e,t,n,o){h1=!1;var a=e.updateQueue;mr=!1;var r=a.firstBaseUpdate,s=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var l=i,c=l.next;l.next=null,s===null?r=c:s.next=c,s=l;var u=e.alternate;u!==null&&(u=u.updateQueue,i=u.lastBaseUpdate,i!==s&&(i===null?u.firstBaseUpdate=c:i.next=c,u.lastBaseUpdate=l))}if(r!==null){var d=a.baseState;s=0,u=c=l=null,i=r;do{var f=i.lane&-536870913,p=f!==i.lane;if(p?(he&f)===f:(o&f)===f){f!==0&&f===Bl&&(h1=!0),u!==null&&(u=u.next={lane:0,tag:i.tag,payload:i.payload,callback:null,next:null});e:{var h=e,m=i;f=t;var x=n;switch(m.tag){case 1:if(h=m.payload,typeof h=="function"){d=h.call(x,d,f);break e}d=h;break e;case 3:h.flags=h.flags&-65537|128;case 0:if(h=m.payload,f=typeof h=="function"?h.call(x,d,f):h,f==null)break e;d=qe({},d,f);break e;case 2:mr=!0}}f=i.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=a.callbacks,p===null?a.callbacks=[f]:p.push(f))}else p={lane:f,tag:i.tag,payload:i.payload,callback:i.callback,next:null},u===null?(c=u=p,l=d):u=u.next=p,s|=f;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;p=i,i=p.next,p.next=null,a.lastBaseUpdate=p,a.shared.pending=null}}while(!0);u===null&&(l=d),a.baseState=l,a.firstBaseUpdate=c,a.lastBaseUpdate=u,r===null&&(a.shared.lanes=0),Nr|=s,e.lanes=s,e.memoizedState=d}}function p_(e,t){if(typeof e!="function")throw Error(O(191,e));e.call(t)}function h_(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)p_(n[e],t)}var Nl=Fo(null),Tm=Fo(0);function Lk(e,t){e=Ra,Ne(Tm,e),Ne(Nl,t),Ra=e|t.baseLanes}function m1(){Ne(Tm,Ra),Ne(Nl,Nl.current)}function ib(){Ra=Tm.current,kt(Nl),kt(Tm)}var En=Fo(null),Yn=null;function gr(e){var t=e.alternate;Ne(tt,tt.current&1),Ne(En,e),Yn===null&&(t===null||Nl.current!==null||t.memoizedState!==null)&&(Yn=e)}function y1(e){Ne(tt,tt.current),Ne(En,e),Yn===null&&(Yn=e)}function m_(e){e.tag===22?(Ne(tt,tt.current),Ne(En,e),Yn===null&&(Yn=e)):xr(e)}function xr(){Ne(tt,tt.current),Ne(En,En.current)}function An(e){kt(En),Yn===e&&(Yn=null),kt(tt)}var tt=Fo(0);function Im(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||P1(n)||B1(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ta=0,oe=null,Me=null,rt=null,Mm=!1,Ml=!1,Us=!1,Rm=0,Ju=0,Rl=null,U7=0;function $e(){throw Error(O(321))}function lb(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Cn(e[n],t[n]))return!1;return!0}function cb(e,t,n,o,a,r){return Ta=r,oe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,K.H=e===null||e.memoizedState===null?V_:Ab,Us=!1,r=n(o,a),Us=!1,Ml&&(r=g_(t,n,o,a)),y_(e),r}function y_(e){K.H=ed;var t=Me!==null&&Me.next!==null;if(Ta=0,rt=Me=oe=null,Mm=!1,Ju=0,Rl=null,t)throw Error(O(300));e===null||lt||(e=e.dependencies,e!==null&&Cm(e)&&(lt=!0))}function g_(e,t,n,o){oe=e;var a=0;do{if(Ml&&(Rl=null),Ju=0,Ml=!1,25<=a)throw Error(O(301));if(a+=1,rt=Me=null,e.updateQueue!=null){var r=e.updateQueue;r.lastEffect=null,r.events=null,r.stores=null,r.memoCache!=null&&(r.memoCache.index=0)}K.H=Z_,r=t(n,o)}while(Ml);return r}function G7(){var e=K.H,t=e.useState()[0];return t=typeof t.then=="function"?pd(t):t,e=e.useState()[0],(Me!==null?Me.memoizedState:null)!==e&&(oe.flags|=1024),t}function ub(){var e=Rm!==0;return Rm=0,e}function db(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function fb(e){if(Mm){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Mm=!1}Ta=0,rt=Me=oe=null,Ml=!1,Ju=Rm=0,Rl=null}function Zt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rt===null?oe.memoizedState=rt=e:rt=rt.next=e,rt}function nt(){if(Me===null){var e=oe.alternate;e=e!==null?e.memoizedState:null}else e=Me.next;var t=rt===null?oe.memoizedState:rt.next;if(t!==null)rt=t,Me=e;else{if(e===null)throw oe.alternate===null?Error(O(467)):Error(O(310));Me=e,e={memoizedState:Me.memoizedState,baseState:Me.baseState,baseQueue:Me.baseQueue,queue:Me.queue,next:null},rt===null?oe.memoizedState=rt=e:rt=rt.next=e}return rt}function t0(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function pd(e){var t=Ju;return Ju+=1,Rl===null&&(Rl=[]),e=u_(Rl,e,t),t=oe,(rt===null?t.memoizedState:rt.next)===null&&(t=t.alternate,K.H=t===null||t.memoizedState===null?V_:Ab),e}function n0(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return pd(e);if(e.$$typeof===Sa)return Rt(e)}throw Error(O(438,String(e)))}function pb(e){var t=null,n=oe.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var o=oe.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(t={data:o.data.map(function(a){return a.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=t0(),oe.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),o=0;o<e;o++)n[o]=CP;return t.index++,n}function Ia(e,t){return typeof t=="function"?t(e):t}function um(e){var t=nt();return hb(t,Me,e)}function hb(e,t,n){var o=e.queue;if(o===null)throw Error(O(311));o.lastRenderedReducer=n;var a=e.baseQueue,r=o.pending;if(r!==null){if(a!==null){var s=a.next;a.next=r.next,r.next=s}t.baseQueue=a=r,o.pending=null}if(r=e.baseState,a===null)e.memoizedState=r;else{t=a.next;var i=s=null,l=null,c=t,u=!1;do{var d=c.lane&-536870913;if(d!==c.lane?(he&d)===d:(Ta&d)===d){var f=c.revertLane;if(f===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),d===Bl&&(u=!0);else if((Ta&f)===f){c=c.next,f===Bl&&(u=!0);continue}else d={lane:0,revertLane:c.revertLane,gesture:null,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null},l===null?(i=l=d,s=r):l=l.next=d,oe.lanes|=f,Nr|=f;d=c.action,Us&&n(r,d),r=c.hasEagerState?c.eagerState:n(r,d)}else f={lane:d,revertLane:c.revertLane,gesture:c.gesture,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null},l===null?(i=l=f,s=r):l=l.next=f,oe.lanes|=d,Nr|=d;c=c.next}while(c!==null&&c!==t);if(l===null?s=r:l.next=i,!Cn(r,e.memoizedState)&&(lt=!0,u&&(n=Tl,n!==null)))throw n;e.memoizedState=r,e.baseState=s,e.baseQueue=l,o.lastRenderedState=r}return a===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function Cx(e){var t=nt(),n=t.queue;if(n===null)throw Error(O(311));n.lastRenderedReducer=e;var o=n.dispatch,a=n.pending,r=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do r=e(r,s.action),s=s.next;while(s!==a);Cn(r,t.memoizedState)||(lt=!0),t.memoizedState=r,t.baseQueue===null&&(t.baseState=r),n.lastRenderedState=r}return[r,o]}function x_(e,t,n){var o=oe,a=nt(),r=xe;if(r){if(n===void 0)throw Error(O(407));n=n()}else n=t();var s=!Cn((Me||a).memoizedState,n);if(s&&(a.memoizedState=n,lt=!0),a=a.queue,mb(v_.bind(null,o,a,e),[e]),a.getSnapshot!==t||s||rt!==null&&rt.memoizedState.tag&1){if(o.flags|=2048,zl(9,{destroy:void 0},A_.bind(null,o,a,n,t),null),De===null)throw Error(O(349));r||(Ta&127)!==0||b_(o,t,n)}return n}function b_(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=oe.updateQueue,t===null?(t=t0(),oe.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function A_(e,t,n,o){t.value=n,t.getSnapshot=o,S_(t)&&L_(e)}function v_(e,t,n){return n(function(){S_(t)&&L_(e)})}function S_(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Cn(e,n)}catch{return!0}}function L_(e){var t=Vs(e,2);t!==null&&on(t,e,2)}function g1(e){var t=Zt();if(typeof e=="function"){var n=e;if(e=n(),Us){Ar(!0);try{n()}finally{Ar(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:e},t}function k_(e,t,n,o){return e.baseState=n,hb(e,Me,typeof o=="function"?o:Ia)}function W7(e,t,n,o,a){if(a0(e))throw Error(O(485));if(e=t.action,e!==null){var r={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(s){r.listeners.push(s)}};K.T!==null?n(!0):r.isTransition=!1,o(r),n=t.pending,n===null?(r.next=t.pending=r,w_(t,r)):(r.next=n.next,t.pending=n.next=r)}}function w_(e,t){var n=t.action,o=t.payload,a=e.state;if(t.isTransition){var r=K.T,s={};K.T=s;try{var i=n(a,o),l=K.S;l!==null&&l(s,i),kk(e,t,i)}catch(c){x1(e,t,c)}finally{r!==null&&s.types!==null&&(r.types=s.types),K.T=r}}else try{r=n(a,o),kk(e,t,r)}catch(c){x1(e,t,c)}}function kk(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(o){wk(e,t,o)},function(o){return x1(e,t,o)}):wk(e,t,n)}function wk(e,t,n){t.status="fulfilled",t.value=n,__(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,w_(e,n)))}function x1(e,t,n){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=n,__(t),t=t.next;while(t!==o)}e.action=null}function __(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function C_(e,t){return t}function _k(e,t){if(xe){var n=De.formState;if(n!==null){e:{var o=oe;if(xe){if(We){t:{for(var a=We,r=Xn;a.nodeType!==8;){if(!r){a=null;break t}if(a=Kn(a.nextSibling),a===null){a=null;break t}}r=a.data,a=r==="F!"||r==="F"?a:null}if(a){We=Kn(a.nextSibling),o=a.data==="F!";break e}}Pr(o)}o=!1}o&&(t=n[0])}}return n=Zt(),n.memoizedState=n.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:C_,lastRenderedState:t},n.queue=o,n=W_.bind(null,oe,o),o.dispatch=n,o=g1(!1),r=bb.bind(null,oe,!1,o.queue),o=Zt(),a={state:t,dispatch:null,action:e,pending:null},o.queue=a,n=W7.bind(null,oe,a,r,n),a.dispatch=n,o.memoizedState=e,[t,n,!1]}function Ck(e){var t=nt();return E_(t,Me,e)}function E_(e,t,n){if(t=hb(e,t,C_)[0],e=um(Ia)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=pd(t)}catch(s){throw s===Zl?e0:s}else o=t;t=nt();var a=t.queue,r=a.dispatch;return n!==t.memoizedState&&(oe.flags|=2048,zl(9,{destroy:void 0},q7.bind(null,a,n),null)),[o,r,e]}function q7(e,t){e.action=t}function Ek(e){var t=nt(),n=Me;if(n!==null)return E_(t,n,e);nt(),t=t.memoizedState,n=nt();var o=n.queue.dispatch;return n.memoizedState=e,[t,o,!1]}function zl(e,t,n,o){return e={tag:e,create:n,deps:o,inst:t,next:null},t=oe.updateQueue,t===null&&(t=t0(),oe.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(o=n.next,n.next=e,e.next=o,t.lastEffect=e),e}function T_(){return nt().memoizedState}function dm(e,t,n,o){var a=Zt();oe.flags|=e,a.memoizedState=zl(1|t,{destroy:void 0},n,o===void 0?null:o)}function o0(e,t,n,o){var a=nt();o=o===void 0?null:o;var r=a.memoizedState.inst;Me!==null&&o!==null&&lb(o,Me.memoizedState.deps)?a.memoizedState=zl(t,r,n,o):(oe.flags|=e,a.memoizedState=zl(1|t,r,n,o))}function Tk(e,t){dm(8390656,8,e,t)}function mb(e,t){o0(2048,8,e,t)}function j7(e){oe.flags|=4;var t=oe.updateQueue;if(t===null)t=t0(),oe.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function I_(e){var t=nt().memoizedState;return j7({ref:t,nextImpl:e}),function(){if((ke&2)!==0)throw Error(O(440));return t.impl.apply(void 0,arguments)}}function M_(e,t){return o0(4,2,e,t)}function R_(e,t){return o0(4,4,e,t)}function O_(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function D_(e,t,n){n=n!=null?n.concat([e]):null,o0(4,4,O_.bind(null,t,e),n)}function yb(){}function P_(e,t){var n=nt();t=t===void 0?null:t;var o=n.memoizedState;return t!==null&&lb(t,o[1])?o[0]:(n.memoizedState=[e,t],e)}function B_(e,t){var n=nt();t=t===void 0?null:t;var o=n.memoizedState;if(t!==null&&lb(t,o[1]))return o[0];if(o=e(),Us){Ar(!0);try{e()}finally{Ar(!1)}}return n.memoizedState=[o,t],o}function gb(e,t,n){return n===void 0||(Ta&1073741824)!==0&&(he&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=kC(),oe.lanes|=e,Nr|=e,n)}function N_(e,t,n,o){return Cn(n,t)?n:Nl.current!==null?(e=gb(e,n,o),Cn(e,t)||(lt=!0),e):(Ta&42)===0||(Ta&1073741824)!==0&&(he&261930)===0?(lt=!0,e.memoizedState=n):(e=kC(),oe.lanes|=e,Nr|=e,t)}function z_(e,t,n,o,a){var r=we.p;we.p=r!==0&&8>r?r:8;var s=K.T,i={};K.T=i,bb(e,!1,t,n);try{var l=a(),c=K.S;if(c!==null&&c(i,l),l!==null&&typeof l=="object"&&typeof l.then=="function"){var u=H7(l,o);Hu(e,t,u,_n(e))}else Hu(e,t,o,_n(e))}catch(d){Hu(e,t,{then:function(){},status:"rejected",reason:d},_n())}finally{we.p=r,s!==null&&i.types!==null&&(s.types=i.types),K.T=s}}function V7(){}function b1(e,t,n,o){if(e.tag!==5)throw Error(O(476));var a=F_(e).queue;z_(e,a,t,Os,n===null?V7:function(){return H_(e),n(o)})}function F_(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Os,baseState:Os,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:Os},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ia,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function H_(e){var t=F_(e);t.next===null&&(t=e.alternate.memoizedState),Hu(e,t.next.queue,{},_n())}function xb(){return Rt(od)}function U_(){return nt().memoizedState}function G_(){return nt().memoizedState}function Z7(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=_n();e=Cr(n);var o=Er(t,e,n);o!==null&&(on(o,t,n),Nu(o,t,n)),t={cache:ob()},e.payload=t;return}t=t.return}}function X7(e,t,n){var o=_n();n={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},a0(e)?q_(t,n):(n=J1(e,t,n,o),n!==null&&(on(n,e,o),j_(n,t,o)))}function W_(e,t,n){var o=_n();Hu(e,t,n,o)}function Hu(e,t,n,o){var a={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(a0(e))q_(t,a);else{var r=e.alternate;if(e.lanes===0&&(r===null||r.lanes===0)&&(r=t.lastRenderedReducer,r!==null))try{var s=t.lastRenderedState,i=r(s,n);if(a.hasEagerState=!0,a.eagerState=i,Cn(i,s))return Jm(e,t,a,0),De===null&&Qm(),!1}catch{}finally{}if(n=J1(e,t,a,o),n!==null)return on(n,e,o),j_(n,t,o),!0}return!1}function bb(e,t,n,o){if(o={lane:2,revertLane:Eb(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},a0(e)){if(t)throw Error(O(479))}else t=J1(e,n,o,2),t!==null&&on(t,e,2)}function a0(e){var t=e.alternate;return e===oe||t!==null&&t===oe}function q_(e,t){Ml=Mm=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function j_(e,t,n){if((n&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,n|=o,t.lanes=n,Iw(e,n)}}var ed={readContext:Rt,use:n0,useCallback:$e,useContext:$e,useEffect:$e,useImperativeHandle:$e,useLayoutEffect:$e,useInsertionEffect:$e,useMemo:$e,useReducer:$e,useRef:$e,useState:$e,useDebugValue:$e,useDeferredValue:$e,useTransition:$e,useSyncExternalStore:$e,useId:$e,useHostTransitionStatus:$e,useFormState:$e,useActionState:$e,useOptimistic:$e,useMemoCache:$e,useCacheRefresh:$e};ed.useEffectEvent=$e;var V_={readContext:Rt,use:n0,useCallback:function(e,t){return Zt().memoizedState=[e,t===void 0?null:t],e},useContext:Rt,useEffect:Tk,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,dm(4194308,4,O_.bind(null,t,e),n)},useLayoutEffect:function(e,t){return dm(4194308,4,e,t)},useInsertionEffect:function(e,t){dm(4,2,e,t)},useMemo:function(e,t){var n=Zt();t=t===void 0?null:t;var o=e();if(Us){Ar(!0);try{e()}finally{Ar(!1)}}return n.memoizedState=[o,t],o},useReducer:function(e,t,n){var o=Zt();if(n!==void 0){var a=n(t);if(Us){Ar(!0);try{n(t)}finally{Ar(!1)}}}else a=t;return o.memoizedState=o.baseState=a,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:a},o.queue=e,e=e.dispatch=X7.bind(null,oe,e),[o.memoizedState,e]},useRef:function(e){var t=Zt();return e={current:e},t.memoizedState=e},useState:function(e){e=g1(e);var t=e.queue,n=W_.bind(null,oe,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:yb,useDeferredValue:function(e,t){var n=Zt();return gb(n,e,t)},useTransition:function(){var e=g1(!1);return e=z_.bind(null,oe,e.queue,!0,!1),Zt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var o=oe,a=Zt();if(xe){if(n===void 0)throw Error(O(407));n=n()}else{if(n=t(),De===null)throw Error(O(349));(he&127)!==0||b_(o,t,n)}a.memoizedState=n;var r={value:n,getSnapshot:t};return a.queue=r,Tk(v_.bind(null,o,r,e),[e]),o.flags|=2048,zl(9,{destroy:void 0},A_.bind(null,o,r,n,t),null),n},useId:function(){var e=Zt(),t=De.identifierPrefix;if(xe){var n=Bo,o=Po;n=(o&~(1<<32-wn(o)-1)).toString(32)+n,t="_"+t+"R_"+n,n=Rm++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=U7++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:xb,useFormState:_k,useActionState:_k,useOptimistic:function(e){var t=Zt();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=bb.bind(null,oe,!0,n),n.dispatch=t,[e,t]},useMemoCache:pb,useCacheRefresh:function(){return Zt().memoizedState=Z7.bind(null,oe)},useEffectEvent:function(e){var t=Zt(),n={impl:e};return t.memoizedState=n,function(){if((ke&2)!==0)throw Error(O(440));return n.impl.apply(void 0,arguments)}}},Ab={readContext:Rt,use:n0,useCallback:P_,useContext:Rt,useEffect:mb,useImperativeHandle:D_,useInsertionEffect:M_,useLayoutEffect:R_,useMemo:B_,useReducer:um,useRef:T_,useState:function(){return um(Ia)},useDebugValue:yb,useDeferredValue:function(e,t){var n=nt();return N_(n,Me.memoizedState,e,t)},useTransition:function(){var e=um(Ia)[0],t=nt().memoizedState;return[typeof e=="boolean"?e:pd(e),t]},useSyncExternalStore:x_,useId:U_,useHostTransitionStatus:xb,useFormState:Ck,useActionState:Ck,useOptimistic:function(e,t){var n=nt();return k_(n,Me,e,t)},useMemoCache:pb,useCacheRefresh:G_};Ab.useEffectEvent=I_;var Z_={readContext:Rt,use:n0,useCallback:P_,useContext:Rt,useEffect:mb,useImperativeHandle:D_,useInsertionEffect:M_,useLayoutEffect:R_,useMemo:B_,useReducer:Cx,useRef:T_,useState:function(){return Cx(Ia)},useDebugValue:yb,useDeferredValue:function(e,t){var n=nt();return Me===null?gb(n,e,t):N_(n,Me.memoizedState,e,t)},useTransition:function(){var e=Cx(Ia)[0],t=nt().memoizedState;return[typeof e=="boolean"?e:pd(e),t]},useSyncExternalStore:x_,useId:U_,useHostTransitionStatus:xb,useFormState:Ek,useActionState:Ek,useOptimistic:function(e,t){var n=nt();return Me!==null?k_(n,Me,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:pb,useCacheRefresh:G_};Z_.useEffectEvent=I_;function Ex(e,t,n,o){t=e.memoizedState,n=n(o,t),n=n==null?t:qe({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var A1={enqueueSetState:function(e,t,n){e=e._reactInternals;var o=_n(),a=Cr(o);a.payload=t,n!=null&&(a.callback=n),t=Er(e,a,o),t!==null&&(on(t,e,o),Nu(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var o=_n(),a=Cr(o);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=Er(e,a,o),t!==null&&(on(t,e,o),Nu(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=_n(),o=Cr(n);o.tag=2,t!=null&&(o.callback=t),t=Er(e,o,n),t!==null&&(on(t,e,n),Nu(t,e,n))}};function Ik(e,t,n,o,a,r,s){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,r,s):t.prototype&&t.prototype.isPureReactComponent?!Yu(n,o)||!Yu(a,r):!0}function Mk(e,t,n,o){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,o),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,o),t.state!==e&&A1.enqueueReplaceState(t,t.state,null)}function Gs(e,t){var n=t;if("ref"in t){n={};for(var o in t)o!=="ref"&&(n[o]=t[o])}if(e=e.defaultProps){n===t&&(n=qe({},n));for(var a in e)n[a]===void 0&&(n[a]=e[a])}return n}function X_(e){km(e)}function Y_(e){console.error(e)}function K_(e){km(e)}function Om(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function Rk(e,t,n){try{var o=e.onCaughtError;o(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(a){setTimeout(function(){throw a})}}function v1(e,t,n){return n=Cr(n),n.tag=3,n.payload={element:null},n.callback=function(){Om(e,t)},n}function $_(e){return e=Cr(e),e.tag=3,e}function Q_(e,t,n,o){var a=n.type.getDerivedStateFromError;if(typeof a=="function"){var r=o.value;e.payload=function(){return a(r)},e.callback=function(){Rk(t,n,o)}}var s=n.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(e.callback=function(){Rk(t,n,o),typeof a!="function"&&(Tr===null?Tr=new Set([this]):Tr.add(this));var i=o.stack;this.componentDidCatch(o.value,{componentStack:i!==null?i:""})})}function Y7(e,t,n,o,a){if(n.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=n.alternate,t!==null&&Vl(t,n,a,!0),n=En.current,n!==null){switch(n.tag){case 31:case 13:return Yn===null?zm():n.alternate===null&&Qe===0&&(Qe=3),n.flags&=-257,n.flags|=65536,n.lanes=a,o===Em?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([o]):t.add(o),Fx(e,o,a)),!1;case 22:return n.flags|=65536,o===Em?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([o])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([o]):n.add(o)),Fx(e,o,a)),!1}throw Error(O(435,n.tag))}return Fx(e,o,a),zm(),!1}if(xe)return t=En.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=a,o!==l1&&(e=Error(O(422),{cause:o}),$u(Zn(e,n)))):(o!==l1&&(t=Error(O(423),{cause:o}),$u(Zn(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,o=Zn(o,n),a=v1(e.stateNode,o,a),_x(e,a),Qe!==4&&(Qe=2)),!1;var r=Error(O(520),{cause:o});if(r=Zn(r,n),Wu===null?Wu=[r]:Wu.push(r),Qe!==4&&(Qe=2),t===null)return!0;o=Zn(o,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=v1(n.stateNode,o,e),_x(n,e),!1;case 1:if(t=n.type,r=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||r!==null&&typeof r.componentDidCatch=="function"&&(Tr===null||!Tr.has(r))))return n.flags|=65536,a&=-a,n.lanes|=a,a=$_(a),Q_(a,e,n,o),_x(n,a),!1}n=n.return}while(n!==null);return!1}var vb=Error(O(461)),lt=!1;function Tt(e,t,n,o){t.child=e===null?f_(t,null,n,o):Hs(t,e.child,n,o)}function Ok(e,t,n,o,a){n=n.render;var r=t.ref;if("ref"in o){var s={};for(var i in o)i!=="ref"&&(s[i]=o[i])}else s=o;return Fs(t),o=cb(e,t,n,s,r,a),i=ub(),e!==null&&!lt?(db(e,t,a),Ma(e,t,a)):(xe&&i&&tb(t),t.flags|=1,Tt(e,t,o,a),t.child)}function Dk(e,t,n,o,a){if(e===null){var r=n.type;return typeof r=="function"&&!eb(r)&&r.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=r,J_(e,t,r,o,a)):(e=lm(n.type,null,o,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(r=e.child,!Sb(e,a)){var s=r.memoizedProps;if(n=n.compare,n=n!==null?n:Yu,n(s,o)&&e.ref===t.ref)return Ma(e,t,a)}return t.flags|=1,e=wa(r,o),e.ref=t.ref,e.return=t,t.child=e}function J_(e,t,n,o,a){if(e!==null){var r=e.memoizedProps;if(Yu(r,o)&&e.ref===t.ref)if(lt=!1,t.pendingProps=o=r,Sb(e,a))(e.flags&131072)!==0&&(lt=!0);else return t.lanes=e.lanes,Ma(e,t,a)}return S1(e,t,n,o,a)}function eC(e,t,n,o){var a=o.children,r=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((t.flags&128)!==0){if(r=r!==null?r.baseLanes|n:n,e!==null){for(o=t.child=e.child,a=0;o!==null;)a=a|o.lanes|o.childLanes,o=o.sibling;o=a&~r}else o=0,t.child=null;return Pk(e,t,r,n,o)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&cm(t,r!==null?r.cachePool:null),r!==null?Lk(t,r):m1(),m_(t);else return o=t.lanes=536870912,Pk(e,t,r!==null?r.baseLanes|n:n,n,o)}else r!==null?(cm(t,r.cachePool),Lk(t,r),xr(t),t.memoizedState=null):(e!==null&&cm(t,null),m1(),xr(t));return Tt(e,t,a,n),t.child}function Mu(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Pk(e,t,n,o,a){var r=ab();return r=r===null?null:{parent:it._currentValue,pool:r},t.memoizedState={baseLanes:n,cachePool:r},e!==null&&cm(t,null),m1(),m_(t),e!==null&&Vl(e,t,o,!0),t.childLanes=a,null}function fm(e,t){return t=Dm({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Bk(e,t,n){return Hs(t,e.child,null,n),e=fm(t,t.pendingProps),e.flags|=2,An(t),t.memoizedState=null,e}function K7(e,t,n){var o=t.pendingProps,a=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(xe){if(o.mode==="hidden")return e=fm(t,o),t.lanes=536870912,Mu(null,e);if(y1(t),(e=We)?(e=VC(e,Xn),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Dr!==null?{id:Po,overflow:Bo}:null,retryLane:536870912,hydrationErrors:null},n=r_(e),n.return=t,t.child=n,Mt=t,We=null)):e=null,e===null)throw Pr(t);return t.lanes=536870912,null}return fm(t,o)}var r=e.memoizedState;if(r!==null){var s=r.dehydrated;if(y1(t),a)if(t.flags&256)t.flags&=-257,t=Bk(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(O(558));else if(lt||Vl(e,t,n,!1),a=(n&e.childLanes)!==0,lt||a){if(o=De,o!==null&&(s=Mw(o,n),s!==0&&s!==r.retryLane))throw r.retryLane=s,Vs(e,s),on(o,e,s),vb;zm(),t=Bk(e,t,n)}else e=r.treeContext,We=Kn(s.nextSibling),Mt=t,xe=!0,_r=null,Xn=!1,e!==null&&i_(t,e),t=fm(t,o),t.flags|=4096;return t}return e=wa(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function pm(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(O(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function S1(e,t,n,o,a){return Fs(t),n=cb(e,t,n,o,void 0,a),o=ub(),e!==null&&!lt?(db(e,t,a),Ma(e,t,a)):(xe&&o&&tb(t),t.flags|=1,Tt(e,t,n,a),t.child)}function Nk(e,t,n,o,a,r){return Fs(t),t.updateQueue=null,n=g_(t,o,n,a),y_(e),o=ub(),e!==null&&!lt?(db(e,t,r),Ma(e,t,r)):(xe&&o&&tb(t),t.flags|=1,Tt(e,t,n,r),t.child)}function zk(e,t,n,o,a){if(Fs(t),t.stateNode===null){var r=Sl,s=n.contextType;typeof s=="object"&&s!==null&&(r=Rt(s)),r=new n(o,r),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=A1,t.stateNode=r,r._reactInternals=t,r=t.stateNode,r.props=o,r.state=t.memoizedState,r.refs={},sb(t),s=n.contextType,r.context=typeof s=="object"&&s!==null?Rt(s):Sl,r.state=t.memoizedState,s=n.getDerivedStateFromProps,typeof s=="function"&&(Ex(t,n,s,o),r.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(s=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),s!==r.state&&A1.enqueueReplaceState(r,r.state,null),Fu(t,o,r,a),zu(),r.state=t.memoizedState),typeof r.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){r=t.stateNode;var i=t.memoizedProps,l=Gs(n,i);r.props=l;var c=r.context,u=n.contextType;s=Sl,typeof u=="object"&&u!==null&&(s=Rt(u));var d=n.getDerivedStateFromProps;u=typeof d=="function"||typeof r.getSnapshotBeforeUpdate=="function",i=t.pendingProps!==i,u||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(i||c!==s)&&Mk(t,r,o,s),mr=!1;var f=t.memoizedState;r.state=f,Fu(t,o,r,a),zu(),c=t.memoizedState,i||f!==c||mr?(typeof d=="function"&&(Ex(t,n,d,o),c=t.memoizedState),(l=mr||Ik(t,n,l,o,f,c,s))?(u||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount()),typeof r.componentDidMount=="function"&&(t.flags|=4194308)):(typeof r.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=o,t.memoizedState=c),r.props=o,r.state=c,r.context=s,o=l):(typeof r.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{r=t.stateNode,p1(e,t),s=t.memoizedProps,u=Gs(n,s),r.props=u,d=t.pendingProps,f=r.context,c=n.contextType,l=Sl,typeof c=="object"&&c!==null&&(l=Rt(c)),i=n.getDerivedStateFromProps,(c=typeof i=="function"||typeof r.getSnapshotBeforeUpdate=="function")||typeof r.UNSAFE_componentWillReceiveProps!="function"&&typeof r.componentWillReceiveProps!="function"||(s!==d||f!==l)&&Mk(t,r,o,l),mr=!1,f=t.memoizedState,r.state=f,Fu(t,o,r,a),zu();var p=t.memoizedState;s!==d||f!==p||mr||e!==null&&e.dependencies!==null&&Cm(e.dependencies)?(typeof i=="function"&&(Ex(t,n,i,o),p=t.memoizedState),(u=mr||Ik(t,n,u,o,f,p,l)||e!==null&&e.dependencies!==null&&Cm(e.dependencies))?(c||typeof r.UNSAFE_componentWillUpdate!="function"&&typeof r.componentWillUpdate!="function"||(typeof r.componentWillUpdate=="function"&&r.componentWillUpdate(o,p,l),typeof r.UNSAFE_componentWillUpdate=="function"&&r.UNSAFE_componentWillUpdate(o,p,l)),typeof r.componentDidUpdate=="function"&&(t.flags|=4),typeof r.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof r.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=p),r.props=o,r.state=p,r.context=l,o=u):(typeof r.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof r.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),o=!1)}return r=o,pm(e,t),o=(t.flags&128)!==0,r||o?(r=t.stateNode,n=o&&typeof n.getDerivedStateFromError!="function"?null:r.render(),t.flags|=1,e!==null&&o?(t.child=Hs(t,e.child,null,a),t.child=Hs(t,null,n,a)):Tt(e,t,n,a),t.memoizedState=r.state,e=t.child):e=Ma(e,t,a),e}function Fk(e,t,n,o){return zs(),t.flags|=256,Tt(e,t,n,o),t.child}var Tx={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ix(e){return{baseLanes:e,cachePool:c_()}}function Mx(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Sn),e}function tC(e,t,n){var o=t.pendingProps,a=!1,r=(t.flags&128)!==0,s;if((s=r)||(s=e!==null&&e.memoizedState===null?!1:(tt.current&2)!==0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!==0,t.flags&=-33,e===null){if(xe){if(a?gr(t):xr(t),(e=We)?(e=VC(e,Xn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Dr!==null?{id:Po,overflow:Bo}:null,retryLane:536870912,hydrationErrors:null},n=r_(e),n.return=t,t.child=n,Mt=t,We=null)):e=null,e===null)throw Pr(t);return B1(e)?t.lanes=32:t.lanes=536870912,null}var i=o.children;return o=o.fallback,a?(xr(t),a=t.mode,i=Dm({mode:"hidden",children:i},a),o=Ds(o,a,n,null),i.return=t,o.return=t,i.sibling=o,t.child=i,o=t.child,o.memoizedState=Ix(n),o.childLanes=Mx(e,s,n),t.memoizedState=Tx,Mu(null,o)):(gr(t),L1(t,i))}var l=e.memoizedState;if(l!==null&&(i=l.dehydrated,i!==null)){if(r)t.flags&256?(gr(t),t.flags&=-257,t=Rx(e,t,n)):t.memoizedState!==null?(xr(t),t.child=e.child,t.flags|=128,t=null):(xr(t),i=o.fallback,a=t.mode,o=Dm({mode:"visible",children:o.children},a),i=Ds(i,a,n,null),i.flags|=2,o.return=t,i.return=t,o.sibling=i,t.child=o,Hs(t,e.child,null,n),o=t.child,o.memoizedState=Ix(n),o.childLanes=Mx(e,s,n),t.memoizedState=Tx,t=Mu(null,o));else if(gr(t),B1(i)){if(s=i.nextSibling&&i.nextSibling.dataset,s)var c=s.dgst;s=c,o=Error(O(419)),o.stack="",o.digest=s,$u({value:o,source:null,stack:null}),t=Rx(e,t,n)}else if(lt||Vl(e,t,n,!1),s=(n&e.childLanes)!==0,lt||s){if(s=De,s!==null&&(o=Mw(s,n),o!==0&&o!==l.retryLane))throw l.retryLane=o,Vs(e,o),on(s,e,o),vb;P1(i)||zm(),t=Rx(e,t,n)}else P1(i)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,We=Kn(i.nextSibling),Mt=t,xe=!0,_r=null,Xn=!1,e!==null&&i_(t,e),t=L1(t,o.children),t.flags|=4096);return t}return a?(xr(t),i=o.fallback,a=t.mode,l=e.child,c=l.sibling,o=wa(l,{mode:"hidden",children:o.children}),o.subtreeFlags=l.subtreeFlags&65011712,c!==null?i=wa(c,i):(i=Ds(i,a,n,null),i.flags|=2),i.return=t,o.return=t,o.sibling=i,t.child=o,Mu(null,o),o=t.child,i=e.child.memoizedState,i===null?i=Ix(n):(a=i.cachePool,a!==null?(l=it._currentValue,a=a.parent!==l?{parent:l,pool:l}:a):a=c_(),i={baseLanes:i.baseLanes|n,cachePool:a}),o.memoizedState=i,o.childLanes=Mx(e,s,n),t.memoizedState=Tx,Mu(e.child,o)):(gr(t),n=e.child,e=n.sibling,n=wa(n,{mode:"visible",children:o.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function L1(e,t){return t=Dm({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Dm(e,t){return e=vn(22,e,null,t),e.lanes=0,e}function Rx(e,t,n){return Hs(t,e.child,null,n),e=L1(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Hk(e,t,n){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),u1(e.return,t,n)}function Ox(e,t,n,o,a,r){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:o,tail:n,tailMode:a,treeForkCount:r}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=o,s.tail=n,s.tailMode=a,s.treeForkCount=r)}function nC(e,t,n){var o=t.pendingProps,a=o.revealOrder,r=o.tail;o=o.children;var s=tt.current,i=(s&2)!==0;if(i?(s=s&1|2,t.flags|=128):s&=1,Ne(tt,s),Tt(e,t,o,n),o=xe?Ku:0,!i&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Hk(e,n,t);else if(e.tag===19)Hk(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(a){case"forwards":for(n=t.child,a=null;n!==null;)e=n.alternate,e!==null&&Im(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Ox(t,!1,a,n,r,o);break;case"backwards":case"unstable_legacy-backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&Im(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Ox(t,!0,n,null,r,o);break;case"together":Ox(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function Ma(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Nr|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Vl(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(O(153));if(t.child!==null){for(e=t.child,n=wa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=wa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Sb(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Cm(e)))}function $7(e,t,n){switch(t.tag){case 3:Am(t,t.stateNode.containerInfo),yr(t,it,e.memoizedState.cache),zs();break;case 27:case 5:$x(t);break;case 4:Am(t,t.stateNode.containerInfo);break;case 10:yr(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,y1(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(gr(t),t.flags|=128,null):(n&t.child.childLanes)!==0?tC(e,t,n):(gr(t),e=Ma(e,t,n),e!==null?e.sibling:null);gr(t);break;case 19:var a=(e.flags&128)!==0;if(o=(n&t.childLanes)!==0,o||(Vl(e,t,n,!1),o=(n&t.childLanes)!==0),a){if(o)return nC(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),Ne(tt,tt.current),o)break;return null;case 22:return t.lanes=0,eC(e,t,n,t.pendingProps);case 24:yr(t,it,e.memoizedState.cache)}return Ma(e,t,n)}function oC(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)lt=!0;else{if(!Sb(e,n)&&(t.flags&128)===0)return lt=!1,$7(e,t,n);lt=(e.flags&131072)!==0}else lt=!1,xe&&(t.flags&1048576)!==0&&s_(t,Ku,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=Ms(t.elementType),t.type=e,typeof e=="function")eb(e)?(o=Gs(e,o),t.tag=1,t=zk(null,t,e,o,n)):(t.tag=0,t=S1(null,t,e,o,n));else{if(e!=null){var a=e.$$typeof;if(a===H1){t.tag=11,t=Ok(null,t,e,o,n);break e}else if(a===U1){t.tag=14,t=Dk(null,t,e,o,n);break e}}throw t=Yx(e)||e,Error(O(306,t,""))}}return t;case 0:return S1(e,t,t.type,t.pendingProps,n);case 1:return o=t.type,a=Gs(o,t.pendingProps),zk(e,t,o,a,n);case 3:e:{if(Am(t,t.stateNode.containerInfo),e===null)throw Error(O(387));o=t.pendingProps;var r=t.memoizedState;a=r.element,p1(e,t),Fu(t,o,null,n);var s=t.memoizedState;if(o=s.cache,yr(t,it,o),o!==r.cache&&d1(t,[it],n,!0),zu(),o=s.element,r.isDehydrated)if(r={element:o,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=r,t.memoizedState=r,t.flags&256){t=Fk(e,t,o,n);break e}else if(o!==a){a=Zn(Error(O(424)),t),$u(a),t=Fk(e,t,o,n);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(We=Kn(e.firstChild),Mt=t,xe=!0,_r=null,Xn=!0,n=f_(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(zs(),o===a){t=Ma(e,t,n);break e}Tt(e,t,o,n)}t=t.child}return t;case 26:return pm(e,t),e===null?(n=lw(t.type,null,t.pendingProps,null))?t.memoizedState=n:xe||(n=t.type,e=t.pendingProps,o=Gm(wr.current).createElement(n),o[It]=t,o[an]=e,Ot(o,n,e),Lt(o),t.stateNode=o):t.memoizedState=lw(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return $x(t),e===null&&xe&&(o=t.stateNode=ZC(t.type,t.pendingProps,wr.current),Mt=t,Xn=!0,a=We,Fr(t.type)?(N1=a,We=Kn(o.firstChild)):We=a),Tt(e,t,t.pendingProps.children,n),pm(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&xe&&((a=o=We)&&(o=wB(o,t.type,t.pendingProps,Xn),o!==null?(t.stateNode=o,Mt=t,We=Kn(o.firstChild),Xn=!1,a=!0):a=!1),a||Pr(t)),$x(t),a=t.type,r=t.pendingProps,s=e!==null?e.memoizedProps:null,o=r.children,O1(a,r)?o=null:s!==null&&O1(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=cb(e,t,G7,null,null,n),od._currentValue=a),pm(e,t),Tt(e,t,o,n),t.child;case 6:return e===null&&xe&&((e=n=We)&&(n=_B(n,t.pendingProps,Xn),n!==null?(t.stateNode=n,Mt=t,We=null,e=!0):e=!1),e||Pr(t)),null;case 13:return tC(e,t,n);case 4:return Am(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=Hs(t,null,o,n):Tt(e,t,o,n),t.child;case 11:return Ok(e,t,t.type,t.pendingProps,n);case 7:return Tt(e,t,t.pendingProps,n),t.child;case 8:return Tt(e,t,t.pendingProps.children,n),t.child;case 12:return Tt(e,t,t.pendingProps.children,n),t.child;case 10:return o=t.pendingProps,yr(t,t.type,o.value),Tt(e,t,o.children,n),t.child;case 9:return a=t.type._context,o=t.pendingProps.children,Fs(t),a=Rt(a),o=o(a),t.flags|=1,Tt(e,t,o,n),t.child;case 14:return Dk(e,t,t.type,t.pendingProps,n);case 15:return J_(e,t,t.type,t.pendingProps,n);case 19:return nC(e,t,n);case 31:return K7(e,t,n);case 22:return eC(e,t,n,t.pendingProps);case 24:return Fs(t),o=Rt(it),e===null?(a=ab(),a===null&&(a=De,r=ob(),a.pooledCache=r,r.refCount++,r!==null&&(a.pooledCacheLanes|=n),a=r),t.memoizedState={parent:o,cache:a},sb(t),yr(t,it,a)):((e.lanes&n)!==0&&(p1(e,t),Fu(t,null,null,n),zu()),a=e.memoizedState,r=t.memoizedState,a.parent!==o?(a={parent:o,cache:o},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),yr(t,it,o)):(o=r.cache,yr(t,it,o),o!==a.cache&&d1(t,[it],n,!0))),Tt(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(O(156,t.tag))}function ya(e){e.flags|=4}function Dx(e,t,n,o,a){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(a&335544128)===a)if(e.stateNode.complete)e.flags|=8192;else if(CC())e.flags|=8192;else throw Bs=Em,rb}else e.flags&=-16777217}function Uk(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!KC(t))if(CC())e.flags|=8192;else throw Bs=Em,rb}function $h(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?Ew():536870912,e.lanes|=t,Fl|=t)}function ku(e,t){if(!xe)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var o=null;n!==null;)n.alternate!==null&&(o=n),n=n.sibling;o===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function Ge(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,o=0;if(t)for(var a=e.child;a!==null;)n|=a.lanes|a.childLanes,o|=a.subtreeFlags&65011712,o|=a.flags&65011712,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)n|=a.lanes|a.childLanes,o|=a.subtreeFlags,o|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=o,e.childLanes=n,t}function Q7(e,t,n){var o=t.pendingProps;switch(nb(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ge(t),null;case 1:return Ge(t),null;case 3:return n=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),_a(it),Ol(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ul(t)?ya(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,wx())),Ge(t),null;case 26:var a=t.type,r=t.memoizedState;return e===null?(ya(t),r!==null?(Ge(t),Uk(t,r)):(Ge(t),Dx(t,a,null,o,n))):r?r!==e.memoizedState?(ya(t),Ge(t),Uk(t,r)):(Ge(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&ya(t),Ge(t),Dx(t,a,e,o,n)),null;case 27:if(vm(t),n=wr.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&ya(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Ge(t),null}e=zo.current,ul(t)?yk(t,e):(e=ZC(a,o,n),t.stateNode=e,ya(t))}return Ge(t),null;case 5:if(vm(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&ya(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Ge(t),null}if(r=zo.current,ul(t))yk(t,r);else{var s=Gm(wr.current);switch(r){case 1:r=s.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:r=s.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":r=s.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":r=s.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":r=s.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild);break;case"select":r=typeof o.is=="string"?s.createElement("select",{is:o.is}):s.createElement("select"),o.multiple?r.multiple=!0:o.size&&(r.size=o.size);break;default:r=typeof o.is=="string"?s.createElement(a,{is:o.is}):s.createElement(a)}}r[It]=t,r[an]=o;e:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)r.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break e;for(;s.sibling===null;){if(s.return===null||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=r;e:switch(Ot(r,a,o),a){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&ya(t)}}return Ge(t),Dx(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&ya(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(O(166));if(e=wr.current,ul(t)){if(e=t.stateNode,n=t.memoizedProps,o=null,a=Mt,a!==null)switch(a.tag){case 27:case 5:o=a.memoizedProps}e[It]=t,e=!!(e.nodeValue===n||o!==null&&o.suppressHydrationWarning===!0||WC(e.nodeValue,n)),e||Pr(t,!0)}else e=Gm(e).createTextNode(o),e[It]=t,t.stateNode=e}return Ge(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(o=ul(t),n!==null){if(e===null){if(!o)throw Error(O(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(557));e[It]=t}else zs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ge(t),e=!1}else n=wx(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(An(t),t):(An(t),null);if((t.flags&128)!==0)throw Error(O(558))}return Ge(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ul(t),o!==null&&o.dehydrated!==null){if(e===null){if(!a)throw Error(O(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(O(317));a[It]=t}else zs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ge(t),a=!1}else a=wx(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(An(t),t):(An(t),null)}return An(t),(t.flags&128)!==0?(t.lanes=n,t):(n=o!==null,e=e!==null&&e.memoizedState!==null,n&&(o=t.child,a=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(a=o.alternate.memoizedState.cachePool.pool),r=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(r=o.memoizedState.cachePool.pool),r!==a&&(o.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),$h(t,t.updateQueue),Ge(t),null);case 4:return Ol(),e===null&&Tb(t.stateNode.containerInfo),Ge(t),null;case 10:return _a(t.type),Ge(t),null;case 19:if(kt(tt),o=t.memoizedState,o===null)return Ge(t),null;if(a=(t.flags&128)!==0,r=o.rendering,r===null)if(a)ku(o,!1);else{if(Qe!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(r=Im(e),r!==null){for(t.flags|=128,ku(o,!1),e=r.updateQueue,t.updateQueue=e,$h(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)a_(n,e),n=n.sibling;return Ne(tt,tt.current&1|2),xe&&Aa(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&Ln()>Bm&&(t.flags|=128,a=!0,ku(o,!1),t.lanes=4194304)}else{if(!a)if(e=Im(r),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,$h(t,e),ku(o,!0),o.tail===null&&o.tailMode==="hidden"&&!r.alternate&&!xe)return Ge(t),null}else 2*Ln()-o.renderingStartTime>Bm&&n!==536870912&&(t.flags|=128,a=!0,ku(o,!1),t.lanes=4194304);o.isBackwards?(r.sibling=t.child,t.child=r):(e=o.last,e!==null?e.sibling=r:t.child=r,o.last=r)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Ln(),e.sibling=null,n=tt.current,Ne(tt,a?n&1|2:n&1),xe&&Aa(t,o.treeForkCount),e):(Ge(t),null);case 22:case 23:return An(t),ib(),o=t.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(t.flags|=8192):o&&(t.flags|=8192),o?(n&536870912)!==0&&(t.flags&128)===0&&(Ge(t),t.subtreeFlags&6&&(t.flags|=8192)):Ge(t),n=t.updateQueue,n!==null&&$h(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),o=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),o!==n&&(t.flags|=2048),e!==null&&kt(Ps),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),_a(it),Ge(t),null;case 25:return null;case 30:return null}throw Error(O(156,t.tag))}function J7(e,t){switch(nb(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return _a(it),Ol(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return vm(t),null;case 31:if(t.memoizedState!==null){if(An(t),t.alternate===null)throw Error(O(340));zs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(An(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(O(340));zs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return kt(tt),null;case 4:return Ol(),null;case 10:return _a(t.type),null;case 22:case 23:return An(t),ib(),e!==null&&kt(Ps),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return _a(it),null;case 25:return null;default:return null}}function aC(e,t){switch(nb(t),t.tag){case 3:_a(it),Ol();break;case 26:case 27:case 5:vm(t);break;case 4:Ol();break;case 31:t.memoizedState!==null&&An(t);break;case 13:An(t);break;case 19:kt(tt);break;case 10:_a(t.type);break;case 22:case 23:An(t),ib(),e!==null&&kt(Ps);break;case 24:_a(it)}}function hd(e,t){try{var n=t.updateQueue,o=n!==null?n.lastEffect:null;if(o!==null){var a=o.next;n=a;do{if((n.tag&e)===e){o=void 0;var r=n.create,s=n.inst;o=r(),s.destroy=o}n=n.next}while(n!==a)}}catch(i){Te(t,t.return,i)}}function Br(e,t,n){try{var o=t.updateQueue,a=o!==null?o.lastEffect:null;if(a!==null){var r=a.next;o=r;do{if((o.tag&e)===e){var s=o.inst,i=s.destroy;if(i!==void 0){s.destroy=void 0,a=t;var l=n,c=i;try{c()}catch(u){Te(a,l,u)}}}o=o.next}while(o!==r)}}catch(u){Te(t,t.return,u)}}function rC(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{h_(t,n)}catch(o){Te(e,e.return,o)}}}function sC(e,t,n){n.props=Gs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(o){Te(e,t,o)}}function Uu(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof n=="function"?e.refCleanup=n(o):n.current=o}}catch(a){Te(e,t,a)}}function No(e,t){var n=e.ref,o=e.refCleanup;if(n!==null)if(typeof o=="function")try{o()}catch(a){Te(e,t,a)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(a){Te(e,t,a)}else n.current=null}function iC(e){var t=e.type,n=e.memoizedProps,o=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&o.focus();break e;case"img":n.src?o.src=n.src:n.srcSet&&(o.srcset=n.srcSet)}}catch(a){Te(e,e.return,a)}}function Px(e,t,n){try{var o=e.stateNode;bB(o,e.type,n,t),o[an]=t}catch(a){Te(e,e.return,a)}}function lC(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Fr(e.type)||e.tag===4}function Bx(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||lC(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Fr(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function k1(e,t,n){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=La));else if(o!==4&&(o===27&&Fr(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(k1(e,t,n),e=e.sibling;e!==null;)k1(e,t,n),e=e.sibling}function Pm(e,t,n){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(o!==4&&(o===27&&Fr(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Pm(e,t,n),e=e.sibling;e!==null;)Pm(e,t,n),e=e.sibling}function cC(e){var t=e.stateNode,n=e.memoizedProps;try{for(var o=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);Ot(t,o,n),t[It]=e,t[an]=n}catch(r){Te(e,e.return,r)}}var va=!1,st=!1,Nx=!1,Gk=typeof WeakSet=="function"?WeakSet:Set,St=null;function eB(e,t){if(e=e.containerInfo,M1=Vm,e=Kw(e),$1(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var o=n.getSelection&&n.getSelection();if(o&&o.rangeCount!==0){n=o.anchorNode;var a=o.anchorOffset,r=o.focusNode;o=o.focusOffset;try{n.nodeType,r.nodeType}catch{n=null;break e}var s=0,i=-1,l=-1,c=0,u=0,d=e,f=null;t:for(;;){for(var p;d!==n||a!==0&&d.nodeType!==3||(i=s+a),d!==r||o!==0&&d.nodeType!==3||(l=s+o),d.nodeType===3&&(s+=d.nodeValue.length),(p=d.firstChild)!==null;)f=d,d=p;for(;;){if(d===e)break t;if(f===n&&++c===a&&(i=s),f===r&&++u===o&&(l=s),(p=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=p}n=i===-1||l===-1?null:{start:i,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(R1={focusedElem:e,selectionRange:n},Vm=!1,St=t;St!==null;)if(t=St,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,St=e;else for(;St!==null;){switch(t=St,r=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&r!==null){e=void 0,n=t,a=r.memoizedProps,r=r.memoizedState,o=n.stateNode;try{var h=Gs(n.type,a);e=o.getSnapshotBeforeUpdate(h,r),o.__reactInternalSnapshotBeforeUpdate=e}catch(m){Te(n,n.return,m)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)D1(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":D1(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(O(163))}if(e=t.sibling,e!==null){e.return=t.return,St=e;break}St=t.return}}function uC(e,t,n){var o=n.flags;switch(n.tag){case 0:case 11:case 15:xa(e,n),o&4&&hd(5,n);break;case 1:if(xa(e,n),o&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(s){Te(n,n.return,s)}else{var a=Gs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){Te(n,n.return,s)}}o&64&&rC(n),o&512&&Uu(n,n.return);break;case 3:if(xa(e,n),o&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{h_(e,t)}catch(s){Te(n,n.return,s)}}break;case 27:t===null&&o&4&&cC(n);case 26:case 5:xa(e,n),t===null&&o&4&&iC(n),o&512&&Uu(n,n.return);break;case 12:xa(e,n);break;case 31:xa(e,n),o&4&&pC(e,n);break;case 13:xa(e,n),o&4&&hC(e,n),o&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=cB.bind(null,n),CB(e,n))));break;case 22:if(o=n.memoizedState!==null||va,!o){t=t!==null&&t.memoizedState!==null||st,a=va;var r=st;va=o,(st=t)&&!r?ba(e,n,(n.subtreeFlags&8772)!==0):xa(e,n),va=a,st=r}break;case 30:break;default:xa(e,n)}}function dC(e){var t=e.alternate;t!==null&&(e.alternate=null,dC(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&j1(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Ve=null,tn=!1;function ga(e,t,n){for(n=n.child;n!==null;)fC(e,t,n),n=n.sibling}function fC(e,t,n){if(kn&&typeof kn.onCommitFiberUnmount=="function")try{kn.onCommitFiberUnmount(id,n)}catch{}switch(n.tag){case 26:st||No(n,t),ga(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:st||No(n,t);var o=Ve,a=tn;Fr(n.type)&&(Ve=n.stateNode,tn=!1),ga(e,t,n),ju(n.stateNode),Ve=o,tn=a;break;case 5:st||No(n,t);case 6:if(o=Ve,a=tn,Ve=null,ga(e,t,n),Ve=o,tn=a,Ve!==null)if(tn)try{(Ve.nodeType===9?Ve.body:Ve.nodeName==="HTML"?Ve.ownerDocument.body:Ve).removeChild(n.stateNode)}catch(r){Te(n,t,r)}else try{Ve.removeChild(n.stateNode)}catch(r){Te(n,t,r)}break;case 18:Ve!==null&&(tn?(e=Ve,ow(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Wl(e)):ow(Ve,n.stateNode));break;case 4:o=Ve,a=tn,Ve=n.stateNode.containerInfo,tn=!0,ga(e,t,n),Ve=o,tn=a;break;case 0:case 11:case 14:case 15:Br(2,n,t),st||Br(4,n,t),ga(e,t,n);break;case 1:st||(No(n,t),o=n.stateNode,typeof o.componentWillUnmount=="function"&&sC(n,t,o)),ga(e,t,n);break;case 21:ga(e,t,n);break;case 22:st=(o=st)||n.memoizedState!==null,ga(e,t,n),st=o;break;default:ga(e,t,n)}}function pC(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Wl(e)}catch(n){Te(t,t.return,n)}}}function hC(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Wl(e)}catch(n){Te(t,t.return,n)}}function tB(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Gk),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Gk),t;default:throw Error(O(435,e.tag))}}function Qh(e,t){var n=tB(e);t.forEach(function(o){if(!n.has(o)){n.add(o);var a=uB.bind(null,e,o);o.then(a,a)}})}function Jt(e,t){var n=t.deletions;if(n!==null)for(var o=0;o<n.length;o++){var a=n[o],r=e,s=t,i=s;e:for(;i!==null;){switch(i.tag){case 27:if(Fr(i.type)){Ve=i.stateNode,tn=!1;break e}break;case 5:Ve=i.stateNode,tn=!1;break e;case 3:case 4:Ve=i.stateNode.containerInfo,tn=!0;break e}i=i.return}if(Ve===null)throw Error(O(160));fC(r,s,a),Ve=null,tn=!1,r=a.alternate,r!==null&&(r.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)mC(t,e),t=t.sibling}var yo=null;function mC(e,t){var n=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Jt(t,e),en(e),o&4&&(Br(3,e,e.return),hd(3,e),Br(5,e,e.return));break;case 1:Jt(t,e),en(e),o&512&&(st||n===null||No(n,n.return)),o&64&&va&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?o:n.concat(o))));break;case 26:var a=yo;if(Jt(t,e),en(e),o&512&&(st||n===null||No(n,n.return)),o&4){var r=n!==null?n.memoizedState:null;if(o=e.memoizedState,n===null)if(o===null)if(e.stateNode===null){e:{o=e.type,n=e.memoizedProps,a=a.ownerDocument||a;t:switch(o){case"title":r=a.getElementsByTagName("title")[0],(!r||r[ud]||r[It]||r.namespaceURI==="http://www.w3.org/2000/svg"||r.hasAttribute("itemprop"))&&(r=a.createElement(o),a.head.insertBefore(r,a.querySelector("head > title"))),Ot(r,o,n),r[It]=e,Lt(r),o=r;break e;case"link":var s=uw("link","href",a).get(o+(n.href||""));if(s){for(var i=0;i<s.length;i++)if(r=s[i],r.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&r.getAttribute("rel")===(n.rel==null?null:n.rel)&&r.getAttribute("title")===(n.title==null?null:n.title)&&r.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(i,1);break t}}r=a.createElement(o),Ot(r,o,n),a.head.appendChild(r);break;case"meta":if(s=uw("meta","content",a).get(o+(n.content||""))){for(i=0;i<s.length;i++)if(r=s[i],r.getAttribute("content")===(n.content==null?null:""+n.content)&&r.getAttribute("name")===(n.name==null?null:n.name)&&r.getAttribute("property")===(n.property==null?null:n.property)&&r.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute("charset")===(n.charSet==null?null:n.charSet)){s.splice(i,1);break t}}r=a.createElement(o),Ot(r,o,n),a.head.appendChild(r);break;default:throw Error(O(468,o))}r[It]=e,Lt(r),o=r}e.stateNode=o}else dw(a,e.type,e.stateNode);else e.stateNode=cw(a,o,e.memoizedProps);else r!==o?(r===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):r.count--,o===null?dw(a,e.type,e.stateNode):cw(a,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Px(e,e.memoizedProps,n.memoizedProps)}break;case 27:Jt(t,e),en(e),o&512&&(st||n===null||No(n,n.return)),n!==null&&o&4&&Px(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Jt(t,e),en(e),o&512&&(st||n===null||No(n,n.return)),e.flags&32){a=e.stateNode;try{Pl(a,"")}catch(h){Te(e,e.return,h)}}o&4&&e.stateNode!=null&&(a=e.memoizedProps,Px(e,a,n!==null?n.memoizedProps:a)),o&1024&&(Nx=!0);break;case 6:if(Jt(t,e),en(e),o&4){if(e.stateNode===null)throw Error(O(162));o=e.memoizedProps,n=e.stateNode;try{n.nodeValue=o}catch(h){Te(e,e.return,h)}}break;case 3:if(ym=null,a=yo,yo=Wm(t.containerInfo),Jt(t,e),yo=a,en(e),o&4&&n!==null&&n.memoizedState.isDehydrated)try{Wl(t.containerInfo)}catch(h){Te(e,e.return,h)}Nx&&(Nx=!1,yC(e));break;case 4:o=yo,yo=Wm(e.stateNode.containerInfo),Jt(t,e),en(e),yo=o;break;case 12:Jt(t,e),en(e);break;case 31:Jt(t,e),en(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Qh(e,o)));break;case 13:Jt(t,e),en(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(r0=Ln()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Qh(e,o)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,c=va,u=st;if(va=c||a,st=u||l,Jt(t,e),st=u,va=c,en(e),o&8192)e:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||va||st||Rs(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(r=l.stateNode,a)s=r.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none";else{i=l.stateNode;var d=l.memoizedProps.style,f=d!=null&&d.hasOwnProperty("display")?d.display:null;i.style.display=f==null||typeof f=="boolean"?"":(""+f).trim()}}catch(h){Te(l,l.return,h)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?"":l.memoizedProps}catch(h){Te(l,l.return,h)}}}else if(t.tag===18){if(n===null){l=t;try{var p=l.stateNode;a?aw(p,!0):aw(l.stateNode,!1)}catch(h){Te(l,l.return,h)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}o&4&&(o=e.updateQueue,o!==null&&(n=o.retryQueue,n!==null&&(o.retryQueue=null,Qh(e,n))));break;case 19:Jt(t,e),en(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Qh(e,o)));break;case 30:break;case 21:break;default:Jt(t,e),en(e)}}function en(e){var t=e.flags;if(t&2){try{for(var n,o=e.return;o!==null;){if(lC(o)){n=o;break}o=o.return}if(n==null)throw Error(O(160));switch(n.tag){case 27:var a=n.stateNode,r=Bx(e);Pm(e,r,a);break;case 5:var s=n.stateNode;n.flags&32&&(Pl(s,""),n.flags&=-33);var i=Bx(e);Pm(e,i,s);break;case 3:case 4:var l=n.stateNode.containerInfo,c=Bx(e);k1(e,c,l);break;default:throw Error(O(161))}}catch(u){Te(e,e.return,u)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function yC(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;yC(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function xa(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)uC(e,t.alternate,t),t=t.sibling}function Rs(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Br(4,t,t.return),Rs(t);break;case 1:No(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&sC(t,t.return,n),Rs(t);break;case 27:ju(t.stateNode);case 26:case 5:No(t,t.return),Rs(t);break;case 22:t.memoizedState===null&&Rs(t);break;case 30:Rs(t);break;default:Rs(t)}e=e.sibling}}function ba(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var o=t.alternate,a=e,r=t,s=r.flags;switch(r.tag){case 0:case 11:case 15:ba(a,r,n),hd(4,r);break;case 1:if(ba(a,r,n),o=r,a=o.stateNode,typeof a.componentDidMount=="function")try{a.componentDidMount()}catch(c){Te(o,o.return,c)}if(o=r,a=o.updateQueue,a!==null){var i=o.stateNode;try{var l=a.shared.hiddenCallbacks;if(l!==null)for(a.shared.hiddenCallbacks=null,a=0;a<l.length;a++)p_(l[a],i)}catch(c){Te(o,o.return,c)}}n&&s&64&&rC(r),Uu(r,r.return);break;case 27:cC(r);case 26:case 5:ba(a,r,n),n&&o===null&&s&4&&iC(r),Uu(r,r.return);break;case 12:ba(a,r,n);break;case 31:ba(a,r,n),n&&s&4&&pC(a,r);break;case 13:ba(a,r,n),n&&s&4&&hC(a,r);break;case 22:r.memoizedState===null&&ba(a,r,n),Uu(r,r.return);break;case 30:break;default:ba(a,r,n)}t=t.sibling}}function Lb(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&fd(n))}function kb(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&fd(e))}function mo(e,t,n,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)gC(e,t,n,o),t=t.sibling}function gC(e,t,n,o){var a=t.flags;switch(t.tag){case 0:case 11:case 15:mo(e,t,n,o),a&2048&&hd(9,t);break;case 1:mo(e,t,n,o);break;case 3:mo(e,t,n,o),a&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&fd(e)));break;case 12:if(a&2048){mo(e,t,n,o),e=t.stateNode;try{var r=t.memoizedProps,s=r.id,i=r.onPostCommit;typeof i=="function"&&i(s,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(l){Te(t,t.return,l)}}else mo(e,t,n,o);break;case 31:mo(e,t,n,o);break;case 13:mo(e,t,n,o);break;case 23:break;case 22:r=t.stateNode,s=t.alternate,t.memoizedState!==null?r._visibility&2?mo(e,t,n,o):Gu(e,t):r._visibility&2?mo(e,t,n,o):(r._visibility|=2,fl(e,t,n,o,(t.subtreeFlags&10256)!==0||!1)),a&2048&&Lb(s,t);break;case 24:mo(e,t,n,o),a&2048&&kb(t.alternate,t);break;default:mo(e,t,n,o)}}function fl(e,t,n,o,a){for(a=a&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var r=e,s=t,i=n,l=o,c=s.flags;switch(s.tag){case 0:case 11:case 15:fl(r,s,i,l,a),hd(8,s);break;case 23:break;case 22:var u=s.stateNode;s.memoizedState!==null?u._visibility&2?fl(r,s,i,l,a):Gu(r,s):(u._visibility|=2,fl(r,s,i,l,a)),a&&c&2048&&Lb(s.alternate,s);break;case 24:fl(r,s,i,l,a),a&&c&2048&&kb(s.alternate,s);break;default:fl(r,s,i,l,a)}t=t.sibling}}function Gu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,o=t,a=o.flags;switch(o.tag){case 22:Gu(n,o),a&2048&&Lb(o.alternate,o);break;case 24:Gu(n,o),a&2048&&kb(o.alternate,o);break;default:Gu(n,o)}t=t.sibling}}var Ru=8192;function dl(e,t,n){if(e.subtreeFlags&Ru)for(e=e.child;e!==null;)xC(e,t,n),e=e.sibling}function xC(e,t,n){switch(e.tag){case 26:dl(e,t,n),e.flags&Ru&&e.memoizedState!==null&&FB(n,yo,e.memoizedState,e.memoizedProps);break;case 5:dl(e,t,n);break;case 3:case 4:var o=yo;yo=Wm(e.stateNode.containerInfo),dl(e,t,n),yo=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=Ru,Ru=16777216,dl(e,t,n),Ru=o):dl(e,t,n));break;default:dl(e,t,n)}}function bC(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function wu(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var o=t[n];St=o,vC(o,e)}bC(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)AC(e),e=e.sibling}function AC(e){switch(e.tag){case 0:case 11:case 15:wu(e),e.flags&2048&&Br(9,e,e.return);break;case 3:wu(e);break;case 12:wu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,hm(e)):wu(e);break;default:wu(e)}}function hm(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var o=t[n];St=o,vC(o,e)}bC(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Br(8,t,t.return),hm(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,hm(t));break;default:hm(t)}e=e.sibling}}function vC(e,t){for(;St!==null;){var n=St;switch(n.tag){case 0:case 11:case 15:Br(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var o=n.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:fd(n.memoizedState.cache)}if(o=n.child,o!==null)o.return=n,St=o;else e:for(n=e;St!==null;){o=St;var a=o.sibling,r=o.return;if(dC(o),o===n){St=null;break e}if(a!==null){a.return=r,St=a;break e}St=r}}}var nB={getCacheForType:function(e){var t=Rt(it),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Rt(it).controller.signal}},oB=typeof WeakMap=="function"?WeakMap:Map,ke=0,De=null,de=null,he=0,Ee=0,bn=null,Sr=!1,Xl=!1,wb=!1,Ra=0,Qe=0,Nr=0,Ns=0,_b=0,Sn=0,Fl=0,Wu=null,nn=null,w1=!1,r0=0,SC=0,Bm=1/0,Nm=null,Tr=null,pt=0,Ir=null,Hl=null,Ca=0,_1=0,C1=null,LC=null,qu=0,E1=null;function _n(){return(ke&2)!==0&&he!==0?he&-he:K.T!==null?Eb():Rw()}function kC(){if(Sn===0)if((he&536870912)===0||xe){var e=Gh;Gh<<=1,(Gh&3932160)===0&&(Gh=262144),Sn=e}else Sn=536870912;return e=En.current,e!==null&&(e.flags|=32),Sn}function on(e,t,n){(e===De&&(Ee===2||Ee===9)||e.cancelPendingCommit!==null)&&(Ul(e,0),Lr(e,he,Sn,!1)),cd(e,n),((ke&2)===0||e!==De)&&(e===De&&((ke&2)===0&&(Ns|=n),Qe===4&&Lr(e,he,Sn,!1)),Ho(e))}function wC(e,t,n){if((ke&6)!==0)throw Error(O(327));var o=!n&&(t&127)===0&&(t&e.expiredLanes)===0||ld(e,t),a=o?sB(e,t):zx(e,t,!0),r=o;do{if(a===0){Xl&&!o&&Lr(e,t,0,!1);break}else{if(n=e.current.alternate,r&&!aB(n)){a=zx(e,t,!1),r=!1;continue}if(a===2){if(r=t,e.errorRecoveryDisabledLanes&r)var s=0;else s=e.pendingLanes&-536870913,s=s!==0?s:s&536870912?536870912:0;if(s!==0){t=s;e:{var i=e;a=Wu;var l=i.current.memoizedState.isDehydrated;if(l&&(Ul(i,s).flags|=256),s=zx(i,s,!1),s!==2){if(wb&&!l){i.errorRecoveryDisabledLanes|=r,Ns|=r,a=4;break e}r=nn,nn=a,r!==null&&(nn===null?nn=r:nn.push.apply(nn,r))}a=s}if(r=!1,a!==2)continue}}if(a===1){Ul(e,0),Lr(e,t,0,!0);break}e:{switch(o=e,r=a,r){case 0:case 1:throw Error(O(345));case 4:if((t&4194048)!==t)break;case 6:Lr(o,t,Sn,!Sr);break e;case 2:nn=null;break;case 3:case 5:break;default:throw Error(O(329))}if((t&62914560)===t&&(a=r0+300-Ln(),10<a)){if(Lr(o,t,Sn,!Sr),Xm(o,0,!0)!==0)break e;Ca=t,o.timeoutHandle=jC(Wk.bind(null,o,n,nn,Nm,w1,t,Sn,Ns,Fl,Sr,r,"Throttled",-0,0),a);break e}Wk(o,n,nn,Nm,w1,t,Sn,Ns,Fl,Sr,r,null,-0,0)}}break}while(!0);Ho(e)}function Wk(e,t,n,o,a,r,s,i,l,c,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)===16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:La},xC(t,r,d);var h=(r&62914560)===r?r0-Ln():(r&4194048)===r?SC-Ln():0;if(h=HB(d,h),h!==null){Ca=r,e.cancelPendingCommit=h(jk.bind(null,e,t,r,n,o,a,s,i,l,u,d,null,f,p)),Lr(e,r,s,!c);return}}jk(e,t,r,n,o,a,s,i,l)}function aB(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var o=0;o<n.length;o++){var a=n[o],r=a.getSnapshot;a=a.value;try{if(!Cn(r(),a))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Lr(e,t,n,o){t&=~_b,t&=~Ns,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var a=t;0<a;){var r=31-wn(a),s=1<<r;o[r]=-1,a&=~s}n!==0&&Tw(e,n,t)}function s0(){return(ke&6)===0?(md(0,!1),!1):!0}function Cb(){if(de!==null){if(Ee===0)var e=de.return;else e=de,ka=Zs=null,fb(e),Il=null,Qu=0,e=de;for(;e!==null;)aC(e.alternate,e),e=e.return;de=null}}function Ul(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,SB(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Ca=0,Cb(),De=e,de=n=wa(e.current,null),he=t,Ee=0,bn=null,Sr=!1,Xl=ld(e,t),wb=!1,Fl=Sn=_b=Ns=Nr=Qe=0,nn=Wu=null,w1=!1,(t&8)!==0&&(t|=t&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=t;0<o;){var a=31-wn(o),r=1<<a;t|=e[a],o&=~r}return Ra=t,Qm(),n}function _C(e,t){oe=null,K.H=ed,t===Zl||t===e0?(t=vk(),Ee=3):t===rb?(t=vk(),Ee=4):Ee=t===vb?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,bn=t,de===null&&(Qe=1,Om(e,Zn(t,e.current)))}function CC(){var e=En.current;return e===null?!0:(he&4194048)===he?Yn===null:(he&62914560)===he||(he&536870912)!==0?e===Yn:!1}function EC(){var e=K.H;return K.H=ed,e===null?ed:e}function TC(){var e=K.A;return K.A=nB,e}function zm(){Qe=4,Sr||(he&4194048)!==he&&En.current!==null||(Xl=!0),(Nr&134217727)===0&&(Ns&134217727)===0||De===null||Lr(De,he,Sn,!1)}function zx(e,t,n){var o=ke;ke|=2;var a=EC(),r=TC();(De!==e||he!==t)&&(Nm=null,Ul(e,t)),t=!1;var s=Qe;e:do try{if(Ee!==0&&de!==null){var i=de,l=bn;switch(Ee){case 8:Cb(),s=6;break e;case 3:case 2:case 9:case 6:En.current===null&&(t=!0);var c=Ee;if(Ee=0,bn=null,wl(e,i,l,c),n&&Xl){s=0;break e}break;default:c=Ee,Ee=0,bn=null,wl(e,i,l,c)}}rB(),s=Qe;break}catch(u){_C(e,u)}while(!0);return t&&e.shellSuspendCounter++,ka=Zs=null,ke=o,K.H=a,K.A=r,de===null&&(De=null,he=0,Qm()),s}function rB(){for(;de!==null;)IC(de)}function sB(e,t){var n=ke;ke|=2;var o=EC(),a=TC();De!==e||he!==t?(Nm=null,Bm=Ln()+500,Ul(e,t)):Xl=ld(e,t);e:do try{if(Ee!==0&&de!==null){t=de;var r=bn;t:switch(Ee){case 1:Ee=0,bn=null,wl(e,t,r,1);break;case 2:case 9:if(Ak(r)){Ee=0,bn=null,qk(t);break}t=function(){Ee!==2&&Ee!==9||De!==e||(Ee=7),Ho(e)},r.then(t,t);break e;case 3:Ee=7;break e;case 4:Ee=5;break e;case 7:Ak(r)?(Ee=0,bn=null,qk(t)):(Ee=0,bn=null,wl(e,t,r,7));break;case 5:var s=null;switch(de.tag){case 26:s=de.memoizedState;case 5:case 27:var i=de;if(s?KC(s):i.stateNode.complete){Ee=0,bn=null;var l=i.sibling;if(l!==null)de=l;else{var c=i.return;c!==null?(de=c,i0(c)):de=null}break t}}Ee=0,bn=null,wl(e,t,r,5);break;case 6:Ee=0,bn=null,wl(e,t,r,6);break;case 8:Cb(),Qe=6;break e;default:throw Error(O(462))}}iB();break}catch(u){_C(e,u)}while(!0);return ka=Zs=null,K.H=o,K.A=a,ke=n,de!==null?0:(De=null,he=0,Qm(),Qe)}function iB(){for(;de!==null&&!IP();)IC(de)}function IC(e){var t=oC(e.alternate,e,Ra);e.memoizedProps=e.pendingProps,t===null?i0(e):de=t}function qk(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Nk(n,t,t.pendingProps,t.type,void 0,he);break;case 11:t=Nk(n,t,t.pendingProps,t.type.render,t.ref,he);break;case 5:fb(t);default:aC(n,t),t=de=a_(t,Ra),t=oC(n,t,Ra)}e.memoizedProps=e.pendingProps,t===null?i0(e):de=t}function wl(e,t,n,o){ka=Zs=null,fb(t),Il=null,Qu=0;var a=t.return;try{if(Y7(e,a,t,n,he)){Qe=1,Om(e,Zn(n,e.current)),de=null;return}}catch(r){if(a!==null)throw de=a,r;Qe=1,Om(e,Zn(n,e.current)),de=null;return}t.flags&32768?(xe||o===1?e=!0:Xl||(he&536870912)!==0?e=!1:(Sr=e=!0,(o===2||o===9||o===3||o===6)&&(o=En.current,o!==null&&o.tag===13&&(o.flags|=16384))),MC(t,e)):i0(t)}function i0(e){var t=e;do{if((t.flags&32768)!==0){MC(t,Sr);return}e=t.return;var n=Q7(t.alternate,t,Ra);if(n!==null){de=n;return}if(t=t.sibling,t!==null){de=t;return}de=t=e}while(t!==null);Qe===0&&(Qe=5)}function MC(e,t){do{var n=J7(e.alternate,e);if(n!==null){n.flags&=32767,de=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){de=e;return}de=e=n}while(e!==null);Qe=6,de=null}function jk(e,t,n,o,a,r,s,i,l){e.cancelPendingCommit=null;do l0();while(pt!==0);if((ke&6)!==0)throw Error(O(327));if(t!==null){if(t===e.current)throw Error(O(177));if(r=t.lanes|t.childLanes,r|=Q1,HP(e,n,r,s,i,l),e===De&&(de=De=null,he=0),Hl=t,Ir=e,Ca=n,_1=r,C1=a,LC=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,dB(Sm,function(){return BC(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=K.T,K.T=null,a=we.p,we.p=2,s=ke,ke|=4;try{eB(e,t,n)}finally{ke=s,we.p=a,K.T=o}}pt=1,RC(),OC(),DC()}}function RC(){if(pt===1){pt=0;var e=Ir,t=Hl,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=K.T,K.T=null;var o=we.p;we.p=2;var a=ke;ke|=4;try{mC(t,e);var r=R1,s=Kw(e.containerInfo),i=r.focusedElem,l=r.selectionRange;if(s!==i&&i&&i.ownerDocument&&Yw(i.ownerDocument.documentElement,i)){if(l!==null&&$1(i)){var c=l.start,u=l.end;if(u===void 0&&(u=c),"selectionStart"in i)i.selectionStart=c,i.selectionEnd=Math.min(u,i.value.length);else{var d=i.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),h=i.textContent.length,m=Math.min(l.start,h),x=l.end===void 0?m:Math.min(l.end,h);!p.extend&&m>x&&(s=x,x=m,m=s);var y=pk(i,m),g=pk(i,x);if(y&&g&&(p.rangeCount!==1||p.anchorNode!==y.node||p.anchorOffset!==y.offset||p.focusNode!==g.node||p.focusOffset!==g.offset)){var b=d.createRange();b.setStart(y.node,y.offset),p.removeAllRanges(),m>x?(p.addRange(b),p.extend(g.node,g.offset)):(b.setEnd(g.node,g.offset),p.addRange(b))}}}}for(d=[],p=i;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<d.length;i++){var A=d[i];A.element.scrollLeft=A.left,A.element.scrollTop=A.top}}Vm=!!M1,R1=M1=null}finally{ke=a,we.p=o,K.T=n}}e.current=t,pt=2}}function OC(){if(pt===2){pt=0;var e=Ir,t=Hl,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=K.T,K.T=null;var o=we.p;we.p=2;var a=ke;ke|=4;try{uC(e,t.alternate,t)}finally{ke=a,we.p=o,K.T=n}}pt=3}}function DC(){if(pt===4||pt===3){pt=0,MP();var e=Ir,t=Hl,n=Ca,o=LC;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?pt=5:(pt=0,Hl=Ir=null,PC(e,e.pendingLanes));var a=e.pendingLanes;if(a===0&&(Tr=null),q1(n),t=t.stateNode,kn&&typeof kn.onCommitFiberRoot=="function")try{kn.onCommitFiberRoot(id,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=K.T,a=we.p,we.p=2,K.T=null;try{for(var r=e.onRecoverableError,s=0;s<o.length;s++){var i=o[s];r(i.value,{componentStack:i.stack})}}finally{K.T=t,we.p=a}}(Ca&3)!==0&&l0(),Ho(e),a=e.pendingLanes,(n&261930)!==0&&(a&42)!==0?e===E1?qu++:(qu=0,E1=e):qu=0,md(0,!1)}}function PC(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,fd(t)))}function l0(){return RC(),OC(),DC(),BC()}function BC(){if(pt!==5)return!1;var e=Ir,t=_1;_1=0;var n=q1(Ca),o=K.T,a=we.p;try{we.p=32>n?32:n,K.T=null,n=C1,C1=null;var r=Ir,s=Ca;if(pt=0,Hl=Ir=null,Ca=0,(ke&6)!==0)throw Error(O(331));var i=ke;if(ke|=4,AC(r.current),gC(r,r.current,s,n),ke=i,md(0,!1),kn&&typeof kn.onPostCommitFiberRoot=="function")try{kn.onPostCommitFiberRoot(id,r)}catch{}return!0}finally{we.p=a,K.T=o,PC(e,t)}}function Vk(e,t,n){t=Zn(n,t),t=v1(e.stateNode,t,2),e=Er(e,t,2),e!==null&&(cd(e,2),Ho(e))}function Te(e,t,n){if(e.tag===3)Vk(e,e,n);else for(;t!==null;){if(t.tag===3){Vk(t,e,n);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Tr===null||!Tr.has(o))){e=Zn(n,e),n=$_(2),o=Er(t,n,2),o!==null&&(Q_(n,o,t,e),cd(o,2),Ho(o));break}}t=t.return}}function Fx(e,t,n){var o=e.pingCache;if(o===null){o=e.pingCache=new oB;var a=new Set;o.set(t,a)}else a=o.get(t),a===void 0&&(a=new Set,o.set(t,a));a.has(n)||(wb=!0,a.add(n),e=lB.bind(null,e,t,n),t.then(e,e))}function lB(e,t,n){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,De===e&&(he&n)===n&&(Qe===4||Qe===3&&(he&62914560)===he&&300>Ln()-r0?(ke&2)===0&&Ul(e,0):_b|=n,Fl===he&&(Fl=0)),Ho(e)}function NC(e,t){t===0&&(t=Ew()),e=Vs(e,t),e!==null&&(cd(e,t),Ho(e))}function cB(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),NC(e,n)}function uB(e,t){var n=0;switch(e.tag){case 31:case 13:var o=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(O(314))}o!==null&&o.delete(t),NC(e,n)}function dB(e,t){return G1(e,t)}var Fm=null,pl=null,T1=!1,Hm=!1,Hx=!1,kr=0;function Ho(e){e!==pl&&e.next===null&&(pl===null?Fm=pl=e:pl=pl.next=e),Hm=!0,T1||(T1=!0,pB())}function md(e,t){if(!Hx&&Hm){Hx=!0;do for(var n=!1,o=Fm;o!==null;){if(!t)if(e!==0){var a=o.pendingLanes;if(a===0)var r=0;else{var s=o.suspendedLanes,i=o.pingedLanes;r=(1<<31-wn(42|e)+1)-1,r&=a&~(s&~i),r=r&201326741?r&201326741|1:r?r|2:0}r!==0&&(n=!0,Zk(o,r))}else r=he,r=Xm(o,o===De?r:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(r&3)===0||ld(o,r)||(n=!0,Zk(o,r));o=o.next}while(n);Hx=!1}}function fB(){zC()}function zC(){Hm=T1=!1;var e=0;kr!==0&&vB()&&(e=kr);for(var t=Ln(),n=null,o=Fm;o!==null;){var a=o.next,r=FC(o,t);r===0?(o.next=null,n===null?Fm=a:n.next=a,a===null&&(pl=n)):(n=o,(e!==0||(r&3)!==0)&&(Hm=!0)),o=a}pt!==0&&pt!==5||md(e,!1),kr!==0&&(kr=0)}function FC(e,t){for(var n=e.suspendedLanes,o=e.pingedLanes,a=e.expirationTimes,r=e.pendingLanes&-62914561;0<r;){var s=31-wn(r),i=1<<s,l=a[s];l===-1?((i&n)===0||(i&o)!==0)&&(a[s]=FP(i,t)):l<=t&&(e.expiredLanes|=i),r&=~i}if(t=De,n=he,n=Xm(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,n===0||e===t&&(Ee===2||Ee===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&mx(o),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||ld(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(o!==null&&mx(o),q1(n)){case 2:case 8:n=_w;break;case 32:n=Sm;break;case 268435456:n=Cw;break;default:n=Sm}return o=HC.bind(null,e),n=G1(n,o),e.callbackPriority=t,e.callbackNode=n,t}return o!==null&&o!==null&&mx(o),e.callbackPriority=2,e.callbackNode=null,2}function HC(e,t){if(pt!==0&&pt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(l0()&&e.callbackNode!==n)return null;var o=he;return o=Xm(e,e===De?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(wC(e,o,t),FC(e,Ln()),e.callbackNode!=null&&e.callbackNode===n?HC.bind(null,e):null)}function Zk(e,t){if(l0())return null;wC(e,t,!0)}function pB(){LB(function(){(ke&6)!==0?G1(ww,fB):zC()})}function Eb(){if(kr===0){var e=Bl;e===0&&(e=Uh,Uh<<=1,(Uh&261888)===0&&(Uh=256)),kr=e}return kr}function Xk(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:rm(""+e)}function Yk(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function hB(e,t,n,o,a){if(t==="submit"&&n&&n.stateNode===a){var r=Xk((a[an]||null).action),s=o.submitter;s&&(t=(t=s[an]||null)?Xk(t.formAction):s.getAttribute("formAction"),t!==null&&(r=t,s=null));var i=new Ym("action","action",null,o,a);e.push({event:i,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(kr!==0){var l=s?Yk(a,s):new FormData(a);b1(n,{pending:!0,data:l,method:a.method,action:r},null,l)}}else typeof r=="function"&&(i.preventDefault(),l=s?Yk(a,s):new FormData(a),b1(n,{pending:!0,data:l,method:a.method,action:r},r,l))},currentTarget:a}]})}}for(Jh=0;Jh<i1.length;Jh++)em=i1[Jh],Kk=em.toLowerCase(),$k=em[0].toUpperCase()+em.slice(1),go(Kk,"on"+$k);var em,Kk,$k,Jh;go(Qw,"onAnimationEnd");go(Jw,"onAnimationIteration");go(e_,"onAnimationStart");go("dblclick","onDoubleClick");go("focusin","onFocus");go("focusout","onBlur");go(R7,"onTransitionRun");go(O7,"onTransitionStart");go(D7,"onTransitionCancel");go(t_,"onTransitionEnd");Dl("onMouseEnter",["mouseout","mouseover"]);Dl("onMouseLeave",["mouseout","mouseover"]);Dl("onPointerEnter",["pointerout","pointerover"]);Dl("onPointerLeave",["pointerout","pointerover"]);Ws("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ws("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ws("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ws("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ws("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ws("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var td="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),mB=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(td));function UC(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var o=e[n],a=o.event;o=o.listeners;e:{var r=void 0;if(t)for(var s=o.length-1;0<=s;s--){var i=o[s],l=i.instance,c=i.currentTarget;if(i=i.listener,l!==r&&a.isPropagationStopped())break e;r=i,a.currentTarget=c;try{r(a)}catch(u){km(u)}a.currentTarget=null,r=l}else for(s=0;s<o.length;s++){if(i=o[s],l=i.instance,c=i.currentTarget,i=i.listener,l!==r&&a.isPropagationStopped())break e;r=i,a.currentTarget=c;try{r(a)}catch(u){km(u)}a.currentTarget=null,r=l}}}}function ue(e,t){var n=t[Jx];n===void 0&&(n=t[Jx]=new Set);var o=e+"__bubble";n.has(o)||(GC(t,e,2,!1),n.add(o))}function Ux(e,t,n){var o=0;t&&(o|=4),GC(n,e,o,t)}var tm="_reactListening"+Math.random().toString(36).slice(2);function Tb(e){if(!e[tm]){e[tm]=!0,Ow.forEach(function(n){n!=="selectionchange"&&(mB.has(n)||Ux(n,!1,e),Ux(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[tm]||(t[tm]=!0,Ux("selectionchange",!1,t))}}function GC(e,t,n,o){switch(tE(t)){case 2:var a=WB;break;case 8:a=qB;break;default:a=Ob}n=a.bind(null,t,n,e),a=void 0,!a1||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),o?a!==void 0?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):a!==void 0?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function Gx(e,t,n,o,a){var r=o;if((t&1)===0&&(t&2)===0&&o!==null)e:for(;;){if(o===null)return;var s=o.tag;if(s===3||s===4){var i=o.stateNode.containerInfo;if(i===a)break;if(s===4)for(s=o.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===a)return;s=s.return}for(;i!==null;){if(s=yl(i),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){o=r=s;continue e}i=i.parentNode}}o=o.return}Uw(function(){var c=r,u=Z1(n),d=[];e:{var f=n_.get(e);if(f!==void 0){var p=Ym,h=e;switch(e){case"keypress":if(im(n)===0)break e;case"keydown":case"keyup":p=u7;break;case"focusin":h="focus",p=Ax;break;case"focusout":h="blur",p=Ax;break;case"beforeblur":case"afterblur":p=Ax;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=ak;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=QP;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=p7;break;case Qw:case Jw:case e_:p=t7;break;case t_:p=m7;break;case"scroll":case"scrollend":p=KP;break;case"wheel":p=g7;break;case"copy":case"cut":case"paste":p=o7;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=sk;break;case"toggle":case"beforetoggle":p=b7}var m=(t&4)!==0,x=!m&&(e==="scroll"||e==="scrollend"),y=m?f!==null?f+"Capture":null:f;m=[];for(var g=c,b;g!==null;){var A=g;if(b=A.stateNode,A=A.tag,A!==5&&A!==26&&A!==27||b===null||y===null||(A=Zu(g,y),A!=null&&m.push(nd(g,A,b))),x)break;g=g.return}0<m.length&&(f=new p(f,h,null,n,u),d.push({event:f,listeners:m}))}}if((t&7)===0){e:{if(f=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",f&&n!==o1&&(h=n.relatedTarget||n.fromElement)&&(yl(h)||h[ql]))break e;if((p||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,p?(h=n.relatedTarget||n.toElement,p=c,h=h?yl(h):null,h!==null&&(x=sd(h),m=h.tag,h!==x||m!==5&&m!==27&&m!==6)&&(h=null)):(p=null,h=c),p!==h)){if(m=ak,A="onMouseLeave",y="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(m=sk,A="onPointerLeave",y="onPointerEnter",g="pointer"),x=p==null?f:Iu(p),b=h==null?f:Iu(h),f=new m(A,g+"leave",p,n,u),f.target=x,f.relatedTarget=b,A=null,yl(u)===c&&(m=new m(y,g+"enter",h,n,u),m.target=b,m.relatedTarget=x,A=m),x=A,p&&h)t:{for(m=yB,y=p,g=h,b=0,A=y;A;A=m(A))b++;A=0;for(var _=g;_;_=m(_))A++;for(;0<b-A;)y=m(y),b--;for(;0<A-b;)g=m(g),A--;for(;b--;){if(y===g||g!==null&&y===g.alternate){m=y;break t}y=m(y),g=m(g)}m=null}else m=null;p!==null&&Qk(d,f,p,m,!1),h!==null&&x!==null&&Qk(d,x,h,m,!0)}}e:{if(f=c?Iu(c):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var T=uk;else if(ck(f))if(Zw)T=T7;else{T=C7;var w=_7}else p=f.nodeName,!p||p.toLowerCase()!=="input"||f.type!=="checkbox"&&f.type!=="radio"?c&&V1(c.elementType)&&(T=uk):T=E7;if(T&&(T=T(e,c))){Vw(d,T,n,u);break e}w&&w(e,f,c),e==="focusout"&&c&&f.type==="number"&&c.memoizedProps.value!=null&&n1(f,"number",f.value)}switch(w=c?Iu(c):window,e){case"focusin":(ck(w)||w.contentEditable==="true")&&(bl=w,r1=c,Pu=null);break;case"focusout":Pu=r1=bl=null;break;case"mousedown":s1=!0;break;case"contextmenu":case"mouseup":case"dragend":s1=!1,hk(d,n,u);break;case"selectionchange":if(M7)break;case"keydown":case"keyup":hk(d,n,u)}var S;if(K1)e:{switch(e){case"compositionstart":var L="onCompositionStart";break e;case"compositionend":L="onCompositionEnd";break e;case"compositionupdate":L="onCompositionUpdate";break e}L=void 0}else xl?qw(e,n)&&(L="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(L="onCompositionStart");L&&(Ww&&n.locale!=="ko"&&(xl||L!=="onCompositionStart"?L==="onCompositionEnd"&&xl&&(S=Gw()):(vr=u,X1="value"in vr?vr.value:vr.textContent,xl=!0)),w=Um(c,L),0<w.length&&(L=new rk(L,e,null,n,u),d.push({event:L,listeners:w}),S?L.data=S:(S=jw(n),S!==null&&(L.data=S)))),(S=v7?S7(e,n):L7(e,n))&&(L=Um(c,"onBeforeInput"),0<L.length&&(w=new rk("onBeforeInput","beforeinput",null,n,u),d.push({event:w,listeners:L}),w.data=S)),hB(d,e,c,n,u)}UC(d,t)})}function nd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Um(e,t){for(var n=t+"Capture",o=[];e!==null;){var a=e,r=a.stateNode;if(a=a.tag,a!==5&&a!==26&&a!==27||r===null||(a=Zu(e,n),a!=null&&o.unshift(nd(e,a,r)),a=Zu(e,t),a!=null&&o.push(nd(e,a,r))),e.tag===3)return o;e=e.return}return[]}function yB(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Qk(e,t,n,o,a){for(var r=t._reactName,s=[];n!==null&&n!==o;){var i=n,l=i.alternate,c=i.stateNode;if(i=i.tag,l!==null&&l===o)break;i!==5&&i!==26&&i!==27||c===null||(l=c,a?(c=Zu(n,r),c!=null&&s.unshift(nd(n,c,l))):a||(c=Zu(n,r),c!=null&&s.push(nd(n,c,l)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var gB=/\r\n?/g,xB=/\u0000|\uFFFD/g;function Jk(e){return(typeof e=="string"?e:""+e).replace(gB,`
|
|
9
|
+
`).replace(xB,"")}function WC(e,t){return t=Jk(t),Jk(e)===t}function Ie(e,t,n,o,a,r){switch(n){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||Pl(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&Pl(e,""+o);break;case"className":qh(e,"class",o);break;case"tabIndex":qh(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":qh(e,n,o);break;case"style":Hw(e,o,r);break;case"data":if(t!=="object"){qh(e,"data",o);break}case"src":case"href":if(o===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(n);break}o=rm(""+o),e.setAttribute(n,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(n,"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 r=="function"&&(n==="formAction"?(t!=="input"&&Ie(e,t,"name",a.name,a,null),Ie(e,t,"formEncType",a.formEncType,a,null),Ie(e,t,"formMethod",a.formMethod,a,null),Ie(e,t,"formTarget",a.formTarget,a,null)):(Ie(e,t,"encType",a.encType,a,null),Ie(e,t,"method",a.method,a,null),Ie(e,t,"target",a.target,a,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(n);break}o=rm(""+o),e.setAttribute(n,o);break;case"onClick":o!=null&&(e.onclick=La);break;case"onScroll":o!=null&&ue("scroll",e);break;case"onScrollEnd":o!=null&&ue("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(O(61));if(n=o.__html,n!=null){if(a.children!=null)throw Error(O(60));e.innerHTML=n}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}n=rm(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,""+o):e.removeAttribute(n);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":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":o===!0?e.setAttribute(n,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(n,o):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(n,o):e.removeAttribute(n);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(n):e.setAttribute(n,o);break;case"popover":ue("beforetoggle",e),ue("toggle",e),am(e,"popover",o);break;case"xlinkActuate":ma(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":ma(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":ma(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":ma(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":ma(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":ma(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":ma(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":ma(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":ma(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":am(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=XP.get(n)||n,am(e,n,o))}}function I1(e,t,n,o,a,r){switch(n){case"style":Hw(e,o,r);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(O(61));if(n=o.__html,n!=null){if(a.children!=null)throw Error(O(60));e.innerHTML=n}}break;case"children":typeof o=="string"?Pl(e,o):(typeof o=="number"||typeof o=="bigint")&&Pl(e,""+o);break;case"onScroll":o!=null&&ue("scroll",e);break;case"onScrollEnd":o!=null&&ue("scrollend",e);break;case"onClick":o!=null&&(e.onclick=La);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Dw.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(a=n.endsWith("Capture"),t=n.slice(2,a?n.length-7:void 0),r=e[an]||null,r=r!=null?r[n]:null,typeof r=="function"&&e.removeEventListener(t,r,a),typeof o=="function")){typeof r!="function"&&r!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,o,a);break e}n in e?e[n]=o:o===!0?e.setAttribute(n,""):am(e,n,o)}}}function Ot(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ue("error",e),ue("load",e);var o=!1,a=!1,r;for(r in n)if(n.hasOwnProperty(r)){var s=n[r];if(s!=null)switch(r){case"src":o=!0;break;case"srcSet":a=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(O(137,t));default:Ie(e,t,r,s,n,null)}}a&&Ie(e,t,"srcSet",n.srcSet,n,null),o&&Ie(e,t,"src",n.src,n,null);return;case"input":ue("invalid",e);var i=r=s=a=null,l=null,c=null;for(o in n)if(n.hasOwnProperty(o)){var u=n[o];if(u!=null)switch(o){case"name":a=u;break;case"type":s=u;break;case"checked":l=u;break;case"defaultChecked":c=u;break;case"value":r=u;break;case"defaultValue":i=u;break;case"children":case"dangerouslySetInnerHTML":if(u!=null)throw Error(O(137,t));break;default:Ie(e,t,o,u,n,null)}}Nw(e,r,i,l,c,s,a,!1);return;case"select":ue("invalid",e),o=s=r=null;for(a in n)if(n.hasOwnProperty(a)&&(i=n[a],i!=null))switch(a){case"value":r=i;break;case"defaultValue":s=i;break;case"multiple":o=i;default:Ie(e,t,a,i,n,null)}t=r,n=s,e.multiple=!!o,t!=null?Cl(e,!!o,t,!1):n!=null&&Cl(e,!!o,n,!0);return;case"textarea":ue("invalid",e),r=a=o=null;for(s in n)if(n.hasOwnProperty(s)&&(i=n[s],i!=null))switch(s){case"value":o=i;break;case"defaultValue":a=i;break;case"children":r=i;break;case"dangerouslySetInnerHTML":if(i!=null)throw Error(O(91));break;default:Ie(e,t,s,i,n,null)}Fw(e,o,a,r);return;case"option":for(l in n)if(n.hasOwnProperty(l)&&(o=n[l],o!=null))switch(l){case"selected":e.selected=o&&typeof o!="function"&&typeof o!="symbol";break;default:Ie(e,t,l,o,n,null)}return;case"dialog":ue("beforetoggle",e),ue("toggle",e),ue("cancel",e),ue("close",e);break;case"iframe":case"object":ue("load",e);break;case"video":case"audio":for(o=0;o<td.length;o++)ue(td[o],e);break;case"image":ue("error",e),ue("load",e);break;case"details":ue("toggle",e);break;case"embed":case"source":case"link":ue("error",e),ue("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(c in n)if(n.hasOwnProperty(c)&&(o=n[c],o!=null))switch(c){case"children":case"dangerouslySetInnerHTML":throw Error(O(137,t));default:Ie(e,t,c,o,n,null)}return;default:if(V1(t)){for(u in n)n.hasOwnProperty(u)&&(o=n[u],o!==void 0&&I1(e,t,u,o,n,void 0));return}}for(i in n)n.hasOwnProperty(i)&&(o=n[i],o!=null&&Ie(e,t,i,o,n,null))}function bB(e,t,n,o){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,r=null,s=null,i=null,l=null,c=null,u=null;for(p in n){var d=n[p];if(n.hasOwnProperty(p)&&d!=null)switch(p){case"checked":break;case"value":break;case"defaultValue":l=d;default:o.hasOwnProperty(p)||Ie(e,t,p,null,o,d)}}for(var f in o){var p=o[f];if(d=n[f],o.hasOwnProperty(f)&&(p!=null||d!=null))switch(f){case"type":r=p;break;case"name":a=p;break;case"checked":c=p;break;case"defaultChecked":u=p;break;case"value":s=p;break;case"defaultValue":i=p;break;case"children":case"dangerouslySetInnerHTML":if(p!=null)throw Error(O(137,t));break;default:p!==d&&Ie(e,t,f,p,o,d)}}t1(e,s,i,l,c,u,r,a);return;case"select":p=s=i=f=null;for(r in n)if(l=n[r],n.hasOwnProperty(r)&&l!=null)switch(r){case"value":break;case"multiple":p=l;default:o.hasOwnProperty(r)||Ie(e,t,r,null,o,l)}for(a in o)if(r=o[a],l=n[a],o.hasOwnProperty(a)&&(r!=null||l!=null))switch(a){case"value":f=r;break;case"defaultValue":i=r;break;case"multiple":s=r;default:r!==l&&Ie(e,t,a,r,o,l)}t=i,n=s,o=p,f!=null?Cl(e,!!n,f,!1):!!o!=!!n&&(t!=null?Cl(e,!!n,t,!0):Cl(e,!!n,n?[]:"",!1));return;case"textarea":p=f=null;for(i in n)if(a=n[i],n.hasOwnProperty(i)&&a!=null&&!o.hasOwnProperty(i))switch(i){case"value":break;case"children":break;default:Ie(e,t,i,null,o,a)}for(s in o)if(a=o[s],r=n[s],o.hasOwnProperty(s)&&(a!=null||r!=null))switch(s){case"value":f=a;break;case"defaultValue":p=a;break;case"children":break;case"dangerouslySetInnerHTML":if(a!=null)throw Error(O(91));break;default:a!==r&&Ie(e,t,s,a,o,r)}zw(e,f,p);return;case"option":for(var h in n)if(f=n[h],n.hasOwnProperty(h)&&f!=null&&!o.hasOwnProperty(h))switch(h){case"selected":e.selected=!1;break;default:Ie(e,t,h,null,o,f)}for(l in o)if(f=o[l],p=n[l],o.hasOwnProperty(l)&&f!==p&&(f!=null||p!=null))switch(l){case"selected":e.selected=f&&typeof f!="function"&&typeof f!="symbol";break;default:Ie(e,t,l,f,o,p)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var m in n)f=n[m],n.hasOwnProperty(m)&&f!=null&&!o.hasOwnProperty(m)&&Ie(e,t,m,null,o,f);for(c in o)if(f=o[c],p=n[c],o.hasOwnProperty(c)&&f!==p&&(f!=null||p!=null))switch(c){case"children":case"dangerouslySetInnerHTML":if(f!=null)throw Error(O(137,t));break;default:Ie(e,t,c,f,o,p)}return;default:if(V1(t)){for(var x in n)f=n[x],n.hasOwnProperty(x)&&f!==void 0&&!o.hasOwnProperty(x)&&I1(e,t,x,void 0,o,f);for(u in o)f=o[u],p=n[u],!o.hasOwnProperty(u)||f===p||f===void 0&&p===void 0||I1(e,t,u,f,o,p);return}}for(var y in n)f=n[y],n.hasOwnProperty(y)&&f!=null&&!o.hasOwnProperty(y)&&Ie(e,t,y,null,o,f);for(d in o)f=o[d],p=n[d],!o.hasOwnProperty(d)||f===p||f==null&&p==null||Ie(e,t,d,f,o,p)}function ew(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function AB(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),o=0;o<n.length;o++){var a=n[o],r=a.transferSize,s=a.initiatorType,i=a.duration;if(r&&i&&ew(s)){for(s=0,i=a.responseEnd,o+=1;o<n.length;o++){var l=n[o],c=l.startTime;if(c>i)break;var u=l.transferSize,d=l.initiatorType;u&&ew(d)&&(l=l.responseEnd,s+=u*(l<i?1:(i-c)/(l-c)))}if(--o,t+=8*(r+s)/(a.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var M1=null,R1=null;function Gm(e){return e.nodeType===9?e:e.ownerDocument}function tw(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function qC(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function O1(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wx=null;function vB(){var e=window.event;return e&&e.type==="popstate"?e===Wx?!1:(Wx=e,!0):(Wx=null,!1)}var jC=typeof setTimeout=="function"?setTimeout:void 0,SB=typeof clearTimeout=="function"?clearTimeout:void 0,nw=typeof Promise=="function"?Promise:void 0,LB=typeof queueMicrotask=="function"?queueMicrotask:typeof nw<"u"?function(e){return nw.resolve(null).then(e).catch(kB)}:jC;function kB(e){setTimeout(function(){throw e})}function Fr(e){return e==="head"}function ow(e,t){var n=t,o=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&a.nodeType===8)if(n=a.data,n==="/$"||n==="/&"){if(o===0){e.removeChild(a),Wl(t);return}o--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")o++;else if(n==="html")ju(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,ju(n);for(var r=n.firstChild;r;){var s=r.nextSibling,i=r.nodeName;r[ud]||i==="SCRIPT"||i==="STYLE"||i==="LINK"&&r.rel.toLowerCase()==="stylesheet"||n.removeChild(r),r=s}}else n==="body"&&ju(e.ownerDocument.body);n=a}while(n);Wl(t)}function aw(e,t){var n=e;e=0;do{var o=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),o&&o.nodeType===8)if(n=o.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=o}while(n)}function D1(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":D1(n),j1(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function wB(e,t,n,o){for(;e.nodeType===1;){var a=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[ud])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(r=e.getAttribute("rel"),r==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(r!==a.rel||e.getAttribute("href")!==(a.href==null||a.href===""?null:a.href)||e.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin)||e.getAttribute("title")!==(a.title==null?null:a.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(r=e.getAttribute("src"),(r!==(a.src==null?null:a.src)||e.getAttribute("type")!==(a.type==null?null:a.type)||e.getAttribute("crossorigin")!==(a.crossOrigin==null?null:a.crossOrigin))&&r&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var r=a.name==null?null:""+a.name;if(a.type==="hidden"&&e.getAttribute("name")===r)return e}else return e;if(e=Kn(e.nextSibling),e===null)break}return null}function _B(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Kn(e.nextSibling),e===null))return null;return e}function VC(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Kn(e.nextSibling),e===null))return null;return e}function P1(e){return e.data==="$?"||e.data==="$~"}function B1(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function CB(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var o=function(){t(),n.removeEventListener("DOMContentLoaded",o)};n.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Kn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var N1=null;function rw(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return Kn(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function sw(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(t===0)return e;t--}else n!=="/$"&&n!=="/&"||t++}e=e.previousSibling}return null}function ZC(e,t,n){switch(t=Gm(n),e){case"html":if(e=t.documentElement,!e)throw Error(O(452));return e;case"head":if(e=t.head,!e)throw Error(O(453));return e;case"body":if(e=t.body,!e)throw Error(O(454));return e;default:throw Error(O(451))}}function ju(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);j1(e)}var $n=new Map,iw=new Set;function Wm(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Oa=we.d;we.d={f:EB,r:TB,D:IB,C:MB,L:RB,m:OB,X:PB,S:DB,M:BB};function EB(){var e=Oa.f(),t=s0();return e||t}function TB(e){var t=jl(e);t!==null&&t.tag===5&&t.type==="form"?H_(t):Oa.r(e)}var Yl=typeof document>"u"?null:document;function XC(e,t,n){var o=Yl;if(o&&typeof t=="string"&&t){var a=Vn(t);a='link[rel="'+e+'"][href="'+a+'"]',typeof n=="string"&&(a+='[crossorigin="'+n+'"]'),iw.has(a)||(iw.add(a),e={rel:e,crossOrigin:n,href:t},o.querySelector(a)===null&&(t=o.createElement("link"),Ot(t,"link",e),Lt(t),o.head.appendChild(t)))}}function IB(e){Oa.D(e),XC("dns-prefetch",e,null)}function MB(e,t){Oa.C(e,t),XC("preconnect",e,t)}function RB(e,t,n){Oa.L(e,t,n);var o=Yl;if(o&&e&&t){var a='link[rel="preload"][as="'+Vn(t)+'"]';t==="image"&&n&&n.imageSrcSet?(a+='[imagesrcset="'+Vn(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(a+='[imagesizes="'+Vn(n.imageSizes)+'"]')):a+='[href="'+Vn(e)+'"]';var r=a;switch(t){case"style":r=Gl(e);break;case"script":r=Kl(e)}$n.has(r)||(e=qe({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),$n.set(r,e),o.querySelector(a)!==null||t==="style"&&o.querySelector(yd(r))||t==="script"&&o.querySelector(gd(r))||(t=o.createElement("link"),Ot(t,"link",e),Lt(t),o.head.appendChild(t)))}}function OB(e,t){Oa.m(e,t);var n=Yl;if(n&&e){var o=t&&typeof t.as=="string"?t.as:"script",a='link[rel="modulepreload"][as="'+Vn(o)+'"][href="'+Vn(e)+'"]',r=a;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":r=Kl(e)}if(!$n.has(r)&&(e=qe({rel:"modulepreload",href:e},t),$n.set(r,e),n.querySelector(a)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(gd(r)))return}o=n.createElement("link"),Ot(o,"link",e),Lt(o),n.head.appendChild(o)}}}function DB(e,t,n){Oa.S(e,t,n);var o=Yl;if(o&&e){var a=_l(o).hoistableStyles,r=Gl(e);t=t||"default";var s=a.get(r);if(!s){var i={loading:0,preload:null};if(s=o.querySelector(yd(r)))i.loading=5;else{e=qe({rel:"stylesheet",href:e,"data-precedence":t},n),(n=$n.get(r))&&Ib(e,n);var l=s=o.createElement("link");Lt(l),Ot(l,"link",e),l._p=new Promise(function(c,u){l.onload=c,l.onerror=u}),l.addEventListener("load",function(){i.loading|=1}),l.addEventListener("error",function(){i.loading|=2}),i.loading|=4,mm(s,t,o)}s={type:"stylesheet",instance:s,count:1,state:i},a.set(r,s)}}}function PB(e,t){Oa.X(e,t);var n=Yl;if(n&&e){var o=_l(n).hoistableScripts,a=Kl(e),r=o.get(a);r||(r=n.querySelector(gd(a)),r||(e=qe({src:e,async:!0},t),(t=$n.get(a))&&Mb(e,t),r=n.createElement("script"),Lt(r),Ot(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function BB(e,t){Oa.M(e,t);var n=Yl;if(n&&e){var o=_l(n).hoistableScripts,a=Kl(e),r=o.get(a);r||(r=n.querySelector(gd(a)),r||(e=qe({src:e,async:!0,type:"module"},t),(t=$n.get(a))&&Mb(e,t),r=n.createElement("script"),Lt(r),Ot(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function lw(e,t,n,o){var a=(a=wr.current)?Wm(a):null;if(!a)throw Error(O(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=Gl(n.href),n=_l(a).hoistableStyles,o=n.get(t),o||(o={type:"style",instance:null,count:0,state:null},n.set(t,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=Gl(n.href);var r=_l(a).hoistableStyles,s=r.get(e);if(s||(a=a.ownerDocument||a,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},r.set(e,s),(r=a.querySelector(yd(e)))&&!r._p&&(s.instance=r,s.state.loading=5),$n.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},$n.set(e,n),r||NB(a,e,n,s.state))),t&&o===null)throw Error(O(528,""));return s}if(t&&o!==null)throw Error(O(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Kl(n),n=_l(a).hoistableScripts,o=n.get(t),o||(o={type:"script",instance:null,count:0,state:null},n.set(t,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(O(444,e))}}function Gl(e){return'href="'+Vn(e)+'"'}function yd(e){return'link[rel="stylesheet"]['+e+"]"}function YC(e){return qe({},e,{"data-precedence":e.precedence,precedence:null})}function NB(e,t,n,o){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?o.loading=1:(t=e.createElement("link"),o.preload=t,t.addEventListener("load",function(){return o.loading|=1}),t.addEventListener("error",function(){return o.loading|=2}),Ot(t,"link",n),Lt(t),e.head.appendChild(t))}function Kl(e){return'[src="'+Vn(e)+'"]'}function gd(e){return"script[async]"+e}function cw(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+Vn(n.href)+'"]');if(o)return t.instance=o,Lt(o),o;var a=qe({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),Lt(o),Ot(o,"style",a),mm(o,n.precedence,e),t.instance=o;case"stylesheet":a=Gl(n.href);var r=e.querySelector(yd(a));if(r)return t.state.loading|=4,t.instance=r,Lt(r),r;o=YC(n),(a=$n.get(a))&&Ib(o,a),r=(e.ownerDocument||e).createElement("link"),Lt(r);var s=r;return s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),Ot(r,"link",o),t.state.loading|=4,mm(r,n.precedence,e),t.instance=r;case"script":return r=Kl(n.src),(a=e.querySelector(gd(r)))?(t.instance=a,Lt(a),a):(o=n,(a=$n.get(r))&&(o=qe({},n),Mb(o,a)),e=e.ownerDocument||e,a=e.createElement("script"),Lt(a),Ot(a,"link",o),e.head.appendChild(a),t.instance=a);case"void":return null;default:throw Error(O(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(o=t.instance,t.state.loading|=4,mm(o,n.precedence,e));return t.instance}function mm(e,t,n){for(var o=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=o.length?o[o.length-1]:null,r=a,s=0;s<o.length;s++){var i=o[s];if(i.dataset.precedence===t)r=i;else if(r!==a)break}r?r.parentNode.insertBefore(e,r.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Ib(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Mb(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var ym=null;function uw(e,t,n){if(ym===null){var o=new Map,a=ym=new Map;a.set(n,o)}else a=ym,o=a.get(n),o||(o=new Map,a.set(n,o));if(o.has(e))return o;for(o.set(e,null),n=n.getElementsByTagName(e),a=0;a<n.length;a++){var r=n[a];if(!(r[ud]||r[It]||e==="link"&&r.getAttribute("rel")==="stylesheet")&&r.namespaceURI!=="http://www.w3.org/2000/svg"){var s=r.getAttribute(t)||"";s=e+s;var i=o.get(s);i?i.push(r):o.set(s,[r])}}return o}function dw(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function zB(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function KC(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function FB(e,t,n,o){if(n.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var a=Gl(o.href),r=t.querySelector(yd(a));if(r){t=r._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=qm.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=r,Lt(r);return}r=t.ownerDocument||t,o=YC(o),(a=$n.get(a))&&Ib(o,a),r=r.createElement("link"),Lt(r);var s=r;s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),Ot(r,"link",o),n.instance=r}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(e.count++,n=qm.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var qx=0;function HB(e,t){return e.stylesheets&&e.count===0&&gm(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var o=setTimeout(function(){if(e.stylesheets&&gm(e,e.stylesheets),e.unsuspend){var r=e.unsuspend;e.unsuspend=null,r()}},6e4+t);0<e.imgBytes&&qx===0&&(qx=62500*AB());var a=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&gm(e,e.stylesheets),e.unsuspend)){var r=e.unsuspend;e.unsuspend=null,r()}},(e.imgBytes>qx?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(a)}}:null}function qm(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)gm(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var jm=null;function gm(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,jm=new Map,t.forEach(UB,e),jm=null,qm.call(e))}function UB(e,t){if(!(t.state.loading&4)){var n=jm.get(e);if(n)var o=n.get(null);else{n=new Map,jm.set(e,n);for(var a=e.querySelectorAll("link[data-precedence],style[data-precedence]"),r=0;r<a.length;r++){var s=a[r];(s.nodeName==="LINK"||s.getAttribute("media")!=="not all")&&(n.set(s.dataset.precedence,s),o=s)}o&&n.set(null,o)}a=t.instance,s=a.getAttribute("data-precedence"),r=n.get(s)||o,r===o&&n.set(null,a),n.set(s,a),this.count++,o=qm.bind(this),a.addEventListener("load",o),a.addEventListener("error",o),r?r.parentNode.insertBefore(a,r.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(a,e.firstChild)),t.state.loading|=4}}var od={$$typeof:Sa,Provider:null,Consumer:null,_currentValue:Os,_currentValue2:Os,_threadCount:0};function GB(e,t,n,o,a,r,s,i,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=yx(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=yx(0),this.hiddenUpdates=yx(null),this.identifierPrefix=o,this.onUncaughtError=a,this.onCaughtError=r,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function $C(e,t,n,o,a,r,s,i,l,c,u,d){return e=new GB(e,t,n,s,l,c,u,d,i),t=1,r===!0&&(t|=24),r=vn(3,null,null,t),e.current=r,r.stateNode=e,t=ob(),t.refCount++,e.pooledCache=t,t.refCount++,r.memoizedState={element:o,isDehydrated:n,cache:t},sb(r),e}function QC(e){return e?(e=Sl,e):Sl}function JC(e,t,n,o,a,r){a=QC(a),o.context===null?o.context=a:o.pendingContext=a,o=Cr(t),o.payload={element:n},r=r===void 0?null:r,r!==null&&(o.callback=r),n=Er(e,o,t),n!==null&&(on(n,e,t),Nu(n,e,t))}function fw(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Rb(e,t){fw(e,t),(e=e.alternate)&&fw(e,t)}function eE(e){if(e.tag===13||e.tag===31){var t=Vs(e,67108864);t!==null&&on(t,e,67108864),Rb(e,67108864)}}function pw(e){if(e.tag===13||e.tag===31){var t=_n();t=W1(t);var n=Vs(e,t);n!==null&&on(n,e,t),Rb(e,t)}}var Vm=!0;function WB(e,t,n,o){var a=K.T;K.T=null;var r=we.p;try{we.p=2,Ob(e,t,n,o)}finally{we.p=r,K.T=a}}function qB(e,t,n,o){var a=K.T;K.T=null;var r=we.p;try{we.p=8,Ob(e,t,n,o)}finally{we.p=r,K.T=a}}function Ob(e,t,n,o){if(Vm){var a=z1(o);if(a===null)Gx(e,t,o,Zm,n),hw(e,o);else if(VB(a,e,t,n,o))o.stopPropagation();else if(hw(e,o),t&4&&-1<jB.indexOf(e)){for(;a!==null;){var r=jl(a);if(r!==null)switch(r.tag){case 3:if(r=r.stateNode,r.current.memoizedState.isDehydrated){var s=Is(r.pendingLanes);if(s!==0){var i=r;for(i.pendingLanes|=2,i.entangledLanes|=2;s;){var l=1<<31-wn(s);i.entanglements[1]|=l,s&=~l}Ho(r),(ke&6)===0&&(Bm=Ln()+500,md(0,!1))}}break;case 31:case 13:i=Vs(r,2),i!==null&&on(i,r,2),s0(),Rb(r,2)}if(r=z1(o),r===null&&Gx(e,t,o,Zm,n),r===a)break;a=r}a!==null&&o.stopPropagation()}else Gx(e,t,o,null,n)}}function z1(e){return e=Z1(e),Db(e)}var Zm=null;function Db(e){if(Zm=null,e=yl(e),e!==null){var t=sd(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=Aw(t),e!==null)return e;e=null}else if(n===31){if(e=vw(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Zm=e,null}function tE(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(RP()){case ww:return 2;case _w:return 8;case Sm:case OP:return 32;case Cw:return 268435456;default:return 32}default:return 32}}var F1=!1,Mr=null,Rr=null,Or=null,ad=new Map,rd=new Map,br=[],jB="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function hw(e,t){switch(e){case"focusin":case"focusout":Mr=null;break;case"dragenter":case"dragleave":Rr=null;break;case"mouseover":case"mouseout":Or=null;break;case"pointerover":case"pointerout":ad.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":rd.delete(t.pointerId)}}function _u(e,t,n,o,a,r){return e===null||e.nativeEvent!==r?(e={blockedOn:t,domEventName:n,eventSystemFlags:o,nativeEvent:r,targetContainers:[a]},t!==null&&(t=jl(t),t!==null&&eE(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function VB(e,t,n,o,a){switch(t){case"focusin":return Mr=_u(Mr,e,t,n,o,a),!0;case"dragenter":return Rr=_u(Rr,e,t,n,o,a),!0;case"mouseover":return Or=_u(Or,e,t,n,o,a),!0;case"pointerover":var r=a.pointerId;return ad.set(r,_u(ad.get(r)||null,e,t,n,o,a)),!0;case"gotpointercapture":return r=a.pointerId,rd.set(r,_u(rd.get(r)||null,e,t,n,o,a)),!0}return!1}function nE(e){var t=yl(e.target);if(t!==null){var n=sd(t);if(n!==null){if(t=n.tag,t===13){if(t=Aw(n),t!==null){e.blockedOn=t,$3(e.priority,function(){pw(n)});return}}else if(t===31){if(t=vw(n),t!==null){e.blockedOn=t,$3(e.priority,function(){pw(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function xm(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=z1(e.nativeEvent);if(n===null){n=e.nativeEvent;var o=new n.constructor(n.type,n);o1=o,n.target.dispatchEvent(o),o1=null}else return t=jl(n),t!==null&&eE(t),e.blockedOn=n,!1;t.shift()}return!0}function mw(e,t,n){xm(e)&&n.delete(t)}function ZB(){F1=!1,Mr!==null&&xm(Mr)&&(Mr=null),Rr!==null&&xm(Rr)&&(Rr=null),Or!==null&&xm(Or)&&(Or=null),ad.forEach(mw),rd.forEach(mw)}function nm(e,t){e.blockedOn===t&&(e.blockedOn=null,F1||(F1=!0,ht.unstable_scheduleCallback(ht.unstable_NormalPriority,ZB)))}var om=null;function yw(e){om!==e&&(om=e,ht.unstable_scheduleCallback(ht.unstable_NormalPriority,function(){om===e&&(om=null);for(var t=0;t<e.length;t+=3){var n=e[t],o=e[t+1],a=e[t+2];if(typeof o!="function"){if(Db(o||n)===null)continue;break}var r=jl(n);r!==null&&(e.splice(t,3),t-=3,b1(r,{pending:!0,data:a,method:n.method,action:o},o,a))}}))}function Wl(e){function t(l){return nm(l,e)}Mr!==null&&nm(Mr,e),Rr!==null&&nm(Rr,e),Or!==null&&nm(Or,e),ad.forEach(t),rd.forEach(t);for(var n=0;n<br.length;n++){var o=br[n];o.blockedOn===e&&(o.blockedOn=null)}for(;0<br.length&&(n=br[0],n.blockedOn===null);)nE(n),n.blockedOn===null&&br.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(o=0;o<n.length;o+=3){var a=n[o],r=n[o+1],s=a[an]||null;if(typeof r=="function")s||yw(n);else if(s){var i=null;if(r&&r.hasAttribute("formAction")){if(a=r,s=r[an]||null)i=s.formAction;else if(Db(a)!==null)continue}else i=s.action;typeof i=="function"?n[o+1]=i:(n.splice(o,3),o-=3),yw(n)}}}function oE(){function e(r){r.canIntercept&&r.info==="react-transition"&&r.intercept({handler:function(){return new Promise(function(s){return a=s})},focusReset:"manual",scroll:"manual"})}function t(){a!==null&&(a(),a=null),o||setTimeout(n,20)}function n(){if(!o&&!navigation.transition){var r=navigation.currentEntry;r&&r.url!=null&&navigation.navigate(r.url,{state:r.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,a=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),a!==null&&(a(),a=null)}}}function Pb(e){this._internalRoot=e}c0.prototype.render=Pb.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(O(409));var n=t.current,o=_n();JC(n,o,e,t,null,null)};c0.prototype.unmount=Pb.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;JC(e.current,2,null,e,null,null),s0(),t[ql]=null}};function c0(e){this._internalRoot=e}c0.prototype.unstable_scheduleHydration=function(e){if(e){var t=Rw();e={blockedOn:null,target:e,priority:t};for(var n=0;n<br.length&&t!==0&&t<br[n].priority;n++);br.splice(n,0,e),n===0&&nE(e)}};var gw=xw.version;if(gw!=="19.2.6")throw Error(O(527,gw,"19.2.6"));we.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(O(188)):(e=Object.keys(e).join(","),Error(O(268,e)));return e=wP(t),e=e!==null?Sw(e):null,e=e===null?null:e.stateNode,e};var XB={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(Cu=__REACT_DEVTOOLS_GLOBAL_HOOK__,!Cu.isDisabled&&Cu.supportsFiber))try{id=Cu.inject(XB),kn=Cu}catch{}var Cu;u0.createRoot=function(e,t){if(!bw(e))throw Error(O(299));var n=!1,o="",a=X_,r=Y_,s=K_;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(o=t.identifierPrefix),t.onUncaughtError!==void 0&&(a=t.onUncaughtError),t.onCaughtError!==void 0&&(r=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=$C(e,1,!1,null,null,n,o,null,a,r,s,oE),e[ql]=t.current,Tb(e),new Pb(t)};u0.hydrateRoot=function(e,t,n){if(!bw(e))throw Error(O(299));var o=!1,a="",r=X_,s=Y_,i=K_,l=null;return n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(a=n.identifierPrefix),n.onUncaughtError!==void 0&&(r=n.onUncaughtError),n.onCaughtError!==void 0&&(s=n.onCaughtError),n.onRecoverableError!==void 0&&(i=n.onRecoverableError),n.formState!==void 0&&(l=n.formState)),t=$C(e,1,!0,t,n??null,o,a,l,r,s,i,oE),t.context=QC(null),n=t.current,o=_n(),o=W1(o),a=Cr(o),a.callback=null,Er(n,a,o),n=o,t.current.lanes=n,cd(t,n),Ho(t),e[ql]=t.current,Tb(e),new c0(t)};u0.version="19.2.6"});var iE=Ht((x$,sE)=>{"use strict";function rE(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(rE)}catch(e){console.error(e)}}rE(),sE.exports=aE()});var cE=Ht(d0=>{"use strict";var YB=Symbol.for("react.transitional.element"),KB=Symbol.for("react.fragment");function lE(e,t,n){var o=null;if(n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),"key"in t){n={};for(var a in t)a!=="key"&&(n[a]=t[a])}else n=t;return t=n.ref,{$$typeof:YB,type:e,key:o,ref:t!==void 0?t:null,props:n}}d0.Fragment=KB;d0.jsx=lE;d0.jsxs=lE});var se=Ht((A$,uE)=>{"use strict";uE.exports=cE()});var JL=Ht(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.loop=Ss.conditional=Ss.parse=void 0;var lK=function e(t,n){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:o;if(Array.isArray(n))n.forEach(function(s){return e(t,s,o,a)});else if(typeof n=="function")n(t,o,a,e);else{var r=Object.keys(n)[0];Array.isArray(n[r])?(a[r]={},e(t,n[r],o,a[r])):a[r]=n[r](t,o,a,e)}return o};Ss.parse=lK;var cK=function(t,n){return function(o,a,r,s){n(o,a,r)&&s(o,t,a,r)}};Ss.conditional=cK;var uK=function(t,n){return function(o,a,r,s){for(var i=[],l=o.pos;n(o,a,r);){var c={};if(s(o,t,a,c),o.pos===l)break;l=o.pos,i.push(c)}return i}};Ss.loop=uK});var e3=Ht(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.readBits=dt.readArray=dt.readUnsigned=dt.readString=dt.peekBytes=dt.readBytes=dt.peekByte=dt.readByte=dt.buildStream=void 0;var dK=function(t){return{data:t,pos:0}};dt.buildStream=dK;var L6=function(){return function(t){return t.data[t.pos++]}};dt.readByte=L6;var fK=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(n){return n.data[n.pos+t]}};dt.peekByte=fK;var Gg=function(t){return function(n){return n.data.subarray(n.pos,n.pos+=t)}};dt.readBytes=Gg;var pK=function(t){return function(n){return n.data.subarray(n.pos,n.pos+t)}};dt.peekBytes=pK;var hK=function(t){return function(n){return Array.from(Gg(t)(n)).map(function(o){return String.fromCharCode(o)}).join("")}};dt.readString=hK;var mK=function(t){return function(n){var o=Gg(2)(n);return t?(o[1]<<8)+o[0]:(o[0]<<8)+o[1]}};dt.readUnsigned=mK;var yK=function(t,n){return function(o,a,r){for(var s=typeof n=="function"?n(o,a,r):n,i=Gg(t),l=new Array(s),c=0;c<s;c++)l[c]=i(o);return l}};dt.readArray=yK;var gK=function(t,n,o){for(var a=0,r=0;r<o;r++)a+=t[n+r]&&Math.pow(2,o-r-1);return a},xK=function(t){return function(n){for(var o=L6()(n),a=new Array(8),r=0;r<8;r++)a[7-r]=!!(o&1<<r);return Object.keys(t).reduce(function(s,i){var l=t[i];return l.length?s[i]=gK(a,l.index,l.length):s[i]=a[l.index],s},{})}};dt.readBits=xK});var k6=Ht(qg=>{"use strict";Object.defineProperty(qg,"__esModule",{value:!0});qg.default=void 0;var Ls=JL(),ce=e3(),Wg={blocks:function(t){for(var n=0,o=[],a=t.data.length,r=0,s=(0,ce.readByte)()(t);s!==n&&s;s=(0,ce.readByte)()(t)){if(t.pos+s>=a){var i=a-t.pos;o.push((0,ce.readBytes)(i)(t)),r+=i;break}o.push((0,ce.readBytes)(s)(t)),r+=s}for(var l=new Uint8Array(r),c=0,u=0;u<o.length;u++)l.set(o[u],c),c+=o[u].length;return l}},bK=(0,Ls.conditional)({gce:[{codes:(0,ce.readBytes)(2)},{byteSize:(0,ce.readByte)()},{extras:(0,ce.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,ce.readUnsigned)(!0)},{transparentColorIndex:(0,ce.readByte)()},{terminator:(0,ce.readByte)()}]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===249}),AK=(0,Ls.conditional)({image:[{code:(0,ce.readByte)()},{descriptor:[{left:(0,ce.readUnsigned)(!0)},{top:(0,ce.readUnsigned)(!0)},{width:(0,ce.readUnsigned)(!0)},{height:(0,ce.readUnsigned)(!0)},{lct:(0,ce.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,Ls.conditional)({lct:(0,ce.readArray)(3,function(e,t,n){return Math.pow(2,n.descriptor.lct.size+1)})},function(e,t,n){return n.descriptor.lct.exists}),{data:[{minCodeSize:(0,ce.readByte)()},Wg]}]},function(e){return(0,ce.peekByte)()(e)===44}),vK=(0,Ls.conditional)({text:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{preData:function(t,n,o){return(0,ce.readBytes)(o.text.blockSize)(t)}},Wg]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===1}),SK=(0,Ls.conditional)({application:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{id:function(t,n,o){return(0,ce.readString)(o.blockSize)(t)}},Wg]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===255}),LK=(0,Ls.conditional)({comment:[{codes:(0,ce.readBytes)(2)},Wg]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===254}),kK=[{header:[{signature:(0,ce.readString)(3)},{version:(0,ce.readString)(3)}]},{lsd:[{width:(0,ce.readUnsigned)(!0)},{height:(0,ce.readUnsigned)(!0)},{gct:(0,ce.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,ce.readByte)()},{pixelAspectRatio:(0,ce.readByte)()}]},(0,Ls.conditional)({gct:(0,ce.readArray)(3,function(e,t){return Math.pow(2,t.lsd.gct.size+1)})},function(e,t){return t.lsd.gct.exists}),{frames:(0,Ls.loop)([bK,SK,LK,AK,vK],function(e){var t=(0,ce.peekByte)()(e);return t===33||t===44})}],wK=kK;qg.default=wK});var w6=Ht(jg=>{"use strict";Object.defineProperty(jg,"__esModule",{value:!0});jg.deinterlace=void 0;var _K=function(t,n){for(var o=new Array(t.length),a=t.length/n,r=function(f,p){var h=t.slice(p*n,(p+1)*n);o.splice.apply(o,[f*n,n].concat(h))},s=[0,4,2,1],i=[8,8,4,2],l=0,c=0;c<4;c++)for(var u=s[c];u<a;u+=i[c])r(u,l),l++;return o};jg.deinterlace=_K});var _6=Ht(Vg=>{"use strict";Object.defineProperty(Vg,"__esModule",{value:!0});Vg.lzw=void 0;var CK=function(t,n,o){var a=4096,r=-1,s=o,i,l,c,u,d,f,p,T,h,m,_,x,S,L,B,M,y=new Array(o),g=new Array(a),b=new Array(a),A=new Array(a+1);for(x=t,l=1<<x,d=l+1,i=l+2,p=r,u=x+1,c=(1<<u)-1,h=0;h<l;h++)g[h]=0,b[h]=h;var _,T,w,S,L,M,B;for(_=T=w=S=L=M=B=0,m=0;m<s;){if(L===0){if(T<u){_+=n[B]<<T,T+=8,B++;continue}if(h=_&c,_>>=u,T-=u,h>i||h==d)break;if(h==l){u=x+1,c=(1<<u)-1,i=l+2,p=r;continue}if(p==r){A[L++]=b[h],p=h,S=h;continue}for(f=h,h==i&&(A[L++]=S,h=p);h>l;)A[L++]=b[h],h=g[h];S=b[h]&255,A[L++]=S,i<a&&(g[i]=p,b[i]=S,i++,(i&c)===0&&i<a&&(u++,c+=i)),p=f}L--,y[M++]=A[L],m++}for(m=M;m<s;m++)y[m]=0;return y};Vg.lzw=CK});var E6=Ht(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.decompressFrames=ks.decompressFrame=ks.parseGIF=void 0;var EK=OK(k6()),TK=JL(),IK=e3(),MK=w6(),RK=_6();function OK(e){return e&&e.__esModule?e:{default:e}}var DK=function(t){var n=new Uint8Array(t);return(0,TK.parse)((0,IK.buildStream)(n),EK.default)};ks.parseGIF=DK;var PK=function(t){for(var n=t.pixels.length,o=new Uint8ClampedArray(n*4),a=0;a<n;a++){var r=a*4,s=t.pixels[a],i=t.colorTable[s]||[0,0,0];o[r]=i[0],o[r+1]=i[1],o[r+2]=i[2],o[r+3]=s!==t.transparentIndex?255:0}return o},C6=function(t,n,o){if(!t.image){console.warn("gif frame does not have associated image.");return}var a=t.image,r=a.descriptor.width*a.descriptor.height,s=(0,RK.lzw)(a.data.minCodeSize,a.data.blocks,r);a.descriptor.lct.interlaced&&(s=(0,MK.deinterlace)(s,a.descriptor.width));var i={pixels:s,dims:{top:t.image.descriptor.top,left:t.image.descriptor.left,width:t.image.descriptor.width,height:t.image.descriptor.height}};return a.descriptor.lct&&a.descriptor.lct.exists?i.colorTable=a.lct:i.colorTable=n,t.gce&&(i.delay=(t.gce.delay||10)*10,i.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(i.transparentIndex=t.gce.transparentColorIndex)),o&&(i.patch=PK(i)),i};ks.decompressFrame=C6;var BK=function(t,n){return t.frames.filter(function(o){return o.image}).map(function(o){return C6(o,t.gct,n)})};ks.decompressFrames=BK});var F6=P(iE(),1);var R=P(se(),1),me=P(re(),1);var h0=P(re(),1);var f0=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();var dE=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var fE=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase());var Bb=e=>{let t=fE(e);return t.charAt(0).toUpperCase()+t.slice(1)};var xd=P(re(),1);var p0={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var pE=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var $l=P(re(),1);var $B=(0,$l.createContext)({});var hE=()=>(0,$l.useContext)($B);var mE=(0,xd.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:o,className:a="",children:r,iconNode:s,...i},l)=>{let{size:c=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f="currentColor",className:p=""}=hE()??{},h=o??d?Number(n??u)*24/Number(t??c):n??u;return(0,xd.createElement)("svg",{ref:l,...p0,width:t??c??p0.width,height:t??c??p0.height,stroke:e??f,strokeWidth:h,className:f0("lucide",p,a),...!r&&!pE(i)&&{"aria-hidden":"true"},...i},[...s.map(([m,x])=>(0,xd.createElement)(m,x)),...Array.isArray(r)?r:[r]])});var E=(e,t)=>{let n=(0,h0.forwardRef)(({className:o,...a},r)=>(0,h0.createElement)(mE,{ref:r,iconNode:t,className:f0(`lucide-${dE(Bb(e))}`,`lucide-${e}`,o),...a}));return n.displayName=Bb(e),n};var QB=[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4",key:"11f1s0"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4",key:"t14dx9"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1",key:"1w07xs"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1",key:"1apec2"}]],bd=E("align-center-horizontal",QB);var JB=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]],Ql=E("align-center-vertical",JB);var eN=[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2",key:"z5wdxg"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2",key:"um7a8w"}],["path",{d:"M22 22H2",key:"19qnx5"}]],Ad=E("align-end-horizontal",eN);var tN=[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]],vd=E("align-end-vertical",tN);var nN=[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]],Sd=E("align-horizontal-distribute-center",nN);var oN=[["rect",{width:"6",height:"16",x:"4",y:"6",rx:"2",key:"1n4dg1"}],["rect",{width:"6",height:"9",x:"14",y:"6",rx:"2",key:"17khns"}],["path",{d:"M22 2H2",key:"fhrpnj"}]],Ld=E("align-start-horizontal",oN);var aN=[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]],kd=E("align-start-vertical",aN);var rN=[["path",{d:"M22 17h-3",key:"1lwga1"}],["path",{d:"M22 7h-5",key:"o2endc"}],["path",{d:"M5 17H2",key:"1gx9xc"}],["path",{d:"M7 7H2",key:"6bq26l"}],["rect",{x:"5",y:"14",width:"14",height:"6",rx:"2",key:"1qrzuf"}],["rect",{x:"7",y:"4",width:"10",height:"6",rx:"2",key:"we8e9z"}]],wd=E("align-vertical-distribute-center",rN);var sN=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],_d=E("bold",sN);var iN=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],Cd=E("case-sensitive",iN);var lN=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ed=E("check",lN);var cN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Td=E("chevron-down",cN);var uN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Xs=E("chevron-right",uN);var dN=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],Id=E("chevrons-down",dN);var fN=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Md=E("chevrons-up",fN);var pN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Tn=E("circle-question-mark",pN);var hN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ys=E("circle",hN);var mN=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],Rd=E("clipboard",mN);var yN=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Hr=E("copy",yN);var gN=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],Od=E("crop",gN);var xN=[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]],Dd=E("delete",xN);var bN=[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]],Pd=E("diamond",bN);var AN=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Jl=E("download",AN);var vN=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Ur=E("ellipsis-vertical",vN);var SN=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Gr=E("ellipsis",SN);var LN=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],Bd=E("eraser",LN);var kN=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Nd=E("external-link",kN);var wN=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],zd=E("file-down",wN);var _N=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],Fd=E("file-up",_N);var CN=[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]],Hd=E("flip-horizontal-2",CN);var EN=[["path",{d:"m17 3-5 5-5-5h10",key:"1ftt6x"}],["path",{d:"m17 21-5-5-5 5h10",key:"1m0wmu"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]],Ud=E("flip-vertical-2",EN);var TN=[["line",{x1:"22",x2:"2",y1:"6",y2:"6",key:"15w7dq"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18",key:"1ip48p"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22",key:"a2lnyx"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22",key:"8vb6jd"}]],Gd=E("frame",TN);var IN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],xo=E("grid-3x3",IN);var MN=[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]],Wd=E("grip",MN);var RN=[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]],qd=E("group",RN);var ON=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],jd=E("hand",ON);var DN=[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],Ks=E("image-down",DN);var PN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],$s=E("image",PN);var BN=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],Vd=E("italic",BN);var NN=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Zd=E("library",NN);var zN=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Xd=E("link",zN);var FN=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Yd=E("locate-fixed",FN);var HN=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],Kd=E("lock",HN);var UN=[["path",{d:"m12 15 4 4",key:"lnac28"}],["path",{d:"M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z",key:"nlhkjb"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}]],$d=E("magnet",UN);var GN=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],ec=E("maximize",GN);var WN=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Qd=E("menu",WN);var qN=[["path",{d:"M5 12h14",key:"1ays0h"}]],Da=E("minus",qN);var jN=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Jd=E("monitor",jN);var VN=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],ef=E("moon",VN);var ZN=[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]],tf=E("mouse-pointer-2",ZN);var XN=[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]],nf=E("mouse-pointer",XN);var YN=[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]],of=E("move-down",YN);var KN=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],af=E("move-right",KN);var $N=[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]],rf=E("move-up",$N);var QN=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Wr=E("pen-line",QN);var JN=[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12",key:"1y3wsu"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z",key:"110lr1"}],["path",{d:"m2 22 .414-.414",key:"jhxm08"}]],sf=E("pipette",JN);var ez=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Qs=E("plus",ez);var tz=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],lf=E("radio",tz);var nz=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],Js=E("redo-2",nz);var oz=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],cf=E("rotate-ccw",oz);var az=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],uf=E("scissors",az);var rz=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],df=E("search",rz);var sz=[["path",{d:"M22 2 2 22",key:"y4kqgn"}]],ff=E("slash",sz);var iz=[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]],pf=E("spline",iz);var lz=[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]],Pa=E("square-dashed",lz);var cz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Ba=E("square-dot",cz);var uz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Uo=E("square",uz);var dz=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],hf=E("strikethrough",dz);var fz=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],mf=E("sun",fz);var pz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],qr=E("text-align-end",pz);var hz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],jr=E("text-align-center",hz);var mz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],bo=E("text-align-start",mz);var yz=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],tc=E("trash-2",yz);var gz=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],yf=E("type",gz);var xz=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],gf=E("underline",xz);var bz=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],ei=E("undo-2",bz);var Az=[["rect",{width:"8",height:"6",x:"5",y:"4",rx:"1",key:"nzclkv"}],["rect",{width:"8",height:"6",x:"11",y:"14",rx:"1",key:"4tytwb"}]],xf=E("ungroup",Az);var vz=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],bf=E("upload",vz);var Sz=[["path",{d:"m10.586 5.414-5.172 5.172",key:"4mc350"}],["path",{d:"m18.586 13.414-5.172 5.172",key:"8c96vv"}],["path",{d:"M6 12h12",key:"8npq4p"}],["circle",{cx:"12",cy:"20",r:"2",key:"144qzu"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["circle",{cx:"20",cy:"12",r:"2",key:"1xzzfp"}],["circle",{cx:"4",cy:"12",r:"2",key:"1hvhnz"}]],Af=E("waypoints",Sz);var Lz=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Na=E("x",Lz);var kz=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],vf=E("zoom-out",kz);var wz=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Sf=E("zoom-in",wz);var _z=P(se(),1),Ao=P(re(),1),yE=(0,Ao.createContext)(null);var gE=yE;var Nb=()=>(0,Ao.useContext)(yE),sn=(e,t,n)=>{let o=Nb(),[a,r]=(0,Ao.useState)(()=>o?e(o):t),s=(0,Ao.useRef)(e);s.current=e;let i=(0,Ao.useRef)(t);return i.current=t,(0,Ao.useEffect)(()=>{if(!o){r(i.current);return}let l=()=>{let c=s.current(o);r(u=>Object.is(u,c)?u:c)};return l(),n!==void 0?o.on(n,l):o.subscribe(l)},[o,n]),a};var Xb=P(se(),1);var nc=P(se(),1),Je=P(re(),1),DE=P(ha(),1);var xE=P(se(),1),m0=P(re(),1),bE=(0,m0.createContext)(null),Lf=({container:e,children:t})=>(0,xE.jsx)(bE.Provider,{value:e,children:t}),Dt=()=>(0,m0.useContext)(bE)??document.body;var zb=[{label:"S",value:16},{label:"M",value:24},{label:"L",value:36},{label:"XL",value:64}],AE=8,vE=256,SE=160,LE=200,kE=150,Fb=8,Hb=150,wE="#2563eb",_E=1.5,CE="rgba(37, 99, 235, 0.12)",EE=1,Ub=10,Gb=[{label:"Sans",value:"system-ui, sans-serif"},{label:"Serif",value:"Georgia, 'Times New Roman', serif"},{label:"Mono",value:"ui-monospace, 'SF Mono', Menlo, monospace"}],TE=176,IE=1,ME=40;var qb=new Set,kf=null,Go=null,Wo=null,Vb=0,jb=!1,Cz=()=>{for(let e of qb)e(kf)},y0=e=>{kf=e,Cz()},Ez=e=>(qb.add(e),()=>{qb.delete(e)}),Tz=e=>{if(jb)return;Wo&&(clearTimeout(Wo),Wo=null),Go&&clearTimeout(Go);let t=Date.now()-Vb;if(kf!==null||t<600){y0(e);return}Go=setTimeout(()=>{Go=null,y0(e)},600)},RE=e=>{Go&&(clearTimeout(Go),Go=null),kf?.id===e&&(Wo&&clearTimeout(Wo),Wo=setTimeout(()=>{Wo=null,Vb=Date.now(),y0(null)},80))},OE=()=>{Go&&(clearTimeout(Go),Go=null),Wo&&(clearTimeout(Wo),Wo=null),kf&&(Vb=Date.now(),y0(null))},Zb=({children:e})=>((0,Je.useEffect)(()=>{let t=()=>{jb=!0,OE()},n=()=>{jb=!1},o=a=>{a.key==="Escape"&&OE()};return document.addEventListener("pointerdown",t,{capture:!0}),document.addEventListener("pointerup",n,{capture:!0}),document.addEventListener("keydown",o,{capture:!0}),()=>{document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointerup",n,{capture:!0}),document.removeEventListener("keydown",o,{capture:!0})}},[]),(0,nc.jsxs)(PE.Provider,{value:!0,children:[e,(0,nc.jsx)(Mz,{})]})),PE=(0,Je.createContext)(!1),Iz=()=>(0,Je.useContext)(PE),Mz=()=>{let[e,t]=(0,Je.useState)(null),n=Dt();return(0,Je.useEffect)(()=>Ez(t),[]),!e||typeof document>"u"?null:(0,DE.createPortal)((0,nc.jsx)(Rz,{target:e}),n)},Rz=({target:e})=>{let t=(0,Je.useRef)(null),[n,o]=(0,Je.useState)(null);(0,Je.useLayoutEffect)(()=>{let r=t.current;if(!r)return;let s=r.getBoundingClientRect(),{rect:i,side:l}=e,c=i.left+i.width/2-s.width/2,u=i.top+i.height/2-s.height/2;switch(l){case"top":u=i.top-s.height-6;break;case"bottom":u=i.bottom+6;break;case"left":c=i.left-s.width-6;break;case"right":c=i.right+6;break}let d=4;c=Math.max(d,Math.min(c,window.innerWidth-s.width-d)),u=Math.max(d,Math.min(u,window.innerHeight-s.height-d)),o({left:c,top:u})},[e]);let a={position:"fixed",left:n?.left??-9999,top:n?.top??-9999,pointerEvents:"none",zIndex:1e4,visibility:n?"visible":"hidden"};return(0,nc.jsx)("div",{ref:t,role:"tooltip",className:"du-tooltip",style:a,children:e.content})},ti=({content:e,side:t="bottom",disabled:n,children:o})=>{let a=(0,Je.useId)();if(!Iz()||n||e===void 0||e===null)return(0,Je.isValidElement)(o)&&typeof e=="string"&&!n?(0,Je.cloneElement)(o,{title:e}):o;if(!(0,Je.isValidElement)(o))return o;let s=o,i=f=>{Tz({id:a,content:e,side:t,rect:f.getBoundingClientRect()})};return(0,Je.cloneElement)(s,{onPointerEnter:f=>{s.props.onPointerEnter?.(f),f.pointerType!=="touch"&&i(f.currentTarget)},onPointerLeave:f=>{s.props.onPointerLeave?.(f),RE(a)},onFocus:f=>{s.props.onFocus?.(f),i(f.currentTarget)},onBlur:f=>{s.props.onBlur?.(f),RE(a)},title:void 0})};var Qn=({label:e,active:t,size:n="default",className:o,children:a,...r})=>{let s=["du-icon-button",n==="sm"?"du-icon-button-sm":"",t?"is-active":"",o??""].filter(Boolean).join(" ");return(0,Xb.jsx)(ti,{content:e,children:(0,Xb.jsx)("button",{type:"button",className:s,"aria-label":e,"aria-pressed":t??void 0,...r,children:a})})};var BE=P(se(),1),ni=({children:e,className:t,ariaLabel:n})=>(0,BE.jsx)("div",{className:`du-button-group ${t??""}`.trim(),role:"group","aria-label":n,children:e});var Yb=P(se(),1);var In=({value:e,options:t,onChange:n,ariaLabel:o})=>(0,Yb.jsx)(ni,{...o!==void 0?{ariaLabel:o}:{},children:t.map(a=>(0,Yb.jsx)(Qn,{label:a.label,active:e===a.value,onClick:()=>{n(a.value)},size:"sm",children:a.icon},String(a.value)))});var wf=P(se(),1),_f=({value:e,min:t,max:n,step:o=1,onChange:a,ariaLabel:r,valueLabel:s})=>{let i=c=>{a(Number(c.target.value))},l=e??(t+n)/2;return(0,wf.jsxs)("div",{className:"du-slider",children:[(0,wf.jsx)("input",{type:"range",min:t,max:n,step:o,value:l,onChange:i,"aria-label":r,className:"du-slider-track"}),(0,wf.jsx)("span",{className:"du-slider-value",children:e===null?"\u2014":s??e})]})};var NE=P(se(),1),Kb=({children:e,className:t,style:n})=>(0,NE.jsx)("div",{className:`du-ui-layer ${t??""}`.trim(),style:n,children:e});var Jn=P(se(),1),$b=({left:e,center:t,right:n})=>(0,Jn.jsxs)("div",{className:"du-bar du-bar-top",children:[(0,Jn.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,Jn.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,Jn.jsx)("div",{}),(0,Jn.jsx)("div",{className:"du-bar-zone",children:n})]}),Qb=({left:e,center:t,right:n})=>(0,Jn.jsxs)("div",{className:"du-bar du-bar-bottom",children:[(0,Jn.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,Jn.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,Jn.jsx)("div",{}),(0,Jn.jsx)("div",{className:"du-bar-zone",children:n})]});var ss=P(se(),1),o8=P(re(),1);var Ye=P(se(),1),Gc=P(re(),1);var zE="select";var qo={};ho(qo,{EMPTY:()=>Pe,add:()=>Xt,clear:()=>Pz,equals:()=>oi,has:()=>Oz,remove:()=>Tf,replace:()=>Dz,single:()=>wt,toggle:()=>tA});var Ze=e=>e,Jb=e=>e,ln=e=>e,Cf=e=>e,oc=e=>e,eA=e=>e;var v=e=>{if(e===void 0)throw new Error("required value is undefined");return e};var Ef=e=>{let t={};for(let[n,o]of Object.entries(e))o!==void 0&&(t[n]=o);return t};var g0=(e,t)=>{if(e===t)return!0;if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};var Pe=Object.freeze(new Set),wt=e=>new Set([e]),Oz=(e,t)=>e.has(t),Xt=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},Tf=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},tA=(e,t)=>e.has(t)?Tf(e,t):Xt(e,t),Dz=e=>wt(e),Pz=()=>Pe,oi=(e,t)=>g0(e,t);var U={};ho(U,{ZERO:()=>FE,add:()=>Nz,angle:()=>Xz,cross:()=>Wz,distance:()=>qz,distanceSq:()=>GE,div:()=>Hz,dot:()=>Gz,equals:()=>Qz,length:()=>UE,lengthSq:()=>HE,lerp:()=>Vz,midpoint:()=>Zz,mul:()=>Fz,negate:()=>Uz,normalize:()=>jz,of:()=>Bz,perp:()=>$z,rotate:()=>Yz,rotateAround:()=>Kz,sub:()=>zz});var FE=Object.freeze({x:0,y:0}),Bz=(e,t)=>({x:e,y:t}),Nz=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),zz=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),Fz=(e,t)=>({x:e.x*t,y:e.y*t}),Hz=(e,t)=>({x:e.x/t,y:e.y/t}),Uz=e=>({x:-e.x,y:-e.y}),Gz=(e,t)=>e.x*t.x+e.y*t.y,Wz=(e,t)=>e.x*t.y-e.y*t.x,HE=e=>e.x*e.x+e.y*e.y,UE=e=>Math.sqrt(HE(e)),GE=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o},qz=(e,t)=>Math.sqrt(GE(e,t)),jz=e=>{let t=UE(e);return t===0?FE:{x:e.x/t,y:e.y/t}},Vz=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),Zz=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Xz=e=>Math.atan2(e.y,e.x),Yz=(e,t)=>{let n=Math.cos(t),o=Math.sin(t);return{x:e.x*n-e.y*o,y:e.x*o+e.y*n}},Kz=(e,t,n)=>{let o=Math.cos(n),a=Math.sin(n),r=e.x-t.x,s=e.y-t.y;return{x:t.x+(r*o-s*a),y:t.y+(r*a+s*o)}},$z=e=>({x:-e.y,y:e.x}),Qz=(e,t,n=0)=>n===0?e.x===t.x&&e.y===t.y:Math.abs(e.x-t.x)<=n&&Math.abs(e.y-t.y)<=n;var ac={};ho(ac,{clamp:()=>Jz,clamp01:()=>eF});var Jz=(e,t,n)=>Math.max(t,Math.min(n,e)),eF=e=>e<0?0:e>1?1:e;var N={};ho(N,{IDENTITY:()=>tF,applyToBounds:()=>lF,applyToPoint:()=>If,decompose:()=>cF,equals:()=>uF,inverse:()=>iF,multiply:()=>sF,of:()=>nF,rotation:()=>rF,scaling:()=>aF,translation:()=>oF});var tF=Object.freeze({a:1,b:0,c:0,d:1,e:0,f:0}),nF=(e,t,n,o,a,r)=>({a:e,b:t,c:n,d:o,e:a,f:r}),oF=(e,t)=>({a:1,b:0,c:0,d:1,e,f:t}),aF=(e,t=e)=>({a:e,b:0,c:0,d:t,e:0,f:0}),rF=e=>{let t=Math.cos(e),n=Math.sin(e);return{a:t,b:n,c:-n,d:t,e:0,f:0}},sF=(e,t)=>({a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,e:e.a*t.e+e.c*t.f+e.e,f:e.b*t.e+e.d*t.f+e.f}),iF=e=>{let t=e.a*e.d-e.b*e.c;if(t===0)throw new Error("Cannot invert singular matrix");return{a:e.d/t,b:-e.b/t,c:-e.c/t,d:e.a/t,e:(e.c*e.f-e.d*e.e)/t,f:(e.b*e.e-e.a*e.f)/t}},If=(e,t)=>({x:e.a*t.x+e.c*t.y+e.e,y:e.b*t.x+e.d*t.y+e.f}),lF=(e,t)=>{let n=If(e,{x:t.x,y:t.y}),o=If(e,{x:t.x+t.width,y:t.y}),a=If(e,{x:t.x,y:t.y+t.height}),r=If(e,{x:t.x+t.width,y:t.y+t.height}),s=Math.min(n.x,o.x,a.x,r.x),i=Math.min(n.y,o.y,a.y,r.y),l=Math.max(n.x,o.x,a.x,r.x),c=Math.max(n.y,o.y,a.y,r.y);return{x:s,y:i,width:l-s,height:c-i}},cF=e=>{let t=Math.sqrt(e.a*e.a+e.b*e.b),n=Math.sqrt(e.c*e.c+e.d*e.d),a=e.a*e.d-e.b*e.c<0?-n:n;return{translation:{x:e.e,y:e.f},rotation:Math.atan2(e.b,e.a),scale:{x:t,y:a}}},uF=(e,t,n=0)=>{let o=["a","b","c","d","e","f"];return n===0?o.every(a=>e[a]===t[a]):o.every(a=>Math.abs(e[a]-t[a])<=n)};var V={};ho(V,{EMPTY:()=>WE,centerOf:()=>pF,contains:()=>oA,containsBounds:()=>yF,equals:()=>bF,expand:()=>gF,fromCenter:()=>fF,fromPoints:()=>x0,intersection:()=>qE,intersects:()=>mF,isEmpty:()=>nA,maxX:()=>Vr,maxY:()=>Zr,normalize:()=>xF,of:()=>dF,union:()=>hF});var WE=Object.freeze({x:0,y:0,width:0,height:0}),dF=(e,t,n,o)=>({x:e,y:t,width:n,height:o}),x0=e=>{if(e.length===0)return WE;let t=1/0,n=1/0,o=-1/0,a=-1/0;for(let r of e)r.x<t&&(t=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>a&&(a=r.y);return{x:t,y:n,width:o-t,height:a-n}},fF=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,width:t,height:n}),pF=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),Vr=e=>e.x+e.width,Zr=e=>e.y+e.height,nA=e=>e.width<=0||e.height<=0,hF=(e,t)=>{if(nA(e))return t;if(nA(t))return e;let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(Vr(e),Vr(t)),r=Math.max(Zr(e),Zr(t));return{x:n,y:o,width:a-n,height:r-o}},qE=(e,t)=>{let n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),a=Math.min(Vr(e),Vr(t)),r=Math.min(Zr(e),Zr(t));return a<=n||r<=o?null:{x:n,y:o,width:a-n,height:r-o}},mF=(e,t)=>qE(e,t)!==null,oA=(e,t)=>t.x>=e.x&&t.x<=Vr(e)&&t.y>=e.y&&t.y<=Zr(e),yF=(e,t)=>t.x>=e.x&&t.y>=e.y&&Vr(t)<=Vr(e)&&Zr(t)<=Zr(e),gF=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),xF=e=>({x:e.width<0?e.x+e.width:e.x,y:e.height<0?e.y+e.height:e.y,width:Math.abs(e.width),height:Math.abs(e.height)}),bF=(e,t,n=0)=>n===0?e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height:Math.abs(e.x-t.x)<=n&&Math.abs(e.y-t.y)<=n&&Math.abs(e.width-t.width)<=n&&Math.abs(e.height-t.height)<=n;var za={};ho(za,{distanceToSegment:()=>SF,distanceToSegmentSq:()=>rc,pointInPolygon:()=>vF,pointInRect:()=>AF,pointOnPolyline:()=>LF,pointOnSegment:()=>jE});var AF=(e,t)=>oA(t,e),vF=(e,t)=>{if(t.length<3)return!1;let n=!1;for(let o=0,a=t.length-1;o<t.length;a=o++){let r=t[o],s=t[a];if(!r||!s)continue;r.y>e.y!=s.y>e.y&&e.x<(s.x-r.x)*(e.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n},rc=(e,t,n)=>{let o=n.x-t.x,a=n.y-t.y,r=o*o+a*a;if(r===0){let d=e.x-t.x,f=e.y-t.y;return d*d+f*f}let s=((e.x-t.x)*o+(e.y-t.y)*a)/r;s<0?s=0:s>1&&(s=1);let i=t.x+s*o,l=t.y+s*a,c=e.x-i,u=e.y-l;return c*c+u*u},SF=(e,t,n)=>Math.sqrt(rc(e,t,n)),jE=(e,t,n,o=1)=>rc(e,t,n)<=o*o,LF=(e,t,n=1)=>{for(let o=0;o<t.length-1;o++){let a=t[o],r=t[o+1];if(a&&r&&jE(e,a,r,n))return!0}return!1};var cn={};ho(cn,{cubicAt:()=>ri,cubicBounds:()=>wF,flattenCubic:()=>TF,flattenQuadratic:()=>EF,pointOnCubic:()=>CF,pointOnQuadratic:()=>_F,quadraticAt:()=>ai,quadraticBounds:()=>kF});var ai=(e,t,n,o)=>{let a=1-o;return{x:a*a*e.x+2*a*o*t.x+o*o*n.x,y:a*a*e.y+2*a*o*t.y+o*o*n.y}},ri=(e,t,n,o,a)=>{let r=1-a,s=r*r,i=s*r,l=a*a,c=l*a;return{x:i*e.x+3*s*a*t.x+3*r*l*n.x+c*o.x,y:i*e.y+3*s*a*t.y+3*r*l*n.y+c*o.y}},kF=(e,t,n)=>{let o=[e,n];for(let a of VE(e.x,t.x,n.x))o.push(ai(e,t,n,a));for(let a of VE(e.y,t.y,n.y))o.push(ai(e,t,n,a));return x0(o)},wF=(e,t,n,o)=>{let a=[e,o];for(let r of ZE(e.x,t.x,n.x,o.x))a.push(ri(e,t,n,o,r));for(let r of ZE(e.y,t.y,n.y,o.y))a.push(ri(e,t,n,o,r));return x0(a)},_F=(e,t,n,o,a=1,r=32)=>{let s=a*a,i=t;for(let l=1;l<=r;l++){let c=ai(t,n,o,l/r);if(rc(e,i,c)<=s)return!0;i=c}return!1},CF=(e,t,n,o,a,r=1,s=64)=>{let i=r*r,l=t;for(let c=1;c<=s;c++){let u=ri(t,n,o,a,c/s);if(rc(e,l,u)<=i)return!0;l=u}return!1},EF=(e,t,n,o=16)=>{let a=new Array(o+1);for(let r=0;r<=o;r++)a[r]=ai(e,t,n,r/o);return a},TF=(e,t,n,o,a=32)=>{let r=new Array(a+1);for(let s=0;s<=a;s++)r[s]=ri(e,t,n,o,s/a);return r},VE=(e,t,n)=>{let o=e-2*t+n;if(o===0)return[];let a=(e-t)/o;return a>0&&a<1?[a]:[]},ZE=(e,t,n,o)=>{let a=-e+3*t-3*n+o,r=2*(e-2*t+n),s=t-e,i=[];if(Math.abs(a)<1e-12){if(Math.abs(r)>1e-12){let f=-s/r;f>0&&f<1&&i.push(f)}return i}let l=r*r-4*a*s;if(l<0)return i;let c=Math.sqrt(l),u=(-r+c)/(2*a),d=(-r-c)/(2*a);return u>0&&u<1&&i.push(u),d>0&&d<1&&i.push(d),i};var A0={};ho(A0,{lineLine:()=>IF,segmentCubic:()=>RF,segmentQuadratic:()=>MF,segmentSegment:()=>XE});var b0=1e-12,IF=(e,t,n,o)=>{let a=t.x-e.x,r=t.y-e.y,s=o.x-n.x,i=o.y-n.y,l=a*i-r*s;if(Math.abs(l)<b0)return null;let c=n.x-e.x,u=n.y-e.y,d=(c*i-u*s)/l;return{x:e.x+d*a,y:e.y+d*r}},XE=(e,t,n,o)=>{let a=t.x-e.x,r=t.y-e.y,s=o.x-n.x,i=o.y-n.y,l=a*i-r*s;if(Math.abs(l)<b0)return null;let c=n.x-e.x,u=n.y-e.y,d=(c*i-u*s)/l,f=(c*r-u*a)/l;return d<0||d>1||f<0||f>1?null:{x:e.x+d*a,y:e.y+d*r}},MF=(e,t,n,o,a)=>{let r=t.y-e.y,s=-(t.x-e.x),i=-(r*e.x+s*e.y),l=r*n.x+s*n.y,c=r*o.x+s*o.y,u=r*a.x+s*a.y,d=l-2*c+u,f=-2*l+2*c,p=l+i,h=[];if(Math.abs(d)<b0){if(Math.abs(f)>b0){let b=-p/f;b>=0&&b<=1&&h.push(b)}}else{let b=f*f-4*d*p;if(b>=0){let A=Math.sqrt(b),_=(-f+A)/(2*d),T=(-f-A)/(2*d);_>=0&&_<=1&&h.push(_),T>=0&&T<=1&&h.push(T)}}let m=[],x=t.x-e.x,y=t.y-e.y,g=x*x+y*y;for(let b of h){let A=ai(n,o,a,b);if(g===0){m.push(A);continue}let _=((A.x-e.x)*x+(A.y-e.y)*y)/g;_>=0&&_<=1&&m.push(A)}return m},RF=(e,t,n,o,a,r,s=64)=>{let i=[],l=n;for(let c=1;c<=s;c++){let u=ri(n,o,a,r,c/s),d=XE(e,t,l,u);d!==null&&i.push(d),l=u}return i};var v0={};ho(v0,{contrastRatio:()=>iA,format:()=>PF,luminance:()=>sA,meetsContrastAA:()=>zF,meetsContrastAAA:()=>FF,mix:()=>BF,parse:()=>DF,withAlpha:()=>NF});var OF=Object.freeze({transparent:{r:0,g:0,b:0,a:0},black:{r:0,g:0,b:0,a:1},white:{r:255,g:255,b:255,a:1},red:{r:255,g:0,b:0,a:1},green:{r:0,g:128,b:0,a:1},blue:{r:0,g:0,b:255,a:1},yellow:{r:255,g:255,b:0,a:1},cyan:{r:0,g:255,b:255,a:1},magenta:{r:255,g:0,b:255,a:1},gray:{r:128,g:128,b:128,a:1},grey:{r:128,g:128,b:128,a:1}}),DF=e=>{let t=e.trim().toLowerCase(),n=OF[t];if(n!==void 0)return n;if(t.startsWith("#")){let a=t.slice(1);if(a.length===3||a.length===4){let r=Xr(a.charAt(0)+a.charAt(0)),s=Xr(a.charAt(1)+a.charAt(1)),i=Xr(a.charAt(2)+a.charAt(2)),l=a.length===4?Xr(a.charAt(3)+a.charAt(3))/255:1;if(Number.isNaN(r)||Number.isNaN(s)||Number.isNaN(i)||Number.isNaN(l))throw new Error(`Invalid hex color: ${e}`);return{r,g:s,b:i,a:l}}if(a.length===6||a.length===8){let r=Xr(a.slice(0,2)),s=Xr(a.slice(2,4)),i=Xr(a.slice(4,6)),l=a.length===8?Xr(a.slice(6,8))/255:1;if(Number.isNaN(r)||Number.isNaN(s)||Number.isNaN(i)||Number.isNaN(l))throw new Error(`Invalid hex color: ${e}`);return{r,g:s,b:i,a:l}}throw new Error(`Invalid hex color length: ${e}`)}let o=/^rgba?\(([^)]+)\)$/.exec(t);if(o){let a=(o[1]??"").split(",").map(c=>c.trim());if(a.length!==3&&a.length!==4)throw new Error(`Expected 3 or 4 components: ${e}`);let r=Math.round(Number(a[0])),s=Math.round(Number(a[1])),i=Math.round(Number(a[2])),l=a.length===4?Number(a[3]):1;if([r,s,i,l].some(Number.isNaN))throw new Error(`Invalid component: ${e}`);return{r,g:s,b:i,a:l}}throw new Error(`Cannot parse color: ${e}`)},PF=e=>{let t=aA(e.r),n=aA(e.g),o=aA(e.b),a=HF(e.a);return a===1?`#${rA(t)}${rA(n)}${rA(o)}`:`rgba(${t}, ${n}, ${o}, ${a})`},BF=(e,t,n)=>({r:e.r+(t.r-e.r)*n,g:e.g+(t.g-e.g)*n,b:e.b+(t.b-e.b)*n,a:e.a+(t.a-e.a)*n}),NF=(e,t)=>({...e,a:t}),sA=e=>{let t=n=>{let o=n/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)},iA=(e,t)=>{let n=sA(e),o=sA(t),[a,r]=n<o?[n,o]:[o,n];return(r+.05)/(a+.05)},zF=(e,t,n=!1)=>iA(e,t)>=(n?3:4.5),FF=(e,t,n=!1)=>iA(e,t)>=(n?4.5:7),Xr=e=>parseInt(e,16),aA=e=>{let t=Math.round(e);return t<0?0:t>255?255:t},HF=e=>e<0?0:e>1?1:e,rA=e=>e.toString(16).padStart(2,"0");var Mf={};ho(Mf,{offsetClosedPath:()=>UF,signedArea:()=>GF});var UF=(e,t)=>{if(e.length<3||t===0)return e.map(l=>({x:l.x,y:l.y}));let n=0,o=0;for(let l of e)n+=l.x,o+=l.y;n/=e.length,o/=e.length;let a=e.length,r=new Array(a),s=new Array(a);for(let l=0;l<a;l++){let c=v(e[l]),u=v(e[(l+1)%a]),d=u.x-c.x,f=u.y-c.y,p=Math.hypot(d,f)||1;r[l]=-f/p,s[l]=d/p}let i=[];for(let l=0;l<a;l++){let c=(l-1+a)%a,u=v(r[c]),d=v(s[c]),f=v(r[l]),p=v(s[l]),h=u+f,m=d+p,x=Math.hypot(h,m);x<1e-6?(h=u,m=d):(h/=x,m/=x);let y=v(e[l]),g=n-y.x,b=o-y.y,_=h*g+m*b>=0?1:-1,T=h*u+m*d,w=T>1e-6?t/T:t;i.push({x:y.x+_*h*w,y:y.y+_*m*w})}return i},GF=e=>{let t=0;for(let n=0;n<e.length;n++){let o=v(e[n]),a=v(e[(n+1)%e.length]);t+=o.x*a.y-a.x*o.y}return t/2};var lA=e=>{if(!(e.stroke!==void 0&&e.stroke!=="transparent"))return 0;let n=e.strokeWidth??1;if(n<=0)return 0;switch(e.strokeAlign??"center"){case"outside":return n;case"inside":return 0;default:return n/2}},Rf=(e,t,n)=>{if(!e||e.type==="sharp")return 0;let o=Math.min(Math.abs(t),Math.abs(n));if(o<=0)return 0;if(e.value!==void 0)return Math.max(0,Math.min(e.value,o/2));let a=32/.25;return o<=a?o*.25:32};var YE=e=>{if(!e)return"";let t=Object.entries(e).filter(([,n])=>n!==void 0).sort(([n],[o])=>n<o?-1:n>o?1:0);return JSON.stringify(t)},cA=e=>{let t=[];for(let n of e){if(n.text==="")continue;let o=t[t.length-1];o!==void 0&&YE(o.style)===YE(n.style)?t[t.length-1]={text:o.text+n.text,...o.style!==void 0?{style:o.style}:{}}:t.push(n)}return t},KE=e=>{let t=e.runs;return t!==void 0&&t.length>0?cA(t):e.text===""?[]:[{text:e.text}]},Of=(e,t,n)=>{let o=Math.min(t,n),a=Math.max(t,n),r=[],s=0;for(let i of KE(e)){let l=s,c=s+i.text.length;s=c;let u=Math.max(l,o),d=Math.min(c,a);u>=d||r.push({text:i.text.slice(u-l,d-l),...i.style!==void 0?{style:i.style}:{}})}return r},jF=(e,t)=>{let n={...e??{},...t},o=Object.entries(n).filter(([,r])=>r!==void 0);return o.length===0?void 0:Object.fromEntries(o)},uA=(e,t,n,o)=>{let a=Math.max(0,Math.min(t,n)),r=Math.min(e.text.length,Math.max(t,n));if(a>=r)return e;let s=[],i=0;for(let u of KE(e)){let d=i,f=i+u.text.length;i=f;let p=Math.max(d,a),h=Math.min(f,r);if(p>=h){s.push(u);continue}d<p&&s.push({text:u.text.slice(0,p-d),...u.style!==void 0?{style:u.style}:{}});let m=jF(u.style,o);s.push({text:u.text.slice(p-d,h-d),...m!==void 0?{style:m}:{}}),h<f&&s.push({text:u.text.slice(h-d),...u.style!==void 0?{style:u.style}:{}})}let l=cA(s),c=l[0];if(l.length===1&&c!==void 0&&(c.style===void 0||Object.keys(c.style).length===0)){let{runs:u,...d}=e;return d}return{...e,runs:l}};var dA=e=>{if(typeof e!="object"||e===null)return!1;let t=e.kind;return t==="named"||t==="ratio"||t==="absolute"||t==="edge"},si=e=>e.kind==="point"?void 0:e.elementId;var $E=null,fA=e=>{$E=e},pA=()=>$E;var ii=e=>e.type==="rectangle",sc=e=>e.type==="ellipse",Fa=e=>e.type==="polygon",hA=e=>e.type==="path",fe=e=>e.type==="text",ct=e=>e.type==="image";var ze=e=>e.type==="group",Be=e=>e.type==="frame";var Ha=e=>e.type==="brush",Df=e=>e.stroke??e.fill??"#000",QE=new Map,eo=(e,t)=>{QE.set(e,t)};var Re=e=>{let t=QE.get(e.type);if(!t)throw new Error(`No bounder registered for shape type: ${e.type}`);return t(e)},z=e=>{let t=Re(e),n=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}],o=Math.sin(e.rotation),a=Math.cos(e.rotation),r=n.map(s=>{let i=s.x*e.scale.x,l=s.y*e.scale.y;return{x:e.position.x+(i*a-l*o),y:e.position.y+(i*o+l*a)}});return V.fromPoints(r)};eo("rectangle",e=>({x:0,y:0,width:e.width,height:e.height}));eo("ellipse",e=>({x:0,y:0,width:e.width,height:e.height}));eo("polygon",e=>V.fromPoints(e.points));eo("path",e=>{let t=[],n={x:0,y:0};for(let o of e.commands)switch(o.kind){case"M":case"L":t.push(o.to),n=o.to;break;case"Q":t.push(o.control,o.to),n=o.to;break;case"C":t.push(o.control1,o.control2,o.to),n=o.to;break;case"Z":break}return V.fromPoints(t)});eo("text",e=>{let t=e.fontSize*1.2,n=e.text.split(`
|
|
10
|
+
`),o=pA(),a={bold:e.style.fontWeight==="bold",italic:e.style.fontStyle==="italic"},r=i=>{if(o){let l=o(i,e.fontFamily,e.fontSize,a);if(l!==null)return l}return i.length*e.fontSize*.6};if(e.maxWidth===void 0){let i=0;for(let l of n)i=Math.max(i,r(l));return i=Math.max(i,e.fontSize*.5),{x:0,y:0,width:i,height:Math.max(1,n.length)*t}}let s=0;for(let i of n)s+=Math.max(1,Math.ceil(r(i)/e.maxWidth));return{x:0,y:0,width:e.maxWidth,height:Math.max(1,s)*t}});eo("image",e=>({x:0,y:0,width:e.width,height:e.height}));eo("template",e=>({x:0,y:0,width:e.width,height:e.height}));eo("brush",e=>{if(e.points.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,n=1/0,o=-1/0,a=-1/0;for(let r of e.points)r.x-r.width<t&&(t=r.x-r.width),r.y-r.width<n&&(n=r.y-r.width),r.x+r.width>o&&(o=r.x+r.width),r.y+r.width>a&&(a=r.y+r.width);return{x:t,y:n,width:o-t,height:a-n}});eo("group",()=>({x:0,y:0,width:0,height:0}));eo("frame",e=>({x:0,y:0,width:e.width,height:e.height}));eo("block-arrow",e=>({x:0,y:0,width:e.width,height:e.height}));var S0=class{cellSize;cells=new Map;bounds=new Map;constructor(t=256){if(t<=0)throw new Error("cellSize must be positive");this.cellSize=t}get size(){return this.bounds.size}insert(t,n){if(this.bounds.has(t))throw new Error(`Element already indexed: ${t}`);this.bounds.set(t,n),this.eachCell(n,o=>{let a=this.cells.get(o);a||(a=new Set,this.cells.set(o,a)),a.add(t)})}remove(t){let n=this.bounds.get(t);n&&(this.bounds.delete(t),this.eachCell(n,o=>{let a=this.cells.get(o);a&&(a.delete(t),a.size===0&&this.cells.delete(o))}))}update(t,n){this.remove(t),this.insert(t,n)}query(t){let n=new Set;return this.eachCell(t,o=>{let a=this.cells.get(o);if(a)for(let r of a)n.add(r)}),n}clear(){this.cells.clear(),this.bounds.clear()}eachCell(t,n){let o=Math.floor(t.x/this.cellSize),a=Math.floor(t.y/this.cellSize),r=Math.floor((t.x+t.width)/this.cellSize),s=Math.floor((t.y+t.height)/this.cellSize);for(let i=a;i<=s;i++)for(let l=o;l<=r;l++)n(`${l},${i}`)}};var _t=(e,t)=>e.order<t.order?-1:e.order>t.order?1:0,Pf=(e,t)=>_t(t,e);var Mn=(e,t)=>{let n=t.x*e.scale.x,o=t.y*e.scale.y,a=Math.cos(e.rotation),r=Math.sin(e.rotation);return{x:e.position.x+(n*a-o*r),y:e.position.y+(n*r+o*a)}},li=(e,t)=>{let n=t.x-e.position.x,o=t.y-e.position.y,a=Math.cos(e.rotation),r=Math.sin(e.rotation),s=n*a+o*r,i=-n*r+o*a;return{x:e.scale.x===0?0:s/e.scale.x,y:e.scale.y===0?0:i/e.scale.y}};var L0=(e,t,n,o,a)=>{let r=a*Math.PI*2-Math.PI/2;return{x:e+n*Math.cos(r),y:t+o*Math.sin(r)}};var I=(e,t)=>e.elements.get(t),be=(e,t)=>e.links.get(t);var vo=e=>[...e.layers.values()].sort(_t),Ua=(e,t)=>[...e.elements.values()].filter(n=>n.layerId===t).sort(_t),yA=(e,t)=>[...e.links.values()].filter(n=>n.layerId===t).sort(_t),JE=48,k0=10,mA=e=>[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],eT=6,VF=(e,t)=>{let{x:n,y:o,width:a,height:r}=e,s=(l,c,u,d)=>{let f=[];for(let p=0;p<=eT;p++){let h=u+(d-u)*(p/eT);f.push({x:l+t*Math.cos(h),y:c+t*Math.sin(h)})}return f},i=Math.PI/2;return[...s(n+t,o+t,Math.PI,Math.PI+i),...s(n+a-t,o+t,-i,0),...s(n+a-t,o+r-t,0,i),...s(n+t,o+r-t,i,Math.PI)]},ZF=e=>{let t=[],n={x:0,y:0};for(let o of e)if(o.kind==="M"||o.kind==="L")n=o.to,t.push({x:n.x,y:n.y});else if(o.kind==="Q"){for(let a=1;a<=k0;a++){let r=a/k0,s=1-r;t.push({x:s*s*n.x+2*s*r*o.control.x+r*r*o.to.x,y:s*s*n.y+2*s*r*o.control.y+r*r*o.to.y})}n=o.to}else if(o.kind==="C"){for(let a=1;a<=k0;a++){let r=a/k0,s=1-r;t.push({x:s**3*n.x+3*s*s*r*o.control1.x+3*s*r*r*o.control2.x+r**3*o.to.x,y:s**3*n.y+3*s*s*r*o.control1.y+3*s*r*r*o.control2.y+r**3*o.to.y})}n=o.to}return t},XF=new Map;var YF=e=>{if(Fa(e))return[e.points.map(t=>({x:t.x,y:t.y}))];if(sc(e)){let t=Re(e),n=t.x+t.width/2,o=t.y+t.height/2,a=t.width/2,r=t.height/2,s=[];for(let i=0;i<JE;i++)s.push(L0(n,o,a,r,i/JE));return[s]}if(ii(e)){let t=Re(e),n=Rf(e.style.roundness,t.width,t.height);return[n>0?VF(t,n):mA(t)]}return ct(e)||fe(e)?[mA(Re(e))]:hA(e)?[ZF(e.commands)]:null},Bf=(e,t)=>{if(ze(t)){let r=[];for(let s of gA(e,t.id))r.push(...Bf(e,s));return r}let n=YF(t);if(n)return n.map(r=>r.map(s=>Mn(t,s)));let o=XF.get(t.type);if(o){let r=o(t).filter(s=>s.length>=2);if(r.length>0)return r.map(s=>s.map(i=>Mn(t,i)))}let a=z(t);return[mA(a)]},gA=(e,t)=>{let n=[];for(let o of e.elements.values())o.parentId===t&&n.push(o);return n.sort(_t),n},xA=(e,t)=>{let n=t;for(let o=0;n&&o<tT;o++){if(n.locked===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1},ic=(e,t)=>{let n=t;for(let o=0;n&&o<tT;o++){if(n.hidden===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1};var bA=(e,t)=>{let n=e.elements.get(t);if(!n)return[];let o=new Set([t]),a=[n],r=[t];for(;r.length>0;){let s=r.pop();if(s===void 0)break;for(let i of gA(e,s))o.has(i.id)||(o.add(i.id),a.push(i),r.push(i.id))}return a},tT=64;var w0=(e,t,n=.5)=>{let o=[];for(let a of e.elements.values()){let r=z(a);if(!V.intersects(r,t))continue;let s=r.width*r.height;if(s<=0){o.push(a);continue}let i=Math.max(r.x,t.x),l=Math.max(r.y,t.y),c=Math.min(r.x+r.width,t.x+t.width),u=Math.min(r.y+r.height,t.y+t.height),d=c-i,f=u-l;if(d<=0||f<=0)continue;if(d*f/s>=n){o.push(a);continue}let h=t.width*t.height;h>0&&d*f/h>=n&&o.push(a)}return o},ci=(e,t)=>{let n=vo(e);for(let o=n.length-1;o>=0;o--){let a=n[o];if(!a?.visible)continue;let r=Ua(e,a.id);for(let s=r.length-1;s>=0;s--){let i=r[s];if(i!==void 0&&V.contains(z(i),t))return i}}},AA=(e,t)=>{let n=new S0(t);for(let o of e.elements.values())n.insert(o.id,z(o));return n};var vA=(e,t,n)=>{let o={x:n.x,y:n.y,width:0,height:0},a=t.query(o);if(a.size===0)return;let r,s="",i="",l=!1;for(let c of a){let u=e.elements.get(c);if(!u||!V.contains(z(u),n))continue;let d=e.layers.get(u.layerId);if(!d?.visible)continue;let f=d.order;(!l||f>s||f===s&&u.order>i)&&(r=u,s=f,i=u.order,l=!0)}return r};var KF=[];var Nf=e=>ui(e)!==null,ui=e=>{for(let s of KF){let i=s(e);if(i)return i}let t=e.metadata,n=e;if(t?.autoLayout!=null&&typeof n.width=="number"&&typeof n.height=="number"){let s=t.container?.padding??$F,i=n.width,l=n.height;return{dropZone:{x:s,y:s,width:Math.max(0,i-2*s),height:Math.max(0,l-2*s)},padding:s}}let o=e.metadata?.container;if(!o||typeof o!="object")return null;let a=o;return a.dropZone?a.padding!==void 0?{dropZone:a.dropZone,padding:a.padding}:{dropZone:a.dropZone}:null},$F=0,to=e=>{let t=ui(e);return t?{x:e.position.x+t.dropZone.x,y:e.position.y+t.dropZone.y,width:t.dropZone.width,height:t.dropZone.height}:null},QF=[];var SA=e=>{for(let n of QF){let o=n(e);if(o)return o.map(a=>({x:e.position.x+a.x,y:e.position.y+a.y,width:a.width,height:a.height}))}let t=to(e);return t?[t]:[]},zf=(e,t,n=new Set)=>{let o=vo(e);for(let a=o.length-1;a>=0;a--){let r=o[a];if(!r?.visible)continue;let s=Ua(e,r.id);for(let i=s.length-1;i>=0;i--){let l=s[i];if(l===void 0||n.has(l.id))continue;let c=to(l);if(c&&V.contains(c,t))return l}}return null},LA=(e,t)=>{let n=ui(e);if(!n)return null;let o=n.padding??0,a={x:t.x-e.position.x,y:t.y-e.position.y,width:t.width,height:t.height},r=n.dropZone,s=a.x,i=a.y,l=a.x+a.width,c=a.y+a.height,u=r.x,d=r.y,f=r.x+r.width,p=r.y+r.height,h=s<u?s-o:u,m=i<d?i-o:d,x=l>f?l+o:f,y=c>p?c+o:p;return h===u&&m===d&&x===f&&y===p?null:{x:h,y:m,width:x-h,height:y-m}},kA=(e,t)=>{let n=e.spec.dropZone,o=n.x-t.x,a=n.y-t.y,r=t.x+t.width-(n.x+n.width),s=t.y+t.height-(n.y+n.height);return{width:e.width+o+r,height:e.height+a+s,positionOffset:{x:-o,y:-a}}};var nT=new Set,wA={"top-left":{x:0,y:0},top:{x:.5,y:0},"top-right":{x:1,y:0},right:{x:1,y:.5},"bottom-right":{x:1,y:1},bottom:{x:.5,y:1},"bottom-left":{x:0,y:1},left:{x:0,y:.5},center:{x:.5,y:.5}},oT=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left","center"];var aT=(e,t)=>_A(e,t),Yt=(e,t)=>{let n=aT(e,t),o=n.x*e.scale.x,a=n.y*e.scale.y,r=Math.cos(e.rotation),s=Math.sin(e.rotation);return{x:e.position.x+(o*r-a*s),y:e.position.y+(o*s+a*r)}},jo=(e,t)=>{let n=Yt(e,t),o=Yt(e,{kind:"named",name:"center"}),a=n.x-o.x,r=n.y-o.y,s=Math.hypot(a,r);return s<1e-6?{x:0,y:-1}:{x:a/s,y:r/s}},Ga=(e,t,n=nT)=>{let o=null;for(let[a,r]of _0(e)){if(n.has(a))continue;let s=JF(a),i=Yt(e,s),l=i.x-t.x,c=i.y-t.y,u=Math.hypot(l,c);(o===null||u<o.distance)&&(o={ref:s,world:i,distance:u})}return o||{ref:{kind:"named",name:"center"},world:Yt(e,{kind:"named",name:"center"}),distance:1/0}},JF=e=>{let t=/^edge-(\d+)$/.exec(e);return t?{kind:"edge",index:Number(t[1]),t:.5}:{kind:"named",name:e}},So=e=>Nf(e)?eH:nT,eH=new Set(["center"]);var _0=e=>{let t=new Map;if(Fa(e))tH(e,t);else{let n=Re(e);for(let o of rT){let a=wA[o];t.set(o,{x:n.x+n.width*a.x,y:n.y+n.height*a.y})}}if(e.anchors)for(let[n,o]of Object.entries(e.anchors))t.set(n,_A(e,o));return t},rT=["top","right","bottom","left"],tH=(e,t)=>{let n=e.points;if(!(n.length<2))for(let o=0;o<n.length;o++){let a=n[o],r=n[(o+1)%n.length];a===void 0||r===void 0||t.set(`edge-${o}`,U.midpoint(a,r))}},_A=(e,t)=>{switch(t.kind){case"named":{let n=iT(e,t.name);if(!n)throw new Error(`Unknown anchor "${t.name}" on shape ${e.id} (type ${e.type}). Standard names: ${oT.join(", ")}; custom anchors live on shape.anchors.`);return n}case"ratio":{let n=Re(e);return{x:n.x+n.width*t.position.x,y:n.y+n.height*t.position.y}}case"absolute":{let n=Re(e);return{x:n.x+t.offset.x,y:n.y+t.offset.y}}case"edge":return sT(e,t.index,t.t)}},sT=(e,t,n)=>{if(Fa(e)&&e.points.length>=2){let a=e.points,r=a.length,s=(t%r+r)%r,i=a[s],l=a[(s+1)%r];if(i!==void 0&&l!==void 0){let c=n<0?0:n>1?1:n;return{x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}}}let o=Re(e);return{x:o.x+o.width/2,y:o.y+o.height/2}},iT=(e,t)=>{let n=e.anchors?.[t];if(n!==void 0)return n.kind==="named"?iT(e,n.name):_A(e,n);if(Fa(e)&&t.startsWith("edge-")){let r=parseInt(t.slice(5),10);if(!isNaN(r))return sT(e,r,.5)}let o=wA[t];if(!o)return;let a=Re(e);return{x:a.x+a.width*o.x,y:a.y+a.height*o.y}};var CA=(e,t,n,o)=>{let a=Math.hypot(t.x-e.x,t.y-e.y),r=Math.min(a*.8,240);return{c1:{x:e.x+n.x*r,y:e.y+n.y*r},c2:{x:t.x+o.x*r,y:t.y+o.y*r},to:t}},Ff=e=>{let t=[],n=6;for(let o=0;o<e.length-1;o++){let a=v(e[o]),r=v(e[o+1]),s=e[o-1]??a,i=e[o+2]??r;t.push({c1:{x:a.x+(r.x-s.x)/n,y:a.y+(r.y-s.y)/n},c2:{x:r.x-(i.x-a.x)/n,y:r.y-(i.y-a.y)/n},to:r})}return t},Hf=(e,t,n=16)=>{let o=[e],a=e;for(let r of t){for(let s=1;s<=n;s++)o.push(cn.cubicAt(a,r.c1,r.c2,r.to,s/n));a=r.to}return o};var lc={x:1,y:0},Uf={x:0,y:1},Gf={x:-1,y:0},Wf={x:0,y:-1},lT=e=>e.y===0;var nH=e=>{let t=Math.abs(e.x),n=Math.abs(e.y);return e.x>n?lc:e.x<=-n?Gf:e.y>t?Uf:Wf},qf=(e,t)=>nH({x:e.x-t.x,y:e.y-t.y}),C0=(e,t)=>{let n=z(e),o=Math.abs(t.x-n.x),a=Math.abs(n.x+n.width-t.x),r=Math.abs(t.y-n.y),s=Math.abs(n.y+n.height-t.y),i=Math.min(o,a,r,s);return i===o?Gf:i===a?lc:i===r?Wf:Uf},cT=(e,t)=>{let n=z(e),o=n.x+n.width/2,a=n.y+n.height/2,r=t.x-o,s=t.y-a;if(r===0&&s===0)return lc;let i=n.width||1,l=n.height||1,c=r/(i/2),u=s/(l/2);return Math.abs(c)>=Math.abs(u)?c>=0?lc:Gf:u>=0?Uf:Wf};var E0=new Map,EA=(e,t)=>{E0.set(e,t)},uT=e=>E0.get(e),T0=(e,t)=>{let n=E0.get(e.type);if(!n)throw new Error(`No outline sampler registered for shape type: ${e.type}`);let o=n(e,ac.clamp01(t));return Mn(e,o)},dT=(e,t,n=64)=>{let o=E0.get(e.type);if(!o)return null;let a=0,r=Mn(e,o(e,0)),s=U.distance(t,r);for(let i=1;i<n;i++){let l=i/n,c=Mn(e,o(e,l)),u=U.distance(t,c);u<s&&(s=u,a=l,r=c)}return{ratio:a,world:r,distance:s}},fT=(e,t)=>{if(e.length===0)return{x:0,y:0};if(e.length===1)return v(e[0]);let n=0,o=[];for(let r=0;r<e.length;r++){let s=v(e[r]),i=v(e[(r+1)%e.length]),l=U.distance(s,i);o.push(l),n+=l}if(n===0)return v(e[0]);let a=n*t;for(let r=0;r<e.length;r++){let s=v(o[r]);if(a<=s){let i=v(e[r]),l=v(e[(r+1)%e.length]),c=s===0?0:a/s;return{x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}}a-=s}return v(e[0])};EA("rectangle",(e,t)=>{let n=Re(e),o=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}];return fT(o,t)});EA("ellipse",(e,t)=>{let n=Re(e),o=n.x+n.width/2,a=n.y+n.height/2,r=n.width/2,s=n.height/2;return L0(o,a,r,s,t)});EA("polygon",(e,t)=>fT(e.points,t));var pT=e=>e.kind==="point"?null:e.elementId,hT=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:Math.sign(e.x)||0,y:0}:{x:0,y:Math.sign(e.y)},mT=(e,t,n)=>{if(t.kind==="anchor"){let a=hT(jo(e,t.anchor));if(a.x!==0||a.y!==0)return a}let o=hT(C0(e,n));return o.x!==0||o.y!==0?o:{x:0,y:-1}},sH=(e,t)=>{let n=e.x+e.width/2,o=e.y+e.height/2;return t.y<0?{x:n,y:e.y}:t.y>0?{x:n,y:e.y+e.height}:t.x<0?{x:e.x,y:o}:{x:e.x+e.width,y:o}},IA=(e,t)=>{let n=pT(t.from);if(!n||n!==pT(t.to))return null;let o=I(e,n);if(!o)return null;let a=z(o),r=no(e,t.from),s=no(e,t.to);if(!r||!s)return null;let i=r,l=s,c=mT(o,t.from,i),u=mT(o,t.to,l);if(Math.hypot(l.x-i.x,l.y-i.y)<1){let d=c.x!==0||c.y!==0?c:{x:0,y:-1};c=d,u=d;let f={x:-d.y,y:d.x},p=d.x!==0?a.height:a.width,h=Math.min(24,p/3),m=sH(a,d);i={x:m.x-f.x*h,y:m.y-f.y*h},l={x:m.x+f.x*h,y:m.y+f.y*h}}return{p1:i,n1:c,p2:l,n2:u,bounds:a}},iH=e=>{let t=40,{p1:n,n1:o,p2:a,n2:r,bounds:s}=e,i={x:n.x+o.x*t,y:n.y+o.y*t},l={x:a.x+r.x*t,y:a.y+r.y*t},c=o.x===r.x&&o.y===r.y,u=o.x===-r.x&&o.y===-r.y;if(c)return[n,i,l,a];if(u){if(o.x===0){let p=s.x+s.width+t;return[n,i,{x:p,y:i.y},{x:p,y:l.y},l,a]}let f=s.y+s.height+t;return[n,i,{x:i.x,y:f},{x:l.x,y:f},l,a]}let d={x:o.y!==0?l.x:i.x,y:o.y!==0?i.y:l.y};return[n,i,d,l,a]},lH=e=>{let t=40*2.2,{p1:n,n1:o,p2:a,n2:r}=e;return{start:n,segments:[{c1:{x:n.x+o.x*t,y:n.y+o.y*t},c2:{x:a.x+r.x*t,y:a.y+r.y*t},to:a}]}},gT=e=>{let t=z(e);return{x:t.x+t.width/2,y:t.y+t.height/2}},cH=(e,t)=>{let n=gT(e),o=t.x-n.x,a=t.y-n.y;if(Math.abs(o)<1e-6&&Math.abs(a)<1e-6||!uT(e.type))return n;let s=Math.hypot(o,a),i={x:n.x+o/s*1e6,y:n.y+a/s*1e6},l=null,c=1/0,u=T0(e,0);for(let d=1;d<=96;d++){let f=T0(e,d/96),p=A0.segmentSegment(n,i,u,f);if(p){let h=Math.hypot(p.x-t.x,p.y-t.y);h<c&&(c=h,l=p)}u=f}return l??n},no=(e,t,n)=>{if(t.kind==="point")return t.position;let o=I(e,t.elementId);return o?t.kind==="anchor"?Yt(o,t.anchor):t.kind==="floating"?cH(o,n??gT(o)):T0(o,t.ratio):null},ot=(e,t)=>{let n=IA(e,t);if(n)return iH(n);let o=no(e,t.from);if(!o)return null;let a=no(e,t.to);if(!a)return null;let r=t.from.kind==="floating"?no(e,t.from,a)??o:o,s=t.to.kind==="floating"?no(e,t.to,o)??a:a;return(t.routing??"straight")!=="orthogonal"?[r,...t.waypoints??[],s]:t.routedPoints!==void 0?[r,...t.routedPoints,s]:xT(r,s,TA(t.from),TA(t.to))},xT=(e,t,n,o)=>{let a=Math.min(40,Math.max(8,Math.abs(t.x-e.x)/4,Math.abs(t.y-e.y)/4));if(n||o){let c=[e],u=e,d=t;n&&(u={x:e.x+n.x*a,y:e.y+n.y*a},c.push(u));let f=null;o&&(f={x:t.x+o.x*a,y:t.y+o.y*a});let p=f??d,h=p.x-u.x,m=p.y-u.y,x=n?Math.abs(n.x)>Math.abs(n.y):Math.abs(h)>=Math.abs(m);if(Math.abs(h)>.5&&Math.abs(m)>.5){let y=x?{x:p.x,y:u.y}:{x:u.x,y:p.y};c.push(y)}return f&&c.push(f),c.push(t),c}let r=t.x-e.x,s=t.y-e.y,l=Math.abs(r)>=Math.abs(s)?{x:t.x,y:e.y}:{x:e.x,y:t.y};return[e,l,t]},TA=e=>{if(e.kind!=="anchor"||e.anchor.kind!=="named")return null;switch(e.anchor.name){case"top":return{x:0,y:-1};case"right":return{x:1,y:0};case"bottom":return{x:0,y:1};case"left":return{x:-1,y:0};default:return null}},yT=(e,t,n)=>{let o=TA(e);if(o)return o;let a=n.x-t.x,r=n.y-t.y;return Math.abs(a)>=Math.abs(r)?{x:Math.sign(a)||1,y:0}:{x:0,y:Math.sign(r)||1}},jf=(e,t)=>{if((t.routing??"straight")!=="bezier")return null;let n=IA(e,t);if(n)return lH(n);let o=ot(e,t);if(!o||o.length<2)return null;let a=v(o[0]),r=v(o[o.length-1]);if(o.length===2){let s=yT(t.from,a,r),i=yT(t.to,r,a);return{start:a,segments:[CA(a,r,s,i)]}}return{start:a,segments:Ff(o)}},cc=(e,t)=>{if((t.routing??"straight")!=="bezier")return ot(e,t);let n=jf(e,t);return n?Hf(n.start,n.segments):null},Vf=(e,t)=>{let n=t.routing??"straight";if(n==="orthogonal")return null;if(n==="bezier"){let r=jf(e,t);if(!r)return null;let s=[],i=r.start;for(let l of r.segments)s.push(cn.cubicAt(i,l.c1,l.c2,l.to,.5)),i=l.to;return s}let o=ot(e,t);if(!o||o.length<2)return null;let a=[];for(let r=0;r<o.length-1;r++){let s=v(o[r]),i=v(o[r+1]);a.push(U.midpoint(s,i))}return a},MA=(e,t,n=5)=>{let o=null;for(let a of e.links.values()){let r=cc(e,a);if(!r)continue;let s=1/0;for(let i=1;i<r.length;i++){let l=za.distanceToSegment(t,v(r[i-1]),v(r[i]));l<s&&(s=l)}s>n||(!o||s<=o.distance)&&(o={edge:a,distance:s})}return o?.edge??null};var Zf=e=>{let t=e.length;if(t<2)return[];let n=d=>{let f=v(e[d]);return{x:f.x,y:f.y}},o=d=>v(e[d]).width,a=[],r=[];for(let d=0;d<t-1;d++){let f=U.sub(n(d+1),n(d)),p=U.lengthSq(f)>0?U.normalize(f):{x:1,y:0};a.push(p),r.push(U.perp(p))}let s=[],i=[];for(let d=0;d<t;d++){let f=o(d),p=n(d);if(d===0){let y=v(r[0]);s.push(U.add(p,U.mul(y,f))),i.push(U.sub(p,U.mul(y,f)));continue}if(d===t-1){let y=v(r[t-2]);s.push(U.add(p,U.mul(y,f))),i.push(U.sub(p,U.mul(y,f)));continue}let h=v(r[d-1]),m=v(r[d]),x=U.cross(v(a[d-1]),v(a[d]));if(Math.abs(x)<1e-9){s.push(U.add(p,U.mul(h,f))),i.push(U.sub(p,U.mul(h,f)));continue}x>0?(s.push(...bT(p,h,m,f,1)),i.push(...AT(p,h,m,f,-1))):(s.push(...AT(p,h,m,f,1)),i.push(...bT(p,h,m,f,-1)))}let l=vT(n(t-1),v(r[t-2]),o(t-1),!1),c=vT(n(0),v(r[0]),o(0),!0),u=[];for(let d of s)u.push(d);for(let d of l)u.push(d);for(let d=i.length-1;d>=0;d--)u.push(v(i[d]));for(let d of c)u.push(d);return u},bT=(e,t,n,o,a)=>{let r=U.normalize(U.add(t,n)),s=U.dot(r,t);return s>.001&&1/s<=2.5?[U.add(e,U.mul(r,a*(o/s)))]:[U.add(e,U.mul(t,a*o)),U.add(e,U.mul(n,a*o))]},AT=(e,t,n,o,a)=>ST(e,o,U.angle(U.mul(t,a)),U.angle(U.mul(n,a))),vT=(e,t,n,o)=>{let a=U.angle(t)+(o?Math.PI:0);return ST(e,n,a,a-Math.PI)},ST=(e,t,n,o)=>{let a=o-n;for(;a>Math.PI+1e-9;)a-=2*Math.PI;for(;a<-Math.PI-1e-9;)a+=2*Math.PI;let r=Math.max(1,Math.ceil(Math.abs(a)/.35)),s=[];for(let i=0;i<=r;i++){let l=n+a*i/r;s.push({x:e.x+t*Math.cos(l),y:e.y+t*Math.sin(l)})}return s};var LT=new Map,RA=(e,t)=>{LT.set(e,t)},Xf=e=>{let t=z(e),n=LT.get(e.type);if(!n)return t;let o=n(e),a=o.top??0,r=o.right??0,s=o.bottom??0,i=o.left??0;return a===0&&r===0&&s===0&&i===0?t:{x:t.x-i,y:t.y-a,width:t.width+i+r,height:t.height+a+s}};var Yf=class{contributors;constructor(t){this.contributors=t}snap(t){let n=[];for(let o of this.contributors)for(let a of o.contribute(t))a.distance<=t.threshold*t.threshold&&n.push(a);return n.sort((o,a)=>o.distance-a.distance),{best:n[0]??null,all:n}}},DA={id:"grid",contribute(e){if(!e.scene.viewport.gridEnabled)return[];let t=20,n={x:Math.round(e.probe.x/t)*t,y:Math.round(e.probe.y/t)*t},o=n.x-e.probe.x,a=n.y-e.probe.y;return[{snapped:n,distance:o*o+a*a,kind:"grid"}]}},PA={id:"anchor",contribute(e){if(e.gesture!=="draw-edge"&&e.gesture!=="edit-edge-endpoint")return[];let t=[];for(let n of e.scene.elements.values()){if(e.excludeElementIds?.has(n.id)||!kT(n,e.probe,e.threshold))continue;let o=Ga(n,e.probe,So(n)),a=o.world.x-e.probe.x,r=o.world.y-e.probe.y;t.push({snapped:o.world,distance:a*a+r*r,kind:"anchor",metadata:{elementId:n.id,ref:o.ref}})}return t}},BA={id:"outline",contribute(e){if(e.gesture!=="draw-edge"&&e.gesture!=="edit-edge-endpoint")return[];let t=[];for(let n of e.scene.elements.values()){if(e.excludeElementIds?.has(n.id)||!kT(n,e.probe,e.threshold))continue;let o=dT(n,e.probe);if(!o)continue;let a=o.world.x-e.probe.x,r=o.world.y-e.probe.y;t.push({snapped:o.world,distance:a*a+r*r,kind:"outline",metadata:{elementId:n.id,ratio:o.ratio}})}return t}},kT=(e,t,n)=>{let o=n,a=t.x-e.position.x,r=t.y-e.position.y;return Math.abs(a)<=1e3+o&&Math.abs(r)<=1e3+o};var NA=()=>20,I0=e=>e.snapToGrid??!0,zA=Object.freeze({pan:{x:0,y:0},zoom:1,rotation:0,size:{width:0,height:0},gridEnabled:!1}),oo=e=>{let t=N.translation(-e.pan.x,-e.pan.y),n=N.rotation(e.rotation),o=N.scaling(e.zoom);return N.multiply(o,N.multiply(n,t))},Wa=e=>N.inverse(oo(e)),FA=(e,t)=>({...e,pan:{x:e.pan.x-t.x/e.zoom,y:e.pan.y-t.y/e.zoom}}),M0=(e,t,n)=>{let o=e.zoom*t;return{...e,zoom:o,pan:{x:n.x-(n.x-e.pan.x)/t,y:n.y-(n.y-e.pan.y)/t}}},HA=(e,t,n)=>({...e,size:{width:t,height:n}});var Ct=class extends Error{name="FractionalIndexError"};var R0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function wT(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw new Ct("invalid order key head: "+e)}function _T(e){let t=e.charAt(0);if(e.length!==wT(t))throw new Ct("invalid integer part of order key: "+e)}function uc(e){let t=wT(e.charAt(0));if(t>e.length)throw new Ct("invalid order key: "+e);return e.slice(0,t)}function UA(e,t){_T(e);let n=t.charAt(0),[o,...a]=e.split("");if(o===void 0)throw new Ct("invalid integer part of order key: "+e);let r=!0;for(let s=a.length-1;r&&s>=0;s--){let i=a[s];if(i===void 0)continue;let l=t.indexOf(i)+1;l===t.length?a[s]=n:(a[s]=t.charAt(l),r=!1)}if(r){if(o==="Z")return"a"+n;if(o==="z")return null;let s=String.fromCharCode(o.charCodeAt(0)+1);return s>"a"?a.push(n):a.pop(),s+a.join("")}return o+a.join("")}function CT(e,t){_T(e);let[n,...o]=e.split("");if(n===void 0)throw new Ct("invalid integer part of order key: "+e);let a=t.slice(-1),r=!0;for(let s=o.length-1;r&&s>=0;s--){let i=o[s];if(i===void 0)continue;let l=t.indexOf(i)-1;l===-1?o[s]=a:(o[s]=t.charAt(l),r=!1)}if(r){if(n==="a")return"Z"+a;if(n==="A")return null;let s=String.fromCharCode(n.charCodeAt(0)-1);return s<"Z"?o.push(a):o.pop(),s+o.join("")}return n+o.join("")}function di(e,t,n){let o=n.charAt(0);if(t!==null&&e>=t)throw new Ct(e+" >= "+t);if(e.slice(-1)===o||t!==null&&t.slice(-1)===o)throw new Ct("trailing zero");if(t!==null){let s=0;for(;(e.charAt(s)||o)===t.charAt(s);)s++;if(s>0)return t.slice(0,s)+di(e.slice(s),t.slice(s),n)}let a=e?n.indexOf(e.charAt(0)):0,r=t!==null?n.indexOf(t.charAt(0)):n.length;if(r-a>1){let s=Math.round(.5*(a+r));return n.charAt(s)}return t!==null&&t.length>1?t.slice(0,1):n.charAt(a)+di(e.slice(1),null,n)}function ET(e){return"A"+e.charAt(0).repeat(26)}function dH(e){return"a"+e.charAt(0)}function GA(e,t=R0){if(e===ET(t))throw new Ct("invalid order key: "+e);let n=uc(e);if(e.slice(n.length).slice(-1)===t.charAt(0))throw new Ct("invalid order key: "+e)}function ao(e,t,n=R0){let o=e??null,a=t??null;if(o!==null&&GA(o,n),a!==null&&GA(a,n),o!==null&&a!==null&&o>=a)throw new Ct(o+" >= "+a);if(o===null&&a===null)return dH(n);if(o===null){let u=uc(a),d=a.slice(u.length);if(u===ET(n))return u+di("",d,n);if(u<a)return u;let f=CT(u,n);if(f===null)throw new Ct("cannot decrement any more");return f}if(a===null){let u=uc(o),d=o.slice(u.length),f=UA(u,n);return f===null?u+di(d,null,n):f}let r=uc(o),s=o.slice(r.length),i=uc(a),l=a.slice(i.length);if(r===i)return r+di(s,l,n);let c=UA(r,n);if(c===null)throw new Ct("cannot increment any more");return c<a?c:r+di(s,null,n)}function Kf(e,t,n,o=R0){if(!Number.isInteger(n)||n<0)throw new Ct(`n must be a non-negative integer, got ${n}`);if(n===0)return[];if(n===1)return[ao(e,t,o)];let a=e??null,r=t??null;if(r===null){let l=ao(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=ao(l,r,o),c.push(l);return c}if(a===null){let l=ao(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=ao(a,l,o),c.push(l);return c.reverse(),c}let s=Math.floor(n/2),i=ao(a,r,o);return[...Kf(a,i,s,o),i,...Kf(i,r,n-s-1,o)]}var Rn=ln("default"),fH=()=>({id:Rn,name:"Default",visible:!0,locked:!1,order:ao(null,null)}),un=Object.freeze({elements:new Map,links:new Map,layers:new Map([[Rn,fH()]]),annotations:new Map,files:new Map,viewport:zA}),WA=()=>({elements:new Map(un.elements),links:new Map(un.links),layers:new Map(un.layers),annotations:new Map(un.annotations),files:new Map(un.files),viewport:un.viewport});var O0=(e,t)=>e.files.get(t),Q=(e,t)=>{switch(t.kind){case"element":{let n=new Map(e.elements);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,elements:n}}case"link":{let n=new Map(e.links);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,links:n}}case"layer":{let n=new Map(e.layers);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,layers:n}}case"annotation":{let n=new Map(e.annotations);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,annotations:n}}case"viewport":return{...e,viewport:t.after};case"file":{let n=new Map(e.files);return t.after===null?n.delete(t.id):n.set(t.id,t.after),{...e,files:n}}case"batch":return t.patches.reduce(Q,e)}},Ae=e=>{let t=null;for(let n of e)(t===null||n>t)&&(t=n);return ao(t,null)},dc=e=>{let t=null;for(let n of e)(t===null||n<t)&&(t=n);return ao(null,t)},fc=(e,t)=>ao(e,t),qA=(e,t,n)=>Kf(e,t,n);var jA={pan:"browser",zoom:"browser",rotation:"browser",size:"ephemeral",gridEnabled:"export",gridStyle:"export",snapToGrid:"export"},TT=Object.keys(jA),Tae=TT.filter(e=>jA[e]==="ephemeral"),pH=(e,...t)=>{let n=e;for(let o of t)if(o)for(let a of TT)o[a]!==void 0&&(n={...n,[a]:o[a]});return n},VA=(e={})=>{let{saved:t,hostSettings:n}=e;return{elements:new Map(t?.elements??un.elements),links:new Map(t?.links??un.links),layers:new Map(t?.layers??un.layers),annotations:new Map(t?.annotations??un.annotations),files:new Map(t?.files??un.files),viewport:pH(un.viewport,n?.viewport,t?.viewport)}};var ZA=(e,t,n={})=>({id:e,data:t,mime:n.mime??"application/octet-stream",createdAt:n.createdAt??Date.now(),...n.name!==void 0?{name:n.name}:{}});var pc=e=>{switch(e.kind){case"element":return{kind:"element",id:e.id,before:e.after,after:e.before};case"link":return{kind:"link",id:e.id,before:e.after,after:e.before};case"layer":return{kind:"layer",id:e.id,before:e.after,after:e.before};case"annotation":return{kind:"annotation",id:e.id,before:e.after,after:e.before};case"viewport":return{kind:"viewport",before:e.after,after:e.before};case"file":return{kind:"file",id:e.id,before:e.after,after:e.before};case"batch":return{kind:"batch",patches:e.patches.map(pc).reverse()}}},Vo=e=>{let t=[];for(let n of e)n.kind==="batch"?t.push(...n.patches):t.push(n);return{kind:"batch",patches:t}},Yr=e=>{switch(e.kind){case"element":case"link":case"layer":case"annotation":case"file":return e.before===e.after;case"viewport":return e.before===e.after;case"batch":return e.patches.length===0||e.patches.every(Yr)}};var Fe=(e,t)=>{if(e.elements.has(t.id))throw new Error(`Element already exists: ${t.id}`);let n={kind:"element",id:t.id,before:null,after:t};return{scene:Q(e,n),patch:n}},dn=(e,t)=>{let n=e.elements.get(t);if(!n)throw new Error(`Element not found: ${t}`);let o={kind:"element",id:t,before:n,after:null};return{scene:Q(e,o),patch:o}},J=(e,t,n)=>{let o=e.elements.get(t);if(!o)throw new Error(`Element not found: ${t}`);let a=n(o),r={kind:"element",id:t,before:o,after:a};return{scene:Q(e,r),patch:r}};var fi=(e,t)=>{if(e.links.has(t.id))throw new Error(`Link already exists: ${t.id}`);let n={kind:"link",id:t.id,before:null,after:t};return{scene:Q(e,n),patch:n}},pi=(e,t)=>{let n=e.links.get(t);if(!n)throw new Error(`Link not found: ${t}`);let o={kind:"link",id:t,before:n,after:null};return{scene:Q(e,o),patch:o}},et=(e,t,n)=>{let o=e.links.get(t);if(!o)throw new Error(`Link not found: ${t}`);let a=n(o),r={kind:"link",id:t,before:o,after:a};return{scene:Q(e,r),patch:r}},XA=(e,t)=>{if(e.layers.has(t.id))throw new Error(`Layer already exists: ${t.id}`);let n={kind:"layer",id:t.id,before:null,after:t};return{scene:Q(e,n),patch:n}},YA=(e,t)=>{let n=e.layers.get(t);if(!n)throw new Error(`Layer not found: ${t}`);let o={kind:"layer",id:t,before:n,after:null};return{scene:Q(e,o),patch:o}},$f=(e,t,n)=>{let o=e.layers.get(t);if(!o)throw new Error(`Layer not found: ${t}`);let a=n(o),r={kind:"layer",id:t,before:o,after:a};return{scene:Q(e,r),patch:r}},KA=(e,t)=>{if(e.annotations.has(t.id))throw new Error(`Annotation already exists: ${t.id}`);let n={kind:"annotation",id:t.id,before:null,after:t};return{scene:Q(e,n),patch:n}},$A=(e,t)=>{let n=e.annotations.get(t);if(!n)throw new Error(`Annotation not found: ${t}`);let o={kind:"annotation",id:t,before:n,after:null};return{scene:Q(e,o),patch:o}},qa=(e,t,n)=>{let o=e.annotations.get(t);if(!o)throw new Error(`Annotation not found: ${t}`);let a=n(o),r={kind:"annotation",id:t,before:o,after:a};return{scene:Q(e,r),patch:r}};var Kr=(e,t)=>{if(t.elementId===null)return t.position;let n=I(e,t.elementId);return n?{x:n.position.x+t.position.x,y:n.position.y+t.position.y}:t.position};var IT=new Map,QA=(e,t)=>{IT.set(e,t)},JA=e=>{let t=IT.get(e.type);if(t){let n=t(e).trim();if(n)return n}return MT(e.type)},MT=e=>e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).replace(/[-_]/g," ");QA("text",e=>{let t=e.text.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,77)}\u2026`:t});QA("template",e=>{let t=e.metadata?.label;return typeof t=="string"&&t.trim()?t.trim():MT(e.templateId)});var RT=new Map,e2=e=>{RT.set(e.kind,e)};var D0=e=>RT.get(e);var Qf=e=>{try{let t=Re(e);return{width:t.width*Math.abs(e.scale.x),height:t.height*Math.abs(e.scale.y)}}catch{return{width:0,height:0}}},P0=(e,t)=>{if(t.shapeIds.length===0||t.cols<1)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=[];for(let d of t.shapeIds){let f=I(e,d);f&&a.push(f)}a.sort(_t);let r=a.map(Qf),s=r.reduce((d,f)=>Math.max(d,f.width),0),i=r.reduce((d,f)=>Math.max(d,f.height),0),l={x:s+n,y:i+n},c=[],u=e;return a.forEach((d,f)=>{let p=f%t.cols,h=Math.floor(f/t.cols),m={x:o.x+p*l.x,y:o.y+h*l.y};if(d.position.x===m.x&&d.position.y===m.y)return;let x=J(u,d.id,y=>({...y,position:m}));u=x.scene,c.push(x.patch)}),c.length===0?null:Vo(c)},B0=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=[];for(let l of t.shapeIds){let c=I(e,l);c&&a.push(c)}a.sort(_t);let r=[],s=e,i={x:o.x,y:o.y};for(let l of a){let{width:c,height:u}=Qf(l);if(l.position.x!==i.x||l.position.y!==i.y){let d=i,f=J(s,l.id,p=>({...p,position:d}));s=f.scene,r.push(f.patch)}t.direction==="horizontal"?i={x:i.x+c+n,y:i.y}:i={x:i.x,y:i.y+u+n}}return r.length===0?null:Vo(r)},OT=(e,t,n,o)=>{let a=[],r=o.x,s=o.y,i=0,l=0,c=0,u=!0;for(let d of e)l=Math.max(l,d.w),!u&&r-o.x+d.w>n+1e-6&&(c=Math.max(c,r-t-o.x),r=o.x,s+=i+t,i=0,u=!0),a.push({id:d.id,x:r,y:s}),r+=d.w+t,i=Math.max(i,d.h),u=!1;return c=Math.max(c,r-t-o.x),{placements:a,widest:l,contentWidth:Math.max(0,c),contentHeight:s+i-o.y}},DT=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(a)}return n.sort(_t),n.map(o=>{let a=Qf(o);return{id:o.id,w:a.width,h:a.height}})},PT=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=DT(e,t.shapeIds),{placements:r}=OT(a,n,t.innerWidth,o),s=[],i=e;for(let l of r){let c=I(i,l.id);if(!c||c.position.x===l.x&&c.position.y===l.y)continue;let u=J(i,l.id,d=>({...d,position:{x:l.x,y:l.y}}));i=u.scene,s.push(u.patch)}return s.length===0?null:Vo(s)},N0=(e,t,n)=>{let o=[];for(let l of e.elements.values())l.parentId===t&&o.push(l.id);if(o.length===0)return null;let a=DT(e,o),r=I(e,t),s=(r?On(r):null)?.gap??16,i=OT(a,s,n,{x:0,y:0});return{widest:i.widest,contentWidth:i.contentWidth,contentHeight:i.contentHeight}},On=e=>{let t=e.metadata?.autoLayout;if(!t||typeof t!="object")return null;let n=t;if(n.kind==="grid")return typeof n.cols!="number"||n.cols<1?null:{kind:"grid",cols:n.cols,...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="stack")return n.direction!=="horizontal"&&n.direction!=="vertical"?null:{kind:"stack",direction:n.direction,...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="wrap")return{kind:"wrap",...typeof n.gap=="number"?{gap:n.gap}:{}};if(n.kind==="tree"){let o=t;return{kind:"tree",...typeof o.ranksep=="number"?{ranksep:o.ranksep}:{},...typeof o.nodesep=="number"?{nodesep:o.nodesep}:{}}}if(typeof n.kind=="string"){let o=D0(n.kind);if(o){let a=o.parse(t);if(a!==null)return{...a,kind:n.kind}}}return null},Jf=(e,t)=>{let n=I(e,t);if(!n)return null;let o=On(n);if(!o)return null;let a=[];for(let c of e.elements.values())c.parentId===t&&a.push(c.id);if(a.length===0)return null;let r=to(n),s=r?{x:r.x,y:r.y}:n.position;if(o.kind==="grid")return P0(e,{shapeIds:a,origin:s,cols:o.cols,...o.gap!==void 0?{gap:o.gap}:{}});if(o.kind==="stack")return B0(e,{shapeIds:a,origin:s,direction:o.direction,...o.gap!==void 0?{gap:o.gap}:{}});if(o.kind==="wrap"){let c=r?r.width:Number.POSITIVE_INFINITY;return PT(e,{shapeIds:a,origin:s,innerWidth:c,...o.gap!==void 0?{gap:o.gap}:{}})}if(o.kind==="tree")return BT(e,{shapeIds:a,origin:s,...o.ranksep!==void 0?{ranksep:o.ranksep}:{},...o.nodesep!==void 0?{nodesep:o.nodesep}:{}});let i=o,l=D0(i.kind);return l?l.run(e,t,a,s,i):null},BT=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.ranksep??80,o=t.nodesep??24,a=t.origin??{x:0,y:0},r=m=>{let x=[];for(let y of e.elements.values())y.parentId===m&&x.push(y);return x.sort(_t),x},s=new Map,i=new Map,l=m=>Qf(m).width,c=m=>Qf(m).height,u=m=>{let x=s.get(m),y=i.get(m);if(x!==void 0&&y!==void 0)return{w:x,h:y};let g=I(e,m);if(!g)return s.set(m,0),i.set(m,0),{w:0,h:0};let b=l(g),A=c(g),_=r(m);if(_.length===0)return s.set(m,b),i.set(m,A),{w:b,h:A};let T=0,w=0;for(let M=0;M<_.length;M++){let B=u(v(_[M]).id);T+=B.w,M>0&&(T+=o),B.h>w&&(w=B.h)}let S=Math.max(b,T),L=A+n+w;return s.set(m,S),i.set(m,L),{w:S,h:L}};for(let m of t.shapeIds)u(m);let d=[],f=e,p=(m,x,y)=>{let g=I(f,m);if(!g)return;let b=u(m),A=l(g),_=c(g),T={x:x+(b.w-A)/2,y};if(g.position.x!==T.x||g.position.y!==T.y){let M=J(f,m,B=>({...B,position:T}));f=M.scene,d.push(M.patch)}let w=r(m);if(w.length===0)return;let S=x,L=y+_+n;for(let M of w)p(M.id,S,L),S+=u(M.id).w+o},h=a.x;for(let m of t.shapeIds)p(m,h,a.y),h+=u(m).w+o;return d.length===0?null:Vo(d)};var mH=20,z0=.5,yH=1e5,n2=(e,t,n,o={})=>{if(gH(e,t))return[e];let a=o.margin??mH,r=n.map(S=>xH(S,a)),s=o.startHeading,i=o.endHeading,l=new Set([e.x,t.x]),c=new Set([e.y,t.y]);for(let S of r)l.add(S.x),l.add(S.x+S.width),c.add(S.y),c.add(S.y+S.height);let u=[...l].sort((S,L)=>S-L),d=[...c].sort((S,L)=>S-L),f=(S,L)=>`${S},${L}`,p=S=>v(u[S]),h=S=>v(d[S]),m=u.indexOf(e.x),x=d.indexOf(e.y),y=u.indexOf(t.x),g=d.indexOf(t.y),b=(S,L)=>Math.abs(p(S)-p(y))+Math.abs(h(L)-h(g)),A=f(m,x),_=[{key:A,skey:`${A},0`,xi:m,yi:x,axis:0,g:0,f:b(m,x)}],T=new Map,w=new Map([[`${A},0`,0]]);for(;_.length>0;){_.sort((L,M)=>L.f-M.f||L.g-M.g||(L.skey<M.skey?-1:1));let S=v(_.shift());if(S.xi===y&&S.yi===g)return vH(T,S.skey,p,h);for(let L of bH(S.xi,S.yi,u.length,d.length)){let M={x:p(S.xi),y:h(S.yi)},B={x:p(L.xi),y:h(L.yi)};if(AH(M,B,r))continue;let W=Math.sign(B.x-M.x),ie=Math.sign(B.y-M.y);if(S.axis===0&&s&&W===-Math.sign(s.x)&&ie===-Math.sign(s.y)||L.xi===y&&L.yi===g&&i&&W===Math.sign(i.x)&&ie===Math.sign(i.y))continue;let ne=L.xi!==S.xi?1:2,j=Math.abs(M.x-B.x)+Math.abs(M.y-B.y),ve=S.axis!==0&&S.axis!==ne?yH:0,ye=S.g+j+ve,ee=f(L.xi,L.yi),Se=`${ee},${ne}`,Oe=w.get(Se);Oe!==void 0&&ye>=Oe||(w.set(Se,ye),T.set(Se,S.skey),_.push({key:ee,skey:Se,xi:L.xi,yi:L.yi,axis:ne,g:ye,f:ye+b(L.xi,L.yi)}))}}return null},gH=(e,t)=>e.x===t.x&&e.y===t.y,xH=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),bH=(e,t,n,o)=>{let a=[];return e>0&&a.push({xi:e-1,yi:t}),e<n-1&&a.push({xi:e+1,yi:t}),t>0&&a.push({xi:e,yi:t-1}),t<o-1&&a.push({xi:e,yi:t+1}),a},AH=(e,t,n)=>{let o=Math.min(e.x,t.x),a=Math.max(e.x,t.x),r=Math.min(e.y,t.y),s=Math.max(e.y,t.y);for(let i of n){let l=i.x+i.width,c=i.y+i.height;if(!(a<=i.x||o>=l||s<=i.y||r>=c)&&!(a-i.x<=z0||l-o<=z0||s-i.y<=z0||c-r<=z0))return!0}return!1},vH=(e,t,n,o)=>{let a=[],r=new Set,s=t;for(;s&&!r.has(s);){r.add(s);let i=s.split(",").map(Number);a.unshift({x:n(v(i[0])),y:o(v(i[1]))}),s=e.get(s)}return SH(a)},SH=e=>{if(e.length<=2)return e;let t=[v(e[0])];for(let n=1;n<e.length-1;n++){let o=v(e[n-1]),a=v(e[n]),r=v(e[n+1]),s=o.y===a.y&&a.y===r.y,i=o.x===a.x&&a.x===r.x;s||i||t.push(a)}return t.push(v(e[e.length-1])),t};var tp=(e,t)=>{let n=no(e,t.from),o=no(e,t.to);if(!n||!o)return[];let a=t.from.kind==="floating"?no(e,t.from,o)??n:n,r=t.to.kind==="floating"?no(e,t.to,n)??o:o;if(a.x===r.x&&a.y===r.y)return[];let s=UT(e,t.from,a,r),i=UT(e,t.to,r,a),l=t.avoidObstacles===!0?LH(e,t):void 0,c=l&&l.length<=150?l:void 0,u=WT(a,r,s,i,t.routedPoints,c);return u=_H(u,t.fixedSegments),u},LH=(e,t)=>{let n=new Set;for(let a of[t.from,t.to])a.kind!=="point"&&n.add(a.elementId);let o=[];for(let a of e.elements.values())n.has(a.id)||o.push(z(a));return o},o2=(e,t,n,o,a)=>{if(n.x===a.x&&n.y===a.y)return[n,a];let r=HT(e,t,n,a),s=HT(e,o,a,n);return[n,...WT(n,a,r,s),a]},WT=(e,t,n,o,a,r)=>{let s=30,i={x:e.x+n.heading.x*s,y:e.y+n.heading.y*s},l={x:t.x+o.heading.x*s,y:t.y+o.heading.y*s},c=[];if(n.obstacle&&c.push(n.obstacle),o.obstacle&&c.push(o.obstacle),r){let h=[...c,...r],m=n2(i,l,h,{startHeading:n.heading,endHeading:o.heading}),x=m&&m.length>=2?m:[i,GT(i,l,n.heading),l];return ep(x)}let u=kH(e,t,n,o,i,l);if(u&&!FT(u,c))return ep(u);let d=wH(e,t,n,o,i,l,c,a);if(d&&!FT(d,c))return ep(d);let f=n2(i,l,c,{startHeading:n.heading,endHeading:o.heading}),p=f&&f.length>=2?f:[i,GT(i,l,n.heading),l];return ep(p)},kH=(e,t,n,o,a,r)=>{if(n.heading.y!==0&&o.heading.y===-n.heading.y){if(Math.sign(a.y-r.y)===Math.sign(n.heading.y)){let l=(e.x+t.x)/2;return[a,{x:l,y:a.y},{x:l,y:r.y},r]}let i=(a.y+r.y)/2;return[a,{x:a.x,y:i},{x:r.x,y:i},r]}if(n.heading.x!==0&&o.heading.x===-n.heading.x){if(Math.sign(a.x-r.x)===Math.sign(n.heading.x)){let l=(e.y+t.y)/2;return[a,{x:a.x,y:l},{x:r.x,y:l},r]}let i=(a.x+r.x)/2;return[a,{x:i,y:a.y},{x:i,y:r.y},r]}return null},NT=(e,t,n,o,a)=>{let r=e<=t;return a!==null&&Math.abs(e-t)<24?a?n:o:r?n:o},wH=(e,t,n,o,a,r,s,i)=>{if(s.length===0)return null;let l=1/0,c=1/0,u=-1/0,d=-1/0;for(let p of s)l=Math.min(l,p.x),c=Math.min(c,p.y),u=Math.max(u,p.x+p.width),d=Math.max(d,p.y+p.height);let f=20;if(l-=f,c-=f,u+=f,d+=f,n.heading.y===0&&o.heading.y===0&&n.heading.x!==0&&o.heading.x===-n.heading.x){let p=(e.y+t.y)/2,h=NT(p,(c+d)/2,c,d,zT(i,"y"));return[a,{x:a.x,y:h},{x:r.x,y:h},r]}if(n.heading.x===0&&o.heading.x===0&&n.heading.y!==0&&o.heading.y===-n.heading.y){let p=(e.x+t.x)/2,h=NT(p,(l+u)/2,l,u,zT(i,"x"));return[a,{x:h,y:a.y},{x:h,y:r.y},r]}return null},zT=(e,t)=>{if(!e||e.length<3)return null;let n=d=>t==="y"?d.y:d.x,o=n(v(e[0])),a=n(v(e[e.length-1])),r=Math.min(o,a),s=Math.max(o,a),i=1/0,l=-1/0;for(let d of e){let f=n(d);f<i&&(i=f),f>l&&(l=f)}let c=r-i,u=l-s;return c<=0&&u<=0?null:c>=u},FT=(e,t)=>{let n=1;for(let o=1;o<e.length;o++){let a=v(e[o-1]),r=v(e[o]);for(let s=0;s<=1;s+=.1){let i=a.x+(r.x-a.x)*s,l=a.y+(r.y-a.y)*s;for(let c of t)if(i>c.x+n&&i<c.x+c.width-n&&l>c.y+n&&l<c.y+c.height-n)return!0}}return!1},HT=(e,t,n,o)=>{if(!t)return{heading:qf(o,n),obstacle:null};let a=I(e,t);return a?{heading:cT(a,n),obstacle:z(a)}:{heading:qf(o,n),obstacle:null}},_H=(e,t)=>{if(!t||t.length===0)return e;let n=e.map(o=>({...o}));for(let o of t){let a=n.length-2,r=-1,s=1/0;for(let c=1;c<a;c++){let u=v(n[c]),d=v(n[c+1]),f=Math.abs(u.y-d.y)<1e-6,p=Math.abs(u.x-d.x)<1e-6;if(o.axis==="h"!==f||o.axis==="v"!==p)continue;let h=o.axis==="h"?(u.x+d.x)/2:(u.y+d.y)/2,m=Math.abs(h-o.at);m<s&&(s=m,r=c)}if(r>=0){let c=v(n[r]),u=v(n[r+1]);o.axis==="h"?(c.y=o.pos,u.y=o.pos):(c.x=o.pos,u.x=o.pos);continue}let i=v(n[0]),l=v(n[n.length-1]);n=o.axis==="h"?[i,{x:i.x,y:o.pos},{x:l.x,y:o.pos},l]:[i,{x:o.pos,y:i.y},{x:o.pos,y:l.y},l]}return ep(n)},CH=e=>{switch(e){case"top":return Wf;case"bottom":return Uf;case"left":return Gf;case"right":return lc;default:return null}},UT=(e,t,n,o)=>{if(t.kind==="point")return{heading:qf(o,n),obstacle:null};let a=I(e,t.elementId);if(!a)return{heading:qf(o,n),obstacle:null};let r=z(a);if(t.kind==="anchor"&&t.anchor.kind==="named"){let s=CH(t.anchor.name);if(s)return{heading:s,obstacle:r}}return{heading:C0(a,n),obstacle:r}},GT=(e,t,n)=>lT(n)?{x:t.x,y:e.y}:{x:e.x,y:t.y},ep=e=>{if(e.length<=2)return[...e];let t=[v(e[0])];for(let n=1;n<e.length-1;n++){let o=v(t[t.length-1]),a=v(e[n]),r=v(e[n+1]),s=1e-6,i=Math.abs(o.y-a.y)<s&&Math.abs(a.y-r.y)<s,l=Math.abs(o.x-a.x)<s&&Math.abs(a.x-r.x)<s,c=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;i||l||c||t.push(a)}return t.push(v(e[e.length-1])),t};var hi="orthogonal",np="triangle";var a2=Math.PI/12,Zo=11,qT=6,jT=4,VT=12,F0=9,r2=4,ZT="#1a73e8",XT="#fff",op=3.5,Xo=5,YT=8,KT=1.5,$T=ZT,s2=XT,QT=XT,i2=ZT,Lo=20,JT=0,eI="#ffffff",H0=6,U0=7,tI=18,l2=40,hc=.16,ap=.7,c2="#e8118c",nI="#f59e0b",rp="#2563eb",u2="#16a34a",oI="#06b6d4",aI="#a855f7",rI="#eab308",sI="#dc2626",iI="#14b8a6",lI="#f43f5e",cI=16,d2=14,f2=6,p2=3,h2=11,uI=1.5,dI=[4,3],fI=3;var m2=1,y2=1.6,g2=10,pI=1,hI=.05,mI=32,yI=.5,gI=500,mc=8,G0=300,W0=8,xI=.6,bI=.2,AI=.85,q0=.4,vI=22,SI=22,LI=18,kI=16,wI=16,_I=9,j0=12,CI="#f9a825",EI="#fff",TI="#888",II=10,x2=2e3,b2=.5,MI=.5,A2=12,sp=6,RI=2,OI="#222222",DI=1,PI=4,v2=sp*3,BI=6,V0="#888888",NI=1.5,Z0=120,zI=.25,FI=.5,HI=10,UI=1,X0=1400,GI="#ff2d2d",S2=4,WI=8,L2=480,qI=1e3/60,jI=1e3/12,VI=2,ZI=2*1024*1024,XI=3e4,YI=24,KI="system-ui, sans-serif",$I="#1a1a1a",QI=1e3,JI=1,e4=10,t4=530,n4="#1a73e8",o4=.25,a4=1.5,Y0=4,k2=1.1,ko=80,r4=8,K0=.5,s4=256,i4=30,l4=16,w2=4,c4=4,u4="rgba(0,0,0,0.65)",d4=16,f4="#1a73e8",p4="#fff",ip=10,h4=11,m4=.12,y4=14,g4=3;var mi=["nw","n","ne","e","se","s","sw","w"],yi=["nw","ne","se","sw"],x4=e=>{switch(e){case"nw":case"se":return"nwse-resize";case"ne":case"sw":return"nesw-resize";case"n":case"s":return"ns-resize";case"e":case"w":return"ew-resize"}};var gi=(e,t,n=1)=>{let o=t.x+t.width/2,a=t.y+t.height/2,r=t.x+t.width,s=t.y+t.height,i=3/n;switch(e){case"nw":return{x:t.x-i,y:t.y-i};case"n":return{x:o,y:t.y-i};case"ne":return{x:r+i,y:t.y-i};case"e":return{x:r+i,y:a};case"se":return{x:r+i,y:s+i};case"s":return{x:o,y:s+i};case"sw":return{x:t.x-i,y:s+i};case"w":return{x:t.x-i,y:a}}},_2=(e,t,n,o=11,a=mi)=>{let r=o/n;for(let f of a){if(f.length!==2)continue;let p=gi(f,t,n);if(Math.abs(e.x-p.x)<=r&&Math.abs(e.y-p.y)<=r)return f}let s=t.x,i=t.x+t.width,l=t.y,c=t.y+t.height,u=e.x>=s-r&&e.x<=i+r,d=e.y>=l-r&&e.y<=c+r;for(let f of a)switch(f){case"n":if(u&&Math.abs(e.y-l)<=r)return"n";break;case"s":if(u&&Math.abs(e.y-c)<=r)return"s";break;case"w":if(d&&Math.abs(e.x-s)<=r)return"w";break;case"e":if(d&&Math.abs(e.x-i)<=r)return"e";break}return null},yc=(e,t)=>e.rotation===0?t:U.rotateAround(t,e.pivot,e.rotation),TH=(e,t)=>e.rotation===0?t:U.rotateAround(t,e.pivot,-e.rotation),xi=e=>{let t=Re(e),n=t.x*e.scale.x,o=(t.x+t.width)*e.scale.x,a=t.y*e.scale.y,r=(t.y+t.height)*e.scale.y;return{bounds:{x:e.position.x+Math.min(n,o),y:e.position.y+Math.min(a,r),width:Math.abs(o-n),height:Math.abs(r-a)},rotation:e.rotation,pivot:e.position}},cp=e=>{let t=e.bounds;return[yc(e,{x:t.x,y:t.y}),yc(e,{x:t.x+t.width,y:t.y}),yc(e,{x:t.x+t.width,y:t.y+t.height}),yc(e,{x:t.x,y:t.y+t.height})]},b4=e=>yc(e,{x:e.bounds.x+e.bounds.width/2,y:e.bounds.y+e.bounds.height/2}),A4=(e,t,n=1)=>yc(t,gi(e,t.bounds,n)),v4=(e,t,n,o=11,a=mi)=>_2(TH(t,e),t.bounds,n,o,a),IH={kind:"ratio",position:{x:0,y:1}},MH=new Map;var RH=e=>MH.get(e)??IH,$0=(e,t=1)=>{let n=RH(e.type),o=Yt(e,n),a=jo(e,n),r=26/t;return{x:o.x+a.x*r,y:o.y+a.y*r}},Q0=(e,t=1)=>{let n=26/t*Math.SQRT1_2;return{x:e.x-n,y:e.y+e.height+n}},C2=(e,t,n,o=11)=>{let a=o/n;return Math.abs(e.x-t.x)<=a&&Math.abs(e.y-t.y)<=a};function OH(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function DH(){let e=OH();if(e.__xstate__)return e.__xstate__}var S4=e=>{if(typeof window>"u")return;let t=DH();t&&t.register(e)};var J0=class{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){let n={value:t,next:null};if(this._current){this._last.next=n,this._last=n;return}this._current=n,this._last=n,this._active&&this.flush()}flush(){for(;this._current;){let t=this._current;this._process(t.value),this._current=t.next}this._last=null}},P2=".",PH="",B2="",BH="#",NH="*",E4="xstate.init",T4="xstate.error",I2="xstate.stop";function zH(e,t){return{type:`xstate.after.${e}.${t}`}}function M2(e,t){return{type:`xstate.done.state.${e}`,output:t}}function FH(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function N2(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function ty(e){return{type:E4,input:e}}function Yo(e){setTimeout(()=>{throw e})}var HH=typeof Symbol=="function"&&Symbol.observable||"@@observable";function z2(e,t){let n=L4(e),o=L4(t);return typeof o=="string"?typeof n=="string"?o===n:!1:typeof n=="string"?n in o:Object.keys(n).every(a=>a in o?z2(n[a],o[a]):!1)}function ny(e){if(R4(e))return e;let t=[],n="";for(let o=0;o<e.length;o++){switch(e.charCodeAt(o)){case 92:n+=e[o+1],o++;continue;case 46:t.push(n),n="";continue}n+=e[o]}return t.push(n),t}function L4(e){if(Q4(e))return e.value;if(typeof e!="string")return e;let t=ny(e);return I4(t)}function I4(e){if(e.length===1)return e[0];let t={},n=t;for(let o=0;o<e.length-1;o++)if(o===e.length-2)n[e[o]]=e[o+1];else{let a=n;n={},a[e[o]]=n}return t}function F2(e,t){let n={},o=Object.keys(e);for(let a=0;a<o.length;a++){let r=o[a];n[r]=t(e[r],r,e,a)}return n}function M4(e){return R4(e)?e:[e]}function Ko(e){return e===void 0?[]:M4(e)}function R2(e,t,n,o){return typeof e=="function"?e({context:t,event:n,self:o}):e}function R4(e){return Array.isArray(e)}function UH(e){return e.type.startsWith("xstate.error.actor")}function bi(e){return M4(e).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function O4(e){if(!(e===void 0||e===PH))return Ko(e)}function up(e,t,n){let o=typeof e=="object",a=o?e:void 0;return{next:(o?e.next:e)?.bind(a),error:(o?e.error:t)?.bind(a),complete:(o?e.complete:n)?.bind(a)}}function H2(e,t){return`${t}.${e}`}function fp(e,t){let n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];let[,o,a]=n,s=e.getStateNodeById(a).config.invoke;return(Array.isArray(s)?s[o]:s).src}function D4(e,t){if(t===e||t===NH)return!0;if(!t.endsWith(".*"))return!1;let n=t.split("."),o=e.split(".");for(let a=0;a<n.length;a++){let r=n[a],s=o[a];if(r==="*")return a===n.length-1;if(r!==s)return!1}return!0}function k4(e,t){return`${e.sessionId}.${t}`}var GH=0;function WH(e,t){let n=new Map,o=new Map,a=new WeakMap,r=new Set,s={},{clock:i,logger:l}=t,c={schedule:(f,p,h,m,x=Math.random().toString(36).slice(2))=>{let y={source:f,target:p,event:h,delay:m,id:x,startedAt:Date.now()},g=k4(f,x);d._snapshot._scheduledEvents[g]=y;let b=i.setTimeout(()=>{delete s[g],delete d._snapshot._scheduledEvents[g],d._relay(f,p,h)},m);s[g]=b},cancel:(f,p)=>{let h=k4(f,p),m=s[h];delete s[h],delete d._snapshot._scheduledEvents[h],m!==void 0&&i.clearTimeout(m)},cancelAll:f=>{for(let p in d._snapshot._scheduledEvents){let h=d._snapshot._scheduledEvents[p];h.source===f&&c.cancel(f,h.id)}}},u=f=>{if(!r.size)return;let p={...f,rootId:e.sessionId};r.forEach(h=>h.next?.(p))},d={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${GH++}`,_register:(f,p)=>(n.set(f,p),f),_unregister:f=>{n.delete(f.sessionId);let p=a.get(f);p!==void 0&&(o.delete(p),a.delete(f))},get:f=>o.get(f),getAll:()=>Object.fromEntries(o.entries()),_set:(f,p)=>{let h=o.get(f);if(h&&h!==p)throw new Error(`Actor with system ID '${f}' already exists.`);o.set(f,p),a.set(p,f)},inspect:f=>{let p=up(f);return r.add(p),{unsubscribe(){r.delete(p)}}},_sendInspectionEvent:u,_relay:(f,p,h)=>{d._sendInspectionEvent({type:"@xstate.event",sourceRef:f,actorRef:p,event:h}),p._send(h)},scheduler:c,getSnapshot:()=>({_scheduledEvents:{...d._snapshot._scheduledEvents}}),start:()=>{let f=d._snapshot._scheduledEvents;d._snapshot._scheduledEvents={};for(let p in f){let{source:h,target:m,event:x,delay:y,id:g}=f[p];c.schedule(h,m,x,y,g)}},_clock:i,_logger:l};return d}var E2=!1,oy=1,Kt=(function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e})({}),qH={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},ey=class{constructor(t,n){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new J0(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=Kt.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];let o={...qH,...n},{clock:a,logger:r,parent:s,syncSnapshot:i,id:l,systemId:c,inspect:u}=o;this.system=s?s.system:WH(this,{clock:a,logger:r}),u&&!s&&this.system.inspect(up(u)),this.sessionId=this.system._bookId(),this.id=l??this.sessionId,this.logger=n?.logger??this.system._logger,this.clock=n?.clock??this.system._clock,this._parent=s,this._syncSnapshot=i,this.options=o,this.src=o.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:d=>{this._deferred.push(d)},system:this.system,stopChild:d=>{if(d._parent!==this)throw new Error(`Cannot stop child actor ${d.id} of ${this.id} because it is not a child`);d._stop()},emit:d=>{let f=this.eventListeners.get(d.type),p=this.eventListeners.get("*");if(!f&&!p)return;let h=[...f?f.values():[],...p?p.values():[]];for(let m of h)try{m(d)}catch(x){Yo(x)}},actionExecutor:d=>{let f=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:d.type,params:d.params}}),!d.exec)return;let p=E2;try{E2=!0,d.exec(d.info,d.params)}finally{E2=p}};this._processingStatus===Kt.Running?f():this._deferred.push(f)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),c&&(this.systemId=c,this.system._set(c,this)),this._initState(n?.snapshot??n?.state),c&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(t){try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(n){this._snapshot={status:"error",output:void 0,error:n}}}update(t,n){this._snapshot=t;let o;for(;o=this._deferred.shift();)try{o()}catch(a){this._deferred.length=0,this._snapshot={...t,status:"error",error:a}}switch(this._snapshot.status){case"active":for(let a of this.observers)try{a.next?.(t)}catch(r){Yo(r)}break;case"done":for(let a of this.observers)try{a.next?.(t)}catch(r){Yo(r)}this._stopProcedure(),this._complete(),this._doneEvent=FH(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:n,snapshot:t})}subscribe(t,n,o){let a=up(t,n,o);if(this._processingStatus!==Kt.Stopped)this.observers.add(a);else switch(this._snapshot.status){case"done":try{a.complete?.()}catch(r){Yo(r)}break;case"error":{let r=this._snapshot.error;if(!a.error)Yo(r);else try{a.error(r)}catch(s){Yo(s)}break}}return{unsubscribe:()=>{this.observers.delete(a)}}}on(t,n){let o=this.eventListeners.get(t);o||(o=new Set,this.eventListeners.set(t,o));let a=n.bind(void 0);return o.add(a),{unsubscribe:()=>{o.delete(a)}}}select(t,n=Object.is){return{subscribe:o=>{let a=up(o),r=this.getSnapshot(),s=t(r);return this.subscribe(i=>{let l=t(i);n(s,l)||(s=l,a.next?.(l))})},get:()=>t(this.getSnapshot())}}start(){if(this._processingStatus===Kt.Running)return this;this._syncSnapshot&&this.subscribe({next:o=>{o.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:o})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=Kt.Running;let t=ty(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(o){return this._snapshot={...this._snapshot,status:"error",error:o},this._error(o),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let n,o;try{n=this.logic.transition(this._snapshot,t,this._actorScope)}catch(a){o={err:a}}if(o){let{err:a}=o;this._snapshot={...this._snapshot,status:"error",error:a},this._error(a);return}this.update(n,t),t.type===I2&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===Kt.Stopped?this:(this.mailbox.clear(),this._processingStatus===Kt.NotStarted?(this._processingStatus=Kt.Stopped,this):(this.mailbox.enqueue({type:I2}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(let t of this.observers)try{t.complete?.()}catch(n){Yo(n)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||Yo(t),this.eventListeners.clear();return}let n=!1;for(let o of this.observers){let a=o.error;n||=!a;try{a?.(t)}catch(r){Yo(r)}}this.observers.clear(),this.eventListeners.clear(),n&&Yo(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,N2(this.id,t))}_stopProcedure(){return this._processingStatus!==Kt.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new J0(this._process.bind(this)),this._processingStatus=Kt.Stopped,this.system._unregister(this),this)}_send(t){this._processingStatus!==Kt.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){let{devTools:t}=this.options;t&&(typeof t=="function"?t:S4)(this)}toJSON(){return{xstate$$type:oy,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[HH](){return this}getSnapshot(){return this._snapshot}};function $o(e,...[t]){return new ey(e,t)}function jH(e,t,n,o,{sendId:a}){let r=typeof a=="function"?a(n,o):a;return[t,{sendId:r},void 0]}function VH(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function Ac(e){function t(n,o){}return t.type="xstate.cancel",t.sendId=e,t.resolve=jH,t.execute=VH,t}function ZH(e,t,n,o,{id:a,systemId:r,src:s,input:i,syncSnapshot:l}){let c=typeof s=="string"?fp(t.machine,s):s,u=typeof a=="function"?a(n):a,d,f;return c&&(f=typeof i=="function"?i({context:t.context,event:n.event,self:e.self}):i,d=$o(c,{id:u,src:s,parent:e.self,syncSnapshot:l,systemId:r,input:f})),[Qr(t,{children:{...t.children,[u]:d}}),{id:a,systemId:r,actorRef:d,src:s,input:f},void 0]}function XH(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==Kt.Stopped&&t.start()})}function vc(...[e,{id:t,systemId:n,input:o,syncSnapshot:a=!1}={}]){function r(s,i){}return r.type="xstate.spawnChild",r.id=t,r.systemId=n,r.src=e,r.input=o,r.syncSnapshot=a,r.resolve=ZH,r.execute=XH,r}function YH(e,t,n,o,{actorRef:a}){let r=typeof a=="function"?a(n,o):a,s=typeof r=="string"?t.children[r]:r,i=t.children;return s&&(i={...i},delete i[s.id]),[Qr(t,{children:i}),s,void 0]}function P4(e,t){let n=t.getSnapshot();if(n&&"children"in n)for(let o of Object.values(n.children))P4(e,o);e.system._unregister(t)}function KH(e,t){if(t){if(P4(e,t),t._processingStatus!==Kt.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Si(e){function t(n,o){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=YH,t.execute=KH,t}function $H(e,{context:t,event:n},{guards:o}){return o.every(a=>Li(a,t,n,e))}function B4(e){function t(n,o){return!1}return t.check=$H,t.guards=e,t}function Li(e,t,n,o){let{machine:a}=o,r=typeof e=="function",s=r?e:a.implementations.guards[typeof e=="string"?e:e.type];if(!r&&!s)throw new Error(`Guard '${typeof e=="string"?e:e.type}' is not implemented.'.`);if(typeof s!="function")return Li(s,t,n,o);let i={context:t,event:n},l=r||typeof e=="string"?void 0:"params"in e?typeof e.params=="function"?e.params({context:t,event:n}):e.params:void 0;return"check"in s?s.check(o,i,s):s(i,l)}function ay(e){return e.type==="atomic"||e.type==="final"}function xc(e){return Object.values(e.states).filter(t=>t.type!=="history")}function Sc(e,t){let n=[];if(t===e)return n;let o=e.parent;for(;o&&o!==t;)n.push(o),o=o.parent;return n}function pp(e){let t=new Set(e),n=z4(t);for(let o of t)if(o.type==="compound"&&(!n.get(o)||!n.get(o).length))w4(o).forEach(a=>t.add(a));else if(o.type==="parallel"){for(let a of xc(o))if(a.type!=="history"&&!t.has(a)){let r=w4(a);for(let s of r)t.add(s)}}for(let o of t){let a=o.parent;for(;a;)t.add(a),a=a.parent}return t}function N4(e,t){let n=t.get(e);if(!n)return{};if(e.type==="compound"){let a=n[0];if(a){if(ay(a))return a.key}else return{}}let o={};for(let a of n)o[a.key]=N4(a,t);return o}function z4(e){let t=new Map;for(let n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function F4(e,t){let n=pp(t);return N4(e,z4(n))}function ry(e,t){return t.type==="compound"?xc(t).some(n=>n.type==="final"&&e.has(n)):t.type==="parallel"?xc(t).every(n=>ry(e,n)):t.type==="final"}var hp=e=>e[0]===BH;function H4(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(o=>D4(t,o)).sort((o,a)=>a.length-o.length).flatMap(o=>e.transitions.get(o))}function U4(e){let t=e.config.after;if(!t)return[];let n=a=>{let r=zH(a,e.id),s=r.type;return e.entry.push(kc(r,{id:s,delay:a})),e.exit.push(Ac(s)),s};return Object.keys(t).flatMap(a=>{let r=t[a],s=typeof r=="string"?{target:r}:r,i=Number.isNaN(+a)?a:+a,l=n(i);return Ko(s).map(c=>({...c,event:l,delay:i}))}).map(a=>{let{delay:r}=a;return{...ja(e,a.event,a),delay:r}})}function ja(e,t,n){let o=O4(n.target),a=n.reenter??!1,r=QH(e,o),s={...n,actions:Ko(n.actions),guard:n.guard,target:r,source:e,reenter:a,eventType:t,toJSON:()=>({...s,source:`#${e.id}`,target:r?r.map(i=>`#${i.id}`):void 0})};return s}function G4(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===B2)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let o=e.config.on[n];t.set(n,bi(o).map(a=>ja(e,n,a)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,bi(e.config.onDone).map(o=>ja(e,n,o)))}for(let n of e.invoke){if(n.onDone){let o=`xstate.done.actor.${n.id}`;t.set(o,bi(n.onDone).map(a=>ja(e,o,a)))}if(n.onError){let o=`xstate.error.actor.${n.id}`;t.set(o,bi(n.onError).map(a=>ja(e,o,a)))}if(n.onSnapshot){let o=`xstate.snapshot.${n.id}`;t.set(o,bi(n.onSnapshot).map(a=>ja(e,o,a)))}}for(let n of e.after){let o=t.get(n.eventType);o||(o=[],t.set(n.eventType,o)),o.push(n)}return t}function W4(e){let t=[],n=o=>{Object.values(o).forEach(a=>{if(a.config.route&&a.config.id){let r=a.config.id,s=a.config.route.guard,i=({event:c})=>c.to===`#${r}`,l={...a.config.route,guard:s?B4([i,s]):i,target:`#${r}`};t.push(ja(e,"xstate.route",l))}a.states&&n(a.states)})};n(e.states),t.length>0&&e.transitions.set("xstate.route",t)}function q4(e,t){let n=typeof t=="string"?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let o={source:e,actions:!t||typeof t=="string"?[]:Ko(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...o,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return o}function QH(e,t){if(t!==void 0)return t.map(n=>{if(typeof n!="string")return n;if(hp(n))return e.machine.getStateNodeById(n);let o=n[0]===P2;if(o&&!e.parent)return dp(e,n.slice(1));let a=o?e.key+n:n;if(e.parent)try{return dp(e.parent,a)}catch(r){throw new Error(`Invalid transition definition for state node '${e.id}':
|
|
11
|
+
${r.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function j4(e){let t=O4(e.config.target);return t?{target:t.map(n=>typeof n=="string"?dp(e.parent,n):n)}:e.parent.initial}function Ai(e){return e.type==="history"}function w4(e){let t=V4(e);for(let n of t)for(let o of Sc(n,e))t.add(o);return t}function V4(e){let t=new Set;function n(o){if(!t.has(o)){if(t.add(o),o.type==="compound")n(o.initial.target[0]);else if(o.type==="parallel")for(let a of xc(o))n(a)}}return n(e),t}function bc(e,t){if(hp(t))return e.machine.getStateNodeById(t);if(!e.states)throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let n=e.states[t];if(!n)throw new Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function dp(e,t){if(typeof t=="string"&&hp(t))try{return e.machine.getStateNodeById(t)}catch{}let n=ny(t).slice(),o=e;for(;n.length;){let a=n.shift();if(!a.length)break;o=bc(o,a)}return o}function Lc(e,t){if(typeof t=="string"){let a=e.states[t];if(!a)throw new Error(`State '${t}' does not exist on '${e.id}'`);return[e,a]}let n=Object.keys(t),o=n.map(a=>bc(e,a)).filter(Boolean);return[e.machine.root,e].concat(o,n.reduce((a,r)=>{let s=bc(e,r);if(!s)return a;let i=Lc(s,t[r]);return a.concat(i)},[]))}function JH(e,t,n,o){let r=bc(e,t).next(n,o);return!r||!r.length?e.next(n,o):r}function eU(e,t,n,o){let a=Object.keys(t),r=bc(e,a[0]),s=sy(r,t[a[0]],n,o);return!s||!s.length?e.next(n,o):s}function tU(e,t,n,o){let a=[];for(let r of Object.keys(t)){let s=t[r];if(!s)continue;let i=bc(e,r),l=sy(i,s,n,o);l&&a.push(...l)}return a.length?a:e.next(n,o)}function sy(e,t,n,o){return typeof t=="string"?JH(e,t,n,o):Object.keys(t).length===1?eU(e,t,n,o):tU(e,t,n,o)}function nU(e){return Object.keys(e.states).map(t=>e.states[t]).filter(t=>t.type==="history")}function $r(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function oU(e,t){let n=new Set(e),o=new Set(t);for(let a of n)if(o.has(a))return!0;for(let a of o)if(n.has(a))return!0;return!1}function Z4(e,t,n){let o=new Set;for(let a of e){let r=!1,s=new Set;for(let i of o)if(oU(O2([a],t,n),O2([i],t,n)))if($r(a.source,i.source))s.add(i);else{r=!0;break}if(!r){for(let i of s)o.delete(i);o.add(a)}}return Array.from(o)}function aU(e){let[t,...n]=e;for(let o of Sc(t,void 0))if(n.every(a=>$r(a,o)))return o}function U2(e,t){if(!e.target)return[];let n=new Set;for(let o of e.target)if(Ai(o))if(t[o.id])for(let a of t[o.id])n.add(a);else for(let a of U2(j4(o),t))n.add(a);else n.add(o);return[...n]}function X4(e,t){let n=U2(e,t);if(!n)return;if(!e.reenter&&n.every(a=>a===e.source||$r(a,e.source)))return e.source;let o=aU(n.concat(e.source));if(o)return o;if(!e.reenter)return e.source.machine.root}function O2(e,t,n){let o=new Set;for(let a of e)if(a.target?.length){let r=X4(a,n);a.reenter&&a.source===r&&o.add(r);for(let s of t)$r(s,r)&&o.add(s)}return[...o]}function rU(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function G2(e,t,n,o,a){return D2([{target:[...V4(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,o,!0,a)}function D2(e,t,n,o,a,r){let s=[];if(!e.length)return[t,s];let i=n.actionExecutor;n.actionExecutor=l=>{s.push(l),i(l)};try{let l=new Set(t._nodes),c=t.historyValue,u=Z4(e,l,c),d=t;a||([d,c]=cU(d,o,n,u,l,c,r,n.actionExecutor)),d=vi(d,o,n,u.flatMap(p=>p.actions),r,void 0),d=iU(d,o,n,u,l,r,c,a);let f=[...l];d.status==="done"&&(d=vi(d,o,n,f.sort((p,h)=>h.order-p.order).flatMap(p=>p.exit),r,void 0));try{return c===t.historyValue&&rU(t._nodes,l)?[d,s]:[Qr(d,{_nodes:f,historyValue:c}),s]}catch(p){throw p}}finally{n.actionExecutor=i}}function sU(e,t,n,o,a){if(o.output===void 0)return;let r=M2(a.id,a.output!==void 0&&a.parent?R2(a.output,e.context,t,n.self):void 0);return R2(o.output,e.context,r,n.self)}function iU(e,t,n,o,a,r,s,i){let l=e,c=new Set,u=new Set;lU(o,s,u,c),i&&u.add(e.machine.root);let d=new Set;for(let f of[...c].sort((p,h)=>p.order-h.order)){a.add(f);let p=[];p.push(...f.entry);for(let h of f.invoke)p.push(vc(h.src,{...h,syncSnapshot:!!h.onSnapshot}));if(u.has(f)){let h=f.initial.actions;p.push(...h)}if(l=vi(l,t,n,p,r,f.invoke.map(h=>h.id)),f.type==="final"){let h=f.parent,m=h?.type==="parallel"?h:h?.parent,x=m||f;for(h?.type==="compound"&&r.push(M2(h.id,f.output!==void 0?R2(f.output,l.context,t,n.self):void 0));m?.type==="parallel"&&!d.has(m)&&ry(a,m);)d.add(m),r.push(M2(m.id)),x=m,m=m.parent;if(m)continue;l=Qr(l,{status:"done",output:sU(l,t,n,l.machine.root,x)})}}return l}function lU(e,t,n,o){for(let a of e){let r=X4(a,t);for(let i of a.target||[])!Ai(i)&&(a.source!==i||a.source!==r||a.reenter)&&(o.add(i),n.add(i)),gc(i,t,n,o);let s=U2(a,t);for(let i of s){let l=Sc(i,r);r?.type==="parallel"&&l.push(r),Y4(o,t,n,l,!a.source.parent&&a.reenter?void 0:r)}}}function gc(e,t,n,o){if(Ai(e))if(t[e.id]){let a=t[e.id];for(let r of a)o.add(r),gc(r,t,n,o);for(let r of a)T2(r,e.parent,o,t,n)}else{let a=j4(e);for(let r of a.target)o.add(r),a===e.parent?.initial&&n.add(e.parent),gc(r,t,n,o);for(let r of a.target)T2(r,e.parent,o,t,n)}else if(e.type==="compound"){let[a]=e.initial.target;Ai(a)||(o.add(a),n.add(a)),gc(a,t,n,o),T2(a,e,o,t,n)}else if(e.type==="parallel")for(let a of xc(e).filter(r=>!Ai(r)))[...o].some(r=>$r(r,a))||(Ai(a)||(o.add(a),n.add(a)),gc(a,t,n,o))}function Y4(e,t,n,o,a){for(let r of o)if((!a||$r(r,a))&&e.add(r),r.type==="parallel")for(let s of xc(r).filter(i=>!Ai(i)))[...e].some(i=>$r(i,s))||(e.add(s),gc(s,t,n,e))}function T2(e,t,n,o,a){Y4(n,o,a,Sc(e,t))}function cU(e,t,n,o,a,r,s,i){let l=e,c=O2(o,a,r);c.sort((d,f)=>f.order-d.order);let u;for(let d of c)for(let f of nU(d)){let p;f.history==="deep"?p=h=>ay(h)&&$r(h,d):p=h=>h.parent===d,u??={...r},u[f.id]=Array.from(a).filter(p)}for(let d of c)l=vi(l,t,n,[...d.exit,...d.invoke.map(f=>Si(f.id))],s,void 0),a.delete(d);return[l,u||r]}function uU(e,t){return e.implementations.actions[t]}function K4(e,t,n,o,a,r){let{machine:s}=e,i=e;for(let l of o){let c=typeof l=="function",u=c?l:uU(s,typeof l=="string"?l:l.type),d={context:i.context,event:t,self:n.self,system:n.system},f=c||typeof l=="string"?void 0:"params"in l?typeof l.params=="function"?l.params({context:i.context,event:t}):l.params:void 0;if(!u||!("resolve"in u)){n.actionExecutor({type:typeof l=="string"?l:typeof l=="object"?l.type:l.name||"(anonymous)",info:d,params:f,exec:u});continue}let p=u,[h,m,x]=p.resolve(n,i,d,f,u,a);i=h,"retryResolve"in p&&r?.push([p,m]),"execute"in p&&n.actionExecutor({type:p.type,info:d,params:m,exec:p.execute.bind(null,n,m)}),x&&(i=K4(i,t,n,x,a,r))}return i}function vi(e,t,n,o,a,r){let s=r?[]:void 0,i=K4(e,t,n,o,{internalQueue:a,deferredActorIds:r},s);return s?.forEach(([l,c])=>{l.retryResolve(n,i,c)}),i}function mp(e,t,n,o){let a=e,r=[];function s(d,f,p){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:f,snapshot:d[0],_transitions:p}),r.push(d)}if(t.type===I2)return a=Qr(_4(a,t,n),{status:"stopped"}),s([a,[]],t,[]),{snapshot:a,microsteps:r};let i=t;if(i.type!==E4){let d=i,f=UH(d),p=C4(d,a);if(f&&!p.length)return a=Qr(e,{status:"error",error:d.error}),s([a,[]],d,[]),{snapshot:a,microsteps:r};let h=D2(p,e,n,i,!1,o);a=h[0],s(h,d,p)}let l=!0,c=e.machine.options?.maxIterations??1/0,u=0;for(;a.status==="active";){if(u++,u>c)throw new Error(`Infinite loop detected: the machine has processed more than ${c} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let d=l?dU(a,i):[],f=d.length?a:void 0;if(!d.length){if(!o.length)break;i=o.shift(),d=C4(i,a)}let p=D2(d,a,n,i,!1,o);a=p[0],l=a!==f,s(p,i,d)}return a.status!=="active"&&_4(a,i,n),{snapshot:a,microsteps:r}}function _4(e,t,n){return vi(e,t,n,Object.values(e.children).map(o=>Si(o)),[],void 0)}function C4(e,t){return t.machine.getTransitionData(t,e)}function dU(e,t){let n=new Set,o=e._nodes.filter(ay);for(let a of o)e:for(let r of[a].concat(Sc(a,void 0)))if(r.always){for(let s of r.always)if(s.guard===void 0||Li(s.guard,e.context,t,e)){n.add(s);break e}}return Z4(Array.from(n),new Set(e._nodes),e.historyValue)}function $4(e,t){let n=pp(Lc(e,t));return F4(e,[...n])}function Q4(e){return!!e&&typeof e=="object"&&"machine"in e&&"value"in e}var fU=function(t){return z2(t,this.value)},pU=function(t){return this.tags.has(t)},hU=function(t){let n=this.machine.getTransitionData(this,t);return!!n?.length&&n.some(o=>o.target!==void 0||o.actions.length)},mU=function(){let{_nodes:t,tags:n,machine:o,getMeta:a,toJSON:r,can:s,hasTag:i,matches:l,...c}=this;return{...c,tags:Array.from(n)}},yU=function(){return this._nodes.reduce((t,n)=>(n.meta!==void 0&&(t[n.id]=n.meta),t),{})};function yp(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:F4(t.root,e._nodes),tags:new Set(e._nodes.flatMap(n=>n.tags)),children:e.children,historyValue:e.historyValue||{},matches:fU,hasTag:pU,can:hU,getMeta:yU,toJSON:mU}}function Qr(e,t={}){return yp({...e,...t},e.machine)}function gU(e){if(typeof e!="object"||e===null)return{};let t={};for(let n in e){let o=e[n];Array.isArray(o)&&(t[n]=o.map(a=>({id:a.id})))}return t}function J4(e,t){let{_nodes:n,tags:o,machine:a,children:r,context:s,can:i,hasTag:l,matches:c,getMeta:u,toJSON:d,...f}=e,p={};for(let m in r){let x=r[m];p[m]={snapshot:x.getPersistedSnapshot(t),src:x.src,systemId:x.systemId,syncSnapshot:x._syncSnapshot}}return{...f,context:e5(s),children:p,historyValue:gU(f.historyValue)}}function e5(e){let t;for(let n in e){let o=e[n];if(o&&typeof o=="object")if("sessionId"in o&&"send"in o&&"ref"in o)t??=Array.isArray(e)?e.slice():{...e},t[n]={xstate$$type:oy,id:o.id};else{let a=e5(o);a!==o&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=a)}}return t??e}function xU(e,t,n,o,{event:a,id:r,delay:s},{internalQueue:i}){let l=t.machine.implementations.delays;if(typeof a=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${a}" }) instead`);let c=typeof a=="function"?a(n,o):a,u;if(typeof s=="string"){let d=l&&l[s];u=typeof d=="function"?d(n,o):d}else u=typeof s=="function"?s(n,o):s;return typeof u!="number"&&i.push(c),[t,{event:c,id:r,delay:u},void 0]}function bU(e,t){let{event:n,delay:o,id:a}=t;if(typeof o=="number"){e.defer(()=>{let r=e.self;e.system.scheduler.schedule(r,r,n,o,a)});return}}function kc(e,t){function n(o,a){}return n.type="xstate.raise",n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=xU,n.execute=bU,n}function t5(e,t){return{config:e,transition:(n,o,a)=>({...n,context:e(n.context,o,a)}),getInitialSnapshot:(n,o)=>({status:"active",output:void 0,error:void 0,context:typeof t=="function"?t({input:o}):t}),getPersistedSnapshot:n=>n,restoreSnapshot:n=>n}}var hse=t5(e=>{},void 0);function AU(e,{machine:t,context:n},o,a){let r=(s,i)=>{if(typeof s=="string"){let l=fp(t,s);if(!l)throw new Error(`Actor logic '${s}' not implemented in machine '${t.id}'`);let c=$o(l,{id:i?.id,parent:e.self,syncSnapshot:i?.syncSnapshot,input:typeof i?.input=="function"?i.input({context:n,event:o,self:e.self}):i?.input,src:s,systemId:i?.systemId});return a[c.id]=c,c}else return $o(s,{id:i?.id,parent:e.self,syncSnapshot:i?.syncSnapshot,input:i?.input,src:s,systemId:i?.systemId})};return(s,i)=>{let l=r(s,i);return a[l.id]=l,e.defer(()=>{l._processingStatus!==Kt.Stopped&&l.start()}),l}}function vU(e,t,n,o,{assignment:a}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let r={},s={context:t.context,event:n.event,spawn:AU(e,t,n.event,r),self:e.self,system:e.system},i={};if(typeof a=="function")i=a(s,o);else for(let c of Object.keys(a)){let u=a[c];i[c]=typeof u=="function"?u(s,o):u}let l=Object.assign({},t.context,i);return[Qr(t,{context:l,children:Object.keys(r).length?{...t.children,...r}:t.children}),void 0,void 0]}function Dn(e){function t(n,o){}return t.type="xstate.assign",t.assignment=e,t.resolve=vU,t}var n5=new WeakMap;function wc(e,t,n){let o=n5.get(e);return o?t in o||(o[t]=n()):(o={[t]:n()},n5.set(e,o)),o[t]}var SU={},gp=e=>typeof e=="string"?{type:e}:typeof e=="function"?"resolve"in e?{type:e.type}:{type:e.name}:e,iy=class e{constructor(t,n){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(P2),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?F2(this.config.states,(o,a)=>new e(o,{_parent:this,_key:a,_machine:this.machine})):SU,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=Ko(this.config.entry).slice(),this.exit=Ko(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=Ko(t.tags).slice()}_initialize(){this.transitions=G4(this),this.config.always&&(this.always=bi(this.config.always).map(t=>ja(this,B2,t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(gp),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(gp),eventType:null})}:void 0,history:this.history,states:F2(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(gp)})),entry:this.entry.map(gp),exit:this.exit.map(gp),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return wc(this,"invoke",()=>Ko(this.config.invoke).map((t,n)=>{let{src:o,systemId:a}=t,r=t.id??H2(this.id,n),s=typeof o=="string"?o:`xstate.invoke.${H2(this.id,n)}`;return{...t,src:s,id:r,systemId:a,toJSON(){let{onDone:i,onError:l,...c}=t;return{...c,type:"xstate.invoke",src:s,id:r}}}}))}get on(){return wc(this,"on",()=>[...this.transitions].flatMap(([n,o])=>o.map(a=>[n,a])).reduce((n,[o,a])=>(n[o]=n[o]||[],n[o].push(a),n),{}))}get after(){return wc(this,"delayedTransitions",()=>U4(this))}get initial(){return wc(this,"initial",()=>q4(this,this.config.initial))}next(t,n){let o=n.type,a=[],r,s=wc(this,`candidates-${o}`,()=>H4(this,o));for(let i of s){let{guard:l}=i,c=t.context,u=!1;try{u=!l||Li(l,c,n,t)}catch(d){let f=typeof l=="string"?l:typeof l=="object"?l.type:void 0;throw new Error(`Unable to evaluate guard ${f?`'${f}' `:""}in transition for event '${o}' in state node '${this.id}':
|
|
12
|
+
${d.message}`)}if(u){a.push(...i.actions),r=i;break}}return r?[r]:void 0}get events(){return wc(this,"events",()=>{let{states:t}=this,n=new Set(this.ownEvents);if(t)for(let o of Object.keys(t)){let a=t[o];if(a.states)for(let r of a.events)n.add(`${r}`)}return Array.from(n)})}get ownEvents(){let t=Object.keys(Object.fromEntries(this.transitions)),n=new Set(t.filter(o=>this.transitions.get(o).some(a=>!(!a.target&&!a.actions.length&&!a.reenter))));return Array.from(n)}},LU="#",ly=class e{constructor(t,n){this.config=t,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=t.id||"(machine)",this.implementations={actors:n?.actors??{},actions:n?.actions??{},delays:n?.delays??{},guards:n?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new iy(t,{_key:this.id,_machine:this}),this.root._initialize(),W4(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:n,guards:o,actors:a,delays:r}=this.implementations;return new e(this.config,{actions:{...n,...t.actions},guards:{...o,...t.guards},actors:{...a,...t.actors},delays:{...r,...t.delays}})}resolveState(t){let n=$4(this.root,t.value),o=pp(Lc(this.root,n));return yp({_nodes:[...o],context:t.context||{},children:{},status:ry(o,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,n,o){return mp(t,n,o,[]).snapshot}microstep(t,n,o){return mp(t,n,o,[]).microsteps.map(([a])=>a)}getTransitionData(t,n){return sy(this.root,t.value,t,n)||[]}_getPreInitialState(t,n,o){let{context:a}=this.config,r=yp({context:typeof a!="function"&&a?a:{},_nodes:[this.root],children:{},status:"active"},this);return typeof a=="function"?vi(r,n,t,[Dn(({spawn:i,event:l,self:c})=>a({spawn:i,input:l.input,self:c}))],o,void 0):r}getInitialSnapshot(t,n){let o=ty(n),a=[],r=this._getPreInitialState(t,o,a),[s]=G2(this.root,r,t,o,a),{snapshot:i}=mp(s,o,t,a);return i}start(t){Object.values(t.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(t){let n=ny(t),o=n.slice(1),a=hp(n[0])?n[0].slice(LU.length):n[0],r=this.idMap.get(a);if(!r)throw new Error(`Child state node '#${a}' does not exist on machine '${this.id}'`);return dp(r,o)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,n){return J4(t,n)}restoreSnapshot(t,n){let o={},a=t.children;Object.keys(a).forEach(d=>{let f=a[d],p=f.snapshot,h=f.src,m=typeof h=="string"?fp(this,h):h;if(!m)return;let x=$o(m,{id:d,parent:n.self,syncSnapshot:f.syncSnapshot,snapshot:p,src:h,systemId:f.systemId});o[d]=x});function r(d,f){if(f instanceof iy)return f;try{return d.machine.getStateNodeById(f.id)}catch{}}function s(d,f){if(!f||typeof f!="object")return{};let p={};for(let h in f){let m=f[h];for(let x of m){let y=r(d,x);y&&(p[h]??=[],p[h].push(y))}}return p}let i=s(this.root,t.historyValue),l=yp({...t,children:o,_nodes:Array.from(pp(Lc(this.root,t.value))),historyValue:i},this),c=new Set;function u(d,f){if(!c.has(d)){c.add(d);for(let p in d){let h=d[p];if(h&&typeof h=="object"){if("xstate$$type"in h&&h.xstate$$type===oy){d[p]=f[h.id];continue}u(h,f)}}}}return u(l.context,o),l}};function kU(e,t,n,o,{event:a}){let r=typeof a=="function"?a(n,o):a;return[t,{event:r},void 0]}function wU(e,{event:t}){e.defer(()=>e.emit(t))}function uy(e){function t(n,o){}return t.type="xstate.emit",t.event=e,t.resolve=kU,t.execute=wU,t}var cy=(function(e){return e.Parent="#_parent",e.Internal="#_internal",e})({});function _U(e,t,n,o,{to:a,event:r,id:s,delay:i},l){let c=t.machine.implementations.delays;if(typeof r=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${r}" }) instead`);let u=typeof r=="function"?r(n,o):r,d;if(typeof i=="string"){let h=c&&c[i];d=typeof h=="function"?h(n,o):h}else d=typeof i=="function"?i(n,o):i;let f=typeof a=="function"?a(n,o):a,p;if(typeof f=="string"){if(f===cy.Parent?p=e.self._parent:f===cy.Internal?p=e.self:f.startsWith("#_")?p=t.children[f.slice(2)]:p=l.deferredActorIds?.includes(f)?f:t.children[f],!p)throw new Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`)}else p=f||e.self;return[t,{to:p,targetId:typeof f=="string"?f:void 0,event:u,id:s,delay:d},void 0]}function CU(e,t,n){typeof n.to=="string"&&(n.to=t.children[n.to])}function EU(e,t){e.defer(()=>{let{to:n,event:o,delay:a,id:r}=t;if(typeof a=="number"){e.system.scheduler.schedule(e.self,n,o,a,r);return}e.system._relay(e.self,n,o.type===T4?N2(e.self.id,o.data):o)})}function xp(e,t,n){function o(a,r){}return o.type="xstate.sendTo",o.to=e,o.event=t,o.id=n?.id,o.delay=n?.delay,o.resolve=_U,o.retryResolve=CU,o.execute=EU,o}function o5(e,t){return xp(cy.Parent,e,t)}function TU(e,t,n,o,{collect:a}){let r=[],s=function(l){r.push(l)};return s.assign=(...i)=>{r.push(Dn(...i))},s.cancel=(...i)=>{r.push(Ac(...i))},s.raise=(...i)=>{r.push(kc(...i))},s.sendTo=(...i)=>{r.push(xp(...i))},s.sendParent=(...i)=>{r.push(o5(...i))},s.spawnChild=(...i)=>{r.push(vc(...i))},s.stopChild=(...i)=>{r.push(Si(...i))},s.emit=(...i)=>{r.push(uy(...i))},a({context:n.context,event:n.event,enqueue:s,check:i=>Li(i,t.context,n.event,t),self:e.self,system:e.system},o),[t,void 0,r]}function Et(e){function t(n,o){}return t.type="xstate.enqueueActions",t.collect=e,t.resolve=TU,t}function IU(e,t,n,o,{value:a,label:r}){return[t,{value:typeof a=="function"?a(n,o):a,label:r},void 0]}function MU({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function W2(e=({context:n,event:o})=>({context:n,event:o}),t){function n(o,a){}return n.type="xstate.log",n.value=e,n.label=t,n.resolve=IU,n.execute=MU,n}function RU(e,t){return new ly(e,t)}function q2({schemas:e,actors:t,actions:n,guards:o,delays:a}){return{assign:Dn,sendTo:xp,raise:kc,log:W2,cancel:Ac,stopChild:Si,enqueueActions:Et,emit:uy,spawnChild:vc,createStateConfig:r=>r,createAction:r=>r,createMachine:r=>RU({...r,schemas:e},{actors:t,actions:n,guards:o,delays:a}),extend:r=>q2({schemas:e,actors:t,actions:{...n,...r.actions},guards:{...o,...r.guards},delays:{...a,...r.delays}})}}var OU=()=>({mode:zE,pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null}),ki=4,Qo=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o>=ki*ki},bp=(e,t)=>{let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y);return{x:n,y:o,width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}},a5=q2({types:{context:{},events:{},emitted:{}},actions:{startPress:Dn((e,t)=>({pressOrigin:t.point,pressLast:t.point,pressTarget:t.target,pressModifiers:t.modifiers})),updateLast:Dn((e,t)=>({pressLast:t.point})),setDrawingType:Dn((e,t)=>({drawingType:t.kind})),resetGesture:Dn(()=>({pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null})),setMode:Dn((e,t)=>({mode:t.mode})),emitMoveElement:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="element"||n.emit({type:"MOVE_SHAPE",id:e.pressTarget.id,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitMoveAnnotation:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="annotation"||n.emit({type:"MOVE_ANNOTATION",id:e.pressTarget.id,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalPosition:e.pressTarget.origin})}),emitCommitAnnotationDrag:Et(({context:e,enqueue:t})=>{e.pressTarget?.kind==="annotation"&&t.emit({type:"COMMIT_ANNOTATION_DRAG",id:e.pressTarget.id})}),emitResizeElement:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="handle"||n.emit({type:"RESIZE_SHAPE",id:e.pressTarget.elementId,handle:e.pressTarget.handle,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitResizeGroup:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="group-handle"||n.emit({type:"RESIZE_GROUP",handle:e.pressTarget.handle,delta:{x:t.point.x-e.pressOrigin.x,y:t.point.y-e.pressOrigin.y},originalBounds:e.pressTarget.bounds})}),emitRotate:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="rotate-handle")return;let{pivot:o}=e.pressTarget,a=Math.atan2(e.pressOrigin.y-o.y,e.pressOrigin.x-o.x),r=Math.atan2(t.point.y-o.y,t.point.x-o.x);n.emit({type:"ROTATE",pivot:o,deltaAngle:r-a})}),maybeEmitCreate:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin||!e.drawingType)return;let o=bp(e.pressOrigin,t.point);o.width<1||o.height<1||n.emit({type:"CREATE_SHAPE",shapeType:e.drawingType,bounds:o})}),emitLinkPreview:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||n.emit({type:"DRAW_EDGE_PREVIEW",fromElement:e.pressTarget?.kind==="element"?e.pressTarget.id:null,fromPoint:e.pressOrigin,toPoint:t.point})}),emitLinkPreviewClear:Et(({enqueue:e})=>{e.emit({type:"DRAW_EDGE_PREVIEW_CLEAR"})}),emitLinkEndpointPreview:Et(({context:e,event:t,enqueue:n})=>{t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind==="edge-endpoint"&&n.emit({type:"UPDATE_EDGE_ENDPOINT_PREVIEW",linkId:e.pressTarget.linkId,side:e.pressTarget.side,toPoint:t.point})}),emitLinkEndpointUpdate:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin||e.pressTarget?.kind!=="edge-endpoint")return;let o=t.target,a=o?.kind==="element"?o.id:null;n.emit({type:"UPDATE_EDGE_ENDPOINT",linkId:e.pressTarget.linkId,side:e.pressTarget.side,toPoint:t.point,toElement:a})}),emitLassoProgress:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_MOVE"||!e.pressOrigin)return;let o=e.pressModifiers,a=!!(o&&(o.shift||o.meta||o.ctrl));n.emit({type:"LASSO_PROGRESS",bounds:bp(e.pressOrigin,t.point),mode:a?"add":"replace"})}),emitLassoCommit:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin)return;let o=bp(e.pressOrigin,t.point);if(o.width<1&&o.height<1){n.emit({type:"LASSO_CLEAR"});return}let a=e.pressModifiers,r=!!(a&&(a.shift||a.meta||a.ctrl));n.emit({type:"SELECT_BY_BOUNDS",bounds:o,mode:r?"add":"replace"}),n.emit({type:"LASSO_CLEAR"})}),emitCreateLink:Et(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin)return;let o=t.target,a=o?.kind==="element"?o.id:null,r=e.pressTarget?.kind==="element"?e.pressTarget.id:null,s=t.point.x-e.pressOrigin.x,i=t.point.y-e.pressOrigin.y;s*s+i*i<ki*ki||n.emit({type:"CREATE_EDGE",fromElement:r,toElement:a,fromPoint:e.pressOrigin,toPoint:t.point})})},guards:{movedAndOnElement:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="element"||e.mode!=="select"?!1:Qo(e.pressOrigin,t.point),movedAndOnHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="handle"?!1:Qo(e.pressOrigin,t.point),movedAndOnGroupHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="group-handle"?!1:Qo(e.pressOrigin,t.point),movedAndOnRotateHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="rotate-handle"?!1:Qo(e.pressOrigin,t.point),movedAndDrawing:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="draw-rect"&&e.mode!=="draw-ellipse"&&e.mode!=="draw-frame"?!1:Qo(e.pressOrigin,t.point),movedAndDrawingLink:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="draw-edge"?!1:Qo(e.pressOrigin,t.point),movedAndOnLinkEndpoint:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="edge-endpoint"?!1:Qo(e.pressOrigin,t.point),movedAndOnAnnotation:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="annotation"||e.mode!=="select"?!1:Qo(e.pressOrigin,t.point),movedAndLasso:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="select"||e.pressTarget?.kind!=="empty"?!1:Qo(e.pressOrigin,t.point)}}).createMachine({id:"interaction",initial:"idle",context:OU(),on:{SET_MODE:{target:".idle",actions:[{type:"setMode",params:({event:e})=>({mode:e.mode})},{type:"resetGesture"}]}},states:{idle:{on:{POINTER_DOWN:{target:"pressing",actions:[{type:"startPress",params:({event:e})=>({point:e.point,target:e.target,modifiers:e.modifiers??null})}]}}},pressing:{on:{POINTER_MOVE:[{guard:"movedAndOnHandle",target:"draggingHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeElement"}]},{guard:"movedAndOnGroupHandle",target:"draggingGroupHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeGroup"}]},{guard:"movedAndOnRotateHandle",target:"draggingRotateHandle",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitRotate"}]},{guard:"movedAndOnElement",target:"draggingElement",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveElement"}]},{guard:"movedAndDrawing",target:"drawing",actions:[{type:"setDrawingType",params:({context:e})=>({kind:e.mode==="draw-rect"?"rect":e.mode==="draw-frame"?"frame":"ellipse"})},{type:"updateLast",params:({event:e})=>({point:e.point})}]},{guard:"movedAndDrawingLink",target:"drawingLink",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkPreview"}]},{guard:"movedAndOnLinkEndpoint",target:"draggingLinkEndpoint",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkEndpointPreview"}]},{guard:"movedAndOnAnnotation",target:"draggingAnnotation",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveAnnotation"}]},{guard:"movedAndLasso",target:"lassoing",actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLassoProgress"}]},{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})}]}],POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingElement:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveElement"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeElement"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingGroupHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitResizeGroup"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingRotateHandle:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitRotate"}]},POINTER_UP:{target:"idle",actions:[{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},drawing:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})}]},POINTER_UP:{target:"idle",actions:[{type:"maybeEmitCreate"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},drawingLink:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkPreview"}]},POINTER_UP:{target:"idle",actions:[{type:"emitCreateLink"},{type:"emitLinkPreviewClear"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"emitLinkPreviewClear"},{type:"resetGesture"}]}}},draggingLinkEndpoint:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLinkEndpointPreview"}]},POINTER_UP:{target:"idle",actions:[{type:"emitLinkEndpointUpdate"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},draggingAnnotation:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitMoveAnnotation"}]},POINTER_UP:{target:"idle",actions:[{type:"emitCommitAnnotationDrag"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"resetGesture"}]}}},lassoing:{on:{POINTER_MOVE:{actions:[{type:"updateLast",params:({event:e})=>({point:e.point})},{type:"emitLassoProgress"}]},POINTER_UP:{target:"idle",actions:[{type:"emitLassoCommit"},{type:"resetGesture"}]},POINTER_CANCEL:{target:"idle",actions:[{type:"emitLassoCommit"},{type:"resetGesture"}]}}}}}),r5=(e,t)=>{if(!e.pressOrigin||!e.pressTarget||Qo(e.pressOrigin,t)||e.mode==="draw-edge")return null;if(e.pressTarget.kind==="element"){let n=e.pressModifiers;return n&&(n.shift||n.meta||n.ctrl)?{type:"SELECT_TOGGLE",id:e.pressTarget.id}:{type:"SELECT_REPLACE",id:e.pressTarget.id}}if(e.pressTarget.kind==="link"){let n=e.pressModifiers;return n&&(n.shift||n.meta||n.ctrl)?{type:"SELECT_EDGE_TOGGLE",id:e.pressTarget.id}:{type:"SELECT_EDGE_REPLACE",id:e.pressTarget.id}}return e.pressTarget.kind==="empty"&&e.mode==="select"?{type:"SELECT_CLEAR"}:null};var s5=new Map,ro=(e,t)=>{s5.set(e,t)},Jr=e=>s5.get(e);var wi=["background","main","overlay"];var i5=(e,t)=>{let n=new Map,o=r=>{e.setOpacity(r*t)},a={get(r,s){if(s==="setOpacity")return o;if(n.has(s))return n.get(s);let i=Reflect.get(r,s),l=typeof i=="function"?i.bind(r):i;return n.set(s,l),l}};return new Proxy(e,a)};var es=class{entries=new Map;get(t){let n=this.entries.get(t.id);if(n){if(n.ref!==t){this.entries.delete(t.id);return}return n.value}}set(t,n){return this.entries.set(t.id,{ref:t,value:n}),n}getOrCompute(t,n){let o=this.get(t);return o!==void 0?o:this.set(t,n(t))}invalidate(t){this.entries.delete(t)}clear(){this.entries.clear()}prune(t){for(let n of this.entries.keys())t.elements.has(n)||this.entries.delete(n)}get size(){return this.entries.size}},DU=new es,_c=(e,t)=>e.getOrCompute(t,z);var j2={gray1:"#111111",gray2:"#191919",gray3:"#222222",gray4:"#2a2a2a",gray5:"#313131",gray6:"#3a3a3a",gray7:"#484848",gray8:"#606060",gray9:"#6e6e6e",gray10:"#7b7b7b",gray11:"#b4b4b4",gray12:"#eeeeee"};var dy={tomato1:"#181111",tomato2:"#1f1513",tomato3:"#391714",tomato4:"#4e1511",tomato5:"#5e1c16",tomato6:"#6e2920",tomato7:"#853a2d",tomato8:"#ac4d39",tomato9:"#e54d2e",tomato10:"#ec6142",tomato11:"#ff977d",tomato12:"#fbd3cb"};var V2={plum1:"#181118",plum2:"#201320",plum3:"#351a35",plum4:"#451d47",plum5:"#512454",plum6:"#5e3061",plum7:"#734079",plum8:"#92549c",plum9:"#ab4aba",plum10:"#b658c4",plum11:"#e796f3",plum12:"#f4d4f4"};var _i={iris1:"#13131e",iris2:"#171625",iris3:"#202248",iris4:"#262a65",iris5:"#303374",iris6:"#3d3e82",iris7:"#4a4a95",iris8:"#5958b1",iris9:"#5b5bd6",iris10:"#6e6ade",iris11:"#b1a9ff",iris12:"#e0dffe"};var Z2={cyan1:"#0b161a",cyan2:"#101b20",cyan3:"#082c36",cyan4:"#003848",cyan5:"#004558",cyan6:"#045468",cyan7:"#12677e",cyan8:"#11809c",cyan9:"#00a2c7",cyan10:"#23afd0",cyan11:"#4ccce6",cyan12:"#b6ecf7"};var X2={grass1:"#0e1511",grass2:"#141a15",grass3:"#1b2a1e",grass4:"#1d3a24",grass5:"#25482d",grass6:"#2d5736",grass7:"#366740",grass8:"#3e7949",grass9:"#46a758",grass10:"#53b365",grass11:"#71d083",grass12:"#c2f0c2"};var Y2={amber1:"#16120c",amber2:"#1d180f",amber3:"#302008",amber4:"#3f2700",amber5:"#4d3000",amber6:"#5c3d05",amber7:"#714f19",amber8:"#8f6424",amber9:"#ffc53d",amber10:"#ffd60a",amber11:"#ffca16",amber12:"#ffe7b3"};var Cc={gray1:"#fcfcfc",gray2:"#f9f9f9",gray3:"#f0f0f0",gray4:"#e8e8e8",gray5:"#e0e0e0",gray6:"#d9d9d9",gray7:"#cecece",gray8:"#bbbbbb",gray9:"#8d8d8d",gray10:"#838383",gray11:"#646464",gray12:"#202020"};var Ci={tomato1:"#fffcfc",tomato2:"#fff8f7",tomato3:"#feebe7",tomato4:"#ffdcd3",tomato5:"#ffcdc2",tomato6:"#fdbdaf",tomato7:"#f5a898",tomato8:"#ec8e7b",tomato9:"#e54d2e",tomato10:"#dd4425",tomato11:"#d13415",tomato12:"#5c271f"};var K2={plum1:"#fefcff",plum2:"#fdf7fd",plum3:"#fbebfb",plum4:"#f7def8",plum5:"#f2d1f3",plum6:"#e9c2ec",plum7:"#deade3",plum8:"#cf91d8",plum9:"#ab4aba",plum10:"#a144af",plum11:"#953ea3",plum12:"#53195d"};var Va={iris1:"#fdfdff",iris2:"#f8f8ff",iris3:"#f0f1fe",iris4:"#e6e7ff",iris5:"#dadcff",iris6:"#cbcdff",iris7:"#b8baf8",iris8:"#9b9ef0",iris9:"#5b5bd6",iris10:"#5151cd",iris11:"#5753c6",iris12:"#272962"};var $2={cyan1:"#fafdfe",cyan2:"#f2fafb",cyan3:"#def7f9",cyan4:"#caf1f6",cyan5:"#b5e9f0",cyan6:"#9ddde7",cyan7:"#7dcedc",cyan8:"#3db9cf",cyan9:"#00a2c7",cyan10:"#0797b9",cyan11:"#107d98",cyan12:"#0d3c48"};var Ec={grass1:"#fbfefb",grass2:"#f5fbf5",grass3:"#e9f6e9",grass4:"#daf1db",grass5:"#c9e8ca",grass6:"#b2ddb5",grass7:"#94ce9a",grass8:"#65ba74",grass9:"#46a758",grass10:"#3e9b4f",grass11:"#2a7e3b",grass12:"#203c25"};var Tc={amber1:"#fefdfb",amber2:"#fefbe9",amber3:"#fff7c2",amber4:"#ffee9c",amber5:"#fbe577",amber6:"#f3d673",amber7:"#e9c162",amber8:"#e2a336",amber9:"#ffc53d",amber10:"#ffba18",amber11:"#ab6400",amber12:"#4f3422"};var ts=["tomato","amber","grass","cyan","iris","plum","gray"],Ap=(e,t)=>{let n=e[t];if(n===void 0)throw new Error(`Missing color token: ${t}`);return n},fn=(e,t)=>({fill:Ap(e,`${t}4`),solid:Ap(e,`${t}9`),solidHover:Ap(e,`${t}10`),textLow:Ap(e,`${t}11`),textHigh:Ap(e,`${t}12`)}),Ic={light:{tomato:fn(Ci,"tomato"),amber:fn(Tc,"amber"),grass:fn(Ec,"grass"),cyan:fn($2,"cyan"),iris:fn(Va,"iris"),plum:fn(K2,"plum"),gray:fn(Cc,"gray")},dark:{tomato:fn(dy,"tomato"),amber:fn(Y2,"amber"),grass:fn(X2,"grass"),cyan:fn(Z2,"cyan"),iris:fn(_i,"iris"),plum:fn(V2,"plum"),gray:fn(j2,"gray")}},fy={light:{tomato:Ci.tomato2,amber:Tc.amber2,grass:Ec.grass2,cyan:$2.cyan2,iris:Va.iris2,plum:K2.plum2,gray:Cc.gray2},dark:{tomato:dy.tomato2,amber:Y2.amber2,grass:X2.grass2,cyan:Z2.cyan2,iris:_i.iris2,plum:V2.plum2,gray:j2.gray2}};var PU={light:{accent:Va.iris9,accentHover:Va.iris10,selectedBg:Va.iris4,selectedFg:Va.iris11,danger:Ci.tomato9},dark:{accent:_i.iris9,accentHover:_i.iris10,selectedBg:_i.iris4,selectedFg:_i.iris11,danger:dy.tomato9}},Q2=Cc.gray6,J2=Cc.gray9,ns={rectangle:{fill:Va.iris3,stroke:Va.iris9,strokeWidth:2},ellipse:{fill:Ci.tomato3,stroke:Ci.tomato9,strokeWidth:2},flowchart:{fill:Ec.grass3,stroke:Ec.grass9,strokeWidth:2},sticky:{fill:Tc.amber3,stroke:Tc.amber9,strokeWidth:1}},Mc={stroke:Cc.gray12,strokeWidth:1.5},BU={added:Ec.grass9,removed:Ci.tomato9,modified:Tc.amber9};var ev={placeholder:.15,hideText:.4},tv="#bbb";var nv=.06,ov=.92,av=.5,Rc=10,rv=Q2,sv=J2,iv=1,lv=1,cv=4,uv=4,dv=3,fv=12,pv=56,hv=10,mv=20,l5=.4,c5=.5,yv=.1,gv=.9,u5="#888",d5="#ffffff",f5="#222",p5="#ddd",h5=18,m5=12,y5="#444",g5="#222",x5=10,xv="#000",b5=.5,A5=12,v5="#222",S5="#fff";var vp=class{cap;onEvict;map=new Map;constructor(t,n){this.cap=t,this.onEvict=n}get(t){let n=this.map.get(t);if(n!==void 0)return this.map.delete(t),this.map.set(t,n),n}has(t){return this.map.has(t)}set(t,n){for(this.map.delete(t),this.map.set(t,n);this.map.size>this.cap;){let o=this.map.keys().next().value,a=this.map.get(o);this.map.delete(o),a!==void 0&&this.onEvict?.(o,a)}}delete(t){return this.map.delete(t)}clear(){this.map.clear()}get size(){return this.map.size}keys(){return this.map.keys()}values(){return this.map.values()}};var py=e=>e<=0?1:2**Math.round(Math.log2(e));var Za=(e,t,n={})=>{let o=oo(e.viewport),a=n.dirtyWorld;if(!n.skipClear)if(a){let T=[N.applyToPoint(o,{x:a.x,y:a.y}),N.applyToPoint(o,{x:a.x+a.width,y:a.y+a.height})],w=V.expand(V.fromPoints(T),2);t.clear(w)}else t.clear();t.save(),t.setTransform(o);let r=n.boundsCache??new es,s=n.viewport,i=null;s&&n.spatialIndex&&(i=n.spatialIndex.query(s));let l=e.viewport.zoom,c=n.clock,u=c?{zoom:l,clock:c}:{zoom:l},d=n.lod,f=d?.placeholder!==void 0&&l<d.placeholder,p=d?.hideText!==void 0&&l<d.hideText,h=n.placeholderFill??tv,m=n.layerCompositeCache,x=n.dirtyLayerIds,y=n.compositeLayerBitmap,g=py(l),b=T=>{let w=null;for(let S of Ua(e,T)){let L=_c(r,S);w=w?V.union(w,L):L}return w},A=n.dimOpacity,_=n.dimElements!==void 0&&A!==void 0?i5(t,A):null;for(let T of vo(e))if(T.visible){if(m&&y){x?.has(T.id)&&m.invalidateLayer(T.id);let w=m.get(T.id,g);if(w===void 0){let S=y(T.id,g,e);S!==null&&(m.set(T.id,g,S),w=S)}if(w!==void 0){let S=b(T.id);S&&t.drawImage(w,S.x,S.y,S.width,S.height);continue}}for(let w of Ua(e,T.id)){if(n.hideElements?.has(w.id)||i&&!i.has(w.id))continue;if(s){let B=_c(r,w);if(!V.intersects(B,s))continue}if(a){let B=_c(r,w);if(!V.intersects(B,a))continue}if(p&&fe(w))continue;if(f){let B=_c(r,w);t.setFill(h),t.setStrokeWidth(0),t.beginPath(),t.rect(B.x,B.y,B.width,B.height),t.fill();continue}let S=Jr(w.type);if(!S){n.onUnknownElement?.(w);continue}t.save();let L=_!==null&&n.dimElements?.has(w.id)===!0,M=L?_:t;L&&M.setOpacity(1),M.translate(w.position.x,w.position.y),w.rotation!==0&&M.rotate(w.rotation),(w.scale.x!==1||w.scale.y!==1)&&M.scale(w.scale.x,w.scale.y),S(w,M,u),t.restore()}}t.restore()};var hy=class{entries=new Map;get(t,n){let o=this.entries.get(n.id);if(o){if(o.edge!==n||o.scene!==t){this.entries.delete(n.id);return}return o.value}}set(t,n,o){return this.entries.set(n.id,{edge:n,scene:t,value:o}),o}getOrCompute(t,n){let o=this.get(t,n);return o!==void 0?o:this.set(t,n,os(t,n))}invalidate(t){this.entries.delete(t)}clear(){this.entries.clear()}prune(t){for(let n of this.entries.keys())t.links.has(n)||this.entries.delete(n)}get size(){return this.entries.size}},os=(e,t)=>{let n=cc(e,t);if(!n||n.length===0)return null;let o=1/0,a=1/0,r=-1/0,s=-1/0;for(let u of n)u.x<o&&(o=u.x),u.y<a&&(a=u.y),u.x>r&&(r=u.x),u.y>s&&(s=u.y);let i=t.arrowheads,l=i?.from!==void 0&&i.from!=="none"||i?.to!==void 0&&i.to!=="none",c=Math.max(2,(t.style.strokeWidth??1)/2+(l?i.size??10:0));return{x:o-c,y:a-c,width:r-o+c*2,height:s-a+c*2}},bv=new hy;var Pn=(e,t,n={})=>{t.save(),t.setTransform(oo(e.viewport));let o=n.edgeBoundsCache??bv,a=n.viewportWorld,r=n.dirtyWorld,s=n.edgeBitmapCache,i=n.rasteriseLink,l=py(n.zoom??e.viewport.zoom);for(let c of vo(e))if(c.visible)for(let u of yA(e,c.id)){let d=null;if(a||r||s&&i){if(d=o.getOrCompute(e,u),d===null){n.onMissingEndpoint?.(u);continue}if(a&&!V.intersects(d,a)||r&&!V.intersects(d,r))continue}if(s&&i&&d){let f=s.get(u,l);if(f===void 0){let p=i(u,d,e,l);p!==null&&(s.set(u,l,p),f=p)}if(f!==void 0){t.drawImage(f,d.x,d.y,d.width,d.height);continue}}NU(e,u,t,n)}t.restore()},NU=(e,t,n,o)=>{let a=ot(e,t);if(!a||a.length<2){o.onMissingEndpoint?.(t);return}if(n.save(),(t.lineKind??"line")==="block-arrow")zU(t,a,n);else{UU(t,n);let r=(t.routing??"straight")==="bezier"?jf(e,t):null;if(n.beginPath(),r){n.moveTo(r.start.x,r.start.y);for(let s of r.segments)n.bezierCurveTo(s.c1.x,s.c1.y,s.c2.x,s.c2.y,s.to.x,s.to.y)}else if(a.length>=3&&Rc>0)my(n,a,Rc);else{let s=v(a[0]);n.moveTo(s.x,s.y);for(let i=1;i<a.length;i++){let l=v(a[i]);n.lineTo(l.x,l.y)}}if(n.stroke(),t.arrowheads){let s=r?Hf(r.start,r.segments):a;GU(s,t.arrowheads,n,t.style.stroke??xv)}}t.label&&WU(a,t.label,n),n.restore()},zU=(e,t,n)=>{let o=e.blockArrow?.headLength??h5,a=e.blockArrow?.bodyThickness??m5,r=e.style.fill??e.style.stroke??y5,s=e.style.stroke??g5,i=e.style.strokeWidth??1;e.style.opacity!==void 0&&n.setOpacity(e.style.opacity);let l=FU(t,o);if(l.length<2)return;let c=L5(l,a/2),u=L5(l,-a/2),d=v(c[c.length-1]),f=v(u[u.length-1]),p=v(t[t.length-1]);n.setFill(r),n.setStroke(s),n.setStrokeWidth(i),n.beginPath();let h=v(c[0]);n.moveTo(h.x,h.y);for(let g=1;g<c.length;g++){let b=v(c[g]);n.lineTo(b.x,b.y)}let m=Math.max(0,a*.5),x=k5(d,p,m),y=k5(f,p,-m);n.lineTo(x.x,x.y),n.lineTo(p.x,p.y),n.lineTo(y.x,y.y);for(let g=u.length-1;g>=0;g--){let b=v(u[g]);n.lineTo(b.x,b.y)}n.closePath(),n.fill(),i>0&&n.stroke()},FU=(e,t)=>{if(e.length<2)return e;let n=t,o=[...e].reverse(),a=[v(o[0])];for(let r=1;r<o.length;r++){let s=v(a[a.length-1]),i=v(o[r]),l=i.x-s.x,c=i.y-s.y,u=Math.hypot(l,c);if(u>n){let d=n/u,f={x:s.x+l*d,y:s.y+c*d};return a[a.length-1]=f,a.push(...o.slice(r)),a.reverse()}n-=u,a[a.length-1]=i}return e},L5=(e,t)=>{if(e.length<2)return e;let n=[];for(let o=0;o<e.length;o++){let a=v(e[Math.max(0,o-1)]),r=v(e[Math.min(e.length-1,o+1)]),s=v(e[o]),i=r.x-a.x,l=r.y-a.y,c=Math.hypot(i,l)||1,u=-l/c,d=i/c;n.push({x:s.x+u*t,y:s.y+d*t})}return n},k5=(e,t,n)=>{let o=t.x-e.x,a=t.y-e.y,r=Math.hypot(o,a)||1,s=-a/r,i=o/r;return{x:e.x+s*n,y:e.y+i*n}},HU=e=>{if(e.length<=2)return e;let t=[v(e[0])];for(let n=1;n<e.length-1;n++){let o=v(t[t.length-1]),a=v(e[n]),r=v(e[n+1]),s=Math.abs(o.y-a.y)<1e-6&&Math.abs(a.y-r.y)<1e-6,i=Math.abs(o.x-a.x)<1e-6&&Math.abs(a.x-r.x)<1e-6,l=Math.abs(o.x-a.x)<1e-6&&Math.abs(o.y-a.y)<1e-6;s||i||l||t.push(a)}return t.push(v(e[e.length-1])),t},my=(e,t,n)=>{let o=HU(t);if(o.length<3){let s=v(o[0]);e.moveTo(s.x,s.y);for(let i=1;i<o.length;i++){let l=v(o[i]);e.lineTo(l.x,l.y)}return}let a=v(o[0]);e.moveTo(a.x,a.y);for(let s=1;s<o.length-1;s++){let i=v(o[s-1]),l=v(o[s]),c=v(o[s+1]),u=Math.hypot(i.x-l.x,i.y-l.y),d=Math.hypot(c.x-l.x,c.y-l.y);if(u<1e-6||d<1e-6){e.lineTo(l.x,l.y);continue}let f=Math.min(n,u/2,d/2),p={x:l.x+(i.x-l.x)/u*f,y:l.y+(i.y-l.y)/u*f},h={x:l.x+(c.x-l.x)/d*f,y:l.y+(c.y-l.y)/d*f};e.lineTo(p.x,p.y),e.quadraticCurveTo(l.x,l.y,h.x,h.y)}let r=v(o[o.length-1]);e.lineTo(r.x,r.y)},UU=(e,t)=>{let n=e.style.stroke??xv;t.setStroke(n),t.setFill(null),t.setStrokeWidth(e.style.strokeWidth??1),e.style.opacity!==void 0&&t.setOpacity(e.style.opacity),e.style.lineCap!==void 0&&t.setLineCap(e.style.lineCap),e.style.lineJoin!==void 0&&t.setLineJoin(e.style.lineJoin),t.setDashArray(e.style.dashArray??null)},GU=(e,t,n,o)=>{let a=t.size??x5;if(t.from&&t.from!=="none"){let r=e[0],s=e[1];r!==void 0&&s!==void 0&&w5(r,s,t.from,a,n,o)}if(t.to&&t.to!=="none"){let r=e[e.length-1],s=e[e.length-2];r!==void 0&&s!==void 0&&w5(r,s,t.to,a,n,o)}},w5=(e,t,n,o,a,r)=>{let s=t.x-e.x,i=t.y-e.y,l=Math.hypot(s,i)||1,c=s/l,u=i/l,d=-u,f=c,p=o*.5,h=y=>({x:e.x+c*y,y:e.y+u*y}),m=(y,g)=>({x:e.x+c*y+d*g,y:e.y+u*y+f*g}),x=()=>{a.setFill(r),a.fill(),a.setFill(null),a.stroke()};switch(n){case"arrow":case"openArrow":case"roundedArrow":{let y=n==="openArrow"?o*.65:p,g=n==="openArrow"?o*1.1:o;n==="roundedArrow"&&a.setLineCap("round"),a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(e.x+c*g+d*y,e.y+u*g+f*y),a.moveTo(e.x,e.y),a.lineTo(e.x+c*g-d*y,e.y+u*g-f*y),a.stroke(),n==="roundedArrow"&&a.setLineCap("butt");break}case"arcArrow":{let y=m(o,p),g=m(o,-p),b=h(o*.45);a.beginPath(),a.moveTo(y.x,y.y),a.lineTo(e.x,e.y),a.lineTo(g.x,g.y),a.quadraticCurveTo(b.x,b.y,y.x,y.y),a.stroke();break}case"triangle":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...wo(m(o,p))),a.lineTo(...wo(m(o,-p))),a.closePath(),a.stroke();break}case"filledArrow":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...wo(m(o,p))),a.lineTo(...wo(m(o,-p))),a.closePath(),x();break}case"circle":case"filledCircle":{let y=p,g=h(y);a.beginPath(),a.ellipse(g.x,g.y,y,y),n==="filledCircle"?x():a.stroke();break}case"diamond":case"rhombus":case"filledRhombus":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...wo(m(o,p))),a.lineTo(...wo(h(o*2))),a.lineTo(...wo(m(o,-p))),a.closePath(),n==="filledRhombus"?x():a.stroke();break}case"erdOne":case"erdOnlyOne":case"erdMany":case"erdOneOrMany":case"erdZeroOrOne":case"erdZeroOrMany":{let y=n==="erdMany"||n==="erdOneOrMany"||n==="erdZeroOrMany",g=n==="erdZeroOrOne"||n==="erdZeroOrMany",b=n==="erdOnlyOne",A=n==="erdOne"||n==="erdOnlyOne"||n==="erdOneOrMany"||n==="erdZeroOrOne";if(y){let w=h(o);a.beginPath(),a.moveTo(w.x,w.y),a.lineTo(e.x,e.y),a.moveTo(w.x,w.y),a.lineTo(...wo(m(0,p))),a.moveTo(w.x,w.y),a.lineTo(...wo(m(0,-p))),a.stroke()}let _=y?o*1.15:o*.55,T=w=>{a.beginPath(),a.moveTo(...wo(m(w,p))),a.lineTo(...wo(m(w,-p))),a.stroke()};if(A&&T(_),b&&T(_+o*.4),g){let w=p*.6,S=h(o*(y?1.6:1)+w);a.beginPath(),a.ellipse(S.x,S.y,w,w),a.stroke()}break}}},wo=e=>[e.x,e.y],WU=(e,t,n)=>{let o=t.position??b5,a=t.fontSize??A5,r=t.fill??v5,s=t.background??S5,i=qU(e,o),l=t.text.length*a*.3+4,c=a*.7;n.beginPath(),n.setFill(s),n.setStroke(null),n.rect(i.x-l,i.y-c,l*2,c*2),n.fill(),n.setFill(r),n.setFont("system-ui, sans-serif",a),n.setTextAlign("center"),n.setTextBaseline("middle"),n.fillText(t.text,i.x,i.y)},qU=(e,t)=>{if(e.length===2){let[r,s]=e;return{x:r.x+(s.x-r.x)*t,y:r.y+(s.y-r.y)*t}}let n=[],o=0;for(let r=1;r<e.length;r++){let s=v(e[r]),i=v(e[r-1]),l=s.x-i.x,c=s.y-i.y,u=Math.hypot(l,c);n.push(u),o+=u}let a=o*t;for(let r=0;r<n.length;r++){let s=v(n[r]);if(a<=s){let i=s===0?0:a/s,l=v(e[r]),c=v(e[r+1]);return{x:l.x+(c.x-l.x)*i,y:l.y+(c.y-l.y)*i}}a-=s}return v(e[e.length-1])};var _5=(e,t,n,o,a=uv,r=dv)=>{let s=[];if(e<=0||t<=0)return s;let i=e*t,l=Math.ceil(Math.log(n/i)/Math.log(a));for(let c=0;c<r;c++){let u=l+c,d=e*a**u,f=d*t,p=Math.max(0,Math.min(1,(f-n)/(o-n)));p<=0||s.push({step:d,opacity:p})}return s},Sp=(e,t,n={})=>{if(n.skipClear||t.clear(),!e.viewport.gridEnabled)return;let o=20,r=(e.viewport.gridStyle??"lines")==="dots",s=n.color??(r?sv:rv),i=e.viewport.zoom,{width:l,height:c}=t.size;if(l<=0||c<=0)return;let u=XU(e,l,c);if(!u)return;let d=f=>{r?VU(t,u,f,s,i):jU(t,u,f,s,i)};if(t.save(),t.setTransform(oo(e.viewport)),t.setDashArray(null),n.levels)for(let f of n.levels){let p=ZU(i,f);if(p<=0)continue;let h=f.step*o;h*i<cv||(t.setOpacity(p),d(h))}else{let f=r?hv:fv,p=r?mv:pv;for(let h of _5(o,i,f,p))t.setOpacity(h.opacity),d(h.step)}t.setOpacity(1),t.restore()},jU=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=C5(t,n),c=iv/a;e.setStroke(o),e.setStrokeWidth(c),e.beginPath();for(let u=r;u<=s;u+=n)e.moveTo(u,i),e.lineTo(u,l);for(let u=i;u<=l;u+=n)e.moveTo(r,u),e.lineTo(s,u);e.stroke()},VU=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=C5(t,n);e.setStroke(null),e.setFill(o);let c=lv/a,u=c*2;for(let d=r;d<=s;d+=n)for(let f=i;f<=l;f+=n)e.beginPath(),e.rect(d-c,f-c,u,u),e.fill()},C5=(e,t)=>({minX:Math.floor(e.x/t)*t-t,maxX:Math.ceil((e.x+e.width)/t)*t+t,minY:Math.floor(e.y/t)*t-t,maxY:Math.ceil((e.y+e.height)/t)*t+t}),ZU=(e,t)=>e>=t.mid?1:e<=t.min?0:(e-t.min)/(t.mid-t.min),XU=(e,t,n)=>{let o=Wa(e.viewport),a=[N.applyToPoint(o,{x:0,y:0}),N.applyToPoint(o,{x:t,y:0}),N.applyToPoint(o,{x:t,y:n}),N.applyToPoint(o,{x:0,y:n})],r=V.fromPoints(a);return Number.isFinite(r.x)?r:null};var E5=1.2,YU=(e,t,n,o,a)=>{if(e===""){a.push({text:"",start:t,end:t,width:0});return}let r=[],s=/\S+/g,i;for(;(i=s.exec(e))!==null;)r.push({s:i.index,e:i.index+i[0].length});if(r.length===0){a.push({text:e,start:t,end:t+e.length,width:o(e)});return}let l=0,c=(d,f)=>{let p=e.slice(d,f);a.push({text:p,start:t+d,end:t+f,width:o(p)})},u=0;for(;u<r.length;){let d=v(r[u]);if(o(e.slice(l,d.e))<=n){u++;continue}if(d.s>l){c(l,d.s),l=d.s;continue}let f=d.s+1;for(;f<d.e&&o(e.slice(l,f+1))<=n;)f++;if(f>=d.e){u++;continue}c(l,f),l=f,d.s=f}c(l,e.length)},Oc=(e,t,n)=>{let o=n.fontSize*(n.lineHeightFactor??E5),a=[],r=0;for(let l=0;l<=e.length;l++)if(l===e.length||e[l]===`
|
|
13
|
+
`){let c=e.slice(r,l);n.maxWidth===void 0?a.push({text:c,start:r,end:l,width:t(c)}):YU(c,r,n.maxWidth,t,a),r=l+1}a.length===0&&a.push({text:"",start:0,end:0,width:0});let s=0;for(let l of a)s=Math.max(s,l.width);let i=n.maxWidth??s;return{lines:a,lineHeight:o,blockWidth:i}},Av=(e,t,n)=>n==="center"?t/2-e/2:n==="right"?t-e:0,KU=(e,t)=>{let{lines:n}=e;for(let o=0;o<n.length;o++){let a=v(n[o]);if(t<=a.end)return o}return n.length-1},vv=(e,t,n,o,a)=>{let r=KU(e,t),s=v(e.lines[r]),i=Math.max(0,Math.min(t,s.end)-s.start),l=i===0?0:n(s.text.slice(0,i));return{x:Av(s.width,e.blockWidth,a)+l,y:r*e.lineHeight,height:o,line:r}},Sv=(e,t,n,o)=>{let{lines:a,lineHeight:r}=e,s=Math.max(0,Math.min(a.length-1,Math.floor(t.y/r))),i=v(a[s]),l=Av(i.width,e.blockWidth,o),c=0,u=Math.abs(l-t.x);for(let d=1;d<=i.text.length;d++){let f=l+n(i.text.slice(0,d)),p=Math.abs(f-t.x);p<u&&(u=p,c=d)}return i.start+c},Lv=(e,t,n,o,a)=>{let r=Math.min(t,n),s=Math.max(t,n);if(r===s)return[];let i=[];for(let l=0;l<e.lines.length;l++){let c=v(e.lines[l]),u=Math.max(r,c.start),d=Math.min(s,c.end);if(u>d||u===d&&!(r<=c.start&&s>c.end)&&!(s>c.end&&r<=c.end))continue;let f=Av(c.width,e.blockWidth,a),p=f+(u===c.start?0:o(c.text.slice(0,u-c.start))),h=f+(d===c.start?0:o(c.text.slice(0,d-c.start))),m=s>c.end?e.lineHeight*.25:0;i.push({x:p,y:l*e.lineHeight,width:Math.max(0,h-p)+m,height:e.lineHeight})}return i};var T5=new Map,Lp=e=>{T5.set(e.kind,e)};var kv=new Set,wv=e=>(kv.add(e),()=>kv.delete(e)),_v=()=>{for(let e of kv)try{e()}catch{}},I5=()=>typeof performance<"u"?performance.now():0,Cv=e=>{I5=e};var Ei=(e,t=I5(e))=>{if(!e.animationKind)return e.src;let n=T5.get(e.animationKind);if(!n)return e.src;try{return n.getFrameAt(e.animationData,t)}catch{return e.src}};var wp=(e,t)=>{let n=e.fill!==void 0&&e.fill!=="transparent",o=e.stroke!==void 0&&e.stroke!=="transparent"&&(e.strokeWidth??1)>0;return n&&t.setFill(e.fill),o&&(t.setStroke(e.stroke),t.setStrokeWidth(e.strokeWidth??1),e.lineCap&&t.setLineCap(e.lineCap),e.lineJoin&&t.setLineJoin(e.lineJoin),e.dashArray&&t.setDashArray(e.dashArray)),e.opacity!==void 0&&t.setOpacity(e.opacity),{fill:n,stroke:o}},$U=(e,t)=>{let{fill:n,stroke:o}=wp(e.style,t);if(!n&&!o)return;let a=Rf(e.style.roundness,e.width,e.height);if(n&&(t.beginPath(),a>0?M5(t,0,0,e.width,e.height,a):t.rect(0,0,e.width,e.height),t.fill()),o){let r=gy(e.style),s=r,i=r,l=e.width-2*r,c=e.height-2*r;if(l<=0||c<=0)return;let u=a>0?Math.max(0,a-r):0;t.beginPath(),u>0?M5(t,s,i,l,c,u):t.rect(s,i,l,c),t.stroke()}},gy=e=>{let t=e.strokeAlign??"center";if(t==="center")return 0;let n=(e.strokeWidth??1)/2;return t==="inside"?n:-n},M5=(e,t,n,o,a,r)=>{e.moveTo(t+r,n),e.lineTo(t+o-r,n),e.quadraticCurveTo(t+o,n,t+o,n+r),e.lineTo(t+o,n+a-r),e.quadraticCurveTo(t+o,n+a,t+o-r,n+a),e.lineTo(t+r,n+a),e.quadraticCurveTo(t,n+a,t,n+a-r),e.lineTo(t,n+r),e.quadraticCurveTo(t,n,t+r,n),e.closePath()},QU=(e,t)=>{let{fill:n,stroke:o}=wp(e.style,t);if(!n&&!o)return;let a=e.width/2,r=e.height/2;if(n&&(t.beginPath(),t.ellipse(a,r,a,r),t.fill()),o){let s=gy(e.style),i=a-s,l=r-s;if(i<=0||l<=0)return;t.beginPath(),t.ellipse(a,r,i,l),t.stroke()}},JU=(e,t)=>{if(e.points.length<2)return;let{fill:n,stroke:o}=wp(e.style,t);if(!(!n&&!o)&&(n&&(t.beginPath(),yy(t,e.points),t.fill()),o)){let a=gy(e.style),r=a!==0?Mf.offsetClosedPath(e.points,a):e.points;t.beginPath(),yy(t,r),t.stroke()}},yy=(e,t)=>{let n=t[0];if(n!==void 0){e.moveTo(n.x,n.y);for(let o=1;o<t.length;o++){let a=t[o];a!==void 0&&e.lineTo(a.x,a.y)}e.closePath()}},eG=(e,t)=>{if(e.commands.length===0)return;let{fill:n,stroke:o}=wp(e.style,t);if(!(!n&&!o)){t.beginPath();for(let a of e.commands)switch(a.kind){case"M":t.moveTo(a.to.x,a.to.y);break;case"L":t.lineTo(a.to.x,a.to.y);break;case"Q":t.quadraticCurveTo(a.control.x,a.control.y,a.to.x,a.to.y);break;case"C":t.bezierCurveTo(a.control1.x,a.control1.y,a.control2.x,a.control2.y,a.to.x,a.to.y);break;case"Z":t.closePath();break}n&&t.fill(),o&&t.stroke()}},tG=(e,t)=>{let n=e.style.textAlign??"left",o=e.fontSize;t.setTextAlign("left"),t.setTextBaseline(e.style.textBaseline??"top");let a=c=>{let u=c?.fontWeight??e.style.fontWeight,d=c?.fontStyle??e.style.fontStyle;t.setFont(e.fontFamily,o,{...u?{weight:u}:{},...d?{style:d}:{}})};a(void 0);let r=Oc(e.text,c=>t.measureText(c).width,{fontSize:o,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{}}),s=r.lines.map(c=>{let u=Of(e,c.start,c.end).map(f=>(a(f.style),{text:f.text,style:f.style,width:t.measureText(f.text).width})),d=u.reduce((f,p)=>f+p.width,0);return{segs:u,total:d}}),i=e.maxWidth??s.reduce((c,u)=>Math.max(c,u.total),0),l=Math.max(1,o*nv);s.forEach((c,u)=>{let d=u*r.lineHeight,f=n==="center"?i/2-c.total/2:n==="right"?i-c.total:0;for(let p of c.segs){let h=p.style?.fill??e.style.fill??"#000",m=p.style?.opacity??e.style.opacity;a(p.style),t.setFill(h),m!==void 0&&t.setOpacity(m),t.fillText(p.text,f,d);let x=p.style?.textDecoration??e.style.textDecoration;p.width>0&&(x?.underline||x?.strikethrough)&&(x.underline&&(t.beginPath(),t.rect(f,d+o*ov,p.width,l),t.fill()),x.strikethrough&&(t.beginPath(),t.rect(f,d+o*av-l/2,p.width,l),t.fill())),f+=p.width}})},nG=(e,t)=>{if(e.runs!==void 0&&e.runs.length>0){tG(e,t);return}let n=e.style.textAlign??"left",o=e.style.fontWeight,a=e.style.fontStyle;t.setFont(e.fontFamily,e.fontSize,{...o?{weight:o}:{},...a?{style:a}:{}}),t.setTextAlign("left"),t.setTextBaseline(e.style.textBaseline??"top");let r=e.style.fill??"#000";t.setFill(r),e.style.opacity!==void 0&&t.setOpacity(e.style.opacity);let s=e.fontSize,i;if(e.maxWidth===void 0&&!e.text.includes(`
|
|
14
|
+
`))i=[{text:e.text,x:0,width:t.measureText(e.text).width,top:0}];else{let c=d=>t.measureText(d).width,u=Oc(e.text,c,{fontSize:s,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{}});i=u.lines.map((d,f)=>({text:d.text,x:n==="center"?u.blockWidth/2-d.width/2:n==="right"?u.blockWidth-d.width:0,width:d.width,top:f*u.lineHeight}))}for(let c of i)t.fillText(c.text,c.x,c.top);let l=e.style.textDecoration;if(l?.underline||l?.strikethrough){let c=Math.max(1,s*nv);for(let u of i)u.width<=0||(l.underline&&(t.beginPath(),t.rect(u.x,u.top+s*ov,u.width,c),t.fill()),l.strikethrough&&(t.beginPath(),t.rect(u.x,u.top+s*av-c/2,u.width,c),t.fill()))}},oG=(e,t)=>{let n=e.points;if(n.length===0)return;if(e.style.opacity!==void 0&&t.setOpacity(e.style.opacity),e.closed===!0&&e.style.fill!==void 0&&n.length>=3){t.setFill(e.style.fill),t.setStroke(null),t.beginPath();let r=v(n[0]);t.moveTo(r.x,r.y);for(let s=1;s<n.length;s++){let i=v(n[s]);t.lineTo(i.x,i.y)}t.closePath(),t.fill()}let o=Df(e.style);if(t.setFill(o),t.setStroke(null),n.length===1){let r=v(n[0]);t.beginPath(),t.ellipse(r.x,r.y,r.width,r.width),t.fill();return}let a=Zf(n);if(a.length>=3){t.beginPath();let r=v(a[0]);t.moveTo(r.x,r.y);for(let s=1;s<a.length;s++){let i=v(a[s]);t.lineTo(i.x,i.y)}t.closePath(),t.fill()}},aG=(e,t,n)=>{let o=n?.clock?.(e),a=e.animationKind?Ei(e,o):e.metadata?.image??Ei(e,o),r=e.metadata?.animated===!0||e.animationKind!==void 0;t.drawImage(a,0,0,e.width,e.height,r,e.crop)},Dc=()=>{ro("rectangle",$U),ro("ellipse",QU),ro("polygon",JU),ro("path",eG),ro("text",nG),ro("image",aG),ro("group",()=>{}),ro("frame",lG),RA("frame",()=>({top:24})),ro("block-arrow",rG),ro("brush",oG)},rG=(e,t)=>{let{fill:n,stroke:o}=wp(e.style,t),a=e.direction??"right",r=Math.max(yv,Math.min(gv,e.headRatio??l5)),s=Math.max(yv,Math.min(gv,e.bodyThickness??c5)),i=e.width,l=e.height,c=i*r,u=i-c,d=l*s/2,f=l/2,p=[[0,f-d],[u,f-d],[u,0],[i,f],[u,l],[u,f+d],[0,f+d]];a!=="right"&&(p=p.map(([m,x])=>sG([m,x],a,i,l)));let h=p.map(([m,x])=>({x:m,y:x}));if(n&&(t.beginPath(),yy(t,h),t.fill()),o){let m=gy(e.style),x=m!==0?Mf.offsetClosedPath(h,m):h;t.beginPath(),yy(t,x),t.stroke()}},sG=([e,t],n,o,a)=>{switch(n){case"left":return[o-e,t];case"up":return[t*(o/a),a-e*(a/o)];case"down":return[(a-t)*(o/a),e*(a/o)]}},Ev="\u2026",iG=(e,t,n)=>{if(t<=0)return"";if(n.measureText(e).width<=t)return e;let o=0,a=e.length;for(;o<a;){let r=Math.ceil((o+a)/2);n.measureText(e.slice(0,r)+Ev).width<=t?o=r:a=r-1}return o>0?e.slice(0,o)+Ev:Ev},lG=(e,t,n)=>{t.setFill(e.style.fill??d5),t.setStroke(null),t.setDashArray(null),t.beginPath(),t.rect(0,0,e.width,e.height),t.fill();let o=(n?.zoom??1)*(e.scale.x||1);t.setFill(null),t.setStroke(u5),t.setStrokeWidth(1/(o||1)),t.setDashArray(null),t.beginPath(),t.rect(0,0,e.width,e.height),t.stroke();let a=e.name??"Frame";t.setFont("system-ui, sans-serif",12);let r=e.width-16,s=t.measureText(a).width<=r,i=s?a:iG(a,r,t),l=s?Math.min(t.measureText(a).width+16,e.width):e.width;t.setFill(f5),t.beginPath(),t.rect(0,-24,l,24),t.fill(),t.setFill(p5),t.setTextBaseline("middle"),t.setTextAlign("left"),t.fillText(i,8,-24/2)};var R5=async(e,t)=>{if(e instanceof ArrayBuffer)return e;if(e instanceof Uint8Array)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if(e instanceof Response)return e.arrayBuffer();let n=typeof e=="string"?e:e.href;if(n.startsWith("file:")){let{readFile:a}=await import("node:fs/promises"),{fileURLToPath:r}=await import("node:url"),s=r(n),i=await a(s);return i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}let o=await fetch(e);if(!o.ok)throw new Error(`${t}: fetch failed (${o.status})`);return o.arrayBuffer()},_p=async(e,t)=>{if(typeof WebAssembly.instantiateStreaming=="function"&&(e instanceof Response||(typeof e=="string"||e instanceof URL)&&!String(e).startsWith("file:")))try{let r=e instanceof Response?e.clone():await fetch(e),{instance:s}=await WebAssembly.instantiateStreaming(r,{});return s}catch{}let o=await R5(e,t),{instance:a}=await WebAssembly.instantiate(o,{});return a},as=(e,t)=>{let n=t.byteLength,o=e.alloc(n);return new Uint8Array(e.memory.buffer,o,n).set(t),{ptr:o,len:n,free:()=>{e.free(o,n)}}};var O5=null,Cp=e=>{O5=e},Iv=()=>O5;var D5=null,Ep=e=>{D5=e},xy=()=>D5;var by={flatten(e,t){let n=r=>Math.min(128,Math.max(8,Math.ceil(r/Math.max(.1,t)))),o=[],a={x:0,y:0};for(let r of e)switch(r.kind){case"M":a=r.to,o.push(a);break;case"L":a=r.to,o.push(a);break;case"Q":{let s=Math.hypot(r.to.x-a.x,r.to.y-a.y),i=cn.flattenQuadratic(a,r.control,r.to,n(s));for(let l=1;l<i.length;l++)o.push(v(i[l]));a=r.to;break}case"C":{let s=Math.hypot(r.to.x-a.x,r.to.y-a.y),i=cn.flattenCubic(a,r.control1,r.control2,r.to,n(s));for(let l=1;l<i.length;l++)o.push(v(i[l]));a=r.to;break}case"Z":if(o.length>0){let s=v(o[0]);o.push(s),a=s}break}return o},strokeToFill(e,t,n){if(e.length<2)return e;let o=t/2,a=n?.cap??"butt";n?.join;let r=[],s=[];for(let i=0;i<e.length;i++){let l=v(e[Math.max(0,i-1)]),c=v(e[Math.min(e.length-1,i+1)]),u=v(e[i]),d=c.x-l.x,f=c.y-l.y,p=Math.hypot(d,f)||1,h=-f/p,m=d/p;r.push({x:u.x+h*o,y:u.y+m*o}),s.push({x:u.x-h*o,y:u.y-m*o})}return[...r,...s.reverse(),v(r[0])]}};var Ay=(e,t,n)=>{if(e.length<3)return e;let o=Ff(e.map(i=>({x:i.x,y:i.y}))),a=v(e[0]),r=[a],s={x:a.x,y:a.y};for(let i=0;i<o.length;i++){let l=v(o[i]),c=v(e[i]),u=v(e[i+1]);for(let d=1;d<=t;d++){let f=d/t,p=cn.cubicAt(s,l.c1,l.c2,l.to,f);r.push(n(c,u,p,f))}s=l.to}return r};var vy=(e,t)=>({points:[{x:e.x,y:e.y,t}]}),Mv=(e,t,n)=>{e.points.push({x:t.x,y:t.y,t:n})},Rv=(e,t,n=X0)=>{let o=!1,a=[];for(let r of e){let s=r.points.filter(i=>t-i.t<n);if(s.length===r.points.length){a.push(r);continue}o=!0,s.length>0&&a.push({points:s})}return o?{strokes:a,changed:o}:{strokes:e,changed:o}},P5=(e,t=WI)=>Ay(e,t,(n,o,a,r)=>({x:a.x,y:a.y,t:n.t+(o.t-n.t)*r}));var Ti=e=>e.type==="rectangle"||e.type==="ellipse"||e.type==="image"||e.type==="template"||e.type==="frame",cG=new Set(["rectangle","ellipse","template","text","frame"]),Ii=e=>cG.has(e.type),Ov=e=>mi;var _o=(e,t)=>{let n=So(e),a=[..._0(e).keys()].filter(s=>!n.has(s)),r=a.map(s=>{let i={kind:"named",name:s},l=Yt(e,i);if(t===0)return l;let c=jo(e,i);return{x:l.x+c.x*t,y:l.y+c.y*t}});return{names:a,worldPoints:r}};var z5=(e,t)=>{let n=t.scene.viewport.zoom,o=t.hitAnnotation(e);if(o!==null){let l=t.scene.annotations.get(o);if(l)return{kind:"annotation",id:o,origin:Kr(t.scene,l)}}let a=t.selection.size+t.selectedLinkCount>1||t.selectionIsAspectLocked();if(a){let l=t.combinedSelectionBounds();if(l){let u=t.selectionIsAspectLocked()?yi:mi,d=_2(e,l,n,t.handleHitSlop,u);if(d)return{kind:"group-handle",handle:d,bounds:l}}}if(t.selection.size===1)for(let l of t.selection){let c=I(t.scene,l);if(!c||!Ii(c)||c.locked===!0)continue;let u=xi(c),d=v4(e,u,n,t.handleHitSlop,Ov(c));if(d)return{kind:"handle",elementId:l,handle:d,bounds:u.bounds}}let r=a?t.combinedSelectionBounds():null;if(r){let l=Q0(r,n);if(C2(e,l,n,t.handleHitSlop))return{kind:"rotate-handle",pivot:{x:r.x+r.width/2,y:r.y+r.height/2},bounds:r}}else if(t.selection.size===1)for(let l of t.selection){let c=I(t.scene,l);if(!c||!Ii(c)||c.locked===!0)continue;let u=$0(c,n);if(C2(e,u,n,t.handleHitSlop)){let d=xi(c);return{kind:"rotate-handle",pivot:b4(d),bounds:d.bounds}}}if(t.selectedLink){let l=be(t.scene,t.selectedLink);if(l){let c=ot(t.scene,l);if(c&&c.length>=2){let u=t.edgeHandleHitSlop/n,d=v(c[0]),f=v(c[c.length-1]);if(U.distance(e,d)<=u)return{kind:"edge-endpoint",linkId:l.id,side:"from"};if(U.distance(e,f)<=u)return{kind:"edge-endpoint",linkId:l.id,side:"to"}}}}let s=t.acceleratedElementAt(e);if(s&&t.isElementInteractable(s)){let l=t.promoteToGroupRoot(s);return{kind:"element",id:l.id,bounds:z(l)}}let i=MA(t.scene,e,t.edgeHitThreshold/n);return i&&!t.isLayerLocked(i.layerId)?{kind:"link",id:i.id}:{kind:"empty"}},Tp=(e,t,n,o,a,r)=>{e.setStroke(null),e.setFill(r),e.setOpacity(hc),e.beginPath(),e.rect(t,n,o,a),e.fill(),e.setFill(null),e.setStroke(r),e.setStrokeWidth(1),e.setOpacity(ap),e.beginPath(),e.rect(t,n,o,a),e.stroke()},Mi=(e,t,n,o,a)=>{e.setStroke(null),e.setFill(a),e.setOpacity(hc),e.beginPath(),e.ellipse(t,n,o,o),e.fill(),e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setOpacity(ap),e.beginPath(),e.ellipse(t,n,o,o),e.stroke()},uG=(e,t,n,o,a)=>{e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setDashArray([2,2]),e.setOpacity(ap),e.beginPath(),e.ellipse(t,n,o,o),e.stroke(),e.setDashArray(null)},B5=(e,t,n)=>{if(t.length<3)return;e.setStroke(null),e.setFill(n),e.setOpacity(hc),e.beginPath();let o=v(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=v(t[a]);e.lineTo(r.x,r.y)}e.closePath(),e.fill(),e.setFill(null),e.setStroke(n),e.setStrokeWidth(1),e.setOpacity(ap),e.beginPath(),e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=v(t[a]);e.lineTo(r.x,r.y)}e.closePath(),e.stroke()},N5=(e,t,n,o,a,r)=>{let s=N.applyToPoint(t,{x:n.x,y:n.y}),i=N.applyToPoint(t,{x:n.x+n.width,y:n.y+n.height}),l=Math.min(s.x,i.x),c=Math.min(s.y,i.y),u=Math.abs(i.x-s.x),d=Math.abs(i.y-s.y),f=11;for(let p of a)switch(p){case"nw":case"ne":case"se":case"sw":{let h=N.applyToPoint(t,gi(p,n,o));Tp(e,h.x-f,h.y-f,f*2,f*2,r);break}case"n":Tp(e,l-f,c-f,u+f*2,f*2,r);break;case"s":Tp(e,l-f,c+d-f,u+f*2,f*2,r);break;case"w":Tp(e,l-f,c-f,f*2,d+f*2,r);break;case"e":Tp(e,l+u-f,c-f,f*2,d+f*2,r);break}},Sy=e=>{let t={resizeHandles:!1,linkBodies:!1,selectedEdgeHandles:!1,anchorDots:!1,attachDropZones:!1,containerDropZones:!1,groupHandles:!1,annotationPins:!1};return e.linkDragActive?{...t,attachDropZones:!0}:e.elementDragActive?{...t,containerDropZones:!0}:{...t,resizeHandles:!0,linkBodies:!0,selectedEdgeHandles:!0,anchorDots:!0,groupHandles:!0,annotationPins:!0}},F5=(e,t)=>{let{scene:n,w2s:o,zoom:a,selection:r,visibility:s,edgeSelection:i,attach:l,containers:c}=t,{groupBounds:u,groupAspectLocked:d}=t;if(e.save(),s.resizeHandles&&r.size===1){let f=v([...r][0]),p=I(n,f);p&&Ii(p)&&p.locked!==!0&&N5(e,o,z(p),a,Ov(p),c2)}if(s.linkBodies)for(let f of n.links.values()){let p=ot(n,f);if(!p||p.length<2)continue;e.setFill(null),e.setStroke(nI),e.setStrokeWidth(F0*2),e.setOpacity(hc),e.setLineCap("round"),e.setLineJoin("round"),e.beginPath();let h=N.applyToPoint(o,v(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=N.applyToPoint(o,v(p[m]));e.lineTo(x.x,x.y)}e.stroke()}if(s.selectedEdgeHandles&&i){let f=N.applyToPoint(o,i.from),p=N.applyToPoint(o,i.to);Mi(e,f.x,f.y,Zo,rp),Mi(e,p.x,p.y,Zo,rp);for(let h of i.waypoints??[]){let m=N.applyToPoint(o,h);Mi(e,m.x,m.y,Zo,rp)}for(let h of i.midpoints??[]){let m=N.applyToPoint(o,h);Mi(e,m.x,m.y,Zo,rp)}}if(s.anchorDots&&r.size===1){let f=v([...r][0]),p=I(n,f);if(p){let h=Xo+H0,{worldPoints:m}=_o(p,Lo/a);for(let x of m){let y=N.applyToPoint(o,x);Mi(e,y.x,y.y,h,u2),uG(e,y.x,y.y,U0,u2)}}}if(s.attachDropZones&&l){let f=l.thresholdWorld*a;for(let p of l.outlineLoops)B5(e,p.map(h=>N.applyToPoint(o,h)),rI);e.setFill(null),e.setStroke(aI),e.setStrokeWidth(f*2),e.setOpacity(hc),e.setLineCap("round"),e.setLineJoin("round");for(let p of l.outlineLoops){if(p.length<2)continue;e.beginPath();let h=N.applyToPoint(o,v(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=N.applyToPoint(o,v(p[m]));e.lineTo(x.x,x.y)}e.closePath(),e.stroke()}for(let p of l.anchors){let h=N.applyToPoint(o,p);Mi(e,h.x,h.y,f,oI)}}if(s.containerDropZones&&c){let f=(p,h)=>{let m=[{x:p.x,y:p.y},{x:p.x+p.width,y:p.y},{x:p.x+p.width,y:p.y+p.height},{x:p.x,y:p.y+p.height}].map(x=>N.applyToPoint(o,x));B5(e,m,h)};for(let p of c.frames)f(p,sI);for(let p of c.containers)f(p,iI)}if(s.groupHandles&&u&&N5(e,o,u,a,d?yi:mi,c2),s.annotationPins)for(let f of n.annotations.values()){let p=N.applyToPoint(o,Kr(n,f));Mi(e,p.x,p.y,j0,lI)}e.setOpacity(1),e.restore()};var G5=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=ze(o)?G5(e,o.id):z(o);a&&(n=n?V.union(n,a):a)}return n},W5={selectionStroke:"#1a73e8",selectionStrokeWidth:1,handleFill:"#fff",handleStroke:"#1a73e8",drawingStroke:"#1a73e8",drawingDash:[4,4]},q5=.32,j5=(e,t,n,o,a=W5)=>{if(n.length===0)return;let s=r2/(o||1);e.setTransform(t),e.setStroke(a.selectionStroke),e.setOpacity(q5),e.setDashArray(null),e.setLineJoin("miter"),e.setLineCap("butt");for(let{loops:i,outsetWorld:l}of n){e.setStrokeWidth(2*(l+s));for(let c of i){if(c.length<2)continue;e.beginPath();let u=!1;for(let d of c)u?e.lineTo(d.x,d.y):(e.moveTo(d.x,d.y),u=!0);e.closePath(),e.stroke()}}e.setOpacity(1),e.setTransform(N.IDENTITY)},V5=(e,t,n,o={})=>{let a={...W5,...o.style};n.clear();let r=oo(e.viewport),s=e.viewport.zoom;n.save(),n.setTransform(N.IDENTITY);let i={scene:e,selection:t,target:n,options:o,style:a,w2s:r,zoom:s};pG(i),hG(i),mG(i),yG(i),gG(i),xG(i),bG(i),vG(i),SG(i),LG(i),kG(i),wG(i),_G(i),CG(i),n.restore()},pG=e=>{let{scene:t,selection:n,target:o,options:a,w2s:r,zoom:s}=e;a.debugHitZones&&F5(o,{scene:t,w2s:r,zoom:s,selection:n,visibility:a.debugHitZoneVisibility??Sy({linkDragActive:!1,elementDragActive:!1}),...a.edgeSelection?{edgeSelection:a.edgeSelection}:{},...a.debugAttachZones?{attach:a.debugAttachZones}:{},...a.debugContainerZones?{containers:a.debugContainerZones}:{},...a.groupBounds?{groupBounds:a.groupBounds}:{},...a.groupAspectLocked!==void 0?{groupAspectLocked:a.groupAspectLocked}:{}})},hG=e=>{let{scene:t,selection:n,target:o,options:a,style:r,w2s:s,zoom:i}=e;if(a.cropFrame)return;let l=n.size>1;for(let c of n){let u=t.elements.get(c);if(!u)continue;if(ze(u)){let f=G5(t,c);if(!f)continue;let p=Jo(f,s);if(Pv(o,p,r),u.locked===!0){U5(o,p);continue}if(l||!Ii(u)||a.readOnly===!0)continue;for(let h of yi){let m=gi(h,f,i);Bv(o,N.applyToPoint(s,m),r)}X5(o,f,i,s,r);continue}let d=xi(u);if(d.rotation===0?Pv(o,Jo(d.bounds,s),r):TG(o,d,s,r),u.locked===!0){U5(o,IG(d,s));continue}if(!(l||!Ii(u)||a.readOnly===!0)){for(let f of yi){let p=A4(f,d,i);Bv(o,N.applyToPoint(s,p),r)}Z5(o,N.applyToPoint(s,$0(u,i)),r)}}},mG=e=>{let{target:t,options:n,style:o,w2s:a}=e;if(n.cropGhost&&PG(t,n.cropGhost,a),n.cropFrame&&n.cropFrame.length>=4){let r=n.cropFrame.map(s=>N.applyToPoint(a,s));OG(t,r,o),DG(t,r,o)}if(n.drawingPreview){let r=Jo(n.drawingPreview,a);MG(t,r,o)}if(n.drawingPreviewElement){let r=n.drawingPreviewElement,s=Jr(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(AI),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore())}if(n.flowchartPreviewElements&&n.flowchartPreviewElements.length>0)for(let r of n.flowchartPreviewElements){let s=Jr(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(K0),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore())}if(n.strokeErasePreviewElements&&n.strokeErasePreviewElements.length>0)for(let r of n.strokeErasePreviewElements){let s=Jr(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(1),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore())}if(n.edgePreview){let r=n.edgePreview.points;if(r&&r.length>=2)BG(t,r.map(s=>N.applyToPoint(a,s)),o);else{let s=N.applyToPoint(a,n.edgePreview.from),i=N.applyToPoint(a,n.edgePreview.to);RG(t,s,i,o)}}if(n.ghostElement||n.ghostElementShape){t.setOpacity(q0);let r=n.ghostElementShape,s=r?Jr(r.type):void 0;if(r&&s)t.save(),t.setTransform(a),t.setDashArray(null),t.translate(r.position.x,r.position.y),r.rotation!==0&&t.rotate(r.rotation),(r.scale.x!==1||r.scale.y!==1)&&t.scale(r.scale.x,r.scale.y),s(r,t),t.restore();else if(n.ghostElement){let i=Jo(n.ghostElement,a);t.setStroke(o.selectionStroke),t.setStrokeWidth(1.5),t.setDashArray(null),t.setFill(null),t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.stroke()}t.setOpacity(1)}if(n.linkAttachHighlight){let r=Jo(n.linkAttachHighlight,a),s=2;t.setStroke(o.selectionStroke),t.setStrokeWidth(2),t.setDashArray(null),t.setFill(null),t.beginPath(),t.rect(r.x-s,r.y-s,r.width+s*2,r.height+s*2),t.stroke()}},yG=e=>{let{target:t,options:n,style:o,w2s:a,zoom:r}=e;if(n.ports){let s=Array.isArray(n.ports)?n.ports:[n.ports];for(let i of s)for(let l=0;l<i.worldPoints.length;l++){let c=N.applyToPoint(a,v(i.worldPoints[l])),u=i.activeIndex===l;NG(t,c,u,i.role,u?i.activeRadius:void 0)}}if(n.selectedLinkPaths&&n.selectedLinkPaths.length>0){t.setTransform(a),t.setStroke(o.selectionStroke),t.setOpacity(q5),t.setDashArray(null),t.setLineJoin("round"),t.setLineCap("round");let s=r2/(r||1);for(let{path:i,width:l}of n.selectedLinkPaths)i.length<2||(t.setStrokeWidth(l+2*s),t.beginPath(),my(t,i,Rc),t.stroke());t.setOpacity(1),t.setLineJoin("miter"),t.setLineCap("butt"),t.setTransform(N.IDENTITY)}if(n.edgeSelection&&n.readOnly!==!0){let s=N.applyToPoint(a,n.edgeSelection.from),i=N.applyToPoint(a,n.edgeSelection.to);for(let l of n.edgeSelection.midpoints??[])zG(t,N.applyToPoint(a,l),o);Dv(t,s,o),Dv(t,i,o);for(let l of n.edgeSelection.waypoints??[])Dv(t,N.applyToPoint(a,l),o)}},gG=e=>{let{target:t,options:n,w2s:o}=e;if(n.peerSelections)for(let a of n.peerSelections)for(let r of a.bounds){let s=Jo(r,o);FG(t,s,a.color)}},xG=e=>{let{target:t,options:n,w2s:o}=e;if(n.brushPreview&&n.brushPreview.points.length>0){let a=n.brushPreview;t.save(),t.setTransform(o),t.setOpacity(a.opacity),t.setFill(a.fill),t.setStroke(null);let r=a.points,s=a.origin.x,i=a.origin.y;if(r.length===1){let l=v(r[0]);t.beginPath(),t.ellipse(s+l.x,i+l.y,l.width,l.width),t.fill()}else{let l=Zf(r);if(l.length>=3){t.beginPath();let c=v(l[0]);t.moveTo(s+c.x,i+c.y);for(let u=1;u<l.length;u++){let d=v(l[u]);t.lineTo(s+d.x,i+d.y)}t.closePath(),t.fill()}}t.restore()}},bG=e=>{let{target:t,options:n,w2s:o}=e;H5(t,o,n.laserStrokes,GI,S2,X0);let a=(n.eraserCursor?.radius??S2/2)*2;H5(t,o,n.eraserTrail,V0,a,Z0)},H5=(e,t,n,o,a,r)=>{if(!n||n.length===0)return;let s=typeof performance<"u"?performance.now():Date.now(),i=a/2;e.setStroke(null),e.setDashArray(null),e.setFill(o);for(let l of n){let c=P5(l.points);if(c.length===0)continue;let u=v(c[c.length-1]),d=1-(s-u.t)/r;if(d<=0)continue;e.setOpacity(d);let f=c.map(m=>N.applyToPoint(t,{x:m.x,y:m.y}));if(f.length===1){let m=v(f[0]);e.beginPath(),e.ellipse(m.x,m.y,i,i),e.fill();continue}let p=AG(f,i),h=v(p[0]);e.beginPath(),e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=v(p[m]);e.lineTo(x.x,x.y)}e.closePath(),e.fill()}e.setOpacity(1)},AG=(e,t)=>{let n=e.length,o=[],a=[];for(let r=0;r<n;r++){let s=v(e[r]),i=v(e[Math.max(0,r-1)]),l=v(e[Math.min(n-1,r+1)]),c=l.x-i.x,u=l.y-i.y,d=Math.hypot(c,u)||1;c/=d,u/=d;let f=t*(n>1?r/(n-1):1),p=-u*f,h=c*f;o.push({x:s.x+p,y:s.y+h}),a.push({x:s.x-p,y:s.y-h})}return a.reverse(),[...o,...a]},vG=e=>{let{target:t,options:n,w2s:o}=e,a=n.eraserCursor;if(!a||a.radius<=0)return;let r=N.applyToPoint(o,a.center);t.setDashArray(null),t.setOpacity(1),t.beginPath(),t.ellipse(r.x,r.y,a.radius,a.radius),t.setFill(V0),t.fill(),t.setFill(null),t.setStroke(V0),t.setStrokeWidth(NI),t.stroke()},SG=e=>{let{target:t,options:n,w2s:o}=e;if(n.containerDropZone){let a=Jo(n.containerDropZone,o);t.setFill("rgba(26, 115, 232, 0.10)"),t.setStroke("#1a73e8"),t.setStrokeWidth(2),t.setDashArray([6,3]),t.beginPath(),t.rect(a.x,a.y,a.width,a.height),t.fill(),t.stroke(),t.setDashArray(null)}},LG=e=>{let{target:t,options:n,style:o,w2s:a,zoom:r}=e;if(!n.cropFrame&&n.groupBounds){let s=Jo(n.groupBounds,a);if(Pv(t,s,o),n.readOnly===!0)return;let i=yi;for(let l of i){let c=gi(l,n.groupBounds,r),u=N.applyToPoint(a,c);Bv(t,u,o)}X5(t,n.groupBounds,r,a,o)}},kG=e=>{let{scene:t,target:n,options:o,w2s:a}=e;if(o.annotations&&o.annotations.length>0)for(let r of o.annotations){let s=Kr(t,r),i=N.applyToPoint(a,s);UG(n,i,r,o.selectedAnnotation??null)}},wG=e=>{let{target:t,options:n,w2s:o}=e;if(n.peerCursors)for(let a of n.peerCursors){let r=N.applyToPoint(o,a.position);HG(t,r,a.color,a.name)}},_G=e=>{let{target:t,options:n,w2s:o}=e;if(n.gifBadges)for(let a of n.gifBadges)EG(t,Jo(a,o))},CG=e=>{let{target:t,options:n,w2s:o,zoom:a}=e;if(n.editingText){let r=n.editingText;if(r.selectionRects.length>0){t.setFill(n4),t.setOpacity(o4);for(let s of r.selectionRects){let i=Jo(s,o);t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.fill()}t.setOpacity(1)}if(r.caret){let s=N.applyToPoint(o,{x:r.caret.x,y:r.caret.y});t.setFill(r.caretColor),t.setOpacity(1),t.beginPath(),t.rect(s.x,s.y,a4,r.caret.height*a),t.fill()}}},U5=(e,t)=>{let n=d4,o=t.x+t.width-n-2,a=t.y+2,r=f4;e.setStroke(r),e.setFill(null),e.setStrokeWidth(2),e.setDashArray(null),e.setOpacity(1),e.beginPath(),e.ellipse(o+n/2,a+n*.46,n*.22,n*.26),e.stroke(),e.setStroke(null),e.setFill(r),e.beginPath(),e.rect(o+n*.2,a+n*.44,n*.6,n*.48),e.fill(),e.setFill(p4),e.beginPath(),e.ellipse(o+n/2,a+n*.64,n*.07,n*.07),e.fill()},EG=(e,t)=>{let n=t.x+w2,o=t.y+w2,a=i4,r=l4,s=c4;e.setStroke(null),e.setFill(u4),e.beginPath(),e.moveTo(n+s,o),e.lineTo(n+a-s,o),e.quadraticCurveTo(n+a,o,n+a,o+s),e.lineTo(n+a,o+r-s),e.quadraticCurveTo(n+a,o+r,n+a-s,o+r),e.lineTo(n+s,o+r),e.quadraticCurveTo(n,o+r,n,o+r-s),e.lineTo(n,o+s),e.quadraticCurveTo(n,o,n+s,o),e.closePath(),e.fill(),e.setFill("#ffffff"),e.setFont("system-ui, sans-serif",10),e.setTextAlign("center"),e.setTextBaseline("middle"),e.fillText("gif",n+a/2,o+r/2)},Jo=(e,t)=>{let n=N.applyToPoint(t,{x:e.x,y:e.y}),o=N.applyToPoint(t,{x:e.x+e.width,y:e.y+e.height}),a=Math.min(n.x,o.x),r=Math.min(n.y,o.y);return{x:a,y:r,width:Math.abs(o.x-n.x),height:Math.abs(o.y-n.y)}},Pv=(e,t,n)=>{e.setStroke(n.selectionStroke),e.setStrokeWidth(n.selectionStrokeWidth),e.setDashArray(null),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.stroke()},TG=(e,t,n,o)=>{let[a,r,s,i]=cp(t),l=N.applyToPoint(n,a),c=N.applyToPoint(n,r),u=N.applyToPoint(n,s),d=N.applyToPoint(n,i);e.setStroke(o.selectionStroke),e.setStrokeWidth(o.selectionStrokeWidth),e.setDashArray(null),e.beginPath(),e.moveTo(l.x,l.y),e.lineTo(c.x,c.y),e.lineTo(u.x,u.y),e.lineTo(d.x,d.y),e.closePath(),e.stroke()},IG=(e,t)=>{let n=cp(e).map(i=>N.applyToPoint(t,i)),o=1/0,a=1/0,r=-1/0,s=-1/0;for(let i of n)i.x<o&&(o=i.x),i.y<a&&(a=i.y),i.x>r&&(r=i.x),i.y>s&&(s=i.y);return{x:o,y:a,width:r-o,height:s-a}},Ly=(e,t,n,o)=>{o.opacity!==void 0&&e.setOpacity(o.opacity),e.setStroke(o.stroke),e.setStrokeWidth(o.strokeWidth),e.setDashArray(null),e.setFill(o.fill),e.beginPath(),e.ellipse(t.x,t.y,n,n),e.fill(),e.stroke(),o.opacity!==void 0&&e.setOpacity(1)},Bv=(e,t,n)=>{Ly(e,t,5,{fill:n.handleFill,stroke:n.handleStroke,strokeWidth:1})},Z5=(e,t,n)=>{let o=7/9,a=(u,d)=>({x:t.x+(u-12)*o,y:t.y+(d-12)*o});e.setStroke(n.handleStroke),e.setFill(null),e.setStrokeWidth(2*o),e.setLineCap("round"),e.setLineJoin("round"),e.setDashArray(null);let r=336,s=30;e.beginPath();for(let u=0;u<=s;u++){let d=r*u/s*(Math.PI/180),f=a(12+9*Math.cos(d),12+9*Math.sin(d));u===0?e.moveTo(f.x,f.y):e.lineTo(f.x,f.y)}e.stroke();let i=a(21,3),l=a(21,8),c=a(16,8);e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.stroke(),e.setLineCap("butt"),e.setLineJoin("miter")},X5=(e,t,n,o,a)=>{let r=Q0(t,n);Z5(e,N.applyToPoint(o,r),a)},MG=(e,t,n)=>{e.setStroke(n.drawingStroke),e.setStrokeWidth(1),e.setDashArray(n.drawingDash),e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.stroke()},RG=(e,t,n,o)=>{e.setStroke(o.drawingStroke),e.setStrokeWidth(1.5),e.setDashArray(o.drawingDash),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(n.x,n.y),e.stroke()},OG=(e,t,n)=>{e.setStroke(n.selectionStroke),e.setStrokeWidth(1.5),e.setDashArray(n.drawingDash),e.beginPath();let o=v(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=v(t[a]);e.lineTo(r.x,r.y)}e.lineTo(o.x,o.y),e.stroke(),e.setDashArray(null)},DG=(e,t,n)=>{if(t.length<4)return;e.setStroke(n.selectionStroke),e.setStrokeWidth(g4),e.setDashArray(null),e.setLineCap("round"),e.setLineJoin("round");let o=(a,r)=>{let s=r.x-a.x,i=r.y-a.y,l=Math.hypot(s,i)||1,c=Math.min(y4,l)/l;return{x:a.x+s*c,y:a.y+i*c}};for(let a=0;a<4;a++){let r=v(t[a]),s=v(t[(a+3)%4]),i=v(t[(a+1)%4]),l=o(r,s),c=o(r,i);e.beginPath(),e.moveTo(l.x,l.y),e.lineTo(r.x,r.y),e.lineTo(c.x,c.y),e.stroke()}e.setLineCap("butt"),e.setLineJoin("miter")},PG=(e,t,n)=>{let o=t.element,a=o.animationKind!==void 0?Ei(o,void 0):o.metadata?.image??Ei(o,void 0);if(a==null)return;let r=o.metadata?.animated===!0||o.animationKind!==void 0,{fullRect:s}=t;e.save(),e.setTransform(n),e.setDashArray(null),e.translate(o.position.x,o.position.y),o.rotation!==0&&e.rotate(o.rotation),(o.scale.x!==1||o.scale.y!==1)&&e.scale(o.scale.x,o.scale.y),e.setOpacity(m4),e.drawImage(a,s.x,s.y,s.width,s.height,r),e.setOpacity(1),e.restore()},BG=(e,t,n)=>{e.setStroke(n.drawingStroke),e.setStrokeWidth(1.5),e.setDashArray(n.drawingDash),e.beginPath();let o=v(t[0]);e.moveTo(o.x,o.y);for(let a=1;a<t.length;a++){let r=v(t[a]);e.lineTo(r.x,r.y)}e.stroke()},NG=(e,t,n,o="link-start",a)=>{let r=n?a??Xo:op,s=o==="link-start";Ly(e,t,r,{fill:n?s?s2:i2:s?$T:QT,stroke:s?s2:i2,strokeWidth:KT})},Dv=(e,t,n)=>{Ly(e,t,qT,{fill:n.handleFill,stroke:n.selectionStroke,strokeWidth:2})},zG=(e,t,n)=>{Ly(e,t,jT,{fill:n.handleFill,stroke:n.selectionStroke,strokeWidth:1.5,opacity:.55})},FG=(e,t,n)=>{let o=fI;e.setStroke(n),e.setStrokeWidth(uI),e.setDashArray(dI),e.beginPath(),e.rect(t.x-o,t.y-o,t.width+2*o,t.height+2*o),e.stroke()},HG=(e,t,n,o)=>{let a=cI;e.setFill(n),e.setStroke("#fff"),e.setStrokeWidth(1),e.setDashArray(null),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(t.x+a*.7,t.y+a*.25),e.lineTo(t.x+a*.35,t.y+a*.4),e.lineTo(t.x+a*.5,t.y+a*.95),e.lineTo(t.x+a*.35,t.y+a*1.05),e.lineTo(t.x+a*.2,t.y+a*.5),e.lineTo(t.x,t.y+a*.65),e.closePath(),e.fill(),e.stroke(),e.setFont("sans-serif",h2),e.setTextBaseline("top"),e.setTextAlign("left");let r=e.measureText(o).width,s=t.x+d2,i=t.y+d2,l=r+2*f2,c=h2+2*p2;e.setFill(n),e.setStrokeWidth(0),e.beginPath(),e.rect(s,i,l,c),e.fill(),e.setFill("#fff"),e.fillText(o,s+f2,i+p2)},UG=(e,t,n,o)=>{let a=_I,r=n.resolved?TI:CI,s=n.id===o;if(e.setFill(r),e.setStroke(s?"#1a73e8":EI),e.setStrokeWidth(s?2:1.5),e.setDashArray(null),e.beginPath(),e.ellipse(t.x,t.y,a,a),e.fill(),e.stroke(),n.thread.length>0){let i=n.thread.length,l=i>9?"9+":String(i);e.setFont("sans-serif",II),e.setTextAlign("center"),e.setTextBaseline("middle"),e.setFill("#fff"),e.fillText(l,t.x,t.y)}};var Pc=(e,t)=>{let n=t.getBoundingClientRect();return{kind:WG(e.pointerType),phase:qG(e.type),point:{x:e.clientX-n.left,y:e.clientY-n.top},buttons:e.buttons,modifiers:GG(e),pointerId:e.pointerId,timestamp:e.timeStamp}};var ea=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable},GG=e=>({shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey}),WG=e=>e==="pen"?"pen":e==="touch"?"touch":"mouse",qG=e=>{switch(e){case"pointerdown":return"down";case"pointermove":return"move";case"pointerup":return"up";case"pointercancel":return"cancel";case"pointerenter":return"enter";case"pointerleave":return"leave";default:return"move"}};var Nv=()=>typeof navigator<"u"?navigator.userAgent:"",Ip=()=>typeof navigator<"u"&&navigator.platform||"",rs=/Mac|iPod|iPhone|iPad/.test(Ip()),jG=Ip().startsWith("Win"),Y5=/\b(android)\b/i.test(Nv()),VG=/iPad|iPhone/i.test(Ip())||typeof navigator<"u"&&/Mac/i.test(Ip())&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1,ZG=/Linux/i.test(Ip())&&!Y5,XG=/Firefox/i.test(Nv()),YG=/^((?!chrome|android).)*safari/i.test(Nv());var KG={Enter:"\u23CE",Backspace:"\u232B",Delete:"\u2326",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"\u21E5"," ":"Space"},$G={Enter:"Enter",Backspace:"Backspace",Delete:"Del",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"Tab"," ":"Space"},ky=e=>{let t=[];rs?(e.ctrl&&t.push("\u2303"),e.alt&&t.push("\u2325"),e.shift&&t.push("\u21E7"),e.meta&&t.push("\u2318")):(e.meta&&t.push("Ctrl"),e.ctrl&&t.push("Ctrl"),e.alt&&t.push("Alt"),e.shift&&t.push("Shift"));let n=rs?KG:$G,o=e.key??e.code??"",a=n[o]??(o.length===1?o.toUpperCase():o);return t.push(a),t},ut=e=>{let t=ky(e);return rs?t.join(""):t.join("+")};var K5={id:"undo",label:"Undo",category:"history",hotkey:{key:"z",meta:!0},iconId:"undo",predicate:({editor:e})=>e.canUndo,perform:({editor:e})=>e.undo()},$5={id:"redo",label:"Redo",category:"history",hotkey:[{key:"z",meta:!0,shift:!0},{key:"y",meta:!0}],iconId:"redo",predicate:({editor:e})=>e.canRedo,perform:({editor:e})=>e.redo()},zv=[K5,$5];var mt=e=>e.editor.selection.size>0,Fv=e=>e.editor.selection.size>0||e.editor.selectedLinks.size>0;var Q5={id:"select-all",label:"Select all",category:"selection",viewMode:!0,hotkey:{key:"a",meta:!0},perform:({editor:e})=>{e.selectAll()}},J5={id:"delete-selection",label:"Delete",category:"selection",hotkey:[{key:"Delete"},{key:"Backspace"}],predicate:Fv,perform:({editor:e})=>{e.deleteSelected()}},e9={id:"duplicate-selection",label:"Duplicate",category:"selection",hotkey:{key:"d",meta:!0},predicate:mt,perform:({editor:e})=>{e.duplicateSelected()}},t9={id:"toggle-lock",label:"Lock / Unlock",category:"selection",hotkey:{key:"l",meta:!0,shift:!0},predicate:mt,perform:({editor:e})=>{e.toggleLockSelection()}},n9={id:"enter-container",label:"Enter container",category:"selection",hotkey:{key:"ArrowDown",meta:!0,shift:!0},predicate:({editor:e})=>e.selection.size===1,perform:({editor:e})=>{e.enterContainer()}},o9={id:"exit-container",label:"Exit container",category:"selection",hotkey:{key:"ArrowUp",meta:!0,shift:!0},predicate:mt,perform:({editor:e})=>{e.exitContainer()}},Hv=[Q5,J5,e9,t9,n9,o9];var a9={id:"copy",label:"Copy",category:"clipboard",viewMode:!0,hotkey:{key:"c",meta:!0},predicate:mt,perform:({editor:e})=>{e.copySelected()}},r9={id:"cut",label:"Cut",category:"clipboard",hotkey:{key:"x",meta:!0},predicate:mt,perform:({editor:e})=>{e.cutSelected()}},s9={id:"paste",label:"Paste",category:"clipboard",hotkey:{key:"v",meta:!0},perform:({editor:e})=>{e.paste()}},i9={id:"copy-style",label:"Copy style",category:"clipboard",viewMode:!0,hotkey:{key:"c",meta:!0,alt:!0},predicate:mt,perform:({editor:e})=>{e.copySelectionStyle()}},l9={id:"paste-style",label:"Paste style",category:"clipboard",hotkey:{key:"v",meta:!0,alt:!0},predicate:({editor:e})=>e.selection.size>0&&e.hasStyleClipboard,perform:({editor:e})=>{e.pasteSelectionStyle()}},Uv=[a9,r9,s9,i9,l9];var c9={id:"bring-to-front",label:"Bring to front",category:"z-order",hotkey:{key:"]",meta:!0,shift:!0},predicate:mt,perform:({editor:e})=>{e.bringToFront()}},u9={id:"send-to-back",label:"Send to back",category:"z-order",hotkey:{key:"[",meta:!0,shift:!0},predicate:mt,perform:({editor:e})=>{e.sendToBack()}},d9={id:"bring-forward",label:"Bring forward",category:"z-order",hotkey:{key:"]",meta:!0},predicate:mt,perform:({editor:e})=>{e.bringForward()}},f9={id:"send-backward",label:"Send backward",category:"z-order",hotkey:{key:"[",meta:!0},predicate:mt,perform:({editor:e})=>{e.sendBackward()}},Gv=[c9,d9,f9,u9];var p9={id:"group-selection",label:"Group",category:"grouping",hotkey:{key:"g",meta:!0},predicate:e=>e.editor.selection.size>=2,perform:({editor:e})=>{e.groupSelected()}},h9={id:"ungroup-selection",label:"Ungroup",category:"grouping",hotkey:{key:"g",meta:!0,shift:!0},predicate:e=>{for(let t of e.editor.selection)if(e.editor.scene.elements.get(t)?.type==="group")return!0;return!1},perform:({editor:e})=>{e.ungroup()}},Wv=[p9,h9];var m9={id:"zoom-in",label:"Zoom in",category:"zoom",viewMode:!0,hotkey:[{key:"=",meta:!0},{key:"+",meta:!0},{key:"+"},{key:"="}],perform:({editor:e})=>{e.zoomIn()}},y9={id:"zoom-out",label:"Zoom out",category:"zoom",viewMode:!0,hotkey:[{key:"-",meta:!0},{key:"_",meta:!0},{key:"-"},{key:"_"}],perform:({editor:e})=>{e.zoomOut()}},g9={id:"zoom-reset",label:"Reset zoom",category:"zoom",viewMode:!0,hotkey:{key:"0",meta:!0},perform:({editor:e})=>{e.resetZoom()}},x9={id:"zoom-to-fit",label:"Fit to screen",category:"zoom",viewMode:!0,hotkey:[{key:"1",alt:!0},{key:"1",meta:!0}],perform:({editor:e})=>{e.zoomToFit()}},b9={id:"zoom-to-selection",label:"Zoom to selection",category:"zoom",viewMode:!0,hotkey:{key:"2",alt:!0},predicate:mt,perform:({editor:e})=>{e.zoomToSelection()}},qv=[m9,y9,g9,x9,b9];var A9={id:"mode-select",label:"Select tool",category:"mode",viewMode:!0,hotkey:{key:"v"},iconId:"mode-select",uiKind:"toggle",checked:({editor:e})=>e.mode==="select",perform:({editor:e})=>{e.setMode("select")}},v9={id:"mode-hand",label:"Hand tool",category:"mode",viewMode:!0,hotkey:{key:"h"},iconId:"mode-hand",uiKind:"toggle",checked:({editor:e})=>e.mode==="hand",perform:({editor:e})=>{e.setMode("hand")}},S9={id:"mode-rect",label:"Rectangle tool",category:"mode",hotkey:{key:"r"},iconId:"mode-rect",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-rect",perform:({editor:e})=>{e.setMode("draw-rect")}},L9={id:"mode-ellipse",label:"Ellipse tool",category:"mode",hotkey:{key:"o"},iconId:"mode-ellipse",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-ellipse",perform:({editor:e})=>{e.setMode("draw-ellipse")}},k9={id:"mode-text",label:"Text tool",category:"mode",hotkey:{key:"t"},iconId:"mode-text",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-text",perform:({editor:e})=>{e.setMode("draw-text")}},w9={id:"mode-edge",label:"Link tool",category:"mode",hotkey:{key:"l"},iconId:"mode-edge",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-edge",perform:({editor:e})=>{e.setMode("draw-edge")}},_9={id:"mode-brush",label:"Brush tool",category:"mode",hotkey:{key:"b"},iconId:"mode-brush",uiKind:"toggle",checked:({editor:e})=>e.mode==="brush",perform:({editor:e})=>{e.setMode("brush")}},C9={id:"mode-erase",label:"Eraser tool",category:"mode",hotkey:{key:"e"},iconId:"mode-erase",uiKind:"toggle",checked:({editor:e})=>e.mode==="erase",perform:({editor:e})=>{e.setMode("erase")}},E9={id:"mode-laser",label:"Laser pointer",category:"mode",viewMode:!0,hotkey:{key:"k"},iconId:"mode-laser",uiKind:"toggle",checked:({editor:e})=>e.mode==="laser",perform:({editor:e})=>{e.setMode("laser")}},T9={id:"mode-frame",label:"Frame tool",category:"mode",hotkey:{key:"f"},iconId:"mode-frame",uiKind:"toggle",checked:({editor:e})=>e.mode==="draw-frame",perform:({editor:e})=>{e.setMode("draw-frame")}},I9={id:"toggle-tool-lock",label:"Toggle tool lock",category:"mode",iconId:"tool-lock",uiKind:"toggle",checked:({editor:e})=>e.toolLocked,perform:({editor:e})=>{e.setToolLocked(!e.toolLocked)}},QG={id:"commit-image-crop",label:"Apply crop",category:"edit",hotkey:{key:"Enter"},predicate:({editor:e})=>e.mode==="crop",perform:({editor:e})=>{e.commitImageCrop()}},JG={id:"cancel-image-crop",label:"Cancel crop",category:"edit",viewMode:!0,hotkey:{key:"Escape"},predicate:({editor:e})=>e.mode==="crop",perform:({editor:e})=>{e.cancelImageCrop()}},M9={id:"cancel",label:"Cancel / clear selection",category:"edit",viewMode:!0,hotkey:{key:"Escape"},perform:({editor:e})=>{e.cancelInteraction()}},jv=[A9,v9,S9,L9,k9,w9,_9,C9,E9,T9,I9,QG,JG,M9];var eW={id:"nudge-selection",label:"Nudge selection",category:"selection",displayHotkey:[{key:"ArrowLeft"},{key:"ArrowRight"},{key:"ArrowUp"},{key:"ArrowDown"}],keyTest:e=>(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"||e.key==="ArrowDown")&&!e.metaKey&&!e.ctrlKey&&!e.altKey,perform:({editor:e,event:t})=>{if(!t)return;let n=t.shiftKey?e4:JI;switch(t.key){case"ArrowLeft":e.moveSelectionBy({x:-n,y:0});return;case"ArrowRight":e.moveSelectionBy({x:n,y:0});return;case"ArrowUp":e.moveSelectionBy({x:0,y:-n});return;case"ArrowDown":e.moveSelectionBy({x:0,y:n});return}}},tW={id:"select-closest",label:"Navigate to adjacent node",category:"selection",displayHotkey:[{key:"ArrowLeft",alt:!0},{key:"ArrowRight",alt:!0},{key:"ArrowUp",alt:!0},{key:"ArrowDown",alt:!0}],keyTest:e=>e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"||e.key==="ArrowDown"),perform:({editor:e,event:t})=>{if(t)switch(t.key){case"ArrowLeft":e.navigateFlowchart("left");return;case"ArrowRight":e.navigateFlowchart("right");return;case"ArrowUp":e.navigateFlowchart("up");return;case"ArrowDown":e.navigateFlowchart("down");return}}},nW={id:"spawn-connected",label:"Create connected node",category:"edit",displayHotkey:[{key:"ArrowLeft",meta:!0},{key:"ArrowRight",meta:!0},{key:"ArrowUp",meta:!0},{key:"ArrowDown",meta:!0}],keyTest:e=>(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"||e.key==="ArrowDown"),predicate:({editor:e})=>e.selection.size===1,perform:({editor:e,event:t})=>{if(t)switch(t.key){case"ArrowLeft":e.growFlowchart("left");return;case"ArrowRight":e.growFlowchart("right");return;case"ArrowUp":e.growFlowchart("up");return;case"ArrowDown":e.growFlowchart("down");return}}},oW={id:"focus-next",label:"Focus next element",category:"selection",hotkey:{key:"Tab"},perform:({editor:e})=>{e.focusCycle("next")}},aW={id:"focus-prev",label:"Focus previous element",category:"selection",hotkey:{key:"Tab",shift:!0},perform:({editor:e})=>{e.focusCycle("prev")}},rW={id:"edit-or-create",label:"Edit / create",category:"edit",displayHotkey:{key:"Enter"},keyTest:e=>e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey,predicate:({editor:e})=>{if(e.selection.size===1){let[t]=[...e.selection];if(t&&e.scene.elements.get(t)?.type==="text")return!0}return e.mode==="draw-rect"||e.mode==="draw-ellipse"},perform:({editor:e})=>{if(e.selection.size===1){let[t]=[...e.selection];if(t&&e.scene.elements.get(t)?.type==="text"){e.beginTextEdit(t);return}}(e.mode==="draw-rect"||e.mode==="draw-ellipse")&&e.createElementAtCursor()}},R9=[eW,tW,nW,oW,aW,rW];var sW={id:"arrange-grid",label:"Arrange as grid",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsGrid()}},iW={id:"arrange-stack-h",label:"Stack horizontally",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"horizontal"})}},lW={id:"arrange-stack-v",label:"Stack vertically",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"vertical"})}},cW={id:"auto-arrange",label:"Auto-arrange children",category:"layout",predicate:({editor:e})=>{if(e.selection.size!==1)return!1;let[t]=[...e.selection];if(!t)return!1;let n=e.scene.elements.get(t);return n?On(n)!==null:!1},perform:({editor:e})=>{let[t]=[...e.selection];t&&e.runLayout(t)}},uW={id:"compact-z-order",label:"Compact z-order",category:"z-order",perform:({editor:e})=>{e.compactLayerZOrder()}},O9=[sW,iW,lW,cW,uW];var D9={id:"toggle-grid",label:"Toggle grid",category:"other",viewMode:!0,hotkey:{key:"g"},uiKind:"toggle",checked:({editor:e})=>e.gridEnabled,perform:({editor:e})=>{e.toggleGrid()}},P9={id:"toggle-read-only",label:"Read-only mode",category:"other",viewMode:!0,hotkey:{key:"r",alt:!0},uiKind:"toggle",checked:({editor:e})=>e.readOnly,perform:({editor:e})=>{e.toggleReadOnly()}},Vv=[D9,P9];var Bc=e=>e.editor.selection.size>=2,B9=e=>e.editor.selection.size>=3,N9={id:"flip-horizontal",label:"Flip horizontal",category:"arrange",hotkey:{key:"h",shift:!0},iconId:"flip-horizontal",predicate:mt,perform:({editor:e})=>{e.flipSelection("horizontal")}},z9={id:"flip-vertical",label:"Flip vertical",category:"arrange",hotkey:{key:"v",shift:!0},iconId:"flip-vertical",predicate:mt,perform:({editor:e})=>{e.flipSelection("vertical")}},F9={id:"align-left",label:"Align left",category:"arrange",hotkey:{key:"ArrowLeft",meta:!0,shift:!0},iconId:"align-left",predicate:Bc,perform:({editor:e})=>{e.alignSelection("left")}},H9={id:"align-h-center",label:"Align horizontal centres",category:"arrange",iconId:"align-h-center",predicate:Bc,perform:({editor:e})=>{e.alignSelection("h-center")}},U9={id:"align-right",label:"Align right",category:"arrange",hotkey:{key:"ArrowRight",meta:!0,shift:!0},iconId:"align-right",predicate:Bc,perform:({editor:e})=>{e.alignSelection("right")}},G9={id:"align-top",label:"Align top",category:"arrange",hotkey:{key:"ArrowUp",meta:!0,shift:!0},iconId:"align-top",predicate:Bc,perform:({editor:e})=>{e.alignSelection("top")}},W9={id:"align-v-center",label:"Align vertical centres",category:"arrange",iconId:"align-v-center",predicate:Bc,perform:({editor:e})=>{e.alignSelection("v-center")}},q9={id:"align-bottom",label:"Align bottom",category:"arrange",hotkey:{key:"ArrowDown",meta:!0,shift:!0},iconId:"align-bottom",predicate:Bc,perform:({editor:e})=>{e.alignSelection("bottom")}},j9={id:"distribute-horizontal",label:"Distribute horizontally",category:"arrange",hotkey:{key:"h",alt:!0},iconId:"distribute-horizontal",predicate:B9,perform:({editor:e})=>{e.distributeSelection("horizontal")}},V9={id:"distribute-vertical",label:"Distribute vertically",category:"arrange",hotkey:{key:"v",alt:!0},iconId:"distribute-vertical",predicate:B9,perform:({editor:e})=>{e.distributeSelection("vertical")}},Zv=[N9,z9,F9,H9,U9,G9,W9,q9,j9,V9];var Z9=e=>{let{editor:t}=e;for(let n of t.selection){let o=I(t.scene,n);if(o!==void 0&&fe(o))return!0}return!1},X9={id:"increase-font-size",label:"Increase font size",category:"edit",hotkey:{code:"Period",meta:!0,shift:!0},predicate:Z9,perform:({editor:e})=>{e.adjustSelectionFontSize("increase")}},Y9={id:"decrease-font-size",label:"Decrease font size",category:"edit",hotkey:{code:"Comma",meta:!0,shift:!0},predicate:Z9,perform:({editor:e})=>{e.adjustSelectionFontSize("decrease")}},Xv=[X9,Y9];var Mp=class{entries=new Map;order=[];seqBuffer=[];register(t){if(this.entries.has(t.id))throw new Error(`Action already registered: ${t.id}`);this.entries.set(t.id,t),this.order.push(t.id)}replace(t){if(this.entries.has(t.id)){this.entries.set(t.id,t);return}this.register(t)}unregister(t){if(!this.entries.delete(t))return;let n=this.order.indexOf(t);n!==-1&&this.order.splice(n,1)}get(t){return this.entries.get(t)}getAll(){return this.order.map(t=>this.entries.get(t)).filter(t=>t!==void 0)}dispatch(t,n){let o=this.entries.get(t);return!o||Yv(o,n)||o.predicate&&!o.predicate(n)?!1:(o.perform(n),!0)}dispatchHotkey(t,n){let o={...n,event:t};if(this.trySequence(t,o))return!0;for(let a of this.order){let r=this.entries.get(a);if(!r||Yv(r,o))continue;if(r.keyTest?.(t,o)){if(r.predicate&&!r.predicate(o))continue;return r.perform(o),!0}if(!r.hotkey)continue;let s=Array.isArray(r.hotkey)?r.hotkey:[r.hotkey];for(let i of s)if(dW(t,i)&&!(r.predicate&&!r.predicate(o)))return r.perform(o),!0}return!1}trySequence(t,n){if(!(t.key.length===1&&!t.metaKey&&!t.ctrlKey&&!t.altKey))return this.seqBuffer=[],!1;let a=t.timeStamp;this.seqBuffer=this.seqBuffer.filter(r=>a-r.t<=QI),this.seqBuffer.push({key:t.key,code:t.code,t:a});for(let r of this.order){let s=this.entries.get(r);if(!s?.sequence||s.sequence.length===0||Yv(s,n))continue;let i=s.sequence,l=this.seqBuffer.slice(-i.length);if(l.length===i.length&&l.every((c,u)=>K9(c.key,c.code,i[u]??""))&&!(s.predicate&&!s.predicate(n)))return this.seqBuffer=[],s.perform(n),!0}return!1}},Yv=(e,t)=>t.editor.readOnly&&e.viewMode!==!0,dW=(e,t)=>{if(t.key!==void 0&&!fW(e,t.key)||t.code!==void 0&&e.code!==t.code)return!1;let n=a=>a===!0,o=rs?e.metaKey:e.ctrlKey;return!(n(t.meta)!==o||n(t.shift)!==e.shiftKey||n(t.alt)!==e.altKey||t.ctrl!==void 0&&n(t.ctrl)!==e.ctrlKey)},fW=(e,t)=>K9(e.key,e.code,t),K9=(e,t,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;if(pW(e))return!1;let o=hW(n);return o!==null&&t===o},pW=e=>/^[a-z]$/i.test(e),hW=e=>{if(e.length!==1)return null;let t=e.toLowerCase();if(t>="a"&&t<="z")return`Key${t.toUpperCase()}`;if(t>="0"&&t<="9")return`Digit${t}`;switch(t){case"[":return"BracketLeft";case"]":return"BracketRight";case",":return"Comma";case".":return"Period";case"/":return"Slash";case";":return"Semicolon";case"'":return"Quote";case"`":return"Backquote";case"-":return"Minus";case"=":return"Equal";case"\\":return"Backslash";default:return null}},Kv=e=>{let t=[...zv,...Hv,...Uv,...Gv,...Wv,...qv,...jv,...R9,...O9,...Vv,...Zv,...Xv];for(let n of t)e.register(n)},_e=new Mp;Kv(_e);var wy=(e,t={})=>{let n=t.target??window,o=t.registry??_e,a=r=>{if(!(r instanceof KeyboardEvent))return;let s=r.composedPath()[0]??r.target;if(ea(s)){if(r.key!=="Escape")return;s instanceof HTMLElement&&s.blur()}o.dispatchHotkey(r,{editor:e})&&r.preventDefault()};return n.addEventListener("keydown",a),()=>{n.removeEventListener("keydown",a)}};var $9=e=>{if(fe(e))return e.text.length>0?e.text:null;if(Be(e)){let t=e.name;return t!==void 0&&t.length>0?t:null}return null},$v=(e,t)=>{let n=t.trim().toLowerCase();if(n==="")return[];let o=[];for(let a of e.elements.values()){let r=$9(a);r?.toLowerCase().includes(n)&&o.push({kind:"element",id:a.id,text:r})}for(let a of e.links.values()){let r=a.label?.text;r?.toLowerCase().includes(n)&&o.push({kind:"link",id:a.id,text:r})}return o};var mW=new Map;var Q9=e=>mW.get(e);var Qv=()=>{let e=new Map;return{on:(s,i)=>{let l=e.get(s);return l||(l=new Set,e.set(s,l)),l.add(i),()=>{let c=e.get(s);c&&(c.delete(i),c.size===0&&e.delete(s))}},off:(s,i)=>{let l=e.get(s);l&&(l.delete(i),l.size===0&&e.delete(s))},emit:(s,...i)=>{let l=e.get(s);if(!l||l.size===0)return 0;let c=Array.from(l),u=null,d=0;for(let f of c)try{f(...i),d++}catch(p){u??=p instanceof Error?p:new Error(String(p))}if(u!==null)throw u;return d},clear:s=>{if(s===void 0){e.clear();return}e.delete(s)},listenerCount:s=>{let i=e.get(s);return i?i.size:0}}};var Jv=()=>{let e=new Set;return{add:t=>(e.add(t),()=>e.delete(t)),emit:t=>{for(let n of[...e])n(t)},clear:()=>{e.clear()},size:()=>e.size}};var J9=e=>{let t=new Map,n=new Map,o=new Map,a=new Map,r=new Map,s=null,i=()=>s,l=[],c=-1,u=p=>{if(p.kind==="batch"){for(let h of p.patches)u(h);return}if(p.kind==="element"){let h=t.get(p.id);h?h.latest={...h.latest,after:p.after}:(t.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="link"){let h=n.get(p.id);h?h.latest={...h.latest,after:p.after}:(n.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="layer"){let h=o.get(p.id);h?h.latest={...h.latest,after:p.after}:(o.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="annotation"){let h=a.get(p.id);h?h.latest={...h.latest,after:p.after}:(a.set(p.id,{first:p,latest:p}),l.push(p));return}if(p.kind==="file"){let h=r.get(p.id);h?h.latest={...h.latest,after:p.after}:(r.set(p.id,{first:p,latest:p}),l.push(p));return}s?s={first:s.first,latest:{...s.latest,after:p.after}}:(s={first:p,latest:p},c=l.length,l.push(p))};for(let p of e)u(p);let d=i(),f=[];for(let p=0;p<l.length;p++){let h=v(l[p]),m;if(h.kind==="element"){let x=v(t.get(h.id));m={kind:"element",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="link"){let x=v(n.get(h.id));m={kind:"link",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="layer"){let x=v(o.get(h.id));m={kind:"layer",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="annotation"){let x=v(a.get(h.id));m={kind:"annotation",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(h.kind==="file"){let x=v(r.get(h.id));m={kind:"file",id:x.first.id,before:x.first.before,after:x.latest.after}}else if(p===c&&d!==null)m={kind:"viewport",before:d.first.before,after:d.latest.after};else continue;yW(m)||f.push(m)}return f},yW=e=>e.kind==="element"||e.kind==="link"||e.kind==="layer"||e.kind==="annotation"||e.kind==="file"||e.kind==="viewport"?e.before===e.after:!1;var Rp=class{past=[];future=[];limit;mergeTransactions;constructor(t={}){this.limit=t.limit??1/0,this.mergeTransactions=t.mergeTransactions??!0}push(t){Yr(t)||(this.past.push(t),this.future.length=0,this.trim())}undo(){let t=this.past.pop();return t?(this.future.push(t),pc(t)):null}redo(){let t=this.future.pop();return t?(this.past.push(t),t):null}get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}get size(){return this.past.length}get redoSize(){return this.future.length}get undoStack(){return this.past}get redoStack(){return this.future}clear(){this.past.length=0,this.future.length=0}transaction(){if(this.current!==null)throw new Error("A transaction is already open");let t=[];return this.current=t,{add:n=>{if(this.current!==t)throw new Error("Transaction is no longer open");Yr(n)||t.push(n)},commit:()=>{if(this.current!==t||(this.current=null,t.length===0))return;let n=this.mergeTransactions?J9(t):t;if(n.length===0)return;let o=n[0],a=n.length===1&&o!==void 0?o:Vo(n);Yr(a)||(this.past.push(a),this.future.length=0,this.trim())},cancel:()=>{this.current===t&&(this.current=null)},isOpen:()=>this.current===t}}hasOpenTransaction(){return this.current!==null}record(t,n){if(n?.transaction?.isOpen()){n.transaction.add(t);return}this.push(t)}current=null;trim(){if(Number.isFinite(this.limit))for(;this.past.length>this.limit;)this.past.shift()}};var Op=class{entries=[];register(t){let n=this.entries.findIndex(o=>o.id===t.id);if(n!==-1){this.entries[n]=t;return}this.entries.push(t)}unregister(t){let n=this.entries.findIndex(o=>o.id===t);n!==-1&&this.entries.splice(n,1)}getAll(){return this.entries}async dispatch(t,n){for(let o of this.entries)if(o.accept(t))return await o.handle(t,n),!0;return!1}},eM=["image/png","image/jpeg","image/svg+xml","image/gif","image/webp","image/bmp","image/x-icon","image/avif","image/jfif"];var eS=e=>{if(e.type.startsWith("video/"))return!0;let t=e.name.toLowerCase().split(".").pop();return t==="mp4"||t==="webm"||t==="ogv"||t==="mov"},tS=e=>{if(e.type&&eM.includes(e.type))return!0;let t=e.name.toLowerCase().split(".").pop();return t?{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",jfif:"image/jfif",svg:"image/svg+xml",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif"}[t]!==void 0:!1};var nS=e=>new Promise((t,n)=>{let o=new FileReader;o.onload=()=>{let a=o.result;typeof a=="string"?t(a):n(new Error(`Unexpected FileReader result type for ${e.name}`))},o.onerror=()=>{n(o.error??new Error(`Failed to read ${e.name}`))},o.readAsDataURL(e)});var gW=e=>e===".git"||e==="node_modules"||e==="__MACOSX"||e===".DS_Store"||e.startsWith("."),oS=async function*(e,t={}){let n=t.skipDirectory??gW,o=t.maxDepth??32,a=e.items,r=a!==null&&a.length>0&&typeof a[0]?.webkitGetAsEntry=="function";if(a===null||!r){for(let s of Array.from(e.files))yield s;return}for(let s of Array.from(a)){if(s.kind!=="file")continue;let i=s.webkitGetAsEntry?.();i&&(yield*tM(i,"",0,n,o,t.onError))}};async function*tM(e,t,n,o,a,r){let s=t?`${t}/${e.name}`:e.name;if(e.isFile){try{yield await new Promise((c,u)=>{e.file?.(c,u)})}catch(l){r?.(s,l)}return}if(!e.isDirectory||o(e.name))return;if(n>=a){r?.(s,new Error(`Folder depth exceeds ${a}`));return}let i=e.createReader?.();if(i)for(;;){let l;try{l=await new Promise((c,u)=>{i.readEntries(c,u)})}catch(c){r?.(s,c);return}if(l.length===0)return;for(let c of l)yield*tM(c,s,n+1,o,a,r)}}var xW=e=>new Promise((t,n)=>{if(typeof Image>"u"){n(new Error("Image() is not available in this environment"));return}let o=new Image;o.onload=()=>{t({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=()=>{n(new Error("Failed to decode image data URL"))},o.src=e}),oM={id:"image",accept:e=>tS(e),handle:async(e,{editor:t,worldPoint:n})=>{let o=typeof URL<"u"&&typeof URL.createObjectURL=="function",a=await t.addBinaryFile(e,e.name),r=o?URL.createObjectURL(e):await nS(e),s=await xW(r),i=L2,l=Math.max(s.width,s.height)>i?i/Math.max(s.width,s.height):1,c=Math.round(s.width*l),u=Math.round(s.height*l),d={x:n.x-c/2,y:n.y-u/2},f=e.type==="image/gif"||/\.gif$/i.test(e.name),p=null;if(typeof Image<"u"){if(p=new Image,p.src=r,typeof document<"u"){let y=aM();p.style.position="fixed",p.style.left="0",p.style.top="0",p.style.width="1px",p.style.height="1px",p.style.opacity="0.01",p.style.zIndex="-1",p.style.pointerEvents="none",y.appendChild(p)}let x=p;x.complete||await new Promise(y=>{x.onload=()=>{y()},x.onerror=()=>{y()}})}let h=f?await e.arrayBuffer():void 0,m=p??void 0;if(p&&!f&&typeof createImageBitmap=="function")try{m=await createImageBitmap(p)}catch{}t.insertImage({src:r,fileId:a,width:c,height:u,position:d,...m?{image:m}:{},animated:f,...f?{animationKind:"gif"}:{},...h?{animationData:h}:{}})}},nM="oh-just-another-animated-image-sink",aM=()=>{let e=document.getElementById(nM);if(e)return e;let t=document.createElement("div");return t.id=nM,t.setAttribute("aria-hidden","true"),t.style.position="fixed",t.style.left="0",t.style.top="0",t.style.width="0",t.style.height="0",t.style.overflow="visible",t.style.pointerEvents="none",t.style.zIndex="-1",document.body.appendChild(t),t},rM={id:"video",accept:e=>eS(e),handle:async(e,{editor:t,worldPoint:n})=>{if(typeof document>"u")return;let o=URL.createObjectURL(e),a=document.createElement("video");a.src=o,a.muted=!0,a.loop=!0,a.playsInline=!0,a.autoplay=!0;let r=aM();a.style.position="absolute",a.style.left="-99999px",a.style.top="-99999px",a.style.width="1px",a.style.height="1px",r.appendChild(a),await new Promise(p=>{let h=()=>{p()};a.onloadedmetadata=h,a.onerror=h});let s=a.videoWidth||480,i=a.videoHeight||270,l=L2,c=Math.max(s,i)>l?l/Math.max(s,i):1,u=Math.round(s*c),d=Math.round(i*c),f={x:n.x-u/2,y:n.y-d/2};a.play().catch(()=>{}),t.insertImage({src:o,width:u,height:d,position:f,image:a,animated:!0})}};var _y=64,sM=(e,t)=>{let n=null,o=t,a=0;for(;o.parentId&&a<_y;){let r=I(e,o.parentId);if(!r)break;ze(r)&&(n=r),o=r,a++}return n},aS=(e,t,n)=>{let o=I(e,t),a=0;for(;o&&a<_y;){if(o.id===n)return!0;if(!o.parentId)return!1;o=I(e,o.parentId),a++}return!1},iM=(e,t,n)=>{let o=t,a=0;for(;o.parentId&&a<_y&&n!==o.parentId;){let r=I(e,o.parentId);if(!r||!ze(r))break;o=r,a++}return o},lM=(e,t,n)=>{let o=new Set,a=new Set(t);for(let r of e.elements.values())a.has(r.id)||aS(e,r.id,n)||o.add(r.id);return o},cM=(e,t,n,o)=>{if(!n)return null;if(o!==n.id)return n;let a=t,r=null,s=0;for(;a.parentId&&s<_y;){let i=I(e,a.parentId);if(!i||i.id===n.id)break;ze(i)&&(r=i),a=i,s++}return r};var bW=/^Frame (\d+)$/,uM=e=>{let t=0;for(let n of e.elements.values()){if(!Be(n))continue;let o=bW.exec(n.name??"");o&&(t=Math.max(t,Number(o[1])))}return`Frame ${t+1}`},dM=(e,t,n,o)=>{let a=o.x,r=o.y,s=o.x+o.width,i=o.y+o.height,l=e;for(let c of e.elements.values()){if(c.id===n||Be(c)||c.frameId!==void 0)continue;let u=z(c),d=u.x+u.width/2,f=u.y+u.height/2;if(d<a||d>s||f<r||f>i)continue;let p=J(l,c.id,h=>({...h,frameId:n}));l=p.scene,t.push(p.patch)}return l},fM=(e,t)=>{let n=[...e.elements.values()].filter(Be).sort((a,r)=>a.order<r.order?1:a.order>r.order?-1:0).map(a=>({id:a.id,b:z(a)})),o=e;for(let a of e.elements.values()){if(Be(a))continue;let r=z(a),s=r.x+r.width/2,i=r.y+r.height/2,l;for(let u of n)if(s>=u.b.x&&s<=u.b.x+u.b.width&&i>=u.b.y&&i<=u.b.y+u.b.height){l=u.id;break}if(a.frameId===l)continue;let c=J(o,a.id,u=>{let d={...u};return l===void 0?delete d.frameId:d.frameId=l,d});o=c.scene,t.push(c.patch)}return o};var Cy=class{pending=!1;getScene;compact;constructor(t){this.getScene=t.getScene,this.compact=t.compact}schedule(){this.pending||(this.pending=!0,queueMicrotask(()=>{this.pending=!1,this.runCheck()}))}runCheck(){let t=this.getScene(),n=new Set;for(let o of t.elements.values())o.order.length>A2&&n.add(o.layerId);for(let o of t.links.values())o.order.length>A2&&n.add(o.layerId);for(let o of n)this.compact(o)}};var Ey=class{opts;pending=!1;signatures=new Map;constructor(t){this.opts=t}schedule(){this.pending||(this.pending=!0,queueMicrotask(()=>{this.pending=!1,this.runCheck()}))}resetSignature(t){this.signatures.set(t,this.signatureFor(t))}runCheck(){let t=this.opts.getScene(),n=!1;for(let o of t.elements.values()){if(!On(o))continue;let a=this.signatureFor(o.id);if(this.signatures.get(o.id)===a)continue;this.signatures.set(o.id,a);let r=Jf(this.opts.getScene(),o.id);if(!r)continue;this.opts.applyPatch(r);let s=this.opts.getScene();for(let i of s.elements.values())i.parentId===o.id&&this.opts.growContainer(o.id,i.id);n=!0}n&&this.opts.onMutated()}signatureFor(t){let n=this.opts.getScene(),o=I(n,t),a=[...n.elements.values()].filter(s=>s.parentId===t);if(o&&On(o)?.kind==="wrap"){let s=to(o),i=s?`${Math.round(s.x)},${Math.round(s.y)}`:"0,0",l=s?Math.round(s.width):0,c=a.map(u=>{let d=z(u);return`${u.id}:${Math.round(d.width)}x${Math.round(d.height)}`}).sort();return`o${i}|w${l}|${c.join(",")}`}let r=a.map(s=>s.id);return r.sort(),r.join(",")}};var pM=()=>({mode:null,selection:null,scene:null,viewport:null,canUndo:!1,canRedo:!1}),hM=(e,t,n)=>{n.mode!==e.mode&&(e.mode=n.mode,t.emit("mode",n.mode)),n.selection!==e.selection&&(e.selection=n.selection,t.emit("selection",n.selection)),n.scene!==e.scene&&(e.scene=n.scene,t.emit("scene",n.scene)),n.scene.viewport!==e.viewport&&(e.viewport=n.scene.viewport,t.emit("viewport",n.scene)),(n.canUndo!==e.canUndo||n.canRedo!==e.canRedo)&&(e.canUndo=n.canUndo,e.canRedo=n.canRedo,t.emit("history",{canUndo:n.canUndo,canRedo:n.canRedo})),t.emit("change")},mM=(e,t)=>{e.mode=t.mode,e.selection=t.selection,e.scene=t.scene,e.viewport=t.scene.viewport,e.canUndo=t.canUndo,e.canRedo=t.canRedo};var Ty=class{frameId=null;isAnimated;onTick;constructor(t){this.isAnimated=t.isAnimated,this.onTick=t.onTick}start(){if(this.frameId!==null||typeof requestAnimationFrame>"u")return;let t=()=>{if(!this.isAnimated()){this.frameId=null;return}this.onTick(),this.frameId=requestAnimationFrame(t)};this.frameId=requestAnimationFrame(t)}stop(){this.frameId!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.frameId),this.frameId=null)}get running(){return this.frameId!==null}};var Iy=class{host;tick;costEma=0;lastTickMs=0;onVisibilityChange=()=>{typeof document>"u"||(document.hidden?this.tick.stop():this.maybe())};constructor(t){this.host=t,this.tick=new Ty({isAnimated:()=>this.host.hasVisibleAnimatedElement(),onTick:()=>{this.onTick()}})}onTick(){let t=typeof performance<"u"?performance.now():Date.now(),n=Math.min(jI,Math.max(qI,this.costEma*VI));if(t-this.lastTickMs<n)return;this.lastTickMs=t,this.host.autoStopHeavyGifs(),this.host.forceAnimationRepaint();let o=(typeof performance<"u"?performance.now():Date.now())-t;this.costEma=this.costEma*.8+o*.2}attach(){typeof document<"u"&&document.addEventListener("visibilitychange",this.onVisibilityChange)}detach(){this.tick.stop(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onVisibilityChange)}maybe(){this.host.hasVisibleAnimatedElement()&&this.tick.start()}};var My=class{ref;constructor(t){this.ref=t}record(t){this.ref.gestureTx??=this.ref.history.transaction(),this.ref.gestureTx.add(t)}commit(){this.ref.groupMoveOrigin=null,this.ref.groupLinkMoveOrigin=null,this.ref.groupResizeOrigin=null,this.ref.dragElementId=null,this.ref.containerHover!==null&&(this.ref.containerHover=null),this.ref.gestureTx&&(this.ref.gestureTx.commit(),this.ref.gestureTx=null),this.ref.notify()}cancel(){this.ref.groupMoveOrigin=null,this.ref.groupLinkMoveOrigin=null,this.ref.groupResizeOrigin=null,this.ref.gestureTx&&(this.ref.gestureTx.cancel(),this.ref.gestureTx=null)}finalize(){if(this.ref.gestureTx){try{this.ref.gestureTx.commit()}catch{this.ref.gestureTx.cancel()}this.ref.gestureTx=null}}maybeRevertModeAfterCreate(){this.ref.toolLocked||this.ref.mode==="select"||this.ref.mode==="hand"||this.ref.setMode("select")}};function Dp(){return typeof performance<"u"?performance.now():Date.now()}function AW(){if(typeof matchMedia!="function")return!1;try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var Ry=class{state=new Map;hoveredId=null;ensure(t){if(this.state.has(t))return;let n=Dp();this.state.set(t,{playing:!AW(),originMs:n,playStartMs:n,frozenMs:0})}clock(t){let n=this.state.get(t),o=Dp();return n?n.playing?o-n.originMs:n.frozenMs:o}toggle(t){let n=Dp(),o=this.state.get(t);o?o.playing?(o.frozenMs=n-o.originMs,o.playing=!1):(o.originMs=n-o.frozenMs,o.playStartMs=n,o.playing=!0):this.state.set(t,{playing:!0,originMs:n,playStartMs:n,frozenMs:0})}hoverEnter(t){if(this.hoveredId===t||(this.hoveredId=t,t===null))return!1;let n=this.state.get(t);if(n&&!n.playing){let o=Dp();return n.originMs=o-n.frozenMs,n.playStartMs=o,n.playing=!0,!0}return!1}isPaused(t){return this.state.get(t)?.playing===!1}autoStopHeavy(t){let n=Dp();for(let o of t){let a=this.state.get(o);if(a?.playing){if(o===this.hoveredId){a.playStartMs=n;continue}n-a.playStartMs>XI&&(a.frozenMs=n-a.originMs,a.playing=!1)}}}};var yM=(e,t,n,o)=>{let a=Ae(Array.from(e.elements.values()).filter(s=>s.layerId===o).map(s=>s.order)),r={};return t.image&&(r.image=t.image),t.animated&&(r.animated=!0),{id:n,layerId:o,type:"image",position:t.position,rotation:0,scale:{x:1,y:1},order:a,style:{},width:t.width,height:t.height,src:t.src,...t.fileId?{fileId:t.fileId}:{},...t.animationKind?{animationKind:t.animationKind}:{},...t.animationData!==void 0?{animationData:t.animationData}:{},...Object.keys(r).length>0?{metadata:r}:{}}},gM=async(e,t,n,o)=>{let a=await t.arrayBuffer(),r=eA(`file-${o()}-${Date.now().toString(36)}`),s=ZA(r,a,{mime:t.type||"application/octet-stream",...n!==void 0?{name:n}:{}}),i={kind:"file",id:r,before:null,after:s};return{scene:Q(e,i),patch:i,id:r}},Oy=e=>{for(let t of e.elements.values())if(t.metadata?.animated===!0)return!0;return!1};var bM=e=>{if(!Oy(e._scene))return!1;let t=e.computeViewportWorld();if(!t)return!0;for(let n of e._scene.elements.values())if(n.metadata?.animated===!0&&V.intersects(z(n),t))return!0;return!1},AM=e=>{let t=[];for(let n of e._scene.elements.values()){if(!ct(n)||!n.animationKind)continue;n.animationData instanceof ArrayBuffer&&n.animationData.byteLength>ZI&&t.push(n.id)}e.gifPlayback.autoStopHeavy(t)},rS=e=>{for(let t of e._scene.elements.values()){if(!ct(t)||!t.animationKind||(e.gifPlayback.ensure(t.id),!t.fileId)||t.animationData instanceof ArrayBuffer)continue;let n=O0(e._scene,t.fileId);n&&(e._scene=Q(e._scene,{kind:"element",id:t.id,before:t,after:{...t,animationData:n.data}}))}},vW=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],xM=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of vW){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},SW=async(e,t)=>{if(typeof Blob>"u")return null;let n=new Blob([e],{type:t||"application/octet-stream"});if(typeof createImageBitmap=="function")try{return await createImageBitmap(n)}catch{}if(typeof Image<"u"&&typeof URL<"u"&&typeof URL.createObjectURL=="function"){let o=URL.createObjectURL(n);return new Promise(a=>{let r=new Image;r.onload=()=>{a(r)},r.onerror=()=>{URL.revokeObjectURL(o),a(null)},r.src=o})}return null},sS=async e=>{let t=[];for(let o of e._scene.elements.values()){if(!ct(o)||o.animationKind||xM(o.metadata?.image)||!o.fileId)continue;let a=O0(e._scene,o.fileId);a&&t.push({id:o.id,data:a.data,mime:a.mime})}if(t.length===0)return;let n=!1;for(let o of t){let a=await SW(o.data,o.mime);if(!a)continue;let r=e._scene.elements.get(o.id);!r||!ct(r)||xM(r.metadata?.image)||(e._scene=Q(e._scene,{kind:"element",id:r.id,before:r,after:{...r,metadata:{...r.metadata,image:a}}}),n=!0)}n&&e.forceRender()};var vM={x:-1e9,y:-1e9,width:0,height:0},kW=4,SM=(e,t)=>{let n=new Map;if(e===t)return{world:vM,tileDirty:n};let o=null,a=u=>{o=o?V.union(o,u):u},r=new Set;for(let[u,d]of t.elements){let f=e.elements.get(u);if(f===d)continue;r.add(u);let p=Xf(d),h=f?Xf(f):null;a(p),h&&a(h),n.set(u,{before:h,after:p})}for(let[u,d]of e.elements)if(!t.elements.has(u)){r.add(u);let f=Xf(d);a(f),n.set(u,{before:f,after:null})}let s=u=>{for(let d of[u.from,u.to])if(d.kind!=="point"&&r.has(d.elementId))return!0;return!1};for(let[u,d]of t.links){let f=e.links.get(u);if(f===d&&!s(d))continue;let p=os(t,d);p&&a(p);let m=os(e,f??d);m&&a(m)}for(let[u,d]of e.links)if(!t.links.has(u)){let f=os(e,d);f&&a(f)}if(o===null)return{world:vM,tileDirty:n};let i=new Set,l=o,c=!0;for(;c;){c=!1;for(let u of t.elements.values()){if(i.has(u.id))continue;let d=z(u);if(!V.intersects(d,l))continue;i.add(u.id);let f=V.union(l,d);(f.x!==l.x||f.y!==l.y||f.width!==l.width||f.height!==l.height)&&(l=f,c=!0)}}return{world:V.expand(l,kW),tileDirty:n}};var Dy=class{screenToWorld;onFire;timer=null;origin=null;constructor(t,n){this.screenToWorld=t,this.onFire=n}start(t){this.cancel(),this.origin=t,this.timer=setTimeout(()=>{this.timer=null;let n=this.origin;if(this.origin=null,!n)return;let o=this.screenToWorld(n);this.onFire({screenPoint:n,worldPoint:o})},gI)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.origin=null}cancelIfMovedBeyond(t,n){this.origin&&U.distance(this.origin,t)>n&&this.cancel()}};var Py=class{screenToWorld;zoomAt;panBy;origin=null;constructor(t,n,o){this.screenToWorld=t,this.zoomAt=n,this.panBy=o}isActive(){return this.origin!==null}begin(t){if(t.length<2)return;let[n,o]=t,a=U.midpoint(n,o);this.origin={midpointScreen:a,midpointWorld:this.screenToWorld(a),distance:U.distance(n,o)}}apply(t){if(!this.origin||t.length<2)return;let[n,o]=t,a=U.distance(n,o),r=U.midpoint(n,o);if(U.distance(r,this.origin.midpointScreen)+Math.abs(a-this.origin.distance)<yI)return;let i=a/this.origin.distance;if(i!==1){let u=this.screenToWorld(r);this.zoomAt(i,u)}let l=r.x-this.origin.midpointScreen.x,c=r.y-this.origin.midpointScreen.y;(l!==0||c!==0)&&this.panBy({x:l,y:c}),this.origin={midpointWorld:this.screenToWorld(r),distance:a,midpointScreen:r}}end(){this.origin=null}};var wW=(e,t)=>{let n=e.width*e.height;if(n<=0)return 0;let o=Math.max(e.x,t.x),a=Math.max(e.y,t.y),r=Math.min(e.x+e.width,t.x+t.width),s=Math.min(e.y+e.height,t.y+t.height),i=r-o,l=s-a;return i<=0||l<=0?0:i*l/n},_W=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=z(o);n=n?V.union(n,a):a}return n},LM=(e,t,n,o)=>{if(!Nf(t)||!Ti(t))return n;if(On(t)?.kind==="wrap")return CW(e,t,n,o);let a=_W(e,t.id);if(!a)return n;let r={...t,position:{x:n.x,y:n.y},width:n.width,height:n.height},s=to(r);if(!s)return n;let{x:i,y:l,width:c,height:u}=n,d=s.x,f=s.y,p=s.x+s.width,h=s.y+s.height,m=a.x,x=a.y,y=a.x+a.width,g=a.y+a.height;if(o.includes("e")&&p<y&&(c+=y-p),o.includes("s")&&h<g&&(u+=g-h),o.includes("w")&&d>m){let b=d-m;i-=b,c+=b}if(o.includes("n")&&f>x){let b=f-x;l-=b,u+=b}return{x:i,y:l,width:c,height:u}},CW=(e,t,n,o)=>{let a=ui(t)?.padding??0,r=Math.max(0,n.width-2*a),s=N0(e,t.id,r);if(!s)return n;let{x:i,y:l,width:c,height:u}=n,d=s.widest+2*a;if(c<d){let m=d-c;c=d,o.includes("w")&&(i-=m)}let f=Math.max(0,c-2*a),h=(f===r?s:N0(e,t.id,f)??s).contentHeight+2*a;if(u<h){let m=h-u;u=h,o.includes("n")&&(l-=m)}return{x:i,y:l,width:c,height:u}},kM=(e,t)=>{let n=e.dragElementId;if(!n)return;let o=I(e.scene,n);if(!o)return;let a=e.containerHover;if(a&&a.id!==o.parentId){let r=Ae([...e.scene.elements.values()].filter(i=>i.layerId===o.layerId&&i.id!==n).map(i=>i.order)),s=J(e.scene,n,i=>({...i,parentId:a.id,order:r}));e.applyPatch(s.patch,s.scene),Pp(e,a.id,n);return}if(a&&a.id===o.parentId){Pp(e,o.parentId,n);return}if(o.parentId){let r=I(e.scene,o.parentId);if(r!==void 0&&ze(r))return;let s=r?to(r):null,i=z(o),l=s?wW(i,s):0;if(s&&l>=MI){Pp(e,o.parentId,n);return}let c=J(e.scene,n,u=>{let d={...u};return delete d.parentId,d});e.applyPatch(c.patch,c.scene)}},Pp=(e,t,n)=>{let o=I(e.scene,t),a=I(e.scene,n);if(!o||!a)return;let r=ui(o);if(!r)return;let s=z(a),i=LA(o,s);if(!i)return;if(Ti(o)){let c=kA({width:o.width,height:o.height,spec:r},i),u=J(e.scene,t,d=>({...d,position:{x:d.position.x+c.positionOffset.x,y:d.position.y+c.positionOffset.y},width:c.width,height:c.height,metadata:{...d.metadata??{},container:{...r,dropZone:i}}}));e.applyPatch(u.patch,u.scene);return}let l=J(e.scene,t,c=>({...c,metadata:{...c.metadata??{},container:{...r,dropZone:i}}}));e.applyPatch(l.patch,l.scene)};var Bp=(e,t,n)=>{let o=e.x,a=e.y,r=e.width,s=e.height;switch(t){case"nw":o+=n.x,a+=n.y,r-=n.x,s-=n.y;break;case"n":a+=n.y,s-=n.y;break;case"ne":a+=n.y,r+=n.x,s-=n.y;break;case"e":r+=n.x;break;case"se":r+=n.x,s+=n.y;break;case"s":s+=n.y;break;case"sw":o+=n.x,r-=n.x,s+=n.y;break;case"w":o+=n.x,r-=n.x;break}return{x:o,y:a,width:r,height:s}},iS=(e,t)=>{let n=e.x+e.width/2,o=e.y+e.height/2,a=e.width+2*(t.width-e.width),r=e.height+2*(t.height-e.height);return{x:n-a/2,y:o-r/2,width:a,height:r}},lS=(e,t)=>{if(e.width===0||e.height===0)return t;let n=t.width/e.width,o=t.height/e.height,a=Math.abs(n-1)>=Math.abs(o-1)?n:o;return{x:t.x,y:t.y,width:e.width*a,height:e.height*a}},wM=e=>e==="nw"||e==="w"||e==="sw",_M=e=>e==="ne"||e==="e"||e==="se",CM=e=>e==="nw"||e==="n"||e==="ne",EM=e=>e==="sw"||e==="s"||e==="se",cS=(e,t,n,o,a=!1)=>{let r=o.noFlip?o.minWidth??0:o.minWidth,s=o.noFlip?o.minHeight??0:o.minHeight,i=o.maxWidth,l=o.maxHeight,c=(m,x,y)=>{let g=m;return x!==void 0&&g<x&&(g=x),y!==void 0&&g>y&&(g=y),g},u=t.width;o.noFlip?u=c(u,r,i):i!==void 0&&Math.abs(u)>i?u=u<0?-i:i:r!==void 0&&Math.abs(u)<r&&u!==0&&(u=u<0?-r:r);let d=t.height;if(o.noFlip?d=c(d,s,l):l!==void 0&&Math.abs(d)>l?d=d<0?-l:l:s!==void 0&&Math.abs(d)<s&&d!==0&&(d=d<0?-s:s),a){let m=o.noFlip?u:Math.abs(u),x=o.noFlip?d:Math.abs(d),y=e.x+e.width/2,g=e.y+e.height/2;return{x:y-m/2,y:g-x/2,width:m,height:x}}let f=t.x;wM(n)&&!_M(n)?f=e.x+e.width-u:_M(n)&&!wM(n)&&(f=e.x);let p=t.y;CM(n)&&!EM(n)?p=e.y+e.height-d:EM(n)&&!CM(n)&&(p=e.y);let h={x:f,y:p,width:u,height:d};return o.noFlip?h:V.normalize(h)};var TM=(e,t)=>e.kind!=="point"&&t.has(e.elementId),EW=(e,t)=>TM(e.from,t)&&TM(e.to,t),RM=e=>(e.waypoints?.length??0)>0||(e.fixedSegments?.length??0)>0||(e.routedPoints?.length??0)>0,IM=(e,t)=>e.map(n=>({x:n.x+t.x,y:n.y+t.y})),TW=(e,t)=>{if(!RM(e))return null;let n={};return e.waypoints?.length&&(n.waypoints=IM(e.waypoints,t)),e.fixedSegments?.length&&(n.fixedSegments=e.fixedSegments.map(o=>({axis:o.axis,pos:o.pos+(o.axis==="h"?t.y:t.x),at:o.at+(o.axis==="h"?t.x:t.y)}))),e.routedPoints?.length&&(n.routedPoints=IM(e.routedPoints,t)),n},MM=(e,t)=>e.kind==="point"?{kind:"point",position:{x:e.position.x+t.x,y:e.position.y+t.y}}:e,uS=(e,t)=>{let n=TW(e,t),o=e.from.kind==="point",a=e.to.kind==="point";if(!n&&!o&&!a)return null;let r={...n??{}};return o&&(r.from=MM(e.from,t)),a&&(r.to=MM(e.to,t)),r},OM=(e,t,n,o,a)=>{let r=c=>({x:t+(c.x-t)*o,y:n+(c.y-n)*a}),s=e.from.kind==="point",i=e.to.kind==="point";if(!RM(e)&&!s&&!i)return null;let l={};return e.waypoints?.length&&(l.waypoints=e.waypoints.map(r)),e.fixedSegments?.length&&(l.fixedSegments=e.fixedSegments.map(c=>({axis:c.axis,pos:c.axis==="h"?n+(c.pos-n)*a:t+(c.pos-t)*o,at:c.axis==="h"?t+(c.at-t)*o:n+(c.at-n)*a}))),e.routedPoints?.length&&(l.routedPoints=e.routedPoints.map(r)),e.from.kind==="point"&&(l.from={kind:"point",position:r(e.from.position)}),e.to.kind==="point"&&(l.to={kind:"point",position:r(e.to.position)}),l},DM=(e,t,n)=>n.has(e.id)||EW(e,t),dS=(e,t,n)=>{let o=new Map;for(let a of e.links.values())DM(a,t,n)&&uS(a,{x:0,y:0})!==null&&o.set(a.id,a);return o},PM=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=be(e,a);if(!s)continue;let i=uS(r,n);i&&o.push({kind:"link",id:a,before:s,after:{...s,...i}})}return o},BM=(e,t,n,o)=>{let a=e,r=[];for(let s of[...e.links.values()]){if(!DM(s,t,n))continue;let i=uS(s,o);if(!i)continue;let l=et(a,s.id,c=>({...c,...i}));a=l.scene,r.push(l.patch)}return{scene:a,patches:r}};var NM=(e,t,n,o,a,r,s=!1,i=!1)=>{let l=I(e,t);if(!l||!Ti(l))return null;let c=Bp(a,n,o),u=s?lS(a,c):c,d=i?iS(a,u):u,p=l.noFlip===!0||On(l)!==null?{...l,noFlip:!0}:l,h=cS(a,d,n,p,i),m=r(l,h,n),x={...l,position:{x:m.x,y:m.y},scale:{x:1,y:1},width:m.width,height:m.height},y={kind:"element",id:t,before:l,after:x};return{scene:Q(e,y),patch:y}},zM=(e,t,n,o,a=!1,r=!1)=>{let s=I(e,t.id);if(!s||!Ti(t))return null;let i=xi(t),[l]=cp(i),c=Math.cos(i.rotation),u=Math.sin(i.rotation),d={x:c,y:u},f={x:-u,y:c},p={x:o.x*d.x+o.y*d.y,y:o.x*f.x+o.y*f.y},h={x:0,y:0,width:i.bounds.width,height:i.bounds.height},m=Bp(h,n,p),x=a?lS(h,m):m,y=r?iS(h,x):x,b=t.noFlip===!0||On(t)!==null?{...t,noFlip:!0}:t,A=cS(h,y,n,b,r),_={x:l.x+A.x*d.x+A.y*f.x,y:l.y+A.x*d.y+A.y*f.y},T={...t,position:_,scale:{x:1,y:1},width:A.width,height:A.height},w={kind:"element",id:t.id,before:s,after:T};return{scene:Q(e,w),patch:w}},FM=(e,t,n,o,a,r=!1)=>{let s=I(e,t.id);if(!s)return null;let i=Bp(a,n,o),l=a.x+a.width/2,c=a.y+a.height/2;if(n==="e"||n==="w"){let S=Math.max(t.fontSize,Math.abs(i.width)),L=n==="w"?a.x+a.width:a.x,M=r?l-S/2:n==="w"?L-S:L,B={...t,position:{x:M,y:a.y},scale:{x:1,y:1},maxWidth:S},W={kind:"element",id:t.id,before:s,after:B};return{scene:Q(e,W),patch:W}}let u=n==="n"||n==="s",d=a.width>0?Math.abs(i.width/a.width):1,f=a.height>0?Math.abs(i.height/a.height):1,p=u?f:Math.max(d,f),h=Math.max(Y0,t.fontSize*p),m=h/t.fontSize,x=a.width*m,y=a.height*m,g=n.includes("w")?a.x+a.width:a.x,b=n.includes("n")?a.y+a.height:a.y,A=r?l-x/2:n.includes("w")?g-x:g,_=r?c-y/2:n.includes("n")?b-y:b,T={...t,position:{x:A,y:_},scale:{x:1,y:1},fontSize:h,...t.maxWidth!==void 0?{maxWidth:t.maxWidth*m}:{}},w={kind:"element",id:t.id,before:s,after:T};return{scene:Q(e,w),patch:w}},HM=(e,t,n,o,a,r,s=!1)=>{let i=Bp(a,n,o),l=1,c=a.width>0?i.width/a.width:1,u=a.height>0?i.height/a.height:1;if(r){let x=Math.max(Math.abs(c),Math.abs(u));c=x*(c>=0?1:-1),u=x*(u>=0?1:-1)}s&&(c=1+2*(c-1),u=1+2*(u-1));let d=Math.abs(c-1)>=Math.abs(u-1)?c:u,f=s?a.x+a.width/2:n.includes("w")?a.x+a.width:a.x,p=s?a.y+a.height/2:n.includes("n")?a.y+a.height:a.y,h=e,m=[];for(let[x,y]of t.elements){let g=I(h,x);if(!g)continue;let b=f+(y.position.x-f)*c,A=p+(y.position.y-p)*u;if(Ti(g)){let L=g.type==="image",M=L?d:c,B=L?d:u,W=y.bounds.width*M,ie=y.bounds.height*B;if(Math.abs(W)<l||Math.abs(ie)<l)continue;let ne={...g,position:{x:b,y:A},scale:{x:W>=0?1:-1,y:ie>=0?1:-1},width:Math.abs(W),height:Math.abs(ie)},j={kind:"element",id:x,before:g,after:ne};h=Q(h,j),m.push(j);continue}let _=y.scale.x*c,T=y.scale.y*u;if(Math.abs(_)<l/Math.max(1,y.bounds.width)||Math.abs(T)<l/Math.max(1,y.bounds.height))continue;let w={...g,position:{x:b,y:A},scale:{x:_,y:T}},S={kind:"element",id:x,before:g,after:w};h=Q(h,S),m.push(S)}for(let[x,y]of t.links??[]){let g=be(h,x);if(!g)continue;let b=OM(y,f,p,c,u);if(!b)continue;let A={kind:"link",id:x,before:g,after:{...g,...b}};h=Q(h,A),m.push(A)}return{scene:h,patches:m}};var yt=Object.freeze(new Set),By=e=>new Set([e]),fS=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},IW=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},UM=(e,t)=>e.has(t)?IW(e,t):fS(e,t),Np=(e,t)=>g0(e,t),GM=e=>{if(e.size!==1)return null;for(let t of e)return t;return null};var zp=e=>Math.min(mI,Math.max(hI,e)),WM=(e,t)=>t.x===0&&t.y===0?null:{...e,viewport:FA(e.viewport,t)},qM=(e,t,n)=>{let o=e.viewport.zoom,r=zp(o*t)/o;return r===1?null:{...e,viewport:M0(e.viewport,r,n)}},jM=e=>{let t=e.viewport;if(t.zoom===1)return null;let n={x:t.pan.x+t.size.width/2/t.zoom,y:t.pan.y+t.size.height/2/t.zoom};return{...e,viewport:M0(t,1/t.zoom,n)}},hS=(e,t,n)=>{let o=e.viewport;if(o.size.width<=0||o.size.height<=0||t.width<=0||t.height<=0)return null;let a=o.size.width-n*2,r=o.size.height-n*2;if(a<=0||r<=0)return null;let s=zp(Math.min(a/t.width,r/t.height)),i={x:t.x+t.width/2,y:t.y+t.height/2},l={x:i.x-o.size.width/2/s,y:i.y-o.size.height/2/s};return{...e,viewport:{...o,zoom:s,pan:l}}},VM=(e,t,n)=>{let o=e.viewport;if(o.size.width<=0||o.size.height<=0||t.width<=0||t.height<=0)return null;let a=o.size.width-n*2,r=o.size.height-n*2;if(a<=0||r<=0)return null;let s=Math.min(a/t.width,r/t.height),i=zp(Math.min(o.zoom,s)),l={x:t.x+t.width/2,y:t.y+t.height/2},c={x:l.x-o.size.width/2/i,y:l.y-o.size.height/2/i};return{...e,viewport:{...o,zoom:i,pan:c}}},ZM=(e,t)=>{if(e.elements.size===0)return null;let n=null;for(let o of e.elements.values()){let a=z(o);n=n?V.union(n,a):a}return n?hS(e,n,t):null},XM=(e,t,n)=>{let o=e.viewport;return o.size.width===t&&o.size.height===n?null:{...e,viewport:HA(o,t,n)}},YM=(e,t)=>{let n=e.viewport,o=t.enabled??n.gridEnabled,a=t.style??n.gridStyle,r=t.snap??n.snapToGrid;if(o===n.gridEnabled&&a===n.gridStyle&&r===n.snapToGrid)return null;let s={...n,gridEnabled:o,...a===void 0?{}:{gridStyle:a},...r===void 0?{}:{snapToGrid:r}};return{...e,viewport:s}};var MW=(e,t)=>{let n=[];for(let o=e;o<=t;o++)n.push(o);return n},KM=(e,t,n)=>{let o=e.x-t.x,a=e.y-t.y;return o*o+a*a<=n},RW=(e,t,n)=>{let o=t.button===2||t.button===1,a=t.button===0&&e.spaceHeld,r=t.button===0&&e.mode==="hand";return o||a||r?(o&&(e.suppressNextContextMenu=!0),e.beginPanGesture(t.pointerId,t.button,n.point),!0):!1},OW=(e,t,n)=>(e.activePointers.set(t.pointerId,n.point),e.activePointers.size===2?(e.actor.send({type:"POINTER_CANCEL"}),e.cancelGesture(),e.cancelLongPress(),e.panGesture=null,e.touchPanCandidate=null,e.beginPinch(),!0):e.activePointers.size>2),DW=(e,t)=>e.readOnly||e.editingTextElement===null?!1:e.editedElementContainsPoint(t)?(e.cancelLongPress(),e.setTextCaretFromPoint(t),!0):(e.commitTextEdit(),!1),PW=(e,t)=>e.mode!=="crop"||e.cropSession?.drag==null?!1:(e.updateImageCropDrag(t),!0),BW=e=>e.mode!=="crop"||e.cropSession?.drag==null?!1:(e.endImageCropDrag(),!0),NW=(e,t,n)=>e.readOnly||e.mode!=="brush"?!1:(e.beginBrushStroke(t,n),!0),zW=(e,t,n,o)=>e.readOnly||e.mode!=="erase"?!1:(e.cancelLongPress(),e.beginEraseStroke(t,n,o),!0),FW=(e,t)=>e.mode!=="laser"?!1:(e.cancelLongPress(),e.beginLaserStroke(t),!0),HW=(e,t)=>e.mode!=="eyedropper"&&!e.isEyedropperArmed?!1:(e.cancelLongPress(),e.applyEyedropperAt(t),!0),UW=(e,t)=>{if(e.mode!=="crop"||e.cropSession===null)return!1;let n=e.cropHandleAtWorld(t);return n===null?(e.commitImageCrop(),!1):(e.cancelLongPress(),n==="body"?e.beginImageCropBody(t):e.beginImageCropHandle(n,t),!0)},GW=(e,t,n)=>{if(e.readOnly||e.mode!=="select"||(n||0)<2)return!1;let o=e.hitTest(t);if(o.kind!=="element")return!1;let a=I(e._scene,o.id);return a===void 0||!ct(a)?!1:(e.beginImageCrop(o.id),!0)},WW=(e,t)=>{if(e.readOnly||e.mode!=="draw-text")return!1;e.cancelLongPress();let n=e.hitTest(t),o=n.kind==="element"?I(e._scene,n.id):void 0;return o!==void 0&&fe(o)?(e._selection=wt(o.id),e.beginTextEdit(o.id),e.notify()):e.createTextAt(t),!0},qW=(e,t)=>{if(e.readOnly)return!1;let n=e.hitAnnotation(t);if(!n)return!1;let o=e._scene.annotations.get(n);return o?(e.annotationDrag={id:n,originPosition:{...o.position},originWorldPoint:t,moved:!1},e.setSelectedAnnotation(n),!0):!1},jW=(e,t)=>{let n=e.acceleratedElementAt(t);if(!n)return!1;let o=Q9(n.type);if(!o)return!1;let a={x:t.x-n.position.x,y:t.y-n.position.y},r=o(n,a);return r?(e.applyEmit(r),!0):!1},VW=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.mode==="select"&&n))return!1;let o=be(e._scene,n);if(!(o&&(o.routing??"straight")==="orthogonal"))return!1;let a=ot(e._scene,o);if(!(a&&a.length>=2))return!1;let r=e._scene.viewport.zoom||1,s=Zo/r,i=s*s,l=a.length===2?[0]:MW(1,a.length-3);for(let c of l){let u=v(a[c]),d=v(a[c+1]),f=(u.x+d.x)/2,p=(u.y+d.y)/2,h=f-t.x,m=p-t.y;if(h*h+m*m<=i){let x=Math.abs(u.y-d.y)<1e-6?"h":"v",y=x==="h"?(u.x+d.x)/2:(u.y+d.y)/2,g=x==="h"?u.y:u.x;return e.isHandleDoubleClick(t)?e.resetSegmentPin(n,x,g,y):e.beginSegmentDrag(n,x,y),e.cancelLongPress(),!0}}return!1},ZW=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.mode==="select"&&n))return!1;let o=be(e._scene,n),a=o&&(o.routing??"straight")!=="orthogonal"?ot(e._scene,o):null;if(!(o&&a&&a.length>=2))return!1;let r=e._scene.viewport.zoom||1,s=Zo/r,i=s*s,l=[...o.waypoints??[]],c=!1;for(let u=0;u<l.length;u++)if(KM(v(l[u]),t,i)){e.isHandleDoubleClick(t)?e.deleteWaypoint(n,u):e.beginWaypointDrag(n,u,!1),c=!0;break}if(!c){let u=Vf(e._scene,o)??[];for(let d=0;d<u.length;d++)if(KM(v(u[d]),t,i)){e.beginWaypointDrag(n,d,!0),c=!0;break}}return c?(e.cancelLongPress(),!0):!1},XW=(e,t,n)=>{let o=I(e._scene,t);if(!o)return!1;let a=e._scene.viewport.zoom||1,{names:r,worldPoints:s}=_o(o,Lo/a),i=(Xo+e.anchorStartHitSlop)/a,l=null,c=i*i;for(let u=0;u<s.length;u++){let d=v(s[u]),f=d.x-n.x,p=d.y-n.y,h=f*f+p*p;h<=c&&(c=h,l=v(r[u]))}return l===null?!1:(e.cancelLongPress(),e.linkDragFromAnchor={fromElement:t,fromWorld:Yt(o,{kind:"named",name:l}),anchorName:l,origin:n,moved:!1},!0)},YW=(e,t,n,o)=>{if(e.readOnly||!(e.mode==="select"&&!t.modifiers.shift&&!t.modifiers.meta&&!t.modifiers.ctrl&&o.kind!=="rotate-handle"))return!1;let a=e._selection.size===1?[...e._selection][0]:null;return!!(a&&XW(e,a,n))},KW=(e,t,n)=>{if(!((t.modifiers.meta||t.modifiers.ctrl)&&n.kind==="element"&&e.elementLink(n.id)!==null)&&n.kind==="element"&&!e._selection.has(n.id)){let r=t.modifiers.shift||t.modifiers.meta||t.modifiers.ctrl;e._selection=r?Xt(e._selection,n.id):wt(n.id),r&&(e.additivePressAdded=n.id),!r&&e._selectedLinks.size>0&&(e._selectedLinks=yt),e.notify()}},$W=(e,t,n)=>{if(e.readOnly)return n;if(t.modifiers.alt&&e.mode==="select"&&n.kind==="element"&&e._selection.has(n.id)){let o=e.duplicateSelectedInPlace(n.id);if(o!==null)return{kind:"element",id:o,bounds:n.bounds}}return n},QM=(e,t,n)=>{if(!n.has(t)){n.add(t);for(let o of e._scene.elements.values())o.parentId===t&&QM(e,o.id,n)}},QW=(e,t)=>{if(t.kind==="element"){let n=I(e._scene,t.id),o=n!==void 0&&ze(n),a=n!==void 0&&Be(n),r=e._selection.has(t.id);if(r||o||a){let s=new Set;if(r)for(let l of e.expandSelectionWithDescendants()){let c=I(e._scene,l);c&&e.isElementManipulable(c)&&s.add(l)}if(o&&QM(e,t.id,s),a){s.add(t.id);for(let l of e._scene.elements.values())l.frameId===t.id&&s.add(l.id)}let i=dS(e._scene,s,e._selectedLinks);if(s.size>1||i.size>0){let l=new Map;for(let c of s){let u=I(e._scene,c);u&&l.set(c,u.position)}e.groupMoveOrigin=l,e.groupLinkMoveOrigin=i.size>0?i:null}else e.groupMoveOrigin=null,e.groupLinkMoveOrigin=null}else e.groupMoveOrigin=null,e.groupLinkMoveOrigin=null}else e.groupMoveOrigin=null},JW=(e,t)=>{if(t.kind==="group-handle"){let n=new Map;for(let a of e.expandSelectionWithDescendants()){let r=I(e._scene,a);r&&n.set(a,{position:r.position,bounds:z(r),scale:r.scale})}let o=dS(e._scene,new Set(n.keys()),e._selectedLinks);e.groupResizeOrigin={combined:t.bounds,elements:n,links:o}}else e.groupResizeOrigin=null},eq=(e,t)=>{if(t.kind==="rotate-handle"){let n=new Map;for(let o of e.expandSelectionWithDescendants()){let a=I(e._scene,o);a&&n.set(o,{position:a.position,rotation:a.rotation})}e.rotateGestureOrigin={pivot:t.pivot,origin:n}}else e.rotateGestureOrigin=null},tq=(e,t,n)=>{let o=e.panGesture;if(o?.pointerId!==t.pointerId)return!1;let a=n.point.x-o.lastPoint.x,r=n.point.y-o.lastPoint.y;return o.lastPoint=n.point,!o.moved&&U.distance(o.startPoint,n.point)>mc&&(o.moved=!0),e.panBy({x:a,y:r}),!0},nq=(e,t,n)=>(e.activePointers.has(t.pointerId)&&e.activePointers.set(t.pointerId,n.point),e.pinch.isActive()?(e.applyPinch(),!0):!1),oq=(e,t,n)=>{if(e.touchPanCandidate!==null&&e.activePointers.size===1&&U.distance(e.touchPanCandidate,n.point)>mc){let o=e.touchPanCandidate;e.touchPanCandidate=null,e.beginPanGesture(t.pointerId,t.button,o);let a=e.panGesture;return a&&(a.moved=!0,e.panBy({x:n.point.x-o.x,y:n.point.y-o.y}),a.lastPoint=n.point),!0}return!1},aq=(e,t)=>e.isDraggingSegment?(e.updateSegmentDrag(t),!0):!1,rq=(e,t)=>e.isDraggingWaypoint?(e.updateWaypointDrag(t),!0):!1,sq=(e,t)=>{let n=e.linkDragFromAnchor;if(!n)return!1;if(!n.moved){let o=t.x-n.origin.x,a=t.y-n.origin.y;if(o*o+a*a<ki*ki)return!0;n.moved=!0}return e.applyLinkPreview(n.fromElement,n.fromWorld,t),e.updateHoveredLinkTarget(t),!0},iq=(e,t)=>e.editingTextElement!==null&&e.isTextDragging?(e.extendTextSelectionToPoint(t),!0):!1,lq=(e,t,n)=>e.brushStroke?(e.extendBrushStroke(t,n),!0):!1,cq=(e,t,n)=>e.eraseStroke?(e.extendEraseStroke(t,n),!0):!1,uq=(e,t)=>e.laserDrawing?(e.extendLaserStroke(t),!0):!1,dq=(e,t)=>{if(!e.dragElementId)return;let n=e.dragElementId,o=new Set([n]);for(let r of e._scene.elements.values()){let s=r.parentId;for(let i=0;s&&i<64;i++){if(s===n){o.add(r.id);break}s=e._scene.elements.get(s)?.parentId}}let a=zf(e._scene,t,o);if(a){let r=to(a);if(r){let s={id:a.id,dropZone:r};(e.containerHover?.id!==s.id||e.containerHover.dropZone!==s.dropZone)&&(e.containerHover=s,e.notify())}}else e.containerHover!==null&&(e.containerHover=null,e.notify())},fq=(e,t)=>{let n=e.annotationDrag;if(!n)return!1;let o=t.x-n.originWorldPoint.x,a=t.y-n.originWorldPoint.y;(o!==0||a!==0)&&(n.moved=!0);let r=e._scene.annotations.get(n.id);if(r){let s={x:n.originPosition.x+o,y:n.originPosition.y+a},i={...r,position:s},l=new Map(e._scene.annotations);l.set(n.id,i),e._scene={...e._scene,annotations:l},e.notify()}return!0},pq=(e,t)=>{for(let o of e.cursorListeners)o(t);let n=e.actor.getSnapshot().context;if(n.pressOrigin&&n.mode!=="select"&&n.mode!=="draw-edge"&&e.isDrawingPhase(n)&&(e.drawingPreview=bp(n.pressOrigin,t)),n.mode==="draw-edge"?e.updateHoveredLinkTarget(t):e.hoveredLinkTarget!==null&&(e.hoveredLinkTarget=null,e.notify()),!n.pressOrigin){let o=e.hitTest(t),a=o.kind==="element"?e._scene.elements.get(o.id):void 0;e.hoverAnimatedElement(a&&ct(a)&&a.animationKind?a.id:null),e.setHoverCursorWorld(e.mode==="select"?t:null),e.mode==="erase"&&e.notify()}e.actor.send({type:"POINTER_MOVE",point:t})},hq=(e,t)=>e.panGesture?.pointerId!==t.pointerId?!1:(e.endPanGesture(),!0),mq=e=>e.pinch.isActive()?(e.activePointers.size<2&&e.pinch.end(),!0):!1,yq=e=>e.isDraggingSegment?(e.endSegmentDrag(),!0):!1,gq=e=>e.isDraggingWaypoint?(e.endWaypointDrag(),!0):!1,xq=(e,t)=>{let n=e.linkDragFromAnchor;if(!n)return!1;e.linkDragFromAnchor=null;let o=Pc(t,e.host),a=e.screenToWorld(o.point);if(n.moved){let r=e.hitTest(a),s=r.kind==="element"?r.id:null;e.applyEmit({type:"CREATE_EDGE",fromElement:n.fromElement,toElement:s,fromPoint:n.fromWorld,toPoint:a})}else{let r=I(e._scene,n.fromElement),s=e._scene.viewport.zoom||1,i=!1;if(r){let{names:l,worldPoints:c}=_o(r,Lo/s),u=l.indexOf(n.anchorName);if(u>=0){let d=v(c[u]),f=e.anchorClickRadius/s,p=d.x-n.origin.x,h=d.y-n.origin.y;i=p*p+h*h<=f*f}}if(i)e.createLinkedElementFromAnchor(n.fromElement,n.anchorName);else{let l=e.hitTest(a);l.kind==="empty"?e.applyEmit({type:"SELECT_CLEAR"}):l.kind==="element"?e.applyEmit({type:"SELECT_REPLACE",id:l.id}):l.kind==="link"&&e.applyEmit({type:"SELECT_EDGE_REPLACE",id:l.id})}}return e.edgePreview=null,e.hoveredLinkTarget=null,e.notify(),!0},bq=e=>e.editingTextElement!==null&&e.isTextDragging?(e.endTextDragSelect(),!0):!1,Aq=e=>e.brushStroke?(e.commitBrushStroke(),!0):!1,vq=e=>e.eraseStroke?(e.commitEraseStroke(),!0):!1,Sq=e=>e.laserDrawing?(e.endLaserStroke(),!0):!1,Lq=e=>{let t=e.annotationDrag;if(!t)return!1;if(e.annotationDrag=null,t.moved){let n=e._scene.annotations.get(t.id);if(n){let o={...n,position:t.originPosition},a=new Map(e._scene.annotations);a.set(t.id,o),e._scene={...e._scene,annotations:a};let r=qa(e._scene,t.id,()=>n);e._scene=r.scene,e._history.push(r.patch),e.notify()}}return!0},kq=(e,t,n)=>{let o=e.actor.getSnapshot().context.pressOrigin,a=t.modifiers.meta||t.modifiers.ctrl;if(o&&a){let r=e._scene.viewport.zoom||1;if(Math.hypot(n.x-o.x,n.y-o.y)*r<mc){let i=e.hitTest(n);if(i.kind==="element"){let l=e.elementLink(i.id);if(l)return e.openLink(l),e.actor.send({type:"POINTER_UP",point:n}),e.commitGesture(),!0}}}return!1},wq=(e,t)=>{let n=e.actor.getSnapshot().context,o=r5(n,t);o?.type==="SELECT_TOGGLE"&&e.additivePressAdded===o.id&&(o=null),e.additivePressAdded=null,!e.routeIsolationClick(o,t)&&o&&e.applyEmit(o),e.drawingPreview=null;let r;n.mode==="draw-edge"?r=e.hitTest(t):n.pressTarget?.kind==="edge-endpoint"&&(r=e.linkAttachTargetAt(t)),e.actor.send(r!==void 0?{type:"POINTER_UP",point:t,target:r}:{type:"POINTER_UP",point:t}),e.applyContainerDrop(t),e.reconcileFrameMembership(),e.commitGesture();let s=n.pressOrigin;if(s){let i=e._scene.viewport.zoom||1;if(Math.hypot(t.x-s.x,t.y-s.y)*i<mc){let c=e.hitTest(t);if(c.kind==="element"){let u=e._scene.elements.get(c.id);u&&ct(u)&&u.animationKind&&e.togglePlayback(u.id)}}}e.refreshCursor(t)},$M=(e,t,n)=>{if(t.deltaY===0)return;let a=1-(Math.abs(t.deltaY)>g2?g2*Math.sign(t.deltaY):t.deltaY)*pI/100;if(a<=0)return;let r=e._scene.viewport.zoom,s=zp(r*a);if(s===r)return;let i=e.screenToWorld(n);e.zoomAt(s/r,i)},_q=(e,t)=>{let n=t.deltaX,o=t.deltaY;t.shiftKey&&n===0&&(n=o,o=0),e.panBy({x:-n*m2,y:-o*m2})},JM=e=>{let t=c=>{c.preventDefault(),e.host.setPointerCapture(c.pointerId),typeof e.host.focus=="function"&&!ea(c.target)&&e.host.focus({preventScroll:!0});let u=Pc(c,e.host);if(e.additivePressAdded=null,RW(e,c,u)||OW(e,c,u))return;e.startLongPress(u.point);let d=e.screenToWorld(u.point);if(HW(e,d)||DW(e,d)||UW(e,d)||GW(e,d,c.detail)||NW(e,d,c.pressure)||zW(e,d,u.modifiers.alt,u.modifiers.shift)||FW(e,d)||WW(e,d)||qW(e,d)||jW(e,d)||VW(e,d)||ZW(e,d))return;let f=e.hitTest(d);YW(e,u,d,f)||(KW(e,u,f),f=$W(e,u,f),e.dragElementId=f.kind==="element"?f.id:null,e.containerHover=null,QW(e,f),JW(e,f),eq(e,f),e.touchPanCandidate=u.kind==="touch"&&e.mode==="select"&&f.kind==="empty"?u.point:null,e.actor.send({type:"POINTER_DOWN",point:d,target:f,modifiers:u.modifiers}))},n=c=>{let u=Pc(c,e.host);if(tq(e,c,u)||nq(e,c,u)||oq(e,c,u))return;e.longPress.cancelIfMovedBeyond(u.point,mc);let d=e.screenToWorld(u.point);e.lastPointerWorld=d,e.refreshCursor(d),!PW(e,d)&&(aq(e,d)||rq(e,d)||sq(e,d)||iq(e,d)||lq(e,d,c.pressure)||cq(e,d,u.modifiers.alt)||uq(e,d)||(dq(e,d),!fq(e,d)&&pq(e,d)))},o=c=>{if(e.host.hasPointerCapture(c.pointerId)&&e.host.releasePointerCapture(c.pointerId),e.activePointers.delete(c.pointerId),e.touchPanCandidate=null,hq(e,c)||mq(e)||(e.cancelLongPress(),BW(e))||yq(e)||gq(e)||xq(e,c)||bq(e)||Aq(e)||vq(e)||Sq(e)||Lq(e))return;let u=Pc(c,e.host),d=e.screenToWorld(u.point);kq(e,u,d)||wq(e,d)},a=c=>{if(e.activePointers.delete(c.pointerId),e.touchPanCandidate=null,e.panGesture?.pointerId===c.pointerId){e.endPanGesture();return}if(e.pinch.isActive()){e.activePointers.size<2&&e.pinch.end();return}if(e.cancelLongPress(),e.linkDragFromAnchor){e.linkDragFromAnchor=null,e.edgePreview=null,e.hoveredLinkTarget=null,e.notify();return}if(e.brushStroke){e.cancelBrushStroke();return}if(e.eraseStroke){e.cancelEraseStroke();return}if(e.laserDrawing){e.endLaserStroke();return}if(e.annotationDrag){let u=e.annotationDrag;e.annotationDrag=null;let d=e._scene.annotations.get(u.id);if(d){let f=new Map(e._scene.annotations);f.set(u.id,{...d,position:u.originPosition}),e._scene={...e._scene,annotations:f},e.notify()}return}e.drawingPreview=null,e.actor.send({type:"POINTER_CANCEL"}),e.cancelGesture()};e.host.addEventListener("pointerdown",t),e.host.addEventListener("pointermove",n),e.host.addEventListener("pointerup",o),e.host.addEventListener("pointercancel",a);let r=c=>{e.suppressNextContextMenu&&(e.suppressNextContextMenu=!1,c.preventDefault(),c.stopPropagation())};e.host.addEventListener("contextmenu",r,!0);let s=c=>{c.code!=="Space"&&c.key!==" "||ea(c.target)||e.spaceHeld||(e.spaceHeld=!0,e.refreshCursor(),c.preventDefault())},i=c=>{c.code!=="Space"&&c.key!==" "||e.spaceHeld&&(e.spaceHeld=!1,e.refreshCursor())};typeof window<"u"&&(window.addEventListener("keydown",s),window.addEventListener("keyup",i));let l=c=>{c.preventDefault();let u=e.host.getBoundingClientRect(),d={x:c.clientX-u.left,y:c.clientY-u.top};if(c.ctrlKey||c.metaKey){$M(e,c,d);return}if(c.deltaX!==0){_q(e,c);return}$M(e,c,d)};return e.host.addEventListener("wheel",l,{passive:!1}),()=>{e.host.removeEventListener("pointerdown",t),e.host.removeEventListener("pointermove",n),e.host.removeEventListener("pointerup",o),e.host.removeEventListener("pointercancel",a),e.host.removeEventListener("contextmenu",r,!0),e.host.removeEventListener("wheel",l),typeof window<"u"&&(window.removeEventListener("keydown",s),window.removeEventListener("keyup",i))}};var Ny=class{drawingPreview=null;edgePreview=null;lassoPreview=null;hoveredLinkTarget=null;hoverCursorWorld=null;annotationDrag=null;linkDragFromAnchor=null;pendingLinkDropMenu=null;lassoBaseSelection=null;lassoBaseLinks=null;groupMoveOrigin=null;groupLinkMoveOrigin=null;groupResizeOrigin=null;rotateGestureOrigin=null;resizeOriginElement=null;snapSuppressed=!1;transformAltKey=!1;transformShiftKey=!1;lastClickAt=0;lastClickWorldPoint=null;brushStroke=null;eraseStroke=null;laserStrokes=[];eraserTrail=[];laserDrawing=!1;lastPointerWorld=null;dragElementId=null;additivePressAdded=null;containerHover=null;activePointers=new Map;touchPanCandidate=null;spaceHeld=!1;panGesture=null;suppressNextContextMenu=!1;editingLinkCaption=null;resetPreviews(){this.drawingPreview=null,this.edgePreview=null,this.lassoPreview=null,this.hoveredLinkTarget=null,this.hoverCursorWorld=null}reset(){this.resetPreviews(),this.annotationDrag=null,this.linkDragFromAnchor=null,this.pendingLinkDropMenu=null,this.lassoBaseSelection=null,this.lassoBaseLinks=null,this.groupMoveOrigin=null,this.groupLinkMoveOrigin=null,this.groupResizeOrigin=null,this.rotateGestureOrigin=null,this.resizeOriginElement=null,this.snapSuppressed=!1,this.transformAltKey=!1,this.transformShiftKey=!1,this.lastClickAt=0,this.lastClickWorldPoint=null,this.brushStroke=null,this.eraseStroke=null,this.laserStrokes=[],this.eraserTrail=[],this.laserDrawing=!1,this.lastPointerWorld=null,this.dragElementId=null,this.additivePressAdded=null,this.containerHover=null,this.activePointers.clear(),this.touchPanCandidate=null,this.spaceHeld=!1,this.panGesture=null,this.suppressNextContextMenu=!1,this.editingLinkCaption=null}};var Nc={stroke:OI,fill:null,opacity:DI,width:sp},zy=e=>({stroke:e.stroke,...e.fill!==null?{fill:e.fill}:{},...e.opacity!==1?{opacity:e.opacity}:{}}),eR=(e,t)=>e<=0?RI:Math.max(.5,e*t),tR=(e,t,n=sp)=>({points:[{x:0,y:0,width:eR(t,n)}],origin:e}),nR=(e,t,n,o=sp)=>{let a=e.origin;e.points.push({x:t.x-a.x,y:t.y-a.y,width:eR(n,o)})},mS=(e,t=PI)=>Ay(e,t,(n,o,a,r)=>({x:a.x,y:a.y,width:n.width+(o.width-n.width)*r})),Cq=(e,t)=>{if(t.fill===void 0||e.length<3)return!1;let n=e[0],o=e[e.length-1];if(!n||!o)return!1;let a=o.x-n.x,r=o.y-n.y;return a*a+r*r<=v2*v2},oR=(e,t,n,o,a=zy(Nc))=>{if(!t||t.points.length===0)return null;let r=Ae([...e.elements.values()].filter(c=>c.layerId===n).map(c=>c.order)),s=mS(t.points),i={id:o,layerId:n,type:"brush",position:t.origin,rotation:0,scale:{x:1,y:1},order:r,style:a,points:s,...Cq(s,a)?{closed:!0}:{}},l=Fe(e,i);return{scene:l.scene,patch:l.patch,elementId:o}},yS=e=>Ze(`brush-${e}-${Date.now().toString(36)}`);var aR=(e,t,n,o)=>{if(n.x===0&&n.y===0)return null;let a=e,r=[],s=0;for(let i of t){let l=I(a,i);if(!l||o(l.layerId))continue;let c=J(a,i,u=>({...u,position:{x:u.position.x+n.x,y:u.position.y+n.y}}));a=c.scene,r.push(c.patch),s++}return s===0?null:{scene:a,patches:r,moved:s}},Fy=(e,t,n)=>{if(t.size===0&&n.size===0)return null;let o=e,a=[],r=new Set,s=i=>{if(r.has(i)||!o.links.has(i))return;let l=pi(o,i);o=l.scene,a.push(l.patch),r.add(i)};for(let i of t){for(let c of[...o.links.values()])(c.from.kind!=="point"&&c.from.elementId===i||c.to.kind!=="point"&&c.to.elementId===i)&&s(c.id);let l=dn(o,i);o=l.scene,a.push(l.patch)}for(let i of n)s(i);return{scene:o,patches:a}},rR=(e,t,n)=>{let o=[...t];if(o.length===0)return null;let a=e,r=[],s=[];for(let i of o){let l=I(a,i);if(!l)continue;let c=Ze(`shape-${n()}-${Date.now().toString(36)}`),u=Ae([...a.elements.values()].filter(p=>p.layerId===l.layerId).map(p=>p.order)),d={...l,id:c,position:{x:l.position.x+10,y:l.position.y+10},order:u},f=Fe(a,d);a=f.scene,r.push(f.patch),s.push(c)}return{scene:a,patches:r,newIds:s}},sR=(e,t,n)=>{let o=Pe;for(let a of t)e.elements.has(a)&&(o=Xt(o,a));return oi(o,n)?null:o},iR=(e,t)=>{let n=Pe;for(let o of e.elements.values()){let a=e.layers.get(o.layerId);!a||!a.visible||a.locked||(n=Xt(n,o.id))}return oi(n,t)?null:n},lR=e=>{let t=new Set;for(let n of e.links.values()){let o=e.layers.get(n.layerId);!o||!o.visible||o.locked||t.add(n.id)}return t},cR=(e,t,n)=>{let o=[];for(let i of t)e.elements.has(i)&&o.push(i);if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=J(a,i,c=>({...c,style:{...c.style,...n}}));a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},uR=(e,t,n,o,a)=>{let r=I(e,t);if(r===void 0||!fe(r))return null;let s=uA(r,n,o,a);if(s===r)return null;let i=J(e,t,()=>s);return{scene:i.scene,patch:i.patch}},dR=(e,t,n)=>{let o=[];for(let i of t){let l=I(e,i);l!==void 0&&fe(l)&&o.push(i)}if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=J(a,i,c=>({...c,...n}));a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},fR=(e,t,n)=>{let o=n==="increase",a=o?k2:1/k2,r=e,s=[];for(let l of t){let c=I(r,l);if(c===void 0||!fe(c))continue;let u=Math.round(c.fontSize*a),d=o?Math.max(c.fontSize+1,u):Math.min(c.fontSize-1,u),f=Math.min(s4,Math.max(Y0,d));if(f===c.fontSize)continue;let p=J(r,l,h=>({...h,fontSize:f}));r=p.scene,s.push(p.patch)}let i=s[0];return i===void 0?null:{scene:r,patch:s.length===1?i:{kind:"batch",patches:s}}},pR=(e,t)=>{let n=[];return e.x>0?n.push(`${e.x} px right`):e.x<0&&n.push(`${-e.x} px left`),e.y>0?n.push(`${e.y} px down`):e.y<0&&n.push(`${-e.y} px up`),`Moved ${t===1?"shape":`${t} shapes`} ${n.join(" and ")}`},gS=e=>{let t=Pe;for(let n of e)t=Xt(t,n);return t},xS=(e,t,n,o,a)=>{let r=n==="left"?{x:-1,y:0}:n==="right"?{x:1,y:0}:n==="up"?{x:0,y:-1}:{x:0,y:1},s=null,i=1/0;for(let l of e.elements.values()){if(l.parentId!==void 0||t.has(l.id)||!a(l))continue;let c=z(l),u=c.x+c.width/2-o.x,d=c.y+c.height/2-o.y,f=u*r.x+d*r.y;if(f<=0)continue;let p=Math.abs(u*r.y-d*r.x);if(p>f)continue;let h=f+p;h<i&&(i=h,s=l.id)}return s};var hR=(e,t=!1)=>({pending:new Set,last:e,erased:new Map,strokeMode:t}),mR=(e,t,n,o,a=!1,r=!1)=>{let s=t.x-e.x,i=t.y-e.y,l=Math.hypot(s,i),c=Math.max(1,Math.ceil(l/BI)),u=!1;for(let d=1;d<=c;d++){let f=d/c,p=n({x:e.x+s*f,y:e.y+i*f});p&&(r&&p.type==="brush"||(a?o.delete(p.id)&&(u=!0):o.has(p.id)||(o.add(p.id),u=!0)))}return u},yR=(e,t)=>{let n=Pe;for(let o of t)e.elements.has(o)&&(n=Xt(n,o));return n.size===0?null:Fy(e,n,new Set)};var bS=1e-6,AS=e=>{let t=e.points,n=t.length,o=new Array(Math.max(1,n)).fill(0),a=0;for(let r=1;r<n;r++){let s=v(t[r-1]),i=v(t[r]);a+=Math.hypot(i.x-s.x,i.y-s.y),o[r]=a}return{pts:t,position:e.position,cum:o,total:a}},Hy=(e,t)=>{let{pts:n,cum:o,total:a}=e,r=n.length;if(r===0)return{x:0,y:0,width:0};if(r===1||t<=0)return{...v(n[0])};if(t>=a)return{...v(n[r-1])};let s=0,i=r-1;for(;i-s>1;){let f=s+i>>1;v(o[f])<=t?s=f:i=f}let l=v(n[s]),c=v(n[s+1]),u=v(o[s+1])-v(o[s]),d=u>0?(t-v(o[s]))/u:0;return{x:l.x+(c.x-l.x)*d,y:l.y+(c.y-l.y)*d,width:l.width+(c.width-l.width)*d}},xR=(e,t,n,o)=>{let a=Hy(e,t);return za.distanceToSegmentSq({x:e.position.x+a.x,y:e.position.y+a.y},n,o)},gR=(e,t,n,o,a,r)=>{let s=t,i=n;for(let l=0;l<HI;l++){let c=(s+i)/2;xR(e,c,o,a)<=r?i=c:s=c}return i},bR=(e,t,n,o)=>{let{pts:a,cum:r,total:s}=e,i=a.length;if(i===0)return[];let l=o*o;if(s===0){let y=v(a[0]);return za.distanceToSegmentSq({x:e.position.x+y.x,y:e.position.y+y.y},t,n)<=l?[[0,0]]:[]}let c=Math.min(t.x,n.x)-o,u=Math.max(t.x,n.x)+o,d=Math.min(t.y,n.y)-o,f=Math.max(t.y,n.y)+o,p=e.position.x,h=e.position.y,m=Math.max(FI,o*zI),x=[];for(let y=0;y<i-1;y++){let g=v(a[y]),b=v(a[y+1]);if(Math.max(g.x,b.x)+p<c||Math.min(g.x,b.x)+p>u||Math.max(g.y,b.y)+h<d||Math.min(g.y,b.y)+h>f)continue;let A=v(r[y]),_=v(r[y+1])-A;if(_<=0)continue;let T=Math.max(1,Math.ceil(_/m)),w=-1,S=A;for(let L=0;L<=T;L++){let M=L===T?A+_:A+_*L/T,B=xR(e,M,t,n)<=l;B&&w<0?w=L===0?M:gR(e,S,M,t,n,l):!B&&w>=0&&(x.push([w,gR(e,M,S,t,n,l)]),w=-1),S=M}w>=0&&x.push([w,A+_])}return Fp(x)},Fp=e=>{if(e.length<=1)return e.map(o=>[o[0],o[1]]);let t=[...e].sort((o,a)=>o[0]-a[0]),n=[];for(let[o,a]of t){let r=n[n.length-1];r&&o<=r[1]+bS?a>r[1]&&(r[1]=a):n.push([o,a])}return n},vS=e=>e.reduce((t,[n,o])=>t+(o-n),0),AR=(e,t)=>{let n=Fp(e),o=[],a=0;for(let[r,s]of n)r>a+bS&&o.push([a,r]),s>a&&(a=s);return t>a+bS&&o.push([a,t]),o};var vR=1e-6,SR=(e,t,n)=>{let o=AS(e);if(o.total===0)return[];let a=AR(t,o.total),r=[],s=e.order,i=0;for(let[l,c]of a){if(c-l<UI)continue;let u=[Hy(o,l)];for(let m=0;m<o.pts.length;m++){let x=v(o.cum[m]);x>l+vR&&x<c-vR&&u.push({...v(o.pts[m])})}if(u.push(Hy(o,c)),u.length<2)continue;let d=v(u[0]),f={x:e.position.x+d.x,y:e.position.y+d.y},p=u.map(m=>({x:m.x-d.x,y:m.y-d.y,width:m.width})),h=i===0?e.order:fc(s,null);s=h,i++,r.push({id:n(),layerId:e.layerId,type:"brush",position:f,rotation:0,scale:{x:1,y:1},order:h,style:e.style,points:p})}return r},LR=(e,t,n,o,a)=>{let r=bR(AS(e),n,o,a);return r.length===0?t.length>0?Fp(t):[]:Fp([...t,...r])};var kR=(e,t,n)=>{let o=e,a=[],r=[],s=[],i=new Set;for(let[l,c]of t){if(c.length===0)continue;let u=e.elements.get(l);if(u===void 0||!Ha(u))continue;let d=SR(u,c,n);for(let p of[...o.links.values()])if(!i.has(p.id)&&(si(p.from)===u.id||si(p.to)===u.id)){let h=pi(o,p.id);o=h.scene,a.push(h.patch),i.add(p.id)}let f=dn(o,u.id);o=f.scene,a.push(f.patch),r.push(u.id);for(let p of d){let h=Fe(o,p);o=h.scene,a.push(h.patch),s.push(p.id)}}return a.length===0?null:{scene:o,patches:a,removedIds:r,addedIds:s}},wR=(e,t)=>{let n=[],o=new Set;for(let[a,r]of t){if(r.length===0)continue;let s=e.elements.get(a);if(s===void 0||!Ha(s))continue;let i=0,l=SR(s,r,()=>Ze(`stroke-erase-preview-${s.id}-${i++}`));o.add(s.id),n.push(...l)}return o.size===0?null:{fragments:n,hidden:o}};var _R=e=>{let t=e.metadata,n=t&&"image"in t?t.image:void 0,o=e.animationData,a={...e};if(o!==void 0&&delete a.animationData,t){let s={...t};delete s.image,a.metadata=s}let r=structuredClone(a);return n!==void 0&&(r.metadata={...r.metadata,image:n}),o!==void 0&&(r.animationData=o),r},CR=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(_R(a))}return n},ER=(e,t,n,o,a)=>{if(n.length===0)return{scene:e,newIds:[]};let r=0,s=0;for(let f of n)r+=f.position.x,s+=f.position.y;r/=n.length,s/=n.length;let i=o?{x:o.x-r,y:o.y-s}:{x:10,y:10},l=[],c=[],u=e;for(let f of n){let p=a(),h=Ae([...u.elements.values()].filter(y=>y.layerId===f.layerId).map(y=>y.order)),m={..._R(f),id:p,position:{x:f.position.x+i.x,y:f.position.y+i.y},order:h},x=Fe(u,m);u=x.scene,l.push(x.patch),c.push(p)}let d=l[0];return d!==void 0&&t.push(l.length===1?d:Vo(l)),{scene:u,newIds:c}};var TR=(e,t)=>CR(e,t),IR=(e,t,n,o,a)=>{let r=ER(e,t,n,o,()=>Ze(`shape-${a()}-${Date.now().toString(36)}`));return{scene:r.scene,newIds:r.newIds}},MR=e=>{let t=Pe;for(let n of e)t=Xt(t,n);return t};var RR=(e,t,n)=>{let o=Ae([...e.layers.values()].map(s=>s.order)),r=XA(e,{id:n,name:t,visible:!0,locked:!1,order:o});return{scene:r.scene,patch:r.patch,layerId:n}},OR=(e,t,n)=>{if(!e.layers.has(t))return null;if(e.layers.size<=1)throw new Error("Cannot remove the only remaining layer.");let o=[],a=e;for(let i of[...a.elements.values()]){if(i.layerId!==t)continue;let l=dn(a,i.id);a=l.scene,o.push(l.patch)}for(let i of[...a.links.values()]){if(i.layerId!==t)continue;let l=pi(a,i.id);a=l.scene,o.push(l.patch)}let r=YA(a,t);a=r.scene,o.push(r.patch);let s=n;if(n===t){let i=[...a.layers.values()].sort(Pf)[0];i&&(s=i.id)}return{scene:a,patches:o,nextActiveLayerId:s}},DR=(e,t,n)=>{let o=e.layers.get(t);if(!o||o.name===n)return null;let a=$f(e,t,r=>({...r,name:n}));return{scene:a.scene,patch:a.patch}},PR=(e,t)=>{if(!e.layers.has(t))return null;let n=$f(e,t,o=>({...o,visible:!o.visible}));return{scene:n.scene,patch:n.patch}},BR=(e,t)=>{if(!e.layers.has(t))return null;let n=$f(e,t,o=>({...o,locked:!o.locked}));return{scene:n.scene,patch:n.patch}},NR=(e,t,n)=>{if(!e.layers.has(n)||t.size===0)return null;let o=e,a=[];for(let r of t){let s=I(o,r);if(!s||s.layerId===n)continue;let i=J(o,r,l=>({...l,layerId:n}));o=i.scene,a.push(i.patch)}return a.length===0?null:{scene:o,patches:a}},zR=e=>ln(`layer-${e}-${Date.now().toString(36)}`);var FR=(e,t,n,o)=>{let a=new Date().toISOString(),r=Cf(o("ann")),s=[];t.firstComment?.trim()&&s.push({id:oc(o("cmt")),authorId:n.id,authorName:n.name,body:t.firstComment.trim(),createdAt:a});let i={id:r,elementId:t.elementId??null,position:t.position,resolved:!1,thread:s,createdAt:a},l=KA(e,i);return{scene:l.scene,patch:l.patch,id:r}},HR=(e,t)=>{if(!e.annotations.has(t))return null;let n=$A(e,t);return{scene:n.scene,patch:n.patch}},UR=(e,t)=>{let n=e.annotations.get(t);if(!n)return null;let o=qa(e,t,a=>({...a,resolved:!a.resolved}));return{scene:o.scene,patch:o.patch,wasResolved:n.resolved}},GR=(e,t,n,o,a)=>{let r=n.trim();if(!r||!e.annotations.has(t))return null;let s={id:oc(a("cmt")),authorId:o.id,authorName:o.name,body:r,createdAt:new Date().toISOString()},i=qa(e,t,l=>({...l,thread:[...l.thread,s]}));return{scene:i.scene,patch:i.patch}},WR=(e,t,n)=>{if(!e.annotations.get(t)?.thread.some(r=>r.id===n))return null;let a=qa(e,t,r=>({...r,thread:r.thread.filter(s=>s.id!==n)}));return{scene:a.scene,patch:a.patch}},qR=(e,t)=>{let n=e.viewport.zoom,o=j0/n,a=[...e.annotations.values()];for(let r=a.length-1;r>=0;r--){let s=a[r];if(s===void 0)continue;let i=Kr(e,s),l=t.x-i.x,c=t.y-i.y;if(l*l+c*c<=o*o)return s.id}return null};var jR=(e,t)=>{let n=null,o="";for(let a of e.elements.values()){if(!Be(a))continue;let r=a.position.x,s=a.width*a.scale.x,i=24*a.scale.y,l=a.position.y-i;t.x>=r&&t.x<=r+s&&t.y>=l&&t.y<=l+i&&(n===null||a.order>o)&&(n=a.id,o=a.order)}return n},VR=(e,t,n)=>{let o=I(e,t);if(o===void 0||!Be(o))return null;let a=n.trim(),r=o.name??"";if(a===r)return null;let s=J(e,t,i=>{let l={...i};return a===""?delete l.name:l.name=a,l});return{scene:s.scene,patch:s.patch}};var Eq={nw:"resize-nwse",se:"resize-nwse",ne:"resize-nesw",sw:"resize-nesw",n:"resize-ns",s:"resize-ns",e:"resize-ew",w:"resize-ew"},Tq=(e,t)=>{if(typeof e=="string")return e;let n=e.hotspot?.x??0,o=e.hotspot?.y??0;return`${e.url2x!==void 0?`image-set(url("${e.url}") 1x, url("${e.url2x}") 2x)`:`url("${e.url}")`} ${String(n)} ${String(o)}, ${e.fallback??t}`},Iq=(e,t,n)=>{let o=e.getCursorOverride(t);return o===void 0?n:Tq(o,n)},Mq=(e,t)=>{if(e.mode!=="select"||e._selection.size!==1)return!1;let n=[...e._selection][0];if(n===void 0)return!1;let o=I(e._scene,n);if(!o)return!1;let a=e._scene.viewport.zoom||1,{worldPoints:r}=_o(o,Lo/a),s=(Xo+e.anchorStartHitSlop)/a,i=s*s;for(let l of r){let c=l.x-t.x,u=l.y-t.y;if(c*c+u*u<=i)return!0}return!1},ZR=(e,t)=>{let n=(a,r)=>Iq(e,a,r),o=a=>n(Eq[a],x4(a));if(e.panGesture)return n("pan-active","grabbing");if(e.linkDragFromAnchor?.moved===!0)return n("draw","crosshair");if(e.isDraggingWaypoint||e.isDraggingSegment||e.annotationDrag?.moved===!0)return n("move","grabbing");if(e.brushStroke)return n("draw","crosshair");if(e.gestureTx){let a=e.actor.getSnapshot().context.pressTarget;if(a&&(a.kind==="handle"||a.kind==="group-handle"))return o(a.handle);if(a?.kind==="rotate-handle")return n("rotate","grabbing");if(a&&(a.kind==="element"||a.kind==="link"||a.kind==="edge-endpoint"))return n("move","grabbing")}if(e.isEyedropperArmed)return n("draw","crosshair");if(e.editingTextElement!==null)return n("text","text");if(e.spaceHeld||e.mode==="hand")return n("pan-ready","grab");switch(e.mode){case"draw-rect":case"draw-ellipse":case"draw-frame":case"draw-edge":case"brush":case"laser":case"eyedropper":case"crop":return n("draw","crosshair");case"erase":return n("erase","none");case"draw-text":return n("text","text");default:break}if(t){if(Mq(e,t))return n("link-start","crosshair");let a=e.hitTest(t);switch(a.kind){case"handle":case"group-handle":return o(a.handle);case"rotate-handle":return n("rotate","grab");case"edge-endpoint":return n("link-handle","grab");case"annotation":return n("annotation","pointer");default:return n("default","default")}}return n("default","default")};var Uy=(e,t,n)=>{let o=t??(n.size===1?[...n][0]??null:null);return o&&e.elements.has(o)?o:null},YR=(e,t,n)=>{let o=Uy(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=Ae([...e.elements.values()].filter(i=>i.layerId===a.layerId&&i.id!==a.id).map(i=>i.order));if(r===a.order)return null;let s=J(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},KR=(e,t,n)=>{let o=Uy(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=dc([...e.elements.values()].filter(i=>i.layerId===a.layerId&&i.id!==a.id).map(i=>i.order));if(r===a.order)return null;let s=J(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},$R=(e,t,n)=>{let o=Uy(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=[...e.elements.values()].filter(u=>u.layerId===a.layerId&&u.id!==a.id).sort(_t),s=r.find(u=>u.order>a.order)??null;if(!s)return null;let i=r.find(u=>u.order>s.order)??null,l=i?fc(s.order,i.order):Ae(r.map(u=>u.order));if(l===a.order)return null;let c=J(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},QR=(e,t,n)=>{let o=Uy(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=[...e.elements.values()].filter(u=>u.layerId===a.layerId&&u.id!==a.id).sort(Pf),s=r.find(u=>u.order<a.order)??null;if(!s)return null;let i=r.find(u=>u.order<s.order)??null,l=i?fc(i.order,s.order):dc(r.map(u=>u.order));if(l===a.order)return null;let c=J(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},XR=(e,t)=>{if(e.length===0)return 0;let n=[...e].sort(_t),o=qA(null,null,n.length),a=0;return n.forEach((r,s)=>{let i=o[s];i===void 0||i===r.order||(t(r,i),a++)}),a},JR=(e,t,n)=>{let o=e,a=0;for(let r of t)a+=XR([...o.elements.values()].filter(s=>s.layerId===r),(s,i)=>{let l=J(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)}),a+=XR([...o.links.values()].filter(s=>s.layerId===r),(s,i)=>{let l=et(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)});return a};var eO=(e,t,n,o)=>{let a=[...t];if(a.length<2)return null;let r=Math.max(1,n.cols??Math.ceil(Math.sqrt(a.length))),s=n.gap??16,i=P0(e,{shapeIds:a,origin:o,cols:r,gap:s});return i?{scene:Q(e,i),patch:i,count:a.length,cols:r}:null},tO=(e,t,n,o)=>{let a=[...t];if(a.length<2)return null;let r=n.direction??"horizontal",s=n.gap??16,i=B0(e,{shapeIds:a,origin:o,direction:r,gap:s});return i?{scene:Q(e,i),patch:i,count:a.length,direction:r}:null},SS=(e,t)=>{let n=[],o=new Set;for(let a of t){let r=I(e,a);if(!r)continue;let s=r,i=!1;for(let l=0;s?.parentId&&l<64;l++){if(t.has(s.parentId)){i=!0;break}s=I(e,s.parentId)}i||o.has(r.id)||(o.add(r.id),n.push(r))}return n},nO=(e,t)=>{let n=new Set,o=a=>{if(!(n.has(a)||!I(e,a))){n.add(a);for(let s of e.elements.values())s.parentId===a&&o(s.id)}};for(let a of t)o(a);return n},oO=(e,t,n)=>{let o=SS(e,t),a=o[0];if(o.length<2||a===void 0)return null;let r=a.layerId,s=Ae([...e.elements.values()].filter(d=>d.layerId===r).map(d=>d.order)),i={id:n,layerId:r,type:"group",position:{x:0,y:0},rotation:0,scale:{x:1,y:1},order:s,style:{}},l=e,c=[],u=Fe(l,i);l=u.scene,c.push(u.patch);for(let d of o){let f=J(l,d.id,p=>({...p,parentId:n}));l=f.scene,c.push(f.patch)}return{scene:l,patches:c,groupId:n}},aO=(e,t)=>{let n=[...t].map(s=>I(e,s)).filter(s=>s!==void 0&&ze(s));if(n.length===0)return null;let o=e,a=[],r=new Set;for(let s of n){let i=[...o.elements.values()].filter(c=>c.parentId===s.id);for(let c of i){let u=J(o,c.id,d=>{let f={...d};return delete f.parentId,f});o=u.scene,a.push(u.patch),r.add(c.id)}let l=dn(o,s.id);o=l.scene,a.push(l.patch)}return{scene:o,patches:a,nextSelection:r}},rO=(e,t,n)=>{let o=[...e.layers.values()].filter(l=>l.visible&&!l.locked).sort(_t),a=[];for(let l of o){let c=[...e.elements.values()].filter(u=>u.layerId===l.id).sort(_t);for(let u of c)a.push(u.id)}if(a.length===0)return null;let r=t?a.indexOf(t):-1;n==="next"?r=r===-1?0:(r+1)%a.length:r=r===-1?a.length-1:(r-1+a.length)%a.length;let s=a[r];if(!s)return null;let i=I(e,s);return{id:s,name:i?JA(i):s}},sO=e=>Ze(`group-${e}-${Date.now().toString(36)}`);var iO=/^(https?:|mailto:)/i,Rq=/^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/,lO=e=>{let t=e.trim();return t===""?null:iO.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t)?null:Rq.test(t)?`mailto:${t}`:`https://${t}`},Gy=e=>e&&iO.test(e.trim())?e.trim():null,cO=(e,t,n)=>{let o=[];for(let i of t){let l=I(e,i);l&&(l.href??null)!==n&&o.push(i)}if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=J(a,i,c=>{let u={...c};return n===null?delete u.href:u.href=n,u});a=l.scene,r.push(l.patch)}let s=r[0];return{scene:a,patch:r.length===1&&s!==void 0?s:{kind:"batch",patches:r}}},Oq=(e,t,n)=>{if(t.kind==="anchor"){let o=t.metadata?.ref;if(o)return{kind:"anchor",elementId:e,anchor:o}}return t.kind==="outline"&&typeof t.metadata?.ratio=="number"?{kind:"outline",elementId:e,ratio:t.metadata.ratio}:{kind:"point",position:t.snapped}},uO=(e,t,n,o,a)=>{let r=t.snap({scene:e,probe:a,threshold:n,gesture:"draw-edge"}),s=u=>{if(o!==null){let d=r.all.find(f=>f.kind===u&&f.metadata?.elementId===o);if(d)return d}return r.all.find(d=>d.kind===u)},i=(u,d)=>{if(!u)return null;let f=u.metadata?.elementId;if(f===void 0)return null;let p=I(e,f);if(!p)return null;let h=Oq(f,u,p);return h.kind===d?h:null},l=i(s("anchor"),"anchor");if(l)return l;let c=i(s("outline"),"outline");return c||(o!==null&&I(e,o)?{kind:"floating",elementId:o}:{kind:"point",position:a})};var Dq=ns.rectangle,Pq=ns.ellipse,LS=(e,t,n,o,a,r)=>{let s=Array.from(e.elements.values()).filter(c=>c.layerId===a).map(c=>c.order),i=t==="frame"?dc(s):Ae(s),l={id:o,layerId:a,position:{x:n.x,y:n.y},rotation:0,scale:{x:1,y:1},order:i,width:n.width,height:n.height};return t==="rect"?{...l,type:"rectangle",style:{...Dq}}:t==="ellipse"?{...l,type:"ellipse",style:{...Pq}}:{...l,type:"frame",style:{fill:eI},name:r()}},dO=(e,t,n,o,a)=>{let r=Ae(Array.from(e.links.values()).filter(s=>s.layerId===a).map(s=>s.order));return{id:o,layerId:a,from:t,to:n,order:r,routing:hi,style:{...Mc},arrowheads:{to:np}}},fO=(e,t,n,o)=>{let a=dO(e,{kind:"point",position:t.from},{kind:"point",position:t.to},n,o);return t.points&&t.points.length>2?{...a,routedPoints:t.points.slice(1,-1)}:a},pO=(e,t,n,o,a,r)=>{let s=LS(e,t,n,o,a,r),i=Fe(e,s);return{scene:i.scene,patch:i.patch,elementId:o}},Hp=(e,t,n,o,a)=>{let r=dO(e,t,n,o,a),s=fi(e,r);return{scene:s.scene,patch:s.patch,linkId:o}},zc=e=>`shape-${e}-${Date.now().toString(36)}`,Up=e=>`edge-${e}-${Date.now().toString(36)}`;var hO=(e,t,n,o,a)=>{let r=Ae([...e.elements.values()].filter(c=>c.layerId===o).map(c=>c.order)),s=t==="draw-ellipse"?"ellipse":"rectangle",i=120,l=80;return{id:a,layerId:o,type:s,position:{x:n.x-i/2,y:n.y-l/2},rotation:0,scale:{x:1,y:1},order:r,style:{fill:"#bbb",stroke:"#000",strokeWidth:1},width:i,height:l}},mO=(e,t,n,o)=>{let a=Ae([...e.elements.values()].filter(r=>r.layerId===n).map(r=>r.order));return{id:o,layerId:n,type:"text",position:{x:t.x,y:t.y},rotation:0,scale:{x:1,y:1},order:a,text:"",fontFamily:KI,fontSize:YI,style:{fill:$I,textAlign:"left",textBaseline:"top"}}},wS=e=>Ze(`shape-${e}-${Date.now().toString(36)}`),yO=(e,t,n)=>{let o={...t.current,position:{x:n.x-t.halfWidth,y:n.y-t.halfHeight}},a={kind:"element",id:t.current.id,before:t.current,after:o};return{scene:Q(e,a),patch:a,next:o}},gO=(e,t)=>{let n={x:t.current.position.x+t.halfWidth,y:t.current.position.y+t.halfHeight},o=zf(e,n,new Set([t.current.id]));if(!o)return null;let a={...t.current,parentId:o.id},r={kind:"element",id:t.current.id,before:t.current,after:a};return{scene:Q(e,r),patch:r,next:a}},xO=e=>{let t=z(e);return{scene:n=>{let o=Fe(n,e);return{scene:o.scene,patch:o.patch}},state:{current:e,halfWidth:t.width/2,halfHeight:t.height/2}}},bO=(e,t)=>({scene:dn(e,t).scene}),kS="__ghost-preview__",Fc="__ghost-preview-link__",AO=(e,t,n,o)=>{let a=I(e,n);if(!a||Ha(a))return null;let r={kind:"named",name:o},s=jo(a,r),i=z(a),l=Math.abs(s.x)*i.width+Math.abs(s.y)*i.height,c=l+l2,u={x:s.x*c,y:s.y*c},d={x:i.x+u.x,y:i.y+u.y,width:i.width,height:i.height},f=Yt(a,r),p=d.x+d.width/2,h=d.y+d.height/2,m={x:p-s.x*(l/2),y:h-s.y*(l/2)},x={...a,id:kS,position:{x:a.position.x+u.x,y:a.position.y+u.y}};fe(x)?x={...x,text:""}:Be(x)&&(x={...x,name:""});let y={x:i.x+i.width/2,y:i.y+i.height/2},g=Fe(e,x).scene,b=v(I(g,kS)),{ref:A}=Ga(b,y,So(b)),T=Hp(g,{kind:"anchor",elementId:n,anchor:r},{kind:"anchor",elementId:kS,anchor:A},Fc,t).scene,w=v(be(T,Fc));if((w.routing??"straight")==="orthogonal"){let S=tp(T,w);T=et(T,Fc,L=>({...L,routedPoints:S})).scene}return T={...T,links:new Map([[Fc,v(be(T,Fc))]])},{bounds:d,path:[f,m],element:x,ghostScene:T,ghostLinkId:Fc}},vO=(e,t,n,o,a,r)=>{let s=I(e,n);if(!s||Ha(s))return null;let i={kind:"named",name:o},l=jo(s,i),c=z(s),u={x:c.x+c.width/2,y:c.y+c.height/2},f=Math.abs(l.x)*c.width+Math.abs(l.y)*c.height+l2,p={x:l.x*f,y:l.y*f},h=Ae([...e.elements.values()].filter(A=>A.layerId===s.layerId).map(A=>A.order)),m={...s,id:a,position:{x:s.position.x+p.x,y:s.position.y+p.y},order:h};fe(m)?m={...m,text:""}:Be(m)&&(m={...m,name:""});let x=Fe(e,m),y=v(I(x.scene,a)),{ref:g}=Ga(y,u,So(y)),b=Hp(x.scene,{kind:"anchor",elementId:n,anchor:i},{kind:"anchor",elementId:a,anchor:g},r,t);return{scene:b.scene,addPatch:x.patch,linkPatch:b.patch}},SO=(e,t,n)=>{let o=e,a=[];for(let r of t){let s=I(o,r);if(!s)continue;let i=n.get(r);if(i===void 0)continue;let l=Ae([...o.elements.values()].filter(d=>d.layerId===s.layerId).map(d=>d.order)),c={...s,id:i,order:l};if(c.parentId!==void 0){let d=n.get(c.parentId);d!==void 0&&(c.parentId=d)}if(c.frameId!==void 0){let d=n.get(c.frameId);d!==void 0&&(c.frameId=d)}let u=Fe(o,c);o=u.scene,a.push(u.patch)}return{scene:o,patches:a}},LO=(e,t,n,o,a)=>{let r=Ae([...e.elements.values()].filter(d=>d.layerId===t).map(d=>d.order)),s=a({id:o,layerId:t,position:n.world,order:r}),i=z(s),l={...s,position:{x:s.position.x+(n.world.x-(i.x+i.width/2)),y:s.position.y+(n.world.y-(i.y+i.height/2))}},c=Fe(e,l),u=et(c.scene,n.linkId,d=>({...d,[n.side]:{kind:"floating",elementId:o}}));return{scene:u.scene,addPatch:c.patch,linkPatch:u.patch}};var _S=(e,t,n="fill")=>{let o=ci(e,t);if(o===void 0)return null;let{fill:a,stroke:r}=o.style;return(n==="fill"?a:r)??(n==="fill"?r:a)??null},Bq=new Set(["rectangle","ellipse","polygon"]),Nq=(e,t)=>[{x:e/2,y:0},{x:e,y:t/2},{x:e/2,y:t},{x:0,y:t/2}],kO=(e,t,n)=>{let o=e,a=[];for(let s of t){let i=I(o,s);if(i===void 0||!Bq.has(i.type)||i.type===n)continue;let l=Re(i),c=l.width,u=l.height,d=J(o,s,f=>{let{width:p,height:h,points:m,...x}=f;return n==="polygon"?{...x,type:"polygon",points:Nq(c,u)}:{...x,type:n,width:c,height:u}});o=d.scene,a.push(d.patch)}let r=a[0];return r===void 0?null:{scene:o,patch:a.length===1?r:{kind:"batch",patches:a}}},wO=e=>{let t=Math.min(Math.max(e.x,0),1),n=Math.min(Math.max(e.y,0),1),o=Math.min(Math.max(e.width,0),1-t),a=Math.min(Math.max(e.height,0),1-n);return{x:t,y:n,width:o,height:a}},zq=(e,t)=>e===void 0||t===void 0?e===t:e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height;var Wy={x:0,y:0,width:1,height:1},_O=["nw","ne","se","sw","n","e","s","w"],Hc=(e,t,n)=>Math.min(Math.max(e,t),n),qy=(e,t)=>{let n=Re(e),o=t.width||1,a=t.height||1,r=n.width/o,s=n.height/a;return{x:n.x-t.x*r,y:n.y-t.y*s,width:r,height:s}},CO=e=>{let t=Re(e),{x:n,y:o,width:a,height:r}=t,s=(i,l)=>Mn(e,{x:i,y:l});return{nw:s(n,o),n:s(n+a/2,o),ne:s(n+a,o),e:s(n+a,o+r/2),se:s(n+a,o+r),s:s(n+a/2,o+r),sw:s(n,o+r),w:s(n,o+r/2)}},Fq=e=>({west:e==="nw"||e==="w"||e==="sw",east:e==="ne"||e==="e"||e==="se",north:e==="nw"||e==="n"||e==="ne",south:e==="sw"||e==="s"||e==="se"}),EO=(e,t,n,o)=>{let a=qy(e,t),r=Re(e),s=li(e,o),i=r.x,l=r.y,c=r.x+r.width,u=r.y+r.height,{west:d,east:f,north:p,south:h}=Fq(n),m=a.x+a.width,x=a.y+a.height;d&&(i=Hc(s.x,a.x,c-ip)),f&&(c=Hc(s.x,i+ip,m)),p&&(l=Hc(s.y,a.y,u-ip)),h&&(u=Hc(s.y,l+ip,x));let y={x:i,y:l,width:c-i,height:u-l};return{crop:wO({x:(y.x-a.x)/a.width,y:(y.y-a.y)/a.height,width:y.width/a.width,height:y.height/a.height}),position:Mn(e,{x:y.x,y:y.y}),width:y.width,height:y.height}},TO=(e,t,n,o)=>{let a=qy(e,t),r=li(e,n),s=li(e,o),i=s.x-r.x,l=s.y-r.y;return{crop:{x:Hc(t.x-i/a.width,0,1-t.width),y:Hc(t.y-l/a.height,0,1-t.height),width:t.width,height:t.height}}},Hq=(e,t=1e-4)=>Math.abs(e.x)<t&&Math.abs(e.y)<t&&Math.abs(e.width-1)<t&&Math.abs(e.height-1)<t,IO=(e,t,n)=>{let o=I(e,t);if(o?.type!=="image")return null;let a=wO(n.crop),r=Hq(a)?void 0:a,s=o.crop;if(zq(r,s)&&o.position.x===n.position.x&&o.position.y===n.position.y&&o.width===n.width&&o.height===n.height)return null;let l=J(e,t,c=>{let{crop:u,...d}=c,f={...d,position:n.position,width:n.width,height:n.height};return r===void 0?f:{...f,crop:r}});return{scene:l.scene,patch:l.patch}},MO=(e,t,n,o,a)=>{let r=I(e,t);if(r===void 0)return null;let s=Re(r),i=s.width*r.scale.x,l=s.height*r.scale.y,c=n==="right"?i+ko:n==="left"?-(i+ko):0,u=n==="down"?l+ko:n==="up"?-(l+ko):0,d=Ae([...e.elements.values()].filter(b=>b.layerId===r.layerId).map(b=>b.order)),{parentId:f,frameId:p,...h}=r,m={...h,id:o,position:{x:r.position.x+c,y:r.position.y+u},order:d},x=Fe(e,m),y={id:a,layerId:r.layerId,from:{kind:"floating",elementId:t},to:{kind:"floating",elementId:o},order:Ae([...x.scene.links.values()].filter(b=>b.layerId===r.layerId).map(b=>b.order)),routing:hi,style:{...Mc},arrowheads:{to:np}},g=fi(x.scene,y);return{scene:g.scene,patches:[x.patch,g.patch],newElementId:o,linkId:a}},RO=(e,t,n,o,a,r)=>{let s=I(e,t);if(s===void 0||o<1)return{elements:[],links:[]};let i=Re(s),l=i.width*s.scale.x,c=i.height*s.scale.y,u=n==="left"||n==="right",d=n==="right"?l+ko:n==="left"?-(l+ko):0,f=n==="down"?c+ko:n==="up"?-(c+ko):0,p=u?c+ko:l+ko,h=Ae([...e.elements.values()].filter(_=>_.layerId===s.layerId).map(_=>_.order)),m=Ae([...e.links.values()].filter(_=>_.layerId===s.layerId).map(_=>_.order)),{parentId:x,frameId:y,...g}=s,b=[],A=[];for(let _=0;_<o;_++){let T=(_-(o-1)/2)*p,w=d+(u?0:T),S=f+(u?T:0),L=a();b.push({...g,id:L,position:{x:s.position.x+w,y:s.position.y+S},order:h}),A.push({id:r(),layerId:s.layerId,from:{kind:"floating",elementId:t},to:{kind:"floating",elementId:L},order:m,routing:hi,style:{...Mc},arrowheads:{to:np}})}return{elements:b,links:A}};var Uq="__draw-preview__",OO="__draw-preview-link__",DO=new WeakMap,Gq=e=>[e.scene,e.selection,e.selectedLinks,e.selectedLink,e.selectedAnnotation,e.mode,e.activeLayerId,e.cropFrame,e.cropGhost,e.flowchartPreview,e.strokeErasePreview,e.lassoPreview,e.drawingPreview,e.edgePreview,e.linkDragFromAnchor,e.hoveredLinkTarget,e.panGesture,e.pinchActive,e.gestureActive,e.linkEndpointDrag,e.linkSegmentDrag,e.linkWaypointDrag,e.hoverCursorWorld,e.anchorStartHitSlop,e.anchorClickRadius,e.containerHover,e.brushStroke,e.laserStrokes,e.eraserTrail,e.eraserCursor,e.peerCursors,e.peerSelections,e.debugHitZones,e.readOnly,e.groupMoveOrigin,e.editingText],Wq=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},PO=e=>{if(e.backgroundTarget){e.gridEnabled?Sp(e.scene,e.backgroundTarget):e.backgroundTarget.clear();let u=[];for(let d of e.selection){let f=I(e.scene,d);if(!f)continue;let p=f.style??{};u.push({loops:Bf(e.scene,f),outsetWorld:lA(p)})}u.length>0&&j5(e.backgroundTarget,oo(e.scene.viewport),u,e.scene.viewport.zoom||1)}let t=e.viewportWorld,n=e.dirtyWorld,o=e.dimElements,a=e.hideElements,r=o!==void 0&&o.size>0||a!==void 0&&a.size>0;if(e.tileComposeFn&&t&&!r)Cv(e.animationClock),e.mainTarget.clear(),e.tileComposeFn(e.scene,e.mainTarget,{viewport:t,changedElements:e.tileDirtyElements,zoomBucket:e.scene.viewport.zoom>0?2**Math.round(Math.log2(e.scene.viewport.zoom)):1,...e.sharedIndex?{index:e.sharedIndex}:{}}),Pn(e.scene,e.mainTarget,{viewportWorld:t});else{let u=e.sharedIndex;Za(e.scene,e.mainTarget,{...t?{viewport:t}:{},...n?{dirtyWorld:n}:{},boundsCache:e.boundsCache,clock:e.animationClock,lod:ev,...o?{dimElements:o,dimOpacity:e.eraseActive?bI:xI}:{},...a?{hideElements:a}:{},...u?{spatialIndex:u}:{}}),Pn(e.scene,e.mainTarget,{...t?{viewportWorld:t}:{},...n?{dirtyWorld:n}:{}})}let s=Gq(e),i=DO.get(e.overlayTarget);if(i===void 0||!Wq(i.sig,s)){let u={};e.readOnly&&(u.readOnly=!0),e.cropFrame&&(u.cropFrame=e.cropFrame),e.cropGhost&&(u.cropGhost=e.cropGhost);let d=null;if(e.lassoPreview)u.drawingPreview=e.lassoPreview;else if(e.drawingPreview){let x=e.mode==="draw-rect"?"rect":e.mode==="draw-ellipse"?"ellipse":null;x?u.drawingPreviewElement=LS(e.scene,x,e.drawingPreview,Uq,e.activeLayerId,()=>""):u.drawingPreview=e.drawingPreview}let f=null;if(e.edgePreview){let x=fO(e.scene,e.edgePreview,OO,e.activeLayerId);f={...e.scene,links:new Map([[OO,x]])}}let p=null;if(e.flowchartPreview&&e.flowchartPreview.elements.length>0){u.flowchartPreviewElements=e.flowchartPreview.elements;let x=new Map(e.scene.elements);for(let g of e.flowchartPreview.elements)x.set(g.id,g);let y=new Map;for(let g of e.flowchartPreview.links)y.set(g.id,g);p={...e.scene,elements:x,links:y}}if(e.strokeErasePreview&&e.strokeErasePreview.elements.length>0&&(u.strokeErasePreviewElements=e.strokeErasePreview.elements),e.mode!=="brush"&&e.mode!=="hand"&&!e.readOnly){let x=e.scene.viewport.zoom||1,y=(A,_,T,w)=>{let S=I(e.scene,A);if(!S)return null;let L=_==="link-start"?Lo:JT,{names:M,worldPoints:B}=_o(S,L/x),W=[...B],ie=T!==null?M.indexOf(T):-1;_==="link-attach"&&w&&W.push(w);let ne=ie>=0?ie:_==="link-attach"&&w?W.length-1:-1;return{worldPoints:W,...ne>=0?{activeIndex:ne}:{},role:_}},g=[];if(e.linkDragFromAnchor){let A=y(e.linkDragFromAnchor.fromElement,"link-start",null);if(A&&g.push(A),e.hoveredLinkTarget){let _=e.hoveredLinkTarget,T=y(_.elementId,"link-attach",_.activeAnchor,_.outlinePoint);T&&g.push(T)}}else if(e.hoveredLinkTarget){let A=e.hoveredLinkTarget,_=y(A.elementId,"link-attach",A.activeAnchor,A.outlinePoint);_&&g.push(_)}else if(!e.panGesture&&!e.pinchActive&&!e.gestureActive&&!e.edgePreview&&!e.linkEndpointDrag){let A=e.hoverCursorWorld;if(e.selection.size===1&&A){let _=v([...e.selection][0]),T=I(e.scene,_);if(T){let w=z(T),S=(Lo+Xo+e.anchorStartHitSlop)/x;if(A.x>=w.x-S&&A.x<=w.x+w.width+S&&A.y>=w.y-S&&A.y<=w.y+w.height+S){let M=y(_,"link-start",null);if(M){let j=tI/x,ve=-1,ye=j*j;if(M.worldPoints.forEach((ee,Se)=>{let Oe=ee.x-A.x,qt=ee.y-A.y,xn=Oe*Oe+qt*qt;xn<=ye&&(ye=xn,ve=Se)}),ve>=0){let ee=j>0?Math.max(0,1-Math.sqrt(ye)/j):0,Se=op+(YT-op)*ee;g.push({...M,activeIndex:ve,activeRadius:Se})}else g.push(M)}let{names:B,worldPoints:W}=_o(T,Lo/x),ie=(e.anchorClickRadius/x)**2,ne=null;for(let j=0;j<W.length;j++){let ve=v(W[j]);if((ve.x-A.x)**2+(ve.y-A.y)**2<=ie){ne=v(B[j]);break}}if(ne){let j=e.previewClickCreate(_,ne);j&&(u.ghostElement=j.bounds,u.ghostElementShape=j.element,d=j.ghostScene)}}}}}g.length===1?u.ports=v(g[0]):g.length>1&&(u.ports=g);let b=e.hoveredLinkTarget;if(b?.mode==="element"){let A=I(e.scene,b.elementId);A&&(u.linkAttachHighlight=z(A))}}if(e.selection.size+e.selectedLinks.size>1||e.aspectLocked){let x=e.combinedSelectionBounds;x&&(u.groupBounds=x),e.aspectLocked&&(u.groupAspectLocked=!0)}if(e.containerHover&&(u.containerDropZone=e.containerHover.dropZone),e.brushStroke&&(u.brushPreview={origin:e.brushStroke.origin,points:e.brushStroke.points,fill:e.brushStroke.fill,opacity:e.brushStroke.opacity}),e.laserStrokes.length>0&&(u.laserStrokes=e.laserStrokes),e.eraserTrail.length>0&&(u.eraserTrail=e.eraserTrail),e.eraserCursor&&(u.eraserCursor=e.eraserCursor),e.selectedLinks.size>0){let x=[];for(let y of e.selectedLinks){let g=be(e.scene,y);if(!g)continue;let b=cc(e.scene,g);b&&b.length>=2&&x.push({path:b,width:g.style.strokeWidth??1})}x.length>0&&(u.selectedLinkPaths=x)}let h=e.selectedLink;if(h){let x=be(e.scene,h);if(x){let y=ot(e.scene,x);if(y&&y.length>=2){let g=v(y[0]),b=v(y[y.length-1]);if((x.routing??"straight")==="orthogonal"){let _=[];if(!e.linkSegmentDrag&&!e.linkEndpointDrag){let T=y.length===2?[0]:Array.from({length:Math.max(0,y.length-3)},(w,S)=>S+1);for(let w of T){let S=v(y[w]),L=v(y[w+1]);_.push({x:(S.x+L.x)/2,y:(S.y+L.y)/2})}}u.edgeSelection={from:g,to:b,midpoints:_}}else{let _=[...x.waypoints??[]],T=e.linkWaypointDrag?[]:Vf(e.scene,x)??[];u.edgeSelection={from:g,to:b,waypoints:_,midpoints:T}}}}}e.peerCursors.length>0&&(u.peerCursors=e.peerCursors),e.peerSelections.length>0&&(u.peerSelections=e.peerSelections),e.scene.annotations.size>0&&(u.annotations=[...e.scene.annotations.values()],u.selectedAnnotation=e.selectedAnnotation);let m=e.editingText;if(m&&(u.editingText=m),e.debugHitZones){u.debugHitZones=!0;let x=e.linkDragFromAnchor!==null||e.edgePreview!==null||e.linkEndpointDrag!==null,y=e.groupMoveOrigin!==null&&e.gestureActive,g=Sy({linkDragActive:x,elementDragActive:y});if(u.debugHitZoneVisibility=g,g.attachDropZones){let b=e.linkDragFromAnchor?.fromElement,A=[],_=[];for(let T of e.scene.elements.values())if(T.id!==b){A.push(..._o(T,0).worldPoints);for(let w of Bf(e.scene,T))_.push(w)}u.debugAttachZones={anchors:A,outlineLoops:_,thresholdWorld:12}}if(g.containerDropZones){let b=e.groupMoveOrigin,A=[],_=[];for(let T of e.scene.elements.values())if(!b?.has(T.id)){if(Be(T)){A.push(z(T));continue}_.push(...SA(T))}u.debugContainerZones={frames:A,containers:_}}}i={sig:s,opts:u,ghostScene:d,edgePreviewScene:f,flowchartPreviewScene:p},DO.set(e.overlayTarget,i)}let l=i.opts,c=[];for(let u of e.scene.elements.values())ct(u)&&u.animationKind&&e.isPlaybackPaused(u.id)&&c.push(z(u));c.length>0?l.gifBadges=c:l.gifBadges!==void 0&&delete l.gifBadges,V5(e.scene,e.selection,e.overlayTarget,l),i.ghostScene&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(q0),Pn(i.ghostScene,e.overlayTarget,{}),e.overlayTarget.restore()),i.edgePreviewScene&&Pn(i.edgePreviewScene,e.overlayTarget,{}),i.flowchartPreviewScene&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(K0),Pn(i.flowchartPreviewScene,e.overlayTarget,{}),e.overlayTarget.restore())};var jy=class{onTick;_on=!0;timer=null;constructor(t){this.onTick=t}get on(){return this._on}start(){this._on=!0,this.stop(),!(typeof window>"u")&&(this.timer=setInterval(()=>{this._on=!this._on,this.onTick()},t4))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}wake(){this._on=!0}};var BO=(e,t,n)=>{let o=I(e,t);return!(o===void 0||!fe(o)||n(o.layerId))};var Vy=class{host;_editingElement=null;_pendingCreate=null;_origin=null;_sel=null;_dragAnchor=null;caretBlink;constructor(t){this.host=t,this.caretBlink=new jy(()=>{this.host.notify()})}get editingElement(){return this._editingElement}get selection(){return this._sel}get caret(){return this._sel?this._sel.dir==="backward"?this._sel.start:this._sel.end:null}get caretBlinkOn(){return this.caretBlink.on}get isDragging(){return this._dragAnchor!==null}markPendingCreate(t){this._pendingCreate=t}begin(t){if(!BO(this.host.scene,t,a=>this.host.isLayerLocked(a)))return;this._editingElement!==null&&this._editingElement!==t&&this.commit(),this._editingElement=t,this._origin=this._pendingCreate===t?null:I(this.host.scene,t)??null;let n=I(this.host.scene,t),o=n!==void 0&&fe(n)?n.text.length:0;this._sel={start:o,end:o,dir:"forward"},this.caretBlink.start(),this.host.notify()}setText(t,n,o,a="forward"){let r=this._editingElement;if(!r)return;let s=J(this.host.scene,r,i=>({...i,text:t}));this.host.scene=s.scene,this._sel={start:n,end:o,dir:a},this.caretBlink.wake(),this.host.notify()}setSelection(t,n,o="forward"){this._editingElement&&(this._sel={start:t,end:n,dir:o},this.caretBlink.wake(),this.host.notify())}caretIndexAtWorldPoint(t){let n=this._editingElement;if(!n)return null;let o=I(this.host.scene,n);if(o===void 0||!fe(o))return null;let a=this.editingTextLayout(o);if(!a)return null;let r=o.scale.x||1,s=o.scale.y||1,i={x:(t.x-o.position.x)/r,y:(t.y-o.position.y)/s},l=o.style.textAlign??"left";return Sv(a,i,this.measureFor(o),l)}editedElementContainsPoint(t){let n=this._editingElement;if(!n)return!1;let o=I(this.host.scene,n);if(!o)return!1;let a=z(o);return t.x>=a.x&&t.x<=a.x+a.width&&t.y>=a.y&&t.y<=a.y+a.height}setCaretFromPoint(t){let n=this.caretIndexAtWorldPoint(t);n!==null&&(this._dragAnchor=n,this.setSelection(n,n,"forward"))}extendSelectionToPoint(t){if(this._dragAnchor===null)return;let n=this.caretIndexAtWorldPoint(t);if(n===null)return;let o=this._dragAnchor;n>=o?this.setSelection(o,n,"forward"):this.setSelection(n,o,"backward")}endDragSelect(){this._dragAnchor=null}editingTextLayout(t){return Oc(t.text,this.measureFor(t),{fontSize:t.fontSize,...t.maxWidth!==void 0?{maxWidth:t.maxWidth}:{}})}measureFor(t){let n=this.host.mainTarget;return n.setFont(t.fontFamily,t.fontSize,{...t.style.fontWeight==="bold"?{weight:"bold"}:{},...t.style.fontStyle==="italic"?{style:"italic"}:{}}),o=>n.measureText(o).width}overlay(){let t=this._editingElement;if(!t||!this._sel)return null;let n=I(this.host.scene,t);if(n===void 0||!fe(n))return null;let o=this.editingTextLayout(n);if(!o)return null;let a=n.style.textAlign??"left",r=this.measureFor(n),{x:s,y:i}=n.position,l=n.scale.x,c=n.scale.y,d=Lv(o,this._sel.start,this._sel.end,r,a).map(p=>({x:s+Math.min(p.x*l,(p.x+p.width)*l),y:i+Math.min(p.y*c,(p.y+p.height)*c),width:Math.abs(p.width*l),height:Math.abs(p.height*c)})),f=null;if(this.caretBlink.on){let p=this._sel.dir==="backward"?this._sel.start:this._sel.end,h=vv(o,p,r,n.fontSize,a);f={x:s+h.x*l,y:i+h.y*c,height:h.height*Math.abs(c)}}return{caret:f,caretColor:n.style.fill??"#1a1a1a",selectionRects:d}}commit(t){let n=this._editingElement;if(!n)return;let o=this._pendingCreate===n,a=this._origin;t!==void 0&&(this.host.scene=J(this.host.scene,n,l=>({...l,text:t})).scene),this._editingElement=null,this._pendingCreate=null,this._origin=null,this._sel=null,this.caretBlink.stop();let r=I(this.host.scene,n),s=r!==void 0&&fe(r)?r:void 0;if((s?.text??"").trim()===""){s&&(this.host.scene=dn(this.host.scene,n).scene,!o&&a&&this.host.pushHistory({kind:"element",id:n,before:a,after:null}),this.host.clearSelectionFor(n)),this.host.notify();return}if(o)s&&this.host.pushHistory({kind:"element",id:n,before:null,after:s});else if(a&&s){let l=fe(a)?a.text:"";if(l!==s.text){let c={...s,text:l};this.host.pushHistory({kind:"element",id:n,before:c,after:s})}}this.host.notify()}cancel(){let t=this._editingElement;if(t===null)return;let n=this._pendingCreate===t,o=this._origin;if(this._editingElement=null,this._pendingCreate=null,this._origin=null,this._sel=null,this.caretBlink.stop(),n)I(this.host.scene,t)&&(this.host.scene=dn(this.host.scene,t).scene,this.host.clearSelectionFor(t));else if(o){let a=fe(o)?o.text:"";this.host.scene=J(this.host.scene,t,r=>({...r,text:a})).scene}this.host.notify()}};var NO=(e,t,n,o)=>{let a=n;if(t){let i=I(e,t);i&&(a=Ga(i,n,So(i)).world)}let r=o,s=ci(e,o);return s&&(r=Ga(s,o,So(s)).world),{from:a,to:r}},zO=(e,t,n)=>{let o=be(e,t.linkId);if(!o)return null;let a=n(t.toElement,t.toPoint),r=et(e,o.id,s=>({...s,[t.side]:a}));return{scene:r.scene,patch:r.patch,linkId:o.id}},FO=(e,t)=>{let n=a=>{if(a.kind==="point")return`p:${a.position.x},${a.position.y}`;let r=I(e,a.elementId),s=r?z(r):null,i=a.kind==="anchor"?JSON.stringify(a.anchor):a.kind==="outline"?`o:${a.ratio}`:"f";return`${a.kind}:${a.elementId}:${i}:${s?`${s.x},${s.y},${s.width},${s.height}`:"x"}`},o=`${n(t.from)}|${n(t.to)}|${JSON.stringify(t.fixedSegments??null)}`;if(t.avoidObstacles===!0){let a="|avoid:";for(let r of e.elements.values()){let s=z(r);a+=`${r.id},${s.x},${s.y},${s.width},${s.height};`}return o+a}return o};var Zy=class{host;_endpointDrag=null;_waypointDrag=null;_segmentDrag=null;lastHandleClickAt=0;lastHandleClickWorld=null;constructor(t){this.host=t}get endpointDrag(){return this._endpointDrag}get waypointDrag(){return this._waypointDrag}get segmentDrag(){return this._segmentDrag}reset(){this._waypointDrag=null,this._segmentDrag=null,this._endpointDrag=null}applyEndpointMove(t,n,o){if(!be(this.host.scene,t))return;this.lastHandleClickAt=0;let r=this.host.linkAttachTargetAt(o),s=r?.kind==="element"?r.id:null,i=this.host.snapLinkEndpoint(s,o),l=et(this.host.scene,t,c=>n==="from"?{...c,from:i}:{...c,to:i});this.host.scene=l.scene,this.host.recordGesturePatch(l.patch),this._endpointDrag={linkId:t,side:n,toPoint:o},this.host.updateHoveredLinkTarget(o),this.host.notify()}applyEndpointUpdate(t){let n=this.host.hasGestureTx(),o=zO(this.host.scene,t,(a,r)=>this.host.snapLinkEndpoint(a,r));if(o===null){this.host.cancelGesture(),this._endpointDrag=null,this.host.clearHoveredLinkTarget(),this.host.notify();return}if(!n&&Yr(o.patch)){this._endpointDrag=null,this.host.clearHoveredLinkTarget(),this.host.notify();return}this.host.scene=o.scene,this.host.recordGesturePatch(o.patch),this.host.commitGesture(),this._endpointDrag=null,this.host.clearHoveredLinkTarget()}get isDraggingWaypoint(){return this._waypointDrag!==null}beginWaypointDrag(t,n,o){be(this.host.scene,t)&&(this._waypointDrag={linkId:t,index:n,pendingInsert:o})}updateWaypointDrag(t){let n=this._waypointDrag;if(!n)return;this.lastHandleClickAt=0;let o=be(this.host.scene,n.linkId);if(!o)return;let a=[...o.waypoints??[]];if(n.pendingInsert)a.splice(n.index,0,t),n.pendingInsert=!1;else{if(n.index<0||n.index>=a.length)return;a[n.index]=t}let r=et(this.host.scene,n.linkId,s=>({...s,waypoints:a}));this.host.scene=r.scene,this.host.recordGesturePatch(r.patch),this.host.notify()}endWaypointDrag(){let t=this._waypointDrag;if(this._waypointDrag=null,!t)return;if(t.pendingInsert){this.host.commitGesture();return}let n=be(this.host.scene,t.linkId);if(n?.waypoints&&t.index>=0&&t.index<n.waypoints.length){let o=ot(this.host.scene,n),a=v(n.waypoints[t.index]),r=VT/(this.host.scene.viewport.zoom||1),s=o?.[t.index],i=o?.[t.index+2];if(s&&i&&za.distanceToSegment(a,s,i)<=r){let l=n.waypoints.filter((u,d)=>d!==t.index),c=et(this.host.scene,t.linkId,u=>({...u,waypoints:l}));this.host.scene=c.scene,this.host.recordGesturePatch(c.patch)}}this.host.commitGesture()}get isDraggingSegment(){return this._segmentDrag!==null}beginSegmentDrag(t,n,o){be(this.host.scene,t)&&(this._segmentDrag={linkId:t,axis:n,at:o})}updateSegmentDrag(t){let n=this._segmentDrag;if(!n)return;this.lastHandleClickAt=0;let o=be(this.host.scene,n.linkId);if(!o)return;let a=n.axis==="h"?t.y:t.x,r=[...o.fixedSegments??[]],s={axis:n.axis,pos:a,at:n.at},i=r.findIndex(c=>c.axis===n.axis&&Math.abs(c.at-n.at)<.5);i>=0?r[i]=s:r.push(s);let l=et(this.host.scene,n.linkId,c=>({...c,fixedSegments:r}));this.host.scene=l.scene,this.host.recordGesturePatch(l.patch),this.host.notify()}endSegmentDrag(){this._segmentDrag&&(this._segmentDrag=null,this.host.commitGesture())}isHandleDoubleClick(t){let n=performance.now(),o=n-this.lastHandleClickAt<G0&&this.lastHandleClickWorld!==null&&U.distance(this.lastHandleClickWorld,t)<=W0;return this.lastHandleClickAt=n,this.lastHandleClickWorld=t,o}deleteWaypoint(t,n){let o=be(this.host.scene,t);if(!o?.waypoints||n<0||n>=o.waypoints.length)return;let a=o.waypoints.filter((s,i)=>i!==n),r=et(this.host.scene,t,s=>({...s,waypoints:a}));this.host.scene=r.scene,this.host.pushHistory(r.patch),this.host.notify()}resetSegmentPin(t,n,o,a){let r=be(this.host.scene,t);if(!r?.fixedSegments||r.fixedSegments.length===0)return;let s=-1,i=1/0;for(let u=0;u<r.fixedSegments.length;u++){let d=v(r.fixedSegments[u]);if(d.axis!==n)continue;let f=Math.abs(d.pos-o)+Math.abs(d.at-a)*.001;f<i&&(i=f,s=u)}if(s<0)return;let l=r.fixedSegments.filter((u,d)=>d!==s),c=et(this.host.scene,t,u=>({...u,fixedSegments:l}));this.host.scene=c.scene,this.host.pushHistory(c.patch),this.host.notify()}};var HO=e=>{let t=e.viewport,n=t.size.width,o=t.size.height;if(n<=0||o<=0)return null;let a=Wa(t),r=[N.applyToPoint(a,{x:0,y:0}),N.applyToPoint(a,{x:n,y:0}),N.applyToPoint(a,{x:0,y:o}),N.applyToPoint(a,{x:n,y:o})],s=V.fromPoints(r);return V.expand(s,Math.max(s.width,s.height)*.05)},Xy=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=ze(o)?Xy(e,o.id):z(o);a&&(n=n?V.union(n,a):a)}return n},UO=(e,t)=>{let n=null;for(let o of t){let a=I(e,o);if(!a)continue;let r=ze(a)?Xy(e,a.id):z(a);r&&(n=n?V.union(n,r):r)}return n};var GO=e=>{let t=null;for(let n of e.elements.values())ic(e,n)&&(t??=new Set,t.add(n.id));return t??void 0};var WO=(e,t,n,o,a)=>{let r=w0(e,o,b2),s=a==="replace"?Pe:t;for(let i of r)n(i.layerId)||(s=Xt(s,i.id));return s},qO=(e,t,n,o,a)=>{let r=a==="replace"?Pe:t,s=w0(e,o,b2);for(let i of s)n(i.layerId)||(r=Xt(r,i.id));return r},qq=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,ES=(e,t,n,o,a)=>{let r=a==="replace"?yt:t;for(let s of e.links.values()){if(n(s.layerId))continue;let i=ot(e,s);!i||i.length<2||i.every(l=>qq(l,o))&&(r=fS(r,s.id))}return r};var TS=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:e.x,y:0}:{x:0,y:e.y},jO=(e,t,n,o)=>{let a=I(e,t);if(!a)return null;let r=z(a),s=o.x-r.x,i=o.y-r.y,l={...a,position:{x:a.position.x+n.x+s,y:a.position.y+n.y+i}};return{kind:"element",id:t,before:a,after:l}},VO=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=I(e,a);if(!s)continue;let i={...s,position:{x:r.x+n.x,y:r.y+n.y}};i.position.x===s.position.x&&i.position.y===s.position.y||o.push({kind:"element",id:a,before:s,after:i})}return o},ZO=(e,t,n,o)=>{let a=e.annotations.get(t);if(!a)return null;let r={x:o.x+n.x,y:o.y+n.y},s=r;if(a.elementId){let l=I(e,a.elementId);l&&(s={x:r.x-l.position.x,y:r.y-l.position.y})}if(s.x===a.position.x&&s.y===a.position.y)return null;let i=qa(e,t,l=>({...l,position:s}));return{scene:i.scene,patch:i.patch}};var IS=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(a)}return n},MS=e=>e.map(t=>z(t)).reduce((t,n)=>V.union(t,n)),XO=(e,t,n)=>{let o=IS(e,t);if(o.length===0)return[];let a=MS(o),r=a.x+a.width/2,s=a.y+a.height/2,i=n==="horizontal",l=[];for(let c of o){let u=i?{...c,position:{x:2*r-c.position.x,y:c.position.y},scale:{x:-c.scale.x,y:c.scale.y}}:{...c,position:{x:c.position.x,y:2*s-c.position.y},scale:{x:c.scale.x,y:-c.scale.y}};l.push({kind:"element",id:c.id,before:c,after:u})}return l},YO=(e,t,n)=>{let o=IS(e,t);if(o.length<2)return[];let a=MS(o),r=[];for(let s of o){let i=z(s),l=0,c=0;switch(n){case"left":l=a.x-i.x;break;case"right":l=a.x+a.width-(i.x+i.width);break;case"h-center":l=a.x+a.width/2-(i.x+i.width/2);break;case"top":c=a.y-i.y;break;case"bottom":c=a.y+a.height-(i.y+i.height);break;case"v-center":c=a.y+a.height/2-(i.y+i.height/2);break}if(l===0&&c===0)continue;let u={...s,position:{x:s.position.x+l,y:s.position.y+c}};r.push({kind:"element",id:s.id,before:s,after:u})}return r},KO=(e,t,n)=>{let o=IS(e,t);if(o.length<3)return[];let a=n==="horizontal",r=m=>a?m.x:m.y,s=m=>a?m.width:m.height,i=o.map(m=>({el:m,b:z(m)})).sort((m,x)=>r(m.b)-r(x.b)),l=i[0],c=i[i.length-1];if(!l||!c)return[];let u=r(c.b)+s(c.b)-r(l.b),d=i.reduce((m,x)=>m+s(x.b),0),f=(u-d)/(i.length-1),p=[],h=r(l.b)+s(l.b)+f;for(let m=1;m<i.length-1;m++){let x=i[m];if(!x)continue;let y=h-r(x.b);if(y!==0){let g=a?{...x.el,position:{x:x.el.position.x+y,y:x.el.position.y}}:{...x.el,position:{x:x.el.position.x,y:x.el.position.y+y}};p.push({kind:"element",id:x.el.id,before:x.el,after:g})}h+=s(x.b)+f}return p},RS=(e,t,n,o)=>{let a=Math.cos(o),r=Math.sin(o),s=[];for(let[i,l]of t){let c=I(e,i);if(!c)continue;let u=l.position.x-n.x,d=l.position.y-n.y,f={...c,position:{x:n.x+(u*a-d*r),y:n.y+(u*r+d*a)},rotation:l.rotation+o};s.push({kind:"element",id:i,before:c,after:f})}return s},$O=e=>{let t=MS(e);return{x:t.x+t.width/2,y:t.y+t.height/2}};var Yy=(e,t)=>({x:Math.round(e.x/t)*t,y:Math.round(e.y/t)*t}),e8=(e,t,n)=>{let o=Yy({x:e.x+t.x,y:e.y+t.y},n);return{x:o.x-e.x,y:o.y-e.y}},t8=(e,t,n)=>{let o=1/0,a=1/0;for(let s of e.values())s.x<o&&(o=s.x),s.y<a&&(a=s.y);if(!Number.isFinite(o))return t;let r=Yy({x:o+t.x,y:a+t.y},n);return{x:r.x-o,y:r.y-a}},QO=new Set(["nw","w","sw"]),jq=new Set(["ne","e","se"]),JO=new Set(["nw","n","ne"]),Vq=new Set(["sw","s","se"]),OS=(e,t,n,o)=>{let a=n.x,r=n.y;if(QO.has(t)||jq.has(t)){let s=QO.has(t)?e.x:e.x+e.width;a=Math.round((s+n.x)/o)*o-s}if(JO.has(t)||Vq.has(t)){let s=JO.has(t)?e.y:e.y+e.height;r=Math.round((s+n.y)/o)*o-s}return{x:a,y:r}},n8=(e,t)=>{let n=Yy({x:e.x,y:e.y},t),o=Yy({x:e.x+e.width,y:e.y+e.height},t);return{x:n.x,y:n.y,width:Math.max(0,o.x-n.x),height:Math.max(0,o.y-n.y)}};var Zq=new Set(["MOVE_SHAPE","RESIZE_GROUP","RESIZE_SHAPE","ROTATE","CREATE_SHAPE","CREATE_EDGE","MOVE_ANNOTATION","COMMIT_ANNOTATION_DRAG","UPDATE_EDGE_ENDPOINT","UPDATE_EDGE_ENDPOINT_PREVIEW","DRAW_EDGE_PREVIEW"]),Xq=Object.freeze(new Set),Ri=()=>typeof performance<"u"?performance.now():Date.now(),Gp=class{host;mainTarget;overlayTarget;backgroundTarget;onAfterRender;debugHitZones=!1;_readOnly=!1;actor;listeners=new Set;events=Qv();eventCache=pM();unbind;_scene;_selection=Pe;interaction=new Ny;get annotationDrag(){return this.interaction.annotationDrag}set annotationDrag(t){this.interaction.annotationDrag=t}get drawingPreview(){return this.interaction.drawingPreview}set drawingPreview(t){this.interaction.drawingPreview=t}get edgePreview(){return this.interaction.edgePreview}set edgePreview(t){this.interaction.edgePreview=t}get linkDragFromAnchor(){return this.interaction.linkDragFromAnchor}set linkDragFromAnchor(t){this.interaction.linkDragFromAnchor=t}get hoveredLinkTarget(){return this.interaction.hoveredLinkTarget}set hoveredLinkTarget(t){this.interaction.hoveredLinkTarget=t}get hoverCursorWorld(){return this.interaction.hoverCursorWorld}set hoverCursorWorld(t){this.interaction.hoverCursorWorld=t}_selectedLinks=yt;_selectedAnnotation=null;commentAuthor={id:"local",name:"You"};get linkEndpointDrag(){return this.linkHandles.endpointDrag}get linkWaypointDrag(){return this.linkHandles.waypointDrag}get linkSegmentDrag(){return this.linkHandles.segmentDrag}get lassoPreview(){return this.interaction.lassoPreview}set lassoPreview(t){this.interaction.lassoPreview=t}get groupMoveOrigin(){return this.interaction.groupMoveOrigin}set groupMoveOrigin(t){this.interaction.groupMoveOrigin=t}get groupLinkMoveOrigin(){return this.interaction.groupLinkMoveOrigin}set groupLinkMoveOrigin(t){this.interaction.groupLinkMoveOrigin=t}get groupResizeOrigin(){return this.interaction.groupResizeOrigin}set groupResizeOrigin(t){this.interaction.groupResizeOrigin=t}get rotateGestureOrigin(){return this.interaction.rotateGestureOrigin}set rotateGestureOrigin(t){this.interaction.rotateGestureOrigin=t}_activeLayerId=ln(Rn);nextId=0;uniqueId(t){return`${t}-${++this.nextId}-${Date.now().toString(36)}`}snapEngine=new Yf([DA,PA,BA]);snapThreshold=12;styleClipboard=null;boundsCache=new es;spatialIndexCache=null;_enteredGroup=null;get brushStroke(){return this.interaction.brushStroke}set brushStroke(t){this.interaction.brushStroke=t}get brushPreviewStroke(){let t=this.interaction.brushStroke;if(!t)return null;let n=zy(this._brushSettings);return{origin:t.origin,points:mS(t.points),fill:Df(n),opacity:n.opacity??1}}get eraseStroke(){return this.interaction.eraseStroke}set eraseStroke(t){this.interaction.eraseStroke=t}get pendingErase(){return this.interaction.eraseStroke?.pending??Xq}get laserStrokes(){return this.interaction.laserStrokes}get lastPointerWorld(){return this.interaction.lastPointerWorld}set lastPointerWorld(t){this.interaction.lastPointerWorld=t}cursorOverrides=new Map;lastRenderedScene=null;lastRenderedEnteredGroup=null;lastRenderedEraseActive=!1;eraseDirty=!1;autoCompactScheduler=new Cy({getScene:()=>this._scene,compact:t=>{this.compactLayerZOrder(t,{recordHistory:!1})}});autoLayoutScheduler=new Ey({getScene:()=>this._scene,applyPatch:t=>{this._scene=Q(this._scene,t),this.gestureTx?this.gestureTx.add(t):this._history.push(t)},growContainer:(t,n)=>{this.maybeGrowContainer(t,n)},onMutated:()=>{this.scheduleRender();for(let t of this.listeners)t()}});get dragElementId(){return this.interaction.dragElementId}set dragElementId(t){this.interaction.dragElementId=t}get additivePressAdded(){return this.interaction.additivePressAdded}set additivePressAdded(t){this.interaction.additivePressAdded=t}get containerHover(){return this.interaction.containerHover}set containerHover(t){this.interaction.containerHover=t}_peerCursors=[];_peerSelections=[];cursorListeners=new Set;get activePointers(){return this.interaction.activePointers}get touchPanCandidate(){return this.interaction.touchPanCandidate}set touchPanCandidate(t){this.interaction.touchPanCandidate=t}pinch;containerOpsRef;get spaceHeld(){return this.interaction.spaceHeld}set spaceHeld(t){this.interaction.spaceHeld=t}tileComposeFn;tileDirtyElements=new Map;_toolLocked=!1;fileDropRegistry=new Op;get panGesture(){return this.interaction.panGesture}set panGesture(t){this.interaction.panGesture=t}get suppressNextContextMenu(){return this.interaction.suppressNextContextMenu}set suppressNextContextMenu(t){this.interaction.suppressNextContextMenu=t}longPress;longPressListeners=new Set;announceListeners=new Set;inputMode;handleHitSlop;edgeHandleHitSlop;edgeHitThreshold;anchorStartHitSlop;anchorClickRadius;_history;gestureTx=null;gestureStartScene=null;gestures;textEdit;linkHandles;constructor(t){this.host=t.host,this.mainTarget=t.mainTarget,this.overlayTarget=t.overlayTarget,this.backgroundTarget=t.backgroundTarget??null,this.onAfterRender=t.onAfterRender??null,this._scene=t.initialScene,this._history=Yq(t.history)?t.history:new Rp(t.history??{}),this.tileComposeFn=t.useTileCache===!0&&t.tileCompose?t.tileCompose:null,this.initControllers(),this.initGlobalHooks(t),this.initInputMode(t),this.initActor(t),this.unbind=this.bindPointerEvents(),this.animation.attach(),rS(this),sS(this),this.maybeAnimate(),this.animationContentOff=wv(()=>{this.scheduleRender()}),this.forceRender(),mM(this.eventCache,this.observableSnapshot())}initControllers(){let t=this;this.gestures=new My({get history(){return t._history},get gestureTx(){return t.gestureTx},set gestureTx(n){t.gestureTx=n},get groupMoveOrigin(){return t.groupMoveOrigin},set groupMoveOrigin(n){t.groupMoveOrigin=n},get groupLinkMoveOrigin(){return t.groupLinkMoveOrigin},set groupLinkMoveOrigin(n){t.groupLinkMoveOrigin=n},get groupResizeOrigin(){return t.groupResizeOrigin},set groupResizeOrigin(n){t.groupResizeOrigin=n},get dragElementId(){return t.dragElementId},set dragElementId(n){t.dragElementId=n},get containerHover(){return t.containerHover},set containerHover(n){t.containerHover=n},get toolLocked(){return t._toolLocked},get mode(){return t.mode},setMode:n=>{t.setMode(n)},notify:()=>{t.notify()}}),this.textEdit=new Vy({get scene(){return t._scene},set scene(n){t._scene=n},pushHistory:n=>{t._history.push(n)},notify:()=>{t.notify()},isLayerLocked:n=>t.isLayerLocked(n),clearSelectionFor:n=>{t._selection.has(n)&&(t._selection=Pe)},mainTarget:this.mainTarget}),this.linkHandles=new Zy({get scene(){return t._scene},set scene(n){t._scene=n},pushHistory:n=>{t._history.push(n)},recordGesturePatch:n=>{t.recordGesturePatch(n)},commitGesture:()=>{t.commitGesture()},cancelGesture:()=>{t.cancelGesture()},hasGestureTx:()=>t.gestureTx!==null,notify:()=>{t.notify()},linkAttachTargetAt:n=>t.linkAttachTargetAt(n),snapLinkEndpoint:(n,o)=>t.snapLinkEndpoint(n,o),updateHoveredLinkTarget:n=>{t.updateHoveredLinkTarget(n)},clearHoveredLinkTarget:()=>{t.hoveredLinkTarget=null}}),this.longPress=new Dy(n=>this.screenToWorld(n),n=>{for(let o of this.longPressListeners)o(n)}),this.pinch=new Py(n=>this.screenToWorld(n),(n,o)=>{this.zoomAt(n,o)},n=>{this.panBy(n)}),this.containerOpsRef={get scene(){return t._scene},get dragElementId(){return t.dragElementId},get containerHover(){return t.containerHover},applyPatch(n,o){t._scene=o,t.beginOrAttachGesture().add(n)}}}initGlobalHooks(t){t.textShaper&&Cp(t.textShaper),t.rasterizer&&Ep(t.rasterizer),fA((n,o,a,r)=>(this.mainTarget.setFont(o,a,{...r?.bold?{weight:"bold"}:{},...r?.italic?{style:"italic"}:{}}),this.mainTarget.measureText(n).width))}initInputMode(t){let n=t.inputMode??"auto";n==="touch"?this.inputMode="touch":n==="mouse"?this.inputMode="mouse":typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?this.inputMode="touch":this.inputMode="mouse",this.handleHitSlop=this.inputMode==="touch"?vI:11,this.edgeHandleHitSlop=this.inputMode==="touch"?SI:Zo,this.edgeHitThreshold=this.inputMode==="touch"?LI:F0,this.anchorStartHitSlop=this.inputMode==="touch"?kI:H0,this.anchorClickRadius=this.inputMode==="touch"?wI:U0}initActor(t){this.actor=$o(a5),this.actor.subscribe({next:()=>{this.scheduleRender()}}),this.actor.on("*",n=>{this.applyEmit(n)}),this.actor.start(),this.fileDropRegistry.register(oM),this.fileDropRegistry.register(rM),this._readOnly=t.readOnly??!1,t.initialMode&&this.actor.send({type:"SET_MODE",mode:t.initialMode})}snapshotCache=null;observableSnapshot(){let t=this.mode,n=this._selection,o=this._selectedLinks,a=this._scene,r=this.canUndo,s=this.canRedo,i=this.snapshotCache;if(i!==null&&i.mode===t&&i.selection===n&&i.selectedLinks===o&&i.scene===a&&i.canUndo===r&&i.canRedo===s)return i;let l={mode:t,selection:n,selectedLinks:o,scene:a,canUndo:r,canRedo:s};return this.snapshotCache=l,l}get scene(){return this._scene}get selection(){return this._selection}get mode(){return this.actor.getSnapshot().context.mode}get history(){return this._history}get canUndo(){return this._history.canUndo}get canRedo(){return this._history.canRedo}get hostElement(){return this.host}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}onCursorMove(t){return this.cursorListeners.add(t),()=>this.cursorListeners.delete(t)}setCommentAuthor(t){this.commentAuthor=t}get selectedAnnotation(){return this._selectedAnnotation}setSelectedAnnotation(t){this._selectedAnnotation!==t&&(this._selectedAnnotation=t,this.notify())}addAnnotation(t){let n=FR(this._scene,t,this.commentAuthor,o=>this.uniqueId(o));return this._scene=n.scene,this._history.push(n.patch),this._selectedAnnotation=n.id,this.notify(),this.announce("Annotation added"),n.id}removeAnnotation(t){let n=HR(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this._selectedAnnotation===t&&(this._selectedAnnotation=null),this.notify(),this.announce("Annotation removed"))}toggleAnnotationResolved(t){let n=UR(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify(),this.announce(n.wasResolved?"Annotation reopened":"Annotation resolved"))}addComment(t,n,o){let a=GR(this._scene,t,n,o??this.commentAuthor,r=>this.uniqueId(r));a&&(this._scene=a.scene,this._history.push(a.patch),this.notify())}removeComment(t,n){let o=WR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}hitAnnotation(t){return qR(this._scene,t)}onLongPress(t){return this.longPressListeners.add(t),()=>this.longPressListeners.delete(t)}onAnnounce(t){return this.announceListeners.add(t),()=>this.announceListeners.delete(t)}announce(t){if(t)for(let n of this.announceListeners)n(t)}setPeerCursors(t){this._peerCursors=t,this.scheduleRender()}setPeerSelections(t){this._peerSelections=t,this.scheduleRender()}setDebugHitZones(t){this.debugHitZones!==t&&(this.debugHitZones=t,this.scheduleRender())}get readOnly(){return this._readOnly}setReadOnly(t){this._readOnly!==t&&(this._readOnly=t,this.notify(),this.scheduleRender())}toggleReadOnly(){this.setReadOnly(!this._readOnly)}get gridEnabled(){return this._scene.viewport.gridEnabled}setGridVisible(t){this.setGrid({enabled:t})}toggleGrid(){this.setGrid({enabled:!this.gridEnabled})}get toolLocked(){return this._toolLocked}get selectedLinks(){return this._selectedLinks}get selectedLink(){return this._selection.size>0?null:GM(this._selectedLinks)}updateSelectedLink(t){if(this.readOnly)return;let n=this.selectedLink;if(n===null)return;let o=et(this._scene,n,t);this._scene=o.scene,this._history.push(o.patch),this.notify()}registerFileDropHandler(t){this.fileDropRegistry.register(t)}unregisterFileDropHandler(t){this.fileDropRegistry.unregister(t)}async dispatchFileDrop(t,n){let o={editor:this,worldPoint:n};return this.fileDropRegistry.dispatch(t,o)}setToolLocked(t){this._toolLocked!==t&&(this._toolLocked=t,this.notify())}maybeRevertModeAfterCreate(){this.gestures.maybeRevertModeAfterCreate()}setMode(t){this.pendingEyedropperPick=null,this.editingTextElement!==null&&this.commitTextEdit(),this.gestureTx&&(this.gestureTx.cancel(),this.gestureTx=null),t!=="draw-edge"&&this.hoveredLinkTarget!==null&&(this.hoveredLinkTarget=null),this.actor.send({type:"SET_MODE",mode:t}),this.refreshCursor(),this.notify()}undo(){let t=this._history.undo();return t?(this._scene=Q(this._scene,t),this.pruneSelection(),this.notify(),!0):!1}redo(){let t=this._history.redo();return t?(this._scene=Q(this._scene,t),this.pruneSelection(),this.notify(),!0):!1}addElement(t,n){let o=Fe(this._scene,t);return this._scene=o.scene,(n?.select??!0)&&(this._selection=wt(t.id)),this._history.push(o.patch),this.notify(),o.patch}insertImage(t){let n=Ze(this.uniqueId("img")),o=yM(this._scene,t,n,this._activeLayerId);return this.addElement(o),t.animated&&(this.gifPlayback.ensure(n),this.maybeAnimate()),n}async addBinaryFile(t,n){let o=await gM(this._scene,t,n,()=>++this.nextId);return this._scene=o.scene,this._history.push(o.patch),o.id}animation=new Iy({hasVisibleAnimatedElement:()=>bM(this)||this.hasActiveLaser(),autoStopHeavyGifs:()=>{AM(this)},forceAnimationRepaint:()=>{this.lastRenderedScene=null,this.render()}});hasAnimatedElement(){return Oy(this._scene)}maybeAnimate(){this.animation.maybe()}gifPlayback=new Ry;togglePlayback(t){this.gifPlayback.toggle(t),this.maybeAnimate(),this.scheduleRender()}hoverAnimatedElement(t){this.gifPlayback.hoverEnter(t)&&(this.maybeAnimate(),this.scheduleRender())}isPlaybackPaused(t){return this.gifPlayback.isPaused(t)}setHoverCursorWorld(t){this.hoverCursorWorld=t,this._selection.size===1&&this.notify()}get linkPreviewPath(){return this.edgePreview?.points??null}get linkAttachTarget(){let t=this.hoveredLinkTarget;return t?{elementId:t.elementId,mode:t.mode}:null}beginPlacement(t){let n=this._history.transaction(),{scene:o,state:a}=xO(t),r=o(this._scene);this._scene=r.scene,this._selection=wt(t.id),this.notify();let s={...a};return{update:i=>{let l=yO(this._scene,s,i);this._scene=l.scene,s.current=l.next,this.notify()},commit:()=>{let i=gO(this._scene,s);i&&(this._scene=i.scene,s.current=i.next),n.add({kind:"element",id:t.id,before:null,after:s.current}),n.commit(),this.notify()},cancel:()=>{let{scene:i}=bO(this._scene,t.id);this._scene=i,n.cancel(),this._selection=Pe,this.notify()}}}deleteSelected(){if(this.readOnly)return;let t=Fy(this._scene,this._selection,this._selectedLinks);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),this._selection=Pe,this._selectedLinks=yt,this.notify()}get editingTextElement(){return this.textEdit.editingElement}get editingLinkCaption(){return this.interaction.editingLinkCaption}_editingFrameName=null;get editingFrameName(){return this._editingFrameName}get editingTextSelection(){return this.textEdit.selection}get editingTextCaret(){return this.textEdit.caret}get caretBlinkOn(){return this.textEdit.caretBlinkOn}get isTextDragging(){return this.textEdit.isDragging}beginLinkCaptionEdit(t){be(this._scene,t)&&(this.editingTextElement!==null&&this.commitTextEdit(),this.interaction.editingLinkCaption=t,this.notify())}commitLinkCaptionEdit(t){let n=this.interaction.editingLinkCaption;if(this.interaction.editingLinkCaption=null,n===null){this.notify();return}let o=be(this._scene,n);if(o){let a=t.trim(),r=a===""?void 0:{...o.label??{},text:a};if(!((o.label?.text??"")===(r?.text??""))){let i=et(this._scene,n,l=>{let c={...l};return r?c.label=r:delete c.label,c});this._scene=i.scene,this._history.push(i.patch)}}this.notify()}cancelLinkCaptionEdit(){this.interaction.editingLinkCaption!==null&&(this.interaction.editingLinkCaption=null,this.notify())}linkLabelWorld(t){let n=be(this._scene,t);if(!n)return null;let o=ot(this._scene,n);if(!o||o.length<2)return null;let a=n.label?.position??.5,r=0;for(let i=1;i<o.length;i++)r+=U.distance(v(o[i-1]),v(o[i]));let s=r*a;for(let i=1;i<o.length;i++){let l=v(o[i-1]),c=v(o[i]),u=U.distance(l,c);if(s<=u){let d=u===0?0:s/u;return{x:l.x+(c.x-l.x)*d,y:l.y+(c.y-l.y)*d}}s-=u}return v(o[o.length-1])}beginTextEdit(t){this.textEdit.begin(t)}beginFrameNameEdit(t){let n=I(this._scene,t);n===void 0||!Be(n)||this.isLayerLocked(n.layerId)||(this.editingTextElement!==null&&this.commitTextEdit(),this._editingFrameName=t,this.notify())}commitFrameNameEdit(t){let n=this._editingFrameName;if(n===null)return;this._editingFrameName=null;let o=VR(this._scene,n,t);o&&(this._scene=o.scene,this._history.push(o.patch)),this.notify()}cancelFrameNameEdit(){this._editingFrameName!==null&&(this._editingFrameName=null,this.notify())}frameHeaderAt(t){return jR(this._scene,t)}setEditingText(t,n,o,a="forward"){this.textEdit.setText(t,n,o,a)}setEditingSelection(t,n,o="forward"){this.textEdit.setSelection(t,n,o)}caretIndexAtWorldPoint(t){return this.textEdit.caretIndexAtWorldPoint(t)}editedElementContainsPoint(t){return this.textEdit.editedElementContainsPoint(t)}setTextCaretFromPoint(t){this.textEdit.setCaretFromPoint(t)}extendTextSelectionToPoint(t){this.textEdit.extendSelectionToPoint(t)}endTextDragSelect(){this.textEdit.endDragSelect()}editingTextOverlay(){return this.textEdit.overlay()}commitTextEdit(t){this.textEdit.commit(t)}cancelTextEdit(){this.textEdit.cancel()}moveSelectionBy(t){if(this.readOnly||this._selection.size===0&&this._selectedLinks.size===0)return;let n=new Set([...this.expandSelectionWithDescendants()].filter(i=>{let l=I(this._scene,i);return l?this.isElementManipulable(l):!1})),o=this._selection.size>0?aR(this._scene,n,t,i=>this.isLayerLocked(i)):null,a=o?o.scene:this._scene,r=BM(a,n,this._selectedLinks,t);if(!o&&r.patches.length===0)return;let s=this._history.transaction();if(this._scene=r.scene,o)for(let i of o.patches)s.add(i);for(let i of r.patches)s.add(i);s.commit(),this.notify(),this.announce(pR(t,o?.moved??0))}createElementAtCursor(){let t=this._scene.viewport,n=this.screenToWorld({x:(t.size.width||200)/2,y:(t.size.height||200)/2}),o=wS(++this.nextId),a=hO(this._scene,this.mode,n,this._activeLayerId,o),r=Fe(this._scene,a);return this._scene=r.scene,this._history.push(r.patch),this._selection=wt(o),this.notify(),this.announce(`Created ${a.type} ${o}`),o}createTextAt(t){let n=wS(++this.nextId),o=mO(this._scene,t,this._activeLayerId,n),a=Fe(this._scene,o);return this._scene=a.scene,this.textEdit.markPendingCreate(n),this._selection=wt(n),this.maybeRevertModeAfterCreate(),this.notify(),this.announce(`Created text ${n}`),this.beginTextEdit(n),n}_brushSettings=Nc;get brushSettings(){return this._brushSettings}setBrushSettings(t){this._brushSettings={...this._brushSettings,...t},this.notify()}beginBrushStroke(t,n=.5){this.brushStroke=tR(t,n,this._brushSettings.width),this.notify()}extendBrushStroke(t,n=.5){this.brushStroke&&(nR(this.brushStroke,t,n,this._brushSettings.width),this.notify())}commitBrushStroke(){let t=oR(this._scene,this.brushStroke,this._activeLayerId,yS(++this.nextId),zy(this._brushSettings));return t?(this._scene=t.scene,this._history.push(t.patch),this.brushStroke=null,this.notify(),t.elementId):(this.brushStroke=null,this.notify(),null)}cancelBrushStroke(){this.brushStroke&&(this.brushStroke=null,this.notify())}get pendingBrushStroke(){return this.brushStroke}beginEraseStroke(t,n=!1,o=!1){let a=hR(t,o);if(!n){let r=this.acceleratedElementAt(t);r&&!(o&&r.type==="brush")&&a.pending.add(r.id)}this.eraseStroke=a,this.eraseDirty=!0,o&&this.markStrokeEraseSegment(a,t,t),this.interaction.eraserTrail=[vy(t,Ri())],this.maybeAnimate(),this.notify()}markStrokeEraseSegment(t,n,o){let a=this._scene.viewport.zoom||1,r=this._brushSettings.width/a,s=!1;for(let i of this._scene.elements.values()){if(!Ha(i))continue;let l=t.erased.get(i.id)??[],c=LR(i,l,n,o,r);(c.length>l.length||vS(c)>vS(l)+1e-6)&&(t.erased.set(i.id,c),s=!0)}return s}extendEraseStroke(t,n=!1){let o=this.eraseStroke;if(!o)return;let a=mR(o.last,t,l=>this.acceleratedElementAt(l),o.pending,n,o.strokeMode),r=o.strokeMode?this.markStrokeEraseSegment(o,o.last,t):!1;(a||r)&&(this.eraseDirty=!0),o.last=t;let s=this.interaction.eraserTrail,i=s[s.length-1];i?(Mv(i,t,Ri()),this.interaction.eraserTrail=s.slice()):this.interaction.eraserTrail=[vy(t,Ri())],this.maybeAnimate(),this.notify()}commitEraseStroke(){let t=this.eraseStroke;if(!t)return 0;this.eraseStroke=null;let n=yR(this._scene,t.pending),o=n?n.scene:this._scene,a=n?[...n.patches]:[],r=[];if(t.strokeMode){let l=kR(o,t.erased,()=>yS(++this.nextId));l&&(o=l.scene,a.push(...l.patches),r.push(...l.removedIds))}if(a.length===0)return this.notify(),0;let s=this._history.transaction();this._scene=o;for(let l of a)s.add(l);s.commit();let i=this._selection;for(let l of t.pending)i=Tf(i,l);for(let l of r)i=Tf(i,l);return this._selection=i,this.notify(),t.pending.size+r.length}cancelEraseStroke(){this.eraseStroke&&(this.eraseStroke=null,this.notify())}get laserDrawing(){return this.interaction.laserDrawing}beginLaserStroke(t){this.interaction.laserStrokes=[...this.interaction.laserStrokes,vy(t,Ri())],this.interaction.laserDrawing=!0,this.maybeAnimate(),this.notify()}extendLaserStroke(t){if(!this.interaction.laserDrawing)return;let n=this.interaction.laserStrokes,o=n[n.length-1];o&&(Mv(o,t,Ri()),this.interaction.laserStrokes=n.slice(),this.maybeAnimate(),this.notify())}endLaserStroke(){this.interaction.laserDrawing=!1,this.maybeAnimate()}hasActiveLaser(){return this.interaction.laserStrokes.length>0||this.interaction.eraserTrail.length>0}get eraserTrail(){return this.interaction.eraserTrail}pruneLaser(){let t=this.interaction.laserStrokes;if(t.length>0){let o=Rv(t,Ri());o.changed&&(this.interaction.laserStrokes=o.strokes)}let n=this.interaction.eraserTrail;if(n.length>0){let o=Rv(n,Ri(),Z0);o.changed&&(this.interaction.eraserTrail=o.strokes)}}arrangeAsGrid(t={}){let n=this.combinedSelectionBounds()??{x:0,y:0},o=eO(this._scene,this._selection,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify(),this.announce(`Arranged ${o.count} shapes on a ${o.cols}-column grid`))}arrangeAsStack(t={}){let n=this.combinedSelectionBounds()??{x:0,y:0},o=tO(this._scene,this._selection,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify(),this.announce(`Stacked ${o.count} shapes ${o.direction}`))}groupSelected(){if(this.readOnly)return{kind:"noop"};let t=oO(this._scene,this._selection,sO(++this.nextId));if(!t)return{kind:"noop"};let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);return n.commit(),this._selection=wt(t.groupId),this.notify(),{kind:"grouped",groupId:t.groupId}}ungroup(){if(this.readOnly)return;let t=aO(this._scene,this._selection);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),this._selection=new Set(t.nextSelection),this.notify()}selectionRoots(){return SS(this._scene,this._selection)}expandSelectionWithDescendants(){return nO(this._scene,this._selection)}focusCycle(t){let n=[...this._selection][0],o=rO(this._scene,n,t);o&&(this._selection=wt(o.id),this.notify(),this.announce(`Selected ${o.name}`))}cancelInteraction(){this.cancelGesture(),this.actor.send({type:"POINTER_CANCEL"}),this.interaction.resetPreviews(),this.interaction.linkDragFromAnchor=null,this.interaction.editingLinkCaption=null,this.interaction.pendingLinkDropMenu=null,this.interaction.eraseStroke=null,this.interaction.laserDrawing=!1,this.flowchartSession=null,this.linkHandles.reset(),this._enteredGroup!==null&&(this._enteredGroup=null),this._selection=Pe,this._selectedLinks=yt,this.notify(),this.announce("Selection cleared")}duplicateSelected(){if(this.readOnly)return;let t=rR(this._scene,this._selection,()=>++this.nextId);if(!t)return;let n=this._history.transaction();this._scene=t.scene;for(let o of t.patches)n.add(o);n.commit(),t.newIds.length>0&&(this._selection=gS(t.newIds)),this.notify()}duplicateSelectedInPlace(t=null){if(this.readOnly||this._selection.size===0)return null;let n=new Set,o=l=>{if(!n.has(l)){n.add(l);for(let c of this._scene.elements.values())(c.parentId===l||c.frameId===l)&&o(c.id)}};for(let l of this._selection)o(l);let a=new Map;for(let l of n)a.set(l,Ze(this.uniqueId("shape")));let r=SO(this._scene,n,a),s=this._history.transaction();this._scene=r.scene;for(let l of r.patches)s.add(l);s.commit();let i=[];for(let l of this._selection){let c=a.get(l);c!==void 0&&i.push(c)}return i.length>0&&(this._selection=gS(i)),this.notify(),t!==null?a.get(t)??null:null}setSelection(t){let n=sR(this._scene,t,this._selection);n&&(this._selection=n,this._selectedLinks.size>0&&(this._selectedLinks=yt),this.notify())}selectLink(t){let n=t===null?yt:By(t),o=!Np(n,this._selectedLinks),a=this._selection.size>0;!o&&!a||(this._selection=Pe,this._selectedLinks=n,this.notify())}selectAll(){let t=iR(this._scene,this._selection),n=lR(this._scene),o=!Np(n,this._selectedLinks);if(!t&&!o)return;t&&(this._selection=t),this._selectedLinks=n,this.notify();let a=this._selection.size+this._selectedLinks.size;this.announce(`Selected ${a} objects`)}clipboard=[];copySelected(){let t=TR(this._scene,this._selection);t.length!==0&&(this.clipboard=[...t],this.announce(`Copied ${t.length} shapes`))}cutSelected(){this.readOnly||(this.copySelected(),this.deleteSelected())}paste(t){if(this.clipboard.length===0)return;this.finalizeOpenGestureTx();let n=t??this.lastPointerWorld,o=IR(this._scene,this._history,this.clipboard,n??null,()=>++this.nextId);this._scene=o.scene,this._selection=MR(o.newIds),this.notify(),this.announce(`Pasted ${o.newIds.length} shapes`)}copySelectionStyle(){for(let t of this._selection){let n=I(this._scene,t);if(n!==void 0){this.styleClipboard={...n.style};return}}}pasteSelectionStyle(){this.styleClipboard!==null&&this.updateStyle(this._selection,this.styleClipboard)}get hasStyleClipboard(){return this.styleClipboard!==null}updateStyle(t,n){if(this.readOnly)return;let o=cR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}applyTextStyleToRange(t,n,o,a){if(this.readOnly)return;let r=uR(this._scene,t,n,o,a);r&&(this._scene=r.scene,this._history.push(r.patch),this.notify())}pickColorAt(t,n="fill"){return _S(this._scene,t,n)}pendingEyedropperPick=null;get isEyedropperArmed(){return this.pendingEyedropperPick!==null}beginEyedropperPick(t){this.pendingEyedropperPick=t,this.refreshCursor(),this.notify()}applyEyedropperAt(t){let n=_S(this._scene,t,"fill"),o=this.pendingEyedropperPick;return o!==null?(this.pendingEyedropperPick=null,n!==null&&o(n),this.refreshCursor(),this.notify(),n):n===null?null:(!this.readOnly&&this._selection.size>0&&this.updateStyle(this._selection,{fill:n}),this.mode==="eyedropper"&&!this.toolLocked&&this.setMode("select"),n)}convertSelection(t){if(this.readOnly)return;let n=kO(this._scene,this._selection,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}spawnConnectedNode(t){if(this.readOnly)return;let n=[...this._selection],o=n.length===1?n[0]:void 0;if(o===void 0)return;let a=MO(this._scene,o,t,zc(++this.nextId),Up(++this.nextId));a&&(this._scene=a.scene,this._history.push({kind:"batch",patches:[...a.patches]}),this.setSelection([a.newElementId]),this.notify())}flowchartSession=null;growFlowchart(t){if(this._readOnly||this._selection.size!==1)return;let o=[...this._selection][0];if(o===void 0||I(this._scene,o)===void 0)return;let a=this.flowchartSession,r=a?.direction===t&&a.sourceId===o?Math.min(a.count+1,r4):1,{elements:s,links:i}=RO(this._scene,o,t,r,()=>zc(++this.nextId),()=>Up(++this.nextId));this.flowchartSession={sourceId:o,direction:t,count:r,elements:s,links:i},this.notify()}commitFlowchart(){let t=this.flowchartSession;if(t===null)return null;let n=this._scene,o=[];for(let r of t.elements){let s=Fe(n,r);n=s.scene,o.push(s.patch)}for(let r of t.links){let s=fi(n,r);n=s.scene,o.push(s.patch)}this.flowchartSession=null;let a=t.elements[0]?.id??null;return o.length===0?(this.notify(),a):(this._scene=n,this._history.push({kind:"batch",patches:o}),a!==null&&this.setSelection([a]),this.notify(),a)}cancelFlowchart(){this.flowchartSession!==null&&(this.flowchartSession=null,this.notify())}get flowchartPreview(){let t=this.flowchartSession;return t===null?null:{elements:t.elements,links:t.links}}navigateFlowchart(t){if(this._selection.size!==1)return;let o=[...this._selection][0];if(o===void 0)return;let a=new Set;for(let r of this._scene.links.values()){let s=si(r.from),i=si(r.to);s===o&&i!==void 0&&i!==o?a.add(i):i===o&&s!==void 0&&s!==o&&a.add(s)}if(a.size>0){let r=this.combinedSelectionBounds(),s=r?{x:r.x+r.width/2,y:r.y+r.height/2}:{x:0,y:0},i=xS(this._scene,this._selection,t,s,l=>this.isElementInteractable(l)&&a.has(l.id));if(i!==null){this.setSelection([i]);return}}this.selectClosest(t)}cropSession=null;get imageCropSession(){let t=this.cropSession;return t===null?null:{id:t.id,crop:t.crop,position:t.position,width:t.width,height:t.height}}beginImageCrop(t){if(this.readOnly)return;let n=I(this._scene,t);n===void 0||!ct(n)||(this.cancelInteraction(),this._selection=wt(t),this.cropSession={id:t,crop:n.crop??Wy,position:n.position,width:n.width,height:n.height,drag:null,dragStartWorld:null},this.setMode("crop"),this.refreshCursor(),this.notify())}cropHandleAtWorld(t){let n=this.cropSession;if(n===null)return null;let o=I(this._scene,n.id);if(o===void 0)return null;let a=this.pendingCropElement(o),r=CO(a),s=this._scene.viewport.zoom||1,i=h4/s;for(let c of _O){let u=r[c];if(Math.hypot(t.x-u.x,t.y-u.y)<=i)return c}let l=li(a,t);return l.x>=0&&l.x<=n.width&&l.y>=0&&l.y<=n.height?"body":null}beginImageCropHandle(t,n){this.cropSession!==null&&(this.cropSession={...this.cropSession,drag:{kind:"handle",handle:t},dragStartWorld:n})}beginImageCropBody(t){this.cropSession!==null&&(this.cropSession={...this.cropSession,drag:{kind:"body"},dragStartWorld:t})}updateImageCropDrag(t){let n=this.cropSession;if(n?.drag==null||n.dragStartWorld===null)return;let o=I(this._scene,n.id);if(o===void 0)return;let a=o.crop??Wy;if(n.drag.kind==="handle"){let r=EO(o,a,n.drag.handle,t);this.cropSession={...n,crop:r.crop,position:r.position,width:r.width,height:r.height}}else{let r=TO(o,a,n.dragStartWorld,t);this.cropSession={...n,crop:r.crop}}this.notify()}endImageCropDrag(){this.cropSession!==null&&(this.cropSession={...this.cropSession,drag:null,dragStartWorld:null})}commitImageCrop(){let t=this.cropSession;if(t===null)return;let n=IO(this._scene,t.id,{crop:t.crop,position:t.position,width:t.width,height:t.height});this.cropSession=null,n&&(this._scene=n.scene,this._history.push(n.patch)),this.setMode("select"),this.refreshCursor(),this.notify()}cancelImageCrop(){this.cropSession!==null&&(this.cropSession=null,this.setMode("select"),this.refreshCursor(),this.notify())}pendingCropElement(t){let n=this.cropSession;return n===null?t:{...t,position:n.position,width:n.width,height:n.height}}cropFrameCorners(){let t=this.cropSession;if(t===null)return null;let n=I(this._scene,t.id);if(n===void 0)return null;let o=this.pendingCropElement(n),a=Re(o);return[{x:a.x,y:a.y},{x:a.x+a.width,y:a.y},{x:a.x+a.width,y:a.y+a.height},{x:a.x,y:a.y+a.height}].map(r=>Mn(o,r))}cropGhost(){let t=this.cropSession;if(t===null)return null;let n=I(this._scene,t.id);if(n===void 0)return null;let o=n.crop??Wy;return{element:n,fullRect:qy(n,o)}}updateTextProps(t,n){if(this.readOnly)return;let o=dR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}adjustSelectionFontSize(t){if(this.readOnly)return;let n=fR(this._scene,this._selection,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}setLink(t,n){if(this.readOnly)return;let o=n===null?null:lO(n),a=cO(this._scene,t,o);a&&(this._scene=a.scene,this._history.push(a.patch),this.notify())}openLink(t){let n=Gy(t);!n||typeof window>"u"||window.open(n,"_blank","noopener,noreferrer")}elementLink(t){return Gy(I(this._scene,t)?.href)}linkAt(t){let n=this.acceleratedElementAt(t);if(!n||!this.isElementInteractable(n))return null;let o=Gy(n.href);return o?{id:n.id,href:o,bounds:z(n)}:null}bringToFront(t){if(this.readOnly)return;let n=YR(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}sendToBack(t){if(this.readOnly)return;let n=KR(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}bringForward(t){if(this.readOnly)return;let n=$R(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}sendBackward(t){if(this.readOnly)return;let n=QR(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}flipSelection(t){this.commitArrange(XO(this._scene,this._selection,t))}alignSelection(t){this.commitArrange(YO(this._scene,this._selection,t))}distributeSelection(t){this.commitArrange(KO(this._scene,this._selection,t))}rotateSelection(t){let n=[],o=new Map;for(let r of this._selection){let s=I(this._scene,r);s!==void 0&&(n.push(s),o.set(r,{position:s.position,rotation:s.rotation}))}if(n.length===0)return;let a=$O(n);this.commitArrange(RS(this._scene,o,a,t))}commitArrange(t){if(this.readOnly||t.length===0)return;let n=this._history.transaction();for(let o of t)this._scene=Q(this._scene,o),n.add(o);n.commit(),this.notify()}compactLayerZOrder(t,n={}){let o=n.recordHistory??!0,a=t?[t]:[...this._scene.layers.keys()],r=o?this._history.transaction():null;if(JR(this._scene,a,(i,l)=>{this._scene=i,r?.add(l)})===0){r?.cancel();return}r?.commit(),this.notify(),o&&this.announce(`Compacted z-order across ${a.length} layer(s)`)}clear(){this.readOnly||this._scene.elements.size===0&&this._scene.links.size===0||(this._scene={...this._scene,elements:new Map,links:new Map},this._selection=Pe,this._selectedLinks=yt,this._history.clear(),this.notify())}get activeLayerId(){return this._activeLayerId}setActiveLayer(t){this._scene.layers.has(t)&&this._activeLayerId!==t&&(this._activeLayerId=t,this.notify())}createLayer(t){let n=RR(this._scene,t,zR(++this.nextId));return this._scene=n.scene,this._history.push(n.patch),this._activeLayerId=n.layerId,this.notify(),n.layerId}removeLayer(t){let n=OR(this._scene,t,this._activeLayerId);if(!n)return;let o=this._history.transaction();this._scene=n.scene;for(let a of n.patches)o.add(a);o.commit(),this._activeLayerId=n.nextActiveLayerId,this._selection=Pe,this.notify()}renameLayer(t,n){let o=DR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}toggleLayerVisibility(t){let n=PR(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}toggleLayerLock(t){let n=BR(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}moveSelectionToLayer(t){if(this.readOnly)return;let n=NR(this._scene,this._selection,t);if(!n)return;let o=this._history.transaction();this._scene=n.scene;for(let a of n.patches)o.add(a);o.commit(),this.notify()}panBy(t){let n=WM(this._scene,t);n&&(this._scene=n,this.notify())}zoomIn(){this.zoomStep(y2)}zoomOut(){this.zoomStep(1/y2)}zoomStep(t){let n=this._scene.viewport;if(n.size.width<=0||n.size.height<=0)return;let o=this.screenToWorld({x:n.size.width/2,y:n.size.height/2});this.zoomAt(t,o)}resetZoom(){let t=jM(this._scene);t&&(this._scene=t,this.notify())}zoomToFit(t=40){let n=ZM(this._scene,t);n&&(this._scene=n,this.notify())}zoomToSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=hS(this._scene,n,t);o&&(this._scene=o,this.notify())}revealSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=VM(this._scene,n,t);o&&(this._scene=o,this.notify())}selectClosest(t){let n=this.combinedSelectionBounds(),o=this._scene.viewport,a=n?{x:n.x+n.width/2,y:n.y+n.height/2}:{x:o.pan.x+o.size.width/2/o.zoom,y:o.pan.y+o.size.height/2/o.zoom},r=xS(this._scene,this._selection,t,a,s=>this.isElementInteractable(s));r!==null&&this.setSelection([r])}zoomAt(t,n){let o=qM(this._scene,t,n);o&&(this._scene=o,this.notify())}setViewportSize(t,n){let o=XM(this._scene,t,n);o&&(this._scene=o,this.notify())}setGrid(t){let n=YM(this._scene,t);n&&(this._scene=n,this.notify())}get snapToGridEnabled(){return I0(this._scene.viewport)}setSnapToGrid(t){this.setGrid({snap:t})}setSnapSuppressed(t){this.interaction.snapSuppressed=t}setTransformModifiers(t){this.interaction.transformAltKey=t.alt,this.interaction.transformShiftKey=t.shift}snapActive(){let t=this._scene.viewport;return!this.interaction.snapSuppressed&&t.gridEnabled&&I0(t)}snapSpacing(){return NA()}loadScene(t,n={}){if(this.gestureTx&&(this.gestureTx.cancel(),this.gestureTx=null),this._scene=t,!t.layers.has(this._activeLayerId)){let o=t.layers.keys().next().value;this._activeLayerId=o??ln(Rn)}n.preserveHistory?this.pruneSelection():(this._selection=Pe,this._history.clear()),rS(this),sS(this),this.notify(),this.maybeAnimate()}dispose(){this.cancelLongPress(),this.unbind(),this.actor.stop(),this.listeners.clear(),this.cursorListeners.clear(),this.longPressListeners.clear(),this.announceListeners.clear(),this.animation.detach(),this.animationContentOff?.(),this.renderRafId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this.renderRafId),this.renderRafId=null)}bindPointerEvents(){return JM(this)}beginPanGesture(t,n,o){this.actor.send({type:"POINTER_CANCEL"}),this.cancelGesture(),this.cancelLongPress(),this.host.setPointerCapture(t),this.panGesture={pointerId:t,button:n,startPoint:o,lastPoint:o,moved:!1},this.refreshCursor()}endPanGesture(){let t=this.panGesture;if(this.panGesture=null,t&&(t.button===2||t.button===1)&&!t.moved){let n=this.screenToWorld(t.startPoint);for(let o of this.longPressListeners)o({screenPoint:t.startPoint,worldPoint:n})}this.refreshCursor()}isDrawingPhase(t){return t.mode==="draw-rect"||t.mode==="draw-ellipse"||t.mode==="draw-edge"}startLongPress(t){this.longPress.start(t)}cancelLongPress(){this.longPress.cancel()}beginPinch(){this.pinch.begin([...this.activePointers.values()])}applyPinch(){this.pinch.apply([...this.activePointers.values()])}screenToWorld(t){return N.applyToPoint(Wa(this._scene.viewport),t)}linkAttachTargetAt(t){let n=this.acceleratedElementAt(t);if(n&&this.isElementInteractable(n)){let o=this.promoteToGroupRoot(n);return{kind:"element",id:o.id,bounds:z(o)}}}hitTest(t){return z5(t,{scene:this._scene,selection:this._selection,selectedLink:this.selectedLink,selectedLinkCount:this._selectedLinks.size,enteredGroup:this._enteredGroup,handleHitSlop:this.handleHitSlop,edgeHandleHitSlop:this.edgeHandleHitSlop,edgeHitThreshold:this.edgeHitThreshold,hitAnnotation:n=>this.hitAnnotation(n),selectionIsAspectLocked:()=>this.selectionIsAspectLocked(),combinedSelectionBounds:()=>this.combinedSelectionBounds(),acceleratedElementAt:n=>this.acceleratedElementAt(n),isElementInteractable:n=>this.isElementInteractable(n),isLayerLocked:n=>this.isLayerLocked(n),promoteToGroupRoot:n=>this.promoteToGroupRoot(n)})}refreshCursor(t){let n=ZR(this,t??this.lastPointerWorld);this.host.style.cursor!==n&&(this.host.style.cursor=n)}setCursorOverride(t,n){n===null?this.cursorOverrides.delete(t):this.cursorOverrides.set(t,n),this.refreshCursor()}getCursorOverride(t){return this.cursorOverrides.get(t)}isLayerLocked(t){return this._scene.layers.get(t)?.locked===!0}isElementInteractable(t){return!(this.isLayerLocked(t.layerId)||ic(this._scene,t))}isElementManipulable(t){return!(this.isLayerLocked(t.layerId)||xA(this._scene,t)||ic(this._scene,t))}toggleLockSelection(){if(this.readOnly||this._selection.size===0)return;let t=[...this._selection],n=t.some(a=>I(this._scene,a)?.locked!==!0),o=this._history.transaction();for(let a of t){let r=J(this._scene,a,s=>{let i={...s};return n?i.locked=!0:delete i.locked,i});this._scene=r.scene,o.add(r.patch)}o.commit(),this.notify()}promoteToGroupRoot(t){return iM(this._scene,t,this._enteredGroup)}topGroupAncestor(t){return sM(this._scene,t)}isDescendantOfGroup(t,n){return aS(this._scene,t,n)}computeHiddenElements(){return GO(this._scene)}computeStrokeErasePreview(){let t=this.eraseStroke;if(!t||!t.strokeMode||t.erased.size===0)return null;let n=wR(this._scene,t.erased);return n?{elements:n.fragments,hidden:n.hidden}:null}computeDimElements(t){return lM(this._scene,this._selection,t)}computeDimSet(){let t=this._enteredGroup?this.computeDimElements(this._enteredGroup):void 0,n=this.interaction.eraseStroke?.pending;if(!n||n.size===0)return t;let o=new Set(t);for(let a of n)o.add(a);return o}enterGroup(t){this._enteredGroup=t,this.notify()}enterContainer(){if(this._selection.size!==1)return;let t=v([...this._selection][0]),n=I(this._scene,t);if(!n)return;let o=Be(n),a=[];for(let r of this._scene.elements.values())(r.parentId===t||o&&r.frameId===t)&&a.push(r.id);a.length!==0&&(ze(n)&&(this._enteredGroup=t),this.setSelection(a))}exitContainer(){if(this._selection.size===0)return;let t,n=!0;for(let o of this._selection){let a=I(this._scene,o),r=a?.parentId??a?.frameId;if(r===void 0){n=!1;break}if(t===void 0)t=r;else if(t!==r){n=!1;break}}this._enteredGroup=null,n&&t!==void 0?this.setSelection([t]):this.notify()}get enteredGroup(){return this._enteredGroup}acceleratedElementAt(t){return this._scene.elements.size<x2?ci(this._scene,t):vA(this._scene,this.ensureSpatialIndex(),t)}ensureSpatialIndex(){let t=this.spatialIndexCache;if(t?.scene===this._scene)return t.index;let n=AA(this._scene);return this.spatialIndexCache={scene:this._scene,index:n},n}routeIsolationClick(t,n){let o=performance.now(),a=o-this.interaction.lastClickAt<G0&&this.interaction.lastClickWorldPoint!==null&&U.distance(this.interaction.lastClickWorldPoint,n)<=W0;if(this.interaction.lastClickAt=o,this.interaction.lastClickWorldPoint=n,a){let r=this.frameHeaderAt(n);if(r!==null)return this.beginFrameNameEdit(r),!0}if(!t)return!1;if(this._enteredGroup!==null){let r=t.type==="SELECT_REPLACE"||t.type==="SELECT_TOGGLE"?t.id:null;if(!(r!==null&&this.isDescendantOfGroup(r,this._enteredGroup)))return this._enteredGroup=null,this.notify(),!1}if(a&&t.type==="SELECT_EDGE_REPLACE")return this._selectedLinks=By(t.id),this._selection=Pe,this.beginLinkCaptionEdit(t.id),!0;if(a&&(t.type==="SELECT_REPLACE"||t.type==="SELECT_TOGGLE")){let r=this.acceleratedElementAt(n);if(r!==void 0&&fe(r))return this.beginTextEdit(r.id),!0;if(r!==void 0&&Be(r))return this.beginFrameNameEdit(r.id),!0;if(r){let s=this.topGroupAncestor(r),i=this.pickDrillTarget(r,s);if(i)return this._enteredGroup=i.id,this._selection=wt(r.id),this._selectedLinks.size>0&&(this._selectedLinks=yt),this.notify(),!0}}return!1}pickDrillTarget(t,n){return cM(this._scene,t,n,this._enteredGroup)}applyEmit(t){if(!(this._readOnly&&Zq.has(t.type)))switch(t.type){case"SELECT_REPLACE":this._selection=wt(t.id),this._selectedLinks=yt,this.notify();return;case"SELECT_TOGGLE":this._selection=tA(this._selection,t.id),this.notify();return;case"SELECT_CLEAR":this._selection=Pe,this._selectedLinks=yt,this.notify();return;case"SELECT_EDGE_REPLACE":this._selectedLinks=By(t.id),this._selection=Pe,this.notify();return;case"SELECT_EDGE_TOGGLE":this._selectedLinks=UM(this._selectedLinks,t.id),this.notify();return;case"SELECT_EDGE_CLEAR":this._selectedLinks.size>0&&(this._selectedLinks=yt,this.notify());return;case"UPDATE_EDGE_ENDPOINT_PREVIEW":this.applyLinkEndpointMove(t.linkId,t.side,t.toPoint);return;case"UPDATE_EDGE_ENDPOINT":this.applyLinkEndpointUpdate(t);return;case"LASSO_PROGRESS":this.interaction.lassoBaseSelection??=this._selection,this.interaction.lassoBaseLinks??=this._selectedLinks,this.lassoPreview=t.bounds,this.applyLassoLiveSelection(t.bounds,t.mode),this.notify();return;case"LASSO_CLEAR":(this.lassoPreview!==null||this.interaction.lassoBaseSelection!==null||this.interaction.lassoBaseLinks!==null)&&(this.lassoPreview=null,this.interaction.lassoBaseSelection=null,this.interaction.lassoBaseLinks=null,this.notify());return;case"SELECT_BY_BOUNDS":this.interaction.lassoBaseSelection=null,this.interaction.lassoBaseLinks=null,this.applySelectByBounds(t.bounds,t.mode);return;case"MOVE_SHAPE":this.groupMoveOrigin?this.applyGroupMove(t.delta):this.applyMove(t.id,t.delta,t.originalBounds);return;case"RESIZE_GROUP":this.applyGroupResize(t.handle,t.delta,t.originalBounds);return;case"RESIZE_SHAPE":this.applyResize(t.id,t.handle,t.delta,t.originalBounds);return;case"ROTATE":this.applyRotate(t.deltaAngle);return;case"CREATE_SHAPE":this.applyCreate(t.shapeType,t.bounds);return;case"CREATE_EDGE":this.applyCreateLink(t);return;case"DRAW_EDGE_PREVIEW":this.applyLinkPreview(t.fromElement,t.fromPoint,t.toPoint);return;case"DRAW_EDGE_PREVIEW_CLEAR":this.edgePreview&&(this.edgePreview=null,this.notify());return;case"TEMPLATE_TAP":for(let n of this.templateTapListeners)n(t);return;case"TEMPLATE_DROP":for(let n of this.templateDropListeners)n(t);return;case"MOVE_ANNOTATION":this.applyAnnotationMove(t.id,t.delta,t.originalPosition);return;case"COMMIT_ANNOTATION_DRAG":this.finalizeOpenGestureTx();return}}applyAnnotationMove(t,n,o){let a=ZO(this._scene,t,n,o);a&&(this._scene=a.scene,this.recordGesturePatch(a.patch),this.notify())}templateTapListeners=new Set;templateDropListeners=new Set;onTemplateTap(t){return this.templateTapListeners.add(t),()=>this.templateTapListeners.delete(t)}onTemplateDrop(t){return this.templateDropListeners.add(t),()=>this.templateDropListeners.delete(t)}dispatchTemplateDrop(t){this.applyEmit(t)}applyMove(t,n,o){let a=I(this._scene,t);if(a&&!this.isElementManipulable(a))return;let r=this.interaction.transformShiftKey?TS(n):n,s=this.snapActive()?e8(o,r,this.snapSpacing()):r,i=jO(this._scene,t,s,o);i&&(this._scene=Q(this._scene,i),this.recordGesturePatch(i),this.notify())}applyGroupMove(t){if(!this.groupMoveOrigin)return;let n=this.interaction.transformShiftKey?TS(t):t,o=this.snapActive()?t8(this.groupMoveOrigin,n,this.snapSpacing()):n,a=VO(this._scene,this.groupMoveOrigin,o);for(let r of a)this._scene=Q(this._scene,r),this.recordGesturePatch(r);if(this.groupLinkMoveOrigin){let r=PM(this._scene,this.groupLinkMoveOrigin,o);for(let s of r)this._scene=Q(this._scene,s),this.recordGesturePatch(s)}this.notify()}computeViewportWorld(){return HO(this._scene)}computeDirtyWorld(){let t=this.lastRenderedScene,n=this._scene;if(!t||t.viewport.size.width<=0||t.viewport.size.height<=0||n.viewport.size.width<=0||n.viewport.size.height<=0||this.gestureTx!==null||this.dragElementId!==null||this.drawingPreview!==null||this.edgePreview!==null||this.brushStroke!==null||this.lassoPreview!==null||this.interaction.eraseStroke!==null&&this.eraseDirty||t.viewport!==n.viewport||t.layers!==n.layers||this.lastRenderedEnteredGroup!==this._enteredGroup||this.lastRenderedEraseActive)return null;let{world:o,tileDirty:a}=SM(t,n);if(this.tileComposeFn!==null)for(let[r,s]of a)this.tileDirtyElements.set(r,s);return o}combinedSelectionBounds(){let t=UO(this._scene,this._selection);for(let n of this._selectedLinks){let o=be(this._scene,n);if(!o)continue;let a=ot(this._scene,o);if(!a||a.length===0)continue;let r=1/0,s=1/0,i=-1/0,l=-1/0;for(let u of a)u.x<r&&(r=u.x),u.y<s&&(s=u.y),u.x>i&&(i=u.x),u.y>l&&(l=u.y);let c={x:r,y:s,width:i-r,height:l-s};t=t?V.union(t,c):c}return t}groupChildrenUnion(t){return Xy(this._scene,t)}selectionIsAspectLocked(){if(this._selection.size===0)return!1;if(this._selection.size===1){let[t]=[...this._selection];if(!t)return!1;let n=I(this._scene,t)?.type;return n==="group"||n==="image"}for(let t of this._selection){let n=I(this._scene,t);if(n===void 0||!ct(n))return!1}return!0}applyRotate(t){let n=this.rotateGestureOrigin;if(!n)return;let o=this.interaction.transformShiftKey?Math.round(t/a2)*a2:t,a=RS(this._scene,n.origin,n.pivot,o);for(let r of a)this._scene=Q(this._scene,r),this.recordGesturePatch(r);this.notify()}applyGroupResize(t,n,o){if(!this.groupResizeOrigin)return;let a=this.snapActive()?OS(o,t,n,this.snapSpacing()):n,r=HM(this._scene,this.groupResizeOrigin,t,a,o,this.selectionIsAspectLocked()||this.interaction.transformShiftKey,this.interaction.transformAltKey);this._scene=r.scene;for(let s of r.patches)this.recordGesturePatch(s);this.notify()}applyResize(t,n,o,a){let r=I(this._scene,t);if(r!==void 0&&!fe(r)&&r.rotation!==0){this.interaction.resizeOriginElement?.id!==t&&(this.interaction.resizeOriginElement=r);let l=zM(this._scene,this.interaction.resizeOriginElement,n,o,this.interaction.transformShiftKey,this.interaction.transformAltKey);if(!l)return;this._scene=l.scene,this.recordGesturePatch(l.patch),this.notify();return}let s=this.snapActive()?OS(a,n,o,this.snapSpacing()):o;if(r!==void 0&&fe(r)){this.interaction.resizeOriginElement?.id!==t&&(this.interaction.resizeOriginElement=r);let l=this.interaction.resizeOriginElement,c=fe(l)?l:r,u=FM(this._scene,c,n,s,a,this.interaction.transformAltKey);if(!u)return;this._scene=u.scene,this.recordGesturePatch(u.patch),this.notify();return}let i=NM(this._scene,t,n,s,a,(l,c,u)=>this.clampContainerToChildren(l,c,u),this.interaction.transformShiftKey,this.interaction.transformAltKey);i&&(this._scene=i.scene,this.recordGesturePatch(i.patch),this.notify())}applyCreate(t,n){let o=zc(++this.nextId),a=this.snapActive()?n8(n,this.snapSpacing()):n,r=pO(this._scene,t,a,o,this._activeLayerId,()=>this.nextFrameName());this._scene=r.scene,this._selection=wt(o),this._history.push(r.patch),t==="frame"&&this.assignFrameMembers(o,a),this.maybeRevertModeAfterCreate(),this.notify()}nextFrameName(){return uM(this._scene)}assignFrameMembers(t,n){this._scene=dM(this._scene,this._history,t,n)}reconcileFrameMembership(){this._scene=fM(this._scene,this._history)}applyCreateLink(t){let n=this.snapLinkEndpoint(t.fromElement,t.fromPoint),o=this.snapLinkEndpoint(t.toElement,t.toPoint),a=Up(++this.nextId),r=Hp(this._scene,n,o,a,this._activeLayerId);this._scene=r.scene,this._history.push(r.patch),this.edgePreview=null,this.maybeRevertModeAfterCreate(),o.kind==="point"&&(this.interaction.pendingLinkDropMenu={linkId:a,side:"to",world:o.position}),this.notify()}get linkDropMenu(){return this.interaction.pendingLinkDropMenu}placeShapeAtLinkDrop(t){let n=this.interaction.pendingLinkDropMenu;if(!n)return;if(!be(this._scene,n.linkId)){this.interaction.pendingLinkDropMenu=null,this.notify();return}let a=zc(++this.nextId),r=LO(this._scene,this._activeLayerId,n,a,t),s=this._history.transaction();this._scene=r.scene,s.add(r.addPatch),s.add(r.linkPatch),s.commit(),this.interaction.pendingLinkDropMenu=null,this._selection=wt(a),this._selectedLinks=yt,this.notify()}dismissLinkDropMenu(){this.interaction.pendingLinkDropMenu&&(this.interaction.pendingLinkDropMenu=null,this.notify())}createLinkedElementFromAnchor(t,n){let o=zc(++this.nextId),a=Up(++this.nextId),r=vO(this._scene,this._activeLayerId,t,n,o,a);if(!r)return;let s=this._history.transaction();this._scene=r.scene,s.add(r.addPatch),s.add(r.linkPatch),s.commit(),this._selection=wt(o),this._selectedLinks.size>0&&(this._selectedLinks=yt),this.notify()}previewClickCreate(t,n){return AO(this._scene,this._activeLayerId,t,n)}snapLinkEndpoint(t,n){return uO(this._scene,this.snapEngine,this.snapThreshold,t,n)}applySelectByBounds(t,n){let o=WO(this._scene,this._selection,s=>this.isLayerLocked(s),t,n),a=ES(this._scene,n==="add"?this._selectedLinks:yt,s=>this.isLayerLocked(s),t,n),r=!Np(a,this._selectedLinks);if(this._selectedLinks=a,oi(o,this._selection)&&!r){this.notify();return}this._selection=o,this.notify()}applyLassoLiveSelection(t,n){let o=this.interaction.lassoBaseSelection??Pe,a=qO(this._scene,o,l=>this.isLayerLocked(l),t,n),r=this.interaction.lassoBaseLinks??yt,s=ES(this._scene,r,l=>this.isLayerLocked(l),t,n),i=!Np(s,this._selectedLinks);oi(a,this._selection)&&!i||(this._selectedLinks=s,this._selection=a)}applyLinkEndpointMove(t,n,o){this.linkHandles.applyEndpointMove(t,n,o)}applyLinkEndpointUpdate(t){this.linkHandles.applyEndpointUpdate(t)}get isDraggingWaypoint(){return this.linkHandles.isDraggingWaypoint}beginWaypointDrag(t,n,o){this.linkHandles.beginWaypointDrag(t,n,o)}updateWaypointDrag(t){this.linkHandles.updateWaypointDrag(t)}endWaypointDrag(){this.linkHandles.endWaypointDrag()}get isDraggingSegment(){return this.linkHandles.isDraggingSegment}beginSegmentDrag(t,n,o){this.linkHandles.beginSegmentDrag(t,n,o)}updateSegmentDrag(t){this.linkHandles.updateSegmentDrag(t)}endSegmentDrag(){this.linkHandles.endSegmentDrag()}isHandleDoubleClick(t){return this.linkHandles.isHandleDoubleClick(t)}deleteWaypoint(t,n){this.linkHandles.deleteWaypoint(t,n)}resetSegmentPin(t,n,o,a){this.linkHandles.resetSegmentPin(t,n,o,a)}get selectedLinkAvoidsObstacles(){let t=this.selectedLink;return t===null?!1:be(this._scene,t)?.avoidObstacles===!0}setSelectedLinkAvoidObstacles(t){if(this.readOnly)return;let n=this.selectedLink;if(n===null)return;let o=be(this._scene,n);if(!o||o.avoidObstacles===t)return;let a=et(this._scene,n,r=>({...r,avoidObstacles:t,...t?{routing:"orthogonal"}:{}}));this._scene=a.scene,this._history.push(a.patch),this.elbowRoutes.delete(n),this.notify()}updateHoveredLinkTarget(t){let n=this.acceleratedElementAt(t);if(!n){this.hoveredLinkTarget!==null&&(this.hoveredLinkTarget=null,this.notify());return}let a=this.snapEngine.snap({scene:this._scene,probe:t,threshold:this.snapThreshold,gesture:"draw-edge"}).all.filter(p=>p.metadata?.elementId===n.id),r=a.find(p=>p.kind==="anchor"),s=a.find(p=>p.kind==="outline"),i=r?.metadata?.ref,l=dA(i)?i:void 0,c=null;l?.kind==="named"?c=l.name:l?.kind==="edge"&&l.t===.5&&(c=`edge-${l.index}`);let u=!c&&s?s.snapped:void 0,d=this.hoveredLinkTarget;if(d?.elementId===n.id&&d.activeAnchor===c&&d.outlinePoint?.x===u?.x&&d.outlinePoint?.y===u?.y)return;let f=c!==null||u?"point":"element";this.hoveredLinkTarget={elementId:n.id,activeAnchor:c,outlinePoint:u,mode:f},this.notify()}applyLinkPreview(t,n,o){let a=NO(this._scene,t,n,o);if(hi==="orthogonal"){let r=this.hitTest(a.to),s=r.kind==="element"?r.id:null,i=o2(this._scene,t,a.from,s,a.to);this.edgePreview={...a,points:i}}else this.edgePreview=a;this.notify()}recordGesturePatch(t){this.gestureTx===null&&(this.gestureStartScene=Q(this._scene,pc(t))),this.gestures.record(t)}commitGesture(){this.interaction.resizeOriginElement=null,this.rotateGestureOrigin=null,this.gestures.commit(),this.gestureStartScene=null}finalizeOpenGestureTx(){this.gestures.finalize()}applyContainerDrop(t){kM(this.containerOpsRef,t)}maybeGrowContainer(t,n){Pp(this.containerOpsRef,t,n)}clampContainerToChildren(t,n,o){return LM(this._scene,t,n,o)}beginOrAttachGesture(){return this.gestureTx??=this._history.transaction(),this.gestureTx}cancelGesture(){this.interaction.resizeOriginElement=null,this.interaction.rotateGestureOrigin=null,this.gestures.cancel(),this.gestureStartScene!==null&&(this._scene=this.gestureStartScene,this.gestureStartScene=null)}pruneSelection(){let t=null;for(let n of this._selection)this._scene.elements.has(n)||(t??=new Set(this._selection),t.delete(n));t!==null&&(this._selection=t)}notify(){this.scheduleRender(),hM(this.eventCache,this.events,this.observableSnapshot());for(let t of this.listeners)t();this.autoCompactScheduler.schedule(),this.autoLayoutScheduler.schedule(),this.maybeAnimate()}renderRafId=null;animationContentOff=null;scheduleRender(){if(this.renderRafId===null){if(typeof requestAnimationFrame>"u"){this.render();return}this.renderRafId=requestAnimationFrame(()=>{this.renderRafId=null,this.render()})}}forceRender(){this.renderRafId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this.renderRafId),this.renderRafId=null),this.render()}on(t,n){return this.events.on(t,n)}off(t,n){this.events.off(t,n)}runLayout(t){let n=Jf(this._scene,t);return n?(this._scene=Q(this._scene,n),this._history.push(n),this.autoLayoutScheduler.resetSignature(t),this.notify(),n):null}elbowRoutes=new Map;rerouteElbows(){let t=this._scene;for(let[n,o]of this._scene.links){if((o.routing??"straight")!=="orthogonal")continue;let a=FO(this._scene,o);if(this.elbowRoutes.get(n)?.sig===a)continue;let r=tp(t,o);this.elbowRoutes.set(n,{sig:a,points:r}),t=et(t,n,s=>({...s,routedPoints:r})).scene}this._scene=t}buildRenderSnapshot(){let t=this.computeStrokeErasePreview(),n=this.computeHiddenElements(),o=t===null?n:new Set([...n??[],...t.hidden]);return{mainTarget:this.mainTarget,overlayTarget:this.overlayTarget,backgroundTarget:this.backgroundTarget,scene:this._scene,selection:this._selection,selectedLinks:this._selectedLinks,selectedLink:this.selectedLink,selectedAnnotation:this._selectedAnnotation,enteredGroup:this._enteredGroup,gridEnabled:this.gridEnabled,viewportWorld:this.computeViewportWorld(),dirtyWorld:this.computeDirtyWorld(),dimElements:this.computeDimSet(),eraseActive:(this.interaction.eraseStroke?.pending.size??0)>0,hideElements:o,strokeErasePreview:t,sharedIndex:this._scene.elements.size>=x2?this.ensureSpatialIndex():null,boundsCache:this.boundsCache,animationClock:a=>this.gifPlayback.clock(Ze(typeof a.id=="string"?a.id:"")),tileComposeFn:this.tileComposeFn,tileDirtyElements:this.tileDirtyElements,mode:this.mode,activeLayerId:this._activeLayerId,cropFrame:this.cropFrameCorners(),cropGhost:this.cropGhost(),flowchartPreview:this.flowchartPreview,lassoPreview:this.lassoPreview,drawingPreview:this.drawingPreview,edgePreview:this.edgePreview,linkDragFromAnchor:this.linkDragFromAnchor,hoveredLinkTarget:this.hoveredLinkTarget,panGesture:this.panGesture,pinchActive:this.pinch?.isActive()??!1,gestureActive:this.gestureTx!==null,linkEndpointDrag:this.linkEndpointDrag,linkSegmentDrag:this.linkSegmentDrag,linkWaypointDrag:this.linkWaypointDrag,hoverCursorWorld:this.hoverCursorWorld,anchorStartHitSlop:this.anchorStartHitSlop,anchorClickRadius:this.anchorClickRadius,containerHover:this.containerHover,brushStroke:this.brushPreviewStroke,laserStrokes:this.interaction.laserStrokes,eraserTrail:this.interaction.eraserTrail,eraserCursor:this.mode==="erase"&&!this._readOnly&&this.lastPointerWorld!==null?{center:this.lastPointerWorld,radius:this._brushSettings.width}:null,peerCursors:this._peerCursors,peerSelections:this._peerSelections,debugHitZones:this.debugHitZones,readOnly:this._readOnly,groupMoveOrigin:this.groupMoveOrigin,aspectLocked:this.selectionIsAspectLocked(),combinedSelectionBounds:this.combinedSelectionBounds(),editingText:this.editingTextOverlay(),previewClickCreate:(a,r)=>this.previewClickCreate(a,r),isPlaybackPaused:a=>this.isPlaybackPaused(a)}}render(){this.rerouteElbows(),this.pruneLaser();let t=this.buildRenderSnapshot();PO(t),this.lastRenderedScene=this._scene,this.lastRenderedEnteredGroup=this._enteredGroup,this.lastRenderedEraseActive=t.eraseActive,this.eraseDirty=!1;let n=t.dimElements!==void 0&&t.dimElements.size>0||t.hideElements!==void 0&&t.hideElements.size>0;t.tileComposeFn&&t.viewportWorld&&!n&&(this.tileDirtyElements=new Map),this.onAfterRender?.()}},Yq=e=>!e||typeof e!="object"?!1:typeof e.push=="function"&&typeof e.undo=="function"&&typeof e.redo=="function"&&typeof e.transaction=="function";var DS=P(se(),1),Uc=P(re(),1),Ky=({open:e,onClose:t,title:n="Dialog",children:o,dismissOnBackdrop:a=!0,className:r,style:s})=>{let i=(0,Uc.useRef)(null),l=(0,Uc.useRef)(null);if((0,Uc.useEffect)(()=>{if(!e)return;l.current=document.activeElement;let d=p=>{p.key==="Escape"&&(p.preventDefault(),t())};window.addEventListener("keydown",d);let f=i.current;return f&&(f.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??f).focus(),()=>{window.removeEventListener("keydown",d),l.current?.focus()}},[e,t]),(0,Uc.useEffect)(()=>{if(!e)return;let d=f=>{if(f.key!=="Tab")return;let p=i.current;if(!p)return;let h=p.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(h.length===0)return;let m=h[0],x=h[h.length-1];if(m===void 0||x===void 0)return;let y=document.activeElement;f.shiftKey&&y===m?(f.preventDefault(),x.focus()):!f.shiftKey&&y===x&&(f.preventDefault(),m.focus())};return window.addEventListener("keydown",d,!0),()=>{window.removeEventListener("keydown",d,!0)}},[e]),!e)return null;let c={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},u={background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",border:"1px solid var(--border, #2a2a2a)",borderRadius:8,boxShadow:"0 8px 32px rgba(0, 0, 0, 0.45)",maxWidth:"calc(100vw - 64px)",maxHeight:"calc(100vh - 64px)",overflow:"auto",outline:"none",...s};return(0,DS.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":n,style:c,onClick:d=>{a&&d.target===d.currentTarget&&t()},children:(0,DS.jsx)("div",{ref:i,tabIndex:-1,className:r,style:u,onClick:d=>{d.stopPropagation()},children:o})})};var Kq={history:"History",selection:"Selection",clipboard:"Clipboard","z-order":"Z-order",grouping:"Grouping",zoom:"Zoom",mode:"Tools",layout:"Layout",arrange:"Arrange",edit:"Editing",other:"Other"},$q=["mode","edit","selection","clipboard","history","z-order","grouping","arrange","layout","zoom","other"],PS=e=>{(0,Gc.useEffect)(()=>{let t=n=>{let o=n.target;o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement||!(n.key==="?"||n.shiftKey&&n.key==="/")||(n.preventDefault(),e())};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[e])},Qq=e=>{let t=[],n=e.hotkey??e.displayHotkey;if(n){let o=Array.isArray(n)?n:[n];for(let a of o)t.push(ky(a))}if(e.sequence&&e.sequence.length>0){let o=e.sequence.map(a=>a.length===1?a.toUpperCase():a).join(" ");t.push([o])}return t},Wp=({registry:e=_e,open:t,onClose:n,title:o="Keyboard shortcuts",extraSections:a})=>{let r=(0,Gc.useMemo)(()=>{let c=new Map;for(let d of e.getAll()){if(!d.label)continue;let f=d.category??"other",p=c.get(f)??[];p.push({label:d.label,keys:Qq(d)}),c.set(f,p)}let u=[];for(let d of $q){let f=c.get(d);!f||f.length===0||u.push({title:Kq[d],rows:f})}return a&&u.push(...a),u},[e,a]),s={maxWidth:720,width:"calc(100vw - 64px)",display:"flex",flexDirection:"column"},i={padding:"16px 20px",borderBottom:"1px solid var(--du-ui-border)",display:"flex",alignItems:"center",justifyContent:"space-between"},l={padding:"16px 20px 20px",overflowY:"auto"};return(0,Ye.jsx)(Ky,{open:t,onClose:n,title:o,style:s,children:(0,Ye.jsxs)("div",{children:[(0,Ye.jsxs)("div",{style:i,children:[(0,Ye.jsx)("h2",{style:{margin:0,fontSize:16,fontWeight:600},children:o}),(0,Ye.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,Ye.jsx)("span",{className:"du-help-platform-badge",children:rs?"macOS":"Win / Linux"}),(0,Ye.jsx)("button",{type:"button","aria-label":"Close help",onClick:n,style:{background:"transparent",border:"none",color:"var(--du-text)",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:4},children:(0,Ye.jsx)(Na,{size:18,strokeWidth:1.75})})]})]}),(0,Ye.jsx)("div",{style:l,children:(0,Ye.jsx)("div",{className:"du-help-islands",children:r.map(c=>(0,Ye.jsxs)("section",{className:"du-help-island",children:[(0,Ye.jsx)("h3",{className:"du-help-island-title",children:c.title}),(0,Ye.jsx)("div",{className:"du-help-island-rows",children:c.rows.map(u=>(0,Ye.jsxs)("div",{className:"du-help-row",children:[(0,Ye.jsx)("span",{className:"du-help-row-label",children:u.label}),(0,Ye.jsx)(Jq,{combos:u.keys})]},u.label))})]},c.title))})})]})})},Jq=({combos:e})=>e.length===0?(0,Ye.jsx)("span",{className:"du-help-keys-separator",children:"\u2014"}):(0,Ye.jsx)("span",{className:"du-help-keys",children:e.map((t,n)=>(0,Ye.jsxs)(Gc.Fragment,{children:[n>0?(0,Ye.jsx)("span",{className:"du-help-keys-separator",children:"or"}):null,t.map((o,a)=>(0,Ye.jsx)("kbd",{className:"du-help-key",children:o},a))]},n))});var ej=16,tj=1.75,$y=({renderDialog:e})=>{let[t,n]=(0,o8.useState)(!1);return(0,ss.jsxs)(ss.Fragment,{children:[(0,ss.jsx)(Qn,{label:"Help",onClick:()=>{n(!0)},children:(0,ss.jsx)(Tn,{size:ej,strokeWidth:tj})}),e?e({open:t,onClose:()=>{n(!1)}}):(0,ss.jsx)(Wp,{open:t,onClose:()=>{n(!1)}})]})};var Zp=P(se(),1),r8=P(re(),1);var qp=P(re(),1);var a8=`(pointer: coarse), (max-width: ${640}px)`,nj=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(a8).matches:!1,jp=()=>(0,qp.useSyncExternalStore)(e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};let t=window.matchMedia(a8);return t.addEventListener("change",e),()=>{t.removeEventListener("change",e)}},nj,()=>!1),G=()=>Nb(),oj=WA(),Ya=()=>sn(e=>e.scene,oj,"scene"),Qy=()=>sn(e=>e.selection,qo.EMPTY,"selection"),Vp=()=>sn(e=>e.mode,"select","mode"),BS=()=>sn(e=>e.brushSettings,Nc),is=()=>sn(e=>e.readOnly,!1),NS=()=>{let e=G(),t=sn(r=>r.canUndo,!1,"history"),n=sn(r=>r.canRedo,!1,"history"),o=(0,qp.useCallback)(()=>{e?.undo()},[e]),a=(0,qp.useCallback)(()=>{e?.redo()},[e]);return{canUndo:t,canRedo:n,undo:o,redo:a}};var Zhe=ln(Rn);var zS=()=>sn(e=>e.selectedLink,null);var aj=14,rj=1.75,FS=()=>{let e=G(),t=Ya(),n=(0,r8.useMemo)(()=>sj(t),[t]);return!e||t.elements.size===0||!n?null:(0,Zp.jsxs)("button",{type:"button",className:"du-pill-button",onClick:()=>{e.zoomToFit()},title:"Reset view to fit all content",children:[(0,Zp.jsx)(Yd,{size:aj,strokeWidth:rj,"aria-hidden":!0}),(0,Zp.jsx)("span",{children:"Back to content"})]})},sj=e=>{if(e.elements.size===0)return!1;let t=e.viewport;if(t.size.width<=0||t.size.height<=0)return!1;let n=null;for(let c of e.elements.values()){let u=z(c);n=n?V.union(n,u):u}if(!n)return!1;let o=Wa(t),a=N.applyToPoint(o,{x:0,y:0}),r=N.applyToPoint(o,{x:t.size.width,y:t.size.height}),s={x:Math.min(a.x,r.x),y:Math.min(a.y,r.y),width:Math.abs(r.x-a.x),height:Math.abs(r.y-a.y)},i=n.x<s.x+s.width&&s.x<n.x+n.width,l=n.y<s.y+s.height&&s.y<n.y+n.height;return!(i&&l)};var mn=P(se(),1),Ki=P(re(),1);var gt=P(se(),1),co=P(re(),1);var Jy=class{items=new Map;register(t){if(this.items.has(t.id))throw new Error(`Template already registered: ${t.id}`);this.items.set(t.id,t)}replace(t){this.items.set(t.id,t)}get(t){return this.items.get(t)}has(t){return this.items.has(t)}list(){return[...this.items.values()]}byCategory(t){return this.list().filter(n=>n.category===t)}categories(){let t=new Set;for(let n of this.items.values())t.add(n.category);return[...t]}clear(){this.items.clear()}},Oi=new Jy;var nme={...ns.rectangle},ome={...ns.sticky},ame={...ns.flowchart};var HS=(e,t)=>{let n=t.trim().toLowerCase();if(!n||e.name.toLowerCase().includes(n)||typeof e.category=="string"&&e.category.toLowerCase().includes(n))return!0;if(e.tags){for(let o of e.tags)if(o.toLowerCase().includes(n))return!0}return!1};var C={};ho(C,{BRAND:()=>Rj,DIRTY:()=>Di,EMPTY_PATH:()=>uj,INVALID:()=>Z,NEVER:()=>yV,OK:()=>Gt,ParseStatus:()=>Pt,Schema:()=>le,ZodAny:()=>us,ZodArray:()=>Ja,ZodBigInt:()=>Bi,ZodBoolean:()=>Ni,ZodBranded:()=>Yp,ZodCatch:()=>Xi,ZodDate:()=>zi,ZodDefault:()=>Zi,ZodDiscriminatedUnion:()=>ng,ZodEffects:()=>lo,ZodEnum:()=>ji,ZodError:()=>pn,ZodFirstPartyTypeKind:()=>Y,ZodFunction:()=>ag,ZodIntersection:()=>Gi,ZodIssueCode:()=>D,ZodLazy:()=>Wi,ZodLiteral:()=>qi,ZodMap:()=>Xc,ZodNaN:()=>Kc,ZodNativeEnum:()=>Vi,ZodNever:()=>Co,ZodNull:()=>Hi,ZodNullable:()=>oa,ZodNumber:()=>Pi,ZodObject:()=>hn,ZodOptional:()=>so,ZodParsedType:()=>H,ZodPipeline:()=>Kp,ZodPromise:()=>ds,ZodReadonly:()=>Yi,ZodRecord:()=>og,ZodSchema:()=>le,ZodSet:()=>Yc,ZodString:()=>cs,ZodSymbol:()=>Vc,ZodTransformer:()=>lo,ZodTuple:()=>na,ZodType:()=>le,ZodUndefined:()=>Fi,ZodUnion:()=>Ui,ZodUnknown:()=>Qa,ZodVoid:()=>Zc,addIssueToContext:()=>F,any:()=>Uj,array:()=>jj,bigint:()=>Bj,boolean:()=>y8,coerce:()=>mV,custom:()=>p8,date:()=>Nj,datetimeRegex:()=>d8,defaultErrorMap:()=>Ka,discriminatedUnion:()=>Yj,effect:()=>iV,enum:()=>aV,function:()=>tV,getErrorMap:()=>Wc,getParsedType:()=>ta,instanceof:()=>Dj,intersection:()=>Kj,isAborted:()=>eg,isAsync:()=>qc,isDirty:()=>tg,isValid:()=>ls,late:()=>Oj,lazy:()=>nV,literal:()=>oV,makeIssue:()=>Xp,map:()=>Jj,nan:()=>Pj,nativeEnum:()=>rV,never:()=>Wj,null:()=>Hj,nullable:()=>cV,number:()=>m8,object:()=>Vj,objectUtil:()=>US,oboolean:()=>hV,onumber:()=>pV,optional:()=>lV,ostring:()=>fV,pipeline:()=>dV,preprocess:()=>uV,promise:()=>sV,quotelessJson:()=>ij,record:()=>Qj,set:()=>eV,setErrorMap:()=>cj,strictObject:()=>Zj,string:()=>h8,symbol:()=>zj,transformer:()=>iV,tuple:()=>$j,undefined:()=>Fj,union:()=>Xj,unknown:()=>Gj,util:()=>pe,void:()=>qj});var pe;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function n(a){throw new Error}e.assertNever=n,e.arrayToEnum=a=>{let r={};for(let s of a)r[s]=s;return r},e.getValidEnumValues=a=>{let r=e.objectKeys(a).filter(i=>typeof a[a[i]]!="number"),s={};for(let i of r)s[i]=a[i];return e.objectValues(s)},e.objectValues=a=>e.objectKeys(a).map(function(r){return a[r]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let r=[];for(let s in a)Object.prototype.hasOwnProperty.call(a,s)&&r.push(s);return r},e.find=(a,r)=>{for(let s of a)if(r(s))return s},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function o(a,r=" | "){return a.map(s=>typeof s=="string"?`'${s}'`:s).join(r)}e.joinValues=o,e.jsonStringifyReplacer=(a,r)=>typeof r=="bigint"?r.toString():r})(pe||(pe={}));var US;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(US||(US={}));var H=pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ta=e=>{switch(typeof e){case"undefined":return H.undefined;case"string":return H.string;case"number":return Number.isNaN(e)?H.nan:H.number;case"boolean":return H.boolean;case"function":return H.function;case"bigint":return H.bigint;case"symbol":return H.symbol;case"object":return Array.isArray(e)?H.array:e===null?H.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?H.promise:typeof Map<"u"&&e instanceof Map?H.map:typeof Set<"u"&&e instanceof Set?H.set:typeof Date<"u"&&e instanceof Date?H.date:H.object;default:return H.unknown}};var D=pe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ij=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),pn=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){let n=t||function(r){return r.message},o={_errors:[]},a=r=>{for(let s of r.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)o._errors.push(n(s));else{let i=o,l=0;for(;l<s.path.length;){let c=s.path[l];l===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(n(s))):i[c]=i[c]||{_errors:[]},i=i[c],l++}}};return a(this),o}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},o=[];for(let a of this.issues)if(a.path.length>0){let r=a.path[0];n[r]=n[r]||[],n[r].push(t(a))}else o.push(t(a));return{formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}};pn.create=e=>new pn(e);var lj=(e,t)=>{let n;switch(e.code){case D.invalid_type:e.received===H.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case D.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,pe.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:n=`Unrecognized key(s) in object: ${pe.joinValues(e.keys,", ")}`;break;case D.invalid_union:n="Invalid input";break;case D.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${pe.joinValues(e.options)}`;break;case D.invalid_enum_value:n=`Invalid enum value. Expected ${pe.joinValues(e.options)}, received '${e.received}'`;break;case D.invalid_arguments:n="Invalid function arguments";break;case D.invalid_return_type:n="Invalid function return type";break;case D.invalid_date:n="Invalid date";break;case D.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:pe.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case D.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case D.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case D.custom:n="Invalid input";break;case D.invalid_intersection_types:n="Intersection results could not be merged";break;case D.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case D.not_finite:n="Number must be finite";break;default:n=t.defaultError,pe.assertNever(e)}return{message:n}},Ka=lj;var s8=Ka;function cj(e){s8=e}function Wc(){return s8}var Xp=e=>{let{data:t,path:n,errorMaps:o,issueData:a}=e,r=[...n,...a.path||[]],s={...a,path:r};if(a.message!==void 0)return{...a,path:r,message:a.message};let i="",l=o.filter(c=>!!c).slice().reverse();for(let c of l)i=c(s,{data:t,defaultError:i}).message;return{...a,path:r,message:i}},uj=[];function F(e,t){let n=Wc(),o=Xp({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Ka?void 0:Ka].filter(a=>!!a)});e.common.issues.push(o)}var Pt=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){let o=[];for(let a of n){if(a.status==="aborted")return Z;a.status==="dirty"&&t.dirty(),o.push(a.value)}return{status:t.value,value:o}}static async mergeObjectAsync(t,n){let o=[];for(let a of n){let r=await a.key,s=await a.value;o.push({key:r,value:s})}return e.mergeObjectSync(t,o)}static mergeObjectSync(t,n){let o={};for(let a of n){let{key:r,value:s}=a;if(r.status==="aborted"||s.status==="aborted")return Z;r.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),r.value!=="__proto__"&&(typeof s.value<"u"||a.alwaysSet)&&(o[r.value]=s.value)}return{status:t.value,value:o}}},Z=Object.freeze({status:"aborted"}),Di=e=>({status:"dirty",value:e}),Gt=e=>({status:"valid",value:e}),eg=e=>e.status==="aborted",tg=e=>e.status==="dirty",ls=e=>e.status==="valid",qc=e=>typeof Promise<"u"&&e instanceof Promise;var q;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(q||(q={}));var io=class{constructor(t,n,o,a){this._cachedPath=[],this.parent=t,this.data=n,this._path=o,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},i8=(e,t)=>{if(ls(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new pn(e.common.issues);return this._error=n,this._error}}};function ae(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:o,description:a}=e;if(t&&(n||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(s,i)=>{let{message:l}=e;return s.code==="invalid_enum_value"?{message:l??i.defaultError}:typeof i.data>"u"?{message:l??o??i.defaultError}:s.code!=="invalid_type"?{message:i.defaultError}:{message:l??n??i.defaultError}},description:a}}var le=class{get description(){return this._def.description}_getType(t){return ta(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ta(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Pt,ctx:{common:t.parent.common,data:t.data,parsedType:ta(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(qc(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){let n=this._parse(t);return Promise.resolve(n)}parse(t,n){let o=this.safeParse(t,n);if(o.success)return o.data;throw o.error}safeParse(t,n){let o={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ta(t)},a=this._parseSync({data:t,path:o.path,parent:o});return i8(o,a)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ta(t)};if(!this["~standard"].async)try{let o=this._parseSync({data:t,path:[],parent:n});return ls(o)?{value:o.value}:{issues:n.common.issues}}catch(o){o?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(o=>ls(o)?{value:o.value}:{issues:n.common.issues})}async parseAsync(t,n){let o=await this.safeParseAsync(t,n);if(o.success)return o.data;throw o.error}async safeParseAsync(t,n){let o={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ta(t)},a=this._parse({data:t,path:o.path,parent:o}),r=await(qc(a)?a:Promise.resolve(a));return i8(o,r)}refine(t,n){let o=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,r)=>{let s=t(a),i=()=>r.addIssue({code:D.custom,...o(a)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(i(),!1)):s?!0:(i(),!1)})}refinement(t,n){return this._refinement((o,a)=>t(o)?!0:(a.addIssue(typeof n=="function"?n(o,a):n),!1))}_refinement(t){return new lo({schema:this,typeName:Y.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return so.create(this,this._def)}nullable(){return oa.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ja.create(this)}promise(){return ds.create(this,this._def)}or(t){return Ui.create([this,t],this._def)}and(t){return Gi.create(this,t,this._def)}transform(t){return new lo({...ae(this._def),schema:this,typeName:Y.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new Zi({...ae(this._def),innerType:this,defaultValue:n,typeName:Y.ZodDefault})}brand(){return new Yp({typeName:Y.ZodBranded,type:this,...ae(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new Xi({...ae(this._def),innerType:this,catchValue:n,typeName:Y.ZodCatch})}describe(t){let n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Kp.create(this,t)}readonly(){return Yi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},dj=/^c[^\s-]{8,}$/i,fj=/^[0-9a-z]+$/,pj=/^[0-9A-HJKMNP-TV-Z]{26}$/i,hj=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,mj=/^[a-z0-9_-]{21}$/i,yj=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,gj=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,xj=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bj="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",GS,Aj=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vj=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Sj=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Lj=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kj=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,wj=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,c8="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",_j=new RegExp(`^${c8}$`);function u8(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Cj(e){return new RegExp(`^${u8(e)}$`)}function d8(e){let t=`${c8}T${u8(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Ej(e,t){return!!((t==="v4"||!t)&&Aj.test(e)||(t==="v6"||!t)&&Sj.test(e))}function Tj(e,t){if(!yj.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(o));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function Ij(e,t){return!!((t==="v4"||!t)&&vj.test(e)||(t==="v6"||!t)&&Lj.test(e))}var cs=class e extends le{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==H.string){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_type,expected:H.string,received:r.parsedType}),Z}let o=new Pt,a;for(let r of this._def.checks)if(r.kind==="min")t.data.length<r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),o.dirty());else if(r.kind==="max")t.data.length>r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),o.dirty());else if(r.kind==="length"){let s=t.data.length>r.value,i=t.data.length<r.value;(s||i)&&(a=this._getOrReturnCtx(t,a),s?F(a,{code:D.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&F(a,{code:D.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),o.dirty())}else if(r.kind==="email")xj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"email",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="emoji")GS||(GS=new RegExp(bj,"u")),GS.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"emoji",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="uuid")hj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"uuid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="nanoid")mj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"nanoid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid")dj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"cuid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="cuid2")fj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"cuid2",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="ulid")pj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"ulid",code:D.invalid_string,message:r.message}),o.dirty());else if(r.kind==="url")try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),F(a,{validation:"url",code:D.invalid_string,message:r.message}),o.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"regex",code:D.invalid_string,message:r.message}),o.dirty())):r.kind==="trim"?t.data=t.data.trim():r.kind==="includes"?t.data.includes(r.value,r.position)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),o.dirty()):r.kind==="toLowerCase"?t.data=t.data.toLowerCase():r.kind==="toUpperCase"?t.data=t.data.toUpperCase():r.kind==="startsWith"?t.data.startsWith(r.value)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:{startsWith:r.value},message:r.message}),o.dirty()):r.kind==="endsWith"?t.data.endsWith(r.value)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:{endsWith:r.value},message:r.message}),o.dirty()):r.kind==="datetime"?d8(r).test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:"datetime",message:r.message}),o.dirty()):r.kind==="date"?_j.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:"date",message:r.message}),o.dirty()):r.kind==="time"?Cj(r).test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:"time",message:r.message}),o.dirty()):r.kind==="duration"?gj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"duration",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="ip"?Ej(t.data,r.version)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"ip",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="jwt"?Tj(t.data,r.alg)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"jwt",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="cidr"?Ij(t.data,r.version)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"cidr",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64"?kj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"base64",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64url"?wj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"base64url",code:D.invalid_string,message:r.message}),o.dirty()):pe.assertNever(r);return{status:o.value,value:t.data}}_regex(t,n,o){return this.refinement(a=>t.test(a),{validation:n,code:D.invalid_string,...q.errToObj(o)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...q.errToObj(t)})}url(t){return this._addCheck({kind:"url",...q.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...q.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...q.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...q.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...q.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...q.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...q.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...q.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...q.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...q.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...q.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...q.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...q.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...q.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...q.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...q.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...q.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...q.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...q.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...q.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...q.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...q.errToObj(n)})}nonempty(t){return this.min(1,q.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};cs.create=e=>new cs({checks:[],typeName:Y.ZodString,coerce:e?.coerce??!1,...ae(e)});function Mj(e,t){let n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,a=n>o?n:o,r=Number.parseInt(e.toFixed(a).replace(".","")),s=Number.parseInt(t.toFixed(a).replace(".",""));return r%s/10**a}var Pi=class e extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==H.number){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_type,expected:H.number,received:r.parsedType}),Z}let o,a=new Pt;for(let r of this._def.checks)r.kind==="int"?pe.isInteger(t.data)||(o=this._getOrReturnCtx(t,o),F(o,{code:D.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):r.kind==="min"?(r.inclusive?t.data<r.value:t.data<=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?t.data>r.value:t.data>=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?Mj(t.data,r.value)!==0&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):r.kind==="finite"?Number.isFinite(t.data)||(o=this._getOrReturnCtx(t,o),F(o,{code:D.not_finite,message:r.message}),a.dirty()):pe.assertNever(r);return{status:a.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,q.toString(n))}gt(t,n){return this.setLimit("min",t,!1,q.toString(n))}lte(t,n){return this.setLimit("max",t,!0,q.toString(n))}lt(t,n){return this.setLimit("max",t,!1,q.toString(n))}setLimit(t,n,o,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:q.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:q.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:q.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:q.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:q.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:q.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:q.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:q.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:q.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:q.toString(t)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&pe.isInteger(t.value))}get isFinite(){let t=null,n=null;for(let o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(n===null||o.value>n)&&(n=o.value):o.kind==="max"&&(t===null||o.value<t)&&(t=o.value)}return Number.isFinite(n)&&Number.isFinite(t)}};Pi.create=e=>new Pi({checks:[],typeName:Y.ZodNumber,coerce:e?.coerce||!1,...ae(e)});var Bi=class e extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==H.bigint)return this._getInvalidInput(t);let o,a=new Pt;for(let r of this._def.checks)r.kind==="min"?(r.inclusive?t.data<r.value:t.data<=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?t.data>r.value:t.data>=r.value)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="multipleOf"?t.data%r.value!==BigInt(0)&&(o=this._getOrReturnCtx(t,o),F(o,{code:D.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):pe.assertNever(r);return{status:a.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return F(n,{code:D.invalid_type,expected:H.bigint,received:n.parsedType}),Z}gte(t,n){return this.setLimit("min",t,!0,q.toString(n))}gt(t,n){return this.setLimit("min",t,!1,q.toString(n))}lte(t,n){return this.setLimit("max",t,!0,q.toString(n))}lt(t,n){return this.setLimit("max",t,!1,q.toString(n))}setLimit(t,n,o,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:q.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:q.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:q.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:q.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:q.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:q.toString(n)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};Bi.create=e=>new Bi({checks:[],typeName:Y.ZodBigInt,coerce:e?.coerce??!1,...ae(e)});var Ni=class extends le{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==H.boolean){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.boolean,received:o.parsedType}),Z}return Gt(t.data)}};Ni.create=e=>new Ni({typeName:Y.ZodBoolean,coerce:e?.coerce||!1,...ae(e)});var zi=class e extends le{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==H.date){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_type,expected:H.date,received:r.parsedType}),Z}if(Number.isNaN(t.data.getTime())){let r=this._getOrReturnCtx(t);return F(r,{code:D.invalid_date}),Z}let o=new Pt,a;for(let r of this._def.checks)r.kind==="min"?t.data.getTime()<r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),o.dirty()):r.kind==="max"?t.data.getTime()>r.value&&(a=this._getOrReturnCtx(t,a),F(a,{code:D.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),o.dirty()):pe.assertNever(r);return{status:o.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:q.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:q.toString(n)})}get minDate(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};zi.create=e=>new zi({checks:[],coerce:e?.coerce||!1,typeName:Y.ZodDate,...ae(e)});var Vc=class extends le{_parse(t){if(this._getType(t)!==H.symbol){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.symbol,received:o.parsedType}),Z}return Gt(t.data)}};Vc.create=e=>new Vc({typeName:Y.ZodSymbol,...ae(e)});var Fi=class extends le{_parse(t){if(this._getType(t)!==H.undefined){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.undefined,received:o.parsedType}),Z}return Gt(t.data)}};Fi.create=e=>new Fi({typeName:Y.ZodUndefined,...ae(e)});var Hi=class extends le{_parse(t){if(this._getType(t)!==H.null){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.null,received:o.parsedType}),Z}return Gt(t.data)}};Hi.create=e=>new Hi({typeName:Y.ZodNull,...ae(e)});var us=class extends le{constructor(){super(...arguments),this._any=!0}_parse(t){return Gt(t.data)}};us.create=e=>new us({typeName:Y.ZodAny,...ae(e)});var Qa=class extends le{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Gt(t.data)}};Qa.create=e=>new Qa({typeName:Y.ZodUnknown,...ae(e)});var Co=class extends le{_parse(t){let n=this._getOrReturnCtx(t);return F(n,{code:D.invalid_type,expected:H.never,received:n.parsedType}),Z}};Co.create=e=>new Co({typeName:Y.ZodNever,...ae(e)});var Zc=class extends le{_parse(t){if(this._getType(t)!==H.undefined){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.void,received:o.parsedType}),Z}return Gt(t.data)}};Zc.create=e=>new Zc({typeName:Y.ZodVoid,...ae(e)});var Ja=class e extends le{_parse(t){let{ctx:n,status:o}=this._processInputParams(t),a=this._def;if(n.parsedType!==H.array)return F(n,{code:D.invalid_type,expected:H.array,received:n.parsedType}),Z;if(a.exactLength!==null){let s=n.data.length>a.exactLength.value,i=n.data.length<a.exactLength.value;(s||i)&&(F(n,{code:s?D.too_big:D.too_small,minimum:i?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),o.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(F(n,{code:D.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),o.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(F(n,{code:D.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),o.dirty()),n.common.async)return Promise.all([...n.data].map((s,i)=>a.type._parseAsync(new io(n,s,n.path,i)))).then(s=>Pt.mergeArray(o,s));let r=[...n.data].map((s,i)=>a.type._parseSync(new io(n,s,n.path,i)));return Pt.mergeArray(o,r)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:q.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:q.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:q.toString(n)}})}nonempty(t){return this.min(1,t)}};Ja.create=(e,t)=>new Ja({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Y.ZodArray,...ae(t)});function jc(e){if(e instanceof hn){let t={};for(let n in e.shape){let o=e.shape[n];t[n]=so.create(jc(o))}return new hn({...e._def,shape:()=>t})}else return e instanceof Ja?new Ja({...e._def,type:jc(e.element)}):e instanceof so?so.create(jc(e.unwrap())):e instanceof oa?oa.create(jc(e.unwrap())):e instanceof na?na.create(e.items.map(t=>jc(t))):e}var hn=class e extends le{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=pe.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==H.object){let c=this._getOrReturnCtx(t);return F(c,{code:D.invalid_type,expected:H.object,received:c.parsedType}),Z}let{status:o,ctx:a}=this._processInputParams(t),{shape:r,keys:s}=this._getCached(),i=[];if(!(this._def.catchall instanceof Co&&this._def.unknownKeys==="strip"))for(let c in a.data)s.includes(c)||i.push(c);let l=[];for(let c of s){let u=r[c],d=a.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new io(a,d,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof Co){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of i)l.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(c==="strict")i.length>0&&(F(a,{code:D.unrecognized_keys,keys:i}),o.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of i){let d=a.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new io(a,d,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Pt.mergeObjectSync(o,c)):Pt.mergeObjectSync(o,l)}get shape(){return this._def.shape()}strict(t){return q.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,o)=>{let a=this._def.errorMap?.(n,o).message??o.defaultError;return n.code==="unrecognized_keys"?{message:q.errToObj(t).message??a}:{message:a}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Y.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let o of pe.objectKeys(t))t[o]&&this.shape[o]&&(n[o]=this.shape[o]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let o of pe.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new e({...this._def,shape:()=>n})}deepPartial(){return jc(this)}partial(t){let n={};for(let o of pe.objectKeys(this.shape)){let a=this.shape[o];t&&!t[o]?n[o]=a:n[o]=a.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let o of pe.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let r=this.shape[o];for(;r instanceof so;)r=r._def.innerType;n[o]=r}return new e({...this._def,shape:()=>n})}keyof(){return f8(pe.objectKeys(this.shape))}};hn.create=(e,t)=>new hn({shape:()=>e,unknownKeys:"strip",catchall:Co.create(),typeName:Y.ZodObject,...ae(t)});hn.strictCreate=(e,t)=>new hn({shape:()=>e,unknownKeys:"strict",catchall:Co.create(),typeName:Y.ZodObject,...ae(t)});hn.lazycreate=(e,t)=>new hn({shape:e,unknownKeys:"strip",catchall:Co.create(),typeName:Y.ZodObject,...ae(t)});var Ui=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o=this._def.options;function a(r){for(let i of r)if(i.result.status==="valid")return i.result;for(let i of r)if(i.result.status==="dirty")return n.common.issues.push(...i.ctx.common.issues),i.result;let s=r.map(i=>new pn(i.ctx.common.issues));return F(n,{code:D.invalid_union,unionErrors:s}),Z}if(n.common.async)return Promise.all(o.map(async r=>{let s={...n,common:{...n.common,issues:[]},parent:null};return{result:await r._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(a);{let r,s=[];for(let l of o){let c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!r&&(r={result:u,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(r)return n.common.issues.push(...r.ctx.common.issues),r.result;let i=s.map(l=>new pn(l));return F(n,{code:D.invalid_union,unionErrors:i}),Z}}get options(){return this._def.options}};Ui.create=(e,t)=>new Ui({options:e,typeName:Y.ZodUnion,...ae(t)});var $a=e=>e instanceof Wi?$a(e.schema):e instanceof lo?$a(e.innerType()):e instanceof qi?[e.value]:e instanceof ji?e.options:e instanceof Vi?pe.objectValues(e.enum):e instanceof Zi?$a(e._def.innerType):e instanceof Fi?[void 0]:e instanceof Hi?[null]:e instanceof so?[void 0,...$a(e.unwrap())]:e instanceof oa?[null,...$a(e.unwrap())]:e instanceof Yp||e instanceof Yi?$a(e.unwrap()):e instanceof Xi?$a(e._def.innerType):[],ng=class e extends le{_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==H.object)return F(n,{code:D.invalid_type,expected:H.object,received:n.parsedType}),Z;let o=this.discriminator,a=n.data[o],r=this.optionsMap.get(a);return r?n.common.async?r._parseAsync({data:n.data,path:n.path,parent:n}):r._parseSync({data:n.data,path:n.path,parent:n}):(F(n,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[o]}),Z)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,o){let a=new Map;for(let r of n){let s=$a(r.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let i of s){if(a.has(i))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(i)}`);a.set(i,r)}}return new e({typeName:Y.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:a,...ae(o)})}};function WS(e,t){let n=ta(e),o=ta(t);if(e===t)return{valid:!0,data:e};if(n===H.object&&o===H.object){let a=pe.objectKeys(t),r=pe.objectKeys(e).filter(i=>a.indexOf(i)!==-1),s={...e,...t};for(let i of r){let l=WS(e[i],t[i]);if(!l.valid)return{valid:!1};s[i]=l.data}return{valid:!0,data:s}}else if(n===H.array&&o===H.array){if(e.length!==t.length)return{valid:!1};let a=[];for(let r=0;r<e.length;r++){let s=e[r],i=t[r],l=WS(s,i);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return n===H.date&&o===H.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Gi=class extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t),a=(r,s)=>{if(eg(r)||eg(s))return Z;let i=WS(r.value,s.value);return i.valid?((tg(r)||tg(s))&&n.dirty(),{status:n.value,value:i.data}):(F(o,{code:D.invalid_intersection_types}),Z)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([r,s])=>a(r,s)):a(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}};Gi.create=(e,t,n)=>new Gi({left:e,right:t,typeName:Y.ZodIntersection,...ae(n)});var na=class e extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.array)return F(o,{code:D.invalid_type,expected:H.array,received:o.parsedType}),Z;if(o.data.length<this._def.items.length)return F(o,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Z;!this._def.rest&&o.data.length>this._def.items.length&&(F(o,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let r=[...o.data].map((s,i)=>{let l=this._def.items[i]||this._def.rest;return l?l._parse(new io(o,s,o.path,i)):null}).filter(s=>!!s);return o.common.async?Promise.all(r).then(s=>Pt.mergeArray(n,s)):Pt.mergeArray(n,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};na.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new na({items:e,typeName:Y.ZodTuple,rest:null,...ae(t)})};var og=class e extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.object)return F(o,{code:D.invalid_type,expected:H.object,received:o.parsedType}),Z;let a=[],r=this._def.keyType,s=this._def.valueType;for(let i in o.data)a.push({key:r._parse(new io(o,i,o.path,i)),value:s._parse(new io(o,o.data[i],o.path,i)),alwaysSet:i in o.data});return o.common.async?Pt.mergeObjectAsync(n,a):Pt.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(t,n,o){return n instanceof le?new e({keyType:t,valueType:n,typeName:Y.ZodRecord,...ae(o)}):new e({keyType:cs.create(),valueType:t,typeName:Y.ZodRecord,...ae(n)})}},Xc=class extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.map)return F(o,{code:D.invalid_type,expected:H.map,received:o.parsedType}),Z;let a=this._def.keyType,r=this._def.valueType,s=[...o.data.entries()].map(([i,l],c)=>({key:a._parse(new io(o,i,o.path,[c,"key"])),value:r._parse(new io(o,l,o.path,[c,"value"]))}));if(o.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let l of s){let c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Z;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(c.value,u.value)}return{status:n.value,value:i}})}else{let i=new Map;for(let l of s){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Z;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(c.value,u.value)}return{status:n.value,value:i}}}};Xc.create=(e,t,n)=>new Xc({valueType:t,keyType:e,typeName:Y.ZodMap,...ae(n)});var Yc=class e extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==H.set)return F(o,{code:D.invalid_type,expected:H.set,received:o.parsedType}),Z;let a=this._def;a.minSize!==null&&o.data.size<a.minSize.value&&(F(o,{code:D.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&o.data.size>a.maxSize.value&&(F(o,{code:D.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());let r=this._def.valueType;function s(l){let c=new Set;for(let u of l){if(u.status==="aborted")return Z;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}let i=[...o.data.values()].map((l,c)=>r._parse(new io(o,l,o.path,c)));return o.common.async?Promise.all(i).then(l=>s(l)):s(i)}min(t,n){return new e({...this._def,minSize:{value:t,message:q.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:q.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};Yc.create=(e,t)=>new Yc({valueType:e,minSize:null,maxSize:null,typeName:Y.ZodSet,...ae(t)});var ag=class e extends le{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==H.function)return F(n,{code:D.invalid_type,expected:H.function,received:n.parsedType}),Z;function o(i,l){return Xp({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Wc(),Ka].filter(c=>!!c),issueData:{code:D.invalid_arguments,argumentsError:l}})}function a(i,l){return Xp({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Wc(),Ka].filter(c=>!!c),issueData:{code:D.invalid_return_type,returnTypeError:l}})}let r={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof ds){let i=this;return Gt(async function(...l){let c=new pn([]),u=await i._def.args.parseAsync(l,r).catch(p=>{throw c.addIssue(o(l,p)),c}),d=await Reflect.apply(s,this,u);return await i._def.returns._def.type.parseAsync(d,r).catch(p=>{throw c.addIssue(a(d,p)),c})})}else{let i=this;return Gt(function(...l){let c=i._def.args.safeParse(l,r);if(!c.success)throw new pn([o(l,c.error)]);let u=Reflect.apply(s,this,c.data),d=i._def.returns.safeParse(u,r);if(!d.success)throw new pn([a(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:na.create(t).rest(Qa.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,o){return new e({args:t||na.create([]).rest(Qa.create()),returns:n||Qa.create(),typeName:Y.ZodFunction,...ae(o)})}},Wi=class extends le{get schema(){return this._def.getter()}_parse(t){let{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Wi.create=(e,t)=>new Wi({getter:e,typeName:Y.ZodLazy,...ae(t)});var qi=class extends le{_parse(t){if(t.data!==this._def.value){let n=this._getOrReturnCtx(t);return F(n,{received:n.data,code:D.invalid_literal,expected:this._def.value}),Z}return{status:"valid",value:t.data}}get value(){return this._def.value}};qi.create=(e,t)=>new qi({value:e,typeName:Y.ZodLiteral,...ae(t)});function f8(e,t){return new ji({values:e,typeName:Y.ZodEnum,...ae(t)})}var ji=class e extends le{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),o=this._def.values;return F(n,{expected:pe.joinValues(o),received:n.parsedType,code:D.invalid_type}),Z}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),o=this._def.values;return F(n,{received:n.data,code:D.invalid_enum_value,options:o}),Z}return Gt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let n of this._def.values)t[n]=n;return t}get Values(){let t={};for(let n of this._def.values)t[n]=n;return t}get Enum(){let t={};for(let n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(o=>!t.includes(o)),{...this._def,...n})}};ji.create=f8;var Vi=class extends le{_parse(t){let n=pe.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==H.string&&o.parsedType!==H.number){let a=pe.objectValues(n);return F(o,{expected:pe.joinValues(a),received:o.parsedType,code:D.invalid_type}),Z}if(this._cache||(this._cache=new Set(pe.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let a=pe.objectValues(n);return F(o,{received:o.data,code:D.invalid_enum_value,options:a}),Z}return Gt(t.data)}get enum(){return this._def.values}};Vi.create=(e,t)=>new Vi({values:e,typeName:Y.ZodNativeEnum,...ae(t)});var ds=class extends le{unwrap(){return this._def.type}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==H.promise&&n.common.async===!1)return F(n,{code:D.invalid_type,expected:H.promise,received:n.parsedType}),Z;let o=n.parsedType===H.promise?n.data:Promise.resolve(n.data);return Gt(o.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};ds.create=(e,t)=>new ds({type:e,typeName:Y.ZodPromise,...ae(t)});var lo=class extends le{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:o}=this._processInputParams(t),a=this._def.effect||null,r={addIssue:s=>{F(o,s),s.fatal?n.abort():n.dirty()},get path(){return o.path}};if(r.addIssue=r.addIssue.bind(r),a.type==="preprocess"){let s=a.transform(o.data,r);if(o.common.async)return Promise.resolve(s).then(async i=>{if(n.value==="aborted")return Z;let l=await this._def.schema._parseAsync({data:i,path:o.path,parent:o});return l.status==="aborted"?Z:l.status==="dirty"?Di(l.value):n.value==="dirty"?Di(l.value):l});{if(n.value==="aborted")return Z;let i=this._def.schema._parseSync({data:s,path:o.path,parent:o});return i.status==="aborted"?Z:i.status==="dirty"?Di(i.value):n.value==="dirty"?Di(i.value):i}}if(a.type==="refinement"){let s=i=>{let l=a.refinement(i,r);if(o.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(o.common.async===!1){let i=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return i.status==="aborted"?Z:(i.status==="dirty"&&n.dirty(),s(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(i=>i.status==="aborted"?Z:(i.status==="dirty"&&n.dirty(),s(i.value).then(()=>({status:n.value,value:i.value}))))}if(a.type==="transform")if(o.common.async===!1){let s=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!ls(s))return Z;let i=a.transform(s.value,r);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:i}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(s=>ls(s)?Promise.resolve(a.transform(s.value,r)).then(i=>({status:n.value,value:i})):Z);pe.assertNever(a)}};lo.create=(e,t,n)=>new lo({schema:e,typeName:Y.ZodEffects,effect:t,...ae(n)});lo.createWithPreprocess=(e,t,n)=>new lo({schema:t,effect:{type:"preprocess",transform:e},typeName:Y.ZodEffects,...ae(n)});var so=class extends le{_parse(t){return this._getType(t)===H.undefined?Gt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};so.create=(e,t)=>new so({innerType:e,typeName:Y.ZodOptional,...ae(t)});var oa=class extends le{_parse(t){return this._getType(t)===H.null?Gt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};oa.create=(e,t)=>new oa({innerType:e,typeName:Y.ZodNullable,...ae(t)});var Zi=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o=n.data;return n.parsedType===H.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Zi.create=(e,t)=>new Zi({innerType:e,typeName:Y.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ae(t)});var Xi=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return qc(a)?a.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new pn(o.common.issues)},input:o.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new pn(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}};Xi.create=(e,t)=>new Xi({innerType:e,typeName:Y.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ae(t)});var Kc=class extends le{_parse(t){if(this._getType(t)!==H.nan){let o=this._getOrReturnCtx(t);return F(o,{code:D.invalid_type,expected:H.nan,received:o.parsedType}),Z}return{status:"valid",value:t.data}}};Kc.create=e=>new Kc({typeName:Y.ZodNaN,...ae(e)});var Rj=Symbol("zod_brand"),Yp=class extends le{_parse(t){let{ctx:n}=this._processInputParams(t),o=n.data;return this._def.type._parse({data:o,path:n.path,parent:n})}unwrap(){return this._def.type}},Kp=class e extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t);if(o.common.async)return(async()=>{let r=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return r.status==="aborted"?Z:r.status==="dirty"?(n.dirty(),Di(r.value)):this._def.out._parseAsync({data:r.value,path:o.path,parent:o})})();{let a=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?Z:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:o.path,parent:o})}}static create(t,n){return new e({in:t,out:n,typeName:Y.ZodPipeline})}},Yi=class extends le{_parse(t){let n=this._def.innerType._parse(t),o=a=>(ls(a)&&(a.value=Object.freeze(a.value)),a);return qc(n)?n.then(a=>o(a)):o(n)}unwrap(){return this._def.innerType}};Yi.create=(e,t)=>new Yi({innerType:e,typeName:Y.ZodReadonly,...ae(t)});function l8(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function p8(e,t={},n){return e?us.create().superRefine((o,a)=>{let r=e(o);if(r instanceof Promise)return r.then(s=>{if(!s){let i=l8(t,o),l=i.fatal??n??!0;a.addIssue({code:"custom",...i,fatal:l})}});if(!r){let s=l8(t,o),i=s.fatal??n??!0;a.addIssue({code:"custom",...s,fatal:i})}}):us.create()}var Oj={object:hn.lazycreate},Y;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Y||(Y={}));var Dj=(e,t={message:`Input not instance of ${e.name}`})=>p8(n=>n instanceof e,t),h8=cs.create,m8=Pi.create,Pj=Kc.create,Bj=Bi.create,y8=Ni.create,Nj=zi.create,zj=Vc.create,Fj=Fi.create,Hj=Hi.create,Uj=us.create,Gj=Qa.create,Wj=Co.create,qj=Zc.create,jj=Ja.create,Vj=hn.create,Zj=hn.strictCreate,Xj=Ui.create,Yj=ng.create,Kj=Gi.create,$j=na.create,Qj=og.create,Jj=Xc.create,eV=Yc.create,tV=ag.create,nV=Wi.create,oV=qi.create,aV=ji.create,rV=Vi.create,sV=ds.create,iV=lo.create,lV=so.create,cV=oa.create,uV=lo.createWithPreprocess,dV=Kp.create,fV=()=>h8().optional(),pV=()=>m8().optional(),hV=()=>y8().optional(),mV={string:(e=>cs.create({...e,coerce:!0})),number:(e=>Pi.create({...e,coerce:!0})),boolean:(e=>Ni.create({...e,coerce:!0})),bigint:(e=>Bi.create({...e,coerce:!0})),date:(e=>zi.create({...e,coerce:!0}))};var yV=Z;var xV=["basic","layout","flowchart","custom","rich"],qS=({registry:e=Oi,categories:t=xV,collapsedByDefault:n=[],searchQuery:o,layout:a="grid",style:r,className:s})=>{let i=a==="list"?"du-palette-list":"du-palette-grid",l=(0,co.useMemo)(()=>new Set(e.categories()),[e]),c=(0,co.useMemo)(()=>t.filter(x=>l.has(x)),[t,l]),u=(0,co.useMemo)(()=>c.map(x=>({category:x,items:e.byCategory(x)})),[e,c]),[d,f]=(0,co.useState)(()=>new Set(n)),p=x=>{f(y=>{let g=new Set(y);return g.has(x)?g.delete(x):g.add(x),g})},h=o?.trim()??"",m=(0,co.useMemo)(()=>{if(!h)return[];let x=[];for(let{items:y}of u)for(let g of y)HS(g,h)&&x.push(g);return x},[u,h]);return(0,gt.jsx)("aside",{className:`du-palette ${s??""}`.trim(),style:r,children:(0,gt.jsx)("div",{className:"du-palette-body",children:h?m.length===0?(0,gt.jsxs)("div",{className:"du-palette-empty",children:["No templates match \u201C",h,"\u201D"]}):(0,gt.jsx)("div",{className:i,children:m.map(x=>(0,gt.jsx)(A8,{template:x},x.id))}):u.map(({category:x,items:y})=>(0,gt.jsx)(bV,{category:x,items:y,itemsClass:i,collapsed:d.has(x),onToggle:()=>{p(x)}},x))})})},bV=({category:e,items:t,itemsClass:n,collapsed:o,onToggle:a})=>t.length===0?null:(0,gt.jsxs)("section",{className:"du-palette-section",children:[(0,gt.jsxs)("button",{type:"button",onClick:a,"aria-expanded":!o,className:"du-palette-category",children:[(0,gt.jsx)("span",{children:e}),(0,gt.jsx)("span",{className:"du-palette-category-caret","aria-hidden":!0,children:o?(0,gt.jsx)(Xs,{size:12,strokeWidth:1.75}):(0,gt.jsx)(Td,{size:12,strokeWidth:1.75})})]}),o?null:(0,gt.jsx)("div",{className:n,children:t.map(r=>(0,gt.jsx)(A8,{template:r},r.id))})]}),$p=null,x8=Jv(),g8=e=>{$p!==e&&($p=e,x8.emit())};var b8=e=>x8.add(e);var rg=null,AV=()=>{if(typeof document>"u")return null;if(rg&&document.body.contains(rg))return rg;let e=document.createElement("div");return e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;top:-1000px;left:-1000px;width:1px;height:1px;background:rgba(0,0,0,0.01)",document.body.appendChild(e),rg=e,e},A8=({template:e})=>{let t=G(),n=r=>{r.dataTransfer.setData("application/x-template-id",e.id),r.dataTransfer.effectAllowed="copy";let s=AV();s&&r.dataTransfer.setDragImage(s,0,0),g8(e)},o=()=>{g8(null)},a=()=>{if(!t||typeof window<"u"&&!window.matchMedia("(pointer: coarse)").matches)return;let s=t.hostElement.getBoundingClientRect(),i=t.screenToWorld({x:s.width/2,y:s.height/2}),l=Ze(`shape-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`),c=e.factory({id:l,layerId:Rn,position:i,order:Ae([...t.scene.elements.values()].filter(d=>d.layerId===Rn).map(d=>d.order))}),u=t.beginPlacement(c);u.update(i),u.commit()};return(0,gt.jsxs)("div",{role:"button",draggable:!0,title:e.name,onDragStart:n,onDragEnd:o,onClick:a,className:"du-palette-item",children:[(0,gt.jsx)("span",{className:"du-palette-item-icon",style:{width:28,height:28},dangerouslySetInnerHTML:{__html:e.icon}}),(0,gt.jsx)("span",{className:"du-palette-item-label",children:e.name})]})},jS=()=>{let e=G(),t=(0,co.useRef)(null);(0,co.useEffect)(()=>{let a=r=>{r.key!=="Escape"||!t.current||(t.current.cancel(),t.current=null)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[]),(0,co.useEffect)(()=>b8(()=>{$p===null&&t.current&&(t.current.cancel(),t.current=null)}),[]);let n=a=>{if(t.current||!e||!$p)return!1;let r=$p,s=a.currentTarget.getBoundingClientRect(),i={x:a.clientX-s.left,y:a.clientY-s.top},l=e.screenToWorld(i),c=Ze(`shape-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`),u=r.factory({id:c,layerId:Rn,position:l,order:Ae([...e.scene.elements.values()].filter(d=>d.layerId===Rn).map(d=>d.order))});return t.current=e.beginPlacement(u),t.current.update(l),!0},o=a=>{if(!e)return null;let r=a.currentTarget.getBoundingClientRect();return e.screenToWorld({x:a.clientX-r.left,y:a.clientY-r.top})};return{onDragEnter:a=>{let r=a.dataTransfer.types,s=r.includes("application/x-template-id"),i=r.includes("Files");!s&&!i||(a.preventDefault(),s&&n(a))},onDragOver:a=>{let r=a.dataTransfer.types,s=r.includes("application/x-template-id"),i=r.includes("Files");if(!(!s&&!i)&&(a.preventDefault(),a.dataTransfer.dropEffect="copy",s)){t.current||n(a);let l=o(a);l&&t.current&&t.current.update(l)}},onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||t.current&&(t.current.cancel(),t.current=null)},onDrop:a=>{if(a.preventDefault(),t.current){let l=o(a);l&&t.current.update(l),t.current.commit(),t.current=null;return}let r=a.dataTransfer;if(!r)return;let i=o(a)??{x:0,y:0};e&&(async()=>{for await(let l of oS(r,{onError:(c,u)=>{console.warn(`[file-drop] failed at ${c}:`,u)}}))e.dispatchFileDrop(l,i)})()}}};var VS=14,ZS=1.75,sg=({open:e,onClose:t,side:n="right",sheet:o=!1,onImport:a,style:r})=>{let[s,i]=(0,Ki.useState)("");(0,Ki.useEffect)(()=>{e||i("")},[e]);let l=(0,Ki.useRef)(null);return(0,Ki.useEffect)(()=>{e&&l.current?.focus()},[e]),e?(0,mn.jsxs)("aside",{className:`du-side-panel ${o?"du-side-panel-sheet":n==="right"?"du-side-panel-right":"du-side-panel-left"}`,style:r,children:[(0,mn.jsx)("header",{className:"du-side-panel-header",children:(0,mn.jsxs)("div",{style:{display:"inline-flex",gap:4},children:[a?(0,mn.jsx)(Qn,{label:"Import templates",size:"sm",onClick:a,children:(0,mn.jsx)(bf,{size:VS,strokeWidth:ZS})}):null,(0,mn.jsx)(Qn,{label:"Close library",size:"sm",onClick:t,children:(0,mn.jsx)(Na,{size:VS,strokeWidth:ZS})})]})}),(0,mn.jsxs)("div",{className:"du-side-panel-search",children:[(0,mn.jsx)(df,{size:VS,strokeWidth:ZS,className:"du-side-panel-search-icon","aria-hidden":!0}),(0,mn.jsx)("input",{ref:l,type:"search",value:s,placeholder:"Search templates\u2026","aria-label":"Search templates",onChange:u=>{i(u.target.value)},onKeyDown:u=>{u.key==="Escape"&&s&&(u.stopPropagation(),i(""))}})]}),(0,mn.jsx)("div",{className:"du-side-panel-body du-side-panel-body-flush",children:(0,mn.jsx)(qS,{searchQuery:s,layout:"list"})})]}):null};var sh=P(se(),1);var $c=Math.min,er=Math.max,Jp=Math.round,eh=Math.floor,Eo=e=>({x:e,y:e}),vV={left:"right",right:"left",bottom:"top",top:"bottom"};function XS(e,t,n){return er(e,$c(t,n))}function th(e,t){return typeof e=="function"?e(t):e}function fs(e){return e.split("-")[0]}function nh(e){return e.split("-")[1]}function YS(e){return e==="x"?"y":"x"}function KS(e){return e==="y"?"height":"width"}function tr(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function $S(e){return YS(tr(e))}function L8(e,t,n){n===void 0&&(n=!1);let o=nh(e),a=$S(e),r=KS(a),s=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(s=Qp(s)),[s,Qp(s)]}function k8(e){let t=Qp(e);return[ig(e),t,ig(t)]}function ig(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var v8=["left","right"],S8=["right","left"],SV=["top","bottom"],LV=["bottom","top"];function kV(e,t,n){switch(e){case"top":case"bottom":return n?t?S8:v8:t?v8:S8;case"left":case"right":return t?SV:LV;default:return[]}}function w8(e,t,n,o){let a=nh(e),r=kV(fs(e),n==="start",o);return a&&(r=r.map(s=>s+"-"+a),t&&(r=r.concat(r.map(ig)))),r}function Qp(e){let t=fs(e);return vV[t]+e.slice(t.length)}function wV(e){return{top:0,right:0,bottom:0,left:0,...e}}function _8(e){return typeof e!="number"?wV(e):{top:e,right:e,bottom:e,left:e}}function $i(e){let{x:t,y:n,width:o,height:a}=e;return{width:o,height:a,top:n,left:t,right:t+o,bottom:n+a,x:t,y:n}}function C8(e,t,n){let{reference:o,floating:a}=e,r=tr(t),s=$S(t),i=KS(s),l=fs(t),c=r==="y",u=o.x+o.width/2-a.width/2,d=o.y+o.height/2-a.height/2,f=o[i]/2-a[i]/2,p;switch(l){case"top":p={x:u,y:o.y-a.height};break;case"bottom":p={x:u,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-a.width,y:d};break;default:p={x:o.x,y:o.y}}switch(nh(t)){case"start":p[s]-=f*(n&&c?-1:1);break;case"end":p[s]+=f*(n&&c?-1:1);break}return p}async function E8(e,t){var n;t===void 0&&(t={});let{x:o,y:a,platform:r,rects:s,elements:i,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=th(t,e),h=_8(p),x=i[f?d==="floating"?"reference":"floating":d],y=$i(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(x)))==null||n?x:x.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(i.floating)),boundary:c,rootBoundary:u,strategy:l})),g=d==="floating"?{x:o,y:a,width:s.floating.width,height:s.floating.height}:s.reference,b=await(r.getOffsetParent==null?void 0:r.getOffsetParent(i.floating)),A=await(r.isElement==null?void 0:r.isElement(b))?await(r.getScale==null?void 0:r.getScale(b))||{x:1,y:1}:{x:1,y:1},_=$i(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:g,offsetParent:b,strategy:l}):g);return{top:(y.top-_.top+h.top)/A.y,bottom:(_.bottom-y.bottom+h.bottom)/A.y,left:(y.left-_.left+h.left)/A.x,right:(_.right-y.right+h.right)/A.x}}var _V=50,T8=async(e,t,n)=>{let{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:s}=n,i=s.detectOverflow?s:{...s,detectOverflow:E8},l=await(s.isRTL==null?void 0:s.isRTL(t)),c=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:u,y:d}=C8(c,o,l),f=o,p=0,h={};for(let m=0;m<r.length;m++){let x=r[m];if(!x)continue;let{name:y,fn:g}=x,{x:b,y:A,data:_,reset:T}=await g({x:u,y:d,initialPlacement:o,placement:f,strategy:a,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});u=b??u,d=A??d,h[y]={...h[y],..._},T&&p<_V&&(p++,typeof T=="object"&&(T.placement&&(f=T.placement),T.rects&&(c=T.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:a}):T.rects),{x:u,y:d}=C8(c,f,l)),m=-1)}return{x:u,y:d,placement:f,strategy:a,middlewareData:h}};var I8=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;let{placement:a,middlewareData:r,rects:s,initialPlacement:i,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:m=!0,...x}=th(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let y=fs(a),g=tr(i),b=fs(i)===i,A=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=f||(b||!m?[Qp(i)]:k8(i)),T=h!=="none";!f&&T&&_.push(...w8(i,m,h,A));let w=[i,..._],S=await l.detectOverflow(t,x),L=[],M=((o=r.flip)==null?void 0:o.overflows)||[];if(u&&L.push(S[y]),d){let ne=L8(a,s,A);L.push(S[ne[0]],S[ne[1]])}if(M=[...M,{placement:a,overflows:L}],!L.every(ne=>ne<=0)){var B,W;let ne=(((B=r.flip)==null?void 0:B.index)||0)+1,j=w[ne];if(j&&(!(d==="alignment"?g!==tr(j):!1)||M.every(ee=>tr(ee.placement)===g?ee.overflows[0]>0:!0)))return{data:{index:ne,overflows:M},reset:{placement:j}};let ve=(W=M.filter(ye=>ye.overflows[0]<=0).sort((ye,ee)=>ye.overflows[1]-ee.overflows[1])[0])==null?void 0:W.placement;if(!ve)switch(p){case"bestFit":{var ie;let ye=(ie=M.filter(ee=>{if(T){let Se=tr(ee.placement);return Se===g||Se==="y"}return!0}).map(ee=>[ee.placement,ee.overflows.filter(Se=>Se>0).reduce((Se,Oe)=>Se+Oe,0)]).sort((ee,Se)=>ee[1]-Se[1])[0])==null?void 0:ie[0];ye&&(ve=ye);break}case"initialPlacement":ve=i;break}if(a!==ve)return{reset:{placement:ve}}}return{}}}};var CV=new Set(["left","top"]);async function EV(e,t){let{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),s=fs(n),i=nh(n),l=tr(n)==="y",c=CV.has(s)?-1:1,u=r&&l?-1:1,d=th(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:h}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return i&&typeof h=="number"&&(p=i==="end"?h*-1:h),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}var M8=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;let{x:a,y:r,placement:s,middlewareData:i}=t,l=await EV(t,e);return s===((n=i.offset)==null?void 0:n.placement)&&(o=i.arrow)!=null&&o.alignmentOffset?{}:{x:a+l.x,y:r+l.y,data:{...l,placement:s}}}}},R8=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:o,placement:a,platform:r}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:l={fn:y=>{let{x:g,y:b}=y;return{x:g,y:b}}},...c}=th(e,t),u={x:n,y:o},d=await r.detectOverflow(t,c),f=tr(fs(a)),p=YS(f),h=u[p],m=u[f];if(s){let y=p==="y"?"top":"left",g=p==="y"?"bottom":"right",b=h+d[y],A=h-d[g];h=XS(b,h,A)}if(i){let y=f==="y"?"top":"left",g=f==="y"?"bottom":"right",b=m+d[y],A=m-d[g];m=XS(b,m,A)}let x=l.fn({...t,[p]:h,[f]:m});return{...x,data:{x:x.x-n,y:x.y-o,enabled:{[p]:s,[f]:i}}}}}};function lg(){return typeof window<"u"}function Ji(e){return D8(e)?(e.nodeName||"").toLowerCase():"#document"}function yn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function To(e){var t;return(t=(D8(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function D8(e){return lg()?e instanceof Node||e instanceof yn(e).Node:!1}function uo(e){return lg()?e instanceof Element||e instanceof yn(e).Element:!1}function aa(e){return lg()?e instanceof HTMLElement||e instanceof yn(e).HTMLElement:!1}function O8(e){return!lg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yn(e).ShadowRoot}function Jc(e){let{overflow:t,overflowX:n,overflowY:o,display:a}=fo(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&a!=="inline"&&a!=="contents"}function P8(e){return/^(table|td|th)$/.test(Ji(e))}function oh(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var TV=/transform|translate|scale|rotate|perspective|filter/,IV=/paint|layout|strict|content/,Qi=e=>!!e&&e!=="none",QS;function cg(e){let t=uo(e)?fo(e):e;return Qi(t.transform)||Qi(t.translate)||Qi(t.scale)||Qi(t.rotate)||Qi(t.perspective)||!ug()&&(Qi(t.backdropFilter)||Qi(t.filter))||TV.test(t.willChange||"")||IV.test(t.contain||"")}function B8(e){let t=nr(e);for(;aa(t)&&!el(t);){if(cg(t))return t;if(oh(t))return null;t=nr(t)}return null}function ug(){return QS==null&&(QS=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),QS}function el(e){return/^(html|body|#document)$/.test(Ji(e))}function fo(e){return yn(e).getComputedStyle(e)}function ah(e){return uo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nr(e){if(Ji(e)==="html")return e;let t=e.assignedSlot||e.parentNode||O8(e)&&e.host||To(e);return O8(t)?t.host:t}function N8(e){let t=nr(e);return el(t)?e.ownerDocument?e.ownerDocument.body:e.body:aa(t)&&Jc(t)?t:N8(t)}function Qc(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);let a=N8(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),s=yn(a);if(r){let i=dg(s);return t.concat(s,s.visualViewport||[],Jc(a)?a:[],i&&n?Qc(i):[])}else return t.concat(a,Qc(a,[],n))}function dg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function U8(e){let t=fo(e),n=parseFloat(t.width)||0,o=parseFloat(t.height)||0,a=aa(e),r=a?e.offsetWidth:n,s=a?e.offsetHeight:o,i=Jp(n)!==r||Jp(o)!==s;return i&&(n=r,o=s),{width:n,height:o,$:i}}function eL(e){return uo(e)?e:e.contextElement}function eu(e){let t=eL(e);if(!aa(t))return Eo(1);let n=t.getBoundingClientRect(),{width:o,height:a,$:r}=U8(t),s=(r?Jp(n.width):n.width)/o,i=(r?Jp(n.height):n.height)/a;return(!s||!Number.isFinite(s))&&(s=1),(!i||!Number.isFinite(i))&&(i=1),{x:s,y:i}}var MV=Eo(0);function G8(e){let t=yn(e);return!ug()||!t.visualViewport?MV:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function RV(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yn(e)?!1:t}function tl(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),r=eL(e),s=Eo(1);t&&(o?uo(o)&&(s=eu(o)):s=eu(e));let i=RV(r,n,o)?G8(r):Eo(0),l=(a.left+i.x)/s.x,c=(a.top+i.y)/s.y,u=a.width/s.x,d=a.height/s.y;if(r){let f=yn(r),p=o&&uo(o)?yn(o):o,h=f,m=dg(h);for(;m&&o&&p!==h;){let x=eu(m),y=m.getBoundingClientRect(),g=fo(m),b=y.left+(m.clientLeft+parseFloat(g.paddingLeft))*x.x,A=y.top+(m.clientTop+parseFloat(g.paddingTop))*x.y;l*=x.x,c*=x.y,u*=x.x,d*=x.y,l+=b,c+=A,h=yn(m),m=dg(h)}}return $i({width:u,height:d,x:l,y:c})}function fg(e,t){let n=ah(e).scrollLeft;return t?t.left+n:tl(To(e)).left+n}function W8(e,t){let n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-fg(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function OV(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e,r=a==="fixed",s=To(o),i=t?oh(t.floating):!1;if(o===s||i&&r)return n;let l={scrollLeft:0,scrollTop:0},c=Eo(1),u=Eo(0),d=aa(o);if((d||!d&&!r)&&((Ji(o)!=="body"||Jc(s))&&(l=ah(o)),d)){let p=tl(o);c=eu(o),u.x=p.x+o.clientLeft,u.y=p.y+o.clientTop}let f=s&&!d&&!r?W8(s,l):Eo(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function DV(e){return Array.from(e.getClientRects())}function PV(e){let t=To(e),n=ah(e),o=e.ownerDocument.body,a=er(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=er(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight),s=-n.scrollLeft+fg(e),i=-n.scrollTop;return fo(o).direction==="rtl"&&(s+=er(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:s,y:i}}var z8=25;function BV(e,t){let n=yn(e),o=To(e),a=n.visualViewport,r=o.clientWidth,s=o.clientHeight,i=0,l=0;if(a){r=a.width,s=a.height;let u=ug();(!u||u&&t==="fixed")&&(i=a.offsetLeft,l=a.offsetTop)}let c=fg(o);if(c<=0){let u=o.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,h=Math.abs(o.clientWidth-d.clientWidth-p);h<=z8&&(r-=h)}else c<=z8&&(r+=c);return{width:r,height:s,x:i,y:l}}function NV(e,t){let n=tl(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=aa(e)?eu(e):Eo(1),s=e.clientWidth*r.x,i=e.clientHeight*r.y,l=a*r.x,c=o*r.y;return{width:s,height:i,x:l,y:c}}function F8(e,t,n){let o;if(t==="viewport")o=BV(e,n);else if(t==="document")o=PV(To(e));else if(uo(t))o=NV(t,n);else{let a=G8(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return $i(o)}function q8(e,t){let n=nr(e);return n===t||!uo(n)||el(n)?!1:fo(n).position==="fixed"||q8(n,t)}function zV(e,t){let n=t.get(e);if(n)return n;let o=Qc(e,[],!1).filter(i=>uo(i)&&Ji(i)!=="body"),a=null,r=fo(e).position==="fixed",s=r?nr(e):e;for(;uo(s)&&!el(s);){let i=fo(s),l=cg(s);!l&&i.position==="fixed"&&(a=null),(r?!l&&!a:!l&&i.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Jc(s)&&!l&&q8(e,s))?o=o.filter(u=>u!==s):a=i,s=nr(s)}return t.set(e,o),o}function FV(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e,s=[...n==="clippingAncestors"?oh(t)?[]:zV(t,this._c):[].concat(n),o],i=F8(t,s[0],a),l=i.top,c=i.right,u=i.bottom,d=i.left;for(let f=1;f<s.length;f++){let p=F8(t,s[f],a);l=er(p.top,l),c=$c(p.right,c),u=$c(p.bottom,u),d=er(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function HV(e){let{width:t,height:n}=U8(e);return{width:t,height:n}}function UV(e,t,n){let o=aa(t),a=To(t),r=n==="fixed",s=tl(e,!0,r,t),i={scrollLeft:0,scrollTop:0},l=Eo(0);function c(){l.x=fg(a)}if(o||!o&&!r)if((Ji(t)!=="body"||Jc(a))&&(i=ah(t)),o){let p=tl(t,!0,r,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else a&&c();r&&!o&&a&&c();let u=a&&!o&&!r?W8(a,i):Eo(0),d=s.left+i.scrollLeft-l.x-u.x,f=s.top+i.scrollTop-l.y-u.y;return{x:d,y:f,width:s.width,height:s.height}}function JS(e){return fo(e).position==="static"}function H8(e,t){if(!aa(e)||fo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return To(e)===n&&(n=n.ownerDocument.body),n}function j8(e,t){let n=yn(e);if(oh(e))return n;if(!aa(e)){let a=nr(e);for(;a&&!el(a);){if(uo(a)&&!JS(a))return a;a=nr(a)}return n}let o=H8(e,t);for(;o&&P8(o)&&JS(o);)o=H8(o,t);return o&&el(o)&&JS(o)&&!cg(o)?n:o||B8(e)||n}var GV=async function(e){let t=this.getOffsetParent||j8,n=this.getDimensions,o=await n(e.floating);return{reference:UV(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function WV(e){return fo(e).direction==="rtl"}var qV={convertOffsetParentRelativeRectToViewportRelativeRect:OV,getDocumentElement:To,getClippingRect:FV,getOffsetParent:j8,getElementRects:GV,getClientRects:DV,getDimensions:HV,getScale:eu,isElement:uo,isRTL:WV};function V8(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function jV(e,t){let n=null,o,a=To(e);function r(){var i;clearTimeout(o),(i=n)==null||i.disconnect(),n=null}function s(i,l){i===void 0&&(i=!1),l===void 0&&(l=1),r();let c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(i||t(),!f||!p)return;let h=eh(d),m=eh(a.clientWidth-(u+f)),x=eh(a.clientHeight-(d+p)),y=eh(u),b={rootMargin:-h+"px "+-m+"px "+-x+"px "+-y+"px",threshold:er(0,$c(1,l))||1},A=!0;function _(T){let w=T[0].intersectionRatio;if(w!==l){if(!A)return s();w?s(!1,w):o=setTimeout(()=>{s(!1,1e-7)},1e3)}w===1&&!V8(c,e.getBoundingClientRect())&&s(),A=!1}try{n=new IntersectionObserver(_,{...b,root:a.ownerDocument})}catch{n=new IntersectionObserver(_,b)}n.observe(e)}return s(!0),r}function pg(e,t,n,o){o===void 0&&(o={});let{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,c=eL(e),u=a||r?[...c?Qc(c):[],...t?Qc(t):[]]:[];u.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});let d=c&&i?jV(c,n):null,f=-1,p=null;s&&(p=new ResizeObserver(y=>{let[g]=y;g&&g.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let h,m=l?tl(e):null;l&&x();function x(){let y=tl(e);m&&!V8(m,y)&&n(),m=y,h=requestAnimationFrame(x)}return n(),()=>{var y;u.forEach(g=>{a&&g.removeEventListener("scroll",n),r&&g.removeEventListener("resize",n)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(h)}}var hg=M8;var mg=R8,yg=I8;var gg=(e,t,n)=>{let o=new Map,a={platform:qV,...n},r={...a.platform,_c:o};return T8(e,t,{...a,platform:r})};var sa=P(re(),1),rL=P(ha(),1);var k=P(se(),1),hs=P(re(),1);var Z8=P(se(),1),ps=P(re(),1),X8=(0,ps.createContext)(null),Y8=({children:e})=>{let t=(0,ps.useRef)(null),n=(0,ps.useMemo)(()=>({open:o=>t.current?.(o),register:o=>(t.current=o,()=>{t.current===o&&(t.current=null)})}),[]);return(0,Z8.jsx)(X8.Provider,{value:n,children:e})},xg=()=>(0,ps.useContext)(X8);var Bt=P(se(),1),Q8=P(re(),1);var VV=ts.map(e=>Ic.light[e].fill),ZV=ts.map(e=>Ic.light[e].solid),XV=ts.map(e=>Ic.dark[e].fill),YV=ts.map(e=>Ic.dark[e].solid),KV=ts.map(e=>fy.light[e]),$V=ts.map(e=>fy.dark[e]),bg=[...VV,...ZV,"#ffffff","#1e1e1e","transparent"],tL=[...XV,...YV,"#1e1e1e","#ffffff","transparent"],y0e=["#ffffff",...KV],g0e=["#121113",...$V],K8=e=>e==="light"||e==="dark"?e:typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";var tu=({value:e,onChange:t,palette:n,allowCustom:o=!0,allowClear:a=!0,onEyedrop:r})=>{let s=n??tZ(),[i,l]=(0,Q8.useState)(!1);return(0,Bt.jsxs)("div",{className:"du-swatch-grid",role:"radiogroup","aria-label":"Colour",children:[s.map(c=>(0,Bt.jsx)(QV,{color:c,selected:$8(c)===$8(e),onClick:()=>{t(c==="transparent"?null:c)}},c)),o?(0,Bt.jsx)(JV,{value:e,onChange:t,open:i,onOpenChange:l}):null,r?(0,Bt.jsx)("button",{type:"button","aria-label":"Pick colour from canvas",title:"Pick colour from canvas",onClick:()=>{r(c=>{t(c)})},className:"du-swatch du-swatch-eyedrop",children:(0,Bt.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,Bt.jsx)(sf,{size:12,strokeWidth:2})})}):null,a?(0,Bt.jsx)("button",{type:"button","aria-label":"Clear colour",title:"Clear colour",onClick:()=>{t(null)},className:"du-swatch du-swatch-clear",children:(0,Bt.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,Bt.jsx)(Na,{size:12,strokeWidth:2})})}):null]})},QV=({color:e,selected:t,onClick:n})=>(0,Bt.jsx)("button",{type:"button",role:"radio","aria-checked":t,"aria-label":e,title:e,onClick:n,className:"du-swatch",children:(0,Bt.jsx)("span",{className:"du-swatch-fill",style:{background:e==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":e}})}),JV=({value:e,onChange:t,open:n,onOpenChange:o})=>{let a=!!e&&e!=="transparent";return(0,Bt.jsxs)("label",{className:"du-swatch du-swatch-custom",title:"Pick custom colour",children:[(0,Bt.jsx)("span",{className:"du-swatch-fill",style:a?{background:e}:void 0,children:a?null:(0,Bt.jsx)(Qs,{size:12,strokeWidth:2})}),(0,Bt.jsx)("input",{type:"color","aria-label":"Custom colour",value:eZ(e),onChange:r=>{t(r.target.value),o(!1)},onClick:()=>{o(!n)},className:"du-swatch-color-input"})]})},$8=e=>e===null?"transparent":e.toLowerCase(),eZ=e=>{if(!e||e==="transparent")return"#000000";if(/^#[0-9a-f]{6}$/i.test(e))return e.toLowerCase();if(/^#[0-9a-f]{3}$/i.test(e)){let t=e.slice(1);return`#${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`.toLowerCase()}return"#000000"},tZ=()=>{if(typeof document>"u")return bg;let e=document.documentElement.getAttribute("data-theme");return e==="dark"?tL:e==="light"?bg:K8("system")==="dark"?tL:bg};var nu=P(se(),1);var xt=P(re(),1),J8=P(ha(),1);var Io=({trigger:e,children:t,placement:n="bottom-start",offset:o=6,className:a,open:r,onOpenChange:s,ariaLabel:i})=>{let l=Dt(),[c,u]=(0,xt.useState)(!1),d=r!==void 0,f=d?r:c,p=(0,xt.useCallback)(g=>{d||u(g),s?.(g)},[d,s]),h=(0,xt.useId)(),m=(0,xt.useRef)(null),x=(0,xt.useRef)(null);(0,xt.useLayoutEffect)(()=>{if(!f)return;let g=m.current,b=x.current;if(!g||!b)return;let A=()=>{gg(g,b,{placement:n,middleware:[hg(o),yg(),mg({padding:6})]}).then(({x:T,y:w})=>{b.style.transform=`translate(${Math.round(T)}px, ${Math.round(w)}px)`})};return A(),pg(g,b,A)},[f,n,o]),(0,xt.useEffect)(()=>{if(!f)return;let g=A=>{let _=A.target;_&&(m.current?.contains(_)||x.current?.contains(_)||p(!1))},b=A=>{A.key==="Escape"&&(A.stopPropagation(),p(!1),m.current?.focus())};return document.addEventListener("pointerdown",g),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",g),document.removeEventListener("keydown",b)}},[f,p]);let y=(0,xt.useMemo)(()=>{if(!(0,xt.isValidElement)(e))return e;let g=e.props;return(0,xt.cloneElement)(e,{ref:b=>{m.current=b;let A=e.ref;typeof A=="function"?A(b):A&&typeof A=="object"&&(A.current=b)},onClick:b=>{let A=g.onClick;A?.(b),!b.defaultPrevented&&p(!f)},"aria-haspopup":"dialog","aria-expanded":f,"aria-controls":f?h:void 0})},[e,f,p,h]);return(0,nu.jsxs)(nu.Fragment,{children:[y,f?(0,J8.createPortal)((0,nu.jsx)("div",{ref:x,id:h,role:"dialog","aria-label":i,className:`du-popover ${a??""}`.trim(),style:{position:"absolute",top:0,left:0,zIndex:1600},children:t}),l):null]})};var oL=({style:e,className:t,mobile:n=!1})=>{let o=Qy(),a=zS(),r=Ya();if(is())return null;if(o.size>0){let i=[...o].map(p=>r.elements.get(p)).filter(p=>p!==void 0);if(i.length===0)return null;let l=i.every(p=>fe(p)),c=i.every(p=>ct(p)),u=i.every(p=>Be(p)),d=[],f=[];return u?d.push((0,k.jsx)(nD,{shapes:i},"fill")):l?(d.push((0,k.jsx)(aZ,{shapes:i},"size"),(0,k.jsx)(oZ,{shapes:i},"color"),(0,k.jsx)(sZ,{shapes:i},"align")),f.push((0,k.jsx)(rZ,{shapes:i},"family"),(0,k.jsx)(iZ,{shapes:i},"decor"))):c?d.push((0,k.jsx)(oD,{shapes:i},"opacity"),(0,k.jsx)(hZ,{shapes:i},"crop")):(d.push((0,k.jsx)(nD,{shapes:i},"fill"),(0,k.jsx)(lZ,{shapes:i},"stroke"),(0,k.jsx)(cZ,{shapes:i},"width")),f.push((0,k.jsx)(uZ,{shapes:i},"dash"),(0,k.jsx)(dZ,{shapes:i},"round"),(0,k.jsx)(oD,{shapes:i},"opacity"),(0,k.jsx)(pZ,{shapes:i},"convert"))),f.push((0,k.jsx)(fZ,{},"z"),(0,k.jsx)(nZ,{shapes:i},"link")),i.length>=2&&f.push((0,k.jsx)(gZ,{},"align")),f.push((0,k.jsx)(mZ,{shapes:i},"actions"),(0,k.jsx)(tD,{},"more")),(0,k.jsx)(eD,{mobile:n,primary:d,overflow:f,className:t,style:e})}if(a!==null){let i=r.links.get(a);if(!i)return null;let l=[(0,k.jsx)(xZ,{edge:i},"color"),(0,k.jsx)(bZ,{edge:i},"width"),(0,k.jsx)(aD,{edge:i,side:"to"},"arrow-to")],c=[(0,k.jsx)(AZ,{edge:i},"dash"),(0,k.jsx)(SZ,{edge:i},"routing"),(0,k.jsx)(vZ,{edge:i},"kind"),(0,k.jsx)(aD,{edge:i,side:"from"},"arrow-from"),(0,k.jsx)(LZ,{edge:i},"auto"),(0,k.jsx)(kZ,{},"delete"),(0,k.jsx)(tD,{},"more")];return(0,k.jsx)(eD,{mobile:n,primary:l,overflow:c,className:t,style:e})}return null},eD=({mobile:e,primary:t,overflow:n,className:o,style:a})=>{let[r,s]=(0,hs.useState)(!1),i=(0,hs.useRef)(null);return(0,hs.useEffect)(()=>{if(!e||!r)return;let l=c=>{let u=i.current;u&&c.target instanceof Node&&!u.contains(c.target)&&s(!1)};return document.addEventListener("pointerdown",l,!0),()=>{document.removeEventListener("pointerdown",l,!0)}},[e,r]),e?(0,k.jsxs)("div",{ref:i,className:`du-sel-panel du-sel-panel-mobile ${o??""}`.trim(),style:a,children:[(0,k.jsxs)("div",{className:"du-sel-mobile-row",children:[(0,k.jsx)("div",{className:"du-sel-mobile-primary",children:t}),n.length>0?(0,k.jsx)("button",{type:"button",className:`du-sel-icon-button du-sel-mobile-expand${r?" is-active":""}`,"aria-expanded":r,"aria-label":r?"Hide more properties":"More properties",title:"More properties",onClick:()=>{s(l=>!l)},children:(0,k.jsx)(Ur,{size:18,strokeWidth:1.75,"aria-hidden":!0})}):null]}),r&&n.length>0?(0,k.jsx)("div",{className:"du-sel-mobile-overflow",children:n}):null]}):(0,k.jsxs)("div",{className:`du-sel-panel ${o??""}`.trim(),style:a,children:[t,n.length>0?(0,k.jsx)(CZ,{}):null,n]})},nZ=({shapes:e})=>{let t=G(),n=(0,hs.useRef)(null);if(!t)return null;let o=e.map(i=>i.id),a=rh(e,i=>i.href),r=e.some(i=>!!i.href),s=i=>{t.setLink(o,i)};return(0,k.jsx)(Io,{ariaLabel:"Link",trigger:(0,k.jsx)("button",{type:"button",className:`du-sel-icon-button${r?" is-active":""}`,title:"Link","aria-label":"Link",children:(0,k.jsx)(Xd,{size:14,strokeWidth:1.75,"aria-hidden":!0})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Link"}),(0,k.jsx)("input",{ref:n,className:"du-sel-link-input",type:"text",placeholder:"https://\u2026 \xB7 name@mail",defaultValue:a??"","aria-label":"Link URL",onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),s(i.currentTarget.value))}}),(0,k.jsxs)("div",{style:{display:"flex",gap:2},children:[(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{s(n.current?.value??"")},children:"Save"}),r?(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{t.openLink(a)},children:"Open"}):null,r?(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",onClick:()=>{t.setLink(o,null)},children:"Remove"}):null]})]})})},tD=()=>{let e=G(),t=xg();return!e||!t?null:(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"More actions","aria-label":"More actions",onClick:n=>{let o=n.currentTarget.getBoundingClientRect(),a={x:o.left,y:o.bottom+4},s=e.hostElement?.getBoundingClientRect(),i=s?e.screenToWorld({x:a.x-s.left,y:a.y-s.top}):{x:0,y:0};t.open({screenPoint:a,worldPoint:i})},children:(0,k.jsx)(Gr,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},aL=({label:e,color:t,onChange:n,ariaLabel:o,onEyedrop:a})=>(0,k.jsx)(Io,{ariaLabel:o,trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-color-trigger",title:e,"aria-label":o,children:(0,k.jsx)("span",{className:"du-sel-color-swatch",style:{background:!t||t==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":t}})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:e}),(0,k.jsx)(tu,{value:t,onChange:n,...a?{onEyedrop:a}:{}})]})}),iD=e=>{let t=sn(a=>a.editingTextElement,null),n=sn(a=>a.editingTextSelection,null);if(t===null||n===null||n.start===n.end)return null;let o=e.find(a=>a.id===t);return o===void 0||!fe(o)?null:{target:o,from:Math.min(n.start,n.end),to:Math.max(n.start,n.end)}},oZ=({shapes:e})=>{let t=G(),n=iD(e);if(!t)return null;let o=e.map(l=>l.id),a=rh(e,l=>l.style.fill),r=ra(e,l=>l.style.opacity??1),s=r===null?null:Math.round(r*100);return(0,k.jsx)(Io,{ariaLabel:"Text color and opacity",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-color-trigger",title:"Color & opacity","aria-label":"Text color and opacity",children:(0,k.jsx)("span",{className:"du-sel-color-swatch",style:{background:!a||a==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":a,opacity:r??1}})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Color"}),(0,k.jsx)(tu,{value:a,onChange:l=>{n?t.applyTextStyleToRange(n.target.id,n.from,n.to,{fill:l??"transparent"}):t.updateStyle(o,{fill:l??"transparent"})},onEyedrop:l=>{t.beginEyedropperPick(l)}}),(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Opacity"}),(0,k.jsx)(_f,{value:s,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:s===null?"\u2014":`${s}%`,onChange:l=>{t.updateStyle(o,{opacity:l/100})}})]})})},nD=({shapes:e})=>{let t=G();if(!t||!e.some(EZ))return null;let n=rh(e,a=>a.style.fill),o=e.map(a=>a.id);return(0,k.jsx)(aL,{label:"Fill",ariaLabel:"Fill color",color:n,onChange:a=>{t.updateStyle(o,{fill:a??"transparent"})},onEyedrop:a=>{t.beginEyedropperPick(a)}})},aZ=({shapes:e})=>{let t=G();if(!t)return null;let n=e.map(r=>r.id),o=ra(e,r=>r.fontSize??null),a=o!==null&&zb.some(r=>r.value===o)?o:null;return(0,k.jsx)(Io,{ariaLabel:"Font size",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Font size","aria-label":`Font size ${o??"mixed"}`,children:o===null?"\u2014":`${Math.round(o)}`}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Font size"}),(0,k.jsx)(In,{ariaLabel:"Font size preset",value:a,options:zb.map(r=>({value:r.value,label:r.label,icon:(0,k.jsx)("span",{style:{fontSize:11,fontWeight:600},children:r.label})})),onChange:r=>{t.updateTextProps(n,{fontSize:r})}}),(0,k.jsx)(_f,{value:o,min:AE,max:vE,step:1,ariaLabel:"Font size",valueLabel:o===null?"\u2014":`${o}px`,onChange:r=>{t.updateTextProps(n,{fontSize:r})}})]})})},rZ=({shapes:e})=>{let t=G();if(!t)return null;let n=e.map(s=>s.id),o=rh(e,s=>s.fontFamily),a=Gb.find(s=>s.value===o),r=o===null?"Mixed":a?.label??"Custom";return(0,k.jsx)(Io,{ariaLabel:"Font family",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Font family","aria-label":`Font family ${r}`,style:o?{fontFamily:o}:void 0,children:r}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Font family"}),Gb.map(s=>(0,k.jsx)("button",{type:"button",role:"menuitemradio","aria-checked":s.value===o,className:`du-sel-menu-row${s.value===o?" is-active":""}`,style:{fontFamily:s.value},onClick:()=>{t.updateTextProps(n,{fontFamily:s.value})},children:s.label},s.value))]})})},sZ=({shapes:e})=>{let t=G();if(!t)return null;let n=e.map(a=>a.id),o=ra(e,a=>a.style.textAlign??"left");return(0,k.jsx)(In,{ariaLabel:"Text alignment",value:o,options:[{value:"left",label:"Left",icon:(0,k.jsx)(bo,{size:14,strokeWidth:1.75})},{value:"center",label:"Center",icon:(0,k.jsx)(jr,{size:14,strokeWidth:1.75})},{value:"right",label:"Right",icon:(0,k.jsx)(qr,{size:14,strokeWidth:1.75})}],onChange:a=>{t.updateStyle(n,{textAlign:a})}})},Ag=({active:e,label:t,icon:n,onClick:o})=>(0,k.jsx)("button",{type:"button",className:`du-sel-icon-button${e?" is-active":""}`,title:t,"aria-label":t,"aria-pressed":e,onClick:o,children:n}),iZ=({shapes:e})=>{let t=G(),n=iD(e);if(!t)return null;let o=e.map(p=>p.id),a=n?Of(n.target,n.from,n.to):[],r=n?.target.style,s=p=>a.length>0&&a.every(h=>p(h.style)),i=n?s(p=>(p?.fontWeight??r?.fontWeight)==="bold"):e.every(p=>p.style?.fontWeight==="bold"),l=n?s(p=>(p?.fontStyle??r?.fontStyle)==="italic"):e.every(p=>p.style?.fontStyle==="italic"),c=n?s(p=>(p?.textDecoration??r?.textDecoration)?.underline===!0):e.every(p=>p.style?.textDecoration?.underline===!0),u=n?s(p=>(p?.textDecoration??r?.textDecoration)?.strikethrough===!0):e.every(p=>p.style?.textDecoration?.strikethrough===!0),d=p=>{n?t.applyTextStyleToRange(n.target.id,n.from,n.to,p):t.updateStyle(o,p)},f=(p,h)=>{if(n)t.applyTextStyleToRange(n.target.id,n.from,n.to,{textDecoration:{underline:c,strikethrough:u,[p]:h}});else for(let m of e){let x=m.style?.textDecoration??{};t.updateStyle([m.id],{textDecoration:{...x,[p]:h}})}};return(0,k.jsx)(Io,{ariaLabel:"Text style",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Text style (bold / italic / \u2026)","aria-label":"Text style",children:(0,k.jsx)(Cd,{size:16,strokeWidth:1.75,"aria-hidden":!0})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Style"}),(0,k.jsxs)("div",{style:{display:"flex",gap:2},children:[(0,k.jsx)(Ag,{active:i,label:"Bold",icon:(0,k.jsx)(_d,{size:14,strokeWidth:1.75}),onClick:()=>{d({fontWeight:i?"normal":"bold"})}}),(0,k.jsx)(Ag,{active:l,label:"Italic",icon:(0,k.jsx)(Vd,{size:14,strokeWidth:1.75}),onClick:()=>{d({fontStyle:l?"normal":"italic"})}}),(0,k.jsx)(Ag,{active:c,label:"Underline",icon:(0,k.jsx)(gf,{size:14,strokeWidth:1.75}),onClick:()=>{f("underline",!c)}}),(0,k.jsx)(Ag,{active:u,label:"Strikethrough",icon:(0,k.jsx)(hf,{size:14,strokeWidth:1.75}),onClick:()=>{f("strikethrough",!u)}})]})]})})},lZ=({shapes:e})=>{let t=G();if(!t||!e.some(cD))return null;let n=rh(e,a=>a.style.stroke),o=e.map(a=>a.id);return(0,k.jsx)(aL,{label:"Stroke",ariaLabel:"Stroke color",color:n,onChange:a=>{t.updateStyle(o,{stroke:a??"transparent"})},onEyedrop:a=>{t.beginEyedropperPick(a)}})},cZ=({shapes:e})=>{let t=G();if(!t||!e.some(a=>a.style.stroke!==void 0))return null;let n=ra(e,a=>a.style.strokeWidth??null),o=e.map(a=>a.id);return(0,k.jsx)(In,{ariaLabel:"Stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,k.jsx)(ou,{thickness:1})},{value:2,label:"Medium",icon:(0,k.jsx)(ou,{thickness:2.5})},{value:4,label:"Thick",icon:(0,k.jsx)(ou,{thickness:4})}],onChange:a=>{t.updateStyle(o,{strokeWidth:a})}})},uZ=({shapes:e})=>{let t=G();if(!t||!e.some(cD))return null;let n=ra(e,a=>{let r=a.style.dashArray;return!r||r.length===0?"solid":(r[0]??0)<=3?"dotted":"dashed"}),o=e.map(a=>a.id);return(0,k.jsx)(In,{ariaLabel:"Stroke style",value:n,options:[{value:"solid",label:"Solid",icon:(0,k.jsx)(Uo,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,k.jsx)(Pa,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,k.jsx)(Ba,{size:14,strokeWidth:1.75})}],onChange:a=>{let r=a==="solid"?[]:a==="dashed"?[8,4]:[2,4];t.updateStyle(o,{dashArray:r})}})},dZ=({shapes:e})=>{let t=G();if(!t||!e.every(i=>ii(i)||i.type==="container"))return null;let o=ra(e,i=>i.style.roundness?.type??"sharp"),a=ra(e,i=>i.style.roundness?.value??null),r=e.map(i=>i.id),s=a===null;return(0,k.jsx)(Io,{ariaLabel:"Corners",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Corners","aria-label":"Corners",children:(0,k.jsx)(nL,{kind:o??"sharp"})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Corners"}),(0,k.jsx)(In,{ariaLabel:"Corner roundness",value:o,options:[{value:"sharp",label:"Sharp",icon:(0,k.jsx)(nL,{kind:"sharp"})},{value:"round",label:"Round",icon:(0,k.jsx)(nL,{kind:"round"})}],onChange:i=>{t.updateStyle(r,{roundness:{type:i}})}}),o==="round"?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)("label",{className:"du-prop-checkbox",children:[(0,k.jsx)("input",{type:"checkbox",checked:s,onChange:i=>{i.target.checked?t.updateStyle(r,{roundness:{type:"round"}}):t.updateStyle(r,{roundness:{type:"round",value:a??8}})}}),(0,k.jsx)("span",{children:"Auto radius"})]}),s?null:(0,k.jsx)(_f,{value:a,min:0,max:64,step:1,ariaLabel:"Corner radius",valueLabel:`${a}px`,onChange:i=>{t.updateStyle(r,{roundness:{type:"round",value:i}})}})]}):null]})})},oD=({shapes:e})=>{let t=G();if(!t)return null;let n=ra(e,s=>s.style.opacity??1),o=e.map(s=>s.id),a=n===null?null:Math.round(n*100),r=a===null?"\u2014":`${a}%`;return(0,k.jsx)(Io,{ariaLabel:"Opacity",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-text-button",title:"Opacity","aria-label":`Opacity ${r}`,children:r}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Opacity"}),(0,k.jsx)(_f,{value:a,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:r,onChange:s=>{t.updateStyle(o,{opacity:s/100})}})]})})},fZ=()=>{let e=G();return e?(0,k.jsx)(In,{ariaLabel:"Z-order",value:null,options:[{value:"back",label:"Send to back",icon:(0,k.jsx)(Id,{size:14,strokeWidth:1.75})},{value:"backward",label:"Send backward",icon:(0,k.jsx)(of,{size:14,strokeWidth:1.75})},{value:"forward",label:"Bring forward",icon:(0,k.jsx)(rf,{size:14,strokeWidth:1.75})},{value:"front",label:"Bring to front",icon:(0,k.jsx)(Md,{size:14,strokeWidth:1.75})}],onChange:t=>{t==="back"?e.sendToBack():t==="backward"?e.sendBackward():t==="forward"?e.bringForward():e.bringToFront()}}):null},pZ=({shapes:e})=>{let t=G();if(!t||!e.every(a=>ii(a)||sc(a)||Fa(a)))return null;let o=ra(e,a=>ii(a)?"rectangle":sc(a)?"ellipse":"polygon");return(0,k.jsx)(In,{ariaLabel:"Shape type",value:o,options:[{value:"rectangle",label:"Rectangle",icon:(0,k.jsx)(Uo,{size:14,strokeWidth:1.75})},{value:"ellipse",label:"Ellipse",icon:(0,k.jsx)(Ys,{size:14,strokeWidth:1.75})},{value:"polygon",label:"Diamond",icon:(0,k.jsx)(Pd,{size:14,strokeWidth:1.75})}],onChange:a=>{t.convertSelection(a)}})},hZ=({shapes:e})=>{let t=G();if(!t)return null;let n=e.length===1?e[0]:void 0;if(n===void 0||!ct(n))return null;let o=n.id;return(0,k.jsx)("button",{type:"button",className:"du-icon-button",title:"Crop image (double-click)","aria-label":"Crop image",onClick:()=>{t.beginImageCrop(o)},children:(0,k.jsx)(Od,{size:16,strokeWidth:1.75})})},mZ=({shapes:e})=>{let t=G();if(!t)return null;let n=e.length>=2,o=e.some(r=>ze(r)),a=[{value:"duplicate",label:"Duplicate",icon:(0,k.jsx)(Hr,{size:14,strokeWidth:1.75})},{value:"delete",label:"Delete",icon:(0,k.jsx)(tc,{size:14,strokeWidth:1.75})}];return n&&a.push({value:"group",label:"Group",icon:(0,k.jsx)(qd,{size:14,strokeWidth:1.75})}),o&&a.push({value:"ungroup",label:"Ungroup",icon:(0,k.jsx)(xf,{size:14,strokeWidth:1.75})}),a.push({value:"flip-h",label:"Flip horizontal",icon:(0,k.jsx)(Hd,{size:14,strokeWidth:1.75})},{value:"flip-v",label:"Flip vertical",icon:(0,k.jsx)(Ud,{size:14,strokeWidth:1.75})}),(0,k.jsx)(In,{ariaLabel:"Element actions",value:null,options:a,onChange:r=>{r==="duplicate"?t.duplicateSelected():r==="delete"?t.deleteSelected():r==="group"?t.groupSelected():r==="ungroup"?t.ungroup():r==="flip-h"?t.flipSelection("horizontal"):t.flipSelection("vertical")}})},yZ=[{edge:"left",label:"Align left",icon:(0,k.jsx)(kd,{size:16,strokeWidth:1.75})},{edge:"h-center",label:"Align horizontal centres",icon:(0,k.jsx)(Ql,{size:16,strokeWidth:1.75})},{edge:"right",label:"Align right",icon:(0,k.jsx)(vd,{size:16,strokeWidth:1.75})},{edge:"top",label:"Align top",icon:(0,k.jsx)(Ld,{size:16,strokeWidth:1.75})},{edge:"v-center",label:"Align vertical centres",icon:(0,k.jsx)(bd,{size:16,strokeWidth:1.75})},{edge:"bottom",label:"Align bottom",icon:(0,k.jsx)(Ad,{size:16,strokeWidth:1.75})}],gZ=()=>{let e=G(),t=Qy();if(!e)return null;let n=t.size>=3;return(0,k.jsx)(Io,{ariaLabel:"Align and distribute",trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Align","aria-label":"Align",children:(0,k.jsx)(Ql,{size:16,strokeWidth:1.75})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Align"}),(0,k.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:4},children:yZ.map(o=>(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:o.label,"aria-label":o.label,onClick:()=>{e.alignSelection(o.edge)},children:o.icon},o.edge))}),n?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)("header",{className:"du-sel-popover-label",children:"Distribute"}),(0,k.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Distribute horizontally","aria-label":"Distribute horizontally",onClick:()=>{e.distributeSelection("horizontal")},children:(0,k.jsx)(Sd,{size:16,strokeWidth:1.75})}),(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Distribute vertically","aria-label":"Distribute vertically",onClick:()=>{e.distributeSelection("vertical")},children:(0,k.jsx)(wd,{size:16,strokeWidth:1.75})})]})]}):null]})})},xZ=({edge:e})=>{let t=G();if(!t)return null;let n=typeof e.style.stroke=="string"?e.style.stroke:null;return(0,k.jsx)(aL,{label:"Stroke",ariaLabel:"Link stroke color",color:n,onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,stroke:o??"transparent"}}))},onEyedrop:o=>{t.beginEyedropperPick(o)}})},bZ=({edge:e})=>{let t=G();if(!t)return null;let n=typeof e.style.strokeWidth=="number"?e.style.strokeWidth:null;return(0,k.jsx)(In,{ariaLabel:"Link stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,k.jsx)(ou,{thickness:1})},{value:2,label:"Medium",icon:(0,k.jsx)(ou,{thickness:2.5})},{value:4,label:"Thick",icon:(0,k.jsx)(ou,{thickness:4})}],onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,strokeWidth:o}}))}})},AZ=({edge:e})=>{let t=G();if(!t)return null;let n=e.style.dashArray,o=!n||n.length===0?"solid":(n[0]??0)<=3?"dotted":"dashed";return(0,k.jsx)(In,{ariaLabel:"Link stroke style",value:o,options:[{value:"solid",label:"Solid",icon:(0,k.jsx)(Uo,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,k.jsx)(Pa,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,k.jsx)(Ba,{size:14,strokeWidth:1.75})}],onChange:a=>{let r=a==="solid"?[]:a==="dashed"?[8,4]:[2,4];t.updateSelectedLink(s=>({...s,style:{...s.style,dashArray:r}}))}})},vZ=({edge:e})=>{let t=G();if(!t)return null;let n=e.lineKind??"line";return(0,k.jsx)(In,{ariaLabel:"Link body",value:n,options:[{value:"line",label:"Line",icon:(0,k.jsx)(Da,{size:14,strokeWidth:1.75})},{value:"block-arrow",label:"Block arrow",icon:(0,k.jsx)(af,{size:14,strokeWidth:2.5})}],onChange:o=>{t.updateSelectedLink(a=>({...a,lineKind:o}))}})},SZ=({edge:e})=>{let t=G();if(!t)return null;let n=e.routing??"straight";return(0,k.jsx)(In,{ariaLabel:"Link routing",value:n,options:[{value:"straight",label:"Straight",icon:(0,k.jsx)(rD,{kind:"straight"})},{value:"orthogonal",label:"Elbow",icon:(0,k.jsx)(rD,{kind:"orthogonal"})},{value:"bezier",label:"Curved",icon:(0,k.jsx)(pf,{size:14,strokeWidth:1.75})}],onChange:o=>{t.updateSelectedLink(a=>({...a,routing:o}))}})},aD=({edge:e,side:t})=>{let n=G(),[o,a]=(0,hs.useState)(!1);if(!n)return null;let r=e.arrowheads?.[t]??"none",s=l=>{n.updateSelectedLink(c=>({...c,arrowheads:{...c.arrowheads??{},[t]:l}}))},i=({style:l})=>(0,k.jsx)("button",{type:"button",className:`du-arrowhead-option${l===r?" du-arrowhead-option--active":""}`,title:vg[l],"aria-label":vg[l],"aria-pressed":l===r,onClick:()=>{s(l)},children:l==="none"?(0,k.jsx)("span",{className:"du-arrowhead-none",children:"\u2205"}):lD(l)==="none"?(0,k.jsx)("span",{className:"du-arrowhead-erd-label",children:vg[l].replace(/^ERD /,"")}):(0,k.jsx)(sD,{kind:l,side:t})});return(0,k.jsx)(Io,{trigger:(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:`Arrow ${t}: ${vg[r]}`,"aria-label":`Arrow ${t}`,children:(0,k.jsx)(sD,{kind:r,side:t})}),children:(0,k.jsxs)("div",{className:"du-sel-popover-section",children:[(0,k.jsxs)("header",{className:"du-sel-popover-label",children:["Arrow ",t]}),(0,k.jsx)("div",{className:"du-arrowhead-grid",children:wZ.map(l=>(0,k.jsx)(i,{style:l},l))}),(0,k.jsxs)("button",{type:"button",className:"du-arrowhead-erd-toggle","aria-expanded":o,onClick:()=>{a(l=>!l)},children:[o?"\u25BE":"\u25B8"," ER diagram"]}),o&&(0,k.jsx)("div",{className:"du-arrowhead-grid",children:_Z.map(l=>(0,k.jsx)(i,{style:l},l))})]})})},LZ=({edge:e})=>{let t=G();if(!t||(e.routing??"straight")==="bezier")return null;let o=e.avoidObstacles===!0;return(0,k.jsx)("button",{type:"button",className:`du-sel-icon-button${o?" is-active":""}`,title:"Route around shapes","aria-label":"Route around shapes","aria-pressed":o,onClick:()=>{t.setSelectedLinkAvoidObstacles(!o)},children:(0,k.jsx)(Af,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},kZ=()=>{let e=G();return e?(0,k.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Delete edge","aria-label":"Delete edge",onClick:()=>{e.deleteSelected()},children:(0,k.jsx)(tc,{size:14,strokeWidth:1.75,"aria-hidden":!0})}):null},rD=({kind:e})=>e==="straight"?(0,k.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,k.jsx)("line",{x1:2,y1:11,x2:12,y2:3,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round"})}):(0,k.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,k.jsx)("path",{d:"M 2 11 L 2 7 L 12 7 L 12 3",stroke:"currentColor",strokeWidth:1.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}),lD=e=>{switch(e){case"arrow":case"openArrow":case"roundedArrow":case"arcArrow":return"open";case"triangle":case"filledArrow":return"triangle";case"diamond":case"rhombus":case"filledRhombus":return"diamond";case"circle":case"filledCircle":return"circle";default:return"none"}},wZ=["none","arrow","openArrow","roundedArrow","arcArrow","filledArrow","triangle","circle","filledCircle","rhombus","filledRhombus"],_Z=["erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"],vg={none:"None",arrow:"Arrow",openArrow:"Open arrow",roundedArrow:"Rounded arrow",arcArrow:"Arc arrow",triangle:"Triangle",filledArrow:"Filled arrow",circle:"Circle",filledCircle:"Filled circle",diamond:"Diamond",rhombus:"Rhombus",filledRhombus:"Filled rhombus",erdOne:"ERD one",erdOnlyOne:"ERD only one",erdMany:"ERD many",erdOneOrMany:"ERD one or many",erdZeroOrOne:"ERD zero or one",erdZeroOrMany:"ERD zero or many"},sD=({kind:e,side:t})=>{let n=t==="from",o=n?12:2,a=n?5:9,r=n?3:11,s=n?5:9,i=(0,k.jsx)("line",{x1:o,y1:7,x2:a,y2:7,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round"}),l=lD(e),c=null;return l==="open"?c=(0,k.jsx)("polyline",{points:n?`${r+3},4 ${r},7 ${r+3},10`:`${r-3},4 ${r},7 ${r-3},10`,stroke:"currentColor",strokeWidth:1.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}):l==="triangle"?c=(0,k.jsx)("polygon",{points:n?`${r},7 ${s},4 ${s},10`:`${r},7 ${s},4 ${s},10`,fill:"currentColor"}):l==="diamond"?c=(0,k.jsx)("polygon",{points:`${r},4 ${r+(n?-3:3)},7 ${r},10 ${r+(n?3:-3)},7`,fill:e==="filledRhombus"?"currentColor":"none",stroke:"currentColor",strokeWidth:1.2}):l==="circle"&&(c=(0,k.jsx)("circle",{cx:r,cy:7,r:2.2,fill:e==="filledCircle"?"currentColor":"none",stroke:"currentColor",strokeWidth:1.2})),(0,k.jsxs)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:[i,c]})},CZ=()=>(0,k.jsx)("span",{className:"du-sel-divider","aria-hidden":!0}),ou=({thickness:e})=>(0,k.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,k.jsx)("line",{x1:2,y1:7,x2:12,y2:7,stroke:"currentColor",strokeWidth:e,strokeLinecap:"round"})}),nL=({kind:e})=>e==="sharp"?(0,k.jsx)(Uo,{size:14,strokeWidth:1.75,"aria-hidden":!0}):(0,k.jsx)("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:(0,k.jsx)("rect",{x:2,y:2,width:10,height:10,rx:3,ry:3,stroke:"currentColor",strokeWidth:1.5})}),ra=(e,t)=>{let n=new Set;for(let a of e)n.add(t(a));return n.size!==1?null:n.values().next().value??null},rh=(e,t)=>{let n=ra(e,o=>t(o));return typeof n=="string"?n:null},EZ=e=>e.style.fill!==void 0||Be(e),cD=e=>e.style.stroke!==void 0;var sL=({offset:e=48,placement:t="top",edgeInset:n}={})=>{let o={top:n?.top??66,right:n?.right??16,bottom:n?.bottom??66,left:n?.left??16},a=G(),r=is(),s=Dt(),i=jp(),[l,c]=(0,sa.useState)(!1),u=(0,sa.useRef)(null),[d,f]=(0,sa.useState)(0),[p,h]=(0,sa.useState)(!1);return(0,sa.useEffect)(()=>{if(!a)return;let m=()=>{let x=a.selection,y=a.selection.size>0||a.selectedLink!==null;c(g=>(!g&&y&&h(!1),y)),f(g=>g+1)};return m(),a.on("change",m)},[a]),(0,sa.useLayoutEffect)(()=>{if(!a||!l||i)return;let m=u.current;if(!m)return;let x=TZ(a);if(!x)return;let y=()=>{gg(x,m,{placement:t,middleware:[hg(e),yg({fallbackPlacements:["bottom","right","left"],padding:o}),mg({padding:o})]}).then(({x:b,y:A})=>{m.style.transform=`translate(${Math.round(b)}px, ${Math.round(A)}px)`,h(!0)})};return y(),pg(x,m,y)},[a,l,i,d,e,t,o.top,o.right,o.bottom,o.left]),!a||!l||r?null:i?(0,rL.createPortal)((0,sh.jsx)("div",{className:"du-sel-panel-dock",role:"toolbar","aria-label":"Selection actions",children:(0,sh.jsx)(oL,{mobile:!0})}),s):(0,rL.createPortal)((0,sh.jsx)("div",{ref:u,className:"du-sel-panel-floating",role:"toolbar","aria-label":"Selection actions",style:{position:"absolute",top:0,left:0,zIndex:1500,pointerEvents:"auto",opacity:p?1:0,transition:p?"opacity 120ms ease":"none",...p?{}:{pointerEvents:"none"}},children:(0,sh.jsx)(oL,{})}),s)},TZ=e=>{let t=e.hostElement;return t?{getBoundingClientRect:()=>{let n=IZ(e);if(!n){let c=t.getBoundingClientRect();return new DOMRect(c.left,c.top,0,0)}let o=e.scene.viewport,a=(n.x-o.pan.x)*o.zoom,r=(n.y-o.pan.y)*o.zoom,s=Math.max(1,n.width*o.zoom),i=Math.max(1,n.height*o.zoom),l=t.getBoundingClientRect();return new DOMRect(l.left+a,l.top+r,s,i)},contextElement:t}:null},IZ=e=>{let t=[];for(let o of e.selection){let a=e.scene.elements.get(o);a&&t.push(a)}if(t.length===0){let o=e.selectedLink;if(o){let a=e.scene.links.get(o);if(a)return os(e.scene,a)}return null}let n=null;for(let o of t){if(ze(o)&&e.scene.elements.has(o.id)){let r=bA(e.scene,o.id);for(let s of r){if(ze(s))continue;let i;try{i=z(s)}catch{continue}i.width===0&&i.height===0||(n=uD(n,i))}continue}let a;try{a=z(o)}catch{continue}n=uD(n,a)}return n},uD=(e,t)=>{if(!e)return{...t};let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(e.x+e.width,t.x+t.width),r=Math.max(e.y+e.height,t.y+t.height);return{x:n,y:o,width:a-n,height:r-o}};var ys=P(se(),1),Le=P(re(),1);var au="Roboto",ih="PT Serif",lh="Roboto Mono",ru=e=>{let t=e.toLowerCase();return t.includes("mono")?lh:t.includes("sans")?au:t.includes("serif")||t.includes("slab")||t.includes("georgia")||t.includes("times")?ih:au},MZ=[{family:au,weight:"400",style:"normal",url:new URL("../fonts/Roboto-Regular.woff2",import.meta.url)},{family:au,weight:"700",style:"normal",url:new URL("../fonts/Roboto-Bold.woff2",import.meta.url)},{family:au,weight:"400",style:"italic",url:new URL("../fonts/Roboto-Italic.woff2",import.meta.url)},{family:au,weight:"700",style:"italic",url:new URL("../fonts/Roboto-BoldItalic.woff2",import.meta.url)},{family:ih,weight:"400",style:"normal",url:new URL("../fonts/PTSerif-Regular.woff2",import.meta.url)},{family:ih,weight:"700",style:"normal",url:new URL("../fonts/PTSerif-Bold.woff2",import.meta.url)},{family:ih,weight:"400",style:"italic",url:new URL("../fonts/PTSerif-Italic.woff2",import.meta.url)},{family:ih,weight:"700",style:"italic",url:new URL("../fonts/PTSerif-BoldItalic.woff2",import.meta.url)},{family:lh,weight:"400",style:"normal",url:new URL("../fonts/RobotoMono-Regular.woff2",import.meta.url)},{family:lh,weight:"700",style:"normal",url:new URL("../fonts/RobotoMono-Bold.woff2",import.meta.url)},{family:lh,weight:"400",style:"italic",url:new URL("../fonts/RobotoMono-Italic.woff2",import.meta.url)},{family:lh,weight:"700",style:"italic",url:new URL("../fonts/RobotoMono-BoldItalic.woff2",import.meta.url)}],dD=async(e=globalThis)=>{let t=e.fonts;!t||typeof FontFace>"u"||await Promise.allSettled(MZ.map(async n=>{let o=new FontFace(n.family,`url(${n.url.href})`,{weight:n.weight,style:n.style});await o.load(),t.add(o)}))};var RZ=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],Sg=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of RZ){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},pD=e=>{let t=e;return typeof t.naturalWidth=="number"&&t.naturalWidth>0?{width:t.naturalWidth,height:t.naturalHeight??t.naturalWidth}:typeof t.videoWidth=="number"&&t.videoWidth>0?{width:t.videoWidth,height:t.videoHeight??t.videoWidth}:typeof t.width=="number"&&t.width>0&&typeof t.height=="number"?{width:t.width,height:t.height}:null},fD=new Set,Lg=e=>{if(typeof console>"u")return;let t=typeof e=="string"?e.startsWith("blob:")?"dead-blob-url":"string-src":e==null?"empty":"stale-object";fD.has(t)||(fD.add(t),console.warn(`[renderer] skipped a non-drawable image source (kind: ${t}). The shape's image handle isn't a live HTMLImageElement / canvas / bitmap \u2014 likely a scene restored from storage where the <img> was lost (metadata.image) and src is a dead blob: URL. The image won't render until rehydrated from Scene.files.`))};var or=class{ctx;_width;_height;dpr;constructor(t,n,o,a=1){this.ctx=t,this._width=n,this._height=o,this.dpr=a}get size(){return{width:this._width,height:this._height}}resize(t,n,o){this._width=t,this._height=n,o!==void 0&&(this.dpr=o)}setFill(t){this.ctx.fillStyle=t??"transparent"}setStroke(t){this.ctx.strokeStyle=t??"transparent"}setStrokeWidth(t){this.ctx.lineWidth=t}setOpacity(t){this.ctx.globalAlpha=t}setLineCap(t){this.ctx.lineCap=t}setLineJoin(t){this.ctx.lineJoin=t}setDashArray(t){this.ctx.setLineDash(t?[...t]:[])}setFont(t,n,o){let a=o?.style==="italic"?"italic ":"",r=o?.weight==="bold"?"bold ":"";this.ctx.font=`${a}${r}${n}px "${ru(t)}", ${t}`}setTextAlign(t){this.ctx.textAlign=t==="center"?"center":t}setTextBaseline(t){this.ctx.textBaseline=t==="middle"?"middle":t==="top"?"top":"bottom"}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(t,n){this.ctx.translate(t,n)}rotate(t){this.ctx.rotate(t)}scale(t,n){this.ctx.scale(t,n)}setTransform(t){let n=this.dpr;this.ctx.setTransform(n*t.a,n*t.b,n*t.c,n*t.d,n*t.e,n*t.f)}resetTransform(){this.ctx.setTransform(this.dpr,0,0,this.dpr,0,0)}beginPath(){this.ctx.beginPath()}closePath(){this.ctx.closePath()}moveTo(t,n){this.ctx.moveTo(t,n)}lineTo(t,n){this.ctx.lineTo(t,n)}quadraticCurveTo(t,n,o,a){this.ctx.quadraticCurveTo(t,n,o,a)}bezierCurveTo(t,n,o,a,r,s){this.ctx.bezierCurveTo(t,n,o,a,r,s)}rect(t,n,o,a){this.ctx.rect(t,n,o,a)}ellipse(t,n,o,a){this.ctx.ellipse(t,n,o,a,0,0,Math.PI*2)}fill(t){this.ctx.fill(t)}stroke(){this.ctx.stroke()}fillText(t,n,o,a){a!==void 0?this.ctx.fillText(t,n,o,a):this.ctx.fillText(t,n,o)}measureText(t){return{width:this.ctx.measureText(t).width}}drawImage(t,n,o,a,r,s,i){if(!Sg(t)){Lg(t);return}if(i&&(i.x!==0||i.y!==0||i.width!==1||i.height!==1)){let l=pD(t);if(l){this.ctx.drawImage(t,i.x*l.width,i.y*l.height,i.width*l.width,i.height*l.height,n,o,a,r);return}}this.ctx.drawImage(t,n,o,a,r)}clear(t){this.dirtyRect=null,t?this.ctx.clearRect(t.x,t.y,t.width,t.height):(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}dirtyRect=null;markDirty(t){if(!this.dirtyRect){this.dirtyRect=t;return}let n=Math.min(this.dirtyRect.x,t.x),o=Math.min(this.dirtyRect.y,t.y),a=Math.max(this.dirtyRect.x+this.dirtyRect.width,t.x+t.width),r=Math.max(this.dirtyRect.y+this.dirtyRect.height,t.y+t.height);this.dirtyRect={x:n,y:o,width:a-n,height:r-o}}getDirtyRect(){return this.dirtyRect}};var ch=class{shaper;atlasSize;tileSize;range;columns;capacity;glyphs=new Map;buffer;dirtyTiles=new Set;needsFullUpload=!0;nextSlot=0;texture=null;constructor(t,n={}){if(this.shaper=t,this.atlasSize=n.atlasSize??2048,this.tileSize=n.tileSize??64,this.range=n.range??8,this.atlasSize%this.tileSize!==0)throw new Error(`GlyphAtlas: atlasSize (${this.atlasSize}) must be a multiple of tileSize (${this.tileSize})`);this.columns=this.atlasSize/this.tileSize,this.capacity=this.columns*this.columns,this.buffer=new Uint8Array(this.atlasSize*this.atlasSize*3)}resolveFontId(t,n=!1,o=!1){return this.shaper.resolveFontId?.(t,n,o)??0}getOrRasterize(t,n=0){let o=n*1114112+t,a=this.glyphs.get(o);if(a)return a;if(this.nextSlot>=this.capacity)return null;let r=this.shaper.glyphMetrics(t,n);if(!r)return null;let s=this.nextSlot++,i=s%this.columns,l=Math.floor(s/this.columns),c=i*this.tileSize,u=l*this.tileSize,d=r.bboxW<=0||r.bboxH<=0;if(!d){let p=this.shaper.rasterizeGlyphMSDF(t,this.tileSize,this.range,n);if(p){for(let h=0;h<this.tileSize;h++){let m=h*this.tileSize*3,x=((u+h)*this.atlasSize+c)*3;this.buffer.set(p.data.subarray(m,m+this.tileSize*3),x)}this.dirtyTiles.add(s)}}let f={codePoint:t,atlasX:c,atlasY:u,tileSize:this.tileSize,range:this.range,advance:r.advance,bboxXMin:r.bboxXMin,bboxYMin:r.bboxYMin,bboxW:r.bboxW,bboxH:r.bboxH,unitsPerEm:r.unitsPerEm,empty:d};return this.glyphs.set(o,f),f}get glyphCount(){return this.glyphs.size}get cpuBuffer(){return this.buffer}uploadTo(t){if(this.texture)t.bindTexture(t.TEXTURE_2D,this.texture);else{let n=t.createTexture();if(!n)throw new Error("GlyphAtlas: gl.createTexture() returned null");this.texture=n,t.bindTexture(t.TEXTURE_2D,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}if(this.needsFullUpload)return t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGB8,this.atlasSize,this.atlasSize,0,t.RGB,t.UNSIGNED_BYTE,this.buffer),this.needsFullUpload=!1,this.dirtyTiles.clear(),this.texture;if(this.dirtyTiles.size===0)return this.texture;t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ROW_LENGTH,this.atlasSize);for(let n of this.dirtyTiles){let o=n%this.columns,a=Math.floor(n/this.columns),r=o*this.tileSize,s=a*this.tileSize,i=r,l=s;t.pixelStorei(t.UNPACK_SKIP_PIXELS,i),t.pixelStorei(t.UNPACK_SKIP_ROWS,l),t.texSubImage2D(t.TEXTURE_2D,0,r,s,this.tileSize,this.tileSize,t.RGB,t.UNSIGNED_BYTE,this.buffer)}return t.pixelStorei(t.UNPACK_ROW_LENGTH,0),t.pixelStorei(t.UNPACK_SKIP_PIXELS,0),t.pixelStorei(t.UNPACK_SKIP_ROWS,0),this.dirtyTiles.clear(),this.texture}dispose(t){this.texture&&t&&t.deleteTexture(this.texture),this.texture=null,this.needsFullUpload=!0}};function cL(e,t,n=2){let o=t&&t.length,a=o?t[0]*n:e.length,r=mD(e,0,a,n,!0),s=[];if(!r||r.next===r.prev)return s;let i,l,c;if(o&&(r=NZ(e,t,r,n)),e.length>80*n){i=e[0],l=e[1];let u=i,d=l;for(let f=n;f<a;f+=n){let p=e[f],h=e[f+1];p<i&&(i=p),h<l&&(l=h),p>u&&(u=p),h>d&&(d=h)}c=Math.max(u-i,d-l),c=c!==0?32767/c:0}return dh(r,s,n,i,l,c,0),s}function mD(e,t,n,o,a){let r;if(a===XZ(e,t,n,o)>0)for(let s=t;s<n;s+=o)r=hD(s/o|0,e[s],e[s+1],r);else for(let s=n-o;s>=t;s-=o)r=hD(s/o|0,e[s],e[s+1],r);return r&&su(r,r.next)&&(ph(r),r=r.next),r}function nl(e,t){if(!e)return e;t||(t=e);let n=e,o;do if(o=!1,!n.steiner&&(su(n,n.next)||Ke(n.prev,n,n.next)===0)){if(ph(n),n=t=n.prev,n===n.next)break;o=!0}else n=n.next;while(o||n!==t);return t}function dh(e,t,n,o,a,r,s){if(!e)return;!s&&r&&GZ(e,o,a,r);let i=e;for(;e.prev!==e.next;){let l=e.prev,c=e.next;if(r?DZ(e,o,a,r):OZ(e)){t.push(l.i,e.i,c.i),ph(e),e=c.next,i=c.next;continue}if(e=c,e===i){s?s===1?(e=PZ(nl(e),t),dh(e,t,n,o,a,r,2)):s===2&&BZ(e,t,n,o,a,r):dh(nl(e),t,n,o,a,r,1);break}}}function OZ(e){let t=e.prev,n=e,o=e.next;if(Ke(t,n,o)>=0)return!1;let a=t.x,r=n.x,s=o.x,i=t.y,l=n.y,c=o.y,u=Math.min(a,r,s),d=Math.min(i,l,c),f=Math.max(a,r,s),p=Math.max(i,l,c),h=o.next;for(;h!==t;){if(h.x>=u&&h.x<=f&&h.y>=d&&h.y<=p&&uh(a,i,r,l,s,c,h.x,h.y)&&Ke(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function DZ(e,t,n,o){let a=e.prev,r=e,s=e.next;if(Ke(a,r,s)>=0)return!1;let i=a.x,l=r.x,c=s.x,u=a.y,d=r.y,f=s.y,p=Math.min(i,l,c),h=Math.min(u,d,f),m=Math.max(i,l,c),x=Math.max(u,d,f),y=iL(p,h,t,n,o),g=iL(m,x,t,n,o),b=e.prevZ,A=e.nextZ;for(;b&&b.z>=y&&A&&A.z<=g;){if(b.x>=p&&b.x<=m&&b.y>=h&&b.y<=x&&b!==a&&b!==s&&uh(i,u,l,d,c,f,b.x,b.y)&&Ke(b.prev,b,b.next)>=0||(b=b.prevZ,A.x>=p&&A.x<=m&&A.y>=h&&A.y<=x&&A!==a&&A!==s&&uh(i,u,l,d,c,f,A.x,A.y)&&Ke(A.prev,A,A.next)>=0))return!1;A=A.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=m&&b.y>=h&&b.y<=x&&b!==a&&b!==s&&uh(i,u,l,d,c,f,b.x,b.y)&&Ke(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;A&&A.z<=g;){if(A.x>=p&&A.x<=m&&A.y>=h&&A.y<=x&&A!==a&&A!==s&&uh(i,u,l,d,c,f,A.x,A.y)&&Ke(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function PZ(e,t){let n=e;do{let o=n.prev,a=n.next.next;!su(o,a)&&gD(o,n,n.next,a)&&fh(o,a)&&fh(a,o)&&(t.push(o.i,n.i,a.i),ph(n),ph(n.next),n=e=a),n=n.next}while(n!==e);return nl(n)}function BZ(e,t,n,o,a,r){let s=e;do{let i=s.next.next;for(;i!==s.prev;){if(s.i!==i.i&&jZ(s,i)){let l=xD(s,i);s=nl(s,s.next),l=nl(l,l.next),dh(s,t,n,o,a,r,0),dh(l,t,n,o,a,r,0);return}i=i.next}s=s.next}while(s!==e)}function NZ(e,t,n,o){let a=[];for(let r=0,s=t.length;r<s;r++){let i=t[r]*o,l=r<s-1?t[r+1]*o:e.length,c=mD(e,i,l,o,!1);c===c.next&&(c.steiner=!0),a.push(qZ(c))}a.sort(zZ);for(let r=0;r<a.length;r++)n=FZ(a[r],n);return n}function zZ(e,t){let n=e.x-t.x;if(n===0&&(n=e.y-t.y,n===0)){let o=(e.next.y-e.y)/(e.next.x-e.x),a=(t.next.y-t.y)/(t.next.x-t.x);n=o-a}return n}function FZ(e,t){let n=HZ(e,t);if(!n)return t;let o=xD(n,e);return nl(o,o.next),nl(n,n.next)}function HZ(e,t){let n=t,o=e.x,a=e.y,r=-1/0,s;if(su(e,n))return n;do{if(su(e,n.next))return n.next;if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){let d=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(d<=o&&d>r&&(r=d,s=n.x<n.next.x?n:n.next,d===o))return s}n=n.next}while(n!==t);if(!s)return null;let i=s,l=s.x,c=s.y,u=1/0;n=s;do{if(o>=n.x&&n.x>=l&&o!==n.x&&yD(a<c?o:r,a,l,c,a<c?r:o,a,n.x,n.y)){let d=Math.abs(a-n.y)/(o-n.x);fh(n,e)&&(d<u||d===u&&(n.x>s.x||n.x===s.x&&UZ(s,n)))&&(s=n,u=d)}n=n.next}while(n!==i);return s}function UZ(e,t){return Ke(e.prev,e,t.prev)<0&&Ke(t.next,e,e.next)<0}function GZ(e,t,n,o){let a=e;do a.z===0&&(a.z=iL(a.x,a.y,t,n,o)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==e);a.prevZ.nextZ=null,a.prevZ=null,WZ(a)}function WZ(e){let t,n=1;do{let o=e,a;e=null;let r=null;for(t=0;o;){t++;let s=o,i=0;for(let c=0;c<n&&(i++,s=s.nextZ,!!s);c++);let l=n;for(;i>0||l>0&&s;)i!==0&&(l===0||!s||o.z<=s.z)?(a=o,o=o.nextZ,i--):(a=s,s=s.nextZ,l--),r?r.nextZ=a:e=a,a.prevZ=r,r=a;o=s}r.nextZ=null,n*=2}while(t>1);return e}function iL(e,t,n,o,a){return e=(e-n)*a|0,t=(t-o)*a|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function qZ(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function yD(e,t,n,o,a,r,s,i){return(a-s)*(t-i)>=(e-s)*(r-i)&&(e-s)*(o-i)>=(n-s)*(t-i)&&(n-s)*(r-i)>=(a-s)*(o-i)}function uh(e,t,n,o,a,r,s,i){return!(e===s&&t===i)&&yD(e,t,n,o,a,r,s,i)}function jZ(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!VZ(e,t)&&(fh(e,t)&&fh(t,e)&&ZZ(e,t)&&(Ke(e.prev,e,t.prev)||Ke(e,t.prev,t))||su(e,t)&&Ke(e.prev,e,e.next)>0&&Ke(t.prev,t,t.next)>0)}function Ke(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function su(e,t){return e.x===t.x&&e.y===t.y}function gD(e,t,n,o){let a=wg(Ke(e,t,n)),r=wg(Ke(e,t,o)),s=wg(Ke(n,o,e)),i=wg(Ke(n,o,t));return!!(a!==r&&s!==i||a===0&&kg(e,n,t)||r===0&&kg(e,o,t)||s===0&&kg(n,e,o)||i===0&&kg(n,t,o))}function kg(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function wg(e){return e>0?1:e<0?-1:0}function VZ(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&gD(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function fh(e,t){return Ke(e.prev,e,e.next)<0?Ke(e,t,e.next)>=0&&Ke(e,e.prev,t)>=0:Ke(e,t,e.prev)<0||Ke(e,e.next,t)<0}function ZZ(e,t){let n=e,o=!1,a=(e.x+t.x)/2,r=(e.y+t.y)/2;do n.y>r!=n.next.y>r&&n.next.y!==n.y&&a<(n.next.x-n.x)*(r-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next;while(n!==e);return o}function xD(e,t){let n=lL(e.i,e.x,e.y),o=lL(t.i,t.x,t.y),a=e.next,r=t.prev;return e.next=t,t.prev=e,n.next=a,a.prev=n,o.next=n,n.prev=o,r.next=o,o.prev=r,o}function hD(e,t,n,o){let a=lL(e,t,n);return o?(a.next=o.next,a.prev=o,o.next.prev=a,o.next=a):(a.prev=a,a.next=a),a}function ph(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function lL(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function XZ(e,t,n,o){let a=0;for(let r=t,s=n-o;r<n;r+=o)a+=(e[s]-e[r])*(e[r+1]+e[s+1]),s=r;return a}var uL=e=>{if(e===null)return[0,0,0,0];try{let{r:t,g:n,b:o,a}=v0.parse(e);return[t/255,n/255,o/255,a]}catch{return typeof console<"u"&&console.warn(`[WebGL2Target] cannot parse color '${e}', falling back to black`),[0,0,0,1]}};var Wt=e=>{if(e===null)throw new Error("packages/renderer-canvas: WebGL resource creation failed");return e},Nt=(e,t,n,o)=>{let a=Wt(e.createShader(t));if(e.shaderSource(a,n),e.compileShader(a),!e.getShaderParameter(a,e.COMPILE_STATUS)){let r=e.getShaderInfoLog(a);throw e.deleteShader(a),new Error(`${o} shader compile failed: ${r}`)}return a},Mo=(e,t,n,o)=>{let a=Wt(e.createProgram());if(e.attachShader(a,t),e.attachShader(a,n),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){let r=e.getProgramInfoLog(a);throw e.deleteProgram(a),new Error(`${o} program link failed: ${r}`)}return a};var Cg=class{gl;program;vbo;uTransform;uColor;uOpacity;uPxRange;uAtlas;aPos;aUV;constructor(t){this.gl=t;let n=Nt(t,t.VERTEX_SHADER,JZ,"MSDF"),o=Nt(t,t.FRAGMENT_SHADER,eX,"MSDF");this.program=Mo(t,n,o,"MSDF"),this.vbo=Wt(t.createBuffer()),this.aPos=t.getAttribLocation(this.program,"aPos"),this.aUV=t.getAttribLocation(this.program,"aUV"),this.uTransform=t.getUniformLocation(this.program,"uTransform"),this.uColor=t.getUniformLocation(this.program,"uColor"),this.uOpacity=t.getUniformLocation(this.program,"uOpacity"),this.uPxRange=t.getUniformLocation(this.program,"uPxRange"),this.uAtlas=t.getUniformLocation(this.program,"uAtlas")}drawText(t,n,o,a,r,s,i,l=0,c=0){if(t.length===0)return 0;let u=6,d=4,f=t.length*u*d;$Z(f);let p=_g,h=0,m=n,x=!0;for(let w of t){let S=w.codePointAt(0);if(S===void 0)continue;let L=r.getOrRasterize(S,c);if(!L){x=!1;break}let M=L.advance*a/L.unitsPerEm;if(L.empty){m+=M;continue}KZ(p,h,L,m,o,a,r),h+=u*d,m+=M}if(x&&a>0&&vD(r,t,c,(m-n)/a),h===0)return m-n;let y=r.uploadTo(this.gl),g=this.gl;g.useProgram(this.program),g.bindBuffer(g.ARRAY_BUFFER,this.vbo),g.bufferData(g.ARRAY_BUFFER,p.subarray(0,h),g.DYNAMIC_DRAW),g.enableVertexAttribArray(this.aPos),g.vertexAttribPointer(this.aPos,2,g.FLOAT,!1,16,0),g.enableVertexAttribArray(this.aUV),g.vertexAttribPointer(this.aUV,2,g.FLOAT,!1,16,8);let b=s.transform,A=b;if(l!==0){let w=-(m-n)*l;A={...b,e:b.e+b.a*w,f:b.f+b.b*w}}QZ(bD,A,i.width,i.height),g.uniformMatrix3fv(this.uTransform,!1,bD),g.uniform3f(this.uColor,s.color[0],s.color[1],s.color[2]),g.uniform1f(this.uOpacity,s.opacity);let _=r.tileSize-2*r.range,T=r.range*a/Math.max(1,_);return g.uniform1f(this.uPxRange,T),g.activeTexture(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,y),g.uniform1i(this.uAtlas,0),g.drawArrays(g.TRIANGLES,0,h/d),m-n}dispose(){this.gl.deleteBuffer(this.vbo),this.gl.deleteProgram(this.program)}},YZ=(e,t,n,o,a)=>{let r=o/e.unitsPerEm,s=Math.max(1,a.tileSize-2*a.range),i=Math.max(e.bboxW,e.bboxH)/s,l=e.bboxW/i+2*a.range,c=e.bboxH/i+2*a.range,u=a.range*i*r,d=e.bboxW*r+2*u,f=e.bboxH*r+2*u,p=t+e.bboxXMin*r-u,h=n+(-e.bboxYMin-e.bboxH)*r-u,m=p+d,x=h+f,y=.5,g=(e.atlasX+y)/a.atlasSize,b=(e.atlasY+y)/a.atlasSize,A=(e.atlasX+l-y)/a.atlasSize,_=(e.atlasY+c-y)/a.atlasSize;return{left:p,top:h,right:m,bottom:x,u0:g,v0:b,u1:A,v1:_}},dL=new WeakMap,AD=(e,t)=>`${t}\0${e}`,vD=(e,t,n,o)=>{let a=dL.get(e);a||(a=new Map,dL.set(e,a));let r=AD(t,n);if(a.delete(r),a.set(r,o),a.size>1024){let s=a.keys().next().value;s!==void 0&&a.delete(s)}},SD=(e,t,n=0)=>{if(e.length===0)return 0;let o=AD(e,n),a=dL.get(t);if(a){let s=a.get(o);if(s!==void 0)return a.delete(o),a.set(o,s),s}let r=0;for(let s of e){let i=s.codePointAt(0);if(i===void 0)continue;let l=t.getOrRasterize(i,n);l&&(r+=l.advance/l.unitsPerEm)}return vD(t,e,n,r),r},KZ=(e,t,n,o,a,r,s)=>{let{left:i,top:l,right:c,bottom:u,u0:d,v0:f,u1:p,v1:h}=YZ(n,o,a,r,s);e.set([i,l,d,f,c,l,p,f,i,u,d,h,c,l,p,f,c,u,p,h,i,u,d,h],t)},_g=new Float32Array(512),bD=new Float32Array(9),$Z=e=>{if(_g.length>=e)return;let t=_g.length;for(;t<e;)t*=2;_g=new Float32Array(t)},QZ=(e,t,n,o)=>{let a=2/n,r=-2/o;e[0]=t.a*a,e[1]=t.b*r,e[2]=0,e[3]=t.c*a,e[4]=t.d*r,e[5]=0,e[6]=t.e*a-1,e[7]=t.f*r+1,e[8]=1},JZ=`#version 300 es
|
|
15
15
|
in vec2 aPos;
|
|
16
16
|
in vec2 aUV;
|
|
17
17
|
uniform mat3 uTransform;
|
|
@@ -20,7 +20,7 @@ void main() {
|
|
|
20
20
|
vec3 p = uTransform * vec3(aPos, 1.0);
|
|
21
21
|
gl_Position = vec4(p.xy, 0.0, 1.0);
|
|
22
22
|
vUV = aUV;
|
|
23
|
-
}`,
|
|
23
|
+
}`,eX=`#version 300 es
|
|
24
24
|
precision mediump float;
|
|
25
25
|
uniform vec3 uColor;
|
|
26
26
|
uniform float uOpacity;
|
|
@@ -46,7 +46,7 @@ void main() {
|
|
|
46
46
|
// contract + blendFunc(ONE, 1-SRC_ALPHA).
|
|
47
47
|
float a = alpha * uOpacity;
|
|
48
48
|
fragColor = vec4(uColor * a, a);
|
|
49
|
-
}`;var
|
|
49
|
+
}`;var tX=10,kD=12,Eg=new Float32Array(64),wD=new Float32Array(64),po=new Float32Array(1024),ia=0,nX=e=>{if(Eg.length>=e)return;let t=Eg.length;for(;t<e;)t*=2;Eg=new Float32Array(t),wD=new Float32Array(t)},oX=e=>{if(po.length>=e)return;let t=po.length;for(;t<e;)t*=2;let n=new Float32Array(t);n.set(po.subarray(0,ia)),po=n},aX=(e,t)=>{ia+2>po.length&&oX(ia+2),po[ia++]=e,po[ia++]=t},rX=(e,t,n,o,a)=>{let r=e+n,s=t+o,i=Math.hypot(r,s);if(i<1e-6)return{ox:e*a,oy:t*a};r/=i,s/=i;let l=r*e+s*t,c=l>1e-6?a/l:a,u=Math.min(c,a*tX);return{ox:r*u,oy:s*u}},_D=(e,t,n,o,a,r,s,i,l,c,u,d,f)=>{if(o.width<=0||n<2)return;let p=o.width/2,h=n-1;nX(h);let m=Eg,x=wD;for(let S=0;S<h;S++){let L=v(t[S*2+2])-v(t[S*2]),M=v(t[S*2+3])-v(t[S*2+1]),B=Math.hypot(L,M)||1;m[S]=-M/B,x[S]=L/B}let y=n>=3&&t[0]===t[(n-1)*2]&&t[1]===t[(n-1)*2+1];ia=0;let g=aX,b=(S,L,M,B,W,ie,ne,j)=>{g(S+M,L+B),g(S-M,L-B),g(W+ne,ie+j),g(W+ne,ie+j),g(S-M,L-B),g(W-ne,ie-j)},A=S=>({ox:v(m[S])*p,oy:v(x[S])*p});for(let S=0;S<h;S++){let L=A(S);b(v(t[S*2]),v(t[S*2+1]),L.ox,L.oy,v(t[S*2+2]),v(t[S*2+3]),L.ox,L.oy)}let _=(S,L,M,B,W,ie)=>{if(o.join==="miter"){let{ox:ne,oy:j}=rX(M,B,W,ie,p),ve=M*ie-B*W;if(Math.abs(ve)<1e-9)return;let ye=ve<0?1:-1,ee=S+ye*ne,Se=L+ye*j,Oe=ye*M*p,qt=ye*B*p,xn=ye*W*p,Oo=ye*ie*p;g(S,L),g(S+Oe,L+qt),g(ee,Se),g(S,L),g(ee,Se),g(S+xn,L+Oo)}else if(o.join==="bevel"){let ne=M*ie-B*W;if(Math.abs(ne)<1e-9)return;let j=ne<0?1:-1,ve=S+j*M*p,ye=L+j*B*p,ee=S+j*W*p,Se=L+j*ie*p;g(S,L),g(ve,ye),g(ee,Se)}else{let ne=M*ie-B*W;if(Math.abs(ne)<1e-9)return;let j=ne<0?1:-1,ve=Math.atan2(j*B,j*M),ee=Math.atan2(j*ie,j*W)-ve;for(;ee>Math.PI;)ee-=2*Math.PI;for(;ee<-Math.PI;)ee+=2*Math.PI;let Se=Math.max(2,Math.ceil(Math.abs(ee)/Math.PI*kD)),Oe=S+Math.cos(ve)*p,qt=L+Math.sin(ve)*p;for(let xn=1;xn<=Se;xn++){let Oo=xn/Se,vt=ve+ee*Oo,Eh=S+Math.cos(vt)*p,Th=L+Math.sin(vt)*p;g(S,L),g(Oe,qt),g(Eh,Th),Oe=Eh,qt=Th}}};for(let S=1;S<h;S++)_(v(t[S*2]),v(t[S*2+1]),v(m[S-1]),v(x[S-1]),v(m[S]),v(x[S]));if(y&&_(v(t[0]),v(t[1]),v(m[h-1]),v(x[h-1]),v(m[0]),v(x[0])),y||(LD(g,v(t[0]),v(t[1]),v(t[2]),v(t[3]),v(m[0]),v(x[0]),p,o.cap,!0),LD(g,v(t[(n-1)*2]),v(t[(n-1)*2+1]),v(t[(n-2)*2]),v(t[(n-2)*2+1]),v(m[h-1]),v(x[h-1]),p,o.cap,!1)),ia===0)return;let T=2/r.width,w=-2/r.height;for(let S=0;S<ia;S+=2){let L=v(po[S]),M=v(po[S+1]),B=a.a*L+a.c*M+a.e,W=a.b*L+a.d*M+a.f;po[S]=B*T-1,po[S+1]=W*w+1}e.useProgram(s),e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,po.subarray(0,ia),e.DYNAMIC_DRAW),e.enableVertexAttribArray(d),e.vertexAttribPointer(d,2,e.FLOAT,!1,0,0),e.uniformMatrix3fv(i,!1,f),e.uniform3f(l,o.color[0],o.color[1],o.color[2]),e.uniform1f(c,o.opacity),e.drawArrays(e.TRIANGLES,0,ia/2)},LD=(e,t,n,o,a,r,s,i,l,c)=>{if(l==="butt")return;let u=o-t,d=a-n,f=Math.hypot(u,d)||1,p=-u/f,h=-d/f,m=c?1:-1,x=m*p,y=m*h;if(l==="square"){let S={x:t+r*i,y:n+s*i},L={x:t-r*i,y:n-s*i},M={x:S.x+x*i,y:S.y+y*i},B={x:L.x+x*i,y:L.y+y*i};e(S.x,S.y),e(M.x,M.y),e(L.x,L.y),e(L.x,L.y),e(M.x,M.y),e(B.x,B.y);return}let g=Math.atan2(s,r),b=kD,_=r*y-s*x>=0?1:-1,T=t+Math.cos(g)*i,w=n+Math.sin(g)*i;for(let S=1;S<=b;S++){let L=S/b,M=g+_*Math.PI*L,B=t+Math.cos(M)*i,W=n+Math.sin(M)*i;e(t,n),e(T,w),e(B,W),T=B,w=W}};var ED=(e,t,n,o,a=8)=>{let r=[],s=e;for(let i=0;i<a;i++){let l=i/a,c=(i+1)/a,u=(l+c)/2,d=cn.cubicAt(e,t,n,o,c),f=cn.cubicAt(e,t,n,o,u),p={x:2*f.x-(s.x+d.x)/2,y:2*f.y-(s.y+d.y)/2};r.push([s,p,d]),s=d}return r};var hh=class{positionsBuf=new Float32Array(CD*6);uvsBuf=new Float32Array(CD*9);count=0;get triangleCount(){return this.count}get positions(){return this.positionsBuf.subarray(0,this.count*6)}get uvs(){return this.uvsBuf.subarray(0,this.count*9)}reset(){this.count=0}addQuadratic(t,n,o){let a=(n.x-t.x)*(o.y-t.y)-(n.y-t.y)*(o.x-t.x);if(a===0)return!1;let r=a>0?1:-1;this.ensureCapacity(this.count+1);let s=this.count*6,i=this.positionsBuf;i[s++]=t.x,i[s++]=t.y,i[s++]=n.x,i[s++]=n.y,i[s++]=o.x,i[s]=o.y;let l=this.count*9,c=this.uvsBuf;return c[l++]=0,c[l++]=0,c[l++]=r,c[l++]=.5,c[l++]=0,c[l++]=r,c[l++]=1,c[l++]=1,c[l]=r,this.count++,!0}addCubic(t,n,o,a,r=8){for(let[s,i,l]of ED(t,n,o,a,r))this.addQuadratic(s,i,l)}ensureCapacity(t){if(this.positionsBuf.length>=t*6)return;let n=this.positionsBuf.length/6;for(;n<t;)n*=2;let o=new Float32Array(n*6);o.set(this.positionsBuf),this.positionsBuf=o;let a=new Float32Array(n*9);a.set(this.uvsBuf),this.uvsBuf=a}},CD=64;var Tg=class{gl;program;vbo;uvBuf;uTransform;uColor;uOpacity;aPos;aUVW;constructor(t){this.gl=t;let n=Nt(t,t.VERTEX_SHADER,hX,"Loop-Blinn"),o=Nt(t,t.FRAGMENT_SHADER,mX,"Loop-Blinn");this.program=Mo(t,n,o,"Loop-Blinn"),this.vbo=Wt(t.createBuffer()),this.uvBuf=Wt(t.createBuffer()),this.aPos=t.getAttribLocation(this.program,"aPos"),this.aUVW=t.getAttribLocation(this.program,"aUVW"),this.uTransform=t.getUniformLocation(this.program,"uTransform"),this.uColor=t.getUniformLocation(this.program,"uColor"),this.uOpacity=t.getUniformLocation(this.program,"uOpacity")}draw(t,n,o,a,r){if(t.length===0||o<=0)return;let{positions:s,uvs:i}=pX(t);if(s.length===0)return;let l=this.gl;l.useProgram(this.program),l.bindBuffer(l.ARRAY_BUFFER,this.vbo),l.bufferData(l.ARRAY_BUFFER,s,l.DYNAMIC_DRAW),l.enableVertexAttribArray(this.aPos),l.vertexAttribPointer(this.aPos,2,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,this.uvBuf),l.bufferData(l.ARRAY_BUFFER,i,l.DYNAMIC_DRAW),l.enableVertexAttribArray(this.aUVW),l.vertexAttribPointer(this.aUVW,3,l.FLOAT,!1,0,0),l.uniformMatrix3fv(this.uTransform,!1,iX(a,r.width,r.height)),l.uniform3f(this.uColor,n[0],n[1],n[2]),l.uniform1f(this.uOpacity,o),l.drawArrays(l.TRIANGLES,0,s.length/2)}dispose(){this.gl.deleteBuffer(this.vbo),this.gl.deleteBuffer(this.uvBuf),this.gl.deleteProgram(this.program)}},la=new Float32Array(9),iX=(e,t,n)=>{let o=2/t,a=-2/n;return la[0]=e.a*o,la[1]=e.b*a,la[2]=0,la[3]=e.c*o,la[4]=e.d*a,la[5]=0,la[6]=e.e*o-1,la[7]=e.f*a+1,la[8]=1,la},ms=new Map,ol=new Float64Array(64),lX=e=>{if(ol.length>=e)return;let t=ol.length;for(;t<e;)t*=2;ol=new Float64Array(t)},ID=new Float64Array(1),TD=new Uint32Array(ID.buffer),mh=new hh,cX=e=>{lX(e.length*9);let t=ol,n=0;for(let o of e){t[n++]=o.kind==="q"?1:2;for(let a of o.points)t[n++]=a.x,t[n++]=a.y}return n},uX=(e,t)=>{let n=2166136261;for(let o=0;o<t;o++)ID[0]=e[o]??0,n=Math.imul(n^(TD[0]??0),16777619),n=Math.imul(n^(TD[1]??0),16777619);return n>>>0},dX=(e,t,n)=>{if(e.length!==n)return!1;for(let o=0;o<n;o++)if(e[o]!==t[o])return!1;return!0},fX=(e,t)=>{mh.reset();for(let n of e)if(n.kind==="q"){let[o,a,r]=n.points;if(!o||!a||!r)continue;mh.addQuadratic(o,a,r)}else{let[o,a,r,s]=n.points;if(!o||!a||!r||!s)continue;mh.addCubic(o,a,r,s)}return{key:ol.slice(0,t),positions:new Float32Array(mh.positions),uvs:new Float32Array(mh.uvs)}},pX=e=>{let t=cX(e),n=uX(ol,t),o=ms.get(n);if(o&&dX(o.key,ol,t))return ms.delete(n),ms.set(n,o),o;let a=fX(e,t);for(ms.delete(n),ms.set(n,a);ms.size>4096;){let r=ms.keys().next().value;if(r===void 0)break;ms.delete(r)}return a},hX=`#version 300 es
|
|
50
50
|
in vec2 aPos;
|
|
51
51
|
in vec3 aUVW;
|
|
52
52
|
uniform mat3 uTransform;
|
|
@@ -55,7 +55,7 @@ void main() {
|
|
|
55
55
|
vec3 p = uTransform * vec3(aPos, 1.0);
|
|
56
56
|
gl_Position = vec4(p.xy, 0.0, 1.0);
|
|
57
57
|
vUVW = aUVW;
|
|
58
|
-
}`,
|
|
58
|
+
}`,mX=`#version 300 es
|
|
59
59
|
precision mediump float;
|
|
60
60
|
uniform vec3 uColor;
|
|
61
61
|
uniform float uOpacity;
|
|
@@ -78,7 +78,7 @@ void main() {
|
|
|
78
78
|
// contract + blendFunc(ONE, 1-SRC_ALPHA).
|
|
79
79
|
float a = coverage * uOpacity;
|
|
80
80
|
fragColor = vec4(uColor * a, a);
|
|
81
|
-
}`;var
|
|
81
|
+
}`;var ca=new Float32Array(9),Ig=class{gl;program;vbo;aPos;aLocal;uTransform;uColor;uOpacity;constructor(t){this.gl=t;let n=Nt(t,t.VERTEX_SHADER,yX,"Ellipse"),o=Nt(t,t.FRAGMENT_SHADER,gX,"Ellipse");this.program=Mo(t,n,o,"Ellipse"),this.aPos=t.getAttribLocation(this.program,"aPos"),this.aLocal=t.getAttribLocation(this.program,"aLocal"),this.uTransform=t.getUniformLocation(this.program,"uTransform"),this.uColor=t.getUniformLocation(this.program,"uColor"),this.uOpacity=t.getUniformLocation(this.program,"uOpacity"),this.vbo=Wt(t.createBuffer()),t.bindBuffer(t.ARRAY_BUFFER,this.vbo),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,-1,-1,1,0,1,-1,0,1,-1,1,1,1,1,1]),t.STATIC_DRAW)}draw(t,n,o,a,r,s,i,l){if(s<=0||o<=0||a<=0)return;let c=this.gl;c.useProgram(this.program),c.bindBuffer(c.ARRAY_BUFFER,this.vbo),c.enableVertexAttribArray(this.aPos),c.vertexAttribPointer(this.aPos,2,c.FLOAT,!1,16,0),c.enableVertexAttribArray(this.aLocal),c.vertexAttribPointer(this.aLocal,2,c.FLOAT,!1,16,8);let u=2*o,d=2*a,f=t-o,p=n-a,h=2/l.width,m=-2/l.height,x=i;ca[0]=x.a*u*h,ca[1]=x.b*u*m,ca[2]=0,ca[3]=x.c*d*h,ca[4]=x.d*d*m,ca[5]=0,ca[6]=(x.a*f+x.c*p+x.e)*h-1,ca[7]=(x.b*f+x.d*p+x.f)*m+1,ca[8]=1,c.uniformMatrix3fv(this.uTransform,!1,ca),c.uniform3f(this.uColor,r[0],r[1],r[2]),c.uniform1f(this.uOpacity,s),c.drawArrays(c.TRIANGLE_STRIP,0,4)}dispose(){this.gl.deleteBuffer(this.vbo),this.gl.deleteProgram(this.program)}},yX=`#version 300 es
|
|
82
82
|
in vec2 aPos;
|
|
83
83
|
in vec2 aLocal;
|
|
84
84
|
uniform mat3 uTransform;
|
|
@@ -87,7 +87,7 @@ void main() {
|
|
|
87
87
|
vec3 p = uTransform * vec3(aPos, 1.0);
|
|
88
88
|
gl_Position = vec4(p.xy, 0.0, 1.0);
|
|
89
89
|
vLocal = aLocal;
|
|
90
|
-
}`,
|
|
90
|
+
}`,gX=`#version 300 es
|
|
91
91
|
precision mediump float;
|
|
92
92
|
uniform vec3 uColor;
|
|
93
93
|
uniform float uOpacity;
|
|
@@ -100,16 +100,41 @@ void main() {
|
|
|
100
100
|
if (coverage <= 0.0) discard;
|
|
101
101
|
float a = coverage * uOpacity;
|
|
102
102
|
fragColor = vec4(uColor * a, a);
|
|
103
|
-
}`;var hy=class{gl;program;vbo;dynamicVbo;uTransformLoc;uColorLoc;uOpacityLoc;aPosLoc;_size;fillColor=[0,0,0];fillAlpha=1;strokeColor=[0,0,0];strokeAlpha=1;fillColorString="#000";strokeWidth=1;lineCap="butt";lineJoin="miter";dashArray=null;opacity=1;currentPath=null;fontFamily="sans-serif";fontSize=14;fontWeight="normal";fontStyle="normal";textAlign="left";textBaseline="top";currentPolyline=[];currentCurves=[];currentEllipse=null;transform={a:1,b:0,c:0,d:1,e:0,f:0};stack=[];constructor(t,n,o){let a=t.getContext("webgl2",{antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!0});if(a??=t.getContext("webgl2",{premultipliedAlpha:!0,preserveDrawingBuffer:!0}),!a)throw new Error("WebGL2 unavailable in this environment (probably hit the per-page GL context cap; Chrome allows ~16). LayeredSurface will fall back to canvas2d.");this.gl=a,this._size={width:n,height:o};let r=rn(this.gl,this.gl.VERTEX_SHADER,yq,"WebGL2"),s=rn(this.gl,this.gl.FRAGMENT_SHADER,gq,"WebGL2");this.program=Na(this.gl,r,s,"WebGL2"),this.gl.useProgram(this.program),this.vbo=Jn(this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vbo),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),this.gl.STATIC_DRAW),this.dynamicVbo=Jn(this.gl.createBuffer()),this.aPosLoc=this.gl.getAttribLocation(this.program,"aPos"),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.vertexAttribPointer(this.aPosLoc,2,this.gl.FLOAT,!1,0,0),this.uTransformLoc=this.gl.getUniformLocation(this.program,"uTransform"),this.uColorLoc=this.gl.getUniformLocation(this.program,"uColor"),this.uOpacityLoc=this.gl.getUniformLocation(this.program,"uOpacity"),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.viewport(0,0,t.width,t.height)}get size(){return this._size}resize(t,n){this._size.width=t,this._size.height=n,this.gl.viewport(0,0,t,n)}dispose(){this.msdfPipeline&&(this.msdfPipeline.dispose(),this.msdfPipeline=null),this.glyphAtlas&&(this.glyphAtlas.dispose(this.gl),this.glyphAtlas=null,this.glyphAtlasShaper=null),this.indexBuffer&&(this.gl.deleteBuffer(this.indexBuffer),this.indexBuffer=null),this.curvePipeline&&(this.curvePipeline.dispose(),this.curvePipeline=null),this.ellipsePipeline&&(this.ellipsePipeline.dispose(),this.ellipsePipeline=null),this.gl.deleteBuffer(this.dynamicVbo),this.imageQuadVbo&&(this.gl.deleteBuffer(this.imageQuadVbo),this.imageQuadVbo=null);for(let n of this.textures.values())this.gl.deleteTexture(n);this.textures.clear(),this.gl.getExtension("WEBGL_lose_context")?.loseContext()}setFill(t){let n=Cv(t);this.fillColor=[n[0],n[1],n[2]],this.fillAlpha=n[3],this.fillColorString=t??"transparent"}setOpacity(t){this.opacity=t}save(){this.stack.push({transform:{...this.transform},fillColor:[this.fillColor[0],this.fillColor[1],this.fillColor[2]],fillAlpha:this.fillAlpha,strokeColor:[this.strokeColor[0],this.strokeColor[1],this.strokeColor[2]],strokeAlpha:this.strokeAlpha,fillColorString:this.fillColorString,strokeWidth:this.strokeWidth,lineCap:this.lineCap,lineJoin:this.lineJoin,dashArray:this.dashArray,opacity:this.opacity,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontStyle:this.fontStyle,textAlign:this.textAlign,textBaseline:this.textBaseline})}restore(){let t=this.stack.pop();t&&(this.transform=t.transform,this.fillColor=t.fillColor,this.fillAlpha=t.fillAlpha,this.strokeColor=t.strokeColor,this.strokeAlpha=t.strokeAlpha,this.fillColorString=t.fillColorString,this.strokeWidth=t.strokeWidth,this.lineCap=t.lineCap,this.lineJoin=t.lineJoin,this.dashArray=t.dashArray,this.opacity=t.opacity,this.fontFamily=t.fontFamily,this.fontSize=t.fontSize,this.fontWeight=t.fontWeight,this.fontStyle=t.fontStyle,this.textAlign=t.textAlign,this.textBaseline=t.textBaseline)}setTransform(t){this.transform={a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}resetTransform(){this.transform={a:1,b:0,c:0,d:1,e:0,f:0}}translate(t,n){this.transform.e+=this.transform.a*t+this.transform.c*n,this.transform.f+=this.transform.b*t+this.transform.d*n}rotate(t){let n=Math.cos(t),o=Math.sin(t),{a,b:r,c:s,d:i}=this.transform;this.transform.a=a*n+s*o,this.transform.b=r*n+i*o,this.transform.c=a*-o+s*n,this.transform.d=r*-o+i*n}scale(t,n){this.transform.a*=t,this.transform.b*=t,this.transform.c*=n,this.transform.d*=n}beginPath(){this.currentPath=null,this.currentPolyline=[],this.currentCurves=[],this.currentEllipse=null}rect(t,n,o,a){this._pathRect.x=t,this._pathRect.y=n,this._pathRect.width=o,this._pathRect.height=a,this.currentPath=this._pathRect}_pathRect={x:0,y:0,width:0,height:0};moveTo(t,n){this.currentPolyline=[{x:t,y:n}]}lineTo(t,n){this.currentPolyline.push({x:t,y:n})}closePath(){let t=this.currentPolyline[0];this.currentPolyline.length>1&&t!==void 0&&this.currentPolyline.push({...t})}ellipse(t,n,o,a){this.currentEllipse={cx:t,cy:n,rx:o,ry:a},this.currentPolyline=[],this.currentPath=null}buildEllipseStrokePolyline(t){let n=Math.hypot(this.transform.a,this.transform.b),o=Math.max(t.rx,t.ry)*(Number.isFinite(n)&&n>0?n:1),a=Math.max(24,Math.min(512,Math.ceil(Math.PI*o*.7)));this.currentPolyline=[];for(let r=0;r<=a;r++){let s=r/a*Math.PI*2;this.currentPolyline.push({x:t.cx+t.rx*Math.cos(s),y:t.cy+t.ry*Math.sin(s)})}}quadraticCurveTo(t,n,o,a){let r=this.currentPolyline[this.currentPolyline.length-1]??{x:t,y:n};this.currentCurves.push({kind:"q",points:[r,{x:t,y:n},{x:o,y:a}]});let s=this.currentFlattenTolerance(),i=c0();if(i){let u=i.flatten([{kind:"M",to:r},{kind:"Q",control:{x:t,y:n},to:{x:o,y:a}}],s);for(let d=1;d<u.length;d++)this.currentPolyline.push(L(u[d]));return}let l=Math.max(8,Math.min(128,Math.ceil(i6(r,{x:o,y:a})/s))),c=dq(r,{x:t,y:n},{x:o,y:a},l);for(let u=1;u<c.length;u++)this.currentPolyline.push(L(c[u]))}bezierCurveTo(t,n,o,a,r,s){let i=this.currentPolyline[this.currentPolyline.length-1]??{x:r,y:s};this.currentCurves.push({kind:"c",points:[i,{x:t,y:n},{x:o,y:a},{x:r,y:s}]});let l=this.currentFlattenTolerance(),c=c0();if(c){let f=c.flatten([{kind:"M",to:i},{kind:"C",control1:{x:t,y:n},control2:{x:o,y:a},to:{x:r,y:s}}],l);for(let p=1;p<f.length;p++)this.currentPolyline.push(L(f[p]));return}let u=Math.max(12,Math.min(192,Math.ceil(i6(i,{x:r,y:s})/l))),d=fq(i,{x:t,y:n},{x:o,y:a},{x:r,y:s},u);for(let f=1;f<d.length;f++)this.currentPolyline.push(L(d[f]))}currentFlattenTolerance(){let t=Math.hypot(this.transform.a,this.transform.b);return!Number.isFinite(t)||t<=0?s6:s6/t}drawImage(t,n,o,a,r,s){let i=this.textureFor(t,s??!1);if(!i)return;this.imageProgram||(this.imageProgram=hq(this.gl),this.imageQuadVbo=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.imageQuadVbo),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,0,0,1,0,1,0,0,1,0,1,1,1,1,1]),this.gl.STATIC_DRAW));let l=this.imageProgram;this.gl.useProgram(l.program),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.imageQuadVbo),this.gl.enableVertexAttribArray(l.aPos),this.gl.vertexAttribPointer(l.aPos,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(l.aUV),this.gl.vertexAttribPointer(l.aUV,2,this.gl.FLOAT,!1,16,8);let c=pq({a:this.transform.a*a,b:this.transform.b*a,c:this.transform.c*r,d:this.transform.d*r,e:this.transform.e+this.transform.a*n+this.transform.c*o,f:this.transform.f+this.transform.b*n+this.transform.d*o},this._size.width,this._size.height);this.gl.uniformMatrix3fv(l.uTransform,!1,c),this.gl.uniform1f(l.uOpacity,this.opacity),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,i),this.gl.uniform1i(l.uTex,0),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.restoreSolidProgram()}imageProgram=null;imageQuadVbo=null;textures=new Map;textureFor(t,n){if(!oy(t))return ay(t),null;let o=t,a=this.textures.get(o);if(a)return this.textures.delete(o),this.textures.set(o,a),n&&(this.gl.bindTexture(this.gl.TEXTURE_2D,a),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t)),a;let r=this.gl.createTexture();return r?(this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.textures.set(o,r),this.evictImageTexturesIfOverCap(),r):null}evictImageTexturesIfOverCap(){for(;this.textures.size>64;){let t=this.textures.keys().next().value;if(t===void 0)break;if(iq(this.textBitmaps,t)){let o=this.textures.get(t);if(o===void 0)continue;this.textures.delete(t),this.textures.set(t,o);continue}let n=this.textures.get(t);this.textures.delete(t),n&&this.gl.deleteTexture(n)}}fill(t){let n=this.opacity*this.fillAlpha;if(!(n<=0)){if(this.currentEllipse){this.ellipsePipeline??=new fy(this.gl);let o=this.currentEllipse;this.ellipsePipeline.draw(o.cx,o.cy,o.rx,o.ry,this.fillColor,n,this.transform,this._size),this.restoreSolidProgram();return}if(this.currentPath){let o=this.currentPath,a=mq({a:this.transform.a*o.width,b:this.transform.b*o.width,c:this.transform.c*o.height,d:this.transform.d*o.height,e:this.transform.e+this.transform.a*o.x+this.transform.c*o.y,f:this.transform.f+this.transform.b*o.x+this.transform.d*o.y},this._size.width,this._size.height);this.restoreSolidProgram(),this.gl.uniformMatrix3fv(this.uTransformLoc,!1,a),this.gl.uniform3f(this.uColorLoc,this.fillColor[0],this.fillColor[1],this.fillColor[2]),this.gl.uniform1f(this.uOpacityLoc,n),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);return}this.currentPolyline.length>=3&&this.fillPolygonEarcut(this.currentPolyline,n),this.currentCurves.length>0&&(this.curvePipeline??=new dy(this.gl),this.curvePipeline.draw(this.currentCurves,this.fillColor,n,this.transform,this._size),this.restoreSolidProgram())}}curvePipeline=null;ellipsePipeline=null;fillPolygonEarcut(t,n){let o=t[0],a=t[t.length-1],r=t.length>=4&&o!==void 0&&o.x===a?.x&&o.y===a.y?t.length-1:t.length;if(r<3)return;r6(r);let s=py;for(let f=0;f<r;f++){let p=L(t[f]);s[f*2]=p.x,s[f*2+1]=p.y}let i=_v(s.subarray(0,r*2));if(i.length===0){this.drawTriangleFan(t,r,n);return}let l=2/this._size.width,c=-2/this._size.height,u=Mv;for(let f=0;f<r;f++){let p=L(t[f]),h=this.transform.a*p.x+this.transform.c*p.y+this.transform.e,m=this.transform.b*p.x+this.transform.d*p.y+this.transform.f;u[f*2]=h*l-1,u[f*2+1]=m*c+1}cq(i.length);for(let f=0;f<i.length;f++)bp[f]=L(i[f]);let d=this.gl;d.useProgram(this.program),d.bindBuffer(d.ARRAY_BUFFER,this.dynamicVbo),d.bufferData(d.ARRAY_BUFFER,u.subarray(0,r*2),d.DYNAMIC_DRAW),d.enableVertexAttribArray(this.aPosLoc),d.vertexAttribPointer(this.aPosLoc,2,d.FLOAT,!1,0,0),d.uniformMatrix3fv(this.uTransformLoc,!1,Ev),d.uniform3f(this.uColorLoc,this.fillColor[0],this.fillColor[1],this.fillColor[2]),d.uniform1f(this.uOpacityLoc,n),this.indexBuffer??=d.createBuffer(),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,this.indexBuffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,bp.subarray(0,i.length),d.DYNAMIC_DRAW),d.drawElements(d.TRIANGLES,i.length,d.UNSIGNED_SHORT,0),this.restoreSolidProgram()}indexBuffer=null;drawTriangleFan(t,n,o){let a=2/this._size.width,r=-2/this._size.height;r6(n);let s=Mv;for(let l=0;l<n;l++){let c=L(t[l]),u=this.transform.a*c.x+this.transform.c*c.y+this.transform.e,d=this.transform.b*c.x+this.transform.d*c.y+this.transform.f;s[l*2]=u*a-1,s[l*2+1]=d*r+1}let i=this.gl;i.useProgram(this.program),i.bindBuffer(i.ARRAY_BUFFER,this.dynamicVbo),i.bufferData(i.ARRAY_BUFFER,s.subarray(0,n*2),i.DYNAMIC_DRAW),i.enableVertexAttribArray(this.aPosLoc),i.vertexAttribPointer(this.aPosLoc,2,i.FLOAT,!1,0,0),i.uniformMatrix3fv(this.uTransformLoc,!1,Ev),i.uniform3f(this.uColorLoc,this.fillColor[0],this.fillColor[1],this.fillColor[2]),i.uniform1f(this.uOpacityLoc,o),i.drawArrays(i.TRIANGLE_FAN,0,n),this.restoreSolidProgram()}clear(t){let n=this.gl.canvas.width,o=this.gl.canvas.height;if(t){if(t.width<=0||t.height<=0)return;let a=this._size.width>0?n/this._size.width:1,r=this._size.height>0?o/this._size.height:1,s=Math.floor(t.x*a),i=Math.ceil(t.width*a),l=Math.ceil(t.height*r),c=Math.floor(o-(t.y+t.height)*r);this.gl.viewport(0,0,n,o),this.gl.enable(this.gl.SCISSOR_TEST),this.gl.scissor(s,c,i,l),this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.disable(this.gl.SCISSOR_TEST);return}this.gl.viewport(0,0,n,o),this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT)}setStroke(t){let n=Cv(t);this.strokeColor=[n[0],n[1],n[2]],this.strokeAlpha=n[3]}setStrokeWidth(t){this.strokeWidth=Math.max(0,t)}stroke(){if(this.currentPath){let o=this.currentPath;this.currentPolyline=[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height},{x:o.x,y:o.y}]}if(this.currentEllipse&&this.currentPolyline.length<2&&this.buildEllipseStrokePolyline(this.currentEllipse),this.currentPolyline.length<2)return;let t=this.opacity*this.strokeAlpha;if(t<=0)return;let n=this.dashArray?lq(this.currentPolyline,this.dashArray):[this.currentPolyline];for(let o of n)o.length<2||o6(this.gl,o,{width:this.strokeWidth,color:this.strokeColor,opacity:t,join:this.lineJoin,cap:this.lineCap},this.transform,this._size,this.program,this.uTransformLoc,this.uColorLoc,this.uOpacityLoc,this.dynamicVbo,this.aPosLoc,Ev);this.restoreSolidProgram()}setLineCap(t){this.lineCap=t}setLineJoin(t){this.lineJoin=t}setDashArray(t){this.dashArray=t&&t.length>0?t:null}setFont(t,n,o){this.fontFamily=t,this.fontSize=n,this.fontWeight=o?.weight??"normal",this.fontStyle=o?.style??"normal"}setTextAlign(t){this.textAlign=t}setTextBaseline(t){this.textBaseline=t}fillText(t,n,o,a){if(t.length===0)return;let r=this.ensureGlyphAtlas();if(r){this.fillTextMSDF(t,n,o,r);return}let s=this.rasteriseString(t);if(!s)return;let i=this.textMetrics(t),l=n;this.textAlign==="center"?l-=i.width/2:this.textAlign==="right"&&(l-=i.width);let c=o;this.textBaseline==="middle"?c-=this.fontSize/2:this.textBaseline==="bottom"&&(c-=this.fontSize),this.drawImage(s,l,c,i.width,this.fontSize*1.4)}msdfPipeline=null;glyphAtlas=null;glyphAtlasShaper=null;ensureGlyphAtlas(){let t=rA();return!t||!uq(t)?null:this.glyphAtlas&&this.glyphAtlasShaper===t?this.glyphAtlas:(this.glyphAtlas&&this.glyphAtlas.dispose(this.gl),this.glyphAtlas=new hp(t),this.glyphAtlasShaper=t,this.glyphAtlas)}fillTextMSDF(t,n,o,a){this.msdfPipeline??=new ly(this.gl);let r=a.resolveFontId(this.fontFamily,this.fontWeight==="bold",this.fontStyle==="italic"),s=this.textAlign==="center"?.5:this.textAlign==="right"?1:0,i=o+this.baselineOffsetForBaseline();this.msdfPipeline.drawText(t,n,i,this.fontSize,a,{opacity:this.opacity,color:this.fillColor,transform:this.transform},this._size,s,r),this.restoreSolidProgram()}restoreSolidProgram(){this.gl.useProgram(this.program),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vbo),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.vertexAttribPointer(this.aPosLoc,2,this.gl.FLOAT,!1,0,0)}measureText(t){return this.textMetrics(t)}textCtx=null;textBitmaps=new Map;ensureTextCtx(){if(this.textCtx)return this.textCtx;if(typeof OffscreenCanvas>"u")return null;let n=new OffscreenCanvas(1,1).getContext("2d");return n?(this.textCtx=n,this.textCtx):null}textFontSpec(){return`${this.fontSize}px "${kc(this.fontFamily)}", ${this.fontFamily}`}baselineOffsetCache=new Map;baselineOffsetForBaseline(){let t=this.ensureTextCtx();if(!t)return this.fontSize*.8;let n=this.textFontSpec(),o=`${n}|${this.textBaseline}`,a=this.baselineOffsetCache.get(o);if(a!==void 0)return a;t.font=n,t.textBaseline="alphabetic";let r=t.measureText("Mg").fontBoundingBoxDescent;t.textBaseline=this.textBaseline;let s=t.measureText("Mg").fontBoundingBoxDescent,i=Number.isFinite(r)&&Number.isFinite(s)?s-r:this.fontSize*.8;return this.baselineOffsetCache.set(o,i),i}textMetrics(t){let n=this.ensureGlyphAtlas();if(n){let a=n.resolveFontId(this.fontFamily,this.fontWeight==="bold",this.fontStyle==="italic"),r=0;for(let s of t){let i=s.codePointAt(0);if(i===void 0)continue;let l=n.getOrRasterize(i,a);l&&(r+=l.advance*this.fontSize/l.unitsPerEm)}return{width:r}}let o=this.ensureTextCtx();return o?(o.font=this.textFontSpec(),{width:o.measureText(t).width}):{width:t.length*this.fontSize*.55}}rasteriseString(t){if(typeof OffscreenCanvas>"u")return null;let n=`${t}|${this.textFontSpec()}|${this.fillColorString}`,o=this.textBitmaps.get(n);if(o)return this.textBitmaps.delete(n),this.textBitmaps.set(n,o),o;let a=this.textMetrics(t),r=Math.max(1,Math.ceil(a.width)),s=Math.max(1,Math.ceil(this.fontSize*1.4)),i=new OffscreenCanvas(r,s),l=i.getContext("2d");return l?(l.font=this.textFontSpec(),l.textAlign="left",l.textBaseline="top",l.fillStyle=this.fillColorString,l.fillText(t,0,0),this.textBitmaps.set(n,i),this.evictTextBitmapsIfOverCap(),i):null}evictTextBitmapsIfOverCap(){for(;this.textBitmaps.size>256;){let t=this.textBitmaps.keys().next().value;if(t===void 0)break;let n=this.textBitmaps.get(t);if(this.textBitmaps.delete(t),n){let o=this.textures.get(n);o&&(this.gl.deleteTexture(o),this.textures.delete(n))}}}},iq=(e,t)=>{for(let n of e.values())if(n===t)return!0;return!1},lq=(e,t)=>{let n=[],o=0,a=t[0]??0,r=!0,s=[];if(a<=0)return[e.slice()];for(let i=0;i<e.length-1;i++){let l=L(e[i]),c=L(e[i+1]),u=Math.hypot(c.x-l.x,c.y-l.y);if(u<1e-9)continue;let d=(c.x-l.x)/u,f=(c.y-l.y)/u,p={x:l.x,y:l.y},h=u;for(r&&s.length===0&&s.push(p);h>1e-9;){let m=Math.min(h,a),b={x:p.x+d*m,y:p.y+f*m};r&&s.push(b),p=b,h-=m,a-=m,a<=1e-9&&(r&&s.length>=2&&n.push(s),r=!r,o=(o+1)%t.length,a=t[o]??0,s=r?[{x:p.x,y:p.y}]:[],a<=0&&(a=1e-6))}}return r&&s.length>=2&&n.push(s),n},py=new Float64Array(128),Mv=new Float32Array(128),bp=new Uint16Array(256),r6=e=>{let t=e*2;if(py.length>=t)return;let n=py.length;for(;n<t;)n*=2;py=new Float64Array(n),Mv=new Float32Array(n)},cq=e=>{if(bp.length>=e)return;let t=bp.length;for(;t<e;)t*=2;bp=new Uint16Array(t)},Ev=new Float32Array([1,0,0,0,1,0,0,0,1]),s6=.5,uq=e=>{let t=e;return typeof t.glyphMetrics=="function"&&typeof t.rasterizeGlyphMSDF=="function"},i6=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),dq=(e,t,n,o)=>{let a=[];for(let r=0;r<=o;r++){let s=r/o,i=1-s;a.push({x:i*i*e.x+2*i*s*t.x+s*s*n.x,y:i*i*e.y+2*i*s*t.y+s*s*n.y})}return a},fq=(e,t,n,o,a)=>{let r=[];for(let s=0;s<=a;s++){let i=s/a,l=1-i,c=l*l,u=c*l,d=i*i,f=d*i;r.push({x:u*e.x+3*c*i*t.x+3*l*d*n.x+f*o.x,y:u*e.y+3*c*i*t.y+3*l*d*n.y+f*o.y})}return r},pq=(e,t,n)=>{let o=2/t,a=-2/n;return new Float32Array([e.a*o,e.b*a,0,e.c*o,e.d*a,0,e.e*o-1,e.f*a+1,1])},hq=e=>{let t=rn(e,e.VERTEX_SHADER,`#version 300 es
|
|
103
|
+
}`;var yh=10,Mg=class{data;instanceCount=0;constructor(t=256){this.data=new Float32Array(Math.max(1,t)*yh)}get pending(){return this.instanceCount}add(t,n,o,a,r,s,i,l,c,u){let d=(this.instanceCount+1)*yh;if(d>this.data.length){let p=this.data.length;for(;p<d;)p*=2;let h=new Float32Array(p);h.set(this.data),this.data=h}let f=this.instanceCount*yh;this.data[f]=t,this.data[f+1]=n,this.data[f+2]=o,this.data[f+3]=a,this.data[f+4]=r,this.data[f+5]=s,this.data[f+6]=i,this.data[f+7]=l,this.data[f+8]=c,this.data[f+9]=u,this.instanceCount++}flush(t){return this.instanceCount===0?!1:(t(this.data,this.instanceCount),this.instanceCount=0,!0)}reset(){this.instanceCount=0}},Rg=class{gl;program;vao;unitQuadVbo;instanceVbo;instanceBytes=0;constructor(t){this.gl=t;let n=Nt(t,t.VERTEX_SHADER,xX,"RectInstance"),o=Nt(t,t.FRAGMENT_SHADER,bX,"RectInstance");this.program=Mo(t,n,o,"RectInstance");let a=t.getAttribLocation(this.program,"aPos"),r=t.getAttribLocation(this.program,"aM0"),s=t.getAttribLocation(this.program,"aM1"),i=t.getAttribLocation(this.program,"aTrans"),l=t.getAttribLocation(this.program,"aColor");this.vao=Wt(t.createVertexArray()),this.unitQuadVbo=Wt(t.createBuffer()),this.instanceVbo=Wt(t.createBuffer()),t.bindVertexArray(this.vao),t.bindBuffer(t.ARRAY_BUFFER,this.unitQuadVbo),t.bufferData(t.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),t.STATIC_DRAW),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,0,0),t.vertexAttribDivisor(a,0);let c=yh*4;t.bindBuffer(t.ARRAY_BUFFER,this.instanceVbo),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,c,0),t.vertexAttribDivisor(r,1),t.enableVertexAttribArray(s),t.vertexAttribPointer(s,2,t.FLOAT,!1,c,8),t.vertexAttribDivisor(s,1),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,c,16),t.vertexAttribDivisor(i,1),t.enableVertexAttribArray(l),t.vertexAttribPointer(l,4,t.FLOAT,!1,c,24),t.vertexAttribDivisor(l,1),t.bindVertexArray(null)}draw(t,n){if(n===0)return;let o=this.gl,a=t.subarray(0,n*yh);o.useProgram(this.program),o.bindVertexArray(this.vao),o.bindBuffer(o.ARRAY_BUFFER,this.instanceVbo);let r=a.byteLength;r>this.instanceBytes?(o.bufferData(o.ARRAY_BUFFER,a,o.DYNAMIC_DRAW),this.instanceBytes=r):o.bufferSubData(o.ARRAY_BUFFER,0,a),o.drawArraysInstanced(o.TRIANGLE_STRIP,0,4,n),o.bindVertexArray(null)}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteBuffer(this.unitQuadVbo),this.gl.deleteBuffer(this.instanceVbo),this.gl.deleteProgram(this.program)}},xX=`#version 300 es
|
|
104
|
+
in vec2 aPos;
|
|
105
|
+
in vec2 aM0;
|
|
106
|
+
in vec2 aM1;
|
|
107
|
+
in vec2 aTrans;
|
|
108
|
+
in vec4 aColor;
|
|
109
|
+
out vec4 vColor;
|
|
110
|
+
void main() {
|
|
111
|
+
// Reconstruct the clip-space position from the projected affine
|
|
112
|
+
// columns: p = M0 * x + M1 * y + T (unit quad x,y in [0,1]).
|
|
113
|
+
vec2 p = aM0 * aPos.x + aM1 * aPos.y + aTrans;
|
|
114
|
+
gl_Position = vec4(p, 0.0, 1.0);
|
|
115
|
+
vColor = aColor;
|
|
116
|
+
}`,bX=`#version 300 es
|
|
117
|
+
precision mediump float;
|
|
118
|
+
in vec4 vColor;
|
|
119
|
+
out vec4 fragColor;
|
|
120
|
+
void main() {
|
|
121
|
+
// Premultiplied output (rgb*a, a) \u2014 matches premultipliedAlpha:true +
|
|
122
|
+
// blendFunc(ONE, 1-SRC_ALPHA).
|
|
123
|
+
fragColor = vec4(vColor.rgb * vColor.a, vColor.a);
|
|
124
|
+
}`;var Og=class{gl;program;vbo;dynamicVbo;uTransformLoc;uColorLoc;uOpacityLoc;aPosLoc;_size;fillColor=[0,0,0];fillAlpha=1;strokeColor=[0,0,0];strokeAlpha=1;fillColorString="#000";strokeWidth=1;lineCap="butt";lineJoin="miter";dashArray=null;opacity=1;currentPath=null;fontFamily="sans-serif";fontSize=14;fontWeight="normal";fontStyle="normal";textAlign="left";textBaseline="top";pathXY=new Float64Array(LX*2);pathPts=0;pushPathPoint(t,n){if((this.pathPts+1)*2>this.pathXY.length){let o=new Float64Array(this.pathXY.length*2);o.set(this.pathXY),this.pathXY=o}this.pathXY[this.pathPts*2]=t,this.pathXY[this.pathPts*2+1]=n,this.pathPts++}currentCurves=[];currentEllipse=null;transform={a:1,b:0,c:0,d:1,e:0,f:0};stack=[];rectBatch=new Mg;rectPipeline=null;constructor(t,n,o,a={}){let r=a.preserveDrawingBuffer??!0,s=t.getContext("webgl2",{antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:r});if(s??=t.getContext("webgl2",{premultipliedAlpha:!0,preserveDrawingBuffer:r}),!s)throw new Error("WebGL2 unavailable in this environment (probably hit the per-page GL context cap; Chrome allows ~16). LayeredSurface will fall back to canvas2d.");this.gl=s,this._size={width:n,height:o};let i=Nt(this.gl,this.gl.VERTEX_SHADER,EX,"WebGL2"),l=Nt(this.gl,this.gl.FRAGMENT_SHADER,TX,"WebGL2");this.program=Mo(this.gl,i,l,"WebGL2"),this.gl.useProgram(this.program),this.vbo=Wt(this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vbo),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),this.gl.STATIC_DRAW),this.dynamicVbo=Wt(this.gl.createBuffer()),this.aPosLoc=this.gl.getAttribLocation(this.program,"aPos"),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.vertexAttribPointer(this.aPosLoc,2,this.gl.FLOAT,!1,0,0),this.uTransformLoc=this.gl.getUniformLocation(this.program,"uTransform"),this.uColorLoc=this.gl.getUniformLocation(this.program,"uColor"),this.uOpacityLoc=this.gl.getUniformLocation(this.program,"uOpacity"),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.viewport(0,0,t.width,t.height)}get size(){return this._size}resize(t,n){this.flushRectBatch(),this._size.width=t,this._size.height=n,this.gl.viewport(0,0,t,n)}dispose(){this.rectBatch.reset(),this.rectPipeline&&(this.rectPipeline.dispose(),this.rectPipeline=null),this.msdfPipeline&&(this.msdfPipeline.dispose(),this.msdfPipeline=null),this.glyphAtlas&&(this.glyphAtlas.dispose(this.gl),this.glyphAtlas=null,this.glyphAtlasShaper=null),this.indexBuffer&&(this.gl.deleteBuffer(this.indexBuffer),this.indexBuffer=null),this.curvePipeline&&(this.curvePipeline.dispose(),this.curvePipeline=null),this.ellipsePipeline&&(this.ellipsePipeline.dispose(),this.ellipsePipeline=null),this.gl.deleteBuffer(this.dynamicVbo),this.imageQuadVbo&&(this.gl.deleteBuffer(this.imageQuadVbo),this.imageQuadVbo=null);for(let n of this.textures.values())this.gl.deleteTexture(n);this.textures.clear(),this.gl.getExtension("WEBGL_lose_context")?.loseContext()}setFill(t){let n=uL(t);this.fillColor=[n[0],n[1],n[2]],this.fillAlpha=n[3],this.fillColorString=t??"transparent"}setOpacity(t){this.opacity=t}save(){this.stack.push({transform:{...this.transform},fillColor:[this.fillColor[0],this.fillColor[1],this.fillColor[2]],fillAlpha:this.fillAlpha,strokeColor:[this.strokeColor[0],this.strokeColor[1],this.strokeColor[2]],strokeAlpha:this.strokeAlpha,fillColorString:this.fillColorString,strokeWidth:this.strokeWidth,lineCap:this.lineCap,lineJoin:this.lineJoin,dashArray:this.dashArray,opacity:this.opacity,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontStyle:this.fontStyle,textAlign:this.textAlign,textBaseline:this.textBaseline})}restore(){let t=this.stack.pop();t&&(this.transform=t.transform,this.fillColor=t.fillColor,this.fillAlpha=t.fillAlpha,this.strokeColor=t.strokeColor,this.strokeAlpha=t.strokeAlpha,this.fillColorString=t.fillColorString,this.strokeWidth=t.strokeWidth,this.lineCap=t.lineCap,this.lineJoin=t.lineJoin,this.dashArray=t.dashArray,this.opacity=t.opacity,this.fontFamily=t.fontFamily,this.fontSize=t.fontSize,this.fontWeight=t.fontWeight,this.fontStyle=t.fontStyle,this.textAlign=t.textAlign,this.textBaseline=t.textBaseline)}setTransform(t){this.transform={a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}}resetTransform(){this.transform={a:1,b:0,c:0,d:1,e:0,f:0}}translate(t,n){this.transform.e+=this.transform.a*t+this.transform.c*n,this.transform.f+=this.transform.b*t+this.transform.d*n}rotate(t){let n=Math.cos(t),o=Math.sin(t),{a,b:r,c:s,d:i}=this.transform;this.transform.a=a*n+s*o,this.transform.b=r*n+i*o,this.transform.c=a*-o+s*n,this.transform.d=r*-o+i*n}scale(t,n){this.transform.a*=t,this.transform.b*=t,this.transform.c*=n,this.transform.d*=n}beginPath(){this.currentPath=null,this.pathPts=0,this.currentCurves=[],this.currentEllipse=null}rect(t,n,o,a){this._pathRect.x=t,this._pathRect.y=n,this._pathRect.width=o,this._pathRect.height=a,this.currentPath=this._pathRect}_pathRect={x:0,y:0,width:0,height:0};moveTo(t,n){this.pathPts=0,this.pushPathPoint(t,n)}lineTo(t,n){this.pushPathPoint(t,n)}closePath(){this.pathPts>1&&this.pushPathPoint(v(this.pathXY[0]),v(this.pathXY[1]))}ellipse(t,n,o,a){this.currentEllipse={cx:t,cy:n,rx:o,ry:a},this.pathPts=0,this.currentPath=null}buildEllipseStrokePolyline(t){let n=Math.hypot(this.transform.a,this.transform.b),o=Math.max(t.rx,t.ry)*(Number.isFinite(n)&&n>0?n:1),a=Math.max(24,Math.min(512,Math.ceil(Math.PI*o*.7)));this.pathPts=0;for(let r=0;r<=a;r++){let s=r/a*Math.PI*2;this.pushPathPoint(t.cx+t.rx*Math.cos(s),t.cy+t.ry*Math.sin(s))}}quadraticCurveTo(t,n,o,a){let r=this.lastPathPoint()??{x:t,y:n};this.currentCurves.push({kind:"q",points:[r,{x:t,y:n},{x:o,y:a}]});let s=this.currentFlattenTolerance(),i=xy();if(i){let c=i.flatten([{kind:"M",to:r},{kind:"Q",control:{x:t,y:n},to:{x:o,y:a}}],s);for(let u=1;u<c.length;u++){let d=v(c[u]);this.pushPathPoint(d.x,d.y)}return}let l=Math.max(8,Math.min(128,Math.ceil(OD(r.x,r.y,o,a)/s)));for(let c=1;c<=l;c++){let u=c/l,d=1-u;this.pushPathPoint(d*d*r.x+2*d*u*t+u*u*o,d*d*r.y+2*d*u*n+u*u*a)}}bezierCurveTo(t,n,o,a,r,s){let i=this.lastPathPoint()??{x:r,y:s};this.currentCurves.push({kind:"c",points:[i,{x:t,y:n},{x:o,y:a},{x:r,y:s}]});let l=this.currentFlattenTolerance(),c=xy();if(c){let d=c.flatten([{kind:"M",to:i},{kind:"C",control1:{x:t,y:n},control2:{x:o,y:a},to:{x:r,y:s}}],l);for(let f=1;f<d.length;f++){let p=v(d[f]);this.pushPathPoint(p.x,p.y)}return}let u=Math.max(12,Math.min(192,Math.ceil(OD(i.x,i.y,r,s)/l)));for(let d=1;d<=u;d++){let f=d/u,p=1-f,h=p*p,m=h*p,x=f*f,y=x*f;this.pushPathPoint(m*i.x+3*h*f*t+3*p*x*o+y*r,m*i.y+3*h*f*n+3*p*x*a+y*s)}}lastPathPoint(){if(this.pathPts!==0)return{x:v(this.pathXY[(this.pathPts-1)*2]),y:v(this.pathXY[(this.pathPts-1)*2+1])}}currentFlattenTolerance(){let t=Math.hypot(this.transform.a,this.transform.b);return!Number.isFinite(t)||t<=0?RD:RD/t}drawImage(t,n,o,a,r,s,i){this.flushRectBatch();let l=this.textureFor(t,s??!1);if(!l)return;this.imageProgram||(this.imageProgram=_X(this.gl),this.imageQuadVbo=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.imageQuadVbo),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,0,0,1,0,1,0,0,1,0,1,1,1,1,1]),this.gl.STATIC_DRAW));let c=this.imageProgram;this.gl.useProgram(c.program),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.imageQuadVbo),this.gl.enableVertexAttribArray(c.aPos),this.gl.vertexAttribPointer(c.aPos,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(c.aUV),this.gl.vertexAttribPointer(c.aUV,2,this.gl.FLOAT,!1,16,8);let u=CX({a:this.transform.a*a,b:this.transform.b*a,c:this.transform.c*r,d:this.transform.d*r,e:this.transform.e+this.transform.a*n+this.transform.c*o,f:this.transform.f+this.transform.b*n+this.transform.d*o},this._size.width,this._size.height);this.gl.uniformMatrix3fv(c.uTransform,!1,u),this.gl.uniform1f(c.uOpacity,this.opacity),i&&(i.x!==0||i.y!==0||i.width!==1||i.height!==1)?(this.gl.uniform2f(c.uUvOffset,i.x,i.y),this.gl.uniform2f(c.uUvScale,i.width,i.height)):(this.gl.uniform2f(c.uUvOffset,0,0),this.gl.uniform2f(c.uUvScale,1,1)),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,l),this.gl.uniform1i(c.uTex,0),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),this.restoreSolidProgram()}imageProgram=null;imageQuadVbo=null;textures=new Map;textureFor(t,n){if(!Sg(t))return Lg(t),null;let o=t,a=this.textures.get(o);if(a)return this.textures.delete(o),this.textures.set(o,a),n&&(this.gl.bindTexture(this.gl.TEXTURE_2D,a),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t)),a;let r=this.gl.createTexture();return r?(this.gl.bindTexture(this.gl.TEXTURE_2D,r),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.textures.set(o,r),this.evictImageTexturesIfOverCap(),r):null}evictImageTexturesIfOverCap(){for(;this.textures.size>64;){let t=this.textures.keys().next().value;if(t===void 0)break;if(AX(this.textBitmaps,t)){let o=this.textures.get(t);if(o===void 0)continue;this.textures.delete(t),this.textures.set(t,o);continue}let n=this.textures.get(t);this.textures.delete(t),n&&this.gl.deleteTexture(n)}}fill(t){let n=this.opacity*this.fillAlpha;if(!(n<=0)){if(this.currentEllipse){this.flushRectBatch(),this.ellipsePipeline??=new Ig(this.gl);let o=this.currentEllipse;this.ellipsePipeline.draw(o.cx,o.cy,o.rx,o.ry,this.fillColor,n,this.transform,this._size),this.restoreSolidProgram();return}if(this.currentPath){let o=this.currentPath,a=this.transform,r=2/this._size.width,s=-2/this._size.height,i=a.a*o.width,l=a.b*o.width,c=a.c*o.height,u=a.d*o.height,d=a.e+a.a*o.x+a.c*o.y,f=a.f+a.b*o.x+a.d*o.y;this.rectBatch.add(i*r,l*s,c*r,u*s,d*r-1,f*s+1,this.fillColor[0],this.fillColor[1],this.fillColor[2],n);return}this.pathPts>=3&&(this.flushRectBatch(),this.fillPolygonEarcut(this.pathXY,this.pathPts,n)),this.currentCurves.length>0&&(this.flushRectBatch(),this.curvePipeline??=new Tg(this.gl),this.curvePipeline.draw(this.currentCurves,this.fillColor,n,this.transform,this._size),this.restoreSolidProgram())}}curvePipeline=null;ellipsePipeline=null;fillPolygonEarcut(t,n,o){let a=n>=4&&t[0]===t[(n-1)*2]&&t[1]===t[(n-1)*2+1]?n-1:n;if(a<3)return;let r=cL(t.subarray(0,a*2));if(r.length===0){this.drawTriangleFan(t,a,o);return}MD(a);let s=2/this._size.width,i=-2/this._size.height,l=gh;for(let u=0;u<a;u++){let d=v(t[u*2]),f=v(t[u*2+1]),p=this.transform.a*d+this.transform.c*f+this.transform.e,h=this.transform.b*d+this.transform.d*f+this.transform.f;l[u*2]=p*s-1,l[u*2+1]=h*i+1}kX(r.length);for(let u=0;u<r.length;u++)xh[u]=v(r[u]);let c=this.gl;c.useProgram(this.program),c.bindBuffer(c.ARRAY_BUFFER,this.dynamicVbo),c.bufferData(c.ARRAY_BUFFER,l.subarray(0,a*2),c.DYNAMIC_DRAW),c.enableVertexAttribArray(this.aPosLoc),c.vertexAttribPointer(this.aPosLoc,2,c.FLOAT,!1,0,0),c.uniformMatrix3fv(this.uTransformLoc,!1,fL),c.uniform3f(this.uColorLoc,this.fillColor[0],this.fillColor[1],this.fillColor[2]),c.uniform1f(this.uOpacityLoc,o),this.indexBuffer??=c.createBuffer(),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this.indexBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,xh.subarray(0,r.length),c.DYNAMIC_DRAW),c.drawElements(c.TRIANGLES,r.length,c.UNSIGNED_SHORT,0),this.restoreSolidProgram()}indexBuffer=null;drawTriangleFan(t,n,o){let a=2/this._size.width,r=-2/this._size.height;MD(n);let s=gh;for(let l=0;l<n;l++){let c=v(t[l*2]),u=v(t[l*2+1]),d=this.transform.a*c+this.transform.c*u+this.transform.e,f=this.transform.b*c+this.transform.d*u+this.transform.f;s[l*2]=d*a-1,s[l*2+1]=f*r+1}let i=this.gl;i.useProgram(this.program),i.bindBuffer(i.ARRAY_BUFFER,this.dynamicVbo),i.bufferData(i.ARRAY_BUFFER,s.subarray(0,n*2),i.DYNAMIC_DRAW),i.enableVertexAttribArray(this.aPosLoc),i.vertexAttribPointer(this.aPosLoc,2,i.FLOAT,!1,0,0),i.uniformMatrix3fv(this.uTransformLoc,!1,fL),i.uniform3f(this.uColorLoc,this.fillColor[0],this.fillColor[1],this.fillColor[2]),i.uniform1f(this.uOpacityLoc,o),i.drawArrays(i.TRIANGLE_FAN,0,n),this.restoreSolidProgram()}clear(t){this.flushRectBatch();let n=this.gl.canvas.width,o=this.gl.canvas.height;if(t){if(t.width<=0||t.height<=0)return;let a=this._size.width>0?n/this._size.width:1,r=this._size.height>0?o/this._size.height:1,s=Math.floor(t.x*a),i=Math.ceil(t.width*a),l=Math.ceil(t.height*r),c=Math.floor(o-(t.y+t.height)*r);this.gl.viewport(0,0,n,o),this.gl.enable(this.gl.SCISSOR_TEST),this.gl.scissor(s,c,i,l),this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.disable(this.gl.SCISSOR_TEST);return}this.gl.viewport(0,0,n,o),this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT)}setStroke(t){let n=uL(t);this.strokeColor=[n[0],n[1],n[2]],this.strokeAlpha=n[3]}setStrokeWidth(t){this.strokeWidth=Math.max(0,t)}stroke(){if(this.flushRectBatch(),this.currentPath){let o=this.currentPath;this.pathPts=0,this.pushPathPoint(o.x,o.y),this.pushPathPoint(o.x+o.width,o.y),this.pushPathPoint(o.x+o.width,o.y+o.height),this.pushPathPoint(o.x,o.y+o.height),this.pushPathPoint(o.x,o.y)}if(this.currentEllipse&&this.pathPts<2&&this.buildEllipseStrokePolyline(this.currentEllipse),this.pathPts<2)return;let t=this.opacity*this.strokeAlpha;if(t<=0)return;let n={width:this.strokeWidth,color:this.strokeColor,opacity:t,join:this.lineJoin,cap:this.lineCap};if(this.dashArray){let o=new Array(this.pathPts);for(let a=0;a<this.pathPts;a++)o[a]={x:v(this.pathXY[a*2]),y:v(this.pathXY[a*2+1])};for(let a of vX(o,this.dashArray))if(!(a.length<2)){SX(a.length*2);for(let r=0;r<a.length;r++){let s=v(a[r]);iu[r*2]=s.x,iu[r*2+1]=s.y}this.strokePolylineFlat(iu,a.length,n)}}else this.strokePolylineFlat(this.pathXY,this.pathPts,n);this.restoreSolidProgram()}strokePolylineFlat(t,n,o){_D(this.gl,t,n,o,this.transform,this._size,this.program,this.uTransformLoc,this.uColorLoc,this.uOpacityLoc,this.dynamicVbo,this.aPosLoc,fL)}setLineCap(t){this.lineCap=t}setLineJoin(t){this.lineJoin=t}setDashArray(t){this.dashArray=t&&t.length>0?t:null}setFont(t,n,o){this.fontFamily=t,this.fontSize=n,this.fontWeight=o?.weight??"normal",this.fontStyle=o?.style??"normal"}setTextAlign(t){this.textAlign=t}setTextBaseline(t){this.textBaseline=t}fillText(t,n,o,a){if(t.length===0)return;this.flushRectBatch();let r=this.ensureGlyphAtlas();if(r){this.fillTextMSDF(t,n,o,r);return}let s=this.rasteriseString(t);if(!s)return;let i=this.textMetrics(t),l=n;this.textAlign==="center"?l-=i.width/2:this.textAlign==="right"&&(l-=i.width);let c=o;this.textBaseline==="middle"?c-=this.fontSize/2:this.textBaseline==="bottom"&&(c-=this.fontSize),this.drawImage(s,l,c,i.width,this.fontSize*1.4)}msdfPipeline=null;glyphAtlas=null;glyphAtlasShaper=null;ensureGlyphAtlas(){let t=Iv();return!t||!wX(t)?null:this.glyphAtlas&&this.glyphAtlasShaper===t?this.glyphAtlas:(this.glyphAtlas&&this.glyphAtlas.dispose(this.gl),this.glyphAtlas=new ch(t),this.glyphAtlasShaper=t,this.glyphAtlas)}fillTextMSDF(t,n,o,a){this.msdfPipeline??=new Cg(this.gl);let r=a.resolveFontId(this.fontFamily,this.fontWeight==="bold",this.fontStyle==="italic"),s=this.textAlign==="center"?.5:this.textAlign==="right"?1:0,i=o+this.baselineOffsetForBaseline();this.msdfPipeline.drawText(t,n,i,this.fontSize,a,{opacity:this.opacity,color:this.fillColor,transform:this.transform},this._size,s,r),this.restoreSolidProgram()}restoreSolidProgram(){this.gl.useProgram(this.program),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vbo),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.vertexAttribPointer(this.aPosLoc,2,this.gl.FLOAT,!1,0,0)}flushRectBatch(){if(this.rectBatch.pending===0)return;this.rectPipeline??=new Rg(this.gl);let t=this.rectPipeline;this.rectBatch.flush((n,o)=>{t.draw(n,o)}),this.restoreSolidProgram()}flushBatch(){this.flushRectBatch()}measureText(t){return this.textMetrics(t)}textCtx=null;textBitmaps=new Map;ensureTextCtx(){if(this.textCtx)return this.textCtx;if(typeof OffscreenCanvas>"u")return null;let n=new OffscreenCanvas(1,1).getContext("2d");return n?(this.textCtx=n,this.textCtx):null}textFontSpec(){let t=this.fontStyle==="italic"?"italic ":"",n=this.fontWeight==="bold"?"bold ":"";return`${t}${n}${this.fontSize}px "${ru(this.fontFamily)}", ${this.fontFamily}`}baselineOffsetCache=new Map;baselineOffsetForBaseline(){let t=this.ensureTextCtx();if(!t)return this.fontSize*.8;let n=this.textFontSpec(),o=`${n}|${this.textBaseline}`,a=this.baselineOffsetCache.get(o);if(a!==void 0)return a;t.font=n,t.textBaseline="alphabetic";let r=t.measureText("Mg").fontBoundingBoxDescent;t.textBaseline=this.textBaseline;let s=t.measureText("Mg").fontBoundingBoxDescent,i=Number.isFinite(r)&&Number.isFinite(s)?s-r:this.fontSize*.8;return this.baselineOffsetCache.set(o,i),i}textMetrics(t){let n=this.ensureGlyphAtlas();if(n){let a=n.resolveFontId(this.fontFamily,this.fontWeight==="bold",this.fontStyle==="italic");return{width:SD(t,n,a)*this.fontSize}}let o=this.ensureTextCtx();return o?(o.font=this.textFontSpec(),{width:o.measureText(t).width}):{width:t.length*this.fontSize*.55}}rasteriseString(t){if(typeof OffscreenCanvas>"u")return null;let n=`${t}|${this.textFontSpec()}|${this.fillColorString}`,o=this.textBitmaps.get(n);if(o)return this.textBitmaps.delete(n),this.textBitmaps.set(n,o),o;let a=this.textMetrics(t),r=Math.max(1,Math.ceil(a.width)),s=Math.max(1,Math.ceil(this.fontSize*1.4)),i=new OffscreenCanvas(r,s),l=i.getContext("2d");return l?(l.font=this.textFontSpec(),l.textAlign="left",l.textBaseline="top",l.fillStyle=this.fillColorString,l.fillText(t,0,0),this.textBitmaps.set(n,i),this.evictTextBitmapsIfOverCap(),i):null}evictTextBitmapsIfOverCap(){for(;this.textBitmaps.size>256;){let t=this.textBitmaps.keys().next().value;if(t===void 0)break;let n=this.textBitmaps.get(t);if(this.textBitmaps.delete(t),n){let o=this.textures.get(n);o&&(this.gl.deleteTexture(o),this.textures.delete(n))}}}},AX=(e,t)=>{for(let n of e.values())if(n===t)return!0;return!1},vX=(e,t)=>{let n=[],o=0,a=t[0]??0,r=!0,s=[];if(a<=0)return[e.slice()];for(let i=0;i<e.length-1;i++){let l=v(e[i]),c=v(e[i+1]),u=Math.hypot(c.x-l.x,c.y-l.y);if(u<1e-9)continue;let d=(c.x-l.x)/u,f=(c.y-l.y)/u,p={x:l.x,y:l.y},h=u;for(r&&s.length===0&&s.push(p);h>1e-9;){let m=Math.min(h,a),x={x:p.x+d*m,y:p.y+f*m};r&&s.push(x),p=x,h-=m,a-=m,a<=1e-9&&(r&&s.length>=2&&n.push(s),r=!r,o=(o+1)%t.length,a=t[o]??0,s=r?[{x:p.x,y:p.y}]:[],a<=0&&(a=1e-6))}}return r&&s.length>=2&&n.push(s),n},gh=new Float32Array(128),xh=new Uint16Array(256),MD=e=>{let t=e*2;if(gh.length>=t)return;let n=gh.length;for(;n<t;)n*=2;gh=new Float32Array(n)},iu=new Float64Array(128),SX=e=>{if(iu.length>=e)return;let t=iu.length;for(;t<e;)t*=2;iu=new Float64Array(t)},LX=128,kX=e=>{if(xh.length>=e)return;let t=xh.length;for(;t<e;)t*=2;xh=new Uint16Array(t)},fL=new Float32Array([1,0,0,0,1,0,0,0,1]),RD=.5,wX=e=>{let t=e;return typeof t.glyphMetrics=="function"&&typeof t.rasterizeGlyphMSDF=="function"},OD=(e,t,n,o)=>Math.hypot(e-n,t-o),_X=e=>{let t=Nt(e,e.VERTEX_SHADER,`#version 300 es
|
|
104
125
|
in vec2 aPos;
|
|
105
126
|
in vec2 aUV;
|
|
106
127
|
uniform mat3 uTransform;
|
|
128
|
+
uniform vec2 uUvOffset;
|
|
129
|
+
uniform vec2 uUvScale;
|
|
107
130
|
out vec2 vUV;
|
|
108
131
|
void main() {
|
|
109
132
|
vec3 p = uTransform * vec3(aPos, 1.0);
|
|
110
133
|
gl_Position = vec4(p.xy, 0.0, 1.0);
|
|
111
|
-
|
|
112
|
-
|
|
134
|
+
// Crop: map the unit-quad UV into the source sub-rect. Identity is
|
|
135
|
+
// offset (0,0) + scale (1,1); a crop narrows it to the kept region.
|
|
136
|
+
vUV = aUV * uUvScale + uUvOffset;
|
|
137
|
+
}`,"WebGL2"),n=Nt(e,e.FRAGMENT_SHADER,`#version 300 es
|
|
113
138
|
precision mediump float;
|
|
114
139
|
in vec2 vUV;
|
|
115
140
|
uniform sampler2D uTex;
|
|
@@ -122,13 +147,13 @@ void main() {
|
|
|
122
147
|
// channels by the per-call opacity.
|
|
123
148
|
vec4 t = texture(uTex, vUV);
|
|
124
149
|
fragColor = vec4(t.rgb * uOpacity, t.a * uOpacity);
|
|
125
|
-
}`,"WebGL2"),o=
|
|
150
|
+
}`,"WebGL2"),o=Mo(e,t,n,"WebGL2");return{program:o,aPos:e.getAttribLocation(o,"aPos"),aUV:e.getAttribLocation(o,"aUV"),uTransform:e.getUniformLocation(o,"uTransform"),uTex:e.getUniformLocation(o,"uTex"),uOpacity:e.getUniformLocation(o,"uOpacity"),uUvOffset:e.getUniformLocation(o,"uUvOffset"),uUvScale:e.getUniformLocation(o,"uUvScale")}},ua=new Float32Array(9),CX=(e,t,n)=>{let o=2/t,a=-2/n;return ua[0]=e.a*o,ua[1]=e.b*a,ua[2]=0,ua[3]=e.c*o,ua[4]=e.d*a,ua[5]=0,ua[6]=e.e*o-1,ua[7]=e.f*a+1,ua[8]=1,ua},EX=`#version 300 es
|
|
126
151
|
in vec2 aPos;
|
|
127
152
|
uniform mat3 uTransform;
|
|
128
153
|
void main() {
|
|
129
154
|
vec3 p = uTransform * vec3(aPos, 1.0);
|
|
130
155
|
gl_Position = vec4(p.xy, 0.0, 1.0);
|
|
131
|
-
}`,
|
|
156
|
+
}`,TX=`#version 300 es
|
|
132
157
|
precision mediump float;
|
|
133
158
|
uniform vec3 uColor;
|
|
134
159
|
uniform float uOpacity;
|
|
@@ -137,9 +162,9 @@ void main() {
|
|
|
137
162
|
// Output premultiplied (rgb*a, a) \u2014 matches the context's
|
|
138
163
|
// premultipliedAlpha:true contract + blendFunc(ONE, 1-SRC_ALPHA).
|
|
139
164
|
fragColor = vec4(uColor * uOpacity, uOpacity);
|
|
140
|
-
}`;var my=()=>typeof OffscreenCanvas>"u"||typeof HTMLCanvasElement>"u"?!1:typeof HTMLCanvasElement.prototype.transferControlToOffscreen=="function",Ov=(e,t)=>{let n=new OffscreenCanvas(e,t),o=n.getContext("2d");if(!o)throw new Error("OffscreenCanvas 2D context unavailable");let a=new wc(o,e,t);return{canvas:n,target:a}};var Cc=(e,t,n,o=window.devicePixelRatio||1,a=!0)=>{let r=Math.round(t*o),s=Math.round(n*o),i=`${t}px`,l=`${n}px`;if(e.width===r&&e.height===s&&e.style.width===i&&e.style.height===l)return o;if(e.width=r,e.height=s,e.style.width=i,e.style.height=l,a){let c=e.getContext("2d");if(!c)throw new Error("Failed to obtain 2D context");c.setTransform(o,0,0,o,0,0)}return o};var Ap=class{host;layers;canvases;width;height;dprOverride;constructor(t,n,o,a={}){this.host=t,this.width=n,this.height=o,this.dprOverride=a.dpr,getComputedStyle(t).position==="static"&&(t.style.position="relative");let r=a.layers??Ks,s=new Map,i=new Map;for(let l of Ks){if(!r.includes(l))continue;let c=t.ownerDocument.createElement("canvas");c.dataset.layer=l,c.style.position="absolute",c.style.inset="0",c.style.pointerEvents=l==="overlay"?"auto":"none",t.appendChild(c);let u=Cc(c,n,o,this.dprOverride),d=c.getContext("2d");if(!d)throw new Error("Failed to obtain 2D context");s.set(l,new wc(d,n,o,u)),i.set(l,c)}this.layers=s,this.canvases=i}get(t){let n=this.layers.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}getCanvas(t){let n=this.canvases.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}resize(t,n){if(!(this.width===t&&this.height===n)){this.width=t,this.height=n;for(let[o,a]of this.canvases){let r=Cc(a,t,n,this.dprOverride),s=this.layers.get(o);s!==void 0&&s.resize(t,n,r)}}}get size(){return{width:this.width,height:this.height}}dispose(){for(let t of this.canvases.values())t.remove()}};var Rv=()=>new Worker(new URL("./render-worker.js",import.meta.url),{type:"module"});var yy=class{commands=[];_width;_height;skippedImageDraws=0;fontSpec="10px sans-serif";measureCtx=null;imageIds=new Ef(64);nextImageId=0;constructor(t,n){this._width=t,this._height=n}get size(){return{width:this._width,height:this._height}}resize(t,n){this._width=t,this._height=n,this.commands.push({k:"resize",w:t,h:n})}flush(){let t=this.commands;return this.commands=[],t}peek(){return this.commands}setFill(t){this.commands.push({k:"setFill",color:t})}setStroke(t){this.commands.push({k:"setStroke",color:t})}setStrokeWidth(t){this.commands.push({k:"setStrokeWidth",w:t})}setOpacity(t){this.commands.push({k:"setOpacity",a:t})}setLineCap(t){this.commands.push({k:"setLineCap",cap:t})}setLineJoin(t){this.commands.push({k:"setLineJoin",join:t})}setDashArray(t){this.commands.push({k:"setDashArray",dash:t})}setFont(t,n,o){this.commands.push({k:"setFont",family:t,size:n,...o?{options:o}:{}});let a=o?.style==="italic"?"italic ":"",r=o?.weight==="bold"?"bold ":"";this.fontSpec=`${a}${r}${n}px "${kc(t)}", ${t}`}setTextAlign(t){this.commands.push({k:"setTextAlign",align:t})}setTextBaseline(t){this.commands.push({k:"setTextBaseline",baseline:t})}save(){this.commands.push({k:"save"})}restore(){this.commands.push({k:"restore"})}translate(t,n){this.commands.push({k:"translate",x:t,y:n})}rotate(t){this.commands.push({k:"rotate",r:t})}scale(t,n){this.commands.push({k:"scale",sx:t,sy:n})}setTransform(t){this.commands.push({k:"setTransform",t})}resetTransform(){this.commands.push({k:"resetTransform"})}beginPath(){this.commands.push({k:"beginPath"})}closePath(){this.commands.push({k:"closePath"})}moveTo(t,n){this.commands.push({k:"moveTo",x:t,y:n})}lineTo(t,n){this.commands.push({k:"lineTo",x:t,y:n})}quadraticCurveTo(t,n,o,a){this.commands.push({k:"quadraticCurveTo",cx:t,cy:n,x:o,y:a})}bezierCurveTo(t,n,o,a,r,s){this.commands.push({k:"bezierCurveTo",c1x:t,c1y:n,c2x:o,c2y:a,x:r,y:s})}rect(t,n,o,a){this.commands.push({k:"rect",x:t,y:n,w:o,h:a})}ellipse(t,n,o,a){this.commands.push({k:"ellipse",cx:t,cy:n,rx:o,ry:a})}fill(t){this.commands.push(t!==void 0?{k:"fill",rule:t}:{k:"fill"})}stroke(){this.commands.push({k:"stroke"})}fillText(t,n,o,a){this.commands.push(a!==void 0?{k:"fillText",text:t,x:n,y:o,maxWidth:a}:{k:"fillText",text:t,x:n,y:o})}measureText(t){let n=this.ensureMeasureCtx();return n?(n.font=this.fontSpec,{width:n.measureText(t).width}):{width:t.length*(Number.parseFloat(this.fontSpec)||8)*.5}}ensureMeasureCtx(){if(this.measureCtx)return this.measureCtx;if(typeof OffscreenCanvas>"u")return null;let t=new OffscreenCanvas(1,1).getContext("2d");return this.measureCtx=t??null,this.measureCtx}drawImage(t,n,o,a,r,s){if(typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let i=this.imageIds.get(t);i===void 0&&(i=this.nextImageId++,this.imageIds.set(t,i),this.commands.push({k:"defineImage",id:i,bitmap:t})),this.commands.push({k:"drawImage",id:i,dx:n,dy:o,dw:a,dh:r})}else this.skippedImageDraws++}clear(t){this.commands.push(t!==void 0?{k:"clear",bounds:t}:{k:"clear"})}markDirty(t){this.commands.push({k:"markDirty",bounds:t})}};var Dv=(e,t,n,o={})=>{switch(o.backend??"canvas2d"){case"canvas2d":return new Pv(e,t,n);case"webgl2":return new Bv(e,t,n);case"offscreen":if(!o.workerFactory)throw new Error("createLayeredSurface: workerFactory is required for the offscreen backend");return new zv(e,t,n,o.workerFactory,o.onWorkerError)}},Nv=(e,t,n,o={},a)=>{let r=o.backend??"canvas2d";try{return{surface:Dv(e,t,n,o),effectiveBackend:r}}catch(s){if(r==="canvas2d")throw s;return a?.(r,s),{surface:Dv(e,t,n,{...o,backend:"canvas2d"}),effectiveBackend:"canvas2d"}}},Pv=class{backend="canvas2d";inner;constructor(t,n,o){this.inner=new Ap(t,n,o)}get(t){return this.inner.get(t)}getCanvas(t){return this.inner.getCanvas(t)}resize(t,n){this.inner.resize(t,n)}get size(){return this.inner.size}present(){}dispose(){this.inner.dispose()}},Bv=class{backend="webgl2";base;mainCanvas;mainTarget;_width;_height;constructor(t,n,o){this._width=n,this._height=o,this.base=new Ap(t,n,o,{layers:Ks.filter(s=>s!=="main")});let a=this.base.getCanvas("overlay"),r=t.ownerDocument.createElement("canvas");r.dataset.layer="main",r.dataset.backend="webgl2",r.style.position="absolute",r.style.inset="0",r.style.pointerEvents="none",t.insertBefore(r,a),Cc(r,n,o,window.devicePixelRatio||1,!1);try{this.mainCanvas=r,this.mainTarget=new hy(r,n,o)}catch(s){throw r.remove(),this.base.dispose(),s}}get(t){return t==="main"?this.mainTarget:this.base.get(t)}getCanvas(t){return t==="main"?this.mainCanvas:this.base.getCanvas(t)}resize(t,n){this._width===t&&this._height===n||(this._width=t,this._height=n,this.base.resize(t,n),Cc(this.mainCanvas,t,n,window.devicePixelRatio||1,!1),this.mainTarget.resize(t,n))}get size(){return{width:this._width,height:this._height}}present(){}dispose(){this.mainTarget.dispose(),this.mainCanvas.remove(),this.base.dispose()}},zv=class{backend="offscreen";canvases=new Map;targets=new Map;workers=new Map;_width;_height;dpr;constructor(t,n,o,a,r){this._width=n,this._height=o,this.dpr=typeof window<"u"&&window.devicePixelRatio||1,getComputedStyle(t).position==="static"&&(t.style.position="relative");let s=!1,i=l=>{s||(s=!0,r?.(l))};try{for(let l of Ks){let c=t.ownerDocument.createElement("canvas");c.dataset.layer=l,c.dataset.backend="offscreen",c.style.position="absolute",c.style.inset="0",c.style.pointerEvents=l==="overlay"?"auto":"none",c.style.width=`${n}px`,c.style.height=`${o}px`,t.appendChild(c);let u=a();u.onerror=f=>{i(f)};let d=c.transferControlToOffscreen();u.postMessage({type:"init",canvas:d,width:n,height:o,dpr:this.dpr},[d]),this.canvases.set(l,c),this.workers.set(l,u),this.targets.set(l,new yy(n,o))}}catch(l){throw this.dispose(),l}}get(t){let n=this.targets.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}getCanvas(t){let n=this.canvases.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}resize(t,n){if(!(this._width===t&&this._height===n)){this._width=t,this._height=n;for(let[o,a]of this.canvases)a.style.width=`${t}px`,a.style.height=`${n}px`,this.targets.get(o)?.resize(t,n),this.workers.get(o)?.postMessage({type:"resize",width:t,height:n})}}get size(){return{width:this._width,height:this._height}}present(){for(let[t,n]of this.targets){let o=n.flush();o.length!==0&&this.workers.get(t)?.postMessage({type:"replay",commands:o})}}dispose(){for(let t of this.workers.values())t.terminate();for(let t of this.canvases.values())t.remove();this.workers.clear(),this.canvases.clear(),this.targets.clear()}};var Fv=async()=>{if(typeof navigator>"u")return!1;let e=navigator.gpu;if(!e)return!1;try{return await e.requestAdapter()!==null}catch{return!1}},Hv=()=>{if(typeof document>"u")return!1;try{let t=document.createElement("canvas").getContext("webgl2");return t?(t.getExtension?.("WEBGL_lose_context")?.loseContext(),!0):!1}catch{return!1}};var l6=(0,Se.createContext)(null),Uv=({initialScene:e,initialMode:t,children:n,onReady:o,skipInstallRenderers:a,renderer:r="canvas2d",workerFactory:s,textShaper:i,rasterizer:l})=>{let[c,u]=(0,Se.useState)(null),d=(0,Se.useRef)(null),f=(0,Se.useRef)(null),p=(0,Se.useRef)(null),h=(0,Se.useRef)(null),m=(0,Se.useRef)(null),b=(0,Se.useRef)(!1),y=(0,Se.useRef)(()=>{}),g=(0,Se.useRef)(r),x=(0,Se.useRef)(s),A=(0,Se.useRef)(i),C=(0,Se.useRef)(l);g.current=r,x.current=s,A.current=i,C.current=l;let _=(0,Se.useCallback)(T=>{a||oc();let{width:P,height:N}=T.getBoundingClientRect(),{surface:U,effectiveBackend:q}=Nv(T,P,N,{backend:b.current?"canvas2d":g.current,...x.current?{workerFactory:x.current}:{},onWorkerError:$=>{y.current($)}},($,re)=>{console.warn(`[DiagramRoot] ${$} renderer unavailable, falling back to canvas2d:`,re)});T.dataset.effectiveBackend=q;let te={host:T,mainTarget:U.get("main"),overlayTarget:U.get("overlay"),backgroundTarget:U.get("background"),onAfterRender:()=>f.current?.present(),initialScene:e,...t!==void 0?{initialMode:t}:{},...A.current?{textShaper:A.current}:{},...C.current?{rasterizer:C.current}:{}},Z=new Xf(te);Z.setViewportSize(P,N),f.current=U,d.current=Z,u(Z),o?.(Z),U.present();let ue=new ResizeObserver(()=>{let $=T.getBoundingClientRect();U.resize($.width,$.height),Z.setViewportSize($.width,$.height),Z.forceRender()});ue.observe(T),p.current=ue},[]),v=(0,Se.useCallback)(()=>{p.current?.disconnect(),p.current=null,m.current?.(),m.current=null,d.current?.dispose(),d.current=null,f.current?.dispose(),f.current=null},[]);y.current=T=>{if(b.current)return;b.current=!0,console.warn("[DiagramRoot] offscreen render worker failed to load; falling back to canvas2d:",T);let P=h.current;P&&(v(),_(P))};let I=(0,Se.useCallback)(T=>{if(v(),h.current=T,!T){u(null);return}_(T)},[_,v]),k=(0,Se.useRef)(null);return(0,Se.useEffect)(()=>{let T=h.current;if(T){if(k.current===null){k.current=r;return}k.current!==r&&(k.current=r,b.current=!1,v(),_(T))}},[r,_,v]),(0,Se.useLayoutEffect)(()=>()=>{v(),h.current=null},[v]),(0,jr.jsx)(S_.Provider,{value:c,children:(0,jr.jsx)(l6.Provider,{value:I,children:(0,jr.jsxs)(M8,{children:[n,(0,jr.jsx)(xq,{editor:c})]})})})},xq=({editor:e})=>{let[t,n]=(0,Se.useState)("");return(0,Se.useEffect)(()=>{if(e)return e.onAnnounce(n)},[e]),(0,jr.jsx)("div",{role:"status","aria-live":"polite","aria-atomic":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0},children:t})},Gv=({style:e,className:t,ariaLabel:n})=>{let o=(0,Se.useContext)(l6),a=(0,Se.useRef)(null);if((0,Se.useLayoutEffect)(()=>{if(o)return o(a.current),()=>{o(null)}},[o]),!o)throw new Error("@oh-just-another/react-ui: <DiagramSurface> rendered outside <DiagramRoot>.");return(0,jr.jsx)("div",{ref:a,className:t?`du-canvas-surface ${t}`:"du-canvas-surface",role:"application",tabIndex:0,"aria-label":n??"Diagram canvas",style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",touchAction:"none",userSelect:"none",...e}})};var Tc=2,Rt=w.object({x:w.number(),y:w.number()}),kde=w.object({x:w.number(),y:w.number(),width:w.number(),height:w.number()}),bq=w.object({type:w.enum(["sharp","round"]),value:w.number().optional()}).strict(),bo=w.object({fill:w.string().optional(),stroke:w.string().optional(),strokeWidth:w.number().optional(),opacity:w.number().optional(),dashArray:w.array(w.number()).readonly().optional(),lineCap:w.enum(["butt","round","square"]).optional(),lineJoin:w.enum(["miter","round","bevel"]).optional(),strokeAlign:w.enum(["center","inside","outside"]).optional(),roundness:bq.optional()}).strict(),Aq=bo.extend({textAlign:w.enum(["left","center","right"]).optional(),textBaseline:w.enum(["top","middle","bottom"]).optional(),fontWeight:w.enum(["normal","bold"]).optional(),fontStyle:w.enum(["normal","italic"]).optional(),textDecoration:w.object({underline:w.boolean().optional(),strikethrough:w.boolean().optional()}).strict().optional()}).strict(),d6=w.record(w.string(),w.unknown()).optional(),vq=w.string(),f6=w.discriminatedUnion("kind",[w.object({kind:w.literal("named"),name:vq}).strict(),w.object({kind:w.literal("ratio"),position:Rt}).strict(),w.object({kind:w.literal("absolute"),offset:Rt}).strict(),w.object({kind:w.literal("edge"),index:w.number().int().nonnegative(),t:w.number()}).strict()]),Vo=w.object({id:w.string(),layerId:w.string(),position:Rt,rotation:w.number(),scale:Rt,order:w.string(),metadata:d6,minWidth:w.number().optional(),minHeight:w.number().optional(),maxWidth:w.number().optional(),maxHeight:w.number().optional(),noFlip:w.boolean().optional(),anchors:w.record(w.string(),f6).optional(),parentId:w.string().optional(),frameId:w.string().optional(),href:w.string().optional()}),Lq=Vo.extend({type:w.literal("rectangle"),style:bo,width:w.number(),height:w.number()}).strict(),Sq=Vo.extend({type:w.literal("ellipse"),style:bo,width:w.number(),height:w.number()}).strict(),kq=Vo.extend({type:w.literal("polygon"),style:bo,points:w.array(Rt)}).strict(),wq=w.discriminatedUnion("kind",[w.object({kind:w.literal("M"),to:Rt}).strict(),w.object({kind:w.literal("L"),to:Rt}).strict(),w.object({kind:w.literal("Q"),control:Rt,to:Rt}).strict(),w.object({kind:w.literal("C"),control1:Rt,control2:Rt,to:Rt}).strict(),w.object({kind:w.literal("Z")}).strict()]),_q=Vo.extend({type:w.literal("path"),style:bo,commands:w.array(wq)}).strict(),Cq=Vo.extend({type:w.literal("text"),style:Aq,text:w.string(),fontFamily:w.string(),fontSize:w.number(),maxWidth:w.number().optional()}).strict(),Tq=Vo.extend({type:w.literal("image"),style:bo,src:w.string(),width:w.number(),height:w.number(),fileId:w.string().optional(),animationKind:w.string().optional(),animationData:w.unknown().optional()}).strict(),Iq=Vo.extend({type:w.literal("template"),style:bo.optional(),templateId:w.string(),data:w.record(w.string(),w.unknown()),width:w.number(),height:w.number()}).strict(),Eq=Vo.extend({type:w.literal("group"),style:bo.optional()}).strict(),Mq=w.object({x:w.number(),y:w.number(),width:w.number()}).strict(),Oq=Vo.extend({type:w.literal("brush"),style:bo,points:w.array(Mq)}).strict(),Rq=Vo.extend({type:w.string(),style:bo.optional()}).passthrough().refine(e=>!["rectangle","ellipse","polygon","path","text","image","template","group","brush"].includes(e.type),{message:"Use the specific built-in schema for built-in shape types"}),Dq=w.union([Lq,Sq,kq,_q,Cq,Tq,Iq,Eq,Oq,Rq]),c6=w.discriminatedUnion("kind",[w.object({kind:w.literal("point"),position:Rt}).strict(),w.object({kind:w.literal("anchor"),elementId:w.string(),anchor:f6}).strict(),w.object({kind:w.literal("outline"),elementId:w.string(),ratio:w.number()}).strict(),w.object({kind:w.literal("floating"),elementId:w.string()}).strict()]),Pq=w.enum(["straight","orthogonal","bezier"]),u6=w.enum(["none","arrow","openArrow","roundedArrow","arcArrow","triangle","filledArrow","circle","filledCircle","diamond","rhombus","filledRhombus","erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"]),Bq=w.object({from:u6.optional(),to:u6.optional(),size:w.number().optional()}).strict(),zq=w.object({text:w.string(),position:w.number().optional(),fontSize:w.number().optional(),fill:w.string().optional(),background:w.string().optional()}).strict(),Nq=w.object({id:w.string(),layerId:w.string(),from:c6,to:c6,waypoints:w.array(Rt).readonly().optional(),routedPoints:w.array(Rt).readonly().optional(),fixedSegments:w.array(w.object({axis:w.enum(["h","v"]),pos:w.number(),at:w.number()}).strict()).readonly().optional(),routing:Pq.optional(),avoidObstacles:w.boolean().optional(),arrowheads:Bq.optional(),label:zq.optional(),order:w.string(),style:bo,metadata:d6}).strict(),Fq=w.object({id:w.string(),name:w.string(),visible:w.boolean(),locked:w.boolean(),order:w.string()}).strict(),Hq=w.object({pan:Rt,zoom:w.number(),rotation:w.number(),size:w.object({width:w.number(),height:w.number()}).strict(),gridEnabled:w.boolean(),gridStyle:w.enum(["lines","dots"]).optional(),snapToGrid:w.boolean().optional()}).strict(),Uq=w.object({id:w.string(),authorId:w.string(),authorName:w.string(),body:w.string(),createdAt:w.string()}).strict(),Gq=w.object({id:w.string(),elementId:w.string().nullable(),position:Rt,resolved:w.boolean(),thread:w.array(Uq),createdAt:w.string()}).strict(),p6=w.object({format:w.literal("oh-just-another/scene"),version:w.number().int().nonnegative(),elements:w.array(Dq),links:w.array(Nq),layers:w.array(Fq),annotations:w.array(Gq).optional(),viewport:Hq}).strict();var h6=e=>{let t=e.annotations.size>0?[...e.annotations.values()]:void 0,n={format:"oh-just-another/scene",version:Tc,elements:[...e.elements.values()].map(qq),links:[...e.links.values()],layers:[...e.layers.values()],viewport:e.viewport};return t&&(n.annotations=t),n},qq=e=>{let t=e.metadata,n=t&&"image"in t,o=e.animationData!==void 0;if(!n&&!o)return e;let a={...e};if(n){let{image:r,...s}=t;Object.keys(s).length>0?a.metadata=s:delete a.metadata}return o&&delete a.animationData,a},qv=(e,t=null)=>JSON.stringify(h6(e),null,t??void 0);var m6=new Map,y6=(e,t)=>{m6.set(e,t)},g6=(e,t,n)=>{let o=e;for(let a=t;a<n;a++){let r=m6.get(a);if(!r)throw new Wv(a,n);o=r(o)}return o},Wv=class extends Error{fromVersion;toVersion;constructor(t,n){super(`No migration registered from v${t} \u2192 v${t+1} (target v${n})`),this.name="MissingMigrationError",this.fromVersion=t,this.toVersion=n}};var Wq=e=>{let t=e,n={...t.viewport??{}},o=n.gridSize;return delete n.gridSize,n.gridEnabled=typeof o=="number"&&o>0,{...t,version:2,viewport:n}};y6(1,Wq);var Ic=class extends Error{reason;constructor(t,n){super(t),this.name="DeserializationError",this.reason=n}},x6=(e,t={})=>{if(typeof e!="object"||e===null)throw new Ic("Expected an object",e);let n=e.version,o=typeof n=="number"?n:0,a=t.maxVersion??Tc;if(o>a)throw new Ic(`Document version ${o} is newer than this build understands (${a}). Upgrade your library.`,null);let r=o===Tc?e:g6(e,o,Tc),s;try{s=p6.parse(r)}catch(i){throw i instanceof w.ZodError?new Ic(`Invalid scene document: ${i.message}`,i):i}return jq(s)},jv=(e,t)=>x6(JSON.parse(e),t),jq=e=>{let t=new Map;for(let s of e.elements){let i=Qe(s.id);t.set(i,Vq(s,i))}let n=new Map;for(let s of e.links){let i=E1(s.id);n.set(i,Zq(s,i))}let o=new Map;for(let s of e.layers){let i=$t(s.id);o.set(i,{id:i,name:s.name,visible:s.visible,locked:s.locked,order:s.order})}let a=Ud(e.viewport),r=new Map;if(e.annotations)for(let s of e.annotations){let i=Hd(s.id);r.set(i,{id:i,elementId:s.elementId===null?null:Qe(s.elementId),position:s.position,resolved:s.resolved,thread:s.thread.map(l=>({id:Tl(l.id),authorId:l.authorId,authorName:l.authorName,body:l.body,createdAt:l.createdAt})),createdAt:s.createdAt})}return{elements:t,links:n,layers:o,annotations:r,files:new Map,viewport:a}},Vq=(e,t)=>({...Ud(e),id:t,layerId:$t(e.layerId),order:e.order}),Zq=(e,t)=>{let n=s=>s.kind==="anchor"||s.kind==="outline"||s.kind==="floating"?{...s,elementId:Qe(s.elementId)}:s,o=n(e.from),a=n(e.to);return{...Ud(e),id:t,layerId:$t(e.layerId),order:e.order,from:o,to:a}};var Ec=F(ye(),1),Fa=F(he(),1);var Xq=[0,50,90],Vv=({children:e,snapPoints:t=Xq,value:n,defaultValue:o,onChange:a,className:r,style:s})=>{let[i,l]=(0,Fa.useState)(()=>o??t.find(b=>b>0)??50),c=n??i,u=(0,Fa.useCallback)(b=>{l(b),a?.(b)},[a]),d=(0,Fa.useRef)(null),f=(0,Fa.useRef)(null),p=b=>{d.current={startY:b.clientY,startHeight:c,pointerId:b.pointerId},b.target.setPointerCapture?.(b.pointerId)},h=b=>{if(d.current?.pointerId!==b.pointerId)return;let y=window.innerHeight||1,g=(d.current.startY-b.clientY)/y*100,x=Il.clamp(d.current.startHeight+g,0,100);u(x)},m=b=>{if(d.current?.pointerId!==b.pointerId)return;d.current=null;let y=t[0];if(y===void 0)return;let g=Math.abs(c-y);for(let x of t){let A=Math.abs(c-x);A<g&&(y=x,g=A)}u(y)};return(0,Fa.useEffect)(()=>{let b=y=>{y.key==="Escape"&&u(Math.min(...t))};return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b)}},[u,t]),(0,Ec.jsxs)("div",{ref:f,role:"dialog","aria-label":"Bottom sheet",className:r,style:{position:"fixed",left:0,right:0,bottom:0,height:`${c}vh`,background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",borderTop:"1px solid var(--border, #2a2a2a)",borderTopLeftRadius:12,borderTopRightRadius:12,boxShadow:"0 -4px 18px rgba(0,0,0,0.4)",display:"flex",flexDirection:"column",overflow:"hidden",transition:d.current?"none":"height 180ms ease",zIndex:100,...s},children:[(0,Ec.jsx)("div",{role:"separator","aria-orientation":"horizontal",onPointerDown:p,onPointerMove:h,onPointerUp:m,onPointerCancel:m,style:{touchAction:"none",padding:"8px 0",display:"flex",justifyContent:"center",cursor:"grab"},children:(0,Ec.jsx)("span",{"aria-hidden":!0,style:{display:"block",width:36,height:4,borderRadius:2,background:"var(--text, #ddd)",opacity:.4}})}),(0,Ec.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"0 12px 12px"},children:e})]})};var b6=F(ye(),1),Ha=F(he(),1);var Zv=()=>{let e=j(),t=(0,Ha.useRef)(null),[,n]=(0,Ha.useReducer)(c=>c+1,0);(0,Ha.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingTextElement??null;if((0,Ha.useEffect)(()=>{o&&t.current?.focus()},[o]),(0,Ha.useLayoutEffect)(()=>{let c=t.current;if(!e||!o||!c)return;let u=M(e.scene,o),d=u?.type==="text"?u.text:"";c.value!==d&&(c.value=d);let f=e.editingTextSelection;f&&(c.selectionStart!==f.start||c.selectionEnd!==f.end)&&c.setSelectionRange(f.start,f.end,f.dir)}),!e||!o)return null;let a=M(e.scene,o);if(a?.type!=="text")return null;let r=e.scene.viewport,s=(a.position.x-r.pan.x)*r.zoom,i=(a.position.y-r.pan.y)*r.zoom,l=c=>c.selectionDirection==="backward"?"backward":"forward";return(0,b6.jsx)("textarea",{ref:t,defaultValue:a.text,onInput:c=>{let u=c.currentTarget;e.setEditingText(u.value,u.selectionStart,u.selectionEnd,l(u))},onSelect:c=>{let u=c.currentTarget;e.setEditingSelection(u.selectionStart,u.selectionEnd,l(u))},onKeyDown:c=>{(c.key==="Escape"||c.key==="Enter"&&(c.metaKey||c.ctrlKey))&&(c.preventDefault(),c.stopPropagation(),e.commitTextEdit())},onBlur:()=>{let c=o;setTimeout(()=>{let u=t.current;u&&e.editingTextElement===c&&document.activeElement!==u&&u.focus()},0)},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","aria-label":"Text editor",style:{position:"absolute",top:i,left:s,width:1,height:1,padding:0,margin:0,border:0,outline:"none",opacity:0,resize:"none",overflow:"hidden",whiteSpace:"pre",pointerEvents:"none",zIndex:100}})};var A6=F(ye(),1),Ti=F(he(),1);var Xv=()=>{let e=j(),t=(0,Ti.useRef)(null),[,n]=(0,Ti.useReducer)(d=>d+1,0);(0,Ti.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingFrameName??null;if((0,Ti.useEffect)(()=>{if(!o)return;let d=t.current;d&&(d.focus(),d.select())},[o]),!e||!o)return null;let a=M(e.scene,o);if(!a||!He(a))return null;let r=e.scene.viewport,s=r.zoom,i=(a.position.x-r.pan.x)*s,l=(a.position.y-24*a.scale.y-r.pan.y)*s,c=a.width*a.scale.x*s,u=24*a.scale.y*s;return(0,A6.jsx)("input",{ref:t,type:"text",defaultValue:a.name??"",placeholder:"Frame","aria-label":"Frame name",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onKeyDown:d=>{d.key==="Enter"?(d.preventDefault(),d.stopPropagation(),e.commitFrameNameEdit(d.currentTarget.value)):d.key==="Escape"?(d.preventDefault(),d.stopPropagation(),e.cancelFrameNameEdit()):d.stopPropagation()},onBlur:d=>{e.commitFrameNameEdit(d.currentTarget.value)},style:{position:"absolute",left:i,top:l,width:c,height:u,boxSizing:"border-box",padding:`0 ${8*s}px`,margin:0,border:0,outline:"none",background:"#222",color:"#ddd",font:`${12*s}px system-ui, sans-serif`,lineHeight:`${u}px`,pointerEvents:"auto",zIndex:100}},o)};var Mc=F(ye(),1),Zr=F(he(),1),S6=F(Yo(),1);var Vr=F(he(),1),v6=e=>{let t=(0,Vr.useRef)(null),n=(0,Vr.useRef)(e);n.current=e;let o=(0,Vr.useCallback)(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),a=(0,Vr.useCallback)(r=>{o(),t.current=setTimeout(()=>{t.current=null,n.current()},r)},[o]);return(0,Vr.useEffect)(()=>o,[o]),{schedule:a,cancel:o}};var L6=220,Yv=()=>{let e=j(),[t,n]=(0,Zr.useState)(null),[,o]=(0,Zr.useReducer)(m=>m+1,0),a=(0,Zr.useRef)(!1),r=Et(),{schedule:s,cancel:i}=v6(()=>{a.current||n(null)});if((0,Zr.useEffect)(()=>{if(!e)return;let m=e.hostElement;if(!m)return;let b=x=>{if(e.editingTextElement!==null){n(null);return}let A=m.getBoundingClientRect(),C=e.screenToWorld({x:x.clientX-A.left,y:x.clientY-A.top}),_=e.linkAt(C);_?(i(),n({href:_.href,bounds:_.bounds})):a.current||s(L6)},y=()=>{s(L6)};m.addEventListener("pointermove",b),m.addEventListener("pointerleave",y);let g=e.on("change",()=>{o()});return()=>{m.removeEventListener("pointermove",b),m.removeEventListener("pointerleave",y),g(),i()}},[e,s,i]),!e||!t)return null;let l=e.hostElement;if(!l)return null;let c=e.scene.viewport,u=l.getBoundingClientRect(),d=(t.bounds.x-c.pan.x)*c.zoom+u.left,f=(t.bounds.y-c.pan.y)*c.zoom+u.top,p=t.bounds.width*c.zoom,h=t.href.replace(/^mailto:/,"").replace(/^https?:\/\//,"");return(0,S6.createPortal)((0,Mc.jsx)("div",{className:"du-link-popup",style:{position:"fixed",left:d+p/2,top:f,transform:"translate(-50%, -100%)"},onPointerEnter:()=>{a.current=!0},onPointerLeave:()=>{a.current=!1,n(null)},children:(0,Mc.jsxs)("a",{className:"du-link-popup-url",href:t.href,title:t.href,onClick:m=>{m.preventDefault(),e.openLink(t.href)},children:[(0,Mc.jsx)("span",{className:"du-link-popup-text",children:h}),(0,Mc.jsx)(Ju,{size:13,strokeWidth:1.75,"aria-hidden":!0})]})}),r)};var Xr=F(ye(),1),gy=F(he(),1),k6=F(Yo(),1);var Kv=()=>{let e=j(),[,t]=(0,gy.useReducer)(u=>u+1,0),n=Et();if((0,gy.useEffect)(()=>{if(!e)return;let u=e.on("change",()=>{t()}),d=f=>{f.key==="Escape"&&e.linkDropMenu&&e.dismissLinkDropMenu()};return window.addEventListener("keydown",d),()=>{u(),window.removeEventListener("keydown",d)}},[e]),!e)return null;let o=e.linkDropMenu;if(!o)return null;let a=e.hostElement;if(!a)return null;let r=e.scene.viewport,s=a.getBoundingClientRect(),i=(o.world.x-r.pan.x)*r.zoom+s.left,l=(o.world.y-r.pan.y)*r.zoom+s.top,c=ai.byCategory("basic");return(0,k6.createPortal)((0,Xr.jsxs)(Xr.Fragment,{children:[(0,Xr.jsx)("div",{className:"du-link-drop-backdrop",style:{position:"fixed",inset:0,zIndex:1600},onPointerDown:()=>{e.dismissLinkDropMenu()}}),(0,Xr.jsx)("div",{className:"du-link-drop-menu",role:"menu","aria-label":"Create shape",style:{position:"fixed",left:i,top:l,transform:"translate(-50%, -100%)",zIndex:1601},onPointerDown:u=>{u.stopPropagation()},children:c.map(u=>(0,Xr.jsx)("button",{type:"button",className:"du-link-drop-item",title:u.name,"aria-label":`Create ${u.name}`,onClick:()=>{e.placeShapeAtLinkDrop(d=>u.factory(d))},dangerouslySetInnerHTML:{__html:u.icon}},u.id))})]}),n)};var w6=F(ye(),1),Ua=F(he(),1),_6=F(Yo(),1);var $v=()=>{let e=j(),[,t]=(0,Ua.useReducer)(h=>h+1,0),[n,o]=(0,Ua.useState)(""),a=(0,Ua.useRef)(null),r=Et();(0,Ua.useEffect)(()=>{if(e)return e.on("change",()=>{t()})},[e]);let s=e?.editingLinkCaption??null;if((0,Ua.useEffect)(()=>{if(!e||s===null)return;let h=e.scene.links.get(s);o(h?.label?.text??"");let m=setTimeout(()=>{a.current?.focus(),a.current?.select()},0);return()=>{clearTimeout(m)}},[e,s]),!e||s===null)return null;let i=e.hostElement;if(!i)return null;let l=e.linkLabelWorld(s);if(!l)return null;let c=e.scene.viewport,u=i.getBoundingClientRect(),d=(l.x-c.pan.x)*c.zoom+u.left,f=(l.y-c.pan.y)*c.zoom+u.top,p=()=>{e.commitLinkCaptionEdit(n)};return(0,_6.createPortal)((0,w6.jsx)("input",{ref:a,className:"du-link-caption-input",value:n,placeholder:"Label",style:{position:"fixed",left:d,top:f,transform:"translate(-50%, -50%)",zIndex:1602},onChange:h=>{o(h.target.value)},onBlur:p,onKeyDown:h=>{h.key==="Enter"?(h.preventDefault(),p()):h.key==="Escape"&&(h.preventDefault(),e.cancelLinkCaptionEdit()),h.stopPropagation()}}),r)};var mt=F(ye(),1),xy=F(he(),1);var Yq=16,Kq=1.75,Qv={size:Yq,strokeWidth:Kq},$q={"mode-select":gd,"mode-hand":id,"mode-rect":xa,"mode-ellipse":Ku,"mode-text":Id,"mode-edge":wd,"mode-brush":vr,"mode-frame":ad,"insert-image":Cs,"tool-lock":fd,undo:Es,redo:Is},Qq=({id:e})=>{let t=j(),[,n]=(0,xy.useState)(0);(0,xy.useEffect)(()=>{if(t)return t.on("change",()=>{n(d=>d+1)})},[t]);let o=st.get(e);if(!o)return null;let a=o.iconId?$q[o.iconId]:void 0,r=t?{editor:t}:null,s=r?o.checked?.(r)??!1:!1,i=r?o.predicate?o.predicate(r):!0:!1,c=(o.hotkey===void 0?[]:Array.isArray(o.hotkey)?o.hotkey:[o.hotkey])[0],u=`${o.label??e}${c?` (${Bt(c)})`:""}`;return(0,mt.jsx)(Oc,{title:u,active:s,disabled:!i,onClick:()=>{t&&st.dispatch(e,{editor:t})},children:a?(0,mt.jsx)(a,{...Qv}):o.label??e})},ffe=Bt({meta:!0,key:"\u2212"}),pfe=Bt({meta:!0,key:"+"}),hfe=Bt({meta:!0,key:"0"}),mfe=Bt({meta:!0,key:"1"}),Jv=e=>{if(typeof document>"u")return;let t=document.createElement("input");t.type="file",t.accept="image/*",t.multiple=!0,t.addEventListener("change",()=>{let n=t.files;if(!n||n.length===0)return;let o=e.scene.viewport,a=e.screenToWorld({x:o.size.width/2,y:o.size.height/2});for(let r of Array.from(n))e.dispatchFileDrop(r,a)}),t.click()},C6=[{kind:"action-ref",id:"mode-select"},{kind:"action-ref",id:"mode-hand"},{kind:"action-ref",id:"mode-rect"},{kind:"action-ref",id:"mode-ellipse"},{kind:"action-ref",id:"mode-text"},{kind:"action-ref",id:"mode-edge"},{kind:"action-ref",id:"mode-brush"},{kind:"action-ref",id:"mode-frame"},{kind:"action",id:"insert-image",label:(0,mt.jsx)(Cs,{...Qv}),title:"Insert image (I)",onClick:e=>{Jv(e)}},{kind:"action-ref",id:"toggle-tool-lock"},{kind:"divider"},{kind:"action-ref",id:"undo"},{kind:"action-ref",id:"redo"},{kind:"divider"}],by=[{kind:"action-ref",id:"mode-select"},{kind:"action-ref",id:"mode-hand"},{kind:"divider"},{kind:"action-ref",id:"mode-rect"},{kind:"action-ref",id:"mode-ellipse"},{kind:"action-ref",id:"mode-text"},{kind:"action-ref",id:"mode-edge"},{kind:"action-ref",id:"mode-brush"},{kind:"action-ref",id:"mode-frame"},{kind:"action",id:"insert-image",label:(0,mt.jsx)(Cs,{...Qv}),title:"Insert image (I)",onClick:e=>{Jv(e)}},{kind:"divider"},{kind:"action-ref",id:"toggle-tool-lock"}],eL=({items:e=C6,style:t,className:n,orientation:o="horizontal"})=>{let a=j(),r=QA(),{canUndo:s,canRedo:i,undo:l,redo:c}=JA(),u=o==="vertical";return(0,mt.jsx)("div",{role:"toolbar","aria-orientation":o,className:`du-button-group${u?" du-button-group-vertical":""} ${n??""}`.trim(),style:t,children:e.map((d,f)=>{switch(d.kind){case"divider":return(0,mt.jsx)(eW,{vertical:u},f);case"action-ref":return(0,mt.jsx)(Qq,{id:d.id},f);case"mode":{let p=r===d.mode;return(0,mt.jsx)(Oc,{...d.title!==void 0?{title:d.title}:{},disabled:!a,active:p,onClick:()=>a?.setMode(d.mode),children:d.label},f)}case"action":return(0,mt.jsx)(Oc,{...d.title!==void 0?{title:d.title}:{},disabled:d.disabled??!a,active:d.active,onClick:()=>{a&&d.onClick(a)},children:d.label},f);case"undo":return(0,mt.jsx)(Oc,{disabled:!s,onClick:l,children:d.label??"Undo"},f);case"redo":return(0,mt.jsx)(Oc,{disabled:!i,onClick:c,children:d.label??"Redo"},f);case"tool-lock":return(0,mt.jsx)(Jq,{...d.label!==void 0?{label:d.label}:{},...d.title!==void 0?{title:d.title}:{}},f)}})})},Jq=({label:e="\u{1F512}",title:t="Lock current tool"})=>{let n=j(),o=Aa(a=>a.toolLocked,!1);return(0,mt.jsx)(Oc,{disabled:!n,title:t,active:o,onClick:()=>n?.setToolLocked(!o),children:e})};var Oc=({children:e,onClick:t,active:n,disabled:o,title:a,className:r,style:s})=>{let i=(0,mt.jsx)("button",{type:"button",onClick:t,disabled:o,"aria-label":a,"aria-pressed":n,className:`du-icon-button${n?" is-active":""}${r?` ${r}`:""}`,style:{width:"auto",minWidth:"var(--du-button-size, 36px)",padding:"0 8px",...s},children:e});return a?(0,mt.jsx)(Ms,{content:a,children:i}):i},eW=({vertical:e=!1})=>e?(0,mt.jsx)("span",{style:{height:1,width:"100%",background:"var(--du-ui-border, #333)",margin:"4px 0"}}):(0,mt.jsx)("span",{style:{width:1,height:20,background:"var(--du-ui-border, #333)",margin:"0 4px"}});var tL=.5522847498307936,T6=.55;var tW={i:.28,l:.28,I:.34,t:.34,f:.36,j:.3,r:.4," ":.3,m:.86,w:.82,M:.86,W:.92},I6=(e,t,n)=>{let o=0;for(let a of e)o+=(tW[a]??T6)*n;return o};var Ay=class{size;measure;fillColor=null;strokeColor=null;strokeWidth=1;opacity=1;lineCap="butt";lineJoin="miter";dashArray=null;fontFamily="system-ui, sans-serif";fontSize=14;fontWeight="normal";fontStyle="normal";textAlign="left";textBaseline="top";currentTransform=B.IDENTITY;pathSegments=[];pathCursor=null;elements=[];stack=[];constructor(t){this.size={width:t.width,height:t.height},this.measure=t.measureText??I6}toSvg(){let t=this.size.width,n=this.size.height;return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${n}" viewBox="0 0 ${t} ${n}">`+this.elements.join("")+"</svg>"}setFill(t){this.fillColor=t}setStroke(t){this.strokeColor=t}setStrokeWidth(t){this.strokeWidth=t}setOpacity(t){this.opacity=t}setLineCap(t){this.lineCap=t}setLineJoin(t){this.lineJoin=t}setDashArray(t){this.dashArray=t}setFont(t,n,o){this.fontFamily=t,this.fontSize=n,this.fontWeight=o?.weight??"normal",this.fontStyle=o?.style??"normal"}setTextAlign(t){this.textAlign=t}setTextBaseline(t){this.textBaseline=t}save(){this.stack.push({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,opacity:this.opacity,lineCap:this.lineCap,lineJoin:this.lineJoin,dashArray:this.dashArray,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontStyle:this.fontStyle,textAlign:this.textAlign,textBaseline:this.textBaseline,transform:this.currentTransform})}restore(){let t=this.stack.pop();t&&(this.fillColor=t.fillColor,this.strokeColor=t.strokeColor,this.strokeWidth=t.strokeWidth,this.opacity=t.opacity,this.lineCap=t.lineCap,this.lineJoin=t.lineJoin,this.dashArray=t.dashArray,this.fontFamily=t.fontFamily,this.fontSize=t.fontSize,this.fontWeight=t.fontWeight,this.fontStyle=t.fontStyle,this.textAlign=t.textAlign,this.textBaseline=t.textBaseline,this.currentTransform=t.transform)}translate(t,n){this.currentTransform=B.multiply(this.currentTransform,B.translation(t,n))}rotate(t){this.currentTransform=B.multiply(this.currentTransform,B.rotation(t))}scale(t,n){this.currentTransform=B.multiply(this.currentTransform,B.scaling(t,n))}setTransform(t){this.currentTransform=t}resetTransform(){this.currentTransform=B.IDENTITY}beginPath(){this.pathSegments=[],this.pathCursor=null}closePath(){this.pathSegments.push("Z")}moveTo(t,n){let o=this.apply(t,n);this.pathSegments.push(`M${it(o.x)} ${it(o.y)}`),this.pathCursor=o}lineTo(t,n){let o=this.apply(t,n);this.pathSegments.push(`L${it(o.x)} ${it(o.y)}`),this.pathCursor=o}quadraticCurveTo(t,n,o,a){let r=this.apply(t,n),s=this.apply(o,a);this.pathSegments.push(`Q${it(r.x)} ${it(r.y)} ${it(s.x)} ${it(s.y)}`),this.pathCursor=s}bezierCurveTo(t,n,o,a,r,s){let i=this.apply(t,n),l=this.apply(o,a),c=this.apply(r,s);this.pathSegments.push(`C${it(i.x)} ${it(i.y)} ${it(l.x)} ${it(l.y)} ${it(c.x)} ${it(c.y)}`),this.pathCursor=c}rect(t,n,o,a){this.moveTo(t,n),this.lineTo(t+o,n),this.lineTo(t+o,n+a),this.lineTo(t,n+a),this.closePath()}ellipse(t,n,o,a){let r=o*tL,s=a*tL;this.moveTo(t+o,n),this.bezierCurveTo(t+o,n+s,t+r,n+a,t,n+a),this.bezierCurveTo(t-r,n+a,t-o,n+s,t-o,n),this.bezierCurveTo(t-o,n-s,t-r,n-a,t,n-a),this.bezierCurveTo(t+r,n-a,t+o,n-s,t+o,n),this.closePath()}fill(t="nonzero"){if(this.pathSegments.length===0)return;let o=[`d="${this.pathSegments.join(" ")}"`,`fill="${this.fillColor??"none"}"`,t==="evenodd"?'fill-rule="evenodd"':"",this.opacity!==1?`fill-opacity="${this.opacity}"`:""].filter(Boolean).join(" ");this.elements.push(`<path ${o}/>`)}stroke(){if(this.pathSegments.length===0||this.strokeColor===null||this.strokeWidth<=0)return;let t=this.pathSegments.join(" "),n=this.dashArray&&this.dashArray.length>0?`stroke-dasharray="${this.dashArray.join(" ")}"`:"",o=[`d="${t}"`,'fill="none"',`stroke="${this.strokeColor}"`,`stroke-width="${this.strokeWidth}"`,this.lineCap!=="butt"?`stroke-linecap="${this.lineCap}"`:"",this.lineJoin!=="miter"?`stroke-linejoin="${this.lineJoin}"`:"",n,this.opacity!==1?`stroke-opacity="${this.opacity}"`:""].filter(Boolean).join(" ");this.elements.push(`<path ${o}/>`)}fillText(t,n,o,a){if(!t)return;let r=this.apply(n,o),s=this.textAlign==="center"?"middle":this.textAlign==="right"?"end":"start",i=this.textBaseline==="middle"?"central":this.textBaseline==="bottom"?"alphabetic":"hanging",l=[`x="${it(r.x)}"`,`y="${it(r.y)}"`,`font-family="${E6(this.fontFamily)}"`,`font-size="${this.fontSize}"`,this.fontWeight==="bold"?'font-weight="bold"':"",this.fontStyle==="italic"?'font-style="italic"':"",`fill="${this.fillColor??"#000"}"`,`text-anchor="${s}"`,`dominant-baseline="${i}"`,this.opacity!==1?`fill-opacity="${this.opacity}"`:"",a!==void 0?`textLength="${a}" lengthAdjust="spacingAndGlyphs"`:""].filter(Boolean).join(" ");this.elements.push(`<text ${l}>${oW(t)}</text>`)}measureText(t){return{width:this.measure(t,this.fontFamily,this.fontSize)}}drawImage(t,n,o,a,r){if(typeof t!="string"||t==="")return;let s=this.apply(n,o);this.elements.push(`<image x="${it(s.x)}" y="${it(s.y)}" width="${a}" height="${r}" href="${E6(t)}"/>`)}clear(t){if(!t){this.elements.length=0;return}let n=this.apply(t.x,t.y),o=this.apply(t.x+t.width,t.y+t.height),a=Math.min(n.x,o.x),r=Math.min(n.y,o.y),s=Math.abs(o.x-n.x),i=Math.abs(o.y-n.y);this.elements.push(`<rect x="${it(a)}" y="${it(r)}" width="${s}" height="${i}" fill="#fff"/>`)}apply(t,n){return B.applyToPoint(this.currentTransform,{x:t,y:n})}},it=e=>Number.isInteger(e)?String(e):e.toFixed(3).replace(/\.?0+$/,""),E6=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),oW=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");var nL=(e,t={})=>{t.skipInstall||oc();let n=t.width??e.viewport.size.width,o=t.height??e.viewport.size.height,a=new Ay({width:n,height:o,...t.measureText?{measureText:t.measureText}:{}});return Js(e,a,t),No(e,a),a.toSvg()};var Yr=F(ye(),1),Zo=F(he(),1),M6=F(Yo(),1);var oL=({items:e,style:t,className:n})=>{let o=j(),a=ey(),r=Et(),[s,i]=(0,Zo.useState)(null),l=(0,Zo.useRef)(null);(0,Zo.useEffect)(()=>{if(a)return a.register(({screenPoint:p,worldPoint:h})=>{i({screenPoint:p,worldPoint:h})})},[a]),(0,Zo.useEffect)(()=>{if(o)return o.onLongPress(({screenPoint:p,worldPoint:h})=>{let m=o.hostElement.getBoundingClientRect();i({screenPoint:{x:p.x+m.left,y:p.y+m.top},worldPoint:h})})},[o]),(0,Zo.useEffect)(()=>{if(!s)return;let p=m=>{l.current?.contains(m.target)||i(null)},h=m=>{m.key==="Escape"&&i(null)};return window.addEventListener("pointerdown",p,!0),window.addEventListener("keydown",h),()=>{window.removeEventListener("pointerdown",p,!0),window.removeEventListener("keydown",h)}},[s]);let c=(0,Zo.useCallback)(()=>{i(null)},[]);if(!o||!s)return null;let u={worldPoint:s.worldPoint,screenPoint:s.screenPoint},d=e.filter(p=>p.kind==="divider"||p.visible?.(o,u)!==!1),f=rW(d);return f.length===0?null:(0,M6.createPortal)((0,Yr.jsx)("div",{ref:l,role:"menu",style:{position:"fixed",zIndex:1e3,top:s.screenPoint.y,left:s.screenPoint.x,background:"var(--menu-bg, var(--du-ui-bg-solid, #fff))",color:"var(--menu-text, var(--du-text, #1a1a1a))",border:"1px solid var(--menu-border, var(--du-ui-border, rgba(0,0,0,0.08)))",borderRadius:6,padding:"4px 0",minWidth:180,boxShadow:"var(--du-ui-shadow, 0 4px 16px rgba(0,0,0,0.18))",font:"13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",...t},className:n,children:f.map((p,h)=>p.kind==="divider"?(0,Yr.jsx)("hr",{style:{border:0,borderTop:"1px solid var(--menu-divider, var(--du-ui-border, rgba(0,0,0,0.08)))",margin:"4px 0"}},`d-${h}`):(0,Yr.jsx)(aW,{item:p,editor:o,ctx:u,onActivate:()=>{c(),p.onClick(o,u)}},p.id))}),r)},aW=({item:e,editor:t,ctx:n,onActivate:o})=>{let a=e.disabled?.(t,n)??!1;return(0,Yr.jsxs)("button",{type:"button",role:"menuitem",onClick:s=>{if(a){s.preventDefault();return}s.stopPropagation(),o()},disabled:a,style:{all:"unset",display:"flex",justifyContent:"space-between",padding:"6px 12px",cursor:a?"not-allowed":"pointer",opacity:a?.4:1,width:"100%",boxSizing:"border-box"},onMouseEnter:s=>{a||(s.currentTarget.style.background="var(--du-hover-overlay, rgba(0,0,0,0.05))")},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[(0,Yr.jsx)("span",{children:e.label}),e.shortcut?(0,Yr.jsx)("span",{style:{marginLeft:16,opacity:.6,fontSize:11},children:e.shortcut}):null]})},rW=e=>{let t=[];for(let n of e)n.kind==="divider"&&(t.length===0||t[t.length-1]?.kind==="divider")||t.push(n);for(;t.length>0&&t[t.length-1]?.kind==="divider";)t.pop();return t},aL=e=>{window.confirm("Clear the canvas? Every shape is removed and this can't be undone.")&&e.clear()},ke=(e,t)=>{let n=st.get(e),o=n?.predicate,r=(n?.hotkey?Array.isArray(n.hotkey)?n.hotkey:[n.hotkey]:[])[0],s=t?.visible??(o?i=>o({editor:i}):void 0);return{kind:"action",id:e,label:t?.label??n?.label??e,...r?{shortcut:Bt(r)}:{},...s?{visible:s}:{},onClick:i=>{st.dispatch(e,{editor:i})}}},rL=[{kind:"action",id:"annotation-open",label:"Open thread",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.setSelectedAnnotation(n)}},{kind:"action",id:"annotation-toggle-resolved",label:"Toggle resolved",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.toggleAnnotationResolved(n)}},{kind:"action",id:"annotation-delete",label:"Delete annotation",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.removeAnnotation(n)}},{kind:"divider"},ke("delete-selection",{label:"Delete"}),ke("duplicate-selection",{label:"Duplicate"}),ke("copy"),ke("cut"),ke("paste"),ke("copy-style",{label:"Copy style"}),ke("paste-style",{label:"Paste style"}),ke("select-all"),{kind:"divider"},ke("group-selection",{label:"Group"}),ke("ungroup-selection",{label:"Ungroup"}),ke("flip-horizontal",{label:"Flip horizontal"}),ke("flip-vertical",{label:"Flip vertical"}),ke("align-left",{label:"Align left"}),ke("align-h-center",{label:"Align horizontal centres"}),ke("align-right",{label:"Align right"}),ke("align-top",{label:"Align top"}),ke("align-v-center",{label:"Align vertical centres"}),ke("align-bottom",{label:"Align bottom"}),ke("distribute-horizontal",{label:"Distribute horizontally"}),ke("distribute-vertical",{label:"Distribute vertically"}),ke("arrange-grid"),ke("arrange-stack-h"),ke("arrange-stack-v"),ke("auto-arrange"),ke("compact-z-order"),{kind:"divider"},ke("bring-to-front",{visible:e=>e.selection.size===1}),ke("send-to-back",{visible:e=>e.selection.size===1}),{kind:"action",id:"move-to-layer",label:"Move to layer\u2026",visible:e=>e.selection.size>0&&e.scene.layers.size>1,onClick:e=>{if(typeof window>"u")return;let t=[...e.scene.layers.values()],n=t.map((s,i)=>`${i+1}. ${s.name}`).join(`
|
|
165
|
+
}`;var Dg=()=>typeof OffscreenCanvas>"u"||typeof HTMLCanvasElement>"u"?!1:typeof HTMLCanvasElement.prototype.transferControlToOffscreen=="function",pL=(e,t)=>{let n=new OffscreenCanvas(e,t),o=n.getContext("2d");if(!o)throw new Error("OffscreenCanvas 2D context unavailable");let a=new or(o,e,t);return{canvas:n,target:a}};var ar=(e,t,n,o=rr(),a=!0)=>{let r=Math.round(t*o),s=Math.round(n*o),i=`${t}px`,l=`${n}px`;if(e.width===r&&e.height===s&&e.style.width===i&&e.style.height===l)return o;if(e.width=r,e.height=s,e.style.width=i,e.style.height=l,a){let c=e.getContext("2d");if(!c)throw new Error("Failed to obtain 2D context");c.setTransform(o,0,0,o,0,0)}return o},rr=(e=2)=>Math.min(typeof window<"u"&&window.devicePixelRatio||1,e);var bh=class{host;layers;canvases;width;height;dprOverride;maxDpr;constructor(t,n,o,a={}){this.host=t,this.width=n,this.height=o,this.dprOverride=a.dpr,this.maxDpr=a.maxDpr??2,getComputedStyle(t).position==="static"&&(t.style.position="relative");let r=a.layers??wi,s=new Map,i=new Map;for(let l of wi){if(!r.includes(l))continue;let c=t.ownerDocument.createElement("canvas");c.dataset.layer=l,c.style.position="absolute",c.style.inset="0",c.style.pointerEvents=l==="overlay"?"auto":"none",t.appendChild(c);let u=ar(c,n,o,this.dprOverride??rr(this.maxDpr)),d=c.getContext("2d");if(!d)throw new Error("Failed to obtain 2D context");s.set(l,new or(d,n,o,u)),i.set(l,c)}this.layers=s,this.canvases=i}get(t){let n=this.layers.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}getCanvas(t){let n=this.canvases.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}resize(t,n){if(!(this.width===t&&this.height===n)){this.width=t,this.height=n;for(let[o,a]of this.canvases){let r=ar(a,t,n,this.dprOverride??rr(this.maxDpr)),s=this.layers.get(o);s!==void 0&&s.resize(t,n,r)}}}get size(){return{width:this.width,height:this.height}}dispose(){for(let t of this.canvases.values())t.remove()}};var mL=()=>new Worker(new URL("./render-worker.js",import.meta.url),{type:"module"});var DD=-2128831035,PD=522970236,IX=16777619,MX=2246822507,BD=-1640531527,RX=2147483647,OX=1431655765,zD=new Float64Array(1),ND=new Int32Array(zD.buffer),Pg=class{commands=[];_width;_height;skippedImageDraws=0;fontSpec="10px sans-serif";measureCtx=null;imageIds=new vp(64);nextImageId=0;sigA=DD;sigB=PD;cmdCount=0;_lastSignature="";constructor(t,n){this._width=t,this._height=n}get size(){return{width:this._width,height:this._height}}resize(t,n){this._width=t,this._height=n,this.emit({k:"resize",w:t,h:n})}emit(t){this.commands.push(t),this.cmdCount++,this.mixString(t.k);for(let n in t)n!=="k"&&this.mixValue(t[n])}mix32(t){let n=t|0;this.sigA=(Math.imul(this.sigA^n,IX)|0)^BD,this.sigB=Math.imul(this.sigB^n+BD,MX)|0}mixNumber(t){zD[0]=t,this.mix32(ND[0]??0),this.mix32(ND[1]??0)}mixString(t){for(let n=0;n<t.length;n++)this.mix32(t.charCodeAt(n));this.mix32(t.length^65536)}mixValue(t){if(t==null){this.mix32(RX);return}switch(typeof t){case"number":this.mixNumber(t);return;case"boolean":this.mix32(t?1:2);return;case"string":this.mixString(t);return;case"object":{if(Array.isArray(t)){for(let n of t)this.mixValue(n);this.mix32(t.length^OX);return}if(typeof ImageBitmap<"u"&&t instanceof ImageBitmap)return;for(let n in t)this.mixValue(t[n]);return}default:return}}get lastSignature(){return this._lastSignature}flush(){let t=this.commands;return this._lastSignature=`${this.cmdCount}:${(this.sigA>>>0).toString(36)}:${(this.sigB>>>0).toString(36)}`,this.commands=[],this.sigA=DD,this.sigB=PD,this.cmdCount=0,t}peek(){return this.commands}setFill(t){this.emit({k:"setFill",color:t})}setStroke(t){this.emit({k:"setStroke",color:t})}setStrokeWidth(t){this.emit({k:"setStrokeWidth",w:t})}setOpacity(t){this.emit({k:"setOpacity",a:t})}setLineCap(t){this.emit({k:"setLineCap",cap:t})}setLineJoin(t){this.emit({k:"setLineJoin",join:t})}setDashArray(t){this.emit({k:"setDashArray",dash:t})}setFont(t,n,o){this.emit({k:"setFont",family:t,size:n,...o?{options:o}:{}});let a=o?.style==="italic"?"italic ":"",r=o?.weight==="bold"?"bold ":"";this.fontSpec=`${a}${r}${n}px "${ru(t)}", ${t}`}setTextAlign(t){this.emit({k:"setTextAlign",align:t})}setTextBaseline(t){this.emit({k:"setTextBaseline",baseline:t})}save(){this.emit({k:"save"})}restore(){this.emit({k:"restore"})}translate(t,n){this.emit({k:"translate",x:t,y:n})}rotate(t){this.emit({k:"rotate",r:t})}scale(t,n){this.emit({k:"scale",sx:t,sy:n})}setTransform(t){this.emit({k:"setTransform",t})}resetTransform(){this.emit({k:"resetTransform"})}beginPath(){this.emit({k:"beginPath"})}closePath(){this.emit({k:"closePath"})}moveTo(t,n){this.emit({k:"moveTo",x:t,y:n})}lineTo(t,n){this.emit({k:"lineTo",x:t,y:n})}quadraticCurveTo(t,n,o,a){this.emit({k:"quadraticCurveTo",cx:t,cy:n,x:o,y:a})}bezierCurveTo(t,n,o,a,r,s){this.emit({k:"bezierCurveTo",c1x:t,c1y:n,c2x:o,c2y:a,x:r,y:s})}rect(t,n,o,a){this.emit({k:"rect",x:t,y:n,w:o,h:a})}ellipse(t,n,o,a){this.emit({k:"ellipse",cx:t,cy:n,rx:o,ry:a})}fill(t){this.emit(t!==void 0?{k:"fill",rule:t}:{k:"fill"})}stroke(){this.emit({k:"stroke"})}fillText(t,n,o,a){this.emit(a!==void 0?{k:"fillText",text:t,x:n,y:o,maxWidth:a}:{k:"fillText",text:t,x:n,y:o})}measureText(t){let n=this.ensureMeasureCtx();return n?(n.font=this.fontSpec,{width:n.measureText(t).width}):{width:t.length*(Number.parseFloat(this.fontSpec)||8)*.5}}ensureMeasureCtx(){if(this.measureCtx)return this.measureCtx;if(typeof OffscreenCanvas>"u")return null;let t=new OffscreenCanvas(1,1).getContext("2d");return this.measureCtx=t??null,this.measureCtx}drawImage(t,n,o,a,r,s){if(typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let i=this.imageIds.get(t);i===void 0&&(i=this.nextImageId++,this.imageIds.set(t,i),this.emit({k:"defineImage",id:i,bitmap:t})),this.emit({k:"drawImage",id:i,dx:n,dy:o,dw:a,dh:r})}else this.skippedImageDraws++}clear(t){this.emit(t!==void 0?{k:"clear",bounds:t}:{k:"clear"})}markDirty(t){this.emit({k:"markDirty",bounds:t})}};var yL=(e,t,n,o={})=>{let a=o.backend??"canvas2d",r=o.maxDpr??2;switch(a){case"canvas2d":return new gL(e,t,n,r);case"webgl2":return new xL(e,t,n,r,{...o.preserveDrawingBuffer!==void 0?{preserveDrawingBuffer:o.preserveDrawingBuffer}:{}});case"offscreen":if(!o.workerFactory)throw new Error("createLayeredSurface: workerFactory is required for the offscreen backend");return new bL(e,t,n,o.workerFactory,o.onWorkerError,r)}},AL=(e,t,n,o={},a)=>{let r=o.backend??"canvas2d";try{return{surface:yL(e,t,n,o),effectiveBackend:r}}catch(s){if(r==="canvas2d")throw s;return a?.(r,s),{surface:yL(e,t,n,{...o,backend:"canvas2d"}),effectiveBackend:"canvas2d"}}},gL=class{backend="canvas2d";inner;constructor(t,n,o,a){this.inner=new bh(t,n,o,{maxDpr:a})}get(t){return this.inner.get(t)}getCanvas(t){return this.inner.getCanvas(t)}resize(t,n){this.inner.resize(t,n)}get size(){return this.inner.size}present(){}dispose(){this.inner.dispose()}},xL=class{backend="webgl2";base;mainCanvas;mainTarget;_width;_height;maxDpr;constructor(t,n,o,a,r={}){this._width=n,this._height=o,this.maxDpr=a,this.base=new bh(t,n,o,{layers:wi.filter(l=>l!=="main"),maxDpr:a});let s=this.base.getCanvas("overlay"),i=t.ownerDocument.createElement("canvas");i.dataset.layer="main",i.dataset.backend="webgl2",i.style.position="absolute",i.style.inset="0",i.style.pointerEvents="none",t.insertBefore(i,s),ar(i,n,o,rr(a),!1);try{this.mainCanvas=i,this.mainTarget=new Og(i,n,o,{...r.preserveDrawingBuffer!==void 0?{preserveDrawingBuffer:r.preserveDrawingBuffer}:{}})}catch(l){throw i.remove(),this.base.dispose(),l}}get(t){return t==="main"?this.mainTarget:this.base.get(t)}getCanvas(t){return t==="main"?this.mainCanvas:this.base.getCanvas(t)}resize(t,n){this._width===t&&this._height===n||(this._width=t,this._height=n,this.base.resize(t,n),ar(this.mainCanvas,t,n,rr(this.maxDpr),!1),this.mainTarget.resize(t,n))}get size(){return{width:this._width,height:this._height}}present(){this.mainTarget.flushBatch()}dispose(){this.mainTarget.dispose(),this.mainCanvas.remove(),this.base.dispose()}},bL=class{backend="offscreen";canvases=new Map;targets=new Map;workers=new Map;lastSentSig=new Map;_width;_height;dpr;constructor(t,n,o,a,r,s=2){this._width=n,this._height=o,this.dpr=rr(s),getComputedStyle(t).position==="static"&&(t.style.position="relative");let i=!1,l=c=>{i||(i=!0,r?.(c))};try{for(let c of wi){let u=t.ownerDocument.createElement("canvas");u.dataset.layer=c,u.dataset.backend="offscreen",u.style.position="absolute",u.style.inset="0",u.style.pointerEvents=c==="overlay"?"auto":"none",u.style.width=`${n}px`,u.style.height=`${o}px`,t.appendChild(u);let d=a();d.onerror=p=>{l(p)};let f=u.transferControlToOffscreen();d.postMessage({type:"init",canvas:f,width:n,height:o,dpr:this.dpr},[f]),this.canvases.set(c,u),this.workers.set(c,d),this.targets.set(c,new Pg(n,o))}}catch(c){throw this.dispose(),c}}get(t){let n=this.targets.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}getCanvas(t){let n=this.canvases.get(t);if(!n)throw new Error(`Layer not created: ${t}`);return n}resize(t,n){if(!(this._width===t&&this._height===n)){this._width=t,this._height=n;for(let[o,a]of this.canvases)a.style.width=`${t}px`,a.style.height=`${n}px`,this.targets.get(o)?.resize(t,n),this.workers.get(o)?.postMessage({type:"resize",width:t,height:n});this.lastSentSig.clear()}}get size(){return{width:this._width,height:this._height}}present(){for(let[t,n]of this.targets){let o=n.flush();if(o.length===0)continue;let a=n.lastSignature;this.lastSentSig.get(t)!==a&&(this.lastSentSig.set(t,a),this.workers.get(t)?.postMessage({type:"replay",commands:o}))}}dispose(){for(let t of this.workers.values())t.terminate();for(let t of this.canvases.values())t.remove();this.workers.clear(),this.canvases.clear(),this.targets.clear()}};var vL=async()=>{if(typeof navigator>"u")return!1;let e=navigator.gpu;if(!e)return!1;try{return await e.requestAdapter()!==null}catch{return!1}},SL=()=>{if(typeof document>"u")return!1;try{let t=document.createElement("canvas").getContext("webgl2");return t?(t.getExtension?.("WEBGL_lose_context")?.loseContext(),!0):!1}catch{return!1}};var FD=(0,Le.createContext)(null),LL=({initialScene:e,initialMode:t,children:n,onReady:o,skipInstallRenderers:a,renderer:r="canvas2d",workerFactory:s,textShaper:i,rasterizer:l,readOnly:c=!1})=>{let[u,d]=(0,Le.useState)(null),f=(0,Le.useRef)(null),p=(0,Le.useRef)(null),h=(0,Le.useRef)(null),m=(0,Le.useRef)(null),x=(0,Le.useRef)(null),y=(0,Le.useRef)(!1),g=(0,Le.useRef)(()=>{}),b=(0,Le.useRef)(r),A=(0,Le.useRef)(s),_=(0,Le.useRef)(i),T=(0,Le.useRef)(l),w=(0,Le.useRef)(c);b.current=r,A.current=s,_.current=i,T.current=l,w.current=c;let S=(0,Le.useCallback)(W=>{a||Dc();let{width:ie,height:ne}=W.getBoundingClientRect(),{surface:j,effectiveBackend:ve}=AL(W,ie,ne,{backend:y.current?"canvas2d":b.current,...A.current?{workerFactory:A.current}:{},onWorkerError:Oe=>{g.current(Oe)}},(Oe,qt)=>{console.warn(`[DiagramRoot] ${Oe} renderer unavailable, falling back to canvas2d:`,qt)});W.dataset.effectiveBackend=ve;let ye={host:W,mainTarget:j.get("main"),overlayTarget:j.get("overlay"),backgroundTarget:j.get("background"),onAfterRender:()=>p.current?.present(),initialScene:e,...t!==void 0?{initialMode:t}:{},..._.current?{textShaper:_.current}:{},...T.current?{rasterizer:T.current}:{}},ee=new Gp(ye);ee.setViewportSize(ie,ne),ee.setReadOnly(w.current),p.current=j,f.current=ee,d(ee),o?.(ee),j.present();let Se=new ResizeObserver(()=>{let Oe=W.getBoundingClientRect();j.resize(Oe.width,Oe.height),ee.setViewportSize(Oe.width,Oe.height),ee.forceRender()});Se.observe(W),h.current=Se},[]),L=(0,Le.useCallback)(()=>{h.current?.disconnect(),h.current=null,x.current?.(),x.current=null,f.current?.dispose(),f.current=null,p.current?.dispose(),p.current=null},[]);g.current=W=>{if(y.current)return;y.current=!0,console.warn("[DiagramRoot] offscreen render worker failed to load; falling back to canvas2d:",W);let ie=m.current;ie&&(L(),S(ie))};let M=(0,Le.useCallback)(W=>{if(L(),m.current=W,!W){d(null);return}S(W)},[S,L]),B=(0,Le.useRef)(null);return(0,Le.useEffect)(()=>{let W=m.current;if(W){if(B.current===null){B.current=r;return}B.current!==r&&(B.current=r,y.current=!1,L(),S(W))}},[r,S,L]),(0,Le.useEffect)(()=>{u?.setReadOnly(c)},[u,c]),(0,Le.useLayoutEffect)(()=>()=>{L(),m.current=null},[L]),(0,ys.jsx)(gE.Provider,{value:u,children:(0,ys.jsx)(FD.Provider,{value:M,children:(0,ys.jsxs)(Y8,{children:[n,(0,ys.jsx)(DX,{editor:u})]})})})},DX=({editor:e})=>{let[t,n]=(0,Le.useState)("");return(0,Le.useEffect)(()=>{if(e)return e.onAnnounce(n)},[e]),(0,ys.jsx)("div",{role:"status","aria-live":"polite","aria-atomic":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0},children:t})},kL=({style:e,className:t,ariaLabel:n})=>{let o=(0,Le.useContext)(FD),a=(0,Le.useRef)(null);if((0,Le.useLayoutEffect)(()=>{if(o)return o(a.current),()=>{o(null)}},[o]),!o)throw new Error("@oh-just-another/react-ui: <DiagramSurface> rendered outside <DiagramRoot>.");return(0,ys.jsx)("div",{ref:a,className:t?`du-canvas-surface ${t}`:"du-canvas-surface",role:"application",tabIndex:0,"aria-label":n??"Diagram canvas",style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",touchAction:"none",userSelect:"none",...e}})};var HD=P(se(),1),gn=P(re(),1);var PX=e=>{let t=null;for(let n of e.elements.values()){if(n.hidden===!0)continue;let o=z(n);t=t?V.union(t,o):o}return t},BX=(e,t,n)=>{let o=t-Fb*2,a=n-Fb*2;if(o<=0||a<=0||e.width<=0||e.height<=0)return null;let r=Math.min(o/e.width,a/e.height),s=e.x+e.width/2,i=e.y+e.height/2;return{zoom:r,pan:{x:s-t/2/r,y:i-n/2/r}}},wL=({width:e=LE,height:t=kE,className:n,style:o,editor:a})=>{let r=G(),s=a??r,i=(0,gn.useRef)(null),l=(0,gn.useRef)(null),c=(0,gn.useRef)(!1),u=(0,gn.useCallback)(()=>{let y=i.current;if(!y||!s)return;let g=s.scene,b=ar(y,e,t),A=y.getContext("2d");if(!A)return;let _=new or(A,e,t,b);_.clear();let T=PX(g),w=T?BX(T,e,t):null;if(l.current=w,!w)return;let S={...g,viewport:{...g.viewport,pan:w.pan,zoom:w.zoom,rotation:0,size:{width:e,height:t}}};Za(S,_),Pn(S,_);let L=g.viewport;if(L.zoom>0&&L.size.width>0&&L.size.height>0){let M=(L.pan.x-w.pan.x)*w.zoom,B=(L.pan.y-w.pan.y)*w.zoom,W=L.size.width/L.zoom*w.zoom,ie=L.size.height/L.zoom*w.zoom;A.setTransform(b,0,0,b,0,0),A.fillStyle=CE,A.fillRect(M,B,W,ie),A.strokeStyle=wE,A.lineWidth=_E,A.strokeRect(M,B,W,ie)}},[s,e,t]);(0,gn.useEffect)(()=>{if(!s)return;u();let y=Date.now(),g=null,b=()=>{let _=Date.now()-y;_>=Hb?(y=Date.now(),u()):g??=setTimeout(()=>{g=null,y=Date.now(),u()},Hb-_)},A=s.subscribe(b);return()=>{A(),g!==null&&clearTimeout(g)}},[s,u]);let d=(0,gn.useCallback)((y,g)=>{let b=l.current;if(!s||!b)return;let A={x:y/b.zoom+b.pan.x,y:g/b.zoom+b.pan.y},_=s.scene.viewport,T=_.pan.x+_.size.width/2/_.zoom,w=_.pan.y+_.size.height/2/_.zoom;s.panBy({x:(T-A.x)*_.zoom,y:(w-A.y)*_.zoom})},[s]),f=(0,gn.useCallback)((y,g,b)=>{let A=l.current;if(!s||!A||b===0)return;let _={x:y/A.zoom+A.pan.x,y:g/A.zoom+A.pan.y},w=1-(Math.abs(b)>Ub?Ub*Math.sign(b):b)*EE/100;if(w<=0)return;let S=s.scene.viewport,L=S.pan.x+S.size.width/2/S.zoom,M=S.pan.y+S.size.height/2/S.zoom;s.panBy({x:(L-_.x)*S.zoom,y:(M-_.y)*S.zoom}),s.zoomAt(w,_)},[s]);(0,gn.useEffect)(()=>{let y=i.current;if(!y)return;let g=b=>{b.preventDefault();let A=y.getBoundingClientRect();f(b.clientX-A.left,b.clientY-A.top,b.deltaY)};return y.addEventListener("wheel",g,{passive:!1}),()=>{y.removeEventListener("wheel",g)}},[f]);let p=y=>{let g=y.currentTarget.getBoundingClientRect();return{x:y.clientX-g.left,y:y.clientY-g.top}},h=(0,gn.useCallback)(y=>{c.current=!0,y.currentTarget.setPointerCapture(y.pointerId);let g=p(y);d(g.x,g.y)},[d]),m=(0,gn.useCallback)(y=>{if(!c.current)return;let g=p(y);d(g.x,g.y)},[d]),x=(0,gn.useCallback)(y=>{c.current=!1,y.currentTarget.releasePointerCapture(y.pointerId)},[]);return(0,HD.jsx)("canvas",{ref:i,className:n,"aria-label":"Diagram minimap",onPointerDown:h,onPointerMove:m,onPointerUp:x,style:{display:"block",width:e,height:t,cursor:"pointer",touchAction:"none",...o}})};var zt=P(se(),1),zge=P(re(),1);var _L=({style:e})=>{let t=G(),n=Vp(),o=BS();if(!t||n!=="brush"&&n!=="erase")return null;let a=n==="erase";return(0,zt.jsxs)("div",{className:"du-drawing-panel",style:{...NX,...e},children:[(0,zt.jsx)("div",{style:zX,children:a?"Eraser":"Drawing"}),!a&&(0,zt.jsxs)(zt.Fragment,{children:[(0,zt.jsx)(Bg,{label:"Stroke",children:(0,zt.jsx)(tu,{value:o.stroke,onChange:r=>{t.setBrushSettings({stroke:r??o.stroke})},onEyedrop:r=>{t.beginEyedropperPick(r)},allowClear:!1})}),(0,zt.jsx)(Bg,{label:"Fill",children:(0,zt.jsx)(tu,{value:o.fill,onChange:r=>{t.setBrushSettings({fill:r})},onEyedrop:r=>{t.beginEyedropperPick(r)}})}),(0,zt.jsx)(Bg,{label:`Opacity ${Math.round(o.opacity*100)}%`,children:(0,zt.jsx)("input",{type:"range",min:0,max:1,step:.05,value:o.opacity,onChange:r=>{t.setBrushSettings({opacity:r.currentTarget.valueAsNumber})},style:UD,"aria-label":"Brush opacity"})})]}),(0,zt.jsx)(Bg,{label:`${a?"Radius":"Width"} ${o.width}`,children:(0,zt.jsx)("input",{type:"range",min:IE,max:ME,step:1,value:o.width,onChange:r=>{t.setBrushSettings({width:r.currentTarget.valueAsNumber})},style:UD,"aria-label":a?"Eraser radius":"Brush width"})})]})},Bg=({label:e,children:t})=>(0,zt.jsxs)("label",{style:FX,children:[(0,zt.jsx)("span",{style:HX,children:e}),t]}),NX={width:TE,display:"flex",flexDirection:"column",gap:8,padding:10,border:"1px solid var(--du-border, #d0d0d0)",borderRadius:8,background:"var(--du-surface, #fff)",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",font:"12px/1.4 system-ui, sans-serif",color:"var(--du-text, #222)"},zX={fontWeight:600,opacity:.7},FX={display:"flex",flexDirection:"column",gap:4},HX={opacity:.7},UD={width:"100%"};var lu=2,Ft=C.object({x:C.number(),y:C.number()}),qge=C.object({x:C.number(),y:C.number(),width:C.number(),height:C.number()}),UX=C.object({type:C.enum(["sharp","round"]),value:C.number().optional()}).strict(),Ro=C.object({fill:C.string().optional(),stroke:C.string().optional(),strokeWidth:C.number().optional(),opacity:C.number().optional(),dashArray:C.array(C.number()).readonly().optional(),lineCap:C.enum(["butt","round","square"]).optional(),lineJoin:C.enum(["miter","round","bevel"]).optional(),strokeAlign:C.enum(["center","inside","outside"]).optional(),roundness:UX.optional()}).strict(),qD=Ro.extend({textAlign:C.enum(["left","center","right"]).optional(),textBaseline:C.enum(["top","middle","bottom"]).optional(),fontWeight:C.enum(["normal","bold"]).optional(),fontStyle:C.enum(["normal","italic"]).optional(),textDecoration:C.object({underline:C.boolean().optional(),strikethrough:C.boolean().optional()}).strict().optional()}).strict(),jD=C.record(C.string(),C.unknown()).optional(),GX=C.string(),VD=C.discriminatedUnion("kind",[C.object({kind:C.literal("named"),name:GX}).strict(),C.object({kind:C.literal("ratio"),position:Ft}).strict(),C.object({kind:C.literal("absolute"),offset:Ft}).strict(),C.object({kind:C.literal("edge"),index:C.number().int().nonnegative(),t:C.number()}).strict()]),da=C.object({id:C.string(),layerId:C.string(),position:Ft,rotation:C.number(),scale:Ft,order:C.string(),metadata:jD,minWidth:C.number().optional(),minHeight:C.number().optional(),maxWidth:C.number().optional(),maxHeight:C.number().optional(),noFlip:C.boolean().optional(),anchors:C.record(C.string(),VD).optional(),parentId:C.string().optional(),frameId:C.string().optional(),href:C.string().optional()}),WX=da.extend({type:C.literal("rectangle"),style:Ro,width:C.number(),height:C.number()}).strict(),qX=da.extend({type:C.literal("ellipse"),style:Ro,width:C.number(),height:C.number()}).strict(),jX=da.extend({type:C.literal("polygon"),style:Ro,points:C.array(Ft)}).strict(),VX=C.discriminatedUnion("kind",[C.object({kind:C.literal("M"),to:Ft}).strict(),C.object({kind:C.literal("L"),to:Ft}).strict(),C.object({kind:C.literal("Q"),control:Ft,to:Ft}).strict(),C.object({kind:C.literal("C"),control1:Ft,control2:Ft,to:Ft}).strict(),C.object({kind:C.literal("Z")}).strict()]),ZX=da.extend({type:C.literal("path"),style:Ro,commands:C.array(VX)}).strict(),XX=C.object({text:C.string(),style:qD.optional()}).strict(),YX=da.extend({type:C.literal("text"),style:qD,text:C.string(),fontFamily:C.string(),fontSize:C.number(),maxWidth:C.number().optional(),runs:C.array(XX).optional()}).strict(),KX=da.extend({type:C.literal("image"),style:Ro,src:C.string(),width:C.number(),height:C.number(),fileId:C.string().optional(),crop:C.object({x:C.number(),y:C.number(),width:C.number(),height:C.number()}).optional(),animationKind:C.string().optional(),animationData:C.unknown().optional()}).strict(),$X=da.extend({type:C.literal("template"),style:Ro.optional(),templateId:C.string(),data:C.record(C.string(),C.unknown()),width:C.number(),height:C.number()}).strict(),QX=da.extend({type:C.literal("group"),style:Ro.optional()}).strict(),JX=C.object({x:C.number(),y:C.number(),width:C.number()}).strict(),eY=da.extend({type:C.literal("brush"),style:Ro,points:C.array(JX),closed:C.boolean().optional()}).strict(),tY=da.extend({type:C.string(),style:Ro.optional()}).passthrough().refine(e=>!["rectangle","ellipse","polygon","path","text","image","template","group","brush"].includes(e.type),{message:"Use the specific built-in schema for built-in shape types"}),nY=C.union([WX,qX,jX,ZX,YX,KX,$X,QX,eY,tY]),GD=C.discriminatedUnion("kind",[C.object({kind:C.literal("point"),position:Ft}).strict(),C.object({kind:C.literal("anchor"),elementId:C.string(),anchor:VD}).strict(),C.object({kind:C.literal("outline"),elementId:C.string(),ratio:C.number()}).strict(),C.object({kind:C.literal("floating"),elementId:C.string()}).strict()]),oY=C.enum(["straight","orthogonal","bezier"]),WD=C.enum(["none","arrow","openArrow","roundedArrow","arcArrow","triangle","filledArrow","circle","filledCircle","diamond","rhombus","filledRhombus","erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"]),aY=C.object({from:WD.optional(),to:WD.optional(),size:C.number().optional()}).strict(),rY=C.object({text:C.string(),position:C.number().optional(),fontSize:C.number().optional(),fill:C.string().optional(),background:C.string().optional()}).strict(),sY=C.object({id:C.string(),layerId:C.string(),from:GD,to:GD,waypoints:C.array(Ft).readonly().optional(),routedPoints:C.array(Ft).readonly().optional(),fixedSegments:C.array(C.object({axis:C.enum(["h","v"]),pos:C.number(),at:C.number()}).strict()).readonly().optional(),routing:oY.optional(),avoidObstacles:C.boolean().optional(),arrowheads:aY.optional(),label:rY.optional(),order:C.string(),style:Ro,metadata:jD}).strict(),iY=C.object({id:C.string(),name:C.string(),visible:C.boolean(),locked:C.boolean(),order:C.string()}).strict(),lY=C.object({pan:Ft,zoom:C.number(),rotation:C.number(),size:C.object({width:C.number(),height:C.number()}).strict(),gridEnabled:C.boolean(),gridStyle:C.enum(["lines","dots"]).optional(),snapToGrid:C.boolean().optional()}).strict(),cY=C.object({id:C.string(),authorId:C.string(),authorName:C.string(),body:C.string(),createdAt:C.string()}).strict(),uY=C.object({id:C.string(),elementId:C.string().nullable(),position:Ft,resolved:C.boolean(),thread:C.array(cY),createdAt:C.string()}).strict(),ZD=C.object({format:C.literal("oh-just-another/scene"),version:C.number().int().nonnegative(),elements:C.array(nY),links:C.array(sY),layers:C.array(iY),annotations:C.array(uY).optional(),viewport:lY}).strict();var XD=e=>{let t=e.annotations.size>0?[...e.annotations.values()]:void 0,n={format:"oh-just-another/scene",version:lu,elements:[...e.elements.values()].map(dY),links:[...e.links.values()],layers:[...e.layers.values()],viewport:e.viewport};return t&&(n.annotations=t),n},dY=e=>{let t=e.metadata,n=t&&"image"in t,o=e.animationData!==void 0;if(!n&&!o)return e;let a={...e};if(n){let{image:r,...s}=t;Object.keys(s).length>0?a.metadata=s:delete a.metadata}return o&&delete a.animationData,a},CL=(e,t=null)=>JSON.stringify(XD(e),null,t??void 0);var YD=new Map,KD=(e,t)=>{YD.set(e,t)},$D=(e,t,n)=>{let o=e;for(let a=t;a<n;a++){let r=YD.get(a);if(!r)throw new EL(a,n);o=r(o)}return o},EL=class extends Error{fromVersion;toVersion;constructor(t,n){super(`No migration registered from v${t} \u2192 v${t+1} (target v${n})`),this.name="MissingMigrationError",this.fromVersion=t,this.toVersion=n}};var fY=e=>{let t=e,n={...t.viewport??{}},o=n.gridSize;return delete n.gridSize,n.gridEnabled=typeof o=="number"&&o>0,{...t,version:2,viewport:n}};KD(1,fY);var cu=class extends Error{reason;constructor(t,n){super(t),this.name="DeserializationError",this.reason=n}},QD=(e,t={})=>{if(typeof e!="object"||e===null)throw new cu("Expected an object",e);let n=e.version,o=typeof n=="number"?n:0,a=t.maxVersion??lu;if(o>a)throw new cu(`Document version ${o} is newer than this build understands (${a}). Upgrade your library.`,null);let r=o===lu?e:$D(e,o,lu),s;try{s=ZD.parse(r)}catch(i){throw i instanceof C.ZodError?new cu(`Invalid scene document: ${i.message}`,i):i}return pY(s)},TL=(e,t)=>QD(JSON.parse(e),t),pY=e=>{let t=new Map;for(let s of e.elements){let i=Ze(s.id);t.set(i,hY(s,i))}let n=new Map;for(let s of e.links){let i=Jb(s.id);n.set(i,mY(s,i))}let o=new Map;for(let s of e.layers){let i=ln(s.id);o.set(i,{id:i,name:s.name,visible:s.visible,locked:s.locked,order:s.order})}let a=Ef(e.viewport),r=new Map;if(e.annotations)for(let s of e.annotations){let i=Cf(s.id);r.set(i,{id:i,elementId:s.elementId===null?null:Ze(s.elementId),position:s.position,resolved:s.resolved,thread:s.thread.map(l=>({id:oc(l.id),authorId:l.authorId,authorName:l.authorName,body:l.body,createdAt:l.createdAt})),createdAt:s.createdAt})}return{elements:t,links:n,layers:o,annotations:r,files:new Map,viewport:a}},hY=(e,t)=>({...Ef(e),id:t,layerId:ln(e.layerId),order:e.order}),mY=(e,t)=>{let n=s=>s.kind==="anchor"||s.kind==="outline"||s.kind==="floating"?{...s,elementId:Ze(s.elementId)}:s,o=n(e.from),a=n(e.to);return{...Ef(e),id:t,layerId:ln(e.layerId),order:e.order,from:o,to:a}};var uu=P(se(),1),sr=P(re(),1);var yY=[0,50,90],IL=({children:e,snapPoints:t=yY,value:n,defaultValue:o,onChange:a,className:r,style:s})=>{let[i,l]=(0,sr.useState)(()=>o??t.find(x=>x>0)??50),c=n??i,u=(0,sr.useCallback)(x=>{l(x),a?.(x)},[a]),d=(0,sr.useRef)(null),f=(0,sr.useRef)(null),p=x=>{d.current={startY:x.clientY,startHeight:c,pointerId:x.pointerId},x.target.setPointerCapture?.(x.pointerId)},h=x=>{if(d.current?.pointerId!==x.pointerId)return;let y=window.innerHeight||1,g=(d.current.startY-x.clientY)/y*100,b=ac.clamp(d.current.startHeight+g,0,100);u(b)},m=x=>{if(d.current?.pointerId!==x.pointerId)return;d.current=null;let y=t[0];if(y===void 0)return;let g=Math.abs(c-y);for(let b of t){let A=Math.abs(c-b);A<g&&(y=b,g=A)}u(y)};return(0,sr.useEffect)(()=>{let x=y=>{y.key==="Escape"&&u(Math.min(...t))};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x)}},[u,t]),(0,uu.jsxs)("div",{ref:f,role:"dialog","aria-label":"Bottom sheet",className:r,style:{position:"fixed",left:0,right:0,bottom:0,height:`${c}vh`,background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",borderTop:"1px solid var(--border, #2a2a2a)",borderTopLeftRadius:12,borderTopRightRadius:12,boxShadow:"0 -4px 18px rgba(0,0,0,0.4)",display:"flex",flexDirection:"column",overflow:"hidden",transition:d.current?"none":"height 180ms ease",zIndex:100,...s},children:[(0,uu.jsx)("div",{role:"separator","aria-orientation":"horizontal",onPointerDown:p,onPointerMove:h,onPointerUp:m,onPointerCancel:m,style:{touchAction:"none",padding:"8px 0",display:"flex",justifyContent:"center",cursor:"grab"},children:(0,uu.jsx)("span",{"aria-hidden":!0,style:{display:"block",width:36,height:4,borderRadius:2,background:"var(--text, #ddd)",opacity:.4}})}),(0,uu.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"0 12px 12px"},children:e})]})};var JD=P(se(),1),ir=P(re(),1);var ML=()=>{let e=G(),t=(0,ir.useRef)(null),[,n]=(0,ir.useReducer)(c=>c+1,0);(0,ir.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingTextElement??null;if((0,ir.useEffect)(()=>{o&&t.current?.focus()},[o]),(0,ir.useLayoutEffect)(()=>{let c=t.current;if(!e||!o||!c)return;let u=I(e.scene,o),d=u?.type==="text"?u.text:"";c.value!==d&&(c.value=d);let f=e.editingTextSelection;f&&(c.selectionStart!==f.start||c.selectionEnd!==f.end)&&c.setSelectionRange(f.start,f.end,f.dir)}),!e||!o)return null;let a=I(e.scene,o);if(a?.type!=="text")return null;let r=e.scene.viewport,s=(a.position.x-r.pan.x)*r.zoom,i=(a.position.y-r.pan.y)*r.zoom,l=c=>c.selectionDirection==="backward"?"backward":"forward";return(0,JD.jsx)("textarea",{ref:t,defaultValue:a.text,onInput:c=>{let u=c.currentTarget;e.setEditingText(u.value,u.selectionStart,u.selectionEnd,l(u))},onSelect:c=>{let u=c.currentTarget;e.setEditingSelection(u.selectionStart,u.selectionEnd,l(u))},onKeyDown:c=>{(c.key==="Escape"||c.key==="Enter"&&(c.metaKey||c.ctrlKey))&&(c.preventDefault(),c.stopPropagation(),e.commitTextEdit())},onBlur:()=>{let c=o;setTimeout(()=>{let u=t.current;u&&e.editingTextElement===c&&document.activeElement!==u&&u.focus()},0)},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","aria-label":"Text editor",style:{position:"absolute",top:i,left:s,width:1,height:1,padding:0,margin:0,border:0,outline:"none",opacity:0,resize:"none",overflow:"hidden",whiteSpace:"pre",pointerEvents:"none",zIndex:100}})};var e6=P(se(),1),al=P(re(),1);var RL=()=>{let e=G(),t=(0,al.useRef)(null),[,n]=(0,al.useReducer)(d=>d+1,0);(0,al.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingFrameName??null;if((0,al.useEffect)(()=>{if(!o)return;let d=t.current;d&&(d.focus(),d.select())},[o]),!e||!o)return null;let a=I(e.scene,o);if(!a||!Be(a))return null;let r=e.scene.viewport,s=r.zoom,i=(a.position.x-r.pan.x)*s,l=(a.position.y-24*a.scale.y-r.pan.y)*s,c=a.width*a.scale.x*s,u=24*a.scale.y*s;return(0,e6.jsx)("input",{ref:t,type:"text",defaultValue:a.name??"",placeholder:"Frame","aria-label":"Frame name",spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",onKeyDown:d=>{d.key==="Enter"?(d.preventDefault(),d.stopPropagation(),e.commitFrameNameEdit(d.currentTarget.value)):d.key==="Escape"?(d.preventDefault(),d.stopPropagation(),e.cancelFrameNameEdit()):d.stopPropagation()},onBlur:d=>{e.commitFrameNameEdit(d.currentTarget.value)},style:{position:"absolute",left:i,top:l,width:c,height:u,boxSizing:"border-box",padding:`0 ${8*s}px`,margin:0,border:0,outline:"none",background:"#222",color:"#ddd",font:`${12*s}px system-ui, sans-serif`,lineHeight:`${u}px`,pointerEvents:"auto",zIndex:100}},o)};var du=P(se(),1),xs=P(re(),1),o6=P(ha(),1);var gs=P(re(),1),t6=e=>{let t=(0,gs.useRef)(null),n=(0,gs.useRef)(e);n.current=e;let o=(0,gs.useCallback)(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),a=(0,gs.useCallback)(r=>{o(),t.current=setTimeout(()=>{t.current=null,n.current()},r)},[o]);return(0,gs.useEffect)(()=>o,[o]),{schedule:a,cancel:o}};var n6=220,OL=()=>{let e=G(),[t,n]=(0,xs.useState)(null),[,o]=(0,xs.useReducer)(m=>m+1,0),a=(0,xs.useRef)(!1),r=Dt(),{schedule:s,cancel:i}=t6(()=>{a.current||n(null)});if((0,xs.useEffect)(()=>{if(!e)return;let m=e.hostElement;if(!m)return;let x=b=>{if(e.editingTextElement!==null){n(null);return}let A=m.getBoundingClientRect(),_=e.screenToWorld({x:b.clientX-A.left,y:b.clientY-A.top}),T=e.linkAt(_);T?(i(),n({href:T.href,bounds:T.bounds})):a.current||s(n6)},y=()=>{s(n6)};m.addEventListener("pointermove",x),m.addEventListener("pointerleave",y);let g=e.on("change",()=>{o()});return()=>{m.removeEventListener("pointermove",x),m.removeEventListener("pointerleave",y),g(),i()}},[e,s,i]),!e||!t)return null;let l=e.hostElement;if(!l)return null;let c=e.scene.viewport,u=l.getBoundingClientRect(),d=(t.bounds.x-c.pan.x)*c.zoom+u.left,f=(t.bounds.y-c.pan.y)*c.zoom+u.top,p=t.bounds.width*c.zoom,h=t.href.replace(/^mailto:/,"").replace(/^https?:\/\//,"");return(0,o6.createPortal)((0,du.jsx)("div",{className:"du-link-popup",style:{position:"fixed",left:d+p/2,top:f,transform:"translate(-50%, -100%)"},onPointerEnter:()=>{a.current=!0},onPointerLeave:()=>{a.current=!1,n(null)},children:(0,du.jsxs)("a",{className:"du-link-popup-url",href:t.href,title:t.href,onClick:m=>{m.preventDefault(),e.openLink(t.href)},children:[(0,du.jsx)("span",{className:"du-link-popup-text",children:h}),(0,du.jsx)(Nd,{size:13,strokeWidth:1.75,"aria-hidden":!0})]})}),r)};var bs=P(se(),1),Ng=P(re(),1),a6=P(ha(),1);var DL=()=>{let e=G(),[,t]=(0,Ng.useReducer)(u=>u+1,0),n=Dt();if((0,Ng.useEffect)(()=>{if(!e)return;let u=e.on("change",()=>{t()}),d=f=>{f.key==="Escape"&&e.linkDropMenu&&e.dismissLinkDropMenu()};return window.addEventListener("keydown",d),()=>{u(),window.removeEventListener("keydown",d)}},[e]),!e)return null;let o=e.linkDropMenu;if(!o)return null;let a=e.hostElement;if(!a)return null;let r=e.scene.viewport,s=a.getBoundingClientRect(),i=(o.world.x-r.pan.x)*r.zoom+s.left,l=(o.world.y-r.pan.y)*r.zoom+s.top,c=Oi.byCategory("basic");return(0,a6.createPortal)((0,bs.jsxs)(bs.Fragment,{children:[(0,bs.jsx)("div",{className:"du-link-drop-backdrop",style:{position:"fixed",inset:0,zIndex:1600},onPointerDown:()=>{e.dismissLinkDropMenu()}}),(0,bs.jsx)("div",{className:"du-link-drop-menu",role:"menu","aria-label":"Create shape",style:{position:"fixed",left:i,top:l,transform:"translate(-50%, -100%)",zIndex:1601},onPointerDown:u=>{u.stopPropagation()},children:c.map(u=>(0,bs.jsx)("button",{type:"button",className:"du-link-drop-item",title:u.name,"aria-label":`Create ${u.name}`,onClick:()=>{e.placeShapeAtLinkDrop(d=>u.factory(d))},dangerouslySetInnerHTML:{__html:u.icon}},u.id))})]}),n)};var r6=P(se(),1),lr=P(re(),1),s6=P(ha(),1);var PL=()=>{let e=G(),[,t]=(0,lr.useReducer)(h=>h+1,0),[n,o]=(0,lr.useState)(""),a=(0,lr.useRef)(null),r=Dt();(0,lr.useEffect)(()=>{if(e)return e.on("change",()=>{t()})},[e]);let s=e?.editingLinkCaption??null;if((0,lr.useEffect)(()=>{if(!e||s===null)return;let h=e.scene.links.get(s);o(h?.label?.text??"");let m=setTimeout(()=>{a.current?.focus(),a.current?.select()},0);return()=>{clearTimeout(m)}},[e,s]),!e||s===null)return null;let i=e.hostElement;if(!i)return null;let l=e.linkLabelWorld(s);if(!l)return null;let c=e.scene.viewport,u=i.getBoundingClientRect(),d=(l.x-c.pan.x)*c.zoom+u.left,f=(l.y-c.pan.y)*c.zoom+u.top,p=()=>{e.commitLinkCaptionEdit(n)};return(0,s6.createPortal)((0,r6.jsx)("input",{ref:a,className:"du-link-caption-input",value:n,placeholder:"Label",style:{position:"fixed",left:d,top:f,transform:"translate(-50%, -50%)",zIndex:1602},onChange:h=>{o(h.target.value)},onBlur:p,onKeyDown:h=>{h.key==="Enter"?(h.preventDefault(),p()):h.key==="Escape"&&(h.preventDefault(),e.cancelLinkCaptionEdit()),h.stopPropagation()}}),r)};var bt=P(se(),1),zg=P(re(),1);var gY=16,xY=1.75,BL={size:gY,strokeWidth:xY},bY={"mode-select":tf,"mode-hand":jd,"mode-rect":Uo,"mode-ellipse":Ys,"mode-text":yf,"mode-edge":ff,"mode-brush":Wr,"mode-erase":Bd,"mode-laser":lf,"mode-frame":Gd,"insert-image":$s,"tool-lock":Kd,undo:ei,redo:Js},AY=({id:e})=>{let t=G(),[,n]=(0,zg.useState)(0);(0,zg.useEffect)(()=>{if(t)return t.on("change",()=>{n(f=>f+1)})},[t]);let o=_e.get(e);if(!o)return null;let a=o.iconId?bY[o.iconId]:void 0,r=t?{editor:t}:null,s=r?o.checked?.(r)??!1:!1,i=!!t?.readOnly&&o.viewMode!==!0,l=r&&!i?o.predicate?o.predicate(r):!0:!1,u=(o.hotkey===void 0?[]:Array.isArray(o.hotkey)?o.hotkey:[o.hotkey])[0],d=`${o.label??e}${u?` (${ut(u)})`:""}`;return(0,bt.jsx)(fu,{title:d,active:s,disabled:!l,onClick:()=>{t&&_e.dispatch(e,{editor:t})},children:a?(0,bt.jsx)(a,{...BL}):o.label??e})},Rxe=ut({meta:!0,key:"\u2212"}),Oxe=ut({meta:!0,key:"+"}),Dxe=ut({meta:!0,key:"0"}),Pxe=ut({meta:!0,key:"1"}),NL=e=>{if(typeof document>"u")return;let t=document.createElement("input");t.type="file",t.accept="image/*",t.multiple=!0,t.addEventListener("change",()=>{let n=t.files;if(!n||n.length===0)return;let o=e.scene.viewport,a=e.screenToWorld({x:o.size.width/2,y:o.size.height/2});for(let r of Array.from(n))e.dispatchFileDrop(r,a)}),t.click()},i6=[{kind:"action-ref",id:"mode-select"},{kind:"action-ref",id:"mode-hand"},{kind:"action-ref",id:"mode-rect"},{kind:"action-ref",id:"mode-ellipse"},{kind:"action-ref",id:"mode-text"},{kind:"action-ref",id:"mode-edge"},{kind:"action-ref",id:"mode-brush"},{kind:"action-ref",id:"mode-erase"},{kind:"action-ref",id:"mode-laser"},{kind:"action-ref",id:"mode-frame"},{kind:"action",id:"insert-image",label:(0,bt.jsx)($s,{...BL}),title:"Insert image (I)",onClick:e=>{NL(e)}},{kind:"action-ref",id:"toggle-tool-lock"},{kind:"divider"},{kind:"action-ref",id:"undo"},{kind:"action-ref",id:"redo"},{kind:"divider"}],Fg=[{kind:"action-ref",id:"mode-select"},{kind:"action-ref",id:"mode-hand"},{kind:"divider"},{kind:"action-ref",id:"mode-rect"},{kind:"action-ref",id:"mode-ellipse"},{kind:"action-ref",id:"mode-text"},{kind:"action-ref",id:"mode-edge"},{kind:"action-ref",id:"mode-brush"},{kind:"action-ref",id:"mode-erase"},{kind:"action-ref",id:"mode-laser"},{kind:"action-ref",id:"mode-frame"},{kind:"action",id:"insert-image",label:(0,bt.jsx)($s,{...BL}),title:"Insert image (I)",onClick:e=>{NL(e)}},{kind:"divider"},{kind:"action-ref",id:"toggle-tool-lock"}],zL=({items:e=i6,style:t,className:n,orientation:o="horizontal"})=>{let a=G(),r=Vp(),s=is(),{canUndo:i,canRedo:l,undo:c,redo:u}=NS(),d=o==="vertical";return(0,bt.jsx)("div",{role:"toolbar","aria-orientation":o,className:`du-button-group${d?" du-button-group-vertical":""} ${n??""}`.trim(),style:t,children:e.map((f,p)=>{switch(f.kind){case"divider":return(0,bt.jsx)(SY,{vertical:d},p);case"action-ref":return(0,bt.jsx)(AY,{id:f.id},p);case"mode":{let h=r===f.mode,m=f.mode==="select"||f.mode==="hand";return(0,bt.jsx)(fu,{...f.title!==void 0?{title:f.title}:{},disabled:!a||s&&!m,active:h,onClick:()=>a?.setMode(f.mode),children:f.label},p)}case"action":return(0,bt.jsx)(fu,{...f.title!==void 0?{title:f.title}:{},disabled:f.disabled??(!a||s),active:f.active,onClick:()=>{a&&f.onClick(a)},children:f.label},p);case"undo":return(0,bt.jsx)(fu,{disabled:!i||s,onClick:c,children:f.label??"Undo"},p);case"redo":return(0,bt.jsx)(fu,{disabled:!l||s,onClick:u,children:f.label??"Redo"},p);case"tool-lock":return(0,bt.jsx)(vY,{...f.label!==void 0?{label:f.label}:{},...f.title!==void 0?{title:f.title}:{}},p)}})})},vY=({label:e="\u{1F512}",title:t="Lock current tool"})=>{let n=G(),o=sn(r=>r.toolLocked,!1),a=is();return(0,bt.jsx)(fu,{disabled:!n||a,title:t,active:o,onClick:()=>n?.setToolLocked(!o),children:e})};var fu=({children:e,onClick:t,active:n,disabled:o,title:a,className:r,style:s})=>{let i=(0,bt.jsx)("button",{type:"button",onClick:t,disabled:o,"aria-label":a,"aria-pressed":n,className:`du-icon-button${n?" is-active":""}${r?` ${r}`:""}`,style:{width:"auto",minWidth:"var(--du-button-size, 36px)",padding:"0 8px",...s},children:e});return a?(0,bt.jsx)(ti,{content:a,children:i}):i},SY=({vertical:e=!1})=>e?(0,bt.jsx)("span",{style:{height:1,width:"100%",background:"var(--du-ui-border, #333)",margin:"4px 0"}}):(0,bt.jsx)("span",{style:{width:1,height:20,background:"var(--du-ui-border, #333)",margin:"0 4px"}});var FL=.5522847498307936,l6=.55;var LY={i:.28,l:.28,I:.34,t:.34,f:.36,j:.3,r:.4," ":.3,m:.86,w:.82,M:.86,W:.92},c6=(e,t,n)=>{let o=0;for(let a of e)o+=(LY[a]??l6)*n;return o};var Hg=class{size;measure;fillColor=null;strokeColor=null;strokeWidth=1;opacity=1;lineCap="butt";lineJoin="miter";dashArray=null;fontFamily="system-ui, sans-serif";fontSize=14;fontWeight="normal";fontStyle="normal";textAlign="left";textBaseline="top";currentTransform=N.IDENTITY;pathSegments=[];pathCursor=null;elements=[];clipIdCounter=0;stack=[];constructor(t){this.size={width:t.width,height:t.height},this.measure=t.measureText??c6}toSvg(){let t=this.size.width,n=this.size.height;return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${n}" viewBox="0 0 ${t} ${n}">`+this.elements.join("")+"</svg>"}setFill(t){this.fillColor=t}setStroke(t){this.strokeColor=t}setStrokeWidth(t){this.strokeWidth=t}setOpacity(t){this.opacity=t}setLineCap(t){this.lineCap=t}setLineJoin(t){this.lineJoin=t}setDashArray(t){this.dashArray=t}setFont(t,n,o){this.fontFamily=t,this.fontSize=n,this.fontWeight=o?.weight??"normal",this.fontStyle=o?.style??"normal"}setTextAlign(t){this.textAlign=t}setTextBaseline(t){this.textBaseline=t}save(){this.stack.push({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,opacity:this.opacity,lineCap:this.lineCap,lineJoin:this.lineJoin,dashArray:this.dashArray,fontFamily:this.fontFamily,fontSize:this.fontSize,fontWeight:this.fontWeight,fontStyle:this.fontStyle,textAlign:this.textAlign,textBaseline:this.textBaseline,transform:this.currentTransform})}restore(){let t=this.stack.pop();t&&(this.fillColor=t.fillColor,this.strokeColor=t.strokeColor,this.strokeWidth=t.strokeWidth,this.opacity=t.opacity,this.lineCap=t.lineCap,this.lineJoin=t.lineJoin,this.dashArray=t.dashArray,this.fontFamily=t.fontFamily,this.fontSize=t.fontSize,this.fontWeight=t.fontWeight,this.fontStyle=t.fontStyle,this.textAlign=t.textAlign,this.textBaseline=t.textBaseline,this.currentTransform=t.transform)}translate(t,n){this.currentTransform=N.multiply(this.currentTransform,N.translation(t,n))}rotate(t){this.currentTransform=N.multiply(this.currentTransform,N.rotation(t))}scale(t,n){this.currentTransform=N.multiply(this.currentTransform,N.scaling(t,n))}setTransform(t){this.currentTransform=t}resetTransform(){this.currentTransform=N.IDENTITY}beginPath(){this.pathSegments=[],this.pathCursor=null}closePath(){this.pathSegments.push("Z")}moveTo(t,n){let o=this.apply(t,n);this.pathSegments.push(`M${He(o.x)} ${He(o.y)}`),this.pathCursor=o}lineTo(t,n){let o=this.apply(t,n);this.pathSegments.push(`L${He(o.x)} ${He(o.y)}`),this.pathCursor=o}quadraticCurveTo(t,n,o,a){let r=this.apply(t,n),s=this.apply(o,a);this.pathSegments.push(`Q${He(r.x)} ${He(r.y)} ${He(s.x)} ${He(s.y)}`),this.pathCursor=s}bezierCurveTo(t,n,o,a,r,s){let i=this.apply(t,n),l=this.apply(o,a),c=this.apply(r,s);this.pathSegments.push(`C${He(i.x)} ${He(i.y)} ${He(l.x)} ${He(l.y)} ${He(c.x)} ${He(c.y)}`),this.pathCursor=c}rect(t,n,o,a){this.moveTo(t,n),this.lineTo(t+o,n),this.lineTo(t+o,n+a),this.lineTo(t,n+a),this.closePath()}ellipse(t,n,o,a){let r=o*FL,s=a*FL;this.moveTo(t+o,n),this.bezierCurveTo(t+o,n+s,t+r,n+a,t,n+a),this.bezierCurveTo(t-r,n+a,t-o,n+s,t-o,n),this.bezierCurveTo(t-o,n-s,t-r,n-a,t,n-a),this.bezierCurveTo(t+r,n-a,t+o,n-s,t+o,n),this.closePath()}fill(t="nonzero"){if(this.pathSegments.length===0)return;let o=[`d="${this.pathSegments.join(" ")}"`,`fill="${this.fillColor??"none"}"`,t==="evenodd"?'fill-rule="evenodd"':"",this.opacity!==1?`fill-opacity="${this.opacity}"`:""].filter(Boolean).join(" ");this.elements.push(`<path ${o}/>`)}stroke(){if(this.pathSegments.length===0||this.strokeColor===null||this.strokeWidth<=0)return;let t=this.pathSegments.join(" "),n=this.dashArray&&this.dashArray.length>0?`stroke-dasharray="${this.dashArray.join(" ")}"`:"",o=[`d="${t}"`,'fill="none"',`stroke="${this.strokeColor}"`,`stroke-width="${this.strokeWidth}"`,this.lineCap!=="butt"?`stroke-linecap="${this.lineCap}"`:"",this.lineJoin!=="miter"?`stroke-linejoin="${this.lineJoin}"`:"",n,this.opacity!==1?`stroke-opacity="${this.opacity}"`:""].filter(Boolean).join(" ");this.elements.push(`<path ${o}/>`)}fillText(t,n,o,a){if(!t)return;let r=this.apply(n,o),s=this.textAlign==="center"?"middle":this.textAlign==="right"?"end":"start",i=this.textBaseline==="middle"?"central":this.textBaseline==="bottom"?"alphabetic":"hanging",l=[`x="${He(r.x)}"`,`y="${He(r.y)}"`,`font-family="${HL(this.fontFamily)}"`,`font-size="${this.fontSize}"`,this.fontWeight==="bold"?'font-weight="bold"':"",this.fontStyle==="italic"?'font-style="italic"':"",`fill="${this.fillColor??"#000"}"`,`text-anchor="${s}"`,`dominant-baseline="${i}"`,this.opacity!==1?`fill-opacity="${this.opacity}"`:"",a!==void 0?`textLength="${a}" lengthAdjust="spacingAndGlyphs"`:""].filter(Boolean).join(" ");this.elements.push(`<text ${l}>${wY(t)}</text>`)}measureText(t){return{width:this.measure(t,this.fontFamily,this.fontSize)}}drawImage(t,n,o,a,r,s,i){if(typeof t!="string"||t==="")return;let l=this.apply(n,o);if(i&&(i.x!==0||i.y!==0||i.width!==1||i.height!==1)){this.drawCroppedImage(t,l.x,l.y,a,r,i);return}this.elements.push(`<image x="${He(l.x)}" y="${He(l.y)}" width="${a}" height="${r}" href="${HL(t)}"/>`)}drawCroppedImage(t,n,o,a,r,s){let i=a/s.width,l=r/s.height,c=n-s.x*i,u=o-s.y*l,d=`oja-crop-${(this.clipIdCounter++).toString()}`;this.elements.push(`<clipPath id="${d}"><rect x="${He(n)}" y="${He(o)}" width="${a}" height="${r}"/></clipPath><g clip-path="url(#${d})"><image x="${He(c)}" y="${He(u)}" width="${He(i)}" height="${He(l)}" preserveAspectRatio="none" href="${HL(t)}"/></g>`)}clear(t){if(!t){this.elements.length=0;return}let n=this.apply(t.x,t.y),o=this.apply(t.x+t.width,t.y+t.height),a=Math.min(n.x,o.x),r=Math.min(n.y,o.y),s=Math.abs(o.x-n.x),i=Math.abs(o.y-n.y);this.elements.push(`<rect x="${He(a)}" y="${He(r)}" width="${s}" height="${i}" fill="#fff"/>`)}apply(t,n){return N.applyToPoint(this.currentTransform,{x:t,y:n})}},He=e=>Number.isInteger(e)?String(e):e.toFixed(3).replace(/\.?0+$/,""),HL=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),wY=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");var UL=(e,t={})=>{t.skipInstall||Dc();let n=t.width??e.viewport.size.width,o=t.height??e.viewport.size.height,a=new Hg({width:n,height:o,...t.measureText?{measureText:t.measureText}:{}});return Za(e,a,t),Pn(e,a),a.toSvg()};var As=P(se(),1),fa=P(re(),1),u6=P(ha(),1);var GL=({items:e,style:t,className:n})=>{let o=G(),a=xg(),r=Dt(),[s,i]=(0,fa.useState)(null),l=(0,fa.useRef)(null);(0,fa.useEffect)(()=>{if(a)return a.register(({screenPoint:p,worldPoint:h})=>{i({screenPoint:p,worldPoint:h})})},[a]),(0,fa.useEffect)(()=>{if(o)return o.onLongPress(({screenPoint:p,worldPoint:h})=>{let m=o.hostElement.getBoundingClientRect();i({screenPoint:{x:p.x+m.left,y:p.y+m.top},worldPoint:h})})},[o]),(0,fa.useEffect)(()=>{if(!s)return;let p=m=>{l.current?.contains(m.target)||i(null)},h=m=>{m.key==="Escape"&&i(null)};return window.addEventListener("pointerdown",p,!0),window.addEventListener("keydown",h),()=>{window.removeEventListener("pointerdown",p,!0),window.removeEventListener("keydown",h)}},[s]);let c=(0,fa.useCallback)(()=>{i(null)},[]);if(!o||!s)return null;let u={worldPoint:s.worldPoint,screenPoint:s.screenPoint},d=e.filter(p=>p.kind==="divider"||p.visible?.(o,u)!==!1),f=CY(d);return f.length===0?null:(0,u6.createPortal)((0,As.jsx)("div",{ref:l,role:"menu",style:{position:"fixed",zIndex:1e3,top:s.screenPoint.y,left:s.screenPoint.x,background:"var(--menu-bg, var(--du-ui-bg-solid, #fff))",color:"var(--menu-text, var(--du-text, #1a1a1a))",border:"1px solid var(--menu-border, var(--du-ui-border, rgba(0,0,0,0.08)))",borderRadius:6,padding:"4px 0",minWidth:180,boxShadow:"var(--du-ui-shadow, 0 4px 16px rgba(0,0,0,0.18))",font:"13px system-ui, -apple-system, Segoe UI, Roboto, sans-serif",...t},className:n,children:f.map((p,h)=>p.kind==="divider"?(0,As.jsx)("hr",{style:{border:0,borderTop:"1px solid var(--menu-divider, var(--du-ui-border, rgba(0,0,0,0.08)))",margin:"4px 0"}},`d-${h}`):(0,As.jsx)(_Y,{item:p,editor:o,ctx:u,onActivate:()=>{c(),p.onClick(o,u)}},p.id))}),r)},_Y=({item:e,editor:t,ctx:n,onActivate:o})=>{let a=e.disabled?.(t,n)??!1;return(0,As.jsxs)("button",{type:"button",role:"menuitem",onClick:s=>{if(a){s.preventDefault();return}s.stopPropagation(),o()},disabled:a,style:{all:"unset",display:"flex",justifyContent:"space-between",padding:"6px 12px",cursor:a?"not-allowed":"pointer",opacity:a?.4:1,width:"100%",boxSizing:"border-box"},onMouseEnter:s=>{a||(s.currentTarget.style.background="var(--du-hover-overlay, rgba(0,0,0,0.05))")},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[(0,As.jsx)("span",{children:e.label}),e.shortcut?(0,As.jsx)("span",{style:{marginLeft:16,opacity:.6,fontSize:11},children:e.shortcut}):null]})},CY=e=>{let t=[];for(let n of e)n.kind==="divider"&&(t.length===0||t[t.length-1]?.kind==="divider")||t.push(n);for(;t.length>0&&t[t.length-1]?.kind==="divider";)t.pop();return t},WL=e=>{window.confirm("Clear the canvas? Every shape is removed and this can't be undone.")&&e.clear()},Ce=(e,t)=>{let n=_e.get(e),o=n?.predicate,r=(n?.hotkey?Array.isArray(n.hotkey)?n.hotkey:[n.hotkey]:[])[0],s=t?.visible??(o?l=>o({editor:l}):void 0),i=(l,c)=>(!l.readOnly||n?.viewMode===!0)&&(s?.(l,c)??!0);return{kind:"action",id:e,label:t?.label??n?.label??e,...r?{shortcut:ut(r)}:{},visible:i,onClick:l=>{_e.dispatch(e,{editor:l})}}},qL=[{kind:"action",id:"annotation-open",label:"Open thread",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.setSelectedAnnotation(n)}},{kind:"action",id:"annotation-toggle-resolved",label:"Toggle resolved",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.toggleAnnotationResolved(n)}},{kind:"action",id:"annotation-delete",label:"Delete annotation",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.removeAnnotation(n)}},{kind:"divider"},Ce("delete-selection",{label:"Delete"}),Ce("duplicate-selection",{label:"Duplicate"}),Ce("copy"),Ce("cut"),Ce("paste"),Ce("copy-style",{label:"Copy style"}),Ce("paste-style",{label:"Paste style"}),Ce("select-all"),{kind:"divider"},Ce("group-selection",{label:"Group"}),Ce("ungroup-selection",{label:"Ungroup"}),Ce("flip-horizontal",{label:"Flip horizontal"}),Ce("flip-vertical",{label:"Flip vertical"}),Ce("align-left",{label:"Align left"}),Ce("align-h-center",{label:"Align horizontal centres"}),Ce("align-right",{label:"Align right"}),Ce("align-top",{label:"Align top"}),Ce("align-v-center",{label:"Align vertical centres"}),Ce("align-bottom",{label:"Align bottom"}),Ce("distribute-horizontal",{label:"Distribute horizontally"}),Ce("distribute-vertical",{label:"Distribute vertically"}),Ce("arrange-grid"),Ce("arrange-stack-h"),Ce("arrange-stack-v"),Ce("auto-arrange"),Ce("compact-z-order"),{kind:"divider"},Ce("bring-to-front",{visible:e=>e.selection.size===1}),Ce("send-to-back",{visible:e=>e.selection.size===1}),{kind:"action",id:"move-to-layer",label:"Move to layer\u2026",visible:e=>!e.readOnly&&e.selection.size>0&&e.scene.layers.size>1,onClick:e=>{if(typeof window>"u")return;let t=[...e.scene.layers.values()],n=t.map((s,i)=>`${i+1}. ${s.name}`).join(`
|
|
141
166
|
`),o=window.prompt(`Move selection to layer (1-${t.length}):
|
|
142
|
-
${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id)}},{kind:"divider"},{kind:"action",id:"open-thread",label:"Open thread",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.setSelectedAnnotation(n)}},{kind:"action",id:"resolve-annotation",label:"Toggle resolved",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.toggleAnnotationResolved(n)}},{kind:"action",id:"remove-annotation",label:"Delete annotation",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.removeAnnotation(n)}},{kind:"action",id:"add-comment",label:"Add comment",visible:(e,t)=>e.hitAnnotation(t.worldPoint)===null,onClick:(e,t)=>{let n=[...e.scene.elements.values()].reverse().find(a=>{let r=a.position,s="width"in a&&typeof a.width=="number"?a.width:0,i="height"in a&&typeof a.height=="number"?a.height:0;return t.worldPoint.x>=r.x&&t.worldPoint.y>=r.y&&t.worldPoint.x<=r.x+s&&t.worldPoint.y<=r.y+i}),o=n?{x:t.worldPoint.x-n.position.x,y:t.worldPoint.y-n.position.y}:t.worldPoint;e.addAnnotation({position:o,elementId:n?.id??null})}},{kind:"divider"},ke("zoom-in"),ke("zoom-out"),ke("zoom-reset",{label:"Reset zoom (100%)"}),ke("zoom-to-fit",{label:"Fit to screen",visible:e=>e.scene.elements.size>0}),{kind:"divider"},{kind:"action",id:"clear-canvas",label:"Clear canvas",visible:e=>e.scene.elements.size>0||e.scene.links.size>0,onClick:e=>{aL(e)}}];var Ga=F(ye(),1),Ln=F(he(),1);var sL=()=>{let e=j(),[t,n]=(0,Ln.useState)(!1),[o,a]=(0,Ln.useState)(""),[r,s]=(0,Ln.useState)(0),i=(0,Ln.useRef)(null);(0,Ln.useEffect)(()=>(st.replace({id:"open-command-palette",label:"Command palette",category:"other",hotkey:[{key:"k",meta:!0},{key:"p",meta:!0,shift:!0}],perform:()=>{n(!0)}}),st.replace({id:"clear-canvas",label:"Clear canvas",category:"edit",hotkey:[{key:"Delete",meta:!0},{key:"Backspace",meta:!0}],predicate:({editor:m})=>m.scene.elements.size>0||m.scene.links.size>0,perform:({editor:m})=>{aL(m)}}),()=>{st.unregister("open-command-palette"),st.unregister("clear-canvas")}),[]);let l=(0,Ln.useMemo)(()=>st.getAll().filter(m=>m.label!==void 0&&m.id!=="open-command-palette"),[t]),c=e?{editor:e}:null,u=(0,Ln.useMemo)(()=>{let m=o.trim().toLowerCase();return(m?l.filter(y=>(y.label??"").toLowerCase().includes(m)):l).map(y=>({action:y,enabled:c?y.predicate?y.predicate(c):!0:!1}))},[l,o,c]);if((0,Ln.useEffect)(()=>{if(!t)return;a(""),s(0);let m=requestAnimationFrame(()=>i.current?.focus());return()=>{cancelAnimationFrame(m)}},[t]),(0,Ln.useEffect)(()=>{s(0)},[o]),!t)return null;let d=()=>{n(!1)},f=m=>{!m.enabled||!c||(d(),st.dispatch(m.action.id,c))},p=m=>{if(m.key==="ArrowDown")m.preventDefault(),s(b=>Math.min(u.length-1,b+1));else if(m.key==="ArrowUp")m.preventDefault(),s(b=>Math.max(0,b-1));else if(m.key==="Enter"){m.preventDefault();let b=u[r];b&&f(b)}},h=(m,b)=>({display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"8px 14px",cursor:b?"pointer":"default",opacity:b?1:.4,background:m===r?"var(--du-ui-hover, rgba(0,0,0,0.06))":"transparent"});return(0,Ga.jsxs)(O0,{open:t,onClose:d,title:"Command palette",style:iW,children:[(0,Ga.jsx)("input",{ref:i,value:o,onChange:m=>{a(m.target.value)},onKeyDown:p,placeholder:"Search commands\u2026","aria-label":"Search commands",style:lW}),(0,Ga.jsx)("ul",{style:cW,role:"listbox",children:u.length===0?(0,Ga.jsx)("li",{style:{padding:"12px 14px",opacity:.6},children:"No commands"}):u.map((m,b)=>{let y=sW(m.action);return(0,Ga.jsxs)("li",{role:"option","aria-selected":b===r,"aria-disabled":!m.enabled,style:h(b,m.enabled),onPointerEnter:()=>{s(b)},onClick:()=>{f(m)},children:[(0,Ga.jsx)("span",{children:m.action.label}),y?(0,Ga.jsx)("kbd",{style:uW,children:y}):null]},m.action.id)})})]})},sW=e=>{if(e.hotkey){let n=(Array.isArray(e.hotkey)?e.hotkey:[e.hotkey])[0];if(n)return Bt(n)}return e.sequence&&e.sequence.length>0?e.sequence.map(t=>t.length===1?t.toUpperCase():t).join(" "):null},iW={maxWidth:520,width:"calc(100vw - 64px)",padding:0,display:"flex",flexDirection:"column",overflow:"hidden"},lW={border:"none",borderBottom:"1px solid var(--du-ui-border)",outline:"none",padding:"14px 16px",fontSize:15,background:"transparent",color:"inherit"},cW={listStyle:"none",margin:0,padding:4,maxHeight:360,overflowY:"auto"},uW={fontSize:11,color:"var(--du-text-muted, #6b6b6b)",fontFamily:"inherit"};var qa=F(ye(),1),Sn=F(he(),1);var dW=(0,Sn.createContext)(null);var iL=({children:e,defaultDuration:t=3e3,style:n})=>{let[o,a]=(0,Sn.useState)([]),r=(0,Sn.useRef)(0),s=(0,Sn.useCallback)(c=>{a(u=>u.filter(d=>d.id!==c))},[]),i=(0,Sn.useCallback)((c,u="info",d)=>{let f=`toast-${++r.current}`,p=d??t;return a(h=>[...h,{id:f,kind:u,message:c,duration:p}]),p>0&&Number.isFinite(p)&&window.setTimeout(()=>{s(f)},p),f},[t,s]),l=(0,Sn.useMemo)(()=>({push:i,dismiss:s}),[i,s]);return(0,qa.jsxs)(dW.Provider,{value:l,children:[e,(0,qa.jsx)(fW,{toasts:o,onDismiss:s,...n?{style:n}:{}})]})},fW=({toasts:e,onDismiss:t,style:n})=>{let o={position:"fixed",top:16,right:16,zIndex:1100,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none",...n};return(0,qa.jsx)("div",{style:o,"aria-live":"polite","aria-atomic":"false",children:e.map(a=>(0,qa.jsx)(hW,{toast:a,onDismiss:t},a.id))})},pW={info:"var(--accent, #1a73e8)",success:"#2e8b57",warn:"#c79100",error:"#c83232"},hW=({toast:e,onDismiss:t})=>{let n={pointerEvents:"auto",minWidth:240,maxWidth:360,padding:"10px 12px",background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",border:"1px solid var(--border, #2a2a2a)",borderLeft:`4px solid ${pW[e.kind]}`,borderRadius:4,boxShadow:"0 4px 14px rgba(0, 0, 0, 0.3)",fontSize:13,display:"flex",alignItems:"flex-start",gap:12};return(0,qa.jsxs)("div",{role:"status",style:n,children:[(0,qa.jsx)("span",{style:{flex:1,lineHeight:1.35},children:e.message}),(0,qa.jsx)("button",{type:"button","aria-label":"Dismiss",onClick:()=>{t(e.id)},style:{background:"transparent",border:"none",color:"var(--muted, #888)",cursor:"pointer",fontSize:16,lineHeight:1,padding:0},children:"\xD7"})]})};var qe=F(ye(),1),yt=F(he(),1);var mW=16,yW=1.75,O6=(0,yt.createContext)(null),R6=()=>(0,yt.useContext)(O6)??{close:()=>{}},Q=({children:e,trigger:t=(0,qe.jsx)(hd,{size:mW,strokeWidth:yW}),className:n,style:o})=>{let[a,r]=(0,yt.useState)(!1),s=(0,yt.useRef)(null),i=(0,yt.useId)();(0,yt.useEffect)(()=>{if(!a)return;let d=p=>{s.current&&(s.current.contains(p.target)||r(!1))},f=p=>{p.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",d),window.addEventListener("pointerdown",d),window.addEventListener("keydown",f),()=>{window.removeEventListener("mousedown",d),window.removeEventListener("pointerdown",d),window.removeEventListener("keydown",f)}},[a]);let l=(0,yt.useCallback)(()=>{r(!1)},[]),c={position:"relative",display:"inline-flex",...o},u={position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:200,background:"var(--menu-bg)",color:"var(--menu-text)",border:"1px solid var(--menu-border)",borderRadius:6,boxShadow:"var(--du-ui-shadow)",padding:4,zIndex:900};return(0,qe.jsxs)("div",{ref:s,className:n,style:c,children:[(0,qe.jsx)("button",{type:"button",className:`du-icon-button du-icon-button-flat${a?" is-active":""}`,"aria-haspopup":"menu","aria-expanded":a,"aria-controls":i,"aria-label":"Main menu",title:"Main menu",onClick:()=>{r(d=>!d)},children:t}),a?(0,qe.jsx)("div",{id:i,role:"menu",style:u,children:(0,qe.jsx)(O6.Provider,{value:{close:l},children:e})}):null]})},gW={display:"block",width:"100%",textAlign:"left",background:"transparent",color:"inherit",border:"none",borderRadius:4,padding:"6px 10px",font:"inherit",fontSize:13,cursor:"pointer"},lL=e=>({...gW,...e}),xW=({children:e,onClick:t,shortcut:n,disabled:o,active:a,icon:r})=>{let{close:s}=R6();return(0,qe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,onClick:()=>{o||(t?.(),s())},style:{...lL(),cursor:o?"not-allowed":"pointer",opacity:o?.4:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,qe.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,qe.jsx)("span",{"aria-hidden":!0,style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",color:a?"var(--du-accent, #1a73e8)":"var(--du-text-muted, #888)"},children:a?(0,qe.jsx)(Vu,{size:12,strokeWidth:2.25}):r??""}),e]}),n?(0,qe.jsx)("span",{style:{color:"var(--muted, #888)",fontSize:11},children:n}):null]})},bW=({children:e,href:t,external:n})=>{let{close:o}=R6();return(0,qe.jsx)("a",{role:"menuitem",href:t,target:n?"_blank":void 0,rel:n?"noreferrer noopener":void 0,onClick:o,style:{...lL({textDecoration:"none"}),color:"var(--text, #ddd)"},children:e})},AW=()=>(0,qe.jsx)("hr",{style:{margin:"4px 6px",border:"none",borderTop:"1px solid var(--border, #2a2a2a)"}}),vW=({title:e,children:t})=>(0,qe.jsxs)("div",{children:[(0,qe.jsx)("div",{style:{padding:"6px 10px 2px",fontSize:11,textTransform:"uppercase",letterSpacing:.5,color:"var(--muted, #888)"},children:e}),t]}),LW=({value:e,onChange:t,options:n})=>(0,qe.jsx)("div",{role:"radiogroup",style:{display:"flex",margin:"4px 8px 6px",background:"var(--menu-divider, #2a2a2a)",borderRadius:6,padding:2,gap:2},children:n.map(o=>{let a=o.value===e;return(0,qe.jsx)("button",{type:"button",role:"radio","aria-checked":a,title:o.label,"aria-label":o.label,onClick:()=>{t(o.value)},style:{flex:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,minHeight:26,padding:"0 8px",background:a?"var(--menu-bg, #1a1a1a)":"transparent",color:a?"var(--text, #ddd)":"var(--muted, #888)",border:"none",borderRadius:4,cursor:"pointer",fontSize:12,fontWeight:a?600:400,boxShadow:a?"0 1px 2px rgba(0, 0, 0, 0.15)":"none",transition:"background 0.12s ease, color 0.12s ease"},children:o.icon??o.label},o.value)})}),SW=120,kW=({children:e,label:t,icon:n,disabled:o})=>{let[a,r]=(0,yt.useState)(!1),s=(0,yt.useRef)(null),i=(0,yt.useCallback)(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null)},[]),l=(0,yt.useCallback)(()=>{i(),s.current=window.setTimeout(()=>{r(!1),s.current=null},SW)},[i]);(0,yt.useEffect)(()=>i,[i]);let c={position:"absolute",top:-4,left:"100%",marginLeft:4,minWidth:220,background:"var(--menu-bg)",color:"var(--menu-text)",border:"1px solid var(--menu-border)",borderRadius:6,boxShadow:"var(--du-ui-shadow)",padding:4,zIndex:1e3};return(0,qe.jsxs)("div",{style:{position:"relative"},onMouseEnter:()=>{o||(i(),r(!0))},onMouseLeave:l,children:[(0,qe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,"aria-haspopup":"menu","aria-expanded":a,onClick:()=>{o||(i(),r(u=>!u))},style:{...lL(),cursor:o?"not-allowed":"pointer",opacity:o?.4:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,qe.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,qe.jsx)("span",{"aria-hidden":!0,style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--du-text-muted, #888)"},children:n??""}),t]}),(0,qe.jsx)(ks,{size:12,strokeWidth:2.25,"aria-hidden":!0})]}),a?(0,qe.jsx)("div",{role:"menu",style:c,children:e}):null]})};Q.Item=xW;Q.ItemLink=bW;Q.Separator=AW;Q.Group=vW;Q.Toggle=LW;Q.Submenu=kW;var vp=class e{cacheSize;fallbackFactor;cache=new Map;wasm=null;currentFontKey=null;textEncoder=new TextEncoder;constructor(t={}){this.cacheSize=t.cacheSize??1e4,this.fallbackFactor=t.fallbackAdvanceFactor??.55}get isReady(){return this.wasm!==null}async loadModule(t){let n=await Bf(t,"WasmTextShaper.loadModule"),{instance:o}=await WebAssembly.instantiate(n,{});this.wasm=o.exports,this.cache.clear(),this.currentFontKey=null}static async loadBundled(){let t=new e,n=new URL("../wasm/text_shaper.wasm",import.meta.url);return await t.loadModule(n),t}measure(t,n){let o=`${D6(n)}|${t}`,a=this.cache.get(o);if(a)return this.cache.delete(o),this.cache.set(o,a),a;let r=this.wasm?this.measureViaWasm(t,n,this.wasm):this.measureFallback(t,n);if(this.cache.size>=this.cacheSize){let s=this.cache.keys().next().value;s!==void 0&&this.cache.delete(s)}return this.cache.set(o,r),r}shape(t,n){let o=this.measure(t,n),a=t.length===0?0:o.width/t.length,r=[];for(let s=0;s<t.length;s++)r.push({glyphId:t.charCodeAt(s),advance:a,x:s*a,y:0});return r}resolveFontId(t,n=!1,o=!1){let a=this.wasm;if(!a?.resolveFont)return 0;let r=this.textEncoder.encode(t),{ptr:s,len:i,free:l}=Pr(a,r),c=a.resolveFont(s,i,n?1:0,o?1:0);return l(),c}glyphMetrics(t,n=0){let o=this.wasm;if(!o?.glyphMetrics)return null;let a=o.glyphMetrics(n,t),r=o.memory.buffer;if(a<=0||a+24>r.byteLength)return null;let s=new DataView(r,a,24);return{advance:s.getFloat32(0,!0),bboxXMin:s.getFloat32(4,!0),bboxYMin:s.getFloat32(8,!0),bboxW:s.getFloat32(12,!0),bboxH:s.getFloat32(16,!0),unitsPerEm:s.getFloat32(20,!0)}}rasterizeGlyphMSDF(t,n,o,a=0){let r=this.wasm;if(!r?.rasterizeGlyphMSDF)return null;let s=r.rasterizeGlyphMSDF(a,t,n,o),i=n*n*3,l=new Uint8Array(r.memory.buffer,s,i),c=new Uint8Array(l);return{atlasSize:n,range:o,data:c}}resetArena(){this.wasm?.reset?.(),this.currentFontKey=null}measureFallback(t,n){return{width:t.length*n.size*this.fallbackFactor}}measureViaWasm(t,n,o){let a=D6(n);if(a!==this.currentFontKey){let u=this.textEncoder.encode(n.family),d=Pr(o,u);o.setFont(d.ptr,d.len,n.size,0,0),d.free(),this.currentFontKey=a}let r=this.textEncoder.encode(t),{ptr:s,len:i,free:l}=Pr(o,r),c=o.measure(s,i);return l(),{width:c}}},D6=e=>`${e.family}|${e.size}|${e.weight??"normal"}|${e.style??"normal"}`;var wW={butt:0,round:1,square:2},_W={miter:0,round:1,bevel:2},CW={M:0,L:1,Q:2,C:3,Z:4},Lp=class e{defaultTolerance;wasm=null;constructor(t={}){this.defaultTolerance=t.defaultTolerance??.5}get isReady(){return this.wasm!==null}async loadModule(t){let n=await Bf(t,"WasmRasterizer.loadModule"),{instance:o}=await WebAssembly.instantiate(n,{});this.wasm=o.exports}static async loadBundled(t={}){let n=new e(t),o=new URL("../wasm/rasterizer.wasm",import.meta.url);return await n.loadModule(o),n}flatten(t,n){let o=n>0?n:this.defaultTolerance;return this.wasm?this.flattenViaWasm(t,o,this.wasm):u0.flatten(t,o)}strokeToFill(t,n,o){return this.wasm?this.strokeToFillViaWasm(t,n,o,this.wasm):u0.strokeToFill(t,n,o)}flattenViaWasm(t,n,o){let a=TW(t),r=Pr(o,new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),s=o.alloc(4),i=o.alloc(4);try{o.flattenF32(r.ptr,a.length,n,s,i);let l=vy(o.memory,s),c=vy(o.memory,i);return P6(o.memory,l,c)}finally{r.free(),o.free(s,4),o.free(i,4)}}strokeToFillViaWasm(t,n,o,a){let r=IW(t),s=Pr(a,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),i=a.alloc(4),l=a.alloc(4);try{let c=wW[o?.cap??"butt"],u=_W[o?.join??"miter"];a.strokeToFillF32(s.ptr,t.length,n,c,u,i,l);let d=vy(a.memory,i),f=vy(a.memory,l);return P6(a.memory,d,f)}finally{s.free(),a.free(i,4),a.free(l,4)}}},TW=e=>{let t=new Float32Array(e.length*7),n=0;for(let o of e)switch(t[n++]=CW[o.kind],o.kind){case"M":case"L":t[n++]=o.to.x,t[n++]=o.to.y;break;case"Q":t[n++]=o.control.x,t[n++]=o.control.y,t[n++]=o.to.x,t[n++]=o.to.y;break;case"C":t[n++]=o.control1.x,t[n++]=o.control1.y,t[n++]=o.control2.x,t[n++]=o.control2.y,t[n++]=o.to.x,t[n++]=o.to.y;break;case"Z":break}return t.slice(0,n)},IW=e=>{let t=new Float32Array(e.length*2);for(let n=0;n<e.length;n++){let o=e[n];o!==void 0&&(t[n*2]=o.x,t[n*2+1]=o.y)}return t},vy=(e,t)=>new DataView(e.buffer,t,4).getUint32(0,!0),P6=(e,t,n)=>{let o=new Float32Array(e.buffer,t,n*2),a=new Array(n);for(let r=0;r<n;r++)a[r]={x:L(o[r*2]),y:L(o[r*2+1])};return a};var z6=()=>typeof Worker<"u",B6=()=>typeof WebAssembly<"u"&&typeof WebAssembly.instantiate=="function",EW=()=>{if(typeof matchMedia!="function")return!1;try{return matchMedia("(pointer: coarse)").matches}catch{return!1}},MW=async()=>await Fv()||Hv()?"webgl2":my()&&z6()?"offscreen":"canvas2d",N6=async(e={})=>{let t=e.renderer&&e.renderer!=="auto"?e.renderer:await MW(),n=e.wasmText!==void 0&&e.wasmText!=="auto"?e.wasmText:B6(),o=e.wasmRaster!==void 0&&e.wasmRaster!=="auto"?e.wasmRaster:B6()&&t==="webgl2",a=e.workers!==void 0&&e.workers!=="auto"?e.workers:my()&&z6(),r=e.tiles!==void 0&&e.tiles!=="auto"?e.tiles:!0;return{renderer:t,wasmText:n,wasmRaster:o,workers:a,tiles:r,touch:EW()}},F6=e=>{let t=e.renderer==="webgl2"?"WebGL2":e.renderer==="offscreen"?"OffscreenCanvas + Worker":"Canvas2D";console.log("%c[diagram]%c renderer=%s, wasmText=%s, wasmRaster=%s, workers=%s, tiles=%s, touch=%s (%s)","color: #1a73e8; font-weight: 700","color: inherit",e.renderer,e.wasmText,e.wasmRaster,e.workers,e.tiles,e.touch,t)};var dL=new WeakMap,fL=new WeakSet,ij=async e=>{let{parseGIF:t,decompressFrames:n}=await Promise.resolve().then(()=>F(j6(),1)),o=t(e),a=n(o,!0),r=o.lsd.width,s=o.lsd.height;if(r<=0||s<=0||a.length===0)return{frames:[],totalMs:0};let i=new OffscreenCanvas(r,s),l=i.getContext("2d"),c=new OffscreenCanvas(r,s),u=c.getContext("2d");if(!l||!u)return{frames:[],totalMs:0};let d=[],f=0;for(let p of a){let h=new ImageData(new Uint8ClampedArray(p.patch),p.dims.width,p.dims.height);c.width=p.dims.width,c.height=p.dims.height,u.putImageData(h,0,0),l.drawImage(c,p.dims.left,p.dims.top);let m=await createImageBitmap(i);f+=p.delay>0?p.delay:100,d.push({bitmap:m,endMs:f}),p.disposalType===2&&l.clearRect(p.dims.left,p.dims.top,p.dims.width,p.dims.height)}return{frames:d,totalMs:f}},lj={kind:"gif",getFrameAt(e,t){if(!(e instanceof ArrayBuffer)||e.byteLength===0)return null;let n=dL.get(e);if(!n)return fL.has(e)||(fL.add(e),ij(e).then(r=>{dL.set(e,r),tA()}).catch(()=>{}).finally(()=>fL.delete(e))),null;if(n.frames.length===0)return null;let o=n.totalMs>0?t%n.totalMs:0;for(let r of n.frames)if(o<r.endMs)return r.bitmap;let a=n.frames[n.frames.length-1];return a?a.bitmap:null},totalDurationMs(e){return dL.get(e)?.totalMs??0}},V6=!1,Z6=()=>{V6||(V6=!0,Rf(lj))};var Sp=F(he(),1);var X6=e=>{let t=Et(),[n]=(0,Sp.useState)(()=>typeof document>"u"?null:document.createElement("div"));return(0,Sp.useEffect)(()=>{if(n)return n.setAttribute("data-diagram-portal",""),t.appendChild(n),()=>{n.remove()}},[n,t]),(0,Sp.useEffect)(()=>{n&&(e==="system"?n.removeAttribute("data-theme"):n.setAttribute("data-theme",e))},[n,e]),n};var Y6=async(e,t)=>{if(typeof OffscreenCanvas>"u")return null;let n=cj(e);if(!n)return null;let o={x:n.x-20,y:n.y-20,width:n.width+40,height:n.height+40},a=Math.max(1,Math.ceil(o.width*t.scale)),r=Math.max(1,Math.ceil(o.height*t.scale)),{canvas:s,target:i}=Ov(a,r);t.background!=="transparent"&&(i.setFill(t.backgroundColor),i.beginPath(),i.rect(0,0,a,r),i.fill());let l={...e,viewport:{pan:{x:o.x,y:o.y},zoom:t.scale,rotation:0,size:{width:a,height:r},gridEnabled:e.viewport.gridEnabled,...e.viewport.gridStyle!==void 0?{gridStyle:e.viewport.gridStyle}:{}}};return t.background==="color-and-grid"&&l.viewport.gridEnabled&&Mf(l,i),Js(l,i,{skipClear:!0}),No(l,i),s.convertToBlob({type:"image/png"})},cj=e=>{let t=null;for(let n of co(e))if(n.visible)for(let o of La(e,n.id)){let a=z(o);t=t?uj(t,a):a}return t},uj=(e,t)=>{let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(e.x+e.width,t.x+t.width),r=Math.max(e.y+e.height,t.y+t.height);return{x:n,y:o,width:a-n,height:r-o}};var dj=14,fj=14,pj=16,mL=1.75,gt={size:dj,strokeWidth:mL},Jr={size:fj,strokeWidth:mL},Cy={size:pj,strokeWidth:mL},hj="https://github.com/oh-just-another/diagram",kp=(0,xe.forwardRef)(function(t,n){let{initialScene:o,initialMode:a="select",grid:r,snap:s,templates:i,fileDropHandlers:l,layoutKinds:c,animationAdapters:u,onReady:d,onSceneChange:f,onSelectionChange:p,capabilities:h,workerFactory:m,hideTopBar:b,hideBottomBar:y,hideToolbar:g,hideLibraryButton:x,hideMainMenu:A,hideZoomControls:C,hideResetToContent:_,hideHelpButton:v,hideContextMenu:I,hideSelectionPanel:k,renderTopBarLeft:T,renderTopBarCenter:P,renderTopBarRight:N,renderBottomBarLeft:U,renderBottomBarCenter:q,renderBottomBarRight:te,renderMainMenuExtras:Z,onImportTemplates:ue,theme:$,defaultTheme:re="system",onThemeChange:We,persistTheme:Re,repositoryUrl:Ii,onConfirm:es,onNotify:Rc,className:ts,style:ns}=t,Wa=(0,xe.useMemo)(()=>Re===!0?"diagram-theme":typeof Re=="string"?Re:null,[Re]),[tM,nM]=(0,xe.useState)(()=>{if(!Wa||typeof window>"u")return re;let ne=window.localStorage.getItem(Wa);return ne==="light"||ne==="dark"||ne==="system"?ne:re}),_p=$??tM,oM=X6(_p),aM=(0,xe.useCallback)(ne=>{$===void 0&&nM(ne),Wa&&typeof window<"u"&&window.localStorage.setItem(Wa,ne),We?.(ne)},[$,We,Wa]),xL=r?.enabled,bL=r?.style,Dc=(0,xe.useMemo)(()=>Sb({...o?{saved:o}:{},hostSettings:_j(xL,bL,s)}),[o,xL,bL,s]),AL=(0,xe.useMemo)(()=>{for(let ne of Dc.elements.values())if(Fe(ne))return!0;return!1},[Dc]);(0,xe.useEffect)(()=>{if(Z6(),i)for(let ne of i)ai.register(ne);if(c)for(let ne of c)Ob(ne);if(u)for(let ne of u)Rf(ne)},[i,c,u]);let[os,rM]=(0,xe.useState)(null),[Cp,sM]=(0,xe.useState)(null),[Tp,iM]=(0,xe.useState)(null),[lM,vL]=(0,xe.useState)(!1),[Iy,LL]=(0,xe.useState)(!1),SL=(0,xe.useRef)(null),kL=(0,xe.useRef)(!1);(0,xe.useEffect)(()=>{let ne=!1;return(async()=>{SL.current??=N6(h);let kn=await SL.current;if(ne)return;kL.current||(kL.current=!0,F6(kn)),rM(kn);let Ao=[];Ao.push(V8(document).then(()=>{ne||LL(!0)},to=>{ne||LL(!0),console.warn("[diagram] bundled fonts load failed",to)})),kn.wasmText&&Ao.push(vp.loadBundled().then(to=>{ne||(zf(to),sM(to),vL(!0))},to=>{ne||(vL(!0),console.warn("[diagram] WASM text shaper load failed",to))})),kn.wasmRaster&&Ao.push(Lp.loadBundled().then(to=>{ne||(Nf(to),iM(to))},to=>{console.warn("[diagram] WASM rasterizer load failed",to)})),await Promise.allSettled(Ao)})(),()=>{ne=!0}},[h]);let[se,cM]=(0,xe.useState)(null),uM=(0,xe.useCallback)(ne=>{if(l)for(let kn of l)ne.registerFileDropHandler(kn);cM(ne),d?.(ne)},[l,d]);return(0,xe.useEffect)(()=>{se&&(!Cp&&!Tp||se.setMode(se.mode))},[se,Cp,Tp]),(0,xe.useEffect)(()=>{se&&se.forceRender()},[se,u]),(0,xe.useEffect)(()=>{se&&Iy&&se.forceRender()},[se,Iy]),(0,xe.useEffect)(()=>{if(!se||!f&&!p)return;let ne=se.scene,kn=se.selection;return se.subscribe(()=>{f&&se.scene!==ne&&(ne=se.scene,f(se.scene)),p&&se.selection!==kn&&(kn=se.selection,p(se.selection))})},[se,f,p]),(0,xe.useEffect)(()=>{if(!se)return;let ne=Ao=>{Ia(Ao.target)||(se.setSnapSuppressed(Ao.metaKey||Ao.ctrlKey),se.setTransformModifiers({alt:Ao.altKey,shift:Ao.shiftKey}))},kn=()=>{se.setSnapSuppressed(!1),se.setTransformModifiers({alt:!1,shift:!1})};return window.addEventListener("keydown",ne),window.addEventListener("keyup",ne),window.addEventListener("blur",kn),()=>{window.removeEventListener("keydown",ne),window.removeEventListener("keyup",ne),window.removeEventListener("blur",kn),se.setSnapSuppressed(!1),se.setTransformModifiers({alt:!1,shift:!1})}},[se]),(0,xe.useImperativeHandle)(n,()=>({editor:se,capabilities:os,getScene:()=>se?.scene??Dc,loadScene:ne=>se?.loadScene(ne),getMode:()=>se?.mode??null,setMode:ne=>se?.setMode(ne),getSelection:()=>se?.selection??new Set,setSelection:ne=>se?.setSelection(ne),undo:()=>{se?.undo()},redo:()=>{se?.redo()},zoomToFit:()=>{se?.zoomToFit()}}),[se,Dc,os]),os?AL&&!Iy?(0,R.jsx)("div",{className:ts,style:ns}):os.renderer==="webgl2"&&os.wasmText&&!lM&&AL?(0,R.jsx)("div",{className:ts,style:ns}):(0,R.jsx)(Bd,{container:oM,children:(0,R.jsx)(iL,{children:(0,R.jsx)(k1,{children:(0,R.jsx)("div",{className:ts,"data-diagram-root":!0,..._p==="system"?{}:{"data-theme":_p},style:{position:"relative",width:"100%",height:"100%",background:"var(--du-canvas-bg)",...ns},children:(0,R.jsx)(Uv,{initialScene:Dc,initialMode:a,onReady:uM,renderer:os.renderer,...os.renderer==="offscreen"?{workerFactory:m??Rv}:{},...Cp?{textShaper:Cp}:{},...Tp?{rasterizer:Tp}:{},children:(0,R.jsx)(mj,{hideTopBar:b,hideBottomBar:y,hideToolbar:g,hideLibraryButton:x,hideMainMenu:A,hideZoomControls:C,hideResetToContent:_,hideHelpButton:v,hideContextMenu:I,hideSelectionPanel:k,renderTopBarLeft:T,renderTopBarCenter:P,renderTopBarRight:N,renderBottomBarLeft:U,renderBottomBarCenter:q,renderBottomBarRight:te,renderMainMenuExtras:Z,onImportTemplates:ue,repositoryUrl:Ii,onConfirm:es,onNotify:Rc,theme:_p,changeTheme:aM})})})})})}):(0,R.jsx)("div",{className:ts,style:ns})});kp.displayName="Editor";var mj=({hideTopBar:e,hideBottomBar:t,hideToolbar:n,hideLibraryButton:o,hideMainMenu:a,hideZoomControls:r,hideResetToContent:s,hideHelpButton:i,hideContextMenu:l,hideSelectionPanel:c,renderTopBarLeft:u,renderTopBarCenter:d,renderTopBarRight:f,renderBottomBarLeft:p,renderBottomBarCenter:h,renderBottomBarRight:m,renderMainMenuExtras:b,onImportTemplates:y,repositoryUrl:g,onConfirm:x,onNotify:A,theme:C,changeTheme:_})=>{let v=j(),I=g===void 0?hj:g,k=x??(Re=>window.confirm(Re)),T=A??(Re=>{window.alert(Re)});oi();let P=iv(),N=$f(),[U,q]=(0,xe.useState)(!1),[te,Z]=(0,xe.useState)(!1);$A(()=>{Z(Re=>!Re)});let ue=240,$=12,re=!N&&U?ue+$:$,We=(0,xe.useMemo)(()=>o?[...by]:[{kind:"action",id:"toggle-library",label:(0,R.jsx)(cd,{...Cy}),title:"Templates library",active:U,onClick:()=>{q(Re=>!Re)}},{kind:"divider"},...by],[o,U]);return(0,R.jsxs)("div",{style:{position:"absolute",inset:0},onDragEnter:P.onDragEnter,onDragOver:P.onDragOver,onDragLeave:P.onDragLeave,onDrop:P.onDrop,children:[(0,R.jsxs)("div",{style:{position:"absolute",top:0,bottom:0,left:0,right:0},children:[(0,R.jsx)(Gv,{style:{position:"absolute",inset:0}}),(0,R.jsx)(Zv,{}),(0,R.jsx)(Xv,{}),(0,R.jsx)(Yv,{}),(0,R.jsx)(Kv,{}),(0,R.jsx)($v,{}),!l&&(0,R.jsx)(oL,{items:rL})]}),n?null:(0,R.jsx)(eL,{orientation:"vertical",items:We,style:{position:"absolute",top:"50%",left:`calc(env(safe-area-inset-left, 0px) + ${re}px)`,transform:"translateY(-50%)",zIndex:60}}),(0,R.jsxs)(C1,{children:[!e&&(0,R.jsx)(T1,{left:(0,R.jsxs)(Os,{ariaLabel:"Logo and main menu",children:[(0,R.jsx)("span",{"aria-label":"Diagram",title:"Diagram",className:"du-icon-button",style:{minWidth:36,padding:"0 10px",cursor:"default",fontWeight:600,letterSpacing:.5},children:"\u2317"}),!a&&(0,R.jsxs)(Q,{children:[(0,R.jsxs)(Q.Group,{title:"File",children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(td,{...gt}),onClick:()=>{Lj(v,T)},children:"Open\u2026"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(ed,{...gt}),onClick:()=>{v&&vj(v.scene)},disabled:!v,children:"Save as JSON"}),(0,R.jsxs)(Q.Submenu,{icon:(0,R.jsx)(kl,{...gt}),label:"Export\u2026",disabled:!v,children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(_s,{...gt}),onClick:()=>v&&void hL(v,"transparent",T),disabled:!v,children:"PNG (transparent)"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(_s,{...gt}),onClick:()=>v&&void hL(v,"color",T),disabled:!v,children:"PNG (with background)"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(_s,{...gt}),onClick:()=>v&&void hL(v,"color-and-grid",T),disabled:!v,children:"PNG (with background + grid)"}),(0,R.jsx)(Q.Separator,{}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(kl,{...gt}),onClick:()=>{v&&wj(v.scene)},disabled:!v,children:"SVG"})]}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Ld,{...gt}),onClick:()=>{v&&k("Reset canvas? This clears all shapes.")&&v.clear()},disabled:!v,children:"Reset canvas"})]}),(0,R.jsx)(Q.Separator,{}),(0,R.jsxs)(Q.Group,{title:"Edit",children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Es,{...gt}),shortcut:"\u2318Z",onClick:()=>v?.undo(),disabled:!v,children:"Undo"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Is,{...gt}),shortcut:"\u21E7\u2318Z",onClick:()=>v?.redo(),disabled:!v,children:"Redo"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Sd,{...gt}),shortcut:"\u2318X",onClick:()=>v?.cutSelected(),disabled:!v,children:"Cut"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(ws,{...gt}),shortcut:"\u2318C",onClick:()=>v?.copySelected(),disabled:!v,children:"Copy"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)($u,{...gt}),shortcut:"\u2318V",onClick:()=>v?.paste(),disabled:!v,children:"Paste"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(xd,{...gt}),shortcut:"\u2318A",onClick:()=>v?.selectAll(),disabled:!v,children:"Select all"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Qu,{...gt}),shortcut:"\u232B",onClick:()=>v?.deleteSelected(),disabled:!v,children:"Delete selected"})]}),(0,R.jsx)(Q.Separator,{}),(0,R.jsxs)(Q.Group,{title:"View",children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(wl,{...gt}),shortcut:"\u21E7F",onClick:()=>v?.zoomToFit(),disabled:!v,children:"Fit to screen"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Pd,{...gt}),shortcut:"\u2318+",onClick:()=>v?.zoomIn(),disabled:!v,children:"Zoom in"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Dd,{...gt}),shortcut:"\u2318\u2212",onClick:()=>v?.zoomOut(),disabled:!v,children:"Zoom out"})]}),(0,R.jsx)(Q.Separator,{}),(0,R.jsx)(Q.Group,{title:"Theme",children:(0,R.jsx)(Q.Toggle,{value:C,onChange:_,options:[{value:"light",label:"Light",icon:(0,R.jsx)(Td,{...Jr})},{value:"dark",label:"Dark",icon:(0,R.jsx)(yd,{...Jr})},{value:"system",label:"System",icon:(0,R.jsx)(md,{...Jr})}]})}),(0,R.jsx)(Q.Group,{title:"Grid",children:(0,R.jsx)(Q.Toggle,{value:Cj(v),onChange:Re=>{Ij(v,Re)},options:[{value:"lines",label:"Lines",icon:(0,R.jsx)(so,{...Jr})},{value:"dots",label:"Dots",icon:(0,R.jsx)(rd,{...Jr})},{value:"off",label:"Off",icon:(0,R.jsx)(ma,{...Jr})}]})}),(0,R.jsx)(Q.Group,{title:"Snap to grid",children:(0,R.jsx)(Q.Toggle,{value:Tj(v),onChange:Re=>{v?.setSnapToGrid(Re==="on")},options:[{value:"on",label:"On",icon:(0,R.jsx)(pd,{...Jr})},{value:"off",label:"Off",icon:(0,R.jsx)(ma,{...Jr})}]})}),(0,R.jsx)(Q.Separator,{}),(0,R.jsxs)(Q.Group,{title:"Help",children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(gn,{...gt}),shortcut:"?",onClick:()=>{Z(!0)},children:"Hotkeys"}),I?(0,R.jsx)(Q.ItemLink,{href:I,external:!0,children:"GitHub"}):null]}),b?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Q.Separator,{}),b()]}):null]}),u?u():null]}),center:d?.(),right:(0,R.jsx)(Os,{ariaLabel:"Top bar actions",children:f?f():null})}),!t&&(0,R.jsx)(I1,{left:p?p():null,center:h?h():s?null:(0,R.jsx)(tv,{}),right:m?m():r?i?null:(0,R.jsx)(R0,{}):(0,R.jsx)(Aj,{trailing:i?void 0:(0,R.jsx)(R0,{})})}),N?U?(0,R.jsx)(Vv,{snapPoints:[0,60,92],defaultValue:60,style:{pointerEvents:"auto"},onChange:Re=>{Re<=0&&q(!1)},children:(0,R.jsx)(G0,{open:!0,sheet:!0,onClose:()=>{q(!1)},...y?{onImport:y}:{}})}):null:(0,R.jsx)(G0,{open:U,side:"left",style:{left:0},onClose:()=>{q(!1)},...y?{onImport:y}:{}})]}),!c&&(0,R.jsx)(Sv,{}),(0,R.jsx)(Yf,{open:te,onClose:()=>{Z(!1)}}),(0,R.jsx)(sL,{}),void 0]})},yj=Bt({meta:!0,key:"\u2212"}),gj=Bt({meta:!0,key:"+"}),xj=Bt({meta:!0,key:"0"}),bj=Bt({alt:!0,key:"1"}),Aj=({trailing:e})=>{let t=j(),[,n]=(0,xe.useState)(0);if((0,xe.useEffect)(()=>{if(t)return t.subscribe(()=>{n(a=>a+1)})},[t]),!t)return null;let o=t.scene.viewport.zoom;return(0,R.jsxs)(Os,{ariaLabel:"Zoom",children:[(0,R.jsx)(Bn,{label:`Zoom out (${yj})`,onClick:()=>{t.zoomOut()},children:(0,R.jsx)(ma,{...Cy})}),(0,R.jsx)(Ms,{content:`Reset zoom to 100% (${xj})`,children:(0,R.jsxs)("button",{type:"button",className:"du-icon-button","aria-label":"Reset zoom to 100%",onClick:()=>{t.resetZoom()},style:{minWidth:56,padding:"0 8px",borderRadius:0},children:[Math.round(o*100),"%"]})}),(0,R.jsx)(Bn,{label:`Zoom in (${gj})`,onClick:()=>{t.zoomIn()},children:(0,R.jsx)(Ts,{...Cy})}),(0,R.jsx)(Bn,{label:`Fit to screen (${bj})`,onClick:()=>{t.zoomToFit()},children:(0,R.jsx)(wl,{...Cy})}),e]})},yL=(e,t)=>{let n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),requestAnimationFrame(()=>{URL.revokeObjectURL(n)})},vj=e=>{let t=qv(e,2);yL(new Blob([t],{type:"application/json"}),"scene.diagram.json")},Lj=(e,t)=>{if(!e)return;let n=document.createElement("input");n.type="file",n.accept="application/json,.json",n.onchange=()=>{let o=n.files?.[0];o&&o.text().then(a=>{try{let r=jv(a);e.loadScene(r)}catch(r){console.error("[diagram] failed to parse scene file:",r),t("Failed to parse the file \u2014 make sure it was saved through this app's Save action.")}})},n.click()},Sj=2,hL=async(e,t,n)=>{let o=kj(),a=await Y6(e.scene,{background:t,scale:Sj,backgroundColor:o});if(!a){n("Nothing to export \u2014 the canvas is empty.");return}yL(a,"scene.png")},kj=()=>{let e=document.querySelector('canvas[data-layer="main"]')??document.body;return getComputedStyle(e).getPropertyValue("--du-canvas-bg").trim()||"#ffffff"},wj=e=>{let t=nL(e);yL(new Blob([t],{type:"image/svg+xml"}),"scene.svg")},_j=(e,t,n)=>({viewport:{...e!==void 0?{gridEnabled:e}:{},...t!==void 0?{gridStyle:t}:{},...n!==void 0?{snapToGrid:n}:{}}}),Cj=e=>{if(!e)return"lines";let t=e.scene.viewport;return t.gridEnabled?t.gridStyle??"lines":"off"},Tj=e=>e?.snapToGridEnabled??!0?"on":"off",Ij=(e,t)=>{if(e){if(t==="off"){e.setGrid({enabled:!1});return}e.setGrid({enabled:!0,style:t})}};var K6=`/**
|
|
167
|
+
${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id)}},{kind:"divider"},{kind:"action",id:"open-thread",label:"Open thread",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.setSelectedAnnotation(n)}},{kind:"action",id:"resolve-annotation",label:"Toggle resolved",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.toggleAnnotationResolved(n)}},{kind:"action",id:"remove-annotation",label:"Delete annotation",visible:(e,t)=>e.hitAnnotation(t.worldPoint)!==null,onClick:(e,t)=>{let n=e.hitAnnotation(t.worldPoint);n&&e.removeAnnotation(n)}},{kind:"action",id:"add-comment",label:"Add comment",visible:(e,t)=>e.hitAnnotation(t.worldPoint)===null,onClick:(e,t)=>{let n=[...e.scene.elements.values()].reverse().find(a=>{let r=a.position,s="width"in a&&typeof a.width=="number"?a.width:0,i="height"in a&&typeof a.height=="number"?a.height:0;return t.worldPoint.x>=r.x&&t.worldPoint.y>=r.y&&t.worldPoint.x<=r.x+s&&t.worldPoint.y<=r.y+i}),o=n?{x:t.worldPoint.x-n.position.x,y:t.worldPoint.y-n.position.y}:t.worldPoint;e.addAnnotation({position:o,elementId:n?.id??null})}},{kind:"divider"},Ce("zoom-in"),Ce("zoom-out"),Ce("zoom-reset",{label:"Reset zoom (100%)"}),Ce("zoom-to-fit",{label:"Fit to screen",visible:e=>e.scene.elements.size>0}),{kind:"divider"},{kind:"action",id:"clear-canvas",label:"Clear canvas",visible:e=>!e.readOnly&&(e.scene.elements.size>0||e.scene.links.size>0),onClick:e=>{WL(e)}}];var cr=P(se(),1),Bn=P(re(),1);var jL=()=>{let e=G(),[t,n]=(0,Bn.useState)(!1),[o,a]=(0,Bn.useState)(""),[r,s]=(0,Bn.useState)(0),i=(0,Bn.useRef)(null);(0,Bn.useEffect)(()=>(_e.replace({id:"open-command-palette",label:"Command palette",category:"other",hotkey:[{key:"k",meta:!0},{key:"p",meta:!0,shift:!0}],perform:()=>{n(!0)}}),_e.replace({id:"clear-canvas",label:"Clear canvas",category:"edit",hotkey:[{key:"Delete",meta:!0},{key:"Backspace",meta:!0}],predicate:({editor:m})=>m.scene.elements.size>0||m.scene.links.size>0,perform:({editor:m})=>{WL(m)}}),()=>{_e.unregister("open-command-palette"),_e.unregister("clear-canvas")}),[]);let l=(0,Bn.useMemo)(()=>_e.getAll().filter(m=>m.label!==void 0&&m.id!=="open-command-palette"),[t]),c=e?{editor:e}:null,u=(0,Bn.useMemo)(()=>{let m=o.trim().toLowerCase();return(m?l.filter(y=>(y.label??"").toLowerCase().includes(m)):l).map(y=>({action:y,enabled:c?y.predicate?y.predicate(c):!0:!1}))},[l,o,c]);if((0,Bn.useEffect)(()=>{if(!t)return;a(""),s(0);let m=requestAnimationFrame(()=>i.current?.focus());return()=>{cancelAnimationFrame(m)}},[t]),(0,Bn.useEffect)(()=>{s(0)},[o]),!t)return null;let d=()=>{n(!1)},f=m=>{!m.enabled||!c||(d(),_e.dispatch(m.action.id,c))},p=m=>{if(m.key==="ArrowDown")m.preventDefault(),s(x=>Math.min(u.length-1,x+1));else if(m.key==="ArrowUp")m.preventDefault(),s(x=>Math.max(0,x-1));else if(m.key==="Enter"){m.preventDefault();let x=u[r];x&&f(x)}},h=(m,x)=>({display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"8px 14px",cursor:x?"pointer":"default",opacity:x?1:.4,background:m===r?"var(--du-ui-hover, rgba(0,0,0,0.06))":"transparent"});return(0,cr.jsxs)(Ky,{open:t,onClose:d,title:"Command palette",style:TY,children:[(0,cr.jsx)("input",{ref:i,value:o,onChange:m=>{a(m.target.value)},onKeyDown:p,placeholder:"Search commands\u2026","aria-label":"Search commands",style:IY}),(0,cr.jsx)("ul",{style:MY,role:"listbox",children:u.length===0?(0,cr.jsx)("li",{style:{padding:"12px 14px",opacity:.6},children:"No commands"}):u.map((m,x)=>{let y=EY(m.action);return(0,cr.jsxs)("li",{role:"option","aria-selected":x===r,"aria-disabled":!m.enabled,style:h(x,m.enabled),onPointerEnter:()=>{s(x)},onClick:()=>{f(m)},children:[(0,cr.jsx)("span",{children:m.action.label}),y?(0,cr.jsx)("kbd",{style:RY,children:y}):null]},m.action.id)})})]})},EY=e=>{if(e.hotkey){let n=(Array.isArray(e.hotkey)?e.hotkey:[e.hotkey])[0];if(n)return ut(n)}return e.sequence&&e.sequence.length>0?e.sequence.map(t=>t.length===1?t.toUpperCase():t).join(" "):null},TY={maxWidth:520,width:"calc(100vw - 64px)",padding:0,display:"flex",flexDirection:"column",overflow:"hidden"},IY={border:"none",borderBottom:"1px solid var(--du-ui-border)",outline:"none",padding:"14px 16px",fontSize:15,background:"transparent",color:"inherit"},MY={listStyle:"none",margin:0,padding:4,maxHeight:360,overflowY:"auto"},RY={fontSize:11,color:"var(--du-text-muted, #6b6b6b)",fontFamily:"inherit"};var vs=P(se(),1),Nn=P(re(),1);var ZL=()=>{let e=G(),t=Ya(),[n,o]=(0,Nn.useState)(!1),[a,r]=(0,Nn.useState)(""),[s,i]=(0,Nn.useState)(0),l=(0,Nn.useRef)(null);(0,Nn.useEffect)(()=>(_e.replace({id:"open-search",label:"Find text",category:"other",viewMode:!0,hotkey:{key:"f",meta:!0},perform:()=>{o(!0)}}),()=>{_e.unregister("open-search")}),[]);let c=(0,Nn.useMemo)(()=>a.trim()?$v(t,a):[],[t,a]),u=(0,Nn.useRef)(c);if(u.current=c,(0,Nn.useEffect)(()=>{if(!n||!e)return;let m=u.current[s];m&&(m.kind==="element"?e.setSelection([m.id]):e.selectLink(m.id),e.revealSelection(SE))},[n,s,a,e]),(0,Nn.useEffect)(()=>{if(!n)return;r(""),i(0);let m=requestAnimationFrame(()=>l.current?.focus());return()=>{cancelAnimationFrame(m)}},[n]),!n)return null;let d=()=>{r(""),i(0),o(!1)},f=m=>{c.length!==0&&i(x=>(x+m+c.length)%c.length)},p=m=>{m.key==="Escape"?(m.preventDefault(),m.stopPropagation(),d()):m.key==="Enter"?(m.preventDefault(),f(m.shiftKey?-1:1)):m.key==="ArrowDown"?(m.preventDefault(),f(1)):m.key==="ArrowUp"&&(m.preventDefault(),f(-1))},h=c.length===0?a.trim()?"No results":"":`${String(s+1)} of ${String(c.length)}`;return(0,vs.jsxs)("div",{style:OY,role:"search",children:[(0,vs.jsx)("input",{ref:l,value:a,onChange:m=>{r(m.target.value),i(0)},onKeyDown:p,placeholder:"Find in diagram\u2026","aria-label":"Find text in diagram",style:DY}),(0,vs.jsx)("span",{style:PY,"aria-live":"polite",children:h}),(0,vs.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Previous match",title:"Previous (\u21E7\u23CE)",disabled:c.length===0,onClick:()=>{f(-1)},style:VL,children:"\u2191"}),(0,vs.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Next match",title:"Next (\u23CE)",disabled:c.length===0,onClick:()=>{f(1)},style:VL,children:"\u2193"}),(0,vs.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Close search",title:"Close (Esc)",onClick:d,style:VL,children:"\u2715"})]})},OY={position:"absolute",top:64,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:6,padding:"6px 8px",borderRadius:10,background:"var(--du-ui-bg-solid)",border:"1px solid var(--du-ui-border)",boxShadow:"0 6px 24px rgba(0,0,0,0.18)",color:"var(--du-text)",zIndex:80,pointerEvents:"auto"},DY={border:"none",outline:"none",padding:"4px 8px",fontSize:14,minWidth:180,background:"transparent",color:"inherit"},PY={fontSize:12,color:"var(--du-text-muted)",minWidth:56,textAlign:"right",whiteSpace:"nowrap"},VL={minWidth:28,height:28};var at=P(se(),1),pu=P(re(),1);var XL=()=>{let e=G(),[t,n]=(0,pu.useState)(!1),[,o]=(0,pu.useState)(0);if((0,pu.useEffect)(()=>(_e.replace({id:"toggle-stats",label:"Stats panel",category:"other",viewMode:!0,hotkey:{key:"/",alt:!0},perform:()=>{n(u=>!u)}}),()=>{_e.unregister("toggle-stats")}),[]),(0,pu.useEffect)(()=>{if(!(!e||!t))return e.subscribe(()=>{o(u=>u+1)})},[e,t]),!t||!e)return null;let a=e.combinedSelectionBounds(),r=e.selection.size,s=e.selectedLinks.size,i=r+s,l=e.scene,c=null;if(r===1&&s===0){let u=[...e.selection][0],d=u?l.elements.get(u):void 0;d&&(c=d.rotation*180/Math.PI)}return(0,at.jsxs)("div",{style:BY,role:"status","aria-label":"Selection stats","aria-live":"polite",children:[(0,at.jsx)("div",{style:d6,children:"Selection"}),a?(0,at.jsxs)(at.Fragment,{children:[(0,at.jsx)(ur,{label:"X",value:Ah(a.x)}),(0,at.jsx)(ur,{label:"Y",value:Ah(a.y)}),(0,at.jsx)(ur,{label:"W",value:Ah(a.width)}),(0,at.jsx)(ur,{label:"H",value:Ah(a.height)}),c!==null?(0,at.jsx)(ur,{label:"\u2220",value:`${String(Ah(c))}\xB0`}):null,i>1?(0,at.jsx)(ur,{label:"Count",value:String(i)}):null]}):(0,at.jsx)("div",{style:HY,children:"Nothing selected"}),(0,at.jsx)("div",{style:{...d6,marginTop:8},children:"Scene"}),(0,at.jsx)(ur,{label:"Elements",value:String(l.elements.size)}),(0,at.jsx)(ur,{label:"Edges",value:String(l.links.size)}),(0,at.jsx)(ur,{label:"Selected",value:String(i)})]})},Ah=e=>Math.round(e*10)/10,ur=({label:e,value:t})=>(0,at.jsxs)("div",{style:NY,children:[(0,at.jsx)("span",{style:zY,children:e}),(0,at.jsx)("span",{style:FY,children:t})]}),BY={position:"absolute",top:64,right:12,minWidth:148,padding:"8px 10px",borderRadius:10,background:"var(--du-ui-bg-solid)",border:"1px solid var(--du-ui-border)",boxShadow:"0 6px 24px rgba(0,0,0,0.18)",color:"var(--du-text)",fontSize:12,zIndex:80,pointerEvents:"auto"},d6={fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"var(--du-text-muted)",marginBottom:4},NY={display:"flex",justifyContent:"space-between",gap:12,lineHeight:"18px"},zY={color:"var(--du-text-muted)"},FY={fontVariantNumeric:"tabular-nums",fontFamily:"ui-monospace, monospace"},HY={color:"var(--du-text-muted)",fontStyle:"italic"};var f6=P(se(),1),zn=P(re(),1);var p6=(0,zn.createContext)(null),YL=({children:e})=>{let[t,n]=(0,zn.useState)(!1),o=(0,zn.useCallback)(()=>{n(r=>!r)},[]);(0,zn.useEffect)(()=>(_e.replace({id:"toggle-zen-mode",label:"Zen mode",category:"other",viewMode:!0,hotkey:{key:"z",alt:!0},perform:()=>{n(r=>!r)}}),()=>{_e.unregister("toggle-zen-mode")}),[]),(0,zn.useEffect)(()=>{if(!t)return;let r=s=>{s.key==="Escape"&&n(!1)};return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r)}},[t]);let a=(0,zn.useMemo)(()=>({zen:t,setZen:n,toggle:o}),[t,o]);return(0,f6.jsx)(p6.Provider,{value:a,children:e})},KL=()=>{let e=(0,zn.useContext)(p6);if(!e)throw new Error("@oh-just-another/react-ui: useZenMode called outside <ZenModeProvider>.");return e};var dr=P(se(),1),Fn=P(re(),1);var UY=(0,Fn.createContext)(null);var $L=({children:e,defaultDuration:t=3e3,style:n})=>{let[o,a]=(0,Fn.useState)([]),r=(0,Fn.useRef)(0),s=(0,Fn.useCallback)(c=>{a(u=>u.filter(d=>d.id!==c))},[]),i=(0,Fn.useCallback)((c,u="info",d)=>{let f=`toast-${++r.current}`,p=d??t;return a(h=>[...h,{id:f,kind:u,message:c,duration:p}]),p>0&&Number.isFinite(p)&&window.setTimeout(()=>{s(f)},p),f},[t,s]),l=(0,Fn.useMemo)(()=>({push:i,dismiss:s}),[i,s]);return(0,dr.jsxs)(UY.Provider,{value:l,children:[e,(0,dr.jsx)(GY,{toasts:o,onDismiss:s,...n?{style:n}:{}})]})},GY=({toasts:e,onDismiss:t,style:n})=>{let o={position:"fixed",top:16,right:16,zIndex:1100,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none",...n};return(0,dr.jsx)("div",{style:o,"aria-live":"polite","aria-atomic":"false",children:e.map(a=>(0,dr.jsx)(qY,{toast:a,onDismiss:t},a.id))})},WY={info:"var(--accent, #1a73e8)",success:"#2e8b57",warn:"#c79100",error:"#c83232"},qY=({toast:e,onDismiss:t})=>{let n={pointerEvents:"auto",minWidth:240,maxWidth:360,padding:"10px 12px",background:"var(--panel, #1a1a1a)",color:"var(--text, #ddd)",border:"1px solid var(--border, #2a2a2a)",borderLeft:`4px solid ${WY[e.kind]}`,borderRadius:4,boxShadow:"0 4px 14px rgba(0, 0, 0, 0.3)",fontSize:13,display:"flex",alignItems:"flex-start",gap:12};return(0,dr.jsxs)("div",{role:"status",style:n,children:[(0,dr.jsx)("span",{style:{flex:1,lineHeight:1.35},children:e.message}),(0,dr.jsx)("button",{type:"button","aria-label":"Dismiss",onClick:()=>{t(e.id)},style:{background:"transparent",border:"none",color:"var(--muted, #888)",cursor:"pointer",fontSize:16,lineHeight:1,padding:0},children:"\xD7"})]})};var Xe=P(se(),1),At=P(re(),1);var jY=16,VY=1.75,h6=(0,At.createContext)(null),m6=()=>(0,At.useContext)(h6)??{close:()=>{}},$=({children:e,trigger:t=(0,Xe.jsx)(Qd,{size:jY,strokeWidth:VY}),className:n,style:o})=>{let[a,r]=(0,At.useState)(!1),s=(0,At.useRef)(null),i=(0,At.useId)();(0,At.useEffect)(()=>{if(!a)return;let d=p=>{s.current&&(s.current.contains(p.target)||r(!1))},f=p=>{p.key==="Escape"&&r(!1)};return window.addEventListener("mousedown",d),window.addEventListener("pointerdown",d),window.addEventListener("keydown",f),()=>{window.removeEventListener("mousedown",d),window.removeEventListener("pointerdown",d),window.removeEventListener("keydown",f)}},[a]);let l=(0,At.useCallback)(()=>{r(!1)},[]),c={position:"relative",display:"inline-flex",...o},u={position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:200,background:"var(--menu-bg)",color:"var(--menu-text)",border:"1px solid var(--menu-border)",borderRadius:6,boxShadow:"var(--du-ui-shadow)",padding:4,zIndex:900};return(0,Xe.jsxs)("div",{ref:s,className:n,style:c,children:[(0,Xe.jsx)("button",{type:"button",className:`du-icon-button du-icon-button-flat${a?" is-active":""}`,"aria-haspopup":"menu","aria-expanded":a,"aria-controls":i,"aria-label":"Main menu",title:"Main menu",onClick:()=>{r(d=>!d)},children:t}),a?(0,Xe.jsx)("div",{id:i,role:"menu",style:u,children:(0,Xe.jsx)(h6.Provider,{value:{close:l},children:e})}):null]})},ZY={display:"block",width:"100%",textAlign:"left",background:"transparent",color:"inherit",border:"none",borderRadius:4,padding:"6px 10px",font:"inherit",fontSize:13,cursor:"pointer"},QL=e=>({...ZY,...e}),XY=({children:e,onClick:t,shortcut:n,disabled:o,active:a,icon:r})=>{let{close:s}=m6();return(0,Xe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,onClick:()=>{o||(t?.(),s())},style:{...QL(),cursor:o?"not-allowed":"pointer",opacity:o?.4:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,Xe.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,Xe.jsx)("span",{"aria-hidden":!0,style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",color:a?"var(--du-accent, #1a73e8)":"var(--du-text-muted, #888)"},children:a?(0,Xe.jsx)(Ed,{size:12,strokeWidth:2.25}):r??""}),e]}),n?(0,Xe.jsx)("span",{style:{color:"var(--muted, #888)",fontSize:11},children:n}):null]})},YY=({children:e,href:t,external:n})=>{let{close:o}=m6();return(0,Xe.jsx)("a",{role:"menuitem",href:t,target:n?"_blank":void 0,rel:n?"noreferrer noopener":void 0,onClick:o,style:{...QL({textDecoration:"none"}),color:"var(--text, #ddd)"},children:e})},KY=()=>(0,Xe.jsx)("hr",{style:{margin:"4px 6px",border:"none",borderTop:"1px solid var(--border, #2a2a2a)"}}),$Y=({title:e,children:t})=>(0,Xe.jsxs)("div",{children:[(0,Xe.jsx)("div",{style:{padding:"6px 10px 2px",fontSize:11,textTransform:"uppercase",letterSpacing:.5,color:"var(--muted, #888)"},children:e}),t]}),QY=({value:e,onChange:t,options:n})=>(0,Xe.jsx)("div",{role:"radiogroup",style:{display:"flex",margin:"4px 8px 6px",background:"var(--menu-divider, #2a2a2a)",borderRadius:6,padding:2,gap:2},children:n.map(o=>{let a=o.value===e;return(0,Xe.jsx)("button",{type:"button",role:"radio","aria-checked":a,title:o.label,"aria-label":o.label,onClick:()=>{t(o.value)},style:{flex:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,minHeight:26,padding:"0 8px",background:a?"var(--menu-bg, #1a1a1a)":"transparent",color:a?"var(--text, #ddd)":"var(--muted, #888)",border:"none",borderRadius:4,cursor:"pointer",fontSize:12,fontWeight:a?600:400,boxShadow:a?"0 1px 2px rgba(0, 0, 0, 0.15)":"none",transition:"background 0.12s ease, color 0.12s ease"},children:o.icon??o.label},o.value)})}),JY=120,eK=({children:e,label:t,icon:n,disabled:o})=>{let[a,r]=(0,At.useState)(!1),s=(0,At.useRef)(null),i=(0,At.useCallback)(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null)},[]),l=(0,At.useCallback)(()=>{i(),s.current=window.setTimeout(()=>{r(!1),s.current=null},JY)},[i]);(0,At.useEffect)(()=>i,[i]);let c={position:"absolute",top:-4,left:"100%",marginLeft:4,minWidth:220,background:"var(--menu-bg)",color:"var(--menu-text)",border:"1px solid var(--menu-border)",borderRadius:6,boxShadow:"var(--du-ui-shadow)",padding:4,zIndex:1e3};return(0,Xe.jsxs)("div",{style:{position:"relative"},onMouseEnter:()=>{o||(i(),r(!0))},onMouseLeave:l,children:[(0,Xe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,"aria-haspopup":"menu","aria-expanded":a,onClick:()=>{o||(i(),r(u=>!u))},style:{...QL(),cursor:o?"not-allowed":"pointer",opacity:o?.4:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,Xe.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,Xe.jsx)("span",{"aria-hidden":!0,style:{width:14,height:14,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--du-text-muted, #888)"},children:n??""}),t]}),(0,Xe.jsx)(Xs,{size:12,strokeWidth:2.25,"aria-hidden":!0})]}),a?(0,Xe.jsx)("div",{role:"menu",style:c,children:e}):null]})};$.Item=XY;$.ItemLink=YY;$.Separator=KY;$.Group=$Y;$.Toggle=QY;$.Submenu=eK;var vh=class e{cacheSize;fallbackFactor;cache=new Map;wasm=null;currentFontKey=null;textEncoder=new TextEncoder;constructor(t={}){this.cacheSize=t.cacheSize??1e4,this.fallbackFactor=t.fallbackAdvanceFactor??.55}get isReady(){return this.wasm!==null}async loadModule(t){let n=await _p(t,"WasmTextShaper.loadModule");this.wasm=n.exports,this.cache.clear(),this.currentFontKey=null}static async loadBundled(){let t=new e,n=new URL("../wasm/text_shaper.wasm",import.meta.url);return await t.loadModule(n),t}measure(t,n){let o=`${y6(n)}|${t}`,a=this.cache.get(o);if(a)return this.cache.delete(o),this.cache.set(o,a),a;let r=this.wasm?this.measureViaWasm(t,n,this.wasm):this.measureFallback(t,n);if(this.cache.size>=this.cacheSize){let s=this.cache.keys().next().value;s!==void 0&&this.cache.delete(s)}return this.cache.set(o,r),r}shape(t,n){let o=this.measure(t,n),a=t.length===0?0:o.width/t.length,r=[];for(let s=0;s<t.length;s++)r.push({glyphId:t.charCodeAt(s),advance:a,x:s*a,y:0});return r}resolveFontId(t,n=!1,o=!1){let a=this.wasm;if(!a?.resolveFont)return 0;let r=this.textEncoder.encode(t),{ptr:s,len:i,free:l}=as(a,r),c=a.resolveFont(s,i,n?1:0,o?1:0);return l(),c}glyphMetrics(t,n=0){let o=this.wasm;if(!o?.glyphMetrics)return null;let a=o.glyphMetrics(n,t),r=o.memory.buffer;if(a<=0||a+24>r.byteLength)return null;let s=new DataView(r,a,24);return{advance:s.getFloat32(0,!0),bboxXMin:s.getFloat32(4,!0),bboxYMin:s.getFloat32(8,!0),bboxW:s.getFloat32(12,!0),bboxH:s.getFloat32(16,!0),unitsPerEm:s.getFloat32(20,!0)}}rasterizeGlyphMSDF(t,n,o,a=0){let r=this.wasm;if(!r?.rasterizeGlyphMSDF)return null;let s=r.rasterizeGlyphMSDF(a,t,n,o),i=n*n*3,l=new Uint8Array(r.memory.buffer,s,i),c=new Uint8Array(l);return{atlasSize:n,range:o,data:c}}resetArena(){this.wasm?.reset?.(),this.currentFontKey=null}measureFallback(t,n){return{width:t.length*n.size*this.fallbackFactor}}measureViaWasm(t,n,o){let a=y6(n);if(a!==this.currentFontKey){let u=this.textEncoder.encode(n.family),d=as(o,u);o.setFont(d.ptr,d.len,n.size,0,0),d.free(),this.currentFontKey=a}let r=this.textEncoder.encode(t),{ptr:s,len:i,free:l}=as(o,r),c=o.measure(s,i);return l(),{width:c}}},y6=e=>`${e.family}|${e.size}|${e.weight??"normal"}|${e.style??"normal"}`;var tK={butt:0,round:1,square:2},nK={miter:0,round:1,bevel:2},oK={M:0,L:1,Q:2,C:3,Z:4},Lh=class e{defaultTolerance;wasm=null;constructor(t={}){this.defaultTolerance=t.defaultTolerance??.5}get isReady(){return this.wasm!==null}async loadModule(t){let n=await _p(t,"WasmRasterizer.loadModule");this.wasm=n.exports}static async loadBundled(t={}){let n=new e(t),o=new URL("../wasm/rasterizer.wasm",import.meta.url);return await n.loadModule(o),n}flatten(t,n){let o=n>0?n:this.defaultTolerance;return this.wasm?this.flattenViaWasm(t,o,this.wasm):by.flatten(t,o)}strokeToFill(t,n,o){return this.wasm?this.strokeToFillViaWasm(t,n,o,this.wasm):by.strokeToFill(t,n,o)}flattenViaWasm(t,n,o){let a=aK(t),r=as(o,new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),s=o.alloc(4),i=o.alloc(4);try{o.flattenF32(r.ptr,a.length,n,s,i);let l=Ug(o.memory,s),c=Ug(o.memory,i);return g6(o.memory,l,c)}finally{r.free(),o.free(s,4),o.free(i,4)}}strokeToFillViaWasm(t,n,o,a){let r=rK(t),s=as(a,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),i=a.alloc(4),l=a.alloc(4);try{let c=tK[o?.cap??"butt"],u=nK[o?.join??"miter"];a.strokeToFillF32(s.ptr,t.length,n,c,u,i,l);let d=Ug(a.memory,i),f=Ug(a.memory,l);return g6(a.memory,d,f)}finally{s.free(),a.free(i,4),a.free(l,4)}}},Sh=new Float32Array(256),x6=e=>{if(Sh.length>=e)return;let t=Sh.length;for(;t<e;)t*=2;Sh=new Float32Array(t)},aK=e=>{x6(e.length*7);let t=Sh,n=0;for(let o of e)switch(t[n++]=oK[o.kind],o.kind){case"M":case"L":t[n++]=o.to.x,t[n++]=o.to.y;break;case"Q":t[n++]=o.control.x,t[n++]=o.control.y,t[n++]=o.to.x,t[n++]=o.to.y;break;case"C":t[n++]=o.control1.x,t[n++]=o.control1.y,t[n++]=o.control2.x,t[n++]=o.control2.y,t[n++]=o.to.x,t[n++]=o.to.y;break;case"Z":break}return t.subarray(0,n)},rK=e=>{x6(e.length*2);let t=Sh;for(let n=0;n<e.length;n++){let o=e[n];t[n*2]=o?.x??0,t[n*2+1]=o?.y??0}return t.subarray(0,e.length*2)},Ug=(e,t)=>new DataView(e.buffer,t,4).getUint32(0,!0),g6=(e,t,n)=>{let o=new Float32Array(e.buffer,t,n*2),a=new Array(n);for(let r=0;r<n;r++)a[r]={x:v(o[r*2]),y:v(o[r*2+1])};return a};var A6=()=>typeof Worker<"u",b6=()=>typeof WebAssembly<"u"&&typeof WebAssembly.instantiate=="function",sK=()=>{if(typeof matchMedia!="function")return!1;try{return matchMedia("(pointer: coarse)").matches}catch{return!1}},iK=async()=>await vL()||SL()?"webgl2":Dg()&&A6()?"offscreen":"canvas2d",v6=async(e={})=>{let t=e.renderer&&e.renderer!=="auto"?e.renderer:await iK(),n=e.wasmText!==void 0&&e.wasmText!=="auto"?e.wasmText:b6(),o=e.wasmRaster!==void 0&&e.wasmRaster!=="auto"?e.wasmRaster:b6()&&t==="webgl2",a=e.workers!==void 0&&e.workers!=="auto"?e.workers:Dg()&&A6(),r=e.tiles!==void 0&&e.tiles!=="auto"?e.tiles:!0;return{renderer:t,wasmText:n,wasmRaster:o,workers:a,tiles:r,touch:sK()}},S6=e=>{let t=e.renderer==="webgl2"?"WebGL2":e.renderer==="offscreen"?"OffscreenCanvas + Worker":"Canvas2D";console.log("%c[diagram]%c renderer=%s, wasmText=%s, wasmRaster=%s, workers=%s, tiles=%s, touch=%s (%s)","color: #1a73e8; font-weight: 700","color: inherit",e.renderer,e.wasmText,e.wasmRaster,e.workers,e.tiles,e.touch,t)};var t3=new WeakMap,n3=new WeakSet,NK=async e=>{let{parseGIF:t,decompressFrames:n}=await Promise.resolve().then(()=>P(E6(),1)),o=t(e),a=n(o,!0),r=o.lsd.width,s=o.lsd.height;if(r<=0||s<=0||a.length===0)return{frames:[],totalMs:0};let i=new OffscreenCanvas(r,s),l=i.getContext("2d"),c=new OffscreenCanvas(r,s),u=c.getContext("2d");if(!l||!u)return{frames:[],totalMs:0};let d=[],f=0;for(let p of a){let h=new ImageData(new Uint8ClampedArray(p.patch),p.dims.width,p.dims.height);c.width=p.dims.width,c.height=p.dims.height,u.putImageData(h,0,0),l.drawImage(c,p.dims.left,p.dims.top);let m=await createImageBitmap(i);f+=p.delay>0?p.delay:100,d.push({bitmap:m,endMs:f}),p.disposalType===2&&l.clearRect(p.dims.left,p.dims.top,p.dims.width,p.dims.height)}return{frames:d,totalMs:f}},zK={kind:"gif",getFrameAt(e,t){if(!(e instanceof ArrayBuffer)||e.byteLength===0)return null;let n=t3.get(e);if(!n)return n3.has(e)||(n3.add(e),NK(e).then(r=>{t3.set(e,r),_v()}).catch(()=>{}).finally(()=>n3.delete(e))),null;if(n.frames.length===0)return null;let o=n.totalMs>0?t%n.totalMs:0;for(let r of n.frames)if(o<r.endMs)return r.bitmap;let a=n.frames[n.frames.length-1];return a?a.bitmap:null},totalDurationMs(e){return t3.get(e)?.totalMs??0}},T6=!1,I6=()=>{T6||(T6=!0,Lp(zK))};var kh=P(re(),1);var M6=e=>{let t=Dt(),[n]=(0,kh.useState)(()=>typeof document>"u"?null:document.createElement("div"));return(0,kh.useEffect)(()=>{if(n)return n.setAttribute("data-diagram-portal",""),t.appendChild(n),()=>{n.remove()}},[n,t]),(0,kh.useEffect)(()=>{n&&(e==="system"?n.removeAttribute("data-theme"):n.setAttribute("data-theme",e))},[n,e]),n};var a3=async(e,t)=>{if(typeof OffscreenCanvas>"u")return null;let n=FK(e);if(!n)return null;let o={x:n.x-20,y:n.y-20,width:n.width+40,height:n.height+40},a=Math.max(1,Math.ceil(o.width*t.scale)),r=Math.max(1,Math.ceil(o.height*t.scale)),{canvas:s,target:i}=pL(a,r);t.background!=="transparent"&&(i.setFill(t.backgroundColor),i.beginPath(),i.rect(0,0,a,r),i.fill());let l={...e,viewport:{pan:{x:o.x,y:o.y},zoom:t.scale,rotation:0,size:{width:a,height:r},gridEnabled:e.viewport.gridEnabled,...e.viewport.gridStyle!==void 0?{gridStyle:e.viewport.gridStyle}:{}}};return t.background==="color-and-grid"&&l.viewport.gridEnabled&&Sp(l,i),Za(l,i,{skipClear:!0}),Pn(l,i),s.convertToBlob({type:"image/png"})},FK=e=>{let t=null;for(let n of vo(e))if(n.visible)for(let o of Ua(e,n.id)){let a=z(o);t=t?HK(t,a):a}return t},HK=(e,t)=>{let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(e.x+e.width,t.x+t.width),r=Math.max(e.y+e.height,t.y+t.height);return{x:n,y:o,width:a-n,height:r-o}};var R6=2,hu=e=>{typeof window<"u"&&window.alert(e)},O6=e=>{hu=e},r3=(e,t)=>{let n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),requestAnimationFrame(()=>{URL.revokeObjectURL(n)})},s3=e=>{let t=CL(e,2);r3(new Blob([t],{type:"application/json"}),"scene.diagram.json")},i3=e=>{if(typeof document>"u")return;let t=document.createElement("input");t.type="file",t.accept="application/json,.json",t.onchange=()=>{let n=t.files?.[0];n&&n.text().then(o=>{try{let a=TL(o);e.loadScene(a)}catch(a){console.error("[diagram] failed to parse scene file:",a),hu("Failed to parse the file \u2014 make sure it was saved through this app's Save action.")}})},t.click()},D6=()=>{if(typeof document>"u")return"#ffffff";let e=document.querySelector('canvas[data-layer="main"]')??document.body;return getComputedStyle(e).getPropertyValue("--du-canvas-bg").trim()||"#ffffff"},wh=async(e,t)=>{let n=await a3(e.scene,{background:t,scale:R6,backgroundColor:D6()});if(!n){hu("Nothing to export \u2014 the canvas is empty.");return}r3(n,"scene.png")},P6=e=>{let t=UL(e);r3(new Blob([t],{type:"image/svg+xml"}),"scene.svg")},l3=async e=>{let t=typeof navigator>"u"?void 0:navigator.clipboard;if(typeof t?.write!="function"||typeof ClipboardItem>"u"){hu("Copy to clipboard isn't supported in this browser.");return}let n=await a3(e.scene,{background:"color",scale:R6,backgroundColor:D6()});if(!n){hu("Nothing to copy \u2014 the canvas is empty.");return}try{await t.write([new ClipboardItem({"image/png":n})])}catch(o){console.error("[diagram] copy-as-image failed:",o),hu("Couldn't copy the image to the clipboard.")}},UK=[{id:"save-scene",label:"Save as JSON",category:"other",viewMode:!0,hotkey:{key:"s",meta:!0},perform:({editor:e})=>{s3(e.scene)}},{id:"open-scene",label:"Open\u2026",category:"other",hotkey:{key:"o",meta:!0},perform:({editor:e})=>{i3(e)}},{id:"export-png",label:"Export as PNG",category:"other",viewMode:!0,hotkey:{key:"e",meta:!0,shift:!0},perform:({editor:e})=>{wh(e,"color")}},{id:"copy-as-image",label:"Copy as image",category:"other",viewMode:!0,hotkey:{key:"c",shift:!0,alt:!0},perform:({editor:e})=>{l3(e)}}],B6=(e=_e)=>{for(let t of UK)e.replace(t)};var GK=14,WK=14,qK=16,c3=1.75,ft={size:GK,strokeWidth:c3},ws={size:WK,strokeWidth:c3},Zg={size:qK,strokeWidth:c3},jK="https://github.com/oh-just-another/diagram",_h=(0,me.forwardRef)(function(t,n){let{initialScene:o,initialMode:a="select",grid:r,snap:s,templates:i,fileDropHandlers:l,layoutKinds:c,animationAdapters:u,onReady:d,onSceneChange:f,onSelectionChange:p,capabilities:h,workerFactory:m,hideTopBar:x,hideBottomBar:y,hideToolbar:g,hideLibraryButton:b,hideMainMenu:A,hideZoomControls:_,hideResetToContent:T,hideHelpButton:w,hideContextMenu:S,hideSelectionPanel:L,hideDrawingPanel:M,minimap:B,renderTopBarLeft:W,renderTopBarCenter:ie,renderTopBarRight:ne,renderBottomBarLeft:j,renderBottomBarCenter:ve,renderBottomBarRight:ye,renderMainMenuExtras:ee,onImportTemplates:Se,theme:Oe,defaultTheme:qt="system",onThemeChange:xn,persistTheme:Oo,repositoryUrl:vt,onConfirm:Eh,onNotify:Th,className:Ih,style:Mh}=t,mu=(0,me.useMemo)(()=>Oo===!0?"diagram-theme":typeof Oo=="string"?Oo:null,[Oo]),[G6,W6]=(0,me.useState)(()=>{if(!mu||typeof window>"u")return qt;let X=window.localStorage.getItem(mu);return X==="light"||X==="dark"||X==="system"?X:qt}),Rh=Oe??G6,q6=M6(Rh),j6=(0,me.useCallback)(X=>{Oe===void 0&&W6(X),mu&&typeof window<"u"&&window.localStorage.setItem(mu,X),xn?.(X)},[Oe,xn,mu]),d3=r?.enabled,f3=r?.style,yu=(0,me.useMemo)(()=>VA({...o?{saved:o}:{},hostSettings:QK(d3,f3,s)}),[o,d3,f3,s]),p3=(0,me.useMemo)(()=>{for(let X of yu.elements.values())if(fe(X))return!0;return!1},[yu]);(0,me.useEffect)(()=>{if(I6(),i)for(let X of i)Oi.register(X);if(c)for(let X of c)e2(X);if(u)for(let X of u)Lp(X)},[i,c,u]);let[_s,V6]=(0,me.useState)(null),[Oh,Z6]=(0,me.useState)(null),[Dh,X6]=(0,me.useState)(null),[Y6,h3]=(0,me.useState)(!1),[Yg,m3]=(0,me.useState)(!1),y3=(0,me.useRef)(null),g3=(0,me.useRef)(!1);(0,me.useEffect)(()=>{let X=!1;return(async()=>{y3.current??=v6(h);let Hn=await y3.current;if(X)return;g3.current||(g3.current=!0,S6(Hn)),V6(Hn);let Cs=[];Cs.push(dD(document).then(()=>{X||m3(!0)},$t=>{X||m3(!0),console.warn("[diagram] bundled fonts load failed",$t)})),Hn.wasmText&&Cs.push(vh.loadBundled().then($t=>{X||(Cp($t),Z6($t),h3(!0))},$t=>{X||(h3(!0),console.warn("[diagram] WASM text shaper load failed",$t))})),Hn.wasmRaster&&Cs.push(Lh.loadBundled().then($t=>{X||(Ep($t),X6($t))},$t=>{console.warn("[diagram] WASM rasterizer load failed",$t)})),await Promise.allSettled(Cs)})(),()=>{X=!0}},[h]);let[ge,K6]=(0,me.useState)(null),$6=(0,me.useCallback)(X=>{if(l)for(let Hn of l)X.registerFileDropHandler(Hn);K6(X),d?.(X)},[l,d]);return(0,me.useEffect)(()=>{ge&&(!Oh&&!Dh||ge.setMode(ge.mode))},[ge,Oh,Dh]),(0,me.useEffect)(()=>{ge&&ge.forceRender()},[ge,u]),(0,me.useEffect)(()=>{ge&&Yg&&ge.forceRender()},[ge,Yg]),(0,me.useEffect)(()=>{if(!ge||!f&&!p)return;let X=ge.scene,Hn=ge.selection;return ge.subscribe(()=>{f&&ge.scene!==X&&(X=ge.scene,f(ge.scene)),p&&ge.selection!==Hn&&(Hn=ge.selection,p(ge.selection))})},[ge,f,p]),(0,me.useEffect)(()=>{if(!ge)return;let X=ge,Hn=Qt=>{ea(Qt.target)||(X.setSnapSuppressed(Qt.metaKey||Qt.ctrlKey),X.setTransformModifiers({alt:Qt.altKey,shift:Qt.shiftKey}))},Cs=Qt=>{Hn(Qt),!ea(Qt.target)&&Qt.key==="Escape"&&X.flowchartPreview!==null&&(X.cancelFlowchart(),Qt.preventDefault())},$t=Qt=>{Hn(Qt),!Qt.metaKey&&!Qt.ctrlKey&&X.flowchartPreview!==null&&X.commitFlowchart()},x3=()=>{X.setSnapSuppressed(!1),X.setTransformModifiers({alt:!1,shift:!1}),X.flowchartPreview!==null&&X.commitFlowchart()};return window.addEventListener("keydown",Cs),window.addEventListener("keyup",$t),window.addEventListener("blur",x3),()=>{window.removeEventListener("keydown",Cs),window.removeEventListener("keyup",$t),window.removeEventListener("blur",x3),X.setSnapSuppressed(!1),X.setTransformModifiers({alt:!1,shift:!1})}},[ge]),(0,me.useImperativeHandle)(n,()=>({editor:ge,capabilities:_s,getScene:()=>ge?.scene??yu,loadScene:X=>ge?.loadScene(X),getMode:()=>ge?.mode??null,setMode:X=>ge?.setMode(X),getSelection:()=>ge?.selection??new Set,setSelection:X=>ge?.setSelection(X),undo:()=>{ge?.undo()},redo:()=>{ge?.redo()},zoomToFit:()=>{ge?.zoomToFit()}}),[ge,yu,_s]),_s?p3&&!Yg?(0,R.jsx)("div",{className:Ih,style:Mh}):_s.renderer==="webgl2"&&_s.wasmText&&!Y6&&p3?(0,R.jsx)("div",{className:Ih,style:Mh}):(0,R.jsx)(Lf,{container:q6,children:(0,R.jsx)($L,{children:(0,R.jsx)(Zb,{children:(0,R.jsx)("div",{className:Ih,"data-diagram-root":!0,...Rh==="system"?{}:{"data-theme":Rh},style:{position:"relative",width:"100%",height:"100%",background:"var(--du-canvas-bg)",...Mh},children:(0,R.jsx)(LL,{initialScene:yu,initialMode:a,onReady:$6,renderer:_s.renderer,..._s.renderer==="offscreen"?{workerFactory:m??mL}:{},...Oh?{textShaper:Oh}:{},...Dh?{rasterizer:Dh}:{},children:(0,R.jsx)(YL,{children:(0,R.jsx)(VK,{hideTopBar:x,hideBottomBar:y,hideToolbar:g,hideLibraryButton:b,hideMainMenu:A,hideZoomControls:_,hideResetToContent:T,hideHelpButton:w,hideContextMenu:S,hideSelectionPanel:L,hideDrawingPanel:M,minimap:B,renderTopBarLeft:W,renderTopBarCenter:ie,renderTopBarRight:ne,renderBottomBarLeft:j,renderBottomBarCenter:ve,renderBottomBarRight:ye,renderMainMenuExtras:ee,onImportTemplates:Se,repositoryUrl:vt,onConfirm:Eh,onNotify:Th,theme:Rh,changeTheme:j6})})})})})})}):(0,R.jsx)("div",{className:Ih,style:Mh})});_h.displayName="Editor";var VK=({hideTopBar:e,hideBottomBar:t,hideToolbar:n,hideLibraryButton:o,hideMainMenu:a,hideZoomControls:r,hideResetToContent:s,hideHelpButton:i,hideContextMenu:l,hideSelectionPanel:c,hideDrawingPanel:u,minimap:d,renderTopBarLeft:f,renderTopBarCenter:p,renderTopBarRight:h,renderBottomBarLeft:m,renderBottomBarCenter:x,renderBottomBarRight:y,renderMainMenuExtras:g,onImportTemplates:b,repositoryUrl:A,onConfirm:_,onNotify:T,theme:w,changeTheme:S})=>{let L=G(),{zen:M}=KL(),B=A===void 0?jK:A,W=_??(vt=>window.confirm(vt)),ie=T??(vt=>{window.alert(vt)});(0,me.useEffect)(()=>{B6(),O6(ie)},[ie]),Ya();let ne=jS(),j=jp(),[ve,ye]=(0,me.useState)(!1),[ee,Se]=(0,me.useState)(!1);PS(()=>{Se(vt=>!vt)});let Oe=240,qt=12,xn=!j&&ve?Oe+qt:qt,Oo=(0,me.useMemo)(()=>o?[...Fg]:[{kind:"action",id:"toggle-library",label:(0,R.jsx)(Zd,{...Zg}),title:"Templates library",active:ve,onClick:()=>{ye(vt=>!vt)}},{kind:"divider"},...Fg],[o,ve]);return(0,R.jsxs)("div",{style:{position:"absolute",inset:0},onDragEnter:ne.onDragEnter,onDragOver:ne.onDragOver,onDragLeave:ne.onDragLeave,onDrop:ne.onDrop,children:[(0,R.jsxs)("div",{style:{position:"absolute",top:0,bottom:0,left:0,right:0},children:[(0,R.jsx)(kL,{style:{position:"absolute",inset:0}}),(0,R.jsx)(ML,{}),(0,R.jsx)(RL,{}),(0,R.jsx)(OL,{}),(0,R.jsx)(DL,{}),(0,R.jsx)(PL,{}),!l&&(0,R.jsx)(GL,{items:qL})]}),!n&&!M?(0,R.jsx)(zL,{orientation:"vertical",items:Oo,style:{position:"absolute",top:"50%",left:`calc(env(safe-area-inset-left, 0px) + ${xn}px)`,transform:"translateY(-50%)",zIndex:60}}):null,(0,R.jsxs)(Kb,{children:[!e&&!M&&(0,R.jsx)($b,{left:(0,R.jsxs)(ni,{ariaLabel:"Logo and main menu",children:[(0,R.jsx)("span",{"aria-label":"Diagram",title:"Diagram",className:"du-icon-button",style:{minWidth:36,padding:"0 10px",cursor:"default",fontWeight:600,letterSpacing:.5},children:"\u2317"}),!a&&(0,R.jsxs)($,{children:[(0,R.jsxs)($.Group,{title:"File",children:[(0,R.jsx)($.Item,{icon:(0,R.jsx)(Fd,{...ft}),onClick:()=>{L&&i3(L)},shortcut:ut({key:"O",meta:!0}),children:"Open\u2026"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(zd,{...ft}),onClick:()=>{L&&s3(L.scene)},disabled:!L,shortcut:ut({key:"S",meta:!0}),children:"Save as JSON"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Hr,{...ft}),onClick:()=>{L&&l3(L)},disabled:!L,shortcut:ut({key:"C",shift:!0,alt:!0}),children:"Copy as image"}),(0,R.jsxs)($.Submenu,{icon:(0,R.jsx)(Jl,{...ft}),label:"Export\u2026",disabled:!L,children:[(0,R.jsx)($.Item,{icon:(0,R.jsx)(Ks,{...ft}),onClick:()=>L&&void wh(L,"transparent"),disabled:!L,children:"PNG (transparent)"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Ks,{...ft}),onClick:()=>L&&void wh(L,"color"),disabled:!L,shortcut:ut({key:"E",meta:!0,shift:!0}),children:"PNG (with background)"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Ks,{...ft}),onClick:()=>L&&void wh(L,"color-and-grid"),disabled:!L,children:"PNG (with background + grid)"}),(0,R.jsx)($.Separator,{}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Jl,{...ft}),onClick:()=>{L&&P6(L.scene)},disabled:!L,children:"SVG"})]}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(cf,{...ft}),onClick:()=>{L&&W("Reset canvas? This clears all shapes.")&&L.clear()},disabled:!L,children:"Reset canvas"})]}),(0,R.jsx)($.Separator,{}),(0,R.jsxs)($.Group,{title:"Edit",children:[(0,R.jsx)($.Item,{icon:(0,R.jsx)(ei,{...ft}),shortcut:"\u2318Z",onClick:()=>L?.undo(),disabled:!L,children:"Undo"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Js,{...ft}),shortcut:"\u21E7\u2318Z",onClick:()=>L?.redo(),disabled:!L,children:"Redo"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(uf,{...ft}),shortcut:"\u2318X",onClick:()=>L?.cutSelected(),disabled:!L,children:"Cut"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Hr,{...ft}),shortcut:"\u2318C",onClick:()=>L?.copySelected(),disabled:!L,children:"Copy"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Rd,{...ft}),shortcut:"\u2318V",onClick:()=>L?.paste(),disabled:!L,children:"Paste"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(nf,{...ft}),shortcut:"\u2318A",onClick:()=>L?.selectAll(),disabled:!L,children:"Select all"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Dd,{...ft}),shortcut:"\u232B",onClick:()=>L?.deleteSelected(),disabled:!L,children:"Delete selected"})]}),(0,R.jsx)($.Separator,{}),(0,R.jsxs)($.Group,{title:"View",children:[(0,R.jsx)($.Item,{icon:(0,R.jsx)(ec,{...ft}),shortcut:"\u21E7F",onClick:()=>L?.zoomToFit(),disabled:!L,children:"Fit to screen"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(Sf,{...ft}),shortcut:"\u2318+",onClick:()=>L?.zoomIn(),disabled:!L,children:"Zoom in"}),(0,R.jsx)($.Item,{icon:(0,R.jsx)(vf,{...ft}),shortcut:"\u2318\u2212",onClick:()=>L?.zoomOut(),disabled:!L,children:"Zoom out"})]}),(0,R.jsx)($.Separator,{}),(0,R.jsx)($.Group,{title:"Theme",children:(0,R.jsx)($.Toggle,{value:w,onChange:S,options:[{value:"light",label:"Light",icon:(0,R.jsx)(mf,{...ws})},{value:"dark",label:"Dark",icon:(0,R.jsx)(ef,{...ws})},{value:"system",label:"System",icon:(0,R.jsx)(Jd,{...ws})}]})}),(0,R.jsx)($.Group,{title:"Grid",children:(0,R.jsx)($.Toggle,{value:JK(L),onChange:vt=>{t$(L,vt)},options:[{value:"lines",label:"Lines",icon:(0,R.jsx)(xo,{...ws})},{value:"dots",label:"Dots",icon:(0,R.jsx)(Wd,{...ws})},{value:"off",label:"Off",icon:(0,R.jsx)(Da,{...ws})}]})}),(0,R.jsx)($.Group,{title:"Snap to grid",children:(0,R.jsx)($.Toggle,{value:e$(L),onChange:vt=>{L?.setSnapToGrid(vt==="on")},options:[{value:"on",label:"On",icon:(0,R.jsx)($d,{...ws})},{value:"off",label:"Off",icon:(0,R.jsx)(Da,{...ws})}]})}),(0,R.jsx)($.Separator,{}),(0,R.jsxs)($.Group,{title:"Help",children:[(0,R.jsx)($.Item,{icon:(0,R.jsx)(Tn,{...ft}),shortcut:"?",onClick:()=>{Se(!0)},children:"Hotkeys"}),B?(0,R.jsx)($.ItemLink,{href:B,external:!0,children:"GitHub"}):null]}),g?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)($.Separator,{}),g()]}):null]}),f?f():null]}),center:p?.(),right:(0,R.jsx)(ni,{ariaLabel:"Top bar actions",children:h?h():null})}),!t&&!M&&(0,R.jsx)(Qb,{left:m?m():null,center:x?x():s?null:(0,R.jsx)(FS,{}),right:y?y():r?i?null:(0,R.jsx)($y,{}):(0,R.jsx)($K,{trailing:i?void 0:(0,R.jsx)($y,{})})}),M?null:j?ve?(0,R.jsx)(IL,{snapPoints:[0,60,92],defaultValue:60,style:{pointerEvents:"auto"},onChange:vt=>{vt<=0&&ye(!1)},children:(0,R.jsx)(sg,{open:!0,sheet:!0,onClose:()=>{ye(!1)},...b?{onImport:b}:{}})}):null:(0,R.jsx)(sg,{open:ve,side:"left",style:{left:0},onClose:()=>{ye(!1)},...b?{onImport:b}:{}})]}),d&&!M&&(0,R.jsx)("div",{style:{position:"absolute",right:"var(--du-bar-inset, 12px)",bottom:"calc(var(--du-bar-inset, 12px) + 52px)",border:"1px solid var(--du-border, #d0d0d0)",borderRadius:6,background:"var(--du-surface, #fff)",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",overflow:"hidden",zIndex:40},children:(0,R.jsx)(wL,{})}),!u&&!M&&(0,R.jsx)("div",{style:{position:"absolute",top:"calc(var(--du-bar-inset, 12px) + 52px)",right:"var(--du-bar-inset, 12px)",zIndex:40},children:(0,R.jsx)(_L,{})}),!c&&!M&&(0,R.jsx)(sL,{}),(0,R.jsx)(Wp,{open:ee,onClose:()=>{Se(!1)}}),(0,R.jsx)(jL,{}),(0,R.jsx)(ZL,{}),(0,R.jsx)(XL,{}),void 0]})},ZK=ut({meta:!0,key:"\u2212"}),XK=ut({meta:!0,key:"+"}),YK=ut({meta:!0,key:"0"}),KK=ut({alt:!0,key:"1"}),$K=({trailing:e})=>{let t=G(),[,n]=(0,me.useState)(0);if((0,me.useEffect)(()=>{if(t)return t.subscribe(()=>{n(a=>a+1)})},[t]),!t)return null;let o=t.scene.viewport.zoom;return(0,R.jsxs)(ni,{ariaLabel:"Zoom",children:[(0,R.jsx)(Qn,{label:`Zoom out (${ZK})`,onClick:()=>{t.zoomOut()},children:(0,R.jsx)(Da,{...Zg})}),(0,R.jsx)(ti,{content:`Reset zoom to 100% (${YK})`,children:(0,R.jsxs)("button",{type:"button",className:"du-icon-button","aria-label":"Reset zoom to 100%",onClick:()=>{t.resetZoom()},style:{minWidth:56,padding:"0 8px",borderRadius:0},children:[Math.round(o*100),"%"]})}),(0,R.jsx)(Qn,{label:`Zoom in (${XK})`,onClick:()=>{t.zoomIn()},children:(0,R.jsx)(Qs,{...Zg})}),(0,R.jsx)(Qn,{label:`Fit to screen (${KK})`,onClick:()=>{t.zoomToFit()},children:(0,R.jsx)(ec,{...Zg})}),e]})},QK=(e,t,n)=>({viewport:{...e!==void 0?{gridEnabled:e}:{},...t!==void 0?{gridStyle:t}:{},...n!==void 0?{snapToGrid:n}:{}}}),JK=e=>{if(!e)return"lines";let t=e.scene.viewport;return t.gridEnabled?t.gridStyle??"lines":"off"},e$=e=>e?.snapToGridEnabled??!0?"on":"off",t$=(e,t)=>{if(e){if(t==="off"){e.setGrid({enabled:!1});return}e.setGrid({enabled:!0,style:t})}};var N6=`/**
|
|
143
168
|
* Diagram UI stylesheet. Imported once by the host:
|
|
144
169
|
*
|
|
145
170
|
* import "@oh-just-another/react-ui/styles.css";
|
|
@@ -1691,7 +1716,7 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
1691
1716
|
outline: 2px solid var(--du-accent, #5082ff);
|
|
1692
1717
|
outline-offset: -2px;
|
|
1693
1718
|
}
|
|
1694
|
-
`;var
|
|
1719
|
+
`;var u3=P(se(),1),z6=new Set(["dark","light","system"]),n$=new Set(["canvas2d","webgl2","offscreen"]),Xg=null,o$=()=>(Xg||(Xg=new CSSStyleSheet,Xg.replaceSync(N6.replace(/:root\b/g,":host"))),Xg),Ch=class extends HTMLElement{static get observedAttributes(){return["theme","renderer","grid","snap"]}#n=null;#r=null;#s=null;#e=null;#o=null;#t=void 0;connectedCallback(){if(this.#n)return;let t=this.shadowRoot??this.attachShadow({mode:"open"});t.adoptedStyleSheets=[o$()],this.style.display||(this.style.display="block");let n=document.createElement("div");n.style.cssText="width:100%;height:100%;position:relative";let o=document.createElement("div");o.style.cssText="width:100%;height:100%";let a=document.createElement("div");this.#r=a,n.append(o,a),t.append(n),this.#s=n,this.#i(),this.#n=(0,F6.createRoot)(o),this.#l()}disconnectedCallback(){this.#o?.(),this.#o=null,this.#n?.unmount(),this.#n=null,this.#e=null,this.#r=null,this.#s=null}attributeChangedCallback(t){t==="theme"&&this.#i(),this.#n&&this.#l()}#i(){let t=this.#s;if(!t)return;let n=this.getAttribute("theme");n==="dark"||n==="light"?t.dataset.theme=n:delete t.dataset.theme}get scene(){return this.#e?this.#e.getScene():this.#t}set scene(t){this.#t=t,this.#e&&t&&this.#e.loadScene(t)}get theme(){let t=this.getAttribute("theme");return t&&z6.has(t)?t:null}set theme(t){t?this.setAttribute("theme",t):this.removeAttribute("theme")}get editor(){return this.#e?.editor??null}getScene(){return this.#e?.getScene()}loadScene(t){this.#t=t,this.#e?.loadScene(t)}undo(){this.#e?.undo()}redo(){this.#e?.redo()}zoomToFit(){this.#e?.zoomToFit()}getMode(){return this.#e?.getMode()??null}setMode(t){this.#e?.setMode(t)}getSelection(){return this.#e?.getSelection()??new Set}setSelection(t){this.#e?.setSelection(t)}#a(t,n){this.dispatchEvent(new CustomEvent(t,{detail:n}))}#c(){let t=this.getAttribute("theme"),n=this.getAttribute("renderer"),o=t&&z6.has(t)?t:void 0,a=n&&n$.has(n)?n:void 0;return{...this.#t?{initialScene:this.#t}:{},grid:{enabled:this.hasAttribute("grid")},snap:this.hasAttribute("snap"),...o?{theme:o}:{},...a?{capabilities:{renderer:a}}:{},onReady:r=>{this.#o?.(),this.#o=wy(r),this.#t&&r.loadScene(this.#t),this.#a("ready",{editor:r})},onSceneChange:r=>{this.#a("scenechange",r)},onSelectionChange:r=>{this.#a("selectionchange",[...r])},onThemeChange:r=>{this.#a("themechange",r)}}}#l(){this.#n?.render((0,u3.jsx)(Lf,{container:this.#r,children:(0,u3.jsx)(_h,{ref:t=>{this.#e=t},...this.#c()})}))}};var a$=["ready","scenechange","selectionchange","themechange"],H6=(e,t,n)=>{n?e.setAttribute(t,""):e.removeAttribute(t)},U6=(e,t,n)=>{n===void 0?e.removeAttribute(t):e.setAttribute(t,n)},r$=(e,t)=>{U6(e,"theme",t.theme),U6(e,"renderer",t.renderer),H6(e,"grid",t.grid??!1),H6(e,"snap",t.snap??!1),t.scene!==void 0&&(e.scene=t.scene)},s$=(e,t)=>{let n=[],o=(a,r)=>{if(!r)return;let s=i=>{r(i.detail)};e.addEventListener(a,s),n.push(()=>{e.removeEventListener(a,s)})};return o("ready",t.ready),o("scenechange",t.scenechange),o("selectionchange",t.selectionchange),o("themechange",t.themechange),()=>{for(let a of n)a()}},i$=e=>({getScene:()=>e()?.getScene(),loadScene:t=>e()?.loadScene(t),undo:()=>e()?.undo(),redo:()=>e()?.redo(),zoomToFit:()=>e()?.zoomToFit(),getMode:()=>e()?.getMode()??null,setMode:t=>e()?.setMode(t),getSelection:()=>e()?.getSelection()??new Set,setSelection:t=>e()?.setSelection(t)});var l$="oja-diagram",c$=(e=l$)=>{typeof customElements>"u"||customElements.get(e)||customElements.define(e,Ch)};c$();export{a$ as OJA_DIAGRAM_EVENTS,l$ as OJA_DIAGRAM_TAG,Ch as OjaDiagramElement,r$ as applyOjaDiagramProps,s$ as bindOjaDiagramEvents,c$ as defineOjaDiagram,i$ as ojaDiagramController};
|
|
1695
1720
|
/*! Bundled license information:
|
|
1696
1721
|
|
|
1697
1722
|
scheduler/cjs/scheduler.production.js:
|
|
@@ -1777,10 +1802,13 @@ lucide-react/dist/esm/icons/circle-question-mark.mjs:
|
|
|
1777
1802
|
lucide-react/dist/esm/icons/circle.mjs:
|
|
1778
1803
|
lucide-react/dist/esm/icons/clipboard.mjs:
|
|
1779
1804
|
lucide-react/dist/esm/icons/copy.mjs:
|
|
1805
|
+
lucide-react/dist/esm/icons/crop.mjs:
|
|
1780
1806
|
lucide-react/dist/esm/icons/delete.mjs:
|
|
1807
|
+
lucide-react/dist/esm/icons/diamond.mjs:
|
|
1781
1808
|
lucide-react/dist/esm/icons/download.mjs:
|
|
1782
1809
|
lucide-react/dist/esm/icons/ellipsis-vertical.mjs:
|
|
1783
1810
|
lucide-react/dist/esm/icons/ellipsis.mjs:
|
|
1811
|
+
lucide-react/dist/esm/icons/eraser.mjs:
|
|
1784
1812
|
lucide-react/dist/esm/icons/external-link.mjs:
|
|
1785
1813
|
lucide-react/dist/esm/icons/file-down.mjs:
|
|
1786
1814
|
lucide-react/dist/esm/icons/file-up.mjs:
|
|
@@ -1810,7 +1838,9 @@ lucide-react/dist/esm/icons/move-down.mjs:
|
|
|
1810
1838
|
lucide-react/dist/esm/icons/move-right.mjs:
|
|
1811
1839
|
lucide-react/dist/esm/icons/move-up.mjs:
|
|
1812
1840
|
lucide-react/dist/esm/icons/pen-line.mjs:
|
|
1841
|
+
lucide-react/dist/esm/icons/pipette.mjs:
|
|
1813
1842
|
lucide-react/dist/esm/icons/plus.mjs:
|
|
1843
|
+
lucide-react/dist/esm/icons/radio.mjs:
|
|
1814
1844
|
lucide-react/dist/esm/icons/redo-2.mjs:
|
|
1815
1845
|
lucide-react/dist/esm/icons/rotate-ccw.mjs:
|
|
1816
1846
|
lucide-react/dist/esm/icons/scissors.mjs:
|