@oh-just-another/diagram 0.2.0 → 0.3.0
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 +12 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/oja-diagram.global.js +57 -54
- package/dist/oja-diagram.global.js.map +4 -4
- package/dist/styles.generated.d.ts +1 -1
- package/dist/styles.generated.d.ts.map +1 -1
- package/dist/styles.generated.js +1 -1
- package/dist/styles.generated.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
var OP=Object.create;var lx=Object.defineProperty;var DP=Object.getOwnPropertyDescriptor;var PP=Object.getOwnPropertyNames;var BP=Object.getPrototypeOf,NP=Object.prototype.hasOwnProperty;var Ut=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),yo=(e,t)=>{for(var n in t)lx(e,n,{get:t[n],enumerable:!0})},zP=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of PP(t))!NP.call(e,a)&&a!==n&&lx(e,a,{get:()=>t[a],enumerable:!(o=DP(t,a))||o.enumerable});return e};var P=(e,t,n)=>(n=e!=null?OP(BP(e)):{},zP(t||!e||!e.__esModule?lx(n,"default",{value:e,enumerable:!0}):n,e));var X3=Ut(Ve=>{"use strict";function fx(e,t){var n=e.length;e.push(t);e:for(;0<n;){var o=n-1>>>1,a=e[o];if(0<Zh(a,t))e[o]=t,e[n]=a,n=o;else break e}}function No(e){return e.length===0?null:e[0]}function Yh(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>Zh(i,n))l<a&&0>Zh(c,i)?(e[o]=c,e[l]=n,o=l):(e[o]=i,e[s]=n,o=s);else if(l<a&&0>Zh(c,n))e[o]=c,e[l]=n,o=l;else break e}}return t}function Zh(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}Ve.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(F3=performance,Ve.unstable_now=function(){return F3.now()}):(cx=Date,H3=cx.now(),Ve.unstable_now=function(){return cx.now()-H3});var F3,cx,H3,ma=[],pr=[],FP=1,Gn=null,Gt=3,px=!1,Su=!1,Lu=!1,hx=!1,W3=typeof setTimeout=="function"?setTimeout:null,q3=typeof clearTimeout=="function"?clearTimeout:null,U3=typeof setImmediate<"u"?setImmediate:null;function Xh(e){for(var t=No(pr);t!==null;){if(t.callback===null)Yh(pr);else if(t.startTime<=e)Yh(pr),t.sortIndex=t.expirationTime,fx(ma,t);else break;t=No(pr)}}function mx(e){if(Lu=!1,Xh(e),!Su)if(No(ma)!==null)Su=!0,ll||(ll=!0,il());else{var t=No(pr);t!==null&&yx(mx,t.startTime-e)}}var ll=!1,ku=-1,V3=5,j3=-1;function Z3(){return hx?!0:!(Ve.unstable_now()-j3<V3)}function ux(){if(hx=!1,ll){var e=Ve.unstable_now();j3=e;var t=!0;try{e:{Su=!1,Lu&&(Lu=!1,q3(ku),ku=-1),px=!0;var n=Gt;try{t:{for(Xh(e),Gn=No(ma);Gn!==null&&!(Gn.expirationTime>e&&Z3());){var o=Gn.callback;if(typeof o=="function"){Gn.callback=null,Gt=Gn.priorityLevel;var a=o(Gn.expirationTime<=e);if(e=Ve.unstable_now(),typeof a=="function"){Gn.callback=a,Xh(e),t=!0;break t}Gn===No(ma)&&Yh(ma),Xh(e)}else Yh(ma);Gn=No(ma)}if(Gn!==null)t=!0;else{var r=No(pr);r!==null&&yx(mx,r.startTime-e),t=!1}}break e}finally{Gn=null,Gt=n,px=!1}t=void 0}}finally{t?il():ll=!1}}}var il;typeof U3=="function"?il=function(){U3(ux)}:typeof MessageChannel<"u"?(dx=new MessageChannel,G3=dx.port2,dx.port1.onmessage=ux,il=function(){G3.postMessage(null)}):il=function(){W3(ux,0)};var dx,G3;function yx(e,t){ku=W3(function(){e(Ve.unstable_now())},t)}Ve.unstable_IdlePriority=5;Ve.unstable_ImmediatePriority=1;Ve.unstable_LowPriority=4;Ve.unstable_NormalPriority=3;Ve.unstable_Profiling=null;Ve.unstable_UserBlockingPriority=2;Ve.unstable_cancelCallback=function(e){e.callback=null};Ve.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"):V3=0<e?Math.floor(1e3/e):5};Ve.unstable_getCurrentPriorityLevel=function(){return Gt};Ve.unstable_next=function(e){switch(Gt){case 1:case 2:case 3:var t=3;break;default:t=Gt}var n=Gt;Gt=t;try{return e()}finally{Gt=n}};Ve.unstable_requestPaint=function(){hx=!0};Ve.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=Gt;Gt=e;try{return t()}finally{Gt=n}};Ve.unstable_scheduleCallback=function(e,t,n){var o=Ve.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:FP++,callback:t,priorityLevel:e,startTime:n,expirationTime:a,sortIndex:-1},n>o?(e.sortIndex=n,fx(pr,e),No(ma)===null&&e===No(pr)&&(Lu?(q3(ku),ku=-1):Lu=!0,yx(mx,n-o))):(e.sortIndex=a,fx(ma,e),Su||px||(Su=!0,ll||(ll=!0,il()))),e};Ve.unstable_shouldYield=Z3;Ve.unstable_wrapCallback=function(e){var t=Gt;return function(){var n=Gt;Gt=t;try{return e.apply(this,arguments)}finally{Gt=n}}}});var K3=Ut((UQ,Y3)=>{"use strict";Y3.exports=X3()});var ik=Ut(te=>{"use strict";var bx=Symbol.for("react.transitional.element"),HP=Symbol.for("react.portal"),UP=Symbol.for("react.fragment"),GP=Symbol.for("react.strict_mode"),WP=Symbol.for("react.profiler"),qP=Symbol.for("react.consumer"),VP=Symbol.for("react.context"),jP=Symbol.for("react.forward_ref"),ZP=Symbol.for("react.suspense"),XP=Symbol.for("react.memo"),tk=Symbol.for("react.lazy"),YP=Symbol.for("react.activity"),$3=Symbol.iterator;function KP(e){return e===null||typeof e!="object"?null:(e=$3&&e[$3]||e["@@iterator"],typeof e=="function"?e:null)}var nk={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ok=Object.assign,ak={};function ul(e,t,n){this.props=e,this.context=t,this.refs=ak,this.updater=n||nk}ul.prototype.isReactComponent={};ul.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")};ul.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function rk(){}rk.prototype=ul.prototype;function Ax(e,t,n){this.props=e,this.context=t,this.refs=ak,this.updater=n||nk}var vx=Ax.prototype=new rk;vx.constructor=Ax;ok(vx,ul.prototype);vx.isPureReactComponent=!0;var Q3=Array.isArray;function xx(){}var Ue={H:null,A:null,T:null,S:null},sk=Object.prototype.hasOwnProperty;function Sx(e,t,n){var o=n.ref;return{$$typeof:bx,type:e,key:t,ref:o!==void 0?o:null,props:n}}function $P(e,t){return Sx(e.type,t,e.props)}function Lx(e){return typeof e=="object"&&e!==null&&e.$$typeof===bx}function QP(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var J3=/\/+/g;function gx(e,t){return typeof e=="object"&&e!==null&&e.key!=null?QP(""+e.key):t.toString(36)}function JP(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(xx,xx):(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 cl(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 bx:case HP:s=!0;break;case tk:return s=e._init,cl(s(e._payload),t,n,o,a)}}if(s)return a=a(e),s=o===""?"."+gx(e,0):o,Q3(a)?(n="",s!=null&&(n=s.replace(J3,"$&/")+"/"),cl(a,t,n,"",function(c){return c})):a!=null&&(Lx(a)&&(a=$P(a,n+(a.key==null||e&&e.key===a.key?"":(""+a.key).replace(J3,"$&/")+"/")+s)),t.push(a)),1;s=0;var i=o===""?".":o+":";if(Q3(e))for(var l=0;l<e.length;l++)o=e[l],r=i+gx(o,l),s+=cl(o,t,n,r,a);else if(l=KP(e),typeof l=="function")for(e=l.call(e),l=0;!(o=e.next()).done;)o=o.value,r=i+gx(o,l++),s+=cl(o,t,n,r,a);else if(r==="object"){if(typeof e.then=="function")return cl(JP(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 Kh(e,t,n){if(e==null)return e;var o=[],a=0;return cl(e,o,"","",function(r){return t.call(n,r,a++)}),o}function e7(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 ek=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)},t7={map:Kh,forEach:function(e,t,n){Kh(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Kh(e,function(){t++}),t},toArray:function(e){return Kh(e,function(t){return t})||[]},only:function(e){if(!Lx(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};te.Activity=YP;te.Children=t7;te.Component=ul;te.Fragment=UP;te.Profiler=WP;te.PureComponent=Ax;te.StrictMode=GP;te.Suspense=ZP;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=ok({},e.props),a=e.key;if(t!=null)for(r in t.key!==void 0&&(a=""+t.key),t)!sk.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 Sx(e.type,a,o)};te.createContext=function(e){return e={$$typeof:VP,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:qP,_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)sk.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 Sx(e,r,a)};te.createRef=function(){return{current:null}};te.forwardRef=function(e){return{$$typeof:jP,render:e}};te.isValidElement=Lx;te.lazy=function(e){return{$$typeof:tk,_payload:{_status:-1,_result:e},_init:e7}};te.memo=function(e,t){return{$$typeof:XP,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(xx,ek)}catch(r){ek(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=Ut((WQ,lk)=>{"use strict";lk.exports=ik()});var uk=Ut(jt=>{"use strict";var n7=re();function ck(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 hr(){}var Vt={d:{f:hr,r:function(){throw Error(ck(522))},D:hr,C:hr,L:hr,m:hr,X:hr,S:hr,M:hr},p:0,findDOMNode:null},o7=Symbol.for("react.portal");function a7(e,t,n){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o7,key:o==null?null:""+o,children:e,containerInfo:t,implementation:n}}var _u=n7.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function $h(e,t){if(e==="font")return"";if(typeof t=="string")return t==="use-credentials"?t:""}jt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Vt;jt.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(ck(299));return a7(e,t,null,n)};jt.flushSync=function(e){var t=_u.T,n=Vt.p;try{if(_u.T=null,Vt.p=2,e)return e()}finally{_u.T=t,Vt.p=n,Vt.d.f()}};jt.preconnect=function(e,t){typeof e=="string"&&(t?(t=t.crossOrigin,t=typeof t=="string"?t==="use-credentials"?t:"":void 0):t=null,Vt.d.C(e,t))};jt.prefetchDNS=function(e){typeof e=="string"&&Vt.d.D(e)};jt.preinit=function(e,t){if(typeof e=="string"&&t&&typeof t.as=="string"){var n=t.as,o=$h(n,t.crossOrigin),a=typeof t.integrity=="string"?t.integrity:void 0,r=typeof t.fetchPriority=="string"?t.fetchPriority:void 0;n==="style"?Vt.d.S(e,typeof t.precedence=="string"?t.precedence:void 0,{crossOrigin:o,integrity:a,fetchPriority:r}):n==="script"&&Vt.d.X(e,{crossOrigin:o,integrity:a,fetchPriority:r,nonce:typeof t.nonce=="string"?t.nonce:void 0})}};jt.preinitModule=function(e,t){if(typeof e=="string")if(typeof t=="object"&&t!==null){if(t.as==null||t.as==="script"){var n=$h(t.as,t.crossOrigin);Vt.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&&Vt.d.M(e)};jt.preload=function(e,t){if(typeof e=="string"&&typeof t=="object"&&t!==null&&typeof t.as=="string"){var n=t.as,o=$h(n,t.crossOrigin);Vt.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})}};jt.preloadModule=function(e,t){if(typeof e=="string")if(t){var n=$h(t.as,t.crossOrigin);Vt.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 Vt.d.m(e)};jt.requestFormReset=function(e){Vt.d.r(e)};jt.unstable_batchedUpdates=function(e,t){return e(t)};jt.useFormState=function(e,t,n){return _u.H.useFormState(e,t,n)};jt.useFormStatus=function(){return _u.H.useHostTransitionStatus()};jt.version="19.2.6"});var ya=Ut((VQ,fk)=>{"use strict";function dk(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(dk)}catch(e){console.error(e)}}dk(),fk.exports=uk()});var kE=Ut(S0=>{"use strict";var mt=K3(),z_=re(),r7=ya();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 F_(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function dd(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 H_(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 U_(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 pk(e){if(dd(e)!==e)throw Error(O(188))}function s7(e){var t=e.alternate;if(!t){if(t=dd(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 pk(a),e;if(r===o)return pk(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 G_(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=G_(e),t!==null)return t;e=e.sibling}return null}var qe=Object.assign,i7=Symbol.for("react.element"),Qh=Symbol.for("react.transitional.element"),Ou=Symbol.for("react.portal"),yl=Symbol.for("react.fragment"),W_=Symbol.for("react.strict_mode"),o1=Symbol.for("react.profiler"),q_=Symbol.for("react.consumer"),ka=Symbol.for("react.context"),Q1=Symbol.for("react.forward_ref"),a1=Symbol.for("react.suspense"),r1=Symbol.for("react.suspense_list"),J1=Symbol.for("react.memo"),mr=Symbol.for("react.lazy");Symbol.for("react.scope");var s1=Symbol.for("react.activity");Symbol.for("react.legacy_hidden");Symbol.for("react.tracing_marker");var l7=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var hk=Symbol.iterator;function wu(e){return e===null||typeof e!="object"?null:(e=hk&&e[hk]||e["@@iterator"],typeof e=="function"?e:null)}var c7=Symbol.for("react.client.reference");function i1(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===c7?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case yl:return"Fragment";case o1:return"Profiler";case W_:return"StrictMode";case a1:return"Suspense";case r1:return"SuspenseList";case s1:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case Ou:return"Portal";case ka:return e.displayName||"Context";case q_:return(e._context.displayName||"Context")+".Consumer";case Q1:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case J1:return t=e.displayName||null,t!==null?t:i1(e.type)||"Memo";case mr:t=e._payload,e=e._init;try{return i1(e(t))}catch{}}return null}var Du=Array.isArray,K=z_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e=r7.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ds={pending:!1,data:null,method:null,action:null},l1=[],gl=-1;function Go(e){return{current:e}}function _t(e){0>gl||(e.current=l1[gl],l1[gl]=null,gl--)}function Ne(e,t){gl++,l1[gl]=e.current,e.current=t}var Uo=Go(null),$u=Go(null),wr=Go(null),Mm=Go(null);function Rm(e,t){switch(Ne(wr,t),Ne($u,e),Ne(Uo,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?v_(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=v_(t),e=uE(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}_t(Uo),Ne(Uo,e)}function Pl(){_t(Uo),_t($u),_t(wr)}function c1(e){e.memoizedState!==null&&Ne(Mm,e);var t=Uo.current,n=uE(t,e.type);t!==n&&(Ne($u,e),Ne(Uo,n))}function Om(e){$u.current===e&&(_t(Uo),_t($u)),Mm.current===e&&(_t(Mm),ld._currentValue=Ds)}var kx,mk;function Is(e){if(kx===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);kx=t&&t[1]||"",mk=-1<n.stack.indexOf(`
|
|
1
|
+
var JP=Object.create;var dx=Object.defineProperty;var e7=Object.getOwnPropertyDescriptor;var t7=Object.getOwnPropertyNames;var n7=Object.getPrototypeOf,o7=Object.prototype.hasOwnProperty;var Ut=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),yo=(e,t)=>{for(var n in t)dx(e,n,{get:t[n],enumerable:!0})},a7=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of t7(t))!o7.call(e,a)&&a!==n&&dx(e,a,{get:()=>t[a],enumerable:!(o=e7(t,a))||o.enumerable});return e};var P=(e,t,n)=>(n=e!=null?JP(n7(e)):{},a7(t||!e||!e.__esModule?dx(n,"default",{value:e,enumerable:!0}):n,e));var $3=Ut(Ve=>{"use strict";function mx(e,t){var n=e.length;e.push(t);e:for(;0<n;){var o=n-1>>>1,a=e[o];if(0<Kh(a,t))e[o]=t,e[n]=a,n=o;else break e}}function No(e){return e.length===0?null:e[0]}function Qh(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>Kh(i,n))l<a&&0>Kh(c,i)?(e[o]=c,e[l]=n,o=l):(e[o]=i,e[s]=n,o=s);else if(l<a&&0>Kh(c,n))e[o]=c,e[l]=n,o=l;else break e}}return t}function Kh(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}Ve.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(G3=performance,Ve.unstable_now=function(){return G3.now()}):(fx=Date,W3=fx.now(),Ve.unstable_now=function(){return fx.now()-W3});var G3,fx,W3,ma=[],hr=[],r7=1,Gn=null,Gt=3,yx=!1,ku=!1,_u=!1,gx=!1,j3=typeof setTimeout=="function"?setTimeout:null,Z3=typeof clearTimeout=="function"?clearTimeout:null,q3=typeof setImmediate<"u"?setImmediate:null;function $h(e){for(var t=No(hr);t!==null;){if(t.callback===null)Qh(hr);else if(t.startTime<=e)Qh(hr),t.sortIndex=t.expirationTime,mx(ma,t);else break;t=No(hr)}}function xx(e){if(_u=!1,$h(e),!ku)if(No(ma)!==null)ku=!0,ul||(ul=!0,cl());else{var t=No(hr);t!==null&&bx(xx,t.startTime-e)}}var ul=!1,wu=-1,X3=5,Y3=-1;function K3(){return gx?!0:!(Ve.unstable_now()-Y3<X3)}function px(){if(gx=!1,ul){var e=Ve.unstable_now();Y3=e;var t=!0;try{e:{ku=!1,_u&&(_u=!1,Z3(wu),wu=-1),yx=!0;var n=Gt;try{t:{for($h(e),Gn=No(ma);Gn!==null&&!(Gn.expirationTime>e&&K3());){var o=Gn.callback;if(typeof o=="function"){Gn.callback=null,Gt=Gn.priorityLevel;var a=o(Gn.expirationTime<=e);if(e=Ve.unstable_now(),typeof a=="function"){Gn.callback=a,$h(e),t=!0;break t}Gn===No(ma)&&Qh(ma),$h(e)}else Qh(ma);Gn=No(ma)}if(Gn!==null)t=!0;else{var r=No(hr);r!==null&&bx(xx,r.startTime-e),t=!1}}break e}finally{Gn=null,Gt=n,yx=!1}t=void 0}}finally{t?cl():ul=!1}}}var cl;typeof q3=="function"?cl=function(){q3(px)}:typeof MessageChannel<"u"?(hx=new MessageChannel,V3=hx.port2,hx.port1.onmessage=px,cl=function(){V3.postMessage(null)}):cl=function(){j3(px,0)};var hx,V3;function bx(e,t){wu=j3(function(){e(Ve.unstable_now())},t)}Ve.unstable_IdlePriority=5;Ve.unstable_ImmediatePriority=1;Ve.unstable_LowPriority=4;Ve.unstable_NormalPriority=3;Ve.unstable_Profiling=null;Ve.unstable_UserBlockingPriority=2;Ve.unstable_cancelCallback=function(e){e.callback=null};Ve.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"):X3=0<e?Math.floor(1e3/e):5};Ve.unstable_getCurrentPriorityLevel=function(){return Gt};Ve.unstable_next=function(e){switch(Gt){case 1:case 2:case 3:var t=3;break;default:t=Gt}var n=Gt;Gt=t;try{return e()}finally{Gt=n}};Ve.unstable_requestPaint=function(){gx=!0};Ve.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=Gt;Gt=e;try{return t()}finally{Gt=n}};Ve.unstable_scheduleCallback=function(e,t,n){var o=Ve.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:r7++,callback:t,priorityLevel:e,startTime:n,expirationTime:a,sortIndex:-1},n>o?(e.sortIndex=n,mx(hr,e),No(ma)===null&&e===No(hr)&&(_u?(Z3(wu),wu=-1):_u=!0,bx(xx,n-o))):(e.sortIndex=a,mx(ma,e),ku||yx||(ku=!0,ul||(ul=!0,cl()))),e};Ve.unstable_shouldYield=K3;Ve.unstable_wrapCallback=function(e){var t=Gt;return function(){var n=Gt;Gt=t;try{return e.apply(this,arguments)}finally{Gt=n}}}});var J3=Ut((tJ,Q3)=>{"use strict";Q3.exports=$3()});var uk=Ut(te=>{"use strict";var Sx=Symbol.for("react.transitional.element"),s7=Symbol.for("react.portal"),i7=Symbol.for("react.fragment"),l7=Symbol.for("react.strict_mode"),c7=Symbol.for("react.profiler"),u7=Symbol.for("react.consumer"),d7=Symbol.for("react.context"),f7=Symbol.for("react.forward_ref"),p7=Symbol.for("react.suspense"),h7=Symbol.for("react.memo"),ak=Symbol.for("react.lazy"),m7=Symbol.for("react.activity"),ek=Symbol.iterator;function y7(e){return e===null||typeof e!="object"?null:(e=ek&&e[ek]||e["@@iterator"],typeof e=="function"?e:null)}var rk={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},sk=Object.assign,ik={};function fl(e,t,n){this.props=e,this.context=t,this.refs=ik,this.updater=n||rk}fl.prototype.isReactComponent={};fl.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")};fl.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function lk(){}lk.prototype=fl.prototype;function Lx(e,t,n){this.props=e,this.context=t,this.refs=ik,this.updater=n||rk}var kx=Lx.prototype=new lk;kx.constructor=Lx;sk(kx,fl.prototype);kx.isPureReactComponent=!0;var tk=Array.isArray;function vx(){}var Ue={H:null,A:null,T:null,S:null},ck=Object.prototype.hasOwnProperty;function _x(e,t,n){var o=n.ref;return{$$typeof:Sx,type:e,key:t,ref:o!==void 0?o:null,props:n}}function g7(e,t){return _x(e.type,t,e.props)}function wx(e){return typeof e=="object"&&e!==null&&e.$$typeof===Sx}function x7(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var nk=/\/+/g;function Ax(e,t){return typeof e=="object"&&e!==null&&e.key!=null?x7(""+e.key):t.toString(36)}function b7(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(vx,vx):(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 dl(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 Sx:case s7:s=!0;break;case ak:return s=e._init,dl(s(e._payload),t,n,o,a)}}if(s)return a=a(e),s=o===""?"."+Ax(e,0):o,tk(a)?(n="",s!=null&&(n=s.replace(nk,"$&/")+"/"),dl(a,t,n,"",function(c){return c})):a!=null&&(wx(a)&&(a=g7(a,n+(a.key==null||e&&e.key===a.key?"":(""+a.key).replace(nk,"$&/")+"/")+s)),t.push(a)),1;s=0;var i=o===""?".":o+":";if(tk(e))for(var l=0;l<e.length;l++)o=e[l],r=i+Ax(o,l),s+=dl(o,t,n,r,a);else if(l=y7(e),typeof l=="function")for(e=l.call(e),l=0;!(o=e.next()).done;)o=o.value,r=i+Ax(o,l++),s+=dl(o,t,n,r,a);else if(r==="object"){if(typeof e.then=="function")return dl(b7(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 Jh(e,t,n){if(e==null)return e;var o=[],a=0;return dl(e,o,"","",function(r){return t.call(n,r,a++)}),o}function A7(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 ok=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)},v7={map:Jh,forEach:function(e,t,n){Jh(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Jh(e,function(){t++}),t},toArray:function(e){return Jh(e,function(t){return t})||[]},only:function(e){if(!wx(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};te.Activity=m7;te.Children=v7;te.Component=fl;te.Fragment=i7;te.Profiler=c7;te.PureComponent=Lx;te.StrictMode=l7;te.Suspense=p7;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=sk({},e.props),a=e.key;if(t!=null)for(r in t.key!==void 0&&(a=""+t.key),t)!ck.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 _x(e.type,a,o)};te.createContext=function(e){return e={$$typeof:d7,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:u7,_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)ck.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 _x(e,r,a)};te.createRef=function(){return{current:null}};te.forwardRef=function(e){return{$$typeof:f7,render:e}};te.isValidElement=wx;te.lazy=function(e){return{$$typeof:ak,_payload:{_status:-1,_result:e},_init:A7}};te.memo=function(e,t){return{$$typeof:h7,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(vx,ok)}catch(r){ok(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=Ut((oJ,dk)=>{"use strict";dk.exports=uk()});var pk=Ut(jt=>{"use strict";var S7=re();function fk(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 mr(){}var Vt={d:{f:mr,r:function(){throw Error(fk(522))},D:mr,C:mr,L:mr,m:mr,X:mr,S:mr,M:mr},p:0,findDOMNode:null},L7=Symbol.for("react.portal");function k7(e,t,n){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:L7,key:o==null?null:""+o,children:e,containerInfo:t,implementation:n}}var Tu=S7.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function em(e,t){if(e==="font")return"";if(typeof t=="string")return t==="use-credentials"?t:""}jt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Vt;jt.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(fk(299));return k7(e,t,null,n)};jt.flushSync=function(e){var t=Tu.T,n=Vt.p;try{if(Tu.T=null,Vt.p=2,e)return e()}finally{Tu.T=t,Vt.p=n,Vt.d.f()}};jt.preconnect=function(e,t){typeof e=="string"&&(t?(t=t.crossOrigin,t=typeof t=="string"?t==="use-credentials"?t:"":void 0):t=null,Vt.d.C(e,t))};jt.prefetchDNS=function(e){typeof e=="string"&&Vt.d.D(e)};jt.preinit=function(e,t){if(typeof e=="string"&&t&&typeof t.as=="string"){var n=t.as,o=em(n,t.crossOrigin),a=typeof t.integrity=="string"?t.integrity:void 0,r=typeof t.fetchPriority=="string"?t.fetchPriority:void 0;n==="style"?Vt.d.S(e,typeof t.precedence=="string"?t.precedence:void 0,{crossOrigin:o,integrity:a,fetchPriority:r}):n==="script"&&Vt.d.X(e,{crossOrigin:o,integrity:a,fetchPriority:r,nonce:typeof t.nonce=="string"?t.nonce:void 0})}};jt.preinitModule=function(e,t){if(typeof e=="string")if(typeof t=="object"&&t!==null){if(t.as==null||t.as==="script"){var n=em(t.as,t.crossOrigin);Vt.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&&Vt.d.M(e)};jt.preload=function(e,t){if(typeof e=="string"&&typeof t=="object"&&t!==null&&typeof t.as=="string"){var n=t.as,o=em(n,t.crossOrigin);Vt.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})}};jt.preloadModule=function(e,t){if(typeof e=="string")if(t){var n=em(t.as,t.crossOrigin);Vt.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 Vt.d.m(e)};jt.requestFormReset=function(e){Vt.d.r(e)};jt.unstable_batchedUpdates=function(e,t){return e(t)};jt.useFormState=function(e,t,n){return Tu.H.useFormState(e,t,n)};jt.useFormStatus=function(){return Tu.H.useHostTransitionStatus()};jt.version="19.2.6"});var ya=Ut((rJ,mk)=>{"use strict";function hk(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(hk)}catch(e){console.error(e)}}hk(),mk.exports=pk()});var TE=Ut(_0=>{"use strict";var mt=J3(),U_=re(),_7=ya();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 G_(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function pd(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 W_(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 q_(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 yk(e){if(pd(e)!==e)throw Error(O(188))}function w7(e){var t=e.alternate;if(!t){if(t=pd(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 yk(a),e;if(r===o)return yk(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 V_(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=V_(e),t!==null)return t;e=e.sibling}return null}var qe=Object.assign,T7=Symbol.for("react.element"),tm=Symbol.for("react.transitional.element"),Pu=Symbol.for("react.portal"),xl=Symbol.for("react.fragment"),j_=Symbol.for("react.strict_mode"),s1=Symbol.for("react.profiler"),Z_=Symbol.for("react.consumer"),ka=Symbol.for("react.context"),tb=Symbol.for("react.forward_ref"),i1=Symbol.for("react.suspense"),l1=Symbol.for("react.suspense_list"),nb=Symbol.for("react.memo"),yr=Symbol.for("react.lazy");Symbol.for("react.scope");var c1=Symbol.for("react.activity");Symbol.for("react.legacy_hidden");Symbol.for("react.tracing_marker");var E7=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var gk=Symbol.iterator;function Eu(e){return e===null||typeof e!="object"?null:(e=gk&&e[gk]||e["@@iterator"],typeof e=="function"?e:null)}var C7=Symbol.for("react.client.reference");function u1(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===C7?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case xl:return"Fragment";case s1:return"Profiler";case j_:return"StrictMode";case i1:return"Suspense";case l1:return"SuspenseList";case c1:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case Pu:return"Portal";case ka:return e.displayName||"Context";case Z_:return(e._context.displayName||"Context")+".Consumer";case tb:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case nb:return t=e.displayName||null,t!==null?t:u1(e.type)||"Memo";case yr:t=e._payload,e=e._init;try{return u1(e(t))}catch{}}return null}var Bu=Array.isArray,K=U_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e=_7.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Bs={pending:!1,data:null,method:null,action:null},d1=[],bl=-1;function Go(e){return{current:e}}function _t(e){0>bl||(e.current=d1[bl],d1[bl]=null,bl--)}function Ne(e,t){bl++,d1[bl]=e.current,e.current=t}var Uo=Go(null),Ju=Go(null),Tr=Go(null),Dm=Go(null);function Pm(e,t){switch(Ne(Tr,t),Ne(Ju,e),Ne(Uo,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?k_(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=k_(t),e=pE(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}_t(Uo),Ne(Uo,e)}function Nl(){_t(Uo),_t(Ju),_t(Tr)}function f1(e){e.memoizedState!==null&&Ne(Dm,e);var t=Uo.current,n=pE(t,e.type);t!==n&&(Ne(Ju,e),Ne(Uo,n))}function Bm(e){Ju.current===e&&(_t(Uo),_t(Ju)),Dm.current===e&&(_t(Dm),ud._currentValue=Bs)}var Tx,xk;function Rs(e){if(Tx===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Tx=t&&t[1]||"",xk=-1<n.stack.indexOf(`
|
|
2
2
|
at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
-
`+
|
|
3
|
+
`+Tx+e+xk}var Ex=!1;function Cx(e,t){if(!e||Ex)return"";Ex=!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{Ex=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?Rs(n):""}function I7(e,t){switch(e.tag){case 26:case 27:case 5:return Rs(e.type);case 16:return Rs("Lazy");case 13:return e.child!==t&&t!==null?Rs("Suspense Fallback"):Rs("Suspense");case 19:return Rs("SuspenseList");case 0:case 15:return Cx(e.type,!1);case 11:return Cx(e.type.render,!1);case 1:return Cx(e.type,!0);case 31:return Rs("Activity");default:return""}}function bk(e){try{var t="",n=null;do t+=I7(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 u1=Object.prototype.hasOwnProperty,eb=mt.unstable_scheduleCallback,Tx=mt.unstable_cancelCallback,d7=mt.unstable_shouldYield,f7=mt.unstable_requestPaint,Ln=mt.unstable_now,p7=mt.unstable_getCurrentPriorityLevel,V_=mt.unstable_ImmediatePriority,j_=mt.unstable_UserBlockingPriority,Dm=mt.unstable_NormalPriority,h7=mt.unstable_LowPriority,Z_=mt.unstable_IdlePriority,m7=mt.log,y7=mt.unstable_setDisableYieldValue,fd=null,kn=null;function vr(e){if(typeof m7=="function"&&y7(e),kn&&typeof kn.setStrictMode=="function")try{kn.setStrictMode(fd,e)}catch{}}var _n=Math.clz32?Math.clz32:b7,g7=Math.log,x7=Math.LN2;function b7(e){return e>>>=0,e===0?32:31-(g7(e)/x7|0)|0}var Jh=256,em=262144,tm=4194304;function Ms(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 s0(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=Ms(o):(s&=i,s!==0?a=Ms(s):n||(n=i&~e,n!==0&&(a=Ms(n))))):(i=o&~r,i!==0?a=Ms(i):s!==0?a=Ms(s):n||(n=o&~e,n!==0&&(a=Ms(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 pd(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function A7(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 X_(){var e=tm;return tm<<=1,(tm&62914560)===0&&(tm=4194304),e}function Ex(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function hd(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function v7(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-_n(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&&Y_(e,o,0),r!==0&&a===0&&e.tag!==0&&(e.suspendedLanes|=r&~(s&~t))}function Y_(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-_n(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|n&261930}function K_(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var o=31-_n(n),a=1<<o;a&t|e[o]&t&&(e[o]|=t),n&=~a}}function $_(e,t){var n=t&-t;return n=(n&42)!==0?1:tb(n),(n&(e.suspendedLanes|t))!==0?0:n}function tb(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 nb(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Q_(){var e=_e.p;return e!==0?e:(e=window.event,e===void 0?32:vE(e.type))}function gk(e,t){var n=_e.p;try{return _e.p=e,t()}finally{_e.p=n}}var Fr=Math.random().toString(36).slice(2),Mt="__reactFiber$"+Fr,an="__reactProps$"+Fr,jl="__reactContainer$"+Fr,d1="__reactEvents$"+Fr,S7="__reactListeners$"+Fr,L7="__reactHandles$"+Fr,xk="__reactResources$"+Fr,md="__reactMarker$"+Fr;function ob(e){delete e[Mt],delete e[an],delete e[d1],delete e[S7],delete e[L7]}function xl(e){var t=e[Mt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[jl]||n[Mt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=w_(e);e!==null;){if(n=e[Mt])return n;e=w_(e)}return t}e=n,n=e.parentNode}return null}function Zl(e){if(e=e[Mt]||e[jl]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Pu(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(O(33))}function El(e){var t=e[xk];return t||(t=e[xk]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function kt(e){e[md]=!0}var J_=new Set,ew={};function qs(e,t){Bl(e,t),Bl(e+"Capture",t)}function Bl(e,t){for(ew[e]=t,e=0;e<t.length;e++)J_.add(t[e])}var k7=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]*$"),bk={},Ak={};function _7(e){return u1.call(Ak,e)?!0:u1.call(bk,e)?!1:k7.test(e)?Ak[e]=!0:(bk[e]=!0,!1)}function ym(e,t,n){if(_7(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 nm(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 ga(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 qn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function tw(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function w7(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 f1(e){if(!e._valueTracker){var t=tw(e)?"checked":"value";e._valueTracker=w7(e,t,""+e[t])}}function nw(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),o="";return e&&(o=tw(e)?e.checked?"true":"false":e.value),e=o,e!==n?(t.setValue(e),!0):!1}function Pm(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 T7=/[\n"\\]/g;function Zn(e){return e.replace(T7,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function p1(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=""+qn(t)):e.value!==""+qn(t)&&(e.value=""+qn(t)):s!=="submit"&&s!=="reset"||e.removeAttribute("value"),t!=null?h1(e,s,qn(t)):n!=null?h1(e,s,qn(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=""+qn(i):e.removeAttribute("name")}function ow(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)){f1(e);return}n=n!=null?""+qn(n):"",t=t!=null?""+qn(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),f1(e)}function h1(e,t,n){t==="number"&&Pm(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=""+qn(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 aw(e,t,n){if(t!=null&&(t=""+qn(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+qn(n):""}function rw(e,t,n,o){if(t==null){if(o!=null){if(n!=null)throw Error(O(92));if(Du(o)){if(1<o.length)throw Error(O(93));o=o[0]}n=o}n==null&&(n=""),t=n}n=qn(t),e.defaultValue=n,o=e.textContent,o===n&&o!==""&&o!==null&&(e.value=o),f1(e)}function Nl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var E7=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 vk(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||E7.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function sw(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&&vk(e,a,o)}else for(var r in t)t.hasOwnProperty(r)&&vk(e,r,t[r])}function ab(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 C7=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"]]),I7=/^[\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 gm(e){return I7.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function _a(){}var m1=null;function rb(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var bl=null,Il=null;function Sk(e){var t=Zl(e);if(t&&(e=t.stateNode)){var n=e[an]||null;e:switch(e=t.stateNode,t.type){case"input":if(p1(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="'+Zn(""+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));p1(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&&nw(o)}break e;case"textarea":aw(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&Cl(e,!!n.multiple,t,!1)}}}var Cx=!1;function iw(e,t,n){if(Cx)return e(t,n);Cx=!0;try{var o=e(t);return o}finally{if(Cx=!1,(bl!==null||Il!==null)&&(x0(),bl&&(t=bl,e=Il,Il=bl=null,Sk(t),e)))for(t=0;t<e.length;t++)Sk(e[t])}}function Qu(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 Ia=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),y1=!1;if(Ia)try{dl={},Object.defineProperty(dl,"passive",{get:function(){y1=!0}}),window.addEventListener("test",dl,dl),window.removeEventListener("test",dl,dl)}catch{y1=!1}var dl,Sr=null,sb=null,xm=null;function lw(){if(xm)return xm;var e,t=sb,n=t.length,o,a="value"in Sr?Sr.value:Sr.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 xm=a.slice(e,1<o?1-o:void 0)}function bm(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 om(){return!0}function Lk(){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)?om:Lk,this.isPropagationStopped=Lk,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=om)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=om)},persist:function(){},isPersistent:om}),t}var Vs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},i0=rn(Vs),yd=qe({},Vs,{view:0,detail:0}),M7=rn(yd),Ix,Mx,Tu,l0=qe({},yd,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ib,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!==Tu&&(Tu&&e.type==="mousemove"?(Ix=e.screenX-Tu.screenX,Mx=e.screenY-Tu.screenY):Mx=Ix=0,Tu=e),Ix)},movementY:function(e){return"movementY"in e?e.movementY:Mx}}),kk=rn(l0),R7=qe({},l0,{dataTransfer:0}),O7=rn(R7),D7=qe({},yd,{relatedTarget:0}),Rx=rn(D7),P7=qe({},Vs,{animationName:0,elapsedTime:0,pseudoElement:0}),B7=rn(P7),N7=qe({},Vs,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),z7=rn(N7),F7=qe({},Vs,{data:0}),_k=rn(F7),H7={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},U7={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"},G7={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function W7(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=G7[e])?!!t[e]:!1}function ib(){return W7}var q7=qe({},yd,{key:function(e){if(e.key){var t=H7[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=bm(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?U7[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ib,charCode:function(e){return e.type==="keypress"?bm(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?bm(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),V7=rn(q7),j7=qe({},l0,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),wk=rn(j7),Z7=qe({},yd,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ib}),X7=rn(Z7),Y7=qe({},Vs,{propertyName:0,elapsedTime:0,pseudoElement:0}),K7=rn(Y7),$7=qe({},l0,{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}),Q7=rn($7),J7=qe({},Vs,{newState:0,oldState:0}),eB=rn(J7),tB=[9,13,27,32],lb=Ia&&"CompositionEvent"in window,zu=null;Ia&&"documentMode"in document&&(zu=document.documentMode);var nB=Ia&&"TextEvent"in window&&!zu,cw=Ia&&(!lb||zu&&8<zu&&11>=zu),Tk=" ",Ek=!1;function uw(e,t){switch(e){case"keyup":return tB.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function dw(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Al=!1;function oB(e,t){switch(e){case"compositionend":return dw(t);case"keypress":return t.which!==32?null:(Ek=!0,Tk);case"textInput":return e=t.data,e===Tk&&Ek?null:e;default:return null}}function aB(e,t){if(Al)return e==="compositionend"||!lb&&uw(e,t)?(e=lw(),xm=sb=Sr=null,Al=!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 cw&&t.locale!=="ko"?null:t.data;default:return null}}var rB={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"?!!rB[e.type]:t==="textarea"}function fw(e,t,n,o){bl?Il?Il.push(o):Il=[o]:bl=o,t=Jm(t,"onChange"),0<t.length&&(n=new i0("onChange","change",null,n,o),e.push({event:n,listeners:t}))}var Fu=null,Ju=null;function sB(e){iE(e,0)}function c0(e){var t=Pu(e);if(nw(t))return e}function Ik(e,t){if(e==="change")return t}var pw=!1;Ia&&(Ia?(rm="oninput"in document,rm||(Ox=document.createElement("div"),Ox.setAttribute("oninput","return;"),rm=typeof Ox.oninput=="function"),am=rm):am=!1,pw=am&&(!document.documentMode||9<document.documentMode));var am,rm,Ox;function Mk(){Fu&&(Fu.detachEvent("onpropertychange",hw),Ju=Fu=null)}function hw(e){if(e.propertyName==="value"&&c0(Ju)){var t=[];fw(t,Ju,e,rb(e)),iw(sB,t)}}function iB(e,t,n){e==="focusin"?(Mk(),Fu=t,Ju=n,Fu.attachEvent("onpropertychange",hw)):e==="focusout"&&Mk()}function lB(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return c0(Ju)}function cB(e,t){if(e==="click")return c0(t)}function uB(e,t){if(e==="input"||e==="change")return c0(t)}function dB(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Tn=typeof Object.is=="function"?Object.is:dB;function ed(e,t){if(Tn(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(!u1.call(t,a)||!Tn(e[a],t[a]))return!1}return!0}function Rk(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ok(e,t){var n=Rk(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=Rk(n)}}function mw(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?mw(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function yw(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Pm(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=Pm(e.document)}return t}function cb(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 fB=Ia&&"documentMode"in document&&11>=document.documentMode,vl=null,g1=null,Hu=null,x1=!1;function Dk(e,t,n){var o=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;x1||vl==null||vl!==Pm(o)||(o=vl,"selectionStart"in o&&cb(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}),Hu&&ed(Hu,o)||(Hu=o,o=Jm(g1,"onSelect"),0<o.length&&(t=new i0("onSelect","select",null,t,n),e.push({event:t,listeners:o}),t.target=vl)))}function Cs(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Sl={animationend:Cs("Animation","AnimationEnd"),animationiteration:Cs("Animation","AnimationIteration"),animationstart:Cs("Animation","AnimationStart"),transitionrun:Cs("Transition","TransitionRun"),transitionstart:Cs("Transition","TransitionStart"),transitioncancel:Cs("Transition","TransitionCancel"),transitionend:Cs("Transition","TransitionEnd")},Dx={},gw={};Ia&&(gw=document.createElement("div").style,"AnimationEvent"in window||(delete Sl.animationend.animation,delete Sl.animationiteration.animation,delete Sl.animationstart.animation),"TransitionEvent"in window||delete Sl.transitionend.transition);function js(e){if(Dx[e])return Dx[e];if(!Sl[e])return e;var t=Sl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in gw)return Dx[e]=t[n];return e}var xw=js("animationend"),bw=js("animationiteration"),Aw=js("animationstart"),pB=js("transitionrun"),hB=js("transitionstart"),mB=js("transitioncancel"),vw=js("transitionend"),Sw=new Map,b1="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(" ");b1.push("scrollEnd");function bo(e,t){Sw.set(e,t),qs(t,[e])}var Bm=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)},Wn=[],Ll=0,ub=0;function u0(){for(var e=Ll,t=ub=Ll=0;t<e;){var n=Wn[t];Wn[t++]=null;var o=Wn[t];Wn[t++]=null;var a=Wn[t];Wn[t++]=null;var r=Wn[t];if(Wn[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&&Lw(n,a,r)}}function d0(e,t,n,o){Wn[Ll++]=e,Wn[Ll++]=t,Wn[Ll++]=n,Wn[Ll++]=o,ub|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function db(e,t,n,o){return d0(e,t,n,o),Nm(e)}function Zs(e,t){return d0(e,null,null,t),Nm(e)}function Lw(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-_n(n),e=r.hiddenUpdates,o=e[a],o===null?e[a]=[t]:o.push(t),t.lane=n|536870912),r):null}function Nm(e){if(50<Yu)throw Yu=0,H1=null,Error(O(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var kl={};function yB(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 yB(e,t,n,o)}function fb(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ta(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 kw(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 Am(e,t,n,o,a,r){var s=0;if(o=e,typeof e=="function")fb(e)&&(s=1);else if(typeof e=="string")s=bN(e,n,Uo.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case s1:return e=vn(31,n,t,a),e.elementType=s1,e.lanes=r,e;case yl:return Ps(n.children,a,r,t);case W_:s=8,a|=24;break;case o1:return e=vn(12,n,t,a|2),e.elementType=o1,e.lanes=r,e;case a1:return e=vn(13,n,t,a),e.elementType=a1,e.lanes=r,e;case r1:return e=vn(19,n,t,a),e.elementType=r1,e.lanes=r,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ka:s=10;break e;case q_:s=9;break e;case Q1:s=11;break e;case J1:s=14;break e;case mr: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 Ps(e,t,n,o){return e=vn(7,e,o,t),e.lanes=n,e}function Px(e,t,n){return e=vn(6,e,null,t),e.lanes=n,e}function _w(e){var t=vn(18,null,null,0);return t.stateNode=e,t}function Bx(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 Pk=new WeakMap;function Xn(e,t){if(typeof e=="object"&&e!==null){var n=Pk.get(e);return n!==void 0?n:(t={value:e,source:t,stack:yk(t)},Pk.set(e,t),t)}return{value:e,source:t,stack:yk(t)}}var _l=[],wl=0,zm=null,td=0,Vn=[],jn=0,Pr=null,zo=1,Fo="";function Sa(e,t){_l[wl++]=td,_l[wl++]=zm,zm=e,td=t}function ww(e,t,n){Vn[jn++]=zo,Vn[jn++]=Fo,Vn[jn++]=Pr,Pr=e;var o=zo;e=Fo;var a=32-_n(o)-1;o&=~(1<<a),n+=1;var r=32-_n(t)+a;if(30<r){var s=a-a%5;r=(o&(1<<s)-1).toString(32),o>>=s,a-=s,zo=1<<32-_n(t)+a|n<<a|o,Fo=r+e}else zo=1<<r|n<<a|o,Fo=e}function pb(e){e.return!==null&&(Sa(e,1),ww(e,1,0))}function hb(e){for(;e===zm;)zm=_l[--wl],_l[wl]=null,td=_l[--wl],_l[wl]=null;for(;e===Pr;)Pr=Vn[--jn],Vn[jn]=null,Fo=Vn[--jn],Vn[jn]=null,zo=Vn[--jn],Vn[jn]=null}function Tw(e,t){Vn[jn++]=zo,Vn[jn++]=Fo,Vn[jn++]=Pr,zo=t.id,Fo=t.overflow,Pr=e}var Rt=null,We=null,be=!1,Tr=null,Yn=!1,A1=Error(O(519));function Br(e){var t=Error(O(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw nd(Xn(t,e)),A1}function Bk(e){var t=e.stateNode,n=e.type,o=e.memoizedProps;switch(t[Mt]=e,t[an]=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<sd.length;n++)de(sd[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),ow(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),rw(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||cE(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=_a),t=!0):t=!1,t||Br(e,!0)}function Nk(e){for(Rt=e.return;Rt;)switch(Rt.tag){case 5:case 31:case 13:Yn=!1;return;case 27:case 3:Yn=!0;return;default:Rt=Rt.return}}function fl(e){if(e!==Rt)return!1;if(!be)return Nk(e),be=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||V1(e.type,e.memoizedProps)),n=!n),n&&We&&Br(e),Nk(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));We=__(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));We=__(e)}else t===27?(t=We,Hr(e.type)?(e=Y1,Y1=null,We=e):We=t):We=Rt?$n(e.stateNode.nextSibling):null;return!0}function Fs(){We=Rt=null,be=!1}function Nx(){var e=Tr;return e!==null&&(nn===null?nn=e:nn.push.apply(nn,e),Tr=null),e}function nd(e){Tr===null?Tr=[e]:Tr.push(e)}var v1=Go(null),Xs=null,wa=null;function gr(e,t,n){Ne(v1,t._currentValue),t._currentValue=n}function Ea(e){e._currentValue=v1.current,_t(v1)}function S1(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 L1(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),S1(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),S1(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 Xl(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;Tn(a.pendingProps.value,s.value)||(e!==null?e.push(i):e=[i])}}else if(a===Mm.current){if(s=a.alternate,s===null)throw Error(O(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e!==null?e.push(ld):e=[ld])}a=a.return}e!==null&&L1(t,e,n,o),t.flags|=262144}function Fm(e){for(e=e.firstContext;e!==null;){if(!Tn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Hs(e){Xs=e,wa=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ot(e){return Ew(Xs,e)}function sm(e,t){return Xs===null&&Hs(e),Ew(e,t)}function Ew(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},wa===null){if(e===null)throw Error(O(308));wa=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else wa=wa.next=t;return n}var gB=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()})}},xB=mt.unstable_scheduleCallback,bB=mt.unstable_NormalPriority,it={$$typeof:ka,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function mb(){return{controller:new gB,data:new Map,refCount:0}}function gd(e){e.refCount--,e.refCount===0&&xB(bB,function(){e.controller.abort()})}var Uu=null,k1=0,zl=0,Ml=null;function AB(e,t){if(Uu===null){var n=Uu=[];k1=0,zl=Hb(),Ml={status:"pending",value:void 0,then:function(o){n.push(o)}}}return k1++,t.then(zk,zk),t}function zk(){if(--k1===0&&Uu!==null){Ml!==null&&(Ml.status="fulfilled");var e=Uu;Uu=null,zl=0,Ml=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function vB(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 Fk=K.S;K.S=function(e,t){GT=Ln(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&AB(e,t),Fk!==null&&Fk(e,t)};var Bs=Go(null);function yb(){var e=Bs.current;return e!==null?e:De.pooledCache}function vm(e,t){t===null?Ne(Bs,Bs.current):Ne(Bs,t.pool)}function Cw(){var e=yb();return e===null?null:{parent:it._currentValue,pool:e}}var Yl=Error(O(460)),gb=Error(O(474)),f0=Error(O(542)),Hm={then:function(){}};function Hk(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Iw(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(_a,_a),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Gk(e),e;default:if(typeof t.status=="string")t.then(_a,_a);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,Gk(e),e}throw Ns=t,Yl}}function Rs(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Ns=n,Yl):n}}var Ns=null;function Uk(){if(Ns===null)throw Error(O(459));var e=Ns;return Ns=null,e}function Gk(e){if(e===Yl||e===f0)throw Error(O(483))}var Rl=null,od=0;function im(e){var t=od;return od+=1,Rl===null&&(Rl=[]),Iw(Rl,e,t)}function Eu(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function lm(e,t){throw t.$$typeof===i7?Error(O(525)):(e=Object.prototype.toString.call(t),Error(O(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Mw(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=Ta(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=Px(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 _===yl?u(y,g,b.props.children,A,b.key):g!==null&&(g.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===mr&&Rs(_)===g.type)?(g=a(g,b.props),Eu(g,b),g.return=y,g):(g=Am(b.type,b.key,b.props,null,y.mode,A),Eu(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=Bx(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=Ps(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=Px(""+g,y.mode,b),g.return=y,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case Qh:return b=Am(g.type,g.key,g.props,null,y.mode,b),Eu(b,g),b.return=y,b;case Ou:return g=Bx(g,y.mode,b),g.return=y,g;case mr:return g=Rs(g),d(y,g,b)}if(Du(g)||wu(g))return g=Ps(g,y.mode,b,null),g.return=y,g;if(typeof g.then=="function")return d(y,im(g),b);if(g.$$typeof===ka)return d(y,sm(y,g),b);lm(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 Qh:return b.key===_?l(y,g,b,A):null;case Ou:return b.key===_?c(y,g,b,A):null;case mr:return b=Rs(b),f(y,g,b,A)}if(Du(b)||wu(b))return _!==null?null:u(y,g,b,A,null);if(typeof b.then=="function")return f(y,g,im(b),A);if(b.$$typeof===ka)return f(y,g,sm(y,b),A);lm(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 Qh:return y=y.get(A.key===null?b:A.key)||null,l(g,y,A,_);case Ou:return y=y.get(A.key===null?b:A.key)||null,c(g,y,A,_);case mr:return A=Rs(A),p(y,g,b,A,_)}if(Du(A)||wu(A))return y=y.get(b)||null,u(g,y,A,_,null);if(typeof A.then=="function")return p(y,g,b,im(A),_);if(A.$$typeof===ka)return p(y,g,b,sm(g,A),_);lm(g,A)}return null}function h(y,g,b,A){for(var _=null,C=null,w=g,L=g=0,k=null;w!==null&&L<b.length;L++){w.index>L?(k=w,w=null):k=w.sibling;var M=f(y,w,b[L],A);if(M===null){w===null&&(w=k);break}e&&w&&M.alternate===null&&t(y,w),g=r(M,g,L),C===null?_=M:C.sibling=M,C=M,w=k}if(L===b.length)return n(y,w),be&&Sa(y,L),_;if(w===null){for(;L<b.length;L++)w=d(y,b[L],A),w!==null&&(g=r(w,g,L),C===null?_=w:C.sibling=w,C=w);return be&&Sa(y,L),_}for(w=o(w);L<b.length;L++)k=p(w,y,L,b[L],A),k!==null&&(e&&k.alternate!==null&&w.delete(k.key===null?L:k.key),g=r(k,g,L),C===null?_=k:C.sibling=k,C=k);return e&&w.forEach(function(B){return t(y,B)}),be&&Sa(y,L),_}function m(y,g,b,A){if(b==null)throw Error(O(151));for(var _=null,C=null,w=g,L=g=0,k=null,M=b.next();w!==null&&!M.done;L++,M=b.next()){w.index>L?(k=w,w=null):k=w.sibling;var B=f(y,w,M.value,A);if(B===null){w===null&&(w=k);break}e&&w&&B.alternate===null&&t(y,w),g=r(B,g,L),C===null?_=B:C.sibling=B,C=B,w=k}if(M.done)return n(y,w),be&&Sa(y,L),_;if(w===null){for(;!M.done;L++,M=b.next())M=d(y,M.value,A),M!==null&&(g=r(M,g,L),C===null?_=M:C.sibling=M,C=M);return be&&Sa(y,L),_}for(w=o(w);!M.done;L++,M=b.next())M=p(w,y,L,M.value,A),M!==null&&(e&&M.alternate!==null&&w.delete(M.key===null?L:M.key),g=r(M,g,L),C===null?_=M:C.sibling=M,C=M);return e&&w.forEach(function(G){return t(y,G)}),be&&Sa(y,L),_}function x(y,g,b,A){if(typeof b=="object"&&b!==null&&b.type===yl&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case Qh:e:{for(var _=b.key;g!==null;){if(g.key===_){if(_=b.type,_===yl){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===mr&&Rs(_)===g.type){n(y,g.sibling),A=a(g,b.props),Eu(A,b),A.return=y,y=A;break e}n(y,g);break}else t(y,g);g=g.sibling}b.type===yl?(A=Ps(b.props.children,y.mode,A,b.key),A.return=y,y=A):(A=Am(b.type,b.key,b.props,null,y.mode,A),Eu(A,b),A.return=y,y=A)}return s(y);case Ou: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=Bx(b,y.mode,A),A.return=y,y=A}return s(y);case mr:return b=Rs(b),x(y,g,b,A)}if(Du(b))return h(y,g,b,A);if(wu(b)){if(_=wu(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,im(b),A);if(b.$$typeof===ka)return x(y,g,sm(y,b),A);lm(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=Px(b,y.mode,A),A.return=y,y=A),s(y)):n(y,g)}return function(y,g,b,A){try{od=0;var _=x(y,g,b,A);return Rl=null,_}catch(w){if(w===Yl||w===f0)throw w;var C=vn(29,w,null,y.mode);return C.lanes=A,C.return=y,C}finally{}}}var Us=Mw(!0),Rw=Mw(!1),yr=!1;function xb(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function _1(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 Er(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Cr(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=Nm(e),Lw(e,null,n),t}return d0(e,o,t,n),Nm(e)}function Gu(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,K_(e,n)}}function zx(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 w1=!1;function Wu(){if(w1){var e=Ml;if(e!==null)throw e}}function qu(e,t,n,o){w1=!1;var a=e.updateQueue;yr=!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===zl&&(w1=!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:yr=!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),zr|=s,e.lanes=s,e.memoizedState=d}}function Ow(e,t){if(typeof e!="function")throw Error(O(191,e));e.call(t)}function Dw(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ow(n[e],t)}var Fl=Go(null),Um=Go(0);function Wk(e,t){e=Da,Ne(Um,e),Ne(Fl,t),Da=e|t.baseLanes}function T1(){Ne(Um,Da),Ne(Fl,Fl.current)}function bb(){Da=Um.current,_t(Fl),_t(Um)}var En=Go(null),Kn=null;function xr(e){var t=e.alternate;Ne(tt,tt.current&1),Ne(En,e),Kn===null&&(t===null||Fl.current!==null||t.memoizedState!==null)&&(Kn=e)}function E1(e){Ne(tt,tt.current),Ne(En,e),Kn===null&&(Kn=e)}function Pw(e){e.tag===22?(Ne(tt,tt.current),Ne(En,e),Kn===null&&(Kn=e)):br(e)}function br(){Ne(tt,tt.current),Ne(En,En.current)}function An(e){_t(En),Kn===e&&(Kn=null),_t(tt)}var tt=Go(0);function Gm(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||Z1(n)||X1(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 Ma=0,oe=null,Me=null,rt=null,Wm=!1,Ol=!1,Gs=!1,qm=0,ad=0,Dl=null,SB=0;function Qe(){throw Error(O(321))}function Ab(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Tn(e[n],t[n]))return!1;return!0}function vb(e,t,n,o,a,r){return Ma=r,oe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,K.H=e===null||e.memoizedState===null?fT:Rb,Gs=!1,r=n(o,a),Gs=!1,Ol&&(r=Nw(t,n,o,a)),Bw(e),r}function Bw(e){K.H=rd;var t=Me!==null&&Me.next!==null;if(Ma=0,rt=Me=oe=null,Wm=!1,ad=0,Dl=null,t)throw Error(O(300));e===null||lt||(e=e.dependencies,e!==null&&Fm(e)&&(lt=!0))}function Nw(e,t,n,o){oe=e;var a=0;do{if(Ol&&(Dl=null),ad=0,Ol=!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=pT,r=t(n,o)}while(Ol);return r}function LB(){var e=K.H,t=e.useState()[0];return t=typeof t.then=="function"?xd(t):t,e=e.useState()[0],(Me!==null?Me.memoizedState:null)!==e&&(oe.flags|=1024),t}function Sb(){var e=qm!==0;return qm=0,e}function Lb(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function kb(e){if(Wm){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Wm=!1}Ma=0,rt=Me=oe=null,Ol=!1,ad=qm=0,Dl=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 p0(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function xd(e){var t=ad;return ad+=1,Dl===null&&(Dl=[]),e=Iw(Dl,e,t),t=oe,(rt===null?t.memoizedState:rt.next)===null&&(t=t.alternate,K.H=t===null||t.memoizedState===null?fT:Rb),e}function h0(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return xd(e);if(e.$$typeof===ka)return Ot(e)}throw Error(O(438,String(e)))}function _b(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=p0(),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]=l7;return t.index++,n}function Ra(e,t){return typeof t=="function"?t(e):t}function Sm(e){var t=nt();return wb(t,Me,e)}function wb(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:(Ma&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===zl&&(u=!0);else if((Ma&f)===f){c=c.next,f===zl&&(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,zr|=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,zr|=d;c=c.next}while(c!==null&&c!==t);if(l===null?s=r:l.next=i,!Tn(r,e.memoizedState)&&(lt=!0,u&&(n=Ml,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 Fx(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);Tn(r,t.memoizedState)||(lt=!0),t.memoizedState=r,t.baseQueue===null&&(t.baseState=r),n.lastRenderedState=r}return[r,o]}function zw(e,t,n){var o=oe,a=nt(),r=be;if(r){if(n===void 0)throw Error(O(407));n=n()}else n=t();var s=!Tn((Me||a).memoizedState,n);if(s&&(a.memoizedState=n,lt=!0),a=a.queue,Tb(Uw.bind(null,o,a,e),[e]),a.getSnapshot!==t||s||rt!==null&&rt.memoizedState.tag&1){if(o.flags|=2048,Hl(9,{destroy:void 0},Hw.bind(null,o,a,n,t),null),De===null)throw Error(O(349));r||(Ma&127)!==0||Fw(o,t,n)}return n}function Fw(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=oe.updateQueue,t===null?(t=p0(),oe.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Hw(e,t,n,o){t.value=n,t.getSnapshot=o,Gw(t)&&Ww(e)}function Uw(e,t,n){return n(function(){Gw(t)&&Ww(e)})}function Gw(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Tn(e,n)}catch{return!0}}function Ww(e){var t=Zs(e,2);t!==null&&on(t,e,2)}function C1(e){var t=Zt();if(typeof e=="function"){var n=e;if(e=n(),Gs){vr(!0);try{n()}finally{vr(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:e},t}function qw(e,t,n,o){return e.baseState=n,wb(e,Me,typeof o=="function"?o:Ra)}function kB(e,t,n,o,a){if(y0(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,Vw(t,r)):(r.next=n.next,t.pending=n.next=r)}}function Vw(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),qk(e,t,i)}catch(c){I1(e,t,c)}finally{r!==null&&s.types!==null&&(r.types=s.types),K.T=r}}else try{r=n(a,o),qk(e,t,r)}catch(c){I1(e,t,c)}}function qk(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(o){Vk(e,t,o)},function(o){return I1(e,t,o)}):Vk(e,t,n)}function Vk(e,t,n){t.status="fulfilled",t.value=n,jw(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Vw(e,n)))}function I1(e,t,n){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=n,jw(t),t=t.next;while(t!==o)}e.action=null}function jw(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Zw(e,t){return t}function jk(e,t){if(be){var n=De.formState;if(n!==null){e:{var o=oe;if(be){if(We){t:{for(var a=We,r=Yn;a.nodeType!==8;){if(!r){a=null;break t}if(a=$n(a.nextSibling),a===null){a=null;break t}}r=a.data,a=r==="F!"||r==="F"?a:null}if(a){We=$n(a.nextSibling),o=a.data==="F!";break e}}Br(o)}o=!1}o&&(t=n[0])}}return n=Zt(),n.memoizedState=n.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zw,lastRenderedState:t},n.queue=o,n=cT.bind(null,oe,o),o.dispatch=n,o=C1(!1),r=Mb.bind(null,oe,!1,o.queue),o=Zt(),a={state:t,dispatch:null,action:e,pending:null},o.queue=a,n=kB.bind(null,oe,a,r,n),a.dispatch=n,o.memoizedState=e,[t,n,!1]}function Zk(e){var t=nt();return Xw(t,Me,e)}function Xw(e,t,n){if(t=wb(e,t,Zw)[0],e=Sm(Ra)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=xd(t)}catch(s){throw s===Yl?f0:s}else o=t;t=nt();var a=t.queue,r=a.dispatch;return n!==t.memoizedState&&(oe.flags|=2048,Hl(9,{destroy:void 0},_B.bind(null,a,n),null)),[o,r,e]}function _B(e,t){e.action=t}function Xk(e){var t=nt(),n=Me;if(n!==null)return Xw(t,n,e);nt(),t=t.memoizedState,n=nt();var o=n.queue.dispatch;return n.memoizedState=e,[t,o,!1]}function Hl(e,t,n,o){return e={tag:e,create:n,deps:o,inst:t,next:null},t=oe.updateQueue,t===null&&(t=p0(),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 Yw(){return nt().memoizedState}function Lm(e,t,n,o){var a=Zt();oe.flags|=e,a.memoizedState=Hl(1|t,{destroy:void 0},n,o===void 0?null:o)}function m0(e,t,n,o){var a=nt();o=o===void 0?null:o;var r=a.memoizedState.inst;Me!==null&&o!==null&&Ab(o,Me.memoizedState.deps)?a.memoizedState=Hl(t,r,n,o):(oe.flags|=e,a.memoizedState=Hl(1|t,r,n,o))}function Yk(e,t){Lm(8390656,8,e,t)}function Tb(e,t){m0(2048,8,e,t)}function wB(e){oe.flags|=4;var t=oe.updateQueue;if(t===null)t=p0(),oe.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Kw(e){var t=nt().memoizedState;return wB({ref:t,nextImpl:e}),function(){if((ke&2)!==0)throw Error(O(440));return t.impl.apply(void 0,arguments)}}function $w(e,t){return m0(4,2,e,t)}function Qw(e,t){return m0(4,4,e,t)}function Jw(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 eT(e,t,n){n=n!=null?n.concat([e]):null,m0(4,4,Jw.bind(null,t,e),n)}function Eb(){}function tT(e,t){var n=nt();t=t===void 0?null:t;var o=n.memoizedState;return t!==null&&Ab(t,o[1])?o[0]:(n.memoizedState=[e,t],e)}function nT(e,t){var n=nt();t=t===void 0?null:t;var o=n.memoizedState;if(t!==null&&Ab(t,o[1]))return o[0];if(o=e(),Gs){vr(!0);try{e()}finally{vr(!1)}}return n.memoizedState=[o,t],o}function Cb(e,t,n){return n===void 0||(Ma&1073741824)!==0&&(me&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=qT(),oe.lanes|=e,zr|=e,n)}function oT(e,t,n,o){return Tn(n,t)?n:Fl.current!==null?(e=Cb(e,n,o),Tn(e,t)||(lt=!0),e):(Ma&42)===0||(Ma&1073741824)!==0&&(me&261930)===0?(lt=!0,e.memoizedState=n):(e=qT(),oe.lanes|=e,zr|=e,t)}function aT(e,t,n,o,a){var r=_e.p;_e.p=r!==0&&8>r?r:8;var s=K.T,i={};K.T=i,Mb(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=vB(l,o);Vu(e,t,u,wn(e))}else Vu(e,t,o,wn(e))}catch(d){Vu(e,t,{then:function(){},status:"rejected",reason:d},wn())}finally{_e.p=r,s!==null&&i.types!==null&&(s.types=i.types),K.T=s}}function TB(){}function M1(e,t,n,o){if(e.tag!==5)throw Error(O(476));var a=rT(e).queue;aT(e,a,t,Ds,n===null?TB:function(){return sT(e),n(o)})}function rT(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Ds,baseState:Ds,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:Ds},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function sT(e){var t=rT(e);t.next===null&&(t=e.alternate.memoizedState),Vu(e,t.next.queue,{},wn())}function Ib(){return Ot(ld)}function iT(){return nt().memoizedState}function lT(){return nt().memoizedState}function EB(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=wn();e=Er(n);var o=Cr(t,e,n);o!==null&&(on(o,t,n),Gu(o,t,n)),t={cache:mb()},e.payload=t;return}t=t.return}}function CB(e,t,n){var o=wn();n={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},y0(e)?uT(t,n):(n=db(e,t,n,o),n!==null&&(on(n,e,o),dT(n,t,o)))}function cT(e,t,n){var o=wn();Vu(e,t,n,o)}function Vu(e,t,n,o){var a={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(y0(e))uT(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,Tn(i,s))return d0(e,t,a,0),De===null&&u0(),!1}catch{}finally{}if(n=db(e,t,a,o),n!==null)return on(n,e,o),dT(n,t,o),!0}return!1}function Mb(e,t,n,o){if(o={lane:2,revertLane:Hb(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},y0(e)){if(t)throw Error(O(479))}else t=db(e,n,o,2),t!==null&&on(t,e,2)}function y0(e){var t=e.alternate;return e===oe||t!==null&&t===oe}function uT(e,t){Ol=Wm=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function dT(e,t,n){if((n&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,n|=o,t.lanes=n,K_(e,n)}}var rd={readContext:Ot,use:h0,useCallback:Qe,useContext:Qe,useEffect:Qe,useImperativeHandle:Qe,useLayoutEffect:Qe,useInsertionEffect:Qe,useMemo:Qe,useReducer:Qe,useRef:Qe,useState:Qe,useDebugValue:Qe,useDeferredValue:Qe,useTransition:Qe,useSyncExternalStore:Qe,useId:Qe,useHostTransitionStatus:Qe,useFormState:Qe,useActionState:Qe,useOptimistic:Qe,useMemoCache:Qe,useCacheRefresh:Qe};rd.useEffectEvent=Qe;var fT={readContext:Ot,use:h0,useCallback:function(e,t){return Zt().memoizedState=[e,t===void 0?null:t],e},useContext:Ot,useEffect:Yk,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,Lm(4194308,4,Jw.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Lm(4194308,4,e,t)},useInsertionEffect:function(e,t){Lm(4,2,e,t)},useMemo:function(e,t){var n=Zt();t=t===void 0?null:t;var o=e();if(Gs){vr(!0);try{e()}finally{vr(!1)}}return n.memoizedState=[o,t],o},useReducer:function(e,t,n){var o=Zt();if(n!==void 0){var a=n(t);if(Gs){vr(!0);try{n(t)}finally{vr(!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=CB.bind(null,oe,e),[o.memoizedState,e]},useRef:function(e){var t=Zt();return e={current:e},t.memoizedState=e},useState:function(e){e=C1(e);var t=e.queue,n=cT.bind(null,oe,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Eb,useDeferredValue:function(e,t){var n=Zt();return Cb(n,e,t)},useTransition:function(){var e=C1(!1);return e=aT.bind(null,oe,e.queue,!0,!1),Zt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var o=oe,a=Zt();if(be){if(n===void 0)throw Error(O(407));n=n()}else{if(n=t(),De===null)throw Error(O(349));(me&127)!==0||Fw(o,t,n)}a.memoizedState=n;var r={value:n,getSnapshot:t};return a.queue=r,Yk(Uw.bind(null,o,r,e),[e]),o.flags|=2048,Hl(9,{destroy:void 0},Hw.bind(null,o,r,n,t),null),n},useId:function(){var e=Zt(),t=De.identifierPrefix;if(be){var n=Fo,o=zo;n=(o&~(1<<32-_n(o)-1)).toString(32)+n,t="_"+t+"R_"+n,n=qm++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=SB++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Ib,useFormState:jk,useActionState:jk,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=Mb.bind(null,oe,!0,n),n.dispatch=t,[e,t]},useMemoCache:_b,useCacheRefresh:function(){return Zt().memoizedState=EB.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)}}},Rb={readContext:Ot,use:h0,useCallback:tT,useContext:Ot,useEffect:Tb,useImperativeHandle:eT,useInsertionEffect:$w,useLayoutEffect:Qw,useMemo:nT,useReducer:Sm,useRef:Yw,useState:function(){return Sm(Ra)},useDebugValue:Eb,useDeferredValue:function(e,t){var n=nt();return oT(n,Me.memoizedState,e,t)},useTransition:function(){var e=Sm(Ra)[0],t=nt().memoizedState;return[typeof e=="boolean"?e:xd(e),t]},useSyncExternalStore:zw,useId:iT,useHostTransitionStatus:Ib,useFormState:Zk,useActionState:Zk,useOptimistic:function(e,t){var n=nt();return qw(n,Me,e,t)},useMemoCache:_b,useCacheRefresh:lT};Rb.useEffectEvent=Kw;var pT={readContext:Ot,use:h0,useCallback:tT,useContext:Ot,useEffect:Tb,useImperativeHandle:eT,useInsertionEffect:$w,useLayoutEffect:Qw,useMemo:nT,useReducer:Fx,useRef:Yw,useState:function(){return Fx(Ra)},useDebugValue:Eb,useDeferredValue:function(e,t){var n=nt();return Me===null?Cb(n,e,t):oT(n,Me.memoizedState,e,t)},useTransition:function(){var e=Fx(Ra)[0],t=nt().memoizedState;return[typeof e=="boolean"?e:xd(e),t]},useSyncExternalStore:zw,useId:iT,useHostTransitionStatus:Ib,useFormState:Xk,useActionState:Xk,useOptimistic:function(e,t){var n=nt();return Me!==null?qw(n,Me,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:_b,useCacheRefresh:lT};pT.useEffectEvent=Kw;function Hx(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 R1={enqueueSetState:function(e,t,n){e=e._reactInternals;var o=wn(),a=Er(o);a.payload=t,n!=null&&(a.callback=n),t=Cr(e,a,o),t!==null&&(on(t,e,o),Gu(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var o=wn(),a=Er(o);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=Cr(e,a,o),t!==null&&(on(t,e,o),Gu(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=wn(),o=Er(n);o.tag=2,t!=null&&(o.callback=t),t=Cr(e,o,n),t!==null&&(on(t,e,n),Gu(t,e,n))}};function Kk(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?!ed(n,o)||!ed(a,r):!0}function $k(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&&R1.enqueueReplaceState(t,t.state,null)}function Ws(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 hT(e){Bm(e)}function mT(e){console.error(e)}function yT(e){Bm(e)}function Vm(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function Qk(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 O1(e,t,n){return n=Er(n),n.tag=3,n.payload={element:null},n.callback=function(){Vm(e,t)},n}function gT(e){return e=Er(e),e.tag=3,e}function xT(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(){Qk(t,n,o)}}var s=n.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(e.callback=function(){Qk(t,n,o),typeof a!="function"&&(Ir===null?Ir=new Set([this]):Ir.add(this));var i=o.stack;this.componentDidCatch(o.value,{componentStack:i!==null?i:""})})}function IB(e,t,n,o,a){if(n.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=n.alternate,t!==null&&Xl(t,n,a,!0),n=En.current,n!==null){switch(n.tag){case 31:case 13:return Kn===null?Km():n.alternate===null&&Je===0&&(Je=3),n.flags&=-257,n.flags|=65536,n.lanes=a,o===Hm?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([o]):t.add(o),$x(e,o,a)),!1;case 22:return n.flags|=65536,o===Hm?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)),$x(e,o,a)),!1}throw Error(O(435,n.tag))}return $x(e,o,a),Km(),!1}if(be)return t=En.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=a,o!==A1&&(e=Error(O(422),{cause:o}),nd(Xn(e,n)))):(o!==A1&&(t=Error(O(423),{cause:o}),nd(Xn(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,o=Xn(o,n),a=O1(e.stateNode,o,a),zx(e,a),Je!==4&&(Je=2)),!1;var r=Error(O(520),{cause:o});if(r=Xn(r,n),Xu===null?Xu=[r]:Xu.push(r),Je!==4&&(Je=2),t===null)return!0;o=Xn(o,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=O1(n.stateNode,o,e),zx(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"&&(Ir===null||!Ir.has(r))))return n.flags|=65536,a&=-a,n.lanes|=a,a=gT(a),xT(a,e,n,o),zx(n,a),!1}n=n.return}while(n!==null);return!1}var Ob=Error(O(461)),lt=!1;function It(e,t,n,o){t.child=e===null?Rw(t,null,n,o):Us(t,e.child,n,o)}function Jk(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 Hs(t),o=vb(e,t,n,s,r,a),i=Sb(),e!==null&&!lt?(Lb(e,t,a),Oa(e,t,a)):(be&&i&&pb(t),t.flags|=1,It(e,t,o,a),t.child)}function e_(e,t,n,o,a){if(e===null){var r=n.type;return typeof r=="function"&&!fb(r)&&r.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=r,bT(e,t,r,o,a)):(e=Am(n.type,null,o,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(r=e.child,!Db(e,a)){var s=r.memoizedProps;if(n=n.compare,n=n!==null?n:ed,n(s,o)&&e.ref===t.ref)return Oa(e,t,a)}return t.flags|=1,e=Ta(r,o),e.ref=t.ref,e.return=t,t.child=e}function bT(e,t,n,o,a){if(e!==null){var r=e.memoizedProps;if(ed(r,o)&&e.ref===t.ref)if(lt=!1,t.pendingProps=o=r,Db(e,a))(e.flags&131072)!==0&&(lt=!0);else return t.lanes=e.lanes,Oa(e,t,a)}return D1(e,t,n,o,a)}function AT(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 t_(e,t,r,n,o)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&vm(t,r!==null?r.cachePool:null),r!==null?Wk(t,r):T1(),Pw(t);else return o=t.lanes=536870912,t_(e,t,r!==null?r.baseLanes|n:n,n,o)}else r!==null?(vm(t,r.cachePool),Wk(t,r),br(t),t.memoizedState=null):(e!==null&&vm(t,null),T1(),br(t));return It(e,t,a,n),t.child}function Bu(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function t_(e,t,n,o,a){var r=yb();return r=r===null?null:{parent:it._currentValue,pool:r},t.memoizedState={baseLanes:n,cachePool:r},e!==null&&vm(t,null),T1(),Pw(t),e!==null&&Xl(e,t,o,!0),t.childLanes=a,null}function km(e,t){return t=jm({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function n_(e,t,n){return Us(t,e.child,null,n),e=km(t,t.pendingProps),e.flags|=2,An(t),t.memoizedState=null,e}function MB(e,t,n){var o=t.pendingProps,a=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(be){if(o.mode==="hidden")return e=km(t,o),t.lanes=536870912,Bu(null,e);if(E1(t),(e=We)?(e=fE(e,Yn),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Pr!==null?{id:zo,overflow:Fo}:null,retryLane:536870912,hydrationErrors:null},n=_w(e),n.return=t,t.child=n,Rt=t,We=null)):e=null,e===null)throw Br(t);return t.lanes=536870912,null}return km(t,o)}var r=e.memoizedState;if(r!==null){var s=r.dehydrated;if(E1(t),a)if(t.flags&256)t.flags&=-257,t=n_(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||Xl(e,t,n,!1),a=(n&e.childLanes)!==0,lt||a){if(o=De,o!==null&&(s=$_(o,n),s!==0&&s!==r.retryLane))throw r.retryLane=s,Zs(e,s),on(o,e,s),Ob;Km(),t=n_(e,t,n)}else e=r.treeContext,We=$n(s.nextSibling),Rt=t,be=!0,Tr=null,Yn=!1,e!==null&&Tw(t,e),t=km(t,o),t.flags|=4096;return t}return e=Ta(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function _m(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 D1(e,t,n,o,a){return Hs(t),n=vb(e,t,n,o,void 0,a),o=Sb(),e!==null&&!lt?(Lb(e,t,a),Oa(e,t,a)):(be&&o&&pb(t),t.flags|=1,It(e,t,n,a),t.child)}function o_(e,t,n,o,a,r){return Hs(t),t.updateQueue=null,n=Nw(t,o,n,a),Bw(e),o=Sb(),e!==null&&!lt?(Lb(e,t,r),Oa(e,t,r)):(be&&o&&pb(t),t.flags|=1,It(e,t,n,r),t.child)}function a_(e,t,n,o,a){if(Hs(t),t.stateNode===null){var r=kl,s=n.contextType;typeof s=="object"&&s!==null&&(r=Ot(s)),r=new n(o,r),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=R1,t.stateNode=r,r._reactInternals=t,r=t.stateNode,r.props=o,r.state=t.memoizedState,r.refs={},xb(t),s=n.contextType,r.context=typeof s=="object"&&s!==null?Ot(s):kl,r.state=t.memoizedState,s=n.getDerivedStateFromProps,typeof s=="function"&&(Hx(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&&R1.enqueueReplaceState(r,r.state,null),qu(t,o,r,a),Wu(),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=Ws(n,i);r.props=l;var c=r.context,u=n.contextType;s=kl,typeof u=="object"&&u!==null&&(s=Ot(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)&&$k(t,r,o,s),yr=!1;var f=t.memoizedState;r.state=f,qu(t,o,r,a),Wu(),c=t.memoizedState,i||f!==c||yr?(typeof d=="function"&&(Hx(t,n,d,o),c=t.memoizedState),(l=yr||Kk(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,_1(e,t),s=t.memoizedProps,u=Ws(n,s),r.props=u,d=t.pendingProps,f=r.context,c=n.contextType,l=kl,typeof c=="object"&&c!==null&&(l=Ot(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)&&$k(t,r,o,l),yr=!1,f=t.memoizedState,r.state=f,qu(t,o,r,a),Wu();var p=t.memoizedState;s!==d||f!==p||yr||e!==null&&e.dependencies!==null&&Fm(e.dependencies)?(typeof i=="function"&&(Hx(t,n,i,o),p=t.memoizedState),(u=yr||Kk(t,n,u,o,f,p,l)||e!==null&&e.dependencies!==null&&Fm(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,_m(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=Us(t,e.child,null,a),t.child=Us(t,null,n,a)):It(e,t,n,a),t.memoizedState=r.state,e=t.child):e=Oa(e,t,a),e}function r_(e,t,n,o){return Fs(),t.flags|=256,It(e,t,n,o),t.child}var Ux={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Gx(e){return{baseLanes:e,cachePool:Cw()}}function Wx(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Sn),e}function vT(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(be){if(a?xr(t):br(t),(e=We)?(e=fE(e,Yn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Pr!==null?{id:zo,overflow:Fo}:null,retryLane:536870912,hydrationErrors:null},n=_w(e),n.return=t,t.child=n,Rt=t,We=null)):e=null,e===null)throw Br(t);return X1(e)?t.lanes=32:t.lanes=536870912,null}var i=o.children;return o=o.fallback,a?(br(t),a=t.mode,i=jm({mode:"hidden",children:i},a),o=Ps(o,a,n,null),i.return=t,o.return=t,i.sibling=o,t.child=i,o=t.child,o.memoizedState=Gx(n),o.childLanes=Wx(e,s,n),t.memoizedState=Ux,Bu(null,o)):(xr(t),P1(t,i))}var l=e.memoizedState;if(l!==null&&(i=l.dehydrated,i!==null)){if(r)t.flags&256?(xr(t),t.flags&=-257,t=qx(e,t,n)):t.memoizedState!==null?(br(t),t.child=e.child,t.flags|=128,t=null):(br(t),i=o.fallback,a=t.mode,o=jm({mode:"visible",children:o.children},a),i=Ps(i,a,n,null),i.flags|=2,o.return=t,i.return=t,o.sibling=i,t.child=o,Us(t,e.child,null,n),o=t.child,o.memoizedState=Gx(n),o.childLanes=Wx(e,s,n),t.memoizedState=Ux,t=Bu(null,o));else if(xr(t),X1(i)){if(s=i.nextSibling&&i.nextSibling.dataset,s)var c=s.dgst;s=c,o=Error(O(419)),o.stack="",o.digest=s,nd({value:o,source:null,stack:null}),t=qx(e,t,n)}else if(lt||Xl(e,t,n,!1),s=(n&e.childLanes)!==0,lt||s){if(s=De,s!==null&&(o=$_(s,n),o!==0&&o!==l.retryLane))throw l.retryLane=o,Zs(e,o),on(s,e,o),Ob;Z1(i)||Km(),t=qx(e,t,n)}else Z1(i)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,We=$n(i.nextSibling),Rt=t,be=!0,Tr=null,Yn=!1,e!==null&&Tw(t,e),t=P1(t,o.children),t.flags|=4096);return t}return a?(br(t),i=o.fallback,a=t.mode,l=e.child,c=l.sibling,o=Ta(l,{mode:"hidden",children:o.children}),o.subtreeFlags=l.subtreeFlags&65011712,c!==null?i=Ta(c,i):(i=Ps(i,a,n,null),i.flags|=2),i.return=t,o.return=t,o.sibling=i,t.child=o,Bu(null,o),o=t.child,i=e.child.memoizedState,i===null?i=Gx(n):(a=i.cachePool,a!==null?(l=it._currentValue,a=a.parent!==l?{parent:l,pool:l}:a):a=Cw(),i={baseLanes:i.baseLanes|n,cachePool:a}),o.memoizedState=i,o.childLanes=Wx(e,s,n),t.memoizedState=Ux,Bu(e.child,o)):(xr(t),n=e.child,e=n.sibling,n=Ta(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 P1(e,t){return t=jm({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function jm(e,t){return e=vn(22,e,null,t),e.lanes=0,e}function qx(e,t,n){return Us(t,e.child,null,n),e=P1(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function s_(e,t,n){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),S1(e.return,t,n)}function Vx(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 ST(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),It(e,t,o,n),o=be?td:0,!i&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&s_(e,n,t);else if(e.tag===19)s_(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&&Gm(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Vx(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&&Gm(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Vx(t,!0,n,null,r,o);break;case"together":Vx(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function Oa(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),zr|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Xl(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=Ta(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Ta(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Db(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Fm(e)))}function RB(e,t,n){switch(t.tag){case 3:Rm(t,t.stateNode.containerInfo),gr(t,it,e.memoizedState.cache),Fs();break;case 27:case 5:c1(t);break;case 4:Rm(t,t.stateNode.containerInfo);break;case 10:gr(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,E1(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(xr(t),t.flags|=128,null):(n&t.child.childLanes)!==0?vT(e,t,n):(xr(t),e=Oa(e,t,n),e!==null?e.sibling:null);xr(t);break;case 19:var a=(e.flags&128)!==0;if(o=(n&t.childLanes)!==0,o||(Xl(e,t,n,!1),o=(n&t.childLanes)!==0),a){if(o)return ST(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,AT(e,t,n,t.pendingProps);case 24:gr(t,it,e.memoizedState.cache)}return Oa(e,t,n)}function LT(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)lt=!0;else{if(!Db(e,n)&&(t.flags&128)===0)return lt=!1,RB(e,t,n);lt=(e.flags&131072)!==0}else lt=!1,be&&(t.flags&1048576)!==0&&ww(t,td,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=Rs(t.elementType),t.type=e,typeof e=="function")fb(e)?(o=Ws(e,o),t.tag=1,t=a_(null,t,e,o,n)):(t.tag=0,t=D1(null,t,e,o,n));else{if(e!=null){var a=e.$$typeof;if(a===Q1){t.tag=11,t=Jk(null,t,e,o,n);break e}else if(a===J1){t.tag=14,t=e_(null,t,e,o,n);break e}}throw t=i1(e)||e,Error(O(306,t,""))}}return t;case 0:return D1(e,t,t.type,t.pendingProps,n);case 1:return o=t.type,a=Ws(o,t.pendingProps),a_(e,t,o,a,n);case 3:e:{if(Rm(t,t.stateNode.containerInfo),e===null)throw Error(O(387));o=t.pendingProps;var r=t.memoizedState;a=r.element,_1(e,t),qu(t,o,null,n);var s=t.memoizedState;if(o=s.cache,gr(t,it,o),o!==r.cache&&L1(t,[it],n,!0),Wu(),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=r_(e,t,o,n);break e}else if(o!==a){a=Xn(Error(O(424)),t),nd(a),t=r_(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=$n(e.firstChild),Rt=t,be=!0,Tr=null,Yn=!0,n=Rw(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Fs(),o===a){t=Oa(e,t,n);break e}It(e,t,o,n)}t=t.child}return t;case 26:return _m(e,t),e===null?(n=E_(t.type,null,t.pendingProps,null))?t.memoizedState=n:be||(n=t.type,e=t.pendingProps,o=e0(wr.current).createElement(n),o[Mt]=t,o[an]=e,Dt(o,n,e),kt(o),t.stateNode=o):t.memoizedState=E_(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return c1(t),e===null&&be&&(o=t.stateNode=pE(t.type,t.pendingProps,wr.current),Rt=t,Yn=!0,a=We,Hr(t.type)?(Y1=a,We=$n(o.firstChild)):We=a),It(e,t,t.pendingProps.children,n),_m(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&be&&((a=o=We)&&(o=sN(o,t.type,t.pendingProps,Yn),o!==null?(t.stateNode=o,Rt=t,We=$n(o.firstChild),Yn=!1,a=!0):a=!1),a||Br(t)),c1(t),a=t.type,r=t.pendingProps,s=e!==null?e.memoizedProps:null,o=r.children,V1(a,r)?o=null:s!==null&&V1(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=vb(e,t,LB,null,null,n),ld._currentValue=a),_m(e,t),It(e,t,o,n),t.child;case 6:return e===null&&be&&((e=n=We)&&(n=iN(n,t.pendingProps,Yn),n!==null?(t.stateNode=n,Rt=t,We=null,e=!0):e=!1),e||Br(t)),null;case 13:return vT(e,t,n);case 4:return Rm(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=Us(t,null,o,n):It(e,t,o,n),t.child;case 11:return Jk(e,t,t.type,t.pendingProps,n);case 7:return It(e,t,t.pendingProps,n),t.child;case 8:return It(e,t,t.pendingProps.children,n),t.child;case 12:return It(e,t,t.pendingProps.children,n),t.child;case 10:return o=t.pendingProps,gr(t,t.type,o.value),It(e,t,o.children,n),t.child;case 9:return a=t.type._context,o=t.pendingProps.children,Hs(t),a=Ot(a),o=o(a),t.flags|=1,It(e,t,o,n),t.child;case 14:return e_(e,t,t.type,t.pendingProps,n);case 15:return bT(e,t,t.type,t.pendingProps,n);case 19:return ST(e,t,n);case 31:return MB(e,t,n);case 22:return AT(e,t,n,t.pendingProps);case 24:return Hs(t),o=Ot(it),e===null?(a=yb(),a===null&&(a=De,r=mb(),a.pooledCache=r,r.refCount++,r!==null&&(a.pooledCacheLanes|=n),a=r),t.memoizedState={parent:o,cache:a},xb(t),gr(t,it,a)):((e.lanes&n)!==0&&(_1(e,t),qu(t,null,null,n),Wu()),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),gr(t,it,o)):(o=r.cache,gr(t,it,o),o!==a.cache&&L1(t,[it],n,!0))),It(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(O(156,t.tag))}function xa(e){e.flags|=4}function jx(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(ZT())e.flags|=8192;else throw Ns=Hm,gb}else e.flags&=-16777217}function i_(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!yE(t))if(ZT())e.flags|=8192;else throw Ns=Hm,gb}function cm(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?X_():536870912,e.lanes|=t,Ul|=t)}function Cu(e,t){if(!be)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 OB(e,t,n){var o=t.pendingProps;switch(hb(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),Ea(it),Pl(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(fl(t)?xa(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Nx())),Ge(t),null;case 26:var a=t.type,r=t.memoizedState;return e===null?(xa(t),r!==null?(Ge(t),i_(t,r)):(Ge(t),jx(t,a,null,o,n))):r?r!==e.memoizedState?(xa(t),Ge(t),i_(t,r)):(Ge(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&xa(t),Ge(t),jx(t,a,e,o,n)),null;case 27:if(Om(t),n=wr.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&xa(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Ge(t),null}e=Uo.current,fl(t)?Bk(t,e):(e=pE(a,o,n),t.stateNode=e,xa(t))}return Ge(t),null;case 5:if(Om(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&xa(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Ge(t),null}if(r=Uo.current,fl(t))Bk(t,r);else{var s=e0(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[Mt]=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(Dt(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&&xa(t)}}return Ge(t),jx(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&xa(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(O(166));if(e=wr.current,fl(t)){if(e=t.stateNode,n=t.memoizedProps,o=null,a=Rt,a!==null)switch(a.tag){case 27:case 5:o=a.memoizedProps}e[Mt]=t,e=!!(e.nodeValue===n||o!==null&&o.suppressHydrationWarning===!0||cE(e.nodeValue,n)),e||Br(t,!0)}else e=e0(e).createTextNode(o),e[Mt]=t,t.stateNode=e}return Ge(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(o=fl(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[Mt]=t}else Fs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ge(t),e=!1}else n=Nx(),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=fl(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[Mt]=t}else Fs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ge(t),a=!1}else a=Nx(),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),cm(t,t.updateQueue),Ge(t),null);case 4:return Pl(),e===null&&Ub(t.stateNode.containerInfo),Ge(t),null;case 10:return Ea(t.type),Ge(t),null;case 19:if(_t(tt),o=t.memoizedState,o===null)return Ge(t),null;if(a=(t.flags&128)!==0,r=o.rendering,r===null)if(a)Cu(o,!1);else{if(Je!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(r=Gm(e),r!==null){for(t.flags|=128,Cu(o,!1),e=r.updateQueue,t.updateQueue=e,cm(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)kw(n,e),n=n.sibling;return Ne(tt,tt.current&1|2),be&&Sa(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&Ln()>Xm&&(t.flags|=128,a=!0,Cu(o,!1),t.lanes=4194304)}else{if(!a)if(e=Gm(r),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,cm(t,e),Cu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!r.alternate&&!be)return Ge(t),null}else 2*Ln()-o.renderingStartTime>Xm&&n!==536870912&&(t.flags|=128,a=!0,Cu(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),be&&Sa(t,o.treeForkCount),e):(Ge(t),null);case 22:case 23:return An(t),bb(),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&&cm(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&&_t(Bs),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ea(it),Ge(t),null;case 25:return null;case 30:return null}throw Error(O(156,t.tag))}function DB(e,t){switch(hb(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ea(it),Pl(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Om(t),null;case 31:if(t.memoizedState!==null){if(An(t),t.alternate===null)throw Error(O(340));Fs()}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));Fs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return _t(tt),null;case 4:return Pl(),null;case 10:return Ea(t.type),null;case 22:case 23:return An(t),bb(),e!==null&&_t(Bs),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ea(it),null;case 25:return null;default:return null}}function kT(e,t){switch(hb(t),t.tag){case 3:Ea(it),Pl();break;case 26:case 27:case 5:Om(t);break;case 4:Pl();break;case 31:t.memoizedState!==null&&An(t);break;case 13:An(t);break;case 19:_t(tt);break;case 10:Ea(t.type);break;case 22:case 23:An(t),bb(),e!==null&&_t(Bs);break;case 24:Ea(it)}}function bd(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 Nr(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 _T(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Dw(t,n)}catch(o){Ce(e,e.return,o)}}}function wT(e,t,n){n.props=Ws(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(o){Ce(e,t,o)}}function ju(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 Ho(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 TT(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 Zx(e,t,n){try{var o=e.stateNode;eN(o,e.type,n,t),o[an]=t}catch(a){Ce(e,e.return,a)}}function ET(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Hr(e.type)||e.tag===4}function Xx(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ET(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&&Hr(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 B1(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=_a));else if(o!==4&&(o===27&&Hr(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(B1(e,t,n),e=e.sibling;e!==null;)B1(e,t,n),e=e.sibling}function Zm(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&&Hr(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Zm(e,t,n),e=e.sibling;e!==null;)Zm(e,t,n),e=e.sibling}function CT(e){var t=e.stateNode,n=e.memoizedProps;try{for(var o=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);Dt(t,o,n),t[Mt]=e,t[an]=n}catch(r){Ce(e,e.return,r)}}var La=!1,st=!1,Yx=!1,l_=typeof WeakSet=="function"?WeakSet:Set,Lt=null;function PB(e,t){if(e=e.containerInfo,W1=a0,e=yw(e),cb(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(q1={focusedElem:e,selectionRange:n},a0=!1,Lt=t;Lt!==null;)if(t=Lt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Lt=e;else for(;Lt!==null;){switch(t=Lt,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=Ws(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)j1(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":j1(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,Lt=e;break}Lt=t.return}}function IT(e,t,n){var o=n.flags;switch(n.tag){case 0:case 11:case 15:Aa(e,n),o&4&&bd(5,n);break;case 1:if(Aa(e,n),o&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(s){Ce(n,n.return,s)}else{var a=Ws(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){Ce(n,n.return,s)}}o&64&&_T(n),o&512&&ju(n,n.return);break;case 3:if(Aa(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{Dw(e,t)}catch(s){Ce(n,n.return,s)}}break;case 27:t===null&&o&4&&CT(n);case 26:case 5:Aa(e,n),t===null&&o&4&&TT(n),o&512&&ju(n,n.return);break;case 12:Aa(e,n);break;case 31:Aa(e,n),o&4&&OT(e,n);break;case 13:Aa(e,n),o&4&&DT(e,n),o&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=qB.bind(null,n),lN(e,n))));break;case 22:if(o=n.memoizedState!==null||La,!o){t=t!==null&&t.memoizedState!==null||st,a=La;var r=st;La=o,(st=t)&&!r?va(e,n,(n.subtreeFlags&8772)!==0):Aa(e,n),La=a,st=r}break;case 30:break;default:Aa(e,n)}}function MT(e){var t=e.alternate;t!==null&&(e.alternate=null,MT(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ob(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 je=null,tn=!1;function ba(e,t,n){for(n=n.child;n!==null;)RT(e,t,n),n=n.sibling}function RT(e,t,n){if(kn&&typeof kn.onCommitFiberUnmount=="function")try{kn.onCommitFiberUnmount(fd,n)}catch{}switch(n.tag){case 26:st||Ho(n,t),ba(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:st||Ho(n,t);var o=je,a=tn;Hr(n.type)&&(je=n.stateNode,tn=!1),ba(e,t,n),Ku(n.stateNode),je=o,tn=a;break;case 5:st||Ho(n,t);case 6:if(o=je,a=tn,je=null,ba(e,t,n),je=o,tn=a,je!==null)if(tn)try{(je.nodeType===9?je.body:je.nodeName==="HTML"?je.ownerDocument.body:je).removeChild(n.stateNode)}catch(r){Ce(n,t,r)}else try{je.removeChild(n.stateNode)}catch(r){Ce(n,t,r)}break;case 18:je!==null&&(tn?(e=je,L_(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Vl(e)):L_(je,n.stateNode));break;case 4:o=je,a=tn,je=n.stateNode.containerInfo,tn=!0,ba(e,t,n),je=o,tn=a;break;case 0:case 11:case 14:case 15:Nr(2,n,t),st||Nr(4,n,t),ba(e,t,n);break;case 1:st||(Ho(n,t),o=n.stateNode,typeof o.componentWillUnmount=="function"&&wT(n,t,o)),ba(e,t,n);break;case 21:ba(e,t,n);break;case 22:st=(o=st)||n.memoizedState!==null,ba(e,t,n),st=o;break;default:ba(e,t,n)}}function OT(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Vl(e)}catch(n){Ce(t,t.return,n)}}}function DT(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Vl(e)}catch(n){Ce(t,t.return,n)}}function BB(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new l_),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new l_),t;default:throw Error(O(435,e.tag))}}function um(e,t){var n=BB(e);t.forEach(function(o){if(!n.has(o)){n.add(o);var a=VB.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(Hr(i.type)){je=i.stateNode,tn=!1;break e}break;case 5:je=i.stateNode,tn=!1;break e;case 3:case 4:je=i.stateNode.containerInfo,tn=!0;break e}i=i.return}if(je===null)throw Error(O(160));RT(r,s,a),je=null,tn=!1,r=a.alternate,r!==null&&(r.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)PT(t,e),t=t.sibling}var xo=null;function PT(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&&(Nr(3,e,e.return),bd(3,e),Nr(5,e,e.return));break;case 1:Jt(t,e),en(e),o&512&&(st||n===null||Ho(n,n.return)),o&64&&La&&(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=xo;if(Jt(t,e),en(e),o&512&&(st||n===null||Ho(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[md]||r[Mt]||r.namespaceURI==="http://www.w3.org/2000/svg"||r.hasAttribute("itemprop"))&&(r=a.createElement(o),a.head.insertBefore(r,a.querySelector("head > title"))),Dt(r,o,n),r[Mt]=e,kt(r),o=r;break e;case"link":var s=I_("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),Dt(r,o,n),a.head.appendChild(r);break;case"meta":if(s=I_("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),Dt(r,o,n),a.head.appendChild(r);break;default:throw Error(O(468,o))}r[Mt]=e,kt(r),o=r}e.stateNode=o}else M_(a,e.type,e.stateNode);else e.stateNode=C_(a,o,e.memoizedProps);else r!==o?(r===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):r.count--,o===null?M_(a,e.type,e.stateNode):C_(a,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Zx(e,e.memoizedProps,n.memoizedProps)}break;case 27:Jt(t,e),en(e),o&512&&(st||n===null||Ho(n,n.return)),n!==null&&o&4&&Zx(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Jt(t,e),en(e),o&512&&(st||n===null||Ho(n,n.return)),e.flags&32){a=e.stateNode;try{Nl(a,"")}catch(h){Ce(e,e.return,h)}}o&4&&e.stateNode!=null&&(a=e.memoizedProps,Zx(e,a,n!==null?n.memoizedProps:a)),o&1024&&(Yx=!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){Ce(e,e.return,h)}}break;case 3:if(Em=null,a=xo,xo=t0(t.containerInfo),Jt(t,e),xo=a,en(e),o&4&&n!==null&&n.memoizedState.isDehydrated)try{Vl(t.containerInfo)}catch(h){Ce(e,e.return,h)}Yx&&(Yx=!1,BT(e));break;case 4:o=xo,xo=t0(e.stateNode.containerInfo),Jt(t,e),en(e),xo=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,um(e,o)));break;case 13:Jt(t,e),en(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(g0=Ln()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,um(e,o)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,c=La,u=st;if(La=c||a,st=u||l,Jt(t,e),st=u,La=c,en(e),o&8192)e:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||La||st||Os(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?k_(p,!0):k_(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,um(e,n))));break;case 19:Jt(t,e),en(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,um(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(ET(o)){n=o;break}o=o.return}if(n==null)throw Error(O(160));switch(n.tag){case 27:var a=n.stateNode,r=Xx(e);Zm(e,r,a);break;case 5:var s=n.stateNode;n.flags&32&&(Nl(s,""),n.flags&=-33);var i=Xx(e);Zm(e,i,s);break;case 3:case 4:var l=n.stateNode.containerInfo,c=Xx(e);B1(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 BT(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;BT(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Aa(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)IT(e,t.alternate,t),t=t.sibling}function Os(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Nr(4,t,t.return),Os(t);break;case 1:Ho(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&wT(t,t.return,n),Os(t);break;case 27:Ku(t.stateNode);case 26:case 5:Ho(t,t.return),Os(t);break;case 22:t.memoizedState===null&&Os(t);break;case 30:Os(t);break;default:Os(t)}e=e.sibling}}function va(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:va(a,r,n),bd(4,r);break;case 1:if(va(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++)Ow(l[a],i)}catch(c){Ce(o,o.return,c)}}n&&s&64&&_T(r),ju(r,r.return);break;case 27:CT(r);case 26:case 5:va(a,r,n),n&&o===null&&s&4&&TT(r),ju(r,r.return);break;case 12:va(a,r,n);break;case 31:va(a,r,n),n&&s&4&&OT(a,r);break;case 13:va(a,r,n),n&&s&4&&DT(a,r);break;case 22:r.memoizedState===null&&va(a,r,n),ju(r,r.return);break;case 30:break;default:va(a,r,n)}t=t.sibling}}function Pb(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&&gd(n))}function Bb(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&gd(e))}function go(e,t,n,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)NT(e,t,n,o),t=t.sibling}function NT(e,t,n,o){var a=t.flags;switch(t.tag){case 0:case 11:case 15:go(e,t,n,o),a&2048&&bd(9,t);break;case 1:go(e,t,n,o);break;case 3:go(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&&gd(e)));break;case 12:if(a&2048){go(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 go(e,t,n,o);break;case 31:go(e,t,n,o);break;case 13:go(e,t,n,o);break;case 23:break;case 22:r=t.stateNode,s=t.alternate,t.memoizedState!==null?r._visibility&2?go(e,t,n,o):Zu(e,t):r._visibility&2?go(e,t,n,o):(r._visibility|=2,hl(e,t,n,o,(t.subtreeFlags&10256)!==0||!1)),a&2048&&Pb(s,t);break;case 24:go(e,t,n,o),a&2048&&Bb(t.alternate,t);break;default:go(e,t,n,o)}}function hl(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:hl(r,s,i,l,a),bd(8,s);break;case 23:break;case 22:var u=s.stateNode;s.memoizedState!==null?u._visibility&2?hl(r,s,i,l,a):Zu(r,s):(u._visibility|=2,hl(r,s,i,l,a)),a&&c&2048&&Pb(s.alternate,s);break;case 24:hl(r,s,i,l,a),a&&c&2048&&Bb(s.alternate,s);break;default:hl(r,s,i,l,a)}t=t.sibling}}function Zu(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:Zu(n,o),a&2048&&Pb(o.alternate,o);break;case 24:Zu(n,o),a&2048&&Bb(o.alternate,o);break;default:Zu(n,o)}t=t.sibling}}var Nu=8192;function pl(e,t,n){if(e.subtreeFlags&Nu)for(e=e.child;e!==null;)zT(e,t,n),e=e.sibling}function zT(e,t,n){switch(e.tag){case 26:pl(e,t,n),e.flags&Nu&&e.memoizedState!==null&&AN(n,xo,e.memoizedState,e.memoizedProps);break;case 5:pl(e,t,n);break;case 3:case 4:var o=xo;xo=t0(e.stateNode.containerInfo),pl(e,t,n),xo=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=Nu,Nu=16777216,pl(e,t,n),Nu=o):pl(e,t,n));break;default:pl(e,t,n)}}function FT(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 Iu(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];Lt=o,UT(o,e)}FT(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)HT(e),e=e.sibling}function HT(e){switch(e.tag){case 0:case 11:case 15:Iu(e),e.flags&2048&&Nr(9,e,e.return);break;case 3:Iu(e);break;case 12:Iu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,wm(e)):Iu(e);break;default:Iu(e)}}function wm(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];Lt=o,UT(o,e)}FT(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Nr(8,t,t.return),wm(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,wm(t));break;default:wm(t)}e=e.sibling}}function UT(e,t){for(;Lt!==null;){var n=Lt;switch(n.tag){case 0:case 11:case 15:Nr(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:gd(n.memoizedState.cache)}if(o=n.child,o!==null)o.return=n,Lt=o;else e:for(n=e;Lt!==null;){o=Lt;var a=o.sibling,r=o.return;if(MT(o),o===n){Lt=null;break e}if(a!==null){a.return=r,Lt=a;break e}Lt=r}}}var NB={getCacheForType:function(e){var t=Ot(it),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ot(it).controller.signal}},zB=typeof WeakMap=="function"?WeakMap:Map,ke=0,De=null,fe=null,me=0,Ee=0,bn=null,Lr=!1,Kl=!1,Nb=!1,Da=0,Je=0,zr=0,zs=0,zb=0,Sn=0,Ul=0,Xu=null,nn=null,N1=!1,g0=0,GT=0,Xm=1/0,Ym=null,Ir=null,ht=0,Mr=null,Gl=null,Ca=0,z1=0,F1=null,WT=null,Yu=0,H1=null;function wn(){return(ke&2)!==0&&me!==0?me&-me:K.T!==null?Hb():Q_()}function qT(){if(Sn===0)if((me&536870912)===0||be){var e=em;em<<=1,(em&3932160)===0&&(em=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)&&(Wl(e,0),kr(e,me,Sn,!1)),hd(e,n),((ke&2)===0||e!==De)&&(e===De&&((ke&2)===0&&(zs|=n),Je===4&&kr(e,me,Sn,!1)),Wo(e))}function VT(e,t,n){if((ke&6)!==0)throw Error(O(327));var o=!n&&(t&127)===0&&(t&e.expiredLanes)===0||pd(e,t),a=o?UB(e,t):Kx(e,t,!0),r=o;do{if(a===0){Kl&&!o&&kr(e,t,0,!1);break}else{if(n=e.current.alternate,r&&!FB(n)){a=Kx(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=Xu;var l=i.current.memoizedState.isDehydrated;if(l&&(Wl(i,s).flags|=256),s=Kx(i,s,!1),s!==2){if(Nb&&!l){i.errorRecoveryDisabledLanes|=r,zs|=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){Wl(e,0),kr(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:kr(o,t,Sn,!Lr);break e;case 2:nn=null;break;case 3:case 5:break;default:throw Error(O(329))}if((t&62914560)===t&&(a=g0+300-Ln(),10<a)){if(kr(o,t,Sn,!Lr),s0(o,0,!0)!==0)break e;Ca=t,o.timeoutHandle=dE(c_.bind(null,o,n,nn,Ym,N1,t,Sn,zs,Ul,Lr,r,"Throttled",-0,0),a);break e}c_(o,n,nn,Ym,N1,t,Sn,zs,Ul,Lr,r,null,-0,0)}}break}while(!0);Wo(e)}function c_(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:_a},zT(t,r,d);var h=(r&62914560)===r?g0-Ln():(r&4194048)===r?GT-Ln():0;if(h=vN(d,h),h!==null){Ca=r,e.cancelPendingCommit=h(d_.bind(null,e,t,r,n,o,a,s,i,l,u,d,null,f,p)),kr(e,r,s,!c);return}}d_(e,t,r,n,o,a,s,i,l)}function FB(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(!Tn(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 kr(e,t,n,o){t&=~zb,t&=~zs,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var a=t;0<a;){var r=31-_n(a),s=1<<r;o[r]=-1,a&=~s}n!==0&&Y_(e,n,t)}function x0(){return(ke&6)===0?(Ad(0,!1),!1):!0}function Fb(){if(fe!==null){if(Ee===0)var e=fe.return;else e=fe,wa=Xs=null,kb(e),Rl=null,od=0,e=fe;for(;e!==null;)kT(e.alternate,e),e=e.return;fe=null}}function Wl(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,oN(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Ca=0,Fb(),De=e,fe=n=Ta(e.current,null),me=t,Ee=0,bn=null,Lr=!1,Kl=pd(e,t),Nb=!1,Ul=Sn=zb=zs=zr=Je=0,nn=Xu=null,N1=!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-_n(o),r=1<<a;t|=e[a],o&=~r}return Da=t,u0(),n}function jT(e,t){oe=null,K.H=rd,t===Yl||t===f0?(t=Uk(),Ee=3):t===gb?(t=Uk(),Ee=4):Ee=t===Ob?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,bn=t,fe===null&&(Je=1,Vm(e,Xn(t,e.current)))}function ZT(){var e=En.current;return e===null?!0:(me&4194048)===me?Kn===null:(me&62914560)===me||(me&536870912)!==0?e===Kn:!1}function XT(){var e=K.H;return K.H=rd,e===null?rd:e}function YT(){var e=K.A;return K.A=NB,e}function Km(){Je=4,Lr||(me&4194048)!==me&&En.current!==null||(Kl=!0),(zr&134217727)===0&&(zs&134217727)===0||De===null||kr(De,me,Sn,!1)}function Kx(e,t,n){var o=ke;ke|=2;var a=XT(),r=YT();(De!==e||me!==t)&&(Ym=null,Wl(e,t)),t=!1;var s=Je;e:do try{if(Ee!==0&&fe!==null){var i=fe,l=bn;switch(Ee){case 8:Fb(),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,Tl(e,i,l,c),n&&Kl){s=0;break e}break;default:c=Ee,Ee=0,bn=null,Tl(e,i,l,c)}}HB(),s=Je;break}catch(u){jT(e,u)}while(!0);return t&&e.shellSuspendCounter++,wa=Xs=null,ke=o,K.H=a,K.A=r,fe===null&&(De=null,me=0,u0()),s}function HB(){for(;fe!==null;)KT(fe)}function UB(e,t){var n=ke;ke|=2;var o=XT(),a=YT();De!==e||me!==t?(Ym=null,Xm=Ln()+500,Wl(e,t)):Kl=pd(e,t);e:do try{if(Ee!==0&&fe!==null){t=fe;var r=bn;t:switch(Ee){case 1:Ee=0,bn=null,Tl(e,t,r,1);break;case 2:case 9:if(Hk(r)){Ee=0,bn=null,u_(t);break}t=function(){Ee!==2&&Ee!==9||De!==e||(Ee=7),Wo(e)},r.then(t,t);break e;case 3:Ee=7;break e;case 4:Ee=5;break e;case 7:Hk(r)?(Ee=0,bn=null,u_(t)):(Ee=0,bn=null,Tl(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?yE(s):i.stateNode.complete){Ee=0,bn=null;var l=i.sibling;if(l!==null)fe=l;else{var c=i.return;c!==null?(fe=c,b0(c)):fe=null}break t}}Ee=0,bn=null,Tl(e,t,r,5);break;case 6:Ee=0,bn=null,Tl(e,t,r,6);break;case 8:Fb(),Je=6;break e;default:throw Error(O(462))}}GB();break}catch(u){jT(e,u)}while(!0);return wa=Xs=null,K.H=o,K.A=a,ke=n,fe!==null?0:(De=null,me=0,u0(),Je)}function GB(){for(;fe!==null&&!d7();)KT(fe)}function KT(e){var t=LT(e.alternate,e,Da);e.memoizedProps=e.pendingProps,t===null?b0(e):fe=t}function u_(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=o_(n,t,t.pendingProps,t.type,void 0,me);break;case 11:t=o_(n,t,t.pendingProps,t.type.render,t.ref,me);break;case 5:kb(t);default:kT(n,t),t=fe=kw(t,Da),t=LT(n,t,Da)}e.memoizedProps=e.pendingProps,t===null?b0(e):fe=t}function Tl(e,t,n,o){wa=Xs=null,kb(t),Rl=null,od=0;var a=t.return;try{if(IB(e,a,t,n,me)){Je=1,Vm(e,Xn(n,e.current)),fe=null;return}}catch(r){if(a!==null)throw fe=a,r;Je=1,Vm(e,Xn(n,e.current)),fe=null;return}t.flags&32768?(be||o===1?e=!0:Kl||(me&536870912)!==0?e=!1:(Lr=e=!0,(o===2||o===9||o===3||o===6)&&(o=En.current,o!==null&&o.tag===13&&(o.flags|=16384))),$T(t,e)):b0(t)}function b0(e){var t=e;do{if((t.flags&32768)!==0){$T(t,Lr);return}e=t.return;var n=OB(t.alternate,t,Da);if(n!==null){fe=n;return}if(t=t.sibling,t!==null){fe=t;return}fe=t=e}while(t!==null);Je===0&&(Je=5)}function $T(e,t){do{var n=DB(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);Je=6,fe=null}function d_(e,t,n,o,a,r,s,i,l){e.cancelPendingCommit=null;do A0();while(ht!==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|=ub,v7(e,n,r,s,i,l),e===De&&(fe=De=null,me=0),Gl=t,Mr=e,Ca=n,z1=r,F1=a,WT=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,jB(Dm,function(){return nE(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=K.T,K.T=null,a=_e.p,_e.p=2,s=ke,ke|=4;try{PB(e,t,n)}finally{ke=s,_e.p=a,K.T=o}}ht=1,QT(),JT(),eE()}}function QT(){if(ht===1){ht=0;var e=Mr,t=Gl,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=K.T,K.T=null;var o=_e.p;_e.p=2;var a=ke;ke|=4;try{PT(t,e);var r=q1,s=yw(e.containerInfo),i=r.focusedElem,l=r.selectionRange;if(s!==i&&i&&i.ownerDocument&&mw(i.ownerDocument.documentElement,i)){if(l!==null&&cb(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=Ok(i,m),g=Ok(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}}a0=!!W1,q1=W1=null}finally{ke=a,_e.p=o,K.T=n}}e.current=t,ht=2}}function JT(){if(ht===2){ht=0;var e=Mr,t=Gl,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=K.T,K.T=null;var o=_e.p;_e.p=2;var a=ke;ke|=4;try{IT(e,t.alternate,t)}finally{ke=a,_e.p=o,K.T=n}}ht=3}}function eE(){if(ht===4||ht===3){ht=0,f7();var e=Mr,t=Gl,n=Ca,o=WT;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?ht=5:(ht=0,Gl=Mr=null,tE(e,e.pendingLanes));var a=e.pendingLanes;if(a===0&&(Ir=null),nb(n),t=t.stateNode,kn&&typeof kn.onCommitFiberRoot=="function")try{kn.onCommitFiberRoot(fd,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=K.T,a=_e.p,_e.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,_e.p=a}}(Ca&3)!==0&&A0(),Wo(e),a=e.pendingLanes,(n&261930)!==0&&(a&42)!==0?e===H1?Yu++:(Yu=0,H1=e):Yu=0,Ad(0,!1)}}function tE(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,gd(t)))}function A0(){return QT(),JT(),eE(),nE()}function nE(){if(ht!==5)return!1;var e=Mr,t=z1;z1=0;var n=nb(Ca),o=K.T,a=_e.p;try{_e.p=32>n?32:n,K.T=null,n=F1,F1=null;var r=Mr,s=Ca;if(ht=0,Gl=Mr=null,Ca=0,(ke&6)!==0)throw Error(O(331));var i=ke;if(ke|=4,HT(r.current),NT(r,r.current,s,n),ke=i,Ad(0,!1),kn&&typeof kn.onPostCommitFiberRoot=="function")try{kn.onPostCommitFiberRoot(fd,r)}catch{}return!0}finally{_e.p=a,K.T=o,tE(e,t)}}function f_(e,t,n){t=Xn(n,t),t=O1(e.stateNode,t,2),e=Cr(e,t,2),e!==null&&(hd(e,2),Wo(e))}function Ce(e,t,n){if(e.tag===3)f_(e,e,n);else for(;t!==null;){if(t.tag===3){f_(t,e,n);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Ir===null||!Ir.has(o))){e=Xn(n,e),n=gT(2),o=Cr(t,n,2),o!==null&&(xT(n,o,t,e),hd(o,2),Wo(o));break}}t=t.return}}function $x(e,t,n){var o=e.pingCache;if(o===null){o=e.pingCache=new zB;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)||(Nb=!0,a.add(n),e=WB.bind(null,e,t,n),t.then(e,e))}function WB(e,t,n){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,De===e&&(me&n)===n&&(Je===4||Je===3&&(me&62914560)===me&&300>Ln()-g0?(ke&2)===0&&Wl(e,0):zb|=n,Ul===me&&(Ul=0)),Wo(e)}function oE(e,t){t===0&&(t=X_()),e=Zs(e,t),e!==null&&(hd(e,t),Wo(e))}function qB(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),oE(e,n)}function VB(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),oE(e,n)}function jB(e,t){return eb(e,t)}var $m=null,ml=null,U1=!1,Qm=!1,Qx=!1,_r=0;function Wo(e){e!==ml&&e.next===null&&(ml===null?$m=ml=e:ml=ml.next=e),Qm=!0,U1||(U1=!0,XB())}function Ad(e,t){if(!Qx&&Qm){Qx=!0;do for(var n=!1,o=$m;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-_n(42|e)+1)-1,r&=a&~(s&~i),r=r&201326741?r&201326741|1:r?r|2:0}r!==0&&(n=!0,p_(o,r))}else r=me,r=s0(o,o===De?r:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(r&3)===0||pd(o,r)||(n=!0,p_(o,r));o=o.next}while(n);Qx=!1}}function ZB(){aE()}function aE(){Qm=U1=!1;var e=0;_r!==0&&nN()&&(e=_r);for(var t=Ln(),n=null,o=$m;o!==null;){var a=o.next,r=rE(o,t);r===0?(o.next=null,n===null?$m=a:n.next=a,a===null&&(ml=n)):(n=o,(e!==0||(r&3)!==0)&&(Qm=!0)),o=a}ht!==0&&ht!==5||Ad(e,!1),_r!==0&&(_r=0)}function rE(e,t){for(var n=e.suspendedLanes,o=e.pingedLanes,a=e.expirationTimes,r=e.pendingLanes&-62914561;0<r;){var s=31-_n(r),i=1<<s,l=a[s];l===-1?((i&n)===0||(i&o)!==0)&&(a[s]=A7(i,t)):l<=t&&(e.expiredLanes|=i),r&=~i}if(t=De,n=me,n=s0(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&&Tx(o),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||pd(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(o!==null&&Tx(o),nb(n)){case 2:case 8:n=j_;break;case 32:n=Dm;break;case 268435456:n=Z_;break;default:n=Dm}return o=sE.bind(null,e),n=eb(n,o),e.callbackPriority=t,e.callbackNode=n,t}return o!==null&&o!==null&&Tx(o),e.callbackPriority=2,e.callbackNode=null,2}function sE(e,t){if(ht!==0&&ht!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(A0()&&e.callbackNode!==n)return null;var o=me;return o=s0(e,e===De?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(VT(e,o,t),rE(e,Ln()),e.callbackNode!=null&&e.callbackNode===n?sE.bind(null,e):null)}function p_(e,t){if(A0())return null;VT(e,t,!0)}function XB(){aN(function(){(ke&6)!==0?eb(V_,ZB):aE()})}function Hb(){if(_r===0){var e=zl;e===0&&(e=Jh,Jh<<=1,(Jh&261888)===0&&(Jh=256)),_r=e}return _r}function h_(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:gm(""+e)}function m_(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 YB(e,t,n,o,a){if(t==="submit"&&n&&n.stateNode===a){var r=h_((a[an]||null).action),s=o.submitter;s&&(t=(t=s[an]||null)?h_(t.formAction):s.getAttribute("formAction"),t!==null&&(r=t,s=null));var i=new i0("action","action",null,o,a);e.push({event:i,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(_r!==0){var l=s?m_(a,s):new FormData(a);M1(n,{pending:!0,data:l,method:a.method,action:r},null,l)}}else typeof r=="function"&&(i.preventDefault(),l=s?m_(a,s):new FormData(a),M1(n,{pending:!0,data:l,method:a.method,action:r},r,l))},currentTarget:a}]})}}for(dm=0;dm<b1.length;dm++)fm=b1[dm],y_=fm.toLowerCase(),g_=fm[0].toUpperCase()+fm.slice(1),bo(y_,"on"+g_);var fm,y_,g_,dm;bo(xw,"onAnimationEnd");bo(bw,"onAnimationIteration");bo(Aw,"onAnimationStart");bo("dblclick","onDoubleClick");bo("focusin","onFocus");bo("focusout","onBlur");bo(pB,"onTransitionRun");bo(hB,"onTransitionStart");bo(mB,"onTransitionCancel");bo(vw,"onTransitionEnd");Bl("onMouseEnter",["mouseout","mouseover"]);Bl("onMouseLeave",["mouseout","mouseover"]);Bl("onPointerEnter",["pointerout","pointerover"]);Bl("onPointerLeave",["pointerout","pointerover"]);qs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));qs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));qs("onBeforeInput",["compositionend","keypress","textInput","paste"]);qs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));qs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));qs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var sd="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(" "),KB=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(sd));function iE(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){Bm(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){Bm(u)}a.currentTarget=null,r=l}}}}function de(e,t){var n=t[d1];n===void 0&&(n=t[d1]=new Set);var o=e+"__bubble";n.has(o)||(lE(t,e,2,!1),n.add(o))}function Jx(e,t,n){var o=0;t&&(o|=4),lE(n,e,o,t)}var pm="_reactListening"+Math.random().toString(36).slice(2);function Ub(e){if(!e[pm]){e[pm]=!0,J_.forEach(function(n){n!=="selectionchange"&&(KB.has(n)||Jx(n,!1,e),Jx(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[pm]||(t[pm]=!0,Jx("selectionchange",!1,t))}}function lE(e,t,n,o){switch(vE(t)){case 2:var a=kN;break;case 8:a=_N;break;default:a=Vb}n=a.bind(null,t,n,e),a=void 0,!y1||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 e1(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=xl(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}iw(function(){var c=r,u=rb(n),d=[];e:{var f=Sw.get(e);if(f!==void 0){var p=i0,h=e;switch(e){case"keypress":if(bm(n)===0)break e;case"keydown":case"keyup":p=V7;break;case"focusin":h="focus",p=Rx;break;case"focusout":h="blur",p=Rx;break;case"beforeblur":case"afterblur":p=Rx;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=kk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=O7;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=X7;break;case xw:case bw:case Aw:p=B7;break;case vw:p=K7;break;case"scroll":case"scrollend":p=M7;break;case"wheel":p=Q7;break;case"copy":case"cut":case"paste":p=z7;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=wk;break;case"toggle":case"beforetoggle":p=eB}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=Qu(g,y),A!=null&&m.push(id(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!==m1&&(h=n.relatedTarget||n.fromElement)&&(xl(h)||h[jl]))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?xl(h):null,h!==null&&(x=dd(h),m=h.tag,h!==x||m!==5&&m!==27&&m!==6)&&(h=null)):(p=null,h=c),p!==h)){if(m=kk,A="onMouseLeave",y="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(m=wk,A="onPointerLeave",y="onPointerEnter",g="pointer"),x=p==null?f:Pu(p),b=h==null?f:Pu(h),f=new m(A,g+"leave",p,n,u),f.target=x,f.relatedTarget=b,A=null,xl(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=$B,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&&x_(d,f,p,m,!1),h!==null&&x!==null&&x_(d,x,h,m,!0)}}e:{if(f=c?Pu(c):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var C=Ik;else if(Ck(f))if(pw)C=uB;else{C=lB;var w=iB}else p=f.nodeName,!p||p.toLowerCase()!=="input"||f.type!=="checkbox"&&f.type!=="radio"?c&&ab(c.elementType)&&(C=Ik):C=cB;if(C&&(C=C(e,c))){fw(d,C,n,u);break e}w&&w(e,f,c),e==="focusout"&&c&&f.type==="number"&&c.memoizedProps.value!=null&&h1(f,"number",f.value)}switch(w=c?Pu(c):window,e){case"focusin":(Ck(w)||w.contentEditable==="true")&&(vl=w,g1=c,Hu=null);break;case"focusout":Hu=g1=vl=null;break;case"mousedown":x1=!0;break;case"contextmenu":case"mouseup":case"dragend":x1=!1,Dk(d,n,u);break;case"selectionchange":if(fB)break;case"keydown":case"keyup":Dk(d,n,u)}var L;if(lb)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 Al?uw(e,n)&&(k="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(k="onCompositionStart");k&&(cw&&n.locale!=="ko"&&(Al||k!=="onCompositionStart"?k==="onCompositionEnd"&&Al&&(L=lw()):(Sr=u,sb="value"in Sr?Sr.value:Sr.textContent,Al=!0)),w=Jm(c,k),0<w.length&&(k=new _k(k,e,null,n,u),d.push({event:k,listeners:w}),L?k.data=L:(L=dw(n),L!==null&&(k.data=L)))),(L=nB?oB(e,n):aB(e,n))&&(k=Jm(c,"onBeforeInput"),0<k.length&&(w=new _k("onBeforeInput","beforeinput",null,n,u),d.push({event:w,listeners:k}),w.data=L)),YB(d,e,c,n,u)}iE(d,t)})}function id(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Jm(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=Qu(e,n),a!=null&&o.unshift(id(e,a,r)),a=Qu(e,t),a!=null&&o.push(id(e,a,r))),e.tag===3)return o;e=e.return}return[]}function $B(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function x_(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=Qu(n,r),c!=null&&s.unshift(id(n,c,l))):a||(c=Qu(n,r),c!=null&&s.push(id(n,c,l)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var QB=/\r\n?/g,JB=/\u0000|\uFFFD/g;function b_(e){return(typeof e=="string"?e:""+e).replace(QB,`
|
|
9
|
-
`).replace(JB,"")}function cE(e,t){return t=b_(t),b_(e)===t}function Ie(e,t,n,o,a,r){switch(n){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||Nl(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&Nl(e,""+o);break;case"className":nm(e,"class",o);break;case"tabIndex":nm(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":nm(e,n,o);break;case"style":sw(e,o,r);break;case"data":if(t!=="object"){nm(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=gm(""+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=gm(""+o),e.setAttribute(n,o);break;case"onClick":o!=null&&(e.onclick=_a);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=gm(""+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),ym(e,"popover",o);break;case"xlinkActuate":ga(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":ga(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":ga(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":ga(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":ga(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":ga(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":ga(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":ga(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":ga(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":ym(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=C7.get(n)||n,ym(e,n,o))}}function G1(e,t,n,o,a,r){switch(n){case"style":sw(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"?Nl(e,o):(typeof o=="number"||typeof o=="bigint")&&Nl(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=_a);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ew.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,""):ym(e,n,o)}}}function Dt(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: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":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:Ie(e,t,o,u,n,null)}}ow(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: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":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:Ie(e,t,s,i,n,null)}rw(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":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<sd.length;o++)de(sd[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:Ie(e,t,c,o,n,null)}return;default:if(ab(t)){for(u in n)n.hasOwnProperty(u)&&(o=n[u],o!==void 0&&G1(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 eN(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)}}p1(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)}aw(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(ab(t)){for(var x in n)f=n[x],n.hasOwnProperty(x)&&f!==void 0&&!o.hasOwnProperty(x)&&G1(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||G1(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 A_(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function tN(){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&&A_(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&&A_(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 W1=null,q1=null;function e0(e){return e.nodeType===9?e:e.ownerDocument}function v_(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 uE(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 V1(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 t1=null;function nN(){var e=window.event;return e&&e.type==="popstate"?e===t1?!1:(t1=e,!0):(t1=null,!1)}var dE=typeof setTimeout=="function"?setTimeout:void 0,oN=typeof clearTimeout=="function"?clearTimeout:void 0,S_=typeof Promise=="function"?Promise:void 0,aN=typeof queueMicrotask=="function"?queueMicrotask:typeof S_<"u"?function(e){return S_.resolve(null).then(e).catch(rN)}:dE;function rN(e){setTimeout(function(){throw e})}function Hr(e){return e==="head"}function L_(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),Vl(t);return}o--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")o++;else if(n==="html")Ku(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,Ku(n);for(var r=n.firstChild;r;){var s=r.nextSibling,i=r.nodeName;r[md]||i==="SCRIPT"||i==="STYLE"||i==="LINK"&&r.rel.toLowerCase()==="stylesheet"||n.removeChild(r),r=s}}else n==="body"&&Ku(e.ownerDocument.body);n=a}while(n);Vl(t)}function k_(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 j1(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":j1(n),ob(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function sN(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[md])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=$n(e.nextSibling),e===null)break}return null}function iN(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=$n(e.nextSibling),e===null))return null;return e}function fE(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=$n(e.nextSibling),e===null))return null;return e}function Z1(e){return e.data==="$?"||e.data==="$~"}function X1(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function lN(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 $n(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 Y1=null;function __(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return $n(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function w_(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 pE(e,t,n){switch(t=e0(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 Ku(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ob(e)}var Qn=new Map,T_=new Set;function t0(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Pa=_e.d;_e.d={f:cN,r:uN,D:dN,C:fN,L:pN,m:hN,X:yN,S:mN,M:gN};function cN(){var e=Pa.f(),t=x0();return e||t}function uN(e){var t=Zl(e);t!==null&&t.tag===5&&t.type==="form"?sT(t):Pa.r(e)}var $l=typeof document>"u"?null:document;function hE(e,t,n){var o=$l;if(o&&typeof t=="string"&&t){var a=Zn(t);a='link[rel="'+e+'"][href="'+a+'"]',typeof n=="string"&&(a+='[crossorigin="'+n+'"]'),T_.has(a)||(T_.add(a),e={rel:e,crossOrigin:n,href:t},o.querySelector(a)===null&&(t=o.createElement("link"),Dt(t,"link",e),kt(t),o.head.appendChild(t)))}}function dN(e){Pa.D(e),hE("dns-prefetch",e,null)}function fN(e,t){Pa.C(e,t),hE("preconnect",e,t)}function pN(e,t,n){Pa.L(e,t,n);var o=$l;if(o&&e&&t){var a='link[rel="preload"][as="'+Zn(t)+'"]';t==="image"&&n&&n.imageSrcSet?(a+='[imagesrcset="'+Zn(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(a+='[imagesizes="'+Zn(n.imageSizes)+'"]')):a+='[href="'+Zn(e)+'"]';var r=a;switch(t){case"style":r=ql(e);break;case"script":r=Ql(e)}Qn.has(r)||(e=qe({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),Qn.set(r,e),o.querySelector(a)!==null||t==="style"&&o.querySelector(vd(r))||t==="script"&&o.querySelector(Sd(r))||(t=o.createElement("link"),Dt(t,"link",e),kt(t),o.head.appendChild(t)))}}function hN(e,t){Pa.m(e,t);var n=$l;if(n&&e){var o=t&&typeof t.as=="string"?t.as:"script",a='link[rel="modulepreload"][as="'+Zn(o)+'"][href="'+Zn(e)+'"]',r=a;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":r=Ql(e)}if(!Qn.has(r)&&(e=qe({rel:"modulepreload",href:e},t),Qn.set(r,e),n.querySelector(a)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Sd(r)))return}o=n.createElement("link"),Dt(o,"link",e),kt(o),n.head.appendChild(o)}}}function mN(e,t,n){Pa.S(e,t,n);var o=$l;if(o&&e){var a=El(o).hoistableStyles,r=ql(e);t=t||"default";var s=a.get(r);if(!s){var i={loading:0,preload:null};if(s=o.querySelector(vd(r)))i.loading=5;else{e=qe({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Qn.get(r))&&Gb(e,n);var l=s=o.createElement("link");kt(l),Dt(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,Tm(s,t,o)}s={type:"stylesheet",instance:s,count:1,state:i},a.set(r,s)}}}function yN(e,t){Pa.X(e,t);var n=$l;if(n&&e){var o=El(n).hoistableScripts,a=Ql(e),r=o.get(a);r||(r=n.querySelector(Sd(a)),r||(e=qe({src:e,async:!0},t),(t=Qn.get(a))&&Wb(e,t),r=n.createElement("script"),kt(r),Dt(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function gN(e,t){Pa.M(e,t);var n=$l;if(n&&e){var o=El(n).hoistableScripts,a=Ql(e),r=o.get(a);r||(r=n.querySelector(Sd(a)),r||(e=qe({src:e,async:!0,type:"module"},t),(t=Qn.get(a))&&Wb(e,t),r=n.createElement("script"),kt(r),Dt(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function E_(e,t,n,o){var a=(a=wr.current)?t0(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=ql(n.href),n=El(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=ql(n.href);var r=El(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(vd(e)))&&!r._p&&(s.instance=r,s.state.loading=5),Qn.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},Qn.set(e,n),r||xN(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=Ql(n),n=El(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 ql(e){return'href="'+Zn(e)+'"'}function vd(e){return'link[rel="stylesheet"]['+e+"]"}function mE(e){return qe({},e,{"data-precedence":e.precedence,precedence:null})}function xN(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}),Dt(t,"link",n),kt(t),e.head.appendChild(t))}function Ql(e){return'[src="'+Zn(e)+'"]'}function Sd(e){return"script[async]"+e}function C_(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+Zn(n.href)+'"]');if(o)return t.instance=o,kt(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"),kt(o),Dt(o,"style",a),Tm(o,n.precedence,e),t.instance=o;case"stylesheet":a=ql(n.href);var r=e.querySelector(vd(a));if(r)return t.state.loading|=4,t.instance=r,kt(r),r;o=mE(n),(a=Qn.get(a))&&Gb(o,a),r=(e.ownerDocument||e).createElement("link"),kt(r);var s=r;return s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),Dt(r,"link",o),t.state.loading|=4,Tm(r,n.precedence,e),t.instance=r;case"script":return r=Ql(n.src),(a=e.querySelector(Sd(r)))?(t.instance=a,kt(a),a):(o=n,(a=Qn.get(r))&&(o=qe({},n),Wb(o,a)),e=e.ownerDocument||e,a=e.createElement("script"),kt(a),Dt(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,Tm(o,n.precedence,e));return t.instance}function Tm(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 Gb(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Wb(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Em=null;function I_(e,t,n){if(Em===null){var o=new Map,a=Em=new Map;a.set(n,o)}else a=Em,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[md]||r[Mt]||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 M_(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function bN(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 yE(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function AN(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=ql(o.href),r=t.querySelector(vd(a));if(r){t=r._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=n0.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=r,kt(r);return}r=t.ownerDocument||t,o=mE(o),(a=Qn.get(a))&&Gb(o,a),r=r.createElement("link"),kt(r);var s=r;s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),Dt(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=n0.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var n1=0;function vN(e,t){return e.stylesheets&&e.count===0&&Cm(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var o=setTimeout(function(){if(e.stylesheets&&Cm(e,e.stylesheets),e.unsuspend){var r=e.unsuspend;e.unsuspend=null,r()}},6e4+t);0<e.imgBytes&&n1===0&&(n1=62500*tN());var a=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Cm(e,e.stylesheets),e.unsuspend)){var r=e.unsuspend;e.unsuspend=null,r()}},(e.imgBytes>n1?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(a)}}:null}function n0(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Cm(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var o0=null;function Cm(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,o0=new Map,t.forEach(SN,e),o0=null,n0.call(e))}function SN(e,t){if(!(t.state.loading&4)){var n=o0.get(e);if(n)var o=n.get(null);else{n=new Map,o0.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=n0.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 ld={$$typeof:ka,Provider:null,Consumer:null,_currentValue:Ds,_currentValue2:Ds,_threadCount:0};function LN(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=Ex(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ex(0),this.hiddenUpdates=Ex(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 gE(e,t,n,o,a,r,s,i,l,c,u,d){return e=new LN(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=mb(),t.refCount++,e.pooledCache=t,t.refCount++,r.memoizedState={element:o,isDehydrated:n,cache:t},xb(r),e}function xE(e){return e?(e=kl,e):kl}function bE(e,t,n,o,a,r){a=xE(a),o.context===null?o.context=a:o.pendingContext=a,o=Er(t),o.payload={element:n},r=r===void 0?null:r,r!==null&&(o.callback=r),n=Cr(e,o,t),n!==null&&(on(n,e,t),Gu(n,e,t))}function R_(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function qb(e,t){R_(e,t),(e=e.alternate)&&R_(e,t)}function AE(e){if(e.tag===13||e.tag===31){var t=Zs(e,67108864);t!==null&&on(t,e,67108864),qb(e,67108864)}}function O_(e){if(e.tag===13||e.tag===31){var t=wn();t=tb(t);var n=Zs(e,t);n!==null&&on(n,e,t),qb(e,t)}}var a0=!0;function kN(e,t,n,o){var a=K.T;K.T=null;var r=_e.p;try{_e.p=2,Vb(e,t,n,o)}finally{_e.p=r,K.T=a}}function _N(e,t,n,o){var a=K.T;K.T=null;var r=_e.p;try{_e.p=8,Vb(e,t,n,o)}finally{_e.p=r,K.T=a}}function Vb(e,t,n,o){if(a0){var a=K1(o);if(a===null)e1(e,t,o,r0,n),D_(e,o);else if(TN(a,e,t,n,o))o.stopPropagation();else if(D_(e,o),t&4&&-1<wN.indexOf(e)){for(;a!==null;){var r=Zl(a);if(r!==null)switch(r.tag){case 3:if(r=r.stateNode,r.current.memoizedState.isDehydrated){var s=Ms(r.pendingLanes);if(s!==0){var i=r;for(i.pendingLanes|=2,i.entangledLanes|=2;s;){var l=1<<31-_n(s);i.entanglements[1]|=l,s&=~l}Wo(r),(ke&6)===0&&(Xm=Ln()+500,Ad(0,!1))}}break;case 31:case 13:i=Zs(r,2),i!==null&&on(i,r,2),x0(),qb(r,2)}if(r=K1(o),r===null&&e1(e,t,o,r0,n),r===a)break;a=r}a!==null&&o.stopPropagation()}else e1(e,t,o,null,n)}}function K1(e){return e=rb(e),jb(e)}var r0=null;function jb(e){if(r0=null,e=xl(e),e!==null){var t=dd(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=H_(t),e!==null)return e;e=null}else if(n===31){if(e=U_(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 r0=e,null}function vE(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(p7()){case V_:return 2;case j_:return 8;case Dm:case h7:return 32;case Z_:return 268435456;default:return 32}default:return 32}}var $1=!1,Rr=null,Or=null,Dr=null,cd=new Map,ud=new Map,Ar=[],wN="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 D_(e,t){switch(e){case"focusin":case"focusout":Rr=null;break;case"dragenter":case"dragleave":Or=null;break;case"mouseover":case"mouseout":Dr=null;break;case"pointerover":case"pointerout":cd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ud.delete(t.pointerId)}}function Mu(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=Zl(t),t!==null&&AE(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function TN(e,t,n,o,a){switch(t){case"focusin":return Rr=Mu(Rr,e,t,n,o,a),!0;case"dragenter":return Or=Mu(Or,e,t,n,o,a),!0;case"mouseover":return Dr=Mu(Dr,e,t,n,o,a),!0;case"pointerover":var r=a.pointerId;return cd.set(r,Mu(cd.get(r)||null,e,t,n,o,a)),!0;case"gotpointercapture":return r=a.pointerId,ud.set(r,Mu(ud.get(r)||null,e,t,n,o,a)),!0}return!1}function SE(e){var t=xl(e.target);if(t!==null){var n=dd(t);if(n!==null){if(t=n.tag,t===13){if(t=H_(n),t!==null){e.blockedOn=t,gk(e.priority,function(){O_(n)});return}}else if(t===31){if(t=U_(n),t!==null){e.blockedOn=t,gk(e.priority,function(){O_(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 Im(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=K1(e.nativeEvent);if(n===null){n=e.nativeEvent;var o=new n.constructor(n.type,n);m1=o,n.target.dispatchEvent(o),m1=null}else return t=Zl(n),t!==null&&AE(t),e.blockedOn=n,!1;t.shift()}return!0}function P_(e,t,n){Im(e)&&n.delete(t)}function EN(){$1=!1,Rr!==null&&Im(Rr)&&(Rr=null),Or!==null&&Im(Or)&&(Or=null),Dr!==null&&Im(Dr)&&(Dr=null),cd.forEach(P_),ud.forEach(P_)}function hm(e,t){e.blockedOn===t&&(e.blockedOn=null,$1||($1=!0,mt.unstable_scheduleCallback(mt.unstable_NormalPriority,EN)))}var mm=null;function B_(e){mm!==e&&(mm=e,mt.unstable_scheduleCallback(mt.unstable_NormalPriority,function(){mm===e&&(mm=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(jb(o||n)===null)continue;break}var r=Zl(n);r!==null&&(e.splice(t,3),t-=3,M1(r,{pending:!0,data:a,method:n.method,action:o},o,a))}}))}function Vl(e){function t(l){return hm(l,e)}Rr!==null&&hm(Rr,e),Or!==null&&hm(Or,e),Dr!==null&&hm(Dr,e),cd.forEach(t),ud.forEach(t);for(var n=0;n<Ar.length;n++){var o=Ar[n];o.blockedOn===e&&(o.blockedOn=null)}for(;0<Ar.length&&(n=Ar[0],n.blockedOn===null);)SE(n),n.blockedOn===null&&Ar.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||B_(n);else if(s){var i=null;if(r&&r.hasAttribute("formAction")){if(a=r,s=r[an]||null)i=s.formAction;else if(jb(a)!==null)continue}else i=s.action;typeof i=="function"?n[o+1]=i:(n.splice(o,3),o-=3),B_(n)}}}function LE(){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 Zb(e){this._internalRoot=e}v0.prototype.render=Zb.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(O(409));var n=t.current,o=wn();bE(n,o,e,t,null,null)};v0.prototype.unmount=Zb.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;bE(e.current,2,null,e,null,null),x0(),t[jl]=null}};function v0(e){this._internalRoot=e}v0.prototype.unstable_scheduleHydration=function(e){if(e){var t=Q_();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ar.length&&t!==0&&t<Ar[n].priority;n++);Ar.splice(n,0,e),n===0&&SE(e)}};var N_=z_.version;if(N_!=="19.2.6")throw Error(O(527,N_,"19.2.6"));_e.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=s7(t),e=e!==null?G_(e):null,e=e===null?null:e.stateNode,e};var CN={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(Ru=__REACT_DEVTOOLS_GLOBAL_HOOK__,!Ru.isDisabled&&Ru.supportsFiber))try{fd=Ru.inject(CN),kn=Ru}catch{}var Ru;S0.createRoot=function(e,t){if(!F_(e))throw Error(O(299));var n=!1,o="",a=hT,r=mT,s=yT;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=gE(e,1,!1,null,null,n,o,null,a,r,s,LE),e[jl]=t.current,Ub(e),new Zb(t)};S0.hydrateRoot=function(e,t,n){if(!F_(e))throw Error(O(299));var o=!1,a="",r=hT,s=mT,i=yT,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=gE(e,1,!0,t,n??null,o,a,l,r,s,i,LE),t.context=xE(null),n=t.current,o=wn(),o=tb(o),a=Er(o),a.callback=null,Cr(n,a,o),n=o,t.current.lanes=n,hd(t,n),Wo(t),e[jl]=t.current,Ub(e),new v0(t)};S0.version="19.2.6"});var TE=Ut((ZQ,wE)=>{"use strict";function _E(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(_E)}catch(e){console.error(e)}}_E(),wE.exports=kE()});var CE=Ut(L0=>{"use strict";var IN=Symbol.for("react.transitional.element"),MN=Symbol.for("react.fragment");function EE(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:IN,type:e,key:o,ref:t!==void 0?t:null,props:n}}L0.Fragment=MN;L0.jsx=EE;L0.jsxs=EE});var se=Ut((YQ,IE)=>{"use strict";IE.exports=CE()});var b3=Ut(Ls=>{"use strict";Object.defineProperty(Ls,"__esModule",{value:!0});Ls.loop=Ls.conditional=Ls.parse=void 0;var N$=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};Ls.parse=N$;var z$=function(t,n){return function(o,a,r,s){n(o,a,r)&&s(o,t,a,r)}};Ls.conditional=z$;var F$=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}};Ls.loop=F$});var A3=Ut(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.readBits=ft.readArray=ft.readUnsigned=ft.readString=ft.peekBytes=ft.readBytes=ft.peekByte=ft.readByte=ft.buildStream=void 0;var H$=function(t){return{data:t,pos:0}};ft.buildStream=H$;var aP=function(){return function(t){return t.data[t.pos++]}};ft.readByte=aP;var U$=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(n){return n.data[n.pos+t]}};ft.peekByte=U$;var ex=function(t){return function(n){return n.data.subarray(n.pos,n.pos+=t)}};ft.readBytes=ex;var G$=function(t){return function(n){return n.data.subarray(n.pos,n.pos+t)}};ft.peekBytes=G$;var W$=function(t){return function(n){return Array.from(ex(t)(n)).map(function(o){return String.fromCharCode(o)}).join("")}};ft.readString=W$;var q$=function(t){return function(n){var o=ex(2)(n);return t?(o[1]<<8)+o[0]:(o[0]<<8)+o[1]}};ft.readUnsigned=q$;var V$=function(t,n){return function(o,a,r){for(var s=typeof n=="function"?n(o,a,r):n,i=ex(t),l=new Array(s),c=0;c<s;c++)l[c]=i(o);return l}};ft.readArray=V$;var j$=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},Z$=function(t){return function(n){for(var o=aP()(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]=j$(a,l.index,l.length):s[i]=a[l.index],s},{})}};ft.readBits=Z$});var rP=Ut(nx=>{"use strict";Object.defineProperty(nx,"__esModule",{value:!0});nx.default=void 0;var ks=b3(),ce=A3(),tx={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}},X$=(0,ks.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}),Y$=(0,ks.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,ks.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)()},tx]}]},function(e){return(0,ce.peekByte)()(e)===44}),K$=(0,ks.conditional)({text:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{preData:function(t,n,o){return(0,ce.readBytes)(o.text.blockSize)(t)}},tx]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===1}),$$=(0,ks.conditional)({application:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{id:function(t,n,o){return(0,ce.readString)(o.blockSize)(t)}},tx]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===255}),Q$=(0,ks.conditional)({comment:[{codes:(0,ce.readBytes)(2)},tx]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===254}),J$=[{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,ks.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,ks.loop)([X$,$$,Q$,Y$,K$],function(e){var t=(0,ce.peekByte)()(e);return t===33||t===44})}],eQ=J$;nx.default=eQ});var sP=Ut(ox=>{"use strict";Object.defineProperty(ox,"__esModule",{value:!0});ox.deinterlace=void 0;var tQ=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};ox.deinterlace=tQ});var iP=Ut(ax=>{"use strict";Object.defineProperty(ax,"__esModule",{value:!0});ax.lzw=void 0;var nQ=function(t,n,o){var a=4096,r=-1,s=o,i,l,c,u,d,f,p,C,h,m,_,x,L,k,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 _,C,w,L,k,M,B;for(_=C=w=L=k=M=B=0,m=0;m<s;){if(k===0){if(C<u){_+=n[B]<<C,C+=8,B++;continue}if(h=_&c,_>>=u,C-=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[k++]=b[h],p=h,L=h;continue}for(f=h,h==i&&(A[k++]=L,h=p);h>l;)A[k++]=b[h],h=g[h];L=b[h]&255,A[k++]=L,i<a&&(g[i]=p,b[i]=L,i++,(i&c)===0&&i<a&&(u++,c+=i)),p=f}k--,y[M++]=A[k],m++}for(m=M;m<s;m++)y[m]=0;return y};ax.lzw=nQ});var cP=Ut(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.decompressFrames=_s.decompressFrame=_s.parseGIF=void 0;var oQ=lQ(rP()),aQ=b3(),rQ=A3(),sQ=sP(),iQ=iP();function lQ(e){return e&&e.__esModule?e:{default:e}}var cQ=function(t){var n=new Uint8Array(t);return(0,aQ.parse)((0,rQ.buildStream)(n),oQ.default)};_s.parseGIF=cQ;var uQ=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},lP=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,iQ.lzw)(a.data.minCodeSize,a.data.blocks,r);a.descriptor.lct.interlaced&&(s=(0,sQ.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=uQ(i)),i};_s.decompressFrame=lP;var dQ=function(t,n){return t.frames.filter(function(o){return o.image}).map(function(o){return lP(o,t.gct,n)})};_s.decompressFrames=dQ});var AP=P(TE(),1);var R=P(se(),1),ye=P(re(),1);var w0=P(re(),1);var k0=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();var ME=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var RE=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase());var Xb=e=>{let t=RE(e);return t.charAt(0).toUpperCase()+t.slice(1)};var Ld=P(re(),1);var _0={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 OE=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var Jl=P(re(),1);var RN=(0,Jl.createContext)({});var DE=()=>(0,Jl.useContext)(RN);var PE=(0,Ld.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=""}=DE()??{},h=o??d?Number(n??u)*24/Number(t??c):n??u;return(0,Ld.createElement)("svg",{ref:l,..._0,width:t??c??_0.width,height:t??c??_0.height,stroke:e??f,strokeWidth:h,className:k0("lucide",p,a),...!r&&!OE(i)&&{"aria-hidden":"true"},...i},[...s.map(([m,x])=>(0,Ld.createElement)(m,x)),...Array.isArray(r)?r:[r]])});var E=(e,t)=>{let n=(0,w0.forwardRef)(({className:o,...a},r)=>(0,w0.createElement)(PE,{ref:r,iconNode:t,className:k0(`lucide-${ME(Xb(e))}`,`lucide-${e}`,o),...a}));return n.displayName=Xb(e),n};var ON=[["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"}]],kd=E("align-center-horizontal",ON);var DN=[["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"}]],ec=E("align-center-vertical",DN);var PN=[["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"}]],_d=E("align-end-horizontal",PN);var BN=[["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"}]],wd=E("align-end-vertical",BN);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"}]],Td=E("align-horizontal-distribute-center",NN);var zN=[["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"}]],Ed=E("align-start-horizontal",zN);var FN=[["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"}]],Cd=E("align-start-vertical",FN);var HN=[["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"}]],Id=E("align-vertical-distribute-center",HN);var UN=[["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"}]],Md=E("bold",UN);var GN=[["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"}]],Rd=E("case-sensitive",GN);var WN=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Od=E("check",WN);var qN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Dd=E("chevron-down",qN);var VN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ys=E("chevron-right",VN);var jN=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],Pd=E("chevrons-down",jN);var ZN=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Bd=E("chevrons-up",ZN);var XN=[["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"}]],Cn=E("circle-question-mark",XN);var YN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ks=E("circle",YN);var KN=[["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"}]],Nd=E("clipboard",KN);var $N=[["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"}]],Ur=E("copy",$N);var QN=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],zd=E("crop",QN);var JN=[["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"}]],Fd=E("delete",JN);var ez=[["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"}]],Hd=E("diamond",ez);var tz=[["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"}]],tc=E("download",tz);var nz=[["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"}]],Gr=E("ellipsis-vertical",nz);var oz=[["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"}]],Wr=E("ellipsis",oz);var az=[["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"}]],Ud=E("eraser",az);var rz=[["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"}]],Gd=E("external-link",rz);var sz=[["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"}]],Wd=E("file-down",sz);var iz=[["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"}]],qd=E("file-up",iz);var lz=[["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"}]],Vd=E("flip-horizontal-2",lz);var cz=[["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"}]],jd=E("flip-vertical-2",cz);var uz=[["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"}]],Zd=E("frame",uz);var dz=[["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"}]],Ao=E("grid-3x3",dz);var fz=[["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"}]],Xd=E("grip",fz);var pz=[["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"}]],Yd=E("group",pz);var hz=[["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"}]],Kd=E("hand",hz);var mz=[["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",mz);var yz=[["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"}]],Qs=E("image",yz);var gz=[["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"}]],$d=E("italic",gz);var xz=[["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"}]],Qd=E("library",xz);var bz=[["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"}]],Jd=E("link",bz);var Az=[["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"}]],ef=E("locate-fixed",Az);var vz=[["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"}]],tf=E("lock",vz);var Sz=[["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"}]],nf=E("magnet",Sz);var Lz=[["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"}]],nc=E("maximize",Lz);var kz=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],of=E("menu",kz);var _z=[["path",{d:"M5 12h14",key:"1ays0h"}]],Ba=E("minus",_z);var wz=[["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"}]],af=E("monitor",wz);var Tz=[["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"}]],rf=E("moon",Tz);var Ez=[["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"}]],sf=E("mouse-pointer-2",Ez);var Cz=[["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"}]],lf=E("mouse-pointer",Cz);var Iz=[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]],cf=E("move-down",Iz);var Mz=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],uf=E("move-right",Mz);var Rz=[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]],df=E("move-up",Rz);var Oz=[["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"}]],qr=E("pen-line",Oz);var Dz=[["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"}]],ff=E("pipette",Dz);var Pz=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Js=E("plus",Pz);var Bz=[["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"}]],pf=E("radio",Bz);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"}]],ei=E("redo-2",Nz);var zz=[["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"}]],hf=E("rotate-ccw",zz);var Fz=[["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"}]],mf=E("scissors",Fz);var Hz=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],yf=E("search",Hz);var Uz=[["path",{d:"M22 2 2 22",key:"y4kqgn"}]],gf=E("slash",Uz);var Gz=[["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"}]],xf=E("spline",Gz);var Wz=[["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"}]],Na=E("square-dashed",Wz);var qz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],za=E("square-dot",qz);var Vz=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],qo=E("square",Vz);var jz=[["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"}]],bf=E("strikethrough",jz);var Zz=[["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"}]],Af=E("sun",Zz);var Xz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Vr=E("text-align-end",Xz);var Yz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],jr=E("text-align-center",Yz);var Kz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],vo=E("text-align-start",Kz);var $z=[["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"}]],oc=E("trash-2",$z);var Qz=[["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"}]],vf=E("type",Qz);var Jz=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Sf=E("underline",Jz);var eF=[["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"}]],ti=E("undo-2",eF);var tF=[["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"}]],Lf=E("ungroup",tF);var nF=[["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"}]],kf=E("upload",nF);var oF=[["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"}]],_f=E("waypoints",oF);var aF=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Fa=E("x",aF);var rF=[["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"}]],wf=E("zoom-out",rF);var sF=[["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"}]],Tf=E("zoom-in",sF);var iF=P(se(),1),So=P(re(),1),BE=(0,So.createContext)(null);var NE=BE;var Yb=()=>(0,So.useContext)(BE),sn=(e,t,n)=>{let o=Yb(),[a,r]=(0,So.useState)(()=>o?e(o):t),s=(0,So.useRef)(e);s.current=e;let i=(0,So.useRef)(t);return i.current=t,(0,So.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 sA=P(se(),1);var ac=P(se(),1),et=P(re(),1),QE=P(ya(),1);var zE=P(se(),1),T0=P(re(),1),FE=(0,T0.createContext)(null),Ef=({container:e,children:t})=>(0,zE.jsx)(FE.Provider,{value:e,children:t}),Pt=()=>(0,T0.useContext)(FE)??document.body;var Kb=[{label:"S",value:16},{label:"M",value:24},{label:"L",value:36},{label:"XL",value:64}],HE=8,UE=256,GE=160,WE=200,qE=150,$b=8,Qb=150,VE="#2563eb",jE=1.5,ZE="rgba(37, 99, 235, 0.12)",XE=1,Jb=10,eA=[{label:"Sans",value:"system-ui, sans-serif"},{label:"Serif",value:"Georgia, 'Times New Roman', serif"},{label:"Mono",value:"ui-monospace, 'SF Mono', Menlo, monospace"}],YE=176,Cf=1,E0=40;var nA=new Set,If=null,Vo=null,jo=null,aA=0,oA=!1,lF=()=>{for(let e of nA)e(If)},C0=e=>{If=e,lF()},cF=e=>(nA.add(e),()=>{nA.delete(e)}),uF=e=>{if(oA)return;jo&&(clearTimeout(jo),jo=null),Vo&&clearTimeout(Vo);let t=Date.now()-aA;if(If!==null||t<600){C0(e);return}Vo=setTimeout(()=>{Vo=null,C0(e)},600)},KE=e=>{Vo&&(clearTimeout(Vo),Vo=null),If?.id===e&&(jo&&clearTimeout(jo),jo=setTimeout(()=>{jo=null,aA=Date.now(),C0(null)},80))},$E=()=>{Vo&&(clearTimeout(Vo),Vo=null),jo&&(clearTimeout(jo),jo=null),If&&(aA=Date.now(),C0(null))},rA=({children:e})=>((0,et.useEffect)(()=>{let t=()=>{oA=!0,$E()},n=()=>{oA=!1},o=a=>{a.key==="Escape"&&$E()};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,ac.jsxs)(JE.Provider,{value:!0,children:[e,(0,ac.jsx)(fF,{})]})),JE=(0,et.createContext)(!1),dF=()=>(0,et.useContext)(JE),fF=()=>{let[e,t]=(0,et.useState)(null),n=Pt();return(0,et.useEffect)(()=>cF(t),[]),!e||typeof document>"u"?null:(0,QE.createPortal)((0,ac.jsx)(pF,{target:e}),n)},pF=({target:e})=>{let t=(0,et.useRef)(null),[n,o]=(0,et.useState)(null);(0,et.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,ac.jsx)("div",{ref:t,role:"tooltip",className:"du-tooltip",style:a,children:e.content})},ni=({content:e,side:t="bottom",disabled:n,children:o})=>{let a=(0,et.useId)();if(!dF()||n||e===void 0||e===null)return(0,et.isValidElement)(o)&&typeof e=="string"&&!n?(0,et.cloneElement)(o,{title:e}):o;if(!(0,et.isValidElement)(o))return o;let s=o,i=f=>{uF({id:a,content:e,side:t,rect:f.getBoundingClientRect()})};return(0,et.cloneElement)(s,{onPointerEnter:f=>{s.props.onPointerEnter?.(f),f.pointerType!=="touch"&&i(f.currentTarget)},onPointerLeave:f=>{s.props.onPointerLeave?.(f),KE(a)},onFocus:f=>{s.props.onFocus?.(f),i(f.currentTarget)},onBlur:f=>{s.props.onBlur?.(f),KE(a)},title:void 0})};var Jn=({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,sA.jsx)(ni,{content:e,children:(0,sA.jsx)("button",{type:"button",className:s,"aria-label":e,"aria-pressed":t??void 0,...r,children:a})})};var eC=P(se(),1),oi=({children:e,className:t,ariaLabel:n})=>(0,eC.jsx)("div",{className:`du-button-group ${t??""}`.trim(),role:"group","aria-label":n,children:e});var iA=P(se(),1);var In=({value:e,options:t,onChange:n,ariaLabel:o})=>(0,iA.jsx)(oi,{...o!==void 0?{ariaLabel:o}:{},children:t.map(a=>(0,iA.jsx)(Jn,{label:a.label,active:e===a.value,onClick:()=>{n(a.value)},size:"sm",children:a.icon},String(a.value)))});var Mf=P(se(),1),Rf=({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,Mf.jsxs)("div",{className:"du-slider",children:[(0,Mf.jsx)("input",{type:"range",min:t,max:n,step:o,value:l,onChange:i,"aria-label":r,className:"du-slider-track"}),(0,Mf.jsx)("span",{className:"du-slider-value",children:e===null?"\u2014":s??e})]})};var tC=P(se(),1),lA=({children:e,className:t,style:n})=>(0,tC.jsx)("div",{className:`du-ui-layer ${t??""}`.trim(),style:n,children:e});var eo=P(se(),1),cA=({left:e,center:t,right:n})=>(0,eo.jsxs)("div",{className:"du-bar du-bar-top",children:[(0,eo.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,eo.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,eo.jsx)("div",{}),(0,eo.jsx)("div",{className:"du-bar-zone",children:n})]}),uA=({left:e,center:t,right:n})=>(0,eo.jsxs)("div",{className:"du-bar du-bar-bottom",children:[(0,eo.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,eo.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,eo.jsx)("div",{}),(0,eo.jsx)("div",{className:"du-bar-zone",children:n})]});var is=P(se(),1),BD=P(re(),1);var Ke=P(se(),1),Zc=P(re(),1);var I0="select";var Zo={};yo(Zo,{EMPTY:()=>Pe,add:()=>Xt,clear:()=>yF,equals:()=>ai,has:()=>hF,remove:()=>Pf,replace:()=>mF,single:()=>wt,toggle:()=>pA});var Ze=e=>e,dA=e=>e,ln=e=>e,Of=e=>e,rc=e=>e,fA=e=>e;var v=e=>{if(e===void 0)throw new Error("required value is undefined");return e};var Df=e=>{let t={};for(let[n,o]of Object.entries(e))o!==void 0&&(t[n]=o);return t};var M0=(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]),hF=(e,t)=>e.has(t),Xt=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},Pf=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},pA=(e,t)=>e.has(t)?Pf(e,t):Xt(e,t),mF=e=>wt(e),yF=()=>Pe,ai=(e,t)=>M0(e,t);var W={};yo(W,{ZERO:()=>nC,add:()=>xF,angle:()=>CF,cross:()=>kF,distance:()=>_F,distanceSq:()=>rC,div:()=>vF,dot:()=>LF,equals:()=>OF,length:()=>aC,lengthSq:()=>oC,lerp:()=>TF,midpoint:()=>EF,mul:()=>AF,negate:()=>SF,normalize:()=>wF,of:()=>gF,perp:()=>RF,rotate:()=>IF,rotateAround:()=>MF,sub:()=>bF});var nC=Object.freeze({x:0,y:0}),gF=(e,t)=>({x:e,y:t}),xF=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),bF=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),AF=(e,t)=>({x:e.x*t,y:e.y*t}),vF=(e,t)=>({x:e.x/t,y:e.y/t}),SF=e=>({x:-e.x,y:-e.y}),LF=(e,t)=>e.x*t.x+e.y*t.y,kF=(e,t)=>e.x*t.y-e.y*t.x,oC=e=>e.x*e.x+e.y*e.y,aC=e=>Math.sqrt(oC(e)),rC=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o},_F=(e,t)=>Math.sqrt(rC(e,t)),wF=e=>{let t=aC(e);return t===0?nC:{x:e.x/t,y:e.y/t}},TF=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),EF=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),CF=e=>Math.atan2(e.y,e.x),IF=(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}},MF=(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)}},RF=e=>({x:-e.y,y:e.x}),OF=(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 sc={};yo(sc,{clamp:()=>DF,clamp01:()=>PF});var DF=(e,t,n)=>Math.max(t,Math.min(n,e)),PF=e=>e<0?0:e>1?1:e;var z={};yo(z,{IDENTITY:()=>BF,applyToBounds:()=>WF,applyToPoint:()=>Bf,decompose:()=>qF,equals:()=>VF,inverse:()=>GF,multiply:()=>UF,of:()=>NF,rotation:()=>HF,scaling:()=>FF,translation:()=>zF});var BF=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}),zF=(e,t)=>({a:1,b:0,c:0,d:1,e,f:t}),FF=(e,t=e)=>({a:e,b:0,c:0,d:t,e:0,f:0}),HF=e=>{let t=Math.cos(e),n=Math.sin(e);return{a:t,b:n,c:-n,d:t,e:0,f:0}},UF=(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}),GF=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}},Bf=(e,t)=>({x:e.a*t.x+e.c*t.y+e.e,y:e.b*t.x+e.d*t.y+e.f}),WF=(e,t)=>{let n=Bf(e,{x:t.x,y:t.y}),o=Bf(e,{x:t.x+t.width,y:t.y}),a=Bf(e,{x:t.x,y:t.y+t.height}),r=Bf(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}},qF=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}}},VF=(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 j={};yo(j,{EMPTY:()=>sC,centerOf:()=>XF,contains:()=>mA,containsBounds:()=>$F,equals:()=>eH,expand:()=>QF,fromCenter:()=>ZF,fromPoints:()=>R0,intersection:()=>iC,intersects:()=>KF,isEmpty:()=>hA,maxX:()=>Zr,maxY:()=>Xr,normalize:()=>JF,of:()=>jF,union:()=>YF});var sC=Object.freeze({x:0,y:0,width:0,height:0}),jF=(e,t,n,o)=>({x:e,y:t,width:n,height:o}),R0=e=>{if(e.length===0)return sC;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}},ZF=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,width:t,height:n}),XF=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),Zr=e=>e.x+e.width,Xr=e=>e.y+e.height,hA=e=>e.width<=0||e.height<=0,YF=(e,t)=>{if(hA(e))return t;if(hA(t))return e;let n=Math.min(e.x,t.x),o=Math.min(e.y,t.y),a=Math.max(Zr(e),Zr(t)),r=Math.max(Xr(e),Xr(t));return{x:n,y:o,width:a-n,height:r-o}},iC=(e,t)=>{let n=Math.max(e.x,t.x),o=Math.max(e.y,t.y),a=Math.min(Zr(e),Zr(t)),r=Math.min(Xr(e),Xr(t));return a<=n||r<=o?null:{x:n,y:o,width:a-n,height:r-o}},KF=(e,t)=>iC(e,t)!==null,mA=(e,t)=>t.x>=e.x&&t.x<=Zr(e)&&t.y>=e.y&&t.y<=Xr(e),$F=(e,t)=>t.x>=e.x&&t.y>=e.y&&Zr(t)<=Zr(e)&&Xr(t)<=Xr(e),QF=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),JF=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)}),eH=(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 Ha={};yo(Ha,{distanceToSegment:()=>oH,distanceToSegmentSq:()=>ic,pointInPolygon:()=>nH,pointInRect:()=>tH,pointOnPolyline:()=>aH,pointOnSegment:()=>lC});var tH=(e,t)=>mA(t,e),nH=(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},ic=(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},oH=(e,t,n)=>Math.sqrt(ic(e,t,n)),lC=(e,t,n,o=1)=>ic(e,t,n)<=o*o,aH=(e,t,n=1)=>{for(let o=0;o<t.length-1;o++){let a=t[o],r=t[o+1];if(a&&r&&lC(e,a,r,n))return!0}return!1};var cn={};yo(cn,{cubicAt:()=>si,cubicBounds:()=>sH,flattenCubic:()=>uH,flattenQuadratic:()=>cH,pointOnCubic:()=>lH,pointOnQuadratic:()=>iH,quadraticAt:()=>ri,quadraticBounds:()=>rH});var ri=(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}},si=(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}},rH=(e,t,n)=>{let o=[e,n];for(let a of cC(e.x,t.x,n.x))o.push(ri(e,t,n,a));for(let a of cC(e.y,t.y,n.y))o.push(ri(e,t,n,a));return R0(o)},sH=(e,t,n,o)=>{let a=[e,o];for(let r of uC(e.x,t.x,n.x,o.x))a.push(si(e,t,n,o,r));for(let r of uC(e.y,t.y,n.y,o.y))a.push(si(e,t,n,o,r));return R0(a)},iH=(e,t,n,o,a=1,r=32)=>{let s=a*a,i=t;for(let l=1;l<=r;l++){let c=ri(t,n,o,l/r);if(ic(e,i,c)<=s)return!0;i=c}return!1},lH=(e,t,n,o,a,r=1,s=64)=>{let i=r*r,l=t;for(let c=1;c<=s;c++){let u=si(t,n,o,a,c/s);if(ic(e,l,u)<=i)return!0;l=u}return!1},cH=(e,t,n,o=16)=>{let a=new Array(o+1);for(let r=0;r<=o;r++)a[r]=ri(e,t,n,r/o);return a},uH=(e,t,n,o,a=32)=>{let r=new Array(a+1);for(let s=0;s<=a;s++)r[s]=si(e,t,n,o,s/a);return r},cC=(e,t,n)=>{let o=e-2*t+n;if(o===0)return[];let a=(e-t)/o;return a>0&&a<1?[a]:[]},uC=(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 D0={};yo(D0,{lineLine:()=>dH,segmentCubic:()=>pH,segmentQuadratic:()=>fH,segmentSegment:()=>dC});var O0=1e-12,dH=(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)<O0)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}},dC=(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)<O0)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}},fH=(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)<O0){if(Math.abs(f)>O0){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),C=(-f-A)/(2*d);_>=0&&_<=1&&h.push(_),C>=0&&C<=1&&h.push(C)}}let m=[],x=t.x-e.x,y=t.y-e.y,g=x*x+y*y;for(let b of h){let A=ri(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},pH=(e,t,n,o,a,r,s=64)=>{let i=[],l=n;for(let c=1;c<=s;c++){let u=si(n,o,a,r,c/s),d=dC(e,t,l,u);d!==null&&i.push(d),l=u}return i};var P0={};yo(P0,{contrastRatio:()=>bA,format:()=>yH,luminance:()=>xA,meetsContrastAA:()=>bH,meetsContrastAAA:()=>AH,mix:()=>gH,parse:()=>mH,withAlpha:()=>xH});var hH=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}}),mH=e=>{let t=e.trim().toLowerCase(),n=hH[t];if(n!==void 0)return n;if(t.startsWith("#")){let a=t.slice(1);if(a.length===3||a.length===4){let r=Yr(a.charAt(0)+a.charAt(0)),s=Yr(a.charAt(1)+a.charAt(1)),i=Yr(a.charAt(2)+a.charAt(2)),l=a.length===4?Yr(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=Yr(a.slice(0,2)),s=Yr(a.slice(2,4)),i=Yr(a.slice(4,6)),l=a.length===8?Yr(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}`)},yH=e=>{let t=yA(e.r),n=yA(e.g),o=yA(e.b),a=vH(e.a);return a===1?`#${gA(t)}${gA(n)}${gA(o)}`:`rgba(${t}, ${n}, ${o}, ${a})`},gH=(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}),xH=(e,t)=>({...e,a:t}),xA=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)},bA=(e,t)=>{let n=xA(e),o=xA(t),[a,r]=n<o?[n,o]:[o,n];return(r+.05)/(a+.05)},bH=(e,t,n=!1)=>bA(e,t)>=(n?3:4.5),AH=(e,t,n=!1)=>bA(e,t)>=(n?4.5:7),Yr=e=>parseInt(e,16),yA=e=>{let t=Math.round(e);return t<0?0:t>255?255:t},vH=e=>e<0?0:e>1?1:e,gA=e=>e.toString(16).padStart(2,"0");var Nf={};yo(Nf,{offsetClosedPath:()=>SH,signedArea:()=>LH});var SH=(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,C=h*u+m*d,w=C>1e-6?t/C:t;i.push({x:y.x+_*h*w,y:y.y+_*m*w})}return i},LH=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 AA=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}},zf=(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 fC=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)},vA=e=>{let t=[];for(let n of e){if(n.text==="")continue;let o=t[t.length-1];o!==void 0&&fC(o.style)===fC(n.style)?t[t.length-1]={text:o.text+n.text,...o.style!==void 0?{style:o.style}:{}}:t.push(n)}return t},pC=e=>{let t=e.runs;return t!==void 0&&t.length>0?vA(t):e.text===""?[]:[{text:e.text}]},Ff=(e,t,n)=>{let o=Math.min(t,n),a=Math.max(t,n),r=[],s=0;for(let i of pC(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},wH=(e,t)=>{let n={...e??{},...t},o=Object.entries(n).filter(([,r])=>r!==void 0);return o.length===0?void 0:Object.fromEntries(o)},SA=(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 pC(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=wH(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=vA(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 LA=e=>{if(typeof e!="object"||e===null)return!1;let t=e.kind;return t==="named"||t==="ratio"||t==="absolute"||t==="edge"},ii=e=>e.kind==="point"?void 0:e.elementId;var hC=null,kA=e=>{hC=e},_A=()=>hC;var li=e=>e.type==="rectangle",lc=e=>e.type==="ellipse",Ua=e=>e.type==="polygon",wA=e=>e.type==="path",pe=e=>e.type==="text",ct=e=>e.type==="image";var ze=e=>e.type==="group",Be=e=>e.type==="frame";var Mn=e=>e.type==="brush",Hf=e=>e.stroke??e.fill??"#000",mC=new Map,to=(e,t)=>{mC.set(e,t)};var Re=e=>{let t=mC.get(e.type);if(!t)throw new Error(`No bounder registered for shape type: ${e.type}`);return t(e)},N=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 j.fromPoints(r)};to("rectangle",e=>({x:0,y:0,width:e.width,height:e.height}));to("ellipse",e=>({x:0,y:0,width:e.width,height:e.height}));to("polygon",e=>j.fromPoints(e.points));to("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 j.fromPoints(t)});to("text",e=>{let t=e.fontSize*1.2,n=e.text.split(`
|
|
10
|
-
`),o=_A(),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}});to("image",e=>({x:0,y:0,width:e.width,height:e.height}));to("template",e=>({x:0,y:0,width:e.width,height:e.height}));to("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}});to("group",()=>({x:0,y:0,width:0,height:0}));to("frame",e=>({x:0,y:0,width:e.width,height:e.height}));to("block-arrow",e=>({x:0,y:0,width:e.width,height:e.height}));var B0=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 Tt=(e,t)=>e.order<t.order?-1:e.order>t.order?1:0,Uf=(e,t)=>Tt(t,e);var Rn=(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)}},ci=(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 N0=(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),ue=(e,t)=>e.links.get(t);var Lo=e=>[...e.layers.values()].sort(Tt),Ga=(e,t)=>[...e.elements.values()].filter(n=>n.layerId===t).sort(Tt),EA=(e,t)=>[...e.links.values()].filter(n=>n.layerId===t).sort(Tt),yC=48,z0=10,TA=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}],gC=6,TH=(e,t)=>{let{x:n,y:o,width:a,height:r}=e,s=(l,c,u,d)=>{let f=[];for(let p=0;p<=gC;p++){let h=u+(d-u)*(p/gC);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)]},EH=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<=z0;a++){let r=a/z0,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<=z0;a++){let r=a/z0,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},CH=new Map;var IH=e=>{if(Ua(e))return[e.points.map(t=>({x:t.x,y:t.y}))];if(lc(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<yC;i++)s.push(N0(n,o,a,r,i/yC));return[s]}if(li(e)){let t=Re(e),n=zf(e.style.roundness,t.width,t.height);return[n>0?TH(t,n):TA(t)]}return ct(e)||pe(e)?[TA(Re(e))]:wA(e)?[EH(e.commands)]:null},Gf=(e,t)=>{if(ze(t)){let r=[];for(let s of CA(e,t.id))r.push(...Gf(e,s));return r}let n=IH(t);if(n)return n.map(r=>r.map(s=>Rn(t,s)));let o=CH.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=>Rn(t,i)))}let a=N(t);return[TA(a)]},CA=(e,t)=>{let n=[];for(let o of e.elements.values())o.parentId===t&&n.push(o);return n.sort(Tt),n},IA=(e,t)=>{let n=t;for(let o=0;n&&o<xC;o++){if(n.locked===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1},cc=(e,t)=>{let n=t;for(let o=0;n&&o<xC;o++){if(n.hidden===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1};var MA=(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 CA(e,s))o.has(i.id)||(o.add(i.id),a.push(i),r.push(i.id))}return a},xC=64;var F0=(e,t,n=.5)=>{let o=[];for(let a of e.elements.values()){let r=N(a);if(!j.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},ui=(e,t)=>{let n=Lo(e);for(let o=n.length-1;o>=0;o--){let a=n[o];if(!a?.visible)continue;let r=Ga(e,a.id);for(let s=r.length-1;s>=0;s--){let i=r[s];if(i!==void 0&&j.contains(N(i),t))return i}}},RA=(e,t)=>{let n=new B0(t);for(let o of e.elements.values())n.insert(o.id,N(o));return n};var OA=(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||!j.contains(N(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 MH=[];var Wf=e=>di(e)!==null,di=e=>{for(let s of MH){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??RH,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},RH=0,no=e=>{let t=di(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},OH=[];var DA=e=>{for(let n of OH){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=no(e);return t?[t]:[]},qf=(e,t,n=new Set)=>{let o=Lo(e);for(let a=o.length-1;a>=0;a--){let r=o[a];if(!r?.visible)continue;let s=Ga(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=no(l);if(c&&j.contains(c,t))return l}}return null},PA=(e,t)=>{let n=di(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}},BA=(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 bC=new Set,NA={"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}},AC=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left","center"];var vC=(e,t)=>zA(e,t),Yt=(e,t)=>{let n=vC(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)}},Xo=(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}},Wa=(e,t,n=bC)=>{let o=null;for(let[a,r]of H0(e)){if(n.has(a))continue;let s=DH(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}},DH=e=>{let t=/^edge-(\d+)$/.exec(e);return t?{kind:"edge",index:Number(t[1]),t:.5}:{kind:"named",name:e}},ko=e=>Wf(e)?PH:bC,PH=new Set(["center"]);var H0=e=>{let t=new Map;if(Ua(e))BH(e,t);else{let n=Re(e);for(let o of SC){let a=NA[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,zA(e,o));return t},SC=["top","right","bottom","left"],BH=(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}`,W.midpoint(a,r))}},zA=(e,t)=>{switch(t.kind){case"named":{let n=kC(e,t.name);if(!n)throw new Error(`Unknown anchor "${t.name}" on shape ${e.id} (type ${e.type}). Standard names: ${AC.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 LC(e,t.index,t.t)}},LC=(e,t,n)=>{if(Ua(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}},kC=(e,t)=>{let n=e.anchors?.[t];if(n!==void 0)return n.kind==="named"?kC(e,n.name):zA(e,n);if(Ua(e)&&t.startsWith("edge-")){let r=parseInt(t.slice(5),10);if(!isNaN(r))return LC(e,r,.5)}let o=NA[t];if(!o)return;let a=Re(e);return{x:a.x+a.width*o.x,y:a.y+a.height*o.y}};var FA=(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}},Vf=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},jf=(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 IC=(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=Math.hypot(s.x-i.x,s.y-i.y);n.push(l),o+=l}let a=o*t;for(let r=0;r<n.length;r++){let s=v(n[r]);if(a<=s){let i=v(e[r]),l=v(e[r+1]),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[e.length-1])},NH=e=>{let t=0;for(let n=1;n<e.length;n++){let o=v(e[n-1]),a=v(e[n]);t+=Math.hypot(a.x-o.x,a.y-o.y)}return t},uc=(e,t)=>{let n=t.label?.position;if(n===void 0&&(t.routing??"straight")==="orthogonal"&&e.length>2){let s=-1,i=v(e[0]);for(let l=1;l<e.length;l++){let c=v(e[l-1]),u=v(e[l]),d=Math.hypot(u.x-c.x,u.y-c.y);d>s&&(s=d,i={x:(c.x+u.x)/2,y:(c.y+u.y)/2})}return i}let o=NH(e),a=o>0?Math.min(.5,24/o):0,r=Math.min(1-a,Math.max(a,n??.5));return IC(e,r)},MC=e=>{let t=e.fontSize??12,n=t*.62,o=Math.max(1,Math.floor(160/n)),a=0,r=0;for(let s of e.text.split(`
|
|
11
|
-
`)){let i=s.split(/\s+/).filter(c=>c.length>0);if(i.length===0){a+=1;continue}let l="";for(let c of i){let u=l===""?c:`${l} ${c}`;u.length<=o||l===""?l=u:(r=Math.max(r,l.length),a+=1,l=c)}r=Math.max(r,l.length),a+=1}return{width:Math.min(r*n,160)+12,height:a*t*1.25+6}},Zf=(e,t)=>{if(!t.label||t.label.text===""||e.length<2)return null;let n=uc(e,t),o=MC(t.label);return{x:n.x-o.width/2,y:n.y-o.height/2,width:o.width,height:o.height}},zH=[.5,.38,.62,.26,.74,.14,.86],_C=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,Xf=(e,t)=>{let n=e(.5);if(t===null||!_C(n,t))return n;for(let o of zH){let a=e(o);if(!_C(a,t))return a}return n},UA=(e,t)=>{let n=0,o=1/0,a=0,r=0;for(let s=1;s<e.length;s++){let i=v(e[s-1]),l=v(e[s]),c=l.x-i.x,u=l.y-i.y,d=Math.hypot(c,u);if(d>0){let f=Math.max(0,Math.min(1,((t.x-i.x)*c+(t.y-i.y)*u)/(d*d))),p=i.x+c*f,h=i.y+u*f,m=(t.x-p)**2+(t.y-h)**2;m<o&&(o=m,a=r+d*f)}r+=d,n+=d}return n>0?a/n:.5};var dc={x:1,y:0},Yf={x:0,y:1},Kf={x:-1,y:0},$f={x:0,y:-1},RC=e=>e.y===0;var FH=e=>{let t=Math.abs(e.x),n=Math.abs(e.y);return e.x>n?dc:e.x<=-n?Kf:e.y>t?Yf:$f},Qf=(e,t)=>FH({x:e.x-t.x,y:e.y-t.y}),U0=(e,t)=>{let n=N(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?Kf:i===a?dc:i===r?$f:Yf},OC=(e,t)=>{let n=N(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 dc;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?dc:Kf:u>=0?Yf:$f};var G0=new Map,GA=(e,t)=>{G0.set(e,t)},DC=e=>G0.get(e),W0=(e,t)=>{let n=G0.get(e.type);if(!n)throw new Error(`No outline sampler registered for shape type: ${e.type}`);let o=n(e,sc.clamp01(t));return Rn(e,o)},PC=(e,t,n=64)=>{let o=G0.get(e.type);if(!o)return null;let a=0,r=Rn(e,o(e,0)),s=W.distance(t,r);for(let i=1;i<n;i++){let l=i/n,c=Rn(e,o(e,l)),u=W.distance(t,c);u<s&&(s=u,a=l,r=c)}return{ratio:a,world:r,distance:s}},BC=(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=W.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])};GA("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 BC(o,t)});GA("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 N0(o,a,r,s,t)});GA("polygon",(e,t)=>BC(e.points,t));var NC=e=>e.kind==="point"?null:e.elementId,zC=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:Math.sign(e.x)||0,y:0}:{x:0,y:Math.sign(e.y)},FC=(e,t,n)=>{if(t.kind==="anchor"){let a=zC(Xo(e,t.anchor));if(a.x!==0||a.y!==0)return a}let o=zC(U0(e,n));return o.x!==0||o.y!==0?o:{x:0,y:-1}},WH=(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}},qA=(e,t)=>{let n=NC(t.from);if(!n||n!==NC(t.to))return null;let o=I(e,n);if(!o)return null;let a=N(o),r=oo(e,t.from),s=oo(e,t.to);if(!r||!s)return null;let i=r,l=s,c=FC(o,t.from,i),u=FC(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=WH(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}},qH=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]},VH=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}]}},UC=e=>{let t=N(e);return{x:t.x+t.width/2,y:t.y+t.height/2}},jH=(e,t)=>{let n=UC(e),o=t.x-n.x,a=t.y-n.y;if(Math.abs(o)<1e-6&&Math.abs(a)<1e-6||!DC(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=W0(e,0);for(let d=1;d<=96;d++){let f=W0(e,d/96),p=D0.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},oo=(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"?jH(o,n??UC(o)):W0(o,t.ratio):null},ut=(e,t)=>{let n=qA(e,t);if(n)return qH(n);let o=oo(e,t.from);if(!o)return null;let a=oo(e,t.to);if(!a)return null;let r=t.from.kind==="floating"?oo(e,t.from,a)??o:o,s=t.to.kind==="floating"?oo(e,t.to,o)??a:a;return(t.routing??"straight")!=="orthogonal"?[r,...t.waypoints??[],s]:t.routedPoints!==void 0?[r,...t.routedPoints,s]:GC(r,s,WA(t.from),WA(t.to))},GC=(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]},WA=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}},HC=(e,t,n)=>{let o=WA(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=qA(e,t);if(n)return VH(n);let o=ut(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=HC(t.from,a,r),i=HC(t.to,r,a);return{start:a,segments:[FA(a,r,s,i)]}}return{start:a,segments:Vf(o)}},_o=(e,t)=>{if((t.routing??"straight")!=="bezier")return ut(e,t);let n=Jf(e,t);return n?jf(n.start,n.segments):null},ep=(e,t)=>{let n=t.routing??"straight";if(n==="orthogonal")return null;let o=fc(e,t);if(n==="bezier"){let s=Jf(e,t);if(!s)return null;let i=[],l=s.start;for(let c of s.segments){let u=l;i.push(Xf(d=>cn.cubicAt(u,c.c1,c.c2,c.to,d),o)),l=c.to}return i}let a=ut(e,t);if(!a||a.length<2)return null;let r=[];for(let s=0;s<a.length-1;s++){let i=v(a[s]),l=v(a[s+1]);r.push(Xf(c=>({x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}),o))}return r},tp=(e,t,n)=>{let o=fc(e,t);return(n.length===2?[0]:Array.from({length:Math.max(0,n.length-3)},(r,s)=>s+1)).map(r=>{let s=v(n[r]),i=v(n[r+1]);return{k:r,point:Xf(l=>({x:s.x+(i.x-s.x)*l,y:s.y+(i.y-s.y)*l}),o)}})},VA=(e,t,n=5)=>{let o=null;for(let a of e.links.values()){let r=_o(e,a);if(!r)continue;let s=1/0;for(let i=1;i<r.length;i++){let l=Ha.distanceToSegment(t,v(r[i-1]),v(r[i]));l<s&&(s=l)}s>n&&!ZH(e,a,t)||(!o||s<=o.distance)&&(o={edge:a,distance:s})}return o?.edge??null},fc=(e,t)=>{let n=_o(e,t);return!n||n.length<2?null:Zf(n,t)},ZH=(e,t,n)=>{let o=fc(e,t);return o!==null&&n.x>=o.x&&n.x<=o.x+o.width&&n.y>=o.y&&n.y<=o.y+o.height};var np=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=W.sub(n(d+1),n(d)),p=W.lengthSq(f)>0?W.normalize(f):{x:1,y:0};a.push(p),r.push(W.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(W.add(p,W.mul(y,f))),i.push(W.sub(p,W.mul(y,f)));continue}if(d===t-1){let y=v(r[t-2]);s.push(W.add(p,W.mul(y,f))),i.push(W.sub(p,W.mul(y,f)));continue}let h=v(r[d-1]),m=v(r[d]),x=W.cross(v(a[d-1]),v(a[d]));if(Math.abs(x)<1e-9){s.push(W.add(p,W.mul(h,f))),i.push(W.sub(p,W.mul(h,f)));continue}x>0?(s.push(...WC(p,h,m,f,1)),i.push(...qC(p,h,m,f,-1))):(s.push(...qC(p,h,m,f,1)),i.push(...WC(p,h,m,f,-1)))}let l=VC(n(t-1),v(r[t-2]),o(t-1),!1),c=VC(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},WC=(e,t,n,o,a)=>{let r=W.normalize(W.add(t,n)),s=W.dot(r,t);return s>.001&&1/s<=2.5?[W.add(e,W.mul(r,a*(o/s)))]:[W.add(e,W.mul(t,a*o)),W.add(e,W.mul(n,a*o))]},qC=(e,t,n,o,a)=>jC(e,o,W.angle(W.mul(t,a)),W.angle(W.mul(n,a))),VC=(e,t,n,o)=>{let a=W.angle(t)+(o?Math.PI:0);return jC(e,n,a,a-Math.PI)},jC=(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 ZC=new Map,jA=(e,t)=>{ZC.set(e,t)},op=e=>{let t=N(e),n=ZC.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 ap=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}}},XA={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"}]}},YA={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)||!XC(n,e.probe,e.threshold))continue;let o=Wa(n,e.probe,ko(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}},KA={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)||!XC(n,e.probe,e.threshold))continue;let o=PC(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}},XC=(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 $A=()=>20,q0=e=>e.snapToGrid??!0,QA=Object.freeze({pan:{x:0,y:0},zoom:1,rotation:0,size:{width:0,height:0},gridEnabled:!1}),ao=e=>{let t=z.translation(-e.pan.x,-e.pan.y),n=z.rotation(e.rotation),o=z.scaling(e.zoom);return z.multiply(o,z.multiply(n,t))},qa=e=>z.inverse(ao(e)),JA=(e,t)=>({...e,pan:{x:e.pan.x-t.x/e.zoom,y:e.pan.y-t.y/e.zoom}}),V0=(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}}},ev=(e,t,n)=>({...e,size:{width:t,height:n}});var Et=class extends Error{name="FractionalIndexError"};var j0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function YC(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 Et("invalid order key head: "+e)}function KC(e){let t=e.charAt(0);if(e.length!==YC(t))throw new Et("invalid integer part of order key: "+e)}function pc(e){let t=YC(e.charAt(0));if(t>e.length)throw new Et("invalid order key: "+e);return e.slice(0,t)}function tv(e,t){KC(e);let n=t.charAt(0),[o,...a]=e.split("");if(o===void 0)throw new Et("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 $C(e,t){KC(e);let[n,...o]=e.split("");if(n===void 0)throw new Et("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 fi(e,t,n){let o=n.charAt(0);if(t!==null&&e>=t)throw new Et(e+" >= "+t);if(e.slice(-1)===o||t!==null&&t.slice(-1)===o)throw new Et("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)+fi(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)+fi(e.slice(1),null,n)}function QC(e){return"A"+e.charAt(0).repeat(26)}function YH(e){return"a"+e.charAt(0)}function nv(e,t=j0){if(e===QC(t))throw new Et("invalid order key: "+e);let n=pc(e);if(e.slice(n.length).slice(-1)===t.charAt(0))throw new Et("invalid order key: "+e)}function ro(e,t,n=j0){let o=e??null,a=t??null;if(o!==null&&nv(o,n),a!==null&&nv(a,n),o!==null&&a!==null&&o>=a)throw new Et(o+" >= "+a);if(o===null&&a===null)return YH(n);if(o===null){let u=pc(a),d=a.slice(u.length);if(u===QC(n))return u+fi("",d,n);if(u<a)return u;let f=$C(u,n);if(f===null)throw new Et("cannot decrement any more");return f}if(a===null){let u=pc(o),d=o.slice(u.length),f=tv(u,n);return f===null?u+fi(d,null,n):f}let r=pc(o),s=o.slice(r.length),i=pc(a),l=a.slice(i.length);if(r===i)return r+fi(s,l,n);let c=tv(r,n);if(c===null)throw new Et("cannot increment any more");return c<a?c:r+fi(s,null,n)}function rp(e,t,n,o=j0){if(!Number.isInteger(n)||n<0)throw new Et(`n must be a non-negative integer, got ${n}`);if(n===0)return[];if(n===1)return[ro(e,t,o)];let a=e??null,r=t??null;if(r===null){let l=ro(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=ro(l,r,o),c.push(l);return c}if(a===null){let l=ro(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=ro(a,l,o),c.push(l);return c.reverse(),c}let s=Math.floor(n/2),i=ro(a,r,o);return[...rp(a,i,s,o),i,...rp(i,r,n-s-1,o)]}var On=ln("default"),KH=()=>({id:On,name:"Default",visible:!0,locked:!1,order:ro(null,null)}),un=Object.freeze({elements:new Map,links:new Map,layers:new Map([[On,KH()]]),annotations:new Map,files:new Map,viewport:QA}),ov=()=>({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 Z0=(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)}},Ae=e=>{let t=null;for(let n of e)(t===null||n>t)&&(t=n);return ro(t,null)},hc=e=>{let t=null;for(let n of e)(t===null||n<t)&&(t=n);return ro(null,t)},mc=(e,t)=>ro(e,t),av=(e,t,n)=>rp(e,t,n);var rv={pan:"browser",zoom:"browser",rotation:"browser",size:"ephemeral",gridEnabled:"export",gridStyle:"export",snapToGrid:"export"},JC=Object.keys(rv),use=JC.filter(e=>rv[e]==="ephemeral"),$H=(e,...t)=>{let n=e;for(let o of t)if(o)for(let a of JC)o[a]!==void 0&&(n={...n,[a]:o[a]});return n},sv=(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:$H(un.viewport,n?.viewport,t?.viewport)}};var iv=(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 yc=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(yc).reverse()}}},Yo=e=>{let t=[];for(let n of e)n.kind==="batch"?t.push(...n.patches):t.push(n);return{kind:"batch",patches:t}},Kr=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(Kr)}};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:J(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:J(e,o),patch:o}},$=(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 pi=(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}},hi=(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}},Ye=(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}},lv=(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}},cv=(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}},sp=(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}},uv=(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}},dv=(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}},Va=(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 $r=(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 eI=new Map,fv=(e,t)=>{eI.set(e,t)},pv=e=>{let t=eI.get(e.type);if(t){let n=t(e).trim();if(n)return n}return tI(e.type)},tI=e=>e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).replace(/[-_]/g," ");fv("text",e=>{let t=e.text.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,77)}\u2026`:t});fv("template",e=>{let t=e.metadata?.label;return typeof t=="string"&&t.trim()?t.trim():tI(e.templateId)});var nI=new Map,hv=e=>{nI.set(e.kind,e)};var X0=e=>nI.get(e);var ip=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}}},Y0=(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(Tt);let r=a.map(ip),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=$(u,d.id,y=>({...y,position:m}));u=x.scene,c.push(x.patch)}),c.length===0?null:Yo(c)},K0=(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(Tt);let r=[],s=e,i={x:o.x,y:o.y};for(let l of a){let{width:c,height:u}=ip(l);if(l.position.x!==i.x||l.position.y!==i.y){let d=i,f=$(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:Yo(r)},oI=(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}},aI=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(a)}return n.sort(Tt),n.map(o=>{let a=ip(o);return{id:o.id,w:a.width,h:a.height}})},rI=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=aI(e,t.shapeIds),{placements:r}=oI(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=$(i,l.id,d=>({...d,position:{x:l.x,y:l.y}}));i=u.scene,s.push(u.patch)}return s.length===0?null:Yo(s)},$0=(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=aI(e,o),r=I(e,t),s=(r?Dn(r):null)?.gap??16,i=oI(a,s,n,{x:0,y:0});return{widest:i.widest,contentWidth:i.contentWidth,contentHeight:i.contentHeight}},Dn=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=X0(n.kind);if(o){let a=o.parse(t);if(a!==null)return{...a,kind:n.kind}}}return null},lp=(e,t)=>{let n=I(e,t);if(!n)return null;let o=Dn(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=no(n),s=r?{x:r.x,y:r.y}:n.position;if(o.kind==="grid")return Y0(e,{shapeIds:a,origin:s,cols:o.cols,...o.gap!==void 0?{gap:o.gap}:{}});if(o.kind==="stack")return K0(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 rI(e,{shapeIds:a,origin:s,innerWidth:c,...o.gap!==void 0?{gap:o.gap}:{}})}if(o.kind==="tree")return sI(e,{shapeIds:a,origin:s,...o.ranksep!==void 0?{ranksep:o.ranksep}:{},...o.nodesep!==void 0?{nodesep:o.nodesep}:{}});let i=o,l=X0(i.kind);return l?l.run(e,t,a,s,i):null},sI=(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(Tt),x},s=new Map,i=new Map,l=m=>ip(m).width,c=m=>ip(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 C=0,w=0;for(let M=0;M<_.length;M++){let B=u(v(_[M]).id);C+=B.w,M>0&&(C+=o),B.h>w&&(w=B.h)}let L=Math.max(b,C),k=A+n+w;return s.set(m,L),i.set(m,k),{w:L,h:k}};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),C={x:x+(b.w-A)/2,y};if(g.position.x!==C.x||g.position.y!==C.y){let M=$(f,m,B=>({...B,position:C}));f=M.scene,d.push(M.patch)}let w=r(m);if(w.length===0)return;let L=x,k=y+_+n;for(let M of w)p(M.id,L,k),L+=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:Yo(d)};var JH=20,Q0=.5,eU=1e5,yv=(e,t,n,o={})=>{if(tU(e,t))return[e];let a=o.margin??JH,r=n.map(L=>nU(L,a)),s=o.startHeading,i=o.endHeading,l=new Set([e.x,t.x]),c=new Set([e.y,t.y]);for(let L of r)l.add(L.x),l.add(L.x+L.width),c.add(L.y),c.add(L.y+L.height);let u=[...l].sort((L,k)=>L-k),d=[...c].sort((L,k)=>L-k),f=(L,k)=>`${L},${k}`,p=L=>v(u[L]),h=L=>v(d[L]),m=u.indexOf(e.x),x=d.indexOf(e.y),y=u.indexOf(t.x),g=d.indexOf(t.y),b=(L,k)=>Math.abs(p(L)-p(y))+Math.abs(h(k)-h(g)),A=f(m,x),_=[{key:A,skey:`${A},0`,xi:m,yi:x,axis:0,g:0,f:b(m,x)}],C=new Map,w=new Map([[`${A},0`,0]]);for(;_.length>0;){_.sort((k,M)=>k.f-M.f||k.g-M.g||(k.skey<M.skey?-1:1));let L=v(_.shift());if(L.xi===y&&L.yi===g)return rU(C,L.skey,p,h);for(let k of oU(L.xi,L.yi,u.length,d.length)){let M={x:p(L.xi),y:h(L.yi)},B={x:p(k.xi),y:h(k.yi)};if(aU(M,B,r))continue;let G=Math.sign(B.x-M.x),ie=Math.sign(B.y-M.y);if(L.axis===0&&s&&G===-Math.sign(s.x)&&ie===-Math.sign(s.y)||k.xi===y&&k.yi===g&&i&&G===Math.sign(i.x)&&ie===Math.sign(i.y))continue;let ne=k.xi!==L.xi?1:2,V=Math.abs(M.x-B.x)+Math.abs(M.y-B.y),ve=L.axis!==0&&L.axis!==ne?eU:0,ge=L.g+V+ve,ee=f(k.xi,k.yi),Se=`${ee},${ne}`,Oe=w.get(Se);Oe!==void 0&&ge>=Oe||(w.set(Se,ge),C.set(Se,L.skey),_.push({key:ee,skey:Se,xi:k.xi,yi:k.yi,axis:ne,g:ge,f:ge+b(k.xi,k.yi)}))}}return null},tU=(e,t)=>e.x===t.x&&e.y===t.y,nU=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),oU=(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},aU=(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<=Q0||l-o<=Q0||s-i.y<=Q0||c-r<=Q0))return!0}return!1},rU=(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 sU(a)},sU=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 up=(e,t)=>{let n=oo(e,t.from),o=oo(e,t.to);if(!n||!o)return[];let a=t.from.kind==="floating"?oo(e,t.from,o)??n:n,r=t.to.kind==="floating"?oo(e,t.to,n)??o:o;if(a.x===r.x&&a.y===r.y)return[];let s=dI(e,t.from,a,r),i=dI(e,t.to,r,a),l=t.avoidObstacles===!0?iU(e,t):void 0,c=l&&l.length<=150?l:void 0,u=pI(a,r,s,i,t.routedPoints,c);return u=uU(u,t.fixedSegments),u},iU=(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(N(a));return o},gv=(e,t,n,o,a)=>{if(n.x===a.x&&n.y===a.y)return[n,a];let r=uI(e,t,n,a),s=uI(e,o,a,n);return[n,...pI(n,a,r,s),a]},pI=(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=yv(i,l,h,{startHeading:n.heading,endHeading:o.heading}),x=m&&m.length>=2?m:[i,fI(i,l,n.heading),l];return cp(x)}let u=lU(e,t,n,o,i,l);if(u&&!cI(u,c))return cp(u);let d=cU(e,t,n,o,i,l,c,a);if(d&&!cI(d,c))return cp(d);let f=yv(i,l,c,{startHeading:n.heading,endHeading:o.heading}),p=f&&f.length>=2?f:[i,fI(i,l,n.heading),l];return cp(p)},lU=(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},iI=(e,t,n,o,a)=>{let r=e<=t;return a!==null&&Math.abs(e-t)<24?a?n:o:r?n:o},cU=(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=iI(p,(c+d)/2,c,d,lI(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=iI(p,(l+u)/2,l,u,lI(i,"x"));return[a,{x:h,y:a.y},{x:h,y:r.y},r]}return null},lI=(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},cI=(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},uI=(e,t,n,o)=>{if(!t)return{heading:Qf(o,n),obstacle:null};let a=I(e,t);return a?{heading:OC(a,n),obstacle:N(a)}:{heading:Qf(o,n),obstacle:null}},uU=(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 cp(n)},dU=e=>{switch(e){case"top":return $f;case"bottom":return Yf;case"left":return Kf;case"right":return dc;default:return null}},dI=(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=N(a);if(t.kind==="anchor"&&t.anchor.kind==="named"){let s=dU(t.anchor.name);if(s)return{heading:s,obstacle:r}}return{heading:U0(a,n),obstacle:r}},fI=(e,t,n)=>RC(n)?{x:t.x,y:e.y}:{x:e.x,y:t.y},cp=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 mi="orthogonal",dp="triangle";var xv=Math.PI/12,Ko=11,hI=6,mI=4,yI=12,J0=9,bv=4,gI="#1a73e8",xI="#fff",fp=3.5,$o=5,bI=8,AI=1.5,vI=gI,Av=xI,SI=xI,vv=gI,wo=20,LI=0,kI="#ffffff",ey=6,ty=7,_I=18,Sv=40,gc=.16,pp=.7,Lv="#e8118c",wI="#f59e0b",hp="#2563eb",kv="#16a34a",TI="#06b6d4",EI="#a855f7",CI="#eab308",II="#dc2626",MI="#14b8a6",RI="#f43f5e",OI=16,_v=14,wv=6,Tv=3,Ev=11,DI=1.5,PI=[4,3],BI=3;var Cv=1,Iv=1.6,Mv=10,NI=1,zI=.05,FI=32,HI=.5,UI=500,xc=8,bc=300,Ac=8,GI=.6,WI=.2,qI=.85,ny=.4,VI=22,jI=22,ZI=18,XI=16,YI=16,KI=9,oy=12,$I="#f9a825",QI="#fff",JI="#888",e4=10,Rv=2e3,Ov=.5,t4=.5,Dv=12,ay=6,n4=2,o4="#222222",a4=1,r4=4,s4=.5,Pv=.3,i4=32,l4=.55,c4=.7,ry=.7,Bv=1.5,u4=2048,d4=0,f4=.1,Nv=ay*3,p4=6,sy="#888888",h4=1.5,iy=120,m4=.25,y4=.5,g4=10,x4=1,ly=1400,b4="#ff2d2d",zv=4,A4=8,Fv=480,v4=480,S4=270,L4=1e3/60,k4=1e3/12,_4=2,w4=2*1024*1024,T4=3e4,E4=24,C4="system-ui, sans-serif",I4="#1a1a1a",M4=1e3,R4=1,O4=10,D4=530,P4="#1a73e8",B4=.25,N4=1.5,cy=4,Hv=1.1,To=80,z4=8,uy=.5,F4=256,H4=30,U4=16,Uv=4,G4=4,W4="rgba(0,0,0,0.65)",q4=16,V4="#1a73e8",j4="#fff",mp=10,Z4=11,X4=.12,Y4=14,K4=3,$4=8;var yi=["nw","n","ne","e","se","s","sw","w"],gi=["nw","ne","se","sw"],Q4=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 xi=(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}}},Gv=(e,t,n,o=11,a=yi)=>{let r=o/n;for(let f of a){if(f.length!==2)continue;let p=xi(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},vc=(e,t)=>e.rotation===0?t:W.rotateAround(t,e.pivot,e.rotation),pU=(e,t)=>e.rotation===0?t:W.rotateAround(t,e.pivot,-e.rotation),bi=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}},gp=e=>{let t=e.bounds;return[vc(e,{x:t.x,y:t.y}),vc(e,{x:t.x+t.width,y:t.y}),vc(e,{x:t.x+t.width,y:t.y+t.height}),vc(e,{x:t.x,y:t.y+t.height})]},J4=e=>vc(e,{x:e.bounds.x+e.bounds.width/2,y:e.bounds.y+e.bounds.height/2}),e5=(e,t,n=1)=>vc(t,xi(e,t.bounds,n)),t5=(e,t,n,o=11,a=yi)=>Gv(pU(t,e),t.bounds,n,o,a),hU={kind:"ratio",position:{x:0,y:1}},mU=new Map;var yU=e=>mU.get(e)??hU,dy=(e,t=1)=>{let n=yU(e.type),o=Yt(e,n),a=Xo(e,n),r=26/t;return{x:o.x+a.x*r,y:o.y+a.y*r}},fy=(e,t=1)=>{let n=26/t*Math.SQRT1_2;return{x:e.x-n,y:e.y+e.height+n}},Wv=(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 gU(){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 xU(){let e=gU();if(e.__xstate__)return e.__xstate__}var n5=e=>{if(typeof window>"u")return;let t=xU();t&&t.register(e)};var py=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}},$v=".",bU="",Qv="",AU="#",vU="*",l5="xstate.init",c5="xstate.error",jv="xstate.stop";function SU(e,t){return{type:`xstate.after.${e}.${t}`}}function Zv(e,t){return{type:`xstate.done.state.${e}`,output:t}}function LU(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function Jv(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function my(e){return{type:l5,input:e}}function Qo(e){setTimeout(()=>{throw e})}var kU=typeof Symbol=="function"&&Symbol.observable||"@@observable";function e2(e,t){let n=o5(e),o=o5(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?e2(n[a],o[a]):!1)}function yy(e){if(f5(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 o5(e){if(R5(e))return e.value;if(typeof e!="string")return e;let t=yy(e);return u5(t)}function u5(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 t2(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 d5(e){return f5(e)?e:[e]}function Jo(e){return e===void 0?[]:d5(e)}function Xv(e,t,n,o){return typeof e=="function"?e({context:t,event:n,self:o}):e}function f5(e){return Array.isArray(e)}function _U(e){return e.type.startsWith("xstate.error.actor")}function Ai(e){return d5(e).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function p5(e){if(!(e===void 0||e===bU))return Jo(e)}function xp(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 n2(e,t){return`${t}.${e}`}function Ap(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 h5(e,t){if(t===e||t===vU)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 a5(e,t){return`${e.sessionId}.${t}`}var wU=0;function TU(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=a5(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=a5(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:${wU++}`,_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=xp(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 qv=!1,gy=1,Kt=(function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e})({}),EU={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},hy=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 py(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={...EU,...n},{clock:a,logger:r,parent:s,syncSnapshot:i,id:l,systemId:c,inspect:u}=o;this.system=s?s.system:TU(this,{clock:a,logger:r}),u&&!s&&this.system.inspect(xp(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){Qo(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=qv;try{qv=!0,d.exec(d.info,d.params)}finally{qv=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){Qo(r)}break;case"done":for(let a of this.observers)try{a.next?.(t)}catch(r){Qo(r)}this._stopProcedure(),this._complete(),this._doneEvent=LU(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=xp(t,n,o);if(this._processingStatus!==Kt.Stopped)this.observers.add(a);else switch(this._snapshot.status){case"done":try{a.complete?.()}catch(r){Qo(r)}break;case"error":{let r=this._snapshot.error;if(!a.error)Qo(r);else try{a.error(r)}catch(s){Qo(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=xp(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=my(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===jv&&(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:jv}),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){Qo(n)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||Qo(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){Qo(r)}}this.observers.clear(),this.eventListeners.clear(),n&&Qo(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,Jv(this.id,t))}_stopProcedure(){return this._processingStatus!==Kt.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new py(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:n5)(this)}toJSON(){return{xstate$$type:gy,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[kU](){return this}getSnapshot(){return this._snapshot}};function ea(e,...[t]){return new hy(e,t)}function CU(e,t,n,o,{sendId:a}){let r=typeof a=="function"?a(n,o):a;return[t,{sendId:r},void 0]}function IU(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function _c(e){function t(n,o){}return t.type="xstate.cancel",t.sendId=e,t.resolve=CU,t.execute=IU,t}function MU(e,t,n,o,{id:a,systemId:r,src:s,input:i,syncSnapshot:l}){let c=typeof s=="string"?Ap(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=ea(c,{id:u,src:s,parent:e.self,syncSnapshot:l,systemId:r,input:f})),[Jr(t,{children:{...t.children,[u]:d}}),{id:a,systemId:r,actorRef:d,src:s,input:f},void 0]}function RU(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==Kt.Stopped&&t.start()})}function wc(...[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=MU,r.execute=RU,r}function OU(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]),[Jr(t,{children:i}),s,void 0]}function m5(e,t){let n=t.getSnapshot();if(n&&"children"in n)for(let o of Object.values(n.children))m5(e,o);e.system._unregister(t)}function DU(e,t){if(t){if(m5(e,t),t._processingStatus!==Kt.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Li(e){function t(n,o){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=OU,t.execute=DU,t}function PU(e,{context:t,event:n},{guards:o}){return o.every(a=>ki(a,t,n,e))}function y5(e){function t(n,o){return!1}return t.check=PU,t.guards=e,t}function ki(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 ki(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 xy(e){return e.type==="atomic"||e.type==="final"}function Lc(e){return Object.values(e.states).filter(t=>t.type!=="history")}function Tc(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 vp(e){let t=new Set(e),n=x5(t);for(let o of t)if(o.type==="compound"&&(!n.get(o)||!n.get(o).length))r5(o).forEach(a=>t.add(a));else if(o.type==="parallel"){for(let a of Lc(o))if(a.type!=="history"&&!t.has(a)){let r=r5(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 g5(e,t){let n=t.get(e);if(!n)return{};if(e.type==="compound"){let a=n[0];if(a){if(xy(a))return a.key}else return{}}let o={};for(let a of n)o[a.key]=g5(a,t);return o}function x5(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 b5(e,t){let n=vp(t);return g5(e,x5(n))}function by(e,t){return t.type==="compound"?Lc(t).some(n=>n.type==="final"&&e.has(n)):t.type==="parallel"?Lc(t).every(n=>by(e,n)):t.type==="final"}var Sp=e=>e[0]===AU;function A5(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(o=>h5(t,o)).sort((o,a)=>a.length-o.length).flatMap(o=>e.transitions.get(o))}function v5(e){let t=e.config.after;if(!t)return[];let n=a=>{let r=SU(a,e.id),s=r.type;return e.entry.push(Cc(r,{id:s,delay:a})),e.exit.push(_c(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 Jo(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=p5(n.target),a=n.reenter??!1,r=BU(e,o),s={...n,actions:Jo(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 S5(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===Qv)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let o=e.config.on[n];t.set(n,Ai(o).map(a=>ja(e,n,a)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,Ai(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,Ai(n.onDone).map(a=>ja(e,o,a)))}if(n.onError){let o=`xstate.error.actor.${n.id}`;t.set(o,Ai(n.onError).map(a=>ja(e,o,a)))}if(n.onSnapshot){let o=`xstate.snapshot.${n.id}`;t.set(o,Ai(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 L5(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?y5([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 k5(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"?[]:Jo(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...o,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return o}function BU(e,t){if(t!==void 0)return t.map(n=>{if(typeof n!="string")return n;if(Sp(n))return e.machine.getStateNodeById(n);let o=n[0]===$v;if(o&&!e.parent)return bp(e,n.slice(1));let a=o?e.key+n:n;if(e.parent)try{return bp(e.parent,a)}catch(r){throw new Error(`Invalid transition definition for state node '${e.id}':
|
|
12
|
-
${r.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function _5(e){let t=p5(e.config.target);return t?{target:t.map(n=>typeof n=="string"?bp(e.parent,n):n)}:e.parent.initial}function vi(e){return e.type==="history"}function r5(e){let t=w5(e);for(let n of t)for(let o of Tc(n,e))t.add(o);return t}function w5(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 Lc(o))n(a)}}return n(e),t}function kc(e,t){if(Sp(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 bp(e,t){if(typeof t=="string"&&Sp(t))try{return e.machine.getStateNodeById(t)}catch{}let n=yy(t).slice(),o=e;for(;n.length;){let a=n.shift();if(!a.length)break;o=kc(o,a)}return o}function Ec(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=>kc(e,a)).filter(Boolean);return[e.machine.root,e].concat(o,n.reduce((a,r)=>{let s=kc(e,r);if(!s)return a;let i=Ec(s,t[r]);return a.concat(i)},[]))}function NU(e,t,n,o){let r=kc(e,t).next(n,o);return!r||!r.length?e.next(n,o):r}function zU(e,t,n,o){let a=Object.keys(t),r=kc(e,a[0]),s=Ay(r,t[a[0]],n,o);return!s||!s.length?e.next(n,o):s}function FU(e,t,n,o){let a=[];for(let r of Object.keys(t)){let s=t[r];if(!s)continue;let i=kc(e,r),l=Ay(i,s,n,o);l&&a.push(...l)}return a.length?a:e.next(n,o)}function Ay(e,t,n,o){return typeof t=="string"?NU(e,t,n,o):Object.keys(t).length===1?zU(e,t,n,o):FU(e,t,n,o)}function HU(e){return Object.keys(e.states).map(t=>e.states[t]).filter(t=>t.type==="history")}function Qr(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function UU(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 T5(e,t,n){let o=new Set;for(let a of e){let r=!1,s=new Set;for(let i of o)if(UU(Yv([a],t,n),Yv([i],t,n)))if(Qr(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 GU(e){let[t,...n]=e;for(let o of Tc(t,void 0))if(n.every(a=>Qr(a,o)))return o}function o2(e,t){if(!e.target)return[];let n=new Set;for(let o of e.target)if(vi(o))if(t[o.id])for(let a of t[o.id])n.add(a);else for(let a of o2(_5(o),t))n.add(a);else n.add(o);return[...n]}function E5(e,t){let n=o2(e,t);if(!n)return;if(!e.reenter&&n.every(a=>a===e.source||Qr(a,e.source)))return e.source;let o=GU(n.concat(e.source));if(o)return o;if(!e.reenter)return e.source.machine.root}function Yv(e,t,n){let o=new Set;for(let a of e)if(a.target?.length){let r=E5(a,n);a.reenter&&a.source===r&&o.add(r);for(let s of t)Qr(s,r)&&o.add(s)}return[...o]}function WU(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function a2(e,t,n,o,a){return Kv([{target:[...w5(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,o,!0,a)}function Kv(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=T5(e,l,c),d=t;a||([d,c]=ZU(d,o,n,u,l,c,r,n.actionExecutor)),d=Si(d,o,n,u.flatMap(p=>p.actions),r,void 0),d=VU(d,o,n,u,l,r,c,a);let f=[...l];d.status==="done"&&(d=Si(d,o,n,f.sort((p,h)=>h.order-p.order).flatMap(p=>p.exit),r,void 0));try{return c===t.historyValue&&WU(t._nodes,l)?[d,s]:[Jr(d,{_nodes:f,historyValue:c}),s]}catch(p){throw p}}finally{n.actionExecutor=i}}function qU(e,t,n,o,a){if(o.output===void 0)return;let r=Zv(a.id,a.output!==void 0&&a.parent?Xv(a.output,e.context,t,n.self):void 0);return Xv(o.output,e.context,r,n.self)}function VU(e,t,n,o,a,r,s,i){let l=e,c=new Set,u=new Set;jU(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(wc(h.src,{...h,syncSnapshot:!!h.onSnapshot}));if(u.has(f)){let h=f.initial.actions;p.push(...h)}if(l=Si(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(Zv(h.id,f.output!==void 0?Xv(f.output,l.context,t,n.self):void 0));m?.type==="parallel"&&!d.has(m)&&by(a,m);)d.add(m),r.push(Zv(m.id)),x=m,m=m.parent;if(m)continue;l=Jr(l,{status:"done",output:qU(l,t,n,l.machine.root,x)})}}return l}function jU(e,t,n,o){for(let a of e){let r=E5(a,t);for(let i of a.target||[])!vi(i)&&(a.source!==i||a.source!==r||a.reenter)&&(o.add(i),n.add(i)),Sc(i,t,n,o);let s=o2(a,t);for(let i of s){let l=Tc(i,r);r?.type==="parallel"&&l.push(r),C5(o,t,n,l,!a.source.parent&&a.reenter?void 0:r)}}}function Sc(e,t,n,o){if(vi(e))if(t[e.id]){let a=t[e.id];for(let r of a)o.add(r),Sc(r,t,n,o);for(let r of a)Vv(r,e.parent,o,t,n)}else{let a=_5(e);for(let r of a.target)o.add(r),a===e.parent?.initial&&n.add(e.parent),Sc(r,t,n,o);for(let r of a.target)Vv(r,e.parent,o,t,n)}else if(e.type==="compound"){let[a]=e.initial.target;vi(a)||(o.add(a),n.add(a)),Sc(a,t,n,o),Vv(a,e,o,t,n)}else if(e.type==="parallel")for(let a of Lc(e).filter(r=>!vi(r)))[...o].some(r=>Qr(r,a))||(vi(a)||(o.add(a),n.add(a)),Sc(a,t,n,o))}function C5(e,t,n,o,a){for(let r of o)if((!a||Qr(r,a))&&e.add(r),r.type==="parallel")for(let s of Lc(r).filter(i=>!vi(i)))[...e].some(i=>Qr(i,s))||(e.add(s),Sc(s,t,n,e))}function Vv(e,t,n,o,a){C5(n,o,a,Tc(e,t))}function ZU(e,t,n,o,a,r,s,i){let l=e,c=Yv(o,a,r);c.sort((d,f)=>f.order-d.order);let u;for(let d of c)for(let f of HU(d)){let p;f.history==="deep"?p=h=>xy(h)&&Qr(h,d):p=h=>h.parent===d,u??={...r},u[f.id]=Array.from(a).filter(p)}for(let d of c)l=Si(l,t,n,[...d.exit,...d.invoke.map(f=>Li(f.id))],s,void 0),a.delete(d);return[l,u||r]}function XU(e,t){return e.implementations.actions[t]}function I5(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:XU(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=I5(i,t,n,x,a,r))}return i}function Si(e,t,n,o,a,r){let s=r?[]:void 0,i=I5(e,t,n,o,{internalQueue:a,deferredActorIds:r},s);return s?.forEach(([l,c])=>{l.retryResolve(n,i,c)}),i}function Lp(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===jv)return a=Jr(s5(a,t,n),{status:"stopped"}),s([a,[]],t,[]),{snapshot:a,microsteps:r};let i=t;if(i.type!==l5){let d=i,f=_U(d),p=i5(d,a);if(f&&!p.length)return a=Jr(e,{status:"error",error:d.error}),s([a,[]],d,[]),{snapshot:a,microsteps:r};let h=Kv(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?YU(a,i):[],f=d.length?a:void 0;if(!d.length){if(!o.length)break;i=o.shift(),d=i5(i,a)}let p=Kv(d,a,n,i,!1,o);a=p[0],l=a!==f,s(p,i,d)}return a.status!=="active"&&s5(a,i,n),{snapshot:a,microsteps:r}}function s5(e,t,n){return Si(e,t,n,Object.values(e.children).map(o=>Li(o)),[],void 0)}function i5(e,t){return t.machine.getTransitionData(t,e)}function YU(e,t){let n=new Set,o=e._nodes.filter(xy);for(let a of o)e:for(let r of[a].concat(Tc(a,void 0)))if(r.always){for(let s of r.always)if(s.guard===void 0||ki(s.guard,e.context,t,e)){n.add(s);break e}}return T5(Array.from(n),new Set(e._nodes),e.historyValue)}function M5(e,t){let n=vp(Ec(e,t));return b5(e,[...n])}function R5(e){return!!e&&typeof e=="object"&&"machine"in e&&"value"in e}var KU=function(t){return e2(t,this.value)},$U=function(t){return this.tags.has(t)},QU=function(t){let n=this.machine.getTransitionData(this,t);return!!n?.length&&n.some(o=>o.target!==void 0||o.actions.length)},JU=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)}},eG=function(){return this._nodes.reduce((t,n)=>(n.meta!==void 0&&(t[n.id]=n.meta),t),{})};function kp(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:b5(t.root,e._nodes),tags:new Set(e._nodes.flatMap(n=>n.tags)),children:e.children,historyValue:e.historyValue||{},matches:KU,hasTag:$U,can:QU,getMeta:eG,toJSON:JU}}function Jr(e,t={}){return kp({...e,...t},e.machine)}function tG(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 O5(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:D5(s),children:p,historyValue:tG(f.historyValue)}}function D5(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:gy,id:o.id};else{let a=D5(o);a!==o&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=a)}}return t??e}function nG(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 oG(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 Cc(e,t){function n(o,a){}return n.type="xstate.raise",n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=nG,n.execute=oG,n}function P5(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 Kie=P5(e=>{},void 0);function aG(e,{machine:t,context:n},o,a){let r=(s,i)=>{if(typeof s=="string"){let l=Ap(t,s);if(!l)throw new Error(`Actor logic '${s}' not implemented in machine '${t.id}'`);let c=ea(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 ea(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 rG(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:aG(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[Jr(t,{context:l,children:Object.keys(r).length?{...t.children,...r}:t.children}),void 0,void 0]}function Pn(e){function t(n,o){}return t.type="xstate.assign",t.assignment=e,t.resolve=rG,t}var B5=new WeakMap;function Ic(e,t,n){let o=B5.get(e);return o?t in o||(o[t]=n()):(o={[t]:n()},B5.set(e,o)),o[t]}var sG={},_p=e=>typeof e=="string"?{type:e}:typeof e=="function"?"resolve"in e?{type:e.type}:{type:e.name}:e,vy=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($v),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?t2(this.config.states,(o,a)=>new e(o,{_parent:this,_key:a,_machine:this.machine})):sG,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=Jo(this.config.entry).slice(),this.exit=Jo(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=Jo(t.tags).slice()}_initialize(){this.transitions=S5(this),this.config.always&&(this.always=Ai(this.config.always).map(t=>ja(this,Qv,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(_p),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(_p),eventType:null})}:void 0,history:this.history,states:t2(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(_p)})),entry:this.entry.map(_p),exit:this.exit.map(_p),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 Ic(this,"invoke",()=>Jo(this.config.invoke).map((t,n)=>{let{src:o,systemId:a}=t,r=t.id??n2(this.id,n),s=typeof o=="string"?o:`xstate.invoke.${n2(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 Ic(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 Ic(this,"delayedTransitions",()=>v5(this))}get initial(){return Ic(this,"initial",()=>k5(this,this.config.initial))}next(t,n){let o=n.type,a=[],r,s=Ic(this,`candidates-${o}`,()=>A5(this,o));for(let i of s){let{guard:l}=i,c=t.context,u=!1;try{u=!l||ki(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}':
|
|
13
|
-
${d.message}`)}if(u){a.push(...i.actions),r=i;break}}return r?[r]:void 0}get events(){return Ic(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)}},iG="#",Sy=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 vy(t,{_key:this.id,_machine:this}),this.root._initialize(),L5(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=M5(this.root,t.value),o=vp(Ec(this.root,n));return kp({_nodes:[...o],context:t.context||{},children:{},status:by(o,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,n,o){return Lp(t,n,o,[]).snapshot}microstep(t,n,o){return Lp(t,n,o,[]).microsteps.map(([a])=>a)}getTransitionData(t,n){return Ay(this.root,t.value,t,n)||[]}_getPreInitialState(t,n,o){let{context:a}=this.config,r=kp({context:typeof a!="function"&&a?a:{},_nodes:[this.root],children:{},status:"active"},this);return typeof a=="function"?Si(r,n,t,[Pn(({spawn:i,event:l,self:c})=>a({spawn:i,input:l.input,self:c}))],o,void 0):r}getInitialSnapshot(t,n){let o=my(n),a=[],r=this._getPreInitialState(t,o,a),[s]=a2(this.root,r,t,o,a),{snapshot:i}=Lp(s,o,t,a);return i}start(t){Object.values(t.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(t){let n=yy(t),o=n.slice(1),a=Sp(n[0])?n[0].slice(iG.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 bp(r,o)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,n){return O5(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"?Ap(this,h):h;if(!m)return;let x=ea(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 vy)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=kp({...t,children:o,_nodes:Array.from(vp(Ec(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===gy){d[p]=f[h.id];continue}u(h,f)}}}}return u(l.context,o),l}};function lG(e,t,n,o,{event:a}){let r=typeof a=="function"?a(n,o):a;return[t,{event:r},void 0]}function cG(e,{event:t}){e.defer(()=>e.emit(t))}function ky(e){function t(n,o){}return t.type="xstate.emit",t.event=e,t.resolve=lG,t.execute=cG,t}var Ly=(function(e){return e.Parent="#_parent",e.Internal="#_internal",e})({});function uG(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===Ly.Parent?p=e.self._parent:f===Ly.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 dG(e,t,n){typeof n.to=="string"&&(n.to=t.children[n.to])}function fG(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===c5?Jv(e.self.id,o.data):o)})}function wp(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=uG,o.retryResolve=dG,o.execute=fG,o}function N5(e,t){return wp(Ly.Parent,e,t)}function pG(e,t,n,o,{collect:a}){let r=[],s=function(l){r.push(l)};return s.assign=(...i)=>{r.push(Pn(...i))},s.cancel=(...i)=>{r.push(_c(...i))},s.raise=(...i)=>{r.push(Cc(...i))},s.sendTo=(...i)=>{r.push(wp(...i))},s.sendParent=(...i)=>{r.push(N5(...i))},s.spawnChild=(...i)=>{r.push(wc(...i))},s.stopChild=(...i)=>{r.push(Li(...i))},s.emit=(...i)=>{r.push(ky(...i))},a({context:n.context,event:n.event,enqueue:s,check:i=>ki(i,t.context,n.event,t),self:e.self,system:e.system},o),[t,void 0,r]}function Ct(e){function t(n,o){}return t.type="xstate.enqueueActions",t.collect=e,t.resolve=pG,t}function hG(e,t,n,o,{value:a,label:r}){return[t,{value:typeof a=="function"?a(n,o):a,label:r},void 0]}function mG({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function r2(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=hG,n.execute=mG,n}function yG(e,t){return new Sy(e,t)}function s2({schemas:e,actors:t,actions:n,guards:o,delays:a}){return{assign:Pn,sendTo:wp,raise:Cc,log:r2,cancel:_c,stopChild:Li,enqueueActions:Ct,emit:ky,spawnChild:wc,createStateConfig:r=>r,createAction:r=>r,createMachine:r=>yG({...r,schemas:e},{actors:t,actions:n,guards:o,delays:a}),extend:r=>s2({schemas:e,actors:t,actions:{...n,...r.actions},guards:{...o,...r.guards},delays:{...a,...r.delays}})}}var gG=()=>({mode:I0,pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null}),_i=4,ta=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o>=_i*_i},Tp=(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)}},z5=s2({types:{context:{},events:{},emitted:{}},actions:{startPress:Pn((e,t)=>({pressOrigin:t.point,pressLast:t.point,pressTarget:t.target,pressModifiers:t.modifiers})),updateLast:Pn((e,t)=>({pressLast:t.point})),setDrawingType:Pn((e,t)=>({drawingType:t.kind})),resetGesture:Pn(()=>({pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null})),setMode:Pn((e,t)=>({mode:t.mode})),emitMoveElement:Ct(({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:Ct(({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:Ct(({context:e,enqueue:t})=>{e.pressTarget?.kind==="annotation"&&t.emit({type:"COMMIT_ANNOTATION_DRAG",id:e.pressTarget.id})}),emitResizeElement:Ct(({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:Ct(({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:Ct(({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:Ct(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin||!e.drawingType)return;let o=Tp(e.pressOrigin,t.point);o.width<1||o.height<1||n.emit({type:"CREATE_SHAPE",shapeType:e.drawingType,bounds:o})}),emitLinkPreview:Ct(({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:Ct(({enqueue:e})=>{e.emit({type:"DRAW_EDGE_PREVIEW_CLEAR"})}),emitLinkEndpointPreview:Ct(({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:Ct(({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:Ct(({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:Tp(e.pressOrigin,t.point),mode:a?"add":"replace"})}),emitLassoCommit:Ct(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin)return;let o=Tp(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:Ct(({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<_i*_i||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:ta(e.pressOrigin,t.point),movedAndOnHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="handle"?!1:ta(e.pressOrigin,t.point),movedAndOnGroupHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="group-handle"?!1:ta(e.pressOrigin,t.point),movedAndOnRotateHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="rotate-handle"?!1:ta(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:ta(e.pressOrigin,t.point),movedAndDrawingLink:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="draw-edge"?!1:ta(e.pressOrigin,t.point),movedAndOnLinkEndpoint:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="edge-endpoint"?!1:ta(e.pressOrigin,t.point),movedAndOnAnnotation:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="annotation"||e.mode!=="select"?!1:ta(e.pressOrigin,t.point),movedAndLasso:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="select"||e.pressTarget?.kind!=="empty"?!1:ta(e.pressOrigin,t.point)}}).createMachine({id:"interaction",initial:"idle",context:gG(),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"}]}}}}}),F5=(e,t)=>{if(!e.pressOrigin||!e.pressTarget||ta(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 H5=new Map,so=(e,t)=>{H5.set(e,t)},es=e=>H5.get(e);var wi=["background","main","overlay"];var U5=(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 ts=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}},xG=new ts,Mc=(e,t)=>e.getOrCompute(t,N);var i2={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 _y={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 l2={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 Ti={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 c2={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 u2={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 d2={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 Rc={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 Ei={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 f2={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 Za={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 p2={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 Oc={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 Dc={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 ns=["tomato","amber","grass","cyan","iris","plum","gray"],Ep=(e,t)=>{let n=e[t];if(n===void 0)throw new Error(`Missing color token: ${t}`);return n},fn=(e,t)=>({fill:Ep(e,`${t}4`),solid:Ep(e,`${t}9`),solidHover:Ep(e,`${t}10`),textLow:Ep(e,`${t}11`),textHigh:Ep(e,`${t}12`)}),Pc={light:{tomato:fn(Ei,"tomato"),amber:fn(Dc,"amber"),grass:fn(Oc,"grass"),cyan:fn(p2,"cyan"),iris:fn(Za,"iris"),plum:fn(f2,"plum"),gray:fn(Rc,"gray")},dark:{tomato:fn(_y,"tomato"),amber:fn(d2,"amber"),grass:fn(u2,"grass"),cyan:fn(c2,"cyan"),iris:fn(Ti,"iris"),plum:fn(l2,"plum"),gray:fn(i2,"gray")}},wy={light:{tomato:Ei.tomato2,amber:Dc.amber2,grass:Oc.grass2,cyan:p2.cyan2,iris:Za.iris2,plum:f2.plum2,gray:Rc.gray2},dark:{tomato:_y.tomato2,amber:d2.amber2,grass:u2.grass2,cyan:c2.cyan2,iris:Ti.iris2,plum:l2.plum2,gray:i2.gray2}};var bG={light:{accent:Za.iris9,accentHover:Za.iris10,selectedBg:Za.iris4,selectedFg:Za.iris11,danger:Ei.tomato9},dark:{accent:Ti.iris9,accentHover:Ti.iris10,selectedBg:Ti.iris4,selectedFg:Ti.iris11,danger:_y.tomato9}},h2=Rc.gray6,m2=Rc.gray9,os={rectangle:{fill:Za.iris3,stroke:Za.iris9,strokeWidth:2},ellipse:{fill:Ei.tomato3,stroke:Ei.tomato9,strokeWidth:2},flowchart:{fill:Oc.grass3,stroke:Oc.grass9,strokeWidth:2},sticky:{fill:Dc.amber3,stroke:Dc.amber9,strokeWidth:1}},Bc={stroke:Rc.gray12,strokeWidth:1.5},AG={added:Oc.grass9,removed:Ei.tomato9,modified:Dc.amber9};var y2={placeholder:.15,hideText:.4},g2="#bbb";var x2=.06,b2=.92,A2=.5,Nc=10,v2=h2,S2=m2,L2=1,k2=1,_2=4,w2=4,T2=3,E2=12,C2=56,I2=10,M2=20,G5=.4,W5=.5,R2=.1,O2=.9,q5="#888",V5="#ffffff",j5="#222",Z5="#ddd",X5=18,Y5=12,K5="#444",$5="#222",Q5=10,D2="#000",J5="#222",eM="#fff",tM=4;var Cp=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 Ty=e=>e<=0?1:2**Math.round(Math.log2(e));var Xa=(e,t,n={})=>{let o=ao(e.viewport),a=n.dirtyWorld;if(!n.skipClear)if(a){let C=[z.applyToPoint(o,{x:a.x,y:a.y}),z.applyToPoint(o,{x:a.x+a.width,y:a.y+a.height})],w=j.expand(j.fromPoints(C),2);t.clear(w)}else t.clear();t.save(),t.setTransform(o);let r=n.boundsCache??new ts,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??g2,m=n.layerCompositeCache,x=n.dirtyLayerIds,y=n.compositeLayerBitmap,g=Ty(l),b=C=>{let w=null;for(let L of Ga(e,C)){let k=Mc(r,L);w=w?j.union(w,k):k}return w},A=n.dimOpacity,_=n.dimElements!==void 0&&A!==void 0?U5(t,A):null;for(let C of Lo(e))if(C.visible){if(m&&y){x?.has(C.id)&&m.invalidateLayer(C.id);let w=m.get(C.id,g);if(w===void 0){let L=y(C.id,g,e);L!==null&&(m.set(C.id,g,L),w=L)}if(w!==void 0){let L=b(C.id);L&&t.drawImage(w,L.x,L.y,L.width,L.height);continue}}for(let w of Ga(e,C.id)){if(n.hideElements?.has(w.id)||i&&!i.has(w.id))continue;if(s){let B=Mc(r,w);if(!j.intersects(B,s))continue}if(a){let B=Mc(r,w);if(!j.intersects(B,a))continue}if(p&&pe(w))continue;if(f){let B=Mc(r,w);t.setFill(h),t.setStrokeWidth(0),t.beginPath(),t.rect(B.x,B.y,B.width,B.height),t.fill();continue}let L=es(w.type);if(!L){n.onUnknownElement?.(w);continue}t.save();let k=_!==null&&n.dimElements?.has(w.id)===!0,M=k?_:t;k&&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),L(w,M,u),t.restore()}}t.restore()};var P2=(e,t,n)=>{let{maxWidth:o}=n,a=n.lineHeightFactor??1.2,r=[],s=n.fontFamily??"sans-serif",i=n.shaper,l=i?u=>i.measure(u,{family:s,size:n.fontSize}).width:u=>t.measureText(u).width;for(let u of e.split(`
|
|
14
|
-
`)){if(u===""){r.push({text:"",width:0});continue}let d=u.split(/\s+/).filter(m=>m.length>0);if(d.length===0){r.push({text:"",width:0});continue}let f=d[0];if(f===void 0){r.push({text:"",width:0});continue}let p=f,h=l(p);for(let m=1;m<d.length;m++){let x=d[m];if(x===void 0)continue;let y=`${p} ${x}`,g=l(y);g<=o?(p=y,h=g):(r.push({text:p,width:h}),p=x,h=l(x))}r.push({text:p,width:h})}let c=n.fontSize*a;return{lines:r,lineHeight:c}};var
|
|
15
|
-
`){let c=e.slice(r,l);n.maxWidth===void 0?a.push({text:c,start:r,end:l,width:t(c)}):
|
|
16
|
-
`))i=[{text:e.text,x:0,width:t.measureText(e.text).width,top:0}];else{let c=d=>t.measureText(d).width,u=zc(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*x2);for(let u of i)u.width<=0||(l.underline&&(t.beginPath(),t.rect(u.x,u.top+s*b2,u.width,c),t.fill()),l.strikethrough&&(t.beginPath(),t.rect(u.x,u.top+s*A2-c/2,u.width,c),t.fill()))}},CG=(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=Hf(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=np(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()}},IG=(e,t,n)=>{let o=n?.clock?.(e),a=e.animationKind?Ci(e,o):e.metadata?.image??Ci(e,o),r=e.metadata?.animated===!0||e.animationKind!==void 0;t.drawImage(a,0,0,e.width,e.height,r,e.crop)},Fc=()=>{so("rectangle",LG),so("ellipse",kG),so("polygon",_G),so("path",wG),so("text",EG),so("image",IG),so("group",()=>{}),so("frame",DG),jA("frame",()=>({top:24})),so("block-arrow",MG),so("brush",CG)},MG=(e,t)=>{let{fill:n,stroke:o}=Rp(e.style,t),a=e.direction??"right",r=Math.max(R2,Math.min(O2,e.headRatio??G5)),s=Math.max(R2,Math.min(O2,e.bodyThickness??W5)),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])=>RG([m,x],a,i,l)));let h=p.map(([m,x])=>({x:m,y:x}));if(n&&(t.beginPath(),Cy(t,h),t.fill()),o){let m=Iy(e.style),x=m!==0?Nf.offsetClosedPath(h,m):h;t.beginPath(),Cy(t,x),t.stroke()}},RG=([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)]}},q2="\u2026",OG=(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)+q2).width<=t?o=r:a=r-1}return o>0?e.slice(0,o)+q2:q2},DG=(e,t,n)=>{t.setFill(e.style.fill??V5),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(q5),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:OG(a,r,t),l=s?Math.min(t.measureText(a).width+16,e.width):e.width;t.setFill(j5),t.beginPath(),t.rect(0,-24,l,24),t.fill(),t.setFill(Z5),t.setTextBaseline("middle"),t.setTextAlign("left"),t.fillText(i,8,-24/2)};var My=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,as(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}},as=(e,t)=>{let n=_o(e,t);if(!n||n.length===0)return null;let o=1/0,a=1/0,r=-1/0,s=-1/0;for(let m of n)m.x<o&&(o=m.x),m.y<a&&(a=m.y),m.x>r&&(r=m.x),m.y>s&&(s=m.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)),u=o-c,d=a-c,f=r+c,p=s+c,h=Zf(n,t);return h&&(u=Math.min(u,h.x),d=Math.min(d,h.y),f=Math.max(f,h.x+h.width),p=Math.max(p,h.y+h.height)),{x:u,y:d,width:f-u,height:p-d}},j2=new My;var Bn=(e,t,n={})=>{t.save(),t.setTransform(ao(e.viewport));let o=n.edgeBoundsCache??j2,a=n.viewportWorld,r=n.dirtyWorld,s=n.edgeBitmapCache,i=n.rasteriseLink,l=Ty(n.zoom??e.viewport.zoom);for(let c of Lo(e))if(c.visible)for(let u of EA(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&&!j.intersects(d,a)||r&&!j.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}}PG(e,u,t,n)}t.restore()},PG=(e,t,n,o)=>{let a=ut(e,t);if(!a||a.length<2){o.onMissingEndpoint?.(t);return}let r=(t.routing??"straight")==="bezier"?Jf(e,t):null,s=r?jf(r.start,r.segments):a;if(n.save(),(t.lineKind??"line")==="block-arrow")BG(t,a,n);else{if(FG(t,n),n.beginPath(),r){n.moveTo(r.start.x,r.start.y);for(let i of r.segments)n.bezierCurveTo(i.c1.x,i.c1.y,i.c2.x,i.c2.y,i.to.x,i.to.y)}else if(a.length>=3&&Nc>0)Ry(n,a,Nc);else{let i=v(a[0]);n.moveTo(i.x,i.y);for(let l=1;l<a.length;l++){let c=v(a[l]);n.lineTo(c.x,c.y)}}n.stroke(),t.arrowheads&&HG(s,t.arrowheads,n,t.style.stroke??D2)}t.label&&UG(s,t,n),n.restore()},BG=(e,t,n)=>{let o=e.blockArrow?.headLength??X5,a=e.blockArrow?.bodyThickness??Y5,r=e.style.fill??e.style.stroke??K5,s=e.style.stroke??$5,i=e.style.strokeWidth??1;e.style.opacity!==void 0&&n.setOpacity(e.style.opacity);let l=NG(t,o);if(l.length<2)return;let c=rM(l,a/2),u=rM(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=sM(d,p,m),y=sM(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()},NG=(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},rM=(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},sM=(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}},zG=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},Ry=(e,t,n)=>{let o=zG(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)},FG=(e,t)=>{let n=e.style.stroke??D2;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)},HG=(e,t,n,o)=>{let a=t.size??Q5;if(t.from&&t.from!=="none"){let r=e[0],s=e[1];r!==void 0&&s!==void 0&&iM(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&&iM(r,s,t.to,a,n,o)}},iM=(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(...Eo(m(o,p))),a.lineTo(...Eo(m(o,-p))),a.closePath(),a.stroke();break}case"filledArrow":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...Eo(m(o,p))),a.lineTo(...Eo(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(...Eo(m(o,p))),a.lineTo(...Eo(h(o*2))),a.lineTo(...Eo(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(...Eo(m(0,p))),a.moveTo(w.x,w.y),a.lineTo(...Eo(m(0,-p))),a.stroke()}let _=y?o*1.15:o*.55,C=w=>{a.beginPath(),a.moveTo(...Eo(m(w,p))),a.lineTo(...Eo(m(w,-p))),a.stroke()};if(A&&C(_),b&&C(_+o*.4),g){let w=p*.6,L=h(o*(y?1.6:1)+w);a.beginPath(),a.ellipse(L.x,L.y,w,w),a.stroke()}break}}},Eo=e=>[e.x,e.y],UG=(e,t,n)=>{let o=t.label;if(!o||o.text==="")return;let a=o.fontSize??12,r=o.fill??J5,s=o.background??eM,i=uc(e,t);n.setFont("system-ui, sans-serif",a);let{lines:l,lineHeight:c}=P2(o.text,n,{maxWidth:160,fontSize:a,lineHeightFactor:1.25}),u=0;for(let h of l)u=Math.max(u,h.width);let d=u+12,f=l.length*c+6;n.beginPath(),n.setFill(s),n.setStroke(null),Ey(n,i.x-d/2,i.y-f/2,d,f,Math.min(tM,f/2)),n.fill(),n.setFill(r),n.setTextAlign("center"),n.setTextBaseline("middle");let p=i.y-(l.length-1)*c/2;for(let h=0;h<l.length;h++){let m=l[h];m===void 0||m.text===""||n.fillText(m.text,i.x,p+h*c)}};var lM=(e,t,n,o,a=w2,r=T2)=>{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},Op=(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?S2:v2),i=e.viewport.zoom,{width:l,height:c}=t.size;if(l<=0||c<=0)return;let u=VG(e,l,c);if(!u)return;let d=f=>{r?WG(t,u,f,s,i):GG(t,u,f,s,i)};if(t.save(),t.setTransform(ao(e.viewport)),t.setDashArray(null),n.levels)for(let f of n.levels){let p=qG(i,f);if(p<=0)continue;let h=f.step*o;h*i<_2||(t.setOpacity(p),d(h))}else{let f=r?I2:E2,p=r?M2:C2;for(let h of lM(o,i,f,p))t.setOpacity(h.opacity),d(h.step)}t.setOpacity(1),t.restore()},GG=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=cM(t,n),c=L2/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()},WG=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=cM(t,n);e.setStroke(null),e.setFill(o);let c=k2/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()},cM=(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}),qG=(e,t)=>e>=t.mid?1:e<=t.min?0:(e-t.min)/(t.mid-t.min),VG=(e,t,n)=>{let o=qa(e.viewport),a=[z.applyToPoint(o,{x:0,y:0}),z.applyToPoint(o,{x:t,y:0}),z.applyToPoint(o,{x:t,y:n}),z.applyToPoint(o,{x:0,y:n})],r=j.fromPoints(a);return Number.isFinite(r.x)?r:null};var uM=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()},Dp=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 uM(e,t),{instance:a}=await WebAssembly.instantiate(o,{});return a},rs=(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 dM=null,Pp=e=>{dM=e},Z2=()=>dM;var fM=null,Bp=e=>{fM=e},Oy=()=>fM;var Dy={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 Py=(e,t,n)=>{if(e.length<3)return e;let o=Vf(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 By=(e,t)=>({points:[{x:e.x,y:e.y,t}]}),X2=(e,t,n)=>{e.points.push({x:t.x,y:t.y,t:n})},Y2=(e,t,n=ly)=>{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}},pM=(e,t=A4)=>Py(e,t,(n,o,a,r)=>({x:a.x,y:a.y,t:n.t+(o.t-n.t)*r}));var Ii=e=>e.type==="rectangle"||e.type==="ellipse"||e.type==="image"||e.type==="template"||e.type==="frame",jG=new Set(["rectangle","ellipse","template","text","frame"]),Mi=e=>jG.has(e.type),K2=e=>yi;var Co=(e,t)=>{let n=ko(e),a=[...H0(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=Xo(e,i);return{x:l.x+c.x*t,y:l.y+c.y*t}});return{names:a,worldPoints:r}};var yM=(e,t)=>{let n=t.scene.viewport.zoom,o=t.hitAnnotation(e);if(o!==null){let s=t.scene.annotations.get(o);if(s)return{kind:"annotation",id:o,origin:$r(t.scene,s)}}if(t.selectionChromeActive){let s=ZG(e,t,n);if(s)return s}let a=t.acceleratedElementAt(e);if(a&&t.isElementInteractable(a)){let s=t.promoteToGroupRoot(a);return{kind:"element",id:s.id,bounds:N(s)}}let r=VA(t.scene,e,t.edgeHitThreshold/n);return r&&!t.isLayerLocked(r.layerId)?{kind:"link",id:r.id}:{kind:"empty"}},ZG=(e,t,n)=>{let o=t.selection.size+t.selectedLinkCount>1||t.selectionIsAspectLocked();if(o){let r=t.combinedSelectionBounds();if(r){let i=t.selectionIsAspectLocked()?gi:yi,l=Gv(e,r,n,t.handleHitSlop,i);if(l)return{kind:"group-handle",handle:l,bounds:r}}}if(t.selection.size===1)for(let r of t.selection){let s=I(t.scene,r);if(!s||!Mi(s)||s.locked===!0)continue;let i=bi(s),l=t5(e,i,n,t.handleHitSlop,K2(s));if(l)return{kind:"handle",elementId:r,handle:l,bounds:i.bounds}}let a=o?t.combinedSelectionBounds():null;if(a){let r=fy(a,n);if(Wv(e,r,n,t.handleHitSlop))return{kind:"rotate-handle",pivot:{x:a.x+a.width/2,y:a.y+a.height/2},bounds:a}}else if(t.selection.size===1)for(let r of t.selection){let s=I(t.scene,r);if(!s||!Mi(s)||s.locked===!0)continue;let i=dy(s,n);if(Wv(e,i,n,t.handleHitSlop)){let l=bi(s);return{kind:"rotate-handle",pivot:J4(l),bounds:l.bounds}}}if(t.selectedLink){let r=ue(t.scene,t.selectedLink);if(r){let s=ut(t.scene,r);if(s&&s.length>=2){let i=t.edgeHandleHitSlop/n,l=v(s[0]),c=v(s[s.length-1]);if(W.distance(e,l)<=i)return{kind:"edge-endpoint",linkId:r.id,side:"from"};if(W.distance(e,c)<=i)return{kind:"edge-endpoint",linkId:r.id,side:"to"}}}}return null},Np=(e,t,n,o,a,r)=>{e.setStroke(null),e.setFill(r),e.setOpacity(gc),e.beginPath(),e.rect(t,n,o,a),e.fill(),e.setFill(null),e.setStroke(r),e.setStrokeWidth(1),e.setOpacity(pp),e.beginPath(),e.rect(t,n,o,a),e.stroke()},Ri=(e,t,n,o,a)=>{e.setStroke(null),e.setFill(a),e.setOpacity(gc),e.beginPath(),e.ellipse(t,n,o,o),e.fill(),e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setOpacity(pp),e.beginPath(),e.ellipse(t,n,o,o),e.stroke()},XG=(e,t,n,o,a)=>{e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setDashArray([2,2]),e.setOpacity(pp),e.beginPath(),e.ellipse(t,n,o,o),e.stroke(),e.setDashArray(null)},hM=(e,t,n)=>{if(t.length<3)return;e.setStroke(null),e.setFill(n),e.setOpacity(gc),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(pp),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()},mM=(e,t,n,o,a,r)=>{let s=z.applyToPoint(t,{x:n.x,y:n.y}),i=z.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=z.applyToPoint(t,xi(p,n,o));Np(e,h.x-f,h.y-f,f*2,f*2,r);break}case"n":Np(e,l-f,c-f,u+f*2,f*2,r);break;case"s":Np(e,l-f,c+d-f,u+f*2,f*2,r);break;case"w":Np(e,l-f,c-f,f*2,d+f*2,r);break;case"e":Np(e,l+u-f,c-f,f*2,d+f*2,r);break}},Ny=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}},gM=(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&&Mi(p)&&p.locked!==!0&&mM(e,o,N(p),a,K2(p),Lv)}if(s.linkBodies)for(let f of n.links.values()){let p=ut(n,f);if(!p||p.length<2)continue;e.setFill(null),e.setStroke(wI),e.setStrokeWidth(J0*2),e.setOpacity(gc),e.setLineCap("round"),e.setLineJoin("round"),e.beginPath();let h=z.applyToPoint(o,v(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=z.applyToPoint(o,v(p[m]));e.lineTo(x.x,x.y)}e.stroke()}if(s.selectedEdgeHandles&&i){let f=z.applyToPoint(o,i.from),p=z.applyToPoint(o,i.to);Ri(e,f.x,f.y,Ko,hp),Ri(e,p.x,p.y,Ko,hp);for(let h of i.waypoints??[]){let m=z.applyToPoint(o,h);Ri(e,m.x,m.y,Ko,hp)}for(let h of i.midpoints??[]){let m=z.applyToPoint(o,h);Ri(e,m.x,m.y,Ko,hp)}}if(s.anchorDots&&r.size===1){let f=v([...r][0]),p=I(n,f);if(p){let h=$o+ey,{worldPoints:m}=Co(p,wo/a);for(let x of m){let y=z.applyToPoint(o,x);Ri(e,y.x,y.y,h,kv),XG(e,y.x,y.y,ty,kv)}}}if(s.attachDropZones&&l){let f=l.thresholdWorld*a;for(let p of l.outlineLoops)hM(e,p.map(h=>z.applyToPoint(o,h)),CI);e.setFill(null),e.setStroke(EI),e.setStrokeWidth(f*2),e.setOpacity(gc),e.setLineCap("round"),e.setLineJoin("round");for(let p of l.outlineLoops){if(p.length<2)continue;e.beginPath();let h=z.applyToPoint(o,v(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=z.applyToPoint(o,v(p[m]));e.lineTo(x.x,x.y)}e.closePath(),e.stroke()}for(let p of l.anchors){let h=z.applyToPoint(o,p);Ri(e,h.x,h.y,f,TI)}}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=>z.applyToPoint(o,x));hM(e,m,h)};for(let p of c.frames)f(p,II);for(let p of c.containers)f(p,MI)}if(s.groupHandles&&u&&mM(e,o,u,a,d?gi:yi,Lv),s.annotationPins)for(let f of n.annotations.values()){let p=z.applyToPoint(o,$r(n,f));Ri(e,p.x,p.y,oy,RI)}e.setOpacity(1),e.restore()};var AM=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=ze(o)?AM(e,o.id):N(o);a&&(n=n?j.union(n,a):a)}return n},vM={selectionStroke:"#1a73e8",selectionStrokeWidth:1,handleFill:"#fff",handleStroke:"#1a73e8",drawingStroke:"#1a73e8",drawingDash:[4,4]},SM=.32,LM=(e,t,n,o,a=vM)=>{if(n.length===0)return;let s=bv/(o||1);e.setTransform(t),e.setStroke(a.selectionStroke),e.setOpacity(SM),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(z.IDENTITY)},kM=(e,t,n,o={})=>{let a={...vM,...o.style};n.clear();let r=ao(e.viewport),s=e.viewport.zoom;n.save(),n.setTransform(z.IDENTITY);let i={scene:e,selection:t,target:n,options:o,style:a,w2s:r,zoom:s};$G(i),QG(i),JG(i),eW(i),tW(i),nW(i),oW(i),rW(i),sW(i),iW(i),lW(i),cW(i),uW(i),dW(i),n.restore()},$G=e=>{let{scene:t,selection:n,target:o,options:a,w2s:r,zoom:s}=e;a.debugHitZones&&gM(o,{scene:t,w2s:r,zoom:s,selection:n,visibility:a.debugHitZoneVisibility??Ny({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}:{}})},QG=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=AM(t,c);if(!f)continue;let p=na(f,s);if(Q2(o,p,r),u.locked===!0){bM(o,p);continue}if(l||!Mi(u)||a.readOnly===!0||a.suppressHandles===!0)continue;for(let h of gi){let m=xi(h,f,i);J2(o,z.applyToPoint(s,m),r)}wM(o,f,i,s,r);continue}let d=bi(u);if(d.rotation===0?Q2(o,na(d.bounds,s),r):pW(o,d,s,r),u.locked===!0){bM(o,hW(d,s));continue}if(!(l||!Mi(u)||a.readOnly===!0||a.suppressHandles===!0)){for(let f of gi){let p=e5(f,d,i);J2(o,z.applyToPoint(s,p),r)}_M(o,z.applyToPoint(s,dy(u,i)),r)}}},JG=e=>{let{target:t,options:n,style:o,w2s:a}=e;if(n.cropGhost&&xW(t,n.cropGhost,a),n.cropFrame&&n.cropFrame.length>=4){let r=n.cropFrame.map(s=>z.applyToPoint(a,s));yW(t,r,o),gW(t,r,o)}if(n.drawingPreview){let r=na(n.drawingPreview,a);mW(t,r,o)}if(n.drawingPreviewElement){let r=n.drawingPreviewElement,s=es(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(qI),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=es(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(uy),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=es(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.ghostElement||n.ghostElementShape){t.setOpacity(ny);let r=n.ghostElementShape,s=r?es(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=na(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=na(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()}},eW=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=z.applyToPoint(a,v(i.worldPoints[l])),u=i.activeIndex===l;bW(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(SM),t.setDashArray(null),t.setLineJoin("round"),t.setLineCap("round");let s=bv/(r||1);for(let{path:i,width:l}of n.selectedLinkPaths)i.length<2||(t.setStrokeWidth(l+2*s),t.beginPath(),Ry(t,i,Nc),t.stroke());t.setOpacity(1),t.setLineJoin("miter"),t.setLineCap("butt"),t.setTransform(z.IDENTITY)}if(n.edgeSelection&&n.readOnly!==!0&&n.suppressHandles!==!0){let s=z.applyToPoint(a,n.edgeSelection.from),i=z.applyToPoint(a,n.edgeSelection.to);for(let l of n.edgeSelection.midpoints??[])AW(t,z.applyToPoint(a,l),o);$2(t,s,o),$2(t,i,o);for(let l of n.edgeSelection.waypoints??[])$2(t,z.applyToPoint(a,l),o)}},tW=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=na(r,o);vW(t,s,a.color)}},nW=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=np(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()}},oW=e=>{let{target:t,options:n,w2s:o}=e;xM(t,o,n.laserStrokes,b4,zv,ly);let a=(n.eraserCursor?.radius??zv/2)*2;xM(t,o,n.eraserTrail,sy,a,iy)},xM=(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=pM(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=>z.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=aW(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)},aW=(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]},rW=e=>{let{target:t,options:n,w2s:o}=e,a=n.eraserCursor;if(!a||a.radius<=0)return;let r=z.applyToPoint(o,a.center);t.setDashArray(null),t.setOpacity(1),t.beginPath(),t.ellipse(r.x,r.y,a.radius,a.radius),t.setFill(sy),t.fill(),t.setFill(null),t.setStroke(sy),t.setStrokeWidth(h4),t.stroke()},sW=e=>{let{target:t,options:n,w2s:o}=e;if(n.containerDropZone){let a=na(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)}},iW=e=>{let{target:t,options:n,style:o,w2s:a,zoom:r}=e;if(!n.cropFrame&&n.groupBounds){let s=na(n.groupBounds,a);if(Q2(t,s,o),n.readOnly===!0||n.suppressHandles===!0)return;let i=gi;for(let l of i){let c=xi(l,n.groupBounds,r),u=z.applyToPoint(a,c);J2(t,u,o)}wM(t,n.groupBounds,r,a,o)}},lW=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=$r(t,r),i=z.applyToPoint(a,s);LW(n,i,r,o.selectedAnnotation??null)}},cW=e=>{let{target:t,options:n,w2s:o}=e;if(n.peerCursors)for(let a of n.peerCursors){let r=z.applyToPoint(o,a.position);SW(t,r,a.color,a.name)}},uW=e=>{let{target:t,options:n,w2s:o}=e;if(n.gifBadges)for(let a of n.gifBadges)fW(t,na(a,o))},dW=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(P4),t.setOpacity(B4);for(let s of r.selectionRects){let i=na(s,o);t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.fill()}t.setOpacity(1)}if(r.caret){let s=z.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,N4,r.caret.height*a),t.fill()}}},bM=(e,t)=>{let n=q4,o=t.x+t.width-n-2,a=t.y+2,r=V4;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(j4),e.beginPath(),e.ellipse(o+n/2,a+n*.64,n*.07,n*.07),e.fill()},fW=(e,t)=>{let n=t.x+Uv,o=t.y+Uv,a=H4,r=U4,s=G4;e.setStroke(null),e.setFill(W4),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)},na=(e,t)=>{let n=z.applyToPoint(t,{x:e.x,y:e.y}),o=z.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)}},Q2=(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()},pW=(e,t,n,o)=>{let[a,r,s,i]=gp(t),l=z.applyToPoint(n,a),c=z.applyToPoint(n,r),u=z.applyToPoint(n,s),d=z.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()},hW=(e,t)=>{let n=gp(e).map(i=>z.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}},zy=(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)},J2=(e,t,n)=>{zy(e,t,5,{fill:n.handleFill,stroke:n.handleStroke,strokeWidth:1})},_M=(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")},wM=(e,t,n,o,a)=>{let r=fy(t,n);_M(e,z.applyToPoint(o,r),a)},mW=(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()},yW=(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)},gW=(e,t,n)=>{if(t.length<4)return;e.setStroke(n.selectionStroke),e.setStrokeWidth(K4),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")},xW=(e,t,n)=>{let o=t.element,a=o.animationKind!==void 0?Ci(o,void 0):o.metadata?.image??Ci(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(X4),e.drawImage(a,s.x,s.y,s.width,s.height,r),e.setOpacity(1),e.restore()},bW=(e,t,n,o="link-start",a)=>{let r=n?a??$o:fp,s=o==="link-start";zy(e,t,r,{fill:n?s?Av:vv:s?vI:SI,stroke:s?Av:vv,strokeWidth:AI})},$2=(e,t,n)=>{zy(e,t,hI,{fill:n.handleFill,stroke:n.selectionStroke,strokeWidth:2})},AW=(e,t,n)=>{zy(e,t,mI,{fill:n.handleFill,stroke:n.selectionStroke,strokeWidth:1.5,opacity:.55})},vW=(e,t,n)=>{let o=BI;e.setStroke(n),e.setStrokeWidth(DI),e.setDashArray(PI),e.beginPath(),e.rect(t.x-o,t.y-o,t.width+2*o,t.height+2*o),e.stroke()},SW=(e,t,n,o)=>{let a=OI;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",Ev),e.setTextBaseline("top"),e.setTextAlign("left");let r=e.measureText(o).width,s=t.x+_v,i=t.y+_v,l=r+2*wv,c=Ev+2*Tv;e.setFill(n),e.setStrokeWidth(0),e.beginPath(),e.rect(s,i,l,c),e.fill(),e.setFill("#fff"),e.fillText(o,s+wv,i+Tv)},LW=(e,t,n,o)=>{let a=KI,r=n.resolved?JI:$I,s=n.id===o;if(e.setFill(r),e.setStroke(s?"#1a73e8":QI),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",e4),e.setTextAlign("center"),e.setTextBaseline("middle"),e.setFill("#fff"),e.fillText(l,t.x,t.y)}};var Hc=(e,t)=>{let n=t.getBoundingClientRect();return{kind:_W(e.pointerType),phase:wW(e.type),point:{x:e.clientX-n.left,y:e.clientY-n.top},buttons:e.buttons,modifiers:kW(e),pointerId:e.pointerId,timestamp:e.timeStamp}};var oa=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable},kW=e=>({shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey}),_W=e=>e==="pen"?"pen":e==="touch"?"touch":"mouse",wW=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 eS=()=>typeof navigator<"u"?navigator.userAgent:"",zp=()=>typeof navigator<"u"&&navigator.platform||"",ss=/Mac|iPod|iPhone|iPad/.test(zp()),TW=zp().startsWith("Win"),TM=/\b(android)\b/i.test(eS()),EW=/iPad|iPhone/i.test(zp())||typeof navigator<"u"&&/Mac/i.test(zp())&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1,CW=/Linux/i.test(zp())&&!TM,IW=/Firefox/i.test(eS()),MW=/^((?!chrome|android).)*safari/i.test(eS());var RW={Enter:"\u23CE",Backspace:"\u232B",Delete:"\u2326",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"\u21E5"," ":"Space"},OW={Enter:"Enter",Backspace:"Backspace",Delete:"Del",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"Tab"," ":"Space"},Fy=e=>{let t=[];ss?(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=ss?RW:OW,o=e.key??e.code??"",a=n[o]??(o.length===1?o.toUpperCase():o);return t.push(a),t},dt=e=>{let t=Fy(e);return ss?t.join(""):t.join("+")};var EM={id:"undo",label:"Undo",category:"history",hotkey:{key:"z",meta:!0},iconId:"undo",predicate:({editor:e})=>e.canUndo,perform:({editor:e})=>e.undo()},CM={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()},tS=[EM,CM];var yt=e=>e.editor.selection.size>0,nS=e=>e.editor.selection.size>0||e.editor.selectedLinks.size>0;var IM={id:"select-all",label:"Select all",category:"selection",viewMode:!0,hotkey:{key:"a",meta:!0},perform:({editor:e})=>{e.selectAll()}},MM={id:"delete-selection",label:"Delete",category:"selection",hotkey:[{key:"Delete"},{key:"Backspace"}],predicate:nS,perform:({editor:e})=>{e.deleteSelected()}},RM={id:"duplicate-selection",label:"Duplicate",category:"selection",hotkey:{key:"d",meta:!0},predicate:yt,perform:({editor:e})=>{e.duplicateSelected()}},OM={id:"toggle-lock",label:"Lock / Unlock",category:"selection",hotkey:{key:"l",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.toggleLockSelection()}},DM={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()}},PM={id:"exit-container",label:"Exit container",category:"selection",hotkey:{key:"ArrowUp",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.exitContainer()}},oS=[IM,MM,RM,OM,DM,PM];var BM={id:"copy",label:"Copy",category:"clipboard",viewMode:!0,hotkey:{key:"c",meta:!0},predicate:yt,perform:({editor:e})=>{e.copySelected()}},NM={id:"cut",label:"Cut",category:"clipboard",hotkey:{key:"x",meta:!0},predicate:yt,perform:({editor:e})=>{e.cutSelected()}},zM={id:"paste",label:"Paste",category:"clipboard",hotkey:{key:"v",meta:!0},perform:({editor:e})=>{e.paste()}},FM={id:"copy-style",label:"Copy style",category:"clipboard",viewMode:!0,hotkey:{key:"c",meta:!0,alt:!0},predicate:yt,perform:({editor:e})=>{e.copySelectionStyle()}},HM={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()}},aS=[BM,NM,zM,FM,HM];var UM={id:"bring-to-front",label:"Bring to front",category:"z-order",hotkey:{key:"]",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.bringToFront()}},GM={id:"send-to-back",label:"Send to back",category:"z-order",hotkey:{key:"[",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.sendToBack()}},WM={id:"bring-forward",label:"Bring forward",category:"z-order",hotkey:{key:"]",meta:!0},predicate:yt,perform:({editor:e})=>{e.bringForward()}},qM={id:"send-backward",label:"Send backward",category:"z-order",hotkey:{key:"[",meta:!0},predicate:yt,perform:({editor:e})=>{e.sendBackward()}},rS=[UM,WM,qM,GM];var VM={id:"group-selection",label:"Group",category:"grouping",hotkey:{key:"g",meta:!0},predicate:e=>e.editor.selection.size>=2,perform:({editor:e})=>{e.groupSelected()}},jM={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()}},sS=[VM,jM];var ZM={id:"zoom-in",label:"Zoom in",category:"zoom",viewMode:!0,hotkey:[{key:"=",meta:!0},{key:"+",meta:!0},{key:"+"},{key:"="}],perform:({editor:e})=>{e.zoomIn()}},XM={id:"zoom-out",label:"Zoom out",category:"zoom",viewMode:!0,hotkey:[{key:"-",meta:!0},{key:"_",meta:!0},{key:"-"},{key:"_"}],perform:({editor:e})=>{e.zoomOut()}},YM={id:"zoom-reset",label:"Reset zoom",category:"zoom",viewMode:!0,hotkey:{key:"0",meta:!0},perform:({editor:e})=>{e.resetZoom()}},KM={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()}},$M={id:"zoom-to-selection",label:"Zoom to selection",category:"zoom",viewMode:!0,hotkey:{key:"2",alt:!0},predicate:yt,perform:({editor:e})=>{e.zoomToSelection()}},iS=[ZM,XM,YM,KM,$M];var QM={id:"mode-select",label:"Select tool",category:"tool",viewMode:!0,hotkey:{key:"v"},iconId:"mode-select",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="select",perform:({editor:e})=>{e.setActiveTool("select")}},JM={id:"mode-hand",label:"Hand tool",category:"tool",viewMode:!0,hotkey:{key:"h"},iconId:"mode-hand",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="hand",perform:({editor:e})=>{e.setActiveTool("hand")}},e9={id:"mode-rect",label:"Rectangle tool",category:"tool",hotkey:{key:"r"},iconId:"mode-rect",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-rect",perform:({editor:e})=>{e.setActiveTool("draw-rect")}},t9={id:"mode-ellipse",label:"Ellipse tool",category:"tool",hotkey:{key:"o"},iconId:"mode-ellipse",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-ellipse",perform:({editor:e})=>{e.setActiveTool("draw-ellipse")}},n9={id:"mode-text",label:"Text tool",category:"tool",hotkey:{key:"t"},iconId:"mode-text",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-text",perform:({editor:e})=>{e.setActiveTool("draw-text")}},o9={id:"mode-edge",label:"Link tool",category:"tool",hotkey:{key:"l"},iconId:"mode-edge",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-edge",perform:({editor:e})=>{e.setActiveTool("draw-edge")}},a9={id:"mode-brush",label:"Brush tool",category:"tool",hotkey:{key:"b"},iconId:"mode-brush",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="brush",perform:({editor:e})=>{e.setActiveTool("brush")}},r9={id:"mode-erase",label:"Eraser tool",category:"tool",hotkey:{key:"e"},iconId:"mode-erase",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="erase",perform:({editor:e})=>{e.setActiveTool("erase")}},s9={id:"mode-laser",label:"Laser pointer",category:"tool",viewMode:!0,hotkey:{key:"k"},iconId:"mode-laser",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="laser",perform:({editor:e})=>{e.setActiveTool("laser")}},i9={id:"mode-frame",label:"Frame tool",category:"tool",hotkey:{key:"f"},iconId:"mode-frame",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-frame",perform:({editor:e})=>{e.setActiveTool("draw-frame")}},l9={id:"toggle-tool-lock",label:"Toggle tool lock",category:"tool",iconId:"tool-lock",uiKind:"toggle",checked:({editor:e})=>e.activeTool.locked,perform:({editor:e})=>{e.setToolLocked(!e.activeTool.locked)}},DW={id:"commit-image-crop",label:"Apply crop",category:"edit",hotkey:{key:"Enter"},predicate:({editor:e})=>e.activeTool.type==="crop",perform:({editor:e})=>{e.commitImageCrop()}},PW={id:"cancel-image-crop",label:"Cancel crop",category:"edit",viewMode:!0,hotkey:{key:"Escape"},predicate:({editor:e})=>e.activeTool.type==="crop",perform:({editor:e})=>{e.cancelImageCrop()}},c9={id:"cancel",label:"Cancel / clear selection",category:"edit",viewMode:!0,hotkey:{key:"Escape"},perform:({editor:e})=>{e.cancelInteraction()}},lS=[QM,JM,e9,t9,n9,o9,a9,r9,s9,i9,l9,DW,PW,c9];var BW={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?O4:R4;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}}},NW={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}}},zW={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}}},FW={id:"focus-next",label:"Focus next element",category:"selection",hotkey:{key:"Tab"},perform:({editor:e})=>{e.focusCycle("next")}},HW={id:"focus-prev",label:"Focus previous element",category:"selection",hotkey:{key:"Tab",shift:!0},perform:({editor:e})=>{e.focusCycle("prev")}},UW={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.activeTool.type==="draw-rect"||e.activeTool.type==="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.activeTool.type==="draw-rect"||e.activeTool.type==="draw-ellipse")&&e.createElementAtCursor()}},u9=[BW,NW,zW,FW,HW,UW];var GW={id:"arrange-grid",label:"Arrange as grid",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsGrid()}},WW={id:"arrange-stack-h",label:"Stack horizontally",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"horizontal"})}},qW={id:"arrange-stack-v",label:"Stack vertically",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"vertical"})}},VW={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?Dn(n)!==null:!1},perform:({editor:e})=>{let[t]=[...e.selection];t&&e.runLayout(t)}},jW={id:"compact-z-order",label:"Compact z-order",category:"z-order",perform:({editor:e})=>{e.compactLayerZOrder()}},d9=[GW,WW,qW,VW,jW];var f9={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()}},cS=[f9,p9];var Uc=e=>e.editor.selection.size>=2,h9=e=>e.editor.selection.size>=3,m9={id:"flip-horizontal",label:"Flip horizontal",category:"arrange",hotkey:{key:"h",shift:!0},iconId:"flip-horizontal",predicate:yt,perform:({editor:e})=>{e.flipSelection("horizontal")}},y9={id:"flip-vertical",label:"Flip vertical",category:"arrange",hotkey:{key:"v",shift:!0},iconId:"flip-vertical",predicate:yt,perform:({editor:e})=>{e.flipSelection("vertical")}},g9={id:"align-left",label:"Align left",category:"arrange",hotkey:{key:"ArrowLeft",meta:!0,shift:!0},iconId:"align-left",predicate:Uc,perform:({editor:e})=>{e.alignSelection("left")}},x9={id:"align-h-center",label:"Align horizontal centres",category:"arrange",iconId:"align-h-center",predicate:Uc,perform:({editor:e})=>{e.alignSelection("h-center")}},b9={id:"align-right",label:"Align right",category:"arrange",hotkey:{key:"ArrowRight",meta:!0,shift:!0},iconId:"align-right",predicate:Uc,perform:({editor:e})=>{e.alignSelection("right")}},A9={id:"align-top",label:"Align top",category:"arrange",hotkey:{key:"ArrowUp",meta:!0,shift:!0},iconId:"align-top",predicate:Uc,perform:({editor:e})=>{e.alignSelection("top")}},v9={id:"align-v-center",label:"Align vertical centres",category:"arrange",iconId:"align-v-center",predicate:Uc,perform:({editor:e})=>{e.alignSelection("v-center")}},S9={id:"align-bottom",label:"Align bottom",category:"arrange",hotkey:{key:"ArrowDown",meta:!0,shift:!0},iconId:"align-bottom",predicate:Uc,perform:({editor:e})=>{e.alignSelection("bottom")}},L9={id:"distribute-horizontal",label:"Distribute horizontally",category:"arrange",hotkey:{key:"h",alt:!0},iconId:"distribute-horizontal",predicate:h9,perform:({editor:e})=>{e.distributeSelection("horizontal")}},k9={id:"distribute-vertical",label:"Distribute vertically",category:"arrange",hotkey:{key:"v",alt:!0},iconId:"distribute-vertical",predicate:h9,perform:({editor:e})=>{e.distributeSelection("vertical")}},uS=[m9,y9,g9,x9,b9,A9,v9,S9,L9,k9];var _9=e=>{let{editor:t}=e;for(let n of t.selection){let o=I(t.scene,n);if(o!==void 0&&pe(o))return!0}return!1},w9={id:"increase-font-size",label:"Increase font size",category:"edit",hotkey:{code:"Period",meta:!0,shift:!0},predicate:_9,perform:({editor:e})=>{e.adjustSelectionFontSize("increase")}},T9={id:"decrease-font-size",label:"Decrease font size",category:"edit",hotkey:{code:"Comma",meta:!0,shift:!0},predicate:_9,perform:({editor:e})=>{e.adjustSelectionFontSize("decrease")}},dS=[w9,T9];var Fp=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||fS(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||fS(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(ZW(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<=M4),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||fS(s,n))continue;let i=s.sequence,l=this.seqBuffer.slice(-i.length);if(l.length===i.length&&l.every((c,u)=>E9(c.key,c.code,i[u]??""))&&!(s.predicate&&!s.predicate(n)))return this.seqBuffer=[],s.perform(n),!0}return!1}},fS=(e,t)=>t.editor.readOnly&&e.viewMode!==!0,ZW=(e,t)=>{if(t.key!==void 0&&!XW(e,t.key)||t.code!==void 0&&e.code!==t.code)return!1;let n=a=>a===!0,o=ss?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)},XW=(e,t)=>E9(e.key,e.code,t),E9=(e,t,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;if(YW(e))return!1;let o=KW(n);return o!==null&&t===o},YW=e=>/^[a-z]$/i.test(e),KW=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}},pS=e=>{let t=[...tS,...oS,...aS,...rS,...sS,...iS,...lS,...u9,...d9,...cS,...uS,...dS];for(let n of t)e.register(n)},we=new Fp;pS(we);var Hy=(e,t={})=>{let n=t.target??window,o=t.registry??we,a=r=>{if(!(r instanceof KeyboardEvent))return;let s=r.composedPath()[0]??r.target;if(oa(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 C9=e=>{if(pe(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},hS=(e,t)=>{let n=t.trim().toLowerCase();if(n==="")return[];let o=[];for(let a of e.elements.values()){let r=C9(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 $W=new Map;var I9=e=>$W.get(e);var mS=()=>{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 yS=()=>{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 M9=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;QW(m)||f.push(m)}return f},QW=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 Hp=class{past=[];future=[];limit;mergeTransactions;constructor(t={}){this.limit=t.limit??1/0,this.mergeTransactions=t.mergeTransactions??!0}push(t){Kr(t)||(this.past.push(t),this.future.length=0,this.trim())}undo(){let t=this.past.pop();return t?(this.future.push(t),yc(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");Kr(n)||t.push(n)},commit:()=>{if(this.current!==t||(this.current=null,t.length===0))return;let n=this.mergeTransactions?M9(t):t;if(n.length===0)return;let o=n[0],a=n.length===1&&o!==void 0?o:Yo(n);Kr(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 Up=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}},R9=["image/png","image/jpeg","image/svg+xml","image/gif","image/webp","image/bmp","image/x-icon","image/avif","image/jfif"];var gS=e=>{if(e.type.startsWith("video/"))return!0;let t=e.name.toLowerCase().split(".").pop();return t==="mp4"||t==="webm"||t==="ogv"||t==="mov"},xS=e=>{if(e.type&&R9.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 bS=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 JW=e=>e===".git"||e==="node_modules"||e==="__MACOSX"||e===".DS_Store"||e.startsWith("."),AS=async function*(e,t={}){let n=t.skipDirectory??JW,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*O9(i,"",0,n,o,t.onError))}};async function*O9(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*O9(c,s,n+1,o,a,r)}}var eq=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}),P9={id:"image",accept:e=>xS(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 bS(e),s=await eq(r),i=Fv,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=B9();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}:{}})}},D9="oh-just-another-animated-image-sink",B9=()=>{let e=document.getElementById(D9);if(e)return e;let t=document.createElement("div");return t.id=D9,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},vS=e=>{let t=document.createElement("video");return t.src=e,t.muted=!0,t.loop=!0,t.playsInline=!0,t.autoplay=!0,t.style.position="absolute",t.style.left="-99999px",t.style.top="-99999px",t.style.width="1px",t.style.height="1px",B9().appendChild(t),t},N9={id:"video",accept:e=>gS(e),handle:async(e,{editor:t,worldPoint:n})=>{if(typeof document>"u")return;let o=await t.addBinaryFile(e,e.name),a=URL.createObjectURL(e),r=vS(a);await new Promise(p=>{let h=()=>{p()};r.onloadedmetadata=h,r.onerror=h});let s=r.videoWidth||v4,i=r.videoHeight||S4,l=Fv,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};r.play().catch(()=>{}),t.insertImage({src:a,width:u,height:d,position:f,image:r,animated:!0,fileId:o})}};var Uy=64,z9=(e,t)=>{let n=null,o=t,a=0;for(;o.parentId&&a<Uy;){let r=I(e,o.parentId);if(!r)break;ze(r)&&(n=r),o=r,a++}return n},SS=(e,t,n)=>{let o=I(e,t),a=0;for(;o&&a<Uy;){if(o.id===n)return!0;if(!o.parentId)return!1;o=I(e,o.parentId),a++}return!1},F9=(e,t,n)=>{let o=t,a=0;for(;o.parentId&&a<Uy&&n!==o.parentId;){let r=I(e,o.parentId);if(!r||!ze(r))break;o=r,a++}return o},H9=(e,t,n)=>{let o=new Set,a=new Set(t);for(let r of e.elements.values())a.has(r.id)||SS(e,r.id,n)||o.add(r.id);return o},U9=(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<Uy;){let i=I(e,a.parentId);if(!i||i.id===n.id)break;ze(i)&&(r=i),a=i,s++}return r};var tq=/^Frame (\d+)$/,G9=e=>{let t=0;for(let n of e.elements.values()){if(!Be(n))continue;let o=tq.exec(n.name??"");o&&(t=Math.max(t,Number(o[1])))}return`Frame ${t+1}`},W9=(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=N(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=$(l,c.id,h=>({...h,frameId:n}));l=p.scene,t.push(p.patch)}return l},q9=(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:N(a)})),o=e;for(let a of e.elements.values()){if(Be(a))continue;let r=N(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=$(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 Gy=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>Dv&&n.add(o.layerId);for(let o of t.links.values())o.order.length>Dv&&n.add(o.layerId);for(let o of n)this.compact(o)}};var Wy=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(!Dn(o))continue;let a=this.signatureFor(o.id);if(this.signatures.get(o.id)===a)continue;this.signatures.set(o.id,a);let r=lp(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&&Dn(o)?.kind==="wrap"){let s=no(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=N(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 V9=()=>({activeTool:null,selection:null,scene:null,viewport:null,canUndo:!1,canRedo:!1}),j9=(e,t,n)=>{n.activeTool!==e.activeTool&&(e.activeTool=n.activeTool,t.emit("tool",n.activeTool)),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")},Z9=(e,t)=>{e.activeTool=t.activeTool,e.selection=t.selection,e.scene=t.scene,e.viewport=t.scene.viewport,e.canUndo=t.canUndo,e.canRedo=t.canRedo};var qy=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 Vy=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 qy({isAnimated:()=>this.host.hasVisibleAnimatedElement(),onTick:()=>{this.onTick()}})}onTick(){let t=typeof performance<"u"?performance.now():Date.now(),n=Math.min(k4,Math.max(L4,this.costEma*_4));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 jy=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 Gp(){return typeof performance<"u"?performance.now():Date.now()}function nq(){if(typeof matchMedia!="function")return!1;try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var Zy=class{state=new Map;hoveredId=null;ensure(t){if(this.state.has(t))return;let n=Gp();this.state.set(t,{playing:!nq(),originMs:n,playStartMs:n,frozenMs:0})}clock(t){let n=this.state.get(t),o=Gp();return n?n.playing?o-n.originMs:n.frozenMs:o}toggle(t){let n=Gp(),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=Gp();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=Gp();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>T4&&(a.frozenMs=n-a.originMs,a.playing=!1)}}}};var X9=(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}:{}}},Y9=async(e,t,n,o)=>{let a=await t.arrayBuffer(),r=fA(`file-${o()}-${Date.now().toString(36)}`),s=iv(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}},Xy=e=>{for(let t of e.elements.values())if(t.metadata?.animated===!0)return!0;return!1};var $9=e=>{if(!Xy(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&&j.intersects(N(n),t))return!0;return!1},Q9=e=>{let t=[];for(let n of e._scene.elements.values()){if(!ct(n)||!n.animationKind)continue;n.animationData instanceof ArrayBuffer&&n.animationData.byteLength>w4&&t.push(n.id)}e.gifPlayback.autoStopHeavy(t)},LS=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=Z0(e._scene,t.fileId);n&&(e._scene=J(e._scene,{kind:"element",id:t.id,before:t,after:{...t,animationData:n.data}}))}},oq=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],K9=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of oq){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},aq=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},rq=async(e,t)=>{if(typeof document>"u"||typeof URL>"u"||typeof URL.createObjectURL!="function")return null;let n=URL.createObjectURL(new Blob([e],{type:t})),o=vS(n);return await new Promise(r=>{o.onloadedmetadata=()=>{r(!0)},o.onerror=()=>{r(!1)}})?(o.play().catch(()=>{}),o):(URL.revokeObjectURL(n),o.remove(),null)},kS=async e=>{let t=[];for(let o of e._scene.elements.values()){if(!ct(o)||o.animationKind||K9(o.metadata?.image)||!o.fileId)continue;let a=Z0(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=o.mime.startsWith("video/")?await rq(o.data,o.mime):await aq(o.data,o.mime);if(!a)continue;let r=e._scene.elements.get(o.id);!r||!ct(r)||K9(r.metadata?.image)||(e._scene=J(e._scene,{kind:"element",id:r.id,before:r,after:{...r,metadata:{...r.metadata,image:a}}}),n=!0)}n&&e.forceRender()};var J9={x:-1e9,y:-1e9,width:0,height:0},iq=4,eR=(e,t)=>{let n=new Map;if(e===t)return{world:J9,tileDirty:n};let o=null,a=u=>{o=o?j.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=op(d),h=f?op(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=op(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=as(t,d);p&&a(p);let m=as(e,f??d);m&&a(m)}for(let[u,d]of e.links)if(!t.links.has(u)){let f=as(e,d);f&&a(f)}if(o===null)return{world:J9,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=N(u);if(!j.intersects(d,l))continue;i.add(u.id);let f=j.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:j.expand(l,iq),tileDirty:n}};var Yy=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})},UI)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.origin=null}cancelIfMovedBeyond(t,n){this.origin&&W.distance(this.origin,t)>n&&this.cancel()}};var Ky=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=W.midpoint(n,o);this.origin={midpointScreen:a,midpointWorld:this.screenToWorld(a),distance:W.distance(n,o)}}apply(t){if(!this.origin||t.length<2)return;let[n,o]=t,a=W.distance(n,o),r=W.midpoint(n,o);if(W.distance(r,this.origin.midpointScreen)+Math.abs(a-this.origin.distance)<HI)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 lq=(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},cq=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=N(o);n=n?j.union(n,a):a}return n},tR=(e,t,n,o)=>{if(!Wf(t)||!Ii(t))return n;if(Dn(t)?.kind==="wrap")return uq(e,t,n,o);let a=cq(e,t.id);if(!a)return n;let r={...t,position:{x:n.x,y:n.y},width:n.width,height:n.height},s=no(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}},uq=(e,t,n,o)=>{let a=di(t)?.padding??0,r=Math.max(0,n.width-2*a),s=$0(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:$0(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}},nR=(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=$(e.scene,n,i=>({...i,parentId:a.id,order:r}));e.applyPatch(s.patch,s.scene),Wp(e,a.id,n);return}if(a&&a.id===o.parentId){Wp(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?no(r):null,i=N(o),l=s?lq(i,s):0;if(s&&l>=t4){Wp(e,o.parentId,n);return}let c=$(e.scene,n,u=>{let d={...u};return delete d.parentId,d});e.applyPatch(c.patch,c.scene)}},Wp=(e,t,n)=>{let o=I(e.scene,t),a=I(e.scene,n);if(!o||!a)return;let r=di(o);if(!r)return;let s=N(a),i=PA(o,s);if(!i)return;if(Ii(o)){let c=BA({width:o.width,height:o.height,spec:r},i),u=$(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=$(e.scene,t,c=>({...c,metadata:{...c.metadata??{},container:{...r,dropZone:i}}}));e.applyPatch(l.patch,l.scene)};var qp=(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}},_S=(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}},wS=(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}},oR=e=>e==="nw"||e==="w"||e==="sw",aR=e=>e==="ne"||e==="e"||e==="se",rR=e=>e==="nw"||e==="n"||e==="ne",sR=e=>e==="sw"||e==="s"||e==="se",TS=(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;oR(n)&&!aR(n)?f=e.x+e.width-u:aR(n)&&!oR(n)&&(f=e.x);let p=t.y;rR(n)&&!sR(n)?p=e.y+e.height-d:sR(n)&&!rR(n)&&(p=e.y);let h={x:f,y:p,width:u,height:d};return o.noFlip?h:j.normalize(h)};var iR=(e,t)=>e.kind!=="point"&&t.has(e.elementId),dq=(e,t)=>iR(e.from,t)&&iR(e.to,t),uR=e=>(e.waypoints?.length??0)>0||(e.fixedSegments?.length??0)>0||(e.routedPoints?.length??0)>0,lR=(e,t)=>e.map(n=>({x:n.x+t.x,y:n.y+t.y})),fq=(e,t)=>{if(!uR(e))return null;let n={};return e.waypoints?.length&&(n.waypoints=lR(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=lR(e.routedPoints,t)),n},cR=(e,t)=>e.kind==="point"?{kind:"point",position:{x:e.position.x+t.x,y:e.position.y+t.y}}:e,ES=(e,t)=>{let n=fq(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=cR(e.from,t)),a&&(r.to=cR(e.to,t)),r},dR=(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(!uR(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},fR=(e,t,n)=>n.has(e.id)||dq(e,t),CS=(e,t,n)=>{let o=new Map;for(let a of e.links.values())fR(a,t,n)&&ES(a,{x:0,y:0})!==null&&o.set(a.id,a);return o},pR=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=ue(e,a);if(!s)continue;let i=ES(r,n);i&&o.push({kind:"link",id:a,before:s,after:{...s,...i}})}return o},hR=(e,t,n,o)=>{let a=e,r=[];for(let s of[...e.links.values()]){if(!fR(s,t,n))continue;let i=ES(s,o);if(!i)continue;let l=Ye(a,s.id,c=>({...c,...i}));a=l.scene,r.push(l.patch)}return{scene:a,patches:r}};var mR=(e,t,n,o,a,r,s=!1,i=!1)=>{let l=I(e,t);if(!l||!Ii(l))return null;let c=qp(a,n,o),u=s?wS(a,c):c,d=i?_S(a,u):u,p=l.noFlip===!0||Dn(l)!==null?{...l,noFlip:!0}:l,h=TS(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:J(e,y),patch:y}},yR=(e,t,n,o,a=!1,r=!1)=>{let s=I(e,t.id);if(!s||!Ii(t))return null;let i=bi(t),[l]=gp(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=qp(h,n,p),x=a?wS(h,m):m,y=r?_S(h,x):x,b=t.noFlip===!0||Dn(t)!==null?{...t,noFlip:!0}:t,A=TS(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},C={...t,position:_,scale:{x:1,y:1},width:A.width,height:A.height},w={kind:"element",id:t.id,before:s,after:C};return{scene:J(e,w),patch:w}},gR=(e,t,n,o,a,r=!1)=>{let s=I(e,t.id);if(!s)return null;let i=qp(a,n,o),l=a.x+a.width/2,c=a.y+a.height/2;if(n==="e"||n==="w"){let L=Math.max(t.fontSize,Math.abs(i.width)),k=n==="w"?a.x+a.width:a.x,M=r?l-L/2:n==="w"?k-L:k,B={...t,position:{x:M,y:a.y},scale:{x:1,y:1},maxWidth:L},G={kind:"element",id:t.id,before:s,after:B};return{scene:J(e,G),patch:G}}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(cy,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,C={...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:C};return{scene:J(e,w),patch:w}},xR=(e,t,n,o,a,r,s=!1)=>{let i=qp(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(Ii(g)){let k=g.type==="image",M=k?d:c,B=k?d:u,G=y.bounds.width*M,ie=y.bounds.height*B;if(Math.abs(G)<l||Math.abs(ie)<l)continue;let ne={...g,position:{x:b,y:A},scale:{x:G>=0?1:-1,y:ie>=0?1:-1},width:Math.abs(G),height:Math.abs(ie)},V={kind:"element",id:x,before:g,after:ne};h=J(h,V),m.push(V);continue}let _=y.scale.x*c,C=y.scale.y*u;if(Math.abs(_)<l/Math.max(1,y.bounds.width)||Math.abs(C)<l/Math.max(1,y.bounds.height))continue;let w={...g,position:{x:b,y:A},scale:{x:_,y:C}},L={kind:"element",id:x,before:g,after:w};h=J(h,L),m.push(L)}for(let[x,y]of t.links??[]){let g=ue(h,x);if(!g)continue;let b=dR(y,f,p,c,u);if(!b)continue;let A={kind:"link",id:x,before:g,after:{...g,...b}};h=J(h,A),m.push(A)}return{scene:h,patches:m}};var gt=Object.freeze(new Set),$y=e=>new Set([e]),IS=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},pq=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},bR=(e,t)=>e.has(t)?pq(e,t):IS(e,t),Vp=(e,t)=>M0(e,t),AR=e=>{if(e.size!==1)return null;for(let t of e)return t;return null};var jp=e=>Math.min(FI,Math.max(zI,e)),vR=(e,t)=>t.x===0&&t.y===0?null:{...e,viewport:JA(e.viewport,t)},SR=(e,t,n)=>{let o=e.viewport.zoom,r=jp(o*t)/o;return r===1?null:{...e,viewport:V0(e.viewport,r,n)}},LR=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:V0(t,1/t.zoom,n)}},RS=(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=jp(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}}},kR=(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=jp(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}}},_R=(e,t)=>{if(e.elements.size===0)return null;let n=null;for(let o of e.elements.values()){let a=N(o);n=n?j.union(n,a):a}return n?RS(e,n,t):null},wR=(e,t,n)=>{let o=e.viewport;return o.size.width===t&&o.size.height===n?null:{...e,viewport:ev(o,t,n)}},TR=(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 hq=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.activeTool.type==="select"&&n))return!1;let o=ue(e._scene,n);if(!o?.label)return!1;let a=fc(e._scene,o);if(!(a!==null&&t.x>=a.x&&t.x<=a.x+a.width&&t.y>=a.y&&t.y<=a.y+a.height))return!1;e.cancelLongPress();let s=performance.now(),i=e.interaction.lastClickWorldPoint,l=s-e.interaction.lastClickAt<bc&&i!==null&&Math.hypot(i.x-t.x,i.y-t.y)<=Ac;return e.interaction.lastClickAt=s,e.interaction.lastClickWorldPoint=t,l?(e.beginLinkCaptionEdit(n),!0):(e.beginLabelDrag(n),!0)},mq=(e,t)=>e.isDraggingLabel?(e.updateLabelDrag(t),!0):!1,yq=e=>e.isDraggingLabel?(e.endLabelDrag(),!0):!1,ER=(e,t,n)=>{let o=e.x-t.x,a=e.y-t.y;return o*o+a*a<=n},gq=(e,t,n)=>{let o=t.button===2||t.button===1,a=t.button===0&&e.spaceHeld,r=t.button===0&&e.activeTool.type==="hand";return o||a||r?(o&&(e.suppressNextContextMenu=!0),e.beginPanGesture(t.pointerId,t.button,n.point),!0):!1},xq=(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),bq=(e,t)=>e.readOnly||e.editingTextElement===null?!1:e.editedElementContainsPoint(t)?(e.cancelLongPress(),e.setTextCaretFromPoint(t),!0):(e.commitTextEdit(),!1),Aq=(e,t)=>e.activeTool.type!=="crop"||e.cropSession?.drag==null?!1:(e.updateImageCropDrag(t),!0),vq=e=>e.activeTool.type!=="crop"||e.cropSession?.drag==null?!1:(e.endImageCropDrag(),!0),Sq=(e,t,n,o)=>e.readOnly||e.activeTool.type!=="brush"?!1:(e.beginBrushStroke(t,n,o),!0),Lq=(e,t,n,o)=>e.readOnly||e.activeTool.type!=="erase"?!1:(e.cancelLongPress(),e.beginEraseStroke(t,n,o),!0),kq=(e,t)=>e.activeTool.type!=="laser"?!1:(e.cancelLongPress(),e.beginLaserStroke(t),!0),_q=(e,t)=>e.isEyedropperArmed?(e.cancelLongPress(),e.applyEyedropperAt(t),!0):!1,wq=(e,t)=>{if(e.activeTool.type!=="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)},Tq=(e,t,n)=>{if(e.readOnly||e.activeTool.type!=="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)},Eq=(e,t)=>{if(e.readOnly||e.activeTool.type!=="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&&pe(o)?(e._selection=wt(o.id),e.beginTextEdit(o.id),e.notify()):e.createTextAt(t),!0},Cq=(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},Iq=(e,t)=>{let n=e.acceleratedElementAt(t);if(!n)return!1;let o=I9(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},Mq=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.activeTool.type==="select"&&n))return!1;let o=ue(e._scene,n);if(!(o&&(o.routing??"straight")==="orthogonal"))return!1;let a=ut(e._scene,o);if(!(a&&a.length>=2))return!1;let r=e._scene.viewport.zoom||1,s=Ko/r,i=s*s;for(let{k:l,point:c}of tp(e._scene,o,a)){let u=v(a[l]),d=v(a[l+1]),f=c.x-t.x,p=c.y-t.y;if(f*f+p*p<=i){let h=Math.abs(u.y-d.y)<1e-6?"h":"v",m=h==="h"?(u.x+d.x)/2:(u.y+d.y)/2,x=h==="h"?u.y:u.x;return e.isHandleDoubleClick(t)?e.resetSegmentPin(n,h,x,m):e.beginSegmentDrag(n,h,m),e.cancelLongPress(),!0}}return!1},Rq=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.activeTool.type==="select"&&n))return!1;let o=ue(e._scene,n),a=o&&(o.routing??"straight")!=="orthogonal"?ut(e._scene,o):null;if(!(o&&a&&a.length>=2))return!1;let r=e._scene.viewport.zoom||1,s=Ko/r,i=s*s,l=[...o.waypoints??[]],c=!1;for(let u=0;u<l.length;u++)if(ER(v(l[u]),t,i)){e.isHandleDoubleClick(t)?e.deleteWaypoint(n,u):e.beginWaypointDrag(n,u,!1),c=!0;break}if(!c){let u=ep(e._scene,o)??[];for(let d=0;d<u.length;d++)if(ER(v(u[d]),t,i)){e.beginWaypointDrag(n,d,!0),c=!0;break}}return c?(e.cancelLongPress(),!0):!1},Oq=(e,t,n)=>{let o=I(e._scene,t);if(!o)return!1;let a=e._scene.viewport.zoom||1,{names:r,worldPoints:s}=Co(o,wo/a),i=($o+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)},Dq=(e,t,n,o)=>{if(e.readOnly||!(e.activeTool.type==="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&&Oq(e,a,n))},Pq=(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=gt),e.notify()}},Bq=(e,t,n)=>{if(e.readOnly)return n;if(t.modifiers.alt&&e.activeTool.type==="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},IR=(e,t,n)=>{if(!n.has(t)){n.add(t);for(let o of e._scene.elements.values())o.parentId===t&&IR(e,o.id,n)}},Nq=(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&&IR(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=CS(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},zq=(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:N(r),scale:r.scale})}let o=CS(e._scene,new Set(n.keys()),e._selectedLinks);e.groupResizeOrigin={combined:t.bounds,elements:n,links:o}}else e.groupResizeOrigin=null},Fq=(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},Hq=(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&&W.distance(o.startPoint,n.point)>xc&&(o.moved=!0),e.panBy({x:a,y:r}),!0},Uq=(e,t,n)=>(e.activePointers.has(t.pointerId)&&e.activePointers.set(t.pointerId,n.point),e.pinch.isActive()?(e.applyPinch(),!0):!1),Gq=(e,t,n)=>{if(e.touchPanCandidate!==null&&e.activePointers.size===1&&W.distance(e.touchPanCandidate,n.point)>xc){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},Wq=(e,t)=>e.isDraggingSegment?(e.updateSegmentDrag(t),!0):!1,qq=(e,t)=>e.isDraggingWaypoint?(e.updateWaypointDrag(t),!0):!1,Vq=(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<_i*_i)return!0;n.moved=!0}return e.applyLinkPreview(n.fromElement,n.fromWorld,t),e.updateHoveredLinkTarget(t),!0},jq=(e,t)=>e.editingTextElement!==null&&e.isTextDragging?(e.extendTextSelectionToPoint(t),!0):!1,Zq=(e,t,n)=>e.brushStroke?(e.extendBrushStroke(t,n),!0):!1,Xq=(e,t,n)=>e.eraseStroke?(e.extendEraseStroke(t,n),!0):!1,Yq=(e,t)=>e.laserDrawing?(e.extendLaserStroke(t),!0):!1,Kq=(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=qf(e._scene,t,o);if(a){let r=no(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())},$q=(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},Qq=(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=Tp(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.activeTool.type==="select"?t:null),e.activeTool.type==="erase"&&e.notify()}e.actor.send({type:"POINTER_MOVE",point:t})},Jq=(e,t)=>e.panGesture?.pointerId!==t.pointerId?!1:(e.endPanGesture(),!0),eV=e=>e.pinch.isActive()?(e.activePointers.size<2&&e.pinch.end(),!0):!1,tV=e=>e.isDraggingSegment?(e.endSegmentDrag(),!0):!1,nV=e=>e.isDraggingWaypoint?(e.endWaypointDrag(),!0):!1,oV=(e,t)=>{let n=e.linkDragFromAnchor;if(!n)return!1;e.linkDragFromAnchor=null;let o=Hc(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}=Co(r,wo/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},aV=e=>e.editingTextElement!==null&&e.isTextDragging?(e.endTextDragSelect(),!0):!1,rV=e=>e.brushStroke?(e.commitBrushStroke(),!0):!1,sV=e=>e.eraseStroke?(e.commitEraseStroke(),!0):!1,iV=e=>e.laserDrawing?(e.endLaserStroke(),!0):!1,lV=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=Va(e._scene,t.id,()=>n);e._scene=r.scene,e._history.push(r.patch),e.notify()}}return!0},cV=(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<xc){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},uV=(e,t)=>{let n=e.actor.getSnapshot().context,o=F5(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<xc){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)},CR=(e,t,n)=>{if(t.deltaY===0)return;let a=1-(Math.abs(t.deltaY)>Mv?Mv*Math.sign(t.deltaY):t.deltaY)*NI/100;if(a<=0)return;let r=e._scene.viewport.zoom,s=jp(r*a);if(s===r)return;let i=e.screenToWorld(n);e.zoomAt(s/r,i)},dV=(e,t)=>{let n=t.deltaX,o=t.deltaY;t.shiftKey&&n===0&&(n=o,o=0),e.panBy({x:-n*Cv,y:-o*Cv})},MR=e=>{let t=c=>{c.preventDefault(),e.host.setPointerCapture(c.pointerId),typeof e.host.focus=="function"&&!oa(c.target)&&e.host.focus({preventScroll:!0});let u=Hc(c,e.host);if(e.additivePressAdded=null,gq(e,c,u)||xq(e,c,u))return;e.startLongPress(u.point);let d=e.screenToWorld(u.point);if(_q(e,d)||bq(e,d)||wq(e,d)||Tq(e,d,c.detail)||Sq(e,d,c.pressure,c.pointerType)||Lq(e,d,u.modifiers.alt,u.modifiers.shift)||kq(e,d)||Eq(e,d)||Cq(e,d)||Iq(e,d)||Mq(e,d)||Rq(e,d)||hq(e,d))return;let f=e.hitTest(d);Dq(e,u,d,f)||(Pq(e,u,f),f=Bq(e,u,f),e.dragElementId=f.kind==="element"?f.id:null,e.containerHover=null,Nq(e,f),zq(e,f),Fq(e,f),e.touchPanCandidate=u.kind==="touch"&&e.activeTool.type==="select"&&f.kind==="empty"?u.point:null,e.actor.send({type:"POINTER_DOWN",point:d,target:f,modifiers:u.modifiers}))},n=c=>{let u=Hc(c,e.host);if(Hq(e,c,u)||Uq(e,c,u)||Gq(e,c,u))return;e.longPress.cancelIfMovedBeyond(u.point,xc);let d=e.screenToWorld(u.point);e.lastPointerWorld=d,e.refreshCursor(d),!Aq(e,d)&&(mq(e,d)||Wq(e,d)||qq(e,d)||Vq(e,d)||jq(e,d)||Zq(e,d,c.pressure)||Xq(e,d,u.modifiers.alt)||Yq(e,d)||(Kq(e,d),!$q(e,d)&&Qq(e,d)))},o=c=>{if(e.host.hasPointerCapture(c.pointerId)&&e.host.releasePointerCapture(c.pointerId),e.activePointers.delete(c.pointerId),e.touchPanCandidate=null,Jq(e,c)||eV(e)||(e.cancelLongPress(),vq(e))||yq(e)||tV(e)||nV(e)||oV(e,c)||aV(e)||rV(e)||sV(e)||iV(e)||lV(e))return;let u=Hc(c,e.host),d=e.screenToWorld(u.point);cV(e,u,d)||uV(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!==" "||oa(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){CR(e,c,d);return}if(c.deltaX!==0){dV(e,c);return}CR(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 Qy=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 Gc={stroke:o4,fill:null,opacity:a4,width:ay},Jy=e=>({stroke:e.stroke,...e.fill!==null?{fill:e.fill}:{},...e.opacity!==1?{opacity:e.opacity}:{}}),OS=(e,t)=>e<=0?n4:Math.max(.5,e*t),RR=(e,t,n=ay,o=!1)=>{let a=o?ry:t,r={x:0,y:0,width:OS(a,n),pressure:a};return{points:[r],pressures:[a],simulatePressure:o,baseWidth:n,lastRaw:r,lastStoredRaw:{x:0,y:0},origin:e}},fV=e=>{let t=(n,o)=>n===0||n===o-1||n%2===0;e.points=e.points.filter((n,o,a)=>t(o,a.length)),e.pressures=e.pressures.filter((n,o,a)=>t(o,a.length))},OR=(e,t,n,o=1)=>{let a=e.origin,r=t.x-a.x,s=t.y-a.y,i=e.pressures[e.pressures.length-1]??ry,l;if(e.simulatePressure){let h=Math.hypot(r-e.lastRaw.x,s-e.lastRaw.y)*o,m=1-Math.min(1,h/i4);l=i+(m-i)*Pv,l=Math.min(c4,Math.max(l4,l))}else l=i+(n-i)*Pv;let c={x:r,y:s,width:OS(e.simulatePressure?l:n,e.baseWidth),pressure:e.simulatePressure?l:n},u=(r-e.lastStoredRaw.x)*o,d=(s-e.lastStoredRaw.y)*o;if(u*u+d*d<Bv*Bv){e.lastRaw=c;return}let f=e.points[e.points.length-1]??c,p=1-s4;e.points.push({x:f.x+(c.x-f.x)*p,y:f.y+(c.y-f.y)*p,width:OS(l,e.baseWidth)}),e.pressures.push(l),e.lastRaw=c,e.lastStoredRaw={x:r,y:s},e.points.length>u4&&fV(e)},pV=(e,t,n=d4,o=f4)=>{let a=e.length;if(a<3||n<=0)return e.slice();let r=new Array(a);r[0]=0;for(let l=1;l<a;l++){let c=v(e[l-1]),u=v(e[l]);r[l]=v(r[l-1])+Math.hypot(u.x-c.x,u.y-c.y)}let s=v(r[a-1]),i=Math.min(t*n,s/2);return i<=0?e.slice():e.map((l,c)=>{let u=Math.min(v(r[c]),s-v(r[c]));if(u>=i)return l;let d=u/i,f=o+(1-o)*d*(2-d);return{x:l.x,y:l.y,width:l.width*f}})},DS=(e,t)=>{let n=e.points.map((l,c)=>({...l,pressure:e.pressures[c]??ry})),o=n[n.length-1],a=e.lastRaw;o!==void 0&&(Math.abs(o.x-a.x)>.001||Math.abs(o.y-a.y)>.001)&&n.push(a);let r=Py(n,r4,(l,c,u,d)=>({x:u.x,y:u.y,width:l.width+(c.width-l.width)*d,pressure:l.pressure+(c.pressure-l.pressure)*d})),s=r.map(({x:l,y:c,width:u})=>({x:l,y:c,width:u}));return{points:t!==void 0&&DR(s,t)?s:pV(s,e.baseWidth),pressures:r.map(l=>l.pressure)}},DR=(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<=Nv*Nv},PR=(e,t,n,o,a=Jy(Gc))=>{if(!t||t.points.length===0)return null;let r=Ae([...e.elements.values()].filter(u=>u.layerId===n).map(u=>u.order)),{points:s,pressures:i}=DS(t,a),l={id:o,layerId:n,type:"brush",position:t.origin,rotation:0,scale:{x:1,y:1},order:r,style:a,points:s,pressures:i,baseWidth:t.baseWidth,...t.simulatePressure?{simulatePressure:!0}:{},...DR(s,a)?{closed:!0}:{}},c=Fe(e,l);return{scene:c.scene,patch:c.patch,elementId:o}},PS=e=>Ze(`brush-${e}-${Date.now().toString(36)}`),BR=(e,t,n)=>{if(!(n>0))return null;let o=e,a=[];for(let s of t){let i=I(o,s);if(!i||!Mn(i))continue;let l=i.baseWidth??i.points.reduce((d,f)=>Math.max(d,f.width),0);if(!(l>0)||l===n)continue;let c=n/l,u=$(o,s,d=>({...d,points:d.points.map(f=>({...f,width:f.width*c})),baseWidth:n}));o=u.scene,a.push(u.patch)}let r=a[0];return r===void 0?null:{scene:o,patch:a.length===1?r:{kind:"batch",patches:a}}};var NR=(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=$(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}},eg=(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=hi(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}},zR=(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}},FR=(e,t,n)=>{let o=Pe;for(let a of t)e.elements.has(a)&&(o=Xt(o,a));return ai(o,n)?null:o},HR=(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 ai(n,t)?null:n},UR=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},GR=(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=$(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}}},WR=(e,t,n,o,a)=>{let r=I(e,t);if(r===void 0||!pe(r))return null;let s=SA(r,n,o,a);if(s===r)return null;let i=$(e,t,()=>s);return{scene:i.scene,patch:i.patch}},qR=(e,t,n)=>{let o=[];for(let i of t){let l=I(e,i);l!==void 0&&pe(l)&&o.push(i)}if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=$(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}}},VR=(e,t,n)=>{let o=n==="increase",a=o?Hv:1/Hv,r=e,s=[];for(let l of t){let c=I(r,l);if(c===void 0||!pe(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(F4,Math.max(cy,d));if(f===c.fontSize)continue;let p=$(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}}},jR=(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 ")}`},BS=e=>{let t=Pe;for(let n of e)t=Xt(t,n);return t},NS=(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=N(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 ZR=(e,t=!1)=>({pending:new Set,last:e,erased:new Map,strokeMode:t}),XR=(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/p4)),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:eg(e,n,new Set)};var zS=1e-6,FS=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}},tg=(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}},$R=(e,t,n,o)=>{let a=tg(e,t);return Ha.distanceToSegmentSq({x:e.position.x+a.x,y:e.position.y+a.y},n,o)},KR=(e,t,n,o,a,r)=>{let s=t,i=n;for(let l=0;l<g4;l++){let c=(s+i)/2;$R(e,c,o,a)<=r?i=c:s=c}return i},QR=(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 Ha.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(y4,o*m4),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 C=Math.max(1,Math.ceil(_/m)),w=-1,L=A;for(let k=0;k<=C;k++){let M=k===C?A+_:A+_*k/C,B=$R(e,M,t,n)<=l;B&&w<0?w=k===0?M:KR(e,L,M,t,n,l):!B&&w>=0&&(x.push([w,KR(e,M,L,t,n,l)]),w=-1),L=M}w>=0&&x.push([w,A+_])}return Zp(x)},Zp=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]+zS?a>r[1]&&(r[1]=a):n.push([o,a])}return n},HS=e=>e.reduce((t,[n,o])=>t+(o-n),0),JR=(e,t)=>{let n=Zp(e),o=[],a=0;for(let[r,s]of n)r>a+zS&&o.push([a,r]),s>a&&(a=s);return t>a+zS&&o.push([a,t]),o};var eO=1e-6,tO=(e,t,n)=>{let o=FS(e);if(o.total===0)return[];let a=JR(t,o.total),r=[],s=e.order,i=0;for(let[l,c]of a){if(c-l<x4)continue;let u=[tg(o,l)];for(let m=0;m<o.pts.length;m++){let x=v(o.cum[m]);x>l+eO&&x<c-eO&&u.push({...v(o.pts[m])})}if(u.push(tg(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:mc(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},nO=(e,t,n,o,a)=>{let r=QR(FS(e),n,o,a);return r.length===0?t.length>0?Zp(t):[]:Zp([...t,...r])};var oO=(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||!Mn(u))continue;let d=tO(u,c,n);for(let p of[...o.links.values()])if(!i.has(p.id)&&(ii(p.from)===u.id||ii(p.to)===u.id)){let h=hi(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}},aO=(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||!Mn(s))continue;let i=0,l=tO(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 rO=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},sO=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(rO(a))}return n},iO=(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={...rO(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:Yo(l)),{scene:u,newIds:c}};var lO=(e,t)=>sO(e,t),cO=(e,t,n,o,a)=>{let r=iO(e,t,n,o,()=>Ze(`shape-${a()}-${Date.now().toString(36)}`));return{scene:r.scene,newIds:r.newIds}},uO=e=>{let t=Pe;for(let n of e)t=Xt(t,n);return t};var dO=(e,t,n)=>{let o=Ae([...e.layers.values()].map(s=>s.order)),r=lv(e,{id:n,name:t,visible:!0,locked:!1,order:o});return{scene:r.scene,patch:r.patch,layerId:n}},fO=(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=hi(a,i.id);a=l.scene,o.push(l.patch)}let r=cv(a,t);a=r.scene,o.push(r.patch);let s=n;if(n===t){let i=[...a.layers.values()].sort(Uf)[0];i&&(s=i.id)}return{scene:a,patches:o,nextActiveLayerId:s}},pO=(e,t,n)=>{let o=e.layers.get(t);if(!o||o.name===n)return null;let a=sp(e,t,r=>({...r,name:n}));return{scene:a.scene,patch:a.patch}},hO=(e,t)=>{if(!e.layers.has(t))return null;let n=sp(e,t,o=>({...o,visible:!o.visible}));return{scene:n.scene,patch:n.patch}},mO=(e,t)=>{if(!e.layers.has(t))return null;let n=sp(e,t,o=>({...o,locked:!o.locked}));return{scene:n.scene,patch:n.patch}},yO=(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=$(o,r,l=>({...l,layerId:n}));o=i.scene,a.push(i.patch)}return a.length===0?null:{scene:o,patches:a}},gO=e=>ln(`layer-${e}-${Date.now().toString(36)}`);var xO=(e,t,n,o)=>{let a=new Date().toISOString(),r=Of(o("ann")),s=[];t.firstComment?.trim()&&s.push({id:rc(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=uv(e,i);return{scene:l.scene,patch:l.patch,id:r}},bO=(e,t)=>{if(!e.annotations.has(t))return null;let n=dv(e,t);return{scene:n.scene,patch:n.patch}},AO=(e,t)=>{let n=e.annotations.get(t);if(!n)return null;let o=Va(e,t,a=>({...a,resolved:!a.resolved}));return{scene:o.scene,patch:o.patch,wasResolved:n.resolved}},vO=(e,t,n,o,a)=>{let r=n.trim();if(!r||!e.annotations.has(t))return null;let s={id:rc(a("cmt")),authorId:o.id,authorName:o.name,body:r,createdAt:new Date().toISOString()},i=Va(e,t,l=>({...l,thread:[...l.thread,s]}));return{scene:i.scene,patch:i.patch}},SO=(e,t,n)=>{if(!e.annotations.get(t)?.thread.some(r=>r.id===n))return null;let a=Va(e,t,r=>({...r,thread:r.thread.filter(s=>s.id!==n)}));return{scene:a.scene,patch:a.patch}},LO=(e,t)=>{let n=e.viewport.zoom,o=oy/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=$r(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 kO=(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},_O=(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=$(e,t,i=>{let l={...i};return a===""?delete l.name:l.name=a,l});return{scene:s.scene,patch:s.patch}};var hV={nw:"resize-nwse",se:"resize-nwse",ne:"resize-nesw",sw:"resize-nesw",n:"resize-ns",s:"resize-ns",e:"resize-ew",w:"resize-ew"},mV=(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}`},yV=(e,t,n)=>{let o=e.getCursorOverride(t);return o===void 0?n:mV(o,n)},gV=(e,t)=>{if(e.activeTool.type!=="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}=Co(o,wo/a),s=($o+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},wO=(e,t)=>{let n=(a,r)=>yV(e,a,r),o=a=>n(hV[a],Q4(a));if(e.panGesture)return n("pan-active","grabbing");if(e.linkDragFromAnchor?.moved===!0)return n("draw","crosshair");if(e.isDraggingWaypoint||e.isDraggingSegment||e.isDraggingLabel||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.activeTool.type==="hand")return n("pan-ready","grab");switch(e.activeTool.type){case"draw-rect":case"draw-ellipse":case"draw-frame":case"draw-edge":case"brush":case"laser":case"crop":return n("draw","crosshair");case"erase":return n("erase","none");case"draw-text":return n("text","text");default:break}if(t){if(gV(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 ng=(e,t,n)=>{let o=t??(n.size===1?[...n][0]??null:null);return o&&e.elements.has(o)?o:null},EO=(e,t,n)=>{let o=ng(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=$(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},CO=(e,t,n)=>{let o=ng(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=hc([...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=$(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},IO=(e,t,n)=>{let o=ng(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(Tt),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?mc(s.order,i.order):Ae(r.map(u=>u.order));if(l===a.order)return null;let c=$(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},MO=(e,t,n)=>{let o=ng(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(Uf),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?mc(i.order,s.order):hc(r.map(u=>u.order));if(l===a.order)return null;let c=$(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},TO=(e,t)=>{if(e.length===0)return 0;let n=[...e].sort(Tt),o=av(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},RO=(e,t,n)=>{let o=e,a=0;for(let r of t)a+=TO([...o.elements.values()].filter(s=>s.layerId===r),(s,i)=>{let l=$(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)}),a+=TO([...o.links.values()].filter(s=>s.layerId===r),(s,i)=>{let l=Ye(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)});return a};var OO=(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=Y0(e,{shapeIds:a,origin:o,cols:r,gap:s});return i?{scene:J(e,i),patch:i,count:a.length,cols:r}:null},DO=(e,t,n,o)=>{let a=[...t];if(a.length<2)return null;let r=n.direction??"horizontal",s=n.gap??16,i=K0(e,{shapeIds:a,origin:o,direction:r,gap:s});return i?{scene:J(e,i),patch:i,count:a.length,direction:r}:null},US=(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},PO=(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},BO=(e,t,n)=>{let o=US(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=$(l,d.id,p=>({...p,parentId:n}));l=f.scene,c.push(f.patch)}return{scene:l,patches:c,groupId:n}},NO=(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=$(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}},zO=(e,t,n)=>{let o=[...e.layers.values()].filter(l=>l.visible&&!l.locked).sort(Tt),a=[];for(let l of o){let c=[...e.elements.values()].filter(u=>u.layerId===l.id).sort(Tt);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?pv(i):s}},FO=e=>Ze(`group-${e}-${Date.now().toString(36)}`);var HO=/^(https?:|mailto:)/i,xV=/^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/,UO=e=>{let t=e.trim();return t===""?null:HO.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t)?null:xV.test(t)?`mailto:${t}`:`https://${t}`},og=e=>e&&HO.test(e.trim())?e.trim():null,GO=(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=$(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}}},bV=(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}},WO=(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=bV(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 AV=os.rectangle,vV=os.ellipse,GS=(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"?hc(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:{...AV}}:t==="ellipse"?{...l,type:"ellipse",style:{...vV}}:{...l,type:"frame",style:{fill:kI},name:r()}},qO=(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:mi,style:{...Bc},arrowheads:{to:dp}}},VO=(e,t,n,o)=>{let a=qO(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},jO=(e,t,n,o,a,r)=>{let s=GS(e,t,n,o,a,r),i=Fe(e,s);return{scene:i.scene,patch:i.patch,elementId:o}},Xp=(e,t,n,o,a)=>{let r=qO(e,t,n,o,a),s=pi(e,r);return{scene:s.scene,patch:s.patch,linkId:o}},Wc=e=>`shape-${e}-${Date.now().toString(36)}`,Yp=e=>`edge-${e}-${Date.now().toString(36)}`;var ZO=(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}},XO=(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:C4,fontSize:E4,style:{fill:I4,textAlign:"left",textBaseline:"top"}}},qS=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:J(e,a),patch:a,next:o}},KO=(e,t)=>{let n={x:t.current.position.x+t.halfWidth,y:t.current.position.y+t.halfHeight},o=qf(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}},$O=e=>{let t=N(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}}},QO=(e,t)=>({scene:dn(e,t).scene}),WS="__ghost-preview__",qc="__ghost-preview-link__",JO=(e,t,n,o)=>{let a=I(e,n);if(!a||Mn(a))return null;let r={kind:"named",name:o},s=Xo(a,r),i=N(a),l=Math.abs(s.x)*i.width+Math.abs(s.y)*i.height,c=l+Sv,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:WS,position:{x:a.position.x+u.x,y:a.position.y+u.y}};pe(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,WS)),{ref:A}=Wa(b,y,ko(b)),C=Xp(g,{kind:"anchor",elementId:n,anchor:r},{kind:"anchor",elementId:WS,anchor:A},qc,t).scene,w=v(ue(C,qc));if((w.routing??"straight")==="orthogonal"){let L=up(C,w);C=Ye(C,qc,k=>({...k,routedPoints:L})).scene}return C={...C,links:new Map([[qc,v(ue(C,qc))]])},{bounds:d,path:[f,m],element:x,ghostScene:C,ghostLinkId:qc}},eD=(e,t,n,o,a,r)=>{let s=I(e,n);if(!s||Mn(s))return null;let i={kind:"named",name:o},l=Xo(s,i),c=N(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+Sv,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};pe(m)?m={...m,text:""}:Be(m)&&(m={...m,name:""});let x=Fe(e,m),y=v(I(x.scene,a)),{ref:g}=Wa(y,u,ko(y)),b=Xp(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}},tD=(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}},nD=(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=N(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=Ye(c.scene,n.linkId,d=>({...d,[n.side]:{kind:"floating",elementId:o}}));return{scene:u.scene,addPatch:c.patch,linkPatch:u.patch}};var VS=(e,t,n="fill")=>{let o=ui(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},SV=new Set(["rectangle","ellipse","polygon"]),LV=(e,t)=>[{x:e/2,y:0},{x:e,y:t/2},{x:e/2,y:t},{x:0,y:t/2}],oD=(e,t,n)=>{let o=e,a=[];for(let s of t){let i=I(o,s);if(i===void 0||!SV.has(i.type)||i.type===n)continue;let l=Re(i),c=l.width,u=l.height,d=$(o,s,f=>{let{width:p,height:h,points:m,...x}=f;return n==="polygon"?{...x,type:"polygon",points:LV(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}}},aD=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}},kV=(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 ag={x:0,y:0,width:1,height:1},rD=["nw","ne","se","sw","n","e","s","w"],Vc=(e,t,n)=>Math.min(Math.max(e,t),n),rg=(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}},sD=e=>{let t=Re(e),{x:n,y:o,width:a,height:r}=t,s=(i,l)=>Rn(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)}},_V=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"}),iD=(e,t,n,o)=>{let a=rg(e,t),r=Re(e),s=ci(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}=_V(n),m=a.x+a.width,x=a.y+a.height;d&&(i=Vc(s.x,a.x,c-mp)),f&&(c=Vc(s.x,i+mp,m)),p&&(l=Vc(s.y,a.y,u-mp)),h&&(u=Vc(s.y,l+mp,x));let y={x:i,y:l,width:c-i,height:u-l};return{crop:aD({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:Rn(e,{x:y.x,y:y.y}),width:y.width,height:y.height}},lD=(e,t,n,o)=>{let a=rg(e,t),r=ci(e,n),s=ci(e,o),i=s.x-r.x,l=s.y-r.y;return{crop:{x:Vc(t.x-i/a.width,0,1-t.width),y:Vc(t.y-l/a.height,0,1-t.height),width:t.width,height:t.height}}},wV=(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,cD=(e,t,n)=>{let o=I(e,t);if(o?.type!=="image")return null;let a=aD(n.crop),r=wV(a)?void 0:a,s=o.crop;if(kV(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=$(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}},uD=(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+To:n==="left"?-(i+To):0,u=n==="down"?l+To:n==="up"?-(l+To):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:mi,style:{...Bc},arrowheads:{to:dp}},g=pi(x.scene,y);return{scene:g.scene,patches:[x.patch,g.patch],newElementId:o,linkId:a}},dD=(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+To:n==="left"?-(l+To):0,f=n==="down"?c+To:n==="up"?-(c+To):0,p=u?c+To:l+To,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 C=(_-(o-1)/2)*p,w=d+(u?0:C),L=f+(u?C:0),k=a();b.push({...g,id:k,position:{x:s.position.x+w,y:s.position.y+L},order:h}),A.push({id:r(),layerId:s.layerId,from:{kind:"floating",elementId:t},to:{kind:"floating",elementId:k},order:m,routing:mi,style:{...Bc},arrowheads:{to:dp}})}return{elements:b,links:A}};var TV="__draw-preview__",fD="__draw-preview-link__",pD=new WeakMap,EV=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],CV=(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},hD=e=>{if(e.backgroundTarget){e.gridEnabled?Op(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:Gf(e.scene,f),outsetWorld:AA(p)})}u.length>0&&LM(e.backgroundTarget,ao(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;if(e.tileComposeFn&&t&&!r)W2(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,...a&&a.size>0?{hideElements:a}:{},...e.sharedIndex?{index:e.sharedIndex}:{}}),Bn(e.scene,e.mainTarget,{viewportWorld:t});else{let u=e.sharedIndex;Xa(e.scene,e.mainTarget,{...t?{viewport:t}:{},...n?{dirtyWorld:n}:{},boundsCache:e.boundsCache,clock:e.animationClock,lod:y2,...o?{dimElements:o,dimOpacity:e.eraseActive?WI:GI}:{},...a?{hideElements:a}:{},...u?{spatialIndex:u}:{}}),Bn(e.scene,e.mainTarget,{...t?{viewportWorld:t}:{},...n?{dirtyWorld:n}:{}})}let s=EV(e),i=pD.get(e.overlayTarget);if(i===void 0||!CV(i.sig,s)){let u={};e.readOnly&&(u.readOnly=!0),e.mode!=="select"&&e.mode!=="hand"&&(u.suppressHandles=!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=GS(e.scene,x,e.drawingPreview,TV,e.activeLayerId,()=>""):u.drawingPreview=e.drawingPreview}let f=null;if(e.edgePreview){let x=VO(e.scene,e.edgePreview,fD,e.activeLayerId);f={...e.scene,links:new Map([[fD,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,_,C,w)=>{let L=I(e.scene,A);if(!L)return null;let k=_==="link-start"?wo:LI,{names:M,worldPoints:B}=Co(L,k/x),G=[...B],ie=C!==null?M.indexOf(C):-1;_==="link-attach"&&w&&G.push(w);let ne=ie>=0?ie:_==="link-attach"&&w?G.length-1:-1;return{worldPoints:G,...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,C=y(_.elementId,"link-attach",_.activeAnchor,_.outlinePoint);C&&g.push(C)}}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]),C=I(e.scene,_);if(C){let w=N(C),L=(wo+$o+e.anchorStartHitSlop)/x;if(A.x>=w.x-L&&A.x<=w.x+w.width+L&&A.y>=w.y-L&&A.y<=w.y+w.height+L){let M=y(_,"link-start",null);if(M){let V=_I/x,ve=-1,ge=V*V;if(M.worldPoints.forEach((ee,Se)=>{let Oe=ee.x-A.x,qt=ee.y-A.y,xn=Oe*Oe+qt*qt;xn<=ge&&(ge=xn,ve=Se)}),ve>=0){let ee=V>0?Math.max(0,1-Math.sqrt(ge)/V):0,Se=fp+(bI-fp)*ee;g.push({...M,activeIndex:ve,activeRadius:Se})}else g.push(M)}let{names:B,worldPoints:G}=Co(C,wo/x),ie=(e.anchorClickRadius/x)**2,ne=null;for(let V=0;V<G.length;V++){let ve=v(G[V]);if((ve.x-A.x)**2+(ve.y-A.y)**2<=ie){ne=v(B[V]);break}}if(ne){let V=e.previewClickCreate(_,ne);V&&(u.ghostElement=V.bounds,u.ghostElementShape=V.element,d=V.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=N(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=ue(e.scene,y);if(!g)continue;let b=_o(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=ue(e.scene,h);if(x){let y=ut(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 _=e.linkSegmentDrag||e.linkEndpointDrag?[]:tp(e.scene,x,y).map(C=>C.point);u.edgeSelection={from:g,to:b,midpoints:_}}else{let _=[...x.waypoints??[]],C=e.linkWaypointDrag?[]:ep(e.scene,x)??[];u.edgeSelection={from:g,to:b,waypoints:_,midpoints:C}}}}}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=Ny({linkDragActive:x,elementDragActive:y});if(u.debugHitZoneVisibility=g,g.attachDropZones){let b=e.linkDragFromAnchor?.fromElement,A=[],_=[];for(let C of e.scene.elements.values())if(C.id!==b){A.push(...Co(C,0).worldPoints);for(let w of Gf(e.scene,C))_.push(w)}u.debugAttachZones={anchors:A,outlineLoops:_,thresholdWorld:12}}if(g.containerDropZones){let b=e.groupMoveOrigin,A=[],_=[];for(let C of e.scene.elements.values())if(!b?.has(C.id)){if(Be(C)){A.push(N(C));continue}_.push(...DA(C))}u.debugContainerZones={frames:A,containers:_}}}i={sig:s,opts:u,ghostScene:d,edgePreviewScene:f,flowchartPreviewScene:p},pD.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(N(u));c.length>0?l.gifBadges=c:l.gifBadges!==void 0&&delete l.gifBadges,kM(e.scene,e.selection,e.overlayTarget,l),i.ghostScene&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(ny),Bn(i.ghostScene,e.overlayTarget,{}),e.overlayTarget.restore()),i.edgePreviewScene&&Bn(i.edgePreviewScene,e.overlayTarget,{}),i.flowchartPreviewScene&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(uy),Bn(i.flowchartPreviewScene,e.overlayTarget,{}),e.overlayTarget.restore())};var sg=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()},D4))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}wake(){this._on=!0}};var mD=(e,t,n)=>{let o=I(e,t);return!(o===void 0||!pe(o)||n(o.layerId))};var ig=class{host;_editingElement=null;_pendingCreate=null;_origin=null;_sel=null;_dragAnchor=null;caretBlink;constructor(t){this.host=t,this.caretBlink=new sg(()=>{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(!mD(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&&pe(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=$(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||!pe(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 z2(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=N(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 zc(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||!pe(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=F2(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=N2(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=$(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&&pe(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=pe(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=pe(o)?o.text:"";this.host.scene=$(this.host.scene,t,r=>({...r,text:a})).scene}this.host.notify()}};var yD=(e,t,n,o)=>{let a=n;if(t){let i=I(e,t);i&&(a=Wa(i,n,ko(i)).world)}let r=o,s=ui(e,o);return s&&(r=Wa(s,o,ko(s)).world),{from:a,to:r}},gD=(e,t,n)=>{let o=ue(e,t.linkId);if(!o)return null;let a=n(t.toElement,t.toPoint),r=Ye(e,o.id,s=>({...s,[t.side]:a}));return{scene:r.scene,patch:r.patch,linkId:o.id}},xD=(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?N(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=N(r);a+=`${r.id},${s.x},${s.y},${s.width},${s.height};`}return o+a}return o};var lg=class{host;_endpointDrag=null;_waypointDrag=null;_segmentDrag=null;_labelDrag=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}get labelDrag(){return this._labelDrag}get isDraggingLabel(){return this._labelDrag!==null}reset(){this._waypointDrag=null,this._segmentDrag=null,this._endpointDrag=null,this._labelDrag=null}applyEndpointMove(t,n,o){if(!ue(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=Ye(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=gD(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&&Kr(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){ue(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=ue(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=Ye(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=ue(this.host.scene,t.linkId);if(n?.waypoints&&t.index>=0&&t.index<n.waypoints.length){let o=ut(this.host.scene,n),a=v(n.waypoints[t.index]),r=yI/(this.host.scene.viewport.zoom||1),s=o?.[t.index],i=o?.[t.index+2];if(s&&i&&Ha.distanceToSegment(a,s,i)<=r){let l=n.waypoints.filter((u,d)=>d!==t.index),c=Ye(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){ue(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=ue(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=Ye(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())}beginLabelDrag(t){ue(this.host.scene,t)?.label&&(this._labelDrag={linkId:t,moved:!1})}updateLabelDrag(t){let n=this._labelDrag;if(!n)return;n.moved=!0,this.lastHandleClickAt=0;let o=ue(this.host.scene,n.linkId);if(!o?.label)return;let a=_o(this.host.scene,o);if(!a||a.length<2)return;let r=0;for(let u=1;u<a.length;u++){let d=a[u-1],f=a[u];d&&f&&(r+=Math.hypot(f.x-d.x,f.y-d.y))}let s=UA(a,t),i=this.host.scene.viewport.zoom||1,l=r>0&&Math.abs(s-.5)*r<$4/i,c=Ye(this.host.scene,n.linkId,u=>{if(!u.label)return u;if(l){let{position:d,...f}=u.label;return{...u,label:f}}return{...u,label:{...u.label,position:s}}});this.host.scene=c.scene,this.host.recordGesturePatch(c.patch),this.host.notify()}endLabelDrag(){this._labelDrag&&(this._labelDrag=null,this.host.commitGesture())}isHandleDoubleClick(t){let n=performance.now(),o=n-this.lastHandleClickAt<bc&&this.lastHandleClickWorld!==null&&W.distance(this.lastHandleClickWorld,t)<=Ac;return this.lastHandleClickAt=n,this.lastHandleClickWorld=t,o}deleteWaypoint(t,n){let o=ue(this.host.scene,t);if(!o?.waypoints||n<0||n>=o.waypoints.length)return;let a=o.waypoints.filter((s,i)=>i!==n),r=Ye(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=ue(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=Ye(this.host.scene,t,u=>({...u,fixedSegments:l}));this.host.scene=c.scene,this.host.pushHistory(c.patch),this.host.notify()}};var bD=e=>{let t=e.viewport,n=t.size.width,o=t.size.height;if(n<=0||o<=0)return null;let a=qa(t),r=[z.applyToPoint(a,{x:0,y:0}),z.applyToPoint(a,{x:n,y:0}),z.applyToPoint(a,{x:0,y:o}),z.applyToPoint(a,{x:n,y:o})],s=j.fromPoints(r);return j.expand(s,Math.max(s.width,s.height)*.05)},cg=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=ze(o)?cg(e,o.id):N(o);a&&(n=n?j.union(n,a):a)}return n},AD=(e,t)=>{let n=null;for(let o of t){let a=I(e,o);if(!a)continue;let r=ze(a)?cg(e,a.id):N(a);r&&(n=n?j.union(n,r):r)}return n};var vD=e=>{let t=null;for(let n of e.elements.values())cc(e,n)&&(t??=new Set,t.add(n.id));return t??void 0};var SD=(e,t,n,o,a)=>{let r=F0(e,o,Ov),s=a==="replace"?Pe:t;for(let i of r)n(i.layerId)||(s=Xt(s,i.id));return s},LD=(e,t,n,o,a)=>{let r=a==="replace"?Pe:t,s=F0(e,o,Ov);for(let i of s)n(i.layerId)||(r=Xt(r,i.id));return r},IV=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,ZS=(e,t,n,o,a)=>{let r=a==="replace"?gt:t;for(let s of e.links.values()){if(n(s.layerId))continue;let i=ut(e,s);!i||i.length<2||i.every(l=>IV(l,o))&&(r=IS(r,s.id))}return r};var XS=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:e.x,y:0}:{x:0,y:e.y},kD=(e,t,n,o)=>{let a=I(e,t);if(!a)return null;let r=N(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}},_D=(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},wD=(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=Va(e,t,l=>({...l,position:s}));return{scene:i.scene,patch:i.patch}};var YS=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(a)}return n},KS=e=>e.map(t=>N(t)).reduce((t,n)=>j.union(t,n)),TD=(e,t,n)=>{let o=YS(e,t);if(o.length===0)return[];let a=KS(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},ED=(e,t,n)=>{let o=YS(e,t);if(o.length<2)return[];let a=KS(o),r=[];for(let s of o){let i=N(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},CD=(e,t,n)=>{let o=YS(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:N(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},$S=(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},ID=e=>{let t=KS(e);return{x:t.x+t.width/2,y:t.y+t.height/2}};var ug=(e,t)=>({x:Math.round(e.x/t)*t,y:Math.round(e.y/t)*t}),OD=(e,t,n)=>{let o=ug({x:e.x+t.x,y:e.y+t.y},n);return{x:o.x-e.x,y:o.y-e.y}},DD=(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=ug({x:o+t.x,y:a+t.y},n);return{x:r.x-o,y:r.y-a}},MD=new Set(["nw","w","sw"]),MV=new Set(["ne","e","se"]),RD=new Set(["nw","n","ne"]),RV=new Set(["sw","s","se"]),QS=(e,t,n,o)=>{let a=n.x,r=n.y;if(MD.has(t)||MV.has(t)){let s=MD.has(t)?e.x:e.x+e.width;a=Math.round((s+n.x)/o)*o-s}if(RD.has(t)||RV.has(t)){let s=RD.has(t)?e.y:e.y+e.height;r=Math.round((s+n.y)/o)*o-s}return{x:a,y:r}},PD=(e,t)=>{let n=ug({x:e.x,y:e.y},t),o=ug({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 OV=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"]),DV=Object.freeze(new Set),Oi=()=>typeof performance<"u"?performance.now():Date.now(),Kp=class{host;mainTarget;overlayTarget;backgroundTarget;onAfterRender;debugHitZones=!1;_readOnly=!1;actor;listeners=new Set;events=mS();eventCache=V9();unbind;_scene;_selection=Pe;interaction=new Qy;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=gt;_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(On);nextId=0;uniqueId(t){return`${t}-${++this.nextId}-${Date.now().toString(36)}`}snapEngine=new ap([XA,YA,KA]);snapThreshold=12;styleClipboard=null;boundsCache=new ts;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=Jy(this._brushSettings);return{origin:t.origin,points:DS(t,n).points,fill:Hf(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??DV}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 Gy({getScene:()=>this._scene,compact:t=>{this.compactLayerZOrder(t,{recordHistory:!1})}});autoLayoutScheduler=new Wy({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()}});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;_lastActiveTool=null;_activeToolCache={type:I0,locked:!1,lastActiveTool:null};fileDropRegistry=new Up;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=PV(t.history)?t.history:new Hp(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(),LS(this),kS(this),this.maybeAnimate(),this.animationContentOff=U2(()=>{this.scheduleRender()}),this.forceRender(),Z9(this.eventCache,this.observableSnapshot())}initControllers(){let t=this;this.gestures=new jy({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.activeTool.type},setMode:n=>{t.setActiveTool(n)},notify:()=>{t.notify()}}),this.textEdit=new ig({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 lg({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 Yy(n=>this.screenToWorld(n),n=>{for(let o of this.longPressListeners)o(n)}),this.pinch=new Ky(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&&Pp(t.textShaper),t.rasterizer&&Bp(t.rasterizer),kA((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"?jI:Ko,this.edgeHitThreshold=this.inputMode==="touch"?ZI:J0,this.anchorStartHitSlop=this.inputMode==="touch"?XI:ey,this.anchorClickRadius=this.inputMode==="touch"?YI:ty}initActor(t){this.actor=ea(z5),this.actor.subscribe({next:()=>{this.scheduleRender()}}),this.actor.on("*",n=>{this.applyEmit(n)}),this.actor.start(),this.fileDropRegistry.register(P9),this.fileDropRegistry.register(N9),this._readOnly=t.readOnly??!1,t.initialTool&&this.actor.send({type:"SET_MODE",mode:t.initialTool})}snapshotCache=null;observableSnapshot(){let t=this.activeTool,n=this._selection,o=this._selectedLinks,a=this._scene,r=this.canUndo,s=this.canRedo,i=this.snapshotCache;if(i!==null&&i.activeTool===t&&i.selection===n&&i.selectedLinks===o&&i.scene===a&&i.canUndo===r&&i.canRedo===s)return i;let l={activeTool: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 activeTool(){let t=this.actor.getSnapshot().context.mode,n=this._activeToolCache;return(n.type!==t||n.locked!==this._toolLocked||n.lastActiveTool!==this._lastActiveTool)&&(this._activeToolCache={type:t,locked:this._toolLocked,lastActiveTool:this._lastActiveTool}),this._activeToolCache}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=xO(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=bO(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=AO(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=vO(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=SO(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}hitAnnotation(t){return LO(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 selectedLinks(){return this._selectedLinks}get selectedLink(){return this._selection.size>0?null:AR(this._selectedLinks)}updateSelectedLink(t){if(this.readOnly)return;let n=this.selectedLink;if(n===null)return;let o=Ye(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())}maybeRevertToolAfterCreate(){this.gestures.maybeRevertModeAfterCreate()}setActiveTool(t){let n=this.actor.getSnapshot().context.mode;n!==t&&(this._lastActiveTool=n),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=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=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=X9(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 Y9(this._scene,t,n,()=>++this.nextId);return this._scene=o.scene,this._history.push(o.patch),o.id}animation=new Vy({hasVisibleAnimatedElement:()=>$9(this)||this.hasActiveLaser(),autoStopHeavyGifs:()=>{Q9(this)},forceAnimationRepaint:()=>{this.lastRenderedScene=null,this.render()}});hasAnimatedElement(){return Xy(this._scene)}maybeAnimate(){this.animation.maybe()}gifPlayback=new Zy;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}=$O(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=KO(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}=QO(this._scene,t.id);this._scene=i,n.cancel(),this._selection=Pe,this.notify()}}}deleteSelected(){if(this.readOnly)return;let t=eg(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=gt,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){ue(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=ue(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=Ye(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=ue(this._scene,t);if(!n)return null;let o=_o(this._scene,n);return!o||o.length<2?null:uc(o,n)}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=_O(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 kO(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?NR(this._scene,n,t,i=>this.isLayerLocked(i)):null,a=o?o.scene:this._scene,r=hR(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(jR(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=qS(++this.nextId),a=ZO(this._scene,this.activeTool.type,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=qS(++this.nextId),o=XO(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.maybeRevertToolAfterCreate(),this.notify(),this.announce(`Created text ${n}`),this.beginTextEdit(n),n}_brushSettings=Gc;get brushSettings(){return this._brushSettings}setBrushSettings(t){this._brushSettings={...this._brushSettings,...t},this.notify()}beginBrushStroke(t,n=.5,o="pen"){this.brushStroke=RR(t,n,this._brushSettings.width,o!=="pen"),this.notify()}extendBrushStroke(t,n=.5){this.brushStroke&&(OR(this.brushStroke,t,n,this._scene.viewport.zoom||1),this.notify())}commitBrushStroke(){let t=PR(this._scene,this.brushStroke,this._activeLayerId,PS(++this.nextId),Jy(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=ZR(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=[By(t,Oi())],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(!Mn(i))continue;let l=t.erased.get(i.id)??[],c=nO(i,l,n,o,r);(c.length>l.length||HS(c)>HS(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=XR(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?(X2(i,t,Oi()),this.interaction.eraserTrail=s.slice()):this.interaction.eraserTrail=[By(t,Oi())],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=oO(o,t.erased,()=>PS(++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=Pf(i,l);for(let l of r)i=Pf(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,By(t,Oi())],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&&(X2(o,t,Oi()),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=Y2(t,Oi());o.changed&&(this.interaction.laserStrokes=o.strokes)}let n=this.interaction.eraserTrail;if(n.length>0){let o=Y2(n,Oi(),iy);o.changed&&(this.interaction.eraserTrail=o.strokes)}}arrangeAsGrid(t={}){let n=this.combinedSelectionBounds()??{x:0,y:0},o=OO(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=DO(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=BO(this._scene,this._selection,FO(++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=NO(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 US(this._scene,this._selection)}expandSelectionWithDescendants(){return PO(this._scene,this._selection)}focusCycle(t){let n=[...this._selection][0],o=zO(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=gt,this.notify(),this.announce("Selection cleared")}duplicateSelected(){if(this.readOnly)return;let t=zR(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=BS(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=tD(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=BS(i)),this.notify(),t!==null?a.get(t)??null:null}setSelection(t){let n=FR(this._scene,t,this._selection);n&&(this._selection=n,this._selectedLinks.size>0&&(this._selectedLinks=gt),this.notify())}selectLink(t){let n=t===null?gt:$y(t),o=!Vp(n,this._selectedLinks),a=this._selection.size>0;!o&&!a||(this._selection=Pe,this._selectedLinks=n,this.notify())}selectAll(){let t=HR(this._scene,this._selection),n=UR(this._scene),o=!Vp(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=lO(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=cO(this._scene,this._history,this.clipboard,n??null,()=>++this.nextId);this._scene=o.scene,this._selection=uO(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=GR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}setBrushWidth(t,n){if(this.readOnly)return;let o=BR(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=WR(this._scene,t,n,o,a);r&&(this._scene=r.scene,this._history.push(r.patch),this.notify())}pickColorAt(t,n="fill"){return VS(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=VS(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}),n)}convertSelection(t){if(this.readOnly)return;let n=oD(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=uD(this._scene,o,t,Wc(++this.nextId),Yp(++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,z4):1,{elements:s,links:i}=dD(this._scene,o,t,r,()=>Wc(++this.nextId),()=>Yp(++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=pi(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=ii(r.from),i=ii(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=NS(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??ag,position:n.position,width:n.width,height:n.height,drag:null,dragStartWorld:null},this.setActiveTool("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=sD(a),s=this._scene.viewport.zoom||1,i=Z4/s;for(let c of rD){let u=r[c];if(Math.hypot(t.x-u.x,t.y-u.y)<=i)return c}let l=ci(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??ag;if(n.drag.kind==="handle"){let r=iD(o,a,n.drag.handle,t);this.cropSession={...n,crop:r.crop,position:r.position,width:r.width,height:r.height}}else{let r=lD(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=cD(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.setActiveTool("select"),this.refreshCursor(),this.notify()}cancelImageCrop(){this.cropSession!==null&&(this.cropSession=null,this.setActiveTool("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=>Rn(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??ag;return{element:n,fullRect:rg(n,o)}}updateTextProps(t,n){if(this.readOnly)return;let o=qR(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}adjustSelectionFontSize(t){if(this.readOnly)return;let n=VR(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:UO(n),a=GO(this._scene,t,o);a&&(this._scene=a.scene,this._history.push(a.patch),this.notify())}openLink(t){let n=og(t);!n||typeof window>"u"||window.open(n,"_blank","noopener,noreferrer")}elementLink(t){return og(I(this._scene,t)?.href)}linkAt(t){let n=this.acceleratedElementAt(t);if(!n||!this.isElementInteractable(n))return null;let o=og(n.href);return o?{id:n.id,href:o,bounds:N(n)}:null}bringToFront(t){if(this.readOnly)return;let n=EO(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=CO(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=IO(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=MO(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}flipSelection(t){this.commitArrange(TD(this._scene,this._selection,t))}alignSelection(t){this.commitArrange(ED(this._scene,this._selection,t))}distributeSelection(t){this.commitArrange(CD(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=ID(n);this.commitArrange($S(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=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(RO(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=gt,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=dO(this._scene,t,gO(++this.nextId));return this._scene=n.scene,this._history.push(n.patch),this._activeLayerId=n.layerId,this.notify(),n.layerId}removeLayer(t){let n=fO(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=pO(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}toggleLayerVisibility(t){let n=hO(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}toggleLayerLock(t){let n=mO(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}moveSelectionToLayer(t){if(this.readOnly)return;let n=yO(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=vR(this._scene,t);n&&(this._scene=n,this.notify())}zoomIn(){this.zoomStep(Iv)}zoomOut(){this.zoomStep(1/Iv)}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=LR(this._scene);t&&(this._scene=t,this.notify())}zoomToFit(t=40){let n=_R(this._scene,t);n&&(this._scene=n,this.notify())}zoomToSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=RS(this._scene,n,t);o&&(this._scene=o,this.notify())}revealSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=kR(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=NS(this._scene,this._selection,t,a,s=>this.isElementInteractable(s));r!==null&&this.setSelection([r])}zoomAt(t,n){let o=SR(this._scene,t,n);o&&(this._scene=o,this.notify())}setViewportSize(t,n){let o=wR(this._scene,t,n);o&&(this._scene=o,this.notify())}setGrid(t){let n=TR(this._scene,t);n&&(this._scene=n,this.notify())}get snapToGridEnabled(){return q0(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&&q0(t)}snapSpacing(){return $A()}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(On)}n.preserveHistory?this.pruneSelection():(this._selection=Pe,this._history.clear()),LS(this),kS(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 MR(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 z.applyToPoint(qa(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:N(o)}}}hitTest(t){return yM(t,{scene:this._scene,selection:this._selection,selectionChromeActive:this.activeTool.type==="select",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=wO(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)||cc(this._scene,t))}isElementManipulable(t){return!(this.isLayerLocked(t.layerId)||IA(this._scene,t)||cc(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=$(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 F9(this._scene,t,this._enteredGroup)}topGroupAncestor(t){return z9(this._scene,t)}isDescendantOfGroup(t,n){return SS(this._scene,t,n)}computeHiddenElements(){return vD(this._scene)}computeStrokeErasePreview(){let t=this.eraseStroke;if(!t||!t.strokeMode||t.erased.size===0)return null;let n=aO(this._scene,t.erased);return n?{elements:n.fragments,hidden:n.hidden}:null}computeDimElements(t){return H9(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<Rv?ui(this._scene,t):OA(this._scene,this.ensureSpatialIndex(),t)}ensureSpatialIndex(){let t=this.spatialIndexCache;if(t?.scene===this._scene)return t.index;let n=RA(this._scene);return this.spatialIndexCache={scene:this._scene,index:n},n}routeIsolationClick(t,n){let o=performance.now(),a=o-this.interaction.lastClickAt<bc&&this.interaction.lastClickWorldPoint!==null&&W.distance(this.interaction.lastClickWorldPoint,n)<=Ac;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=$y(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&&pe(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=gt),this.notify(),!0}}return!1}pickDrillTarget(t,n){return U9(this._scene,t,n,this._enteredGroup)}applyEmit(t){if(!(this._readOnly&&OV.has(t.type)))switch(t.type){case"SELECT_REPLACE":this._selection=wt(t.id),this._selectedLinks=gt,this.notify();return;case"SELECT_TOGGLE":this._selection=pA(this._selection,t.id),this.notify();return;case"SELECT_CLEAR":this._selection=Pe,this._selectedLinks=gt,this.notify();return;case"SELECT_EDGE_REPLACE":this._selectedLinks=$y(t.id),this._selection=Pe,this.notify();return;case"SELECT_EDGE_TOGGLE":this._selectedLinks=bR(this._selectedLinks,t.id),this.notify();return;case"SELECT_EDGE_CLEAR":this._selectedLinks.size>0&&(this._selectedLinks=gt,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=wD(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?XS(n):n,s=this.snapActive()?OD(o,r,this.snapSpacing()):r,i=kD(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.interaction.transformShiftKey?XS(t):t,o=this.snapActive()?DD(this.groupMoveOrigin,n,this.snapSpacing()):n,a=_D(this._scene,this.groupMoveOrigin,o);for(let r of a)this._scene=J(this._scene,r),this.recordGesturePatch(r);if(this.groupLinkMoveOrigin){let r=pR(this._scene,this.groupLinkMoveOrigin,o);for(let s of r)this._scene=J(this._scene,s),this.recordGesturePatch(s)}this.notify()}computeViewportWorld(){return bD(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}=eR(t,n);if(this.tileComposeFn!==null)for(let[r,s]of a)this.tileDirtyElements.set(r,s);return o}combinedSelectionBounds(){let t=AD(this._scene,this._selection);for(let n of this._selectedLinks){let o=ue(this._scene,n);if(!o)continue;let a=ut(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?j.union(t,c):c}return t}groupChildrenUnion(t){return cg(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/xv)*xv:t,a=$S(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()?QS(o,t,n,this.snapSpacing()):n,r=xR(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&&!pe(r)&&r.rotation!==0){this.interaction.resizeOriginElement?.id!==t&&(this.interaction.resizeOriginElement=r);let l=yR(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()?QS(a,n,o,this.snapSpacing()):o;if(r!==void 0&&pe(r)){this.interaction.resizeOriginElement?.id!==t&&(this.interaction.resizeOriginElement=r);let l=this.interaction.resizeOriginElement,c=pe(l)?l:r,u=gR(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=mR(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=Wc(++this.nextId),a=this.snapActive()?PD(n,this.snapSpacing()):n,r=jO(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.maybeRevertToolAfterCreate(),this.notify()}nextFrameName(){return G9(this._scene)}assignFrameMembers(t,n){this._scene=W9(this._scene,this._history,t,n)}reconcileFrameMembership(){this._scene=q9(this._scene,this._history)}applyCreateLink(t){let n=this.snapLinkEndpoint(t.fromElement,t.fromPoint),o=this.snapLinkEndpoint(t.toElement,t.toPoint),a=Yp(++this.nextId),r=Xp(this._scene,n,o,a,this._activeLayerId);this._scene=r.scene,this._history.push(r.patch),this.edgePreview=null,this.maybeRevertToolAfterCreate(),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(!ue(this._scene,n.linkId)){this.interaction.pendingLinkDropMenu=null,this.notify();return}let a=Wc(++this.nextId),r=nD(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=gt,this.notify()}dismissLinkDropMenu(){this.interaction.pendingLinkDropMenu&&(this.interaction.pendingLinkDropMenu=null,this.notify())}createLinkedElementFromAnchor(t,n){let o=Wc(++this.nextId),a=Yp(++this.nextId),r=eD(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=gt),this.notify()}previewClickCreate(t,n){return JO(this._scene,this._activeLayerId,t,n)}snapLinkEndpoint(t,n){return WO(this._scene,this.snapEngine,this.snapThreshold,t,n)}applySelectByBounds(t,n){let o=SD(this._scene,this._selection,s=>this.isLayerLocked(s),t,n),a=ZS(this._scene,n==="add"?this._selectedLinks:gt,s=>this.isLayerLocked(s),t,n),r=!Vp(a,this._selectedLinks);if(this._selectedLinks=a,ai(o,this._selection)&&!r){this.notify();return}this._selection=o,this.notify()}applyLassoLiveSelection(t,n){let o=this.interaction.lassoBaseSelection??Pe,a=LD(this._scene,o,l=>this.isLayerLocked(l),t,n),r=this.interaction.lassoBaseLinks??gt,s=ZS(this._scene,r,l=>this.isLayerLocked(l),t,n),i=!Vp(s,this._selectedLinks);ai(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)}get isDraggingLabel(){return this.linkHandles.isDraggingLabel}beginLabelDrag(t){this.linkHandles.beginLabelDrag(t)}updateLabelDrag(t){this.linkHandles.updateLabelDrag(t)}endLabelDrag(){this.linkHandles.endLabelDrag()}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:ue(this._scene,t)?.avoidObstacles===!0}setSelectedLinkAvoidObstacles(t){if(this.readOnly)return;let n=this.selectedLink;if(n===null)return;let o=ue(this._scene,n);if(!o||o.avoidObstacles===t)return;let a=Ye(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=LA(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=yD(this._scene,t,n,o);if(mi==="orthogonal"){let r=this.hitTest(a.to),s=r.kind==="element"?r.id:null,i=gv(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,yc(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){nR(this.containerOpsRef,t)}maybeGrowContainer(t,n){Wp(this.containerOpsRef,t,n)}clampContainerToChildren(t,n,o){return tR(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(),j9(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=lp(this._scene,t);return n?(this._scene=J(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=xD(this._scene,o);if(this.elbowRoutes.get(n)?.sig===a)continue;let r=up(t,o);this.elbowRoutes.set(n,{sig:a,points:r}),t=Ye(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>=Rv?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.activeTool.type,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.activeTool.type==="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();hD(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?.()}},PV=e=>!e||typeof e!="object"?!1:typeof e.push=="function"&&typeof e.undo=="function"&&typeof e.redo=="function"&&typeof e.transaction=="function";var JS=P(se(),1),jc=P(re(),1),dg=({open:e,onClose:t,title:n="Dialog",children:o,dismissOnBackdrop:a=!0,className:r,style:s})=>{let i=(0,jc.useRef)(null),l=(0,jc.useRef)(null);if((0,jc.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,jc.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,JS.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":n,style:c,onClick:d=>{a&&d.target===d.currentTarget&&t()},children:(0,JS.jsx)("div",{ref:i,tabIndex:-1,className:r,style:u,onClick:d=>{d.stopPropagation()},children:o})})};var BV={history:"History",selection:"Selection",clipboard:"Clipboard","z-order":"Z-order",grouping:"Grouping",zoom:"Zoom",tool:"Tools",layout:"Layout",arrange:"Arrange",edit:"Editing",other:"Other"},NV=["tool","edit","selection","clipboard","history","z-order","grouping","arrange","layout","zoom","other"],eL=e=>{(0,Zc.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])},zV=e=>{let t=[],n=e.hotkey??e.displayHotkey;if(n){let o=Array.isArray(n)?n:[n];for(let a of o)t.push(Fy(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},$p=({registry:e=we,open:t,onClose:n,title:o="Keyboard shortcuts",extraSections:a})=>{let r=(0,Zc.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:zV(d)}),c.set(f,p)}let u=[];for(let d of NV){let f=c.get(d);!f||f.length===0||u.push({title:BV[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,Ke.jsx)(dg,{open:t,onClose:n,title:o,style:s,children:(0,Ke.jsxs)("div",{children:[(0,Ke.jsxs)("div",{style:i,children:[(0,Ke.jsx)("h2",{style:{margin:0,fontSize:16,fontWeight:600},children:o}),(0,Ke.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,Ke.jsx)("span",{className:"du-help-platform-badge",children:ss?"macOS":"Win / Linux"}),(0,Ke.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,Ke.jsx)(Fa,{size:18,strokeWidth:1.75})})]})]}),(0,Ke.jsx)("div",{style:l,children:(0,Ke.jsx)("div",{className:"du-help-islands",children:r.map(c=>(0,Ke.jsxs)("section",{className:"du-help-island",children:[(0,Ke.jsx)("h3",{className:"du-help-island-title",children:c.title}),(0,Ke.jsx)("div",{className:"du-help-island-rows",children:c.rows.map(u=>(0,Ke.jsxs)("div",{className:"du-help-row",children:[(0,Ke.jsx)("span",{className:"du-help-row-label",children:u.label}),(0,Ke.jsx)(FV,{combos:u.keys})]},u.label))})]},c.title))})})]})})},FV=({combos:e})=>e.length===0?(0,Ke.jsx)("span",{className:"du-help-keys-separator",children:"\u2014"}):(0,Ke.jsx)("span",{className:"du-help-keys",children:e.map((t,n)=>(0,Ke.jsxs)(Zc.Fragment,{children:[n>0?(0,Ke.jsx)("span",{className:"du-help-keys-separator",children:"or"}):null,t.map((o,a)=>(0,Ke.jsx)("kbd",{className:"du-help-key",children:o},a))]},n))});var HV=16,UV=1.75,fg=({renderDialog:e})=>{let[t,n]=(0,BD.useState)(!1);return(0,is.jsxs)(is.Fragment,{children:[(0,is.jsx)(Jn,{label:"Help",onClick:()=>{n(!0)},children:(0,is.jsx)(Cn,{size:HV,strokeWidth:UV})}),e?e({open:t,onClose:()=>{n(!1)}}):(0,is.jsx)($p,{open:t,onClose:()=>{n(!1)}})]})};var th=P(se(),1),zD=P(re(),1);var Qp=P(re(),1);var ND=`(pointer: coarse), (max-width: ${640}px)`,GV=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(ND).matches:!1,Jp=()=>(0,Qp.useSyncExternalStore)(e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};let t=window.matchMedia(ND);return t.addEventListener("change",e),()=>{t.removeEventListener("change",e)}},GV,()=>!1),U=()=>Yb(),WV=ov(),Ka=()=>sn(e=>e.scene,WV,"scene"),pg=()=>sn(e=>e.selection,Zo.EMPTY,"selection"),qV={type:"select",locked:!1,lastActiveTool:null},eh=()=>sn(e=>e.activeTool,qV,"tool"),tL=()=>sn(e=>e.brushSettings,Gc),ls=()=>sn(e=>e.readOnly,!1),nL=()=>{let e=U(),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 P0e=ln(On);var oL=()=>sn(e=>e.selectedLink,null);var VV=14,jV=1.75,aL=()=>{let e=U(),t=Ka(),n=(0,zD.useMemo)(()=>ZV(t),[t]);return!e||t.elements.size===0||!n?null:(0,th.jsxs)("button",{type:"button",className:"du-pill-button",onClick:()=>{e.zoomToFit()},title:"Reset view to fit all content",children:[(0,th.jsx)(ef,{size:VV,strokeWidth:jV,"aria-hidden":!0}),(0,th.jsx)("span",{children:"Back to content"})]})},ZV=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=N(c);n=n?j.union(n,u):u}if(!n)return!1;let o=qa(t),a=z.applyToPoint(o,{x:0,y:0}),r=z.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),$i=P(re(),1);var xt=P(se(),1),uo=P(re(),1);var hg=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()}},Di=new hg;var q0e={...os.rectangle},V0e={...os.sticky},j0e={...os.flowchart};var rL=(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 T={};yo(T,{BRAND:()=>bj,DIRTY:()=>Pi,EMPTY_PATH:()=>$V,INVALID:()=>Z,NEVER:()=>oZ,OK:()=>Wt,ParseStatus:()=>Bt,Schema:()=>le,ZodAny:()=>ds,ZodArray:()=>er,ZodBigInt:()=>Ni,ZodBoolean:()=>zi,ZodBranded:()=>oh,ZodCatch:()=>Yi,ZodDate:()=>Fi,ZodDefault:()=>Xi,ZodDiscriminatedUnion:()=>gg,ZodEffects:()=>co,ZodEnum:()=>ji,ZodError:()=>pn,ZodFirstPartyTypeKind:()=>Y,ZodFunction:()=>bg,ZodIntersection:()=>Wi,ZodIssueCode:()=>D,ZodLazy:()=>qi,ZodLiteral:()=>Vi,ZodMap:()=>Jc,ZodNaN:()=>tu,ZodNativeEnum:()=>Zi,ZodNever:()=>Io,ZodNull:()=>Ui,ZodNullable:()=>sa,ZodNumber:()=>Bi,ZodObject:()=>hn,ZodOptional:()=>io,ZodParsedType:()=>H,ZodPipeline:()=>ah,ZodPromise:()=>fs,ZodReadonly:()=>Ki,ZodRecord:()=>xg,ZodSchema:()=>le,ZodSet:()=>eu,ZodString:()=>us,ZodSymbol:()=>$c,ZodTransformer:()=>co,ZodTuple:()=>ra,ZodType:()=>le,ZodUndefined:()=>Hi,ZodUnion:()=>Gi,ZodUnknown:()=>Ja,ZodVoid:()=>Qc,addIssueToContext:()=>F,any:()=>Ej,array:()=>Rj,bigint:()=>Lj,boolean:()=>YD,coerce:()=>nZ,custom:()=>jD,date:()=>kj,datetimeRegex:()=>qD,defaultErrorMap:()=>$a,discriminatedUnion:()=>Bj,effect:()=>Xj,enum:()=>Vj,function:()=>Gj,getErrorMap:()=>Xc,getParsedType:()=>aa,instanceof:()=>vj,intersection:()=>Nj,isAborted:()=>mg,isAsync:()=>Yc,isDirty:()=>yg,isValid:()=>cs,late:()=>Aj,lazy:()=>Wj,literal:()=>qj,makeIssue:()=>nh,map:()=>Hj,nan:()=>Sj,nativeEnum:()=>jj,never:()=>Ij,null:()=>Tj,nullable:()=>Kj,number:()=>XD,object:()=>Oj,objectUtil:()=>sL,oboolean:()=>tZ,onumber:()=>eZ,optional:()=>Yj,ostring:()=>Jj,pipeline:()=>Qj,preprocess:()=>$j,promise:()=>Zj,quotelessJson:()=>XV,record:()=>Fj,set:()=>Uj,setErrorMap:()=>KV,strictObject:()=>Dj,string:()=>ZD,symbol:()=>_j,transformer:()=>Xj,tuple:()=>zj,undefined:()=>wj,union:()=>Pj,unknown:()=>Cj,util:()=>he,void:()=>Mj});var he;(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})(he||(he={}));var sL;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(sL||(sL={}));var H=he.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),aa=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=he.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"]),XV=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,he.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 YV=(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,he.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:n=`Unrecognized key(s) in object: ${he.joinValues(e.keys,", ")}`;break;case D.invalid_union:n="Invalid input";break;case D.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${he.joinValues(e.options)}`;break;case D.invalid_enum_value:n=`Invalid enum value. Expected ${he.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}"`:he.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,he.assertNever(e)}return{message:n}},$a=YV;var FD=$a;function KV(e){FD=e}function Xc(){return FD}var nh=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}},$V=[];function F(e,t){let n=Xc(),o=nh({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===$a?void 0:$a].filter(a=>!!a)});e.common.issues.push(o)}var Bt=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"}),Pi=e=>({status:"dirty",value:e}),Wt=e=>({status:"valid",value:e}),mg=e=>e.status==="aborted",yg=e=>e.status==="dirty",cs=e=>e.status==="valid",Yc=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 lo=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}},HD=(e,t)=>{if(cs(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 aa(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:aa(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Bt,ctx:{common:t.parent.common,data:t.data,parsedType:aa(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(Yc(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:aa(t)},a=this._parseSync({data:t,path:o.path,parent:o});return HD(o,a)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:aa(t)};if(!this["~standard"].async)try{let o=this._parseSync({data:t,path:[],parent:n});return cs(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=>cs(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:aa(t)},a=this._parse({data:t,path:o.path,parent:o}),r=await(Yc(a)?a:Promise.resolve(a));return HD(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 co({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 io.create(this,this._def)}nullable(){return sa.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return er.create(this)}promise(){return fs.create(this,this._def)}or(t){return Gi.create([this,t],this._def)}and(t){return Wi.create(this,t,this._def)}transform(t){return new co({...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 oh({typeName:Y.ZodBranded,type:this,...ae(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new Yi({...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 ah.create(this,t)}readonly(){return Ki.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},QV=/^c[^\s-]{8,}$/i,JV=/^[0-9a-z]+$/,ej=/^[0-9A-HJKMNP-TV-Z]{26}$/i,tj=/^[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,nj=/^[a-z0-9_-]{21}$/i,oj=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,aj=/^[-+]?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)?)??$/,rj=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,sj="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",iL,ij=/^(?:(?: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])$/,lj=/^(?:(?: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])$/,cj=/^(([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]))$/,uj=/^(([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])$/,dj=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,fj=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,GD="((\\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])))",pj=new RegExp(`^${GD}$`);function WD(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 hj(e){return new RegExp(`^${WD(e)}$`)}function qD(e){let t=`${GD}T${WD(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 mj(e,t){return!!((t==="v4"||!t)&&ij.test(e)||(t==="v6"||!t)&&cj.test(e))}function yj(e,t){if(!oj.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 gj(e,t){return!!((t==="v4"||!t)&&lj.test(e)||(t==="v6"||!t)&&uj.test(e))}var us=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 Bt,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")rj.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")iL||(iL=new RegExp(sj,"u")),iL.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")tj.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")nj.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")QV.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")JV.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")ej.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"?qD(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"?pj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:"date",message:r.message}),o.dirty()):r.kind==="time"?hj(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"?aj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"duration",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="ip"?mj(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"?yj(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"?gj(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"?dj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"base64",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64url"?fj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"base64url",code:D.invalid_string,message:r.message}),o.dirty()):he.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}};us.create=e=>new us({checks:[],typeName:Y.ZodString,coerce:e?.coerce??!1,...ae(e)});function xj(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 Bi=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 Bt;for(let r of this._def.checks)r.kind==="int"?he.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"?xj(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()):he.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"&&he.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)}};Bi.create=e=>new Bi({checks:[],typeName:Y.ZodNumber,coerce:e?.coerce||!1,...ae(e)});var Ni=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 Bt;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()):he.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}};Ni.create=e=>new Ni({checks:[],typeName:Y.ZodBigInt,coerce:e?.coerce??!1,...ae(e)});var zi=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 Wt(t.data)}};zi.create=e=>new zi({typeName:Y.ZodBoolean,coerce:e?.coerce||!1,...ae(e)});var Fi=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 Bt,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()):he.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}};Fi.create=e=>new Fi({checks:[],coerce:e?.coerce||!1,typeName:Y.ZodDate,...ae(e)});var $c=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 Wt(t.data)}};$c.create=e=>new $c({typeName:Y.ZodSymbol,...ae(e)});var Hi=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 Wt(t.data)}};Hi.create=e=>new Hi({typeName:Y.ZodUndefined,...ae(e)});var Ui=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 Wt(t.data)}};Ui.create=e=>new Ui({typeName:Y.ZodNull,...ae(e)});var ds=class extends le{constructor(){super(...arguments),this._any=!0}_parse(t){return Wt(t.data)}};ds.create=e=>new ds({typeName:Y.ZodAny,...ae(e)});var Ja=class extends le{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Wt(t.data)}};Ja.create=e=>new Ja({typeName:Y.ZodUnknown,...ae(e)});var Io=class extends le{_parse(t){let n=this._getOrReturnCtx(t);return F(n,{code:D.invalid_type,expected:H.never,received:n.parsedType}),Z}};Io.create=e=>new Io({typeName:Y.ZodNever,...ae(e)});var Qc=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 Wt(t.data)}};Qc.create=e=>new Qc({typeName:Y.ZodVoid,...ae(e)});var er=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 lo(n,s,n.path,i)))).then(s=>Bt.mergeArray(o,s));let r=[...n.data].map((s,i)=>a.type._parseSync(new lo(n,s,n.path,i)));return Bt.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)}};er.create=(e,t)=>new er({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Y.ZodArray,...ae(t)});function Kc(e){if(e instanceof hn){let t={};for(let n in e.shape){let o=e.shape[n];t[n]=io.create(Kc(o))}return new hn({...e._def,shape:()=>t})}else return e instanceof er?new er({...e._def,type:Kc(e.element)}):e instanceof io?io.create(Kc(e.unwrap())):e instanceof sa?sa.create(Kc(e.unwrap())):e instanceof ra?ra.create(e.items.map(t=>Kc(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=he.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 Io&&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 lo(a,d,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof Io){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 lo(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=>Bt.mergeObjectSync(o,c)):Bt.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 he.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 he.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new e({...this._def,shape:()=>n})}deepPartial(){return Kc(this)}partial(t){let n={};for(let o of he.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 he.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let r=this.shape[o];for(;r instanceof io;)r=r._def.innerType;n[o]=r}return new e({...this._def,shape:()=>n})}keyof(){return VD(he.objectKeys(this.shape))}};hn.create=(e,t)=>new hn({shape:()=>e,unknownKeys:"strip",catchall:Io.create(),typeName:Y.ZodObject,...ae(t)});hn.strictCreate=(e,t)=>new hn({shape:()=>e,unknownKeys:"strict",catchall:Io.create(),typeName:Y.ZodObject,...ae(t)});hn.lazycreate=(e,t)=>new hn({shape:e,unknownKeys:"strip",catchall:Io.create(),typeName:Y.ZodObject,...ae(t)});var Gi=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}};Gi.create=(e,t)=>new Gi({options:e,typeName:Y.ZodUnion,...ae(t)});var Qa=e=>e instanceof qi?Qa(e.schema):e instanceof co?Qa(e.innerType()):e instanceof Vi?[e.value]:e instanceof ji?e.options:e instanceof Zi?he.objectValues(e.enum):e instanceof Xi?Qa(e._def.innerType):e instanceof Hi?[void 0]:e instanceof Ui?[null]:e instanceof io?[void 0,...Qa(e.unwrap())]:e instanceof sa?[null,...Qa(e.unwrap())]:e instanceof oh||e instanceof Ki?Qa(e.unwrap()):e instanceof Yi?Qa(e._def.innerType):[],gg=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=Qa(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 lL(e,t){let n=aa(e),o=aa(t);if(e===t)return{valid:!0,data:e};if(n===H.object&&o===H.object){let a=he.objectKeys(t),r=he.objectKeys(e).filter(i=>a.indexOf(i)!==-1),s={...e,...t};for(let i of r){let l=lL(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=lL(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 Wi=class extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t),a=(r,s)=>{if(mg(r)||mg(s))return Z;let i=lL(r.value,s.value);return i.valid?((yg(r)||yg(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}))}};Wi.create=(e,t,n)=>new Wi({left:e,right:t,typeName:Y.ZodIntersection,...ae(n)});var ra=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 lo(o,s,o.path,i)):null}).filter(s=>!!s);return o.common.async?Promise.all(r).then(s=>Bt.mergeArray(n,s)):Bt.mergeArray(n,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};ra.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ra({items:e,typeName:Y.ZodTuple,rest:null,...ae(t)})};var xg=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 lo(o,i,o.path,i)),value:s._parse(new lo(o,o.data[i],o.path,i)),alwaysSet:i in o.data});return o.common.async?Bt.mergeObjectAsync(n,a):Bt.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:us.create(),valueType:t,typeName:Y.ZodRecord,...ae(n)})}},Jc=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 lo(o,i,o.path,[c,"key"])),value:r._parse(new lo(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}}}};Jc.create=(e,t,n)=>new Jc({valueType:t,keyType:e,typeName:Y.ZodMap,...ae(n)});var eu=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 lo(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)}};eu.create=(e,t)=>new eu({valueType:e,minSize:null,maxSize:null,typeName:Y.ZodSet,...ae(t)});var bg=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 nh({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Xc(),$a].filter(c=>!!c),issueData:{code:D.invalid_arguments,argumentsError:l}})}function a(i,l){return nh({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Xc(),$a].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 fs){let i=this;return Wt(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 Wt(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:ra.create(t).rest(Ja.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||ra.create([]).rest(Ja.create()),returns:n||Ja.create(),typeName:Y.ZodFunction,...ae(o)})}},qi=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})}};qi.create=(e,t)=>new qi({getter:e,typeName:Y.ZodLazy,...ae(t)});var Vi=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}};Vi.create=(e,t)=>new Vi({value:e,typeName:Y.ZodLiteral,...ae(t)});function VD(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:he.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 Wt(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=VD;var Zi=class extends le{_parse(t){let n=he.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==H.string&&o.parsedType!==H.number){let a=he.objectValues(n);return F(o,{expected:he.joinValues(a),received:o.parsedType,code:D.invalid_type}),Z}if(this._cache||(this._cache=new Set(he.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let a=he.objectValues(n);return F(o,{received:o.data,code:D.invalid_enum_value,options:a}),Z}return Wt(t.data)}get enum(){return this._def.values}};Zi.create=(e,t)=>new Zi({values:e,typeName:Y.ZodNativeEnum,...ae(t)});var fs=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 Wt(o.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};fs.create=(e,t)=>new fs({type:e,typeName:Y.ZodPromise,...ae(t)});var co=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"?Pi(l.value):n.value==="dirty"?Pi(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"?Pi(i.value):n.value==="dirty"?Pi(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(!cs(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=>cs(s)?Promise.resolve(a.transform(s.value,r)).then(i=>({status:n.value,value:i})):Z);he.assertNever(a)}};co.create=(e,t,n)=>new co({schema:e,typeName:Y.ZodEffects,effect:t,...ae(n)});co.createWithPreprocess=(e,t,n)=>new co({schema:t,effect:{type:"preprocess",transform:e},typeName:Y.ZodEffects,...ae(n)});var io=class extends le{_parse(t){return this._getType(t)===H.undefined?Wt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};io.create=(e,t)=>new io({innerType:e,typeName:Y.ZodOptional,...ae(t)});var sa=class extends le{_parse(t){return this._getType(t)===H.null?Wt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};sa.create=(e,t)=>new sa({innerType:e,typeName:Y.ZodNullable,...ae(t)});var Xi=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}};Xi.create=(e,t)=>new Xi({innerType:e,typeName:Y.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ae(t)});var Yi=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 Yc(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}};Yi.create=(e,t)=>new Yi({innerType:e,typeName:Y.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ae(t)});var tu=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}}};tu.create=e=>new tu({typeName:Y.ZodNaN,...ae(e)});var bj=Symbol("zod_brand"),oh=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}},ah=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(),Pi(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})}},Ki=class extends le{_parse(t){let n=this._def.innerType._parse(t),o=a=>(cs(a)&&(a.value=Object.freeze(a.value)),a);return Yc(n)?n.then(a=>o(a)):o(n)}unwrap(){return this._def.innerType}};Ki.create=(e,t)=>new Ki({innerType:e,typeName:Y.ZodReadonly,...ae(t)});function UD(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function jD(e,t={},n){return e?ds.create().superRefine((o,a)=>{let r=e(o);if(r instanceof Promise)return r.then(s=>{if(!s){let i=UD(t,o),l=i.fatal??n??!0;a.addIssue({code:"custom",...i,fatal:l})}});if(!r){let s=UD(t,o),i=s.fatal??n??!0;a.addIssue({code:"custom",...s,fatal:i})}}):ds.create()}var Aj={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 vj=(e,t={message:`Input not instance of ${e.name}`})=>jD(n=>n instanceof e,t),ZD=us.create,XD=Bi.create,Sj=tu.create,Lj=Ni.create,YD=zi.create,kj=Fi.create,_j=$c.create,wj=Hi.create,Tj=Ui.create,Ej=ds.create,Cj=Ja.create,Ij=Io.create,Mj=Qc.create,Rj=er.create,Oj=hn.create,Dj=hn.strictCreate,Pj=Gi.create,Bj=gg.create,Nj=Wi.create,zj=ra.create,Fj=xg.create,Hj=Jc.create,Uj=eu.create,Gj=bg.create,Wj=qi.create,qj=Vi.create,Vj=ji.create,jj=Zi.create,Zj=fs.create,Xj=co.create,Yj=io.create,Kj=sa.create,$j=co.createWithPreprocess,Qj=ah.create,Jj=()=>ZD().optional(),eZ=()=>XD().optional(),tZ=()=>YD().optional(),nZ={string:(e=>us.create({...e,coerce:!0})),number:(e=>Bi.create({...e,coerce:!0})),boolean:(e=>zi.create({...e,coerce:!0})),bigint:(e=>Ni.create({...e,coerce:!0})),date:(e=>Fi.create({...e,coerce:!0}))};var oZ=Z;var rZ=["basic","layout","flowchart","custom","rich"],cL=({registry:e=Di,categories:t=rZ,collapsedByDefault:n=[],searchQuery:o,layout:a="grid",style:r,className:s})=>{let i=a==="list"?"du-palette-list":"du-palette-grid",l=(0,uo.useMemo)(()=>new Set(e.categories()),[e]),c=(0,uo.useMemo)(()=>t.filter(x=>l.has(x)),[t,l]),u=(0,uo.useMemo)(()=>c.map(x=>({category:x,items:e.byCategory(x)})),[e,c]),[d,f]=(0,uo.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,uo.useMemo)(()=>{if(!h)return[];let x=[];for(let{items:y}of u)for(let g of y)rL(g,h)&&x.push(g);return x},[u,h]);return(0,xt.jsx)("aside",{className:`du-palette ${s??""}`.trim(),style:r,children:(0,xt.jsx)("div",{className:"du-palette-body",children:h?m.length===0?(0,xt.jsxs)("div",{className:"du-palette-empty",children:["No templates match \u201C",h,"\u201D"]}):(0,xt.jsx)("div",{className:i,children:m.map(x=>(0,xt.jsx)(JD,{template:x},x.id))}):u.map(({category:x,items:y})=>(0,xt.jsx)(sZ,{category:x,items:y,itemsClass:i,collapsed:d.has(x),onToggle:()=>{p(x)}},x))})})},sZ=({category:e,items:t,itemsClass:n,collapsed:o,onToggle:a})=>t.length===0?null:(0,xt.jsxs)("section",{className:"du-palette-section",children:[(0,xt.jsxs)("button",{type:"button",onClick:a,"aria-expanded":!o,className:"du-palette-category",children:[(0,xt.jsx)("span",{children:e}),(0,xt.jsx)("span",{className:"du-palette-category-caret","aria-hidden":!0,children:o?(0,xt.jsx)(Ys,{size:12,strokeWidth:1.75}):(0,xt.jsx)(Dd,{size:12,strokeWidth:1.75})})]}),o?null:(0,xt.jsx)("div",{className:n,children:t.map(r=>(0,xt.jsx)(JD,{template:r},r.id))})]}),rh=null,$D=yS(),KD=e=>{rh!==e&&(rh=e,$D.emit())};var QD=e=>$D.add(e);var Ag=null,iZ=()=>{if(typeof document>"u")return null;if(Ag&&document.body.contains(Ag))return Ag;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),Ag=e,e},JD=({template:e})=>{let t=U(),n=r=>{r.dataTransfer.setData("application/x-template-id",e.id),r.dataTransfer.effectAllowed="copy";let s=iZ();s&&r.dataTransfer.setDragImage(s,0,0),KD(e)},o=()=>{KD(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:On,position:i,order:Ae([...t.scene.elements.values()].filter(d=>d.layerId===On).map(d=>d.order))}),u=t.beginPlacement(c);u.update(i),u.commit()};return(0,xt.jsxs)("div",{role:"button",draggable:!0,title:e.name,onDragStart:n,onDragEnd:o,onClick:a,className:"du-palette-item",children:[(0,xt.jsx)("span",{className:"du-palette-item-icon",style:{width:28,height:28},dangerouslySetInnerHTML:{__html:e.icon}}),(0,xt.jsx)("span",{className:"du-palette-item-label",children:e.name})]})},uL=()=>{let e=U(),t=(0,uo.useRef)(null);(0,uo.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,uo.useEffect)(()=>QD(()=>{rh===null&&t.current&&(t.current.cancel(),t.current=null)}),[]);let n=a=>{if(t.current||!e||!rh)return!1;let r=rh,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:On,position:l,order:Ae([...e.scene.elements.values()].filter(d=>d.layerId===On).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 AS(r,{onError:(c,u)=>{console.warn(`[file-drop] failed at ${c}:`,u)}}))e.dispatchFileDrop(l,i)})()}}};var dL=14,fL=1.75,vg=({open:e,onClose:t,side:n="right",sheet:o=!1,onImport:a,style:r})=>{let[s,i]=(0,$i.useState)("");(0,$i.useEffect)(()=>{e||i("")},[e]);let l=(0,$i.useRef)(null);return(0,$i.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)(Jn,{label:"Import templates",size:"sm",onClick:a,children:(0,mn.jsx)(kf,{size:dL,strokeWidth:fL})}):null,(0,mn.jsx)(Jn,{label:"Close library",size:"sm",onClick:t,children:(0,mn.jsx)(Fa,{size:dL,strokeWidth:fL})})]})}),(0,mn.jsxs)("div",{className:"du-side-panel-search",children:[(0,mn.jsx)(yf,{size:dL,strokeWidth:fL,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)(cL,{searchQuery:s,layout:"list"})})]}):null};var hh=P(se(),1);var nu=Math.min,tr=Math.max,ih=Math.round,lh=Math.floor,Mo=e=>({x:e,y:e}),lZ={left:"right",right:"left",bottom:"top",top:"bottom"};function pL(e,t,n){return tr(e,nu(t,n))}function ch(e,t){return typeof e=="function"?e(t):e}function ps(e){return e.split("-")[0]}function uh(e){return e.split("-")[1]}function hL(e){return e==="x"?"y":"x"}function mL(e){return e==="y"?"height":"width"}function nr(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function yL(e){return hL(nr(e))}function n8(e,t,n){n===void 0&&(n=!1);let o=uh(e),a=yL(e),r=mL(a),s=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(s=sh(s)),[s,sh(s)]}function o8(e){let t=sh(e);return[Sg(e),t,Sg(t)]}function Sg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var e8=["left","right"],t8=["right","left"],cZ=["top","bottom"],uZ=["bottom","top"];function dZ(e,t,n){switch(e){case"top":case"bottom":return n?t?t8:e8:t?e8:t8;case"left":case"right":return t?cZ:uZ;default:return[]}}function a8(e,t,n,o){let a=uh(e),r=dZ(ps(e),n==="start",o);return a&&(r=r.map(s=>s+"-"+a),t&&(r=r.concat(r.map(Sg)))),r}function sh(e){let t=ps(e);return lZ[t]+e.slice(t.length)}function fZ(e){return{top:0,right:0,bottom:0,left:0,...e}}function r8(e){return typeof e!="number"?fZ(e):{top:e,right:e,bottom:e,left:e}}function Qi(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 s8(e,t,n){let{reference:o,floating:a}=e,r=nr(t),s=yL(t),i=mL(s),l=ps(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(uh(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 i8(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}=ch(t,e),h=r8(p),x=i[f?d==="floating"?"reference":"floating":d],y=Qi(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},_=Qi(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 pZ=50,l8=async(e,t,n)=>{let{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:s}=n,i=s.detectOverflow?s:{...s,detectOverflow:i8},l=await(s.isRTL==null?void 0:s.isRTL(t)),c=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:u,y:d}=s8(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:C}=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],..._},C&&p<pZ&&(p++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:a}):C.rects),{x:u,y:d}=s8(c,f,l)),m=-1)}return{x:u,y:d,placement:f,strategy:a,middlewareData:h}};var c8=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}=ch(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let y=ps(a),g=nr(i),b=ps(i)===i,A=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=f||(b||!m?[sh(i)]:o8(i)),C=h!=="none";!f&&C&&_.push(...a8(i,m,h,A));let w=[i,..._],L=await l.detectOverflow(t,x),k=[],M=((o=r.flip)==null?void 0:o.overflows)||[];if(u&&k.push(L[y]),d){let ne=n8(a,s,A);k.push(L[ne[0]],L[ne[1]])}if(M=[...M,{placement:a,overflows:k}],!k.every(ne=>ne<=0)){var B,G;let ne=(((B=r.flip)==null?void 0:B.index)||0)+1,V=w[ne];if(V&&(!(d==="alignment"?g!==nr(V):!1)||M.every(ee=>nr(ee.placement)===g?ee.overflows[0]>0:!0)))return{data:{index:ne,overflows:M},reset:{placement:V}};let ve=(G=M.filter(ge=>ge.overflows[0]<=0).sort((ge,ee)=>ge.overflows[1]-ee.overflows[1])[0])==null?void 0:G.placement;if(!ve)switch(p){case"bestFit":{var ie;let ge=(ie=M.filter(ee=>{if(C){let Se=nr(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];ge&&(ve=ge);break}case"initialPlacement":ve=i;break}if(a!==ve)return{reset:{placement:ve}}}return{}}}};var hZ=new Set(["left","top"]);async function mZ(e,t){let{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),s=ps(n),i=uh(n),l=nr(n)==="y",c=hZ.has(s)?-1:1,u=r&&l?-1:1,d=ch(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 u8=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 mZ(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}}}}},d8=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}=ch(e,t),u={x:n,y:o},d=await r.detectOverflow(t,c),f=nr(ps(a)),p=hL(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=pL(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=pL(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 el(e){return p8(e)?(e.nodeName||"").toLowerCase():"#document"}function yn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ro(e){var t;return(t=(p8(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function p8(e){return Lg()?e instanceof Node||e instanceof yn(e).Node:!1}function fo(e){return Lg()?e instanceof Element||e instanceof yn(e).Element:!1}function ia(e){return Lg()?e instanceof HTMLElement||e instanceof yn(e).HTMLElement:!1}function f8(e){return!Lg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yn(e).ShadowRoot}function au(e){let{overflow:t,overflowX:n,overflowY:o,display:a}=po(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&a!=="inline"&&a!=="contents"}function h8(e){return/^(table|td|th)$/.test(el(e))}function dh(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var yZ=/transform|translate|scale|rotate|perspective|filter/,gZ=/paint|layout|strict|content/,Ji=e=>!!e&&e!=="none",gL;function kg(e){let t=fo(e)?po(e):e;return Ji(t.transform)||Ji(t.translate)||Ji(t.scale)||Ji(t.rotate)||Ji(t.perspective)||!_g()&&(Ji(t.backdropFilter)||Ji(t.filter))||yZ.test(t.willChange||"")||gZ.test(t.contain||"")}function m8(e){let t=or(e);for(;ia(t)&&!tl(t);){if(kg(t))return t;if(dh(t))return null;t=or(t)}return null}function _g(){return gL==null&&(gL=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),gL}function tl(e){return/^(html|body|#document)$/.test(el(e))}function po(e){return yn(e).getComputedStyle(e)}function fh(e){return fo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function or(e){if(el(e)==="html")return e;let t=e.assignedSlot||e.parentNode||f8(e)&&e.host||Ro(e);return f8(t)?t.host:t}function y8(e){let t=or(e);return tl(t)?e.ownerDocument?e.ownerDocument.body:e.body:ia(t)&&au(t)?t:y8(t)}function ou(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);let a=y8(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),s=yn(a);if(r){let i=wg(s);return t.concat(s,s.visualViewport||[],au(a)?a:[],i&&n?ou(i):[])}else return t.concat(a,ou(a,[],n))}function wg(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function A8(e){let t=po(e),n=parseFloat(t.width)||0,o=parseFloat(t.height)||0,a=ia(e),r=a?e.offsetWidth:n,s=a?e.offsetHeight:o,i=ih(n)!==r||ih(o)!==s;return i&&(n=r,o=s),{width:n,height:o,$:i}}function bL(e){return fo(e)?e:e.contextElement}function ru(e){let t=bL(e);if(!ia(t))return Mo(1);let n=t.getBoundingClientRect(),{width:o,height:a,$:r}=A8(t),s=(r?ih(n.width):n.width)/o,i=(r?ih(n.height):n.height)/a;return(!s||!Number.isFinite(s))&&(s=1),(!i||!Number.isFinite(i))&&(i=1),{x:s,y:i}}var xZ=Mo(0);function v8(e){let t=yn(e);return!_g()||!t.visualViewport?xZ:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function bZ(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yn(e)?!1:t}function nl(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),r=bL(e),s=Mo(1);t&&(o?fo(o)&&(s=ru(o)):s=ru(e));let i=bZ(r,n,o)?v8(r):Mo(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&&fo(o)?yn(o):o,h=f,m=wg(h);for(;m&&o&&p!==h;){let x=ru(m),y=m.getBoundingClientRect(),g=po(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=wg(h)}}return Qi({width:u,height:d,x:l,y:c})}function Tg(e,t){let n=fh(e).scrollLeft;return t?t.left+n:nl(Ro(e)).left+n}function S8(e,t){let n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-Tg(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function AZ(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e,r=a==="fixed",s=Ro(o),i=t?dh(t.floating):!1;if(o===s||i&&r)return n;let l={scrollLeft:0,scrollTop:0},c=Mo(1),u=Mo(0),d=ia(o);if((d||!d&&!r)&&((el(o)!=="body"||au(s))&&(l=fh(o)),d)){let p=nl(o);c=ru(o),u.x=p.x+o.clientLeft,u.y=p.y+o.clientTop}let f=s&&!d&&!r?S8(s,l):Mo(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 vZ(e){return Array.from(e.getClientRects())}function SZ(e){let t=Ro(e),n=fh(e),o=e.ownerDocument.body,a=tr(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=tr(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight),s=-n.scrollLeft+Tg(e),i=-n.scrollTop;return po(o).direction==="rtl"&&(s+=tr(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:s,y:i}}var g8=25;function LZ(e,t){let n=yn(e),o=Ro(e),a=n.visualViewport,r=o.clientWidth,s=o.clientHeight,i=0,l=0;if(a){r=a.width,s=a.height;let u=_g();(!u||u&&t==="fixed")&&(i=a.offsetLeft,l=a.offsetTop)}let c=Tg(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<=g8&&(r-=h)}else c<=g8&&(r+=c);return{width:r,height:s,x:i,y:l}}function kZ(e,t){let n=nl(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=ia(e)?ru(e):Mo(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 x8(e,t,n){let o;if(t==="viewport")o=LZ(e,n);else if(t==="document")o=SZ(Ro(e));else if(fo(t))o=kZ(t,n);else{let a=v8(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Qi(o)}function L8(e,t){let n=or(e);return n===t||!fo(n)||tl(n)?!1:po(n).position==="fixed"||L8(n,t)}function _Z(e,t){let n=t.get(e);if(n)return n;let o=ou(e,[],!1).filter(i=>fo(i)&&el(i)!=="body"),a=null,r=po(e).position==="fixed",s=r?or(e):e;for(;fo(s)&&!tl(s);){let i=po(s),l=kg(s);!l&&i.position==="fixed"&&(a=null),(r?!l&&!a:!l&&i.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||au(s)&&!l&&L8(e,s))?o=o.filter(u=>u!==s):a=i,s=or(s)}return t.set(e,o),o}function wZ(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e,s=[...n==="clippingAncestors"?dh(t)?[]:_Z(t,this._c):[].concat(n),o],i=x8(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=x8(t,s[f],a);l=tr(p.top,l),c=nu(p.right,c),u=nu(p.bottom,u),d=tr(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function TZ(e){let{width:t,height:n}=A8(e);return{width:t,height:n}}function EZ(e,t,n){let o=ia(t),a=Ro(t),r=n==="fixed",s=nl(e,!0,r,t),i={scrollLeft:0,scrollTop:0},l=Mo(0);function c(){l.x=Tg(a)}if(o||!o&&!r)if((el(t)!=="body"||au(a))&&(i=fh(t)),o){let p=nl(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?S8(a,i):Mo(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 xL(e){return po(e).position==="static"}function b8(e,t){if(!ia(e)||po(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ro(e)===n&&(n=n.ownerDocument.body),n}function k8(e,t){let n=yn(e);if(dh(e))return n;if(!ia(e)){let a=or(e);for(;a&&!tl(a);){if(fo(a)&&!xL(a))return a;a=or(a)}return n}let o=b8(e,t);for(;o&&h8(o)&&xL(o);)o=b8(o,t);return o&&tl(o)&&xL(o)&&!kg(o)?n:o||m8(e)||n}var CZ=async function(e){let t=this.getOffsetParent||k8,n=this.getDimensions,o=await n(e.floating);return{reference:EZ(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function IZ(e){return po(e).direction==="rtl"}var MZ={convertOffsetParentRelativeRectToViewportRelativeRect:AZ,getDocumentElement:Ro,getClippingRect:wZ,getOffsetParent:k8,getElementRects:CZ,getClientRects:vZ,getDimensions:TZ,getScale:ru,isElement:fo,isRTL:IZ};function _8(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function RZ(e,t){let n=null,o,a=Ro(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=lh(d),m=lh(a.clientWidth-(u+f)),x=lh(a.clientHeight-(d+p)),y=lh(u),b={rootMargin:-h+"px "+-m+"px "+-x+"px "+-y+"px",threshold:tr(0,nu(1,l))||1},A=!0;function _(C){let w=C[0].intersectionRatio;if(w!==l){if(!A)return s();w?s(!1,w):o=setTimeout(()=>{s(!1,1e-7)},1e3)}w===1&&!_8(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 Eg(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=bL(e),u=a||r?[...c?ou(c):[],...t?ou(t):[]]:[];u.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});let d=c&&i?RZ(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?nl(e):null;l&&x();function x(){let y=nl(e);m&&!_8(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 Cg=u8;var Ig=d8,Mg=c8;var Rg=(e,t,n)=>{let o=new Map,a={platform:MZ,...n},r={...a.platform,_c:o};return l8(e,t,{...a,platform:r})};var la=P(re(),1),kL=P(ya(),1);var S=P(se(),1),ms=P(re(),1);var w8=P(se(),1),hs=P(re(),1),T8=(0,hs.createContext)(null),E8=({children:e})=>{let t=(0,hs.useRef)(null),n=(0,hs.useMemo)(()=>({open:o=>t.current?.(o),register:o=>(t.current=o,()=>{t.current===o&&(t.current=null)})}),[]);return(0,w8.jsx)(T8.Provider,{value:n,children:e})},Og=()=>(0,hs.useContext)(T8);var Nt=P(se(),1),M8=P(re(),1);var OZ=ns.map(e=>Pc.light[e].fill),DZ=ns.map(e=>Pc.light[e].solid),PZ=ns.map(e=>Pc.dark[e].fill),BZ=ns.map(e=>Pc.dark[e].solid),NZ=ns.map(e=>wy.light[e]),zZ=ns.map(e=>wy.dark[e]),Dg=[...OZ,...DZ,"#ffffff","#1e1e1e","transparent"],AL=[...PZ,...BZ,"#1e1e1e","#ffffff","transparent"],age=["#ffffff",...NZ],rge=["#121113",...zZ],C8=e=>e==="light"||e==="dark"?e:typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";var su=({value:e,onChange:t,palette:n,allowCustom:o=!0,allowClear:a=!0,onEyedrop:r})=>{let s=n??GZ(),[i,l]=(0,M8.useState)(!1);return(0,Nt.jsxs)("div",{className:"du-swatch-grid",role:"radiogroup","aria-label":"Colour",children:[s.map(c=>(0,Nt.jsx)(FZ,{color:c,selected:I8(c)===I8(e),onClick:()=>{t(c==="transparent"?null:c)}},c)),o?(0,Nt.jsx)(HZ,{value:e,onChange:t,open:i,onOpenChange:l}):null,r?(0,Nt.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,Nt.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,Nt.jsx)(ff,{size:12,strokeWidth:2})})}):null,a?(0,Nt.jsx)("button",{type:"button","aria-label":"Clear colour",title:"Clear colour",onClick:()=>{t(null)},className:"du-swatch du-swatch-clear",children:(0,Nt.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,Nt.jsx)(Fa,{size:12,strokeWidth:2})})}):null]})},FZ=({color:e,selected:t,onClick:n})=>(0,Nt.jsx)("button",{type:"button",role:"radio","aria-checked":t,"aria-label":e,title:e,onClick:n,className:"du-swatch",children:(0,Nt.jsx)("span",{className:"du-swatch-fill",style:{background:e==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":e}})}),HZ=({value:e,onChange:t,open:n,onOpenChange:o})=>{let a=!!e&&e!=="transparent";return(0,Nt.jsxs)("label",{className:"du-swatch du-swatch-custom",title:"Pick custom colour",children:[(0,Nt.jsx)("span",{className:"du-swatch-fill",style:a?{background:e}:void 0,children:a?null:(0,Nt.jsx)(Js,{size:12,strokeWidth:2})}),(0,Nt.jsx)("input",{type:"color","aria-label":"Custom colour",value:UZ(e),onChange:r=>{t(r.target.value),o(!1)},onClick:()=>{o(!n)},className:"du-swatch-color-input"})]})},I8=e=>e===null?"transparent":e.toLowerCase(),UZ=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"},GZ=()=>{if(typeof document>"u")return Dg;let e=document.documentElement.getAttribute("data-theme");return e==="dark"?AL:e==="light"?Dg:C8("system")==="dark"?AL:Dg};var iu=P(se(),1);var bt=P(re(),1),R8=P(ya(),1);var ho=({trigger:e,children:t,placement:n="bottom-start",offset:o=6,className:a,open:r,onOpenChange:s,ariaLabel:i})=>{let l=Pt(),[c,u]=(0,bt.useState)(!1),d=r!==void 0,f=d?r:c,p=(0,bt.useCallback)(g=>{d||u(g),s?.(g)},[d,s]),h=(0,bt.useId)(),m=(0,bt.useRef)(null),x=(0,bt.useRef)(null);(0,bt.useLayoutEffect)(()=>{if(!f)return;let g=m.current,b=x.current;if(!g||!b)return;let A=()=>{Rg(g,b,{placement:n,middleware:[Cg(o),Mg(),Ig({padding:6})]}).then(({x:C,y:w})=>{b.style.transform=`translate(${Math.round(C)}px, ${Math.round(w)}px)`})};return A(),Eg(g,b,A)},[f,n,o]),(0,bt.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,bt.useMemo)(()=>{if(!(0,bt.isValidElement)(e))return e;let g=e.props;return(0,bt.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,iu.jsxs)(iu.Fragment,{children:[y,f?(0,R8.createPortal)((0,iu.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 SL=({style:e,className:t,mobile:n=!1})=>{let o=pg(),a=oL(),r=Ka();if(ls())return null;if(o.size>0){let i=[...o].map(h=>r.elements.get(h)).filter(h=>h!==void 0);if(i.length===0)return null;let l=i.every(h=>pe(h)),c=i.every(h=>ct(h)),u=i.every(h=>Mn(h)),d=i.every(h=>Be(h)),f=[],p=[];return d?f.push((0,S.jsx)(P8,{shapes:i},"fill")):l?(f.push((0,S.jsx)(VZ,{shapes:i},"size"),(0,S.jsx)(qZ,{shapes:i},"color"),(0,S.jsx)(ZZ,{shapes:i},"align")),p.push((0,S.jsx)(jZ,{shapes:i},"family"),(0,S.jsx)(XZ,{shapes:i},"decor"))):c?f.push((0,S.jsx)(B8,{shapes:i},"opacity"),(0,S.jsx)(nX,{shapes:i},"crop")):(f.push((0,S.jsx)(P8,{shapes:i},"fill"),(0,S.jsx)(YZ,{shapes:i},"stroke"),u?(0,S.jsx)(KZ,{shapes:i},"width"):(0,S.jsx)($Z,{shapes:i},"width")),p.push((0,S.jsx)(QZ,{shapes:i},"dash"),(0,S.jsx)(JZ,{shapes:i},"round"),(0,S.jsx)(B8,{shapes:i},"opacity"),(0,S.jsx)(tX,{shapes:i},"convert"))),p.push((0,S.jsx)(eX,{},"z"),(0,S.jsx)(WZ,{shapes:i},"link")),i.length>=2&&p.push((0,S.jsx)(rX,{},"align")),p.push((0,S.jsx)(oX,{shapes:i},"actions"),(0,S.jsx)(D8,{},"more")),(0,S.jsx)(O8,{mobile:n,primary:f,overflow:p,className:t,style:e})}if(a!==null){let i=r.links.get(a);if(!i)return null;let l=[(0,S.jsx)(sX,{edge:i},"color"),(0,S.jsx)(iX,{edge:i},"width"),(0,S.jsx)(N8,{edge:i,side:"to"},"arrow-to")],c=[(0,S.jsx)(lX,{edge:i},"dash"),(0,S.jsx)(uX,{edge:i},"routing"),(0,S.jsx)(cX,{edge:i},"kind"),(0,S.jsx)(N8,{edge:i,side:"from"},"arrow-from"),(0,S.jsx)(dX,{edge:i},"auto"),(0,S.jsx)(fX,{},"delete"),(0,S.jsx)(D8,{},"more")];return(0,S.jsx)(O8,{mobile:n,primary:l,overflow:c,className:t,style:e})}return null},O8=({mobile:e,primary:t,overflow:n,className:o,style:a})=>{let[r,s]=(0,ms.useState)(!1),i=(0,ms.useRef)(null);return(0,ms.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)(Gr,{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)(mX,{}):null,n]})},WZ=({shapes:e})=>{let t=U(),n=(0,ms.useRef)(null);if(!t)return null;let o=e.map(i=>i.id),a=ph(e,i=>i.href),r=e.some(i=>!!i.href),s=i=>{t.setLink(o,i)};return(0,S.jsx)(ho,{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)(Jd,{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]})]})})},D8=()=>{let e=U(),t=Og();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)(Wr,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},LL=({label:e,color:t,onChange:n,ariaLabel:o,onEyedrop:a})=>(0,S.jsx)(ho,{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)(su,{value:t,onChange:n,...a?{onEyedrop:a}:{}})]})}),H8=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||!pe(o)?null:{target:o,from:Math.min(n.start,n.end),to:Math.max(n.start,n.end)}},qZ=({shapes:e})=>{let t=U(),n=H8(e);if(!t)return null;let o=e.map(l=>l.id),a=ph(e,l=>l.style.fill),r=Oo(e,l=>l.style.opacity??1),s=r===null?null:Math.round(r*100);return(0,S.jsx)(ho,{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:!a||a==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":a,opacity:r??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)(su,{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,S.jsx)("header",{className:"du-sel-popover-label",children:"Opacity"}),(0,S.jsx)(Rf,{value:s,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:s===null?"\u2014":`${s}%`,onChange:l=>{t.updateStyle(o,{opacity:l/100})}})]})})},P8=({shapes:e})=>{let t=U();if(!t||!e.some(yX))return null;let n=ph(e,a=>a.style.fill),o=e.map(a=>a.id);return(0,S.jsx)(LL,{label:"Fill",ariaLabel:"Fill color",color:n,onChange:a=>{t.updateStyle(o,{fill:a??"transparent"})},onEyedrop:a=>{t.beginEyedropperPick(a)}})},VZ=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(r=>r.id),o=Oo(e,r=>r.fontSize??null),a=o!==null&&Kb.some(r=>r.value===o)?o:null;return(0,S.jsx)(ho,{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)(In,{ariaLabel:"Font size preset",value:a,options:Kb.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)(Rf,{value:o,min:HE,max:UE,step:1,ariaLabel:"Font size",valueLabel:o===null?"\u2014":`${o}px`,onChange:r=>{t.updateTextProps(n,{fontSize:r})}})]})})},jZ=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(s=>s.id),o=ph(e,s=>s.fontFamily),a=eA.find(s=>s.value===o),r=o===null?"Mixed":a?.label??"Custom";return(0,S.jsx)(ho,{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"}),eA.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))]})})},ZZ=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(a=>a.id),o=Oo(e,a=>a.style.textAlign??"left");return(0,S.jsx)(In,{ariaLabel:"Text alignment",value:o,options:[{value:"left",label:"Left",icon:(0,S.jsx)(vo,{size:14,strokeWidth:1.75})},{value:"center",label:"Center",icon:(0,S.jsx)(jr,{size:14,strokeWidth:1.75})},{value:"right",label:"Right",icon:(0,S.jsx)(Vr,{size:14,strokeWidth:1.75})}],onChange:a=>{t.updateStyle(n,{textAlign:a})}})},Pg=({active:e,label:t,icon:n,onClick:o})=>(0,S.jsx)("button",{type:"button",className:`du-sel-icon-button${e?" is-active":""}`,title:t,"aria-label":t,"aria-pressed":e,onClick:o,children:n}),XZ=({shapes:e})=>{let t=U(),n=H8(e);if(!t)return null;let o=e.map(p=>p.id),a=n?Ff(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,S.jsx)(ho,{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)(Rd,{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)(Pg,{active:i,label:"Bold",icon:(0,S.jsx)(Md,{size:14,strokeWidth:1.75}),onClick:()=>{d({fontWeight:i?"normal":"bold"})}}),(0,S.jsx)(Pg,{active:l,label:"Italic",icon:(0,S.jsx)($d,{size:14,strokeWidth:1.75}),onClick:()=>{d({fontStyle:l?"normal":"italic"})}}),(0,S.jsx)(Pg,{active:c,label:"Underline",icon:(0,S.jsx)(Sf,{size:14,strokeWidth:1.75}),onClick:()=>{f("underline",!c)}}),(0,S.jsx)(Pg,{active:u,label:"Strikethrough",icon:(0,S.jsx)(bf,{size:14,strokeWidth:1.75}),onClick:()=>{f("strikethrough",!u)}})]})]})})},YZ=({shapes:e})=>{let t=U();if(!t||!e.some(G8))return null;let n=ph(e,a=>a.style.stroke),o=e.map(a=>a.id);return(0,S.jsx)(LL,{label:"Stroke",ariaLabel:"Stroke color",color:n,onChange:a=>{t.updateStyle(o,{stroke:a??"transparent"})},onEyedrop:a=>{t.beginEyedropperPick(a)}})},KZ=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(a=>a.id),o=Oo(e,a=>{let r=a,s=r.baseWidth??r.points.reduce((i,l)=>Math.max(i,l.width),0);return s>0?Math.round(s):null});return(0,S.jsx)(ho,{ariaLabel:"Brush width",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Brush width","aria-label":"Brush width",children:(0,S.jsx)(ol,{thickness:2.5})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:`Width ${o!==null?String(o):"mixed"}`}),(0,S.jsx)("input",{type:"range",min:Cf,max:E0,step:1,value:o??Cf,onChange:a=>{t.setBrushWidth(n,a.currentTarget.valueAsNumber)},style:{width:"100%"},"aria-label":"Brush width"})]})})},$Z=({shapes:e})=>{let t=U();if(!t||!e.some(a=>a.style.stroke!==void 0))return null;let n=Oo(e,a=>a.style.strokeWidth??null),o=e.map(a=>a.id);return(0,S.jsx)(In,{ariaLabel:"Stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,S.jsx)(ol,{thickness:1})},{value:2,label:"Medium",icon:(0,S.jsx)(ol,{thickness:2.5})},{value:4,label:"Thick",icon:(0,S.jsx)(ol,{thickness:4})}],onChange:a=>{t.updateStyle(o,{strokeWidth:a})}})},QZ=({shapes:e})=>{let t=U();if(!t||!e.some(G8))return null;let n=Oo(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)(In,{ariaLabel:"Stroke style",value:n,options:[{value:"solid",label:"Solid",icon:(0,S.jsx)(qo,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,S.jsx)(Na,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,S.jsx)(za,{size:14,strokeWidth:1.75})}],onChange:a=>{let r=a==="solid"?[]:a==="dashed"?[8,4]:[2,4];t.updateStyle(o,{dashArray:r})}})},JZ=({shapes:e})=>{let t=U();if(!t||!e.every(i=>li(i)||i.type==="container"))return null;let o=Oo(e,i=>i.style.roundness?.type??"sharp"),a=Oo(e,i=>i.style.roundness?.value??null),r=e.map(i=>i.id),s=a===null;return(0,S.jsx)(ho,{ariaLabel:"Corners",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Corners","aria-label":"Corners",children:(0,S.jsx)(vL,{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)(In,{ariaLabel:"Corner roundness",value:o,options:[{value:"sharp",label:"Sharp",icon:(0,S.jsx)(vL,{kind:"sharp"})},{value:"round",label:"Round",icon:(0,S.jsx)(vL,{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)(Rf,{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]})})},B8=({shapes:e})=>{let t=U();if(!t)return null;let n=Oo(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)(ho,{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)(Rf,{value:a,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:r,onChange:s=>{t.updateStyle(o,{opacity:s/100})}})]})})},eX=()=>{let e=U();return e?(0,S.jsx)(In,{ariaLabel:"Z-order",value:null,options:[{value:"back",label:"Send to back",icon:(0,S.jsx)(Pd,{size:14,strokeWidth:1.75})},{value:"backward",label:"Send backward",icon:(0,S.jsx)(cf,{size:14,strokeWidth:1.75})},{value:"forward",label:"Bring forward",icon:(0,S.jsx)(df,{size:14,strokeWidth:1.75})},{value:"front",label:"Bring to front",icon:(0,S.jsx)(Bd,{size:14,strokeWidth:1.75})}],onChange:t=>{t==="back"?e.sendToBack():t==="backward"?e.sendBackward():t==="forward"?e.bringForward():e.bringToFront()}}):null},tX=({shapes:e})=>{let t=U();if(!t||!e.every(a=>li(a)||lc(a)||Ua(a)))return null;let o=Oo(e,a=>li(a)?"rectangle":lc(a)?"ellipse":"polygon");return(0,S.jsx)(In,{ariaLabel:"Shape type",value:o,options:[{value:"rectangle",label:"Rectangle",icon:(0,S.jsx)(qo,{size:14,strokeWidth:1.75})},{value:"ellipse",label:"Ellipse",icon:(0,S.jsx)(Ks,{size:14,strokeWidth:1.75})},{value:"polygon",label:"Diamond",icon:(0,S.jsx)(Hd,{size:14,strokeWidth:1.75})}],onChange:a=>{t.convertSelection(a)}})},nX=({shapes:e})=>{let t=U();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,S.jsx)("button",{type:"button",className:"du-icon-button",title:"Crop image (double-click)","aria-label":"Crop image",onClick:()=>{t.beginImageCrop(o)},children:(0,S.jsx)(zd,{size:16,strokeWidth:1.75})})},oX=({shapes:e})=>{let t=U();if(!t)return null;let n=e.length>=2,o=e.some(r=>ze(r)),a=[{value:"duplicate",label:"Duplicate",icon:(0,S.jsx)(Ur,{size:14,strokeWidth:1.75})},{value:"delete",label:"Delete",icon:(0,S.jsx)(oc,{size:14,strokeWidth:1.75})}];return n&&a.push({value:"group",label:"Group",icon:(0,S.jsx)(Yd,{size:14,strokeWidth:1.75})}),o&&a.push({value:"ungroup",label:"Ungroup",icon:(0,S.jsx)(Lf,{size:14,strokeWidth:1.75})}),a.push({value:"flip-h",label:"Flip horizontal",icon:(0,S.jsx)(Vd,{size:14,strokeWidth:1.75})},{value:"flip-v",label:"Flip vertical",icon:(0,S.jsx)(jd,{size:14,strokeWidth:1.75})}),(0,S.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")}})},aX=[{edge:"left",label:"Align left",icon:(0,S.jsx)(Cd,{size:16,strokeWidth:1.75})},{edge:"h-center",label:"Align horizontal centres",icon:(0,S.jsx)(ec,{size:16,strokeWidth:1.75})},{edge:"right",label:"Align right",icon:(0,S.jsx)(wd,{size:16,strokeWidth:1.75})},{edge:"top",label:"Align top",icon:(0,S.jsx)(Ed,{size:16,strokeWidth:1.75})},{edge:"v-center",label:"Align vertical centres",icon:(0,S.jsx)(kd,{size:16,strokeWidth:1.75})},{edge:"bottom",label:"Align bottom",icon:(0,S.jsx)(_d,{size:16,strokeWidth:1.75})}],rX=()=>{let e=U(),t=pg();if(!e)return null;let n=t.size>=3;return(0,S.jsx)(ho,{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)(ec,{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:aX.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)(Td,{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)(Id,{size:16,strokeWidth:1.75})})]})]}):null]})})},sX=({edge:e})=>{let t=U();if(!t)return null;let n=typeof e.style.stroke=="string"?e.style.stroke:null;return(0,S.jsx)(LL,{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)}})},iX=({edge:e})=>{let t=U();if(!t)return null;let n=typeof e.style.strokeWidth=="number"?e.style.strokeWidth:null;return(0,S.jsx)(In,{ariaLabel:"Link stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,S.jsx)(ol,{thickness:1})},{value:2,label:"Medium",icon:(0,S.jsx)(ol,{thickness:2.5})},{value:4,label:"Thick",icon:(0,S.jsx)(ol,{thickness:4})}],onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,strokeWidth:o}}))}})},lX=({edge:e})=>{let t=U();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)(In,{ariaLabel:"Link stroke style",value:o,options:[{value:"solid",label:"Solid",icon:(0,S.jsx)(qo,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,S.jsx)(Na,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,S.jsx)(za,{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}}))}})},cX=({edge:e})=>{let t=U();if(!t)return null;let n=e.lineKind??"line";return(0,S.jsx)(In,{ariaLabel:"Link body",value:n,options:[{value:"line",label:"Line",icon:(0,S.jsx)(Ba,{size:14,strokeWidth:1.75})},{value:"block-arrow",label:"Block arrow",icon:(0,S.jsx)(uf,{size:14,strokeWidth:2.5})}],onChange:o=>{t.updateSelectedLink(a=>({...a,lineKind:o}))}})},uX=({edge:e})=>{let t=U();if(!t)return null;let n=e.routing??"straight";return(0,S.jsx)(In,{ariaLabel:"Link routing",value:n,options:[{value:"straight",label:"Straight",icon:(0,S.jsx)(z8,{kind:"straight"})},{value:"orthogonal",label:"Elbow",icon:(0,S.jsx)(z8,{kind:"orthogonal"})},{value:"bezier",label:"Curved",icon:(0,S.jsx)(xf,{size:14,strokeWidth:1.75})}],onChange:o=>{t.updateSelectedLink(a=>({...a,routing:o}))}})},N8=({edge:e,side:t})=>{let n=U(),[o,a]=(0,ms.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:Bg[l],"aria-label":Bg[l],"aria-pressed":l===r,onClick:()=>{s(l)},children:l==="none"?(0,S.jsx)("span",{className:"du-arrowhead-none",children:"\u2205"}):U8(l)==="none"?(0,S.jsx)("span",{className:"du-arrowhead-erd-label",children:Bg[l].replace(/^ERD /,"")}):(0,S.jsx)(F8,{kind:l,side:t})});return(0,S.jsx)(ho,{trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:`Arrow ${t}: ${Bg[r]}`,"aria-label":`Arrow ${t}`,children:(0,S.jsx)(F8,{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:pX.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:hX.map(l=>(0,S.jsx)(i,{style:l},l))})]})})},dX=({edge:e})=>{let t=U();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)(_f,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},fX=()=>{let e=U();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)(oc,{size:14,strokeWidth:1.75,"aria-hidden":!0})}):null},z8=({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"})}),U8=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"}},pX=["none","arrow","openArrow","roundedArrow","arcArrow","filledArrow","triangle","circle","filledCircle","rhombus","filledRhombus"],hX=["erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"],Bg={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"},F8=({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=U8(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]})},mX=()=>(0,S.jsx)("span",{className:"du-sel-divider","aria-hidden":!0}),ol=({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"})}),vL=({kind:e})=>e==="sharp"?(0,S.jsx)(qo,{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})}),Oo=(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},ph=(e,t)=>{let n=Oo(e,o=>t(o));return typeof n=="string"?n:null},yX=e=>e.style.fill!==void 0||Be(e),G8=e=>e.style.stroke!==void 0;var _L=({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=U(),r=ls(),s=Pt(),i=Jp(),[l,c]=(0,la.useState)(!1),u=(0,la.useRef)(null),[d,f]=(0,la.useState)(0),[p,h]=(0,la.useState)(!1);return(0,la.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,la.useLayoutEffect)(()=>{if(!a||!l||i)return;let m=u.current;if(!m)return;let x=gX(a);if(!x)return;let y=()=>{Rg(x,m,{placement:t,middleware:[Cg(e),Mg({fallbackPlacements:["bottom","right","left"],padding:o}),Ig({padding:o})]}).then(({x:b,y:A})=>{m.style.transform=`translate(${Math.round(b)}px, ${Math.round(A)}px)`,h(!0)})};return y(),Eg(x,m,y)},[a,l,i,d,e,t,o.top,o.right,o.bottom,o.left]),!a||!l||r?null:i?(0,kL.createPortal)((0,hh.jsx)("div",{className:"du-sel-panel-dock",role:"toolbar","aria-label":"Selection actions",children:(0,hh.jsx)(SL,{mobile:!0})}),s):(0,kL.createPortal)((0,hh.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,hh.jsx)(SL,{})}),s)},gX=e=>{let t=e.hostElement;return t?{getBoundingClientRect:()=>{let n=xX(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},xX=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 as(e.scene,a)}return null}let n=null;for(let o of t){if(ze(o)&&e.scene.elements.has(o.id)){let r=MA(e.scene,o.id);for(let s of r){if(ze(s))continue;let i;try{i=N(s)}catch{continue}i.width===0&&i.height===0||(n=W8(n,i))}continue}let a;try{a=N(o)}catch{continue}n=W8(n,a)}return n},W8=(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 gs=P(se(),1),Le=P(re(),1);var lu="Roboto",mh="PT Serif",yh="Roboto Mono",cu=e=>{let t=e.toLowerCase();return t.includes("mono")?yh:t.includes("sans")?lu:t.includes("serif")||t.includes("slab")||t.includes("georgia")||t.includes("times")?mh:lu},bX=[{family:lu,weight:"400",style:"normal",url:new URL("../fonts/Roboto-Regular.woff2",import.meta.url)},{family:lu,weight:"700",style:"normal",url:new URL("../fonts/Roboto-Bold.woff2",import.meta.url)},{family:lu,weight:"400",style:"italic",url:new URL("../fonts/Roboto-Italic.woff2",import.meta.url)},{family:lu,weight:"700",style:"italic",url:new URL("../fonts/Roboto-BoldItalic.woff2",import.meta.url)},{family:mh,weight:"400",style:"normal",url:new URL("../fonts/PTSerif-Regular.woff2",import.meta.url)},{family:mh,weight:"700",style:"normal",url:new URL("../fonts/PTSerif-Bold.woff2",import.meta.url)},{family:mh,weight:"400",style:"italic",url:new URL("../fonts/PTSerif-Italic.woff2",import.meta.url)},{family:mh,weight:"700",style:"italic",url:new URL("../fonts/PTSerif-BoldItalic.woff2",import.meta.url)},{family:yh,weight:"400",style:"normal",url:new URL("../fonts/RobotoMono-Regular.woff2",import.meta.url)},{family:yh,weight:"700",style:"normal",url:new URL("../fonts/RobotoMono-Bold.woff2",import.meta.url)},{family:yh,weight:"400",style:"italic",url:new URL("../fonts/RobotoMono-Italic.woff2",import.meta.url)},{family:yh,weight:"700",style:"italic",url:new URL("../fonts/RobotoMono-BoldItalic.woff2",import.meta.url)}],q8=async(e=globalThis)=>{let t=e.fonts;!t||typeof FontFace>"u"||await Promise.allSettled(bX.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 AX=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],uu=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of AX){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},Ng=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},V8=new Set,zg=e=>{if(typeof console>"u")return;let t=typeof e=="string"?e.startsWith("blob:")?"dead-blob-url":"string-src":e==null?"empty":"stale-object";V8.has(t)||(V8.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 ar=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 "${cu(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(!uu(t)){zg(t);return}if(i&&(i.x!==0||i.y!==0||i.width!==1||i.height!==1)){let l=Ng(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 gh=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 EL(e,t,n=2){let o=t&&t.length,a=o?t[0]*n:e.length,r=Z8(e,0,a,n,!0),s=[];if(!r||r.next===r.prev)return s;let i,l,c;if(o&&(r=_X(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 bh(r,s,n,i,l,c,0),s}function Z8(e,t,n,o,a){let r;if(a===BX(e,t,n,o)>0)for(let s=t;s<n;s+=o)r=j8(s/o|0,e[s],e[s+1],r);else for(let s=n-o;s>=t;s-=o)r=j8(s/o|0,e[s],e[s+1],r);return r&&du(r,r.next)&&(vh(r),r=r.next),r}function al(e,t){if(!e)return e;t||(t=e);let n=e,o;do if(o=!1,!n.steiner&&(du(n,n.next)||$e(n.prev,n,n.next)===0)){if(vh(n),n=t=n.prev,n===n.next)break;o=!0}else n=n.next;while(o||n!==t);return t}function bh(e,t,n,o,a,r,s){if(!e)return;!s&&r&&IX(e,o,a,r);let i=e;for(;e.prev!==e.next;){let l=e.prev,c=e.next;if(r?SX(e,o,a,r):vX(e)){t.push(l.i,e.i,c.i),vh(e),e=c.next,i=c.next;continue}if(e=c,e===i){s?s===1?(e=LX(al(e),t),bh(e,t,n,o,a,r,2)):s===2&&kX(e,t,n,o,a,r):bh(al(e),t,n,o,a,r,1);break}}}function vX(e){let t=e.prev,n=e,o=e.next;if($e(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&&xh(a,i,r,l,s,c,h.x,h.y)&&$e(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function SX(e,t,n,o){let a=e.prev,r=e,s=e.next;if($e(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=wL(p,h,t,n,o),g=wL(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&&xh(i,u,l,d,c,f,b.x,b.y)&&$e(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&&xh(i,u,l,d,c,f,A.x,A.y)&&$e(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&&xh(i,u,l,d,c,f,b.x,b.y)&&$e(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&&xh(i,u,l,d,c,f,A.x,A.y)&&$e(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function LX(e,t){let n=e;do{let o=n.prev,a=n.next.next;!du(o,a)&&Y8(o,n,n.next,a)&&Ah(o,a)&&Ah(a,o)&&(t.push(o.i,n.i,a.i),vh(n),vh(n.next),n=e=a),n=n.next}while(n!==e);return al(n)}function kX(e,t,n,o,a,r){let s=e;do{let i=s.next.next;for(;i!==s.prev;){if(s.i!==i.i&&OX(s,i)){let l=K8(s,i);s=al(s,s.next),l=al(l,l.next),bh(s,t,n,o,a,r,0),bh(l,t,n,o,a,r,0);return}i=i.next}s=s.next}while(s!==e)}function _X(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=Z8(e,i,l,o,!1);c===c.next&&(c.steiner=!0),a.push(RX(c))}a.sort(wX);for(let r=0;r<a.length;r++)n=TX(a[r],n);return n}function wX(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 TX(e,t){let n=EX(e,t);if(!n)return t;let o=K8(n,e);return al(o,o.next),al(n,n.next)}function EX(e,t){let n=t,o=e.x,a=e.y,r=-1/0,s;if(du(e,n))return n;do{if(du(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&&X8(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);Ah(n,e)&&(d<u||d===u&&(n.x>s.x||n.x===s.x&&CX(s,n)))&&(s=n,u=d)}n=n.next}while(n!==i);return s}function CX(e,t){return $e(e.prev,e,t.prev)<0&&$e(t.next,e,e.next)<0}function IX(e,t,n,o){let a=e;do a.z===0&&(a.z=wL(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,MX(a)}function MX(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 wL(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 RX(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 X8(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 xh(e,t,n,o,a,r,s,i){return!(e===s&&t===i)&&X8(e,t,n,o,a,r,s,i)}function OX(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!DX(e,t)&&(Ah(e,t)&&Ah(t,e)&&PX(e,t)&&($e(e.prev,e,t.prev)||$e(e,t.prev,t))||du(e,t)&&$e(e.prev,e,e.next)>0&&$e(t.prev,t,t.next)>0)}function $e(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function du(e,t){return e.x===t.x&&e.y===t.y}function Y8(e,t,n,o){let a=Hg($e(e,t,n)),r=Hg($e(e,t,o)),s=Hg($e(n,o,e)),i=Hg($e(n,o,t));return!!(a!==r&&s!==i||a===0&&Fg(e,n,t)||r===0&&Fg(e,o,t)||s===0&&Fg(n,e,o)||i===0&&Fg(n,t,o))}function Fg(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 Hg(e){return e>0?1:e<0?-1:0}function DX(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&&Y8(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Ah(e,t){return $e(e.prev,e,e.next)<0?$e(e,t,e.next)>=0&&$e(e,e.prev,t)>=0:$e(e,t,e.prev)<0||$e(e,e.next,t)<0}function PX(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 K8(e,t){let n=TL(e.i,e.x,e.y),o=TL(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 j8(e,t,n,o){let a=TL(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 vh(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 TL(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function BX(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 CL=e=>{if(e===null)return[0,0,0,0];try{let{r:t,g:n,b:o,a}=P0.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 ot=e=>{if(e===null)throw new Error("packages/renderer-canvas: WebGL resource creation failed");return e},zt=(e,t,n,o)=>{let a=ot(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},Do=(e,t,n,o)=>{let a=ot(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 Sh=class{gl;program;vbo;vao;uTransform;uColor;uOpacity;uPxRange;uAtlas;constructor(t){this.gl=t;let n=zt(t,t.VERTEX_SHADER,UX,"MSDF"),o=zt(t,t.FRAGMENT_SHADER,GX,"MSDF");this.program=Do(t,n,o,"MSDF"),this.vbo=ot(t.createBuffer());let a=t.getAttribLocation(this.program,"aPos"),r=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"),this.vao=ot(t.createVertexArray()),t.bindVertexArray(this.vao),t.bindBuffer(t.ARRAY_BUFFER,this.vbo),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,16,0),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,16,8),t.bindVertexArray(null)}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;FX(f);let p=Ug,h=0,m=n,x=!0;for(let w of t){let L=w.codePointAt(0);if(L===void 0)continue;let k=r.getOrRasterize(L,c);if(!k){x=!1;break}let M=k.advance*a/k.unitsPerEm;if(k.empty){m+=M;continue}zX(p,h,k,m,o,a,r),h+=u*d,m+=M}if(x&&a>0&&J8(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.bindVertexArray(this.vao),g.bindBuffer(g.ARRAY_BUFFER,this.vbo),g.bufferData(g.ARRAY_BUFFER,p.subarray(0,h),g.DYNAMIC_DRAW);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}}HX($8,A,i.width,i.height),g.uniformMatrix3fv(this.uTransform,!1,$8),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,C=r.range*a/Math.max(1,_);return g.uniform1f(this.uPxRange,C),g.activeTexture(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,y),g.uniform1i(this.uAtlas,0),g.drawArrays(g.TRIANGLES,0,h/d),g.bindVertexArray(null),m-n}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteBuffer(this.vbo),this.gl.deleteProgram(this.program)}},NX=(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:_}},IL=new WeakMap,Q8=(e,t)=>`${t}\0${e}`,J8=(e,t,n,o)=>{let a=IL.get(e);a||(a=new Map,IL.set(e,a));let r=Q8(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)}},e6=(e,t,n=0)=>{if(e.length===0)return 0;let o=Q8(e,n),a=IL.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 J8(t,e,n,r),r},zX=(e,t,n,o,a,r,s)=>{let{left:i,top:l,right:c,bottom:u,u0:d,v0:f,u1:p,v1:h}=NX(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)},Ug=new Float32Array(512),$8=new Float32Array(9),FX=e=>{if(Ug.length>=e)return;let t=Ug.length;for(;t<e;)t*=2;Ug=new Float32Array(t)},HX=(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},UX=`#version 300 es
|
|
8
|
+
`+o.stack}}var p1=Object.prototype.hasOwnProperty,ob=mt.unstable_scheduleCallback,Ix=mt.unstable_cancelCallback,M7=mt.unstable_shouldYield,R7=mt.unstable_requestPaint,Ln=mt.unstable_now,O7=mt.unstable_getCurrentPriorityLevel,X_=mt.unstable_ImmediatePriority,Y_=mt.unstable_UserBlockingPriority,Nm=mt.unstable_NormalPriority,D7=mt.unstable_LowPriority,K_=mt.unstable_IdlePriority,P7=mt.log,B7=mt.unstable_setDisableYieldValue,hd=null,kn=null;function Sr(e){if(typeof P7=="function"&&B7(e),kn&&typeof kn.setStrictMode=="function")try{kn.setStrictMode(hd,e)}catch{}}var _n=Math.clz32?Math.clz32:F7,N7=Math.log,z7=Math.LN2;function F7(e){return e>>>=0,e===0?32:31-(N7(e)/z7|0)|0}var nm=256,om=262144,am=4194304;function Os(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 c0(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=Os(o):(s&=i,s!==0?a=Os(s):n||(n=i&~e,n!==0&&(a=Os(n))))):(i=o&~r,i!==0?a=Os(i):s!==0?a=Os(s):n||(n=o&~e,n!==0&&(a=Os(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 md(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function H7(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 $_(){var e=am;return am<<=1,(am&62914560)===0&&(am=4194304),e}function Mx(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function yd(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function U7(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-_n(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&&Q_(e,o,0),r!==0&&a===0&&e.tag!==0&&(e.suspendedLanes|=r&~(s&~t))}function Q_(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-_n(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|n&261930}function J_(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var o=31-_n(n),a=1<<o;a&t|e[o]&t&&(e[o]|=t),n&=~a}}function ew(e,t){var n=t&-t;return n=(n&42)!==0?1:ab(n),(n&(e.suspendedLanes|t))!==0?0:n}function ab(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 rb(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function tw(){var e=_e.p;return e!==0?e:(e=window.event,e===void 0?32:kE(e.type))}function Ak(e,t){var n=_e.p;try{return _e.p=e,t()}finally{_e.p=n}}var Hr=Math.random().toString(36).slice(2),Mt="__reactFiber$"+Hr,an="__reactProps$"+Hr,Xl="__reactContainer$"+Hr,h1="__reactEvents$"+Hr,G7="__reactListeners$"+Hr,W7="__reactHandles$"+Hr,vk="__reactResources$"+Hr,gd="__reactMarker$"+Hr;function sb(e){delete e[Mt],delete e[an],delete e[h1],delete e[G7],delete e[W7]}function Al(e){var t=e[Mt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Xl]||n[Mt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=C_(e);e!==null;){if(n=e[Mt])return n;e=C_(e)}return t}e=n,n=e.parentNode}return null}function Yl(e){if(e=e[Mt]||e[Xl]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Nu(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(O(33))}function Il(e){var t=e[vk];return t||(t=e[vk]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function kt(e){e[gd]=!0}var nw=new Set,ow={};function js(e,t){zl(e,t),zl(e+"Capture",t)}function zl(e,t){for(ow[e]=t,e=0;e<t.length;e++)nw.add(t[e])}var q7=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]*$"),Sk={},Lk={};function V7(e){return p1.call(Lk,e)?!0:p1.call(Sk,e)?!1:q7.test(e)?Lk[e]=!0:(Sk[e]=!0,!1)}function bm(e,t,n){if(V7(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 rm(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 ga(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 qn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function aw(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function j7(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 m1(e){if(!e._valueTracker){var t=aw(e)?"checked":"value";e._valueTracker=j7(e,t,""+e[t])}}function rw(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),o="";return e&&(o=aw(e)?e.checked?"true":"false":e.value),e=o,e!==n?(t.setValue(e),!0):!1}function zm(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 Z7=/[\n"\\]/g;function Zn(e){return e.replace(Z7,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function y1(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=""+qn(t)):e.value!==""+qn(t)&&(e.value=""+qn(t)):s!=="submit"&&s!=="reset"||e.removeAttribute("value"),t!=null?g1(e,s,qn(t)):n!=null?g1(e,s,qn(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=""+qn(i):e.removeAttribute("name")}function sw(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)){m1(e);return}n=n!=null?""+qn(n):"",t=t!=null?""+qn(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),m1(e)}function g1(e,t,n){t==="number"&&zm(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function Ml(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=""+qn(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 iw(e,t,n){if(t!=null&&(t=""+qn(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+qn(n):""}function lw(e,t,n,o){if(t==null){if(o!=null){if(n!=null)throw Error(O(92));if(Bu(o)){if(1<o.length)throw Error(O(93));o=o[0]}n=o}n==null&&(n=""),t=n}n=qn(t),e.defaultValue=n,o=e.textContent,o===n&&o!==""&&o!==null&&(e.value=o),m1(e)}function Fl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var X7=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 kk(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||X7.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function cw(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&&kk(e,a,o)}else for(var r in t)t.hasOwnProperty(r)&&kk(e,r,t[r])}function ib(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 Y7=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"]]),K7=/^[\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 Am(e){return K7.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function _a(){}var x1=null;function lb(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var vl=null,Rl=null;function _k(e){var t=Yl(e);if(t&&(e=t.stateNode)){var n=e[an]||null;e:switch(e=t.stateNode,t.type){case"input":if(y1(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="'+Zn(""+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));y1(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&&rw(o)}break e;case"textarea":iw(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&Ml(e,!!n.multiple,t,!1)}}}var Rx=!1;function uw(e,t,n){if(Rx)return e(t,n);Rx=!0;try{var o=e(t);return o}finally{if(Rx=!1,(vl!==null||Rl!==null)&&(v0(),vl&&(t=vl,e=Rl,Rl=vl=null,_k(t),e)))for(t=0;t<e.length;t++)_k(e[t])}}function ed(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 Ia=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),b1=!1;if(Ia)try{pl={},Object.defineProperty(pl,"passive",{get:function(){b1=!0}}),window.addEventListener("test",pl,pl),window.removeEventListener("test",pl,pl)}catch{b1=!1}var pl,Lr=null,cb=null,vm=null;function dw(){if(vm)return vm;var e,t=cb,n=t.length,o,a="value"in Lr?Lr.value:Lr.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 vm=a.slice(e,1<o?1-o:void 0)}function Sm(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 sm(){return!0}function wk(){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)?sm:wk,this.isPropagationStopped=wk,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=sm)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=sm)},persist:function(){},isPersistent:sm}),t}var Zs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},u0=rn(Zs),xd=qe({},Zs,{view:0,detail:0}),$7=rn(xd),Ox,Dx,Cu,d0=qe({},xd,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ub,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!==Cu&&(Cu&&e.type==="mousemove"?(Ox=e.screenX-Cu.screenX,Dx=e.screenY-Cu.screenY):Dx=Ox=0,Cu=e),Ox)},movementY:function(e){return"movementY"in e?e.movementY:Dx}}),Tk=rn(d0),Q7=qe({},d0,{dataTransfer:0}),J7=rn(Q7),eB=qe({},xd,{relatedTarget:0}),Px=rn(eB),tB=qe({},Zs,{animationName:0,elapsedTime:0,pseudoElement:0}),nB=rn(tB),oB=qe({},Zs,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),aB=rn(oB),rB=qe({},Zs,{data:0}),Ek=rn(rB),sB={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},iB={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"},lB={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function cB(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=lB[e])?!!t[e]:!1}function ub(){return cB}var uB=qe({},xd,{key:function(e){if(e.key){var t=sB[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Sm(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?iB[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ub,charCode:function(e){return e.type==="keypress"?Sm(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Sm(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),dB=rn(uB),fB=qe({},d0,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ck=rn(fB),pB=qe({},xd,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ub}),hB=rn(pB),mB=qe({},Zs,{propertyName:0,elapsedTime:0,pseudoElement:0}),yB=rn(mB),gB=qe({},d0,{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}),xB=rn(gB),bB=qe({},Zs,{newState:0,oldState:0}),AB=rn(bB),vB=[9,13,27,32],db=Ia&&"CompositionEvent"in window,Hu=null;Ia&&"documentMode"in document&&(Hu=document.documentMode);var SB=Ia&&"TextEvent"in window&&!Hu,fw=Ia&&(!db||Hu&&8<Hu&&11>=Hu),Ik=" ",Mk=!1;function pw(e,t){switch(e){case"keyup":return vB.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function hw(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Sl=!1;function LB(e,t){switch(e){case"compositionend":return hw(t);case"keypress":return t.which!==32?null:(Mk=!0,Ik);case"textInput":return e=t.data,e===Ik&&Mk?null:e;default:return null}}function kB(e,t){if(Sl)return e==="compositionend"||!db&&pw(e,t)?(e=dw(),vm=cb=Lr=null,Sl=!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 fw&&t.locale!=="ko"?null:t.data;default:return null}}var _B={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 Rk(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!_B[e.type]:t==="textarea"}function mw(e,t,n,o){vl?Rl?Rl.push(o):Rl=[o]:vl=o,t=n0(t,"onChange"),0<t.length&&(n=new u0("onChange","change",null,n,o),e.push({event:n,listeners:t}))}var Uu=null,td=null;function wB(e){uE(e,0)}function f0(e){var t=Nu(e);if(rw(t))return e}function Ok(e,t){if(e==="change")return t}var yw=!1;Ia&&(Ia?(lm="oninput"in document,lm||(Bx=document.createElement("div"),Bx.setAttribute("oninput","return;"),lm=typeof Bx.oninput=="function"),im=lm):im=!1,yw=im&&(!document.documentMode||9<document.documentMode));var im,lm,Bx;function Dk(){Uu&&(Uu.detachEvent("onpropertychange",gw),td=Uu=null)}function gw(e){if(e.propertyName==="value"&&f0(td)){var t=[];mw(t,td,e,lb(e)),uw(wB,t)}}function TB(e,t,n){e==="focusin"?(Dk(),Uu=t,td=n,Uu.attachEvent("onpropertychange",gw)):e==="focusout"&&Dk()}function EB(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return f0(td)}function CB(e,t){if(e==="click")return f0(t)}function IB(e,t){if(e==="input"||e==="change")return f0(t)}function MB(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Tn=typeof Object.is=="function"?Object.is:MB;function nd(e,t){if(Tn(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(!p1.call(t,a)||!Tn(e[a],t[a]))return!1}return!0}function Pk(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Bk(e,t){var n=Pk(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=Pk(n)}}function xw(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?xw(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function bw(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=zm(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=zm(e.document)}return t}function fb(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 RB=Ia&&"documentMode"in document&&11>=document.documentMode,Ll=null,A1=null,Gu=null,v1=!1;function Nk(e,t,n){var o=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;v1||Ll==null||Ll!==zm(o)||(o=Ll,"selectionStart"in o&&fb(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}),Gu&&nd(Gu,o)||(Gu=o,o=n0(A1,"onSelect"),0<o.length&&(t=new u0("onSelect","select",null,t,n),e.push({event:t,listeners:o}),t.target=Ll)))}function Ms(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var kl={animationend:Ms("Animation","AnimationEnd"),animationiteration:Ms("Animation","AnimationIteration"),animationstart:Ms("Animation","AnimationStart"),transitionrun:Ms("Transition","TransitionRun"),transitionstart:Ms("Transition","TransitionStart"),transitioncancel:Ms("Transition","TransitionCancel"),transitionend:Ms("Transition","TransitionEnd")},Nx={},Aw={};Ia&&(Aw=document.createElement("div").style,"AnimationEvent"in window||(delete kl.animationend.animation,delete kl.animationiteration.animation,delete kl.animationstart.animation),"TransitionEvent"in window||delete kl.transitionend.transition);function Xs(e){if(Nx[e])return Nx[e];if(!kl[e])return e;var t=kl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Aw)return Nx[e]=t[n];return e}var vw=Xs("animationend"),Sw=Xs("animationiteration"),Lw=Xs("animationstart"),OB=Xs("transitionrun"),DB=Xs("transitionstart"),PB=Xs("transitioncancel"),kw=Xs("transitionend"),_w=new Map,S1="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(" ");S1.push("scrollEnd");function bo(e,t){_w.set(e,t),js(t,[e])}var Fm=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)},Wn=[],_l=0,pb=0;function p0(){for(var e=_l,t=pb=_l=0;t<e;){var n=Wn[t];Wn[t++]=null;var o=Wn[t];Wn[t++]=null;var a=Wn[t];Wn[t++]=null;var r=Wn[t];if(Wn[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&&ww(n,a,r)}}function h0(e,t,n,o){Wn[_l++]=e,Wn[_l++]=t,Wn[_l++]=n,Wn[_l++]=o,pb|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function hb(e,t,n,o){return h0(e,t,n,o),Hm(e)}function Ys(e,t){return h0(e,null,null,t),Hm(e)}function ww(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-_n(n),e=r.hiddenUpdates,o=e[a],o===null?e[a]=[t]:o.push(t),t.lane=n|536870912),r):null}function Hm(e){if(50<$u)throw $u=0,W1=null,Error(O(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var wl={};function BB(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 BB(e,t,n,o)}function mb(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ta(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 Tw(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")mb(e)&&(s=1);else if(typeof e=="string")s=FN(e,n,Uo.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case c1:return e=vn(31,n,t,a),e.elementType=c1,e.lanes=r,e;case xl:return Ns(n.children,a,r,t);case j_:s=8,a|=24;break;case s1:return e=vn(12,n,t,a|2),e.elementType=s1,e.lanes=r,e;case i1:return e=vn(13,n,t,a),e.elementType=i1,e.lanes=r,e;case l1:return e=vn(19,n,t,a),e.elementType=l1,e.lanes=r,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ka:s=10;break e;case Z_:s=9;break e;case tb:s=11;break e;case nb:s=14;break e;case yr: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 Ns(e,t,n,o){return e=vn(7,e,o,t),e.lanes=n,e}function zx(e,t,n){return e=vn(6,e,null,t),e.lanes=n,e}function Ew(e){var t=vn(18,null,null,0);return t.stateNode=e,t}function Fx(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 zk=new WeakMap;function Xn(e,t){if(typeof e=="object"&&e!==null){var n=zk.get(e);return n!==void 0?n:(t={value:e,source:t,stack:bk(t)},zk.set(e,t),t)}return{value:e,source:t,stack:bk(t)}}var Tl=[],El=0,Um=null,od=0,Vn=[],jn=0,Br=null,zo=1,Fo="";function Sa(e,t){Tl[El++]=od,Tl[El++]=Um,Um=e,od=t}function Cw(e,t,n){Vn[jn++]=zo,Vn[jn++]=Fo,Vn[jn++]=Br,Br=e;var o=zo;e=Fo;var a=32-_n(o)-1;o&=~(1<<a),n+=1;var r=32-_n(t)+a;if(30<r){var s=a-a%5;r=(o&(1<<s)-1).toString(32),o>>=s,a-=s,zo=1<<32-_n(t)+a|n<<a|o,Fo=r+e}else zo=1<<r|n<<a|o,Fo=e}function yb(e){e.return!==null&&(Sa(e,1),Cw(e,1,0))}function gb(e){for(;e===Um;)Um=Tl[--El],Tl[El]=null,od=Tl[--El],Tl[El]=null;for(;e===Br;)Br=Vn[--jn],Vn[jn]=null,Fo=Vn[--jn],Vn[jn]=null,zo=Vn[--jn],Vn[jn]=null}function Iw(e,t){Vn[jn++]=zo,Vn[jn++]=Fo,Vn[jn++]=Br,zo=t.id,Fo=t.overflow,Br=e}var Rt=null,We=null,be=!1,Er=null,Yn=!1,L1=Error(O(519));function Nr(e){var t=Error(O(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ad(Xn(t,e)),L1}function Fk(e){var t=e.stateNode,n=e.type,o=e.memoizedProps;switch(t[Mt]=e,t[an]=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<ld.length;n++)de(ld[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),sw(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),lw(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||fE(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=_a),t=!0):t=!1,t||Nr(e,!0)}function Hk(e){for(Rt=e.return;Rt;)switch(Rt.tag){case 5:case 31:case 13:Yn=!1;return;case 27:case 3:Yn=!0;return;default:Rt=Rt.return}}function hl(e){if(e!==Rt)return!1;if(!be)return Hk(e),be=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||X1(e.type,e.memoizedProps)),n=!n),n&&We&&Nr(e),Hk(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));We=E_(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(O(317));We=E_(e)}else t===27?(t=We,Ur(e.type)?(e=Q1,Q1=null,We=e):We=t):We=Rt?$n(e.stateNode.nextSibling):null;return!0}function Us(){We=Rt=null,be=!1}function Hx(){var e=Er;return e!==null&&(nn===null?nn=e:nn.push.apply(nn,e),Er=null),e}function ad(e){Er===null?Er=[e]:Er.push(e)}var k1=Go(null),Ks=null,wa=null;function xr(e,t,n){Ne(k1,t._currentValue),t._currentValue=n}function Ea(e){e._currentValue=k1.current,_t(k1)}function _1(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 w1(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),_1(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),_1(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 Kl(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;Tn(a.pendingProps.value,s.value)||(e!==null?e.push(i):e=[i])}}else if(a===Dm.current){if(s=a.alternate,s===null)throw Error(O(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e!==null?e.push(ud):e=[ud])}a=a.return}e!==null&&w1(t,e,n,o),t.flags|=262144}function Gm(e){for(e=e.firstContext;e!==null;){if(!Tn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Gs(e){Ks=e,wa=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ot(e){return Mw(Ks,e)}function cm(e,t){return Ks===null&&Gs(e),Mw(e,t)}function Mw(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},wa===null){if(e===null)throw Error(O(308));wa=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else wa=wa.next=t;return n}var NB=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()})}},zB=mt.unstable_scheduleCallback,FB=mt.unstable_NormalPriority,it={$$typeof:ka,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function xb(){return{controller:new NB,data:new Map,refCount:0}}function bd(e){e.refCount--,e.refCount===0&&zB(FB,function(){e.controller.abort()})}var Wu=null,T1=0,Hl=0,Ol=null;function HB(e,t){if(Wu===null){var n=Wu=[];T1=0,Hl=Wb(),Ol={status:"pending",value:void 0,then:function(o){n.push(o)}}}return T1++,t.then(Uk,Uk),t}function Uk(){if(--T1===0&&Wu!==null){Ol!==null&&(Ol.status="fulfilled");var e=Wu;Wu=null,Hl=0,Ol=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function UB(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 Gk=K.S;K.S=function(e,t){VT=Ln(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&HB(e,t),Gk!==null&&Gk(e,t)};var zs=Go(null);function bb(){var e=zs.current;return e!==null?e:De.pooledCache}function km(e,t){t===null?Ne(zs,zs.current):Ne(zs,t.pool)}function Rw(){var e=bb();return e===null?null:{parent:it._currentValue,pool:e}}var $l=Error(O(460)),Ab=Error(O(474)),m0=Error(O(542)),Wm={then:function(){}};function Wk(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Ow(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(_a,_a),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Vk(e),e;default:if(typeof t.status=="string")t.then(_a,_a);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,Vk(e),e}throw Fs=t,$l}}function Ds(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Fs=n,$l):n}}var Fs=null;function qk(){if(Fs===null)throw Error(O(459));var e=Fs;return Fs=null,e}function Vk(e){if(e===$l||e===m0)throw Error(O(483))}var Dl=null,rd=0;function um(e){var t=rd;return rd+=1,Dl===null&&(Dl=[]),Ow(Dl,e,t)}function Iu(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function dm(e,t){throw t.$$typeof===T7?Error(O(525)):(e=Object.prototype.toString.call(t),Error(O(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Dw(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=Ta(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=zx(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 _===xl?u(y,g,b.props.children,A,b.key):g!==null&&(g.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===yr&&Ds(_)===g.type)?(g=a(g,b.props),Iu(g,b),g.return=y,g):(g=Lm(b.type,b.key,b.props,null,y.mode,A),Iu(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=Fx(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=Ns(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=zx(""+g,y.mode,b),g.return=y,g;if(typeof g=="object"&&g!==null){switch(g.$$typeof){case tm:return b=Lm(g.type,g.key,g.props,null,y.mode,b),Iu(b,g),b.return=y,b;case Pu:return g=Fx(g,y.mode,b),g.return=y,g;case yr:return g=Ds(g),d(y,g,b)}if(Bu(g)||Eu(g))return g=Ns(g,y.mode,b,null),g.return=y,g;if(typeof g.then=="function")return d(y,um(g),b);if(g.$$typeof===ka)return d(y,cm(y,g),b);dm(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 tm:return b.key===_?l(y,g,b,A):null;case Pu:return b.key===_?c(y,g,b,A):null;case yr:return b=Ds(b),f(y,g,b,A)}if(Bu(b)||Eu(b))return _!==null?null:u(y,g,b,A,null);if(typeof b.then=="function")return f(y,g,um(b),A);if(b.$$typeof===ka)return f(y,g,cm(y,b),A);dm(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 tm:return y=y.get(A.key===null?b:A.key)||null,l(g,y,A,_);case Pu:return y=y.get(A.key===null?b:A.key)||null,c(g,y,A,_);case yr:return A=Ds(A),p(y,g,b,A,_)}if(Bu(A)||Eu(A))return y=y.get(b)||null,u(g,y,A,_,null);if(typeof A.then=="function")return p(y,g,b,um(A),_);if(A.$$typeof===ka)return p(y,g,b,cm(g,A),_);dm(g,A)}return null}function h(y,g,b,A){for(var _=null,C=null,w=g,L=g=0,k=null;w!==null&&L<b.length;L++){w.index>L?(k=w,w=null):k=w.sibling;var M=f(y,w,b[L],A);if(M===null){w===null&&(w=k);break}e&&w&&M.alternate===null&&t(y,w),g=r(M,g,L),C===null?_=M:C.sibling=M,C=M,w=k}if(L===b.length)return n(y,w),be&&Sa(y,L),_;if(w===null){for(;L<b.length;L++)w=d(y,b[L],A),w!==null&&(g=r(w,g,L),C===null?_=w:C.sibling=w,C=w);return be&&Sa(y,L),_}for(w=o(w);L<b.length;L++)k=p(w,y,L,b[L],A),k!==null&&(e&&k.alternate!==null&&w.delete(k.key===null?L:k.key),g=r(k,g,L),C===null?_=k:C.sibling=k,C=k);return e&&w.forEach(function(B){return t(y,B)}),be&&Sa(y,L),_}function m(y,g,b,A){if(b==null)throw Error(O(151));for(var _=null,C=null,w=g,L=g=0,k=null,M=b.next();w!==null&&!M.done;L++,M=b.next()){w.index>L?(k=w,w=null):k=w.sibling;var B=f(y,w,M.value,A);if(B===null){w===null&&(w=k);break}e&&w&&B.alternate===null&&t(y,w),g=r(B,g,L),C===null?_=B:C.sibling=B,C=B,w=k}if(M.done)return n(y,w),be&&Sa(y,L),_;if(w===null){for(;!M.done;L++,M=b.next())M=d(y,M.value,A),M!==null&&(g=r(M,g,L),C===null?_=M:C.sibling=M,C=M);return be&&Sa(y,L),_}for(w=o(w);!M.done;L++,M=b.next())M=p(w,y,L,M.value,A),M!==null&&(e&&M.alternate!==null&&w.delete(M.key===null?L:M.key),g=r(M,g,L),C===null?_=M:C.sibling=M,C=M);return e&&w.forEach(function(G){return t(y,G)}),be&&Sa(y,L),_}function x(y,g,b,A){if(typeof b=="object"&&b!==null&&b.type===xl&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case tm:e:{for(var _=b.key;g!==null;){if(g.key===_){if(_=b.type,_===xl){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===yr&&Ds(_)===g.type){n(y,g.sibling),A=a(g,b.props),Iu(A,b),A.return=y,y=A;break e}n(y,g);break}else t(y,g);g=g.sibling}b.type===xl?(A=Ns(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),Iu(A,b),A.return=y,y=A)}return s(y);case Pu: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=Fx(b,y.mode,A),A.return=y,y=A}return s(y);case yr:return b=Ds(b),x(y,g,b,A)}if(Bu(b))return h(y,g,b,A);if(Eu(b)){if(_=Eu(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,um(b),A);if(b.$$typeof===ka)return x(y,g,cm(y,b),A);dm(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=zx(b,y.mode,A),A.return=y,y=A),s(y)):n(y,g)}return function(y,g,b,A){try{rd=0;var _=x(y,g,b,A);return Dl=null,_}catch(w){if(w===$l||w===m0)throw w;var C=vn(29,w,null,y.mode);return C.lanes=A,C.return=y,C}finally{}}}var Ws=Dw(!0),Pw=Dw(!1),gr=!1;function vb(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function E1(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 Ir(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=Hm(e),ww(e,null,n),t}return h0(e,o,t,n),Hm(e)}function qu(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,J_(e,n)}}function Ux(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 C1=!1;function Vu(){if(C1){var e=Ol;if(e!==null)throw e}}function ju(e,t,n,o){C1=!1;var a=e.updateQueue;gr=!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===Hl&&(C1=!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:gr=!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),Fr|=s,e.lanes=s,e.memoizedState=d}}function Bw(e,t){if(typeof e!="function")throw Error(O(191,e));e.call(t)}function Nw(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Bw(n[e],t)}var Ul=Go(null),qm=Go(0);function jk(e,t){e=Da,Ne(qm,e),Ne(Ul,t),Da=e|t.baseLanes}function I1(){Ne(qm,Da),Ne(Ul,Ul.current)}function Sb(){Da=qm.current,_t(Ul),_t(qm)}var En=Go(null),Kn=null;function br(e){var t=e.alternate;Ne(tt,tt.current&1),Ne(En,e),Kn===null&&(t===null||Ul.current!==null||t.memoizedState!==null)&&(Kn=e)}function M1(e){Ne(tt,tt.current),Ne(En,e),Kn===null&&(Kn=e)}function zw(e){e.tag===22?(Ne(tt,tt.current),Ne(En,e),Kn===null&&(Kn=e)):Ar(e)}function Ar(){Ne(tt,tt.current),Ne(En,En.current)}function An(e){_t(En),Kn===e&&(Kn=null),_t(tt)}var tt=Go(0);function Vm(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||K1(n)||$1(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 Ma=0,oe=null,Me=null,rt=null,jm=!1,Pl=!1,qs=!1,Zm=0,sd=0,Bl=null,GB=0;function Qe(){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(!Tn(e[n],t[n]))return!1;return!0}function kb(e,t,n,o,a,r){return Ma=r,oe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,K.H=e===null||e.memoizedState===null?mT:Pb,qs=!1,r=n(o,a),qs=!1,Pl&&(r=Hw(t,n,o,a)),Fw(e),r}function Fw(e){K.H=id;var t=Me!==null&&Me.next!==null;if(Ma=0,rt=Me=oe=null,jm=!1,sd=0,Bl=null,t)throw Error(O(300));e===null||lt||(e=e.dependencies,e!==null&&Gm(e)&&(lt=!0))}function Hw(e,t,n,o){oe=e;var a=0;do{if(Pl&&(Bl=null),sd=0,Pl=!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=yT,r=t(n,o)}while(Pl);return r}function WB(){var e=K.H,t=e.useState()[0];return t=typeof t.then=="function"?Ad(t):t,e=e.useState()[0],(Me!==null?Me.memoizedState:null)!==e&&(oe.flags|=1024),t}function _b(){var e=Zm!==0;return Zm=0,e}function wb(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Tb(e){if(jm){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}jm=!1}Ma=0,rt=Me=oe=null,Pl=!1,sd=Zm=0,Bl=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 y0(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ad(e){var t=sd;return sd+=1,Bl===null&&(Bl=[]),e=Ow(Bl,e,t),t=oe,(rt===null?t.memoizedState:rt.next)===null&&(t=t.alternate,K.H=t===null||t.memoizedState===null?mT:Pb),e}function g0(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Ad(e);if(e.$$typeof===ka)return Ot(e)}throw Error(O(438,String(e)))}function Eb(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=y0(),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]=E7;return t.index++,n}function Ra(e,t){return typeof t=="function"?t(e):t}function _m(e){var t=nt();return Cb(t,Me,e)}function Cb(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:(Ma&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===Hl&&(u=!0);else if((Ma&f)===f){c=c.next,f===Hl&&(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,Fr|=f;d=c.action,qs&&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,Fr|=d;c=c.next}while(c!==null&&c!==t);if(l===null?s=r:l.next=i,!Tn(r,e.memoizedState)&&(lt=!0,u&&(n=Ol,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 Gx(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);Tn(r,t.memoizedState)||(lt=!0),t.memoizedState=r,t.baseQueue===null&&(t.baseState=r),n.lastRenderedState=r}return[r,o]}function Uw(e,t,n){var o=oe,a=nt(),r=be;if(r){if(n===void 0)throw Error(O(407));n=n()}else n=t();var s=!Tn((Me||a).memoizedState,n);if(s&&(a.memoizedState=n,lt=!0),a=a.queue,Ib(qw.bind(null,o,a,e),[e]),a.getSnapshot!==t||s||rt!==null&&rt.memoizedState.tag&1){if(o.flags|=2048,Gl(9,{destroy:void 0},Ww.bind(null,o,a,n,t),null),De===null)throw Error(O(349));r||(Ma&127)!==0||Gw(o,t,n)}return n}function Gw(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=oe.updateQueue,t===null?(t=y0(),oe.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Ww(e,t,n,o){t.value=n,t.getSnapshot=o,Vw(t)&&jw(e)}function qw(e,t,n){return n(function(){Vw(t)&&jw(e)})}function Vw(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Tn(e,n)}catch{return!0}}function jw(e){var t=Ys(e,2);t!==null&&on(t,e,2)}function R1(e){var t=Zt();if(typeof e=="function"){var n=e;if(e=n(),qs){Sr(!0);try{n()}finally{Sr(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:e},t}function Zw(e,t,n,o){return e.baseState=n,Cb(e,Me,typeof o=="function"?o:Ra)}function qB(e,t,n,o,a){if(b0(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,Xw(t,r)):(r.next=n.next,t.pending=n.next=r)}}function Xw(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),Zk(e,t,i)}catch(c){O1(e,t,c)}finally{r!==null&&s.types!==null&&(r.types=s.types),K.T=r}}else try{r=n(a,o),Zk(e,t,r)}catch(c){O1(e,t,c)}}function Zk(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(o){Xk(e,t,o)},function(o){return O1(e,t,o)}):Xk(e,t,n)}function Xk(e,t,n){t.status="fulfilled",t.value=n,Yw(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Xw(e,n)))}function O1(e,t,n){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=n,Yw(t),t=t.next;while(t!==o)}e.action=null}function Yw(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Kw(e,t){return t}function Yk(e,t){if(be){var n=De.formState;if(n!==null){e:{var o=oe;if(be){if(We){t:{for(var a=We,r=Yn;a.nodeType!==8;){if(!r){a=null;break t}if(a=$n(a.nextSibling),a===null){a=null;break t}}r=a.data,a=r==="F!"||r==="F"?a:null}if(a){We=$n(a.nextSibling),o=a.data==="F!";break e}}Nr(o)}o=!1}o&&(t=n[0])}}return n=Zt(),n.memoizedState=n.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kw,lastRenderedState:t},n.queue=o,n=fT.bind(null,oe,o),o.dispatch=n,o=R1(!1),r=Db.bind(null,oe,!1,o.queue),o=Zt(),a={state:t,dispatch:null,action:e,pending:null},o.queue=a,n=qB.bind(null,oe,a,r,n),a.dispatch=n,o.memoizedState=e,[t,n,!1]}function Kk(e){var t=nt();return $w(t,Me,e)}function $w(e,t,n){if(t=Cb(e,t,Kw)[0],e=_m(Ra)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=Ad(t)}catch(s){throw s===$l?m0:s}else o=t;t=nt();var a=t.queue,r=a.dispatch;return n!==t.memoizedState&&(oe.flags|=2048,Gl(9,{destroy:void 0},VB.bind(null,a,n),null)),[o,r,e]}function VB(e,t){e.action=t}function $k(e){var t=nt(),n=Me;if(n!==null)return $w(t,n,e);nt(),t=t.memoizedState,n=nt();var o=n.queue.dispatch;return n.memoizedState=e,[t,o,!1]}function Gl(e,t,n,o){return e={tag:e,create:n,deps:o,inst:t,next:null},t=oe.updateQueue,t===null&&(t=y0(),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 Qw(){return nt().memoizedState}function wm(e,t,n,o){var a=Zt();oe.flags|=e,a.memoizedState=Gl(1|t,{destroy:void 0},n,o===void 0?null:o)}function x0(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=Gl(t,r,n,o):(oe.flags|=e,a.memoizedState=Gl(1|t,r,n,o))}function Qk(e,t){wm(8390656,8,e,t)}function Ib(e,t){x0(2048,8,e,t)}function jB(e){oe.flags|=4;var t=oe.updateQueue;if(t===null)t=y0(),oe.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Jw(e){var t=nt().memoizedState;return jB({ref:t,nextImpl:e}),function(){if((ke&2)!==0)throw Error(O(440));return t.impl.apply(void 0,arguments)}}function eT(e,t){return x0(4,2,e,t)}function tT(e,t){return x0(4,4,e,t)}function nT(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 oT(e,t,n){n=n!=null?n.concat([e]):null,x0(4,4,nT.bind(null,t,e),n)}function Mb(){}function aT(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 rT(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(),qs){Sr(!0);try{e()}finally{Sr(!1)}}return n.memoizedState=[o,t],o}function Rb(e,t,n){return n===void 0||(Ma&1073741824)!==0&&(me&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=ZT(),oe.lanes|=e,Fr|=e,n)}function sT(e,t,n,o){return Tn(n,t)?n:Ul.current!==null?(e=Rb(e,n,o),Tn(e,t)||(lt=!0),e):(Ma&42)===0||(Ma&1073741824)!==0&&(me&261930)===0?(lt=!0,e.memoizedState=n):(e=ZT(),oe.lanes|=e,Fr|=e,t)}function iT(e,t,n,o,a){var r=_e.p;_e.p=r!==0&&8>r?r:8;var s=K.T,i={};K.T=i,Db(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=UB(l,o);Zu(e,t,u,wn(e))}else Zu(e,t,o,wn(e))}catch(d){Zu(e,t,{then:function(){},status:"rejected",reason:d},wn())}finally{_e.p=r,s!==null&&i.types!==null&&(s.types=i.types),K.T=s}}function ZB(){}function D1(e,t,n,o){if(e.tag!==5)throw Error(O(476));var a=lT(e).queue;iT(e,a,t,Bs,n===null?ZB:function(){return cT(e),n(o)})}function lT(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Bs,baseState:Bs,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:Bs},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ra,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function cT(e){var t=lT(e);t.next===null&&(t=e.alternate.memoizedState),Zu(e,t.next.queue,{},wn())}function Ob(){return Ot(ud)}function uT(){return nt().memoizedState}function dT(){return nt().memoizedState}function XB(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=wn();e=Cr(n);var o=Ir(t,e,n);o!==null&&(on(o,t,n),qu(o,t,n)),t={cache:xb()},e.payload=t;return}t=t.return}}function YB(e,t,n){var o=wn();n={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},b0(e)?pT(t,n):(n=hb(e,t,n,o),n!==null&&(on(n,e,o),hT(n,t,o)))}function fT(e,t,n){var o=wn();Zu(e,t,n,o)}function Zu(e,t,n,o){var a={lane:o,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(b0(e))pT(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,Tn(i,s))return h0(e,t,a,0),De===null&&p0(),!1}catch{}finally{}if(n=hb(e,t,a,o),n!==null)return on(n,e,o),hT(n,t,o),!0}return!1}function Db(e,t,n,o){if(o={lane:2,revertLane:Wb(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},b0(e)){if(t)throw Error(O(479))}else t=hb(e,n,o,2),t!==null&&on(t,e,2)}function b0(e){var t=e.alternate;return e===oe||t!==null&&t===oe}function pT(e,t){Pl=jm=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function hT(e,t,n){if((n&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,n|=o,t.lanes=n,J_(e,n)}}var id={readContext:Ot,use:g0,useCallback:Qe,useContext:Qe,useEffect:Qe,useImperativeHandle:Qe,useLayoutEffect:Qe,useInsertionEffect:Qe,useMemo:Qe,useReducer:Qe,useRef:Qe,useState:Qe,useDebugValue:Qe,useDeferredValue:Qe,useTransition:Qe,useSyncExternalStore:Qe,useId:Qe,useHostTransitionStatus:Qe,useFormState:Qe,useActionState:Qe,useOptimistic:Qe,useMemoCache:Qe,useCacheRefresh:Qe};id.useEffectEvent=Qe;var mT={readContext:Ot,use:g0,useCallback:function(e,t){return Zt().memoizedState=[e,t===void 0?null:t],e},useContext:Ot,useEffect:Qk,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,wm(4194308,4,nT.bind(null,t,e),n)},useLayoutEffect:function(e,t){return wm(4194308,4,e,t)},useInsertionEffect:function(e,t){wm(4,2,e,t)},useMemo:function(e,t){var n=Zt();t=t===void 0?null:t;var o=e();if(qs){Sr(!0);try{e()}finally{Sr(!1)}}return n.memoizedState=[o,t],o},useReducer:function(e,t,n){var o=Zt();if(n!==void 0){var a=n(t);if(qs){Sr(!0);try{n(t)}finally{Sr(!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=YB.bind(null,oe,e),[o.memoizedState,e]},useRef:function(e){var t=Zt();return e={current:e},t.memoizedState=e},useState:function(e){e=R1(e);var t=e.queue,n=fT.bind(null,oe,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Mb,useDeferredValue:function(e,t){var n=Zt();return Rb(n,e,t)},useTransition:function(){var e=R1(!1);return e=iT.bind(null,oe,e.queue,!0,!1),Zt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var o=oe,a=Zt();if(be){if(n===void 0)throw Error(O(407));n=n()}else{if(n=t(),De===null)throw Error(O(349));(me&127)!==0||Gw(o,t,n)}a.memoizedState=n;var r={value:n,getSnapshot:t};return a.queue=r,Qk(qw.bind(null,o,r,e),[e]),o.flags|=2048,Gl(9,{destroy:void 0},Ww.bind(null,o,r,n,t),null),n},useId:function(){var e=Zt(),t=De.identifierPrefix;if(be){var n=Fo,o=zo;n=(o&~(1<<32-_n(o)-1)).toString(32)+n,t="_"+t+"R_"+n,n=Zm++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=GB++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Ob,useFormState:Yk,useActionState:Yk,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=Db.bind(null,oe,!0,n),n.dispatch=t,[e,t]},useMemoCache:Eb,useCacheRefresh:function(){return Zt().memoizedState=XB.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)}}},Pb={readContext:Ot,use:g0,useCallback:aT,useContext:Ot,useEffect:Ib,useImperativeHandle:oT,useInsertionEffect:eT,useLayoutEffect:tT,useMemo:rT,useReducer:_m,useRef:Qw,useState:function(){return _m(Ra)},useDebugValue:Mb,useDeferredValue:function(e,t){var n=nt();return sT(n,Me.memoizedState,e,t)},useTransition:function(){var e=_m(Ra)[0],t=nt().memoizedState;return[typeof e=="boolean"?e:Ad(e),t]},useSyncExternalStore:Uw,useId:uT,useHostTransitionStatus:Ob,useFormState:Kk,useActionState:Kk,useOptimistic:function(e,t){var n=nt();return Zw(n,Me,e,t)},useMemoCache:Eb,useCacheRefresh:dT};Pb.useEffectEvent=Jw;var yT={readContext:Ot,use:g0,useCallback:aT,useContext:Ot,useEffect:Ib,useImperativeHandle:oT,useInsertionEffect:eT,useLayoutEffect:tT,useMemo:rT,useReducer:Gx,useRef:Qw,useState:function(){return Gx(Ra)},useDebugValue:Mb,useDeferredValue:function(e,t){var n=nt();return Me===null?Rb(n,e,t):sT(n,Me.memoizedState,e,t)},useTransition:function(){var e=Gx(Ra)[0],t=nt().memoizedState;return[typeof e=="boolean"?e:Ad(e),t]},useSyncExternalStore:Uw,useId:uT,useHostTransitionStatus:Ob,useFormState:$k,useActionState:$k,useOptimistic:function(e,t){var n=nt();return Me!==null?Zw(n,Me,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:Eb,useCacheRefresh:dT};yT.useEffectEvent=Jw;function Wx(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 P1={enqueueSetState:function(e,t,n){e=e._reactInternals;var o=wn(),a=Cr(o);a.payload=t,n!=null&&(a.callback=n),t=Ir(e,a,o),t!==null&&(on(t,e,o),qu(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var o=wn(),a=Cr(o);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=Ir(e,a,o),t!==null&&(on(t,e,o),qu(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=wn(),o=Cr(n);o.tag=2,t!=null&&(o.callback=t),t=Ir(e,o,n),t!==null&&(on(t,e,n),qu(t,e,n))}};function Jk(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?!nd(n,o)||!nd(a,r):!0}function e_(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&&P1.enqueueReplaceState(t,t.state,null)}function Vs(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 gT(e){Fm(e)}function xT(e){console.error(e)}function bT(e){Fm(e)}function Xm(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function t_(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 B1(e,t,n){return n=Cr(n),n.tag=3,n.payload={element:null},n.callback=function(){Xm(e,t)},n}function AT(e){return e=Cr(e),e.tag=3,e}function vT(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(){t_(t,n,o)}}var s=n.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(e.callback=function(){t_(t,n,o),typeof a!="function"&&(Mr===null?Mr=new Set([this]):Mr.add(this));var i=o.stack;this.componentDidCatch(o.value,{componentStack:i!==null?i:""})})}function KB(e,t,n,o,a){if(n.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=n.alternate,t!==null&&Kl(t,n,a,!0),n=En.current,n!==null){switch(n.tag){case 31:case 13:return Kn===null?Jm():n.alternate===null&&Je===0&&(Je=3),n.flags&=-257,n.flags|=65536,n.lanes=a,o===Wm?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([o]):t.add(o),e1(e,o,a)),!1;case 22:return n.flags|=65536,o===Wm?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)),e1(e,o,a)),!1}throw Error(O(435,n.tag))}return e1(e,o,a),Jm(),!1}if(be)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}),ad(Xn(e,n)))):(o!==L1&&(t=Error(O(423),{cause:o}),ad(Xn(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,o=Xn(o,n),a=B1(e.stateNode,o,a),Ux(e,a),Je!==4&&(Je=2)),!1;var r=Error(O(520),{cause:o});if(r=Xn(r,n),Ku===null?Ku=[r]:Ku.push(r),Je!==4&&(Je=2),t===null)return!0;o=Xn(o,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=B1(n.stateNode,o,e),Ux(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"&&(Mr===null||!Mr.has(r))))return n.flags|=65536,a&=-a,n.lanes|=a,a=AT(a),vT(a,e,n,o),Ux(n,a),!1}n=n.return}while(n!==null);return!1}var Bb=Error(O(461)),lt=!1;function It(e,t,n,o){t.child=e===null?Pw(t,null,n,o):Ws(t,e.child,n,o)}function n_(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 Gs(t),o=kb(e,t,n,s,r,a),i=_b(),e!==null&&!lt?(wb(e,t,a),Oa(e,t,a)):(be&&i&&yb(t),t.flags|=1,It(e,t,o,a),t.child)}function o_(e,t,n,o,a){if(e===null){var r=n.type;return typeof r=="function"&&!mb(r)&&r.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=r,ST(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,!Nb(e,a)){var s=r.memoizedProps;if(n=n.compare,n=n!==null?n:nd,n(s,o)&&e.ref===t.ref)return Oa(e,t,a)}return t.flags|=1,e=Ta(r,o),e.ref=t.ref,e.return=t,t.child=e}function ST(e,t,n,o,a){if(e!==null){var r=e.memoizedProps;if(nd(r,o)&&e.ref===t.ref)if(lt=!1,t.pendingProps=o=r,Nb(e,a))(e.flags&131072)!==0&&(lt=!0);else return t.lanes=e.lanes,Oa(e,t,a)}return N1(e,t,n,o,a)}function LT(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 a_(e,t,r,n,o)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&km(t,r!==null?r.cachePool:null),r!==null?jk(t,r):I1(),zw(t);else return o=t.lanes=536870912,a_(e,t,r!==null?r.baseLanes|n:n,n,o)}else r!==null?(km(t,r.cachePool),jk(t,r),Ar(t),t.memoizedState=null):(e!==null&&km(t,null),I1(),Ar(t));return It(e,t,a,n),t.child}function zu(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function a_(e,t,n,o,a){var r=bb();return r=r===null?null:{parent:it._currentValue,pool:r},t.memoizedState={baseLanes:n,cachePool:r},e!==null&&km(t,null),I1(),zw(t),e!==null&&Kl(e,t,o,!0),t.childLanes=a,null}function Tm(e,t){return t=Ym({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function r_(e,t,n){return Ws(t,e.child,null,n),e=Tm(t,t.pendingProps),e.flags|=2,An(t),t.memoizedState=null,e}function $B(e,t,n){var o=t.pendingProps,a=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(be){if(o.mode==="hidden")return e=Tm(t,o),t.lanes=536870912,zu(null,e);if(M1(t),(e=We)?(e=mE(e,Yn),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Br!==null?{id:zo,overflow:Fo}:null,retryLane:536870912,hydrationErrors:null},n=Ew(e),n.return=t,t.child=n,Rt=t,We=null)):e=null,e===null)throw Nr(t);return t.lanes=536870912,null}return Tm(t,o)}var r=e.memoizedState;if(r!==null){var s=r.dehydrated;if(M1(t),a)if(t.flags&256)t.flags&=-257,t=r_(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||Kl(e,t,n,!1),a=(n&e.childLanes)!==0,lt||a){if(o=De,o!==null&&(s=ew(o,n),s!==0&&s!==r.retryLane))throw r.retryLane=s,Ys(e,s),on(o,e,s),Bb;Jm(),t=r_(e,t,n)}else e=r.treeContext,We=$n(s.nextSibling),Rt=t,be=!0,Er=null,Yn=!1,e!==null&&Iw(t,e),t=Tm(t,o),t.flags|=4096;return t}return e=Ta(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Em(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 N1(e,t,n,o,a){return Gs(t),n=kb(e,t,n,o,void 0,a),o=_b(),e!==null&&!lt?(wb(e,t,a),Oa(e,t,a)):(be&&o&&yb(t),t.flags|=1,It(e,t,n,a),t.child)}function s_(e,t,n,o,a,r){return Gs(t),t.updateQueue=null,n=Hw(t,o,n,a),Fw(e),o=_b(),e!==null&&!lt?(wb(e,t,r),Oa(e,t,r)):(be&&o&&yb(t),t.flags|=1,It(e,t,n,r),t.child)}function i_(e,t,n,o,a){if(Gs(t),t.stateNode===null){var r=wl,s=n.contextType;typeof s=="object"&&s!==null&&(r=Ot(s)),r=new n(o,r),t.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=P1,t.stateNode=r,r._reactInternals=t,r=t.stateNode,r.props=o,r.state=t.memoizedState,r.refs={},vb(t),s=n.contextType,r.context=typeof s=="object"&&s!==null?Ot(s):wl,r.state=t.memoizedState,s=n.getDerivedStateFromProps,typeof s=="function"&&(Wx(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&&P1.enqueueReplaceState(r,r.state,null),ju(t,o,r,a),Vu(),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=Vs(n,i);r.props=l;var c=r.context,u=n.contextType;s=wl,typeof u=="object"&&u!==null&&(s=Ot(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)&&e_(t,r,o,s),gr=!1;var f=t.memoizedState;r.state=f,ju(t,o,r,a),Vu(),c=t.memoizedState,i||f!==c||gr?(typeof d=="function"&&(Wx(t,n,d,o),c=t.memoizedState),(l=gr||Jk(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,E1(e,t),s=t.memoizedProps,u=Vs(n,s),r.props=u,d=t.pendingProps,f=r.context,c=n.contextType,l=wl,typeof c=="object"&&c!==null&&(l=Ot(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)&&e_(t,r,o,l),gr=!1,f=t.memoizedState,r.state=f,ju(t,o,r,a),Vu();var p=t.memoizedState;s!==d||f!==p||gr||e!==null&&e.dependencies!==null&&Gm(e.dependencies)?(typeof i=="function"&&(Wx(t,n,i,o),p=t.memoizedState),(u=gr||Jk(t,n,u,o,f,p,l)||e!==null&&e.dependencies!==null&&Gm(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,Em(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=Ws(t,e.child,null,a),t.child=Ws(t,null,n,a)):It(e,t,n,a),t.memoizedState=r.state,e=t.child):e=Oa(e,t,a),e}function l_(e,t,n,o){return Us(),t.flags|=256,It(e,t,n,o),t.child}var qx={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Vx(e){return{baseLanes:e,cachePool:Rw()}}function jx(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Sn),e}function kT(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(be){if(a?br(t):Ar(t),(e=We)?(e=mE(e,Yn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Br!==null?{id:zo,overflow:Fo}:null,retryLane:536870912,hydrationErrors:null},n=Ew(e),n.return=t,t.child=n,Rt=t,We=null)):e=null,e===null)throw Nr(t);return $1(e)?t.lanes=32:t.lanes=536870912,null}var i=o.children;return o=o.fallback,a?(Ar(t),a=t.mode,i=Ym({mode:"hidden",children:i},a),o=Ns(o,a,n,null),i.return=t,o.return=t,i.sibling=o,t.child=i,o=t.child,o.memoizedState=Vx(n),o.childLanes=jx(e,s,n),t.memoizedState=qx,zu(null,o)):(br(t),z1(t,i))}var l=e.memoizedState;if(l!==null&&(i=l.dehydrated,i!==null)){if(r)t.flags&256?(br(t),t.flags&=-257,t=Zx(e,t,n)):t.memoizedState!==null?(Ar(t),t.child=e.child,t.flags|=128,t=null):(Ar(t),i=o.fallback,a=t.mode,o=Ym({mode:"visible",children:o.children},a),i=Ns(i,a,n,null),i.flags|=2,o.return=t,i.return=t,o.sibling=i,t.child=o,Ws(t,e.child,null,n),o=t.child,o.memoizedState=Vx(n),o.childLanes=jx(e,s,n),t.memoizedState=qx,t=zu(null,o));else if(br(t),$1(i)){if(s=i.nextSibling&&i.nextSibling.dataset,s)var c=s.dgst;s=c,o=Error(O(419)),o.stack="",o.digest=s,ad({value:o,source:null,stack:null}),t=Zx(e,t,n)}else if(lt||Kl(e,t,n,!1),s=(n&e.childLanes)!==0,lt||s){if(s=De,s!==null&&(o=ew(s,n),o!==0&&o!==l.retryLane))throw l.retryLane=o,Ys(e,o),on(s,e,o),Bb;K1(i)||Jm(),t=Zx(e,t,n)}else K1(i)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,We=$n(i.nextSibling),Rt=t,be=!0,Er=null,Yn=!1,e!==null&&Iw(t,e),t=z1(t,o.children),t.flags|=4096);return t}return a?(Ar(t),i=o.fallback,a=t.mode,l=e.child,c=l.sibling,o=Ta(l,{mode:"hidden",children:o.children}),o.subtreeFlags=l.subtreeFlags&65011712,c!==null?i=Ta(c,i):(i=Ns(i,a,n,null),i.flags|=2),i.return=t,o.return=t,o.sibling=i,t.child=o,zu(null,o),o=t.child,i=e.child.memoizedState,i===null?i=Vx(n):(a=i.cachePool,a!==null?(l=it._currentValue,a=a.parent!==l?{parent:l,pool:l}:a):a=Rw(),i={baseLanes:i.baseLanes|n,cachePool:a}),o.memoizedState=i,o.childLanes=jx(e,s,n),t.memoizedState=qx,zu(e.child,o)):(br(t),n=e.child,e=n.sibling,n=Ta(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 z1(e,t){return t=Ym({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Ym(e,t){return e=vn(22,e,null,t),e.lanes=0,e}function Zx(e,t,n){return Ws(t,e.child,null,n),e=z1(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function c_(e,t,n){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),_1(e.return,t,n)}function Xx(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 _T(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),It(e,t,o,n),o=be?od:0,!i&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&c_(e,n,t);else if(e.tag===19)c_(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&&Vm(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Xx(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&&Vm(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Xx(t,!0,n,null,r,o);break;case"together":Xx(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function Oa(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Fr|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Kl(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=Ta(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Ta(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Nb(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Gm(e)))}function QB(e,t,n){switch(t.tag){case 3:Pm(t,t.stateNode.containerInfo),xr(t,it,e.memoizedState.cache),Us();break;case 27:case 5:f1(t);break;case 4:Pm(t,t.stateNode.containerInfo);break;case 10:xr(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,M1(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(br(t),t.flags|=128,null):(n&t.child.childLanes)!==0?kT(e,t,n):(br(t),e=Oa(e,t,n),e!==null?e.sibling:null);br(t);break;case 19:var a=(e.flags&128)!==0;if(o=(n&t.childLanes)!==0,o||(Kl(e,t,n,!1),o=(n&t.childLanes)!==0),a){if(o)return _T(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,LT(e,t,n,t.pendingProps);case 24:xr(t,it,e.memoizedState.cache)}return Oa(e,t,n)}function wT(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)lt=!0;else{if(!Nb(e,n)&&(t.flags&128)===0)return lt=!1,QB(e,t,n);lt=(e.flags&131072)!==0}else lt=!1,be&&(t.flags&1048576)!==0&&Cw(t,od,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=Ds(t.elementType),t.type=e,typeof e=="function")mb(e)?(o=Vs(e,o),t.tag=1,t=i_(null,t,e,o,n)):(t.tag=0,t=N1(null,t,e,o,n));else{if(e!=null){var a=e.$$typeof;if(a===tb){t.tag=11,t=n_(null,t,e,o,n);break e}else if(a===nb){t.tag=14,t=o_(null,t,e,o,n);break e}}throw t=u1(e)||e,Error(O(306,t,""))}}return t;case 0:return N1(e,t,t.type,t.pendingProps,n);case 1:return o=t.type,a=Vs(o,t.pendingProps),i_(e,t,o,a,n);case 3:e:{if(Pm(t,t.stateNode.containerInfo),e===null)throw Error(O(387));o=t.pendingProps;var r=t.memoizedState;a=r.element,E1(e,t),ju(t,o,null,n);var s=t.memoizedState;if(o=s.cache,xr(t,it,o),o!==r.cache&&w1(t,[it],n,!0),Vu(),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=l_(e,t,o,n);break e}else if(o!==a){a=Xn(Error(O(424)),t),ad(a),t=l_(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=$n(e.firstChild),Rt=t,be=!0,Er=null,Yn=!0,n=Pw(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Us(),o===a){t=Oa(e,t,n);break e}It(e,t,o,n)}t=t.child}return t;case 26:return Em(e,t),e===null?(n=M_(t.type,null,t.pendingProps,null))?t.memoizedState=n:be||(n=t.type,e=t.pendingProps,o=o0(Tr.current).createElement(n),o[Mt]=t,o[an]=e,Dt(o,n,e),kt(o),t.stateNode=o):t.memoizedState=M_(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return f1(t),e===null&&be&&(o=t.stateNode=yE(t.type,t.pendingProps,Tr.current),Rt=t,Yn=!0,a=We,Ur(t.type)?(Q1=a,We=$n(o.firstChild)):We=a),It(e,t,t.pendingProps.children,n),Em(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&be&&((a=o=We)&&(o=wN(o,t.type,t.pendingProps,Yn),o!==null?(t.stateNode=o,Rt=t,We=$n(o.firstChild),Yn=!1,a=!0):a=!1),a||Nr(t)),f1(t),a=t.type,r=t.pendingProps,s=e!==null?e.memoizedProps:null,o=r.children,X1(a,r)?o=null:s!==null&&X1(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=kb(e,t,WB,null,null,n),ud._currentValue=a),Em(e,t),It(e,t,o,n),t.child;case 6:return e===null&&be&&((e=n=We)&&(n=TN(n,t.pendingProps,Yn),n!==null?(t.stateNode=n,Rt=t,We=null,e=!0):e=!1),e||Nr(t)),null;case 13:return kT(e,t,n);case 4:return Pm(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=Ws(t,null,o,n):It(e,t,o,n),t.child;case 11:return n_(e,t,t.type,t.pendingProps,n);case 7:return It(e,t,t.pendingProps,n),t.child;case 8:return It(e,t,t.pendingProps.children,n),t.child;case 12:return It(e,t,t.pendingProps.children,n),t.child;case 10:return o=t.pendingProps,xr(t,t.type,o.value),It(e,t,o.children,n),t.child;case 9:return a=t.type._context,o=t.pendingProps.children,Gs(t),a=Ot(a),o=o(a),t.flags|=1,It(e,t,o,n),t.child;case 14:return o_(e,t,t.type,t.pendingProps,n);case 15:return ST(e,t,t.type,t.pendingProps,n);case 19:return _T(e,t,n);case 31:return $B(e,t,n);case 22:return LT(e,t,n,t.pendingProps);case 24:return Gs(t),o=Ot(it),e===null?(a=bb(),a===null&&(a=De,r=xb(),a.pooledCache=r,r.refCount++,r!==null&&(a.pooledCacheLanes|=n),a=r),t.memoizedState={parent:o,cache:a},vb(t),xr(t,it,a)):((e.lanes&n)!==0&&(E1(e,t),ju(t,null,null,n),Vu()),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),xr(t,it,o)):(o=r.cache,xr(t,it,o),o!==a.cache&&w1(t,[it],n,!0))),It(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(O(156,t.tag))}function xa(e){e.flags|=4}function Yx(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(KT())e.flags|=8192;else throw Fs=Wm,Ab}else e.flags&=-16777217}function u_(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!bE(t))if(KT())e.flags|=8192;else throw Fs=Wm,Ab}function fm(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?$_():536870912,e.lanes|=t,Wl|=t)}function Mu(e,t){if(!be)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 JB(e,t,n){var o=t.pendingProps;switch(gb(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),Ea(it),Nl(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(hl(t)?xa(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Hx())),Ge(t),null;case 26:var a=t.type,r=t.memoizedState;return e===null?(xa(t),r!==null?(Ge(t),u_(t,r)):(Ge(t),Yx(t,a,null,o,n))):r?r!==e.memoizedState?(xa(t),Ge(t),u_(t,r)):(Ge(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&xa(t),Ge(t),Yx(t,a,e,o,n)),null;case 27:if(Bm(t),n=Tr.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&xa(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Ge(t),null}e=Uo.current,hl(t)?Fk(t,e):(e=yE(a,o,n),t.stateNode=e,xa(t))}return Ge(t),null;case 5:if(Bm(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&xa(t);else{if(!o){if(t.stateNode===null)throw Error(O(166));return Ge(t),null}if(r=Uo.current,hl(t))Fk(t,r);else{var s=o0(Tr.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[Mt]=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(Dt(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&&xa(t)}}return Ge(t),Yx(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&xa(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(O(166));if(e=Tr.current,hl(t)){if(e=t.stateNode,n=t.memoizedProps,o=null,a=Rt,a!==null)switch(a.tag){case 27:case 5:o=a.memoizedProps}e[Mt]=t,e=!!(e.nodeValue===n||o!==null&&o.suppressHydrationWarning===!0||fE(e.nodeValue,n)),e||Nr(t,!0)}else e=o0(e).createTextNode(o),e[Mt]=t,t.stateNode=e}return Ge(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(o=hl(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[Mt]=t}else Us(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ge(t),e=!1}else n=Hx(),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=hl(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[Mt]=t}else Us(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ge(t),a=!1}else a=Hx(),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),fm(t,t.updateQueue),Ge(t),null);case 4:return Nl(),e===null&&qb(t.stateNode.containerInfo),Ge(t),null;case 10:return Ea(t.type),Ge(t),null;case 19:if(_t(tt),o=t.memoizedState,o===null)return Ge(t),null;if(a=(t.flags&128)!==0,r=o.rendering,r===null)if(a)Mu(o,!1);else{if(Je!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(r=Vm(e),r!==null){for(t.flags|=128,Mu(o,!1),e=r.updateQueue,t.updateQueue=e,fm(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Tw(n,e),n=n.sibling;return Ne(tt,tt.current&1|2),be&&Sa(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&Ln()>$m&&(t.flags|=128,a=!0,Mu(o,!1),t.lanes=4194304)}else{if(!a)if(e=Vm(r),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,fm(t,e),Mu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!r.alternate&&!be)return Ge(t),null}else 2*Ln()-o.renderingStartTime>$m&&n!==536870912&&(t.flags|=128,a=!0,Mu(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),be&&Sa(t,o.treeForkCount),e):(Ge(t),null);case 22:case 23:return An(t),Sb(),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&&fm(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&&_t(zs),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ea(it),Ge(t),null;case 25:return null;case 30:return null}throw Error(O(156,t.tag))}function eN(e,t){switch(gb(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ea(it),Nl(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Bm(t),null;case 31:if(t.memoizedState!==null){if(An(t),t.alternate===null)throw Error(O(340));Us()}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));Us()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return _t(tt),null;case 4:return Nl(),null;case 10:return Ea(t.type),null;case 22:case 23:return An(t),Sb(),e!==null&&_t(zs),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ea(it),null;case 25:return null;default:return null}}function TT(e,t){switch(gb(t),t.tag){case 3:Ea(it),Nl();break;case 26:case 27:case 5:Bm(t);break;case 4:Nl();break;case 31:t.memoizedState!==null&&An(t);break;case 13:An(t);break;case 19:_t(tt);break;case 10:Ea(t.type);break;case 22:case 23:An(t),Sb(),e!==null&&_t(zs);break;case 24:Ea(it)}}function vd(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 zr(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 ET(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Nw(t,n)}catch(o){Ce(e,e.return,o)}}}function CT(e,t,n){n.props=Vs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(o){Ce(e,t,o)}}function Xu(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 Ho(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 IT(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 Kx(e,t,n){try{var o=e.stateNode;AN(o,e.type,n,t),o[an]=t}catch(a){Ce(e,e.return,a)}}function MT(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ur(e.type)||e.tag===4}function $x(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||MT(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&&Ur(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 F1(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=_a));else if(o!==4&&(o===27&&Ur(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(F1(e,t,n),e=e.sibling;e!==null;)F1(e,t,n),e=e.sibling}function Km(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&&Ur(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Km(e,t,n),e=e.sibling;e!==null;)Km(e,t,n),e=e.sibling}function RT(e){var t=e.stateNode,n=e.memoizedProps;try{for(var o=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);Dt(t,o,n),t[Mt]=e,t[an]=n}catch(r){Ce(e,e.return,r)}}var La=!1,st=!1,Qx=!1,d_=typeof WeakSet=="function"?WeakSet:Set,Lt=null;function tN(e,t){if(e=e.containerInfo,j1=i0,e=bw(e),fb(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(Z1={focusedElem:e,selectionRange:n},i0=!1,Lt=t;Lt!==null;)if(t=Lt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Lt=e;else for(;Lt!==null;){switch(t=Lt,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=Vs(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)Y1(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Y1(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,Lt=e;break}Lt=t.return}}function OT(e,t,n){var o=n.flags;switch(n.tag){case 0:case 11:case 15:Aa(e,n),o&4&&vd(5,n);break;case 1:if(Aa(e,n),o&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(s){Ce(n,n.return,s)}else{var a=Vs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){Ce(n,n.return,s)}}o&64&&ET(n),o&512&&Xu(n,n.return);break;case 3:if(Aa(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{Nw(e,t)}catch(s){Ce(n,n.return,s)}}break;case 27:t===null&&o&4&&RT(n);case 26:case 5:Aa(e,n),t===null&&o&4&&IT(n),o&512&&Xu(n,n.return);break;case 12:Aa(e,n);break;case 31:Aa(e,n),o&4&&BT(e,n);break;case 13:Aa(e,n),o&4&&NT(e,n),o&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=uN.bind(null,n),EN(e,n))));break;case 22:if(o=n.memoizedState!==null||La,!o){t=t!==null&&t.memoizedState!==null||st,a=La;var r=st;La=o,(st=t)&&!r?va(e,n,(n.subtreeFlags&8772)!==0):Aa(e,n),La=a,st=r}break;case 30:break;default:Aa(e,n)}}function DT(e){var t=e.alternate;t!==null&&(e.alternate=null,DT(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&sb(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 je=null,tn=!1;function ba(e,t,n){for(n=n.child;n!==null;)PT(e,t,n),n=n.sibling}function PT(e,t,n){if(kn&&typeof kn.onCommitFiberUnmount=="function")try{kn.onCommitFiberUnmount(hd,n)}catch{}switch(n.tag){case 26:st||Ho(n,t),ba(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:st||Ho(n,t);var o=je,a=tn;Ur(n.type)&&(je=n.stateNode,tn=!1),ba(e,t,n),Qu(n.stateNode),je=o,tn=a;break;case 5:st||Ho(n,t);case 6:if(o=je,a=tn,je=null,ba(e,t,n),je=o,tn=a,je!==null)if(tn)try{(je.nodeType===9?je.body:je.nodeName==="HTML"?je.ownerDocument.body:je).removeChild(n.stateNode)}catch(r){Ce(n,t,r)}else try{je.removeChild(n.stateNode)}catch(r){Ce(n,t,r)}break;case 18:je!==null&&(tn?(e=je,w_(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),Zl(e)):w_(je,n.stateNode));break;case 4:o=je,a=tn,je=n.stateNode.containerInfo,tn=!0,ba(e,t,n),je=o,tn=a;break;case 0:case 11:case 14:case 15:zr(2,n,t),st||zr(4,n,t),ba(e,t,n);break;case 1:st||(Ho(n,t),o=n.stateNode,typeof o.componentWillUnmount=="function"&&CT(n,t,o)),ba(e,t,n);break;case 21:ba(e,t,n);break;case 22:st=(o=st)||n.memoizedState!==null,ba(e,t,n),st=o;break;default:ba(e,t,n)}}function BT(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Zl(e)}catch(n){Ce(t,t.return,n)}}}function NT(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Zl(e)}catch(n){Ce(t,t.return,n)}}function nN(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new d_),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new d_),t;default:throw Error(O(435,e.tag))}}function pm(e,t){var n=nN(e);t.forEach(function(o){if(!n.has(o)){n.add(o);var a=dN.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(Ur(i.type)){je=i.stateNode,tn=!1;break e}break;case 5:je=i.stateNode,tn=!1;break e;case 3:case 4:je=i.stateNode.containerInfo,tn=!0;break e}i=i.return}if(je===null)throw Error(O(160));PT(r,s,a),je=null,tn=!1,r=a.alternate,r!==null&&(r.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)zT(t,e),t=t.sibling}var xo=null;function zT(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&&(zr(3,e,e.return),vd(3,e),zr(5,e,e.return));break;case 1:Jt(t,e),en(e),o&512&&(st||n===null||Ho(n,n.return)),o&64&&La&&(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=xo;if(Jt(t,e),en(e),o&512&&(st||n===null||Ho(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[gd]||r[Mt]||r.namespaceURI==="http://www.w3.org/2000/svg"||r.hasAttribute("itemprop"))&&(r=a.createElement(o),a.head.insertBefore(r,a.querySelector("head > title"))),Dt(r,o,n),r[Mt]=e,kt(r),o=r;break e;case"link":var s=O_("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),Dt(r,o,n),a.head.appendChild(r);break;case"meta":if(s=O_("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),Dt(r,o,n),a.head.appendChild(r);break;default:throw Error(O(468,o))}r[Mt]=e,kt(r),o=r}e.stateNode=o}else D_(a,e.type,e.stateNode);else e.stateNode=R_(a,o,e.memoizedProps);else r!==o?(r===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):r.count--,o===null?D_(a,e.type,e.stateNode):R_(a,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Kx(e,e.memoizedProps,n.memoizedProps)}break;case 27:Jt(t,e),en(e),o&512&&(st||n===null||Ho(n,n.return)),n!==null&&o&4&&Kx(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Jt(t,e),en(e),o&512&&(st||n===null||Ho(n,n.return)),e.flags&32){a=e.stateNode;try{Fl(a,"")}catch(h){Ce(e,e.return,h)}}o&4&&e.stateNode!=null&&(a=e.memoizedProps,Kx(e,a,n!==null?n.memoizedProps:a)),o&1024&&(Qx=!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){Ce(e,e.return,h)}}break;case 3:if(Mm=null,a=xo,xo=a0(t.containerInfo),Jt(t,e),xo=a,en(e),o&4&&n!==null&&n.memoizedState.isDehydrated)try{Zl(t.containerInfo)}catch(h){Ce(e,e.return,h)}Qx&&(Qx=!1,FT(e));break;case 4:o=xo,xo=a0(e.stateNode.containerInfo),Jt(t,e),en(e),xo=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,pm(e,o)));break;case 13:Jt(t,e),en(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(A0=Ln()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,pm(e,o)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,c=La,u=st;if(La=c||a,st=u||l,Jt(t,e),st=u,La=c,en(e),o&8192)e:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||La||st||Ps(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?T_(p,!0):T_(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,pm(e,n))));break;case 19:Jt(t,e),en(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,pm(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(MT(o)){n=o;break}o=o.return}if(n==null)throw Error(O(160));switch(n.tag){case 27:var a=n.stateNode,r=$x(e);Km(e,r,a);break;case 5:var s=n.stateNode;n.flags&32&&(Fl(s,""),n.flags&=-33);var i=$x(e);Km(e,i,s);break;case 3:case 4:var l=n.stateNode.containerInfo,c=$x(e);F1(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 FT(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;FT(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Aa(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)OT(e,t.alternate,t),t=t.sibling}function Ps(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:zr(4,t,t.return),Ps(t);break;case 1:Ho(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&CT(t,t.return,n),Ps(t);break;case 27:Qu(t.stateNode);case 26:case 5:Ho(t,t.return),Ps(t);break;case 22:t.memoizedState===null&&Ps(t);break;case 30:Ps(t);break;default:Ps(t)}e=e.sibling}}function va(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:va(a,r,n),vd(4,r);break;case 1:if(va(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++)Bw(l[a],i)}catch(c){Ce(o,o.return,c)}}n&&s&64&&ET(r),Xu(r,r.return);break;case 27:RT(r);case 26:case 5:va(a,r,n),n&&o===null&&s&4&&IT(r),Xu(r,r.return);break;case 12:va(a,r,n);break;case 31:va(a,r,n),n&&s&4&&BT(a,r);break;case 13:va(a,r,n),n&&s&4&&NT(a,r);break;case 22:r.memoizedState===null&&va(a,r,n),Xu(r,r.return);break;case 30:break;default:va(a,r,n)}t=t.sibling}}function zb(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&&bd(n))}function Fb(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&bd(e))}function go(e,t,n,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)HT(e,t,n,o),t=t.sibling}function HT(e,t,n,o){var a=t.flags;switch(t.tag){case 0:case 11:case 15:go(e,t,n,o),a&2048&&vd(9,t);break;case 1:go(e,t,n,o);break;case 3:go(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&&bd(e)));break;case 12:if(a&2048){go(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 go(e,t,n,o);break;case 31:go(e,t,n,o);break;case 13:go(e,t,n,o);break;case 23:break;case 22:r=t.stateNode,s=t.alternate,t.memoizedState!==null?r._visibility&2?go(e,t,n,o):Yu(e,t):r._visibility&2?go(e,t,n,o):(r._visibility|=2,yl(e,t,n,o,(t.subtreeFlags&10256)!==0||!1)),a&2048&&zb(s,t);break;case 24:go(e,t,n,o),a&2048&&Fb(t.alternate,t);break;default:go(e,t,n,o)}}function yl(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:yl(r,s,i,l,a),vd(8,s);break;case 23:break;case 22:var u=s.stateNode;s.memoizedState!==null?u._visibility&2?yl(r,s,i,l,a):Yu(r,s):(u._visibility|=2,yl(r,s,i,l,a)),a&&c&2048&&zb(s.alternate,s);break;case 24:yl(r,s,i,l,a),a&&c&2048&&Fb(s.alternate,s);break;default:yl(r,s,i,l,a)}t=t.sibling}}function Yu(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:Yu(n,o),a&2048&&zb(o.alternate,o);break;case 24:Yu(n,o),a&2048&&Fb(o.alternate,o);break;default:Yu(n,o)}t=t.sibling}}var Fu=8192;function ml(e,t,n){if(e.subtreeFlags&Fu)for(e=e.child;e!==null;)UT(e,t,n),e=e.sibling}function UT(e,t,n){switch(e.tag){case 26:ml(e,t,n),e.flags&Fu&&e.memoizedState!==null&&HN(n,xo,e.memoizedState,e.memoizedProps);break;case 5:ml(e,t,n);break;case 3:case 4:var o=xo;xo=a0(e.stateNode.containerInfo),ml(e,t,n),xo=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=Fu,Fu=16777216,ml(e,t,n),Fu=o):ml(e,t,n));break;default:ml(e,t,n)}}function GT(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 Ru(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];Lt=o,qT(o,e)}GT(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)WT(e),e=e.sibling}function WT(e){switch(e.tag){case 0:case 11:case 15:Ru(e),e.flags&2048&&zr(9,e,e.return);break;case 3:Ru(e);break;case 12:Ru(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Cm(e)):Ru(e);break;default:Ru(e)}}function Cm(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];Lt=o,qT(o,e)}GT(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:zr(8,t,t.return),Cm(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Cm(t));break;default:Cm(t)}e=e.sibling}}function qT(e,t){for(;Lt!==null;){var n=Lt;switch(n.tag){case 0:case 11:case 15:zr(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:bd(n.memoizedState.cache)}if(o=n.child,o!==null)o.return=n,Lt=o;else e:for(n=e;Lt!==null;){o=Lt;var a=o.sibling,r=o.return;if(DT(o),o===n){Lt=null;break e}if(a!==null){a.return=r,Lt=a;break e}Lt=r}}}var oN={getCacheForType:function(e){var t=Ot(it),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ot(it).controller.signal}},aN=typeof WeakMap=="function"?WeakMap:Map,ke=0,De=null,fe=null,me=0,Ee=0,bn=null,kr=!1,Ql=!1,Hb=!1,Da=0,Je=0,Fr=0,Hs=0,Ub=0,Sn=0,Wl=0,Ku=null,nn=null,H1=!1,A0=0,VT=0,$m=1/0,Qm=null,Mr=null,ht=0,Rr=null,ql=null,Ca=0,U1=0,G1=null,jT=null,$u=0,W1=null;function wn(){return(ke&2)!==0&&me!==0?me&-me:K.T!==null?Wb():tw()}function ZT(){if(Sn===0)if((me&536870912)===0||be){var e=om;om<<=1,(om&3932160)===0&&(om=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)&&(Vl(e,0),_r(e,me,Sn,!1)),yd(e,n),((ke&2)===0||e!==De)&&(e===De&&((ke&2)===0&&(Hs|=n),Je===4&&_r(e,me,Sn,!1)),Wo(e))}function XT(e,t,n){if((ke&6)!==0)throw Error(O(327));var o=!n&&(t&127)===0&&(t&e.expiredLanes)===0||md(e,t),a=o?iN(e,t):Jx(e,t,!0),r=o;do{if(a===0){Ql&&!o&&_r(e,t,0,!1);break}else{if(n=e.current.alternate,r&&!rN(n)){a=Jx(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=Ku;var l=i.current.memoizedState.isDehydrated;if(l&&(Vl(i,s).flags|=256),s=Jx(i,s,!1),s!==2){if(Hb&&!l){i.errorRecoveryDisabledLanes|=r,Hs|=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){Vl(e,0),_r(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:_r(o,t,Sn,!kr);break e;case 2:nn=null;break;case 3:case 5:break;default:throw Error(O(329))}if((t&62914560)===t&&(a=A0+300-Ln(),10<a)){if(_r(o,t,Sn,!kr),c0(o,0,!0)!==0)break e;Ca=t,o.timeoutHandle=hE(f_.bind(null,o,n,nn,Qm,H1,t,Sn,Hs,Wl,kr,r,"Throttled",-0,0),a);break e}f_(o,n,nn,Qm,H1,t,Sn,Hs,Wl,kr,r,null,-0,0)}}break}while(!0);Wo(e)}function f_(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:_a},UT(t,r,d);var h=(r&62914560)===r?A0-Ln():(r&4194048)===r?VT-Ln():0;if(h=UN(d,h),h!==null){Ca=r,e.cancelPendingCommit=h(h_.bind(null,e,t,r,n,o,a,s,i,l,u,d,null,f,p)),_r(e,r,s,!c);return}}h_(e,t,r,n,o,a,s,i,l)}function rN(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(!Tn(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 _r(e,t,n,o){t&=~Ub,t&=~Hs,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var a=t;0<a;){var r=31-_n(a),s=1<<r;o[r]=-1,a&=~s}n!==0&&Q_(e,n,t)}function v0(){return(ke&6)===0?(Sd(0,!1),!1):!0}function Gb(){if(fe!==null){if(Ee===0)var e=fe.return;else e=fe,wa=Ks=null,Tb(e),Dl=null,rd=0,e=fe;for(;e!==null;)TT(e.alternate,e),e=e.return;fe=null}}function Vl(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,LN(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Ca=0,Gb(),De=e,fe=n=Ta(e.current,null),me=t,Ee=0,bn=null,kr=!1,Ql=md(e,t),Hb=!1,Wl=Sn=Ub=Hs=Fr=Je=0,nn=Ku=null,H1=!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-_n(o),r=1<<a;t|=e[a],o&=~r}return Da=t,p0(),n}function YT(e,t){oe=null,K.H=id,t===$l||t===m0?(t=qk(),Ee=3):t===Ab?(t=qk(),Ee=4):Ee=t===Bb?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,bn=t,fe===null&&(Je=1,Xm(e,Xn(t,e.current)))}function KT(){var e=En.current;return e===null?!0:(me&4194048)===me?Kn===null:(me&62914560)===me||(me&536870912)!==0?e===Kn:!1}function $T(){var e=K.H;return K.H=id,e===null?id:e}function QT(){var e=K.A;return K.A=oN,e}function Jm(){Je=4,kr||(me&4194048)!==me&&En.current!==null||(Ql=!0),(Fr&134217727)===0&&(Hs&134217727)===0||De===null||_r(De,me,Sn,!1)}function Jx(e,t,n){var o=ke;ke|=2;var a=$T(),r=QT();(De!==e||me!==t)&&(Qm=null,Vl(e,t)),t=!1;var s=Je;e:do try{if(Ee!==0&&fe!==null){var i=fe,l=bn;switch(Ee){case 8:Gb(),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,Cl(e,i,l,c),n&&Ql){s=0;break e}break;default:c=Ee,Ee=0,bn=null,Cl(e,i,l,c)}}sN(),s=Je;break}catch(u){YT(e,u)}while(!0);return t&&e.shellSuspendCounter++,wa=Ks=null,ke=o,K.H=a,K.A=r,fe===null&&(De=null,me=0,p0()),s}function sN(){for(;fe!==null;)JT(fe)}function iN(e,t){var n=ke;ke|=2;var o=$T(),a=QT();De!==e||me!==t?(Qm=null,$m=Ln()+500,Vl(e,t)):Ql=md(e,t);e:do try{if(Ee!==0&&fe!==null){t=fe;var r=bn;t:switch(Ee){case 1:Ee=0,bn=null,Cl(e,t,r,1);break;case 2:case 9:if(Wk(r)){Ee=0,bn=null,p_(t);break}t=function(){Ee!==2&&Ee!==9||De!==e||(Ee=7),Wo(e)},r.then(t,t);break e;case 3:Ee=7;break e;case 4:Ee=5;break e;case 7:Wk(r)?(Ee=0,bn=null,p_(t)):(Ee=0,bn=null,Cl(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?bE(s):i.stateNode.complete){Ee=0,bn=null;var l=i.sibling;if(l!==null)fe=l;else{var c=i.return;c!==null?(fe=c,S0(c)):fe=null}break t}}Ee=0,bn=null,Cl(e,t,r,5);break;case 6:Ee=0,bn=null,Cl(e,t,r,6);break;case 8:Gb(),Je=6;break e;default:throw Error(O(462))}}lN();break}catch(u){YT(e,u)}while(!0);return wa=Ks=null,K.H=o,K.A=a,ke=n,fe!==null?0:(De=null,me=0,p0(),Je)}function lN(){for(;fe!==null&&!M7();)JT(fe)}function JT(e){var t=wT(e.alternate,e,Da);e.memoizedProps=e.pendingProps,t===null?S0(e):fe=t}function p_(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=s_(n,t,t.pendingProps,t.type,void 0,me);break;case 11:t=s_(n,t,t.pendingProps,t.type.render,t.ref,me);break;case 5:Tb(t);default:TT(n,t),t=fe=Tw(t,Da),t=wT(n,t,Da)}e.memoizedProps=e.pendingProps,t===null?S0(e):fe=t}function Cl(e,t,n,o){wa=Ks=null,Tb(t),Dl=null,rd=0;var a=t.return;try{if(KB(e,a,t,n,me)){Je=1,Xm(e,Xn(n,e.current)),fe=null;return}}catch(r){if(a!==null)throw fe=a,r;Je=1,Xm(e,Xn(n,e.current)),fe=null;return}t.flags&32768?(be||o===1?e=!0:Ql||(me&536870912)!==0?e=!1:(kr=e=!0,(o===2||o===9||o===3||o===6)&&(o=En.current,o!==null&&o.tag===13&&(o.flags|=16384))),eE(t,e)):S0(t)}function S0(e){var t=e;do{if((t.flags&32768)!==0){eE(t,kr);return}e=t.return;var n=JB(t.alternate,t,Da);if(n!==null){fe=n;return}if(t=t.sibling,t!==null){fe=t;return}fe=t=e}while(t!==null);Je===0&&(Je=5)}function eE(e,t){do{var n=eN(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);Je=6,fe=null}function h_(e,t,n,o,a,r,s,i,l){e.cancelPendingCommit=null;do L0();while(ht!==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|=pb,U7(e,n,r,s,i,l),e===De&&(fe=De=null,me=0),ql=t,Rr=e,Ca=n,U1=r,G1=a,jT=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,fN(Nm,function(){return rE(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=K.T,K.T=null,a=_e.p,_e.p=2,s=ke,ke|=4;try{tN(e,t,n)}finally{ke=s,_e.p=a,K.T=o}}ht=1,tE(),nE(),oE()}}function tE(){if(ht===1){ht=0;var e=Rr,t=ql,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=K.T,K.T=null;var o=_e.p;_e.p=2;var a=ke;ke|=4;try{zT(t,e);var r=Z1,s=bw(e.containerInfo),i=r.focusedElem,l=r.selectionRange;if(s!==i&&i&&i.ownerDocument&&xw(i.ownerDocument.documentElement,i)){if(l!==null&&fb(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=Bk(i,m),g=Bk(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}}i0=!!j1,Z1=j1=null}finally{ke=a,_e.p=o,K.T=n}}e.current=t,ht=2}}function nE(){if(ht===2){ht=0;var e=Rr,t=ql,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=K.T,K.T=null;var o=_e.p;_e.p=2;var a=ke;ke|=4;try{OT(e,t.alternate,t)}finally{ke=a,_e.p=o,K.T=n}}ht=3}}function oE(){if(ht===4||ht===3){ht=0,R7();var e=Rr,t=ql,n=Ca,o=jT;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?ht=5:(ht=0,ql=Rr=null,aE(e,e.pendingLanes));var a=e.pendingLanes;if(a===0&&(Mr=null),rb(n),t=t.stateNode,kn&&typeof kn.onCommitFiberRoot=="function")try{kn.onCommitFiberRoot(hd,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=K.T,a=_e.p,_e.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,_e.p=a}}(Ca&3)!==0&&L0(),Wo(e),a=e.pendingLanes,(n&261930)!==0&&(a&42)!==0?e===W1?$u++:($u=0,W1=e):$u=0,Sd(0,!1)}}function aE(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,bd(t)))}function L0(){return tE(),nE(),oE(),rE()}function rE(){if(ht!==5)return!1;var e=Rr,t=U1;U1=0;var n=rb(Ca),o=K.T,a=_e.p;try{_e.p=32>n?32:n,K.T=null,n=G1,G1=null;var r=Rr,s=Ca;if(ht=0,ql=Rr=null,Ca=0,(ke&6)!==0)throw Error(O(331));var i=ke;if(ke|=4,WT(r.current),HT(r,r.current,s,n),ke=i,Sd(0,!1),kn&&typeof kn.onPostCommitFiberRoot=="function")try{kn.onPostCommitFiberRoot(hd,r)}catch{}return!0}finally{_e.p=a,K.T=o,aE(e,t)}}function m_(e,t,n){t=Xn(n,t),t=B1(e.stateNode,t,2),e=Ir(e,t,2),e!==null&&(yd(e,2),Wo(e))}function Ce(e,t,n){if(e.tag===3)m_(e,e,n);else for(;t!==null;){if(t.tag===3){m_(t,e,n);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Mr===null||!Mr.has(o))){e=Xn(n,e),n=AT(2),o=Ir(t,n,2),o!==null&&(vT(n,o,t,e),yd(o,2),Wo(o));break}}t=t.return}}function e1(e,t,n){var o=e.pingCache;if(o===null){o=e.pingCache=new aN;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)||(Hb=!0,a.add(n),e=cN.bind(null,e,t,n),t.then(e,e))}function cN(e,t,n){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,De===e&&(me&n)===n&&(Je===4||Je===3&&(me&62914560)===me&&300>Ln()-A0?(ke&2)===0&&Vl(e,0):Ub|=n,Wl===me&&(Wl=0)),Wo(e)}function sE(e,t){t===0&&(t=$_()),e=Ys(e,t),e!==null&&(yd(e,t),Wo(e))}function uN(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),sE(e,n)}function dN(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),sE(e,n)}function fN(e,t){return ob(e,t)}var e0=null,gl=null,q1=!1,t0=!1,t1=!1,wr=0;function Wo(e){e!==gl&&e.next===null&&(gl===null?e0=gl=e:gl=gl.next=e),t0=!0,q1||(q1=!0,hN())}function Sd(e,t){if(!t1&&t0){t1=!0;do for(var n=!1,o=e0;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-_n(42|e)+1)-1,r&=a&~(s&~i),r=r&201326741?r&201326741|1:r?r|2:0}r!==0&&(n=!0,y_(o,r))}else r=me,r=c0(o,o===De?r:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(r&3)===0||md(o,r)||(n=!0,y_(o,r));o=o.next}while(n);t1=!1}}function pN(){iE()}function iE(){t0=q1=!1;var e=0;wr!==0&&SN()&&(e=wr);for(var t=Ln(),n=null,o=e0;o!==null;){var a=o.next,r=lE(o,t);r===0?(o.next=null,n===null?e0=a:n.next=a,a===null&&(gl=n)):(n=o,(e!==0||(r&3)!==0)&&(t0=!0)),o=a}ht!==0&&ht!==5||Sd(e,!1),wr!==0&&(wr=0)}function lE(e,t){for(var n=e.suspendedLanes,o=e.pingedLanes,a=e.expirationTimes,r=e.pendingLanes&-62914561;0<r;){var s=31-_n(r),i=1<<s,l=a[s];l===-1?((i&n)===0||(i&o)!==0)&&(a[s]=H7(i,t)):l<=t&&(e.expiredLanes|=i),r&=~i}if(t=De,n=me,n=c0(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&&Ix(o),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||md(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(o!==null&&Ix(o),rb(n)){case 2:case 8:n=Y_;break;case 32:n=Nm;break;case 268435456:n=K_;break;default:n=Nm}return o=cE.bind(null,e),n=ob(n,o),e.callbackPriority=t,e.callbackNode=n,t}return o!==null&&o!==null&&Ix(o),e.callbackPriority=2,e.callbackNode=null,2}function cE(e,t){if(ht!==0&&ht!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(L0()&&e.callbackNode!==n)return null;var o=me;return o=c0(e,e===De?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(XT(e,o,t),lE(e,Ln()),e.callbackNode!=null&&e.callbackNode===n?cE.bind(null,e):null)}function y_(e,t){if(L0())return null;XT(e,t,!0)}function hN(){kN(function(){(ke&6)!==0?ob(X_,pN):iE()})}function Wb(){if(wr===0){var e=Hl;e===0&&(e=nm,nm<<=1,(nm&261888)===0&&(nm=256)),wr=e}return wr}function g_(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Am(""+e)}function x_(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 mN(e,t,n,o,a){if(t==="submit"&&n&&n.stateNode===a){var r=g_((a[an]||null).action),s=o.submitter;s&&(t=(t=s[an]||null)?g_(t.formAction):s.getAttribute("formAction"),t!==null&&(r=t,s=null));var i=new u0("action","action",null,o,a);e.push({event:i,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(wr!==0){var l=s?x_(a,s):new FormData(a);D1(n,{pending:!0,data:l,method:a.method,action:r},null,l)}}else typeof r=="function"&&(i.preventDefault(),l=s?x_(a,s):new FormData(a),D1(n,{pending:!0,data:l,method:a.method,action:r},r,l))},currentTarget:a}]})}}for(hm=0;hm<S1.length;hm++)mm=S1[hm],b_=mm.toLowerCase(),A_=mm[0].toUpperCase()+mm.slice(1),bo(b_,"on"+A_);var mm,b_,A_,hm;bo(vw,"onAnimationEnd");bo(Sw,"onAnimationIteration");bo(Lw,"onAnimationStart");bo("dblclick","onDoubleClick");bo("focusin","onFocus");bo("focusout","onBlur");bo(OB,"onTransitionRun");bo(DB,"onTransitionStart");bo(PB,"onTransitionCancel");bo(kw,"onTransitionEnd");zl("onMouseEnter",["mouseout","mouseover"]);zl("onMouseLeave",["mouseout","mouseover"]);zl("onPointerEnter",["pointerout","pointerover"]);zl("onPointerLeave",["pointerout","pointerover"]);js("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));js("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));js("onBeforeInput",["compositionend","keypress","textInput","paste"]);js("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));js("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));js("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ld="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(" "),yN=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ld));function uE(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){Fm(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){Fm(u)}a.currentTarget=null,r=l}}}}function de(e,t){var n=t[h1];n===void 0&&(n=t[h1]=new Set);var o=e+"__bubble";n.has(o)||(dE(t,e,2,!1),n.add(o))}function n1(e,t,n){var o=0;t&&(o|=4),dE(n,e,o,t)}var ym="_reactListening"+Math.random().toString(36).slice(2);function qb(e){if(!e[ym]){e[ym]=!0,nw.forEach(function(n){n!=="selectionchange"&&(yN.has(n)||n1(n,!1,e),n1(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[ym]||(t[ym]=!0,n1("selectionchange",!1,t))}}function dE(e,t,n,o){switch(kE(t)){case 2:var a=qN;break;case 8:a=VN;break;default:a=Xb}n=a.bind(null,t,n,e),a=void 0,!b1||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 o1(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=Al(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=lb(n),d=[];e:{var f=_w.get(e);if(f!==void 0){var p=u0,h=e;switch(e){case"keypress":if(Sm(n)===0)break e;case"keydown":case"keyup":p=dB;break;case"focusin":h="focus",p=Px;break;case"focusout":h="blur",p=Px;break;case"beforeblur":case"afterblur":p=Px;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=Tk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=J7;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=hB;break;case vw:case Sw:case Lw:p=nB;break;case kw:p=yB;break;case"scroll":case"scrollend":p=$7;break;case"wheel":p=xB;break;case"copy":case"cut":case"paste":p=aB;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=Ck;break;case"toggle":case"beforetoggle":p=AB}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=ed(g,y),A!=null&&m.push(cd(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!==x1&&(h=n.relatedTarget||n.fromElement)&&(Al(h)||h[Xl]))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?Al(h):null,h!==null&&(x=pd(h),m=h.tag,h!==x||m!==5&&m!==27&&m!==6)&&(h=null)):(p=null,h=c),p!==h)){if(m=Tk,A="onMouseLeave",y="onMouseEnter",g="mouse",(e==="pointerout"||e==="pointerover")&&(m=Ck,A="onPointerLeave",y="onPointerEnter",g="pointer"),x=p==null?f:Nu(p),b=h==null?f:Nu(h),f=new m(A,g+"leave",p,n,u),f.target=x,f.relatedTarget=b,A=null,Al(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=gN,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&&v_(d,f,p,m,!1),h!==null&&x!==null&&v_(d,x,h,m,!0)}}e:{if(f=c?Nu(c):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var C=Ok;else if(Rk(f))if(yw)C=IB;else{C=EB;var w=TB}else p=f.nodeName,!p||p.toLowerCase()!=="input"||f.type!=="checkbox"&&f.type!=="radio"?c&&ib(c.elementType)&&(C=Ok):C=CB;if(C&&(C=C(e,c))){mw(d,C,n,u);break e}w&&w(e,f,c),e==="focusout"&&c&&f.type==="number"&&c.memoizedProps.value!=null&&g1(f,"number",f.value)}switch(w=c?Nu(c):window,e){case"focusin":(Rk(w)||w.contentEditable==="true")&&(Ll=w,A1=c,Gu=null);break;case"focusout":Gu=A1=Ll=null;break;case"mousedown":v1=!0;break;case"contextmenu":case"mouseup":case"dragend":v1=!1,Nk(d,n,u);break;case"selectionchange":if(RB)break;case"keydown":case"keyup":Nk(d,n,u)}var L;if(db)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 Sl?pw(e,n)&&(k="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(k="onCompositionStart");k&&(fw&&n.locale!=="ko"&&(Sl||k!=="onCompositionStart"?k==="onCompositionEnd"&&Sl&&(L=dw()):(Lr=u,cb="value"in Lr?Lr.value:Lr.textContent,Sl=!0)),w=n0(c,k),0<w.length&&(k=new Ek(k,e,null,n,u),d.push({event:k,listeners:w}),L?k.data=L:(L=hw(n),L!==null&&(k.data=L)))),(L=SB?LB(e,n):kB(e,n))&&(k=n0(c,"onBeforeInput"),0<k.length&&(w=new Ek("onBeforeInput","beforeinput",null,n,u),d.push({event:w,listeners:k}),w.data=L)),mN(d,e,c,n,u)}uE(d,t)})}function cd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function n0(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=ed(e,n),a!=null&&o.unshift(cd(e,a,r)),a=ed(e,t),a!=null&&o.push(cd(e,a,r))),e.tag===3)return o;e=e.return}return[]}function gN(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function v_(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=ed(n,r),c!=null&&s.unshift(cd(n,c,l))):a||(c=ed(n,r),c!=null&&s.push(cd(n,c,l)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var xN=/\r\n?/g,bN=/\u0000|\uFFFD/g;function S_(e){return(typeof e=="string"?e:""+e).replace(xN,`
|
|
9
|
+
`).replace(bN,"")}function fE(e,t){return t=S_(t),S_(e)===t}function Ie(e,t,n,o,a,r){switch(n){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||Fl(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&Fl(e,""+o);break;case"className":rm(e,"class",o);break;case"tabIndex":rm(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":rm(e,n,o);break;case"style":cw(e,o,r);break;case"data":if(t!=="object"){rm(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=Am(""+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=Am(""+o),e.setAttribute(n,o);break;case"onClick":o!=null&&(e.onclick=_a);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=Am(""+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),bm(e,"popover",o);break;case"xlinkActuate":ga(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":ga(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":ga(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":ga(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":ga(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":ga(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":ga(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":ga(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":ga(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":bm(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=Y7.get(n)||n,bm(e,n,o))}}function V1(e,t,n,o,a,r){switch(n){case"style":cw(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"?Fl(e,o):(typeof o=="number"||typeof o=="bigint")&&Fl(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=_a);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ow.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,""):bm(e,n,o)}}}function Dt(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: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":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:Ie(e,t,o,u,n,null)}}sw(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:Ie(e,t,a,i,n,null)}t=r,n=s,e.multiple=!!o,t!=null?Ml(e,!!o,t,!1):n!=null&&Ml(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:Ie(e,t,s,i,n,null)}lw(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":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<ld.length;o++)de(ld[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:Ie(e,t,c,o,n,null)}return;default:if(ib(t)){for(u in n)n.hasOwnProperty(u)&&(o=n[u],o!==void 0&&V1(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 AN(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)}}y1(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?Ml(e,!!n,f,!1):!!o!=!!n&&(t!=null?Ml(e,!!n,t,!0):Ml(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)}iw(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(ib(t)){for(var x in n)f=n[x],n.hasOwnProperty(x)&&f!==void 0&&!o.hasOwnProperty(x)&&V1(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||V1(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 L_(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function vN(){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&&L_(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&&L_(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 j1=null,Z1=null;function o0(e){return e.nodeType===9?e:e.ownerDocument}function k_(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 pE(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 X1(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 a1=null;function SN(){var e=window.event;return e&&e.type==="popstate"?e===a1?!1:(a1=e,!0):(a1=null,!1)}var hE=typeof setTimeout=="function"?setTimeout:void 0,LN=typeof clearTimeout=="function"?clearTimeout:void 0,__=typeof Promise=="function"?Promise:void 0,kN=typeof queueMicrotask=="function"?queueMicrotask:typeof __<"u"?function(e){return __.resolve(null).then(e).catch(_N)}:hE;function _N(e){setTimeout(function(){throw e})}function Ur(e){return e==="head"}function w_(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),Zl(t);return}o--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")o++;else if(n==="html")Qu(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,Qu(n);for(var r=n.firstChild;r;){var s=r.nextSibling,i=r.nodeName;r[gd]||i==="SCRIPT"||i==="STYLE"||i==="LINK"&&r.rel.toLowerCase()==="stylesheet"||n.removeChild(r),r=s}}else n==="body"&&Qu(e.ownerDocument.body);n=a}while(n);Zl(t)}function T_(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 Y1(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":Y1(n),sb(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function wN(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[gd])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=$n(e.nextSibling),e===null)break}return null}function TN(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=$n(e.nextSibling),e===null))return null;return e}function mE(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=$n(e.nextSibling),e===null))return null;return e}function K1(e){return e.data==="$?"||e.data==="$~"}function $1(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function EN(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 $n(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 Q1=null;function E_(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return $n(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function C_(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 yE(e,t,n){switch(t=o0(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 Qu(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);sb(e)}var Qn=new Map,I_=new Set;function a0(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Pa=_e.d;_e.d={f:CN,r:IN,D:MN,C:RN,L:ON,m:DN,X:BN,S:PN,M:NN};function CN(){var e=Pa.f(),t=v0();return e||t}function IN(e){var t=Yl(e);t!==null&&t.tag===5&&t.type==="form"?cT(t):Pa.r(e)}var Jl=typeof document>"u"?null:document;function gE(e,t,n){var o=Jl;if(o&&typeof t=="string"&&t){var a=Zn(t);a='link[rel="'+e+'"][href="'+a+'"]',typeof n=="string"&&(a+='[crossorigin="'+n+'"]'),I_.has(a)||(I_.add(a),e={rel:e,crossOrigin:n,href:t},o.querySelector(a)===null&&(t=o.createElement("link"),Dt(t,"link",e),kt(t),o.head.appendChild(t)))}}function MN(e){Pa.D(e),gE("dns-prefetch",e,null)}function RN(e,t){Pa.C(e,t),gE("preconnect",e,t)}function ON(e,t,n){Pa.L(e,t,n);var o=Jl;if(o&&e&&t){var a='link[rel="preload"][as="'+Zn(t)+'"]';t==="image"&&n&&n.imageSrcSet?(a+='[imagesrcset="'+Zn(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(a+='[imagesizes="'+Zn(n.imageSizes)+'"]')):a+='[href="'+Zn(e)+'"]';var r=a;switch(t){case"style":r=jl(e);break;case"script":r=ec(e)}Qn.has(r)||(e=qe({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),Qn.set(r,e),o.querySelector(a)!==null||t==="style"&&o.querySelector(Ld(r))||t==="script"&&o.querySelector(kd(r))||(t=o.createElement("link"),Dt(t,"link",e),kt(t),o.head.appendChild(t)))}}function DN(e,t){Pa.m(e,t);var n=Jl;if(n&&e){var o=t&&typeof t.as=="string"?t.as:"script",a='link[rel="modulepreload"][as="'+Zn(o)+'"][href="'+Zn(e)+'"]',r=a;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":r=ec(e)}if(!Qn.has(r)&&(e=qe({rel:"modulepreload",href:e},t),Qn.set(r,e),n.querySelector(a)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(kd(r)))return}o=n.createElement("link"),Dt(o,"link",e),kt(o),n.head.appendChild(o)}}}function PN(e,t,n){Pa.S(e,t,n);var o=Jl;if(o&&e){var a=Il(o).hoistableStyles,r=jl(e);t=t||"default";var s=a.get(r);if(!s){var i={loading:0,preload:null};if(s=o.querySelector(Ld(r)))i.loading=5;else{e=qe({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Qn.get(r))&&Vb(e,n);var l=s=o.createElement("link");kt(l),Dt(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,Im(s,t,o)}s={type:"stylesheet",instance:s,count:1,state:i},a.set(r,s)}}}function BN(e,t){Pa.X(e,t);var n=Jl;if(n&&e){var o=Il(n).hoistableScripts,a=ec(e),r=o.get(a);r||(r=n.querySelector(kd(a)),r||(e=qe({src:e,async:!0},t),(t=Qn.get(a))&&jb(e,t),r=n.createElement("script"),kt(r),Dt(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function NN(e,t){Pa.M(e,t);var n=Jl;if(n&&e){var o=Il(n).hoistableScripts,a=ec(e),r=o.get(a);r||(r=n.querySelector(kd(a)),r||(e=qe({src:e,async:!0,type:"module"},t),(t=Qn.get(a))&&jb(e,t),r=n.createElement("script"),kt(r),Dt(r,"link",e),n.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},o.set(a,r))}}function M_(e,t,n,o){var a=(a=Tr.current)?a0(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=jl(n.href),n=Il(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=jl(n.href);var r=Il(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(Ld(e)))&&!r._p&&(s.instance=r,s.state.loading=5),Qn.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},Qn.set(e,n),r||zN(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=ec(n),n=Il(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 jl(e){return'href="'+Zn(e)+'"'}function Ld(e){return'link[rel="stylesheet"]['+e+"]"}function xE(e){return qe({},e,{"data-precedence":e.precedence,precedence:null})}function zN(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}),Dt(t,"link",n),kt(t),e.head.appendChild(t))}function ec(e){return'[src="'+Zn(e)+'"]'}function kd(e){return"script[async]"+e}function R_(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+Zn(n.href)+'"]');if(o)return t.instance=o,kt(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"),kt(o),Dt(o,"style",a),Im(o,n.precedence,e),t.instance=o;case"stylesheet":a=jl(n.href);var r=e.querySelector(Ld(a));if(r)return t.state.loading|=4,t.instance=r,kt(r),r;o=xE(n),(a=Qn.get(a))&&Vb(o,a),r=(e.ownerDocument||e).createElement("link"),kt(r);var s=r;return s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),Dt(r,"link",o),t.state.loading|=4,Im(r,n.precedence,e),t.instance=r;case"script":return r=ec(n.src),(a=e.querySelector(kd(r)))?(t.instance=a,kt(a),a):(o=n,(a=Qn.get(r))&&(o=qe({},n),jb(o,a)),e=e.ownerDocument||e,a=e.createElement("script"),kt(a),Dt(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,Im(o,n.precedence,e));return t.instance}function Im(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 Vb(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function jb(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Mm=null;function O_(e,t,n){if(Mm===null){var o=new Map,a=Mm=new Map;a.set(n,o)}else a=Mm,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[gd]||r[Mt]||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 D_(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function FN(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 bE(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function HN(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=jl(o.href),r=t.querySelector(Ld(a));if(r){t=r._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=r0.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=r,kt(r);return}r=t.ownerDocument||t,o=xE(o),(a=Qn.get(a))&&Vb(o,a),r=r.createElement("link"),kt(r);var s=r;s._p=new Promise(function(i,l){s.onload=i,s.onerror=l}),Dt(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=r0.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var r1=0;function UN(e,t){return e.stylesheets&&e.count===0&&Rm(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var o=setTimeout(function(){if(e.stylesheets&&Rm(e,e.stylesheets),e.unsuspend){var r=e.unsuspend;e.unsuspend=null,r()}},6e4+t);0<e.imgBytes&&r1===0&&(r1=62500*vN());var a=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Rm(e,e.stylesheets),e.unsuspend)){var r=e.unsuspend;e.unsuspend=null,r()}},(e.imgBytes>r1?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(a)}}:null}function r0(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Rm(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var s0=null;function Rm(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,s0=new Map,t.forEach(GN,e),s0=null,r0.call(e))}function GN(e,t){if(!(t.state.loading&4)){var n=s0.get(e);if(n)var o=n.get(null);else{n=new Map,s0.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=r0.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 ud={$$typeof:ka,Provider:null,Consumer:null,_currentValue:Bs,_currentValue2:Bs,_threadCount:0};function WN(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=Mx(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mx(0),this.hiddenUpdates=Mx(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 AE(e,t,n,o,a,r,s,i,l,c,u,d){return e=new WN(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=xb(),t.refCount++,e.pooledCache=t,t.refCount++,r.memoizedState={element:o,isDehydrated:n,cache:t},vb(r),e}function vE(e){return e?(e=wl,e):wl}function SE(e,t,n,o,a,r){a=vE(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=Ir(e,o,t),n!==null&&(on(n,e,t),qu(n,e,t))}function P_(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Zb(e,t){P_(e,t),(e=e.alternate)&&P_(e,t)}function LE(e){if(e.tag===13||e.tag===31){var t=Ys(e,67108864);t!==null&&on(t,e,67108864),Zb(e,67108864)}}function B_(e){if(e.tag===13||e.tag===31){var t=wn();t=ab(t);var n=Ys(e,t);n!==null&&on(n,e,t),Zb(e,t)}}var i0=!0;function qN(e,t,n,o){var a=K.T;K.T=null;var r=_e.p;try{_e.p=2,Xb(e,t,n,o)}finally{_e.p=r,K.T=a}}function VN(e,t,n,o){var a=K.T;K.T=null;var r=_e.p;try{_e.p=8,Xb(e,t,n,o)}finally{_e.p=r,K.T=a}}function Xb(e,t,n,o){if(i0){var a=J1(o);if(a===null)o1(e,t,o,l0,n),N_(e,o);else if(ZN(a,e,t,n,o))o.stopPropagation();else if(N_(e,o),t&4&&-1<jN.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=Os(r.pendingLanes);if(s!==0){var i=r;for(i.pendingLanes|=2,i.entangledLanes|=2;s;){var l=1<<31-_n(s);i.entanglements[1]|=l,s&=~l}Wo(r),(ke&6)===0&&($m=Ln()+500,Sd(0,!1))}}break;case 31:case 13:i=Ys(r,2),i!==null&&on(i,r,2),v0(),Zb(r,2)}if(r=J1(o),r===null&&o1(e,t,o,l0,n),r===a)break;a=r}a!==null&&o.stopPropagation()}else o1(e,t,o,null,n)}}function J1(e){return e=lb(e),Yb(e)}var l0=null;function Yb(e){if(l0=null,e=Al(e),e!==null){var t=pd(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=W_(t),e!==null)return e;e=null}else if(n===31){if(e=q_(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 l0=e,null}function kE(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(O7()){case X_:return 2;case Y_:return 8;case Nm:case D7:return 32;case K_:return 268435456;default:return 32}default:return 32}}var eb=!1,Or=null,Dr=null,Pr=null,dd=new Map,fd=new Map,vr=[],jN="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 N_(e,t){switch(e){case"focusin":case"focusout":Or=null;break;case"dragenter":case"dragleave":Dr=null;break;case"mouseover":case"mouseout":Pr=null;break;case"pointerover":case"pointerout":dd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":fd.delete(t.pointerId)}}function Ou(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&&LE(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function ZN(e,t,n,o,a){switch(t){case"focusin":return Or=Ou(Or,e,t,n,o,a),!0;case"dragenter":return Dr=Ou(Dr,e,t,n,o,a),!0;case"mouseover":return Pr=Ou(Pr,e,t,n,o,a),!0;case"pointerover":var r=a.pointerId;return dd.set(r,Ou(dd.get(r)||null,e,t,n,o,a)),!0;case"gotpointercapture":return r=a.pointerId,fd.set(r,Ou(fd.get(r)||null,e,t,n,o,a)),!0}return!1}function _E(e){var t=Al(e.target);if(t!==null){var n=pd(t);if(n!==null){if(t=n.tag,t===13){if(t=W_(n),t!==null){e.blockedOn=t,Ak(e.priority,function(){B_(n)});return}}else if(t===31){if(t=q_(n),t!==null){e.blockedOn=t,Ak(e.priority,function(){B_(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 Om(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=J1(e.nativeEvent);if(n===null){n=e.nativeEvent;var o=new n.constructor(n.type,n);x1=o,n.target.dispatchEvent(o),x1=null}else return t=Yl(n),t!==null&&LE(t),e.blockedOn=n,!1;t.shift()}return!0}function z_(e,t,n){Om(e)&&n.delete(t)}function XN(){eb=!1,Or!==null&&Om(Or)&&(Or=null),Dr!==null&&Om(Dr)&&(Dr=null),Pr!==null&&Om(Pr)&&(Pr=null),dd.forEach(z_),fd.forEach(z_)}function gm(e,t){e.blockedOn===t&&(e.blockedOn=null,eb||(eb=!0,mt.unstable_scheduleCallback(mt.unstable_NormalPriority,XN)))}var xm=null;function F_(e){xm!==e&&(xm=e,mt.unstable_scheduleCallback(mt.unstable_NormalPriority,function(){xm===e&&(xm=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(Yb(o||n)===null)continue;break}var r=Yl(n);r!==null&&(e.splice(t,3),t-=3,D1(r,{pending:!0,data:a,method:n.method,action:o},o,a))}}))}function Zl(e){function t(l){return gm(l,e)}Or!==null&&gm(Or,e),Dr!==null&&gm(Dr,e),Pr!==null&&gm(Pr,e),dd.forEach(t),fd.forEach(t);for(var n=0;n<vr.length;n++){var o=vr[n];o.blockedOn===e&&(o.blockedOn=null)}for(;0<vr.length&&(n=vr[0],n.blockedOn===null);)_E(n),n.blockedOn===null&&vr.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||F_(n);else if(s){var i=null;if(r&&r.hasAttribute("formAction")){if(a=r,s=r[an]||null)i=s.formAction;else if(Yb(a)!==null)continue}else i=s.action;typeof i=="function"?n[o+1]=i:(n.splice(o,3),o-=3),F_(n)}}}function wE(){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 Kb(e){this._internalRoot=e}k0.prototype.render=Kb.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(O(409));var n=t.current,o=wn();SE(n,o,e,t,null,null)};k0.prototype.unmount=Kb.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;SE(e.current,2,null,e,null,null),v0(),t[Xl]=null}};function k0(e){this._internalRoot=e}k0.prototype.unstable_scheduleHydration=function(e){if(e){var t=tw();e={blockedOn:null,target:e,priority:t};for(var n=0;n<vr.length&&t!==0&&t<vr[n].priority;n++);vr.splice(n,0,e),n===0&&_E(e)}};var H_=U_.version;if(H_!=="19.2.6")throw Error(O(527,H_,"19.2.6"));_e.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=w7(t),e=e!==null?V_(e):null,e=e===null?null:e.stateNode,e};var YN={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(Du=__REACT_DEVTOOLS_GLOBAL_HOOK__,!Du.isDisabled&&Du.supportsFiber))try{hd=Du.inject(YN),kn=Du}catch{}var Du;_0.createRoot=function(e,t){if(!G_(e))throw Error(O(299));var n=!1,o="",a=gT,r=xT,s=bT;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=AE(e,1,!1,null,null,n,o,null,a,r,s,wE),e[Xl]=t.current,qb(e),new Kb(t)};_0.hydrateRoot=function(e,t,n){if(!G_(e))throw Error(O(299));var o=!1,a="",r=gT,s=xT,i=bT,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=AE(e,1,!0,t,n??null,o,a,l,r,s,i,wE),t.context=vE(null),n=t.current,o=wn(),o=ab(o),a=Cr(o),a.callback=null,Ir(n,a,o),n=o,t.current.lanes=n,yd(t,n),Wo(t),e[Xl]=t.current,qb(e),new k0(t)};_0.version="19.2.6"});var IE=Ut((iJ,CE)=>{"use strict";function EE(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(EE)}catch(e){console.error(e)}}EE(),CE.exports=TE()});var RE=Ut(w0=>{"use strict";var KN=Symbol.for("react.transitional.element"),$N=Symbol.for("react.fragment");function ME(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:KN,type:e,key:o,ref:t!==void 0?t:null,props:n}}w0.Fragment=$N;w0.jsx=ME;w0.jsxs=ME});var se=Ut((cJ,OE)=>{"use strict";OE.exports=RE()});var S3=Ut(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.loop=_s.conditional=_s.parse=void 0;var $$=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};_s.parse=$$;var Q$=function(t,n){return function(o,a,r,s){n(o,a,r)&&s(o,t,a,r)}};_s.conditional=Q$;var J$=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}};_s.loop=J$});var L3=Ut(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.readBits=ft.readArray=ft.readUnsigned=ft.readString=ft.peekBytes=ft.readBytes=ft.peekByte=ft.readByte=ft.buildStream=void 0;var eQ=function(t){return{data:t,pos:0}};ft.buildStream=eQ;var kP=function(){return function(t){return t.data[t.pos++]}};ft.readByte=kP;var tQ=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(n){return n.data[n.pos+t]}};ft.peekByte=tQ;var ox=function(t){return function(n){return n.data.subarray(n.pos,n.pos+=t)}};ft.readBytes=ox;var nQ=function(t){return function(n){return n.data.subarray(n.pos,n.pos+t)}};ft.peekBytes=nQ;var oQ=function(t){return function(n){return Array.from(ox(t)(n)).map(function(o){return String.fromCharCode(o)}).join("")}};ft.readString=oQ;var aQ=function(t){return function(n){var o=ox(2)(n);return t?(o[1]<<8)+o[0]:(o[0]<<8)+o[1]}};ft.readUnsigned=aQ;var rQ=function(t,n){return function(o,a,r){for(var s=typeof n=="function"?n(o,a,r):n,i=ox(t),l=new Array(s),c=0;c<s;c++)l[c]=i(o);return l}};ft.readArray=rQ;var sQ=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},iQ=function(t){return function(n){for(var o=kP()(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]=sQ(a,l.index,l.length):s[i]=a[l.index],s},{})}};ft.readBits=iQ});var _P=Ut(rx=>{"use strict";Object.defineProperty(rx,"__esModule",{value:!0});rx.default=void 0;var ws=S3(),ce=L3(),ax={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}},lQ=(0,ws.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}),cQ=(0,ws.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,ws.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)()},ax]}]},function(e){return(0,ce.peekByte)()(e)===44}),uQ=(0,ws.conditional)({text:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{preData:function(t,n,o){return(0,ce.readBytes)(o.text.blockSize)(t)}},ax]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===1}),dQ=(0,ws.conditional)({application:[{codes:(0,ce.readBytes)(2)},{blockSize:(0,ce.readByte)()},{id:function(t,n,o){return(0,ce.readString)(o.blockSize)(t)}},ax]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===255}),fQ=(0,ws.conditional)({comment:[{codes:(0,ce.readBytes)(2)},ax]},function(e){var t=(0,ce.peekBytes)(2)(e);return t[0]===33&&t[1]===254}),pQ=[{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,ws.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,ws.loop)([lQ,dQ,fQ,cQ,uQ],function(e){var t=(0,ce.peekByte)()(e);return t===33||t===44})}],hQ=pQ;rx.default=hQ});var wP=Ut(sx=>{"use strict";Object.defineProperty(sx,"__esModule",{value:!0});sx.deinterlace=void 0;var mQ=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};sx.deinterlace=mQ});var TP=Ut(ix=>{"use strict";Object.defineProperty(ix,"__esModule",{value:!0});ix.lzw=void 0;var yQ=function(t,n,o){var a=4096,r=-1,s=o,i,l,c,u,d,f,p,C,h,m,_,x,L,k,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 _,C,w,L,k,M,B;for(_=C=w=L=k=M=B=0,m=0;m<s;){if(k===0){if(C<u){_+=n[B]<<C,C+=8,B++;continue}if(h=_&c,_>>=u,C-=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[k++]=b[h],p=h,L=h;continue}for(f=h,h==i&&(A[k++]=L,h=p);h>l;)A[k++]=b[h],h=g[h];L=b[h]&255,A[k++]=L,i<a&&(g[i]=p,b[i]=L,i++,(i&c)===0&&i<a&&(u++,c+=i)),p=f}k--,y[M++]=A[k],m++}for(m=M;m<s;m++)y[m]=0;return y};ix.lzw=yQ});var CP=Ut(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.decompressFrames=Ts.decompressFrame=Ts.parseGIF=void 0;var gQ=SQ(_P()),xQ=S3(),bQ=L3(),AQ=wP(),vQ=TP();function SQ(e){return e&&e.__esModule?e:{default:e}}var LQ=function(t){var n=new Uint8Array(t);return(0,xQ.parse)((0,bQ.buildStream)(n),gQ.default)};Ts.parseGIF=LQ;var kQ=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},EP=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,vQ.lzw)(a.data.minCodeSize,a.data.blocks,r);a.descriptor.lct.interlaced&&(s=(0,AQ.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=kQ(i)),i};Ts.decompressFrame=EP;var _Q=function(t,n){return t.frames.filter(function(o){return o.image}).map(function(o){return EP(o,t.gct,n)})};Ts.decompressFrames=_Q});var HP=P(IE(),1);var R=P(se(),1),ye=P(re(),1);var C0=P(re(),1);var T0=(...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 PE=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase());var $b=e=>{let t=PE(e);return t.charAt(0).toUpperCase()+t.slice(1)};var _d=P(re(),1);var E0={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 BE=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var tc=P(re(),1);var QN=(0,tc.createContext)({});var NE=()=>(0,tc.useContext)(QN);var zE=(0,_d.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=""}=NE()??{},h=o??d?Number(n??u)*24/Number(t??c):n??u;return(0,_d.createElement)("svg",{ref:l,...E0,width:t??c??E0.width,height:t??c??E0.height,stroke:e??f,strokeWidth:h,className:T0("lucide",p,a),...!r&&!BE(i)&&{"aria-hidden":"true"},...i},[...s.map(([m,x])=>(0,_d.createElement)(m,x)),...Array.isArray(r)?r:[r]])});var E=(e,t)=>{let n=(0,C0.forwardRef)(({className:o,...a},r)=>(0,C0.createElement)(zE,{ref:r,iconNode:t,className:T0(`lucide-${DE($b(e))}`,`lucide-${e}`,o),...a}));return n.displayName=$b(e),n};var JN=[["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"}]],wd=E("align-center-horizontal",JN);var ez=[["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"}]],nc=E("align-center-vertical",ez);var tz=[["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"}]],Td=E("align-end-horizontal",tz);var nz=[["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"}]],Ed=E("align-end-vertical",nz);var oz=[["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"}]],Cd=E("align-horizontal-distribute-center",oz);var az=[["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"}]],Id=E("align-start-horizontal",az);var rz=[["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"}]],Md=E("align-start-vertical",rz);var sz=[["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"}]],Rd=E("align-vertical-distribute-center",sz);var iz=[["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"}]],Od=E("bold",iz);var lz=[["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"}]],Dd=E("case-sensitive",lz);var cz=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Pd=E("check",cz);var uz=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bd=E("chevron-down",uz);var dz=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],$s=E("chevron-right",dz);var fz=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],Nd=E("chevrons-down",fz);var pz=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],zd=E("chevrons-up",pz);var hz=[["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"}]],Cn=E("circle-question-mark",hz);var mz=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Qs=E("circle",mz);var yz=[["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"}]],Fd=E("clipboard",yz);var gz=[["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"}]],Gr=E("copy",gz);var xz=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],Hd=E("crop",xz);var bz=[["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"}]],Ud=E("delete",bz);var Az=[["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"}]],Gd=E("diamond",Az);var vz=[["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"}]],oc=E("download",vz);var Sz=[["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"}]],Wr=E("ellipsis-vertical",Sz);var Lz=[["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"}]],qr=E("ellipsis",Lz);var kz=[["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"}]],Wd=E("eraser",kz);var _z=[["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"}]],qd=E("external-link",_z);var wz=[["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"}]],Vd=E("file-down",wz);var Tz=[["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"}]],jd=E("file-up",Tz);var Ez=[["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"}]],Zd=E("flip-horizontal-2",Ez);var Cz=[["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"}]],Xd=E("flip-vertical-2",Cz);var Iz=[["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"}]],Yd=E("frame",Iz);var Mz=[["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"}]],Ao=E("grid-3x3",Mz);var Rz=[["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"}]],Kd=E("grip",Rz);var Oz=[["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"}]],$d=E("group",Oz);var Dz=[["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"}]],Qd=E("hand",Dz);var Pz=[["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"}]],Js=E("image-down",Pz);var Bz=[["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"}]],ei=E("image",Bz);var Nz=[["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"}]],Jd=E("italic",Nz);var zz=[["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"}]],ef=E("library",zz);var Fz=[["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"}]],tf=E("link",Fz);var Hz=[["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"}]],nf=E("locate-fixed",Hz);var Uz=[["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"}]],of=E("lock",Uz);var Gz=[["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"}]],af=E("magnet",Gz);var Wz=[["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"}]],ac=E("maximize",Wz);var qz=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],rf=E("menu",qz);var Vz=[["path",{d:"M5 12h14",key:"1ays0h"}]],Ba=E("minus",Vz);var jz=[["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"}]],sf=E("monitor",jz);var Zz=[["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"}]],lf=E("moon",Zz);var Xz=[["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"}]],cf=E("mouse-pointer-2",Xz);var Yz=[["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"}]],uf=E("mouse-pointer",Yz);var Kz=[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]],df=E("move-down",Kz);var $z=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],ff=E("move-right",$z);var Qz=[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]],pf=E("move-up",Qz);var Jz=[["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",Jz);var eF=[["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"}]],hf=E("pipette",eF);var tF=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ti=E("plus",tF);var nF=[["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"}]],mf=E("radio",nF);var oF=[["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"}]],ni=E("redo-2",oF);var aF=[["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"}]],yf=E("rotate-ccw",aF);var rF=[["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"}]],gf=E("scissors",rF);var sF=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],xf=E("search",sF);var iF=[["path",{d:"M22 2 2 22",key:"y4kqgn"}]],bf=E("slash",iF);var lF=[["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"}]],Af=E("spline",lF);var cF=[["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"}]],Na=E("square-dashed",cF);var uF=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],za=E("square-dot",uF);var dF=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],qo=E("square",dF);var fF=[["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"}]],vf=E("strikethrough",fF);var pF=[["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"}]],Sf=E("sun",pF);var hF=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],jr=E("text-align-end",hF);var mF=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Zr=E("text-align-center",mF);var yF=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],vo=E("text-align-start",yF);var gF=[["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"}]],rc=E("trash-2",gF);var xF=[["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"}]],Lf=E("type",xF);var bF=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],kf=E("underline",bF);var AF=[["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"}]],oi=E("undo-2",AF);var vF=[["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"}]],_f=E("ungroup",vF);var SF=[["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"}]],wf=E("upload",SF);var LF=[["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"}]],Tf=E("waypoints",LF);var kF=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Fa=E("x",kF);var _F=[["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"}]],Ef=E("zoom-out",_F);var wF=[["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"}]],Cf=E("zoom-in",wF);var TF=P(se(),1),So=P(re(),1),FE=(0,So.createContext)(null);var HE=FE;var Qb=()=>(0,So.useContext)(FE),sn=(e,t,n)=>{let o=Qb(),[a,r]=(0,So.useState)(()=>o?e(o):t),s=(0,So.useRef)(e);s.current=e;let i=(0,So.useRef)(t);return i.current=t,(0,So.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 xA=P(se(),1);var dc=P(se(),1),et=P(re(),1),hC=P(ya(),1);var UE=P(se(),1),I0=P(re(),1),GE=(0,I0.createContext)(null),If=({container:e,children:t})=>(0,UE.jsx)(GE.Provider,{value:e,children:t}),Pt=()=>(0,I0.useContext)(GE)??document.body;var Jb={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 M0={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 eA={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 ai={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 tA={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 nA={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 oA={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 sc={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 ri={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 aA={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 Ha={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 rA={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 ic={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 lc={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 Xr=["tomato","amber","grass","cyan","iris","plum","gray"],Mf=(e,t)=>{let n=e[t];if(n===void 0)throw new Error(`Missing color token: ${t}`);return n},ln=(e,t)=>({fill:Mf(e,`${t}4`),solid:Mf(e,`${t}9`),solidHover:Mf(e,`${t}10`),textLow:Mf(e,`${t}11`),textHigh:Mf(e,`${t}12`)}),cc={light:{tomato:ln(ri,"tomato"),amber:ln(lc,"amber"),grass:ln(ic,"grass"),cyan:ln(rA,"cyan"),iris:ln(Ha,"iris"),plum:ln(aA,"plum"),gray:ln(sc,"gray")},dark:{tomato:ln(M0,"tomato"),amber:ln(oA,"amber"),grass:ln(nA,"grass"),cyan:ln(tA,"cyan"),iris:ln(ai,"iris"),plum:ln(eA,"plum"),gray:ln(Jb,"gray")}},R0={light:{tomato:ri.tomato2,amber:lc.amber2,grass:ic.grass2,cyan:rA.cyan2,iris:Ha.iris2,plum:aA.plum2,gray:sc.gray2},dark:{tomato:M0.tomato2,amber:oA.amber2,grass:nA.grass2,cyan:tA.cyan2,iris:ai.iris2,plum:eA.plum2,gray:Jb.gray2}};var Rf={light:{accent:Ha.iris9,accentHover:Ha.iris10,selectedBg:Ha.iris4,selectedFg:Ha.iris11,danger:ri.tomato9},dark:{accent:ai.iris9,accentHover:ai.iris10,selectedBg:ai.iris4,selectedFg:ai.iris11,danger:M0.tomato9}},sA=sc.gray6,iA=sc.gray9,Yr={rectangle:{fill:Ha.iris3,stroke:Ha.iris9,strokeWidth:2},ellipse:{fill:ri.tomato3,stroke:ri.tomato9,strokeWidth:2},flowchart:{fill:ic.grass3,stroke:ic.grass9,strokeWidth:2},sticky:{fill:lc.amber3,stroke:lc.amber9,strokeWidth:1}},uc={stroke:sc.gray12,strokeWidth:1.5},EF={added:ic.grass9,removed:ri.tomato9,modified:lc.amber9};var WE=640;var lA=28;var qE=20,VE=3e3,jE=720,ZE=600,XE=600,YE=80,Of=6,KE=48,$E=66,QE=16,JE=66,eC=16,tC=6,cA=[{label:"S",value:16},{label:"M",value:24},{label:"L",value:36},{label:"XL",value:64}],nC=8,oC=256,aC=160,rC=200,sC=150,uA=8,dA=150,iC=Rf.light.accent,lC=1.5,cC="rgba(91, 91, 214, 0.12)",uC=1,fA=10,pA=[{label:"Sans",value:"system-ui, sans-serif"},{label:"Serif",value:"Georgia, 'Times New Roman', serif"},{label:"Mono",value:"ui-monospace, 'SF Mono', Menlo, monospace"}],dC=176,Df=1,O0=40;var hA=new Set,Pf=null,Vo=null,jo=null,yA=0,mA=!1,CF=()=>{for(let e of hA)e(Pf)},D0=e=>{Pf=e,CF()},IF=e=>(hA.add(e),()=>{hA.delete(e)}),MF=e=>{if(mA)return;jo&&(clearTimeout(jo),jo=null),Vo&&clearTimeout(Vo);let t=Date.now()-yA;if(Pf!==null||t<XE){D0(e);return}Vo=setTimeout(()=>{Vo=null,D0(e)},ZE)},fC=e=>{Vo&&(clearTimeout(Vo),Vo=null),Pf?.id===e&&(jo&&clearTimeout(jo),jo=setTimeout(()=>{jo=null,yA=Date.now(),D0(null)},YE))},pC=()=>{Vo&&(clearTimeout(Vo),Vo=null),jo&&(clearTimeout(jo),jo=null),Pf&&(yA=Date.now(),D0(null))},gA=({children:e})=>((0,et.useEffect)(()=>{let t=()=>{mA=!0,pC()},n=()=>{mA=!1},o=a=>{a.key==="Escape"&&pC()};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,dc.jsxs)(mC.Provider,{value:!0,children:[e,(0,dc.jsx)(OF,{})]})),mC=(0,et.createContext)(!1),RF=()=>(0,et.useContext)(mC),OF=()=>{let[e,t]=(0,et.useState)(null),n=Pt();return(0,et.useEffect)(()=>IF(t),[]),!e||typeof document>"u"?null:(0,hC.createPortal)((0,dc.jsx)(DF,{target:e}),n)},DF=({target:e})=>{let t=(0,et.useRef)(null),[n,o]=(0,et.useState)(null);(0,et.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-Of;break;case"bottom":u=i.bottom+Of;break;case"left":c=i.left-s.width-Of;break;case"right":c=i.right+Of;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,dc.jsx)("div",{ref:t,role:"tooltip",className:"du-tooltip",style:a,children:e.content})},si=({content:e,side:t="bottom",disabled:n,children:o})=>{let a=(0,et.useId)();if(!RF()||n||e===void 0||e===null)return(0,et.isValidElement)(o)&&typeof e=="string"&&!n?(0,et.cloneElement)(o,{title:e}):o;if(!(0,et.isValidElement)(o))return o;let s=o,i=f=>{MF({id:a,content:e,side:t,rect:f.getBoundingClientRect()})};return(0,et.cloneElement)(s,{onPointerEnter:f=>{s.props.onPointerEnter?.(f),f.pointerType!=="touch"&&i(f.currentTarget)},onPointerLeave:f=>{s.props.onPointerLeave?.(f),fC(a)},onFocus:f=>{s.props.onFocus?.(f),i(f.currentTarget)},onBlur:f=>{s.props.onBlur?.(f),fC(a)},title:void 0})};var Jn=({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,xA.jsx)(si,{content:e,children:(0,xA.jsx)("button",{type:"button",className:s,"aria-label":e,"aria-pressed":t??void 0,...r,children:a})})};var yC=P(se(),1),ii=({children:e,className:t,ariaLabel:n})=>(0,yC.jsx)("div",{className:`du-button-group ${t??""}`.trim(),role:"group","aria-label":n,children:e});var bA=P(se(),1);var In=({value:e,options:t,onChange:n,ariaLabel:o})=>(0,bA.jsx)(ii,{...o!==void 0?{ariaLabel:o}:{},children:t.map(a=>(0,bA.jsx)(Jn,{label:a.label,active:e===a.value,onClick:()=>{n(a.value)},size:"sm",children:a.icon},String(a.value)))});var Bf=P(se(),1),Nf=({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,Bf.jsxs)("div",{className:"du-slider",children:[(0,Bf.jsx)("input",{type:"range",min:t,max:n,step:o,value:l,onChange:i,"aria-label":r,className:"du-slider-track"}),(0,Bf.jsx)("span",{className:"du-slider-value",children:e===null?"\u2014":s??e})]})};var gC=P(se(),1),AA=({children:e,className:t,style:n})=>(0,gC.jsx)("div",{className:`du-ui-layer ${t??""}`.trim(),style:n,children:e});var eo=P(se(),1),vA=({left:e,center:t,right:n})=>(0,eo.jsxs)("div",{className:"du-bar du-bar-top",children:[(0,eo.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,eo.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,eo.jsx)("div",{}),(0,eo.jsx)("div",{className:"du-bar-zone",children:n})]}),SA=({left:e,center:t,right:n})=>(0,eo.jsxs)("div",{className:"du-bar du-bar-bottom",children:[(0,eo.jsx)("div",{className:"du-bar-zone",children:e}),t!=null?(0,eo.jsx)("div",{className:"du-bar-zone du-bar-zone-center",children:t}):(0,eo.jsx)("div",{}),(0,eo.jsx)("div",{className:"du-bar-zone",children:n})]});var cs=P(se(),1),n8=P(re(),1);var Ke=P(se(),1),Yc=P(re(),1);var P0="select";var Zo={};yo(Zo,{EMPTY:()=>Pe,add:()=>Xt,clear:()=>NF,equals:()=>li,has:()=>PF,remove:()=>Hf,replace:()=>BF,single:()=>wt,toggle:()=>_A});var Ze=e=>e,LA=e=>e,cn=e=>e,zf=e=>e,fc=e=>e,kA=e=>e;var v=e=>{if(e===void 0)throw new Error("required value is undefined");return e};var Ff=e=>{let t={};for(let[n,o]of Object.entries(e))o!==void 0&&(t[n]=o);return t};var B0=(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]),PF=(e,t)=>e.has(t),Xt=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},Hf=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},_A=(e,t)=>e.has(t)?Hf(e,t):Xt(e,t),BF=e=>wt(e),NF=()=>Pe,li=(e,t)=>B0(e,t);var W={};yo(W,{ZERO:()=>xC,add:()=>FF,angle:()=>KF,cross:()=>VF,distance:()=>jF,distanceSq:()=>vC,div:()=>GF,dot:()=>qF,equals:()=>eH,length:()=>AC,lengthSq:()=>bC,lerp:()=>XF,midpoint:()=>YF,mul:()=>UF,negate:()=>WF,normalize:()=>ZF,of:()=>zF,perp:()=>JF,rotate:()=>$F,rotateAround:()=>QF,sub:()=>HF});var xC=Object.freeze({x:0,y:0}),zF=(e,t)=>({x:e,y:t}),FF=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),HF=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),UF=(e,t)=>({x:e.x*t,y:e.y*t}),GF=(e,t)=>({x:e.x/t,y:e.y/t}),WF=e=>({x:-e.x,y:-e.y}),qF=(e,t)=>e.x*t.x+e.y*t.y,VF=(e,t)=>e.x*t.y-e.y*t.x,bC=e=>e.x*e.x+e.y*e.y,AC=e=>Math.sqrt(bC(e)),vC=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o},jF=(e,t)=>Math.sqrt(vC(e,t)),ZF=e=>{let t=AC(e);return t===0?xC:{x:e.x/t,y:e.y/t}},XF=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),YF=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),KF=e=>Math.atan2(e.y,e.x),$F=(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}},QF=(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)}},JF=e=>({x:-e.y,y:e.x}),eH=(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 pc={};yo(pc,{clamp:()=>tH,clamp01:()=>nH});var tH=(e,t,n)=>Math.max(t,Math.min(n,e)),nH=e=>e<0?0:e>1?1:e;var z={};yo(z,{IDENTITY:()=>oH,applyToBounds:()=>uH,applyToPoint:()=>Uf,decompose:()=>dH,equals:()=>fH,inverse:()=>cH,multiply:()=>lH,of:()=>aH,rotation:()=>iH,scaling:()=>sH,translation:()=>rH});var oH=Object.freeze({a:1,b:0,c:0,d:1,e:0,f:0}),aH=(e,t,n,o,a,r)=>({a:e,b:t,c:n,d:o,e:a,f:r}),rH=(e,t)=>({a:1,b:0,c:0,d:1,e,f:t}),sH=(e,t=e)=>({a:e,b:0,c:0,d:t,e:0,f:0}),iH=e=>{let t=Math.cos(e),n=Math.sin(e);return{a:t,b:n,c:-n,d:t,e:0,f:0}},lH=(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}),cH=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}},Uf=(e,t)=>({x:e.a*t.x+e.c*t.y+e.e,y:e.b*t.x+e.d*t.y+e.f}),uH=(e,t)=>{let n=Uf(e,{x:t.x,y:t.y}),o=Uf(e,{x:t.x+t.width,y:t.y}),a=Uf(e,{x:t.x,y:t.y+t.height}),r=Uf(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}},dH=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}}},fH=(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 j={};yo(j,{EMPTY:()=>SC,centerOf:()=>mH,contains:()=>TA,containsBounds:()=>xH,equals:()=>vH,expand:()=>bH,fromCenter:()=>hH,fromPoints:()=>N0,intersection:()=>LC,intersects:()=>gH,isEmpty:()=>wA,maxX:()=>Kr,maxY:()=>$r,normalize:()=>AH,of:()=>pH,union:()=>yH});var SC=Object.freeze({x:0,y:0,width:0,height:0}),pH=(e,t,n,o)=>({x:e,y:t,width:n,height:o}),N0=e=>{if(e.length===0)return SC;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}},hH=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,width:t,height:n}),mH=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),Kr=e=>e.x+e.width,$r=e=>e.y+e.height,wA=e=>e.width<=0||e.height<=0,yH=(e,t)=>{if(wA(e))return t;if(wA(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($r(e),$r(t));return{x:n,y:o,width:a-n,height:r-o}},LC=(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($r(e),$r(t));return a<=n||r<=o?null:{x:n,y:o,width:a-n,height:r-o}},gH=(e,t)=>LC(e,t)!==null,TA=(e,t)=>t.x>=e.x&&t.x<=Kr(e)&&t.y>=e.y&&t.y<=$r(e),xH=(e,t)=>t.x>=e.x&&t.y>=e.y&&Kr(t)<=Kr(e)&&$r(t)<=$r(e),bH=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),AH=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)}),vH=(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 Ua={};yo(Ua,{distanceToSegment:()=>kH,distanceToSegmentSq:()=>hc,pointInPolygon:()=>LH,pointInRect:()=>SH,pointOnPolyline:()=>_H,pointOnSegment:()=>kC});var SH=(e,t)=>TA(t,e),LH=(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},hc=(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},kH=(e,t,n)=>Math.sqrt(hc(e,t,n)),kC=(e,t,n,o=1)=>hc(e,t,n)<=o*o,_H=(e,t,n=1)=>{for(let o=0;o<t.length-1;o++){let a=t[o],r=t[o+1];if(a&&r&&kC(e,a,r,n))return!0}return!1};var un={};yo(un,{cubicAt:()=>ui,cubicBounds:()=>TH,flattenCubic:()=>MH,flattenQuadratic:()=>IH,pointOnCubic:()=>CH,pointOnQuadratic:()=>EH,quadraticAt:()=>ci,quadraticBounds:()=>wH});var ci=(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}},ui=(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}},wH=(e,t,n)=>{let o=[e,n];for(let a of _C(e.x,t.x,n.x))o.push(ci(e,t,n,a));for(let a of _C(e.y,t.y,n.y))o.push(ci(e,t,n,a));return N0(o)},TH=(e,t,n,o)=>{let a=[e,o];for(let r of wC(e.x,t.x,n.x,o.x))a.push(ui(e,t,n,o,r));for(let r of wC(e.y,t.y,n.y,o.y))a.push(ui(e,t,n,o,r));return N0(a)},EH=(e,t,n,o,a=1,r=32)=>{let s=a*a,i=t;for(let l=1;l<=r;l++){let c=ci(t,n,o,l/r);if(hc(e,i,c)<=s)return!0;i=c}return!1},CH=(e,t,n,o,a,r=1,s=64)=>{let i=r*r,l=t;for(let c=1;c<=s;c++){let u=ui(t,n,o,a,c/s);if(hc(e,l,u)<=i)return!0;l=u}return!1},IH=(e,t,n,o=16)=>{let a=new Array(o+1);for(let r=0;r<=o;r++)a[r]=ci(e,t,n,r/o);return a},MH=(e,t,n,o,a=32)=>{let r=new Array(a+1);for(let s=0;s<=a;s++)r[s]=ui(e,t,n,o,s/a);return r},_C=(e,t,n)=>{let o=e-2*t+n;if(o===0)return[];let a=(e-t)/o;return a>0&&a<1?[a]:[]},wC=(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 F0={};yo(F0,{lineLine:()=>RH,segmentCubic:()=>DH,segmentQuadratic:()=>OH,segmentSegment:()=>TC});var z0=1e-12,RH=(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)<z0)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}},TC=(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)<z0)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}},OH=(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)<z0){if(Math.abs(f)>z0){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),C=(-f-A)/(2*d);_>=0&&_<=1&&h.push(_),C>=0&&C<=1&&h.push(C)}}let m=[],x=t.x-e.x,y=t.y-e.y,g=x*x+y*y;for(let b of h){let A=ci(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},DH=(e,t,n,o,a,r,s=64)=>{let i=[],l=n;for(let c=1;c<=s;c++){let u=ui(n,o,a,r,c/s),d=TC(e,t,l,u);d!==null&&i.push(d),l=u}return i};var H0={};yo(H0,{contrastRatio:()=>MA,format:()=>NH,luminance:()=>IA,meetsContrastAA:()=>HH,meetsContrastAAA:()=>UH,mix:()=>zH,parse:()=>BH,withAlpha:()=>FH});var PH=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}}),BH=e=>{let t=e.trim().toLowerCase(),n=PH[t];if(n!==void 0)return n;if(t.startsWith("#")){let a=t.slice(1);if(a.length===3||a.length===4){let r=Qr(a.charAt(0)+a.charAt(0)),s=Qr(a.charAt(1)+a.charAt(1)),i=Qr(a.charAt(2)+a.charAt(2)),l=a.length===4?Qr(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=Qr(a.slice(0,2)),s=Qr(a.slice(2,4)),i=Qr(a.slice(4,6)),l=a.length===8?Qr(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}`)},NH=e=>{let t=EA(e.r),n=EA(e.g),o=EA(e.b),a=GH(e.a);return a===1?`#${CA(t)}${CA(n)}${CA(o)}`:`rgba(${t}, ${n}, ${o}, ${a})`},zH=(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}),FH=(e,t)=>({...e,a:t}),IA=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)},MA=(e,t)=>{let n=IA(e),o=IA(t),[a,r]=n<o?[n,o]:[o,n];return(r+.05)/(a+.05)},HH=(e,t,n=!1)=>MA(e,t)>=(n?3:4.5),UH=(e,t,n=!1)=>MA(e,t)>=(n?4.5:7),Qr=e=>parseInt(e,16),EA=e=>{let t=Math.round(e);return t<0?0:t>255?255:t},GH=e=>e<0?0:e>1?1:e,CA=e=>e.toString(16).padStart(2,"0");var Gf={};yo(Gf,{offsetClosedPath:()=>WH,signedArea:()=>qH});var WH=(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,C=h*u+m*d,w=C>1e-6?t/C:t;i.push({x:y.x+_*h*w,y:y.y+_*m*w})}return i},qH=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 RA=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}},Wf=(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 EC=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)},OA=e=>{let t=[];for(let n of e){if(n.text==="")continue;let o=t[t.length-1];o!==void 0&&EC(o.style)===EC(n.style)?t[t.length-1]={text:o.text+n.text,...o.style!==void 0?{style:o.style}:{}}:t.push(n)}return t},CC=e=>{let t=e.runs;return t!==void 0&&t.length>0?OA(t):e.text===""?[]:[{text:e.text}]},qf=(e,t,n)=>{let o=Math.min(t,n),a=Math.max(t,n),r=[],s=0;for(let i of CC(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},ZH=(e,t)=>{let n={...e??{},...t},o=Object.entries(n).filter(([,r])=>r!==void 0);return o.length===0?void 0:Object.fromEntries(o)},DA=(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 CC(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=ZH(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=OA(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 PA=e=>{if(typeof e!="object"||e===null)return!1;let t=e.kind;return t==="named"||t==="ratio"||t==="absolute"||t==="edge"},di=e=>e.kind==="point"?void 0:e.elementId;var IC=null,BA=e=>{IC=e},NA=()=>IC;var fi=e=>e.type==="rectangle",mc=e=>e.type==="ellipse",Ga=e=>e.type==="polygon",zA=e=>e.type==="path",pe=e=>e.type==="text",ct=e=>e.type==="image";var ze=e=>e.type==="group",Be=e=>e.type==="frame";var Mn=e=>e.type==="brush",Vf=e=>e.stroke??e.fill??"#000",MC=new Map,to=(e,t)=>{MC.set(e,t)};var Re=e=>{let t=MC.get(e.type);if(!t)throw new Error(`No bounder registered for shape type: ${e.type}`);return t(e)},N=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 j.fromPoints(r)};to("rectangle",e=>({x:0,y:0,width:e.width,height:e.height}));to("ellipse",e=>({x:0,y:0,width:e.width,height:e.height}));to("polygon",e=>j.fromPoints(e.points));to("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 j.fromPoints(t)});to("text",e=>{let t=e.fontSize*1.2,n=e.text.split(`
|
|
10
|
+
`),o=NA(),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}});to("image",e=>({x:0,y:0,width:e.width,height:e.height}));to("template",e=>({x:0,y:0,width:e.width,height:e.height}));to("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}});to("group",()=>({x:0,y:0,width:0,height:0}));to("frame",e=>({x:0,y:0,width:e.width,height:e.height}));to("block-arrow",e=>({x:0,y:0,width:e.width,height:e.height}));var U0=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 Tt=(e,t)=>e.order<t.order?-1:e.order>t.order?1:0,jf=(e,t)=>Tt(t,e);var Rn=(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)}},pi=(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 G0=(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),ue=(e,t)=>e.links.get(t);var Lo=e=>[...e.layers.values()].sort(Tt),Wa=(e,t)=>[...e.elements.values()].filter(n=>n.layerId===t).sort(Tt),HA=(e,t)=>[...e.links.values()].filter(n=>n.layerId===t).sort(Tt),RC=48,W0=10,FA=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}],OC=6,XH=(e,t)=>{let{x:n,y:o,width:a,height:r}=e,s=(l,c,u,d)=>{let f=[];for(let p=0;p<=OC;p++){let h=u+(d-u)*(p/OC);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)]},YH=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<=W0;a++){let r=a/W0,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<=W0;a++){let r=a/W0,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},KH=new Map;var $H=e=>{if(Ga(e))return[e.points.map(t=>({x:t.x,y:t.y}))];if(mc(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<RC;i++)s.push(G0(n,o,a,r,i/RC));return[s]}if(fi(e)){let t=Re(e),n=Wf(e.style.roundness,t.width,t.height);return[n>0?XH(t,n):FA(t)]}return ct(e)||pe(e)?[FA(Re(e))]:zA(e)?[YH(e.commands)]:null},Zf=(e,t)=>{if(ze(t)){let r=[];for(let s of UA(e,t.id))r.push(...Zf(e,s));return r}let n=$H(t);if(n)return n.map(r=>r.map(s=>Rn(t,s)));let o=KH.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=>Rn(t,i)))}let a=N(t);return[FA(a)]},UA=(e,t)=>{let n=[];for(let o of e.elements.values())o.parentId===t&&n.push(o);return n.sort(Tt),n},GA=(e,t)=>{let n=t;for(let o=0;n&&o<DC;o++){if(n.locked===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1},yc=(e,t)=>{let n=t;for(let o=0;n&&o<DC;o++){if(n.hidden===!0)return!0;if(!n.parentId)return!1;n=e.elements.get(n.parentId)}return!1};var WA=(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 UA(e,s))o.has(i.id)||(o.add(i.id),a.push(i),r.push(i.id))}return a},DC=64;var q0=(e,t,n=.5)=>{let o=[];for(let a of e.elements.values()){let r=N(a);if(!j.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},hi=(e,t)=>{let n=Lo(e);for(let o=n.length-1;o>=0;o--){let a=n[o];if(!a?.visible)continue;let r=Wa(e,a.id);for(let s=r.length-1;s>=0;s--){let i=r[s];if(i!==void 0&&j.contains(N(i),t))return i}}},qA=(e,t)=>{let n=new U0(t);for(let o of e.elements.values())n.insert(o.id,N(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||!j.contains(N(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 QH=[];var Xf=e=>mi(e)!==null,mi=e=>{for(let s of QH){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??JH,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},JH=0,no=e=>{let t=mi(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},eU=[];var jA=e=>{for(let n of eU){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=no(e);return t?[t]:[]},Yf=(e,t,n=new Set)=>{let o=Lo(e);for(let a=o.length-1;a>=0;a--){let r=o[a];if(!r?.visible)continue;let s=Wa(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=no(l);if(c&&j.contains(c,t))return l}}return null},ZA=(e,t)=>{let n=mi(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}},XA=(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 PC=new Set,YA={"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}},BC=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left","center"];var NC=(e,t)=>KA(e,t),Yt=(e,t)=>{let n=NC(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)}},Xo=(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}},qa=(e,t,n=PC)=>{let o=null;for(let[a,r]of V0(e)){if(n.has(a))continue;let s=tU(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}},tU=e=>{let t=/^edge-(\d+)$/.exec(e);return t?{kind:"edge",index:Number(t[1]),t:.5}:{kind:"named",name:e}},ko=e=>Xf(e)?nU:PC,nU=new Set(["center"]);var V0=e=>{let t=new Map;if(Ga(e))oU(e,t);else{let n=Re(e);for(let o of zC){let a=YA[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,KA(e,o));return t},zC=["top","right","bottom","left"],oU=(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}`,W.midpoint(a,r))}},KA=(e,t)=>{switch(t.kind){case"named":{let n=HC(e,t.name);if(!n)throw new Error(`Unknown anchor "${t.name}" on shape ${e.id} (type ${e.type}). Standard names: ${BC.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 FC(e,t.index,t.t)}},FC=(e,t,n)=>{if(Ga(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}},HC=(e,t)=>{let n=e.anchors?.[t];if(n!==void 0)return n.kind==="named"?HC(e,n.name):KA(e,n);if(Ga(e)&&t.startsWith("edge-")){let r=parseInt(t.slice(5),10);if(!isNaN(r))return FC(e,r,.5)}let o=YA[t];if(!o)return;let a=Re(e);return{x:a.x+a.width*o.x,y:a.y+a.height*o.y}};var $A=(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}},Kf=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},$f=(e,t,n=16)=>{let o=[e],a=e;for(let r of t){for(let s=1;s<=n;s++)o.push(un.cubicAt(a,r.c1,r.c2,r.to,s/n));a=r.to}return o};var jC=(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=Math.hypot(s.x-i.x,s.y-i.y);n.push(l),o+=l}let a=o*t;for(let r=0;r<n.length;r++){let s=v(n[r]);if(a<=s){let i=v(e[r]),l=v(e[r+1]),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[e.length-1])},aU=e=>{let t=0;for(let n=1;n<e.length;n++){let o=v(e[n-1]),a=v(e[n]);t+=Math.hypot(a.x-o.x,a.y-o.y)}return t},gc=(e,t)=>{let n=t.label?.position;if(n===void 0&&(t.routing??"straight")==="orthogonal"&&e.length>2){let s=-1,i=v(e[0]);for(let l=1;l<e.length;l++){let c=v(e[l-1]),u=v(e[l]),d=Math.hypot(u.x-c.x,u.y-c.y);d>s&&(s=d,i={x:(c.x+u.x)/2,y:(c.y+u.y)/2})}return i}let o=aU(e),a=o>0?Math.min(.5,24/o):0,r=Math.min(1-a,Math.max(a,n??.5));return jC(e,r)},ZC=e=>{let t=e.fontSize??12,n=t*.62,o=Math.max(1,Math.floor(160/n)),a=0,r=0;for(let s of e.text.split(`
|
|
11
|
+
`)){let i=s.split(/\s+/).filter(c=>c.length>0);if(i.length===0){a+=1;continue}let l="";for(let c of i){let u=l===""?c:`${l} ${c}`;u.length<=o||l===""?l=u:(r=Math.max(r,l.length),a+=1,l=c)}r=Math.max(r,l.length),a+=1}return{width:Math.min(r*n,160)+12,height:a*t*1.25+6}},Qf=(e,t)=>{if(!t.label||t.label.text===""||e.length<2)return null;let n=gc(e,t),o=ZC(t.label);return{x:n.x-o.width/2,y:n.y-o.height/2,width:o.width,height:o.height}},rU=[.5,.38,.62,.26,.74,.14,.86],UC=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,Jf=(e,t)=>{let n=e(.5);if(t===null||!UC(n,t))return n;for(let o of rU){let a=e(o);if(!UC(a,t))return a}return n},JA=(e,t)=>{let n=0,o=1/0,a=0,r=0;for(let s=1;s<e.length;s++){let i=v(e[s-1]),l=v(e[s]),c=l.x-i.x,u=l.y-i.y,d=Math.hypot(c,u);if(d>0){let f=Math.max(0,Math.min(1,((t.x-i.x)*c+(t.y-i.y)*u)/(d*d))),p=i.x+c*f,h=i.y+u*f,m=(t.x-p)**2+(t.y-h)**2;m<o&&(o=m,a=r+d*f)}r+=d,n+=d}return n>0?a/n:.5};var xc={x:1,y:0},ep={x:0,y:1},tp={x:-1,y:0},np={x:0,y:-1},XC=e=>e.y===0;var sU=e=>{let t=Math.abs(e.x),n=Math.abs(e.y);return e.x>n?xc:e.x<=-n?tp:e.y>t?ep:np},op=(e,t)=>sU({x:e.x-t.x,y:e.y-t.y}),j0=(e,t)=>{let n=N(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?tp:i===a?xc:i===r?np:ep},YC=(e,t)=>{let n=N(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 xc;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?xc:tp:u>=0?ep:np};var Z0=new Map,ev=(e,t)=>{Z0.set(e,t)},KC=e=>Z0.get(e),X0=(e,t)=>{let n=Z0.get(e.type);if(!n)throw new Error(`No outline sampler registered for shape type: ${e.type}`);let o=n(e,pc.clamp01(t));return Rn(e,o)},$C=(e,t,n=64)=>{let o=Z0.get(e.type);if(!o)return null;let a=0,r=Rn(e,o(e,0)),s=W.distance(t,r);for(let i=1;i<n;i++){let l=i/n,c=Rn(e,o(e,l)),u=W.distance(t,c);u<s&&(s=u,a=l,r=c)}return{ratio:a,world:r,distance:s}},QC=(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=W.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])};ev("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 QC(o,t)});ev("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 G0(o,a,r,s,t)});ev("polygon",(e,t)=>QC(e.points,t));var JC=e=>e.kind==="point"?null:e.elementId,eI=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:Math.sign(e.x)||0,y:0}:{x:0,y:Math.sign(e.y)},tI=(e,t,n)=>{if(t.kind==="anchor"){let a=eI(Xo(e,t.anchor));if(a.x!==0||a.y!==0)return a}let o=eI(j0(e,n));return o.x!==0||o.y!==0?o:{x:0,y:-1}},uU=(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}},nv=(e,t)=>{let n=JC(t.from);if(!n||n!==JC(t.to))return null;let o=I(e,n);if(!o)return null;let a=N(o),r=oo(e,t.from),s=oo(e,t.to);if(!r||!s)return null;let i=r,l=s,c=tI(o,t.from,i),u=tI(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=uU(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}},dU=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]},fU=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}]}},oI=e=>{let t=N(e);return{x:t.x+t.width/2,y:t.y+t.height/2}},pU=(e,t)=>{let n=oI(e),o=t.x-n.x,a=t.y-n.y;if(Math.abs(o)<1e-6&&Math.abs(a)<1e-6||!KC(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=X0(e,0);for(let d=1;d<=96;d++){let f=X0(e,d/96),p=F0.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},oo=(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"?pU(o,n??oI(o)):X0(o,t.ratio):null},ut=(e,t)=>{let n=nv(e,t);if(n)return dU(n);let o=oo(e,t.from);if(!o)return null;let a=oo(e,t.to);if(!a)return null;let r=t.from.kind==="floating"?oo(e,t.from,a)??o:o,s=t.to.kind==="floating"?oo(e,t.to,o)??a:a;return(t.routing??"straight")!=="orthogonal"?[r,...t.waypoints??[],s]:t.routedPoints!==void 0?[r,...t.routedPoints,s]:aI(r,s,tv(t.from),tv(t.to))},aI=(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]},tv=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}},nI=(e,t,n)=>{let o=tv(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}},ap=(e,t)=>{if((t.routing??"straight")!=="bezier")return null;let n=nv(e,t);if(n)return fU(n);let o=ut(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=nI(t.from,a,r),i=nI(t.to,r,a);return{start:a,segments:[$A(a,r,s,i)]}}return{start:a,segments:Kf(o)}},_o=(e,t)=>{if((t.routing??"straight")!=="bezier")return ut(e,t);let n=ap(e,t);return n?$f(n.start,n.segments):null},rp=(e,t)=>{let n=t.routing??"straight";if(n==="orthogonal")return null;let o=bc(e,t);if(n==="bezier"){let s=ap(e,t);if(!s)return null;let i=[],l=s.start;for(let c of s.segments){let u=l;i.push(Jf(d=>un.cubicAt(u,c.c1,c.c2,c.to,d),o)),l=c.to}return i}let a=ut(e,t);if(!a||a.length<2)return null;let r=[];for(let s=0;s<a.length-1;s++){let i=v(a[s]),l=v(a[s+1]);r.push(Jf(c=>({x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}),o))}return r},sp=(e,t,n)=>{let o=bc(e,t);return(n.length===2?[0]:Array.from({length:Math.max(0,n.length-3)},(r,s)=>s+1)).map(r=>{let s=v(n[r]),i=v(n[r+1]);return{k:r,point:Jf(l=>({x:s.x+(i.x-s.x)*l,y:s.y+(i.y-s.y)*l}),o)}})},ov=(e,t,n=5)=>{let o=null;for(let a of e.links.values()){let r=_o(e,a);if(!r)continue;let s=1/0;for(let i=1;i<r.length;i++){let l=Ua.distanceToSegment(t,v(r[i-1]),v(r[i]));l<s&&(s=l)}s>n&&!hU(e,a,t)||(!o||s<=o.distance)&&(o={edge:a,distance:s})}return o?.edge??null},bc=(e,t)=>{let n=_o(e,t);return!n||n.length<2?null:Qf(n,t)},hU=(e,t,n)=>{let o=bc(e,t);return o!==null&&n.x>=o.x&&n.x<=o.x+o.width&&n.y>=o.y&&n.y<=o.y+o.height};var ip=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=W.sub(n(d+1),n(d)),p=W.lengthSq(f)>0?W.normalize(f):{x:1,y:0};a.push(p),r.push(W.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(W.add(p,W.mul(y,f))),i.push(W.sub(p,W.mul(y,f)));continue}if(d===t-1){let y=v(r[t-2]);s.push(W.add(p,W.mul(y,f))),i.push(W.sub(p,W.mul(y,f)));continue}let h=v(r[d-1]),m=v(r[d]),x=W.cross(v(a[d-1]),v(a[d]));if(Math.abs(x)<1e-9){s.push(W.add(p,W.mul(h,f))),i.push(W.sub(p,W.mul(h,f)));continue}x>0?(s.push(...rI(p,h,m,f,1)),i.push(...sI(p,h,m,f,-1))):(s.push(...sI(p,h,m,f,1)),i.push(...rI(p,h,m,f,-1)))}let l=iI(n(t-1),v(r[t-2]),o(t-1),!1),c=iI(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},rI=(e,t,n,o,a)=>{let r=W.normalize(W.add(t,n)),s=W.dot(r,t);return s>.001&&1/s<=2.5?[W.add(e,W.mul(r,a*(o/s)))]:[W.add(e,W.mul(t,a*o)),W.add(e,W.mul(n,a*o))]},sI=(e,t,n,o,a)=>lI(e,o,W.angle(W.mul(t,a)),W.angle(W.mul(n,a))),iI=(e,t,n,o)=>{let a=W.angle(t)+(o?Math.PI:0);return lI(e,n,a,a-Math.PI)},lI=(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 cI=new Map,av=(e,t)=>{cI.set(e,t)},lp=e=>{let t=N(e),n=cI.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 cp=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}}},sv={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"}]}},iv={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)||!uI(n,e.probe,e.threshold))continue;let o=qa(n,e.probe,ko(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}},lv={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)||!uI(n,e.probe,e.threshold))continue;let o=$C(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}},uI=(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 cv=()=>20,Y0=e=>e.snapToGrid??!0,uv=Object.freeze({pan:{x:0,y:0},zoom:1,rotation:0,size:{width:0,height:0},gridEnabled:!1}),ao=e=>{let t=z.translation(-e.pan.x,-e.pan.y),n=z.rotation(e.rotation),o=z.scaling(e.zoom);return z.multiply(o,z.multiply(n,t))},Va=e=>z.inverse(ao(e)),dv=(e,t)=>({...e,pan:{x:e.pan.x-t.x/e.zoom,y:e.pan.y-t.y/e.zoom}}),K0=(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}}},fv=(e,t,n)=>({...e,size:{width:t,height:n}});var Et=class extends Error{name="FractionalIndexError"};var $0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function dI(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 Et("invalid order key head: "+e)}function fI(e){let t=e.charAt(0);if(e.length!==dI(t))throw new Et("invalid integer part of order key: "+e)}function Ac(e){let t=dI(e.charAt(0));if(t>e.length)throw new Et("invalid order key: "+e);return e.slice(0,t)}function pv(e,t){fI(e);let n=t.charAt(0),[o,...a]=e.split("");if(o===void 0)throw new Et("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 pI(e,t){fI(e);let[n,...o]=e.split("");if(n===void 0)throw new Et("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 yi(e,t,n){let o=n.charAt(0);if(t!==null&&e>=t)throw new Et(e+" >= "+t);if(e.slice(-1)===o||t!==null&&t.slice(-1)===o)throw new Et("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)+yi(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)+yi(e.slice(1),null,n)}function hI(e){return"A"+e.charAt(0).repeat(26)}function yU(e){return"a"+e.charAt(0)}function hv(e,t=$0){if(e===hI(t))throw new Et("invalid order key: "+e);let n=Ac(e);if(e.slice(n.length).slice(-1)===t.charAt(0))throw new Et("invalid order key: "+e)}function ro(e,t,n=$0){let o=e??null,a=t??null;if(o!==null&&hv(o,n),a!==null&&hv(a,n),o!==null&&a!==null&&o>=a)throw new Et(o+" >= "+a);if(o===null&&a===null)return yU(n);if(o===null){let u=Ac(a),d=a.slice(u.length);if(u===hI(n))return u+yi("",d,n);if(u<a)return u;let f=pI(u,n);if(f===null)throw new Et("cannot decrement any more");return f}if(a===null){let u=Ac(o),d=o.slice(u.length),f=pv(u,n);return f===null?u+yi(d,null,n):f}let r=Ac(o),s=o.slice(r.length),i=Ac(a),l=a.slice(i.length);if(r===i)return r+yi(s,l,n);let c=pv(r,n);if(c===null)throw new Et("cannot increment any more");return c<a?c:r+yi(s,null,n)}function up(e,t,n,o=$0){if(!Number.isInteger(n)||n<0)throw new Et(`n must be a non-negative integer, got ${n}`);if(n===0)return[];if(n===1)return[ro(e,t,o)];let a=e??null,r=t??null;if(r===null){let l=ro(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=ro(l,r,o),c.push(l);return c}if(a===null){let l=ro(a,r,o),c=[l];for(let u=0;u<n-1;u++)l=ro(a,l,o),c.push(l);return c.reverse(),c}let s=Math.floor(n/2),i=ro(a,r,o);return[...up(a,i,s,o),i,...up(i,r,n-s-1,o)]}var On=cn("default"),gU=()=>({id:On,name:"Default",visible:!0,locked:!1,order:ro(null,null)}),dn=Object.freeze({elements:new Map,links:new Map,layers:new Map([[On,gU()]]),annotations:new Map,files:new Map,viewport:uv}),mv=()=>({elements:new Map(dn.elements),links:new Map(dn.links),layers:new Map(dn.layers),annotations:new Map(dn.annotations),files:new Map(dn.files),viewport:dn.viewport});var Q0=(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)}},Ae=e=>{let t=null;for(let n of e)(t===null||n>t)&&(t=n);return ro(t,null)},vc=e=>{let t=null;for(let n of e)(t===null||n<t)&&(t=n);return ro(null,t)},Sc=(e,t)=>ro(e,t),yv=(e,t,n)=>up(e,t,n);var gv={pan:"browser",zoom:"browser",rotation:"browser",size:"ephemeral",gridEnabled:"export",gridStyle:"export",snapToGrid:"export"},mI=Object.keys(gv),Cse=mI.filter(e=>gv[e]==="ephemeral"),xU=(e,...t)=>{let n=e;for(let o of t)if(o)for(let a of mI)o[a]!==void 0&&(n={...n,[a]:o[a]});return n},xv=(e={})=>{let{saved:t,hostSettings:n}=e;return{elements:new Map(t?.elements??dn.elements),links:new Map(t?.links??dn.links),layers:new Map(t?.layers??dn.layers),annotations:new Map(t?.annotations??dn.annotations),files:new Map(t?.files??dn.files),viewport:xU(dn.viewport,n?.viewport,t?.viewport)}};var bv=(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 Lc=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(Lc).reverse()}}},Yo=e=>{let t=[];for(let n of e)n.kind==="batch"?t.push(...n.patches):t.push(n);return{kind:"batch",patches:t}},Jr=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(Jr)}};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:J(e,n),patch:n}},fn=(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}},$=(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 gi=(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}},xi=(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}},Ye=(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}},Av=(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}},vv=(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}},dp=(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}},Sv=(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}},Lv=(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}},ja=(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 es=(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 yI=new Map,kv=(e,t)=>{yI.set(e,t)},_v=e=>{let t=yI.get(e.type);if(t){let n=t(e).trim();if(n)return n}return gI(e.type)},gI=e=>e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).replace(/[-_]/g," ");kv("text",e=>{let t=e.text.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,77)}\u2026`:t});kv("template",e=>{let t=e.metadata?.label;return typeof t=="string"&&t.trim()?t.trim():gI(e.templateId)});var xI=new Map,wv=e=>{xI.set(e.kind,e)};var J0=e=>xI.get(e);var fp=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}}},ey=(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(Tt);let r=a.map(fp),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=$(u,d.id,y=>({...y,position:m}));u=x.scene,c.push(x.patch)}),c.length===0?null:Yo(c)},ty=(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(Tt);let r=[],s=e,i={x:o.x,y:o.y};for(let l of a){let{width:c,height:u}=fp(l);if(l.position.x!==i.x||l.position.y!==i.y){let d=i,f=$(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:Yo(r)},bI=(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}},AI=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(a)}return n.sort(Tt),n.map(o=>{let a=fp(o);return{id:o.id,w:a.width,h:a.height}})},vI=(e,t)=>{if(t.shapeIds.length===0)return null;let n=t.gap??16,o=t.origin??{x:0,y:0},a=AI(e,t.shapeIds),{placements:r}=bI(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=$(i,l.id,d=>({...d,position:{x:l.x,y:l.y}}));i=u.scene,s.push(u.patch)}return s.length===0?null:Yo(s)},ny=(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=AI(e,o),r=I(e,t),s=(r?Dn(r):null)?.gap??16,i=bI(a,s,n,{x:0,y:0});return{widest:i.widest,contentWidth:i.contentWidth,contentHeight:i.contentHeight}},Dn=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=J0(n.kind);if(o){let a=o.parse(t);if(a!==null)return{...a,kind:n.kind}}}return null},pp=(e,t)=>{let n=I(e,t);if(!n)return null;let o=Dn(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=no(n),s=r?{x:r.x,y:r.y}:n.position;if(o.kind==="grid")return ey(e,{shapeIds:a,origin:s,cols:o.cols,...o.gap!==void 0?{gap:o.gap}:{}});if(o.kind==="stack")return ty(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 vI(e,{shapeIds:a,origin:s,innerWidth:c,...o.gap!==void 0?{gap:o.gap}:{}})}if(o.kind==="tree")return SI(e,{shapeIds:a,origin:s,...o.ranksep!==void 0?{ranksep:o.ranksep}:{},...o.nodesep!==void 0?{nodesep:o.nodesep}:{}});let i=o,l=J0(i.kind);return l?l.run(e,t,a,s,i):null},SI=(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(Tt),x},s=new Map,i=new Map,l=m=>fp(m).width,c=m=>fp(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 C=0,w=0;for(let M=0;M<_.length;M++){let B=u(v(_[M]).id);C+=B.w,M>0&&(C+=o),B.h>w&&(w=B.h)}let L=Math.max(b,C),k=A+n+w;return s.set(m,L),i.set(m,k),{w:L,h:k}};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),C={x:x+(b.w-A)/2,y};if(g.position.x!==C.x||g.position.y!==C.y){let M=$(f,m,B=>({...B,position:C}));f=M.scene,d.push(M.patch)}let w=r(m);if(w.length===0)return;let L=x,k=y+_+n;for(let M of w)p(M.id,L,k),L+=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:Yo(d)};var AU=20,oy=.5,vU=1e5,Ev=(e,t,n,o={})=>{if(SU(e,t))return[e];let a=o.margin??AU,r=n.map(L=>LU(L,a)),s=o.startHeading,i=o.endHeading,l=new Set([e.x,t.x]),c=new Set([e.y,t.y]);for(let L of r)l.add(L.x),l.add(L.x+L.width),c.add(L.y),c.add(L.y+L.height);let u=[...l].sort((L,k)=>L-k),d=[...c].sort((L,k)=>L-k),f=(L,k)=>`${L},${k}`,p=L=>v(u[L]),h=L=>v(d[L]),m=u.indexOf(e.x),x=d.indexOf(e.y),y=u.indexOf(t.x),g=d.indexOf(t.y),b=(L,k)=>Math.abs(p(L)-p(y))+Math.abs(h(k)-h(g)),A=f(m,x),_=[{key:A,skey:`${A},0`,xi:m,yi:x,axis:0,g:0,f:b(m,x)}],C=new Map,w=new Map([[`${A},0`,0]]);for(;_.length>0;){_.sort((k,M)=>k.f-M.f||k.g-M.g||(k.skey<M.skey?-1:1));let L=v(_.shift());if(L.xi===y&&L.yi===g)return wU(C,L.skey,p,h);for(let k of kU(L.xi,L.yi,u.length,d.length)){let M={x:p(L.xi),y:h(L.yi)},B={x:p(k.xi),y:h(k.yi)};if(_U(M,B,r))continue;let G=Math.sign(B.x-M.x),ie=Math.sign(B.y-M.y);if(L.axis===0&&s&&G===-Math.sign(s.x)&&ie===-Math.sign(s.y)||k.xi===y&&k.yi===g&&i&&G===Math.sign(i.x)&&ie===Math.sign(i.y))continue;let ne=k.xi!==L.xi?1:2,V=Math.abs(M.x-B.x)+Math.abs(M.y-B.y),ve=L.axis!==0&&L.axis!==ne?vU:0,ge=L.g+V+ve,ee=f(k.xi,k.yi),Se=`${ee},${ne}`,Oe=w.get(Se);Oe!==void 0&&ge>=Oe||(w.set(Se,ge),C.set(Se,L.skey),_.push({key:ee,skey:Se,xi:k.xi,yi:k.yi,axis:ne,g:ge,f:ge+b(k.xi,k.yi)}))}}return null},SU=(e,t)=>e.x===t.x&&e.y===t.y,LU=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),kU=(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},_U=(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<=oy||l-o<=oy||s-i.y<=oy||c-r<=oy))return!0}return!1},wU=(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 TU(a)},TU=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 mp=(e,t)=>{let n=oo(e,t.from),o=oo(e,t.to);if(!n||!o)return[];let a=t.from.kind==="floating"?oo(e,t.from,o)??n:n,r=t.to.kind==="floating"?oo(e,t.to,n)??o:o;if(a.x===r.x&&a.y===r.y)return[];let s=TI(e,t.from,a,r),i=TI(e,t.to,r,a),l=t.avoidObstacles===!0?EU(e,t):void 0,c=l&&l.length<=150?l:void 0,u=CI(a,r,s,i,t.routedPoints,c);return u=MU(u,t.fixedSegments),u},EU=(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(N(a));return o},Cv=(e,t,n,o,a)=>{if(n.x===a.x&&n.y===a.y)return[n,a];let r=wI(e,t,n,a),s=wI(e,o,a,n);return[n,...CI(n,a,r,s),a]},CI=(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=Ev(i,l,h,{startHeading:n.heading,endHeading:o.heading}),x=m&&m.length>=2?m:[i,EI(i,l,n.heading),l];return hp(x)}let u=CU(e,t,n,o,i,l);if(u&&!_I(u,c))return hp(u);let d=IU(e,t,n,o,i,l,c,a);if(d&&!_I(d,c))return hp(d);let f=Ev(i,l,c,{startHeading:n.heading,endHeading:o.heading}),p=f&&f.length>=2?f:[i,EI(i,l,n.heading),l];return hp(p)},CU=(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},LI=(e,t,n,o,a)=>{let r=e<=t;return a!==null&&Math.abs(e-t)<24?a?n:o:r?n:o},IU=(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=LI(p,(c+d)/2,c,d,kI(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=LI(p,(l+u)/2,l,u,kI(i,"x"));return[a,{x:h,y:a.y},{x:h,y:r.y},r]}return null},kI=(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},_I=(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},wI=(e,t,n,o)=>{if(!t)return{heading:op(o,n),obstacle:null};let a=I(e,t);return a?{heading:YC(a,n),obstacle:N(a)}:{heading:op(o,n),obstacle:null}},MU=(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 hp(n)},RU=e=>{switch(e){case"top":return np;case"bottom":return ep;case"left":return tp;case"right":return xc;default:return null}},TI=(e,t,n,o)=>{if(t.kind==="point")return{heading:op(o,n),obstacle:null};let a=I(e,t.elementId);if(!a)return{heading:op(o,n),obstacle:null};let r=N(a);if(t.kind==="anchor"&&t.anchor.kind==="named"){let s=RU(t.anchor.name);if(s)return{heading:s,obstacle:r}}return{heading:j0(a,n),obstacle:r}},EI=(e,t,n)=>XC(n)?{x:t.x,y:e.y}:{x:e.x,y:t.y},hp=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 Za=Rf.light.accent,II="rgba(91, 91, 214, 0.10)",ay=12,bi="orthogonal",yp="triangle",MI=.05,Iv=5,RI=3,ts=11,Mv=26,OI=7,Rv=Math.PI/12,Ko=11,DI=6,PI=4,BI=12,ry=9,Ov=4,NI=Za,zI="#fff",gp=3.5,$o=5,FI=8,HI=1.5,UI=NI,Dv=zI,GI=zI,Pv=NI,wo=20,WI=0,qI="#ffffff",sy=6,iy=7,VI=18,Bv=40,kc=.16,xp=.7,Nv="#e8118c",jI="#f59e0b",bp="#2563eb",zv="#16a34a",ZI="#06b6d4",XI="#a855f7",YI="#eab308",KI="#dc2626",$I="#14b8a6",QI="#f43f5e",JI=16,Fv=14,Hv=6,Uv=3,Gv=11,e4=1.5,t4=[4,3],n4=3;var Wv=1,qv=1.6,Vv=10,o4=1,a4=.05,r4=32,s4=.5,i4=500,_c=8,wc=300,Tc=8,l4=.6,c4=.2,u4=.85,ly=.4,d4=22,f4=22,p4=18,h4=16,m4=16,y4=9,cy=12,g4="#f9a825",x4="#fff",b4="#888",A4=10,jv=2e3,Zv=.5,v4=.5,Xv=12,uy=6,S4=2,L4="#222222",k4=1,_4=4,w4=.5,Yv=.3,T4=32,E4=.55,C4=.7,dy=.7,Kv=1.5,I4=2048,M4=0,R4=.1,$v=uy*3,O4=6,fy="#888888",D4=1.5,py=120,P4=.25,B4=.5,N4=10,z4=1,hy=1400,F4="#ff2d2d",Qv=4,H4=8,Jv=480,U4=480,G4=270,W4=1e3/60,q4=1e3/12,V4=2,j4=2*1024*1024,Z4=3e4,X4=24,Y4="system-ui, sans-serif",K4="#1a1a1a",$4=1e3,Q4=1,J4=10,e5=530,t5=Za,n5=.25,o5=1.5,my=4,e2=1.1,To=80,a5=8,yy=.5,r5=256,s5=30,i5=16,t2=4,l5=4,c5="rgba(0,0,0,0.65)",u5=16,d5=Za,f5="#fff",Ap=10,p5=11,h5=.12,m5=14,y5=3,g5=8;var Ai=["nw","n","ne","e","se","s","sw","w"],vi=["nw","ne","se","sw"],x5=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 Si=(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=RI/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}}},n2=(e,t,n,o=ts,a=Ai)=>{let r=o/n;for(let f of a){if(f.length!==2)continue;let p=Si(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},Ec=(e,t)=>e.rotation===0?t:W.rotateAround(t,e.pivot,e.rotation),OU=(e,t)=>e.rotation===0?t:W.rotateAround(t,e.pivot,-e.rotation),Li=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}},vp=e=>{let t=e.bounds;return[Ec(e,{x:t.x,y:t.y}),Ec(e,{x:t.x+t.width,y:t.y}),Ec(e,{x:t.x+t.width,y:t.y+t.height}),Ec(e,{x:t.x,y:t.y+t.height})]},b5=e=>Ec(e,{x:e.bounds.x+e.bounds.width/2,y:e.bounds.y+e.bounds.height/2}),A5=(e,t,n=1)=>Ec(t,Si(e,t.bounds,n)),v5=(e,t,n,o=ts,a=Ai)=>n2(OU(t,e),t.bounds,n,o,a),DU={kind:"ratio",position:{x:0,y:1}},PU=new Map;var BU=e=>PU.get(e)??DU,gy=(e,t=1)=>{let n=BU(e.type),o=Yt(e,n),a=Xo(e,n),r=Mv/t;return{x:o.x+a.x*r,y:o.y+a.y*r}},xy=(e,t=1)=>{let n=Mv/t*Math.SQRT1_2;return{x:e.x-n,y:e.y+e.height+n}},o2=(e,t,n,o=ts)=>{let a=o/n;return Math.abs(e.x-t.x)<=a&&Math.abs(e.y-t.y)<=a};function NU(){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 zU(){let e=NU();if(e.__xstate__)return e.__xstate__}var S5=e=>{if(typeof window>"u")return;let t=zU();t&&t.register(e)};var by=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}},d2=".",FU="",f2="",HU="#",UU="*",E5="xstate.init",C5="xstate.error",s2="xstate.stop";function GU(e,t){return{type:`xstate.after.${e}.${t}`}}function i2(e,t){return{type:`xstate.done.state.${e}`,output:t}}function WU(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function p2(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function vy(e){return{type:E5,input:e}}function Qo(e){setTimeout(()=>{throw e})}var qU=typeof Symbol=="function"&&Symbol.observable||"@@observable";function h2(e,t){let n=L5(e),o=L5(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?h2(n[a],o[a]):!1)}function Sy(e){if(R5(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 L5(e){if(Q5(e))return e.value;if(typeof e!="string")return e;let t=Sy(e);return I5(t)}function I5(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 m2(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 M5(e){return R5(e)?e:[e]}function Jo(e){return e===void 0?[]:M5(e)}function l2(e,t,n,o){return typeof e=="function"?e({context:t,event:n,self:o}):e}function R5(e){return Array.isArray(e)}function VU(e){return e.type.startsWith("xstate.error.actor")}function ki(e){return M5(e).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function O5(e){if(!(e===void 0||e===FU))return Jo(e)}function Sp(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 y2(e,t){return`${t}.${e}`}function kp(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 D5(e,t){if(t===e||t===UU)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 k5(e,t){return`${e.sessionId}.${t}`}var jU=0;function ZU(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=k5(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=k5(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:${jU++}`,_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=Sp(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 a2=!1,Ly=1,Kt=(function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e})({}),XU={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},Ay=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 by(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={...XU,...n},{clock:a,logger:r,parent:s,syncSnapshot:i,id:l,systemId:c,inspect:u}=o;this.system=s?s.system:ZU(this,{clock:a,logger:r}),u&&!s&&this.system.inspect(Sp(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){Qo(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=a2;try{a2=!0,d.exec(d.info,d.params)}finally{a2=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){Qo(r)}break;case"done":for(let a of this.observers)try{a.next?.(t)}catch(r){Qo(r)}this._stopProcedure(),this._complete(),this._doneEvent=WU(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=Sp(t,n,o);if(this._processingStatus!==Kt.Stopped)this.observers.add(a);else switch(this._snapshot.status){case"done":try{a.complete?.()}catch(r){Qo(r)}break;case"error":{let r=this._snapshot.error;if(!a.error)Qo(r);else try{a.error(r)}catch(s){Qo(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=Sp(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=vy(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===s2&&(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:s2}),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){Qo(n)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||Qo(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){Qo(r)}}this.observers.clear(),this.eventListeners.clear(),n&&Qo(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,p2(this.id,t))}_stopProcedure(){return this._processingStatus!==Kt.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new by(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:S5)(this)}toJSON(){return{xstate$$type:Ly,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[qU](){return this}getSnapshot(){return this._snapshot}};function ea(e,...[t]){return new Ay(e,t)}function YU(e,t,n,o,{sendId:a}){let r=typeof a=="function"?a(n,o):a;return[t,{sendId:r},void 0]}function KU(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function Rc(e){function t(n,o){}return t.type="xstate.cancel",t.sendId=e,t.resolve=YU,t.execute=KU,t}function $U(e,t,n,o,{id:a,systemId:r,src:s,input:i,syncSnapshot:l}){let c=typeof s=="string"?kp(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=ea(c,{id:u,src:s,parent:e.self,syncSnapshot:l,systemId:r,input:f})),[os(t,{children:{...t.children,[u]:d}}),{id:a,systemId:r,actorRef:d,src:s,input:f},void 0]}function QU(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==Kt.Stopped&&t.start()})}function Oc(...[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=$U,r.execute=QU,r}function JU(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]),[os(t,{children:i}),s,void 0]}function P5(e,t){let n=t.getSnapshot();if(n&&"children"in n)for(let o of Object.values(n.children))P5(e,o);e.system._unregister(t)}function eG(e,t){if(t){if(P5(e,t),t._processingStatus!==Kt.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Ti(e){function t(n,o){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=JU,t.execute=eG,t}function tG(e,{context:t,event:n},{guards:o}){return o.every(a=>Ei(a,t,n,e))}function B5(e){function t(n,o){return!1}return t.check=tG,t.guards=e,t}function Ei(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 Ei(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 ky(e){return e.type==="atomic"||e.type==="final"}function Ic(e){return Object.values(e.states).filter(t=>t.type!=="history")}function Dc(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 _p(e){let t=new Set(e),n=z5(t);for(let o of t)if(o.type==="compound"&&(!n.get(o)||!n.get(o).length))_5(o).forEach(a=>t.add(a));else if(o.type==="parallel"){for(let a of Ic(o))if(a.type!=="history"&&!t.has(a)){let r=_5(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 N5(e,t){let n=t.get(e);if(!n)return{};if(e.type==="compound"){let a=n[0];if(a){if(ky(a))return a.key}else return{}}let o={};for(let a of n)o[a.key]=N5(a,t);return o}function z5(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 F5(e,t){let n=_p(t);return N5(e,z5(n))}function _y(e,t){return t.type==="compound"?Ic(t).some(n=>n.type==="final"&&e.has(n)):t.type==="parallel"?Ic(t).every(n=>_y(e,n)):t.type==="final"}var wp=e=>e[0]===HU;function H5(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(o=>D5(t,o)).sort((o,a)=>a.length-o.length).flatMap(o=>e.transitions.get(o))}function U5(e){let t=e.config.after;if(!t)return[];let n=a=>{let r=GU(a,e.id),s=r.type;return e.entry.push(Bc(r,{id:s,delay:a})),e.exit.push(Rc(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 Jo(s).map(c=>({...c,event:l,delay:i}))}).map(a=>{let{delay:r}=a;return{...Xa(e,a.event,a),delay:r}})}function Xa(e,t,n){let o=O5(n.target),a=n.reenter??!1,r=nG(e,o),s={...n,actions:Jo(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 G5(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===f2)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let o=e.config.on[n];t.set(n,ki(o).map(a=>Xa(e,n,a)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,ki(e.config.onDone).map(o=>Xa(e,n,o)))}for(let n of e.invoke){if(n.onDone){let o=`xstate.done.actor.${n.id}`;t.set(o,ki(n.onDone).map(a=>Xa(e,o,a)))}if(n.onError){let o=`xstate.error.actor.${n.id}`;t.set(o,ki(n.onError).map(a=>Xa(e,o,a)))}if(n.onSnapshot){let o=`xstate.snapshot.${n.id}`;t.set(o,ki(n.onSnapshot).map(a=>Xa(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 W5(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?B5([i,s]):i,target:`#${r}`};t.push(Xa(e,"xstate.route",l))}a.states&&n(a.states)})};n(e.states),t.length>0&&e.transitions.set("xstate.route",t)}function q5(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"?[]:Jo(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...o,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return o}function nG(e,t){if(t!==void 0)return t.map(n=>{if(typeof n!="string")return n;if(wp(n))return e.machine.getStateNodeById(n);let o=n[0]===d2;if(o&&!e.parent)return Lp(e,n.slice(1));let a=o?e.key+n:n;if(e.parent)try{return Lp(e.parent,a)}catch(r){throw new Error(`Invalid transition definition for state node '${e.id}':
|
|
12
|
+
${r.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function V5(e){let t=O5(e.config.target);return t?{target:t.map(n=>typeof n=="string"?Lp(e.parent,n):n)}:e.parent.initial}function _i(e){return e.type==="history"}function _5(e){let t=j5(e);for(let n of t)for(let o of Dc(n,e))t.add(o);return t}function j5(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 Ic(o))n(a)}}return n(e),t}function Mc(e,t){if(wp(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 Lp(e,t){if(typeof t=="string"&&wp(t))try{return e.machine.getStateNodeById(t)}catch{}let n=Sy(t).slice(),o=e;for(;n.length;){let a=n.shift();if(!a.length)break;o=Mc(o,a)}return o}function Pc(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=>Mc(e,a)).filter(Boolean);return[e.machine.root,e].concat(o,n.reduce((a,r)=>{let s=Mc(e,r);if(!s)return a;let i=Pc(s,t[r]);return a.concat(i)},[]))}function oG(e,t,n,o){let r=Mc(e,t).next(n,o);return!r||!r.length?e.next(n,o):r}function aG(e,t,n,o){let a=Object.keys(t),r=Mc(e,a[0]),s=wy(r,t[a[0]],n,o);return!s||!s.length?e.next(n,o):s}function rG(e,t,n,o){let a=[];for(let r of Object.keys(t)){let s=t[r];if(!s)continue;let i=Mc(e,r),l=wy(i,s,n,o);l&&a.push(...l)}return a.length?a:e.next(n,o)}function wy(e,t,n,o){return typeof t=="string"?oG(e,t,n,o):Object.keys(t).length===1?aG(e,t,n,o):rG(e,t,n,o)}function sG(e){return Object.keys(e.states).map(t=>e.states[t]).filter(t=>t.type==="history")}function ns(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function iG(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 Z5(e,t,n){let o=new Set;for(let a of e){let r=!1,s=new Set;for(let i of o)if(iG(c2([a],t,n),c2([i],t,n)))if(ns(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 lG(e){let[t,...n]=e;for(let o of Dc(t,void 0))if(n.every(a=>ns(a,o)))return o}function g2(e,t){if(!e.target)return[];let n=new Set;for(let o of e.target)if(_i(o))if(t[o.id])for(let a of t[o.id])n.add(a);else for(let a of g2(V5(o),t))n.add(a);else n.add(o);return[...n]}function X5(e,t){let n=g2(e,t);if(!n)return;if(!e.reenter&&n.every(a=>a===e.source||ns(a,e.source)))return e.source;let o=lG(n.concat(e.source));if(o)return o;if(!e.reenter)return e.source.machine.root}function c2(e,t,n){let o=new Set;for(let a of e)if(a.target?.length){let r=X5(a,n);a.reenter&&a.source===r&&o.add(r);for(let s of t)ns(s,r)&&o.add(s)}return[...o]}function cG(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function x2(e,t,n,o,a){return u2([{target:[...j5(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,o,!0,a)}function u2(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=Z5(e,l,c),d=t;a||([d,c]=pG(d,o,n,u,l,c,r,n.actionExecutor)),d=wi(d,o,n,u.flatMap(p=>p.actions),r,void 0),d=dG(d,o,n,u,l,r,c,a);let f=[...l];d.status==="done"&&(d=wi(d,o,n,f.sort((p,h)=>h.order-p.order).flatMap(p=>p.exit),r,void 0));try{return c===t.historyValue&&cG(t._nodes,l)?[d,s]:[os(d,{_nodes:f,historyValue:c}),s]}catch(p){throw p}}finally{n.actionExecutor=i}}function uG(e,t,n,o,a){if(o.output===void 0)return;let r=i2(a.id,a.output!==void 0&&a.parent?l2(a.output,e.context,t,n.self):void 0);return l2(o.output,e.context,r,n.self)}function dG(e,t,n,o,a,r,s,i){let l=e,c=new Set,u=new Set;fG(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(Oc(h.src,{...h,syncSnapshot:!!h.onSnapshot}));if(u.has(f)){let h=f.initial.actions;p.push(...h)}if(l=wi(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(i2(h.id,f.output!==void 0?l2(f.output,l.context,t,n.self):void 0));m?.type==="parallel"&&!d.has(m)&&_y(a,m);)d.add(m),r.push(i2(m.id)),x=m,m=m.parent;if(m)continue;l=os(l,{status:"done",output:uG(l,t,n,l.machine.root,x)})}}return l}function fG(e,t,n,o){for(let a of e){let r=X5(a,t);for(let i of a.target||[])!_i(i)&&(a.source!==i||a.source!==r||a.reenter)&&(o.add(i),n.add(i)),Cc(i,t,n,o);let s=g2(a,t);for(let i of s){let l=Dc(i,r);r?.type==="parallel"&&l.push(r),Y5(o,t,n,l,!a.source.parent&&a.reenter?void 0:r)}}}function Cc(e,t,n,o){if(_i(e))if(t[e.id]){let a=t[e.id];for(let r of a)o.add(r),Cc(r,t,n,o);for(let r of a)r2(r,e.parent,o,t,n)}else{let a=V5(e);for(let r of a.target)o.add(r),a===e.parent?.initial&&n.add(e.parent),Cc(r,t,n,o);for(let r of a.target)r2(r,e.parent,o,t,n)}else if(e.type==="compound"){let[a]=e.initial.target;_i(a)||(o.add(a),n.add(a)),Cc(a,t,n,o),r2(a,e,o,t,n)}else if(e.type==="parallel")for(let a of Ic(e).filter(r=>!_i(r)))[...o].some(r=>ns(r,a))||(_i(a)||(o.add(a),n.add(a)),Cc(a,t,n,o))}function Y5(e,t,n,o,a){for(let r of o)if((!a||ns(r,a))&&e.add(r),r.type==="parallel")for(let s of Ic(r).filter(i=>!_i(i)))[...e].some(i=>ns(i,s))||(e.add(s),Cc(s,t,n,e))}function r2(e,t,n,o,a){Y5(n,o,a,Dc(e,t))}function pG(e,t,n,o,a,r,s,i){let l=e,c=c2(o,a,r);c.sort((d,f)=>f.order-d.order);let u;for(let d of c)for(let f of sG(d)){let p;f.history==="deep"?p=h=>ky(h)&&ns(h,d):p=h=>h.parent===d,u??={...r},u[f.id]=Array.from(a).filter(p)}for(let d of c)l=wi(l,t,n,[...d.exit,...d.invoke.map(f=>Ti(f.id))],s,void 0),a.delete(d);return[l,u||r]}function hG(e,t){return e.implementations.actions[t]}function K5(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:hG(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=K5(i,t,n,x,a,r))}return i}function wi(e,t,n,o,a,r){let s=r?[]:void 0,i=K5(e,t,n,o,{internalQueue:a,deferredActorIds:r},s);return s?.forEach(([l,c])=>{l.retryResolve(n,i,c)}),i}function Tp(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===s2)return a=os(w5(a,t,n),{status:"stopped"}),s([a,[]],t,[]),{snapshot:a,microsteps:r};let i=t;if(i.type!==E5){let d=i,f=VU(d),p=T5(d,a);if(f&&!p.length)return a=os(e,{status:"error",error:d.error}),s([a,[]],d,[]),{snapshot:a,microsteps:r};let h=u2(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?mG(a,i):[],f=d.length?a:void 0;if(!d.length){if(!o.length)break;i=o.shift(),d=T5(i,a)}let p=u2(d,a,n,i,!1,o);a=p[0],l=a!==f,s(p,i,d)}return a.status!=="active"&&w5(a,i,n),{snapshot:a,microsteps:r}}function w5(e,t,n){return wi(e,t,n,Object.values(e.children).map(o=>Ti(o)),[],void 0)}function T5(e,t){return t.machine.getTransitionData(t,e)}function mG(e,t){let n=new Set,o=e._nodes.filter(ky);for(let a of o)e:for(let r of[a].concat(Dc(a,void 0)))if(r.always){for(let s of r.always)if(s.guard===void 0||Ei(s.guard,e.context,t,e)){n.add(s);break e}}return Z5(Array.from(n),new Set(e._nodes),e.historyValue)}function $5(e,t){let n=_p(Pc(e,t));return F5(e,[...n])}function Q5(e){return!!e&&typeof e=="object"&&"machine"in e&&"value"in e}var yG=function(t){return h2(t,this.value)},gG=function(t){return this.tags.has(t)},xG=function(t){let n=this.machine.getTransitionData(this,t);return!!n?.length&&n.some(o=>o.target!==void 0||o.actions.length)},bG=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)}},AG=function(){return this._nodes.reduce((t,n)=>(n.meta!==void 0&&(t[n.id]=n.meta),t),{})};function Ep(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:F5(t.root,e._nodes),tags:new Set(e._nodes.flatMap(n=>n.tags)),children:e.children,historyValue:e.historyValue||{},matches:yG,hasTag:gG,can:xG,getMeta:AG,toJSON:bG}}function os(e,t={}){return Ep({...e,...t},e.machine)}function vG(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 J5(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:eM(s),children:p,historyValue:vG(f.historyValue)}}function eM(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:Ly,id:o.id};else{let a=eM(o);a!==o&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=a)}}return t??e}function SG(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 LG(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 Bc(e,t){function n(o,a){}return n.type="xstate.raise",n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=SG,n.execute=LG,n}function tM(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 yle=tM(e=>{},void 0);function kG(e,{machine:t,context:n},o,a){let r=(s,i)=>{if(typeof s=="string"){let l=kp(t,s);if(!l)throw new Error(`Actor logic '${s}' not implemented in machine '${t.id}'`);let c=ea(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 ea(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 _G(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:kG(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[os(t,{context:l,children:Object.keys(r).length?{...t.children,...r}:t.children}),void 0,void 0]}function Pn(e){function t(n,o){}return t.type="xstate.assign",t.assignment=e,t.resolve=_G,t}var nM=new WeakMap;function Nc(e,t,n){let o=nM.get(e);return o?t in o||(o[t]=n()):(o={[t]:n()},nM.set(e,o)),o[t]}var wG={},Cp=e=>typeof e=="string"?{type:e}:typeof e=="function"?"resolve"in e?{type:e.type}:{type:e.name}:e,Ty=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(d2),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?m2(this.config.states,(o,a)=>new e(o,{_parent:this,_key:a,_machine:this.machine})):wG,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=Jo(this.config.entry).slice(),this.exit=Jo(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=Jo(t.tags).slice()}_initialize(){this.transitions=G5(this),this.config.always&&(this.always=ki(this.config.always).map(t=>Xa(this,f2,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(Cp),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(Cp),eventType:null})}:void 0,history:this.history,states:m2(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(Cp)})),entry:this.entry.map(Cp),exit:this.exit.map(Cp),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 Nc(this,"invoke",()=>Jo(this.config.invoke).map((t,n)=>{let{src:o,systemId:a}=t,r=t.id??y2(this.id,n),s=typeof o=="string"?o:`xstate.invoke.${y2(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 Nc(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 Nc(this,"delayedTransitions",()=>U5(this))}get initial(){return Nc(this,"initial",()=>q5(this,this.config.initial))}next(t,n){let o=n.type,a=[],r,s=Nc(this,`candidates-${o}`,()=>H5(this,o));for(let i of s){let{guard:l}=i,c=t.context,u=!1;try{u=!l||Ei(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}':
|
|
13
|
+
${d.message}`)}if(u){a.push(...i.actions),r=i;break}}return r?[r]:void 0}get events(){return Nc(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)}},TG="#",Ey=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 Ty(t,{_key:this.id,_machine:this}),this.root._initialize(),W5(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=$5(this.root,t.value),o=_p(Pc(this.root,n));return Ep({_nodes:[...o],context:t.context||{},children:{},status:_y(o,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,n,o){return Tp(t,n,o,[]).snapshot}microstep(t,n,o){return Tp(t,n,o,[]).microsteps.map(([a])=>a)}getTransitionData(t,n){return wy(this.root,t.value,t,n)||[]}_getPreInitialState(t,n,o){let{context:a}=this.config,r=Ep({context:typeof a!="function"&&a?a:{},_nodes:[this.root],children:{},status:"active"},this);return typeof a=="function"?wi(r,n,t,[Pn(({spawn:i,event:l,self:c})=>a({spawn:i,input:l.input,self:c}))],o,void 0):r}getInitialSnapshot(t,n){let o=vy(n),a=[],r=this._getPreInitialState(t,o,a),[s]=x2(this.root,r,t,o,a),{snapshot:i}=Tp(s,o,t,a);return i}start(t){Object.values(t.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(t){let n=Sy(t),o=n.slice(1),a=wp(n[0])?n[0].slice(TG.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 Lp(r,o)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,n){return J5(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"?kp(this,h):h;if(!m)return;let x=ea(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 Ty)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=Ep({...t,children:o,_nodes:Array.from(_p(Pc(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===Ly){d[p]=f[h.id];continue}u(h,f)}}}}return u(l.context,o),l}};function EG(e,t,n,o,{event:a}){let r=typeof a=="function"?a(n,o):a;return[t,{event:r},void 0]}function CG(e,{event:t}){e.defer(()=>e.emit(t))}function Iy(e){function t(n,o){}return t.type="xstate.emit",t.event=e,t.resolve=EG,t.execute=CG,t}var Cy=(function(e){return e.Parent="#_parent",e.Internal="#_internal",e})({});function IG(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 MG(e,t,n){typeof n.to=="string"&&(n.to=t.children[n.to])}function RG(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===C5?p2(e.self.id,o.data):o)})}function Ip(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=IG,o.retryResolve=MG,o.execute=RG,o}function oM(e,t){return Ip(Cy.Parent,e,t)}function OG(e,t,n,o,{collect:a}){let r=[],s=function(l){r.push(l)};return s.assign=(...i)=>{r.push(Pn(...i))},s.cancel=(...i)=>{r.push(Rc(...i))},s.raise=(...i)=>{r.push(Bc(...i))},s.sendTo=(...i)=>{r.push(Ip(...i))},s.sendParent=(...i)=>{r.push(oM(...i))},s.spawnChild=(...i)=>{r.push(Oc(...i))},s.stopChild=(...i)=>{r.push(Ti(...i))},s.emit=(...i)=>{r.push(Iy(...i))},a({context:n.context,event:n.event,enqueue:s,check:i=>Ei(i,t.context,n.event,t),self:e.self,system:e.system},o),[t,void 0,r]}function Ct(e){function t(n,o){}return t.type="xstate.enqueueActions",t.collect=e,t.resolve=OG,t}function DG(e,t,n,o,{value:a,label:r}){return[t,{value:typeof a=="function"?a(n,o):a,label:r},void 0]}function PG({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function b2(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=DG,n.execute=PG,n}function BG(e,t){return new Ey(e,t)}function A2({schemas:e,actors:t,actions:n,guards:o,delays:a}){return{assign:Pn,sendTo:Ip,raise:Bc,log:b2,cancel:Rc,stopChild:Ti,enqueueActions:Ct,emit:Iy,spawnChild:Oc,createStateConfig:r=>r,createAction:r=>r,createMachine:r=>BG({...r,schemas:e},{actors:t,actions:n,guards:o,delays:a}),extend:r=>A2({schemas:e,actors:t,actions:{...n,...r.actions},guards:{...o,...r.guards},delays:{...a,...r.delays}})}}var NG=()=>({mode:P0,pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null}),Ci=4,ta=(e,t)=>{let n=t.x-e.x,o=t.y-e.y;return n*n+o*o>=Ci*Ci},Mp=(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)}},aM=A2({types:{context:{},events:{},emitted:{}},actions:{startPress:Pn((e,t)=>({pressOrigin:t.point,pressLast:t.point,pressTarget:t.target,pressModifiers:t.modifiers})),updateLast:Pn((e,t)=>({pressLast:t.point})),setDrawingType:Pn((e,t)=>({drawingType:t.kind})),resetGesture:Pn(()=>({pressOrigin:null,pressLast:null,pressTarget:null,drawingType:null,pressModifiers:null})),setMode:Pn((e,t)=>({mode:t.mode})),emitMoveElement:Ct(({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:Ct(({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:Ct(({context:e,enqueue:t})=>{e.pressTarget?.kind==="annotation"&&t.emit({type:"COMMIT_ANNOTATION_DRAG",id:e.pressTarget.id})}),emitResizeElement:Ct(({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:Ct(({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:Ct(({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:Ct(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin||!e.drawingType)return;let o=Mp(e.pressOrigin,t.point);o.width<1||o.height<1||n.emit({type:"CREATE_SHAPE",shapeType:e.drawingType,bounds:o})}),emitLinkPreview:Ct(({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:Ct(({enqueue:e})=>{e.emit({type:"DRAW_EDGE_PREVIEW_CLEAR"})}),emitLinkEndpointPreview:Ct(({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:Ct(({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:Ct(({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:Mp(e.pressOrigin,t.point),mode:a?"add":"replace"})}),emitLassoCommit:Ct(({context:e,event:t,enqueue:n})=>{if(t.type!=="POINTER_UP"||!e.pressOrigin)return;let o=Mp(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:Ct(({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<Ci*Ci||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:ta(e.pressOrigin,t.point),movedAndOnHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="handle"?!1:ta(e.pressOrigin,t.point),movedAndOnGroupHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="group-handle"?!1:ta(e.pressOrigin,t.point),movedAndOnRotateHandle:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="rotate-handle"?!1:ta(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:ta(e.pressOrigin,t.point),movedAndDrawingLink:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="draw-edge"?!1:ta(e.pressOrigin,t.point),movedAndOnLinkEndpoint:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="edge-endpoint"?!1:ta(e.pressOrigin,t.point),movedAndOnAnnotation:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.pressTarget?.kind!=="annotation"||e.mode!=="select"?!1:ta(e.pressOrigin,t.point),movedAndLasso:({context:e,event:t})=>t.type!=="POINTER_MOVE"||!e.pressOrigin||e.mode!=="select"||e.pressTarget?.kind!=="empty"?!1:ta(e.pressOrigin,t.point)}}).createMachine({id:"interaction",initial:"idle",context:NG(),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"}]}}}}}),rM=(e,t)=>{if(!e.pressOrigin||!e.pressTarget||ta(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 sM=new Map,so=(e,t)=>{sM.set(e,t)},as=e=>sM.get(e);var Ii=["background","main","overlay"];var iM=(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 rs=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}},zG=new rs,zc=(e,t)=>e.getOrCompute(t,N);var v2={placeholder:.15,hideText:.4},S2="#bbb";var L2=.06,k2=.92,_2=.5,Fc=10,w2=sA,T2=iA,E2=1,C2=1,I2=4,M2=4,R2=3,O2=12,D2=56,P2=10,B2=20,lM=.4,cM=.5,N2=.1,z2=.9,uM="#888",dM="#ffffff",fM="#222",pM="#ddd",hM=18,mM=12,yM="#444",gM="#222",xM=10,F2="#000",bM="#222",AM="#fff",vM=4;var Rp=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 My=e=>e<=0?1:2**Math.round(Math.log2(e));var Ya=(e,t,n={})=>{let o=ao(e.viewport),a=n.dirtyWorld;if(!n.skipClear)if(a){let C=[z.applyToPoint(o,{x:a.x,y:a.y}),z.applyToPoint(o,{x:a.x+a.width,y:a.y+a.height})],w=j.expand(j.fromPoints(C),2);t.clear(w)}else t.clear();t.save(),t.setTransform(o);let r=n.boundsCache??new rs,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??S2,m=n.layerCompositeCache,x=n.dirtyLayerIds,y=n.compositeLayerBitmap,g=My(l),b=C=>{let w=null;for(let L of Wa(e,C)){let k=zc(r,L);w=w?j.union(w,k):k}return w},A=n.dimOpacity,_=n.dimElements!==void 0&&A!==void 0?iM(t,A):null;for(let C of Lo(e))if(C.visible){if(m&&y){x?.has(C.id)&&m.invalidateLayer(C.id);let w=m.get(C.id,g);if(w===void 0){let L=y(C.id,g,e);L!==null&&(m.set(C.id,g,L),w=L)}if(w!==void 0){let L=b(C.id);L&&t.drawImage(w,L.x,L.y,L.width,L.height);continue}}for(let w of Wa(e,C.id)){if(n.hideElements?.has(w.id)||i&&!i.has(w.id))continue;if(s){let B=zc(r,w);if(!j.intersects(B,s))continue}if(a){let B=zc(r,w);if(!j.intersects(B,a))continue}if(p&&pe(w))continue;if(f){let B=zc(r,w);t.setFill(h),t.setStrokeWidth(0),t.beginPath(),t.rect(B.x,B.y,B.width,B.height),t.fill();continue}let L=as(w.type);if(!L){n.onUnknownElement?.(w);continue}t.save();let k=_!==null&&n.dimElements?.has(w.id)===!0,M=k?_:t;k&&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),L(w,M,u),t.restore()}}t.restore()};var H2=(e,t,n)=>{let{maxWidth:o}=n,a=n.lineHeightFactor??1.2,r=[],s=n.fontFamily??"sans-serif",i=n.shaper,l=i?u=>i.measure(u,{family:s,size:n.fontSize}).width:u=>t.measureText(u).width;for(let u of e.split(`
|
|
14
|
+
`)){if(u===""){r.push({text:"",width:0});continue}let d=u.split(/\s+/).filter(m=>m.length>0);if(d.length===0){r.push({text:"",width:0});continue}let f=d[0];if(f===void 0){r.push({text:"",width:0});continue}let p=f,h=l(p);for(let m=1;m<d.length;m++){let x=d[m];if(x===void 0)continue;let y=`${p} ${x}`,g=l(y);g<=o?(p=y,h=g):(r.push({text:p,width:h}),p=x,h=l(x))}r.push({text:p,width:h})}let c=n.fontSize*a;return{lines:r,lineHeight:c}};var SM=1.2,FG=(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)},Hc=(e,t,n)=>{let o=n.fontSize*(n.lineHeightFactor??SM),a=[],r=0;for(let l=0;l<=e.length;l++)if(l===e.length||e[l]===`
|
|
15
|
+
`){let c=e.slice(r,l);n.maxWidth===void 0?a.push({text:c,start:r,end:l,width:t(c)}):FG(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}},U2=(e,t,n)=>n==="center"?t/2-e/2:n==="right"?t-e:0,HG=(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},G2=(e,t,n,o,a)=>{let r=HG(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:U2(s.width,e.blockWidth,a)+l,y:r*e.lineHeight,height:o,line:r}},W2=(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=U2(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},q2=(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=U2(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 LM=new Map,Op=e=>{LM.set(e.kind,e)};var V2=new Set,j2=e=>(V2.add(e),()=>V2.delete(e)),Z2=()=>{for(let e of V2)try{e()}catch{}},kM=()=>typeof performance<"u"?performance.now():0,X2=e=>{kM=e};var Mi=(e,t=kM(e))=>{if(!e.animationKind)return e.src;let n=LM.get(e.animationKind);if(!n)return e.src;try{return n.getFrameAt(e.animationData,t)}catch{return e.src}};var Pp=(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}},UG=(e,t)=>{let{fill:n,stroke:o}=Pp(e.style,t);if(!n&&!o)return;let a=Wf(e.style.roundness,e.width,e.height);if(n&&(t.beginPath(),a>0?Ry(t,0,0,e.width,e.height,a):t.rect(0,0,e.width,e.height),t.fill()),o){let r=Dy(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?Ry(t,s,i,l,c,u):t.rect(s,i,l,c),t.stroke()}},Dy=e=>{let t=e.strokeAlign??"center";if(t==="center")return 0;let n=(e.strokeWidth??1)/2;return t==="inside"?n:-n},Ry=(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()},GG=(e,t)=>{let{fill:n,stroke:o}=Pp(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=Dy(e.style),i=a-s,l=r-s;if(i<=0||l<=0)return;t.beginPath(),t.ellipse(a,r,i,l),t.stroke()}},WG=(e,t)=>{if(e.points.length<2)return;let{fill:n,stroke:o}=Pp(e.style,t);if(!(!n&&!o)&&(n&&(t.beginPath(),Oy(t,e.points),t.fill()),o)){let a=Dy(e.style),r=a!==0?Gf.offsetClosedPath(e.points,a):e.points;t.beginPath(),Oy(t,r),t.stroke()}},Oy=(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()}},qG=(e,t)=>{if(e.commands.length===0)return;let{fill:n,stroke:o}=Pp(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()}},VG=(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=Hc(e.text,c=>t.measureText(c).width,{fontSize:o,...e.maxWidth!==void 0?{maxWidth:e.maxWidth}:{}}),s=r.lines.map(c=>{let u=qf(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*L2);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*k2,p.width,l),t.fill()),x.strikethrough&&(t.beginPath(),t.rect(f,d+o*_2-l/2,p.width,l),t.fill())),f+=p.width}})},jG=(e,t)=>{if(e.runs!==void 0&&e.runs.length>0){VG(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(`
|
|
16
|
+
`))i=[{text:e.text,x:0,width:t.measureText(e.text).width,top:0}];else{let c=d=>t.measureText(d).width,u=Hc(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*L2);for(let u of i)u.width<=0||(l.underline&&(t.beginPath(),t.rect(u.x,u.top+s*k2,u.width,c),t.fill()),l.strikethrough&&(t.beginPath(),t.rect(u.x,u.top+s*_2-c/2,u.width,c),t.fill()))}},ZG=(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=Vf(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=ip(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()}},XG=(e,t,n)=>{let o=n?.clock?.(e),a=e.animationKind?Mi(e,o):e.metadata?.image??Mi(e,o),r=e.metadata?.animated===!0||e.animationKind!==void 0;t.drawImage(a,0,0,e.width,e.height,r,e.crop)},Uc=()=>{so("rectangle",UG),so("ellipse",GG),so("polygon",WG),so("path",qG),so("text",jG),so("image",XG),so("group",()=>{}),so("frame",QG),av("frame",()=>({top:24})),so("block-arrow",YG),so("brush",ZG)},YG=(e,t)=>{let{fill:n,stroke:o}=Pp(e.style,t),a=e.direction??"right",r=Math.max(N2,Math.min(z2,e.headRatio??lM)),s=Math.max(N2,Math.min(z2,e.bodyThickness??cM)),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])=>KG([m,x],a,i,l)));let h=p.map(([m,x])=>({x:m,y:x}));if(n&&(t.beginPath(),Oy(t,h),t.fill()),o){let m=Dy(e.style),x=m!==0?Gf.offsetClosedPath(h,m):h;t.beginPath(),Oy(t,x),t.stroke()}},KG=([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)]}},Y2="\u2026",$G=(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)+Y2).width<=t?o=r:a=r-1}return o>0?e.slice(0,o)+Y2:Y2},QG=(e,t,n)=>{t.setFill(e.style.fill??dM),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(uM),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:$G(a,r,t),l=s?Math.min(t.measureText(a).width+16,e.width):e.width;t.setFill(fM),t.beginPath(),t.rect(0,-24,l,24),t.fill(),t.setFill(pM),t.setTextBaseline("middle"),t.setTextAlign("left"),t.fillText(i,8,-24/2)};var Py=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,ss(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}},ss=(e,t)=>{let n=_o(e,t);if(!n||n.length===0)return null;let o=1/0,a=1/0,r=-1/0,s=-1/0;for(let m of n)m.x<o&&(o=m.x),m.y<a&&(a=m.y),m.x>r&&(r=m.x),m.y>s&&(s=m.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)),u=o-c,d=a-c,f=r+c,p=s+c,h=Qf(n,t);return h&&(u=Math.min(u,h.x),d=Math.min(d,h.y),f=Math.max(f,h.x+h.width),p=Math.max(p,h.y+h.height)),{x:u,y:d,width:f-u,height:p-d}},$2=new Py;var Bn=(e,t,n={})=>{t.save(),t.setTransform(ao(e.viewport));let o=n.edgeBoundsCache??$2,a=n.viewportWorld,r=n.dirtyWorld,s=n.edgeBitmapCache,i=n.rasteriseLink,l=My(n.zoom??e.viewport.zoom);for(let c of Lo(e))if(c.visible)for(let u of HA(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&&!j.intersects(d,a)||r&&!j.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}}JG(e,u,t,n)}t.restore()},JG=(e,t,n,o)=>{let a=ut(e,t);if(!a||a.length<2){o.onMissingEndpoint?.(t);return}let r=(t.routing??"straight")==="bezier"?ap(e,t):null,s=r?$f(r.start,r.segments):a;if(n.save(),(t.lineKind??"line")==="block-arrow")eW(t,a,n);else{if(oW(t,n),n.beginPath(),r){n.moveTo(r.start.x,r.start.y);for(let i of r.segments)n.bezierCurveTo(i.c1.x,i.c1.y,i.c2.x,i.c2.y,i.to.x,i.to.y)}else if(a.length>=3&&Fc>0)By(n,a,Fc);else{let i=v(a[0]);n.moveTo(i.x,i.y);for(let l=1;l<a.length;l++){let c=v(a[l]);n.lineTo(c.x,c.y)}}n.stroke(),t.arrowheads&&aW(s,t.arrowheads,n,t.style.stroke??F2)}t.label&&rW(s,t,n),n.restore()},eW=(e,t,n)=>{let o=e.blockArrow?.headLength??hM,a=e.blockArrow?.bodyThickness??mM,r=e.style.fill??e.style.stroke??yM,s=e.style.stroke??gM,i=e.style.strokeWidth??1;e.style.opacity!==void 0&&n.setOpacity(e.style.opacity);let l=tW(t,o);if(l.length<2)return;let c=_M(l,a/2),u=_M(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=wM(d,p,m),y=wM(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()},tW=(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},_M=(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},wM=(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}},nW=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},By=(e,t,n)=>{let o=nW(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)},oW=(e,t)=>{let n=e.style.stroke??F2;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)},aW=(e,t,n,o)=>{let a=t.size??xM;if(t.from&&t.from!=="none"){let r=e[0],s=e[1];r!==void 0&&s!==void 0&&TM(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&&TM(r,s,t.to,a,n,o)}},TM=(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(...Eo(m(o,p))),a.lineTo(...Eo(m(o,-p))),a.closePath(),a.stroke();break}case"filledArrow":{a.beginPath(),a.moveTo(e.x,e.y),a.lineTo(...Eo(m(o,p))),a.lineTo(...Eo(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(...Eo(m(o,p))),a.lineTo(...Eo(h(o*2))),a.lineTo(...Eo(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(...Eo(m(0,p))),a.moveTo(w.x,w.y),a.lineTo(...Eo(m(0,-p))),a.stroke()}let _=y?o*1.15:o*.55,C=w=>{a.beginPath(),a.moveTo(...Eo(m(w,p))),a.lineTo(...Eo(m(w,-p))),a.stroke()};if(A&&C(_),b&&C(_+o*.4),g){let w=p*.6,L=h(o*(y?1.6:1)+w);a.beginPath(),a.ellipse(L.x,L.y,w,w),a.stroke()}break}}},Eo=e=>[e.x,e.y],rW=(e,t,n)=>{let o=t.label;if(!o||o.text==="")return;let a=o.fontSize??12,r=o.fill??bM,s=o.background??AM,i=gc(e,t);n.setFont("system-ui, sans-serif",a);let{lines:l,lineHeight:c}=H2(o.text,n,{maxWidth:160,fontSize:a,lineHeightFactor:1.25}),u=0;for(let h of l)u=Math.max(u,h.width);let d=u+12,f=l.length*c+6;n.beginPath(),n.setFill(s),n.setStroke(null),Ry(n,i.x-d/2,i.y-f/2,d,f,Math.min(vM,f/2)),n.fill(),n.setFill(r),n.setTextAlign("center"),n.setTextBaseline("middle");let p=i.y-(l.length-1)*c/2;for(let h=0;h<l.length;h++){let m=l[h];m===void 0||m.text===""||n.fillText(m.text,i.x,p+h*c)}};var EM=(e,t,n,o,a=M2,r=R2)=>{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},Bp=(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?T2:w2),i=e.viewport.zoom,{width:l,height:c}=t.size;if(l<=0||c<=0)return;let u=cW(e,l,c);if(!u)return;let d=f=>{r?iW(t,u,f,s,i):sW(t,u,f,s,i)};if(t.save(),t.setTransform(ao(e.viewport)),t.setDashArray(null),n.levels)for(let f of n.levels){let p=lW(i,f);if(p<=0)continue;let h=f.step*o;h*i<I2||(t.setOpacity(p),d(h))}else{let f=r?P2:O2,p=r?B2:D2;for(let h of EM(o,i,f,p))t.setOpacity(h.opacity),d(h.step)}t.setOpacity(1),t.restore()},sW=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=CM(t,n),c=E2/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()},iW=(e,t,n,o,a)=>{let{minX:r,maxX:s,minY:i,maxY:l}=CM(t,n);e.setStroke(null),e.setFill(o);let c=C2/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()},CM=(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}),lW=(e,t)=>e>=t.mid?1:e<=t.min?0:(e-t.min)/(t.mid-t.min),cW=(e,t,n)=>{let o=Va(e.viewport),a=[z.applyToPoint(o,{x:0,y:0}),z.applyToPoint(o,{x:t,y:0}),z.applyToPoint(o,{x:t,y:n}),z.applyToPoint(o,{x:0,y:n})],r=j.fromPoints(a);return Number.isFinite(r.x)?r:null};var IM=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()},Np=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 IM(e,t),{instance:a}=await WebAssembly.instantiate(o,{});return a},is=(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 MM=null,zp=e=>{MM=e},Q2=()=>MM;var RM=null,Fp=e=>{RM=e},Ny=()=>RM;var zy={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=un.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=un.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 Fy=(e,t,n)=>{if(e.length<3)return e;let o=Kf(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=un.cubicAt(s,l.c1,l.c2,l.to,f);r.push(n(c,u,p,f))}s=l.to}return r};var Hy=(e,t)=>({points:[{x:e.x,y:e.y,t}]}),J2=(e,t,n)=>{e.points.push({x:t.x,y:t.y,t:n})},eS=(e,t,n=hy)=>{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}},OM=(e,t=H4)=>Fy(e,t,(n,o,a,r)=>({x:a.x,y:a.y,t:n.t+(o.t-n.t)*r}));var Ri=e=>e.type==="rectangle"||e.type==="ellipse"||e.type==="image"||e.type==="template"||e.type==="frame",uW=new Set(["rectangle","ellipse","template","text","frame"]),Oi=e=>uW.has(e.type),tS=e=>Ai;var Co=(e,t)=>{let n=ko(e),a=[...V0(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=Xo(e,i);return{x:l.x+c.x*t,y:l.y+c.y*t}});return{names:a,worldPoints:r}};var BM=(e,t)=>{let n=t.scene.viewport.zoom,o=t.hitAnnotation(e);if(o!==null){let s=t.scene.annotations.get(o);if(s)return{kind:"annotation",id:o,origin:es(t.scene,s)}}if(t.selectionChromeActive){let s=dW(e,t,n);if(s)return s}let a=t.acceleratedElementAt(e);if(a&&t.isElementInteractable(a)){let s=t.promoteToGroupRoot(a);return{kind:"element",id:s.id,bounds:N(s)}}let r=ov(t.scene,e,t.edgeHitThreshold/n);return r&&!t.isLayerLocked(r.layerId)?{kind:"link",id:r.id}:{kind:"empty"}},dW=(e,t,n)=>{let o=t.selection.size+t.selectedLinkCount>1||t.selectionIsAspectLocked();if(o){let r=t.combinedSelectionBounds();if(r){let i=t.selectionIsAspectLocked()?vi:Ai,l=n2(e,r,n,t.handleHitSlop,i);if(l)return{kind:"group-handle",handle:l,bounds:r}}}if(t.selection.size===1)for(let r of t.selection){let s=I(t.scene,r);if(!s||!Oi(s)||s.locked===!0)continue;let i=Li(s),l=v5(e,i,n,t.handleHitSlop,tS(s));if(l)return{kind:"handle",elementId:r,handle:l,bounds:i.bounds}}let a=o?t.combinedSelectionBounds():null;if(a){let r=xy(a,n);if(o2(e,r,n,t.handleHitSlop))return{kind:"rotate-handle",pivot:{x:a.x+a.width/2,y:a.y+a.height/2},bounds:a}}else if(t.selection.size===1)for(let r of t.selection){let s=I(t.scene,r);if(!s||!Oi(s)||s.locked===!0)continue;let i=gy(s,n);if(o2(e,i,n,t.handleHitSlop)){let l=Li(s);return{kind:"rotate-handle",pivot:b5(l),bounds:l.bounds}}}if(t.selectedLink){let r=ue(t.scene,t.selectedLink);if(r){let s=ut(t.scene,r);if(s&&s.length>=2){let i=t.edgeHandleHitSlop/n,l=v(s[0]),c=v(s[s.length-1]);if(W.distance(e,l)<=i)return{kind:"edge-endpoint",linkId:r.id,side:"from"};if(W.distance(e,c)<=i)return{kind:"edge-endpoint",linkId:r.id,side:"to"}}}}return null},Hp=(e,t,n,o,a,r)=>{e.setStroke(null),e.setFill(r),e.setOpacity(kc),e.beginPath(),e.rect(t,n,o,a),e.fill(),e.setFill(null),e.setStroke(r),e.setStrokeWidth(1),e.setOpacity(xp),e.beginPath(),e.rect(t,n,o,a),e.stroke()},Di=(e,t,n,o,a)=>{e.setStroke(null),e.setFill(a),e.setOpacity(kc),e.beginPath(),e.ellipse(t,n,o,o),e.fill(),e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setOpacity(xp),e.beginPath(),e.ellipse(t,n,o,o),e.stroke()},fW=(e,t,n,o,a)=>{e.setFill(null),e.setStroke(a),e.setStrokeWidth(1),e.setDashArray([2,2]),e.setOpacity(xp),e.beginPath(),e.ellipse(t,n,o,o),e.stroke(),e.setDashArray(null)},DM=(e,t,n)=>{if(t.length<3)return;e.setStroke(null),e.setFill(n),e.setOpacity(kc),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(xp),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()},PM=(e,t,n,o,a,r)=>{let s=z.applyToPoint(t,{x:n.x,y:n.y}),i=z.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=ts;for(let p of a)switch(p){case"nw":case"ne":case"se":case"sw":{let h=z.applyToPoint(t,Si(p,n,o));Hp(e,h.x-f,h.y-f,f*2,f*2,r);break}case"n":Hp(e,l-f,c-f,u+f*2,f*2,r);break;case"s":Hp(e,l-f,c+d-f,u+f*2,f*2,r);break;case"w":Hp(e,l-f,c-f,f*2,d+f*2,r);break;case"e":Hp(e,l+u-f,c-f,f*2,d+f*2,r);break}},Uy=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}},NM=(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&&Oi(p)&&p.locked!==!0&&PM(e,o,N(p),a,tS(p),Nv)}if(s.linkBodies)for(let f of n.links.values()){let p=ut(n,f);if(!p||p.length<2)continue;e.setFill(null),e.setStroke(jI),e.setStrokeWidth(ry*2),e.setOpacity(kc),e.setLineCap("round"),e.setLineJoin("round"),e.beginPath();let h=z.applyToPoint(o,v(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=z.applyToPoint(o,v(p[m]));e.lineTo(x.x,x.y)}e.stroke()}if(s.selectedEdgeHandles&&i){let f=z.applyToPoint(o,i.from),p=z.applyToPoint(o,i.to);Di(e,f.x,f.y,Ko,bp),Di(e,p.x,p.y,Ko,bp);for(let h of i.waypoints??[]){let m=z.applyToPoint(o,h);Di(e,m.x,m.y,Ko,bp)}for(let h of i.midpoints??[]){let m=z.applyToPoint(o,h);Di(e,m.x,m.y,Ko,bp)}}if(s.anchorDots&&r.size===1){let f=v([...r][0]),p=I(n,f);if(p){let h=$o+sy,{worldPoints:m}=Co(p,wo/a);for(let x of m){let y=z.applyToPoint(o,x);Di(e,y.x,y.y,h,zv),fW(e,y.x,y.y,iy,zv)}}}if(s.attachDropZones&&l){let f=l.thresholdWorld*a;for(let p of l.outlineLoops)DM(e,p.map(h=>z.applyToPoint(o,h)),YI);e.setFill(null),e.setStroke(XI),e.setStrokeWidth(f*2),e.setOpacity(kc),e.setLineCap("round"),e.setLineJoin("round");for(let p of l.outlineLoops){if(p.length<2)continue;e.beginPath();let h=z.applyToPoint(o,v(p[0]));e.moveTo(h.x,h.y);for(let m=1;m<p.length;m++){let x=z.applyToPoint(o,v(p[m]));e.lineTo(x.x,x.y)}e.closePath(),e.stroke()}for(let p of l.anchors){let h=z.applyToPoint(o,p);Di(e,h.x,h.y,f,ZI)}}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=>z.applyToPoint(o,x));DM(e,m,h)};for(let p of c.frames)f(p,KI);for(let p of c.containers)f(p,$I)}if(s.groupHandles&&u&&PM(e,o,u,a,d?vi:Ai,Nv),s.annotationPins)for(let f of n.annotations.values()){let p=z.applyToPoint(o,es(n,f));Di(e,p.x,p.y,cy,QI)}e.setOpacity(1),e.restore()};var HM=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=ze(o)?HM(e,o.id):N(o);a&&(n=n?j.union(n,a):a)}return n},UM={selectionStroke:Za,selectionStrokeWidth:1,handleFill:"#fff",handleStroke:Za,drawingStroke:Za,drawingDash:[4,4]},GM=.32,WM=(e,t,n,o,a=UM)=>{if(n.length===0)return;let s=Ov/(o||1);e.setTransform(t),e.setStroke(a.selectionStroke),e.setOpacity(GM),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(z.IDENTITY)},qM=(e,t,n,o={})=>{let a={...UM,...o.style};n.clear();let r=ao(e.viewport),s=e.viewport.zoom;n.save(),n.setTransform(z.IDENTITY);let i={scene:e,selection:t,target:n,options:o,style:a,w2s:r,zoom:s};pW(i),hW(i),mW(i),yW(i),gW(i),xW(i),bW(i),vW(i),SW(i),LW(i),kW(i),_W(i),wW(i),TW(i),n.restore()},pW=e=>{let{scene:t,selection:n,target:o,options:a,w2s:r,zoom:s}=e;a.debugHitZones&&NM(o,{scene:t,w2s:r,zoom:s,selection:n,visibility:a.debugHitZoneVisibility??Uy({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}:{}})},hW=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=HM(t,c);if(!f)continue;let p=na(f,s);if(oS(o,p,r),u.locked===!0){FM(o,p);continue}if(l||!Oi(u)||a.readOnly===!0||a.suppressHandles===!0)continue;for(let h of vi){let m=Si(h,f,i);aS(o,z.applyToPoint(s,m),r)}jM(o,f,i,s,r);continue}let d=Li(u);if(d.rotation===0?oS(o,na(d.bounds,s),r):CW(o,d,s,r),u.locked===!0){FM(o,IW(d,s));continue}if(!(l||!Oi(u)||a.readOnly===!0||a.suppressHandles===!0)){for(let f of vi){let p=A5(f,d,i);aS(o,z.applyToPoint(s,p),r)}VM(o,z.applyToPoint(s,gy(u,i)),r)}}},mW=e=>{let{target:t,options:n,style:o,w2s:a}=e;if(n.cropGhost&&DW(t,n.cropGhost,a),n.cropFrame&&n.cropFrame.length>=4){let r=n.cropFrame.map(s=>z.applyToPoint(a,s));RW(t,r,o),OW(t,r,o)}if(n.drawingPreview){let r=na(n.drawingPreview,a);MW(t,r,o)}if(n.drawingPreviewElement){let r=n.drawingPreviewElement,s=as(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(u4),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=as(r.type);s&&(t.save(),t.setTransform(a),t.setOpacity(yy),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=as(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.ghostElement||n.ghostElementShape){t.setOpacity(ly);let r=n.ghostElementShape,s=r?as(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=na(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=na(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()}},yW=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=z.applyToPoint(a,v(i.worldPoints[l])),u=i.activeIndex===l;PW(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(GM),t.setDashArray(null),t.setLineJoin("round"),t.setLineCap("round");let s=Ov/(r||1);for(let{path:i,width:l}of n.selectedLinkPaths)i.length<2||(t.setStrokeWidth(l+2*s),t.beginPath(),By(t,i,Fc),t.stroke());t.setOpacity(1),t.setLineJoin("miter"),t.setLineCap("butt"),t.setTransform(z.IDENTITY)}if(n.edgeSelection&&n.readOnly!==!0&&n.suppressHandles!==!0){let s=z.applyToPoint(a,n.edgeSelection.from),i=z.applyToPoint(a,n.edgeSelection.to);for(let l of n.edgeSelection.midpoints??[])BW(t,z.applyToPoint(a,l),o);nS(t,s,o),nS(t,i,o);for(let l of n.edgeSelection.waypoints??[])nS(t,z.applyToPoint(a,l),o)}},gW=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=na(r,o);NW(t,s,a.color)}},xW=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=ip(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()}},bW=e=>{let{target:t,options:n,w2s:o}=e;zM(t,o,n.laserStrokes,F4,Qv,hy);let a=(n.eraserCursor?.radius??Qv/2)*2;zM(t,o,n.eraserTrail,fy,a,py)},zM=(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=OM(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=>z.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=AW(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)},AW=(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]},vW=e=>{let{target:t,options:n,w2s:o}=e,a=n.eraserCursor;if(!a||a.radius<=0)return;let r=z.applyToPoint(o,a.center);t.setDashArray(null),t.setOpacity(1),t.beginPath(),t.ellipse(r.x,r.y,a.radius,a.radius),t.setFill(fy),t.fill(),t.setFill(null),t.setStroke(fy),t.setStrokeWidth(D4),t.stroke()},SW=e=>{let{target:t,options:n,w2s:o}=e;if(n.containerDropZone){let a=na(n.containerDropZone,o);t.setFill(II),t.setStroke(Za),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)}},LW=e=>{let{target:t,options:n,style:o,w2s:a,zoom:r}=e;if(!n.cropFrame&&n.groupBounds){let s=na(n.groupBounds,a);if(oS(t,s,o),n.readOnly===!0||n.suppressHandles===!0)return;let i=vi;for(let l of i){let c=Si(l,n.groupBounds,r),u=z.applyToPoint(a,c);aS(t,u,o)}jM(t,n.groupBounds,r,a,o)}},kW=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=es(t,r),i=z.applyToPoint(a,s);FW(n,i,r,o.selectedAnnotation??null)}},_W=e=>{let{target:t,options:n,w2s:o}=e;if(n.peerCursors)for(let a of n.peerCursors){let r=z.applyToPoint(o,a.position);zW(t,r,a.color,a.name)}},wW=e=>{let{target:t,options:n,w2s:o}=e;if(n.gifBadges)for(let a of n.gifBadges)EW(t,na(a,o))},TW=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(t5),t.setOpacity(n5);for(let s of r.selectionRects){let i=na(s,o);t.beginPath(),t.rect(i.x,i.y,i.width,i.height),t.fill()}t.setOpacity(1)}if(r.caret){let s=z.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,o5,r.caret.height*a),t.fill()}}},FM=(e,t)=>{let n=u5,o=t.x+t.width-n-2,a=t.y+2,r=d5;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(f5),e.beginPath(),e.ellipse(o+n/2,a+n*.64,n*.07,n*.07),e.fill()},EW=(e,t)=>{let n=t.x+t2,o=t.y+t2,a=s5,r=i5,s=l5;e.setStroke(null),e.setFill(c5),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)},na=(e,t)=>{let n=z.applyToPoint(t,{x:e.x,y:e.y}),o=z.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)}},oS=(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()},CW=(e,t,n,o)=>{let[a,r,s,i]=vp(t),l=z.applyToPoint(n,a),c=z.applyToPoint(n,r),u=z.applyToPoint(n,s),d=z.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()},IW=(e,t)=>{let n=vp(e).map(i=>z.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}},Gy=(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)},aS=(e,t,n)=>{Gy(e,t,Iv,{fill:n.handleFill,stroke:n.handleStroke,strokeWidth:1})},VM=(e,t,n)=>{let o=OI/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")},jM=(e,t,n,o,a)=>{let r=xy(t,n);VM(e,z.applyToPoint(o,r),a)},MW=(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()},RW=(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)},OW=(e,t,n)=>{if(t.length<4)return;e.setStroke(n.selectionStroke),e.setStrokeWidth(y5),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(m5,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")},DW=(e,t,n)=>{let o=t.element,a=o.animationKind!==void 0?Mi(o,void 0):o.metadata?.image??Mi(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(h5),e.drawImage(a,s.x,s.y,s.width,s.height,r),e.setOpacity(1),e.restore()},PW=(e,t,n,o="link-start",a)=>{let r=n?a??$o:gp,s=o==="link-start";Gy(e,t,r,{fill:n?s?Dv:Pv:s?UI:GI,stroke:s?Dv:Pv,strokeWidth:HI})},nS=(e,t,n)=>{Gy(e,t,DI,{fill:n.handleFill,stroke:n.selectionStroke,strokeWidth:2})},BW=(e,t,n)=>{Gy(e,t,PI,{fill:n.handleFill,stroke:n.selectionStroke,strokeWidth:1.5,opacity:.55})},NW=(e,t,n)=>{let o=n4;e.setStroke(n),e.setStrokeWidth(e4),e.setDashArray(t4),e.beginPath(),e.rect(t.x-o,t.y-o,t.width+2*o,t.height+2*o),e.stroke()},zW=(e,t,n,o)=>{let a=JI;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",Gv),e.setTextBaseline("top"),e.setTextAlign("left");let r=e.measureText(o).width,s=t.x+Fv,i=t.y+Fv,l=r+2*Hv,c=Gv+2*Uv;e.setFill(n),e.setStrokeWidth(0),e.beginPath(),e.rect(s,i,l,c),e.fill(),e.setFill("#fff"),e.fillText(o,s+Hv,i+Uv)},FW=(e,t,n,o)=>{let a=y4,r=n.resolved?b4:g4,s=n.id===o;if(e.setFill(r),e.setStroke(s?Za:x4),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",A4),e.setTextAlign("center"),e.setTextBaseline("middle"),e.setFill("#fff"),e.fillText(l,t.x,t.y)}};var Gc=(e,t)=>{let n=t.getBoundingClientRect();return{kind:UW(e.pointerType),phase:GW(e.type),point:{x:e.clientX-n.left,y:e.clientY-n.top},buttons:e.buttons,modifiers:HW(e),pointerId:e.pointerId,timestamp:e.timeStamp}};var oa=e=>{if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable},HW=e=>({shift:e.shiftKey,ctrl:e.ctrlKey,alt:e.altKey,meta:e.metaKey}),UW=e=>e==="pen"?"pen":e==="touch"?"touch":"mouse",GW=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 rS=()=>typeof navigator<"u"?navigator.userAgent:"",Up=()=>typeof navigator<"u"&&navigator.platform||"",ls=/Mac|iPod|iPhone|iPad/.test(Up()),WW=Up().startsWith("Win"),ZM=/\b(android)\b/i.test(rS()),qW=/iPad|iPhone/i.test(Up())||typeof navigator<"u"&&/Mac/i.test(Up())&&typeof navigator.maxTouchPoints=="number"&&navigator.maxTouchPoints>1,VW=/Linux/i.test(Up())&&!ZM,jW=/Firefox/i.test(rS()),ZW=/^((?!chrome|android).)*safari/i.test(rS());var XW={Enter:"\u23CE",Backspace:"\u232B",Delete:"\u2326",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"\u21E5"," ":"Space"},YW={Enter:"Enter",Backspace:"Backspace",Delete:"Del",ArrowLeft:"\u2190",ArrowRight:"\u2192",ArrowUp:"\u2191",ArrowDown:"\u2193",Escape:"Esc",Tab:"Tab"," ":"Space"},Wy=e=>{let t=[];ls?(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=ls?XW:YW,o=e.key??e.code??"",a=n[o]??(o.length===1?o.toUpperCase():o);return t.push(a),t},dt=e=>{let t=Wy(e);return ls?t.join(""):t.join("+")};var XM={id:"undo",label:"Undo",category:"history",hotkey:{key:"z",meta:!0},iconId:"undo",predicate:({editor:e})=>e.canUndo,perform:({editor:e})=>e.undo()},YM={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()},sS=[XM,YM];var yt=e=>e.editor.selection.size>0,iS=e=>e.editor.selection.size>0||e.editor.selectedLinks.size>0;var KM={id:"select-all",label:"Select all",category:"selection",viewMode:!0,hotkey:{key:"a",meta:!0},perform:({editor:e})=>{e.selectAll()}},$M={id:"delete-selection",label:"Delete",category:"selection",hotkey:[{key:"Delete"},{key:"Backspace"}],predicate:iS,perform:({editor:e})=>{e.deleteSelected()}},QM={id:"duplicate-selection",label:"Duplicate",category:"selection",hotkey:{key:"d",meta:!0},predicate:yt,perform:({editor:e})=>{e.duplicateSelected()}},JM={id:"toggle-lock",label:"Lock / Unlock",category:"selection",hotkey:{key:"l",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.toggleLockSelection()}},e9={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()}},t9={id:"exit-container",label:"Exit container",category:"selection",hotkey:{key:"ArrowUp",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.exitContainer()}},lS=[KM,$M,QM,JM,e9,t9];var n9={id:"copy",label:"Copy",category:"clipboard",viewMode:!0,hotkey:{key:"c",meta:!0},predicate:yt,perform:({editor:e})=>{e.copySelected()}},o9={id:"cut",label:"Cut",category:"clipboard",hotkey:{key:"x",meta:!0},predicate:yt,perform:({editor:e})=>{e.cutSelected()}},a9={id:"paste",label:"Paste",category:"clipboard",hotkey:{key:"v",meta:!0},perform:({editor:e})=>{e.paste()}},r9={id:"copy-style",label:"Copy style",category:"clipboard",viewMode:!0,hotkey:{key:"c",meta:!0,alt:!0},predicate:yt,perform:({editor:e})=>{e.copySelectionStyle()}},s9={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()}},cS=[n9,o9,a9,r9,s9];var i9={id:"bring-to-front",label:"Bring to front",category:"z-order",hotkey:{key:"]",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.bringToFront()}},l9={id:"send-to-back",label:"Send to back",category:"z-order",hotkey:{key:"[",meta:!0,shift:!0},predicate:yt,perform:({editor:e})=>{e.sendToBack()}},c9={id:"bring-forward",label:"Bring forward",category:"z-order",hotkey:{key:"]",meta:!0},predicate:yt,perform:({editor:e})=>{e.bringForward()}},u9={id:"send-backward",label:"Send backward",category:"z-order",hotkey:{key:"[",meta:!0},predicate:yt,perform:({editor:e})=>{e.sendBackward()}},uS=[i9,c9,u9,l9];var d9={id:"group-selection",label:"Group",category:"grouping",hotkey:{key:"g",meta:!0},predicate:e=>e.editor.selection.size>=2,perform:({editor:e})=>{e.groupSelected()}},f9={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()}},dS=[d9,f9];var p9={id:"zoom-in",label:"Zoom in",category:"zoom",viewMode:!0,hotkey:[{key:"=",meta:!0},{key:"+",meta:!0},{key:"+"},{key:"="}],perform:({editor:e})=>{e.zoomIn()}},h9={id:"zoom-out",label:"Zoom out",category:"zoom",viewMode:!0,hotkey:[{key:"-",meta:!0},{key:"_",meta:!0},{key:"-"},{key:"_"}],perform:({editor:e})=>{e.zoomOut()}},m9={id:"zoom-reset",label:"Reset zoom",category:"zoom",viewMode:!0,hotkey:{key:"0",meta:!0},perform:({editor:e})=>{e.resetZoom()}},y9={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()}},g9={id:"zoom-to-selection",label:"Zoom to selection",category:"zoom",viewMode:!0,hotkey:{key:"2",alt:!0},predicate:yt,perform:({editor:e})=>{e.zoomToSelection()}},fS=[p9,h9,m9,y9,g9];var x9={id:"mode-select",label:"Select tool",category:"tool",viewMode:!0,hotkey:{key:"v"},iconId:"mode-select",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="select",perform:({editor:e})=>{e.setActiveTool("select")}},b9={id:"mode-hand",label:"Hand tool",category:"tool",viewMode:!0,hotkey:{key:"h"},iconId:"mode-hand",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="hand",perform:({editor:e})=>{e.setActiveTool("hand")}},A9={id:"mode-rect",label:"Rectangle tool",category:"tool",hotkey:{key:"r"},iconId:"mode-rect",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-rect",perform:({editor:e})=>{e.setActiveTool("draw-rect")}},v9={id:"mode-ellipse",label:"Ellipse tool",category:"tool",hotkey:{key:"o"},iconId:"mode-ellipse",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-ellipse",perform:({editor:e})=>{e.setActiveTool("draw-ellipse")}},S9={id:"mode-text",label:"Text tool",category:"tool",hotkey:{key:"t"},iconId:"mode-text",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-text",perform:({editor:e})=>{e.setActiveTool("draw-text")}},L9={id:"mode-edge",label:"Link tool",category:"tool",hotkey:{key:"l"},iconId:"mode-edge",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-edge",perform:({editor:e})=>{e.setActiveTool("draw-edge")}},k9={id:"mode-brush",label:"Brush tool",category:"tool",hotkey:{key:"b"},iconId:"mode-brush",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="brush",perform:({editor:e})=>{e.setActiveTool("brush")}},_9={id:"mode-erase",label:"Eraser tool",category:"tool",hotkey:{key:"e"},iconId:"mode-erase",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="erase",perform:({editor:e})=>{e.setActiveTool("erase")}},w9={id:"mode-laser",label:"Laser pointer",category:"tool",viewMode:!0,hotkey:{key:"k"},iconId:"mode-laser",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="laser",perform:({editor:e})=>{e.setActiveTool("laser")}},T9={id:"mode-frame",label:"Frame tool",category:"tool",hotkey:{key:"f"},iconId:"mode-frame",uiKind:"toggle",checked:({editor:e})=>e.activeTool.type==="draw-frame",perform:({editor:e})=>{e.setActiveTool("draw-frame")}},E9={id:"toggle-tool-lock",label:"Toggle tool lock",category:"tool",iconId:"tool-lock",uiKind:"toggle",checked:({editor:e})=>e.activeTool.locked,perform:({editor:e})=>{e.setToolLocked(!e.activeTool.locked)}},KW={id:"commit-image-crop",label:"Apply crop",category:"edit",hotkey:{key:"Enter"},predicate:({editor:e})=>e.activeTool.type==="crop",perform:({editor:e})=>{e.commitImageCrop()}},$W={id:"cancel-image-crop",label:"Cancel crop",category:"edit",viewMode:!0,hotkey:{key:"Escape"},predicate:({editor:e})=>e.activeTool.type==="crop",perform:({editor:e})=>{e.cancelImageCrop()}},C9={id:"cancel",label:"Cancel / clear selection",category:"edit",viewMode:!0,hotkey:{key:"Escape"},perform:({editor:e})=>{e.cancelInteraction()}},pS=[x9,b9,A9,v9,S9,L9,k9,_9,w9,T9,E9,KW,$W,C9];var QW={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?J4:Q4;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}}},JW={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}}},eq={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}}},tq={id:"focus-next",label:"Focus next element",category:"selection",hotkey:{key:"Tab"},perform:({editor:e})=>{e.focusCycle("next")}},nq={id:"focus-prev",label:"Focus previous element",category:"selection",hotkey:{key:"Tab",shift:!0},perform:({editor:e})=>{e.focusCycle("prev")}},oq={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.activeTool.type==="draw-rect"||e.activeTool.type==="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.activeTool.type==="draw-rect"||e.activeTool.type==="draw-ellipse")&&e.createElementAtCursor()}},I9=[QW,JW,eq,tq,nq,oq];var aq={id:"arrange-grid",label:"Arrange as grid",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsGrid()}},rq={id:"arrange-stack-h",label:"Stack horizontally",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"horizontal"})}},sq={id:"arrange-stack-v",label:"Stack vertically",category:"layout",predicate:({editor:e})=>e.selection.size>1,perform:({editor:e})=>{e.arrangeAsStack({direction:"vertical"})}},iq={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?Dn(n)!==null:!1},perform:({editor:e})=>{let[t]=[...e.selection];t&&e.runLayout(t)}},lq={id:"compact-z-order",label:"Compact z-order",category:"z-order",perform:({editor:e})=>{e.compactLayerZOrder()}},M9=[aq,rq,sq,iq,lq];var R9={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()}},O9={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()}},hS=[R9,O9];var Wc=e=>e.editor.selection.size>=2,D9=e=>e.editor.selection.size>=3,P9={id:"flip-horizontal",label:"Flip horizontal",category:"arrange",hotkey:{key:"h",shift:!0},iconId:"flip-horizontal",predicate:yt,perform:({editor:e})=>{e.flipSelection("horizontal")}},B9={id:"flip-vertical",label:"Flip vertical",category:"arrange",hotkey:{key:"v",shift:!0},iconId:"flip-vertical",predicate:yt,perform:({editor:e})=>{e.flipSelection("vertical")}},N9={id:"align-left",label:"Align left",category:"arrange",hotkey:{key:"ArrowLeft",meta:!0,shift:!0},iconId:"align-left",predicate:Wc,perform:({editor:e})=>{e.alignSelection("left")}},z9={id:"align-h-center",label:"Align horizontal centres",category:"arrange",iconId:"align-h-center",predicate:Wc,perform:({editor:e})=>{e.alignSelection("h-center")}},F9={id:"align-right",label:"Align right",category:"arrange",hotkey:{key:"ArrowRight",meta:!0,shift:!0},iconId:"align-right",predicate:Wc,perform:({editor:e})=>{e.alignSelection("right")}},H9={id:"align-top",label:"Align top",category:"arrange",hotkey:{key:"ArrowUp",meta:!0,shift:!0},iconId:"align-top",predicate:Wc,perform:({editor:e})=>{e.alignSelection("top")}},U9={id:"align-v-center",label:"Align vertical centres",category:"arrange",iconId:"align-v-center",predicate:Wc,perform:({editor:e})=>{e.alignSelection("v-center")}},G9={id:"align-bottom",label:"Align bottom",category:"arrange",hotkey:{key:"ArrowDown",meta:!0,shift:!0},iconId:"align-bottom",predicate:Wc,perform:({editor:e})=>{e.alignSelection("bottom")}},W9={id:"distribute-horizontal",label:"Distribute horizontally",category:"arrange",hotkey:{key:"h",alt:!0},iconId:"distribute-horizontal",predicate:D9,perform:({editor:e})=>{e.distributeSelection("horizontal")}},q9={id:"distribute-vertical",label:"Distribute vertically",category:"arrange",hotkey:{key:"v",alt:!0},iconId:"distribute-vertical",predicate:D9,perform:({editor:e})=>{e.distributeSelection("vertical")}},mS=[P9,B9,N9,z9,F9,H9,U9,G9,W9,q9];var V9=e=>{let{editor:t}=e;for(let n of t.selection){let o=I(t.scene,n);if(o!==void 0&&pe(o))return!0}return!1},j9={id:"increase-font-size",label:"Increase font size",category:"edit",hotkey:{code:"Period",meta:!0,shift:!0},predicate:V9,perform:({editor:e})=>{e.adjustSelectionFontSize("increase")}},Z9={id:"decrease-font-size",label:"Decrease font size",category:"edit",hotkey:{code:"Comma",meta:!0,shift:!0},predicate:V9,perform:({editor:e})=>{e.adjustSelectionFontSize("decrease")}},yS=[j9,Z9];var Gp=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||gS(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||gS(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(cq(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<=$4),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||gS(s,n))continue;let i=s.sequence,l=this.seqBuffer.slice(-i.length);if(l.length===i.length&&l.every((c,u)=>X9(c.key,c.code,i[u]??""))&&!(s.predicate&&!s.predicate(n)))return this.seqBuffer=[],s.perform(n),!0}return!1}},gS=(e,t)=>t.editor.readOnly&&e.viewMode!==!0,cq=(e,t)=>{if(t.key!==void 0&&!uq(e,t.key)||t.code!==void 0&&e.code!==t.code)return!1;let n=a=>a===!0,o=ls?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)},uq=(e,t)=>X9(e.key,e.code,t),X9=(e,t,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;if(dq(e))return!1;let o=fq(n);return o!==null&&t===o},dq=e=>/^[a-z]$/i.test(e),fq=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}},xS=e=>{let t=[...sS,...lS,...cS,...uS,...dS,...fS,...pS,...I9,...M9,...hS,...mS,...yS];for(let n of t)e.register(n)},we=new Gp;xS(we);var qy=(e,t={})=>{let n=t.target??window,o=t.registry??we,a=r=>{if(!(r instanceof KeyboardEvent))return;let s=r.composedPath()[0]??r.target;if(oa(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 Y9=e=>{if(pe(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},bS=(e,t)=>{let n=t.trim().toLowerCase();if(n==="")return[];let o=[];for(let a of e.elements.values()){let r=Y9(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 pq=new Map;var K9=e=>pq.get(e);var AS=()=>{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 vS=()=>{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 $9=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;hq(m)||f.push(m)}return f},hq=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 Wp=class{past=[];future=[];limit;mergeTransactions;constructor(t={}){this.limit=t.limit??1/0,this.mergeTransactions=t.mergeTransactions??!0}push(t){Jr(t)||(this.past.push(t),this.future.length=0,this.trim())}undo(){let t=this.past.pop();return t?(this.future.push(t),Lc(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");Jr(n)||t.push(n)},commit:()=>{if(this.current!==t||(this.current=null,t.length===0))return;let n=this.mergeTransactions?$9(t):t;if(n.length===0)return;let o=n[0],a=n.length===1&&o!==void 0?o:Yo(n);Jr(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 qp=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}},Q9=["image/png","image/jpeg","image/svg+xml","image/gif","image/webp","image/bmp","image/x-icon","image/avif","image/jfif"];var SS=e=>{if(e.type.startsWith("video/"))return!0;let t=e.name.toLowerCase().split(".").pop();return t==="mp4"||t==="webm"||t==="ogv"||t==="mov"},LS=e=>{if(e.type&&Q9.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 kS=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 mq=e=>e===".git"||e==="node_modules"||e==="__MACOSX"||e===".DS_Store"||e.startsWith("."),_S=async function*(e,t={}){let n=t.skipDirectory??mq,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*J9(i,"",0,n,o,t.onError))}};async function*J9(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*J9(c,s,n+1,o,a,r)}}var yq=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}),tR={id:"image",accept:e=>LS(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 kS(e),s=await yq(r),i=Jv,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=nR();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}:{}})}},eR="oh-just-another-animated-image-sink",nR=()=>{let e=document.getElementById(eR);if(e)return e;let t=document.createElement("div");return t.id=eR,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},wS=e=>{let t=document.createElement("video");return t.src=e,t.muted=!0,t.loop=!0,t.playsInline=!0,t.autoplay=!0,t.style.position="absolute",t.style.left="-99999px",t.style.top="-99999px",t.style.width="1px",t.style.height="1px",nR().appendChild(t),t},oR={id:"video",accept:e=>SS(e),handle:async(e,{editor:t,worldPoint:n})=>{if(typeof document>"u")return;let o=await t.addBinaryFile(e,e.name),a=URL.createObjectURL(e),r=wS(a);await new Promise(p=>{let h=()=>{p()};r.onloadedmetadata=h,r.onerror=h});let s=r.videoWidth||U4,i=r.videoHeight||G4,l=Jv,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};r.play().catch(()=>{}),t.insertImage({src:a,width:u,height:d,position:f,image:r,animated:!0,fileId:o})}};var Vy=64,aR=(e,t)=>{let n=null,o=t,a=0;for(;o.parentId&&a<Vy;){let r=I(e,o.parentId);if(!r)break;ze(r)&&(n=r),o=r,a++}return n},TS=(e,t,n)=>{let o=I(e,t),a=0;for(;o&&a<Vy;){if(o.id===n)return!0;if(!o.parentId)return!1;o=I(e,o.parentId),a++}return!1},rR=(e,t,n)=>{let o=t,a=0;for(;o.parentId&&a<Vy&&n!==o.parentId;){let r=I(e,o.parentId);if(!r||!ze(r))break;o=r,a++}return o},sR=(e,t,n)=>{let o=new Set,a=new Set(t);for(let r of e.elements.values())a.has(r.id)||TS(e,r.id,n)||o.add(r.id);return o},iR=(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<Vy;){let i=I(e,a.parentId);if(!i||i.id===n.id)break;ze(i)&&(r=i),a=i,s++}return r};var gq=/^Frame (\d+)$/,lR=e=>{let t=0;for(let n of e.elements.values()){if(!Be(n))continue;let o=gq.exec(n.name??"");o&&(t=Math.max(t,Number(o[1])))}return`Frame ${t+1}`},cR=(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=N(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=$(l,c.id,h=>({...h,frameId:n}));l=p.scene,t.push(p.patch)}return l},uR=(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:N(a)})),o=e;for(let a of e.elements.values()){if(Be(a))continue;let r=N(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=$(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 jy=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>Xv&&n.add(o.layerId);for(let o of t.links.values())o.order.length>Xv&&n.add(o.layerId);for(let o of n)this.compact(o)}};var Zy=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(!Dn(o))continue;let a=this.signatureFor(o.id);if(this.signatures.get(o.id)===a)continue;this.signatures.set(o.id,a);let r=pp(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&&Dn(o)?.kind==="wrap"){let s=no(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=N(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 dR=()=>({activeTool:null,selection:null,scene:null,viewport:null,canUndo:!1,canRedo:!1}),fR=(e,t,n)=>{n.activeTool!==e.activeTool&&(e.activeTool=n.activeTool,t.emit("tool",n.activeTool)),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")},pR=(e,t)=>{e.activeTool=t.activeTool,e.selection=t.selection,e.scene=t.scene,e.viewport=t.scene.viewport,e.canUndo=t.canUndo,e.canRedo=t.canRedo};var Xy=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 Yy=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 Xy({isAnimated:()=>this.host.hasVisibleAnimatedElement(),onTick:()=>{this.onTick()}})}onTick(){let t=typeof performance<"u"?performance.now():Date.now(),n=Math.min(q4,Math.max(W4,this.costEma*V4));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 Ky=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 Vp(){return typeof performance<"u"?performance.now():Date.now()}function xq(){if(typeof matchMedia!="function")return!1;try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var $y=class{state=new Map;hoveredId=null;ensure(t){if(this.state.has(t))return;let n=Vp();this.state.set(t,{playing:!xq(),originMs:n,playStartMs:n,frozenMs:0})}clock(t){let n=this.state.get(t),o=Vp();return n?n.playing?o-n.originMs:n.frozenMs:o}toggle(t){let n=Vp(),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=Vp();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=Vp();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>Z4&&(a.frozenMs=n-a.originMs,a.playing=!1)}}}};var hR=(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}:{}}},mR=async(e,t,n,o)=>{let a=await t.arrayBuffer(),r=kA(`file-${o()}-${Date.now().toString(36)}`),s=bv(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}},Qy=e=>{for(let t of e.elements.values())if(t.metadata?.animated===!0)return!0;return!1};var gR=e=>{if(!Qy(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&&j.intersects(N(n),t))return!0;return!1},xR=e=>{let t=[];for(let n of e._scene.elements.values()){if(!ct(n)||!n.animationKind)continue;n.animationData instanceof ArrayBuffer&&n.animationData.byteLength>j4&&t.push(n.id)}e.gifPlayback.autoStopHeavy(t)},ES=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=Q0(e._scene,t.fileId);n&&(e._scene=J(e._scene,{kind:"element",id:t.id,before:t,after:{...t,animationData:n.data}}))}},bq=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],yR=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of bq){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},Aq=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},vq=async(e,t)=>{if(typeof document>"u"||typeof URL>"u"||typeof URL.createObjectURL!="function")return null;let n=URL.createObjectURL(new Blob([e],{type:t})),o=wS(n);return await new Promise(r=>{o.onloadedmetadata=()=>{r(!0)},o.onerror=()=>{r(!1)}})?(o.play().catch(()=>{}),o):(URL.revokeObjectURL(n),o.remove(),null)},CS=async e=>{let t=[];for(let o of e._scene.elements.values()){if(!ct(o)||o.animationKind||yR(o.metadata?.image)||!o.fileId)continue;let a=Q0(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=o.mime.startsWith("video/")?await vq(o.data,o.mime):await Aq(o.data,o.mime);if(!a)continue;let r=e._scene.elements.get(o.id);!r||!ct(r)||yR(r.metadata?.image)||(e._scene=J(e._scene,{kind:"element",id:r.id,before:r,after:{...r,metadata:{...r.metadata,image:a}}}),n=!0)}n&&e.forceRender()};var bR={x:-1e9,y:-1e9,width:0,height:0},Lq=4,AR=(e,t)=>{let n=new Map;if(e===t)return{world:bR,tileDirty:n};let o=null,a=u=>{o=o?j.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=lp(d),h=f?lp(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=lp(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=ss(t,d);p&&a(p);let m=ss(e,f??d);m&&a(m)}for(let[u,d]of e.links)if(!t.links.has(u)){let f=ss(e,d);f&&a(f)}if(o===null)return{world:bR,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=N(u);if(!j.intersects(d,l))continue;i.add(u.id);let f=j.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:j.expand(l,Lq),tileDirty:n}};var Jy=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})},i4)}cancel(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.origin=null}cancelIfMovedBeyond(t,n){this.origin&&W.distance(this.origin,t)>n&&this.cancel()}};var eg=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=W.midpoint(n,o);this.origin={midpointScreen:a,midpointWorld:this.screenToWorld(a),distance:W.distance(n,o)}}apply(t){if(!this.origin||t.length<2)return;let[n,o]=t,a=W.distance(n,o),r=W.midpoint(n,o);if(W.distance(r,this.origin.midpointScreen)+Math.abs(a-this.origin.distance)<s4)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 kq=(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},_q=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=N(o);n=n?j.union(n,a):a}return n},vR=(e,t,n,o)=>{if(!Xf(t)||!Ri(t))return n;if(Dn(t)?.kind==="wrap")return wq(e,t,n,o);let a=_q(e,t.id);if(!a)return n;let r={...t,position:{x:n.x,y:n.y},width:n.width,height:n.height},s=no(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}},wq=(e,t,n,o)=>{let a=mi(t)?.padding??0,r=Math.max(0,n.width-2*a),s=ny(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:ny(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}},SR=(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=$(e.scene,n,i=>({...i,parentId:a.id,order:r}));e.applyPatch(s.patch,s.scene),jp(e,a.id,n);return}if(a&&a.id===o.parentId){jp(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?no(r):null,i=N(o),l=s?kq(i,s):0;if(s&&l>=v4){jp(e,o.parentId,n);return}let c=$(e.scene,n,u=>{let d={...u};return delete d.parentId,d});e.applyPatch(c.patch,c.scene)}},jp=(e,t,n)=>{let o=I(e.scene,t),a=I(e.scene,n);if(!o||!a)return;let r=mi(o);if(!r)return;let s=N(a),i=ZA(o,s);if(!i)return;if(Ri(o)){let c=XA({width:o.width,height:o.height,spec:r},i),u=$(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=$(e.scene,t,c=>({...c,metadata:{...c.metadata??{},container:{...r,dropZone:i}}}));e.applyPatch(l.patch,l.scene)};var Zp=(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}},MS=(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}},LR=e=>e==="nw"||e==="w"||e==="sw",kR=e=>e==="ne"||e==="e"||e==="se",_R=e=>e==="nw"||e==="n"||e==="ne",wR=e=>e==="sw"||e==="s"||e==="se",RS=(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;LR(n)&&!kR(n)?f=e.x+e.width-u:kR(n)&&!LR(n)&&(f=e.x);let p=t.y;_R(n)&&!wR(n)?p=e.y+e.height-d:wR(n)&&!_R(n)&&(p=e.y);let h={x:f,y:p,width:u,height:d};return o.noFlip?h:j.normalize(h)};var TR=(e,t)=>e.kind!=="point"&&t.has(e.elementId),Tq=(e,t)=>TR(e.from,t)&&TR(e.to,t),IR=e=>(e.waypoints?.length??0)>0||(e.fixedSegments?.length??0)>0||(e.routedPoints?.length??0)>0,ER=(e,t)=>e.map(n=>({x:n.x+t.x,y:n.y+t.y})),Eq=(e,t)=>{if(!IR(e))return null;let n={};return e.waypoints?.length&&(n.waypoints=ER(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=ER(e.routedPoints,t)),n},CR=(e,t)=>e.kind==="point"?{kind:"point",position:{x:e.position.x+t.x,y:e.position.y+t.y}}:e,OS=(e,t)=>{let n=Eq(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=CR(e.from,t)),a&&(r.to=CR(e.to,t)),r},MR=(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(!IR(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},RR=(e,t,n)=>n.has(e.id)||Tq(e,t),DS=(e,t,n)=>{let o=new Map;for(let a of e.links.values())RR(a,t,n)&&OS(a,{x:0,y:0})!==null&&o.set(a.id,a);return o},OR=(e,t,n)=>{let o=[];for(let[a,r]of t){let s=ue(e,a);if(!s)continue;let i=OS(r,n);i&&o.push({kind:"link",id:a,before:s,after:{...s,...i}})}return o},DR=(e,t,n,o)=>{let a=e,r=[];for(let s of[...e.links.values()]){if(!RR(s,t,n))continue;let i=OS(s,o);if(!i)continue;let l=Ye(a,s.id,c=>({...c,...i}));a=l.scene,r.push(l.patch)}return{scene:a,patches:r}};var PR=(e,t,n,o,a,r,s=!1,i=!1)=>{let l=I(e,t);if(!l||!Ri(l))return null;let c=Zp(a,n,o),u=s?MS(a,c):c,d=i?IS(a,u):u,p=l.noFlip===!0||Dn(l)!==null?{...l,noFlip:!0}:l,h=RS(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:J(e,y),patch:y}},BR=(e,t,n,o,a=!1,r=!1)=>{let s=I(e,t.id);if(!s||!Ri(t))return null;let i=Li(t),[l]=vp(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=Zp(h,n,p),x=a?MS(h,m):m,y=r?IS(h,x):x,b=t.noFlip===!0||Dn(t)!==null?{...t,noFlip:!0}:t,A=RS(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},C={...t,position:_,scale:{x:1,y:1},width:A.width,height:A.height},w={kind:"element",id:t.id,before:s,after:C};return{scene:J(e,w),patch:w}},NR=(e,t,n,o,a,r=!1)=>{let s=I(e,t.id);if(!s)return null;let i=Zp(a,n,o),l=a.x+a.width/2,c=a.y+a.height/2;if(n==="e"||n==="w"){let L=Math.max(t.fontSize,Math.abs(i.width)),k=n==="w"?a.x+a.width:a.x,M=r?l-L/2:n==="w"?k-L:k,B={...t,position:{x:M,y:a.y},scale:{x:1,y:1},maxWidth:L},G={kind:"element",id:t.id,before:s,after:B};return{scene:J(e,G),patch:G}}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(my,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,C={...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:C};return{scene:J(e,w),patch:w}},zR=(e,t,n,o,a,r,s=!1)=>{let i=Zp(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(Ri(g)){let k=g.type==="image",M=k?d:c,B=k?d:u,G=y.bounds.width*M,ie=y.bounds.height*B;if(Math.abs(G)<l||Math.abs(ie)<l)continue;let ne={...g,position:{x:b,y:A},scale:{x:G>=0?1:-1,y:ie>=0?1:-1},width:Math.abs(G),height:Math.abs(ie)},V={kind:"element",id:x,before:g,after:ne};h=J(h,V),m.push(V);continue}let _=y.scale.x*c,C=y.scale.y*u;if(Math.abs(_)<l/Math.max(1,y.bounds.width)||Math.abs(C)<l/Math.max(1,y.bounds.height))continue;let w={...g,position:{x:b,y:A},scale:{x:_,y:C}},L={kind:"element",id:x,before:g,after:w};h=J(h,L),m.push(L)}for(let[x,y]of t.links??[]){let g=ue(h,x);if(!g)continue;let b=MR(y,f,p,c,u);if(!b)continue;let A={kind:"link",id:x,before:g,after:{...g,...b}};h=J(h,A),m.push(A)}return{scene:h,patches:m}};var gt=Object.freeze(new Set),tg=e=>new Set([e]),PS=(e,t)=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n},Cq=(e,t)=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n},FR=(e,t)=>e.has(t)?Cq(e,t):PS(e,t),Xp=(e,t)=>B0(e,t),HR=e=>{if(e.size!==1)return null;for(let t of e)return t;return null};var Yp=e=>Math.min(r4,Math.max(a4,e)),UR=(e,t)=>t.x===0&&t.y===0?null:{...e,viewport:dv(e.viewport,t)},GR=(e,t,n)=>{let o=e.viewport.zoom,r=Yp(o*t)/o;return r===1?null:{...e,viewport:K0(e.viewport,r,n)}},WR=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:K0(t,1/t.zoom,n)}},NS=(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=Yp(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}}},qR=(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=Yp(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}}},VR=(e,t)=>{if(e.elements.size===0)return null;let n=null;for(let o of e.elements.values()){let a=N(o);n=n?j.union(n,a):a}return n?NS(e,n,t):null},jR=(e,t,n)=>{let o=e.viewport;return o.size.width===t&&o.size.height===n?null:{...e,viewport:fv(o,t,n)}},ZR=(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 Iq=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.activeTool.type==="select"&&n))return!1;let o=ue(e._scene,n);if(!o?.label)return!1;let a=bc(e._scene,o);if(!(a!==null&&t.x>=a.x&&t.x<=a.x+a.width&&t.y>=a.y&&t.y<=a.y+a.height))return!1;e.cancelLongPress();let s=performance.now(),i=e.interaction.lastClickWorldPoint,l=s-e.interaction.lastClickAt<wc&&i!==null&&Math.hypot(i.x-t.x,i.y-t.y)<=Tc;return e.interaction.lastClickAt=s,e.interaction.lastClickWorldPoint=t,l?(e.beginLinkCaptionEdit(n),!0):(e.beginLabelDrag(n),!0)},Mq=(e,t)=>e.isDraggingLabel?(e.updateLabelDrag(t),!0):!1,Rq=e=>e.isDraggingLabel?(e.endLabelDrag(),!0):!1,XR=(e,t,n)=>{let o=e.x-t.x,a=e.y-t.y;return o*o+a*a<=n},Oq=(e,t,n)=>{let o=t.button===2||t.button===1,a=t.button===0&&e.spaceHeld,r=t.button===0&&e.activeTool.type==="hand";return o||a||r?(o&&(e.suppressNextContextMenu=!0),e.beginPanGesture(t.pointerId,t.button,n.point),!0):!1},Dq=(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),Pq=(e,t)=>e.readOnly||e.editingTextElement===null?!1:e.editedElementContainsPoint(t)?(e.cancelLongPress(),e.setTextCaretFromPoint(t),!0):(e.commitTextEdit(),!1),Bq=(e,t)=>e.activeTool.type!=="crop"||e.cropSession?.drag==null?!1:(e.updateImageCropDrag(t),!0),Nq=e=>e.activeTool.type!=="crop"||e.cropSession?.drag==null?!1:(e.endImageCropDrag(),!0),zq=(e,t,n,o)=>e.readOnly||e.activeTool.type!=="brush"?!1:(e.beginBrushStroke(t,n,o),!0),Fq=(e,t,n,o)=>e.readOnly||e.activeTool.type!=="erase"?!1:(e.cancelLongPress(),e.beginEraseStroke(t,n,o),!0),Hq=(e,t)=>e.activeTool.type!=="laser"?!1:(e.cancelLongPress(),e.beginLaserStroke(t),!0),Uq=(e,t)=>e.isEyedropperArmed?(e.cancelLongPress(),e.applyEyedropperAt(t),!0):!1,Gq=(e,t)=>{if(e.activeTool.type!=="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)},Wq=(e,t,n)=>{if(e.readOnly||e.activeTool.type!=="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)},qq=(e,t)=>{if(e.readOnly||e.activeTool.type!=="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&&pe(o)?(e._selection=wt(o.id),e.beginTextEdit(o.id),e.notify()):e.createTextAt(t),!0},Vq=(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},jq=(e,t)=>{let n=e.acceleratedElementAt(t);if(!n)return!1;let o=K9(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},Zq=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.activeTool.type==="select"&&n))return!1;let o=ue(e._scene,n);if(!(o&&(o.routing??"straight")==="orthogonal"))return!1;let a=ut(e._scene,o);if(!(a&&a.length>=2))return!1;let r=e._scene.viewport.zoom||1,s=Ko/r,i=s*s;for(let{k:l,point:c}of sp(e._scene,o,a)){let u=v(a[l]),d=v(a[l+1]),f=c.x-t.x,p=c.y-t.y;if(f*f+p*p<=i){let h=Math.abs(u.y-d.y)<1e-6?"h":"v",m=h==="h"?(u.x+d.x)/2:(u.y+d.y)/2,x=h==="h"?u.y:u.x;return e.isHandleDoubleClick(t)?e.resetSegmentPin(n,h,x,m):e.beginSegmentDrag(n,h,m),e.cancelLongPress(),!0}}return!1},Xq=(e,t)=>{if(e.readOnly)return!1;let n=e.selectedLink;if(!(e.activeTool.type==="select"&&n))return!1;let o=ue(e._scene,n),a=o&&(o.routing??"straight")!=="orthogonal"?ut(e._scene,o):null;if(!(o&&a&&a.length>=2))return!1;let r=e._scene.viewport.zoom||1,s=Ko/r,i=s*s,l=[...o.waypoints??[]],c=!1;for(let u=0;u<l.length;u++)if(XR(v(l[u]),t,i)){e.isHandleDoubleClick(t)?e.deleteWaypoint(n,u):e.beginWaypointDrag(n,u,!1),c=!0;break}if(!c){let u=rp(e._scene,o)??[];for(let d=0;d<u.length;d++)if(XR(v(u[d]),t,i)){e.beginWaypointDrag(n,d,!0),c=!0;break}}return c?(e.cancelLongPress(),!0):!1},Yq=(e,t,n)=>{let o=I(e._scene,t);if(!o)return!1;let a=e._scene.viewport.zoom||1,{names:r,worldPoints:s}=Co(o,wo/a),i=($o+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)},Kq=(e,t,n,o)=>{if(e.readOnly||!(e.activeTool.type==="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&&Yq(e,a,n))},$q=(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=gt),e.notify()}},Qq=(e,t,n)=>{if(e.readOnly)return n;if(t.modifiers.alt&&e.activeTool.type==="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},KR=(e,t,n)=>{if(!n.has(t)){n.add(t);for(let o of e._scene.elements.values())o.parentId===t&&KR(e,o.id,n)}},Jq=(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&&KR(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},eV=(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:N(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},tV=(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},nV=(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&&W.distance(o.startPoint,n.point)>_c&&(o.moved=!0),e.panBy({x:a,y:r}),!0},oV=(e,t,n)=>(e.activePointers.has(t.pointerId)&&e.activePointers.set(t.pointerId,n.point),e.pinch.isActive()?(e.applyPinch(),!0):!1),aV=(e,t,n)=>{if(e.touchPanCandidate!==null&&e.activePointers.size===1&&W.distance(e.touchPanCandidate,n.point)>_c){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},rV=(e,t)=>e.isDraggingSegment?(e.updateSegmentDrag(t),!0):!1,sV=(e,t)=>e.isDraggingWaypoint?(e.updateWaypointDrag(t),!0):!1,iV=(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<Ci*Ci)return!0;n.moved=!0}return e.applyLinkPreview(n.fromElement,n.fromWorld,t),e.updateHoveredLinkTarget(t),!0},lV=(e,t)=>e.editingTextElement!==null&&e.isTextDragging?(e.extendTextSelectionToPoint(t),!0):!1,cV=(e,t,n)=>e.brushStroke?(e.extendBrushStroke(t,n),!0):!1,uV=(e,t,n)=>e.eraseStroke?(e.extendEraseStroke(t,n),!0):!1,dV=(e,t)=>e.laserDrawing?(e.extendLaserStroke(t),!0):!1,fV=(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=Yf(e._scene,t,o);if(a){let r=no(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())},pV=(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},hV=(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=Mp(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.activeTool.type==="select"?t:null),e.activeTool.type==="erase"&&e.notify()}e.actor.send({type:"POINTER_MOVE",point:t})},mV=(e,t)=>e.panGesture?.pointerId!==t.pointerId?!1:(e.endPanGesture(),!0),yV=e=>e.pinch.isActive()?(e.activePointers.size<2&&e.pinch.end(),!0):!1,gV=e=>e.isDraggingSegment?(e.endSegmentDrag(),!0):!1,xV=e=>e.isDraggingWaypoint?(e.endWaypointDrag(),!0):!1,bV=(e,t)=>{let n=e.linkDragFromAnchor;if(!n)return!1;e.linkDragFromAnchor=null;let o=Gc(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}=Co(r,wo/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},AV=e=>e.editingTextElement!==null&&e.isTextDragging?(e.endTextDragSelect(),!0):!1,vV=e=>e.brushStroke?(e.commitBrushStroke(),!0):!1,SV=e=>e.eraseStroke?(e.commitEraseStroke(),!0):!1,LV=e=>e.laserDrawing?(e.endLaserStroke(),!0):!1,kV=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=ja(e._scene,t.id,()=>n);e._scene=r.scene,e._history.push(r.patch),e.notify()}}return!0},_V=(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<_c){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},wV=(e,t)=>{let n=e.actor.getSnapshot().context,o=rM(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<_c){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)},YR=(e,t,n)=>{if(t.deltaY===0)return;let a=1-(Math.abs(t.deltaY)>Vv?Vv*Math.sign(t.deltaY):t.deltaY)*o4/100;if(a<=0)return;let r=e._scene.viewport.zoom,s=Yp(r*a);if(s===r)return;let i=e.screenToWorld(n);e.zoomAt(s/r,i)},TV=(e,t)=>{let n=t.deltaX,o=t.deltaY;t.shiftKey&&n===0&&(n=o,o=0),e.panBy({x:-n*Wv,y:-o*Wv})},$R=e=>{let t=c=>{c.preventDefault(),e.host.setPointerCapture(c.pointerId),typeof e.host.focus=="function"&&!oa(c.target)&&e.host.focus({preventScroll:!0});let u=Gc(c,e.host);if(e.additivePressAdded=null,Oq(e,c,u)||Dq(e,c,u))return;e.startLongPress(u.point);let d=e.screenToWorld(u.point);if(Uq(e,d)||Pq(e,d)||Gq(e,d)||Wq(e,d,c.detail)||zq(e,d,c.pressure,c.pointerType)||Fq(e,d,u.modifiers.alt,u.modifiers.shift)||Hq(e,d)||qq(e,d)||Vq(e,d)||jq(e,d)||Zq(e,d)||Xq(e,d)||Iq(e,d))return;let f=e.hitTest(d);Kq(e,u,d,f)||($q(e,u,f),f=Qq(e,u,f),e.dragElementId=f.kind==="element"?f.id:null,e.containerHover=null,Jq(e,f),eV(e,f),tV(e,f),e.touchPanCandidate=u.kind==="touch"&&e.activeTool.type==="select"&&f.kind==="empty"?u.point:null,e.actor.send({type:"POINTER_DOWN",point:d,target:f,modifiers:u.modifiers}))},n=c=>{let u=Gc(c,e.host);if(nV(e,c,u)||oV(e,c,u)||aV(e,c,u))return;e.longPress.cancelIfMovedBeyond(u.point,_c);let d=e.screenToWorld(u.point);e.lastPointerWorld=d,e.refreshCursor(d),!Bq(e,d)&&(Mq(e,d)||rV(e,d)||sV(e,d)||iV(e,d)||lV(e,d)||cV(e,d,c.pressure)||uV(e,d,u.modifiers.alt)||dV(e,d)||(fV(e,d),!pV(e,d)&&hV(e,d)))},o=c=>{if(e.host.hasPointerCapture(c.pointerId)&&e.host.releasePointerCapture(c.pointerId),e.activePointers.delete(c.pointerId),e.touchPanCandidate=null,mV(e,c)||yV(e)||(e.cancelLongPress(),Nq(e))||Rq(e)||gV(e)||xV(e)||bV(e,c)||AV(e)||vV(e)||SV(e)||LV(e)||kV(e))return;let u=Gc(c,e.host),d=e.screenToWorld(u.point);_V(e,u,d)||wV(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!==" "||oa(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){YR(e,c,d);return}if(c.deltaX!==0){TV(e,c);return}YR(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 ng=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 qc={stroke:L4,fill:null,opacity:k4,width:uy},og=e=>({stroke:e.stroke,...e.fill!==null?{fill:e.fill}:{},...e.opacity!==1?{opacity:e.opacity}:{}}),zS=(e,t)=>e<=0?S4:Math.max(.5,e*t),QR=(e,t,n=uy,o=!1)=>{let a=o?dy:t,r={x:0,y:0,width:zS(a,n),pressure:a};return{points:[r],pressures:[a],simulatePressure:o,baseWidth:n,lastRaw:r,lastStoredRaw:{x:0,y:0},origin:e}},EV=e=>{let t=(n,o)=>n===0||n===o-1||n%2===0;e.points=e.points.filter((n,o,a)=>t(o,a.length)),e.pressures=e.pressures.filter((n,o,a)=>t(o,a.length))},JR=(e,t,n,o=1)=>{let a=e.origin,r=t.x-a.x,s=t.y-a.y,i=e.pressures[e.pressures.length-1]??dy,l;if(e.simulatePressure){let h=Math.hypot(r-e.lastRaw.x,s-e.lastRaw.y)*o,m=1-Math.min(1,h/T4);l=i+(m-i)*Yv,l=Math.min(C4,Math.max(E4,l))}else l=i+(n-i)*Yv;let c={x:r,y:s,width:zS(e.simulatePressure?l:n,e.baseWidth),pressure:e.simulatePressure?l:n},u=(r-e.lastStoredRaw.x)*o,d=(s-e.lastStoredRaw.y)*o;if(u*u+d*d<Kv*Kv){e.lastRaw=c;return}let f=e.points[e.points.length-1]??c,p=1-w4;e.points.push({x:f.x+(c.x-f.x)*p,y:f.y+(c.y-f.y)*p,width:zS(l,e.baseWidth)}),e.pressures.push(l),e.lastRaw=c,e.lastStoredRaw={x:r,y:s},e.points.length>I4&&EV(e)},CV=(e,t,n=M4,o=R4)=>{let a=e.length;if(a<3||n<=0)return e.slice();let r=new Array(a);r[0]=0;for(let l=1;l<a;l++){let c=v(e[l-1]),u=v(e[l]);r[l]=v(r[l-1])+Math.hypot(u.x-c.x,u.y-c.y)}let s=v(r[a-1]),i=Math.min(t*n,s/2);return i<=0?e.slice():e.map((l,c)=>{let u=Math.min(v(r[c]),s-v(r[c]));if(u>=i)return l;let d=u/i,f=o+(1-o)*d*(2-d);return{x:l.x,y:l.y,width:l.width*f}})},FS=(e,t)=>{let n=e.points.map((l,c)=>({...l,pressure:e.pressures[c]??dy})),o=n[n.length-1],a=e.lastRaw;o!==void 0&&(Math.abs(o.x-a.x)>.001||Math.abs(o.y-a.y)>.001)&&n.push(a);let r=Fy(n,_4,(l,c,u,d)=>({x:u.x,y:u.y,width:l.width+(c.width-l.width)*d,pressure:l.pressure+(c.pressure-l.pressure)*d})),s=r.map(({x:l,y:c,width:u})=>({x:l,y:c,width:u}));return{points:t!==void 0&&eO(s,t)?s:CV(s,e.baseWidth),pressures:r.map(l=>l.pressure)}},eO=(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<=$v*$v},tO=(e,t,n,o,a=og(qc))=>{if(!t||t.points.length===0)return null;let r=Ae([...e.elements.values()].filter(u=>u.layerId===n).map(u=>u.order)),{points:s,pressures:i}=FS(t,a),l={id:o,layerId:n,type:"brush",position:t.origin,rotation:0,scale:{x:1,y:1},order:r,style:a,points:s,pressures:i,baseWidth:t.baseWidth,...t.simulatePressure?{simulatePressure:!0}:{},...eO(s,a)?{closed:!0}:{}},c=Fe(e,l);return{scene:c.scene,patch:c.patch,elementId:o}},HS=e=>Ze(`brush-${e}-${Date.now().toString(36)}`),nO=(e,t,n)=>{if(!(n>0))return null;let o=e,a=[];for(let s of t){let i=I(o,s);if(!i||!Mn(i))continue;let l=i.baseWidth??i.points.reduce((d,f)=>Math.max(d,f.width),0);if(!(l>0)||l===n)continue;let c=n/l,u=$(o,s,d=>({...d,points:d.points.map(f=>({...f,width:f.width*c})),baseWidth:n}));o=u.scene,a.push(u.patch)}let r=a[0];return r===void 0?null:{scene:o,patch:a.length===1?r:{kind:"batch",patches:a}}};var oO=(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=$(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}},ag=(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=xi(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=fn(o,i);o=l.scene,a.push(l.patch)}for(let i of n)s(i);return{scene:o,patches:a}},aO=(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}},rO=(e,t,n)=>{let o=Pe;for(let a of t)e.elements.has(a)&&(o=Xt(o,a));return li(o,n)?null:o},sO=(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 li(n,t)?null:n},iO=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},lO=(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=$(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}}},cO=(e,t,n,o,a)=>{let r=I(e,t);if(r===void 0||!pe(r))return null;let s=DA(r,n,o,a);if(s===r)return null;let i=$(e,t,()=>s);return{scene:i.scene,patch:i.patch}},uO=(e,t,n)=>{let o=[];for(let i of t){let l=I(e,i);l!==void 0&&pe(l)&&o.push(i)}if(o.length===0)return null;let a=e,r=[];for(let i of o){let l=$(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}}},dO=(e,t,n)=>{let o=n==="increase",a=o?e2:1/e2,r=e,s=[];for(let l of t){let c=I(r,l);if(c===void 0||!pe(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(r5,Math.max(my,d));if(f===c.fontSize)continue;let p=$(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}}},fO=(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 ")}`},US=e=>{let t=Pe;for(let n of e)t=Xt(t,n);return t},GS=(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=N(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 pO=(e,t=!1)=>({pending:new Set,last:e,erased:new Map,strokeMode:t}),hO=(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/O4)),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},mO=(e,t)=>{let n=Pe;for(let o of t)e.elements.has(o)&&(n=Xt(n,o));return n.size===0?null:ag(e,n,new Set)};var WS=1e-6,qS=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}},rg=(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}},gO=(e,t,n,o)=>{let a=rg(e,t);return Ua.distanceToSegmentSq({x:e.position.x+a.x,y:e.position.y+a.y},n,o)},yO=(e,t,n,o,a,r)=>{let s=t,i=n;for(let l=0;l<N4;l++){let c=(s+i)/2;gO(e,c,o,a)<=r?i=c:s=c}return i},xO=(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 Ua.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(B4,o*P4),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 C=Math.max(1,Math.ceil(_/m)),w=-1,L=A;for(let k=0;k<=C;k++){let M=k===C?A+_:A+_*k/C,B=gO(e,M,t,n)<=l;B&&w<0?w=k===0?M:yO(e,L,M,t,n,l):!B&&w>=0&&(x.push([w,yO(e,M,L,t,n,l)]),w=-1),L=M}w>=0&&x.push([w,A+_])}return Kp(x)},Kp=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]+WS?a>r[1]&&(r[1]=a):n.push([o,a])}return n},VS=e=>e.reduce((t,[n,o])=>t+(o-n),0),bO=(e,t)=>{let n=Kp(e),o=[],a=0;for(let[r,s]of n)r>a+WS&&o.push([a,r]),s>a&&(a=s);return t>a+WS&&o.push([a,t]),o};var AO=1e-6,vO=(e,t,n)=>{let o=qS(e);if(o.total===0)return[];let a=bO(t,o.total),r=[],s=e.order,i=0;for(let[l,c]of a){if(c-l<z4)continue;let u=[rg(o,l)];for(let m=0;m<o.pts.length;m++){let x=v(o.cum[m]);x>l+AO&&x<c-AO&&u.push({...v(o.pts[m])})}if(u.push(rg(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:Sc(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},SO=(e,t,n,o,a)=>{let r=xO(qS(e),n,o,a);return r.length===0?t.length>0?Kp(t):[]:Kp([...t,...r])};var LO=(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||!Mn(u))continue;let d=vO(u,c,n);for(let p of[...o.links.values()])if(!i.has(p.id)&&(di(p.from)===u.id||di(p.to)===u.id)){let h=xi(o,p.id);o=h.scene,a.push(h.patch),i.add(p.id)}let f=fn(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}},kO=(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||!Mn(s))continue;let i=0,l=vO(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 _O=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},wO=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(_O(a))}return n},TO=(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={..._O(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:Yo(l)),{scene:u,newIds:c}};var EO=(e,t)=>wO(e,t),CO=(e,t,n,o,a)=>{let r=TO(e,t,n,o,()=>Ze(`shape-${a()}-${Date.now().toString(36)}`));return{scene:r.scene,newIds:r.newIds}},IO=e=>{let t=Pe;for(let n of e)t=Xt(t,n);return t};var MO=(e,t,n)=>{let o=Ae([...e.layers.values()].map(s=>s.order)),r=Av(e,{id:n,name:t,visible:!0,locked:!1,order:o});return{scene:r.scene,patch:r.patch,layerId:n}},RO=(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=fn(a,i.id);a=l.scene,o.push(l.patch)}for(let i of[...a.links.values()]){if(i.layerId!==t)continue;let l=xi(a,i.id);a=l.scene,o.push(l.patch)}let r=vv(a,t);a=r.scene,o.push(r.patch);let s=n;if(n===t){let i=[...a.layers.values()].sort(jf)[0];i&&(s=i.id)}return{scene:a,patches:o,nextActiveLayerId:s}},OO=(e,t,n)=>{let o=e.layers.get(t);if(!o||o.name===n)return null;let a=dp(e,t,r=>({...r,name:n}));return{scene:a.scene,patch:a.patch}},DO=(e,t)=>{if(!e.layers.has(t))return null;let n=dp(e,t,o=>({...o,visible:!o.visible}));return{scene:n.scene,patch:n.patch}},PO=(e,t)=>{if(!e.layers.has(t))return null;let n=dp(e,t,o=>({...o,locked:!o.locked}));return{scene:n.scene,patch:n.patch}},BO=(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=$(o,r,l=>({...l,layerId:n}));o=i.scene,a.push(i.patch)}return a.length===0?null:{scene:o,patches:a}},NO=e=>cn(`layer-${e}-${Date.now().toString(36)}`);var zO=(e,t,n,o)=>{let a=new Date().toISOString(),r=zf(o("ann")),s=[];t.firstComment?.trim()&&s.push({id:fc(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=Sv(e,i);return{scene:l.scene,patch:l.patch,id:r}},FO=(e,t)=>{if(!e.annotations.has(t))return null;let n=Lv(e,t);return{scene:n.scene,patch:n.patch}},HO=(e,t)=>{let n=e.annotations.get(t);if(!n)return null;let o=ja(e,t,a=>({...a,resolved:!a.resolved}));return{scene:o.scene,patch:o.patch,wasResolved:n.resolved}},UO=(e,t,n,o,a)=>{let r=n.trim();if(!r||!e.annotations.has(t))return null;let s={id:fc(a("cmt")),authorId:o.id,authorName:o.name,body:r,createdAt:new Date().toISOString()},i=ja(e,t,l=>({...l,thread:[...l.thread,s]}));return{scene:i.scene,patch:i.patch}},GO=(e,t,n)=>{if(!e.annotations.get(t)?.thread.some(r=>r.id===n))return null;let a=ja(e,t,r=>({...r,thread:r.thread.filter(s=>s.id!==n)}));return{scene:a.scene,patch:a.patch}},WO=(e,t)=>{let n=e.viewport.zoom,o=cy/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=es(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 qO=(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},VO=(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=$(e,t,i=>{let l={...i};return a===""?delete l.name:l.name=a,l});return{scene:s.scene,patch:s.patch}};var IV={nw:"resize-nwse",se:"resize-nwse",ne:"resize-nesw",sw:"resize-nesw",n:"resize-ns",s:"resize-ns",e:"resize-ew",w:"resize-ew"},MV=(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}`},RV=(e,t,n)=>{let o=e.getCursorOverride(t);return o===void 0?n:MV(o,n)},OV=(e,t)=>{if(e.activeTool.type!=="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}=Co(o,wo/a),s=($o+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},jO=(e,t)=>{let n=(a,r)=>RV(e,a,r),o=a=>n(IV[a],x5(a));if(e.panGesture)return n("pan-active","grabbing");if(e.linkDragFromAnchor?.moved===!0)return n("draw","crosshair");if(e.isDraggingWaypoint||e.isDraggingSegment||e.isDraggingLabel||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.activeTool.type==="hand")return n("pan-ready","grab");switch(e.activeTool.type){case"draw-rect":case"draw-ellipse":case"draw-frame":case"draw-edge":case"brush":case"laser":case"crop":return n("draw","crosshair");case"erase":return n("erase","none");case"draw-text":return n("text","text");default:break}if(t){if(OV(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 sg=(e,t,n)=>{let o=t??(n.size===1?[...n][0]??null:null);return o&&e.elements.has(o)?o:null},XO=(e,t,n)=>{let o=sg(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=$(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},YO=(e,t,n)=>{let o=sg(e,t,n);if(!o)return null;let a=I(e,o);if(!a)return null;let r=vc([...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=$(e,a.id,i=>({...i,order:r}));return{scene:s.scene,patch:s.patch}},KO=(e,t,n)=>{let o=sg(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(Tt),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?Sc(s.order,i.order):Ae(r.map(u=>u.order));if(l===a.order)return null;let c=$(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},$O=(e,t,n)=>{let o=sg(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(jf),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?Sc(i.order,s.order):vc(r.map(u=>u.order));if(l===a.order)return null;let c=$(e,a.id,u=>({...u,order:l}));return{scene:c.scene,patch:c.patch}},ZO=(e,t)=>{if(e.length===0)return 0;let n=[...e].sort(Tt),o=yv(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},QO=(e,t,n)=>{let o=e,a=0;for(let r of t)a+=ZO([...o.elements.values()].filter(s=>s.layerId===r),(s,i)=>{let l=$(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)}),a+=ZO([...o.links.values()].filter(s=>s.layerId===r),(s,i)=>{let l=Ye(o,s.id,c=>({...c,order:i}));o=l.scene,n(o,l.patch)});return a};var JO=(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=ey(e,{shapeIds:a,origin:o,cols:r,gap:s});return i?{scene:J(e,i),patch:i,count:a.length,cols:r}:null},eD=(e,t,n,o)=>{let a=[...t];if(a.length<2)return null;let r=n.direction??"horizontal",s=n.gap??16,i=ty(e,{shapeIds:a,origin:o,direction:r,gap:s});return i?{scene:J(e,i),patch:i,count:a.length,direction:r}:null},jS=(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},tD=(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},nD=(e,t,n)=>{let o=jS(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=$(l,d.id,p=>({...p,parentId:n}));l=f.scene,c.push(f.patch)}return{scene:l,patches:c,groupId:n}},oD=(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=$(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=fn(o,s.id);o=l.scene,a.push(l.patch)}return{scene:o,patches:a,nextSelection:r}},aD=(e,t,n)=>{let o=[...e.layers.values()].filter(l=>l.visible&&!l.locked).sort(Tt),a=[];for(let l of o){let c=[...e.elements.values()].filter(u=>u.layerId===l.id).sort(Tt);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?_v(i):s}},rD=e=>Ze(`group-${e}-${Date.now().toString(36)}`);var sD=/^(https?:|mailto:)/i,DV=/^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/,iD=e=>{let t=e.trim();return t===""?null:sD.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t)?null:DV.test(t)?`mailto:${t}`:`https://${t}`},ig=e=>e&&sD.test(e.trim())?e.trim():null,lD=(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=$(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}}},PV=(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}},cD=(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=PV(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 BV=Yr.rectangle,NV=Yr.ellipse,ZS=(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"?vc(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:{...BV}}:t==="ellipse"?{...l,type:"ellipse",style:{...NV}}:{...l,type:"frame",style:{fill:qI},name:r()}},uD=(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:bi,style:{...uc},arrowheads:{to:yp}}},dD=(e,t,n,o)=>{let a=uD(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},fD=(e,t,n,o,a,r)=>{let s=ZS(e,t,n,o,a,r),i=Fe(e,s);return{scene:i.scene,patch:i.patch,elementId:o}},$p=(e,t,n,o,a)=>{let r=uD(e,t,n,o,a),s=gi(e,r);return{scene:s.scene,patch:s.patch,linkId:o}},Vc=e=>`shape-${e}-${Date.now().toString(36)}`,Qp=e=>`edge-${e}-${Date.now().toString(36)}`;var pD=(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}},hD=(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:Y4,fontSize:X4,style:{fill:K4,textAlign:"left",textBaseline:"top"}}},YS=e=>Ze(`shape-${e}-${Date.now().toString(36)}`),mD=(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}},yD=(e,t)=>{let n={x:t.current.position.x+t.halfWidth,y:t.current.position.y+t.halfHeight},o=Yf(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}},gD=e=>{let t=N(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}}},xD=(e,t)=>({scene:fn(e,t).scene}),XS="__ghost-preview__",jc="__ghost-preview-link__",bD=(e,t,n,o)=>{let a=I(e,n);if(!a||Mn(a))return null;let r={kind:"named",name:o},s=Xo(a,r),i=N(a),l=Math.abs(s.x)*i.width+Math.abs(s.y)*i.height,c=l+Bv,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:XS,position:{x:a.position.x+u.x,y:a.position.y+u.y}};pe(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,XS)),{ref:A}=qa(b,y,ko(b)),C=$p(g,{kind:"anchor",elementId:n,anchor:r},{kind:"anchor",elementId:XS,anchor:A},jc,t).scene,w=v(ue(C,jc));if((w.routing??"straight")==="orthogonal"){let L=mp(C,w);C=Ye(C,jc,k=>({...k,routedPoints:L})).scene}return C={...C,links:new Map([[jc,v(ue(C,jc))]])},{bounds:d,path:[f,m],element:x,ghostScene:C,ghostLinkId:jc}},AD=(e,t,n,o,a,r)=>{let s=I(e,n);if(!s||Mn(s))return null;let i={kind:"named",name:o},l=Xo(s,i),c=N(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+Bv,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};pe(m)?m={...m,text:""}:Be(m)&&(m={...m,name:""});let x=Fe(e,m),y=v(I(x.scene,a)),{ref:g}=qa(y,u,ko(y)),b=$p(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}},vD=(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}},SD=(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=N(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=Ye(c.scene,n.linkId,d=>({...d,[n.side]:{kind:"floating",elementId:o}}));return{scene:u.scene,addPatch:c.patch,linkPatch:u.patch}};var KS=(e,t,n="fill")=>{let o=hi(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},zV=new Set(["rectangle","ellipse","polygon"]),FV=(e,t)=>[{x:e/2,y:0},{x:e,y:t/2},{x:e/2,y:t},{x:0,y:t/2}],LD=(e,t,n)=>{let o=e,a=[];for(let s of t){let i=I(o,s);if(i===void 0||!zV.has(i.type)||i.type===n)continue;let l=Re(i),c=l.width,u=l.height,d=$(o,s,f=>{let{width:p,height:h,points:m,...x}=f;return n==="polygon"?{...x,type:"polygon",points:FV(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}}},kD=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}},HV=(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 lg={x:0,y:0,width:1,height:1},_D=["nw","ne","se","sw","n","e","s","w"],Zc=(e,t,n)=>Math.min(Math.max(e,t),n),cg=(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}},wD=e=>{let t=Re(e),{x:n,y:o,width:a,height:r}=t,s=(i,l)=>Rn(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)}},UV=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"}),TD=(e,t,n,o)=>{let a=cg(e,t),r=Re(e),s=pi(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}=UV(n),m=a.x+a.width,x=a.y+a.height;d&&(i=Zc(s.x,a.x,c-Ap)),f&&(c=Zc(s.x,i+Ap,m)),p&&(l=Zc(s.y,a.y,u-Ap)),h&&(u=Zc(s.y,l+Ap,x));let y={x:i,y:l,width:c-i,height:u-l};return{crop:kD({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:Rn(e,{x:y.x,y:y.y}),width:y.width,height:y.height}},ED=(e,t,n,o)=>{let a=cg(e,t),r=pi(e,n),s=pi(e,o),i=s.x-r.x,l=s.y-r.y;return{crop:{x:Zc(t.x-i/a.width,0,1-t.width),y:Zc(t.y-l/a.height,0,1-t.height),width:t.width,height:t.height}}},GV=(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,CD=(e,t,n)=>{let o=I(e,t);if(o?.type!=="image")return null;let a=kD(n.crop),r=GV(a)?void 0:a,s=o.crop;if(HV(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=$(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}},ID=(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+To:n==="left"?-(i+To):0,u=n==="down"?l+To:n==="up"?-(l+To):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:bi,style:{...uc},arrowheads:{to:yp}},g=gi(x.scene,y);return{scene:g.scene,patches:[x.patch,g.patch],newElementId:o,linkId:a}},MD=(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+To:n==="left"?-(l+To):0,f=n==="down"?c+To:n==="up"?-(c+To):0,p=u?c+To:l+To,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 C=(_-(o-1)/2)*p,w=d+(u?0:C),L=f+(u?C:0),k=a();b.push({...g,id:k,position:{x:s.position.x+w,y:s.position.y+L},order:h}),A.push({id:r(),layerId:s.layerId,from:{kind:"floating",elementId:t},to:{kind:"floating",elementId:k},order:m,routing:bi,style:{...uc},arrowheads:{to:yp}})}return{elements:b,links:A}};var WV="__draw-preview__",RD="__draw-preview-link__",OD=new WeakMap,qV=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],VV=(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},DD=e=>{if(e.backgroundTarget){e.gridEnabled?Bp(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:Zf(e.scene,f),outsetWorld:RA(p)})}u.length>0&&WM(e.backgroundTarget,ao(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;if(e.tileComposeFn&&t&&!r)X2(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,...a&&a.size>0?{hideElements:a}:{},...e.sharedIndex?{index:e.sharedIndex}:{}}),Bn(e.scene,e.mainTarget,{viewportWorld:t});else{let u=e.sharedIndex;Ya(e.scene,e.mainTarget,{...t?{viewport:t}:{},...n?{dirtyWorld:n}:{},boundsCache:e.boundsCache,clock:e.animationClock,lod:v2,...o?{dimElements:o,dimOpacity:e.eraseActive?c4:l4}:{},...a?{hideElements:a}:{},...u?{spatialIndex:u}:{}}),Bn(e.scene,e.mainTarget,{...t?{viewportWorld:t}:{},...n?{dirtyWorld:n}:{}})}let s=qV(e),i=OD.get(e.overlayTarget);if(i===void 0||!VV(i.sig,s)){let u={};e.readOnly&&(u.readOnly=!0),e.mode!=="select"&&e.mode!=="hand"&&(u.suppressHandles=!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=ZS(e.scene,x,e.drawingPreview,WV,e.activeLayerId,()=>""):u.drawingPreview=e.drawingPreview}let f=null;if(e.edgePreview){let x=dD(e.scene,e.edgePreview,RD,e.activeLayerId);f={...e.scene,links:new Map([[RD,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,_,C,w)=>{let L=I(e.scene,A);if(!L)return null;let k=_==="link-start"?wo:WI,{names:M,worldPoints:B}=Co(L,k/x),G=[...B],ie=C!==null?M.indexOf(C):-1;_==="link-attach"&&w&&G.push(w);let ne=ie>=0?ie:_==="link-attach"&&w?G.length-1:-1;return{worldPoints:G,...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,C=y(_.elementId,"link-attach",_.activeAnchor,_.outlinePoint);C&&g.push(C)}}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]),C=I(e.scene,_);if(C){let w=N(C),L=(wo+$o+e.anchorStartHitSlop)/x;if(A.x>=w.x-L&&A.x<=w.x+w.width+L&&A.y>=w.y-L&&A.y<=w.y+w.height+L){let M=y(_,"link-start",null);if(M){let V=VI/x,ve=-1,ge=V*V;if(M.worldPoints.forEach((ee,Se)=>{let Oe=ee.x-A.x,qt=ee.y-A.y,xn=Oe*Oe+qt*qt;xn<=ge&&(ge=xn,ve=Se)}),ve>=0){let ee=V>0?Math.max(0,1-Math.sqrt(ge)/V):0,Se=gp+(FI-gp)*ee;g.push({...M,activeIndex:ve,activeRadius:Se})}else g.push(M)}let{names:B,worldPoints:G}=Co(C,wo/x),ie=(e.anchorClickRadius/x)**2,ne=null;for(let V=0;V<G.length;V++){let ve=v(G[V]);if((ve.x-A.x)**2+(ve.y-A.y)**2<=ie){ne=v(B[V]);break}}if(ne){let V=e.previewClickCreate(_,ne);V&&(u.ghostElement=V.bounds,u.ghostElementShape=V.element,d=V.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=N(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=ue(e.scene,y);if(!g)continue;let b=_o(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=ue(e.scene,h);if(x){let y=ut(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 _=e.linkSegmentDrag||e.linkEndpointDrag?[]:sp(e.scene,x,y).map(C=>C.point);u.edgeSelection={from:g,to:b,midpoints:_}}else{let _=[...x.waypoints??[]],C=e.linkWaypointDrag?[]:rp(e.scene,x)??[];u.edgeSelection={from:g,to:b,waypoints:_,midpoints:C}}}}}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=Uy({linkDragActive:x,elementDragActive:y});if(u.debugHitZoneVisibility=g,g.attachDropZones){let b=e.linkDragFromAnchor?.fromElement,A=[],_=[];for(let C of e.scene.elements.values())if(C.id!==b){A.push(...Co(C,0).worldPoints);for(let w of Zf(e.scene,C))_.push(w)}u.debugAttachZones={anchors:A,outlineLoops:_,thresholdWorld:ay}}if(g.containerDropZones){let b=e.groupMoveOrigin,A=[],_=[];for(let C of e.scene.elements.values())if(!b?.has(C.id)){if(Be(C)){A.push(N(C));continue}_.push(...jA(C))}u.debugContainerZones={frames:A,containers:_}}}i={sig:s,opts:u,ghostScene:d,edgePreviewScene:f,flowchartPreviewScene:p},OD.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(N(u));c.length>0?l.gifBadges=c:l.gifBadges!==void 0&&delete l.gifBadges,qM(e.scene,e.selection,e.overlayTarget,l),i.ghostScene&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(ly),Bn(i.ghostScene,e.overlayTarget,{}),e.overlayTarget.restore()),i.edgePreviewScene&&Bn(i.edgePreviewScene,e.overlayTarget,{}),i.flowchartPreviewScene&&(e.overlayTarget.save(),e.overlayTarget.setOpacity(yy),Bn(i.flowchartPreviewScene,e.overlayTarget,{}),e.overlayTarget.restore())};var ug=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()},e5))}stop(){this.timer!==null&&(clearInterval(this.timer),this.timer=null)}wake(){this._on=!0}};var PD=(e,t,n)=>{let o=I(e,t);return!(o===void 0||!pe(o)||n(o.layerId))};var dg=class{host;_editingElement=null;_pendingCreate=null;_origin=null;_sel=null;_dragAnchor=null;caretBlink;constructor(t){this.host=t,this.caretBlink=new ug(()=>{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(!PD(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&&pe(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=$(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||!pe(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 W2(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=N(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 Hc(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||!pe(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=q2(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=G2(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=$(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&&pe(r)?r:void 0;if((s?.text??"").trim()===""){s&&(this.host.scene=fn(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=pe(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=fn(this.host.scene,t).scene,this.host.clearSelectionFor(t));else if(o){let a=pe(o)?o.text:"";this.host.scene=$(this.host.scene,t,r=>({...r,text:a})).scene}this.host.notify()}};var BD=(e,t,n,o)=>{let a=n;if(t){let i=I(e,t);i&&(a=qa(i,n,ko(i)).world)}let r=o,s=hi(e,o);return s&&(r=qa(s,o,ko(s)).world),{from:a,to:r}},ND=(e,t,n)=>{let o=ue(e,t.linkId);if(!o)return null;let a=n(t.toElement,t.toPoint),r=Ye(e,o.id,s=>({...s,[t.side]:a}));return{scene:r.scene,patch:r.patch,linkId:o.id}},zD=(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?N(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=N(r);a+=`${r.id},${s.x},${s.y},${s.width},${s.height};`}return o+a}return o};var fg=class{host;_endpointDrag=null;_waypointDrag=null;_segmentDrag=null;_labelDrag=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}get labelDrag(){return this._labelDrag}get isDraggingLabel(){return this._labelDrag!==null}reset(){this._waypointDrag=null,this._segmentDrag=null,this._endpointDrag=null,this._labelDrag=null}applyEndpointMove(t,n,o){if(!ue(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=Ye(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=ND(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&&Jr(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){ue(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=ue(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=Ye(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=ue(this.host.scene,t.linkId);if(n?.waypoints&&t.index>=0&&t.index<n.waypoints.length){let o=ut(this.host.scene,n),a=v(n.waypoints[t.index]),r=BI/(this.host.scene.viewport.zoom||1),s=o?.[t.index],i=o?.[t.index+2];if(s&&i&&Ua.distanceToSegment(a,s,i)<=r){let l=n.waypoints.filter((u,d)=>d!==t.index),c=Ye(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){ue(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=ue(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=Ye(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())}beginLabelDrag(t){ue(this.host.scene,t)?.label&&(this._labelDrag={linkId:t,moved:!1})}updateLabelDrag(t){let n=this._labelDrag;if(!n)return;n.moved=!0,this.lastHandleClickAt=0;let o=ue(this.host.scene,n.linkId);if(!o?.label)return;let a=_o(this.host.scene,o);if(!a||a.length<2)return;let r=0;for(let u=1;u<a.length;u++){let d=a[u-1],f=a[u];d&&f&&(r+=Math.hypot(f.x-d.x,f.y-d.y))}let s=JA(a,t),i=this.host.scene.viewport.zoom||1,l=r>0&&Math.abs(s-.5)*r<g5/i,c=Ye(this.host.scene,n.linkId,u=>{if(!u.label)return u;if(l){let{position:d,...f}=u.label;return{...u,label:f}}return{...u,label:{...u.label,position:s}}});this.host.scene=c.scene,this.host.recordGesturePatch(c.patch),this.host.notify()}endLabelDrag(){this._labelDrag&&(this._labelDrag=null,this.host.commitGesture())}isHandleDoubleClick(t){let n=performance.now(),o=n-this.lastHandleClickAt<wc&&this.lastHandleClickWorld!==null&&W.distance(this.lastHandleClickWorld,t)<=Tc;return this.lastHandleClickAt=n,this.lastHandleClickWorld=t,o}deleteWaypoint(t,n){let o=ue(this.host.scene,t);if(!o?.waypoints||n<0||n>=o.waypoints.length)return;let a=o.waypoints.filter((s,i)=>i!==n),r=Ye(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=ue(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=Ye(this.host.scene,t,u=>({...u,fixedSegments:l}));this.host.scene=c.scene,this.host.pushHistory(c.patch),this.host.notify()}};var FD=e=>{let t=e.viewport,n=t.size.width,o=t.size.height;if(n<=0||o<=0)return null;let a=Va(t),r=[z.applyToPoint(a,{x:0,y:0}),z.applyToPoint(a,{x:n,y:0}),z.applyToPoint(a,{x:0,y:o}),z.applyToPoint(a,{x:n,y:o})],s=j.fromPoints(r);return j.expand(s,Math.max(s.width,s.height)*MI)},pg=(e,t)=>{let n=null;for(let o of e.elements.values()){if(o.parentId!==t)continue;let a=ze(o)?pg(e,o.id):N(o);a&&(n=n?j.union(n,a):a)}return n},HD=(e,t)=>{let n=null;for(let o of t){let a=I(e,o);if(!a)continue;let r=ze(a)?pg(e,a.id):N(a);r&&(n=n?j.union(n,r):r)}return n};var UD=e=>{let t=null;for(let n of e.elements.values())yc(e,n)&&(t??=new Set,t.add(n.id));return t??void 0};var GD=(e,t,n,o,a)=>{let r=q0(e,o,Zv),s=a==="replace"?Pe:t;for(let i of r)n(i.layerId)||(s=Xt(s,i.id));return s},WD=(e,t,n,o,a)=>{let r=a==="replace"?Pe:t,s=q0(e,o,Zv);for(let i of s)n(i.layerId)||(r=Xt(r,i.id));return r},jV=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,$S=(e,t,n,o,a)=>{let r=a==="replace"?gt:t;for(let s of e.links.values()){if(n(s.layerId))continue;let i=ut(e,s);!i||i.length<2||i.every(l=>jV(l,o))&&(r=PS(r,s.id))}return r};var QS=e=>Math.abs(e.x)>=Math.abs(e.y)?{x:e.x,y:0}:{x:0,y:e.y},qD=(e,t,n,o)=>{let a=I(e,t);if(!a)return null;let r=N(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}},VD=(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},jD=(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=ja(e,t,l=>({...l,position:s}));return{scene:i.scene,patch:i.patch}};var JS=(e,t)=>{let n=[];for(let o of t){let a=I(e,o);a&&n.push(a)}return n},eL=e=>e.map(t=>N(t)).reduce((t,n)=>j.union(t,n)),ZD=(e,t,n)=>{let o=JS(e,t);if(o.length===0)return[];let a=eL(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},XD=(e,t,n)=>{let o=JS(e,t);if(o.length<2)return[];let a=eL(o),r=[];for(let s of o){let i=N(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},YD=(e,t,n)=>{let o=JS(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:N(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},tL=(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},KD=e=>{let t=eL(e);return{x:t.x+t.width/2,y:t.y+t.height/2}};var hg=(e,t)=>({x:Math.round(e.x/t)*t,y:Math.round(e.y/t)*t}),JD=(e,t,n)=>{let o=hg({x:e.x+t.x,y:e.y+t.y},n);return{x:o.x-e.x,y:o.y-e.y}},e8=(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=hg({x:o+t.x,y:a+t.y},n);return{x:r.x-o,y:r.y-a}},$D=new Set(["nw","w","sw"]),ZV=new Set(["ne","e","se"]),QD=new Set(["nw","n","ne"]),XV=new Set(["sw","s","se"]),nL=(e,t,n,o)=>{let a=n.x,r=n.y;if($D.has(t)||ZV.has(t)){let s=$D.has(t)?e.x:e.x+e.width;a=Math.round((s+n.x)/o)*o-s}if(QD.has(t)||XV.has(t)){let s=QD.has(t)?e.y:e.y+e.height;r=Math.round((s+n.y)/o)*o-s}return{x:a,y:r}},t8=(e,t)=>{let n=hg({x:e.x,y:e.y},t),o=hg({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 YV=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"]),KV=Object.freeze(new Set),Pi=()=>typeof performance<"u"?performance.now():Date.now(),Jp=class{host;mainTarget;overlayTarget;backgroundTarget;onAfterRender;debugHitZones=!1;_readOnly=!1;actor;listeners=new Set;events=AS();eventCache=dR();unbind;_scene;_selection=Pe;interaction=new ng;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=gt;_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=cn(On);nextId=0;uniqueId(t){return`${t}-${++this.nextId}-${Date.now().toString(36)}`}snapEngine=new cp([sv,iv,lv]);snapThreshold=ay;styleClipboard=null;boundsCache=new rs;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=og(this._brushSettings);return{origin:t.origin,points:FS(t,n).points,fill:Vf(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??KV}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 jy({getScene:()=>this._scene,compact:t=>{this.compactLayerZOrder(t,{recordHistory:!1})}});autoLayoutScheduler=new Zy({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()}});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;_lastActiveTool=null;_activeToolCache={type:P0,locked:!1,lastActiveTool:null};fileDropRegistry=new qp;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=$V(t.history)?t.history:new Wp(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(),ES(this),CS(this),this.maybeAnimate(),this.animationContentOff=j2(()=>{this.scheduleRender()}),this.forceRender(),pR(this.eventCache,this.observableSnapshot())}initControllers(){let t=this;this.gestures=new Ky({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.activeTool.type},setMode:n=>{t.setActiveTool(n)},notify:()=>{t.notify()}}),this.textEdit=new dg({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 fg({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 Jy(n=>this.screenToWorld(n),n=>{for(let o of this.longPressListeners)o(n)}),this.pinch=new eg(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&&zp(t.textShaper),t.rasterizer&&Fp(t.rasterizer),BA((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"?d4:ts,this.edgeHandleHitSlop=this.inputMode==="touch"?f4:Ko,this.edgeHitThreshold=this.inputMode==="touch"?p4:ry,this.anchorStartHitSlop=this.inputMode==="touch"?h4:sy,this.anchorClickRadius=this.inputMode==="touch"?m4:iy}initActor(t){this.actor=ea(aM),this.actor.subscribe({next:()=>{this.scheduleRender()}}),this.actor.on("*",n=>{this.applyEmit(n)}),this.actor.start(),this.fileDropRegistry.register(tR),this.fileDropRegistry.register(oR),this._readOnly=t.readOnly??!1,t.initialTool&&this.actor.send({type:"SET_MODE",mode:t.initialTool})}snapshotCache=null;observableSnapshot(){let t=this.activeTool,n=this._selection,o=this._selectedLinks,a=this._scene,r=this.canUndo,s=this.canRedo,i=this.snapshotCache;if(i!==null&&i.activeTool===t&&i.selection===n&&i.selectedLinks===o&&i.scene===a&&i.canUndo===r&&i.canRedo===s)return i;let l={activeTool: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 activeTool(){let t=this.actor.getSnapshot().context.mode,n=this._activeToolCache;return(n.type!==t||n.locked!==this._toolLocked||n.lastActiveTool!==this._lastActiveTool)&&(this._activeToolCache={type:t,locked:this._toolLocked,lastActiveTool:this._lastActiveTool}),this._activeToolCache}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=zO(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=FO(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=HO(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=UO(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=GO(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}hitAnnotation(t){return WO(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 selectedLinks(){return this._selectedLinks}get selectedLink(){return this._selection.size>0?null:HR(this._selectedLinks)}updateSelectedLink(t){if(this.readOnly)return;let n=this.selectedLink;if(n===null)return;let o=Ye(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())}maybeRevertToolAfterCreate(){this.gestures.maybeRevertModeAfterCreate()}setActiveTool(t){let n=this.actor.getSnapshot().context.mode;n!==t&&(this._lastActiveTool=n),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=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=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=hR(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 mR(this._scene,t,n,()=>++this.nextId);return this._scene=o.scene,this._history.push(o.patch),o.id}animation=new Yy({hasVisibleAnimatedElement:()=>gR(this)||this.hasActiveLaser(),autoStopHeavyGifs:()=>{xR(this)},forceAnimationRepaint:()=>{this.lastRenderedScene=null,this.render()}});hasAnimatedElement(){return Qy(this._scene)}maybeAnimate(){this.animation.maybe()}gifPlayback=new $y;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}=gD(t),r=o(this._scene);this._scene=r.scene,this._selection=wt(t.id),this.notify();let s={...a};return{update:i=>{let l=mD(this._scene,s,i);this._scene=l.scene,s.current=l.next,this.notify()},commit:()=>{let i=yD(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}=xD(this._scene,t.id);this._scene=i,n.cancel(),this._selection=Pe,this.notify()}}}deleteSelected(){if(this.readOnly)return;let t=ag(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=gt,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){ue(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=ue(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=Ye(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=ue(this._scene,t);if(!n)return null;let o=_o(this._scene,n);return!o||o.length<2?null:gc(o,n)}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=VO(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 qO(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?oO(this._scene,n,t,i=>this.isLayerLocked(i)):null,a=o?o.scene:this._scene,r=DR(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(fO(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=YS(++this.nextId),a=pD(this._scene,this.activeTool.type,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=YS(++this.nextId),o=hD(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.maybeRevertToolAfterCreate(),this.notify(),this.announce(`Created text ${n}`),this.beginTextEdit(n),n}_brushSettings=qc;get brushSettings(){return this._brushSettings}setBrushSettings(t){this._brushSettings={...this._brushSettings,...t},this.notify()}beginBrushStroke(t,n=.5,o="pen"){this.brushStroke=QR(t,n,this._brushSettings.width,o!=="pen"),this.notify()}extendBrushStroke(t,n=.5){this.brushStroke&&(JR(this.brushStroke,t,n,this._scene.viewport.zoom||1),this.notify())}commitBrushStroke(){let t=tO(this._scene,this.brushStroke,this._activeLayerId,HS(++this.nextId),og(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=pO(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=[Hy(t,Pi())],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(!Mn(i))continue;let l=t.erased.get(i.id)??[],c=SO(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=hO(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?(J2(i,t,Pi()),this.interaction.eraserTrail=s.slice()):this.interaction.eraserTrail=[Hy(t,Pi())],this.maybeAnimate(),this.notify()}commitEraseStroke(){let t=this.eraseStroke;if(!t)return 0;this.eraseStroke=null;let n=mO(this._scene,t.pending),o=n?n.scene:this._scene,a=n?[...n.patches]:[],r=[];if(t.strokeMode){let l=LO(o,t.erased,()=>HS(++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=Hf(i,l);for(let l of r)i=Hf(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,Hy(t,Pi())],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&&(J2(o,t,Pi()),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=eS(t,Pi());o.changed&&(this.interaction.laserStrokes=o.strokes)}let n=this.interaction.eraserTrail;if(n.length>0){let o=eS(n,Pi(),py);o.changed&&(this.interaction.eraserTrail=o.strokes)}}arrangeAsGrid(t={}){let n=this.combinedSelectionBounds()??{x:0,y:0},o=JO(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=eD(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=nD(this._scene,this._selection,rD(++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=oD(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 jS(this._scene,this._selection)}expandSelectionWithDescendants(){return tD(this._scene,this._selection)}focusCycle(t){let n=[...this._selection][0],o=aD(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=gt,this.notify(),this.announce("Selection cleared")}duplicateSelected(){if(this.readOnly)return;let t=aO(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=US(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=vD(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=US(i)),this.notify(),t!==null?a.get(t)??null:null}setSelection(t){let n=rO(this._scene,t,this._selection);n&&(this._selection=n,this._selectedLinks.size>0&&(this._selectedLinks=gt),this.notify())}selectLink(t){let n=t===null?gt:tg(t),o=!Xp(n,this._selectedLinks),a=this._selection.size>0;!o&&!a||(this._selection=Pe,this._selectedLinks=n,this.notify())}selectAll(){let t=sO(this._scene,this._selection),n=iO(this._scene),o=!Xp(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=EO(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=CO(this._scene,this._history,this.clipboard,n??null,()=>++this.nextId);this._scene=o.scene,this._selection=IO(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=lO(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}setBrushWidth(t,n){if(this.readOnly)return;let o=nO(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=cO(this._scene,t,n,o,a);r&&(this._scene=r.scene,this._history.push(r.patch),this.notify())}pickColorAt(t,n="fill"){return KS(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=KS(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}),n)}convertSelection(t){if(this.readOnly)return;let n=LD(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=ID(this._scene,o,t,Vc(++this.nextId),Qp(++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,a5):1,{elements:s,links:i}=MD(this._scene,o,t,r,()=>Vc(++this.nextId),()=>Qp(++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=gi(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=di(r.from),i=di(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=GS(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??lg,position:n.position,width:n.width,height:n.height,drag:null,dragStartWorld:null},this.setActiveTool("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=wD(a),s=this._scene.viewport.zoom||1,i=p5/s;for(let c of _D){let u=r[c];if(Math.hypot(t.x-u.x,t.y-u.y)<=i)return c}let l=pi(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??lg;if(n.drag.kind==="handle"){let r=TD(o,a,n.drag.handle,t);this.cropSession={...n,crop:r.crop,position:r.position,width:r.width,height:r.height}}else{let r=ED(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=CD(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.setActiveTool("select"),this.refreshCursor(),this.notify()}cancelImageCrop(){this.cropSession!==null&&(this.cropSession=null,this.setActiveTool("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=>Rn(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??lg;return{element:n,fullRect:cg(n,o)}}updateTextProps(t,n){if(this.readOnly)return;let o=uO(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}adjustSelectionFontSize(t){if(this.readOnly)return;let n=dO(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:iD(n),a=lD(this._scene,t,o);a&&(this._scene=a.scene,this._history.push(a.patch),this.notify())}openLink(t){let n=ig(t);!n||typeof window>"u"||window.open(n,"_blank","noopener,noreferrer")}elementLink(t){return ig(I(this._scene,t)?.href)}linkAt(t){let n=this.acceleratedElementAt(t);if(!n||!this.isElementInteractable(n))return null;let o=ig(n.href);return o?{id:n.id,href:o,bounds:N(n)}:null}bringToFront(t){if(this.readOnly)return;let n=XO(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=YO(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=KO(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=$O(this._scene,t,this._selection);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}flipSelection(t){this.commitArrange(ZD(this._scene,this._selection,t))}alignSelection(t){this.commitArrange(XD(this._scene,this._selection,t))}distributeSelection(t){this.commitArrange(YD(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=KD(n);this.commitArrange(tL(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=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(QO(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=gt,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=MO(this._scene,t,NO(++this.nextId));return this._scene=n.scene,this._history.push(n.patch),this._activeLayerId=n.layerId,this.notify(),n.layerId}removeLayer(t){let n=RO(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=OO(this._scene,t,n);o&&(this._scene=o.scene,this._history.push(o.patch),this.notify())}toggleLayerVisibility(t){let n=DO(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}toggleLayerLock(t){let n=PO(this._scene,t);n&&(this._scene=n.scene,this._history.push(n.patch),this.notify())}moveSelectionToLayer(t){if(this.readOnly)return;let n=BO(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=UR(this._scene,t);n&&(this._scene=n,this.notify())}zoomIn(){this.zoomStep(qv)}zoomOut(){this.zoomStep(1/qv)}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=WR(this._scene);t&&(this._scene=t,this.notify())}zoomToFit(t=40){let n=VR(this._scene,t);n&&(this._scene=n,this.notify())}zoomToSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=NS(this._scene,n,t);o&&(this._scene=o,this.notify())}revealSelection(t=80){let n=this.combinedSelectionBounds();if(!n)return;let o=qR(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=GS(this._scene,this._selection,t,a,s=>this.isElementInteractable(s));r!==null&&this.setSelection([r])}zoomAt(t,n){let o=GR(this._scene,t,n);o&&(this._scene=o,this.notify())}setViewportSize(t,n){let o=jR(this._scene,t,n);o&&(this._scene=o,this.notify())}setGrid(t){let n=ZR(this._scene,t);n&&(this._scene=n,this.notify())}get snapToGridEnabled(){return Y0(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&&Y0(t)}snapSpacing(){return cv()}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??cn(On)}n.preserveHistory?this.pruneSelection():(this._selection=Pe,this._history.clear()),ES(this),CS(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 $R(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 z.applyToPoint(Va(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:N(o)}}}hitTest(t){return BM(t,{scene:this._scene,selection:this._selection,selectionChromeActive:this.activeTool.type==="select",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=jO(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)||yc(this._scene,t))}isElementManipulable(t){return!(this.isLayerLocked(t.layerId)||GA(this._scene,t)||yc(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=$(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 rR(this._scene,t,this._enteredGroup)}topGroupAncestor(t){return aR(this._scene,t)}isDescendantOfGroup(t,n){return TS(this._scene,t,n)}computeHiddenElements(){return UD(this._scene)}computeStrokeErasePreview(){let t=this.eraseStroke;if(!t||!t.strokeMode||t.erased.size===0)return null;let n=kO(this._scene,t.erased);return n?{elements:n.fragments,hidden:n.hidden}:null}computeDimElements(t){return sR(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<jv?hi(this._scene,t):VA(this._scene,this.ensureSpatialIndex(),t)}ensureSpatialIndex(){let t=this.spatialIndexCache;if(t?.scene===this._scene)return t.index;let n=qA(this._scene);return this.spatialIndexCache={scene:this._scene,index:n},n}routeIsolationClick(t,n){let o=performance.now(),a=o-this.interaction.lastClickAt<wc&&this.interaction.lastClickWorldPoint!==null&&W.distance(this.interaction.lastClickWorldPoint,n)<=Tc;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=tg(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&&pe(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=gt),this.notify(),!0}}return!1}pickDrillTarget(t,n){return iR(this._scene,t,n,this._enteredGroup)}applyEmit(t){if(!(this._readOnly&&YV.has(t.type)))switch(t.type){case"SELECT_REPLACE":this._selection=wt(t.id),this._selectedLinks=gt,this.notify();return;case"SELECT_TOGGLE":this._selection=_A(this._selection,t.id),this.notify();return;case"SELECT_CLEAR":this._selection=Pe,this._selectedLinks=gt,this.notify();return;case"SELECT_EDGE_REPLACE":this._selectedLinks=tg(t.id),this._selection=Pe,this.notify();return;case"SELECT_EDGE_TOGGLE":this._selectedLinks=FR(this._selectedLinks,t.id),this.notify();return;case"SELECT_EDGE_CLEAR":this._selectedLinks.size>0&&(this._selectedLinks=gt,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=jD(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?QS(n):n,s=this.snapActive()?JD(o,r,this.snapSpacing()):r,i=qD(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.interaction.transformShiftKey?QS(t):t,o=this.snapActive()?e8(this.groupMoveOrigin,n,this.snapSpacing()):n,a=VD(this._scene,this.groupMoveOrigin,o);for(let r of a)this._scene=J(this._scene,r),this.recordGesturePatch(r);if(this.groupLinkMoveOrigin){let r=OR(this._scene,this.groupLinkMoveOrigin,o);for(let s of r)this._scene=J(this._scene,s),this.recordGesturePatch(s)}this.notify()}computeViewportWorld(){return FD(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}=AR(t,n);if(this.tileComposeFn!==null)for(let[r,s]of a)this.tileDirtyElements.set(r,s);return o}combinedSelectionBounds(){let t=HD(this._scene,this._selection);for(let n of this._selectedLinks){let o=ue(this._scene,n);if(!o)continue;let a=ut(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?j.union(t,c):c}return t}groupChildrenUnion(t){return pg(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/Rv)*Rv:t,a=tL(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()?nL(o,t,n,this.snapSpacing()):n,r=zR(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&&!pe(r)&&r.rotation!==0){this.interaction.resizeOriginElement?.id!==t&&(this.interaction.resizeOriginElement=r);let l=BR(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()?nL(a,n,o,this.snapSpacing()):o;if(r!==void 0&&pe(r)){this.interaction.resizeOriginElement?.id!==t&&(this.interaction.resizeOriginElement=r);let l=this.interaction.resizeOriginElement,c=pe(l)?l:r,u=NR(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=PR(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=Vc(++this.nextId),a=this.snapActive()?t8(n,this.snapSpacing()):n,r=fD(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.maybeRevertToolAfterCreate(),this.notify()}nextFrameName(){return lR(this._scene)}assignFrameMembers(t,n){this._scene=cR(this._scene,this._history,t,n)}reconcileFrameMembership(){this._scene=uR(this._scene,this._history)}applyCreateLink(t){let n=this.snapLinkEndpoint(t.fromElement,t.fromPoint),o=this.snapLinkEndpoint(t.toElement,t.toPoint),a=Qp(++this.nextId),r=$p(this._scene,n,o,a,this._activeLayerId);this._scene=r.scene,this._history.push(r.patch),this.edgePreview=null,this.maybeRevertToolAfterCreate(),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(!ue(this._scene,n.linkId)){this.interaction.pendingLinkDropMenu=null,this.notify();return}let a=Vc(++this.nextId),r=SD(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=gt,this.notify()}dismissLinkDropMenu(){this.interaction.pendingLinkDropMenu&&(this.interaction.pendingLinkDropMenu=null,this.notify())}createLinkedElementFromAnchor(t,n){let o=Vc(++this.nextId),a=Qp(++this.nextId),r=AD(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=gt),this.notify()}previewClickCreate(t,n){return bD(this._scene,this._activeLayerId,t,n)}snapLinkEndpoint(t,n){return cD(this._scene,this.snapEngine,this.snapThreshold,t,n)}applySelectByBounds(t,n){let o=GD(this._scene,this._selection,s=>this.isLayerLocked(s),t,n),a=$S(this._scene,n==="add"?this._selectedLinks:gt,s=>this.isLayerLocked(s),t,n),r=!Xp(a,this._selectedLinks);if(this._selectedLinks=a,li(o,this._selection)&&!r){this.notify();return}this._selection=o,this.notify()}applyLassoLiveSelection(t,n){let o=this.interaction.lassoBaseSelection??Pe,a=WD(this._scene,o,l=>this.isLayerLocked(l),t,n),r=this.interaction.lassoBaseLinks??gt,s=$S(this._scene,r,l=>this.isLayerLocked(l),t,n),i=!Xp(s,this._selectedLinks);li(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)}get isDraggingLabel(){return this.linkHandles.isDraggingLabel}beginLabelDrag(t){this.linkHandles.beginLabelDrag(t)}updateLabelDrag(t){this.linkHandles.updateLabelDrag(t)}endLabelDrag(){this.linkHandles.endLabelDrag()}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:ue(this._scene,t)?.avoidObstacles===!0}setSelectedLinkAvoidObstacles(t){if(this.readOnly)return;let n=this.selectedLink;if(n===null)return;let o=ue(this._scene,n);if(!o||o.avoidObstacles===t)return;let a=Ye(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=PA(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=BD(this._scene,t,n,o);if(bi==="orthogonal"){let r=this.hitTest(a.to),s=r.kind==="element"?r.id:null,i=Cv(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,Lc(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){SR(this.containerOpsRef,t)}maybeGrowContainer(t,n){jp(this.containerOpsRef,t,n)}clampContainerToChildren(t,n,o){return vR(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(),fR(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=pp(this._scene,t);return n?(this._scene=J(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=zD(this._scene,o);if(this.elbowRoutes.get(n)?.sig===a)continue;let r=mp(t,o);this.elbowRoutes.set(n,{sig:a,points:r}),t=Ye(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>=jv?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.activeTool.type,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.activeTool.type==="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();DD(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?.()}},$V=e=>!e||typeof e!="object"?!1:typeof e.push=="function"&&typeof e.undo=="function"&&typeof e.redo=="function"&&typeof e.transaction=="function";var oL=P(se(),1),Xc=P(re(),1),mg=({open:e,onClose:t,title:n="Dialog",children:o,dismissOnBackdrop:a=!0,className:r,style:s})=>{let i=(0,Xc.useRef)(null),l=(0,Xc.useRef)(null);if((0,Xc.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,Xc.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,oL.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":n,style:c,onClick:d=>{a&&d.target===d.currentTarget&&t()},children:(0,oL.jsx)("div",{ref:i,tabIndex:-1,className:r,style:u,onClick:d=>{d.stopPropagation()},children:o})})};var QV={history:"History",selection:"Selection",clipboard:"Clipboard","z-order":"Z-order",grouping:"Grouping",zoom:"Zoom",tool:"Tools",layout:"Layout",arrange:"Arrange",edit:"Editing",other:"Other"},JV=["tool","edit","selection","clipboard","history","z-order","grouping","arrange","layout","zoom","other"],aL=e=>{(0,Yc.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])},ej=e=>{let t=[],n=e.hotkey??e.displayHotkey;if(n){let o=Array.isArray(n)?n:[n];for(let a of o)t.push(Wy(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},eh=({registry:e=we,open:t,onClose:n,title:o="Keyboard shortcuts",extraSections:a})=>{let r=(0,Yc.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:ej(d)}),c.set(f,p)}let u=[];for(let d of JV){let f=c.get(d);!f||f.length===0||u.push({title:QV[d],rows:f})}return a&&u.push(...a),u},[e,a]),s={maxWidth:jE,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,Ke.jsx)(mg,{open:t,onClose:n,title:o,style:s,children:(0,Ke.jsxs)("div",{children:[(0,Ke.jsxs)("div",{style:i,children:[(0,Ke.jsx)("h2",{style:{margin:0,fontSize:16,fontWeight:600},children:o}),(0,Ke.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:12},children:[(0,Ke.jsx)("span",{className:"du-help-platform-badge",children:ls?"macOS":"Win / Linux"}),(0,Ke.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,Ke.jsx)(Fa,{size:18,strokeWidth:1.75})})]})]}),(0,Ke.jsx)("div",{style:l,children:(0,Ke.jsx)("div",{className:"du-help-islands",children:r.map(c=>(0,Ke.jsxs)("section",{className:"du-help-island",children:[(0,Ke.jsx)("h3",{className:"du-help-island-title",children:c.title}),(0,Ke.jsx)("div",{className:"du-help-island-rows",children:c.rows.map(u=>(0,Ke.jsxs)("div",{className:"du-help-row",children:[(0,Ke.jsx)("span",{className:"du-help-row-label",children:u.label}),(0,Ke.jsx)(tj,{combos:u.keys})]},u.label))})]},c.title))})})]})})},tj=({combos:e})=>e.length===0?(0,Ke.jsx)("span",{className:"du-help-keys-separator",children:"\u2014"}):(0,Ke.jsx)("span",{className:"du-help-keys",children:e.map((t,n)=>(0,Ke.jsxs)(Yc.Fragment,{children:[n>0?(0,Ke.jsx)("span",{className:"du-help-keys-separator",children:"or"}):null,t.map((o,a)=>(0,Ke.jsx)("kbd",{className:"du-help-key",children:o},a))]},n))});var nj=16,oj=1.75,yg=({renderDialog:e})=>{let[t,n]=(0,n8.useState)(!1);return(0,cs.jsxs)(cs.Fragment,{children:[(0,cs.jsx)(Jn,{label:"Help",onClick:()=>{n(!0)},children:(0,cs.jsx)(Cn,{size:nj,strokeWidth:oj})}),e?e({open:t,onClose:()=>{n(!1)}}):(0,cs.jsx)(eh,{open:t,onClose:()=>{n(!1)}})]})};var ah=P(se(),1),a8=P(re(),1);var th=P(re(),1);var o8=`(pointer: coarse), (max-width: ${WE}px)`,aj=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(o8).matches:!1,nh=()=>(0,th.useSyncExternalStore)(e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};let t=window.matchMedia(o8);return t.addEventListener("change",e),()=>{t.removeEventListener("change",e)}},aj,()=>!1),U=()=>Qb(),rj=mv(),$a=()=>sn(e=>e.scene,rj,"scene"),gg=()=>sn(e=>e.selection,Zo.EMPTY,"selection"),sj={type:"select",locked:!1,lastActiveTool:null},oh=()=>sn(e=>e.activeTool,sj,"tool"),rL=()=>sn(e=>e.brushSettings,qc),us=()=>sn(e=>e.readOnly,!1),sL=()=>{let e=U(),t=sn(r=>r.canUndo,!1,"history"),n=sn(r=>r.canRedo,!1,"history"),o=(0,th.useCallback)(()=>{e?.undo()},[e]),a=(0,th.useCallback)(()=>{e?.redo()},[e]);return{canUndo:t,canRedo:n,undo:o,redo:a}};var K0e=cn(On);var iL=()=>sn(e=>e.selectedLink,null);var ij=14,lj=1.75,lL=()=>{let e=U(),t=$a(),n=(0,a8.useMemo)(()=>cj(t),[t]);return!e||t.elements.size===0||!n?null:(0,ah.jsxs)("button",{type:"button",className:"du-pill-button",onClick:()=>{e.zoomToFit()},title:"Reset view to fit all content",children:[(0,ah.jsx)(nf,{size:ij,strokeWidth:lj,"aria-hidden":!0}),(0,ah.jsx)("span",{children:"Back to content"})]})},cj=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=N(c);n=n?j.union(n,u):u}if(!n)return!1;let o=Va(t),a=z.applyToPoint(o,{x:0,y:0}),r=z.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),Ji=P(re(),1);var xt=P(se(),1),uo=P(re(),1);var xg=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()}},Bi=new xg;var rye={...Yr.rectangle},sye={...Yr.sticky},iye={...Yr.flowchart};var cL=(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 T={};yo(T,{BRAND:()=>Pj,DIRTY:()=>Ni,EMPTY_PATH:()=>pj,INVALID:()=>Z,NEVER:()=>bZ,OK:()=>Wt,ParseStatus:()=>Bt,Schema:()=>le,ZodAny:()=>ps,ZodArray:()=>tr,ZodBigInt:()=>Fi,ZodBoolean:()=>Hi,ZodBranded:()=>sh,ZodCatch:()=>$i,ZodDate:()=>Ui,ZodDefault:()=>Ki,ZodDiscriminatedUnion:()=>vg,ZodEffects:()=>co,ZodEnum:()=>Xi,ZodError:()=>pn,ZodFirstPartyTypeKind:()=>Y,ZodFunction:()=>Lg,ZodIntersection:()=>Vi,ZodIssueCode:()=>D,ZodLazy:()=>ji,ZodLiteral:()=>Zi,ZodMap:()=>tu,ZodNaN:()=>ou,ZodNativeEnum:()=>Yi,ZodNever:()=>Io,ZodNull:()=>Wi,ZodNullable:()=>sa,ZodNumber:()=>zi,ZodObject:()=>hn,ZodOptional:()=>io,ZodParsedType:()=>H,ZodPipeline:()=>ih,ZodPromise:()=>hs,ZodReadonly:()=>Qi,ZodRecord:()=>Sg,ZodSchema:()=>le,ZodSet:()=>nu,ZodString:()=>fs,ZodSymbol:()=>Jc,ZodTransformer:()=>co,ZodTuple:()=>ra,ZodType:()=>le,ZodUndefined:()=>Gi,ZodUnion:()=>qi,ZodUnknown:()=>er,ZodVoid:()=>eu,addIssueToContext:()=>F,any:()=>qj,array:()=>Xj,bigint:()=>Fj,boolean:()=>m8,coerce:()=>xZ,custom:()=>f8,date:()=>Hj,datetimeRegex:()=>u8,defaultErrorMap:()=>Qa,discriminatedUnion:()=>Qj,effect:()=>uZ,enum:()=>iZ,function:()=>aZ,getErrorMap:()=>Kc,getParsedType:()=>aa,instanceof:()=>Nj,intersection:()=>Jj,isAborted:()=>bg,isAsync:()=>$c,isDirty:()=>Ag,isValid:()=>ds,late:()=>Bj,lazy:()=>rZ,literal:()=>sZ,makeIssue:()=>rh,map:()=>nZ,nan:()=>zj,nativeEnum:()=>lZ,never:()=>jj,null:()=>Wj,nullable:()=>fZ,number:()=>h8,object:()=>Yj,objectUtil:()=>uL,oboolean:()=>gZ,onumber:()=>yZ,optional:()=>dZ,ostring:()=>mZ,pipeline:()=>hZ,preprocess:()=>pZ,promise:()=>cZ,quotelessJson:()=>uj,record:()=>tZ,set:()=>oZ,setErrorMap:()=>fj,strictObject:()=>Kj,string:()=>p8,symbol:()=>Uj,transformer:()=>uZ,tuple:()=>eZ,undefined:()=>Gj,union:()=>$j,unknown:()=>Vj,util:()=>he,void:()=>Zj});var he;(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})(he||(he={}));var uL;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(uL||(uL={}));var H=he.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),aa=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=he.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"]),uj=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,he.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 dj=(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,he.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:n=`Unrecognized key(s) in object: ${he.joinValues(e.keys,", ")}`;break;case D.invalid_union:n="Invalid input";break;case D.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${he.joinValues(e.options)}`;break;case D.invalid_enum_value:n=`Invalid enum value. Expected ${he.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}"`:he.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,he.assertNever(e)}return{message:n}},Qa=dj;var r8=Qa;function fj(e){r8=e}function Kc(){return r8}var rh=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}},pj=[];function F(e,t){let n=Kc(),o=rh({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Qa?void 0:Qa].filter(a=>!!a)});e.common.issues.push(o)}var Bt=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"}),Ni=e=>({status:"dirty",value:e}),Wt=e=>({status:"valid",value:e}),bg=e=>e.status==="aborted",Ag=e=>e.status==="dirty",ds=e=>e.status==="valid",$c=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 lo=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}},s8=(e,t)=>{if(ds(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 aa(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:aa(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Bt,ctx:{common:t.parent.common,data:t.data,parsedType:aa(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if($c(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:aa(t)},a=this._parseSync({data:t,path:o.path,parent:o});return s8(o,a)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:aa(t)};if(!this["~standard"].async)try{let o=this._parseSync({data:t,path:[],parent:n});return ds(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=>ds(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:aa(t)},a=this._parse({data:t,path:o.path,parent:o}),r=await($c(a)?a:Promise.resolve(a));return s8(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 co({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 io.create(this,this._def)}nullable(){return sa.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return tr.create(this)}promise(){return hs.create(this,this._def)}or(t){return qi.create([this,t],this._def)}and(t){return Vi.create(this,t,this._def)}transform(t){return new co({...ae(this._def),schema:this,typeName:Y.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new Ki({...ae(this._def),innerType:this,defaultValue:n,typeName:Y.ZodDefault})}brand(){return new sh({typeName:Y.ZodBranded,type:this,...ae(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new $i({...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 ih.create(this,t)}readonly(){return Qi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},hj=/^c[^\s-]{8,}$/i,mj=/^[0-9a-z]+$/,yj=/^[0-9A-HJKMNP-TV-Z]{26}$/i,gj=/^[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,xj=/^[a-z0-9_-]{21}$/i,bj=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Aj=/^[-+]?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)?)??$/,vj=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Sj="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",dL,Lj=/^(?:(?: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])$/,kj=/^(?:(?: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])$/,_j=/^(([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]))$/,wj=/^(([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])$/,Tj=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ej=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,l8="((\\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])))",Cj=new RegExp(`^${l8}$`);function c8(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 Ij(e){return new RegExp(`^${c8(e)}$`)}function u8(e){let t=`${l8}T${c8(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 Mj(e,t){return!!((t==="v4"||!t)&&Lj.test(e)||(t==="v6"||!t)&&_j.test(e))}function Rj(e,t){if(!bj.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 Oj(e,t){return!!((t==="v4"||!t)&&kj.test(e)||(t==="v6"||!t)&&wj.test(e))}var fs=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 Bt,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")vj.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")dL||(dL=new RegExp(Sj,"u")),dL.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")gj.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")xj.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")hj.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")mj.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")yj.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"?u8(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"?Cj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{code:D.invalid_string,validation:"date",message:r.message}),o.dirty()):r.kind==="time"?Ij(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"?Aj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"duration",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="ip"?Mj(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"?Rj(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"?Oj(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"?Tj.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"base64",code:D.invalid_string,message:r.message}),o.dirty()):r.kind==="base64url"?Ej.test(t.data)||(a=this._getOrReturnCtx(t,a),F(a,{validation:"base64url",code:D.invalid_string,message:r.message}),o.dirty()):he.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}};fs.create=e=>new fs({checks:[],typeName:Y.ZodString,coerce:e?.coerce??!1,...ae(e)});function Dj(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 zi=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 Bt;for(let r of this._def.checks)r.kind==="int"?he.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"?Dj(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()):he.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"&&he.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)}};zi.create=e=>new zi({checks:[],typeName:Y.ZodNumber,coerce:e?.coerce||!1,...ae(e)});var Fi=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 Bt;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()):he.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}};Fi.create=e=>new Fi({checks:[],typeName:Y.ZodBigInt,coerce:e?.coerce??!1,...ae(e)});var Hi=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 Wt(t.data)}};Hi.create=e=>new Hi({typeName:Y.ZodBoolean,coerce:e?.coerce||!1,...ae(e)});var Ui=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 Bt,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()):he.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}};Ui.create=e=>new Ui({checks:[],coerce:e?.coerce||!1,typeName:Y.ZodDate,...ae(e)});var Jc=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 Wt(t.data)}};Jc.create=e=>new Jc({typeName:Y.ZodSymbol,...ae(e)});var Gi=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 Wt(t.data)}};Gi.create=e=>new Gi({typeName:Y.ZodUndefined,...ae(e)});var Wi=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 Wt(t.data)}};Wi.create=e=>new Wi({typeName:Y.ZodNull,...ae(e)});var ps=class extends le{constructor(){super(...arguments),this._any=!0}_parse(t){return Wt(t.data)}};ps.create=e=>new ps({typeName:Y.ZodAny,...ae(e)});var er=class extends le{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Wt(t.data)}};er.create=e=>new er({typeName:Y.ZodUnknown,...ae(e)});var Io=class extends le{_parse(t){let n=this._getOrReturnCtx(t);return F(n,{code:D.invalid_type,expected:H.never,received:n.parsedType}),Z}};Io.create=e=>new Io({typeName:Y.ZodNever,...ae(e)});var eu=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 Wt(t.data)}};eu.create=e=>new eu({typeName:Y.ZodVoid,...ae(e)});var tr=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 lo(n,s,n.path,i)))).then(s=>Bt.mergeArray(o,s));let r=[...n.data].map((s,i)=>a.type._parseSync(new lo(n,s,n.path,i)));return Bt.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)}};tr.create=(e,t)=>new tr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Y.ZodArray,...ae(t)});function Qc(e){if(e instanceof hn){let t={};for(let n in e.shape){let o=e.shape[n];t[n]=io.create(Qc(o))}return new hn({...e._def,shape:()=>t})}else return e instanceof tr?new tr({...e._def,type:Qc(e.element)}):e instanceof io?io.create(Qc(e.unwrap())):e instanceof sa?sa.create(Qc(e.unwrap())):e instanceof ra?ra.create(e.items.map(t=>Qc(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=he.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 Io&&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 lo(a,d,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof Io){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 lo(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=>Bt.mergeObjectSync(o,c)):Bt.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 he.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 he.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new e({...this._def,shape:()=>n})}deepPartial(){return Qc(this)}partial(t){let n={};for(let o of he.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 he.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let r=this.shape[o];for(;r instanceof io;)r=r._def.innerType;n[o]=r}return new e({...this._def,shape:()=>n})}keyof(){return d8(he.objectKeys(this.shape))}};hn.create=(e,t)=>new hn({shape:()=>e,unknownKeys:"strip",catchall:Io.create(),typeName:Y.ZodObject,...ae(t)});hn.strictCreate=(e,t)=>new hn({shape:()=>e,unknownKeys:"strict",catchall:Io.create(),typeName:Y.ZodObject,...ae(t)});hn.lazycreate=(e,t)=>new hn({shape:e,unknownKeys:"strip",catchall:Io.create(),typeName:Y.ZodObject,...ae(t)});var qi=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}};qi.create=(e,t)=>new qi({options:e,typeName:Y.ZodUnion,...ae(t)});var Ja=e=>e instanceof ji?Ja(e.schema):e instanceof co?Ja(e.innerType()):e instanceof Zi?[e.value]:e instanceof Xi?e.options:e instanceof Yi?he.objectValues(e.enum):e instanceof Ki?Ja(e._def.innerType):e instanceof Gi?[void 0]:e instanceof Wi?[null]:e instanceof io?[void 0,...Ja(e.unwrap())]:e instanceof sa?[null,...Ja(e.unwrap())]:e instanceof sh||e instanceof Qi?Ja(e.unwrap()):e instanceof $i?Ja(e._def.innerType):[],vg=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=Ja(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 fL(e,t){let n=aa(e),o=aa(t);if(e===t)return{valid:!0,data:e};if(n===H.object&&o===H.object){let a=he.objectKeys(t),r=he.objectKeys(e).filter(i=>a.indexOf(i)!==-1),s={...e,...t};for(let i of r){let l=fL(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=fL(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 Vi=class extends le{_parse(t){let{status:n,ctx:o}=this._processInputParams(t),a=(r,s)=>{if(bg(r)||bg(s))return Z;let i=fL(r.value,s.value);return i.valid?((Ag(r)||Ag(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}))}};Vi.create=(e,t,n)=>new Vi({left:e,right:t,typeName:Y.ZodIntersection,...ae(n)});var ra=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 lo(o,s,o.path,i)):null}).filter(s=>!!s);return o.common.async?Promise.all(r).then(s=>Bt.mergeArray(n,s)):Bt.mergeArray(n,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};ra.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ra({items:e,typeName:Y.ZodTuple,rest:null,...ae(t)})};var Sg=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 lo(o,i,o.path,i)),value:s._parse(new lo(o,o.data[i],o.path,i)),alwaysSet:i in o.data});return o.common.async?Bt.mergeObjectAsync(n,a):Bt.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:fs.create(),valueType:t,typeName:Y.ZodRecord,...ae(n)})}},tu=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 lo(o,i,o.path,[c,"key"])),value:r._parse(new lo(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}}}};tu.create=(e,t,n)=>new tu({valueType:t,keyType:e,typeName:Y.ZodMap,...ae(n)});var nu=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 lo(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)}};nu.create=(e,t)=>new nu({valueType:e,minSize:null,maxSize:null,typeName:Y.ZodSet,...ae(t)});var Lg=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 rh({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Kc(),Qa].filter(c=>!!c),issueData:{code:D.invalid_arguments,argumentsError:l}})}function a(i,l){return rh({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Kc(),Qa].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 hs){let i=this;return Wt(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 Wt(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:ra.create(t).rest(er.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||ra.create([]).rest(er.create()),returns:n||er.create(),typeName:Y.ZodFunction,...ae(o)})}},ji=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})}};ji.create=(e,t)=>new ji({getter:e,typeName:Y.ZodLazy,...ae(t)});var Zi=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}};Zi.create=(e,t)=>new Zi({value:e,typeName:Y.ZodLiteral,...ae(t)});function d8(e,t){return new Xi({values:e,typeName:Y.ZodEnum,...ae(t)})}var Xi=class e extends le{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),o=this._def.values;return F(n,{expected:he.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 Wt(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})}};Xi.create=d8;var Yi=class extends le{_parse(t){let n=he.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==H.string&&o.parsedType!==H.number){let a=he.objectValues(n);return F(o,{expected:he.joinValues(a),received:o.parsedType,code:D.invalid_type}),Z}if(this._cache||(this._cache=new Set(he.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let a=he.objectValues(n);return F(o,{received:o.data,code:D.invalid_enum_value,options:a}),Z}return Wt(t.data)}get enum(){return this._def.values}};Yi.create=(e,t)=>new Yi({values:e,typeName:Y.ZodNativeEnum,...ae(t)});var hs=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 Wt(o.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};hs.create=(e,t)=>new hs({type:e,typeName:Y.ZodPromise,...ae(t)});var co=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"?Ni(l.value):n.value==="dirty"?Ni(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"?Ni(i.value):n.value==="dirty"?Ni(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(!ds(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=>ds(s)?Promise.resolve(a.transform(s.value,r)).then(i=>({status:n.value,value:i})):Z);he.assertNever(a)}};co.create=(e,t,n)=>new co({schema:e,typeName:Y.ZodEffects,effect:t,...ae(n)});co.createWithPreprocess=(e,t,n)=>new co({schema:t,effect:{type:"preprocess",transform:e},typeName:Y.ZodEffects,...ae(n)});var io=class extends le{_parse(t){return this._getType(t)===H.undefined?Wt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};io.create=(e,t)=>new io({innerType:e,typeName:Y.ZodOptional,...ae(t)});var sa=class extends le{_parse(t){return this._getType(t)===H.null?Wt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};sa.create=(e,t)=>new sa({innerType:e,typeName:Y.ZodNullable,...ae(t)});var Ki=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}};Ki.create=(e,t)=>new Ki({innerType:e,typeName:Y.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...ae(t)});var $i=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 $c(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}};$i.create=(e,t)=>new $i({innerType:e,typeName:Y.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...ae(t)});var ou=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}}};ou.create=e=>new ou({typeName:Y.ZodNaN,...ae(e)});var Pj=Symbol("zod_brand"),sh=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}},ih=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(),Ni(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})}},Qi=class extends le{_parse(t){let n=this._def.innerType._parse(t),o=a=>(ds(a)&&(a.value=Object.freeze(a.value)),a);return $c(n)?n.then(a=>o(a)):o(n)}unwrap(){return this._def.innerType}};Qi.create=(e,t)=>new Qi({innerType:e,typeName:Y.ZodReadonly,...ae(t)});function i8(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function f8(e,t={},n){return e?ps.create().superRefine((o,a)=>{let r=e(o);if(r instanceof Promise)return r.then(s=>{if(!s){let i=i8(t,o),l=i.fatal??n??!0;a.addIssue({code:"custom",...i,fatal:l})}});if(!r){let s=i8(t,o),i=s.fatal??n??!0;a.addIssue({code:"custom",...s,fatal:i})}}):ps.create()}var Bj={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 Nj=(e,t={message:`Input not instance of ${e.name}`})=>f8(n=>n instanceof e,t),p8=fs.create,h8=zi.create,zj=ou.create,Fj=Fi.create,m8=Hi.create,Hj=Ui.create,Uj=Jc.create,Gj=Gi.create,Wj=Wi.create,qj=ps.create,Vj=er.create,jj=Io.create,Zj=eu.create,Xj=tr.create,Yj=hn.create,Kj=hn.strictCreate,$j=qi.create,Qj=vg.create,Jj=Vi.create,eZ=ra.create,tZ=Sg.create,nZ=tu.create,oZ=nu.create,aZ=Lg.create,rZ=ji.create,sZ=Zi.create,iZ=Xi.create,lZ=Yi.create,cZ=hs.create,uZ=co.create,dZ=io.create,fZ=sa.create,pZ=co.createWithPreprocess,hZ=ih.create,mZ=()=>p8().optional(),yZ=()=>h8().optional(),gZ=()=>m8().optional(),xZ={string:(e=>fs.create({...e,coerce:!0})),number:(e=>zi.create({...e,coerce:!0})),boolean:(e=>Hi.create({...e,coerce:!0})),bigint:(e=>Fi.create({...e,coerce:!0})),date:(e=>Ui.create({...e,coerce:!0}))};var bZ=Z;var AZ=["basic","layout","flowchart","custom","rich"],pL=({registry:e=Bi,categories:t=AZ,collapsedByDefault:n=[],searchQuery:o,layout:a="grid",style:r,className:s})=>{let i=a==="list"?"du-palette-list":"du-palette-grid",l=(0,uo.useMemo)(()=>new Set(e.categories()),[e]),c=(0,uo.useMemo)(()=>t.filter(x=>l.has(x)),[t,l]),u=(0,uo.useMemo)(()=>c.map(x=>({category:x,items:e.byCategory(x)})),[e,c]),[d,f]=(0,uo.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,uo.useMemo)(()=>{if(!h)return[];let x=[];for(let{items:y}of u)for(let g of y)cL(g,h)&&x.push(g);return x},[u,h]);return(0,xt.jsx)("aside",{className:`du-palette ${s??""}`.trim(),style:r,children:(0,xt.jsx)("div",{className:"du-palette-body",children:h?m.length===0?(0,xt.jsxs)("div",{className:"du-palette-empty",children:["No templates match \u201C",h,"\u201D"]}):(0,xt.jsx)("div",{className:i,children:m.map(x=>(0,xt.jsx)(b8,{template:x},x.id))}):u.map(({category:x,items:y})=>(0,xt.jsx)(vZ,{category:x,items:y,itemsClass:i,collapsed:d.has(x),onToggle:()=>{p(x)}},x))})})},vZ=({category:e,items:t,itemsClass:n,collapsed:o,onToggle:a})=>t.length===0?null:(0,xt.jsxs)("section",{className:"du-palette-section",children:[(0,xt.jsxs)("button",{type:"button",onClick:a,"aria-expanded":!o,className:"du-palette-category",children:[(0,xt.jsx)("span",{children:e}),(0,xt.jsx)("span",{className:"du-palette-category-caret","aria-hidden":!0,children:o?(0,xt.jsx)($s,{size:12,strokeWidth:1.75}):(0,xt.jsx)(Bd,{size:12,strokeWidth:1.75})})]}),o?null:(0,xt.jsx)("div",{className:n,children:t.map(r=>(0,xt.jsx)(b8,{template:r},r.id))})]}),lh=null,g8=vS(),y8=e=>{lh!==e&&(lh=e,g8.emit())};var x8=e=>g8.add(e);var kg=null,SZ=()=>{if(typeof document>"u")return null;if(kg&&document.body.contains(kg))return kg;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),kg=e,e},b8=({template:e})=>{let t=U(),n=r=>{r.dataTransfer.setData("application/x-template-id",e.id),r.dataTransfer.effectAllowed="copy";let s=SZ();s&&r.dataTransfer.setDragImage(s,0,0),y8(e)},o=()=>{y8(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:On,position:i,order:Ae([...t.scene.elements.values()].filter(d=>d.layerId===On).map(d=>d.order))}),u=t.beginPlacement(c);u.update(i),u.commit()};return(0,xt.jsxs)("div",{role:"button",draggable:!0,title:e.name,onDragStart:n,onDragEnd:o,onClick:a,className:"du-palette-item",children:[(0,xt.jsx)("span",{className:"du-palette-item-icon",style:{width:lA,height:lA},dangerouslySetInnerHTML:{__html:e.icon}}),(0,xt.jsx)("span",{className:"du-palette-item-label",children:e.name})]})},hL=()=>{let e=U(),t=(0,uo.useRef)(null);(0,uo.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,uo.useEffect)(()=>x8(()=>{lh===null&&t.current&&(t.current.cancel(),t.current=null)}),[]);let n=a=>{if(t.current||!e||!lh)return!1;let r=lh,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:On,position:l,order:Ae([...e.scene.elements.values()].filter(d=>d.layerId===On).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 _S(r,{onError:(c,u)=>{console.warn(`[file-drop] failed at ${c}:`,u)}}))e.dispatchFileDrop(l,i)})()}}};var mL=14,yL=1.75,_g=({open:e,onClose:t,side:n="right",sheet:o=!1,onImport:a,style:r})=>{let[s,i]=(0,Ji.useState)("");(0,Ji.useEffect)(()=>{e||i("")},[e]);let l=(0,Ji.useRef)(null);return(0,Ji.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)(Jn,{label:"Import templates",size:"sm",onClick:a,children:(0,mn.jsx)(wf,{size:mL,strokeWidth:yL})}):null,(0,mn.jsx)(Jn,{label:"Close library",size:"sm",onClick:t,children:(0,mn.jsx)(Fa,{size:mL,strokeWidth:yL})})]})}),(0,mn.jsxs)("div",{className:"du-side-panel-search",children:[(0,mn.jsx)(xf,{size:mL,strokeWidth:yL,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)(pL,{searchQuery:s,layout:"list"})})]}):null};var gh=P(se(),1);var au=Math.min,nr=Math.max,uh=Math.round,dh=Math.floor,Mo=e=>({x:e,y:e}),LZ={left:"right",right:"left",bottom:"top",top:"bottom"};function gL(e,t,n){return nr(e,au(t,n))}function fh(e,t){return typeof e=="function"?e(t):e}function ms(e){return e.split("-")[0]}function ph(e){return e.split("-")[1]}function xL(e){return e==="x"?"y":"x"}function bL(e){return e==="y"?"height":"width"}function or(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function AL(e){return xL(or(e))}function S8(e,t,n){n===void 0&&(n=!1);let o=ph(e),a=AL(e),r=bL(a),s=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(s=ch(s)),[s,ch(s)]}function L8(e){let t=ch(e);return[wg(e),t,wg(t)]}function wg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var A8=["left","right"],v8=["right","left"],kZ=["top","bottom"],_Z=["bottom","top"];function wZ(e,t,n){switch(e){case"top":case"bottom":return n?t?v8:A8:t?A8:v8;case"left":case"right":return t?kZ:_Z;default:return[]}}function k8(e,t,n,o){let a=ph(e),r=wZ(ms(e),n==="start",o);return a&&(r=r.map(s=>s+"-"+a),t&&(r=r.concat(r.map(wg)))),r}function ch(e){let t=ms(e);return LZ[t]+e.slice(t.length)}function TZ(e){return{top:0,right:0,bottom:0,left:0,...e}}function _8(e){return typeof e!="number"?TZ(e):{top:e,right:e,bottom:e,left:e}}function el(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 w8(e,t,n){let{reference:o,floating:a}=e,r=or(t),s=AL(t),i=bL(s),l=ms(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(ph(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 T8(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}=fh(t,e),h=_8(p),x=i[f?d==="floating"?"reference":"floating":d],y=el(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},_=el(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 EZ=50,E8=async(e,t,n)=>{let{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:s}=n,i=s.detectOverflow?s:{...s,detectOverflow:T8},l=await(s.isRTL==null?void 0:s.isRTL(t)),c=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:u,y:d}=w8(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:C}=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],..._},C&&p<EZ&&(p++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:a}):C.rects),{x:u,y:d}=w8(c,f,l)),m=-1)}return{x:u,y:d,placement:f,strategy:a,middlewareData:h}};var C8=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}=fh(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let y=ms(a),g=or(i),b=ms(i)===i,A=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=f||(b||!m?[ch(i)]:L8(i)),C=h!=="none";!f&&C&&_.push(...k8(i,m,h,A));let w=[i,..._],L=await l.detectOverflow(t,x),k=[],M=((o=r.flip)==null?void 0:o.overflows)||[];if(u&&k.push(L[y]),d){let ne=S8(a,s,A);k.push(L[ne[0]],L[ne[1]])}if(M=[...M,{placement:a,overflows:k}],!k.every(ne=>ne<=0)){var B,G;let ne=(((B=r.flip)==null?void 0:B.index)||0)+1,V=w[ne];if(V&&(!(d==="alignment"?g!==or(V):!1)||M.every(ee=>or(ee.placement)===g?ee.overflows[0]>0:!0)))return{data:{index:ne,overflows:M},reset:{placement:V}};let ve=(G=M.filter(ge=>ge.overflows[0]<=0).sort((ge,ee)=>ge.overflows[1]-ee.overflows[1])[0])==null?void 0:G.placement;if(!ve)switch(p){case"bestFit":{var ie;let ge=(ie=M.filter(ee=>{if(C){let Se=or(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];ge&&(ve=ge);break}case"initialPlacement":ve=i;break}if(a!==ve)return{reset:{placement:ve}}}return{}}}};var CZ=new Set(["left","top"]);async function IZ(e,t){let{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),s=ms(n),i=ph(n),l=or(n)==="y",c=CZ.has(s)?-1:1,u=r&&l?-1:1,d=fh(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 I8=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 IZ(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}}}}},M8=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}=fh(e,t),u={x:n,y:o},d=await r.detectOverflow(t,c),f=or(ms(a)),p=xL(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=gL(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=gL(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 Tg(){return typeof window<"u"}function nl(e){return O8(e)?(e.nodeName||"").toLowerCase():"#document"}function yn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ro(e){var t;return(t=(O8(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function O8(e){return Tg()?e instanceof Node||e instanceof yn(e).Node:!1}function fo(e){return Tg()?e instanceof Element||e instanceof yn(e).Element:!1}function ia(e){return Tg()?e instanceof HTMLElement||e instanceof yn(e).HTMLElement:!1}function R8(e){return!Tg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yn(e).ShadowRoot}function su(e){let{overflow:t,overflowX:n,overflowY:o,display:a}=po(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&a!=="inline"&&a!=="contents"}function D8(e){return/^(table|td|th)$/.test(nl(e))}function hh(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var MZ=/transform|translate|scale|rotate|perspective|filter/,RZ=/paint|layout|strict|content/,tl=e=>!!e&&e!=="none",vL;function Eg(e){let t=fo(e)?po(e):e;return tl(t.transform)||tl(t.translate)||tl(t.scale)||tl(t.rotate)||tl(t.perspective)||!Cg()&&(tl(t.backdropFilter)||tl(t.filter))||MZ.test(t.willChange||"")||RZ.test(t.contain||"")}function P8(e){let t=ar(e);for(;ia(t)&&!ol(t);){if(Eg(t))return t;if(hh(t))return null;t=ar(t)}return null}function Cg(){return vL==null&&(vL=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),vL}function ol(e){return/^(html|body|#document)$/.test(nl(e))}function po(e){return yn(e).getComputedStyle(e)}function mh(e){return fo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ar(e){if(nl(e)==="html")return e;let t=e.assignedSlot||e.parentNode||R8(e)&&e.host||Ro(e);return R8(t)?t.host:t}function B8(e){let t=ar(e);return ol(t)?e.ownerDocument?e.ownerDocument.body:e.body:ia(t)&&su(t)?t:B8(t)}function ru(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=yn(a);if(r){let i=Ig(s);return t.concat(s,s.visualViewport||[],su(a)?a:[],i&&n?ru(i):[])}else return t.concat(a,ru(a,[],n))}function Ig(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function H8(e){let t=po(e),n=parseFloat(t.width)||0,o=parseFloat(t.height)||0,a=ia(e),r=a?e.offsetWidth:n,s=a?e.offsetHeight:o,i=uh(n)!==r||uh(o)!==s;return i&&(n=r,o=s),{width:n,height:o,$:i}}function LL(e){return fo(e)?e:e.contextElement}function iu(e){let t=LL(e);if(!ia(t))return Mo(1);let n=t.getBoundingClientRect(),{width:o,height:a,$:r}=H8(t),s=(r?uh(n.width):n.width)/o,i=(r?uh(n.height):n.height)/a;return(!s||!Number.isFinite(s))&&(s=1),(!i||!Number.isFinite(i))&&(i=1),{x:s,y:i}}var OZ=Mo(0);function U8(e){let t=yn(e);return!Cg()||!t.visualViewport?OZ:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function DZ(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yn(e)?!1:t}function al(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),r=LL(e),s=Mo(1);t&&(o?fo(o)&&(s=iu(o)):s=iu(e));let i=DZ(r,n,o)?U8(r):Mo(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&&fo(o)?yn(o):o,h=f,m=Ig(h);for(;m&&o&&p!==h;){let x=iu(m),y=m.getBoundingClientRect(),g=po(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=Ig(h)}}return el({width:u,height:d,x:l,y:c})}function Mg(e,t){let n=mh(e).scrollLeft;return t?t.left+n:al(Ro(e)).left+n}function G8(e,t){let n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-Mg(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function PZ(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e,r=a==="fixed",s=Ro(o),i=t?hh(t.floating):!1;if(o===s||i&&r)return n;let l={scrollLeft:0,scrollTop:0},c=Mo(1),u=Mo(0),d=ia(o);if((d||!d&&!r)&&((nl(o)!=="body"||su(s))&&(l=mh(o)),d)){let p=al(o);c=iu(o),u.x=p.x+o.clientLeft,u.y=p.y+o.clientTop}let f=s&&!d&&!r?G8(s,l):Mo(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 BZ(e){return Array.from(e.getClientRects())}function NZ(e){let t=Ro(e),n=mh(e),o=e.ownerDocument.body,a=nr(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),r=nr(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight),s=-n.scrollLeft+Mg(e),i=-n.scrollTop;return po(o).direction==="rtl"&&(s+=nr(t.clientWidth,o.clientWidth)-a),{width:a,height:r,x:s,y:i}}var N8=25;function zZ(e,t){let n=yn(e),o=Ro(e),a=n.visualViewport,r=o.clientWidth,s=o.clientHeight,i=0,l=0;if(a){r=a.width,s=a.height;let u=Cg();(!u||u&&t==="fixed")&&(i=a.offsetLeft,l=a.offsetTop)}let c=Mg(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<=N8&&(r-=h)}else c<=N8&&(r+=c);return{width:r,height:s,x:i,y:l}}function FZ(e,t){let n=al(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=ia(e)?iu(e):Mo(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 z8(e,t,n){let o;if(t==="viewport")o=zZ(e,n);else if(t==="document")o=NZ(Ro(e));else if(fo(t))o=FZ(t,n);else{let a=U8(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return el(o)}function W8(e,t){let n=ar(e);return n===t||!fo(n)||ol(n)?!1:po(n).position==="fixed"||W8(n,t)}function HZ(e,t){let n=t.get(e);if(n)return n;let o=ru(e,[],!1).filter(i=>fo(i)&&nl(i)!=="body"),a=null,r=po(e).position==="fixed",s=r?ar(e):e;for(;fo(s)&&!ol(s);){let i=po(s),l=Eg(s);!l&&i.position==="fixed"&&(a=null),(r?!l&&!a:!l&&i.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||su(s)&&!l&&W8(e,s))?o=o.filter(u=>u!==s):a=i,s=ar(s)}return t.set(e,o),o}function UZ(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e,s=[...n==="clippingAncestors"?hh(t)?[]:HZ(t,this._c):[].concat(n),o],i=z8(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=z8(t,s[f],a);l=nr(p.top,l),c=au(p.right,c),u=au(p.bottom,u),d=nr(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function GZ(e){let{width:t,height:n}=H8(e);return{width:t,height:n}}function WZ(e,t,n){let o=ia(t),a=Ro(t),r=n==="fixed",s=al(e,!0,r,t),i={scrollLeft:0,scrollTop:0},l=Mo(0);function c(){l.x=Mg(a)}if(o||!o&&!r)if((nl(t)!=="body"||su(a))&&(i=mh(t)),o){let p=al(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?G8(a,i):Mo(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 SL(e){return po(e).position==="static"}function F8(e,t){if(!ia(e)||po(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ro(e)===n&&(n=n.ownerDocument.body),n}function q8(e,t){let n=yn(e);if(hh(e))return n;if(!ia(e)){let a=ar(e);for(;a&&!ol(a);){if(fo(a)&&!SL(a))return a;a=ar(a)}return n}let o=F8(e,t);for(;o&&D8(o)&&SL(o);)o=F8(o,t);return o&&ol(o)&&SL(o)&&!Eg(o)?n:o||P8(e)||n}var qZ=async function(e){let t=this.getOffsetParent||q8,n=this.getDimensions,o=await n(e.floating);return{reference:WZ(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function VZ(e){return po(e).direction==="rtl"}var jZ={convertOffsetParentRelativeRectToViewportRelativeRect:PZ,getDocumentElement:Ro,getClippingRect:UZ,getOffsetParent:q8,getElementRects:qZ,getClientRects:BZ,getDimensions:GZ,getScale:iu,isElement:fo,isRTL:VZ};function V8(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ZZ(e,t){let n=null,o,a=Ro(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=dh(d),m=dh(a.clientWidth-(u+f)),x=dh(a.clientHeight-(d+p)),y=dh(u),b={rootMargin:-h+"px "+-m+"px "+-x+"px "+-y+"px",threshold:nr(0,au(1,l))||1},A=!0;function _(C){let w=C[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 Rg(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=LL(e),u=a||r?[...c?ru(c):[],...t?ru(t):[]]:[];u.forEach(y=>{a&&y.addEventListener("scroll",n,{passive:!0}),r&&y.addEventListener("resize",n)});let d=c&&i?ZZ(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?al(e):null;l&&x();function x(){let y=al(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 Og=I8;var Dg=M8,Pg=C8;var Bg=(e,t,n)=>{let o=new Map,a={platform:jZ,...n},r={...a.platform,_c:o};return E8(e,t,{...a,platform:r})};var la=P(re(),1),TL=P(ya(),1);var S=P(se(),1),gs=P(re(),1);var j8=P(se(),1),ys=P(re(),1),Z8=(0,ys.createContext)(null),X8=({children:e})=>{let t=(0,ys.useRef)(null),n=(0,ys.useMemo)(()=>({open:o=>t.current?.(o),register:o=>(t.current=o,()=>{t.current===o&&(t.current=null)})}),[]);return(0,j8.jsx)(Z8.Provider,{value:n,children:e})},Ng=()=>(0,ys.useContext)(Z8);var Nt=P(se(),1),$8=P(re(),1);var XZ=Xr.map(e=>cc.light[e].fill),YZ=Xr.map(e=>cc.light[e].solid),KZ=Xr.map(e=>cc.dark[e].fill),$Z=Xr.map(e=>cc.dark[e].solid),QZ=Xr.map(e=>R0.light[e]),JZ=Xr.map(e=>R0.dark[e]),Y8=[...XZ,...YZ,"#ffffff","#1e1e1e","transparent"],Age=[...KZ,...$Z,"#1e1e1e","#ffffff","transparent"],vge=["#ffffff",...QZ],Sge=["#121113",...JZ];var lu=({value:e,onChange:t,palette:n,allowCustom:o=!0,allowClear:a=!0,onEyedrop:r})=>{let s=n??Y8,[i,l]=(0,$8.useState)(!1);return(0,Nt.jsxs)("div",{className:"du-swatch-grid",role:"radiogroup","aria-label":"Colour",children:[s.map(c=>(0,Nt.jsx)(eX,{color:c,selected:K8(c)===K8(e),onClick:()=>{t(c==="transparent"?null:c)}},c)),o?(0,Nt.jsx)(tX,{value:e,onChange:t,open:i,onOpenChange:l}):null,r?(0,Nt.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,Nt.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,Nt.jsx)(hf,{size:12,strokeWidth:2})})}):null,a?(0,Nt.jsx)("button",{type:"button","aria-label":"Clear colour",title:"Clear colour",onClick:()=>{t(null)},className:"du-swatch du-swatch-clear",children:(0,Nt.jsx)("span",{className:"du-swatch-fill du-swatch-fill-blank",children:(0,Nt.jsx)(Fa,{size:12,strokeWidth:2})})}):null]})},eX=({color:e,selected:t,onClick:n})=>(0,Nt.jsx)("button",{type:"button",role:"radio","aria-checked":t,"aria-label":e,title:e,onClick:n,className:"du-swatch",children:(0,Nt.jsx)("span",{className:"du-swatch-fill",style:{background:e==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":e}})}),tX=({value:e,onChange:t,open:n,onOpenChange:o})=>{let a=!!e&&e!=="transparent";return(0,Nt.jsxs)("label",{className:"du-swatch du-swatch-custom",title:"Pick custom colour",children:[(0,Nt.jsx)("span",{className:"du-swatch-fill",style:a?{background:e}:void 0,children:a?null:(0,Nt.jsx)(ti,{size:12,strokeWidth:2})}),(0,Nt.jsx)("input",{type:"color","aria-label":"Custom colour",value:nX(e),onChange:r=>{t(r.target.value),o(!1)},onClick:()=>{o(!n)},className:"du-swatch-color-input"})]})},K8=e=>e===null?"transparent":e.toLowerCase(),nX=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"};var cu=P(se(),1);var bt=P(re(),1),Q8=P(ya(),1);var ho=({trigger:e,children:t,placement:n="bottom-start",offset:o=tC,className:a,open:r,onOpenChange:s,ariaLabel:i})=>{let l=Pt(),[c,u]=(0,bt.useState)(!1),d=r!==void 0,f=d?r:c,p=(0,bt.useCallback)(g=>{d||u(g),s?.(g)},[d,s]),h=(0,bt.useId)(),m=(0,bt.useRef)(null),x=(0,bt.useRef)(null);(0,bt.useLayoutEffect)(()=>{if(!f)return;let g=m.current,b=x.current;if(!g||!b)return;let A=()=>{Bg(g,b,{placement:n,middleware:[Og(o),Pg(),Dg({padding:6})]}).then(({x:C,y:w})=>{b.style.transform=`translate(${Math.round(C)}px, ${Math.round(w)}px)`})};return A(),Rg(g,b,A)},[f,n,o]),(0,bt.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,bt.useMemo)(()=>{if(!(0,bt.isValidElement)(e))return e;let g=e.props;return(0,bt.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,cu.jsxs)(cu.Fragment,{children:[y,f?(0,Q8.createPortal)((0,cu.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 _L=({style:e,className:t,mobile:n=!1})=>{let o=gg(),a=iL(),r=$a();if(us())return null;if(o.size>0){let i=[...o].map(h=>r.elements.get(h)).filter(h=>h!==void 0);if(i.length===0)return null;let l=i.every(h=>pe(h)),c=i.every(h=>ct(h)),u=i.every(h=>Mn(h)),d=i.every(h=>Be(h)),f=[],p=[];return d?f.push((0,S.jsx)(t6,{shapes:i},"fill")):l?(f.push((0,S.jsx)(rX,{shapes:i},"size"),(0,S.jsx)(aX,{shapes:i},"color"),(0,S.jsx)(iX,{shapes:i},"align")),p.push((0,S.jsx)(sX,{shapes:i},"family"),(0,S.jsx)(lX,{shapes:i},"decor"))):c?f.push((0,S.jsx)(n6,{shapes:i},"opacity"),(0,S.jsx)(yX,{shapes:i},"crop")):(f.push((0,S.jsx)(t6,{shapes:i},"fill"),(0,S.jsx)(cX,{shapes:i},"stroke"),u?(0,S.jsx)(uX,{shapes:i},"width"):(0,S.jsx)(dX,{shapes:i},"width")),p.push((0,S.jsx)(fX,{shapes:i},"dash"),(0,S.jsx)(pX,{shapes:i},"round"),(0,S.jsx)(n6,{shapes:i},"opacity"),(0,S.jsx)(mX,{shapes:i},"convert"))),p.push((0,S.jsx)(hX,{},"z"),(0,S.jsx)(oX,{shapes:i},"link")),i.length>=2&&p.push((0,S.jsx)(bX,{},"align")),p.push((0,S.jsx)(gX,{shapes:i},"actions"),(0,S.jsx)(e6,{},"more")),(0,S.jsx)(J8,{mobile:n,primary:f,overflow:p,className:t,style:e})}if(a!==null){let i=r.links.get(a);if(!i)return null;let l=[(0,S.jsx)(AX,{edge:i},"color"),(0,S.jsx)(vX,{edge:i},"width"),(0,S.jsx)(o6,{edge:i,side:"to"},"arrow-to")],c=[(0,S.jsx)(SX,{edge:i},"dash"),(0,S.jsx)(kX,{edge:i},"routing"),(0,S.jsx)(LX,{edge:i},"kind"),(0,S.jsx)(o6,{edge:i,side:"from"},"arrow-from"),(0,S.jsx)(_X,{edge:i},"auto"),(0,S.jsx)(wX,{},"delete"),(0,S.jsx)(e6,{},"more")];return(0,S.jsx)(J8,{mobile:n,primary:l,overflow:c,className:t,style:e})}return null},J8=({mobile:e,primary:t,overflow:n,className:o,style:a})=>{let[r,s]=(0,gs.useState)(!1),i=(0,gs.useRef)(null);return(0,gs.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)(Wr,{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)(CX,{}):null,n]})},oX=({shapes:e})=>{let t=U(),n=(0,gs.useRef)(null);if(!t)return null;let o=e.map(i=>i.id),a=yh(e,i=>i.href),r=e.some(i=>!!i.href),s=i=>{t.setLink(o,i)};return(0,S.jsx)(ho,{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)(tf,{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]})]})})},e6=()=>{let e=U(),t=Ng();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)(qr,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},wL=({label:e,color:t,onChange:n,ariaLabel:o,onEyedrop:a})=>(0,S.jsx)(ho,{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)(lu,{value:t,onChange:n,...a?{onEyedrop:a}:{}})]})}),s6=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||!pe(o)?null:{target:o,from:Math.min(n.start,n.end),to:Math.max(n.start,n.end)}},aX=({shapes:e})=>{let t=U(),n=s6(e);if(!t)return null;let o=e.map(l=>l.id),a=yh(e,l=>l.style.fill),r=Oo(e,l=>l.style.opacity??1),s=r===null?null:Math.round(r*100);return(0,S.jsx)(ho,{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:!a||a==="transparent"?"repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 50% / 6px 6px":a,opacity:r??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)(lu,{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,S.jsx)("header",{className:"du-sel-popover-label",children:"Opacity"}),(0,S.jsx)(Nf,{value:s,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:s===null?"\u2014":`${s}%`,onChange:l=>{t.updateStyle(o,{opacity:l/100})}})]})})},t6=({shapes:e})=>{let t=U();if(!t||!e.some(IX))return null;let n=yh(e,a=>a.style.fill),o=e.map(a=>a.id);return(0,S.jsx)(wL,{label:"Fill",ariaLabel:"Fill color",color:n,onChange:a=>{t.updateStyle(o,{fill:a??"transparent"})},onEyedrop:a=>{t.beginEyedropperPick(a)}})},rX=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(r=>r.id),o=Oo(e,r=>r.fontSize??null),a=o!==null&&cA.some(r=>r.value===o)?o:null;return(0,S.jsx)(ho,{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)(In,{ariaLabel:"Font size preset",value:a,options:cA.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)(Nf,{value:o,min:nC,max:oC,step:1,ariaLabel:"Font size",valueLabel:o===null?"\u2014":`${o}px`,onChange:r=>{t.updateTextProps(n,{fontSize:r})}})]})})},sX=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(s=>s.id),o=yh(e,s=>s.fontFamily),a=pA.find(s=>s.value===o),r=o===null?"Mixed":a?.label??"Custom";return(0,S.jsx)(ho,{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"}),pA.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))]})})},iX=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(a=>a.id),o=Oo(e,a=>a.style.textAlign??"left");return(0,S.jsx)(In,{ariaLabel:"Text alignment",value:o,options:[{value:"left",label:"Left",icon:(0,S.jsx)(vo,{size:14,strokeWidth:1.75})},{value:"center",label:"Center",icon:(0,S.jsx)(Zr,{size:14,strokeWidth:1.75})},{value:"right",label:"Right",icon:(0,S.jsx)(jr,{size:14,strokeWidth:1.75})}],onChange:a=>{t.updateStyle(n,{textAlign:a})}})},zg=({active:e,label:t,icon:n,onClick:o})=>(0,S.jsx)("button",{type:"button",className:`du-sel-icon-button${e?" is-active":""}`,title:t,"aria-label":t,"aria-pressed":e,onClick:o,children:n}),lX=({shapes:e})=>{let t=U(),n=s6(e);if(!t)return null;let o=e.map(p=>p.id),a=n?qf(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,S.jsx)(ho,{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)(Dd,{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)(zg,{active:i,label:"Bold",icon:(0,S.jsx)(Od,{size:14,strokeWidth:1.75}),onClick:()=>{d({fontWeight:i?"normal":"bold"})}}),(0,S.jsx)(zg,{active:l,label:"Italic",icon:(0,S.jsx)(Jd,{size:14,strokeWidth:1.75}),onClick:()=>{d({fontStyle:l?"normal":"italic"})}}),(0,S.jsx)(zg,{active:c,label:"Underline",icon:(0,S.jsx)(kf,{size:14,strokeWidth:1.75}),onClick:()=>{f("underline",!c)}}),(0,S.jsx)(zg,{active:u,label:"Strikethrough",icon:(0,S.jsx)(vf,{size:14,strokeWidth:1.75}),onClick:()=>{f("strikethrough",!u)}})]})]})})},cX=({shapes:e})=>{let t=U();if(!t||!e.some(l6))return null;let n=yh(e,a=>a.style.stroke),o=e.map(a=>a.id);return(0,S.jsx)(wL,{label:"Stroke",ariaLabel:"Stroke color",color:n,onChange:a=>{t.updateStyle(o,{stroke:a??"transparent"})},onEyedrop:a=>{t.beginEyedropperPick(a)}})},uX=({shapes:e})=>{let t=U();if(!t)return null;let n=e.map(a=>a.id),o=Oo(e,a=>{let r=a,s=r.baseWidth??r.points.reduce((i,l)=>Math.max(i,l.width),0);return s>0?Math.round(s):null});return(0,S.jsx)(ho,{ariaLabel:"Brush width",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Brush width","aria-label":"Brush width",children:(0,S.jsx)(rl,{thickness:2.5})}),children:(0,S.jsxs)("div",{className:"du-sel-popover-section",children:[(0,S.jsx)("header",{className:"du-sel-popover-label",children:`Width ${o!==null?String(o):"mixed"}`}),(0,S.jsx)("input",{type:"range",min:Df,max:O0,step:1,value:o??Df,onChange:a=>{t.setBrushWidth(n,a.currentTarget.valueAsNumber)},style:{width:"100%"},"aria-label":"Brush width"})]})})},dX=({shapes:e})=>{let t=U();if(!t||!e.some(a=>a.style.stroke!==void 0))return null;let n=Oo(e,a=>a.style.strokeWidth??null),o=e.map(a=>a.id);return(0,S.jsx)(In,{ariaLabel:"Stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,S.jsx)(rl,{thickness:1})},{value:2,label:"Medium",icon:(0,S.jsx)(rl,{thickness:2.5})},{value:4,label:"Thick",icon:(0,S.jsx)(rl,{thickness:4})}],onChange:a=>{t.updateStyle(o,{strokeWidth:a})}})},fX=({shapes:e})=>{let t=U();if(!t||!e.some(l6))return null;let n=Oo(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)(In,{ariaLabel:"Stroke style",value:n,options:[{value:"solid",label:"Solid",icon:(0,S.jsx)(qo,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,S.jsx)(Na,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,S.jsx)(za,{size:14,strokeWidth:1.75})}],onChange:a=>{let r=a==="solid"?[]:a==="dashed"?[8,4]:[2,4];t.updateStyle(o,{dashArray:r})}})},pX=({shapes:e})=>{let t=U();if(!t||!e.every(i=>fi(i)||i.type==="container"))return null;let o=Oo(e,i=>i.style.roundness?.type??"sharp"),a=Oo(e,i=>i.style.roundness?.value??null),r=e.map(i=>i.id),s=a===null;return(0,S.jsx)(ho,{ariaLabel:"Corners",trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:"Corners","aria-label":"Corners",children:(0,S.jsx)(kL,{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)(In,{ariaLabel:"Corner roundness",value:o,options:[{value:"sharp",label:"Sharp",icon:(0,S.jsx)(kL,{kind:"sharp"})},{value:"round",label:"Round",icon:(0,S.jsx)(kL,{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)(Nf,{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]})})},n6=({shapes:e})=>{let t=U();if(!t)return null;let n=Oo(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)(ho,{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)(Nf,{value:a,min:0,max:100,step:5,ariaLabel:"Opacity",valueLabel:r,onChange:s=>{t.updateStyle(o,{opacity:s/100})}})]})})},hX=()=>{let e=U();return e?(0,S.jsx)(In,{ariaLabel:"Z-order",value:null,options:[{value:"back",label:"Send to back",icon:(0,S.jsx)(Nd,{size:14,strokeWidth:1.75})},{value:"backward",label:"Send backward",icon:(0,S.jsx)(df,{size:14,strokeWidth:1.75})},{value:"forward",label:"Bring forward",icon:(0,S.jsx)(pf,{size:14,strokeWidth:1.75})},{value:"front",label:"Bring to front",icon:(0,S.jsx)(zd,{size:14,strokeWidth:1.75})}],onChange:t=>{t==="back"?e.sendToBack():t==="backward"?e.sendBackward():t==="forward"?e.bringForward():e.bringToFront()}}):null},mX=({shapes:e})=>{let t=U();if(!t||!e.every(a=>fi(a)||mc(a)||Ga(a)))return null;let o=Oo(e,a=>fi(a)?"rectangle":mc(a)?"ellipse":"polygon");return(0,S.jsx)(In,{ariaLabel:"Shape type",value:o,options:[{value:"rectangle",label:"Rectangle",icon:(0,S.jsx)(qo,{size:14,strokeWidth:1.75})},{value:"ellipse",label:"Ellipse",icon:(0,S.jsx)(Qs,{size:14,strokeWidth:1.75})},{value:"polygon",label:"Diamond",icon:(0,S.jsx)(Gd,{size:14,strokeWidth:1.75})}],onChange:a=>{t.convertSelection(a)}})},yX=({shapes:e})=>{let t=U();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,S.jsx)("button",{type:"button",className:"du-icon-button",title:"Crop image (double-click)","aria-label":"Crop image",onClick:()=>{t.beginImageCrop(o)},children:(0,S.jsx)(Hd,{size:16,strokeWidth:1.75})})},gX=({shapes:e})=>{let t=U();if(!t)return null;let n=e.length>=2,o=e.some(r=>ze(r)),a=[{value:"duplicate",label:"Duplicate",icon:(0,S.jsx)(Gr,{size:14,strokeWidth:1.75})},{value:"delete",label:"Delete",icon:(0,S.jsx)(rc,{size:14,strokeWidth:1.75})}];return n&&a.push({value:"group",label:"Group",icon:(0,S.jsx)($d,{size:14,strokeWidth:1.75})}),o&&a.push({value:"ungroup",label:"Ungroup",icon:(0,S.jsx)(_f,{size:14,strokeWidth:1.75})}),a.push({value:"flip-h",label:"Flip horizontal",icon:(0,S.jsx)(Zd,{size:14,strokeWidth:1.75})},{value:"flip-v",label:"Flip vertical",icon:(0,S.jsx)(Xd,{size:14,strokeWidth:1.75})}),(0,S.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")}})},xX=[{edge:"left",label:"Align left",icon:(0,S.jsx)(Md,{size:16,strokeWidth:1.75})},{edge:"h-center",label:"Align horizontal centres",icon:(0,S.jsx)(nc,{size:16,strokeWidth:1.75})},{edge:"right",label:"Align right",icon:(0,S.jsx)(Ed,{size:16,strokeWidth:1.75})},{edge:"top",label:"Align top",icon:(0,S.jsx)(Id,{size:16,strokeWidth:1.75})},{edge:"v-center",label:"Align vertical centres",icon:(0,S.jsx)(wd,{size:16,strokeWidth:1.75})},{edge:"bottom",label:"Align bottom",icon:(0,S.jsx)(Td,{size:16,strokeWidth:1.75})}],bX=()=>{let e=U(),t=gg();if(!e)return null;let n=t.size>=3;return(0,S.jsx)(ho,{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)(nc,{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:xX.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)(Cd,{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)(Rd,{size:16,strokeWidth:1.75})})]})]}):null]})})},AX=({edge:e})=>{let t=U();if(!t)return null;let n=typeof e.style.stroke=="string"?e.style.stroke:null;return(0,S.jsx)(wL,{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)}})},vX=({edge:e})=>{let t=U();if(!t)return null;let n=typeof e.style.strokeWidth=="number"?e.style.strokeWidth:null;return(0,S.jsx)(In,{ariaLabel:"Link stroke width",value:n,options:[{value:1,label:"Thin",icon:(0,S.jsx)(rl,{thickness:1})},{value:2,label:"Medium",icon:(0,S.jsx)(rl,{thickness:2.5})},{value:4,label:"Thick",icon:(0,S.jsx)(rl,{thickness:4})}],onChange:o=>{t.updateSelectedLink(a=>({...a,style:{...a.style,strokeWidth:o}}))}})},SX=({edge:e})=>{let t=U();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)(In,{ariaLabel:"Link stroke style",value:o,options:[{value:"solid",label:"Solid",icon:(0,S.jsx)(qo,{size:14,strokeWidth:1.75})},{value:"dashed",label:"Dashed",icon:(0,S.jsx)(Na,{size:14,strokeWidth:1.75})},{value:"dotted",label:"Dotted",icon:(0,S.jsx)(za,{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}}))}})},LX=({edge:e})=>{let t=U();if(!t)return null;let n=e.lineKind??"line";return(0,S.jsx)(In,{ariaLabel:"Link body",value:n,options:[{value:"line",label:"Line",icon:(0,S.jsx)(Ba,{size:14,strokeWidth:1.75})},{value:"block-arrow",label:"Block arrow",icon:(0,S.jsx)(ff,{size:14,strokeWidth:2.5})}],onChange:o=>{t.updateSelectedLink(a=>({...a,lineKind:o}))}})},kX=({edge:e})=>{let t=U();if(!t)return null;let n=e.routing??"straight";return(0,S.jsx)(In,{ariaLabel:"Link routing",value:n,options:[{value:"straight",label:"Straight",icon:(0,S.jsx)(a6,{kind:"straight"})},{value:"orthogonal",label:"Elbow",icon:(0,S.jsx)(a6,{kind:"orthogonal"})},{value:"bezier",label:"Curved",icon:(0,S.jsx)(Af,{size:14,strokeWidth:1.75})}],onChange:o=>{t.updateSelectedLink(a=>({...a,routing:o}))}})},o6=({edge:e,side:t})=>{let n=U(),[o,a]=(0,gs.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:Fg[l],"aria-label":Fg[l],"aria-pressed":l===r,onClick:()=>{s(l)},children:l==="none"?(0,S.jsx)("span",{className:"du-arrowhead-none",children:"\u2205"}):i6(l)==="none"?(0,S.jsx)("span",{className:"du-arrowhead-erd-label",children:Fg[l].replace(/^ERD /,"")}):(0,S.jsx)(r6,{kind:l,side:t})});return(0,S.jsx)(ho,{trigger:(0,S.jsx)("button",{type:"button",className:"du-sel-icon-button",title:`Arrow ${t}: ${Fg[r]}`,"aria-label":`Arrow ${t}`,children:(0,S.jsx)(r6,{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:TX.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:EX.map(l=>(0,S.jsx)(i,{style:l},l))})]})})},_X=({edge:e})=>{let t=U();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)(Tf,{size:14,strokeWidth:1.75,"aria-hidden":!0})})},wX=()=>{let e=U();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)(rc,{size:14,strokeWidth:1.75,"aria-hidden":!0})}):null},a6=({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"})}),i6=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"}},TX=["none","arrow","openArrow","roundedArrow","arcArrow","filledArrow","triangle","circle","filledCircle","rhombus","filledRhombus"],EX=["erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"],Fg={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"},r6=({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=i6(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]})},CX=()=>(0,S.jsx)("span",{className:"du-sel-divider","aria-hidden":!0}),rl=({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"})}),kL=({kind:e})=>e==="sharp"?(0,S.jsx)(qo,{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})}),Oo=(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},yh=(e,t)=>{let n=Oo(e,o=>t(o));return typeof n=="string"?n:null},IX=e=>e.style.fill!==void 0||Be(e),l6=e=>e.style.stroke!==void 0;var EL=({offset:e=KE,placement:t="top",edgeInset:n}={})=>{let o={top:n?.top??$E,right:n?.right??QE,bottom:n?.bottom??JE,left:n?.left??eC},a=U(),r=us(),s=Pt(),i=nh(),[l,c]=(0,la.useState)(!1),u=(0,la.useRef)(null),[d,f]=(0,la.useState)(0),[p,h]=(0,la.useState)(!1);return(0,la.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,la.useLayoutEffect)(()=>{if(!a||!l||i)return;let m=u.current;if(!m)return;let x=MX(a);if(!x)return;let y=()=>{Bg(x,m,{placement:t,middleware:[Og(e),Pg({fallbackPlacements:["bottom","right","left"],padding:o}),Dg({padding:o})]}).then(({x:b,y:A})=>{m.style.transform=`translate(${Math.round(b)}px, ${Math.round(A)}px)`,h(!0)})};return y(),Rg(x,m,y)},[a,l,i,d,e,t,o.top,o.right,o.bottom,o.left]),!a||!l||r?null:i?(0,TL.createPortal)((0,gh.jsx)("div",{className:"du-sel-panel-dock",role:"toolbar","aria-label":"Selection actions",children:(0,gh.jsx)(_L,{mobile:!0})}),s):(0,TL.createPortal)((0,gh.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,gh.jsx)(_L,{})}),s)},MX=e=>{let t=e.hostElement;return t?{getBoundingClientRect:()=>{let n=RX(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},RX=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 ss(e.scene,a)}return null}let n=null;for(let o of t){if(ze(o)&&e.scene.elements.has(o.id)){let r=WA(e.scene,o.id);for(let s of r){if(ze(s))continue;let i;try{i=N(s)}catch{continue}i.width===0&&i.height===0||(n=c6(n,i))}continue}let a;try{a=N(o)}catch{continue}n=c6(n,a)}return n},c6=(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 bs=P(se(),1),Le=P(re(),1);var uu="Roboto",xh="PT Serif",bh="Roboto Mono",du=e=>{let t=e.toLowerCase();return t.includes("mono")?bh:t.includes("sans")?uu:t.includes("serif")||t.includes("slab")||t.includes("georgia")||t.includes("times")?xh:uu},OX=[{family:uu,weight:"400",style:"normal",url:new URL("../fonts/Roboto-Regular.woff2",import.meta.url)},{family:uu,weight:"700",style:"normal",url:new URL("../fonts/Roboto-Bold.woff2",import.meta.url)},{family:uu,weight:"400",style:"italic",url:new URL("../fonts/Roboto-Italic.woff2",import.meta.url)},{family:uu,weight:"700",style:"italic",url:new URL("../fonts/Roboto-BoldItalic.woff2",import.meta.url)},{family:xh,weight:"400",style:"normal",url:new URL("../fonts/PTSerif-Regular.woff2",import.meta.url)},{family:xh,weight:"700",style:"normal",url:new URL("../fonts/PTSerif-Bold.woff2",import.meta.url)},{family:xh,weight:"400",style:"italic",url:new URL("../fonts/PTSerif-Italic.woff2",import.meta.url)},{family:xh,weight:"700",style:"italic",url:new URL("../fonts/PTSerif-BoldItalic.woff2",import.meta.url)},{family:bh,weight:"400",style:"normal",url:new URL("../fonts/RobotoMono-Regular.woff2",import.meta.url)},{family:bh,weight:"700",style:"normal",url:new URL("../fonts/RobotoMono-Bold.woff2",import.meta.url)},{family:bh,weight:"400",style:"italic",url:new URL("../fonts/RobotoMono-Italic.woff2",import.meta.url)},{family:bh,weight:"700",style:"italic",url:new URL("../fonts/RobotoMono-BoldItalic.woff2",import.meta.url)}],u6=async(e=globalThis)=>{let t=e.fonts;!t||typeof FontFace>"u"||await Promise.allSettled(OX.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 DX=["HTMLImageElement","HTMLCanvasElement","HTMLVideoElement","ImageBitmap","OffscreenCanvas","SVGImageElement","VideoFrame"],fu=e=>{if(typeof e!="object"||e===null)return!1;let t=globalThis;for(let n of DX){let o=t[n];if(typeof o=="function"&&e instanceof o)return!0}return!1},Hg=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},d6=new Set,Ug=e=>{if(typeof console>"u")return;let t=typeof e=="string"?e.startsWith("blob:")?"dead-blob-url":"string-src":e==null?"empty":"stale-object";d6.has(t)||(d6.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 rr=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 "${du(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(!fu(t)){Ug(t);return}if(i&&(i.x!==0||i.y!==0||i.width!==1||i.height!==1)){let l=Hg(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 Ah=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 ML(e,t,n=2){let o=t&&t.length,a=o?t[0]*n:e.length,r=p6(e,0,a,n,!0),s=[];if(!r||r.next===r.prev)return s;let i,l,c;if(o&&(r=FX(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 Sh(r,s,n,i,l,c,0),s}function p6(e,t,n,o,a){let r;if(a===KX(e,t,n,o)>0)for(let s=t;s<n;s+=o)r=f6(s/o|0,e[s],e[s+1],r);else for(let s=n-o;s>=t;s-=o)r=f6(s/o|0,e[s],e[s+1],r);return r&&pu(r,r.next)&&(kh(r),r=r.next),r}function sl(e,t){if(!e)return e;t||(t=e);let n=e,o;do if(o=!1,!n.steiner&&(pu(n,n.next)||$e(n.prev,n,n.next)===0)){if(kh(n),n=t=n.prev,n===n.next)break;o=!0}else n=n.next;while(o||n!==t);return t}function Sh(e,t,n,o,a,r,s){if(!e)return;!s&&r&&qX(e,o,a,r);let i=e;for(;e.prev!==e.next;){let l=e.prev,c=e.next;if(r?BX(e,o,a,r):PX(e)){t.push(l.i,e.i,c.i),kh(e),e=c.next,i=c.next;continue}if(e=c,e===i){s?s===1?(e=NX(sl(e),t),Sh(e,t,n,o,a,r,2)):s===2&&zX(e,t,n,o,a,r):Sh(sl(e),t,n,o,a,r,1);break}}}function PX(e){let t=e.prev,n=e,o=e.next;if($e(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&&vh(a,i,r,l,s,c,h.x,h.y)&&$e(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function BX(e,t,n,o){let a=e.prev,r=e,s=e.next;if($e(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=CL(p,h,t,n,o),g=CL(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&&vh(i,u,l,d,c,f,b.x,b.y)&&$e(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&&vh(i,u,l,d,c,f,A.x,A.y)&&$e(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&&vh(i,u,l,d,c,f,b.x,b.y)&&$e(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&&vh(i,u,l,d,c,f,A.x,A.y)&&$e(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function NX(e,t){let n=e;do{let o=n.prev,a=n.next.next;!pu(o,a)&&m6(o,n,n.next,a)&&Lh(o,a)&&Lh(a,o)&&(t.push(o.i,n.i,a.i),kh(n),kh(n.next),n=e=a),n=n.next}while(n!==e);return sl(n)}function zX(e,t,n,o,a,r){let s=e;do{let i=s.next.next;for(;i!==s.prev;){if(s.i!==i.i&&ZX(s,i)){let l=y6(s,i);s=sl(s,s.next),l=sl(l,l.next),Sh(s,t,n,o,a,r,0),Sh(l,t,n,o,a,r,0);return}i=i.next}s=s.next}while(s!==e)}function FX(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=p6(e,i,l,o,!1);c===c.next&&(c.steiner=!0),a.push(jX(c))}a.sort(HX);for(let r=0;r<a.length;r++)n=UX(a[r],n);return n}function HX(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 UX(e,t){let n=GX(e,t);if(!n)return t;let o=y6(n,e);return sl(o,o.next),sl(n,n.next)}function GX(e,t){let n=t,o=e.x,a=e.y,r=-1/0,s;if(pu(e,n))return n;do{if(pu(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&&h6(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);Lh(n,e)&&(d<u||d===u&&(n.x>s.x||n.x===s.x&&WX(s,n)))&&(s=n,u=d)}n=n.next}while(n!==i);return s}function WX(e,t){return $e(e.prev,e,t.prev)<0&&$e(t.next,e,e.next)<0}function qX(e,t,n,o){let a=e;do a.z===0&&(a.z=CL(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,VX(a)}function VX(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 CL(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 jX(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 h6(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 vh(e,t,n,o,a,r,s,i){return!(e===s&&t===i)&&h6(e,t,n,o,a,r,s,i)}function ZX(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!XX(e,t)&&(Lh(e,t)&&Lh(t,e)&&YX(e,t)&&($e(e.prev,e,t.prev)||$e(e,t.prev,t))||pu(e,t)&&$e(e.prev,e,e.next)>0&&$e(t.prev,t,t.next)>0)}function $e(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function pu(e,t){return e.x===t.x&&e.y===t.y}function m6(e,t,n,o){let a=Wg($e(e,t,n)),r=Wg($e(e,t,o)),s=Wg($e(n,o,e)),i=Wg($e(n,o,t));return!!(a!==r&&s!==i||a===0&&Gg(e,n,t)||r===0&&Gg(e,o,t)||s===0&&Gg(n,e,o)||i===0&&Gg(n,t,o))}function Gg(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 XX(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&&m6(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Lh(e,t){return $e(e.prev,e,e.next)<0?$e(e,t,e.next)>=0&&$e(e,e.prev,t)>=0:$e(e,t,e.prev)<0||$e(e,e.next,t)<0}function YX(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 y6(e,t){let n=IL(e.i,e.x,e.y),o=IL(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 f6(e,t,n,o){let a=IL(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 kh(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 IL(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function KX(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 RL=e=>{if(e===null)return[0,0,0,0];try{let{r:t,g:n,b:o,a}=H0.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 ot=e=>{if(e===null)throw new Error("packages/renderer-canvas: WebGL resource creation failed");return e},zt=(e,t,n,o)=>{let a=ot(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},Do=(e,t,n,o)=>{let a=ot(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 _h=class{gl;program;vbo;vao;uTransform;uColor;uOpacity;uPxRange;uAtlas;constructor(t){this.gl=t;let n=zt(t,t.VERTEX_SHADER,tY,"MSDF"),o=zt(t,t.FRAGMENT_SHADER,nY,"MSDF");this.program=Do(t,n,o,"MSDF"),this.vbo=ot(t.createBuffer());let a=t.getAttribLocation(this.program,"aPos"),r=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"),this.vao=ot(t.createVertexArray()),t.bindVertexArray(this.vao),t.bindBuffer(t.ARRAY_BUFFER,this.vbo),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,16,0),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,16,8),t.bindVertexArray(null)}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;JX(f);let p=qg,h=0,m=n,x=!0;for(let w of t){let L=w.codePointAt(0);if(L===void 0)continue;let k=r.getOrRasterize(L,c);if(!k){x=!1;break}let M=k.advance*a/k.unitsPerEm;if(k.empty){m+=M;continue}QX(p,h,k,m,o,a,r),h+=u*d,m+=M}if(x&&a>0&&b6(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.bindVertexArray(this.vao),g.bindBuffer(g.ARRAY_BUFFER,this.vbo),g.bufferData(g.ARRAY_BUFFER,p.subarray(0,h),g.DYNAMIC_DRAW);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}}eY(g6,A,i.width,i.height),g.uniformMatrix3fv(this.uTransform,!1,g6),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,C=r.range*a/Math.max(1,_);return g.uniform1f(this.uPxRange,C),g.activeTexture(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,y),g.uniform1i(this.uAtlas,0),g.drawArrays(g.TRIANGLES,0,h/d),g.bindVertexArray(null),m-n}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteBuffer(this.vbo),this.gl.deleteProgram(this.program)}},$X=(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:_}},OL=new WeakMap,x6=(e,t)=>`${t}\0${e}`,b6=(e,t,n,o)=>{let a=OL.get(e);a||(a=new Map,OL.set(e,a));let r=x6(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)}},A6=(e,t,n=0)=>{if(e.length===0)return 0;let o=x6(e,n),a=OL.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 b6(t,e,n,r),r},QX=(e,t,n,o,a,r,s)=>{let{left:i,top:l,right:c,bottom:u,u0:d,v0:f,u1:p,v1:h}=$X(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)},qg=new Float32Array(512),g6=new Float32Array(9),JX=e=>{if(qg.length>=e)return;let t=qg.length;for(;t<e;)t*=2;qg=new Float32Array(t)},eY=(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},tY=`#version 300 es
|
|
17
17
|
in vec2 aPos;
|
|
18
18
|
in vec2 aUV;
|
|
19
19
|
uniform mat3 uTransform;
|
|
@@ -22,7 +22,7 @@ void main() {
|
|
|
22
22
|
vec3 p = uTransform * vec3(aPos, 1.0);
|
|
23
23
|
gl_Position = vec4(p.xy, 0.0, 1.0);
|
|
24
24
|
vUV = aUV;
|
|
25
|
-
}`,
|
|
25
|
+
}`,nY=`#version 300 es
|
|
26
26
|
precision mediump float;
|
|
27
27
|
uniform vec3 uColor;
|
|
28
28
|
uniform float uOpacity;
|
|
@@ -48,7 +48,7 @@ void main() {
|
|
|
48
48
|
// contract + blendFunc(ONE, 1-SRC_ALPHA).
|
|
49
49
|
float a = alpha * uOpacity;
|
|
50
50
|
fragColor = vec4(uColor * a, a);
|
|
51
|
-
}`;var
|
|
51
|
+
}`;var oY=10,S6=12,Vg=new Float32Array(64),L6=new Float32Array(64),mo=new Float32Array(1024),ca=0,aY=e=>{if(Vg.length>=e)return;let t=Vg.length;for(;t<e;)t*=2;Vg=new Float32Array(t),L6=new Float32Array(t)},rY=e=>{if(mo.length>=e)return;let t=mo.length;for(;t<e;)t*=2;let n=new Float32Array(t);n.set(mo.subarray(0,ca)),mo=n},sY=(e,t)=>{ca+2>mo.length&&rY(ca+2),mo[ca++]=e,mo[ca++]=t},iY=(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*oY);return{ox:r*u,oy:s*u}},k6=(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;aY(h);let m=Vg,x=L6;for(let L=0;L<h;L++){let k=v(t[L*2+2])-v(t[L*2]),M=v(t[L*2+3])-v(t[L*2+1]),B=Math.hypot(k,M)||1;m[L]=-M/B,x[L]=k/B}let y=n>=3&&t[0]===t[(n-1)*2]&&t[1]===t[(n-1)*2+1];ca=0;let g=sY,b=(L,k,M,B,G,ie,ne,V)=>{g(L+M,k+B),g(L-M,k-B),g(G+ne,ie+V),g(G+ne,ie+V),g(L-M,k-B),g(G-ne,ie-V)},A=L=>({ox:v(m[L])*p,oy:v(x[L])*p});for(let L=0;L<h;L++){let k=A(L);b(v(t[L*2]),v(t[L*2+1]),k.ox,k.oy,v(t[L*2+2]),v(t[L*2+3]),k.ox,k.oy)}let _=(L,k,M,B,G,ie)=>{if(o.join==="miter"){let{ox:ne,oy:V}=iY(M,B,G,ie,p),ve=M*ie-B*G;if(Math.abs(ve)<1e-9)return;let ge=ve<0?1:-1,ee=L+ge*ne,Se=k+ge*V,Oe=ge*M*p,qt=ge*B*p,xn=ge*G*p,Bo=ge*ie*p;g(L,k),g(L+Oe,k+qt),g(ee,Se),g(L,k),g(ee,Se),g(L+xn,k+Bo)}else if(o.join==="bevel"){let ne=M*ie-B*G;if(Math.abs(ne)<1e-9)return;let V=ne<0?1:-1,ve=L+V*M*p,ge=k+V*B*p,ee=L+V*G*p,Se=k+V*ie*p;g(L,k),g(ve,ge),g(ee,Se)}else{let ne=M*ie-B*G;if(Math.abs(ne)<1e-9)return;let V=ne<0?1:-1,ve=Math.atan2(V*B,V*M),ee=Math.atan2(V*ie,V*G)-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*S6)),Oe=L+Math.cos(ve)*p,qt=k+Math.sin(ve)*p;for(let xn=1;xn<=Se;xn++){let Bo=xn/Se,St=ve+ee*Bo,Wh=L+Math.cos(St)*p,qh=k+Math.sin(St)*p;g(L,k),g(Oe,qt),g(Wh,qh),Oe=Wh,qt=qh}}};for(let L=1;L<h;L++)_(v(t[L*2]),v(t[L*2+1]),v(m[L-1]),v(x[L-1]),v(m[L]),v(x[L]));if(y&&_(v(t[0]),v(t[1]),v(m[h-1]),v(x[h-1]),v(m[0]),v(x[0])),y||(v6(g,v(t[0]),v(t[1]),v(t[2]),v(t[3]),v(m[0]),v(x[0]),p,o.cap,!0),v6(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)),ca===0)return;let C=2/r.width,w=-2/r.height;for(let L=0;L<ca;L+=2){let k=v(mo[L]),M=v(mo[L+1]),B=a.a*k+a.c*M+a.e,G=a.b*k+a.d*M+a.f;mo[L]=B*C-1,mo[L+1]=G*w+1}e.useProgram(s),e.bindVertexArray(d),e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,mo.subarray(0,ca),e.DYNAMIC_DRAW),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,ca/2),e.bindVertexArray(null)},v6=(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 L={x:t+r*i,y:n+s*i},k={x:t-r*i,y:n-s*i},M={x:L.x+x*i,y:L.y+y*i},B={x:k.x+x*i,y:k.y+y*i};e(L.x,L.y),e(M.x,M.y),e(k.x,k.y),e(k.x,k.y),e(M.x,M.y),e(B.x,B.y);return}let g=Math.atan2(s,r),b=S6,_=r*y-s*x>=0?1:-1,C=t+Math.cos(g)*i,w=n+Math.sin(g)*i;for(let L=1;L<=b;L++){let k=L/b,M=g+_*Math.PI*k,B=t+Math.cos(M)*i,G=n+Math.sin(M)*i;e(t,n),e(C,w),e(B,G),C=B,w=G}};var w6=(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=un.cubicAt(e,t,n,o,c),f=un.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 wh=class{positionsBuf=new Float32Array(_6*6);uvsBuf=new Float32Array(_6*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 w6(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}},_6=64;var Eh=class{gl;program;vbo;uvBuf;vao;uTransform;uColor;uOpacity;constructor(t){this.gl=t;let n=zt(t,t.VERTEX_SHADER,yY,"Loop-Blinn"),o=zt(t,t.FRAGMENT_SHADER,gY,"Loop-Blinn");this.program=Do(t,n,o,"Loop-Blinn"),this.vbo=ot(t.createBuffer()),this.uvBuf=ot(t.createBuffer());let a=t.getAttribLocation(this.program,"aPos"),r=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"),this.vao=ot(t.createVertexArray()),t.bindVertexArray(this.vao),t.bindBuffer(t.ARRAY_BUFFER,this.vbo),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,0,0),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuf),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,3,t.FLOAT,!1,0,0),t.bindVertexArray(null)}draw(t,n,o,a,r){if(t.length===0||o<=0)return;let{positions:s,uvs:i}=mY(t);if(s.length===0)return;let l=this.gl;l.useProgram(this.program),l.bindVertexArray(this.vao),l.bindBuffer(l.ARRAY_BUFFER,this.vbo),l.bufferData(l.ARRAY_BUFFER,s,l.DYNAMIC_DRAW),l.bindBuffer(l.ARRAY_BUFFER,this.uvBuf),l.bufferData(l.ARRAY_BUFFER,i,l.DYNAMIC_DRAW),l.uniformMatrix3fv(this.uTransform,!1,cY(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),l.bindVertexArray(null)}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteBuffer(this.vbo),this.gl.deleteBuffer(this.uvBuf),this.gl.deleteProgram(this.program)}},ua=new Float32Array(9),cY=(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},xs=new Map,il=new Float64Array(64),uY=e=>{if(il.length>=e)return;let t=il.length;for(;t<e;)t*=2;il=new Float64Array(t)},E6=new Float64Array(1),T6=new Uint32Array(E6.buffer),Th=new wh,dY=e=>{uY(e.length*9);let t=il,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},fY=(e,t)=>{let n=2166136261;for(let o=0;o<t;o++)E6[0]=e[o]??0,n=Math.imul(n^(T6[0]??0),16777619),n=Math.imul(n^(T6[1]??0),16777619);return n>>>0},pY=(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},hY=(e,t)=>{Th.reset();for(let n of e)if(n.kind==="q"){let[o,a,r]=n.points;if(!o||!a||!r)continue;Th.addQuadratic(o,a,r)}else{let[o,a,r,s]=n.points;if(!o||!a||!r||!s)continue;Th.addCubic(o,a,r,s)}return{key:il.slice(0,t),positions:new Float32Array(Th.positions),uvs:new Float32Array(Th.uvs)}},mY=e=>{let t=dY(e),n=fY(il,t),o=xs.get(n);if(o&&pY(o.key,il,t))return xs.delete(n),xs.set(n,o),o;let a=hY(e,t);for(xs.delete(n),xs.set(n,a);xs.size>4096;){let r=xs.keys().next().value;if(r===void 0)break;xs.delete(r)}return a},yY=`#version 300 es
|
|
52
52
|
in vec2 aPos;
|
|
53
53
|
in vec3 aUVW;
|
|
54
54
|
uniform mat3 uTransform;
|
|
@@ -57,7 +57,7 @@ void main() {
|
|
|
57
57
|
vec3 p = uTransform * vec3(aPos, 1.0);
|
|
58
58
|
gl_Position = vec4(p.xy, 0.0, 1.0);
|
|
59
59
|
vUVW = aUVW;
|
|
60
|
-
}`,
|
|
60
|
+
}`,gY=`#version 300 es
|
|
61
61
|
precision mediump float;
|
|
62
62
|
uniform vec3 uColor;
|
|
63
63
|
uniform float uOpacity;
|
|
@@ -80,7 +80,7 @@ void main() {
|
|
|
80
80
|
// contract + blendFunc(ONE, 1-SRC_ALPHA).
|
|
81
81
|
float a = coverage * uOpacity;
|
|
82
82
|
fragColor = vec4(uColor * a, a);
|
|
83
|
-
}`;var da=new Float32Array(9),
|
|
83
|
+
}`;var da=new Float32Array(9),Ch=class{gl;program;vbo;vao;uTransform;uColor;uOpacity;constructor(t){this.gl=t;let n=zt(t,t.VERTEX_SHADER,xY,"Ellipse"),o=zt(t,t.FRAGMENT_SHADER,bY,"Ellipse");this.program=Do(t,n,o,"Ellipse");let a=t.getAttribLocation(this.program,"aPos"),r=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=ot(t.createBuffer()),this.vao=ot(t.createVertexArray()),t.bindVertexArray(this.vao),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),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,16,0),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,16,8),t.bindVertexArray(null)}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.bindVertexArray(this.vao);let u=2*o,d=2*a,f=t-o,p=n-a,h=2/l.width,m=-2/l.height,x=i;da[0]=x.a*u*h,da[1]=x.b*u*m,da[2]=0,da[3]=x.c*d*h,da[4]=x.d*d*m,da[5]=0,da[6]=(x.a*f+x.c*p+x.e)*h-1,da[7]=(x.b*f+x.d*p+x.f)*m+1,da[8]=1,c.uniformMatrix3fv(this.uTransform,!1,da),c.uniform3f(this.uColor,r[0],r[1],r[2]),c.uniform1f(this.uOpacity,s),c.drawArrays(c.TRIANGLE_STRIP,0,4),c.bindVertexArray(null)}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteBuffer(this.vbo),this.gl.deleteProgram(this.program)}},xY=`#version 300 es
|
|
84
84
|
in vec2 aPos;
|
|
85
85
|
in vec2 aLocal;
|
|
86
86
|
uniform mat3 uTransform;
|
|
@@ -89,7 +89,7 @@ void main() {
|
|
|
89
89
|
vec3 p = uTransform * vec3(aPos, 1.0);
|
|
90
90
|
gl_Position = vec4(p.xy, 0.0, 1.0);
|
|
91
91
|
vLocal = aLocal;
|
|
92
|
-
}`,
|
|
92
|
+
}`,bY=`#version 300 es
|
|
93
93
|
precision mediump float;
|
|
94
94
|
uniform vec3 uColor;
|
|
95
95
|
uniform float uOpacity;
|
|
@@ -102,7 +102,7 @@ void main() {
|
|
|
102
102
|
if (coverage <= 0.0) discard;
|
|
103
103
|
float a = coverage * uOpacity;
|
|
104
104
|
fragColor = vec4(uColor * a, a);
|
|
105
|
-
}`;var
|
|
105
|
+
}`;var Ih=10,jg=class{data;instanceCount=0;constructor(t=256){this.data=new Float32Array(Math.max(1,t)*Ih)}get pending(){return this.instanceCount}add(t,n,o,a,r,s,i,l,c,u){let d=(this.instanceCount+1)*Ih;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*Ih;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}},Mh=class{gl;program;vao;unitQuadVbo;instanceVbo;instanceBytes=0;constructor(t){this.gl=t;let n=zt(t,t.VERTEX_SHADER,AY,"RectInstance"),o=zt(t,t.FRAGMENT_SHADER,vY,"RectInstance");this.program=Do(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=ot(t.createVertexArray()),this.unitQuadVbo=ot(t.createBuffer()),this.instanceVbo=ot(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=Ih*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*Ih);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)}},AY=`#version 300 es
|
|
106
106
|
in vec2 aPos;
|
|
107
107
|
in vec2 aM0;
|
|
108
108
|
in vec2 aM1;
|
|
@@ -115,7 +115,7 @@ void main() {
|
|
|
115
115
|
vec2 p = aM0 * aPos.x + aM1 * aPos.y + aTrans;
|
|
116
116
|
gl_Position = vec4(p, 0.0, 1.0);
|
|
117
117
|
vColor = aColor;
|
|
118
|
-
}`,
|
|
118
|
+
}`,vY=`#version 300 es
|
|
119
119
|
precision mediump float;
|
|
120
120
|
in vec4 vColor;
|
|
121
121
|
out vec4 fragColor;
|
|
@@ -123,7 +123,7 @@ void main() {
|
|
|
123
123
|
// Premultiplied output (rgb*a, a) \u2014 matches premultipliedAlpha:true +
|
|
124
124
|
// blendFunc(ONE, 1-SRC_ALPHA).
|
|
125
125
|
fragColor = vec4(vColor.rgb * vColor.a, vColor.a);
|
|
126
|
-
}`;var qg=class{gl;program;vbo;dynamicVbo;dynamicVao;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(uY*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 Wg;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=zt(this.gl,this.gl.VERTEX_SHADER,mY,"WebGL2"),l=zt(this.gl,this.gl.FRAGMENT_SHADER,yY,"WebGL2");this.program=Do(this.gl,i,l,"WebGL2"),this.gl.useProgram(this.program),this.vbo=ot(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=ot(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.dynamicVao=ot(this.gl.createVertexArray()),this.gl.bindVertexArray(this.dynamicVao),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.dynamicVbo),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.vertexAttribPointer(this.aPosLoc,2,this.gl.FLOAT,!1,0,0),this.gl.bindVertexArray(null),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vbo),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.rectPipeline=new Eh(this.gl),this.curvePipeline=new _h(this.gl),this.ellipsePipeline=new wh(this.gl),this.msdfPipeline=new Sh(this.gl),this.ensureImageProgram(),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.deleteVertexArray(this.dynamicVao),this.gl.deleteBuffer(this.dynamicVbo),this.imageQuadVao&&(this.gl.deleteVertexArray(this.imageQuadVao),this.imageQuadVao=null),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=CL(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=Oy();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(f6(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=Oy();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(f6(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?d6:d6/t}drawImage(t,n,o,a,r,s,i){this.flushRectBatch();let l=this.textureFor(t,s??!1);if(!l)return;let c=this.ensureImageProgram();this.gl.useProgram(c.program),this.gl.bindVertexArray(this.imageQuadVao);let u=hY({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.gl.bindVertexArray(null),this.restoreSolidProgram()}imageProgram=null;ensureImageProgram(){return this.imageProgram?this.imageProgram:(this.imageProgram=pY(this.gl),this.imageQuadVbo=this.gl.createBuffer(),this.imageQuadVao=ot(this.gl.createVertexArray()),this.gl.bindVertexArray(this.imageQuadVao),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),this.gl.enableVertexAttribArray(this.imageProgram.aPos),this.gl.vertexAttribPointer(this.imageProgram.aPos,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(this.imageProgram.aUV),this.gl.vertexAttribPointer(this.imageProgram.aUV,2,this.gl.FLOAT,!1,16,8),this.gl.bindVertexArray(null),this.imageProgram)}imageQuadVbo=null;imageQuadVao=null;textures=new Map;textureFor(t,n){if(!uu(t))return zg(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(c6(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)}}invalidateImage(t){let n=t,o=this.textures.get(n);return o===void 0||c6(this.textBitmaps,n)?!1:(this.textures.delete(n),this.gl.deleteTexture(o),!0)}fill(t){let n=this.opacity*this.fillAlpha;if(!(n<=0)){if(this.currentEllipse){this.flushRectBatch(),this.ellipsePipeline??=new wh(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 _h(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=EL(t.subarray(0,a*2));if(r.length===0){this.drawTriangleFan(t,a,o);return}u6(a);let s=2/this._size.width,i=-2/this._size.height,l=Ch;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}dY(r.length);for(let u=0;u<r.length;u++)Ih[u]=v(r[u]);let c=this.gl;c.useProgram(this.program),c.bindVertexArray(this.dynamicVao),c.bindBuffer(c.ARRAY_BUFFER,this.dynamicVbo),c.bufferData(c.ARRAY_BUFFER,l.subarray(0,a*2),c.DYNAMIC_DRAW),c.uniformMatrix3fv(this.uTransformLoc,!1,ML),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,Ih.subarray(0,r.length),c.DYNAMIC_DRAW),c.drawElements(c.TRIANGLES,r.length,c.UNSIGNED_SHORT,0),c.bindVertexArray(null),this.restoreSolidProgram()}indexBuffer=null;drawTriangleFan(t,n,o){let a=2/this._size.width,r=-2/this._size.height;u6(n);let s=Ch;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.bindVertexArray(this.dynamicVao),i.bindBuffer(i.ARRAY_BUFFER,this.dynamicVbo),i.bufferData(i.ARRAY_BUFFER,s.subarray(0,n*2),i.DYNAMIC_DRAW),i.uniformMatrix3fv(this.uTransformLoc,!1,ML),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),i.bindVertexArray(null),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=CL(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 lY(o,this.dashArray))if(!(a.length<2)){cY(a.length*2);for(let r=0;r<a.length;r++){let s=v(a[r]);fu[r*2]=s.x,fu[r*2+1]=s.y}this.strokePolylineFlat(fu,a.length,n)}}else this.strokePolylineFlat(this.pathXY,this.pathPts,n);this.restoreSolidProgram()}strokePolylineFlat(t,n,o){a6(this.gl,t,n,o,this.transform,this._size,this.program,this.uTransformLoc,this.uColorLoc,this.uOpacityLoc,this.dynamicVbo,this.dynamicVao,ML)}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=Z2();return!t||!fY(t)?null:this.glyphAtlas&&this.glyphAtlasShaper===t?this.glyphAtlas:(this.glyphAtlas&&this.glyphAtlas.dispose(this.gl),this.glyphAtlas=new gh(t),this.glyphAtlasShaper=t,this.glyphAtlas)}fillTextMSDF(t,n,o,a){this.msdfPipeline??=new Sh(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)}flushRectBatch(){if(this.rectBatch.pending===0)return;this.rectPipeline??=new Eh(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 "${cu(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:e6(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))}}}},c6=(e,t)=>{for(let n of e.values())if(n===t)return!0;return!1},lY=(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},Ch=new Float32Array(128),Ih=new Uint16Array(256),u6=e=>{let t=e*2;if(Ch.length>=t)return;let n=Ch.length;for(;n<t;)n*=2;Ch=new Float32Array(n)},fu=new Float64Array(128),cY=e=>{if(fu.length>=e)return;let t=fu.length;for(;t<e;)t*=2;fu=new Float64Array(t)},uY=128,dY=e=>{if(Ih.length>=e)return;let t=Ih.length;for(;t<e;)t*=2;Ih=new Uint16Array(t)},ML=new Float32Array([1,0,0,0,1,0,0,0,1]),d6=.5,fY=e=>{let t=e;return typeof t.glyphMetrics=="function"&&typeof t.rasterizeGlyphMSDF=="function"},f6=(e,t,n,o)=>Math.hypot(e-n,t-o),pY=e=>{let t=zt(e,e.VERTEX_SHADER,`#version 300 es
|
|
126
|
+
}`;var Zg=class{gl;program;vbo;dynamicVbo;dynamicVao;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(kY*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 jg;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=zt(this.gl,this.gl.VERTEX_SHADER,CY,"WebGL2"),l=zt(this.gl,this.gl.FRAGMENT_SHADER,IY,"WebGL2");this.program=Do(this.gl,i,l,"WebGL2"),this.gl.useProgram(this.program),this.vbo=ot(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=ot(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.dynamicVao=ot(this.gl.createVertexArray()),this.gl.bindVertexArray(this.dynamicVao),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.dynamicVbo),this.gl.enableVertexAttribArray(this.aPosLoc),this.gl.vertexAttribPointer(this.aPosLoc,2,this.gl.FLOAT,!1,0,0),this.gl.bindVertexArray(null),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vbo),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.rectPipeline=new Mh(this.gl),this.curvePipeline=new Eh(this.gl),this.ellipsePipeline=new Ch(this.gl),this.msdfPipeline=new _h(this.gl),this.ensureImageProgram(),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.deleteVertexArray(this.dynamicVao),this.gl.deleteBuffer(this.dynamicVbo),this.imageQuadVao&&(this.gl.deleteVertexArray(this.imageQuadVao),this.imageQuadVao=null),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=RL(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=Ny();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(R6(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=Ny();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(R6(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?M6:M6/t}drawImage(t,n,o,a,r,s,i){this.flushRectBatch();let l=this.textureFor(t,s??!1);if(!l)return;let c=this.ensureImageProgram();this.gl.useProgram(c.program),this.gl.bindVertexArray(this.imageQuadVao);let u=EY({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.gl.bindVertexArray(null),this.restoreSolidProgram()}imageProgram=null;ensureImageProgram(){return this.imageProgram?this.imageProgram:(this.imageProgram=TY(this.gl),this.imageQuadVbo=this.gl.createBuffer(),this.imageQuadVao=ot(this.gl.createVertexArray()),this.gl.bindVertexArray(this.imageQuadVao),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),this.gl.enableVertexAttribArray(this.imageProgram.aPos),this.gl.vertexAttribPointer(this.imageProgram.aPos,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(this.imageProgram.aUV),this.gl.vertexAttribPointer(this.imageProgram.aUV,2,this.gl.FLOAT,!1,16,8),this.gl.bindVertexArray(null),this.imageProgram)}imageQuadVbo=null;imageQuadVao=null;textures=new Map;textureFor(t,n){if(!fu(t))return Ug(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(C6(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)}}invalidateImage(t){let n=t,o=this.textures.get(n);return o===void 0||C6(this.textBitmaps,n)?!1:(this.textures.delete(n),this.gl.deleteTexture(o),!0)}fill(t){let n=this.opacity*this.fillAlpha;if(!(n<=0)){if(this.currentEllipse){this.flushRectBatch(),this.ellipsePipeline??=new Ch(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 Eh(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=ML(t.subarray(0,a*2));if(r.length===0){this.drawTriangleFan(t,a,o);return}I6(a);let s=2/this._size.width,i=-2/this._size.height,l=Rh;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}_Y(r.length);for(let u=0;u<r.length;u++)Oh[u]=v(r[u]);let c=this.gl;c.useProgram(this.program),c.bindVertexArray(this.dynamicVao),c.bindBuffer(c.ARRAY_BUFFER,this.dynamicVbo),c.bufferData(c.ARRAY_BUFFER,l.subarray(0,a*2),c.DYNAMIC_DRAW),c.uniformMatrix3fv(this.uTransformLoc,!1,DL),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,Oh.subarray(0,r.length),c.DYNAMIC_DRAW),c.drawElements(c.TRIANGLES,r.length,c.UNSIGNED_SHORT,0),c.bindVertexArray(null),this.restoreSolidProgram()}indexBuffer=null;drawTriangleFan(t,n,o){let a=2/this._size.width,r=-2/this._size.height;I6(n);let s=Rh;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.bindVertexArray(this.dynamicVao),i.bindBuffer(i.ARRAY_BUFFER,this.dynamicVbo),i.bufferData(i.ARRAY_BUFFER,s.subarray(0,n*2),i.DYNAMIC_DRAW),i.uniformMatrix3fv(this.uTransformLoc,!1,DL),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),i.bindVertexArray(null),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=RL(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 SY(o,this.dashArray))if(!(a.length<2)){LY(a.length*2);for(let r=0;r<a.length;r++){let s=v(a[r]);hu[r*2]=s.x,hu[r*2+1]=s.y}this.strokePolylineFlat(hu,a.length,n)}}else this.strokePolylineFlat(this.pathXY,this.pathPts,n);this.restoreSolidProgram()}strokePolylineFlat(t,n,o){k6(this.gl,t,n,o,this.transform,this._size,this.program,this.uTransformLoc,this.uColorLoc,this.uOpacityLoc,this.dynamicVbo,this.dynamicVao,DL)}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=Q2();return!t||!wY(t)?null:this.glyphAtlas&&this.glyphAtlasShaper===t?this.glyphAtlas:(this.glyphAtlas&&this.glyphAtlas.dispose(this.gl),this.glyphAtlas=new Ah(t),this.glyphAtlasShaper=t,this.glyphAtlas)}fillTextMSDF(t,n,o,a){this.msdfPipeline??=new _h(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)}flushRectBatch(){if(this.rectBatch.pending===0)return;this.rectPipeline??=new Mh(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 "${du(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:A6(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))}}}},C6=(e,t)=>{for(let n of e.values())if(n===t)return!0;return!1},SY=(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},Rh=new Float32Array(128),Oh=new Uint16Array(256),I6=e=>{let t=e*2;if(Rh.length>=t)return;let n=Rh.length;for(;n<t;)n*=2;Rh=new Float32Array(n)},hu=new Float64Array(128),LY=e=>{if(hu.length>=e)return;let t=hu.length;for(;t<e;)t*=2;hu=new Float64Array(t)},kY=128,_Y=e=>{if(Oh.length>=e)return;let t=Oh.length;for(;t<e;)t*=2;Oh=new Uint16Array(t)},DL=new Float32Array([1,0,0,0,1,0,0,0,1]),M6=.5,wY=e=>{let t=e;return typeof t.glyphMetrics=="function"&&typeof t.rasterizeGlyphMSDF=="function"},R6=(e,t,n,o)=>Math.hypot(e-n,t-o),TY=e=>{let t=zt(e,e.VERTEX_SHADER,`#version 300 es
|
|
127
127
|
in vec2 aPos;
|
|
128
128
|
in vec2 aUV;
|
|
129
129
|
uniform mat3 uTransform;
|
|
@@ -149,13 +149,13 @@ void main() {
|
|
|
149
149
|
// channels by the per-call opacity.
|
|
150
150
|
vec4 t = texture(uTex, vUV);
|
|
151
151
|
fragColor = vec4(t.rgb * uOpacity, t.a * uOpacity);
|
|
152
|
-
}`,"WebGL2"),o=Do(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")}},fa=new Float32Array(9),
|
|
152
|
+
}`,"WebGL2"),o=Do(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")}},fa=new Float32Array(9),EY=(e,t,n)=>{let o=2/t,a=-2/n;return fa[0]=e.a*o,fa[1]=e.b*a,fa[2]=0,fa[3]=e.c*o,fa[4]=e.d*a,fa[5]=0,fa[6]=e.e*o-1,fa[7]=e.f*a+1,fa[8]=1,fa},CY=`#version 300 es
|
|
153
153
|
in vec2 aPos;
|
|
154
154
|
uniform mat3 uTransform;
|
|
155
155
|
void main() {
|
|
156
156
|
vec3 p = uTransform * vec3(aPos, 1.0);
|
|
157
157
|
gl_Position = vec4(p.xy, 0.0, 1.0);
|
|
158
|
-
}`,
|
|
158
|
+
}`,IY=`#version 300 es
|
|
159
159
|
precision mediump float;
|
|
160
160
|
uniform vec3 uColor;
|
|
161
161
|
uniform float uOpacity;
|
|
@@ -164,10 +164,10 @@ void main() {
|
|
|
164
164
|
// Output premultiplied (rgb*a, a) \u2014 matches the context's
|
|
165
165
|
// premultipliedAlpha:true contract + blendFunc(ONE, 1-SRC_ALPHA).
|
|
166
166
|
fragColor = vec4(uColor * uOpacity, uOpacity);
|
|
167
|
-
}`;var Vg=()=>typeof OffscreenCanvas>"u"||typeof HTMLCanvasElement>"u"?!1:typeof HTMLCanvasElement.prototype.transferControlToOffscreen=="function",RL=(e,t)=>{let n=new OffscreenCanvas(e,t),o=n.getContext("2d");if(!o)throw new Error("OffscreenCanvas 2D context unavailable");let a=new ar(o,e,t);return{canvas:n,target:a}};var rr=(e,t,n,o=sr(),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},sr=(e=2)=>Math.min(typeof window<"u"&&window.devicePixelRatio||1,e);var Mh=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=rr(c,n,o,this.dprOverride??sr(this.maxDpr)),d=c.getContext("2d");if(!d)throw new Error("Failed to obtain 2D context");s.set(l,new ar(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=rr(a,t,n,this.dprOverride??sr(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 DL=()=>new Worker(new URL("./render-worker.js",import.meta.url),{type:"module"});var p6=-2128831035,h6=522970236,gY=16777619,xY=2246822507,m6=-1640531527,bY=2147483647,AY=1431655765,g6=new Float64Array(1),y6=new Int32Array(g6.buffer),jg=class{commands=[];_width;_height;skippedImageDraws=0;fontSpec="10px sans-serif";measureCtx=null;imageIds=new Cp(64);captureGen=0;captureCanvas=null;nextImageId=0;sigA=p6;sigB=h6;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,gY)|0)^m6,this.sigB=Math.imul(this.sigB^n+m6,xY)|0}mixNumber(t){g6[0]=t,this.mix32(y6[0]??0),this.mix32(y6[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(bY);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^AY);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=p6,this.sigB=h6,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 "${cu(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});return}if(uu(t)){let i=this.imageIds.get(t);if(i===void 0||s===!0){let l=this.captureBitmap(t);if(!l){this.skippedImageDraws++;return}i===void 0&&(i=this.nextImageId++,this.imageIds.set(t,i)),this.emit({k:"defineImage",id:i,bitmap:l,gen:++this.captureGen})}this.emit({k:"drawImage",id:i,dx:n,dy:o,dw:a,dh:r});return}this.skippedImageDraws++}captureBitmap(t){if(typeof OffscreenCanvas>"u")return null;let n=Ng(t);if(!n||n.width<=0||n.height<=0)return null;let o=t;if(typeof o.readyState=="number"&&o.readyState<2)return null;this.captureCanvas??=new OffscreenCanvas(n.width,n.height);let a=this.captureCanvas;(a.width!==n.width||a.height!==n.height)&&(a.width=n.width,a.height=n.height);let r=a.getContext("2d");return r?(r.clearRect(0,0,n.width,n.height),r.drawImage(t,0,0),a.transferToImageBitmap()):null}clear(t){this.emit(t!==void 0?{k:"clear",bounds:t}:{k:"clear"})}markDirty(t){this.emit({k:"markDirty",bounds:t})}};var vY=0,SY=1,LY=2,kY=3,_Y=4,wY=5,TY=6,EY=7,CY=8,IY=9,MY=10,RY=11,OY=12,DY=13,PY=14,BY=15,NY=16,zY=17,FY=18,HY=19,UY=20,GY=21,WY=22,qY=23,VY=24,jY=25,ZY=26,XY=27,YY=28,KY=29,$Y=30,QY=31,x6=-1,JY=-1;var eK={butt:0,round:1,square:2};var tK={miter:0,round:1,bevel:2};var nK={left:0,center:1,right:2};var oK={top:0,middle:1,bottom:2},aK={nonzero:1,evenodd:2},rK={normal:1,bold:2},sK={normal:1,italic:2},Zg=0,PL=1,iK=4,lK=64,b6=e=>{let t=new Float64Array(Math.max(lK,e.length*iK)),n=0,o=l=>{if(n===t.length){let c=new Float64Array(t.length*2);c.set(t),t=c}t[n++]=l},a=[],r=new Map,s=l=>{let c=r.get(l);return c===void 0&&(c=a.length,a.push(l),r.set(l,c)),c},i=[];for(let l of e)switch(l.k){case"setFill":o(vY),o(l.color===null?x6:s(l.color));break;case"setStroke":o(SY),o(l.color===null?x6:s(l.color));break;case"setStrokeWidth":o(LY),o(l.w);break;case"setOpacity":o(kY),o(l.a);break;case"setLineCap":o(_Y),o(eK[l.cap]);break;case"setLineJoin":o(wY),o(tK[l.join]);break;case"setDashArray":if(o(TY),l.dash===null)o(JY);else{o(l.dash.length);for(let c of l.dash)o(c)}break;case"setFont":o(EY),o(s(l.family)),o(l.size),l.options===void 0?o(Zg):(o(PL),o(l.options.weight===void 0?0:rK[l.options.weight]),o(l.options.style===void 0?0:sK[l.options.style]));break;case"setTextAlign":o(CY),o(nK[l.align]);break;case"setTextBaseline":o(IY),o(oK[l.baseline]);break;case"save":o(MY);break;case"restore":o(RY);break;case"translate":o(OY),o(l.x),o(l.y);break;case"rotate":o(DY),o(l.r);break;case"scale":o(PY),o(l.sx),o(l.sy);break;case"setTransform":o(BY),o(l.t.a),o(l.t.b),o(l.t.c),o(l.t.d),o(l.t.e),o(l.t.f);break;case"resetTransform":o(NY);break;case"beginPath":o(zY);break;case"closePath":o(FY);break;case"moveTo":o(HY),o(l.x),o(l.y);break;case"lineTo":o(UY),o(l.x),o(l.y);break;case"quadraticCurveTo":o(GY),o(l.cx),o(l.cy),o(l.x),o(l.y);break;case"bezierCurveTo":o(WY),o(l.c1x),o(l.c1y),o(l.c2x),o(l.c2y),o(l.x),o(l.y);break;case"rect":o(qY),o(l.x),o(l.y),o(l.w),o(l.h);break;case"ellipse":o(VY),o(l.cx),o(l.cy),o(l.rx),o(l.ry);break;case"fill":o(jY),o(l.rule===void 0?Zg:aK[l.rule]);break;case"stroke":o(ZY);break;case"fillText":o(XY),o(s(l.text)),o(l.x),o(l.y),l.maxWidth===void 0?o(Zg):(o(PL),o(l.maxWidth));break;case"clear":o(YY),l.bounds===void 0?o(Zg):(o(PL),o(l.bounds.x),o(l.bounds.y),o(l.bounds.width),o(l.bounds.height));break;case"markDirty":o(KY),o(l.bounds.x),o(l.bounds.y),o(l.bounds.width),o(l.bounds.height);break;case"resize":o($Y),o(l.w),o(l.h);break;case"defineImage":i.push({id:l.id,bitmap:l.bitmap});break;case"drawImage":o(QY),o(l.id),o(l.dx),o(l.dy),o(l.dw),o(l.dh);break}return{buffer:t.slice(0,n).buffer,strings:a,bitmaps:i}};var BL=(e,t,n,o={})=>{let a=o.backend??"canvas2d",r=o.maxDpr??2;switch(a){case"canvas2d":return new NL(e,t,n,r);case"webgl2":return new zL(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 FL(e,t,n,o.workerFactory,o.onWorkerError,r)}},HL=(e,t,n,o={},a)=>{let r=o.backend??"canvas2d";try{return{surface:BL(e,t,n,o),effectiveBackend:r}}catch(s){if(r==="canvas2d")throw s;return a?.(r,s),{surface:BL(e,t,n,{...o,backend:"canvas2d"}),effectiveBackend:"canvas2d"}}},NL=class{backend="canvas2d";inner;constructor(t,n,o,a){this.inner=new Mh(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()}},zL=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 Mh(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),rr(i,n,o,sr(a),!1);try{this.mainCanvas=i,this.mainTarget=new qg(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),rr(this.mainCanvas,t,n,sr(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()}},FL=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=sr(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 jg(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;if(this.lastSentSig.get(t)===a)continue;this.lastSentSig.set(t,a);let{buffer:r,strings:s,bitmaps:i}=b6(o),l={type:"replay",buffer:r,strings:s,bitmaps:i};this.workers.get(t)?.postMessage(l,[r])}}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 UL=async()=>{if(typeof navigator>"u")return!1;let e=navigator.gpu;if(!e)return!1;try{return await e.requestAdapter()!==null}catch{return!1}},GL=()=>{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 A6=(0,Le.createContext)(null),WL=({initialScene:e,initialTool: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),C=(0,Le.useRef)(l),w=(0,Le.useRef)(c);b.current=r,A.current=s,_.current=i,C.current=l,w.current=c;let L=(0,Le.useCallback)(G=>{a||Fc();let{width:ie,height:ne}=G.getBoundingClientRect(),{surface:V,effectiveBackend:ve}=HL(G,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)});G.dataset.effectiveBackend=ve;let ge={host:G,mainTarget:V.get("main"),overlayTarget:V.get("overlay"),backgroundTarget:V.get("background"),onAfterRender:()=>p.current?.present(),initialScene:e,...t!==void 0?{initialTool:t}:{},..._.current?{textShaper:_.current}:{},...C.current?{rasterizer:C.current}:{}},ee=new Kp(ge);ee.setViewportSize(ie,ne),ee.setReadOnly(w.current),p.current=V,f.current=ee,d(ee),o?.(ee),V.present();let Se=new ResizeObserver(()=>{let Oe=G.getBoundingClientRect();V.resize(Oe.width,Oe.height),ee.setViewportSize(Oe.width,Oe.height),ee.forceRender()});Se.observe(G),h.current=Se},[]),k=(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=G=>{if(y.current)return;y.current=!0,console.warn("[DiagramRoot] offscreen render worker failed to load; falling back to canvas2d:",G);let ie=m.current;ie&&(k(),L(ie))};let M=(0,Le.useCallback)(G=>{if(k(),m.current=G,!G){d(null);return}L(G)},[L,k]),B=(0,Le.useRef)(null);return(0,Le.useEffect)(()=>{let G=m.current;if(G){if(B.current===null){B.current=r;return}B.current!==r&&(B.current=r,y.current=!1,k(),L(G))}},[r,L,k]),(0,Le.useEffect)(()=>{u?.setReadOnly(c)},[u,c]),(0,Le.useLayoutEffect)(()=>()=>{k(),m.current=null},[k]),(0,gs.jsx)(NE.Provider,{value:u,children:(0,gs.jsx)(A6.Provider,{value:M,children:(0,gs.jsxs)(E8,{children:[n,(0,gs.jsx)(cK,{editor:u})]})})})},cK=({editor:e})=>{let[t,n]=(0,Le.useState)("");return(0,Le.useEffect)(()=>{if(e)return e.onAnnounce(n)},[e]),(0,gs.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})},qL=({style:e,className:t,ariaLabel:n})=>{let o=(0,Le.useContext)(A6),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,gs.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 v6=P(se(),1),gn=P(re(),1);var uK=e=>{let t=null;for(let n of e.elements.values()){if(n.hidden===!0)continue;let o=N(n);t=t?j.union(t,o):o}return t},dK=(e,t,n)=>{let o=t-$b*2,a=n-$b*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}}},VL=({width:e=WE,height:t=qE,className:n,style:o,editor:a})=>{let r=U(),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=rr(y,e,t),A=y.getContext("2d");if(!A)return;let _=new ar(A,e,t,b);_.clear();let C=uK(g),w=C?dK(C,e,t):null;if(l.current=w,!w)return;let L={...g,viewport:{...g.viewport,pan:w.pan,zoom:w.zoom,rotation:0,size:{width:e,height:t}}};Xa(L,_),Bn(L,_);let k=g.viewport;if(k.zoom>0&&k.size.width>0&&k.size.height>0){let M=(k.pan.x-w.pan.x)*w.zoom,B=(k.pan.y-w.pan.y)*w.zoom,G=k.size.width/k.zoom*w.zoom,ie=k.size.height/k.zoom*w.zoom;A.setTransform(b,0,0,b,0,0),A.fillStyle=ZE,A.fillRect(M,B,G,ie),A.strokeStyle=VE,A.lineWidth=jE,A.strokeRect(M,B,G,ie)}},[s,e,t]);(0,gn.useEffect)(()=>{if(!s)return;u();let y=Date.now(),g=null,b=()=>{let _=Date.now()-y;_>=Qb?(y=Date.now(),u()):g??=setTimeout(()=>{g=null,y=Date.now(),u()},Qb-_)},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,C=_.pan.x+_.size.width/2/_.zoom,w=_.pan.y+_.size.height/2/_.zoom;s.panBy({x:(C-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)>Jb?Jb*Math.sign(b):b)*XE/100;if(w<=0)return;let L=s.scene.viewport,k=L.pan.x+L.size.width/2/L.zoom,M=L.pan.y+L.size.height/2/L.zoom;s.panBy({x:(k-_.x)*L.zoom,y:(M-_.y)*L.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,v6.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 Ft=P(se(),1),E1e=P(re(),1);var jL=({style:e})=>{let t=U(),n=eh().type,o=tL();if(!t||n!=="brush"&&n!=="erase")return null;let a=n==="erase";return(0,Ft.jsxs)("div",{className:"du-drawing-panel",style:{...fK,...e},children:[(0,Ft.jsx)("div",{style:pK,children:a?"Eraser":"Drawing"}),!a&&(0,Ft.jsxs)(Ft.Fragment,{children:[(0,Ft.jsx)(Xg,{label:"Stroke",children:(0,Ft.jsx)(su,{value:o.stroke,onChange:r=>{t.setBrushSettings({stroke:r??o.stroke})},onEyedrop:r=>{t.beginEyedropperPick(r)},allowClear:!1})}),(0,Ft.jsx)(Xg,{label:"Fill",children:(0,Ft.jsx)(su,{value:o.fill,onChange:r=>{t.setBrushSettings({fill:r})},onEyedrop:r=>{t.beginEyedropperPick(r)}})}),(0,Ft.jsx)(Xg,{label:`Opacity ${Math.round(o.opacity*100)}%`,children:(0,Ft.jsx)("input",{type:"range",min:0,max:1,step:.05,value:o.opacity,onChange:r=>{t.setBrushSettings({opacity:r.currentTarget.valueAsNumber})},style:S6,"aria-label":"Brush opacity"})})]}),(0,Ft.jsx)(Xg,{label:`${a?"Radius":"Width"} ${o.width}`,children:(0,Ft.jsx)("input",{type:"range",min:Cf,max:E0,step:1,value:o.width,onChange:r=>{t.setBrushSettings({width:r.currentTarget.valueAsNumber})},style:S6,"aria-label":a?"Eraser radius":"Brush width"})})]})},Xg=({label:e,children:t})=>(0,Ft.jsxs)("label",{style:hK,children:[(0,Ft.jsx)("span",{style:mK,children:e}),t]}),fK={width:YE,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)"},pK={fontWeight:600,opacity:.7},hK={display:"flex",flexDirection:"column",gap:4},mK={opacity:.7},S6={width:"100%"};var pu=2,Ht=T.object({x:T.number(),y:T.number()}),D1e=T.object({x:T.number(),y:T.number(),width:T.number(),height:T.number()}),yK=T.object({type:T.enum(["sharp","round"]),value:T.number().optional()}).strict(),Po=T.object({fill:T.string().optional(),stroke:T.string().optional(),strokeWidth:T.number().optional(),opacity:T.number().optional(),dashArray:T.array(T.number()).readonly().optional(),lineCap:T.enum(["butt","round","square"]).optional(),lineJoin:T.enum(["miter","round","bevel"]).optional(),strokeAlign:T.enum(["center","inside","outside"]).optional(),roundness:yK.optional()}).strict(),_6=Po.extend({textAlign:T.enum(["left","center","right"]).optional(),textBaseline:T.enum(["top","middle","bottom"]).optional(),fontWeight:T.enum(["normal","bold"]).optional(),fontStyle:T.enum(["normal","italic"]).optional(),textDecoration:T.object({underline:T.boolean().optional(),strikethrough:T.boolean().optional()}).strict().optional()}).strict(),w6=T.record(T.string(),T.unknown()).optional(),gK=T.string(),T6=T.discriminatedUnion("kind",[T.object({kind:T.literal("named"),name:gK}).strict(),T.object({kind:T.literal("ratio"),position:Ht}).strict(),T.object({kind:T.literal("absolute"),offset:Ht}).strict(),T.object({kind:T.literal("edge"),index:T.number().int().nonnegative(),t:T.number()}).strict()]),pa=T.object({id:T.string(),layerId:T.string(),position:Ht,rotation:T.number(),scale:Ht,order:T.string(),metadata:w6,minWidth:T.number().optional(),minHeight:T.number().optional(),maxWidth:T.number().optional(),maxHeight:T.number().optional(),noFlip:T.boolean().optional(),anchors:T.record(T.string(),T6).optional(),parentId:T.string().optional(),frameId:T.string().optional(),href:T.string().optional()}),xK=pa.extend({type:T.literal("rectangle"),style:Po,width:T.number(),height:T.number()}).strict(),bK=pa.extend({type:T.literal("ellipse"),style:Po,width:T.number(),height:T.number()}).strict(),AK=pa.extend({type:T.literal("polygon"),style:Po,points:T.array(Ht)}).strict(),vK=T.discriminatedUnion("kind",[T.object({kind:T.literal("M"),to:Ht}).strict(),T.object({kind:T.literal("L"),to:Ht}).strict(),T.object({kind:T.literal("Q"),control:Ht,to:Ht}).strict(),T.object({kind:T.literal("C"),control1:Ht,control2:Ht,to:Ht}).strict(),T.object({kind:T.literal("Z")}).strict()]),SK=pa.extend({type:T.literal("path"),style:Po,commands:T.array(vK)}).strict(),LK=T.object({text:T.string(),style:_6.optional()}).strict(),kK=pa.extend({type:T.literal("text"),style:_6,text:T.string(),fontFamily:T.string(),fontSize:T.number(),maxWidth:T.number().optional(),runs:T.array(LK).optional()}).strict(),_K=pa.extend({type:T.literal("image"),style:Po,src:T.string(),width:T.number(),height:T.number(),fileId:T.string().optional(),crop:T.object({x:T.number(),y:T.number(),width:T.number(),height:T.number()}).optional(),animationKind:T.string().optional(),animationData:T.unknown().optional()}).strict(),wK=pa.extend({type:T.literal("template"),style:Po.optional(),templateId:T.string(),data:T.record(T.string(),T.unknown()),width:T.number(),height:T.number()}).strict(),TK=pa.extend({type:T.literal("group"),style:Po.optional()}).strict(),EK=T.object({x:T.number(),y:T.number(),width:T.number()}).strict(),CK=pa.extend({type:T.literal("brush"),style:Po,points:T.array(EK),closed:T.boolean().optional(),pressures:T.array(T.number()).optional(),simulatePressure:T.boolean().optional(),baseWidth:T.number().optional()}).strict(),IK=pa.extend({type:T.string(),style:Po.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"}),MK=T.union([xK,bK,AK,SK,kK,_K,wK,TK,CK,IK]),L6=T.discriminatedUnion("kind",[T.object({kind:T.literal("point"),position:Ht}).strict(),T.object({kind:T.literal("anchor"),elementId:T.string(),anchor:T6}).strict(),T.object({kind:T.literal("outline"),elementId:T.string(),ratio:T.number()}).strict(),T.object({kind:T.literal("floating"),elementId:T.string()}).strict()]),RK=T.enum(["straight","orthogonal","bezier"]),k6=T.enum(["none","arrow","openArrow","roundedArrow","arcArrow","triangle","filledArrow","circle","filledCircle","diamond","rhombus","filledRhombus","erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"]),OK=T.object({from:k6.optional(),to:k6.optional(),size:T.number().optional()}).strict(),DK=T.object({text:T.string(),position:T.number().optional(),fontSize:T.number().optional(),fill:T.string().optional(),background:T.string().optional()}).strict(),PK=T.object({id:T.string(),layerId:T.string(),from:L6,to:L6,waypoints:T.array(Ht).readonly().optional(),routedPoints:T.array(Ht).readonly().optional(),fixedSegments:T.array(T.object({axis:T.enum(["h","v"]),pos:T.number(),at:T.number()}).strict()).readonly().optional(),routing:RK.optional(),avoidObstacles:T.boolean().optional(),arrowheads:OK.optional(),label:DK.optional(),order:T.string(),style:Po,metadata:w6}).strict(),BK=T.object({id:T.string(),name:T.string(),visible:T.boolean(),locked:T.boolean(),order:T.string()}).strict(),NK=T.object({pan:Ht,zoom:T.number(),rotation:T.number(),size:T.object({width:T.number(),height:T.number()}).strict(),gridEnabled:T.boolean(),gridStyle:T.enum(["lines","dots"]).optional(),snapToGrid:T.boolean().optional()}).strict(),zK=T.object({id:T.string(),authorId:T.string(),authorName:T.string(),body:T.string(),createdAt:T.string()}).strict(),FK=T.object({id:T.string(),elementId:T.string().nullable(),position:Ht,resolved:T.boolean(),thread:T.array(zK),createdAt:T.string()}).strict(),E6=T.object({format:T.literal("oh-just-another/scene"),version:T.number().int().nonnegative(),elements:T.array(MK),links:T.array(PK),layers:T.array(BK),annotations:T.array(FK).optional(),viewport:NK}).strict();var C6=e=>{let t=e.annotations.size>0?[...e.annotations.values()]:void 0,n={format:"oh-just-another/scene",version:pu,elements:[...e.elements.values()].map(HK),links:[...e.links.values()],layers:[...e.layers.values()],viewport:e.viewport};return t&&(n.annotations=t),n},HK=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},ZL=(e,t=null)=>JSON.stringify(C6(e),null,t??void 0);var I6=new Map,M6=(e,t)=>{I6.set(e,t)},R6=(e,t,n)=>{let o=e;for(let a=t;a<n;a++){let r=I6.get(a);if(!r)throw new XL(a,n);o=r(o)}return o},XL=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 UK=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}};M6(1,UK);var hu=class extends Error{reason;constructor(t,n){super(t),this.name="DeserializationError",this.reason=n}},O6=(e,t={})=>{if(typeof e!="object"||e===null)throw new hu("Expected an object",e);let n=e.version,o=typeof n=="number"?n:0,a=t.maxVersion??pu;if(o>a)throw new hu(`Document version ${o} is newer than this build understands (${a}). Upgrade your library.`,null);let r=o===pu?e:R6(e,o,pu),s;try{s=E6.parse(r)}catch(i){throw i instanceof T.ZodError?new hu(`Invalid scene document: ${i.message}`,i):i}return GK(s)},YL=(e,t)=>O6(JSON.parse(e),t),GK=e=>{let t=new Map;for(let s of e.elements){let i=Ze(s.id);t.set(i,WK(s,i))}let n=new Map;for(let s of e.links){let i=dA(s.id);n.set(i,qK(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=Df(e.viewport),r=new Map;if(e.annotations)for(let s of e.annotations){let i=Of(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:rc(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}},WK=(e,t)=>({...Df(e),id:t,layerId:ln(e.layerId),order:e.order}),qK=(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{...Df(e),id:t,layerId:ln(e.layerId),order:e.order,from:o,to:a}};var mu=P(se(),1),ir=P(re(),1);var VK=[0,50,90],KL=({children:e,snapPoints:t=VK,value:n,defaultValue:o,onChange:a,className:r,style:s})=>{let[i,l]=(0,ir.useState)(()=>o??t.find(x=>x>0)??50),c=n??i,u=(0,ir.useCallback)(x=>{l(x),a?.(x)},[a]),d=(0,ir.useRef)(null),f=(0,ir.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=sc.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,ir.useEffect)(()=>{let x=y=>{y.key==="Escape"&&u(Math.min(...t))};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x)}},[u,t]),(0,mu.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,mu.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,mu.jsx)("span",{"aria-hidden":!0,style:{display:"block",width:36,height:4,borderRadius:2,background:"var(--text, #ddd)",opacity:.4}})}),(0,mu.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"0 12px 12px"},children:e})]})};var D6=P(se(),1),lr=P(re(),1);var $L=()=>{let e=U(),t=(0,lr.useRef)(null),[,n]=(0,lr.useReducer)(c=>c+1,0);(0,lr.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingTextElement??null;if((0,lr.useEffect)(()=>{o&&t.current?.focus()},[o]),(0,lr.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,D6.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 P6=P(se(),1),sl=P(re(),1);var QL=()=>{let e=U(),t=(0,sl.useRef)(null),[,n]=(0,sl.useReducer)(d=>d+1,0);(0,sl.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingFrameName??null;if((0,sl.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,P6.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 yu=P(se(),1),bs=P(re(),1),z6=P(ya(),1);var xs=P(re(),1),B6=e=>{let t=(0,xs.useRef)(null),n=(0,xs.useRef)(e);n.current=e;let o=(0,xs.useCallback)(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),a=(0,xs.useCallback)(r=>{o(),t.current=setTimeout(()=>{t.current=null,n.current()},r)},[o]);return(0,xs.useEffect)(()=>o,[o]),{schedule:a,cancel:o}};var N6=220,JL=()=>{let e=U(),[t,n]=(0,bs.useState)(null),[,o]=(0,bs.useReducer)(m=>m+1,0),a=(0,bs.useRef)(!1),r=Pt(),{schedule:s,cancel:i}=B6(()=>{a.current||n(null)});if((0,bs.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}),C=e.linkAt(_);C?(i(),n({href:C.href,bounds:C.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,z6.createPortal)((0,yu.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,yu.jsxs)("a",{className:"du-link-popup-url",href:t.href,title:t.href,onClick:m=>{m.preventDefault(),e.openLink(t.href)},children:[(0,yu.jsx)("span",{className:"du-link-popup-text",children:h}),(0,yu.jsx)(Gd,{size:13,strokeWidth:1.75,"aria-hidden":!0})]})}),r)};var As=P(se(),1),Yg=P(re(),1),F6=P(ya(),1);var e3=()=>{let e=U(),[,t]=(0,Yg.useReducer)(u=>u+1,0),n=Pt();if((0,Yg.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=Di.byCategory("basic");return(0,F6.createPortal)((0,As.jsxs)(As.Fragment,{children:[(0,As.jsx)("div",{className:"du-link-drop-backdrop",style:{position:"fixed",inset:0,zIndex:1600},onPointerDown:()=>{e.dismissLinkDropMenu()}}),(0,As.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,As.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 H6=P(se(),1),cr=P(re(),1),U6=P(ya(),1);var t3=()=>{let e=U(),[,t]=(0,cr.useReducer)(m=>m+1,0),[n,o]=(0,cr.useState)(""),a=(0,cr.useRef)(null),r=Pt();(0,cr.useEffect)(()=>{if(e)return e.on("change",()=>{t()})},[e]);let s=e?.editingLinkCaption??null;if((0,cr.useEffect)(()=>{if(!e||s===null)return;let m=e.scene.links.get(s);o(m?.label?.text??"");let x=setTimeout(()=>{a.current?.focus(),a.current?.select()},0);return()=>{clearTimeout(x)}},[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)},h=Math.min(5,n.split(`
|
|
168
|
-
`).length);return(0,U6.createPortal)((0,H6.jsx)("textarea",{ref:a,className:"du-link-caption-input",value:n,placeholder:"Label",rows:h,style:{position:"fixed",left:d,top:f,transform:"translate(-50%, -50%)",zIndex:1602},onChange:m=>{o(m.target.value)},onBlur:p,onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey?(m.preventDefault(),p()):m.key==="Escape"&&(m.preventDefault(),e.cancelLinkCaptionEdit()),m.stopPropagation()}}),r)};var At=P(se(),1),Kg=P(re(),1);var jK=16,ZK=1.75,n3={size:jK,strokeWidth:ZK},XK={"mode-select":sf,"mode-hand":Kd,"mode-rect":qo,"mode-ellipse":Ks,"mode-text":vf,"mode-edge":gf,"mode-brush":qr,"mode-erase":Ud,"mode-laser":pf,"mode-frame":Zd,"insert-image":Qs,"tool-lock":tf,undo:ti,redo:ei},YK=({id:e})=>{let t=U(),[,n]=(0,Kg.useState)(0);(0,Kg.useEffect)(()=>{if(t)return t.on("change",()=>{n(f=>f+1)})},[t]);let o=we.get(e);if(!o)return null;let a=o.iconId?XK[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?` (${dt(u)})`:""}`;return(0,At.jsx)(gu,{title:d,active:s,disabled:!l,onClick:()=>{t&&we.dispatch(e,{editor:t})},children:a?(0,At.jsx)(a,{...n3}):o.label??e})},Sbe=dt({meta:!0,key:"\u2212"}),Lbe=dt({meta:!0,key:"+"}),kbe=dt({meta:!0,key:"0"}),_be=dt({meta:!0,key:"1"}),o3=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()},G6=[{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,At.jsx)(Qs,{...n3}),title:"Insert image (I)",onClick:e=>{o3(e)}},{kind:"action-ref",id:"toggle-tool-lock"},{kind:"divider"},{kind:"action-ref",id:"undo"},{kind:"action-ref",id:"redo"},{kind:"divider"}],$g=[{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,At.jsx)(Qs,{...n3}),title:"Insert image (I)",onClick:e=>{o3(e)}},{kind:"divider"},{kind:"action-ref",id:"toggle-tool-lock"}],a3=({items:e=G6,style:t,className:n,orientation:o="horizontal"})=>{let a=U(),r=eh(),s=ls(),{canUndo:i,canRedo:l,undo:c,redo:u}=nL(),d=o==="vertical";return(0,At.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,At.jsx)($K,{vertical:d},p);case"action-ref":return(0,At.jsx)(YK,{id:f.id},p);case"mode":{let h=r.type===f.mode,m=f.mode==="select"||f.mode==="hand";return(0,At.jsx)(gu,{...f.title!==void 0?{title:f.title}:{},disabled:!a||s&&!m,active:h,onClick:()=>a?.setActiveTool(f.mode),children:f.label},p)}case"action":return(0,At.jsx)(gu,{...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,At.jsx)(gu,{disabled:!i||s,onClick:c,children:f.label??"Undo"},p);case"redo":return(0,At.jsx)(gu,{disabled:!l||s,onClick:u,children:f.label??"Redo"},p);case"tool-lock":return(0,At.jsx)(KK,{...f.label!==void 0?{label:f.label}:{},...f.title!==void 0?{title:f.title}:{}},p)}})})},KK=({label:e="\u{1F512}",title:t="Lock current tool"})=>{let n=U(),o=sn(r=>r.activeTool.locked,!1),a=ls();return(0,At.jsx)(gu,{disabled:!n||a,title:t,active:o,onClick:()=>n?.setToolLocked(!o),children:e})};var gu=({children:e,onClick:t,active:n,disabled:o,title:a,className:r,style:s})=>{let i=(0,At.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,At.jsx)(ni,{content:a,children:i}):i},$K=({vertical:e=!1})=>e?(0,At.jsx)("span",{style:{height:1,width:"100%",background:"var(--du-ui-border, #333)",margin:"4px 0"}}):(0,At.jsx)("span",{style:{width:1,height:20,background:"var(--du-ui-border, #333)",margin:"0 4px"}});var r3=.5522847498307936,W6=.55;var QK={i:.28,l:.28,I:.34,t:.34,f:.36,j:.3,r:.4," ":.3,m:.86,w:.82,M:.86,W:.92},q6=(e,t,n)=>{let o=0;for(let a of e)o+=(QK[a]??W6)*n;return o};var Qg=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=z.IDENTITY;pathSegments=[];pathCursor=null;elements=[];clipIdCounter=0;stack=[];constructor(t){this.size={width:t.width,height:t.height},this.measure=t.measureText??q6}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=z.multiply(this.currentTransform,z.translation(t,n))}rotate(t){this.currentTransform=z.multiply(this.currentTransform,z.rotation(t))}scale(t,n){this.currentTransform=z.multiply(this.currentTransform,z.scaling(t,n))}setTransform(t){this.currentTransform=t}resetTransform(){this.currentTransform=z.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*r3,s=a*r3;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="${s3(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}>${e$(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="${s3(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="${s3(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 z.applyToPoint(this.currentTransform,{x:t,y:n})}},He=e=>Number.isInteger(e)?String(e):e.toFixed(3).replace(/\.?0+$/,""),s3=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),e$=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");var i3=(e,t={})=>{t.skipInstall||Fc();let n=t.width??e.viewport.size.width,o=t.height??e.viewport.size.height,a=new Qg({width:n,height:o,...t.measureText?{measureText:t.measureText}:{}});return Xa(e,a,t),Bn(e,a),a.toSvg()};var vs=P(se(),1),ha=P(re(),1),V6=P(ya(),1);var l3=({items:e,style:t,className:n})=>{let o=U(),a=Og(),r=Pt(),[s,i]=(0,ha.useState)(null),l=(0,ha.useRef)(null);(0,ha.useEffect)(()=>{if(a)return a.register(({screenPoint:p,worldPoint:h})=>{i({screenPoint:p,worldPoint:h})})},[a]),(0,ha.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,ha.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,ha.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=n$(d);return f.length===0?null:(0,V6.createPortal)((0,vs.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,vs.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,vs.jsx)(t$,{item:p,editor:o,ctx:u,onActivate:()=>{c(),p.onClick(o,u)}},p.id))}),r)},t$=({item:e,editor:t,ctx:n,onActivate:o})=>{let a=e.disabled?.(t,n)??!1;return(0,vs.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,vs.jsx)("span",{children:e.label}),e.shortcut?(0,vs.jsx)("span",{style:{marginLeft:16,opacity:.6,fontSize:11},children:e.shortcut}):null]})},n$=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},c3=e=>{window.confirm("Clear the canvas? Every shape is removed and this can't be undone.")&&e.clear()},Te=(e,t)=>{let n=we.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:dt(r)}:{},visible:i,onClick:l=>{we.dispatch(e,{editor:l})}}},u3=[{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"},Te("delete-selection",{label:"Delete"}),Te("duplicate-selection",{label:"Duplicate"}),Te("copy"),Te("cut"),Te("paste"),Te("copy-style",{label:"Copy style"}),Te("paste-style",{label:"Paste style"}),Te("select-all"),{kind:"divider"},Te("group-selection",{label:"Group"}),Te("ungroup-selection",{label:"Ungroup"}),Te("flip-horizontal",{label:"Flip horizontal"}),Te("flip-vertical",{label:"Flip vertical"}),Te("align-left",{label:"Align left"}),Te("align-h-center",{label:"Align horizontal centres"}),Te("align-right",{label:"Align right"}),Te("align-top",{label:"Align top"}),Te("align-v-center",{label:"Align vertical centres"}),Te("align-bottom",{label:"Align bottom"}),Te("distribute-horizontal",{label:"Distribute horizontally"}),Te("distribute-vertical",{label:"Distribute vertically"}),Te("arrange-grid"),Te("arrange-stack-h"),Te("arrange-stack-v"),Te("auto-arrange"),Te("compact-z-order"),{kind:"divider"},Te("bring-to-front",{visible:e=>e.selection.size===1}),Te("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(`
|
|
167
|
+
}`;var Xg=()=>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 rr(o,e,t);return{canvas:n,target:a}};var sr=(e,t,n,o=ir(),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},ir=(e=2)=>Math.min(typeof window<"u"&&window.devicePixelRatio||1,e);var Dh=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??Ii,s=new Map,i=new Map;for(let l of Ii){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=sr(c,n,o,this.dprOverride??ir(this.maxDpr)),d=c.getContext("2d");if(!d)throw new Error("Failed to obtain 2D context");s.set(l,new rr(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=sr(a,t,n,this.dprOverride??ir(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 NL=()=>new Worker(new URL("./render-worker.js",import.meta.url),{type:"module"});var O6=-2128831035,D6=522970236,MY=16777619,RY=2246822507,P6=-1640531527,OY=2147483647,DY=1431655765,N6=new Float64Array(1),B6=new Int32Array(N6.buffer),Yg=class{commands=[];_width;_height;skippedImageDraws=0;fontSpec="10px sans-serif";measureCtx=null;imageIds=new Rp(64);captureGen=0;captureCanvas=null;nextImageId=0;sigA=O6;sigB=D6;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,MY)|0)^P6,this.sigB=Math.imul(this.sigB^n+P6,RY)|0}mixNumber(t){N6[0]=t,this.mix32(B6[0]??0),this.mix32(B6[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(OY);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^DY);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=O6,this.sigB=D6,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 "${du(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});return}if(fu(t)){let i=this.imageIds.get(t);if(i===void 0||s===!0){let l=this.captureBitmap(t);if(!l){this.skippedImageDraws++;return}i===void 0&&(i=this.nextImageId++,this.imageIds.set(t,i)),this.emit({k:"defineImage",id:i,bitmap:l,gen:++this.captureGen})}this.emit({k:"drawImage",id:i,dx:n,dy:o,dw:a,dh:r});return}this.skippedImageDraws++}captureBitmap(t){if(typeof OffscreenCanvas>"u")return null;let n=Hg(t);if(!n||n.width<=0||n.height<=0)return null;let o=t;if(typeof o.readyState=="number"&&o.readyState<2)return null;this.captureCanvas??=new OffscreenCanvas(n.width,n.height);let a=this.captureCanvas;(a.width!==n.width||a.height!==n.height)&&(a.width=n.width,a.height=n.height);let r=a.getContext("2d");return r?(r.clearRect(0,0,n.width,n.height),r.drawImage(t,0,0),a.transferToImageBitmap()):null}clear(t){this.emit(t!==void 0?{k:"clear",bounds:t}:{k:"clear"})}markDirty(t){this.emit({k:"markDirty",bounds:t})}};var PY=0,BY=1,NY=2,zY=3,FY=4,HY=5,UY=6,GY=7,WY=8,qY=9,VY=10,jY=11,ZY=12,XY=13,YY=14,KY=15,$Y=16,QY=17,JY=18,eK=19,tK=20,nK=21,oK=22,aK=23,rK=24,sK=25,iK=26,lK=27,cK=28,uK=29,dK=30,fK=31,z6=-1,pK=-1;var hK={butt:0,round:1,square:2};var mK={miter:0,round:1,bevel:2};var yK={left:0,center:1,right:2};var gK={top:0,middle:1,bottom:2},xK={nonzero:1,evenodd:2},bK={normal:1,bold:2},AK={normal:1,italic:2},Kg=0,zL=1,vK=4,SK=64,F6=e=>{let t=new Float64Array(Math.max(SK,e.length*vK)),n=0,o=l=>{if(n===t.length){let c=new Float64Array(t.length*2);c.set(t),t=c}t[n++]=l},a=[],r=new Map,s=l=>{let c=r.get(l);return c===void 0&&(c=a.length,a.push(l),r.set(l,c)),c},i=[];for(let l of e)switch(l.k){case"setFill":o(PY),o(l.color===null?z6:s(l.color));break;case"setStroke":o(BY),o(l.color===null?z6:s(l.color));break;case"setStrokeWidth":o(NY),o(l.w);break;case"setOpacity":o(zY),o(l.a);break;case"setLineCap":o(FY),o(hK[l.cap]);break;case"setLineJoin":o(HY),o(mK[l.join]);break;case"setDashArray":if(o(UY),l.dash===null)o(pK);else{o(l.dash.length);for(let c of l.dash)o(c)}break;case"setFont":o(GY),o(s(l.family)),o(l.size),l.options===void 0?o(Kg):(o(zL),o(l.options.weight===void 0?0:bK[l.options.weight]),o(l.options.style===void 0?0:AK[l.options.style]));break;case"setTextAlign":o(WY),o(yK[l.align]);break;case"setTextBaseline":o(qY),o(gK[l.baseline]);break;case"save":o(VY);break;case"restore":o(jY);break;case"translate":o(ZY),o(l.x),o(l.y);break;case"rotate":o(XY),o(l.r);break;case"scale":o(YY),o(l.sx),o(l.sy);break;case"setTransform":o(KY),o(l.t.a),o(l.t.b),o(l.t.c),o(l.t.d),o(l.t.e),o(l.t.f);break;case"resetTransform":o($Y);break;case"beginPath":o(QY);break;case"closePath":o(JY);break;case"moveTo":o(eK),o(l.x),o(l.y);break;case"lineTo":o(tK),o(l.x),o(l.y);break;case"quadraticCurveTo":o(nK),o(l.cx),o(l.cy),o(l.x),o(l.y);break;case"bezierCurveTo":o(oK),o(l.c1x),o(l.c1y),o(l.c2x),o(l.c2y),o(l.x),o(l.y);break;case"rect":o(aK),o(l.x),o(l.y),o(l.w),o(l.h);break;case"ellipse":o(rK),o(l.cx),o(l.cy),o(l.rx),o(l.ry);break;case"fill":o(sK),o(l.rule===void 0?Kg:xK[l.rule]);break;case"stroke":o(iK);break;case"fillText":o(lK),o(s(l.text)),o(l.x),o(l.y),l.maxWidth===void 0?o(Kg):(o(zL),o(l.maxWidth));break;case"clear":o(cK),l.bounds===void 0?o(Kg):(o(zL),o(l.bounds.x),o(l.bounds.y),o(l.bounds.width),o(l.bounds.height));break;case"markDirty":o(uK),o(l.bounds.x),o(l.bounds.y),o(l.bounds.width),o(l.bounds.height);break;case"resize":o(dK),o(l.w),o(l.h);break;case"defineImage":i.push({id:l.id,bitmap:l.bitmap});break;case"drawImage":o(fK),o(l.id),o(l.dx),o(l.dy),o(l.dw),o(l.dh);break}return{buffer:t.slice(0,n).buffer,strings:a,bitmaps:i}};var FL=(e,t,n,o={})=>{let a=o.backend??"canvas2d",r=o.maxDpr??2;switch(a){case"canvas2d":return new HL(e,t,n,r);case"webgl2":return new UL(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 GL(e,t,n,o.workerFactory,o.onWorkerError,r)}},WL=(e,t,n,o={},a)=>{let r=o.backend??"canvas2d";try{return{surface:FL(e,t,n,o),effectiveBackend:r}}catch(s){if(r==="canvas2d")throw s;return a?.(r,s),{surface:FL(e,t,n,{...o,backend:"canvas2d"}),effectiveBackend:"canvas2d"}}},HL=class{backend="canvas2d";inner;constructor(t,n,o,a){this.inner=new Dh(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()}},UL=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 Dh(t,n,o,{layers:Ii.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),sr(i,n,o,ir(a),!1);try{this.mainCanvas=i,this.mainTarget=new Zg(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),sr(this.mainCanvas,t,n,ir(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()}},GL=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=ir(s),getComputedStyle(t).position==="static"&&(t.style.position="relative");let i=!1,l=c=>{i||(i=!0,r?.(c))};try{for(let c of Ii){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 Yg(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;if(this.lastSentSig.get(t)===a)continue;this.lastSentSig.set(t,a);let{buffer:r,strings:s,bitmaps:i}=F6(o),l={type:"replay",buffer:r,strings:s,bitmaps:i};this.workers.get(t)?.postMessage(l,[r])}}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 qL=async()=>{if(typeof navigator>"u")return!1;let e=navigator.gpu;if(!e)return!1;try{return await e.requestAdapter()!==null}catch{return!1}},VL=()=>{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 H6=(0,Le.createContext)(null),jL=({initialScene:e,initialTool: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),C=(0,Le.useRef)(l),w=(0,Le.useRef)(c);b.current=r,A.current=s,_.current=i,C.current=l,w.current=c;let L=(0,Le.useCallback)(G=>{a||Uc();let{width:ie,height:ne}=G.getBoundingClientRect(),{surface:V,effectiveBackend:ve}=WL(G,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)});G.dataset.effectiveBackend=ve;let ge={host:G,mainTarget:V.get("main"),overlayTarget:V.get("overlay"),backgroundTarget:V.get("background"),onAfterRender:()=>p.current?.present(),initialScene:e,...t!==void 0?{initialTool:t}:{},..._.current?{textShaper:_.current}:{},...C.current?{rasterizer:C.current}:{}},ee=new Jp(ge);ee.setViewportSize(ie,ne),ee.setReadOnly(w.current),p.current=V,f.current=ee,d(ee),o?.(ee),V.present();let Se=new ResizeObserver(()=>{let Oe=G.getBoundingClientRect();V.resize(Oe.width,Oe.height),ee.setViewportSize(Oe.width,Oe.height),ee.forceRender()});Se.observe(G),h.current=Se},[]),k=(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=G=>{if(y.current)return;y.current=!0,console.warn("[DiagramRoot] offscreen render worker failed to load; falling back to canvas2d:",G);let ie=m.current;ie&&(k(),L(ie))};let M=(0,Le.useCallback)(G=>{if(k(),m.current=G,!G){d(null);return}L(G)},[L,k]),B=(0,Le.useRef)(null);return(0,Le.useEffect)(()=>{let G=m.current;if(G){if(B.current===null){B.current=r;return}B.current!==r&&(B.current=r,y.current=!1,k(),L(G))}},[r,L,k]),(0,Le.useEffect)(()=>{u?.setReadOnly(c)},[u,c]),(0,Le.useLayoutEffect)(()=>()=>{k(),m.current=null},[k]),(0,bs.jsx)(HE.Provider,{value:u,children:(0,bs.jsx)(H6.Provider,{value:M,children:(0,bs.jsxs)(X8,{children:[n,(0,bs.jsx)(LK,{editor:u})]})})})},LK=({editor:e})=>{let[t,n]=(0,Le.useState)("");return(0,Le.useEffect)(()=>{if(e)return e.onAnnounce(n)},[e]),(0,bs.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})},ZL=({style:e,className:t,ariaLabel:n})=>{let o=(0,Le.useContext)(H6),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,bs.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 U6=P(se(),1),gn=P(re(),1);var kK=e=>{let t=null;for(let n of e.elements.values()){if(n.hidden===!0)continue;let o=N(n);t=t?j.union(t,o):o}return t},_K=(e,t,n)=>{let o=t-uA*2,a=n-uA*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}}},XL=({width:e=rC,height:t=sC,className:n,style:o,editor:a})=>{let r=U(),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=sr(y,e,t),A=y.getContext("2d");if(!A)return;let _=new rr(A,e,t,b);_.clear();let C=kK(g),w=C?_K(C,e,t):null;if(l.current=w,!w)return;let L={...g,viewport:{...g.viewport,pan:w.pan,zoom:w.zoom,rotation:0,size:{width:e,height:t}}};Ya(L,_),Bn(L,_);let k=g.viewport;if(k.zoom>0&&k.size.width>0&&k.size.height>0){let M=(k.pan.x-w.pan.x)*w.zoom,B=(k.pan.y-w.pan.y)*w.zoom,G=k.size.width/k.zoom*w.zoom,ie=k.size.height/k.zoom*w.zoom;A.setTransform(b,0,0,b,0,0),A.fillStyle=cC,A.fillRect(M,B,G,ie),A.strokeStyle=iC,A.lineWidth=lC,A.strokeRect(M,B,G,ie)}},[s,e,t]);(0,gn.useEffect)(()=>{if(!s)return;u();let y=Date.now(),g=null,b=()=>{let _=Date.now()-y;_>=dA?(y=Date.now(),u()):g??=setTimeout(()=>{g=null,y=Date.now(),u()},dA-_)},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,C=_.pan.x+_.size.width/2/_.zoom,w=_.pan.y+_.size.height/2/_.zoom;s.panBy({x:(C-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)>fA?fA*Math.sign(b):b)*uC/100;if(w<=0)return;let L=s.scene.viewport,k=L.pan.x+L.size.width/2/L.zoom,M=L.pan.y+L.size.height/2/L.zoom;s.panBy({x:(k-_.x)*L.zoom,y:(M-_.y)*L.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,U6.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 Ft=P(se(),1),U1e=P(re(),1);var YL=({style:e})=>{let t=U(),n=oh().type,o=rL();if(!t||n!=="brush"&&n!=="erase")return null;let a=n==="erase";return(0,Ft.jsxs)("div",{className:"du-drawing-panel",style:{...wK,...e},children:[(0,Ft.jsx)("div",{style:TK,children:a?"Eraser":"Drawing"}),!a&&(0,Ft.jsxs)(Ft.Fragment,{children:[(0,Ft.jsx)($g,{label:"Stroke",children:(0,Ft.jsx)(lu,{value:o.stroke,onChange:r=>{t.setBrushSettings({stroke:r??o.stroke})},onEyedrop:r=>{t.beginEyedropperPick(r)},allowClear:!1})}),(0,Ft.jsx)($g,{label:"Fill",children:(0,Ft.jsx)(lu,{value:o.fill,onChange:r=>{t.setBrushSettings({fill:r})},onEyedrop:r=>{t.beginEyedropperPick(r)}})}),(0,Ft.jsx)($g,{label:`Opacity ${Math.round(o.opacity*100)}%`,children:(0,Ft.jsx)("input",{type:"range",min:0,max:1,step:.05,value:o.opacity,onChange:r=>{t.setBrushSettings({opacity:r.currentTarget.valueAsNumber})},style:G6,"aria-label":"Brush opacity"})})]}),(0,Ft.jsx)($g,{label:`${a?"Radius":"Width"} ${o.width}`,children:(0,Ft.jsx)("input",{type:"range",min:Df,max:O0,step:1,value:o.width,onChange:r=>{t.setBrushSettings({width:r.currentTarget.valueAsNumber})},style:G6,"aria-label":a?"Eraser radius":"Brush width"})})]})},$g=({label:e,children:t})=>(0,Ft.jsxs)("label",{style:EK,children:[(0,Ft.jsx)("span",{style:CK,children:e}),t]}),wK={width:dC,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)"},TK={fontWeight:600,opacity:.7},EK={display:"flex",flexDirection:"column",gap:4},CK={opacity:.7},G6={width:"100%"};var mu=2,Ht=T.object({x:T.number(),y:T.number()}),Z1e=T.object({x:T.number(),y:T.number(),width:T.number(),height:T.number()}),IK=T.object({type:T.enum(["sharp","round"]),value:T.number().optional()}).strict(),Po=T.object({fill:T.string().optional(),stroke:T.string().optional(),strokeWidth:T.number().optional(),opacity:T.number().optional(),dashArray:T.array(T.number()).readonly().optional(),lineCap:T.enum(["butt","round","square"]).optional(),lineJoin:T.enum(["miter","round","bevel"]).optional(),strokeAlign:T.enum(["center","inside","outside"]).optional(),roundness:IK.optional()}).strict(),V6=Po.extend({textAlign:T.enum(["left","center","right"]).optional(),textBaseline:T.enum(["top","middle","bottom"]).optional(),fontWeight:T.enum(["normal","bold"]).optional(),fontStyle:T.enum(["normal","italic"]).optional(),textDecoration:T.object({underline:T.boolean().optional(),strikethrough:T.boolean().optional()}).strict().optional()}).strict(),j6=T.record(T.string(),T.unknown()).optional(),MK=T.string(),Z6=T.discriminatedUnion("kind",[T.object({kind:T.literal("named"),name:MK}).strict(),T.object({kind:T.literal("ratio"),position:Ht}).strict(),T.object({kind:T.literal("absolute"),offset:Ht}).strict(),T.object({kind:T.literal("edge"),index:T.number().int().nonnegative(),t:T.number()}).strict()]),pa=T.object({id:T.string(),layerId:T.string(),position:Ht,rotation:T.number(),scale:Ht,order:T.string(),metadata:j6,minWidth:T.number().optional(),minHeight:T.number().optional(),maxWidth:T.number().optional(),maxHeight:T.number().optional(),noFlip:T.boolean().optional(),anchors:T.record(T.string(),Z6).optional(),parentId:T.string().optional(),frameId:T.string().optional(),href:T.string().optional()}),RK=pa.extend({type:T.literal("rectangle"),style:Po,width:T.number(),height:T.number()}).strict(),OK=pa.extend({type:T.literal("ellipse"),style:Po,width:T.number(),height:T.number()}).strict(),DK=pa.extend({type:T.literal("polygon"),style:Po,points:T.array(Ht)}).strict(),PK=T.discriminatedUnion("kind",[T.object({kind:T.literal("M"),to:Ht}).strict(),T.object({kind:T.literal("L"),to:Ht}).strict(),T.object({kind:T.literal("Q"),control:Ht,to:Ht}).strict(),T.object({kind:T.literal("C"),control1:Ht,control2:Ht,to:Ht}).strict(),T.object({kind:T.literal("Z")}).strict()]),BK=pa.extend({type:T.literal("path"),style:Po,commands:T.array(PK)}).strict(),NK=T.object({text:T.string(),style:V6.optional()}).strict(),zK=pa.extend({type:T.literal("text"),style:V6,text:T.string(),fontFamily:T.string(),fontSize:T.number(),maxWidth:T.number().optional(),runs:T.array(NK).optional()}).strict(),FK=pa.extend({type:T.literal("image"),style:Po,src:T.string(),width:T.number(),height:T.number(),fileId:T.string().optional(),crop:T.object({x:T.number(),y:T.number(),width:T.number(),height:T.number()}).optional(),animationKind:T.string().optional(),animationData:T.unknown().optional()}).strict(),HK=pa.extend({type:T.literal("template"),style:Po.optional(),templateId:T.string(),data:T.record(T.string(),T.unknown()),width:T.number(),height:T.number()}).strict(),UK=pa.extend({type:T.literal("group"),style:Po.optional()}).strict(),GK=T.object({x:T.number(),y:T.number(),width:T.number()}).strict(),WK=pa.extend({type:T.literal("brush"),style:Po,points:T.array(GK),closed:T.boolean().optional(),pressures:T.array(T.number()).optional(),simulatePressure:T.boolean().optional(),baseWidth:T.number().optional()}).strict(),qK=pa.extend({type:T.string(),style:Po.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"}),VK=T.union([RK,OK,DK,BK,zK,FK,HK,UK,WK,qK]),W6=T.discriminatedUnion("kind",[T.object({kind:T.literal("point"),position:Ht}).strict(),T.object({kind:T.literal("anchor"),elementId:T.string(),anchor:Z6}).strict(),T.object({kind:T.literal("outline"),elementId:T.string(),ratio:T.number()}).strict(),T.object({kind:T.literal("floating"),elementId:T.string()}).strict()]),jK=T.enum(["straight","orthogonal","bezier"]),q6=T.enum(["none","arrow","openArrow","roundedArrow","arcArrow","triangle","filledArrow","circle","filledCircle","diamond","rhombus","filledRhombus","erdOne","erdOnlyOne","erdMany","erdOneOrMany","erdZeroOrOne","erdZeroOrMany"]),ZK=T.object({from:q6.optional(),to:q6.optional(),size:T.number().optional()}).strict(),XK=T.object({text:T.string(),position:T.number().optional(),fontSize:T.number().optional(),fill:T.string().optional(),background:T.string().optional()}).strict(),YK=T.object({id:T.string(),layerId:T.string(),from:W6,to:W6,waypoints:T.array(Ht).readonly().optional(),routedPoints:T.array(Ht).readonly().optional(),fixedSegments:T.array(T.object({axis:T.enum(["h","v"]),pos:T.number(),at:T.number()}).strict()).readonly().optional(),routing:jK.optional(),avoidObstacles:T.boolean().optional(),arrowheads:ZK.optional(),label:XK.optional(),order:T.string(),style:Po,metadata:j6}).strict(),KK=T.object({id:T.string(),name:T.string(),visible:T.boolean(),locked:T.boolean(),order:T.string()}).strict(),$K=T.object({pan:Ht,zoom:T.number(),rotation:T.number(),size:T.object({width:T.number(),height:T.number()}).strict(),gridEnabled:T.boolean(),gridStyle:T.enum(["lines","dots"]).optional(),snapToGrid:T.boolean().optional()}).strict(),QK=T.object({id:T.string(),authorId:T.string(),authorName:T.string(),body:T.string(),createdAt:T.string()}).strict(),JK=T.object({id:T.string(),elementId:T.string().nullable(),position:Ht,resolved:T.boolean(),thread:T.array(QK),createdAt:T.string()}).strict(),X6=T.object({format:T.literal("oh-just-another/scene"),version:T.number().int().nonnegative(),elements:T.array(VK),links:T.array(YK),layers:T.array(KK),annotations:T.array(JK).optional(),viewport:$K}).strict();var Y6=e=>{let t=e.annotations.size>0?[...e.annotations.values()]:void 0,n={format:"oh-just-another/scene",version:mu,elements:[...e.elements.values()].map(e$),links:[...e.links.values()],layers:[...e.layers.values()],viewport:e.viewport};return t&&(n.annotations=t),n},e$=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},KL=(e,t=null)=>JSON.stringify(Y6(e),null,t??void 0);var K6=new Map,$6=(e,t)=>{K6.set(e,t)},Q6=(e,t,n)=>{let o=e;for(let a=t;a<n;a++){let r=K6.get(a);if(!r)throw new $L(a,n);o=r(o)}return o},$L=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 t$=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}};$6(1,t$);var yu=class extends Error{reason;constructor(t,n){super(t),this.name="DeserializationError",this.reason=n}},J6=(e,t={})=>{if(typeof e!="object"||e===null)throw new yu("Expected an object",e);let n=e.version,o=typeof n=="number"?n:0,a=t.maxVersion??mu;if(o>a)throw new yu(`Document version ${o} is newer than this build understands (${a}). Upgrade your library.`,null);let r=o===mu?e:Q6(e,o,mu),s;try{s=X6.parse(r)}catch(i){throw i instanceof T.ZodError?new yu(`Invalid scene document: ${i.message}`,i):i}return n$(s)},QL=(e,t)=>J6(JSON.parse(e),t),n$=e=>{let t=new Map;for(let s of e.elements){let i=Ze(s.id);t.set(i,o$(s,i))}let n=new Map;for(let s of e.links){let i=LA(s.id);n.set(i,a$(s,i))}let o=new Map;for(let s of e.layers){let i=cn(s.id);o.set(i,{id:i,name:s.name,visible:s.visible,locked:s.locked,order:s.order})}let a=Ff(e.viewport),r=new Map;if(e.annotations)for(let s of e.annotations){let i=zf(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:fc(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}},o$=(e,t)=>({...Ff(e),id:t,layerId:cn(e.layerId),order:e.order}),a$=(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{...Ff(e),id:t,layerId:cn(e.layerId),order:e.order,from:o,to:a}};var gu=P(se(),1),lr=P(re(),1);var r$=[0,50,90],JL=({children:e,snapPoints:t=r$,value:n,defaultValue:o,onChange:a,className:r,style:s})=>{let[i,l]=(0,lr.useState)(()=>o??t.find(x=>x>0)??50),c=n??i,u=(0,lr.useCallback)(x=>{l(x),a?.(x)},[a]),d=(0,lr.useRef)(null),f=(0,lr.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=pc.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,lr.useEffect)(()=>{let x=y=>{y.key==="Escape"&&u(Math.min(...t))};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x)}},[u,t]),(0,gu.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,gu.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,gu.jsx)("span",{"aria-hidden":!0,style:{display:"block",width:36,height:4,borderRadius:2,background:"var(--text, #ddd)",opacity:.4}})}),(0,gu.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"0 12px 12px"},children:e})]})};var eP=P(se(),1),cr=P(re(),1);var e3=()=>{let e=U(),t=(0,cr.useRef)(null),[,n]=(0,cr.useReducer)(c=>c+1,0);(0,cr.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingTextElement??null;if((0,cr.useEffect)(()=>{o&&t.current?.focus()},[o]),(0,cr.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,eP.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 tP=P(se(),1),ll=P(re(),1);var t3=()=>{let e=U(),t=(0,ll.useRef)(null),[,n]=(0,ll.useReducer)(d=>d+1,0);(0,ll.useEffect)(()=>{if(e)return e.on("change",n)},[e]);let o=e?.editingFrameName??null;if((0,ll.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,tP.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 xu=P(se(),1),vs=P(re(),1),aP=P(ya(),1);var As=P(re(),1),nP=e=>{let t=(0,As.useRef)(null),n=(0,As.useRef)(e);n.current=e;let o=(0,As.useCallback)(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),a=(0,As.useCallback)(r=>{o(),t.current=setTimeout(()=>{t.current=null,n.current()},r)},[o]);return(0,As.useEffect)(()=>o,[o]),{schedule:a,cancel:o}};var oP=220,n3=()=>{let e=U(),[t,n]=(0,vs.useState)(null),[,o]=(0,vs.useReducer)(m=>m+1,0),a=(0,vs.useRef)(!1),r=Pt(),{schedule:s,cancel:i}=nP(()=>{a.current||n(null)});if((0,vs.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}),C=e.linkAt(_);C?(i(),n({href:C.href,bounds:C.bounds})):a.current||s(oP)},y=()=>{s(oP)};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,aP.createPortal)((0,xu.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,xu.jsxs)("a",{className:"du-link-popup-url",href:t.href,title:t.href,onClick:m=>{m.preventDefault(),e.openLink(t.href)},children:[(0,xu.jsx)("span",{className:"du-link-popup-text",children:h}),(0,xu.jsx)(qd,{size:13,strokeWidth:1.75,"aria-hidden":!0})]})}),r)};var Ss=P(se(),1),Qg=P(re(),1),rP=P(ya(),1);var o3=()=>{let e=U(),[,t]=(0,Qg.useReducer)(u=>u+1,0),n=Pt();if((0,Qg.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=Bi.byCategory("basic");return(0,rP.createPortal)((0,Ss.jsxs)(Ss.Fragment,{children:[(0,Ss.jsx)("div",{className:"du-link-drop-backdrop",style:{position:"fixed",inset:0,zIndex:1600},onPointerDown:()=>{e.dismissLinkDropMenu()}}),(0,Ss.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,Ss.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 sP=P(se(),1),ur=P(re(),1),iP=P(ya(),1);var a3=()=>{let e=U(),[,t]=(0,ur.useReducer)(m=>m+1,0),[n,o]=(0,ur.useState)(""),a=(0,ur.useRef)(null),r=Pt();(0,ur.useEffect)(()=>{if(e)return e.on("change",()=>{t()})},[e]);let s=e?.editingLinkCaption??null;if((0,ur.useEffect)(()=>{if(!e||s===null)return;let m=e.scene.links.get(s);o(m?.label?.text??"");let x=setTimeout(()=>{a.current?.focus(),a.current?.select()},0);return()=>{clearTimeout(x)}},[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)},h=Math.min(5,n.split(`
|
|
168
|
+
`).length);return(0,iP.createPortal)((0,sP.jsx)("textarea",{ref:a,className:"du-link-caption-input",value:n,placeholder:"Label",rows:h,style:{position:"fixed",left:d,top:f,transform:"translate(-50%, -50%)",zIndex:1602},onChange:m=>{o(m.target.value)},onBlur:p,onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey?(m.preventDefault(),p()):m.key==="Escape"&&(m.preventDefault(),e.cancelLinkCaptionEdit()),m.stopPropagation()}}),r)};var At=P(se(),1),Jg=P(re(),1);var s$=16,i$=1.75,r3={size:s$,strokeWidth:i$},l$={"mode-select":cf,"mode-hand":Qd,"mode-rect":qo,"mode-ellipse":Qs,"mode-text":Lf,"mode-edge":bf,"mode-brush":Vr,"mode-erase":Wd,"mode-laser":mf,"mode-frame":Yd,"insert-image":ei,"tool-lock":of,undo:oi,redo:ni},c$=({id:e})=>{let t=U(),[,n]=(0,Jg.useState)(0);(0,Jg.useEffect)(()=>{if(t)return t.on("change",()=>{n(f=>f+1)})},[t]);let o=we.get(e);if(!o)return null;let a=o.iconId?l$[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?` (${dt(u)})`:""}`;return(0,At.jsx)(bu,{title:d,active:s,disabled:!l,onClick:()=>{t&&we.dispatch(e,{editor:t})},children:a?(0,At.jsx)(a,{...r3}):o.label??e})},Pbe=dt({meta:!0,key:"\u2212"}),Bbe=dt({meta:!0,key:"+"}),Nbe=dt({meta:!0,key:"0"}),zbe=dt({meta:!0,key:"1"}),s3=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()},lP=[{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,At.jsx)(ei,{...r3}),title:"Insert image (I)",onClick:e=>{s3(e)}},{kind:"action-ref",id:"toggle-tool-lock"},{kind:"divider"},{kind:"action-ref",id:"undo"},{kind:"action-ref",id:"redo"},{kind:"divider"}],ex=[{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,At.jsx)(ei,{...r3}),title:"Insert image (I)",onClick:e=>{s3(e)}},{kind:"divider"},{kind:"action-ref",id:"toggle-tool-lock"}],i3=({items:e=lP,style:t,className:n,orientation:o="horizontal"})=>{let a=U(),r=oh(),s=us(),{canUndo:i,canRedo:l,undo:c,redo:u}=sL(),d=o==="vertical";return(0,At.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,At.jsx)(d$,{vertical:d},p);case"action-ref":return(0,At.jsx)(c$,{id:f.id},p);case"mode":{let h=r.type===f.mode,m=f.mode==="select"||f.mode==="hand";return(0,At.jsx)(bu,{...f.title!==void 0?{title:f.title}:{},disabled:!a||s&&!m,active:h,onClick:()=>a?.setActiveTool(f.mode),children:f.label},p)}case"action":return(0,At.jsx)(bu,{...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,At.jsx)(bu,{disabled:!i||s,onClick:c,children:f.label??"Undo"},p);case"redo":return(0,At.jsx)(bu,{disabled:!l||s,onClick:u,children:f.label??"Redo"},p);case"tool-lock":return(0,At.jsx)(u$,{...f.label!==void 0?{label:f.label}:{},...f.title!==void 0?{title:f.title}:{}},p)}})})},u$=({label:e="\u{1F512}",title:t="Lock current tool"})=>{let n=U(),o=sn(r=>r.activeTool.locked,!1),a=us();return(0,At.jsx)(bu,{disabled:!n||a,title:t,active:o,onClick:()=>n?.setToolLocked(!o),children:e})};var bu=({children:e,onClick:t,active:n,disabled:o,title:a,className:r,style:s})=>{let i=(0,At.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,At.jsx)(si,{content:a,children:i}):i},d$=({vertical:e=!1})=>e?(0,At.jsx)("span",{style:{height:1,width:"100%",background:"var(--du-ui-border, #333)",margin:"4px 0"}}):(0,At.jsx)("span",{style:{width:1,height:qE,background:"var(--du-ui-border, #333)",margin:"0 4px"}});var l3=.5522847498307936,cP=.55;var f$={i:.28,l:.28,I:.34,t:.34,f:.36,j:.3,r:.4," ":.3,m:.86,w:.82,M:.86,W:.92},uP=(e,t,n)=>{let o=0;for(let a of e)o+=(f$[a]??cP)*n;return o};var tx=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=z.IDENTITY;pathSegments=[];pathCursor=null;elements=[];clipIdCounter=0;stack=[];constructor(t){this.size={width:t.width,height:t.height},this.measure=t.measureText??uP}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=z.multiply(this.currentTransform,z.translation(t,n))}rotate(t){this.currentTransform=z.multiply(this.currentTransform,z.rotation(t))}scale(t,n){this.currentTransform=z.multiply(this.currentTransform,z.scaling(t,n))}setTransform(t){this.currentTransform=t}resetTransform(){this.currentTransform=z.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*l3,s=a*l3;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="${c3(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}>${h$(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="${c3(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="${c3(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 z.applyToPoint(this.currentTransform,{x:t,y:n})}},He=e=>Number.isInteger(e)?String(e):e.toFixed(3).replace(/\.?0+$/,""),c3=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),h$=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");var u3=(e,t={})=>{t.skipInstall||Uc();let n=t.width??e.viewport.size.width,o=t.height??e.viewport.size.height,a=new tx({width:n,height:o,...t.measureText?{measureText:t.measureText}:{}});return Ya(e,a,t),Bn(e,a),a.toSvg()};var Ls=P(se(),1),ha=P(re(),1),dP=P(ya(),1);var d3=({items:e,style:t,className:n})=>{let o=U(),a=Ng(),r=Pt(),[s,i]=(0,ha.useState)(null),l=(0,ha.useRef)(null);(0,ha.useEffect)(()=>{if(a)return a.register(({screenPoint:p,worldPoint:h})=>{i({screenPoint:p,worldPoint:h})})},[a]),(0,ha.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,ha.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,ha.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=y$(d);return f.length===0?null:(0,dP.createPortal)((0,Ls.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,Ls.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,Ls.jsx)(m$,{item:p,editor:o,ctx:u,onActivate:()=>{c(),p.onClick(o,u)}},p.id))}),r)},m$=({item:e,editor:t,ctx:n,onActivate:o})=>{let a=e.disabled?.(t,n)??!1;return(0,Ls.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,Ls.jsx)("span",{children:e.label}),e.shortcut?(0,Ls.jsx)("span",{style:{marginLeft:16,opacity:.6,fontSize:11},children:e.shortcut}):null]})},y$=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},f3=e=>{window.confirm("Clear the canvas? Every shape is removed and this can't be undone.")&&e.clear()},Te=(e,t)=>{let n=we.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:dt(r)}:{},visible:i,onClick:l=>{we.dispatch(e,{editor:l})}}},p3=[{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"},Te("delete-selection",{label:"Delete"}),Te("duplicate-selection",{label:"Duplicate"}),Te("copy"),Te("cut"),Te("paste"),Te("copy-style",{label:"Copy style"}),Te("paste-style",{label:"Paste style"}),Te("select-all"),{kind:"divider"},Te("group-selection",{label:"Group"}),Te("ungroup-selection",{label:"Ungroup"}),Te("flip-horizontal",{label:"Flip horizontal"}),Te("flip-vertical",{label:"Flip vertical"}),Te("align-left",{label:"Align left"}),Te("align-h-center",{label:"Align horizontal centres"}),Te("align-right",{label:"Align right"}),Te("align-top",{label:"Align top"}),Te("align-v-center",{label:"Align vertical centres"}),Te("align-bottom",{label:"Align bottom"}),Te("distribute-horizontal",{label:"Distribute horizontally"}),Te("distribute-vertical",{label:"Distribute vertically"}),Te("arrange-grid"),Te("arrange-stack-h"),Te("arrange-stack-v"),Te("auto-arrange"),Te("compact-z-order"),{kind:"divider"},Te("bring-to-front",{visible:e=>e.selection.size===1}),Te("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(`
|
|
169
169
|
`),o=window.prompt(`Move selection to layer (1-${t.length}):
|
|
170
|
-
${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"},Te("zoom-in"),Te("zoom-out"),Te("zoom-reset",{label:"Reset zoom (100%)"}),Te("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=>{c3(e)}}];var ur=P(se(),1),Nn=P(re(),1);var d3=()=>{let e=U(),[t,n]=(0,Nn.useState)(!1),[o,a]=(0,Nn.useState)(""),[r,s]=(0,Nn.useState)(0),i=(0,Nn.useRef)(null);(0,Nn.useEffect)(()=>(we.replace({id:"open-command-palette",label:"Command palette",category:"other",hotkey:[{key:"k",meta:!0},{key:"p",meta:!0,shift:!0}],perform:()=>{n(!0)}}),we.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})=>{c3(m)}}),()=>{we.unregister("open-command-palette"),we.unregister("clear-canvas")}),[]);let l=(0,Nn.useMemo)(()=>we.getAll().filter(m=>m.label!==void 0&&m.id!=="open-command-palette"),[t]),c=e?{editor:e}:null,u=(0,Nn.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,Nn.useEffect)(()=>{if(!t)return;a(""),s(0);let m=requestAnimationFrame(()=>i.current?.focus());return()=>{cancelAnimationFrame(m)}},[t]),(0,Nn.useEffect)(()=>{s(0)},[o]),!t)return null;let d=()=>{n(!1)},f=m=>{!m.enabled||!c||(d(),we.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,ur.jsxs)(dg,{open:t,onClose:d,title:"Command palette",style:a$,children:[(0,ur.jsx)("input",{ref:i,value:o,onChange:m=>{a(m.target.value)},onKeyDown:p,placeholder:"Search commands\u2026","aria-label":"Search commands",style:r$}),(0,ur.jsx)("ul",{style:s$,role:"listbox",children:u.length===0?(0,ur.jsx)("li",{style:{padding:"12px 14px",opacity:.6},children:"No commands"}):u.map((m,x)=>{let y=o$(m.action);return(0,ur.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,ur.jsx)("span",{children:m.action.label}),y?(0,ur.jsx)("kbd",{style:i$,children:y}):null]},m.action.id)})})]})},o$=e=>{if(e.hotkey){let n=(Array.isArray(e.hotkey)?e.hotkey:[e.hotkey])[0];if(n)return dt(n)}return e.sequence&&e.sequence.length>0?e.sequence.map(t=>t.length===1?t.toUpperCase():t).join(" "):null},a$={maxWidth:520,width:"calc(100vw - 64px)",padding:0,display:"flex",flexDirection:"column",overflow:"hidden"},r$={border:"none",borderBottom:"1px solid var(--du-ui-border)",outline:"none",padding:"14px 16px",fontSize:15,background:"transparent",color:"inherit"},s$={listStyle:"none",margin:0,padding:4,maxHeight:360,overflowY:"auto"},i$={fontSize:11,color:"var(--du-text-muted, #6b6b6b)",fontFamily:"inherit"};var Ss=P(se(),1),zn=P(re(),1);var p3=()=>{let e=U(),t=Ka(),[n,o]=(0,zn.useState)(!1),[a,r]=(0,zn.useState)(""),[s,i]=(0,zn.useState)(0),l=(0,zn.useRef)(null);(0,zn.useEffect)(()=>(we.replace({id:"open-search",label:"Find text",category:"other",viewMode:!0,hotkey:{key:"f",meta:!0},perform:()=>{o(!0)}}),()=>{we.unregister("open-search")}),[]);let c=(0,zn.useMemo)(()=>a.trim()?hS(t,a):[],[t,a]),u=(0,zn.useRef)(c);if(u.current=c,(0,zn.useEffect)(()=>{if(!n||!e)return;let m=u.current[s];m&&(m.kind==="element"?e.setSelection([m.id]):e.selectLink(m.id),e.revealSelection(GE))},[n,s,a,e]),(0,zn.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,Ss.jsxs)("div",{style:l$,role:"search",children:[(0,Ss.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:c$}),(0,Ss.jsx)("span",{style:u$,"aria-live":"polite",children:h}),(0,Ss.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Previous match",title:"Previous (\u21E7\u23CE)",disabled:c.length===0,onClick:()=>{f(-1)},style:f3,children:"\u2191"}),(0,Ss.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Next match",title:"Next (\u23CE)",disabled:c.length===0,onClick:()=>{f(1)},style:f3,children:"\u2193"}),(0,Ss.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Close search",title:"Close (Esc)",onClick:d,style:f3,children:"\u2715"})]})},l$={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"},c$={border:"none",outline:"none",padding:"4px 8px",fontSize:14,minWidth:180,background:"transparent",color:"inherit"},u$={fontSize:12,color:"var(--du-text-muted)",minWidth:56,textAlign:"right",whiteSpace:"nowrap"},f3={minWidth:28,height:28};var at=P(se(),1),xu=P(re(),1);var h3=()=>{let e=U(),[t,n]=(0,xu.useState)(!1),[,o]=(0,xu.useState)(0);if((0,xu.useEffect)(()=>(we.replace({id:"toggle-stats",label:"Stats panel",category:"other",viewMode:!0,hotkey:{key:"/",alt:!0},perform:()=>{n(u=>!u)}}),()=>{we.unregister("toggle-stats")}),[]),(0,xu.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:d$,role:"status","aria-label":"Selection stats","aria-live":"polite",children:[(0,at.jsx)("div",{style:j6,children:"Selection"}),a?(0,at.jsxs)(at.Fragment,{children:[(0,at.jsx)(dr,{label:"X",value:Rh(a.x)}),(0,at.jsx)(dr,{label:"Y",value:Rh(a.y)}),(0,at.jsx)(dr,{label:"W",value:Rh(a.width)}),(0,at.jsx)(dr,{label:"H",value:Rh(a.height)}),c!==null?(0,at.jsx)(dr,{label:"\u2220",value:`${String(Rh(c))}\xB0`}):null,i>1?(0,at.jsx)(dr,{label:"Count",value:String(i)}):null]}):(0,at.jsx)("div",{style:m$,children:"Nothing selected"}),(0,at.jsx)("div",{style:{...j6,marginTop:8},children:"Scene"}),(0,at.jsx)(dr,{label:"Elements",value:String(l.elements.size)}),(0,at.jsx)(dr,{label:"Edges",value:String(l.links.size)}),(0,at.jsx)(dr,{label:"Selected",value:String(i)})]})},Rh=e=>Math.round(e*10)/10,dr=({label:e,value:t})=>(0,at.jsxs)("div",{style:f$,children:[(0,at.jsx)("span",{style:p$,children:e}),(0,at.jsx)("span",{style:h$,children:t})]}),d$={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"},j6={fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"var(--du-text-muted)",marginBottom:4},f$={display:"flex",justifyContent:"space-between",gap:12,lineHeight:"18px"},p$={color:"var(--du-text-muted)"},h$={fontVariantNumeric:"tabular-nums",fontFamily:"ui-monospace, monospace"},m$={color:"var(--du-text-muted)",fontStyle:"italic"};var Z6=P(se(),1),Fn=P(re(),1);var X6=(0,Fn.createContext)(null),m3=({children:e})=>{let[t,n]=(0,Fn.useState)(!1),o=(0,Fn.useCallback)(()=>{n(r=>!r)},[]);(0,Fn.useEffect)(()=>(we.replace({id:"toggle-zen-mode",label:"Zen mode",category:"other",viewMode:!0,hotkey:{key:"z",alt:!0},perform:()=>{n(r=>!r)}}),()=>{we.unregister("toggle-zen-mode")}),[]),(0,Fn.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,Fn.useMemo)(()=>({zen:t,setZen:n,toggle:o}),[t,o]);return(0,Z6.jsx)(X6.Provider,{value:a,children:e})},y3=()=>{let e=(0,Fn.useContext)(X6);if(!e)throw new Error("@oh-just-another/react-ui: useZenMode called outside <ZenModeProvider>.");return e};var fr=P(se(),1),Hn=P(re(),1);var y$=(0,Hn.createContext)(null);var g3=({children:e,defaultDuration:t=3e3,style:n})=>{let[o,a]=(0,Hn.useState)([]),r=(0,Hn.useRef)(0),s=(0,Hn.useCallback)(c=>{a(u=>u.filter(d=>d.id!==c))},[]),i=(0,Hn.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,Hn.useMemo)(()=>({push:i,dismiss:s}),[i,s]);return(0,fr.jsxs)(y$.Provider,{value:l,children:[e,(0,fr.jsx)(g$,{toasts:o,onDismiss:s,...n?{style:n}:{}})]})},g$=({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,fr.jsx)("div",{style:o,"aria-live":"polite","aria-atomic":"false",children:e.map(a=>(0,fr.jsx)(b$,{toast:a,onDismiss:t},a.id))})},x$={info:"var(--accent, #1a73e8)",success:"#2e8b57",warn:"#c79100",error:"#c83232"},b$=({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 ${x$[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,fr.jsxs)("div",{role:"status",style:n,children:[(0,fr.jsx)("span",{style:{flex:1,lineHeight:1.35},children:e.message}),(0,fr.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),vt=P(re(),1);var A$=16,v$=1.75,Y6=(0,vt.createContext)(null),K6=()=>(0,vt.useContext)(Y6)??{close:()=>{}},Q=({children:e,trigger:t=(0,Xe.jsx)(of,{size:A$,strokeWidth:v$}),className:n,style:o})=>{let[a,r]=(0,vt.useState)(!1),s=(0,vt.useRef)(null),i=(0,vt.useId)();(0,vt.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,vt.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)(Y6.Provider,{value:{close:l},children:e})}):null]})},S$={display:"block",width:"100%",textAlign:"left",background:"transparent",color:"inherit",border:"none",borderRadius:4,padding:"6px 10px",font:"inherit",fontSize:13,cursor:"pointer"},x3=e=>({...S$,...e}),L$=({children:e,onClick:t,shortcut:n,disabled:o,active:a,icon:r})=>{let{close:s}=K6();return(0,Xe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,onClick:()=>{o||(t?.(),s())},style:{...x3(),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)(Od,{size:12,strokeWidth:2.25}):r??""}),e]}),n?(0,Xe.jsx)("span",{style:{color:"var(--muted, #888)",fontSize:11},children:n}):null]})},k$=({children:e,href:t,external:n})=>{let{close:o}=K6();return(0,Xe.jsx)("a",{role:"menuitem",href:t,target:n?"_blank":void 0,rel:n?"noreferrer noopener":void 0,onClick:o,style:{...x3({textDecoration:"none"}),color:"var(--text, #ddd)"},children:e})},_$=()=>(0,Xe.jsx)("hr",{style:{margin:"4px 6px",border:"none",borderTop:"1px solid var(--border, #2a2a2a)"}}),w$=({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]}),T$=({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)})}),E$=120,C$=({children:e,label:t,icon:n,disabled:o})=>{let[a,r]=(0,vt.useState)(!1),s=(0,vt.useRef)(null),i=(0,vt.useCallback)(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null)},[]),l=(0,vt.useCallback)(()=>{i(),s.current=window.setTimeout(()=>{r(!1),s.current=null},E$)},[i]);(0,vt.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:{...x3(),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)(Ys,{size:12,strokeWidth:2.25,"aria-hidden":!0})]}),a?(0,Xe.jsx)("div",{role:"menu",style:c,children:e}):null]})};Q.Item=L$;Q.ItemLink=k$;Q.Separator=_$;Q.Group=w$;Q.Toggle=T$;Q.Submenu=C$;var Oh=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 Dp(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=`${$6(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}=rs(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=$6(n);if(a!==this.currentFontKey){let u=this.textEncoder.encode(n.family),d=rs(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}=rs(o,r),c=o.measure(s,i);return l(),{width:c}}},$6=e=>`${e.family}|${e.size}|${e.weight??"normal"}|${e.style??"normal"}`;var I$={butt:0,round:1,square:2},M$={miter:0,round:1,bevel:2},R$={M:0,L:1,Q:2,C:3,Z:4},Ph=class e{defaultTolerance;wasm=null;constructor(t={}){this.defaultTolerance=t.defaultTolerance??.5}get isReady(){return this.wasm!==null}async loadModule(t){let n=await Dp(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):Dy.flatten(t,o)}strokeToFill(t,n,o){return this.wasm?this.strokeToFillViaWasm(t,n,o,this.wasm):Dy.strokeToFill(t,n,o)}flattenViaWasm(t,n,o){let a=O$(t),r=rs(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=Jg(o.memory,s),c=Jg(o.memory,i);return Q6(o.memory,l,c)}finally{r.free(),o.free(s,4),o.free(i,4)}}strokeToFillViaWasm(t,n,o,a){let r=D$(t),s=rs(a,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),i=a.alloc(4),l=a.alloc(4);try{let c=I$[o?.cap??"butt"],u=M$[o?.join??"miter"];a.strokeToFillF32(s.ptr,t.length,n,c,u,i,l);let d=Jg(a.memory,i),f=Jg(a.memory,l);return Q6(a.memory,d,f)}finally{s.free(),a.free(i,4),a.free(l,4)}}},Dh=new Float32Array(256),J6=e=>{if(Dh.length>=e)return;let t=Dh.length;for(;t<e;)t*=2;Dh=new Float32Array(t)},O$=e=>{J6(e.length*7);let t=Dh,n=0;for(let o of e)switch(t[n++]=R$[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)},D$=e=>{J6(e.length*2);let t=Dh;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)},Jg=(e,t)=>new DataView(e.buffer,t,4).getUint32(0,!0),Q6=(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 tP=()=>typeof Worker<"u",eP=()=>typeof WebAssembly<"u"&&typeof WebAssembly.instantiate=="function",P$=()=>{if(typeof matchMedia!="function")return!1;try{return matchMedia("(pointer: coarse)").matches}catch{return!1}},B$=async()=>await UL()||GL()?"webgl2":Vg()&&tP()?"offscreen":"canvas2d",nP=async(e={})=>{let t=e.renderer&&e.renderer!=="auto"?e.renderer:await B$(),n=e.wasmText!==void 0&&e.wasmText!=="auto"?e.wasmText:eP(),o=e.wasmRaster!==void 0&&e.wasmRaster!=="auto"?e.wasmRaster:eP()&&t==="webgl2",a=e.workers!==void 0&&e.workers!=="auto"?e.workers:Vg()&&tP(),r=e.tiles!==void 0&&e.tiles!=="auto"?e.tiles:!0;return{renderer:t,wasmText:n,wasmRaster:o,workers:a,tiles:r,touch:P$()}},oP=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 v3=new WeakMap,S3=new WeakSet,fQ=async e=>{let{parseGIF:t,decompressFrames:n}=await Promise.resolve().then(()=>P(cP(),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}},pQ={kind:"gif",getFrameAt(e,t){if(!(e instanceof ArrayBuffer)||e.byteLength===0)return null;let n=v3.get(e);if(!n)return S3.has(e)||(S3.add(e),fQ(e).then(r=>{v3.set(e,r),G2()}).catch(()=>{}).finally(()=>S3.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 v3.get(e)?.totalMs??0}},uP=!1,dP=()=>{uP||(uP=!0,Ip(pQ))};var Bh=P(re(),1);var fP=e=>{let t=Pt(),[n]=(0,Bh.useState)(()=>typeof document>"u"?null:document.createElement("div"));return(0,Bh.useEffect)(()=>{if(n)return n.setAttribute("data-diagram-portal",""),t.appendChild(n),()=>{n.remove()}},[n,t]),(0,Bh.useEffect)(()=>{n&&(e==="system"?n.removeAttribute("data-theme"):n.setAttribute("data-theme",e))},[n,e]),n};var k3=async(e,t)=>{if(typeof OffscreenCanvas>"u")return null;let n=hQ(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}=RL(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&&Op(l,i),Xa(l,i,{skipClear:!0}),Bn(l,i),s.convertToBlob({type:"image/png"})},hQ=e=>{let t=null;for(let n of Lo(e))if(n.visible)for(let o of Ga(e,n.id)){let a=N(o);t=t?mQ(t,a):a}return t},mQ=(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 pP=2,bu=e=>{typeof window<"u"&&window.alert(e)},hP=e=>{bu=e},_3=(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)})},w3=e=>{let t=ZL(e,2);_3(new Blob([t],{type:"application/json"}),"scene.diagram.json")},T3=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=YL(o);e.loadScene(a)}catch(a){console.error("[diagram] failed to parse scene file:",a),bu("Failed to parse the file \u2014 make sure it was saved through this app's Save action.")}})},t.click()},mP=()=>{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"},Nh=async(e,t)=>{let n=await k3(e.scene,{background:t,scale:pP,backgroundColor:mP()});if(!n){bu("Nothing to export \u2014 the canvas is empty.");return}_3(n,"scene.png")},yP=e=>{let t=i3(e);_3(new Blob([t],{type:"image/svg+xml"}),"scene.svg")},E3=async e=>{let t=typeof navigator>"u"?void 0:navigator.clipboard;if(typeof t?.write!="function"||typeof ClipboardItem>"u"){bu("Copy to clipboard isn't supported in this browser.");return}let n=await k3(e.scene,{background:"color",scale:pP,backgroundColor:mP()});if(!n){bu("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),bu("Couldn't copy the image to the clipboard.")}},yQ=[{id:"save-scene",label:"Save as JSON",category:"other",viewMode:!0,hotkey:{key:"s",meta:!0},perform:({editor:e})=>{w3(e.scene)}},{id:"open-scene",label:"Open\u2026",category:"other",hotkey:{key:"o",meta:!0},perform:({editor:e})=>{T3(e)}},{id:"export-png",label:"Export as PNG",category:"other",viewMode:!0,hotkey:{key:"e",meta:!0,shift:!0},perform:({editor:e})=>{Nh(e,"color")}},{id:"copy-as-image",label:"Copy as image",category:"other",viewMode:!0,hotkey:{key:"c",shift:!0,alt:!0},perform:({editor:e})=>{E3(e)}}],gP=(e=we)=>{for(let t of yQ)e.replace(t)};var gQ=14,xQ=14,bQ=16,C3=1.75,pt={size:gQ,strokeWidth:C3},ws={size:xQ,strokeWidth:C3},rx={size:bQ,strokeWidth:C3},AQ="https://github.com/oh-just-another/diagram",zh=(0,ye.forwardRef)(function(t,n){let{initialScene:o,initialTool: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:C,hideHelpButton:w,hideContextMenu:L,hideSelectionPanel:k,hideDrawingPanel:M,minimap:B,renderTopBarLeft:G,renderTopBarCenter:ie,renderTopBarRight:ne,renderBottomBarLeft:V,renderBottomBarCenter:ve,renderBottomBarRight:ge,renderMainMenuExtras:ee,onImportTemplates:Se,theme:Oe,defaultTheme:qt="system",onThemeChange:xn,persistTheme:Bo,repositoryUrl:St,onConfirm:Hh,onNotify:Uh,className:Gh,style:Wh}=t,Au=(0,ye.useMemo)(()=>Bo===!0?"diagram-theme":typeof Bo=="string"?Bo:null,[Bo]),[LP,kP]=(0,ye.useState)(()=>{if(!Au||typeof window>"u")return qt;let X=window.localStorage.getItem(Au);return X==="light"||X==="dark"||X==="system"?X:qt}),qh=Oe??LP,_P=fP(qh),wP=(0,ye.useCallback)(X=>{Oe===void 0&&kP(X),Au&&typeof window<"u"&&window.localStorage.setItem(Au,X),xn?.(X)},[Oe,xn,Au]),M3=r?.enabled,R3=r?.style,vu=(0,ye.useMemo)(()=>sv({...o?{saved:o}:{},hostSettings:TQ(M3,R3,s)}),[o,M3,R3,s]),O3=(0,ye.useMemo)(()=>{for(let X of vu.elements.values())if(pe(X))return!0;return!1},[vu]);(0,ye.useEffect)(()=>{if(dP(),i)for(let X of i)Di.register(X);if(c)for(let X of c)hv(X);if(u)for(let X of u)Ip(X)},[i,c,u]);let[Ts,TP]=(0,ye.useState)(null),[Vh,EP]=(0,ye.useState)(null),[jh,CP]=(0,ye.useState)(null),[IP,D3]=(0,ye.useState)(!1),[ix,P3]=(0,ye.useState)(!1),B3=(0,ye.useRef)(null),N3=(0,ye.useRef)(!1);(0,ye.useEffect)(()=>{let X=!1;return(async()=>{B3.current??=nP(h);let Un=await B3.current;if(X)return;N3.current||(N3.current=!0,oP(Un)),TP(Un);let Es=[];Es.push(q8(document).then(()=>{X||P3(!0)},$t=>{X||P3(!0),console.warn("[diagram] bundled fonts load failed",$t)})),Un.wasmText&&Es.push(Oh.loadBundled().then($t=>{X||(Pp($t),EP($t),D3(!0))},$t=>{X||(D3(!0),console.warn("[diagram] WASM text shaper load failed",$t))})),Un.wasmRaster&&Es.push(Ph.loadBundled().then($t=>{X||(Bp($t),CP($t))},$t=>{console.warn("[diagram] WASM rasterizer load failed",$t)})),await Promise.allSettled(Es)})(),()=>{X=!0}},[h]);let[xe,MP]=(0,ye.useState)(null),RP=(0,ye.useCallback)(X=>{if(l)for(let Un of l)X.registerFileDropHandler(Un);MP(X),d?.(X)},[l,d]);return(0,ye.useEffect)(()=>{xe&&(!Vh&&!jh||xe.setActiveTool(xe.activeTool.type))},[xe,Vh,jh]),(0,ye.useEffect)(()=>{xe&&xe.forceRender()},[xe,u]),(0,ye.useEffect)(()=>{xe&&ix&&xe.forceRender()},[xe,ix]),(0,ye.useEffect)(()=>{if(!xe||!f&&!p)return;let X=xe.scene,Un=xe.selection;return xe.subscribe(()=>{f&&xe.scene!==X&&(X=xe.scene,f(xe.scene)),p&&xe.selection!==Un&&(Un=xe.selection,p(xe.selection))})},[xe,f,p]),(0,ye.useEffect)(()=>{if(!xe)return;let X=xe,Un=Qt=>{oa(Qt.target)||(X.setSnapSuppressed(Qt.metaKey||Qt.ctrlKey),X.setTransformModifiers({alt:Qt.altKey,shift:Qt.shiftKey}))},Es=Qt=>{Un(Qt),!oa(Qt.target)&&Qt.key==="Escape"&&X.flowchartPreview!==null&&(X.cancelFlowchart(),Qt.preventDefault())},$t=Qt=>{Un(Qt),!Qt.metaKey&&!Qt.ctrlKey&&X.flowchartPreview!==null&&X.commitFlowchart()},z3=()=>{X.setSnapSuppressed(!1),X.setTransformModifiers({alt:!1,shift:!1}),X.flowchartPreview!==null&&X.commitFlowchart()};return window.addEventListener("keydown",Es),window.addEventListener("keyup",$t),window.addEventListener("blur",z3),()=>{window.removeEventListener("keydown",Es),window.removeEventListener("keyup",$t),window.removeEventListener("blur",z3),X.setSnapSuppressed(!1),X.setTransformModifiers({alt:!1,shift:!1})}},[xe]),(0,ye.useImperativeHandle)(n,()=>({editor:xe,capabilities:Ts,getScene:()=>xe?.scene??vu,loadScene:X=>xe?.loadScene(X),getActiveTool:()=>xe?.activeTool??null,setActiveTool:X=>xe?.setActiveTool(X),getSelection:()=>xe?.selection??new Set,setSelection:X=>xe?.setSelection(X),undo:()=>{xe?.undo()},redo:()=>{xe?.redo()},zoomToFit:()=>{xe?.zoomToFit()}}),[xe,vu,Ts]),Ts?O3&&!ix?(0,R.jsx)("div",{className:Gh,style:Wh}):Ts.renderer==="webgl2"&&Ts.wasmText&&!IP&&O3?(0,R.jsx)("div",{className:Gh,style:Wh}):(0,R.jsx)(Ef,{container:_P,children:(0,R.jsx)(g3,{children:(0,R.jsx)(rA,{children:(0,R.jsx)("div",{className:Gh,"data-diagram-root":!0,...qh==="system"?{}:{"data-theme":qh},style:{position:"relative",width:"100%",height:"100%",background:"var(--du-canvas-bg)",...Wh},children:(0,R.jsx)(WL,{initialScene:vu,initialTool:a,onReady:RP,renderer:Ts.renderer,...Ts.renderer==="offscreen"?{workerFactory:m??DL}:{},...Vh?{textShaper:Vh}:{},...jh?{rasterizer:jh}:{},children:(0,R.jsx)(m3,{children:(0,R.jsx)(vQ,{hideTopBar:x,hideBottomBar:y,hideToolbar:g,hideLibraryButton:b,hideMainMenu:A,hideZoomControls:_,hideResetToContent:C,hideHelpButton:w,hideContextMenu:L,hideSelectionPanel:k,hideDrawingPanel:M,minimap:B,renderTopBarLeft:G,renderTopBarCenter:ie,renderTopBarRight:ne,renderBottomBarLeft:V,renderBottomBarCenter:ve,renderBottomBarRight:ge,renderMainMenuExtras:ee,onImportTemplates:Se,repositoryUrl:St,onConfirm:Hh,onNotify:Uh,theme:qh,changeTheme:wP})})})})})})}):(0,R.jsx)("div",{className:Gh,style:Wh})});zh.displayName="Editor";var vQ=({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:C,theme:w,changeTheme:L})=>{let k=U(),{zen:M}=y3(),B=A===void 0?AQ:A,G=_??(St=>window.confirm(St)),ie=C??(St=>{window.alert(St)});(0,ye.useEffect)(()=>{gP(),hP(ie)},[ie]),Ka();let ne=uL(),V=Jp(),[ve,ge]=(0,ye.useState)(!1),[ee,Se]=(0,ye.useState)(!1);eL(()=>{Se(St=>!St)});let Oe=240,qt=12,xn=!V&&ve?Oe+qt:qt,Bo=(0,ye.useMemo)(()=>o?[...$g]:[{kind:"action",id:"toggle-library",label:(0,R.jsx)(Qd,{...rx}),title:"Templates library",active:ve,onClick:()=>{ge(St=>!St)}},{kind:"divider"},...$g],[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)(qL,{style:{position:"absolute",inset:0}}),(0,R.jsx)($L,{}),(0,R.jsx)(QL,{}),(0,R.jsx)(JL,{}),(0,R.jsx)(e3,{}),(0,R.jsx)(t3,{}),!l&&(0,R.jsx)(l3,{items:u3})]}),!n&&!M?(0,R.jsx)(a3,{orientation:"vertical",items:Bo,style:{position:"absolute",top:"50%",left:`calc(env(safe-area-inset-left, 0px) + ${xn}px)`,transform:"translateY(-50%)",zIndex:60}}):null,(0,R.jsxs)(lA,{children:[!e&&!M&&(0,R.jsx)(cA,{left:(0,R.jsxs)(oi,{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)(qd,{...pt}),onClick:()=>{k&&T3(k)},shortcut:dt({key:"O",meta:!0}),children:"Open\u2026"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Wd,{...pt}),onClick:()=>{k&&w3(k.scene)},disabled:!k,shortcut:dt({key:"S",meta:!0}),children:"Save as JSON"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Ur,{...pt}),onClick:()=>{k&&E3(k)},disabled:!k,shortcut:dt({key:"C",shift:!0,alt:!0}),children:"Copy as image"}),(0,R.jsxs)(Q.Submenu,{icon:(0,R.jsx)(tc,{...pt}),label:"Export\u2026",disabled:!k,children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)($s,{...pt}),onClick:()=>k&&void Nh(k,"transparent"),disabled:!k,children:"PNG (transparent)"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)($s,{...pt}),onClick:()=>k&&void Nh(k,"color"),disabled:!k,shortcut:dt({key:"E",meta:!0,shift:!0}),children:"PNG (with background)"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)($s,{...pt}),onClick:()=>k&&void Nh(k,"color-and-grid"),disabled:!k,children:"PNG (with background + grid)"}),(0,R.jsx)(Q.Separator,{}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(tc,{...pt}),onClick:()=>{k&&yP(k.scene)},disabled:!k,children:"SVG"})]}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(hf,{...pt}),onClick:()=>{k&&G("Reset canvas? This clears all shapes.")&&k.clear()},disabled:!k,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)(ti,{...pt}),shortcut:"\u2318Z",onClick:()=>k?.undo(),disabled:!k,children:"Undo"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(ei,{...pt}),shortcut:"\u21E7\u2318Z",onClick:()=>k?.redo(),disabled:!k,children:"Redo"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(mf,{...pt}),shortcut:"\u2318X",onClick:()=>k?.cutSelected(),disabled:!k,children:"Cut"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Ur,{...pt}),shortcut:"\u2318C",onClick:()=>k?.copySelected(),disabled:!k,children:"Copy"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Nd,{...pt}),shortcut:"\u2318V",onClick:()=>k?.paste(),disabled:!k,children:"Paste"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(lf,{...pt}),shortcut:"\u2318A",onClick:()=>k?.selectAll(),disabled:!k,children:"Select all"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Fd,{...pt}),shortcut:"\u232B",onClick:()=>k?.deleteSelected(),disabled:!k,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)(nc,{...pt}),shortcut:"\u21E7F",onClick:()=>k?.zoomToFit(),disabled:!k,children:"Fit to screen"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Tf,{...pt}),shortcut:"\u2318+",onClick:()=>k?.zoomIn(),disabled:!k,children:"Zoom in"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(wf,{...pt}),shortcut:"\u2318\u2212",onClick:()=>k?.zoomOut(),disabled:!k,children:"Zoom out"})]}),(0,R.jsx)(Q.Separator,{}),(0,R.jsx)(Q.Group,{title:"Theme",children:(0,R.jsx)(Q.Toggle,{value:w,onChange:L,options:[{value:"light",label:"Light",icon:(0,R.jsx)(Af,{...ws})},{value:"dark",label:"Dark",icon:(0,R.jsx)(rf,{...ws})},{value:"system",label:"System",icon:(0,R.jsx)(af,{...ws})}]})}),(0,R.jsx)(Q.Group,{title:"Grid",children:(0,R.jsx)(Q.Toggle,{value:EQ(k),onChange:St=>{IQ(k,St)},options:[{value:"lines",label:"Lines",icon:(0,R.jsx)(Ao,{...ws})},{value:"dots",label:"Dots",icon:(0,R.jsx)(Xd,{...ws})},{value:"off",label:"Off",icon:(0,R.jsx)(Ba,{...ws})}]})}),(0,R.jsx)(Q.Group,{title:"Snap to grid",children:(0,R.jsx)(Q.Toggle,{value:CQ(k),onChange:St=>{k?.setSnapToGrid(St==="on")},options:[{value:"on",label:"On",icon:(0,R.jsx)(nf,{...ws})},{value:"off",label:"Off",icon:(0,R.jsx)(Ba,{...ws})}]})}),(0,R.jsx)(Q.Separator,{}),(0,R.jsxs)(Q.Group,{title:"Help",children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Cn,{...pt}),shortcut:"?",onClick:()=>{Se(!0)},children:"Hotkeys"}),B?(0,R.jsx)(Q.ItemLink,{href:B,external:!0,children:"GitHub"}):null]}),g?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Q.Separator,{}),g()]}):null]}),f?f():null]}),center:p?.(),right:(0,R.jsx)(oi,{ariaLabel:"Top bar actions",children:h?h():null})}),!t&&!M&&(0,R.jsx)(uA,{left:m?m():null,center:x?x():s?null:(0,R.jsx)(aL,{}),right:y?y():r?i?null:(0,R.jsx)(fg,{}):(0,R.jsx)(wQ,{trailing:i?void 0:(0,R.jsx)(fg,{})})}),M?null:V?ve?(0,R.jsx)(KL,{snapPoints:[0,60,92],defaultValue:60,style:{pointerEvents:"auto"},onChange:St=>{St<=0&&ge(!1)},children:(0,R.jsx)(vg,{open:!0,sheet:!0,onClose:()=>{ge(!1)},...b?{onImport:b}:{}})}):null:(0,R.jsx)(vg,{open:ve,side:"left",style:{left:0},onClose:()=>{ge(!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)(VL,{})}),!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)(jL,{})}),!c&&!M&&(0,R.jsx)(_L,{}),(0,R.jsx)($p,{open:ee,onClose:()=>{Se(!1)}}),(0,R.jsx)(d3,{}),(0,R.jsx)(p3,{}),(0,R.jsx)(h3,{}),void 0]})},SQ=dt({meta:!0,key:"\u2212"}),LQ=dt({meta:!0,key:"+"}),kQ=dt({meta:!0,key:"0"}),_Q=dt({alt:!0,key:"1"}),wQ=({trailing:e})=>{let t=U(),[,n]=(0,ye.useState)(0);if((0,ye.useEffect)(()=>{if(t)return t.subscribe(()=>{n(a=>a+1)})},[t]),!t)return null;let o=t.scene.viewport.zoom;return(0,R.jsxs)(oi,{ariaLabel:"Zoom",children:[(0,R.jsx)(Jn,{label:`Zoom out (${SQ})`,onClick:()=>{t.zoomOut()},children:(0,R.jsx)(Ba,{...rx})}),(0,R.jsx)(ni,{content:`Reset zoom to 100% (${kQ})`,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)(Jn,{label:`Zoom in (${LQ})`,onClick:()=>{t.zoomIn()},children:(0,R.jsx)(Js,{...rx})}),(0,R.jsx)(Jn,{label:`Fit to screen (${_Q})`,onClick:()=>{t.zoomToFit()},children:(0,R.jsx)(nc,{...rx})}),e]})},TQ=(e,t,n)=>({viewport:{...e!==void 0?{gridEnabled:e}:{},...t!==void 0?{gridStyle:t}:{},...n!==void 0?{snapToGrid:n}:{}}}),EQ=e=>{if(!e)return"lines";let t=e.scene.viewport;return t.gridEnabled?t.gridStyle??"lines":"off"},CQ=e=>e?.snapToGridEnabled??!0?"on":"off",IQ=(e,t)=>{if(e){if(t==="off"){e.setGrid({enabled:!1});return}e.setGrid({enabled:!0,style:t})}};var xP=`/**
|
|
170
|
+
${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"},Te("zoom-in"),Te("zoom-out"),Te("zoom-reset",{label:"Reset zoom (100%)"}),Te("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=>{f3(e)}}];var dr=P(se(),1),Nn=P(re(),1);var h3=()=>{let e=U(),[t,n]=(0,Nn.useState)(!1),[o,a]=(0,Nn.useState)(""),[r,s]=(0,Nn.useState)(0),i=(0,Nn.useRef)(null);(0,Nn.useEffect)(()=>(we.replace({id:"open-command-palette",label:"Command palette",category:"other",hotkey:[{key:"k",meta:!0},{key:"p",meta:!0,shift:!0}],perform:()=>{n(!0)}}),we.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})=>{f3(m)}}),()=>{we.unregister("open-command-palette"),we.unregister("clear-canvas")}),[]);let l=(0,Nn.useMemo)(()=>we.getAll().filter(m=>m.label!==void 0&&m.id!=="open-command-palette"),[t]),c=e?{editor:e}:null,u=(0,Nn.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,Nn.useEffect)(()=>{if(!t)return;a(""),s(0);let m=requestAnimationFrame(()=>i.current?.focus());return()=>{cancelAnimationFrame(m)}},[t]),(0,Nn.useEffect)(()=>{s(0)},[o]),!t)return null;let d=()=>{n(!1)},f=m=>{!m.enabled||!c||(d(),we.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-hover-overlay)":"transparent"});return(0,dr.jsxs)(mg,{open:t,onClose:d,title:"Command palette",style:x$,children:[(0,dr.jsx)("input",{ref:i,value:o,onChange:m=>{a(m.target.value)},onKeyDown:p,placeholder:"Search commands\u2026","aria-label":"Search commands",style:b$}),(0,dr.jsx)("ul",{style:A$,role:"listbox",children:u.length===0?(0,dr.jsx)("li",{style:{padding:"12px 14px",opacity:.6},children:"No commands"}):u.map((m,x)=>{let y=g$(m.action);return(0,dr.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,dr.jsx)("span",{children:m.action.label}),y?(0,dr.jsx)("kbd",{style:v$,children:y}):null]},m.action.id)})})]})},g$=e=>{if(e.hotkey){let n=(Array.isArray(e.hotkey)?e.hotkey:[e.hotkey])[0];if(n)return dt(n)}return e.sequence&&e.sequence.length>0?e.sequence.map(t=>t.length===1?t.toUpperCase():t).join(" "):null},x$={maxWidth:520,width:"calc(100vw - 64px)",padding:0,display:"flex",flexDirection:"column",overflow:"hidden"},b$={border:"none",borderBottom:"1px solid var(--du-ui-border)",outline:"none",padding:"14px 16px",fontSize:15,background:"transparent",color:"inherit"},A$={listStyle:"none",margin:0,padding:4,maxHeight:360,overflowY:"auto"},v$={fontSize:11,color:"var(--du-text-muted, #6b6b6b)",fontFamily:"inherit"};var ks=P(se(),1),zn=P(re(),1);var y3=()=>{let e=U(),t=$a(),[n,o]=(0,zn.useState)(!1),[a,r]=(0,zn.useState)(""),[s,i]=(0,zn.useState)(0),l=(0,zn.useRef)(null);(0,zn.useEffect)(()=>(we.replace({id:"open-search",label:"Find text",category:"other",viewMode:!0,hotkey:{key:"f",meta:!0},perform:()=>{o(!0)}}),()=>{we.unregister("open-search")}),[]);let c=(0,zn.useMemo)(()=>a.trim()?bS(t,a):[],[t,a]),u=(0,zn.useRef)(c);if(u.current=c,(0,zn.useEffect)(()=>{if(!n||!e)return;let m=u.current[s];m&&(m.kind==="element"?e.setSelection([m.id]):e.selectLink(m.id),e.revealSelection(aC))},[n,s,a,e]),(0,zn.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,ks.jsxs)("div",{style:S$,role:"search",children:[(0,ks.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:L$}),(0,ks.jsx)("span",{style:k$,"aria-live":"polite",children:h}),(0,ks.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Previous match",title:"Previous (\u21E7\u23CE)",disabled:c.length===0,onClick:()=>{f(-1)},style:m3,children:"\u2191"}),(0,ks.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Next match",title:"Next (\u23CE)",disabled:c.length===0,onClick:()=>{f(1)},style:m3,children:"\u2193"}),(0,ks.jsx)("button",{type:"button",className:"du-icon-button","aria-label":"Close search",title:"Close (Esc)",onClick:d,style:m3,children:"\u2715"})]})},S$={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"},L$={border:"none",outline:"none",padding:"4px 8px",fontSize:14,minWidth:180,background:"transparent",color:"inherit"},k$={fontSize:12,color:"var(--du-text-muted)",minWidth:56,textAlign:"right",whiteSpace:"nowrap"},m3={minWidth:28,height:28};var at=P(se(),1),Au=P(re(),1);var g3=()=>{let e=U(),[t,n]=(0,Au.useState)(!1),[,o]=(0,Au.useState)(0);if((0,Au.useEffect)(()=>(we.replace({id:"toggle-stats",label:"Stats panel",category:"other",viewMode:!0,hotkey:{key:"/",alt:!0},perform:()=>{n(u=>!u)}}),()=>{we.unregister("toggle-stats")}),[]),(0,Au.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:_$,role:"status","aria-label":"Selection stats","aria-live":"polite",children:[(0,at.jsx)("div",{style:fP,children:"Selection"}),a?(0,at.jsxs)(at.Fragment,{children:[(0,at.jsx)(fr,{label:"X",value:Ph(a.x)}),(0,at.jsx)(fr,{label:"Y",value:Ph(a.y)}),(0,at.jsx)(fr,{label:"W",value:Ph(a.width)}),(0,at.jsx)(fr,{label:"H",value:Ph(a.height)}),c!==null?(0,at.jsx)(fr,{label:"\u2220",value:`${String(Ph(c))}\xB0`}):null,i>1?(0,at.jsx)(fr,{label:"Count",value:String(i)}):null]}):(0,at.jsx)("div",{style:C$,children:"Nothing selected"}),(0,at.jsx)("div",{style:{...fP,marginTop:8},children:"Scene"}),(0,at.jsx)(fr,{label:"Elements",value:String(l.elements.size)}),(0,at.jsx)(fr,{label:"Edges",value:String(l.links.size)}),(0,at.jsx)(fr,{label:"Selected",value:String(i)})]})},Ph=e=>Math.round(e*10)/10,fr=({label:e,value:t})=>(0,at.jsxs)("div",{style:w$,children:[(0,at.jsx)("span",{style:T$,children:e}),(0,at.jsx)("span",{style:E$,children:t})]}),_$={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"},fP={fontSize:10,textTransform:"uppercase",letterSpacing:.6,color:"var(--du-text-muted)",marginBottom:4},w$={display:"flex",justifyContent:"space-between",gap:12,lineHeight:"18px"},T$={color:"var(--du-text-muted)"},E$={fontVariantNumeric:"tabular-nums",fontFamily:"ui-monospace, monospace"},C$={color:"var(--du-text-muted)",fontStyle:"italic"};var pP=P(se(),1),Fn=P(re(),1);var hP=(0,Fn.createContext)(null),x3=({children:e})=>{let[t,n]=(0,Fn.useState)(!1),o=(0,Fn.useCallback)(()=>{n(r=>!r)},[]);(0,Fn.useEffect)(()=>(we.replace({id:"toggle-zen-mode",label:"Zen mode",category:"other",viewMode:!0,hotkey:{key:"z",alt:!0},perform:()=>{n(r=>!r)}}),()=>{we.unregister("toggle-zen-mode")}),[]),(0,Fn.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,Fn.useMemo)(()=>({zen:t,setZen:n,toggle:o}),[t,o]);return(0,pP.jsx)(hP.Provider,{value:a,children:e})},b3=()=>{let e=(0,Fn.useContext)(hP);if(!e)throw new Error("@oh-just-another/react-ui: useZenMode called outside <ZenModeProvider>.");return e};var pr=P(se(),1),Hn=P(re(),1);var I$=(0,Hn.createContext)(null);var A3=({children:e,defaultDuration:t=VE,style:n})=>{let[o,a]=(0,Hn.useState)([]),r=(0,Hn.useRef)(0),s=(0,Hn.useCallback)(c=>{a(u=>u.filter(d=>d.id!==c))},[]),i=(0,Hn.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,Hn.useMemo)(()=>({push:i,dismiss:s}),[i,s]);return(0,pr.jsxs)(I$.Provider,{value:l,children:[e,(0,pr.jsx)(M$,{toasts:o,onDismiss:s,...n?{style:n}:{}})]})},M$=({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,pr.jsx)("div",{style:o,"aria-live":"polite","aria-atomic":"false",children:e.map(a=>(0,pr.jsx)(O$,{toast:a,onDismiss:t},a.id))})},R$={info:"var(--accent, #5b5bd6)",success:"#2e8b57",warn:"#c79100",error:"#c83232"},O$=({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 ${R$[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,pr.jsxs)("div",{role:"status",style:n,children:[(0,pr.jsx)("span",{style:{flex:1,lineHeight:1.35},children:e.message}),(0,pr.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),vt=P(re(),1);var D$=16,P$=1.75,mP=(0,vt.createContext)(null),yP=()=>(0,vt.useContext)(mP)??{close:()=>{}},Q=({children:e,trigger:t=(0,Xe.jsx)(rf,{size:D$,strokeWidth:P$}),className:n,style:o})=>{let[a,r]=(0,vt.useState)(!1),s=(0,vt.useRef)(null),i=(0,vt.useId)();(0,vt.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,vt.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)(mP.Provider,{value:{close:l},children:e})}):null]})},B$={display:"block",width:"100%",textAlign:"left",background:"transparent",color:"inherit",border:"none",borderRadius:4,padding:"6px 10px",font:"inherit",fontSize:13,cursor:"pointer"},v3=e=>({...B$,...e}),N$=({children:e,onClick:t,shortcut:n,disabled:o,active:a,icon:r})=>{let{close:s}=yP();return(0,Xe.jsxs)("button",{type:"button",role:"menuitem",disabled:o,onClick:()=>{o||(t?.(),s())},style:{...v3(),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, #5b5bd6)":"var(--du-text-muted, #888)"},children:a?(0,Xe.jsx)(Pd,{size:12,strokeWidth:2.25}):r??""}),e]}),n?(0,Xe.jsx)("span",{style:{color:"var(--muted, #888)",fontSize:11},children:n}):null]})},z$=({children:e,href:t,external:n})=>{let{close:o}=yP();return(0,Xe.jsx)("a",{role:"menuitem",href:t,target:n?"_blank":void 0,rel:n?"noreferrer noopener":void 0,onClick:o,style:{...v3({textDecoration:"none"}),color:"var(--text, #ddd)"},children:e})},F$=()=>(0,Xe.jsx)("hr",{style:{margin:"4px 6px",border:"none",borderTop:"1px solid var(--border, #2a2a2a)"}}),H$=({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]}),U$=({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)})}),G$=120,W$=({children:e,label:t,icon:n,disabled:o})=>{let[a,r]=(0,vt.useState)(!1),s=(0,vt.useRef)(null),i=(0,vt.useCallback)(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null)},[]),l=(0,vt.useCallback)(()=>{i(),s.current=window.setTimeout(()=>{r(!1),s.current=null},G$)},[i]);(0,vt.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:{...v3(),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)($s,{size:12,strokeWidth:2.25,"aria-hidden":!0})]}),a?(0,Xe.jsx)("div",{role:"menu",style:c,children:e}):null]})};Q.Item=N$;Q.ItemLink=z$;Q.Separator=F$;Q.Group=H$;Q.Toggle=U$;Q.Submenu=W$;var Bh=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 Np(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=`${gP(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}=is(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=gP(n);if(a!==this.currentFontKey){let u=this.textEncoder.encode(n.family),d=is(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}=is(o,r),c=o.measure(s,i);return l(),{width:c}}},gP=e=>`${e.family}|${e.size}|${e.weight??"normal"}|${e.style??"normal"}`;var q$={butt:0,round:1,square:2},V$={miter:0,round:1,bevel:2},j$={M:0,L:1,Q:2,C:3,Z:4},zh=class e{defaultTolerance;wasm=null;constructor(t={}){this.defaultTolerance=t.defaultTolerance??.5}get isReady(){return this.wasm!==null}async loadModule(t){let n=await Np(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):zy.flatten(t,o)}strokeToFill(t,n,o){return this.wasm?this.strokeToFillViaWasm(t,n,o,this.wasm):zy.strokeToFill(t,n,o)}flattenViaWasm(t,n,o){let a=Z$(t),r=is(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=nx(o.memory,s),c=nx(o.memory,i);return xP(o.memory,l,c)}finally{r.free(),o.free(s,4),o.free(i,4)}}strokeToFillViaWasm(t,n,o,a){let r=X$(t),s=is(a,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),i=a.alloc(4),l=a.alloc(4);try{let c=q$[o?.cap??"butt"],u=V$[o?.join??"miter"];a.strokeToFillF32(s.ptr,t.length,n,c,u,i,l);let d=nx(a.memory,i),f=nx(a.memory,l);return xP(a.memory,d,f)}finally{s.free(),a.free(i,4),a.free(l,4)}}},Nh=new Float32Array(256),bP=e=>{if(Nh.length>=e)return;let t=Nh.length;for(;t<e;)t*=2;Nh=new Float32Array(t)},Z$=e=>{bP(e.length*7);let t=Nh,n=0;for(let o of e)switch(t[n++]=j$[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)},X$=e=>{bP(e.length*2);let t=Nh;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)},nx=(e,t)=>new DataView(e.buffer,t,4).getUint32(0,!0),xP=(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 vP=()=>typeof Worker<"u",AP=()=>typeof WebAssembly<"u"&&typeof WebAssembly.instantiate=="function",Y$=()=>{if(typeof matchMedia!="function")return!1;try{return matchMedia("(pointer: coarse)").matches}catch{return!1}},K$=async()=>await qL()||VL()?"webgl2":Xg()&&vP()?"offscreen":"canvas2d",SP=async(e={})=>{let t=e.renderer&&e.renderer!=="auto"?e.renderer:await K$(),n=e.wasmText!==void 0&&e.wasmText!=="auto"?e.wasmText:AP(),o=e.wasmRaster!==void 0&&e.wasmRaster!=="auto"?e.wasmRaster:AP()&&t==="webgl2",a=e.workers!==void 0&&e.workers!=="auto"?e.workers:Xg()&&vP(),r=e.tiles!==void 0&&e.tiles!=="auto"?e.tiles:!0;return{renderer:t,wasmText:n,wasmRaster:o,workers:a,tiles:r,touch:Y$()}},LP=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 k3=new WeakMap,_3=new WeakSet,wQ=async e=>{let{parseGIF:t,decompressFrames:n}=await Promise.resolve().then(()=>P(CP(),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}},TQ={kind:"gif",getFrameAt(e,t){if(!(e instanceof ArrayBuffer)||e.byteLength===0)return null;let n=k3.get(e);if(!n)return _3.has(e)||(_3.add(e),wQ(e).then(r=>{k3.set(e,r),Z2()}).catch(()=>{}).finally(()=>_3.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 k3.get(e)?.totalMs??0}},IP=!1,MP=()=>{IP||(IP=!0,Op(TQ))};var Fh=P(re(),1);var RP=e=>{let t=Pt(),[n]=(0,Fh.useState)(()=>typeof document>"u"?null:document.createElement("div"));return(0,Fh.useEffect)(()=>{if(n)return n.setAttribute("data-diagram-portal",""),t.appendChild(n),()=>{n.remove()}},[n,t]),(0,Fh.useEffect)(()=>{n&&(e==="system"?n.removeAttribute("data-theme"):n.setAttribute("data-theme",e))},[n,e]),n};var T3=async(e,t)=>{if(typeof OffscreenCanvas>"u")return null;let n=EQ(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&&Bp(l,i),Ya(l,i,{skipClear:!0}),Bn(l,i),s.convertToBlob({type:"image/png"})},EQ=e=>{let t=null;for(let n of Lo(e))if(n.visible)for(let o of Wa(e,n.id)){let a=N(o);t=t?CQ(t,a):a}return t},CQ=(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 OP=2,vu=e=>{typeof window<"u"&&window.alert(e)},DP=e=>{vu=e},E3=(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)})},C3=e=>{let t=KL(e,2);E3(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=QL(o);e.loadScene(a)}catch(a){console.error("[diagram] failed to parse scene file:",a),vu("Failed to parse the file \u2014 make sure it was saved through this app's Save action.")}})},t.click()},PP=()=>{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"},Hh=async(e,t)=>{let n=await T3(e.scene,{background:t,scale:OP,backgroundColor:PP()});if(!n){vu("Nothing to export \u2014 the canvas is empty.");return}E3(n,"scene.png")},BP=e=>{let t=u3(e);E3(new Blob([t],{type:"image/svg+xml"}),"scene.svg")},M3=async e=>{let t=typeof navigator>"u"?void 0:navigator.clipboard;if(typeof t?.write!="function"||typeof ClipboardItem>"u"){vu("Copy to clipboard isn't supported in this browser.");return}let n=await T3(e.scene,{background:"color",scale:OP,backgroundColor:PP()});if(!n){vu("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),vu("Couldn't copy the image to the clipboard.")}},IQ=[{id:"save-scene",label:"Save as JSON",category:"other",viewMode:!0,hotkey:{key:"s",meta:!0},perform:({editor:e})=>{C3(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})=>{Hh(e,"color")}},{id:"copy-as-image",label:"Copy as image",category:"other",viewMode:!0,hotkey:{key:"c",shift:!0,alt:!0},perform:({editor:e})=>{M3(e)}}],NP=(e=we)=>{for(let t of IQ)e.replace(t)};var MQ=14,RQ=14,OQ=16,R3=1.75,pt={size:MQ,strokeWidth:R3},Es={size:RQ,strokeWidth:R3},lx={size:OQ,strokeWidth:R3},DQ="https://github.com/oh-just-another/diagram",Uh=(0,ye.forwardRef)(function(t,n){let{initialScene:o,initialTool: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:C,hideHelpButton:w,hideContextMenu:L,hideSelectionPanel:k,hideDrawingPanel:M,minimap:B,renderTopBarLeft:G,renderTopBarCenter:ie,renderTopBarRight:ne,renderBottomBarLeft:V,renderBottomBarCenter:ve,renderBottomBarRight:ge,renderMainMenuExtras:ee,onImportTemplates:Se,theme:Oe,defaultTheme:qt="system",onThemeChange:xn,persistTheme:Bo,repositoryUrl:St,onConfirm:Wh,onNotify:qh,className:Vh,style:jh}=t,Su=(0,ye.useMemo)(()=>Bo===!0?"diagram-theme":typeof Bo=="string"?Bo:null,[Bo]),[WP,qP]=(0,ye.useState)(()=>{if(!Su||typeof window>"u")return qt;let X=window.localStorage.getItem(Su);return X==="light"||X==="dark"||X==="system"?X:qt}),Zh=Oe??WP,VP=RP(Zh),jP=(0,ye.useCallback)(X=>{Oe===void 0&&qP(X),Su&&typeof window<"u"&&window.localStorage.setItem(Su,X),xn?.(X)},[Oe,xn,Su]),D3=r?.enabled,P3=r?.style,Lu=(0,ye.useMemo)(()=>xv({...o?{saved:o}:{},hostSettings:UQ(D3,P3,s)}),[o,D3,P3,s]),B3=(0,ye.useMemo)(()=>{for(let X of Lu.elements.values())if(pe(X))return!0;return!1},[Lu]);(0,ye.useEffect)(()=>{if(MP(),i)for(let X of i)Bi.register(X);if(c)for(let X of c)wv(X);if(u)for(let X of u)Op(X)},[i,c,u]);let[Cs,ZP]=(0,ye.useState)(null),[Xh,XP]=(0,ye.useState)(null),[Yh,YP]=(0,ye.useState)(null),[KP,N3]=(0,ye.useState)(!1),[ux,z3]=(0,ye.useState)(!1),F3=(0,ye.useRef)(null),H3=(0,ye.useRef)(!1);(0,ye.useEffect)(()=>{let X=!1;return(async()=>{F3.current??=SP(h);let Un=await F3.current;if(X)return;H3.current||(H3.current=!0,LP(Un)),ZP(Un);let Is=[];Is.push(u6(document).then(()=>{X||z3(!0)},$t=>{X||z3(!0),console.warn("[diagram] bundled fonts load failed",$t)})),Un.wasmText&&Is.push(Bh.loadBundled().then($t=>{X||(zp($t),XP($t),N3(!0))},$t=>{X||(N3(!0),console.warn("[diagram] WASM text shaper load failed",$t))})),Un.wasmRaster&&Is.push(zh.loadBundled().then($t=>{X||(Fp($t),YP($t))},$t=>{console.warn("[diagram] WASM rasterizer load failed",$t)})),await Promise.allSettled(Is)})(),()=>{X=!0}},[h]);let[xe,$P]=(0,ye.useState)(null),QP=(0,ye.useCallback)(X=>{if(l)for(let Un of l)X.registerFileDropHandler(Un);$P(X),d?.(X)},[l,d]);return(0,ye.useEffect)(()=>{xe&&(!Xh&&!Yh||xe.setActiveTool(xe.activeTool.type))},[xe,Xh,Yh]),(0,ye.useEffect)(()=>{xe&&xe.forceRender()},[xe,u]),(0,ye.useEffect)(()=>{xe&&ux&&xe.forceRender()},[xe,ux]),(0,ye.useEffect)(()=>{if(!xe||!f&&!p)return;let X=xe.scene,Un=xe.selection;return xe.subscribe(()=>{f&&xe.scene!==X&&(X=xe.scene,f(xe.scene)),p&&xe.selection!==Un&&(Un=xe.selection,p(xe.selection))})},[xe,f,p]),(0,ye.useEffect)(()=>{if(!xe)return;let X=xe,Un=Qt=>{oa(Qt.target)||(X.setSnapSuppressed(Qt.metaKey||Qt.ctrlKey),X.setTransformModifiers({alt:Qt.altKey,shift:Qt.shiftKey}))},Is=Qt=>{Un(Qt),!oa(Qt.target)&&Qt.key==="Escape"&&X.flowchartPreview!==null&&(X.cancelFlowchart(),Qt.preventDefault())},$t=Qt=>{Un(Qt),!Qt.metaKey&&!Qt.ctrlKey&&X.flowchartPreview!==null&&X.commitFlowchart()},U3=()=>{X.setSnapSuppressed(!1),X.setTransformModifiers({alt:!1,shift:!1}),X.flowchartPreview!==null&&X.commitFlowchart()};return window.addEventListener("keydown",Is),window.addEventListener("keyup",$t),window.addEventListener("blur",U3),()=>{window.removeEventListener("keydown",Is),window.removeEventListener("keyup",$t),window.removeEventListener("blur",U3),X.setSnapSuppressed(!1),X.setTransformModifiers({alt:!1,shift:!1})}},[xe]),(0,ye.useImperativeHandle)(n,()=>({editor:xe,capabilities:Cs,getScene:()=>xe?.scene??Lu,loadScene:X=>xe?.loadScene(X),getActiveTool:()=>xe?.activeTool??null,setActiveTool:X=>xe?.setActiveTool(X),getSelection:()=>xe?.selection??new Set,setSelection:X=>xe?.setSelection(X),undo:()=>{xe?.undo()},redo:()=>{xe?.redo()},zoomToFit:()=>{xe?.zoomToFit()}}),[xe,Lu,Cs]),Cs?B3&&!ux?(0,R.jsx)("div",{className:Vh,style:jh}):Cs.renderer==="webgl2"&&Cs.wasmText&&!KP&&B3?(0,R.jsx)("div",{className:Vh,style:jh}):(0,R.jsx)(If,{container:VP,children:(0,R.jsx)(A3,{children:(0,R.jsx)(gA,{children:(0,R.jsx)("div",{className:Vh,"data-diagram-root":!0,...Zh==="system"?{}:{"data-theme":Zh},style:{position:"relative",width:"100%",height:"100%",background:"var(--du-canvas-bg)",...jh},children:(0,R.jsx)(jL,{initialScene:Lu,initialTool:a,onReady:QP,renderer:Cs.renderer,...Cs.renderer==="offscreen"?{workerFactory:m??NL}:{},...Xh?{textShaper:Xh}:{},...Yh?{rasterizer:Yh}:{},children:(0,R.jsx)(x3,{children:(0,R.jsx)(PQ,{hideTopBar:x,hideBottomBar:y,hideToolbar:g,hideLibraryButton:b,hideMainMenu:A,hideZoomControls:_,hideResetToContent:C,hideHelpButton:w,hideContextMenu:L,hideSelectionPanel:k,hideDrawingPanel:M,minimap:B,renderTopBarLeft:G,renderTopBarCenter:ie,renderTopBarRight:ne,renderBottomBarLeft:V,renderBottomBarCenter:ve,renderBottomBarRight:ge,renderMainMenuExtras:ee,onImportTemplates:Se,repositoryUrl:St,onConfirm:Wh,onNotify:qh,theme:Zh,changeTheme:jP})})})})})})}):(0,R.jsx)("div",{className:Vh,style:jh})});Uh.displayName="Editor";var PQ=({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:C,theme:w,changeTheme:L})=>{let k=U(),{zen:M}=b3(),B=A===void 0?DQ:A,G=_??(St=>window.confirm(St)),ie=C??(St=>{window.alert(St)});(0,ye.useEffect)(()=>{NP(),DP(ie)},[ie]),$a();let ne=hL(),V=nh(),[ve,ge]=(0,ye.useState)(!1),[ee,Se]=(0,ye.useState)(!1);aL(()=>{Se(St=>!St)});let Oe=240,qt=12,xn=!V&&ve?Oe+qt:qt,Bo=(0,ye.useMemo)(()=>o?[...ex]:[{kind:"action",id:"toggle-library",label:(0,R.jsx)(ef,{...lx}),title:"Templates library",active:ve,onClick:()=>{ge(St=>!St)}},{kind:"divider"},...ex],[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)(ZL,{style:{position:"absolute",inset:0}}),(0,R.jsx)(e3,{}),(0,R.jsx)(t3,{}),(0,R.jsx)(n3,{}),(0,R.jsx)(o3,{}),(0,R.jsx)(a3,{}),!l&&(0,R.jsx)(d3,{items:p3})]}),!n&&!M?(0,R.jsx)(i3,{orientation:"vertical",items:Bo,style:{position:"absolute",top:"50%",left:`calc(env(safe-area-inset-left, 0px) + ${xn}px)`,transform:"translateY(-50%)",zIndex:60}}):null,(0,R.jsxs)(AA,{children:[!e&&!M&&(0,R.jsx)(vA,{left:(0,R.jsxs)(ii,{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)(jd,{...pt}),onClick:()=>{k&&I3(k)},shortcut:dt({key:"O",meta:!0}),children:"Open\u2026"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Vd,{...pt}),onClick:()=>{k&&C3(k.scene)},disabled:!k,shortcut:dt({key:"S",meta:!0}),children:"Save as JSON"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Gr,{...pt}),onClick:()=>{k&&M3(k)},disabled:!k,shortcut:dt({key:"C",shift:!0,alt:!0}),children:"Copy as image"}),(0,R.jsxs)(Q.Submenu,{icon:(0,R.jsx)(oc,{...pt}),label:"Export\u2026",disabled:!k,children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Js,{...pt}),onClick:()=>k&&void Hh(k,"transparent"),disabled:!k,children:"PNG (transparent)"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Js,{...pt}),onClick:()=>k&&void Hh(k,"color"),disabled:!k,shortcut:dt({key:"E",meta:!0,shift:!0}),children:"PNG (with background)"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Js,{...pt}),onClick:()=>k&&void Hh(k,"color-and-grid"),disabled:!k,children:"PNG (with background + grid)"}),(0,R.jsx)(Q.Separator,{}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(oc,{...pt}),onClick:()=>{k&&BP(k.scene)},disabled:!k,children:"SVG"})]}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(yf,{...pt}),onClick:()=>{k&&G("Reset canvas? This clears all shapes.")&&k.clear()},disabled:!k,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)(oi,{...pt}),shortcut:"\u2318Z",onClick:()=>k?.undo(),disabled:!k,children:"Undo"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(ni,{...pt}),shortcut:"\u21E7\u2318Z",onClick:()=>k?.redo(),disabled:!k,children:"Redo"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(gf,{...pt}),shortcut:"\u2318X",onClick:()=>k?.cutSelected(),disabled:!k,children:"Cut"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Gr,{...pt}),shortcut:"\u2318C",onClick:()=>k?.copySelected(),disabled:!k,children:"Copy"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Fd,{...pt}),shortcut:"\u2318V",onClick:()=>k?.paste(),disabled:!k,children:"Paste"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(uf,{...pt}),shortcut:"\u2318A",onClick:()=>k?.selectAll(),disabled:!k,children:"Select all"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Ud,{...pt}),shortcut:"\u232B",onClick:()=>k?.deleteSelected(),disabled:!k,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)(ac,{...pt}),shortcut:"\u21E7F",onClick:()=>k?.zoomToFit(),disabled:!k,children:"Fit to screen"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Cf,{...pt}),shortcut:"\u2318+",onClick:()=>k?.zoomIn(),disabled:!k,children:"Zoom in"}),(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Ef,{...pt}),shortcut:"\u2318\u2212",onClick:()=>k?.zoomOut(),disabled:!k,children:"Zoom out"})]}),(0,R.jsx)(Q.Separator,{}),(0,R.jsx)(Q.Group,{title:"Theme",children:(0,R.jsx)(Q.Toggle,{value:w,onChange:L,options:[{value:"light",label:"Light",icon:(0,R.jsx)(Sf,{...Es})},{value:"dark",label:"Dark",icon:(0,R.jsx)(lf,{...Es})},{value:"system",label:"System",icon:(0,R.jsx)(sf,{...Es})}]})}),(0,R.jsx)(Q.Group,{title:"Grid",children:(0,R.jsx)(Q.Toggle,{value:GQ(k),onChange:St=>{qQ(k,St)},options:[{value:"lines",label:"Lines",icon:(0,R.jsx)(Ao,{...Es})},{value:"dots",label:"Dots",icon:(0,R.jsx)(Kd,{...Es})},{value:"off",label:"Off",icon:(0,R.jsx)(Ba,{...Es})}]})}),(0,R.jsx)(Q.Group,{title:"Snap to grid",children:(0,R.jsx)(Q.Toggle,{value:WQ(k),onChange:St=>{k?.setSnapToGrid(St==="on")},options:[{value:"on",label:"On",icon:(0,R.jsx)(af,{...Es})},{value:"off",label:"Off",icon:(0,R.jsx)(Ba,{...Es})}]})}),(0,R.jsx)(Q.Separator,{}),(0,R.jsxs)(Q.Group,{title:"Help",children:[(0,R.jsx)(Q.Item,{icon:(0,R.jsx)(Cn,{...pt}),shortcut:"?",onClick:()=>{Se(!0)},children:"Hotkeys"}),B?(0,R.jsx)(Q.ItemLink,{href:B,external:!0,children:"GitHub"}):null]}),g?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Q.Separator,{}),g()]}):null]}),f?f():null]}),center:p?.(),right:(0,R.jsx)(ii,{ariaLabel:"Top bar actions",children:h?h():null})}),!t&&!M&&(0,R.jsx)(SA,{left:m?m():null,center:x?x():s?null:(0,R.jsx)(lL,{}),right:y?y():r?i?null:(0,R.jsx)(yg,{}):(0,R.jsx)(HQ,{trailing:i?void 0:(0,R.jsx)(yg,{})})}),M?null:V?ve?(0,R.jsx)(JL,{snapPoints:[0,60,92],defaultValue:60,style:{pointerEvents:"auto"},onChange:St=>{St<=0&&ge(!1)},children:(0,R.jsx)(_g,{open:!0,sheet:!0,onClose:()=>{ge(!1)},...b?{onImport:b}:{}})}):null:(0,R.jsx)(_g,{open:ve,side:"left",style:{left:0},onClose:()=>{ge(!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)(XL,{})}),!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)(YL,{})}),!c&&!M&&(0,R.jsx)(EL,{}),(0,R.jsx)(eh,{open:ee,onClose:()=>{Se(!1)}}),(0,R.jsx)(h3,{}),(0,R.jsx)(y3,{}),(0,R.jsx)(g3,{}),void 0]})},BQ=dt({meta:!0,key:"\u2212"}),NQ=dt({meta:!0,key:"+"}),zQ=dt({meta:!0,key:"0"}),FQ=dt({alt:!0,key:"1"}),HQ=({trailing:e})=>{let t=U(),[,n]=(0,ye.useState)(0);if((0,ye.useEffect)(()=>{if(t)return t.subscribe(()=>{n(a=>a+1)})},[t]),!t)return null;let o=t.scene.viewport.zoom;return(0,R.jsxs)(ii,{ariaLabel:"Zoom",children:[(0,R.jsx)(Jn,{label:`Zoom out (${BQ})`,onClick:()=>{t.zoomOut()},children:(0,R.jsx)(Ba,{...lx})}),(0,R.jsx)(si,{content:`Reset zoom to 100% (${zQ})`,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)(Jn,{label:`Zoom in (${NQ})`,onClick:()=>{t.zoomIn()},children:(0,R.jsx)(ti,{...lx})}),(0,R.jsx)(Jn,{label:`Fit to screen (${FQ})`,onClick:()=>{t.zoomToFit()},children:(0,R.jsx)(ac,{...lx})}),e]})},UQ=(e,t,n)=>({viewport:{...e!==void 0?{gridEnabled:e}:{},...t!==void 0?{gridStyle:t}:{},...n!==void 0?{snapToGrid:n}:{}}}),GQ=e=>{if(!e)return"lines";let t=e.scene.viewport;return t.gridEnabled?t.gridStyle??"lines":"off"},WQ=e=>e?.snapToGridEnabled??!0?"on":"off",qQ=(e,t)=>{if(e){if(t==="off"){e.setGrid({enabled:!1});return}e.setGrid({enabled:!0,style:t})}};var zP=`/**
|
|
171
171
|
* Diagram UI stylesheet. Imported once by the host:
|
|
172
172
|
*
|
|
173
173
|
* import "@oh-just-another/react-ui/styles.css";
|
|
@@ -248,7 +248,9 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
248
248
|
:root {
|
|
249
249
|
/* All values mirror UI_SURFACE.dark + UI_ACCENT.dark from
|
|
250
250
|
\`@oh-just-another/tokens\`. */
|
|
251
|
-
|
|
251
|
+
/* The canvas is NOT themed (user content is authored against light
|
|
252
|
+
paper); dark mode darkens the chrome only. UI_SURFACE.dark.canvas. */
|
|
253
|
+
--du-canvas-bg: #f5f5f5;
|
|
252
254
|
--du-ui-bg: rgba(35, 35, 35, 0.95); /* UI_SURFACE.dark.bg */
|
|
253
255
|
--du-ui-bg-solid: #252525; /* UI_SURFACE.dark.bgSolid */
|
|
254
256
|
--du-ui-border: rgba(255, 255, 255, 0.08); /* UI_SURFACE.dark.border */
|
|
@@ -331,7 +333,8 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
331
333
|
|
|
332
334
|
[data-theme="dark"] {
|
|
333
335
|
/* Mirrors UI_SURFACE.dark + UI_ACCENT.dark from \`@oh-just-another/tokens\`. */
|
|
334
|
-
|
|
336
|
+
/* Canvas stays light \u2014 see the note in the media-query block above. */
|
|
337
|
+
--du-canvas-bg: #f5f5f5;
|
|
335
338
|
--du-ui-bg: rgba(35, 35, 35, 0.95);
|
|
336
339
|
--du-ui-bg-solid: #252525;
|
|
337
340
|
--du-ui-border: rgba(255, 255, 255, 0.08);
|
|
@@ -1460,8 +1463,8 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
1460
1463
|
\`is-active\` class had no visual, so toggles never reflected the
|
|
1461
1464
|
selection's current style. */
|
|
1462
1465
|
.du-sel-icon-button.is-active {
|
|
1463
|
-
background: var(--du-
|
|
1464
|
-
color: var(--du-
|
|
1466
|
+
background: var(--du-selected-bg);
|
|
1467
|
+
color: var(--du-selected-fg);
|
|
1465
1468
|
}
|
|
1466
1469
|
|
|
1467
1470
|
.du-sel-icon-button:focus-visible {
|
|
@@ -1547,16 +1550,16 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
1547
1550
|
padding: 6px 10px;
|
|
1548
1551
|
border-radius: 4px;
|
|
1549
1552
|
font-size: 13px;
|
|
1550
|
-
color: var(--du-text
|
|
1553
|
+
color: var(--du-text);
|
|
1551
1554
|
cursor: pointer;
|
|
1552
1555
|
}
|
|
1553
1556
|
|
|
1554
1557
|
.du-sel-menu-row:hover {
|
|
1555
|
-
background: var(--du-
|
|
1558
|
+
background: var(--du-hover-overlay);
|
|
1556
1559
|
}
|
|
1557
1560
|
|
|
1558
1561
|
.du-sel-menu-row.is-active {
|
|
1559
|
-
background: var(--du-
|
|
1562
|
+
background: var(--du-selected-bg);
|
|
1560
1563
|
}
|
|
1561
1564
|
|
|
1562
1565
|
/* URL field inside the element-link popover. */
|
|
@@ -1566,15 +1569,15 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
1566
1569
|
box-sizing: border-box;
|
|
1567
1570
|
padding: 6px 8px;
|
|
1568
1571
|
font-size: 13px;
|
|
1569
|
-
color: var(--du-text
|
|
1570
|
-
background: var(--du-ui-bg
|
|
1571
|
-
border: 1px solid var(--du-ui-border
|
|
1572
|
+
color: var(--du-text);
|
|
1573
|
+
background: var(--du-ui-bg);
|
|
1574
|
+
border: 1px solid var(--du-ui-border);
|
|
1572
1575
|
border-radius: 4px;
|
|
1573
1576
|
outline: none;
|
|
1574
1577
|
}
|
|
1575
1578
|
|
|
1576
1579
|
.du-sel-link-input:focus-visible {
|
|
1577
|
-
outline: 2px solid var(--du-accent
|
|
1580
|
+
outline: 2px solid var(--du-accent);
|
|
1578
1581
|
outline-offset: -1px;
|
|
1579
1582
|
}
|
|
1580
1583
|
|
|
@@ -1597,17 +1600,17 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
1597
1600
|
Segoe UI,
|
|
1598
1601
|
Roboto,
|
|
1599
1602
|
sans-serif;
|
|
1600
|
-
color: var(--du-accent
|
|
1603
|
+
color: var(--du-accent);
|
|
1601
1604
|
text-decoration: none;
|
|
1602
|
-
background: var(--menu-bg
|
|
1603
|
-
border: 1px solid var(--menu-border
|
|
1605
|
+
background: var(--menu-bg);
|
|
1606
|
+
border: 1px solid var(--menu-border);
|
|
1604
1607
|
border-radius: 6px;
|
|
1605
1608
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
|
|
1606
1609
|
cursor: pointer;
|
|
1607
1610
|
}
|
|
1608
1611
|
|
|
1609
1612
|
.du-link-popup-url:hover {
|
|
1610
|
-
background: var(--du-
|
|
1613
|
+
background: var(--du-hover-overlay);
|
|
1611
1614
|
}
|
|
1612
1615
|
|
|
1613
1616
|
.du-link-popup-text {
|
|
@@ -1635,13 +1638,13 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
1635
1638
|
border-radius: 6px;
|
|
1636
1639
|
background: transparent;
|
|
1637
1640
|
cursor: pointer;
|
|
1638
|
-
color: var(--du-
|
|
1641
|
+
color: var(--du-text);
|
|
1639
1642
|
}
|
|
1640
1643
|
.du-arrowhead-option:hover {
|
|
1641
|
-
background: var(--du-hover
|
|
1644
|
+
background: var(--du-hover-overlay);
|
|
1642
1645
|
}
|
|
1643
1646
|
.du-arrowhead-option--active {
|
|
1644
|
-
border-color: var(--du-accent
|
|
1647
|
+
border-color: var(--du-accent);
|
|
1645
1648
|
}
|
|
1646
1649
|
.du-arrowhead-none {
|
|
1647
1650
|
font-size: 13px;
|
|
@@ -1660,11 +1663,11 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
1660
1663
|
background: transparent;
|
|
1661
1664
|
cursor: pointer;
|
|
1662
1665
|
font-size: 11px;
|
|
1663
|
-
color: var(--du-muted
|
|
1666
|
+
color: var(--du-text-muted);
|
|
1664
1667
|
padding: 2px 0;
|
|
1665
1668
|
}
|
|
1666
1669
|
.du-arrowhead-erd-toggle:hover {
|
|
1667
|
-
color: var(--du-
|
|
1670
|
+
color: var(--du-text);
|
|
1668
1671
|
}
|
|
1669
1672
|
|
|
1670
1673
|
/* Inline link caption editor (multiline textarea). */
|
|
@@ -1677,9 +1680,9 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
1677
1680
|
sans-serif;
|
|
1678
1681
|
line-height: 1.25;
|
|
1679
1682
|
text-align: center;
|
|
1680
|
-
color: var(--du-
|
|
1681
|
-
background: var(--du-
|
|
1682
|
-
border: 1px solid var(--du-accent
|
|
1683
|
+
color: var(--du-text);
|
|
1684
|
+
background: var(--du-ui-bg-solid);
|
|
1685
|
+
border: 1px solid var(--du-accent);
|
|
1683
1686
|
border-radius: 4px;
|
|
1684
1687
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
|
|
1685
1688
|
outline: none;
|
|
@@ -1692,8 +1695,8 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
1692
1695
|
display: flex;
|
|
1693
1696
|
gap: 2px;
|
|
1694
1697
|
padding: 4px;
|
|
1695
|
-
background: var(--du-
|
|
1696
|
-
border: 1px solid var(--du-border
|
|
1698
|
+
background: var(--du-ui-bg-solid);
|
|
1699
|
+
border: 1px solid var(--du-ui-border);
|
|
1697
1700
|
border-radius: 8px;
|
|
1698
1701
|
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
|
|
1699
1702
|
}
|
|
@@ -1708,10 +1711,10 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
1708
1711
|
border-radius: 6px;
|
|
1709
1712
|
background: transparent;
|
|
1710
1713
|
cursor: pointer;
|
|
1711
|
-
color: var(--du-
|
|
1714
|
+
color: var(--du-text);
|
|
1712
1715
|
}
|
|
1713
1716
|
.du-link-drop-item:hover {
|
|
1714
|
-
background: var(--du-hover
|
|
1717
|
+
background: var(--du-hover-overlay);
|
|
1715
1718
|
}
|
|
1716
1719
|
.du-link-drop-item svg {
|
|
1717
1720
|
width: 100%;
|
|
@@ -1719,10 +1722,10 @@ ${n}`);if(!o)return;let a=parseInt(o,10)-1,r=t[a];r&&e.moveSelectionToLayer(r.id
|
|
|
1719
1722
|
}
|
|
1720
1723
|
|
|
1721
1724
|
.du-sel-menu-row:focus-visible {
|
|
1722
|
-
outline: 2px solid var(--du-accent
|
|
1725
|
+
outline: 2px solid var(--du-accent);
|
|
1723
1726
|
outline-offset: -2px;
|
|
1724
1727
|
}
|
|
1725
|
-
`;var
|
|
1728
|
+
`;var O3=P(se(),1),FP=new Set(["dark","light","system"]),VQ=new Set(["canvas2d","webgl2","offscreen"]),cx=null,jQ=()=>(cx||(cx=new CSSStyleSheet,cx.replaceSync(zP.replace(/:root\b/g,":host"))),cx),Gh=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=[jQ()],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,HP.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&&FP.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()}getActiveTool(){return this.#e?.getActiveTool()??null}setActiveTool(t){this.#e?.setActiveTool(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&&FP.has(t)?t:void 0,a=n&&VQ.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=qy(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,O3.jsx)(If,{container:this.#r,children:(0,O3.jsx)(Uh,{ref:t=>{this.#e=t},...this.#c()})}))}};var ZQ=["ready","scenechange","selectionchange","themechange"],UP=(e,t,n)=>{n?e.setAttribute(t,""):e.removeAttribute(t)},GP=(e,t,n)=>{n===void 0?e.removeAttribute(t):e.setAttribute(t,n)},XQ=(e,t)=>{GP(e,"theme",t.theme),GP(e,"renderer",t.renderer),UP(e,"grid",t.grid??!1),UP(e,"snap",t.snap??!1),t.scene!==void 0&&(e.scene=t.scene)},YQ=(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()}},KQ=e=>({getScene:()=>e()?.getScene(),loadScene:t=>e()?.loadScene(t),undo:()=>e()?.undo(),redo:()=>e()?.redo(),zoomToFit:()=>e()?.zoomToFit(),getActiveTool:()=>e()?.getActiveTool()??null,setActiveTool:t=>e()?.setActiveTool(t),getSelection:()=>e()?.getSelection()??new Set,setSelection:t=>e()?.setSelection(t)});var $Q="oja-diagram",QQ=(e=$Q)=>{typeof customElements>"u"||customElements.get(e)||customElements.define(e,Gh)};QQ();export{ZQ as OJA_DIAGRAM_EVENTS,$Q as OJA_DIAGRAM_TAG,Gh as OjaDiagramElement,XQ as applyOjaDiagramProps,YQ as bindOjaDiagramEvents,QQ as defineOjaDiagram,KQ as ojaDiagramController};
|
|
1726
1729
|
/*! Bundled license information:
|
|
1727
1730
|
|
|
1728
1731
|
scheduler/cjs/scheduler.production.js:
|