@kitschpatrol/tldraw-cli 4.6.33 → 4.6.34

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.
Files changed (38) hide show
  1. package/bin/cli.js +785 -234
  2. package/dist/.DS_Store +0 -0
  3. package/dist/lib/index.js +784 -233
  4. package/dist/tldraw/assets/index-BK7ffB3e.css +1 -0
  5. package/dist/tldraw/assets/index-CCEXN6Jj.js +522 -0
  6. package/dist/tldraw/fonts/IBMPlexMono-Bold.woff2 +0 -0
  7. package/dist/tldraw/fonts/IBMPlexMono-BoldItalic.woff2 +0 -0
  8. package/dist/tldraw/fonts/IBMPlexMono-Medium.woff2 +0 -0
  9. package/dist/tldraw/fonts/IBMPlexMono-MediumItalic.woff2 +0 -0
  10. package/dist/tldraw/fonts/IBMPlexSans-Bold.woff2 +0 -0
  11. package/dist/tldraw/fonts/IBMPlexSans-BoldItalic.woff2 +0 -0
  12. package/dist/tldraw/fonts/IBMPlexSans-Medium.woff2 +0 -0
  13. package/dist/tldraw/fonts/IBMPlexSans-MediumItalic.woff2 +0 -0
  14. package/dist/tldraw/fonts/IBMPlexSerif-Bold.woff2 +0 -0
  15. package/dist/tldraw/fonts/IBMPlexSerif-BoldItalic.woff2 +0 -0
  16. package/dist/tldraw/fonts/IBMPlexSerif-Medium.woff2 +0 -0
  17. package/dist/tldraw/fonts/IBMPlexSerif-MediumItalic.woff2 +0 -0
  18. package/dist/tldraw/fonts/Shantell_Sans-Informal_Bold.woff2 +0 -0
  19. package/dist/tldraw/fonts/Shantell_Sans-Informal_Bold_Italic.woff2 +0 -0
  20. package/dist/tldraw/fonts/Shantell_Sans-Informal_Regular.woff2 +0 -0
  21. package/dist/tldraw/fonts/Shantell_Sans-Informal_Regular_Italic.woff2 +0 -0
  22. package/dist/tldraw/icons/icon/0_merged.svg +1 -1
  23. package/dist/tldraw/icons/icon/bold.svg +1 -0
  24. package/dist/tldraw/icons/icon/bulletList.svg +1 -0
  25. package/dist/tldraw/icons/icon/code.svg +1 -0
  26. package/dist/tldraw/icons/icon/heading.svg +1 -0
  27. package/dist/tldraw/icons/icon/highlight.svg +1 -0
  28. package/dist/tldraw/icons/icon/icon-names.json +9 -0
  29. package/dist/tldraw/icons/icon/italic.svg +1 -0
  30. package/dist/tldraw/icons/icon/list.svg +1 -0
  31. package/dist/tldraw/icons/icon/strike.svg +1 -0
  32. package/dist/tldraw/icons/icon/underline.svg +1 -0
  33. package/dist/tldraw/index.html +2 -2
  34. package/dist/tldraw/translations/main.json +10 -0
  35. package/package.json +13 -12
  36. package/dist/tldraw/assets/index-BkIYKf7d.css +0 -1
  37. package/dist/tldraw/assets/index-DipIZPz9.js +0 -419
  38. package/dist/tldraw/fonts/Shantell_Sans-Tldrawish.woff2 +0 -0
@@ -1,419 +0,0 @@
1
- var lge=Object.defineProperty;var uge=(r,e,t)=>e in r?lge(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var q=(r,e,t)=>uge(r,typeof e!="symbol"?e+"":e,t);function dge(r,e){for(var t=0;t<e.length;t++){const n=e[t];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in r)){const o=Object.getOwnPropertyDescriptor(n,i);o&&Object.defineProperty(r,i,o.get?o:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function t(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=t(i);fetch(i.href,o)}})();var ho=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function cc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Bx={exports:{}},jf={},Ux={exports:{}},er={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Gk;function fge(){if(Gk)return er;Gk=1;var r=Symbol.for("react.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),s=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),l=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.iterator;function h(K){return K===null||typeof K!="object"?null:(K=f&&K[f]||K["@@iterator"],typeof K=="function"?K:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,y={};function x(K,Z,ee){this.props=K,this.context=Z,this.refs=y,this.updater=ee||g}x.prototype.isReactComponent={},x.prototype.setState=function(K,Z){if(typeof K!="object"&&typeof K!="function"&&K!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,K,Z,"setState")},x.prototype.forceUpdate=function(K){this.updater.enqueueForceUpdate(this,K,"forceUpdate")};function _(){}_.prototype=x.prototype;function w(K,Z,ee){this.props=K,this.context=Z,this.refs=y,this.updater=ee||g}var I=w.prototype=new _;I.constructor=w,m(I,x.prototype),I.isPureReactComponent=!0;var b=Array.isArray,P=Object.prototype.hasOwnProperty,C={current:null},k={key:!0,ref:!0,__self:!0,__source:!0};function O(K,Z,ee){var re,te={},le=null,ge=null;if(Z!=null)for(re in Z.ref!==void 0&&(ge=Z.ref),Z.key!==void 0&&(le=""+Z.key),Z)P.call(Z,re)&&!k.hasOwnProperty(re)&&(te[re]=Z[re]);var se=arguments.length-2;if(se===1)te.children=ee;else if(1<se){for(var ce=Array(se),_e=0;_e<se;_e++)ce[_e]=arguments[_e+2];te.children=ce}if(K&&K.defaultProps)for(re in se=K.defaultProps,se)te[re]===void 0&&(te[re]=se[re]);return{$$typeof:r,type:K,key:le,ref:ge,props:te,_owner:C.current}}function L(K,Z){return{$$typeof:r,type:K.type,key:Z,ref:K.ref,props:K.props,_owner:K._owner}}function j(K){return typeof K=="object"&&K!==null&&K.$$typeof===r}function F(K){var Z={"=":"=0",":":"=2"};return"$"+K.replace(/[=:]/g,function(ee){return Z[ee]})}var $=/\/+/g;function D(K,Z){return typeof K=="object"&&K!==null&&K.key!=null?F(""+K.key):Z.toString(36)}function N(K,Z,ee,re,te){var le=typeof K;(le==="undefined"||le==="boolean")&&(K=null);var ge=!1;if(K===null)ge=!0;else switch(le){case"string":case"number":ge=!0;break;case"object":switch(K.$$typeof){case r:case e:ge=!0}}if(ge)return ge=K,te=te(ge),K=re===""?"."+D(ge,0):re,b(te)?(ee="",K!=null&&(ee=K.replace($,"$&/")+"/"),N(te,Z,ee,"",function(_e){return _e})):te!=null&&(j(te)&&(te=L(te,ee+(!te.key||ge&&ge.key===te.key?"":(""+te.key).replace($,"$&/")+"/")+K)),Z.push(te)),1;if(ge=0,re=re===""?".":re+":",b(K))for(var se=0;se<K.length;se++){le=K[se];var ce=re+D(le,se);ge+=N(le,Z,ee,ce,te)}else if(ce=h(K),typeof ce=="function")for(K=ce.call(K),se=0;!(le=K.next()).done;)le=le.value,ce=re+D(le,se++),ge+=N(le,Z,ee,ce,te);else if(le==="object")throw Z=String(K),Error("Objects are not valid as a React child (found: "+(Z==="[object Object]"?"object with keys {"+Object.keys(K).join(", ")+"}":Z)+"). If you meant to render a collection of children, use an array instead.");return ge}function B(K,Z,ee){if(K==null)return K;var re=[],te=0;return N(K,re,"","",function(le){return Z.call(ee,le,te++)}),re}function W(K){if(K._status===-1){var Z=K._result;Z=Z(),Z.then(function(ee){(K._status===0||K._status===-1)&&(K._status=1,K._result=ee)},function(ee){(K._status===0||K._status===-1)&&(K._status=2,K._result=ee)}),K._status===-1&&(K._status=0,K._result=Z)}if(K._status===1)return K._result.default;throw K._result}var G={current:null},z={transition:null},V={ReactCurrentDispatcher:G,ReactCurrentBatchConfig:z,ReactCurrentOwner:C};function J(){throw Error("act(...) is not supported in production builds of React.")}return er.Children={map:B,forEach:function(K,Z,ee){B(K,function(){Z.apply(this,arguments)},ee)},count:function(K){var Z=0;return B(K,function(){Z++}),Z},toArray:function(K){return B(K,function(Z){return Z})||[]},only:function(K){if(!j(K))throw Error("React.Children.only expected to receive a single React element child.");return K}},er.Component=x,er.Fragment=t,er.Profiler=i,er.PureComponent=w,er.StrictMode=n,er.Suspense=c,er.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,er.act=J,er.cloneElement=function(K,Z,ee){if(K==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+K+".");var re=m({},K.props),te=K.key,le=K.ref,ge=K._owner;if(Z!=null){if(Z.ref!==void 0&&(le=Z.ref,ge=C.current),Z.key!==void 0&&(te=""+Z.key),K.type&&K.type.defaultProps)var se=K.type.defaultProps;for(ce in Z)P.call(Z,ce)&&!k.hasOwnProperty(ce)&&(re[ce]=Z[ce]===void 0&&se!==void 0?se[ce]:Z[ce])}var ce=arguments.length-2;if(ce===1)re.children=ee;else if(1<ce){se=Array(ce);for(var _e=0;_e<ce;_e++)se[_e]=arguments[_e+2];re.children=se}return{$$typeof:r,type:K.type,key:te,ref:le,props:re,_owner:ge}},er.createContext=function(K){return K={$$typeof:s,_currentValue:K,_currentValue2:K,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},K.Provider={$$typeof:o,_context:K},K.Consumer=K},er.createElement=O,er.createFactory=function(K){var Z=O.bind(null,K);return Z.type=K,Z},er.createRef=function(){return{current:null}},er.forwardRef=function(K){return{$$typeof:a,render:K}},er.isValidElement=j,er.lazy=function(K){return{$$typeof:d,_payload:{_status:-1,_result:K},_init:W}},er.memo=function(K,Z){return{$$typeof:l,type:K,compare:Z===void 0?null:Z}},er.startTransition=function(K){var Z=z.transition;z.transition={};try{K()}finally{z.transition=Z}},er.unstable_act=J,er.useCallback=function(K,Z){return G.current.useCallback(K,Z)},er.useContext=function(K){return G.current.useContext(K)},er.useDebugValue=function(){},er.useDeferredValue=function(K){return G.current.useDeferredValue(K)},er.useEffect=function(K,Z){return G.current.useEffect(K,Z)},er.useId=function(){return G.current.useId()},er.useImperativeHandle=function(K,Z,ee){return G.current.useImperativeHandle(K,Z,ee)},er.useInsertionEffect=function(K,Z){return G.current.useInsertionEffect(K,Z)},er.useLayoutEffect=function(K,Z){return G.current.useLayoutEffect(K,Z)},er.useMemo=function(K,Z){return G.current.useMemo(K,Z)},er.useReducer=function(K,Z,ee){return G.current.useReducer(K,Z,ee)},er.useRef=function(K){return G.current.useRef(K)},er.useState=function(K){return G.current.useState(K)},er.useSyncExternalStore=function(K,Z,ee){return G.current.useSyncExternalStore(K,Z,ee)},er.useTransition=function(){return G.current.useTransition()},er.version="18.3.1",er}var Vk;function TC(){return Vk||(Vk=1,Ux.exports=fge()),Ux.exports}/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var Yk;function hge(){if(Yk)return jf;Yk=1;var r=TC(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(a,c,l){var d,f={},h=null,g=null;l!==void 0&&(h=""+l),c.key!==void 0&&(h=""+c.key),c.ref!==void 0&&(g=c.ref);for(d in c)n.call(c,d)&&!o.hasOwnProperty(d)&&(f[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)f[d]===void 0&&(f[d]=c[d]);return{$$typeof:e,type:a,key:h,ref:g,props:f,_owner:i.current}}return jf.Fragment=t,jf.jsx=s,jf.jsxs=s,jf}var Xk;function pge(){return Xk||(Xk=1,Bx.exports=hge()),Bx.exports}var v=pge(),A=TC();const lr=cc(A),gge=dge({__proto__:null,default:lr},[A]);var Sg={},zx={exports:{}},no={},Hx={exports:{}},Wx={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */var Zk;function vge(){return Zk||(Zk=1,function(r){function e(z,V){var J=z.length;z.push(V);e:for(;0<J;){var K=J-1>>>1,Z=z[K];if(0<i(Z,V))z[K]=V,z[J]=Z,J=K;else break e}}function t(z){return z.length===0?null:z[0]}function n(z){if(z.length===0)return null;var V=z[0],J=z.pop();if(J!==V){z[0]=J;e:for(var K=0,Z=z.length,ee=Z>>>1;K<ee;){var re=2*(K+1)-1,te=z[re],le=re+1,ge=z[le];if(0>i(te,J))le<Z&&0>i(ge,te)?(z[K]=ge,z[le]=J,K=le):(z[K]=te,z[re]=J,K=re);else if(le<Z&&0>i(ge,J))z[K]=ge,z[le]=J,K=le;else break e}}return V}function i(z,V){var J=z.sortIndex-V.sortIndex;return J!==0?J:z.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;r.unstable_now=function(){return o.now()}}else{var s=Date,a=s.now();r.unstable_now=function(){return s.now()-a}}var c=[],l=[],d=1,f=null,h=3,g=!1,m=!1,y=!1,x=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function I(z){for(var V=t(l);V!==null;){if(V.callback===null)n(l);else if(V.startTime<=z)n(l),V.sortIndex=V.expirationTime,e(c,V);else break;V=t(l)}}function b(z){if(y=!1,I(z),!m)if(t(c)!==null)m=!0,W(P);else{var V=t(l);V!==null&&G(b,V.startTime-z)}}function P(z,V){m=!1,y&&(y=!1,_(O),O=-1),g=!0;var J=h;try{for(I(V),f=t(c);f!==null&&(!(f.expirationTime>V)||z&&!F());){var K=f.callback;if(typeof K=="function"){f.callback=null,h=f.priorityLevel;var Z=K(f.expirationTime<=V);V=r.unstable_now(),typeof Z=="function"?f.callback=Z:f===t(c)&&n(c),I(V)}else n(c);f=t(c)}if(f!==null)var ee=!0;else{var re=t(l);re!==null&&G(b,re.startTime-V),ee=!1}return ee}finally{f=null,h=J,g=!1}}var C=!1,k=null,O=-1,L=5,j=-1;function F(){return!(r.unstable_now()-j<L)}function $(){if(k!==null){var z=r.unstable_now();j=z;var V=!0;try{V=k(!0,z)}finally{V?D():(C=!1,k=null)}}else C=!1}var D;if(typeof w=="function")D=function(){w($)};else if(typeof MessageChannel<"u"){var N=new MessageChannel,B=N.port2;N.port1.onmessage=$,D=function(){B.postMessage(null)}}else D=function(){x($,0)};function W(z){k=z,C||(C=!0,D())}function G(z,V){O=x(function(){z(r.unstable_now())},V)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(z){z.callback=null},r.unstable_continueExecution=function(){m||g||(m=!0,W(P))},r.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<z?Math.floor(1e3/z):5},r.unstable_getCurrentPriorityLevel=function(){return h},r.unstable_getFirstCallbackNode=function(){return t(c)},r.unstable_next=function(z){switch(h){case 1:case 2:case 3:var V=3;break;default:V=h}var J=h;h=V;try{return z()}finally{h=J}},r.unstable_pauseExecution=function(){},r.unstable_requestPaint=function(){},r.unstable_runWithPriority=function(z,V){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var J=h;h=z;try{return V()}finally{h=J}},r.unstable_scheduleCallback=function(z,V,J){var K=r.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?K+J:K):J=K,z){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=J+Z,z={id:d++,callback:V,priorityLevel:z,startTime:J,expirationTime:Z,sortIndex:-1},J>K?(z.sortIndex=J,e(l,z),t(c)===null&&z===t(l)&&(y?(_(O),O=-1):y=!0,G(b,J-K))):(z.sortIndex=Z,e(c,z),m||g||(m=!0,W(P))),z},r.unstable_shouldYield=F,r.unstable_wrapCallback=function(z){var V=h;return function(){var J=h;h=V;try{return z.apply(this,arguments)}finally{h=J}}}}(Wx)),Wx}var Qk;function mge(){return Qk||(Qk=1,Hx.exports=vge()),Hx.exports}/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var Jk;function yge(){if(Jk)return no;Jk=1;var r=TC(),e=mge();function t(u){for(var p="https://reactjs.org/docs/error-decoder.html?invariant="+u,S=1;S<arguments.length;S++)p+="&args[]="+encodeURIComponent(arguments[S]);return"Minified React error #"+u+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var n=new Set,i={};function o(u,p){s(u,p),s(u+"Capture",p)}function s(u,p){for(i[u]=p,u=0;u<p.length;u++)n.add(p[u])}var a=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),c=Object.prototype.hasOwnProperty,l=/^[: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]*$/,d={},f={};function h(u){return c.call(f,u)?!0:c.call(d,u)?!1:l.test(u)?f[u]=!0:(d[u]=!0,!1)}function g(u,p,S,E){if(S!==null&&S.type===0)return!1;switch(typeof p){case"function":case"symbol":return!0;case"boolean":return E?!1:S!==null?!S.acceptsBooleans:(u=u.toLowerCase().slice(0,5),u!=="data-"&&u!=="aria-");default:return!1}}function m(u,p,S,E){if(p===null||typeof p>"u"||g(u,p,S,E))return!0;if(E)return!1;if(S!==null)switch(S.type){case 3:return!p;case 4:return p===!1;case 5:return isNaN(p);case 6:return isNaN(p)||1>p}return!1}function y(u,p,S,E,R,M,U){this.acceptsBooleans=p===2||p===3||p===4,this.attributeName=E,this.attributeNamespace=R,this.mustUseProperty=S,this.propertyName=u,this.type=p,this.sanitizeURL=M,this.removeEmptyString=U}var x={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(u){x[u]=new y(u,0,!1,u,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(u){var p=u[0];x[p]=new y(p,1,!1,u[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(u){x[u]=new y(u,2,!1,u.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(u){x[u]=new y(u,2,!1,u,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(u){x[u]=new y(u,3,!1,u.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(u){x[u]=new y(u,3,!0,u,null,!1,!1)}),["capture","download"].forEach(function(u){x[u]=new y(u,4,!1,u,null,!1,!1)}),["cols","rows","size","span"].forEach(function(u){x[u]=new y(u,6,!1,u,null,!1,!1)}),["rowSpan","start"].forEach(function(u){x[u]=new y(u,5,!1,u.toLowerCase(),null,!1,!1)});var _=/[\-:]([a-z])/g;function w(u){return u[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(u){var p=u.replace(_,w);x[p]=new y(p,1,!1,u,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(u){var p=u.replace(_,w);x[p]=new y(p,1,!1,u,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(u){var p=u.replace(_,w);x[p]=new y(p,1,!1,u,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(u){x[u]=new y(u,1,!1,u.toLowerCase(),null,!1,!1)}),x.xlinkHref=new y("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(u){x[u]=new y(u,1,!1,u.toLowerCase(),null,!0,!0)});function I(u,p,S,E){var R=x.hasOwnProperty(p)?x[p]:null;(R!==null?R.type!==0:E||!(2<p.length)||p[0]!=="o"&&p[0]!=="O"||p[1]!=="n"&&p[1]!=="N")&&(m(p,S,R,E)&&(S=null),E||R===null?h(p)&&(S===null?u.removeAttribute(p):u.setAttribute(p,""+S)):R.mustUseProperty?u[R.propertyName]=S===null?R.type===3?!1:"":S:(p=R.attributeName,E=R.attributeNamespace,S===null?u.removeAttribute(p):(R=R.type,S=R===3||R===4&&S===!0?"":""+S,E?u.setAttributeNS(E,p,S):u.setAttribute(p,S))))}var b=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,P=Symbol.for("react.element"),C=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),j=Symbol.for("react.provider"),F=Symbol.for("react.context"),$=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),G=Symbol.for("react.offscreen"),z=Symbol.iterator;function V(u){return u===null||typeof u!="object"?null:(u=z&&u[z]||u["@@iterator"],typeof u=="function"?u:null)}var J=Object.assign,K;function Z(u){if(K===void 0)try{throw Error()}catch(S){var p=S.stack.trim().match(/\n( *(at )?)/);K=p&&p[1]||""}return`
34
- `+K+u}var ee=!1;function re(u,p){if(!u||ee)return"";ee=!0;var S=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(p)if(p=function(){throw Error()},Object.defineProperty(p.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(p,[])}catch(Se){var E=Se}Reflect.construct(u,[],p)}else{try{p.call()}catch(Se){E=Se}u.call(p.prototype)}else{try{throw Error()}catch(Se){E=Se}u()}}catch(Se){if(Se&&E&&typeof Se.stack=="string"){for(var R=Se.stack.split(`
35
- `),M=E.stack.split(`
36
- `),U=R.length-1,Q=M.length-1;1<=U&&0<=Q&&R[U]!==M[Q];)Q--;for(;1<=U&&0<=Q;U--,Q--)if(R[U]!==M[Q]){if(U!==1||Q!==1)do if(U--,Q--,0>Q||R[U]!==M[Q]){var ne=`
37
- `+R[U].replace(" at new "," at ");return u.displayName&&ne.includes("<anonymous>")&&(ne=ne.replace("<anonymous>",u.displayName)),ne}while(1<=U&&0<=Q);break}}}finally{ee=!1,Error.prepareStackTrace=S}return(u=u?u.displayName||u.name:"")?Z(u):""}function te(u){switch(u.tag){case 5:return Z(u.type);case 16:return Z("Lazy");case 13:return Z("Suspense");case 19:return Z("SuspenseList");case 0:case 2:case 15:return u=re(u.type,!1),u;case 11:return u=re(u.type.render,!1),u;case 1:return u=re(u.type,!0),u;default:return""}}function le(u){if(u==null)return null;if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case k:return"Fragment";case C:return"Portal";case L:return"Profiler";case O:return"StrictMode";case D:return"Suspense";case N:return"SuspenseList"}if(typeof u=="object")switch(u.$$typeof){case F:return(u.displayName||"Context")+".Consumer";case j:return(u._context.displayName||"Context")+".Provider";case $:var p=u.render;return u=u.displayName,u||(u=p.displayName||p.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case B:return p=u.displayName||null,p!==null?p:le(u.type)||"Memo";case W:p=u._payload,u=u._init;try{return le(u(p))}catch{}}return null}function ge(u){var p=u.type;switch(u.tag){case 24:return"Cache";case 9:return(p.displayName||"Context")+".Consumer";case 10:return(p._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return u=p.render,u=u.displayName||u.name||"",p.displayName||(u!==""?"ForwardRef("+u+")":"ForwardRef");case 7:return"Fragment";case 5:return p;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return le(p);case 8:return p===O?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof p=="function")return p.displayName||p.name||null;if(typeof p=="string")return p}return null}function se(u){switch(typeof u){case"boolean":case"number":case"string":case"undefined":return u;case"object":return u;default:return""}}function ce(u){var p=u.type;return(u=u.nodeName)&&u.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function _e(u){var p=ce(u)?"checked":"value",S=Object.getOwnPropertyDescriptor(u.constructor.prototype,p),E=""+u[p];if(!u.hasOwnProperty(p)&&typeof S<"u"&&typeof S.get=="function"&&typeof S.set=="function"){var R=S.get,M=S.set;return Object.defineProperty(u,p,{configurable:!0,get:function(){return R.call(this)},set:function(U){E=""+U,M.call(this,U)}}),Object.defineProperty(u,p,{enumerable:S.enumerable}),{getValue:function(){return E},setValue:function(U){E=""+U},stopTracking:function(){u._valueTracker=null,delete u[p]}}}}function Le(u){u._valueTracker||(u._valueTracker=_e(u))}function Ge(u){if(!u)return!1;var p=u._valueTracker;if(!p)return!0;var S=p.getValue(),E="";return u&&(E=ce(u)?u.checked?"true":"false":u.value),u=E,u!==S?(p.setValue(u),!0):!1}function qe(u){if(u=u||(typeof document<"u"?document:void 0),typeof u>"u")return null;try{return u.activeElement||u.body}catch{return u.body}}function mt(u,p){var S=p.checked;return J({},p,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:S??u._wrapperState.initialChecked})}function St(u,p){var S=p.defaultValue==null?"":p.defaultValue,E=p.checked!=null?p.checked:p.defaultChecked;S=se(p.value!=null?p.value:S),u._wrapperState={initialChecked:E,initialValue:S,controlled:p.type==="checkbox"||p.type==="radio"?p.checked!=null:p.value!=null}}function et(u,p){p=p.checked,p!=null&&I(u,"checked",p,!1)}function ct(u,p){et(u,p);var S=se(p.value),E=p.type;if(S!=null)E==="number"?(S===0&&u.value===""||u.value!=S)&&(u.value=""+S):u.value!==""+S&&(u.value=""+S);else if(E==="submit"||E==="reset"){u.removeAttribute("value");return}p.hasOwnProperty("value")?_t(u,p.type,S):p.hasOwnProperty("defaultValue")&&_t(u,p.type,se(p.defaultValue)),p.checked==null&&p.defaultChecked!=null&&(u.defaultChecked=!!p.defaultChecked)}function At(u,p,S){if(p.hasOwnProperty("value")||p.hasOwnProperty("defaultValue")){var E=p.type;if(!(E!=="submit"&&E!=="reset"||p.value!==void 0&&p.value!==null))return;p=""+u._wrapperState.initialValue,S||p===u.value||(u.value=p),u.defaultValue=p}S=u.name,S!==""&&(u.name=""),u.defaultChecked=!!u._wrapperState.initialChecked,S!==""&&(u.name=S)}function _t(u,p,S){(p!=="number"||qe(u.ownerDocument)!==u)&&(S==null?u.defaultValue=""+u._wrapperState.initialValue:u.defaultValue!==""+S&&(u.defaultValue=""+S))}var ut=Array.isArray;function Ae(u,p,S,E){if(u=u.options,p){p={};for(var R=0;R<S.length;R++)p["$"+S[R]]=!0;for(S=0;S<u.length;S++)R=p.hasOwnProperty("$"+u[S].value),u[S].selected!==R&&(u[S].selected=R),R&&E&&(u[S].defaultSelected=!0)}else{for(S=""+se(S),p=null,R=0;R<u.length;R++){if(u[R].value===S){u[R].selected=!0,E&&(u[R].defaultSelected=!0);return}p!==null||u[R].disabled||(p=u[R])}p!==null&&(p.selected=!0)}}function ze(u,p){if(p.dangerouslySetInnerHTML!=null)throw Error(t(91));return J({},p,{value:void 0,defaultValue:void 0,children:""+u._wrapperState.initialValue})}function be(u,p){var S=p.value;if(S==null){if(S=p.children,p=p.defaultValue,S!=null){if(p!=null)throw Error(t(92));if(ut(S)){if(1<S.length)throw Error(t(93));S=S[0]}p=S}p==null&&(p=""),S=p}u._wrapperState={initialValue:se(S)}}function it(u,p){var S=se(p.value),E=se(p.defaultValue);S!=null&&(S=""+S,S!==u.value&&(u.value=S),p.defaultValue==null&&u.defaultValue!==S&&(u.defaultValue=S)),E!=null&&(u.defaultValue=""+E)}function st(u){var p=u.textContent;p===u._wrapperState.initialValue&&p!==""&&p!==null&&(u.value=p)}function Je(u){switch(u){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Ye(u,p){return u==null||u==="http://www.w3.org/1999/xhtml"?Je(p):u==="http://www.w3.org/2000/svg"&&p==="foreignObject"?"http://www.w3.org/1999/xhtml":u}var cr,Sr=function(u){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(p,S,E,R){MSApp.execUnsafeLocalFunction(function(){return u(p,S,E,R)})}:u}(function(u,p){if(u.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in u)u.innerHTML=p;else{for(cr=cr||document.createElement("div"),cr.innerHTML="<svg>"+p.valueOf().toString()+"</svg>",p=cr.firstChild;u.firstChild;)u.removeChild(u.firstChild);for(;p.firstChild;)u.appendChild(p.firstChild)}});function Y(u,p){if(p){var S=u.firstChild;if(S&&S===u.lastChild&&S.nodeType===3){S.nodeValue=p;return}}u.textContent=p}var oe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},me=["Webkit","ms","Moz","O"];Object.keys(oe).forEach(function(u){me.forEach(function(p){p=p+u.charAt(0).toUpperCase()+u.substring(1),oe[p]=oe[u]})});function we(u,p,S){return p==null||typeof p=="boolean"||p===""?"":S||typeof p!="number"||p===0||oe.hasOwnProperty(u)&&oe[u]?(""+p).trim():p+"px"}function Oe(u,p){u=u.style;for(var S in p)if(p.hasOwnProperty(S)){var E=S.indexOf("--")===0,R=we(S,p[S],E);S==="float"&&(S="cssFloat"),E?u.setProperty(S,R):u[S]=R}}var Ee=J({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function dt(u,p){if(p){if(Ee[u]&&(p.children!=null||p.dangerouslySetInnerHTML!=null))throw Error(t(137,u));if(p.dangerouslySetInnerHTML!=null){if(p.children!=null)throw Error(t(60));if(typeof p.dangerouslySetInnerHTML!="object"||!("__html"in p.dangerouslySetInnerHTML))throw Error(t(61))}if(p.style!=null&&typeof p.style!="object")throw Error(t(62))}}function $t(u,p){if(u.indexOf("-")===-1)return typeof p.is=="string";switch(u){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 Pe=null;function $e(u){return u=u.target||u.srcElement||window,u.correspondingUseElement&&(u=u.correspondingUseElement),u.nodeType===3?u.parentNode:u}var Be=null,We=null,yt=null;function Ht(u){if(u=Sf(u)){if(typeof Be!="function")throw Error(t(280));var p=u.stateNode;p&&(p=jp(p),Be(u.stateNode,u.type,p))}}function ur(u){We?yt?yt.push(u):yt=[u]:We=u}function xr(){if(We){var u=We,p=yt;if(yt=We=null,Ht(u),p)for(u=0;u<p.length;u++)Ht(p[u])}}function Rr(u,p){return u(p)}function en(){}var Pn=!1;function yc(u,p,S){if(Pn)return u(p,S);Pn=!0;try{return Rr(u,p,S)}finally{Pn=!1,(We!==null||yt!==null)&&(en(),xr())}}function Ws(u,p){var S=u.stateNode;if(S===null)return null;var E=jp(S);if(E===null)return null;S=E[p];e:switch(p){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(E=!E.disabled)||(u=u.type,E=!(u==="button"||u==="input"||u==="select"||u==="textarea")),u=!E;break e;default:u=!1}if(u)return null;if(S&&typeof S!="function")throw Error(t(231,p,typeof S));return S}var Oa=!1;if(a)try{var Yi={};Object.defineProperty(Yi,"passive",{get:function(){Oa=!0}}),window.addEventListener("test",Yi,Yi),window.removeEventListener("test",Yi,Yi)}catch{Oa=!1}function Xi(u,p,S,E,R,M,U,Q,ne){var Se=Array.prototype.slice.call(arguments,3);try{p.apply(S,Se)}catch(De){this.onError(De)}}var ps=!1,ci=null,ln=!1,Ma=null,Ks={onError:function(u){ps=!0,ci=u}};function Rn(u,p,S,E,R,M,U,Q,ne){ps=!1,ci=null,Xi.apply(Ks,arguments)}function li(u,p,S,E,R,M,U,Q,ne){if(Rn.apply(this,arguments),ps){if(ps){var Se=ci;ps=!1,ci=null}else throw Error(t(198));ln||(ln=!0,Ma=Se)}}function Go(u){var p=u,S=u;if(u.alternate)for(;p.return;)p=p.return;else{u=p;do p=u,(p.flags&4098)!==0&&(S=p.return),u=p.return;while(u)}return p.tag===3?S:null}function Mi(u){if(u.tag===13){var p=u.memoizedState;if(p===null&&(u=u.alternate,u!==null&&(p=u.memoizedState)),p!==null)return p.dehydrated}return null}function ve(u){if(Go(u)!==u)throw Error(t(188))}function Ne(u){var p=u.alternate;if(!p){if(p=Go(u),p===null)throw Error(t(188));return p!==u?null:u}for(var S=u,E=p;;){var R=S.return;if(R===null)break;var M=R.alternate;if(M===null){if(E=R.return,E!==null){S=E;continue}break}if(R.child===M.child){for(M=R.child;M;){if(M===S)return ve(R),u;if(M===E)return ve(R),p;M=M.sibling}throw Error(t(188))}if(S.return!==E.return)S=R,E=M;else{for(var U=!1,Q=R.child;Q;){if(Q===S){U=!0,S=R,E=M;break}if(Q===E){U=!0,E=R,S=M;break}Q=Q.sibling}if(!U){for(Q=M.child;Q;){if(Q===S){U=!0,S=M,E=R;break}if(Q===E){U=!0,E=M,S=R;break}Q=Q.sibling}if(!U)throw Error(t(189))}}if(S.alternate!==E)throw Error(t(190))}if(S.tag!==3)throw Error(t(188));return S.stateNode.current===S?u:p}function xe(u){return u=Ne(u),u!==null?ue(u):null}function ue(u){if(u.tag===5||u.tag===6)return u;for(u=u.child;u!==null;){var p=ue(u);if(p!==null)return p;u=u.sibling}return null}var ke=e.unstable_scheduleCallback,Pt=e.unstable_cancelCallback,ft=e.unstable_shouldYield,Br=e.unstable_requestPaint,Wt=e.unstable_now,hn=e.unstable_getCurrentPriorityLevel,Nn=e.unstable_ImmediatePriority,Me=e.unstable_UserBlockingPriority,Ur=e.unstable_NormalPriority,_o=e.unstable_LowPriority,ji=e.unstable_IdlePriority,ja=null,Di=null;function _l(u){if(Di&&typeof Di.onCommitFiberRoot=="function")try{Di.onCommitFiberRoot(ja,u,void 0,(u.current.flags&128)===128)}catch{}}var wo=Math.clz32?Math.clz32:Eu,fS=Math.log,hS=Math.LN2;function Eu(u){return u>>>=0,u===0?32:31-(fS(u)/hS|0)|0}var Iu=64,Gs=4194304;function Sc(u){switch(u&-u){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: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 u&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return u&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return u}}function wl(u,p){var S=u.pendingLanes;if(S===0)return 0;var E=0,R=u.suspendedLanes,M=u.pingedLanes,U=S&268435455;if(U!==0){var Q=U&~R;Q!==0?E=Sc(Q):(M&=U,M!==0&&(E=Sc(M)))}else U=S&~R,U!==0?E=Sc(U):M!==0&&(E=Sc(M));if(E===0)return 0;if(p!==0&&p!==E&&(p&R)===0&&(R=E&-E,M=p&-p,R>=M||R===16&&(M&4194240)!==0))return p;if((E&4)!==0&&(E|=S&16),p=u.entangledLanes,p!==0)for(u=u.entanglements,p&=E;0<p;)S=31-wo(p),R=1<<S,E|=u[S],p&=~R;return E}function pS(u,p){switch(u){case 1:case 2:case 4:return p+250;case 8:case 16:case 32:case 64: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 p+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function gS(u,p){for(var S=u.suspendedLanes,E=u.pingedLanes,R=u.expirationTimes,M=u.pendingLanes;0<M;){var U=31-wo(M),Q=1<<U,ne=R[U];ne===-1?((Q&S)===0||(Q&E)!==0)&&(R[U]=pS(Q,p)):ne<=p&&(u.expiredLanes|=Q),M&=~Q}}function rf(u){return u=u.pendingLanes&-1073741825,u!==0?u:u&1073741824?1073741824:0}function xp(){var u=Iu;return Iu<<=1,(Iu&4194240)===0&&(Iu=64),u}function Pu(u){for(var p=[],S=0;31>S;S++)p.push(u);return p}function bl(u,p,S){u.pendingLanes|=p,p!==536870912&&(u.suspendedLanes=0,u.pingedLanes=0),u=u.eventTimes,p=31-wo(p),u[p]=S}function vS(u,p){var S=u.pendingLanes&~p;u.pendingLanes=p,u.suspendedLanes=0,u.pingedLanes=0,u.expiredLanes&=p,u.mutableReadLanes&=p,u.entangledLanes&=p,p=u.entanglements;var E=u.eventTimes;for(u=u.expirationTimes;0<S;){var R=31-wo(S),M=1<<R;p[R]=0,E[R]=-1,u[R]=-1,S&=~M}}function Cu(u,p){var S=u.entangledLanes|=p;for(u=u.entanglements;S;){var E=31-wo(S),R=1<<E;R&p|u[E]&p&&(u[E]|=p),S&=~R}}var fr=0;function Da(u){return u&=-u,1<u?4<u?(u&268435455)!==0?16:536870912:4:1}var _p,nf,gs,wp,bp,of=!1,Tu=[],Vs=null,ui=null,vs=null,El=new Map,Ys=new Map,Xs=[],sf="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 submit".split(" ");function Ep(u,p){switch(u){case"focusin":case"focusout":Vs=null;break;case"dragenter":case"dragleave":ui=null;break;case"mouseover":case"mouseout":vs=null;break;case"pointerover":case"pointerout":El.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ys.delete(p.pointerId)}}function xc(u,p,S,E,R,M){return u===null||u.nativeEvent!==M?(u={blockedOn:p,domEventName:S,eventSystemFlags:E,nativeEvent:M,targetContainers:[R]},p!==null&&(p=Sf(p),p!==null&&nf(p)),u):(u.eventSystemFlags|=E,p=u.targetContainers,R!==null&&p.indexOf(R)===-1&&p.push(R),u)}function Ip(u,p,S,E,R){switch(p){case"focusin":return Vs=xc(Vs,u,p,S,E,R),!0;case"dragenter":return ui=xc(ui,u,p,S,E,R),!0;case"mouseover":return vs=xc(vs,u,p,S,E,R),!0;case"pointerover":var M=R.pointerId;return El.set(M,xc(El.get(M)||null,u,p,S,E,R)),!0;case"gotpointercapture":return M=R.pointerId,Ys.set(M,xc(Ys.get(M)||null,u,p,S,E,R)),!0}return!1}function af(u){var p=Cl(u.target);if(p!==null){var S=Go(p);if(S!==null){if(p=S.tag,p===13){if(p=Mi(S),p!==null){u.blockedOn=p,bp(u.priority,function(){gs(S)});return}}else if(p===3&&S.stateNode.current.memoizedState.isDehydrated){u.blockedOn=S.tag===3?S.stateNode.containerInfo:null;return}}}u.blockedOn=null}function Zs(u){if(u.blockedOn!==null)return!1;for(var p=u.targetContainers;0<p.length;){var S=jr(u.domEventName,u.eventSystemFlags,p[0],u.nativeEvent);if(S===null){S=u.nativeEvent;var E=new S.constructor(S.type,S);Pe=E,S.target.dispatchEvent(E),Pe=null}else return p=Sf(S),p!==null&&nf(p),u.blockedOn=S,!1;p.shift()}return!0}function cf(u,p,S){Zs(u)&&S.delete(p)}function mS(){of=!1,Vs!==null&&Zs(Vs)&&(Vs=null),ui!==null&&Zs(ui)&&(ui=null),vs!==null&&Zs(vs)&&(vs=null),El.forEach(cf),Ys.forEach(cf)}function Il(u,p){u.blockedOn===p&&(u.blockedOn=null,of||(of=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,mS)))}function Pl(u){function p(R){return Il(R,u)}if(0<Tu.length){Il(Tu[0],u);for(var S=1;S<Tu.length;S++){var E=Tu[S];E.blockedOn===u&&(E.blockedOn=null)}}for(Vs!==null&&Il(Vs,u),ui!==null&&Il(ui,u),vs!==null&&Il(vs,u),El.forEach(p),Ys.forEach(p),S=0;S<Xs.length;S++)E=Xs[S],E.blockedOn===u&&(E.blockedOn=null);for(;0<Xs.length&&(S=Xs[0],S.blockedOn===null);)af(S),S.blockedOn===null&&Xs.shift()}var X=b.ReactCurrentBatchConfig,ae=!0;function Re(u,p,S,E){var R=fr,M=X.transition;X.transition=null;try{fr=1,br(u,p,S,E)}finally{fr=R,X.transition=M}}function lt(u,p,S,E){var R=fr,M=X.transition;X.transition=null;try{fr=4,br(u,p,S,E)}finally{fr=R,X.transition=M}}function br(u,p,S,E){if(ae){var R=jr(u,p,S,E);if(R===null)kS(u,p,E,Bt,S),Ep(u,E);else if(Ip(R,u,p,S,E))E.stopPropagation();else if(Ep(u,E),p&4&&-1<sf.indexOf(u)){for(;R!==null;){var M=Sf(R);if(M!==null&&_p(M),M=jr(u,p,S,E),M===null&&kS(u,p,E,Bt,S),M===R)break;R=M}R!==null&&E.stopPropagation()}else kS(u,p,E,null,S)}}var Bt=null;function jr(u,p,S,E){if(Bt=null,u=$e(E),u=Cl(u),u!==null)if(p=Go(u),p===null)u=null;else if(S=p.tag,S===13){if(u=Mi(p),u!==null)return u;u=null}else if(S===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;u=null}else p!==u&&(u=null);return Bt=u,null}function pn(u){switch(u){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"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 1;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"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(hn()){case Nn:return 1;case Me:return 4;case Ur:case _o:return 16;case ji:return 536870912;default:return 16}default:return 16}}var Dr=null,kr=null,$n=null;function Zi(){if($n)return $n;var u,p=kr,S=p.length,E,R="value"in Dr?Dr.value:Dr.textContent,M=R.length;for(u=0;u<S&&p[u]===R[u];u++);var U=S-u;for(E=1;E<=U&&p[S-E]===R[M-E];E++);return $n=R.slice(u,1<E?1-E:void 0)}function gn(u){var p=u.keyCode;return"charCode"in u?(u=u.charCode,u===0&&p===13&&(u=13)):u=p,u===10&&(u=13),32<=u||u===13?u:0}function Kn(){return!0}function Li(){return!1}function un(u){function p(S,E,R,M,U){this._reactName=S,this._targetInst=R,this.type=E,this.nativeEvent=M,this.target=U,this.currentTarget=null;for(var Q in u)u.hasOwnProperty(Q)&&(S=u[Q],this[Q]=S?S(M):M[Q]);return this.isDefaultPrevented=(M.defaultPrevented!=null?M.defaultPrevented:M.returnValue===!1)?Kn:Li,this.isPropagationStopped=Li,this}return J(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var S=this.nativeEvent;S&&(S.preventDefault?S.preventDefault():typeof S.returnValue!="unknown"&&(S.returnValue=!1),this.isDefaultPrevented=Kn)},stopPropagation:function(){var S=this.nativeEvent;S&&(S.stopPropagation?S.stopPropagation():typeof S.cancelBubble!="unknown"&&(S.cancelBubble=!0),this.isPropagationStopped=Kn)},persist:function(){},isPersistent:Kn}),p}var di={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(u){return u.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ms=un(di),_c=J({},di,{view:0,detail:0}),Au=un(_c),wc,yS,lf,Pp=J({},_c,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:xS,button:0,buttons:0,relatedTarget:function(u){return u.relatedTarget===void 0?u.fromElement===u.srcElement?u.toElement:u.fromElement:u.relatedTarget},movementX:function(u){return"movementX"in u?u.movementX:(u!==lf&&(lf&&u.type==="mousemove"?(wc=u.screenX-lf.screenX,yS=u.screenY-lf.screenY):yS=wc=0,lf=u),wc)},movementY:function(u){return"movementY"in u?u.movementY:yS}}),LR=un(Pp),Fhe=J({},Pp,{dataTransfer:0}),Nhe=un(Fhe),$he=J({},_c,{relatedTarget:0}),SS=un($he),qhe=J({},di,{animationName:0,elapsedTime:0,pseudoElement:0}),Bhe=un(qhe),Uhe=J({},di,{clipboardData:function(u){return"clipboardData"in u?u.clipboardData:window.clipboardData}}),zhe=un(Uhe),Hhe=J({},di,{data:0}),FR=un(Hhe),Whe={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Khe={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"},Ghe={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Vhe(u){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(u):(u=Ghe[u])?!!p[u]:!1}function xS(){return Vhe}var Yhe=J({},_c,{key:function(u){if(u.key){var p=Whe[u.key]||u.key;if(p!=="Unidentified")return p}return u.type==="keypress"?(u=gn(u),u===13?"Enter":String.fromCharCode(u)):u.type==="keydown"||u.type==="keyup"?Khe[u.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:xS,charCode:function(u){return u.type==="keypress"?gn(u):0},keyCode:function(u){return u.type==="keydown"||u.type==="keyup"?u.keyCode:0},which:function(u){return u.type==="keypress"?gn(u):u.type==="keydown"||u.type==="keyup"?u.keyCode:0}}),Xhe=un(Yhe),Zhe=J({},Pp,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),NR=un(Zhe),Qhe=J({},_c,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:xS}),Jhe=un(Qhe),epe=J({},di,{propertyName:0,elapsedTime:0,pseudoElement:0}),tpe=un(epe),rpe=J({},Pp,{deltaX:function(u){return"deltaX"in u?u.deltaX:"wheelDeltaX"in u?-u.wheelDeltaX:0},deltaY:function(u){return"deltaY"in u?u.deltaY:"wheelDeltaY"in u?-u.wheelDeltaY:"wheelDelta"in u?-u.wheelDelta:0},deltaZ:0,deltaMode:0}),npe=un(rpe),ipe=[9,13,27,32],_S=a&&"CompositionEvent"in window,uf=null;a&&"documentMode"in document&&(uf=document.documentMode);var ope=a&&"TextEvent"in window&&!uf,$R=a&&(!_S||uf&&8<uf&&11>=uf),qR=" ",BR=!1;function UR(u,p){switch(u){case"keyup":return ipe.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function zR(u){return u=u.detail,typeof u=="object"&&"data"in u?u.data:null}var Ru=!1;function spe(u,p){switch(u){case"compositionend":return zR(p);case"keypress":return p.which!==32?null:(BR=!0,qR);case"textInput":return u=p.data,u===qR&&BR?null:u;default:return null}}function ape(u,p){if(Ru)return u==="compositionend"||!_S&&UR(u,p)?(u=Zi(),$n=kr=Dr=null,Ru=!1,u):null;switch(u){case"paste":return null;case"keypress":if(!(p.ctrlKey||p.altKey||p.metaKey)||p.ctrlKey&&p.altKey){if(p.char&&1<p.char.length)return p.char;if(p.which)return String.fromCharCode(p.which)}return null;case"compositionend":return $R&&p.locale!=="ko"?null:p.data;default:return null}}var cpe={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 HR(u){var p=u&&u.nodeName&&u.nodeName.toLowerCase();return p==="input"?!!cpe[u.type]:p==="textarea"}function WR(u,p,S,E){ur(E),p=kp(p,"onChange"),0<p.length&&(S=new ms("onChange","change",null,S,E),u.push({event:S,listeners:p}))}var df=null,ff=null;function lpe(u){l2(u,0)}function Cp(u){var p=Du(u);if(Ge(p))return u}function upe(u,p){if(u==="change")return p}var KR=!1;if(a){var wS;if(a){var bS="oninput"in document;if(!bS){var GR=document.createElement("div");GR.setAttribute("oninput","return;"),bS=typeof GR.oninput=="function"}wS=bS}else wS=!1;KR=wS&&(!document.documentMode||9<document.documentMode)}function VR(){df&&(df.detachEvent("onpropertychange",YR),ff=df=null)}function YR(u){if(u.propertyName==="value"&&Cp(ff)){var p=[];WR(p,ff,u,$e(u)),yc(lpe,p)}}function dpe(u,p,S){u==="focusin"?(VR(),df=p,ff=S,df.attachEvent("onpropertychange",YR)):u==="focusout"&&VR()}function fpe(u){if(u==="selectionchange"||u==="keyup"||u==="keydown")return Cp(ff)}function hpe(u,p){if(u==="click")return Cp(p)}function ppe(u,p){if(u==="input"||u==="change")return Cp(p)}function gpe(u,p){return u===p&&(u!==0||1/u===1/p)||u!==u&&p!==p}var ys=typeof Object.is=="function"?Object.is:gpe;function hf(u,p){if(ys(u,p))return!0;if(typeof u!="object"||u===null||typeof p!="object"||p===null)return!1;var S=Object.keys(u),E=Object.keys(p);if(S.length!==E.length)return!1;for(E=0;E<S.length;E++){var R=S[E];if(!c.call(p,R)||!ys(u[R],p[R]))return!1}return!0}function XR(u){for(;u&&u.firstChild;)u=u.firstChild;return u}function ZR(u,p){var S=XR(u);u=0;for(var E;S;){if(S.nodeType===3){if(E=u+S.textContent.length,u<=p&&E>=p)return{node:S,offset:p-u};u=E}e:{for(;S;){if(S.nextSibling){S=S.nextSibling;break e}S=S.parentNode}S=void 0}S=XR(S)}}function QR(u,p){return u&&p?u===p?!0:u&&u.nodeType===3?!1:p&&p.nodeType===3?QR(u,p.parentNode):"contains"in u?u.contains(p):u.compareDocumentPosition?!!(u.compareDocumentPosition(p)&16):!1:!1}function JR(){for(var u=window,p=qe();p instanceof u.HTMLIFrameElement;){try{var S=typeof p.contentWindow.location.href=="string"}catch{S=!1}if(S)u=p.contentWindow;else break;p=qe(u.document)}return p}function ES(u){var p=u&&u.nodeName&&u.nodeName.toLowerCase();return p&&(p==="input"&&(u.type==="text"||u.type==="search"||u.type==="tel"||u.type==="url"||u.type==="password")||p==="textarea"||u.contentEditable==="true")}function vpe(u){var p=JR(),S=u.focusedElem,E=u.selectionRange;if(p!==S&&S&&S.ownerDocument&&QR(S.ownerDocument.documentElement,S)){if(E!==null&&ES(S)){if(p=E.start,u=E.end,u===void 0&&(u=p),"selectionStart"in S)S.selectionStart=p,S.selectionEnd=Math.min(u,S.value.length);else if(u=(p=S.ownerDocument||document)&&p.defaultView||window,u.getSelection){u=u.getSelection();var R=S.textContent.length,M=Math.min(E.start,R);E=E.end===void 0?M:Math.min(E.end,R),!u.extend&&M>E&&(R=E,E=M,M=R),R=ZR(S,M);var U=ZR(S,E);R&&U&&(u.rangeCount!==1||u.anchorNode!==R.node||u.anchorOffset!==R.offset||u.focusNode!==U.node||u.focusOffset!==U.offset)&&(p=p.createRange(),p.setStart(R.node,R.offset),u.removeAllRanges(),M>E?(u.addRange(p),u.extend(U.node,U.offset)):(p.setEnd(U.node,U.offset),u.addRange(p)))}}for(p=[],u=S;u=u.parentNode;)u.nodeType===1&&p.push({element:u,left:u.scrollLeft,top:u.scrollTop});for(typeof S.focus=="function"&&S.focus(),S=0;S<p.length;S++)u=p[S],u.element.scrollLeft=u.left,u.element.scrollTop=u.top}}var mpe=a&&"documentMode"in document&&11>=document.documentMode,ku=null,IS=null,pf=null,PS=!1;function e2(u,p,S){var E=S.window===S?S.document:S.nodeType===9?S:S.ownerDocument;PS||ku==null||ku!==qe(E)||(E=ku,"selectionStart"in E&&ES(E)?E={start:E.selectionStart,end:E.selectionEnd}:(E=(E.ownerDocument&&E.ownerDocument.defaultView||window).getSelection(),E={anchorNode:E.anchorNode,anchorOffset:E.anchorOffset,focusNode:E.focusNode,focusOffset:E.focusOffset}),pf&&hf(pf,E)||(pf=E,E=kp(IS,"onSelect"),0<E.length&&(p=new ms("onSelect","select",null,p,S),u.push({event:p,listeners:E}),p.target=ku)))}function Tp(u,p){var S={};return S[u.toLowerCase()]=p.toLowerCase(),S["Webkit"+u]="webkit"+p,S["Moz"+u]="moz"+p,S}var Ou={animationend:Tp("Animation","AnimationEnd"),animationiteration:Tp("Animation","AnimationIteration"),animationstart:Tp("Animation","AnimationStart"),transitionend:Tp("Transition","TransitionEnd")},CS={},t2={};a&&(t2=document.createElement("div").style,"AnimationEvent"in window||(delete Ou.animationend.animation,delete Ou.animationiteration.animation,delete Ou.animationstart.animation),"TransitionEvent"in window||delete Ou.transitionend.transition);function Ap(u){if(CS[u])return CS[u];if(!Ou[u])return u;var p=Ou[u],S;for(S in p)if(p.hasOwnProperty(S)&&S in t2)return CS[u]=p[S];return u}var r2=Ap("animationend"),n2=Ap("animationiteration"),i2=Ap("animationstart"),o2=Ap("transitionend"),s2=new Map,a2="abort auxClick 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(" ");function bc(u,p){s2.set(u,p),o(p,[u])}for(var TS=0;TS<a2.length;TS++){var AS=a2[TS],ype=AS.toLowerCase(),Spe=AS[0].toUpperCase()+AS.slice(1);bc(ype,"on"+Spe)}bc(r2,"onAnimationEnd"),bc(n2,"onAnimationIteration"),bc(i2,"onAnimationStart"),bc("dblclick","onDoubleClick"),bc("focusin","onFocus"),bc("focusout","onBlur"),bc(o2,"onTransitionEnd"),s("onMouseEnter",["mouseout","mouseover"]),s("onMouseLeave",["mouseout","mouseover"]),s("onPointerEnter",["pointerout","pointerover"]),s("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var gf="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(" "),xpe=new Set("cancel close invalid load scroll toggle".split(" ").concat(gf));function c2(u,p,S){var E=u.type||"unknown-event";u.currentTarget=S,li(E,p,void 0,u),u.currentTarget=null}function l2(u,p){p=(p&4)!==0;for(var S=0;S<u.length;S++){var E=u[S],R=E.event;E=E.listeners;e:{var M=void 0;if(p)for(var U=E.length-1;0<=U;U--){var Q=E[U],ne=Q.instance,Se=Q.currentTarget;if(Q=Q.listener,ne!==M&&R.isPropagationStopped())break e;c2(R,Q,Se),M=ne}else for(U=0;U<E.length;U++){if(Q=E[U],ne=Q.instance,Se=Q.currentTarget,Q=Q.listener,ne!==M&&R.isPropagationStopped())break e;c2(R,Q,Se),M=ne}}}if(ln)throw u=Ma,ln=!1,Ma=null,u}function zr(u,p){var S=p[FS];S===void 0&&(S=p[FS]=new Set);var E=u+"__bubble";S.has(E)||(u2(p,u,2,!1),S.add(E))}function RS(u,p,S){var E=0;p&&(E|=4),u2(S,u,E,p)}var Rp="_reactListening"+Math.random().toString(36).slice(2);function vf(u){if(!u[Rp]){u[Rp]=!0,n.forEach(function(S){S!=="selectionchange"&&(xpe.has(S)||RS(S,!1,u),RS(S,!0,u))});var p=u.nodeType===9?u:u.ownerDocument;p===null||p[Rp]||(p[Rp]=!0,RS("selectionchange",!1,p))}}function u2(u,p,S,E){switch(pn(p)){case 1:var R=Re;break;case 4:R=lt;break;default:R=br}S=R.bind(null,p,S,u),R=void 0,!Oa||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(R=!0),E?R!==void 0?u.addEventListener(p,S,{capture:!0,passive:R}):u.addEventListener(p,S,!0):R!==void 0?u.addEventListener(p,S,{passive:R}):u.addEventListener(p,S,!1)}function kS(u,p,S,E,R){var M=E;if((p&1)===0&&(p&2)===0&&E!==null)e:for(;;){if(E===null)return;var U=E.tag;if(U===3||U===4){var Q=E.stateNode.containerInfo;if(Q===R||Q.nodeType===8&&Q.parentNode===R)break;if(U===4)for(U=E.return;U!==null;){var ne=U.tag;if((ne===3||ne===4)&&(ne=U.stateNode.containerInfo,ne===R||ne.nodeType===8&&ne.parentNode===R))return;U=U.return}for(;Q!==null;){if(U=Cl(Q),U===null)return;if(ne=U.tag,ne===5||ne===6){E=M=U;continue e}Q=Q.parentNode}}E=E.return}yc(function(){var Se=M,De=$e(S),Ue=[];e:{var je=s2.get(u);if(je!==void 0){var at=ms,gt=u;switch(u){case"keypress":if(gn(S)===0)break e;case"keydown":case"keyup":at=Xhe;break;case"focusin":gt="focus",at=SS;break;case"focusout":gt="blur",at=SS;break;case"beforeblur":case"afterblur":at=SS;break;case"click":if(S.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":at=LR;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":at=Nhe;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":at=Jhe;break;case r2:case n2:case i2:at=Bhe;break;case o2:at=tpe;break;case"scroll":at=Au;break;case"wheel":at=npe;break;case"copy":case"cut":case"paste":at=zhe;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":at=NR}var xt=(p&4)!==0,vn=!xt&&u==="scroll",de=xt?je!==null?je+"Capture":null:je;xt=[];for(var ie=Se,pe;ie!==null;){pe=ie;var Ve=pe.stateNode;if(pe.tag===5&&Ve!==null&&(pe=Ve,de!==null&&(Ve=Ws(ie,de),Ve!=null&&xt.push(mf(ie,Ve,pe)))),vn)break;ie=ie.return}0<xt.length&&(je=new at(je,gt,null,S,De),Ue.push({event:je,listeners:xt}))}}if((p&7)===0){e:{if(je=u==="mouseover"||u==="pointerover",at=u==="mouseout"||u==="pointerout",je&&S!==Pe&&(gt=S.relatedTarget||S.fromElement)&&(Cl(gt)||gt[La]))break e;if((at||je)&&(je=De.window===De?De:(je=De.ownerDocument)?je.defaultView||je.parentWindow:window,at?(gt=S.relatedTarget||S.toElement,at=Se,gt=gt?Cl(gt):null,gt!==null&&(vn=Go(gt),gt!==vn||gt.tag!==5&&gt.tag!==6)&&(gt=null)):(at=null,gt=Se),at!==gt)){if(xt=LR,Ve="onMouseLeave",de="onMouseEnter",ie="mouse",(u==="pointerout"||u==="pointerover")&&(xt=NR,Ve="onPointerLeave",de="onPointerEnter",ie="pointer"),vn=at==null?je:Du(at),pe=gt==null?je:Du(gt),je=new xt(Ve,ie+"leave",at,S,De),je.target=vn,je.relatedTarget=pe,Ve=null,Cl(De)===Se&&(xt=new xt(de,ie+"enter",gt,S,De),xt.target=pe,xt.relatedTarget=vn,Ve=xt),vn=Ve,at&&gt)t:{for(xt=at,de=gt,ie=0,pe=xt;pe;pe=Mu(pe))ie++;for(pe=0,Ve=de;Ve;Ve=Mu(Ve))pe++;for(;0<ie-pe;)xt=Mu(xt),ie--;for(;0<pe-ie;)de=Mu(de),pe--;for(;ie--;){if(xt===de||de!==null&&xt===de.alternate)break t;xt=Mu(xt),de=Mu(de)}xt=null}else xt=null;at!==null&&d2(Ue,je,at,xt,!1),gt!==null&&vn!==null&&d2(Ue,vn,gt,xt,!0)}}e:{if(je=Se?Du(Se):window,at=je.nodeName&&je.nodeName.toLowerCase(),at==="select"||at==="input"&&je.type==="file")var wt=upe;else if(HR(je))if(KR)wt=ppe;else{wt=fpe;var Rt=dpe}else(at=je.nodeName)&&at.toLowerCase()==="input"&&(je.type==="checkbox"||je.type==="radio")&&(wt=hpe);if(wt&&(wt=wt(u,Se))){WR(Ue,wt,S,De);break e}Rt&&Rt(u,je,Se),u==="focusout"&&(Rt=je._wrapperState)&&Rt.controlled&&je.type==="number"&&_t(je,"number",je.value)}switch(Rt=Se?Du(Se):window,u){case"focusin":(HR(Rt)||Rt.contentEditable==="true")&&(ku=Rt,IS=Se,pf=null);break;case"focusout":pf=IS=ku=null;break;case"mousedown":PS=!0;break;case"contextmenu":case"mouseup":case"dragend":PS=!1,e2(Ue,S,De);break;case"selectionchange":if(mpe)break;case"keydown":case"keyup":e2(Ue,S,De)}var kt;if(_S)e:{switch(u){case"compositionstart":var qt="onCompositionStart";break e;case"compositionend":qt="onCompositionEnd";break e;case"compositionupdate":qt="onCompositionUpdate";break e}qt=void 0}else Ru?UR(u,S)&&(qt="onCompositionEnd"):u==="keydown"&&S.keyCode===229&&(qt="onCompositionStart");qt&&($R&&S.locale!=="ko"&&(Ru||qt!=="onCompositionStart"?qt==="onCompositionEnd"&&Ru&&(kt=Zi()):(Dr=De,kr="value"in Dr?Dr.value:Dr.textContent,Ru=!0)),Rt=kp(Se,qt),0<Rt.length&&(qt=new FR(qt,u,null,S,De),Ue.push({event:qt,listeners:Rt}),kt?qt.data=kt:(kt=zR(S),kt!==null&&(qt.data=kt)))),(kt=ope?spe(u,S):ape(u,S))&&(Se=kp(Se,"onBeforeInput"),0<Se.length&&(De=new FR("onBeforeInput","beforeinput",null,S,De),Ue.push({event:De,listeners:Se}),De.data=kt))}l2(Ue,p)})}function mf(u,p,S){return{instance:u,listener:p,currentTarget:S}}function kp(u,p){for(var S=p+"Capture",E=[];u!==null;){var R=u,M=R.stateNode;R.tag===5&&M!==null&&(R=M,M=Ws(u,S),M!=null&&E.unshift(mf(u,M,R)),M=Ws(u,p),M!=null&&E.push(mf(u,M,R))),u=u.return}return E}function Mu(u){if(u===null)return null;do u=u.return;while(u&&u.tag!==5);return u||null}function d2(u,p,S,E,R){for(var M=p._reactName,U=[];S!==null&&S!==E;){var Q=S,ne=Q.alternate,Se=Q.stateNode;if(ne!==null&&ne===E)break;Q.tag===5&&Se!==null&&(Q=Se,R?(ne=Ws(S,M),ne!=null&&U.unshift(mf(S,ne,Q))):R||(ne=Ws(S,M),ne!=null&&U.push(mf(S,ne,Q)))),S=S.return}U.length!==0&&u.push({event:p,listeners:U})}var _pe=/\r\n?/g,wpe=/\u0000|\uFFFD/g;function f2(u){return(typeof u=="string"?u:""+u).replace(_pe,`
38
- `).replace(wpe,"")}function Op(u,p,S){if(p=f2(p),f2(u)!==p&&S)throw Error(t(425))}function Mp(){}var OS=null,MS=null;function jS(u,p){return u==="textarea"||u==="noscript"||typeof p.children=="string"||typeof p.children=="number"||typeof p.dangerouslySetInnerHTML=="object"&&p.dangerouslySetInnerHTML!==null&&p.dangerouslySetInnerHTML.__html!=null}var DS=typeof setTimeout=="function"?setTimeout:void 0,bpe=typeof clearTimeout=="function"?clearTimeout:void 0,h2=typeof Promise=="function"?Promise:void 0,Epe=typeof queueMicrotask=="function"?queueMicrotask:typeof h2<"u"?function(u){return h2.resolve(null).then(u).catch(Ipe)}:DS;function Ipe(u){setTimeout(function(){throw u})}function LS(u,p){var S=p,E=0;do{var R=S.nextSibling;if(u.removeChild(S),R&&R.nodeType===8)if(S=R.data,S==="/$"){if(E===0){u.removeChild(R),Pl(p);return}E--}else S!=="$"&&S!=="$?"&&S!=="$!"||E++;S=R}while(S);Pl(p)}function Ec(u){for(;u!=null;u=u.nextSibling){var p=u.nodeType;if(p===1||p===3)break;if(p===8){if(p=u.data,p==="$"||p==="$!"||p==="$?")break;if(p==="/$")return null}}return u}function p2(u){u=u.previousSibling;for(var p=0;u;){if(u.nodeType===8){var S=u.data;if(S==="$"||S==="$!"||S==="$?"){if(p===0)return u;p--}else S==="/$"&&p++}u=u.previousSibling}return null}var ju=Math.random().toString(36).slice(2),Qs="__reactFiber$"+ju,yf="__reactProps$"+ju,La="__reactContainer$"+ju,FS="__reactEvents$"+ju,Ppe="__reactListeners$"+ju,Cpe="__reactHandles$"+ju;function Cl(u){var p=u[Qs];if(p)return p;for(var S=u.parentNode;S;){if(p=S[La]||S[Qs]){if(S=p.alternate,p.child!==null||S!==null&&S.child!==null)for(u=p2(u);u!==null;){if(S=u[Qs])return S;u=p2(u)}return p}u=S,S=u.parentNode}return null}function Sf(u){return u=u[Qs]||u[La],!u||u.tag!==5&&u.tag!==6&&u.tag!==13&&u.tag!==3?null:u}function Du(u){if(u.tag===5||u.tag===6)return u.stateNode;throw Error(t(33))}function jp(u){return u[yf]||null}var NS=[],Lu=-1;function Ic(u){return{current:u}}function Hr(u){0>Lu||(u.current=NS[Lu],NS[Lu]=null,Lu--)}function Lr(u,p){Lu++,NS[Lu]=u.current,u.current=p}var Pc={},fi=Ic(Pc),Qi=Ic(!1),Tl=Pc;function Fu(u,p){var S=u.type.contextTypes;if(!S)return Pc;var E=u.stateNode;if(E&&E.__reactInternalMemoizedUnmaskedChildContext===p)return E.__reactInternalMemoizedMaskedChildContext;var R={},M;for(M in S)R[M]=p[M];return E&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=p,u.__reactInternalMemoizedMaskedChildContext=R),R}function Ji(u){return u=u.childContextTypes,u!=null}function Dp(){Hr(Qi),Hr(fi)}function g2(u,p,S){if(fi.current!==Pc)throw Error(t(168));Lr(fi,p),Lr(Qi,S)}function v2(u,p,S){var E=u.stateNode;if(p=p.childContextTypes,typeof E.getChildContext!="function")return S;E=E.getChildContext();for(var R in E)if(!(R in p))throw Error(t(108,ge(u)||"Unknown",R));return J({},S,E)}function Lp(u){return u=(u=u.stateNode)&&u.__reactInternalMemoizedMergedChildContext||Pc,Tl=fi.current,Lr(fi,u),Lr(Qi,Qi.current),!0}function m2(u,p,S){var E=u.stateNode;if(!E)throw Error(t(169));S?(u=v2(u,p,Tl),E.__reactInternalMemoizedMergedChildContext=u,Hr(Qi),Hr(fi),Lr(fi,u)):Hr(Qi),Lr(Qi,S)}var Fa=null,Fp=!1,$S=!1;function y2(u){Fa===null?Fa=[u]:Fa.push(u)}function Tpe(u){Fp=!0,y2(u)}function Cc(){if(!$S&&Fa!==null){$S=!0;var u=0,p=fr;try{var S=Fa;for(fr=1;u<S.length;u++){var E=S[u];do E=E(!0);while(E!==null)}Fa=null,Fp=!1}catch(R){throw Fa!==null&&(Fa=Fa.slice(u+1)),ke(Nn,Cc),R}finally{fr=p,$S=!1}}return null}var Nu=[],$u=0,Np=null,$p=0,Vo=[],Yo=0,Al=null,Na=1,$a="";function Rl(u,p){Nu[$u++]=$p,Nu[$u++]=Np,Np=u,$p=p}function S2(u,p,S){Vo[Yo++]=Na,Vo[Yo++]=$a,Vo[Yo++]=Al,Al=u;var E=Na;u=$a;var R=32-wo(E)-1;E&=~(1<<R),S+=1;var M=32-wo(p)+R;if(30<M){var U=R-R%5;M=(E&(1<<U)-1).toString(32),E>>=U,R-=U,Na=1<<32-wo(p)+R|S<<R|E,$a=M+u}else Na=1<<M|S<<R|E,$a=u}function qS(u){u.return!==null&&(Rl(u,1),S2(u,1,0))}function BS(u){for(;u===Np;)Np=Nu[--$u],Nu[$u]=null,$p=Nu[--$u],Nu[$u]=null;for(;u===Al;)Al=Vo[--Yo],Vo[Yo]=null,$a=Vo[--Yo],Vo[Yo]=null,Na=Vo[--Yo],Vo[Yo]=null}var bo=null,Eo=null,Xr=!1,Ss=null;function x2(u,p){var S=Jo(5,null,null,0);S.elementType="DELETED",S.stateNode=p,S.return=u,p=u.deletions,p===null?(u.deletions=[S],u.flags|=16):p.push(S)}function _2(u,p){switch(u.tag){case 5:var S=u.type;return p=p.nodeType!==1||S.toLowerCase()!==p.nodeName.toLowerCase()?null:p,p!==null?(u.stateNode=p,bo=u,Eo=Ec(p.firstChild),!0):!1;case 6:return p=u.pendingProps===""||p.nodeType!==3?null:p,p!==null?(u.stateNode=p,bo=u,Eo=null,!0):!1;case 13:return p=p.nodeType!==8?null:p,p!==null?(S=Al!==null?{id:Na,overflow:$a}:null,u.memoizedState={dehydrated:p,treeContext:S,retryLane:1073741824},S=Jo(18,null,null,0),S.stateNode=p,S.return=u,u.child=S,bo=u,Eo=null,!0):!1;default:return!1}}function US(u){return(u.mode&1)!==0&&(u.flags&128)===0}function zS(u){if(Xr){var p=Eo;if(p){var S=p;if(!_2(u,p)){if(US(u))throw Error(t(418));p=Ec(S.nextSibling);var E=bo;p&&_2(u,p)?x2(E,S):(u.flags=u.flags&-4097|2,Xr=!1,bo=u)}}else{if(US(u))throw Error(t(418));u.flags=u.flags&-4097|2,Xr=!1,bo=u}}}function w2(u){for(u=u.return;u!==null&&u.tag!==5&&u.tag!==3&&u.tag!==13;)u=u.return;bo=u}function qp(u){if(u!==bo)return!1;if(!Xr)return w2(u),Xr=!0,!1;var p;if((p=u.tag!==3)&&!(p=u.tag!==5)&&(p=u.type,p=p!=="head"&&p!=="body"&&!jS(u.type,u.memoizedProps)),p&&(p=Eo)){if(US(u))throw b2(),Error(t(418));for(;p;)x2(u,p),p=Ec(p.nextSibling)}if(w2(u),u.tag===13){if(u=u.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(t(317));e:{for(u=u.nextSibling,p=0;u;){if(u.nodeType===8){var S=u.data;if(S==="/$"){if(p===0){Eo=Ec(u.nextSibling);break e}p--}else S!=="$"&&S!=="$!"&&S!=="$?"||p++}u=u.nextSibling}Eo=null}}else Eo=bo?Ec(u.stateNode.nextSibling):null;return!0}function b2(){for(var u=Eo;u;)u=Ec(u.nextSibling)}function qu(){Eo=bo=null,Xr=!1}function HS(u){Ss===null?Ss=[u]:Ss.push(u)}var Ape=b.ReactCurrentBatchConfig;function xf(u,p,S){if(u=S.ref,u!==null&&typeof u!="function"&&typeof u!="object"){if(S._owner){if(S=S._owner,S){if(S.tag!==1)throw Error(t(309));var E=S.stateNode}if(!E)throw Error(t(147,u));var R=E,M=""+u;return p!==null&&p.ref!==null&&typeof p.ref=="function"&&p.ref._stringRef===M?p.ref:(p=function(U){var Q=R.refs;U===null?delete Q[M]:Q[M]=U},p._stringRef=M,p)}if(typeof u!="string")throw Error(t(284));if(!S._owner)throw Error(t(290,u))}return u}function Bp(u,p){throw u=Object.prototype.toString.call(p),Error(t(31,u==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":u))}function E2(u){var p=u._init;return p(u._payload)}function I2(u){function p(de,ie){if(u){var pe=de.deletions;pe===null?(de.deletions=[ie],de.flags|=16):pe.push(ie)}}function S(de,ie){if(!u)return null;for(;ie!==null;)p(de,ie),ie=ie.sibling;return null}function E(de,ie){for(de=new Map;ie!==null;)ie.key!==null?de.set(ie.key,ie):de.set(ie.index,ie),ie=ie.sibling;return de}function R(de,ie){return de=Dc(de,ie),de.index=0,de.sibling=null,de}function M(de,ie,pe){return de.index=pe,u?(pe=de.alternate,pe!==null?(pe=pe.index,pe<ie?(de.flags|=2,ie):pe):(de.flags|=2,ie)):(de.flags|=1048576,ie)}function U(de){return u&&de.alternate===null&&(de.flags|=2),de}function Q(de,ie,pe,Ve){return ie===null||ie.tag!==6?(ie=Dx(pe,de.mode,Ve),ie.return=de,ie):(ie=R(ie,pe),ie.return=de,ie)}function ne(de,ie,pe,Ve){var wt=pe.type;return wt===k?De(de,ie,pe.props.children,Ve,pe.key):ie!==null&&(ie.elementType===wt||typeof wt=="object"&&wt!==null&&wt.$$typeof===W&&E2(wt)===ie.type)?(Ve=R(ie,pe.props),Ve.ref=xf(de,ie,pe),Ve.return=de,Ve):(Ve=dg(pe.type,pe.key,pe.props,null,de.mode,Ve),Ve.ref=xf(de,ie,pe),Ve.return=de,Ve)}function Se(de,ie,pe,Ve){return ie===null||ie.tag!==4||ie.stateNode.containerInfo!==pe.containerInfo||ie.stateNode.implementation!==pe.implementation?(ie=Lx(pe,de.mode,Ve),ie.return=de,ie):(ie=R(ie,pe.children||[]),ie.return=de,ie)}function De(de,ie,pe,Ve,wt){return ie===null||ie.tag!==7?(ie=Nl(pe,de.mode,Ve,wt),ie.return=de,ie):(ie=R(ie,pe),ie.return=de,ie)}function Ue(de,ie,pe){if(typeof ie=="string"&&ie!==""||typeof ie=="number")return ie=Dx(""+ie,de.mode,pe),ie.return=de,ie;if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case P:return pe=dg(ie.type,ie.key,ie.props,null,de.mode,pe),pe.ref=xf(de,null,ie),pe.return=de,pe;case C:return ie=Lx(ie,de.mode,pe),ie.return=de,ie;case W:var Ve=ie._init;return Ue(de,Ve(ie._payload),pe)}if(ut(ie)||V(ie))return ie=Nl(ie,de.mode,pe,null),ie.return=de,ie;Bp(de,ie)}return null}function je(de,ie,pe,Ve){var wt=ie!==null?ie.key:null;if(typeof pe=="string"&&pe!==""||typeof pe=="number")return wt!==null?null:Q(de,ie,""+pe,Ve);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case P:return pe.key===wt?ne(de,ie,pe,Ve):null;case C:return pe.key===wt?Se(de,ie,pe,Ve):null;case W:return wt=pe._init,je(de,ie,wt(pe._payload),Ve)}if(ut(pe)||V(pe))return wt!==null?null:De(de,ie,pe,Ve,null);Bp(de,pe)}return null}function at(de,ie,pe,Ve,wt){if(typeof Ve=="string"&&Ve!==""||typeof Ve=="number")return de=de.get(pe)||null,Q(ie,de,""+Ve,wt);if(typeof Ve=="object"&&Ve!==null){switch(Ve.$$typeof){case P:return de=de.get(Ve.key===null?pe:Ve.key)||null,ne(ie,de,Ve,wt);case C:return de=de.get(Ve.key===null?pe:Ve.key)||null,Se(ie,de,Ve,wt);case W:var Rt=Ve._init;return at(de,ie,pe,Rt(Ve._payload),wt)}if(ut(Ve)||V(Ve))return de=de.get(pe)||null,De(ie,de,Ve,wt,null);Bp(ie,Ve)}return null}function gt(de,ie,pe,Ve){for(var wt=null,Rt=null,kt=ie,qt=ie=0,Un=null;kt!==null&&qt<pe.length;qt++){kt.index>qt?(Un=kt,kt=null):Un=kt.sibling;var mr=je(de,kt,pe[qt],Ve);if(mr===null){kt===null&&(kt=Un);break}u&&kt&&mr.alternate===null&&p(de,kt),ie=M(mr,ie,qt),Rt===null?wt=mr:Rt.sibling=mr,Rt=mr,kt=Un}if(qt===pe.length)return S(de,kt),Xr&&Rl(de,qt),wt;if(kt===null){for(;qt<pe.length;qt++)kt=Ue(de,pe[qt],Ve),kt!==null&&(ie=M(kt,ie,qt),Rt===null?wt=kt:Rt.sibling=kt,Rt=kt);return Xr&&Rl(de,qt),wt}for(kt=E(de,kt);qt<pe.length;qt++)Un=at(kt,de,qt,pe[qt],Ve),Un!==null&&(u&&Un.alternate!==null&&kt.delete(Un.key===null?qt:Un.key),ie=M(Un,ie,qt),Rt===null?wt=Un:Rt.sibling=Un,Rt=Un);return u&&kt.forEach(function(Lc){return p(de,Lc)}),Xr&&Rl(de,qt),wt}function xt(de,ie,pe,Ve){var wt=V(pe);if(typeof wt!="function")throw Error(t(150));if(pe=wt.call(pe),pe==null)throw Error(t(151));for(var Rt=wt=null,kt=ie,qt=ie=0,Un=null,mr=pe.next();kt!==null&&!mr.done;qt++,mr=pe.next()){kt.index>qt?(Un=kt,kt=null):Un=kt.sibling;var Lc=je(de,kt,mr.value,Ve);if(Lc===null){kt===null&&(kt=Un);break}u&&kt&&Lc.alternate===null&&p(de,kt),ie=M(Lc,ie,qt),Rt===null?wt=Lc:Rt.sibling=Lc,Rt=Lc,kt=Un}if(mr.done)return S(de,kt),Xr&&Rl(de,qt),wt;if(kt===null){for(;!mr.done;qt++,mr=pe.next())mr=Ue(de,mr.value,Ve),mr!==null&&(ie=M(mr,ie,qt),Rt===null?wt=mr:Rt.sibling=mr,Rt=mr);return Xr&&Rl(de,qt),wt}for(kt=E(de,kt);!mr.done;qt++,mr=pe.next())mr=at(kt,de,qt,mr.value,Ve),mr!==null&&(u&&mr.alternate!==null&&kt.delete(mr.key===null?qt:mr.key),ie=M(mr,ie,qt),Rt===null?wt=mr:Rt.sibling=mr,Rt=mr);return u&&kt.forEach(function(cge){return p(de,cge)}),Xr&&Rl(de,qt),wt}function vn(de,ie,pe,Ve){if(typeof pe=="object"&&pe!==null&&pe.type===k&&pe.key===null&&(pe=pe.props.children),typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case P:e:{for(var wt=pe.key,Rt=ie;Rt!==null;){if(Rt.key===wt){if(wt=pe.type,wt===k){if(Rt.tag===7){S(de,Rt.sibling),ie=R(Rt,pe.props.children),ie.return=de,de=ie;break e}}else if(Rt.elementType===wt||typeof wt=="object"&&wt!==null&&wt.$$typeof===W&&E2(wt)===Rt.type){S(de,Rt.sibling),ie=R(Rt,pe.props),ie.ref=xf(de,Rt,pe),ie.return=de,de=ie;break e}S(de,Rt);break}else p(de,Rt);Rt=Rt.sibling}pe.type===k?(ie=Nl(pe.props.children,de.mode,Ve,pe.key),ie.return=de,de=ie):(Ve=dg(pe.type,pe.key,pe.props,null,de.mode,Ve),Ve.ref=xf(de,ie,pe),Ve.return=de,de=Ve)}return U(de);case C:e:{for(Rt=pe.key;ie!==null;){if(ie.key===Rt)if(ie.tag===4&&ie.stateNode.containerInfo===pe.containerInfo&&ie.stateNode.implementation===pe.implementation){S(de,ie.sibling),ie=R(ie,pe.children||[]),ie.return=de,de=ie;break e}else{S(de,ie);break}else p(de,ie);ie=ie.sibling}ie=Lx(pe,de.mode,Ve),ie.return=de,de=ie}return U(de);case W:return Rt=pe._init,vn(de,ie,Rt(pe._payload),Ve)}if(ut(pe))return gt(de,ie,pe,Ve);if(V(pe))return xt(de,ie,pe,Ve);Bp(de,pe)}return typeof pe=="string"&&pe!==""||typeof pe=="number"?(pe=""+pe,ie!==null&&ie.tag===6?(S(de,ie.sibling),ie=R(ie,pe),ie.return=de,de=ie):(S(de,ie),ie=Dx(pe,de.mode,Ve),ie.return=de,de=ie),U(de)):S(de,ie)}return vn}var Bu=I2(!0),P2=I2(!1),Up=Ic(null),zp=null,Uu=null,WS=null;function KS(){WS=Uu=zp=null}function GS(u){var p=Up.current;Hr(Up),u._currentValue=p}function VS(u,p,S){for(;u!==null;){var E=u.alternate;if((u.childLanes&p)!==p?(u.childLanes|=p,E!==null&&(E.childLanes|=p)):E!==null&&(E.childLanes&p)!==p&&(E.childLanes|=p),u===S)break;u=u.return}}function zu(u,p){zp=u,WS=Uu=null,u=u.dependencies,u!==null&&u.firstContext!==null&&((u.lanes&p)!==0&&(eo=!0),u.firstContext=null)}function Xo(u){var p=u._currentValue;if(WS!==u)if(u={context:u,memoizedValue:p,next:null},Uu===null){if(zp===null)throw Error(t(308));Uu=u,zp.dependencies={lanes:0,firstContext:u}}else Uu=Uu.next=u;return p}var kl=null;function YS(u){kl===null?kl=[u]:kl.push(u)}function C2(u,p,S,E){var R=p.interleaved;return R===null?(S.next=S,YS(p)):(S.next=R.next,R.next=S),p.interleaved=S,qa(u,E)}function qa(u,p){u.lanes|=p;var S=u.alternate;for(S!==null&&(S.lanes|=p),S=u,u=u.return;u!==null;)u.childLanes|=p,S=u.alternate,S!==null&&(S.childLanes|=p),S=u,u=u.return;return S.tag===3?S.stateNode:null}var Tc=!1;function XS(u){u.updateQueue={baseState:u.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function T2(u,p){u=u.updateQueue,p.updateQueue===u&&(p.updateQueue={baseState:u.baseState,firstBaseUpdate:u.firstBaseUpdate,lastBaseUpdate:u.lastBaseUpdate,shared:u.shared,effects:u.effects})}function Ba(u,p){return{eventTime:u,lane:p,tag:0,payload:null,callback:null,next:null}}function Ac(u,p,S){var E=u.updateQueue;if(E===null)return null;if(E=E.shared,(gr&2)!==0){var R=E.pending;return R===null?p.next=p:(p.next=R.next,R.next=p),E.pending=p,qa(u,S)}return R=E.interleaved,R===null?(p.next=p,YS(E)):(p.next=R.next,R.next=p),E.interleaved=p,qa(u,S)}function Hp(u,p,S){if(p=p.updateQueue,p!==null&&(p=p.shared,(S&4194240)!==0)){var E=p.lanes;E&=u.pendingLanes,S|=E,p.lanes=S,Cu(u,S)}}function A2(u,p){var S=u.updateQueue,E=u.alternate;if(E!==null&&(E=E.updateQueue,S===E)){var R=null,M=null;if(S=S.firstBaseUpdate,S!==null){do{var U={eventTime:S.eventTime,lane:S.lane,tag:S.tag,payload:S.payload,callback:S.callback,next:null};M===null?R=M=U:M=M.next=U,S=S.next}while(S!==null);M===null?R=M=p:M=M.next=p}else R=M=p;S={baseState:E.baseState,firstBaseUpdate:R,lastBaseUpdate:M,shared:E.shared,effects:E.effects},u.updateQueue=S;return}u=S.lastBaseUpdate,u===null?S.firstBaseUpdate=p:u.next=p,S.lastBaseUpdate=p}function Wp(u,p,S,E){var R=u.updateQueue;Tc=!1;var M=R.firstBaseUpdate,U=R.lastBaseUpdate,Q=R.shared.pending;if(Q!==null){R.shared.pending=null;var ne=Q,Se=ne.next;ne.next=null,U===null?M=Se:U.next=Se,U=ne;var De=u.alternate;De!==null&&(De=De.updateQueue,Q=De.lastBaseUpdate,Q!==U&&(Q===null?De.firstBaseUpdate=Se:Q.next=Se,De.lastBaseUpdate=ne))}if(M!==null){var Ue=R.baseState;U=0,De=Se=ne=null,Q=M;do{var je=Q.lane,at=Q.eventTime;if((E&je)===je){De!==null&&(De=De.next={eventTime:at,lane:0,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null});e:{var gt=u,xt=Q;switch(je=p,at=S,xt.tag){case 1:if(gt=xt.payload,typeof gt=="function"){Ue=gt.call(at,Ue,je);break e}Ue=gt;break e;case 3:gt.flags=gt.flags&-65537|128;case 0:if(gt=xt.payload,je=typeof gt=="function"?gt.call(at,Ue,je):gt,je==null)break e;Ue=J({},Ue,je);break e;case 2:Tc=!0}}Q.callback!==null&&Q.lane!==0&&(u.flags|=64,je=R.effects,je===null?R.effects=[Q]:je.push(Q))}else at={eventTime:at,lane:je,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},De===null?(Se=De=at,ne=Ue):De=De.next=at,U|=je;if(Q=Q.next,Q===null){if(Q=R.shared.pending,Q===null)break;je=Q,Q=je.next,je.next=null,R.lastBaseUpdate=je,R.shared.pending=null}}while(!0);if(De===null&&(ne=Ue),R.baseState=ne,R.firstBaseUpdate=Se,R.lastBaseUpdate=De,p=R.shared.interleaved,p!==null){R=p;do U|=R.lane,R=R.next;while(R!==p)}else M===null&&(R.shared.lanes=0);jl|=U,u.lanes=U,u.memoizedState=Ue}}function R2(u,p,S){if(u=p.effects,p.effects=null,u!==null)for(p=0;p<u.length;p++){var E=u[p],R=E.callback;if(R!==null){if(E.callback=null,E=S,typeof R!="function")throw Error(t(191,R));R.call(E)}}}var _f={},Js=Ic(_f),wf=Ic(_f),bf=Ic(_f);function Ol(u){if(u===_f)throw Error(t(174));return u}function ZS(u,p){switch(Lr(bf,p),Lr(wf,u),Lr(Js,_f),u=p.nodeType,u){case 9:case 11:p=(p=p.documentElement)?p.namespaceURI:Ye(null,"");break;default:u=u===8?p.parentNode:p,p=u.namespaceURI||null,u=u.tagName,p=Ye(p,u)}Hr(Js),Lr(Js,p)}function Hu(){Hr(Js),Hr(wf),Hr(bf)}function k2(u){Ol(bf.current);var p=Ol(Js.current),S=Ye(p,u.type);p!==S&&(Lr(wf,u),Lr(Js,S))}function QS(u){wf.current===u&&(Hr(Js),Hr(wf))}var tn=Ic(0);function Kp(u){for(var p=u;p!==null;){if(p.tag===13){var S=p.memoizedState;if(S!==null&&(S=S.dehydrated,S===null||S.data==="$?"||S.data==="$!"))return p}else if(p.tag===19&&p.memoizedProps.revealOrder!==void 0){if((p.flags&128)!==0)return p}else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===u)break;for(;p.sibling===null;){if(p.return===null||p.return===u)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var JS=[];function ex(){for(var u=0;u<JS.length;u++)JS[u]._workInProgressVersionPrimary=null;JS.length=0}var Gp=b.ReactCurrentDispatcher,tx=b.ReactCurrentBatchConfig,Ml=0,rn=null,kn=null,qn=null,Vp=!1,Ef=!1,If=0,Rpe=0;function hi(){throw Error(t(321))}function rx(u,p){if(p===null)return!1;for(var S=0;S<p.length&&S<u.length;S++)if(!ys(u[S],p[S]))return!1;return!0}function nx(u,p,S,E,R,M){if(Ml=M,rn=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,Gp.current=u===null||u.memoizedState===null?jpe:Dpe,u=S(E,R),Ef){M=0;do{if(Ef=!1,If=0,25<=M)throw Error(t(301));M+=1,qn=kn=null,p.updateQueue=null,Gp.current=Lpe,u=S(E,R)}while(Ef)}if(Gp.current=Zp,p=kn!==null&&kn.next!==null,Ml=0,qn=kn=rn=null,Vp=!1,p)throw Error(t(300));return u}function ix(){var u=If!==0;return If=0,u}function ea(){var u={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return qn===null?rn.memoizedState=qn=u:qn=qn.next=u,qn}function Zo(){if(kn===null){var u=rn.alternate;u=u!==null?u.memoizedState:null}else u=kn.next;var p=qn===null?rn.memoizedState:qn.next;if(p!==null)qn=p,kn=u;else{if(u===null)throw Error(t(310));kn=u,u={memoizedState:kn.memoizedState,baseState:kn.baseState,baseQueue:kn.baseQueue,queue:kn.queue,next:null},qn===null?rn.memoizedState=qn=u:qn=qn.next=u}return qn}function Pf(u,p){return typeof p=="function"?p(u):p}function ox(u){var p=Zo(),S=p.queue;if(S===null)throw Error(t(311));S.lastRenderedReducer=u;var E=kn,R=E.baseQueue,M=S.pending;if(M!==null){if(R!==null){var U=R.next;R.next=M.next,M.next=U}E.baseQueue=R=M,S.pending=null}if(R!==null){M=R.next,E=E.baseState;var Q=U=null,ne=null,Se=M;do{var De=Se.lane;if((Ml&De)===De)ne!==null&&(ne=ne.next={lane:0,action:Se.action,hasEagerState:Se.hasEagerState,eagerState:Se.eagerState,next:null}),E=Se.hasEagerState?Se.eagerState:u(E,Se.action);else{var Ue={lane:De,action:Se.action,hasEagerState:Se.hasEagerState,eagerState:Se.eagerState,next:null};ne===null?(Q=ne=Ue,U=E):ne=ne.next=Ue,rn.lanes|=De,jl|=De}Se=Se.next}while(Se!==null&&Se!==M);ne===null?U=E:ne.next=Q,ys(E,p.memoizedState)||(eo=!0),p.memoizedState=E,p.baseState=U,p.baseQueue=ne,S.lastRenderedState=E}if(u=S.interleaved,u!==null){R=u;do M=R.lane,rn.lanes|=M,jl|=M,R=R.next;while(R!==u)}else R===null&&(S.lanes=0);return[p.memoizedState,S.dispatch]}function sx(u){var p=Zo(),S=p.queue;if(S===null)throw Error(t(311));S.lastRenderedReducer=u;var E=S.dispatch,R=S.pending,M=p.memoizedState;if(R!==null){S.pending=null;var U=R=R.next;do M=u(M,U.action),U=U.next;while(U!==R);ys(M,p.memoizedState)||(eo=!0),p.memoizedState=M,p.baseQueue===null&&(p.baseState=M),S.lastRenderedState=M}return[M,E]}function O2(){}function M2(u,p){var S=rn,E=Zo(),R=p(),M=!ys(E.memoizedState,R);if(M&&(E.memoizedState=R,eo=!0),E=E.queue,ax(L2.bind(null,S,E,u),[u]),E.getSnapshot!==p||M||qn!==null&&qn.memoizedState.tag&1){if(S.flags|=2048,Cf(9,D2.bind(null,S,E,R,p),void 0,null),Bn===null)throw Error(t(349));(Ml&30)!==0||j2(S,p,R)}return R}function j2(u,p,S){u.flags|=16384,u={getSnapshot:p,value:S},p=rn.updateQueue,p===null?(p={lastEffect:null,stores:null},rn.updateQueue=p,p.stores=[u]):(S=p.stores,S===null?p.stores=[u]:S.push(u))}function D2(u,p,S,E){p.value=S,p.getSnapshot=E,F2(p)&&N2(u)}function L2(u,p,S){return S(function(){F2(p)&&N2(u)})}function F2(u){var p=u.getSnapshot;u=u.value;try{var S=p();return!ys(u,S)}catch{return!0}}function N2(u){var p=qa(u,1);p!==null&&bs(p,u,1,-1)}function $2(u){var p=ea();return typeof u=="function"&&(u=u()),p.memoizedState=p.baseState=u,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Pf,lastRenderedState:u},p.queue=u,u=u.dispatch=Mpe.bind(null,rn,u),[p.memoizedState,u]}function Cf(u,p,S,E){return u={tag:u,create:p,destroy:S,deps:E,next:null},p=rn.updateQueue,p===null?(p={lastEffect:null,stores:null},rn.updateQueue=p,p.lastEffect=u.next=u):(S=p.lastEffect,S===null?p.lastEffect=u.next=u:(E=S.next,S.next=u,u.next=E,p.lastEffect=u)),u}function q2(){return Zo().memoizedState}function Yp(u,p,S,E){var R=ea();rn.flags|=u,R.memoizedState=Cf(1|p,S,void 0,E===void 0?null:E)}function Xp(u,p,S,E){var R=Zo();E=E===void 0?null:E;var M=void 0;if(kn!==null){var U=kn.memoizedState;if(M=U.destroy,E!==null&&rx(E,U.deps)){R.memoizedState=Cf(p,S,M,E);return}}rn.flags|=u,R.memoizedState=Cf(1|p,S,M,E)}function B2(u,p){return Yp(8390656,8,u,p)}function ax(u,p){return Xp(2048,8,u,p)}function U2(u,p){return Xp(4,2,u,p)}function z2(u,p){return Xp(4,4,u,p)}function H2(u,p){if(typeof p=="function")return u=u(),p(u),function(){p(null)};if(p!=null)return u=u(),p.current=u,function(){p.current=null}}function W2(u,p,S){return S=S!=null?S.concat([u]):null,Xp(4,4,H2.bind(null,p,u),S)}function cx(){}function K2(u,p){var S=Zo();p=p===void 0?null:p;var E=S.memoizedState;return E!==null&&p!==null&&rx(p,E[1])?E[0]:(S.memoizedState=[u,p],u)}function G2(u,p){var S=Zo();p=p===void 0?null:p;var E=S.memoizedState;return E!==null&&p!==null&&rx(p,E[1])?E[0]:(u=u(),S.memoizedState=[u,p],u)}function V2(u,p,S){return(Ml&21)===0?(u.baseState&&(u.baseState=!1,eo=!0),u.memoizedState=S):(ys(S,p)||(S=xp(),rn.lanes|=S,jl|=S,u.baseState=!0),p)}function kpe(u,p){var S=fr;fr=S!==0&&4>S?S:4,u(!0);var E=tx.transition;tx.transition={};try{u(!1),p()}finally{fr=S,tx.transition=E}}function Y2(){return Zo().memoizedState}function Ope(u,p,S){var E=Mc(u);if(S={lane:E,action:S,hasEagerState:!1,eagerState:null,next:null},X2(u))Z2(p,S);else if(S=C2(u,p,S,E),S!==null){var R=Ni();bs(S,u,E,R),Q2(S,p,E)}}function Mpe(u,p,S){var E=Mc(u),R={lane:E,action:S,hasEagerState:!1,eagerState:null,next:null};if(X2(u))Z2(p,R);else{var M=u.alternate;if(u.lanes===0&&(M===null||M.lanes===0)&&(M=p.lastRenderedReducer,M!==null))try{var U=p.lastRenderedState,Q=M(U,S);if(R.hasEagerState=!0,R.eagerState=Q,ys(Q,U)){var ne=p.interleaved;ne===null?(R.next=R,YS(p)):(R.next=ne.next,ne.next=R),p.interleaved=R;return}}catch{}finally{}S=C2(u,p,R,E),S!==null&&(R=Ni(),bs(S,u,E,R),Q2(S,p,E))}}function X2(u){var p=u.alternate;return u===rn||p!==null&&p===rn}function Z2(u,p){Ef=Vp=!0;var S=u.pending;S===null?p.next=p:(p.next=S.next,S.next=p),u.pending=p}function Q2(u,p,S){if((S&4194240)!==0){var E=p.lanes;E&=u.pendingLanes,S|=E,p.lanes=S,Cu(u,S)}}var Zp={readContext:Xo,useCallback:hi,useContext:hi,useEffect:hi,useImperativeHandle:hi,useInsertionEffect:hi,useLayoutEffect:hi,useMemo:hi,useReducer:hi,useRef:hi,useState:hi,useDebugValue:hi,useDeferredValue:hi,useTransition:hi,useMutableSource:hi,useSyncExternalStore:hi,useId:hi,unstable_isNewReconciler:!1},jpe={readContext:Xo,useCallback:function(u,p){return ea().memoizedState=[u,p===void 0?null:p],u},useContext:Xo,useEffect:B2,useImperativeHandle:function(u,p,S){return S=S!=null?S.concat([u]):null,Yp(4194308,4,H2.bind(null,p,u),S)},useLayoutEffect:function(u,p){return Yp(4194308,4,u,p)},useInsertionEffect:function(u,p){return Yp(4,2,u,p)},useMemo:function(u,p){var S=ea();return p=p===void 0?null:p,u=u(),S.memoizedState=[u,p],u},useReducer:function(u,p,S){var E=ea();return p=S!==void 0?S(p):p,E.memoizedState=E.baseState=p,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:u,lastRenderedState:p},E.queue=u,u=u.dispatch=Ope.bind(null,rn,u),[E.memoizedState,u]},useRef:function(u){var p=ea();return u={current:u},p.memoizedState=u},useState:$2,useDebugValue:cx,useDeferredValue:function(u){return ea().memoizedState=u},useTransition:function(){var u=$2(!1),p=u[0];return u=kpe.bind(null,u[1]),ea().memoizedState=u,[p,u]},useMutableSource:function(){},useSyncExternalStore:function(u,p,S){var E=rn,R=ea();if(Xr){if(S===void 0)throw Error(t(407));S=S()}else{if(S=p(),Bn===null)throw Error(t(349));(Ml&30)!==0||j2(E,p,S)}R.memoizedState=S;var M={value:S,getSnapshot:p};return R.queue=M,B2(L2.bind(null,E,M,u),[u]),E.flags|=2048,Cf(9,D2.bind(null,E,M,S,p),void 0,null),S},useId:function(){var u=ea(),p=Bn.identifierPrefix;if(Xr){var S=$a,E=Na;S=(E&~(1<<32-wo(E)-1)).toString(32)+S,p=":"+p+"R"+S,S=If++,0<S&&(p+="H"+S.toString(32)),p+=":"}else S=Rpe++,p=":"+p+"r"+S.toString(32)+":";return u.memoizedState=p},unstable_isNewReconciler:!1},Dpe={readContext:Xo,useCallback:K2,useContext:Xo,useEffect:ax,useImperativeHandle:W2,useInsertionEffect:U2,useLayoutEffect:z2,useMemo:G2,useReducer:ox,useRef:q2,useState:function(){return ox(Pf)},useDebugValue:cx,useDeferredValue:function(u){var p=Zo();return V2(p,kn.memoizedState,u)},useTransition:function(){var u=ox(Pf)[0],p=Zo().memoizedState;return[u,p]},useMutableSource:O2,useSyncExternalStore:M2,useId:Y2,unstable_isNewReconciler:!1},Lpe={readContext:Xo,useCallback:K2,useContext:Xo,useEffect:ax,useImperativeHandle:W2,useInsertionEffect:U2,useLayoutEffect:z2,useMemo:G2,useReducer:sx,useRef:q2,useState:function(){return sx(Pf)},useDebugValue:cx,useDeferredValue:function(u){var p=Zo();return kn===null?p.memoizedState=u:V2(p,kn.memoizedState,u)},useTransition:function(){var u=sx(Pf)[0],p=Zo().memoizedState;return[u,p]},useMutableSource:O2,useSyncExternalStore:M2,useId:Y2,unstable_isNewReconciler:!1};function xs(u,p){if(u&&u.defaultProps){p=J({},p),u=u.defaultProps;for(var S in u)p[S]===void 0&&(p[S]=u[S]);return p}return p}function lx(u,p,S,E){p=u.memoizedState,S=S(E,p),S=S==null?p:J({},p,S),u.memoizedState=S,u.lanes===0&&(u.updateQueue.baseState=S)}var Qp={isMounted:function(u){return(u=u._reactInternals)?Go(u)===u:!1},enqueueSetState:function(u,p,S){u=u._reactInternals;var E=Ni(),R=Mc(u),M=Ba(E,R);M.payload=p,S!=null&&(M.callback=S),p=Ac(u,M,R),p!==null&&(bs(p,u,R,E),Hp(p,u,R))},enqueueReplaceState:function(u,p,S){u=u._reactInternals;var E=Ni(),R=Mc(u),M=Ba(E,R);M.tag=1,M.payload=p,S!=null&&(M.callback=S),p=Ac(u,M,R),p!==null&&(bs(p,u,R,E),Hp(p,u,R))},enqueueForceUpdate:function(u,p){u=u._reactInternals;var S=Ni(),E=Mc(u),R=Ba(S,E);R.tag=2,p!=null&&(R.callback=p),p=Ac(u,R,E),p!==null&&(bs(p,u,E,S),Hp(p,u,E))}};function J2(u,p,S,E,R,M,U){return u=u.stateNode,typeof u.shouldComponentUpdate=="function"?u.shouldComponentUpdate(E,M,U):p.prototype&&p.prototype.isPureReactComponent?!hf(S,E)||!hf(R,M):!0}function ek(u,p,S){var E=!1,R=Pc,M=p.contextType;return typeof M=="object"&&M!==null?M=Xo(M):(R=Ji(p)?Tl:fi.current,E=p.contextTypes,M=(E=E!=null)?Fu(u,R):Pc),p=new p(S,M),u.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,p.updater=Qp,u.stateNode=p,p._reactInternals=u,E&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=R,u.__reactInternalMemoizedMaskedChildContext=M),p}function tk(u,p,S,E){u=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(S,E),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(S,E),p.state!==u&&Qp.enqueueReplaceState(p,p.state,null)}function ux(u,p,S,E){var R=u.stateNode;R.props=S,R.state=u.memoizedState,R.refs={},XS(u);var M=p.contextType;typeof M=="object"&&M!==null?R.context=Xo(M):(M=Ji(p)?Tl:fi.current,R.context=Fu(u,M)),R.state=u.memoizedState,M=p.getDerivedStateFromProps,typeof M=="function"&&(lx(u,p,M,S),R.state=u.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof R.getSnapshotBeforeUpdate=="function"||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(p=R.state,typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount(),p!==R.state&&Qp.enqueueReplaceState(R,R.state,null),Wp(u,S,R,E),R.state=u.memoizedState),typeof R.componentDidMount=="function"&&(u.flags|=4194308)}function Wu(u,p){try{var S="",E=p;do S+=te(E),E=E.return;while(E);var R=S}catch(M){R=`
39
- Error generating stack: `+M.message+`
40
- `+M.stack}return{value:u,source:p,stack:R,digest:null}}function dx(u,p,S){return{value:u,source:null,stack:S??null,digest:p??null}}function fx(u,p){try{console.error(p.value)}catch(S){setTimeout(function(){throw S})}}var Fpe=typeof WeakMap=="function"?WeakMap:Map;function rk(u,p,S){S=Ba(-1,S),S.tag=3,S.payload={element:null};var E=p.value;return S.callback=function(){og||(og=!0,Cx=E),fx(u,p)},S}function nk(u,p,S){S=Ba(-1,S),S.tag=3;var E=u.type.getDerivedStateFromError;if(typeof E=="function"){var R=p.value;S.payload=function(){return E(R)},S.callback=function(){fx(u,p)}}var M=u.stateNode;return M!==null&&typeof M.componentDidCatch=="function"&&(S.callback=function(){fx(u,p),typeof E!="function"&&(kc===null?kc=new Set([this]):kc.add(this));var U=p.stack;this.componentDidCatch(p.value,{componentStack:U!==null?U:""})}),S}function ik(u,p,S){var E=u.pingCache;if(E===null){E=u.pingCache=new Fpe;var R=new Set;E.set(p,R)}else R=E.get(p),R===void 0&&(R=new Set,E.set(p,R));R.has(S)||(R.add(S),u=Zpe.bind(null,u,p,S),p.then(u,u))}function ok(u){do{var p;if((p=u.tag===13)&&(p=u.memoizedState,p=p!==null?p.dehydrated!==null:!0),p)return u;u=u.return}while(u!==null);return null}function sk(u,p,S,E,R){return(u.mode&1)===0?(u===p?u.flags|=65536:(u.flags|=128,S.flags|=131072,S.flags&=-52805,S.tag===1&&(S.alternate===null?S.tag=17:(p=Ba(-1,1),p.tag=2,Ac(S,p,1))),S.lanes|=1),u):(u.flags|=65536,u.lanes=R,u)}var Npe=b.ReactCurrentOwner,eo=!1;function Fi(u,p,S,E){p.child=u===null?P2(p,null,S,E):Bu(p,u.child,S,E)}function ak(u,p,S,E,R){S=S.render;var M=p.ref;return zu(p,R),E=nx(u,p,S,E,M,R),S=ix(),u!==null&&!eo?(p.updateQueue=u.updateQueue,p.flags&=-2053,u.lanes&=~R,Ua(u,p,R)):(Xr&&S&&qS(p),p.flags|=1,Fi(u,p,E,R),p.child)}function ck(u,p,S,E,R){if(u===null){var M=S.type;return typeof M=="function"&&!jx(M)&&M.defaultProps===void 0&&S.compare===null&&S.defaultProps===void 0?(p.tag=15,p.type=M,lk(u,p,M,E,R)):(u=dg(S.type,null,E,p,p.mode,R),u.ref=p.ref,u.return=p,p.child=u)}if(M=u.child,(u.lanes&R)===0){var U=M.memoizedProps;if(S=S.compare,S=S!==null?S:hf,S(U,E)&&u.ref===p.ref)return Ua(u,p,R)}return p.flags|=1,u=Dc(M,E),u.ref=p.ref,u.return=p,p.child=u}function lk(u,p,S,E,R){if(u!==null){var M=u.memoizedProps;if(hf(M,E)&&u.ref===p.ref)if(eo=!1,p.pendingProps=E=M,(u.lanes&R)!==0)(u.flags&131072)!==0&&(eo=!0);else return p.lanes=u.lanes,Ua(u,p,R)}return hx(u,p,S,E,R)}function uk(u,p,S){var E=p.pendingProps,R=E.children,M=u!==null?u.memoizedState:null;if(E.mode==="hidden")if((p.mode&1)===0)p.memoizedState={baseLanes:0,cachePool:null,transitions:null},Lr(Gu,Io),Io|=S;else{if((S&1073741824)===0)return u=M!==null?M.baseLanes|S:S,p.lanes=p.childLanes=1073741824,p.memoizedState={baseLanes:u,cachePool:null,transitions:null},p.updateQueue=null,Lr(Gu,Io),Io|=u,null;p.memoizedState={baseLanes:0,cachePool:null,transitions:null},E=M!==null?M.baseLanes:S,Lr(Gu,Io),Io|=E}else M!==null?(E=M.baseLanes|S,p.memoizedState=null):E=S,Lr(Gu,Io),Io|=E;return Fi(u,p,R,S),p.child}function dk(u,p){var S=p.ref;(u===null&&S!==null||u!==null&&u.ref!==S)&&(p.flags|=512,p.flags|=2097152)}function hx(u,p,S,E,R){var M=Ji(S)?Tl:fi.current;return M=Fu(p,M),zu(p,R),S=nx(u,p,S,E,M,R),E=ix(),u!==null&&!eo?(p.updateQueue=u.updateQueue,p.flags&=-2053,u.lanes&=~R,Ua(u,p,R)):(Xr&&E&&qS(p),p.flags|=1,Fi(u,p,S,R),p.child)}function fk(u,p,S,E,R){if(Ji(S)){var M=!0;Lp(p)}else M=!1;if(zu(p,R),p.stateNode===null)eg(u,p),ek(p,S,E),ux(p,S,E,R),E=!0;else if(u===null){var U=p.stateNode,Q=p.memoizedProps;U.props=Q;var ne=U.context,Se=S.contextType;typeof Se=="object"&&Se!==null?Se=Xo(Se):(Se=Ji(S)?Tl:fi.current,Se=Fu(p,Se));var De=S.getDerivedStateFromProps,Ue=typeof De=="function"||typeof U.getSnapshotBeforeUpdate=="function";Ue||typeof U.UNSAFE_componentWillReceiveProps!="function"&&typeof U.componentWillReceiveProps!="function"||(Q!==E||ne!==Se)&&tk(p,U,E,Se),Tc=!1;var je=p.memoizedState;U.state=je,Wp(p,E,U,R),ne=p.memoizedState,Q!==E||je!==ne||Qi.current||Tc?(typeof De=="function"&&(lx(p,S,De,E),ne=p.memoizedState),(Q=Tc||J2(p,S,Q,E,je,ne,Se))?(Ue||typeof U.UNSAFE_componentWillMount!="function"&&typeof U.componentWillMount!="function"||(typeof U.componentWillMount=="function"&&U.componentWillMount(),typeof U.UNSAFE_componentWillMount=="function"&&U.UNSAFE_componentWillMount()),typeof U.componentDidMount=="function"&&(p.flags|=4194308)):(typeof U.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=E,p.memoizedState=ne),U.props=E,U.state=ne,U.context=Se,E=Q):(typeof U.componentDidMount=="function"&&(p.flags|=4194308),E=!1)}else{U=p.stateNode,T2(u,p),Q=p.memoizedProps,Se=p.type===p.elementType?Q:xs(p.type,Q),U.props=Se,Ue=p.pendingProps,je=U.context,ne=S.contextType,typeof ne=="object"&&ne!==null?ne=Xo(ne):(ne=Ji(S)?Tl:fi.current,ne=Fu(p,ne));var at=S.getDerivedStateFromProps;(De=typeof at=="function"||typeof U.getSnapshotBeforeUpdate=="function")||typeof U.UNSAFE_componentWillReceiveProps!="function"&&typeof U.componentWillReceiveProps!="function"||(Q!==Ue||je!==ne)&&tk(p,U,E,ne),Tc=!1,je=p.memoizedState,U.state=je,Wp(p,E,U,R);var gt=p.memoizedState;Q!==Ue||je!==gt||Qi.current||Tc?(typeof at=="function"&&(lx(p,S,at,E),gt=p.memoizedState),(Se=Tc||J2(p,S,Se,E,je,gt,ne)||!1)?(De||typeof U.UNSAFE_componentWillUpdate!="function"&&typeof U.componentWillUpdate!="function"||(typeof U.componentWillUpdate=="function"&&U.componentWillUpdate(E,gt,ne),typeof U.UNSAFE_componentWillUpdate=="function"&&U.UNSAFE_componentWillUpdate(E,gt,ne)),typeof U.componentDidUpdate=="function"&&(p.flags|=4),typeof U.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof U.componentDidUpdate!="function"||Q===u.memoizedProps&&je===u.memoizedState||(p.flags|=4),typeof U.getSnapshotBeforeUpdate!="function"||Q===u.memoizedProps&&je===u.memoizedState||(p.flags|=1024),p.memoizedProps=E,p.memoizedState=gt),U.props=E,U.state=gt,U.context=ne,E=Se):(typeof U.componentDidUpdate!="function"||Q===u.memoizedProps&&je===u.memoizedState||(p.flags|=4),typeof U.getSnapshotBeforeUpdate!="function"||Q===u.memoizedProps&&je===u.memoizedState||(p.flags|=1024),E=!1)}return px(u,p,S,E,M,R)}function px(u,p,S,E,R,M){dk(u,p);var U=(p.flags&128)!==0;if(!E&&!U)return R&&m2(p,S,!1),Ua(u,p,M);E=p.stateNode,Npe.current=p;var Q=U&&typeof S.getDerivedStateFromError!="function"?null:E.render();return p.flags|=1,u!==null&&U?(p.child=Bu(p,u.child,null,M),p.child=Bu(p,null,Q,M)):Fi(u,p,Q,M),p.memoizedState=E.state,R&&m2(p,S,!0),p.child}function hk(u){var p=u.stateNode;p.pendingContext?g2(u,p.pendingContext,p.pendingContext!==p.context):p.context&&g2(u,p.context,!1),ZS(u,p.containerInfo)}function pk(u,p,S,E,R){return qu(),HS(R),p.flags|=256,Fi(u,p,S,E),p.child}var gx={dehydrated:null,treeContext:null,retryLane:0};function vx(u){return{baseLanes:u,cachePool:null,transitions:null}}function gk(u,p,S){var E=p.pendingProps,R=tn.current,M=!1,U=(p.flags&128)!==0,Q;if((Q=U)||(Q=u!==null&&u.memoizedState===null?!1:(R&2)!==0),Q?(M=!0,p.flags&=-129):(u===null||u.memoizedState!==null)&&(R|=1),Lr(tn,R&1),u===null)return zS(p),u=p.memoizedState,u!==null&&(u=u.dehydrated,u!==null)?((p.mode&1)===0?p.lanes=1:u.data==="$!"?p.lanes=8:p.lanes=1073741824,null):(U=E.children,u=E.fallback,M?(E=p.mode,M=p.child,U={mode:"hidden",children:U},(E&1)===0&&M!==null?(M.childLanes=0,M.pendingProps=U):M=fg(U,E,0,null),u=Nl(u,E,S,null),M.return=p,u.return=p,M.sibling=u,p.child=M,p.child.memoizedState=vx(S),p.memoizedState=gx,u):mx(p,U));if(R=u.memoizedState,R!==null&&(Q=R.dehydrated,Q!==null))return $pe(u,p,U,E,Q,R,S);if(M){M=E.fallback,U=p.mode,R=u.child,Q=R.sibling;var ne={mode:"hidden",children:E.children};return(U&1)===0&&p.child!==R?(E=p.child,E.childLanes=0,E.pendingProps=ne,p.deletions=null):(E=Dc(R,ne),E.subtreeFlags=R.subtreeFlags&14680064),Q!==null?M=Dc(Q,M):(M=Nl(M,U,S,null),M.flags|=2),M.return=p,E.return=p,E.sibling=M,p.child=E,E=M,M=p.child,U=u.child.memoizedState,U=U===null?vx(S):{baseLanes:U.baseLanes|S,cachePool:null,transitions:U.transitions},M.memoizedState=U,M.childLanes=u.childLanes&~S,p.memoizedState=gx,E}return M=u.child,u=M.sibling,E=Dc(M,{mode:"visible",children:E.children}),(p.mode&1)===0&&(E.lanes=S),E.return=p,E.sibling=null,u!==null&&(S=p.deletions,S===null?(p.deletions=[u],p.flags|=16):S.push(u)),p.child=E,p.memoizedState=null,E}function mx(u,p){return p=fg({mode:"visible",children:p},u.mode,0,null),p.return=u,u.child=p}function Jp(u,p,S,E){return E!==null&&HS(E),Bu(p,u.child,null,S),u=mx(p,p.pendingProps.children),u.flags|=2,p.memoizedState=null,u}function $pe(u,p,S,E,R,M,U){if(S)return p.flags&256?(p.flags&=-257,E=dx(Error(t(422))),Jp(u,p,U,E)):p.memoizedState!==null?(p.child=u.child,p.flags|=128,null):(M=E.fallback,R=p.mode,E=fg({mode:"visible",children:E.children},R,0,null),M=Nl(M,R,U,null),M.flags|=2,E.return=p,M.return=p,E.sibling=M,p.child=E,(p.mode&1)!==0&&Bu(p,u.child,null,U),p.child.memoizedState=vx(U),p.memoizedState=gx,M);if((p.mode&1)===0)return Jp(u,p,U,null);if(R.data==="$!"){if(E=R.nextSibling&&R.nextSibling.dataset,E)var Q=E.dgst;return E=Q,M=Error(t(419)),E=dx(M,E,void 0),Jp(u,p,U,E)}if(Q=(U&u.childLanes)!==0,eo||Q){if(E=Bn,E!==null){switch(U&-U){case 4:R=2;break;case 16:R=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:R=32;break;case 536870912:R=268435456;break;default:R=0}R=(R&(E.suspendedLanes|U))!==0?0:R,R!==0&&R!==M.retryLane&&(M.retryLane=R,qa(u,R),bs(E,u,R,-1))}return Mx(),E=dx(Error(t(421))),Jp(u,p,U,E)}return R.data==="$?"?(p.flags|=128,p.child=u.child,p=Qpe.bind(null,u),R._reactRetry=p,null):(u=M.treeContext,Eo=Ec(R.nextSibling),bo=p,Xr=!0,Ss=null,u!==null&&(Vo[Yo++]=Na,Vo[Yo++]=$a,Vo[Yo++]=Al,Na=u.id,$a=u.overflow,Al=p),p=mx(p,E.children),p.flags|=4096,p)}function vk(u,p,S){u.lanes|=p;var E=u.alternate;E!==null&&(E.lanes|=p),VS(u.return,p,S)}function yx(u,p,S,E,R){var M=u.memoizedState;M===null?u.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:E,tail:S,tailMode:R}:(M.isBackwards=p,M.rendering=null,M.renderingStartTime=0,M.last=E,M.tail=S,M.tailMode=R)}function mk(u,p,S){var E=p.pendingProps,R=E.revealOrder,M=E.tail;if(Fi(u,p,E.children,S),E=tn.current,(E&2)!==0)E=E&1|2,p.flags|=128;else{if(u!==null&&(u.flags&128)!==0)e:for(u=p.child;u!==null;){if(u.tag===13)u.memoizedState!==null&&vk(u,S,p);else if(u.tag===19)vk(u,S,p);else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===p)break e;for(;u.sibling===null;){if(u.return===null||u.return===p)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}E&=1}if(Lr(tn,E),(p.mode&1)===0)p.memoizedState=null;else switch(R){case"forwards":for(S=p.child,R=null;S!==null;)u=S.alternate,u!==null&&Kp(u)===null&&(R=S),S=S.sibling;S=R,S===null?(R=p.child,p.child=null):(R=S.sibling,S.sibling=null),yx(p,!1,R,S,M);break;case"backwards":for(S=null,R=p.child,p.child=null;R!==null;){if(u=R.alternate,u!==null&&Kp(u)===null){p.child=R;break}u=R.sibling,R.sibling=S,S=R,R=u}yx(p,!0,S,null,M);break;case"together":yx(p,!1,null,null,void 0);break;default:p.memoizedState=null}return p.child}function eg(u,p){(p.mode&1)===0&&u!==null&&(u.alternate=null,p.alternate=null,p.flags|=2)}function Ua(u,p,S){if(u!==null&&(p.dependencies=u.dependencies),jl|=p.lanes,(S&p.childLanes)===0)return null;if(u!==null&&p.child!==u.child)throw Error(t(153));if(p.child!==null){for(u=p.child,S=Dc(u,u.pendingProps),p.child=S,S.return=p;u.sibling!==null;)u=u.sibling,S=S.sibling=Dc(u,u.pendingProps),S.return=p;S.sibling=null}return p.child}function qpe(u,p,S){switch(p.tag){case 3:hk(p),qu();break;case 5:k2(p);break;case 1:Ji(p.type)&&Lp(p);break;case 4:ZS(p,p.stateNode.containerInfo);break;case 10:var E=p.type._context,R=p.memoizedProps.value;Lr(Up,E._currentValue),E._currentValue=R;break;case 13:if(E=p.memoizedState,E!==null)return E.dehydrated!==null?(Lr(tn,tn.current&1),p.flags|=128,null):(S&p.child.childLanes)!==0?gk(u,p,S):(Lr(tn,tn.current&1),u=Ua(u,p,S),u!==null?u.sibling:null);Lr(tn,tn.current&1);break;case 19:if(E=(S&p.childLanes)!==0,(u.flags&128)!==0){if(E)return mk(u,p,S);p.flags|=128}if(R=p.memoizedState,R!==null&&(R.rendering=null,R.tail=null,R.lastEffect=null),Lr(tn,tn.current),E)break;return null;case 22:case 23:return p.lanes=0,uk(u,p,S)}return Ua(u,p,S)}var yk,Sx,Sk,xk;yk=function(u,p){for(var S=p.child;S!==null;){if(S.tag===5||S.tag===6)u.appendChild(S.stateNode);else if(S.tag!==4&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===p)break;for(;S.sibling===null;){if(S.return===null||S.return===p)return;S=S.return}S.sibling.return=S.return,S=S.sibling}},Sx=function(){},Sk=function(u,p,S,E){var R=u.memoizedProps;if(R!==E){u=p.stateNode,Ol(Js.current);var M=null;switch(S){case"input":R=mt(u,R),E=mt(u,E),M=[];break;case"select":R=J({},R,{value:void 0}),E=J({},E,{value:void 0}),M=[];break;case"textarea":R=ze(u,R),E=ze(u,E),M=[];break;default:typeof R.onClick!="function"&&typeof E.onClick=="function"&&(u.onclick=Mp)}dt(S,E);var U;S=null;for(Se in R)if(!E.hasOwnProperty(Se)&&R.hasOwnProperty(Se)&&R[Se]!=null)if(Se==="style"){var Q=R[Se];for(U in Q)Q.hasOwnProperty(U)&&(S||(S={}),S[U]="")}else Se!=="dangerouslySetInnerHTML"&&Se!=="children"&&Se!=="suppressContentEditableWarning"&&Se!=="suppressHydrationWarning"&&Se!=="autoFocus"&&(i.hasOwnProperty(Se)?M||(M=[]):(M=M||[]).push(Se,null));for(Se in E){var ne=E[Se];if(Q=R!=null?R[Se]:void 0,E.hasOwnProperty(Se)&&ne!==Q&&(ne!=null||Q!=null))if(Se==="style")if(Q){for(U in Q)!Q.hasOwnProperty(U)||ne&&ne.hasOwnProperty(U)||(S||(S={}),S[U]="");for(U in ne)ne.hasOwnProperty(U)&&Q[U]!==ne[U]&&(S||(S={}),S[U]=ne[U])}else S||(M||(M=[]),M.push(Se,S)),S=ne;else Se==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,Q=Q?Q.__html:void 0,ne!=null&&Q!==ne&&(M=M||[]).push(Se,ne)):Se==="children"?typeof ne!="string"&&typeof ne!="number"||(M=M||[]).push(Se,""+ne):Se!=="suppressContentEditableWarning"&&Se!=="suppressHydrationWarning"&&(i.hasOwnProperty(Se)?(ne!=null&&Se==="onScroll"&&zr("scroll",u),M||Q===ne||(M=[])):(M=M||[]).push(Se,ne))}S&&(M=M||[]).push("style",S);var Se=M;(p.updateQueue=Se)&&(p.flags|=4)}},xk=function(u,p,S,E){S!==E&&(p.flags|=4)};function Tf(u,p){if(!Xr)switch(u.tailMode){case"hidden":p=u.tail;for(var S=null;p!==null;)p.alternate!==null&&(S=p),p=p.sibling;S===null?u.tail=null:S.sibling=null;break;case"collapsed":S=u.tail;for(var E=null;S!==null;)S.alternate!==null&&(E=S),S=S.sibling;E===null?p||u.tail===null?u.tail=null:u.tail.sibling=null:E.sibling=null}}function pi(u){var p=u.alternate!==null&&u.alternate.child===u.child,S=0,E=0;if(p)for(var R=u.child;R!==null;)S|=R.lanes|R.childLanes,E|=R.subtreeFlags&14680064,E|=R.flags&14680064,R.return=u,R=R.sibling;else for(R=u.child;R!==null;)S|=R.lanes|R.childLanes,E|=R.subtreeFlags,E|=R.flags,R.return=u,R=R.sibling;return u.subtreeFlags|=E,u.childLanes=S,p}function Bpe(u,p,S){var E=p.pendingProps;switch(BS(p),p.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return pi(p),null;case 1:return Ji(p.type)&&Dp(),pi(p),null;case 3:return E=p.stateNode,Hu(),Hr(Qi),Hr(fi),ex(),E.pendingContext&&(E.context=E.pendingContext,E.pendingContext=null),(u===null||u.child===null)&&(qp(p)?p.flags|=4:u===null||u.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,Ss!==null&&(Rx(Ss),Ss=null))),Sx(u,p),pi(p),null;case 5:QS(p);var R=Ol(bf.current);if(S=p.type,u!==null&&p.stateNode!=null)Sk(u,p,S,E,R),u.ref!==p.ref&&(p.flags|=512,p.flags|=2097152);else{if(!E){if(p.stateNode===null)throw Error(t(166));return pi(p),null}if(u=Ol(Js.current),qp(p)){E=p.stateNode,S=p.type;var M=p.memoizedProps;switch(E[Qs]=p,E[yf]=M,u=(p.mode&1)!==0,S){case"dialog":zr("cancel",E),zr("close",E);break;case"iframe":case"object":case"embed":zr("load",E);break;case"video":case"audio":for(R=0;R<gf.length;R++)zr(gf[R],E);break;case"source":zr("error",E);break;case"img":case"image":case"link":zr("error",E),zr("load",E);break;case"details":zr("toggle",E);break;case"input":St(E,M),zr("invalid",E);break;case"select":E._wrapperState={wasMultiple:!!M.multiple},zr("invalid",E);break;case"textarea":be(E,M),zr("invalid",E)}dt(S,M),R=null;for(var U in M)if(M.hasOwnProperty(U)){var Q=M[U];U==="children"?typeof Q=="string"?E.textContent!==Q&&(M.suppressHydrationWarning!==!0&&Op(E.textContent,Q,u),R=["children",Q]):typeof Q=="number"&&E.textContent!==""+Q&&(M.suppressHydrationWarning!==!0&&Op(E.textContent,Q,u),R=["children",""+Q]):i.hasOwnProperty(U)&&Q!=null&&U==="onScroll"&&zr("scroll",E)}switch(S){case"input":Le(E),At(E,M,!0);break;case"textarea":Le(E),st(E);break;case"select":case"option":break;default:typeof M.onClick=="function"&&(E.onclick=Mp)}E=R,p.updateQueue=E,E!==null&&(p.flags|=4)}else{U=R.nodeType===9?R:R.ownerDocument,u==="http://www.w3.org/1999/xhtml"&&(u=Je(S)),u==="http://www.w3.org/1999/xhtml"?S==="script"?(u=U.createElement("div"),u.innerHTML="<script><\/script>",u=u.removeChild(u.firstChild)):typeof E.is=="string"?u=U.createElement(S,{is:E.is}):(u=U.createElement(S),S==="select"&&(U=u,E.multiple?U.multiple=!0:E.size&&(U.size=E.size))):u=U.createElementNS(u,S),u[Qs]=p,u[yf]=E,yk(u,p,!1,!1),p.stateNode=u;e:{switch(U=$t(S,E),S){case"dialog":zr("cancel",u),zr("close",u),R=E;break;case"iframe":case"object":case"embed":zr("load",u),R=E;break;case"video":case"audio":for(R=0;R<gf.length;R++)zr(gf[R],u);R=E;break;case"source":zr("error",u),R=E;break;case"img":case"image":case"link":zr("error",u),zr("load",u),R=E;break;case"details":zr("toggle",u),R=E;break;case"input":St(u,E),R=mt(u,E),zr("invalid",u);break;case"option":R=E;break;case"select":u._wrapperState={wasMultiple:!!E.multiple},R=J({},E,{value:void 0}),zr("invalid",u);break;case"textarea":be(u,E),R=ze(u,E),zr("invalid",u);break;default:R=E}dt(S,R),Q=R;for(M in Q)if(Q.hasOwnProperty(M)){var ne=Q[M];M==="style"?Oe(u,ne):M==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,ne!=null&&Sr(u,ne)):M==="children"?typeof ne=="string"?(S!=="textarea"||ne!=="")&&Y(u,ne):typeof ne=="number"&&Y(u,""+ne):M!=="suppressContentEditableWarning"&&M!=="suppressHydrationWarning"&&M!=="autoFocus"&&(i.hasOwnProperty(M)?ne!=null&&M==="onScroll"&&zr("scroll",u):ne!=null&&I(u,M,ne,U))}switch(S){case"input":Le(u),At(u,E,!1);break;case"textarea":Le(u),st(u);break;case"option":E.value!=null&&u.setAttribute("value",""+se(E.value));break;case"select":u.multiple=!!E.multiple,M=E.value,M!=null?Ae(u,!!E.multiple,M,!1):E.defaultValue!=null&&Ae(u,!!E.multiple,E.defaultValue,!0);break;default:typeof R.onClick=="function"&&(u.onclick=Mp)}switch(S){case"button":case"input":case"select":case"textarea":E=!!E.autoFocus;break e;case"img":E=!0;break e;default:E=!1}}E&&(p.flags|=4)}p.ref!==null&&(p.flags|=512,p.flags|=2097152)}return pi(p),null;case 6:if(u&&p.stateNode!=null)xk(u,p,u.memoizedProps,E);else{if(typeof E!="string"&&p.stateNode===null)throw Error(t(166));if(S=Ol(bf.current),Ol(Js.current),qp(p)){if(E=p.stateNode,S=p.memoizedProps,E[Qs]=p,(M=E.nodeValue!==S)&&(u=bo,u!==null))switch(u.tag){case 3:Op(E.nodeValue,S,(u.mode&1)!==0);break;case 5:u.memoizedProps.suppressHydrationWarning!==!0&&Op(E.nodeValue,S,(u.mode&1)!==0)}M&&(p.flags|=4)}else E=(S.nodeType===9?S:S.ownerDocument).createTextNode(E),E[Qs]=p,p.stateNode=E}return pi(p),null;case 13:if(Hr(tn),E=p.memoizedState,u===null||u.memoizedState!==null&&u.memoizedState.dehydrated!==null){if(Xr&&Eo!==null&&(p.mode&1)!==0&&(p.flags&128)===0)b2(),qu(),p.flags|=98560,M=!1;else if(M=qp(p),E!==null&&E.dehydrated!==null){if(u===null){if(!M)throw Error(t(318));if(M=p.memoizedState,M=M!==null?M.dehydrated:null,!M)throw Error(t(317));M[Qs]=p}else qu(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;pi(p),M=!1}else Ss!==null&&(Rx(Ss),Ss=null),M=!0;if(!M)return p.flags&65536?p:null}return(p.flags&128)!==0?(p.lanes=S,p):(E=E!==null,E!==(u!==null&&u.memoizedState!==null)&&E&&(p.child.flags|=8192,(p.mode&1)!==0&&(u===null||(tn.current&1)!==0?On===0&&(On=3):Mx())),p.updateQueue!==null&&(p.flags|=4),pi(p),null);case 4:return Hu(),Sx(u,p),u===null&&vf(p.stateNode.containerInfo),pi(p),null;case 10:return GS(p.type._context),pi(p),null;case 17:return Ji(p.type)&&Dp(),pi(p),null;case 19:if(Hr(tn),M=p.memoizedState,M===null)return pi(p),null;if(E=(p.flags&128)!==0,U=M.rendering,U===null)if(E)Tf(M,!1);else{if(On!==0||u!==null&&(u.flags&128)!==0)for(u=p.child;u!==null;){if(U=Kp(u),U!==null){for(p.flags|=128,Tf(M,!1),E=U.updateQueue,E!==null&&(p.updateQueue=E,p.flags|=4),p.subtreeFlags=0,E=S,S=p.child;S!==null;)M=S,u=E,M.flags&=14680066,U=M.alternate,U===null?(M.childLanes=0,M.lanes=u,M.child=null,M.subtreeFlags=0,M.memoizedProps=null,M.memoizedState=null,M.updateQueue=null,M.dependencies=null,M.stateNode=null):(M.childLanes=U.childLanes,M.lanes=U.lanes,M.child=U.child,M.subtreeFlags=0,M.deletions=null,M.memoizedProps=U.memoizedProps,M.memoizedState=U.memoizedState,M.updateQueue=U.updateQueue,M.type=U.type,u=U.dependencies,M.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),S=S.sibling;return Lr(tn,tn.current&1|2),p.child}u=u.sibling}M.tail!==null&&Wt()>Vu&&(p.flags|=128,E=!0,Tf(M,!1),p.lanes=4194304)}else{if(!E)if(u=Kp(U),u!==null){if(p.flags|=128,E=!0,S=u.updateQueue,S!==null&&(p.updateQueue=S,p.flags|=4),Tf(M,!0),M.tail===null&&M.tailMode==="hidden"&&!U.alternate&&!Xr)return pi(p),null}else 2*Wt()-M.renderingStartTime>Vu&&S!==1073741824&&(p.flags|=128,E=!0,Tf(M,!1),p.lanes=4194304);M.isBackwards?(U.sibling=p.child,p.child=U):(S=M.last,S!==null?S.sibling=U:p.child=U,M.last=U)}return M.tail!==null?(p=M.tail,M.rendering=p,M.tail=p.sibling,M.renderingStartTime=Wt(),p.sibling=null,S=tn.current,Lr(tn,E?S&1|2:S&1),p):(pi(p),null);case 22:case 23:return Ox(),E=p.memoizedState!==null,u!==null&&u.memoizedState!==null!==E&&(p.flags|=8192),E&&(p.mode&1)!==0?(Io&1073741824)!==0&&(pi(p),p.subtreeFlags&6&&(p.flags|=8192)):pi(p),null;case 24:return null;case 25:return null}throw Error(t(156,p.tag))}function Upe(u,p){switch(BS(p),p.tag){case 1:return Ji(p.type)&&Dp(),u=p.flags,u&65536?(p.flags=u&-65537|128,p):null;case 3:return Hu(),Hr(Qi),Hr(fi),ex(),u=p.flags,(u&65536)!==0&&(u&128)===0?(p.flags=u&-65537|128,p):null;case 5:return QS(p),null;case 13:if(Hr(tn),u=p.memoizedState,u!==null&&u.dehydrated!==null){if(p.alternate===null)throw Error(t(340));qu()}return u=p.flags,u&65536?(p.flags=u&-65537|128,p):null;case 19:return Hr(tn),null;case 4:return Hu(),null;case 10:return GS(p.type._context),null;case 22:case 23:return Ox(),null;case 24:return null;default:return null}}var tg=!1,gi=!1,zpe=typeof WeakSet=="function"?WeakSet:Set,ht=null;function Ku(u,p){var S=u.ref;if(S!==null)if(typeof S=="function")try{S(null)}catch(E){dn(u,p,E)}else S.current=null}function xx(u,p,S){try{S()}catch(E){dn(u,p,E)}}var _k=!1;function Hpe(u,p){if(OS=ae,u=JR(),ES(u)){if("selectionStart"in u)var S={start:u.selectionStart,end:u.selectionEnd};else e:{S=(S=u.ownerDocument)&&S.defaultView||window;var E=S.getSelection&&S.getSelection();if(E&&E.rangeCount!==0){S=E.anchorNode;var R=E.anchorOffset,M=E.focusNode;E=E.focusOffset;try{S.nodeType,M.nodeType}catch{S=null;break e}var U=0,Q=-1,ne=-1,Se=0,De=0,Ue=u,je=null;t:for(;;){for(var at;Ue!==S||R!==0&&Ue.nodeType!==3||(Q=U+R),Ue!==M||E!==0&&Ue.nodeType!==3||(ne=U+E),Ue.nodeType===3&&(U+=Ue.nodeValue.length),(at=Ue.firstChild)!==null;)je=Ue,Ue=at;for(;;){if(Ue===u)break t;if(je===S&&++Se===R&&(Q=U),je===M&&++De===E&&(ne=U),(at=Ue.nextSibling)!==null)break;Ue=je,je=Ue.parentNode}Ue=at}S=Q===-1||ne===-1?null:{start:Q,end:ne}}else S=null}S=S||{start:0,end:0}}else S=null;for(MS={focusedElem:u,selectionRange:S},ae=!1,ht=p;ht!==null;)if(p=ht,u=p.child,(p.subtreeFlags&1028)!==0&&u!==null)u.return=p,ht=u;else for(;ht!==null;){p=ht;try{var gt=p.alternate;if((p.flags&1024)!==0)switch(p.tag){case 0:case 11:case 15:break;case 1:if(gt!==null){var xt=gt.memoizedProps,vn=gt.memoizedState,de=p.stateNode,ie=de.getSnapshotBeforeUpdate(p.elementType===p.type?xt:xs(p.type,xt),vn);de.__reactInternalSnapshotBeforeUpdate=ie}break;case 3:var pe=p.stateNode.containerInfo;pe.nodeType===1?pe.textContent="":pe.nodeType===9&&pe.documentElement&&pe.removeChild(pe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(t(163))}}catch(Ve){dn(p,p.return,Ve)}if(u=p.sibling,u!==null){u.return=p.return,ht=u;break}ht=p.return}return gt=_k,_k=!1,gt}function Af(u,p,S){var E=p.updateQueue;if(E=E!==null?E.lastEffect:null,E!==null){var R=E=E.next;do{if((R.tag&u)===u){var M=R.destroy;R.destroy=void 0,M!==void 0&&xx(p,S,M)}R=R.next}while(R!==E)}}function rg(u,p){if(p=p.updateQueue,p=p!==null?p.lastEffect:null,p!==null){var S=p=p.next;do{if((S.tag&u)===u){var E=S.create;S.destroy=E()}S=S.next}while(S!==p)}}function _x(u){var p=u.ref;if(p!==null){var S=u.stateNode;switch(u.tag){case 5:u=S;break;default:u=S}typeof p=="function"?p(u):p.current=u}}function wk(u){var p=u.alternate;p!==null&&(u.alternate=null,wk(p)),u.child=null,u.deletions=null,u.sibling=null,u.tag===5&&(p=u.stateNode,p!==null&&(delete p[Qs],delete p[yf],delete p[FS],delete p[Ppe],delete p[Cpe])),u.stateNode=null,u.return=null,u.dependencies=null,u.memoizedProps=null,u.memoizedState=null,u.pendingProps=null,u.stateNode=null,u.updateQueue=null}function bk(u){return u.tag===5||u.tag===3||u.tag===4}function Ek(u){e:for(;;){for(;u.sibling===null;){if(u.return===null||bk(u.return))return null;u=u.return}for(u.sibling.return=u.return,u=u.sibling;u.tag!==5&&u.tag!==6&&u.tag!==18;){if(u.flags&2||u.child===null||u.tag===4)continue e;u.child.return=u,u=u.child}if(!(u.flags&2))return u.stateNode}}function wx(u,p,S){var E=u.tag;if(E===5||E===6)u=u.stateNode,p?S.nodeType===8?S.parentNode.insertBefore(u,p):S.insertBefore(u,p):(S.nodeType===8?(p=S.parentNode,p.insertBefore(u,S)):(p=S,p.appendChild(u)),S=S._reactRootContainer,S!=null||p.onclick!==null||(p.onclick=Mp));else if(E!==4&&(u=u.child,u!==null))for(wx(u,p,S),u=u.sibling;u!==null;)wx(u,p,S),u=u.sibling}function bx(u,p,S){var E=u.tag;if(E===5||E===6)u=u.stateNode,p?S.insertBefore(u,p):S.appendChild(u);else if(E!==4&&(u=u.child,u!==null))for(bx(u,p,S),u=u.sibling;u!==null;)bx(u,p,S),u=u.sibling}var Gn=null,_s=!1;function Rc(u,p,S){for(S=S.child;S!==null;)Ik(u,p,S),S=S.sibling}function Ik(u,p,S){if(Di&&typeof Di.onCommitFiberUnmount=="function")try{Di.onCommitFiberUnmount(ja,S)}catch{}switch(S.tag){case 5:gi||Ku(S,p);case 6:var E=Gn,R=_s;Gn=null,Rc(u,p,S),Gn=E,_s=R,Gn!==null&&(_s?(u=Gn,S=S.stateNode,u.nodeType===8?u.parentNode.removeChild(S):u.removeChild(S)):Gn.removeChild(S.stateNode));break;case 18:Gn!==null&&(_s?(u=Gn,S=S.stateNode,u.nodeType===8?LS(u.parentNode,S):u.nodeType===1&&LS(u,S),Pl(u)):LS(Gn,S.stateNode));break;case 4:E=Gn,R=_s,Gn=S.stateNode.containerInfo,_s=!0,Rc(u,p,S),Gn=E,_s=R;break;case 0:case 11:case 14:case 15:if(!gi&&(E=S.updateQueue,E!==null&&(E=E.lastEffect,E!==null))){R=E=E.next;do{var M=R,U=M.destroy;M=M.tag,U!==void 0&&((M&2)!==0||(M&4)!==0)&&xx(S,p,U),R=R.next}while(R!==E)}Rc(u,p,S);break;case 1:if(!gi&&(Ku(S,p),E=S.stateNode,typeof E.componentWillUnmount=="function"))try{E.props=S.memoizedProps,E.state=S.memoizedState,E.componentWillUnmount()}catch(Q){dn(S,p,Q)}Rc(u,p,S);break;case 21:Rc(u,p,S);break;case 22:S.mode&1?(gi=(E=gi)||S.memoizedState!==null,Rc(u,p,S),gi=E):Rc(u,p,S);break;default:Rc(u,p,S)}}function Pk(u){var p=u.updateQueue;if(p!==null){u.updateQueue=null;var S=u.stateNode;S===null&&(S=u.stateNode=new zpe),p.forEach(function(E){var R=Jpe.bind(null,u,E);S.has(E)||(S.add(E),E.then(R,R))})}}function ws(u,p){var S=p.deletions;if(S!==null)for(var E=0;E<S.length;E++){var R=S[E];try{var M=u,U=p,Q=U;e:for(;Q!==null;){switch(Q.tag){case 5:Gn=Q.stateNode,_s=!1;break e;case 3:Gn=Q.stateNode.containerInfo,_s=!0;break e;case 4:Gn=Q.stateNode.containerInfo,_s=!0;break e}Q=Q.return}if(Gn===null)throw Error(t(160));Ik(M,U,R),Gn=null,_s=!1;var ne=R.alternate;ne!==null&&(ne.return=null),R.return=null}catch(Se){dn(R,p,Se)}}if(p.subtreeFlags&12854)for(p=p.child;p!==null;)Ck(p,u),p=p.sibling}function Ck(u,p){var S=u.alternate,E=u.flags;switch(u.tag){case 0:case 11:case 14:case 15:if(ws(p,u),ta(u),E&4){try{Af(3,u,u.return),rg(3,u)}catch(xt){dn(u,u.return,xt)}try{Af(5,u,u.return)}catch(xt){dn(u,u.return,xt)}}break;case 1:ws(p,u),ta(u),E&512&&S!==null&&Ku(S,S.return);break;case 5:if(ws(p,u),ta(u),E&512&&S!==null&&Ku(S,S.return),u.flags&32){var R=u.stateNode;try{Y(R,"")}catch(xt){dn(u,u.return,xt)}}if(E&4&&(R=u.stateNode,R!=null)){var M=u.memoizedProps,U=S!==null?S.memoizedProps:M,Q=u.type,ne=u.updateQueue;if(u.updateQueue=null,ne!==null)try{Q==="input"&&M.type==="radio"&&M.name!=null&&et(R,M),$t(Q,U);var Se=$t(Q,M);for(U=0;U<ne.length;U+=2){var De=ne[U],Ue=ne[U+1];De==="style"?Oe(R,Ue):De==="dangerouslySetInnerHTML"?Sr(R,Ue):De==="children"?Y(R,Ue):I(R,De,Ue,Se)}switch(Q){case"input":ct(R,M);break;case"textarea":it(R,M);break;case"select":var je=R._wrapperState.wasMultiple;R._wrapperState.wasMultiple=!!M.multiple;var at=M.value;at!=null?Ae(R,!!M.multiple,at,!1):je!==!!M.multiple&&(M.defaultValue!=null?Ae(R,!!M.multiple,M.defaultValue,!0):Ae(R,!!M.multiple,M.multiple?[]:"",!1))}R[yf]=M}catch(xt){dn(u,u.return,xt)}}break;case 6:if(ws(p,u),ta(u),E&4){if(u.stateNode===null)throw Error(t(162));R=u.stateNode,M=u.memoizedProps;try{R.nodeValue=M}catch(xt){dn(u,u.return,xt)}}break;case 3:if(ws(p,u),ta(u),E&4&&S!==null&&S.memoizedState.isDehydrated)try{Pl(p.containerInfo)}catch(xt){dn(u,u.return,xt)}break;case 4:ws(p,u),ta(u);break;case 13:ws(p,u),ta(u),R=u.child,R.flags&8192&&(M=R.memoizedState!==null,R.stateNode.isHidden=M,!M||R.alternate!==null&&R.alternate.memoizedState!==null||(Px=Wt())),E&4&&Pk(u);break;case 22:if(De=S!==null&&S.memoizedState!==null,u.mode&1?(gi=(Se=gi)||De,ws(p,u),gi=Se):ws(p,u),ta(u),E&8192){if(Se=u.memoizedState!==null,(u.stateNode.isHidden=Se)&&!De&&(u.mode&1)!==0)for(ht=u,De=u.child;De!==null;){for(Ue=ht=De;ht!==null;){switch(je=ht,at=je.child,je.tag){case 0:case 11:case 14:case 15:Af(4,je,je.return);break;case 1:Ku(je,je.return);var gt=je.stateNode;if(typeof gt.componentWillUnmount=="function"){E=je,S=je.return;try{p=E,gt.props=p.memoizedProps,gt.state=p.memoizedState,gt.componentWillUnmount()}catch(xt){dn(E,S,xt)}}break;case 5:Ku(je,je.return);break;case 22:if(je.memoizedState!==null){Rk(Ue);continue}}at!==null?(at.return=je,ht=at):Rk(Ue)}De=De.sibling}e:for(De=null,Ue=u;;){if(Ue.tag===5){if(De===null){De=Ue;try{R=Ue.stateNode,Se?(M=R.style,typeof M.setProperty=="function"?M.setProperty("display","none","important"):M.display="none"):(Q=Ue.stateNode,ne=Ue.memoizedProps.style,U=ne!=null&&ne.hasOwnProperty("display")?ne.display:null,Q.style.display=we("display",U))}catch(xt){dn(u,u.return,xt)}}}else if(Ue.tag===6){if(De===null)try{Ue.stateNode.nodeValue=Se?"":Ue.memoizedProps}catch(xt){dn(u,u.return,xt)}}else if((Ue.tag!==22&&Ue.tag!==23||Ue.memoizedState===null||Ue===u)&&Ue.child!==null){Ue.child.return=Ue,Ue=Ue.child;continue}if(Ue===u)break e;for(;Ue.sibling===null;){if(Ue.return===null||Ue.return===u)break e;De===Ue&&(De=null),Ue=Ue.return}De===Ue&&(De=null),Ue.sibling.return=Ue.return,Ue=Ue.sibling}}break;case 19:ws(p,u),ta(u),E&4&&Pk(u);break;case 21:break;default:ws(p,u),ta(u)}}function ta(u){var p=u.flags;if(p&2){try{e:{for(var S=u.return;S!==null;){if(bk(S)){var E=S;break e}S=S.return}throw Error(t(160))}switch(E.tag){case 5:var R=E.stateNode;E.flags&32&&(Y(R,""),E.flags&=-33);var M=Ek(u);bx(u,M,R);break;case 3:case 4:var U=E.stateNode.containerInfo,Q=Ek(u);wx(u,Q,U);break;default:throw Error(t(161))}}catch(ne){dn(u,u.return,ne)}u.flags&=-3}p&4096&&(u.flags&=-4097)}function Wpe(u,p,S){ht=u,Tk(u)}function Tk(u,p,S){for(var E=(u.mode&1)!==0;ht!==null;){var R=ht,M=R.child;if(R.tag===22&&E){var U=R.memoizedState!==null||tg;if(!U){var Q=R.alternate,ne=Q!==null&&Q.memoizedState!==null||gi;Q=tg;var Se=gi;if(tg=U,(gi=ne)&&!Se)for(ht=R;ht!==null;)U=ht,ne=U.child,U.tag===22&&U.memoizedState!==null?kk(R):ne!==null?(ne.return=U,ht=ne):kk(R);for(;M!==null;)ht=M,Tk(M),M=M.sibling;ht=R,tg=Q,gi=Se}Ak(u)}else(R.subtreeFlags&8772)!==0&&M!==null?(M.return=R,ht=M):Ak(u)}}function Ak(u){for(;ht!==null;){var p=ht;if((p.flags&8772)!==0){var S=p.alternate;try{if((p.flags&8772)!==0)switch(p.tag){case 0:case 11:case 15:gi||rg(5,p);break;case 1:var E=p.stateNode;if(p.flags&4&&!gi)if(S===null)E.componentDidMount();else{var R=p.elementType===p.type?S.memoizedProps:xs(p.type,S.memoizedProps);E.componentDidUpdate(R,S.memoizedState,E.__reactInternalSnapshotBeforeUpdate)}var M=p.updateQueue;M!==null&&R2(p,M,E);break;case 3:var U=p.updateQueue;if(U!==null){if(S=null,p.child!==null)switch(p.child.tag){case 5:S=p.child.stateNode;break;case 1:S=p.child.stateNode}R2(p,U,S)}break;case 5:var Q=p.stateNode;if(S===null&&p.flags&4){S=Q;var ne=p.memoizedProps;switch(p.type){case"button":case"input":case"select":case"textarea":ne.autoFocus&&S.focus();break;case"img":ne.src&&(S.src=ne.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(p.memoizedState===null){var Se=p.alternate;if(Se!==null){var De=Se.memoizedState;if(De!==null){var Ue=De.dehydrated;Ue!==null&&Pl(Ue)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(t(163))}gi||p.flags&512&&_x(p)}catch(je){dn(p,p.return,je)}}if(p===u){ht=null;break}if(S=p.sibling,S!==null){S.return=p.return,ht=S;break}ht=p.return}}function Rk(u){for(;ht!==null;){var p=ht;if(p===u){ht=null;break}var S=p.sibling;if(S!==null){S.return=p.return,ht=S;break}ht=p.return}}function kk(u){for(;ht!==null;){var p=ht;try{switch(p.tag){case 0:case 11:case 15:var S=p.return;try{rg(4,p)}catch(ne){dn(p,S,ne)}break;case 1:var E=p.stateNode;if(typeof E.componentDidMount=="function"){var R=p.return;try{E.componentDidMount()}catch(ne){dn(p,R,ne)}}var M=p.return;try{_x(p)}catch(ne){dn(p,M,ne)}break;case 5:var U=p.return;try{_x(p)}catch(ne){dn(p,U,ne)}}}catch(ne){dn(p,p.return,ne)}if(p===u){ht=null;break}var Q=p.sibling;if(Q!==null){Q.return=p.return,ht=Q;break}ht=p.return}}var Kpe=Math.ceil,ng=b.ReactCurrentDispatcher,Ex=b.ReactCurrentOwner,Qo=b.ReactCurrentBatchConfig,gr=0,Bn=null,Cn=null,Vn=0,Io=0,Gu=Ic(0),On=0,Rf=null,jl=0,ig=0,Ix=0,kf=null,to=null,Px=0,Vu=1/0,za=null,og=!1,Cx=null,kc=null,sg=!1,Oc=null,ag=0,Of=0,Tx=null,cg=-1,lg=0;function Ni(){return(gr&6)!==0?Wt():cg!==-1?cg:cg=Wt()}function Mc(u){return(u.mode&1)===0?1:(gr&2)!==0&&Vn!==0?Vn&-Vn:Ape.transition!==null?(lg===0&&(lg=xp()),lg):(u=fr,u!==0||(u=window.event,u=u===void 0?16:pn(u.type)),u)}function bs(u,p,S,E){if(50<Of)throw Of=0,Tx=null,Error(t(185));bl(u,S,E),((gr&2)===0||u!==Bn)&&(u===Bn&&((gr&2)===0&&(ig|=S),On===4&&jc(u,Vn)),ro(u,E),S===1&&gr===0&&(p.mode&1)===0&&(Vu=Wt()+500,Fp&&Cc()))}function ro(u,p){var S=u.callbackNode;gS(u,p);var E=wl(u,u===Bn?Vn:0);if(E===0)S!==null&&Pt(S),u.callbackNode=null,u.callbackPriority=0;else if(p=E&-E,u.callbackPriority!==p){if(S!=null&&Pt(S),p===1)u.tag===0?Tpe(Mk.bind(null,u)):y2(Mk.bind(null,u)),Epe(function(){(gr&6)===0&&Cc()}),S=null;else{switch(Da(E)){case 1:S=Nn;break;case 4:S=Me;break;case 16:S=Ur;break;case 536870912:S=ji;break;default:S=Ur}S=Bk(S,Ok.bind(null,u))}u.callbackPriority=p,u.callbackNode=S}}function Ok(u,p){if(cg=-1,lg=0,(gr&6)!==0)throw Error(t(327));var S=u.callbackNode;if(Yu()&&u.callbackNode!==S)return null;var E=wl(u,u===Bn?Vn:0);if(E===0)return null;if((E&30)!==0||(E&u.expiredLanes)!==0||p)p=ug(u,E);else{p=E;var R=gr;gr|=2;var M=Dk();(Bn!==u||Vn!==p)&&(za=null,Vu=Wt()+500,Ll(u,p));do try{Ype();break}catch(Q){jk(u,Q)}while(!0);KS(),ng.current=M,gr=R,Cn!==null?p=0:(Bn=null,Vn=0,p=On)}if(p!==0){if(p===2&&(R=rf(u),R!==0&&(E=R,p=Ax(u,R))),p===1)throw S=Rf,Ll(u,0),jc(u,E),ro(u,Wt()),S;if(p===6)jc(u,E);else{if(R=u.current.alternate,(E&30)===0&&!Gpe(R)&&(p=ug(u,E),p===2&&(M=rf(u),M!==0&&(E=M,p=Ax(u,M))),p===1))throw S=Rf,Ll(u,0),jc(u,E),ro(u,Wt()),S;switch(u.finishedWork=R,u.finishedLanes=E,p){case 0:case 1:throw Error(t(345));case 2:Fl(u,to,za);break;case 3:if(jc(u,E),(E&130023424)===E&&(p=Px+500-Wt(),10<p)){if(wl(u,0)!==0)break;if(R=u.suspendedLanes,(R&E)!==E){Ni(),u.pingedLanes|=u.suspendedLanes&R;break}u.timeoutHandle=DS(Fl.bind(null,u,to,za),p);break}Fl(u,to,za);break;case 4:if(jc(u,E),(E&4194240)===E)break;for(p=u.eventTimes,R=-1;0<E;){var U=31-wo(E);M=1<<U,U=p[U],U>R&&(R=U),E&=~M}if(E=R,E=Wt()-E,E=(120>E?120:480>E?480:1080>E?1080:1920>E?1920:3e3>E?3e3:4320>E?4320:1960*Kpe(E/1960))-E,10<E){u.timeoutHandle=DS(Fl.bind(null,u,to,za),E);break}Fl(u,to,za);break;case 5:Fl(u,to,za);break;default:throw Error(t(329))}}}return ro(u,Wt()),u.callbackNode===S?Ok.bind(null,u):null}function Ax(u,p){var S=kf;return u.current.memoizedState.isDehydrated&&(Ll(u,p).flags|=256),u=ug(u,p),u!==2&&(p=to,to=S,p!==null&&Rx(p)),u}function Rx(u){to===null?to=u:to.push.apply(to,u)}function Gpe(u){for(var p=u;;){if(p.flags&16384){var S=p.updateQueue;if(S!==null&&(S=S.stores,S!==null))for(var E=0;E<S.length;E++){var R=S[E],M=R.getSnapshot;R=R.value;try{if(!ys(M(),R))return!1}catch{return!1}}}if(S=p.child,p.subtreeFlags&16384&&S!==null)S.return=p,p=S;else{if(p===u)break;for(;p.sibling===null;){if(p.return===null||p.return===u)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function jc(u,p){for(p&=~Ix,p&=~ig,u.suspendedLanes|=p,u.pingedLanes&=~p,u=u.expirationTimes;0<p;){var S=31-wo(p),E=1<<S;u[S]=-1,p&=~E}}function Mk(u){if((gr&6)!==0)throw Error(t(327));Yu();var p=wl(u,0);if((p&1)===0)return ro(u,Wt()),null;var S=ug(u,p);if(u.tag!==0&&S===2){var E=rf(u);E!==0&&(p=E,S=Ax(u,E))}if(S===1)throw S=Rf,Ll(u,0),jc(u,p),ro(u,Wt()),S;if(S===6)throw Error(t(345));return u.finishedWork=u.current.alternate,u.finishedLanes=p,Fl(u,to,za),ro(u,Wt()),null}function kx(u,p){var S=gr;gr|=1;try{return u(p)}finally{gr=S,gr===0&&(Vu=Wt()+500,Fp&&Cc())}}function Dl(u){Oc!==null&&Oc.tag===0&&(gr&6)===0&&Yu();var p=gr;gr|=1;var S=Qo.transition,E=fr;try{if(Qo.transition=null,fr=1,u)return u()}finally{fr=E,Qo.transition=S,gr=p,(gr&6)===0&&Cc()}}function Ox(){Io=Gu.current,Hr(Gu)}function Ll(u,p){u.finishedWork=null,u.finishedLanes=0;var S=u.timeoutHandle;if(S!==-1&&(u.timeoutHandle=-1,bpe(S)),Cn!==null)for(S=Cn.return;S!==null;){var E=S;switch(BS(E),E.tag){case 1:E=E.type.childContextTypes,E!=null&&Dp();break;case 3:Hu(),Hr(Qi),Hr(fi),ex();break;case 5:QS(E);break;case 4:Hu();break;case 13:Hr(tn);break;case 19:Hr(tn);break;case 10:GS(E.type._context);break;case 22:case 23:Ox()}S=S.return}if(Bn=u,Cn=u=Dc(u.current,null),Vn=Io=p,On=0,Rf=null,Ix=ig=jl=0,to=kf=null,kl!==null){for(p=0;p<kl.length;p++)if(S=kl[p],E=S.interleaved,E!==null){S.interleaved=null;var R=E.next,M=S.pending;if(M!==null){var U=M.next;M.next=R,E.next=U}S.pending=E}kl=null}return u}function jk(u,p){do{var S=Cn;try{if(KS(),Gp.current=Zp,Vp){for(var E=rn.memoizedState;E!==null;){var R=E.queue;R!==null&&(R.pending=null),E=E.next}Vp=!1}if(Ml=0,qn=kn=rn=null,Ef=!1,If=0,Ex.current=null,S===null||S.return===null){On=1,Rf=p,Cn=null;break}e:{var M=u,U=S.return,Q=S,ne=p;if(p=Vn,Q.flags|=32768,ne!==null&&typeof ne=="object"&&typeof ne.then=="function"){var Se=ne,De=Q,Ue=De.tag;if((De.mode&1)===0&&(Ue===0||Ue===11||Ue===15)){var je=De.alternate;je?(De.updateQueue=je.updateQueue,De.memoizedState=je.memoizedState,De.lanes=je.lanes):(De.updateQueue=null,De.memoizedState=null)}var at=ok(U);if(at!==null){at.flags&=-257,sk(at,U,Q,M,p),at.mode&1&&ik(M,Se,p),p=at,ne=Se;var gt=p.updateQueue;if(gt===null){var xt=new Set;xt.add(ne),p.updateQueue=xt}else gt.add(ne);break e}else{if((p&1)===0){ik(M,Se,p),Mx();break e}ne=Error(t(426))}}else if(Xr&&Q.mode&1){var vn=ok(U);if(vn!==null){(vn.flags&65536)===0&&(vn.flags|=256),sk(vn,U,Q,M,p),HS(Wu(ne,Q));break e}}M=ne=Wu(ne,Q),On!==4&&(On=2),kf===null?kf=[M]:kf.push(M),M=U;do{switch(M.tag){case 3:M.flags|=65536,p&=-p,M.lanes|=p;var de=rk(M,ne,p);A2(M,de);break e;case 1:Q=ne;var ie=M.type,pe=M.stateNode;if((M.flags&128)===0&&(typeof ie.getDerivedStateFromError=="function"||pe!==null&&typeof pe.componentDidCatch=="function"&&(kc===null||!kc.has(pe)))){M.flags|=65536,p&=-p,M.lanes|=p;var Ve=nk(M,Q,p);A2(M,Ve);break e}}M=M.return}while(M!==null)}Fk(S)}catch(wt){p=wt,Cn===S&&S!==null&&(Cn=S=S.return);continue}break}while(!0)}function Dk(){var u=ng.current;return ng.current=Zp,u===null?Zp:u}function Mx(){(On===0||On===3||On===2)&&(On=4),Bn===null||(jl&268435455)===0&&(ig&268435455)===0||jc(Bn,Vn)}function ug(u,p){var S=gr;gr|=2;var E=Dk();(Bn!==u||Vn!==p)&&(za=null,Ll(u,p));do try{Vpe();break}catch(R){jk(u,R)}while(!0);if(KS(),gr=S,ng.current=E,Cn!==null)throw Error(t(261));return Bn=null,Vn=0,On}function Vpe(){for(;Cn!==null;)Lk(Cn)}function Ype(){for(;Cn!==null&&!ft();)Lk(Cn)}function Lk(u){var p=qk(u.alternate,u,Io);u.memoizedProps=u.pendingProps,p===null?Fk(u):Cn=p,Ex.current=null}function Fk(u){var p=u;do{var S=p.alternate;if(u=p.return,(p.flags&32768)===0){if(S=Bpe(S,p,Io),S!==null){Cn=S;return}}else{if(S=Upe(S,p),S!==null){S.flags&=32767,Cn=S;return}if(u!==null)u.flags|=32768,u.subtreeFlags=0,u.deletions=null;else{On=6,Cn=null;return}}if(p=p.sibling,p!==null){Cn=p;return}Cn=p=u}while(p!==null);On===0&&(On=5)}function Fl(u,p,S){var E=fr,R=Qo.transition;try{Qo.transition=null,fr=1,Xpe(u,p,S,E)}finally{Qo.transition=R,fr=E}return null}function Xpe(u,p,S,E){do Yu();while(Oc!==null);if((gr&6)!==0)throw Error(t(327));S=u.finishedWork;var R=u.finishedLanes;if(S===null)return null;if(u.finishedWork=null,u.finishedLanes=0,S===u.current)throw Error(t(177));u.callbackNode=null,u.callbackPriority=0;var M=S.lanes|S.childLanes;if(vS(u,M),u===Bn&&(Cn=Bn=null,Vn=0),(S.subtreeFlags&2064)===0&&(S.flags&2064)===0||sg||(sg=!0,Bk(Ur,function(){return Yu(),null})),M=(S.flags&15990)!==0,(S.subtreeFlags&15990)!==0||M){M=Qo.transition,Qo.transition=null;var U=fr;fr=1;var Q=gr;gr|=4,Ex.current=null,Hpe(u,S),Ck(S,u),vpe(MS),ae=!!OS,MS=OS=null,u.current=S,Wpe(S),Br(),gr=Q,fr=U,Qo.transition=M}else u.current=S;if(sg&&(sg=!1,Oc=u,ag=R),M=u.pendingLanes,M===0&&(kc=null),_l(S.stateNode),ro(u,Wt()),p!==null)for(E=u.onRecoverableError,S=0;S<p.length;S++)R=p[S],E(R.value,{componentStack:R.stack,digest:R.digest});if(og)throw og=!1,u=Cx,Cx=null,u;return(ag&1)!==0&&u.tag!==0&&Yu(),M=u.pendingLanes,(M&1)!==0?u===Tx?Of++:(Of=0,Tx=u):Of=0,Cc(),null}function Yu(){if(Oc!==null){var u=Da(ag),p=Qo.transition,S=fr;try{if(Qo.transition=null,fr=16>u?16:u,Oc===null)var E=!1;else{if(u=Oc,Oc=null,ag=0,(gr&6)!==0)throw Error(t(331));var R=gr;for(gr|=4,ht=u.current;ht!==null;){var M=ht,U=M.child;if((ht.flags&16)!==0){var Q=M.deletions;if(Q!==null){for(var ne=0;ne<Q.length;ne++){var Se=Q[ne];for(ht=Se;ht!==null;){var De=ht;switch(De.tag){case 0:case 11:case 15:Af(8,De,M)}var Ue=De.child;if(Ue!==null)Ue.return=De,ht=Ue;else for(;ht!==null;){De=ht;var je=De.sibling,at=De.return;if(wk(De),De===Se){ht=null;break}if(je!==null){je.return=at,ht=je;break}ht=at}}}var gt=M.alternate;if(gt!==null){var xt=gt.child;if(xt!==null){gt.child=null;do{var vn=xt.sibling;xt.sibling=null,xt=vn}while(xt!==null)}}ht=M}}if((M.subtreeFlags&2064)!==0&&U!==null)U.return=M,ht=U;else e:for(;ht!==null;){if(M=ht,(M.flags&2048)!==0)switch(M.tag){case 0:case 11:case 15:Af(9,M,M.return)}var de=M.sibling;if(de!==null){de.return=M.return,ht=de;break e}ht=M.return}}var ie=u.current;for(ht=ie;ht!==null;){U=ht;var pe=U.child;if((U.subtreeFlags&2064)!==0&&pe!==null)pe.return=U,ht=pe;else e:for(U=ie;ht!==null;){if(Q=ht,(Q.flags&2048)!==0)try{switch(Q.tag){case 0:case 11:case 15:rg(9,Q)}}catch(wt){dn(Q,Q.return,wt)}if(Q===U){ht=null;break e}var Ve=Q.sibling;if(Ve!==null){Ve.return=Q.return,ht=Ve;break e}ht=Q.return}}if(gr=R,Cc(),Di&&typeof Di.onPostCommitFiberRoot=="function")try{Di.onPostCommitFiberRoot(ja,u)}catch{}E=!0}return E}finally{fr=S,Qo.transition=p}}return!1}function Nk(u,p,S){p=Wu(S,p),p=rk(u,p,1),u=Ac(u,p,1),p=Ni(),u!==null&&(bl(u,1,p),ro(u,p))}function dn(u,p,S){if(u.tag===3)Nk(u,u,S);else for(;p!==null;){if(p.tag===3){Nk(p,u,S);break}else if(p.tag===1){var E=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof E.componentDidCatch=="function"&&(kc===null||!kc.has(E))){u=Wu(S,u),u=nk(p,u,1),p=Ac(p,u,1),u=Ni(),p!==null&&(bl(p,1,u),ro(p,u));break}}p=p.return}}function Zpe(u,p,S){var E=u.pingCache;E!==null&&E.delete(p),p=Ni(),u.pingedLanes|=u.suspendedLanes&S,Bn===u&&(Vn&S)===S&&(On===4||On===3&&(Vn&130023424)===Vn&&500>Wt()-Px?Ll(u,0):Ix|=S),ro(u,p)}function $k(u,p){p===0&&((u.mode&1)===0?p=1:(p=Gs,Gs<<=1,(Gs&130023424)===0&&(Gs=4194304)));var S=Ni();u=qa(u,p),u!==null&&(bl(u,p,S),ro(u,S))}function Qpe(u){var p=u.memoizedState,S=0;p!==null&&(S=p.retryLane),$k(u,S)}function Jpe(u,p){var S=0;switch(u.tag){case 13:var E=u.stateNode,R=u.memoizedState;R!==null&&(S=R.retryLane);break;case 19:E=u.stateNode;break;default:throw Error(t(314))}E!==null&&E.delete(p),$k(u,S)}var qk;qk=function(u,p,S){if(u!==null)if(u.memoizedProps!==p.pendingProps||Qi.current)eo=!0;else{if((u.lanes&S)===0&&(p.flags&128)===0)return eo=!1,qpe(u,p,S);eo=(u.flags&131072)!==0}else eo=!1,Xr&&(p.flags&1048576)!==0&&S2(p,$p,p.index);switch(p.lanes=0,p.tag){case 2:var E=p.type;eg(u,p),u=p.pendingProps;var R=Fu(p,fi.current);zu(p,S),R=nx(null,p,E,u,R,S);var M=ix();return p.flags|=1,typeof R=="object"&&R!==null&&typeof R.render=="function"&&R.$$typeof===void 0?(p.tag=1,p.memoizedState=null,p.updateQueue=null,Ji(E)?(M=!0,Lp(p)):M=!1,p.memoizedState=R.state!==null&&R.state!==void 0?R.state:null,XS(p),R.updater=Qp,p.stateNode=R,R._reactInternals=p,ux(p,E,u,S),p=px(null,p,E,!0,M,S)):(p.tag=0,Xr&&M&&qS(p),Fi(null,p,R,S),p=p.child),p;case 16:E=p.elementType;e:{switch(eg(u,p),u=p.pendingProps,R=E._init,E=R(E._payload),p.type=E,R=p.tag=tge(E),u=xs(E,u),R){case 0:p=hx(null,p,E,u,S);break e;case 1:p=fk(null,p,E,u,S);break e;case 11:p=ak(null,p,E,u,S);break e;case 14:p=ck(null,p,E,xs(E.type,u),S);break e}throw Error(t(306,E,""))}return p;case 0:return E=p.type,R=p.pendingProps,R=p.elementType===E?R:xs(E,R),hx(u,p,E,R,S);case 1:return E=p.type,R=p.pendingProps,R=p.elementType===E?R:xs(E,R),fk(u,p,E,R,S);case 3:e:{if(hk(p),u===null)throw Error(t(387));E=p.pendingProps,M=p.memoizedState,R=M.element,T2(u,p),Wp(p,E,null,S);var U=p.memoizedState;if(E=U.element,M.isDehydrated)if(M={element:E,isDehydrated:!1,cache:U.cache,pendingSuspenseBoundaries:U.pendingSuspenseBoundaries,transitions:U.transitions},p.updateQueue.baseState=M,p.memoizedState=M,p.flags&256){R=Wu(Error(t(423)),p),p=pk(u,p,E,S,R);break e}else if(E!==R){R=Wu(Error(t(424)),p),p=pk(u,p,E,S,R);break e}else for(Eo=Ec(p.stateNode.containerInfo.firstChild),bo=p,Xr=!0,Ss=null,S=P2(p,null,E,S),p.child=S;S;)S.flags=S.flags&-3|4096,S=S.sibling;else{if(qu(),E===R){p=Ua(u,p,S);break e}Fi(u,p,E,S)}p=p.child}return p;case 5:return k2(p),u===null&&zS(p),E=p.type,R=p.pendingProps,M=u!==null?u.memoizedProps:null,U=R.children,jS(E,R)?U=null:M!==null&&jS(E,M)&&(p.flags|=32),dk(u,p),Fi(u,p,U,S),p.child;case 6:return u===null&&zS(p),null;case 13:return gk(u,p,S);case 4:return ZS(p,p.stateNode.containerInfo),E=p.pendingProps,u===null?p.child=Bu(p,null,E,S):Fi(u,p,E,S),p.child;case 11:return E=p.type,R=p.pendingProps,R=p.elementType===E?R:xs(E,R),ak(u,p,E,R,S);case 7:return Fi(u,p,p.pendingProps,S),p.child;case 8:return Fi(u,p,p.pendingProps.children,S),p.child;case 12:return Fi(u,p,p.pendingProps.children,S),p.child;case 10:e:{if(E=p.type._context,R=p.pendingProps,M=p.memoizedProps,U=R.value,Lr(Up,E._currentValue),E._currentValue=U,M!==null)if(ys(M.value,U)){if(M.children===R.children&&!Qi.current){p=Ua(u,p,S);break e}}else for(M=p.child,M!==null&&(M.return=p);M!==null;){var Q=M.dependencies;if(Q!==null){U=M.child;for(var ne=Q.firstContext;ne!==null;){if(ne.context===E){if(M.tag===1){ne=Ba(-1,S&-S),ne.tag=2;var Se=M.updateQueue;if(Se!==null){Se=Se.shared;var De=Se.pending;De===null?ne.next=ne:(ne.next=De.next,De.next=ne),Se.pending=ne}}M.lanes|=S,ne=M.alternate,ne!==null&&(ne.lanes|=S),VS(M.return,S,p),Q.lanes|=S;break}ne=ne.next}}else if(M.tag===10)U=M.type===p.type?null:M.child;else if(M.tag===18){if(U=M.return,U===null)throw Error(t(341));U.lanes|=S,Q=U.alternate,Q!==null&&(Q.lanes|=S),VS(U,S,p),U=M.sibling}else U=M.child;if(U!==null)U.return=M;else for(U=M;U!==null;){if(U===p){U=null;break}if(M=U.sibling,M!==null){M.return=U.return,U=M;break}U=U.return}M=U}Fi(u,p,R.children,S),p=p.child}return p;case 9:return R=p.type,E=p.pendingProps.children,zu(p,S),R=Xo(R),E=E(R),p.flags|=1,Fi(u,p,E,S),p.child;case 14:return E=p.type,R=xs(E,p.pendingProps),R=xs(E.type,R),ck(u,p,E,R,S);case 15:return lk(u,p,p.type,p.pendingProps,S);case 17:return E=p.type,R=p.pendingProps,R=p.elementType===E?R:xs(E,R),eg(u,p),p.tag=1,Ji(E)?(u=!0,Lp(p)):u=!1,zu(p,S),ek(p,E,R),ux(p,E,R,S),px(null,p,E,!0,u,S);case 19:return mk(u,p,S);case 22:return uk(u,p,S)}throw Error(t(156,p.tag))};function Bk(u,p){return ke(u,p)}function ege(u,p,S,E){this.tag=u,this.key=S,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=E,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Jo(u,p,S,E){return new ege(u,p,S,E)}function jx(u){return u=u.prototype,!(!u||!u.isReactComponent)}function tge(u){if(typeof u=="function")return jx(u)?1:0;if(u!=null){if(u=u.$$typeof,u===$)return 11;if(u===B)return 14}return 2}function Dc(u,p){var S=u.alternate;return S===null?(S=Jo(u.tag,p,u.key,u.mode),S.elementType=u.elementType,S.type=u.type,S.stateNode=u.stateNode,S.alternate=u,u.alternate=S):(S.pendingProps=p,S.type=u.type,S.flags=0,S.subtreeFlags=0,S.deletions=null),S.flags=u.flags&14680064,S.childLanes=u.childLanes,S.lanes=u.lanes,S.child=u.child,S.memoizedProps=u.memoizedProps,S.memoizedState=u.memoizedState,S.updateQueue=u.updateQueue,p=u.dependencies,S.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},S.sibling=u.sibling,S.index=u.index,S.ref=u.ref,S}function dg(u,p,S,E,R,M){var U=2;if(E=u,typeof u=="function")jx(u)&&(U=1);else if(typeof u=="string")U=5;else e:switch(u){case k:return Nl(S.children,R,M,p);case O:U=8,R|=8;break;case L:return u=Jo(12,S,p,R|2),u.elementType=L,u.lanes=M,u;case D:return u=Jo(13,S,p,R),u.elementType=D,u.lanes=M,u;case N:return u=Jo(19,S,p,R),u.elementType=N,u.lanes=M,u;case G:return fg(S,R,M,p);default:if(typeof u=="object"&&u!==null)switch(u.$$typeof){case j:U=10;break e;case F:U=9;break e;case $:U=11;break e;case B:U=14;break e;case W:U=16,E=null;break e}throw Error(t(130,u==null?u:typeof u,""))}return p=Jo(U,S,p,R),p.elementType=u,p.type=E,p.lanes=M,p}function Nl(u,p,S,E){return u=Jo(7,u,E,p),u.lanes=S,u}function fg(u,p,S,E){return u=Jo(22,u,E,p),u.elementType=G,u.lanes=S,u.stateNode={isHidden:!1},u}function Dx(u,p,S){return u=Jo(6,u,null,p),u.lanes=S,u}function Lx(u,p,S){return p=Jo(4,u.children!==null?u.children:[],u.key,p),p.lanes=S,p.stateNode={containerInfo:u.containerInfo,pendingChildren:null,implementation:u.implementation},p}function rge(u,p,S,E,R){this.tag=p,this.containerInfo=u,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Pu(0),this.expirationTimes=Pu(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pu(0),this.identifierPrefix=E,this.onRecoverableError=R,this.mutableSourceEagerHydrationData=null}function Fx(u,p,S,E,R,M,U,Q,ne){return u=new rge(u,p,S,Q,ne),p===1?(p=1,M===!0&&(p|=8)):p=0,M=Jo(3,null,null,p),u.current=M,M.stateNode=u,M.memoizedState={element:E,isDehydrated:S,cache:null,transitions:null,pendingSuspenseBoundaries:null},XS(M),u}function nge(u,p,S){var E=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:C,key:E==null?null:""+E,children:u,containerInfo:p,implementation:S}}function Uk(u){if(!u)return Pc;u=u._reactInternals;e:{if(Go(u)!==u||u.tag!==1)throw Error(t(170));var p=u;do{switch(p.tag){case 3:p=p.stateNode.context;break e;case 1:if(Ji(p.type)){p=p.stateNode.__reactInternalMemoizedMergedChildContext;break e}}p=p.return}while(p!==null);throw Error(t(171))}if(u.tag===1){var S=u.type;if(Ji(S))return v2(u,S,p)}return p}function zk(u,p,S,E,R,M,U,Q,ne){return u=Fx(S,E,!0,u,R,M,U,Q,ne),u.context=Uk(null),S=u.current,E=Ni(),R=Mc(S),M=Ba(E,R),M.callback=p??null,Ac(S,M,R),u.current.lanes=R,bl(u,R,E),ro(u,E),u}function hg(u,p,S,E){var R=p.current,M=Ni(),U=Mc(R);return S=Uk(S),p.context===null?p.context=S:p.pendingContext=S,p=Ba(M,U),p.payload={element:u},E=E===void 0?null:E,E!==null&&(p.callback=E),u=Ac(R,p,U),u!==null&&(bs(u,R,U,M),Hp(u,R,U)),U}function pg(u){if(u=u.current,!u.child)return null;switch(u.child.tag){case 5:return u.child.stateNode;default:return u.child.stateNode}}function Hk(u,p){if(u=u.memoizedState,u!==null&&u.dehydrated!==null){var S=u.retryLane;u.retryLane=S!==0&&S<p?S:p}}function Nx(u,p){Hk(u,p),(u=u.alternate)&&Hk(u,p)}function ige(){return null}var Wk=typeof reportError=="function"?reportError:function(u){console.error(u)};function $x(u){this._internalRoot=u}gg.prototype.render=$x.prototype.render=function(u){var p=this._internalRoot;if(p===null)throw Error(t(409));hg(u,p,null,null)},gg.prototype.unmount=$x.prototype.unmount=function(){var u=this._internalRoot;if(u!==null){this._internalRoot=null;var p=u.containerInfo;Dl(function(){hg(null,u,null,null)}),p[La]=null}};function gg(u){this._internalRoot=u}gg.prototype.unstable_scheduleHydration=function(u){if(u){var p=wp();u={blockedOn:null,target:u,priority:p};for(var S=0;S<Xs.length&&p!==0&&p<Xs[S].priority;S++);Xs.splice(S,0,u),S===0&&af(u)}};function qx(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)}function vg(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11&&(u.nodeType!==8||u.nodeValue!==" react-mount-point-unstable "))}function Kk(){}function oge(u,p,S,E,R){if(R){if(typeof E=="function"){var M=E;E=function(){var Se=pg(U);M.call(Se)}}var U=zk(p,E,u,0,null,!1,!1,"",Kk);return u._reactRootContainer=U,u[La]=U.current,vf(u.nodeType===8?u.parentNode:u),Dl(),U}for(;R=u.lastChild;)u.removeChild(R);if(typeof E=="function"){var Q=E;E=function(){var Se=pg(ne);Q.call(Se)}}var ne=Fx(u,0,!1,null,null,!1,!1,"",Kk);return u._reactRootContainer=ne,u[La]=ne.current,vf(u.nodeType===8?u.parentNode:u),Dl(function(){hg(p,ne,S,E)}),ne}function mg(u,p,S,E,R){var M=S._reactRootContainer;if(M){var U=M;if(typeof R=="function"){var Q=R;R=function(){var ne=pg(U);Q.call(ne)}}hg(p,U,u,R)}else U=oge(S,p,u,R,E);return pg(U)}_p=function(u){switch(u.tag){case 3:var p=u.stateNode;if(p.current.memoizedState.isDehydrated){var S=Sc(p.pendingLanes);S!==0&&(Cu(p,S|1),ro(p,Wt()),(gr&6)===0&&(Vu=Wt()+500,Cc()))}break;case 13:Dl(function(){var E=qa(u,1);if(E!==null){var R=Ni();bs(E,u,1,R)}}),Nx(u,1)}},nf=function(u){if(u.tag===13){var p=qa(u,134217728);if(p!==null){var S=Ni();bs(p,u,134217728,S)}Nx(u,134217728)}},gs=function(u){if(u.tag===13){var p=Mc(u),S=qa(u,p);if(S!==null){var E=Ni();bs(S,u,p,E)}Nx(u,p)}},wp=function(){return fr},bp=function(u,p){var S=fr;try{return fr=u,p()}finally{fr=S}},Be=function(u,p,S){switch(p){case"input":if(ct(u,S),p=S.name,S.type==="radio"&&p!=null){for(S=u;S.parentNode;)S=S.parentNode;for(S=S.querySelectorAll("input[name="+JSON.stringify(""+p)+'][type="radio"]'),p=0;p<S.length;p++){var E=S[p];if(E!==u&&E.form===u.form){var R=jp(E);if(!R)throw Error(t(90));Ge(E),ct(E,R)}}}break;case"textarea":it(u,S);break;case"select":p=S.value,p!=null&&Ae(u,!!S.multiple,p,!1)}},Rr=kx,en=Dl;var sge={usingClientEntryPoint:!1,Events:[Sf,Du,jp,ur,xr,kx]},Mf={findFiberByHostInstance:Cl,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},age={bundleType:Mf.bundleType,version:Mf.version,rendererPackageName:Mf.rendererPackageName,rendererConfig:Mf.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:b.ReactCurrentDispatcher,findHostInstanceByFiber:function(u){return u=xe(u),u===null?null:u.stateNode},findFiberByHostInstance:Mf.findFiberByHostInstance||ige,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var yg=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yg.isDisabled&&yg.supportsFiber)try{ja=yg.inject(age),Di=yg}catch{}}return no.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=sge,no.createPortal=function(u,p){var S=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!qx(p))throw Error(t(200));return nge(u,p,null,S)},no.createRoot=function(u,p){if(!qx(u))throw Error(t(299));var S=!1,E="",R=Wk;return p!=null&&(p.unstable_strictMode===!0&&(S=!0),p.identifierPrefix!==void 0&&(E=p.identifierPrefix),p.onRecoverableError!==void 0&&(R=p.onRecoverableError)),p=Fx(u,1,!1,null,null,S,!1,E,R),u[La]=p.current,vf(u.nodeType===8?u.parentNode:u),new $x(p)},no.findDOMNode=function(u){if(u==null)return null;if(u.nodeType===1)return u;var p=u._reactInternals;if(p===void 0)throw typeof u.render=="function"?Error(t(188)):(u=Object.keys(u).join(","),Error(t(268,u)));return u=xe(p),u=u===null?null:u.stateNode,u},no.flushSync=function(u){return Dl(u)},no.hydrate=function(u,p,S){if(!vg(p))throw Error(t(200));return mg(null,u,p,!0,S)},no.hydrateRoot=function(u,p,S){if(!qx(u))throw Error(t(405));var E=S!=null&&S.hydratedSources||null,R=!1,M="",U=Wk;if(S!=null&&(S.unstable_strictMode===!0&&(R=!0),S.identifierPrefix!==void 0&&(M=S.identifierPrefix),S.onRecoverableError!==void 0&&(U=S.onRecoverableError)),p=zk(p,null,u,1,S??null,R,!1,M,U),u[La]=p.current,vf(u),E)for(u=0;u<E.length;u++)S=E[u],R=S._getVersion,R=R(S._source),p.mutableSourceEagerHydrationData==null?p.mutableSourceEagerHydrationData=[S,R]:p.mutableSourceEagerHydrationData.push(S,R);return new gg(p)},no.render=function(u,p,S){if(!vg(p))throw Error(t(200));return mg(null,u,p,!1,S)},no.unmountComponentAtNode=function(u){if(!vg(u))throw Error(t(40));return u._reactRootContainer?(Dl(function(){mg(null,null,u,!1,function(){u._reactRootContainer=null,u[La]=null})}),!0):!1},no.unstable_batchedUpdates=kx,no.unstable_renderSubtreeIntoContainer=function(u,p,S,E){if(!vg(S))throw Error(t(200));if(u==null||u._reactInternals===void 0)throw Error(t(38));return mg(u,p,S,!1,E)},no.version="18.3.1-next-f1338f8080-20240426",no}var eO;function jJ(){if(eO)return zx.exports;eO=1;function r(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(e){console.error(e)}}return r(),zx.exports=yge(),zx.exports}var tO;function Sge(){if(tO)return Sg;tO=1;var r=jJ();return Sg.createRoot=r.createRoot,Sg.hydrateRoot=r.hydrateRoot,Sg}var DJ=Sge();const xge=cc(DJ);function tt(r,e={}){const t=typeof r=="string"?r:r.src;if(typeof e=="function")return e(t);const{baseUrl:n=""}=e;return t.startsWith("data:")||t.match(/^https?:\/\//)?t:`${n.replace(/\/$/,"")}/${t.replace(/^\.?\//,"")}`}function _ge(r){const e=tt("./icons/icon/0_merged.svg",r);return{fonts:{monospace:tt("./fonts/IBMPlexMono-Medium.woff2",r),sansSerif:tt("./fonts/IBMPlexSans-Medium.woff2",r),serif:tt("./fonts/IBMPlexSerif-Medium.woff2",r),draw:tt("./fonts/Shantell_Sans-Tldrawish.woff2",r)},icons:{"align-bottom":e+"#align-bottom","align-center-horizontal":e+"#align-center-horizontal","align-center-vertical":e+"#align-center-vertical","align-left":e+"#align-left","align-right":e+"#align-right","align-top":e+"#align-top","arrow-left":e+"#arrow-left","arrowhead-arrow":e+"#arrowhead-arrow","arrowhead-bar":e+"#arrowhead-bar","arrowhead-diamond":e+"#arrowhead-diamond","arrowhead-dot":e+"#arrowhead-dot","arrowhead-none":e+"#arrowhead-none","arrowhead-square":e+"#arrowhead-square","arrowhead-triangle-inverted":e+"#arrowhead-triangle-inverted","arrowhead-triangle":e+"#arrowhead-triangle",blob:e+"#blob","bring-forward":e+"#bring-forward","bring-to-front":e+"#bring-to-front",broken:e+"#broken","check-circle":e+"#check-circle",check:e+"#check","chevron-down":e+"#chevron-down","chevron-left":e+"#chevron-left","chevron-right":e+"#chevron-right","chevron-up":e+"#chevron-up","chevrons-ne":e+"#chevrons-ne","chevrons-sw":e+"#chevrons-sw","clipboard-copied":e+"#clipboard-copied","clipboard-copy":e+"#clipboard-copy",color:e+"#color","cross-2":e+"#cross-2","cross-circle":e+"#cross-circle","dash-dashed":e+"#dash-dashed","dash-dotted":e+"#dash-dotted","dash-draw":e+"#dash-draw","dash-solid":e+"#dash-solid",disconnected:e+"#disconnected",discord:e+"#discord","distribute-horizontal":e+"#distribute-horizontal","distribute-vertical":e+"#distribute-vertical",dot:e+"#dot","dots-horizontal":e+"#dots-horizontal","dots-vertical":e+"#dots-vertical","drag-handle-dots":e+"#drag-handle-dots",duplicate:e+"#duplicate",edit:e+"#edit","external-link":e+"#external-link","fill-fill":e+"#fill-fill","fill-none":e+"#fill-none","fill-pattern":e+"#fill-pattern","fill-semi":e+"#fill-semi","fill-solid":e+"#fill-solid",follow:e+"#follow",following:e+"#following","font-draw":e+"#font-draw","font-mono":e+"#font-mono","font-sans":e+"#font-sans","font-serif":e+"#font-serif","geo-arrow-down":e+"#geo-arrow-down","geo-arrow-left":e+"#geo-arrow-left","geo-arrow-right":e+"#geo-arrow-right","geo-arrow-up":e+"#geo-arrow-up","geo-check-box":e+"#geo-check-box","geo-cloud":e+"#geo-cloud","geo-diamond":e+"#geo-diamond","geo-ellipse":e+"#geo-ellipse","geo-heart":e+"#geo-heart","geo-hexagon":e+"#geo-hexagon","geo-octagon":e+"#geo-octagon","geo-oval":e+"#geo-oval","geo-pentagon":e+"#geo-pentagon","geo-rectangle":e+"#geo-rectangle","geo-rhombus-2":e+"#geo-rhombus-2","geo-rhombus":e+"#geo-rhombus","geo-star":e+"#geo-star","geo-trapezoid":e+"#geo-trapezoid","geo-triangle":e+"#geo-triangle","geo-x-box":e+"#geo-x-box",github:e+"#github",group:e+"#group","horizontal-align-end":e+"#horizontal-align-end","horizontal-align-middle":e+"#horizontal-align-middle","horizontal-align-start":e+"#horizontal-align-start","info-circle":e+"#info-circle",leading:e+"#leading",link:e+"#link",lock:e+"#lock",menu:e+"#menu",minus:e+"#minus",mixed:e+"#mixed",pack:e+"#pack",plus:e+"#plus","question-mark-circle":e+"#question-mark-circle","question-mark":e+"#question-mark",redo:e+"#redo","reset-zoom":e+"#reset-zoom","rotate-ccw":e+"#rotate-ccw","rotate-cw":e+"#rotate-cw","send-backward":e+"#send-backward","send-to-back":e+"#send-to-back","share-1":e+"#share-1","size-extra-large":e+"#size-extra-large","size-large":e+"#size-large","size-medium":e+"#size-medium","size-small":e+"#size-small","spline-cubic":e+"#spline-cubic","spline-line":e+"#spline-line","stack-horizontal":e+"#stack-horizontal","stack-vertical":e+"#stack-vertical","status-offline":e+"#status-offline","stretch-horizontal":e+"#stretch-horizontal","stretch-vertical":e+"#stretch-vertical","text-align-center":e+"#text-align-center","text-align-left":e+"#text-align-left","text-align-right":e+"#text-align-right","toggle-off":e+"#toggle-off","toggle-on":e+"#toggle-on","tool-arrow":e+"#tool-arrow","tool-eraser":e+"#tool-eraser","tool-frame":e+"#tool-frame","tool-hand":e+"#tool-hand","tool-highlight":e+"#tool-highlight","tool-laser":e+"#tool-laser","tool-line":e+"#tool-line","tool-media":e+"#tool-media","tool-note":e+"#tool-note","tool-pencil":e+"#tool-pencil","tool-pointer":e+"#tool-pointer","tool-screenshot":e+"#tool-screenshot","tool-text":e+"#tool-text",trash:e+"#trash",twitter:e+"#twitter",undo:e+"#undo",ungroup:e+"#ungroup",unlock:e+"#unlock","vertical-align-end":e+"#vertical-align-end","vertical-align-middle":e+"#vertical-align-middle","vertical-align-start":e+"#vertical-align-start","warning-triangle":e+"#warning-triangle","zoom-in":e+"#zoom-in","zoom-out":e+"#zoom-out"},translations:{ar:tt("./translations/ar.json",r),bn:tt("./translations/bn.json",r),ca:tt("./translations/ca.json",r),cs:tt("./translations/cs.json",r),da:tt("./translations/da.json",r),de:tt("./translations/de.json",r),el:tt("./translations/el.json",r),en:tt("./translations/en.json",r),es:tt("./translations/es.json",r),fa:tt("./translations/fa.json",r),fi:tt("./translations/fi.json",r),fr:tt("./translations/fr.json",r),gl:tt("./translations/gl.json",r),"gu-in":tt("./translations/gu-in.json",r),he:tt("./translations/he.json",r),"hi-in":tt("./translations/hi-in.json",r),hr:tt("./translations/hr.json",r),hu:tt("./translations/hu.json",r),id:tt("./translations/id.json",r),it:tt("./translations/it.json",r),ja:tt("./translations/ja.json",r),"km-kh":tt("./translations/km-kh.json",r),kn:tt("./translations/kn.json",r),"ko-kr":tt("./translations/ko-kr.json",r),ku:tt("./translations/ku.json",r),languages:tt("./translations/languages.json",r),main:tt("./translations/main.json",r),ml:tt("./translations/ml.json",r),mr:tt("./translations/mr.json",r),ms:tt("./translations/ms.json",r),my:tt("./translations/my.json",r),ne:tt("./translations/ne.json",r),nl:tt("./translations/nl.json",r),no:tt("./translations/no.json",r),pa:tt("./translations/pa.json",r),pl:tt("./translations/pl.json",r),"pt-br":tt("./translations/pt-br.json",r),"pt-pt":tt("./translations/pt-pt.json",r),ro:tt("./translations/ro.json",r),ru:tt("./translations/ru.json",r),sl:tt("./translations/sl.json",r),so:tt("./translations/so.json",r),sv:tt("./translations/sv.json",r),ta:tt("./translations/ta.json",r),te:tt("./translations/te.json",r),th:tt("./translations/th.json",r),tl:tt("./translations/tl.json",r),tr:tt("./translations/tr.json",r),uk:tt("./translations/uk.json",r),ur:tt("./translations/ur.json",r),vi:tt("./translations/vi.json",r),"zh-cn":tt("./translations/zh-cn.json",r),"zh-tw":tt("./translations/zh-tw.json",r)},embedIcons:{codepen:tt("./embed-icons/codepen.png",r),codesandbox:tt("./embed-icons/codesandbox.png",r),desmos:tt("./embed-icons/desmos.png",r),excalidraw:tt("./embed-icons/excalidraw.png",r),felt:tt("./embed-icons/felt.png",r),figma:tt("./embed-icons/figma.png",r),github_gist:tt("./embed-icons/github_gist.png",r),google_calendar:tt("./embed-icons/google_calendar.png",r),google_maps:tt("./embed-icons/google_maps.png",r),google_slides:tt("./embed-icons/google_slides.png",r),observable:tt("./embed-icons/observable.png",r),replit:tt("./embed-icons/replit.png",r),scratch:tt("./embed-icons/scratch.png",r),spotify:tt("./embed-icons/spotify.png",r),tldraw:tt("./embed-icons/tldraw.png",r),val_town:tt("./embed-icons/val_town.png",r),vimeo:tt("./embed-icons/vimeo.png",r),youtube:tt("./embed-icons/youtube.png",r)}}}const Kx="__TLDRAW_LIBRARY_VERSIONS__";function wge(){if(globalThis[Kx])return globalThis[Kx];const r={versions:[],didWarn:!1,scheduledNotice:null};return Object.defineProperty(globalThis,Kx,{value:r,writable:!1,configurable:!1,enumerable:!1}),r}function il(r,e,t){if(!r)throw new Error("Missing name/version/module system in built version of tldraw library");const n=wge();if(n.versions.push({name:r,version:e,modules:t}),!n.scheduledNotice)try{n.scheduledNotice=setTimeout(()=>{n.scheduledNotice=null,rO(n)},100)}catch{rO(n)}}function rO(r){if(!r.versions.length||r.didWarn)return;const e=r.versions.sort((a,c)=>nO(a.version,c.version)),t=e[e.length-1].version,n=new Set,i=new Map;for(const a of e){if(i.has(a.name)){n.delete(a.name),Gx(i,a.name,new Set).add(a.version);continue}a.version===t?n.add(a.name):(n.delete(a.name),Gx(i,a.name,new Set).add(a.version))}if(i.size>0){const a=[`${Ha("[tldraw]",["bold","bgRed","textWhite"])} ${Ha("You have multiple versions of tldraw libraries installed. This can lead to bugs and unexpected behavior.",["textRed","bold"])}`,"",`The latest version you have installed is ${Ha(`v${t}`,["bold","textBlue"])}. The following libraries are on the latest version:`,...Array.from(n,c=>` • ✅ ${Ha(c,["bold"])}`),"","The following libraries are not on the latest version, or have multiple versions installed:",...Array.from(i,([c,l])=>{const d=Array.from(l).sort(nO).map(f=>Ha(`v${f}`,f===t?["textGreen"]:["textRed"]));return` • ❌ ${Ha(c,["bold"])} (${d.join(", ")})`})];console.log(a.join(`
41
- `)),r.didWarn=!0;return}const o=new Map;for(const a of e)Gx(o,a.name,{version:a.version,modules:[]}).modules.push(a.modules);const s=new Map;for(const[a,c]of o)c.modules.length>1&&s.set(a,c);if(s.size>0){const a=[`${Ha("[tldraw]",["bold","bgRed","textWhite"])} ${Ha("You have multiple instances of some tldraw libraries active. This can lead to bugs and unexpected behavior. ",["textRed","bold"])}`,"","This usually means that your bundler is misconfigured, and is importing the same library multiple times - usually once as an ES Module, and once as a CommonJS module.","","The following libraries have been imported multiple times:",...Array.from(s,([c,l])=>{const d=l.modules.map((f,h)=>f==="esm"?` ${h+1}. ES Modules`:` ${h+1}. CommonJS`).join(`
42
- `);return` • ❌ ${Ha(c,["bold"])} v${l.version}:
43
- ${d}`}),"","You should configure your bundler to only import one version of each library."];console.log(a.join(`
44
- `)),r.didWarn=!0;return}}function nO(r,e){const t=r.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+))?$/),n=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+))?$/);return!t||!n?r.localeCompare(e):t[1]!==n[1]?Number(t[1])-Number(n[1]):t[2]!==n[2]?Number(t[2])-Number(n[2]):t[3]!==n[3]?Number(t[3])-Number(n[3]):t[4]&&n[4]?t[4].localeCompare(n[4]):t[4]?1:n[4]?-1:0}const bge={bold:"1",textBlue:"94",textRed:"31",textGreen:"32",bgRed:"41",textWhite:"97"};function Ha(r,e=[]){return`\x1B[${e.map(t=>bge[t]).join(";")}m${r}\x1B[m`}function Gx(r,e,t){return r.has(e)?r.get(e):(r.set(e,t),t)}var Vx,iO;function Ege(){if(iO)return Vx;iO=1;var r="Expected a function",e=NaN,t="[object Symbol]",n=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt,c=typeof ho=="object"&&ho&&ho.Object===Object&&ho,l=typeof self=="object"&&self&&self.Object===Object&&self,d=c||l||Function("return this")(),f=Object.prototype,h=f.toString,g=Math.max,m=Math.min,y=function(){return d.Date.now()};function x(C,k,O){var L,j,F,$,D,N,B=0,W=!1,G=!1,z=!0;if(typeof C!="function")throw new TypeError(r);k=P(k)||0,w(O)&&(W=!!O.leading,G="maxWait"in O,F=G?g(P(O.maxWait)||0,k):F,z="trailing"in O?!!O.trailing:z);function V(se){var ce=L,_e=j;return L=j=void 0,B=se,$=C.apply(_e,ce),$}function J(se){return B=se,D=setTimeout(ee,k),W?V(se):$}function K(se){var ce=se-N,_e=se-B,Le=k-ce;return G?m(Le,F-_e):Le}function Z(se){var ce=se-N,_e=se-B;return N===void 0||ce>=k||ce<0||G&&_e>=F}function ee(){var se=y();if(Z(se))return re(se);D=setTimeout(ee,K(se))}function re(se){return D=void 0,z&&L?V(se):(L=j=void 0,$)}function te(){D!==void 0&&clearTimeout(D),B=0,L=N=j=D=void 0}function le(){return D===void 0?$:re(y())}function ge(){var se=y(),ce=Z(se);if(L=arguments,j=this,N=se,ce){if(D===void 0)return J(N);if(G)return D=setTimeout(ee,k),V(N)}return D===void 0&&(D=setTimeout(ee,k)),$}return ge.cancel=te,ge.flush=le,ge}function _(C,k,O){var L=!0,j=!0;if(typeof C!="function")throw new TypeError(r);return w(O)&&(L="leading"in O?!!O.leading:L,j="trailing"in O?!!O.trailing:j),x(C,k,{leading:L,maxWait:k,trailing:j})}function w(C){var k=typeof C;return!!C&&(k=="object"||k=="function")}function I(C){return!!C&&typeof C=="object"}function b(C){return typeof C=="symbol"||I(C)&&h.call(C)==t}function P(C){if(typeof C=="number")return C;if(b(C))return e;if(w(C)){var k=typeof C.valueOf=="function"?C.valueOf():C;C=w(k)?k+"":k}if(typeof C!="string")return C===0?C:+C;C=C.replace(n,"");var O=o.test(C);return O||s.test(C)?a(C.slice(2),O?2:8):i.test(C)?e:+C}return Vx=_,Vx}var Ige=Ege();const LJ=cc(Ige);var Yx,oO;function Pge(){if(oO)return Yx;oO=1;var r=200,e="__lodash_hash_undefined__",t=1/0,n="[object Function]",i="[object GeneratorFunction]",o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,a=typeof ho=="object"&&ho&&ho.Object===Object&&ho,c=typeof self=="object"&&self&&self.Object===Object&&self,l=a||c||Function("return this")();function d(Y,oe){var me=Y?Y.length:0;return!!me&&h(Y,oe,0)>-1}function f(Y,oe,me,we){for(var Oe=Y.length,Ee=me+-1;++Ee<Oe;)if(oe(Y[Ee],Ee,Y))return Ee;return-1}function h(Y,oe,me){if(oe!==oe)return f(Y,g,me);for(var we=me-1,Oe=Y.length;++we<Oe;)if(Y[we]===oe)return we;return-1}function g(Y){return Y!==Y}function m(Y,oe){return Y.has(oe)}function y(Y,oe){return Y==null?void 0:Y[oe]}function x(Y){var oe=!1;if(Y!=null&&typeof Y.toString!="function")try{oe=!!(Y+"")}catch{}return oe}function _(Y){var oe=-1,me=Array(Y.size);return Y.forEach(function(we){me[++oe]=we}),me}var w=Array.prototype,I=Function.prototype,b=Object.prototype,P=l["__core-js_shared__"],C=function(){var Y=/[^.]+$/.exec(P&&P.keys&&P.keys.IE_PROTO||"");return Y?"Symbol(src)_1."+Y:""}(),k=I.toString,O=b.hasOwnProperty,L=b.toString,j=RegExp("^"+k.call(O).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),F=w.splice,$=Ae(l,"Map"),D=Ae(l,"Set"),N=Ae(Object,"create");function B(Y){var oe=-1,me=Y?Y.length:0;for(this.clear();++oe<me;){var we=Y[oe];this.set(we[0],we[1])}}function W(){this.__data__=N?N(null):{}}function G(Y){return this.has(Y)&&delete this.__data__[Y]}function z(Y){var oe=this.__data__;if(N){var me=oe[Y];return me===e?void 0:me}return O.call(oe,Y)?oe[Y]:void 0}function V(Y){var oe=this.__data__;return N?oe[Y]!==void 0:O.call(oe,Y)}function J(Y,oe){var me=this.__data__;return me[Y]=N&&oe===void 0?e:oe,this}B.prototype.clear=W,B.prototype.delete=G,B.prototype.get=z,B.prototype.has=V,B.prototype.set=J;function K(Y){var oe=-1,me=Y?Y.length:0;for(this.clear();++oe<me;){var we=Y[oe];this.set(we[0],we[1])}}function Z(){this.__data__=[]}function ee(Y){var oe=this.__data__,me=et(oe,Y);if(me<0)return!1;var we=oe.length-1;return me==we?oe.pop():F.call(oe,me,1),!0}function re(Y){var oe=this.__data__,me=et(oe,Y);return me<0?void 0:oe[me][1]}function te(Y){return et(this.__data__,Y)>-1}function le(Y,oe){var me=this.__data__,we=et(me,Y);return we<0?me.push([Y,oe]):me[we][1]=oe,this}K.prototype.clear=Z,K.prototype.delete=ee,K.prototype.get=re,K.prototype.has=te,K.prototype.set=le;function ge(Y){var oe=-1,me=Y?Y.length:0;for(this.clear();++oe<me;){var we=Y[oe];this.set(we[0],we[1])}}function se(){this.__data__={hash:new B,map:new($||K),string:new B}}function ce(Y){return ut(this,Y).delete(Y)}function _e(Y){return ut(this,Y).get(Y)}function Le(Y){return ut(this,Y).has(Y)}function Ge(Y,oe){return ut(this,Y).set(Y,oe),this}ge.prototype.clear=se,ge.prototype.delete=ce,ge.prototype.get=_e,ge.prototype.has=Le,ge.prototype.set=Ge;function qe(Y){var oe=-1,me=Y?Y.length:0;for(this.__data__=new ge;++oe<me;)this.add(Y[oe])}function mt(Y){return this.__data__.set(Y,e),this}function St(Y){return this.__data__.has(Y)}qe.prototype.add=qe.prototype.push=mt,qe.prototype.has=St;function et(Y,oe){for(var me=Y.length;me--;)if(Je(Y[me][0],oe))return me;return-1}function ct(Y){if(!cr(Y)||be(Y))return!1;var oe=Ye(Y)||x(Y)?j:s;return oe.test(it(Y))}function At(Y,oe,me){var we=-1,Oe=d,Ee=Y.length,dt=!0,$t=[],Pe=$t;if(Ee>=r){var $e=_t(Y);if($e)return _($e);dt=!1,Oe=m,Pe=new qe}else Pe=$t;e:for(;++we<Ee;){var Be=Y[we],We=Be;if(Be=Be!==0?Be:0,dt&&We===We){for(var yt=Pe.length;yt--;)if(Pe[yt]===We)continue e;$t.push(Be)}else Oe(Pe,We,me)||(Pe!==$t&&Pe.push(We),$t.push(Be))}return $t}var _t=D&&1/_(new D([,-0]))[1]==t?function(Y){return new D(Y)}:Sr;function ut(Y,oe){var me=Y.__data__;return ze(oe)?me[typeof oe=="string"?"string":"hash"]:me.map}function Ae(Y,oe){var me=y(Y,oe);return ct(me)?me:void 0}function ze(Y){var oe=typeof Y;return oe=="string"||oe=="number"||oe=="symbol"||oe=="boolean"?Y!=="__proto__":Y===null}function be(Y){return!!C&&C in Y}function it(Y){if(Y!=null){try{return k.call(Y)}catch{}try{return Y+""}catch{}}return""}function st(Y){return Y&&Y.length?At(Y):[]}function Je(Y,oe){return Y===oe||Y!==Y&&oe!==oe}function Ye(Y){var oe=cr(Y)?L.call(Y):"";return oe==n||oe==i}function cr(Y){var oe=typeof Y;return!!Y&&(oe=="object"||oe=="function")}function Sr(){}return Yx=st,Yx}var Cge=Pge();const Tge=cc(Cge);function FJ(r){const e=(...t)=>{try{return r(...t)}catch(n){throw n instanceof Error&&Error.captureStackTrace&&Error.captureStackTrace(n,e),n}};return e}const gh=()=>{},qi={ok(r){return{ok:!0,value:r}},err(r){return{ok:!1,error:r}}};function An(r,e){const t=e&&r&&typeof r=="object"&&e in r?r[e]:r;throw new Error(`Unknown switch case ${t}`)}const Jt=FJ((r,e)=>{if(!r)throw new Error(e||"Assertion Error")}),lo=FJ((r,e)=>{if(r==null)throw new Error(e??"value must be defined");return r});function AC(){let r,e;const t=new Promise((n,i)=>{r=n,e=i});return Object.assign(t,{resolve:r,reject:e})}function gP(r){return new Promise(e=>setTimeout(e,r))}const Xf={Good:"#40C057",Mid:"#FFC078",Poor:"#E03131"},Age=Xf.Good;class NJ{constructor(){q(this,"startTime",0);q(this,"name","");q(this,"frames",0);q(this,"started",!1);q(this,"frame",null);q(this,"recordFrame",()=>{this.frames++,this.started&&(this.frame=requestAnimationFrame(this.recordFrame))})}start(e){this.name=e,this.frames=0,this.started=!0,this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(this.recordFrame),this.startTime=performance.now()}stop(){this.started=!1,this.frame!==null&&cancelAnimationFrame(this.frame);const e=(performance.now()-this.startTime)/1e3,t=e===0?0:Math.floor(this.frames/e),n=t>55?Xf.Good:t>30?Xf.Mid:Xf.Poor,i=n===Xf.Mid?"black":"white",o=this.name[0].toUpperCase()+this.name.slice(1);console.debug(`%cPerf%c ${o} %c${t}%c fps`,`color: white; background: ${Age};padding: 2px;border-radius: 3px;`,"font-weight: normal",`font-weight: bold; padding: 2px; background: ${n};color: ${i};`,"font-weight: normal")}isStarted(){return this.started}}function RC(r,e){const t=[];e:for(const n of r){for(const i of t)if(e?e(n,i):n===i)continue e;t.push(n)}return t}function Gt(r){return r.filter(e=>e!=null)}function Zn(r){return r[r.length-1]}function Rge(r,e){let t,n=1/0;for(const i of r){const o=e(i);o<n&&(t=i,n=o)}return t}function kge(r,e){let t,n=-1/0;for(const i of r){const o=e(i);o>n&&(t=i,n=o)}return t}function $J(r,e){if(r===e)return!0;if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(!Object.is(r[t],e[t]))return!1;return!0}function Xx(r,e,t){const n=new Set(e.map(o=>o[r])),i=[];for(const o of t)n.has(o[r])||i.push(o);for(const o of e)i.push(o);return i}function po(...r){if(r.length===2){const[e,t]=r;t.addInitializer(function(){Jt(Reflect.isExtensible(this),"Cannot bind to a non-extensible class.");const i=e.bind(this),o=Reflect.defineProperty(this,t.name,{value:i,writable:!0,configurable:!0});Jt(o,"Cannot bind a non-configurable class method.")})}else{const[e,t,n]=r;if(!n||typeof n.value!="function")throw new TypeError(`Only methods can be decorated with @bind. <${t}> is not a method!`);return{configurable:!0,get(){const i=n.value.bind(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i}}}}class js{constructor(){q(this,"items",new WeakMap)}get(e,t){return this.items.has(e)||this.items.set(e,t(e)),this.items.get(e)}}function kC(r,e){let t;const n=(...i)=>(t||(t={},t.promise=new Promise((o,s)=>{t.resolve=o,t.reject=s})),clearTimeout(t.timeout),t.latestArgs=i,t.timeout=setTimeout(()=>{const o=t;t=void 0;try{o.resolve(r(...o.latestArgs))}catch(s){o.reject(s)}},e),t.promise);return n.cancel=()=>{t&&clearTimeout(t.timeout)},n}const sO=new WeakMap;function OC(r,e){if(typeof r!="object"||r===null)return;let t=sO.get(r);t||(t={tags:{},extras:{}},sO.set(r,t)),e.tags&&(t.tags={...t.tags,...e.tags}),e.extras&&(t.extras={...t.extras,...e.extras})}async function pa(r,e){return window.fetch(r,{referrerPolicy:"strict-origin-when-cross-origin",...e})}const vh=(r,e)=>{const t=new window.Image(r,e);return t.referrerPolicy="strict-origin-when-cross-origin",t};class ns{static async dataUrlToArrayBuffer(e){return pa(e).then(function(t){return t.arrayBuffer()})}static async blobToDataUrl(e){return await new Promise((t,n)=>{if(e){const i=new FileReader;i.onload=()=>t(i.result),i.onerror=o=>n(o),i.onabort=o=>n(o),i.readAsDataURL(e)}})}static async blobToText(e){return await new Promise((t,n)=>{if(e){const i=new FileReader;i.onload=()=>t(i.result),i.onerror=o=>n(o),i.onabort=o=>n(o),i.readAsText(e)}})}static rewriteMimeType(e,t){return e.type===t?e:e instanceof File?new File([e],e.name,{type:t}):new Blob([e],{type:t})}}function MC(r){let e=0;for(let t=0;t<r.length;t++)e=(e<<5)-e+r.charCodeAt(t),e|=0;return e+""}function qJ(r){const e=new DataView(r);let t=0;for(let n=0;n<e.byteLength;n++)t=(t<<5)-t+e.getUint8(n),t|=0;return t+""}/*!
45
- * MIT License: https://github.com/ai/nanoid/blob/main/LICENSE
46
- * Modified code originally from <https://github.com/ai/nanoid>
47
- * Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
48
- *
49
- * `nanoid` is currently only distributed as an ES module. Some tools (jest, playwright) don't
50
- * properly support ESM-only code yet, and tldraw itself is distributed as both an ES module and a
51
- * CommonJS module. By including nanoid here, we can make sure it works well in every environment
52
- * where tldraw is used. We can also remove some unused features like custom alphabets.
53
- */const aO=globalThis.crypto,Oge="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Mge=128;let ql,cd;function jge(r){!ql||ql.length<r?(ql=new Uint8Array(r*Mge),aO.getRandomValues(ql),cd=0):cd+r>ql.length&&(aO.getRandomValues(ql),cd=0),cd+=r}function Dge(r=21){jge(r-=0);let e="";for(let t=cd-r;t<cd;t++)e+=Oge[ql[t]&63];return e}let Lge=Dge;function Er(r){return Lge(r)}/*!
54
- * MIT License: https://github.com/vHeemstra/is-apng/blob/main/license
55
- * Copyright (c) Philip van Heemstra
56
- */function Fge(r){const e=new Uint8Array(r);if(!e||!(typeof Buffer<"u"&&Buffer.isBuffer(e)||e instanceof Uint8Array)||e.length<16||!(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10))return!1;function n(o,s,a,c,l=1024){if(!s)return-1;s=new RegExp(s,"g");const d=s.source.length,f=new TextDecoder,h=o.length;if(typeof c>"u"&&(c=h),a>=h||c<=0||a>=c)return-1;o=o.subarray(a,c);let g=-1,m=0,y=0,x="";e:for(;m<o.length;){const _=m+l,w=o.subarray(m,_),I=f.decode(w,{stream:!0}),b=x+I;let P,C=-1;for(;(P=s.exec(b))!==null;){C=P.index-x.length,g=y+C;break e}m=_,y+=I.length;const k=C>-1?C+d:I.length-d;x=I.slice(k)}return g>=0&&(g+=a>=0?a:h+a),g}const i=n(e,"IDAT",12);return i>=12?n(e,"acTL",8,i)>=8:!1}const Nge=r=>new Uint8Array(r)[3]===44;/*!
57
- * MIT License
58
- * Modified code originally from <https://github.com/qzb/is-animated>
59
- * Copyright (c) 2016 Józef Sokołowski <j.k.sokolowski@gmail.com>
60
- */function cO(r,e){let t=0;for(;r[e+t];)t+=r[e+t]+1;return t+1}function $ge(r){return new TextDecoder("ascii").decode(r.slice(0,3))==="GIF"}function qge(r){const e=new Uint8Array(r);let t,n,i=0,o=0;if(!$ge(r))return!1;for(t=e[10]&128,n=e[10]&7,i+=6,i+=7,i+=t?3*Math.pow(2,n+1):0;o<2&&i<e.length;)switch(e[i]){case 44:o+=1,t=e[i+9]&128,n=e[i+9]&7,i+=10,i+=t?3*Math.pow(2,n+1):0,i+=cO(e,i+1)+1;break;case 33:i+=2,i+=cO(e,i);break;case 59:i=e.length;break;default:i=e.length;break}return o>1}/*!
61
- * MIT License: https://github.com/alexgorbatchev/crc/blob/master/LICENSE
62
- * Copyright: 2014 Alex Gorbatchev
63
- * Code: crc32, https://github.com/alexgorbatchev/crc/blob/master/src/calculators/crc32.ts
64
- */let vP=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];typeof Int32Array<"u"&&(vP=new Int32Array(vP));const Bge=(r,e)=>{let t=-1;for(let n=0;n<r.length;n++)t=vP[(t^r[n])&255]^t>>>8;return t^-1},lO=4,uO=4;class sa{static isPng(e,t){return e.getUint8(t+0)===137&&e.getUint8(t+1)===80&&e.getUint8(t+2)===78&&e.getUint8(t+3)===71&&e.getUint8(t+4)===13&&e.getUint8(t+5)===10&&e.getUint8(t+6)===26&&e.getUint8(t+7)===10}static getChunkType(e,t){return[String.fromCharCode(e.getUint8(t)),String.fromCharCode(e.getUint8(t+1)),String.fromCharCode(e.getUint8(t+2)),String.fromCharCode(e.getUint8(t+3))].join("")}static readChunks(e,t=0){const n={};if(!sa.isPng(e,t))throw new Error("Not a PNG");for(t+=8;t<=e.buffer.byteLength;){const i=t,o=e.getInt32(t);t+=4;const s=sa.getChunkType(e,t);if(s==="IDAT"&&n[s]){t+=o+lO+uO;continue}if(s==="IEND")break;n[s]={start:i,dataOffset:t+4,size:o},t+=o+lO+uO}return n}static parsePhys(e,t){return{ppux:e.getUint32(t),ppuy:e.getUint32(t+4),unit:e.getUint8(t+4)}}static findChunk(e,t){return sa.readChunks(e)[t]}static setPhysChunk(e,t=1,n){let i=46,o=0;const s=sa.findChunk(e,"pHYs");s&&(i=s.start,o=s.size);const a=sa.findChunk(e,"IDAT");a&&(i=a.start,o=0);const c=new ArrayBuffer(21),l=new DataView(c);l.setUint32(0,9),l.setUint8(4,112),l.setUint8(5,72),l.setUint8(6,89),l.setUint8(7,115);const d=2835.5;l.setInt32(8,d*t),l.setInt32(12,d*t),l.setInt8(16,1);const f=new Uint8Array(c.slice(4,17));l.setInt32(17,Bge(f));const h=e.buffer.slice(0,i),g=e.buffer.slice(i+o);return new Blob([h,c,g],n)}}/*!
65
- * MIT License: https://github.com/sindresorhus/is-webp/blob/main/license
66
- * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
67
- */function Uge(r){return!r||r.length<12?!1:r[8]===87&&r[9]===69&&r[10]===66&&r[11]===80}function zge(r){const e=new Uint8Array(r);return!Uge(e)||!e||e.length<21?!1:(e[20]>>1&1)===1}const BJ=Object.freeze(["image/svg+xml"]),UJ=Object.freeze(["image/jpeg","image/png","image/webp"]),zJ=Object.freeze(["image/gif","image/apng","image/avif"]),Mh=Object.freeze([...UJ,...BJ,...zJ]),_m=Object.freeze(["video/mp4","video/webm","video/quicktime"]),Hge=[...Mh,..._m].join(",");class To{static loadVideo(e){return new Promise((t,n)=>{const i=document.createElement("video");i.onloadeddata=()=>t(i),i.onerror=o=>{console.error(o),n(new Error("Could not load video"))},i.crossOrigin="anonymous",i.src=e})}static async getVideoFrameAsDataUrl(e,t=0){const n=AC();let i=!1;const o=()=>{if(!i)if(e.readyState>=e.HAVE_METADATA)i=!0,e.currentTime=t;else return;if(e.readyState>=e.HAVE_CURRENT_DATA){const a=document.createElement("canvas");a.width=e.videoWidth,a.height=e.videoHeight;const c=a.getContext("2d");if(!c)throw new Error("Could not get 2d context");c.drawImage(e,0,0),n.resolve(a.toDataURL())}},s=a=>{console.error(a),n.reject(new Error("Could not get video frame"))};e.addEventListener("loadedmetadata",o),e.addEventListener("loadeddata",o),e.addEventListener("canplay",o),e.addEventListener("seeked",o),e.addEventListener("error",s),e.addEventListener("stalled",s),o();try{return await n}finally{e.removeEventListener("loadedmetadata",o),e.removeEventListener("loadeddata",o),e.removeEventListener("canplay",o),e.removeEventListener("seeked",o),e.removeEventListener("error",s),e.removeEventListener("stalled",s)}}static loadImage(e){return new Promise((t,n)=>{const i=vh();i.onload=()=>t(i),i.onerror=o=>{console.error(o),n(new Error("Could not load image"))},i.crossOrigin="anonymous",i.referrerPolicy="strict-origin-when-cross-origin",i.src=e})}static async getVideoSize(e){return To.usingObjectURL(e,async t=>{const n=await To.loadVideo(t);return{w:n.videoWidth,h:n.videoHeight}})}static async getImageSize(e){const t=await To.usingObjectURL(e,To.loadImage);try{if(e.type==="image/png"){const n=new DataView(await e.arrayBuffer());if(sa.isPng(n,0)){const i=sa.findChunk(n,"pHYs");if(i){const o=sa.parsePhys(n,i.dataOffset);if(o.unit===0&&o.ppux===o.ppuy){const a=Math.max(o.ppux/2834.645669291339,1);return{w:Math.round(t.naturalWidth/a),h:Math.round(t.naturalHeight/a)}}}}}}catch(n){return console.error(n),{w:t.naturalWidth,h:t.naturalHeight}}return{w:t.naturalWidth,h:t.naturalHeight}}static async isAnimated(e){return e.type==="image/gif"?qge(await e.arrayBuffer()):e.type==="image/avif"?Nge(await e.arrayBuffer()):e.type==="image/webp"?zge(await e.arrayBuffer()):e.type==="image/apng"?Fge(await e.arrayBuffer()):!1}static isAnimatedImageType(e){return zJ.includes(e||"")}static isStaticImageType(e){return UJ.includes(e||"")}static isVectorImageType(e){return BJ.includes(e||"")}static isImageType(e){return Mh.includes(e)}static async usingObjectURL(e,t){const n=URL.createObjectURL(e);try{return await t(n)}finally{URL.revokeObjectURL(n)}}}function or(r,e,t){return r+(e-r)*t}function Ds(r=""){let e=0,t=0,n=0,i=0;function o(){const s=e^e<<11;return e=t,t=n,n=i,i^=(i>>>19^s^s>>>8)>>>0,i/4294967296*2}for(let s=0;s<r.length+64;s++)e^=r.charCodeAt(s)|0,o();return o}function _d(r,e,t,n=!1){const[i,o]=e,[s,a]=t,c=s+(r-i)/(o-i)*(a-s);return n?s<a?Math.max(Math.min(c,a),s):Math.max(Math.min(c,s),a):c}function ss(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function bi(r,e){if(ss(r,e))return r[e]}function Wge(r){return Object.keys(r)}function Tn(r){return Object.values(r)}function Ro(r){return Object.entries(r)}function HJ(r){return Object.fromEntries(r)}function sh(r,e){const t={};let n=!1;for(const[i,o]of Ro(r))e(i,o)?t[i]=o:n=!0;return n?t:r}function jh(r,e){const t={};for(const[n,i]of Ro(r)){const o=e(n,i);t[n]=o}return t}function WJ(r,e){if(r===e)return!0;const t=new Set(Object.keys(r)),n=new Set(Object.keys(e));if(t.size!==n.size)return!1;for(const i of t)if(!n.has(i)||!Object.is(r[i],e[i]))return!1;return!0}function Kge(r){const e=Gge(r.chars),t=Vge(e,r.firstPositive,r.mostPositive,r.mostNegative),n=r.jitterRange??Math.floor(Math.pow(e.length,3)/5),i=Yge(n,e.length);return{chars:r.chars,byChar:e.byChar,byCode:e.byCode,length:e.length,first:e.byCode[0],last:e.byCode[e.length-1],firstPositive:t.firstPositive,mostPositive:t.mostPositive,firstNegative:t.firstNegative,mostNegative:t.mostNegative,jitterRange:n,paddingDict:i}}function Gge(r){const e={},t={},n=r.length;for(let i=0;i<n;i++){const o=r[i];e[i]=o,t[o]=i}return{byCode:e,byChar:t,length:n}}function Vge(r,e,t,n){const i=r.byChar[e],o=r.byChar[t],s=r.byChar[n];if(i===void 0||o===void 0||s===void 0)throw new Error("invalid charSet");if(o-i<3)throw new Error("mostPositive must be at least 3 characters away from neutral");if(i-s<3)throw new Error("mostNegative must be at least 3 characters away from neutral");return{firstPositive:r.byCode[i],mostPositive:r.byCode[o],firstNegative:r.byCode[i-1],mostNegative:r.byCode[s]}}function Yge(r,e){const t={};for(let n=0;n<100&&(t[n]=Math.pow(e,n),!(t[n]>r));n++);return t}var Zx=null;function jC(){return Zx||(Zx=Kge({chars:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",firstPositive:"a",mostPositive:"z",mostNegative:"A"}))}function Wc(r,e,t){const n=t.byChar[r],i=t.byChar[e];return Math.abs(n-i)}function DC(r,e){const t=r[0];if(t>e.mostPositive||t<e.mostNegative)throw new Error("invalid firstChar on key");return t===e.mostPositive?Wc(t,e.firstPositive,e)+1+Fv(r.slice(1),"positive",e):t===e.mostNegative?Wc(t,e.firstNegative,e)+1+Fv(r.slice(1),"negative",e):t>=e.firstPositive?Wc(t,e.firstPositive,e)+2:Wc(t,e.firstNegative,e)+2}function Fv(r,e,t){const n=r[0];if(n>t.mostPositive||n<t.mostNegative)throw new Error("invalid firstChar on key");return n===t.mostPositive&&e==="positive"?Wc(n,t.mostNegative,t)+1+Fv(r.slice(1),e,t):n===t.mostNegative&&e==="negative"?Wc(n,t.mostPositive,t)+1+Fv(r.slice(1),e,t):e==="positive"?Wc(n,t.mostNegative,t)+2:Wc(n,t.mostPositive,t)+2}function wm(r,e,t,n,i){const o=Math.max(r.length,e.length);return t==="start"?[r.padStart(o,n),e.padStart(o,n)]:[r.padEnd(o,n),e.padEnd(o,n)]}function Xge(r,e,t){let[n,i]=wm(r,e,"end",t.first),o=mP(n,i,t);o===1&&(n=n.padEnd(n.length+1,t.first),o=t.length);const s=VJ(Math.floor(o/2),t);return LC(n,s,t)}function mP(r,e,t){const[n,i]=wm(r,e,"end",t.first).sort(),o=KJ(i,n,t);return Zge(o,t)}function LC(r,e,t){const n=t.length,[i,o]=wm(r,e,"start",t.first),s=[];let a=0;for(let c=i.length-1;c>=0;c--){const l=t.byChar[i[c]],d=t.byChar[o[c]],f=l+d+a;a=Math.floor(f/n);const h=f%n;s.unshift(t.byCode[h])}return a>0&&s.unshift(t.byCode[a]),s.join("")}function KJ(r,e,t){const n=t.length,[i,o]=wm(r,e,"start",t.first),s=[];let a=0;for(let c=i.length-1;c>=0;c--){let l=t.byChar[i[c]];const d=t.byChar[o[c]]+a;l<d?(a=1,l+=n):a=0;const f=l-d;s.unshift(t.byCode[f])}if(a>0)throw new Error("Subtraction result is negative. Ensure a is greater than or equal to b.");for(;s.length>1&&s[0]===t.byCode[0];)s.shift();return s.join("")}function GJ(r,e){return LC(r,e.byCode[1],e)}function yP(r,e){return KJ(r,e.byCode[1],e)}function VJ(r,e){if(r===0)return e.byCode[0];let t="";const n=e.length;for(;r>0;)t=e.byCode[r%n]+t,r=Math.floor(r/n);return t}function Zge(r,e){let t=0;const n=r.length,i=e.length;for(let o=0;o<n;o++)t+=e.byChar[r[o]]*Math.pow(i,n-o-1);return t}function Qge(r){return r.firstPositive+r.byCode[0]}function Jge(r,e){return DC(r,e)===r.length}function dO(r,e){Nv(r,e)}function Nv(r,e){const t=ZJ(r,e),n=DC(t,e);if(n>r.length)throw new Error("invalid order key length: "+r);return r.slice(0,n)}function YJ(r,e){if(!Jge(r,e))throw new Error("invalid integer length: "+r)}function XJ(r,e){YJ(r,e);const[t,n]=QJ(r,e);if(n.split("").some(s=>s!==e.byCode[e.length-1])){const s=GJ(n,e);return t+s}const o=tve(t,e);return JJ(o,"lower",e)}function eve(r,e){YJ(r,e);const[t,n]=QJ(r,e);if(n.split("").some(s=>s!==e.byCode[0])){const s=yP(n,e);return t+s}const o=rve(t,e);return JJ(o,"upper",e)}function ZJ(r,e){let t=0;if(r[0]===e.mostPositive)for(;r[t]===e.mostPositive;)t=t+1;if(r[0]===e.mostNegative)for(;r[t]===e.mostNegative;)t=t+1;return r.slice(0,t+1)}function QJ(r,e){const t=ZJ(r,e),n=r.slice(t.length);return[t,n]}function tve(r,e){const t=r>=e.firstPositive,n=GJ(r,e),i=r[r.length-1]===e.mostPositive,o=n[n.length-1]===e.mostPositive;return t&&o?n+e.mostNegative:!t&&i?r.slice(0,r.length-1):n}function rve(r,e){const t=r>=e.firstPositive,n=r[r.length-1]===e.mostNegative;if(t&&n){const i=r.slice(0,r.length-1);return yP(i,e)}return!t&&n?r+e.mostPositive:yP(r,e)}function JJ(r,e,t){const n=DC(r,t),i=e==="upper"?t.byCode[t.length-1]:t.byCode[0];return r+i.repeat(n-r.length)}function eee(r,e){const t=VJ(Math.floor(Math.random()*e.jitterRange),e);return LC(r,t,e)}function nve(r,e,t){const n=r.padEnd(r.length+e,t.first);return eee(n,t)}function ive(r,e,t){const n=Nv(r,t),i=XJ(n,t);let o=0;if(e!==null){const a=mP(r,e,t);a<t.jitterRange+1&&(o=Math.max(o,fO(a,t)))}const s=mP(r,i,t);return s<t.jitterRange+1&&(o=Math.max(o,fO(s,t))),o}function fO(r,e){const t=e.jitterRange-r,n=Object.entries(e.paddingDict).find(([i,o])=>o>t);return n?parseInt(n[0]):0}function ove(r,e,t=jC()){if(r!==null&&dO(r,t),e!==null&&dO(e,t),r===null&&e===null)return Qge(t);if(r===null){const n=Nv(e,t);return eve(n,t)}if(e===null){const n=Nv(r,t);return XJ(n,t)}if(r>=e)throw new Error(r+" >= "+e);return Xge(r,e,t)}function tee(r,e,t=jC()){const n=ove(r,e,t),i=ive(n,e,t);return i?nve(n,i,t):eee(n,t)}function ree(r,e,t,n=jC()){return sve(r,e,t,n,tee,ree)}function sve(r,e,t,n,i,o){if(t===0)return[];if(t===1)return[i(r,e,n)];if(e==null){let c=i(r,e,n);const l=[c];for(let d=0;d<t-1;d++)c=i(c,e,n),l.push(c);return l}if(r==null){let c=i(r,e,n);const l=[c];for(let d=0;d<t-1;d++)c=i(r,c,n),l.push(c);return l.reverse(),l}const s=Math.floor(t/2),a=i(r,e,n);return[...o(r,a,s,n),a,...o(a,e,t-s-1,n)]}const Rd=ree,nee="a0";function ave(r){try{tee(r,null)}catch{throw new Error("invalid index: "+r)}}function wd(r,e,t){return Rd(r??null,e??null,t)}function Qx(r,e){return Rd(r??null,null,e)}function mh(r,e){return Rd(r??null,e??null,1)[0]}function ca(r=null){return Rd(r,null,1)[0]}function cve(r=null){return Rd(null,r,1)[0]}function yh(r,e="a1"){return[e,...Rd(e,null,r)]}function _i(r,e){return r.index<e.index?-1:r.index>e.index?1:0}function lve(r,e){return r.id>e.id?1:-1}function FC(r){try{return localStorage.getItem(r)}catch{return null}}function NC(r,e){try{localStorage.setItem(r,e)}catch{}}function uve(){try{localStorage.clear()}catch{}}function iee(r){try{return sessionStorage.getItem(r)}catch{return null}}function $C(r,e){try{sessionStorage.setItem(r,e)}catch{}}function oee(r){try{sessionStorage.removeItem(r)}catch{}}function dve(){try{sessionStorage.clear()}catch{}}const ld=[],fve=60,nv=Math.ceil(1e3/fve);let Df,Jx=0,SP=0;const hve=()=>{const r=ld.splice(0,ld.length);for(const e of r)e()};function see(){if(Df)return;const r=Date.now(),e=r-SP;if(Jx+e<nv){Df=requestAnimationFrame(()=>{Df=void 0,see()});return}Df=requestAnimationFrame(()=>{Df=void 0,SP=r,Jx=Math.min(Jx+e-nv,nv*10),hve()})}let hO=!1;function aee(r){return ld.includes(r)||(ld.push(r),hO||(hO=!0,SP=Date.now()-nv-1),see()),()=>{const e=ld.indexOf(r);e>-1&&ld.splice(e,1)}}class pve{constructor(){q(this,"timeouts",new Map);q(this,"intervals",new Map);q(this,"rafs",new Map);this.setTimeout=this.setTimeout.bind(this),this.setInterval=this.setInterval.bind(this),this.requestAnimationFrame=this.requestAnimationFrame.bind(this),this.dispose=this.dispose.bind(this)}setTimeout(e,t,n,...i){const o=window.setTimeout(t,n,i),s=this.timeouts.get(e)??[];return this.timeouts.set(e,[...s,o]),o}setInterval(e,t,n,...i){const o=window.setInterval(t,n,i),s=this.intervals.get(e)??[];return this.intervals.set(e,[...s,o]),o}requestAnimationFrame(e,t){const n=window.requestAnimationFrame(t),i=this.rafs.get(e)??[];return this.rafs.set(e,[...i,n]),n}dispose(e){var t,n,i;(t=this.timeouts.get(e))==null||t.forEach(o=>clearTimeout(o)),(n=this.intervals.get(e))==null||n.forEach(o=>clearInterval(o)),(i=this.rafs.get(e))==null||i.forEach(o=>cancelAnimationFrame(o)),this.timeouts.delete(e),this.intervals.delete(e),this.rafs.delete(e)}disposeAll(){for(const e of this.timeouts.keys())this.dispose(e)}forContext(e){return{setTimeout:(t,n,...i)=>this.setTimeout(e,t,n,i),setInterval:(t,n,...i)=>this.setInterval(e,t,n,i),requestAnimationFrame:t=>this.requestAnimationFrame(e,t),dispose:()=>this.dispose(e)}}}const Ft=(r,e)=>{try{return new URL(r,e)}catch{return}};function gve(r){return r!==void 0}function vve(){return typeof globalThis<"u"&&globalThis.structuredClone?[globalThis.structuredClone,!0]:typeof global<"u"&&global.structuredClone?[global.structuredClone,!0]:typeof window<"u"&&window.structuredClone?[window.structuredClone,!0]:[r=>r&&JSON.parse(JSON.stringify(r)),!1]}const cee=vve(),Kr=cee[0];cee[1];const mve=Object.getPrototypeOf(Kr({}));il("@tldraw/utils","3.9.0","esm");var pO={},Lf,gO;function Xe(){if(gO)return Lf;gO=1;var r=function(e){return e&&e.Math===Math&&e};return Lf=r(typeof globalThis=="object"&&globalThis)||r(typeof window=="object"&&window)||r(typeof self=="object"&&self)||r(typeof ho=="object"&&ho)||r(typeof Lf=="object"&&Lf)||function(){return this}()||Function("return this")(),Lf}var e_={},t_,vO;function Fe(){return vO||(vO=1,t_=function(r){try{return!!r()}catch{return!0}}),t_}var r_,mO;function Et(){if(mO)return r_;mO=1;var r=Fe();return r_=!r(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),r_}var n_,yO;function Dh(){if(yO)return n_;yO=1;var r=Fe();return n_=!r(function(){var e=(function(){}).bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),n_}var i_,SO;function Qe(){if(SO)return i_;SO=1;var r=Dh(),e=Function.prototype.call;return i_=r?e.bind(e):function(){return e.apply(e,arguments)},i_}var o_={},xO;function bm(){if(xO)return o_;xO=1;var r={}.propertyIsEnumerable,e=Object.getOwnPropertyDescriptor,t=e&&!r.call({1:2},1);return o_.f=t?function(i){var o=e(this,i);return!!o&&o.enumerable}:r,o_}var s_,_O;function No(){return _O||(_O=1,s_=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}),s_}var a_,wO;function Ie(){if(wO)return a_;wO=1;var r=Dh(),e=Function.prototype,t=e.call,n=r&&e.bind.bind(t,t);return a_=r?n:function(i){return function(){return t.apply(i,arguments)}},a_}var c_,bO;function Ci(){if(bO)return c_;bO=1;var r=Ie(),e=r({}.toString),t=r("".slice);return c_=function(n){return t(e(n),8,-1)},c_}var l_,EO;function ol(){if(EO)return l_;EO=1;var r=Ie(),e=Fe(),t=Ci(),n=Object,i=r("".split);return l_=e(function(){return!n("z").propertyIsEnumerable(0)})?function(o){return t(o)==="String"?i(o,""):n(o)}:n,l_}var u_,IO;function Mn(){return IO||(IO=1,u_=function(r){return r==null}),u_}var d_,PO;function qr(){if(PO)return d_;PO=1;var r=Mn(),e=TypeError;return d_=function(t){if(r(t))throw new e("Can't call method on "+t);return t},d_}var f_,CO;function jn(){if(CO)return f_;CO=1;var r=ol(),e=qr();return f_=function(t){return r(e(t))},f_}var h_,TO;function Ut(){if(TO)return h_;TO=1;var r=typeof document=="object"&&document.all;return h_=typeof r>"u"&&r!==void 0?function(e){return typeof e=="function"||e===r}:function(e){return typeof e=="function"},h_}var p_,AO;function Lt(){if(AO)return p_;AO=1;var r=Ut();return p_=function(e){return typeof e=="object"?e!==null:r(e)},p_}var g_,RO;function Mt(){if(RO)return g_;RO=1;var r=Xe(),e=Ut(),t=function(n){return e(n)?n:void 0};return g_=function(n,i){return arguments.length<2?t(r[n]):r[n]&&r[n][i]},g_}var v_,kO;function Ti(){if(kO)return v_;kO=1;var r=Ie();return v_=r({}.isPrototypeOf),v_}var m_,OO;function wa(){if(OO)return m_;OO=1;var r=Xe(),e=r.navigator,t=e&&e.userAgent;return m_=t?String(t):"",m_}var y_,MO;function ba(){if(MO)return y_;MO=1;var r=Xe(),e=wa(),t=r.process,n=r.Deno,i=t&&t.versions||n&&n.version,o=i&&i.v8,s,a;return o&&(s=o.split("."),a=s[0]>0&&s[0]<4?1:+(s[0]+s[1])),!a&&e&&(s=e.match(/Edge\/(\d+)/),(!s||s[1]>=74)&&(s=e.match(/Chrome\/(\d+)/),s&&(a=+s[1]))),y_=a,y_}var S_,jO;function ou(){if(jO)return S_;jO=1;var r=ba(),e=Fe(),t=Xe(),n=t.String;return S_=!!Object.getOwnPropertySymbols&&!e(function(){var i=Symbol("symbol detection");return!n(i)||!(Object(i)instanceof Symbol)||!Symbol.sham&&r&&r<41}),S_}var x_,DO;function lee(){if(DO)return x_;DO=1;var r=ou();return x_=r&&!Symbol.sham&&typeof Symbol.iterator=="symbol",x_}var __,LO;function sl(){if(LO)return __;LO=1;var r=Mt(),e=Ut(),t=Ti(),n=lee(),i=Object;return __=n?function(o){return typeof o=="symbol"}:function(o){var s=r("Symbol");return e(s)&&t(s.prototype,i(o))},__}var w_,FO;function su(){if(FO)return w_;FO=1;var r=String;return w_=function(e){try{return r(e)}catch{return"Object"}},w_}var b_,NO;function jt(){if(NO)return b_;NO=1;var r=Ut(),e=su(),t=TypeError;return b_=function(n){if(r(n))return n;throw new t(e(n)+" is not a function")},b_}var E_,$O;function bn(){if($O)return E_;$O=1;var r=jt(),e=Mn();return E_=function(t,n){var i=t[n];return e(i)?void 0:r(i)},E_}var I_,qO;function uee(){if(qO)return I_;qO=1;var r=Qe(),e=Ut(),t=Lt(),n=TypeError;return I_=function(i,o){var s,a;if(o==="string"&&e(s=i.toString)&&!t(a=r(s,i))||e(s=i.valueOf)&&!t(a=r(s,i))||o!=="string"&&e(s=i.toString)&&!t(a=r(s,i)))return a;throw new n("Can't convert object to primitive value")},I_}var P_={exports:{}},C_,BO;function Xt(){return BO||(BO=1,C_=!1),C_}var T_,UO;function qC(){if(UO)return T_;UO=1;var r=Xe(),e=Object.defineProperty;return T_=function(t,n){try{e(r,t,{value:n,configurable:!0,writable:!0})}catch{r[t]=n}return n},T_}var zO;function Em(){if(zO)return P_.exports;zO=1;var r=Xt(),e=Xe(),t=qC(),n="__core-js_shared__",i=P_.exports=e[n]||t(n,{});return(i.versions||(i.versions=[])).push({version:"3.41.0",mode:r?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.41.0/LICENSE",source:"https://github.com/zloirock/core-js"}),P_.exports}var A_,HO;function al(){if(HO)return A_;HO=1;var r=Em();return A_=function(e,t){return r[e]||(r[e]=t||{})},A_}var R_,WO;function Zt(){if(WO)return R_;WO=1;var r=qr(),e=Object;return R_=function(t){return e(r(t))},R_}var k_,KO;function Kt(){if(KO)return k_;KO=1;var r=Ie(),e=Zt(),t=r({}.hasOwnProperty);return k_=Object.hasOwn||function(i,o){return t(e(i),o)},k_}var O_,GO;function au(){if(GO)return O_;GO=1;var r=Ie(),e=0,t=Math.random(),n=r(1 .toString);return O_=function(i){return"Symbol("+(i===void 0?"":i)+")_"+n(++e+t,36)},O_}var M_,VO;function Tt(){if(VO)return M_;VO=1;var r=Xe(),e=al(),t=Kt(),n=au(),i=ou(),o=lee(),s=r.Symbol,a=e("wks"),c=o?s.for||s:s&&s.withoutSetter||n;return M_=function(l){return t(a,l)||(a[l]=i&&t(s,l)?s[l]:c("Symbol."+l)),a[l]},M_}var j_,YO;function Im(){if(YO)return j_;YO=1;var r=Qe(),e=Lt(),t=sl(),n=bn(),i=uee(),o=Tt(),s=TypeError,a=o("toPrimitive");return j_=function(c,l){if(!e(c)||t(c))return c;var d=n(c,a),f;if(d){if(l===void 0&&(l="default"),f=r(d,c,l),!e(f)||t(f))return f;throw new s("Can't convert object to primitive value")}return l===void 0&&(l="number"),i(c,l)},j_}var D_,XO;function lc(){if(XO)return D_;XO=1;var r=Im(),e=sl();return D_=function(t){var n=r(t,"string");return e(n)?n:n+""},D_}var L_,ZO;function Pm(){if(ZO)return L_;ZO=1;var r=Xe(),e=Lt(),t=r.document,n=e(t)&&e(t.createElement);return L_=function(i){return n?t.createElement(i):{}},L_}var F_,QO;function dee(){if(QO)return F_;QO=1;var r=Et(),e=Fe(),t=Pm();return F_=!r&&!e(function(){return Object.defineProperty(t("div"),"a",{get:function(){return 7}}).a!==7}),F_}var JO;function ni(){if(JO)return e_;JO=1;var r=Et(),e=Qe(),t=bm(),n=No(),i=jn(),o=lc(),s=Kt(),a=dee(),c=Object.getOwnPropertyDescriptor;return e_.f=r?c:function(d,f){if(d=i(d),f=o(f),a)try{return c(d,f)}catch{}if(s(d,f))return n(!e(t.f,d,f),d[f])},e_}var N_={},$_,eM;function fee(){if(eM)return $_;eM=1;var r=Et(),e=Fe();return $_=r&&e(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),$_}var q_,tM;function Ze(){if(tM)return q_;tM=1;var r=Lt(),e=String,t=TypeError;return q_=function(n){if(r(n))return n;throw new t(e(n)+" is not an object")},q_}var rM;function Or(){if(rM)return N_;rM=1;var r=Et(),e=dee(),t=fee(),n=Ze(),i=lc(),o=TypeError,s=Object.defineProperty,a=Object.getOwnPropertyDescriptor,c="enumerable",l="configurable",d="writable";return N_.f=r?t?function(h,g,m){if(n(h),g=i(g),n(m),typeof h=="function"&&g==="prototype"&&"value"in m&&d in m&&!m[d]){var y=a(h,g);y&&y[d]&&(h[g]=m.value,m={configurable:l in m?m[l]:y[l],enumerable:c in m?m[c]:y[c],writable:!1})}return s(h,g,m)}:s:function(h,g,m){if(n(h),g=i(g),n(m),e)try{return s(h,g,m)}catch{}if("get"in m||"set"in m)throw new o("Accessors not supported");return"value"in m&&(h[g]=m.value),h},N_}var B_,nM;function Dn(){if(nM)return B_;nM=1;var r=Et(),e=Or(),t=No();return B_=r?function(n,i,o){return e.f(n,i,t(1,o))}:function(n,i,o){return n[i]=o,n},B_}var U_={exports:{}},z_,iM;function kd(){if(iM)return z_;iM=1;var r=Et(),e=Kt(),t=Function.prototype,n=r&&Object.getOwnPropertyDescriptor,i=e(t,"name"),o=i&&(function(){}).name==="something",s=i&&(!r||r&&n(t,"name").configurable);return z_={EXISTS:i,PROPER:o,CONFIGURABLE:s},z_}var H_,oM;function Cm(){if(oM)return H_;oM=1;var r=Ie(),e=Ut(),t=Em(),n=r(Function.toString);return e(t.inspectSource)||(t.inspectSource=function(i){return n(i)}),H_=t.inspectSource,H_}var W_,sM;function hee(){if(sM)return W_;sM=1;var r=Xe(),e=Ut(),t=r.WeakMap;return W_=e(t)&&/native code/.test(String(t)),W_}var K_,aM;function Tm(){if(aM)return K_;aM=1;var r=al(),e=au(),t=r("keys");return K_=function(n){return t[n]||(t[n]=e(n))},K_}var G_,cM;function Lh(){return cM||(cM=1,G_={}),G_}var V_,lM;function _r(){if(lM)return V_;lM=1;var r=hee(),e=Xe(),t=Lt(),n=Dn(),i=Kt(),o=Em(),s=Tm(),a=Lh(),c="Object already initialized",l=e.TypeError,d=e.WeakMap,f,h,g,m=function(w){return g(w)?h(w):f(w,{})},y=function(w){return function(I){var b;if(!t(I)||(b=h(I)).type!==w)throw new l("Incompatible receiver, "+w+" required");return b}};if(r||o.state){var x=o.state||(o.state=new d);x.get=x.get,x.has=x.has,x.set=x.set,f=function(w,I){if(x.has(w))throw new l(c);return I.facade=w,x.set(w,I),I},h=function(w){return x.get(w)||{}},g=function(w){return x.has(w)}}else{var _=s("state");a[_]=!0,f=function(w,I){if(i(w,_))throw new l(c);return I.facade=w,n(w,_,I),I},h=function(w){return i(w,_)?w[_]:{}},g=function(w){return i(w,_)}}return V_={set:f,get:h,has:g,enforce:m,getterFor:y},V_}var uM;function Am(){if(uM)return U_.exports;uM=1;var r=Ie(),e=Fe(),t=Ut(),n=Kt(),i=Et(),o=kd().CONFIGURABLE,s=Cm(),a=_r(),c=a.enforce,l=a.get,d=String,f=Object.defineProperty,h=r("".slice),g=r("".replace),m=r([].join),y=i&&!e(function(){return f(function(){},"length",{value:8}).length!==8}),x=String(String).split("String"),_=U_.exports=function(w,I,b){h(d(I),0,7)==="Symbol("&&(I="["+g(d(I),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),b&&b.getter&&(I="get "+I),b&&b.setter&&(I="set "+I),(!n(w,"name")||o&&w.name!==I)&&(i?f(w,"name",{value:I,configurable:!0}):w.name=I),y&&b&&n(b,"arity")&&w.length!==b.arity&&f(w,"length",{value:b.arity});try{b&&n(b,"constructor")&&b.constructor?i&&f(w,"prototype",{writable:!1}):w.prototype&&(w.prototype=void 0)}catch{}var P=c(w);return n(P,"source")||(P.source=m(x,typeof I=="string"?I:"")),w};return Function.prototype.toString=_(function(){return t(this)&&l(this).source||s(this)},"toString"),U_.exports}var Y_,dM;function wr(){if(dM)return Y_;dM=1;var r=Ut(),e=Or(),t=Am(),n=qC();return Y_=function(i,o,s,a){a||(a={});var c=a.enumerable,l=a.name!==void 0?a.name:o;if(r(s)&&t(s,l,a),a.global)c?i[o]=s:n(o,s);else{try{a.unsafe?i[o]&&(c=!0):delete i[o]}catch{}c?i[o]=s:e.f(i,o,{value:s,enumerable:!1,configurable:!a.nonConfigurable,writable:!a.nonWritable})}return i},Y_}var X_={},Z_,fM;function pee(){if(fM)return Z_;fM=1;var r=Math.ceil,e=Math.floor;return Z_=Math.trunc||function(n){var i=+n;return(i>0?e:r)(i)},Z_}var Q_,hM;function Vr(){if(hM)return Q_;hM=1;var r=pee();return Q_=function(e){var t=+e;return t!==t||t===0?0:r(t)},Q_}var J_,pM;function Ea(){if(pM)return J_;pM=1;var r=Vr(),e=Math.max,t=Math.min;return J_=function(n,i){var o=r(n);return o<0?e(o+i,0):t(o,i)},J_}var ew,gM;function $o(){if(gM)return ew;gM=1;var r=Vr(),e=Math.min;return ew=function(t){var n=r(t);return n>0?e(n,9007199254740991):0},ew}var tw,vM;function sr(){if(vM)return tw;vM=1;var r=$o();return tw=function(e){return r(e.length)},tw}var rw,mM;function Fh(){if(mM)return rw;mM=1;var r=jn(),e=Ea(),t=sr(),n=function(i){return function(o,s,a){var c=r(o),l=t(c);if(l===0)return!i&&-1;var d=e(a,l),f;if(i&&s!==s){for(;l>d;)if(f=c[d++],f!==f)return!0}else for(;l>d;d++)if((i||d in c)&&c[d]===s)return i||d||0;return!i&&-1}};return rw={includes:n(!0),indexOf:n(!1)},rw}var nw,yM;function gee(){if(yM)return nw;yM=1;var r=Ie(),e=Kt(),t=jn(),n=Fh().indexOf,i=Lh(),o=r([].push);return nw=function(s,a){var c=t(s),l=0,d=[],f;for(f in c)!e(i,f)&&e(c,f)&&o(d,f);for(;a.length>l;)e(c,f=a[l++])&&(~n(d,f)||o(d,f));return d},nw}var iw,SM;function BC(){return SM||(SM=1,iw=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),iw}var xM;function cu(){if(xM)return X_;xM=1;var r=gee(),e=BC(),t=e.concat("length","prototype");return X_.f=Object.getOwnPropertyNames||function(i){return r(i,t)},X_}var ow={},_M;function Rm(){return _M||(_M=1,ow.f=Object.getOwnPropertySymbols),ow}var sw,wM;function UC(){if(wM)return sw;wM=1;var r=Mt(),e=Ie(),t=cu(),n=Rm(),i=Ze(),o=e([].concat);return sw=r("Reflect","ownKeys")||function(a){var c=t.f(i(a)),l=n.f;return l?o(c,l(a)):c},sw}var aw,bM;function Od(){if(bM)return aw;bM=1;var r=Kt(),e=UC(),t=ni(),n=Or();return aw=function(i,o,s){for(var a=e(o),c=n.f,l=t.f,d=0;d<a.length;d++){var f=a[d];!r(i,f)&&!(s&&r(s,f))&&c(i,f,l(o,f))}},aw}var cw,EM;function Nh(){if(EM)return cw;EM=1;var r=Fe(),e=Ut(),t=/#|\.prototype\./,n=function(c,l){var d=o[i(c)];return d===a?!0:d===s?!1:e(l)?r(l):!!l},i=n.normalize=function(c){return String(c).replace(t,".").toLowerCase()},o=n.data={},s=n.NATIVE="N",a=n.POLYFILL="P";return cw=n,cw}var lw,IM;function H(){if(IM)return lw;IM=1;var r=Xe(),e=ni().f,t=Dn(),n=wr(),i=qC(),o=Od(),s=Nh();return lw=function(a,c){var l=a.target,d=a.global,f=a.stat,h,g,m,y,x,_;if(d?g=r:f?g=r[l]||i(l,{}):g=r[l]&&r[l].prototype,g)for(m in c){if(x=c[m],a.dontCallGetSet?(_=e(g,m),y=_&&_.value):y=g[m],h=s(d?m:l+(f?".":"#")+m,a.forced),!h&&y!==void 0){if(typeof x==typeof y)continue;o(x,y)}(a.sham||y&&y.sham)&&t(x,"sham",!0),n(g,m,x,a)}},lw}var uw={},dw,PM;function Md(){if(PM)return dw;PM=1;var r=gee(),e=BC();return dw=Object.keys||function(n){return r(n,e)},dw}var CM;function zC(){if(CM)return uw;CM=1;var r=Et(),e=fee(),t=Or(),n=Ze(),i=jn(),o=Md();return uw.f=r&&!e?Object.defineProperties:function(a,c){n(a);for(var l=i(c),d=o(c),f=d.length,h=0,g;f>h;)t.f(a,g=d[h++],l[g]);return a},uw}var fw,TM;function vee(){if(TM)return fw;TM=1;var r=Mt();return fw=r("document","documentElement"),fw}var hw,AM;function En(){if(AM)return hw;AM=1;var r=Ze(),e=zC(),t=BC(),n=Lh(),i=vee(),o=Pm(),s=Tm(),a=">",c="<",l="prototype",d="script",f=s("IE_PROTO"),h=function(){},g=function(w){return c+d+a+w+c+"/"+d+a},m=function(w){w.write(g("")),w.close();var I=w.parentWindow.Object;return w=null,I},y=function(){var w=o("iframe"),I="java"+d+":",b;return w.style.display="none",i.appendChild(w),w.src=String(I),b=w.contentWindow.document,b.open(),b.write(g("document.F=Object")),b.close(),b.F},x,_=function(){try{x=new ActiveXObject("htmlfile")}catch{}_=typeof document<"u"?document.domain&&x?m(x):y():m(x);for(var w=t.length;w--;)delete _[l][t[w]];return _()};return n[f]=!0,hw=Object.create||function(I,b){var P;return I!==null?(h[l]=r(I),P=new h,h[l]=null,P[f]=I):P=_(),b===void 0?P:e.f(P,b)},hw}var pw,RM;function sn(){if(RM)return pw;RM=1;var r=Tt(),e=En(),t=Or().f,n=r("unscopables"),i=Array.prototype;return i[n]===void 0&&t(i,n,{configurable:!0,value:e(null)}),pw=function(o){i[n][o]=!0},pw}var kM;function HC(){if(kM)return pO;kM=1;var r=H(),e=Zt(),t=sr(),n=Vr(),i=sn();return r({target:"Array",proto:!0},{at:function(s){var a=e(this),c=t(a),l=n(s),d=l>=0?l:c+l;return d<0||d>=c?void 0:a[d]}}),i("at"),pO}var gw,OM;function $h(){if(OM)return gw;OM=1;var r=Xe(),e=Ie();return gw=function(t,n){return e(r[t].prototype[n])},gw}var vw,MM;function yve(){if(MM)return vw;MM=1,HC();var r=$h();return vw=r("Array","at"),vw}var mw,jM;function Sve(){if(jM)return mw;jM=1;var r=yve();return mw=r,mw}Sve();var DM={},yw,LM;function Ia(){if(LM)return yw;LM=1;var r=Ci();return yw=Array.isArray||function(t){return r(t)==="Array"},yw}var Sw,FM;function lu(){if(FM)return Sw;FM=1;var r=TypeError,e=9007199254740991;return Sw=function(t){if(t>e)throw r("Maximum allowed index exceeded");return t},Sw}var xw,NM;function uu(){if(NM)return xw;NM=1;var r=Ci(),e=Ie();return xw=function(t){if(r(t)==="Function")return e(t)},xw}var _w,$M;function Ar(){if($M)return _w;$M=1;var r=uu(),e=jt(),t=Dh(),n=r(r.bind);return _w=function(i,o){return e(i),o===void 0?i:t?n(i,o):function(){return i.apply(o,arguments)}},_w}var ww,qM;function mee(){if(qM)return ww;qM=1;var r=Ia(),e=sr(),t=lu(),n=Ar(),i=function(o,s,a,c,l,d,f,h){for(var g=l,m=0,y=f?n(f,h):!1,x,_;m<c;)m in a&&(x=y?y(a[m],m,s):a[m],d>0&&r(x)?(_=e(x),g=i(o,s,x,_,g,d-1)-1):(t(g+1),o[g]=x),g++),m++;return g};return ww=i,ww}var bw,BM;function WC(){if(BM)return bw;BM=1;var r=Tt(),e=r("toStringTag"),t={};return t[e]="z",bw=String(t)==="[object z]",bw}var Ew,UM;function vo(){if(UM)return Ew;UM=1;var r=WC(),e=Ut(),t=Ci(),n=Tt(),i=n("toStringTag"),o=Object,s=t(function(){return arguments}())==="Arguments",a=function(c,l){try{return c[l]}catch{}};return Ew=r?t:function(c){var l,d,f;return c===void 0?"Undefined":c===null?"Null":typeof(d=a(l=o(c),i))=="string"?d:s?t(l):(f=t(l))==="Object"&&e(l.callee)?"Arguments":f},Ew}var Iw,zM;function Pa(){if(zM)return Iw;zM=1;var r=Ie(),e=Fe(),t=Ut(),n=vo(),i=Mt(),o=Cm(),s=function(){},a=i("Reflect","construct"),c=/^\s*(?:class|function)\b/,l=r(c.exec),d=!c.test(s),f=function(m){if(!t(m))return!1;try{return a(s,[],m),!0}catch{return!1}},h=function(m){if(!t(m))return!1;switch(n(m)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return d||!!l(c,o(m))}catch{return!0}};return h.sham=!0,Iw=!a||e(function(){var g;return f(f.call)||!f(Object)||!f(function(){g=!0})||g})?h:f,Iw}var Pw,HM;function xve(){if(HM)return Pw;HM=1;var r=Ia(),e=Pa(),t=Lt(),n=Tt(),i=n("species"),o=Array;return Pw=function(s){var a;return r(s)&&(a=s.constructor,e(a)&&(a===o||r(a.prototype))?a=void 0:t(a)&&(a=a[i],a===null&&(a=void 0))),a===void 0?o:a},Pw}var Cw,WM;function qh(){if(WM)return Cw;WM=1;var r=xve();return Cw=function(e,t){return new(r(e))(t===0?0:t)},Cw}var KM;function yee(){if(KM)return DM;KM=1;var r=H(),e=mee(),t=jt(),n=Zt(),i=sr(),o=qh();return r({target:"Array",proto:!0},{flatMap:function(a){var c=n(this),l=i(c),d;return t(a),d=o(c,0),d.length=e(d,c,c,l,0,1,a,arguments.length>1?arguments[1]:void 0),d}}),DM}var GM={},VM;function See(){if(VM)return GM;VM=1;var r=sn();return r("flatMap"),GM}var Tw,YM;function _ve(){if(YM)return Tw;YM=1,yee(),See();var r=$h();return Tw=r("Array","flatMap"),Tw}var Aw,XM;function wve(){if(XM)return Aw;XM=1;var r=_ve();return Aw=r,Aw}wve();var ZM={},QM;function xee(){if(QM)return ZM;QM=1;var r=H(),e=mee(),t=Zt(),n=sr(),i=Vr(),o=qh();return r({target:"Array",proto:!0},{flat:function(){var a=arguments.length?arguments[0]:void 0,c=t(this),l=n(c),d=o(c,0);return d.length=e(d,c,c,l,0,a===void 0?1:i(a)),d}}),ZM}var JM={},ej;function _ee(){if(ej)return JM;ej=1;var r=sn();return r("flat"),JM}var Rw,tj;function bve(){if(tj)return Rw;tj=1,xee(),_ee();var r=$h();return Rw=r("Array","flat"),Rw}var kw,rj;function Eve(){if(rj)return kw;rj=1;var r=bve();return kw=r,kw}Eve();var nj={},Ow,ij;function Nt(){if(ij)return Ow;ij=1;var r=vo(),e=String;return Ow=function(t){if(r(t)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return e(t)},Ow}var oj;function wee(){if(oj)return nj;oj=1;var r=H(),e=Ie(),t=qr(),n=Vr(),i=Nt(),o=Fe(),s=e("".charAt),a=o(function(){return"𠮷".at(-2)!=="\uD842"});return r({target:"String",proto:!0,forced:a},{at:function(l){var d=i(t(this)),f=d.length,h=n(l),g=h>=0?h:f+h;return g<0||g>=f?void 0:s(d,g)}}),nj}var Mw,sj;function Ive(){if(sj)return Mw;sj=1,wee();var r=$h();return Mw=r("String","at"),Mw}var jw,aj;function Pve(){if(aj)return jw;aj=1;var r=Ive();return jw=r,jw}Pve();var cj={},Dw,lj;function KC(){if(lj)return Dw;lj=1;var r=Ze();return Dw=function(){var e=r(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Dw}var Lw,uj;function km(){if(uj)return Lw;uj=1;var r=Fe(),e=Xe(),t=e.RegExp,n=r(function(){var s=t("a","y");return s.lastIndex=2,s.exec("abcd")!==null}),i=n||r(function(){return!t("a","y").sticky}),o=n||r(function(){var s=t("^r","gy");return s.lastIndex=2,s.exec("str")!==null});return Lw={BROKEN_CARET:o,MISSED_STICKY:i,UNSUPPORTED_Y:n},Lw}var Fw,dj;function GC(){if(dj)return Fw;dj=1;var r=Fe(),e=Xe(),t=e.RegExp;return Fw=r(function(){var n=t(".","s");return!(n.dotAll&&n.test(`
68
- `)&&n.flags==="s")}),Fw}var Nw,fj;function bee(){if(fj)return Nw;fj=1;var r=Fe(),e=Xe(),t=e.RegExp;return Nw=r(function(){var n=t("(?<a>b)","g");return n.exec("b").groups.a!=="b"||"b".replace(n,"$<a>c")!=="bc"}),Nw}var $w,hj;function VC(){if(hj)return $w;hj=1;var r=Qe(),e=Ie(),t=Nt(),n=KC(),i=km(),o=al(),s=En(),a=_r().get,c=GC(),l=bee(),d=o("native-string-replace",String.prototype.replace),f=RegExp.prototype.exec,h=f,g=e("".charAt),m=e("".indexOf),y=e("".replace),x=e("".slice),_=function(){var P=/a/,C=/b*/g;return r(f,P,"a"),r(f,C,"a"),P.lastIndex!==0||C.lastIndex!==0}(),w=i.BROKEN_CARET,I=/()??/.exec("")[1]!==void 0,b=_||I||w||c||l;return b&&(h=function(C){var k=this,O=a(k),L=t(C),j=O.raw,F,$,D,N,B,W,G;if(j)return j.lastIndex=k.lastIndex,F=r(h,j,L),k.lastIndex=j.lastIndex,F;var z=O.groups,V=w&&k.sticky,J=r(n,k),K=k.source,Z=0,ee=L;if(V&&(J=y(J,"y",""),m(J,"g")===-1&&(J+="g"),ee=x(L,k.lastIndex),k.lastIndex>0&&(!k.multiline||k.multiline&&g(L,k.lastIndex-1)!==`
69
- `)&&(K="(?: "+K+")",ee=" "+ee,Z++),$=new RegExp("^(?:"+K+")",J)),I&&($=new RegExp("^"+K+"$(?!\\s)",J)),_&&(D=k.lastIndex),N=r(f,V?$:k,ee),V?N?(N.input=x(N.input,Z),N[0]=x(N[0],Z),N.index=k.lastIndex,k.lastIndex+=N[0].length):k.lastIndex=0:_&&N&&(k.lastIndex=k.global?N.index+N[0].length:D),I&&N&&N.length>1&&r(d,N[0],$,function(){for(B=1;B<arguments.length-2;B++)arguments[B]===void 0&&(N[B]=void 0)}),N&&z)for(N.groups=W=s(null),B=0;B<z.length;B++)G=z[B],W[G[0]]=N[G[1]];return N}),$w=h,$w}var pj;function Om(){if(pj)return cj;pj=1;var r=H(),e=VC();return r({target:"RegExp",proto:!0,forced:/./.exec!==e},{exec:e}),cj}var gj={},qw,vj;function zi(){if(vj)return qw;vj=1;var r=Dh(),e=Function.prototype,t=e.apply,n=e.call;return qw=typeof Reflect=="object"&&Reflect.apply||(r?n.bind(t):function(){return n.apply(t,arguments)}),qw}var Bw,mj;function Mm(){if(mj)return Bw;mj=1,Om();var r=Qe(),e=wr(),t=VC(),n=Fe(),i=Tt(),o=Dn(),s=i("species"),a=RegExp.prototype;return Bw=function(c,l,d,f){var h=i(c),g=!n(function(){var _={};return _[h]=function(){return 7},""[c](_)!==7}),m=g&&!n(function(){var _=!1,w=/a/;return c==="split"&&(w={},w.constructor={},w.constructor[s]=function(){return w},w.flags="",w[h]=/./[h]),w.exec=function(){return _=!0,null},w[h](""),!_});if(!g||!m||d){var y=/./[h],x=l(h,""[c],function(_,w,I,b,P){var C=w.exec;return C===t||C===a.exec?g&&!P?{done:!0,value:r(y,w,I,b)}:{done:!0,value:r(_,I,w,b)}:{done:!1}});e(String.prototype,c,x[0]),e(a,h,x[1])}f&&o(a[h],"sham",!0)},Bw}var Uw,yj;function jd(){if(yj)return Uw;yj=1;var r=Ie(),e=Vr(),t=Nt(),n=qr(),i=r("".charAt),o=r("".charCodeAt),s=r("".slice),a=function(c){return function(l,d){var f=t(n(l)),h=e(d),g=f.length,m,y;return h<0||h>=g?c?"":void 0:(m=o(f,h),m<55296||m>56319||h+1===g||(y=o(f,h+1))<56320||y>57343?c?i(f,h):m:c?s(f,h,h+2):(m-55296<<10)+(y-56320)+65536)}};return Uw={codeAt:a(!1),charAt:a(!0)},Uw}var zw,Sj;function jm(){if(Sj)return zw;Sj=1;var r=jd().charAt;return zw=function(e,t,n){return t+(n?r(e,t).length:1)},zw}var Hw,xj;function Eee(){if(xj)return Hw;xj=1;var r=Ie(),e=Zt(),t=Math.floor,n=r("".charAt),i=r("".replace),o=r("".slice),s=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,a=/\$([$&'`]|\d{1,2})/g;return Hw=function(c,l,d,f,h,g){var m=d+c.length,y=f.length,x=a;return h!==void 0&&(h=e(h),x=s),i(g,x,function(_,w){var I;switch(n(w,0)){case"$":return"$";case"&":return c;case"`":return o(l,0,d);case"'":return o(l,m);case"<":I=h[o(w,1,-1)];break;default:var b=+w;if(b===0)return _;if(b>y){var P=t(b/10);return P===0?_:P<=y?f[P-1]===void 0?n(w,1):f[P-1]+n(w,1):_}I=f[b-1]}return I===void 0?"":I})},Hw}var Ww,_j;function Bh(){if(_j)return Ww;_j=1;var r=Qe(),e=Ze(),t=Ut(),n=Ci(),i=VC(),o=TypeError;return Ww=function(s,a){var c=s.exec;if(t(c)){var l=r(c,s,a);return l!==null&&e(l),l}if(n(s)==="RegExp")return r(i,s,a);throw new o("RegExp#exec called on incompatible receiver")},Ww}var wj;function Iee(){if(wj)return gj;wj=1;var r=zi(),e=Qe(),t=Ie(),n=Mm(),i=Fe(),o=Ze(),s=Ut(),a=Mn(),c=Vr(),l=$o(),d=Nt(),f=qr(),h=jm(),g=bn(),m=Eee(),y=Bh(),x=Tt(),_=x("replace"),w=Math.max,I=Math.min,b=t([].concat),P=t([].push),C=t("".indexOf),k=t("".slice),O=function($){return $===void 0?$:String($)},L=function(){return"a".replace(/./,"$0")==="$0"}(),j=function(){return/./[_]?/./[_]("a","$0")==="":!1}(),F=!i(function(){var $=/./;return $.exec=function(){var D=[];return D.groups={a:"7"},D},"".replace($,"$<a>")!=="7"});return n("replace",function($,D,N){var B=j?"$":"$0";return[function(G,z){var V=f(this),J=a(G)?void 0:g(G,_);return J?e(J,G,V,z):e(D,d(V),G,z)},function(W,G){var z=o(this),V=d(W);if(typeof G=="string"&&C(G,B)===-1&&C(G,"$<")===-1){var J=N(D,z,V,G);if(J.done)return J.value}var K=s(G);K||(G=d(G));var Z=z.global,ee;Z&&(ee=z.unicode,z.lastIndex=0);for(var re=[],te;te=y(z,V),!(te===null||(P(re,te),!Z));){var le=d(te[0]);le===""&&(z.lastIndex=h(V,l(z.lastIndex),ee))}for(var ge="",se=0,ce=0;ce<re.length;ce++){te=re[ce];for(var _e=d(te[0]),Le=w(I(c(te.index),V.length),0),Ge=[],qe,mt=1;mt<te.length;mt++)P(Ge,O(te[mt]));var St=te.groups;if(K){var et=b([_e],Ge,Le,V);St!==void 0&&P(et,St),qe=d(r(G,void 0,et))}else qe=m(_e,V,Le,Ge,St,G);Le>=se&&(ge+=k(V,se,Le)+qe,se=Le+_e.length)}return ge+k(V,se)}]},!F||!L||j),gj}var bj={},Kw,Ej;function Dm(){if(Ej)return Kw;Ej=1;var r=Lt(),e=Ci(),t=Tt(),n=t("match");return Kw=function(i){var o;return r(i)&&((o=i[n])!==void 0?!!o:e(i)==="RegExp")},Kw}var Gw,Ij;function Uh(){if(Ij)return Gw;Ij=1;var r=Qe(),e=Kt(),t=Ti(),n=KC(),i=RegExp.prototype;return Gw=function(o){var s=o.flags;return s===void 0&&!("flags"in i)&&!e(o,"flags")&&t(i,o)?r(n,o):s},Gw}var Pj;function YC(){if(Pj)return bj;Pj=1;var r=H(),e=Qe(),t=Ie(),n=qr(),i=Ut(),o=Mn(),s=Dm(),a=Nt(),c=bn(),l=Uh(),d=Eee(),f=Tt(),h=Xt(),g=f("replace"),m=TypeError,y=t("".indexOf),x=t("".replace),_=t("".slice),w=Math.max;return r({target:"String",proto:!0},{replaceAll:function(b,P){var C=n(this),k,O,L,j,F,$,D,N,B,W,G=0,z="";if(!o(b)){if(k=s(b),k&&(O=a(n(l(b))),!~y(O,"g")))throw new m("`.replaceAll` does not allow non-global regexes");if(L=c(b,g),L)return e(L,b,C,P);if(h&&k)return x(a(C),b,P)}for(j=a(C),F=a(b),$=i(P),$||(P=a(P)),D=F.length,N=w(1,D),B=y(j,F);B!==-1;)W=$?a(P(F,B,j)):d(F,j,B,[],void 0,P),z+=_(j,G,B)+W,G=B+D,B=B+N>j.length?-1:y(j,F,B+N);return G<j.length&&(z+=_(j,G)),z}}),bj}var Vw,Cj;function Cve(){if(Cj)return Vw;Cj=1,Om(),Iee(),YC();var r=$h();return Vw=r("String","replaceAll"),Vw}var Yw,Tj;function Tve(){if(Tj)return Yw;Tj=1;var r=Cve();return Yw=r,Yw}Tve();function Pee(r){return r&&typeof r=="object"&&"parents"in r}function Cee(r){for(let e=0,t=r.parents.length;e<t;e++)if(r.parents[e].__unsafe__getWithoutCapture(!0),r.parents[e].lastChangedEpoch!==r.parentEpochs[e])return!0;return!1}function $v(r,e){if(r.children.remove(e)&&r.children.isEmpty&&Pee(r))for(let t=0,n=r.parents.length;t<n;t++)$v(r.parents[t],r)}function XC(r,e){if(r.children.add(e)&&Pee(r))for(let t=0,n=r.parents.length;t<n;t++)XC(r.parents[t],r)}function Tee(r,e){return r===e||Object.is(r,e)||!!(r&&e&&typeof r.equals=="function"&&r.equals(e))}function cl(r,e){const t=Symbol.for(`com.tldraw.state/${r}`),n=globalThis;return n[t]??(n[t]=e()),n[t]}const ec=cl("empty_array",()=>Object.freeze([])),Aj=8;class qv{constructor(){q(this,"arraySize",0);q(this,"array",Array(Aj));q(this,"set",null)}get isEmpty(){if(this.array)return this.arraySize===0;if(this.set)return this.set.size===0;throw new Error("no set or array")}add(e){if(this.array)return this.array.indexOf(e)!==-1?!1:this.arraySize<Aj?(this.array[this.arraySize]=e,this.arraySize++,!0):(this.set=new Set(this.array),this.array=null,this.set.add(e),!0);if(this.set)return this.set.has(e)?!1:(this.set.add(e),!0);throw new Error("no set or array")}remove(e){if(this.array){const t=this.array.indexOf(e);return t===-1?!1:(this.array[t]=void 0,this.arraySize--,t!==this.arraySize&&(this.array[t]=this.array[this.arraySize],this.array[this.arraySize]=void 0),!0)}if(this.set)return this.set.has(e)?(this.set.delete(e),!0):!1;throw new Error("no set or array")}visit(e){if(this.array){for(let t=0;t<this.arraySize;t++){const n=this.array[t];typeof n<"u"&&e(n)}return}if(this.set){this.set.forEach(e);return}throw new Error("no set or array")}has(e){return this.array?this.array.indexOf(e)!==-1:this.set.has(e)}clear(){this.set?this.set.clear():(this.arraySize=0,this.array=[])}size(){return this.set?this.set.size:this.arraySize}}const ko=Symbol.for("com.tldraw.state/RESET_VALUE");class Aee{constructor(e){q(this,"index",0);q(this,"buffer");this.capacity=e,this.buffer=new Array(e)}pushEntry(e,t,n){if(n!==void 0){if(n===ko){this.clear();return}this.buffer[this.index]=[e,t,n],this.index=(this.index+1)%this.capacity}}clear(){this.index=0,this.buffer.fill(void 0)}getChangesSince(e){const{index:t,capacity:n,buffer:i}=this;for(let o=0;o<n;o++){const s=(t-1+n-o)%n,a=i[s];if(!a)return ko;const[c,l]=a;if(o===0&&e>=l)return[];if(c<=e&&e<l){const d=o+1,f=new Array(d);for(let h=0;h<d;h++)f[h]=i[(s+h)%n][2];return f}}return ko}}class Ave{constructor(e,t){q(this,"offset",0);q(this,"maybeRemoved");this.below=e,this.child=t}}const Zr=cl("capture",()=>({stack:null}));function xg(r){const e=Zr.stack;Zr.stack=null;try{return r()}finally{Zr.stack=e}}function Ree(r){Zr.stack=new Ave(Zr.stack,r),r.parentSet.clear()}function kee(){const r=Zr.stack;if(Zr.stack=r.below,r.offset<r.child.parents.length){for(let e=r.offset;e<r.child.parents.length;e++){const t=r.child.parents[e];r.child.parentSet.has(t)||$v(t,r.child)}r.child.parents.length=r.offset,r.child.parentEpochs.length=r.offset}if(r.maybeRemoved)for(let e=0;e<r.maybeRemoved.length;e++){const t=r.maybeRemoved[e];r.child.parentSet.has(t)||$v(t,r.child)}}function Bv(r){if(Zr.stack){if(Zr.stack.child.parentSet.has(r))return;if(Zr.stack.child.parentSet.add(r),Zr.stack.child.isActivelyListening&&XC(r,Zr.stack.child),Zr.stack.offset<Zr.stack.child.parents.length){const t=Zr.stack.child.parents[Zr.stack.offset];t!==r&&(Zr.stack.maybeRemoved?Zr.stack.maybeRemoved.push(t):Zr.stack.maybeRemoved=[t])}Zr.stack.child.parents[Zr.stack.offset]=r,Zr.stack.child.parentEpochs[Zr.stack.offset]=r.lastChangedEpoch,Zr.stack.offset++}}const Kc=-1;class Rve{constructor(e,t,n){q(this,"_isActivelyListening",!1);q(this,"lastTraversedEpoch",Kc);q(this,"lastReactedEpoch",Kc);q(this,"_scheduleCount",0);q(this,"parentSet",new qv);q(this,"parentEpochs",[]);q(this,"parents",[]);q(this,"_scheduleEffect");q(this,"maybeExecute",()=>{this._isActivelyListening&&this.execute()});this.name=e,this.runEffect=t,this._scheduleEffect=n==null?void 0:n.scheduleEffect}get isActivelyListening(){return this._isActivelyListening}get scheduleCount(){return this._scheduleCount}maybeScheduleEffect(){if(this._isActivelyListening&&this.lastReactedEpoch!==ao()){if(this.parents.length&&!Cee(this)){this.lastReactedEpoch=ao();return}this.scheduleEffect()}}scheduleEffect(){this._scheduleCount++,this._scheduleEffect?this._scheduleEffect(this.maybeExecute):this.execute()}attach(){this._isActivelyListening=!0;for(let e=0,t=this.parents.length;e<t;e++)XC(this.parents[e],this)}detach(){this._isActivelyListening=!1;for(let e=0,t=this.parents.length;e<t;e++)$v(this.parents[e],this)}execute(){try{Ree(this);const e=ao(),t=this.runEffect(this.lastReactedEpoch);return this.lastReactedEpoch=e,t}finally{kee()}}}const Dd=cl("EffectScheduler",()=>Rve);function fa(r,e,t){const n=new Dd(r,e,t);return n.attach(),n.scheduleEffect(),()=>{n.detach()}}function kve(r,e,t){const n=new Dd(r,e,t);return{scheduler:n,start:i=>{const o=(i==null?void 0:i.force)??!1;n.attach(),o?n.scheduleEffect():n.maybeScheduleEffect()},stop:()=>{n.detach()}}}class Ove{constructor(e){q(this,"initialAtomValues",new Map);this.parent=e}get isRoot(){return this.parent===null}commit(){if(yr.globalIsReacting)for(const e of this.initialAtomValues.keys())Mee(e);else this.isRoot?Oee(this.initialAtomValues.keys()):this.initialAtomValues.forEach((e,t)=>{this.parent.initialAtomValues.has(t)||this.parent.initialAtomValues.set(t,e)})}abort(){yr.globalEpoch++,this.initialAtomValues.forEach((e,t)=>{var n;t.set(e),(n=t.historyBuffer)==null||n.clear()}),this.commit()}}const yr=cl("transactions",()=>({globalEpoch:Kc+1,globalIsReacting:!1,currentTransaction:null,cleanupReactors:null,reactionEpoch:Kc+1}));function Mve(){return yr.reactionEpoch}function ao(){return yr.globalEpoch}function jve(){return yr.globalIsReacting}function ZC(r,e){e.lastTraversedEpoch!==yr.globalEpoch&&(e.lastTraversedEpoch=yr.globalEpoch,e instanceof Dd?r.add(e):e.children.visit(t=>ZC(r,t)))}function Oee(r){var t;if(yr.globalIsReacting)throw new Error("flushChanges cannot be called during a reaction");const e=yr.currentTransaction;try{yr.currentTransaction=null,yr.globalIsReacting=!0,yr.reactionEpoch=yr.globalEpoch;const n=new Set;for(const o of r)o.children.visit(s=>ZC(n,s));for(const o of n)o.maybeScheduleEffect();let i=0;for(;(t=yr.cleanupReactors)!=null&&t.size;){if(i++>1e3)throw new Error("Reaction update depth limit exceeded");const o=yr.cleanupReactors;yr.cleanupReactors=null;for(const s of o)s.maybeScheduleEffect()}}finally{yr.cleanupReactors=null,yr.globalIsReacting=!1,yr.currentTransaction=e}}function Dve(r,e){yr.currentTransaction?yr.currentTransaction.initialAtomValues.has(r)||yr.currentTransaction.initialAtomValues.set(r,e):yr.globalIsReacting?Mee(r):Oee([r])}function Mee(r){const e=yr.cleanupReactors??(yr.cleanupReactors=new Set);r.children.visit(t=>ZC(e,t))}function Lve(){yr.globalEpoch++}function Fve(r){const e=new Ove(yr.currentTransaction);yr.currentTransaction=e;try{let t,n=!1;try{t=r(()=>n=!0)}catch(i){throw e.abort(),i}return n?e.abort():e.commit(),t}finally{yr.currentTransaction=yr.currentTransaction.parent}}function Ui(r){return yr.currentTransaction?r():Fve(r)}class Nve{constructor(e,t,n){q(this,"isEqual");q(this,"computeDiff");q(this,"lastChangedEpoch",ao());q(this,"children",new qv);q(this,"historyBuffer");this.name=e,this.current=t,this.isEqual=(n==null?void 0:n.isEqual)??null,n&&(n.historyLength&&(this.historyBuffer=new Aee(n.historyLength)),this.computeDiff=n.computeDiff)}__unsafe__getWithoutCapture(e){return this.current}get(){return Bv(this),this.current}set(e,t){var i,o;if(((i=this.isEqual)==null?void 0:i.call(this,this.current,e))??Tee(this.current,e))return this.current;Lve(),this.historyBuffer&&this.historyBuffer.pushEntry(this.lastChangedEpoch,ao(),t??((o=this.computeDiff)==null?void 0:o.call(this,this.current,e,this.lastChangedEpoch,ao()))??ko),this.lastChangedEpoch=ao();const n=this.current;return this.current=e,Dve(this,n),e}update(e){return this.set(e(this.current))}getDiffSince(e){var t;return Bv(this),e>=this.lastChangedEpoch?ec:((t=this.historyBuffer)==null?void 0:t.getChangesSince(e))??ko}}const $ve=cl("Atom",()=>Nve);function xn(r,e,t){return new $ve(r,e,t)}let Rj=!1;function qve(){Rj||(Rj=!0,console.warn(`Using \`@computed\` as a decorator for getters is deprecated and will be removed in the near future. Please refactor to use \`@computed\` as a decorator for methods.
70
-
71
- // Before
72
- @computed
73
- get foo() {
74
- return 'foo'
75
- }
76
-
77
- // After
78
- @computed
79
- getFoo() {
80
- return 'foo'
81
- }
82
- `))}const yi=Symbol.for("com.tldraw.state/UNINITIALIZED");function zl(r){return r===yi}const xP=cl("WithDiff",()=>class{constructor(e,t){this.value=e,this.diff=t}});function Zf(r,e){return new xP(r,e)}class Bve{constructor(e,t,n){q(this,"lastChangedEpoch",Kc);q(this,"lastTraversedEpoch",Kc);q(this,"lastCheckedEpoch",Kc);q(this,"parentSet",new qv);q(this,"parents",[]);q(this,"parentEpochs",[]);q(this,"children",new qv);q(this,"historyBuffer");q(this,"state",yi);q(this,"error",null);q(this,"computeDiff");q(this,"isEqual");this.name=e,this.derive=t,n!=null&&n.historyLength&&(this.historyBuffer=new Aee(n.historyLength)),this.computeDiff=n==null?void 0:n.computeDiff,this.isEqual=(n==null?void 0:n.isEqual)??Tee}get isActivelyListening(){return!this.children.isEmpty}__unsafe__getWithoutCapture(e){var i;const t=this.lastChangedEpoch===Kc,n=ao();if(!t&&(this.lastCheckedEpoch===n||this.isActivelyListening&&jve()&&this.lastTraversedEpoch<Mve()||!Cee(this)))if(this.lastCheckedEpoch=n,this.error){if(e)return this.state;throw this.error.thrownValue}else return this.state;try{Ree(this);const o=this.derive(this.state,this.lastCheckedEpoch),s=o instanceof xP?o.value:o,a=this.state===yi;if(a||!this.isEqual(s,this.state)){if(this.historyBuffer&&!a){const c=o instanceof xP?o.diff:void 0;this.historyBuffer.pushEntry(this.lastChangedEpoch,ao(),c??((i=this.computeDiff)==null?void 0:i.call(this,this.state,s,this.lastCheckedEpoch,ao()))??ko)}this.lastChangedEpoch=ao(),this.state=s}return this.error=null,this.lastCheckedEpoch=ao(),this.state}catch(o){if(this.state!==yi&&(this.state=yi,this.lastChangedEpoch=ao()),this.lastCheckedEpoch=ao(),this.historyBuffer&&this.historyBuffer.clear(),this.error={thrownValue:o},!e)throw o;return this.state}finally{kee()}}get(){try{return this.__unsafe__getWithoutCapture()}finally{Bv(this)}}getDiffSince(e){var t;return this.__unsafe__getWithoutCapture(!0),Bv(this),e>=this.lastChangedEpoch?ec:((t=this.historyBuffer)==null?void 0:t.getChangesSince(e))??ko}}const Lm=cl("Computed",()=>Bve);function Uve(r={},e,t,n){const i=n.value,o=Symbol.for("__@tldraw/state__computed__"+t);return n.value=function(){let s=this[o];return s||(s=new Lm(t,i.bind(this),r),Object.defineProperty(this,o,{enumerable:!1,configurable:!1,writable:!1,value:s})),s.get()},n.value[jee]=!0,n}function zve(r={},e,t,n){const i=n.get,o=Symbol.for("__@tldraw/state__computed__"+t);return n.get=function(){let s=this[o];return s||(s=new Lm(t,i.bind(this),r),Object.defineProperty(this,o,{enumerable:!1,configurable:!1,writable:!1,value:s})),s.get()},n}function Hve(r,e,t){Jt(t.kind==="method","@computed can only be used on methods");const n=Symbol.for("__@tldraw/state__computed__"+String(t.name)),i=function(){let o=this[n];return o||(o=new Lm(String(t.name),e.bind(this),r),Object.defineProperty(this,n,{enumerable:!1,configurable:!1,writable:!1,value:o})),o.get()};return i[jee]=!0,i}function kj(r={},e){if(e.length===2){const[t,n]=e;return Hve(r,t,n)}else{const[t,n,i]=e;return i.get?(qve(),zve(r,t,n,i)):Uve(r,t,n,i)}}const jee="@@__isComputedMethod__@@";function Te(){if(arguments.length===1){const r=arguments[0];return(...e)=>kj(r,e)}else return typeof arguments[0]=="string"?new Lm(arguments[0],arguments[1],arguments[2]):kj(void 0,arguments)}const Dee=1,Wve=cl("apiVersion",()=>Dee);if(Wve!==Dee)throw new Error("You have multiple incompatible versions of @tldraw/state in your app. Please deduplicate the package.");il("@tldraw/state","3.9.0","esm");function Fm(r,e,t=[]){const n=lr.useRef(e);n.current=e;const[i,o,s]=lr.useMemo(()=>{let a=null;const c=f=>(a=f,()=>{a=null}),l=new Dd(`useStateTracking(${r})`,()=>{var f;return(f=n.current)==null?void 0:f.call(n)},{scheduleEffect(){a==null||a()}});return[l,c,()=>l.scheduleCount]},[r,...t]);return lr.useSyncExternalStore(o,s,s),lr.useEffect(()=>(i.attach(),i.maybeScheduleEffect(),()=>{i.detach()}),[i]),i.execute()}const Oj={apply(r,e,t){return Fm(r.displayName??r.name??"tracked(???)",()=>r.apply(e,t))}},Kve=Symbol.for("react.memo"),Gve=Symbol.for("react.forward_ref");function ii(r){let e=null;const t=r.$$typeof;return t===Kve&&(r=r.type,e=r.compare),t===Gve?A.memo(A.forwardRef(new Proxy(r.render,Oj))):A.memo(new Proxy(r,Oj),e)}function QC(r,e,t){return A.useState(()=>{const n=typeof e=="function"?e():e;return xn(`useAtom(${r})`,n,t)})[0]}function Vve(){const r=arguments[0],e=arguments[1],t=arguments.length===3?void 0:arguments[2],n=arguments.length===3?arguments[2]:arguments[3];return A.useMemo(()=>Te(`useComputed(${r})`,e,t),n)}function Vc(r,e,t=ec){A.useEffect(()=>{const n=new Dd(r,e);return n.attach(),n.execute(),()=>{n.detach()}},t)}function ye(){const r=arguments,e=r.length===3?r[2]:[r[0]],t=r.length===3?r[0]:`useValue(${r[0].name})`,n=A.useRef(!0);n.current=!0;const i=A.useMemo(()=>r.length===1?r[0]:Te(t,()=>{if(n.current)return r[1]();try{return r[1]()}catch{return{}}}),e);try{const{subscribe:o,getSnapshot:s}=A.useMemo(()=>({subscribe:a=>fa(`useValue(${t})`,()=>{i.get(),a()}),getSnapshot:()=>i.get()}),[i]);return A.useSyncExternalStore(o,s,s)}finally{n.current=!1}}il("@tldraw/state-react","3.9.0","esm");const zn={linear:r=>r,easeInQuad:r=>r*r,easeOutQuad:r=>r*(2-r),easeInOutQuad:r=>r<.5?2*r*r:-1+(4-2*r)*r,easeInCubic:r=>r*r*r,easeOutCubic:r=>--r*r*r+1,easeInOutCubic:r=>r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1,easeInQuart:r=>r*r*r*r,easeOutQuart:r=>1- --r*r*r*r,easeInOutQuart:r=>r<.5?8*r*r*r*r:1-8*--r*r*r*r,easeInQuint:r=>r*r*r*r*r,easeOutQuint:r=>1+--r*r*r*r*r,easeInOutQuint:r=>r<.5?16*r*r*r*r*r:1+16*--r*r*r*r*r,easeInSine:r=>1-Math.cos(r*Math.PI/2),easeOutSine:r=>Math.sin(r*Math.PI/2),easeInOutSine:r=>-(Math.cos(Math.PI*r)-1)/2,easeInExpo:r=>r<=0?0:Math.pow(2,10*r-10),easeOutExpo:r=>r>=1?1:1-Math.pow(2,-10*r),easeInOutExpo:r=>r<=0?0:r>=1?1:r<.5?Math.pow(2,20*r-10)/2:(2-Math.pow(2,-20*r+10))/2};function vr(r){return`${fe(r.x)},${fe(r.y)} `}function uo(r,e){return`${fe((r.x+e.x)/2)},${fe((r.y+e.y)/2)} `}const hr=Math.PI,Nr=hr/2,Cr=hr*2,Yve=Math.sin;function Yn(r,e,t){return Math.max(e,typeof t<"u"?Math.min(r,t):r)}function _g(r,e=1e10){return r?Math.round(r*e)/e:0}function Yc(r,e,t=1e-6){return Math.abs(r-e)<=t}function Lee(r,e){const t=Math.pow(r-e,2)/Math.pow(r+e,2);return hr*(r+e)*(1+3*t/(10+Math.sqrt(4-3*t)))}function Hl(r){return r=r%Cr,r<0?r=r+Cr:r===0&&(r=0),r}function zh(r,e){return r=Hl(r),e=Hl(e),r>e&&(e+=Cr),e-r}function Fee(r,e){return Cr-zh(r,e)}function iv(r,e){const t=(e-r)%Cr;return 2*t%Cr-t}function _P(r){return(Cr+r)%Cr}function Uv(r,e){const t=Cr/e;let n=Math.floor((_P(r)+t/2)/t)*t%Cr;return n<hr&&(n+=Cr),n>hr&&(n-=Cr),n}function Nee(r,e){return r===e||Yc(r%(Math.PI/2)-e%(Math.PI/2),0)}function Xve(r){return r*hr/180}function Zve(r){return r*180/hr}function Gl(r,e,t){return new T(r.x,r.y).add(T.FromAngle(t,e))}function Xw(r,e,t){const n=r/2,i=e/2,o=[];let s=1/0,a=-1/0,c=1/0,l=-1/0;for(let m=0;m<t;m++){const y=Cr/t,x=-Nr+m*y,_=n+n*Math.cos(x),w=i+i*Math.sin(x);_<s&&(s=_),w<c&&(c=w),_>a&&(a=_),w>l&&(l=w),o.push(new T(_,w))}const d=a-s,f=l-c,h=r-d,g=e-f;if(h!==0||g!==0)for(let m=0;m<o.length;m++){const y=o[m];y.x=(y.x-s)/d*r,y.y=(y.y-c)/f*e}return o}function Ff(r,e,t,n){return r<n&&t<e}function Es(r,e,t,n){const i=Math.max(r,t),o=Math.min(e,n);return i<=o?[i,o]:null}function Mj(r,e,t){return(e.x-r.x)*(t.y-r.y)-(t.x-r.x)*(e.y-r.y)}function Oo(r,e){let t=0,n,i;for(let o=0;o<e.length;o++){if(n=e[o],n.x===r.x&&n.y===r.y||(i=e[(o+1)%e.length],T.Dist(r,n)+T.Dist(r,i)===T.Dist(n,i)))return!0;n.y<=r.y?i.y>r.y&&Mj(n,i,r)>0&&(t+=1):i.y<=r.y&&Mj(n,i,r)<0&&(t-=1)}return t!==0}function fe(r){return Math.round(r*1e4)/1e4}function Za(r){return Math.round(r*100)/100}const jj=r=>Math.abs(r)<Number.MAX_SAFE_INTEGER;function zc(r,e,t){return t<0?zh(r,e):Fee(r,e)}function wP(r,e,t,n){let i;if(Math.abs(r)>hr){i=iv(e,n);const o=iv(n,t);return Math.abs(i)<Math.abs(o)?i/r:(r-o)/r}else{i=iv(e,n);const o=i/r;return Math.sign(i)!==Math.sign(r)?Math.abs(o)>.5?1:0:o}}function Qve(r,e,t,n){const i=2*((e-r)%Cr)%Cr-(e-r)%Cr;return n?(Cr-Math.abs(i))*(t?1:-1):i}function JC(r,e,t){const n=-2*(r.x*(e.y-t.y)-r.y*(e.x-t.x)+e.x*t.y-t.x*e.y),i=((r.x*r.x+r.y*r.y)*(t.y-e.y)+(e.x*e.x+e.y*e.y)*(r.y-t.y)+(t.x*t.x+t.y*t.y)*(e.y-r.y))/n,o=((r.x*r.x+r.y*r.y)*(e.x-t.x)+(e.x*e.x+e.y*e.y)*(t.x-r.x)+(t.x*t.x+t.y*t.y)*(r.x-e.x))/n;return!Number.isFinite(i)||!Number.isFinite(o)?null:new T(i,o)}function Jve(r,e,t,n,i){if(t===null)return[T.From(r),T.From(e)];const o=[],s=T.Angle(t,r),a=T.Angle(t,e),c=zh(s,a);for(let l=0;l<i;l++){const d=l/(i-1),f=s+c*d,h=Gl(t,n,f);o.push(h)}return o}class T{constructor(e=0,t=0,n=1){this.x=e,this.y=t,this.z=n}get pressure(){return this.z}set(e=this.x,t=this.y,n=this.z){return this.x=e,this.y=t,this.z=n,this}setTo({x:e=0,y:t=0,z:n=1}){return this.x=e,this.y=t,this.z=n,this}rot(e){if(e===0)return this;const{x:t,y:n}=this,i=Math.sin(e),o=Math.cos(e);return this.x=t*o-n*i,this.y=t*i+n*o,this}rotWith(e,t){if(t===0)return this;const n=this.x-e.x,i=this.y-e.y,o=Math.sin(t),s=Math.cos(t);return this.x=e.x+(n*s-i*o),this.y=e.y+(n*o+i*s),this}clone(){const{x:e,y:t,z:n}=this;return new T(e,t,n)}sub(e){return this.x-=e.x,this.y-=e.y,this}subXY(e,t){return this.x-=e,this.y-=t,this}subScalar(e){return this.x-=e,this.y-=e,this}add(e){return this.x+=e.x,this.y+=e.y,this}addXY(e,t){return this.x+=e,this.y+=t,this}addScalar(e){return this.x+=e,this.y+=e,this}clamp(e,t){return this.x=Math.max(this.x,e),this.y=Math.max(this.y,e),t!==void 0&&(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t)),this}div(e){return this.x/=e,this.y/=e,this}divV(e){return this.x/=e.x,this.y/=e.y,this}mul(e){return this.x*=e,this.y*=e,this}mulV(e){return this.x*=e.x,this.y*=e.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(e,t){const n=T.Tan(e,this);return this.add(n.mul(t))}neg(){return this.x*=-1,this.y*=-1,this}cross(e){return this.x=this.y*e.z-this.z*e.y,this.y=this.z*e.x-this.x*e.z,this}dpr(e){return T.Dpr(this,e)}cpr(e){return T.Cpr(this,e)}len2(){return T.Len2(this)}len(){return T.Len(this)}pry(e){return T.Pry(this,e)}per(){const{x:e,y:t}=this;return this.x=t,this.y=-e,this}uni(){return T.Uni(this)}tan(e){return T.Tan(this,e)}dist(e){return T.Dist(this,e)}distanceToLineSegment(e,t){return T.DistanceToLineSegment(e,t,this)}slope(e){return T.Slope(this,e)}snapToGrid(e){return this.x=Math.round(this.x/e)*e,this.y=Math.round(this.y/e)*e,this}angle(e){return T.Angle(this,e)}toAngle(){return T.ToAngle(this)}lrp(e,t){return this.x=this.x+(e.x-this.x)*t,this.y=this.y+(e.y-this.y)*t,this}equals(e){return T.Equals(this,e)}equalsXY(e,t){return T.EqualsXY(this,e,t)}norm(){const e=this.len();return this.x=e===0?0:this.x/e,this.y=e===0?0:this.y/e,this}toFixed(){return T.ToFixed(this)}toString(){return T.ToString(T.ToFixed(this))}toJson(){return T.ToJson(this)}toArray(){return T.ToArray(this)}static Add(e,t){return new T(e.x+t.x,e.y+t.y)}static AddXY(e,t,n){return new T(e.x+t,e.y+n)}static Sub(e,t){return new T(e.x-t.x,e.y-t.y)}static SubXY(e,t,n){return new T(e.x-t,e.y-n)}static AddScalar(e,t){return new T(e.x+t,e.y+t)}static SubScalar(e,t){return new T(e.x-t,e.y-t)}static Div(e,t){return new T(e.x/t,e.y/t)}static Mul(e,t){return new T(e.x*t,e.y*t)}static DivV(e,t){return new T(e.x/t.x,e.y/t.y)}static MulV(e,t){return new T(e.x*t.x,e.y*t.y)}static Neg(e){return new T(-e.x,-e.y)}static Per(e){return new T(e.y,-e.x)}static Abs(e){return new T(Math.abs(e.x),Math.abs(e.y))}static Dist(e,t){return((e.y-t.y)**2+(e.x-t.x)**2)**.5}static DistMin(e,t,n){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)<n**2}static Dist2(e,t){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)}static Dpr(e,t){return e.x*t.x+e.y*t.y}static Cross(e,t){return new T(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z)}static Cpr(e,t){return e.x*t.y-t.x*e.y}static Len2(e){return e.x*e.x+e.y*e.y}static Len(e){return(e.x*e.x+e.y*e.y)**.5}static Pry(e,t){return T.Dpr(e,t)/T.Len(t)}static Uni(e){return T.Div(e,T.Len(e))}static Tan(e,t){return T.Uni(T.Sub(e,t))}static Min(e,t){return new T(Math.min(e.x,t.x),Math.min(e.y,t.y))}static Max(e,t){return new T(Math.max(e.x,t.x),Math.max(e.y,t.y))}static From({x:e,y:t,z:n=1}){return new T(e,t,n)}static FromArray(e){return new T(e[0],e[1])}static Rot(e,t=0){const n=Math.sin(t),i=Math.cos(t);return new T(e.x*i-e.y*n,e.x*n+e.y*i)}static RotWith(e,t,n){const i=e.x-t.x,o=e.y-t.y,s=Math.sin(n),a=Math.cos(n);return new T(t.x+(i*a-o*s),t.y+(i*s+o*a))}static NearestPointOnLineThroughPoint(e,t,n){return T.Mul(t,T.Sub(n,e).pry(t)).add(e)}static NearestPointOnLineSegment(e,t,n,i=!0){if(T.Equals(e,n)||T.Equals(t,n))return T.From(n);const o=T.Tan(t,e),s=T.Add(e,T.Mul(o,T.Sub(n,e).pry(o)));if(i){if(s.x<Math.min(e.x,t.x))return T.Cast(e.x<t.x?e:t);if(s.x>Math.max(e.x,t.x))return T.Cast(e.x>t.x?e:t);if(s.y<Math.min(e.y,t.y))return T.Cast(e.y<t.y?e:t);if(s.y>Math.max(e.y,t.y))return T.Cast(e.y>t.y?e:t)}return s}static DistanceToLineThroughPoint(e,t,n){return T.Dist(n,T.NearestPointOnLineThroughPoint(e,t,n))}static DistanceToLineSegment(e,t,n,i=!0){return T.Dist(n,T.NearestPointOnLineSegment(e,t,n,i))}static Snap(e,t=1){return new T(Math.round(e.x/t)*t,Math.round(e.y/t)*t)}static Cast(e){return e instanceof T?e:T.From(e)}static Slope(e,t){return e.x===t.y?NaN:(e.y-t.y)/(e.x-t.x)}static IsNaN(e){return isNaN(e.x)||isNaN(e.y)}static Angle(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}static Lrp(e,t,n){return T.Sub(t,e).mul(n).add(e)}static Med(e,t){return new T((e.x+t.x)/2,(e.y+t.y)/2)}static Equals(e,t){return Math.abs(e.x-t.x)<1e-4&&Math.abs(e.y-t.y)<1e-4}static EqualsXY(e,t,n){return e.x===t&&e.y===n}static Clockwise(e,t,n){return(n.x-e.x)*(t.y-e.y)-(t.x-e.x)*(n.y-e.y)<0}static Rescale(e,t){const n=T.Len(e);return new T(t*e.x/n,t*e.y/n)}static ScaleWithOrigin(e,t,n){return T.Sub(e,n).mul(t).add(n)}static ToFixed(e){return new T(Za(e.x),Za(e.y))}static ToInt(e){return new T(parseInt(e.x.toFixed(0)),parseInt(e.y.toFixed(0)),parseInt((e.z??0).toFixed(0)))}static ToCss(e){return`${e.x},${e.y}`}static Nudge(e,t,n){return T.Add(e,T.Tan(t,e).mul(n))}static ToString(e){return`${e.x}, ${e.y}`}static ToAngle(e){let t=Math.atan2(e.y,e.x);return t<0&&(t+=Math.PI*2),t}static FromAngle(e,t=1){return new T(Math.cos(e)*t,Math.sin(e)*t)}static ToArray(e){return[e.x,e.y,e.z]}static ToJson(e){const{x:t,y:n,z:i}=e;return{x:t,y:n,z:i}}static Average(e){const t=e.length,n=new T(0,0);if(t===0)return n;for(let i=0;i<t;i++)n.add(e[i]);return n.div(t)}static Clamp(e,t,n){return n===void 0?new T(Math.min(Math.max(e.x,t)),Math.min(Math.max(e.y,t))):new T(Math.min(Math.max(e.x,t),n),Math.min(Math.max(e.y,t),n))}static PointsBetween(e,t,n=6){const i=[];for(let o=0;o<n;o++){const s=zn.easeInQuad(o/(n-1)),a=T.Lrp(e,t,s);a.z=Math.min(1,.5+Math.abs(.5-eme(s))*.65),i.push(a)}return i}static SnapToGrid(e,t=8){return new T(Math.round(e.x/t)*t,Math.round(e.y/t)*t)}}const eme=r=>r<.5?2*r*r:-1+(4-2*r)*r;function $ee(r,{initialBounds:e,scaleX:t,scaleY:n,newPoint:i,handle:o}){let s;switch(o){case"bottom_left":case"bottom_right":case"top_left":case"top_right":{s=Math.max(.01,Math.max(Math.abs(t),Math.abs(n)));break}case"left":case"right":{s=Math.max(.01,Math.abs(t));break}case"bottom":case"top":{s=Math.max(.01,Math.abs(n));break}default:throw An(o)}const a=new T(0,0);t<0&&(a.x=-(e.width*s)),n<0&&(a.y=-(e.height*s));const{x:c,y:l}=T.Add(i,a.rot(r.rotation));return{x:c,y:l,props:{scale:s*r.props.scale}}}const tme=(r,e)=>e.some(t=>r instanceof t);let Dj,Lj;function rme(){return Dj||(Dj=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function nme(){return Lj||(Lj=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const qee=new WeakMap,bP=new WeakMap,Bee=new WeakMap,Zw=new WeakMap,eT=new WeakMap;function ime(r){const e=new Promise((t,n)=>{const i=()=>{r.removeEventListener("success",o),r.removeEventListener("error",s)},o=()=>{t(tc(r.result)),i()},s=()=>{n(r.error),i()};r.addEventListener("success",o),r.addEventListener("error",s)});return e.then(t=>{t instanceof IDBCursor&&qee.set(t,r)}).catch(()=>{}),eT.set(e,r),e}function ome(r){if(bP.has(r))return;const e=new Promise((t,n)=>{const i=()=>{r.removeEventListener("complete",o),r.removeEventListener("error",s),r.removeEventListener("abort",s)},o=()=>{t(),i()},s=()=>{n(r.error||new DOMException("AbortError","AbortError")),i()};r.addEventListener("complete",o),r.addEventListener("error",s),r.addEventListener("abort",s)});bP.set(r,e)}let EP={get(r,e,t){if(r instanceof IDBTransaction){if(e==="done")return bP.get(r);if(e==="objectStoreNames")return r.objectStoreNames||Bee.get(r);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return tc(r[e])},set(r,e,t){return r[e]=t,!0},has(r,e){return r instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in r}};function sme(r){EP=r(EP)}function ame(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const n=r.call(Qw(this),e,...t);return Bee.set(n,e.sort?e.sort():[e]),tc(n)}:nme().includes(r)?function(...e){return r.apply(Qw(this),e),tc(qee.get(this))}:function(...e){return tc(r.apply(Qw(this),e))}}function cme(r){return typeof r=="function"?ame(r):(r instanceof IDBTransaction&&ome(r),tme(r,rme())?new Proxy(r,EP):r)}function tc(r){if(r instanceof IDBRequest)return ime(r);if(Zw.has(r))return Zw.get(r);const e=cme(r);return e!==r&&(Zw.set(r,e),eT.set(e,r)),e}const Qw=r=>eT.get(r);function Uee(r,e,{blocked:t,upgrade:n,blocking:i,terminated:o}={}){const s=indexedDB.open(r,e),a=tc(s);return n&&s.addEventListener("upgradeneeded",c=>{n(tc(s.result),c.oldVersion,c.newVersion,tc(s.transaction),c)}),t&&s.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),a.then(c=>{o&&c.addEventListener("close",()=>o()),i&&c.addEventListener("versionchange",l=>i(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}function zee(r,{blocked:e}={}){const t=indexedDB.deleteDatabase(r);return e&&t.addEventListener("blocked",n=>e(n.oldVersion,n)),tc(t).then(()=>{})}const lme=["get","getKey","getAll","getAllKeys","count"],ume=["put","add","delete","clear"],Jw=new Map;function Fj(r,e){if(!(r instanceof IDBDatabase&&!(e in r)&&typeof e=="string"))return;if(Jw.get(e))return Jw.get(e);const t=e.replace(/FromIndex$/,""),n=e!==t,i=ume.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(i||lme.includes(t)))return;const o=async function(s,...a){const c=this.transaction(s,i?"readwrite":"readonly");let l=c.store;return n&&(l=l.index(a.shift())),(await Promise.all([l[t](...a),i&&c.done]))[0]};return Jw.set(e,o),o}sme(r=>({...r,get:(e,t,n)=>Fj(e,t)||r.get(e,t,n),has:(e,t)=>!!Fj(e,t)||r.has(e,t)}));const dme="TLDRAW_DOCUMENT_v2",fme="TLDRAW_ASSET_STORE_v1",Hee="TLDRAW_DB_NAME_INDEX_v2",ir={Records:"records",Schema:"schema",SessionState:"session_state",Assets:"assets"};async function Wee(r){const e=dme+r;return pme(e),await Uee(e,4,{upgrade(t){t.objectStoreNames.contains(ir.Records)||t.createObjectStore(ir.Records),t.objectStoreNames.contains(ir.Schema)||t.createObjectStore(ir.Schema),t.objectStoreNames.contains(ir.SessionState)||t.createObjectStore(ir.SessionState),t.objectStoreNames.contains(ir.Assets)||t.createObjectStore(ir.Assets)}})}async function hme(r){const e=window.indexedDB.databases?(await window.indexedDB.databases()).map(h=>h.name):tT(),t=fme+r;if(!e.find(h=>h===t))return;const i=await Uee(t,1,{upgrade(h){h.objectStoreNames.contains("assets")||h.createObjectStore("assets")}});if(!i.objectStoreNames.contains("assets"))return;const o=i.transaction(["assets"],"readonly"),s=o.objectStore("assets"),a=await s.getAllKeys(),c=await Promise.all(a.map(async h=>[h,await s.get(h)]));await o.done;const l=await Wee(r),d=l.transaction([ir.Assets],"readwrite"),f=d.objectStore(ir.Assets);for(const[h,g]of c)f.put(g,h);await d.done,i.close(),l.close(),await zee(t)}const ph=class ph{constructor(e){q(this,"getDbPromise");q(this,"isClosed",!1);q(this,"pendingTransactionSet",new Set);ph.connectedInstances.add(this),this.getDbPromise=(async()=>(await hme(e),await Wee(e)))()}getDb(){return this.getDbPromise}pending(){return Promise.allSettled([this.getDbPromise,...this.pendingTransactionSet]).then(gh)}async close(){this.isClosed||(this.isClosed=!0,await this.pending(),(await this.getDb()).close(),ph.connectedInstances.delete(this))}tx(e,t,n){const i=(async()=>{Jt(!this.isClosed,"db is closed");const s=(await this.getDb()).transaction(t,e),a=s.done.catch(c=>{if(!this.isClosed)throw c});try{return await n(s)}finally{this.isClosed?s.abort():await a}})();return this.pendingTransactionSet.add(i),i.finally(()=>this.pendingTransactionSet.delete(i)),i}async load({sessionId:e}={}){return await this.tx("readonly",[ir.Records,ir.Schema,ir.SessionState],async t=>{var c,l;const n=t.objectStore(ir.Records),i=t.objectStore(ir.Schema),o=t.objectStore(ir.SessionState);let s=e?(c=await o.get(e))==null?void 0:c.snapshot:null;return s||(s=(l=(await o.getAll()).sort((f,h)=>f.updatedAt-h.updatedAt).pop())==null?void 0:l.snapshot),{records:await n.getAll(),schema:await i.get(ir.Schema),sessionStateSnapshot:s}})}async storeChanges({schema:e,changes:t,sessionId:n,sessionStateSnapshot:i}){await this.tx("readwrite",[ir.Records,ir.Schema,ir.SessionState],async o=>{const s=o.objectStore(ir.Records),a=o.objectStore(ir.Schema),c=o.objectStore(ir.SessionState);for(const[l,d]of Object.entries(t.added))await s.put(d,l);for(const[l,d]of Object.values(t.updated))await s.put(d,d.id);for(const l of Object.keys(t.removed))await s.delete(l);a.put(e.serialize(),ir.Schema),i&&n?c.put({snapshot:i,updatedAt:Date.now(),id:n},n):(i||n)&&console.error("sessionStateSnapshot and instanceId must be provided together")})}async storeSnapshot({schema:e,snapshot:t,sessionId:n,sessionStateSnapshot:i}){await this.tx("readwrite",[ir.Records,ir.Schema,ir.SessionState],async o=>{const s=o.objectStore(ir.Records),a=o.objectStore(ir.Schema),c=o.objectStore(ir.SessionState);await s.clear();for(const[l,d]of Object.entries(t))await s.put(d,l);a.put(e.serialize(),ir.Schema),i&&n?c.put({snapshot:i,updatedAt:Date.now(),id:n},n):(i||n)&&console.error("sessionStateSnapshot and instanceId must be provided together")})}async pruneSessions(){await this.tx("readwrite",[ir.SessionState],async e=>{const t=e.objectStore(ir.SessionState),n=(await t.getAll()).sort((o,s)=>o.updatedAt-s.updatedAt);if(n.length<10){await e.done;return}const i=n.slice(0,n.length-10);for(const{id:o}of i)await t.delete(o)})}async getAsset(e){return await this.tx("readonly",[ir.Assets],async t=>await t.objectStore(ir.Assets).get(e))}async storeAsset(e,t){await this.tx("readwrite",[ir.Assets],async n=>{await n.objectStore(ir.Assets).put(t,e)})}};q(ph,"connectedInstances",new Set);let zv=ph;function tT(){const r=JSON.parse(FC(Hee)||"[]")??[];return Array.isArray(r)?r:[]}function pme(r){const e=new Set(tT());e.add(r),NC(Hee,JSON.stringify([...e]))}var OJ,MJ;class Nj{constructor(e,t){q(this,"valueMap");q(this,"presentKeysAtom");q(this,OJ,"AtomMap");this.name=e;const n=new Set,i=new Map;if(t)for(const[o,s]of t)n.add(o),i.set(o,xn(`${e}:${String(o)}`,s));this.valueMap=i,this.presentKeysAtom=xn(`${e}:presentKeys`,n)}getAtom(e){const t=this.valueMap.get(e);if(!t){this.presentKeysAtom.get();return}return t}get(e){var n;const t=(n=this.getAtom(e))==null?void 0:n.get();return Jt(t!==yi),t}__unsafe__getWithoutCapture(e){const t=this.valueMap.get(e);if(!t)return;const n=t.__unsafe__getWithoutCapture();return Jt(n!==yi),n}has(e){const t=this.getAtom(e);return t?t.get()!==yi:!1}__unsafe__hasWithoutCapture(e){const t=this.valueMap.get(e);return t?(Jt(t.__unsafe__getWithoutCapture()!==yi),!0):!1}set(e,t){return Ui(()=>{const n=this.valueMap.get(e);n?n.set(t):(this.valueMap.set(e,xn(`${this.name}:${String(e)}`,t)),this.presentKeysAtom.update(i=>{const o=new Set(i);return o.add(e),o}))}),this}update(e,t){return Ui(()=>{const n=this.valueMap.get(e);if(!n)throw new Error(`AtomMap: key ${e} not found`);const i=n.__unsafe__getWithoutCapture();Jt(i!==yi),n.set(t(i))})}delete(e){return Ui(()=>{const t=this.valueMap.get(e);return t?(this.valueMap.delete(e),t.set(yi),this.presentKeysAtom.update(n=>{const i=new Set(n);return i.delete(e),i}),!0):!1})}deleteMany(e){return Ui(()=>{let t;const n=[];for(const i of e){const o=this.valueMap.get(i);if(!o)continue;const s=o.get();Jt(s!==yi),n.push([i,s]),this.valueMap.delete(i),o.set(yi),t||(t=new Set(this.presentKeysAtom.__unsafe__getWithoutCapture())),t.delete(i)}return t&&this.presentKeysAtom.set(t),n})}clear(){return Ui(()=>{for(const e of this.valueMap.values())e.set(yi);this.presentKeysAtom.set(new Set),this.valueMap.clear()})}*entries(){this.presentKeysAtom.get();for(const[e,t]of this.valueMap.entries()){const n=t.get();Jt(n!==yi),yield[e,n]}}*keys(){this.presentKeysAtom.get();for(const e of this.valueMap.keys())yield e}*values(){this.presentKeysAtom.get();for(const e of this.valueMap.values()){const t=e.get();Jt(t!==yi),yield t}}get size(){return this.presentKeysAtom.get().size}forEach(e,t){for(const[n,i]of this.entries())e.call(t,i,n,this)}[(MJ=Symbol.iterator,OJ=Symbol.toStringTag,MJ)](){return this.entries()}}class ov{constructor(e){q(this,"nextValue");q(this,"diff");this.previousValue=e}get(){var n,i,o,s;const e=((i=(n=this.diff)==null?void 0:n.removed)==null?void 0:i.size)??0,t=((s=(o=this.diff)==null?void 0:o.added)==null?void 0:s.size)??0;if(!(e===0&&t===0))return{value:this.nextValue,diff:this.diff}}_add(e,t){var n,i;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.add(e),this.diff??(this.diff={}),t?(n=this.diff.removed)==null||n.delete(e):((i=this.diff).added??(i.added=new Set),this.diff.added.add(e))}add(e){var i,o,s;const t=this.previousValue.has(e);if(t)return((o=(i=this.diff)==null?void 0:i.removed)==null?void 0:o.has(e))?this._add(e,t):void 0;(s=this.nextValue)!=null&&s.has(e)||this._add(e,t)}_remove(e,t){var n,i;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.delete(e),this.diff??(this.diff={}),t?((n=this.diff).removed??(n.removed=new Set),this.diff.removed.add(e)):(i=this.diff.added)==null||i.delete(e)}remove(e){var i,o,s,a;const t=this.previousValue.has(e);if(!t)return((o=(i=this.diff)==null?void 0:i.added)==null?void 0:o.has(e))?this._remove(e,t):void 0;(a=(s=this.diff)==null?void 0:s.removed)!=null&&a.has(e)||this._remove(e,t)}}class Nm{constructor(e,t){q(this,"createDefaultProperties");q(this,"validator");q(this,"ephemeralKeys");q(this,"ephemeralKeySet");q(this,"scope");this.typeName=e,this.createDefaultProperties=t.createDefaultProperties,this.validator=t.validator??{validate:i=>i},this.scope=t.scope??"document",this.ephemeralKeys=t.ephemeralKeys;const n=new Set;if(t.ephemeralKeys)for(const[i,o]of Ro(t.ephemeralKeys))o&&n.add(i);this.ephemeralKeySet=n}create(e){const t={...this.createDefaultProperties(),id:this.createId()};for(const[n,i]of Object.entries(e))i!==void 0&&(t[n]=i);return t.typeName=this.typeName,t}clone(e){return{...Kr(e),id:this.createId()}}createId(e){return this.typeName+":"+(e??Er())}createCustomId(e){return this.typeName+":"+e}parseId(e){if(!this.isId(e))throw new Error(`ID "${e}" is not a valid ID for type "${this.typeName}"`);return e.slice(this.typeName.length+1)}isInstance(e){return(e==null?void 0:e.typeName)===this.typeName}isId(e){if(!e)return!1;for(let t=0;t<this.typeName.length;t++)if(e[t]!==this.typeName[t])return!1;return e[this.typeName.length]===":"}withDefaultProperties(e){return new Nm(this.typeName,{createDefaultProperties:e,validator:this.validator,scope:this.scope,ephemeralKeys:this.ephemeralKeys})}validate(e,t){return t&&this.validator.validateUsingKnownGoodVersion?this.validator.validateUsingKnownGoodVersion(t,e):this.validator.validate(e)}}function Ca(r,e){return new Nm(r,{createDefaultProperties:()=>({}),validator:e.validator,scope:e.scope,ephemeralKeys:e.ephemeralKeys})}function Hv(){return{added:{},updated:{},removed:{}}}function IP(r){const e={added:r.removed,removed:r.added,updated:{}};for(const[t,n]of Object.values(r.updated))e.updated[t.id]=[n,t];return e}function Kee(r){return Object.keys(r.added).length===0&&Object.keys(r.updated).length===0&&Object.keys(r.removed).length===0}function rT(r){const e={added:{},removed:{},updated:{}};return ah(e,r),e}function ah(r,e){for(const t of e){for(const[n,i]of Ro(t.added))if(r.removed[n]){const o=r.removed[n];delete r.removed[n],o!==i&&(r.updated[n]=[o,i])}else r.added[n]=i;for(const[n,[i,o]]of Ro(t.updated)){if(r.added[n]){r.added[n]=o,delete r.updated[n],delete r.removed[n];continue}if(r.updated[n]){r.updated[n]=[r.updated[n][0],o],delete r.removed[n];continue}r.updated[n]=t.updated[n],delete r.removed[n]}for(const[n,i]of Ro(t.removed))r.added[n]?delete r.added[n]:r.updated[n]?(r.removed[n]=r.updated[n][0],delete r.updated[n]):r.removed[n]=i}}var Qf={exports:{}};Qf.exports;var $j;function gme(){return $j||($j=1,function(r,e){var t=200,n="__lodash_hash_undefined__",i=1,o=2,s=9007199254740991,a="[object Arguments]",c="[object Array]",l="[object AsyncFunction]",d="[object Boolean]",f="[object Date]",h="[object Error]",g="[object Function]",m="[object GeneratorFunction]",y="[object Map]",x="[object Number]",_="[object Null]",w="[object Object]",I="[object Promise]",b="[object Proxy]",P="[object RegExp]",C="[object Set]",k="[object String]",O="[object Symbol]",L="[object Undefined]",j="[object WeakMap]",F="[object ArrayBuffer]",$="[object DataView]",D="[object Float32Array]",N="[object Float64Array]",B="[object Int8Array]",W="[object Int16Array]",G="[object Int32Array]",z="[object Uint8Array]",V="[object Uint8ClampedArray]",J="[object Uint16Array]",K="[object Uint32Array]",Z=/[\\^$.*+?()[\]{}|]/g,ee=/^\[object .+?Constructor\]$/,re=/^(?:0|[1-9]\d*)$/,te={};te[D]=te[N]=te[B]=te[W]=te[G]=te[z]=te[V]=te[J]=te[K]=!0,te[a]=te[c]=te[F]=te[d]=te[$]=te[f]=te[h]=te[g]=te[y]=te[x]=te[w]=te[P]=te[C]=te[k]=te[j]=!1;var le=typeof ho=="object"&&ho&&ho.Object===Object&&ho,ge=typeof self=="object"&&self&&self.Object===Object&&self,se=le||ge||Function("return this")(),ce=e&&!e.nodeType&&e,_e=ce&&!0&&r&&!r.nodeType&&r,Le=_e&&_e.exports===ce,Ge=Le&&le.process,qe=function(){try{return Ge&&Ge.binding&&Ge.binding("util")}catch{}}(),mt=qe&&qe.isTypedArray;function St(X,ae){for(var Re=-1,lt=X==null?0:X.length,br=0,Bt=[];++Re<lt;){var jr=X[Re];ae(jr,Re,X)&&(Bt[br++]=jr)}return Bt}function et(X,ae){for(var Re=-1,lt=ae.length,br=X.length;++Re<lt;)X[br+Re]=ae[Re];return X}function ct(X,ae){for(var Re=-1,lt=X==null?0:X.length;++Re<lt;)if(ae(X[Re],Re,X))return!0;return!1}function At(X,ae){for(var Re=-1,lt=Array(X);++Re<X;)lt[Re]=ae(Re);return lt}function _t(X){return function(ae){return X(ae)}}function ut(X,ae){return X.has(ae)}function Ae(X,ae){return X==null?void 0:X[ae]}function ze(X){var ae=-1,Re=Array(X.size);return X.forEach(function(lt,br){Re[++ae]=[br,lt]}),Re}function be(X,ae){return function(Re){return X(ae(Re))}}function it(X){var ae=-1,Re=Array(X.size);return X.forEach(function(lt){Re[++ae]=lt}),Re}var st=Array.prototype,Je=Function.prototype,Ye=Object.prototype,cr=se["__core-js_shared__"],Sr=Je.toString,Y=Ye.hasOwnProperty,oe=function(){var X=/[^.]+$/.exec(cr&&cr.keys&&cr.keys.IE_PROTO||"");return X?"Symbol(src)_1."+X:""}(),me=Ye.toString,we=RegExp("^"+Sr.call(Y).replace(Z,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Oe=Le?se.Buffer:void 0,Ee=se.Symbol,dt=se.Uint8Array,$t=Ye.propertyIsEnumerable,Pe=st.splice,$e=Ee?Ee.toStringTag:void 0,Be=Object.getOwnPropertySymbols,We=Oe?Oe.isBuffer:void 0,yt=be(Object.keys,Object),Ht=Da(se,"DataView"),ur=Da(se,"Map"),xr=Da(se,"Promise"),Rr=Da(se,"Set"),en=Da(se,"WeakMap"),Pn=Da(Object,"create"),yc=ui(Ht),Ws=ui(ur),Oa=ui(xr),Yi=ui(Rr),Xi=ui(en),ps=Ee?Ee.prototype:void 0,ci=ps?ps.valueOf:void 0;function ln(X){var ae=-1,Re=X==null?0:X.length;for(this.clear();++ae<Re;){var lt=X[ae];this.set(lt[0],lt[1])}}function Ma(){this.__data__=Pn?Pn(null):{},this.size=0}function Ks(X){var ae=this.has(X)&&delete this.__data__[X];return this.size-=ae?1:0,ae}function Rn(X){var ae=this.__data__;if(Pn){var Re=ae[X];return Re===n?void 0:Re}return Y.call(ae,X)?ae[X]:void 0}function li(X){var ae=this.__data__;return Pn?ae[X]!==void 0:Y.call(ae,X)}function Go(X,ae){var Re=this.__data__;return this.size+=this.has(X)?0:1,Re[X]=Pn&&ae===void 0?n:ae,this}ln.prototype.clear=Ma,ln.prototype.delete=Ks,ln.prototype.get=Rn,ln.prototype.has=li,ln.prototype.set=Go;function Mi(X){var ae=-1,Re=X==null?0:X.length;for(this.clear();++ae<Re;){var lt=X[ae];this.set(lt[0],lt[1])}}function ve(){this.__data__=[],this.size=0}function Ne(X){var ae=this.__data__,Re=Eu(ae,X);if(Re<0)return!1;var lt=ae.length-1;return Re==lt?ae.pop():Pe.call(ae,Re,1),--this.size,!0}function xe(X){var ae=this.__data__,Re=Eu(ae,X);return Re<0?void 0:ae[Re][1]}function ue(X){return Eu(this.__data__,X)>-1}function ke(X,ae){var Re=this.__data__,lt=Eu(Re,X);return lt<0?(++this.size,Re.push([X,ae])):Re[lt][1]=ae,this}Mi.prototype.clear=ve,Mi.prototype.delete=Ne,Mi.prototype.get=xe,Mi.prototype.has=ue,Mi.prototype.set=ke;function Pt(X){var ae=-1,Re=X==null?0:X.length;for(this.clear();++ae<Re;){var lt=X[ae];this.set(lt[0],lt[1])}}function ft(){this.size=0,this.__data__={hash:new ln,map:new(ur||Mi),string:new ln}}function Br(X){var ae=fr(this,X).delete(X);return this.size-=ae?1:0,ae}function Wt(X){return fr(this,X).get(X)}function hn(X){return fr(this,X).has(X)}function Nn(X,ae){var Re=fr(this,X),lt=Re.size;return Re.set(X,ae),this.size+=Re.size==lt?0:1,this}Pt.prototype.clear=ft,Pt.prototype.delete=Br,Pt.prototype.get=Wt,Pt.prototype.has=hn,Pt.prototype.set=Nn;function Me(X){var ae=-1,Re=X==null?0:X.length;for(this.__data__=new Pt;++ae<Re;)this.add(X[ae])}function Ur(X){return this.__data__.set(X,n),this}function _o(X){return this.__data__.has(X)}Me.prototype.add=Me.prototype.push=Ur,Me.prototype.has=_o;function ji(X){var ae=this.__data__=new Mi(X);this.size=ae.size}function ja(){this.__data__=new Mi,this.size=0}function Di(X){var ae=this.__data__,Re=ae.delete(X);return this.size=ae.size,Re}function _l(X){return this.__data__.get(X)}function wo(X){return this.__data__.has(X)}function fS(X,ae){var Re=this.__data__;if(Re instanceof Mi){var lt=Re.__data__;if(!ur||lt.length<t-1)return lt.push([X,ae]),this.size=++Re.size,this;Re=this.__data__=new Pt(lt)}return Re.set(X,ae),this.size=Re.size,this}ji.prototype.clear=ja,ji.prototype.delete=Di,ji.prototype.get=_l,ji.prototype.has=wo,ji.prototype.set=fS;function hS(X,ae){var Re=Ys(X),lt=!Re&&El(X),br=!Re&&!lt&&sf(X),Bt=!Re&&!lt&&!br&&cf(X),jr=Re||lt||br||Bt,pn=jr?At(X.length,String):[],Dr=pn.length;for(var kr in X)Y.call(X,kr)&&!(jr&&(kr=="length"||br&&(kr=="offset"||kr=="parent")||Bt&&(kr=="buffer"||kr=="byteLength"||kr=="byteOffset")||wp(kr,Dr)))&&pn.push(kr);return pn}function Eu(X,ae){for(var Re=X.length;Re--;)if(vs(X[Re][0],ae))return Re;return-1}function Iu(X,ae,Re){var lt=ae(X);return Ys(X)?lt:et(lt,Re(X))}function Gs(X){return X==null?X===void 0?L:_:$e&&$e in Object(X)?_p(X):Vs(X)}function Sc(X){return Zs(X)&&Gs(X)==a}function wl(X,ae,Re,lt,br){return X===ae?!0:X==null||ae==null||!Zs(X)&&!Zs(ae)?X!==X&&ae!==ae:pS(X,ae,Re,lt,wl,br)}function pS(X,ae,Re,lt,br,Bt){var jr=Ys(X),pn=Ys(ae),Dr=jr?c:gs(X),kr=pn?c:gs(ae);Dr=Dr==a?w:Dr,kr=kr==a?w:kr;var $n=Dr==w,Zi=kr==w,gn=Dr==kr;if(gn&&sf(X)){if(!sf(ae))return!1;jr=!0,$n=!1}if(gn&&!$n)return Bt||(Bt=new ji),jr||cf(X)?Pu(X,ae,Re,lt,br,Bt):bl(X,ae,Dr,Re,lt,br,Bt);if(!(Re&i)){var Kn=$n&&Y.call(X,"__wrapped__"),Li=Zi&&Y.call(ae,"__wrapped__");if(Kn||Li){var un=Kn?X.value():X,di=Li?ae.value():ae;return Bt||(Bt=new ji),br(un,di,Re,lt,Bt)}}return gn?(Bt||(Bt=new ji),vS(X,ae,Re,lt,br,Bt)):!1}function gS(X){if(!af(X)||of(X))return!1;var ae=xc(X)?we:ee;return ae.test(ui(X))}function rf(X){return Zs(X)&&Ip(X.length)&&!!te[Gs(X)]}function xp(X){if(!Tu(X))return yt(X);var ae=[];for(var Re in Object(X))Y.call(X,Re)&&Re!="constructor"&&ae.push(Re);return ae}function Pu(X,ae,Re,lt,br,Bt){var jr=Re&i,pn=X.length,Dr=ae.length;if(pn!=Dr&&!(jr&&Dr>pn))return!1;var kr=Bt.get(X);if(kr&&Bt.get(ae))return kr==ae;var $n=-1,Zi=!0,gn=Re&o?new Me:void 0;for(Bt.set(X,ae),Bt.set(ae,X);++$n<pn;){var Kn=X[$n],Li=ae[$n];if(lt)var un=jr?lt(Li,Kn,$n,ae,X,Bt):lt(Kn,Li,$n,X,ae,Bt);if(un!==void 0){if(un)continue;Zi=!1;break}if(gn){if(!ct(ae,function(di,ms){if(!ut(gn,ms)&&(Kn===di||br(Kn,di,Re,lt,Bt)))return gn.push(ms)})){Zi=!1;break}}else if(!(Kn===Li||br(Kn,Li,Re,lt,Bt))){Zi=!1;break}}return Bt.delete(X),Bt.delete(ae),Zi}function bl(X,ae,Re,lt,br,Bt,jr){switch(Re){case $:if(X.byteLength!=ae.byteLength||X.byteOffset!=ae.byteOffset)return!1;X=X.buffer,ae=ae.buffer;case F:return!(X.byteLength!=ae.byteLength||!Bt(new dt(X),new dt(ae)));case d:case f:case x:return vs(+X,+ae);case h:return X.name==ae.name&&X.message==ae.message;case P:case k:return X==ae+"";case y:var pn=ze;case C:var Dr=lt&i;if(pn||(pn=it),X.size!=ae.size&&!Dr)return!1;var kr=jr.get(X);if(kr)return kr==ae;lt|=o,jr.set(X,ae);var $n=Pu(pn(X),pn(ae),lt,br,Bt,jr);return jr.delete(X),$n;case O:if(ci)return ci.call(X)==ci.call(ae)}return!1}function vS(X,ae,Re,lt,br,Bt){var jr=Re&i,pn=Cu(X),Dr=pn.length,kr=Cu(ae),$n=kr.length;if(Dr!=$n&&!jr)return!1;for(var Zi=Dr;Zi--;){var gn=pn[Zi];if(!(jr?gn in ae:Y.call(ae,gn)))return!1}var Kn=Bt.get(X);if(Kn&&Bt.get(ae))return Kn==ae;var Li=!0;Bt.set(X,ae),Bt.set(ae,X);for(var un=jr;++Zi<Dr;){gn=pn[Zi];var di=X[gn],ms=ae[gn];if(lt)var _c=jr?lt(ms,di,gn,ae,X,Bt):lt(di,ms,gn,X,ae,Bt);if(!(_c===void 0?di===ms||br(di,ms,Re,lt,Bt):_c)){Li=!1;break}un||(un=gn=="constructor")}if(Li&&!un){var Au=X.constructor,wc=ae.constructor;Au!=wc&&"constructor"in X&&"constructor"in ae&&!(typeof Au=="function"&&Au instanceof Au&&typeof wc=="function"&&wc instanceof wc)&&(Li=!1)}return Bt.delete(X),Bt.delete(ae),Li}function Cu(X){return Iu(X,mS,nf)}function fr(X,ae){var Re=X.__data__;return bp(ae)?Re[typeof ae=="string"?"string":"hash"]:Re.map}function Da(X,ae){var Re=Ae(X,ae);return gS(Re)?Re:void 0}function _p(X){var ae=Y.call(X,$e),Re=X[$e];try{X[$e]=void 0;var lt=!0}catch{}var br=me.call(X);return lt&&(ae?X[$e]=Re:delete X[$e]),br}var nf=Be?function(X){return X==null?[]:(X=Object(X),St(Be(X),function(ae){return $t.call(X,ae)}))}:Il,gs=Gs;(Ht&&gs(new Ht(new ArrayBuffer(1)))!=$||ur&&gs(new ur)!=y||xr&&gs(xr.resolve())!=I||Rr&&gs(new Rr)!=C||en&&gs(new en)!=j)&&(gs=function(X){var ae=Gs(X),Re=ae==w?X.constructor:void 0,lt=Re?ui(Re):"";if(lt)switch(lt){case yc:return $;case Ws:return y;case Oa:return I;case Yi:return C;case Xi:return j}return ae});function wp(X,ae){return ae=ae??s,!!ae&&(typeof X=="number"||re.test(X))&&X>-1&&X%1==0&&X<ae}function bp(X){var ae=typeof X;return ae=="string"||ae=="number"||ae=="symbol"||ae=="boolean"?X!=="__proto__":X===null}function of(X){return!!oe&&oe in X}function Tu(X){var ae=X&&X.constructor,Re=typeof ae=="function"&&ae.prototype||Ye;return X===Re}function Vs(X){return me.call(X)}function ui(X){if(X!=null){try{return Sr.call(X)}catch{}try{return X+""}catch{}}return""}function vs(X,ae){return X===ae||X!==X&&ae!==ae}var El=Sc(function(){return arguments}())?Sc:function(X){return Zs(X)&&Y.call(X,"callee")&&!$t.call(X,"callee")},Ys=Array.isArray;function Xs(X){return X!=null&&Ip(X.length)&&!xc(X)}var sf=We||Pl;function Ep(X,ae){return wl(X,ae)}function xc(X){if(!af(X))return!1;var ae=Gs(X);return ae==g||ae==m||ae==l||ae==b}function Ip(X){return typeof X=="number"&&X>-1&&X%1==0&&X<=s}function af(X){var ae=typeof X;return X!=null&&(ae=="object"||ae=="function")}function Zs(X){return X!=null&&typeof X=="object"}var cf=mt?_t(mt):rf;function mS(X){return Xs(X)?hS(X):xp(X)}function Il(){return[]}function Pl(){return!1}r.exports=Ep}(Qf,Qf.exports)),Qf.exports}var vme=gme();const Gee=cc(vme);function mme(r){if(r.length===0)return new Set;const e=r[0],t=r.slice(1),n=new Set;for(const i of e)t.every(o=>o.has(i))&&n.add(i);return n}function yme(r,e){const t={};for(const n of e)r.has(n)||(t.added??(t.added=new Set),t.added.add(n));for(const n of r)e.has(n)||(t.removed??(t.removed=new Set),t.removed.add(n));return t.added||t.removed?t:void 0}function qj(r,e){for(const[t,n]of Object.entries(r)){const i=n,o=e[t];if("eq"in i&&o!==i.eq||"neq"in i&&o===i.neq||"gt"in i&&(typeof o!="number"||o<=i.gt))return!1}return!0}function Bj(r,e,t){const n=Object.fromEntries(Object.keys(t).map(i=>[i,new Set]));for(const[i,o]of Object.entries(t))if("eq"in o){const a=r.index(e,i).get().get(o.eq);if(a)for(const c of a)n[i].add(c)}else if("neq"in o){const s=r.index(e,i);for(const[a,c]of s.get())if(a!==o.neq)for(const l of c)n[i].add(l)}else if("gt"in o){const s=r.index(e,i);for(const[a,c]of s.get())if(a>o.gt)for(const l of c)n[i].add(l)}return mme(Object.values(n))}class Sme{constructor(e,t){q(this,"indexCache",new Map);q(this,"historyCache",new Map);this.recordMap=e,this.history=t}filterHistory(e){if(this.historyCache.has(e))return this.historyCache.get(e);const t=Te("filterHistory:"+e,(n,i)=>{if(zl(n))return this.history.get();const o=this.history.getDiffSince(i);if(o===ko)return this.history.get();const s={added:{},removed:{},updated:{}};let a=0,c=0,l=0;for(const d of o){for(const f of Tn(d.added))if(f.typeName===e)if(s.removed[f.id]){const h=s.removed[f.id];delete s.removed[f.id],c--,h!==f&&(s.updated[f.id]=[h,f],l++)}else s.added[f.id]=f,a++;for(const[f,h]of Tn(d.updated))h.typeName===e&&(s.added[h.id]?s.added[h.id]=h:s.updated[h.id]?s.updated[h.id]=[s.updated[h.id][0],h]:(s.updated[h.id]=[f,h],l++));for(const f of Tn(d.removed))f.typeName===e&&(s.added[f.id]?(delete s.added[f.id],a--):s.updated[f.id]?(s.removed[f.id]=s.updated[f.id][0],delete s.updated[f.id],l--,c++):(s.removed[f.id]=f,c++))}return a||c||l?Zf(this.history.get(),s):n},{historyLength:100});return this.historyCache.set(e,t),t}index(e,t){const n=e+":"+t;if(this.indexCache.has(n))return this.indexCache.get(n);const i=this.__uncached_createIndex(e,t);return this.indexCache.set(n,i),i}__uncached_createIndex(e,t){const n=this.filterHistory(e),i=()=>{n.get();const o=new Map;for(const s of this.recordMap.values())if(s.typeName===e){const a=s[t];o.has(a)||o.set(a,new Set),o.get(a).add(s.id)}return o};return Te("index:"+e+":"+t,(o,s)=>{if(zl(o))return i();const a=n.getDiffSince(s);if(a===ko)return i();const c=new Map,l=(g,m)=>{let y=c.get(g);y||(y=new ov(o.get(g)??new Set)),y.add(m),c.set(g,y)},d=(g,m)=>{let y=c.get(g);y||(y=new ov(o.get(g)??new Set)),y.remove(m),c.set(g,y)};for(const g of a){for(const m of Tn(g.added))if(m.typeName===e){const y=m[t];l(y,m.id)}for(const[m,y]of Tn(g.updated))if(y.typeName===e){const x=m[t],_=y[t];x!==_&&(d(x,y.id),l(_,y.id))}for(const m of Tn(g.removed))if(m.typeName===e){const y=m[t];d(y,m.id)}}let f,h;for(const[g,m]of c){const y=m.get();y&&(f||(f=new Map(o)),h||(h=new Map),y.value.size===0?f.delete(g):f.set(g,y.value),h.set(g,y.diff))}return f&&h?Zf(f,h):o},{historyLength:100})}record(e,t=()=>({}),n="record:"+e+(t?":"+t.toString():"")){const i=this.ids(e,t,n);return Te(n,()=>{for(const o of i.get())return this.recordMap.get(o)})}records(e,t=()=>({}),n="records:"+e+(t?":"+t.toString():"")){const i=this.ids(e,t,"ids:"+n);return Te(n,()=>Array.from(i.get(),o=>this.recordMap.get(o)),{isEqual:$J})}ids(e,t=()=>({}),n="ids:"+e+(t?":"+t.toString():"")){const i=this.filterHistory(e),o=()=>{i.get();const c=t();if(Object.keys(c).length===0){const l=new Set;for(const d of this.recordMap.values())d.typeName===e&&l.add(d.id);return l}return Bj(this,e,c)},s=c=>{const l=o(),d=yme(c,l);return d?Zf(l,d):c},a=Te("ids_query:"+n,t,{isEqual:Gee});return Te("query:"+n,(c,l)=>{const d=a.get();if(zl(c))return o();if(l<a.lastChangedEpoch)return s(c);const f=i.getDiffSince(l);if(f===ko)return s(c);const h=new ov(c);for(const m of f){for(const y of Tn(m.added))y.typeName===e&&qj(d,y)&&h.add(y.id);for(const[y,x]of Tn(m.updated))x.typeName===e&&(qj(d,x)?h.add(x.id):h.remove(x.id));for(const y of Tn(m.removed))y.typeName===e&&h.remove(y.id)}const g=h.get();return g?Zf(g.value,g.diff):c},{historyLength:50})}exec(e,t){const n=Bj(this,e,t);return n.size===0?ec:Array.from(n,i=>this.recordMap.get(i))}}class xme{constructor(e){q(this,"_beforeCreateHandlers",{});q(this,"_afterCreateHandlers",{});q(this,"_beforeChangeHandlers",{});q(this,"_afterChangeHandlers",{});q(this,"_beforeDeleteHandlers",{});q(this,"_afterDeleteHandlers",{});q(this,"_operationCompleteHandlers",[]);q(this,"_isEnabled",!0);this.store=e}isEnabled(){return this._isEnabled}setIsEnabled(e){this._isEnabled=e}handleBeforeCreate(e,t){if(!this._isEnabled)return e;const n=this._beforeCreateHandlers[e.typeName];if(n){let i=e;for(const o of n)i=o(i,t);return i}return e}handleAfterCreate(e,t){if(!this._isEnabled)return;const n=this._afterCreateHandlers[e.typeName];if(n)for(const i of n)i(e,t)}handleBeforeChange(e,t,n){if(!this._isEnabled)return t;const i=this._beforeChangeHandlers[t.typeName];if(i){let o=t;for(const s of i)o=s(e,o,n);return o}return t}handleAfterChange(e,t,n){if(!this._isEnabled)return;const i=this._afterChangeHandlers[t.typeName];if(i)for(const o of i)o(e,t,n)}handleBeforeDelete(e,t){if(!this._isEnabled)return!0;const n=this._beforeDeleteHandlers[e.typeName];if(n){for(const i of n)if(i(e,t)===!1)return!1}return!0}handleAfterDelete(e,t){if(!this._isEnabled)return;const n=this._afterDeleteHandlers[e.typeName];if(n)for(const i of n)i(e,t)}handleOperationComplete(e){if(this._isEnabled)for(const t of this._operationCompleteHandlers)t(e)}register(e){const t=[];for(const[n,i]of Object.entries(e))i!=null&&i.beforeCreate&&t.push(this.registerBeforeCreateHandler(n,i.beforeCreate)),i!=null&&i.afterCreate&&t.push(this.registerAfterCreateHandler(n,i.afterCreate)),i!=null&&i.beforeChange&&t.push(this.registerBeforeChangeHandler(n,i.beforeChange)),i!=null&&i.afterChange&&t.push(this.registerAfterChangeHandler(n,i.afterChange)),i!=null&&i.beforeDelete&&t.push(this.registerBeforeDeleteHandler(n,i.beforeDelete)),i!=null&&i.afterDelete&&t.push(this.registerAfterDeleteHandler(n,i.afterDelete));return()=>{for(const n of t)n()}}registerBeforeCreateHandler(e,t){return this._beforeCreateHandlers[e]||(this._beforeCreateHandlers[e]=[]),this._beforeCreateHandlers[e].push(t),()=>$l(this._beforeCreateHandlers[e],t)}registerAfterCreateHandler(e,t){return this._afterCreateHandlers[e]||(this._afterCreateHandlers[e]=[]),this._afterCreateHandlers[e].push(t),()=>$l(this._afterCreateHandlers[e],t)}registerBeforeChangeHandler(e,t){return this._beforeChangeHandlers[e]||(this._beforeChangeHandlers[e]=[]),this._beforeChangeHandlers[e].push(t),()=>$l(this._beforeChangeHandlers[e],t)}registerAfterChangeHandler(e,t){return this._afterChangeHandlers[e]||(this._afterChangeHandlers[e]=[]),this._afterChangeHandlers[e].push(t),()=>$l(this._afterChangeHandlers[e],t)}registerBeforeDeleteHandler(e,t){return this._beforeDeleteHandlers[e]||(this._beforeDeleteHandlers[e]=[]),this._beforeDeleteHandlers[e].push(t),()=>$l(this._beforeDeleteHandlers[e],t)}registerAfterDeleteHandler(e,t){return this._afterDeleteHandlers[e]||(this._afterDeleteHandlers[e]=[]),this._afterDeleteHandlers[e].push(t),()=>$l(this._afterDeleteHandlers[e],t)}registerOperationCompleteHandler(e){return this._operationCompleteHandlers.push(e),()=>$l(this._operationCompleteHandlers,e)}}function $l(r,e){const t=r.indexOf(e);t>=0&&r.splice(t,1)}class nT{constructor(e){q(this,"id");q(this,"records");q(this,"history",xn("history",0,{historyLength:1e3}));q(this,"query");q(this,"listeners",new Set);q(this,"historyAccumulator",new wme);q(this,"historyReactor");q(this,"schema");q(this,"props");q(this,"scopedTypes");q(this,"sideEffects",new xme(this));q(this,"isMergingRemoteChanges",!1);q(this,"_integrityChecker");q(this,"_isPossiblyCorrupted",!1);q(this,"pendingAfterEvents",null);q(this,"_isInAtomicOp",!1);const{initialData:t,schema:n,id:i}=e;this.id=i??Er(),this.schema=n,this.props=e.props,t?this.records=new Nj("store",Ro(t).map(([o,s])=>[o,this.schema.validateRecord(this,s,"initialize",null)])):this.records=new Nj("store"),this.query=new Sme(this.records,this.history),this.historyReactor=kve("Store.historyReactor",()=>{this.history.get(),this._flushHistory()},{scheduleEffect:o=>this.cancelHistoryReactor=aee(o)}),this.scopedTypes={document:new Set(Tn(this.schema.types).filter(o=>o.scope==="document").map(o=>o.typeName)),session:new Set(Tn(this.schema.types).filter(o=>o.scope==="session").map(o=>o.typeName)),presence:new Set(Tn(this.schema.types).filter(o=>o.scope==="presence").map(o=>o.typeName))}}cancelHistoryReactor(){}_flushHistory(){if(this.historyAccumulator.hasChanges()){const e=this.historyAccumulator.flush();for(const{changes:t,source:n}of e){let i=null,o=null,s=null;for(const{onHistory:a,filters:c}of this.listeners)if(!(c.source!=="all"&&c.source!==n))if(c.scope!=="all")if(c.scope==="document"){if(o??(o=this.filterChangesByScope(t,"document")),!o)continue;a({changes:o,source:n})}else if(c.scope==="session"){if(i??(i=this.filterChangesByScope(t,"session")),!i)continue;a({changes:i,source:n})}else{if(s??(s=this.filterChangesByScope(t,"presence")),!s)continue;a({changes:s,source:n})}else a({changes:t,source:n})}}}dispose(){this.cancelHistoryReactor()}filterChangesByScope(e,t){const n={added:sh(e.added,(i,o)=>this.scopedTypes[t].has(o.typeName)),updated:sh(e.updated,(i,o)=>this.scopedTypes[t].has(o[1].typeName)),removed:sh(e.removed,(i,o)=>this.scopedTypes[t].has(o.typeName))};return Object.keys(n.added).length===0&&Object.keys(n.updated).length===0&&Object.keys(n.removed).length===0?null:n}updateHistory(e){this.historyAccumulator.add({changes:e,source:this.isMergingRemoteChanges?"remote":"user"}),this.listeners.size===0&&this.historyAccumulator.clear(),this.history.set(this.history.get()+1,e)}validate(e){this.allRecords().forEach(t=>this.schema.validateRecord(this,t,e,null))}put(e,t){this.atomic(()=>{const n={},i={};let o,s=!1;const a=this.isMergingRemoteChanges?"remote":"user";for(let c=0,l=e.length;c<l;c++){o=e[c];const d=this.records.__unsafe__getWithoutCapture(o.id);if(d){if(o=this.sideEffects.handleBeforeChange(d,o,a),this.schema.validateRecord(this,o,t??"updateRecord",d)===d)continue;o=o,this.records.set(o.id,o),s=!0,n[o.id]=[d,o],this.addDiffForAfterEvent(d,o)}else o=this.sideEffects.handleBeforeCreate(o,a),s=!0,o=this.schema.validateRecord(this,o,t??"createRecord",null),o=o,i[o.id]=o,this.addDiffForAfterEvent(null,o),this.records.set(o.id,o)}s&&this.updateHistory({added:i,updated:n,removed:{}})})}remove(e){this.atomic(()=>{const t=new Set(e),n=this.isMergingRemoteChanges?"remote":"user";if(this.sideEffects.isEnabled())for(const s of e){const a=this.records.__unsafe__getWithoutCapture(s);a&&this.sideEffects.handleBeforeDelete(a,n)===!1&&t.delete(s)}const i=this.records.deleteMany(t);if(i.length===0)return;const o={};for(const[s,a]of i)o[s]=a,this.addDiffForAfterEvent(a,null);this.updateHistory({added:{},updated:{},removed:o})})}get(e){return this.records.get(e)}unsafeGetWithoutCapture(e){return this.records.__unsafe__getWithoutCapture(e)}serialize(e="document"){const t={};for(const[n,i]of this.records)(e==="all"||this.scopedTypes[e].has(i.typeName))&&(t[n]=i);return t}getStoreSnapshot(e="document"){return{store:this.serialize(e),schema:this.schema.serialize()}}getSnapshot(e="document"){return console.warn("[tldraw] `Store.getSnapshot` is deprecated and will be removed in a future release. Use `getSnapshot` from the `tldraw` package instead."),this.getStoreSnapshot(e)}migrateSnapshot(e){const t=this.schema.migrateStoreSnapshot(e);if(t.type==="error")throw new Error(`Failed to migrate snapshot: ${t.reason}`);return{store:t.value,schema:this.schema.serialize()}}loadStoreSnapshot(e){const t=this.schema.migrateStoreSnapshot(e);if(t.type==="error")throw new Error(`Failed to migrate snapshot: ${t.reason}`);const n=this.sideEffects.isEnabled();try{this.sideEffects.setIsEnabled(!1),this.atomic(()=>{this.clear(),this.put(Object.values(t.value)),this.ensureStoreIsUsable()})}finally{this.sideEffects.setIsEnabled(n)}}loadSnapshot(e){console.warn("[tldraw] `Store.loadSnapshot` is deprecated and will be removed in a future release. Use `loadSnapshot` from the 'tldraw' package instead."),this.loadStoreSnapshot(e)}allRecords(){return Array.from(this.records.values())}clear(){this.remove(Array.from(this.records.keys()))}update(e,t){const n=this.unsafeGetWithoutCapture(e);if(!n){console.error(`Record ${e} not found. This is probably an error`);return}this.put([t(n)])}has(e){return this.records.has(e)}listen(e,t){this._flushHistory();const n={onHistory:e,filters:{source:(t==null?void 0:t.source)??"all",scope:(t==null?void 0:t.scope)??"all"}};return this.historyReactor.scheduler.isActivelyListening||(this.historyReactor.start(),this.historyReactor.scheduler.execute()),this.listeners.add(n),()=>{this.listeners.delete(n),this.listeners.size===0&&this.historyReactor.stop()}}mergeRemoteChanges(e){if(this.isMergingRemoteChanges)return e();if(this._isInAtomicOp)throw new Error("Cannot merge remote changes while in atomic operation");try{this.isMergingRemoteChanges=!0,Ui(e)}finally{this.isMergingRemoteChanges=!1,this.ensureStoreIsUsable()}}extractingChanges(e){const t=[],n=this.historyAccumulator.addInterceptor(i=>t.push(i.changes));try{return Ui(e),rT(t)}finally{n()}}applyDiff(e,{runCallbacks:t=!0,ignoreEphemeralKeys:n=!1}={}){this.atomic(()=>{const i=Tn(e.added);for(const[s,a]of Tn(e.updated)){const c=this.schema.getType(a.typeName);if(n&&c.ephemeralKeySet.size){const l=this.get(a.id);if(!l){i.push(a);continue}let d=null;for(const[f,h]of Object.entries(a))c.ephemeralKeySet.has(f)||Object.is(h,bi(l,f))||(d||(d={...l}),d[f]=h);d&&i.push(d)}else i.push(a)}const o=Wge(e.removed);i.length&&this.put(i),o.length&&this.remove(o)},t)}createCache(e){const t=new js;return{get:n=>{const i=this.records.getAtom(n);if(i)return t.get(i,()=>e(n,i)).get()}}}createComputedCache(e,t,n){return this.createCache((i,o)=>{const s=n!=null&&n.areRecordsEqual?Te(xn.name+":equals",()=>o.get(),{isEqual:n.areRecordsEqual}):o;return Te(e+":"+i,()=>t(s.get()),{isEqual:n==null?void 0:n.areResultsEqual})})}ensureStoreIsUsable(){this.atomic(()=>{var e;this._integrityChecker??(this._integrityChecker=this.schema.createIntegrityChecker(this)),(e=this._integrityChecker)==null||e.call(this)})}markAsPossiblyCorrupted(){this._isPossiblyCorrupted=!0}isPossiblyCorrupted(){return this._isPossiblyCorrupted}addDiffForAfterEvent(e,t){if(Jt(this.pendingAfterEvents,"must be in event operation"),e===t||(e&&t&&Jt(e.id===t.id),!e&&!t))return;const n=(e||t).id,i=this.pendingAfterEvents.get(n);i?i.after=t:this.pendingAfterEvents.set(n,{before:e,after:t})}flushAtomicCallbacks(){let e=0;const t=this.isMergingRemoteChanges?"remote":"user";for(;this.pendingAfterEvents;){const n=this.pendingAfterEvents;if(this.pendingAfterEvents=null,!!this.sideEffects.isEnabled()){if(e++,e>100)throw new Error("Maximum store update depth exceeded, bailing out");for(const{before:i,after:o}of n.values())i&&o?this.sideEffects.handleAfterChange(i,o,t):i&&!o?this.sideEffects.handleAfterDelete(i,t):!i&&o&&this.sideEffects.handleAfterCreate(o,t);this.pendingAfterEvents||this.sideEffects.handleOperationComplete(t)}}}atomic(e,t=!0){return Ui(()=>{if(this._isInAtomicOp)return this.pendingAfterEvents||(this.pendingAfterEvents=new Map),e();this.pendingAfterEvents=new Map;const n=this.sideEffects.isEnabled();this.sideEffects.setIsEnabled(t??n),this._isInAtomicOp=!0;try{const i=e();return this.flushAtomicCallbacks(),i}finally{this.pendingAfterEvents=null,this.sideEffects.setIsEnabled(n),this._isInAtomicOp=!1}})}addHistoryInterceptor(e){return this.historyAccumulator.addInterceptor(t=>e(t,this.isMergingRemoteChanges?"remote":"user"))}}function _me(r){if(r.length===0)return[];const e=[];let t=[r[0]],n;for(let i=1,o=r.length;i<o;i++)n=r[i],t[0].source!==n.source&&(e.push(t),t=[]),t.push(n);return e.push(t),e.map(i=>({source:i[0].source,changes:rT(i.map(o=>o.changes))}))}class wme{constructor(){q(this,"_history",[]);q(this,"_interceptors",new Set)}addInterceptor(e){return this._interceptors.add(e),()=>{this._interceptors.delete(e)}}add(e){this._history.push(e);for(const t of this._interceptors)t(e)}flush(){const e=_me(this._history);return this._history=[],e}clear(){this._history=[]}hasChanges(){return this._history.length>0}}function bme(r,e,t){const n=new js;return{get(i,o){return n.get(i,()=>(i instanceof nT?i:i.store).createComputedCache(r,c=>e(i,c),t)).get(o)}}}function Eme(r){const e=[];for(let t=r.length-1;t>=0;t--){const n=r[t];if("id"in n)e.unshift(n);else{const i=n.dependsOn,o=e[0];o&&(e[0]={...o,dependsOn:i.concat(o.dependsOn??[])})}}return e}function pd({sequence:r,sequenceId:e,retroactive:t=!0}){const n={sequenceId:e,retroactive:t,sequence:Eme(r)};return Vee(n),n}function mo(r,e){return Object.fromEntries(Ro(e).map(([t,n])=>[t,`${r}/${n}`]))}function qo(r){const e=r.sequenceId;return pd({sequenceId:e,retroactive:r.retroactive??!0,sequence:r.sequence.map(t=>"id"in t?{...t,scope:"record",filter:n=>{var i,o;return n.typeName===r.recordType&&(((i=t.filter)==null?void 0:i.call(t,n))??!0)&&(((o=r.filter)==null?void 0:o.call(r,n))??!0)}}:t)})}function Ime(r){const e=new Map(r.map(o=>[o.id,o])),t=new Set,n=[];function i(o){Jt(!t.has(o.id),`Circular dependency in migrations: ${o.id}`),t.add(o.id);const{version:s,sequenceId:a}=Wv(o.id),c=e.get(`${a}/${s-1}`);if(c&&i(c),o.dependsOn)for(const l of o.dependsOn){const d=e.get(l);d&&i(d)}e.delete(o.id),n.push(o)}for(const o of e.values())i(o);return n}function Wv(r){const[e,t]=r.split("/");return{sequenceId:e,version:parseInt(t)}}function Uj(r,e){e&&Jt(r.startsWith(e+"/"),`Every migration in sequence '${e}' must have an id starting with '${e}/'. Got invalid id: '${r}'`),Jt(r.match(/^(.*?)\/(0|[1-9]\d*)$/),`Invalid migration id: '${r}'`)}function Vee(r){if(Jt(!r.sequenceId.includes("/"),`sequenceId cannot contain a '/', got ${r.sequenceId}`),Jt(r.sequenceId.length,"sequenceId must be a non-empty string"),r.sequence.length===0)return;Uj(r.sequence[0].id,r.sequenceId);let e=Wv(r.sequence[0].id).version;Jt(e===1,`Expected the first migrationId to be '${r.sequenceId}/1' but got '${r.sequence[0].id}'`);for(let t=1;t<r.sequence.length;t++){const n=r.sequence[t].id;Uj(n,r.sequenceId);const i=Wv(n).version;Jt(i===e+1,`Migration id numbers must increase in increments of 1, expected ${r.sequenceId}/${e+1} but got '${r.sequence[t].id}'`),e=i}}var qc=(r=>(r.IncompatibleSubtype="incompatible-subtype",r.UnknownType="unknown-type",r.TargetVersionTooNew="target-version-too-new",r.TargetVersionTooOld="target-version-too-old",r.MigrationError="migration-error",r.UnrecognizedSubtype="unrecognized-subtype",r))(qc||{});function Pme(r){if(r.schemaVersion>2||r.schemaVersion<1)return qi.err("Bad schema version");if(r.schemaVersion===2)return qi.ok(r);const e={schemaVersion:2,sequences:{"com.tldraw.store":r.storeVersion}};for(const[t,n]of Object.entries(r.recordVersions))if(e.sequences[`com.tldraw.${t}`]=n.version,"subTypeKey"in n)for(const[i,o]of Object.entries(n.subTypeVersions))e.sequences[`com.tldraw.${t}.${i}`]=o;return qi.ok(e)}class iT{constructor(e,t){q(this,"migrations",{});q(this,"sortedMigrations");var i;this.types=e,this.options=t;for(const o of t.migrations??[])Jt(!this.migrations[o.sequenceId],`Duplicate migration sequenceId ${o.sequenceId}`),Vee(o),this.migrations[o.sequenceId]=o;const n=Object.values(this.migrations).flatMap(o=>o.sequence);this.sortedMigrations=Ime(n);for(const o of this.sortedMigrations)if((i=o.dependsOn)!=null&&i.length)for(const s of o.dependsOn){const a=n.find(c=>c.id===s);Jt(a,`Migration '${o.id}' depends on missing migration '${s}'`)}}static create(e,t){return new iT(e,t??{})}validateRecord(e,t,n,i){try{const o=bi(this.types,t.typeName);if(!o)throw new Error(`Missing definition for record type ${t.typeName}`);return o.validate(t,i??void 0)}catch(o){if(this.options.onValidationFailure)return this.options.onValidationFailure({store:e,record:t,phase:n,recordBefore:i,error:o});throw o}}getMigrationsSince(e){const t=Pme(e);if(!t.ok)return t;const n=t.value,i=new Set(Object.keys(n.sequences).filter(s=>this.migrations[s]));for(const s in this.migrations)n.sequences[s]===void 0&&this.migrations[s].retroactive&&i.add(s);if(i.size===0)return qi.ok([]);const o=new Set;for(const s of i){const a=n.sequences[s];if(typeof a!="number"&&this.migrations[s].retroactive||a===0){for(const d of this.migrations[s].sequence)o.add(d.id);continue}const c=`${s}/${a}`,l=this.migrations[s].sequence.findIndex(d=>d.id===c);if(l===-1)return qi.err("Incompatible schema?");for(const d of this.migrations[s].sequence.slice(l+1))o.add(d.id)}return qi.ok(this.sortedMigrations.filter(({id:s})=>o.has(s)))}migratePersistedRecord(e,t,n="up"){const i=this.getMigrationsSince(t);if(!i.ok)return console.error("Error migrating record",i.error),{type:"error",reason:qc.MigrationError};let o=i.value;if(o.length===0)return{type:"success",value:e};if(o.some(s=>s.scope==="store"))return{type:"error",reason:n==="down"?qc.TargetVersionTooOld:qc.TargetVersionTooNew};if(n==="down"){if(!o.every(s=>s.down))return{type:"error",reason:qc.TargetVersionTooOld};o=o.slice().reverse()}e=Kr(e);try{for(const s of o){if(s.scope==="store")throw new Error;if(!(s.filter?s.filter(e):!0))continue;const c=s[n](e);c&&(e=Kr(c))}}catch(s){return console.error("Error migrating record",s),{type:"error",reason:qc.MigrationError}}return{type:"success",value:e}}migrateStoreSnapshot(e){let{store:t}=e;const n=this.getMigrationsSince(e.schema);if(!n.ok)return console.error("Error migrating store",n.error),{type:"error",reason:qc.MigrationError};const i=n.value;if(i.length===0)return{type:"success",value:t};t=Kr(t);try{for(const o of i)if(o.scope==="record")for(const[s,a]of Object.entries(t)){if(!(o.filter?o.filter(a):!0))continue;const l=o.up(a);l&&(t[s]=Kr(l))}else if(o.scope==="store"){const s=o.up(t);s&&(t=Kr(s))}else An(o)}catch(o){return console.error("Error migrating store",o),{type:"error",reason:qc.MigrationError}}return{type:"success",value:t}}createIntegrityChecker(e){var t,n;return((n=(t=this.options).createIntegrityChecker)==null?void 0:n.call(t,e))??void 0}serialize(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:e,sequence:t})=>[e,t.length?Wv(t.at(-1).id).version:0]))}}serializeEarliestVersion(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:e})=>[e,0]))}}getType(e){const t=bi(this.types,e);return Jt(t,"record type does not exists"),t}}il("@tldraw/store","3.9.0","esm");function Cme(r){if(!r.length)return null;let e="";for(const t of r)typeof t=="number"?e+=`.${t}`:t.startsWith("(")?e.endsWith(")")?e=`${e.slice(0,-1)}, ${t.slice(1)}`:e+=t:e+=`.${t}`;return e=e.replace(/id = [^,]+, /,"").replace(/id = [^)]+/,""),e.startsWith(".")?e.slice(1):e}class dr extends Error{constructor(t,n=[]){const i=Cme(n),o=t.split(`
83
- `).map((s,a)=>a===0?s:` ${s}`).join(`
84
- `);super(n?`At ${i}: ${o}`:o);q(this,"name","ValidationError");this.rawMessage=t,this.path=n}}function go(r,e){try{return e()}catch(t){throw t instanceof dr?new dr(t.rawMessage,[r,...t.path]):new dr(t.toString(),[r])}}function Zc(r){if(r===null)return"null";if(Array.isArray(r))return"an array";const e=typeof r;switch(e){case"bigint":case"boolean":case"function":case"number":case"string":case"symbol":return`a ${e}`;case"object":return`an ${e}`;case"undefined":return"undefined";default:An(e)}}class Hi{constructor(e,t){this.validationFn=e,this.validateUsingKnownGoodVersionFn=t}validate(e){return this.validationFn(e)}validateUsingKnownGoodVersion(e,t){return Object.is(e,t)?e:this.validateUsingKnownGoodVersionFn?this.validateUsingKnownGoodVersionFn(e,t):this.validate(t)}isValid(e){try{return this.validate(e),!0}catch{return!1}}nullable(){return Mme(this)}optional(){return Xee(this)}refine(e){return new Hi(t=>e(this.validate(t)),(t,n)=>{const i=this.validateUsingKnownGoodVersion(t,n);return Object.is(t,i)?t:e(i)})}check(e,t){return typeof e=="string"?this.refine(n=>(go(`(check ${e})`,()=>t(n)),n)):this.refine(n=>(e(n),n))}}class Tme extends Hi{constructor(e){super(t=>{const n=zj.validate(t);for(let i=0;i<n.length;i++)go(i,()=>e.validate(n[i]));return n},(t,n)=>{if(!e.validateUsingKnownGoodVersion)return this.validate(n);const i=zj.validate(n);let o=t.length!==i.length;for(let s=0;s<i.length;s++){const a=i[s];if(s>=t.length){o=!0,go(s,()=>e.validate(a));continue}if(Object.is(t[s],a))continue;const c=go(s,()=>e.validateUsingKnownGoodVersion(t[s],a));Object.is(c,t[s])||(o=!0)}return o?n:t}),this.itemValidator=e}nonEmpty(){return this.check(e=>{if(e.length===0)throw new dr("Expected a non-empty array")})}lengthGreaterThan1(){return this.check(e=>{if(e.length<=1)throw new dr("Expected an array with length greater than 1")})}}class Kv extends Hi{constructor(e,t=!1){super(n=>{if(typeof n!="object"||n===null)throw new dr(`Expected object, got ${Zc(n)}`);for(const[i,o]of Object.entries(e))go(i,()=>{o.validate(bi(n,i))});if(!t){for(const i of Object.keys(n))if(!ss(e,i))throw new dr("Unexpected property",[i])}return n},(n,i)=>{if(typeof i!="object"||i===null)throw new dr(`Expected object, got ${Zc(i)}`);let o=!1;for(const[s,a]of Object.entries(e)){const c=bi(n,s),l=bi(i,s);if(Object.is(c,l))continue;const d=go(s,()=>{const f=a;return f.validateUsingKnownGoodVersion?f.validateUsingKnownGoodVersion(c,l):f.validate(l)});Object.is(d,c)||(o=!0)}if(!t){for(const s of Object.keys(i))if(!ss(e,s))throw new dr("Unexpected property",[s])}for(const s of Object.keys(n))if(!ss(i,s)){o=!0;break}return o?i:n}),this.config=e,this.shouldAllowUnknownProperties=t}allowUnknownProperties(){return new Kv(this.config,!0)}extend(e){return new Kv({...this.config,...e})}}class $m extends Hi{constructor(e,t,n,i){super(o=>{this.expectObject(o);const{matchingSchema:s,variant:a}=this.getMatchingSchemaAndVariant(o);return s===void 0?this.unknownValueValidation(o,a):go(`(${e} = ${a})`,()=>s.validate(o))},(o,s)=>{this.expectObject(s),this.expectObject(o);const{matchingSchema:a,variant:c}=this.getMatchingSchemaAndVariant(s);return a===void 0?this.unknownValueValidation(s,c):bi(o,e)!==bi(s,e)?go(`(${e} = ${c})`,()=>a.validate(s)):go(`(${e} = ${c})`,()=>a.validateUsingKnownGoodVersion?a.validateUsingKnownGoodVersion(o,s):a.validate(s))}),this.key=e,this.config=t,this.unknownValueValidation=n,this.useNumberKeys=i}expectObject(e){if(typeof e!="object"||e===null)throw new dr(`Expected an object, got ${Zc(e)}`,[])}getMatchingSchemaAndVariant(e){const t=bi(e,this.key);if(!this.useNumberKeys&&typeof t!="string")throw new dr(`Expected a string for key "${this.key}", got ${Zc(t)}`);if(this.useNumberKeys&&!Number.isFinite(Number(t)))throw new dr(`Expected a number for key "${this.key}", got "${t}"`);return{matchingSchema:ss(this.config,t)?this.config[t]:void 0,variant:t}}validateUnknownVariants(e){return new $m(this.key,this.config,e,this.useNumberKeys)}}class Ame extends Hi{constructor(e,t){super(n=>{if(typeof n!="object"||n===null)throw new dr(`Expected object, got ${Zc(n)}`);for(const[i,o]of Object.entries(n))go(i,()=>{e.validate(i),t.validate(o)});return n},(n,i)=>{if(typeof i!="object"||i===null)throw new dr(`Expected object, got ${Zc(i)}`);let o=!1;for(const[s,a]of Object.entries(i)){if(!ss(n,s)){o=!0,go(s,()=>{e.validate(s),t.validate(a)});continue}const c=bi(n,s),l=a;if(Object.is(c,l))continue;const d=go(s,()=>t.validateUsingKnownGoodVersion?t.validateUsingKnownGoodVersion(c,l):t.validate(l));Object.is(d,c)||(o=!0)}for(const s of Object.keys(n))if(!ss(i,s)){o=!0;break}return o?i:n}),this.keyValidator=e,this.valueValidator=t}}function oT(r){return new Hi(e=>{if(typeof e!==r)throw new dr(`Expected ${r}, got ${Zc(e)}`);return e})}const Rme=new Hi(r=>r),zt=oT("string"),Dt=oT("number").check(r=>{if(Number.isNaN(r))throw new dr("Expected a number, got NaN");if(!Number.isFinite(r))throw new dr(`Expected a finite number, got ${r}`)}),Gv=Dt.check(r=>{if(r<0)throw new dr(`Expected a positive number, got ${r}`)}),_n=Dt.check(r=>{if(r<=0)throw new dr(`Expected a non-zero positive number, got ${r}`)}),Yee=Dt.check(r=>{if(!Number.isInteger(r))throw new dr(`Expected an integer, got ${r}`)}),sv=Yee.check(r=>{if(r<0)throw new dr(`Expected a positive integer, got ${r}`)}),kme=Yee.check(r=>{if(r<=0)throw new dr(`Expected a non-zero positive integer, got ${r}`)}),tr=oT("boolean");function Pi(r){return new Hi(e=>{if(e!==r)throw new dr(`Expected ${r}, got ${JSON.stringify(e)}`);return r})}const zj=new Hi(r=>{if(!Array.isArray(r))throw new dr(`Expected an array, got ${Zc(r)}`);return r});function Jn(r){return new Tme(r)}function nr(r){return new Kv(r)}function PP(r){return typeof r=="object"&&r!==null&&(Object.getPrototypeOf(r)===Object.prototype||Object.getPrototypeOf(r)===null||Object.getPrototypeOf(r)===mve)}function CP(r){return r===null||typeof r=="number"||typeof r=="string"||typeof r=="boolean"?!0:Array.isArray(r)?r.every(CP):PP(r)?Object.values(r).every(CP):!1}const ei=new Hi(r=>{if(CP(r))return r;throw new dr(`Expected json serializable value, got ${typeof r}`)},(r,e)=>{if(Array.isArray(r)&&Array.isArray(e)){let t=r.length!==e.length;for(let n=0;n<e.length;n++){if(n>=r.length){t=!0,ei.validate(e[n]);continue}const i=r[n],o=e[n];if(Object.is(i,o))continue;const s=ei.validateUsingKnownGoodVersion(i,o);Object.is(s,i)||(t=!0)}return t?e:r}else if(PP(r)&&PP(e)){let t=!1;for(const n of Object.keys(e)){if(!ss(r,n)){t=!0,ei.validate(e[n]);continue}const i=r[n],o=e[n];if(Object.is(i,o))continue;const s=ei.validateUsingKnownGoodVersion(i,o);Object.is(s,i)||(t=!0)}for(const n of Object.keys(r))if(!ss(e,n)){t=!0;break}return t?e:r}else return ei.validate(e)});function Vv(r,e){return new Ame(r,e)}function sT(r,e){return new $m(r,e,(t,n)=>{throw new dr(`Expected one of ${Object.keys(e).map(i=>JSON.stringify(i)).join(" or ")}, got ${JSON.stringify(n)}`,[r])},!1)}function Ome(r,e){return new $m(r,e,(t,n)=>{throw new dr(`Expected one of ${Object.keys(e).map(i=>JSON.stringify(i)).join(" or ")}, got ${JSON.stringify(n)}`,[r])},!0)}function Ta(r,e){return new Hi(t=>go(r,()=>e.validate(t)),(t,n)=>go(r,()=>e.validateUsingKnownGoodVersion?e.validateUsingKnownGoodVersion(t,n):e.validate(n)))}function qm(r){return new Hi(e=>{if(!r.has(e)){const t=Array.from(r,n=>JSON.stringify(n)).join(" or ");throw new dr(`Expected ${t}, got ${e}`)}return e})}function Xee(r){return new Hi(e=>{if(e!==void 0)return r.validate(e)},(e,t)=>{if(!(e===void 0&&t===void 0)&&t!==void 0)return r.validateUsingKnownGoodVersion&&e!==void 0?r.validateUsingKnownGoodVersion(e,t):r.validate(t)})}function Mme(r){return new Hi(e=>e===null?null:r.validate(e),(e,t)=>t===null?null:r.validateUsingKnownGoodVersion&&e!==null?r.validateUsingKnownGoodVersion(e,t):r.validate(t))}function Bm(...r){return qm(new Set(r))}function aT(r){try{return new URL(r)}catch{if(r.startsWith("/")||r.startsWith("./"))try{return new URL(r,"http://example.com")}catch{throw new dr(`Expected a valid url, got ${JSON.stringify(r)}`)}throw new dr(`Expected a valid url, got ${JSON.stringify(r)}`)}}const jme=new Set(["http:","https:","mailto:"]),Do=zt.check(r=>{if(r==="")return;const e=aT(r);if(!jme.has(e.protocol.toLowerCase()))throw new dr(`Expected a valid url, got ${JSON.stringify(r)} (invalid protocol)`)}),Dme=new Set(["http:","https:","data:","asset:"]),Vl=zt.check(r=>{if(r==="")return;const e=aT(r);if(!Dme.has(e.protocol.toLowerCase()))throw new dr(`Expected a valid url, got ${JSON.stringify(r)} (invalid protocol)`)});zt.check(r=>{if(r==="")return;if(!aT(r).protocol.toLowerCase().match(/^https?:$/))throw new dr(`Expected a valid url, got ${JSON.stringify(r)} (invalid protocol)`)});const cT=zt.refine(r=>{try{return ave(r),r}catch{throw new dr(`Expected an index key, got ${JSON.stringify(r)}`)}});il("@tldraw/validate","3.9.0","esm");function Mo(r){return zt.refine(e=>{if(!e.startsWith(`${r}:`))throw new Error(`${r} ID must start with "${r}:"`);return e})}const Um=Mo("asset");function lT(r,e){return nr({id:Um,typeName:Pi("asset"),type:Pi(r),props:e,meta:ei})}const Yl=nr({x:Dt,y:Dt,z:Dt.optional()}),ch=nr({x:Dt,y:Dt,w:Dt,h:Dt}),Zee=Dt.check(r=>{if(r<0||r>1)throw new dr("Opacity must be between 0 and 1")}),Lme=zt.refine(r=>{if(!r.startsWith("page:")&&!r.startsWith("shape:"))throw new Error('Parent ID must start with "page:" or "shape:"');return r}),es=Mo("shape");function Fme(r,e,t){return nr({id:es,typeName:Pi("shape"),x:Dt,y:Dt,rotation:Dt,index:cT,parentId:Lme,type:Pi(r),isLocked:tr,opacity:Zee,props:e?nr(e):ei,meta:t?nr(t):ei})}const Nme=Mo("binding");function $me(r,e,t){return nr({id:Nme,typeName:Pi("binding"),type:Pi(r),fromId:es,toId:es,props:e?nr(e):ei,meta:t?nr(t):ei})}mo("com.tldraw.binding",{});qo({sequenceId:"com.tldraw.binding",recordType:"binding",sequence:[]});function Wl(r){return`binding:${Er()}`}function qme(r){return Ca("binding",{scope:"document",validator:Ta("binding",sT("type",jh(r,(e,{props:t,meta:n})=>$me(e,t,n))))}).withDefaultProperties(()=>({meta:{}}))}class oi{constructor(e,t,n){this.id=e,this.defaultValue=t,this.type=n}static define(e,t){const{defaultValue:n,type:i=Rme}=t;return new oi(e,n,i)}static defineEnum(e,t){const{defaultValue:n,values:i}=t;return new Bme(e,n,i)}setDefaultValue(e){this.defaultValue=e}validate(e){return this.type.validate(e)}validateUsingKnownGoodVersion(e,t){return this.type.validateUsingKnownGoodVersion?this.type.validateUsingKnownGoodVersion(e,t):this.validate(t)}}class Bme extends oi{constructor(e,t,n){super(e,t,Bm(...n)),this.values=n}}const wg=mo("com.tldraw.shape",{AddIsLocked:1,HoistOpacity:2,AddMeta:3,AddWhite:4}),Ume=qo({sequenceId:"com.tldraw.shape",recordType:"shape",sequence:[{id:wg.AddIsLocked,up:r=>{r.isLocked=!1},down:r=>{delete r.isLocked}},{id:wg.HoistOpacity,up:r=>{r.opacity=Number(r.props.opacity??"1"),delete r.props.opacity},down:r=>{const e=r.opacity;delete r.opacity,r.props.opacity=e<.175?"0.1":e<.375?"0.25":e<.625?"0.5":e<.875?"0.75":"1"}},{id:wg.AddMeta,up:r=>{r.meta={}}},{id:wg.AddWhite,up:r=>{},down:r=>{r.props.color==="white"&&(r.props.color="black")}}]});function ud(r){return r?r.typeName==="shape":!1}function co(r){return r?r.startsWith("shape:"):!1}function Tr(r){return`shape:${r??Er()}`}function Qee(r){const e=new Map;for(const[t,n]of Object.entries(r))if(n instanceof oi){if(e.has(n))throw new Error(`Duplicate style prop ${n.id}. Each style prop can only be used once within a shape.`);e.set(n,t)}return e}function Ls(r,e){return jh(e,(t,n)=>`com.tldraw.shape.${r}/${n}`)}function zme(r){return Ca("shape",{scope:"document",validator:Ta("shape",sT("type",jh(r,(e,{props:t,meta:n})=>Fme(e,t,n))))}).withDefaultProperties(()=>({x:0,y:0,rotation:0,isLocked:!1,opacity:1,meta:{}}))}function Hj(r,e){const t=[];for(const[n,{migrations:i}]of Object.entries(e)){const o=`com.tldraw.${r}.${n}`;i?"sequenceId"in i?(Jt(o===i.sequenceId,`sequenceId mismatch for ${n} ${Nm} migrations. Expected '${o}', got '${i.sequenceId}'`),t.push(i)):"sequence"in i?t.push(pd({sequenceId:o,retroactive:!1,sequence:i.sequence.map(s=>"id"in s?Jee(r,n,s):s)})):t.push(pd({sequenceId:o,retroactive:!1,sequence:Object.keys(i.migrators).map(s=>Number(s)).sort((s,a)=>s-a).map(s=>({id:`${o}/${s}`,scope:"record",filter:a=>a.typeName===r&&a.type===n,up:a=>{const c=i.migrators[s].up(a);if(c)return c},down:a=>{const c=i.migrators[s].down(a);if(c)return c}}))})):t.push(pd({sequenceId:o,retroactive:!1,sequence:[]}))}return t}function Jee(r,e,t){return{id:t.id,dependsOn:t.dependsOn,scope:"record",filter:n=>n.typeName===r&&n.type===e,up:n=>{const i=t.up(n.props);i&&(n.props=i)},down:typeof t.down=="function"?n=>{const i=t.down(n.props);i&&(n.props=i)}:void 0}}const ete=["black","grey","light-violet","violet","blue","light-blue","yellow","orange","green","light-green","light-red","red","white"],Yv={lightMode:{id:"light",text:"#000000",background:"rgb(249, 250, 251)",solid:"#fcfffe",black:{solid:"#1d1d1d",fill:"#1d1d1d",note:{fill:"#FCE19C",text:"#000000"},semi:"#e8e8e8",pattern:"#494949",highlight:{srgb:"#fddd00",p3:"color(display-p3 0.972 0.8705 0.05)"}},blue:{solid:"#4465e9",fill:"#4465e9",note:{fill:"#8AA3FF",text:"#000000"},semi:"#dce1f8",pattern:"#6681ee",highlight:{srgb:"#10acff",p3:"color(display-p3 0.308 0.6632 0.9996)"}},green:{solid:"#099268",fill:"#099268",note:{fill:"#6FC896",text:"#000000"},semi:"#d3e9e3",pattern:"#39a785",highlight:{srgb:"#00ffc8",p3:"color(display-p3 0.2536 0.984 0.7981)"}},grey:{solid:"#9fa8b2",fill:"#9fa8b2",note:{fill:"#C0CAD3",text:"#000000"},semi:"#eceef0",pattern:"#bcc3c9",highlight:{srgb:"#cbe7f1",p3:"color(display-p3 0.8163 0.9023 0.9416)"}},"light-blue":{solid:"#4ba1f1",fill:"#4ba1f1",note:{fill:"#9BC4FD",text:"#000000"},semi:"#ddedfa",pattern:"#6fbbf8",highlight:{srgb:"#00f4ff",p3:"color(display-p3 0.1512 0.9414 0.9996)"}},"light-green":{solid:"#4cb05e",fill:"#4cb05e",note:{fill:"#98D08A",text:"#000000"},semi:"#dbf0e0",pattern:"#65cb78",highlight:{srgb:"#65f641",p3:"color(display-p3 0.563 0.9495 0.3857)"}},"light-red":{solid:"#f87777",fill:"#f87777",note:{fill:"#F7A5A1",text:"#000000"},semi:"#f4dadb",pattern:"#fe9e9e",highlight:{srgb:"#ff7fa3",p3:"color(display-p3 0.9988 0.5301 0.6397)"}},"light-violet":{solid:"#e085f4",fill:"#e085f4",note:{fill:"#DFB0F9",text:"#000000"},semi:"#f5eafa",pattern:"#e9acf8",highlight:{srgb:"#ff88ff",p3:"color(display-p3 0.9676 0.5652 0.9999)"}},orange:{solid:"#e16919",fill:"#e16919",note:{fill:"#FAA475",text:"#000000"},semi:"#f8e2d4",pattern:"#f78438",highlight:{srgb:"#ffa500",p3:"color(display-p3 0.9988 0.6905 0.266)"}},red:{solid:"#e03131",fill:"#e03131",note:{fill:"#FC8282",text:"#000000"},semi:"#f4dadb",pattern:"#e55959",highlight:{srgb:"#ff636e",p3:"color(display-p3 0.9992 0.4376 0.45)"}},violet:{solid:"#ae3ec9",fill:"#ae3ec9",note:{fill:"#DB91FD",text:"#000000"},semi:"#ecdcf2",pattern:"#bd63d3",highlight:{srgb:"#c77cff",p3:"color(display-p3 0.7469 0.5089 0.9995)"}},yellow:{solid:"#f1ac4b",fill:"#f1ac4b",note:{fill:"#FED49A",text:"#000000"},semi:"#f9f0e6",pattern:"#fecb92",highlight:{srgb:"#fddd00",p3:"color(display-p3 0.972 0.8705 0.05)"}},white:{solid:"#FFFFFF",fill:"#FFFFFF",semi:"#f5f5f5",pattern:"#f9f9f9",note:{fill:"#FFFFFF",text:"#000000"},highlight:{srgb:"#ffffff",p3:"color(display-p3 1 1 1)"}}},darkMode:{id:"dark",text:"hsl(210, 17%, 98%)",background:"hsl(240, 5%, 6.5%)",solid:"#010403",black:{solid:"#f2f2f2",fill:"#f2f2f2",note:{fill:"#2c2c2c",text:"#f2f2f2"},semi:"#2c3036",pattern:"#989898",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.7225 0.0312)"}},blue:{solid:"#4f72fc",fill:"#4f72fc",note:{fill:"#2A3F98",text:"#f2f2f2"},semi:"#262d40",pattern:"#3a4b9e",highlight:{srgb:"#0079d2",p3:"color(display-p3 0.0032 0.4655 0.7991)"}},green:{solid:"#099268",fill:"#099268",note:{fill:"#014429",text:"#f2f2f2"},semi:"#253231",pattern:"#366a53",highlight:{srgb:"#009774",p3:"color(display-p3 0.0085 0.582 0.4604)"}},grey:{solid:"#9398b0",fill:"#9398b0",note:{fill:"#56595F",text:"#f2f2f2"},semi:"#33373c",pattern:"#7c8187",highlight:{srgb:"#9cb4cb",p3:"color(display-p3 0.6299 0.7012 0.7856)"}},"light-blue":{solid:"#4dabf7",fill:"#4dabf7",note:{fill:"#1F5495",text:"#f2f2f2"},semi:"#2a3642",pattern:"#4d7aa9",highlight:{srgb:"#00bdc8",p3:"color(display-p3 0.0023 0.7259 0.7735)"}},"light-green":{solid:"#40c057",fill:"#40c057",note:{fill:"#21581D",text:"#f2f2f2"},semi:"#2a3830",pattern:"#4e874e",highlight:{srgb:"#00a000",p3:"color(display-p3 0.2711 0.6172 0.0195)"}},"light-red":{solid:"#ff8787",fill:"#ff8787",note:{fill:"#923632",text:"#f2f2f2"},semi:"#3b3235",pattern:"#a56767",highlight:{srgb:"#db005b",p3:"color(display-p3 0.7849 0.0585 0.3589)"}},"light-violet":{solid:"#e599f7",fill:"#e599f7",note:{fill:"#762F8E",text:"#f2f2f2"},semi:"#383442",pattern:"#9770a9",highlight:{srgb:"#c400c7",p3:"color(display-p3 0.7024 0.0403 0.753)"}},orange:{solid:"#f76707",fill:"#f76707",note:{fill:"#843906",text:"#f2f2f2"},semi:"#3a2e2a",pattern:"#9f552d",highlight:{srgb:"#d07a00",p3:"color(display-p3 0.7699 0.4937 0.0085)"}},red:{solid:"#e03131",fill:"#e03131",note:{fill:"#89231A",text:"#f2f2f2"},semi:"#36292b",pattern:"#8f3734",highlight:{srgb:"#de002c",p3:"color(display-p3 0.7978 0.0509 0.2035)"}},violet:{solid:"#ae3ec9",fill:"#ae3ec9",note:{fill:"#681683",text:"#f2f2f2"},semi:"#31293c",pattern:"#763a8b",highlight:{srgb:"#9e00ee",p3:"color(display-p3 0.5651 0.0079 0.8986)"}},yellow:{solid:"#ffc034",fill:"#ffc034",note:{fill:"#98571B",text:"#f2f2f2"},semi:"#3c3934",pattern:"#fecb92",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.7225 0.0312)"}},white:{solid:"#f3f3f3",fill:"#f3f3f3",semi:"#f5f5f5",pattern:"#f9f9f9",note:{fill:"#eaeaea",text:"#1d1d1d"},highlight:{srgb:"#ffffff",p3:"color(display-p3 1 1 1)"}}}};function uc(r){return r.isDarkMode?Yv.darkMode:Yv.lightMode}const Lo=oi.defineEnum("tldraw:color",{defaultValue:"black",values:ete}),uT=oi.defineEnum("tldraw:labelColor",{defaultValue:"black",values:ete}),Xl=oi.defineEnum("tldraw:dash",{defaultValue:"draw",values:["draw","solid","dashed","dotted"]}),Zl=oi.defineEnum("tldraw:fill",{defaultValue:"none",values:["none","semi","solid","pattern","fill"]}),ga=oi.defineEnum("tldraw:font",{defaultValue:"draw",values:["draw","sans","serif","mono"]}),tte={draw:"'tldraw_draw', sans-serif",sans:"'tldraw_sans', sans-serif",serif:"'tldraw_serif', serif",mono:"'tldraw_mono', monospace"},va=oi.defineEnum("tldraw:size",{defaultValue:"m",values:["s","m","l","xl"]}),rte=["arrow","triangle","square","dot","pipe","diamond","inverted","bar","none"],Xv=oi.defineEnum("tldraw:arrowheadStart",{defaultValue:"none",values:rte}),Zv=oi.defineEnum("tldraw:arrowheadEnd",{defaultValue:"arrow",values:rte}),nte={labelColor:uT,color:Lo,fill:Zl,dash:Xl,size:va,arrowheadStart:Xv,arrowheadEnd:Zv,font:ga,start:Yl,end:Yl,bend:Dt,text:zt,labelPosition:Dt,scale:_n},od=Ls("arrow",{AddLabelColor:1,AddIsPrecise:2,AddLabelPosition:3,ExtractBindings:4,AddScale:5});function bg(r){return Jee("shape","arrow",r)}const ite=pd({sequenceId:"com.tldraw.shape.arrow",retroactive:!1,sequence:[bg({id:od.AddLabelColor,up:r=>{r.labelColor="black"},down:"retired"}),bg({id:od.AddIsPrecise,up:({start:r,end:e})=>{r.type==="binding"&&(r.isPrecise=!(r.normalizedAnchor.x===.5&&r.normalizedAnchor.y===.5)),e.type==="binding"&&(e.isPrecise=!(e.normalizedAnchor.x===.5&&e.normalizedAnchor.y===.5))},down:({start:r,end:e})=>{r.type==="binding"&&(r.isPrecise||(r.normalizedAnchor={x:.5,y:.5}),delete r.isPrecise),e.type==="binding"&&(e.isPrecise||(e.normalizedAnchor={x:.5,y:.5}),delete e.isPrecise)}}),bg({id:od.AddLabelPosition,up:r=>{r.labelPosition=.5},down:r=>{delete r.labelPosition}}),{id:od.ExtractBindings,scope:"store",up:r=>{const e=Object.values(r).filter(t=>t.typeName==="shape"&&t.type==="arrow");for(const t of e){const{start:n,end:i}=t.props;if(n.type==="binding"){const o=Wl(),s={typeName:"binding",id:o,type:"arrow",fromId:t.id,toId:n.boundShapeId,meta:{},props:{terminal:"start",normalizedAnchor:n.normalizedAnchor,isExact:n.isExact,isPrecise:n.isPrecise}};r[o]=s,t.props.start={x:0,y:0}}else delete t.props.start.type;if(i.type==="binding"){const o=Wl(),s={typeName:"binding",id:o,type:"arrow",fromId:t.id,toId:i.boundShapeId,meta:{},props:{terminal:"end",normalizedAnchor:i.normalizedAnchor,isExact:i.isExact,isPrecise:i.isPrecise}};r[o]=s,t.props.end={x:0,y:0}}else delete t.props.end.type}}},bg({id:od.AddScale,up:r=>{r.scale=1},down:r=>{delete r.scale}})]}),ote={terminal:Bm("start","end"),normalizedAnchor:Yl,isExact:tr,isPrecise:tr},ste={sequence:[{dependsOn:[od.ExtractBindings]}]},Hme=Ta("camera",nr({typeName:Pi("camera"),id:Mo("camera"),x:Dt,y:Dt,z:Dt,meta:ei})),Wme=mo("com.tldraw.camera",{AddMeta:1}),Kme=qo({sequenceId:"com.tldraw.camera",recordType:"camera",sequence:[{id:Wme.AddMeta,up:r=>{r.meta={}}}]}),la=Ca("camera",{validator:Hme,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,z:1,meta:{}})),Gme=new Set(["none","default","pointer","cross","grab","rotate","grabbing","resize-edge","resize-corner","text","move","ew-resize","ns-resize","nesw-resize","nwse-resize","nesw-rotate","nwse-rotate","swne-rotate","senw-rotate","zoom-in","zoom-out"]),ate=qm(Gme),Vme=nr({type:ate,rotation:Dt}),Yme=new Set(["accent","white","black","selection-stroke","selection-fill","laser","muted-1"]),Xme=qm(Yme),Zme=new Set(["starting","paused","active","stopping"]),cte=nr({id:zt,points:Jn(Yl),size:Gv,color:Xme,opacity:Dt,state:qm(Zme),delay:Dt,shrink:Dt,taper:tr}),Sh=Mo("page"),Qme=Ta("page",nr({typeName:Pi("page"),id:Sh,name:zt,index:cT,meta:ei})),Jme=mo("com.tldraw.page",{AddMeta:1}),eye=qo({sequenceId:"com.tldraw.page",recordType:"page",sequence:[{id:Jme.AddMeta,up:r=>{r.meta={}}}]}),Fo=Ca("page",{validator:Qme,scope:"document"}).withDefaultProperties(()=>({meta:{}}));function oo(r){return Fo.isId(r)}const tye={id:!1,typeName:!1,currentPageId:!1,opacityForNextShape:!1,stylesForNextShape:!1,followingUserId:!1,highlightedUserIds:!1,brush:!1,cursor:!1,scribbles:!1,isFocusMode:!0,isDebugMode:!0,isToolLocked:!0,exportBackground:!0,screenBounds:!0,insets:!0,zoomBrush:!1,chatMessage:!1,isChatting:!1,isPenMode:!1,isGridMode:!0,isFocused:!0,devicePixelRatio:!0,isCoarsePointer:!0,isHoveringCanvas:!1,openMenus:!1,isChangingStyle:!1,isReadonly:!0,meta:!1,duplicateProps:!1};function lte(r){return r?sh(r,e=>tye[e]):null}Mo("instance");function rye(r){const e={};for(const[n,i]of r)e[n]=Xee(i);const t=Ta("instance",nr({typeName:Pi("instance"),id:Mo("instance"),currentPageId:Sh,followingUserId:zt.nullable(),brush:ch.nullable(),opacityForNextShape:Zee,stylesForNextShape:nr(e),cursor:Vme,scribbles:Jn(cte),isFocusMode:tr,isDebugMode:tr,isToolLocked:tr,exportBackground:tr,screenBounds:ch,insets:Jn(tr),zoomBrush:ch.nullable(),isPenMode:tr,isGridMode:tr,chatMessage:zt,isChatting:tr,highlightedUserIds:Jn(zt),isFocused:tr,devicePixelRatio:Dt,isCoarsePointer:tr,isHoveringCanvas:tr.nullable(),openMenus:Jn(zt),isChangingStyle:tr,isReadonly:tr,meta:ei,duplicateProps:nr({shapeIds:Jn(Mo("shape")),offset:nr({x:Dt,y:Dt})}).nullable()}));return Ca("instance",{validator:t,scope:"session",ephemeralKeys:{currentPageId:!1,meta:!1,followingUserId:!0,opacityForNextShape:!0,stylesForNextShape:!0,brush:!0,cursor:!0,scribbles:!0,isFocusMode:!0,isDebugMode:!0,isToolLocked:!0,exportBackground:!0,screenBounds:!0,insets:!0,zoomBrush:!0,isPenMode:!0,isGridMode:!0,chatMessage:!0,isChatting:!0,highlightedUserIds:!0,isFocused:!0,devicePixelRatio:!0,isCoarsePointer:!0,isHoveringCanvas:!0,openMenus:!0,isChangingStyle:!0,isReadonly:!0,duplicateProps:!0}}).withDefaultProperties(()=>({followingUserId:null,opacityForNextShape:1,stylesForNextShape:{},brush:null,scribbles:[],cursor:{type:"default",rotation:0},isFocusMode:!1,exportBackground:!1,isDebugMode:!1,isToolLocked:!1,screenBounds:{x:0,y:0,w:1080,h:720},insets:[!1,!1,!1,!1],zoomBrush:null,isGridMode:!1,isPenMode:!1,chatMessage:"",isChatting:!1,highlightedUserIds:[],isFocused:!1,devicePixelRatio:typeof window>"u"?1:window.devicePixelRatio,isCoarsePointer:!1,isHoveringCanvas:null,openMenus:[],isChangingStyle:!1,isReadonly:!1,meta:{},duplicateProps:null}))}const Wr=mo("com.tldraw.instance",{AddTransparentExportBgs:1,RemoveDialog:2,AddToolLockMode:3,RemoveExtraPropsForNextShape:4,AddLabelColor:5,AddFollowingUserId:6,RemoveAlignJustify:7,AddZoom:8,AddVerticalAlign:9,AddScribbleDelay:10,RemoveUserId:11,AddIsPenModeAndIsGridMode:12,HoistOpacity:13,AddChat:14,AddHighlightedUserIds:15,ReplacePropsForNextShapeWithStylesForNextShape:16,AddMeta:17,RemoveCursorColor:18,AddLonelyProperties:19,ReadOnlyReadonly:20,AddHoveringCanvas:21,AddScribbles:22,AddInset:23,AddDuplicateProps:24,RemoveCanMoveCamera:25}),nye=qo({sequenceId:"com.tldraw.instance",recordType:"instance",sequence:[{id:Wr.AddTransparentExportBgs,up:r=>({...r,exportBackground:!0})},{id:Wr.RemoveDialog,up:({dialog:r,...e})=>e},{id:Wr.AddToolLockMode,up:r=>({...r,isToolLocked:!1})},{id:Wr.RemoveExtraPropsForNextShape,up:({propsForNextShape:r,...e})=>({...e,propsForNextShape:Object.fromEntries(Object.entries(r).filter(([t])=>["color","labelColor","dash","fill","size","font","align","verticalAlign","icon","geo","arrowheadStart","arrowheadEnd","spline"].includes(t)))})},{id:Wr.AddLabelColor,up:({propsForNextShape:r,...e})=>({...e,propsForNextShape:{...r,labelColor:"black"}})},{id:Wr.AddFollowingUserId,up:r=>({...r,followingUserId:null})},{id:Wr.RemoveAlignJustify,up:r=>{let e=r.propsForNextShape.align;return e==="justify"&&(e="start"),{...r,propsForNextShape:{...r.propsForNextShape,align:e}}}},{id:Wr.AddZoom,up:r=>({...r,zoomBrush:null})},{id:Wr.AddVerticalAlign,up:r=>({...r,propsForNextShape:{...r.propsForNextShape,verticalAlign:"middle"}})},{id:Wr.AddScribbleDelay,up:r=>r.scribble!==null?{...r,scribble:{...r.scribble,delay:0}}:{...r}},{id:Wr.RemoveUserId,up:({userId:r,...e})=>e},{id:Wr.AddIsPenModeAndIsGridMode,up:r=>({...r,isPenMode:!1,isGridMode:!1})},{id:Wr.HoistOpacity,up:({propsForNextShape:{opacity:r,...e},...t})=>({...t,opacityForNextShape:Number(r??"1"),propsForNextShape:e})},{id:Wr.AddChat,up:r=>({...r,chatMessage:"",isChatting:!1})},{id:Wr.AddHighlightedUserIds,up:r=>({...r,highlightedUserIds:[]})},{id:Wr.ReplacePropsForNextShapeWithStylesForNextShape,up:({propsForNextShape:r,...e})=>({...e,stylesForNextShape:{}})},{id:Wr.AddMeta,up:r=>({...r,meta:{}})},{id:Wr.RemoveCursorColor,up:r=>{const{color:e,...t}=r.cursor;return{...r,cursor:t}}},{id:Wr.AddLonelyProperties,up:r=>({...r,canMoveCamera:!0,isFocused:!1,devicePixelRatio:1,isCoarsePointer:!1,openMenus:[],isChangingStyle:!1,isReadOnly:!1})},{id:Wr.ReadOnlyReadonly,up:({isReadOnly:r,...e})=>({...e,isReadonly:r})},{id:Wr.AddHoveringCanvas,up:r=>({...r,isHoveringCanvas:null})},{id:Wr.AddScribbles,up:({scribble:r,...e})=>({...e,scribbles:[]})},{id:Wr.AddInset,up:r=>({...r,insets:[!1,!1,!1,!1]}),down:({insets:r,...e})=>({...e})},{id:Wr.AddDuplicateProps,up:r=>({...r,duplicateProps:null}),down:({duplicateProps:r,...e})=>({...e})},{id:Wr.RemoveCanMoveCamera,up:({canMoveCamera:r,...e})=>({...e}),down:r=>({...r,canMoveCamera:!0})}]}),Bi="instance:instance",iye=Ta("instance_page_state",nr({typeName:Pi("instance_page_state"),id:Mo("instance_page_state"),pageId:Sh,selectedShapeIds:Jn(es),hintingShapeIds:Jn(es),erasingShapeIds:Jn(es),hoveredShapeId:es.nullable(),editingShapeId:es.nullable(),croppingShapeId:es.nullable(),focusedGroupId:es.nullable(),meta:ei})),Nf=mo("com.tldraw.instance_page_state",{AddCroppingId:1,RemoveInstanceIdAndCameraId:2,AddMeta:3,RenameProperties:4,RenamePropertiesAgain:5}),oye=qo({sequenceId:"com.tldraw.instance_page_state",recordType:"instance_page_state",sequence:[{id:Nf.AddCroppingId,up(r){r.croppingShapeId=null}},{id:Nf.RemoveInstanceIdAndCameraId,up(r){delete r.instanceId,delete r.cameraId}},{id:Nf.AddMeta,up:r=>{r.meta={}}},{id:Nf.RenameProperties,up:r=>{},down:r=>{}},{id:Nf.RenamePropertiesAgain,up:r=>{r.selectedShapeIds=r.selectedIds,delete r.selectedIds,r.hintingShapeIds=r.hintingIds,delete r.hintingIds,r.erasingShapeIds=r.erasingIds,delete r.erasingIds,r.hoveredShapeId=r.hoveredId,delete r.hoveredId,r.editingShapeId=r.editingId,delete r.editingId,r.croppingShapeId=r.croppingShapeId??r.croppingId??null,delete r.croppingId,r.focusedGroupId=r.focusLayerId,delete r.focusLayerId},down:r=>{r.selectedIds=r.selectedShapeIds,delete r.selectedShapeIds,r.hintingIds=r.hintingShapeIds,delete r.hintingShapeIds,r.erasingIds=r.erasingShapeIds,delete r.erasingShapeIds,r.hoveredId=r.hoveredShapeId,delete r.hoveredShapeId,r.editingId=r.editingShapeId,delete r.editingShapeId,r.croppingId=r.croppingShapeId,delete r.croppingShapeId,r.focusLayerId=r.focusedGroupId,delete r.focusedGroupId}}]}),Cs=Ca("instance_page_state",{validator:iye,scope:"session",ephemeralKeys:{pageId:!1,selectedShapeIds:!1,editingShapeId:!1,croppingShapeId:!1,meta:!1,hintingShapeIds:!0,erasingShapeIds:!0,hoveredShapeId:!0,focusedGroupId:!0}}).withDefaultProperties(()=>({editingShapeId:null,croppingShapeId:null,selectedShapeIds:[],hoveredShapeId:null,erasingShapeIds:[],hintingShapeIds:[],focusedGroupId:null,meta:{}})),sye=Ta("pointer",nr({typeName:Pi("pointer"),id:Mo("pointer"),x:Dt,y:Dt,lastActivityTimestamp:Dt,meta:ei})),aye=mo("com.tldraw.pointer",{AddMeta:1}),cye=qo({sequenceId:"com.tldraw.pointer",recordType:"pointer",sequence:[{id:aye.AddMeta,up:r=>{r.meta={}}}]}),dT=Ca("pointer",{validator:sye,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,lastActivityTimestamp:0,meta:{}})),Qv=dT.createId("pointer"),lye=Ta("instance_presence",nr({typeName:Pi("instance_presence"),id:Mo("instance_presence"),userId:zt,userName:zt,lastActivityTimestamp:Dt.nullable(),followingUserId:zt.nullable(),cursor:nr({x:Dt,y:Dt,type:ate,rotation:Dt}).nullable(),color:zt,camera:nr({x:Dt,y:Dt,z:Dt}).nullable(),screenBounds:ch.nullable(),selectedShapeIds:Jn(Mo("shape")),currentPageId:Mo("page"),brush:ch.nullable(),scribbles:Jn(cte),chatMessage:zt,meta:ei})),Xu=mo("com.tldraw.instance_presence",{AddScribbleDelay:1,RemoveInstanceId:2,AddChatMessage:3,AddMeta:4,RenameSelectedShapeIds:5,NullableCameraCursor:6}),uye=qo({sequenceId:"com.tldraw.instance_presence",recordType:"instance_presence",sequence:[{id:Xu.AddScribbleDelay,up:r=>{r.scribble!==null&&(r.scribble.delay=0)}},{id:Xu.RemoveInstanceId,up:r=>{delete r.instanceId}},{id:Xu.AddChatMessage,up:r=>{r.chatMessage=""}},{id:Xu.AddMeta,up:r=>{r.meta={}}},{id:Xu.RenameSelectedShapeIds,up:r=>{}},{id:Xu.NullableCameraCursor,up:r=>{},down:r=>{r.camera===null&&(r.camera={x:0,y:0,z:1}),r.lastActivityTimestamp===null&&(r.lastActivityTimestamp=0),r.cursor===null&&(r.cursor={type:"default",x:0,y:0,rotation:0}),r.screenBounds===null&&(r.screenBounds={x:0,y:0,w:1,h:1})}}]}),dye=Ca("instance_presence",{validator:lye,scope:"presence"}).withDefaultProperties(()=>({lastActivityTimestamp:null,followingUserId:null,color:"#FF0000",camera:null,cursor:null,screenBounds:null,selectedShapeIds:[],brush:null,scribbles:[],chatMessage:"",meta:{}})),fye=Ta("document",nr({typeName:Pi("document"),id:Pi("document:document"),gridSize:Dt,name:zt,meta:ei})),Wj=mo("com.tldraw.document",{AddName:1,AddMeta:2}),hye=qo({sequenceId:"com.tldraw.document",recordType:"document",sequence:[{id:Wj.AddName,up:r=>{r.name=""},down:r=>{delete r.name}},{id:Wj.AddMeta,up:r=>{r.meta={}}}]}),fT=Ca("document",{validator:fye,scope:"document"}).withDefaultProperties(()=>({gridSize:10,name:"",meta:{}})),TP=fT.createId("document");function pye(r,e){return r.index<e.index?-1:r.index>e.index?1:0}function Kj(r){r.typeName==="asset"&&("src"in r&&(r.src="<redacted>"),"src"in r.props&&(r.props.src="<redacted>"))}function gye({error:r,phase:e,record:t,recordBefore:n}){throw OC(r,{tags:{origin:"store.validateRecord",storePhase:e,isExistingValidationIssue:e==="initialize"},extras:{recordBefore:n?Kj(Kr(n)):void 0,recordAfter:Kj(Kr(t))}}),r}function vye(){return[Fo.create({id:"page:page",name:"Page 1",index:"a1",meta:{}})]}function mye(r){const e=r.query.ids("page"),t=r.query.records("instance_page_state"),n=()=>{if(!r.has(TP))return r.put([fT.create({id:TP,name:r.props.defaultName})]),n();if(!r.has(Qv))return r.put([dT.create({id:Qv})]),n();const i=e.get();if(i.size===0)return r.put(vye()),n();const o=()=>[...i].map(d=>r.get(d)).sort(pye)[0].id,s=r.get(Bi);if(s){if(!i.has(s.currentPageId))return r.put([{...s,currentPageId:o()}]),n()}else return r.put([r.schema.types.instance.create({id:Bi,currentPageId:o(),exportBackground:!0})]),n();const a=new Set,c=new Set;for(const d of i){const f=Cs.createId(d);r.get(f)||a.add(f);const g=la.createId(d);r.has(g)||c.add(g)}a.size>0&&r.put([...a].map(d=>Cs.create({id:d,pageId:Cs.parseId(d)}))),c.size>0&&r.put([...c].map(d=>la.create({id:d})));const l=t.get();for(const d of l){if(!i.has(d.pageId)){r.remove([d.id]);continue}if(d.croppingShapeId&&!r.has(d.croppingShapeId))return r.put([{...d,croppingShapeId:null}]),n();if(d.focusedGroupId&&!r.has(d.focusedGroupId))return r.put([{...d,focusedGroupId:null}]),n();if(d.hoveredShapeId&&!r.has(d.hoveredShapeId))return r.put([{...d,hoveredShapeId:null}]),n();const f=d.selectedShapeIds.filter(m=>r.has(m));if(f.length!==d.selectedShapeIds.length)return r.put([{...d,selectedShapeIds:f}]),n();const h=d.hintingShapeIds.filter(m=>r.has(m));if(h.length!==d.hintingShapeIds.length)return r.put([{...d,hintingShapeIds:h}]),n();const g=d.erasingShapeIds.filter(m=>r.has(m));if(g.length!==d.erasingShapeIds.length)return r.put([{...d,erasingShapeIds:g}]),n()}};return n}const yye=lT("bookmark",nr({title:zt,description:zt,image:zt,favicon:zt,src:Vl.nullable()})),Gj=mo("com.tldraw.asset.bookmark",{MakeUrlsValid:1,AddFavicon:2}),Sye=qo({sequenceId:"com.tldraw.asset.bookmark",recordType:"asset",filter:r=>r.type==="bookmark",sequence:[{id:Gj.MakeUrlsValid,up:r=>{Vl.isValid(r.props.src)||(r.props.src="")},down:r=>{}},{id:Gj.AddFavicon,up:r=>{Vl.isValid(r.props.favicon)||(r.props.favicon="")},down:r=>{delete r.props.favicon}}]}),xye=lT("image",nr({w:Dt,h:Dt,name:zt,isAnimated:tr,mimeType:zt.nullable(),src:Vl.nullable(),fileSize:_n.optional()})),$f=mo("com.tldraw.asset.image",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5}),_ye=qo({sequenceId:"com.tldraw.asset.image",recordType:"asset",filter:r=>r.type==="image",sequence:[{id:$f.AddIsAnimated,up:r=>{r.props.isAnimated=!1},down:r=>{delete r.props.isAnimated}},{id:$f.RenameWidthHeight,up:r=>{r.props.w=r.props.width,r.props.h=r.props.height,delete r.props.width,delete r.props.height},down:r=>{r.props.width=r.props.w,r.props.height=r.props.h,delete r.props.w,delete r.props.h}},{id:$f.MakeUrlsValid,up:r=>{Vl.isValid(r.props.src)||(r.props.src="")},down:r=>{}},{id:$f.AddFileSize,up:r=>{r.props.fileSize=-1},down:r=>{delete r.props.fileSize}},{id:$f.MakeFileSizeOptional,up:r=>{r.props.fileSize===-1&&(r.props.fileSize=void 0)},down:r=>{r.props.fileSize===void 0&&(r.props.fileSize=-1)}}]}),wye=lT("video",nr({w:Dt,h:Dt,name:zt,isAnimated:tr,mimeType:zt.nullable(),src:Vl.nullable(),fileSize:Dt.optional()})),qf=mo("com.tldraw.asset.video",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5}),bye=qo({sequenceId:"com.tldraw.asset.video",recordType:"asset",filter:r=>r.type==="video",sequence:[{id:qf.AddIsAnimated,up:r=>{r.props.isAnimated=!1},down:r=>{delete r.props.isAnimated}},{id:qf.RenameWidthHeight,up:r=>{r.props.w=r.props.width,r.props.h=r.props.height,delete r.props.width,delete r.props.height},down:r=>{r.props.width=r.props.w,r.props.height=r.props.h,delete r.props.w,delete r.props.h}},{id:qf.MakeUrlsValid,up:r=>{Vl.isValid(r.props.src)||(r.props.src="")},down:r=>{}},{id:qf.AddFileSize,up:r=>{r.props.fileSize=-1},down:r=>{delete r.props.fileSize}},{id:qf.MakeFileSizeOptional,up:r=>{r.props.fileSize===-1&&(r.props.fileSize=void 0)},down:r=>{r.props.fileSize===void 0&&(r.props.fileSize=-1)}}]}),Eye=Ta("asset",sT("type",{image:xye,video:wye,bookmark:yye})),Iye=mo("com.tldraw.asset",{AddMeta:1}),Pye=qo({sequenceId:"com.tldraw.asset",recordType:"asset",sequence:[{id:Iye.AddMeta,up:r=>{r.meta={}}}]}),Qc=Ca("asset",{validator:Eye,scope:"document"}).withDefaultProperties(()=>({meta:{}})),ute={w:_n,h:_n,assetId:Um.nullable(),url:Do},Vj=Ls("bookmark",{NullAssetId:1,MakeUrlsValid:2}),dte={sequence:[{id:Vj.NullAssetId,up:r=>{r.assetId===void 0&&(r.assetId=null)},down:"retired"},{id:Vj.MakeUrlsValid,up:r=>{Do.isValid(r.url)||(r.url="")},down:r=>{}}]},fte=nr({type:Bm("free","straight"),points:Jn(Yl)}),hte={color:Lo,fill:Zl,dash:Xl,size:va,segments:Jn(fte),isComplete:tr,isClosed:tr,isPen:tr,scale:_n},Yj=Ls("draw",{AddInPen:1,AddScale:2}),pte={sequence:[{id:Yj.AddInPen,up:r=>{const{points:e}=r.segments[0];if(e.length===0){r.isPen=!1;return}let t=!(e[0].z===0||e[0].z===.5);e[1]&&(t=t&&!(e[1].z===0||e[1].z===.5)),r.isPen=t},down:"retired"},{id:Yj.AddScale,up:r=>{r.scale=1},down:r=>{delete r.scale}}]},Cye=/(^\/r\/[^/]+\/?$)/,Tye=[{hostnames:["beta.tldraw.com","tldraw.com","localhost:3000"],fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(Cye))return r}},{hostnames:["figma.com"],fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/^\/embed\/?$/)){const t=e.searchParams.get("url");if(t)return t}}},{hostnames:["google.*"],fromEmbedUrl:r=>{const e=Ft(r);if(!e)return;if(e.pathname.match(/^\/maps\/embed\/v1\/view\/?$/)&&e.searchParams.has("center")&&e.searchParams.get("zoom")){const n=e.searchParams.get("zoom"),[i,o]=e.searchParams.get("center").split(",");return`https://www.google.com/maps/@${i},${o},${n}z`}}},{hostnames:["val.town"],fromEmbedUrl:r=>{const e=Ft(r),t=e&&e.pathname.match(/\/embed\/(.+)\/?/);if(t)return`https://www.val.town/v/${t[1]}`}},{hostnames:["codesandbox.io"],fromEmbedUrl:r=>{const e=Ft(r),t=e&&e.pathname.match(/\/embed\/([^/]+)\/?/);if(t)return`https://codesandbox.io/s/${t[1]}`}},{hostnames:["codepen.io"],fromEmbedUrl:r=>{const e=/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/,t=r.match(e);if(t){const[n,i,o]=t;return`https://codepen.io/${i}/pen/${o}`}}},{hostnames:["scratch.mit.edu"],fromEmbedUrl:r=>{const e=/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/,t=r.match(e);if(t){const[n,i]=t;return`https://scratch.mit.edu/projects/${i}`}}},{hostnames:["*.youtube.com","youtube.com","youtu.be"],fromEmbedUrl:r=>{const e=Ft(r);if(!e)return;if(e.hostname.replace(/^www./,"")==="youtube.com"){const n=e.pathname.match(/^\/embed\/([^/]+)\/?/);if(n)return`https://www.youtube.com/watch?v=${n[1]}`}}},{hostnames:["calendar.google.*"],fromEmbedUrl:r=>{const e=Ft(r),t=e==null?void 0:e.searchParams.get("src");if(e!=null&&e.pathname.match(/\/calendar\/embed/)&&t){e.pathname="/calendar/u/0";const n=Array.from(e.searchParams.keys());for(const i of n)e.searchParams.delete(i);return e.searchParams.set("cid",t),e.href}}},{hostnames:["docs.google.*"],fromEmbedUrl:r=>{const e=Ft(r);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/embed\/?$/))){e.pathname=e.pathname.replace(/\/embed$/,"/pub");const t=Array.from(e.searchParams.keys());for(const n of t)e.searchParams.delete(n);return e.href}}},{hostnames:["gist.github.com"],fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/\/([^/]+)\/([^/]+)/))return r.split("/").pop()?r:void 0}},{hostnames:["replit.com"],fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/\/@([^/]+)\/([^/]+)/)&&e.searchParams.has("embed"))return e.searchParams.delete("embed"),e.href}},{hostnames:["felt.com"],fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/^\/embed\/map\//))return e.pathname=e.pathname.replace(/^\/embed/,""),e.href}},{hostnames:["open.spotify.com"],fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/^\/embed\/(artist|album)\//))return e.origin+e.pathname.replace(/^\/embed/,"")}},{hostnames:["vimeo.com","player.vimeo.com"],fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.hostname==="player.vimeo.com"){const t=e.pathname.match(/^\/video\/([^/]+)\/?$/);if(t)return"https://vimeo.com/"+t[1]}}},{hostnames:["excalidraw.com"],fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.hash.match(/#room=/))return r}},{hostnames:["observablehq.com"],fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/^\/embed\/@([^/]+)\/([^/]+)\/?$/))return`${e.origin}${e.pathname.replace("/embed","")}#cell-*`;if(e&&e.pathname.match(/^\/embed\/([^/]+)\/?$/))return`${e.origin}${e.pathname.replace("/embed","/d")}#cell-*`}},{hostnames:["desmos.com"],fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search==="?embed"&&e.hash==="")return r.replace("?embed","")}}],gte={w:_n,h:_n,url:zt},Eg=Ls("embed",{GenOriginalUrlInEmbed:1,RemoveDoesResize:2,RemoveTmpOldUrl:3,RemovePermissionOverrides:4}),vte={sequence:[{id:Eg.GenOriginalUrlInEmbed,up:r=>{try{const e=r.url,t=new URL(e).host.replace("www.","");let n;for(const i of Tye)if(i.hostnames.includes(t))try{n=i.fromEmbedUrl(e)}catch(o){console.warn(o)}r.tmpOldUrl=r.url,r.url=n??""}catch{r.url="",r.tmpOldUrl=r.url}},down:"retired"},{id:Eg.RemoveDoesResize,up:r=>{delete r.doesResize},down:"retired"},{id:Eg.RemoveTmpOldUrl,up:r=>{delete r.tmpOldUrl},down:"retired"},{id:Eg.RemovePermissionOverrides,up:r=>{delete r.overridePermissions},down:"retired"}]},mte={w:_n,h:_n,name:zt},yte={sequence:[]},Jv=oi.defineEnum("tldraw:horizontalAlign",{defaultValue:"middle",values:["start","middle","end","start-legacy","end-legacy","middle-legacy"]}),em=oi.defineEnum("tldraw:verticalAlign",{defaultValue:"middle",values:["start","middle","end"]}),Ts=oi.defineEnum("tldraw:geo",{defaultValue:"rectangle",values:["cloud","rectangle","ellipse","triangle","diamond","pentagon","hexagon","octagon","star","rhombus","rhombus-2","oval","trapezoid","arrow-right","arrow-left","arrow-up","arrow-down","x-box","check-box","heart"]}),Ste={geo:Ts,labelColor:uT,color:Lo,fill:Zl,dash:Xl,size:va,font:ga,align:Jv,verticalAlign:em,url:Do,w:_n,h:_n,growY:Gv,text:zt,scale:_n},Wa=Ls("geo",{AddUrlProp:1,AddLabelColor:2,RemoveJustify:3,AddCheckBox:4,AddVerticalAlign:5,MigrateLegacyAlign:6,AddCloud:7,MakeUrlsValid:8,AddScale:9}),xte={sequence:[{id:Wa.AddUrlProp,up:r=>{r.url=""},down:"retired"},{id:Wa.AddLabelColor,up:r=>{r.labelColor="black"},down:"retired"},{id:Wa.RemoveJustify,up:r=>{r.align==="justify"&&(r.align="start")},down:"retired"},{id:Wa.AddCheckBox,up:r=>{},down:"retired"},{id:Wa.AddVerticalAlign,up:r=>{r.verticalAlign="middle"},down:"retired"},{id:Wa.MigrateLegacyAlign,up:r=>{let e;switch(r.align){case"start":e="start-legacy";break;case"end":e="end-legacy";break;default:e="middle-legacy";break}r.align=e},down:"retired"},{id:Wa.AddCloud,up:r=>{},down:"retired"},{id:Wa.MakeUrlsValid,up:r=>{Do.isValid(r.url)||(r.url="")},down:r=>{}},{id:Wa.AddScale,up:r=>{r.scale=1},down:r=>{delete r.scale}}]},_te={},wte={sequence:[]},bte={color:Lo,size:va,segments:Jn(fte),isComplete:tr,isPen:tr,scale:_n},Aye=Ls("highlight",{AddScale:1}),Ete={sequence:[{id:Aye.AddScale,up:r=>{r.scale=1},down:r=>{delete r.scale}}]},Rye=nr({topLeft:Yl,bottomRight:Yl}),Ite={w:_n,h:_n,playing:tr,url:Do,assetId:Um.nullable(),crop:Rye.nullable(),flipX:tr,flipY:tr},Ig=Ls("image",{AddUrlProp:1,AddCropProp:2,MakeUrlsValid:3,AddFlipProps:4}),Pte={sequence:[{id:Ig.AddUrlProp,up:r=>{r.url=""},down:"retired"},{id:Ig.AddCropProp,up:r=>{r.crop=null},down:r=>{delete r.crop}},{id:Ig.MakeUrlsValid,up:r=>{Do.isValid(r.url)||(r.url="")},down:r=>{}},{id:Ig.AddFlipProps,up:r=>{r.flipX=!1,r.flipY=!1},down:r=>{delete r.flipX,delete r.flipY}}]},tm=oi.defineEnum("tldraw:spline",{defaultValue:"line",values:["cubic","line"]}),kye=nr({id:zt,index:cT,x:Dt,y:Dt}),Cte={color:Lo,dash:Xl,size:va,spline:tm,points:Vv(zt,kye),scale:_n},Bf=Ls("line",{AddSnapHandles:1,RemoveExtraHandleProps:2,HandlesToPoints:3,PointIndexIds:4,AddScale:5}),Tte={sequence:[{id:Bf.AddSnapHandles,up:r=>{for(const e of Object.values(r.handles))e.canSnap=!0},down:"retired"},{id:Bf.RemoveExtraHandleProps,up:r=>{r.handles=HJ(Object.values(r.handles).map(e=>[e.index,{x:e.x,y:e.y}]))},down:r=>{const e=Object.entries(r.handles).map(([t,n])=>({index:t,...n})).sort(_i);r.handles=Object.fromEntries(e.map((t,n)=>{const i=n===0?"start":n===e.length-1?"end":`handle:${t.index}`;return[i,{id:i,type:"vertex",canBind:!1,canSnap:!0,index:t.index,x:t.x,y:t.y}]}))}},{id:Bf.HandlesToPoints,up:r=>{const e=Object.entries(r.handles).map(([t,{x:n,y:i}])=>({x:n,y:i,index:t})).sort(_i);r.points=e.map(({x:t,y:n})=>({x:t,y:n})),delete r.handles},down:r=>{const e=yh(r.points.length);r.handles=Object.fromEntries(r.points.map((t,n)=>[e[n],{x:t.x,y:t.y}])),delete r.points}},{id:Bf.PointIndexIds,up:r=>{const e=yh(r.points.length);r.points=Object.fromEntries(r.points.map((t,n)=>{const i=e[n];return[i,{id:i,index:i,x:t.x,y:t.y}]}))},down:r=>{const e=Object.values(r.points).sort(_i);r.points=e.map(({x:t,y:n})=>({x:t,y:n}))}},{id:Bf.AddScale,up:r=>{r.scale=1},down:r=>{delete r.scale}}]},Ate={color:Lo,labelColor:uT,size:va,font:ga,fontSizeAdjustment:Gv,align:Jv,verticalAlign:em,growY:Gv,url:Do,text:zt,scale:_n},Fc=Ls("note",{AddUrlProp:1,RemoveJustify:2,MigrateLegacyAlign:3,AddVerticalAlign:4,MakeUrlsValid:5,AddFontSizeAdjustment:6,AddScale:7,AddLabelColor:8}),Rte={sequence:[{id:Fc.AddUrlProp,up:r=>{r.url=""},down:"retired"},{id:Fc.RemoveJustify,up:r=>{r.align==="justify"&&(r.align="start")},down:"retired"},{id:Fc.MigrateLegacyAlign,up:r=>{switch(r.align){case"start":r.align="start-legacy";return;case"end":r.align="end-legacy";return;default:r.align="middle-legacy";return}},down:"retired"},{id:Fc.AddVerticalAlign,up:r=>{r.verticalAlign="middle"},down:"retired"},{id:Fc.MakeUrlsValid,up:r=>{Do.isValid(r.url)||(r.url="")},down:r=>{}},{id:Fc.AddFontSizeAdjustment,up:r=>{r.fontSizeAdjustment=0},down:r=>{delete r.fontSizeAdjustment}},{id:Fc.AddScale,up:r=>{r.scale=1},down:r=>{delete r.scale}},{id:Fc.AddLabelColor,up:r=>{r.labelColor="black"},down:r=>{delete r.labelColor}}]},AP=oi.defineEnum("tldraw:textAlign",{defaultValue:"start",values:["start","middle","end"]}),kte={color:Lo,size:va,font:ga,textAlign:AP,w:_n,text:zt,scale:_n,autoSize:tr},Xj=Ls("text",{RemoveJustify:1,AddTextAlign:2}),Ote={sequence:[{id:Xj.RemoveJustify,up:r=>{r.align==="justify"&&(r.align="start")},down:"retired"},{id:Xj.AddTextAlign,up:r=>{r.textAlign=r.align,delete r.align},down:r=>{r.align=r.textAlign,delete r.textAlign}}]},Mte={w:_n,h:_n,time:Dt,playing:tr,url:Do,assetId:Um.nullable()},Zj=Ls("video",{AddUrlProp:1,MakeUrlsValid:2}),jte={sequence:[{id:Zj.AddUrlProp,up:r=>{r.url=""},down:"retired"},{id:Zj.MakeUrlsValid,up:r=>{Do.isValid(r.url)||(r.url="")},down:r=>{}}]},Pg=mo("com.tldraw.store",{RemoveCodeAndIconShapeTypes:1,AddInstancePresenceType:2,RemoveTLUserAndPresenceAndAddPointer:3,RemoveUserDocument:4}),Oye=pd({sequenceId:"com.tldraw.store",retroactive:!1,sequence:[{id:Pg.RemoveCodeAndIconShapeTypes,scope:"store",up:r=>{for(const[e,t]of Ro(r))t.typeName==="shape"&&(t.type==="icon"||t.type==="code")&&delete r[e]}},{id:Pg.AddInstancePresenceType,scope:"store",up(r){}},{id:Pg.RemoveTLUserAndPresenceAndAddPointer,scope:"store",up:r=>{for(const[e,t]of Ro(r))t.typeName.match(/^(user|user_presence)$/)&&delete r[e]}},{id:Pg.RemoveUserDocument,scope:"store",up:r=>{for(const[e,t]of Ro(r))t.typeName.match("user_document")&&delete r[e]}}]}),Mye={arrow:{migrations:ite,props:nte},bookmark:{migrations:dte,props:ute},draw:{migrations:pte,props:hte},embed:{migrations:vte,props:gte},frame:{migrations:yte,props:mte},geo:{migrations:xte,props:Ste},group:{migrations:wte,props:_te},highlight:{migrations:Ete,props:bte},image:{migrations:Pte,props:Ite},line:{migrations:Tte,props:Cte},note:{migrations:Rte,props:Ate},text:{migrations:Ote,props:kte},video:{migrations:jte,props:Mte}},jye={arrow:{migrations:ste,props:ote}};function Dye({shapes:r=Mye,bindings:e=jye,migrations:t}={}){const n=new Map;for(const a of Tn(r))for(const c of Qee(a.props??{}).keys()){if(n.has(c.id)&&n.get(c.id)!==c)throw new Error(`Multiple StyleProp instances with the same id: ${c.id}`);n.set(c.id,c)}const i=zme(r),o=qme(e),s=rye(n);return iT.create({asset:Qc,binding:o,camera:la,document:fT,instance:s,instance_page_state:Cs,page:Fo,instance_presence:dye,pointer:dT,shape:i},{migrations:[Oye,Pye,Kme,hye,nye,oye,eye,uye,cye,Ume,Sye,_ye,bye,...Hj("shape",r),...Hj("binding",e),...t??[]],onValidationFailure:gye,createIntegrityChecker:mye})}const xh=[{locale:"id",label:"Bahasa Indonesia"},{locale:"ms",label:"Bahasa Melayu"},{locale:"ca",label:"Català"},{locale:"cs",label:"Čeština"},{locale:"da",label:"Danish"},{locale:"de",label:"Deutsch"},{locale:"en",label:"English"},{locale:"es",label:"Español"},{locale:"tl",label:"Filipino"},{locale:"fr",label:"Français"},{locale:"gl",label:"Galego"},{locale:"hr",label:"Hrvatski"},{locale:"it",label:"Italiano"},{locale:"hu",label:"Magyar"},{locale:"nl",label:"Nederlands"},{locale:"no",label:"Norwegian"},{locale:"pl",label:"Polski"},{locale:"pt-br",label:"Português - Brasil"},{locale:"pt-pt",label:"Português - Europeu"},{locale:"ro",label:"Română"},{locale:"sl",label:"Slovenščina"},{locale:"so",label:"Somali"},{locale:"fi",label:"Suomi"},{locale:"sv",label:"Svenska"},{locale:"vi",label:"Tiếng Việt"},{locale:"tr",label:"Türkçe"},{locale:"el",label:"Ελληνικά"},{locale:"ru",label:"Русский"},{locale:"uk",label:"Українська"},{locale:"he",label:"עברית"},{locale:"ur",label:"اردو"},{locale:"ar",label:"عربي"},{locale:"fa",label:"فارسی"},{locale:"ne",label:"नेपाली"},{locale:"mr",label:"मराठी"},{locale:"hi-in",label:"हिन्दी"},{locale:"bn",label:"বাংলা"},{locale:"pa",label:"ਪੰਜਾਬੀ"},{locale:"gu-in",label:"ગુજરાતી"},{locale:"ta",label:"தமிழ்"},{locale:"te",label:"తెలుగు"},{locale:"kn",label:"ಕನ್ನಡ"},{locale:"ml",label:"മലയാളം"},{locale:"th",label:"ภาษาไทย"},{locale:"km-kh",label:"ភាសាខ្មែរ"},{locale:"ko-kr",label:"한국어"},{locale:"ja",label:"日本語"},{locale:"zh-cn",label:"简体中文"},{locale:"zh-tw",label:"繁體中文 (台灣)"}];function Lye(){const r=typeof window<"u"?window.navigator.languages??["en"]:["en"];return Fye(r)}function Fye(r){for(const e of r){const t=Nye(e);if(t)return t}return"en"}const Qj={zh:"zh-cn",pt:"pt-br",ko:"ko-kr",hi:"hi-in"};function Nye(r){const e=xh.find(i=>i.locale===r.toLowerCase());if(e)return e.locale;const[t,n]=r.split(/[-_]/).map(i=>i.toLowerCase());if(n){const i=xh.find(o=>o.locale===t);if(i)return i.locale}return t in Qj?Qj[t]:null}il("@tldraw/tlschema","3.9.0","esm");var eb={exports:{}};/*!
85
- Copyright (c) 2018 Jed Watson.
86
- Licensed under the MIT License (MIT), see
87
- http://jedwatson.github.io/classnames
88
- */var Jj;function $ye(){return Jj||(Jj=1,function(r){(function(){var e={}.hasOwnProperty;function t(){for(var o="",s=0;s<arguments.length;s++){var a=arguments[s];a&&(o=i(o,n(a)))}return o}function n(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return t.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var s="";for(var a in o)e.call(o,a)&&o[a]&&(s=i(s,a));return s}function i(o,s){return s?o?o+" "+s:o+s:o}r.exports?(t.default=t,r.exports=t):window.classNames=t})()}(eb)),eb.exports}var qye=$ye();const bt=cc(qye),Dte="3.9.0",eD={major:"2024-09-13T14:36:29.063Z",minor:"2025-03-03T11:42:22.746Z"},Bye={error:null};class hT extends A.Component{constructor(){super(...arguments);q(this,"state",Bye)}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){var n,i;(i=(n=this.props).onError)==null||i.call(n,t)}render(){const{error:t}=this.state;if(t!==null){const{fallback:n}=this.props;return v.jsx(n,{error:t})}return this.props.children}}function _h({children:r,fallback:e,...t}){return e===null?r:v.jsx(hT,{fallback:e,...t,children:r})}function pT(r,e){return zm(`${r}_${e}`)}function Ld(r){return zm(`${A.useId()}${r??""}`)}function As(r){const e=lo(A.useContext(Lte));return zm(`${e}_${r}`)}function zm(r){return r.replace(/:/g,"_")}const Lte=A.createContext(null);function Uye({children:r}){const e=Ld();return v.jsx(Lte.Provider,{value:e,children:r})}const gT=A.createContext(null);function he(){const r=lr.useContext(gT);if(!r)throw new Error("useEditor must be used inside of the <Tldraw /> or <TldrawEditor /> components");return r}function ll(){return lr.useContext(gT)}function vT({editor:r,children:e}){return v.jsx(gT.Provider,{value:r,children:v.jsx(Uye,{children:e})})}function zye(){return v.jsx("div",{className:"tl-background"})}function Fd(r,e,t,n,i,o){A.useLayoutEffect(()=>{const s=r.current;if(!s||e===void 0)return;let a=`translate(${e}px, ${t}px)`;n!==void 0&&(a+=` scale(${n})`),i!==void 0&&(a+=` rotate(${i}rad)`),o&&(a+=` translate(${o.x}px, ${o.y}px)`),s.style.transform=a})}const tb=({brush:r,color:e,opacity:t,className:n})=>{const i=A.useRef(null);Fd(i,r.x,r.y);const o=fe(Math.max(1,r.w)),s=fe(Math.max(1,r.h));return v.jsx("svg",{className:"tl-overlays__item",ref:i,children:e?v.jsxs("g",{className:"tl-brush",opacity:t,children:[v.jsx("rect",{width:o,height:s,fill:e,opacity:.75}),v.jsx("rect",{width:o,height:s,fill:"none",stroke:e,opacity:.1})]}):v.jsx("rect",{className:`tl-brush tl-brush__default ${n}`,width:o,height:s})})},Pr={isSafari:!1,isIos:!1,isChromeForIos:!1,isFirefox:!1,isAndroid:!1,isWebview:!1,isDarwin:!1,hasCanvasSupport:!1};typeof window<"u"&&"navigator"in window&&(Pr.isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),Pr.isIos=!!navigator.userAgent.match(/iPad/i)||!!navigator.userAgent.match(/iPhone/i),Pr.isChromeForIos=/crios.*safari/i.test(navigator.userAgent),Pr.isFirefox=/firefox/i.test(navigator.userAgent),Pr.isAndroid=/android/i.test(navigator.userAgent),Pr.isDarwin=window.navigator.userAgent.toLowerCase().indexOf("mac")>-1,Pr.hasCanvasSupport=typeof window<"u"&&"Promise"in window&&"HTMLCanvasElement"in window);const tD={isLocked:!1,wheelBehavior:"pan",panSpeed:1,zoomSpeed:1,zoomSteps:[.1,.25,.5,1,2,4,8]},rb={duration:0,easing:zn.easeInOutCubic},rD={CAMERA_MOVE:-10},Hye=["top","right","bottom","left"],nD=0,mT=2,Cg=1,iD=5,Wye=128;var nb={};const Kye={},Fte=io("pointerCaptureTrackingObject",{defaults:{all:new Map},shouldStoreForSession:!1}),yn={logPreventDefaults:io("logPreventDefaults",{defaults:{all:!1}}),logPointerCaptures:io("logPointerCaptures",{defaults:{all:!1}}),logElementRemoves:io("logElementRemoves",{defaults:{all:!1}}),debugSvg:io("debugSvg",{defaults:{all:!1}}),showFps:io("showFps",{defaults:{all:!1}}),measurePerformance:io("measurePerformance",{defaults:{all:!1}}),throwToBlob:io("throwToBlob",{defaults:{all:!1}}),reconnectOnPing:io("reconnectOnPing",{defaults:{all:!1}}),debugCursors:io("debugCursors",{defaults:{all:!1}}),forceSrgb:io("forceSrgbColors",{defaults:{all:!1}}),debugGeometry:io("debugGeometry",{defaults:{all:!1}}),hideShapes:io("hideShapes",{defaults:{all:!1}}),editOnType:io("editOnType",{defaults:{all:!1}})};if(typeof Element<"u"){const r=Element.prototype.removeChild;fa("element removal logging",()=>{yn.logElementRemoves.get()?Element.prototype.removeChild=function(e){return console.warn("[tldraw] removing child:",e),r.call(this,e)}:Element.prototype.removeChild=r})}function io(r,{defaults:e,shouldStoreForSession:t=!0}){return Gye({name:r,defaults:e,shouldStoreForSession:t})}function Gye(r){const e=Yye(r),t=r.shouldStoreForSession?Vye(r.name):null,n=xn(`debug:${r.name}`,t??e);return typeof window<"u"&&(r.shouldStoreForSession&&fa(`debug:${r.name}`,()=>{const i=n.get();i===e?oee(`tldraw_debug:${r.name}`):$C(`tldraw_debug:${r.name}`,JSON.stringify(i))}),Object.defineProperty(window,`tldraw${r.name.replace(/^[a-z]/,i=>i.toUpperCase())}`,{get(){return n.get()},set(i){n.set(i)},configurable:!0})),Object.assign(n,r)}function Vye(r){try{return JSON.parse(iee(`tldraw_debug:${r}`)??"null")}catch{return null}}function ib(r){try{return r()}catch{return null}}function Yye(r){switch(ib(()=>nb.TLDRAW_ENV)??ib(()=>nb.VERCEL_PUBLIC_TLDRAW_ENV)??ib(()=>nb.NEXT_PUBLIC_TLDRAW_ENV)??"production"){case"production":return r.defaults.production??r.defaults.all;case"preview":case"staging":return r.defaults.staging??r.defaults.all;default:return r.defaults.development??r.defaults.all}}function rm(r){if(r instanceof HTMLElement)return r;if(r.parentElement)return rm(r.parentElement);throw Error("Could not find a parent element of an HTML type!")}function Qt(r){r.preventDefault(),yn.logPreventDefaults.get()&&console.warn("preventDefault called on event:",r)}function Hh(r,e){if(r.setPointerCapture(e.pointerId),yn.logPointerCaptures.get()){const t=Fte.get();t.set(r,(t.get(r)??0)+1),console.warn("setPointerCapture called on element:",r,e)}}function Wh(r,e){if(r.hasPointerCapture(e.pointerId)&&(r.releasePointerCapture(e.pointerId),yn.logPointerCaptures.get())){const t=Fte.get();t.get(r)===1?t.delete(r):t.has(r)?t.set(r,t.get(r)-1):console.warn("Release without capture"),console.warn("releasePointerCapture called on element:",r,e)}}const wn=r=>r.stopPropagation(),vi=(r,e,t)=>{r&&r.style.setProperty(e,t)},Xye=["input","select","button","textarea"];function Nte(){const{activeElement:r}=document;return!!(r&&(r.getAttribute("contenteditable")||Xye.indexOf(r.tagName.toLowerCase())>-1))}const wi=r=>Pr.isDarwin?r.metaKey:r.ctrlKey||r.metaKey;function Ao(r){return r.isKilled=!0,{point:{x:r.clientX,y:r.clientY,z:r.pressure},shiftKey:r.shiftKey,altKey:r.altKey,ctrlKey:r.metaKey||r.ctrlKey,metaKey:r.metaKey,accelKey:wi(r),pointerId:r.pointerId,button:r.button,isPen:r.pointerType==="pen"}}function yT(){const r=he();return A.useMemo(function(){let n,i;function o(y){if(!y.isKilled){if(y.button===mT){r.dispatch({type:"pointer",target:"canvas",name:"right_click",...Ao(y)});return}y.button!==0&&y.button!==1&&y.button!==5||(Hh(y.currentTarget,y),r.dispatch({type:"pointer",target:"canvas",name:"pointer_down",...Ao(y)}))}}function s(y){y.isKilled||y.clientX===n&&y.clientY===i||(n=y.clientX,i=y.clientY,r.dispatch({type:"pointer",target:"canvas",name:"pointer_move",...Ao(y)}))}function a(y){y.isKilled||y.button!==0&&y.button!==1&&y.button!==2&&y.button!==5||(n=y.clientX,i=y.clientY,Wh(y.currentTarget,y),r.dispatch({type:"pointer",target:"canvas",name:"pointer_up",...Ao(y)}))}function c(y){if(y.isKilled||r.getInstanceState().isPenMode&&y.pointerType!=="pen")return;const x=y.pointerType==="mouse"||y.pointerType==="pen";r.updateInstanceState({isHoveringCanvas:x?!0:null})}function l(y){if(y.isKilled||r.getInstanceState().isPenMode&&y.pointerType!=="pen")return;const x=y.pointerType==="mouse"||y.pointerType==="pen";r.updateInstanceState({isHoveringCanvas:x?!1:null})}function d(y){y.isKilled=!0,Qt(y)}function f(y){y.isKilled=!0,y.target instanceof HTMLElement&&y.target.tagName!=="A"&&y.target.tagName!=="TEXTAREA"&&!(r.getEditingShape()&&y.target.className.includes("tl-text-content"))&&Qt(y)}function h(y){Qt(y)}async function g(y){var _,w;if(Qt(y),wn(y),(w=(_=y.dataTransfer)==null?void 0:_.files)!=null&&w.length){const I=Array.from(y.dataTransfer.files);await r.putExternalContent({type:"files",files:I,point:r.screenToPage({x:y.clientX,y:y.clientY}),ignoreParent:!1});return}const x=y.dataTransfer.getData("url");if(x){await r.putExternalContent({type:"url",url:x,point:r.screenToPage({x:y.clientX,y:y.clientY})});return}}function m(y){wn(y)}return{onPointerDown:o,onPointerMove:s,onPointerUp:a,onPointerEnter:c,onPointerLeave:l,onDragOver:h,onDrop:g,onTouchStart:d,onTouchEnd:f,onClick:m}},[r])}function Zye(){const r=he();A.useEffect(()=>{let e=r.getInstanceState().isCoarsePointer;const t=s=>{const a=s.pointerType!=="mouse";e!==a&&(e=a,r.updateInstanceState({isCoarsePointer:a}))};window.addEventListener("pointerdown",t,{capture:!0});const n=window.matchMedia&&window.matchMedia("(any-pointer: coarse)"),i=Pr.isFirefox&&!Pr.isAndroid&&!Pr.isIos,o=()=>{const s=i?!1:n.matches;e===s&&(e=s,r.updateInstanceState({isCoarsePointer:s}))};return n&&(n.addEventListener("change",o),o()),()=>{window.removeEventListener("pointerdown",t,{capture:!0}),n&&n.removeEventListener("change",o)}},[r])}const $te=A.createContext(null);function qte({container:r,children:e}){return v.jsx($te.Provider,{value:r,children:e})}function Ln(){return lo(A.useContext($te),"useContainer used outside of <Tldraw />")}function Qye(){const r=he(),e=Ln(),t=ye("isFocused",()=>r.getIsFocused(),[r]);A.useEffect(()=>{if(!e)return;function n(i){if(i.isSpecialRedispatchedEvent)return;Qt(i),wn(i);const o=e.querySelector(".tl-canvas");if(!o)return;const s=new DragEvent(i.type,i);s.isSpecialRedispatchedEvent=!0,o.dispatchEvent(s)}return e.addEventListener("dragover",n),e.addEventListener("drop",n),()=>{e.removeEventListener("dragover",n),e.removeEventListener("drop",n)}},[e]),A.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;let n=null;const i=()=>{n!=null&&n();const o=`(resolution: ${window.devicePixelRatio}dppx)`,s=matchMedia(o),a=c=>{c.type==="change"&&i()};s.addEventListener?s.addEventListener("change",i):s.addListener&&s.addListener(a),n=()=>{s.removeEventListener?s.removeEventListener("change",i):s.removeListener&&s.removeListener(a)},r.updateInstanceState({devicePixelRatio:window.devicePixelRatio})};return i(),()=>{n==null||n()}},[r]),A.useEffect(()=>{if(!t)return;const n=a=>{if(a.altKey&&(r.isIn("zoom")||!r.getPath().endsWith(".idle"))&&!Tg(r)&&Qt(a),a.isKilled)return;switch(a.isKilled=!0,a.key){case"=":case"-":case"0":{if(a.metaKey||a.ctrlKey){Qt(a);return}break}case"Tab":{if(Tg(r))return;break}case",":return;case"Escape":{if((r.getEditingShape()||r.getSelectedShapeIds().length>0)&&Qt(a),r.menus.getOpenMenus().length>0)return;r.inputs.keys.has("Escape")||(r.inputs.keys.add("Escape"),r.cancel(),e.focus());return}default:if(Tg(r))return}const c={type:"keyboard",name:a.repeat?"key_repeat":"key_down",key:a.key,code:a.code,shiftKey:a.shiftKey,altKey:a.altKey,ctrlKey:a.metaKey||a.ctrlKey,metaKey:a.metaKey,accelKey:wi(a)};r.dispatch(c)},i=a=>{if(a.isKilled||(a.isKilled=!0,Tg(r))||a.key===",")return;const c={type:"keyboard",name:"key_up",key:a.key,code:a.code,shiftKey:a.shiftKey,altKey:a.altKey,ctrlKey:a.metaKey||a.ctrlKey,metaKey:a.metaKey,accelKey:wi(a)};r.dispatch(c)};function o(a){var c,l;if(e.contains(a.target)){const d=a.touches[0].pageX,f=a.touches[0].radiusX||0;(d-f<10||d+f>r.getViewportScreenBounds().width-10)&&(((c=a.target)==null?void 0:c.tagName)==="BUTTON"&&((l=a.target)==null||l.click()),Qt(a))}}const s=a=>{e.contains(a.target)&&(a.ctrlKey||a.metaKey)&&Qt(a)};return e.addEventListener("touchstart",o,{passive:!1}),e.addEventListener("wheel",s,{passive:!1}),document.addEventListener("gesturestart",Qt),document.addEventListener("gesturechange",Qt),document.addEventListener("gestureend",Qt),e.addEventListener("keydown",n),e.addEventListener("keyup",i),()=>{e.removeEventListener("touchstart",o),e.removeEventListener("wheel",s),document.removeEventListener("gesturestart",Qt),document.removeEventListener("gesturechange",Qt),document.removeEventListener("gestureend",Qt),e.removeEventListener("keydown",n),e.removeEventListener("keyup",i)}},[r,e,t])}function Tg(r){return r.menus.hasOpenMenus()||Nte()}const Jye=["textarea","input"];function eSe(r){const e=he();A.useEffect(()=>{const t=r.current;if(!t)return;const n=i=>{var o;if(i instanceof PointerEvent&&i.pointerType==="pen"){i.isKilled=!0;const{target:s}=i;if(Jye.includes((o=s.tagName)==null?void 0:o.toLocaleLowerCase())||e.isIn("select.editing_shape"))return;Qt(i)}};return t.addEventListener("touchstart",n),t.addEventListener("touchend",n),()=>{t.removeEventListener("touchstart",n),t.removeEventListener("touchend",n)}},[e,r])}function tSe(r,e,t){return Math.max(e,Math.min(r,t))}const ti={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function oD(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function sD(r,e,t,n=.15){return n===0?tSe(r,e,t):r<e?-oD(e-r,t-e,n)+e:r>t?+oD(r-t,t-e,n)+t:r}function rSe(r,[e,t],[n,i]){const[[o,s],[a,c]]=r;return[sD(e,o,s,n),sD(t,a,c,i)]}function nSe(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function iSe(r){var e=nSe(r,"string");return typeof e=="symbol"?e:String(e)}function Si(r,e,t){return e=iSe(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function aD(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function nn(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?aD(Object(t),!0).forEach(function(n){Si(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):aD(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Bte={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function cD(r){return r?r[0].toUpperCase()+r.slice(1):""}const oSe=["enter","leave"];function sSe(r=!1,e){return r&&!oSe.includes(e)}function aSe(r,e="",t=!1){const n=Bte[r],i=n&&n[e]||e;return"on"+cD(r)+cD(i)+(sSe(t,i)?"Capture":"")}const cSe=["gotpointercapture","lostpointercapture"];function lSe(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=cSe.includes(e)?"capturecapture":"capture",i=!!~e.indexOf(n);return i&&(e=e.replace("capture","")),{device:e,capture:i,passive:t}}function uSe(r,e=""){const t=Bte[r],n=t&&t[e]||e;return r+n}function Ute(r){return"touches"in r}function dSe(r){return Ute(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function fSe(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function RP(r,e){try{const t=e.clientX-r.clientX,n=e.clientY-r.clientY,i=(e.clientX+r.clientX)/2,o=(e.clientY+r.clientY)/2,s=Math.hypot(t,n);return{angle:-(Math.atan2(t,n)*180)/Math.PI,distance:s,origin:[i,o]}}catch{}return null}function hSe(r){return fSe(r).map(e=>e.identifier)}function lD(r,e){const[t,n]=Array.from(r.touches).filter(i=>e.includes(i.identifier));return RP(t,n)}const uD=40,dD=800;function zte(r){let{deltaX:e,deltaY:t,deltaMode:n}=r;return n===1?(e*=uD,t*=uD):n===2&&(e*=dD,t*=dD),[e,t]}function pSe(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:i,ctrlKey:o}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:i,ctrlKey:o})}return e}function nm(r,...e){return typeof r=="function"?r(...e):r}function gSe(){}function vSe(...r){return r.length===0?gSe:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function fD(r,e){return Object.assign({},e,r||{})}const mSe=32;class Hte{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:i}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=i,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?nm(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:i}=this;t.args=this.args;let o=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,pSe(e)),i.down=i.pressed=i.buttons%2===1||i.touches>0,o=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const C=t._delta.map(Math.abs);ti.addTo(t._distance,C)}this.axisIntent&&this.axisIntent(e);const[s,a]=t._movement,[c,l]=n.threshold,{_step:d,values:f}=t;if(n.hasCustomTransform?(d[0]===!1&&(d[0]=Math.abs(s)>=c&&f[0]),d[1]===!1&&(d[1]=Math.abs(a)>=l&&f[1])):(d[0]===!1&&(d[0]=Math.abs(s)>=c&&Math.sign(s)*c),d[1]===!1&&(d[1]=Math.abs(a)>=l&&Math.sign(a)*l)),t.intentional=d[0]!==!1||d[1]!==!1,!t.intentional)return;const h=[0,0];if(n.hasCustomTransform){const[C,k]=f;h[0]=d[0]!==!1?C-d[0]:0,h[1]=d[1]!==!1?k-d[1]:0}else h[0]=d[0]!==!1?s-d[0]:0,h[1]=d[1]!==!1?a-d[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(h);const g=t.offset,m=t._active&&!t._blocked||t.active;m&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=i[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=nm(n.bounds,t)),this.setup&&this.setup()),t.movement=h,this.computeOffset()));const[y,x]=t.offset,[[_,w],[I,b]]=t._bounds;t.overflow=[y<_?-1:y>w?1:0,x<I?-1:x>b?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const P=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=rSe(t._bounds,t.offset,P),t.delta=ti.sub(t.offset,g),this.computeMovement(),m&&(!t.last||o>mSe)){t.delta=ti.sub(t.offset,g);const C=t.delta.map(Math.abs);ti.addTo(t.distance,C),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&o>0&&(t.velocity=[C[0]/o,C[1]/o],t.timeDelta=o)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const i=this.handler(nn(nn(nn({},t),e),{},{[this.aliasKey]:e.values}));i!==void 0&&(e.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function ySe([r,e],t){const n=Math.abs(r),i=Math.abs(e);if(n>i&&n>t)return"x";if(i>n&&i>t)return"y"}class SSe extends Hte{constructor(...e){super(...e),Si(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=ti.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=ti.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const i=typeof n.axisThreshold=="object"?n.axisThreshold[dSe(e)]:n.axisThreshold;t.axis=ySe(t._movement,i)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const xSe=r=>r,hD=.15,Wte={enabled(r=!0){return r},eventOptions(r,e,t){return nn(nn({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[hD,hD];case!1:return[0,0];default:return ti.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return ti.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;return this.hasCustomTransform=!!n,n||xSe},threshold(r){return ti.toVector(r,0)}},_Se=0,Kh=nn(nn({},Wte),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=_Se){return r},bounds(r={}){if(typeof r=="function")return o=>Kh.bounds(r(o));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:i=1/0}=r;return[[e,t],[n,i]]}}),Gh=typeof window<"u"&&window.document&&window.document.createElement;function Kte(){return Gh&&"ontouchstart"in window}function wSe(){return Kte()||Gh&&window.navigator.maxTouchPoints>1}function bSe(){return Gh&&"onpointerdown"in window}function ESe(){return Gh&&"exitPointerLock"in window.document}function ISe(){try{return"constructor"in GestureEvent}catch{return!1}}const rs={isBrowser:Gh,gesture:ISe(),touch:Kte(),touchscreen:wSe(),pointer:bSe(),pointerLock:ESe()},PSe=250,CSe=180,TSe=.5,ASe=50,RSe=250,kSe=10,pD={mouse:0,touch:0,pen:8};nn(nn({},Kh),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:i=!1}={}}){return this.pointerLock=n&&rs.pointerLock,rs.touch&&t?"touch":this.pointerLock?"mouse":rs.pointer&&!i?"pointer":rs.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?PSe:void 0,!(!rs.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:i=!0}={}}){return this.pointerButtons=n,this.keys=i,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:i=void 0}){const o=ti.toVector(r,t?n:i?1:0);return this.filterTaps=t,this.tapsThreshold=n,o},swipe({velocity:r=TSe,distance:e=ASe,duration:t=RSe}={}){return{velocity:this.transform(ti.toVector(r)),distance:this.transform(ti.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return CSe;case!1:return 0;default:return r}},axisThreshold(r){return r?nn(nn({},pD),r):pD},keyboardDisplacement(r=kSe){return r}});function Gte(r){const[e,t]=r.overflow,[n,i]=r._delta,[o,s]=r._direction;(e<0&&n>0&&o<0||e>0&&n<0&&o>0)&&(r._movement[0]=r._movementBound[0]),(t<0&&i>0&&s<0||t>0&&i<0&&s>0)&&(r._movement[1]=r._movementBound[1])}const OSe=30,MSe=100;class jSe extends Hte{constructor(...e){super(...e),Si(this,"ingKey","pinching"),Si(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:t,lastOffset:n}=this.state;e==="wheel"?this.state.offset=ti.add(t,n):this.state.offset=[(1+t[0])*n[0],t[1]+n[1]]}computeMovement(){const{offset:e,lastOffset:t}=this.state;this.state.movement=[e[0]/t[0],e[1]-t[1]]}axisIntent(){const e=this.state,[t,n]=e._movement;if(!e.axis){const i=Math.abs(t)*OSe-Math.abs(n);i<0?e.axis="angle":i>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const t=this.state,n=this.ctrl.touchIds;if(t._active&&t._touchIds.every(o=>n.has(o))||n.size<2)return;this.start(e),t._touchIds=Array.from(n).slice(0,2);const i=lD(e,t._touchIds);i&&this.pinchStart(e,i)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const t=this.state,n=t._pointerEvents,i=this.ctrl.pointerIds;if(t._active&&Array.from(n.keys()).every(s=>i.has(s))||(n.size<2&&n.set(e.pointerId,e),t._pointerEvents.size<2))return;this.start(e);const o=RP(...Array.from(n.values()));o&&this.pinchStart(e,o)}pinchStart(e,t){const n=this.state;n.origin=t.origin,this.computeValues([t.distance,t.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const t=lD(e,this.state._touchIds);t&&this.pinchMove(e,t)}pointerMove(e){const t=this.state._pointerEvents;if(t.has(e.pointerId)&&t.set(e.pointerId,e),!this.state._active)return;const n=RP(...Array.from(t.values()));n&&this.pinchMove(e,n)}pinchMove(e,t){const n=this.state,i=n._values[1],o=t.angle-i;let s=0;Math.abs(o)>270&&(s+=Math.sign(o)),this.computeValues([t.distance,t.angle-360*s]),n.origin=t.origin,n.turns=s,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(t=>!this.ctrl.touchIds.has(t))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const t=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}t._pointerEvents.has(e.pointerId)&&t._pointerEvents.delete(e.pointerId),t._active&&t._pointerEvents.size<2&&(t._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const t=this.state;t._active||(this.start(e),this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const t=this.state;this.computeValues([e.scale,e.rotation]),t.origin=[e.clientX,e.clientY];const n=t._movement;t._movement=[e.scale-1,e.rotation],t._delta=ti.sub(t._movement,n),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const t=this.config.modifierKey;t&&(Array.isArray(t)?!t.find(n=>e[n]):!e[t])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||e.cancelable&&e.preventDefault();const n=this.state;n._delta=[-zte(e)[1]/MSe*n.offset[0],0],ti.addTo(n._movement,n._delta),Gte(n),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const t=this.config.device;t&&(e(t,"start",this[t+"Start"].bind(this)),e(t,"change",this[t+"Move"].bind(this)),e(t,"end",this[t+"End"].bind(this)),e(t,"cancel",this[t+"End"].bind(this)),e("lostPointerCapture","",this[t+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const DSe=nn(nn({},Wte),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!rs.touch&&rs.gesture)return"gesture";if(rs.touch&&n)return"touch";if(rs.touchscreen){if(rs.pointer)return"pointer";if(rs.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const i=s=>{const a=fD(nm(t,s),{min:-1/0,max:1/0});return[a.min,a.max]},o=s=>{const a=fD(nm(n,s),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[i(),o()]:s=>[i(s),o(s)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",ti.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}});nn(nn({},Kh),{},{mouseOnly:(r=!0)=>r});class LSe extends SSe{constructor(...e){super(...e),Si(this,"ingKey","wheeling")}wheel(e){this.state._active||this.start(e),this.wheelChange(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(e){const t=this.state;t._delta=zte(e),ti.addTo(t._movement,t._delta),Gte(t),this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){e("wheel","",this.wheel.bind(this))}}const FSe=Kh;nn(nn({},Kh),{},{mouseOnly:(r=!0)=>r});const ST=new Map,kP=new Map;function NSe(r){ST.set(r.key,r.engine),kP.set(r.key,r.resolver)}const $Se={key:"pinch",engine:jSe,resolver:DSe},qSe={key:"wheel",engine:LSe,resolver:FSe};function BSe(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,o;for(o=0;o<n.length;o++)i=n[o],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}function USe(r,e){if(r==null)return{};var t=BSe(r,e),n,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(i=0;i<o.length;i++)n=o[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const zSe={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=rs.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},HSe=["target","eventOptions","window","enabled","transform"];function av(r={},e){const t={};for(const[n,i]of Object.entries(e))switch(typeof i){case"function":t[n]=i.call(t,r[n],n,r);break;case"object":t[n]=av(r[n],i);break;case"boolean":i&&(t[n]=r[n]);break}return t}function WSe(r,e,t={}){const n=r,{target:i,eventOptions:o,window:s,enabled:a,transform:c}=n,l=USe(n,HSe);if(t.shared=av({target:i,eventOptions:o,window:s,enabled:a,transform:c},zSe),e){const d=kP.get(e);t[e]=av(nn({shared:t.shared},l),d)}else for(const d in l){const f=kP.get(d);f&&(t[d]=av(nn({shared:t.shared},l[d]),f))}return t}class Vte{constructor(e,t){Si(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,i,o){const s=this._listeners,a=uSe(t,n),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},l=nn(nn({},c),o);e.addEventListener(a,i,l);const d=()=>{e.removeEventListener(a,i,l),s.delete(d)};return s.add(d),d}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class KSe{constructor(){Si(this,"_timeouts",new Map)}add(e,t,n=140,...i){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...i))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class GSe{constructor(e){Si(this,"gestures",new Set),Si(this,"_targetEventStore",new Vte(this)),Si(this,"gestureEventStores",{}),Si(this,"gestureTimeoutStores",{}),Si(this,"handlers",{}),Si(this,"config",{}),Si(this,"pointerIds",new Set),Si(this,"touchIds",new Set),Si(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),VSe(this,e)}setEventIds(e){if(Ute(e))return this.touchIds=new Set(hSe(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=WSe(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let i;if(!(t.target&&(i=t.target(),!i))){if(t.enabled){for(const s of this.gestures){const a=this.config[s],c=gD(n,a.eventOptions,!!i);if(a.enabled){const l=ST.get(s);new l(this,e,s).bind(c)}}const o=gD(n,t.eventOptions,!!i);for(const s in this.nativeHandlers)o(s,"",a=>this.nativeHandlers[s](nn(nn({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const o in n)n[o]=vSe(...n[o]);if(!i)return n;for(const o in n){const{device:s,capture:a,passive:c}=lSe(o);this._targetEventStore.add(i,s,"",n[o],{capture:a,passive:c})}}}}function Zu(r,e){r.gestures.add(e),r.gestureEventStores[e]=new Vte(r,e),r.gestureTimeoutStores[e]=new KSe}function VSe(r,e){e.drag&&Zu(r,"drag"),e.wheel&&Zu(r,"wheel"),e.scroll&&Zu(r,"scroll"),e.move&&Zu(r,"move"),e.pinch&&Zu(r,"pinch"),e.hover&&Zu(r,"hover")}const gD=(r,e,t)=>(n,i,o,s={},a=!1)=>{var c,l;const d=(c=s.capture)!==null&&c!==void 0?c:e.capture,f=(l=s.passive)!==null&&l!==void 0?l:e.passive;let h=a?n:aSe(n,i,d);t&&f&&(h+="Passive"),r[h]=r[h]||[],r[h].push(o)},YSe=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function XSe(r){const e={},t={},n=new Set;for(let i in r)YSe.test(i)?(n.add(RegExp.lastMatch),t[i]=r[i]):e[i]=r[i];return[t,e,n]}function Qu(r,e,t,n,i,o){if(!r.has(t)||!ST.has(n))return;const s=t+"Start",a=t+"End",c=l=>{let d;return l.first&&s in e&&e[s](l),t in e&&(d=e[t](l)),l.last&&a in e&&e[a](l),d};i[n]=c,o[n]=o[n]||{}}function ZSe(r,e){const[t,n,i]=XSe(r),o={};return Qu(i,t,"onDrag","drag",o,e),Qu(i,t,"onWheel","wheel",o,e),Qu(i,t,"onScroll","scroll",o,e),Qu(i,t,"onPinch","pinch",o,e),Qu(i,t,"onMove","move",o,e),Qu(i,t,"onHover","hover",o,e),{handlers:o,config:e,nativeHandlers:n}}function QSe(r,e={},t,n){const i=lr.useMemo(()=>new GSe(r),[]);if(i.applyHandlers(r,n),i.applyConfig(e,t),lr.useEffect(i.effect.bind(i)),lr.useEffect(()=>i.clean.bind(i),[]),e.target===void 0)return i.bind.bind(i)}function JSe(r){return r.forEach(NSe),function(t,n){const{handlers:i,nativeHandlers:o,config:s}=ZSe(t,n||{});return QSe(i,s,void 0,o)}}const vD=10,exe=/Mac|iPod|iPhone|iPad/.test(typeof window>"u"?"node":window.navigator.platform);function Yte(r){let{deltaY:e,deltaX:t}=r,n=0;return r.ctrlKey||r.altKey||r.metaKey?n=(Math.abs(e)>vD?vD*Math.sign(e):e)/100:r.shiftKey&&!exe&&(t=e,e=0),{x:-t,y:-e,z:-n}}const txe=JSe([qSe,$Se]);let Ju;const rxe=r=>Ju===void 0?(Ju=r,!1):r-Ju>120&&r-Ju<160?(Ju=r,!0):(Ju=r,!1);function nxe(r){const e=he(),t=A.useMemo(()=>{let n="not sure";const i=({event:y})=>{if(!e.getInstanceState().isFocused||(n="not sure",rxe(Date.now())))return;const x=e.getEditingShapeId();if(x){const I=e.getShape(x);if(I&&e.getShapeUtil(I).canScroll(I)){const P=e.getShapePageBounds(x);if(P!=null&&P.containsPoint(e.inputs.currentPagePoint))return}}Qt(y),wn(y);const _=Yte(y);if(_.x===0&&_.y===0)return;const w={type:"wheel",name:"wheel",delta:_,point:new T(y.clientX,y.clientY),shiftKey:y.shiftKey,altKey:y.altKey,ctrlKey:y.metaKey||y.ctrlKey,metaKey:y.metaKey,accelKey:wi(y)};e.dispatch(w)};let o=1,s=1,a=1,c=0;const l=new T,d=new T,f=y=>{const x=r.current;n="not sure";const{event:_,origin:w,da:I}=y;_ instanceof WheelEvent||(_.target===x||x!=null&&x.contains(_.target))&&(d.x=w[0],d.y=w[1],l.x=w[0],l.y=w[1],o=I[0],s=e.getZoomLevel(),e.dispatch({type:"pinch",name:"pinch_start",point:{x:w[0],y:w[1],z:e.getZoomLevel()},delta:{x:0,y:0},shiftKey:_.shiftKey,altKey:_.altKey,ctrlKey:_.metaKey||_.ctrlKey,metaKey:_.metaKey,accelKey:wi(_)}))},h=y=>{if(y&&(n="zooming"),n==="zooming")return;const x=Math.abs(c-o),_=T.Dist(l,d);switch(n){case"not sure":{x>24?n="zooming":_>16&&(n="panning");break}case"panning":{x>64&&(n="zooming");break}}};return{onWheel:i,onPinchStart:f,onPinchEnd:y=>{const x=r.current,{event:_,origin:w,offset:I}=y;if(_ instanceof WheelEvent||!(_.target===x||x!=null&&x.contains(_.target)))return;const b=I[0];n="not sure",e.timers.requestAnimationFrame(()=>{e.dispatch({type:"pinch",name:"pinch_end",point:{x:w[0],y:w[1],z:b},delta:{x:w[0],y:w[1]},shiftKey:_.shiftKey,altKey:_.altKey,ctrlKey:_.metaKey||_.ctrlKey,metaKey:_.metaKey,accelKey:wi(_)})})},onPinch:y=>{const x=r.current,{event:_,origin:w,offset:I,da:b}=y;if(_ instanceof WheelEvent||!(_.target===x||x!=null&&x.contains(_.target)))return;const P=y.type==="gesturechange"||y.type==="gestureend";c=b[0];const C=w[0]-d.x,k=w[1]-d.y;switch(d.x=w[0],d.y=w[1],h(P),n){case"zooming":{a=I[0],e.dispatch({type:"pinch",name:"pinch",point:{x:w[0],y:w[1],z:a},delta:{x:C,y:k},shiftKey:_.shiftKey,altKey:_.altKey,ctrlKey:_.metaKey||_.ctrlKey,metaKey:_.metaKey,accelKey:wi(_)});break}case"panning":{e.dispatch({type:"pinch",name:"pinch",point:{x:w[0],y:w[1],z:s},delta:{x:C,y:k},shiftKey:_.shiftKey,altKey:_.altKey,ctrlKey:_.metaKey||_.ctrlKey,metaKey:_.metaKey,accelKey:wi(_)});break}}}}},[e,r]);txe(t,{target:r,eventOptions:{passive:!1},pinch:{from:()=>[e.getZoomLevel(),0],scaleBounds:()=>{const n=e.getBaseZoom(),i=e.getCameraOptions().zoomSteps,o=i[0]*n,s=i[i.length-1]*n;return{from:e.getZoomLevel(),max:s,min:o}}}})}function ob(r,e,t){const n=r.getShape(e),i=r.getShapeHandles(n);return{shape:n,handle:i.find(o=>o.id===t)}}function ixe(r,e){const t=he();return A.useMemo(()=>{const n=c=>{if(c.isKilled)return;const l=rm(c.currentTarget);Hh(l,c);const{shape:d,handle:f}=ob(t,r,e);f&&t.dispatch({type:"pointer",target:"handle",handle:f,shape:d,name:"pointer_down",...Ao(c)})};let i,o;return{onPointerDown:n,onPointerMove:c=>{if(c.isKilled||c.clientX===i&&c.clientY===o)return;i=c.clientX,o=c.clientY;const{shape:l,handle:d}=ob(t,r,e);d&&t.dispatch({type:"pointer",target:"handle",handle:d,shape:l,name:"pointer_move",...Ao(c)})},onPointerUp:c=>{if(c.isKilled)return;const l=rm(c.currentTarget);Wh(l,c);const{shape:d,handle:f}=ob(t,r,e);f&&t.dispatch({type:"pointer",target:"handle",handle:f,shape:d,name:"pointer_up",...Ao(c)})}}},[t,r,e])}function oxe(r){const e=he();A.useLayoutEffect(()=>{const t=LJ(()=>{r.current&&e.updateViewportScreenBounds(r.current)},200,{trailing:!0}),n=e.timers.setInterval(t,1e3);window.addEventListener("resize",t);const i=new ResizeObserver(a=>{a[0].contentRect&&t()}),o=r.current;let s=null;return o&&(i.observe(o),s=sxe(o),s.addEventListener("scroll",t)),()=>{clearInterval(n),window.removeEventListener("resize",t),i.disconnect(),s==null||s.removeEventListener("scroll",t),t.cancel()}},[e,r])}/*!
89
- * Author: excalidraw
90
- * MIT License: https://github.com/excalidraw/excalidraw/blob/master/LICENSE
91
- * https://github.com/excalidraw/excalidraw/blob/48c3465b19f10ec755b3eb84e21a01a468e96e43/packages/excalidraw/utils.ts#L600
92
- */const sxe=r=>{let e=r.parentElement;for(;e;){if(e===document.body)return document;const{overflowY:t}=window.getComputedStyle(e);if(e.scrollHeight>e.clientHeight&&(t==="auto"||t==="scroll"||t==="overlay"))return e;e=e.parentElement}return document};class He{constructor(e=0,t=0,n=0,i=0){q(this,"x",0);q(this,"y",0);q(this,"w",0);q(this,"h",0);this.x=e,this.y=t,this.w=n,this.h=i}get point(){return new T(this.x,this.y)}set point(e){this.x=e.x,this.y=e.y}get minX(){return this.x}set minX(e){this.x=e}get midX(){return this.x+this.w/2}get maxX(){return this.x+this.w}get minY(){return this.y}set minY(e){this.y=e}get midY(){return this.y+this.h/2}get maxY(){return this.y+this.h}get width(){return this.w}set width(e){this.w=e}get height(){return this.h}set height(e){this.h=e}get aspectRatio(){return this.width/this.height}get center(){return new T(this.midX,this.midY)}set center(e){this.minX=e.x-this.width/2,this.minY=e.y-this.height/2}get corners(){return[new T(this.minX,this.minY),new T(this.maxX,this.minY),new T(this.maxX,this.maxY),new T(this.minX,this.maxY)]}get cornersAndCenter(){return[new T(this.minX,this.minY),new T(this.maxX,this.minY),new T(this.maxX,this.maxY),new T(this.minX,this.maxY),this.center]}get sides(){const{corners:e}=this;return[[e[0],e[1]],[e[1],e[2]],[e[2],e[3]],[e[3],e[0]]]}get size(){return new T(this.w,this.h)}toFixed(){return this.x=_g(this.x),this.y=_g(this.y),this.w=_g(this.w),this.h=_g(this.h),this}setTo(e){return this.x=e.x,this.y=e.y,this.w=e.w,this.h=e.h,this}set(e=0,t=0,n=0,i=0){return this.x=e,this.y=t,this.w=n,this.h=i,this}expand(e){const t=Math.min(this.minX,e.minX),n=Math.min(this.minY,e.minY),i=Math.max(this.maxX,e.maxX),o=Math.max(this.maxY,e.maxY);return this.x=t,this.y=n,this.w=i-t,this.h=o-n,this}expandBy(e){return this.x-=e,this.y-=e,this.w+=e*2,this.h+=e*2,this}scale(e){return this.x/=e,this.y/=e,this.w/=e,this.h/=e,this}clone(){const{x:e,y:t,w:n,h:i}=this;return new He(e,t,n,i)}translate(e){return this.x+=e.x,this.y+=e.y,this}snapToGrid(e){const t=Math.round(this.minX/e)*e,n=Math.round(this.minY/e)*e,i=Math.round(this.maxX/e)*e,o=Math.round(this.maxY/e)*e;this.minX=t,this.minY=n,this.width=Math.max(1,i-t),this.height=Math.max(1,o-n)}collides(e){return He.Collides(this,e)}contains(e){return He.Contains(this,e)}includes(e){return He.Includes(this,e)}containsPoint(e,t=0){return He.ContainsPoint(this,e,t)}getHandlePoint(e){switch(e){case"top_left":return new T(this.minX,this.minY);case"top_right":return new T(this.maxX,this.minY);case"bottom_left":return new T(this.minX,this.maxY);case"bottom_right":return new T(this.maxX,this.maxY);case"top":return new T(this.midX,this.minY);case"right":return new T(this.maxX,this.midY);case"bottom":return new T(this.midX,this.maxY);case"left":return new T(this.minX,this.midY)}}toJson(){return{x:this.minX,y:this.minY,w:this.w,h:this.h}}resize(e,t,n){const{minX:i,minY:o,maxX:s,maxY:a}=this;let{minX:c,minY:l,maxX:d,maxY:f}=this;switch(e){case"left":case"top_left":case"bottom_left":{c+=t;break}case"right":case"top_right":case"bottom_right":{d+=t;break}}switch(e){case"top":case"top_left":case"top_right":{l+=n;break}case"bottom":case"bottom_left":case"bottom_right":{f+=n;break}}const h=(d-c)/(s-i),g=(f-l)/(a-o),m=h<0,y=g<0;if(m){const x=d;d=c,c=x}if(y){const x=f;f=l,l=x}this.minX=c,this.minY=l,this.width=Math.abs(d-c),this.height=Math.abs(f-l)}union(e){const t=Math.min(this.minX,e.x),n=Math.min(this.minY,e.y),i=Math.max(this.maxX,e.w+e.x),o=Math.max(this.maxY,e.h+e.y);return this.x=t,this.y=n,this.width=i-t,this.height=o-n,this}static From(e){return new He(e.x,e.y,e.w,e.h)}static FromCenter(e,t){return new He(e.x-t.x/2,e.y-t.y/2,t.x,t.y)}static FromPoints(e){if(e.length===0)return new He;let t=1/0,n=1/0,i=-1/0,o=-1/0,s;for(let a=0,c=e.length;a<c;a++)s=e[a],t=Math.min(s.x,t),n=Math.min(s.y,n),i=Math.max(s.x,i),o=Math.max(s.y,o);return new He(t,n,i-t,o-n)}static Expand(e,t){const n=Math.min(t.minX,e.minX),i=Math.min(t.minY,e.minY),o=Math.max(t.maxX,e.maxX),s=Math.max(t.maxY,e.maxY);return new He(n,i,o-n,s-i)}static ExpandBy(e,t){return new He(e.minX-t,e.minY-t,e.width+t*2,e.height+t*2)}static Collides(e,t){return!(e.maxX<t.minX||e.minX>t.maxX||e.maxY<t.minY||e.minY>t.maxY)}static Contains(e,t){return e.minX<t.minX&&e.minY<t.minY&&e.maxY>t.maxY&&e.maxX>t.maxX}static Includes(e,t){return He.Collides(e,t)||He.Contains(e,t)}static ContainsPoint(e,t,n=0){return!(t.x<e.minX-n||t.y<e.minY-n||t.x>e.maxX+n||t.y>e.maxY+n)}static Common(e){let t=1/0,n=1/0,i=-1/0,o=-1/0;for(let s=0;s<e.length;s++){const a=e[s];t=Math.min(t,a.minX),n=Math.min(n,a.minY),i=Math.max(i,a.maxX),o=Math.max(o,a.maxY)}return new He(t,n,i-t,o-n)}static Sides(e,t=0){const{corners:n}=e;return[[n[0],n[1]],[n[1],n[2]],[n[2],n[3]],[n[3],n[0]]]}static Resize(e,t,n,i,o=!1){const{minX:s,minY:a,maxX:c,maxY:l}=e;let{minX:d,minY:f,maxX:h,maxY:g}=e;switch(t){case"left":case"top_left":case"bottom_left":{d+=n;break}case"right":case"top_right":case"bottom_right":{h+=n;break}}switch(t){case"top":case"top_left":case"top_right":{f+=i;break}case"bottom":case"bottom_left":case"bottom_right":{g+=i;break}}const m=(h-d)/(c-s),y=(g-f)/(l-a),x=m<0,_=y<0;if(o){const I=(c-s)/(l-a),b=Math.abs(h-d),P=Math.abs(g-f),C=b*(y<0?1:-1)*(1/I),k=P*(m<0?1:-1)*I,O=I<b/P;switch(t){case"top_left":{O?f=g+C:d=h+k;break}case"top_right":{O?f=g+C:h=d-k;break}case"bottom_right":{O?g=f-C:h=d-k;break}case"bottom_left":{O?g=f-C:d=h+k;break}case"bottom":case"top":{const L=(d+h)/2,j=P*I;d=L-j/2,h=L+j/2;break}case"left":case"right":{const L=(f+g)/2,j=b/I;f=L-j/2,g=L+j/2;break}}}if(x){const I=h;h=d,d=I}if(_){const I=g;g=f,f=I}const w=new He(d,f,Math.abs(h-d),Math.abs(g-f));return{box:w,scaleX:+(w.width/e.width*(m>0?1:-1)).toFixed(5),scaleY:+(w.height/e.height*(y>0?1:-1)).toFixed(5)}}equals(e){return He.Equals(this,e)}static Equals(e,t){return t.x===e.x&&t.y===e.y&&t.w===e.w&&t.h===e.h}zeroFix(){return this.w=Math.max(1,this.w),this.h=Math.max(1,this.h),this}static ZeroFix(e){return new He(e.x,e.y,Math.max(1,e.w),Math.max(1,e.h))}}function axe(r){switch(r){case"top":return"bottom";case"bottom":return"top";case"top_left":return"bottom_left";case"top_right":return"bottom_right";case"bottom_left":return"top_left";case"bottom_right":return"top_right";default:return r}}function cxe(r){switch(r){case"left":return"right";case"right":return"left";case"top_left":return"top_right";case"top_right":return"top_left";case"bottom_left":return"bottom_right";case"bottom_right":return"bottom_left";default:return r}}function lxe(r){return r==="top_left"||r==="top_right"||r==="bottom_right"||r==="bottom_left"}class Ke{constructor(e,t,n,i,o,s){q(this,"a",1);q(this,"b",0);q(this,"c",0);q(this,"d",1);q(this,"e",0);q(this,"f",0);this.a=e,this.b=t,this.c=n,this.d=i,this.e=o,this.f=s}equals(e){return this===e||this.a===e.a&&this.b===e.b&&this.c===e.c&&this.d===e.d&&this.e===e.e&&this.f===e.f}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this}multiply(e){const t=e,{a:n,b:i,c:o,d:s,e:a,f:c}=this;return this.a=n*t.a+o*t.b,this.c=n*t.c+o*t.d,this.e=n*t.e+o*t.f+a,this.b=i*t.a+s*t.b,this.d=i*t.c+s*t.d,this.f=i*t.e+s*t.f+c,this}rotate(e,t,n){return e===0?this:t===void 0?this.multiply(Ke.Rotate(e)):this.translate(t,n).multiply(Ke.Rotate(e)).translate(-t,-n)}translate(e,t){return this.multiply(Ke.Translate(e,t))}scale(e,t){return this.multiply(Ke.Scale(e,t))}invert(){const{a:e,b:t,c:n,d:i,e:o,f:s}=this,a=e*i-t*n;return this.a=i/a,this.b=t/-a,this.c=n/-a,this.d=e/a,this.e=(i*o-n*s)/-a,this.f=(t*o-e*s)/a,this}applyToPoint(e){return Ke.applyToPoint(this,e)}applyToPoints(e){return Ke.applyToPoints(this,e)}rotation(){return Ke.Rotation(this)}point(){return Ke.Point(this)}decomposed(){return Ke.Decompose(this)}toCssString(){return Ke.toCssString(this)}setTo(e){return Object.assign(this,e),this}decompose(){return Ke.Decompose(this)}clone(){return new Ke(this.a,this.b,this.c,this.d,this.e,this.f)}static Identity(){return new Ke(1,0,0,1,0,0)}static Translate(e,t){return new Ke(1,0,0,1,e,t)}static Rotate(e,t,n){if(e===0)return Ke.Identity();const i=Math.cos(e),o=Math.sin(e),s=new Ke(i,o,-o,i,0,0);return t===void 0?s:Ke.Compose(Ke.Translate(t,n),s,Ke.Translate(-t,-n))}static Scale(e,t,n,i){const o=new Ke(e,0,0,t,0,0);return n===void 0?o:Ke.Compose(Ke.Translate(n,i),o,Ke.Translate(-n,-i))}static Multiply(e,t){return{a:e.a*t.a+e.c*t.b,c:e.a*t.c+e.c*t.d,e:e.a*t.e+e.c*t.f+e.e,b:e.b*t.a+e.d*t.b,d:e.b*t.c+e.d*t.d,f:e.b*t.e+e.d*t.f+e.f}}static Inverse(e){const t=e.a*e.d-e.b*e.c;return{a:e.d/t,b:e.b/-t,c:e.c/-t,d:e.a/t,e:(e.d*e.e-e.c*e.f)/-t,f:(e.b*e.e-e.a*e.f)/t}}static Absolute(e){const t=e.a*e.d-e.b*e.c;return{a:e.d/t,b:e.b/-t,c:e.c/-t,d:e.a/t,e:(e.d*e.e-e.c*e.f)/t,f:(e.b*e.e-e.a*e.f)/-t}}static Compose(...e){const t=Ke.Identity();for(let n=0,i=e.length;n<i;n++)t.multiply(e[n]);return t}static Point(e){return new T(e.e,e.f)}static Rotation(e){let t;if(e.a!==0||e.c!==0){const n=(e.a*e.a+e.c*e.c)**.5;t=Math.acos(e.a/n)*(e.c>0?-1:1)}else if(e.b!==0||e.d!==0){const n=(e.b*e.b+e.d*e.d)**.5;t=Nr+Math.acos(e.b/n)*(e.d>0?-1:1)}else t=0;return _P(t)}static Decompose(e){let t,n,i;if(e.a!==0||e.c!==0){const o=(e.a*e.a+e.c*e.c)**.5;t=o,n=(e.a*e.d-e.b*e.c)/o,i=Math.acos(e.a/o)*(e.c>0?-1:1)}else if(e.b!==0||e.d!==0){const o=(e.b*e.b+e.d*e.d)**.5;t=(e.a*e.d-e.b*e.c)/o,n=o,i=Nr+Math.acos(e.b/o)*(e.d>0?-1:1)}else t=0,n=0,i=0;return{x:e.e,y:e.f,scaleX:t,scaleY:n,rotation:_P(i)}}static Smooth(e,t=1e10){return e.a=Math.round(e.a*t)/t,e.b=Math.round(e.b*t)/t,e.c=Math.round(e.c*t)/t,e.d=Math.round(e.d*t)/t,e.e=Math.round(e.e*t)/t,e.f=Math.round(e.f*t)/t,e}static toCssString(e){return`matrix(${fe(e.a)}, ${fe(e.b)}, ${fe(e.c)}, ${fe(e.d)}, ${fe(e.e)}, ${fe(e.f)})`}static applyToPoint(e,t){return new T(e.a*t.x+e.c*t.y+e.e,e.b*t.x+e.d*t.y+e.f,t.z)}static applyToXY(e,t,n){return[e.a*t+e.c*n+e.e,e.b*t+e.d*n+e.f]}static applyToPoints(e,t){return t.map(n=>new T(e.a*n.x+e.c*n.y+e.e,e.b*n.x+e.d*n.y+e.f,n.z))}static applyToBounds(e,t){return new He(e.e+t.minX,e.f+t.minY,t.width,t.height)}static From(e){return new Ke(e.a,e.b,e.c,e.d,e.e,e.f)}static Cast(e){return e instanceof Ke?e:Ke.From(e)}}class ul{constructor(e){q(this,"isFilled",!1);q(this,"isClosed",!0);q(this,"isLabel",!1);q(this,"debugColor");q(this,"ignore");q(this,"_vertices");q(this,"_bounds");q(this,"_area");q(this,"_length");this.isFilled=e.isFilled,this.isClosed=e.isClosed,this.isLabel=e.isLabel??!1,this.debugColor=e.debugColor,this.ignore=e.ignore}hitTestPoint(e,t=0,n=!1){return this.isClosed&&(this.isFilled||n)&&Oo(e,this.vertices)?!0:T.Dist2(e,this.nearestPoint(e))<=t*t}distanceToPoint(e,t=!1){return e.dist(this.nearestPoint(e))*(this.isClosed&&(this.isFilled||t)&&Oo(e,this.vertices)?-1:1)}distanceToLineSegment(e,t){if(e.equals(t))return this.distanceToPoint(e);const{vertices:n}=this;let i,o=1/0,s,a,c;for(let l=0;l<n.length;l++)a=n[l],c=T.NearestPointOnLineSegment(e,t,a,!0),s=T.Dist2(a,c),s<o&&(o=s,i=c);if(!i)throw Error("nearest point not found");return this.isClosed&&this.isFilled&&Oo(i,this.vertices)?-o:o}hitTestLineSegment(e,t,n=0){return this.distanceToLineSegment(e,t)<=n}nearestPointOnLineSegment(e,t){const{vertices:n}=this;let i,o=1/0,s,a,c;for(let l=0;l<n.length;l++)a=n[l],c=T.NearestPointOnLineSegment(e,t,a,!0),s=T.Dist2(a,c),s<o&&(o=s,i=c);if(!i)throw Error("nearest point not found");return i}isPointInBounds(e,t=0){const{bounds:n}=this;return!(e.x<n.minX-t||e.y<n.minY-t||e.x>n.maxX+t||e.y>n.maxY+t)}get vertices(){return this._vertices||(this._vertices=this.getVertices()),this._vertices}getBounds(){return He.FromPoints(this.vertices)}get bounds(){return this._bounds||(this._bounds=this.getBounds()),this._bounds}get center(){return this.bounds.center}get area(){return this._area||(this._area=this.getArea()),this._area}getArea(){if(!this.isClosed)return 0;const{vertices:e}=this;let t=0;for(let n=0,i=e.length;n<i;n++){const o=e[n],s=e[(n+1)%i];t+=o.x*s.y-s.x*o.y}return t/2}toSimpleSvgPath(){let e="";const{vertices:t}=this,n=t.length;if(n===0)return e;e+=`M${t[0].x},${t[0].y}`;for(let i=1;i<n;i++)e+=`L${t[i].x},${t[i].y}`;return this.isClosed&&(e+="Z"),e}get length(){return this._length?this._length:(this._length=this.getLength(),this._length)}getLength(){const{vertices:e}=this;let t,n=e[0],i=0;for(let o=1;o<e.length;o++)t=e[o],i+=T.Dist2(n,t),n=t;return Math.sqrt(i)}}class cs extends ul{constructor(t){super({...t,isClosed:!0,isFilled:!1});q(this,"children",[]);q(this,"ignoredChildren",[]);for(const n of t.children)n.ignore?this.ignoredChildren.push(n):this.children.push(n);if(this.children.length===0)throw Error("Group2d must have at least one child")}getVertices(){return this.children.filter(t=>!t.isLabel).flatMap(t=>t.vertices)}nearestPoint(t){let n=1/0,i;const{children:o}=this;if(o.length===0)throw Error("no children");let s,a;for(const c of o)s=c.nearestPoint(t),a=T.Dist2(s,t),a<n&&(n=a,i=s);if(!i)throw Error("nearest point not found");return i}distanceToPoint(t,n=!1){return Math.min(...this.children.map((i,o)=>i.distanceToPoint(t,n||o>0)))}hitTestPoint(t,n,i){return!!this.children.filter(o=>!o.isLabel).find(o=>o.hitTestPoint(t,n,i))}hitTestLineSegment(t,n,i){return!!this.children.filter(o=>!o.isLabel).find(o=>o.hitTestLineSegment(t,n,i))}getArea(){return this.children[0].area}toSimpleSvgPath(){let t="";for(const i of this.children)t+=i.toSimpleSvgPath();const n=He.FromPoints(this.vertices).corners;for(let i=0,o=n.length;i<o;i++){const s=n[i],a=n[(i-1+o)%o],c=s.dist(a),l=n[(i+1)%o],d=s.dist(l),f=s.clone().lrp(a,4/c),h=s,g=s.clone().lrp(l,4/d);t+=`M${f.x},${f.y} L${h.x},${h.y} L${g.x},${g.y} `}return t}getLength(){return this.children.reduce((t,n)=>n.isLabel?t:t+n.length,0)}getSvgPathData(){return this.children.map((t,n)=>t.isLabel?"":t.getSvgPathData(n===0)).join(" ")}}function uxe(r=!0){const[e,t]=A.useState(0),n=he();A.useEffect(()=>{if(!r)return;const i=()=>t(o=>o+1);return n.on("tick",i),()=>{n.off("tick",i)}},[n,r])}const dxe=ii(function({showStroke:e=!0,showVertices:t=!0,showClosestPointOnOutline:n=!0}){const i=he();uxe(n);const o=i.getZoomLevel(),s=i.getRenderingShapes(),{inputs:{currentPagePoint:a}}=i;return v.jsx("svg",{style:{position:"absolute",pointerEvents:"none",zIndex:999999999,top:0,left:0,overflow:"visible"},children:s.map(c=>{const l=i.getShape(c.id);if(l.type==="group")return null;const d=i.getShapeGeometry(l),f=i.getShapePageTransform(l),h=i.getPointInShapeSpace(l,a),g=d.nearestPoint(h),m=d.distanceToPoint(h,!0),y=Math.abs(m)*o,x=m<0,{vertices:_}=d;return v.jsxs("g",{transform:f.toCssString(),strokeLinecap:"round",strokeLinejoin:"round",children:[e&&v.jsx("g",{stroke:d.debugColor??"red",opacity:"1",strokeWidth:2/o,fill:"none",children:v.jsx(Xte,{geometry:d})}),t&&_.map((w,I)=>v.jsx("circle",{cx:w.x,cy:w.y,r:2/o,fill:`hsl(${_d(I,[0,_.length-1],[120,200])}, 100%, 50%)`,stroke:"black",strokeWidth:1/o},`v${I}`)),n&&y<150&&v.jsx("line",{x1:g.x,y1:g.y,x2:h.x,y2:h.y,opacity:1-y/150,stroke:x?"goldenrod":"dodgerblue",strokeWidth:2/o})]},c.id+"_outline")})})});function Xte({geometry:r}){return r instanceof cs?v.jsx(v.Fragment,{children:[...r.children,...r.ignoredChildren].map((e,t)=>v.jsx(Xte,{geometry:e},t))}):v.jsx("path",{d:r.toSimpleSvgPath()})}function Zte(r){return Tge(r)}function Qte(){const r=he(),e=Vve("userIds",()=>Zte(r.getCollaborators().map(t=>t.userId)).sort(),{isEqual:(t,n)=>{var i;return t.join(",")===((i=n.join)==null?void 0:i.call(n,","))}},[r]);return ye(e)}function Hm(r){const e=he();return ye(`latestPresence:${r}`,()=>e.getCollaborators().find(n=>n.userId===r),[e,r])??null}const fxe=ii(function(){return Qte().map(t=>v.jsx(hxe,{collaboratorId:t},t))}),hxe=ii(function({collaboratorId:e}){const t=he(),n=Hm(e),i=gxe(t,n);if(!(n&&n.currentPageId===t.getCurrentPageId()))return null;switch(i){case"inactive":{const{followingUserId:o,highlightedUserIds:s}=t.getInstanceState();if(!(o===n.userId||s.includes(n.userId)))return null;break}case"idle":{const{highlightedUserIds:o}=t.getInstanceState();if(n.followingUserId===t.user.getId()&&!(n.chatMessage||o.includes(n.userId)))return null;break}}return v.jsx(pxe,{latestPresence:n})}),pxe=ii(function({latestPresence:e}){const t=he(),{CollaboratorBrush:n,CollaboratorScribble:i,CollaboratorCursor:o,CollaboratorHint:s,CollaboratorShapeIndicator:a}=Gr(),c=t.getZoomLevel(),l=t.getViewportPageBounds(),{userId:d,chatMessage:f,brush:h,scribbles:g,selectedShapeIds:m,userName:y,cursor:x,color:_}=e;if(!x)return null;const w=!(x.x<l.minX-12/c||x.y<l.minY-16/c||x.x>l.maxX-12/c||x.y>l.maxY-16/c);return v.jsxs(v.Fragment,{children:[h&&n?v.jsx(n,{className:"tl-collaborator__brush",brush:h,color:_,opacity:.1},d+"_brush"):null,w&&o?v.jsx(o,{className:"tl-collaborator__cursor",point:x,color:_,zoom:c,name:y!=="New User"?y:null,chatMessage:f??""},d+"_cursor"):s?v.jsx(s,{className:"tl-collaborator__cursor-hint",point:x,color:_,zoom:c,viewport:l},d+"_cursor_hint"):null,i&&g.length?v.jsx(v.Fragment,{children:g.map(I=>v.jsx(i,{className:"tl-collaborator__scribble",scribble:I,color:_,zoom:c,opacity:I.color==="laser"?.5:.1},d+"_scribble_"+I.id))}):null,a&&m.filter(I=>!t.isShapeHidden(I)).map(I=>v.jsx(a,{className:"tl-collaborator__shape-indicator",shapeId:I,color:_,opacity:.5},d+"_"+I))]})});function mD(r,e){return e>r.options.collaboratorInactiveTimeoutMs?"inactive":e>r.options.collaboratorIdleTimeoutMs?"idle":"active"}function gxe(r,e){const t=A.useRef((e==null?void 0:e.lastActivityTimestamp)??-1),[n,i]=A.useState(()=>mD(r,Date.now()-t.current));return A.useEffect(()=>{const o=r.timers.setInterval(()=>{i(mD(r,Date.now()-t.current))},r.options.collaboratorCheckIntervalMs);return()=>clearInterval(o)},[r]),e&&(t.current=e.lastActivityTimestamp??1/0),n}function vxe(){const r=he(),e=ye("is menu open",()=>r.menus.hasAnyOpenMenus(),[r]),[t,n]=A.useState(!1),i=e||t,o=yT(),s=A.useRef({isDown:!1,isDragging:!1,start:new T}),a=A.useCallback(d=>{d.button===0&&(n(!0),s.current={isDown:!0,isDragging:!1,start:new T(d.clientX,d.clientY)}),r.menus.clearOpenMenus()},[r]),c=A.useCallback(d=>{var f,h,g;if(s.current.isDown){if(s.current.isDragging){(f=o.onPointerMove)==null||f.call(o,d);return}if(T.Dist2(s.current.start,new T(d.clientX,d.clientY))>r.options.dragDistanceSquared){s.current={...s.current,isDown:!0,isDragging:!0};const{x:m,y}=s.current.start;(h=o.onPointerDown)==null||h.call(o,{...d,clientX:m,clientY:y,button:0}),(g=o.onPointerMove)==null||g.call(o,d)}}},[o,r]),l=A.useCallback(d=>{var f;(f=o.onPointerUp)==null||f.call(o,d),n(!1),s.current={isDown:!1,isDragging:!1,start:new T(d.clientX,d.clientY)}},[o]);return i&&v.jsx("div",{className:"tlui-menu-click-capture","data-testid":"menu-click-capture.content",...o,onPointerDown:a,onPointerMove:c,onPointerUp:l})}const Jte=A.memo(function({id:e,shape:t,util:n,index:i,backgroundIndex:o,opacity:s}){const a=he(),{ShapeErrorFallback:c}=Gr(),l=A.useRef(null),d=A.useRef(null),f=A.useRef({transform:"",clipPath:"none",width:0,height:0,x:0,y:0,isCulled:!1});Vc("set shape stuff",()=>{const m=a.getShape(e);if(!m)return;const y=f.current,x=a.getShapeClipPath(e)??"none";x!==y.clipPath&&(vi(l.current,"clip-path",x),vi(d.current,"clip-path",x),y.clipPath=x);const _=a.getShapePageTransform(e),w=Ke.toCssString(_),I=a.getShapeGeometry(m).bounds;w!==y.transform&&(vi(l.current,"transform",w),vi(d.current,"transform",w),y.transform=w);const b=Math.max(I.width,1),P=Math.max(I.height,1);(b!==y.width||P!==y.height)&&(vi(l.current,"width",b+"px"),vi(l.current,"height",P+"px"),vi(d.current,"width",b+"px"),vi(d.current,"height",P+"px"),y.width=b,y.height=P)},[a]),Vc("set opacity and z-index",()=>{const m=l.current,y=d.current;vi(m,"opacity",s),vi(y,"opacity",s),vi(m,"z-index",i),vi(y,"z-index",o)},[s,i,o]),Vc("set display",()=>{if(!a.getShape(e))return;const x=a.getCulledShapes().has(e);x!==f.current.isCulled&&(vi(l.current,"display",x?"none":"block"),vi(d.current,"display",x?"none":"block"),f.current.isCulled=x)},[a]);const h=A.useCallback(m=>a.annotateError(m,{origin:"shape",willCrashApp:!1}),[a]);if(!t)return null;const g="fill"in t.props&&t.props.fill!=="none";return v.jsxs(v.Fragment,{children:[n.backgroundComponent&&v.jsx("div",{ref:d,className:"tl-shape tl-shape-background","data-shape-type":t.type,"data-shape-id":t.id,draggable:!1,children:v.jsx(_h,{fallback:c,onError:h,children:v.jsx(tre,{shape:t,util:n})})}),v.jsx("div",{ref:l,className:"tl-shape","data-shape-type":t.type,"data-shape-is-filled":g,"data-shape-id":t.id,draggable:!1,children:v.jsx(_h,{fallback:c,onError:h,children:v.jsx(ere,{shape:t,util:n})})})]})}),ere=A.memo(function({shape:e,util:t}){return Fm("InnerShape:"+e.type,()=>t.component(t.editor.store.unsafeGetWithoutCapture(e.id)),[t,e.id])},(r,e)=>r.shape.props===e.shape.props&&r.shape.meta===e.shape.meta&&r.util===e.util),tre=A.memo(function({shape:e,util:t}){return Fm("InnerShape:"+e.type,()=>{var n;return(n=t.backgroundComponent)==null?void 0:n.call(t,t.editor.store.unsafeGetWithoutCapture(e.id))},[t,e.id])},(r,e)=>r.shape.props===e.shape.props&&r.shape.meta===e.shape.meta&&r.util===e.util);function mxe({className:r}){const e=he(),{Background:t,SvgDefs:n,ShapeIndicators:i}=Gr(),o=A.useRef(null),s=A.useRef(null),a=A.useRef(null),c=Ln();oxe(o),Qye(),Zye(),nxe(o),eSe(o);const l=A.useRef({lodDisableTextOutline:!1,allowTextOutline:!0});Vc("position layers",function(){const{x:w,y:I,z:b}=e.getCamera();if(l.current.allowTextOutline&&Pr.isSafari&&(c.style.setProperty("--tl-text-outline","none"),l.current.allowTextOutline=!1),l.current.allowTextOutline&&b<e.options.textShadowLod!==l.current.lodDisableTextOutline){const k=b<e.options.textShadowLod;c.style.setProperty("--tl-text-outline",k?"none":"var(--tl-text-outline-reference)"),l.current.lodDisableTextOutline=k}const P=b>=1?_d(b,[1,8],[.125,.5],!0):_d(b,[.1,1],[-2,.125],!0),C=`scale(${fe(b)}) translate(${fe(w+P)}px,${fe(I+P)}px)`;vi(s.current,"transform",C),vi(a.current,"transform",C)},[e,c]);const d=yT(),f=ye("shapeSvgDefs",()=>{const _=new Map;for(const w of Tn(e.shapeUtils)){if(!w)return;const I=w.getCanvasSvgDefs();for(const{key:b,component:P}of I)_.has(b)||_.set(b,v.jsx(P,{},b))}return[..._.values()]},[e]),h=ye("debug_shapes",()=>yn.hideShapes.get(),[yn]),g=ye("debug_svg",()=>yn.debugSvg.get(),[yn]),m=ye("debug_geometry",()=>yn.debugGeometry.get(),[yn]),y=ye("isEditingAnything",()=>e.getEditingShapeId()!==null,[e]),x=ye("isSelectingAnything",()=>!!e.getSelectedShapeIds().length,[e]);return v.jsxs(v.Fragment,{children:[v.jsxs("div",{ref:o,draggable:!1,"data-iseditinganything":y,"data-isselectinganything":x,className:bt("tl-canvas",r),"data-testid":"canvas",...d,children:[v.jsx("svg",{className:"tl-svg-context",children:v.jsxs("defs",{children:[f,v.jsx(kxe,{}),v.jsx(Oxe,{}),n&&v.jsx(n,{})]})}),t&&v.jsx("div",{className:"tl-background__wrapper",children:v.jsx(t,{})}),v.jsx(Sxe,{}),v.jsxs("div",{ref:s,className:"tl-html-layer tl-shapes",draggable:!1,children:[v.jsx(Lxe,{}),v.jsx(Dxe,{}),h?null:g?v.jsx(Cxe,{}):v.jsx(Axe,{})]}),v.jsx("div",{className:"tl-overlays",children:v.jsxs("div",{ref:a,className:"tl-html-layer",children:[m?v.jsx(dxe,{}):null,v.jsx(_xe,{}),v.jsx(xxe,{}),v.jsx(wxe,{}),i&&v.jsx(i,{}),v.jsx(Rxe,{}),v.jsx(bxe,{}),v.jsx(jxe,{}),v.jsx(Exe,{}),v.jsx(fxe,{})]})}),v.jsx(Fxe,{})]}),v.jsx(vxe,{}),v.jsx(yxe,{})]})}function yxe(){const{InFrontOfTheCanvas:r}=Gr();return r?v.jsx(r,{}):null}function Sxe(){const r=he(),e=ye("gridSize",()=>r.getDocumentSettings().gridSize,[r]),{x:t,y:n,z:i}=ye("camera",()=>r.getCamera(),[r]),o=ye("isGridMode",()=>r.getInstanceState().isGridMode,[r]),{Grid:s}=Gr();return s&&o?v.jsx(s,{x:t,y:n,z:i,size:e}):null}function xxe(){const r=he(),e=ye("scribbles",()=>r.getInstanceState().scribbles,[r]),t=ye("zoomLevel",()=>r.getZoomLevel(),[r]),{Scribble:n}=Gr();return n&&e.length?e.map(i=>v.jsx(n,{className:"tl-user-scribble",scribble:i,zoom:t},i.id)):null}function _xe(){const r=he(),e=ye("brush",()=>r.getInstanceState().brush,[r]),{Brush:t}=Gr();return t&&e?v.jsx(t,{className:"tl-user-brush",brush:e}):null}function wxe(){const r=he(),e=ye("zoomBrush",()=>r.getInstanceState().zoomBrush,[r]),{ZoomBrush:t}=Gr();return t&&e?v.jsx(t,{className:"tl-user-brush tl-zoom-brush",brush:e}):null}function bxe(){const r=he(),e=ye("snapLines",()=>r.snaps.getIndicators(),[r]),t=ye("zoomLevel",()=>r.getZoomLevel(),[r]),{SnapIndicator:n}=Gr();return n&&e.length>0?e.map(i=>v.jsx(n,{className:"tl-user-snapline",line:i,zoom:t},i.id)):null}function Exe(){const r=he(),e=ye("handles shapeIdWithHandles",()=>{const{isReadonly:t,isChangingStyle:n}=r.getInstanceState();if(t||n)return!1;const i=r.getOnlySelectedShape();return!i||!r.getShapeHandles(i)?!1:i.id},[r]);return e?v.jsx(Ixe,{shapeId:e}):null}function Ixe({shapeId:r}){const e=he(),{Handles:t}=Gr(),n=ye("zoomLevel",()=>e.getZoomLevel(),[e]),i=ye("coarse pointer",()=>e.getInstanceState().isCoarsePointer,[e]),o=ye("handles transform",()=>e.getShapePageTransform(r),[e,r]),s=ye("handles",()=>{const c=e.getShapeHandles(r);if(!c)return null;const l=(i?e.options.coarseHandleRadius:e.options.handleRadius)/n*2;return c.filter(d=>d.type!=="virtual"||!c.some(f=>f!==d&&f.type==="vertex"&&T.Dist(d,f)<l)).sort(d=>d.type==="vertex"?1:-1)},[e,n,i,r]),a=ye("isHidden",()=>e.isShapeHidden(r),[e,r]);return!t||!s||!o||a?null:v.jsx(t,{children:v.jsx("g",{transform:Ke.toCssString(o),children:s.map(c=>v.jsx(Pxe,{shapeId:r,handle:c,zoom:n,isCoarse:i},c.id))})})}function Pxe({shapeId:r,handle:e,zoom:t,isCoarse:n}){const i=ixe(r,e.id),{Handle:o}=Gr();return o?v.jsx("g",{"aria-label":"handle",transform:`translate(${e.x}, ${e.y})`,...i,children:v.jsx(o,{shapeId:r,handle:e,zoom:t,isCoarse:n})}):null}function Cxe(){const r=he();return ye("rendering shapes",()=>r.getRenderingShapes(),[r]).map(t=>v.jsxs(A.Fragment,{children:[v.jsx(Jte,{...t}),v.jsx(Mxe,{id:t.id,mode:"iframe"})]},t.id+"_fragment"))}function Txe(){const r=he(),e=A.useRef(new Set);return Vc("reflow for culled shapes",()=>{const t=r.getCulledShapes();if(e.current.size===t.size&&[...t].every(i=>e.current.has(i)))return;e.current=t;const n=document.getElementsByClassName("tl-canvas");n.length!==0&&n[0].offsetHeight},[r]),null}function Axe(){const r=he(),e=ye("rendering shapes",()=>r.getRenderingShapes(),[r]);return v.jsxs(v.Fragment,{children:[e.map(t=>v.jsx(Jte,{...t},t.id+"_shape")),Pr.isSafari&&v.jsx(Txe,{})]})}function Rxe(){const r=he(),{ShapeIndicator:e}=Gr(),t=ye("hinting shape ids",()=>RC(r.getHintingShapeIds()),[r]);return!t.length||!e?null:t.map(n=>v.jsx(e,{className:"tl-user-indicator__hint",shapeId:n},n+"_hinting"))}function kxe(){return v.jsxs("g",{id:As("cursor"),children:[v.jsxs("g",{fill:"rgba(0,0,0,.2)",transform:"translate(-11,-11)",children:[v.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),v.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),v.jsxs("g",{fill:"white",transform:"translate(-12,-12)",children:[v.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),v.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),v.jsxs("g",{fill:"currentColor",transform:"translate(-12,-12)",children:[v.jsx("path",{d:"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"}),v.jsx("path",{d:"m13 10.814v11.188l2.969-2.866.428-.139h4.768z"})]})]})}function Oxe(){const r=As("cursor_hint");return v.jsx("path",{id:r,fill:"currentColor",d:"M -2,-5 2,0 -2,5 Z"})}function Mxe({id:r,mode:e}){const t=he(),[n,i]=A.useState(null),o=ye("is in root",()=>{const s=t.getShape(r);return(s==null?void 0:s.parentId)===t.getCurrentPageId()},[t,r]);return A.useEffect(()=>{if(!o)return;let s=null;const a=fa("shape to svg",async()=>{const c=Math.random();s=c;const d=t.isShapeOfType(r,"frame")?0:10;let f=t.getShapePageBounds(r);if(!f)return;f=f.clone().expandBy(d);const h=await t.getSvgString([r],{padding:d});if(s!==c||!h)return;const g=`data:image/svg+xml;utf8,${encodeURIComponent(h.svg)}`;i({src:g,bounds:f})});return()=>{s=null,a()}},[t,r,o]),!o||!n?null:e==="iframe"?v.jsx("iframe",{src:n.src,width:n.bounds.width,height:n.bounds.height,referrerPolicy:"no-referrer",style:{position:"absolute",top:0,left:0,border:"none",transform:`translate(${n.bounds.x}px, ${n.bounds.maxY+12}px)`,outline:"1px solid black",maxWidth:"none"}}):v.jsx("img",{src:n.src,width:n.bounds.width,height:n.bounds.height,referrerPolicy:"no-referrer",style:{position:"absolute",top:0,left:0,transform:`translate(${n.bounds.x}px, ${n.bounds.maxY+12}px)`,outline:"1px solid black",maxWidth:"none"}})}function jxe(){const r=he(),e=ye("selection rotation",()=>r.getSelectionRotation(),[r]),t=ye("selection bounds",()=>r.getSelectionRotatedPageBounds(),[r]),{SelectionForeground:n}=Gr();return!t||!n?null:v.jsx(n,{bounds:t,rotation:e})}function Dxe(){const r=he(),e=ye("selection rotation",()=>r.getSelectionRotation(),[r]),t=ye("selection bounds",()=>r.getSelectionRotatedPageBounds(),[r]),{SelectionBackground:n}=Gr();return!t||!n?null:v.jsx(n,{bounds:t,rotation:e})}function Lxe(){const{OnTheCanvas:r}=Gr();return r?v.jsx(r,{}):null}function Fxe(){const r=he(),e=ye("camera state",()=>r.getCameraState(),[r]);return v.jsx("div",{className:bt("tl-hit-test-blocker",{"tl-hit-test-blocker__hidden":e==="idle"})})}function Nxe({className:r,zoom:e,point:t,color:n,viewport:i,opacity:o=1}){const s=A.useRef(null);Fd(s,Yn(t.x,i.minX+5/e,i.maxX-5/e),Yn(t.y,i.minY+5/e,i.maxY-5/e),1/e,T.Angle(i.center,t));const a=As("cursor_hint");return v.jsxs("svg",{ref:s,className:bt("tl-overlays__item",r),children:[v.jsx("use",{href:`#${a}`,color:n,strokeWidth:3,stroke:"var(--color-background)"}),v.jsx("use",{href:`#${a}`,color:n,opacity:o})]})}const yD=A.memo(function({className:e,zoom:t,point:n,color:i,name:o,chatMessage:s}){const a=A.useRef(null);Fd(a,n==null?void 0:n.x,n==null?void 0:n.y,1/t);const c=As("cursor");return n?v.jsxs("div",{ref:a,className:bt("tl-overlays__item",e),children:[v.jsx("svg",{className:"tl-cursor",children:v.jsx("use",{href:`#${c}`,color:i})}),s?v.jsxs(v.Fragment,{children:[o&&v.jsx("div",{className:"tl-nametag-title",style:{color:i},children:o}),v.jsx("div",{className:"tl-nametag-chat",style:{backgroundColor:i},children:s})]}):o&&v.jsx("div",{className:"tl-nametag",style:{backgroundColor:i},children:o})]}):null});function $xe({x:r,y:e,z:t,size:n}){const i=Ld("grid"),o=he(),{gridSteps:s}=o.options;return v.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[v.jsx("defs",{children:s.map(({min:a,mid:c,step:l},d)=>{const f=l*n*t,h=.5+r*t,g=.5+e*t,m=h>0?h%f:f+h%f,y=g>0?g%f:f+g%f,x=t<c?_d(t,[a,c],[0,1]):1;return v.jsx("pattern",{id:pT(i,`${l}`),width:f,height:f,patternUnits:"userSpaceOnUse",children:v.jsx("circle",{className:"tl-grid-dot",cx:m,cy:y,r:1,opacity:x})},d)})}),s.map(({step:a},c)=>v.jsx("rect",{width:"100%",height:"100%",fill:`url(#${i}_${a})`},c))]})}function qxe({handle:r,isCoarse:e,className:t,zoom:n}){const i=he(),o=(e?i.options.coarseHandleRadius:i.options.handleRadius)/n;if(r.type==="clone"){const a=3/n,c=`M0,${-a} A${a},${a} 0 0,1 0,${a}`,l=Hye.indexOf(r.id);return v.jsxs("g",{className:bt(`tl-handle tl-handle__${r.type}`,t),children:[v.jsx("circle",{className:"tl-handle__bg",r:o}),v.jsx("path",{className:"tl-handle__fg",d:c,transform:`rotate(${-90+90*l})`})]})}const s=(r.type==="create"&&e?3:4)/Math.max(n,.25);return v.jsxs("g",{className:bt(`tl-handle tl-handle__${r.type}`,t),children:[v.jsx("circle",{className:"tl-handle__bg",r:o}),v.jsx("circle",{className:"tl-handle__fg",r:s})]})}const Bxe=({children:r})=>v.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:r}),Uxe=()=>{const{Spinner:r}=Gr();return v.jsx(vA,{children:r?v.jsx(r,{}):null})};function xT(r,e=!0){const t=r.length;if(t<2)return"";let n=r[0],i=r[1];if(t===2)return`M${vr(n)}L${vr(i)}`;let o="";for(let s=2,a=t-1;s<a;s++)n=r[s],i=r[s+1],o+=uo(n,i);return e?`M${uo(r[0],r[1])}Q${vr(r[1])}${uo(r[1],r[2])}T${o}${uo(r[t-1],r[0])}${uo(r[0],r[1])}Z`:`M${vr(r[0])}Q${vr(r[1])}${uo(r[1],r[2])}${r.length>3?"T":""}${o}L${vr(r[t-1])}`}function SD({scribble:r,zoom:e,color:t,opacity:n,className:i}){return r.points.length?v.jsx("svg",{className:i&&bt("tl-overlays__item",i),children:v.jsx("path",{className:"tl-scribble",d:xT(r.points,!1),stroke:t??`var(--color-${r.color})`,fill:"none",strokeWidth:8/e,opacity:n??r.opacity})}):null}function rre({bounds:r,rotation:e}){const t=A.useRef(null);return Fd(t,r.x,r.y,1,e),A.useLayoutEffect(()=>{const n=t.current;n&&(n.style.width=fe(Math.max(1,r.width))+"px",n.style.height=fe(Math.max(1,r.height))+"px")},[r.width,r.height]),v.jsx("div",{ref:t,className:"tl-selection__bg",draggable:!1})}function zxe({bounds:r,rotation:e}){const t=he(),n=A.useRef(null),i=ye("only selected shape",()=>t.getOnlySelectedShape(),[t]),o=i?t.getShapeUtil(i).expandSelectionOutlinePx(i):0;return Fd(n,r==null?void 0:r.x,r==null?void 0:r.y,1,e,{x:-o,y:-o}),r=o instanceof He?r.clone().expand(o).zeroFix():r.clone().expandBy(o).zeroFix(),v.jsx("svg",{ref:n,className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:v.jsx("rect",{className:bt("tl-selection__fg__outline"),width:fe(r.width),height:fe(r.height)})})}const Hxe=()=>v.jsx("div",{className:"tl-shape-error-boundary"}),Wxe=({shape:r,util:e})=>Fm("Indicator: "+r.type,()=>e.indicator(e.editor.store.unsafeGetWithoutCapture(r.id))),Kxe=({editor:r,id:e})=>{const t=ye("shape for indicator",()=>r.store.get(e),[r,e]),{ShapeIndicatorErrorFallback:n}=Gr();return!t||t.isLocked?null:v.jsx(_h,{fallback:n,onError:i=>r.annotateError(i,{origin:"react.shapeIndicator",willCrashApp:!1}),children:v.jsx(Wxe,{shape:t,util:r.getShapeUtil(t)},t.id)})},xD=A.memo(function({shapeId:e,className:t,color:n,hidden:i,opacity:o}){const s=he(),a=A.useRef(null);return Vc("indicator transform",()=>{const c=a.current;if(!c)return;const l=s.getShapePageTransform(e);l&&c.style.setProperty("transform",l.toCssString())},[s,e]),A.useLayoutEffect(()=>{const c=a.current;c&&c.style.setProperty("display",i?"none":"block")},[i]),v.jsx("svg",{ref:a,className:bt("tl-overlays__item",t),children:v.jsx("g",{className:"tl-shape-indicator",stroke:n??"var(--color-selected)",opacity:o,children:v.jsx(Kxe,{editor:s,id:e})})})}),Gxe=()=>v.jsx("circle",{cx:4,cy:4,r:8,strokeWidth:"1",stroke:"red"}),nre=A.memo(function(){const e=he(),t=A.useRef(new Set),n=ye("should display selected ids",()=>{const s=t.current,a=new Set;if(e.isInAny("select.idle","select.brushing","select.scribble_brushing","select.editing_shape","select.pointing_shape","select.pointing_selection","select.pointing_handle")&&!e.getInstanceState().isChangingStyle){const c=e.getSelectedShapeIds();for(const l of c)a.add(l);if(e.isInAny("select.idle","select.editing_shape")){const l=e.getInstanceState();if(l.isHoveringCanvas&&!l.isCoarsePointer){const d=e.getHoveredShapeId();d&&a.add(d)}}}if(s.size!==a.size)return t.current=a,a;for(const c of a)if(!s.has(c))return t.current=a,a;return s},[e]),i=ye("rendering shapes",()=>e.getRenderingShapes(),[e]),{ShapeIndicator:o}=Gr();return o?i.map(({id:s})=>v.jsx(o,{shapeId:s,hidden:!n.has(s)},s+"_indicator")):null});function Vxe({points:r,zoom:e}){const t=2.5/e,n=r.reduce((h,g)=>Math.min(h,g.x),1/0),i=r.reduce((h,g)=>Math.max(h,g.x),-1/0),o=r.reduce((h,g)=>Math.min(h,g.y),1/0),s=r.reduce((h,g)=>Math.max(h,g.y),-1/0),a=r.some(h=>h.x===n&&h.y===o);let c,l,d,f;return a?(c=n,l=o,d=i,f=s):(c=n,l=s,d=i,f=o),v.jsxs("g",{className:"tl-snap-indicator",stroke:"lime",children:[v.jsx("line",{x1:c,y1:l,x2:d,y2:f}),r.map((h,g)=>v.jsx("g",{transform:`translate(${h.x},${h.y})`,children:v.jsx("path",{className:"tl-snap-point",d:`M ${-t},${-t} L ${t},${t} M ${-t},${t} L ${t},${-t}`})},g))]})}function Yxe({gaps:r,direction:e,zoom:t}){const n=3.5/t;let i=[-1/0,1/0],o=null;const s=e==="horizontal";for(const c of r){if(o=Es(i[0],i[1],s?c.startEdge[0].y:c.startEdge[0].x,s?c.startEdge[1].y:c.startEdge[1].x),o)i=o;else continue;if(o=Es(i[0],i[1],s?c.endEdge[0].y:c.endEdge[0].x,s?c.endEdge[1].y:c.endEdge[1].x),o)i=o;else continue}if(i===null)return null;const a=(i[0]+i[1])/2;return v.jsx("g",{className:"tl-snap-indicator",stroke:"cyan",children:r.map(({startEdge:c,endEdge:l},d)=>v.jsx(A.Fragment,{children:s?v.jsxs(v.Fragment,{children:[v.jsx("line",{x1:c[0].x,y1:a-2*n,x2:c[1].x,y2:a+2*n}),v.jsx("line",{x1:l[0].x,y1:a-2*n,x2:l[1].x,y2:a+2*n}),v.jsx("line",{x1:c[0].x,y1:a,x2:l[0].x,y2:a}),v.jsx("line",{x1:(c[0].x+l[0].x)/2,y1:a-n,x2:(c[0].x+l[0].x)/2,y2:a+n})]}):v.jsxs(v.Fragment,{children:[v.jsx("line",{x1:a-2*n,y1:c[0].y,x2:a+2*n,y2:c[1].y}),v.jsx("line",{x1:a-2*n,y1:l[0].y,x2:a+2*n,y2:l[1].y}),v.jsx("line",{x1:a,y1:c[0].y,x2:a,y2:l[0].y}),v.jsx("line",{x1:a-n,y1:(c[0].y+l[0].y)/2,x2:a+n,y2:(c[0].y+l[0].y)/2})]})},d))})}function Xxe({className:r,line:e,zoom:t}){return v.jsx("svg",{className:bt("tl-overlays__item",r),children:e.type==="points"?v.jsx(Vxe,{...e,zoom:t}):e.type==="gaps"?v.jsx(Yxe,{...e,zoom:t}):null})}function _T(){return v.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",children:v.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[v.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),v.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:v.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}const Zxe=()=>null;function ire(r,e){const t=A.useRef(r);return e(r,t.current)?t.current:(t.current=r,r)}const Qxe=(r,e)=>(r??(r=null),e??(e=null),r===e?!0:!r||!e?!1:$J(r,e));function Hc(r){return ire(r,Qxe)}const Jxe=(r,e)=>(r??(r=null),e??(e=null),r===e?!0:!r||!e?!1:WJ(r,e));function Nd(r){return ire(r,Jxe)}const ore=A.createContext(null);function e_e({overrides:r={},children:e}){const t=Nd(r),n=A.useMemo(()=>({Background:zye,SvgDefs:Zxe,Brush:tb,ZoomBrush:tb,CollaboratorBrush:tb,Cursor:yD,CollaboratorCursor:yD,CollaboratorHint:Nxe,CollaboratorShapeIndicator:xD,Grid:$xe,Scribble:SD,SnapIndicator:Xxe,Handles:Bxe,Handle:qxe,CollaboratorScribble:SD,ErrorFallback:are,ShapeErrorFallback:Hxe,ShapeIndicatorErrorFallback:Gxe,Spinner:_T,SelectionBackground:rre,SelectionForeground:zxe,ShapeIndicators:nre,ShapeIndicator:xD,OnTheCanvas:null,InFrontOfTheCanvas:null,Canvas:mxe,LoadingScreen:Uxe,...t}),[t]);return v.jsx(ore.Provider,{value:n,children:e})}function Gr(){const r=A.useContext(ore);if(!r)throw new Error("useEditorComponents must be used inside of <EditorComponentsProvider />");return r}const Wm={openWindow(r,e){window.open(r,e,"noopener noreferrer")},refreshPage(){window.location.reload()},async hardReset(){var r;return await((r=window.__tldraw__hardReset)==null?void 0:r.call(window))}};function sre(){Wm.hardReset()}function t_e(){Wm.refreshPage()}const r_e="https://github.com/tldraw/tldraw/issues/new",are=({error:r,editor:e})=>{const t=A.useRef(null),[n,i]=A.useState(!1),[o,s]=A.useState(!1),[a,c]=A.useState(!1);let l=null;try{l=Gr().Canvas??null}catch{}const d=r instanceof Error?r.message:String(r),f=r instanceof Error?r.stack:null,h=ye("isDarkMode",()=>{try{if(e)return e.user.getIsDarkMode()}catch{}return null},[e]),[g,m]=A.useState(null);A.useLayoutEffect(()=>{var P;h!==null&&m(h);let I=(P=t.current)==null?void 0:P.parentElement,b=!1;for(;I;){if(I.classList.contains("tl-theme__dark")||I.classList.contains("tl-theme__light")){b=!0;break}I=I.parentElement}if(b){m(null);return}typeof window<"u"&&"matchMedia"in window&&m(window.matchMedia("(prefers-color-scheme: dark)").matches)},[h]),A.useEffect(()=>{if(o){const I=e==null?void 0:e.timers.setTimeout(()=>{s(!1)},2e3);return()=>clearTimeout(I)}},[o,e]);const y=()=>{const I=document.createElement("textarea");I.value=f??d,document.body.appendChild(I),I.select(),document.execCommand("copy"),I.remove(),s(!0)},x=()=>{t_e()},_=async()=>{sre()},w=new URL(r_e);return w.searchParams.set("title",d),w.searchParams.set("labels","bug"),w.searchParams.set("body",`Hey, I ran into an error while using tldraw:
93
-
94
- \`\`\`js
95
- ${f??d}
96
- \`\`\`
97
-
98
- My browser: ${navigator.userAgent}`),v.jsxs("div",{ref:t,className:bt("tl-container tl-error-boundary",g===null?"":g?"tl-theme__dark":"tl-theme__light"),children:[v.jsx("div",{className:"tl-error-boundary__overlay"}),e&&v.jsx(hT,{onError:gh,fallback:()=>null,children:v.jsx(vT,{editor:e,children:v.jsx("div",{className:"tl-overlay tl-error-boundary__canvas",children:l?v.jsx(l,{}):null})})}),v.jsx("div",{className:bt("tl-modal","tl-error-boundary__content",{"tl-error-boundary__content__expanded":n&&!a}),children:a?v.jsxs(v.Fragment,{children:[v.jsx("h2",{children:"Are you sure?"}),v.jsx("p",{children:"Resetting your data will delete your drawing and cannot be undone."}),v.jsxs("div",{className:"tl-error-boundary__content__actions",children:[v.jsx("button",{onClick:()=>c(!1),children:"Cancel"}),v.jsx("button",{className:"tl-error-boundary__reset",onClick:_,children:"Reset data"})]})]}):v.jsxs(v.Fragment,{children:[v.jsx("h2",{children:"Something went wrong"}),v.jsx("p",{children:"Please refresh the page to continue."}),v.jsxs("p",{children:["If you keep seeing this screen, you can create a"," ",v.jsx("a",{href:w.toString(),children:"GitHub issue"})," or ask for help on"," ",v.jsx("a",{href:"https://discord.tldraw.com/?utm_source=sdk&utm_medium=organic&utm_campaign=error-screen",children:"Discord"}),". If you are still stuck, you can reset the tldraw data on your machine. This may erase the project you were working on, so try to get help first."]}),n&&v.jsxs(v.Fragment,{children:["Message:",v.jsx("h4",{children:v.jsx("code",{children:d})}),"Stack trace:",v.jsxs("div",{className:"tl-error-boundary__content__error",children:[v.jsx("pre",{children:v.jsx("code",{children:f??d})}),v.jsx("button",{onClick:y,children:o?"Copied!":"Copy"})]})]}),v.jsxs("div",{className:"tl-error-boundary__content__actions",children:[v.jsx("button",{onClick:()=>i(!n),children:n?"Hide details":"Show details"}),v.jsxs("div",{className:"tl-error-boundary__content__actions__group",children:[v.jsx("button",{className:"tl-error-boundary__reset",onClick:()=>c(!0),children:"Reset data"}),v.jsx("button",{className:"tl-error-boundary__refresh",onClick:x,children:"Refresh Page"})]})]})]})})]})},cre="TLDRAW_USER_DATA_v3",lre=nr({id:zt,name:zt.nullable().optional(),color:zt.nullable().optional(),locale:zt.nullable().optional(),animationSpeed:Dt.nullable().optional(),edgeScrollSpeed:Dt.nullable().optional(),colorScheme:Bm("light","dark","system").optional(),isSnapMode:tr.nullable().optional(),isWrapMode:tr.nullable().optional(),isDynamicSizeMode:tr.nullable().optional(),isPasteAtCursorMode:tr.nullable().optional()}),Ga={AddAnimationSpeed:1,AddIsSnapMode:2,MakeFieldsNullable:3,AddEdgeScrollSpeed:4,AddExcalidrawSelectMode:5,AddDynamicSizeMode:6,AllowSystemColorScheme:7,AddPasteAtCursor:8},wT=Math.max(...Object.values(Ga));function n_e(r){r.version<Ga.AddAnimationSpeed&&(r.user.animationSpeed=1),r.version<Ga.AddIsSnapMode&&(r.user.isSnapMode=!1),r.version<Ga.MakeFieldsNullable,r.version<Ga.AddEdgeScrollSpeed&&(r.user.edgeScrollSpeed=1),r.version<Ga.AddExcalidrawSelectMode&&(r.user.isWrapMode=!1),r.version<Ga.AllowSystemColorScheme&&(r.user.isDarkMode===!0?r.user.colorScheme="dark":r.user.isDarkMode===!1&&(r.user.colorScheme="light"),delete r.user.isDarkMode),r.version<Ga.AddDynamicSizeMode&&(r.user.isDynamicSizeMode=!1),r.version<Ga.AddPasteAtCursor&&(r.user.isPasteAtCursorMode=!1),r.version=wT}const OP=["#FF802B","#EC5E41","#F2555A","#F04F88","#E34BA9","#BD54C6","#9D5BD2","#7B66DC","#02B1CC","#11B3A3","#39B178","#55B467"];function ure(){return OP[Math.floor(Math.random()*OP.length)]}function i_e(){var r,e;return typeof window<"u"&&"matchMedia"in window?((e=(r=window.matchMedia)==null?void 0:r.call(window,"(prefers-reduced-motion: reduce)"))==null?void 0:e.matches)??!1:!1}const ia=Object.freeze({name:"New User",locale:Lye(),color:ure(),edgeScrollSpeed:1,animationSpeed:i_e()?0:1,isSnapMode:!1,isWrapMode:!1,isDynamicSizeMode:!1,isPasteAtCursorMode:!1,colorScheme:"light"});function sb(){return{id:Er(),color:ure()}}function dre(r){if(r===null||typeof r!="object"||!("version"in r)||!("user"in r)||typeof r.version!="number")return sb();const e=Kr(r);n_e(e);try{return lre.validate(e.user)}catch{return sb()}}function o_e(){const r=JSON.parse(FC(cre)||"null")??null;return dre(r)}const Km=xn("globalUserData",null);function s_e(){NC(cre,JSON.stringify({version:wT,user:Km.get()}))}function fre(r){lre.validate(r),Km.set(r),s_e(),a_e()}const gd=typeof BroadcastChannel<"u"?new BroadcastChannel("tldraw-user-sync"):null;gd==null||gd.addEventListener("message",r=>{const e=r.data;(e==null?void 0:e.type)===pre&&(e==null?void 0:e.origin)!==hre()&&Km.set(dre(e.data))});let ab=null;function hre(){return ab===null&&(ab=Er()),ab}const pre="tldraw-user-preferences-change";function a_e(){gd==null||gd.postMessage({type:pre,origin:hre(),data:{user:gre(),version:wT}})}function gre(){let r=Km.get();return r||(r=o_e(),fre(r)),r}const c_e=Te("defaultLocalStorageUserPrefs",()=>gre());function vre(r={}){return{userPreferences:r.userPreferences??c_e,setUserPreferences:r.setUserPreferences??fre}}var _D={},wD={},cb={},lb,bD;function Bo(){if(bD)return lb;bD=1;var r=Ie();return lb=r([].slice),lb}var ED;function bT(){if(ED)return cb;ED=1;var r=Ci(),e=jn(),t=cu().f,n=Bo(),i=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],o=function(s){try{return t(s)}catch{return n(i)}};return cb.f=function(a){return i&&r(a)==="Window"?o(a):t(e(a))},cb}var ub,ID;function Yr(){if(ID)return ub;ID=1;var r=Am(),e=Or();return ub=function(t,n,i){return i.get&&r(i.get,n,{getter:!0}),i.set&&r(i.set,n,{setter:!0}),e.f(t,n,i)},ub}var db={},PD;function mre(){if(PD)return db;PD=1;var r=Tt();return db.f=r,db}var fb,CD;function ET(){if(CD)return fb;CD=1;var r=Xe();return fb=r,fb}var hb,TD;function an(){if(TD)return hb;TD=1;var r=ET(),e=Kt(),t=mre(),n=Or().f;return hb=function(i){var o=r.Symbol||(r.Symbol={});e(o,i)||n(o,i,{value:t.f(i)})},hb}var pb,AD;function yre(){if(AD)return pb;AD=1;var r=Qe(),e=Mt(),t=Tt(),n=wr();return pb=function(){var i=e("Symbol"),o=i&&i.prototype,s=o&&o.valueOf,a=t("toPrimitive");o&&!o[a]&&n(o,a,function(c){return r(s,this)},{arity:1})},pb}var gb,RD;function yo(){if(RD)return gb;RD=1;var r=Or().f,e=Kt(),t=Tt(),n=t("toStringTag");return gb=function(i,o,s){i&&!s&&(i=i.prototype),i&&!e(i,n)&&r(i,n,{configurable:!0,value:o})},gb}var vb,kD;function In(){if(kD)return vb;kD=1;var r=Ar(),e=Ie(),t=ol(),n=Zt(),i=sr(),o=qh(),s=e([].push),a=function(c){var l=c===1,d=c===2,f=c===3,h=c===4,g=c===6,m=c===7,y=c===5||g;return function(x,_,w,I){for(var b=n(x),P=t(b),C=i(P),k=r(_,w),O=0,L=I||o,j=l?L(x,C):d||m?L(x,0):void 0,F,$;C>O;O++)if((y||O in P)&&(F=P[O],$=k(F,O,b),c))if(l)j[O]=$;else if($)switch(c){case 3:return!0;case 5:return F;case 6:return O;case 2:s(j,F)}else switch(c){case 4:return!1;case 7:s(j,F)}return g?-1:f||h?h:j}};return vb={forEach:a(0),map:a(1),filter:a(2),some:a(3),every:a(4),find:a(5),findIndex:a(6),filterReject:a(7)},vb}var OD;function l_e(){if(OD)return wD;OD=1;var r=H(),e=Xe(),t=Qe(),n=Ie(),i=Xt(),o=Et(),s=ou(),a=Fe(),c=Kt(),l=Ti(),d=Ze(),f=jn(),h=lc(),g=Nt(),m=No(),y=En(),x=Md(),_=cu(),w=bT(),I=Rm(),b=ni(),P=Or(),C=zC(),k=bm(),O=wr(),L=Yr(),j=al(),F=Tm(),$=Lh(),D=au(),N=Tt(),B=mre(),W=an(),G=yre(),z=yo(),V=_r(),J=In().forEach,K=F("hidden"),Z="Symbol",ee="prototype",re=V.set,te=V.getterFor(Z),le=Object[ee],ge=e.Symbol,se=ge&&ge[ee],ce=e.RangeError,_e=e.TypeError,Le=e.QObject,Ge=b.f,qe=P.f,mt=w.f,St=k.f,et=n([].push),ct=j("symbols"),At=j("op-symbols"),_t=j("wks"),ut=!Le||!Le[ee]||!Le[ee].findChild,Ae=function(oe,me,we){var Oe=Ge(le,me);Oe&&delete le[me],qe(oe,me,we),Oe&&oe!==le&&qe(le,me,Oe)},ze=o&&a(function(){return y(qe({},"a",{get:function(){return qe(this,"a",{value:7}).a}})).a!==7})?Ae:qe,be=function(oe,me){var we=ct[oe]=y(se);return re(we,{type:Z,tag:oe,description:me}),o||(we.description=me),we},it=function(me,we,Oe){me===le&&it(At,we,Oe),d(me);var Ee=h(we);return d(Oe),c(ct,Ee)?(Oe.enumerable?(c(me,K)&&me[K][Ee]&&(me[K][Ee]=!1),Oe=y(Oe,{enumerable:m(0,!1)})):(c(me,K)||qe(me,K,m(1,y(null))),me[K][Ee]=!0),ze(me,Ee,Oe)):qe(me,Ee,Oe)},st=function(me,we){d(me);var Oe=f(we),Ee=x(Oe).concat(Y(Oe));return J(Ee,function(dt){(!o||t(Ye,Oe,dt))&&it(me,dt,Oe[dt])}),me},Je=function(me,we){return we===void 0?y(me):st(y(me),we)},Ye=function(me){var we=h(me),Oe=t(St,this,we);return this===le&&c(ct,we)&&!c(At,we)?!1:Oe||!c(this,we)||!c(ct,we)||c(this,K)&&this[K][we]?Oe:!0},cr=function(me,we){var Oe=f(me),Ee=h(we);if(!(Oe===le&&c(ct,Ee)&&!c(At,Ee))){var dt=Ge(Oe,Ee);return dt&&c(ct,Ee)&&!(c(Oe,K)&&Oe[K][Ee])&&(dt.enumerable=!0),dt}},Sr=function(me){var we=mt(f(me)),Oe=[];return J(we,function(Ee){!c(ct,Ee)&&!c($,Ee)&&et(Oe,Ee)}),Oe},Y=function(oe){var me=oe===le,we=mt(me?At:f(oe)),Oe=[];return J(we,function(Ee){c(ct,Ee)&&(!me||c(le,Ee))&&et(Oe,ct[Ee])}),Oe};return s||(ge=function(){if(l(se,this))throw new _e("Symbol is not a constructor");var me=!arguments.length||arguments[0]===void 0?void 0:g(arguments[0]),we=D(me),Oe=function(Ee){var dt=this===void 0?e:this;dt===le&&t(Oe,At,Ee),c(dt,K)&&c(dt[K],we)&&(dt[K][we]=!1);var $t=m(1,Ee);try{ze(dt,we,$t)}catch(Pe){if(!(Pe instanceof ce))throw Pe;Ae(dt,we,$t)}};return o&&ut&&ze(le,we,{configurable:!0,set:Oe}),be(we,me)},se=ge[ee],O(se,"toString",function(){return te(this).tag}),O(ge,"withoutSetter",function(oe){return be(D(oe),oe)}),k.f=Ye,P.f=it,C.f=st,b.f=cr,_.f=w.f=Sr,I.f=Y,B.f=function(oe){return be(N(oe),oe)},o&&(L(se,"description",{configurable:!0,get:function(){return te(this).description}}),i||O(le,"propertyIsEnumerable",Ye,{unsafe:!0}))),r({global:!0,constructor:!0,wrap:!0,forced:!s,sham:!s},{Symbol:ge}),J(x(_t),function(oe){W(oe)}),r({target:Z,stat:!0,forced:!s},{useSetter:function(){ut=!0},useSimple:function(){ut=!1}}),r({target:"Object",stat:!0,forced:!s,sham:!o},{create:Je,defineProperty:it,defineProperties:st,getOwnPropertyDescriptor:cr}),r({target:"Object",stat:!0,forced:!s},{getOwnPropertyNames:Sr}),G(),z(ge,Z),$[K]=!0,wD}var MD={},mb,jD;function Sre(){if(jD)return mb;jD=1;var r=ou();return mb=r&&!!Symbol.for&&!!Symbol.keyFor,mb}var DD;function u_e(){if(DD)return MD;DD=1;var r=H(),e=Mt(),t=Kt(),n=Nt(),i=al(),o=Sre(),s=i("string-to-symbol-registry"),a=i("symbol-to-string-registry");return r({target:"Symbol",stat:!0,forced:!o},{for:function(c){var l=n(c);if(t(s,l))return s[l];var d=e("Symbol")(l);return s[l]=d,a[d]=l,d}}),MD}var LD={},FD;function d_e(){if(FD)return LD;FD=1;var r=H(),e=Kt(),t=sl(),n=su(),i=al(),o=Sre(),s=i("symbol-to-string-registry");return r({target:"Symbol",stat:!0,forced:!o},{keyFor:function(c){if(!t(c))throw new TypeError(n(c)+" is not a symbol");if(e(s,c))return s[c]}}),LD}var ND={},yb,$D;function xre(){if($D)return yb;$D=1;var r=Ie(),e=Ia(),t=Ut(),n=Ci(),i=Nt(),o=r([].push);return yb=function(s){if(t(s))return s;if(e(s)){for(var a=s.length,c=[],l=0;l<a;l++){var d=s[l];typeof d=="string"?o(c,d):(typeof d=="number"||n(d)==="Number"||n(d)==="String")&&o(c,i(d))}var f=c.length,h=!0;return function(g,m){if(h)return h=!1,m;if(e(this))return m;for(var y=0;y<f;y++)if(c[y]===g)return m}}},yb}var qD;function _re(){if(qD)return ND;qD=1;var r=H(),e=Mt(),t=zi(),n=Qe(),i=Ie(),o=Fe(),s=Ut(),a=sl(),c=Bo(),l=xre(),d=ou(),f=String,h=e("JSON","stringify"),g=i(/./.exec),m=i("".charAt),y=i("".charCodeAt),x=i("".replace),_=i(1 .toString),w=/[\uD800-\uDFFF]/g,I=/^[\uD800-\uDBFF]$/,b=/^[\uDC00-\uDFFF]$/,P=!d||o(function(){var L=e("Symbol")("stringify detection");return h([L])!=="[null]"||h({a:L})!=="{}"||h(Object(L))!=="{}"}),C=o(function(){return h("\uDF06\uD834")!=='"\\udf06\\ud834"'||h("\uDEAD")!=='"\\udead"'}),k=function(L,j){var F=c(arguments),$=l(j);if(!(!s($)&&(L===void 0||a(L))))return F[1]=function(D,N){if(s($)&&(N=n($,this,f(D),N)),!a(N))return N},t(h,null,F)},O=function(L,j,F){var $=m(F,j-1),D=m(F,j+1);return g(I,L)&&!g(b,D)||g(b,L)&&!g(I,$)?"\\u"+_(y(L,0),16):L};return h&&r({target:"JSON",stat:!0,arity:3,forced:P||C},{stringify:function(j,F,$){var D=c(arguments),N=t(P?k:h,null,D);return C&&typeof N=="string"?x(N,w,O):N}}),ND}var BD={},UD;function f_e(){if(UD)return BD;UD=1;var r=H(),e=ou(),t=Fe(),n=Rm(),i=Zt(),o=!e||t(function(){n.f(1)});return r({target:"Object",stat:!0,forced:o},{getOwnPropertySymbols:function(a){var c=n.f;return c?c(i(a)):[]}}),BD}var zD;function h_e(){return zD||(zD=1,l_e(),u_e(),d_e(),_re(),f_e()),_D}var HD={},WD;function p_e(){if(WD)return HD;WD=1;var r=H(),e=Et(),t=Xe(),n=Ie(),i=Kt(),o=Ut(),s=Ti(),a=Nt(),c=Yr(),l=Od(),d=t.Symbol,f=d&&d.prototype;if(e&&o(d)&&(!("description"in f)||d().description!==void 0)){var h={},g=function(){var P=arguments.length<1||arguments[0]===void 0?void 0:a(arguments[0]),C=s(f,this)?new d(P):P===void 0?d():d(P);return P===""&&(h[C]=!0),C};l(g,d),g.prototype=f,f.constructor=g;var m=String(d("description detection"))==="Symbol(description detection)",y=n(f.valueOf),x=n(f.toString),_=/^Symbol\((.*)\)[^)]+$/,w=n("".replace),I=n("".slice);c(f,"description",{configurable:!0,get:function(){var P=y(this);if(i(h,P))return"";var C=x(P),k=m?I(C,7,-1):w(C,_,"$1");return k===""?void 0:k}}),r({global:!0,constructor:!0,forced:!0},{Symbol:g})}return HD}var KD={},GD;function g_e(){if(GD)return KD;GD=1;var r=an();return r("asyncIterator"),KD}var VD={},YD;function v_e(){if(YD)return VD;YD=1;var r=an();return r("hasInstance"),VD}var XD={},ZD;function m_e(){if(ZD)return XD;ZD=1;var r=an();return r("isConcatSpreadable"),XD}var QD={},JD;function y_e(){if(JD)return QD;JD=1;var r=an();return r("iterator"),QD}var eL={},tL;function S_e(){if(tL)return eL;tL=1;var r=an();return r("match"),eL}var rL={},nL;function x_e(){if(nL)return rL;nL=1;var r=an();return r("matchAll"),rL}var iL={},oL;function __e(){if(oL)return iL;oL=1;var r=an();return r("replace"),iL}var sL={},aL;function w_e(){if(aL)return sL;aL=1;var r=an();return r("search"),sL}var cL={},lL;function b_e(){if(lL)return cL;lL=1;var r=an();return r("species"),cL}var uL={},dL;function E_e(){if(dL)return uL;dL=1;var r=an();return r("split"),uL}var fL={},hL;function I_e(){if(hL)return fL;hL=1;var r=an(),e=yre();return r("toPrimitive"),e(),fL}var pL={},gL;function P_e(){if(gL)return pL;gL=1;var r=Mt(),e=an(),t=yo();return e("toStringTag"),t(r("Symbol"),"Symbol"),pL}var vL={},mL;function C_e(){if(mL)return vL;mL=1;var r=an();return r("unscopables"),vL}var yL={},Sb,SL;function Gm(){if(SL)return Sb;SL=1;var r=Ie(),e=jt();return Sb=function(t,n,i){try{return r(e(Object.getOwnPropertyDescriptor(t,n)[i]))}catch{}},Sb}var xb,xL;function wre(){if(xL)return xb;xL=1;var r=Lt();return xb=function(e){return r(e)||e===null},xb}var _b,_L;function bre(){if(_L)return _b;_L=1;var r=wre(),e=String,t=TypeError;return _b=function(n){if(r(n))return n;throw new t("Can't set "+e(n)+" as a prototype")},_b}var wb,wL;function Fs(){if(wL)return wb;wL=1;var r=Gm(),e=Lt(),t=qr(),n=bre();return wb=Object.setPrototypeOf||("__proto__"in{}?function(){var i=!1,o={},s;try{s=r(Object.prototype,"__proto__","set"),s(o,[]),i=o instanceof Array}catch{}return function(c,l){return t(c),n(l),e(c)&&(i?s(c,l):c.__proto__=l),c}}():void 0),wb}var bb,bL;function Ere(){if(bL)return bb;bL=1;var r=Or().f;return bb=function(e,t,n){n in e||r(e,n,{configurable:!0,get:function(){return t[n]},set:function(i){t[n]=i}})},bb}var Eb,EL;function du(){if(EL)return Eb;EL=1;var r=Ut(),e=Lt(),t=Fs();return Eb=function(n,i,o){var s,a;return t&&r(s=i.constructor)&&s!==o&&e(a=s.prototype)&&a!==o.prototype&&t(n,a),n},Eb}var Ib,IL;function $d(){if(IL)return Ib;IL=1;var r=Nt();return Ib=function(e,t){return e===void 0?arguments.length<2?"":t:r(e)},Ib}var Pb,PL;function Ire(){if(PL)return Pb;PL=1;var r=Lt(),e=Dn();return Pb=function(t,n){r(n)&&"cause"in n&&e(t,"cause",n.cause)},Pb}var Cb,CL;function IT(){if(CL)return Cb;CL=1;var r=Ie(),e=Error,t=r("".replace),n=function(s){return String(new e(s).stack)}("zxcasd"),i=/\n\s*at [^:]*:[^\n]*/,o=i.test(n);return Cb=function(s,a){if(o&&typeof s=="string"&&!e.prepareStackTrace)for(;a--;)s=t(s,i,"");return s},Cb}var Tb,TL;function Pre(){if(TL)return Tb;TL=1;var r=Fe(),e=No();return Tb=!r(function(){var t=new Error("a");return"stack"in t?(Object.defineProperty(t,"stack",e(1,7)),t.stack!==7):!0}),Tb}var Ab,AL;function PT(){if(AL)return Ab;AL=1;var r=Dn(),e=IT(),t=Pre(),n=Error.captureStackTrace;return Ab=function(i,o,s,a){t&&(n?n(i,o):r(i,"stack",e(s,a)))},Ab}var Rb,RL;function Cre(){if(RL)return Rb;RL=1;var r=Mt(),e=Kt(),t=Dn(),n=Ti(),i=Fs(),o=Od(),s=Ere(),a=du(),c=$d(),l=Ire(),d=PT(),f=Et(),h=Xt();return Rb=function(g,m,y,x){var _="stackTraceLimit",w=x?2:1,I=g.split("."),b=I[I.length-1],P=r.apply(null,I);if(P){var C=P.prototype;if(!h&&e(C,"cause")&&delete C.cause,!y)return P;var k=r("Error"),O=m(function(L,j){var F=c(x?j:L,void 0),$=x?new P(L):new P;return F!==void 0&&t($,"message",F),d($,O,$.stack,2),this&&n(C,this)&&a($,this,O),arguments.length>w&&l($,arguments[w]),$});if(O.prototype=C,b!=="Error"?i?i(O,k):o(O,k,{name:!0}):f&&_ in P&&(s(O,P,_),s(O,P,"prepareStackTrace")),o(O,P),!h)try{C.name!==b&&t(C,"name",b),C.constructor=O}catch{}return O}},Rb}var kL;function T_e(){if(kL)return yL;kL=1;var r=H(),e=Xe(),t=zi(),n=Cre(),i="WebAssembly",o=e[i],s=new Error("e",{cause:7}).cause!==7,a=function(l,d){var f={};f[l]=n(l,d,s),r({global:!0,constructor:!0,arity:1,forced:s},f)},c=function(l,d){if(o&&o[l]){var f={};f[l]=n(i+"."+l,d,s),r({target:i,stat:!0,constructor:!0,arity:1,forced:s},f)}};return a("Error",function(l){return function(f){return t(l,this,arguments)}}),a("EvalError",function(l){return function(f){return t(l,this,arguments)}}),a("RangeError",function(l){return function(f){return t(l,this,arguments)}}),a("ReferenceError",function(l){return function(f){return t(l,this,arguments)}}),a("SyntaxError",function(l){return function(f){return t(l,this,arguments)}}),a("TypeError",function(l){return function(f){return t(l,this,arguments)}}),a("URIError",function(l){return function(f){return t(l,this,arguments)}}),c("CompileError",function(l){return function(f){return t(l,this,arguments)}}),c("LinkError",function(l){return function(f){return t(l,this,arguments)}}),c("RuntimeError",function(l){return function(f){return t(l,this,arguments)}}),yL}var OL={},kb,ML;function Tre(){if(ML)return kb;ML=1;var r=Et(),e=Fe(),t=Ze(),n=$d(),i=Error.prototype.toString,o=e(function(){if(r){var s=Object.create(Object.defineProperty({},"name",{get:function(){return this===s}}));if(i.call(s)!=="true")return!0}return i.call({message:1,name:2})!=="2: 1"||i.call({})!=="Error"});return kb=o?function(){var a=t(this),c=n(a.name,"Error"),l=n(a.message);return c?l?c+": "+l:c:l}:i,kb}var jL;function A_e(){if(jL)return OL;jL=1;var r=wr(),e=Tre(),t=Error.prototype;return t.toString!==e&&r(t,"toString",e),OL}var DL={},LL={},Ob,FL;function CT(){if(FL)return Ob;FL=1;var r=Fe();return Ob=!r(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),Ob}var Mb,NL;function Fn(){if(NL)return Mb;NL=1;var r=Kt(),e=Ut(),t=Zt(),n=Tm(),i=CT(),o=n("IE_PROTO"),s=Object,a=s.prototype;return Mb=i?s.getPrototypeOf:function(c){var l=t(c);if(r(l,o))return l[o];var d=l.constructor;return e(d)&&l instanceof d?d.prototype:l instanceof s?a:null},Mb}var jb,$L;function qd(){return $L||($L=1,jb={}),jb}var Db,qL;function TT(){if(qL)return Db;qL=1;var r=Tt(),e=qd(),t=r("iterator"),n=Array.prototype;return Db=function(i){return i!==void 0&&(e.Array===i||n[t]===i)},Db}var Lb,BL;function dc(){if(BL)return Lb;BL=1;var r=vo(),e=bn(),t=Mn(),n=qd(),i=Tt(),o=i("iterator");return Lb=function(s){if(!t(s))return e(s,o)||e(s,"@@iterator")||n[r(s)]},Lb}var Fb,UL;function fu(){if(UL)return Fb;UL=1;var r=Qe(),e=jt(),t=Ze(),n=su(),i=dc(),o=TypeError;return Fb=function(s,a){var c=arguments.length<2?i(s):a;if(e(c))return t(r(c,s));throw new o(n(s)+" is not iterable")},Fb}var Nb,zL;function dl(){if(zL)return Nb;zL=1;var r=Qe(),e=Ze(),t=bn();return Nb=function(n,i,o){var s,a;e(n);try{if(s=t(n,"return"),!s){if(i==="throw")throw o;return o}s=r(s,n)}catch(c){a=!0,s=c}if(i==="throw")throw o;if(a)throw s;return e(s),o},Nb}var $b,HL;function cn(){if(HL)return $b;HL=1;var r=Ar(),e=Qe(),t=Ze(),n=su(),i=TT(),o=sr(),s=Ti(),a=fu(),c=dc(),l=dl(),d=TypeError,f=function(g,m){this.stopped=g,this.result=m},h=f.prototype;return $b=function(g,m,y){var x=y&&y.that,_=!!(y&&y.AS_ENTRIES),w=!!(y&&y.IS_RECORD),I=!!(y&&y.IS_ITERATOR),b=!!(y&&y.INTERRUPTED),P=r(m,x),C,k,O,L,j,F,$,D=function(B){return C&&l(C,"normal",B),new f(!0,B)},N=function(B){return _?(t(B),b?P(B[0],B[1],D):P(B[0],B[1])):b?P(B,D):P(B)};if(w)C=g.iterator;else if(I)C=g;else{if(k=c(g),!k)throw new d(n(g)+" is not iterable");if(i(k)){for(O=0,L=o(g);L>O;O++)if(j=N(g[O]),j&&s(h,j))return j;return new f(!1)}C=a(g,k)}for(F=w?g.next:C.next;!($=e(F,C)).done;){try{j=N($.value)}catch(B){l(C,"throw",B)}if(typeof j=="object"&&j&&s(h,j))return j}return new f(!1)},$b}var WL;function R_e(){if(WL)return LL;WL=1;var r=H(),e=Ti(),t=Fn(),n=Fs(),i=Od(),o=En(),s=Dn(),a=No(),c=Ire(),l=PT(),d=cn(),f=$d(),h=Tt(),g=h("toStringTag"),m=Error,y=[].push,x=function(I,b){var P=e(_,this),C;n?C=n(new m,P?t(this):_):(C=P?this:o(_),s(C,g,"Error")),b!==void 0&&s(C,"message",f(b)),l(C,x,C.stack,1),arguments.length>2&&c(C,arguments[2]);var k=[];return d(I,y,{that:k}),s(C,"errors",k),C};n?n(x,m):i(x,m,{name:!0});var _=x.prototype=o(m.prototype,{constructor:a(1,x),message:a(1,""),name:a(1,"AggregateError")});return r({global:!0,constructor:!0,arity:2},{AggregateError:x}),LL}var KL;function Are(){return KL||(KL=1,R_e()),DL}var GL={},VL;function k_e(){if(VL)return GL;VL=1;var r=H(),e=Mt(),t=zi(),n=Fe(),i=Cre(),o="AggregateError",s=e(o),a=!n(function(){return s([1]).errors[0]!==1})&&n(function(){return s([1],o,{cause:7}).cause!==7});return r({global:!0,constructor:!0,arity:2,forced:a},{AggregateError:i(o,function(c){return function(d,f){return t(c,this,arguments)}},a,!0)}),GL}var YL={},qb,XL;function Ns(){if(XL)return qb;XL=1;var r=Et(),e=Or(),t=No();return qb=function(n,i,o){r?e.f(n,i,t(0,o)):n[i]=o},qb}var Bb,ZL;function Vh(){if(ZL)return Bb;ZL=1;var r=Fe(),e=Tt(),t=ba(),n=e("species");return Bb=function(i){return t>=51||!r(function(){var o=[],s=o.constructor={};return s[n]=function(){return{foo:1}},o[i](Boolean).foo!==1})},Bb}var QL;function O_e(){if(QL)return YL;QL=1;var r=H(),e=Fe(),t=Ia(),n=Lt(),i=Zt(),o=sr(),s=lu(),a=Ns(),c=qh(),l=Vh(),d=Tt(),f=ba(),h=d("isConcatSpreadable"),g=f>=51||!e(function(){var x=[];return x[h]=!1,x.concat()[0]!==x}),m=function(x){if(!n(x))return!1;var _=x[h];return _!==void 0?!!_:t(x)},y=!g||!l("concat");return r({target:"Array",proto:!0,arity:1,forced:y},{concat:function(_){var w=i(this),I=c(w,0),b=0,P,C,k,O,L;for(P=-1,k=arguments.length;P<k;P++)if(L=P===-1?w:arguments[P],m(L))for(O=o(L),s(b+O),C=0;C<O;C++,b++)C in L&&a(I,b,L[C]);else s(b+1),a(I,b++,L);return I.length=b,I}}),YL}var JL={},Ub,eF;function Vm(){if(eF)return Ub;eF=1;var r=su(),e=TypeError;return Ub=function(t,n){if(!delete t[n])throw new e("Cannot delete property "+r(n)+" of "+r(t))},Ub}var zb,tF;function Rre(){if(tF)return zb;tF=1;var r=Zt(),e=Ea(),t=sr(),n=Vm(),i=Math.min;return zb=[].copyWithin||function(s,a){var c=r(this),l=t(c),d=e(s,l),f=e(a,l),h=arguments.length>2?arguments[2]:void 0,g=i((h===void 0?l:e(h,l))-f,l-d),m=1;for(f<d&&d<f+g&&(m=-1,f+=g-1,d+=g-1);g-- >0;)f in c?c[d]=c[f]:n(c,d),d+=m,f+=m;return c},zb}var rF;function M_e(){if(rF)return JL;rF=1;var r=H(),e=Rre(),t=sn();return r({target:"Array",proto:!0},{copyWithin:e}),t("copyWithin"),JL}var nF={},Hb,iF;function $s(){if(iF)return Hb;iF=1;var r=Fe();return Hb=function(e,t){var n=[][e];return!!n&&r(function(){n.call(null,t||function(){return 1},1)})},Hb}var oF;function j_e(){if(oF)return nF;oF=1;var r=H(),e=In().every,t=$s(),n=t("every");return r({target:"Array",proto:!0,forced:!n},{every:function(o){return e(this,o,arguments.length>1?arguments[1]:void 0)}}),nF}var sF={},Wb,aF;function AT(){if(aF)return Wb;aF=1;var r=Zt(),e=Ea(),t=sr();return Wb=function(i){for(var o=r(this),s=t(o),a=arguments.length,c=e(a>1?arguments[1]:void 0,s),l=a>2?arguments[2]:void 0,d=l===void 0?s:e(l,s);d>c;)o[c++]=i;return o},Wb}var cF;function D_e(){if(cF)return sF;cF=1;var r=H(),e=AT(),t=sn();return r({target:"Array",proto:!0},{fill:e}),t("fill"),sF}var lF={},uF;function L_e(){if(uF)return lF;uF=1;var r=H(),e=In().filter,t=Vh(),n=t("filter");return r({target:"Array",proto:!0,forced:!n},{filter:function(o){return e(this,o,arguments.length>1?arguments[1]:void 0)}}),lF}var dF={},fF;function F_e(){if(fF)return dF;fF=1;var r=H(),e=In().find,t=sn(),n="find",i=!0;return n in[]&&Array(1)[n](function(){i=!1}),r({target:"Array",proto:!0,forced:i},{find:function(s){return e(this,s,arguments.length>1?arguments[1]:void 0)}}),t(n),dF}var hF={},pF;function N_e(){if(pF)return hF;pF=1;var r=H(),e=In().findIndex,t=sn(),n="findIndex",i=!0;return n in[]&&Array(1)[n](function(){i=!1}),r({target:"Array",proto:!0,forced:i},{findIndex:function(s){return e(this,s,arguments.length>1?arguments[1]:void 0)}}),t(n),hF}var gF={},Kb,vF;function Ym(){if(vF)return Kb;vF=1;var r=Ar(),e=ol(),t=Zt(),n=sr(),i=function(o){var s=o===1;return function(a,c,l){for(var d=t(a),f=e(d),h=n(f),g=r(c,l),m,y;h-- >0;)if(m=f[h],y=g(m,h,d),y)switch(o){case 0:return m;case 1:return h}return s?-1:void 0}};return Kb={findLast:i(0),findLastIndex:i(1)},Kb}var mF;function kre(){if(mF)return gF;mF=1;var r=H(),e=Ym().findLast,t=sn();return r({target:"Array",proto:!0},{findLast:function(i){return e(this,i,arguments.length>1?arguments[1]:void 0)}}),t("findLast"),gF}var yF={},SF;function Ore(){if(SF)return yF;SF=1;var r=H(),e=Ym().findLastIndex,t=sn();return r({target:"Array",proto:!0},{findLastIndex:function(i){return e(this,i,arguments.length>1?arguments[1]:void 0)}}),t("findLastIndex"),yF}var xF={},Gb,_F;function Mre(){if(_F)return Gb;_F=1;var r=In().forEach,e=$s(),t=e("forEach");return Gb=t?[].forEach:function(i){return r(this,i,arguments.length>1?arguments[1]:void 0)},Gb}var wF;function $_e(){if(wF)return xF;wF=1;var r=H(),e=Mre();return r({target:"Array",proto:!0,forced:[].forEach!==e},{forEach:e}),xF}var bF={},Vb,EF;function RT(){if(EF)return Vb;EF=1;var r=Ze(),e=dl();return Vb=function(t,n,i,o){try{return o?n(r(i)[0],i[1]):n(i)}catch(s){e(t,"throw",s)}},Vb}var Yb,IF;function jre(){if(IF)return Yb;IF=1;var r=Ar(),e=Qe(),t=Zt(),n=RT(),i=TT(),o=Pa(),s=sr(),a=Ns(),c=fu(),l=dc(),d=Array;return Yb=function(h){var g=t(h),m=o(this),y=arguments.length,x=y>1?arguments[1]:void 0,_=x!==void 0;_&&(x=r(x,y>2?arguments[2]:void 0));var w=l(g),I=0,b,P,C,k,O,L;if(w&&!(this===d&&i(w)))for(P=m?new this:[],k=c(g,w),O=k.next;!(C=e(O,k)).done;I++)L=_?n(k,x,[C.value,I],!0):C.value,a(P,I,L);else for(b=s(g),P=m?new this(b):d(b);b>I;I++)L=_?x(g[I],I):g[I],a(P,I,L);return P.length=I,P},Yb}var Xb,PF;function Xm(){if(PF)return Xb;PF=1;var r=Tt(),e=r("iterator"),t=!1;try{var n=0,i={next:function(){return{done:!!n++}},return:function(){t=!0}};i[e]=function(){return this},Array.from(i,function(){throw 2})}catch{}return Xb=function(o,s){try{if(!s&&!t)return!1}catch{return!1}var a=!1;try{var c={};c[e]=function(){return{next:function(){return{done:a=!0}}}},o(c)}catch{}return a},Xb}var CF;function q_e(){if(CF)return bF;CF=1;var r=H(),e=jre(),t=Xm(),n=!t(function(i){Array.from(i)});return r({target:"Array",stat:!0,forced:n},{from:e}),bF}var TF={},AF;function B_e(){if(AF)return TF;AF=1;var r=H(),e=Fh().includes,t=Fe(),n=sn(),i=t(function(){return!Array(1).includes()});return r({target:"Array",proto:!0,forced:i},{includes:function(s){return e(this,s,arguments.length>1?arguments[1]:void 0)}}),n("includes"),TF}var RF={},kF;function U_e(){if(kF)return RF;kF=1;var r=H(),e=uu(),t=Fh().indexOf,n=$s(),i=e([].indexOf),o=!!i&&1/i([1],1,-0)<0,s=o||!n("indexOf");return r({target:"Array",proto:!0,forced:s},{indexOf:function(c){var l=arguments.length>1?arguments[1]:void 0;return o?i(this,c,l)||0:t(this,c,l)}}),RF}var OF={},MF;function z_e(){if(MF)return OF;MF=1;var r=H(),e=Ia();return r({target:"Array",stat:!0},{isArray:e}),OF}var Zb,jF;function Bd(){if(jF)return Zb;jF=1;var r=Fe(),e=Ut(),t=Lt(),n=En(),i=Fn(),o=wr(),s=Tt(),a=Xt(),c=s("iterator"),l=!1,d,f,h;[].keys&&(h=[].keys(),"next"in h?(f=i(i(h)),f!==Object.prototype&&(d=f)):l=!0);var g=!t(d)||r(function(){var m={};return d[c].call(m)!==m});return g?d={}:a&&(d=n(d)),e(d[c])||o(d,c,function(){return this}),Zb={IteratorPrototype:d,BUGGY_SAFARI_ITERATORS:l},Zb}var Qb,DF;function hu(){if(DF)return Qb;DF=1;var r=Bd().IteratorPrototype,e=En(),t=No(),n=yo(),i=qd(),o=function(){return this};return Qb=function(s,a,c,l){var d=a+" Iterator";return s.prototype=e(r,{next:t(+!l,c)}),n(s,d,!1,!0),i[d]=o,s},Qb}var Jb,LF;function kT(){if(LF)return Jb;LF=1;var r=H(),e=Qe(),t=Xt(),n=kd(),i=Ut(),o=hu(),s=Fn(),a=Fs(),c=yo(),l=Dn(),d=wr(),f=Tt(),h=qd(),g=Bd(),m=n.PROPER,y=n.CONFIGURABLE,x=g.IteratorPrototype,_=g.BUGGY_SAFARI_ITERATORS,w=f("iterator"),I="keys",b="values",P="entries",C=function(){return this};return Jb=function(k,O,L,j,F,$,D){o(L,O,j);var N=function(re){if(re===F&&V)return V;if(!_&&re&&re in G)return G[re];switch(re){case I:return function(){return new L(this,re)};case b:return function(){return new L(this,re)};case P:return function(){return new L(this,re)}}return function(){return new L(this)}},B=O+" Iterator",W=!1,G=k.prototype,z=G[w]||G["@@iterator"]||F&&G[F],V=!_&&z||N(F),J=O==="Array"&&G.entries||z,K,Z,ee;if(J&&(K=s(J.call(new k)),K!==Object.prototype&&K.next&&(!t&&s(K)!==x&&(a?a(K,x):i(K[w])||d(K,w,C)),c(K,B,!0,!0),t&&(h[B]=C))),m&&F===b&&z&&z.name!==b&&(!t&&y?l(G,"name",b):(W=!0,V=function(){return e(z,this)})),F)if(Z={values:N(b),keys:$?V:N(I),entries:N(P)},D)for(ee in Z)(_||W||!(ee in G))&&d(G,ee,Z[ee]);else r({target:O,proto:!0,forced:_||W},Z);return(!t||D)&&G[w]!==V&&d(G,w,V,{name:F}),h[O]=V,Z},Jb}var e0,FF;function Hn(){return FF||(FF=1,e0=function(r,e){return{value:r,done:e}}),e0}var t0,NF;function Zm(){if(NF)return t0;NF=1;var r=jn(),e=sn(),t=qd(),n=_r(),i=Or().f,o=kT(),s=Hn(),a=Xt(),c=Et(),l="Array Iterator",d=n.set,f=n.getterFor(l);t0=o(Array,"Array",function(g,m){d(this,{type:l,target:r(g),index:0,kind:m})},function(){var g=f(this),m=g.target,y=g.index++;if(!m||y>=m.length)return g.target=null,s(void 0,!0);switch(g.kind){case"keys":return s(y,!1);case"values":return s(m[y],!1)}return s([y,m[y]],!1)},"values");var h=t.Arguments=t.Array;if(e("keys"),e("values"),e("entries"),!a&&c&&h.name!=="values")try{i(h,"name",{value:"values"})}catch{}return t0}var $F={},qF;function H_e(){if(qF)return $F;qF=1;var r=H(),e=Ie(),t=ol(),n=jn(),i=$s(),o=e([].join),s=t!==Object,a=s||!i("join",",");return r({target:"Array",proto:!0,forced:a},{join:function(l){return o(n(this),l===void 0?",":l)}}),$F}var BF={},r0,UF;function Dre(){if(UF)return r0;UF=1;var r=zi(),e=jn(),t=Vr(),n=sr(),i=$s(),o=Math.min,s=[].lastIndexOf,a=!!s&&1/[1].lastIndexOf(1,-0)<0,c=i("lastIndexOf"),l=a||!c;return r0=l?function(f){if(a)return r(s,this,arguments)||0;var h=e(this),g=n(h);if(g===0)return-1;var m=g-1;for(arguments.length>1&&(m=o(m,t(arguments[1]))),m<0&&(m=g+m);m>=0;m--)if(m in h&&h[m]===f)return m||0;return-1}:s,r0}var zF;function W_e(){if(zF)return BF;zF=1;var r=H(),e=Dre();return r({target:"Array",proto:!0,forced:e!==[].lastIndexOf},{lastIndexOf:e}),BF}var HF={},WF;function K_e(){if(WF)return HF;WF=1;var r=H(),e=In().map,t=Vh(),n=t("map");return r({target:"Array",proto:!0,forced:!n},{map:function(o){return e(this,o,arguments.length>1?arguments[1]:void 0)}}),HF}var KF={},GF;function G_e(){if(GF)return KF;GF=1;var r=H(),e=Fe(),t=Pa(),n=Ns(),i=Array,o=e(function(){function s(){}return!(i.of.call(s)instanceof s)});return r({target:"Array",stat:!0,forced:o},{of:function(){for(var a=0,c=arguments.length,l=new(t(this)?this:i)(c);c>a;)n(l,a,arguments[a++]);return l.length=c,l}}),KF}var VF={},n0,YF;function OT(){if(YF)return n0;YF=1;var r=Et(),e=Ia(),t=TypeError,n=Object.getOwnPropertyDescriptor,i=r&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(o){return o instanceof TypeError}}();return n0=i?function(o,s){if(e(o)&&!n(o,"length").writable)throw new t("Cannot set read only .length");return o.length=s}:function(o,s){return o.length=s},n0}var XF;function V_e(){if(XF)return VF;XF=1;var r=H(),e=Zt(),t=sr(),n=OT(),i=lu(),o=Fe(),s=o(function(){return[].push.call({length:4294967296},1)!==4294967297}),a=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(l){return l instanceof TypeError}},c=s||!a();return r({target:"Array",proto:!0,arity:1,forced:c},{push:function(d){var f=e(this),h=t(f),g=arguments.length;i(h+g);for(var m=0;m<g;m++)f[h]=arguments[m],h++;return n(f,h),h}}),VF}var ZF={},i0,QF;function Qm(){if(QF)return i0;QF=1;var r=jt(),e=Zt(),t=ol(),n=sr(),i=TypeError,o="Reduce of empty array with no initial value",s=function(a){return function(c,l,d,f){var h=e(c),g=t(h),m=n(h);if(r(l),m===0&&d<2)throw new i(o);var y=a?m-1:0,x=a?-1:1;if(d<2)for(;;){if(y in g){f=g[y],y+=x;break}if(y+=x,a?y<0:m<=y)throw new i(o)}for(;a?y>=0:m>y;y+=x)y in g&&(f=l(f,g[y],y,h));return f}};return i0={left:s(!1),right:s(!0)},i0}var o0,JF;function Jm(){if(JF)return o0;JF=1;var r=Xe(),e=wa(),t=Ci(),n=function(i){return e.slice(0,i.length)===i};return o0=function(){return n("Bun/")?"BUN":n("Cloudflare-Workers")?"CLOUDFLARE":n("Deno/")?"DENO":n("Node.js/")?"NODE":r.Bun&&typeof Bun.version=="string"?"BUN":r.Deno&&typeof Deno.version=="object"?"DENO":t(r.process)==="process"?"NODE":r.window&&r.document?"BROWSER":"REST"}(),o0}var s0,eN;function Ud(){if(eN)return s0;eN=1;var r=Jm();return s0=r==="NODE",s0}var tN;function Y_e(){if(tN)return ZF;tN=1;var r=H(),e=Qm().left,t=$s(),n=ba(),i=Ud(),o=!i&&n>79&&n<83,s=o||!t("reduce");return r({target:"Array",proto:!0,forced:s},{reduce:function(c){var l=arguments.length;return e(this,c,l,l>1?arguments[1]:void 0)}}),ZF}var rN={},nN;function X_e(){if(nN)return rN;nN=1;var r=H(),e=Qm().right,t=$s(),n=ba(),i=Ud(),o=!i&&n>79&&n<83,s=o||!t("reduceRight");return r({target:"Array",proto:!0,forced:s},{reduceRight:function(c){return e(this,c,arguments.length,arguments.length>1?arguments[1]:void 0)}}),rN}var iN={},oN;function Z_e(){if(oN)return iN;oN=1;var r=H(),e=Ie(),t=Ia(),n=e([].reverse),i=[1,2];return r({target:"Array",proto:!0,forced:String(i)===String(i.reverse())},{reverse:function(){return t(this)&&(this.length=this.length),n(this)}}),iN}var sN={},aN;function Q_e(){if(aN)return sN;aN=1;var r=H(),e=Ia(),t=Pa(),n=Lt(),i=Ea(),o=sr(),s=jn(),a=Ns(),c=Tt(),l=Vh(),d=Bo(),f=l("slice"),h=c("species"),g=Array,m=Math.max;return r({target:"Array",proto:!0,forced:!f},{slice:function(x,_){var w=s(this),I=o(w),b=i(x,I),P=i(_===void 0?I:_,I),C,k,O;if(e(w)&&(C=w.constructor,t(C)&&(C===g||e(C.prototype))?C=void 0:n(C)&&(C=C[h],C===null&&(C=void 0)),C===g||C===void 0))return d(w,b,P);for(k=new(C===void 0?g:C)(m(P-b,0)),O=0;b<P;b++,O++)b in w&&a(k,O,w[b]);return k.length=O,k}}),sN}var cN={},lN;function J_e(){if(lN)return cN;lN=1;var r=H(),e=In().some,t=$s(),n=t("some");return r({target:"Array",proto:!0,forced:!n},{some:function(o){return e(this,o,arguments.length>1?arguments[1]:void 0)}}),cN}var uN={},a0,dN;function MT(){if(dN)return a0;dN=1;var r=Bo(),e=Math.floor,t=function(n,i){var o=n.length;if(o<8)for(var s=1,a,c;s<o;){for(c=s,a=n[s];c&&i(n[c-1],a)>0;)n[c]=n[--c];c!==s++&&(n[c]=a)}else for(var l=e(o/2),d=t(r(n,0,l),i),f=t(r(n,l),i),h=d.length,g=f.length,m=0,y=0;m<h||y<g;)n[m+y]=m<h&&y<g?i(d[m],f[y])<=0?d[m++]:f[y++]:m<h?d[m++]:f[y++];return n};return a0=t,a0}var c0,fN;function Lre(){if(fN)return c0;fN=1;var r=wa(),e=r.match(/firefox\/(\d+)/i);return c0=!!e&&+e[1],c0}var l0,hN;function Fre(){if(hN)return l0;hN=1;var r=wa();return l0=/MSIE|Trident/.test(r),l0}var u0,pN;function jT(){if(pN)return u0;pN=1;var r=wa(),e=r.match(/AppleWebKit\/(\d+)\./);return u0=!!e&&+e[1],u0}var gN;function ewe(){if(gN)return uN;gN=1;var r=H(),e=Ie(),t=jt(),n=Zt(),i=sr(),o=Vm(),s=Nt(),a=Fe(),c=MT(),l=$s(),d=Lre(),f=Fre(),h=ba(),g=jT(),m=[],y=e(m.sort),x=e(m.push),_=a(function(){m.sort(void 0)}),w=a(function(){m.sort(null)}),I=l("sort"),b=!a(function(){if(h)return h<70;if(!(d&&d>3)){if(f)return!0;if(g)return g<603;var k="",O,L,j,F;for(O=65;O<76;O++){switch(L=String.fromCharCode(O),O){case 66:case 69:case 70:case 72:j=3;break;case 68:case 71:j=4;break;default:j=2}for(F=0;F<47;F++)m.push({k:L+F,v:j})}for(m.sort(function($,D){return D.v-$.v}),F=0;F<m.length;F++)L=m[F].k.charAt(0),k.charAt(k.length-1)!==L&&(k+=L);return k!=="DGBEFHACIJK"}}),P=_||!w||!I||!b,C=function(k){return function(O,L){return L===void 0?-1:O===void 0?1:k!==void 0?+k(O,L)||0:s(O)>s(L)?1:-1}};return r({target:"Array",proto:!0,forced:P},{sort:function(O){O!==void 0&&t(O);var L=n(this);if(b)return O===void 0?y(L):y(L,O);var j=[],F=i(L),$,D;for(D=0;D<F;D++)D in L&&x(j,L[D]);for(c(j,C(O)),$=i(j),D=0;D<$;)L[D]=j[D++];for(;D<F;)o(L,D++);return L}}),uN}var vN={},d0,mN;function pu(){if(mN)return d0;mN=1;var r=Mt(),e=Yr(),t=Tt(),n=Et(),i=t("species");return d0=function(o){var s=r(o);n&&s&&!s[i]&&e(s,i,{configurable:!0,get:function(){return this}})},d0}var yN;function twe(){if(yN)return vN;yN=1;var r=pu();return r("Array"),vN}var SN={},xN;function rwe(){if(xN)return SN;xN=1;var r=H(),e=Zt(),t=Ea(),n=Vr(),i=sr(),o=OT(),s=lu(),a=qh(),c=Ns(),l=Vm(),d=Vh(),f=d("splice"),h=Math.max,g=Math.min;return r({target:"Array",proto:!0,forced:!f},{splice:function(y,x){var _=e(this),w=i(_),I=t(y,w),b=arguments.length,P,C,k,O,L,j;for(b===0?P=C=0:b===1?(P=0,C=w-I):(P=b-2,C=g(h(n(x),0),w-I)),s(w+P-C),k=a(_,C),O=0;O<C;O++)L=I+O,L in _&&c(k,O,_[L]);if(k.length=C,P<C){for(O=I;O<w-C;O++)L=O+C,j=O+P,L in _?_[j]=_[L]:l(_,j);for(O=w;O>w-C+P;O--)l(_,O-1)}else if(P>C)for(O=w-C;O>I;O--)L=O+C-1,j=O+P-1,L in _?_[j]=_[L]:l(_,j);for(O=0;O<P;O++)_[O+I]=arguments[O+2];return o(_,w-C+P),k}}),SN}var _N={},f0,wN;function Nre(){if(wN)return f0;wN=1;var r=sr();return f0=function(e,t){for(var n=r(e),i=new t(n),o=0;o<n;o++)i[o]=e[n-o-1];return i},f0}var bN;function $re(){if(bN)return _N;bN=1;var r=H(),e=Nre(),t=jn(),n=sn(),i=Array;return r({target:"Array",proto:!0},{toReversed:function(){return e(t(this),i)}}),n("toReversed"),_N}var EN={},h0,IN;function fl(){if(IN)return h0;IN=1;var r=sr();return h0=function(e,t,n){for(var i=0,o=arguments.length>2?n:r(t),s=new e(o);o>i;)s[i]=t[i++];return s},h0}var p0,PN;function qre(){if(PN)return p0;PN=1;var r=Xe();return p0=function(e,t){var n=r[e],i=n&&n.prototype;return i&&i[t]},p0}var CN;function Bre(){if(CN)return EN;CN=1;var r=H(),e=Ie(),t=jt(),n=jn(),i=fl(),o=qre(),s=sn(),a=Array,c=e(o("Array","sort"));return r({target:"Array",proto:!0},{toSorted:function(d){d!==void 0&&t(d);var f=n(this),h=i(a,f);return c(h,d)}}),s("toSorted"),EN}var TN={},AN;function Ure(){if(AN)return TN;AN=1;var r=H(),e=sn(),t=lu(),n=sr(),i=Ea(),o=jn(),s=Vr(),a=Array,c=Math.max,l=Math.min;return r({target:"Array",proto:!0},{toSpliced:function(f,h){var g=o(this),m=n(g),y=i(f,m),x=arguments.length,_=0,w,I,b,P;for(x===0?w=I=0:x===1?(w=0,I=m-y):(w=x-2,I=l(c(s(h),0),m-y)),b=t(m+w-I),P=a(b);_<y;_++)P[_]=g[_];for(;_<y+w;_++)P[_]=arguments[_-y+2];for(;_<b;_++)P[_]=g[_+I-w];return P}}),e("toSpliced"),TN}var RN={},kN;function nwe(){if(kN)return RN;kN=1;var r=H(),e=Zt(),t=sr(),n=OT(),i=Vm(),o=lu(),s=[].unshift(0)!==1,a=function(){try{Object.defineProperty([],"length",{writable:!1}).unshift()}catch(l){return l instanceof TypeError}},c=s||!a();return r({target:"Array",proto:!0,arity:1,forced:c},{unshift:function(d){var f=e(this),h=t(f),g=arguments.length;if(g){o(h+g);for(var m=h;m--;){var y=m+g;m in f?f[y]=f[m]:i(f,y)}for(var x=0;x<g;x++)f[x]=arguments[x]}return n(f,h+g)}}),RN}var ON={},g0,MN;function zre(){if(MN)return g0;MN=1;var r=sr(),e=Vr(),t=RangeError;return g0=function(n,i,o,s){var a=r(n),c=e(o),l=c<0?a+c:c;if(l>=a||l<0)throw new t("Incorrect index");for(var d=new i(a),f=0;f<a;f++)d[f]=f===l?s:n[f];return d},g0}var jN;function Hre(){if(jN)return ON;jN=1;var r=H(),e=zre(),t=jn(),n=Array;return r({target:"Array",proto:!0},{with:function(i,o){return e(t(this),n,i,o)}}),ON}var DN={},v0,LN;function ey(){return LN||(LN=1,v0=typeof ArrayBuffer<"u"&&typeof DataView<"u"),v0}var m0,FN;function qs(){if(FN)return m0;FN=1;var r=wr();return m0=function(e,t,n){for(var i in t)r(e,i,t[i],n);return e},m0}var y0,NN;function Wi(){if(NN)return y0;NN=1;var r=Ti(),e=TypeError;return y0=function(t,n){if(r(n,t))return t;throw new e("Incorrect invocation")},y0}var S0,$N;function Yh(){if($N)return S0;$N=1;var r=Vr(),e=$o(),t=RangeError;return S0=function(n){if(n===void 0)return 0;var i=r(n),o=e(i);if(i!==o)throw new t("Wrong length or index");return o},S0}var x0,qN;function DT(){return qN||(qN=1,x0=Math.sign||function(e){var t=+e;return t===0||t!==t?t:t<0?-1:1}),x0}var _0,BN;function Wre(){if(BN)return _0;BN=1;var r=2220446049250313e-31,e=1/r;return _0=function(t){return t+e-e},_0}var w0,UN;function Kre(){if(UN)return w0;UN=1;var r=DT(),e=Wre(),t=Math.abs,n=2220446049250313e-31;return w0=function(i,o,s,a){var c=+i,l=t(c),d=r(c);if(l<a)return d*e(l/a/o)*a*o;var f=(1+o/n)*l,h=f-(f-l);return h>s||h!==h?d*(1/0):d*h},w0}var b0,zN;function LT(){if(zN)return b0;zN=1;var r=Kre(),e=11920928955078125e-23,t=34028234663852886e22,n=11754943508222875e-54;return b0=Math.fround||function(o){return r(o,e,t,n)},b0}var E0,HN;function iwe(){if(HN)return E0;HN=1;var r=Array,e=Math.abs,t=Math.pow,n=Math.floor,i=Math.log,o=Math.LN2,s=function(c,l,d){var f=r(d),h=d*8-l-1,g=(1<<h)-1,m=g>>1,y=l===23?t(2,-24)-t(2,-77):0,x=c<0||c===0&&1/c<0?1:0,_=0,w,I,b;for(c=e(c),c!==c||c===1/0?(I=c!==c?1:0,w=g):(w=n(i(c)/o),b=t(2,-w),c*b<1&&(w--,b*=2),w+m>=1?c+=y/b:c+=y*t(2,1-m),c*b>=2&&(w++,b/=2),w+m>=g?(I=0,w=g):w+m>=1?(I=(c*b-1)*t(2,l),w+=m):(I=c*t(2,m-1)*t(2,l),w=0));l>=8;)f[_++]=I&255,I/=256,l-=8;for(w=w<<l|I,h+=l;h>0;)f[_++]=w&255,w/=256,h-=8;return f[_-1]|=x*128,f},a=function(c,l){var d=c.length,f=d*8-l-1,h=(1<<f)-1,g=h>>1,m=f-7,y=d-1,x=c[y--],_=x&127,w;for(x>>=7;m>0;)_=_*256+c[y--],m-=8;for(w=_&(1<<-m)-1,_>>=-m,m+=l;m>0;)w=w*256+c[y--],m-=8;if(_===0)_=1-g;else{if(_===h)return w?NaN:x?-1/0:1/0;w+=t(2,l),_-=g}return(x?-1:1)*w*t(2,_-l)};return E0={pack:s,unpack:a},E0}var I0,WN;function ty(){if(WN)return I0;WN=1;var r=Xe(),e=Ie(),t=Et(),n=ey(),i=kd(),o=Dn(),s=Yr(),a=qs(),c=Fe(),l=Wi(),d=Vr(),f=$o(),h=Yh(),g=LT(),m=iwe(),y=Fn(),x=Fs(),_=AT(),w=Bo(),I=du(),b=Od(),P=yo(),C=_r(),k=i.PROPER,O=i.CONFIGURABLE,L="ArrayBuffer",j="DataView",F="prototype",$="Wrong length",D="Wrong index",N=C.getterFor(L),B=C.getterFor(j),W=C.set,G=r[L],z=G,V=z&&z[F],J=r[j],K=J&&J[F],Z=Object.prototype,ee=r.Array,re=r.RangeError,te=e(_),le=e([].reverse),ge=m.pack,se=m.unpack,ce=function(Ae){return[Ae&255]},_e=function(Ae){return[Ae&255,Ae>>8&255]},Le=function(Ae){return[Ae&255,Ae>>8&255,Ae>>16&255,Ae>>24&255]},Ge=function(Ae){return Ae[3]<<24|Ae[2]<<16|Ae[1]<<8|Ae[0]},qe=function(Ae){return ge(g(Ae),23,4)},mt=function(Ae){return ge(Ae,52,8)},St=function(Ae,ze,be){s(Ae[F],ze,{configurable:!0,get:function(){return be(this)[ze]}})},et=function(Ae,ze,be,it){var st=B(Ae),Je=h(be),Ye=!!it;if(Je+ze>st.byteLength)throw new re(D);var cr=st.bytes,Sr=Je+st.byteOffset,Y=w(cr,Sr,Sr+ze);return Ye?Y:le(Y)},ct=function(Ae,ze,be,it,st,Je){var Ye=B(Ae),cr=h(be),Sr=it(+st),Y=!!Je;if(cr+ze>Ye.byteLength)throw new re(D);for(var oe=Ye.bytes,me=cr+Ye.byteOffset,we=0;we<ze;we++)oe[me+we]=Sr[Y?we:ze-we-1]};if(!n)z=function(ze){l(this,V);var be=h(ze);W(this,{type:L,bytes:te(ee(be),0),byteLength:be}),t||(this.byteLength=be,this.detached=!1)},V=z[F],J=function(ze,be,it){l(this,K),l(ze,V);var st=N(ze),Je=st.byteLength,Ye=d(be);if(Ye<0||Ye>Je)throw new re("Wrong offset");if(it=it===void 0?Je-Ye:f(it),Ye+it>Je)throw new re($);W(this,{type:j,buffer:ze,byteLength:it,byteOffset:Ye,bytes:st.bytes}),t||(this.buffer=ze,this.byteLength=it,this.byteOffset=Ye)},K=J[F],t&&(St(z,"byteLength",N),St(J,"buffer",B),St(J,"byteLength",B),St(J,"byteOffset",B)),a(K,{getInt8:function(ze){return et(this,1,ze)[0]<<24>>24},getUint8:function(ze){return et(this,1,ze)[0]},getInt16:function(ze){var be=et(this,2,ze,arguments.length>1?arguments[1]:!1);return(be[1]<<8|be[0])<<16>>16},getUint16:function(ze){var be=et(this,2,ze,arguments.length>1?arguments[1]:!1);return be[1]<<8|be[0]},getInt32:function(ze){return Ge(et(this,4,ze,arguments.length>1?arguments[1]:!1))},getUint32:function(ze){return Ge(et(this,4,ze,arguments.length>1?arguments[1]:!1))>>>0},getFloat32:function(ze){return se(et(this,4,ze,arguments.length>1?arguments[1]:!1),23)},getFloat64:function(ze){return se(et(this,8,ze,arguments.length>1?arguments[1]:!1),52)},setInt8:function(ze,be){ct(this,1,ze,ce,be)},setUint8:function(ze,be){ct(this,1,ze,ce,be)},setInt16:function(ze,be){ct(this,2,ze,_e,be,arguments.length>2?arguments[2]:!1)},setUint16:function(ze,be){ct(this,2,ze,_e,be,arguments.length>2?arguments[2]:!1)},setInt32:function(ze,be){ct(this,4,ze,Le,be,arguments.length>2?arguments[2]:!1)},setUint32:function(ze,be){ct(this,4,ze,Le,be,arguments.length>2?arguments[2]:!1)},setFloat32:function(ze,be){ct(this,4,ze,qe,be,arguments.length>2?arguments[2]:!1)},setFloat64:function(ze,be){ct(this,8,ze,mt,be,arguments.length>2?arguments[2]:!1)}});else{var At=k&&G.name!==L;!c(function(){G(1)})||!c(function(){new G(-1)})||c(function(){return new G,new G(1.5),new G(NaN),G.length!==1||At&&!O})?(z=function(ze){return l(this,V),I(new G(h(ze)),this,z)},z[F]=V,V.constructor=z,b(z,G)):At&&O&&o(G,"name",L),x&&y(K)!==Z&&x(K,Z);var _t=new J(new z(2)),ut=e(K.setInt8);_t.setInt8(0,2147483648),_t.setInt8(1,2147483649),(_t.getInt8(0)||!_t.getInt8(1))&&a(K,{setInt8:function(ze,be){ut(this,ze,be<<24>>24)},setUint8:function(ze,be){ut(this,ze,be<<24>>24)}},{unsafe:!0})}return P(z,L),P(J,j),I0={ArrayBuffer:z,DataView:J},I0}var KN;function owe(){if(KN)return DN;KN=1;var r=H(),e=Xe(),t=ty(),n=pu(),i="ArrayBuffer",o=t[i],s=e[i];return r({global:!0,constructor:!0,forced:s!==o},{ArrayBuffer:o}),n(i),DN}var GN={},P0,VN;function Vt(){if(VN)return P0;VN=1;var r=ey(),e=Et(),t=Xe(),n=Ut(),i=Lt(),o=Kt(),s=vo(),a=su(),c=Dn(),l=wr(),d=Yr(),f=Ti(),h=Fn(),g=Fs(),m=Tt(),y=au(),x=_r(),_=x.enforce,w=x.get,I=t.Int8Array,b=I&&I.prototype,P=t.Uint8ClampedArray,C=P&&P.prototype,k=I&&h(I),O=b&&h(b),L=Object.prototype,j=t.TypeError,F=m("toStringTag"),$=y("TYPED_ARRAY_TAG"),D="TypedArrayConstructor",N=r&&!!g&&s(t.opera)!=="Opera",B=!1,W,G,z,V={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},J={BigInt64Array:8,BigUint64Array:8},K=function(ce){if(!i(ce))return!1;var _e=s(ce);return _e==="DataView"||o(V,_e)||o(J,_e)},Z=function(se){var ce=h(se);if(i(ce)){var _e=w(ce);return _e&&o(_e,D)?_e[D]:Z(ce)}},ee=function(se){if(!i(se))return!1;var ce=s(se);return o(V,ce)||o(J,ce)},re=function(se){if(ee(se))return se;throw new j("Target is not a typed array")},te=function(se){if(n(se)&&(!g||f(k,se)))return se;throw new j(a(se)+" is not a typed array constructor")},le=function(se,ce,_e,Le){if(e){if(_e)for(var Ge in V){var qe=t[Ge];if(qe&&o(qe.prototype,se))try{delete qe.prototype[se]}catch{try{qe.prototype[se]=ce}catch{}}}(!O[se]||_e)&&l(O,se,_e?ce:N&&b[se]||ce,Le)}},ge=function(se,ce,_e){var Le,Ge;if(e){if(g){if(_e){for(Le in V)if(Ge=t[Le],Ge&&o(Ge,se))try{delete Ge[se]}catch{}}if(!k[se]||_e)try{return l(k,se,_e?ce:N&&k[se]||ce)}catch{}else return}for(Le in V)Ge=t[Le],Ge&&(!Ge[se]||_e)&&l(Ge,se,ce)}};for(W in V)G=t[W],z=G&&G.prototype,z?_(z)[D]=G:N=!1;for(W in J)G=t[W],z=G&&G.prototype,z&&(_(z)[D]=G);if((!N||!n(k)||k===Function.prototype)&&(k=function(){throw new j("Incorrect invocation")},N))for(W in V)t[W]&&g(t[W],k);if((!N||!O||O===L)&&(O=k.prototype,N))for(W in V)t[W]&&g(t[W].prototype,O);if(N&&h(C)!==O&&g(C,O),e&&!o(O,F)){B=!0,d(O,F,{configurable:!0,get:function(){return i(this)?this[$]:void 0}});for(W in V)t[W]&&c(t[W],$,W)}return P0={NATIVE_ARRAY_BUFFER_VIEWS:N,TYPED_ARRAY_TAG:B&&$,aTypedArray:re,aTypedArrayConstructor:te,exportTypedArrayMethod:le,exportTypedArrayStaticMethod:ge,getTypedArrayConstructor:Z,isView:K,isTypedArray:ee,TypedArray:k,TypedArrayPrototype:O},P0}var YN;function swe(){if(YN)return GN;YN=1;var r=H(),e=Vt(),t=e.NATIVE_ARRAY_BUFFER_VIEWS;return r({target:"ArrayBuffer",stat:!0,forced:!t},{isView:e.isView}),GN}var XN={},ZN;function awe(){if(ZN)return XN;ZN=1;var r=H(),e=uu(),t=Fe(),n=ty(),i=Ze(),o=Ea(),s=$o(),a=n.ArrayBuffer,c=n.DataView,l=c.prototype,d=e(a.prototype.slice),f=e(l.getUint8),h=e(l.setUint8),g=t(function(){return!new a(2).slice(1,void 0).byteLength});return r({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:g},{slice:function(y,x){if(d&&x===void 0)return d(i(this),y);for(var _=i(this).byteLength,w=o(y,_),I=o(x===void 0?_:x,_),b=new a(s(I-w)),P=new c(this),C=new c(b),k=0;w<I;)h(C,k++,f(P,w++));return b}}),XN}var QN={},JN={},e3;function cwe(){if(e3)return JN;e3=1;var r=H(),e=ty(),t=ey();return r({global:!0,constructor:!0,forced:!t},{DataView:e.DataView}),JN}var t3;function lwe(){return t3||(t3=1,cwe()),QN}var r3={},n3;function Gre(){if(n3)return r3;n3=1;var r=H(),e=Ie(),t=Math.pow,n=31,i=1023,o=t(2,-24),s=.0009765625,a=function(l){var d=l>>>15,f=l>>>10&n,h=l&i;return f===n?h===0?d===0?1/0:-1/0:NaN:f===0?h*(d===0?o:-o):t(2,f-15)*(d===0?1+h*s:-1-h*s)},c=e(DataView.prototype.getUint16);return r({target:"DataView",proto:!0},{getFloat16:function(d){var f=c(this,d,arguments.length>1?arguments[1]:!1);return a(f)}}),r3}var i3={},C0,o3;function Vre(){if(o3)return C0;o3=1;var r=vo(),e=TypeError;return C0=function(t){if(r(t)==="DataView")return t;throw new e("Argument is not a DataView")},C0}var T0,s3;function Yre(){if(s3)return T0;s3=1;var r=Math.log,e=Math.LN2;return T0=Math.log2||function(n){return r(n)/e},T0}var a3;function Xre(){if(a3)return i3;a3=1;var r=H(),e=Ie(),t=Vre(),n=Yh(),i=Yre(),o=Wre(),s=Math.pow,a=65520,c=61005353927612305e-21,l=16777216,d=1024,f=function(g){if(g!==g)return 32256;if(g===0)return(1/g===-1/0)<<15;var m=g<0;if(m&&(g=-g),g>=a)return m<<15|31744;if(g<c)return m<<15|o(g*l);var y=i(g)|0;if(y===-15)return m<<15|d;var x=o((g*s(2,-y)-1)*d);return x===d?m<<15|y+16<<10:m<<15|y+15<<10|x},h=e(DataView.prototype.setUint16);return r({target:"DataView",proto:!0},{setFloat16:function(m,y){t(this);var x=n(m),_=f(+y);return h(this,x,_,arguments.length>2?arguments[2]:!1)}}),i3}var c3={},A0,l3;function Zre(){if(l3)return A0;l3=1;var r=Xe(),e=Gm(),t=Ci(),n=r.ArrayBuffer,i=r.TypeError;return A0=n&&e(n.prototype,"byteLength","get")||function(o){if(t(o)!=="ArrayBuffer")throw new i("ArrayBuffer expected");return o.byteLength},A0}var R0,u3;function Qre(){if(u3)return R0;u3=1;var r=Xe(),e=ey(),t=Zre(),n=r.DataView;return R0=function(i){if(!e||t(i)!==0)return!1;try{return new n(i),!1}catch{return!0}},R0}var d3;function Jre(){if(d3)return c3;d3=1;var r=Et(),e=Yr(),t=Qre(),n=ArrayBuffer.prototype;return r&&!("detached"in n)&&e(n,"detached",{configurable:!0,get:function(){return t(this)}}),c3}var f3={},k0,h3;function Xh(){if(h3)return k0;h3=1;var r=Qre(),e=TypeError;return k0=function(t){if(r(t))throw new e("ArrayBuffer is detached");return t},k0}var O0,p3;function ene(){if(p3)return O0;p3=1;var r=Xe(),e=Ud();return O0=function(t){if(e){try{return r.process.getBuiltinModule(t)}catch{}try{return Function('return require("'+t+'")')()}catch{}}},O0}var M0,g3;function FT(){if(g3)return M0;g3=1;var r=Xe(),e=Fe(),t=ba(),n=Jm(),i=r.structuredClone;return M0=!!i&&!e(function(){if(n==="DENO"&&t>92||n==="NODE"&&t>94||n==="BROWSER"&&t>97)return!1;var o=new ArrayBuffer(8),s=i(o,{transfer:[o]});return o.byteLength!==0||s.byteLength!==8}),M0}var j0,v3;function tne(){if(v3)return j0;v3=1;var r=Xe(),e=ene(),t=FT(),n=r.structuredClone,i=r.ArrayBuffer,o=r.MessageChannel,s=!1,a,c,l,d;if(t)s=function(f){n(f,{transfer:[f]})};else if(i)try{o||(a=e("worker_threads"),a&&(o=a.MessageChannel)),o&&(c=new o,l=new i(2),d=function(f){c.port1.postMessage(null,[f])},l.byteLength===2&&(d(l),l.byteLength===0&&(s=d)))}catch{}return j0=s,j0}var D0,m3;function rne(){if(m3)return D0;m3=1;var r=Xe(),e=Ie(),t=Gm(),n=Yh(),i=Xh(),o=Zre(),s=tne(),a=FT(),c=r.structuredClone,l=r.ArrayBuffer,d=r.DataView,f=Math.min,h=l.prototype,g=d.prototype,m=e(h.slice),y=t(h,"resizable","get"),x=t(h,"maxByteLength","get"),_=e(g.getInt8),w=e(g.setInt8);return D0=(a||s)&&function(I,b,P){var C=o(I),k=b===void 0?C:n(b),O=!y||!y(I),L;if(i(I),a&&(I=c(I,{transfer:[I]}),C===k&&(P||O)))return I;if(C>=k&&(!P||O))L=m(I,0,k);else{var j=P&&!O&&x?{maxByteLength:x(I)}:void 0;L=new l(k,j);for(var F=new d(I),$=new d(L),D=f(k,C),N=0;N<D;N++)w($,N,_(F,N))}return a||s(I),L},D0}var y3;function nne(){if(y3)return f3;y3=1;var r=H(),e=rne();return e&&r({target:"ArrayBuffer",proto:!0},{transfer:function(){return e(this,arguments.length?arguments[0]:void 0,!0)}}),f3}var S3={},x3;function ine(){if(x3)return S3;x3=1;var r=H(),e=rne();return e&&r({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return e(this,arguments.length?arguments[0]:void 0,!1)}}),S3}var _3={},w3;function uwe(){if(w3)return _3;w3=1;var r=H(),e=Ie(),t=Fe(),n=t(function(){return new Date(16e11).getYear()!==120}),i=e(Date.prototype.getFullYear);return r({target:"Date",proto:!0,forced:n},{getYear:function(){return i(this)-1900}}),_3}var b3={},E3;function dwe(){if(E3)return b3;E3=1;var r=H(),e=Ie(),t=Date,n=e(t.prototype.getTime);return r({target:"Date",stat:!0},{now:function(){return n(new t)}}),b3}var I3={},P3;function fwe(){if(P3)return I3;P3=1;var r=H(),e=Ie(),t=Vr(),n=Date.prototype,i=e(n.getTime),o=e(n.setFullYear);return r({target:"Date",proto:!0},{setYear:function(a){i(this);var c=t(a),l=c>=0&&c<=99?c+1900:c;return o(this,l)}}),I3}var C3={},T3;function hwe(){if(T3)return C3;T3=1;var r=H();return r({target:"Date",proto:!0},{toGMTString:Date.prototype.toUTCString}),C3}var A3={},L0,R3;function ry(){if(R3)return L0;R3=1;var r=Vr(),e=Nt(),t=qr(),n=RangeError;return L0=function(o){var s=e(t(this)),a="",c=r(o);if(c<0||c===1/0)throw new n("Wrong number of repetitions");for(;c>0;(c>>>=1)&&(s+=s))c&1&&(a+=s);return a},L0}var F0,k3;function ny(){if(k3)return F0;k3=1;var r=Ie(),e=$o(),t=Nt(),n=ry(),i=qr(),o=r(n),s=r("".slice),a=Math.ceil,c=function(l){return function(d,f,h){var g=t(i(d)),m=e(f),y=g.length,x=h===void 0?" ":t(h),_,w;return m<=y||x===""?g:(_=m-y,w=o(x,a(_/x.length)),w.length>_&&(w=s(w,0,_)),l?g+w:w+g)}};return F0={start:c(!1),end:c(!0)},F0}var N0,O3;function pwe(){if(O3)return N0;O3=1;var r=Ie(),e=Fe(),t=ny().start,n=RangeError,i=isFinite,o=Math.abs,s=Date.prototype,a=s.toISOString,c=r(s.getTime),l=r(s.getUTCDate),d=r(s.getUTCFullYear),f=r(s.getUTCHours),h=r(s.getUTCMilliseconds),g=r(s.getUTCMinutes),m=r(s.getUTCMonth),y=r(s.getUTCSeconds);return N0=e(function(){return a.call(new Date(-5e13-1))!=="0385-07-25T07:06:39.999Z"})||!e(function(){a.call(new Date(NaN))})?function(){if(!i(c(this)))throw new n("Invalid time value");var _=this,w=d(_),I=h(_),b=w<0?"-":w>9999?"+":"";return b+t(o(w),b?6:4,0)+"-"+t(m(_)+1,2,0)+"-"+t(l(_),2,0)+"T"+t(f(_),2,0)+":"+t(g(_),2,0)+":"+t(y(_),2,0)+"."+t(I,3,0)+"Z"}:a,N0}var M3;function gwe(){if(M3)return A3;M3=1;var r=H(),e=pwe();return r({target:"Date",proto:!0,forced:Date.prototype.toISOString!==e},{toISOString:e}),A3}var j3={},D3;function vwe(){if(D3)return j3;D3=1;var r=H(),e=Fe(),t=Zt(),n=Im(),i=e(function(){return new Date(NaN).toJSON()!==null||Date.prototype.toJSON.call({toISOString:function(){return 1}})!==1});return r({target:"Date",proto:!0,arity:1,forced:i},{toJSON:function(s){var a=t(this),c=n(a,"number");return typeof c=="number"&&!isFinite(c)?null:a.toISOString()}}),j3}var L3={},$0,F3;function mwe(){if(F3)return $0;F3=1;var r=Ze(),e=uee(),t=TypeError;return $0=function(n){if(r(this),n==="string"||n==="default")n="string";else if(n!=="number")throw new t("Incorrect hint");return e(this,n)},$0}var N3;function ywe(){if(N3)return L3;N3=1;var r=Kt(),e=wr(),t=mwe(),n=Tt(),i=n("toPrimitive"),o=Date.prototype;return r(o,i)||e(o,i,t),L3}var $3={},q3;function Swe(){if(q3)return $3;q3=1;var r=Ie(),e=wr(),t=Date.prototype,n="Invalid Date",i="toString",o=r(t[i]),s=r(t.getTime);return String(new Date(NaN))!==n&&e(t,i,function(){var c=s(this);return c===c?o(this):n}),$3}var B3={},U3;function xwe(){if(U3)return B3;U3=1;var r=H(),e=Ie(),t=Nt(),n=e("".charAt),i=e("".charCodeAt),o=e(/./.exec),s=e(1 .toString),a=e("".toUpperCase),c=/[\w*+\-./@]/,l=function(d,f){for(var h=s(d,16);h.length<f;)h="0"+h;return h};return r({global:!0},{escape:function(f){for(var h=t(f),g="",m=h.length,y=0,x,_;y<m;)x=n(h,y++),o(c,x)?g+=x:(_=i(x,0),_<256?g+="%"+l(_,2):g+="%u"+a(l(_,4)));return g}}),B3}var z3={},q0,H3;function one(){if(H3)return q0;H3=1;var r=Ie(),e=jt(),t=Lt(),n=Kt(),i=Bo(),o=Dh(),s=Function,a=r([].concat),c=r([].join),l={},d=function(f,h,g){if(!n(l,h)){for(var m=[],y=0;y<h;y++)m[y]="a["+y+"]";l[h]=s("C,a","return new C("+c(m,",")+")")}return l[h](f,g)};return q0=o?s.bind:function(h){var g=e(this),m=g.prototype,y=i(arguments,1),x=function(){var w=a(y,i(arguments));return this instanceof x?d(g,w.length,w):g.apply(h,w)};return t(m)&&(x.prototype=m),x},q0}var W3;function _we(){if(W3)return z3;W3=1;var r=H(),e=one();return r({target:"Function",proto:!0,forced:Function.bind!==e},{bind:e}),z3}var K3={},G3;function wwe(){if(G3)return K3;G3=1;var r=Ut(),e=Lt(),t=Or(),n=Ti(),i=Tt(),o=Am(),s=i("hasInstance"),a=Function.prototype;return s in a||t.f(a,s,{value:o(function(c){if(!r(this)||!e(c))return!1;var l=this.prototype;return e(l)?n(l,c):c instanceof this},s)}),K3}var V3={},Y3;function bwe(){if(Y3)return V3;Y3=1;var r=Et(),e=kd().EXISTS,t=Ie(),n=Yr(),i=Function.prototype,o=t(i.toString),s=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,a=t(s.exec),c="name";return r&&!e&&n(i,c,{configurable:!0,get:function(){try{return a(s,o(this))[1]}catch{return""}}}),V3}var X3={},Z3;function sne(){if(Z3)return X3;Z3=1;var r=H(),e=Xe();return r({global:!0,forced:e.globalThis!==e},{globalThis:e}),X3}var Q3={},J3;function ane(){if(J3)return Q3;J3=1;var r=H(),e=Xe(),t=Wi(),n=Ze(),i=Ut(),o=Fn(),s=Yr(),a=Ns(),c=Fe(),l=Kt(),d=Tt(),f=Bd().IteratorPrototype,h=Et(),g=Xt(),m="constructor",y="Iterator",x=d("toStringTag"),_=TypeError,w=e[y],I=g||!i(w)||w.prototype!==f||!c(function(){w({})}),b=function(){if(t(this,f),o(this)===f)throw new _("Abstract class Iterator not directly constructable")},P=function(C,k){h?s(f,C,{configurable:!0,get:function(){return k},set:function(O){if(n(this),this===f)throw new _("You can't redefine this property");l(this,C)?this[C]=O:a(this,C,O)}}):f[C]=k};return l(f,x)||P(x,y),(I||!l(f,m)||f[m]===Object)&&P(m,b),b.prototype=f,r({global:!0,constructor:!0,forced:I},{Iterator:b}),Q3}var e$={},B0,t$;function Jr(){return t$||(t$=1,B0=function(r){return{iterator:r,next:r.next,done:!1}}),B0}var U0,r$;function Zh(){if(r$)return U0;r$=1;var r=RangeError;return U0=function(e){if(e===e)return e;throw new r("NaN is not allowed")},U0}var z0,n$;function Qh(){if(n$)return z0;n$=1;var r=Vr(),e=RangeError;return z0=function(t){var n=r(t);if(n<0)throw new e("The argument can't be less than 0");return n},z0}var H0,i$;function gu(){if(i$)return H0;i$=1;var r=Qe(),e=En(),t=Dn(),n=qs(),i=Tt(),o=_r(),s=bn(),a=Bd().IteratorPrototype,c=Hn(),l=dl(),d=i("toStringTag"),f="IteratorHelper",h="WrapForValidIterator",g=o.set,m=function(_){var w=o.getterFor(_?h:f);return n(e(a),{next:function(){var b=w(this);if(_)return b.nextHandler();if(b.done)return c(void 0,!0);try{var P=b.nextHandler();return b.returnHandlerResult?P:c(P,b.done)}catch(C){throw b.done=!0,C}},return:function(){var I=w(this),b=I.iterator;if(I.done=!0,_){var P=s(b,"return");return P?r(P,b):c(void 0,!0)}if(I.inner)try{l(I.inner.iterator,"normal")}catch(C){return l(b,"throw",C)}return b&&l(b,"normal"),c(void 0,!0)}})},y=m(!0),x=m(!1);return t(x,d,"Iterator Helper"),H0=function(_,w,I){var b=function(C,k){k?(k.iterator=C.iterator,k.next=C.next):k=C,k.type=w?h:f,k.returnHandlerResult=!!I,k.nextHandler=_,k.counter=0,k.done=!1,g(this,k)};return b.prototype=w?y:x,b},H0}var o$;function cne(){if(o$)return e$;o$=1;var r=H(),e=Qe(),t=Ze(),n=Jr(),i=Zh(),o=Qh(),s=gu(),a=Xt(),c=s(function(){for(var l=this.iterator,d=this.next,f,h;this.remaining;)if(this.remaining--,f=t(e(d,l)),h=this.done=!!f.done,h)return;if(f=t(e(d,l)),h=this.done=!!f.done,!h)return f.value});return r({target:"Iterator",proto:!0,real:!0,forced:a},{drop:function(d){t(this);var f=o(i(+d));return new c(n(this),{remaining:f})}}),e$}var s$={},a$;function lne(){if(a$)return s$;a$=1;var r=H(),e=cn(),t=jt(),n=Ze(),i=Jr();return r({target:"Iterator",proto:!0,real:!0},{every:function(s){n(this),t(s);var a=i(this),c=0;return!e(a,function(l,d){if(!s(l,c++))return d()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}}),s$}var c$={},l$;function une(){if(l$)return c$;l$=1;var r=H(),e=Qe(),t=jt(),n=Ze(),i=Jr(),o=gu(),s=RT(),a=Xt(),c=o(function(){for(var l=this.iterator,d=this.predicate,f=this.next,h,g,m;;){if(h=n(e(f,l)),g=this.done=!!h.done,g)return;if(m=h.value,s(l,d,[m,this.counter++],!0))return m}});return r({target:"Iterator",proto:!0,real:!0,forced:a},{filter:function(d){return n(this),t(d),new c(i(this),{predicate:d})}}),c$}var u$={},d$;function dne(){if(d$)return u$;d$=1;var r=H(),e=cn(),t=jt(),n=Ze(),i=Jr();return r({target:"Iterator",proto:!0,real:!0},{find:function(s){n(this),t(s);var a=i(this),c=0;return e(a,function(l,d){if(s(l,c++))return d(l)},{IS_RECORD:!0,INTERRUPTED:!0}).result}}),u$}var f$={},W0,h$;function fne(){if(h$)return W0;h$=1;var r=Qe(),e=Ze(),t=Jr(),n=dc();return W0=function(i,o){(!o||typeof i!="string")&&e(i);var s=n(i);return t(e(s!==void 0?r(s,i):i))},W0}var p$;function hne(){if(p$)return f$;p$=1;var r=H(),e=Qe(),t=jt(),n=Ze(),i=Jr(),o=fne(),s=gu(),a=dl(),c=Xt(),l=s(function(){for(var d=this.iterator,f=this.mapper,h,g;;){if(g=this.inner)try{if(h=n(e(g.next,g.iterator)),!h.done)return h.value;this.inner=null}catch(m){a(d,"throw",m)}if(h=n(e(this.next,d)),this.done=!!h.done)return;try{this.inner=o(f(h.value,this.counter++),!1)}catch(m){a(d,"throw",m)}}});return r({target:"Iterator",proto:!0,real:!0,forced:c},{flatMap:function(f){return n(this),t(f),new l(i(this),{mapper:f,inner:null})}}),f$}var g$={},v$;function pne(){if(v$)return g$;v$=1;var r=H(),e=cn(),t=jt(),n=Ze(),i=Jr();return r({target:"Iterator",proto:!0,real:!0},{forEach:function(s){n(this),t(s);var a=i(this),c=0;e(a,function(l){s(l,c++)},{IS_RECORD:!0})}}),g$}var m$={},y$;function gne(){if(y$)return m$;y$=1;var r=H(),e=Qe(),t=Zt(),n=Ti(),i=Bd().IteratorPrototype,o=gu(),s=fne(),a=Xt(),c=o(function(){return e(this.next,this.iterator)},!0);return r({target:"Iterator",stat:!0,forced:a},{from:function(d){var f=s(typeof d=="string"?t(d):d,!0);return n(i,f.iterator)?f.iterator:new c(f)}}),m$}var S$={},K0,x$;function vne(){if(x$)return K0;x$=1;var r=Qe(),e=jt(),t=Ze(),n=Jr(),i=gu(),o=RT(),s=i(function(){var a=this.iterator,c=t(r(this.next,a)),l=this.done=!!c.done;if(!l)return o(a,this.mapper,[c.value,this.counter++],!0)});return K0=function(c){return t(this),e(c),new s(n(this),{mapper:c})},K0}var _$;function mne(){if(_$)return S$;_$=1;var r=H(),e=vne(),t=Xt();return r({target:"Iterator",proto:!0,real:!0,forced:t},{map:e}),S$}var w$={},b$;function yne(){if(b$)return w$;b$=1;var r=H(),e=cn(),t=jt(),n=Ze(),i=Jr(),o=TypeError;return r({target:"Iterator",proto:!0,real:!0},{reduce:function(a){n(this),t(a);var c=i(this),l=arguments.length<2,d=l?void 0:arguments[1],f=0;if(e(c,function(h){l?(l=!1,d=h):d=a(d,h,f),f++},{IS_RECORD:!0}),l)throw new o("Reduce of empty iterator with no initial value");return d}}),w$}var E$={},I$;function Sne(){if(I$)return E$;I$=1;var r=H(),e=cn(),t=jt(),n=Ze(),i=Jr();return r({target:"Iterator",proto:!0,real:!0},{some:function(s){n(this),t(s);var a=i(this),c=0;return e(a,function(l,d){if(s(l,c++))return d()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}}),E$}var P$={},C$;function xne(){if(C$)return P$;C$=1;var r=H(),e=Qe(),t=Ze(),n=Jr(),i=Zh(),o=Qh(),s=gu(),a=dl(),c=Xt(),l=s(function(){var d=this.iterator;if(!this.remaining--)return this.done=!0,a(d,"normal",void 0);var f=t(e(this.next,d)),h=this.done=!!f.done;if(!h)return f.value});return r({target:"Iterator",proto:!0,real:!0,forced:c},{take:function(f){t(this);var h=o(i(+f));return new l(n(this),{remaining:h})}}),P$}var T$={},A$;function _ne(){if(A$)return T$;A$=1;var r=H(),e=Ze(),t=cn(),n=Jr(),i=[].push;return r({target:"Iterator",proto:!0,real:!0},{toArray:function(){var s=[];return t(n(e(this)),i,{that:s,IS_RECORD:!0}),s}}),T$}var R$={},k$;function Ewe(){if(k$)return R$;k$=1;var r=Xe(),e=yo();return e(r.JSON,"JSON",!0),R$}var O$={},M$={},G0={exports:{}},V0,j$;function NT(){if(j$)return V0;j$=1;var r=Fe();return V0=r(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),V0}var Y0,D$;function $T(){if(D$)return Y0;D$=1;var r=Fe(),e=Lt(),t=Ci(),n=NT(),i=Object.isExtensible,o=r(function(){});return Y0=o||n?function(a){return!e(a)||n&&t(a)==="ArrayBuffer"?!1:i?i(a):!0}:i,Y0}var X0,L$;function hl(){if(L$)return X0;L$=1;var r=Fe();return X0=!r(function(){return Object.isExtensible(Object.preventExtensions({}))}),X0}var F$;function vu(){if(F$)return G0.exports;F$=1;var r=H(),e=Ie(),t=Lh(),n=Lt(),i=Kt(),o=Or().f,s=cu(),a=bT(),c=$T(),l=au(),d=hl(),f=!1,h=l("meta"),g=0,m=function(b){o(b,h,{value:{objectID:"O"+g++,weakData:{}}})},y=function(b,P){if(!n(b))return typeof b=="symbol"?b:(typeof b=="string"?"S":"P")+b;if(!i(b,h)){if(!c(b))return"F";if(!P)return"E";m(b)}return b[h].objectID},x=function(b,P){if(!i(b,h)){if(!c(b))return!0;if(!P)return!1;m(b)}return b[h].weakData},_=function(b){return d&&f&&c(b)&&!i(b,h)&&m(b),b},w=function(){I.enable=function(){},f=!0;var b=s.f,P=e([].splice),C={};C[h]=1,b(C).length&&(s.f=function(k){for(var O=b(k),L=0,j=O.length;L<j;L++)if(O[L]===h){P(O,L,1);break}return O},r({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:a.f}))},I=G0.exports={enable:w,fastKey:y,getWeakData:x,onFreeze:_};return t[h]=!0,G0.exports}var Z0,N$;function iy(){if(N$)return Z0;N$=1;var r=H(),e=Xe(),t=Ie(),n=Nh(),i=wr(),o=vu(),s=cn(),a=Wi(),c=Ut(),l=Mn(),d=Lt(),f=Fe(),h=Xm(),g=yo(),m=du();return Z0=function(y,x,_){var w=y.indexOf("Map")!==-1,I=y.indexOf("Weak")!==-1,b=w?"set":"add",P=e[y],C=P&&P.prototype,k=P,O={},L=function(W){var G=t(C[W]);i(C,W,W==="add"?function(V){return G(this,V===0?0:V),this}:W==="delete"?function(z){return I&&!d(z)?!1:G(this,z===0?0:z)}:W==="get"?function(V){return I&&!d(V)?void 0:G(this,V===0?0:V)}:W==="has"?function(V){return I&&!d(V)?!1:G(this,V===0?0:V)}:function(V,J){return G(this,V===0?0:V,J),this})},j=n(y,!c(P)||!(I||C.forEach&&!f(function(){new P().entries().next()})));if(j)k=_.getConstructor(x,y,w,b),o.enable();else if(n(y,!0)){var F=new k,$=F[b](I?{}:-0,1)!==F,D=f(function(){F.has(1)}),N=h(function(W){new P(W)}),B=!I&&f(function(){for(var W=new P,G=5;G--;)W[b](G,G);return!W.has(-0)});N||(k=x(function(W,G){a(W,C);var z=m(new P,W,k);return l(G)||s(G,z[b],{that:z,AS_ENTRIES:w}),z}),k.prototype=C,C.constructor=k),(D||B)&&(L("delete"),L("has"),w&&L("get")),(B||$)&&L(b),I&&C.clear&&delete C.clear}return O[y]=k,r({global:!0,constructor:!0,forced:k!==P},O),g(k,y),I||_.setStrong(k,y,w),k},Z0}var Q0,$$;function wne(){if($$)return Q0;$$=1;var r=En(),e=Yr(),t=qs(),n=Ar(),i=Wi(),o=Mn(),s=cn(),a=kT(),c=Hn(),l=pu(),d=Et(),f=vu().fastKey,h=_r(),g=h.set,m=h.getterFor;return Q0={getConstructor:function(y,x,_,w){var I=y(function(O,L){i(O,b),g(O,{type:x,index:r(null),first:null,last:null,size:0}),d||(O.size=0),o(L)||s(L,O[w],{that:O,AS_ENTRIES:_})}),b=I.prototype,P=m(x),C=function(O,L,j){var F=P(O),$=k(O,L),D,N;return $?$.value=j:(F.last=$={index:N=f(L,!0),key:L,value:j,previous:D=F.last,next:null,removed:!1},F.first||(F.first=$),D&&(D.next=$),d?F.size++:O.size++,N!=="F"&&(F.index[N]=$)),O},k=function(O,L){var j=P(O),F=f(L),$;if(F!=="F")return j.index[F];for($=j.first;$;$=$.next)if($.key===L)return $};return t(b,{clear:function(){for(var L=this,j=P(L),F=j.first;F;)F.removed=!0,F.previous&&(F.previous=F.previous.next=null),F=F.next;j.first=j.last=null,j.index=r(null),d?j.size=0:L.size=0},delete:function(O){var L=this,j=P(L),F=k(L,O);if(F){var $=F.next,D=F.previous;delete j.index[F.index],F.removed=!0,D&&(D.next=$),$&&($.previous=D),j.first===F&&(j.first=$),j.last===F&&(j.last=D),d?j.size--:L.size--}return!!F},forEach:function(L){for(var j=P(this),F=n(L,arguments.length>1?arguments[1]:void 0),$;$=$?$.next:j.first;)for(F($.value,$.key,this);$&&$.removed;)$=$.previous},has:function(L){return!!k(this,L)}}),t(b,_?{get:function(L){var j=k(this,L);return j&&j.value},set:function(L,j){return C(this,L===0?0:L,j)}}:{add:function(L){return C(this,L=L===0?0:L,L)}}),d&&e(b,"size",{configurable:!0,get:function(){return P(this).size}}),I},setStrong:function(y,x,_){var w=x+" Iterator",I=m(x),b=m(w);a(y,x,function(P,C){g(this,{type:w,target:P,state:I(P),kind:C,last:null})},function(){for(var P=b(this),C=P.kind,k=P.last;k&&k.removed;)k=k.previous;return!P.target||!(P.last=k=k?k.next:P.state.first)?(P.target=null,c(void 0,!0)):c(C==="keys"?k.key:C==="values"?k.value:[k.key,k.value],!1)},_?"entries":"values",!_,!0),l(x)}},Q0}var q$;function Iwe(){if(q$)return M$;q$=1;var r=iy(),e=wne();return r("Map",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},e),M$}var B$;function qT(){return B$||(B$=1,Iwe()),O$}var U$={},J0,z$;function Wn(){if(z$)return J0;z$=1;var r=Ie(),e=Map.prototype;return J0={Map,set:r(e.set),get:r(e.get),has:r(e.has),remove:r(e.delete),proto:e},J0}var H$;function bne(){if(H$)return U$;H$=1;var r=H(),e=Ie(),t=jt(),n=qr(),i=cn(),o=Wn(),s=Xt(),a=Fe(),c=o.Map,l=o.has,d=o.get,f=o.set,h=e([].push),g=s||a(function(){return c.groupBy("ab",function(m){return m}).get("a").length!==1});return r({target:"Map",stat:!0,forced:s||g},{groupBy:function(y,x){n(y),t(x);var _=new c,w=0;return i(y,function(I){var b=x(I,w++);l(_,b)?h(d(_,b),I):f(_,b,[I])}),_}}),U$}var W$={},e1,K$;function Ene(){if(K$)return e1;K$=1;var r=Math.log;return e1=Math.log1p||function(t){var n=+t;return n>-1e-8&&n<1e-8?n-n*n/2:r(1+n)},e1}var G$;function Pwe(){if(G$)return W$;G$=1;var r=H(),e=Ene(),t=Math.acosh,n=Math.log,i=Math.sqrt,o=Math.LN2,s=!t||Math.floor(t(Number.MAX_VALUE))!==710||t(1/0)!==1/0;return r({target:"Math",stat:!0,forced:s},{acosh:function(c){var l=+c;return l<1?NaN:l>9490626562425156e-8?n(l)+o:e(l-1+i(l-1)*i(l+1))}}),W$}var V$={},Y$;function Cwe(){if(Y$)return V$;Y$=1;var r=H(),e=Math.asinh,t=Math.log,n=Math.sqrt;function i(s){var a=+s;return!isFinite(a)||a===0?a:a<0?-i(-a):t(a+n(a*a+1))}var o=!(e&&1/e(0)>0);return r({target:"Math",stat:!0,forced:o},{asinh:i}),V$}var X$={},Z$;function Twe(){if(Z$)return X$;Z$=1;var r=H(),e=Math.atanh,t=Math.log,n=!(e&&1/e(-0)<0);return r({target:"Math",stat:!0,forced:n},{atanh:function(o){var s=+o;return s===0?s:t((1+s)/(1-s))/2}}),X$}var Q$={},J$;function Awe(){if(J$)return Q$;J$=1;var r=H(),e=DT(),t=Math.abs,n=Math.pow;return r({target:"Math",stat:!0},{cbrt:function(o){var s=+o;return e(s)*n(t(s),1/3)}}),Q$}var eq={},tq;function Rwe(){if(tq)return eq;tq=1;var r=H(),e=Math.floor,t=Math.log,n=Math.LOG2E;return r({target:"Math",stat:!0},{clz32:function(o){var s=o>>>0;return s?31-e(t(s+.5)*n):32}}),eq}var rq={},t1,nq;function oy(){if(nq)return t1;nq=1;var r=Math.expm1,e=Math.exp;return t1=!r||r(10)>22025.465794806718||r(10)<22025.465794806718||r(-2e-17)!==-2e-17?function(n){var i=+n;return i===0?i:i>-1e-6&&i<1e-6?i+i*i/2:e(i)-1}:r,t1}var iq;function kwe(){if(iq)return rq;iq=1;var r=H(),e=oy(),t=Math.cosh,n=Math.abs,i=Math.E,o=!t||t(710)===1/0;return r({target:"Math",stat:!0,forced:o},{cosh:function(a){var c=e(n(a)-1)+1;return(c+1/(c*i*i))*(i/2)}}),rq}var oq={},sq;function Owe(){if(sq)return oq;sq=1;var r=H(),e=oy();return r({target:"Math",stat:!0,forced:e!==Math.expm1},{expm1:e}),oq}var aq={},cq;function Mwe(){if(cq)return aq;cq=1;var r=H(),e=LT();return r({target:"Math",stat:!0},{fround:e}),aq}var lq={},uq;function Ine(){if(uq)return lq;uq=1;var r=H(),e=Kre(),t=.0009765625,n=65504,i=6103515625e-14;return r({target:"Math",stat:!0},{f16round:function(s){return e(s,t,n,i)}}),lq}var dq={},fq;function jwe(){if(fq)return dq;fq=1;var r=H(),e=Math.hypot,t=Math.abs,n=Math.sqrt,i=!!e&&e(1/0,NaN)!==1/0;return r({target:"Math",stat:!0,arity:2,forced:i},{hypot:function(s,a){for(var c=0,l=0,d=arguments.length,f=0,h,g;l<d;)h=t(arguments[l++]),f<h?(g=f/h,c=c*g*g+1,f=h):h>0?(g=h/f,c+=g*g):c+=h;return f===1/0?1/0:f*n(c)}}),dq}var hq={},pq;function Dwe(){if(pq)return hq;pq=1;var r=H(),e=Fe(),t=Math.imul,n=e(function(){return t(4294967295,5)!==-5||t.length!==2});return r({target:"Math",stat:!0,forced:n},{imul:function(o,s){var a=65535,c=+o,l=+s,d=a&c,f=a&l;return 0|d*f+((a&c>>>16)*f+d*(a&l>>>16)<<16>>>0)}}),hq}var gq={},r1,vq;function Pne(){if(vq)return r1;vq=1;var r=Math.log,e=Math.LOG10E;return r1=Math.log10||function(n){return r(n)*e},r1}var mq;function Lwe(){if(mq)return gq;mq=1;var r=H(),e=Pne();return r({target:"Math",stat:!0},{log10:e}),gq}var yq={},Sq;function Fwe(){if(Sq)return yq;Sq=1;var r=H(),e=Ene();return r({target:"Math",stat:!0},{log1p:e}),yq}var xq={},_q;function Nwe(){if(_q)return xq;_q=1;var r=H(),e=Yre();return r({target:"Math",stat:!0},{log2:e}),xq}var wq={},bq;function $we(){if(bq)return wq;bq=1;var r=H(),e=DT();return r({target:"Math",stat:!0},{sign:e}),wq}var Eq={},Iq;function qwe(){if(Iq)return Eq;Iq=1;var r=H(),e=Fe(),t=oy(),n=Math.abs,i=Math.exp,o=Math.E,s=e(function(){return Math.sinh(-2e-17)!==-2e-17});return r({target:"Math",stat:!0,forced:s},{sinh:function(c){var l=+c;return n(l)<1?(t(l)-t(-l))/2:(i(l-1)-i(-l-1))*(o/2)}}),Eq}var Pq={},Cq;function Bwe(){if(Cq)return Pq;Cq=1;var r=H(),e=oy(),t=Math.exp;return r({target:"Math",stat:!0},{tanh:function(i){var o=+i,s=e(o),a=e(-o);return s===1/0?1:a===1/0?-1:(s-a)/(t(o)+t(-o))}}),Pq}var Tq={},Aq;function Uwe(){if(Aq)return Tq;Aq=1;var r=yo();return r(Math,"Math",!0),Tq}var Rq={},kq;function zwe(){if(kq)return Rq;kq=1;var r=H(),e=pee();return r({target:"Math",stat:!0},{trunc:e}),Rq}var Oq={},n1,Mq;function sy(){if(Mq)return n1;Mq=1;var r=Ie();return n1=r(1 .valueOf),n1}var i1,jq;function zd(){return jq||(jq=1,i1=`
99
- \v\f\r                 \u2028\u2029\uFEFF`),i1}var o1,Dq;function Hd(){if(Dq)return o1;Dq=1;var r=Ie(),e=qr(),t=Nt(),n=zd(),i=r("".replace),o=RegExp("^["+n+"]+"),s=RegExp("(^|[^"+n+"])["+n+"]+$"),a=function(c){return function(l){var d=t(e(l));return c&1&&(d=i(d,o,"")),c&2&&(d=i(d,s,"$1")),d}};return o1={start:a(1),end:a(2),trim:a(3)},o1}var Lq;function Hwe(){if(Lq)return Oq;Lq=1;var r=H(),e=Xt(),t=Et(),n=Xe(),i=ET(),o=Ie(),s=Nh(),a=Kt(),c=du(),l=Ti(),d=sl(),f=Im(),h=Fe(),g=cu().f,m=ni().f,y=Or().f,x=sy(),_=Hd().trim,w="Number",I=n[w],b=i[w],P=I.prototype,C=n.TypeError,k=o("".slice),O=o("".charCodeAt),L=function(B){var W=f(B,"number");return typeof W=="bigint"?W:j(W)},j=function(B){var W=f(B,"number"),G,z,V,J,K,Z,ee,re;if(d(W))throw new C("Cannot convert a Symbol value to a number");if(typeof W=="string"&&W.length>2){if(W=_(W),G=O(W,0),G===43||G===45){if(z=O(W,2),z===88||z===120)return NaN}else if(G===48){switch(O(W,1)){case 66:case 98:V=2,J=49;break;case 79:case 111:V=8,J=55;break;default:return+W}for(K=k(W,2),Z=K.length,ee=0;ee<Z;ee++)if(re=O(K,ee),re<48||re>J)return NaN;return parseInt(K,V)}}return+W},F=s(w,!I(" 0o1")||!I("0b1")||I("+0x1")),$=function(B){return l(P,B)&&h(function(){x(B)})},D=function(W){var G=arguments.length<1?0:I(L(W));return $(this)?c(Object(G),this,D):G};D.prototype=P,F&&!e&&(P.constructor=D),r({global:!0,constructor:!0,wrap:!0,forced:F},{Number:D});var N=function(B,W){for(var G=t?g(W):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),z=0,V;G.length>z;z++)a(W,V=G[z])&&!a(B,V)&&y(B,V,m(W,V))};return e&&b&&N(i[w],b),(F||e)&&N(i[w],I),Oq}var Fq={},Nq;function Wwe(){if(Nq)return Fq;Nq=1;var r=H();return r({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)}),Fq}var $q={},s1,qq;function Cne(){if(qq)return s1;qq=1;var r=Xe(),e=r.isFinite;return s1=Number.isFinite||function(n){return typeof n=="number"&&e(n)},s1}var Bq;function Kwe(){if(Bq)return $q;Bq=1;var r=H(),e=Cne();return r({target:"Number",stat:!0},{isFinite:e}),$q}var Uq={},a1,zq;function BT(){if(zq)return a1;zq=1;var r=Lt(),e=Math.floor;return a1=Number.isInteger||function(n){return!r(n)&&isFinite(n)&&e(n)===n},a1}var Hq;function Gwe(){if(Hq)return Uq;Hq=1;var r=H(),e=BT();return r({target:"Number",stat:!0},{isInteger:e}),Uq}var Wq={},Kq;function Vwe(){if(Kq)return Wq;Kq=1;var r=H();return r({target:"Number",stat:!0},{isNaN:function(t){return t!==t}}),Wq}var Gq={},Vq;function Ywe(){if(Vq)return Gq;Vq=1;var r=H(),e=BT(),t=Math.abs;return r({target:"Number",stat:!0},{isSafeInteger:function(i){return e(i)&&t(i)<=9007199254740991}}),Gq}var Yq={},Xq;function Xwe(){if(Xq)return Yq;Xq=1;var r=H();return r({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991}),Yq}var Zq={},Qq;function Zwe(){if(Qq)return Zq;Qq=1;var r=H();return r({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MIN_SAFE_INTEGER:-9007199254740991}),Zq}var Jq={},c1,e5;function Tne(){if(e5)return c1;e5=1;var r=Xe(),e=Fe(),t=Ie(),n=Nt(),i=Hd().trim,o=zd(),s=t("".charAt),a=r.parseFloat,c=r.Symbol,l=c&&c.iterator,d=1/a(o+"-0")!==-1/0||l&&!e(function(){a(Object(l))});return c1=d?function(h){var g=i(n(h)),m=a(g);return m===0&&s(g,0)==="-"?-0:m}:a,c1}var t5;function Qwe(){if(t5)return Jq;t5=1;var r=H(),e=Tne();return r({target:"Number",stat:!0,forced:Number.parseFloat!==e},{parseFloat:e}),Jq}var r5={},l1,n5;function Ane(){if(n5)return l1;n5=1;var r=Xe(),e=Fe(),t=Ie(),n=Nt(),i=Hd().trim,o=zd(),s=r.parseInt,a=r.Symbol,c=a&&a.iterator,l=/^[+-]?0x/i,d=t(l.exec),f=s(o+"08")!==8||s(o+"0x16")!==22||c&&!e(function(){s(Object(c))});return l1=f?function(g,m){var y=i(n(g));return s(y,m>>>0||(d(l,y)?16:10))}:s,l1}var i5;function Jwe(){if(i5)return r5;i5=1;var r=H(),e=Ane();return r({target:"Number",stat:!0,forced:Number.parseInt!==e},{parseInt:e}),r5}var o5={},s5;function ebe(){if(s5)return o5;s5=1;var r=H(),e=Ie(),t=Vr(),n=sy(),i=ry(),o=Pne(),s=Fe(),a=RangeError,c=String,l=isFinite,d=Math.abs,f=Math.floor,h=Math.pow,g=Math.round,m=e(1 .toExponential),y=e(i),x=e("".slice),_=m(-69e-12,4)==="-6.9000e-11"&&m(1.255,2)==="1.25e+0"&&m(12345,3)==="1.235e+4"&&m(25,0)==="3e+1",w=function(){return s(function(){m(1,1/0)})&&s(function(){m(1,-1/0)})},I=function(){return!s(function(){m(1/0,1/0),m(NaN,1/0)})},b=!_||!w()||!I();return r({target:"Number",proto:!0,forced:b},{toExponential:function(C){var k=n(this);if(C===void 0)return m(k);var O=t(C);if(!l(k))return String(k);if(O<0||O>20)throw new a("Incorrect fraction digits");if(_)return m(k,O);var L="",j,F,$,D;if(k<0&&(L="-",k=-k),k===0)F=0,j=y("0",O+1);else{var N=o(k);F=f(N);var B=h(10,F-O),W=g(k/B);2*k>=(2*W+1)*B&&(W+=1),W>=h(10,O+1)&&(W/=10,F+=1),j=c(W)}return O!==0&&(j=x(j,0,1)+"."+x(j,1)),F===0?($="+",D="0"):($=F>0?"+":"-",D=c(d(F))),j+="e"+$+D,L+j}}),o5}var a5={},c5;function tbe(){if(c5)return a5;c5=1;var r=H(),e=Ie(),t=Vr(),n=sy(),i=ry(),o=Fe(),s=RangeError,a=String,c=Math.floor,l=e(i),d=e("".slice),f=e(1 .toFixed),h=function(w,I,b){return I===0?b:I%2===1?h(w,I-1,b*w):h(w*w,I/2,b)},g=function(w){for(var I=0,b=w;b>=4096;)I+=12,b/=4096;for(;b>=2;)I+=1,b/=2;return I},m=function(w,I,b){for(var P=-1,C=b;++P<6;)C+=I*w[P],w[P]=C%1e7,C=c(C/1e7)},y=function(w,I){for(var b=6,P=0;--b>=0;)P+=w[b],w[b]=c(P/I),P=P%I*1e7},x=function(w){for(var I=6,b="";--I>=0;)if(b!==""||I===0||w[I]!==0){var P=a(w[I]);b=b===""?P:b+l("0",7-P.length)+P}return b},_=o(function(){return f(8e-5,3)!=="0.000"||f(.9,0)!=="1"||f(1.255,2)!=="1.25"||f(0xde0b6b3a7640080,0)!=="1000000000000000128"})||!o(function(){f({})});return r({target:"Number",proto:!0,forced:_},{toFixed:function(I){var b=n(this),P=t(I),C=[0,0,0,0,0,0],k="",O="0",L,j,F,$;if(P<0||P>20)throw new s("Incorrect fraction digits");if(b!==b)return"NaN";if(b<=-1e21||b>=1e21)return a(b);if(b<0&&(k="-",b=-b),b>1e-21)if(L=g(b*h(2,69,1))-69,j=L<0?b*h(2,-L,1):b/h(2,L,1),j*=4503599627370496,L=52-L,L>0){for(m(C,0,j),F=P;F>=7;)m(C,1e7,0),F-=7;for(m(C,h(10,F,1),0),F=L-1;F>=23;)y(C,1<<23),F-=23;y(C,1<<F),m(C,1,1),y(C,2),O=x(C)}else m(C,0,j),m(C,1<<-L,0),O=x(C)+l("0",P);return P>0?($=O.length,O=k+($<=P?"0."+l("0",P-$)+O:d(O,0,$-P)+"."+d(O,$-P))):O=k+O,O}}),a5}var l5={},u5;function rbe(){if(u5)return l5;u5=1;var r=H(),e=Ie(),t=Fe(),n=sy(),i=e(1 .toPrecision),o=t(function(){return i(1,void 0)!=="1"})||!t(function(){i({})});return r({target:"Number",proto:!0,forced:o},{toPrecision:function(a){return a===void 0?i(n(this)):i(n(this),a)}}),l5}var d5={},u1,f5;function Rne(){if(f5)return u1;f5=1;var r=Et(),e=Ie(),t=Qe(),n=Fe(),i=Md(),o=Rm(),s=bm(),a=Zt(),c=ol(),l=Object.assign,d=Object.defineProperty,f=e([].concat);return u1=!l||n(function(){if(r&&l({b:1},l(d({},"a",{enumerable:!0,get:function(){d(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var h={},g={},m=Symbol("assign detection"),y="abcdefghijklmnopqrst";return h[m]=7,y.split("").forEach(function(x){g[x]=x}),l({},h)[m]!==7||i(l({},g)).join("")!==y})?function(g,m){for(var y=a(g),x=arguments.length,_=1,w=o.f,I=s.f;x>_;)for(var b=c(arguments[_++]),P=w?f(i(b),w(b)):i(b),C=P.length,k=0,O;C>k;)O=P[k++],(!r||t(I,b,O))&&(y[O]=b[O]);return y}:l,u1}var h5;function nbe(){if(h5)return d5;h5=1;var r=H(),e=Rne();return r({target:"Object",stat:!0,arity:2,forced:Object.assign!==e},{assign:e}),d5}var p5={},g5;function ibe(){if(g5)return p5;g5=1;var r=H(),e=Et(),t=En();return r({target:"Object",stat:!0,sham:!e},{create:t}),p5}var v5={},d1,m5;function ay(){if(m5)return d1;m5=1;var r=Xt(),e=Xe(),t=Fe(),n=jT();return d1=r||!t(function(){if(!(n&&n<535)){var i=Math.random();__defineSetter__.call(null,i,function(){}),delete e[i]}}),d1}var y5;function obe(){if(y5)return v5;y5=1;var r=H(),e=Et(),t=ay(),n=jt(),i=Zt(),o=Or();return e&&r({target:"Object",proto:!0,forced:t},{__defineGetter__:function(a,c){o.f(i(this),a,{get:n(c),enumerable:!0,configurable:!0})}}),v5}var S5={},x5;function sbe(){if(x5)return S5;x5=1;var r=H(),e=Et(),t=zC().f;return r({target:"Object",stat:!0,forced:Object.defineProperties!==t,sham:!e},{defineProperties:t}),S5}var _5={},w5;function abe(){if(w5)return _5;w5=1;var r=H(),e=Et(),t=Or().f;return r({target:"Object",stat:!0,forced:Object.defineProperty!==t,sham:!e},{defineProperty:t}),_5}var b5={},E5;function cbe(){if(E5)return b5;E5=1;var r=H(),e=Et(),t=ay(),n=jt(),i=Zt(),o=Or();return e&&r({target:"Object",proto:!0,forced:t},{__defineSetter__:function(a,c){o.f(i(this),a,{set:n(c),enumerable:!0,configurable:!0})}}),b5}var I5={},f1,P5;function kne(){if(P5)return f1;P5=1;var r=Et(),e=Fe(),t=Ie(),n=Fn(),i=Md(),o=jn(),s=bm().f,a=t(s),c=t([].push),l=r&&e(function(){var f=Object.create(null);return f[2]=2,!a(f,2)}),d=function(f){return function(h){for(var g=o(h),m=i(g),y=l&&n(g)===null,x=m.length,_=0,w=[],I;x>_;)I=m[_++],(!r||(y?I in g:a(g,I)))&&c(w,f?[I,g[I]]:g[I]);return w}};return f1={entries:d(!0),values:d(!1)},f1}var C5;function lbe(){if(C5)return I5;C5=1;var r=H(),e=kne().entries;return r({target:"Object",stat:!0},{entries:function(n){return e(n)}}),I5}var T5={},A5;function ube(){if(A5)return T5;A5=1;var r=H(),e=hl(),t=Fe(),n=Lt(),i=vu().onFreeze,o=Object.freeze,s=t(function(){o(1)});return r({target:"Object",stat:!0,forced:s,sham:!e},{freeze:function(c){return o&&n(c)?o(i(c)):c}}),T5}var R5={},k5;function dbe(){if(k5)return R5;k5=1;var r=H(),e=cn(),t=Ns();return r({target:"Object",stat:!0},{fromEntries:function(i){var o={};return e(i,function(s,a){t(o,s,a)},{AS_ENTRIES:!0}),o}}),R5}var O5={},M5;function fbe(){if(M5)return O5;M5=1;var r=H(),e=Fe(),t=jn(),n=ni().f,i=Et(),o=!i||e(function(){n(1)});return r({target:"Object",stat:!0,forced:o,sham:!i},{getOwnPropertyDescriptor:function(a,c){return n(t(a),c)}}),O5}var j5={},D5;function hbe(){if(D5)return j5;D5=1;var r=H(),e=Et(),t=UC(),n=jn(),i=ni(),o=Ns();return r({target:"Object",stat:!0,sham:!e},{getOwnPropertyDescriptors:function(a){for(var c=n(a),l=i.f,d=t(c),f={},h=0,g,m;d.length>h;)m=l(c,g=d[h++]),m!==void 0&&o(f,g,m);return f}}),j5}var L5={},F5;function pbe(){if(F5)return L5;F5=1;var r=H(),e=Fe(),t=bT().f,n=e(function(){return!Object.getOwnPropertyNames(1)});return r({target:"Object",stat:!0,forced:n},{getOwnPropertyNames:t}),L5}var N5={},$5;function gbe(){if($5)return N5;$5=1;var r=H(),e=Fe(),t=Zt(),n=Fn(),i=CT(),o=e(function(){n(1)});return r({target:"Object",stat:!0,forced:o,sham:!i},{getPrototypeOf:function(a){return n(t(a))}}),N5}var q5={},B5;function One(){if(B5)return q5;B5=1;var r=H(),e=Mt(),t=Ie(),n=jt(),i=qr(),o=lc(),s=cn(),a=Fe(),c=Object.groupBy,l=e("Object","create"),d=t([].push),f=!c||a(function(){return c("ab",function(h){return h}).a.length!==1});return r({target:"Object",stat:!0,forced:f},{groupBy:function(g,m){i(g),n(m);var y=l(null),x=0;return s(g,function(_){var w=o(m(_,x++));w in y?d(y[w],_):y[w]=[_]}),y}}),q5}var U5={},z5;function Mne(){if(z5)return U5;z5=1;var r=H(),e=Kt();return r({target:"Object",stat:!0},{hasOwn:e}),U5}var H5={},h1,W5;function UT(){return W5||(W5=1,h1=Object.is||function(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}),h1}var K5;function vbe(){if(K5)return H5;K5=1;var r=H(),e=UT();return r({target:"Object",stat:!0},{is:e}),H5}var G5={},V5;function mbe(){if(V5)return G5;V5=1;var r=H(),e=$T();return r({target:"Object",stat:!0,forced:Object.isExtensible!==e},{isExtensible:e}),G5}var Y5={},X5;function ybe(){if(X5)return Y5;X5=1;var r=H(),e=Fe(),t=Lt(),n=Ci(),i=NT(),o=Object.isFrozen,s=i||e(function(){});return r({target:"Object",stat:!0,forced:s},{isFrozen:function(c){return!t(c)||i&&n(c)==="ArrayBuffer"?!0:o?o(c):!1}}),Y5}var Z5={},Q5;function Sbe(){if(Q5)return Z5;Q5=1;var r=H(),e=Fe(),t=Lt(),n=Ci(),i=NT(),o=Object.isSealed,s=i||e(function(){});return r({target:"Object",stat:!0,forced:s},{isSealed:function(c){return!t(c)||i&&n(c)==="ArrayBuffer"?!0:o?o(c):!1}}),Z5}var J5={},eB;function xbe(){if(eB)return J5;eB=1;var r=H(),e=Zt(),t=Md(),n=Fe(),i=n(function(){t(1)});return r({target:"Object",stat:!0,forced:i},{keys:function(s){return t(e(s))}}),J5}var tB={},rB;function _be(){if(rB)return tB;rB=1;var r=H(),e=Et(),t=ay(),n=Zt(),i=lc(),o=Fn(),s=ni().f;return e&&r({target:"Object",proto:!0,forced:t},{__lookupGetter__:function(c){var l=n(this),d=i(c),f;do if(f=s(l,d))return f.get;while(l=o(l))}}),tB}var nB={},iB;function wbe(){if(iB)return nB;iB=1;var r=H(),e=Et(),t=ay(),n=Zt(),i=lc(),o=Fn(),s=ni().f;return e&&r({target:"Object",proto:!0,forced:t},{__lookupSetter__:function(c){var l=n(this),d=i(c),f;do if(f=s(l,d))return f.set;while(l=o(l))}}),nB}var oB={},sB;function bbe(){if(sB)return oB;sB=1;var r=H(),e=Lt(),t=vu().onFreeze,n=hl(),i=Fe(),o=Object.preventExtensions,s=i(function(){o(1)});return r({target:"Object",stat:!0,forced:s,sham:!n},{preventExtensions:function(c){return o&&e(c)?o(t(c)):c}}),oB}var aB={},cB;function Ebe(){if(cB)return aB;cB=1;var r=Et(),e=Yr(),t=Lt(),n=wre(),i=Zt(),o=qr(),s=Object.getPrototypeOf,a=Object.setPrototypeOf,c=Object.prototype,l="__proto__";if(r&&s&&a&&!(l in c))try{e(c,l,{configurable:!0,get:function(){return s(i(this))},set:function(f){var h=o(this);n(f)&&t(h)&&a(h,f)}})}catch{}return aB}var lB={},uB;function Ibe(){if(uB)return lB;uB=1;var r=H(),e=Lt(),t=vu().onFreeze,n=hl(),i=Fe(),o=Object.seal,s=i(function(){o(1)});return r({target:"Object",stat:!0,forced:s,sham:!n},{seal:function(c){return o&&e(c)?o(t(c)):c}}),lB}var dB={},fB;function Pbe(){if(fB)return dB;fB=1;var r=H(),e=Fs();return r({target:"Object",stat:!0},{setPrototypeOf:e}),dB}var hB={},p1,pB;function Cbe(){if(pB)return p1;pB=1;var r=WC(),e=vo();return p1=r?{}.toString:function(){return"[object "+e(this)+"]"},p1}var gB;function Tbe(){if(gB)return hB;gB=1;var r=WC(),e=wr(),t=Cbe();return r||e(Object.prototype,"toString",t,{unsafe:!0}),hB}var vB={},mB;function Abe(){if(mB)return vB;mB=1;var r=H(),e=kne().values;return r({target:"Object",stat:!0},{values:function(n){return e(n)}}),vB}var yB={},SB;function Rbe(){if(SB)return yB;SB=1;var r=H(),e=Tne();return r({global:!0,forced:parseFloat!==e},{parseFloat:e}),yB}var xB={},_B;function kbe(){if(_B)return xB;_B=1;var r=H(),e=Ane();return r({global:!0,forced:parseInt!==e},{parseInt:e}),xB}var wB={},bB={},g1,EB;function cy(){if(EB)return g1;EB=1;var r=Pa(),e=su(),t=TypeError;return g1=function(n){if(r(n))return n;throw new t(e(n)+" is not a constructor")},g1}var v1,IB;function ly(){if(IB)return v1;IB=1;var r=Ze(),e=cy(),t=Mn(),n=Tt(),i=n("species");return v1=function(o,s){var a=r(o).constructor,c;return a===void 0||t(c=r(a)[i])?s:e(c)},v1}var m1,PB;function us(){if(PB)return m1;PB=1;var r=TypeError;return m1=function(e,t){if(e<t)throw new r("Not enough arguments");return e},m1}var y1,CB;function jne(){if(CB)return y1;CB=1;var r=wa();return y1=/(?:ipad|iphone|ipod).*applewebkit/i.test(r),y1}var S1,TB;function uy(){if(TB)return S1;TB=1;var r=Xe(),e=zi(),t=Ar(),n=Ut(),i=Kt(),o=Fe(),s=vee(),a=Bo(),c=Pm(),l=us(),d=jne(),f=Ud(),h=r.setImmediate,g=r.clearImmediate,m=r.process,y=r.Dispatch,x=r.Function,_=r.MessageChannel,w=r.String,I=0,b={},P="onreadystatechange",C,k,O,L;o(function(){C=r.location});var j=function(N){if(i(b,N)){var B=b[N];delete b[N],B()}},F=function(N){return function(){j(N)}},$=function(N){j(N.data)},D=function(N){r.postMessage(w(N),C.protocol+"//"+C.host)};return(!h||!g)&&(h=function(B){l(arguments.length,1);var W=n(B)?B:x(B),G=a(arguments,1);return b[++I]=function(){e(W,void 0,G)},k(I),I},g=function(B){delete b[B]},f?k=function(N){m.nextTick(F(N))}:y&&y.now?k=function(N){y.now(F(N))}:_&&!d?(O=new _,L=O.port2,O.port1.onmessage=$,k=t(L.postMessage,L)):r.addEventListener&&n(r.postMessage)&&!r.importScripts&&C&&C.protocol!=="file:"&&!o(D)?(k=D,r.addEventListener("message",$,!1)):P in c("script")?k=function(N){s.appendChild(c("script"))[P]=function(){s.removeChild(this),j(N)}}:k=function(N){setTimeout(F(N),0)}),S1={set:h,clear:g},S1}var x1,AB;function Dne(){if(AB)return x1;AB=1;var r=Xe(),e=Et(),t=Object.getOwnPropertyDescriptor;return x1=function(n){if(!e)return r[n];var i=t(r,n);return i&&i.value},x1}var _1,RB;function Lne(){if(RB)return _1;RB=1;var r=function(){this.head=null,this.tail=null};return r.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e){var t=this.head=e.next;return t===null&&(this.tail=null),e.item}}},_1=r,_1}var w1,kB;function Obe(){if(kB)return w1;kB=1;var r=wa();return w1=/ipad|iphone|ipod/i.test(r)&&typeof Pebble<"u",w1}var b1,OB;function Mbe(){if(OB)return b1;OB=1;var r=wa();return b1=/web0s(?!.*chrome)/i.test(r),b1}var E1,MB;function Fne(){if(MB)return E1;MB=1;var r=Xe(),e=Dne(),t=Ar(),n=uy().set,i=Lne(),o=jne(),s=Obe(),a=Mbe(),c=Ud(),l=r.MutationObserver||r.WebKitMutationObserver,d=r.document,f=r.process,h=r.Promise,g=e("queueMicrotask"),m,y,x,_,w;if(!g){var I=new i,b=function(){var P,C;for(c&&(P=f.domain)&&P.exit();C=I.get();)try{C()}catch(k){throw I.head&&m(),k}P&&P.enter()};!o&&!c&&!a&&l&&d?(y=!0,x=d.createTextNode(""),new l(b).observe(x,{characterData:!0}),m=function(){x.data=y=!y}):!s&&h&&h.resolve?(_=h.resolve(void 0),_.constructor=h,w=t(_.then,_),m=function(){w(b)}):c?m=function(){f.nextTick(b)}:(n=t(n,r),m=function(){n(b)}),g=function(P){I.head||m(),I.add(P)}}return E1=g,E1}var I1,jB;function Nne(){return jB||(jB=1,I1=function(r,e){try{arguments.length===1?console.error(r):console.error(r,e)}catch{}}),I1}var P1,DB;function mu(){return DB||(DB=1,P1=function(r){try{return{error:!1,value:r()}}catch(e){return{error:!0,value:e}}}),P1}var C1,LB;function Wd(){if(LB)return C1;LB=1;var r=Xe();return C1=r.Promise,C1}var T1,FB;function Jh(){if(FB)return T1;FB=1;var r=Xe(),e=Wd(),t=Ut(),n=Nh(),i=Cm(),o=Tt(),s=Jm(),a=Xt(),c=ba(),l=e&&e.prototype,d=o("species"),f=!1,h=t(r.PromiseRejectionEvent),g=n("Promise",function(){var m=i(e),y=m!==String(e);if(!y&&c===66||a&&!(l.catch&&l.finally))return!0;if(!c||c<51||!/native code/.test(m)){var x=new e(function(I){I(1)}),_=function(I){I(function(){},function(){})},w=x.constructor={};if(w[d]=_,f=x.then(function(){})instanceof _,!f)return!0}return!y&&(s==="BROWSER"||s==="DENO")&&!h});return T1={CONSTRUCTOR:g,REJECTION_EVENT:h,SUBCLASSING:f},T1}var A1={},NB;function fc(){if(NB)return A1;NB=1;var r=jt(),e=TypeError,t=function(n){var i,o;this.promise=new n(function(s,a){if(i!==void 0||o!==void 0)throw new e("Bad Promise constructor");i=s,o=a}),this.resolve=r(i),this.reject=r(o)};return A1.f=function(n){return new t(n)},A1}var $B;function jbe(){if($B)return bB;$B=1;var r=H(),e=Xt(),t=Ud(),n=Xe(),i=Qe(),o=wr(),s=Fs(),a=yo(),c=pu(),l=jt(),d=Ut(),f=Lt(),h=Wi(),g=ly(),m=uy().set,y=Fne(),x=Nne(),_=mu(),w=Lne(),I=_r(),b=Wd(),P=Jh(),C=fc(),k="Promise",O=P.CONSTRUCTOR,L=P.REJECTION_EVENT,j=P.SUBCLASSING,F=I.getterFor(k),$=I.set,D=b&&b.prototype,N=b,B=D,W=n.TypeError,G=n.document,z=n.process,V=C.f,J=V,K=!!(G&&G.createEvent&&n.dispatchEvent),Z="unhandledrejection",ee="rejectionhandled",re=0,te=1,le=2,ge=1,se=2,ce,_e,Le,Ge,qe=function(be){var it;return f(be)&&d(it=be.then)?it:!1},mt=function(be,it){var st=it.value,Je=it.state===te,Ye=Je?be.ok:be.fail,cr=be.resolve,Sr=be.reject,Y=be.domain,oe,me,we;try{Ye?(Je||(it.rejection===se&&_t(it),it.rejection=ge),Ye===!0?oe=st:(Y&&Y.enter(),oe=Ye(st),Y&&(Y.exit(),we=!0)),oe===be.promise?Sr(new W("Promise-chain cycle")):(me=qe(oe))?i(me,oe,cr,Sr):cr(oe)):Sr(st)}catch(Oe){Y&&!we&&Y.exit(),Sr(Oe)}},St=function(be,it){be.notified||(be.notified=!0,y(function(){for(var st=be.reactions,Je;Je=st.get();)mt(Je,be);be.notified=!1,it&&!be.rejection&&ct(be)}))},et=function(be,it,st){var Je,Ye;K?(Je=G.createEvent("Event"),Je.promise=it,Je.reason=st,Je.initEvent(be,!1,!0),n.dispatchEvent(Je)):Je={promise:it,reason:st},!L&&(Ye=n["on"+be])?Ye(Je):be===Z&&x("Unhandled promise rejection",st)},ct=function(be){i(m,n,function(){var it=be.facade,st=be.value,Je=At(be),Ye;if(Je&&(Ye=_(function(){t?z.emit("unhandledRejection",st,it):et(Z,it,st)}),be.rejection=t||At(be)?se:ge,Ye.error))throw Ye.value})},At=function(be){return be.rejection!==ge&&!be.parent},_t=function(be){i(m,n,function(){var it=be.facade;t?z.emit("rejectionHandled",it):et(ee,it,be.value)})},ut=function(be,it,st){return function(Je){be(it,Je,st)}},Ae=function(be,it,st){be.done||(be.done=!0,st&&(be=st),be.value=it,be.state=le,St(be,!0))},ze=function(be,it,st){if(!be.done){be.done=!0,st&&(be=st);try{if(be.facade===it)throw new W("Promise can't be resolved itself");var Je=qe(it);Je?y(function(){var Ye={done:!1};try{i(Je,it,ut(ze,Ye,be),ut(Ae,Ye,be))}catch(cr){Ae(Ye,cr,be)}}):(be.value=it,be.state=te,St(be,!1))}catch(Ye){Ae({done:!1},Ye,be)}}};if(O&&(N=function(it){h(this,B),l(it),i(ce,this);var st=F(this);try{it(ut(ze,st),ut(Ae,st))}catch(Je){Ae(st,Je)}},B=N.prototype,ce=function(it){$(this,{type:k,done:!1,notified:!1,parent:!1,reactions:new w,rejection:!1,state:re,value:null})},ce.prototype=o(B,"then",function(it,st){var Je=F(this),Ye=V(g(this,N));return Je.parent=!0,Ye.ok=d(it)?it:!0,Ye.fail=d(st)&&st,Ye.domain=t?z.domain:void 0,Je.state===re?Je.reactions.add(Ye):y(function(){mt(Ye,Je)}),Ye.promise}),_e=function(){var be=new ce,it=F(be);this.promise=be,this.resolve=ut(ze,it),this.reject=ut(Ae,it)},C.f=V=function(be){return be===N||be===Le?new _e(be):J(be)},!e&&d(b)&&D!==Object.prototype)){Ge=D.then,j||o(D,"then",function(it,st){var Je=this;return new N(function(Ye,cr){i(Ge,Je,Ye,cr)}).then(it,st)},{unsafe:!0});try{delete D.constructor}catch{}s&&s(D,B)}return r({global:!0,constructor:!0,wrap:!0,forced:O},{Promise:N}),a(N,k,!1,!0),c(k),bB}var qB={},R1,BB;function dy(){if(BB)return R1;BB=1;var r=Wd(),e=Xm(),t=Jh().CONSTRUCTOR;return R1=t||!e(function(n){r.all(n).then(void 0,function(){})}),R1}var UB;function Dbe(){if(UB)return qB;UB=1;var r=H(),e=Qe(),t=jt(),n=fc(),i=mu(),o=cn(),s=dy();return r({target:"Promise",stat:!0,forced:s},{all:function(c){var l=this,d=n.f(l),f=d.resolve,h=d.reject,g=i(function(){var m=t(l.resolve),y=[],x=0,_=1;o(c,function(w){var I=x++,b=!1;_++,e(m,l,w).then(function(P){b||(b=!0,y[I]=P,--_||f(y))},h)}),--_||f(y)});return g.error&&h(g.value),d.promise}}),qB}var zB={},HB;function Lbe(){if(HB)return zB;HB=1;var r=H(),e=Xt(),t=Jh().CONSTRUCTOR,n=Wd(),i=Mt(),o=Ut(),s=wr(),a=n&&n.prototype;if(r({target:"Promise",proto:!0,forced:t,real:!0},{catch:function(l){return this.then(void 0,l)}}),!e&&o(n)){var c=i("Promise").prototype.catch;a.catch!==c&&s(a,"catch",c,{unsafe:!0})}return zB}var WB={},KB;function Fbe(){if(KB)return WB;KB=1;var r=H(),e=Qe(),t=jt(),n=fc(),i=mu(),o=cn(),s=dy();return r({target:"Promise",stat:!0,forced:s},{race:function(c){var l=this,d=n.f(l),f=d.reject,h=i(function(){var g=t(l.resolve);o(c,function(m){e(g,l,m).then(d.resolve,f)})});return h.error&&f(h.value),d.promise}}),WB}var GB={},VB;function Nbe(){if(VB)return GB;VB=1;var r=H(),e=fc(),t=Jh().CONSTRUCTOR;return r({target:"Promise",stat:!0,forced:t},{reject:function(i){var o=e.f(this),s=o.reject;return s(i),o.promise}}),GB}var YB={},k1,XB;function $ne(){if(XB)return k1;XB=1;var r=Ze(),e=Lt(),t=fc();return k1=function(n,i){if(r(n),e(i)&&i.constructor===n)return i;var o=t.f(n),s=o.resolve;return s(i),o.promise},k1}var ZB;function $be(){if(ZB)return YB;ZB=1;var r=H(),e=Mt(),t=Xt(),n=Wd(),i=Jh().CONSTRUCTOR,o=$ne(),s=e("Promise"),a=t&&!i;return r({target:"Promise",stat:!0,forced:t||i},{resolve:function(l){return o(a&&this===s?n:this,l)}}),YB}var QB;function qbe(){return QB||(QB=1,jbe(),Dbe(),Lbe(),Fbe(),Nbe(),$be()),wB}var JB={},e4;function qne(){if(e4)return JB;e4=1;var r=H(),e=Qe(),t=jt(),n=fc(),i=mu(),o=cn(),s=dy();return r({target:"Promise",stat:!0,forced:s},{allSettled:function(c){var l=this,d=n.f(l),f=d.resolve,h=d.reject,g=i(function(){var m=t(l.resolve),y=[],x=0,_=1;o(c,function(w){var I=x++,b=!1;_++,e(m,l,w).then(function(P){b||(b=!0,y[I]={status:"fulfilled",value:P},--_||f(y))},function(P){b||(b=!0,y[I]={status:"rejected",reason:P},--_||f(y))})}),--_||f(y)});return g.error&&h(g.value),d.promise}}),JB}var t4={},r4;function Bne(){if(r4)return t4;r4=1;var r=H(),e=Qe(),t=jt(),n=Mt(),i=fc(),o=mu(),s=cn(),a=dy(),c="No one promise resolved";return r({target:"Promise",stat:!0,forced:a},{any:function(d){var f=this,h=n("AggregateError"),g=i.f(f),m=g.resolve,y=g.reject,x=o(function(){var _=t(f.resolve),w=[],I=0,b=1,P=!1;s(d,function(C){var k=I++,O=!1;b++,e(_,f,C).then(function(L){O||P||(P=!0,m(L))},function(L){O||P||(O=!0,w[k]=L,--b||y(new h(w,c)))})}),--b||y(new h(w,c))});return x.error&&y(x.value),g.promise}}),t4}var n4={},i4;function Bbe(){if(i4)return n4;i4=1;var r=H(),e=Xt(),t=Wd(),n=Fe(),i=Mt(),o=Ut(),s=ly(),a=$ne(),c=wr(),l=t&&t.prototype,d=!!t&&n(function(){l.finally.call({then:function(){}},function(){})});if(r({target:"Promise",proto:!0,real:!0,forced:d},{finally:function(h){var g=s(this,i("Promise")),m=o(h);return this.then(m?function(y){return a(g,h()).then(function(){return y})}:h,m?function(y){return a(g,h()).then(function(){throw y})}:h)}}),!e&&o(t)){var f=i("Promise").prototype.finally;l.finally!==f&&c(l,"finally",f,{unsafe:!0})}return n4}var o4={},s4;function Une(){if(s4)return o4;s4=1;var r=H(),e=Xe(),t=zi(),n=Bo(),i=fc(),o=jt(),s=mu(),a=e.Promise,c=!1,l=!a||!a.try||s(function(){a.try(function(d){c=d===8},8)}).error||!c;return r({target:"Promise",stat:!0,forced:l},{try:function(d){var f=arguments.length>1?n(arguments,1):[],h=i.f(this),g=s(function(){return t(o(d),void 0,f)});return(g.error?h.reject:h.resolve)(g.value),h.promise}}),o4}var a4={},c4;function zne(){if(c4)return a4;c4=1;var r=H(),e=fc();return r({target:"Promise",stat:!0},{withResolvers:function(){var n=e.f(this);return{promise:n.promise,resolve:n.resolve,reject:n.reject}}}),a4}var l4={},u4;function Ube(){if(u4)return l4;u4=1;var r=H(),e=zi(),t=jt(),n=Ze(),i=Fe(),o=!i(function(){Reflect.apply(function(){})});return r({target:"Reflect",stat:!0,forced:o},{apply:function(a,c,l){return e(t(a),c,n(l))}}),l4}var d4={},f4;function zbe(){if(f4)return d4;f4=1;var r=H(),e=Mt(),t=zi(),n=one(),i=cy(),o=Ze(),s=Lt(),a=En(),c=Fe(),l=e("Reflect","construct"),d=Object.prototype,f=[].push,h=c(function(){function y(){}return!(l(function(){},[],y)instanceof y)}),g=!c(function(){l(function(){})}),m=h||g;return r({target:"Reflect",stat:!0,forced:m,sham:m},{construct:function(x,_){i(x),o(_);var w=arguments.length<3?x:i(arguments[2]);if(g&&!h)return l(x,_,w);if(x===w){switch(_.length){case 0:return new x;case 1:return new x(_[0]);case 2:return new x(_[0],_[1]);case 3:return new x(_[0],_[1],_[2]);case 4:return new x(_[0],_[1],_[2],_[3])}var I=[null];return t(f,I,_),new(t(n,x,I))}var b=w.prototype,P=a(s(b)?b:d),C=t(x,P,_);return s(C)?C:P}}),d4}var h4={},p4;function Hbe(){if(p4)return h4;p4=1;var r=H(),e=Et(),t=Ze(),n=lc(),i=Or(),o=Fe(),s=o(function(){Reflect.defineProperty(i.f({},1,{value:1}),1,{value:2})});return r({target:"Reflect",stat:!0,forced:s,sham:!e},{defineProperty:function(c,l,d){t(c);var f=n(l);t(d);try{return i.f(c,f,d),!0}catch{return!1}}}),h4}var g4={},v4;function Wbe(){if(v4)return g4;v4=1;var r=H(),e=Ze(),t=ni().f;return r({target:"Reflect",stat:!0},{deleteProperty:function(i,o){var s=t(e(i),o);return s&&!s.configurable?!1:delete i[o]}}),g4}var m4={},O1,y4;function Hne(){if(y4)return O1;y4=1;var r=Kt();return O1=function(e){return e!==void 0&&(r(e,"value")||r(e,"writable"))},O1}var S4;function Kbe(){if(S4)return m4;S4=1;var r=H(),e=Qe(),t=Lt(),n=Ze(),i=Hne(),o=ni(),s=Fn();function a(c,l){var d=arguments.length<3?c:arguments[2],f,h;if(n(c)===d)return c[l];if(f=o.f(c,l),f)return i(f)?f.value:f.get===void 0?void 0:e(f.get,d);if(t(h=s(c)))return a(h,l,d)}return r({target:"Reflect",stat:!0},{get:a}),m4}var x4={},_4;function Gbe(){if(_4)return x4;_4=1;var r=H(),e=Et(),t=Ze(),n=ni();return r({target:"Reflect",stat:!0,sham:!e},{getOwnPropertyDescriptor:function(o,s){return n.f(t(o),s)}}),x4}var w4={},b4;function Vbe(){if(b4)return w4;b4=1;var r=H(),e=Ze(),t=Fn(),n=CT();return r({target:"Reflect",stat:!0,sham:!n},{getPrototypeOf:function(o){return t(e(o))}}),w4}var E4={},I4;function Ybe(){if(I4)return E4;I4=1;var r=H();return r({target:"Reflect",stat:!0},{has:function(t,n){return n in t}}),E4}var P4={},C4;function Xbe(){if(C4)return P4;C4=1;var r=H(),e=Ze(),t=$T();return r({target:"Reflect",stat:!0},{isExtensible:function(i){return e(i),t(i)}}),P4}var T4={},A4;function Zbe(){if(A4)return T4;A4=1;var r=H(),e=UC();return r({target:"Reflect",stat:!0},{ownKeys:e}),T4}var R4={},k4;function Qbe(){if(k4)return R4;k4=1;var r=H(),e=Mt(),t=Ze(),n=hl();return r({target:"Reflect",stat:!0,sham:!n},{preventExtensions:function(o){t(o);try{var s=e("Object","preventExtensions");return s&&s(o),!0}catch{return!1}}}),R4}var O4={},M4;function Jbe(){if(M4)return O4;M4=1;var r=H(),e=Qe(),t=Ze(),n=Lt(),i=Hne(),o=Fe(),s=Or(),a=ni(),c=Fn(),l=No();function d(h,g,m){var y=arguments.length<4?h:arguments[3],x=a.f(t(h),g),_,w,I;if(!x){if(n(w=c(h)))return d(w,g,m,y);x=l(0)}if(i(x)){if(x.writable===!1||!n(y))return!1;if(_=a.f(y,g)){if(_.get||_.set||_.writable===!1)return!1;_.value=m,s.f(y,g,_)}else s.f(y,g,l(0,m))}else{if(I=x.set,I===void 0)return!1;e(I,y,m)}return!0}var f=o(function(){var h=function(){},g=s.f(new h,"a",{configurable:!0});return Reflect.set(h.prototype,"a",1,g)!==!1});return r({target:"Reflect",stat:!0,forced:f},{set:d}),O4}var j4={},D4;function e0e(){if(D4)return j4;D4=1;var r=H(),e=Ze(),t=bre(),n=Fs();return n&&r({target:"Reflect",stat:!0},{setPrototypeOf:function(o,s){e(o),t(s);try{return n(o,s),!0}catch{return!1}}}),j4}var L4={},F4;function t0e(){if(F4)return L4;F4=1;var r=H(),e=Xe(),t=yo();return r({global:!0},{Reflect:{}}),t(e.Reflect,"Reflect",!0),L4}var N4={},$4;function r0e(){if($4)return N4;$4=1;var r=Et(),e=Xe(),t=Ie(),n=Nh(),i=du(),o=Dn(),s=En(),a=cu().f,c=Ti(),l=Dm(),d=Nt(),f=Uh(),h=km(),g=Ere(),m=wr(),y=Fe(),x=Kt(),_=_r().enforce,w=pu(),I=Tt(),b=GC(),P=bee(),C=I("match"),k=e.RegExp,O=k.prototype,L=e.SyntaxError,j=t(O.exec),F=t("".charAt),$=t("".replace),D=t("".indexOf),N=t("".slice),B=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,W=/a/g,G=/a/g,z=new k(W)!==W,V=h.MISSED_STICKY,J=h.UNSUPPORTED_Y,K=r&&(!z||V||b||P||y(function(){return G[C]=!1,k(W)!==W||k(G)===G||String(k(W,"i"))!=="/a/i"})),Z=function(ge){for(var se=ge.length,ce=0,_e="",Le=!1,Ge;ce<=se;ce++){if(Ge=F(ge,ce),Ge==="\\"){_e+=Ge+F(ge,++ce);continue}!Le&&Ge==="."?_e+="[\\s\\S]":(Ge==="["?Le=!0:Ge==="]"&&(Le=!1),_e+=Ge)}return _e},ee=function(ge){for(var se=ge.length,ce=0,_e="",Le=[],Ge=s(null),qe=!1,mt=!1,St=0,et="",ct;ce<=se;ce++){if(ct=F(ge,ce),ct==="\\")ct+=F(ge,++ce);else if(ct==="]")qe=!1;else if(!qe)switch(!0){case ct==="[":qe=!0;break;case ct==="(":if(_e+=ct,N(ge,ce+1,ce+3)==="?:")continue;j(B,N(ge,ce+1))&&(ce+=2,mt=!0),St++;continue;case(ct===">"&&mt):if(et===""||x(Ge,et))throw new L("Invalid capture group name");Ge[et]=!0,Le[Le.length]=[et,St],mt=!1,et="";continue}mt?et+=ct:_e+=ct}return[_e,Le]};if(n("RegExp",K)){for(var re=function(se,ce){var _e=c(O,this),Le=l(se),Ge=ce===void 0,qe=[],mt=se,St,et,ct,At,_t,ut;if(!_e&&Le&&Ge&&se.constructor===re)return se;if((Le||c(O,se))&&(se=se.source,Ge&&(ce=f(mt))),se=se===void 0?"":d(se),ce=ce===void 0?"":d(ce),mt=se,b&&"dotAll"in W&&(et=!!ce&&D(ce,"s")>-1,et&&(ce=$(ce,/s/g,""))),St=ce,V&&"sticky"in W&&(ct=!!ce&&D(ce,"y")>-1,ct&&J&&(ce=$(ce,/y/g,""))),P&&(At=ee(se),se=At[0],qe=At[1]),_t=i(k(se,ce),_e?this:O,re),(et||ct||qe.length)&&(ut=_(_t),et&&(ut.dotAll=!0,ut.raw=re(Z(se),St)),ct&&(ut.sticky=!0),qe.length&&(ut.groups=qe)),se!==mt)try{o(_t,"source",mt===""?"(?:)":mt)}catch{}return _t},te=a(k),le=0;te.length>le;)g(re,k,te[le++]);O.constructor=re,re.prototype=O,m(e,"RegExp",re,{constructor:!0})}return w("RegExp"),N4}var q4={},M1,B4;function fy(){if(B4)return M1;B4=1;var r=TypeError;return M1=function(e){if(typeof e=="string")return e;throw new r("Argument is not a string")},M1}var U4;function Wne(){if(U4)return q4;U4=1;var r=H(),e=Ie(),t=fy(),n=Kt(),i=ny().start,o=zd(),s=Array,a=RegExp.escape,c=e("".charAt),l=e("".charCodeAt),d=e(1.1.toString),f=e([].join),h=/^[0-9a-z]/i,g=/^[$()*+./?[\\\]^{|}]/,m=RegExp("^[!\"#%&',\\-:;<=>@`~"+o+"]"),y=e(h.exec),x={" ":"t","\n":"n","\v":"v","\f":"f","\r":"r"},_=function(I){var b=d(l(I,0),16);return b.length<3?"\\x"+i(b,2,"0"):"\\u"+i(b,4,"0")},w=!a||a("ab")!=="\\x61b";return r({target:"RegExp",stat:!0,forced:w},{escape:function(b){t(b);for(var P=b.length,C=s(P),k=0;k<P;k++){var O=c(b,k);if(k===0&&y(h,O))C[k]=_(O);else if(n(x,O))C[k]="\\"+x[O];else if(y(g,O))C[k]="\\"+O;else if(y(m,O))C[k]=_(O);else{var L=l(O,0);(L&63488)!==55296?C[k]=O:L>=56320||k+1>=P||(l(b,k+1)&64512)!==56320?C[k]=_(O):(C[k]=O,C[++k]=c(b,k))}}return f(C,"")}}),q4}var z4={},H4;function n0e(){if(H4)return z4;H4=1;var r=Et(),e=GC(),t=Ci(),n=Yr(),i=_r().get,o=RegExp.prototype,s=TypeError;return r&&e&&n(o,"dotAll",{configurable:!0,get:function(){if(this!==o){if(t(this)==="RegExp")return!!i(this).dotAll;throw new s("Incompatible receiver, RegExp required")}}}),z4}var W4={},K4;function i0e(){if(K4)return W4;K4=1;var r=Xe(),e=Et(),t=Yr(),n=KC(),i=Fe(),o=r.RegExp,s=o.prototype,a=e&&i(function(){var c=!0;try{o(".","d")}catch{c=!1}var l={},d="",f=c?"dgimsy":"gimsy",h=function(x,_){Object.defineProperty(l,x,{get:function(){return d+=_,!0}})},g={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};c&&(g.hasIndices="d");for(var m in g)h(m,g[m]);var y=Object.getOwnPropertyDescriptor(s,"flags").get.call(l);return y!==f||d!==f});return a&&t(s,"flags",{configurable:!0,get:n}),W4}var G4={},V4;function o0e(){if(V4)return G4;V4=1;var r=Et(),e=km().MISSED_STICKY,t=Ci(),n=Yr(),i=_r().get,o=RegExp.prototype,s=TypeError;return r&&e&&n(o,"sticky",{configurable:!0,get:function(){if(this!==o){if(t(this)==="RegExp")return!!i(this).sticky;throw new s("Incompatible receiver, RegExp required")}}}),G4}var Y4={},X4;function s0e(){if(X4)return Y4;X4=1,Om();var r=H(),e=Qe(),t=Ut(),n=Ze(),i=Nt(),o=function(){var a=!1,c=/[ac]/;return c.exec=function(){return a=!0,/./.exec.apply(this,arguments)},c.test("abc")===!0&&a}(),s=/./.test;return r({target:"RegExp",proto:!0,forced:!o},{test:function(a){var c=n(this),l=i(a),d=c.exec;if(!t(d))return e(s,c,l);var f=e(d,c,l);return f===null?!1:(n(f),!0)}}),Y4}var Z4={},Q4;function a0e(){if(Q4)return Z4;Q4=1;var r=kd().PROPER,e=wr(),t=Ze(),n=Nt(),i=Fe(),o=Uh(),s="toString",a=RegExp.prototype,c=a[s],l=i(function(){return c.call({source:"a",flags:"b"})!=="/a/b"}),d=r&&c.name!==s;return(l||d)&&e(a,s,function(){var h=t(this),g=n(h.source),m=n(o(h));return"/"+g+"/"+m},{unsafe:!0}),Z4}var J4={},e6={},t6;function c0e(){if(t6)return e6;t6=1;var r=iy(),e=wne();return r("Set",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},e),e6}var r6;function l0e(){return r6||(r6=1,c0e()),J4}var n6={},j1,i6;function si(){if(i6)return j1;i6=1;var r=Ie(),e=Set.prototype;return j1={Set,add:r(e.add),has:r(e.has),remove:r(e.delete),proto:e},j1}var D1,o6;function Ai(){if(o6)return D1;o6=1;var r=si().has;return D1=function(e){return r(e),e},D1}var L1,s6;function pl(){if(s6)return L1;s6=1;var r=Qe();return L1=function(e,t,n){for(var i=n?e:e.iterator,o=e.next,s,a;!(s=r(o,i)).done;)if(a=t(s.value),a!==void 0)return a},L1}var F1,a6;function Uo(){if(a6)return F1;a6=1;var r=Ie(),e=pl(),t=si(),n=t.Set,i=t.proto,o=r(i.forEach),s=r(i.keys),a=s(new n).next;return F1=function(c,l,d){return d?e({iterator:s(c),next:a},l):o(c,l)},F1}var N1,c6;function zT(){if(c6)return N1;c6=1;var r=si(),e=Uo(),t=r.Set,n=r.add;return N1=function(i){var o=new t;return e(i,function(s){n(o,s)}),o},N1}var $1,l6;function ep(){if(l6)return $1;l6=1;var r=Gm(),e=si();return $1=r(e.proto,"size","get")||function(t){return t.size},$1}var q1,u6;function yu(){if(u6)return q1;u6=1;var r=jt(),e=Ze(),t=Qe(),n=Vr(),i=Jr(),o="Invalid size",s=RangeError,a=TypeError,c=Math.max,l=function(d,f){this.set=d,this.size=c(f,0),this.has=r(d.has),this.keys=r(d.keys)};return l.prototype={getIterator:function(){return i(e(t(this.keys,this.set)))},includes:function(d){return t(this.has,this.set,d)}},q1=function(d){e(d);var f=+d.size;if(f!==f)throw new a(o);var h=n(f);if(h<0)throw new s(o);return new l(d,h)},q1}var B1,d6;function Kne(){if(d6)return B1;d6=1;var r=Ai(),e=si(),t=zT(),n=ep(),i=yu(),o=Uo(),s=pl(),a=e.has,c=e.remove;return B1=function(d){var f=r(this),h=i(d),g=t(f);return n(f)<=h.size?o(f,function(m){h.includes(m)&&c(g,m)}):s(h.getIterator(),function(m){a(f,m)&&c(g,m)}),g},B1}var U1,f6;function Su(){if(f6)return U1;f6=1;var r=Mt(),e=function(n){return{size:n,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},t=function(n){return{size:n,has:function(){return!0},keys:function(){throw new Error("e")}}};return U1=function(n,i){var o=r("Set");try{new o()[n](e(0));try{return new o()[n](e(-1)),!1}catch{if(!i)return!0;try{return new o()[n](t(-1/0)),!1}catch{var s=new o;return s.add(1),s.add(2),i(s[n](t(1/0)))}}}catch{return!1}},U1}var h6;function Gne(){if(h6)return n6;h6=1;var r=H(),e=Kne(),t=Su(),n=!t("difference",function(i){return i.size===0});return r({target:"Set",proto:!0,real:!0,forced:n},{difference:e}),n6}var p6={},z1,g6;function Vne(){if(g6)return z1;g6=1;var r=Ai(),e=si(),t=ep(),n=yu(),i=Uo(),o=pl(),s=e.Set,a=e.add,c=e.has;return z1=function(d){var f=r(this),h=n(d),g=new s;return t(f)>h.size?o(h.getIterator(),function(m){c(f,m)&&a(g,m)}):i(f,function(m){h.includes(m)&&a(g,m)}),g},z1}var v6;function Yne(){if(v6)return p6;v6=1;var r=H(),e=Fe(),t=Vne(),n=Su(),i=!n("intersection",function(o){return o.size===2&&o.has(1)&&o.has(2)})||e(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});return r({target:"Set",proto:!0,real:!0,forced:i},{intersection:t}),p6}var m6={},H1,y6;function Xne(){if(y6)return H1;y6=1;var r=Ai(),e=si().has,t=ep(),n=yu(),i=Uo(),o=pl(),s=dl();return H1=function(c){var l=r(this),d=n(c);if(t(l)<=d.size)return i(l,function(h){if(d.includes(h))return!1},!0)!==!1;var f=d.getIterator();return o(f,function(h){if(e(l,h))return s(f,"normal",!1)})!==!1},H1}var S6;function Zne(){if(S6)return m6;S6=1;var r=H(),e=Xne(),t=Su(),n=!t("isDisjointFrom",function(i){return!i});return r({target:"Set",proto:!0,real:!0,forced:n},{isDisjointFrom:e}),m6}var x6={},W1,_6;function Qne(){if(_6)return W1;_6=1;var r=Ai(),e=ep(),t=Uo(),n=yu();return W1=function(o){var s=r(this),a=n(o);return e(s)>a.size?!1:t(s,function(c){if(!a.includes(c))return!1},!0)!==!1},W1}var w6;function Jne(){if(w6)return x6;w6=1;var r=H(),e=Qne(),t=Su(),n=!t("isSubsetOf",function(i){return i});return r({target:"Set",proto:!0,real:!0,forced:n},{isSubsetOf:e}),x6}var b6={},K1,E6;function eie(){if(E6)return K1;E6=1;var r=Ai(),e=si().has,t=ep(),n=yu(),i=pl(),o=dl();return K1=function(a){var c=r(this),l=n(a);if(t(c)<l.size)return!1;var d=l.getIterator();return i(d,function(f){if(!e(c,f))return o(d,"normal",!1)})!==!1},K1}var I6;function tie(){if(I6)return b6;I6=1;var r=H(),e=eie(),t=Su(),n=!t("isSupersetOf",function(i){return!i});return r({target:"Set",proto:!0,real:!0,forced:n},{isSupersetOf:e}),b6}var P6={},G1,C6;function rie(){if(C6)return G1;C6=1;var r=Ai(),e=si(),t=zT(),n=yu(),i=pl(),o=e.add,s=e.has,a=e.remove;return G1=function(l){var d=r(this),f=n(l).getIterator(),h=t(d);return i(f,function(g){s(d,g)?a(h,g):o(h,g)}),h},G1}var T6;function nie(){if(T6)return P6;T6=1;var r=H(),e=rie(),t=Su();return r({target:"Set",proto:!0,real:!0,forced:!t("symmetricDifference")},{symmetricDifference:e}),P6}var A6={},V1,R6;function iie(){if(R6)return V1;R6=1;var r=Ai(),e=si().add,t=zT(),n=yu(),i=pl();return V1=function(s){var a=r(this),c=n(s).getIterator(),l=t(a);return i(c,function(d){e(l,d)}),l},V1}var k6;function oie(){if(k6)return A6;k6=1;var r=H(),e=iie(),t=Su();return r({target:"Set",proto:!0,real:!0,forced:!t("union")},{union:e}),A6}var O6={},M6;function u0e(){if(M6)return O6;M6=1;var r=H(),e=jd().codeAt;return r({target:"String",proto:!0},{codePointAt:function(n){return e(this,n)}}),O6}var j6={},Y1,D6;function HT(){if(D6)return Y1;D6=1;var r=Dm(),e=TypeError;return Y1=function(t){if(r(t))throw new e("The method doesn't accept regular expressions");return t},Y1}var X1,L6;function WT(){if(L6)return X1;L6=1;var r=Tt(),e=r("match");return X1=function(t){var n=/./;try{"/./"[t](n)}catch{try{return n[e]=!1,"/./"[t](n)}catch{}}return!1},X1}var F6;function d0e(){if(F6)return j6;F6=1;var r=H(),e=uu(),t=ni().f,n=$o(),i=Nt(),o=HT(),s=qr(),a=WT(),c=Xt(),l=e("".slice),d=Math.min,f=a("endsWith"),h=!c&&!f&&!!function(){var g=t(String.prototype,"endsWith");return g&&!g.writable}();return r({target:"String",proto:!0,forced:!h&&!f},{endsWith:function(m){var y=i(s(this));o(m);var x=arguments.length>1?arguments[1]:void 0,_=y.length,w=x===void 0?_:d(n(x),_),I=i(m);return l(y,w-I.length,w)===I}}),j6}var N6={},$6;function sie(){if($6)return N6;$6=1;var r=H(),e=Ie(),t=Ea(),n=RangeError,i=String.fromCharCode,o=String.fromCodePoint,s=e([].join),a=!!o&&o.length!==1;return r({target:"String",stat:!0,arity:1,forced:a},{fromCodePoint:function(l){for(var d=[],f=arguments.length,h=0,g;f>h;){if(g=+arguments[h++],t(g,1114111)!==g)throw new n(g+" is not a valid code point");d[h]=g<65536?i(g):i(((g-=65536)>>10)+55296,g%1024+56320)}return s(d,"")}}),N6}var q6={},B6;function f0e(){if(B6)return q6;B6=1;var r=H(),e=Ie(),t=HT(),n=qr(),i=Nt(),o=WT(),s=e("".indexOf);return r({target:"String",proto:!0,forced:!o("includes")},{includes:function(c){return!!~s(i(n(this)),i(t(c)),arguments.length>1?arguments[1]:void 0)}}),q6}var U6={},z6;function aie(){if(z6)return U6;z6=1;var r=H(),e=Ie(),t=qr(),n=Nt(),i=e("".charCodeAt);return r({target:"String",proto:!0},{isWellFormed:function(){for(var s=n(t(this)),a=s.length,c=0;c<a;c++){var l=i(s,c);if((l&63488)===55296&&(l>=56320||++c>=a||(i(s,c)&64512)!==56320))return!1}return!0}}),U6}var H6={},W6;function cie(){if(W6)return H6;W6=1;var r=jd().charAt,e=Nt(),t=_r(),n=kT(),i=Hn(),o="String Iterator",s=t.set,a=t.getterFor(o);return n(String,"String",function(c){s(this,{type:o,string:e(c),index:0})},function(){var l=a(this),d=l.string,f=l.index,h;return f>=d.length?i(void 0,!0):(h=r(d,f),l.index+=h.length,i(h,!1))}),H6}var K6={},G6;function h0e(){if(G6)return K6;G6=1;var r=Qe(),e=Mm(),t=Ze(),n=Mn(),i=$o(),o=Nt(),s=qr(),a=bn(),c=jm(),l=Bh();return e("match",function(d,f,h){return[function(m){var y=s(this),x=n(m)?void 0:a(m,d);return x?r(x,m,y):new RegExp(m)[d](o(y))},function(g){var m=t(this),y=o(g),x=h(f,m,y);if(x.done)return x.value;if(!m.global)return l(m,y);var _=m.unicode;m.lastIndex=0;for(var w=[],I=0,b;(b=l(m,y))!==null;){var P=o(b[0]);w[I]=P,P===""&&(m.lastIndex=c(y,i(m.lastIndex),_)),I++}return I===0?null:w}]}),K6}var V6={},Y6;function lie(){if(Y6)return V6;Y6=1;var r=H(),e=Qe(),t=uu(),n=hu(),i=Hn(),o=qr(),s=$o(),a=Nt(),c=Ze(),l=Mn(),d=Ci(),f=Dm(),h=Uh(),g=bn(),m=wr(),y=Fe(),x=Tt(),_=ly(),w=jm(),I=Bh(),b=_r(),P=Xt(),C=x("matchAll"),k="RegExp String",O=k+" Iterator",L=b.set,j=b.getterFor(O),F=RegExp.prototype,$=TypeError,D=t("".indexOf),N=t("".matchAll),B=!!N&&!y(function(){N("a",/./)}),W=n(function(V,J,K,Z){L(this,{type:O,regexp:V,string:J,global:K,unicode:Z,done:!1})},k,function(){var V=j(this);if(V.done)return i(void 0,!0);var J=V.regexp,K=V.string,Z=I(J,K);return Z===null?(V.done=!0,i(void 0,!0)):V.global?(a(Z[0])===""&&(J.lastIndex=w(K,s(J.lastIndex),V.unicode)),i(Z,!1)):(V.done=!0,i(Z,!1))}),G=function(z){var V=c(this),J=a(z),K=_(V,RegExp),Z=a(h(V)),ee,re,te;return ee=new K(K===RegExp?V.source:V,Z),re=!!~D(Z,"g"),te=!!~D(Z,"u"),ee.lastIndex=s(V.lastIndex),new W(ee,J,re,te)};return r({target:"String",proto:!0,forced:B},{matchAll:function(V){var J=o(this),K,Z,ee,re;if(l(V)){if(B)return N(J,V)}else{if(f(V)&&(K=a(o(h(V))),!~D(K,"g")))throw new $("`.matchAll` does not allow non-global regexes");if(B)return N(J,V);if(ee=g(V,C),ee===void 0&&P&&d(V)==="RegExp"&&(ee=G),ee)return e(ee,V,J)}return Z=a(J),re=new RegExp(V,"g"),P?e(G,re,Z):re[C](Z)}}),P||C in F||m(F,C,G),V6}var X6={},Z1,Z6;function uie(){if(Z6)return Z1;Z6=1;var r=wa();return Z1=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(r),Z1}var Q6;function p0e(){if(Q6)return X6;Q6=1;var r=H(),e=ny().end,t=uie();return r({target:"String",proto:!0,forced:t},{padEnd:function(i){return e(this,i,arguments.length>1?arguments[1]:void 0)}}),X6}var J6={},eU;function g0e(){if(eU)return J6;eU=1;var r=H(),e=ny().start,t=uie();return r({target:"String",proto:!0,forced:t},{padStart:function(i){return e(this,i,arguments.length>1?arguments[1]:void 0)}}),J6}var tU={},rU;function v0e(){if(rU)return tU;rU=1;var r=H(),e=Ie(),t=jn(),n=Zt(),i=Nt(),o=sr(),s=e([].push),a=e([].join);return r({target:"String",stat:!0},{raw:function(l){var d=t(n(l).raw),f=o(d);if(!f)return"";for(var h=arguments.length,g=[],m=0;;){if(s(g,i(d[m++])),m===f)return a(g,"");m<h&&s(g,i(arguments[m]))}}}),tU}var nU={},iU;function m0e(){if(iU)return nU;iU=1;var r=H(),e=ry();return r({target:"String",proto:!0},{repeat:e}),nU}var oU={},sU;function y0e(){if(sU)return oU;sU=1;var r=Qe(),e=Mm(),t=Ze(),n=Mn(),i=qr(),o=UT(),s=Nt(),a=bn(),c=Bh();return e("search",function(l,d,f){return[function(g){var m=i(this),y=n(g)?void 0:a(g,l);return y?r(y,g,m):new RegExp(g)[l](s(m))},function(h){var g=t(this),m=s(h),y=f(d,g,m);if(y.done)return y.value;var x=g.lastIndex;o(x,0)||(g.lastIndex=0);var _=c(g,m);return o(g.lastIndex,x)||(g.lastIndex=x),_===null?-1:_.index}]}),oU}var aU={},cU;function S0e(){if(cU)return aU;cU=1;var r=Qe(),e=Ie(),t=Mm(),n=Ze(),i=Mn(),o=qr(),s=ly(),a=jm(),c=$o(),l=Nt(),d=bn(),f=Bh(),h=km(),g=Fe(),m=h.UNSUPPORTED_Y,y=4294967295,x=Math.min,_=e([].push),w=e("".slice),I=!g(function(){var P=/(?:)/,C=P.exec;P.exec=function(){return C.apply(this,arguments)};var k="ab".split(P);return k.length!==2||k[0]!=="a"||k[1]!=="b"}),b="abbc".split(/(b)*/)[1]==="c"||"test".split(/(?:)/,-1).length!==4||"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||".".split(/()()/).length>1||"".split(/.?/).length;return t("split",function(P,C,k){var O="0".split(void 0,0).length?function(L,j){return L===void 0&&j===0?[]:r(C,this,L,j)}:C;return[function(j,F){var $=o(this),D=i(j)?void 0:d(j,P);return D?r(D,j,$,F):r(O,l($),j,F)},function(L,j){var F=n(this),$=l(L);if(!b){var D=k(O,F,$,j,O!==C);if(D.done)return D.value}var N=s(F,RegExp),B=F.unicode,W=(F.ignoreCase?"i":"")+(F.multiline?"m":"")+(F.unicode?"u":"")+(m?"g":"y"),G=new N(m?"^(?:"+F.source+")":F,W),z=j===void 0?y:j>>>0;if(z===0)return[];if($.length===0)return f(G,$)===null?[$]:[];for(var V=0,J=0,K=[];J<$.length;){G.lastIndex=m?0:J;var Z=f(G,m?w($,J):$),ee;if(Z===null||(ee=x(c(G.lastIndex+(m?J:0)),$.length))===V)J=a($,J,B);else{if(_(K,w($,V,J)),K.length===z)return K;for(var re=1;re<=Z.length-1;re++)if(_(K,Z[re]),K.length===z)return K;J=V=ee}}return _(K,w($,V)),K}]},b||!I,m),aU}var lU={},uU;function x0e(){if(uU)return lU;uU=1;var r=H(),e=uu(),t=ni().f,n=$o(),i=Nt(),o=HT(),s=qr(),a=WT(),c=Xt(),l=e("".slice),d=Math.min,f=a("startsWith"),h=!c&&!f&&!!function(){var g=t(String.prototype,"startsWith");return g&&!g.writable}();return r({target:"String",proto:!0,forced:!h&&!f},{startsWith:function(m){var y=i(s(this));o(m);var x=n(d(arguments.length>1?arguments[1]:void 0,y.length)),_=i(m);return l(y,x,x+_.length)===_}}),lU}var dU={},fU;function _0e(){if(fU)return dU;fU=1;var r=H(),e=Ie(),t=qr(),n=Vr(),i=Nt(),o=e("".slice),s=Math.max,a=Math.min,c=!"".substr||"ab".substr(-1)!=="b";return r({target:"String",proto:!0,forced:c},{substr:function(d,f){var h=i(t(this)),g=h.length,m=n(d),y,x;return m===1/0&&(m=0),m<0&&(m=s(g+m,0)),y=f===void 0?g:n(f),y<=0||y===1/0?"":(x=a(m+y,g),m>=x?"":o(h,m,x))}}),dU}var hU={},pU;function die(){if(pU)return hU;pU=1;var r=H(),e=Qe(),t=Ie(),n=qr(),i=Nt(),o=Fe(),s=Array,a=t("".charAt),c=t("".charCodeAt),l=t([].join),d="".toWellFormed,f="�",h=d&&o(function(){return e(d,1)!=="1"});return r({target:"String",proto:!0,forced:h},{toWellFormed:function(){var m=i(n(this));if(h)return e(d,m);for(var y=m.length,x=s(y),_=0;_<y;_++){var w=c(m,_);(w&63488)!==55296?x[_]=a(m,_):w>=56320||_+1>=y||(c(m,_+1)&64512)!==56320?x[_]=f:(x[_]=a(m,_),x[++_]=a(m,_))}return l(x,"")}}),hU}var gU={},Q1,vU;function KT(){if(vU)return Q1;vU=1;var r=kd().PROPER,e=Fe(),t=zd(),n="​…᠎";return Q1=function(i){return e(function(){return!!t[i]()||n[i]()!==n||r&&t[i].name!==i})},Q1}var mU;function w0e(){if(mU)return gU;mU=1;var r=H(),e=Hd().trim,t=KT();return r({target:"String",proto:!0,forced:t("trim")},{trim:function(){return e(this)}}),gU}var yU={},SU={},J1,xU;function fie(){if(xU)return J1;xU=1;var r=Hd().end,e=KT();return J1=e("trimEnd")?function(){return r(this)}:"".trimEnd,J1}var _U;function b0e(){if(_U)return SU;_U=1;var r=H(),e=fie();return r({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==e},{trimRight:e}),SU}var wU;function E0e(){if(wU)return yU;wU=1,b0e();var r=H(),e=fie();return r({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==e},{trimEnd:e}),yU}var bU={},EU={},eE,IU;function hie(){if(IU)return eE;IU=1;var r=Hd().start,e=KT();return eE=e("trimStart")?function(){return r(this)}:"".trimStart,eE}var PU;function I0e(){if(PU)return EU;PU=1;var r=H(),e=hie();return r({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==e},{trimLeft:e}),EU}var CU;function P0e(){if(CU)return bU;CU=1,I0e();var r=H(),e=hie();return r({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==e},{trimStart:e}),bU}var TU={},tE,AU;function zo(){if(AU)return tE;AU=1;var r=Ie(),e=qr(),t=Nt(),n=/"/g,i=r("".replace);return tE=function(o,s,a,c){var l=t(e(o)),d="<"+s;return a!==""&&(d+=" "+a+'="'+i(t(c),n,"&quot;")+'"'),d+">"+l+"</"+s+">"},tE}var rE,RU;function Ho(){if(RU)return rE;RU=1;var r=Fe();return rE=function(e){return r(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3})},rE}var kU;function C0e(){if(kU)return TU;kU=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("anchor")},{anchor:function(i){return e(this,"a","name",i)}}),TU}var OU={},MU;function T0e(){if(MU)return OU;MU=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("big")},{big:function(){return e(this,"big","","")}}),OU}var jU={},DU;function A0e(){if(DU)return jU;DU=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("blink")},{blink:function(){return e(this,"blink","","")}}),jU}var LU={},FU;function R0e(){if(FU)return LU;FU=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("bold")},{bold:function(){return e(this,"b","","")}}),LU}var NU={},$U;function k0e(){if($U)return NU;$U=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("fixed")},{fixed:function(){return e(this,"tt","","")}}),NU}var qU={},BU;function O0e(){if(BU)return qU;BU=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("fontcolor")},{fontcolor:function(i){return e(this,"font","color",i)}}),qU}var UU={},zU;function M0e(){if(zU)return UU;zU=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("fontsize")},{fontsize:function(i){return e(this,"font","size",i)}}),UU}var HU={},WU;function j0e(){if(WU)return HU;WU=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("italics")},{italics:function(){return e(this,"i","","")}}),HU}var KU={},GU;function D0e(){if(GU)return KU;GU=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("link")},{link:function(i){return e(this,"a","href",i)}}),KU}var VU={},YU;function L0e(){if(YU)return VU;YU=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("small")},{small:function(){return e(this,"small","","")}}),VU}var XU={},ZU;function F0e(){if(ZU)return XU;ZU=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("strike")},{strike:function(){return e(this,"strike","","")}}),XU}var QU={},JU;function N0e(){if(JU)return QU;JU=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("sub")},{sub:function(){return e(this,"sub","","")}}),QU}var e8={},t8;function $0e(){if(t8)return e8;t8=1;var r=H(),e=zo(),t=Ho();return r({target:"String",proto:!0,forced:t("sup")},{sup:function(){return e(this,"sup","","")}}),e8}var r8={},Ag={exports:{}},nE,n8;function GT(){if(n8)return nE;n8=1;var r=Xe(),e=Fe(),t=Xm(),n=Vt().NATIVE_ARRAY_BUFFER_VIEWS,i=r.ArrayBuffer,o=r.Int8Array;return nE=!n||!e(function(){o(1)})||!e(function(){new o(-1)})||!t(function(s){new o,new o(null),new o(1.5),new o(s)},!0)||e(function(){return new o(new i(2),1,void 0).length!==1}),nE}var iE,i8;function pie(){if(i8)return iE;i8=1;var r=Qh(),e=RangeError;return iE=function(t,n){var i=r(t);if(i%n)throw new e("Wrong offset");return i},iE}var oE,o8;function gie(){if(o8)return oE;o8=1;var r=Math.round;return oE=function(e){var t=r(e);return t<0?0:t>255?255:t&255},oE}var sE,s8;function VT(){if(s8)return sE;s8=1;var r=vo();return sE=function(e){var t=r(e);return t==="BigInt64Array"||t==="BigUint64Array"},sE}var aE,a8;function hy(){if(a8)return aE;a8=1;var r=Im(),e=TypeError;return aE=function(t){var n=r(t,"number");if(typeof n=="number")throw new e("Can't convert number to bigint");return BigInt(n)},aE}var cE,c8;function vie(){if(c8)return cE;c8=1;var r=Ar(),e=Qe(),t=cy(),n=Zt(),i=sr(),o=fu(),s=dc(),a=TT(),c=VT(),l=Vt().aTypedArrayConstructor,d=hy();return cE=function(h){var g=t(this),m=n(h),y=arguments.length,x=y>1?arguments[1]:void 0,_=x!==void 0,w=s(m),I,b,P,C,k,O,L,j;if(w&&!a(w))for(L=o(m,w),j=L.next,m=[];!(O=e(j,L)).done;)m.push(O.value);for(_&&y>2&&(x=r(x,arguments[2])),b=i(m),P=new(l(g))(b),C=c(P),I=0;b>I;I++)k=_?x(m[I],I):m[I],P[I]=C?d(k):+k;return P},cE}var l8;function hc(){if(l8)return Ag.exports;l8=1;var r=H(),e=Xe(),t=Qe(),n=Et(),i=GT(),o=Vt(),s=ty(),a=Wi(),c=No(),l=Dn(),d=BT(),f=$o(),h=Yh(),g=pie(),m=gie(),y=lc(),x=Kt(),_=vo(),w=Lt(),I=sl(),b=En(),P=Ti(),C=Fs(),k=cu().f,O=vie(),L=In().forEach,j=pu(),F=Yr(),$=Or(),D=ni(),N=fl(),B=_r(),W=du(),G=B.get,z=B.set,V=B.enforce,J=$.f,K=D.f,Z=e.RangeError,ee=s.ArrayBuffer,re=ee.prototype,te=s.DataView,le=o.NATIVE_ARRAY_BUFFER_VIEWS,ge=o.TYPED_ARRAY_TAG,se=o.TypedArray,ce=o.TypedArrayPrototype,_e=o.isTypedArray,Le="BYTES_PER_ELEMENT",Ge="Wrong length",qe=function(At,_t){F(At,_t,{configurable:!0,get:function(){return G(this)[_t]}})},mt=function(At){var _t;return P(re,At)||(_t=_(At))==="ArrayBuffer"||_t==="SharedArrayBuffer"},St=function(At,_t){return _e(At)&&!I(_t)&&_t in At&&d(+_t)&&_t>=0},et=function(_t,ut){return ut=y(ut),St(_t,ut)?c(2,_t[ut]):K(_t,ut)},ct=function(_t,ut,Ae){return ut=y(ut),St(_t,ut)&&w(Ae)&&x(Ae,"value")&&!x(Ae,"get")&&!x(Ae,"set")&&!Ae.configurable&&(!x(Ae,"writable")||Ae.writable)&&(!x(Ae,"enumerable")||Ae.enumerable)?(_t[ut]=Ae.value,_t):J(_t,ut,Ae)};return n?(le||(D.f=et,$.f=ct,qe(ce,"buffer"),qe(ce,"byteOffset"),qe(ce,"byteLength"),qe(ce,"length")),r({target:"Object",stat:!0,forced:!le},{getOwnPropertyDescriptor:et,defineProperty:ct}),Ag.exports=function(At,_t,ut){var Ae=At.match(/\d+/)[0]/8,ze=At+(ut?"Clamped":"")+"Array",be="get"+At,it="set"+At,st=e[ze],Je=st,Ye=Je&&Je.prototype,cr={},Sr=function(we,Oe){var Ee=G(we);return Ee.view[be](Oe*Ae+Ee.byteOffset,!0)},Y=function(we,Oe,Ee){var dt=G(we);dt.view[it](Oe*Ae+dt.byteOffset,ut?m(Ee):Ee,!0)},oe=function(we,Oe){J(we,Oe,{get:function(){return Sr(this,Oe)},set:function(Ee){return Y(this,Oe,Ee)},enumerable:!0})};le?i&&(Je=_t(function(we,Oe,Ee,dt){return a(we,Ye),W(function(){return w(Oe)?mt(Oe)?dt!==void 0?new st(Oe,g(Ee,Ae),dt):Ee!==void 0?new st(Oe,g(Ee,Ae)):new st(Oe):_e(Oe)?N(Je,Oe):t(O,Je,Oe):new st(h(Oe))}(),we,Je)}),C&&C(Je,se),L(k(st),function(we){we in Je||l(Je,we,st[we])}),Je.prototype=Ye):(Je=_t(function(we,Oe,Ee,dt){a(we,Ye);var $t=0,Pe=0,$e,Be,We;if(!w(Oe))We=h(Oe),Be=We*Ae,$e=new ee(Be);else if(mt(Oe)){$e=Oe,Pe=g(Ee,Ae);var yt=Oe.byteLength;if(dt===void 0){if(yt%Ae)throw new Z(Ge);if(Be=yt-Pe,Be<0)throw new Z(Ge)}else if(Be=f(dt)*Ae,Be+Pe>yt)throw new Z(Ge);We=Be/Ae}else return _e(Oe)?N(Je,Oe):t(O,Je,Oe);for(z(we,{buffer:$e,byteOffset:Pe,byteLength:Be,length:We,view:new te($e)});$t<We;)oe(we,$t++)}),C&&C(Je,se),Ye=Je.prototype=b(ce)),Ye.constructor!==Je&&l(Ye,"constructor",Je),V(Ye).TypedArrayConstructor=Je,ge&&l(Ye,ge,ze);var me=Je!==st;cr[ze]=Je,r({global:!0,constructor:!0,forced:me,sham:!le},cr),Le in Je||l(Je,Le,Ae),Le in Ye||l(Ye,Le,Ae),j(ze)}):Ag.exports=function(){},Ag.exports}var u8;function q0e(){if(u8)return r8;u8=1;var r=hc();return r("Float32",function(e){return function(n,i,o){return e(this,n,i,o)}}),r8}var d8={},f8;function B0e(){if(f8)return d8;f8=1;var r=hc();return r("Float64",function(e){return function(n,i,o){return e(this,n,i,o)}}),d8}var h8={},p8;function U0e(){if(p8)return h8;p8=1;var r=hc();return r("Int8",function(e){return function(n,i,o){return e(this,n,i,o)}}),h8}var g8={},v8;function z0e(){if(v8)return g8;v8=1;var r=hc();return r("Int16",function(e){return function(n,i,o){return e(this,n,i,o)}}),g8}var m8={},y8;function H0e(){if(y8)return m8;y8=1;var r=hc();return r("Int32",function(e){return function(n,i,o){return e(this,n,i,o)}}),m8}var S8={},x8;function W0e(){if(x8)return S8;x8=1;var r=hc();return r("Uint8",function(e){return function(n,i,o){return e(this,n,i,o)}}),S8}var _8={},w8;function K0e(){if(w8)return _8;w8=1;var r=hc();return r("Uint8",function(e){return function(n,i,o){return e(this,n,i,o)}},!0),_8}var b8={},E8;function G0e(){if(E8)return b8;E8=1;var r=hc();return r("Uint16",function(e){return function(n,i,o){return e(this,n,i,o)}}),b8}var I8={},P8;function V0e(){if(P8)return I8;P8=1;var r=hc();return r("Uint32",function(e){return function(n,i,o){return e(this,n,i,o)}}),I8}var C8={},T8;function mie(){if(T8)return C8;T8=1;var r=Vt(),e=sr(),t=Vr(),n=r.aTypedArray,i=r.exportTypedArrayMethod;return i("at",function(s){var a=n(this),c=e(a),l=t(s),d=l>=0?l:c+l;return d<0||d>=c?void 0:a[d]}),C8}var A8={},R8;function Y0e(){if(R8)return A8;R8=1;var r=Ie(),e=Vt(),t=Rre(),n=r(t),i=e.aTypedArray,o=e.exportTypedArrayMethod;return o("copyWithin",function(a,c){return n(i(this),a,c,arguments.length>2?arguments[2]:void 0)}),A8}var k8={},O8;function X0e(){if(O8)return k8;O8=1;var r=Vt(),e=In().every,t=r.aTypedArray,n=r.exportTypedArrayMethod;return n("every",function(o){return e(t(this),o,arguments.length>1?arguments[1]:void 0)}),k8}var M8={},j8;function Z0e(){if(j8)return M8;j8=1;var r=Vt(),e=AT(),t=hy(),n=vo(),i=Qe(),o=Ie(),s=Fe(),a=r.aTypedArray,c=r.exportTypedArrayMethod,l=o("".slice),d=s(function(){var f=0;return new Int8Array(2).fill({valueOf:function(){return f++}}),f!==1});return c("fill",function(h){var g=arguments.length;a(this);var m=l(n(this),0,3)==="Big"?t(h):+h;return i(e,this,m,g>1?arguments[1]:void 0,g>2?arguments[2]:void 0)},d),M8}var D8={},lE,L8;function YT(){if(L8)return lE;L8=1;var r=fl(),e=Vt().getTypedArrayConstructor;return lE=function(t,n){return r(e(t),n)},lE}var F8;function Q0e(){if(F8)return D8;F8=1;var r=Vt(),e=In().filter,t=YT(),n=r.aTypedArray,i=r.exportTypedArrayMethod;return i("filter",function(s){var a=e(n(this),s,arguments.length>1?arguments[1]:void 0);return t(this,a)}),D8}var N8={},$8;function J0e(){if($8)return N8;$8=1;var r=Vt(),e=In().find,t=r.aTypedArray,n=r.exportTypedArrayMethod;return n("find",function(o){return e(t(this),o,arguments.length>1?arguments[1]:void 0)}),N8}var q8={},B8;function e1e(){if(B8)return q8;B8=1;var r=Vt(),e=In().findIndex,t=r.aTypedArray,n=r.exportTypedArrayMethod;return n("findIndex",function(o){return e(t(this),o,arguments.length>1?arguments[1]:void 0)}),q8}var U8={},z8;function yie(){if(z8)return U8;z8=1;var r=Vt(),e=Ym().findLast,t=r.aTypedArray,n=r.exportTypedArrayMethod;return n("findLast",function(o){return e(t(this),o,arguments.length>1?arguments[1]:void 0)}),U8}var H8={},W8;function Sie(){if(W8)return H8;W8=1;var r=Vt(),e=Ym().findLastIndex,t=r.aTypedArray,n=r.exportTypedArrayMethod;return n("findLastIndex",function(o){return e(t(this),o,arguments.length>1?arguments[1]:void 0)}),H8}var K8={},G8;function t1e(){if(G8)return K8;G8=1;var r=Vt(),e=In().forEach,t=r.aTypedArray,n=r.exportTypedArrayMethod;return n("forEach",function(o){e(t(this),o,arguments.length>1?arguments[1]:void 0)}),K8}var V8={},Y8;function r1e(){if(Y8)return V8;Y8=1;var r=GT(),e=Vt().exportTypedArrayStaticMethod,t=vie();return e("from",t,r),V8}var X8={},Z8;function n1e(){if(Z8)return X8;Z8=1;var r=Vt(),e=Fh().includes,t=r.aTypedArray,n=r.exportTypedArrayMethod;return n("includes",function(o){return e(t(this),o,arguments.length>1?arguments[1]:void 0)}),X8}var Q8={},J8;function i1e(){if(J8)return Q8;J8=1;var r=Vt(),e=Fh().indexOf,t=r.aTypedArray,n=r.exportTypedArrayMethod;return n("indexOf",function(o){return e(t(this),o,arguments.length>1?arguments[1]:void 0)}),Q8}var ez={},tz;function o1e(){if(tz)return ez;tz=1;var r=Xe(),e=Fe(),t=Ie(),n=Vt(),i=Zm(),o=Tt(),s=o("iterator"),a=r.Uint8Array,c=t(i.values),l=t(i.keys),d=t(i.entries),f=n.aTypedArray,h=n.exportTypedArrayMethod,g=a&&a.prototype,m=!e(function(){g[s].call([1])}),y=!!g&&g.values&&g[s]===g.values&&g.values.name==="values",x=function(){return c(f(this))};return h("entries",function(){return d(f(this))},m),h("keys",function(){return l(f(this))},m),h("values",x,m||!y,{name:"values"}),h(s,x,m||!y,{name:"values"}),ez}var rz={},nz;function s1e(){if(nz)return rz;nz=1;var r=Vt(),e=Ie(),t=r.aTypedArray,n=r.exportTypedArrayMethod,i=e([].join);return n("join",function(s){return i(t(this),s)}),rz}var iz={},oz;function a1e(){if(oz)return iz;oz=1;var r=Vt(),e=zi(),t=Dre(),n=r.aTypedArray,i=r.exportTypedArrayMethod;return i("lastIndexOf",function(s){var a=arguments.length;return e(t,n(this),a>1?[s,arguments[1]]:[s])}),iz}var sz={},az;function c1e(){if(az)return sz;az=1;var r=Vt(),e=In().map,t=r.aTypedArray,n=r.getTypedArrayConstructor,i=r.exportTypedArrayMethod;return i("map",function(s){return e(t(this),s,arguments.length>1?arguments[1]:void 0,function(a,c){return new(n(a))(c)})}),sz}var cz={},lz;function l1e(){if(lz)return cz;lz=1;var r=Vt(),e=GT(),t=r.aTypedArrayConstructor,n=r.exportTypedArrayStaticMethod;return n("of",function(){for(var o=0,s=arguments.length,a=new(t(this))(s);s>o;)a[o]=arguments[o++];return a},e),cz}var uz={},dz;function u1e(){if(dz)return uz;dz=1;var r=Vt(),e=Qm().left,t=r.aTypedArray,n=r.exportTypedArrayMethod;return n("reduce",function(o){var s=arguments.length;return e(t(this),o,s,s>1?arguments[1]:void 0)}),uz}var fz={},hz;function d1e(){if(hz)return fz;hz=1;var r=Vt(),e=Qm().right,t=r.aTypedArray,n=r.exportTypedArrayMethod;return n("reduceRight",function(o){var s=arguments.length;return e(t(this),o,s,s>1?arguments[1]:void 0)}),fz}var pz={},gz;function f1e(){if(gz)return pz;gz=1;var r=Vt(),e=r.aTypedArray,t=r.exportTypedArrayMethod,n=Math.floor;return t("reverse",function(){for(var o=this,s=e(o).length,a=n(s/2),c=0,l;c<a;)l=o[c],o[c++]=o[--s],o[s]=l;return o}),pz}var vz={},mz;function h1e(){if(mz)return vz;mz=1;var r=Xe(),e=Qe(),t=Vt(),n=sr(),i=pie(),o=Zt(),s=Fe(),a=r.RangeError,c=r.Int8Array,l=c&&c.prototype,d=l&&l.set,f=t.aTypedArray,h=t.exportTypedArrayMethod,g=!s(function(){var y=new Uint8ClampedArray(2);return e(d,y,{length:1,0:3},1),y[1]!==3}),m=g&&t.NATIVE_ARRAY_BUFFER_VIEWS&&s(function(){var y=new c(2);return y.set(1),y.set("2",1),y[0]!==0||y[1]!==2});return h("set",function(x){f(this);var _=i(arguments.length>1?arguments[1]:void 0,1),w=o(x);if(g)return e(d,this,w,_);var I=this.length,b=n(w),P=0;if(b+_>I)throw new a("Wrong length");for(;P<b;)this[_+P]=w[P++]},!g||m),vz}var yz={},Sz;function p1e(){if(Sz)return yz;Sz=1;var r=Vt(),e=Fe(),t=Bo(),n=r.aTypedArray,i=r.getTypedArrayConstructor,o=r.exportTypedArrayMethod,s=e(function(){new Int8Array(1).slice()});return o("slice",function(c,l){for(var d=t(n(this),c,l),f=i(this),h=0,g=d.length,m=new f(g);g>h;)m[h]=d[h++];return m},s),yz}var xz={},_z;function g1e(){if(_z)return xz;_z=1;var r=Vt(),e=In().some,t=r.aTypedArray,n=r.exportTypedArrayMethod;return n("some",function(o){return e(t(this),o,arguments.length>1?arguments[1]:void 0)}),xz}var wz={},bz;function v1e(){if(bz)return wz;bz=1;var r=Xe(),e=uu(),t=Fe(),n=jt(),i=MT(),o=Vt(),s=Lre(),a=Fre(),c=ba(),l=jT(),d=o.aTypedArray,f=o.exportTypedArrayMethod,h=r.Uint16Array,g=h&&e(h.prototype.sort),m=!!g&&!(t(function(){g(new h(2),null)})&&t(function(){g(new h(2),{})})),y=!!g&&!t(function(){if(c)return c<74;if(s)return s<67;if(a)return!0;if(l)return l<602;var _=new h(516),w=Array(516),I,b;for(I=0;I<516;I++)b=I%4,_[I]=515-I,w[I]=I-2*b+3;for(g(_,function(P,C){return(P/4|0)-(C/4|0)}),I=0;I<516;I++)if(_[I]!==w[I])return!0}),x=function(_){return function(w,I){return _!==void 0?+_(w,I)||0:I!==I?-1:w!==w?1:w===0&&I===0?1/w>0&&1/I<0?1:-1:w>I}};return f("sort",function(w){return w!==void 0&&n(w),y?g(this,w):i(d(this),x(w))},!y||m),wz}var Ez={},Iz;function m1e(){if(Iz)return Ez;Iz=1;var r=Vt(),e=$o(),t=Ea(),n=r.aTypedArray,i=r.getTypedArrayConstructor,o=r.exportTypedArrayMethod;return o("subarray",function(a,c){var l=n(this),d=l.length,f=t(a,d),h=i(l);return new h(l.buffer,l.byteOffset+f*l.BYTES_PER_ELEMENT,e((c===void 0?d:t(c,d))-f))}),Ez}var Pz={},Cz;function y1e(){if(Cz)return Pz;Cz=1;var r=Xe(),e=zi(),t=Vt(),n=Fe(),i=Bo(),o=r.Int8Array,s=t.aTypedArray,a=t.exportTypedArrayMethod,c=[].toLocaleString,l=!!o&&n(function(){c.call(new o(1))}),d=n(function(){return[1,2].toLocaleString()!==new o([1,2]).toLocaleString()})||!n(function(){o.prototype.toLocaleString.call([1,2])});return a("toLocaleString",function(){return e(c,l?i(s(this)):s(this),i(arguments))},d),Pz}var Tz={},Az;function xie(){if(Az)return Tz;Az=1;var r=Nre(),e=Vt(),t=e.aTypedArray,n=e.exportTypedArrayMethod,i=e.getTypedArrayConstructor;return n("toReversed",function(){return r(t(this),i(this))}),Tz}var Rz={},kz;function _ie(){if(kz)return Rz;kz=1;var r=Vt(),e=Ie(),t=jt(),n=fl(),i=r.aTypedArray,o=r.getTypedArrayConstructor,s=r.exportTypedArrayMethod,a=e(r.TypedArrayPrototype.sort);return s("toSorted",function(l){l!==void 0&&t(l);var d=i(this),f=n(o(d),d);return a(f,l)}),Rz}var Oz={},Mz;function S1e(){if(Mz)return Oz;Mz=1;var r=Vt().exportTypedArrayMethod,e=Fe(),t=Xe(),n=Ie(),i=t.Uint8Array,o=i&&i.prototype||{},s=[].toString,a=n([].join);e(function(){s.call({})})&&(s=function(){return a(this)});var c=o.toString!==s;return r("toString",s,c),Oz}var jz={},Dz;function wie(){if(Dz)return jz;Dz=1;var r=zre(),e=Vt(),t=VT(),n=Vr(),i=hy(),o=e.aTypedArray,s=e.getTypedArrayConstructor,a=e.exportTypedArrayMethod,c=!!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(l){return l===8}}();return a("with",function(l,d){var f=o(this),h=n(l),g=t(f)?i(d):+d;return r(f,s(f),h,g)},!c),jz}var Lz={},Fz;function x1e(){if(Fz)return Lz;Fz=1;var r=H(),e=Ie(),t=Nt(),n=String.fromCharCode,i=e("".charAt),o=e(/./.exec),s=e("".slice),a=/^[\da-f]{2}$/i,c=/^[\da-f]{4}$/i;return r({global:!0},{unescape:function(d){for(var f=t(d),h="",g=f.length,m=0,y,x;m<g;){if(y=i(f,m++),y==="%"){if(i(f,m)==="u"){if(x=s(f,m+1,m+5),o(c,x)){h+=n(parseInt(x,16)),m+=5;continue}}else if(x=s(f,m,m+2),o(a,x)){h+=n(parseInt(x,16)),m+=2;continue}}h+=y}return h}}),Lz}var Nz={},$z={},uE,qz;function bie(){if(qz)return uE;qz=1;var r=Ie(),e=qs(),t=vu().getWeakData,n=Wi(),i=Ze(),o=Mn(),s=Lt(),a=cn(),c=In(),l=Kt(),d=_r(),f=d.set,h=d.getterFor,g=c.find,m=c.findIndex,y=r([].splice),x=0,_=function(b){return b.frozen||(b.frozen=new w)},w=function(){this.entries=[]},I=function(b,P){return g(b.entries,function(C){return C[0]===P})};return w.prototype={get:function(b){var P=I(this,b);if(P)return P[1]},has:function(b){return!!I(this,b)},set:function(b,P){var C=I(this,b);C?C[1]=P:this.entries.push([b,P])},delete:function(b){var P=m(this.entries,function(C){return C[0]===b});return~P&&y(this.entries,P,1),!!~P}},uE={getConstructor:function(b,P,C,k){var O=b(function($,D){n($,L),f($,{type:P,id:x++,frozen:null}),o(D)||a(D,$[k],{that:$,AS_ENTRIES:C})}),L=O.prototype,j=h(P),F=function($,D,N){var B=j($),W=t(i(D),!0);return W===!0?_(B).set(D,N):W[B.id]=N,$};return e(L,{delete:function($){var D=j(this);if(!s($))return!1;var N=t($);return N===!0?_(D).delete($):N&&l(N,D.id)&&delete N[D.id]},has:function(D){var N=j(this);if(!s(D))return!1;var B=t(D);return B===!0?_(N).has(D):B&&l(B,N.id)}}),e(L,C?{get:function(D){var N=j(this);if(s(D)){var B=t(D);if(B===!0)return _(N).get(D);if(B)return B[N.id]}},set:function(D,N){return F(this,D,N)}}:{add:function(D){return F(this,D,!0)}}),O}},uE}var Bz;function _1e(){if(Bz)return $z;Bz=1;var r=hl(),e=Xe(),t=Ie(),n=qs(),i=vu(),o=iy(),s=bie(),a=Lt(),c=_r().enforce,l=Fe(),d=hee(),f=Object,h=Array.isArray,g=f.isExtensible,m=f.isFrozen,y=f.isSealed,x=f.freeze,_=f.seal,w=!e.ActiveXObject&&"ActiveXObject"in e,I,b=function($){return function(){return $(this,arguments.length?arguments[0]:void 0)}},P=o("WeakMap",b,s),C=P.prototype,k=t(C.set),O=function(){return r&&l(function(){var $=x([]);return k(new P,$,1),!m($)})};if(d)if(w){I=s.getConstructor(b,"WeakMap",!0),i.enable();var L=t(C.delete),j=t(C.has),F=t(C.get);n(C,{delete:function($){if(a($)&&!g($)){var D=c(this);return D.frozen||(D.frozen=new I),L(this,$)||D.frozen.delete($)}return L(this,$)},has:function(D){if(a(D)&&!g(D)){var N=c(this);return N.frozen||(N.frozen=new I),j(this,D)||N.frozen.has(D)}return j(this,D)},get:function(D){if(a(D)&&!g(D)){var N=c(this);return N.frozen||(N.frozen=new I),j(this,D)?F(this,D):N.frozen.get(D)}return F(this,D)},set:function(D,N){if(a(D)&&!g(D)){var B=c(this);B.frozen||(B.frozen=new I),j(this,D)?k(this,D,N):B.frozen.set(D,N)}else k(this,D,N);return this}})}else O()&&n(C,{set:function(D,N){var B;return h(D)&&(m(D)?B=x:y(D)&&(B=_)),k(this,D,N),B&&B(D),this}});return $z}var Uz;function XT(){return Uz||(Uz=1,_1e()),Nz}var zz={},Hz={},Wz;function w1e(){if(Wz)return Hz;Wz=1;var r=iy(),e=bie();return r("WeakSet",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},e),Hz}var Kz;function b1e(){return Kz||(Kz=1,w1e()),zz}var Gz={},Vz;function E1e(){return Vz||(Vz=1,Are()),Gz}var Yz={},Xz;function I1e(){if(Xz)return Yz;Xz=1;var r=H(),e=Xe(),t=Ti(),n=Fn(),i=Fs(),o=Od(),s=En(),a=Dn(),c=No(),l=PT(),d=$d(),f=Tt(),h=Fe(),g=Xt(),m=e.SuppressedError,y=f("toStringTag"),x=Error,_=!!m&&m.length!==3,w=!!m&&h(function(){return new m(1,2,3,{cause:4}).cause===4}),I=_||w,b=function(k,O,L){var j=t(P,this),F;return i?F=I&&(!j||n(this)===P)?new m:i(new x,j?n(this):P):(F=j?this:s(P),a(F,y,"Error")),L!==void 0&&a(F,"message",d(L)),l(F,b,F.stack,1),a(F,"error",k),a(F,"suppressed",O),F};i?i(b,x):o(b,x,{name:!0});var P=b.prototype=I?m.prototype:s(x.prototype,{constructor:c(1,b),message:c(1,""),name:c(1,"SuppressedError")});return I&&!g&&(P.constructor=b),r({global:!0,constructor:!0,arity:3,forced:I},{SuppressedError:b}),Yz}var Zz={},dE,Qz;function tp(){if(Qz)return dE;Qz=1;var r=Xe(),e=Em(),t=Ut(),n=En(),i=Fn(),o=wr(),s=Tt(),a=Xt(),c="USE_FUNCTION_CONSTRUCTOR",l=s("asyncIterator"),d=r.AsyncIterator,f=e.AsyncIteratorPrototype,h,g;if(f)h=f;else if(t(d))h=d.prototype;else if(e[c]||r[c])try{g=i(i(i(Function("return async function*(){}()")()))),i(g)===Object.prototype&&(h=g)}catch{}return h?a&&(h=n(h)):h={},t(h[l])||o(h,l,function(){return this}),dE=h,dE}var fE,Jz;function py(){if(Jz)return fE;Jz=1;var r=Qe(),e=Ze(),t=En(),n=bn(),i=qs(),o=_r(),s=Mt(),a=tp(),c=Hn(),l=s("Promise"),d="AsyncFromSyncIterator",f=o.set,h=o.getterFor(d),g=function(y,x,_){var w=y.done;l.resolve(y.value).then(function(I){x(c(I,w))},_)},m=function(x){x.type=d,f(this,x)};return m.prototype=i(t(a),{next:function(){var x=h(this);return new l(function(_,w){var I=e(r(x.next,x.iterator));g(I,_,w)})},return:function(){var y=h(this).iterator;return new l(function(x,_){var w=n(y,"return");if(w===void 0)return x(c(void 0,!0));var I=e(r(w,y));g(I,x,_)})}}),fE=m,fE}var hE,e9;function P1e(){if(e9)return hE;e9=1;var r=Qe(),e=py(),t=Ze(),n=fu(),i=Jr(),o=bn(),s=Tt(),a=s("asyncIterator");return hE=function(c,l){var d=arguments.length<2?o(c,a):l;return d?t(r(d,c)):new e(i(n(c)))},hE}var pE,t9;function rp(){if(t9)return pE;t9=1;var r=Qe(),e=Mt(),t=bn();return pE=function(n,i,o,s){try{var a=t(n,"return");if(a)return e("Promise").resolve(r(a,n)).then(function(){i(o)},function(c){s(c)})}catch(c){return s(c)}i(o)},pE}var gE,r9;function Kd(){if(r9)return gE;r9=1;var r=Qe(),e=jt(),t=Ze(),n=Lt(),i=lu(),o=Mt(),s=Jr(),a=rp(),c=function(l){var d=l===0,f=l===1,h=l===2,g=l===3;return function(m,y,x){t(m);var _=y!==void 0;(_||!d)&&e(y);var w=s(m),I=o("Promise"),b=w.iterator,P=w.next,C=0;return new I(function(k,O){var L=function(F){a(b,O,F,O)},j=function(){try{if(_)try{i(C)}catch(F){L(F)}I.resolve(t(r(P,b))).then(function(F){try{if(t(F).done)d?(x.length=C,k(x)):k(g?!1:h||void 0);else{var $=F.value;try{if(_){var D=y($,C),N=function(B){if(f)j();else if(h)B?j():a(b,k,!1,O);else if(d)try{x[C++]=B,j()}catch(W){L(W)}else B?a(b,k,g||$,O):j()};n(D)?I.resolve(D).then(N,L):N(D)}else x[C++]=$,j()}catch(B){L(B)}}}catch(B){O(B)}},O)}catch(F){O(F)}};j()})}};return gE={toArray:c(0),forEach:c(1),every:c(2),some:c(3),find:c(4)},gE}var vE,n9;function Eie(){if(n9)return vE;n9=1;var r=Ar(),e=Ie(),t=Zt(),n=Pa(),i=P1e(),o=fu(),s=Jr(),a=dc(),c=bn(),l=Mt(),d=qre(),f=Tt(),h=py(),g=Kd().toArray,m=f("asyncIterator"),y=e(d("Array","values")),x=e(y([]).next),_=function(){return new w(this)},w=function(I){this.iterator=y(I)};return w.prototype.next=function(){return x(this.iterator)},vE=function(b){var P=this,C=arguments.length,k=C>1?arguments[1]:void 0,O=C>2?arguments[2]:void 0;return new(l("Promise"))(function(L){var j=t(b);k!==void 0&&(k=r(k,O));var F=c(j,m),$=F?void 0:a(j)||_,D=n(P)?new P:[],N=F?i(j,F):new h(s(o(j,$)));L(g(N,k,D))})},vE}var i9;function C1e(){if(i9)return Zz;i9=1;var r=H(),e=Eie(),t=Fe(),n=Array.fromAsync,i=!n||t(function(){var o=0;return n.call(function(){return o++,[]},{length:0}),o!==1});return r({target:"Array",stat:!0,forced:i},{fromAsync:e}),Zz}var o9={},s9;function T1e(){return s9||(s9=1,HC()),o9}var a9={},c9;function A1e(){if(c9)return a9;c9=1;var r=H(),e=In().filterReject,t=sn();return r({target:"Array",proto:!0,forced:!0},{filterOut:function(i){return e(this,i,arguments.length>1?arguments[1]:void 0)}}),t("filterOut"),a9}var l9={},u9;function R1e(){if(u9)return l9;u9=1;var r=H(),e=In().filterReject,t=sn();return r({target:"Array",proto:!0,forced:!0},{filterReject:function(i){return e(this,i,arguments.length>1?arguments[1]:void 0)}}),t("filterReject"),l9}var d9={},f9;function k1e(){return f9||(f9=1,kre()),d9}var h9={},p9;function O1e(){return p9||(p9=1,Ore()),h9}var g9={},mE,v9;function ZT(){if(v9)return mE;v9=1;var r=Ar(),e=Ie(),t=ol(),n=Zt(),i=lc(),o=sr(),s=En(),a=fl(),c=Array,l=e([].push);return mE=function(d,f,h,g){for(var m=n(d),y=t(m),x=r(f,h),_=s(null),w=o(y),I=0,b,P,C;w>I;I++)C=y[I],P=i(x(C,I,m)),P in _?l(_[P],C):_[P]=[C];if(g&&(b=g(m),b!==c))for(P in _)_[P]=a(b,_[P]);return _},mE}var m9;function M1e(){if(m9)return g9;m9=1;var r=H(),e=ZT(),t=sn();return r({target:"Array",proto:!0},{group:function(i){var o=arguments.length>1?arguments[1]:void 0;return e(this,i,o)}}),t("group"),g9}var y9={},S9;function j1e(){if(S9)return y9;S9=1;var r=H(),e=ZT(),t=$s(),n=sn();return r({target:"Array",proto:!0,forced:!t("groupBy")},{groupBy:function(o){var s=arguments.length>1?arguments[1]:void 0;return e(this,o,s)}}),n("groupBy"),y9}var x9={},yE,_9;function Iie(){if(_9)return yE;_9=1;var r=Ar(),e=Ie(),t=ol(),n=Zt(),i=sr(),o=Wn(),s=o.Map,a=o.get,c=o.has,l=o.set,d=e([].push);return yE=function(h){for(var g=n(this),m=t(g),y=r(h,arguments.length>1?arguments[1]:void 0),x=new s,_=i(m),w=0,I,b;_>w;w++)b=m[w],I=y(b,w,g),c(x,I)?d(a(x,I),b):l(x,I,[b]);return x},yE}var w9;function D1e(){if(w9)return x9;w9=1;var r=H(),e=$s(),t=sn(),n=Iie(),i=Xt();return r({target:"Array",proto:!0,name:"groupToMap",forced:i||!e("groupByToMap")},{groupByToMap:n}),t("groupByToMap"),x9}var b9={},E9;function L1e(){if(E9)return b9;E9=1;var r=H(),e=sn(),t=Iie(),n=Xt();return r({target:"Array",proto:!0,forced:n},{groupToMap:t}),e("groupToMap"),b9}var I9={},P9;function F1e(){if(P9)return I9;P9=1;var r=H(),e=Ia(),t=Object.isFrozen,n=function(i,o){if(!t||!e(i)||!t(i))return!1;for(var s=0,a=i.length,c;s<a;)if(c=i[s++],!(typeof c=="string"||o&&c===void 0))return!1;return a!==0};return r({target:"Array",stat:!0,sham:!0,forced:!0},{isTemplateObject:function(o){if(!n(o,!0))return!1;var s=o.raw;return s.length===o.length&&n(s,!1)}}),I9}var C9={},T9;function N1e(){if(T9)return C9;T9=1;var r=Et(),e=sn(),t=Zt(),n=sr(),i=Yr();return r&&(i(Array.prototype,"lastIndex",{configurable:!0,get:function(){var s=t(this),a=n(s);return a===0?0:a-1}}),e("lastIndex")),C9}var A9={},R9;function $1e(){if(R9)return A9;R9=1;var r=Et(),e=sn(),t=Zt(),n=sr(),i=Yr();return r&&(i(Array.prototype,"lastItem",{configurable:!0,get:function(){var s=t(this),a=n(s);return a===0?void 0:s[a-1]},set:function(s){var a=t(this),c=n(a);return a[c===0?0:c-1]=s}}),e("lastItem")),A9}var k9={},O9;function q1e(){return O9||(O9=1,$re()),k9}var M9={},j9;function B1e(){return j9||(j9=1,Bre()),M9}var D9={},L9;function U1e(){return L9||(L9=1,Ure()),D9}var F9={},SE,N9;function Bs(){if(N9)return SE;N9=1;var r=Ie(),e=pl(),t=Wn(),n=t.Map,i=t.proto,o=r(i.forEach),s=r(i.entries),a=s(new n).next;return SE=function(c,l,d){return d?e({iterator:s(c),next:a},function(f){return l(f[1],f[0])}):o(c,l)},SE}var xE,$9;function QT(){if($9)return xE;$9=1;var r=Ie(),e=jt(),t=Mn(),n=sr(),i=Zt(),o=Wn(),s=Bs(),a=o.Map,c=o.has,l=o.set,d=r([].push);return xE=function(h){var g=i(this),m=n(g),y=[],x=new a,_=t(h)?function(P){return P}:e(h),w,I,b;for(w=0;w<m;w++)I=g[w],b=_(I),c(x,b)||l(x,b,I);return s(x,function(P){d(y,P)}),y},xE}var q9;function z1e(){if(q9)return F9;q9=1;var r=H(),e=sn(),t=QT();return r({target:"Array",proto:!0,forced:!0},{uniqueBy:t}),e("uniqueBy"),F9}var B9={},U9;function H1e(){return U9||(U9=1,Hre()),B9}var z9={},H9;function W1e(){return H9||(H9=1,Jre()),z9}var W9={},K9;function K1e(){return K9||(K9=1,nne()),W9}var G9={},V9;function G1e(){return V9||(V9=1,ine()),G9}var Y9={},_E,X9;function Pie(){if(X9)return _E;X9=1;var r=Mt(),e=Qe(),t=Ie(),n=Ar(),i=Ze(),o=jt(),s=Mn(),a=bn(),c=Tt(),l=c("asyncDispose"),d=c("dispose"),f=t([].push),h=function(m,y){if(y==="async-dispose"){var x=a(m,l);return x!==void 0||(x=a(m,d),x===void 0)?x:function(){var _=this,w=r("Promise");return new w(function(I){e(x,_),I(void 0)})}}return a(m,d)},g=function(m,y,x){return arguments.length<3&&!s(m)&&(x=o(h(i(m),y))),x===void 0?function(){}:n(x,m)};return _E=function(m,y,x,_){var w;if(arguments.length<4){if(s(y)&&x==="sync-dispose")return;w=g(y,x)}else w=g(void 0,x,_);f(m.stack,w)},_E}var Z9;function V1e(){if(Z9)return Y9;Z9=1;var r=H(),e=Et(),t=Mt(),n=jt(),i=Wi(),o=wr(),s=qs(),a=Yr(),c=Tt(),l=_r(),d=Pie(),f=ba(),h=t("Promise"),g=t("SuppressedError"),m=ReferenceError,y=c("asyncDispose"),x=c("toStringTag"),_="AsyncDisposableStack",w=l.set,I=l.getterFor(_),b="async-dispose",P="disposed",C="pending",k=function(F){var $=I(F);if($.state===P)throw new m(_+" already disposed");return $},O=function(){w(i(this,L),{type:_,state:C,stack:[]}),e||(this.disposed=!1)},L=O.prototype;s(L,{disposeAsync:function(){var $=this;return new h(function(D,N){var B=I($);if(B.state===P)return D(void 0);B.state=P,e||($.disposed=!0);var W=B.stack,G=W.length,z=!1,V,J=function(Z){z?V=new g(Z,V):(z=!0,V=Z),K()},K=function(){if(G){var Z=W[--G];W[G]=null;try{h.resolve(Z()).then(K,J)}catch(ee){J(ee)}}else B.stack=null,z?N(V):D(void 0)};K()})},use:function($){return d(k(this),$,b),$},adopt:function($,D){var N=k(this);return n(D),d(N,void 0,b,function(){return D($)}),$},defer:function($){var D=k(this);n($),d(D,void 0,b,$)},move:function(){var $=k(this),D=new O;return I(D).stack=$.stack,$.stack=[],$.state=P,e||(this.disposed=!0),D}}),e&&a(L,"disposed",{configurable:!0,get:function(){return I(this).state===P}}),o(L,y,L.disposeAsync,{name:"disposeAsync"}),o(L,x,_,{nonWritable:!0});var j=f&&f<136;return r({global:!0,constructor:!0,forced:j},{AsyncDisposableStack:O}),Y9}var Q9={},J9;function Y1e(){if(J9)return Q9;J9=1;var r=H(),e=Wi(),t=Fn(),n=Dn(),i=Kt(),o=Tt(),s=tp(),a=Xt(),c=o("toStringTag"),l=TypeError,d=function(){if(e(this,s),t(this)===s)throw new l("Abstract class AsyncIterator not directly constructable")};return d.prototype=s,i(s,c)||n(s,c,"AsyncIterator"),(a||!i(s,"constructor")||s.constructor===Object)&&n(s,"constructor",d),r({global:!0,constructor:!0,forced:a},{AsyncIterator:d}),Q9}var e7={},wE,t7;function Gd(){if(t7)return wE;t7=1;var r=Qe(),e=mu(),t=Ze(),n=En(),i=Dn(),o=qs(),s=Tt(),a=_r(),c=Mt(),l=bn(),d=tp(),f=Hn(),h=dl(),g=c("Promise"),m=s("toStringTag"),y="AsyncIteratorHelper",x="WrapForValidAsyncIterator",_=a.set,w=function(P){var C=!P,k=a.getterFor(P?x:y),O=function(L){var j=e(function(){return k(L)}),F=j.error,$=j.value;return F||C&&$.done?{exit:!0,value:F?g.reject($):g.resolve(f(void 0,!0))}:{exit:!1,value:$}};return o(n(d),{next:function(){var j=O(this),F=j.value;if(j.exit)return F;var $=e(function(){return t(F.nextHandler(g))}),D=$.error,N=$.value;return D&&(F.done=!0),D?g.reject(N):g.resolve(N)},return:function(){var L=O(this),j=L.value;if(L.exit)return j;j.done=!0;var F=j.iterator,$,D,N=e(function(){if(j.inner)try{h(j.inner.iterator,"normal")}catch(B){return h(F,"throw",B)}return l(F,"return")});return $=D=N.value,N.error?g.reject(D):$===void 0?g.resolve(f(void 0,!0)):(N=e(function(){return r($,F)}),D=N.value,N.error?g.reject(D):P?g.resolve(D):g.resolve(D).then(function(B){return t(B),f(void 0,!0)}))}})},I=w(!0),b=w(!1);return i(b,m,"Async Iterator Helper"),wE=function(P,C){var k=function(L,j){j?(j.iterator=L.iterator,j.next=L.next):j=L,j.type=C?x:y,j.nextHandler=P,j.counter=0,j.done=!1,_(this,j)};return k.prototype=C?I:b,k},wE}var bE,r7;function Cie(){if(r7)return bE;r7=1;var r=Qe(),e=jt(),t=Ze(),n=Lt(),i=Jr(),o=Gd(),s=Hn(),a=rp(),c=o(function(l){var d=this,f=d.iterator,h=d.mapper;return new l(function(g,m){var y=function(_){d.done=!0,m(_)},x=function(_){a(f,y,_,y)};l.resolve(t(r(d.next,f))).then(function(_){try{if(t(_).done)d.done=!0,g(s(void 0,!0));else{var w=_.value;try{var I=h(w,d.counter++),b=function(P){g(s(P,!1))};n(I)?l.resolve(I).then(b,x):b(I)}catch(P){x(P)}}}catch(P){y(P)}},y)})});return bE=function(d){return t(this),e(d),new c(i(this),{mapper:d})},bE}var EE,n7;function Tie(){if(n7)return EE;n7=1;var r=Qe(),e=Cie(),t=function(n,i){return[i,n]};return EE=function(){return r(e,this,t)},EE}var i7;function X1e(){if(i7)return e7;i7=1;var r=H(),e=Tie();return r({target:"AsyncIterator",name:"indexed",proto:!0,real:!0,forced:!0},{asIndexedPairs:e}),e7}var o7={},s7;function Z1e(){if(s7)return o7;s7=1;var r=Qe(),e=wr(),t=Mt(),n=bn(),i=Kt(),o=Tt(),s=tp(),a=o("asyncDispose"),c=t("Promise");return i(s,a)||e(s,a,function(){var l=this;return new c(function(d,f){var h=n(l,"return");h?c.resolve(r(h,l)).then(function(){d(void 0)},f):d(void 0)})}),o7}var a7={},c7;function Q1e(){if(c7)return a7;c7=1;var r=H(),e=Qe(),t=Ze(),n=Jr(),i=Zh(),o=Qh(),s=Gd(),a=Hn(),c=Xt(),l=s(function(d){var f=this;return new d(function(h,g){var m=function(x){f.done=!0,g(x)},y=function(){try{d.resolve(t(e(f.next,f.iterator))).then(function(x){try{t(x).done?(f.done=!0,h(a(void 0,!0))):f.remaining?(f.remaining--,y()):h(a(x.value,!1))}catch(_){m(_)}},m)}catch(x){m(x)}};y()})});return r({target:"AsyncIterator",proto:!0,real:!0,forced:c},{drop:function(f){t(this);var h=o(i(+f));return new l(n(this),{remaining:h})}}),a7}var l7={},u7;function J1e(){if(u7)return l7;u7=1;var r=H(),e=Kd().every;return r({target:"AsyncIterator",proto:!0,real:!0},{every:function(n){return e(this,n)}}),l7}var d7={},f7;function eEe(){if(f7)return d7;f7=1;var r=H(),e=Qe(),t=jt(),n=Ze(),i=Lt(),o=Jr(),s=Gd(),a=Hn(),c=rp(),l=Xt(),d=s(function(f){var h=this,g=h.iterator,m=h.predicate;return new f(function(y,x){var _=function(b){h.done=!0,x(b)},w=function(b){c(g,_,b,_)},I=function(){try{f.resolve(n(e(h.next,g))).then(function(b){try{if(n(b).done)h.done=!0,y(a(void 0,!0));else{var P=b.value;try{var C=m(P,h.counter++),k=function(O){O?y(a(P,!1)):I()};i(C)?f.resolve(C).then(k,w):k(C)}catch(O){w(O)}}}catch(O){_(O)}},_)}catch(b){_(b)}};I()})});return r({target:"AsyncIterator",proto:!0,real:!0,forced:l},{filter:function(h){return n(this),t(h),new d(o(this),{predicate:h})}}),d7}var h7={},p7;function tEe(){if(p7)return h7;p7=1;var r=H(),e=Kd().find;return r({target:"AsyncIterator",proto:!0,real:!0},{find:function(n){return e(this,n)}}),h7}var g7={},IE,v7;function Aie(){if(v7)return IE;v7=1;var r=Qe(),e=Ut(),t=Ze(),n=Jr(),i=dc(),o=bn(),s=Tt(),a=py(),c=s("asyncIterator");return IE=function(l){var d=t(l),f=!0,h=o(d,c),g;return e(h)||(h=i(d),f=!1),h!==void 0?g=r(h,d):(g=d,f=!0),t(g),n(f?g:new a(n(g)))},IE}var m7;function rEe(){if(m7)return g7;m7=1;var r=H(),e=Qe(),t=jt(),n=Ze(),i=Lt(),o=Jr(),s=Gd(),a=Hn(),c=Aie(),l=rp(),d=Xt(),f=s(function(h){var g=this,m=g.iterator,y=g.mapper;return new h(function(x,_){var w=function(C){g.done=!0,_(C)},I=function(C){l(m,w,C,w)},b=function(){try{h.resolve(n(e(g.next,m))).then(function(C){try{if(n(C).done)g.done=!0,x(a(void 0,!0));else{var k=C.value;try{var O=y(k,g.counter++),L=function(j){try{g.inner=c(j),P()}catch(F){I(F)}};i(O)?h.resolve(O).then(L,I):L(O)}catch(j){I(j)}}}catch(j){w(j)}},w)}catch(C){w(C)}},P=function(){var C=g.inner;if(C)try{h.resolve(n(e(C.next,C.iterator))).then(function(k){try{n(k).done?(g.inner=null,b()):x(a(k.value,!1))}catch(O){I(O)}},I)}catch(k){I(k)}else b()};P()})});return r({target:"AsyncIterator",proto:!0,real:!0,forced:d},{flatMap:function(g){return n(this),t(g),new f(o(this),{mapper:g,inner:null})}}),g7}var y7={},S7;function nEe(){if(S7)return y7;S7=1;var r=H(),e=Kd().forEach;return r({target:"AsyncIterator",proto:!0,real:!0},{forEach:function(n){return e(this,n)}}),y7}var x7={},PE,_7;function Rie(){if(_7)return PE;_7=1;var r=Qe(),e=Gd();return PE=e(function(){return r(this.next,this.iterator)},!0),PE}var w7;function iEe(){if(w7)return x7;w7=1;var r=H(),e=Zt(),t=Ti(),n=Aie(),i=tp(),o=Rie(),s=Xt();return r({target:"AsyncIterator",stat:!0,forced:s},{from:function(c){var l=n(typeof c=="string"?e(c):c);return t(i,l.iterator)?l.iterator:new o(l)}}),x7}var b7={},E7;function oEe(){if(E7)return b7;E7=1;var r=H(),e=Tie();return r({target:"AsyncIterator",proto:!0,real:!0,forced:!0},{indexed:e}),b7}var I7={},P7;function sEe(){if(P7)return I7;P7=1;var r=H(),e=Cie(),t=Xt();return r({target:"AsyncIterator",proto:!0,real:!0,forced:t},{map:e}),I7}var C7={},T7;function aEe(){if(T7)return C7;T7=1;var r=H(),e=Qe(),t=jt(),n=Ze(),i=Lt(),o=Mt(),s=Jr(),a=rp(),c=o("Promise"),l=TypeError;return r({target:"AsyncIterator",proto:!0,real:!0},{reduce:function(f){n(this),t(f);var h=s(this),g=h.iterator,m=h.next,y=arguments.length<2,x=y?void 0:arguments[1],_=0;return new c(function(w,I){var b=function(C){a(g,I,C,I)},P=function(){try{c.resolve(n(e(m,g))).then(function(C){try{if(n(C).done)y?I(new l("Reduce of empty iterator with no initial value")):w(x);else{var k=C.value;if(y)y=!1,x=k,P();else try{var O=f(x,k,_),L=function(j){x=j,P()};i(O)?c.resolve(O).then(L,b):L(O)}catch(j){b(j)}}_++}catch(j){I(j)}},I)}catch(C){I(C)}};P()})}}),C7}var A7={},R7;function cEe(){if(R7)return A7;R7=1;var r=H(),e=Kd().some;return r({target:"AsyncIterator",proto:!0,real:!0},{some:function(n){return e(this,n)}}),A7}var k7={},O7;function lEe(){if(O7)return k7;O7=1;var r=H(),e=Qe(),t=Ze(),n=Jr(),i=Zh(),o=Qh(),s=Gd(),a=Hn(),c=Xt(),l=s(function(d){var f=this,h=f.iterator,g;if(!f.remaining--){var m=a(void 0,!0);return f.done=!0,g=h.return,g!==void 0?d.resolve(e(g,h,void 0)).then(function(){return m}):m}return d.resolve(e(f.next,h)).then(function(y){return t(y).done?(f.done=!0,a(void 0,!0)):a(y.value,!1)}).then(null,function(y){throw f.done=!0,y})});return r({target:"AsyncIterator",proto:!0,real:!0,forced:c},{take:function(f){t(this);var h=o(i(+f));return new l(n(this),{remaining:h})}}),k7}var M7={},j7;function uEe(){if(j7)return M7;j7=1;var r=H(),e=Kd().toArray;return r({target:"AsyncIterator",proto:!0,real:!0},{toArray:function(){return e(this,void 0,[])}}),M7}var D7={},CE,L7;function JT(){if(L7)return CE;L7=1;var r=_r(),e=hu(),t=Hn(),n=Mn(),i=Lt(),o=Yr(),s=Et(),a="Incorrect Iterator.range arguments",c="NumericRangeIterator",l=r.set,d=r.getterFor(c),f=RangeError,h=TypeError,g=e(function(x,_,w,I,b,P){if(typeof x!=I||_!==1/0&&_!==-1/0&&typeof _!=I)throw new h(a);if(x===1/0||x===-1/0)throw new f(a);var C=_>x,k=!1,O;if(w===void 0)O=void 0;else if(i(w))O=w.step,k=!!w.inclusive;else if(typeof w==I)O=w;else throw new h(a);if(n(O)&&(O=C?P:-P),typeof O!=I)throw new h(a);if(O===1/0||O===-1/0||O===b&&x!==_)throw new f(a);var L=x!==x||_!==_||O!==O||_>x!=O>b;l(this,{type:c,start:x,end:_,step:O,inclusive:k,hitsEnd:L,currentCount:b,zero:b}),s||(this.start=x,this.end=_,this.step=O,this.inclusive=k)},c,function(){var x=d(this);if(x.hitsEnd)return t(void 0,!0);var _=x.start,w=x.end,I=x.step,b=_+I*x.currentCount++;b===w&&(x.hitsEnd=!0);var P=x.inclusive,C;return w>_?C=P?b>w:b>=w:C=P?w>b:w>=b,C?(x.hitsEnd=!0,t(void 0,!0)):t(b,!1)}),m=function(y){o(g.prototype,y,{get:function(){return d(this)[y]},set:function(){},configurable:!0,enumerable:!1})};return s&&(m("start"),m("end"),m("inclusive"),m("step")),CE=g,CE}var F7;function dEe(){if(F7)return D7;F7=1;var r=H(),e=JT();return typeof BigInt=="function"&&r({target:"BigInt",stat:!0,forced:!0},{range:function(n,i,o){return new e(n,i,o,"bigint",BigInt(0),BigInt(1))}}),D7}var N7={},TE,$7;function kie(){if($7)return TE;$7=1,qT(),XT();var r=Mt(),e=En(),t=Lt(),n=Object,i=TypeError,o=r("Map"),s=r("WeakMap"),a=function(){this.object=null,this.symbol=null,this.primitives=null,this.objectsByIndex=e(null)};a.prototype.get=function(l,d){return this[l]||(this[l]=d())},a.prototype.next=function(l,d,f){var h=f?this.objectsByIndex[l]||(this.objectsByIndex[l]=new s):this.primitives||(this.primitives=new o),g=h.get(d);return g||h.set(d,g=new a),g};var c=new a;return TE=function(){var l=c,d=arguments.length,f,h;for(f=0;f<d;f++)t(h=arguments[f])&&(l=l.next(f,h,!0));if(this===n&&l===c)throw new i("Composite keys must contain a non-primitive component");for(f=0;f<d;f++)t(h=arguments[f])||(l=l.next(f,h,!1));return l},TE}var q7;function fEe(){if(q7)return N7;q7=1;var r=H(),e=zi(),t=kie(),n=Mt(),i=En(),o=Object,s=function(){var a=n("Object","freeze");return a?a(i(null)):i(null)};return r({global:!0,forced:!0},{compositeKey:function(){return e(t,o,arguments).get("object",s)}}),N7}var B7={},U7;function hEe(){if(U7)return B7;U7=1;var r=H(),e=kie(),t=Mt(),n=zi();return r({global:!0,forced:!0},{compositeSymbol:function(){return arguments.length===1&&typeof arguments[0]=="string"?t("Symbol").for(arguments[0]):n(e,null,arguments).get("symbol",t("Symbol"))}}),B7}var z7={},H7;function pEe(){return H7||(H7=1,Gre()),z7}var W7={},K7;function gEe(){if(K7)return W7;K7=1;var r=H(),e=Ie(),t=e(DataView.prototype.getUint8);return r({target:"DataView",proto:!0,forced:!0},{getUint8Clamped:function(i){return t(this,i)}}),W7}var G7={},V7;function vEe(){return V7||(V7=1,Xre()),G7}var Y7={},X7;function mEe(){if(X7)return Y7;X7=1;var r=H(),e=Ie(),t=Vre(),n=Yh(),i=gie(),o=e(DataView.prototype.setUint8);return r({target:"DataView",proto:!0,forced:!0},{setUint8Clamped:function(a,c){t(this);var l=n(a);return o(this,l,i(c))}}),Y7}var Z7={},Q7;function yEe(){if(Q7)return Z7;Q7=1;var r=H(),e=Et(),t=Mt(),n=jt(),i=Wi(),o=wr(),s=qs(),a=Yr(),c=Tt(),l=_r(),d=Pie(),f=t("SuppressedError"),h=ReferenceError,g=c("dispose"),m=c("toStringTag"),y="DisposableStack",x=l.set,_=l.getterFor(y),w="sync-dispose",I="disposed",b="pending",P=function(O){var L=_(O);if(L.state===I)throw new h(y+" already disposed");return L},C=function(){x(i(this,k),{type:y,state:b,stack:[]}),e||(this.disposed=!1)},k=C.prototype;return s(k,{dispose:function(){var L=_(this);if(L.state!==I){L.state=I,e||(this.disposed=!0);for(var j=L.stack,F=j.length,$=!1,D;F;){var N=j[--F];j[F]=null;try{N()}catch(B){$?D=new f(B,D):($=!0,D=B)}}if(L.stack=null,$)throw D}},use:function(L){return d(P(this),L,w),L},adopt:function(L,j){var F=P(this);return n(j),d(F,void 0,w,function(){j(L)}),L},defer:function(L){var j=P(this);n(L),d(j,void 0,w,L)},move:function(){var L=P(this),j=new C;return _(j).stack=L.stack,L.stack=[],L.state=I,e||(this.disposed=!0),j}}),e&&a(k,"disposed",{configurable:!0,get:function(){return _(this).state===I}}),o(k,g,k.dispose,{name:"dispose"}),o(k,m,y,{nonWritable:!0}),r({global:!0,constructor:!0},{DisposableStack:C}),Z7}var J7={},eH;function SEe(){if(eH)return J7;eH=1;var r=H(),e=Mt(),t=Lt(),n=vo(),i=Fe(),o="Error",s="DOMException",a=Object.setPrototypeOf||{}.__proto__,c=e(s),l=Error,d=l.isError,f=!d||!a||i(function(){return c&&!d(new c(s))||!d(new l(o,{cause:function(){}}))||d(e("Object","create")(l.prototype))});return r({target:"Error",stat:!0,sham:!0,forced:f},{isError:function(g){if(!t(g))return!1;var m=n(g);return m===o||m===s}}),J7}var tH={},AE,rH;function Oie(){if(rH)return AE;rH=1;var r=Ie(),e=jt();return AE=function(){return r(e(this))},AE}var nH;function xEe(){if(nH)return tH;nH=1;var r=H(),e=Oie();return r({target:"Function",proto:!0,forced:!0},{demethodize:e}),tH}var iH={},oH;function _Ee(){if(oH)return iH;oH=1;var r=H(),e=Ie(),t=Ut(),n=Cm(),i=Kt(),o=Et(),s=Object.getOwnPropertyDescriptor,a=/^\s*class\b/,c=e(a.exec),l=function(d){try{if(!o||!c(a,n(d)))return!1}catch{}var f=s(d,"prototype");return!!f&&i(f,"writable")&&!f.writable};return r({target:"Function",stat:!0,sham:!0,forced:!0},{isCallable:function(f){return t(f)&&!l(f)}}),iH}var sH={},aH;function wEe(){if(aH)return sH;aH=1;var r=H(),e=Pa();return r({target:"Function",stat:!0,forced:!0},{isConstructor:e}),sH}var cH={},lH;function bEe(){if(lH)return cH;lH=1;var r=Tt(),e=Or().f,t=r("metadata"),n=Function.prototype;return n[t]===void 0&&e(n,t,{value:null}),cH}var uH={},dH;function EEe(){if(dH)return uH;dH=1;var r=H(),e=Oie();return r({target:"Function",proto:!0,forced:!0,name:"demethodize"},{unThis:e}),uH}var fH={},hH;function IEe(){return hH||(hH=1,sne()),fH}var pH={},gH;function PEe(){return gH||(gH=1,ane()),pH}var vH={},RE,mH;function Mie(){if(mH)return RE;mH=1;var r=Qe(),e=vne(),t=function(n,i){return[i,n]};return RE=function(){return r(e,this,t)},RE}var yH;function CEe(){if(yH)return vH;yH=1;var r=H(),e=Mie();return r({target:"Iterator",name:"indexed",proto:!0,real:!0,forced:!0},{asIndexedPairs:e}),vH}var SH={},xH;function TEe(){if(xH)return SH;xH=1;var r=H(),e=Qe(),t=jt(),n=Ze(),i=dc(),o=gu(),s=Hn(),a=Array,c=o(function(){for(;;){var l=this.iterator;if(!l){var d=this.nextIterableIndex++,f=this.iterables;if(d>=f.length)return this.done=!0,s(void 0,!0);var h=f[d];this.iterables[d]=null,l=this.iterator=e(h.method,h.iterable),this.next=l.next}var g=n(e(this.next,l));if(g.done){this.iterator=null,this.next=null;continue}return g}},!1,!0);return r({target:"Iterator",stat:!0,forced:!0},{concat:function(){for(var d=arguments.length,f=a(d),h=0;h<d;h++){var g=n(arguments[h]);f[h]={iterable:g,method:t(i(g))}}return new c({iterables:f,nextIterableIndex:0,iterator:null,next:null})}}),SH}var _H={},wH;function AEe(){if(wH)return _H;wH=1;var r=Qe(),e=wr(),t=bn(),n=Kt(),i=Tt(),o=Bd().IteratorPrototype,s=i("dispose");return n(o,s)||e(o,s,function(){var a=t(this,"return");a&&r(a,this)}),_H}var bH={},EH;function REe(){return EH||(EH=1,cne()),bH}var IH={},PH;function kEe(){return PH||(PH=1,lne()),IH}var CH={},TH;function OEe(){return TH||(TH=1,une()),CH}var AH={},RH;function MEe(){return RH||(RH=1,dne()),AH}var kH={},OH;function jEe(){return OH||(OH=1,hne()),kH}var MH={},jH;function DEe(){return jH||(jH=1,pne()),MH}var DH={},LH;function LEe(){return LH||(LH=1,gne()),DH}var FH={},NH;function FEe(){if(NH)return FH;NH=1;var r=H(),e=Mie();return r({target:"Iterator",proto:!0,real:!0,forced:!0},{indexed:e}),FH}var $H={},qH;function NEe(){return qH||(qH=1,mne()),$H}var BH={},UH;function $Ee(){if(UH)return BH;UH=1;var r=H(),e=JT(),t=TypeError;return r({target:"Iterator",stat:!0,forced:!0},{range:function(i,o,s){if(typeof i=="number")return new e(i,o,s,"number",0,1);if(typeof i=="bigint")return new e(i,o,s,"bigint",BigInt(0),BigInt(1));throw new t("Incorrect Iterator.range arguments")}}),BH}var zH={},HH;function qEe(){return HH||(HH=1,yne()),zH}var WH={},KH;function BEe(){return KH||(KH=1,Sne()),WH}var GH={},VH;function UEe(){return VH||(VH=1,xne()),GH}var YH={},XH;function zEe(){return XH||(XH=1,_ne()),YH}var ZH={},QH;function HEe(){if(QH)return ZH;QH=1;var r=H(),e=Ze(),t=py(),n=Rie(),i=Jr(),o=Xt();return r({target:"Iterator",proto:!0,real:!0,forced:o},{toAsync:function(){return new n(i(new t(i(e(this)))))}}),ZH}var JH={},kE,eW;function jie(){if(eW)return kE;eW=1;var r=Fe();return kE=!r(function(){var e="9007199254740993",t=JSON.rawJSON(e);return!JSON.isRawJSON(t)||JSON.stringify(t)!==e}),kE}var OE,tW;function Die(){if(tW)return OE;tW=1;var r=Lt(),e=_r().get;return OE=function(n){if(!r(n))return!1;var i=e(n);return!!i&&i.type==="RawJSON"},OE}var rW;function WEe(){if(rW)return JH;rW=1;var r=H(),e=jie(),t=Die();return r({target:"JSON",stat:!0,forced:!e},{isRawJSON:t}),JH}var nW={},ME,iW;function Lie(){if(iW)return ME;iW=1;var r=Ie(),e=Kt(),t=SyntaxError,n=parseInt,i=String.fromCharCode,o=r("".charAt),s=r("".slice),a=r(/./.exec),c={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
100
- `,"\\r":"\r","\\t":" "},l=/^[\da-f]{4}$/i,d=/^[\u0000-\u001F]$/;return ME=function(f,h){for(var g=!0,m="";h<f.length;){var y=o(f,h);if(y==="\\"){var x=s(f,h,h+2);if(e(c,x))m+=c[x],h+=2;else if(x==="\\u"){h+=2;var _=s(f,h,h+4);if(!a(l,_))throw new t("Bad Unicode escape at: "+h);m+=i(n(_,16)),h+=4}else throw new t('Unknown escape sequence: "'+x+'"')}else if(y==='"'){g=!1,h++;break}else{if(a(d,y))throw new t("Bad control character in string literal at: "+h);m+=y,h++}}if(g)throw new t("Unterminated string at: "+h);return{value:m,end:h}},ME}var oW;function KEe(){if(oW)return nW;oW=1;var r=H(),e=Et(),t=Xe(),n=Mt(),i=Ie(),o=Qe(),s=Ut(),a=Lt(),c=Ia(),l=Kt(),d=Nt(),f=sr(),h=Ns(),g=Fe(),m=Lie(),y=ou(),x=t.JSON,_=t.Number,w=t.SyntaxError,I=x&&x.parse,b=n("Object","keys"),P=Object.getOwnPropertyDescriptor,C=i("".charAt),k=i("".slice),O=i(/./.exec),L=i([].push),j=/^\d$/,F=/^[1-9]$/,$=/^[\d-]$/,D=/^[\t\n\r ]$/,N=0,B=1,W=function(ee,re){ee=d(ee);var te=new J(ee,0),le=te.parse(),ge=le.value,se=te.skip(D,le.end);if(se<ee.length)throw new w('Unexpected extra character: "'+C(ee,se)+'" after the parsed data at: '+se);return s(re)?G({"":ge},"",re,le):ge},G=function(ee,re,te,le){var ge=ee[re],se=le&&ge===le.value,ce=se&&typeof le.source=="string"?{source:le.source}:{},_e,Le,Ge,qe,mt;if(a(ge)){var St=c(ge),et=se?le.nodes:St?[]:{};if(St)for(_e=et.length,Ge=f(ge),qe=0;qe<Ge;qe++)z(ge,qe,G(ge,""+qe,te,qe<_e?et[qe]:void 0));else for(Le=b(ge),Ge=f(Le),qe=0;qe<Ge;qe++)mt=Le[qe],z(ge,mt,G(ge,mt,te,l(et,mt)?et[mt]:void 0))}return o(te,ee,re,ge,ce)},z=function(ee,re,te){if(e){var le=P(ee,re);if(le&&!le.configurable)return}te===void 0?delete ee[re]:h(ee,re,te)},V=function(ee,re,te,le){this.value=ee,this.end=re,this.source=te,this.nodes=le},J=function(ee,re){this.source=ee,this.index=re};J.prototype={fork:function(ee){return new J(this.source,ee)},parse:function(){var ee=this.source,re=this.skip(D,this.index),te=this.fork(re),le=C(ee,re);if(O($,le))return te.number();switch(le){case"{":return te.object();case"[":return te.array();case'"':return te.string();case"t":return te.keyword(!0);case"f":return te.keyword(!1);case"n":return te.keyword(null)}throw new w('Unexpected character: "'+le+'" at: '+re)},node:function(ee,re,te,le,ge){return new V(re,le,ee?null:k(this.source,te,le),ge)},object:function(){for(var ee=this.source,re=this.index+1,te=!1,le={},ge={};re<ee.length;){if(re=this.until(['"',"}"],re),C(ee,re)==="}"&&!te){re++;break}var se=this.fork(re).string(),ce=se.value;re=se.end,re=this.until([":"],re)+1,re=this.skip(D,re),se=this.fork(re).parse(),h(ge,ce,se),h(le,ce,se.value),re=this.until([",","}"],se.end);var _e=C(ee,re);if(_e===",")te=!0,re++;else if(_e==="}"){re++;break}}return this.node(B,le,this.index,re,ge)},array:function(){for(var ee=this.source,re=this.index+1,te=!1,le=[],ge=[];re<ee.length;){if(re=this.skip(D,re),C(ee,re)==="]"&&!te){re++;break}var se=this.fork(re).parse();if(L(ge,se),L(le,se.value),re=this.until([",","]"],se.end),C(ee,re)===",")te=!0,re++;else if(C(ee,re)==="]"){re++;break}}return this.node(B,le,this.index,re,ge)},string:function(){var ee=this.index,re=m(this.source,this.index+1);return this.node(N,re.value,ee,re.end)},number:function(){var ee=this.source,re=this.index,te=re;if(C(ee,te)==="-"&&te++,C(ee,te)==="0")te++;else if(O(F,C(ee,te)))te=this.skip(j,te+1);else throw new w("Failed to parse number at: "+te);if(C(ee,te)==="."&&(te=this.skip(j,te+1)),C(ee,te)==="e"||C(ee,te)==="E"){te++,(C(ee,te)==="+"||C(ee,te)==="-")&&te++;var le=te;if(te=this.skip(j,te),le===te)throw new w("Failed to parse number's exponent value at: "+te)}return this.node(N,_(k(ee,re,te)),re,te)},keyword:function(ee){var re=""+ee,te=this.index,le=te+re.length;if(k(this.source,te,le)!==re)throw new w("Failed to parse value at: "+te);return this.node(N,ee,te,le)},skip:function(ee,re){for(var te=this.source;re<te.length&&O(ee,C(te,re));re++);return re},until:function(ee,re){re=this.skip(D,re);for(var te=C(this.source,re),le=0;le<ee.length;le++)if(ee[le]===te)return re;throw new w('Unexpected character: "'+te+'" at: '+re)}};var K=g(function(){var ee="9007199254740993",re;return I(ee,function(te,le,ge){re=ge.source}),re!==ee}),Z=y&&!g(function(){return 1/I("-0 ")!==-1/0});return r({target:"JSON",stat:!0,forced:K},{parse:function(re,te){return Z&&!s(te)?I(re):W(re,te)}}),nW}var sW={},aW;function GEe(){if(aW)return sW;aW=1;var r=H(),e=hl(),t=jie(),n=Mt(),i=Qe(),o=Ie(),s=Ut(),a=Die(),c=Nt(),l=Ns(),d=Lie(),f=xre(),h=au(),g=_r().set,m=String,y=SyntaxError,x=n("JSON","parse"),_=n("JSON","stringify"),w=n("Object","create"),I=n("Object","freeze"),b=o("".charAt),P=o("".slice),C=o([].push),k=h(),O=k.length,L="Unacceptable as raw JSON",j=function(F){return F===" "||F===" "||F===`
101
- `||F==="\r"};return r({target:"JSON",stat:!0,forced:!t},{rawJSON:function($){var D=c($);if(D===""||j(b(D,0))||j(b(D,D.length-1)))throw new y(L);var N=x(D);if(typeof N=="object"&&N!==null)throw new y(L);var B=w(null);return g(B,{type:"RawJSON"}),l(B,"rawJSON",D),e?I(B):B}}),_&&r({target:"JSON",stat:!0,arity:3,forced:!t},{stringify:function($,D,N){var B=f(D),W=[],G=_($,function(re,te){var le=s(B)?i(B,this,m(re),te):te;return a(le)?k+(C(W,le.rawJSON)-1):le},N);if(typeof G!="string")return G;for(var z="",V=G.length,J=0;J<V;J++){var K=b(G,J);if(K==='"'){var Z=d(G,++J).end-1,ee=P(G,J,Z);z+=P(ee,0,O)===k?W[P(ee,O)]:'"'+ee+'"',J=Z}else z+=K}return z}}),sW}var cW={},jE,lW;function Ri(){if(lW)return jE;lW=1;var r=Wn().has;return jE=function(e){return r(e),e},jE}var uW;function VEe(){if(uW)return cW;uW=1;var r=H(),e=Ri(),t=Wn().remove;return r({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var i=e(this),o=!0,s,a=0,c=arguments.length;a<c;a++)s=t(i,arguments[a]),o=o&&s;return!!o}}),cW}var dW={},fW;function YEe(){if(fW)return dW;fW=1;var r=H(),e=Ri(),t=Wn(),n=t.get,i=t.has,o=t.set;return r({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(a,c){var l=e(this),d,f;return i(l,a)?(d=n(l,a),"update"in c&&(d=c.update(d,a,l),o(l,a,d)),d):(f=c.insert(a,l),o(l,a,f),f)}}),dW}var hW={},pW;function XEe(){if(pW)return hW;pW=1;var r=H(),e=Ar(),t=Ri(),n=Bs();return r({target:"Map",proto:!0,real:!0,forced:!0},{every:function(o){var s=t(this),a=e(o,arguments.length>1?arguments[1]:void 0);return n(s,function(c,l){if(!a(c,l,s))return!1},!0)!==!1}}),hW}var gW={},vW;function ZEe(){if(vW)return gW;vW=1;var r=H(),e=Ar(),t=Ri(),n=Wn(),i=Bs(),o=n.Map,s=n.set;return r({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(c){var l=t(this),d=e(c,arguments.length>1?arguments[1]:void 0),f=new o;return i(l,function(h,g){d(h,g,l)&&s(f,g,h)}),f}}),gW}var mW={},yW;function QEe(){if(yW)return mW;yW=1;var r=H(),e=Ar(),t=Ri(),n=Bs();return r({target:"Map",proto:!0,real:!0,forced:!0},{find:function(o){var s=t(this),a=e(o,arguments.length>1?arguments[1]:void 0),c=n(s,function(l,d){if(a(l,d,s))return{value:l}},!0);return c&&c.value}}),mW}var SW={},xW;function JEe(){if(xW)return SW;xW=1;var r=H(),e=Ar(),t=Ri(),n=Bs();return r({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(o){var s=t(this),a=e(o,arguments.length>1?arguments[1]:void 0),c=n(s,function(l,d){if(a(l,d,s))return{key:d}},!0);return c&&c.key}}),SW}var _W={},DE,wW;function gy(){if(wW)return DE;wW=1;var r=Ar(),e=Ze(),t=Zt(),n=cn();return DE=function(i,o,s){return function(c){var l=t(c),d=arguments.length,f=d>1?arguments[1]:void 0,h=f!==void 0,g=h?r(f,d>2?arguments[2]:void 0):void 0,m=new i,y=0;return n(l,function(x){var _=h?g(x,y++):x;s?o(m,e(_)[0],_[1]):o(m,_)}),m}},DE}var bW;function eIe(){if(bW)return _W;bW=1;var r=H(),e=Wn(),t=gy();return r({target:"Map",stat:!0,forced:!0},{from:t(e.Map,e.set,!0)}),_W}var EW={},IW;function tIe(){if(IW)return EW;IW=1;var r=H(),e=Ri(),t=Wn(),n=t.get,i=t.has,o=t.set;return r({target:"Map",proto:!0,real:!0,forced:!0},{getOrInsert:function(a,c){return i(e(this),a)?n(this,a):(o(this,a,c),c)}}),EW}var PW={},CW;function rIe(){if(CW)return PW;CW=1;var r=H(),e=jt(),t=Ri(),n=Wn(),i=n.get,o=n.has,s=n.set;return r({target:"Map",proto:!0,real:!0,forced:!0},{getOrInsertComputed:function(c,l){if(t(this),e(l),o(this,c))return i(this,c);c===0&&1/c===-1/0&&(c=0);var d=l(c);return s(this,c,d),d}}),PW}var TW={},AW;function nIe(){return AW||(AW=1,bne()),TW}var RW={},LE,kW;function iIe(){return kW||(kW=1,LE=function(r,e){return r===e||r!==r&&e!==e}),LE}var OW;function oIe(){if(OW)return RW;OW=1;var r=H(),e=iIe(),t=Ri(),n=Bs();return r({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(o){return n(t(this),function(s){if(e(s,o))return!0},!0)===!0}}),RW}var MW={},jW;function sIe(){if(jW)return MW;jW=1;var r=H(),e=Qe(),t=cn(),n=Ut(),i=jt(),o=Wn().Map;return r({target:"Map",stat:!0,forced:!0},{keyBy:function(a,c){var l=n(this)?this:o,d=new l;i(c);var f=i(d.set);return t(a,function(h){e(f,d,c(h),h)}),d}}),MW}var DW={},LW;function aIe(){if(LW)return DW;LW=1;var r=H(),e=Ri(),t=Bs();return r({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(i){var o=t(e(this),function(s,a){if(s===i)return{key:a}},!0);return o&&o.key}}),DW}var FW={},NW;function cIe(){if(NW)return FW;NW=1;var r=H(),e=Ar(),t=Ri(),n=Wn(),i=Bs(),o=n.Map,s=n.set;return r({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(c){var l=t(this),d=e(c,arguments.length>1?arguments[1]:void 0),f=new o;return i(l,function(h,g){s(f,d(h,g,l),h)}),f}}),FW}var $W={},qW;function lIe(){if(qW)return $W;qW=1;var r=H(),e=Ar(),t=Ri(),n=Wn(),i=Bs(),o=n.Map,s=n.set;return r({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(c){var l=t(this),d=e(c,arguments.length>1?arguments[1]:void 0),f=new o;return i(l,function(h,g){s(f,g,d(h,g,l))}),f}}),$W}var BW={},UW;function uIe(){if(UW)return BW;UW=1;var r=H(),e=Ri(),t=cn(),n=Wn().set;return r({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(o){for(var s=e(this),a=arguments.length,c=0;c<a;)t(arguments[c++],function(l,d){n(s,l,d)},{AS_ENTRIES:!0});return s}}),BW}var zW={},FE,HW;function vy(){if(HW)return FE;HW=1;var r=Ze();return FE=function(e,t,n){return function(){for(var o=new e,s=arguments.length,a=0;a<s;a++){var c=arguments[a];n?t(o,r(c)[0],c[1]):t(o,c)}return o}},FE}var WW;function dIe(){if(WW)return zW;WW=1;var r=H(),e=Wn(),t=vy();return r({target:"Map",stat:!0,forced:!0},{of:t(e.Map,e.set,!0)}),zW}var KW={},GW;function fIe(){if(GW)return KW;GW=1;var r=H(),e=jt(),t=Ri(),n=Bs(),i=TypeError;return r({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(s){var a=t(this),c=arguments.length<2,l=c?void 0:arguments[1];if(e(s),n(a,function(d,f){c?(c=!1,l=d):l=s(l,d,f,a)}),c)throw new i("Reduce of empty map with no initial value");return l}}),KW}var VW={},YW;function hIe(){if(YW)return VW;YW=1;var r=H(),e=Ar(),t=Ri(),n=Bs();return r({target:"Map",proto:!0,real:!0,forced:!0},{some:function(o){var s=t(this),a=e(o,arguments.length>1?arguments[1]:void 0);return n(s,function(c,l){if(a(c,l,s))return!0},!0)===!0}}),VW}var XW={},ZW;function pIe(){if(ZW)return XW;ZW=1;var r=H(),e=jt(),t=Ri(),n=Wn(),i=TypeError,o=n.get,s=n.has,a=n.set;return r({target:"Map",proto:!0,real:!0,forced:!0},{update:function(l,d){var f=t(this),h=arguments.length;e(d);var g=s(f,l);if(!g&&h<3)throw new i("Updating absent value");var m=g?o(f,l):e(h>2?arguments[2]:void 0)(l,f);return a(f,l,d(m,l,f)),f}}),XW}var QW={},NE,JW;function eA(){if(JW)return NE;JW=1;var r=Qe(),e=jt(),t=Ut(),n=Ze(),i=TypeError;return NE=function(s,a){var c=n(this),l=e(c.get),d=e(c.has),f=e(c.set),h=arguments.length>2?arguments[2]:void 0,g;if(!t(a)&&!t(h))throw new i("At least one callback required");return r(d,c,s)?(g=r(l,c,s),t(a)&&(g=a(g),r(f,c,s,g))):t(h)&&(g=h(),r(f,c,s,g)),g},NE}var eK;function gIe(){if(eK)return QW;eK=1;var r=H(),e=eA();return r({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:e}),QW}var tK={},rK;function vIe(){if(rK)return tK;rK=1;var r=H(),e=eA();return r({target:"Map",proto:!0,real:!0,forced:!0},{upsert:e}),tK}var nK={},$E,iK;function mIe(){if(iK)return $E;iK=1;var r=TypeError;return $E=function(e){if(typeof e=="number")return e;throw new r("Argument is not a number")},$E}var oK;function yIe(){if(oK)return nK;oK=1;var r=H(),e=mIe(),t=Zh(),n=UT(),i=RangeError,o=Math.min,s=Math.max;return r({target:"Math",stat:!0,forced:!0},{clamp:function(c,l,d){if(e(c),t(e(l)),t(e(d)),n(l,0)&&n(d,-0)||l>d)throw new i("`min` should be smaller than `max`");return o(d,s(l,c))}}),nK}var sK={},aK;function SIe(){if(aK)return sK;aK=1;var r=H();return r({target:"Math",stat:!0,nonConfigurable:!0,nonWritable:!0},{DEG_PER_RAD:Math.PI/180}),sK}var cK={},lK;function xIe(){if(lK)return cK;lK=1;var r=H(),e=180/Math.PI;return r({target:"Math",stat:!0,forced:!0},{degrees:function(n){return n*e}}),cK}var uK={},qE,dK;function Fie(){return dK||(dK=1,qE=function(e,t,n,i,o){var s=+e,a=+t,c=+n,l=+i,d=+o;return s!==s||a!==a||c!==c||l!==l||d!==d?NaN:s===1/0||s===-1/0?s:(s-a)*(d-l)/(c-a)+l}),qE}var fK;function _Ie(){if(fK)return uK;fK=1;var r=H(),e=Fie(),t=LT();return r({target:"Math",stat:!0,forced:!0},{fscale:function(i,o,s,a,c){return t(e(i,o,s,a,c))}}),uK}var hK={},pK;function wIe(){return pK||(pK=1,Ine()),hK}var gK={},vK;function bIe(){if(vK)return gK;vK=1;var r=H();return r({target:"Math",stat:!0,forced:!0},{iaddh:function(t,n,i,o){var s=t>>>0,a=n>>>0,c=i>>>0;return a+(o>>>0)+((s&c|(s|c)&~(s+c>>>0))>>>31)|0}}),gK}var mK={},yK;function EIe(){if(yK)return mK;yK=1;var r=H();return r({target:"Math",stat:!0,forced:!0},{imulh:function(t,n){var i=65535,o=+t,s=+n,a=o&i,c=s&i,l=o>>16,d=s>>16,f=(l*c>>>0)+(a*c>>>16);return l*d+(f>>16)+((a*d>>>0)+(f&i)>>16)}}),mK}var SK={},xK;function IIe(){if(xK)return SK;xK=1;var r=H();return r({target:"Math",stat:!0,forced:!0},{isubh:function(t,n,i,o){var s=t>>>0,a=n>>>0,c=i>>>0;return a-(o>>>0)-((~s&c|~(s^c)&s-c>>>0)>>>31)|0}}),SK}var _K={},wK;function PIe(){if(wK)return _K;wK=1;var r=H();return r({target:"Math",stat:!0,nonConfigurable:!0,nonWritable:!0},{RAD_PER_DEG:180/Math.PI}),_K}var bK={},EK;function CIe(){if(EK)return bK;EK=1;var r=H(),e=Math.PI/180;return r({target:"Math",stat:!0,forced:!0},{radians:function(n){return n*e}}),bK}var IK={},PK;function TIe(){if(PK)return IK;PK=1;var r=H(),e=Fie();return r({target:"Math",stat:!0,forced:!0},{scale:e}),IK}var CK={},TK;function AIe(){if(TK)return CK;TK=1;var r=H(),e=Ze(),t=Cne(),n=hu(),i=Hn(),o=_r(),s="Seeded Random",a=s+" Generator",c='Math.seededPRNG() argument should have a "seed" field with a finite value.',l=o.set,d=o.getterFor(a),f=TypeError,h=n(function(m){l(this,{type:a,seed:m%2147483647})},s,function(){var m=d(this),y=m.seed=(m.seed*1103515245+12345)%2147483647;return i((y&1073741823)/1073741823,!1)});return r({target:"Math",stat:!0,forced:!0},{seededPRNG:function(m){var y=e(m).seed;if(!t(y))throw new f(c);return new h(y)}}),CK}var AK={},RK;function RIe(){if(RK)return AK;RK=1;var r=H();return r({target:"Math",stat:!0,forced:!0},{signbit:function(t){var n=+t;return n===n&&n===0?1/n===-1/0:n<0}}),AK}var kK={},OK;function kIe(){if(OK)return kK;OK=1;var r=H(),e=Ie(),t=cn(),n=RangeError,i=TypeError,o=1/0,s=NaN,a=Math.abs,c=Math.pow,l=e([].push),d=c(2,1023),f=c(2,53)-1,h=Number.MAX_VALUE,g=c(2,971),m={},y={},x={},_={},w={},I=function(b,P){var C=b+P,k=P-(C-b);return{hi:C,lo:k}};return r({target:"Math",stat:!0},{sumPrecise:function(P){var C=[],k=0,O=_;switch(t(P,function(ee){if(++k>=f)throw new n("Maximum allowed index exceeded");if(typeof ee!="number")throw new i("Value is not a number");O!==m&&(ee!==ee?O=m:ee===o?O=O===y?m:x:ee===-o?O=O===x?m:y:(ee!==0||1/ee===o)&&(O===_||O===w)&&(O=w,l(C,ee)))}),O){case m:return s;case y:return-o;case x:return o;case _:return-0}for(var L=[],j=0,F,$,D,N,B,W,G=0;G<C.length;G++){F=C[G];for(var z=0,V=0;V<L.length;V++){if($=L[V],a(F)<a($)&&(W=F,F=$,$=W),D=I(F,$),N=D.hi,B=D.lo,a(N)===o){var J=N===o?1:-1;j+=J,F=F-J*d-J*d,a(F)<a($)&&(W=F,F=$,$=W),D=I(F,$),N=D.hi,B=D.lo}B!==0&&(L[z++]=B),F=N}L.length=z,F!==0&&l(L,F)}var K=L.length-1;if(N=0,B=0,j!==0){var Z=K>=0?L[K]:0;if(K--,a(j)>1||j>0&&Z>0||j<0&&Z<0)return j>0?o:-o;if(D=I(j*d,Z/2),N=D.hi,B=D.lo,B*=2,a(2*N)===o)return N>0?N===d&&B===-(g/2)&&K>=0&&L[K]<0?h:o:N===-d&&B===g/2&&K>=0&&L[K]>0?-h:-o;B!==0&&(L[++K]=B,B=0),N*=2}for(;K>=0&&(D=I(N,L[K--]),N=D.hi,B=D.lo,B===0););return K>=0&&(B<0&&L[K]<0||B>0&&L[K]>0)&&($=B*2,F=N+$,$===F-N&&(N=F)),N}}),kK}var MK={},jK;function OIe(){if(jK)return MK;jK=1;var r=H();return r({target:"Math",stat:!0,forced:!0},{umulh:function(t,n){var i=65535,o=+t,s=+n,a=o&i,c=s&i,l=o>>>16,d=s>>>16,f=(l*c>>>0)+(a*c>>>16);return l*d+(f>>>16)+((a*d>>>0)+(f&i)>>>16)}}),MK}var DK={},LK;function MIe(){if(LK)return DK;LK=1;var r=H(),e=Ie(),t=Vr(),n="Invalid number representation",i="Invalid radix",o=RangeError,s=SyntaxError,a=TypeError,c=parseInt,l=Math.pow,d=/^[\d.a-z]+$/,f=e("".charAt),h=e(d.exec),g=e(1 .toString),m=e("".slice),y=e("".split);return r({target:"Number",stat:!0,forced:!0},{fromString:function(_,w){var I=1;if(typeof _!="string")throw new a(n);if(!_.length)throw new s(n);if(f(_,0)==="-"&&(I=-1,_=m(_,1),!_.length))throw new s(n);var b=w===void 0?10:t(w);if(b<2||b>36)throw new o(i);if(!h(d,_))throw new s(n);var P=y(_,"."),C=c(P[0],b);if(P.length>1&&(C+=c(P[1],b)/l(b,P[1].length)),b===10&&g(C,b)!==_)throw new s(n);return I*C}}),DK}var FK={},NK;function jIe(){if(NK)return FK;NK=1;var r=H(),e=JT();return r({target:"Number",stat:!0,forced:!0},{range:function(n,i,o){return new e(n,i,o,"number",0,1)}}),FK}var $K={},qK;function DIe(){return qK||(qK=1,Mne()),$K}var BK={},BE,UK;function tA(){if(UK)return BE;UK=1;var r=_r(),e=hu(),t=Hn(),n=Kt(),i=Md(),o=Zt(),s="Object Iterator",a=r.set,c=r.getterFor(s);return BE=e(function(d,f){var h=o(d);a(this,{type:s,mode:f,object:h,keys:i(h),index:0})},"Object",function(){for(var d=c(this),f=d.keys;;){if(f===null||d.index>=f.length)return d.object=d.keys=null,t(void 0,!0);var h=f[d.index++],g=d.object;if(n(g,h)){switch(d.mode){case"keys":return t(h,!1);case"values":return t(g[h],!1)}return t([h,g[h]],!1)}}}),BE}var zK;function LIe(){if(zK)return BK;zK=1;var r=H(),e=tA();return r({target:"Object",stat:!0,forced:!0},{iterateEntries:function(n){return new e(n,"entries")}}),BK}var HK={},WK;function FIe(){if(WK)return HK;WK=1;var r=H(),e=tA();return r({target:"Object",stat:!0,forced:!0},{iterateKeys:function(n){return new e(n,"keys")}}),HK}var KK={},GK;function NIe(){if(GK)return KK;GK=1;var r=H(),e=tA();return r({target:"Object",stat:!0,forced:!0},{iterateValues:function(n){return new e(n,"values")}}),KK}var VK={},YK;function $Ie(){return YK||(YK=1,One()),VK}var XK={},ZK={},QK;function qIe(){if(QK)return ZK;QK=1;var r=H(),e=Qe(),t=Et(),n=pu(),i=jt(),o=Ze(),s=Wi(),a=Ut(),c=Mn(),l=Lt(),d=bn(),f=wr(),h=qs(),g=Yr(),m=Nne(),y=Tt(),x=_r(),_=y("observable"),w="Observable",I="Subscription",b="SubscriptionObserver",P=x.getterFor,C=x.set,k=P(w),O=P(I),L=P(b),j=function(B){this.observer=o(B),this.cleanup=null,this.subscriptionObserver=null};j.prototype={type:I,clean:function(){var B=this.cleanup;if(B){this.cleanup=null;try{B()}catch(W){m(W)}}},close:function(){if(!t){var B=this.facade,W=this.subscriptionObserver;B.closed=!0,W&&(W.closed=!0)}this.observer=null},isClosed:function(){return this.observer===null}};var F=function(B,W){var G=C(this,new j(B)),z;t||(this.closed=!1);try{(z=d(B,"start"))&&e(z,B,this)}catch(Z){m(Z)}if(!G.isClosed()){var V=G.subscriptionObserver=new $(G);try{var J=W(V),K=J;c(J)||(G.cleanup=a(J.unsubscribe)?function(){K.unsubscribe()}:i(J))}catch(Z){V.error(Z);return}G.isClosed()&&G.clean()}};F.prototype=h({},{unsubscribe:function(){var W=O(this);W.isClosed()||(W.close(),W.clean())}}),t&&g(F.prototype,"closed",{configurable:!0,get:function(){return O(this).isClosed()}});var $=function(B){C(this,{type:b,subscriptionState:B}),t||(this.closed=!1)};$.prototype=h({},{next:function(W){var G=L(this).subscriptionState;if(!G.isClosed()){var z=G.observer;try{var V=d(z,"next");V&&e(V,z,W)}catch(J){m(J)}}},error:function(W){var G=L(this).subscriptionState;if(!G.isClosed()){var z=G.observer;G.close();try{var V=d(z,"error");V?e(V,z,W):m(W)}catch(J){m(J)}G.clean()}},complete:function(){var W=L(this).subscriptionState;if(!W.isClosed()){var G=W.observer;W.close();try{var z=d(G,"complete");z&&e(z,G)}catch(V){m(V)}W.clean()}}}),t&&g($.prototype,"closed",{configurable:!0,get:function(){return L(this).subscriptionState.isClosed()}});var D=function(W){s(this,N),C(this,{type:w,subscriber:i(W)})},N=D.prototype;return h(N,{subscribe:function(W){var G=arguments.length;return new F(a(W)?{next:W,error:G>1?arguments[1]:void 0,complete:G>2?arguments[2]:void 0}:l(W)?W:{},k(this).subscriber)}}),f(N,_,function(){return this}),r({global:!0,constructor:!0,forced:!0},{Observable:D}),n(w),ZK}var JK={},eG;function BIe(){if(eG)return JK;eG=1;var r=H(),e=Mt(),t=Qe(),n=Ze(),i=Pa(),o=fu(),s=bn(),a=cn(),c=Tt(),l=c("observable");return r({target:"Observable",stat:!0,forced:!0},{from:function(f){var h=i(this)?this:e("Observable"),g=s(n(f),l);if(g){var m=n(t(g,f));return m.constructor===h?m:new h(function(x){return m.subscribe(x)})}var y=o(f);return new h(function(x){a(y,function(_,w){if(x.next(_),x.closed)return w()},{IS_ITERATOR:!0,INTERRUPTED:!0}),x.complete()})}}),JK}var tG={},rG;function UIe(){if(rG)return tG;rG=1;var r=H(),e=Mt(),t=Pa(),n=e("Array");return r({target:"Observable",stat:!0,forced:!0},{of:function(){for(var o=t(this)?this:e("Observable"),s=arguments.length,a=n(s),c=0;c<s;)a[c]=arguments[c++];return new o(function(l){for(var d=0;d<s;d++)if(l.next(a[d]),l.closed)return;l.complete()})}}),tG}var nG;function zIe(){return nG||(nG=1,qIe(),BIe(),UIe()),XK}var iG={},oG;function HIe(){return oG||(oG=1,qne()),iG}var sG={},aG;function WIe(){return aG||(aG=1,Bne()),sG}var cG={},lG;function KIe(){return lG||(lG=1,Une()),cG}var uG={},dG;function GIe(){return dG||(dG=1,zne()),uG}var fG={},UE,hG;function pc(){if(hG)return UE;hG=1,qT(),XT();var r=Mt(),e=Ie(),t=al(),n=r("Map"),i=r("WeakMap"),o=e([].push),s=t("metadata"),a=s.store||(s.store=new i),c=function(m,y,x){var _=a.get(m);if(!_){if(!x)return;a.set(m,_=new n)}var w=_.get(y);if(!w){if(!x)return;_.set(y,w=new n)}return w},l=function(m,y,x){var _=c(y,x,!1);return _===void 0?!1:_.has(m)},d=function(m,y,x){var _=c(y,x,!1);return _===void 0?void 0:_.get(m)},f=function(m,y,x,_){c(x,_,!0).set(m,y)},h=function(m,y){var x=c(m,y,!1),_=[];return x&&x.forEach(function(w,I){o(_,I)}),_},g=function(m){return m===void 0||typeof m=="symbol"?m:String(m)};return UE={store:a,getMap:c,has:l,get:d,set:f,keys:h,toKey:g},UE}var pG;function VIe(){if(pG)return fG;pG=1;var r=H(),e=pc(),t=Ze(),n=e.toKey,i=e.set;return r({target:"Reflect",stat:!0},{defineMetadata:function(s,a,c){var l=arguments.length<4?void 0:n(arguments[3]);i(s,a,t(c),l)}}),fG}var gG={},vG;function YIe(){if(vG)return gG;vG=1;var r=H(),e=pc(),t=Ze(),n=e.toKey,i=e.getMap,o=e.store;return r({target:"Reflect",stat:!0},{deleteMetadata:function(a,c){var l=arguments.length<3?void 0:n(arguments[2]),d=i(t(c),l,!1);if(d===void 0||!d.delete(a))return!1;if(d.size)return!0;var f=o.get(c);return f.delete(l),!!f.size||o.delete(c)}}),gG}var mG={},yG;function XIe(){if(yG)return mG;yG=1;var r=H(),e=pc(),t=Ze(),n=Fn(),i=e.has,o=e.get,s=e.toKey,a=function(c,l,d){var f=i(c,l,d);if(f)return o(c,l,d);var h=n(l);return h!==null?a(c,h,d):void 0};return r({target:"Reflect",stat:!0},{getMetadata:function(l,d){var f=arguments.length<3?void 0:s(arguments[2]);return a(l,t(d),f)}}),mG}var SG={},xG;function ZIe(){if(xG)return SG;xG=1;var r=H(),e=Ie(),t=pc(),n=Ze(),i=Fn(),o=QT(),s=e(o),a=e([].concat),c=t.keys,l=t.toKey,d=function(f,h){var g=c(f,h),m=i(f);if(m===null)return g;var y=d(m,h);return y.length?g.length?s(a(g,y)):y:g};return r({target:"Reflect",stat:!0},{getMetadataKeys:function(h){var g=arguments.length<2?void 0:l(arguments[1]);return d(n(h),g)}}),SG}var _G={},wG;function QIe(){if(wG)return _G;wG=1;var r=H(),e=pc(),t=Ze(),n=e.get,i=e.toKey;return r({target:"Reflect",stat:!0},{getOwnMetadata:function(s,a){var c=arguments.length<3?void 0:i(arguments[2]);return n(s,t(a),c)}}),_G}var bG={},EG;function JIe(){if(EG)return bG;EG=1;var r=H(),e=pc(),t=Ze(),n=e.keys,i=e.toKey;return r({target:"Reflect",stat:!0},{getOwnMetadataKeys:function(s){var a=arguments.length<2?void 0:i(arguments[1]);return n(t(s),a)}}),bG}var IG={},PG;function ePe(){if(PG)return IG;PG=1;var r=H(),e=pc(),t=Ze(),n=Fn(),i=e.has,o=e.toKey,s=function(a,c,l){var d=i(a,c,l);if(d)return!0;var f=n(c);return f!==null?s(a,f,l):!1};return r({target:"Reflect",stat:!0},{hasMetadata:function(c,l){var d=arguments.length<3?void 0:o(arguments[2]);return s(c,t(l),d)}}),IG}var CG={},TG;function tPe(){if(TG)return CG;TG=1;var r=H(),e=pc(),t=Ze(),n=e.has,i=e.toKey;return r({target:"Reflect",stat:!0},{hasOwnMetadata:function(s,a){var c=arguments.length<3?void 0:i(arguments[2]);return n(s,t(a),c)}}),CG}var AG={},RG;function rPe(){if(RG)return AG;RG=1;var r=H(),e=pc(),t=Ze(),n=e.toKey,i=e.set;return r({target:"Reflect",stat:!0},{metadata:function(s,a){return function(l,d){i(s,a,t(l),n(d))}}}),AG}var kG={},OG;function nPe(){return OG||(OG=1,Wne()),kG}var MG={},jG;function iPe(){if(jG)return MG;jG=1;var r=H(),e=Ai(),t=si().add;return r({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var i=e(this),o=0,s=arguments.length;o<s;o++)t(i,arguments[o]);return i}}),MG}var DG={},LG;function oPe(){if(LG)return DG;LG=1;var r=H(),e=Ai(),t=si().remove;return r({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var i=e(this),o=!0,s,a=0,c=arguments.length;a<c;a++)s=t(i,arguments[a]),o=o&&s;return!!o}}),DG}var FG={},NG;function sPe(){return NG||(NG=1,Gne()),FG}var $G={},zE,qG;function aPe(){if(qG)return zE;qG=1;var r=vo(),e=Kt(),t=Mn(),n=Tt(),i=qd(),o=n("iterator"),s=Object;return zE=function(a){if(t(a))return!1;var c=s(a);return c[o]!==void 0||"@@iterator"in c||e(i,r(c))},zE}var HE,BG;function xu(){if(BG)return HE;BG=1;var r=Mt(),e=Ut(),t=aPe(),n=Lt(),i=r("Set"),o=function(s){return n(s)&&typeof s.size=="number"&&e(s.has)&&e(s.keys)};return HE=function(s){return o(s)?s:t(s)?new i(s):s},HE}var UG;function cPe(){if(UG)return $G;UG=1;var r=H(),e=Qe(),t=xu(),n=Kne();return r({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(o){return e(n,this,t(o))}}),$G}var zG={},HG;function lPe(){if(HG)return zG;HG=1;var r=H(),e=Ar(),t=Ai(),n=Uo();return r({target:"Set",proto:!0,real:!0,forced:!0},{every:function(o){var s=t(this),a=e(o,arguments.length>1?arguments[1]:void 0);return n(s,function(c){if(!a(c,c,s))return!1},!0)!==!1}}),zG}var WG={},KG;function uPe(){if(KG)return WG;KG=1;var r=H(),e=Ar(),t=Ai(),n=si(),i=Uo(),o=n.Set,s=n.add;return r({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(c){var l=t(this),d=e(c,arguments.length>1?arguments[1]:void 0),f=new o;return i(l,function(h){d(h,h,l)&&s(f,h)}),f}}),WG}var GG={},VG;function dPe(){if(VG)return GG;VG=1;var r=H(),e=Ar(),t=Ai(),n=Uo();return r({target:"Set",proto:!0,real:!0,forced:!0},{find:function(o){var s=t(this),a=e(o,arguments.length>1?arguments[1]:void 0),c=n(s,function(l){if(a(l,l,s))return{value:l}},!0);return c&&c.value}}),GG}var YG={},XG;function fPe(){if(XG)return YG;XG=1;var r=H(),e=si(),t=gy();return r({target:"Set",stat:!0,forced:!0},{from:t(e.Set,e.add,!1)}),YG}var ZG={},QG;function hPe(){return QG||(QG=1,Yne()),ZG}var JG={},eV;function pPe(){if(eV)return JG;eV=1;var r=H(),e=Qe(),t=xu(),n=Vne();return r({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(o){return e(n,this,t(o))}}),JG}var tV={},rV;function gPe(){return rV||(rV=1,Zne()),tV}var nV={},iV;function vPe(){if(iV)return nV;iV=1;var r=H(),e=Qe(),t=xu(),n=Xne();return r({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(o){return e(n,this,t(o))}}),nV}var oV={},sV;function mPe(){return sV||(sV=1,Jne()),oV}var aV={},cV;function yPe(){if(cV)return aV;cV=1;var r=H(),e=Qe(),t=xu(),n=Qne();return r({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(o){return e(n,this,t(o))}}),aV}var lV={},uV;function SPe(){return uV||(uV=1,tie()),lV}var dV={},fV;function xPe(){if(fV)return dV;fV=1;var r=H(),e=Qe(),t=xu(),n=eie();return r({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(o){return e(n,this,t(o))}}),dV}var hV={},pV;function _Pe(){if(pV)return hV;pV=1;var r=H(),e=Ie(),t=Ai(),n=Uo(),i=Nt(),o=e([].join),s=e([].push);return r({target:"Set",proto:!0,real:!0,forced:!0},{join:function(c){var l=t(this),d=c===void 0?",":i(c),f=[];return n(l,function(h){s(f,h)}),o(f,d)}}),hV}var gV={},vV;function wPe(){if(vV)return gV;vV=1;var r=H(),e=Ar(),t=Ai(),n=si(),i=Uo(),o=n.Set,s=n.add;return r({target:"Set",proto:!0,real:!0,forced:!0},{map:function(c){var l=t(this),d=e(c,arguments.length>1?arguments[1]:void 0),f=new o;return i(l,function(h){s(f,d(h,h,l))}),f}}),gV}var mV={},yV;function bPe(){if(yV)return mV;yV=1;var r=H(),e=si(),t=vy();return r({target:"Set",stat:!0,forced:!0},{of:t(e.Set,e.add,!1)}),mV}var SV={},xV;function EPe(){if(xV)return SV;xV=1;var r=H(),e=jt(),t=Ai(),n=Uo(),i=TypeError;return r({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(s){var a=t(this),c=arguments.length<2,l=c?void 0:arguments[1];if(e(s),n(a,function(d){c?(c=!1,l=d):l=s(l,d,d,a)}),c)throw new i("Reduce of empty set with no initial value");return l}}),SV}var _V={},wV;function IPe(){if(wV)return _V;wV=1;var r=H(),e=Ar(),t=Ai(),n=Uo();return r({target:"Set",proto:!0,real:!0,forced:!0},{some:function(o){var s=t(this),a=e(o,arguments.length>1?arguments[1]:void 0);return n(s,function(c){if(a(c,c,s))return!0},!0)===!0}}),_V}var bV={},EV;function PPe(){return EV||(EV=1,nie()),bV}var IV={},PV;function CPe(){if(PV)return IV;PV=1;var r=H(),e=Qe(),t=xu(),n=rie();return r({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(o){return e(n,this,t(o))}}),IV}var CV={},TV;function TPe(){return TV||(TV=1,oie()),CV}var AV={},RV;function APe(){if(RV)return AV;RV=1;var r=H(),e=Qe(),t=xu(),n=iie();return r({target:"Set",proto:!0,real:!0,forced:!0},{union:function(o){return e(n,this,t(o))}}),AV}var kV={},OV;function RPe(){if(OV)return kV;OV=1;var r=H(),e=jd().charAt,t=qr(),n=Vr(),i=Nt();return r({target:"String",proto:!0,forced:!0},{at:function(s){var a=i(t(this)),c=a.length,l=n(s),d=l>=0?l:c+l;return d<0||d>=c?void 0:e(a,d)}}),kV}var MV={},WE,jV;function Nie(){if(jV)return WE;jV=1;var r=Ie(),e=jn(),t=Nt(),n=sr(),i=TypeError,o=r([].push),s=r([].join);return WE=function(c){var l=e(c),d=n(l);if(!d)return"";for(var f=arguments.length,h=[],g=0;;){var m=l[g++];if(m===void 0)throw new i("Incorrect template");if(o(h,t(m)),g===d)return s(h,"");g<f&&o(h,t(arguments[g]))}},WE}var DV;function kPe(){if(DV)return MV;DV=1;var r=H(),e=Nie();return r({target:"String",stat:!0,forced:!0},{cooked:e}),MV}var LV={},FV;function OPe(){if(FV)return LV;FV=1;var r=H(),e=hu(),t=Hn(),n=qr(),i=Nt(),o=_r(),s=jd(),a=s.codeAt,c=s.charAt,l="String Iterator",d=o.set,f=o.getterFor(l),h=e(function(m){d(this,{type:l,string:m,index:0})},"String",function(){var m=f(this),y=m.string,x=m.index,_;return x>=y.length?t(void 0,!0):(_=c(y,x),m.index+=_.length,t({codePoint:a(_,0),position:x},!1))});return r({target:"String",proto:!0,forced:!0},{codePoints:function(){return new h(i(n(this)))}}),LV}var NV={},KE,$V;function gl(){if($V)return KE;$V=1;var r=Ie(),e=WeakMap.prototype;return KE={WeakMap,set:r(e.set),get:r(e.get),has:r(e.has),remove:r(e.delete)},KE}var GE,qV;function MPe(){if(qV)return GE;qV=1;var r=Mt(),e=Ie(),t=String.fromCharCode,n=r("String","fromCodePoint"),i=e("".charAt),o=e("".charCodeAt),s=e("".indexOf),a=e("".slice),c=48,l=57,d=97,f=102,h=65,g=70,m=function(_,w){var I=o(_,w);return I>=c&&I<=l},y=function(_,w,I){if(I>=_.length)return-1;for(var b=0;w<I;w++){var P=x(o(_,w));if(P===-1)return-1;b=b*16+P}return b},x=function(_){return _>=c&&_<=l?_-c:_>=d&&_<=f?_-d+10:_>=h&&_<=g?_-h+10:-1};return GE=function(_){for(var w="",I=0,b=0,P;(b=s(_,"\\",b))>-1;){if(w+=a(_,I,b),++b===_.length)return;var C=i(_,b++);switch(C){case"b":w+="\b";break;case"t":w+=" ";break;case"n":w+=`
102
- `;break;case"v":w+="\v";break;case"f":w+="\f";break;case"r":w+="\r";break;case"\r":b<_.length&&i(_,b)===`
103
- `&&++b;case`
104
- `:case"\u2028":case"\u2029":break;case"0":if(m(_,b))return;w+="\0";break;case"x":if(P=y(_,b,b+2),P===-1)return;b+=2,w+=t(P);break;case"u":if(b<_.length&&i(_,b)==="{"){var k=s(_,"}",++b);if(k===-1)return;P=y(_,b,k),b=k+1}else P=y(_,b,b+4),b+=4;if(P===-1||P>1114111)return;w+=n(P);break;default:if(m(C,0))return;w+=C}I=b}return w+a(_,I)},GE}var BV;function jPe(){if(BV)return NV;BV=1;var r=hl(),e=H(),t=Am(),n=Ie(),i=zi(),o=Ze(),s=Zt(),a=Ut(),c=sr(),l=Or().f,d=Bo(),f=gl(),h=Nie(),g=MPe(),m=zd(),y=new f.WeakMap,x=f.get,_=f.has,w=f.set,I=Array,b=TypeError,P=Object.freeze||Object,C=Object.isFrozen,k=Math.min,O=n("".charAt),L=n("".slice),j=n("".split),F=n(/./.exec),$=/([\n\u2028\u2029]|\r\n?)/g,D=RegExp("^["+m+"]*"),N=RegExp("[^"+m+"]"),B="Invalid tag",W="Invalid opening line",G="Invalid closing line",z=function(re){var te=re.raw;if(r&&!C(te))throw new b("Raw template should be frozen");if(_(y,te))return x(y,te);var le=V(te),ge=K(le);return l(ge,"raw",{value:P(le)}),P(ge),w(y,te,ge),ge},V=function(re){var te=s(re),le=c(te),ge=I(le),se=I(le),ce=0,_e,Le,Ge,qe;if(!le)throw new b(B);for(;ce<le;ce++){var mt=te[ce];if(typeof mt=="string")ge[ce]=j(mt,$);else throw new b(B)}for(ce=0;ce<le;ce++){var St=ce+1===le;if(_e=ge[ce],ce===0){if(_e.length===1||_e[0].length>0)throw new b(W);_e[1]=""}if(St){if(_e.length===1||F(N,_e[_e.length-1]))throw new b(G);_e[_e.length-2]="",_e[_e.length-1]=""}for(var et=2;et<_e.length;et+=2){var ct=_e[et],At=et+1===_e.length&&!St,_t=F(D,ct)[0];if(!At&&_t.length===ct.length){_e[et]="";continue}Le=J(_t,Le)}}var ut=Le?Le.length:0;for(ce=0;ce<le;ce++){for(_e=ge[ce],Ge=_e[0],qe=1;qe<_e.length;qe+=2)Ge+=_e[qe]+L(_e[qe+1],ut);se[ce]=Ge}return se},J=function(re,te){if(te===void 0||re===te)return re;for(var le=0,ge=k(re.length,te.length);le<ge&&O(re,le)===O(te,le);le++);return L(re,0,le)},K=function(re){for(var te=0,le=re.length,ge=I(le);te<le;te++)ge[te]=g(re[te]);return ge},Z=function(re){return t(function(te){var le=d(arguments);return le[0]=z(o(te)),i(re,this,le)},"")},ee=Z(h);return e({target:"String",stat:!0,forced:!0},{dedent:function(te){return o(te),a(te)?Z(te):i(ee,this,arguments)}}),NV}var UV={},zV;function DPe(){return zV||(zV=1,aie()),UV}var HV={},WV;function LPe(){return WV||(WV=1,lie()),HV}var KV={},GV;function FPe(){return GV||(GV=1,YC()),KV}var VV={},YV;function NPe(){return YV||(YV=1,die()),VV}var XV={},ZV;function $Pe(){if(ZV)return XV;ZV=1;var r=Xe(),e=an(),t=Or().f,n=ni().f,i=r.Symbol;if(e("asyncDispose"),i){var o=n(i,"asyncDispose");o.enumerable&&o.configurable&&o.writable&&t(i,"asyncDispose",{value:o.value,enumerable:!1,configurable:!1,writable:!1})}return XV}var QV={},JV;function qPe(){if(JV)return QV;JV=1;var r=an();return r("customMatcher"),QV}var eY={},tY;function BPe(){if(tY)return eY;tY=1;var r=Xe(),e=an(),t=Or().f,n=ni().f,i=r.Symbol;if(e("dispose"),i){var o=n(i,"dispose");o.enumerable&&o.configurable&&o.writable&&t(i,"dispose",{value:o.value,enumerable:!1,configurable:!1,writable:!1})}return eY}var rY={},VE,nY;function $ie(){if(nY)return VE;nY=1;var r=Mt(),e=Ie(),t=r("Symbol"),n=t.keyFor,i=e(t.prototype.valueOf);return VE=t.isRegisteredSymbol||function(s){try{return n(i(s))!==void 0}catch{return!1}},VE}var iY;function UPe(){if(iY)return rY;iY=1;var r=H(),e=$ie();return r({target:"Symbol",stat:!0},{isRegisteredSymbol:e}),rY}var oY={},sY;function zPe(){if(sY)return oY;sY=1;var r=H(),e=$ie();return r({target:"Symbol",stat:!0,name:"isRegisteredSymbol"},{isRegistered:e}),oY}var aY={},YE,cY;function qie(){if(cY)return YE;cY=1;for(var r=al(),e=Mt(),t=Ie(),n=sl(),i=Tt(),o=e("Symbol"),s=o.isWellKnownSymbol,a=e("Object","getOwnPropertyNames"),c=t(o.prototype.valueOf),l=r("wks"),d=0,f=a(o),h=f.length;d<h;d++)try{var g=f[d];n(o[g])&&i(g)}catch{}return YE=function(y){if(s&&s(y))return!0;try{for(var x=c(y),_=0,w=a(l),I=w.length;_<I;_++)if(l[w[_]]==x)return!0}catch{}return!1},YE}var lY;function HPe(){if(lY)return aY;lY=1;var r=H(),e=qie();return r({target:"Symbol",stat:!0,forced:!0},{isWellKnownSymbol:e}),aY}var uY={},dY;function WPe(){if(dY)return uY;dY=1;var r=H(),e=qie();return r({target:"Symbol",stat:!0,name:"isWellKnownSymbol",forced:!0},{isWellKnown:e}),uY}var fY={},hY;function KPe(){if(hY)return fY;hY=1;var r=an();return r("matcher"),fY}var pY={},gY;function GPe(){if(gY)return pY;gY=1;var r=an();return r("metadata"),pY}var vY={},mY;function VPe(){if(mY)return vY;mY=1;var r=an();return r("metadataKey"),vY}var yY={},SY;function YPe(){if(SY)return yY;SY=1;var r=an();return r("observable"),yY}var xY={},_Y;function XPe(){if(_Y)return xY;_Y=1;var r=an();return r("patternMatch"),xY}var wY={},bY;function ZPe(){if(bY)return wY;bY=1;var r=an();return r("replaceAll"),wY}var EY={},IY;function QPe(){if(IY)return EY;IY=1;var r=Mt(),e=cy(),t=Eie(),n=Vt(),i=fl(),o=n.aTypedArrayConstructor,s=n.exportTypedArrayStaticMethod;return s("fromAsync",function(c){var l=this,d=arguments.length,f=d>1?arguments[1]:void 0,h=d>2?arguments[2]:void 0;return new(r("Promise"))(function(g){e(l),g(t(c,f,h))}).then(function(g){return i(o(l),g)})},!0),EY}var PY={},CY;function JPe(){return CY||(CY=1,mie()),PY}var TY={},AY;function eCe(){if(AY)return TY;AY=1;var r=Vt(),e=In().filterReject,t=YT(),n=r.aTypedArray,i=r.exportTypedArrayMethod;return i("filterOut",function(s){var a=e(n(this),s,arguments.length>1?arguments[1]:void 0);return t(this,a)},!0),TY}var RY={},kY;function tCe(){if(kY)return RY;kY=1;var r=Vt(),e=In().filterReject,t=YT(),n=r.aTypedArray,i=r.exportTypedArrayMethod;return i("filterReject",function(s){var a=e(n(this),s,arguments.length>1?arguments[1]:void 0);return t(this,a)},!0),RY}var OY={},MY;function rCe(){return MY||(MY=1,yie()),OY}var jY={},DY;function nCe(){return DY||(DY=1,Sie()),jY}var LY={},FY;function iCe(){if(FY)return LY;FY=1;var r=Vt(),e=ZT(),t=r.aTypedArray,n=r.getTypedArrayConstructor,i=r.exportTypedArrayMethod;return i("groupBy",function(s){var a=arguments.length>1?arguments[1]:void 0;return e(t(this),s,a,n)},!0),LY}var NY={},$Y;function oCe(){return $Y||($Y=1,xie()),NY}var qY={},BY;function sCe(){return BY||(BY=1,_ie()),qY}var UY={},zY;function aCe(){if(zY)return UY;zY=1;var r=Vt(),e=sr(),t=VT(),n=Ea(),i=hy(),o=Vr(),s=r.aTypedArray,a=r.getTypedArrayConstructor,c=r.exportTypedArrayMethod,l=Math.max,d=Math.min;return c("toSpliced",function(h,g){var m=s(this),y=a(m),x=e(m),_=n(h,x),w=arguments.length,I=0,b,P,C,k,O,L,j;if(w===0)b=P=0;else if(w===1)b=0,P=x-_;else if(P=d(l(o(g),0),x-_),b=w-2,b){k=new y(b),C=t(k);for(var F=2;F<w;F++)O=arguments[F],k[F-2]=C?i(O):+O}for(L=x+b-P,j=new y(L);I<_;I++)j[I]=m[I];for(;I<_+b;I++)j[I]=k[I-_];for(;I<L;I++)j[I]=m[I+P-b];return j},!0),UY}var HY={},WY;function cCe(){if(WY)return HY;WY=1;var r=Ie(),e=Vt(),t=fl(),n=QT(),i=e.aTypedArray,o=e.getTypedArrayConstructor,s=e.exportTypedArrayMethod,a=r(n);return s("uniqueBy",function(l){return i(this),t(o(this),a(this,l))},!0),HY}var KY={},GY;function lCe(){return GY||(GY=1,wie()),KY}var VY={},XE,YY;function Bie(){if(YY)return XE;YY=1;var r=Lt(),e=String,t=TypeError;return XE=function(n){if(n===void 0||r(n))return n;throw new t(e(n)+" is not an object or undefined")},XE}var ZE,XY;function my(){if(XY)return ZE;XY=1;var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=r+"+/",t=r+"-_",n=function(i){for(var o={},s=0;s<64;s++)o[i.charAt(s)]=s;return o};return ZE={i2c:e,c2i:n(e),i2cUrl:t,c2iUrl:n(t)},ZE}var QE,ZY;function Uie(){if(ZY)return QE;ZY=1;var r=TypeError;return QE=function(e){var t=e&&e.alphabet;if(t===void 0||t==="base64"||t==="base64url")return t||"base64";throw new r("Incorrect `alphabet` option")},QE}var JE,QY;function zie(){if(QY)return JE;QY=1;var r=Xe(),e=Ie(),t=Bie(),n=fy(),i=Kt(),o=my(),s=Uie(),a=Xh(),c=o.c2i,l=o.c2iUrl,d=r.SyntaxError,f=r.TypeError,h=e("".charAt),g=function(x,_){for(var w=x.length;_<w;_++){var I=h(x,_);if(I!==" "&&I!==" "&&I!==`
105
- `&&I!=="\f"&&I!=="\r")break}return _},m=function(x,_,w){var I=x.length;I<4&&(x+=I===2?"AA":"A");var b=(_[h(x,0)]<<18)+(_[h(x,1)]<<12)+(_[h(x,2)]<<6)+_[h(x,3)],P=[b>>16&255,b>>8&255,b&255];if(I===2){if(w&&P[1]!==0)throw new d("Extra bits");return[P[0]]}if(I===3){if(w&&P[2]!==0)throw new d("Extra bits");return[P[0],P[1]]}return P},y=function(x,_,w){for(var I=_.length,b=0;b<I;b++)x[w+b]=_[b];return w+I};return JE=function(x,_,w,I){n(x),t(_);var b=s(_)==="base64"?c:l,P=_?_.lastChunkHandling:void 0;if(P===void 0&&(P="loose"),P!=="loose"&&P!=="strict"&&P!=="stop-before-partial")throw new f("Incorrect `lastChunkHandling` option");w&&a(w.buffer);var C=w||[],k=0,O=0,L="",j=0;if(I)for(;;){if(j=g(x,j),j===x.length){if(L.length>0){if(P==="stop-before-partial")break;if(P==="loose"){if(L.length===1)throw new d("Malformed padding: exactly one additional character");k=y(C,m(L,b,!1),k)}else throw new d("Missing padding")}O=x.length;break}var F=h(x,j);if(++j,F==="="){if(L.length<2)throw new d("Padding is too early");if(j=g(x,j),L.length===2){if(j===x.length){if(P==="stop-before-partial")break;throw new d("Malformed padding: only one =")}h(x,j)==="="&&(++j,j=g(x,j))}if(j<x.length)throw new d("Unexpected character after padding");k=y(C,m(L,b,P==="strict"),k),O=x.length;break}if(!i(b,F))throw new d("Unexpected character");var $=I-k;if($===1&&L.length===2||$===2&&L.length===3||(L+=F,L.length===4&&(k=y(C,m(L,b,!1),k),L="",O=j,k===I)))break}return{bytes:C,read:O,written:k}},JE}var JY;function uCe(){if(JY)return VY;JY=1;var r=H(),e=Xe(),t=fl(),n=zie(),i=e.Uint8Array;return i&&r({target:"Uint8Array",stat:!0},{fromBase64:function(s){var a=n(s,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return t(i,a.bytes)}}),VY}var eX={},eI,tX;function Hie(){if(tX)return eI;tX=1;var r=Xe(),e=Ie(),t=r.Uint8Array,n=r.SyntaxError,i=r.parseInt,o=Math.min,s=/[^\da-f]/i,a=e(s.exec),c=e("".slice);return eI=function(l,d){var f=l.length;if(f%2!==0)throw new n("String should be an even number of characters");for(var h=d?o(d.length,f/2):f/2,g=d||new t(h),m=0,y=0;y<h;){var x=c(l,m,m+=2);if(a(s,x))throw new n("String should only contain hex characters");g[y++]=i(x,16)}return{bytes:g,read:m}},eI}var rX;function dCe(){if(rX)return eX;rX=1;var r=H(),e=Xe(),t=fy(),n=Hie();return e.Uint8Array&&r({target:"Uint8Array",stat:!0},{fromHex:function(o){return n(t(o)).bytes}}),eX}var nX={},tI,iX;function yy(){if(iX)return tI;iX=1;var r=vo(),e=TypeError;return tI=function(t){if(r(t)==="Uint8Array")return t;throw new e("Argument is not an Uint8Array")},tI}var oX;function fCe(){if(oX)return nX;oX=1;var r=H(),e=Xe(),t=zie(),n=yy(),i=e.Uint8Array;return i&&r({target:"Uint8Array",proto:!0},{setFromBase64:function(s){n(this);var a=t(s,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:a.read,written:a.written}}}),nX}var sX={},aX;function hCe(){if(aX)return sX;aX=1;var r=H(),e=Xe(),t=fy(),n=yy(),i=Xh(),o=Hie();return e.Uint8Array&&r({target:"Uint8Array",proto:!0},{setFromHex:function(a){n(this),t(a),i(this.buffer);var c=o(a,this).read;return{read:c,written:c/2}}}),sX}var cX={},lX;function pCe(){if(lX)return cX;lX=1;var r=H(),e=Xe(),t=Ie(),n=Bie(),i=yy(),o=Xh(),s=my(),a=Uie(),c=s.i2c,l=s.i2cUrl,d=t("".charAt);return e.Uint8Array&&r({target:"Uint8Array",proto:!0},{toBase64:function(){var h=i(this),g=arguments.length?n(arguments[0]):void 0,m=a(g)==="base64"?c:l,y=!!g&&!!g.omitPadding;o(this.buffer);for(var x="",_=0,w=h.length,I,b=function(P){return d(m,I>>6*P&63)};_+2<w;_+=3)I=(h[_]<<16)+(h[_+1]<<8)+h[_+2],x+=b(3)+b(2)+b(1)+b(0);return _+2===w?(I=(h[_]<<16)+(h[_+1]<<8),x+=b(3)+b(2)+b(1)+(y?"":"=")):_+1===w&&(I=h[_]<<16,x+=b(3)+b(2)+(y?"":"==")),x}}),cX}var uX={},dX;function gCe(){if(dX)return uX;dX=1;var r=H(),e=Xe(),t=Ie(),n=yy(),i=Xh(),o=t(1 .toString);return e.Uint8Array&&r({target:"Uint8Array",proto:!0},{toHex:function(){n(this),i(this.buffer);for(var a="",c=0,l=this.length;c<l;c++){var d=o(this[c],16);a+=d.length===1?"0"+d:d}return a}}),uX}var fX={},rI,hX;function Sy(){if(hX)return rI;hX=1;var r=gl().has;return rI=function(e){return r(e),e},rI}var pX;function vCe(){if(pX)return fX;pX=1;var r=H(),e=Sy(),t=gl().remove;return r({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var i=e(this),o=!0,s,a=0,c=arguments.length;a<c;a++)s=t(i,arguments[a]),o=o&&s;return!!o}}),fX}var gX={},vX;function mCe(){if(vX)return gX;vX=1;var r=H(),e=gl(),t=gy();return r({target:"WeakMap",stat:!0,forced:!0},{from:t(e.WeakMap,e.set,!0)}),gX}var mX={},yX;function yCe(){if(yX)return mX;yX=1;var r=H(),e=gl(),t=vy();return r({target:"WeakMap",stat:!0,forced:!0},{of:t(e.WeakMap,e.set,!0)}),mX}var SX={},xX;function SCe(){if(xX)return SX;xX=1;var r=H(),e=Sy(),t=gl(),n=t.get,i=t.has,o=t.set;return r({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:function(a,c){var l=e(this),d,f;return i(l,a)?(d=n(l,a),"update"in c&&(d=c.update(d,a,l),o(l,a,d)),d):(f=c.insert(a,l),o(l,a,f),f)}}),SX}var _X={},wX;function xCe(){if(wX)return _X;wX=1;var r=H(),e=Sy(),t=gl(),n=t.get,i=t.has,o=t.set;return r({target:"WeakMap",proto:!0,real:!0,forced:!0},{getOrInsert:function(a,c){return i(e(this),a)?n(this,a):(o(this,a,c),c)}}),_X}var bX={},EX;function _Ce(){if(EX)return bX;EX=1;var r=H(),e=jt(),t=Sy(),n=gl(),i=n.get,o=n.has,s=n.set;return r({target:"WeakMap",proto:!0,real:!0,forced:!0},{getOrInsertComputed:function(c,l){if(t(this),e(l),o(this,c))return i(this,c);s(this,c);var d=l(c);return s(this,c,d),d}}),bX}var IX={},PX;function wCe(){if(PX)return IX;PX=1;var r=H(),e=eA();return r({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:e}),IX}var CX={},nI,TX;function np(){if(TX)return nI;TX=1;var r=Ie(),e=WeakSet.prototype;return nI={WeakSet,add:r(e.add),has:r(e.has),remove:r(e.delete)},nI}var iI,AX;function Wie(){if(AX)return iI;AX=1;var r=np().has;return iI=function(e){return r(e),e},iI}var RX;function bCe(){if(RX)return CX;RX=1;var r=H(),e=Wie(),t=np().add;return r({target:"WeakSet",proto:!0,real:!0,forced:!0},{addAll:function(){for(var i=e(this),o=0,s=arguments.length;o<s;o++)t(i,arguments[o]);return i}}),CX}var kX={},OX;function ECe(){if(OX)return kX;OX=1;var r=H(),e=Wie(),t=np().remove;return r({target:"WeakSet",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var i=e(this),o=!0,s,a=0,c=arguments.length;a<c;a++)s=t(i,arguments[a]),o=o&&s;return!!o}}),kX}var MX={},jX;function ICe(){if(jX)return MX;jX=1;var r=H(),e=np(),t=gy();return r({target:"WeakSet",stat:!0,forced:!0},{from:t(e.WeakSet,e.add,!1)}),MX}var DX={},LX;function PCe(){if(LX)return DX;LX=1;var r=H(),e=np(),t=vy();return r({target:"WeakSet",stat:!0,forced:!0},{of:t(e.WeakSet,e.add,!1)}),DX}var FX={},NX;function CCe(){if(NX)return FX;NX=1;var r=H(),e=Xe(),t=Mt(),n=Ie(),i=Qe(),o=Fe(),s=Nt(),a=us(),c=my().c2i,l=/[^\d+/a-z]/i,d=/[\t\n\f\r ]+/g,f=/[=]{1,2}$/,h=t("atob"),g=String.fromCharCode,m=n("".charAt),y=n("".replace),x=n(l.exec),_=!!h&&!o(function(){return h("aGk=")!=="hi"}),w=_&&o(function(){return h(" ")!==""}),I=_&&!o(function(){h("a")}),b=_&&!o(function(){h()}),P=_&&h.length!==1,C=!_||w||I||b||P;return r({global:!0,bind:!0,enumerable:!0,forced:C},{atob:function(O){if(a(arguments.length,1),_&&!w&&!I)return i(h,e,O);var L=y(s(O),d,""),j="",F=0,$=0,D,N,B;if(L.length%4===0&&(L=y(L,f,"")),D=L.length,D%4===1||x(l,L))throw new(t("DOMException"))("The string is not correctly encoded","InvalidCharacterError");for(;F<D;)N=m(L,F++),B=$%4?B*64+c[N]:c[N],$++%4&&(j+=g(255&B>>(-2*$&6)));return j}}),FX}var $X={},qX;function TCe(){if(qX)return $X;qX=1;var r=H(),e=Xe(),t=Mt(),n=Ie(),i=Qe(),o=Fe(),s=Nt(),a=us(),c=my().i2c,l=t("btoa"),d=n("".charAt),f=n("".charCodeAt),h=!!l&&!o(function(){return l("hi")!=="aGk="}),g=h&&!o(function(){l()}),m=h&&o(function(){return l(null)!=="bnVsbA=="}),y=h&&l.length!==1;return r({global:!0,bind:!0,enumerable:!0,forced:!h||g||m||y},{btoa:function(_){if(a(arguments.length,1),h)return i(l,e,s(_));for(var w=s(_),I="",b=0,P=c,C,k;d(w,b)||(P="=",b%1);){if(k=f(w,b+=3/4),k>255)throw new(t("DOMException"))("The string contains characters outside of the Latin1 range","InvalidCharacterError");C=C<<8|k,I+=d(P,63&C>>8-b%1*8)}return I}}),$X}var BX={},oI,UX;function Kie(){return UX||(UX=1,oI={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}),oI}var sI,zX;function Gie(){if(zX)return sI;zX=1;var r=Pm(),e=r("span").classList,t=e&&e.constructor&&e.constructor.prototype;return sI=t===Object.prototype?void 0:t,sI}var HX;function ACe(){if(HX)return BX;HX=1;var r=Xe(),e=Kie(),t=Gie(),n=Mre(),i=Dn(),o=function(a){if(a&&a.forEach!==n)try{i(a,"forEach",n)}catch{a.forEach=n}};for(var s in e)e[s]&&o(r[s]&&r[s].prototype);return o(t),BX}var WX={},KX;function RCe(){if(KX)return WX;KX=1;var r=Xe(),e=Kie(),t=Gie(),n=Zm(),i=Dn(),o=yo(),s=Tt(),a=s("iterator"),c=n.values,l=function(f,h){if(f){if(f[a]!==c)try{i(f,a,c)}catch{f[a]=c}if(o(f,h,!0),e[h]){for(var g in n)if(f[g]!==n[g])try{i(f,g,n[g])}catch{f[g]=n[g]}}}};for(var d in e)l(r[d]&&r[d].prototype,d);return l(t,"DOMTokenList"),WX}var GX={},aI,VX;function Vie(){return VX||(VX=1,aI={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}),aI}var YX;function kCe(){if(YX)return GX;YX=1;var r=H(),e=Mt(),t=ene(),n=Fe(),i=En(),o=No(),s=Or().f,a=wr(),c=Yr(),l=Kt(),d=Wi(),f=Ze(),h=Tre(),g=$d(),m=Vie(),y=IT(),x=_r(),_=Et(),w=Xt(),I="DOMException",b="DATA_CLONE_ERR",P=e("Error"),C=e(I)||function(){try{var se=e("MessageChannel")||t("worker_threads").MessageChannel;new se().port1.postMessage(new WeakMap)}catch(ce){if(ce.name===b&&ce.code===25)return ce.constructor}}(),k=C&&C.prototype,O=P.prototype,L=x.set,j=x.getterFor(I),F="stack"in new P(I),$=function(se){return l(m,se)&&m[se].m?m[se].c:0},D=function(){d(this,N);var ce=arguments.length,_e=g(ce<1?void 0:arguments[0]),Le=g(ce<2?void 0:arguments[1],"Error"),Ge=$(Le);if(L(this,{type:I,name:Le,message:_e,code:Ge}),_||(this.name=Le,this.message=_e,this.code=Ge),F){var qe=new P(_e);qe.name=I,s(this,"stack",o(1,y(qe.stack,1)))}},N=D.prototype=i(O),B=function(se){return{enumerable:!0,configurable:!0,get:se}},W=function(se){return B(function(){return j(this)[se]})};_&&(c(N,"code",W("code")),c(N,"message",W("message")),c(N,"name",W("name"))),s(N,"constructor",o(1,D));var G=n(function(){return!(new C instanceof P)}),z=G||n(function(){return O.toString!==h||String(new C(1,2))!=="2: 1"}),V=G||n(function(){return new C(1,"DataCloneError").code!==25}),J=G||C[b]!==25||k[b]!==25,K=w?z||V||J:G;r({global:!0,constructor:!0,forced:K},{DOMException:K?D:C});var Z=e(I),ee=Z.prototype;z&&(w||C===Z)&&a(ee,"toString",h),V&&_&&C===Z&&c(ee,"code",B(function(){return $(f(this).name)}));for(var re in m)if(l(m,re)){var te=m[re],le=te.s,ge=o(6,te.c);l(Z,le)||s(Z,le,ge),l(ee,le)||s(ee,le,ge)}return GX}var XX={},ZX;function OCe(){if(ZX)return XX;ZX=1;var r=H(),e=Xe(),t=Mt(),n=No(),i=Or().f,o=Kt(),s=Wi(),a=du(),c=$d(),l=Vie(),d=IT(),f=Et(),h=Xt(),g="DOMException",m=t("Error"),y=t(g),x=function(){s(this,_);var D=arguments.length,N=c(D<1?void 0:arguments[0]),B=c(D<2?void 0:arguments[1],"Error"),W=new y(N,B),G=new m(N);return G.name=g,i(W,"stack",n(1,d(G.stack,1))),a(W,this,x),W},_=x.prototype=y.prototype,w="stack"in new m(g),I="stack"in new y(1,2),b=y&&f&&Object.getOwnPropertyDescriptor(e,g),P=!!b&&!(b.writable&&b.configurable),C=w&&!P&&!I;r({global:!0,constructor:!0,forced:h||C},{DOMException:C?x:y});var k=t(g),O=k.prototype;if(O.constructor!==k){h||i(O,"constructor",n(1,k));for(var L in l)if(o(l,L)){var j=l[L],F=j.s;o(k,F)||i(k,F,n(6,j.c))}}return XX}var QX={},JX;function MCe(){if(JX)return QX;JX=1;var r=Mt(),e=yo(),t="DOMException";return e(r(t),t),QX}var eZ={},tZ={},rZ;function jCe(){if(rZ)return tZ;rZ=1;var r=H(),e=Xe(),t=uy().clear;return r({global:!0,bind:!0,enumerable:!0,forced:e.clearImmediate!==t},{clearImmediate:t}),tZ}var nZ={},cI,iZ;function rA(){if(iZ)return cI;iZ=1;var r=Xe(),e=zi(),t=Ut(),n=Jm(),i=wa(),o=Bo(),s=us(),a=r.Function,c=/MSIE .\./.test(i)||n==="BUN"&&function(){var l=r.Bun.version.split(".");return l.length<3||l[0]==="0"&&(l[1]<3||l[1]==="3"&&l[2]==="0")}();return cI=function(l,d){var f=d?2:1;return c?function(h,g){var m=s(arguments.length,1)>f,y=t(h)?h:a(h),x=m?o(arguments,f):[],_=m?function(){e(y,this,x)}:y;return d?l(_,g):l(_)}:l},cI}var oZ;function DCe(){if(oZ)return nZ;oZ=1;var r=H(),e=Xe(),t=uy().set,n=rA(),i=e.setImmediate?n(t,!1):t;return r({global:!0,bind:!0,enumerable:!0,forced:e.setImmediate!==i},{setImmediate:i}),nZ}var sZ;function LCe(){return sZ||(sZ=1,jCe(),DCe()),eZ}var aZ={},cZ;function FCe(){if(cZ)return aZ;cZ=1;var r=H(),e=Xe(),t=Fne(),n=jt(),i=us(),o=Fe(),s=Et(),a=o(function(){return s&&Object.getOwnPropertyDescriptor(e,"queueMicrotask").value.length!==1});return r({global:!0,enumerable:!0,dontCallGetSet:!0,forced:a},{queueMicrotask:function(l){i(arguments.length,1),t(n(l))}}),aZ}var lZ={},uZ;function NCe(){if(uZ)return lZ;uZ=1;var r=H(),e=Xe(),t=Yr(),n=Et(),i=TypeError,o=Object.defineProperty,s=e.self!==e;try{if(n){var a=Object.getOwnPropertyDescriptor(e,"self");(s||!a||!a.get||!a.enumerable)&&t(e,"self",{get:function(){return e},set:function(l){if(this!==e)throw new i("Illegal invocation");o(e,"self",{value:l,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}else r({global:!0,simple:!0,forced:s},{self:e})}catch{}return lZ}var dZ={},fZ;function $Ce(){if(fZ)return dZ;fZ=1;var r=Xt(),e=H(),t=Xe(),n=Mt(),i=Ie(),o=Fe(),s=au(),a=Ut(),c=Pa(),l=Mn(),d=Lt(),f=sl(),h=cn(),g=Ze(),m=vo(),y=Kt(),x=Ns(),_=Dn(),w=sr(),I=us(),b=Uh(),P=Wn(),C=si(),k=Uo(),O=tne(),L=Pre(),j=FT(),F=t.Object,$=t.Array,D=t.Date,N=t.Error,B=t.TypeError,W=t.PerformanceMark,G=n("DOMException"),z=P.Map,V=P.has,J=P.get,K=P.set,Z=C.Set,ee=C.add,re=C.has,te=n("Object","keys"),le=i([].push),ge=i((!0).valueOf),se=i(1 .valueOf),ce=i("".valueOf),_e=i(D.prototype.getTime),Le=s("structuredClone"),Ge="DataCloneError",qe="Transferring",mt=function(Y){return!o(function(){var oe=new t.Set([7]),me=Y(oe),we=Y(F(7));return me===oe||!me.has(7)||!d(we)||+we!=7})&&Y},St=function(Y,oe){return!o(function(){var me=new oe,we=Y({a:me,b:me});return!(we&&we.a===we.b&&we.a instanceof oe&&we.a.stack===me.stack)})},et=function(Y){return!o(function(){var oe=Y(new t.AggregateError([1],Le,{cause:3}));return oe.name!=="AggregateError"||oe.errors[0]!==1||oe.message!==Le||oe.cause!==3})},ct=t.structuredClone,At=r||!St(ct,N)||!St(ct,G)||!et(ct),_t=!ct&&mt(function(Y){return new W(Le,{detail:Y}).detail}),ut=mt(ct)||_t,Ae=function(Y){throw new G("Uncloneable type: "+Y,Ge)},ze=function(Y,oe){throw new G((oe||"Cloning")+" of "+Y+" cannot be properly polyfilled in this engine",Ge)},be=function(Y,oe){return ut||ze(oe),ut(Y)},it=function(){var Y;try{Y=new t.DataTransfer}catch{try{Y=new t.ClipboardEvent("").clipboardData}catch{}}return Y&&Y.items&&Y.files?Y:null},st=function(Y,oe,me){if(V(oe,Y))return J(oe,Y);var we=me||m(Y),Oe,Ee,dt,$t,Pe,$e;if(we==="SharedArrayBuffer")ut?Oe=ut(Y):Oe=Y;else{var Be=t.DataView;!Be&&!a(Y.slice)&&ze("ArrayBuffer");try{if(a(Y.slice)&&!Y.resizable)Oe=Y.slice(0);else for(Ee=Y.byteLength,dt=("maxByteLength"in Y)?{maxByteLength:Y.maxByteLength}:void 0,Oe=new ArrayBuffer(Ee,dt),$t=new Be(Y),Pe=new Be(Oe),$e=0;$e<Ee;$e++)Pe.setUint8($e,$t.getUint8($e))}catch{throw new G("ArrayBuffer is detached",Ge)}}return K(oe,Y,Oe),Oe},Je=function(Y,oe,me,we,Oe){var Ee=t[oe];return d(Ee)||ze(oe),new Ee(st(Y.buffer,Oe),me,we)},Ye=function(Y,oe){if(f(Y)&&Ae("Symbol"),!d(Y))return Y;if(oe){if(V(oe,Y))return J(oe,Y)}else oe=new z;var me=m(Y),we,Oe,Ee,dt,$t,Pe,$e,Be;switch(me){case"Array":Ee=$(w(Y));break;case"Object":Ee={};break;case"Map":Ee=new z;break;case"Set":Ee=new Z;break;case"RegExp":Ee=new RegExp(Y.source,b(Y));break;case"Error":switch(Oe=Y.name,Oe){case"AggregateError":Ee=new(n(Oe))([]);break;case"EvalError":case"RangeError":case"ReferenceError":case"SuppressedError":case"SyntaxError":case"TypeError":case"URIError":Ee=new(n(Oe));break;case"CompileError":case"LinkError":case"RuntimeError":Ee=new(n("WebAssembly",Oe));break;default:Ee=new N}break;case"DOMException":Ee=new G(Y.message,Y.name);break;case"ArrayBuffer":case"SharedArrayBuffer":Ee=st(Y,oe,me);break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float16Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":Pe=me==="DataView"?Y.byteLength:Y.length,Ee=Je(Y,me,Y.byteOffset,Pe,oe);break;case"DOMQuad":try{Ee=new DOMQuad(Ye(Y.p1,oe),Ye(Y.p2,oe),Ye(Y.p3,oe),Ye(Y.p4,oe))}catch{Ee=be(Y,me)}break;case"File":if(ut)try{Ee=ut(Y),m(Ee)!==me&&(Ee=void 0)}catch{}if(!Ee)try{Ee=new File([Y],Y.name,Y)}catch{}Ee||ze(me);break;case"FileList":if(dt=it(),dt){for($t=0,Pe=w(Y);$t<Pe;$t++)dt.items.add(Ye(Y[$t],oe));Ee=dt.files}else Ee=be(Y,me);break;case"ImageData":try{Ee=new ImageData(Ye(Y.data,oe),Y.width,Y.height,{colorSpace:Y.colorSpace})}catch{Ee=be(Y,me)}break;default:if(ut)Ee=ut(Y);else switch(me){case"BigInt":Ee=F(Y.valueOf());break;case"Boolean":Ee=F(ge(Y));break;case"Number":Ee=F(se(Y));break;case"String":Ee=F(ce(Y));break;case"Date":Ee=new D(_e(Y));break;case"Blob":try{Ee=Y.slice(0,Y.size,Y.type)}catch{ze(me)}break;case"DOMPoint":case"DOMPointReadOnly":we=t[me];try{Ee=we.fromPoint?we.fromPoint(Y):new we(Y.x,Y.y,Y.z,Y.w)}catch{ze(me)}break;case"DOMRect":case"DOMRectReadOnly":we=t[me];try{Ee=we.fromRect?we.fromRect(Y):new we(Y.x,Y.y,Y.width,Y.height)}catch{ze(me)}break;case"DOMMatrix":case"DOMMatrixReadOnly":we=t[me];try{Ee=we.fromMatrix?we.fromMatrix(Y):new we(Y)}catch{ze(me)}break;case"AudioData":case"VideoFrame":a(Y.clone)||ze(me);try{Ee=Y.clone()}catch{Ae(me)}break;case"CropTarget":case"CryptoKey":case"FileSystemDirectoryHandle":case"FileSystemFileHandle":case"FileSystemHandle":case"GPUCompilationInfo":case"GPUCompilationMessage":case"ImageBitmap":case"RTCCertificate":case"WebAssembly.Module":ze(me);default:Ae(me)}}switch(K(oe,Y,Ee),me){case"Array":case"Object":for($e=te(Y),$t=0,Pe=w($e);$t<Pe;$t++)Be=$e[$t],x(Ee,Be,Ye(Y[Be],oe));break;case"Map":Y.forEach(function(We,yt){K(Ee,Ye(yt,oe),Ye(We,oe))});break;case"Set":Y.forEach(function(We){ee(Ee,Ye(We,oe))});break;case"Error":_(Ee,"message",Ye(Y.message,oe)),y(Y,"cause")&&_(Ee,"cause",Ye(Y.cause,oe)),Oe==="AggregateError"?Ee.errors=Ye(Y.errors,oe):Oe==="SuppressedError"&&(Ee.error=Ye(Y.error,oe),Ee.suppressed=Ye(Y.suppressed,oe));case"DOMException":L&&_(Ee,"stack",Ye(Y.stack,oe))}return Ee},cr=function(Y,oe){if(!d(Y))throw new B("Transfer option cannot be converted to a sequence");var me=[];h(Y,function(yt){le(me,g(yt))});for(var we=0,Oe=w(me),Ee=new Z,dt,$t,Pe,$e,Be,We;we<Oe;){if(dt=me[we++],$t=m(dt),$t==="ArrayBuffer"?re(Ee,dt):V(oe,dt))throw new G("Duplicate transferable",Ge);if($t==="ArrayBuffer"){ee(Ee,dt);continue}if(j)$e=ct(dt,{transfer:[dt]});else switch($t){case"ImageBitmap":Pe=t.OffscreenCanvas,c(Pe)||ze($t,qe);try{Be=new Pe(dt.width,dt.height),We=Be.getContext("bitmaprenderer"),We.transferFromImageBitmap(dt),$e=Be.transferToImageBitmap()}catch{}break;case"AudioData":case"VideoFrame":(!a(dt.clone)||!a(dt.close))&&ze($t,qe);try{$e=dt.clone(),dt.close()}catch{}break;case"MediaSourceHandle":case"MessagePort":case"MIDIAccess":case"OffscreenCanvas":case"ReadableStream":case"RTCDataChannel":case"TransformStream":case"WebTransportReceiveStream":case"WebTransportSendStream":case"WritableStream":ze($t,qe)}if($e===void 0)throw new G("This object cannot be transferred: "+$t,Ge);K(oe,dt,$e)}return Ee},Sr=function(Y){k(Y,function(oe){j?ut(oe,{transfer:[oe]}):a(oe.transfer)?oe.transfer():O?O(oe):ze("ArrayBuffer",qe)})};return e({global:!0,enumerable:!0,sham:!j,forced:At},{structuredClone:function(oe){var me=I(arguments.length,1)>1&&!l(arguments[1])?g(arguments[1]):void 0,we=me?me.transfer:void 0,Oe,Ee;we!==void 0&&(Oe=new z,Ee=cr(we,Oe));var dt=Ye(oe,Oe);return Ee&&Sr(Ee),dt}}),dZ}var hZ={},pZ={},gZ;function qCe(){if(gZ)return pZ;gZ=1;var r=H(),e=Xe(),t=rA(),n=t(e.setInterval,!0);return r({global:!0,bind:!0,forced:e.setInterval!==n},{setInterval:n}),pZ}var vZ={},mZ;function BCe(){if(mZ)return vZ;mZ=1;var r=H(),e=Xe(),t=rA(),n=t(e.setTimeout,!0);return r({global:!0,bind:!0,forced:e.setTimeout!==n},{setTimeout:n}),vZ}var yZ;function UCe(){return yZ||(yZ=1,qCe(),BCe()),hZ}var SZ={},xZ={},lI,_Z;function xy(){if(_Z)return lI;_Z=1;var r=Fe(),e=Tt(),t=Et(),n=Xt(),i=e("iterator");return lI=!r(function(){var o=new URL("b?a=1&b=2&c=3","https://a"),s=o.searchParams,a=new URLSearchParams("a=1&a=2&b=3"),c="";return o.pathname="c%20d",s.forEach(function(l,d){s.delete("b"),c+=d+l}),a.delete("a",2),a.delete("b",void 0),n&&(!o.toJSON||!a.has("a",1)||a.has("a",2)||!a.has("a",void 0)||a.has("b"))||!s.size&&(n||!t)||!s.sort||o.href!=="https://a/c%20d?a=1&c=3"||s.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!s[i]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||c!=="a1c3"||new URL("https://x",void 0).host!=="x"}),lI}var uI,wZ;function zCe(){if(wZ)return uI;wZ=1;var r=Ie(),e=2147483647,t=36,n=1,i=26,o=38,s=700,a=72,c=128,l="-",d=/[^\0-\u007E]/,f=/[.\u3002\uFF0E\uFF61]/g,h="Overflow: input needs wider integers to process",g=t-n,m=RangeError,y=r(f.exec),x=Math.floor,_=String.fromCharCode,w=r("".charCodeAt),I=r([].join),b=r([].push),P=r("".replace),C=r("".split),k=r("".toLowerCase),O=function($){for(var D=[],N=0,B=$.length;N<B;){var W=w($,N++);if(W>=55296&&W<=56319&&N<B){var G=w($,N++);(G&64512)===56320?b(D,((W&1023)<<10)+(G&1023)+65536):(b(D,W),N--)}else b(D,W)}return D},L=function($){return $+22+75*($<26)},j=function($,D,N){var B=0;for($=N?x($/s):$>>1,$+=x($/D);$>g*i>>1;)$=x($/g),B+=t;return x(B+(g+1)*$/($+o))},F=function($){var D=[];$=O($);var N=$.length,B=c,W=0,G=a,z,V;for(z=0;z<$.length;z++)V=$[z],V<128&&b(D,_(V));var J=D.length,K=J;for(J&&b(D,l);K<N;){var Z=e;for(z=0;z<$.length;z++)V=$[z],V>=B&&V<Z&&(Z=V);var ee=K+1;if(Z-B>x((e-W)/ee))throw new m(h);for(W+=(Z-B)*ee,B=Z,z=0;z<$.length;z++){if(V=$[z],V<B&&++W>e)throw new m(h);if(V===B){for(var re=W,te=t;;){var le=te<=G?n:te>=G+i?i:te-G;if(re<le)break;var ge=re-le,se=t-le;b(D,_(L(le+ge%se))),re=x(ge/se),te+=t}b(D,_(L(re))),G=j(W,ee,K===J),W=0,K++}}W++,B++}return I(D,"")};return uI=function($){var D=[],N=C(P(k($),f,"."),"."),B,W;for(B=0;B<N.length;B++)W=N[B],b(D,y(d,W)?"xn--"+F(W):W);return I(D,".")},uI}var dI,bZ;function Yie(){if(bZ)return dI;bZ=1,Zm(),sie();var r=H(),e=Xe(),t=Dne(),n=Mt(),i=Qe(),o=Ie(),s=Et(),a=xy(),c=wr(),l=Yr(),d=qs(),f=yo(),h=hu(),g=_r(),m=Wi(),y=Ut(),x=Kt(),_=Ar(),w=vo(),I=Ze(),b=Lt(),P=Nt(),C=En(),k=No(),O=fu(),L=dc(),j=Hn(),F=us(),$=Tt(),D=MT(),N=$("iterator"),B="URLSearchParams",W=B+"Iterator",G=g.set,z=g.getterFor(B),V=g.getterFor(W),J=t("fetch"),K=t("Request"),Z=t("Headers"),ee=K&&K.prototype,re=Z&&Z.prototype,te=e.TypeError,le=e.encodeURIComponent,ge=String.fromCharCode,se=n("String","fromCodePoint"),ce=parseInt,_e=o("".charAt),Le=o([].join),Ge=o([].push),qe=o("".replace),mt=o([].shift),St=o([].splice),et=o("".split),ct=o("".slice),At=o(/./.exec),_t=/\+/g,ut="�",Ae=/^[0-9a-f]+$/i,ze=function(Pe,$e){var Be=ct(Pe,$e,$e+2);return At(Ae,Be)?ce(Be,16):NaN},be=function(Pe){for(var $e=0,Be=128;Be>0&&(Pe&Be)!==0;Be>>=1)$e++;return $e},it=function(Pe){var $e=null;switch(Pe.length){case 1:$e=Pe[0];break;case 2:$e=(Pe[0]&31)<<6|Pe[1]&63;break;case 3:$e=(Pe[0]&15)<<12|(Pe[1]&63)<<6|Pe[2]&63;break;case 4:$e=(Pe[0]&7)<<18|(Pe[1]&63)<<12|(Pe[2]&63)<<6|Pe[3]&63;break}return $e>1114111?null:$e},st=function(Pe){Pe=qe(Pe,_t," ");for(var $e=Pe.length,Be="",We=0;We<$e;){var yt=_e(Pe,We);if(yt==="%"){if(_e(Pe,We+1)==="%"||We+3>$e){Be+="%",We++;continue}var Ht=ze(Pe,We+1);if(Ht!==Ht){Be+=yt,We++;continue}We+=2;var ur=be(Ht);if(ur===0)yt=ge(Ht);else{if(ur===1||ur>4){Be+=ut,We++;continue}for(var xr=[Ht],Rr=1;Rr<ur&&(We++,!(We+3>$e||_e(Pe,We)!=="%"));){var en=ze(Pe,We+1);if(en!==en){We+=3;break}if(en>191||en<128)break;Ge(xr,en),We+=2,Rr++}if(xr.length!==ur){Be+=ut;continue}var Pn=it(xr);Pn===null?Be+=ut:yt=se(Pn)}}Be+=yt,We++}return Be},Je=/[!'()~]|%20/g,Ye={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},cr=function(Pe){return Ye[Pe]},Sr=function(Pe){return qe(le(Pe),Je,cr)},Y=h(function($e,Be){G(this,{type:W,target:z($e).entries,index:0,kind:Be})},B,function(){var $e=V(this),Be=$e.target,We=$e.index++;if(!Be||We>=Be.length)return $e.target=null,j(void 0,!0);var yt=Be[We];switch($e.kind){case"keys":return j(yt.key,!1);case"values":return j(yt.value,!1)}return j([yt.key,yt.value],!1)},!0),oe=function(Pe){this.entries=[],this.url=null,Pe!==void 0&&(b(Pe)?this.parseObject(Pe):this.parseQuery(typeof Pe=="string"?_e(Pe,0)==="?"?ct(Pe,1):Pe:P(Pe)))};oe.prototype={type:B,bindURL:function(Pe){this.url=Pe,this.update()},parseObject:function(Pe){var $e=this.entries,Be=L(Pe),We,yt,Ht,ur,xr,Rr,en;if(Be)for(We=O(Pe,Be),yt=We.next;!(Ht=i(yt,We)).done;){if(ur=O(I(Ht.value)),xr=ur.next,(Rr=i(xr,ur)).done||(en=i(xr,ur)).done||!i(xr,ur).done)throw new te("Expected sequence with length 2");Ge($e,{key:P(Rr.value),value:P(en.value)})}else for(var Pn in Pe)x(Pe,Pn)&&Ge($e,{key:Pn,value:P(Pe[Pn])})},parseQuery:function(Pe){if(Pe)for(var $e=this.entries,Be=et(Pe,"&"),We=0,yt,Ht;We<Be.length;)yt=Be[We++],yt.length&&(Ht=et(yt,"="),Ge($e,{key:st(mt(Ht)),value:st(Le(Ht,"="))}))},serialize:function(){for(var Pe=this.entries,$e=[],Be=0,We;Be<Pe.length;)We=Pe[Be++],Ge($e,Sr(We.key)+"="+Sr(We.value));return Le($e,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var me=function(){m(this,we);var $e=arguments.length>0?arguments[0]:void 0,Be=G(this,new oe($e));s||(this.size=Be.entries.length)},we=me.prototype;if(d(we,{append:function($e,Be){var We=z(this);F(arguments.length,2),Ge(We.entries,{key:P($e),value:P(Be)}),s||this.length++,We.updateURL()},delete:function(Pe){for(var $e=z(this),Be=F(arguments.length,1),We=$e.entries,yt=P(Pe),Ht=Be<2?void 0:arguments[1],ur=Ht===void 0?Ht:P(Ht),xr=0;xr<We.length;){var Rr=We[xr];if(Rr.key===yt&&(ur===void 0||Rr.value===ur)){if(St(We,xr,1),ur!==void 0)break}else xr++}s||(this.size=We.length),$e.updateURL()},get:function($e){var Be=z(this).entries;F(arguments.length,1);for(var We=P($e),yt=0;yt<Be.length;yt++)if(Be[yt].key===We)return Be[yt].value;return null},getAll:function($e){var Be=z(this).entries;F(arguments.length,1);for(var We=P($e),yt=[],Ht=0;Ht<Be.length;Ht++)Be[Ht].key===We&&Ge(yt,Be[Ht].value);return yt},has:function($e){for(var Be=z(this).entries,We=F(arguments.length,1),yt=P($e),Ht=We<2?void 0:arguments[1],ur=Ht===void 0?Ht:P(Ht),xr=0;xr<Be.length;){var Rr=Be[xr++];if(Rr.key===yt&&(ur===void 0||Rr.value===ur))return!0}return!1},set:function($e,Be){var We=z(this);F(arguments.length,1);for(var yt=We.entries,Ht=!1,ur=P($e),xr=P(Be),Rr=0,en;Rr<yt.length;Rr++)en=yt[Rr],en.key===ur&&(Ht?St(yt,Rr--,1):(Ht=!0,en.value=xr));Ht||Ge(yt,{key:ur,value:xr}),s||(this.size=yt.length),We.updateURL()},sort:function(){var $e=z(this);D($e.entries,function(Be,We){return Be.key>We.key?1:-1}),$e.updateURL()},forEach:function($e){for(var Be=z(this).entries,We=_($e,arguments.length>1?arguments[1]:void 0),yt=0,Ht;yt<Be.length;)Ht=Be[yt++],We(Ht.value,Ht.key,this)},keys:function(){return new Y(this,"keys")},values:function(){return new Y(this,"values")},entries:function(){return new Y(this,"entries")}},{enumerable:!0}),c(we,N,we.entries,{name:"entries"}),c(we,"toString",function(){return z(this).serialize()},{enumerable:!0}),s&&l(we,"size",{get:function(){return z(this).entries.length},configurable:!0,enumerable:!0}),f(me,B),r({global:!0,constructor:!0,forced:!a},{URLSearchParams:me}),!a&&y(Z)){var Oe=o(re.has),Ee=o(re.set),dt=function(Pe){if(b(Pe)){var $e=Pe.body,Be;if(w($e)===B)return Be=Pe.headers?new Z(Pe.headers):new Z,Oe(Be,"content-type")||Ee(Be,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),C(Pe,{body:k(0,P($e)),headers:k(0,Be)})}return Pe};if(y(J)&&r({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function($e){return J($e,arguments.length>1?dt(arguments[1]):{})}}),y(K)){var $t=function($e){return m(this,ee),new K($e,arguments.length>1?dt(arguments[1]):{})};ee.constructor=$t,$t.prototype=ee,r({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:$t})}}return dI={URLSearchParams:me,getState:z},dI}var EZ;function HCe(){if(EZ)return xZ;EZ=1,cie();var r=H(),e=Et(),t=xy(),n=Xe(),i=Ar(),o=Ie(),s=wr(),a=Yr(),c=Wi(),l=Kt(),d=Rne(),f=jre(),h=Bo(),g=jd().codeAt,m=zCe(),y=Nt(),x=yo(),_=us(),w=Yie(),I=_r(),b=I.set,P=I.getterFor("URL"),C=w.URLSearchParams,k=w.getState,O=n.URL,L=n.TypeError,j=n.parseInt,F=Math.floor,$=Math.pow,D=o("".charAt),N=o(/./.exec),B=o([].join),W=o(1 .toString),G=o([].pop),z=o([].push),V=o("".replace),J=o([].shift),K=o("".split),Z=o("".slice),ee=o("".toLowerCase),re=o([].unshift),te="Invalid authority",le="Invalid scheme",ge="Invalid host",se="Invalid port",ce=/[a-z]/i,_e=/[\d+-.a-z]/i,Le=/\d/,Ge=/^0x/i,qe=/^[0-7]+$/,mt=/^\d+$/,St=/^[\da-f]+$/i,et=/[\0\t\n\r #%/:<>?@[\\\]^|]/,ct=/[\0\t\n\r #/:<>?@[\\\]^|]/,At=/^[\u0000-\u0020]+/,_t=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ut=/[\t\n\r]/g,Ae,ze=function(ve){var Ne=K(ve,"."),xe,ue,ke,Pt,ft,Br,Wt;if(Ne.length&&Ne[Ne.length-1]===""&&Ne.length--,xe=Ne.length,xe>4)return ve;for(ue=[],ke=0;ke<xe;ke++){if(Pt=Ne[ke],Pt==="")return ve;if(ft=10,Pt.length>1&&D(Pt,0)==="0"&&(ft=N(Ge,Pt)?16:8,Pt=Z(Pt,ft===8?1:2)),Pt==="")Br=0;else{if(!N(ft===10?mt:ft===8?qe:St,Pt))return ve;Br=j(Pt,ft)}z(ue,Br)}for(ke=0;ke<xe;ke++)if(Br=ue[ke],ke===xe-1){if(Br>=$(256,5-xe))return null}else if(Br>255)return null;for(Wt=G(ue),ke=0;ke<ue.length;ke++)Wt+=ue[ke]*$(256,3-ke);return Wt},be=function(ve){var Ne=[0,0,0,0,0,0,0,0],xe=0,ue=null,ke=0,Pt,ft,Br,Wt,hn,Nn,Me,Ur=function(){return D(ve,ke)};if(Ur()===":"){if(D(ve,1)!==":")return;ke+=2,xe++,ue=xe}for(;Ur();){if(xe===8)return;if(Ur()===":"){if(ue!==null)return;ke++,xe++,ue=xe;continue}for(Pt=ft=0;ft<4&&N(St,Ur());)Pt=Pt*16+j(Ur(),16),ke++,ft++;if(Ur()==="."){if(ft===0||(ke-=ft,xe>6))return;for(Br=0;Ur();){if(Wt=null,Br>0)if(Ur()==="."&&Br<4)ke++;else return;if(!N(Le,Ur()))return;for(;N(Le,Ur());){if(hn=j(Ur(),10),Wt===null)Wt=hn;else{if(Wt===0)return;Wt=Wt*10+hn}if(Wt>255)return;ke++}Ne[xe]=Ne[xe]*256+Wt,Br++,(Br===2||Br===4)&&xe++}if(Br!==4)return;break}else if(Ur()===":"){if(ke++,!Ur())return}else if(Ur())return;Ne[xe++]=Pt}if(ue!==null)for(Nn=xe-ue,xe=7;xe!==0&&Nn>0;)Me=Ne[xe],Ne[xe--]=Ne[ue+Nn-1],Ne[ue+--Nn]=Me;else if(xe!==8)return;return Ne},it=function(ve){for(var Ne=null,xe=1,ue=null,ke=0,Pt=0;Pt<8;Pt++)ve[Pt]!==0?(ke>xe&&(Ne=ue,xe=ke),ue=null,ke=0):(ue===null&&(ue=Pt),++ke);return ke>xe?ue:Ne},st=function(ve){var Ne,xe,ue,ke;if(typeof ve=="number"){for(Ne=[],xe=0;xe<4;xe++)re(Ne,ve%256),ve=F(ve/256);return B(Ne,".")}if(typeof ve=="object"){for(Ne="",ue=it(ve),xe=0;xe<8;xe++)ke&&ve[xe]===0||(ke&&(ke=!1),ue===xe?(Ne+=xe?":":"::",ke=!0):(Ne+=W(ve[xe],16),xe<7&&(Ne+=":")));return"["+Ne+"]"}return ve},Je={},Ye=d({},Je,{" ":1,'"':1,"<":1,">":1,"`":1}),cr=d({},Ye,{"#":1,"?":1,"{":1,"}":1}),Sr=d({},cr,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Y=function(ve,Ne){var xe=g(ve,0);return xe>32&&xe<127&&!l(Ne,ve)?ve:encodeURIComponent(ve)},oe={ftp:21,file:null,http:80,https:443,ws:80,wss:443},me=function(ve,Ne){var xe;return ve.length===2&&N(ce,D(ve,0))&&((xe=D(ve,1))===":"||!Ne&&xe==="|")},we=function(ve){var Ne;return ve.length>1&&me(Z(ve,0,2))&&(ve.length===2||(Ne=D(ve,2))==="/"||Ne==="\\"||Ne==="?"||Ne==="#")},Oe=function(ve){return ve==="."||ee(ve)==="%2e"},Ee=function(ve){return ve=ee(ve),ve===".."||ve==="%2e."||ve===".%2e"||ve==="%2e%2e"},dt={},$t={},Pe={},$e={},Be={},We={},yt={},Ht={},ur={},xr={},Rr={},en={},Pn={},yc={},Ws={},Oa={},Yi={},Xi={},ps={},ci={},ln={},Ma=function(ve,Ne,xe){var ue=y(ve),ke,Pt,ft;if(Ne){if(Pt=this.parse(ue),Pt)throw new L(Pt);this.searchParams=null}else{if(xe!==void 0&&(ke=new Ma(xe,!0)),Pt=this.parse(ue,null,ke),Pt)throw new L(Pt);ft=k(new C),ft.bindURL(this),this.searchParams=ft}};Ma.prototype={type:"URL",parse:function(ve,Ne,xe){var ue=this,ke=Ne||dt,Pt=0,ft="",Br=!1,Wt=!1,hn=!1,Nn,Me,Ur,_o;for(ve=y(ve),Ne||(ue.scheme="",ue.username="",ue.password="",ue.host=null,ue.port=null,ue.path=[],ue.query=null,ue.fragment=null,ue.cannotBeABaseURL=!1,ve=V(ve,At,""),ve=V(ve,_t,"$1")),ve=V(ve,ut,""),Nn=f(ve);Pt<=Nn.length;){switch(Me=Nn[Pt],ke){case dt:if(Me&&N(ce,Me))ft+=ee(Me),ke=$t;else{if(Ne)return le;ke=Pe;continue}break;case $t:if(Me&&(N(_e,Me)||Me==="+"||Me==="-"||Me==="."))ft+=ee(Me);else if(Me===":"){if(Ne&&(ue.isSpecial()!==l(oe,ft)||ft==="file"&&(ue.includesCredentials()||ue.port!==null)||ue.scheme==="file"&&!ue.host))return;if(ue.scheme=ft,Ne){ue.isSpecial()&&oe[ue.scheme]===ue.port&&(ue.port=null);return}ft="",ue.scheme==="file"?ke=yc:ue.isSpecial()&&xe&&xe.scheme===ue.scheme?ke=$e:ue.isSpecial()?ke=Ht:Nn[Pt+1]==="/"?(ke=Be,Pt++):(ue.cannotBeABaseURL=!0,z(ue.path,""),ke=ps)}else{if(Ne)return le;ft="",ke=Pe,Pt=0;continue}break;case Pe:if(!xe||xe.cannotBeABaseURL&&Me!=="#")return le;if(xe.cannotBeABaseURL&&Me==="#"){ue.scheme=xe.scheme,ue.path=h(xe.path),ue.query=xe.query,ue.fragment="",ue.cannotBeABaseURL=!0,ke=ln;break}ke=xe.scheme==="file"?yc:We;continue;case $e:if(Me==="/"&&Nn[Pt+1]==="/")ke=ur,Pt++;else{ke=We;continue}break;case Be:if(Me==="/"){ke=xr;break}else{ke=Xi;continue}case We:if(ue.scheme=xe.scheme,Me===Ae)ue.username=xe.username,ue.password=xe.password,ue.host=xe.host,ue.port=xe.port,ue.path=h(xe.path),ue.query=xe.query;else if(Me==="/"||Me==="\\"&&ue.isSpecial())ke=yt;else if(Me==="?")ue.username=xe.username,ue.password=xe.password,ue.host=xe.host,ue.port=xe.port,ue.path=h(xe.path),ue.query="",ke=ci;else if(Me==="#")ue.username=xe.username,ue.password=xe.password,ue.host=xe.host,ue.port=xe.port,ue.path=h(xe.path),ue.query=xe.query,ue.fragment="",ke=ln;else{ue.username=xe.username,ue.password=xe.password,ue.host=xe.host,ue.port=xe.port,ue.path=h(xe.path),ue.path.length--,ke=Xi;continue}break;case yt:if(ue.isSpecial()&&(Me==="/"||Me==="\\"))ke=ur;else if(Me==="/")ke=xr;else{ue.username=xe.username,ue.password=xe.password,ue.host=xe.host,ue.port=xe.port,ke=Xi;continue}break;case Ht:if(ke=ur,Me!=="/"||D(ft,Pt+1)!=="/")continue;Pt++;break;case ur:if(Me!=="/"&&Me!=="\\"){ke=xr;continue}break;case xr:if(Me==="@"){Br&&(ft="%40"+ft),Br=!0,Ur=f(ft);for(var ji=0;ji<Ur.length;ji++){var ja=Ur[ji];if(ja===":"&&!hn){hn=!0;continue}var Di=Y(ja,Sr);hn?ue.password+=Di:ue.username+=Di}ft=""}else if(Me===Ae||Me==="/"||Me==="?"||Me==="#"||Me==="\\"&&ue.isSpecial()){if(Br&&ft==="")return te;Pt-=f(ft).length+1,ft="",ke=Rr}else ft+=Me;break;case Rr:case en:if(Ne&&ue.scheme==="file"){ke=Oa;continue}else if(Me===":"&&!Wt){if(ft==="")return ge;if(_o=ue.parseHost(ft),_o)return _o;if(ft="",ke=Pn,Ne===en)return}else if(Me===Ae||Me==="/"||Me==="?"||Me==="#"||Me==="\\"&&ue.isSpecial()){if(ue.isSpecial()&&ft==="")return ge;if(Ne&&ft===""&&(ue.includesCredentials()||ue.port!==null))return;if(_o=ue.parseHost(ft),_o)return _o;if(ft="",ke=Yi,Ne)return;continue}else Me==="["?Wt=!0:Me==="]"&&(Wt=!1),ft+=Me;break;case Pn:if(N(Le,Me))ft+=Me;else if(Me===Ae||Me==="/"||Me==="?"||Me==="#"||Me==="\\"&&ue.isSpecial()||Ne){if(ft!==""){var _l=j(ft,10);if(_l>65535)return se;ue.port=ue.isSpecial()&&_l===oe[ue.scheme]?null:_l,ft=""}if(Ne)return;ke=Yi;continue}else return se;break;case yc:if(ue.scheme="file",Me==="/"||Me==="\\")ke=Ws;else if(xe&&xe.scheme==="file")switch(Me){case Ae:ue.host=xe.host,ue.path=h(xe.path),ue.query=xe.query;break;case"?":ue.host=xe.host,ue.path=h(xe.path),ue.query="",ke=ci;break;case"#":ue.host=xe.host,ue.path=h(xe.path),ue.query=xe.query,ue.fragment="",ke=ln;break;default:we(B(h(Nn,Pt),""))||(ue.host=xe.host,ue.path=h(xe.path),ue.shortenPath()),ke=Xi;continue}else{ke=Xi;continue}break;case Ws:if(Me==="/"||Me==="\\"){ke=Oa;break}xe&&xe.scheme==="file"&&!we(B(h(Nn,Pt),""))&&(me(xe.path[0],!0)?z(ue.path,xe.path[0]):ue.host=xe.host),ke=Xi;continue;case Oa:if(Me===Ae||Me==="/"||Me==="\\"||Me==="?"||Me==="#"){if(!Ne&&me(ft))ke=Xi;else if(ft===""){if(ue.host="",Ne)return;ke=Yi}else{if(_o=ue.parseHost(ft),_o)return _o;if(ue.host==="localhost"&&(ue.host=""),Ne)return;ft="",ke=Yi}continue}else ft+=Me;break;case Yi:if(ue.isSpecial()){if(ke=Xi,Me!=="/"&&Me!=="\\")continue}else if(!Ne&&Me==="?")ue.query="",ke=ci;else if(!Ne&&Me==="#")ue.fragment="",ke=ln;else if(Me!==Ae&&(ke=Xi,Me!=="/"))continue;break;case Xi:if(Me===Ae||Me==="/"||Me==="\\"&&ue.isSpecial()||!Ne&&(Me==="?"||Me==="#")){if(Ee(ft)?(ue.shortenPath(),Me!=="/"&&!(Me==="\\"&&ue.isSpecial())&&z(ue.path,"")):Oe(ft)?Me!=="/"&&!(Me==="\\"&&ue.isSpecial())&&z(ue.path,""):(ue.scheme==="file"&&!ue.path.length&&me(ft)&&(ue.host&&(ue.host=""),ft=D(ft,0)+":"),z(ue.path,ft)),ft="",ue.scheme==="file"&&(Me===Ae||Me==="?"||Me==="#"))for(;ue.path.length>1&&ue.path[0]==="";)J(ue.path);Me==="?"?(ue.query="",ke=ci):Me==="#"&&(ue.fragment="",ke=ln)}else ft+=Y(Me,cr);break;case ps:Me==="?"?(ue.query="",ke=ci):Me==="#"?(ue.fragment="",ke=ln):Me!==Ae&&(ue.path[0]+=Y(Me,Je));break;case ci:!Ne&&Me==="#"?(ue.fragment="",ke=ln):Me!==Ae&&(Me==="'"&&ue.isSpecial()?ue.query+="%27":Me==="#"?ue.query+="%23":ue.query+=Y(Me,Je));break;case ln:Me!==Ae&&(ue.fragment+=Y(Me,Ye));break}Pt++}},parseHost:function(ve){var Ne,xe,ue;if(D(ve,0)==="["){if(D(ve,ve.length-1)!=="]"||(Ne=be(Z(ve,1,-1)),!Ne))return ge;this.host=Ne}else if(this.isSpecial()){if(ve=m(ve),N(et,ve)||(Ne=ze(ve),Ne===null))return ge;this.host=Ne}else{if(N(ct,ve))return ge;for(Ne="",xe=f(ve),ue=0;ue<xe.length;ue++)Ne+=Y(xe[ue],Je);this.host=Ne}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme==="file"},includesCredentials:function(){return this.username!==""||this.password!==""},isSpecial:function(){return l(oe,this.scheme)},shortenPath:function(){var ve=this.path,Ne=ve.length;Ne&&(this.scheme!=="file"||Ne!==1||!me(ve[0],!0))&&ve.length--},serialize:function(){var ve=this,Ne=ve.scheme,xe=ve.username,ue=ve.password,ke=ve.host,Pt=ve.port,ft=ve.path,Br=ve.query,Wt=ve.fragment,hn=Ne+":";return ke!==null?(hn+="//",ve.includesCredentials()&&(hn+=xe+(ue?":"+ue:"")+"@"),hn+=st(ke),Pt!==null&&(hn+=":"+Pt)):Ne==="file"&&(hn+="//"),hn+=ve.cannotBeABaseURL?ft[0]:ft.length?"/"+B(ft,"/"):"",Br!==null&&(hn+="?"+Br),Wt!==null&&(hn+="#"+Wt),hn},setHref:function(ve){var Ne=this.parse(ve);if(Ne)throw new L(Ne);this.searchParams.update()},getOrigin:function(){var ve=this.scheme,Ne=this.port;if(ve==="blob")try{return new Ks(ve.path[0]).origin}catch{return"null"}return ve==="file"||!this.isSpecial()?"null":ve+"://"+st(this.host)+(Ne!==null?":"+Ne:"")},getProtocol:function(){return this.scheme+":"},setProtocol:function(ve){this.parse(y(ve)+":",dt)},getUsername:function(){return this.username},setUsername:function(ve){var Ne=f(y(ve));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var xe=0;xe<Ne.length;xe++)this.username+=Y(Ne[xe],Sr)}},getPassword:function(){return this.password},setPassword:function(ve){var Ne=f(y(ve));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var xe=0;xe<Ne.length;xe++)this.password+=Y(Ne[xe],Sr)}},getHost:function(){var ve=this.host,Ne=this.port;return ve===null?"":Ne===null?st(ve):st(ve)+":"+Ne},setHost:function(ve){this.cannotBeABaseURL||this.parse(ve,Rr)},getHostname:function(){var ve=this.host;return ve===null?"":st(ve)},setHostname:function(ve){this.cannotBeABaseURL||this.parse(ve,en)},getPort:function(){var ve=this.port;return ve===null?"":y(ve)},setPort:function(ve){this.cannotHaveUsernamePasswordPort()||(ve=y(ve),ve===""?this.port=null:this.parse(ve,Pn))},getPathname:function(){var ve=this.path;return this.cannotBeABaseURL?ve[0]:ve.length?"/"+B(ve,"/"):""},setPathname:function(ve){this.cannotBeABaseURL||(this.path=[],this.parse(ve,Yi))},getSearch:function(){var ve=this.query;return ve?"?"+ve:""},setSearch:function(ve){ve=y(ve),ve===""?this.query=null:(D(ve,0)==="?"&&(ve=Z(ve,1)),this.query="",this.parse(ve,ci)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var ve=this.fragment;return ve?"#"+ve:""},setHash:function(ve){if(ve=y(ve),ve===""){this.fragment=null;return}D(ve,0)==="#"&&(ve=Z(ve,1)),this.fragment="",this.parse(ve,ln)},update:function(){this.query=this.searchParams.serialize()||null}};var Ks=function(Ne){var xe=c(this,Rn),ue=_(arguments.length,1)>1?arguments[1]:void 0,ke=b(xe,new Ma(Ne,!1,ue));e||(xe.href=ke.serialize(),xe.origin=ke.getOrigin(),xe.protocol=ke.getProtocol(),xe.username=ke.getUsername(),xe.password=ke.getPassword(),xe.host=ke.getHost(),xe.hostname=ke.getHostname(),xe.port=ke.getPort(),xe.pathname=ke.getPathname(),xe.search=ke.getSearch(),xe.searchParams=ke.getSearchParams(),xe.hash=ke.getHash())},Rn=Ks.prototype,li=function(ve,Ne){return{get:function(){return P(this)[ve]()},set:Ne&&function(xe){return P(this)[Ne](xe)},configurable:!0,enumerable:!0}};if(e&&(a(Rn,"href",li("serialize","setHref")),a(Rn,"origin",li("getOrigin")),a(Rn,"protocol",li("getProtocol","setProtocol")),a(Rn,"username",li("getUsername","setUsername")),a(Rn,"password",li("getPassword","setPassword")),a(Rn,"host",li("getHost","setHost")),a(Rn,"hostname",li("getHostname","setHostname")),a(Rn,"port",li("getPort","setPort")),a(Rn,"pathname",li("getPathname","setPathname")),a(Rn,"search",li("getSearch","setSearch")),a(Rn,"searchParams",li("getSearchParams")),a(Rn,"hash",li("getHash","setHash"))),s(Rn,"toJSON",function(){return P(this).serialize()},{enumerable:!0}),s(Rn,"toString",function(){return P(this).serialize()},{enumerable:!0}),O){var Go=O.createObjectURL,Mi=O.revokeObjectURL;Go&&s(Ks,"createObjectURL",i(Go,O)),Mi&&s(Ks,"revokeObjectURL",i(Mi,O))}return x(Ks,"URL"),r({global:!0,constructor:!0,forced:!t,sham:!e},{URL:Ks}),xZ}var IZ;function WCe(){return IZ||(IZ=1,HCe()),SZ}var PZ={},CZ;function KCe(){if(CZ)return PZ;CZ=1;var r=H(),e=Mt(),t=Fe(),n=us(),i=Nt(),o=xy(),s=e("URL"),a=o&&t(function(){s.canParse()}),c=t(function(){return s.canParse.length!==1});return r({target:"URL",stat:!0,forced:!a||c},{canParse:function(d){var f=n(arguments.length,1),h=i(d),g=f<2||arguments[1]===void 0?void 0:i(arguments[1]);try{return!!new s(h,g)}catch{return!1}}}),PZ}var TZ={},AZ;function GCe(){if(AZ)return TZ;AZ=1;var r=H(),e=Mt(),t=us(),n=Nt(),i=xy(),o=e("URL");return r({target:"URL",stat:!0,forced:!i},{parse:function(a){var c=t(arguments.length,1),l=n(a),d=c<2||arguments[1]===void 0?void 0:n(arguments[1]);try{return new o(l,d)}catch{return null}}}),TZ}var RZ={},kZ;function VCe(){if(kZ)return RZ;kZ=1;var r=H(),e=Qe();return r({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return e(URL.prototype.toString,this)}}),RZ}var OZ={},MZ;function YCe(){return MZ||(MZ=1,Yie()),OZ}var jZ={},DZ;function XCe(){if(DZ)return jZ;DZ=1;var r=wr(),e=Ie(),t=Nt(),n=us(),i=URLSearchParams,o=i.prototype,s=e(o.append),a=e(o.delete),c=e(o.forEach),l=e([].push),d=new i("a=1&a=2&b=3");return d.delete("a",1),d.delete("b",void 0),d+""!="a=2"&&r(o,"delete",function(f){var h=arguments.length,g=h<2?void 0:arguments[1];if(h&&g===void 0)return a(this,f);var m=[];c(this,function(C,k){l(m,{key:k,value:C})}),n(h,1);for(var y=t(f),x=t(g),_=0,w=0,I=!1,b=m.length,P;_<b;)P=m[_++],I||P.key===y?(I=!0,a(this,P.key)):w++;for(;w<b;)P=m[w++],P.key===y&&P.value===x||s(this,P.key,P.value)},{enumerable:!0,unsafe:!0}),jZ}var LZ={},FZ;function ZCe(){if(FZ)return LZ;FZ=1;var r=wr(),e=Ie(),t=Nt(),n=us(),i=URLSearchParams,o=i.prototype,s=e(o.getAll),a=e(o.has),c=new i("a=1");return(c.has("a",2)||!c.has("a",void 0))&&r(o,"has",function(d){var f=arguments.length,h=f<2?void 0:arguments[1];if(f&&h===void 0)return a(this,d);var g=s(this,d);n(f,1);for(var m=t(h),y=0;y<g.length;)if(g[y++]===m)return!0;return!1},{enumerable:!0,unsafe:!0}),LZ}var NZ={},$Z;function QCe(){if($Z)return NZ;$Z=1;var r=Et(),e=Ie(),t=Yr(),n=URLSearchParams.prototype,i=e(n.forEach);return r&&!("size"in n)&&t(n,"size",{get:function(){var s=0;return i(this,function(){s++}),s},configurable:!0,enumerable:!0}),NZ}var fI,qZ;function JCe(){return qZ||(qZ=1,h_e(),p_e(),g_e(),v_e(),m_e(),y_e(),S_e(),x_e(),__e(),w_e(),b_e(),E_e(),I_e(),P_e(),C_e(),T_e(),A_e(),Are(),k_e(),HC(),O_e(),M_e(),j_e(),D_e(),L_e(),F_e(),N_e(),kre(),Ore(),xee(),yee(),$_e(),q_e(),B_e(),U_e(),z_e(),Zm(),H_e(),W_e(),K_e(),G_e(),V_e(),Y_e(),X_e(),Z_e(),Q_e(),J_e(),ewe(),twe(),rwe(),$re(),Bre(),Ure(),_ee(),See(),nwe(),Hre(),owe(),swe(),awe(),lwe(),Gre(),Xre(),Jre(),nne(),ine(),uwe(),dwe(),fwe(),hwe(),gwe(),vwe(),ywe(),Swe(),xwe(),_we(),wwe(),bwe(),sne(),ane(),cne(),lne(),une(),dne(),hne(),pne(),gne(),mne(),yne(),Sne(),xne(),_ne(),_re(),Ewe(),qT(),bne(),Pwe(),Cwe(),Twe(),Awe(),Rwe(),kwe(),Owe(),Mwe(),Ine(),jwe(),Dwe(),Lwe(),Fwe(),Nwe(),$we(),qwe(),Bwe(),Uwe(),zwe(),Hwe(),Wwe(),Kwe(),Gwe(),Vwe(),Ywe(),Xwe(),Zwe(),Qwe(),Jwe(),ebe(),tbe(),rbe(),nbe(),ibe(),obe(),sbe(),abe(),cbe(),lbe(),ube(),dbe(),fbe(),hbe(),pbe(),gbe(),One(),Mne(),vbe(),mbe(),ybe(),Sbe(),xbe(),_be(),wbe(),bbe(),Ebe(),Ibe(),Pbe(),Tbe(),Abe(),Rbe(),kbe(),qbe(),qne(),Bne(),Bbe(),Une(),zne(),Ube(),zbe(),Hbe(),Wbe(),Kbe(),Gbe(),Vbe(),Ybe(),Xbe(),Zbe(),Qbe(),Jbe(),e0e(),t0e(),r0e(),Wne(),n0e(),Om(),i0e(),o0e(),s0e(),a0e(),l0e(),Gne(),Yne(),Zne(),Jne(),tie(),nie(),oie(),wee(),u0e(),d0e(),sie(),f0e(),aie(),cie(),h0e(),lie(),p0e(),g0e(),v0e(),m0e(),Iee(),YC(),y0e(),S0e(),x0e(),_0e(),die(),w0e(),E0e(),P0e(),C0e(),T0e(),A0e(),R0e(),k0e(),O0e(),M0e(),j0e(),D0e(),L0e(),F0e(),N0e(),$0e(),q0e(),B0e(),U0e(),z0e(),H0e(),W0e(),K0e(),G0e(),V0e(),mie(),Y0e(),X0e(),Z0e(),Q0e(),J0e(),e1e(),yie(),Sie(),t1e(),r1e(),n1e(),i1e(),o1e(),s1e(),a1e(),c1e(),l1e(),u1e(),d1e(),f1e(),h1e(),p1e(),g1e(),v1e(),m1e(),y1e(),xie(),_ie(),S1e(),wie(),x1e(),XT(),b1e(),E1e(),I1e(),C1e(),T1e(),A1e(),R1e(),k1e(),O1e(),M1e(),j1e(),D1e(),L1e(),F1e(),N1e(),$1e(),q1e(),B1e(),U1e(),z1e(),H1e(),W1e(),K1e(),G1e(),V1e(),Y1e(),X1e(),Z1e(),Q1e(),J1e(),eEe(),tEe(),rEe(),nEe(),iEe(),oEe(),sEe(),aEe(),cEe(),lEe(),uEe(),dEe(),fEe(),hEe(),pEe(),gEe(),vEe(),mEe(),yEe(),SEe(),xEe(),_Ee(),wEe(),bEe(),EEe(),IEe(),PEe(),CEe(),TEe(),AEe(),REe(),kEe(),OEe(),MEe(),jEe(),DEe(),LEe(),FEe(),NEe(),$Ee(),qEe(),BEe(),UEe(),zEe(),HEe(),WEe(),KEe(),GEe(),VEe(),YEe(),XEe(),ZEe(),QEe(),JEe(),eIe(),tIe(),rIe(),nIe(),oIe(),sIe(),aIe(),cIe(),lIe(),uIe(),dIe(),fIe(),hIe(),pIe(),gIe(),vIe(),yIe(),SIe(),xIe(),_Ie(),wIe(),bIe(),EIe(),IIe(),PIe(),CIe(),TIe(),AIe(),RIe(),kIe(),OIe(),MIe(),jIe(),DIe(),LIe(),FIe(),NIe(),$Ie(),zIe(),HIe(),WIe(),KIe(),GIe(),VIe(),YIe(),XIe(),ZIe(),QIe(),JIe(),ePe(),tPe(),rPe(),nPe(),iPe(),oPe(),sPe(),cPe(),lPe(),uPe(),dPe(),fPe(),hPe(),pPe(),gPe(),vPe(),mPe(),yPe(),SPe(),xPe(),_Pe(),wPe(),bPe(),EPe(),IPe(),PPe(),CPe(),TPe(),APe(),RPe(),kPe(),OPe(),jPe(),DPe(),LPe(),FPe(),NPe(),$Pe(),qPe(),BPe(),UPe(),zPe(),HPe(),WPe(),KPe(),GPe(),VPe(),YPe(),XPe(),ZPe(),QPe(),JPe(),eCe(),tCe(),rCe(),nCe(),iCe(),oCe(),sCe(),aCe(),cCe(),lCe(),uCe(),dCe(),fCe(),hCe(),pCe(),gCe(),vCe(),mCe(),yCe(),SCe(),xCe(),_Ce(),wCe(),bCe(),ECe(),ICe(),PCe(),CCe(),TCe(),ACe(),RCe(),kCe(),OCe(),MCe(),LCe(),FCe(),NCe(),$Ce(),UCe(),WCe(),KCe(),GCe(),VCe(),YCe(),XCe(),ZCe(),QCe(),fI=ET()),fI}var hI,BZ;function eTe(){return BZ||(BZ=1,hI=JCe()),hI}var Uf=eTe(),pI={exports:{}},UZ;function tTe(){return UZ||(UZ=1,function(r){var e=Object.prototype.hasOwnProperty,t="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(t=!1));function i(c,l,d){this.fn=c,this.context=l,this.once=d||!1}function o(c,l,d,f,h){if(typeof d!="function")throw new TypeError("The listener must be a function");var g=new i(d,f||c,h),m=t?t+l:l;return c._events[m]?c._events[m].fn?c._events[m]=[c._events[m],g]:c._events[m].push(g):(c._events[m]=g,c._eventsCount++),c}function s(c,l){--c._eventsCount===0?c._events=new n:delete c._events[l]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],d,f;if(this._eventsCount===0)return l;for(f in d=this._events)e.call(d,f)&&l.push(t?f.slice(1):f);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(d)):l},a.prototype.listeners=function(l){var d=t?t+l:l,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var h=0,g=f.length,m=new Array(g);h<g;h++)m[h]=f[h].fn;return m},a.prototype.listenerCount=function(l){var d=t?t+l:l,f=this._events[d];return f?f.fn?1:f.length:0},a.prototype.emit=function(l,d,f,h,g,m){var y=t?t+l:l;if(!this._events[y])return!1;var x=this._events[y],_=arguments.length,w,I;if(x.fn){switch(x.once&&this.removeListener(l,x.fn,void 0,!0),_){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,d),!0;case 3:return x.fn.call(x.context,d,f),!0;case 4:return x.fn.call(x.context,d,f,h),!0;case 5:return x.fn.call(x.context,d,f,h,g),!0;case 6:return x.fn.call(x.context,d,f,h,g,m),!0}for(I=1,w=new Array(_-1);I<_;I++)w[I-1]=arguments[I];x.fn.apply(x.context,w)}else{var b=x.length,P;for(I=0;I<b;I++)switch(x[I].once&&this.removeListener(l,x[I].fn,void 0,!0),_){case 1:x[I].fn.call(x[I].context);break;case 2:x[I].fn.call(x[I].context,d);break;case 3:x[I].fn.call(x[I].context,d,f);break;case 4:x[I].fn.call(x[I].context,d,f,h);break;default:if(!w)for(P=1,w=new Array(_-1);P<_;P++)w[P-1]=arguments[P];x[I].fn.apply(x[I].context,w)}}return!0},a.prototype.on=function(l,d,f){return o(this,l,d,f,!1)},a.prototype.once=function(l,d,f){return o(this,l,d,f,!0)},a.prototype.removeListener=function(l,d,f,h){var g=t?t+l:l;if(!this._events[g])return this;if(!d)return s(this,g),this;var m=this._events[g];if(m.fn)m.fn===d&&(!h||m.once)&&(!f||m.context===f)&&s(this,g);else{for(var y=0,x=[],_=m.length;y<_;y++)(m[y].fn!==d||h&&!m[y].once||f&&m[y].context!==f)&&x.push(m[y]);x.length?this._events[g]=x.length===1?x[0]:x:s(this,g)}return this},a.prototype.removeAllListeners=function(l){var d;return l?(d=t?t+l:l,this._events[d]&&s(this,d)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,r.exports=a}(pI)),pI.exports}var rTe=tTe();const nTe=cc(rTe),vd="TLDRAW_TAB_ID_v2",rc=globalThis.window;function iTe(){return rc?["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(rc.navigator.platform)||Pr.isDarwin&&"ontouchend"in document:!1}const im=rc?rc[vd]??iee(vd)??"TLDRAW_INSTANCE_STATE_V1_"+Er():"<error>";rc&&(rc[vd]=im,iTe()?$C(vd,im):oee(vd));rc==null||rc.addEventListener("beforeunload",()=>{$C(vd,im)});const Xie={Initial:0},_y=Math.max(...Object.values(Xie));function oTe(r){r.version<Xie.Initial,r.version=_y}const Zie=nr({version:Dt,currentPageId:Sh.optional(),isFocusMode:tr.optional(),exportBackground:tr.optional(),isDebugMode:tr.optional(),isToolLocked:tr.optional(),isGridMode:tr.optional(),pageStates:Jn(nr({pageId:Sh,camera:nr({x:Dt,y:Dt,z:Dt}).optional(),selectedShapeIds:Jn(es).optional(),focusedGroupId:es.nullable().optional()})).optional()});function sTe(r){if(!r||typeof r!="object")return console.warn("Invalid instance state"),null;if(!("version"in r)||typeof r.version!="number")return console.warn("No version in instance state"),null;r.version!==_y&&(r=Kr(r),oTe(r));try{return Zie.validate(r)}catch(e){return console.warn(e),null}}function nA(r){const e=r.query.ids("page");return Te("sessionStateSnapshot",()=>{const t=r.get(Bi);if(!t)return null;const n=[...e.get()];return{version:_y,currentPageId:t.currentPageId,exportBackground:t.exportBackground,isFocusMode:t.isFocusMode,isDebugMode:t.isDebugMode,isToolLocked:t.isToolLocked,isGridMode:t.isGridMode,pageStates:n.map(i=>{const o=r.get(Cs.createId(i)),s=r.get(la.createId(i));return{pageId:i,camera:{x:(s==null?void 0:s.x)??0,y:(s==null?void 0:s.y)??0,z:(s==null?void 0:s.z)??1},selectedShapeIds:(o==null?void 0:o.selectedShapeIds)??[],focusedGroupId:(o==null?void 0:o.focusedGroupId)??null}})}},{isEqual:Gee})}function MP(r,e,t){const n=sTe(e);if(!n)return;const i=lte(r.get(Bi)),o=t!=null&&t.forceOverwrite?n:i,s=t!=null&&t.forceOverwrite?i:n,a=r.schema.types.instance.create({id:Bi,...i,currentPageId:n.currentPageId,isDebugMode:(o==null?void 0:o.isDebugMode)??(s==null?void 0:s.isDebugMode),isFocusMode:(o==null?void 0:o.isFocusMode)??(s==null?void 0:s.isFocusMode),isToolLocked:(o==null?void 0:o.isToolLocked)??(s==null?void 0:s.isToolLocked),isGridMode:(o==null?void 0:o.isGridMode)??(s==null?void 0:s.isGridMode),exportBackground:(o==null?void 0:o.exportBackground)??(s==null?void 0:s.exportBackground)});r.atomic(()=>{var c,l,d;for(const f of n.pageStates??[]){if(!r.has(f.pageId))continue;const h=la.createId(f.pageId),g=Cs.createId(f.pageId),m=r.get(h),y=r.get(g);r.put([la.create({id:h,x:((c=f.camera)==null?void 0:c.x)??(m==null?void 0:m.x),y:((l=f.camera)==null?void 0:l.y)??(m==null?void 0:m.y),z:((d=f.camera)==null?void 0:d.z)??(m==null?void 0:m.z)}),Cs.create({id:g,pageId:f.pageId,selectedShapeIds:f.selectedShapeIds??(y==null?void 0:y.selectedShapeIds),focusedGroupId:f.focusedGroupId??(y==null?void 0:y.focusedGroupId)})])}r.put([a]),r.ensureStoreIsUsable()})}function aTe(r){var i;const e=[];for(const o of Object.values(r))(i=o.typeName)!=null&&i.match(/^(instance.*|pointer|camera)$/)&&e.push(o);const t=e.filter(o=>o.typeName==="instance"&&o.id!==Bi)[0];if(!t)return null;const n={version:_y,currentPageId:t.currentPageId,exportBackground:!!t.exportBackground,isFocusMode:!!t.isFocusMode,isDebugMode:!!t.isDebugMode,isToolLocked:!!t.isToolLocked,isGridMode:!1,pageStates:e.filter(o=>o.typeName==="instance_page_state"&&o.instanceId===t.id).map(o=>{const s=r[o.cameraId]??{x:0,y:0,z:1};return{pageId:o.pageId,camera:{x:s.x,y:s.y,z:s.z},selectedShapeIds:o.selectedShapeIds,focusedGroupId:o.focusedGroupId}})};try{return Zie.validate(n),n}catch{return null}}function Qie(r,e,t){let n={};if("store"in e){const s=r.schema.migrateStoreSnapshot(e);if(s.type!=="success")throw new Error("Failed to migrate store snapshot: "+s.reason);n.document={schema:r.schema.serialize(),store:sh(s.value,(a,{typeName:c})=>r.scopedTypes.document.has(c))}}else n=e;const i=lte(r.get(Bi)),o=Jie.get(r,nA).get();r.atomic(()=>{n.document&&r.loadStoreSnapshot(n.document),i&&r.update(Bi,s=>({...s,...i})),o&&MP(r,o),n.session&&MP(r,n.session,{forceOverwrite:t==null?void 0:t.forceOverwriteSessionState})})}const Jie=new js;function cTe(r){const t=Jie.get(r,nA).get();if(!t)throw new Error("Session state is not ready yet");return{document:r.getStoreSnapshot(),session:t}}function eoe(r){const e=[],t=new Set;for(const n of r){if(t.has(n.type))throw new Error(`Binding type "${n.type}" is defined more than once`);e.push(n),t.add(n.type)}return e}function Jc({children:r,className:e="",...t}){return v.jsx("svg",{...t,className:bt("tl-svg-container",e),children:r})}function iA(r,e,t,n){const i=r.x-t.x,o=r.y-t.y,s=n.x-t.x,a=n.y-t.y,c=e.x-r.x,l=e.y-r.y,d=s*o-a*i,f=c*o-l*i,h=a*c-s*l;if(d===0||f===0||h===0)return null;if(h!==0){const g=d/h,m=f/h;if(0<=g&&g<=1&&0<=m&&m<=1)return T.AddXY(r,g*c,g*l)}return null}function ip(r,e,t,n){const i=(e.x-r.x)*(e.x-r.x)+(e.y-r.y)*(e.y-r.y),o=2*((e.x-r.x)*(r.x-t.x)+(e.y-r.y)*(r.y-t.y)),s=t.x*t.x+t.y*t.y+r.x*r.x+r.y*r.y-2*(t.x*r.x+t.y*r.y)-n*n,a=o*o-4*i*s;if(a<0||a===0)return null;const c=Math.sqrt(a),l=(-o+c)/(2*i),d=(-o-c)/(2*i);if((l<0||l>1)&&(d<0||d>1))return null;const f=[];return 0<=l&&l<=1&&f.push(T.Lrp(r,e,l)),0<=d&&d<=1&&f.push(T.Lrp(r,e,d)),f.length===0?null:f}function lTe(r,e,t){const n=[];let i;for(let o=0,s=t.length-1;o<s;o++)i=iA(r,e,t[o],t[o+1]),i&&n.push(i);return n.length===0?null:n}function oA(r,e,t){const n=[];let i;for(let o=1,s=t.length;o<s+1;o++)i=iA(r,e,t[o-1],t[o%t.length]),i&&n.push(i);return n.length===0?null:n}function uTe(r,e,t,n){let i=t.x-r.x,o=t.y-r.y;const s=Math.sqrt(i*i+o*o),a=(s*s-n*n+e*e)/(2*s),c=Math.sqrt(e*e-a*a);return i/=s,o/=s,[new T(r.x+i*a-o*c,r.y+o*a+i*c),new T(r.x+i*a+o*c,r.y+o*a-i*c)]}function jP(r,e,t){const n=[];let i,o,s;for(let a=0,c=t.length;a<c;a++)i=t[a],o=t[(a+1)%t.length],s=ip(i,o,r,e),s&&n.push(...s);return n.length===0?null:n}function zZ(r,e,t){const n=[];let i,o,s;for(let a=1,c=t.length;a<c;a++)i=t[a-1],o=t[a],s=ip(i,o,r,e),s&&n.push(...s);return n.length===0?null:n}function Rg(r,e,t){return(t.y-r.y)*(e.x-r.x)>(e.y-r.y)*(t.x-r.x)}function sA(r,e,t,n){return Rg(r,t,n)!==Rg(e,t,n)&&Rg(r,e,t)!==Rg(r,e,n)}function HZ(r,e){const t=new Map;let n,i,o,s;for(let a=0,c=r.length;a<c;a++)if(n=r[a],Oo(n,e)){const l=gI(n);t.has(l)||t.set(l,n)}for(let a=0,c=e.length;a<c;a++)if(n=e[a],Oo(n,r)){const l=gI(n);t.has(l)||t.set(l,n)}for(let a=0,c=r.length;a<c;a++){n=r[a],i=r[(a+1)%r.length];for(let l=0,d=e.length;l<d;l++){o=e[l],s=e[(l+1)%e.length];const f=iA(n,i,o,s);if(f!==null){const h=gI(f);t.has(h)||t.set(h,f)}}}return t.size===0?null:dTe([...t.values()])}function gI(r){return`${r.x},${r.y}`}function dTe(r){const e=T.Average(r);return r.sort((t,n)=>T.Angle(e,t)-T.Angle(e,n))}function aA(r,e){let t,n,i,o;for(let s=0,a=r.length;s<a;s++){t=r[s],n=r[(s+1)%a];for(let c=0,l=e.length;c<l;c++)if(i=e[c],o=e[(c+1)%l],sA(t,n,i,o))return!0}return!1}function fTe(r,e){let t,n,i,o;for(let s=0,a=r.length;s<a;s++){t=r[s],n=r[(s+1)%a];for(let c=1,l=e.length;c<l;c++)if(i=e[c-1],o=e[c],sA(t,n,i,o))return!0}return!1}class Qa extends ul{constructor(t){super({...t,isClosed:!1,isFilled:!1});q(this,"start");q(this,"end");q(this,"d");q(this,"u");q(this,"ul");const{start:n,end:i}=t;this.start=n,this.end=i,this.d=n.clone().sub(i),this.u=this.d.clone().uni(),this.ul=this.u.len()}getLength(){return this.d.len()}midPoint(){return this.start.lrp(this.end,.5)}getVertices(){return[this.start,this.end]}nearestPoint(t){const{start:n,end:i,d:o,u:s,ul:a}=this;if(o.len()===0||a===0)return n;const c=T.Sub(t,n).dpr(s)/a,l=n.x+s.x*c;if(l<Math.min(n.x,i.x))return n.x<i.x?n:i;if(l>Math.max(n.x,i.x))return n.x>i.x?n:i;const d=n.y+s.y*c;return d<Math.min(n.y,i.y)?n.y<i.y?n:i:d>Math.max(n.y,i.y)?n.y>i.y?n:i:new T(l,d)}hitTestLineSegment(t,n,i=0){return sA(t,n,this.start,this.end)||this.distanceToLineSegment(t,n)<=i}getSvgPathData(t=!0){const{start:n,end:i}=this;return`${t?`M${n.toFixed()}`:""} L${i.toFixed()}`}}class Vd extends ul{constructor(t){super({isClosed:!1,isFilled:!1,...t});q(this,"points");q(this,"_segments");const{points:n}=t;this.points=n}get segments(){if(!this._segments){this._segments=[];const{vertices:t}=this;for(let n=0,i=t.length-1;n<i;n++){const o=t[n],s=t[n+1];this._segments.push(new Qa({start:o,end:s}))}this.isClosed&&this._segments.push(new Qa({start:t[t.length-1],end:t[0]}))}return this._segments}getLength(){return this.segments.reduce((t,n)=>t+n.length,0)}getVertices(){return this.points}nearestPoint(t){const{segments:n}=this;let i=this.points[0],o=1/0,s,a;for(let c=0;c<n.length;c++)s=n[c].nearestPoint(t),a=T.Dist2(s,t),a<o&&(i=s,o=a);if(!i)throw Error("nearest point not found");return i}hitTestLineSegment(t,n,i=0){const{segments:o}=this;for(let s=0,a=o.length;s<a;s++)if(o[s].hitTestLineSegment(t,n,i))return!0;return!1}getSvgPathData(){const{vertices:t}=this;return t.length<2?"":t.reduce((n,i,o)=>o===0?`M ${i.x} ${i.y}`:`${n} L ${i.x} ${i.y}`,"")}}class mn extends Vd{constructor(e){super({...e}),this.isClosed=!0}}class ma extends mn{constructor(t){const{x:n=0,y:i=0,width:o,height:s}=t;super({...t,points:[new T(n,i),new T(n+o,i),new T(n+o,i+s),new T(n,i+s)]});q(this,"x");q(this,"y");q(this,"w");q(this,"h");this.x=n,this.y=i,this.w=o,this.h=s}getBounds(){return new He(this.x,this.y,this.w,this.h)}getSvgPathData(){const{x:t,y:n,w:i,h:o}=this;return`M${t},${n} h${i} v${o} h-${i}z`}}class Rs{constructor(e){q(this,"options",{});this.editor=e}static configure(e){return class extends this{constructor(){super(...arguments);q(this,"options",{...this.options,...e})}}}canSnap(e){return!0}canScroll(e){return!1}canBind(e){return!0}canEdit(e){return!1}canResize(e){return!0}canEditInReadOnly(e){return!1}canCrop(e){return!1}canBeLaidOut(e,t){return!0}providesBackgroundForChildren(e){return!1}hideResizeHandles(e){return!1}hideRotateHandle(e){return!1}hideSelectionBoundsBg(e){return!1}hideSelectionBoundsFg(e){return!1}isAspectRatioLocked(e){return!1}canReceiveNewChildrenOfType(e,t){return!1}canDropShapes(e,t){return!1}expandSelectionOutlinePx(e){return 0}getCanvasSvgDefs(){return[]}getBoundsSnapGeometry(e){return{}}getHandleSnapGeometry(e){return{}}getText(e){}}q(Rs,"props"),q(Rs,"migrations"),q(Rs,"type");function Ps(r,e,t={}){const{closed:n=!1,snap:i=1,start:o="outset",end:s="outset",lengthRatio:a=2,style:c="dashed",forceSolid:l=!1}=t;let d=0,f=0,h=1,g=0,m=0;if(l)return{strokeDasharray:"none",strokeDashoffset:"none"};switch(c){case"dashed":{h=1,d=Math.min(e*a,r/4);break}case"dotted":{h=100,d=e/h;break}default:return{strokeDasharray:"none",strokeDashoffset:"none"}}return n||(o==="outset"?(r+=d/2,m+=d/2):o==="skip"&&(r-=d,m-=d),s==="outset"?r+=d/2:s==="skip"&&(r-=d)),f=Math.floor(r/d/(2*h)),f-=f%i,f<3&&c==="dashed"?r/e<4?(d=r,f=1,g=0):(d=r*(1/3),g=r*(1/3)):(d=r/f/(2*h),n?(m=d/2,g=(r-f*d)/f):g=(r-f*d)/Math.max(1,f-1)),{strokeDasharray:[d,g].join(" "),strokeDashoffset:m.toString()}}function WZ({bounds:r,className:e}){const t=he(),n=ye("zoom level",()=>t.getZoomLevel(),[t]);return v.jsx("g",{className:e,pointerEvents:"none",strokeLinecap:"round",strokeLinejoin:"round",children:r.sides.map((i,o)=>{const{strokeDasharray:s,strokeDashoffset:a}=Ps(i[0].dist(i[1]),1/n,{style:"dashed",lengthRatio:4});return v.jsx("line",{x1:i[0].x,y1:i[0].y,x2:i[1].x,y2:i[1].y,strokeDasharray:s,strokeDashoffset:a},o)})})}class cv extends Rs{hideSelectionBoundsFg(){return!0}canBind(){return!1}getDefaultProps(){return{}}getGeometry(e){const t=this.editor.getSortedChildIdsForParent(e.id);return t.length===0?new ma({width:1,height:1,isFilled:!1}):new cs({children:t.map(n=>{const i=this.editor.getShape(n),o=this.editor.getShapeGeometry(n),s=this.editor.getShapeLocalTransform(i).applyToPoints(o.vertices);return o.isClosed?new mn({points:s,isFilled:!0}):new Vd({points:s})})})}component(e){const t=this.editor.getErasingShapeIds().includes(e.id),{hintingShapeIds:n}=this.editor.getCurrentPageState(),i=n.length>0&&n.some(a=>a!==e.id&&this.editor.isShapeOfType(this.editor.getShape(a),"group")),o=this.editor.getCurrentPageState().focusedGroupId!==e.id;if(!t&&(o||i))return null;const s=this.editor.getShapeGeometry(e).bounds;return v.jsx(Jc,{children:v.jsx(WZ,{className:"tl-group",bounds:s})})}indicator(e){const t=this.editor.getShapeGeometry(e).bounds;return v.jsx(WZ,{className:"",bounds:t})}onChildrenChange(e){const t=this.editor.getSortedChildIdsForParent(e.id);if(t.length===0){this.editor.getCurrentPageState().focusedGroupId===e.id&&this.editor.popFocusedGroupId(),this.editor.deleteShapes([e.id]);return}else if(t.length===1){this.editor.getCurrentPageState().focusedGroupId===e.id&&this.editor.popFocusedGroupId(),this.editor.reparentShapes(t,e.parentId),this.editor.deleteShapes([e.id]);return}}}q(cv,"type","group"),q(cv,"props",_te),q(cv,"migrations",wte);const toe=[cv],hTe=new Set(toe.map(r=>r.type));function roe(r){const e=[...toe],t=new Set;for(const n of r){if(hTe.has(n.type))throw new Error(`Shape type "${n.type}" is a core shapes type and cannot be overridden`);if(t.has(n.type))throw new Error(`Shape type "${n.type}" is defined more than once`);e.push(n),t.add(n.type)}return e}var Yd=jJ();const pTe=cc(Yd);function noe(r,e){const t=new Map;return async function(i){const o=t.get(i);if(o)return o;const s=(async()=>{try{const a=await pa(i,e);return Jt(a.ok),await r(a)}catch(a){return console.error(a),null}})();return t.set(i,s),s}}const wy=noe(async r=>await ns.blobToDataUrl(await r.blob())),gTe=/@import\s+(?:"([^"]+)"|'([^']+)'|url\s*\(\s*(?:"([^"]+)"|'([^']+)'|([^'")]+))\s*\))([^;]+);/gi,vTe=/@font-face\s*{([^}]+)}/gi,ioe=/url\s*\(\s*(?:"([^"]+)"|'([^']+)'|([^'")]+))\s*\)/gi,mTe=/(?:^|;)\s*font-family\s*:\s*(?:([^'"][^;\n]+)|"([^"]+)"|'([^']+)')\s*(?:;|$)/gi;function yTe(r){return Array.from(r.matchAll(gTe),e=>({url:e[1]||e[2]||e[3]||e[4]||e[5],extras:e[6]}))}function ooe(r,e){return Array.from(r.matchAll(vTe),t=>{const n=t[1],i=Array.from(n.matchAll(ioe),s=>{var c;const a=s[1]||s[2]||s[3];return{original:a,resolved:((c=Ft(a,e))==null?void 0:c.href)??null}}),o=new Set(Array.from(n.matchAll(mTe),s=>(s[1]||s[2]||s[3]).toLowerCase()));return{fontFace:n,urls:i,fontFamilies:o}})}function STe(r){const e=/\s*(?:([^'"][^;\n\s,]+)|"([^"]+)"|'([^']+)')\s*/gi,t=/\s*,\s*/gi,n=new Set;for(;;){const i=e.exec(r);if(!i)break;const o=i[1]||i[2]||i[3];if(n.add(o.toLowerCase()),t.lastIndex=e.lastIndex,!t.exec(r))break;e.lastIndex=t.lastIndex}return n}function soe(r){return!(r.startsWith("-")||r.startsWith("animation")||r.startsWith("transition")||r==="cursor"||r==="pointer-events"||r==="user-select"||r==="touch-action")}function xTe(r,e){return{imports:yTe(r),fontFaces:ooe(r,e)}}function _Te(r){return Array.from(r.matchAll(ioe),e=>({original:e[0],url:e[1]||e[2]||e[3]}))}const wTe=new Set(["border-collapse","border-spacing","caption-side","color","cursor","direction","empty-cells","font-family","font-size","font-style","font-variant","font-weight","font-size-adjust","font-stretch","font","letter-spacing","line-height","list-style-image","list-style-position","list-style-type","list-style","orphans","quotes","tab-size","text-align","text-align-last","text-decoration-color","text-indent","text-justify","text-shadow","text-transform","visibility","white-space","widows","word-break","word-spacing","word-wrap"]);function aoe(r){return wTe.has(r)}var bTe=Object.create,coe=Object.defineProperty,ETe=Object.getOwnPropertyDescriptor,ITe=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),loe=r=>{throw TypeError(r)},uoe=(r,e,t)=>e in r?coe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,PTe=r=>[,,,bTe(null)],doe=["class","method","getter","setter","accessor","field","value","get","set"],foe=r=>r!==void 0&&typeof r!="function"?loe("Function expected"):r,CTe=(r,e,t,n,i)=>({kind:doe[r],name:e,metadata:n,addInitializer:o=>t._?loe("Already initialized"):i.push(foe(o||null))}),TTe=(r,e)=>uoe(e,ITe("metadata"),r[3]),ATe=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},RTe=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=doe[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,ETe(i,t)),_=n.length-1;_>=0;_--)c=CTe(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,foe(s)&&(x[m]=s);return x&&coe(i,t,x),i},kg=(r,e,t)=>uoe(r,typeof e!="symbol"?e+"":e,t),hoe,by;hoe=[po];class cA{constructor(){ATe(by,5,this),kg(this,"fontFacesPromise",null),kg(this,"foundFontNames",new Set),kg(this,"fontFacesToEmbed",new Set),kg(this,"pendingPromises",[])}startFindingCurrentDocumentFontFaces(){Jt(!this.fontFacesPromise,"FontEmbedder already started"),this.fontFacesPromise=kTe()}onFontFamilyValue(e){Jt(this.fontFacesPromise,"FontEmbedder not started");const t=STe(e);for(const n of t){if(this.foundFontNames.has(n))return;this.foundFontNames.add(n),this.pendingPromises.push(this.fontFacesPromise.then(i=>{const o=i.filter(s=>s.fontFamilies.has(n));for(const s of o)if(!this.fontFacesToEmbed.has(s)){this.fontFacesToEmbed.add(s);for(const a of s.urls)!a.resolved||a.embedded||(a.embedded=wy(a.resolved))}}))}}async createCss(){await Promise.all(this.pendingPromises);let e="";for(const t of this.fontFacesToEmbed){let n=`@font-face {${t.fontFace}}`;for(const i of t.urls){if(!i.embedded)continue;const o=await i.embedded;o&&(n=n.replace(i.original,o))}e+=n}return e}}by=PTe();RTe(by,1,"onFontFamilyValue",hoe,cA);TTe(by,cA);async function kTe(){var e;const r=[];for(const t of document.styleSheets){let n;try{n=t.cssRules}catch{}if(n){for(const i of t.cssRules)if(i instanceof CSSFontFaceRule)r.push(ooe(i.cssText,t.href??document.baseURI));else if(i instanceof CSSImportRule){const o=new URL(i.href,((e=i.parentStyleSheet)==null?void 0:e.href)??document.baseURI);r.push(DP(o.href))}}else t.href&&r.push(DP(t.href))}return Gt(await Promise.all(r)).flat()}const DP=noe(async r=>{const e=xTe(await r.text(),r.url),t=await Promise.all(e.imports.map(({url:n})=>DP(new URL(n,r.url).href)));return[...e.fontFaces,...Gt(t).flat()]});function poe(r){if(r.shadowRoot)return r.shadowRoot.childNodes;if(DTe(r)){const e=r.assignedNodes();if(e!=null&&e.length)return e}return r.childNodes}function*LP(r){for(const e of poe(r))OTe(e)&&(yield e)}function Ey(r){var e;return((e=r.ownerDocument)==null?void 0:e.defaultView)??globalThis}function OTe(r){return r instanceof Ey(r).Element}function MTe(r){return r instanceof Ey(r).ShadowRoot}function jTe(r){return"getRootNode"in r&&MTe(r.getRootNode())}function DTe(r){return jTe(r)&&r instanceof Ey(r).HTMLSlotElement}function LTe(r){return r.style}function lA(r,e){return Ey(r).getComputedStyle(r,e)}const Kl={};class FTe{constructor(e){q(this,"styles",new Map);q(this,"fonts",new cA);this.root=e}readRootElementStyles(e){this.readElementStyles(e,{shouldRespectDefaults:!1,shouldSkipInheritedParentStyles:!1});const t=Array.from(LP(e));for(;t.length;){const n=t.pop();t.push(...LP(n)),this.readElementStyles(n,{shouldRespectDefaults:!0,shouldSkipInheritedParentStyles:!0})}}readElementStyles(e,{shouldRespectDefaults:t=!0,shouldSkipInheritedParentStyles:n=!0}){var a;const i=t?BTe(e.tagName.toLowerCase()):Kl,o=n?((a=this.styles.get(e.parentElement))==null?void 0:a.self)??Kl:Kl,s={self:NTe(e,{defaultStyles:i,parentStyles:o}),before:KZ(e,"::before"),after:KZ(e,"::after")};this.styles.set(e,s)}fetchResources(){const e=[];for(const t of this.styles.values())for(const n of Tn(t))if(n)for(const[i,o]of Object.entries(n)){if(!o)continue;i==="font-family"&&this.fonts.onFontFamilyValue(o);const s=_Te(o);s.length!==0&&e.push(...s.map(async({url:a,original:c})=>{const l=await wy(a)??"data:";n[i]=o.replace(c,`url("${l}")`)}))}return Promise.all(e)}unwrapCustomElements(){const e=new Set,t=(n,i)=>{if(e.has(n))return;e.add(n);const o=n.shadowRoot;if(o){const s=document.createElement("div");this.styles.set(s,this.styles.get(n)),s.setAttribute("data-tl-custom-element",n.tagName),(i??n.parentElement).appendChild(s);for(const a of o.childNodes)a instanceof Element?t(a,s):s.appendChild(a.cloneNode(!0));n.remove()}else if(i){if(n.tagName.toLowerCase()==="style")return;const s=n.cloneNode(!1);this.styles.set(s,this.styles.get(n)),i.appendChild(s);for(const a of poe(n))a instanceof Element?t(a,s):s.appendChild(a.cloneNode(!0))}};for(const n of this.styles.keys())t(n,null)}embedStyles(){let e="";for(const[t,n]of this.styles){if(n.after||n.before){const o=`pseudo-${Er()}`;t.classList.add(o),n.before&&(e+=`.${o}::before {${GZ(n.before)}}
106
- `),n.after&&(e+=`.${o}::after {${GZ(n.after)}}
107
- `)}const i=LTe(t);for(const[o,s]of Object.entries(n.self))s&&i.setProperty(o,s);i.fontKerning==="auto"&&(i.fontKerning="normal")}return e}async getFontFaceCss(){return await this.fonts.createCss()}dispose(){qTe()}}function NTe(r,{defaultStyles:e,parentStyles:t}){return r.computedStyleMap?goe(r.computedStyleMap(),{defaultStyles:e,parentStyles:t}):uA(lA(r),{defaultStyles:e,parentStyles:t})}function KZ(r,e){const t=lA(r,e),n=t.getPropertyValue("content");if(!(n===""||n==="none"))return uA(t,{defaultStyles:Kl,parentStyles:Kl})}function goe(r,{defaultStyles:e,parentStyles:t}){const n={};for(const i of r.keys()){if(!soe(i))continue;const o=r.get(i).toString();e[i]!==o&&(t[i]===o&&aoe(i)||(n[i]=o))}return n}function uA(r,{defaultStyles:e,parentStyles:t}){const n={};for(const i of r){if(!soe(i))continue;const o=r.getPropertyValue(i);e[i]!==o&&(t[i]===o&&aoe(i)||(n[i]=o))}return n}function GZ(r){let e="";for(const[t,n]of Object.entries(r))e+=`${t}: ${n};`;return e}let md;const VZ={};function $Te(){if(!md){const r=document.createElement("iframe");r.style.display="none",document.body.appendChild(r);const e=lo(r.contentDocument,"frame must have a document"),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),n=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");t.appendChild(n),e.body.appendChild(t),md={iframe:r,foreignObject:n,document:e}}return md}function qTe(){md&&(document.body.removeChild(md.iframe),md=void 0)}const YZ={defaultStyles:Kl,parentStyles:Kl};function BTe(r){let e=VZ[r];if(!e){const{foreignObject:t,document:n}=$Te(),i=n.createElement(r);t.appendChild(i),e=i.computedStyleMap?goe(i.computedStyleMap(),YZ):uA(lA(i),YZ),t.removeChild(i),VZ[r]=e}return e}function UTe(r,e){Array.from(r.attributes).forEach(n=>{e.setAttribute(n.name,n.value)})}function XZ(r,e){return r.replaceWith(e),e}async function lh(r,e){const t=document.createElement("img");e&&UTe(e,t),t.setAttribute("src",r??"data:"),t.setAttribute("decoding","sync"),t.setAttribute("loading","eager");try{await t.decode()}catch{}return t}async function zTe(r){try{const e=r.toDataURL();return await lh(e,r)}catch{return await lh(null,r)}}async function HTe(r){try{const e=await To.getVideoFrameAsDataUrl(r);return lh(e,r)}catch(e){console.error("Could not get video frame",e)}if(r.poster){const e=await wy(r.poster);return lh(e,r)}return lh(null,r)}async function voe(r){if(r instanceof HTMLCanvasElement)return XZ(r,await zTe(r));if(r instanceof HTMLVideoElement)return XZ(r,await HTe(r));if(r instanceof HTMLImageElement){const e=r.currentSrc||r.src,t=await wy(e);r.setAttribute("src",t??"data:"),r.setAttribute("decoding","sync"),r.setAttribute("loading","eager");try{await r.decode()}catch{}return r}else r instanceof HTMLInputElement?r.setAttribute("value",r.value):r instanceof HTMLTextAreaElement&&(r.textContent=r.value);await Promise.all(Array.from(LP(r),e=>voe(e)))}function Iy(r){const e=A.useRef();return A.useLayoutEffect(()=>{e.current=r}),A.useDebugValue(r),A.useCallback((...t)=>{const n=e.current;return Jt(n,"fn does not exist"),n(...t)},[])}const dA=A.createContext(null);function WTe({context:r,editor:e,children:t}){const n=e.options.exportProvider;return v.jsx(vT,{editor:e,children:v.jsx(qte,{container:e.getContainer(),children:v.jsx(dA.Provider,{value:r,children:v.jsx(n,{children:t})})})})}function op(){return A.useContext(dA)}function KTe(){const r=A.useContext(dA),[e]=A.useState(AC);return A.useEffect(()=>(r==null||r.waitUntil(e),()=>{e.resolve()}),[e,r]),Iy(()=>{e.resolve()})}var GTe=Object.create,moe=Object.defineProperty,VTe=Object.getOwnPropertyDescriptor,YTe=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),yoe=r=>{throw TypeError(r)},Soe=(r,e,t)=>e in r?moe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,XTe=r=>[,,,GTe(null)],xoe=["class","method","getter","setter","accessor","field","value","get","set"],_oe=r=>r!==void 0&&typeof r!="function"?yoe("Function expected"):r,ZTe=(r,e,t,n,i)=>({kind:xoe[r],name:e,metadata:n,addInitializer:o=>t._?yoe("Already initialized"):i.push(_oe(o||null))}),QTe=(r,e)=>Soe(e,YTe("metadata"),r[3]),JTe=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},eAe=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=xoe[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,VTe(i,t)),_=n.length-1;_>=0;_--)c=ZTe(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,_oe(s)&&(x[m]=s);return x&&moe(i,t,x),i},ZZ=(r,e,t)=>Soe(r,typeof e!="symbol"?e+"":e,t),woe,Py;woe=[po];class fA{constructor(e){this.maxDelayTimeMs=e,JTe(Py,5,this),ZZ(this,"isResolved",!1),ZZ(this,"promisesToWaitFor",[])}waitUntil(e){if(this.isResolved)throw new Error("Cannot `waitUntil` - the export has already been resolved. Make sure to call `waitUntil` as soon as possible during an export - ie within the first react effect after rendering.");this.promisesToWaitFor.push(e.catch(t=>console.error("Error whilst waiting for export:",t)))}async resolvePromises(){let e=null;for(;this.promisesToWaitFor.length!==e;)e=this.promisesToWaitFor.length,await Promise.allSettled(this.promisesToWaitFor),await gP(0)}async resolve(){const e=gP(this.maxDelayTimeMs).then(()=>"timeout"),t=this.resolvePromises().then(()=>"resolved");await Promise.race([e,t])==="timeout"&&console.warn("[tldraw] Export delay timed out after ${this.maxDelayTimeMs}ms"),this.isResolved=!0}}Py=XTe();eAe(Py,1,"waitUntil",woe,fA);QTe(Py,fA);function tAe(r,e,t={}){var _,w;if(!window.document)throw Error("No document");const{scale:n=1,background:i=r.getInstanceState().exportBackground,padding:o=r.options.defaultSvgPadding,preserveAspectRatio:s}=t,a=t.darkMode??r.user.getIsDarkMode(),c=r.getShapeAndDescendantIds(e),l=r.getUnorderedRenderingShapes(!1).filter(({id:I})=>c.has(I));let d=null;if(t.bounds)d=t.bounds;else for(const{id:I}of l){const b=r.getShapeMaskedPageBounds(I);b&&(d?d.union(b):d=b.clone())}if(!d)return;const f=e.length===1&&r.isShapeOfType(r.getShape(e[0]),"frame")?e[0]:null;f||d.expandBy(o);const h=d.width*n,g=d.height*n;try{(w=(_=document.body).focus)==null||w.call(_)}catch{}const m=new fA(r.options.maxExportDelayMs),y=AC();return m.waitUntil(y),{jsx:v.jsx(rAe,{editor:r,preserveAspectRatio:s,scale:n,pixelRatio:t.pixelRatio??null,bbox:d,background:i,singleFrameShapeId:f,isDarkMode:a,renderingShapes:l,onMount:y.resolve,waitUntil:m.waitUntil}),width:h,height:g,exportDelay:m}}function rAe({editor:r,preserveAspectRatio:e,scale:t,pixelRatio:n,bbox:i,background:o,singleFrameShapeId:s,isDarkMode:a,renderingShapes:c,onMount:l,waitUntil:d}){const f=Ld(),h=uc({isDarkMode:a}),g=QC("export state",{defsById:{},shapeElements:null}),{defsById:m,shapeElements:y}=ye(g),x=Iy(I=>{g.update(b=>{if(ss(b.defsById,I.key))return b;const P=Promise.resolve(I.getElement());return d(P.then(C=>{g.update(k=>({...k,defsById:{...k.defsById,[I.key]:{pending:!1,element:C}}}))})),{...b,defsById:{...b.defsById,[I.key]:{pending:!0,element:P}}}})}),_=A.useMemo(()=>({isDarkMode:a,waitUntil:d,addExportDef:x,scale:t,pixelRatio:n,async resolveAssetUrl(I,b){const P=r.getAsset(I);return!P||P.type!=="image"&&P.type!=="video"?null:await r.resolveAssetUrl(I,{screenScale:t*(b/P.props.w),shouldResolveToOriginal:n===null,dpr:n??void 0})}}),[a,d,x,t,n,r]),w=A.useRef(!1);return A.useLayoutEffect(()=>{if(w.current)throw new Error("SvgExport should only render once - do not use with react strict mode");w.current=!0,(async()=>{const I={},b=c.map(async({id:C,opacity:k,index:O,backgroundIndex:L})=>{var D,N;if(C===s)return[];const j=r.getShape(C);if(r.isShapeOfType(j,"group"))return[];const F=[],$=r.getShapeUtil(j);if($.toSvg||$.toBackgroundSvg){const[B,W]=await Promise.all([(D=$.toSvg)==null?void 0:D.call($,j,_),(N=$.toBackgroundSvg)==null?void 0:N.call($,j,_)]),G=r.getShapePageTransform(j);let z=G.toCssString(),V=1;"scale"in j.props&&j.props.scale!==1&&(V=j.props.scale,z=`${z} scale(${j.props.scale}, ${j.props.scale})`);const J=r.getShapeMask(j.id),K=J?Ke.From(Ke.Inverse(G)).applyToPoints(J):null,Z=pT(f,j.id);K&&(I[Z]={pending:!1,element:v.jsx("clipPath",{id:Z,children:v.jsx("path",{d:`M${K.map(({x:ee,y:re})=>`${ee/V},${re/V}`).join("L")}Z`})})}),B&&F.push({zIndex:O,element:v.jsx("g",{transform:z,opacity:k,clipPath:J?`url(#${Z})`:void 0,children:B},`fg_${j.id}`)}),W&&F.push({zIndex:L,element:v.jsx("g",{transform:z,opacity:k,clipPath:J?`url(#${Z})`:void 0,children:W},`bg_${j.id}`)})}else F.push({zIndex:O,element:v.jsx(QZ,{shape:j,util:$,component:ere,className:"tl-shape",bbox:i,opacity:k},`fg_${j.id}`)}),$.backgroundComponent&&F.push({zIndex:L,element:v.jsx(QZ,{shape:j,util:$,component:tre,className:"tl-shape tl-shape-background",bbox:i,opacity:k},`bg_${j.id}`)});return F}),P=(await Promise.all(b)).flat();Yd.flushSync(()=>{g.update(C=>({...C,shapeElements:P.sort((k,O)=>k.zIndex-O.zIndex).map(({element:k})=>k),defsById:{...C.defsById,...I}}))})})()},[i,r,_,f,c,s,g]),A.useEffect(()=>{y!==null&&l()},[l,y]),v.jsx(WTe,{editor:r,context:_,children:v.jsxs("svg",{preserveAspectRatio:e,direction:"ltr",width:i.width*t,height:i.height*t,viewBox:`${i.minX} ${i.minY} ${i.width} ${i.height}`,strokeLinecap:"round",strokeLinejoin:"round",style:{backgroundColor:o?s?h.solid:h.background:"transparent"},"data-color-mode":a?"dark":"light",className:`tl-container tl-theme__force-sRGB ${a?"tl-theme__dark":"tl-theme__light"}`,children:[v.jsx("defs",{children:Object.entries(m).map(([I,b])=>b.pending?null:v.jsx(A.Fragment,{children:b.element},I))}),y]})})}function QZ({shape:r,util:e,className:t,component:n,bbox:i,opacity:o}){const s=he(),a=Ke.Translate(-i.minX,-i.minY).multiply(s.getShapePageTransform(r.id)),c=s.getShapeGeometry(r.id).bounds,l=Math.max(c.width,1),d=Math.max(c.height,1);return v.jsx(hT,{fallback:()=>null,children:v.jsx("foreignObject",{x:i.minX,y:i.minY,width:i.w,height:i.h,className:"tl-shape-foreign-object",children:v.jsx("div",{className:t,"data-shape-type":r.type,style:{clipPath:s.getShapeClipPath(r.id),transform:a.toCssString(),width:l,height:d,opacity:o},children:v.jsx(n,{shape:r,util:e})})})})}let nAe=1;async function iAe(r,e,t={}){const n=tAe(r,e,t);if(!n)return;const i=r.getContainer(),o=document.createElement("div");o.className="tldraw-svg-export",o.inert=!0,o.tabIndex=-1,Object.assign(o.style,{position:"absolute",top:"0px",left:"0px",width:n.width+"px",height:n.height+"px",pointerEvents:"none",opacity:0}),i.appendChild(o);const s=DJ.createRoot(o,{identifierPrefix:`export_${nAe++}_`});try{await Promise.resolve(),Yd.flushSync(()=>{s.render(n.jsx)}),await n.exportDelay.resolve();const a=o.firstElementChild;return Jt(a instanceof SVGSVGElement,"Expected an SVG element"),await oAe(a),{svg:a,width:n.width,height:n.height}}finally{setTimeout(()=>{s.unmount(),i.removeChild(o)},0)}}async function oAe(r){const e=[...r.querySelectorAll("foreignObject.tl-shape-foreign-object > *")];if(!e.length)return;const t=new FTe(r);try{t.fonts.startFindingCurrentDocumentFontFaces(),await Promise.all(e.map(o=>voe(o)));for(const o of e)t.readRootElementStyles(o);await t.fetchResources();const n=await t.getFontFaceCss();t.unwrapCustomElements();const i=t.embedStyles();if(n||i){const o=document.createElementNS("http://www.w3.org/2000/svg","style");o.textContent=`${n}
108
- ${i}`,r.prepend(o)}}finally{t.dispose()}}let vI=null;function sAe(){return vI||(vI={maxWidth:mI("width"),maxHeight:mI("height"),maxArea:mI("area")}),vI}const JZ=8192,aAe=4096*4096,cAe={area:[16384,14188,11402,11180,10836,8192,4096],height:[8388607,65535,32767,16384,8192,4096],width:[4194303,65535,32767,16384,8192,4096]};function mI(r){const e=document.createElement("canvas");e.width=1,e.height=1;const t=e.getContext("2d");for(const n of cAe[r]){const i=r==="height"?1:n,o=r==="width"?1:n,s=document.createElement("canvas");s.width=i,s.height=o,s.getContext("2d").fillRect(i-1,o-1,1,1),t.drawImage(s,i-1,o-1,1,1,0,0,1,1);const c=t.getImageData(0,0,1,1).data[3]!==0;if(s.width=0,s.height=0,c)return e.width=0,e.height=0,r==="area"?n*n:n}throw e.width=0,e.height=0,Error("Failed to determine maximum canvas dimension")}function lAe(r,e){if(r<=JZ&&e<=JZ&&r*e<=aAe)return[r,e];const{maxWidth:t,maxHeight:n,maxArea:i}=sAe(),o=r/e;if(r>t&&(r=t,e=r/o),e>n&&(e=n,r=e*o),r*e>i){const s=Math.sqrt(i/(r*e));r*=s,e*=s}return[r,e]}async function uAe(r,e){const{type:t,width:n,height:i,quality:o=1,pixelRatio:s=2}=e;let[a,c]=lAe(n*s,i*s);a=Math.floor(a),c=Math.floor(c);const l=a/n,d=await ns.blobToDataUrl(new Blob([r],{type:"image/svg+xml"})),f=await new Promise(g=>{const m=vh();m.crossOrigin="anonymous",m.onload=async()=>{Pr.isSafari&&await gP(250);const y=document.createElement("canvas"),x=y.getContext("2d");y.width=a,y.height=c,x.imageSmoothingEnabled=!0,x.imageSmoothingQuality="high",x.drawImage(m,0,0,a,c),URL.revokeObjectURL(d),g(y)},m.onerror=()=>{g(null)},m.src=d});if(!f)return null;const h=await new Promise(g=>f.toBlob(m=>{(!m||yn.throwToBlob.get())&&g(null),g(m)},"image/"+t,o));if(!h)return null;if(t==="png"){const g=new DataView(await h.arrayBuffer());return sa.setPhysChunk(g,l,{type:"image/"+t})}else return h}const Is={menus:xn("open menus",[]),getOpenMenus(r){return r?this.menus.get().filter(e=>e.endsWith("-"+r)):this.menus.get()},addOpenMenu(r,e=""){const t=e?`${r}-${e}`:r,n=new Set(this.menus.get());n.has(t)||(n.add(t),this.menus.set([...n]))},deleteOpenMenu(r,e=""){const t=e?`${r}-${e}`:r,n=new Set(this.menus.get());n.has(t)&&(n.delete(t),this.menus.set([...n]))},clearOpenMenus(r){this.menus.set(r?this.menus.get().filter(e=>!e.endsWith("-"+r)):[])},_hiddenMenus:[],hideOpenMenus(r){if(this._hiddenMenus=[...this.getOpenMenus(r)],this._hiddenMenus.length!==0)for(const e of this._hiddenMenus)this.deleteOpenMenu(e,r)},showOpenMenus(r){if(this._hiddenMenus.length!==0){for(const e of this._hiddenMenus)this.addOpenMenu(e,r);this._hiddenMenus=[]}},isMenuOpen(r,e){return this.getOpenMenus(e).includes(r)},hasOpenMenus(r){return this.getOpenMenus(r).length>0},hasAnyOpenMenus(){return this.getOpenMenus().length>0},forContext(r){return{getOpenMenus:()=>this.getOpenMenus(r),addOpenMenu:e=>this.addOpenMenu(e,r),deleteOpenMenu:e=>this.deleteOpenMenu(e,r),clearOpenMenus:()=>this.clearOpenMenus(r),isMenuOpen:e=>this.isMenuOpen(e,r),hasOpenMenus:()=>this.hasOpenMenus(r),hasAnyOpenMenus:()=>this.hasAnyOpenMenus()}}},FP=new pve,dAe={maxShapesPerPage:4e3,maxFilesAtOnce:100,maxPages:40,animationMediumMs:320,followChaseViewportSnap:2,doubleClickDurationMs:450,multiClickDurationMs:200,coarseDragDistanceSquared:36,dragDistanceSquared:16,defaultSvgPadding:32,cameraSlideFriction:.09,gridSteps:[{min:-1,mid:.15,step:64},{min:.05,mid:.375,step:16},{min:.15,mid:1,step:4},{min:.7,mid:2.5,step:1}],collaboratorInactiveTimeoutMs:6e4,collaboratorIdleTimeoutMs:3e3,collaboratorCheckIntervalMs:1200,cameraMovingTimeoutMs:64,hitTestMargin:8,edgeScrollDelay:200,edgeScrollEaseDuration:200,edgeScrollSpeed:25,edgeScrollDistance:8,coarsePointerWidth:12,coarseHandleRadius:20,handleRadius:12,longPressDurationMs:500,textShadowLod:.35,adjacentShapeMargin:10,flattenImageBoundsExpand:64,flattenImageBoundsPadding:16,laserDelayMs:1200,maxExportDelayMs:5e3,temporaryAssetPreviewLifetimeMs:18e4,actionShortcutsLocation:"swap",createTextOnCanvasDoubleClick:!0,exportProvider:A.Fragment,enableToolbarKeyboardShortcuts:!0};function eQ(r,e){if(!e)return!1;switch(r.type){case"mixed":return e.type==="mixed";case"shared":return e.type==="shared"&&r.value===e.value;default:throw An(r)}}class fAe{constructor(e){q(this,"map");this.map=new Map(e)}get(e){return this.map.get(e)}getAsKnownValue(e){const t=this.get(e);if(t&&t.type!=="mixed")return t.value}get size(){return this.map.size}equals(e){if(this.size!==e.size)return!1;const t=new Set;for(const[n,i]of this){if(!eQ(i,e.get(n)))return!1;t.add(n)}for(const[n,i]of e)if(!t.has(n)&&!eQ(i,this.get(n)))return!1;return!0}keys(){return this.map.keys()}values(){return this.map.values()}entries(){return this.map.entries()}[Symbol.iterator](){return this.map[Symbol.iterator]()}}class NP extends fAe{set(e,t){this.map.set(e,t)}applyValue(e,t){const n=this.get(e);if(!n){this.set(e,{type:"shared",value:t});return}switch(n.type){case"mixed":return;case"shared":n.value!==t&&this.set(e,{type:"mixed"});return;default:An(n,"type")}}}function hAe(r,e,t){return pa(r).then(function(n){return n.arrayBuffer()}).then(function(n){return new File([n],e,{type:t})})}const pAe="https://cdn.tldraw.com";function Gc(){return`${pAe}/${Dte}`}function gAe(r){switch(r.type){case"shapes":return`s${r.shapeIds.map(t=>yI(t.slice(6))).join(".")}`;case"page":return"p"+yI(Fo.parseId(r.pageId));case"viewport":{const{bounds:e,pageId:t}=r;let n=`v${Math.round(e.x)}.${Math.round(e.y)}.${Math.round(e.w)}.${Math.round(e.h)}`;return t&&(n+="."+yI(Fo.parseId(t))),n}default:An(r)}}function vAe(r){switch(r[0]){case"s":return{type:"shapes",shapeIds:r.slice(1).split(".").filter(Boolean).map(n=>Tr(decodeURIComponent(n)))};case"p":return{type:"page",pageId:Fo.createId(decodeURIComponent(r.slice(1)))};case"v":{const[t,n,i,o,s]=r.slice(1).split(".");return{type:"viewport",bounds:new He(Number(t),Number(n),Number(i),Number(o)),pageId:s?Fo.createId(decodeURIComponent(s)):void 0}}default:throw Error("Invalid deep link string")}}function yI(r){return encodeURIComponent(r).replace(/\./g,"%2E")}function mAe(r,e){var i;let t=r;const n=new Set(e);for(;n.has(t);)t=(i=/^.*(\d+)$/.exec(t))!=null&&i[1]?t.replace(/(\d+)(?=\D?)$/,o=>(+o+1).toString()):`${t} 1`;return t}function Og(r,e,t,n){if(t.length===0)return[];const i=new Map;for(const s of Gt(t.map(a=>r.getShape(a)))){const{parentId:a}=s;i.has(a)||i.set(a,{children:Gt(r.getSortedChildIdsForParent(a).map(c=>r.getShape(c))),moving:new Set}),i.get(a).moving.add(s)}const o=[];switch(e){case"toBack":{i.forEach(({moving:s,children:a})=>yAe(s,a,o));break}case"toFront":{i.forEach(({moving:s,children:a})=>SAe(s,a,o));break}case"forward":{i.forEach(({moving:s,children:a})=>xAe(r,s,a,o,n));break}case"backward":{i.forEach(({moving:s,children:a})=>_Ae(r,s,a,o,n));break}}return o}function yAe(r,e,t){const n=e.length;if(r.size===n)return;let i,o;for(let s=0;s<n;s++){const a=e[s];if(r.has(a))i=a.index,r.delete(a);else{o=a.index;break}}if(r.size!==0){const s=wd(i,o,r.size);t.push(...Array.from(r.values()).sort(_i).map((a,c)=>({...a,index:s[c]})))}}function SAe(r,e,t){const n=e.length;if(r.size===n)return;let i,o;for(let s=n-1;s>-1;s--){const a=e[s];if(r.has(a))o=a.index,r.delete(a);else{i=a.index;break}}if(r.size!==0){const s=wd(i,o,r.size);t.push(...Array.from(r.values()).sort(_i).map((a,c)=>({...a,index:s[c]})))}}function tQ(r,e){const t=r.getShapeGeometry(e),n=r.getShapePageTransform(e);return!t||!n?null:n.applyToPoints(t.vertices)}function boe(r,e){const t=Array.from(e).map(i=>{const o=tQ(r,i);return o?{shape:i,vertices:o}:null}).filter(Boolean);return i=>{const o=tQ(r,i);return o?t.some(s=>aA(s.vertices,o)):!1}}function xAe(r,e,t,n,i){var c;const o=boe(r,e),s=t.length;if(e.size===s)return;let a={name:"skipping"};for(let l=0;l<s;l++){const d=e.has(t[l]);switch(a.name){case"skipping":{if(!d)continue;a={name:"selecting",selectIndex:l};break}case"selecting":{if(d||!(i!=null&&i.considerAllShapes)&&!o(t[l]))continue;const{selectIndex:f}=a;wd(t[l].index,(c=t[l+1])==null?void 0:c.index,l-f).forEach((h,g)=>{const m=t[f+g];e.has(m)&&n.push({...m,index:h})}),a={name:"skipping"};break}}}}function _Ae(r,e,t,n,i){var c;const o=boe(r,e),s=t.length;if(e.size===s)return;let a={name:"skipping"};for(let l=s-1;l>-1;l--){const d=e.has(t[l]);switch(a.name){case"skipping":{if(!d)continue;a={name:"selecting",selectIndex:l};break}case"selecting":{if(d||!(i!=null&&i.considerAllShapes)&&!o(t[l]))continue;wd((c=t[l-1])==null?void 0:c.index,t[l].index,a.selectIndex-l).forEach((f,h)=>{const g=t[l+h+1];e.has(g)&&n.push({...g,index:f})}),a={name:"skipping"};break}}}}function Eoe({editor:r,ids:e}){const t=Gt(e.map(s=>r.getShape(s))),n=r.getShapesSharedRotation(e),i=r.getShapesRotatedPageBounds(e);if(!i)return null;const o=i.center.clone().rotWith(i.point,n);return{pageCenter:o,initialCursorAngle:o.angle(r.inputs.originPagePoint),initialShapesRotation:n,shapeSnapshots:t.map(s=>({shape:s,initialPagePoint:r.getShapePageTransform(s.id).point()}))}}function lv({delta:r,editor:e,snapshot:t,stage:n,centerOverride:i}){const{pageCenter:o,shapeSnapshots:s}=t;e.updateShapes(s.map(({shape:c,initialPagePoint:l})=>{const d=co(c.parentId)?e.getShapePageTransform(c.parentId):Ke.Identity(),f=T.RotWith(l,i??o,r),h=Ke.applyToPoint(Ke.Inverse(d),f),g=Hl(c.rotation+r);return{id:c.id,type:c.type,x:h.x,y:h.y,rotation:g}}));const a=[];s.forEach(({shape:c})=>{var h,g,m;const l=e.getShape(c.id);if(!l)return;const d=e.getShapeUtil(c);if(n==="start"||n==="one-off"){const y=(h=d.onRotateStart)==null?void 0:h.call(d,c);y&&a.push(y)}const f=(g=d.onRotate)==null?void 0:g.call(d,c,l);if(f&&a.push(f),n==="end"||n==="one-off"){const y=(m=d.onRotateEnd)==null?void 0:m.call(d,c,l);y&&a.push(y)}}),a.length>0&&e.updateShapes(a)}const wAe=r=>{const{store:e}=r,t=e.query.filterHistory("binding"),n=e.query.records("binding");function i(){const o=n.get(),s=new Map;for(const a of o){const{fromId:c,toId:l}=a,d=s.get(c);d?d.push(a):s.set(c,[a]);const f=s.get(l);f?f.push(a):s.set(l,[a])}return s}return Te("arrowBindingsIndex",(o,s)=>{if(zl(o))return i();const a=o,c=t.getDiffSince(s);if(c===ko)return i();let l;function d(g){l??(l=new Map(a));const m=l.get(g.fromId),y=m==null?void 0:m.filter(w=>w.id!==g.id);y!=null&&y.length?l.set(g.fromId,y):l.delete(g.fromId);const x=l.get(g.toId),_=x==null?void 0:x.filter(w=>w.id!==g.id);_!=null&&_.length?l.set(g.toId,_):l.delete(g.toId)}function f(g){l??(l=new Map(a));let m=l.get(g);return m?m===a.get(g)&&(m=m.slice(0),l.set(g,m)):(m=[],l.set(g,m)),m}function h(g){f(g.fromId).push(g),f(g.toId).push(g)}for(const g of c){for(const m of Tn(g.added))h(m);for(const[m,y]of Tn(g.updated))d(m),h(y);for(const m of Tn(g.removed))d(m)}return l??a})};function bAe(r,e,t){const n=r.getShapeMaskedPageBounds(e);return n===void 0?!0:!t.includes(n)}const EAe=r=>{function e(t){const n=t.getCurrentPageShapeIds(),i=t.getViewportPageBounds(),o=new Set;return n.forEach(s=>{bAe(t,s,i)&&o.add(s)}),o}return Te("getCulledShapes",t=>{if(zl(t))return e(r);const n=e(r);if(t.size!==n.size)return n;for(const i of t)if(!n.has(i))return n;return t})},IAe=r=>{const e=r.query.ids("shape"),t=r.query.filterHistory("shape");function n(){const i={},o=e.get(),s=Array(o.size);return o.forEach(a=>s.push(r.get(a))),s.sort(_i),s.forEach(a=>{i[a.parentId]||(i[a.parentId]=[]),i[a.parentId].push(a.id)}),i}return Te("parentsToChildrenWithIndexes",(i,o)=>{if(zl(i))return n();const s=t.getDiffSince(o);if(s===ko)return n();if(s.length===0)return i;let a=null;const c=f=>{a||(a={...i}),a[f]?a[f]===i[f]&&(a[f]=[...a[f]]):a[f]=[]},l=new Set;let d;for(let f=0,h=s.length;f<h;f++){d=s[f];for(const g of Object.values(d.added))ud(g)&&(c(g.parentId),a[g.parentId].push(g.id),l.add(a[g.parentId]));for(const[g,m]of Object.values(d.updated))if(ud(m)&&ud(g)){if(g.parentId!==m.parentId)c(g.parentId),c(m.parentId),a[g.parentId].splice(a[g.parentId].indexOf(m.id),1),a[m.parentId].push(m.id),l.add(a[m.parentId]);else if(g.index!==m.index){c(m.parentId);const y=a[m.parentId].indexOf(m.id);a[m.parentId][y]=m.id,l.add(a[m.parentId])}}for(const g of Object.values(d.removed))ud(g)&&(c(g.parentId),a[g.parentId].splice(a[g.parentId].indexOf(g.id),1))}for(const f of l){const h=Gt(f.map(g=>r.get(g)));h.sort(_i),f.splice(0,f.length,...h.map(g=>g.id))}return a??i})},SI=(r,e,t)=>{for(;!oo(t.parentId);){const n=r.get(t.parentId);if(!n)return!1;t=n}return t.parentId===e},PAe=(r,e)=>{const t=r.query.ids("shape");let n=null;function i(){const o=e();return n=o,new Set([...t.get()].filter(s=>SI(r,o,r.get(s))))}return Te("_shapeIdsInCurrentPage",(o,s)=>{if(zl(o))return i();const a=e();if(a!==n)return i();const c=r.history.getDiffSince(s);if(c===ko)return i();const l=new ov(o);for(const f of c){for(const h of Object.values(f.added))ud(h)&&SI(r,a,h)&&l.add(h.id);for(const[h,g]of Object.values(f.updated))ud(g)&&(SI(r,a,g)?l.add(g.id):l.remove(g.id));for(const h of Object.keys(f.removed))co(h)&&l.remove(h)}const d=l.get();return d?Zf(d.value,d.diff):o})};var CAe=Object.create,Ioe=Object.defineProperty,TAe=Object.getOwnPropertyDescriptor,AAe=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),Poe=r=>{throw TypeError(r)},Coe=(r,e,t)=>e in r?Ioe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,RAe=r=>[,,,CAe(null)],Toe=["class","method","getter","setter","accessor","field","value","get","set"],Aoe=r=>r!==void 0&&typeof r!="function"?Poe("Function expected"):r,kAe=(r,e,t,n,i)=>({kind:Toe[r],name:e,metadata:n,addInitializer:o=>t._?Poe("Already initialized"):i.push(Aoe(o||null))}),OAe=(r,e)=>Coe(e,AAe("metadata"),r[3]),MAe=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},Roe=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=Toe[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,TAe(i,t)),_=n.length-1;_>=0;_--)c=kAe(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,Aoe(s)&&(x[m]=s);return x&&Ioe(i,t,x),i},ed=(r,e,t)=>Coe(r,typeof e!="symbol"?e+"":e,t),koe,Ooe,sp;const jAe=40;Ooe=[po],koe=[po];class Cy{constructor(e){this.editor=e,MAe(sp,5,this),ed(this,"_clickId",""),ed(this,"_clickTimeout"),ed(this,"_clickScreenPoint"),ed(this,"_previousScreenPoint"),ed(this,"_clickState","idle"),ed(this,"lastPointerInfo",{})}_getClickTimeout(e,t=Er()){this._clickId=t,clearTimeout(this._clickTimeout),this._clickTimeout=this.editor.timers.setTimeout(()=>{if(this._clickState===e&&this._clickId===t){switch(this._clickState){case"pendingTriple":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"double_click",phase:"settle"});break}case"pendingQuadruple":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"triple_click",phase:"settle"});break}case"pendingOverflow":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"quadruple_click",phase:"settle"});break}}this._clickState="idle"}},e==="idle"||e==="pendingDouble"?this.editor.options.doubleClickDurationMs:this.editor.options.multiClickDurationMs)}get clickState(){return this._clickState}handlePointerEvent(e){switch(e.name){case"pointer_down":{if(!this._clickState)return e;switch(this._clickScreenPoint=T.From(e.point),this._previousScreenPoint&&T.Dist2(this._previousScreenPoint,this._clickScreenPoint)>jAe**2&&(this._clickState="idle"),this._previousScreenPoint=this._clickScreenPoint,this.lastPointerInfo=e,this._clickState){case"pendingDouble":return this._clickState="pendingTriple",this._clickTimeout=this._getClickTimeout(this._clickState),{...e,type:"click",name:"double_click",phase:"down"};case"pendingTriple":return this._clickState="pendingQuadruple",this._clickTimeout=this._getClickTimeout(this._clickState),{...e,type:"click",name:"triple_click",phase:"down"};case"pendingQuadruple":return this._clickState="pendingOverflow",this._clickTimeout=this._getClickTimeout(this._clickState),{...e,type:"click",name:"quadruple_click",phase:"down"};case"idle":{this._clickState="pendingDouble";break}case"pendingOverflow":{this._clickState="overflow";break}}return this._clickTimeout=this._getClickTimeout(this._clickState),e}case"pointer_up":{if(!this._clickState)return e;switch(this._clickScreenPoint=T.From(e.point),this._clickState){case"pendingTriple":return{...this.lastPointerInfo,type:"click",name:"double_click",phase:"up"};case"pendingQuadruple":return{...this.lastPointerInfo,type:"click",name:"triple_click",phase:"up"};case"pendingOverflow":return{...this.lastPointerInfo,type:"click",name:"quadruple_click",phase:"up"}}return e}case"pointer_move":return this._clickState!=="idle"&&this._clickScreenPoint&&T.Dist2(this._clickScreenPoint,this.editor.inputs.currentScreenPoint)>(this.editor.getInstanceState().isCoarsePointer?this.editor.options.coarseDragDistanceSquared:this.editor.options.dragDistanceSquared)&&this.cancelDoubleClickTimeout(),e}return e}cancelDoubleClickTimeout(){this._clickTimeout=clearTimeout(this._clickTimeout),this._clickState="idle"}}sp=RAe();Roe(sp,1,"_getClickTimeout",Ooe,Cy);Roe(sp,1,"cancelDoubleClickTimeout",koe,Cy);OAe(sp,Cy);class DAe{constructor(e){q(this,"_isEdgeScrolling",!1);q(this,"_edgeScrollDuration",-1);this.editor=e}updateEdgeScrolling(e){const{editor:t}=this,n=this.getEdgeScroll();if(n.x===0&&n.y===0)this._isEdgeScrolling&&(this._isEdgeScrolling=!1,this._edgeScrollDuration=0);else if(this._isEdgeScrolling||(this._isEdgeScrolling=!0,this._edgeScrollDuration=0),this._edgeScrollDuration+=e,this._edgeScrollDuration>t.options.edgeScrollDelay){const i=t.options.edgeScrollEaseDuration>0?zn.easeInCubic(Math.min(1,this._edgeScrollDuration/(t.options.edgeScrollDelay+t.options.edgeScrollEaseDuration))):1;this.moveCameraWhenCloseToEdge({x:n.x*i,y:n.y*i})}}getEdgeProximityFactors(e,t,n,i,o){const{editor:s}=this,a=s.options.edgeScrollDistance,c=n?s.options.coarsePointerWidth:0,l=e-c,d=e+c,f=i?0:a,h=o?t:t-a;return l<f?Math.min(1,(f-l)/a):d>h?-Math.min(1,(d-h)/a):0}getEdgeScroll(){const{editor:e}=this,{inputs:{currentScreenPoint:{x:t,y:n}}}=e,i=e.getViewportScreenBounds(),{isCoarsePointer:o,insets:[s,a,c,l]}=e.getInstanceState(),d=this.getEdgeProximityFactors(t,i.w,o,l,a),f=this.getEdgeProximityFactors(n,i.h,o,s,c);return{x:d,y:f}}moveCameraWhenCloseToEdge(e){const{editor:t}=this;if(!t.inputs.isDragging||t.inputs.isPanning||t.getCameraOptions().isLocked||e.x===0&&e.y===0)return;const n=t.getViewportScreenBounds(),i=n.w<1e3?.612:1,o=n.h<1e3?.612:1,s=t.getZoomLevel(),a=t.user.getEdgeScrollSpeed()*t.options.edgeScrollSpeed,c=a*e.x*i/s,l=a*e.y*o/s,{x:d,y:f,z:h}=t.getCamera();t.setCamera(new T(d+c,f+l,h))}}class LAe{constructor(e,t){q(this,"disposeSideEffectListener");this.editor=e,this.disposeSideEffectListener=e.sideEffects.registerAfterChangeHandler("instance",(i,o)=>{i.isFocused!==o.isFocused&&this.updateContainerClass()});const n=e.getInstanceState().isFocused;t!==n&&e.updateInstanceState({isFocused:!!t}),this.updateContainerClass()}updateContainerClass(){const e=this.editor.getContainer();this.editor.getInstanceState().isFocused?e.classList.add("tl-container__focused"):e.classList.remove("tl-container__focused")}focus(){this.editor.getContainer().focus()}blur(){this.editor.complete(),this.editor.getContainer().blur()}dispose(){var e;(e=this.disposeSideEffectListener)==null||e.call(this)}}function zf(r){return NAe}class FAe{constructor(){q(this,"length",0);q(this,"head",null);q(this,"tail",this)}push(e){return new hA(e,this)}toArray(){return ec}[Symbol.iterator](){return{next(){return{value:void 0,done:!0}}}}}const NAe=new FAe;class hA{constructor(e,t){q(this,"length");this.head=e,this.tail=t,this.length=t.length+1}push(e){return new hA(e,this)}toArray(){return Array.from(this)}[Symbol.iterator](){let e=this;return{next(){if(e.length){const t=e.head;return e=e.tail,{value:t,done:!1}}else return{value:void 0,done:!0}}}}}class $Ae{constructor(e){q(this,"store");q(this,"dispose");q(this,"state","recording");q(this,"pendingDiff",new BAe);q(this,"stacks",xn("HistoryManager.stacks",{undos:zf(),redos:zf()},{isEqual:(e,t)=>e.undos===t.undos&&e.redos===t.redos}));q(this,"annotateError");q(this,"_isInBatch",!1);this.store=e.store,this.annotateError=e.annotateError??gh,this.dispose=this.store.addHistoryInterceptor((t,n)=>{if(n==="user")switch(this.state){case"recording":this.pendingDiff.apply(t.changes),this.stacks.update(({undos:i})=>({undos:i,redos:zf()}));break;case"recordingPreserveRedoStack":this.pendingDiff.apply(t.changes);break;case"paused":break;default:An(this.state)}})}flushPendingDiff(){if(this.pendingDiff.isEmpty())return;const e=this.pendingDiff.clear();this.stacks.update(({undos:t,redos:n})=>({undos:t.push({type:"diff",diff:e}),redos:n}))}getNumUndos(){return this.stacks.get().undos.length+(this.pendingDiff.isEmpty()?0:1)}getNumRedos(){return this.stacks.get().redos.length}batch(e,t){const n=this.state;n!=="paused"&&(t!=null&&t.history)&&(this.state=qAe[t.history]);try{if(this._isInBatch)return Ui(e),this;this._isInBatch=!0;try{Ui(e)}catch(i){throw this.annotateError(i),i}finally{this._isInBatch=!1}return this}finally{this.state=n}}_undo({pushToRedoStack:e,toMark:t=void 0}){var i;const n=this.state;this.state="paused";try{let{undos:o,redos:s}=this.stacks.get();const a=this.pendingDiff.clear(),c=Kee(a),l=IP(a);e&&!c&&(s=s.push({type:"diff",diff:a}));let d=!1;if(c)for(;((i=o.head)==null?void 0:i.type)==="stop";){const f=o.head;if(o=o.tail,e&&(s=s.push(f)),f.id===t){d=!0;break}}if(!d)e:for(;o.head;){const f=o.head;switch(o=o.tail,e&&(s=s.push(f)),f.type){case"diff":ah(l,[IP(f.diff)]);break;case"stop":if(!t)break e;if(f.id===t){d=!0;break e}break;default:An(f)}}if(!d&&t)return this;this.store.applyDiff(l,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:o,redos:s})}finally{this.state=n}return this}undo(){return this._undo({pushToRedoStack:!0}),this}redo(){var t;const e=this.state;this.state="paused";try{this.flushPendingDiff();let{undos:n,redos:i}=this.stacks.get();if(i.length===0)return this;for(;((t=i.head)==null?void 0:t.type)==="stop";)n=n.push(i.head),i=i.tail;const o=Hv();for(;i.head;){const s=i.head;if(n=n.push(s),i=i.tail,s.type==="diff")ah(o,[s.diff]);else break}this.store.applyDiff(o,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:n,redos:i})}finally{this.state=e}return this}bail(){return this._undo({pushToRedoStack:!1}),this}bailToMark(e){return this._undo({pushToRedoStack:!1,toMark:e}),this}squashToMark(e){var o;let t=this.stacks.get().undos;const n=[];for(;t.head&&!(t.head.type==="stop"&&t.head.id===e);)t.head.type==="diff"&&n.push(t.head.diff),t=t.tail;if(!t.head||((o=t.head)==null?void 0:o.id)!==e)return console.error("Could not find mark to squash to: ",e),this;if(n.length===0)return this;const i=Hv();return ah(i,n.reverse()),this.stacks.update(({redos:s})=>({undos:t.push({type:"diff",diff:i}),redos:s})),this}_mark(e){Ui(()=>{this.flushPendingDiff(),this.stacks.update(({undos:t,redos:n})=>({undos:t.push({type:"stop",id:e}),redos:n}))})}clear(){this.stacks.set({undos:zf(),redos:zf()}),this.pendingDiff.clear()}getMarkIdMatching(e){let t=this.stacks.get().undos;for(;t.head;){if(t.head.type==="stop"&&t.head.id.includes(e))return t.head.id;t=t.tail}return null}debug(){const{undos:e,redos:t}=this.stacks.get();return{undos:e.toArray(),redos:t.toArray(),pendingDiff:this.pendingDiff.debug(),state:this.state}}}const qAe={record:"recording","record-preserveRedoStack":"recordingPreserveRedoStack",ignore:"paused"};class BAe{constructor(){q(this,"diff",Hv());q(this,"isEmptyAtom",xn("PendingDiff.isEmpty",!0))}clear(){const e=this.diff;return this.diff=Hv(),this.isEmptyAtom.set(!0),e}isEmpty(){return this.isEmptyAtom.get()}apply(e){ah(this.diff,[e]),this.isEmptyAtom.set(Kee(this.diff))}debug(){return{diff:this.diff,isEmpty:this.isEmpty()}}}class UAe{constructor(e){q(this,"scribbleItems",new Map);q(this,"state","paused");this.editor=e}addScribble(e,t=Er()){const n={id:t,scribble:{id:t,size:20,color:"accent",opacity:.8,delay:0,points:[],shrink:.1,taper:!0,...e,state:"starting"},timeoutMs:0,delayRemaining:e.delay??0,prev:null,next:null};return this.scribbleItems.set(t,n),n}reset(){this.editor.updateInstanceState({scribbles:[]}),this.scribbleItems.clear()}stop(e){const t=this.scribbleItems.get(e);if(!t)throw Error(`Scribble with id ${e} not found`);return t.delayRemaining=Math.min(t.delayRemaining,200),t.scribble.state="stopping",t}addPoint(e,t,n,i=.5){const o=this.scribbleItems.get(e);if(!o)throw Error(`Scribble with id ${e} not found`);const{prev:s}=o,a={x:t,y:n,z:i};return(!s||T.Dist(s,a)>=1)&&(o.next=a),o}tick(e){this.scribbleItems.size!==0&&this.editor.run(()=>{this.scribbleItems.forEach(t=>{if(t.scribble.state==="starting"){const{next:c,prev:l}=t;c&&c!==l&&(t.prev=c,t.scribble.points.push(c)),t.scribble.points.length>8&&(t.scribble.state="active");return}t.delayRemaining>0&&(t.delayRemaining=Math.max(0,t.delayRemaining-e)),t.timeoutMs+=e,t.timeoutMs>=16&&(t.timeoutMs=0);const{delayRemaining:n,timeoutMs:i,prev:o,next:s,scribble:a}=t;switch(a.state){case"active":{s&&s!==o?(t.prev=s,a.points.push(s),n===0&&a.points.length>8&&a.points.shift()):i===0&&(a.points.length>1?a.points.shift():t.delayRemaining=a.delay);break}case"stopping":{if(t.delayRemaining===0&&i===0){if(a.points.length===1){this.scribbleItems.delete(t.id);return}a.shrink&&(a.size=Math.max(1,a.size*(1-a.shrink))),a.points.shift()}break}}}),this.editor.updateInstanceState({scribbles:Array.from(this.scribbleItems.values()).map(({scribble:t})=>({...t,points:[...t.points]})).slice(-5)})})}}var zAe=Object.create,Moe=Object.defineProperty,HAe=Object.getOwnPropertyDescriptor,WAe=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),joe=r=>{throw TypeError(r)},Doe=(r,e,t)=>e in r?Moe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,KAe=r=>[,,,zAe(null)],Loe=["class","method","getter","setter","accessor","field","value","get","set"],Foe=r=>r!==void 0&&typeof r!="function"?joe("Function expected"):r,GAe=(r,e,t,n,i)=>({kind:Loe[r],name:e,metadata:n,addInitializer:o=>t._?joe("Already initialized"):i.push(Foe(o||null))}),VAe=(r,e)=>Doe(e,WAe("metadata"),r[3]),YAe=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},Ty=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=Loe[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,HAe(i,t)),_=n.length-1;_>=0;_--)c=GAe(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,Foe(s)&&(x[m]=s);return x&&Moe(i,t,x),i},XAe=(r,e,t)=>Doe(r,e+"",t),Noe,$oe,qoe,Boe,_u;const Ot=r=>Math.round(r*10**8)/10**8;function Va(r,e,t,n,i){const o=r.filter(a=>(n==="forward"?a.startNode.id===e:a.endNode.id===e)&&Ot(a.length)===Ot(t)&&Es(a.breadthIntersection[0],a.breadthIntersection[1],i[0],i[1]));if(o.length===0)return[];const s=new Set;return o.forEach(a=>{const c=n==="forward"?a.endNode.id:a.startNode.id;if(!s.has(c)){s.add(c);const l=Va(r,c,t,n,Es(a.breadthIntersection[0],a.breadthIntersection[1],i[0],i[1]));o.push(...l)}}),o}function ZAe(r){r.sort((e,t)=>t.gaps.length-e.gaps.length);for(let e=r.length-1;e>0;e--){const t=r[e];for(let n=e-1;n>=0;n--){const i=r[n];if(i.direction===t.direction&&t.gaps.every(o=>i.gaps.some(s=>Ot(o.startEdge[0].x)===Ot(s.startEdge[0].x)&&Ot(o.startEdge[0].y)===Ot(s.startEdge[0].y)&&Ot(o.startEdge[1].x)===Ot(s.startEdge[1].x)&&Ot(o.startEdge[1].y)===Ot(s.startEdge[1].y))&&i.gaps.some(s=>Ot(o.endEdge[0].x)===Ot(s.endEdge[0].x)&&Ot(o.endEdge[0].y)===Ot(s.endEdge[0].y)&&Ot(o.endEdge[1].x)===Ot(s.endEdge[1].x)&&Ot(o.endEdge[1].y)===Ot(s.endEdge[1].y)))){r.splice(e,1);break}}}}Boe=[Te],qoe=[Te],$oe=[Te],Noe=[Te];class Xd{constructor(e){this.manager=e,YAe(_u,5,this),XAe(this,"editor"),this.editor=e.editor}getSnapPointsCache(){const{editor:e}=this;return e.store.createComputedCache("snapPoints",t=>{const n=e.getShapePageTransform(t.id);if(!n)return;const o=e.getShapeUtil(t).getBoundsSnapGeometry(t).points??e.getShapeGeometry(t).bounds.cornersAndCenter;if(!(!n||!o))return o.map((s,a)=>{const{x:c,y:l}=Ke.applyToPoint(n,s);return{x:c,y:l,id:`${t.id}:${a}`}})})}getSnapPoints(e){return this.getSnapPointsCache().get(e)??[]}getSnappablePoints(){const e=this.getSnapPointsCache(),t=this.manager.getSnappableShapes(),n=[];for(const i of t){const o=e.get(i);o&&n.push(...o)}return n}getSnappableGapNodes(){return Array.from(this.manager.getSnappableShapes(),e=>({id:e,pageBounds:lo(this.editor.getShapePageBounds(e))}))}getVisibleGaps(){const e=[],t=[];let n,i;const o=this.getSnappableGapNodes().sort((a,c)=>a.pageBounds.minX-c.pageBounds.minX);for(let a=0;a<o.length;a++){n=o[a];for(let c=a+1;c<o.length;c++)i=o[c],n.pageBounds.maxX<i.pageBounds.minX&&Ff(n.pageBounds.minY,n.pageBounds.maxY,i.pageBounds.minY,i.pageBounds.maxY)&&e.push({startNode:n,endNode:i,startEdge:[new T(n.pageBounds.maxX,n.pageBounds.minY),new T(n.pageBounds.maxX,n.pageBounds.maxY)],endEdge:[new T(i.pageBounds.minX,i.pageBounds.minY),new T(i.pageBounds.minX,i.pageBounds.maxY)],length:i.pageBounds.minX-n.pageBounds.maxX,breadthIntersection:Es(n.pageBounds.minY,n.pageBounds.maxY,i.pageBounds.minY,i.pageBounds.maxY)})}const s=o.sort((a,c)=>a.pageBounds.minY-c.pageBounds.minY);for(let a=0;a<s.length;a++){n=s[a];for(let c=a+1;c<s.length;c++)i=s[c],n.pageBounds.maxY<i.pageBounds.minY&&Ff(n.pageBounds.minX,n.pageBounds.maxX,i.pageBounds.minX,i.pageBounds.maxX)&&t.push({startNode:n,endNode:i,startEdge:[new T(n.pageBounds.minX,n.pageBounds.maxY),new T(n.pageBounds.maxX,n.pageBounds.maxY)],endEdge:[new T(i.pageBounds.minX,i.pageBounds.minY),new T(i.pageBounds.maxX,i.pageBounds.minY)],length:i.pageBounds.minY-n.pageBounds.maxY,breadthIntersection:Es(n.pageBounds.minX,n.pageBounds.maxX,i.pageBounds.minX,i.pageBounds.maxX)})}return{horizontal:e,vertical:t}}snapTranslateShapes({lockedAxis:e,initialSelectionPageBounds:t,initialSelectionSnapPoints:n,dragDelta:i}){var x,_;const o=this.manager.getSnapThreshold(),s=this.getSnappablePoints(),a=t.clone().translate(i),c=n.map(({x:w,y:I},b)=>({id:"selection:"+b,x:w+i.x,y:I+i.y})),l=s,d=[],f=[],h=new T(o,o);this.collectPointSnaps({minOffset:h,nearestSnapsX:d,nearestSnapsY:f,otherNodeSnapPoints:l,selectionSnapPoints:c}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:d,nearestSnapsY:f,minOffset:h});const g=new T(e==="x"?0:((x=d[0])==null?void 0:x.nudge)??0,e==="y"?0:((_=f[0])==null?void 0:_.nudge)??0);h.x=0,h.y=0,d.length=0,f.length=0,c.forEach(w=>{w.x+=g.x,w.y+=g.y}),a.translate(g),this.collectPointSnaps({minOffset:h,nearestSnapsX:d,nearestSnapsY:f,otherNodeSnapPoints:l,selectionSnapPoints:c}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:d,nearestSnapsY:f,minOffset:h});const m=this.getPointSnapLines({nearestSnapsX:d,nearestSnapsY:f}),y=this.getGapSnapLines({selectionPageBounds:a,nearestSnapsX:d,nearestSnapsY:f});return this.manager.setIndicators([...y,...m]),{nudge:g}}snapResizeShapes({initialSelectionPageBounds:e,dragDelta:t,handle:n,isAspectRatioLocked:i,isResizingFromCenter:o}){var k,O;const s=this.manager.getSnapThreshold(),{box:a,scaleX:c,scaleY:l}=He.Resize(e,n,o?t.x*2:t.x,o?t.y*2:t.y,i);let d=n;c<0&&(d=cxe(d)),l<0&&(d=axe(d)),o&&(a.center=e.center);const f=d==="top"||d==="bottom",h=d==="left"||d==="right",g=rQ(d,a),m=this.getSnappablePoints(),y=[],x=[],_=new T(s,s);this.collectPointSnaps({minOffset:_,nearestSnapsX:y,nearestSnapsY:x,otherNodeSnapPoints:m,selectionSnapPoints:g});const w=new T(f?0:((k=y[0])==null?void 0:k.nudge)??0,h?0:((O=x[0])==null?void 0:O.nudge)??0);if(i&&lxe(d)&&w.len()!==0){const L=y.length&&x.length?Math.abs(w.x)<Math.abs(w.y)?"x":"y":y.length?"x":"y",j=e.aspectRatio;L==="x"?(x.length=0,w.y=w.x/j,(d==="bottom_left"||d==="top_right")&&(w.y=-w.y)):(y.length=0,w.x=w.y*j,(d==="bottom_left"||d==="top_right")&&(w.x=-w.x))}const I=T.Add(t,w),{box:b}=He.Resize(e,n,o?I.x*2:I.x,o?I.y*2:I.y,i);o&&(b.center=e.center);const P=rQ("any",b);y.length=0,x.length=0,_.x=0,_.y=0,this.collectPointSnaps({minOffset:_,nearestSnapsX:y,nearestSnapsY:x,otherNodeSnapPoints:m,selectionSnapPoints:P});const C=this.getPointSnapLines({nearestSnapsX:y,nearestSnapsY:x});return this.manager.setIndicators([...C]),{nudge:w}}collectPointSnaps({selectionSnapPoints:e,otherNodeSnapPoints:t,minOffset:n,nearestSnapsX:i,nearestSnapsY:o}){for(const s of e)for(const a of t){const c=T.Sub(s,a),l=Math.abs(c.x),d=Math.abs(c.y);Ot(l)<=Ot(n.x)&&(Ot(l)<Ot(n.x)&&(i.length=0),i.push({type:"points",points:{thisPoint:s,otherPoint:a},nudge:a.x-s.x}),n.x=l),Ot(d)<=Ot(n.y)&&(Ot(d)<Ot(n.y)&&(o.length=0),o.push({type:"points",points:{thisPoint:s,otherPoint:a},nudge:a.y-s.y}),n.y=d)}}collectGapSnaps({selectionPageBounds:e,minOffset:t,nearestSnapsX:n,nearestSnapsY:i}){const{horizontal:o,vertical:s}=this.getVisibleGaps();for(const a of o){if(!Ff(a.breadthIntersection[0],a.breadthIntersection[1],e.minY,e.maxY))continue;const l=a.startEdge[0].x+a.length/2-e.center.x;if(a.length>e.width&&Ot(Math.abs(l))<=Ot(t.x)){Ot(Math.abs(l))<Ot(t.x)&&(n.length=0),t.x=Math.abs(l);const _={type:"gap_center",gap:a,nudge:l},w=n.find(({type:b})=>b==="gap_center"),I=w&&Es(a.breadthIntersection[0],a.breadthIntersection[1],w.gap.breadthIntersection[0],w.gap.breadthIntersection[1]);w&&w.gap.length>a.length&&I?n[n.indexOf(w)]=_:(!w||!I)&&n.push(_)}const f=a.startNode.pageBounds.minX-a.length,h=e.maxX,g=f-h;Ot(Math.abs(g))<=Ot(t.x)&&(Ot(Math.abs(g))<Ot(t.x)&&(n.length=0),t.x=Math.abs(g),n.push({type:"gap_duplicate",gap:a,protrusionDirection:"left",nudge:g}));const m=a.endNode.pageBounds.maxX+a.length,y=e.minX,x=m-y;Ot(Math.abs(x))<=Ot(t.x)&&(Ot(Math.abs(x))<Ot(t.x)&&(n.length=0),t.x=Math.abs(x),n.push({type:"gap_duplicate",gap:a,protrusionDirection:"right",nudge:x}))}for(const a of s){if(!Ff(a.breadthIntersection[0],a.breadthIntersection[1],e.minX,e.maxX))continue;const l=a.startEdge[0].y+a.length/2-e.center.y;if(a.length>e.height&&Ot(Math.abs(l))<=Ot(t.y)){Ot(Math.abs(l))<Ot(t.y)&&(i.length=0),t.y=Math.abs(l);const _={type:"gap_center",gap:a,nudge:l},w=i.find(({type:b})=>b==="gap_center"),I=w&&Ff(w.gap.breadthIntersection[0],w.gap.breadthIntersection[1],a.breadthIntersection[0],a.breadthIntersection[1]);w&&w.gap.length>a.length&&I?i[i.indexOf(w)]=_:(!w||!I)&&i.push(_);continue}const f=a.startNode.pageBounds.minY-a.length,h=e.maxY,g=f-h;Ot(Math.abs(g))<=Ot(t.y)&&(Ot(Math.abs(g))<Ot(t.y)&&(i.length=0),t.y=Math.abs(g),i.push({type:"gap_duplicate",gap:a,protrusionDirection:"top",nudge:g}));const m=a.endNode.pageBounds.maxY+a.length,y=e.minY,x=m-y;Ot(Math.abs(x))<=Ot(t.y)&&(Ot(Math.abs(x))<Ot(t.y)&&(i.length=0),t.y=Math.abs(x),i.push({type:"gap_duplicate",gap:a,protrusionDirection:"bottom",nudge:x}))}}getPointSnapLines({nearestSnapsX:e,nearestSnapsY:t}){const n={},i={};if(e.length>0){for(const o of e)if(o.type==="points"){const s=Ot(o.points.otherPoint.x);n[s]||(n[s]=[]),n[s].push(o.points)}}if(t.length>0){for(const o of t)if(o.type==="points"){const s=Ot(o.points.otherPoint.y);i[s]||(i[s]=[]),i[s].push(o.points)}}return Object.values(n).concat(Object.values(i)).map(o=>({id:Er(),type:"points",points:RC(o.map(s=>T.From(s.otherPoint)).concat(o.map(s=>T.From(s.thisPoint))),(s,a)=>s.equals(a))}))}getGapSnapLines({selectionPageBounds:e,nearestSnapsX:t,nearestSnapsY:n}){const{vertical:i,horizontal:o}=this.getVisibleGaps(),s={top:e.sides[0],right:e.sides[1],bottom:[e.corners[3],e.corners[2]],left:[e.corners[0],e.corners[3]]},a=[];if(t.length>0)for(const c of t){if(c.type==="points")continue;const{gap:{breadthIntersection:l,startEdge:d,startNode:f,endNode:h,length:g,endEdge:m}}=c;switch(c.type){case"gap_center":{const y=(g-e.width)/2,x=Es(l[0],l[1],e.minY,e.maxY);a.push({type:"gaps",direction:"horizontal",id:Er(),gaps:[...Va(o,f.id,y,"backward",x),{startEdge:d,endEdge:s.left},{startEdge:s.right,endEdge:m},...Va(o,h.id,y,"forward",x)]});break}case"gap_duplicate":{const y=Es(l[0],l[1],e.minY,e.maxY);a.push({type:"gaps",direction:"horizontal",id:Er(),gaps:c.protrusionDirection==="left"?[{startEdge:s.right,endEdge:d.map(x=>x.clone().addXY(-f.pageBounds.width,0))},{startEdge:d,endEdge:m},...Va(o,h.id,g,"forward",y)]:[...Va(o,f.id,g,"backward",y),{startEdge:d,endEdge:m},{startEdge:m.map(x=>x.clone().addXY(c.gap.endNode.pageBounds.width,0)),endEdge:s.left}]});break}}}if(n.length>0)for(const c of n){if(c.type==="points")continue;const{gap:{breadthIntersection:l,startEdge:d,startNode:f,endNode:h,length:g,endEdge:m}}=c;switch(c.type){case"gap_center":{const y=(g-e.height)/2,x=Es(l[0],l[1],e.minX,e.maxX);a.push({type:"gaps",direction:"vertical",id:Er(),gaps:[...Va(i,f.id,y,"backward",x),{startEdge:d,endEdge:s.top},{startEdge:s.bottom,endEdge:m},...Va(i,c.gap.endNode.id,y,"forward",x)]});break}case"gap_duplicate":{const y=Es(l[0],l[1],e.minX,e.maxX);a.push({type:"gaps",direction:"vertical",id:Er(),gaps:c.protrusionDirection==="top"?[{startEdge:s.bottom,endEdge:d.map(x=>x.clone().addXY(0,-f.pageBounds.height))},{startEdge:d,endEdge:m},...Va(i,h.id,g,"forward",y)]:[...Va(i,f.id,g,"backward",y),{startEdge:d,endEdge:m},{startEdge:m.map(x=>x.clone().addXY(0,h.pageBounds.height)),endEdge:s.top}]})}break}}return ZAe(a),a}}_u=KAe();Ty(_u,1,"getSnapPointsCache",Boe,Xd);Ty(_u,1,"getSnappablePoints",qoe,Xd);Ty(_u,1,"getSnappableGapNodes",$oe,Xd);Ty(_u,1,"getVisibleGaps",Noe,Xd);VAe(_u,Xd);function rQ(r,e){const{minX:t,maxX:n,minY:i,maxY:o}=e,s=[];switch(r){case"top":case"left":case"top_left":case"any":s.push({id:"top_left",handle:"top_left",x:t,y:i})}switch(r){case"top":case"right":case"top_right":case"any":s.push({id:"top_right",handle:"top_right",x:n,y:i})}switch(r){case"bottom":case"right":case"bottom_right":case"any":s.push({id:"bottom_right",handle:"bottom_right",x:n,y:o})}switch(r){case"bottom":case"left":case"bottom_left":case"any":s.push({id:"bottom_left",handle:"bottom_left",x:t,y:o})}return s}var QAe=Object.create,Uoe=Object.defineProperty,JAe=Object.getOwnPropertyDescriptor,eRe=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),zoe=r=>{throw TypeError(r)},Hoe=(r,e,t)=>e in r?Uoe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,tRe=r=>[,,,QAe(null)],Woe=["class","method","getter","setter","accessor","field","value","get","set"],Koe=r=>r!==void 0&&typeof r!="function"?zoe("Function expected"):r,rRe=(r,e,t,n,i)=>({kind:Woe[r],name:e,metadata:n,addInitializer:o=>t._?zoe("Already initialized"):i.push(Koe(o||null))}),nRe=(r,e)=>Hoe(e,eRe("metadata"),r[3]),iRe=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},oRe=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=Woe[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,JAe(i,t)),_=n.length-1;_>=0;_--)c=rRe(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,Koe(s)&&(x[m]=s);return x&&Uoe(i,t,x),i},sRe=(r,e,t)=>Hoe(r,e+"",t),Goe,Ay;const aRe=()=>null,cRe=()=>[];Goe=[Te];class pA{constructor(e){this.manager=e,iRe(Ay,5,this),sRe(this,"editor"),this.editor=e.editor}getSnapGeometryCache(){const{editor:e}=this;return e.store.createComputedCache("handle snap geometry",t=>{const n=e.getShapeUtil(t).getHandleSnapGeometry(t),i=n.getSelfSnapOutline?n.getSelfSnapOutline.bind(n):aRe,o=n.getSelfSnapPoints?n.getSelfSnapPoints.bind(n):cRe;return{outline:n.outline===void 0?e.getShapeGeometry(t):n.outline,points:n.points??[],getSelfSnapOutline:i,getSelfSnapPoints:o}})}*iterateSnapPointsInPageSpace(e,t){var i,o;const n=(i=this.getSnapGeometryCache().get(e))==null?void 0:i.getSelfSnapPoints(t);if(n&&n.length){const s=lo(this.editor.getShapePageTransform(e));for(const a of n)yield s.applyToPoint(a)}for(const s of this.manager.getSnappableShapes()){if(s===e)continue;const a=(o=this.getSnapGeometryCache().get(s))==null?void 0:o.points;if(!a||!a.length)continue;const c=lo(this.editor.getShapePageTransform(s));for(const l of a)yield c.applyToPoint(l)}}*iterateSnapOutlines(e,t){var i,o;const n=(i=this.getSnapGeometryCache().get(e))==null?void 0:i.getSelfSnapOutline(t);n&&(yield{shapeId:e,outline:n});for(const s of this.manager.getSnappableShapes()){if(s===e)continue;const a=(o=this.getSnapGeometryCache().get(s))==null?void 0:o.outline;a&&(yield{shapeId:s,outline:a})}}getHandleSnapPosition({currentShapeId:e,handle:t,handleInPageSpace:n}){const i=this.manager.getSnapThreshold();let o=i,s=null;for(const l of this.iterateSnapPointsInPageSpace(e,t))T.DistMin(n,l,o)&&(o=T.Dist(n,l),s=l);if(s)return s;let a=i,c=null;for(const{shapeId:l,outline:d}of this.iterateSnapOutlines(e,t)){const f=lo(this.editor.getShapePageTransform(l)),h=this.editor.getPointInShapeSpace(l,n),g=d.nearestPoint(h),m=f.applyToPoint(g);T.DistMin(n,m,a)&&(a=T.Dist(n,m),c=m)}return c||null}snapHandle({currentShapeId:e,handle:t}){const i=lo(this.editor.getShapePageTransform(e)).applyToPoint(t),o=this.getHandleSnapPosition({currentShapeId:e,handle:t,handleInPageSpace:i});return o?(this.manager.setIndicators([{id:Er(),type:"points",points:[o]}]),{nudge:T.Sub(o,i)}):null}}Ay=tRe();oRe(Ay,1,"getSnapGeometryCache",Goe,pA);nRe(Ay,pA);var lRe=Object.create,Voe=Object.defineProperty,uRe=Object.getOwnPropertyDescriptor,dRe=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),Yoe=r=>{throw TypeError(r)},Xoe=(r,e,t)=>e in r?Voe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,fRe=r=>[,,,lRe(null)],Zoe=["class","method","getter","setter","accessor","field","value","get","set"],Qoe=r=>r!==void 0&&typeof r!="function"?Yoe("Function expected"):r,hRe=(r,e,t,n,i)=>({kind:Zoe[r],name:e,metadata:n,addInitializer:o=>t._?Yoe("Already initialized"):i.push(Qoe(o||null))}),pRe=(r,e)=>Xoe(e,dRe("metadata"),r[3]),gRe=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},gA=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=Zoe[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,uRe(i,t)),_=n.length-1;_>=0;_--)c=hRe(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,Qoe(s)&&(x[m]=s);return x&&Voe(i,t,x),i},xI=(r,e,t)=>Xoe(r,typeof e!="symbol"?e+"":e,t),Joe,ese,tse,Zd;tse=[Te],ese=[Te],Joe=[Te];class ap{constructor(e){this.editor=e,gRe(Zd,5,this),xI(this,"shapeBounds"),xI(this,"handles"),xI(this,"_snapIndicators",xn("snapLines",void 0)),this.shapeBounds=new Xd(this),this.handles=new pA(this)}getIndicators(){return this._snapIndicators.get()??ec}clearIndicators(){this.getIndicators().length&&this._snapIndicators.set(void 0)}setIndicators(e){this._snapIndicators.set(e)}getSnapThreshold(){return 8/this.editor.getZoomLevel()}getSnappableShapes(){const{editor:e}=this,t=e.getViewportPageBounds(),n=e.getSelectedShapeIds(),i=new Set,o=s=>{if(co(s)){const c=e.getShape(s);c&&e.isShapeOfType(c,"frame")&&i.add(s)}const a=e.getSortedChildIdsForParent(s);for(const c of a){if(n.includes(c))continue;const l=e.getShape(c);if(!l||!e.getShapeUtil(l).canSnap(l))continue;const f=e.getShapePageBounds(c);if(f&&t.includes(f)){if(e.isShapeOfType(l,"group")){o(c);continue}i.add(c)}}};return o(this.getCurrentCommonAncestor()??e.getCurrentPageId()),i}getCurrentCommonAncestor(){return this.editor.findCommonAncestor(this.editor.getSelectedShapes())}}Zd=fRe();gA(Zd,1,"getSnapThreshold",tse,ap);gA(Zd,1,"getSnappableShapes",ese,ap);gA(Zd,1,"getCurrentCommonAncestor",Joe,ap);pRe(Zd,ap);const vRe=/\r?\n|\r/g;function nQ(r){return r.replace(vRe,`
109
- `).split(`
110
- `).map(e=>e||" ").join(`
111
- `)}const mRe={start:"left","start-legacy":"left",middle:"center","middle-legacy":"center",end:"right","end-legacy":"right"},yRe=/\s/;class SRe{constructor(e){q(this,"baseElem");this.editor=e,this.baseElem=document.createElement("div"),this.baseElem.classList.add("tl-text"),this.baseElem.classList.add("tl-text-measure"),this.baseElem.tabIndex=-1}measureText(e,t){const n=this.baseElem.cloneNode();this.editor.getContainer().appendChild(n),n.setAttribute("dir","auto"),n.style.setProperty("unicode-bidi","plaintext"),n.style.setProperty("font-family",t.fontFamily),n.style.setProperty("font-style",t.fontStyle),n.style.setProperty("font-weight",t.fontWeight),n.style.setProperty("font-size",t.fontSize+"px"),n.style.setProperty("line-height",t.lineHeight*t.fontSize+"px"),n.style.setProperty("max-width",t.maxWidth===null?null:t.maxWidth+"px"),n.style.setProperty("min-width",t.minWidth===null?null:t.minWidth+"px"),n.style.setProperty("padding",t.padding),n.style.setProperty("overflow-wrap",t.disableOverflowWrapBreaking?"normal":"break-word"),n.textContent=nQ(e);const i=n.scrollWidth,o=n.getBoundingClientRect();return n.remove(),{x:0,y:0,w:o.width,h:o.height,scrollWidth:i}}measureElementTextNodeSpans(e,{shouldTruncateToFirstLine:t=!1}={}){const n=[],i=e.getBoundingClientRect(),o=-i.left,s=-i.top,a=new Range,c=e.childNodes[0];let l=0,d=null,f=null,h=0,g=0,m=!1;for(const y of e.childNodes)if(y.nodeType===Node.TEXT_NODE)for(const x of y.textContent??""){a.setStart(c,l),a.setEnd(c,l+x.length);const _=a.getClientRects(),w=_[_.length-1],I=w.top+s,b=w.left+o,P=w.right+o,C=b<g,k=yRe.test(x);if(k!==f||I!==h||!d){if(d){if(t&&I!==h){m=!0;break}n.push(d)}d={box:{x:b,y:I,w:w.width,h:w.height},text:x},g=b}else C&&(d.box.x=b),d.box.w=C?d.box.w+w.width:P-d.box.x,d.text+=x;x===`
112
- `&&(g=0),f=k,h=I,l+=x.length}return d&&n.push(d),{spans:n,didTruncate:m}}measureTextSpans(e,t){if(e==="")return[];const n=this.baseElem.cloneNode();this.editor.getContainer().appendChild(n);const i=Math.ceil(t.width-t.padding*2);n.setAttribute("dir","auto"),n.style.setProperty("unicode-bidi","plaintext"),n.style.setProperty("width",`${i}px`),n.style.setProperty("height","min-content"),n.style.setProperty("font-size",`${t.fontSize}px`),n.style.setProperty("font-family",t.fontFamily),n.style.setProperty("font-weight",t.fontWeight),n.style.setProperty("line-height",`${t.lineHeight*t.fontSize}px`),n.style.setProperty("text-align",mRe[t.textAlign]),n.style.setProperty("font-style",t.fontStyle);const o=t.overflow==="truncate-ellipsis"||t.overflow==="truncate-clip";o&&(n.style.setProperty("overflow-wrap","anywhere"),n.style.setProperty("word-break","break-all"));const s=nQ(e);n.textContent=s;const{spans:a,didTruncate:c}=this.measureElementTextNodeSpans(n,{shouldTruncateToFirstLine:o});if(t.overflow==="truncate-ellipsis"&&c){n.textContent="…";const l=Math.ceil(this.measureElementTextNodeSpans(n).spans[0].box.w);n.style.setProperty("width",`${i-l}px`),n.textContent=s;const d=this.measureElementTextNodeSpans(n,{shouldTruncateToFirstLine:!0}).spans,f=d[d.length-1];return d.push({text:"…",box:{x:Math.min(f.box.x+f.box.w,t.width-t.padding-l),y:f.box.y,w:l,h:f.box.h}}),d}return n.remove(),a}}var xRe=Object.create,rse=Object.defineProperty,_Re=Object.getOwnPropertyDescriptor,wRe=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),nse=r=>{throw TypeError(r)},ise=(r,e,t)=>e in r?rse(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,bRe=r=>[,,,xRe(null)],ose=["class","method","getter","setter","accessor","field","value","get","set"],sse=r=>r!==void 0&&typeof r!="function"?nse("Function expected"):r,ERe=(r,e,t,n,i)=>({kind:ose[r],name:e,metadata:n,addInitializer:o=>t._?nse("Already initialized"):i.push(sse(o||null))}),IRe=(r,e)=>ise(e,wRe("metadata"),r[3]),PRe=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},ase=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=ose[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,_Re(i,t)),_=n.length-1;_>=0;_--)c=ERe(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,sse(s)&&(x[m]=s);return x&&rse(i,t,x),i},Mg=(r,e,t)=>ise(r,typeof e!="symbol"?e+"":e,t),cse,lse,cp;const iQ=aee;lse=[po],cse=[po];class Ry{constructor(e){this.editor=e,PRe(cp,5,this),Mg(this,"cancelRaf"),Mg(this,"isPaused",!0),Mg(this,"now",0),Mg(this,"prevPoint",new T),this.editor.disposables.add(this.dispose),this.start()}start(){var e;this.isPaused=!1,(e=this.cancelRaf)==null||e.call(this),this.cancelRaf=iQ(this.tick),this.now=Date.now()}tick(){if(this.isPaused)return;const e=Date.now(),t=e-this.now;this.now=e,this.updatePointerVelocity(t),this.editor.emit("frame",t),this.editor.emit("tick",t),this.cancelRaf=iQ(this.tick)}dispose(){var e;this.isPaused=!0,(e=this.cancelRaf)==null||e.call(this)}updatePointerVelocity(e){const{prevPoint:t,editor:{inputs:{currentScreenPoint:n,pointerVelocity:i}}}=this;if(e===0)return;const o=T.Sub(n,t);this.prevPoint=n.clone();const s=o.len(),a=s?o.div(s):new T(0,0),c=i.clone().lrp(a.mul(s/e),.5);Math.abs(c.x)<.01&&(c.x=0),Math.abs(c.y)<.01&&(c.y=0),i.equals(c)||(this.editor.inputs.pointerVelocity=c)}}cp=bRe();ase(cp,1,"tick",lse,Ry);ase(cp,1,"dispose",cse,Ry);IRe(cp,Ry);var CRe=Object.create,use=Object.defineProperty,TRe=Object.getOwnPropertyDescriptor,ARe=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),dse=r=>{throw TypeError(r)},fse=(r,e,t)=>e in r?use(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,RRe=r=>[,,,CRe(null)],hse=["class","method","getter","setter","accessor","field","value","get","set"],pse=r=>r!==void 0&&typeof r!="function"?dse("Function expected"):r,kRe=(r,e,t,n,i)=>({kind:hse[r],name:e,metadata:n,addInitializer:o=>t._?dse("Already initialized"):i.push(pse(o||null))}),ORe=(r,e)=>fse(e,ARe("metadata"),r[3]),MRe=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},ds=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=hse[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,TRe(i,t)),_=n.length-1;_>=0;_--)c=kRe(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,pse(s)&&(x[m]=s);return x&&use(i,t,x),i},oQ=(r,e,t)=>fse(r,typeof e!="symbol"?e+"":e,t),gse,vse,mse,yse,Sse,xse,_se,wse,bse,Ese,Ise,Pse,Ki;Pse=[Te],Ise=[Te],Ese=[Te],bse=[Te],wse=[Te],_se=[Te],xse=[Te],Sse=[Te],yse=[Te],mse=[Te],vse=[Te],gse=[Te];class So{constructor(e,t){if(this.user=e,this.inferDarkMode=t,MRe(Ki,5,this),oQ(this,"systemColorScheme",xn("systemColorScheme","light")),oQ(this,"disposables",new Set),typeof window>"u"||!("matchMedia"in window))return;const n=window.matchMedia("(prefers-color-scheme: dark)");n!=null&&n.matches&&this.systemColorScheme.set("dark");const i=o=>{o.matches?this.systemColorScheme.set("dark"):this.systemColorScheme.set("light")};n==null||n.addEventListener("change",i),this.disposables.add(()=>n==null?void 0:n.removeEventListener("change",i))}dispose(){this.disposables.forEach(e=>e())}updateUserPreferences(e){this.user.setUserPreferences({...this.user.userPreferences.get(),...e})}getUserPreferences(){return{id:this.getId(),name:this.getName(),locale:this.getLocale(),color:this.getColor(),animationSpeed:this.getAnimationSpeed(),isSnapMode:this.getIsSnapMode(),colorScheme:this.user.userPreferences.get().colorScheme,isDarkMode:this.getIsDarkMode(),isWrapMode:this.getIsWrapMode(),isDynamicResizeMode:this.getIsDynamicResizeMode()}}getIsDarkMode(){switch(this.user.userPreferences.get().colorScheme){case"dark":return!0;case"light":return!1;case"system":return this.systemColorScheme.get()==="dark";default:return this.inferDarkMode?this.systemColorScheme.get()==="dark":!1}}getEdgeScrollSpeed(){return this.user.userPreferences.get().edgeScrollSpeed??ia.edgeScrollSpeed}getAnimationSpeed(){return this.user.userPreferences.get().animationSpeed??ia.animationSpeed}getId(){return this.user.userPreferences.get().id}getName(){return this.user.userPreferences.get().name??ia.name}getLocale(){return this.user.userPreferences.get().locale??ia.locale}getColor(){return this.user.userPreferences.get().color??ia.color}getIsSnapMode(){return this.user.userPreferences.get().isSnapMode??ia.isSnapMode}getIsWrapMode(){return this.user.userPreferences.get().isWrapMode??ia.isWrapMode}getIsDynamicResizeMode(){return this.user.userPreferences.get().isDynamicSizeMode??ia.isDynamicSizeMode}getIsPasteAtCursorMode(){return this.user.userPreferences.get().isPasteAtCursorMode??ia.isPasteAtCursorMode}}Ki=RRe();ds(Ki,1,"getUserPreferences",Pse,So);ds(Ki,1,"getIsDarkMode",Ise,So);ds(Ki,1,"getEdgeScrollSpeed",Ese,So);ds(Ki,1,"getAnimationSpeed",bse,So);ds(Ki,1,"getId",wse,So);ds(Ki,1,"getName",_se,So);ds(Ki,1,"getLocale",xse,So);ds(Ki,1,"getColor",Sse,So);ds(Ki,1,"getIsSnapMode",yse,So);ds(Ki,1,"getIsWrapMode",mse,So);ds(Ki,1,"getIsDynamicResizeMode",vse,So);ds(Ki,1,"getIsPasteAtCursorMode",gse,So);ORe(Ki,So);const jRe={wheel:"onWheel",pointer_down:"onPointerDown",pointer_move:"onPointerMove",long_press:"onLongPress",pointer_up:"onPointerUp",right_click:"onRightClick",middle_click:"onMiddleClick",key_down:"onKeyDown",key_up:"onKeyUp",key_repeat:"onKeyRepeat",cancel:"onCancel",complete:"onComplete",interrupt:"onInterrupt",double_click:"onDoubleClick",triple_click:"onTripleClick",quadruple_click:"onQuadrupleClick",tick:"onTick"},DRe=["brushing","cropping","dragging","dragging_handle","drawing","erasing","lasering","resizing","rotating","scribble_brushing","translating"];class vt{constructor(e,t){q(this,"performanceTracker");q(this,"id");q(this,"type");q(this,"shapeType");q(this,"initial");q(this,"children");q(this,"isLockable");q(this,"parent");q(this,"_path");q(this,"_current");q(this,"_isActive");q(this,"_currentToolIdMask",xn("curent tool id mask",void 0));this.editor=e;const{id:n,children:i,initial:o,isLockable:s}=this.constructor;this.id=n,this._isActive=xn("toolIsActive"+this.id,!1),this._current=xn("toolState"+this.id,void 0),this._path=Te("toolPath"+this.id,()=>{const a=this.getCurrent();return this.id+(a?`.${a.getPath()}`:"")}),this.parent=t??{},this.parent?i&&o?(this.type="branch",this.initial=o,this.children=Object.fromEntries(i().map(a=>[a.id,new a(this.editor,this)])),this._current.set(this.children[this.initial])):this.type="leaf":(this.type="root",i&&o&&(this.initial=o,this.children=Object.fromEntries(i().map(a=>[a.id,new a(this.editor,this)])),this._current.set(this.children[this.initial]))),this.isLockable=s,this.performanceTracker=new NJ}getPath(){return this._path.get()}getCurrent(){return this._current.get()}getIsActive(){return this._isActive.get()}transition(e,t={}){var o;const n=e.split(".");let i=this;for(let s=0;s<n.length;s++){const a=n[s],c=i.getCurrent(),l=(o=i.children)==null?void 0:o[a];if(!l)throw Error(`${i.id} - no child state exists with the id ${a}.`);if((c==null?void 0:c.id)!==l.id&&(c==null||c.exit(t,a),i._current.set(l),l.enter(t,(c==null?void 0:c.id)||"initial"),!l.getIsActive()))break;i=l}return this}handleEvent(e){var i;const t=jRe[e.name],n=this._current.__unsafe__getWithoutCapture();(i=this[t])==null||i.call(this,e),this._isActive.__unsafe__getWithoutCapture()&&n&&n===this._current.__unsafe__getWithoutCapture()&&n.handleEvent(e)}enter(e,t){var n;if(yn.measurePerformance.get()&&DRe.includes(this.id)&&this.performanceTracker.start(this.id),this._isActive.set(!0),(n=this.onEnter)==null||n.call(this,e,t),this.children&&this.initial&&this.getIsActive()){const i=this.children[this.initial];this._current.set(i),i.enter(e,t)}}exit(e,t){var n,i;yn.measurePerformance.get()&&this.performanceTracker.isStarted()&&this.performanceTracker.stop(),this._isActive.set(!1),(n=this.onExit)==null||n.call(this,e,t),this.getIsActive()||(i=this.getCurrent())==null||i.exit(e,t)}getCurrentToolIdMask(){return this._currentToolIdMask.get()}setCurrentToolIdMask(e){this._currentToolIdMask.set(e)}}q(vt,"id"),q(vt,"initial"),q(vt,"children"),q(vt,"isLockable",!0);class $P extends vt{static children(){return[]}onKeyDown(e){var t;switch(e.code){case"KeyZ":{if(!(e.shiftKey||e.ctrlKey)){const n=this.getCurrent();n&&((t=n.getCurrent())==null?void 0:t.id)==="idle"&&this.children.zoom&&this.editor.setCurrentTool("zoom",{...e,onInteractionEnd:n.id})}break}}}}q($P,"id","root"),q($P,"initial","");var LRe=Object.create,Cse=Object.defineProperty,FRe=Object.getOwnPropertyDescriptor,Tse=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),Ase=r=>{throw TypeError(r)},Rse=(r,e,t)=>e in r?Cse(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,NRe=r=>[,,,LRe((r==null?void 0:r[Tse("metadata")])??null)],kse=["class","method","getter","setter","accessor","field","value","get","set"],Ose=r=>r!==void 0&&typeof r!="function"?Ase("Function expected"):r,$Re=(r,e,t,n,i)=>({kind:kse[r],name:e,metadata:n,addInitializer:o=>t._?Ase("Already initialized"):i.push(Ose(o||null))}),qRe=(r,e)=>Rse(e,Tse("metadata"),r[3]),BRe=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},ot=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=kse[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,FRe(i,t)),_=n.length-1;_>=0;_--)c=$Re(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,Ose(s)&&(x[m]=s);return x&&Cse(i,t,x),i},Ct=(r,e,t)=>Rse(r,typeof e!="symbol"?e+"":e,t),Mse,jse,Dse,Lse,Fse,Nse,$se,qse,Bse,Use,zse,Hse,Wse,Kse,Gse,Vse,Yse,Xse,Zse,Qse,Jse,eae,tae,rae,nae,iae,oae,sae,aae,cae,lae,uae,dae,fae,hae,pae,gae,vae,mae,yae,Sae,xae,_ae,wae,bae,Eae,Iae,Pae,Cae,Tae,Aae,Rae,kae,Oae,Mae,jae,Dae,Lae,Fae,Nae,$ae,qae,Bae,Uae,zae,Hae,Wae,Kae,Gae,Vae,Yae,qP,nt;class rt extends(qP=nTe,Yae=[Te],Vae=[Te],Gae=[Te],Kae=[Te],Wae=[Te],Hae=[Te],zae=[Te],Uae=[Te],Bae=[Te],qae=[Te],$ae=[Te],Nae=[Te],Fae=[Te],Lae=[Te],Dae=[Te],jae=[Te],Mae=[Te],Oae=[Te],kae=[Te],Rae=[Te],Aae=[Te],Tae=[Te],Cae=[Te],Pae=[Te],Iae=[Te],Eae=[Te],bae=[Te],wae=[Te],_ae=[Te],xae=[Te],Sae=[Te],yae=[Te],mae=[Te],vae=[Te],gae=[Te],pae=[Te],hae=[Te],fae=[Te],dae=[Te],uae=[Te],lae=[Te],cae=[Te],aae=[Te],sae=[Te],oae=[Te],iae=[Te],nae=[Te],rae=[Te],tae=[Te],eae=[Te],Jse=[Te],Qse=[Te],Zse=[Te],Xse=[Te],Yse=[Te],Vse=[Te],Gse=[Te],Kse=[Te],Wse=[Te],Hse=[Te],zse=[Te],Use=[Te],Bse=[Te],qse=[Te({isEqual:(e,t)=>e.equals(t)})],$se=[Te],Nse=[Te],Fse=[Te],Lse=[po],Dse=[po],jse=[po],Mse=[po],qP){constructor({store:e,user:t,shapeUtils:n,bindingUtils:i,tools:o,getContainer:s,cameraOptions:a,initialState:c,autoFocus:l,inferDarkMode:d,options:f,isShapeHidden:h}){var L;super(),BRe(nt,5,this),Ct(this,"_isShapeHiddenPredicate"),Ct(this,"options"),Ct(this,"contextId",Er()),Ct(this,"store"),Ct(this,"root"),Ct(this,"disposables",new Set),Ct(this,"isDisposed",!1),Ct(this,"_tickManager"),Ct(this,"snaps"),Ct(this,"timers",FP.forContext(this.contextId)),Ct(this,"user"),Ct(this,"textMeasure"),Ct(this,"environment",Pr),Ct(this,"scribbles"),Ct(this,"sideEffects"),Ct(this,"edgeScrollManager"),Ct(this,"focusManager"),Ct(this,"getContainer"),Ct(this,"shapeUtils"),Ct(this,"styleProps"),Ct(this,"bindingUtils"),Ct(this,"history"),Ct(this,"_shouldIgnoreShapeLock",!1),Ct(this,"_crashingError",null),Ct(this,"_isChangingStyleTimeout",-1),Ct(this,"menus",Is.forContext(this.contextId)),Ct(this,"_cameraOptions",xn("camera options",tD)),Ct(this,"_viewportAnimation",null),Ct(this,"_willSetInitialBounds",!0),Ct(this,"_isLockedOnFollowingUser",xn("isLockedOnFollowingUser",!1)),Ct(this,"_cameraState",xn("camera state","idle")),Ct(this,"_cameraStateTimeoutRemaining",0),Ct(this,"_currentPageShapeIds"),Ct(this,"_shapeGeometryCaches",{}),Ct(this,"_parentIdsToChildIds"),Ct(this,"animatingShapes",new Map),Ct(this,"externalAssetContentHandlers",{file:null,url:null}),Ct(this,"temporaryAssetPreview",new Map),Ct(this,"externalContentHandlers",{text:null,files:null,embed:null,"svg-text":null,url:null,tldraw:null,excalidraw:null}),Ct(this,"inputs",{originPagePoint:new T,originScreenPoint:new T,previousPagePoint:new T,previousScreenPoint:new T,currentPagePoint:new T,currentScreenPoint:new T,keys:new Set,buttons:new Set,isPen:!1,shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1,isDragging:!1,isPointing:!1,isPinching:!1,isEditing:!1,isPanning:!1,isSpacebarPanning:!1,pointerVelocity:new T}),Ct(this,"_clickManager",new Cy(this)),Ct(this,"_prevCursor","default"),Ct(this,"_shiftKeyTimeout",-1),Ct(this,"_altKeyTimeout",-1),Ct(this,"_ctrlKeyTimeout",-1),Ct(this,"_metaKeyTimeout",-1),Ct(this,"_restoreToolId","select"),Ct(this,"_pinchStart",1),Ct(this,"_didPinch",!1),Ct(this,"_selectedShapeIdsAtPointerDown",[]),Ct(this,"_longPressTimeout",-1),Ct(this,"capturedPointerId",null),Ct(this,"performanceTracker"),Ct(this,"performanceTrackerTimeout",-1),Ct(this,"_pendingEventsForNextTick",[]),this._isShapeHiddenPredicate=h,this.options={...dAe,...f},this.store=e,this.disposables.add(this.store.dispose.bind(this.store)),this.history=new $Ae({store:e,annotateError:j=>{this.annotateError(j,{origin:"history.batch",willCrashApp:!0}),this.crash(j)}}),this.snaps=new ap(this),this.disposables.add(this.timers.dispose),this._cameraOptions.set({...tD,...a}),this.user=new So(t??vre(),d??!1),this.disposables.add(()=>this.user.dispose()),this.getContainer=s,this.textMeasure=new SRe(this),this._tickManager=new Ry(this);class g extends $P{}q(g,"initial",c??""),this.root=new g(this),this.root.children={};const m=roe(n),y={},x={},_=new Map;for(const j of m){const F=new j(this);y[j.type]=F;const $=Qee(j.props??{});x[j.type]=$;for(const D of $.keys())if(!_.has(D.id))_.set(D.id,D);else if(_.get(D.id)!==D)throw Error(`Multiple style props with id "${D.id}" in use. Style prop IDs must be unique.`)}this.shapeUtils=y,this.styleProps=x;const w=eoe(i),I={};for(const j of w){const F=new j(this);I[j.type]=F}this.bindingUtils=I;for(const j of[...o]){if(ss(this.root.children,j.id))throw Error(`Can't override tool with id "${j.id}"`);this.root.children[j.id]=new j(this,this.root)}this.scribbles=new UAe(this);const b=(j,F)=>{let $=null;const D=j.selectedShapeIds.filter(W=>!F.has(W));D.length!==j.selectedShapeIds.length&&($||($={...j}),$.selectedShapeIds=D);const N=j.erasingShapeIds.filter(W=>!F.has(W));N.length!==j.erasingShapeIds.length&&($||($={...j}),$.erasingShapeIds=N),j.hoveredShapeId&&F.has(j.hoveredShapeId)&&($||($={...j}),$.hoveredShapeId=null),j.editingShapeId&&F.has(j.editingShapeId)&&($||($={...j}),$.editingShapeId=null);const B=j.hintingShapeIds.filter(W=>!F.has(W));return B.length!==j.hintingShapeIds.length&&($||($={...j}),$.hintingShapeIds=B),j.focusedGroupId&&F.has(j.focusedGroupId)&&($||($={...j}),$.focusedGroupId=null),$};this.sideEffects=this.store.sideEffects;let P=new Map;const C=new Set,k=new Set;let O=new Set;if(this.disposables.add(this.sideEffects.registerOperationCompleteHandler(()=>{var j,F,$,D;C.clear();for(const N of k){k.delete(N);const B=this.getShape(N);if(!B)continue;const W=this.getShapeUtil(B),G=(j=W.onChildrenChange)==null?void 0:j.call(W,B);G!=null&&G.length&&this.updateShapes(G)}if(O.size){const N=O;O=new Set;for(const B of N){const W=this.getBindingUtil(B);(F=W.onOperationComplete)==null||F.call(W)}}if(P.size){const N=P;P=new Map;for(const B of N.values())(D=($=this.getBindingUtil(B.binding)).onAfterDelete)==null||D.call($,B)}this.emit("update")})),this.disposables.add(this.sideEffects.register({shape:{afterChange:(j,F)=>{var $,D,N,B;for(const W of this.getBindingsInvolvingShape(F))O.add(W.type),W.fromId===F.id&&((D=($=this.getBindingUtil(W)).onAfterChangeFromShape)==null||D.call($,{binding:W,shapeBefore:j,shapeAfter:F})),W.toId===F.id&&((B=(N=this.getBindingUtil(W)).onAfterChangeToShape)==null||B.call(N,{binding:W,shapeBefore:j,shapeAfter:F}));if(j.parentId!==F.parentId){const W=G=>{var V,J,K,Z;const z=this.getShape(G);if(z)for(const ee of this.getBindingsInvolvingShape(z))O.add(ee.type),ee.fromId===z.id&&((J=(V=this.getBindingUtil(ee)).onAfterChangeFromShape)==null||J.call(V,{binding:ee,shapeBefore:z,shapeAfter:z})),ee.toId===z.id&&((Z=(K=this.getBindingUtil(ee)).onAfterChangeToShape)==null||Z.call(K,{binding:ee,shapeBefore:z,shapeAfter:z}))};W(F.id),this.visitDescendants(F.id,W)}if(j.parentId!==F.parentId&&oo(F.parentId)){const W=new Set([j.id]);this.visitDescendants(j.id,G=>{W.add(G)});for(const G of this.getPageStates()){if(G.pageId===F.parentId)continue;const z=b(G,W);z&&this.store.put([z])}}j.parentId&&co(j.parentId)&&k.add(j.parentId),F.parentId!==j.parentId&&co(F.parentId)&&k.add(F.parentId)},beforeDelete:j=>{var N,B,W,G;if(C.has(j.id))return;j.parentId&&co(j.parentId)&&k.add(j.parentId),C.add(j.id);const F=[];for(const z of this.getBindingsInvolvingShape(j)){O.add(z.type),F.push(z.id);const V=this.getBindingUtil(z);z.fromId===j.id?((N=V.onBeforeIsolateToShape)==null||N.call(V,{binding:z,removedShape:j}),(B=V.onBeforeDeleteFromShape)==null||B.call(V,{binding:z,shape:j})):((W=V.onBeforeIsolateFromShape)==null||W.call(V,{binding:z,removedShape:j}),(G=V.onBeforeDeleteToShape)==null||G.call(V,{binding:z,shape:j}))}F.length&&this.deleteBindings(F);const $=new Set([j.id]),D=Gt(this.getPageStates().map(z=>b(z,$)));D.length&&this.store.put(D)}},binding:{beforeCreate:j=>{var $,D;const F=(D=($=this.getBindingUtil(j)).onBeforeCreate)==null?void 0:D.call($,{binding:j});return F||j},afterCreate:j=>{var F,$;O.add(j.type),($=(F=this.getBindingUtil(j)).onAfterCreate)==null||$.call(F,{binding:j})},beforeChange:(j,F)=>{var D,N;const $=(N=(D=this.getBindingUtil(F)).onBeforeChange)==null?void 0:N.call(D,{bindingBefore:j,bindingAfter:F});return $||F},afterChange:(j,F)=>{var $,D;O.add(F.type),(D=($=this.getBindingUtil(F)).onAfterChange)==null||D.call($,{bindingBefore:j,bindingAfter:F})},beforeDelete:j=>{var F,$;($=(F=this.getBindingUtil(j)).onBeforeDelete)==null||$.call(F,{binding:j})},afterDelete:j=>{var F,$;($=(F=this.getBindingUtil(j)).onAfterDelete)==null||$.call(F,{binding:j}),O.add(j.type)}},page:{afterCreate:j=>{const F=la.createId(j.id),$=Cs.createId(j.id);this.store.has(F)||this.store.put([la.create({id:F})]),this.store.has($)||this.store.put([Cs.create({id:$,pageId:j.id})])},afterDelete:(j,F)=>{var N,B;if(((N=this.getInstanceState())==null?void 0:N.currentPageId)===j.id){const W=(B=this.getPages().find(G=>G.id!==j.id))==null?void 0:B.id;W?this.store.put([{...this.getInstanceState(),currentPageId:W}]):F==="user"&&this.store.ensureStoreIsUsable()}const $=la.createId(j.id),D=Cs.createId(j.id);this.store.remove([$,D])}},instance:{afterChange:(j,F,$)=>{var D;if(!this.store.has(F.currentPageId)){const N=this.store.has(j.currentPageId)?j.currentPageId:(D=this.getPages()[0])==null?void 0:D.id;N?this.store.update(F.id,B=>({...B,currentPageId:N})):$==="user"&&this.store.ensureStoreIsUsable()}}},instance_page_state:{afterChange:(j,F)=>{if((j==null?void 0:j.selectedShapeIds)!==(F==null?void 0:F.selectedShapeIds)){const $=F.selectedShapeIds.filter(N=>{var W,G;let B=(W=this.getShape(N))==null?void 0:W.parentId;for(;co(B);){if(F.selectedShapeIds.includes(B))return!1;B=(G=this.getShape(B))==null?void 0:G.parentId}return!0});let D=null;if($.length>0){const N=this.findCommonAncestor(Gt($.map(B=>this.getShape(B))),B=>this.isShapeOfType(B,"group"));N&&(D=N)}else F!=null&&F.focusedGroupId&&(D=F.focusedGroupId);($.length!==F.selectedShapeIds.length||D!==F.focusedGroupId)&&this.store.put([{...F,selectedShapeIds:$,focusedGroupId:D??null}])}}}})),this._currentPageShapeIds=PAe(this.store,()=>this.getCurrentPageId()),this._parentIdsToChildIds=IAe(this.store),this.disposables.add(this.store.listen(j=>{this.emit("change",j)})),this.disposables.add(this.history.dispose),this.run(()=>{this.store.ensureStoreIsUsable(),this._updateCurrentPageState({editingShapeId:null,hoveredShapeId:null,erasingShapeIds:[]})},{history:"ignore"}),c&&this.root.children[c]===void 0)throw Error(`No state found for initialState "${c}".`);if(this.root.enter(void 0,"initial"),this.edgeScrollManager=new DAe(this),this.focusManager=new LAe(this,l),this.disposables.add(this.focusManager.dispose.bind(this.focusManager)),this.getInstanceState().followingUserId&&this.stopFollowingUser(),this.on("tick",this._flushEventsForTick),this.timers.requestAnimationFrame(()=>{this._tickManager.start()}),this.performanceTracker=new NJ,(L=this.store.props.collaboration)!=null&&L.mode){const j=this.store.props.collaboration.mode;this.disposables.add(fa("update collaboration mode",()=>{this.store.put([{...this.getInstanceState(),isReadonly:j.get()==="readonly"}])}))}}getIsShapeHiddenCache(){return this._isShapeHiddenPredicate?this.store.createComputedCache("isShapeHidden",e=>this.findShapeAncestor(e,n=>this.isShapeHidden(n))?!0:this._isShapeHiddenPredicate(e,this)??!1):null}isShapeHidden(e){return this._isShapeHiddenPredicate?!!this.getIsShapeHiddenCache().get(typeof e=="string"?e:e.id):!1}dispose(){this.disposables.forEach(e=>e()),this.disposables.clear(),this.isDisposed=!0}getShapeUtil(e){const t=typeof e=="string"?e:e.type,n=bi(this.shapeUtils,t);return Jt(n,`No shape util found for type "${t}"`),n}hasShapeUtil(e){const t=typeof e=="string"?e:e.type;return ss(this.shapeUtils,t)}getBindingUtil(e){const t=typeof e=="string"?e:e.type,n=bi(this.bindingUtils,t);return Jt(n,`No binding util found for type "${t}"`),n}undo(){return this._flushEventsForTick(0),this.complete(),this.history.undo(),this}getCanUndo(){return this.history.getNumUndos()>0}redo(){return this._flushEventsForTick(0),this.complete(),this.history.redo(),this}clearHistory(){return this.history.clear(),this}getCanRedo(){return this.history.getNumRedos()>0}mark(e){return console.warn(typeof e=="string"?`[tldraw] \`editor.history.mark("${e}")\` is deprecated. Please use \`const myMarkId = editor.markHistoryStoppingPoint()\` instead.`:"[tldraw] `editor.mark()` is deprecated. Use `editor.markHistoryStoppingPoint()` instead."),this.history._mark(e??Er()),this}markHistoryStoppingPoint(e){const t=`[${e??"stop"}]_${Er()}`;return this.history._mark(t),t}getMarkIdMatching(e){return this.history.getMarkIdMatching(e)}squashToMark(e){return this.history.squashToMark(e),this}bail(){return this.history.bail(),this}bailToMark(e){return this.history.bailToMark(e),this}run(e,t){const n=this._shouldIgnoreShapeLock;this._shouldIgnoreShapeLock=(t==null?void 0:t.ignoreShapeLock)??n;try{this.history.batch(e,t)}finally{this._shouldIgnoreShapeLock=n}return this}batch(e,t){return this.run(e,t)}annotateError(e,{origin:t,willCrashApp:n,tags:i,extras:o}){const s=this.createErrorAnnotations(t,n);return OC(e,{tags:{...s.tags,...i},extras:{...s.extras,...o}}),n&&this.store.markAsPossiblyCorrupted(),this}createErrorAnnotations(e,t){try{const n=this.getEditingShapeId();return{tags:{origin:e,willCrashApp:t},extras:{activeStateNode:this.root.getPath(),selectedShapes:this.getSelectedShapes().map(i=>{const{props:o,...s}=i,{text:a,richText:c,...l}=o;return{...s,props:l}}),selectionCount:this.getSelectedShapes().length,editingShape:n?this.getShape(n):void 0,inputs:this.inputs,pageState:this.getCurrentPageState(),instanceState:this.getInstanceState(),collaboratorCount:this.getCollaboratorsOnCurrentPage().length}}}catch{return{tags:{origin:e,willCrashApp:t},extras:{}}}}getCrashingError(){return this._crashingError}crash(e){return this._crashingError=e,this.store.markAsPossiblyCorrupted(),this.emit("crash",{error:e}),this}getPath(){return this.root.getPath().split("root.")[1]}isIn(e){const t=e.split(".").reverse();let n=this.root;for(;t.length>0;){const i=t.pop();if(!i)return!0;const o=n.getCurrent();if((o==null?void 0:o.id)===i){if(t.length===0)return!0;n=o;continue}else return!1}return!1}isInAny(...e){return e.some(t=>this.isIn(t))}setCurrentTool(e,t={}){return this.root.transition(e,t),this}getCurrentTool(){return this.root.getCurrent()}getCurrentToolId(){const e=this.getCurrentTool();return e?e.getCurrentToolIdMask()??e.id:""}getStateDescendant(e){var i;const t=e.split(".").reverse();let n=this.root;for(;t.length>0;){const o=t.pop();if(!o)return n;const s=(i=n.children)==null?void 0:i[o];if(!s)return;n=s}return n}getDocumentSettings(){return this.store.get(TP)}updateDocumentSettings(e){return this.run(()=>{this.store.put([{...this.getDocumentSettings(),...e}])},{history:"ignore"}),this}getInstanceState(){return this.store.get(Bi)}updateInstanceState(e,t){return this._updateInstanceState(e,{history:"ignore",...t}),e.isChangingStyle!==void 0&&(clearTimeout(this._isChangingStyleTimeout),e.isChangingStyle===!0&&(this._isChangingStyleTimeout=this.timers.setTimeout(()=>{this._updateInstanceState({isChangingStyle:!1},{history:"ignore"})},1e3))),this}_updateInstanceState(e,t){this.run(()=>{this.store.put([{...this.getInstanceState(),...e}])},t)}getOpenMenus(){return this.menus.getOpenMenus()}addOpenMenu(e){return this.menus.addOpenMenu(e),this}deleteOpenMenu(e){return this.menus.deleteOpenMenu(e),this}clearOpenMenus(){return this.menus.clearOpenMenus(),this}getIsMenuOpen(){return this.menus.hasAnyOpenMenus()}setCursor(e){return this.updateInstanceState({cursor:{...this.getInstanceState().cursor,...e}}),this}getPageStates(){return this._getPageStatesQuery().get()}_getPageStatesQuery(){return this.store.query.records("instance_page_state")}getCurrentPageState(){return this.store.get(this._getCurrentPageStateId())}_getCurrentPageStateId(){return Cs.createId(this.getCurrentPageId())}updateCurrentPageState(e){return this._updateCurrentPageState(e),this}_updateCurrentPageState(e){this.store.update(e.id??this.getCurrentPageState().id,t=>({...t,...e}))}getSelectedShapeIds(){return this.getCurrentPageState().selectedShapeIds}getSelectedShapes(){const{selectedShapeIds:e}=this.getCurrentPageState();return Gt(e.map(t=>this.store.get(t)))}setSelectedShapes(e){return this.run(()=>{const t=e.map(o=>typeof o=="string"?o:o.id),{selectedShapeIds:n}=this.getCurrentPageState(),i=new Set(n);if(t.length===i.size&&t.every(o=>i.has(o)))return null;this.store.put([{...this.getCurrentPageState(),selectedShapeIds:t}])},{history:"record-preserveRedoStack"})}isAncestorSelected(e){const t=typeof e=="string"?e:(e==null?void 0:e.id)??null,n=this.getShape(t);if(!n)return!1;const i=this.getSelectedShapeIds();return!!this.findShapeAncestor(n,o=>i.includes(o.id))}select(...e){const t=typeof e[0]=="string"?e:e.map(n=>n.id);return this.setSelectedShapes(t),this}deselect(...e){const t=typeof e[0]=="string"?e:e.map(i=>i.id),n=this.getSelectedShapeIds();return n.length>0&&t.length>0&&this.setSelectedShapes(n.filter(i=>!t.includes(i))),this}selectAll(){const e=this.getSortedChildIdsForParent(this.getCurrentPageId());return e.length<=0?this:(this.setSelectedShapes(this._getUnlockedShapeIds(e)),this)}selectNone(){return this.getSelectedShapeIds().length>0&&this.setSelectedShapes([]),this}getOnlySelectedShapeId(){var e;return((e=this.getOnlySelectedShape())==null?void 0:e.id)??null}getOnlySelectedShape(){const e=this.getSelectedShapes();return e.length===1?e[0]:null}getShapesPageBounds(e){const t=Gt(e.map(n=>this.getShapePageBounds(n)));return t.length===0?null:He.Common(t)}getSelectionPageBounds(){return this.getShapesPageBounds(this.getSelectedShapeIds())}getShapesSharedRotation(e){let t=!1,n=0;for(let i=0,o=e.length;i<o;i++){const s=this.getShapePageTransform(e[i]);if(s)if(t){if(s.rotation()!==n)return 0}else t=!0,n=s.rotation()}return n}getSelectionRotation(){return this.getShapesSharedRotation(this.getSelectedShapeIds())}getShapesRotatedPageBounds(e){if(e.length===0)return;const t=this.getShapesSharedRotation(e);if(t===0)return this.getShapesPageBounds(e)??void 0;if(e.length===1){const i=this.getShapeGeometry(e[0]).bounds.clone(),o=this.getShapePageTransform(e[0]);return i.point=o.applyToPoint(i.point),i}const n=He.FromPoints(e.flatMap(i=>{const o=this.getShapePageTransform(i);return o?o.applyToPoints(this.getShapeGeometry(i).bounds.corners):[]}).map(i=>i.rot(-t)));return n.point=n.point.rot(t),n}getSelectionRotatedPageBounds(){return this.getShapesRotatedPageBounds(this.getSelectedShapeIds())}getSelectionRotatedScreenBounds(){const e=this.getSelectionRotatedPageBounds();if(!e)return;const{x:t,y:n}=this.pageToScreen(e.point),i=this.getZoomLevel();return new He(t,n,e.width*i,e.height*i)}getFocusedGroupId(){return this.getCurrentPageState().focusedGroupId??this.getCurrentPageId()}getFocusedGroup(){const e=this.getFocusedGroupId();return e?this.getShape(e):void 0}setFocusedGroup(e){const t=typeof e=="string"?e:(e==null?void 0:e.id)??null;if(t!==null){const n=this.getShape(t);if(!n)throw Error(`Editor.setFocusedGroup: Shape with id ${t} does not exist`);if(!this.isShapeOfType(n,"group"))throw Error(`Editor.setFocusedGroup: Cannot set focused group to shape of type ${n.type}`)}return t===this.getFocusedGroupId()?this:this.run(()=>{this.store.update(this.getCurrentPageState().id,n=>({...n,focusedGroupId:t}))},{history:"record-preserveRedoStack"})}popFocusedGroupId(){const e=this.getFocusedGroup();if(e){const t=this.findShapeAncestor(e,n=>this.isShapeOfType(n,"group"));this.setFocusedGroup((t==null?void 0:t.id)??null),this.select(e.id)}else this.setFocusedGroup(null),this.selectNone();return this}getEditingShapeId(){return this.getCurrentPageState().editingShapeId}getEditingShape(){const e=this.getEditingShapeId();return e?this.getShape(e):void 0}setEditingShape(e){const t=typeof e=="string"?e:(e==null?void 0:e.id)??null;if(t!==this.getEditingShapeId()){if(t){const n=this.getShape(t);if(n&&this.getShapeUtil(n).canEdit(n))return this.run(()=>{this._updateCurrentPageState({editingShapeId:t})},{history:"ignore"}),this}this.run(()=>{this._updateCurrentPageState({editingShapeId:null})},{history:"ignore"})}return this}getHoveredShapeId(){return this.getCurrentPageState().hoveredShapeId}getHoveredShape(){const e=this.getHoveredShapeId();return e?this.getShape(e):void 0}setHoveredShape(e){const t=typeof e=="string"?e:(e==null?void 0:e.id)??null;return t===this.getHoveredShapeId()?this:(this.run(()=>{this.updateCurrentPageState({hoveredShapeId:t})},{history:"ignore"}),this)}getHintingShapeIds(){return this.getCurrentPageState().hintingShapeIds}getHintingShape(){const e=this.getHintingShapeIds();return Gt(e.map(t=>this.getShape(t)))}setHintingShapes(e){const t=typeof e[0]=="string"?e:e.map(n=>n.id);return this.run(()=>{this._updateCurrentPageState({hintingShapeIds:RC(t)})},{history:"ignore"}),this}getErasingShapeIds(){return this.getCurrentPageState().erasingShapeIds}getErasingShapes(){const e=this.getErasingShapeIds();return Gt(e.map(t=>this.getShape(t)))}setErasingShapes(e){const t=typeof e[0]=="string"?e:e.map(i=>i.id);t.sort();const n=this.getErasingShapeIds();return this.run(()=>{if(t.length===n.length){for(let i=0;i<t.length;i++)if(t[i]!==n[i]){this._updateCurrentPageState({erasingShapeIds:t});break}}else this._updateCurrentPageState({erasingShapeIds:t})},{history:"ignore"}),this}getCroppingShapeId(){return this.getCurrentPageState().croppingShapeId}setCroppingShape(e){const t=typeof e=="string"?e:(e==null?void 0:e.id)??null;return t!==this.getCroppingShapeId()&&this.run(()=>{if(!t)this.updateCurrentPageState({croppingShapeId:null});else{const n=this.getShape(t),i=this.getShapeUtil(n);n&&i.canCrop(n)&&this.updateCurrentPageState({croppingShapeId:t})}},{history:"ignore"}),this}_unsafe_getCameraId(){return la.createId(this.getCurrentPageId())}getCamera(){const e=this.store.get(this._unsafe_getCameraId());if(this._isLockedOnFollowingUser.get()){const t=this.getCameraForFollowing();if(t)return{...e,...t}}return e}getViewportPageBoundsForFollowing(){const e=this.getInstanceState().followingUserId;if(!e)return null;const t=this.getCollaborators().find(f=>f.userId===e);if(!t||!t.camera||!t.screenBounds)return null;const{w:n,h:i}=t.screenBounds,{x:o,y:s,z:a}=t.camera,c=new He(-o,-s,n/a,i/a),l=this.getViewportScreenBounds().clone(),d=l.width/l.height;return l.width=c.width,l.height=l.width/d,l.height<c.height&&(l.height=c.height,l.width=l.height*d),l.center=c.center,l}getCameraForFollowing(){const e=this.getViewportPageBoundsForFollowing();return e?{x:-e.x,y:-e.y,z:this.getViewportScreenBounds().w/e.width}:null}getZoomLevel(){return this.getCamera().z}getInitialZoom(){const e=this.getCameraOptions();if(!e.constraints||e.constraints.initialZoom==="default")return 1;const{zx:t,zy:n}=aQ(this,e);switch(e.constraints.initialZoom){case"fit-min":return Math.max(t,n);case"fit-max":return Math.min(t,n);case"fit-x":return t;case"fit-y":return n;case"fit-min-100":return Math.min(1,Math.max(t,n));case"fit-max-100":return Math.min(1,Math.min(t,n));case"fit-x-100":return Math.min(1,t);case"fit-y-100":return Math.min(1,n);default:throw An(e.constraints.initialZoom)}}getBaseZoom(){const e=this.getCameraOptions();if(!e.constraints||e.constraints.baseZoom==="default")return 1;const{zx:t,zy:n}=aQ(this,e);switch(e.constraints.baseZoom){case"fit-min":return Math.max(t,n);case"fit-max":return Math.min(t,n);case"fit-x":return t;case"fit-y":return n;case"fit-min-100":return Math.min(1,Math.max(t,n));case"fit-max-100":return Math.min(1,Math.min(t,n));case"fit-x-100":return Math.min(1,t);case"fit-y-100":return Math.min(1,n);default:throw An(e.constraints.baseZoom)}}getCameraOptions(){return this._cameraOptions.get()}setCameraOptions(e){var n;const t=Kr({...this._cameraOptions.__unsafe__getWithoutCapture(),...e});return((n=t.zoomSteps)==null?void 0:n.length)<1&&(t.zoomSteps=[1]),this._cameraOptions.set(t),this.setCamera(this.getCamera()),this}getConstrainedCamera(e,t){const n=this.getCamera();let{x:i,y:o,z:s=n.z}=e;if(!(t!=null&&t.force)){const a=this.getCameraOptions(),c=a.zoomSteps[0],l=Zn(a.zoomSteps),d=this.getViewportScreenBounds();if(a.constraints){const{constraints:f}=a,h=Math.min(f.padding.y,d.w/2),g=Math.min(f.padding.x,d.h/2),m=He.From(a.constraints.bounds),y=(d.w-g*2)/m.w,x=(d.h-h*2)/m.h,_=this.getBaseZoom(),w=l*_,I=c*_;if(t!=null&&t.reset&&(s=this.getInitialZoom()),s<I||s>w){const{x:$,y:D,z:N}=n,B=-$+d.w/N/2,W=-D+d.h/N/2;s=Yn(s,I,w);const G=-$+d.w/s/2,z=-D+d.h/s/2;i=$+G-B,o=D+z-W}const b=g/s-m.x,P=h/s-m.y,C=(d.w-g*2)/s-m.w,k=(d.h-h*2)/s-m.h,O=b+C*f.origin.x,L=P+k*f.origin.y,j=typeof f.behavior=="string"?f.behavior:f.behavior.x,F=typeof f.behavior=="string"?f.behavior:f.behavior.y;if(t!=null&&t.reset)i=O,o=L;else{switch(j){case"fixed":{i=O;break}case"contain":{s<y?i=O:i=Yn(i,b+C,b);break}case"inside":{s<y?i=Yn(i,b,(d.w-g)/s-m.w):i=Yn(i,b+C,b);break}case"outside":{i=Yn(i,g/s-m.w,(d.w-g)/s);break}case"free":break;default:throw An(j)}switch(F){case"fixed":{o=L;break}case"contain":{s<x?o=L:o=Yn(o,P+k,P);break}case"inside":{s<x?o=Yn(o,P,(d.h-h)/s-m.h):o=Yn(o,P+k,P);break}case"outside":{o=Yn(o,h/s-m.h,(d.h-h)/s);break}case"free":break;default:throw An(F)}}}else if(s>l||s<c){const{x:f,y:h,z:g}=n;s=Yn(s,c,l),i=f+(-f+d.w/s/2)-(-f+d.w/g/2),o=h+(-h+d.h/s/2)-(-h+d.h/g/2)}}return{x:i,y:o,z:s}}_setCamera(e,t){const n=this.getCamera(),{x:i,y:o,z:s}=this.getConstrainedCamera(e,t);return n.x===i&&n.y===o&&n.z===s?this:(Ui(()=>{const a={...n,x:i,y:o,z:s};this.run(()=>{this.store.put([a])},{history:"ignore"});const{currentScreenPoint:c,currentPagePoint:l}=this.inputs,{screenBounds:d}=this.store.unsafeGetWithoutCapture(Bi);if(c.x/s-i!==l.x||c.y/s-o!==l.y){const f={type:"pointer",target:"canvas",name:"pointer_move",point:T.AddXY(c,d.x,d.y),pointerId:rD.CAMERA_MOVE,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,shiftKey:this.inputs.shiftKey,metaKey:this.inputs.metaKey,accelKey:wi(this.inputs),button:0,isPen:this.getInstanceState().isPenMode??!1};t!=null&&t.immediate?this._flushEventForTick(f):this.dispatch(f)}this._tickCameraState()}),this)}setCamera(e,t){const{isLocked:n}=this._cameraOptions.__unsafe__getWithoutCapture();if(n&&!(t!=null&&t.force))return this;this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser();const i=T.Cast(e);Uf.Number.isFinite(i.x)||(i.x=0),Uf.Number.isFinite(i.y)||(i.y=0),(i.z===void 0||!Uf.Number.isFinite(i.z))&&(e.z=this.getZoomLevel());const o=this.getConstrainedCamera(i,t);if(t!=null&&t.animation){const{width:s,height:a}=this.getViewportScreenBounds();this._animateToViewport(new He(-o.x,-o.y,s/o.z,a/o.z),t)}else this._setCamera(o,{...t,force:!0});return this}centerOnPoint(e,t){const{isLocked:n}=this.getCameraOptions();if(n&&!(t!=null&&t.force))return this;const{width:i,height:o}=this.getViewportPageBounds();return this.setCamera(new T(-(e.x-i/2),-(e.y-o/2),this.getCamera().z),t),this}zoomToFit(e){const t=[...this.getCurrentPageShapeIds()];if(t.length<=0)return this;const n=He.Common(Gt(t.map(i=>this.getShapePageBounds(i))));return this.zoomToBounds(n,e),this}resetZoom(e=this.getViewportScreenCenter(),t){const{isLocked:n,constraints:i}=this.getCameraOptions();if(n&&!(t!=null&&t.force))return this;const o=this.getCamera(),{x:s,y:a,z:c}=o,{x:l,y:d}=e;let f=1;if(i){const h=this.getInitialZoom();c!==h&&(f=h)}return this.setCamera(new T(s+(l/f-l)-(l/c-l),a+(d/f-d)-(d/c-d),f),t),this}zoomIn(e=this.getViewportScreenCenter(),t){const{isLocked:n}=this.getCameraOptions();if(n&&!(t!=null&&t.force))return this;const{x:i,y:o,z:s}=this.getCamera(),{zoomSteps:a}=this.getCameraOptions();if(a!==null&&a.length>1){const c=this.getBaseZoom();let l=Zn(a)*c;for(let d=1;d<a.length;d++){const f=a[d-1]*c,h=a[d]*c;if(!(h-s<=(h-f)/2)){l=h;break}}this.setCamera(new T(i+(e.x/l-e.x)-(e.x/s-e.x),o+(e.y/l-e.y)-(e.y/s-e.y),l),t)}return this}zoomOut(e=this.getViewportScreenCenter(),t){const{isLocked:n}=this.getCameraOptions();if(n&&!(t!=null&&t.force))return this;const{zoomSteps:i}=this.getCameraOptions();if(i!==null&&i.length>1){const o=this.getBaseZoom(),{x:s,y:a,z:c}=this.getCamera();let l=i[0]*o;for(let d=i.length-1;d>0;d--){const f=i[d-1]*o,h=i[d]*o;if(!(h-c>=(h-f)/2)){l=f;break}}this.setCamera(new T(s+(e.x/l-e.x)-(e.x/c-e.x),a+(e.y/l-e.y)-(e.y/c-e.y),l),t)}return this}zoomToSelection(e){const{isLocked:t}=this.getCameraOptions();if(t&&!(e!=null&&e.force))return this;const n=this.getSelectionPageBounds();return n&&this.zoomToBounds(n,{targetZoom:Math.max(1,this.getZoomLevel()),...e}),this}zoomToBounds(e,t){const n=this._cameraOptions.__unsafe__getWithoutCapture();if(n.isLocked&&!(t!=null&&t.force))return this;const i=this.getViewportScreenBounds(),o=(t==null?void 0:t.inset)??Math.min(Wye,i.width*.28),s=this.getBaseZoom(),a=n.zoomSteps[0],c=Zn(n.zoomSteps);let l=Yn(Math.min((i.width-o)/e.w,(i.height-o)/e.h),a*s,c*s);return(t==null?void 0:t.targetZoom)!==void 0&&(l=Math.min(t.targetZoom,l)),this.setCamera(new T(-e.x+(i.width-e.w*l)/2/l,-e.y+(i.height-e.h*l)/2/l,l),t),this}stopCameraAnimation(){return this.emit("stop-camera-animation"),this}_animateViewport(e){if(!this._viewportAnimation)return;this._viewportAnimation.elapsed+=e;const{elapsed:t,easing:n,duration:i,start:o,end:s}=this._viewportAnimation;if(t>i){this.off("tick",this._animateViewport),this._viewportAnimation=null,this._setCamera(new T(-s.x,-s.y,this.getViewportScreenBounds().width/s.width));return}const a=i-t,c=n(1-a/i),l=o.minX+(s.minX-o.minX)*c,d=o.minY+(s.minY-o.minY)*c,f=o.maxX+(s.maxX-o.maxX)*c;this._setCamera(new T(-l,-d,this.getViewportScreenBounds().width/(f-l)),{force:!0})}_animateToViewport(e,t={animation:rb}){const{animation:n,...i}=t;if(!n)return;const{duration:o=0,easing:s=zn.easeInOutCubic}=n,a=this.user.getAnimationSpeed(),c=this.getViewportPageBounds();return this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),o===0||a===0?this._setCamera(new T(-e.x,-e.y,this.getViewportScreenBounds().width/e.width),{...i}):(this._viewportAnimation={elapsed:0,duration:o/a,easing:s,start:c.clone(),end:e.clone()},this.once("stop-camera-animation",()=>{this.off("tick",this._animateViewport),this._viewportAnimation=null}),this.on("tick",this._animateViewport),this)}slideCamera(e={}){const{isLocked:t}=this.getCameraOptions();if(t&&!(e!=null&&e.force))return this;if(this.user.getAnimationSpeed()===0)return this;this.stopCameraAnimation();const{speed:i,friction:o=this.options.cameraSlideFriction,direction:s,speedThreshold:a=.01}=e;let c=Math.min(i,1);const l=()=>{this.off("tick",d),this.off("stop-camera-animation",l)};this.once("stop-camera-animation",l);const d=f=>{const{x:h,y:g,z:m}=this.getCamera(),y=T.Mul(s,c*f/m);c*=1-o,c<a?l():this._setCamera(new T(h+y.x,g+y.y,m))};return this.on("tick",d),this}zoomToUser(e,t={animation:{duration:500}}){const n=this.getCollaborators().find(o=>o.userId===e);if(!n)return this;const i=n.cursor;return i?(this.run(()=>{this.getInstanceState().followingUserId!==null&&this.stopFollowingUser();const o=n.currentPageId===this.getCurrentPageId();o||this.setCurrentPage(n.currentPageId),t&&t.animation&&!o&&(t.animation=void 0),this.centerOnPoint(i,t);const{highlightedUserIds:s}=this.getInstanceState();this.updateInstanceState({highlightedUserIds:[...s,e]}),this.timers.setTimeout(()=>{const a=[...this.getInstanceState().highlightedUserIds],c=a.indexOf(e);c<0||(a.splice(c,1),this.updateInstanceState({highlightedUserIds:a}))},this.options.collaboratorIdleTimeoutMs)}),this):this}updateViewportScreenBounds(e,t=!1){if(e instanceof HTMLElement){const a=e.getBoundingClientRect();e=new He(a.left||a.x,a.top||a.y,Math.max(a.width,1),Math.max(a.height,1))}else e.width=Math.max(e.width,1),e.height=Math.max(e.height,1);const n=[e.minY!==0,!Yc(document.body.scrollWidth,e.maxX,1),!Yc(document.body.scrollHeight,e.maxY,1),e.minX!==0],{_willSetInitialBounds:i}=this;this._willSetInitialBounds=!1;const{screenBounds:o,insets:s}=this.getInstanceState();if(e.equals(o)&&n.every((a,c)=>a===s[c]))return this;if(i)this.updateInstanceState({screenBounds:e.toJson(),insets:n}),this.setCamera(this.getCamera());else if(t&&!this.getInstanceState().followingUserId){const a=this.getViewportPageBounds().center;this.updateInstanceState({screenBounds:e.toJson(),insets:n}),this.centerOnPoint(a)}else this.updateInstanceState({screenBounds:e.toJson(),insets:n}),this._setCamera(T.From({...this.getCamera()}));return this._tickCameraState(),this}getViewportScreenBounds(){const{x:e,y:t,w:n,h:i}=this.getInstanceState().screenBounds;return new He(e,t,n,i)}getViewportScreenCenter(){const e=this.getViewportScreenBounds();return new T(e.midX-e.minX,e.midY-e.minY)}getViewportPageBounds(){const{w:e,h:t}=this.getViewportScreenBounds(),{x:n,y:i,z:o}=this.getCamera();return new He(-n,-i,e/o,t/o)}screenToPage(e){const{screenBounds:t}=this.store.unsafeGetWithoutCapture(Bi),{x:n,y:i,z:o=1}=this.getCamera();return new T((e.x-t.x)/o-n,(e.y-t.y)/o-i,e.z??.5)}pageToScreen(e){const{screenBounds:t}=this.store.unsafeGetWithoutCapture(Bi),{x:n,y:i,z:o=1}=this.getCamera();return new T((e.x+n)*o+t.x,(e.y+i)*o+t.y,e.z??.5)}pageToViewport(e){const{x:t,y:n,z:i=1}=this.getCamera();return new T((e.x+t)*i,(e.y+n)*i,e.z??.5)}_getCollaboratorsQuery(){return this.store.query.records("instance_presence",()=>({userId:{neq:this.user.getId()}}))}getCollaborators(){const e=this._getCollaboratorsQuery().get();return e.length?[...new Set(e.map(n=>n.userId))].sort().map(n=>kge(e.filter(o=>o.userId===n),o=>o.lastActivityTimestamp??0)):ec}getCollaboratorsOnCurrentPage(){const e=this.getCurrentPageId();return this.getCollaborators().filter(t=>t.currentPageId===e)}startFollowingUser(e){this.stopFollowingUser();const t=this._getCollaboratorsQuery().get().filter(o=>o.userId===e);if(!t.length)return console.warn("User not found"),this;const n=this.user.getId();if(n||console.warn("You should set the userId for the current instance before following a user"),t.some(o=>o.followingUserId===n))return this;const i=Te("latestLeaderPresence",()=>this.getCollaborators().find(o=>o.userId===e));return Ui(()=>{this.updateInstanceState({followingUserId:e},{history:"ignore"});const o=fa("update current page",()=>{const c=i.get();if(!c){this.stopFollowingUser();return}c.currentPageId!==this.getCurrentPageId()&&this.getPage(c.currentPageId)&&this.run(()=>{this.store.put([{...this.getInstanceState(),currentPageId:c.currentPageId}]),this._isLockedOnFollowingUser.set(!0)},{history:"ignore"})}),s=()=>{o(),this._isLockedOnFollowingUser.set(!1),this.off("frame",a),this.off("stop-following",s)},a=()=>{if(!i.get()){this.stopFollowingUser();return}if(this._isLockedOnFollowingUser.get())return;const l=this.user.getAnimationSpeed();if(l===0){this._isLockedOnFollowingUser.set(!0);return}const d=this.getViewportPageBoundsForFollowing();if(!d){this.stopFollowingUser();return}const f=this.getViewportPageBounds(),h=Math.abs(d.minX-f.minX)+Math.abs(d.maxX-f.maxX),g=Math.abs(d.minY-f.minY)+Math.abs(d.maxY-f.maxY);if(h<this.options.followChaseViewportSnap&&g<this.options.followChaseViewportSnap){this._isLockedOnFollowingUser.set(!0);return}const m=Yn(l*.5,.1,.8),y=new He(or(f.minX,d.minX,m),or(f.minY,d.minY,m),or(f.width,d.width,m),or(f.height,d.height,m)),x=new T(-y.x,-y.y,this.getViewportScreenBounds().width/y.width);this.stopCameraAnimation(),this._setCamera(x)};this.once("stop-following",s),this.addListener("frame",a),a()}),this}stopFollowingUser(){return this.run(()=>{this.store.put([this.getCamera()]),this._isLockedOnFollowingUser.set(!1),this.updateInstanceState({followingUserId:null}),this.emit("stop-following")},{history:"ignore"}),this}getUnorderedRenderingShapes(e){const t=[];let n=this.options.maxShapesPerPage*2,i=this.options.maxShapesPerPage;const o=this.getErasingShapeIds(),s=(c,l,d)=>{const f=this.getShape(c);if(!f||this.isShapeHidden(f))return;l*=f.opacity;let h=!1;const g=this.getShapeUtil(f);e&&(h=!d&&o.includes(c),h&&(l*=.32)),t.push({id:c,shape:f,util:g,index:n,backgroundIndex:i,opacity:l}),n+=1,i+=1;const m=this.getSortedChildIdsForParent(c);if(!m.length)return;let y=null;g.providesBackgroundForChildren(f)&&(y=i,i=n,n+=this.options.maxShapesPerPage);for(const x of m)s(x,l,d||h);y!==null&&(i=y)},a=e?[this.getCurrentPage()]:this.getPages();for(const c of a)for(const l of this.getSortedChildIdsForParent(c.id))s(l,1,!1);return t}_decayCameraStateTimeout(e){this._cameraStateTimeoutRemaining-=e,!(this._cameraStateTimeoutRemaining>0)&&(this.off("tick",this._decayCameraStateTimeout),this._cameraState.set("idle"))}_tickCameraState(){this._cameraStateTimeoutRemaining=this.options.cameraMovingTimeoutMs,this._cameraState.__unsafe__getWithoutCapture()==="idle"&&(this._cameraState.set("moving"),this.on("tick",this._decayCameraStateTimeout))}getCameraState(){return this._cameraState.get()}getRenderingShapes(){return this.getUnorderedRenderingShapes(!0).sort(lve)}_getAllPagesQuery(){return this.store.query.records("page")}getPages(){return Array.from(this._getAllPagesQuery().get()).sort(_i)}getCurrentPage(){return this.getPage(this.getCurrentPageId())}getCurrentPageId(){return this.getInstanceState().currentPageId}getPage(e){return this.store.get(typeof e=="string"?e:e.id)}getCurrentPageShapeIds(){return this._currentPageShapeIds.get()}getCurrentPageShapeIdsSorted(){return Array.from(this.getCurrentPageShapeIds()).sort()}getPageShapeIds(e){const t=typeof e=="string"?e:e.id,n=this.store.query.exec("shape",{parentId:{eq:t}});return this.getShapeAndDescendantIds(n.map(i=>i.id))}setCurrentPage(e){const t=typeof e=="string"?e:e.id;return this.store.has(t)?(this.stopFollowingUser(),this.complete(),this.run(()=>{this.store.put([{...this.getInstanceState(),currentPageId:t}]),this.setCamera(this.getCamera())},{history:"record-preserveRedoStack"})):(console.error("Tried to set the current page id to a page that doesn't exist."),this)}updatePage(e){return this.getIsReadonly()?this:this.getPage(e.id)?this.run(()=>this.store.update(e.id,n=>({...n,...e}))):this}createPage(e){return this.run(()=>{if(this.getIsReadonly()||this.getPages().length>=this.options.maxPages)return;const t=this.getPages(),n=mAe(e.name??"Page 1",t.map(s=>s.name));let i=e.index;(!i||t.some(s=>s.index===i))&&(i=ca(t[t.length-1].index));const o=Fo.create({meta:{},...e,name:n,index:i});this.store.put([o])}),this}deletePage(e){const t=typeof e=="string"?e:e.id;return this.run(()=>{if(this.getIsReadonly())return;const n=this.getPages();if(n.length===1)return;const i=this.getPage(t);if(i){if(t===this.getCurrentPageId()){const o=n.findIndex(a=>a.id===t),s=n[o-1]??n[o+1];this.setCurrentPage(s.id)}this.store.remove([i.id])}}),this}duplicatePage(e,t=Fo.createId()){if(this.getPages().length>=this.options.maxPages)return this;const n=typeof e=="string"?e:e.id,i=this.getPage(n);if(!i)return this;const o={...this.getCamera()},s=this.getContentFromCurrentPage(this.getSortedChildIdsForParent(i.id));return this.run(()=>{var l;const a=this.getPages(),c=mh(i.index,(l=a[a.indexOf(i)+1])==null?void 0:l.index);if(this.createPage({name:i.name+" Copy",id:t,index:c}),this.setCurrentPage(t),this.setCamera(o),s)return this.putContentOntoCurrentPage(s)}),this}renamePage(e,t){const n=typeof e=="string"?e:e.id;return this.getIsReadonly()?this:(this.updatePage({id:n,name:t}),this)}_getAllAssetsQuery(){return this.store.query.records("asset")}getAssets(){return this._getAllAssetsQuery().get()}createAssets(e){return this.getIsReadonly()?this:e.length<=0?this:(this.run(()=>this.store.put(e),{history:"ignore"}),this)}updateAssets(e){return this.getIsReadonly()?this:e.length<=0?this:(this.run(()=>{this.store.put(e.map(t=>({...this.store.get(t.id),...t})))},{history:"ignore"}),this)}deleteAssets(e){if(this.getIsReadonly())return this;const t=typeof e[0]=="string"?e:e.map(n=>n.id);return t.length<=0?this:(this.run(()=>this.store.remove(t),{history:"ignore"}),this)}getAsset(e){return this.store.get(typeof e=="string"?e:e.id)}async resolveAssetUrl(e,t){if(!e)return null;const n=this.getAsset(e);if(!n)return null;const{screenScale:i=1,shouldResolveToOriginal:o=!1,dpr:s=this.getInstanceState().devicePixelRatio}=t,c=(d=>Math.pow(2,Math.ceil(Math.log2(d))))(i),l="connection"in navigator?navigator.connection.effectiveType:null;return await this.store.props.assets.resolve(n,{screenScale:i||1,steppedScreenScale:c,dpr:s,networkEffectiveType:l,shouldResolveToOriginal:o})}async uploadAsset(e,t,n){return await this.store.props.assets.upload(e,t,n)}getShapeGeometry(e,t){const n=(t==null?void 0:t.context)??"none";return this._shapeGeometryCaches[n]||(this._shapeGeometryCaches[n]=this.store.createComputedCache("bounds",i=>this.getShapeUtil(i).getGeometry(i,t),{areRecordsEqual:(i,o)=>i.props===o.props})),this._shapeGeometryCaches[n].get(typeof e=="string"?e:e.id)}_getShapeHandlesCache(){return this.store.createComputedCache("handles",e=>{var t,n;return(n=(t=this.getShapeUtil(e)).getHandles)==null?void 0:n.call(t,e)})}getShapeHandles(e){return this._getShapeHandlesCache().get(typeof e=="string"?e:e.id)}getShapeLocalTransform(e){const t=typeof e=="string"?e:e.id,n=this.getShape(t);if(!n)throw Error("Editor.getTransform: shape not found");return Ke.Identity().translate(n.x,n.y).rotate(n.rotation)}_getShapePageTransformCache(){return this.store.createComputedCache("pageTransformCache",e=>{if(oo(e.parentId))return this.getShapeLocalTransform(e);const t=this._getShapePageTransformCache().get(e.parentId)??Ke.Identity();return Ke.Compose(t,this.getShapeLocalTransform(e))})}getShapeParentTransform(e){const t=typeof e=="string"?e:e.id,n=this.getShape(t);return!n||oo(n.parentId)?Ke.Identity():this._getShapePageTransformCache().get(n.parentId)??Ke.Identity()}getShapePageTransform(e){const t=typeof e=="string"?e:e.id;return this._getShapePageTransformCache().get(t)??Ke.Identity()}_getShapePageBoundsCache(){return this.store.createComputedCache("pageBoundsCache",e=>{const t=this._getShapePageTransformCache().get(e.id);return t?He.FromPoints(Ke.applyToPoints(t,this.getShapeGeometry(e).vertices)):new He})}getShapePageBounds(e){return this._getShapePageBoundsCache().get(typeof e=="string"?e:e.id)}_getShapeClipPathCache(){return this.store.createComputedCache("clipPathCache",e=>{const t=this._getShapeMaskCache().get(e.id);if(!t)return;if(t.length===0)return"polygon(0px 0px, 0px 0px, 0px 0px)";const n=this._getShapePageTransformCache().get(e.id);return n?`polygon(${Ke.applyToPoints(Ke.Inverse(n),t).map(o=>`${o.x}px ${o.y}px`).join(",")})`:void 0})}getShapeClipPath(e){return this._getShapeClipPathCache().get(typeof e=="string"?e:e.id)}_getShapeMaskCache(){return this.store.createComputedCache("pageMaskCache",e=>{if(oo(e.parentId))return;const t=this.getShapeAncestors(e.id).filter(i=>this.isShapeOfType(i,"frame"));return t.length===0?void 0:t.map(i=>this._getShapePageTransformCache().get(i.id).applyToPoints(this.getShapeGeometry(i).vertices)).reduce((i,o)=>{if(!(o&&i))return;const s=HZ(i,o);return s?s.map(T.Cast):[]})})}getShapeMask(e){return this._getShapeMaskCache().get(typeof e=="string"?e:e.id)}getShapeMaskedPageBounds(e){return typeof e!="string"&&(e=e.id),this._getShapeMaskedPageBoundsCache().get(e)}_getShapeMaskedPageBoundsCache(){return this.store.createComputedCache("shapeMaskedPageBoundsCache",e=>{const t=this._getShapePageBoundsCache().get(e.id);if(!t)return;const n=this._getShapeMaskCache().get(e.id);if(n){if(n.length===0)return;const{corners:i}=t;if(i.every((s,a)=>s&&T.Equals(s,n[a])))return t.clone();const o=HZ(n,i);return o?He.FromPoints(o):void 0}return t})}getShapeAncestors(e,t=[]){const n=typeof e=="string"?e:e.id,i=this.getShape(n);if(!i)return t;const o=i.parentId;if(oo(o))return t.reverse(),t;const s=this.store.get(o);return s?(t.push(s),this.getShapeAncestors(s,t)):t}findShapeAncestor(e,t){const n=typeof e=="string"?e:e.id,i=this.getShape(n);if(!i)return;const o=i.parentId;if(oo(o))return;const s=this.getShape(o);if(s)return t(s)?s:this.findShapeAncestor(s,t)}hasAncestor(e,t){const n=typeof e=="string"?e:e==null?void 0:e.id,i=n&&this.getShape(n);return i?i.parentId===t?!0:this.hasAncestor(this.getShapeParent(i),t):!1}findCommonAncestor(e,t){var c;if(e.length===0)return;const n=typeof e[0]=="string"?e:e.map(l=>l.id),i=Gt(n.map(l=>this.getShape(l)));if(i.length===1){const l=i[0].parentId;return oo(l)?void 0:t?(c=this.findShapeAncestor(i[0],t))==null?void 0:c.id:l}const[o,...s]=i;let a=this.getShapeParent(o);for(;a;){if(t&&!t(a)){a=this.getShapeParent(a);continue}if(s.every(l=>this.hasAncestor(l,a.id)))return a.id;a=this.getShapeParent(a)}}isShapeOrAncestorLocked(e){const t=typeof e=="string"?this.getShape(e):e;return t===void 0?!1:t.isLocked?!0:this.isShapeOrAncestorLocked(this.getShapeParent(t))}_notVisibleShapes(){return EAe(this)}getCulledShapes(){const e=this._notVisibleShapes().get(),t=this.getSelectedShapeIds(),n=this.getEditingShapeId(),i=new Set(e);return n&&i.delete(n),t.forEach(o=>{i.delete(o)}),i}getCurrentPageBounds(){let e;return this.getCurrentPageShapeIdsSorted().forEach(t=>{const n=this.getShapeMaskedPageBounds(t);n&&(e?e=e.expand(n):e=n.clone())}),e}getSelectedShapeAtPoint(e){const t=this.getSelectedShapeIds();return this.getCurrentPageShapesSorted().filter(n=>n.type!=="group"&&t.includes(n.id)).reverse().find(n=>this.isPointInShape(n,e,{hitInside:!0,margin:0}))}getShapeAtPoint(e,t={}){const n=this.getZoomLevel(),i=this.getViewportPageBounds(),{filter:o,margin:s=0,hitLocked:a=!1,hitLabels:c=!1,hitInside:l=!1,hitFrameInside:d=!1}=t;let f=1/0,h=null,g=1/0,m=null;const y=(t.renderingOnly?this.getCurrentPageRenderingShapesSorted():this.getCurrentPageShapesSorted()).filter(x=>{if(x.isLocked&&!a||this.isShapeHidden(x)||this.isShapeOfType(x,"group"))return!1;const _=this.getShapeMask(x);return _&&!Oo(e,_)?!1:o?o(x):!0});for(let x=y.length-1;x>=0;x--){const _=y[x],w=this.getShapeGeometry(_),I=w instanceof cs,b=this.getPointInShapeSpace(_,e);if(this.isShapeOfType(_,"frame")||(this.isShapeOfType(_,"arrow")||this.isShapeOfType(_,"geo")&&_.props.fill==="none")&&_.props.text.trim()){for(const C of w.children)if(C.isLabel&&C.isPointInBounds(b))return _}if(this.isShapeOfType(_,"frame")){const C=w.distanceToPoint(b,l);if(Math.abs(C)<=s)return m||_;if(w.hitTestPoint(b,0,!0))return m||h||(d?_:void 0);continue}let P;if(I){let C=1/0;for(const k of w.children){if(k.isLabel&&!c)continue;const O=k.distanceToPoint(b,l);O<C&&(C=O)}P=C}else s===0&&(w.bounds.w<1||w.bounds.h<1)||w.bounds.containsPoint(b,s)?P=w.distanceToPoint(b,l):P=1/0;if(w.isClosed){if(P<=s){if(w.isFilled||I&&w.children[0].isFilled)return m||_;if(this.getShapePageBounds(_).contains(i))continue;if(Math.abs(P)<s)Math.abs(P)<g&&(g=Math.abs(P),m=_);else if(!m){const{area:C}=w;C<f&&(f=C,h=_)}}}else if(P<this.options.hitTestMargin/n)return _}return m||h||void 0}getShapesAtPoint(e,t={}){return this.getCurrentPageShapes().filter(n=>!this.isShapeHidden(n)&&this.isPointInShape(n,e,t))}isPointInShape(e,t,n={}){const{hitInside:i=!1,margin:o=0}=n,s=typeof e=="string"?e:e.id,a=this.getShapeMask(s);return a&&!Oo(t,a)?!1:this.getShapeGeometry(s).hitTestPoint(this.getPointInShapeSpace(e,t),o,i)}getPointInShapeSpace(e,t){const n=typeof e=="string"?e:e.id;return this._getShapePageTransformCache().get(n).clone().invert().applyToPoint(t)}getPointInParentSpace(e,t){const n=typeof e=="string"?e:e.id,i=this.getShape(n);if(!i)return new T(0,0);if(oo(i.parentId))return T.From(t);const o=this.getShapePageTransform(i.parentId);return o?o.clone().invert().applyToPoint(t):T.From(t)}getCurrentPageShapes(){return Array.from(this.getCurrentPageShapeIds(),e=>this.store.get(e))}getCurrentPageShapesSorted(){const e=[],t=this.getSortedChildIdsForParent(this.getCurrentPageId());for(let n=0,i=t.length;n<i;n++)Xae(this,t[n],e);return e}getCurrentPageRenderingShapesSorted(){const e=this.getCulledShapes();return this.getCurrentPageShapesSorted().filter(({id:t})=>!e.has(t)&&!this.isShapeHidden(t))}isShapeOfType(e,t){const n=typeof e=="string"?this.getShape(e):e;return n?n.type===t:!1}getShape(e){const t=typeof e=="string"?e:e.id;if(co(t))return this.store.get(t)}getShapeParent(e){const t=typeof e=="string"?e:e==null?void 0:e.id;if(!t)return;const n=this.getShape(t);if(!(n===void 0||!co(n.parentId)))return this.store.get(n.parentId)}getShapeNearestSibling(e,t){return t?t.parentId===e.parentId?t:this.findShapeAncestor(t,i=>i.parentId===e.parentId):void 0}isShapeInPage(e,t=this.getCurrentPageId()){const n=typeof e=="string"?e:e.id,i=this.getShape(n);if(!i)return!1;let o=!1;if(i.parentId===t)o=!0;else{let s=this.getShape(i.parentId);e:for(;s;){if(s.parentId===t){o=!0;break e}s=this.getShape(s.parentId)}}return o}getAncestorPageId(e){const t=typeof e=="string"?e:e==null?void 0:e.id,n=t&&this.getShape(t);if(n)return oo(n.parentId)?n.parentId:this.getAncestorPageId(this.getShape(n.parentId))}reparentShapes(e,t,n){const i=typeof e[0]=="string"?e:e.map(h=>h.id);if(i.length===0)return this;const o=[],s=oo(t)?Ke.Identity():this.getShapePageTransform(t),a=s.rotation();let c=[];const l=Gt(this.getSortedChildIdsForParent(t).map(h=>this.getShape(h)));if(n){const h=l.find(g=>g.index===n);if(h){const g=l[l.indexOf(h)+1];g?c=wd(n,g.index,i.length):c=Qx(n,i.length)}else{const g=l.sort(_i).find(m=>m.index>n);g?c=wd(n,g.index,i.length):c=Qx(n,i.length)}}else{const h=l.length&&l[l.length-1];c=h?Qx(h.index,i.length):yh(i.length)}const d=s.clone().invert(),f=Gt(i.map(h=>this.getShape(h)));return this.run(()=>{for(let h=0;h<f.length;h++){const g=f[h],m=this.getShapePageTransform(g);if(!m)continue;const y=m.point();if(!y)continue;const x=d.applyToPoint(y),_=m.rotation()-a;o.push({id:g.id,type:g.type,parentId:t,x:x.x,y:x.y,rotation:_,index:c[h]})}this.updateShapes(o)},{ignoreShapeLock:!0}),this}getHighestIndexForParent(e){const t=typeof e=="string"?e:e.id,n=this._parentIdsToChildIds.get()[t];if(!n||n.length===0)return"a1";const i=this.getShape(n[n.length-1]);return ca(i.index)}getSortedChildIdsForParent(e){const t=typeof e=="string"?e:e.id,n=this._parentIdsToChildIds.get()[t];return n||ec}visitDescendants(e,t){const n=typeof e=="string"?e:e.id,i=this.getSortedChildIdsForParent(n);for(const o of i)t(o)!==!1&&this.visitDescendants(o,t);return this}getShapeAndDescendantIds(e){const t=new Set;for(const n of e.map(i=>this.getShape(i)).sort(_i))t.add(n.id),this.visitDescendants(n,i=>{t.add(i)});return t}getDroppingOverShape(e,t=[]){const n=this.getCurrentPageShapesSorted();for(let i=n.length-1;i>=0;i--){const o=n[i];if(this.isShapeHidden(o)||this.getSelectedShapeIds().includes(o.id)||!this.getShapeUtil(o).canDropShapes(o,t)||t.find(a=>a.id===o.id||this.hasAncestor(o,a.id)))continue;const s=this.getShapeMaskedPageBounds(o.id);if(s&&s.containsPoint(e)&&this.getShapeGeometry(o).hitTestPoint(this.getPointInShapeSpace(o,e),0,!0))return o}}getOutermostSelectableShape(e,t){const n=typeof e=="string"?e:e.id,i=this.getShape(n);let o=i,s=i;const a=this.getFocusedGroup();for(;s;){if(this.isShapeOfType(s,"group")&&(a==null?void 0:a.id)!==s.id&&!this.hasAncestor(a,s.id)&&((t==null?void 0:t(s))??!0))o=s;else if((a==null?void 0:a.id)===s.id)break;s=this.getShapeParent(s)}return o}_getBindingsIndexCache(){const e=wAe(this);return this.store.createComputedCache("bindingsIndex",t=>e.get().get(t.id))}getBinding(e){return this.store.get(e)}getBindingsFromShape(e,t){const n=typeof e=="string"?e:e.id;return this.getBindingsInvolvingShape(n).filter(i=>i.fromId===n&&i.type===t)}getBindingsToShape(e,t){const n=typeof e=="string"?e:e.id;return this.getBindingsInvolvingShape(n).filter(i=>i.toId===n&&i.type===t)}getBindingsInvolvingShape(e,t){const n=typeof e=="string"?e:e.id,i=this._getBindingsIndexCache().get(n)??ec;return t?i.filter(o=>o.type===t):i}createBindings(e){const t=[];for(const n of e){const i=this.getShape(n.fromId),o=this.getShape(n.toId);if(!i||!o||!this.canBindShapes({fromShape:i,toShape:o,binding:n}))continue;const a=this.getBindingUtil(n.type).getDefaultProps(),c=this.store.schema.types.binding.create({...n,id:n.id??Wl(),props:{...a,...n.props}});t.push(c)}return this.store.put(t),this}createBinding(e){return this.createBindings([e])}updateBindings(e){const t=[];for(const n of e){if(!n)continue;const i=this.getBinding(n.id);if(!i)continue;const o=ra(i,n);if(o===i)continue;const s=this.getShape(o.fromId),a=this.getShape(o.toId);!s||!a||this.canBindShapes({fromShape:s,toShape:a,binding:o})&&t.push(o)}return this.store.put(t),this}updateBinding(e){return this.updateBindings([e])}deleteBindings(e,{isolateShapes:t=!1}={}){const n=e.map(i=>typeof i=="string"?i:i.id);return t?this.store.atomic(()=>{var i,o;for(const s of n){const a=this.getBinding(s);if(!a)continue;const c=this.getBindingUtil(a);(i=c.onBeforeIsolateFromShape)==null||i.call(c,{binding:a,removedShape:this.getShape(a.toId)}),(o=c.onBeforeIsolateToShape)==null||o.call(c,{binding:a,removedShape:this.getShape(a.fromId)}),this.store.remove([s])}}):this.store.remove(n),this}deleteBinding(e,t){return this.deleteBindings([e],t)}canBindShapes({fromShape:e,toShape:t,binding:n}){const i=typeof e=="string"?e:e.type,o=typeof t=="string"?t:t.type,s=typeof n=="string"?n:n.type,a={fromShapeType:i,toShapeType:o,bindingType:s};return i===o?this.getShapeUtil(i).canBind(a):this.getShapeUtil(i).canBind(a)&&this.getShapeUtil(o).canBind(a)}rotateShapesBy(e,t,n){const i=typeof e[0]=="string"?e:e.map(s=>s.id);if(i.length<=0)return this;const o=Eoe({editor:this,ids:i});return o?(lv({delta:t,snapshot:o,editor:this,stage:"one-off",centerOverride:n==null?void 0:n.center}),this):this}getChangesToTranslateShape(e,t){var c,l,d;let n=e;const i=this.getShapeUtil(e),o=(c=i.onTranslateStart)==null?void 0:c.call(i,n);o&&(n=ra(n,o)),n=ra(n,{id:e.id,type:e.type,x:t.x,y:t.y});const s=(l=i.onTranslate)==null?void 0:l.call(i,e,n);s&&(n=ra(n,s));const a=(d=i.onTranslateEnd)==null?void 0:d.call(i,e,n);return a&&(n=ra(n,a)),n}nudgeShapes(e,t){const n=typeof e[0]=="string"?e:e.map(o=>o.id);if(n.length<=0)return this;const i=[];for(const o of n){const s=this.getShape(o),a=T.From(t),c=this.getShapeParentTransform(s);c&&a.rot(-c.rotation()),i.push(this.getChangesToTranslateShape(s,a.add(s)))}return this.updateShapes(i),this}duplicateShapes(e,t){return this.run(()=>{const n=typeof e[0]=="string"?e:e.map(h=>h.id);if(n.length<=0)return this;const i=new Set(n),o=this.getShapeAndDescendantIds(n),s=[...o].reverse(),a=new Map;for(const h of o)a.set(h,Tr());const{shapesToCreateWithOriginals:c,bindingsToCreate:l}=sQ(this,o,h=>{const g=[];for(const y of h){const x=this.getBinding(y);if(!x)continue;const _=Wl();g.push({...x,id:_,fromId:lo(a.get(x.fromId)),toId:lo(a.get(x.toId))})}const m=[];for(const y of s){const x=lo(a.get(y)),_=this.getShape(y);if(!_)continue;let w=0,I=0;if(t&&i.has(y)){const b=this.getShapeParentTransform(_),P=new T(t.x,t.y).rot(-b.rotation());w=P.x,I=P.y}m.push({shape:{..._,id:x,x:_.x+w,y:_.y+I,index:"a1",parentId:a.get(_.parentId)??_.parentId},originalShape:_})}return{shapesToCreateWithOriginals:m,bindingsToCreate:g}});c.forEach(({shape:h,originalShape:g})=>{const m=g.parentId,y=this.getSortedChildIdsForParent(m),x=y.indexOf(g.id),_=y[x+1],w=_?this.getShape(_):void 0,I=mh(g.index,w==null?void 0:w.index);h.index=I});const d=c.map(({shape:h})=>h);if(d.length+this.getCurrentPageShapeIds().size>this.options.maxShapesPerPage){jg(this);return}if(this.createShapes(d),this.createBindings(l),this.setSelectedShapes(Gt(n.map(h=>a.get(h)))),t!==void 0){const h=this.getSelectionPageBounds(),g=this.getViewportPageBounds();h&&!g.contains(h)&&this.centerOnPoint(h.center,{animation:{duration:this.options.animationMediumMs}})}}),this}moveShapesToPage(e,t){const n=typeof e[0]=="string"?e:e.map(a=>a.id);if(n.length===0)return this;if(this.getIsReadonly())return this;const i=this.getCurrentPageId();if(t===i)return this;if(!this.store.has(t))return this;const o=this.getContentFromCurrentPage(n);if(!o)return this;if(this.getPageShapeIds(t).size+o.shapes.length>this.options.maxShapesPerPage)return jg(this,t),this;const s=this.getCamera().z;return this.run(()=>{this.deleteShapes(n),this.setCurrentPage(t),this.setFocusedGroup(null),this.selectNone(),this.putContentOntoCurrentPage(o,{select:!0,preserveIds:!0,preservePosition:!0}),this.setCamera({...this.getCamera(),z:s}),this.centerOnPoint(this.getSelectionRotatedPageBounds().center)}),this}toggleLock(e){const t=typeof e[0]=="string"?e:e.map(s=>s.id);if(this.getIsReadonly()||t.length===0)return this;let n=!0,i=!0;const o=[];for(const s of t){const a=this.getShape(s);a&&(o.push(a),a.isLocked?i=!1:n=!1)}return this.run(()=>{i?(this.updateShapes(o.map(s=>({id:s.id,type:s.type,isLocked:!0}))),this.setSelectedShapes([])):n?this.updateShapes(o.map(s=>({id:s.id,type:s.type,isLocked:!1}))):this.updateShapes(o.map(s=>({id:s.id,type:s.type,isLocked:!0})))}),this}sendToBack(e){const t=typeof e[0]=="string"?e:e.map(i=>i.id),n=Og(this,"toBack",t,{considerAllShapes:!0});return n&&this.updateShapes(n),this}sendBackward(e,t={}){const n=typeof e[0]=="string"?e:e.map(o=>o.id),i=Og(this,"backward",n,t);return i&&this.updateShapes(i),this}bringForward(e,t={}){const n=typeof e[0]=="string"?e:e.map(o=>o.id),i=Og(this,"forward",n,t);return i&&this.updateShapes(i),this}bringToFront(e){const t=typeof e[0]=="string"?e:e.map(i=>i.id),n=Og(this,"toFront",t);return n&&this.updateShapes(n),this}collectShapesViaArrowBindings(e){const{initialShapes:t,resultShapes:n,resultBounds:i,bindings:o,visited:s}=e;for(const a of o)for(const c of[a.fromId,a.toId])if(!s.has(c)){const l=t.find(d=>d.id===c);if(l&&!s.has(l.id)){s.add(l.id);const d=this.getShapePageBounds(l);if(!d)continue;n.push(l),i.push(d),this.collectShapesViaArrowBindings({...e,bindings:this.getBindingsInvolvingShape(l,"arrow")})}}}flipShapes(e,t){if(this.getIsReadonly())return this;const n=typeof e[0]=="string"?e:e.map(c=>c.id),i=Gt(n.map(c=>this.getShape(c)));for(const c of i)if(this.isShapeOfType(c,"group")){const l=Gt(this.getSortedChildIdsForParent(c.id).map(d=>this.getShape(d)));i.push(...l)}const o=[],s=[];for(const c of i){const l=this.getShapeUtil(c);if(!l.canBeLaidOut(c,{type:"flip",shapes:i}))continue;const d=this.getShapePageBounds(c),f=this.getShapeGeometry(c).bounds,h=this.getShapePageTransform(c.id);d&&f&&h&&(o.push({shape:c,localBounds:f,pageTransform:h,isAspectRatioLocked:l.isAspectRatioLocked(c)}),s.push(d))}if(!o.length)return this;const a=He.Common(s).center;return this.run(()=>{for(const{shape:c,localBounds:l,pageTransform:d,isAspectRatioLocked:f}of o)this.resizeShape(c.id,{x:t==="horizontal"?-1:1,y:t==="vertical"?-1:1},{initialBounds:l,initialPageTransform:d,initialShape:c,isAspectRatioLocked:f,mode:"scale_shape",scaleOrigin:a,scaleAxisRotation:0})}),this}stackShapes(e,t,n){var x,_;const i=typeof e[0]=="string"?e:e.map(w=>w.id);if(this.getIsReadonly())return this;const o=Gt(i.map(w=>this.getShape(w))),s=[],a=new Set;for(const w of o){if(a.has(w.id))continue;a.add(w.id);const I=this.getShapePageBounds(w);if(!I||!((_=(x=this.getShapeUtil(w)).canBeLaidOut)!=null&&_.call(x,w,{type:"stack",shapes:o})))continue;const b=[w],P=[I];this.collectShapesViaArrowBindings({bindings:this.getBindingsToShape(w.id,"arrow"),initialShapes:o,resultShapes:b,resultBounds:P,visited:a});const C=He.Common(P);C&&s.push({shapes:b,pageBounds:C})}const c=s.length;if(n===0&&c<3||c<2)return this;let l,d,f,h;t==="horizontal"?(l="x",d="minX",f="maxX",h="width"):(l="y",d="minY",f="maxY",h="height");let g=0;if(n===0){const w={};s.sort((b,P)=>b.pageBounds[d]-P.pageBounds[d]);for(let b=0;b<c-1;b++){const P=s[b],k=s[b+1].pageBounds[d]-P.pageBounds[f];w[k]||(w[k]=0),w[k]++}let I=1;for(const[b,P]of Object.entries(w))P>I&&(I=P,g=parseFloat(b));if(I===1){let b=0;for(const[P,C]of Object.entries(w))g+=parseFloat(P)*C,b+=C;g/=b}}else g=n;const m=[];let y=s[0].pageBounds[f];for(let w=1;w<s.length;w++){const{shapes:I,pageBounds:b}=s[w],P=new T;P[l]=y+g-b[l];for(const C of I){const k=P.clone(),O=this.getShapeParent(C);if(O){const L=this.getShapePageTransform(O);L&&k.rot(-L.rotation())}k.add(C),m.push(this.getChangesToTranslateShape(C,k))}y+=b[h]+g}return this.updateShapes(m),this}packShapes(e,t){var b,P;if(this.getIsReadonly())return this;const n=typeof e[0]=="string"?e:e.map(C=>C.id),i=Gt(n.map(C=>this.getShape(C))),o=[],s=[],a=new Set;for(const C of i){if(a.has(C.id))continue;a.add(C.id);const k=this.getShapePageBounds(C);if(!k||!((P=(b=this.getShapeUtil(C)).canBeLaidOut)!=null&&P.call(b,C,{type:"pack",shapes:i})))continue;const O=[C],L=[k];this.collectShapesViaArrowBindings({bindings:this.getBindingsToShape(C.id,"arrow"),initialShapes:i,resultShapes:O,resultBounds:L,visited:a});const j=He.Common(L);j&&(o.push({shapes:O,pageBounds:j,nextPageBounds:j.clone()}),s.push(j))}if(o.length<2)return this;let c=0;for(const{pageBounds:C}of o)c+=C.width*C.height;const l=He.Common(s),d=l.width;o.sort((C,k)=>C.pageBounds.width-k.pageBounds.width).sort((C,k)=>C.pageBounds.height-k.pageBounds.height);const f=Math.max(Math.ceil(Math.sqrt(c/.95)),d),h=[new He(l.x,l.y,f,1/0)];let g=0,m=0,y,x;for(const{nextPageBounds:C}of o)for(let k=h.length-1;k>=0;k--)if(y=h[k],!(C.width>y.width||C.height>y.height)){C.x=y.x,C.y=y.y,m=Math.max(m,C.maxY),g=Math.max(g,C.maxX),C.width===y.width&&C.height===y.height?(x=h.pop(),k<h.length&&(h[k]=x)):C.height===y.height?(y.x+=C.width+t,y.width-=C.width+t):C.width===y.width?(y.y+=C.height+t,y.height-=C.height+t):(h.push(new He(y.x+(C.width+t),y.y,y.width-(C.width+t),C.height)),y.y+=C.height+t,y.height-=C.height+t);break}const _=He.Common(o.map(C=>C.nextPageBounds)),w=T.Sub(l.center,_.center),I=[];for(const{shapes:C,pageBounds:k,nextPageBounds:O}of o){const L=T.Sub(O.point,k.point).add(w);for(const j of C){const F=L.clone();if(this.getShapeParent(j)){const D=this.getShapeParentTransform(j);D&&F.rot(-D.rotation())}F.add(j),I.push(this.getChangesToTranslateShape(j,F))}}return I.length&&this.updateShapes(I),this}alignShapes(e,t){var d,f;if(this.getIsReadonly())return this;const n=typeof e[0]=="string"?e:e.map(h=>h.id),i=Gt(n.map(h=>this.getShape(h))),o=[],s=[],a=new Set;for(const h of i){if(a.has(h.id))continue;a.add(h.id);const g=this.getShapePageBounds(h);if(!g||!((f=(d=this.getShapeUtil(h)).canBeLaidOut)!=null&&f.call(d,h,{type:"align",shapes:i})))continue;const m=[h],y=[g];this.collectShapesViaArrowBindings({bindings:this.getBindingsToShape(h.id,"arrow"),initialShapes:i,resultShapes:m,resultBounds:y,visited:a});const x=He.Common(y);x&&(o.push({shapes:m,pageBounds:x}),s.push(x))}if(o.length<2)return this;const c=He.Common(s),l=[];return o.forEach(({shapes:h,pageBounds:g})=>{const m=new T;switch(t){case"top":{m.y=c.minY-g.minY;break}case"center-vertical":{m.y=c.midY-g.minY-g.height/2;break}case"bottom":{m.y=c.maxY-g.minY-g.height;break}case"left":{m.x=c.minX-g.minX;break}case"center-horizontal":{m.x=c.midX-g.minX-g.width/2;break}case"right":{m.x=c.maxX-g.minX-g.width;break}}for(const y of h){const x=m.clone(),_=this.getShapeParent(y);if(_){const w=this.getShapePageTransform(_);w&&x.rot(-w.rotation())}x.add(y),l.push(this.getChangesToTranslateShape(y,x))}}),this.updateShapes(l),this}distributeShapes(e,t){var I,b;if(this.getIsReadonly())return this;const n=typeof e[0]=="string"?e:e.map(P=>P.id),i=Gt(n.map(P=>this.getShape(P))),o=[],s=new Set;for(const P of i){if(s.has(P.id))continue;s.add(P.id);const C=this.getShapePageBounds(P);if(!C||!((b=(I=this.getShapeUtil(P)).canBeLaidOut)!=null&&b.call(I,P,{type:"distribute",shapes:i})))continue;const k=[P],O=[C];this.collectShapesViaArrowBindings({bindings:this.getBindingsToShape(P.id,"arrow"),initialShapes:i,resultShapes:k,resultBounds:O,visited:s});const L=He.Common(O);L&&o.push({shapes:k,pageBounds:L})}if(o.length<3)return this;let a,c,l,d;t==="horizontal"?(a="x",c="minX",l="maxX",d="width"):(a="y",c="minY",l="maxY",d="height");const f=[],h=o.sort((P,C)=>P.pageBounds[c]-C.pageBounds[c])[0],g=o.sort((P,C)=>C.pageBounds[l]-P.pageBounds[l])[0];if(h===g){const P=new Set(h.shapes.map(C=>C.id));return this.distributeShapes(n.filter(C=>!P.has(C)),t)}const m=o.filter(P=>P!==h&&P!==g).sort((P,C)=>P.pageBounds[c]===C.pageBounds[c]?P.shapes[0].id<C.shapes[0].id?-1:1:P.pageBounds[c]-C.pageBounds[c]),y=h.pageBounds[l],x=g.pageBounds[c]-y,_=m.reduce((P,C)=>P+C.pageBounds[d],0),w=(x-_)/(m.length+1);for(let P=y+w,C=0;C<m.length;C++){const{shapes:k,pageBounds:O}=m[C],L=new T;L[a]=P-O[a],P+O[d]>g.pageBounds[l]-1&&(L[a]=g.pageBounds[l]-O[l]-1);for(const j of k){const F=L.clone(),$=this.getShapeParent(j);if($){const D=this.getShapePageTransform($);D&&F.rot(-D.rotation())}F.add(j),f.push(this.getChangesToTranslateShape(j,F))}P+=O[d]+w}return this.updateShapes(f),this}stretchShapes(e,t){var h,g;const n=typeof e[0]=="string"?e:e.map(m=>m.id);if(this.getIsReadonly())return this;const i=Gt(n.map(m=>this.getShape(m))).filter(m=>{var y;return((y=this.getShapePageTransform(m))==null?void 0:y.rotation())%(hr/2)===0}),o=[],s=[],a=new Set;for(const m of i){if(a.has(m.id))continue;a.add(m.id);const y=this.getShapePageBounds(m);if(!y)continue;const x=[m],_=[y];if(!((g=(h=this.getShapeUtil(m)).canBeLaidOut)!=null&&g.call(h,m,{type:"stretch",shapes:i})))continue;this.collectShapesViaArrowBindings({bindings:this.getBindingsToShape(m.id,"arrow"),initialShapes:i,resultShapes:x,resultBounds:_,visited:a});const w=He.Common(_);w&&(o.push({shapes:x,pageBounds:w}),s.push(w))}if(o.length<2)return this;const c=He.Common(s);let l,d,f;return t==="horizontal"?(l="x",d="minX",f="width"):(l="y",d="minY",f="height"),this.run(()=>{o.forEach(({shapes:m,pageBounds:y})=>{const x=new T;x[l]=c[d]-y[d];const _=y.center.clone();_[l]=c[d];const w=new T(1,1);w[l]=c[f]/y[f];for(const I of m){const b=x.clone(),P=this.getShapeParentTransform(I);P&&x.rot(-P.rotation()),b.add(I);const C=this.getChangesToTranslateShape(I,b);this.updateShape(C),this.resizeShape(I.id,w,{initialBounds:this.getShapeGeometry(I).bounds,scaleOrigin:_,isAspectRatioLocked:this.getShapeUtil(I).isAspectRatioLocked(I),scaleAxisRotation:0})}})}),this}resizeShape(e,t,n={}){var m,y,x;const i=typeof e=="string"?e:e.id;if(this.getIsReadonly())return this;Uf.Number.isFinite(t.x)||(t=new T(1,t.y)),Uf.Number.isFinite(t.y)||(t=new T(t.x,1));const o=n.initialShape??this.getShape(i);if(!o)return this;const s=n.scaleOrigin??((m=this.getShapePageBounds(i))==null?void 0:m.center);if(!s)return this;const a=n.initialPageTransform?Ke.Cast(n.initialPageTransform):this.getShapePageTransform(i);if(!a)return this;const c=a.rotation();if(c==null)return this;const l=n.scaleAxisRotation??c,d=n.initialBounds??this.getShapeGeometry(i).bounds;if(!d)return this;const f=n.isAspectRatioLocked??this.getShapeUtil(o).isAspectRatioLocked(o);if(!Nee(c,l))return this._resizeUnalignedShape(i,t,{...n,initialBounds:d,scaleOrigin:s,scaleAxisRotation:l,initialPageTransform:a,isAspectRatioLocked:f,initialShape:o});const h=this.getShapeUtil(o);f&&(Math.abs(t.x)>Math.abs(t.y)?t=new T(t.x,Math.sign(t.y)*Math.abs(t.x)):t=new T(Math.sign(t.x)*Math.abs(t.y),t.y));let g=!1;if(h.onResize&&h.canResize(o)){const _=this._scalePagePoint(Ke.applyToPoint(a,new T(0,0)),s,t,l),w=this.getPointInParentSpace(o.id,_),I=new T(t.x,t.y),b=Yc((c-l)%Math.PI,0);I.x=b?t.x:t.y,I.y=b?t.y:t.x;const P=Ke.applyToPoint(a,new T),{x:C,y:k}=this.getPointInParentSpace(o.id,P);let O=o;n.skipStartAndEndCallbacks||(O=ra(o,((y=h.onResizeStart)==null?void 0:y.call(h,o))??void 0));const L=h.onResize({...o,x:C,y:k},{newPoint:w,handle:n.dragHandle??"bottom_right",mode:n.mode??"scale_shape",scaleX:I.x,scaleY:I.y,initialBounds:d,initialShape:o});L&&(g=!0),O=ra(O,{id:i,type:o.type,x:w.x,y:w.y,...L}),n.skipStartAndEndCallbacks||(O=ra(O,((x=h.onResizeEnd)==null?void 0:x.call(h,o,O))??void 0)),this.updateShapes([O])}if(!g){const _=Ke.applyToPoint(a,d.center),w=this._scalePagePoint(_,s,t,l),I=this.getPointInParentSpace(o.id,_),b=this.getPointInParentSpace(o.id,w),P=T.Sub(b,I);this.updateShapes([{id:i,type:o.type,x:o.x+P.x,y:o.y+P.y}])}return this}_scalePagePoint(e,t,n,i){const o=T.RotWith(e,t,-i).sub(t),s=T.MulV(o,n);return T.Add(s,t).rotWith(t,i)}_resizeUnalignedShape(e,t,n){const{type:i}=n.initialShape,o=new T(t.x,t.y);if(Math.abs(t.x)>Math.abs(t.y)?o.x=Math.sign(t.x)*Math.abs(t.y):o.y=Math.sign(t.y)*Math.abs(t.x),this.resizeShape(e,o,{initialShape:n.initialShape,initialBounds:n.initialBounds,isAspectRatioLocked:n.isAspectRatioLocked}),Math.sign(t.x)*Math.sign(t.y)<0){let{rotation:x}=Ke.Decompose(n.initialPageTransform);x-=2*x,this.updateShapes([{id:e,type:i,rotation:x}])}const s=Ke.applyToPoint(n.initialPageTransform,n.initialBounds.center),a=this._scalePagePoint(s,n.scaleOrigin,t,n.scaleAxisRotation),c=this.getShapePageBounds(e),l=this.getShapePageTransform(e),d=c.center,f=l.point();if(!d||!f)return this;const h=T.Sub(a,d),g=T.Add(f,h),{x:m,y}=this.getPointInParentSpace(e,g);return this.updateShapes([{id:e,type:i,x:m,y}]),this}getInitialMetaForShape(e){return{}}createShape(e){return this.createShapes([e]),this}createShapes(e){if(!Array.isArray(e))throw Error("Editor.createShapes: must provide an array of shapes or shape partials");if(this.getIsReadonly())return this;if(e.length<=0)return this;const t=this.getCurrentPageShapeIds();if(e.length+t.size>this.options.maxShapesPerPage)return jg(this),this;const i=this.getFocusedGroupId();return this.run(()=>{var d,f;const o=this.getCurrentPageShapesSorted(),s=e.map(h=>{if(h.id||(h={id:Tr(),...h}),!h.parentId||!(this.store.has(h.parentId)||e.some(g=>g.id===h.parentId))){let g=this.getFocusedGroupId();for(let y=o.length-1;y>=0;y--){const x=o[y];if(!this.isShapeHidden(x)&&this.getShapeUtil(x).canReceiveNewChildrenOfType(x,h.type)&&this.isPointInShape(x,{x:h.x??0,y:h.y??0},{margin:0,hitInside:!0})){g=x.id;break}}const m=h.parentId;if(g===h.id&&(g=i),g!==m&&(h={...h},h.parentId=g,co(g))){const y=this.getPointInShapeSpace(this.getShape(g),{x:h.x??0,y:h.y??0});h.x=y.x,h.y=y.y,h.rotation=-this.getShapePageTransform(g).rotation()+(h.rotation??0)}}return h}),a=new Map,c=[],{opacityForNextShape:l}=this.getInstanceState();for(const h of s){const g=this.getShapeUtil(h);let m=h.index;if(!m){const w=h.parentId??i;a.has(w)||a.set(w,this.getHighestIndexForParent(w)),m=a.get(w),a.set(w,ca(m))}const y=g.getDefaultProps();for(const[w,I]of this.styleProps[h.type])y[I]=this.getStyleForNextShape(w);let x=this.store.schema.types.shape.create({...h,index:m,opacity:h.opacity??l,parentId:h.parentId??i,props:"props"in h?{...y,...h.props}:y});if(x.index===void 0)throw Error("no index!");const _=(f=(d=this.getShapeUtil(x)).onBeforeCreate)==null?void 0:f.call(d,x);_&&(x=_),c.push(x)}c.forEach(h=>{h.meta={...this.getInitialMetaForShape(h),...h.meta}}),this.store.put(c)}),this}animateShape(e,t={animation:rb}){return this.animateShapes([e],t)}animateShapes(e,t={animation:rb}){if(!t.animation)return this;const{duration:n=500,easing:i=zn.linear}=t.animation,o=Er();let s=n,a;const c=[];let l,d;for(let h=0,g=e.length;h<g;h++){if(l=e[h],!l)continue;const m=this.getShape(l.id);m&&(d={start:Kr(m),end:ra(Kr(m),l)},c.push(d),this.animatingShapes.set(m.id,o))}const f=h=>{var x,_;if(s-=h,s<0){const{animatingShapes:w}=this,I=e.filter(b=>b&&w.get(b.id)===o);I.length&&this.updateShapes(I),this.off("tick",f);return}a=i(1-s/n);const{animatingShapes:g}=this,m=[];let y;for(let w=0,I=c.length;w<I;w++){const{start:b,end:P}=c[w];y=g.get(b.id),y===o&&m.push({...P,x:b.x+(P.x-b.x)*a,y:b.y+(P.y-b.y)*a,opacity:b.opacity+(P.opacity-b.opacity)*a,rotation:b.rotation+(P.rotation-b.rotation)*a,props:((_=(x=this.getShapeUtil(P)).getInterpolatedProps)==null?void 0:_.call(x,b,P,a))??P.props})}this._updateShapes(m)};return this.on("tick",f),this}groupShapes(e,t={}){var m;const{groupId:n=Tr(),select:i=!0}=t;if(!Array.isArray(e))throw Error("Editor.groupShapes: must provide an array of shapes or shape ids");if(this.getIsReadonly())return this;const o=typeof e[0]=="string"?e:e.map(y=>y.id);if(o.length<=1)return this;const s=Gt((this._shouldIgnoreShapeLock?o:this._getUnlockedShapeIds(o)).map(y=>this.getShape(y))),a=s.sort(_i).map(y=>y.id),c=He.Common(Gt(s.map(y=>this.getShapePageBounds(y)))),{x:l,y:d}=c.point,f=this.findCommonAncestor(s)??this.getCurrentPageId();if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const h=s.filter(y=>y.parentId===f).sort(_i),g=(m=h[h.length-1])==null?void 0:m.index;return this.run(()=>{this.createShapes([{id:n,type:"group",parentId:f,index:g,x:l,y:d,opacity:1,props:{}}]),this.reparentShapes(a,n),i&&this.select(n)}),this}ungroupShapes(e,t={}){if(this.getIsReadonly())return this;const{select:n=!0}=t,i=typeof e[0]=="string"?e:e.map(c=>c.id),o=Gt((this._shouldIgnoreShapeLock?i:this._getUnlockedShapeIds(i)).map(c=>this.getShape(c)));if(o.length===0)return this;if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const s=new Set,a=[];return o.forEach(c=>{this.isShapeOfType(c,"group")?a.push(c):s.add(c.id)}),a.length===0?this:(this.run(()=>{let c;for(let l=0,d=a.length;l<d;l++){c=a[l];const f=this.getSortedChildIdsForParent(c.id);for(let h=0,g=f.length;h<g;h++)s.add(f[h]);this.reparentShapes(f,c.parentId,c.index)}this.deleteShapes(a.map(l=>l.id)),n&&this.select(...s)}),this)}updateShape(e){return this.updateShapes([e]),this}updateShapes(e){const t=Array(e.length);for(let n=0,i=e.length;n<i;n++){const o=e[n];if(!o)continue;const s=this.getShape(o.id);if(s){if(!this._shouldIgnoreShapeLock){if(s.isLocked){if(!(Object.hasOwn(o,"isLocked")&&!o.isLocked))continue}else if(this.isShapeOrAncestorLocked(s))continue}this.animatingShapes.delete(o.id),t.push(o)}}return this._updateShapes(t),this}_updateShapes(e){this.getIsReadonly()||this.run(()=>{var o,s;const t=[];let n,i;for(let a=0,c=e.length;a<c;a++){const l=e[a];l&&(n=this.getShape(l.id),n&&(i=ra(n,l),i!==n&&(i=((s=(o=this.getShapeUtil(n)).onBeforeUpdate)==null?void 0:s.call(o,n,i))??i,t.push(i))))}this.store.put(t)})}_getUnlockedShapeIds(e){return e.filter(t=>{var n;return!((n=this.getShape(t))!=null&&n.isLocked)})}deleteShapes(e){if(this.getIsReadonly())return this;if(!Array.isArray(e))throw Error("Editor.deleteShapes: must provide an array of shapes or shapeIds");const t=typeof e[0]=="string"?e:e.map(o=>o.id),n=this._shouldIgnoreShapeLock?t:this._getUnlockedShapeIds(t);if(n.length===0)return this;const i=new Set(n);for(const o of n)this.visitDescendants(o,s=>{i.add(s)});return this.run(()=>this.store.remove([...i]))}deleteShape(e){return this.deleteShapes([typeof e=="string"?e:e.id]),this}_extractSharedStyles(e,t){if(this.isShapeOfType(e,"group")){const n=this._parentIdsToChildIds.get()[e.id];if(!n)return;for(let i=0,o=n.length;i<o;i++)this._extractSharedStyles(this.getShape(n[i]),t)}else for(const[n,i]of this.styleProps[e.type])t.applyValue(n,bi(e.props,i))}_getSelectionSharedStyles(){const e=this.getSelectedShapes(),t=new NP;for(const n of e)this._extractSharedStyles(n,t);return t}getStyleForNextShape(e){const t=this.getInstanceState().stylesForNextShape[e.id];return t===void 0?e.defaultValue:t}getShapeStyleIfExists(e,t){const n=this.styleProps[e.type].get(t);if(n!==void 0)return bi(e.props,n)}getSharedStyles(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0)return this._getSelectionSharedStyles();const e=this.root.getCurrent(),t=new NP;if(!e)return t;if(e.shapeType)for(const n of this.styleProps[e.shapeType].keys())t.applyValue(n,this.getStyleForNextShape(n));return t}getSharedOpacity(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0){const e=[],t=i=>{const o=this.getShape(i);if(o)if(this.isShapeOfType(o,"group"))for(const s of this.getSortedChildIdsForParent(o.id))t(s);else e.push(o)};for(const i of this.getSelectedShapeIds())t(i);let n=null;for(const i of e)if(n===null)n=i.opacity;else if(n!==i.opacity)return{type:"mixed"};if(n!==null)return{type:"shared",value:n}}return{type:"shared",value:this.getInstanceState().opacityForNextShape}}setOpacityForNextShapes(e,t){return this.updateInstanceState({opacityForNextShape:e},t),this}setOpacityForSelectedShapes(e){const t=this.getSelectedShapes();if(t.length>0){const n=[],i=o=>{if(this.isShapeOfType(o,"group")){const s=this.getSortedChildIdsForParent(o);for(const a of s)i(this.getShape(a))}else n.push(o)};for(const o of t)i(o);this.updateShapes(n.map(o=>({id:o.id,type:o.type,opacity:e})))}return this}setStyleForNextShapes(e,t,n){const i=this.getInstanceState().stylesForNextShape;return this.updateInstanceState({stylesForNextShape:{...i,[e.id]:t}},n),this}setStyleForSelectedShapes(e,t){const n=this.getSelectedShapes();if(n.length>0){const i=[],o=s=>{if(this.isShapeOfType(s,"group")){const a=this.getSortedChildIdsForParent(s.id);for(const c of a)o(this.getShape(c))}else{const a=this.getShapeUtil(s),c=this.styleProps[s.type].get(e);if(c){const l={id:s.id,type:s.type,props:{[c]:t}};i.push({util:a,originalShape:s,updatePartial:l})}}};for(const s of n)o(s);this.updateShapes(i.map(({updatePartial:s})=>s))}return this}registerExternalAssetHandler(e,t){return this.externalAssetContentHandlers[e]=t,this}createTemporaryAssetPreview(e,t){if(this.temporaryAssetPreview.has(e))return this.temporaryAssetPreview.get(e);const n=URL.createObjectURL(t);return this.temporaryAssetPreview.set(e,n),setTimeout(()=>{this.temporaryAssetPreview.delete(e),URL.revokeObjectURL(n)},this.options.temporaryAssetPreviewLifetimeMs),n}getTemporaryAssetPreview(e){return this.temporaryAssetPreview.get(e)}async getAssetForExternalContent(e){var t,n;return await((n=(t=this.externalAssetContentHandlers)[e.type])==null?void 0:n.call(t,e))}hasExternalAssetHandler(e){return!!this.externalAssetContentHandlers[e]}registerExternalContentHandler(e,t){return this.externalContentHandlers[e]=t,this}async putExternalContent(e){var t,n;return(n=(t=this.externalContentHandlers)[e.type])==null?void 0:n.call(t,e)}getContentFromCurrentPage(e){const t=typeof e[0]=="string"?e:e.map(i=>i.id);if(!t||t.length===0)return;const n=this.getShapeAndDescendantIds(t);return sQ(this,n,i=>{const o=[];for(const d of i){const f=this.getBinding(d);f&&o.push(f)}const s=[],a=[];for(const d of n){const f=this.getShape(d);if(!f)continue;if(!n.has(f.parentId)){const g=this.getShapePageTransform(f.id),m=g.point();a.push({...f,x:m.x,y:m.y,rotation:g.rotation(),parentId:this.getCurrentPageId()}),s.push(f.id)}else a.push(f)}const c=[],l=new Set;for(const d of a){if(!("assetId"in d.props))continue;const f=d.props.assetId;if(!f||l.has(f))continue;l.add(f);const h=this.getAsset(f);h&&c.push(h)}return{schema:this.store.schema.serialize(),shapes:a,rootShapeIds:s,bindings:o,assets:c}})}async resolveAssetsInContent(e){if(!e)return;const t=[];return await Promise.allSettled(e.assets.map(async n=>{var i,o,s;if((n.type==="image"||n.type==="video")&&!((i=n.props.src)!=null&&i.startsWith("data:image"))&&!((o=n.props.src)!=null&&o.startsWith("data:video"))&&!((s=n.props.src)!=null&&s.startsWith("http"))){const a=Kr(n),c=await this.store.props.assets.resolve(n,{screenScale:1,steppedScreenScale:1,dpr:1,networkEffectiveType:null,shouldResolveToOriginal:!0});a.props.src=await ns.blobToDataUrl(await pa(c).then(l=>l.blob())),t.push(a)}else t.push(n)})),e.assets=t,e}putContentOntoCurrentPage(e,t={}){var j,F,$;if(this.getIsReadonly())return this;if(!e.schema)throw Error(`Could not put content:
113
- content is missing a schema.`);const{select:n=!1,preserveIds:i=!1,preservePosition:o=!1}=t;let{point:s=void 0}=t;const a=this.getCurrentPageId(),{rootShapeIds:c}=e,l=[],d=[],f=[],h={store:{...Object.fromEntries(e.assets.map(D=>[D.id,D])),...Object.fromEntries(e.shapes.map(D=>[D.id,D])),...Object.fromEntries(((j=e.bindings)==null?void 0:j.map(D=>[D.id,D]))??[])},schema:e.schema},g=this.store.schema.migrateStoreSnapshot(h);if(g.type==="error")throw Error("Could not put content: could not migrate content");for(const D of Object.values(g.value))switch(D.typeName){case"asset":{l.push(D);break}case"shape":{d.push(D);break}case"binding":{f.push(D);break}}const m=new Map(i?d.map(D=>[D.id,D.id]):d.map(D=>[D.id,Tr()])),y=new Map(i?f.map(D=>[D.id,D.id]):f.map(D=>[D.id,Wl()]));let x=this.getCurrentPageId(),_=1/0,w=[];for(const D of this.getSelectedShapes()){if(_===0)break;const N=this.isShapeOfType(D,"frame"),B=this.getShapeAncestors(D);N&&B.push(D);const W=N?B.length+1:B.length;if(W<_)_=W,w=B,x=N?D.id:D.parentId;else if(W===_){if(w.length!==B.length)throw Error(`Ancestors: ${w.length} !== ${B.length}`);if(w.length===0){x=a;break}else{x=a;for(let G=0;G<w.length&&B[G]===w[G];G++)x=B[G].id}}}let I=!1;if(!oo(x)){const D=this.getShape(x);if(D){if(!this.getViewportPageBounds().includes(this.getShapePageBounds(D)))x=a;else if(c.length===1){const N=d.find(B=>B.id===c[0]);this.isShapeOfType(D,"frame")&&this.isShapeOfType(N,"frame")&&N.props.w===(D==null?void 0:D.props.w)&&N.props.h===(D==null?void 0:D.props.h)&&(I=!0)}}else x=a}I||(I=m.has(x)),I&&(x=this.getShape(x).parentId);let b=this.getHighestIndexForParent(x);const P=[],C=d.map(D=>{const N=m.get(D.id),B={...D,id:N};return c.includes(D.id)&&(B.parentId=a,P.push(B)),m.has(B.parentId)?B.parentId=m.get(D.parentId):(c.push(B.id),B.index=b,b=ca(b)),B});if(C.length+this.getCurrentPageShapeIds().size>this.options.maxShapesPerPage)return jg(this),this;const k=f.map(D=>({...D,id:lo(y.get(D.id)),fromId:lo(m.get(D.fromId)),toId:lo(m.get(D.toId))})),O=[],L=[];for(const D of l)this.store.has(D.id)||((D.type==="image"&&((F=D.props.src)!=null&&F.startsWith("data:image"))||D.type==="video"&&(($=D.props.src)!=null&&$.startsWith("data:video")))&&(L.push(Kr(D)),D.props.src=null),O.push(D));return Promise.allSettled(L.map(async D=>{const N=await hAe(D.props.src,D.props.name,D.props.mimeType??"image/png"),B=await this.getAssetForExternalContent({type:"file",file:N,assetId:D.id});if(!B){this.deleteAssets([D.id]);return}this.updateAssets([{...B,id:D.id}])})),this.run(()=>{O.length>0&&this.createAssets(O),this.createShapes(C),this.createBindings(k),n&&this.select(...P.map(G=>G.id)),x!==a&&this.reparentShapes(P.map(G=>G.id),x);const D=C.map(G=>this.getShape(G.id)),N=He.Common(D.map(G=>this.getShapePageBounds(G)));if(s===void 0)if(oo(x)){const G=this.getViewportPageBounds();o||G.includes(He.From(N))?s=N.center:s=G.center}else{const G=this.getShape(x);s=Ke.applyToPoint(this.getShapePageTransform(G),this.getShapeGeometry(G).bounds.center)}if(P.length===1){const G=P[0];if(this.isShapeOfType(G,"frame"))for(;this.getShapesAtPoint(s).some(z=>this.isShapeOfType(z,"frame")&&z.props.w===G.props.w&&z.props.h===G.props.h);)s.x+=N.w+16}const B=He.Common(Gt(P.map(({id:G})=>this.getShapePageBounds(G)))).center,W=T.Sub(s,B);this.updateShapes(P.map(({id:G})=>{const z=this.getShape(G),V=this.getShapeParentTransform(G).decompose().rotation,J=T.Rot(W,-V);return{id:z.id,type:z.type,x:z.x+J.x,y:z.y+J.y}}))}),this}async getSvgElement(e,t={}){const n=e.length===0?this.getCurrentPageShapeIdsSorted():typeof e[0]=="string"?e:e.map(i=>i.id);if(n.length!==0)return iAe(this,n,t)}async getSvgString(e,t={}){const n=await this.getSvgElement(e,t);return n?{svg:new XMLSerializer().serializeToString(n.svg),width:n.width,height:n.height}:void 0}async getSvg(e,t={}){const n=await this.getSvgElement(e,t);if(n)return n.svg}async toImage(e,t={}){const n={format:"png",scale:1,pixelRatio:t.format==="svg"?void 0:2,...t},i=await this.getSvgString(e,n);if(!i)throw new Error("Could not create SVG");switch(n.format){case"svg":return{blob:new Blob([i.svg],{type:"image/svg+xml"}),width:i.width,height:i.height};case"jpeg":case"png":case"webp":{const o=await uAe(i.svg,{type:n.format,quality:n.quality,pixelRatio:n.pixelRatio,width:i.width,height:i.height});if(!o)throw new Error("Could not construct image.");return{blob:o,width:i.width,height:i.height}}default:An(n.format)}}_updateInputsFromEvent(e){const{pointerVelocity:t,previousScreenPoint:n,previousPagePoint:i,currentScreenPoint:o,currentPagePoint:s}=this.inputs,{screenBounds:a}=this.store.unsafeGetWithoutCapture(Bi),{x:c,y:l,z:d}=xg(()=>this.getCamera()),f=e.point.x-a.x,h=e.point.y-a.y,g=e.point.z??.5;n.setTo(o),i.setTo(s),o.set(f,h);const m=f/d-c,y=h/d-l;isFinite(m)&&isFinite(y)&&s.set(m,y,g),this.inputs.isPen=e.type==="pointer"&&e.isPen,(e.name==="pointer_down"||this.inputs.isPinching)&&(t.set(0,0),this.inputs.originScreenPoint.setTo(o),this.inputs.originPagePoint.setTo(s)),this.run(()=>{var x;this.store.put([{id:Qv,typeName:"pointer",x:s.x,y:s.y,lastActivityTimestamp:e.type==="pointer"&&e.pointerId===rD.CAMERA_MOVE?((x=this.store.unsafeGetWithoutCapture(Qv))==null?void 0:x.lastActivityTimestamp)??this._tickManager.now:this._tickManager.now,meta:{}}])},{history:"ignore"})}cancel(){return this.dispatch({type:"misc",name:"cancel"}),this}interrupt(){return this.dispatch({type:"misc",name:"interrupt"}),this}complete(){return this.dispatch({type:"misc",name:"complete"}),this}focus({focusContainer:e=!0}={}){return this.getIsFocused()?this:(e&&this.focusManager.focus(),this.updateInstanceState({isFocused:!0}),this)}blur({blurContainer:e=!0}={}){return this.getIsFocused()?(e?this.focusManager.blur():this.complete(),this.updateInstanceState({isFocused:!1}),this):this}getIsFocused(){return this.getInstanceState().isFocused}getIsReadonly(){return this.getInstanceState().isReadonly}getSnapshot(){return cTe(this.store)}loadSnapshot(e,t){return Qie(this.store,e,t),this}_zoomToFitPageContentAt100Percent(){const e=this.getCurrentPageBounds();e&&this.zoomToBounds(e,{immediate:!0,targetZoom:this.getBaseZoom()})}_navigateToDeepLink(e){this.run(()=>{switch(e.type){case"page":{const t=this.getPage(e.pageId);t&&this.setCurrentPage(t),this._zoomToFitPageContentAt100Percent();return}case"shapes":{const t=Gt(e.shapeIds.map(s=>this.getShape(s))),n={};for(const s of t){const a=this.getAncestorPageId(s);a&&(n[a]??(n[a]=[]),n[a].push(s))}const[i,o]=Object.entries(n).sort(([s,a],[c,l])=>l.length-a.length)[0]??["",[]];if(!i||!o.length)this._zoomToFitPageContentAt100Percent();else{this.setCurrentPage(i);const s=He.Common(o.map(a=>this.getShapePageBounds(a)));this.zoomToBounds(s,{immediate:!0,targetZoom:this.getBaseZoom()})}return}case"viewport":{if(e.pageId){if(!this.getPage(e.pageId)){this._zoomToFitPageContentAt100Percent();return}this.setCurrentPage(e.pageId)}this.zoomToBounds(e.bounds,{immediate:!0,inset:0});return}default:An(e)}})}navigateToDeepLink(e){if(e&&"type"in e)return this._navigateToDeepLink(e),this;const n=new URL((e==null?void 0:e.url)??window.location.href).searchParams.get((e==null?void 0:e.param)??"d");if(!n)return this._zoomToFitPageContentAt100Percent(),this;try{this._navigateToDeepLink(vAe(n))}catch(i){console.warn(i),this._zoomToFitPageContentAt100Percent()}return this}createDeepLink(e){const t=new URL((e==null?void 0:e.url)??window.location.href);return t.searchParams.set((e==null?void 0:e.param)??"d",gAe((e==null?void 0:e.to)??{type:"viewport",pageId:this.options.maxPages===1?void 0:this.getCurrentPageId(),bounds:this.getViewportPageBounds()})),t}registerDeepLinkListener(e){if(e!=null&&e.getUrl&&!(e!=null&&e.onChange))throw Error("[tldraw:urlStateSync] If you specify getUrl, you must also specify the onChange callback.");const t=Te("url with state",()=>{var c,l;const s=((c=e==null?void 0:e.getUrl)==null?void 0:c.call(e,this))??window.location.href;return this.createDeepLink({param:e==null?void 0:e.param,url:s,to:(l=e==null?void 0:e.getTarget)==null?void 0:l.call(e,this)}).toString()}),n=(e==null?void 0:e.onChange)??(()=>{var a;const s=this.createDeepLink({param:e==null?void 0:e.param,to:(a=e==null?void 0:e.getTarget)==null?void 0:a.call(e,this)});window.history.replaceState({},document.title,s.toString())}),i=kC(s=>s(),(e==null?void 0:e.debounceMs)??500),o=fa("update url on state change",()=>n(new URL(t.get()),this),{scheduleEffect:i});return()=>{o(),i.cancel()}}cancelDoubleClick(){this._clickManager.cancelDoubleClickTimeout()}_setShiftKeyTimeout(){this.inputs.shiftKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Shift",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,metaKey:this.inputs.metaKey,accelKey:wi(this.inputs),code:"ShiftLeft"})}_setAltKeyTimeout(){this.inputs.altKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Alt",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,metaKey:this.inputs.metaKey,accelKey:wi(this.inputs),code:"AltLeft"})}_setCtrlKeyTimeout(){this.inputs.ctrlKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Ctrl",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,metaKey:this.inputs.metaKey,accelKey:wi(this.inputs),code:"ControlLeft"})}_setMetaKeyTimeout(){this.inputs.metaKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Meta",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,metaKey:this.inputs.metaKey,accelKey:wi(this.inputs),code:"MetaLeft"})}dispatch(e){return this._pendingEventsForNextTick.push(e),e.type==="pointer"&&e.name==="pointer_move"||e.type==="wheel"||e.type==="pinch"||this._flushEventsForTick(0),this}_flushEventsForTick(e){this.run(()=>{if(this._pendingEventsForNextTick.length>0){const t=[...this._pendingEventsForNextTick];this._pendingEventsForNextTick.length=0;for(const n of t)this._flushEventForTick(n)}e>0&&this.root.handleEvent({type:"misc",name:"tick",elapsed:e}),this.scribbles.tick(e)})}_flushEventForTick(e){if(this.getCrashingError())return this;this.emit("before-event",e);const{inputs:t}=this,{type:n}=e;if(e.type==="misc"){(e.name==="cancel"||e.name==="complete")&&(this.inputs.isDragging=!1,this.inputs.isPanning&&(this.inputs.isPanning=!1,this.inputs.isSpacebarPanning=!1,this.setCursor({type:this._prevCursor,rotation:0}))),this.root.handleEvent(e);return}e.shiftKey?(clearTimeout(this._shiftKeyTimeout),this._shiftKeyTimeout=-1,t.shiftKey=!0):!e.shiftKey&&t.shiftKey&&this._shiftKeyTimeout===-1&&(this._shiftKeyTimeout=this.timers.setTimeout(this._setShiftKeyTimeout,150)),e.altKey?(clearTimeout(this._altKeyTimeout),this._altKeyTimeout=-1,t.altKey=!0):!e.altKey&&t.altKey&&this._altKeyTimeout===-1&&(this._altKeyTimeout=this.timers.setTimeout(this._setAltKeyTimeout,150)),e.ctrlKey?(clearTimeout(this._ctrlKeyTimeout),this._ctrlKeyTimeout=-1,t.ctrlKey=!0):!e.ctrlKey&&t.ctrlKey&&this._ctrlKeyTimeout===-1&&(this._ctrlKeyTimeout=this.timers.setTimeout(this._setCtrlKeyTimeout,150)),e.metaKey?(clearTimeout(this._metaKeyTimeout),this._metaKeyTimeout=-1,t.metaKey=!0):!e.metaKey&&t.metaKey&&this._metaKeyTimeout===-1&&(this._metaKeyTimeout=this.timers.setTimeout(this._setMetaKeyTimeout,150));const{originPagePoint:i,currentPagePoint:o}=t;t.isPointing||(t.isDragging=!1);const s=this.store.unsafeGetWithoutCapture(Bi),a=this.store.get(this._getCurrentPageStateId()),c=this._cameraOptions.__unsafe__getWithoutCapture();switch(n){case"pinch":{if(c.isLocked)return;switch(clearTimeout(this._longPressTimeout),this._updateInputsFromEvent(e),e.name){case"pinch_start":{if(t.isPinching)return;t.isEditing||(this._pinchStart=this.getCamera().z,this._selectedShapeIdsAtPointerDown.length||(this._selectedShapeIdsAtPointerDown=[...a.selectedShapeIds]),this._didPinch=!0,t.isPinching=!0,this.interrupt());return}case"pinch":{if(!t.isPinching)return;const{point:{z:l=1},delta:{x:d,y:f}}=e,{x:h,y:g}=T.SubXY(e.point,s.screenBounds.x,s.screenBounds.y);this.stopCameraAnimation(),s.followingUserId&&this.stopFollowingUser();const{x:m,y,z:x}=xg(()=>this.getCamera()),{panSpeed:_,zoomSpeed:w}=c;this._setCamera(new T(m+d*_/x-h/x+h/(l*w),y+f*_/x-g/x+g/(l*w),l*w),{immediate:!0});return}case"pinch_end":{if(!t.isPinching)return this;t.isPinching=!1;const{_selectedShapeIdsAtPointerDown:l}=this;this.setSelectedShapes(this._selectedShapeIdsAtPointerDown),this._selectedShapeIdsAtPointerDown=[],this._didPinch&&(this._didPinch=!1,l.length>0&&this.once("tick",()=>{this._didPinch||this.setSelectedShapes(l)}));return}}}case"wheel":{if(c.isLocked)return;this._updateInputsFromEvent(e);const{panSpeed:l,zoomSpeed:d,wheelBehavior:f}=c;if(f!=="none"){this.stopCameraAnimation(),s.followingUserId&&this.stopFollowingUser();const{x:h,y:g,z:m}=xg(()=>this.getCamera()),{x:y,y:x,z:_=0}=e.delta;let w=f;switch(t.ctrlKey&&(w=f==="pan"?"zoom":"pan"),w){case"zoom":{const{x:I,y:b}=this.inputs.currentScreenPoint;let P=_;f==="zoom"&&(Math.abs(x)>10?P=10*Math.sign(x)/100:P=x/100);const C=m+(P??0)*d*m;this._setCamera(new T(h+(I/C-I)-(I/m-I),g+(b/C-b)-(b/m-b),C),{immediate:!0}),this.maybeTrackPerformance("Zooming");return}case"pan":{this._setCamera(new T(h+y*l/m,g+x*l/m,m),{immediate:!0}),this.maybeTrackPerformance("Panning");return}}}break}case"pointer":{if(t.isPinching)return;this._updateInputsFromEvent(e);const{isPen:l}=e,{isPenMode:d}=s;switch(e.name){case"pointer_down":{if(d&&!l)return;if(this.inputs.isPanning||(this._longPressTimeout=this.timers.setTimeout(()=>{const f=this.getViewportScreenBounds();this.dispatch({...e,point:this.inputs.originScreenPoint.clone().addXY(f.x,f.y),name:"long_press"})},this.options.longPressDurationMs)),this._selectedShapeIdsAtPointerDown=this.getSelectedShapeIds(),e.button===nD&&(this.capturedPointerId=e.pointerId),t.buttons.add(e.button),t.isPointing=!0,t.isDragging=!1,!d&&l&&this.updateInstanceState({isPenMode:!0}),e.button===iD?(this._restoreToolId=this.getCurrentToolId(),this.complete(),this.setCurrentTool("eraser")):e.button===Cg&&(this.inputs.isPanning||(this._prevCursor=this.getInstanceState().cursor.type),this.inputs.isPanning=!0,clearTimeout(this._longPressTimeout)),this.inputs.isPanning)return this.stopCameraAnimation(),this.setCursor({type:"grabbing",rotation:0}),this;break}case"pointer_move":{if(!l&&d)return;const{x:f,y:h,z:g}=xg(()=>this.getCamera());if(this.inputs.isPanning&&this.inputs.isPointing){const{currentScreenPoint:m,previousScreenPoint:y}=this.inputs,{panSpeed:x}=c,_=T.Sub(m,y);this.setCamera(new T(f+_.x*x/g,h+_.y*x/g,g),{immediate:!0}),this.maybeTrackPerformance("Panning");return}t.isPointing&&!t.isDragging&&T.Dist2(i,o)*this.getZoomLevel()>(s.isCoarsePointer?this.options.coarseDragDistanceSquared:this.options.dragDistanceSquared)/g&&(t.isDragging=!0,clearTimeout(this._longPressTimeout));break}case"pointer_up":{if(t.isDragging=!1,t.isPointing=!1,clearTimeout(this._longPressTimeout),t.buttons.delete(e.button),s.isPenMode&&!l)return;if(this.capturedPointerId===e.pointerId&&(this.capturedPointerId=null,e.button=0),t.isPanning){t.keys.has("Space")||(t.isPanning=!1,t.isSpacebarPanning=!1);const f=this.inputs.pointerVelocity,h=Math.min(2,f.len());switch(e.button){case nD:{this.setCursor({type:"grab",rotation:0});break}case Cg:this.inputs.keys.has(" ")?this.setCursor({type:"grab",rotation:0}):this.setCursor({type:this._prevCursor,rotation:0})}h>0&&this.slideCamera({speed:h,direction:f})}else e.button===iD&&(this.complete(),this.setCurrentTool(this._restoreToolId));break}}break}case"keyboard":{switch(e.key==="ShiftRight"&&(e.key="ShiftLeft"),e.key==="AltRight"&&(e.key="AltLeft"),e.code==="ControlRight"&&(e.code="ControlLeft"),e.code==="MetaRight"&&(e.code="MetaLeft"),e.name){case"key_down":{if(t.keys.add(e.code),e.code==="Space"&&!e.ctrlKey&&(this.inputs.isPanning||(this._prevCursor=s.cursor.type),this.inputs.isPanning=!0,this.inputs.isSpacebarPanning=!0,clearTimeout(this._longPressTimeout),this.setCursor({type:this.inputs.isPointing?"grabbing":"grab",rotation:0})),this.inputs.isSpacebarPanning){let l;switch(e.code){case"ArrowUp":{l=new T(0,-1);break}case"ArrowRight":{l=new T(1,0);break}case"ArrowDown":{l=new T(0,1);break}case"ArrowLeft":{l=new T(-1,0);break}}if(l){const d=this.getViewportPageBounds(),f=d.clone().translate(l.mulV({x:d.w,y:d.h}));this._animateToViewport(f,{animation:{duration:320}})}}break}case"key_up":{t.keys.delete(e.code),e.code==="Space"&&(this.inputs.buttons.has(Cg)||(this.inputs.isPanning=!1,this.inputs.isSpacebarPanning=!1,this.setCursor({type:this._prevCursor,rotation:0})));break}}break}}if(e.type==="pointer"){e.button===Cg?e.name="middle_click":e.button===mT&&(e.name="right_click");const{isPenMode:l}=this.store.unsafeGetWithoutCapture(Bi);if(e.isPen===l){const d=this._clickManager.handlePointerEvent(e);if(e.name!==d.name){this.root.handleEvent(e),this.emit("event",e),this.root.handleEvent(d),this.emit("event",d);return}}}return this.root.handleEvent(e),this.emit("event",e),e.type==="pointer"&&e.name==="pointer_down"&&this.menus.clearOpenMenus(),this}maybeTrackPerformance(e){yn.measurePerformance.get()&&(this.performanceTracker.isStarted()?clearTimeout(this.performanceTrackerTimeout):this.performanceTracker.start(e),this.performanceTrackerTimeout=this.timers.setTimeout(()=>{this.performanceTracker.stop()},50))}}nt=NRe(qP);ot(nt,1,"getIsShapeHiddenCache",Yae,rt);ot(nt,1,"getCanUndo",Vae,rt);ot(nt,1,"getCanRedo",Gae,rt);ot(nt,1,"getPath",Kae,rt);ot(nt,1,"getCurrentTool",Wae,rt);ot(nt,1,"getCurrentToolId",Hae,rt);ot(nt,1,"getDocumentSettings",zae,rt);ot(nt,1,"getInstanceState",Uae,rt);ot(nt,1,"getOpenMenus",Bae,rt);ot(nt,1,"getIsMenuOpen",qae,rt);ot(nt,1,"getPageStates",$ae,rt);ot(nt,1,"_getPageStatesQuery",Nae,rt);ot(nt,1,"getCurrentPageState",Fae,rt);ot(nt,1,"_getCurrentPageStateId",Lae,rt);ot(nt,1,"getSelectedShapeIds",Dae,rt);ot(nt,1,"getSelectedShapes",jae,rt);ot(nt,1,"getOnlySelectedShapeId",Mae,rt);ot(nt,1,"getOnlySelectedShape",Oae,rt);ot(nt,1,"getSelectionPageBounds",kae,rt);ot(nt,1,"getSelectionRotation",Rae,rt);ot(nt,1,"getSelectionRotatedPageBounds",Aae,rt);ot(nt,1,"getSelectionRotatedScreenBounds",Tae,rt);ot(nt,1,"getFocusedGroupId",Cae,rt);ot(nt,1,"getFocusedGroup",Pae,rt);ot(nt,1,"getEditingShapeId",Iae,rt);ot(nt,1,"getEditingShape",Eae,rt);ot(nt,1,"getHoveredShapeId",bae,rt);ot(nt,1,"getHoveredShape",wae,rt);ot(nt,1,"getHintingShapeIds",_ae,rt);ot(nt,1,"getHintingShape",xae,rt);ot(nt,1,"getErasingShapeIds",Sae,rt);ot(nt,1,"getErasingShapes",yae,rt);ot(nt,1,"_unsafe_getCameraId",mae,rt);ot(nt,1,"getCamera",vae,rt);ot(nt,1,"getViewportPageBoundsForFollowing",gae,rt);ot(nt,1,"getCameraForFollowing",pae,rt);ot(nt,1,"getZoomLevel",hae,rt);ot(nt,1,"getViewportScreenBounds",fae,rt);ot(nt,1,"getViewportScreenCenter",dae,rt);ot(nt,1,"getViewportPageBounds",uae,rt);ot(nt,1,"_getCollaboratorsQuery",lae,rt);ot(nt,1,"getCollaborators",cae,rt);ot(nt,1,"getCollaboratorsOnCurrentPage",aae,rt);ot(nt,1,"getRenderingShapes",sae,rt);ot(nt,1,"_getAllPagesQuery",oae,rt);ot(nt,1,"getPages",iae,rt);ot(nt,1,"getCurrentPageId",nae,rt);ot(nt,1,"getCurrentPageShapeIdsSorted",rae,rt);ot(nt,1,"_getAllAssetsQuery",tae,rt);ot(nt,1,"_getShapeHandlesCache",eae,rt);ot(nt,1,"_getShapePageTransformCache",Jse,rt);ot(nt,1,"_getShapePageBoundsCache",Qse,rt);ot(nt,1,"_getShapeClipPathCache",Zse,rt);ot(nt,1,"_getShapeMaskCache",Xse,rt);ot(nt,1,"_getShapeMaskedPageBoundsCache",Yse,rt);ot(nt,1,"_notVisibleShapes",Vse,rt);ot(nt,1,"getCulledShapes",Gse,rt);ot(nt,1,"getCurrentPageBounds",Kse,rt);ot(nt,1,"getCurrentPageShapes",Wse,rt);ot(nt,1,"getCurrentPageShapesSorted",Hse,rt);ot(nt,1,"getCurrentPageRenderingShapesSorted",zse,rt);ot(nt,1,"_getBindingsIndexCache",Use,rt);ot(nt,1,"_getSelectionSharedStyles",Bse,rt);ot(nt,1,"getSharedStyles",qse,rt);ot(nt,1,"getSharedOpacity",$se,rt);ot(nt,1,"getIsFocused",Nse,rt);ot(nt,1,"getIsReadonly",Fse,rt);ot(nt,1,"_setShiftKeyTimeout",Lse,rt);ot(nt,1,"_setAltKeyTimeout",Dse,rt);ot(nt,1,"_setCtrlKeyTimeout",jse,rt);ot(nt,1,"_setMetaKeyTimeout",Mse,rt);qRe(nt,rt);function jg(r,e=r.getCurrentPageId()){const t=r.getPage(e).name;r.emit("max-shapes",{name:t,pageId:e,count:r.options.maxShapesPerPage})}function ra(r,e){if(!e)return r;let t=null;const n=Object.entries(e);for(let i=0,o=n.length;i<o;i++){const[s,a]=n[i];if(a!==void 0&&!(s==="id"||s==="type"||s==="typeName")&&a!==r[s]){if(t||(t={...r}),s==="props"||s==="meta"){t[s]={...r[s]};for(const[c,l]of Object.entries(a))t[s][c]=l;continue}t[s]=a}}return t||r}function Xae(r,e,t){const n=r.getShape(e);if(!n)return;t.push(n);const i=r.getSortedChildIdsForParent(e);for(let o=0,s=i.length;o<s;o++)Xae(r,i[o],t)}function sQ(r,e,t){let n;if(r.run(()=>{const i=r.store.extractingChanges(()=>{const o=new Set,s=new Set;for(const a of e)if(r.getShape(a))for(const l of r.getBindingsInvolvingShape(a)){const d=e.has(l.fromId),f=e.has(l.toId);if(d&&f){o.add(l.id);continue}(!d||!f)&&s.add(l.id)}r.deleteBindings([...s],{isolateShapes:!0});try{n=qi.ok(t(o))}catch(a){n=qi.err(a)}});r.store.applyDiff(IP(i),{runCallbacks:!1})},{history:"ignore"}),n.ok)return n.value;throw n.error}function aQ(r,e){if(!e.constraints)throw Error("Should have constraints here");const{padding:{x:t,y:n}}=e.constraints,i=r.getViewportScreenBounds(),o=He.From(e.constraints.bounds),s=(i.w-t*2)/o.w,a=(i.h-n*2)/o.h;return{zx:s,zy:a}}function lp(){const r=he(),e=op();return ye("isDarkMode",()=>(e==null?void 0:e.isDarkMode)??r.user.getIsDarkMode(),[e,r])}const cQ="<path d='m19.7432 17.0869-4.072 4.068 2.829 2.828-8.473-.013-.013-8.47 2.841 2.842 4.075-4.068 1.414-1.415-2.844-2.842h8.486v8.484l-2.83-2.827z' fill='%23fff'/><path d='m18.6826 16.7334-4.427 4.424 1.828 1.828-5.056-.016-.014-5.054 1.842 1.841 4.428-4.422 2.474-2.475-1.844-1.843h5.073v5.071l-1.83-1.828z' fill='%23000'/>",lQ="<path d='m9 17.9907v.005l5.997 5.996.001-3.999h1.999 2.02v4l5.98-6.001-5.98-5.999.001 4.019-2.021.002h-2l.001-4.022zm1.411.003 3.587-3.588-.001 2.587h3.5 2.521v-2.585l3.565 3.586-3.564 3.585-.001-2.585h-2.521l-3.499-.001-.001 2.586z' fill='%23fff'/><path d='m17.4971 18.9932h2.521v2.586l3.565-3.586-3.565-3.585v2.605h-2.521-3.5v-2.607l-3.586 3.587 3.586 3.586v-2.587z' fill='%23000'/>",Dg='<path d="M22.4789 9.45728L25.9935 12.9942L22.4789 16.5283V14.1032C18.126 14.1502 14.6071 17.6737 14.5675 22.0283H17.05L13.513 25.543L9.97889 22.0283H12.5674C12.6071 16.5691 17.0214 12.1503 22.4789 12.1031L22.4789 9.45728Z" fill="black"/><path fill-rule="evenodd" clip-rule="evenodd" d="M21.4789 7.03223L27.4035 12.9945L21.4789 18.9521V15.1868C18.4798 15.6549 16.1113 18.0273 15.649 21.0284H19.475L13.5128 26.953L7.55519 21.0284H11.6189C12.1243 15.8155 16.2679 11.6677 21.4789 11.1559L21.4789 7.03223ZM22.4789 12.1031C17.0214 12.1503 12.6071 16.5691 12.5674 22.0284H9.97889L13.513 25.543L17.05 22.0284H14.5675C14.5705 21.6896 14.5947 21.3558 14.6386 21.0284C15.1157 17.4741 17.9266 14.6592 21.4789 14.1761C21.8063 14.1316 22.1401 14.1069 22.4789 14.1032V16.5284L25.9935 12.9942L22.4789 9.45729L22.4789 12.1031Z" fill="white"/>';function Nc(r,e,t,n,i,o=16,s=16){const a=(-t-e)*(hr/180),c=Math.sin(a),l=Math.cos(a),d=1*l-1*c,f=1*c+1*l;return`url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: ${i};'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='${d}' dy='${f}' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(${e+t} 16 16)${n?" scale(-1,-1) translate(0, -32)":""}' filter='url(%23shadow)'>`+r.replaceAll('"',"'")+`</g></svg>") ${o} ${s}, pointer`}const URe=["default","pointer","cross","move","grab","grabbing","text","zoom-in","zoom-out"],zRe={none:()=>"none","ew-resize":(r,e,t)=>Nc(lQ,r,0,e,t),"ns-resize":(r,e,t)=>Nc(lQ,r,90,e,t),"nesw-resize":(r,e,t)=>Nc(cQ,r,0,e,t),"nwse-resize":(r,e,t)=>Nc(cQ,r,90,e,t),"nwse-rotate":(r,e,t)=>Nc(Dg,r,0,e,t),"nesw-rotate":(r,e,t)=>Nc(Dg,r,90,e,t),"senw-rotate":(r,e,t)=>Nc(Dg,r,180,e,t),"swne-rotate":(r,e,t)=>Nc(Dg,r,270,e,t)};function Po(r,e=0,t="black"){return zRe[r](Zve(e),!1,t)}function HRe(){const r=he(),e=Ln(),t=lp();Vc("useCursor",()=>{const{type:n,rotation:i}=r.getInstanceState().cursor;if(URe.includes(n)){e.style.setProperty("--tl-cursor",`var(--tl-cursor-${n})`);return}e.style.setProperty("--tl-cursor",Po(n,i,t?"white":"black"))},[r,e,t])}function WRe(){const r=he(),e=Ln(),t=lp(),n=ye(yn.forceSrgb);lr.useEffect(()=>{t?(e.setAttribute("data-color-mode","dark"),e.classList.remove("tl-theme__light"),e.classList.add("tl-theme__dark")):(e.setAttribute("data-color-mode","light"),e.classList.remove("tl-theme__dark"),e.classList.add("tl-theme__light")),n?e.classList.add("tl-theme__force-sRGB"):e.classList.remove("tl-theme__force-sRGB")},[r,e,n,t])}function KRe(){const[r,e]=A.useState(0);A.useEffect(()=>e(t=>t+1),[])}const GRe=r=>r.props.src,VRe={upload:async(r,e)=>({src:await ns.blobToDataUrl(e)})};function YRe(r){return"schema"in r&&r.schema?r.schema:Dye({shapes:"shapeUtils"in r&&r.shapeUtils?uQ(roe(r.shapeUtils)):void 0,bindings:"bindingUtils"in r&&r.bindingUtils?uQ(eoe(r.bindingUtils)):void 0,migrations:"migrations"in r?r.migrations:void 0})}function wh({initialData:r,defaultName:e="",id:t,assets:n=VRe,onMount:i,collaboration:o,...s}={}){const a=YRe(s),c=new nT({id:t,schema:a,initialData:r,props:{defaultName:e,assets:{upload:n.upload,resolve:n.resolve??GRe},onMount:l=>{Jt(l instanceof rt),i==null||i(l)},collaboration:o}});if(s.snapshot){if(r)throw new Error("Cannot provide both initialData and snapshot");Qie(c,s.snapshot,{forceOverwriteSessionState:!0})}return c}function uQ(r){return Object.fromEntries(r.map(e=>[e.type,{props:e.props,migrations:e.migrations}]))}function XRe(){window.alert(`Oops! We could not save changes to your browser's storage. We now need to reload the page and try again.
114
-
115
- Keep seeing this message?
116
- • If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.
117
- • If your hard disk is full, try clearing up some space and then reload the page.`)}function ZRe(){window.alert(`Oops! We could not access your browser's storage—and the app won't work correctly without that. We now need to reload the page and try again.
118
-
119
- Keep seeing this message?
120
- • If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.`)}const QRe=350,JRe=1e4,dQ=Symbol("UPDATE_INSTANCE_STATE"),e2e=r=>r;class t2e{constructor(e){q(this,"onmessage")}postMessage(e){}close(){}}const r2e=typeof BroadcastChannel>"u"?t2e:BroadcastChannel;class n2e{constructor(e,{persistenceKey:t,sessionId:n=im,onLoad:i,onLoadError:o},s=new r2e(`tldraw-tab-sync-${t}`)){q(this,"disposables",new Set);q(this,"diffQueue",[]);q(this,"didDispose",!1);q(this,"shouldDoFullDBWrite",!0);q(this,"isReloading",!1);q(this,"persistenceKey");q(this,"sessionId");q(this,"serializedSchema");q(this,"isDebugging",!1);q(this,"documentTypes");q(this,"$sessionStateSnapshot");q(this,"db");q(this,"initTime",Date.now());q(this,"isPersisting",!1);q(this,"didLastWriteError",!1);q(this,"scheduledPersistTimeout",null);this.store=e,this.channel=s,typeof window<"u"&&(window.tlsync=this),this.persistenceKey=t,this.sessionId=n,this.db=new zv(t),this.disposables.add(()=>this.db.close()),this.serializedSchema=this.store.schema.serialize(),this.$sessionStateSnapshot=nA(this.store),this.disposables.add(e.listen(({changes:a})=>{this.diffQueue.push(a),this.channel.postMessage(e2e({type:"diff",storeId:this.store.id,changes:a,schema:this.serializedSchema})),this.schedulePersist()},{source:"user",scope:"document"})),this.disposables.add(e.listen(()=>{this.diffQueue.push(dQ),this.schedulePersist()},{scope:"session"})),this.connect(i,o),this.documentTypes=new Set(Object.values(this.store.schema.types).filter(a=>a.scope==="document").map(a=>a.typeName))}debug(...e){this.isDebugging&&console.debug(...e)}async connect(e,t){this.debug("connecting");let n;try{n=await this.db.load({sessionId:this.sessionId})}catch(i){t(i),ZRe();return}if(this.debug("loaded data from store",n,"didDispose",this.didDispose),!this.didDispose)try{if(n){const i=Object.fromEntries(n.records.map(c=>[c.id,c])),o=n.sessionStateSnapshot??aTe(i),s=this.store.schema.migrateStoreSnapshot({store:i,schema:n.schema??this.store.schema.serializeEarliestVersion()});if(s.type==="error"){console.error("failed to migrate store",s),t(new Error(`Failed to migrate store: ${s.reason}`));return}const a=Object.values(s.value).filter(c=>this.documentTypes.has(c.typeName));a.length>0&&this.store.mergeRemoteChanges(()=>{this.store.put(a,"initialize")}),o&&MP(this.store,o,{forceOverwrite:!0})}this.channel.onmessage=({data:i})=>{var a,c;this.debug("got message",i);const o=i,s=this.store.schema.getMigrationsSince(o.schema);if(s.ok){if(s.value.length>0){this.debug("telling them to reload"),this.channel.postMessage({type:"announce",schema:this.serializedSchema}),this.shouldDoFullDBWrite=!0,this.persistIfNeeded();return}}else{if(Date.now()-this.initTime<5e3){t(new Error("Schema mismatch, please close other tabs and reload the page"));return}this.debug("reloading"),this.isReloading=!0,(c=(a=window==null?void 0:window.location)==null?void 0:a.reload)==null||c.call(a);return}o.type==="diff"&&(this.debug("applying diff"),Ui(()=>{this.store.mergeRemoteChanges(()=>{this.store.applyDiff(o.changes)})}))},this.channel.postMessage({type:"announce",schema:this.serializedSchema}),this.disposables.add(()=>{this.channel.close()}),e(this)}catch(i){if(this.debug("error loading data from store",i),this.didDispose)return;t(i);return}}close(){this.debug("closing"),this.didDispose=!0,this.disposables.forEach(e=>e())}schedulePersist(){this.debug("schedulePersist",this.scheduledPersistTimeout),!this.scheduledPersistTimeout&&(this.scheduledPersistTimeout=setTimeout(()=>{this.scheduledPersistTimeout=null,this.persistIfNeeded()},this.didLastWriteError?JRe:QRe))}persistIfNeeded(){this.debug("persistIfNeeded",{isPersisting:this.isPersisting,isReloading:this.isReloading,shouldDoFullDBWrite:this.shouldDoFullDBWrite,diffQueueLength:this.diffQueue.length,storeIsPossiblyCorrupt:this.store.isPossiblyCorrupted()}),this.scheduledPersistTimeout&&(clearTimeout(this.scheduledPersistTimeout),this.scheduledPersistTimeout=null),!this.isPersisting&&(this.isReloading||this.store.isPossiblyCorrupted()||(this.shouldDoFullDBWrite||this.diffQueue.length>0)&&this.doPersist())}async doPersist(){if(Jt(!this.isPersisting,"persist already in progress"),this.didDispose)return;this.isPersisting=!0,this.debug("doPersist start");const e=this.diffQueue;this.diffQueue=[];try{if(this.shouldDoFullDBWrite)this.shouldDoFullDBWrite=!1,await this.db.storeSnapshot({schema:this.store.schema,snapshot:this.store.serialize(),sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()});else{const t=rT(e.filter(n=>n!==dQ));await this.db.storeChanges({changes:t,schema:this.store.schema,sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()})}this.didLastWriteError=!1}catch(t){this.shouldDoFullDBWrite=!0,this.didLastWriteError=!0,console.error("failed to store changes in indexed db",t),XRe(),typeof window<"u"&&window.location.reload()}this.isPersisting=!1,this.debug("doPersist end"),this.schedulePersist()}}function Zae(r){const e=A.useRef(r),[t,n]=A.useState(r);t!==e.current&&n(e.current);const i=A.useCallback(o=>{typeof o=="function"?e.current=o(e.current):e.current=o,n(e.current)},[]);return[t,i]}function i2e(r){const[e,t]=Zae({status:"loading"});return r=Nd(r),A.useEffect(()=>{const{persistenceKey:n,sessionId:i,...o}=r;if(!n){t({status:"not-synced",store:wh(o)});return}t({status:"loading"});const s=new js,a={upload:async(f,h)=>(await d.db.storeAsset(f.id,h),{src:f.id}),resolve:async f=>f.props.src?f.props.src.startsWith("asset:")?await s.get(f,async()=>{const h=await d.db.getAsset(f.id);return h?URL.createObjectURL(h):null}):f.props.src:null,...o.assets},c=wh({...o,assets:a});let l=!1;const d=new n2e(c,{sessionId:i,persistenceKey:n,onLoad(){l||t({store:c,status:"synced-local"})},onLoadError(f){l||t({status:"error",error:f})}});return()=>{l=!0,d.close()}},[r,t]),e}function o2e(){const r=he(),e=Ln();A.useEffect(()=>{const t=o=>e.style.setProperty("--tl-zoom",o.toString()),n=kC(t,100),i=new Dd("useZoomCss",()=>{r.getCurrentPageShapeIds().size<300?t(r.getZoomLevel()):n(r.getZoomLevel())});return i.attach(),i.execute(),()=>{i.detach(),n.cancel()}},[r,e])}function BP(r){const e=new ArrayBuffer(r.length),t=new Uint8Array(e);for(let n=0,i=r.length;n<i;n++)t[n]=r.charCodeAt(n);return e}function s2e(r){const e=atob(r),t=BP(e);return crypto.subtle.importKey("spki",new Uint8Array(t),{name:"ECDSA",namedCurve:"P-256"},!0,["verify"])}const a2e=5,Jf={ANNUAL_LICENSE:1,PERPETUAL_LICENSE:2,INTERNAL_LICENSE:4,WITH_WATERMARK:8},c2e=Math.max(...Object.values(Jf)),eh={ID:0,HOSTS:1,FLAGS:2,EXPIRY_DATE:3},l2e=Object.keys(eh).length,_I="sales@tldraw.com",u2e=`${Gc()}/watermarks/watermark-track.svg`;class ky{constructor(e,t,n){q(this,"publicKey","MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHJh0uUfxHtCGyerXmmatE368Hd9rI6LH9oPDQihnaCryRFWEVeOvf9U/SPbyxX74LFyJs5tYeAHq5Nc0Ax25LQ");q(this,"isDevelopment");q(this,"isTest");q(this,"isCryptoAvailable");q(this,"state",xn("license state","pending"));q(this,"verbose",!0);this.isTest=!1,this.isDevelopment=this.getIsDevelopment(n),this.publicKey=t||this.publicKey,this.isCryptoAvailable=!!crypto.subtle,this.getLicenseFromKey(e).then(i=>{const o=d2e(i);!this.isDevelopment&&o&&pa(u2e),o?this.state.set("unlicensed"):i.isLicensedWithWatermark?this.state.set("licensed-with-watermark"):this.state.set("licensed")})}getIsDevelopment(e){return e==="development"?!0:e==="production"?!1:window.location.protocol!=="https:"||window.location.hostname==="localhost"}async extractLicenseKey(e){const[t,n]=e.split("."),[i,o]=t.split("/");if(!i.startsWith("tldraw-"))throw new Error(`Unsupported prefix '${i}'`);const s=await s2e(this.publicKey);let a;try{a=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},s,new Uint8Array(BP(atob(n))),new Uint8Array(BP(atob(o))))}catch(l){throw console.error(l),new Error("Could not perform signature validation")}if(!a)throw new Error("Invalid signature");let c;try{c=JSON.parse(atob(o))}catch{throw new Error("Could not parse object")}return c.length>l2e&&this.outputMessages(["License key contains some unknown properties.","You may want to update tldraw packages to a newer version to get access to new functionality."]),{id:c[eh.ID],hosts:c[eh.HOSTS],flags:c[eh.FLAGS],expiryDate:c[eh.EXPIRY_DATE]}}async getLicenseFromKey(e){if(!e)return this.isDevelopment||this.outputNoLicenseKeyProvided(),{isLicenseParseable:!1,reason:"no-key-provided"};if(this.isDevelopment&&!this.isCryptoAvailable)return this.verbose&&(console.log("tldraw: you seem to be in a development environment that does not support crypto. License not verified."),console.log("You should check that this works in production separately.")),{isLicenseParseable:!1,reason:"has-key-development-mode"};let t=e.replace(/[\u200B-\u200D\uFEFF]/g,"");t=t.replace(/\r?\n|\r/g,"");try{const n=await this.extractLicenseKey(t),i=new Date(n.expiryDate),o=this.isFlagEnabled(n.flags,Jf.ANNUAL_LICENSE),s=this.isFlagEnabled(n.flags,Jf.PERPETUAL_LICENSE),a={license:n,isLicenseParseable:!0,isDevelopment:this.isDevelopment,isDomainValid:this.isDomainValid(n),expiryDate:i,isAnnualLicense:o,isAnnualLicenseExpired:o&&this.isAnnualLicenseExpired(i),isPerpetualLicense:s,isPerpetualLicenseExpired:s&&this.isPerpetualLicenseExpired(i),isInternalLicense:this.isFlagEnabled(n.flags,Jf.INTERNAL_LICENSE),isLicensedWithWatermark:this.isFlagEnabled(n.flags,Jf.WITH_WATERMARK)};return this.outputLicenseInfoIfNeeded(a),a}catch(n){return this.outputInvalidLicenseKey(n.message),{isLicenseParseable:!1,reason:"invalid-license-key"}}}isDomainValid(e){const t=window.location.hostname.toLowerCase();return e.hosts.some(n=>{const i=n.toLowerCase().trim();if(i===t||`www.${i}`===t||i===`www.${t}`||n==="*")return!0;if(n.includes("*")){const o=new RegExp(n.replace(/\*/g,".*?"));return o.test(t)||o.test(`www.${t}`)}return!1})}getExpirationDateWithoutGracePeriod(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}getExpirationDateWithGracePeriod(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+a2e+1)}isAnnualLicenseExpired(e){const t=this.getExpirationDateWithGracePeriod(e),n=new Date>=t;return!n&&new Date>=this.getExpirationDateWithoutGracePeriod(e)&&this.outputMessages(["tldraw license is about to expire, you are in a grace period.",`Please reach out to ${_I} if you would like to renew your license.`]),n}isPerpetualLicenseExpired(e){const t=this.getExpirationDateWithGracePeriod(e),n={major:new Date(eD.major),minor:new Date(eD.minor)};return n.major>=t||n.minor>=t}isFlagEnabled(e,t){return(e&t)===t}outputNoLicenseKeyProvided(){}outputInvalidLicenseKey(e){this.outputMessages(["Invalid tldraw license key",`Reason: ${e}`])}outputLicenseInfoIfNeeded(e){e.isAnnualLicenseExpired&&this.outputMessages(["Your tldraw license has expired!",`Please reach out to ${_I} to renew.`]),!e.isDomainValid&&!e.isDevelopment&&this.outputMessages(["This tldraw license key is not valid for this domain!",`Please reach out to ${_I} if you would like to use tldraw on other domains.`]),e.license.flags>=c2e*2&&this.outputMessages(["This tldraw license contains some unknown flags.","You may want to update tldraw packages to a newer version to get access to new functionality."])}outputMessages(e){if(!this.isTest&&this.verbose){this.outputDelimiter();for(const t of e)console.log(`%c${t}`,"color: white; background: crimson; padding: 2px; border-radius: 3px;");this.outputDelimiter()}}outputDelimiter(){console.log("%c-------------------------------------------------------------------","color: white; background: crimson; padding: 2px; border-radius: 3px;")}}q(ky,"className","tl-watermark_SEE-LICENSE");function d2e(r){if(!r.isLicenseParseable||!r.isDomainValid&&!r.isDevelopment)return!0;if(r.isPerpetualLicenseExpired||r.isAnnualLicenseExpired){if(r.isInternalLicense)throw new Error("License: Internal license expired.");return!0}return!1}const Qae=A.createContext({}),f2e=()=>A.useContext(Qae);function h2e({licenseKey:r,children:e}){const[t]=A.useState(()=>new ky(r));return v.jsx(Qae.Provider,{value:t,children:e})}function vl(r){if(!r)throw Error("usePassThroughWheelEvents must be passed a ref");const e=Ln();A.useEffect(()=>{function t(i){if(i.isSpecialRedispatchedEvent)return;const o=r.current;if(o&&o.scrollHeight>o.clientHeight)return;Qt(i);const s=e.querySelector(".tl-canvas");if(!s)return;const a=new WheelEvent("wheel",i);a.isSpecialRedispatchedEvent=!0,s.dispatchEvent(a)}const n=r.current;if(n)return n.addEventListener("wheel",t,{passive:!1}),()=>{n.removeEventListener("wheel",t)}},[e,r])}const p2e='<svg xmlns="http://www.w3.org/2000/svg" width="3001" height="1000" fill="none"><path fill="#000" d="M590.656 300.449c0 49.706-40.294 90-90 90-49.705 0-90-40.294-90-90 0-49.705 40.295-90 90-90 49.706 0 90 40.295 90 90M569.431 719.011c-15.247 32.821-56.006 91.589-98.338 91.438-32.004-.115-38.642-30.904-17.414-50.856 17.381-16.337 28.246-48.075 31.995-72.719.415-2.728-1.556-5.197-4.272-5.679-39.666-7.04-70.746-40.877-70.746-83.417 0-48.23 38.983-87.329 87.07-87.329 39.936 0 70.172 22.237 83.369 52.397 18.839 43.055 7.117 115.733-11.664 156.165M2613.29 385.681V239.319c0-11.363 9.22-20.569 20.59-20.569h8.26c11.37 0 20.59 9.206 20.59 20.569v36.911c0 8.629 7 15.625 15.63 15.625h35.25c8.63 0 15.63-6.996 15.63-15.625v-36.911c0-11.363 9.22-20.569 20.59-20.569h8.17c11.37 0 20.59 9.206 20.59 20.569v146.362c0 11.363-9.22 20.569-20.59 20.569h-8.17c-11.37 0-20.59-9.206-20.59-20.569v-36.999c0-8.63-7-15.625-15.63-15.625h-35.25c-8.63 0-15.63 6.995-15.63 15.625v36.999c0 11.363-9.22 20.569-20.59 20.569h-8.26c-11.37 0-20.59-9.206-20.59-20.569M2391.97 239.319v146.362c0 11.348-9.16 20.569-20.49 20.569h-8.2c-11.33 0-20.49-9.221-20.49-20.569V239.319c0-11.348 9.16-20.569 20.49-20.569h8.2c11.33 0 20.49 9.221 20.49 20.569M2098.23 391.43l-42.69-146.361c-3.85-13.171 6.06-26.319 19.79-26.319h10.6c9.59 0 17.93 6.611 20.08 15.952l17.01 73.045c1.48 6.348 10.47 6.478 12.14.176l19.47-73.838c2.38-9.04 10.57-15.335 19.93-15.335h12.1c9.37 0 17.56 6.3 19.94 15.346l19.49 74.067c1.66 6.305 10.65 6.178 12.13-.171l17.09-73.294c2.15-9.339 10.49-15.948 20.08-15.948h10.53c13.72 0 23.63 13.141 19.79 26.31l-42.63 146.361c-2.56 8.789-10.63 14.829-19.79 14.829h-15.68c-9.12 0-17.16-5.98-19.76-14.709l-21.17-71.059c-1.77-5.948-10.19-5.957-11.97-.012l-21.33 71.071c-2.6 8.729-10.64 14.709-19.76 14.709h-15.59c-9.17 0-17.23-6.035-19.8-14.82M2443.23 218.75h118.59c11.38 0 20.62 9.195 20.62 20.557s-9.24 20.556-20.62 20.556h-24.79c-5.53 0-10 4.477-10 10v115.818c0 11.368-9.25 20.569-20.63 20.569h-7.65c-11.39 0-20.63-9.201-20.63-20.569V269.863c0-5.523-4.48-10-10-10h-24.89c-11.37 0-20.61-9.195-20.61-20.556s9.24-20.557 20.61-20.557M1174.15 218.75h24.64c8.35 0 15.88 5.042 19.04 12.764l34.61 83.942c2.13 5.161 9.44 5.155 11.56-.01l34.43-83.932a20.58 20.58 0 0 1 19.04-12.764h24.64c11.37 0 20.58 9.208 20.58 20.569v146.362c0 11.361-9.21 20.569-20.58 20.569h-7.09c-11.36 0-20.58-9.208-20.58-20.569l-.12-50.645c-.01-6.888-9.53-8.688-12.06-2.283l-23.46 59.332a20.57 20.57 0 0 1-19.14 13.009h-3.03a20.57 20.57 0 0 1-19.15-13.046l-23.47-59.68c-2.52-6.416-12.05-4.623-12.06 2.271l-.13 51.042c0 11.361-9.21 20.569-20.57 20.569h-7.1c-11.36 0-20.57-9.208-20.57-20.569V239.319c0-11.361 9.21-20.569 20.57-20.569"/><path fill="#000" fill-rule="evenodd" d="m1449.94 391.836 6.12-19.392a6.255 6.255 0 0 1 5.96-4.369l50.22-.061a6.24 6.24 0 0 1 5.96 4.348l6.23 19.486c2.71 8.581 10.71 14.402 19.74 14.402h9.34c14.13 0 24.15-13.791 19.61-27.151l-49.74-146.361c-2.85-8.37-10.74-13.988-19.61-13.988h-33.16c-8.87 0-16.77 5.618-19.61 13.988l-49.74 146.361c-4.54 13.36 5.48 27.151 19.61 27.151h9.32c9.04 0 17.04-5.827 19.75-14.414m31.1-98.858c1.85-5.807 10.08-5.796 11.91.016l8.83 27.916c1.28 4.028-1.73 8.134-5.96 8.134h-17.74c-4.23 0-7.24-4.119-5.95-8.151zM1681.81 406.25c18.91 0 35.39-3.686 49.36-11.168 13.97-7.544 24.73-18.394 32.24-32.489 7.56-14.105 11.29-30.866 11.29-50.182 0-19.256-3.73-35.957-11.29-50.004-7.57-14.094-18.35-24.912-32.32-32.397-13.91-7.545-30.4-11.26-49.37-11.26h-49.5c-11.38 0-20.63 9.201-20.63 20.569v146.362c0 11.368 9.25 20.569 20.63 20.569zm23.13-47.701c-6.62 3.215-14.85 4.886-24.79 4.886-10.49 0-19-8.507-19-19v-64.34c0-10.149 8.23-18.376 18.38-18.376 10.18 0 18.56 1.703 25.23 4.974 6.59 3.149 11.63 8.315 15.08 15.633 3.45 7.269 5.28 17.268 5.28 30.162 0 12.891-1.82 22.951-5.28 30.347-3.39 7.319-8.36 12.509-14.9 15.714" clip-rule="evenodd"/><path fill="#000" d="M1804.21 385.681V239.319c0-11.361 9.21-20.569 20.58-20.569h91.28c11.36 0 20.57 9.202 20.57 20.557s-9.21 20.556-20.57 20.556h-54.64a7.807 7.807 0 0 0-7.81 7.813v16.366a7.806 7.806 0 0 0 7.81 7.812h48.13c11.37 0 20.58 9.246 20.58 20.602s-9.21 20.601-20.58 20.601h-48.13a7.806 7.806 0 0 0-7.81 7.812v16.455a7.807 7.807 0 0 0 7.81 7.813h54.64c11.36 0 20.57 9.202 20.57 20.556s-9.21 20.557-20.57 20.557h-91.28c-11.37 0-20.58-9.208-20.58-20.569"/><path fill="#000" fill-rule="evenodd" d="M2875.5 68.75h-2750c-31.066 0-56.25 25.184-56.25 56.25v750c0 31.066 25.184 56.25 56.25 56.25h2750c31.07 0 56.25-25.184 56.25-56.25V125c0-31.066-25.18-56.25-56.25-56.25M125.5 0C56.464 0 .5 55.964.5 125v750c0 69.036 55.965 125 125 125h2750c69.04 0 125-55.964 125-125V125c0-69.036-55.96-125-125-125z" clip-rule="evenodd"/><path fill="#000" d="M2476.06 804.813c-10.54 0-19.82-6.947-22.81-17.068L2390.79 575.7c-4.49-15.248 6.92-30.534 22.8-30.534h27.75c11.1 0 20.72 7.686 23.18 18.52L2489 671.402c2.07 9.093 14.93 9.321 17.32.308l28.83-108.844c2.76-10.435 12.19-17.7 22.98-17.7h25.17c10.8 0 20.25 7.293 22.99 17.755l28.27 107.739c2.36 9.001 15.18 8.829 17.3-.232l25.01-106.888c2.51-10.763 12.1-18.374 23.14-18.374h27.87c15.88 0 27.29 15.286 22.8 30.534l-62.46 212.045a23.78 23.78 0 0 1-22.81 17.068h-32.12c-10.39 0-19.58-6.763-22.69-16.696l-32.08-102.694c-2.62-8.397-14.51-8.331-17.04.095l-30.74 102.346c-3.02 10.061-12.27 16.949-22.76 16.949zM1742.44 804.813h-75.81c-13.09 0-23.71-10.656-23.71-23.801V568.967c0-13.145 10.62-23.801 23.71-23.801h74.8c26.6 0 49.59 5.198 68.95 15.594 19.45 10.312 34.44 25.187 44.96 44.627 10.61 19.355 15.91 42.556 15.91 69.602q0 40.57-15.78 69.73c-10.53 19.355-25.43 34.231-44.71 44.627-19.28 10.311-42.05 15.467-68.32 15.467m-29.3-83.642c0 13.145 10.61 23.801 23.71 23.801h3.06c12.8 0 23.7-2.07 32.71-6.212 9.09-4.141 16-11.283 20.71-21.426q7.2-15.213 7.2-42.345 0-27.13-7.32-42.344c-4.8-10.143-11.87-17.285-21.22-21.426-9.26-4.142-20.63-6.212-34.1-6.212h-1.04c-13.1 0-23.71 10.656-23.71 23.801zM1460.86 804.813c-13.12 0-23.76-10.656-23.76-23.801V568.967c0-13.145 10.64-23.801 23.76-23.801h22.84c13.13 0 23.76 10.656 23.76 23.801v155.247c0 13.145 10.64 23.801 23.76 23.801h57.27c13.12 0 23.76 10.656 23.76 23.801v9.196c0 13.145-10.64 23.801-23.76 23.801zM1204.45 601.964c-13.13 0-23.77-10.656-23.77-23.801v-9.196c0-13.145 10.64-23.801 23.77-23.801h177.89c13.13 0 23.78 10.656 23.78 23.801v9.196c0 13.145-10.65 23.801-23.78 23.801h-39.38c-8.21 0-14.86 6.66-14.86 14.875v164.173c0 13.145-10.64 23.801-23.78 23.801h-21.85c-13.13 0-23.78-10.656-23.78-23.801V616.839c0-8.215-6.65-14.875-14.86-14.875z"/><path fill="#000" fill-rule="evenodd" d="M2223.05 787.891c-3.02 10.047-12.27 16.922-22.74 16.922h-25.43c-16.19 0-27.64-15.862-22.57-31.261l69.88-212.045c3.21-9.753 12.31-16.341 22.56-16.341h61.84c10.25 0 19.35 6.588 22.56 16.341l69.87 212.045c5.08 15.399-6.37 31.261-22.56 31.261h-25.43c-10.48 0-19.72-6.875-22.74-16.922l-6.7-22.2a14.84 14.84 0 0 0-14.21-10.576h-63.42c-6.55 0-12.32 4.296-14.22 10.576zm76.13-96.945-14.13-48.436c-2.46-8.451-14.36-8.602-17.04-.217l-15.46 48.436c-1.84 5.759 2.45 11.645 8.48 11.645h29.6c5.94 0 10.22-5.715 8.55-11.428" clip-rule="evenodd"/><path fill="#000" d="M1939.6 804.813c-13.13 0-23.77-10.656-23.77-23.801V568.967c0-13.145 10.64-23.801 23.77-23.801h88.13c19.24 0 36.08 3.508 50.51 10.523s25.65 17.115 33.67 30.3q12.03 19.779 12.03 47.416c0 18.595-4.14 34.273-12.41 47.036-7.64 11.913-18.18 21.101-31.63 27.564-16.98 8.159-36 11.104-54.7 11.104h-43.07c-76.56 0 4.08-135.84 4.08-84.706v7.996c0 12.117 9.81 21.941 21.91 21.941 8.12 0 16.3-.345 24.04-3.043 5.91-2.113 10.43-5.451 13.55-10.015 3.2-4.565 4.81-10.523 4.81-17.877 0-7.437-1.61-13.481-4.81-18.129-3.12-4.733-7.64-8.199-13.55-10.396-7.05-2.766-14.67-3.423-22.18-3.423-13.13 0-23.77 10.656-23.77 23.801v47.71c0 11.825 11.14 16.003 19.91 20.752 12.31 6.671 7.58 25.389-6.42 25.389-7.45 0-13.49 6.048-13.49 13.508v48.395c0 13.145-10.63 23.801-23.76 23.801zm134.89-106.758 5.41 9.95 33.51 61.622c8.62 15.86-2.84 35.186-20.87 35.186h-22.27c-8.74 0-16.77-4.798-20.92-12.496l-35.05-65.04a15.52 15.52 0 0 0-13.66-8.168c-42.24 0 40.62-82.154 73.85-21.054M931.652 0h68.748v1000h-68.748z"/></svg>',g2e='<svg xmlns="http://www.w3.org/2000/svg" width="400" height="1601" fill="none"><path fill="#000" d="M72 1319.8c0-10.73 7.071-20.18 17.372-23.22l215.823-63.62c15.519-4.57 31.078 7.05 31.078 23.22v28.26c0 11.31-7.824 21.1-18.85 23.61l-109.636 24.94c-9.254 2.1-9.487 15.2-.313 17.63l110.784 29.37a24.21 24.21 0 0 1 18.015 23.4v25.64c0 11-7.423 20.62-18.071 23.41l-109.659 28.79c-9.162 2.41-8.986 15.47.236 17.63l108.792 25.46c10.955 2.56 18.702 12.33 18.702 23.57v28.39c0 16.17-15.559 27.79-31.078 23.22l-215.823-63.62c-10.3-3.04-17.372-12.49-17.372-23.22v-32.72c0-10.59 6.883-19.95 16.994-23.11l104.523-32.67c8.547-2.67 8.479-14.79-.096-17.36l-104.17-31.3C79.01 1372.42 72 1363 72 1352.31zM72 572.638V495.43c0-13.336 10.846-24.147 24.225-24.147h215.823c13.379 0 24.225 10.811 24.225 24.147v76.179q0 40.645-15.872 70.228-15.743 29.712-45.422 45.79-29.55 16.206-70.843 16.206-41.292 0-70.971-16.078-29.55-16.077-45.422-45.532Q72 612.767 72 572.638m85.132-29.84c-13.379 0-24.225 10.81-24.225 24.146v3.122q0 19.55 6.323 33.313 6.323 13.89 21.807 21.094 15.485 7.332 43.099 7.331t43.1-7.46q15.484-7.33 21.807-21.608 6.323-14.15 6.323-34.728v-1.064c0-13.336-10.846-24.146-24.225-24.146zM72 285.858c0-13.363 10.846-24.197 24.225-24.197h215.823c13.379 0 24.225 10.834 24.225 24.197v23.27c0 13.364-10.846 24.197-24.225 24.197H154.035c-13.379 0-24.225 10.834-24.225 24.197v58.328c0 13.364-10.846 24.197-24.225 24.197h-9.36C82.845 440.047 72 429.214 72 415.85zM278.463 24.72c0-13.374 10.846-24.216 24.225-24.216h9.36c13.379 0 24.225 10.842 24.225 24.216v181.174c0 13.374-10.846 24.216-24.225 24.216h-9.36c-13.379 0-24.225-10.842-24.225-24.216v-40.108c0-8.359-6.779-15.135-15.141-15.135H96.225c-13.38 0-24.225-10.842-24.225-24.216v-22.256c0-13.374 10.846-24.216 24.225-24.216h167.097c8.362 0 15.141-6.776 15.141-15.135z"/><path fill="#000" fill-rule="evenodd" d="M89.224 1062.13C78.997 1059.04 72 1049.63 72 1038.96v-25.9c0-16.486 16.145-28.147 31.818-22.979l215.823 71.169a24.19 24.19 0 0 1 16.632 22.98v62.97c0 10.45-6.706 19.71-16.632 22.98l-215.823 71.17C88.145 1246.51 72 1234.86 72 1218.37v-25.9c0-10.67 6.997-20.08 17.224-23.17l22.595-6.81a15.13 15.13 0 0 0 10.765-14.48v-64.59a15.13 15.13 0 0 0-10.765-14.48zm98.672 77.53 49.299-14.39c8.601-2.51 8.755-14.62.22-17.35l-49.299-15.75c-5.861-1.88-11.852 2.49-11.852 8.64v30.14c0 6.05 5.817 10.41 11.632 8.71" clip-rule="evenodd"/><path fill="#000" d="M72 773.439c0-13.367 10.846-24.203 24.225-24.203h215.823c13.379 0 24.225 10.836 24.225 24.203v89.762q0 29.395-10.711 51.439-10.71 22.046-30.84 34.293t-48.261 12.248q-28.388 0-47.873-12.635-18.187-11.672-28.056-32.218c-8.303-17.289-11.301-36.661-11.301-55.705v-43.867c0-77.976 138.26 4.16 86.215 4.16h-8.138c-12.334 0-22.332 9.989-22.332 22.311 0 8.269.351 16.6 3.097 24.487q3.225 9.024 10.194 13.794 6.968 4.899 18.194 4.899 11.356 0 18.453-4.899 7.226-4.77 10.581-13.794c2.815-7.188 3.484-14.944 3.484-22.596 0-13.366-10.846-24.202-24.225-24.202h-48.56c-12.036 0-16.288 11.345-21.122 20.272-6.79 12.539-25.841 7.72-25.841-6.536 0-7.586-6.156-13.736-13.749-13.736H96.225C82.845 820.916 72 810.08 72 796.714zm108.66 137.378-10.128 5.511-62.72 34.131C91.67 959.243 72 947.569 72 929.205V906.52a24.2 24.2 0 0 1 12.719-21.299l66.199-35.696a15.82 15.82 0 0 0 8.313-13.921c0-43.012 83.618 41.371 21.429 75.213"/></svg>';function v2e(r){return ye("watermarkState",()=>r.state.get(),[r])}const m2e=`data:image/svg+xml;utf8,${encodeURIComponent(p2e)}`,y2e=`data:image/svg+xml;utf8,${encodeURIComponent(g2e)}`,S2e=A.memo(function(){const e=f2e(),t=he(),n=ye("is mobile",()=>t.getViewportScreenBounds().width<700,[t]),i=v2e(e);return["licensed-with-watermark","unlicensed"].includes(i)?v.jsxs(v.Fragment,{children:[v.jsx(_2e,{}),v.jsx(x2e,{src:n?y2e:m2e})]}):null}),x2e=A.memo(function({src:e}){const t=he(),n=ye("debug mode",()=>t.getInstanceState().isDebugMode,[t]),i=ye("is mobile",()=>t.getViewportScreenBounds().width<700,[t]),o=yT(),s=A.useRef(null);vl(s);const a=`url('${e}') center 100% / 100% no-repeat`,c="https://tldraw.dev";return v.jsx("div",{ref:s,className:ky.className,"data-debug":n,"data-mobile":i,draggable:!1,...o,children:Pr.isWebview?v.jsx("a",{draggable:!1,role:"button",onPointerDown:l=>{wn(l),Qt(l)},onClick:()=>Wm.openWindow(c,"_blank"),style:{mask:a,WebkitMask:a}}):v.jsx("a",{href:c,target:"_blank",rel:"noreferrer",draggable:!1,onPointerDown:l=>{wn(l)},style:{mask:a,WebkitMask:a}})})}),_2e=A.memo(function(){const e=ky.className,t=`/* ------------------- SEE LICENSE -------------------
121
- The tldraw watermark is part of tldraw's license. It is shown for unlicensed
122
- or "licensed-with-watermark" users. By using this library, you agree to
123
- preserve the watermark's behavior, keeping it visible, unobscured, and
124
- available to user-interaction.
125
-
126
- To remove the watermark, please purchase a license at tldraw.dev.
127
- */
128
-
129
- .${e} {
130
- position: absolute;
131
- bottom: var(--space-2);
132
- right: var(--space-2);
133
- width: 96px;
134
- height: 32px;
135
- display: flex;
136
- align-items: center;
137
- justify-content: center;
138
- z-index: var(--layer-watermark) !important;
139
- background-color: color-mix(in srgb, var(--color-background) 62%, transparent);
140
- opacity: 1;
141
- border-radius: 5px;
142
- pointer-events: all;
143
- padding: 2px;
144
- box-sizing: content-box;
145
- }
146
-
147
- .${e} > a {
148
- position: absolute;
149
- width: 96px;
150
- height: 32px;
151
- pointer-events: all;
152
- cursor: inherit;
153
- color: var(--color-text);
154
- opacity: .38;
155
- background-color: currentColor;
156
- }
157
-
158
- .${e}[data-debug='true'] {
159
- bottom: 46px;
160
- }
161
-
162
- .${e}[data-mobile='true'] {
163
- border-radius: 4px 0px 0px 4px;
164
- right: -2px;
165
- width: 8px;
166
- height: 48px;
167
- }
168
-
169
- .${e}[data-mobile='true'] > a {
170
- width: 8px;
171
- height: 32px;
172
- }
173
-
174
- @media (hover: hover) {
175
- .${e} > a {
176
- pointer-events: none;
177
- }
178
-
179
- .${e}:hover {
180
- background-color: var(--color-background);
181
- transition: background-color 0.2s ease-in-out;
182
- transition-delay: 0.32s;
183
- }
184
-
185
- .${e}:hover > a {
186
- animation: delayed_link 0.2s forwards ease-in-out;
187
- animation-delay: 0.32s;
188
- }
189
- }
190
-
191
- @keyframes delayed_link {
192
- 0% {
193
- cursor: inherit;
194
- opacity: .38;
195
- pointer-events: none;
196
- }
197
- 100% {
198
- cursor: pointer;
199
- opacity: 1;
200
- pointer-events: all;
201
- }
202
- }`;return v.jsx("style",{children:t})}),w2e=[],b2e=[],E2e=[],I2e="tl-container",P2e=A.memo(function({store:e,components:t,className:n,user:i,options:o,...s}){const[a,c]=A.useState(null),l=A.useMemo(()=>i??vre(),[i]),d=(t==null?void 0:t.ErrorFallback)===void 0?are:t==null?void 0:t.ErrorFallback,f={...s,shapeUtils:s.shapeUtils??w2e,bindingUtils:s.bindingUtils??b2e,tools:s.tools??E2e,components:t,options:Nd(o)};return v.jsx("div",{ref:c,"data-tldraw":Dte,draggable:!1,className:bt(`${I2e} tl-theme__light`,n),onPointerDown:wn,tabIndex:-1,children:v.jsx(_h,{fallback:d,onError:h=>OC(h,{tags:{origin:"react.tldraw-before-app"}}),children:a&&v.jsx(h2e,{licenseKey:s.licenseKey,children:v.jsx(qte,{container:a,children:v.jsx(e_e,{overrides:t,children:e?e instanceof nT?v.jsx(ece,{...f,store:e,user:l}):v.jsx(Jae,{...f,store:e,user:l}):v.jsx(C2e,{...f,store:e,user:l})})})})})})});function C2e(r){const{defaultName:e,snapshot:t,initialData:n,shapeUtils:i,bindingUtils:o,persistenceKey:s,sessionId:a,user:c,assets:l,migrations:d}=r,f=i2e({shapeUtils:i,bindingUtils:o,initialData:n,persistenceKey:s,sessionId:a,defaultName:e,snapshot:t,assets:l,migrations:d});return v.jsx(Jae,{...r,store:f,user:c})}const Jae=A.memo(function({store:e,user:t,...n}){const i=Ln();A.useLayoutEffect(()=>{t.userPreferences.get().colorScheme==="dark"&&(i.classList.remove("tl-theme__light"),i.classList.add("tl-theme__dark"))},[i,t]);const{LoadingScreen:o}=Gr();switch(e.status){case"error":throw e.error;case"loading":return o?v.jsx(o,{}):null}return v.jsx(ece,{...n,store:e.store,user:t})}),wI=()=>document.location.search.includes("tldraw_preserve_focus");function ece({onMount:r,children:e,store:t,tools:n,shapeUtils:i,bindingUtils:o,user:s,initialState:a,autoFocus:c=!0,inferDarkMode:l,cameraOptions:d,options:f,licenseKey:h,deepLinks:g,isShapeHidden:m}){const{ErrorFallback:y}=Gr(),x=Ln(),[_,w]=Zae(null),I=A.useRef(null),b=Nd(g===!0?{}:g),P=A.useRef({autoFocus:c&&!wI(),inferDarkMode:l,initialState:a,cameraOptions:d,deepLinks:b});A.useLayoutEffect(()=>{P.current={autoFocus:c&&!wI(),inferDarkMode:l,initialState:a,cameraOptions:d,deepLinks:b}},[c,l,a,d,b]),A.useLayoutEffect(()=>{const{autoFocus:O,inferDarkMode:L,initialState:j,cameraOptions:F,deepLinks:$}=P.current,D=new rt({store:t,shapeUtils:i,bindingUtils:o,tools:n,getContainer:()=>x,user:s,initialState:j,autoFocus:O,inferDarkMode:L,cameraOptions:F,options:f,licenseKey:h,isShapeHidden:m});return D.updateViewportScreenBounds(I.current??x),$&&($!=null&&$.getUrl?D.navigateToDeepLink({...$,url:$.getUrl(D)}):D.navigateToDeepLink($)),w(D),()=>{D.dispose()}},[o,x,f,i,t,n,s,w,h,m]),A.useLayoutEffect(()=>{if(_&&b)return _.registerDeepLinkListener(b)},[_,b]),A.useLayoutEffect(()=>{_&&d&&_.setCameraOptions(d)},[_,d]);const C=A.useSyncExternalStore(A.useCallback(O=>_?(_.on("crash",O),()=>_.off("crash",O)):()=>{},[_]),()=>(_==null?void 0:_.getCrashingError())??null);A.useEffect(function(){if(!_)return;function L(){_&&_.focus()}function j(){_&&_.blur()}if(c&&wI())return _.getContainer().addEventListener("pointerdown",L),document.body.addEventListener("pointerdown",j),()=>{var F;(F=_.getContainer())==null||F.removeEventListener("pointerdown",L),document.body.removeEventListener("pointerdown",j)}},[_,c]);const{Canvas:k}=Gr();return _?v.jsx(_h,{fallback:y,onError:O=>_.annotateError(O,{origin:"react.tldraw",willCrashApp:!0}),children:C?v.jsx(A2e,{crashingError:C}):v.jsx(vT,{editor:_,children:v.jsxs(T2e,{onMount:r,children:[e??(k?v.jsx(k,{},_.contextId):null),v.jsx(S2e,{})]})})}):v.jsx("div",{className:"tl-canvas",ref:I})}function T2e({children:r,onMount:e}){return o2e(),HRe(),WRe(),KRe(),rce(t=>{const n=t.store.props.onMount(t),i=e==null?void 0:e(t);return()=>{n==null||n(),i==null||i()}}),r}function A2e({crashingError:r}){throw r}function vA({children:r}){return v.jsx("div",{className:"tl-loading",children:r})}function tce({children:r}){return v.jsx("div",{className:"tl-loading",children:r})}function rce(r){const e=he(),t=Iy(n=>{let i;return n.run(()=>{i=r==null?void 0:r(n),n.emit("mount")},{history:"ignore"}),window.tldrawReady=!0,i});lr.useLayoutEffect(()=>{if(e)return t==null?void 0:t(e)},[e,t])}function Xc({children:r,className:e="",...t}){return v.jsx("div",{...t,className:bt("tl-html-container",e),children:r})}class uv{constructor(e){this.editor=e}}q(uv,"props"),q(uv,"migrations"),q(uv,"type");function Oy(r,e,t={}){const{newPoint:n,handle:i,scaleX:o,scaleY:s}=e,{minWidth:a=1,maxWidth:c=1/0,minHeight:l=1,maxHeight:d=1/0}=t;let f=r.props.w*o,h=r.props.h*s;const g=new T(0,0);if(f>0){if(f<a){switch(i){case"top_left":case"left":case"bottom_left":{g.x=f-a;break}case"top":case"bottom":{g.x=(f-a)/2;break}default:g.x=0}f=a}}else if(g.x=f,f=-f,f<a){switch(i){case"top_left":case"left":case"bottom_left":{g.x=-f;break}default:g.x=-a}f=a}if(h>0){if(h<l){switch(i){case"top_left":case"top":case"top_right":{g.y=h-l;break}case"right":case"left":{g.y=(h-l)/2;break}default:g.y=0}h=l}}else if(g.y=h,h=-h,h<l){switch(i){case"top_left":case"top":case"top_right":{g.y=-h;break}default:g.y=-l}h=l}const{x:m,y}=g.rot(r.rotation).add(n);return{...r,x:m,y,props:{w:Math.min(c,f),h:Math.min(d,h)}}}class Qd extends Rs{getGeometry(e){return new ma({width:e.props.w,height:e.props.h,isFilled:!0})}onResize(e,t){return Oy(e,t)}getHandleSnapGeometry(e){return{points:this.getGeometry(e).bounds.cornersAndCenter}}getInterpolatedProps(e,t,n){return{...t.props,w:or(e.props.w,t.props.w,n),h:or(e.props.h,t.props.h,n)}}}var YI;let R2e=(YI=class extends vt{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},q(YI,"id","idle"),YI);var XI;let k2e=(XI=class extends vt{onPointerMove(e){if(this.editor.inputs.isDragging){const{originPagePoint:t}=this.editor.inputs,n=this.parent.shapeType,i=Tr(),o=this.editor.markHistoryStoppingPoint(`creating_box:${i}`),s=ks(t,this.editor);this.editor.createShapes([{id:i,type:n,x:s.x,y:s.y,props:{w:1,h:1}}]).select(i);const a=this.parent;this.editor.setCurrentTool("select.resizing",{...e,target:"selection",handle:"bottom_right",isCreating:!0,creatingMarkId:o,creationCursorOffset:{x:1,y:1},onInteractionEnd:this.parent.id,onCreate:a.onCreate?c=>{var l;return(l=a.onCreate)==null?void 0:l.call(a,c)}:void 0})}}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}complete(){const{originPagePoint:e}=this.editor.inputs,t=this.parent.shapeType,n=Tr();this.editor.markHistoryStoppingPoint(`creating_box:${n}`),this.editor.createShapes([{id:n,type:t,x:e.x,y:e.y}]);const i=this.editor.getShape(n);if(!i){this.cancel();return}let{w:o,h:s}=i.props;const a=new T(o/2,s/2),c=this.editor.getShapeParentTransform(i);c&&a.rot(-c.rotation());let l=1;this.editor.user.getIsDynamicResizeMode()&&(l=1/this.editor.getZoomLevel(),o*=l,s*=l,a.mul(l));const d=Kr(i),f=ks(new T(i.x-a.x,i.y-a.y),this.editor);d.x=f.x,d.y=f.y,d.props.w=o,d.props.h=s,"scale"in i.props&&(d.props.scale=l),this.editor.updateShape(d),this.editor.setSelectedShapes([n]),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select.idle")}cancel(){this.parent.transition("idle")}},q(XI,"id","pointing"),XI);function ks(r,e){const t=e.getInstanceState().isGridMode,n=e.getDocumentSettings().gridSize;return t?r.clone().snapToGrid(n):r.clone()}class UP extends vt{static children(){return[R2e,k2e]}}q(UP,"id","box"),q(UP,"initial","idle");function O2e(r,e,t){const n=A.useRef(!1),i=A.useCallback(s=>{n.current=s,s?Is.addOpenMenu(r):Is.deleteOpenMenu(r),e==null||e(s)},[r,e]),o=ye("is menu open",()=>Is.getOpenMenus().includes(r),[r]);return A.useEffect(()=>(n.current&&(t==null||t("open-menu"),Is.addOpenMenu(r)),()=>{n.current&&(Is.deleteOpenMenu(r),Is.getOpenMenus().forEach(s=>{s.startsWith(r)&&(t==null||t("close-menu"),Is.deleteOpenMenu(s))}),n.current=!1)}),[r,t]),[o,i]}function My(r){const e=he();return ye("isEditing",()=>e.getEditingShapeId()===r,[e,r])}function oa(r){const e=he();return A.useMemo(function(){const i=l=>{if(l.isKilled)return;if(l.button===mT){e.dispatch({type:"pointer",target:"selection",handle:r,name:"right_click",...Ao(l)});return}if(l.button!==0)return;const d=rm(l.currentTarget);function f(){d.removeEventListener("pointerup",f),Wh(d,l)}Hh(d,l),d.addEventListener("pointerup",f),e.dispatch({name:"pointer_down",type:"pointer",target:"selection",handle:r,...Ao(l)}),wn(l)};let o,s;function a(l){l.isKilled||l.button===0&&(l.clientX===o&&l.clientY===s||(o=l.clientX,s=l.clientY,e.dispatch({name:"pointer_move",type:"pointer",target:"selection",handle:r,...Ao(l)})))}return{onPointerDown:i,onPointerMove:a,onPointerUp:l=>{l.isKilled||l.button===0&&e.dispatch({name:"pointer_up",type:"pointer",target:"selection",handle:r,...Ao(l)})}}},[e,r])}function M2e(r){const[e,t]=A.useState(()=>({store:wh(r),opts:r}));if(!WJ(e.opts,r)){const n={store:wh(r),opts:r};return t(n),n.store}return e.store}const j2e=20,D2e=8;function mA(r,e=j2e){return Math.max(D2e,Math.ceil(r/e))}class dd extends ul{constructor(t){super({...t,isFilled:!1,isClosed:!1});q(this,"_center");q(this,"radius");q(this,"start");q(this,"end");q(this,"largeArcFlag");q(this,"sweepFlag");q(this,"measure");q(this,"angleStart");q(this,"angleEnd");const{center:n,sweepFlag:i,largeArcFlag:o,start:s,end:a}=t;if(s.equals(a))throw Error("Arc must have different start and end points.");this.angleStart=T.Angle(n,s),this.angleEnd=T.Angle(n,a),this.radius=T.Dist(n,s),this.measure=Qve(this.angleStart,this.angleEnd,i,o),this.start=s,this.end=a,this.sweepFlag=i,this.largeArcFlag=o,this._center=n}nearestPoint(t){const{_center:n,measure:i,radius:o,angleEnd:s,angleStart:a,start:c,end:l}=this,d=wP(i,a,s,n.angle(t));if(d<=0)return c;if(d>=1)return l;const f=n.clone().add(t.clone().sub(n).uni().mul(o));let h,g=1/0,m;for(const y of[c,l,f])m=T.Dist2(t,y),m<g&&(h=y,g=m);if(!h)throw Error("nearest point not found");return h}hitTestLineSegment(t,n){const{_center:i,radius:o,measure:s,angleStart:a,angleEnd:c}=this,l=ip(t,n,i,o);return l===null?!1:l.some(d=>{const f=wP(s,a,c,i.angle(d));return f>=0&&f<=1})}getVertices(){const{_center:t,measure:n,length:i,radius:o,angleStart:s}=this,a=[];for(let c=0,l=mA(Math.abs(i));c<l+1;c++){const d=c/l*n,f=s+d;a.push(Gl(t,o,f))}return a}getSvgPathData(t=!0){const{start:n,end:i,radius:o,largeArcFlag:s,sweepFlag:a}=this;return`${t?`M${n.toFixed()}`:""} A${o} ${o} 0 ${s} ${a} ${i.toFixed()}`}getLength(){return this.measure*this.radius}}class yA extends ul{constructor(t){super({isClosed:!0,...t});q(this,"_center");q(this,"radius");q(this,"x");q(this,"y");this.config=t;const{x:n=0,y:i=0,radius:o}=t;this.x=n,this.y=i,this._center=new T(o+n,o+i),this.radius=o}getBounds(){return new He(this.x,this.y,this.radius*2,this.radius*2)}getVertices(){const{_center:t,radius:n}=this,i=Cr*n,o=[];for(let s=0,a=mA(i);s<a;s++){const c=s/a*Cr;o.push(Gl(t,n,c))}return o}nearestPoint(t){const{_center:n,radius:i}=this;return n.equals(t)?T.AddXY(n,i,0):n.clone().add(t.clone().sub(n).uni().mul(i))}hitTestLineSegment(t,n,i=0){const{_center:o,radius:s}=this;return ip(t,n,o,s+i)!==null}getSvgPathData(){const{_center:t,radius:n}=this;return`M${t.x+n},${t.y} a${n},${n} 0 1,0 ${n*2},0a${n},${n} 0 1,0 -${n*2},0`}}class xi extends Vd{constructor(t){const{start:n,cp1:i,cp2:o,end:s}=t;super({...t,points:[n,s]});q(this,"a");q(this,"b");q(this,"c");q(this,"d");this.a=n,this.b=i,this.c=o,this.d=s}getVertices(){const t=[],{a:n,b:i,c:o,d:s}=this;for(let a=0,c=10;a<=c;a++){const l=a/c;t.push(new T((1-l)*(1-l)*(1-l)*n.x+3*((1-l)*(1-l))*l*i.x+3*(1-l)*(l*l)*o.x+l*l*l*s.x,(1-l)*(1-l)*(1-l)*n.y+3*((1-l)*(1-l))*l*i.y+3*(1-l)*(l*l)*o.y+l*l*l*s.y))}return t}midPoint(){return xi.GetAtT(this,.5)}nearestPoint(t){let n,i=1/0,o,s;for(const a of this.segments)s=a.nearestPoint(t),o=T.Dist2(s,t),o<i&&(n=s,i=o);if(!n)throw Error("nearest point not found");return n}getSvgPathData(t=!0){const{a:n,b:i,c:o,d:s}=this;return`${t?`M ${n.toFixed()} `:""} C${i.toFixed()} ${o.toFixed()} ${s.toFixed()}`}static GetAtT(t,n){const{a:i,b:o,c:s,d:a}=t;return new T((1-n)*(1-n)*(1-n)*i.x+3*((1-n)*(1-n))*n*o.x+3*(1-n)*(n*n)*s.x+n*n*n*a.x,(1-n)*(1-n)*(1-n)*i.y+3*((1-n)*(1-n))*n*o.y+3*(1-n)*(n*n)*s.y+n*n*n*a.y)}getLength(t=32){let n,i=this.a,o=0;for(let s=1;s<=t;s++)n=xi.GetAtT(this,s/t),o+=T.Dist(i,n),i=n;return o}}class L2e extends ul{constructor(t){super({...t,isClosed:!1,isFilled:!1});q(this,"points");q(this,"_segments");const{points:n}=t;this.points=n}get segments(){if(!this._segments){this._segments=[];const{points:t}=this,n=t.length,i=n-2,o=1.25;for(let s=0;s<n-1;s++){const a=s===0?t[0]:t[s-1],c=t[s],l=t[s+1],d=s===i?l:t[s+2],f=c,h=s===0?a:new T(c.x+(l.x-a.x)/6*o,c.y+(l.y-a.y)/6*o),g=s===i?l:new T(l.x-(d.x-c.x)/6*o,l.y-(d.y-c.y)/6*o),m=l;this._segments.push(new xi({start:f,cp1:h,cp2:g,end:m}))}}return this._segments}getLength(){return this.segments.reduce((t,n)=>t+n.length,0)}getVertices(){const t=this.segments.reduce((n,i)=>n.concat(i.vertices),[]);return t.push(this.points[this.points.length-1]),t}nearestPoint(t){let n,i=1/0,o,s;for(const a of this.segments)s=a.nearestPoint(t),o=T.Dist2(s,t),o<i&&(n=s,i=o);if(!n)throw Error("nearest point not found");return n}hitTestLineSegment(t,n){return this.segments.some(i=>i.hitTestLineSegment(t,n))}getSvgPathData(){let t=this.segments.reduce((n,i,o)=>n+i.getSvgPathData(o===0),"");return this.isClosed&&(t+="Z"),t}}class F2e extends ul{constructor(t){super({...t,isClosed:!0});q(this,"w");q(this,"h");q(this,"_edges");this.config=t;const{width:n,height:i}=t;this.w=n,this.h=i}get edges(){if(!this._edges){const{vertices:t}=this;this._edges=[];for(let n=0,i=t.length;n<i;n++){const o=t[n],s=t[(n+1)%i];this._edges.push(new Qa({start:o,end:s}))}}return this._edges}getVertices(){const t=Math.max(1,this.w),n=Math.max(1,this.h),i=t/2,o=n/2,s=Math.pow(i-o,2)/Math.pow(i+o,2),a=hr*(i+o)*(1+3*s/(10+Math.sqrt(4-3*s))),c=mA(a),l=Cr/c,d=Math.cos(l),f=Math.sin(l);let h=0,g=1,m=0,y=1;const x=Array(c);for(let _=0;_<c;_++)x[_]=new T(i+i*g,o+o*h),m=f*g+d*h,y=d*g-f*h,h=m,g=y;return x}nearestPoint(t){let n,i=1/0,o,s;for(const a of this.edges)s=a.nearestPoint(t),o=T.Dist2(s,t),o<i&&(n=s,i=o);if(!n)throw Error("nearest point not found");return n}hitTestLineSegment(t,n){return this.edges.some(i=>i.hitTestLineSegment(t,n))}getBounds(){return new He(0,0,this.w,this.h)}getLength(){const{w:t,h:n}=this,i=t/2,o=n/2,s=Math.max(0,i),a=Math.max(0,o);return Lee(s,a)}getSvgPathData(t=!1){const{w:n,h:i}=this,o=n/2,s=i/2,a=Math.max(0,o),c=Math.max(0,s);return`${t?`M${o-a},${s}`:""} a${a},${c},0,1,1,${a*2},0a${a},${c},0,1,1,-${a*2},0`}}class N2e extends ul{constructor(t){super({...t,isClosed:!0});q(this,"w");q(this,"h");q(this,"a");q(this,"b");q(this,"c");q(this,"d");this.config=t;const{width:n,height:i}=t;if(this.w=n,this.h=i,i>n){const o=n/2;this.a=new dd({start:new T(0,o),end:new T(n,o),center:new T(n/2,o),sweepFlag:1,largeArcFlag:1}),this.b=new Qa({start:new T(n,o),end:new T(n,i-o)}),this.c=new dd({start:new T(n,i-o),end:new T(0,i-o),center:new T(n/2,i-o),sweepFlag:1,largeArcFlag:1}),this.d=new Qa({start:new T(0,i-o),end:new T(0,o)})}else{const o=i/2;this.a=new dd({start:new T(o,i),end:new T(o,0),center:new T(o,o),sweepFlag:1,largeArcFlag:1}),this.b=new Qa({start:new T(o,0),end:new T(n-o,0)}),this.c=new dd({start:new T(n-o,0),end:new T(n-o,i),center:new T(n-o,o),sweepFlag:1,largeArcFlag:1}),this.d=new Qa({start:new T(n-o,i),end:new T(o,i)})}}nearestPoint(t){let n,i=1/0,o,s;const{a,b:c,c:l,d}=this;for(const f of[a,c,l,d])s=f.nearestPoint(t),o=T.Dist2(s,t),o<i&&(n=s,i=o);if(!n)throw Error("nearest point not found");return n}hitTestLineSegment(t,n){const{a:i,b:o,c:s,d:a}=this;return[i,o,s,a].some(c=>c.hitTestLineSegment(t,n))}getVertices(){const{a:t,b:n,c:i,d:o}=this;return[t,n,i,o].reduce((s,a)=>(s.push(...a.vertices),s),[])}getBounds(){return new He(0,0,this.w,this.h)}getLength(){const{h:t,w:n}=this;return t>n?(hr*(n/2)+(t-n))*2:(hr*(t/2)+(n-t))*2}getSvgPathData(){const{a:t,b:n,c:i,d:o}=this;return[t,n,i,o].map((s,a)=>s.getSvgPathData(a===0)).join(" ")+" Z"}}async function $2e({shouldReload:r=!0}={}){dve();for(const e of zv.connectedInstances)await e.close();await Promise.all(tT().map(e=>zee(e))),uve(),r&&window.location.reload()}typeof window<"u"&&(window.__tldraw__hardReset=$2e);function q2e(r,e="_blank"){Wm.openWindow(r,e)}il("@tldraw/editor","3.9.0","esm");function nce(){const[r,e]=A.useState(!1);return A.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const t=window.matchMedia("(prefers-reduced-motion: reduce)"),n=()=>{e(t.matches)};return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]),r}const ice=()=>{},oce=A.createContext(null);function B2e({onEvent:r,children:e}){return v.jsx(oce.Provider,{value:r??ice,children:e})}function ai(){return A.useContext(oce)??ice}function pt(r,e,{checkForDefaultPrevented:t=!0}={}){return function(i){if(r==null||r(i),t===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function U2e(r,e){const t=A.createContext(e),n=o=>{const{children:s,...a}=o,c=A.useMemo(()=>a,Object.values(a));return v.jsx(t.Provider,{value:c,children:s})};n.displayName=r+"Provider";function i(o){const s=A.useContext(t);if(s)return s;if(e!==void 0)return e;throw new Error(`\`${o}\` must be used within \`${r}\``)}return[n,i]}function Aa(r,e=[]){let t=[];function n(o,s){const a=A.createContext(s),c=t.length;t=[...t,s];const l=f=>{var _;const{scope:h,children:g,...m}=f,y=((_=h==null?void 0:h[r])==null?void 0:_[c])||a,x=A.useMemo(()=>m,Object.values(m));return v.jsx(y.Provider,{value:x,children:g})};l.displayName=o+"Provider";function d(f,h){var y;const g=((y=h==null?void 0:h[r])==null?void 0:y[c])||a,m=A.useContext(g);if(m)return m;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[l,d]}const i=()=>{const o=t.map(s=>A.createContext(s));return function(a){const c=(a==null?void 0:a[r])||o;return A.useMemo(()=>({[`__scope${r}`]:{...a,[r]:c}}),[a,c])}};return i.scopeName=r,[n,z2e(i,...e)]}function z2e(...r){const e=r[0];if(r.length===1)return e;const t=()=>{const n=r.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const s=n.reduce((a,{useScope:c,scopeName:l})=>{const f=c(o)[`__scope${l}`];return{...a,...f}},{});return A.useMemo(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return t.scopeName=e.scopeName,t}function fQ(r,e){if(typeof r=="function")return r(e);r!=null&&(r.current=e)}function jy(...r){return e=>{let t=!1;const n=r.map(i=>{const o=fQ(i,e);return!t&&typeof o=="function"&&(t=!0),o});if(t)return()=>{for(let i=0;i<n.length;i++){const o=n[i];typeof o=="function"?o():fQ(r[i],null)}}}}function $r(...r){return A.useCallback(jy(...r),r)}var Ql=A.forwardRef((r,e)=>{const{children:t,...n}=r,i=A.Children.toArray(t),o=i.find(W2e);if(o){const s=o.props.children,a=i.map(c=>c===o?A.Children.count(s)>1?A.Children.only(null):A.isValidElement(s)?s.props.children:null:c);return v.jsx(zP,{...n,ref:e,children:A.isValidElement(s)?A.cloneElement(s,void 0,a):null})}return v.jsx(zP,{...n,ref:e,children:t})});Ql.displayName="Slot";var zP=A.forwardRef((r,e)=>{const{children:t,...n}=r;if(A.isValidElement(t)){const i=G2e(t),o=K2e(n,t.props);return t.type!==A.Fragment&&(o.ref=e?jy(e,i):i),A.cloneElement(t,o)}return A.Children.count(t)>1?A.Children.only(null):null});zP.displayName="SlotClone";var H2e=({children:r})=>v.jsx(v.Fragment,{children:r});function W2e(r){return A.isValidElement(r)&&r.type===H2e}function K2e(r,e){const t={...e};for(const n in e){const i=r[n],o=e[n];/^on[A-Z]/.test(n)?i&&o?t[n]=(...a)=>{o(...a),i(...a)}:i&&(t[n]=i):n==="style"?t[n]={...i,...o}:n==="className"&&(t[n]=[i,o].filter(Boolean).join(" "))}return{...r,...t}}function G2e(r){var n,i;let e=(n=Object.getOwnPropertyDescriptor(r.props,"ref"))==null?void 0:n.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?r.ref:(e=(i=Object.getOwnPropertyDescriptor(r,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?r.props.ref:r.props.ref||r.ref)}var V2e=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],pr=V2e.reduce((r,e)=>{const t=A.forwardRef((n,i)=>{const{asChild:o,...s}=n,a=o?Ql:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),v.jsx(a,{...s,ref:i})});return t.displayName=`Primitive.${e}`,{...r,[e]:t}},{});function SA(r,e){r&&Yd.flushSync(()=>r.dispatchEvent(e))}function Dy(r){const e=r+"CollectionProvider",[t,n]=Aa(e),[i,o]=t(e,{collectionRef:{current:null},itemMap:new Map}),s=g=>{const{scope:m,children:y}=g,x=lr.useRef(null),_=lr.useRef(new Map).current;return v.jsx(i,{scope:m,itemMap:_,collectionRef:x,children:y})};s.displayName=e;const a=r+"CollectionSlot",c=lr.forwardRef((g,m)=>{const{scope:y,children:x}=g,_=o(a,y),w=$r(m,_.collectionRef);return v.jsx(Ql,{ref:w,children:x})});c.displayName=a;const l=r+"CollectionItemSlot",d="data-radix-collection-item",f=lr.forwardRef((g,m)=>{const{scope:y,children:x,..._}=g,w=lr.useRef(null),I=$r(m,w),b=o(l,y);return lr.useEffect(()=>(b.itemMap.set(w,{ref:w,..._}),()=>void b.itemMap.delete(w))),v.jsx(Ql,{[d]:"",ref:I,children:x})});f.displayName=l;function h(g){const m=o(r+"CollectionConsumer",g);return lr.useCallback(()=>{const x=m.collectionRef.current;if(!x)return[];const _=Array.from(x.querySelectorAll(`[${d}]`));return Array.from(m.itemMap.values()).sort((b,P)=>_.indexOf(b.ref.current)-_.indexOf(P.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:s,Slot:c,ItemSlot:f},h,n]}var Y2e=A.createContext(void 0);function xA(r){const e=A.useContext(Y2e);return r||e||"ltr"}function ri(r){const e=A.useRef(r);return A.useEffect(()=>{e.current=r}),A.useMemo(()=>(...t)=>{var n;return(n=e.current)==null?void 0:n.call(e,...t)},[])}function X2e(r,e=globalThis==null?void 0:globalThis.document){const t=ri(r);A.useEffect(()=>{const n=i=>{i.key==="Escape"&&t(i)};return e.addEventListener("keydown",n,{capture:!0}),()=>e.removeEventListener("keydown",n,{capture:!0})},[t,e])}var Z2e="DismissableLayer",HP="dismissableLayer.update",Q2e="dismissableLayer.pointerDownOutside",J2e="dismissableLayer.focusOutside",hQ,sce=A.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),up=A.forwardRef((r,e)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:n,onPointerDownOutside:i,onFocusOutside:o,onInteractOutside:s,onDismiss:a,...c}=r,l=A.useContext(sce),[d,f]=A.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=A.useState({}),m=$r(e,k=>f(k)),y=Array.from(l.layers),[x]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=y.indexOf(x),w=d?y.indexOf(d):-1,I=l.layersWithOutsidePointerEventsDisabled.size>0,b=w>=_,P=tke(k=>{const O=k.target,L=[...l.branches].some(j=>j.contains(O));!b||L||(i==null||i(k),s==null||s(k),k.defaultPrevented||a==null||a())},h),C=rke(k=>{const O=k.target;[...l.branches].some(j=>j.contains(O))||(o==null||o(k),s==null||s(k),k.defaultPrevented||a==null||a())},h);return X2e(k=>{w===l.layers.size-1&&(n==null||n(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},h),A.useEffect(()=>{if(d)return t&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(hQ=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(d)),l.layers.add(d),pQ(),()=>{t&&l.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=hQ)}},[d,h,t,l]),A.useEffect(()=>()=>{d&&(l.layers.delete(d),l.layersWithOutsidePointerEventsDisabled.delete(d),pQ())},[d,l]),A.useEffect(()=>{const k=()=>g({});return document.addEventListener(HP,k),()=>document.removeEventListener(HP,k)},[]),v.jsx(pr.div,{...c,ref:m,style:{pointerEvents:I?b?"auto":"none":void 0,...r.style},onFocusCapture:pt(r.onFocusCapture,C.onFocusCapture),onBlurCapture:pt(r.onBlurCapture,C.onBlurCapture),onPointerDownCapture:pt(r.onPointerDownCapture,P.onPointerDownCapture)})});up.displayName=Z2e;var eke="DismissableLayerBranch",ace=A.forwardRef((r,e)=>{const t=A.useContext(sce),n=A.useRef(null),i=$r(e,n);return A.useEffect(()=>{const o=n.current;if(o)return t.branches.add(o),()=>{t.branches.delete(o)}},[t.branches]),v.jsx(pr.div,{...r,ref:i})});ace.displayName=eke;function tke(r,e=globalThis==null?void 0:globalThis.document){const t=ri(r),n=A.useRef(!1),i=A.useRef(()=>{});return A.useEffect(()=>{const o=a=>{if(a.target&&!n.current){let c=function(){cce(Q2e,t,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=c,e.addEventListener("click",i.current,{once:!0})):c()}else e.removeEventListener("click",i.current);n.current=!1},s=window.setTimeout(()=>{e.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(s),e.removeEventListener("pointerdown",o),e.removeEventListener("click",i.current)}},[e,t]),{onPointerDownCapture:()=>n.current=!0}}function rke(r,e=globalThis==null?void 0:globalThis.document){const t=ri(r),n=A.useRef(!1);return A.useEffect(()=>{const i=o=>{o.target&&!n.current&&cce(J2e,t,{originalEvent:o},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,t]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function pQ(){const r=new CustomEvent(HP);document.dispatchEvent(r)}function cce(r,e,t,{discrete:n}){const i=t.originalEvent.target,o=new CustomEvent(r,{bubbles:!1,cancelable:!0,detail:t});e&&i.addEventListener(r,e,{once:!0}),n?SA(i,o):i.dispatchEvent(o)}var nke=up,ike=ace,bI=0;function _A(){A.useEffect(()=>{const r=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",r[0]??gQ()),document.body.insertAdjacentElement("beforeend",r[1]??gQ()),bI++,()=>{bI===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),bI--}},[])}function gQ(){const r=document.createElement("span");return r.setAttribute("data-radix-focus-guard",""),r.tabIndex=0,r.style.outline="none",r.style.opacity="0",r.style.position="fixed",r.style.pointerEvents="none",r}var EI="focusScope.autoFocusOnMount",II="focusScope.autoFocusOnUnmount",vQ={bubbles:!1,cancelable:!0},oke="FocusScope",Ly=A.forwardRef((r,e)=>{const{loop:t=!1,trapped:n=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...s}=r,[a,c]=A.useState(null),l=ri(i),d=ri(o),f=A.useRef(null),h=$r(e,y=>c(y)),g=A.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;A.useEffect(()=>{if(n){let y=function(I){if(g.paused||!a)return;const b=I.target;a.contains(b)?f.current=b:Bc(f.current,{select:!0})},x=function(I){if(g.paused||!a)return;const b=I.relatedTarget;b!==null&&(a.contains(b)||Bc(f.current,{select:!0}))},_=function(I){if(document.activeElement===document.body)for(const P of I)P.removedNodes.length>0&&Bc(a)};document.addEventListener("focusin",y),document.addEventListener("focusout",x);const w=new MutationObserver(_);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",x),w.disconnect()}}},[n,a,g.paused]),A.useEffect(()=>{if(a){yQ.add(g);const y=document.activeElement;if(!a.contains(y)){const _=new CustomEvent(EI,vQ);a.addEventListener(EI,l),a.dispatchEvent(_),_.defaultPrevented||(ske(dke(lce(a)),{select:!0}),document.activeElement===y&&Bc(a))}return()=>{a.removeEventListener(EI,l),setTimeout(()=>{const _=new CustomEvent(II,vQ);a.addEventListener(II,d),a.dispatchEvent(_),_.defaultPrevented||Bc(y??document.body,{select:!0}),a.removeEventListener(II,d),yQ.remove(g)},0)}}},[a,l,d,g]);const m=A.useCallback(y=>{if(!t&&!n||g.paused)return;const x=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,_=document.activeElement;if(x&&_){const w=y.currentTarget,[I,b]=ake(w);I&&b?!y.shiftKey&&_===b?(y.preventDefault(),t&&Bc(I,{select:!0})):y.shiftKey&&_===I&&(y.preventDefault(),t&&Bc(b,{select:!0})):_===w&&y.preventDefault()}},[t,n,g.paused]);return v.jsx(pr.div,{tabIndex:-1,...s,ref:h,onKeyDown:m})});Ly.displayName=oke;function ske(r,{select:e=!1}={}){const t=document.activeElement;for(const n of r)if(Bc(n,{select:e}),document.activeElement!==t)return}function ake(r){const e=lce(r),t=mQ(e,r),n=mQ(e.reverse(),r);return[t,n]}function lce(r){const e=[],t=document.createTreeWalker(r,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const i=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||i?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;t.nextNode();)e.push(t.currentNode);return e}function mQ(r,e){for(const t of r)if(!cke(t,{upTo:e}))return t}function cke(r,{upTo:e}){if(getComputedStyle(r).visibility==="hidden")return!0;for(;r;){if(e!==void 0&&r===e)return!1;if(getComputedStyle(r).display==="none")return!0;r=r.parentElement}return!1}function lke(r){return r instanceof HTMLInputElement&&"select"in r}function Bc(r,{select:e=!1}={}){if(r&&r.focus){const t=document.activeElement;r.focus({preventScroll:!0}),r!==t&&lke(r)&&e&&r.select()}}var yQ=uke();function uke(){let r=[];return{add(e){const t=r[0];e!==t&&(t==null||t.pause()),r=SQ(r,e),r.unshift(e)},remove(e){var t;r=SQ(r,e),(t=r[0])==null||t.resume()}}}function SQ(r,e){const t=[...r],n=t.indexOf(e);return n!==-1&&t.splice(n,1),t}function dke(r){return r.filter(e=>e.tagName!=="A")}var el=globalThis!=null&&globalThis.document?A.useLayoutEffect:()=>{},fke=gge.useId||(()=>{}),hke=0;function nc(r){const[e,t]=A.useState(fke());return el(()=>{t(n=>n??String(hke++))},[r]),r||(e?`radix-${e}`:"")}const pke=["top","right","bottom","left"],tl=Math.min,Co=Math.max,om=Math.round,Lg=Math.floor,ha=r=>({x:r,y:r}),gke={left:"right",right:"left",bottom:"top",top:"bottom"},vke={start:"end",end:"start"};function WP(r,e,t){return Co(r,tl(e,t))}function oc(r,e){return typeof r=="function"?r(e):r}function sc(r){return r.split("-")[0]}function Jd(r){return r.split("-")[1]}function wA(r){return r==="x"?"y":"x"}function bA(r){return r==="y"?"height":"width"}function rl(r){return["top","bottom"].includes(sc(r))?"y":"x"}function EA(r){return wA(rl(r))}function mke(r,e,t){t===void 0&&(t=!1);const n=Jd(r),i=EA(r),o=bA(i);let s=i==="x"?n===(t?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=sm(s)),[s,sm(s)]}function yke(r){const e=sm(r);return[KP(r),e,KP(e)]}function KP(r){return r.replace(/start|end/g,e=>vke[e])}function Ske(r,e,t){const n=["left","right"],i=["right","left"],o=["top","bottom"],s=["bottom","top"];switch(r){case"top":case"bottom":return t?e?i:n:e?n:i;case"left":case"right":return e?o:s;default:return[]}}function xke(r,e,t,n){const i=Jd(r);let o=Ske(sc(r),t==="start",n);return i&&(o=o.map(s=>s+"-"+i),e&&(o=o.concat(o.map(KP)))),o}function sm(r){return r.replace(/left|right|bottom|top/g,e=>gke[e])}function _ke(r){return{top:0,right:0,bottom:0,left:0,...r}}function uce(r){return typeof r!="number"?_ke(r):{top:r,right:r,bottom:r,left:r}}function am(r){const{x:e,y:t,width:n,height:i}=r;return{width:n,height:i,top:t,left:e,right:e+n,bottom:t+i,x:e,y:t}}function xQ(r,e,t){let{reference:n,floating:i}=r;const o=rl(e),s=EA(e),a=bA(s),c=sc(e),l=o==="y",d=n.x+n.width/2-i.width/2,f=n.y+n.height/2-i.height/2,h=n[a]/2-i[a]/2;let g;switch(c){case"top":g={x:d,y:n.y-i.height};break;case"bottom":g={x:d,y:n.y+n.height};break;case"right":g={x:n.x+n.width,y:f};break;case"left":g={x:n.x-i.width,y:f};break;default:g={x:n.x,y:n.y}}switch(Jd(e)){case"start":g[s]-=h*(t&&l?-1:1);break;case"end":g[s]+=h*(t&&l?-1:1);break}return g}const wke=async(r,e,t)=>{const{placement:n="bottom",strategy:i="absolute",middleware:o=[],platform:s}=t,a=o.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(e));let l=await s.getElementRects({reference:r,floating:e,strategy:i}),{x:d,y:f}=xQ(l,n,c),h=n,g={},m=0;for(let y=0;y<a.length;y++){const{name:x,fn:_}=a[y],{x:w,y:I,data:b,reset:P}=await _({x:d,y:f,initialPlacement:n,placement:h,strategy:i,middlewareData:g,rects:l,platform:s,elements:{reference:r,floating:e}});d=w??d,f=I??f,g={...g,[x]:{...g[x],...b}},P&&m<=50&&(m++,typeof P=="object"&&(P.placement&&(h=P.placement),P.rects&&(l=P.rects===!0?await s.getElementRects({reference:r,floating:e,strategy:i}):P.rects),{x:d,y:f}=xQ(l,h,c)),y=-1)}return{x:d,y:f,placement:h,strategy:i,middlewareData:g}};async function bh(r,e){var t;e===void 0&&(e={});const{x:n,y:i,platform:o,rects:s,elements:a,strategy:c}=r,{boundary:l="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:g=0}=oc(e,r),m=uce(g),x=a[h?f==="floating"?"reference":"floating":f],_=am(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(x)))==null||t?x:x.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:l,rootBoundary:d,strategy:c})),w=f==="floating"?{x:n,y:i,width:s.floating.width,height:s.floating.height}:s.reference,I=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),b=await(o.isElement==null?void 0:o.isElement(I))?await(o.getScale==null?void 0:o.getScale(I))||{x:1,y:1}:{x:1,y:1},P=am(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:I,strategy:c}):w);return{top:(_.top-P.top+m.top)/b.y,bottom:(P.bottom-_.bottom+m.bottom)/b.y,left:(_.left-P.left+m.left)/b.x,right:(P.right-_.right+m.right)/b.x}}const bke=r=>({name:"arrow",options:r,async fn(e){const{x:t,y:n,placement:i,rects:o,platform:s,elements:a,middlewareData:c}=e,{element:l,padding:d=0}=oc(r,e)||{};if(l==null)return{};const f=uce(d),h={x:t,y:n},g=EA(i),m=bA(g),y=await s.getDimensions(l),x=g==="y",_=x?"top":"left",w=x?"bottom":"right",I=x?"clientHeight":"clientWidth",b=o.reference[m]+o.reference[g]-h[g]-o.floating[m],P=h[g]-o.reference[g],C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l));let k=C?C[I]:0;(!k||!await(s.isElement==null?void 0:s.isElement(C)))&&(k=a.floating[I]||o.floating[m]);const O=b/2-P/2,L=k/2-y[m]/2-1,j=tl(f[_],L),F=tl(f[w],L),$=j,D=k-y[m]-F,N=k/2-y[m]/2+O,B=WP($,N,D),W=!c.arrow&&Jd(i)!=null&&N!==B&&o.reference[m]/2-(N<$?j:F)-y[m]/2<0,G=W?N<$?N-$:N-D:0;return{[g]:h[g]+G,data:{[g]:B,centerOffset:N-B-G,...W&&{alignmentOffset:G}},reset:W}}}),Eke=function(r){return r===void 0&&(r={}),{name:"flip",options:r,async fn(e){var t,n;const{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:c,elements:l}=e,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:y=!0,...x}=oc(r,e);if((t=o.arrow)!=null&&t.alignmentOffset)return{};const _=sc(i),w=rl(a),I=sc(a)===a,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),P=h||(I||!y?[sm(a)]:yke(a)),C=m!=="none";!h&&C&&P.push(...xke(a,y,m,b));const k=[a,...P],O=await bh(e,x),L=[];let j=((n=o.flip)==null?void 0:n.overflows)||[];if(d&&L.push(O[_]),f){const N=mke(i,s,b);L.push(O[N[0]],O[N[1]])}if(j=[...j,{placement:i,overflows:L}],!L.every(N=>N<=0)){var F,$;const N=(((F=o.flip)==null?void 0:F.index)||0)+1,B=k[N];if(B)return{data:{index:N,overflows:j},reset:{placement:B}};let W=($=j.filter(G=>G.overflows[0]<=0).sort((G,z)=>G.overflows[1]-z.overflows[1])[0])==null?void 0:$.placement;if(!W)switch(g){case"bestFit":{var D;const G=(D=j.filter(z=>{if(C){const V=rl(z.placement);return V===w||V==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(V=>V>0).reduce((V,J)=>V+J,0)]).sort((z,V)=>z[1]-V[1])[0])==null?void 0:D[0];G&&(W=G);break}case"initialPlacement":W=a;break}if(i!==W)return{reset:{placement:W}}}return{}}}};function _Q(r,e){return{top:r.top-e.height,right:r.right-e.width,bottom:r.bottom-e.height,left:r.left-e.width}}function wQ(r){return pke.some(e=>r[e]>=0)}const Ike=function(r){return r===void 0&&(r={}),{name:"hide",options:r,async fn(e){const{rects:t}=e,{strategy:n="referenceHidden",...i}=oc(r,e);switch(n){case"referenceHidden":{const o=await bh(e,{...i,elementContext:"reference"}),s=_Q(o,t.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:wQ(s)}}}case"escaped":{const o=await bh(e,{...i,altBoundary:!0}),s=_Q(o,t.floating);return{data:{escapedOffsets:s,escaped:wQ(s)}}}default:return{}}}}};async function Pke(r,e){const{placement:t,platform:n,elements:i}=r,o=await(n.isRTL==null?void 0:n.isRTL(i.floating)),s=sc(t),a=Jd(t),c=rl(t)==="y",l=["left","top"].includes(s)?-1:1,d=o&&c?-1:1,f=oc(e,r);let{mainAxis:h,crossAxis:g,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof m=="number"&&(g=a==="end"?m*-1:m),c?{x:g*d,y:h*l}:{x:h*l,y:g*d}}const Cke=function(r){return r===void 0&&(r=0),{name:"offset",options:r,async fn(e){var t,n;const{x:i,y:o,placement:s,middlewareData:a}=e,c=await Pke(e,r);return s===((t=a.offset)==null?void 0:t.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:i+c.x,y:o+c.y,data:{...c,placement:s}}}}},Tke=function(r){return r===void 0&&(r={}),{name:"shift",options:r,async fn(e){const{x:t,y:n,placement:i}=e,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:x=>{let{x:_,y:w}=x;return{x:_,y:w}}},...c}=oc(r,e),l={x:t,y:n},d=await bh(e,c),f=rl(sc(i)),h=wA(f);let g=l[h],m=l[f];if(o){const x=h==="y"?"top":"left",_=h==="y"?"bottom":"right",w=g+d[x],I=g-d[_];g=WP(w,g,I)}if(s){const x=f==="y"?"top":"left",_=f==="y"?"bottom":"right",w=m+d[x],I=m-d[_];m=WP(w,m,I)}const y=a.fn({...e,[h]:g,[f]:m});return{...y,data:{x:y.x-t,y:y.y-n,enabled:{[h]:o,[f]:s}}}}}},Ake=function(r){return r===void 0&&(r={}),{options:r,fn(e){const{x:t,y:n,placement:i,rects:o,middlewareData:s}=e,{offset:a=0,mainAxis:c=!0,crossAxis:l=!0}=oc(r,e),d={x:t,y:n},f=rl(i),h=wA(f);let g=d[h],m=d[f];const y=oc(a,e),x=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){const I=h==="y"?"height":"width",b=o.reference[h]-o.floating[I]+x.mainAxis,P=o.reference[h]+o.reference[I]-x.mainAxis;g<b?g=b:g>P&&(g=P)}if(l){var _,w;const I=h==="y"?"width":"height",b=["top","left"].includes(sc(i)),P=o.reference[f]-o.floating[I]+(b&&((_=s.offset)==null?void 0:_[f])||0)+(b?0:x.crossAxis),C=o.reference[f]+o.reference[I]+(b?0:((w=s.offset)==null?void 0:w[f])||0)-(b?x.crossAxis:0);m<P?m=P:m>C&&(m=C)}return{[h]:g,[f]:m}}}},Rke=function(r){return r===void 0&&(r={}),{name:"size",options:r,async fn(e){var t,n;const{placement:i,rects:o,platform:s,elements:a}=e,{apply:c=()=>{},...l}=oc(r,e),d=await bh(e,l),f=sc(i),h=Jd(i),g=rl(i)==="y",{width:m,height:y}=o.floating;let x,_;f==="top"||f==="bottom"?(x=f,_=h===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(_=f,x=h==="end"?"top":"bottom");const w=y-d.top-d.bottom,I=m-d.left-d.right,b=tl(y-d[x],w),P=tl(m-d[_],I),C=!e.middlewareData.shift;let k=b,O=P;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(O=I),(n=e.middlewareData.shift)!=null&&n.enabled.y&&(k=w),C&&!h){const j=Co(d.left,0),F=Co(d.right,0),$=Co(d.top,0),D=Co(d.bottom,0);g?O=m-2*(j!==0||F!==0?j+F:Co(d.left,d.right)):k=y-2*($!==0||D!==0?$+D:Co(d.top,d.bottom))}await c({...e,availableWidth:O,availableHeight:k});const L=await s.getDimensions(a.floating);return m!==L.width||y!==L.height?{reset:{rects:!0}}:{}}}};function Fy(){return typeof window<"u"}function ef(r){return dce(r)?(r.nodeName||"").toLowerCase():"#document"}function jo(r){var e;return(r==null||(e=r.ownerDocument)==null?void 0:e.defaultView)||window}function Ra(r){var e;return(e=(dce(r)?r.ownerDocument:r.document)||window.document)==null?void 0:e.documentElement}function dce(r){return Fy()?r instanceof Node||r instanceof jo(r).Node:!1}function Os(r){return Fy()?r instanceof Element||r instanceof jo(r).Element:!1}function ya(r){return Fy()?r instanceof HTMLElement||r instanceof jo(r).HTMLElement:!1}function bQ(r){return!Fy()||typeof ShadowRoot>"u"?!1:r instanceof ShadowRoot||r instanceof jo(r).ShadowRoot}function dp(r){const{overflow:e,overflowX:t,overflowY:n,display:i}=Ms(r);return/auto|scroll|overlay|hidden|clip/.test(e+n+t)&&!["inline","contents"].includes(i)}function kke(r){return["table","td","th"].includes(ef(r))}function Ny(r){return[":popover-open",":modal"].some(e=>{try{return r.matches(e)}catch{return!1}})}function IA(r){const e=PA(),t=Os(r)?Ms(r):r;return["transform","translate","scale","rotate","perspective"].some(n=>t[n]?t[n]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(n=>(t.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(t.contain||"").includes(n))}function Oke(r){let e=nl(r);for(;ya(e)&&!bd(e);){if(IA(e))return e;if(Ny(e))return null;e=nl(e)}return null}function PA(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function bd(r){return["html","body","#document"].includes(ef(r))}function Ms(r){return jo(r).getComputedStyle(r)}function $y(r){return Os(r)?{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}:{scrollLeft:r.scrollX,scrollTop:r.scrollY}}function nl(r){if(ef(r)==="html")return r;const e=r.assignedSlot||r.parentNode||bQ(r)&&r.host||Ra(r);return bQ(e)?e.host:e}function fce(r){const e=nl(r);return bd(e)?r.ownerDocument?r.ownerDocument.body:r.body:ya(e)&&dp(e)?e:fce(e)}function Eh(r,e,t){var n;e===void 0&&(e=[]),t===void 0&&(t=!0);const i=fce(r),o=i===((n=r.ownerDocument)==null?void 0:n.body),s=jo(i);if(o){const a=GP(s);return e.concat(s,s.visualViewport||[],dp(i)?i:[],a&&t?Eh(a):[])}return e.concat(i,Eh(i,[],t))}function GP(r){return r.parent&&Object.getPrototypeOf(r.parent)?r.frameElement:null}function hce(r){const e=Ms(r);let t=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const i=ya(r),o=i?r.offsetWidth:t,s=i?r.offsetHeight:n,a=om(t)!==o||om(n)!==s;return a&&(t=o,n=s),{width:t,height:n,$:a}}function CA(r){return Os(r)?r:r.contextElement}function yd(r){const e=CA(r);if(!ya(e))return ha(1);const t=e.getBoundingClientRect(),{width:n,height:i,$:o}=hce(e);let s=(o?om(t.width):t.width)/n,a=(o?om(t.height):t.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const Mke=ha(0);function pce(r){const e=jo(r);return!PA()||!e.visualViewport?Mke:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function jke(r,e,t){return e===void 0&&(e=!1),!t||e&&t!==jo(r)?!1:e}function Jl(r,e,t,n){e===void 0&&(e=!1),t===void 0&&(t=!1);const i=r.getBoundingClientRect(),o=CA(r);let s=ha(1);e&&(n?Os(n)&&(s=yd(n)):s=yd(r));const a=jke(o,t,n)?pce(o):ha(0);let c=(i.left+a.x)/s.x,l=(i.top+a.y)/s.y,d=i.width/s.x,f=i.height/s.y;if(o){const h=jo(o),g=n&&Os(n)?jo(n):n;let m=h,y=GP(m);for(;y&&n&&g!==m;){const x=yd(y),_=y.getBoundingClientRect(),w=Ms(y),I=_.left+(y.clientLeft+parseFloat(w.paddingLeft))*x.x,b=_.top+(y.clientTop+parseFloat(w.paddingTop))*x.y;c*=x.x,l*=x.y,d*=x.x,f*=x.y,c+=I,l+=b,m=jo(y),y=GP(m)}}return am({width:d,height:f,x:c,y:l})}function TA(r,e){const t=$y(r).scrollLeft;return e?e.left+t:Jl(Ra(r)).left+t}function gce(r,e,t){t===void 0&&(t=!1);const n=r.getBoundingClientRect(),i=n.left+e.scrollLeft-(t?0:TA(r,n)),o=n.top+e.scrollTop;return{x:i,y:o}}function Dke(r){let{elements:e,rect:t,offsetParent:n,strategy:i}=r;const o=i==="fixed",s=Ra(n),a=e?Ny(e.floating):!1;if(n===s||a&&o)return t;let c={scrollLeft:0,scrollTop:0},l=ha(1);const d=ha(0),f=ya(n);if((f||!f&&!o)&&((ef(n)!=="body"||dp(s))&&(c=$y(n)),ya(n))){const g=Jl(n);l=yd(n),d.x=g.x+n.clientLeft,d.y=g.y+n.clientTop}const h=s&&!f&&!o?gce(s,c,!0):ha(0);return{width:t.width*l.x,height:t.height*l.y,x:t.x*l.x-c.scrollLeft*l.x+d.x+h.x,y:t.y*l.y-c.scrollTop*l.y+d.y+h.y}}function Lke(r){return Array.from(r.getClientRects())}function Fke(r){const e=Ra(r),t=$y(r),n=r.ownerDocument.body,i=Co(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),o=Co(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-t.scrollLeft+TA(r);const a=-t.scrollTop;return Ms(n).direction==="rtl"&&(s+=Co(e.clientWidth,n.clientWidth)-i),{width:i,height:o,x:s,y:a}}function Nke(r,e){const t=jo(r),n=Ra(r),i=t.visualViewport;let o=n.clientWidth,s=n.clientHeight,a=0,c=0;if(i){o=i.width,s=i.height;const l=PA();(!l||l&&e==="fixed")&&(a=i.offsetLeft,c=i.offsetTop)}return{width:o,height:s,x:a,y:c}}function $ke(r,e){const t=Jl(r,!0,e==="fixed"),n=t.top+r.clientTop,i=t.left+r.clientLeft,o=ya(r)?yd(r):ha(1),s=r.clientWidth*o.x,a=r.clientHeight*o.y,c=i*o.x,l=n*o.y;return{width:s,height:a,x:c,y:l}}function EQ(r,e,t){let n;if(e==="viewport")n=Nke(r,t);else if(e==="document")n=Fke(Ra(r));else if(Os(e))n=$ke(e,t);else{const i=pce(r);n={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return am(n)}function vce(r,e){const t=nl(r);return t===e||!Os(t)||bd(t)?!1:Ms(t).position==="fixed"||vce(t,e)}function qke(r,e){const t=e.get(r);if(t)return t;let n=Eh(r,[],!1).filter(a=>Os(a)&&ef(a)!=="body"),i=null;const o=Ms(r).position==="fixed";let s=o?nl(r):r;for(;Os(s)&&!bd(s);){const a=Ms(s),c=IA(s);!c&&a.position==="fixed"&&(i=null),(o?!c&&!i:!c&&a.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||dp(s)&&!c&&vce(r,s))?n=n.filter(d=>d!==s):i=a,s=nl(s)}return e.set(r,n),n}function Bke(r){let{element:e,boundary:t,rootBoundary:n,strategy:i}=r;const s=[...t==="clippingAncestors"?Ny(e)?[]:qke(e,this._c):[].concat(t),n],a=s[0],c=s.reduce((l,d)=>{const f=EQ(e,d,i);return l.top=Co(f.top,l.top),l.right=tl(f.right,l.right),l.bottom=tl(f.bottom,l.bottom),l.left=Co(f.left,l.left),l},EQ(e,a,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Uke(r){const{width:e,height:t}=hce(r);return{width:e,height:t}}function zke(r,e,t){const n=ya(e),i=Ra(e),o=t==="fixed",s=Jl(r,!0,o,e);let a={scrollLeft:0,scrollTop:0};const c=ha(0);if(n||!n&&!o)if((ef(e)!=="body"||dp(i))&&(a=$y(e)),n){const h=Jl(e,!0,o,e);c.x=h.x+e.clientLeft,c.y=h.y+e.clientTop}else i&&(c.x=TA(i));const l=i&&!n&&!o?gce(i,a):ha(0),d=s.left+a.scrollLeft-c.x-l.x,f=s.top+a.scrollTop-c.y-l.y;return{x:d,y:f,width:s.width,height:s.height}}function PI(r){return Ms(r).position==="static"}function IQ(r,e){if(!ya(r)||Ms(r).position==="fixed")return null;if(e)return e(r);let t=r.offsetParent;return Ra(r)===t&&(t=t.ownerDocument.body),t}function mce(r,e){const t=jo(r);if(Ny(r))return t;if(!ya(r)){let i=nl(r);for(;i&&!bd(i);){if(Os(i)&&!PI(i))return i;i=nl(i)}return t}let n=IQ(r,e);for(;n&&kke(n)&&PI(n);)n=IQ(n,e);return n&&bd(n)&&PI(n)&&!IA(n)?t:n||Oke(r)||t}const Hke=async function(r){const e=this.getOffsetParent||mce,t=this.getDimensions,n=await t(r.floating);return{reference:zke(r.reference,await e(r.floating),r.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Wke(r){return Ms(r).direction==="rtl"}const Kke={convertOffsetParentRelativeRectToViewportRelativeRect:Dke,getDocumentElement:Ra,getClippingRect:Bke,getOffsetParent:mce,getElementRects:Hke,getClientRects:Lke,getDimensions:Uke,getScale:yd,isElement:Os,isRTL:Wke};function yce(r,e){return r.x===e.x&&r.y===e.y&&r.width===e.width&&r.height===e.height}function Gke(r,e){let t=null,n;const i=Ra(r);function o(){var a;clearTimeout(n),(a=t)==null||a.disconnect(),t=null}function s(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),o();const l=r.getBoundingClientRect(),{left:d,top:f,width:h,height:g}=l;if(a||e(),!h||!g)return;const m=Lg(f),y=Lg(i.clientWidth-(d+h)),x=Lg(i.clientHeight-(f+g)),_=Lg(d),I={rootMargin:-m+"px "+-y+"px "+-x+"px "+-_+"px",threshold:Co(0,tl(1,c))||1};let b=!0;function P(C){const k=C[0].intersectionRatio;if(k!==c){if(!b)return s();k?s(!1,k):n=setTimeout(()=>{s(!1,1e-7)},1e3)}k===1&&!yce(l,r.getBoundingClientRect())&&s(),b=!1}try{t=new IntersectionObserver(P,{...I,root:i.ownerDocument})}catch{t=new IntersectionObserver(P,I)}t.observe(r)}return s(!0),o}function Vke(r,e,t,n){n===void 0&&(n={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,l=CA(r),d=i||o?[...l?Eh(l):[],...Eh(e)]:[];d.forEach(_=>{i&&_.addEventListener("scroll",t,{passive:!0}),o&&_.addEventListener("resize",t)});const f=l&&a?Gke(l,t):null;let h=-1,g=null;s&&(g=new ResizeObserver(_=>{let[w]=_;w&&w.target===l&&g&&(g.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var I;(I=g)==null||I.observe(e)})),t()}),l&&!c&&g.observe(l),g.observe(e));let m,y=c?Jl(r):null;c&&x();function x(){const _=Jl(r);y&&!yce(y,_)&&t(),y=_,m=requestAnimationFrame(x)}return t(),()=>{var _;d.forEach(w=>{i&&w.removeEventListener("scroll",t),o&&w.removeEventListener("resize",t)}),f==null||f(),(_=g)==null||_.disconnect(),g=null,c&&cancelAnimationFrame(m)}}const Yke=Cke,Xke=Tke,Zke=Eke,Qke=Rke,Jke=Ike,PQ=bke,eOe=Ake,tOe=(r,e,t)=>{const n=new Map,i={platform:Kke,...t},o={...i.platform,_c:n};return wke(r,e,{...i,platform:o})};var dv=typeof document<"u"?A.useLayoutEffect:A.useEffect;function cm(r,e){if(r===e)return!0;if(typeof r!=typeof e)return!1;if(typeof r=="function"&&r.toString()===e.toString())return!0;let t,n,i;if(r&&e&&typeof r=="object"){if(Array.isArray(r)){if(t=r.length,t!==e.length)return!1;for(n=t;n--!==0;)if(!cm(r[n],e[n]))return!1;return!0}if(i=Object.keys(r),t=i.length,t!==Object.keys(e).length)return!1;for(n=t;n--!==0;)if(!{}.hasOwnProperty.call(e,i[n]))return!1;for(n=t;n--!==0;){const o=i[n];if(!(o==="_owner"&&r.$$typeof)&&!cm(r[o],e[o]))return!1}return!0}return r!==r&&e!==e}function Sce(r){return typeof window>"u"?1:(r.ownerDocument.defaultView||window).devicePixelRatio||1}function CQ(r,e){const t=Sce(r);return Math.round(e*t)/t}function CI(r){const e=A.useRef(r);return dv(()=>{e.current=r}),e}function rOe(r){r===void 0&&(r={});const{placement:e="bottom",strategy:t="absolute",middleware:n=[],platform:i,elements:{reference:o,floating:s}={},transform:a=!0,whileElementsMounted:c,open:l}=r,[d,f]=A.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[h,g]=A.useState(n);cm(h,n)||g(n);const[m,y]=A.useState(null),[x,_]=A.useState(null),w=A.useCallback(z=>{z!==C.current&&(C.current=z,y(z))},[]),I=A.useCallback(z=>{z!==k.current&&(k.current=z,_(z))},[]),b=o||m,P=s||x,C=A.useRef(null),k=A.useRef(null),O=A.useRef(d),L=c!=null,j=CI(c),F=CI(i),$=CI(l),D=A.useCallback(()=>{if(!C.current||!k.current)return;const z={placement:e,strategy:t,middleware:h};F.current&&(z.platform=F.current),tOe(C.current,k.current,z).then(V=>{const J={...V,isPositioned:$.current!==!1};N.current&&!cm(O.current,J)&&(O.current=J,Yd.flushSync(()=>{f(J)}))})},[h,e,t,F,$]);dv(()=>{l===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[l]);const N=A.useRef(!1);dv(()=>(N.current=!0,()=>{N.current=!1}),[]),dv(()=>{if(b&&(C.current=b),P&&(k.current=P),b&&P){if(j.current)return j.current(b,P,D);D()}},[b,P,D,j,L]);const B=A.useMemo(()=>({reference:C,floating:k,setReference:w,setFloating:I}),[w,I]),W=A.useMemo(()=>({reference:b,floating:P}),[b,P]),G=A.useMemo(()=>{const z={position:t,left:0,top:0};if(!W.floating)return z;const V=CQ(W.floating,d.x),J=CQ(W.floating,d.y);return a?{...z,transform:"translate("+V+"px, "+J+"px)",...Sce(W.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:V,top:J}},[t,a,W.floating,d.x,d.y]);return A.useMemo(()=>({...d,update:D,refs:B,elements:W,floatingStyles:G}),[d,D,B,W,G])}const nOe=r=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:r,fn(t){const{element:n,padding:i}=typeof r=="function"?r(t):r;return n&&e(n)?n.current!=null?PQ({element:n.current,padding:i}).fn(t):{}:n?PQ({element:n,padding:i}).fn(t):{}}}},iOe=(r,e)=>({...Yke(r),options:[r,e]}),oOe=(r,e)=>({...Xke(r),options:[r,e]}),sOe=(r,e)=>({...eOe(r),options:[r,e]}),aOe=(r,e)=>({...Zke(r),options:[r,e]}),cOe=(r,e)=>({...Qke(r),options:[r,e]}),lOe=(r,e)=>({...Jke(r),options:[r,e]}),uOe=(r,e)=>({...nOe(r),options:[r,e]});var dOe="Arrow",xce=A.forwardRef((r,e)=>{const{children:t,width:n=10,height:i=5,...o}=r;return v.jsx(pr.svg,{...o,ref:e,width:n,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:r.asChild?t:v.jsx("polygon",{points:"0,0 30,0 15,10"})})});xce.displayName=dOe;var fOe=xce;function _ce(r){const[e,t]=A.useState(void 0);return el(()=>{if(r){t({width:r.offsetWidth,height:r.offsetHeight});const n=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let s,a;if("borderBoxSize"in o){const c=o.borderBoxSize,l=Array.isArray(c)?c[0]:c;s=l.inlineSize,a=l.blockSize}else s=r.offsetWidth,a=r.offsetHeight;t({width:s,height:a})});return n.observe(r,{box:"border-box"}),()=>n.unobserve(r)}else t(void 0)},[r]),e}var AA="Popper",[wce,qy]=Aa(AA),[hOe,bce]=wce(AA),Ece=r=>{const{__scopePopper:e,children:t}=r,[n,i]=A.useState(null);return v.jsx(hOe,{scope:e,anchor:n,onAnchorChange:i,children:t})};Ece.displayName=AA;var Ice="PopperAnchor",Pce=A.forwardRef((r,e)=>{const{__scopePopper:t,virtualRef:n,...i}=r,o=bce(Ice,t),s=A.useRef(null),a=$r(e,s);return A.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||s.current)}),n?null:v.jsx(pr.div,{...i,ref:a})});Pce.displayName=Ice;var RA="PopperContent",[pOe,gOe]=wce(RA),Cce=A.forwardRef((r,e)=>{var ge,se,ce,_e,Le,Ge;const{__scopePopper:t,side:n="bottom",sideOffset:i=0,align:o="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:g="optimized",onPlaced:m,...y}=r,x=bce(RA,t),[_,w]=A.useState(null),I=$r(e,qe=>w(qe)),[b,P]=A.useState(null),C=_ce(b),k=(C==null?void 0:C.width)??0,O=(C==null?void 0:C.height)??0,L=n+(o!=="center"?"-"+o:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(l)?l:[l],$=F.length>0,D={padding:j,boundary:F.filter(mOe),altBoundary:$},{refs:N,floatingStyles:B,placement:W,isPositioned:G,middlewareData:z}=rOe({strategy:"fixed",placement:L,whileElementsMounted:(...qe)=>Vke(...qe,{animationFrame:g==="always"}),elements:{reference:x.anchor},middleware:[iOe({mainAxis:i+O,alignmentAxis:s}),c&&oOe({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?sOe():void 0,...D}),c&&aOe({...D}),cOe({...D,apply:({elements:qe,rects:mt,availableWidth:St,availableHeight:et})=>{const{width:ct,height:At}=mt.reference,_t=qe.floating.style;_t.setProperty("--radix-popper-available-width",`${St}px`),_t.setProperty("--radix-popper-available-height",`${et}px`),_t.setProperty("--radix-popper-anchor-width",`${ct}px`),_t.setProperty("--radix-popper-anchor-height",`${At}px`)}}),b&&uOe({element:b,padding:a}),yOe({arrowWidth:k,arrowHeight:O}),h&&lOe({strategy:"referenceHidden",...D})]}),[V,J]=Rce(W),K=ri(m);el(()=>{G&&(K==null||K())},[G,K]);const Z=(ge=z.arrow)==null?void 0:ge.x,ee=(se=z.arrow)==null?void 0:se.y,re=((ce=z.arrow)==null?void 0:ce.centerOffset)!==0,[te,le]=A.useState();return el(()=>{_&&le(window.getComputedStyle(_).zIndex)},[_]),v.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...B,transform:G?B.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:te,"--radix-popper-transform-origin":[(_e=z.transformOrigin)==null?void 0:_e.x,(Le=z.transformOrigin)==null?void 0:Le.y].join(" "),...((Ge=z.hide)==null?void 0:Ge.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:r.dir,children:v.jsx(pOe,{scope:t,placedSide:V,onArrowChange:P,arrowX:Z,arrowY:ee,shouldHideArrow:re,children:v.jsx(pr.div,{"data-side":V,"data-align":J,...y,ref:I,style:{...y.style,animation:G?void 0:"none"}})})})});Cce.displayName=RA;var Tce="PopperArrow",vOe={top:"bottom",right:"left",bottom:"top",left:"right"},Ace=A.forwardRef(function(e,t){const{__scopePopper:n,...i}=e,o=gOe(Tce,n),s=vOe[o.placedSide];return v.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:v.jsx(fOe,{...i,ref:t,style:{...i.style,display:"block"}})})});Ace.displayName=Tce;function mOe(r){return r!==null}var yOe=r=>({name:"transformOrigin",options:r,fn(e){var x,_,w;const{placement:t,rects:n,middlewareData:i}=e,s=((x=i.arrow)==null?void 0:x.centerOffset)!==0,a=s?0:r.arrowWidth,c=s?0:r.arrowHeight,[l,d]=Rce(t),f={start:"0%",center:"50%",end:"100%"}[d],h=(((_=i.arrow)==null?void 0:_.x)??0)+a/2,g=(((w=i.arrow)==null?void 0:w.y)??0)+c/2;let m="",y="";return l==="bottom"?(m=s?f:`${h}px`,y=`${-c}px`):l==="top"?(m=s?f:`${h}px`,y=`${n.floating.height+c}px`):l==="right"?(m=`${-c}px`,y=s?f:`${g}px`):l==="left"&&(m=`${n.floating.width+c}px`,y=s?f:`${g}px`),{data:{x:m,y}}}});function Rce(r){const[e,t="center"]=r.split("-");return[e,t]}var kA=Ece,OA=Pce,kce=Cce,Oce=Ace,SOe="Portal",fp=A.forwardRef((r,e)=>{var a;const{container:t,...n}=r,[i,o]=A.useState(!1);el(()=>o(!0),[]);const s=t||i&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return s?pTe.createPortal(v.jsx(pr.div,{...n,ref:e}),s):null});fp.displayName=SOe;function xOe(r,e){return A.useReducer((t,n)=>e[t][n]??t,r)}var Us=r=>{const{present:e,children:t}=r,n=_Oe(e),i=typeof t=="function"?t({present:n.isPresent}):A.Children.only(t),o=$r(n.ref,wOe(i));return typeof t=="function"||n.isPresent?A.cloneElement(i,{ref:o}):null};Us.displayName="Presence";function _Oe(r){const[e,t]=A.useState(),n=A.useRef({}),i=A.useRef(r),o=A.useRef("none"),s=r?"mounted":"unmounted",[a,c]=xOe(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return A.useEffect(()=>{const l=Fg(n.current);o.current=a==="mounted"?l:"none"},[a]),el(()=>{const l=n.current,d=i.current;if(d!==r){const h=o.current,g=Fg(l);r?c("MOUNT"):g==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(d&&h!==g?"ANIMATION_OUT":"UNMOUNT"),i.current=r}},[r,c]),el(()=>{if(e){let l;const d=e.ownerDocument.defaultView??window,f=g=>{const y=Fg(n.current).includes(g.animationName);if(g.target===e&&y&&(c("ANIMATION_END"),!i.current)){const x=e.style.animationFillMode;e.style.animationFillMode="forwards",l=d.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=x)})}},h=g=>{g.target===e&&(o.current=Fg(n.current))};return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",f),e.addEventListener("animationend",f),()=>{d.clearTimeout(l),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",f),e.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:A.useCallback(l=>{l&&(n.current=getComputedStyle(l)),t(l)},[])}}function Fg(r){return(r==null?void 0:r.animationName)||"none"}function wOe(r){var n,i;let e=(n=Object.getOwnPropertyDescriptor(r.props,"ref"))==null?void 0:n.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?r.ref:(e=(i=Object.getOwnPropertyDescriptor(r,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?r.props.ref:r.props.ref||r.ref)}function ml({prop:r,defaultProp:e,onChange:t=()=>{}}){const[n,i]=bOe({defaultProp:e,onChange:t}),o=r!==void 0,s=o?r:n,a=ri(t),c=A.useCallback(l=>{if(o){const f=typeof l=="function"?l(r):l;f!==r&&a(f)}else i(l)},[o,r,i,a]);return[s,c]}function bOe({defaultProp:r,onChange:e}){const t=A.useState(r),[n]=t,i=A.useRef(n),o=ri(e);return A.useEffect(()=>{i.current!==n&&(o(n),i.current=n)},[n,i,o]),t}var TI="rovingFocusGroup.onEntryFocus",EOe={bubbles:!1,cancelable:!0},By="RovingFocusGroup",[VP,Mce,IOe]=Dy(By),[POe,jce]=Aa(By,[IOe]),[COe,TOe]=POe(By),Dce=A.forwardRef((r,e)=>v.jsx(VP.Provider,{scope:r.__scopeRovingFocusGroup,children:v.jsx(VP.Slot,{scope:r.__scopeRovingFocusGroup,children:v.jsx(AOe,{...r,ref:e})})}));Dce.displayName=By;var AOe=A.forwardRef((r,e)=>{const{__scopeRovingFocusGroup:t,orientation:n,loop:i=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:d=!1,...f}=r,h=A.useRef(null),g=$r(e,h),m=xA(o),[y=null,x]=ml({prop:s,defaultProp:a,onChange:c}),[_,w]=A.useState(!1),I=ri(l),b=Mce(t),P=A.useRef(!1),[C,k]=A.useState(0);return A.useEffect(()=>{const O=h.current;if(O)return O.addEventListener(TI,I),()=>O.removeEventListener(TI,I)},[I]),v.jsx(COe,{scope:t,orientation:n,dir:m,loop:i,currentTabStopId:y,onItemFocus:A.useCallback(O=>x(O),[x]),onItemShiftTab:A.useCallback(()=>w(!0),[]),onFocusableItemAdd:A.useCallback(()=>k(O=>O+1),[]),onFocusableItemRemove:A.useCallback(()=>k(O=>O-1),[]),children:v.jsx(pr.div,{tabIndex:_||C===0?-1:0,"data-orientation":n,...f,ref:g,style:{outline:"none",...r.style},onMouseDown:pt(r.onMouseDown,()=>{P.current=!0}),onFocus:pt(r.onFocus,O=>{const L=!P.current;if(O.target===O.currentTarget&&L&&!_){const j=new CustomEvent(TI,EOe);if(O.currentTarget.dispatchEvent(j),!j.defaultPrevented){const F=b().filter(W=>W.focusable),$=F.find(W=>W.active),D=F.find(W=>W.id===y),B=[$,D,...F].filter(Boolean).map(W=>W.ref.current);Nce(B,d)}}P.current=!1}),onBlur:pt(r.onBlur,()=>w(!1))})})}),Lce="RovingFocusGroupItem",Fce=A.forwardRef((r,e)=>{const{__scopeRovingFocusGroup:t,focusable:n=!0,active:i=!1,tabStopId:o,...s}=r,a=nc(),c=o||a,l=TOe(Lce,t),d=l.currentTabStopId===c,f=Mce(t),{onFocusableItemAdd:h,onFocusableItemRemove:g}=l;return A.useEffect(()=>{if(n)return h(),()=>g()},[n,h,g]),v.jsx(VP.ItemSlot,{scope:t,id:c,focusable:n,active:i,children:v.jsx(pr.span,{tabIndex:d?0:-1,"data-orientation":l.orientation,...s,ref:e,onMouseDown:pt(r.onMouseDown,m=>{n?l.onItemFocus(c):m.preventDefault()}),onFocus:pt(r.onFocus,()=>l.onItemFocus(c)),onKeyDown:pt(r.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){l.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const y=OOe(m,l.orientation,l.dir);if(y!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let _=f().filter(w=>w.focusable).map(w=>w.ref.current);if(y==="last")_.reverse();else if(y==="prev"||y==="next"){y==="prev"&&_.reverse();const w=_.indexOf(m.currentTarget);_=l.loop?MOe(_,w+1):_.slice(w+1)}setTimeout(()=>Nce(_))}})})})});Fce.displayName=Lce;var ROe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function kOe(r,e){return e!=="rtl"?r:r==="ArrowLeft"?"ArrowRight":r==="ArrowRight"?"ArrowLeft":r}function OOe(r,e,t){const n=kOe(r.key,t);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return ROe[n]}function Nce(r,e=!1){const t=document.activeElement;for(const n of r)if(n===t||(n.focus({preventScroll:e}),document.activeElement!==t))return}function MOe(r,e){return r.map((t,n)=>r[(e+n)%r.length])}var jOe=Dce,DOe=Fce,LOe=function(r){if(typeof document>"u")return null;var e=Array.isArray(r)?r[0]:r;return e.ownerDocument.body},td=new WeakMap,Ng=new WeakMap,$g={},AI=0,$ce=function(r){return r&&(r.host||$ce(r.parentNode))},FOe=function(r,e){return e.map(function(t){if(r.contains(t))return t;var n=$ce(t);return n&&r.contains(n)?n:(console.error("aria-hidden",t,"in not contained inside",r,". Doing nothing"),null)}).filter(function(t){return!!t})},NOe=function(r,e,t,n){var i=FOe(e,Array.isArray(r)?r:[r]);$g[t]||($g[t]=new WeakMap);var o=$g[t],s=[],a=new Set,c=new Set(i),l=function(f){!f||a.has(f)||(a.add(f),l(f.parentNode))};i.forEach(l);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var g=h.getAttribute(n),m=g!==null&&g!=="false",y=(td.get(h)||0)+1,x=(o.get(h)||0)+1;td.set(h,y),o.set(h,x),s.push(h),y===1&&m&&Ng.set(h,!0),x===1&&h.setAttribute(t,"true"),m||h.setAttribute(n,"true")}catch(_){console.error("aria-hidden: cannot operate on ",h,_)}})};return d(e),a.clear(),AI++,function(){s.forEach(function(f){var h=td.get(f)-1,g=o.get(f)-1;td.set(f,h),o.set(f,g),h||(Ng.has(f)||f.removeAttribute(n),Ng.delete(f)),g||f.removeAttribute(t)}),AI--,AI||(td=new WeakMap,td=new WeakMap,Ng=new WeakMap,$g={})}},MA=function(r,e,t){t===void 0&&(t="data-aria-hidden");var n=Array.from(Array.isArray(r)?r:[r]),i=LOe(r);return i?(n.push.apply(n,Array.from(i.querySelectorAll("[aria-live]"))),NOe(n,i,t,"aria-hidden")):function(){return null}},aa=function(){return aa=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},aa.apply(this,arguments)};function qce(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t}function $Oe(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}var fv="right-scroll-bar-position",hv="width-before-scroll-bar",qOe="with-scroll-bars-hidden",BOe="--removed-body-scroll-bar-size";function RI(r,e){return typeof r=="function"?r(e):r&&(r.current=e),r}function UOe(r,e){var t=A.useState(function(){return{value:r,callback:e,facade:{get current(){return t.value},set current(n){var i=t.value;i!==n&&(t.value=n,t.callback(n,i))}}}})[0];return t.callback=e,t.facade}var zOe=typeof window<"u"?A.useLayoutEffect:A.useEffect,TQ=new WeakMap;function HOe(r,e){var t=UOe(null,function(n){return r.forEach(function(i){return RI(i,n)})});return zOe(function(){var n=TQ.get(t);if(n){var i=new Set(n),o=new Set(r),s=t.current;i.forEach(function(a){o.has(a)||RI(a,null)}),o.forEach(function(a){i.has(a)||RI(a,s)})}TQ.set(t,r)},[r]),t}function WOe(r){return r}function KOe(r,e){e===void 0&&(e=WOe);var t=[],n=!1,i={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return t.length?t[t.length-1]:r},useMedium:function(o){var s=e(o,n);return t.push(s),function(){t=t.filter(function(a){return a!==s})}},assignSyncMedium:function(o){for(n=!0;t.length;){var s=t;t=[],s.forEach(o)}t={push:function(a){return o(a)},filter:function(){return t}}},assignMedium:function(o){n=!0;var s=[];if(t.length){var a=t;t=[],a.forEach(o),s=t}var c=function(){var d=s;s=[],d.forEach(o)},l=function(){return Promise.resolve().then(c)};l(),t={push:function(d){s.push(d),l()},filter:function(d){return s=s.filter(d),t}}}};return i}function GOe(r){r===void 0&&(r={});var e=KOe(null);return e.options=aa({async:!0,ssr:!1},r),e}var Bce=function(r){var e=r.sideCar,t=qce(r,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=e.read();if(!n)throw new Error("Sidecar medium not found");return A.createElement(n,aa({},t))};Bce.isSideCarExport=!0;function VOe(r,e){return r.useMedium(e),Bce}var Uce=GOe(),kI=function(){},Uy=A.forwardRef(function(r,e){var t=A.useRef(null),n=A.useState({onScrollCapture:kI,onWheelCapture:kI,onTouchMoveCapture:kI}),i=n[0],o=n[1],s=r.forwardProps,a=r.children,c=r.className,l=r.removeScrollBar,d=r.enabled,f=r.shards,h=r.sideCar,g=r.noIsolation,m=r.inert,y=r.allowPinchZoom,x=r.as,_=x===void 0?"div":x,w=r.gapMode,I=qce(r,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),b=h,P=HOe([t,e]),C=aa(aa({},I),i);return A.createElement(A.Fragment,null,d&&A.createElement(b,{sideCar:Uce,removeScrollBar:l,shards:f,noIsolation:g,inert:m,setCallbacks:o,allowPinchZoom:!!y,lockRef:t,gapMode:w}),s?A.cloneElement(A.Children.only(a),aa(aa({},C),{ref:P})):A.createElement(_,aa({},C,{className:c,ref:P}),a))});Uy.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Uy.classNames={fullWidth:hv,zeroRight:fv};var YOe=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function XOe(){if(!document)return null;var r=document.createElement("style");r.type="text/css";var e=YOe();return e&&r.setAttribute("nonce",e),r}function ZOe(r,e){r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}function QOe(r){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(r)}var JOe=function(){var r=0,e=null;return{add:function(t){r==0&&(e=XOe())&&(ZOe(e,t),QOe(e)),r++},remove:function(){r--,!r&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},eMe=function(){var r=JOe();return function(e,t){A.useEffect(function(){return r.add(e),function(){r.remove()}},[e&&t])}},zce=function(){var r=eMe(),e=function(t){var n=t.styles,i=t.dynamic;return r(n,i),null};return e},tMe={left:0,top:0,right:0,gap:0},OI=function(r){return parseInt(r||"",10)||0},rMe=function(r){var e=window.getComputedStyle(document.body),t=e[r==="padding"?"paddingLeft":"marginLeft"],n=e[r==="padding"?"paddingTop":"marginTop"],i=e[r==="padding"?"paddingRight":"marginRight"];return[OI(t),OI(n),OI(i)]},nMe=function(r){if(r===void 0&&(r="margin"),typeof window>"u")return tMe;var e=rMe(r),t=document.documentElement.clientWidth,n=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,n-t+e[2]-e[0])}},iMe=zce(),Sd="data-scroll-locked",oMe=function(r,e,t,n){var i=r.left,o=r.top,s=r.right,a=r.gap;return t===void 0&&(t="margin"),`
203
- .`.concat(qOe,` {
204
- overflow: hidden `).concat(n,`;
205
- padding-right: `).concat(a,"px ").concat(n,`;
206
- }
207
- body[`).concat(Sd,`] {
208
- overflow: hidden `).concat(n,`;
209
- overscroll-behavior: contain;
210
- `).concat([e&&"position: relative ".concat(n,";"),t==="margin"&&`
211
- padding-left: `.concat(i,`px;
212
- padding-top: `).concat(o,`px;
213
- padding-right: `).concat(s,`px;
214
- margin-left:0;
215
- margin-top:0;
216
- margin-right: `).concat(a,"px ").concat(n,`;
217
- `),t==="padding"&&"padding-right: ".concat(a,"px ").concat(n,";")].filter(Boolean).join(""),`
218
- }
219
-
220
- .`).concat(fv,` {
221
- right: `).concat(a,"px ").concat(n,`;
222
- }
223
-
224
- .`).concat(hv,` {
225
- margin-right: `).concat(a,"px ").concat(n,`;
226
- }
227
-
228
- .`).concat(fv," .").concat(fv,` {
229
- right: 0 `).concat(n,`;
230
- }
231
-
232
- .`).concat(hv," .").concat(hv,` {
233
- margin-right: 0 `).concat(n,`;
234
- }
235
-
236
- body[`).concat(Sd,`] {
237
- `).concat(BOe,": ").concat(a,`px;
238
- }
239
- `)},AQ=function(){var r=parseInt(document.body.getAttribute(Sd)||"0",10);return isFinite(r)?r:0},sMe=function(){A.useEffect(function(){return document.body.setAttribute(Sd,(AQ()+1).toString()),function(){var r=AQ()-1;r<=0?document.body.removeAttribute(Sd):document.body.setAttribute(Sd,r.toString())}},[])},aMe=function(r){var e=r.noRelative,t=r.noImportant,n=r.gapMode,i=n===void 0?"margin":n;sMe();var o=A.useMemo(function(){return nMe(i)},[i]);return A.createElement(iMe,{styles:oMe(o,!e,i,t?"":"!important")})},YP=!1;if(typeof window<"u")try{var qg=Object.defineProperty({},"passive",{get:function(){return YP=!0,!0}});window.addEventListener("test",qg,qg),window.removeEventListener("test",qg,qg)}catch{YP=!1}var rd=YP?{passive:!1}:!1,cMe=function(r){return r.tagName==="TEXTAREA"},Hce=function(r,e){if(!(r instanceof Element))return!1;var t=window.getComputedStyle(r);return t[e]!=="hidden"&&!(t.overflowY===t.overflowX&&!cMe(r)&&t[e]==="visible")},lMe=function(r){return Hce(r,"overflowY")},uMe=function(r){return Hce(r,"overflowX")},RQ=function(r,e){var t=e.ownerDocument,n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var i=Wce(r,n);if(i){var o=Kce(r,n),s=o[1],a=o[2];if(s>a)return!0}n=n.parentNode}while(n&&n!==t.body);return!1},dMe=function(r){var e=r.scrollTop,t=r.scrollHeight,n=r.clientHeight;return[e,t,n]},fMe=function(r){var e=r.scrollLeft,t=r.scrollWidth,n=r.clientWidth;return[e,t,n]},Wce=function(r,e){return r==="v"?lMe(e):uMe(e)},Kce=function(r,e){return r==="v"?dMe(e):fMe(e)},hMe=function(r,e){return r==="h"&&e==="rtl"?-1:1},pMe=function(r,e,t,n,i){var o=hMe(r,window.getComputedStyle(e).direction),s=o*n,a=t.target,c=e.contains(a),l=!1,d=s>0,f=0,h=0;do{var g=Kce(r,a),m=g[0],y=g[1],x=g[2],_=y-x-o*m;(m||_)&&Wce(r,a)&&(f+=_,h+=m),a instanceof ShadowRoot?a=a.host:a=a.parentNode}while(!c&&a!==document.body||c&&(e.contains(a)||e===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(l=!0),l},Bg=function(r){return"changedTouches"in r?[r.changedTouches[0].clientX,r.changedTouches[0].clientY]:[0,0]},kQ=function(r){return[r.deltaX,r.deltaY]},OQ=function(r){return r&&"current"in r?r.current:r},gMe=function(r,e){return r[0]===e[0]&&r[1]===e[1]},vMe=function(r){return`
240
- .block-interactivity-`.concat(r,` {pointer-events: none;}
241
- .allow-interactivity-`).concat(r,` {pointer-events: all;}
242
- `)},mMe=0,nd=[];function yMe(r){var e=A.useRef([]),t=A.useRef([0,0]),n=A.useRef(),i=A.useState(mMe++)[0],o=A.useState(zce)[0],s=A.useRef(r);A.useEffect(function(){s.current=r},[r]),A.useEffect(function(){if(r.inert){document.body.classList.add("block-interactivity-".concat(i));var y=$Oe([r.lockRef.current],(r.shards||[]).map(OQ),!0).filter(Boolean);return y.forEach(function(x){return x.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),y.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(i))})}}},[r.inert,r.lockRef.current,r.shards]);var a=A.useCallback(function(y,x){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!s.current.allowPinchZoom;var _=Bg(y),w=t.current,I="deltaX"in y?y.deltaX:w[0]-_[0],b="deltaY"in y?y.deltaY:w[1]-_[1],P,C=y.target,k=Math.abs(I)>Math.abs(b)?"h":"v";if("touches"in y&&k==="h"&&C.type==="range")return!1;var O=RQ(k,C);if(!O)return!0;if(O?P=k:(P=k==="v"?"h":"v",O=RQ(k,C)),!O)return!1;if(!n.current&&"changedTouches"in y&&(I||b)&&(n.current=P),!P)return!0;var L=n.current||P;return pMe(L,x,y,L==="h"?I:b)},[]),c=A.useCallback(function(y){var x=y;if(!(!nd.length||nd[nd.length-1]!==o)){var _="deltaY"in x?kQ(x):Bg(x),w=e.current.filter(function(P){return P.name===x.type&&(P.target===x.target||x.target===P.shadowParent)&&gMe(P.delta,_)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var I=(s.current.shards||[]).map(OQ).filter(Boolean).filter(function(P){return P.contains(x.target)}),b=I.length>0?a(x,I[0]):!s.current.noIsolation;b&&x.cancelable&&x.preventDefault()}}},[]),l=A.useCallback(function(y,x,_,w){var I={name:y,delta:x,target:_,should:w,shadowParent:SMe(_)};e.current.push(I),setTimeout(function(){e.current=e.current.filter(function(b){return b!==I})},1)},[]),d=A.useCallback(function(y){t.current=Bg(y),n.current=void 0},[]),f=A.useCallback(function(y){l(y.type,kQ(y),y.target,a(y,r.lockRef.current))},[]),h=A.useCallback(function(y){l(y.type,Bg(y),y.target,a(y,r.lockRef.current))},[]);A.useEffect(function(){return nd.push(o),r.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,rd),document.addEventListener("touchmove",c,rd),document.addEventListener("touchstart",d,rd),function(){nd=nd.filter(function(y){return y!==o}),document.removeEventListener("wheel",c,rd),document.removeEventListener("touchmove",c,rd),document.removeEventListener("touchstart",d,rd)}},[]);var g=r.removeScrollBar,m=r.inert;return A.createElement(A.Fragment,null,m?A.createElement(o,{styles:vMe(i)}):null,g?A.createElement(aMe,{gapMode:r.gapMode}):null)}function SMe(r){for(var e=null;r!==null;)r instanceof ShadowRoot&&(e=r.host,r=r.host),r=r.parentNode;return e}const xMe=VOe(Uce,yMe);var zy=A.forwardRef(function(r,e){return A.createElement(Uy,aa({},r,{ref:e,sideCar:xMe}))});zy.classNames=Uy.classNames;var XP=["Enter"," "],_Me=["ArrowDown","PageUp","Home"],Gce=["ArrowUp","PageDown","End"],wMe=[..._Me,...Gce],bMe={ltr:[...XP,"ArrowRight"],rtl:[...XP,"ArrowLeft"]},EMe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},hp="Menu",[Ih,IMe,PMe]=Dy(hp),[wu,Hy]=Aa(hp,[PMe,qy,jce]),pp=qy(),Vce=jce(),[Yce,yl]=wu(hp),[CMe,gp]=wu(hp),Xce=r=>{const{__scopeMenu:e,open:t=!1,children:n,dir:i,onOpenChange:o,modal:s=!0}=r,a=pp(e),[c,l]=A.useState(null),d=A.useRef(!1),f=ri(o),h=xA(i);return A.useEffect(()=>{const g=()=>{d.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>d.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),v.jsx(kA,{...a,children:v.jsx(Yce,{scope:e,open:t,onOpenChange:f,content:c,onContentChange:l,children:v.jsx(CMe,{scope:e,onClose:A.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:s,children:n})})})};Xce.displayName=hp;var TMe="MenuAnchor",jA=A.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r,i=pp(t);return v.jsx(OA,{...i,...n,ref:e})});jA.displayName=TMe;var DA="MenuPortal",[AMe,Zce]=wu(DA,{forceMount:void 0}),Qce=r=>{const{__scopeMenu:e,forceMount:t,children:n,container:i}=r,o=yl(DA,e);return v.jsx(AMe,{scope:e,forceMount:t,children:v.jsx(Us,{present:t||o.open,children:v.jsx(fp,{asChild:!0,container:i,children:n})})})};Qce.displayName=DA;var as="MenuContent",[RMe,LA]=wu(as),Jce=A.forwardRef((r,e)=>{const t=Zce(as,r.__scopeMenu),{forceMount:n=t.forceMount,...i}=r,o=yl(as,r.__scopeMenu),s=gp(as,r.__scopeMenu);return v.jsx(Ih.Provider,{scope:r.__scopeMenu,children:v.jsx(Us,{present:n||o.open,children:v.jsx(Ih.Slot,{scope:r.__scopeMenu,children:s.modal?v.jsx(kMe,{...i,ref:e}):v.jsx(OMe,{...i,ref:e})})})})}),kMe=A.forwardRef((r,e)=>{const t=yl(as,r.__scopeMenu),n=A.useRef(null),i=$r(e,n);return A.useEffect(()=>{const o=n.current;if(o)return MA(o)},[]),v.jsx(FA,{...r,ref:i,trapFocus:t.open,disableOutsidePointerEvents:t.open,disableOutsideScroll:!0,onFocusOutside:pt(r.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>t.onOpenChange(!1)})}),OMe=A.forwardRef((r,e)=>{const t=yl(as,r.__scopeMenu);return v.jsx(FA,{...r,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>t.onOpenChange(!1)})}),FA=A.forwardRef((r,e)=>{const{__scopeMenu:t,loop:n=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:g,disableOutsideScroll:m,...y}=r,x=yl(as,t),_=gp(as,t),w=pp(t),I=Vce(t),b=IMe(t),[P,C]=A.useState(null),k=A.useRef(null),O=$r(e,k,x.onContentChange),L=A.useRef(0),j=A.useRef(""),F=A.useRef(0),$=A.useRef(null),D=A.useRef("right"),N=A.useRef(0),B=m?zy:A.Fragment,W=m?{as:Ql,allowPinchZoom:!0}:void 0,G=V=>{var ge,se;const J=j.current+V,K=b().filter(ce=>!ce.disabled),Z=document.activeElement,ee=(ge=K.find(ce=>ce.ref.current===Z))==null?void 0:ge.textValue,re=K.map(ce=>ce.textValue),te=HMe(re,J,ee),le=(se=K.find(ce=>ce.textValue===te))==null?void 0:se.ref.current;(function ce(_e){j.current=_e,window.clearTimeout(L.current),_e!==""&&(L.current=window.setTimeout(()=>ce(""),1e3))})(J),le&&setTimeout(()=>le.focus())};A.useEffect(()=>()=>window.clearTimeout(L.current),[]),_A();const z=A.useCallback(V=>{var K,Z;return D.current===((K=$.current)==null?void 0:K.side)&&KMe(V,(Z=$.current)==null?void 0:Z.area)},[]);return v.jsx(RMe,{scope:t,searchRef:j,onItemEnter:A.useCallback(V=>{z(V)&&V.preventDefault()},[z]),onItemLeave:A.useCallback(V=>{var J;z(V)||((J=k.current)==null||J.focus(),C(null))},[z]),onTriggerLeave:A.useCallback(V=>{z(V)&&V.preventDefault()},[z]),pointerGraceTimerRef:F,onPointerGraceIntentChange:A.useCallback(V=>{$.current=V},[]),children:v.jsx(B,{...W,children:v.jsx(Ly,{asChild:!0,trapped:i,onMountAutoFocus:pt(o,V=>{var J;V.preventDefault(),(J=k.current)==null||J.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:v.jsx(up,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:g,children:v.jsx(jOe,{asChild:!0,...I,dir:_.dir,orientation:"vertical",loop:n,currentTabStopId:P,onCurrentTabStopIdChange:C,onEntryFocus:pt(c,V=>{_.isUsingKeyboardRef.current||V.preventDefault()}),preventScrollOnEntryFocus:!0,children:v.jsx(kce,{role:"menu","aria-orientation":"vertical","data-state":vle(x.open),"data-radix-menu-content":"",dir:_.dir,...w,...y,ref:O,style:{outline:"none",...y.style},onKeyDown:pt(y.onKeyDown,V=>{const K=V.target.closest("[data-radix-menu-content]")===V.currentTarget,Z=V.ctrlKey||V.altKey||V.metaKey,ee=V.key.length===1;K&&(V.key==="Tab"&&V.preventDefault(),!Z&&ee&&G(V.key));const re=k.current;if(V.target!==re||!wMe.includes(V.key))return;V.preventDefault();const le=b().filter(ge=>!ge.disabled).map(ge=>ge.ref.current);Gce.includes(V.key)&&le.reverse(),UMe(le)}),onBlur:pt(r.onBlur,V=>{V.currentTarget.contains(V.target)||(window.clearTimeout(L.current),j.current="")}),onPointerMove:pt(r.onPointerMove,Ph(V=>{const J=V.target,K=N.current!==V.clientX;if(V.currentTarget.contains(J)&&K){const Z=V.clientX>N.current?"right":"left";D.current=Z,N.current=V.clientX}}))})})})})})})});Jce.displayName=as;var MMe="MenuGroup",NA=A.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r;return v.jsx(pr.div,{role:"group",...n,ref:e})});NA.displayName=MMe;var jMe="MenuLabel",ele=A.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r;return v.jsx(pr.div,{...n,ref:e})});ele.displayName=jMe;var lm="MenuItem",MQ="menu.itemSelect",Wy=A.forwardRef((r,e)=>{const{disabled:t=!1,onSelect:n,...i}=r,o=A.useRef(null),s=gp(lm,r.__scopeMenu),a=LA(lm,r.__scopeMenu),c=$r(e,o),l=A.useRef(!1),d=()=>{const f=o.current;if(!t&&f){const h=new CustomEvent(MQ,{bubbles:!0,cancelable:!0});f.addEventListener(MQ,g=>n==null?void 0:n(g),{once:!0}),SA(f,h),h.defaultPrevented?l.current=!1:s.onClose()}};return v.jsx(tle,{...i,ref:c,disabled:t,onClick:pt(r.onClick,d),onPointerDown:f=>{var h;(h=r.onPointerDown)==null||h.call(r,f),l.current=!0},onPointerUp:pt(r.onPointerUp,f=>{var h;l.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:pt(r.onKeyDown,f=>{const h=a.searchRef.current!=="";t||h&&f.key===" "||XP.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Wy.displayName=lm;var tle=A.forwardRef((r,e)=>{const{__scopeMenu:t,disabled:n=!1,textValue:i,...o}=r,s=LA(lm,t),a=Vce(t),c=A.useRef(null),l=$r(e,c),[d,f]=A.useState(!1),[h,g]=A.useState("");return A.useEffect(()=>{const m=c.current;m&&g((m.textContent??"").trim())},[o.children]),v.jsx(Ih.ItemSlot,{scope:t,disabled:n,textValue:i??h,children:v.jsx(DOe,{asChild:!0,...a,focusable:!n,children:v.jsx(pr.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:l,onPointerMove:pt(r.onPointerMove,Ph(m=>{n?s.onItemLeave(m):(s.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:pt(r.onPointerLeave,Ph(m=>s.onItemLeave(m))),onFocus:pt(r.onFocus,()=>f(!0)),onBlur:pt(r.onBlur,()=>f(!1))})})})}),DMe="MenuCheckboxItem",rle=A.forwardRef((r,e)=>{const{checked:t=!1,onCheckedChange:n,...i}=r;return v.jsx(ale,{scope:r.__scopeMenu,checked:t,children:v.jsx(Wy,{role:"menuitemcheckbox","aria-checked":um(t)?"mixed":t,...i,ref:e,"data-state":BA(t),onSelect:pt(i.onSelect,()=>n==null?void 0:n(um(t)?!0:!t),{checkForDefaultPrevented:!1})})})});rle.displayName=DMe;var nle="MenuRadioGroup",[LMe,FMe]=wu(nle,{value:void 0,onValueChange:()=>{}}),ile=A.forwardRef((r,e)=>{const{value:t,onValueChange:n,...i}=r,o=ri(n);return v.jsx(LMe,{scope:r.__scopeMenu,value:t,onValueChange:o,children:v.jsx(NA,{...i,ref:e})})});ile.displayName=nle;var ole="MenuRadioItem",sle=A.forwardRef((r,e)=>{const{value:t,...n}=r,i=FMe(ole,r.__scopeMenu),o=t===i.value;return v.jsx(ale,{scope:r.__scopeMenu,checked:o,children:v.jsx(Wy,{role:"menuitemradio","aria-checked":o,...n,ref:e,"data-state":BA(o),onSelect:pt(n.onSelect,()=>{var s;return(s=i.onValueChange)==null?void 0:s.call(i,t)},{checkForDefaultPrevented:!1})})})});sle.displayName=ole;var $A="MenuItemIndicator",[ale,NMe]=wu($A,{checked:!1}),cle=A.forwardRef((r,e)=>{const{__scopeMenu:t,forceMount:n,...i}=r,o=NMe($A,t);return v.jsx(Us,{present:n||um(o.checked)||o.checked===!0,children:v.jsx(pr.span,{...i,ref:e,"data-state":BA(o.checked)})})});cle.displayName=$A;var $Me="MenuSeparator",lle=A.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r;return v.jsx(pr.div,{role:"separator","aria-orientation":"horizontal",...n,ref:e})});lle.displayName=$Me;var qMe="MenuArrow",ule=A.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r,i=pp(t);return v.jsx(Oce,{...i,...n,ref:e})});ule.displayName=qMe;var qA="MenuSub",[BMe,dle]=wu(qA),fle=r=>{const{__scopeMenu:e,children:t,open:n=!1,onOpenChange:i}=r,o=yl(qA,e),s=pp(e),[a,c]=A.useState(null),[l,d]=A.useState(null),f=ri(i);return A.useEffect(()=>(o.open===!1&&f(!1),()=>f(!1)),[o.open,f]),v.jsx(kA,{...s,children:v.jsx(Yce,{scope:e,open:n,onOpenChange:f,content:l,onContentChange:d,children:v.jsx(BMe,{scope:e,contentId:nc(),triggerId:nc(),trigger:a,onTriggerChange:c,children:t})})})};fle.displayName=qA;var th="MenuSubTrigger",hle=A.forwardRef((r,e)=>{const t=yl(th,r.__scopeMenu),n=gp(th,r.__scopeMenu),i=dle(th,r.__scopeMenu),o=LA(th,r.__scopeMenu),s=A.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=o,l={__scopeMenu:r.__scopeMenu},d=A.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return A.useEffect(()=>d,[d]),A.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),v.jsx(jA,{asChild:!0,...l,children:v.jsx(tle,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":t.open,"aria-controls":i.contentId,"data-state":vle(t.open),...r,ref:jy(e,i.onTriggerChange),onClick:f=>{var h;(h=r.onClick)==null||h.call(r,f),!(r.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),t.open||t.onOpenChange(!0))},onPointerMove:pt(r.onPointerMove,Ph(f=>{o.onItemEnter(f),!f.defaultPrevented&&!r.disabled&&!t.open&&!s.current&&(o.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{t.onOpenChange(!0),d()},100))})),onPointerLeave:pt(r.onPointerLeave,Ph(f=>{var g,m;d();const h=(g=t.content)==null?void 0:g.getBoundingClientRect();if(h){const y=(m=t.content)==null?void 0:m.dataset.side,x=y==="right",_=x?-5:5,w=h[x?"left":"right"],I=h[x?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+_,y:f.clientY},{x:w,y:h.top},{x:I,y:h.top},{x:I,y:h.bottom},{x:w,y:h.bottom}],side:y}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:pt(r.onKeyDown,f=>{var g;const h=o.searchRef.current!=="";r.disabled||h&&f.key===" "||bMe[n.dir].includes(f.key)&&(t.onOpenChange(!0),(g=t.content)==null||g.focus(),f.preventDefault())})})})});hle.displayName=th;var ple="MenuSubContent",gle=A.forwardRef((r,e)=>{const t=Zce(as,r.__scopeMenu),{forceMount:n=t.forceMount,...i}=r,o=yl(as,r.__scopeMenu),s=gp(as,r.__scopeMenu),a=dle(ple,r.__scopeMenu),c=A.useRef(null),l=$r(e,c);return v.jsx(Ih.Provider,{scope:r.__scopeMenu,children:v.jsx(Us,{present:n||o.open,children:v.jsx(Ih.Slot,{scope:r.__scopeMenu,children:v.jsx(FA,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:l,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;s.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:pt(r.onFocusOutside,d=>{d.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:pt(r.onEscapeKeyDown,d=>{s.onClose(),d.preventDefault()}),onKeyDown:pt(r.onKeyDown,d=>{var g;const f=d.currentTarget.contains(d.target),h=EMe[s.dir].includes(d.key);f&&h&&(o.onOpenChange(!1),(g=a.trigger)==null||g.focus(),d.preventDefault())})})})})})});gle.displayName=ple;function vle(r){return r?"open":"closed"}function um(r){return r==="indeterminate"}function BA(r){return um(r)?"indeterminate":r?"checked":"unchecked"}function UMe(r){const e=document.activeElement;for(const t of r)if(t===e||(t.focus(),document.activeElement!==e))return}function zMe(r,e){return r.map((t,n)=>r[(e+n)%r.length])}function HMe(r,e,t){const i=e.length>1&&Array.from(e).every(l=>l===e[0])?e[0]:e,o=t?r.indexOf(t):-1;let s=zMe(r,Math.max(o,0));i.length===1&&(s=s.filter(l=>l!==t));const c=s.find(l=>l.toLowerCase().startsWith(i.toLowerCase()));return c!==t?c:void 0}function WMe(r,e){const{x:t,y:n}=r;let i=!1;for(let o=0,s=e.length-1;o<e.length;s=o++){const a=e[o].x,c=e[o].y,l=e[s].x,d=e[s].y;c>n!=d>n&&t<(l-a)*(n-c)/(d-c)+a&&(i=!i)}return i}function KMe(r,e){if(!e)return!1;const t={x:r.clientX,y:r.clientY};return WMe(t,e)}function Ph(r){return e=>e.pointerType==="mouse"?r(e):void 0}var mle=Xce,yle=jA,Sle=Qce,xle=Jce,_le=NA,wle=ele,ble=Wy,Ele=rle,Ile=ile,Ple=sle,Cle=cle,Tle=lle,Ale=ule,Rle=fle,kle=hle,Ole=gle,UA="ContextMenu",[GMe,T4e]=Aa(UA,[Hy]),ki=Hy(),[VMe,Mle]=GMe(UA),jle=r=>{const{__scopeContextMenu:e,children:t,onOpenChange:n,dir:i,modal:o=!0}=r,[s,a]=A.useState(!1),c=ki(e),l=ri(n),d=A.useCallback(f=>{a(f),l(f)},[l]);return v.jsx(VMe,{scope:e,open:s,onOpenChange:d,modal:o,children:v.jsx(mle,{...c,dir:i,open:s,onOpenChange:d,modal:o,children:t})})};jle.displayName=UA;var Dle="ContextMenuTrigger",Lle=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,disabled:n=!1,...i}=r,o=Mle(Dle,t),s=ki(t),a=A.useRef({x:0,y:0}),c=A.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),l=A.useRef(0),d=A.useCallback(()=>window.clearTimeout(l.current),[]),f=h=>{a.current={x:h.clientX,y:h.clientY},o.onOpenChange(!0)};return A.useEffect(()=>d,[d]),A.useEffect(()=>void(n&&d()),[n,d]),v.jsxs(v.Fragment,{children:[v.jsx(yle,{...s,virtualRef:c}),v.jsx(pr.span,{"data-state":o.open?"open":"closed","data-disabled":n?"":void 0,...i,ref:e,style:{WebkitTouchCallout:"none",...r.style},onContextMenu:n?r.onContextMenu:pt(r.onContextMenu,h=>{d(),f(h),h.preventDefault()}),onPointerDown:n?r.onPointerDown:pt(r.onPointerDown,Ug(h=>{d(),l.current=window.setTimeout(()=>f(h),700)})),onPointerMove:n?r.onPointerMove:pt(r.onPointerMove,Ug(d)),onPointerCancel:n?r.onPointerCancel:pt(r.onPointerCancel,Ug(d)),onPointerUp:n?r.onPointerUp:pt(r.onPointerUp,Ug(d))})]})});Lle.displayName=Dle;var YMe="ContextMenuPortal",zA=r=>{const{__scopeContextMenu:e,...t}=r,n=ki(e);return v.jsx(Sle,{...n,...t})};zA.displayName=YMe;var Fle="ContextMenuContent",Nle=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=Mle(Fle,t),o=ki(t),s=A.useRef(!1);return v.jsx(xle,{...o,...n,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var c;(c=r.onCloseAutoFocus)==null||c.call(r,a),!a.defaultPrevented&&s.current&&a.preventDefault(),s.current=!1},onInteractOutside:a=>{var c;(c=r.onInteractOutside)==null||c.call(r,a),!a.defaultPrevented&&!i.modal&&(s.current=!0)},style:{...r.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Nle.displayName=Fle;var XMe="ContextMenuGroup",$le=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=ki(t);return v.jsx(_le,{...i,...n,ref:e})});$le.displayName=XMe;var ZMe="ContextMenuLabel",QMe=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=ki(t);return v.jsx(wle,{...i,...n,ref:e})});QMe.displayName=ZMe;var JMe="ContextMenuItem",qle=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=ki(t);return v.jsx(ble,{...i,...n,ref:e})});qle.displayName=JMe;var eje="ContextMenuCheckboxItem",Ble=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=ki(t);return v.jsx(Ele,{...i,...n,ref:e})});Ble.displayName=eje;var tje="ContextMenuRadioGroup",rje=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=ki(t);return v.jsx(Ile,{...i,...n,ref:e})});rje.displayName=tje;var nje="ContextMenuRadioItem",ije=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=ki(t);return v.jsx(Ple,{...i,...n,ref:e})});ije.displayName=nje;var oje="ContextMenuItemIndicator",sje=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=ki(t);return v.jsx(Cle,{...i,...n,ref:e})});sje.displayName=oje;var aje="ContextMenuSeparator",cje=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=ki(t);return v.jsx(Tle,{...i,...n,ref:e})});cje.displayName=aje;var lje="ContextMenuArrow",uje=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=ki(t);return v.jsx(Ale,{...i,...n,ref:e})});uje.displayName=lje;var dje="ContextMenuSub",Ule=r=>{const{__scopeContextMenu:e,children:t,onOpenChange:n,open:i,defaultOpen:o}=r,s=ki(e),[a,c]=ml({prop:i,defaultProp:o,onChange:n});return v.jsx(Rle,{...s,open:a,onOpenChange:c,children:t})};Ule.displayName=dje;var fje="ContextMenuSubTrigger",zle=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=ki(t);return v.jsx(kle,{...i,...n,ref:e})});zle.displayName=fje;var hje="ContextMenuSubContent",Hle=A.forwardRef((r,e)=>{const{__scopeContextMenu:t,...n}=r,i=ki(t);return v.jsx(Ole,{...i,...n,ref:e,style:{...r.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Hle.displayName=hje;function Ug(r){return e=>e.pointerType!=="mouse"?r(e):void 0}var pje=jle,gje=Lle,vje=zA,mje=Nle,yje=Ble,HA="DropdownMenu",[Sje,A4e]=Aa(HA,[Hy]),Oi=Hy(),[xje,Wle]=Sje(HA),Kle=r=>{const{__scopeDropdownMenu:e,children:t,dir:n,open:i,defaultOpen:o,onOpenChange:s,modal:a=!0}=r,c=Oi(e),l=A.useRef(null),[d=!1,f]=ml({prop:i,defaultProp:o,onChange:s});return v.jsx(xje,{scope:e,triggerId:nc(),triggerRef:l,contentId:nc(),open:d,onOpenChange:f,onOpenToggle:A.useCallback(()=>f(h=>!h),[f]),modal:a,children:v.jsx(mle,{...c,open:d,onOpenChange:f,dir:n,modal:a,children:t})})};Kle.displayName=HA;var Gle="DropdownMenuTrigger",Vle=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,disabled:n=!1,...i}=r,o=Wle(Gle,t),s=Oi(t);return v.jsx(yle,{asChild:!0,...s,children:v.jsx(pr.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...i,ref:jy(e,o.triggerRef),onPointerDown:pt(r.onPointerDown,a=>{!n&&a.button===0&&a.ctrlKey===!1&&(o.onOpenToggle(),o.open||a.preventDefault())}),onKeyDown:pt(r.onKeyDown,a=>{n||(["Enter"," "].includes(a.key)&&o.onOpenToggle(),a.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Vle.displayName=Gle;var _je="DropdownMenuPortal",Yle=r=>{const{__scopeDropdownMenu:e,...t}=r,n=Oi(e);return v.jsx(Sle,{...n,...t})};Yle.displayName=_je;var Xle="DropdownMenuContent",Zle=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Wle(Xle,t),o=Oi(t),s=A.useRef(!1);return v.jsx(xle,{id:i.contentId,"aria-labelledby":i.triggerId,...o,...n,ref:e,onCloseAutoFocus:pt(r.onCloseAutoFocus,a=>{var c;s.current||(c=i.triggerRef.current)==null||c.focus(),s.current=!1,a.preventDefault()}),onInteractOutside:pt(r.onInteractOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0,d=c.button===2||l;(!i.modal||d)&&(s.current=!0)}),style:{...r.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Zle.displayName=Xle;var wje="DropdownMenuGroup",Qle=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Oi(t);return v.jsx(_le,{...i,...n,ref:e})});Qle.displayName=wje;var bje="DropdownMenuLabel",Eje=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Oi(t);return v.jsx(wle,{...i,...n,ref:e})});Eje.displayName=bje;var Ije="DropdownMenuItem",Jle=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Oi(t);return v.jsx(ble,{...i,...n,ref:e})});Jle.displayName=Ije;var Pje="DropdownMenuCheckboxItem",eue=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Oi(t);return v.jsx(Ele,{...i,...n,ref:e})});eue.displayName=Pje;var Cje="DropdownMenuRadioGroup",Tje=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Oi(t);return v.jsx(Ile,{...i,...n,ref:e})});Tje.displayName=Cje;var Aje="DropdownMenuRadioItem",Rje=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Oi(t);return v.jsx(Ple,{...i,...n,ref:e})});Rje.displayName=Aje;var kje="DropdownMenuItemIndicator",Oje=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Oi(t);return v.jsx(Cle,{...i,...n,ref:e})});Oje.displayName=kje;var Mje="DropdownMenuSeparator",jje=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Oi(t);return v.jsx(Tle,{...i,...n,ref:e})});jje.displayName=Mje;var Dje="DropdownMenuArrow",Lje=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Oi(t);return v.jsx(Ale,{...i,...n,ref:e})});Lje.displayName=Dje;var Fje=r=>{const{__scopeDropdownMenu:e,children:t,open:n,onOpenChange:i,defaultOpen:o}=r,s=Oi(e),[a=!1,c]=ml({prop:n,defaultProp:o,onChange:i});return v.jsx(Rle,{...s,open:a,onOpenChange:c,children:t})},Nje="DropdownMenuSubTrigger",tue=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Oi(t);return v.jsx(kle,{...i,...n,ref:e})});tue.displayName=Nje;var $je="DropdownMenuSubContent",rue=A.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Oi(t);return v.jsx(Ole,{...i,...n,ref:e,style:{...r.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});rue.displayName=$je;var WA=Kle,KA=Vle,Ky=Yle,GA=Zle,qje=Qle,Bje=Jle,Uje=eue,zje=Fje,Hje=tue,Wje=rue;function Fr(r,e){var i;const t=new Set;for(const o of e){const s=r.getShape(o);if(!s)continue;r.getShapeUtil(s).onDragShapesOut&&t.add(s);const a=r.getShape(s.parentId);a&&r.getShapeUtil(a).onDragShapesOut&&t.add(a)}const n=new Map;for(const o of t){const s=nue(r,o);s.length&&n.set(o,s)}for(const[o,s]of n){const a=r.getShapeUtil(o),c=Gt(s.map(l=>r.getShape(l)));(i=a.onDragShapesOut)==null||i.call(a,o,c)}}function nue(r,e){const t=r.getSortedChildIdsForParent(e.id);if(t.length===0)return[];const n=r.getShapePageBounds(e);if(!n)return[];let i,o,s;const a=[];for(const c of t){const l=r.getShapePageBounds(c);if(!l)continue;if(!n.includes(l)){a.push(c);continue}i??(i=r.getShapeGeometry(e)),o??(o=r.getShapePageTransform(e)),s??(s=o.applyToPoints(i.vertices));const d=r.getShapePageTransform(c).clone().invert().applyToPoints(s),{vertices:f,isClosed:h}=r.getShapeGeometry(c);if(!f.some(g=>Oo(g,d))){if(h){if(aA(d,f))continue}else if(fTe(d,f))continue;a.push(c)}}return a}function dm(r,e,t=!1){r.select(e),r.setEditingShape(e),r.setCurrentTool("select.editing_shape",{target:"shape",shape:e}),t&&r.emit("select-all-text",{shapeId:e.id})}function Kje(r,e){const t=Gt(e.map(i=>r.getShape(i)).filter(i=>i&&r.isShapeOfType(i,"frame")));if(!t.length)return;const n=[];r.run(()=>{t.map(i=>{const o=r.getSortedChildIdsForParent(i.id);o.length&&(r.reparentShapes(o,i.parentId,i.index),n.push(...o))}),r.setSelectedShapes(n),r.deleteShapes(e)})}const Gje=50;function Vje(r,e,t={}){const n=r.getShape(e);if(!n)return;const i=r.getSortedChildIdsForParent(n.id),o=Gt(i.map(g=>r.getShape(g)));if(!o.length)return;const s=He.FromPoints(o.flatMap(g=>{const m=r.getShapeGeometry(g.id);return r.getShapeLocalTransform(g).applyToPoints(m.vertices)})),{padding:a=Gje}=t,c=s.w+2*a,l=s.h+2*a,d=a-s.minX,f=a-s.minY;if(d===0&&f===0&&n.props.w===c&&n.props.h===l)return;const h=new T(d,f).rot(n.rotation);r.run(()=>{const g=i.map(m=>{const y=r.getShape(m);return{id:y.id,type:y.type,x:y.x+d,y:y.y+f}});g.push({id:n.id,type:n.type,x:n.x-h.x,y:n.y-h.y,props:{w:c,h:l}}),r.updateShapes(g)})}const iue=A.createContext(null);function Yje({assetUrls:r,children:e}){return A.useEffect(()=>{for(const t of Object.values(r.icons)){const n=vh();n.src=t,n.decode()}for(const t of Object.values(r.embedIcons)){const n=vh();n.src=t,n.decode()}},[r]),v.jsx(iue.Provider,{value:r,children:e})}function VA(){const r=A.useContext(iue);if(!r)throw new Error("useAssetUrls must be used within an AssetUrlsProvider");return r}const ZP={"action.convert-to-bookmark":"Convert to Bookmark","action.convert-to-embed":"Convert to Embed","action.open-embed-link":"Open link","action.align-bottom":"Align bottom","action.align-center-horizontal":"Align horizontally","action.align-center-vertical":"Align vertically","action.align-center-horizontal.short":"Align H","action.align-center-vertical.short":"Align V","action.align-left":"Align left","action.align-right":"Align right","action.align-top":"Align top","action.back-to-content":"Back to content","action.bring-forward":"Bring forward","action.bring-to-front":"Bring to front","action.copy-as-png.short":"PNG","action.copy-as-png":"Copy as PNG","action.copy-as-svg.short":"SVG","action.copy-as-svg":"Copy as SVG","action.copy":"Copy","action.cut":"Cut","action.delete":"Delete","action.unlock-all":"Unlock all","action.distribute-horizontal":"Distribute horizontally","action.distribute-vertical":"Distribute vertically","action.distribute-horizontal.short":"Distribute H","action.distribute-vertical.short":"Distribute V","action.duplicate":"Duplicate","action.edit-link":"Edit link","action.exit-pen-mode":"Exit pen mode","action.export-as-png.short":"PNG","action.export-as-png":"Export as PNG","action.export-as-svg.short":"SVG","action.export-as-svg":"Export as SVG","action.export-all-as-png.short":"PNG","action.export-all-as-png":"Export as PNG","action.export-all-as-svg.short":"SVG","action.export-all-as-svg":"Export as SVG","action.fit-frame-to-content":"Fit to content","action.flip-horizontal":"Flip horizontally","action.flip-vertical":"Flip vertically","action.flip-horizontal.short":"Flip H","action.flip-vertical.short":"Flip V","action.fork-project":"Fork this project","action.fork-project-on-tldraw":"Fork project on tldraw","action.group":"Group","action.insert-embed":"Insert embed","action.insert-media":"Upload media","action.leave-shared-project":"Leave shared project","action.new-project":"New project","action.new-shared-project":"New shared project","action.open-cursor-chat":"Cursor chat","action.open-file":"Open file","action.pack":"Pack","action.paste":"Paste","action.paste-error-title":"Pasting failed","action.paste-error-description":"Could not paste due to missing clipboard permissions. Please enable the permissions and try again.","action.print":"Print","action.redo":"Redo","action.remove-frame":"Remove frame","action.rename":"Rename","action.rotate-ccw":"Rotate counterclockwise","action.rotate-cw":"Rotate clockwise","action.save-copy":"Save a copy","action.select-all":"Select all","action.select-none":"Select none","action.send-backward":"Send backward","action.send-to-back":"Send to back","action.share-project":"Share this project","action.stack-horizontal":"Stack horizontally","action.stack-vertical":"Stack vertically","action.stack-horizontal.short":"Stack H","action.stack-vertical.short":"Stack V","action.stop-following":"Stop following","action.stretch-horizontal":"Stretch horizontally","action.stretch-vertical":"Stretch vertically","action.stretch-horizontal.short":"Stretch H","action.stretch-vertical.short":"Stretch V","action.toggle-auto-size":"Toggle auto size","action.toggle-dark-mode.menu":"Dark mode","action.toggle-dark-mode":"Toggle dark mode","action.toggle-paste-at-cursor.menu":"Paste at cursor","action.toggle-paste-at-cursor":"Toggle paste at cursor","action.toggle-wrap-mode.menu":"Select on wrap","action.toggle-wrap-mode":"Toggle Select on wrap","action.toggle-reduce-motion.menu":"Reduce motion","action.toggle-reduce-motion":"Toggle reduce motion","action.toggle-edge-scrolling.menu":"Edge scrolling","action.toggle-edge-scrolling":"Toggle edge scrolling","action.toggle-debug-mode.menu":"Debug mode","action.toggle-debug-mode":"Toggle debug mode","action.toggle-focus-mode.menu":"Focus mode","action.toggle-focus-mode":"Toggle focus mode","action.toggle-dynamic-size-mode.menu":"Dynamic size","action.toggle-dynamic-size-mode":"Toggle dynamic size","action.toggle-grid.menu":"Show grid","action.toggle-grid":"Toggle grid","action.toggle-lock":"Toggle locked","action.flatten-to-image":"Flatten","action.toggle-snap-mode.menu":"Always snap","action.toggle-snap-mode":"Toggle always snap","action.toggle-tool-lock.menu":"Tool lock","action.toggle-tool-lock":"Toggle tool lock","action.toggle-transparent.context-menu":"Transparent","action.toggle-transparent.menu":"Transparent","action.toggle-transparent":"Toggle transparent background","action.undo":"Undo","action.ungroup":"Ungroup","action.zoom-in":"Zoom in","action.zoom-out":"Zoom out","action.zoom-to-100":"Zoom to 100%","action.zoom-to-fit":"Zoom to fit","action.zoom-to-selection":"Zoom to selection","assets.files.size-too-big":"File size is too big","assets.files.type-not-allowed":"File type is not allowed","assets.files.upload-failed":"Upload failed","assets.files.amount-too-many":"Too many files","assets.url.failed":"Couldn’t load URL preview","theme.dark":"Dark","theme.light":"Light","theme.system":"System","color-style.white":"White","color-style.black":"Black","color-style.blue":"Blue","color-style.green":"Green","color-style.grey":"Grey","color-style.light-blue":"Light blue","color-style.light-green":"Light green","color-style.light-red":"Light red","color-style.light-violet":"Light violet","color-style.orange":"Orange","color-style.red":"Red","color-style.violet":"Violet","color-style.yellow":"Yellow","fill-style.none":"None","document.default-name":"Untitled","fill-style.semi":"Semi","fill-style.solid":"Solid","fill-style.pattern":"Pattern","fill-style.fill":"Fill","dash-style.dashed":"Dashed","dash-style.dotted":"Dotted","dash-style.draw":"Draw","dash-style.solid":"Solid","size-style.s":"Small","size-style.m":"Medium","size-style.l":"Large","size-style.xl":"Extra large","opacity-style.0.1":"10%","opacity-style.0.25":"25%","opacity-style.0.5":"50%","opacity-style.0.75":"75%","opacity-style.1":"100%","font-style.draw":"Draw","font-style.sans":"Sans","font-style.serif":"Serif","font-style.mono":"Mono","align-style.start":"Start","align-style.middle":"Middle","align-style.end":"End","align-style.justify":"Justify","verticalAlign-style.start":"Top","verticalAlign-style.middle":"Middle","verticalAlign-style.end":"Bottom","geo-style.arrow-down":"Arrow down","geo-style.arrow-left":"Arrow left","geo-style.arrow-right":"Arrow right","geo-style.arrow-up":"Arrow up","geo-style.diamond":"Diamond","geo-style.ellipse":"Ellipse","geo-style.hexagon":"Hexagon","geo-style.octagon":"Octagon","geo-style.oval":"Oval","geo-style.cloud":"Cloud","geo-style.pentagon":"Pentagon","geo-style.rectangle":"Rectangle","geo-style.rhombus-2":"Rhombus 2","geo-style.rhombus":"Rhombus","geo-style.star":"Star","geo-style.trapezoid":"Trapezoid","geo-style.triangle":"Triangle","geo-style.x-box":"X box","geo-style.check-box":"Check box","arrowheadStart-style.none":"None","arrowheadStart-style.arrow":"Arrow","arrowheadStart-style.bar":"Bar","arrowheadStart-style.diamond":"Diamond","arrowheadStart-style.dot":"Dot","arrowheadStart-style.inverted":"Inverted","arrowheadStart-style.pipe":"Pipe","arrowheadStart-style.square":"Square","arrowheadStart-style.triangle":"Triangle","arrowheadEnd-style.none":"None","arrowheadEnd-style.arrow":"Arrow","arrowheadEnd-style.bar":"Bar","arrowheadEnd-style.diamond":"Diamond","arrowheadEnd-style.dot":"Dot","arrowheadEnd-style.inverted":"Inverted","arrowheadEnd-style.pipe":"Pipe","arrowheadEnd-style.square":"Square","arrowheadEnd-style.triangle":"Triangle","spline-style.line":"Line","spline-style.cubic":"Cubic","tool.select":"Select","tool.hand":"Hand","tool.draw":"Draw","tool.eraser":"Eraser","tool.arrow-down":"Arrow down","tool.arrow-left":"Arrow left","tool.arrow-right":"Arrow right","tool.arrow-up":"Arrow up","tool.arrow":"Arrow","tool.cloud":"Cloud","tool.diamond":"Diamond","tool.ellipse":"Ellipse","tool.hexagon":"Hexagon","tool.highlight":"Highlight","tool.line":"Line","tool.octagon":"Octagon","tool.oval":"Oval","tool.pentagon":"Pentagon","tool.rectangle":"Rectangle","tool.rhombus":"Rhombus","tool.star":"Star","tool.trapezoid":"Trapezoid","tool.triangle":"Triangle","tool.x-box":"X box","tool.check-box":"Check box","tool.asset":"Asset","tool.frame":"Frame","tool.note":"Note","tool.laser":"Laser","tool.embed":"Embed","tool.text":"Text","tool.pointer-down":"Pointer down","menu.title":"Menu","menu.theme":"Theme","menu.copy-as":"Copy as","menu.edit":"Edit","menu.export-as":"Export as","menu.file":"File","menu.language":"Language","menu.preferences":"Preferences","menu.view":"View","context-menu.edit":"Edit","context-menu.arrange":"Arrange","context-menu.copy-as":"Copy as","context-menu.export-as":"Export as","context-menu.export-all-as":"Export","context-menu.move-to-page":"Move to page","context-menu.reorder":"Reorder","page-menu.title":"Pages","page-menu.create-new-page":"Create new page","page-menu.max-page-count-reached":"Max pages reached","page-menu.new-page-initial-name":"Page 1","page-menu.edit-start":"Edit","page-menu.edit-done":"Done","page-menu.go-to-page":"Go to page","page-menu.submenu.rename":"Rename","page-menu.submenu.duplicate-page":"Duplicate","page-menu.submenu.title":"Menu","page-menu.submenu.move-down":"Move down","page-menu.submenu.move-up":"Move up","page-menu.submenu.delete":"Delete","share-menu.title":"Share","share-menu.save-note":"Download this project to your computer as a .tldr file.","share-menu.fork-note":"Create a new shared project based on this snapshot.","share-menu.share-project":"Share this project","share-menu.copy-link":"Copy editor link","share-menu.create-snapshot-link":"Copy snapshot link","share-menu.snapshot-link-note":"Capture and share this project as a read-only snapshot link.","share-menu.copy-readonly-link":"Copy viewer link","share-menu.offline-note":"Create a new shared project based on your current project.","share-menu.copy-link-note":"Anyone with the link will be able to view and edit this project.","share-menu.copy-readonly-link-note":"Anyone with the link will be able to access this project.","share-menu.project-too-large":"Sorry, this project can’t be shared because it’s too large. We’re working on it!","share-menu.upload-failed":"Sorry, we couldn’t upload your project at the moment. Please try again or let us know if the problem persists.","share-menu.creating-project":"Creating the new project…","share-menu.copied":"Copied link","document-name-menu.copy-link":"Copy link","status.offline":"Offline","people-menu.title":"People","people-menu.change-name":"Change name","people-menu.change-color":"Change color","people-menu.follow":"Following","people-menu.following":"Following","people-menu.leading":"Following You","people-menu.user":"(You)","people-menu.invite":"Invite others","help-menu.import-tldr-file":"Import file…","help-menu.title":"Help and resources","help-menu.about":"About tldraw","help-menu.discord":"Discord","help-menu.github":"GitHub","help-menu.keyboard-shortcuts":"Keyboard shortcuts","help-menu.twitter":"Twitter","help-menu.terms":"Terms of service","help-menu.privacy":"Privacy policy","actions-menu.title":"Actions","edit-link-dialog.title":"Edit link","edit-link-dialog.invalid-url":"A link must be a valid URL.","edit-link-dialog.detail":"Links will open in a new tab.","edit-link-dialog.url":"URL","edit-link-dialog.clear":"Clear","edit-link-dialog.save":"Continue","edit-link-dialog.cancel":"Cancel","embed-dialog.title":"Insert embed","embed-dialog.back":"Back","embed-dialog.create":"Create","embed-dialog.cancel":"Cancel","embed-dialog.url":"URL","embed-dialog.instruction":"Paste in the site’s URL to create the embed.","embed-dialog.invalid-url":"We could not create an embed from that URL.","shortcuts-dialog.title":"Keyboard shortcuts","shortcuts-dialog.edit":"Edit","shortcuts-dialog.file":"File","shortcuts-dialog.preferences":"Preferences","shortcuts-dialog.tools":"Tools","shortcuts-dialog.transform":"Transform","shortcuts-dialog.view":"View","shortcuts-dialog.collaboration":"Collaboration","style-panel.title":"Styles","style-panel.align":"Align","style-panel.label-align":"Label align","style-panel.vertical-align":"Vertical align","style-panel.position":"Position","style-panel.arrowheads":"Arrows","style-panel.arrowhead-start":"Start","style-panel.arrowhead-end":"End","style-panel.color":"Color","style-panel.dash":"Dash","style-panel.fill":"Fill","style-panel.font":"Font","style-panel.geo":"Shape","style-panel.mixed":"Mixed","style-panel.opacity":"Opacity","style-panel.size":"Size","style-panel.spline":"Spline","tool-panel.more":"More","navigation-zone.toggle-minimap":"Toggle minimap","navigation-zone.zoom":"Zoom","focus-mode.toggle-focus-mode":"Toggle focus mode","toast.close":"Close","file-system.file-open-error.title":"Could not open file","file-system.file-open-error.not-a-tldraw-file":"The file you tried to open doesn’t look like a tldraw file.","file-system.file-open-error.file-format-version-too-new":"The file you tried to open is from a newer version of tldraw. Please reload the page and try again.","file-system.file-open-error.generic-corrupted-file":"The file you tried to open is corrupted.","file-system.confirm-open.title":"Overwrite current project?","file-system.confirm-open.description":"Opening a file will replace your current project and any unsaved changes will be lost. Are you sure you want to continue?","file-system.confirm-open.cancel":"Cancel","file-system.confirm-open.open":"Open file","file-system.confirm-open.dont-show-again":"Don’t ask again","file-system.confirm-clear.title":"Clear current project?","file-system.confirm-clear.description":"Creating a new project will clear your current project and any unsaved changes will be lost. Are you sure you want to continue?","file-system.confirm-clear.cancel":"Cancel","file-system.confirm-clear.continue":"Continue","file-system.confirm-clear.dont-show-again":"Don’t ask again","file-system.shared-document-file-open-error.title":"Could not open file","file-system.shared-document-file-open-error.description":"Opening files from shared projects is not supported.","sharing.confirm-leave.title":"Leave current project?","sharing.confirm-leave.description":"Are you sure you want to leave this shared project? You can return to it by navigating to its URL.","sharing.confirm-leave.cancel":"Cancel","sharing.confirm-leave.leave":"Leave","sharing.confirm-leave.dont-show-again":"Don’t ask again","toast.error.export-fail.title":"Failed export","toast.error.export-fail.desc":"Failed to export image","toast.error.copy-fail.title":"Failed copy","toast.error.copy-fail.desc":"Failed to copy image","context.pages.new-page":"New page","vscode.file-open.desc":"We’ve updated this document to work with the current version of tldraw. If you’d like to keep the original version (which will work on old.tldraw.com), click below to create a backup.","vscode.file-open.open":"Continue","vscode.file-open.backup":"Backup","vscode.file-open.backup-saved":"Backup saved","vscode.file-open.backup-failed":"Backup failed: this is not a .tldr file.","vscode.file-open.dont-show-again":"Don’t ask again","cursor-chat.type-to-chat":"Type to chat…"},Xje=new Set(["ar","fa","he","ur","ku"]),id={locale:"en",label:"English",messages:ZP,dir:"ltr"};async function Zje(r,e){if(!(await pa(e.translations.en)).ok)return console.warn("No main translations found."),id;if(r==="en")return id;const n=xh.find(s=>s.locale===r);if(!n)return console.warn(`No translation found for locale ${r}`),id;const o=await(await pa(e.translations[n.locale])).json();if(!o)return console.warn(`No messages found for locale ${r}`),id;for(const s in id.messages)o[s];return{locale:r,label:n.label,dir:Xje.has(n.locale)?"rtl":"ltr",messages:{...id.messages,...o}}}const oue=A.createContext(null);function sue(){const r=A.useContext(oue);if(!r)throw new Error("useCurrentTranslation must be used inside of <TldrawUiContextProvider />");return r}function Qje({overrides:r,locale:e,children:t}){const n=VA(),[i,o]=A.useState(()=>r&&r.en?{locale:"en",label:"English",dir:"ltr",messages:{...ZP,...r.en}}:{locale:"en",label:"English",dir:"ltr",messages:ZP});return A.useEffect(()=>{let s=!1;async function a(){const c=await Zje(e,n);c&&!s&&(r&&r[e]?o({...c,messages:{...c.messages,...r[e]}}):o(c))}return a(),()=>{s=!0}},[n,e,r]),v.jsx(oue.Provider,{value:i,children:t})}function ar(){const r=sue();return A.useCallback(function(t){return r.messages[t]??t},[r])}const It=A.forwardRef(function({children:e,type:t,...n},i){return v.jsx("button",{ref:i,type:"button",draggable:!1,...n,className:bt("tlui-button",`tlui-button__${t}`,n.className),children:e})});function Sn({children:r}){return v.jsx("span",{className:"tlui-button__label",children:r})}var YA="Dialog",[aue,R4e]=Aa(YA),[Jje,zs]=aue(YA),cue=r=>{const{__scopeDialog:e,children:t,open:n,defaultOpen:i,onOpenChange:o,modal:s=!0}=r,a=A.useRef(null),c=A.useRef(null),[l=!1,d]=ml({prop:n,defaultProp:i,onChange:o});return v.jsx(Jje,{scope:e,triggerRef:a,contentRef:c,contentId:nc(),titleId:nc(),descriptionId:nc(),open:l,onOpenChange:d,onOpenToggle:A.useCallback(()=>d(f=>!f),[d]),modal:s,children:t})};cue.displayName=YA;var lue="DialogTrigger",eDe=A.forwardRef((r,e)=>{const{__scopeDialog:t,...n}=r,i=zs(lue,t),o=$r(e,i.triggerRef);return v.jsx(pr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":QA(i.open),...n,ref:o,onClick:pt(r.onClick,i.onOpenToggle)})});eDe.displayName=lue;var XA="DialogPortal",[tDe,uue]=aue(XA,{forceMount:void 0}),due=r=>{const{__scopeDialog:e,forceMount:t,children:n,container:i}=r,o=zs(XA,e);return v.jsx(tDe,{scope:e,forceMount:t,children:A.Children.map(n,s=>v.jsx(Us,{present:t||o.open,children:v.jsx(fp,{asChild:!0,container:i,children:s})}))})};due.displayName=XA;var fm="DialogOverlay",fue=A.forwardRef((r,e)=>{const t=uue(fm,r.__scopeDialog),{forceMount:n=t.forceMount,...i}=r,o=zs(fm,r.__scopeDialog);return o.modal?v.jsx(Us,{present:n||o.open,children:v.jsx(rDe,{...i,ref:e})}):null});fue.displayName=fm;var rDe=A.forwardRef((r,e)=>{const{__scopeDialog:t,...n}=r,i=zs(fm,t);return v.jsx(zy,{as:Ql,allowPinchZoom:!0,shards:[i.contentRef],children:v.jsx(pr.div,{"data-state":QA(i.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),eu="DialogContent",hue=A.forwardRef((r,e)=>{const t=uue(eu,r.__scopeDialog),{forceMount:n=t.forceMount,...i}=r,o=zs(eu,r.__scopeDialog);return v.jsx(Us,{present:n||o.open,children:o.modal?v.jsx(nDe,{...i,ref:e}):v.jsx(iDe,{...i,ref:e})})});hue.displayName=eu;var nDe=A.forwardRef((r,e)=>{const t=zs(eu,r.__scopeDialog),n=A.useRef(null),i=$r(e,t.contentRef,n);return A.useEffect(()=>{const o=n.current;if(o)return MA(o)},[]),v.jsx(pue,{...r,ref:i,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pt(r.onCloseAutoFocus,o=>{var s;o.preventDefault(),(s=t.triggerRef.current)==null||s.focus()}),onPointerDownOutside:pt(r.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:pt(r.onFocusOutside,o=>o.preventDefault())})}),iDe=A.forwardRef((r,e)=>{const t=zs(eu,r.__scopeDialog),n=A.useRef(!1),i=A.useRef(!1);return v.jsx(pue,{...r,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var s,a;(s=r.onCloseAutoFocus)==null||s.call(r,o),o.defaultPrevented||(n.current||(a=t.triggerRef.current)==null||a.focus(),o.preventDefault()),n.current=!1,i.current=!1},onInteractOutside:o=>{var c,l;(c=r.onInteractOutside)==null||c.call(r,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=o.target;((l=t.triggerRef.current)==null?void 0:l.contains(s))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),pue=A.forwardRef((r,e)=>{const{__scopeDialog:t,trapFocus:n,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=r,a=zs(eu,t),c=A.useRef(null),l=$r(e,c);return _A(),v.jsxs(v.Fragment,{children:[v.jsx(Ly,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:i,onUnmountAutoFocus:o,children:v.jsx(up,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":QA(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),v.jsxs(v.Fragment,{children:[v.jsx(sDe,{titleId:a.titleId}),v.jsx(cDe,{contentRef:c,descriptionId:a.descriptionId})]})]})}),ZA="DialogTitle",gue=A.forwardRef((r,e)=>{const{__scopeDialog:t,...n}=r,i=zs(ZA,t);return v.jsx(pr.h2,{id:i.titleId,...n,ref:e})});gue.displayName=ZA;var vue="DialogDescription",oDe=A.forwardRef((r,e)=>{const{__scopeDialog:t,...n}=r,i=zs(vue,t);return v.jsx(pr.p,{id:i.descriptionId,...n,ref:e})});oDe.displayName=vue;var mue="DialogClose",yue=A.forwardRef((r,e)=>{const{__scopeDialog:t,...n}=r,i=zs(mue,t);return v.jsx(pr.button,{type:"button",...n,ref:e,onClick:pt(r.onClick,()=>i.onOpenChange(!1))})});yue.displayName=mue;function QA(r){return r?"open":"closed"}var Sue="DialogTitleWarning",[k4e,xue]=U2e(Sue,{contentName:eu,titleName:ZA,docsSlug:"dialog"}),sDe=({titleId:r})=>{const e=xue(Sue),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
243
-
244
- If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
245
-
246
- For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return A.useEffect(()=>{r&&(document.getElementById(r)||console.error(t))},[t,r]),null},aDe="DialogDescriptionWarning",cDe=({contentRef:r,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${xue(aDe).contentName}}.`;return A.useEffect(()=>{var o;const i=(o=r.current)==null?void 0:o.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(n))},[n,r,e]),null},lDe=cue,uDe=due,dDe=fue,fDe=hue,hDe=gue;const Sa=A.memo(function({small:e,invertIcon:t,icon:n,color:i,className:o,...s}){const a=VA(),c=a.icons[n]??a.icons["question-mark-circle"],l=A.useRef(null);return A.useLayoutEffect(()=>{c||console.error(`Icon not found: ${n}. Add it to the assetUrls.icons object.`),l!=null&&l.current&&(l.current.style.webkitMask=`url(${c}) center 100% / 100% no-repeat`)},[l,c,n]),n==="none"?v.jsx("div",{className:bt("tlui-icon tlui-icon__placeholder",{"tlui-icon__small":e},o)}):v.jsx("div",{...s,ref:l,className:bt("tlui-icon",{"tlui-icon__small":e},o),style:{color:i,mask:`url(${c}) center 100% / 100% no-repeat`,transform:t?"scale(-1, 1)":void 0}})});function rr({icon:r,small:e,invertIcon:t}){return v.jsx(Sa,{className:"tlui-button__icon",icon:r,small:e,invertIcon:t})}function Gy({className:r,children:e}){return v.jsx("div",{className:bt("tlui-dialog__header",r),children:e})}function Vy({className:r,children:e,style:t}){return v.jsx(hDe,{dir:"ltr",className:bt("tlui-dialog__header__title",r),style:t,children:e})}function Yy(){return v.jsx("div",{className:"tlui-dialog__header__close",children:v.jsx(yue,{"data-testid":"dialog.close",dir:"ltr",asChild:!0,children:v.jsx(It,{type:"icon","aria-label":"Close",onTouchEnd:r=>r.target.click(),children:v.jsx(rr,{small:!0,icon:"cross-2"})})})})}function Ch({className:r,children:e,style:t}){return v.jsx("div",{className:bt("tlui-dialog__body",r),style:t,children:e})}function JA({className:r,children:e}){return v.jsx("div",{className:bt("tlui-dialog__footer",r),children:e})}const Xy=A.forwardRef(function({className:e,label:t,icon:n,iconLeft:i,autoSelect:o=!1,autoFocus:s=!1,defaultValue:a,placeholder:c,onComplete:l,onValueChange:d,onCancel:f,onFocus:h,onBlur:g,shouldManuallyMaintainScrollPositionWhenFocused:m=!1,children:y,value:x,"data-testid":_},w){const I=ll(),b=A.useRef(null);A.useImperativeHandle(w,()=>b.current);const P=ar(),C=A.useRef(a??""),k=A.useRef(a??""),[O,L]=A.useState(!1),j=A.useCallback(N=>{L(!0);const B=N.currentTarget;k.current=B.value,I?I.timers.requestAnimationFrame(()=>{o&&B.select()}):FP.requestAnimationFrame("anon",()=>{o&&B.select()}),h==null||h()},[o,I,h]),F=A.useCallback(N=>{const B=N.currentTarget.value;k.current=B,d==null||d(B)},[d]),$=A.useCallback(N=>{switch(N.key){case"Enter":{N.currentTarget.blur(),wn(N),l==null||l(N.currentTarget.value);break}case"Escape":{N.currentTarget.value=C.current,f==null||f(N.currentTarget.value),N.currentTarget.blur(),wn(N);break}}},[l,f]),D=A.useCallback(N=>{L(!1);const B=N.currentTarget.value;g==null||g(B)},[g]);return A.useEffect(()=>{if(!Pr.isIos)return;const N=window.visualViewport;if(O&&m&&N){const B=()=>{var W;(W=b.current)==null||W.scrollIntoView({block:"center"})};return N.addEventListener("resize",B),N.addEventListener("scroll",B),I?I.timers.requestAnimationFrame(()=>{var W;(W=b.current)==null||W.scrollIntoView({block:"center"})}):FP.requestAnimationFrame("anon",()=>{var W;(W=b.current)==null||W.scrollIntoView({block:"center"})}),()=>{N.removeEventListener("resize",B),N.removeEventListener("scroll",B)}}},[O,I,m]),v.jsxs("div",{draggable:!1,className:"tlui-input__wrapper",children:[y,t&&v.jsx("label",{children:P(t)}),i&&v.jsx(Sa,{icon:i,className:"tlui-icon-left",small:!0}),v.jsx("input",{ref:b,className:bt("tlui-input",e),type:"text",defaultValue:a,onKeyDownCapture:$,onChange:F,onFocus:j,onBlur:D,autoFocus:s,placeholder:c,value:x,"data-testid":_}),n&&v.jsx(Sa,{icon:n,small:!!t})]})});function jQ(r){return Do.isValid(r)?{isValid:!0,hasProtocol:!0}:Do.isValid("https://"+r)?{isValid:!0,hasProtocol:!1}:{isValid:!1,hasProtocol:!1}}const pDe=ii(function({onClose:e}){const n=he().getOnlySelectedShape();return n&&"url"in n.props&&typeof n.props.url=="string"?v.jsx(gDe,{onClose:e,selectedShape:n}):null}),gDe=ii(function({onClose:e,selectedShape:t}){const n=he(),i=ar(),o=A.useRef(null);A.useEffect(()=>{n.timers.requestAnimationFrame(()=>{var m;return(m=o.current)==null?void 0:m.focus()})},[n]);const s=A.useRef(t.props.url),[a,c]=A.useState(()=>{const m=jQ(t.props.url),y=m.isValid===!0?m.hasProtocol?t.props.url:"https://"+t.props.url:"https://";return{actual:y,safe:y,valid:!0}}),l=A.useCallback(m=>{const y=m.replace(/https?:\/\/(https?:\/\/)/,(w,I)=>I),x=jQ(y),_=x.isValid===!0?x.hasProtocol?y:"https://"+y:"https://";c({actual:y,safe:_,valid:x.isValid})},[]),d=A.useCallback(()=>{const m=n.getOnlySelectedShape();m&&(n.updateShapes([{id:m.id,type:m.type,props:{url:""}}]),e())},[n,e]),f=A.useCallback(()=>{const m=n.getOnlySelectedShape();m&&(m&&"url"in m.props&&m.props.url!==a.safe&&n.updateShapes([{id:m.id,type:m.type,props:{url:a.safe}}]),e())},[n,e,a]),h=A.useCallback(()=>{e()},[e]);if(!t)return e(),null;const g=s.current&&!a.valid;return v.jsxs(v.Fragment,{children:[v.jsxs(Gy,{children:[v.jsx(Vy,{children:i("edit-link-dialog.title")}),v.jsx(Yy,{})]}),v.jsx(Ch,{children:v.jsxs("div",{className:"tlui-edit-link-dialog",children:[v.jsx(Xy,{ref:o,className:"tlui-edit-link-dialog__input",label:"edit-link-dialog.url",autoFocus:!0,value:a.actual,onValueChange:l,onComplete:f,onCancel:h}),v.jsx("div",{children:a.valid?i("edit-link-dialog.detail"):i("edit-link-dialog.invalid-url")})]})}),v.jsxs(JA,{className:"tlui-dialog__footer__actions",children:[v.jsx(It,{type:"normal",onClick:h,onTouchEnd:h,children:v.jsx(Sn,{children:i("edit-link-dialog.cancel")})}),g?v.jsx(It,{type:"danger",onTouchEnd:d,onClick:d,children:v.jsx(Sn,{children:i("edit-link-dialog.clear")})}):v.jsx(It,{type:"primary",disabled:!a.valid,onTouchEnd:f,onClick:f,children:v.jsx(Sn,{children:i("edit-link-dialog.save")})})]})]})});var vDe={};const DQ=/(^\/r\/[^/]+\/?$)/,eR=[{type:"tldraw",title:"tldraw",hostnames:["beta.tldraw.com","tldraw.com","localhost:3000"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,overridePermissions:{"allow-top-navigation":!0},toEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(DQ))return r},fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(DQ))return r}},{type:"figma",title:"Figma",hostnames:["figma.com"],width:720,height:500,doesResize:!0,toEmbedUrl:r=>{if(r.match(/https:\/\/([\w\.-]+\.)?figma.com\/(file|proto)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/)&&!r.includes("figma.com/embed"))return`https://www.figma.com/embed?embed_host=share&url=${r}`},fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/^\/embed\/?$/)){const t=e.searchParams.get("url");if(t)return t}}},{type:"google_maps",title:"Google Maps",hostnames:["google.*"],width:720,height:500,doesResize:!0,overridePermissions:{"allow-presentation":!0},toEmbedUrl:r=>{if(r.includes("/maps/embed?"))return r;if(r.includes("/maps/")){const e=r.match(/@(.*?),(.*?),(.*?)z/);let t;if(e){const[,n,i,o]=e;t=`https://${new URL(r).host.replace("www.","")}/maps/embed/v1/view?key=${vDe.NEXT_PUBLIC_GC_API_KEY}&center=${n},${i}&zoom=${o}`}else t="";return t}},fromEmbedUrl:r=>{const e=Ft(r);if(!e)return;if(e.pathname.match(/^\/maps\/embed\/v1\/view\/?$/)&&e.searchParams.has("center")&&e.searchParams.get("zoom")){const n=e.searchParams.get("zoom"),[i,o]=e.searchParams.get("center").split(",");return`https://www.google.com/maps/@${i},${o},${n}z`}}},{type:"val_town",title:"Val Town",hostnames:["val.town"],minWidth:260,minHeight:100,width:720,height:500,doesResize:!0,toEmbedUrl:r=>{const e=Ft(r),t=e&&e.pathname.match(/\/v\/(.+)\/?/);if(t)return`https://www.val.town/embed/${t[1]}`},fromEmbedUrl:r=>{const e=Ft(r),t=e&&e.pathname.match(/\/embed\/(.+)\/?/);if(t)return`https://www.val.town/v/${t[1]}`}},{type:"codesandbox",title:"CodeSandbox",hostnames:["codesandbox.io"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,toEmbedUrl:r=>{const e=Ft(r),t=e&&e.pathname.match(/\/s\/([^/]+)\/?/);if(t)return`https://codesandbox.io/embed/${t[1]}`},fromEmbedUrl:r=>{const e=Ft(r),t=e&&e.pathname.match(/\/embed\/([^/]+)\/?/);if(t)return`https://codesandbox.io/s/${t[1]}`}},{type:"codepen",title:"Codepen",hostnames:["codepen.io"],minWidth:300,minHeight:300,width:520,height:400,doesResize:!0,toEmbedUrl:r=>{const e=/https:\/\/codepen.io\/([^/]+)\/pen\/([^/]+)/,t=r.match(e);if(t){const[n,i,o]=t;return`https://codepen.io/${i}/embed/${o}`}},fromEmbedUrl:r=>{const e=/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/,t=r.match(e);if(t){const[n,i,o]=t;return`https://codepen.io/${i}/pen/${o}`}}},{type:"scratch",title:"Scratch",hostnames:["scratch.mit.edu"],width:520,height:400,doesResize:!1,toEmbedUrl:r=>{const e=/https?:\/\/scratch.mit.edu\/projects\/([^/]+)/,t=r.match(e);if(t){const[n,i]=t;return`https://scratch.mit.edu/projects/embed/${i}`}},fromEmbedUrl:r=>{const e=/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/,t=r.match(e);if(t){const[n,i]=t;return`https://scratch.mit.edu/projects/${i}`}}},{type:"youtube",title:"YouTube",hostnames:["*.youtube.com","youtube.com","youtu.be"],width:800,height:450,doesResize:!0,overridePermissions:{"allow-presentation":!0,"allow-popups-to-escape-sandbox":!0},isAspectRatioLocked:!0,toEmbedUrl:r=>{const e=Ft(r);if(!e)return;const t=e.hostname.replace(/^www./,"");if(t==="youtu.be")return`https://www.youtube.com/embed/${e.pathname.split("/").filter(Boolean)[0]}`;if((t==="youtube.com"||t==="m.youtube.com")&&e.pathname.match(/^\/watch/))return`https://www.youtube.com/embed/${e.searchParams.get("v")}`},fromEmbedUrl:r=>{const e=Ft(r);if(!e)return;if(e.hostname.replace(/^www./,"")==="youtube.com"){const n=e.pathname.match(/^\/embed\/([^/]+)\/?/);if(n)return`https://www.youtube.com/watch?v=${n[1]}`}}},{type:"google_calendar",title:"Google Calendar",hostnames:["calendar.google.*"],width:720,height:500,minWidth:460,minHeight:360,doesResize:!0,instructionLink:"https://support.google.com/calendar/answer/41207?hl=en",overridePermissions:{"allow-popups-to-escape-sandbox":!0},toEmbedUrl:r=>{const e=Ft(r),t=e==null?void 0:e.searchParams.get("cid");if(e!=null&&e.pathname.match(/\/calendar\/u\/0/)&&t){e.pathname="/calendar/embed";const n=Array.from(e.searchParams.keys());for(const i of n)e.searchParams.delete(i);return e.searchParams.set("src",t),e.href}},fromEmbedUrl:r=>{const e=Ft(r),t=e==null?void 0:e.searchParams.get("src");if(e!=null&&e.pathname.match(/\/calendar\/embed/)&&t){e.pathname="/calendar/u/0";const n=Array.from(e.searchParams.keys());for(const i of n)e.searchParams.delete(i);return e.searchParams.set("cid",t),e.href}}},{type:"google_slides",title:"Google Slides",hostnames:["docs.google.*"],width:720,height:500,minWidth:460,minHeight:360,doesResize:!0,overridePermissions:{"allow-popups-to-escape-sandbox":!0},toEmbedUrl:r=>{const e=Ft(r);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/pub\/?$/))){e.pathname=e.pathname.replace(/\/pub$/,"/embed");const t=Array.from(e.searchParams.keys());for(const n of t)e.searchParams.delete(n);return e.href}},fromEmbedUrl:r=>{const e=Ft(r);if(e!=null&&e.pathname.match(/^\/presentation/)&&(e!=null&&e.pathname.match(/\/embed\/?$/))){e.pathname=e.pathname.replace(/\/embed$/,"/pub");const t=Array.from(e.searchParams.keys());for(const n of t)e.searchParams.delete(n);return e.href}}},{type:"github_gist",title:"GitHub Gist",hostnames:["gist.github.com"],width:720,height:500,doesResize:!0,toEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/\/([^/]+)\/([0-9a-f]+)$/))return r.split("/").pop()?r:void 0},fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/\/([^/]+)\/([0-9a-f]+)$/))return r.split("/").pop()?r:void 0}},{type:"replit",title:"Replit",hostnames:["replit.com"],width:720,height:500,doesResize:!0,toEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/\/@([^/]+)\/([^/]+)/))return`${r}?embed=true`},fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/\/@([^/]+)\/([^/]+)/)&&e.searchParams.has("embed"))return e.searchParams.delete("embed"),e.href}},{type:"felt",title:"Felt",hostnames:["felt.com"],width:720,height:500,doesResize:!0,toEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/^\/map\//))return e.origin+"/embed"+e.pathname},fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/^\/embed\/map\//))return e.pathname=e.pathname.replace(/^\/embed/,""),e.href}},{type:"spotify",title:"Spotify",hostnames:["open.spotify.com"],width:720,height:500,minHeight:500,overrideOutlineRadius:12,doesResize:!0,toEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/^\/(artist|album)\//))return e.origin+"/embed"+e.pathname},fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/^\/embed\/(artist|album)\//))return e.origin+e.pathname.replace(/^\/embed/,"")}},{type:"vimeo",title:"Vimeo",hostnames:["vimeo.com","player.vimeo.com"],width:640,height:360,doesResize:!0,isAspectRatioLocked:!0,toEmbedUrl:r=>{const e=Ft(r);if(e&&e.hostname==="vimeo.com"&&e.pathname.match(/^\/[0-9]+/))return"https://player.vimeo.com/video/"+e.pathname.split("/")[1]+"?title=0&byline=0"},fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.hostname==="player.vimeo.com"){const t=e.pathname.match(/^\/video\/([^/]+)\/?$/);if(t)return"https://vimeo.com/"+t[1]}}},{type:"excalidraw",title:"Excalidraw",hostnames:["excalidraw.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!0,toEmbedUrl:r=>{const e=Ft(r);if(e&&e.hash.match(/#room=/))return r},fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.hash.match(/#room=/))return r}},{type:"observable",title:"Observable",hostnames:["observablehq.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!1,backgroundColor:"#fff",toEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/^\/@([^/]+)\/([^/]+)\/?$/))return`${e.origin}/embed${e.pathname}?cell=*`;if(e&&e.pathname.match(/^\/d\/([^/]+)\/?$/)){const t=e.pathname.replace(/^\/d/,"");return`${e.origin}/embed${t}?cell=*`}},fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.pathname.match(/^\/embed\/@([^/]+)\/([^/]+)\/?$/))return`${e.origin}${e.pathname.replace("/embed","")}#cell-*`;if(e&&e.pathname.match(/^\/embed\/([^/]+)\/?$/))return`${e.origin}${e.pathname.replace("/embed","/d")}#cell-*`}},{type:"desmos",title:"Desmos",hostnames:["desmos.com"],width:700,height:450,doesResize:!0,toEmbedUrl:r=>{const e=Ft(r);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search===""&&e.hash==="")return`${r}?embed`},fromEmbedUrl:r=>{const e=Ft(r);if(e&&e.hostname==="www.desmos.com"&&e.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&e.search==="?embed"&&e.hash==="")return r.replace("?embed","")}}],mDe={"allow-downloads-without-user-activation":!1,"allow-downloads":!1,"allow-modals":!1,"allow-orientation-lock":!1,"allow-pointer-lock":!1,"allow-popups":!0,"allow-popups-to-escape-sandbox":!1,"allow-presentation":!1,"allow-storage-access-by-user-activation":!1,"allow-top-navigation":!1,"allow-top-navigation-by-user-activation":!1,"allow-scripts":!0,"allow-same-origin":!0,"allow-forms":!0},yDe=eR.map(r=>r.type);function SDe(r){return yDe.includes(r)}function xDe(r){return"icon"in r}function _ue(){const r=he();if(r.hasShapeUtil("embed"))return r.getShapeUtil("embed")}function tR(){const r=_ue();return e=>r?r.getEmbedDefinition(e):void 0}function _De(){const r=_ue();return r?r.getEmbedDefinitions():[]}const wue=ii(function({onClose:e}){const t=he(),n=ar(),i=VA(),[o,s]=A.useState(null),[a,c]=A.useState(""),[l,d]=A.useState(null),[f,h]=A.useState(!1),g=A.useRef(-1),m=_De(),y=tR();return v.jsxs(v.Fragment,{children:[v.jsxs(Gy,{children:[v.jsx(Vy,{children:o?`${n("embed-dialog.title")} — ${o.title}`:n("embed-dialog.title")}),v.jsx(Yy,{})]}),o?v.jsxs(v.Fragment,{children:[v.jsxs(Ch,{className:"tlui-embed-dialog__enter",children:[v.jsx(Xy,{className:"tlui-embed-dialog__input",label:"embed-dialog.url",placeholder:"https://example.com",autoFocus:!0,onValueChange:x=>{c(x);const _=y(x);d(_&&_.definition.type===o.type?_:null),h(!1),clearTimeout(g.current),g.current=t.timers.setTimeout(()=>h(!_),320)}}),a===""?v.jsxs("div",{className:"tlui-embed-dialog__instruction",children:[v.jsx("span",{children:n("embed-dialog.instruction")})," ",o.instructionLink&&v.jsxs("a",{target:"_blank",rel:"noopener noreferrer",href:o.instructionLink,className:"tlui-embed-dialog__instruction__link",children:["Learn more.",v.jsx(Sa,{icon:"external-link",small:!0})]})]}):v.jsx("div",{className:"tlui-embed-dialog__warning",children:f?n("embed-dialog.invalid-url"):" "})]}),v.jsxs(JA,{className:"tlui-dialog__footer__actions",children:[v.jsx(It,{type:"normal",onClick:()=>{s(null),d(null),c("")},children:v.jsx(Sn,{children:n("embed-dialog.back")})}),v.jsx("div",{className:"tlui-embed__spacer"}),v.jsx(It,{type:"normal",onClick:e,children:v.jsx(Sn,{children:n("embed-dialog.cancel")})}),v.jsx(It,{type:"primary",disabled:!l,onClick:()=>{l&&(t.putExternalContent({type:"embed",url:a,point:t.getViewportPageBounds().center,embed:l.definition}),e())},children:v.jsx(Sn,{children:n("embed-dialog.create")})})]})]}):v.jsx(v.Fragment,{children:v.jsx(Ch,{className:"tlui-embed-dialog__list",children:m.map(x=>{const _=SDe(x.type)?i.embedIcons[x.type]:xDe(x)?x.icon:void 0;return v.jsxs(It,{type:"menu",onClick:()=>s(x),children:[v.jsx(Sn,{children:x.title}),_&&v.jsx("div",{className:"tlui-embed-dialog__item__image",style:{backgroundImage:`url(${_})`}})]},x.type)})})})]})});async function wDe(r,e,t){const n=Gt(e.map(a=>{const c=r.getShape(a);if(!(!c||r.getShapeUtil(c.type).toSvg===void 0))return c}));if(n.length===0)return;if(n.length===1){const a=n[0];if(!a||r.isShapeOfType(a,"image"))return}const i=[];if(t!==void 0){const a=n.map(c=>({shape:c,bounds:r.getShapeMaskedPageBounds(c).clone().expandBy(t)}));for(let c=0;c<a.length;c++){const l=a[c];if(c===0){i[0]={shapes:[l.shape],bounds:l.bounds};continue}let d=!1;for(const f of i)if(f.bounds.includes(l.bounds)){f.shapes.push(l.shape),f.bounds.expand(l.bounds),d=!0;break}d||i.push({shapes:[l.shape],bounds:l.bounds})}}else{const a=He.Common(n.map(c=>r.getShapeMaskedPageBounds(c)));i.push({shapes:n,bounds:a})}const o=r.options.flattenImageBoundsPadding;for(const a of i){t!==void 0&&a.bounds.expandBy(-t);const c=await r.getSvgString(a.shapes,{padding:o});if(!(c!=null&&c.svg))continue;const l=await r.getAssetForExternalContent({type:"file",file:new File([c.svg],"asset.svg",{type:"image/svg+xml"})});l&&(a.asset=l)}const s=[];return Ui(()=>{for(const a of i){const{asset:c,bounds:l,shapes:d}=a;if(!c)continue;const f=r.findCommonAncestor(d)??r.getCurrentPageId();if(!f)continue;let h="a1";for(const _ of d)if(_.parentId===f){_.index>h&&(h=_.index);break}let g,m,y;if(co(f)){const _=r.getShape(f);if(!_)continue;const w=r.getPointInShapeSpace(_,{x:l.x,y:l.y});y=r.getShapePageTransform(f).rotation(),w.sub(new T(o,o).rot(-y)),g=w.x,m=w.y}else g=l.x-o,m=l.y-o,y=0;r.deleteShapes(d),r.createAssets([{...c,id:c.id}]);const x=Tr();r.createShape({id:x,type:"image",index:h,parentId:f,x:g,y:m,rotation:-y,props:{assetId:c.id,w:l.w+o*2,h:l.h+o*2}}),s.push(x)}}),s}function Zy(){const r=ll();return(r==null?void 0:r.store.props.collaboration)!==void 0}function bDe(){const r=ll();return ye("sync status",()=>{var e;return(e=r==null?void 0:r.store.props.collaboration)!=null&&e.status?r.store.props.collaboration.status.get():null},[r])}const MI=[0,389,436,476,580,640,840,1023];var fn=(r=>(r[r.ZERO=0]="ZERO",r[r.MOBILE_XXS=1]="MOBILE_XXS",r[r.MOBILE_XS=2]="MOBILE_XS",r[r.MOBILE_SM=3]="MOBILE_SM",r[r.MOBILE=4]="MOBILE",r[r.TABLET_SM=5]="TABLET_SM",r[r.TABLET=6]="TABLET",r[r.DESKTOP=7]="DESKTOP",r))(fn||{});const bue=lr.createContext(null);function EDe({forceMobile:r=!1,children:e}){const t=ll(),n=ye("breakpoint",()=>{const{width:i}=(t==null?void 0:t.getViewportScreenBounds())??{width:window.innerWidth},o=r?fn.MOBILE_SM:MI.length-1;for(let s=0;s<o;s++)if(i>MI[s]&&i<=MI[s+1])return s;return o},[t]);return v.jsx(bue.Provider,{value:n,children:e})}function Gi(){const r=A.useContext(bue);if(r===null)throw new Error("useBreakpoint must be used inside of the <BreakpointProvider /> component");return r}const QP=A.createContext(null);function IDe({context:r,children:e}){const t=A.useContext(QP),n=ai(),i=QC("dialogs",[]),o=A.useMemo(()=>({dialogs:i,addDialog(s){const a=s.id??Er();return i.update(c=>[...c.filter(l=>l.id!==s.id),{...s,id:a}]),n("open-menu",{source:"dialog",id:a}),Is.addOpenMenu(a,r),a},removeDialog(s){var c;const a=i.get().find(l=>l.id===s);return a&&((c=a.onClose)==null||c.call(a),n("close-menu",{source:"dialog",id:s}),Is.deleteOpenMenu(s,r),i.update(l=>l.filter(d=>d!==a))),s},clearDialogs(){const s=i.get();s.length!==0&&(s.forEach(a=>{var c;(c=a.onClose)==null||c.call(a),n("close-menu",{source:"dialog",id:a.id}),Is.deleteOpenMenu(a.id,r)}),i.set([]))}}),[n,i,r]);return t?v.jsx(v.Fragment,{children:e}):v.jsx(QP.Provider,{value:o,children:e})}function vp(){const r=A.useContext(QP);if(!r)throw new Error("useDialogs must be used within a DialogsProvider");return r}var PDe="VisuallyHidden",rR=A.forwardRef((r,e)=>v.jsx(pr.span,{...r,ref:e,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...r.style}}));rR.displayName=PDe;var nR="ToastProvider",[iR,CDe,TDe]=Dy("Toast"),[Eue,O4e]=Aa("Toast",[TDe]),[ADe,Qy]=Eue(nR),Iue=r=>{const{__scopeToast:e,label:t="Notification",duration:n=5e3,swipeDirection:i="right",swipeThreshold:o=50,children:s}=r,[a,c]=A.useState(null),[l,d]=A.useState(0),f=A.useRef(!1),h=A.useRef(!1);return t.trim()||console.error(`Invalid prop \`label\` supplied to \`${nR}\`. Expected non-empty \`string\`.`),v.jsx(iR.Provider,{scope:e,children:v.jsx(ADe,{scope:e,label:t,duration:n,swipeDirection:i,swipeThreshold:o,toastCount:l,viewport:a,onViewportChange:c,onToastAdd:A.useCallback(()=>d(g=>g+1),[]),onToastRemove:A.useCallback(()=>d(g=>g-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:h,children:s})})};Iue.displayName=nR;var Pue="ToastViewport",RDe=["F8"],JP="toast.viewportPause",eC="toast.viewportResume",Cue=A.forwardRef((r,e)=>{const{__scopeToast:t,hotkey:n=RDe,label:i="Notifications ({hotkey})",...o}=r,s=Qy(Pue,t),a=CDe(t),c=A.useRef(null),l=A.useRef(null),d=A.useRef(null),f=A.useRef(null),h=$r(e,f,s.onViewportChange),g=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),m=s.toastCount>0;A.useEffect(()=>{const x=_=>{var I;n.length!==0&&n.every(b=>_[b]||_.code===b)&&((I=f.current)==null||I.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[n]),A.useEffect(()=>{const x=c.current,_=f.current;if(m&&x&&_){const w=()=>{if(!s.isClosePausedRef.current){const C=new CustomEvent(JP);_.dispatchEvent(C),s.isClosePausedRef.current=!0}},I=()=>{if(s.isClosePausedRef.current){const C=new CustomEvent(eC);_.dispatchEvent(C),s.isClosePausedRef.current=!1}},b=C=>{!x.contains(C.relatedTarget)&&I()},P=()=>{x.contains(document.activeElement)||I()};return x.addEventListener("focusin",w),x.addEventListener("focusout",b),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",P),window.addEventListener("blur",w),window.addEventListener("focus",I),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",b),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",P),window.removeEventListener("blur",w),window.removeEventListener("focus",I)}}},[m,s.isClosePausedRef]);const y=A.useCallback(({tabbingDirection:x})=>{const w=a().map(I=>{const b=I.ref.current,P=[b,...zDe(b)];return x==="forwards"?P:P.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return A.useEffect(()=>{const x=f.current;if(x){const _=w=>{var P,C,k;const I=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!I){const O=document.activeElement,L=w.shiftKey;if(w.target===x&&L){(P=l.current)==null||P.focus();return}const $=y({tabbingDirection:L?"backwards":"forwards"}),D=$.findIndex(N=>N===O);jI($.slice(D+1))?w.preventDefault():L?(C=l.current)==null||C.focus():(k=d.current)==null||k.focus()}};return x.addEventListener("keydown",_),()=>x.removeEventListener("keydown",_)}},[a,y]),v.jsxs(ike,{ref:c,role:"region","aria-label":i.replace("{hotkey}",g),tabIndex:-1,style:{pointerEvents:m?void 0:"none"},children:[m&&v.jsx(tC,{ref:l,onFocusFromOutsideViewport:()=>{const x=y({tabbingDirection:"forwards"});jI(x)}}),v.jsx(iR.Slot,{scope:t,children:v.jsx(pr.ol,{tabIndex:-1,...o,ref:h})}),m&&v.jsx(tC,{ref:d,onFocusFromOutsideViewport:()=>{const x=y({tabbingDirection:"backwards"});jI(x)}})]})});Cue.displayName=Pue;var Tue="ToastFocusProxy",tC=A.forwardRef((r,e)=>{const{__scopeToast:t,onFocusFromOutsideViewport:n,...i}=r,o=Qy(Tue,t);return v.jsx(rR,{"aria-hidden":!0,tabIndex:0,...i,ref:e,style:{position:"fixed"},onFocus:s=>{var l;const a=s.relatedTarget;!((l=o.viewport)!=null&&l.contains(a))&&n()}})});tC.displayName=Tue;var Jy="Toast",kDe="toast.swipeStart",ODe="toast.swipeMove",MDe="toast.swipeCancel",jDe="toast.swipeEnd",Aue=A.forwardRef((r,e)=>{const{forceMount:t,open:n,defaultOpen:i,onOpenChange:o,...s}=r,[a=!0,c]=ml({prop:n,defaultProp:i,onChange:o});return v.jsx(Us,{present:t||a,children:v.jsx(FDe,{open:a,...s,ref:e,onClose:()=>c(!1),onPause:ri(r.onPause),onResume:ri(r.onResume),onSwipeStart:pt(r.onSwipeStart,l=>{l.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:pt(r.onSwipeMove,l=>{const{x:d,y:f}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","move"),l.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:pt(r.onSwipeCancel,l=>{l.currentTarget.setAttribute("data-swipe","cancel"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:pt(r.onSwipeEnd,l=>{const{x:d,y:f}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","end"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),c(!1)})})})});Aue.displayName=Jy;var[DDe,LDe]=Eue(Jy,{onClose(){}}),FDe=A.forwardRef((r,e)=>{const{__scopeToast:t,type:n="foreground",duration:i,open:o,onClose:s,onEscapeKeyDown:a,onPause:c,onResume:l,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:h,onSwipeEnd:g,...m}=r,y=Qy(Jy,t),[x,_]=A.useState(null),w=$r(e,N=>_(N)),I=A.useRef(null),b=A.useRef(null),P=i||y.duration,C=A.useRef(0),k=A.useRef(P),O=A.useRef(0),{onToastAdd:L,onToastRemove:j}=y,F=ri(()=>{var B;(x==null?void 0:x.contains(document.activeElement))&&((B=y.viewport)==null||B.focus()),s()}),$=A.useCallback(N=>{!N||N===1/0||(window.clearTimeout(O.current),C.current=new Date().getTime(),O.current=window.setTimeout(F,N))},[F]);A.useEffect(()=>{const N=y.viewport;if(N){const B=()=>{$(k.current),l==null||l()},W=()=>{const G=new Date().getTime()-C.current;k.current=k.current-G,window.clearTimeout(O.current),c==null||c()};return N.addEventListener(JP,W),N.addEventListener(eC,B),()=>{N.removeEventListener(JP,W),N.removeEventListener(eC,B)}}},[y.viewport,P,c,l,$]),A.useEffect(()=>{o&&!y.isClosePausedRef.current&&$(P)},[o,P,y.isClosePausedRef,$]),A.useEffect(()=>(L(),()=>j()),[L,j]);const D=A.useMemo(()=>x?Lue(x):null,[x]);return y.viewport?v.jsxs(v.Fragment,{children:[D&&v.jsx(NDe,{__scopeToast:t,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:D}),v.jsx(DDe,{scope:t,onClose:F,children:Yd.createPortal(v.jsx(iR.ItemSlot,{scope:t,children:v.jsx(nke,{asChild:!0,onEscapeKeyDown:pt(a,()=>{y.isFocusedToastEscapeKeyDownRef.current||F(),y.isFocusedToastEscapeKeyDownRef.current=!1}),children:v.jsx(pr.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":y.swipeDirection,...m,ref:w,style:{userSelect:"none",touchAction:"none",...r.style},onKeyDown:pt(r.onKeyDown,N=>{N.key==="Escape"&&(a==null||a(N.nativeEvent),N.nativeEvent.defaultPrevented||(y.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:pt(r.onPointerDown,N=>{N.button===0&&(I.current={x:N.clientX,y:N.clientY})}),onPointerMove:pt(r.onPointerMove,N=>{if(!I.current)return;const B=N.clientX-I.current.x,W=N.clientY-I.current.y,G=!!b.current,z=["left","right"].includes(y.swipeDirection),V=["left","up"].includes(y.swipeDirection)?Math.min:Math.max,J=z?V(0,B):0,K=z?0:V(0,W),Z=N.pointerType==="touch"?10:2,ee={x:J,y:K},re={originalEvent:N,delta:ee};G?(b.current=ee,zg(ODe,f,re,{discrete:!1})):LQ(ee,y.swipeDirection,Z)?(b.current=ee,zg(kDe,d,re,{discrete:!1}),N.target.setPointerCapture(N.pointerId)):(Math.abs(B)>Z||Math.abs(W)>Z)&&(I.current=null)}),onPointerUp:pt(r.onPointerUp,N=>{const B=b.current,W=N.target;if(W.hasPointerCapture(N.pointerId)&&W.releasePointerCapture(N.pointerId),b.current=null,I.current=null,B){const G=N.currentTarget,z={originalEvent:N,delta:B};LQ(B,y.swipeDirection,y.swipeThreshold)?zg(jDe,g,z,{discrete:!0}):zg(MDe,h,z,{discrete:!0}),G.addEventListener("click",V=>V.preventDefault(),{once:!0})}})})})}),y.viewport)})]}):null}),NDe=r=>{const{__scopeToast:e,children:t,...n}=r,i=Qy(Jy,e),[o,s]=A.useState(!1),[a,c]=A.useState(!1);return BDe(()=>s(!0)),A.useEffect(()=>{const l=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(l)},[]),a?null:v.jsx(fp,{asChild:!0,children:v.jsx(rR,{...n,children:o&&v.jsxs(v.Fragment,{children:[i.label," ",t]})})})},$De="ToastTitle",Rue=A.forwardRef((r,e)=>{const{__scopeToast:t,...n}=r;return v.jsx(pr.div,{...n,ref:e})});Rue.displayName=$De;var qDe="ToastDescription",kue=A.forwardRef((r,e)=>{const{__scopeToast:t,...n}=r;return v.jsx(pr.div,{...n,ref:e})});kue.displayName=qDe;var Oue="ToastAction",Mue=A.forwardRef((r,e)=>{const{altText:t,...n}=r;return t.trim()?v.jsx(Due,{altText:t,asChild:!0,children:v.jsx(oR,{...n,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${Oue}\`. Expected non-empty \`string\`.`),null)});Mue.displayName=Oue;var jue="ToastClose",oR=A.forwardRef((r,e)=>{const{__scopeToast:t,...n}=r,i=LDe(jue,t);return v.jsx(Due,{asChild:!0,children:v.jsx(pr.button,{type:"button",...n,ref:e,onClick:pt(r.onClick,i.onClose)})})});oR.displayName=jue;var Due=A.forwardRef((r,e)=>{const{__scopeToast:t,altText:n,...i}=r;return v.jsx(pr.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...i,ref:e})});function Lue(r){const e=[];return Array.from(r.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&e.push(n.textContent),UDe(n)){const i=n.ariaHidden||n.hidden||n.style.display==="none",o=n.dataset.radixToastAnnounceExclude==="";if(!i)if(o){const s=n.dataset.radixToastAnnounceAlt;s&&e.push(s)}else e.push(...Lue(n))}}),e}function zg(r,e,t,{discrete:n}){const i=t.originalEvent.currentTarget,o=new CustomEvent(r,{bubbles:!0,cancelable:!0,detail:t});e&&i.addEventListener(r,e,{once:!0}),n?SA(i,o):i.dispatchEvent(o)}var LQ=(r,e,t=0)=>{const n=Math.abs(r.x),i=Math.abs(r.y),o=n>i;return e==="left"||e==="right"?o&&n>t:!o&&i>t};function BDe(r=()=>{}){const e=ri(r);el(()=>{let t=0,n=0;return t=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(t),window.cancelAnimationFrame(n)}},[e])}function UDe(r){return r.nodeType===r.ELEMENT_NODE}function zDe(r){const e=[],t=document.createTreeWalker(r,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const i=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||i?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;t.nextNode();)e.push(t.currentNode);return e}function jI(r){const e=document.activeElement;return r.some(t=>t===e?!0:(t.focus(),document.activeElement!==e))}var HDe=Aue,WDe=Rue,KDe=kue,GDe=Mue,FQ=oR;const rC=A.createContext(null);function VDe({children:r}){const e=QC("toasts",[]),t=A.useContext(rC),n=A.useMemo(()=>({toasts:e,addToast(i){const o=i.id??Er();return e.update(s=>[...s.filter(a=>a.id!==i.id),{...i,id:o}]),o},removeToast(i){return e.update(o=>o.filter(s=>s.id!==i)),i},clearToasts(){e.set([])}}),[e]);return t?v.jsx(v.Fragment,{children:r}):v.jsx(Iue,{children:v.jsx(rC.Provider,{value:n,children:r})})}function gc(){const r=A.useContext(rC);if(!r)throw new Error("useToasts must be used within a ToastsProvider");return r}var DI={exports:{}},NQ;function YDe(){return NQ||(NQ=1,function(r){var e=function(){var t=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",o={};function s(c,l){if(!o[c]){o[c]={};for(var d=0;d<c.length;d++)o[c][c.charAt(d)]=d}return o[c][l]}var a={compressToBase64:function(c){if(c==null)return"";var l=a._compress(c,6,function(d){return n.charAt(d)});switch(l.length%4){default:case 0:return l;case 1:return l+"===";case 2:return l+"==";case 3:return l+"="}},decompressFromBase64:function(c){return c==null?"":c==""?null:a._decompress(c.length,32,function(l){return s(n,c.charAt(l))})},compressToUTF16:function(c){return c==null?"":a._compress(c,15,function(l){return t(l+32)})+" "},decompressFromUTF16:function(c){return c==null?"":c==""?null:a._decompress(c.length,16384,function(l){return c.charCodeAt(l)-32})},compressToUint8Array:function(c){for(var l=a.compress(c),d=new Uint8Array(l.length*2),f=0,h=l.length;f<h;f++){var g=l.charCodeAt(f);d[f*2]=g>>>8,d[f*2+1]=g%256}return d},decompressFromUint8Array:function(c){if(c==null)return a.decompress(c);for(var l=new Array(c.length/2),d=0,f=l.length;d<f;d++)l[d]=c[d*2]*256+c[d*2+1];var h=[];return l.forEach(function(g){h.push(t(g))}),a.decompress(h.join(""))},compressToEncodedURIComponent:function(c){return c==null?"":a._compress(c,6,function(l){return i.charAt(l)})},decompressFromEncodedURIComponent:function(c){return c==null?"":c==""?null:(c=c.replace(/ /g,"+"),a._decompress(c.length,32,function(l){return s(i,c.charAt(l))}))},compress:function(c){return a._compress(c,16,function(l){return t(l)})},_compress:function(c,l,d){if(c==null)return"";var f,h,g={},m={},y="",x="",_="",w=2,I=3,b=2,P=[],C=0,k=0,O;for(O=0;O<c.length;O+=1)if(y=c.charAt(O),Object.prototype.hasOwnProperty.call(g,y)||(g[y]=I++,m[y]=!0),x=_+y,Object.prototype.hasOwnProperty.call(g,x))_=x;else{if(Object.prototype.hasOwnProperty.call(m,_)){if(_.charCodeAt(0)<256){for(f=0;f<b;f++)C=C<<1,k==l-1?(k=0,P.push(d(C)),C=0):k++;for(h=_.charCodeAt(0),f=0;f<8;f++)C=C<<1|h&1,k==l-1?(k=0,P.push(d(C)),C=0):k++,h=h>>1}else{for(h=1,f=0;f<b;f++)C=C<<1|h,k==l-1?(k=0,P.push(d(C)),C=0):k++,h=0;for(h=_.charCodeAt(0),f=0;f<16;f++)C=C<<1|h&1,k==l-1?(k=0,P.push(d(C)),C=0):k++,h=h>>1}w--,w==0&&(w=Math.pow(2,b),b++),delete m[_]}else for(h=g[_],f=0;f<b;f++)C=C<<1|h&1,k==l-1?(k=0,P.push(d(C)),C=0):k++,h=h>>1;w--,w==0&&(w=Math.pow(2,b),b++),g[x]=I++,_=String(y)}if(_!==""){if(Object.prototype.hasOwnProperty.call(m,_)){if(_.charCodeAt(0)<256){for(f=0;f<b;f++)C=C<<1,k==l-1?(k=0,P.push(d(C)),C=0):k++;for(h=_.charCodeAt(0),f=0;f<8;f++)C=C<<1|h&1,k==l-1?(k=0,P.push(d(C)),C=0):k++,h=h>>1}else{for(h=1,f=0;f<b;f++)C=C<<1|h,k==l-1?(k=0,P.push(d(C)),C=0):k++,h=0;for(h=_.charCodeAt(0),f=0;f<16;f++)C=C<<1|h&1,k==l-1?(k=0,P.push(d(C)),C=0):k++,h=h>>1}w--,w==0&&(w=Math.pow(2,b),b++),delete m[_]}else for(h=g[_],f=0;f<b;f++)C=C<<1|h&1,k==l-1?(k=0,P.push(d(C)),C=0):k++,h=h>>1;w--,w==0&&(w=Math.pow(2,b),b++)}for(h=2,f=0;f<b;f++)C=C<<1|h&1,k==l-1?(k=0,P.push(d(C)),C=0):k++,h=h>>1;for(;;)if(C=C<<1,k==l-1){P.push(d(C));break}else k++;return P.join("")},decompress:function(c){return c==null?"":c==""?null:a._decompress(c.length,32768,function(l){return c.charCodeAt(l)})},_decompress:function(c,l,d){var f=[],h=4,g=4,m=3,y="",x=[],_,w,I,b,P,C,k,O={val:d(0),position:l,index:1};for(_=0;_<3;_+=1)f[_]=_;for(I=0,P=Math.pow(2,2),C=1;C!=P;)b=O.val&O.position,O.position>>=1,O.position==0&&(O.position=l,O.val=d(O.index++)),I|=(b>0?1:0)*C,C<<=1;switch(I){case 0:for(I=0,P=Math.pow(2,8),C=1;C!=P;)b=O.val&O.position,O.position>>=1,O.position==0&&(O.position=l,O.val=d(O.index++)),I|=(b>0?1:0)*C,C<<=1;k=t(I);break;case 1:for(I=0,P=Math.pow(2,16),C=1;C!=P;)b=O.val&O.position,O.position>>=1,O.position==0&&(O.position=l,O.val=d(O.index++)),I|=(b>0?1:0)*C,C<<=1;k=t(I);break;case 2:return""}for(f[3]=k,w=k,x.push(k);;){if(O.index>c)return"";for(I=0,P=Math.pow(2,m),C=1;C!=P;)b=O.val&O.position,O.position>>=1,O.position==0&&(O.position=l,O.val=d(O.index++)),I|=(b>0?1:0)*C,C<<=1;switch(k=I){case 0:for(I=0,P=Math.pow(2,8),C=1;C!=P;)b=O.val&O.position,O.position>>=1,O.position==0&&(O.position=l,O.val=d(O.index++)),I|=(b>0?1:0)*C,C<<=1;f[g++]=t(I),k=g-1,h--;break;case 1:for(I=0,P=Math.pow(2,16),C=1;C!=P;)b=O.val&O.position,O.position>>=1,O.position==0&&(O.position=l,O.val=d(O.index++)),I|=(b>0?1:0)*C,C<<=1;f[g++]=t(I),k=g-1,h--;break;case 2:return x.join("")}if(h==0&&(h=Math.pow(2,m),m++),f[k])y=f[k];else if(k===g)y=w+w.charAt(0);else return null;x.push(y),f[g++]=w+y.charAt(0),h--,w=y,h==0&&(h=Math.pow(2,m),m++)}}};return a}();r!=null?r.exports=e:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return e})}(DI)),DI.exports}var XDe=YDe();const Fue=cc(XDe),sR="web image/vnd.tldraw+png",ZDe={png:sR},QDe={[sR]:"image/png"};function JDe(r){return bi(ZDe,r)??null}function eLe(r){return bi(QDe,r)??r}function tLe(r){return typeof ClipboardItem<"u"&&"supports"in ClipboardItem&&ClipboardItem.supports(r)}function rLe(r){const e=Object.entries(r);for(const[t,n]of e)n.catch(i=>console.error(i));return navigator.clipboard.write([new ClipboardItem(r)]).catch(t=>(console.error(t),Promise.all(e.map(async([n,i])=>[n,await i])).then(n=>{const i=HJ(n);return navigator.clipboard.write([new ClipboardItem(i)])})))}async function nLe(r,e,t,n){const i=e.map(o=>o instanceof File?o:new File([o],"tldrawFile",{type:o.type}));r.markHistoryStoppingPoint("paste"),await r.putExternalContent({type:"files",files:i,point:t,ignoreParent:!1,sources:n})}async function nC(r,e,t,n){return r.markHistoryStoppingPoint("paste"),await r.putExternalContent({type:"url",point:t,url:e,sources:n})}const iLe=[sR,"image/png","image/jpeg","image/webp","image/svg+xml"];function oLe(r){const e=document.implementation.createHTMLDocument("");return e.documentElement.innerHTML=r.trim(),e.body.textContent||e.body.innerText||""}const sLe=r=>{try{const e=new URL(r);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}},aLe=r=>{const e=r.split(/[\n\s]/);for(const t of e)try{const n=new URL(t);if(!(n.protocol==="http:"||n.protocol==="https:"))return}catch{return}return Zte(e)},cLe=r=>/^<svg/.test(r),lLe=["input","select","textarea"];function LI(r){const{activeElement:e}=document;return r.menus.hasAnyOpenMenus()||e&&(e.getAttribute("contenteditable")||lLe.indexOf(e.tagName.toLowerCase())>-1)}const Hg=(r,e,t,n)=>{const i=aLe(e);if(i)for(const o of i)nC(r,o,t);else sLe(e)?nC(r,e,t):cLe(e)?(r.markHistoryStoppingPoint("paste"),r.putExternalContent({type:"svg-text",text:e,point:t,sources:n})):(r.markHistoryStoppingPoint("paste"),r.putExternalContent({type:"text",text:e,point:t,sources:n}))},uLe=async(r,e,t)=>{if(r.getEditingShapeId()!==null)return;if(!e)throw Error("No clipboard data");const n=[];for(const i of Object.values(e.items))switch(i.kind){case"file":{n.push({type:"file",source:new Promise(o=>o(i.getAsFile()))});break}case"string":{i.type==="text/html"?n.push({type:"html",source:new Promise(o=>i.getAsString(o))}):i.type==="text/plain"?n.push({type:"text",source:new Promise(o=>i.getAsString(o))}):n.push({type:i.type,source:new Promise(o=>i.getAsString(o))});break}}$ue(r,n,t)},Nue=async({editor:r,clipboardItems:e,point:t,fallbackFiles:n})=>{const i=[];for(const o of e){for(const s of iLe)if(o.types.includes(s)){const a=o.getType(s).then(c=>ns.rewriteMimeType(c,eLe(s)));i.push({type:"blob",source:a});break}o.types.includes("text/html")&&i.push({type:"html",source:(async()=>{const s=await o.getType("text/html");return await ns.blobToText(s)})()}),o.types.includes("text/uri-list")&&i.push({type:"url",source:(async()=>{const s=await o.getType("text/uri-list");return await ns.blobToText(s)})()}),o.types.includes("text/plain")&&i.push({type:"text",source:(async()=>{const s=await o.getType("text/plain");return await ns.blobToText(s)})()})}return n!=null&&n.length&&i.length===1&&i[0].type==="text"&&(i.pop(),i.push(...n.map(o=>({type:"file",source:Promise.resolve(o)})))),await $ue(r,i,t)};async function $ue(r,e,t){const n=e.filter(o=>(o.type==="file"||o.type==="blob")&&o.source!==null);if(n.length){if(n.length>r.options.maxFilesAtOnce)throw Error("Too many files");const o=Gt(await Promise.all(n.map(s=>s.source)));return await nLe(r,o,t)}const i=await Promise.all(e.filter(o=>o.type!=="file").map(o=>new Promise(s=>{const a=o;if(a.type==="file"){s({type:"error",data:null,reason:"unexpected file"});return}a.source.then(c=>{var d;const l=(d=c.match(/<div data-tldraw[^>]*>(.*)<\/div>/))==null?void 0:d[1];if(l)try{const f=Fue.decompressFromBase64(l);if(f===null){s({type:"error",data:f,reason:"found tldraw data comment but could not parse base64"});return}else{const h=JSON.parse(f);if(h.type!=="application/tldraw"&&s({type:"error",data:h,reason:`found tldraw data comment but JSON was of a different type: ${h.type}`}),typeof h.data=="string"){s({type:"error",data:h,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}s({type:"tldraw",data:h.data});return}}catch{s({type:"error",data:l,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}else{if(a.type==="html"){s({type:"text",data:c,subtype:"html"});return}if(a.type==="url"){s({type:"text",data:c,subtype:"url"});return}try{const f=JSON.parse(c);if(f.type==="excalidraw/clipboard"){s({type:"excalidraw",data:f});return}else{s({type:"text",data:c,subtype:"json"});return}}catch{s({type:"text",data:c,subtype:"text"});return}}s({type:"error",data:c,reason:"unhandled case"})})})));for(const o of i)if(o.type==="tldraw"){r.markHistoryStoppingPoint("paste"),r.putExternalContent({type:"tldraw",content:o.data,point:t});return}for(const o of i)if(o.type==="excalidraw"){r.markHistoryStoppingPoint("paste"),r.putExternalContent({type:"excalidraw",content:o.data,point:t});return}for(const o of i){if(o.type==="text"&&o.subtype==="html"){const a=new DOMParser().parseFromString(o.data,"text/html").querySelector("body");if(a&&Array.from(a.children).filter(l=>l.nodeType===1).length===1&&a.firstElementChild&&a.firstElementChild.tagName==="A"&&a.firstElementChild.hasAttribute("href")&&a.firstElementChild.getAttribute("href")!==""){const l=a.firstElementChild.getAttribute("href");Hg(r,l,t,i);return}if(!i.some(l=>l.type==="text"&&l.subtype!=="html")&&o.data.trim()){Hg(r,oLe(o.data),t,i);return}}if(o.type==="text"&&o.subtype==="text"&&o.data.startsWith("<iframe ")){const a=new DOMParser().parseFromString(o.data,"text/html").querySelector("body");if(a&&Array.from(a.children).filter(l=>l.nodeType===1).length===1&&a.firstElementChild&&a.firstElementChild.tagName==="IFRAME"&&a.firstElementChild.hasAttribute("src")&&a.firstElementChild.getAttribute("src")!==""){const l=a.firstElementChild.getAttribute("src");Hg(r,l,t,i);return}}}for(const o of i)if(o.type==="text"&&o.subtype==="url"){nC(r,o.data,t,i);return}for(const o of i)if(o.type==="text"&&o.subtype==="text"&&o.data.trim()){Hg(r,o.data,t,i);return}}const hm=async r=>{var n;const e=await r.resolveAssetsInContent(r.getContentFromCurrentPage(r.getSelectedShapeIds()));if(!e){navigator&&navigator.clipboard&&navigator.clipboard.writeText("");return}const t=Fue.compressToBase64(JSON.stringify({type:"application/tldraw",kind:"content",data:e}));if(!(typeof navigator>"u")){const i=e.shapes.map(o=>r.getShapeUtil(o).getText(o)).filter(gve);if((n=navigator.clipboard)!=null&&n.write){const o=new Blob([`<div data-tldraw>${t}</div>`],{type:"text/html"});let s=i.join(" ");s===""&&(s=" "),navigator.clipboard.write([new ClipboardItem({"text/html":o,"text/plain":new Blob([s],{type:"text/plain"})})])}else navigator.clipboard.writeText&&navigator.clipboard.writeText(`<div data-tldraw>${t}</div>`)}};function dLe(){const r=he(),e=ai(),t=A.useCallback(async function(s){r.getSelectedShapeIds().length!==0&&(await hm(r),e("copy",{source:s}))},[r,e]),n=A.useCallback(async function(s){r.getSelectedShapeIds().length!==0&&(await hm(r),r.deleteShapes(r.getSelectedShapeIds()),e("cut",{source:s}))},[r,e]),i=A.useCallback(async function(s,a,c){r.getEditingShapeId()===null&&(Array.isArray(s)&&s[0]instanceof ClipboardItem?(Nue({editor:r,clipboardItems:s,point:c}),e("paste",{source:"menu"})):navigator.clipboard.read().then(l=>{i(l,a,c)}))},[r,e]);return{copy:t,cut:n,paste:i}}function fLe(){const r=he(),e=ai(),t=ye("editor.isFocused",()=>r.getInstanceState().isFocused,[r]);A.useEffect(()=>{if(!t)return;const n=async c=>{r.getSelectedShapeIds().length===0||r.getEditingShapeId()!==null||LI(r)||(Qt(c),await hm(r),e("copy",{source:"kbd"}))};async function i(c){r.getSelectedShapeIds().length===0||r.getEditingShapeId()!==null||LI(r)||(Qt(c),await hm(r),r.deleteShapes(r.getSelectedShapeIds()),e("cut",{source:"kbd"}))}let o=!1;const s=c=>{c.button===1&&(o=!0,r.timers.requestAnimationFrame(()=>{o=!1}))},a=c=>{var h,g;if(o){wn(c);return}if(r.getEditingShapeId()!==null||LI(r))return;let l,d=!1;r.inputs.shiftKey&&(d=!0),r.user.getIsPasteAtCursorMode()&&(d=!d),d&&(l=r.inputs.currentPagePoint);const f=()=>{c.clipboardData&&uLe(r,c.clipboardData,l)};if((h=navigator.clipboard)!=null&&h.read){const m=Array.from(((g=c.clipboardData)==null?void 0:g.files)||[]);navigator.clipboard.read().then(y=>{Array.isArray(y)&&y[0]instanceof ClipboardItem&&Nue({editor:r,clipboardItems:y,point:l,fallbackFiles:m})},()=>{f()})}else f();Qt(c),e("paste",{source:"kbd"})};return document.addEventListener("copy",n),document.addEventListener("cut",i),document.addEventListener("paste",a),document.addEventListener("pointerup",s),()=>{document.removeEventListener("copy",n),document.removeEventListener("cut",i),document.removeEventListener("paste",a),document.removeEventListener("pointerup",s)}},[r,e,t])}const $Q={jpeg:"image/jpeg",png:"image/png",webp:"image/webp",svg:"text/plain"};function hLe(r,e,t={}){const n=e!=null&&e.length?e:[...r.getCurrentPageShapeIds()],i=t.format??"png";return{blobPromise:r.toImage(n,t).then(o=>ns.rewriteMimeType(o.blob,$Q[i])),mimeType:$Q[i]}}function pLe(...r){const[e,t,n]=typeof r[2]=="string"?[r[0],r[1],{...r[3],format:r[2]}]:r;if(!navigator.clipboard)return Promise.reject(new Error("Copy not supported"));if(navigator.clipboard.write){const{blobPromise:i,mimeType:o}=hLe(e,t,n),s={[o]:i},a=JDe(n.format);return a&&tLe(a)&&(s[a]=i.then(c=>ns.rewriteMimeType(c,a))),rLe(s)}switch(n.format){case"svg":return gLe(async()=>{const i=await e.getSvgString(t,n);if(!i)throw new Error("Failed to copy");return i.svg});case"png":throw new Error("Copy not supported");default:An(n.format)}}async function gLe(r){var e,t;await((t=(e=navigator.clipboard)==null?void 0:e.writeText)==null?void 0:t.call(e,await r()))}function vLe(){const r=he(),{addToast:e}=gc(),t=ar();return A.useCallback((n,i="svg")=>{pLe(r,n,{format:i}).catch(()=>{e({id:"copy-fail",severity:"warning",title:t("toast.error.copy-fail.title"),description:t("toast.error.copy-fail.desc")})})},[r,e,t])}async function mLe(...r){const[e,t,n]=typeof r[2]=="object"?r:[r[0],r[1],{...r[4],format:r[2]??"png",name:r[3]}];let i=n.name;if(!i&&(i=`shapes at ${qQ()}`,t.length===1)){const a=e.getShape(t[0]);e.isShapeOfType(a,"frame")?i=a.props.name||"frame":i=`${zm(a.id)} at ${qQ()}`}i+=`.${n.format}`;const{blob:o}=await e.toImage(t,n),s=new File([o],i,{type:o.type});yLe(s)}function qQ(){const r=new Date,e=String(r.getFullYear()).slice(2),t=String(r.getMonth()+1).padStart(2,"0"),n=String(r.getDate()).padStart(2,"0"),i=String(r.getHours()).padStart(2,"0"),o=String(r.getMinutes()).padStart(2,"0"),s=String(r.getSeconds()).padStart(2,"0");return`${e}-${t}-${n} ${i}.${o}.${s}`}function yLe(r){const e=document.createElement("a"),t=URL.createObjectURL(r);e.href=t,e.download=r.name,e.click(),URL.revokeObjectURL(t)}function SLe(){const r=he(),{addToast:e}=gc(),t=ar();return A.useCallback((n,i="png",o)=>{mLe(r,n,{format:i,name:o,scale:1}).catch(s=>{console.error(s.message),e({id:"export-fail",title:t("toast.error.export-fail.title"),description:t("toast.error.export-fail.desc"),severity:"error"})})},[r,e,t])}const que=lr.createContext([]);function xLe(){const r=he(),e=A.useRef(),t=Hc(lr.useContext(que));return A.useEffect(()=>{const n=window.document.createElement("input");n.type="file",n.accept=(t==null?void 0:t.join(","))??Hge,n.multiple=!0,e.current=n;async function i(o){const s=o.target.files;!s||s.length===0||(r.markHistoryStoppingPoint("insert media"),await r.putExternalContent({type:"files",files:Array.from(s),point:r.getViewportPageBounds().center,ignoreParent:!1}),n.value="")}return n.addEventListener("change",i),()=>{e.current=void 0,n.removeEventListener("change",i)}},[r,t]),A.useCallback(()=>{var n;(n=e.current)==null||n.click()},[e])}function _Le(){const r=he(),e=A.useRef(null),t=A.useRef(null);return A.useCallback(async function(){const i=document.createElement("div"),o=document.createElement("style"),s=(_,w)=>{_&&(_.innerHTML=""),w&&document.head.contains(w)&&document.head.removeChild(w),_&&document.body.contains(_)&&document.body.removeChild(_)};s(e.current,t.current),e.current=i,t.current=o;const a=`tl-print-surface-${Er()}`;i.className=a,o.innerHTML=`
247
- .${a} {
248
- display: none;
249
- }
250
-
251
- .${a} svg {
252
- max-width: 100%;
253
- height: 100%;
254
- display: block;
255
- }
256
-
257
- @media print {
258
- html, body {
259
- min-height: 100%;
260
- height: 100%;
261
- margin: 0;
262
- }
263
-
264
- body {
265
- position: relative;
266
- }
267
-
268
- body > * {
269
- display: none;
270
- }
271
-
272
- .tldraw__editor {
273
- display: none;
274
- }
275
-
276
- .${a} {
277
- display: block !important;
278
- background: white;
279
- min-height: 100%;
280
- height: 100%;
281
- max-width: 100%;
282
- }
283
-
284
- .${a}__item {
285
- padding: 10mm;
286
- display: flex;
287
- min-height: 100%;
288
- flex-direction: column;
289
- page-break-after: always;
290
- position: relative;
291
- overflow: hidden;
292
- height: 100%;
293
- }
294
-
295
- .${a}__item__main {
296
- flex: 1;
297
- display: flex;
298
- align-items: center;
299
- justify-content: center;
300
- max-height: 100%;
301
- }
302
-
303
- .${a}__item__header {
304
- display: none;
305
- }
306
-
307
- .${a}__item__footer {
308
- display: none;
309
- text-align: right;
310
- }
311
-
312
- .${a}__item__footer__hide {
313
- display: none;
314
- }
315
-
316
-
317
- }
318
-
319
- `;const c=()=>{document.head.appendChild(o),document.body.appendChild(i)},l=()=>{r.once("tick",()=>{s(i,o)})};window.addEventListener("beforeprint",c),window.addEventListener("afterprint",l);function d(_,w,I){try{i.innerHTML+=`<div class="${a}__item">
320
- <div class="${a}__item__header">
321
- ${_.replace(/</g,"&lt;").replace(/>/g,"&gt;")}
322
- </div>
323
- <div class="${a}__item__main">
324
- ${I}
325
- </div>
326
- <div class="${a}__item__footer ${a}__item__footer__${w?"":"hide"}">
327
- ${w??""}
328
- </div>
329
- </div>`}catch(b){console.error(b)}}function f(){Pr.isChromeForIos?(c(),window.print()):Pr.isSafari?(c(),document.execCommand("print",!1)):window.print()}const h=r.getSelectedShapeIds(),g=r.getCurrentPageId(),m=r.getPages(),x={scale:1,background:!1,darkMode:!1,preserveAspectRatio:"xMidYMid meet"};if(r.getSelectedShapeIds().length>0){const _=await r.getSvgString(h,x);if(_){const w=m.find(I=>I.id===g);d(`tldraw — ${w==null?void 0:w.name}`,null,_.svg),f()}}else{const _=r.getCurrentPage(),w=await r.getSvgString(r.getSortedChildIdsForParent(_.id),x);w&&(d(`tldraw — ${_.name}`,null,w.svg),f())}window.removeEventListener("beforeprint",c),window.removeEventListener("afterprint",l)},[r])}function aR(){const{addToast:r,removeToast:e,clearToasts:t}=gc(),{addDialog:n,clearDialogs:i,removeDialog:o}=vp(),s=ar(),a=xLe(),c=_Le(),{cut:l,copy:d,paste:f}=dLe(),h=vLe(),g=SLe(),m=tR(),x=Gi()<fn.TABLET_SM;return A.useMemo(()=>({addToast:r,removeToast:e,clearToasts:t,addDialog:n,removeDialog:o,clearDialogs:i,msg:s,isMobile:x,insertMedia:a,printSelectionOrPages:c,cut:l,copy:d,paste:f,copyAs:h,exportAs:g,getEmbedDefinition:m}),[r,e,t,n,o,i,s,x,a,c,l,d,f,h,g,m])}function wLe(r,e){const t={};for(const n of r)if(n.translations)for(const[i,o]of Ro(n.translations)){let s=t[i];s||(s=t[i]={}),Object.assign(s,o)}return{actions:(n,i,o)=>{for(const s of r)s.actions&&(i=s.actions(n,i,o));return i},tools:(n,i,o)=>{for(const s of r)s.tools&&(i=s.tools(n,i,{...e,...o}));return i},translations:t}}function Bue(r){return A.useMemo(()=>r,r)}function bLe(r){const e=Bue(r==null?[]:Array.isArray(r)?r:[r]);return A.useMemo(()=>{const t={};for(const n of e)if(n.translations)for(const[i,o]of Ro(n.translations)){let s=t[i];s||(s=t[i]={}),Object.assign(s,o)}return t},[e])}function ELe(r){const e=aR(),t=Bue(r==null?[]:Array.isArray(r)?r:[r]);return A.useMemo(()=>wLe(t,e),[t,e])}const Uue=A.createContext(null);function ILe(r){return Object.fromEntries(r.map(e=>[e.id,e]))}function Wg(r,e){if(r.getSelectedShapes().length===0)return r.getDocumentSettings().name||e}function PLe({overrides:r,children:e}){const t=he(),n=Zy(),i=aR(),o=ai(),s=i.msg("document.default-name"),a=A.useMemo(()=>{function c(){return t.isIn("select")||(t.complete(),t.setCurrentTool("select")),!1}function l(){return t.isIn("select")&&t.getSelectedShapeIds().length>0}const d=[{id:"edit-link",label:"action.edit-link",icon:"link",onSelect(h){l()&&(c()||(o("edit-link",{source:h}),t.markHistoryStoppingPoint("edit-link"),i.addDialog({component:pDe})))}},{id:"insert-embed",label:"action.insert-embed",kbd:"$i",onSelect(h){o("insert-embed",{source:h}),i.addDialog({component:wue})}},{id:"insert-media",label:"action.insert-media",kbd:"$u",onSelect(h){o("insert-media",{source:h}),i.insertMedia()}},{id:"undo",label:"action.undo",icon:"undo",kbd:"$z",onSelect(h){o("undo",{source:h}),t.undo()}},{id:"redo",label:"action.redo",icon:"redo",kbd:"$!z",onSelect(h){o("redo",{source:h}),t.redo()}},{id:"export-as-svg",label:{default:"action.export-as-svg",menu:"action.export-as-svg.short","context-menu":"action.export-as-svg.short"},readonlyOk:!0,onSelect(h){let g=t.getSelectedShapeIds();g.length===0&&(g=Array.from(t.getCurrentPageShapeIds().values())),g.length!==0&&(o("export-as",{format:"svg",source:h}),i.exportAs(g,"svg",Wg(t,s)))}},{id:"export-as-png",label:{default:"action.export-as-png",menu:"action.export-as-png.short","context-menu":"action.export-as-png.short"},readonlyOk:!0,onSelect(h){let g=t.getSelectedShapeIds();g.length===0&&(g=Array.from(t.getCurrentPageShapeIds().values())),g.length!==0&&(o("export-as",{format:"png",source:h}),i.exportAs(g,"png",Wg(t,s)))}},{id:"export-all-as-svg",label:{default:"action.export-all-as-svg",menu:"action.export-all-as-svg.short","context-menu":"action.export-all-as-svg.short"},readonlyOk:!0,onSelect(h){let g=t.getSelectedShapeIds();g.length===0&&(g=Array.from(t.getCurrentPageShapeIds().values())),g.length!==0&&(o("export-all-as",{format:"svg",source:h}),i.exportAs(Array.from(t.getCurrentPageShapeIds()),"svg",Wg(t,s)))}},{id:"export-all-as-png",label:{default:"action.export-all-as-png",menu:"action.export-all-as-png.short","context-menu":"action.export-all-as-png.short"},readonlyOk:!0,onSelect(h){const g=Array.from(t.getCurrentPageShapeIds().values());g.length!==0&&(o("export-all-as",{format:"png",source:h}),i.exportAs(g,"png",Wg(t,s)))}},{id:"copy-as-svg",label:{default:"action.copy-as-svg",menu:"action.copy-as-svg.short","context-menu":"action.copy-as-svg.short"},kbd:"$!c",readonlyOk:!0,onSelect(h){let g=t.getSelectedShapeIds();g.length===0&&(g=Array.from(t.getCurrentPageShapeIds().values())),g.length!==0&&(o("copy-as",{format:"svg",source:h}),i.copyAs(g,"svg"))}},{id:"copy-as-png",label:{default:"action.copy-as-png",menu:"action.copy-as-png.short","context-menu":"action.copy-as-png.short"},readonlyOk:!0,onSelect(h){let g=t.getSelectedShapeIds();g.length===0&&(g=Array.from(t.getCurrentPageShapeIds().values())),g.length!==0&&(o("copy-as",{format:"png",source:h}),i.copyAs(g,"png"))}},{id:"toggle-auto-size",label:"action.toggle-auto-size",onSelect(h){l()&&(c()||(o("toggle-auto-size",{source:h}),t.markHistoryStoppingPoint("toggling auto size"),t.run(()=>{const g=t.getSelectedShapes().filter(m=>t.isShapeOfType(m,"text")&&m.props.autoSize===!1);t.updateShapes(g.map(m=>({id:m.id,type:m.type,props:{...m.props,w:8,autoSize:!0}}))),Fr(t,g.map(m=>m.id))})))}},{id:"open-embed-link",label:"action.open-embed-link",readonlyOk:!0,onSelect(h){o("open-embed-link",{source:h});const g=t.getSelectedShapeIds(),m="No embed shapes selected";if(g.length!==1){console.error(m);return}const y=t.getShape(g[0]);if(!y||!t.isShapeOfType(y,"embed")){console.error(m);return}q2e(y.props.url,"_blank")}},{id:"select-zoom-tool",readonlyOk:!0,kbd:"z",onSelect(h){var g,m;if(((g=t.root.getCurrent())==null?void 0:g.id)!=="zoom"&&(o("zoom-tool",{source:h}),!(t.inputs.shiftKey||t.inputs.ctrlKey))){const y=t.root.getCurrent();y&&((m=y.getCurrent())==null?void 0:m.id)==="idle"&&t.setCurrentTool("zoom",{onInteractionEnd:y.id,maskAs:"zoom"})}}},{id:"convert-to-bookmark",label:"action.convert-to-bookmark",onSelect(h){l()&&(c()||t.run(()=>{o("convert-to-bookmark",{source:h});const g=t.getSelectedShapes(),m=[],y=[];for(const x of g){if(!x||!t.isShapeOfType(x,"embed")||!x.props.url)continue;const _=new T(x.x,x.y);_.rot(-x.rotation),_.add(new T(x.props.w/2-300/2,x.props.h/2-320/2)),_.rot(x.rotation);const w={id:Tr(),type:"bookmark",rotation:x.rotation,x:_.x,y:_.y,opacity:1,props:{url:x.props.url}};m.push(w),y.push(x.id)}t.markHistoryStoppingPoint("convert shapes to bookmark"),t.deleteShapes(y),t.createShapes(m)}))}},{id:"convert-to-embed",label:"action.convert-to-embed",onSelect(h){l()&&(c()||(o("convert-to-embed",{source:h}),t.run(()=>{const g=t.getSelectedShapeIds(),m=Gt(g.map(_=>t.getShape(_))),y=[],x=[];for(const _ of m){if(!t.isShapeOfType(_,"bookmark"))continue;const{url:w}=_.props,I=i.getEmbedDefinition(w);if(!I||!I.definition)continue;const{width:b,height:P}=I.definition,C=new T(_.x,_.y);C.rot(-_.rotation),C.add(new T(_.props.w/2-b/2,_.props.h/2-P/2)),C.rot(_.rotation);const k={id:Tr(),type:"embed",x:C.x,y:C.y,rotation:_.rotation,props:{url:w,w:b,h:P}};y.push(k),x.push(_.id)}t.markHistoryStoppingPoint("convert shapes to embed"),t.deleteShapes(x),t.createShapes(y)})))}},{id:"duplicate",kbd:"$d",label:"action.duplicate",icon:"duplicate",onSelect(h){if(!l()||c())return;o("duplicate-shapes",{source:h});const g=t.getInstanceState();let m,y;if(g.duplicateProps)m=g.duplicateProps.shapeIds,y=g.duplicateProps.offset;else{m=t.getSelectedShapeIds();const x=He.Common(Gt(m.map(_=>t.getShapePageBounds(_))));y=t.getCameraOptions().isLocked?{x:t.options.adjacentShapeMargin,y:t.options.adjacentShapeMargin}:{x:x.width+t.options.adjacentShapeMargin,y:0}}t.markHistoryStoppingPoint("duplicate shapes"),t.duplicateShapes(m,y),g.duplicateProps&&t.updateInstanceState({duplicateProps:{...g.duplicateProps,shapeIds:t.getSelectedShapeIds()}})}},{id:"ungroup",label:"action.ungroup",kbd:"$!g",icon:"ungroup",onSelect(h){l()&&(c()||(o("ungroup-shapes",{source:h}),t.markHistoryStoppingPoint("ungroup"),t.ungroupShapes(t.getSelectedShapeIds())))}},{id:"group",label:"action.group",kbd:"$g",icon:"group",onSelect(h){if(!l()||c())return;o("group-shapes",{source:h});const g=t.getOnlySelectedShape();g&&t.isShapeOfType(g,"group")?(t.markHistoryStoppingPoint("ungroup"),t.ungroupShapes(t.getSelectedShapeIds())):(t.markHistoryStoppingPoint("group"),t.groupShapes(t.getSelectedShapeIds()))}},{id:"remove-frame",label:"action.remove-frame",kbd:"$!f",onSelect(h){if(!l())return;o("remove-frame",{source:h});const g=t.getSelectedShapes();g.length>0&&g.every(m=>t.isShapeOfType(m,"frame"))&&(t.markHistoryStoppingPoint("remove-frame"),Kje(t,g.map(m=>m.id)))}},{id:"fit-frame-to-content",label:"action.fit-frame-to-content",onSelect(h){if(!l())return;o("fit-frame-to-content",{source:h});const g=t.getOnlySelectedShape();g&&t.isShapeOfType(g,"frame")&&(t.markHistoryStoppingPoint("fit-frame-to-content"),Vje(t,g.id))}},{id:"align-left",label:"action.align-left",kbd:"?A",icon:"align-left",onSelect(h){l()&&(c()||(o("align-shapes",{operation:"left",source:h}),t.markHistoryStoppingPoint("align left"),t.run(()=>{const g=t.getSelectedShapeIds();t.alignShapes(g,"left"),Fr(t,g)})))}},{id:"align-center-horizontal",label:{default:"action.align-center-horizontal","context-menu":"action.align-center-horizontal.short"},kbd:"?H",icon:"align-center-horizontal",onSelect(h){l()&&(c()||(o("align-shapes",{operation:"center-horizontal",source:h}),t.markHistoryStoppingPoint("align center horizontal"),t.run(()=>{const g=t.getSelectedShapeIds();t.alignShapes(g,"center-horizontal"),Fr(t,g)})))}},{id:"align-right",label:"action.align-right",kbd:"?D",icon:"align-right",onSelect(h){l()&&(c()||(o("align-shapes",{operation:"right",source:h}),t.markHistoryStoppingPoint("align right"),t.run(()=>{const g=t.getSelectedShapeIds();t.alignShapes(g,"right"),Fr(t,g)})))}},{id:"align-center-vertical",label:{default:"action.align-center-vertical","context-menu":"action.align-center-vertical.short"},kbd:"?V",icon:"align-center-vertical",onSelect(h){l()&&(c()||(o("align-shapes",{operation:"center-vertical",source:h}),t.markHistoryStoppingPoint("align center vertical"),t.run(()=>{const g=t.getSelectedShapeIds();t.alignShapes(g,"center-vertical"),Fr(t,g)})))}},{id:"align-top",label:"action.align-top",icon:"align-top",kbd:"?W",onSelect(h){l()&&(c()||(o("align-shapes",{operation:"top",source:h}),t.markHistoryStoppingPoint("align top"),t.run(()=>{const g=t.getSelectedShapeIds();t.alignShapes(g,"top"),Fr(t,g)})))}},{id:"align-bottom",label:"action.align-bottom",icon:"align-bottom",kbd:"?S",onSelect(h){l()&&(c()||(o("align-shapes",{operation:"bottom",source:h}),t.markHistoryStoppingPoint("align bottom"),t.run(()=>{const g=t.getSelectedShapeIds();t.alignShapes(g,"bottom"),Fr(t,g)})))}},{id:"distribute-horizontal",label:{default:"action.distribute-horizontal","context-menu":"action.distribute-horizontal.short"},icon:"distribute-horizontal",kbd:"?!h",onSelect(h){l()&&(c()||(o("distribute-shapes",{operation:"horizontal",source:h}),t.markHistoryStoppingPoint("distribute horizontal"),t.run(()=>{const g=t.getSelectedShapeIds();t.distributeShapes(g,"horizontal"),Fr(t,g)})))}},{id:"distribute-vertical",label:{default:"action.distribute-vertical","context-menu":"action.distribute-vertical.short"},icon:"distribute-vertical",kbd:"?!V",onSelect(h){l()&&(c()||(o("distribute-shapes",{operation:"vertical",source:h}),t.markHistoryStoppingPoint("distribute vertical"),t.run(()=>{const g=t.getSelectedShapeIds();t.distributeShapes(g,"vertical"),Fr(t,g)})))}},{id:"stretch-horizontal",label:{default:"action.stretch-horizontal","context-menu":"action.stretch-horizontal.short"},icon:"stretch-horizontal",onSelect(h){l()&&(c()||(o("stretch-shapes",{operation:"horizontal",source:h}),t.markHistoryStoppingPoint("stretch horizontal"),t.run(()=>{const g=t.getSelectedShapeIds();t.stretchShapes(g,"horizontal"),Fr(t,g)})))}},{id:"stretch-vertical",label:{default:"action.stretch-vertical","context-menu":"action.stretch-vertical.short"},icon:"stretch-vertical",onSelect(h){l()&&(c()||(o("stretch-shapes",{operation:"vertical",source:h}),t.markHistoryStoppingPoint("stretch vertical"),t.run(()=>{const g=t.getSelectedShapeIds();t.stretchShapes(g,"vertical"),Fr(t,g)})))}},{id:"flip-horizontal",label:{default:"action.flip-horizontal","context-menu":"action.flip-horizontal.short"},kbd:"!h",onSelect(h){l()&&(c()||(o("flip-shapes",{operation:"horizontal",source:h}),t.markHistoryStoppingPoint("flip horizontal"),t.run(()=>{const g=t.getSelectedShapeIds();t.flipShapes(g,"horizontal"),Fr(t,g)})))}},{id:"flip-vertical",label:{default:"action.flip-vertical","context-menu":"action.flip-vertical.short"},kbd:"!v",onSelect(h){l()&&(c()||(o("flip-shapes",{operation:"vertical",source:h}),t.markHistoryStoppingPoint("flip vertical"),t.run(()=>{const g=t.getSelectedShapeIds();t.flipShapes(g,"vertical"),Fr(t,g)})))}},{id:"pack",label:"action.pack",icon:"pack",onSelect(h){l()&&(c()||(o("pack-shapes",{source:h}),t.markHistoryStoppingPoint("pack"),t.run(()=>{const g=t.getSelectedShapeIds();t.packShapes(g,t.options.adjacentShapeMargin),Fr(t,g)})))}},{id:"stack-vertical",label:{default:"action.stack-vertical","context-menu":"action.stack-vertical.short"},icon:"stack-vertical",onSelect(h){l()&&(c()||(o("stack-shapes",{operation:"vertical",source:h}),t.markHistoryStoppingPoint("stack-vertical"),t.run(()=>{const g=t.getSelectedShapeIds();t.stackShapes(g,"vertical",16),Fr(t,g)})))}},{id:"stack-horizontal",label:{default:"action.stack-horizontal","context-menu":"action.stack-horizontal.short"},icon:"stack-horizontal",onSelect(h){l()&&(c()||(o("stack-shapes",{operation:"horizontal",source:h}),t.markHistoryStoppingPoint("stack-horizontal"),t.run(()=>{const g=t.getSelectedShapeIds();t.stackShapes(g,"horizontal",16),Fr(t,g)})))}},{id:"bring-to-front",label:"action.bring-to-front",kbd:"]",icon:"bring-to-front",onSelect(h){l()&&(c()||(o("reorder-shapes",{operation:"toFront",source:h}),t.markHistoryStoppingPoint("bring to front"),t.bringToFront(t.getSelectedShapeIds())))}},{id:"bring-forward",label:"action.bring-forward",icon:"bring-forward",kbd:"?]",onSelect(h){l()&&(c()||(o("reorder-shapes",{operation:"forward",source:h}),t.markHistoryStoppingPoint("bring forward"),t.bringForward(t.getSelectedShapeIds())))}},{id:"send-backward",label:"action.send-backward",icon:"send-backward",kbd:"?[",onSelect(h){l()&&(c()||(o("reorder-shapes",{operation:"backward",source:h}),t.markHistoryStoppingPoint("send backward"),t.sendBackward(t.getSelectedShapeIds())))}},{id:"send-to-back",label:"action.send-to-back",icon:"send-to-back",kbd:"[",onSelect(h){l()&&(c()||(o("reorder-shapes",{operation:"toBack",source:h}),t.markHistoryStoppingPoint("send to back"),t.sendToBack(t.getSelectedShapeIds())))}},{id:"cut",label:"action.cut",kbd:"$x",onSelect(h){l()&&(c()||(t.markHistoryStoppingPoint("cut"),i.cut(h)))}},{id:"copy",label:"action.copy",kbd:"$c",readonlyOk:!0,onSelect(h){l()&&(c()||i.copy(h))}},{id:"paste",label:"action.paste",kbd:"$v",onSelect(h){var g;(g=navigator.clipboard)==null||g.read().then(m=>{i.paste(m,h,h==="context-menu"?t.inputs.currentPagePoint:void 0)}).catch(()=>{i.addToast({title:i.msg("action.paste-error-title"),description:i.msg("action.paste-error-description"),severity:"error"})})}},{id:"select-all",label:"action.select-all",kbd:"$a",readonlyOk:!0,onSelect(h){t.run(()=>{c()||(o("select-all-shapes",{source:h}),t.markHistoryStoppingPoint("select all kbd"),t.selectAll())})}},{id:"select-none",label:"action.select-none",readonlyOk:!0,onSelect(h){l()&&(c()||(o("select-none-shapes",{source:h}),t.markHistoryStoppingPoint("select none"),t.selectNone()))}},{id:"delete",label:"action.delete",kbd:"⌫,del,backspace",icon:"trash",onSelect(h){l()&&(c()||(o("delete-shapes",{source:h}),t.markHistoryStoppingPoint("delete"),t.deleteShapes(t.getSelectedShapeIds())))}},{id:"rotate-cw",label:"action.rotate-cw",icon:"rotate-cw",onSelect(h){l()&&(c()||(o("rotate-cw",{source:h}),t.markHistoryStoppingPoint("rotate-cw"),t.run(()=>{const g=t.getSelectionRotation()%(Nr/2),m=Yc(g,0)||Yc(g,Nr/2),y=t.getSelectedShapeIds();t.rotateShapesBy(y,Nr/2-(m?0:g)),Fr(t,y)})))}},{id:"rotate-ccw",label:"action.rotate-ccw",icon:"rotate-ccw",onSelect(h){l()&&(c()||(o("rotate-ccw",{source:h}),t.markHistoryStoppingPoint("rotate-ccw"),t.run(()=>{const g=t.getSelectionRotation()%(Nr/2),m=Yc(g,0),y=t.getSelectedShapeIds();t.rotateShapesBy(y,m?-(Nr/2):-g),Fr(t,y)})))}},{id:"zoom-in",label:"action.zoom-in",kbd:"$=,=",readonlyOk:!0,onSelect(h){o("zoom-in",{source:h}),t.zoomIn(void 0,{animation:{duration:t.options.animationMediumMs}})}},{id:"zoom-out",label:"action.zoom-out",kbd:"$-,-",readonlyOk:!0,onSelect(h){o("zoom-out",{source:h}),t.zoomOut(void 0,{animation:{duration:t.options.animationMediumMs}})}},{id:"zoom-to-100",label:"action.zoom-to-100",icon:"reset-zoom",kbd:"!0",readonlyOk:!0,onSelect(h){o("reset-zoom",{source:h}),t.resetZoom(void 0,{animation:{duration:t.options.animationMediumMs}})}},{id:"zoom-to-fit",label:"action.zoom-to-fit",kbd:"!1",readonlyOk:!0,onSelect(h){o("zoom-to-fit",{source:h}),t.zoomToFit({animation:{duration:t.options.animationMediumMs}})}},{id:"zoom-to-selection",label:"action.zoom-to-selection",kbd:"!2",readonlyOk:!0,onSelect(h){l()&&(c()||(o("zoom-to-selection",{source:h}),t.zoomToSelection({animation:{duration:t.options.animationMediumMs}})))}},{id:"toggle-snap-mode",label:{default:"action.toggle-snap-mode",menu:"action.toggle-snap-mode.menu"},onSelect(h){o("toggle-snap-mode",{source:h}),t.user.updateUserPreferences({isSnapMode:!t.user.getIsSnapMode()})},checkbox:!0},{id:"toggle-dark-mode",label:{default:"action.toggle-dark-mode",menu:"action.toggle-dark-mode.menu"},kbd:"$/",readonlyOk:!0,onSelect(h){const g=t.user.getIsDarkMode()?"light":"dark";o("color-scheme",{source:h,value:g}),t.user.updateUserPreferences({colorScheme:g})},checkbox:!0},{id:"toggle-wrap-mode",label:{default:"action.toggle-wrap-mode",menu:"action.toggle-wrap-mode.menu"},readonlyOk:!0,onSelect(h){o("toggle-wrap-mode",{source:h}),t.user.updateUserPreferences({isWrapMode:!t.user.getIsWrapMode()})},checkbox:!0},{id:"toggle-dynamic-size-mode",label:{default:"action.toggle-dynamic-size-mode",menu:"action.toggle-dynamic-size-mode.menu"},readonlyOk:!1,onSelect(h){o("toggle-dynamic-size-mode",{source:h}),t.user.updateUserPreferences({isDynamicSizeMode:!t.user.getIsDynamicResizeMode()})},checkbox:!0},{id:"toggle-paste-at-cursor",label:{default:"action.toggle-paste-at-cursor",menu:"action.toggle-paste-at-cursor.menu"},readonlyOk:!1,onSelect(h){o("toggle-paste-at-cursor",{source:h}),t.user.updateUserPreferences({isPasteAtCursorMode:!t.user.getIsPasteAtCursorMode()})},checkbox:!0},{id:"toggle-reduce-motion",label:{default:"action.toggle-reduce-motion",menu:"action.toggle-reduce-motion.menu"},readonlyOk:!0,onSelect(h){o("toggle-reduce-motion",{source:h}),t.user.updateUserPreferences({animationSpeed:t.user.getAnimationSpeed()===0?1:0})},checkbox:!0},{id:"toggle-edge-scrolling",label:{default:"action.toggle-edge-scrolling",menu:"action.toggle-edge-scrolling.menu"},readonlyOk:!0,onSelect(h){o("toggle-edge-scrolling",{source:h}),t.user.updateUserPreferences({edgeScrollSpeed:t.user.getEdgeScrollSpeed()===0?1:0})},checkbox:!0},{id:"toggle-transparent",label:{default:"action.toggle-transparent",menu:"action.toggle-transparent.menu","context-menu":"action.toggle-transparent.context-menu"},readonlyOk:!0,onSelect(h){o("toggle-transparent",{source:h}),t.updateInstanceState({exportBackground:!t.getInstanceState().exportBackground})},checkbox:!0},{id:"toggle-tool-lock",label:{default:"action.toggle-tool-lock",menu:"action.toggle-tool-lock.menu"},kbd:"q",onSelect(h){o("toggle-tool-lock",{source:h}),t.updateInstanceState({isToolLocked:!t.getInstanceState().isToolLocked})},checkbox:!0},{id:"unlock-all",label:"action.unlock-all",onSelect(h){o("unlock-all",{source:h});const g=[];for(const m of t.getCurrentPageShapes())m.isLocked&&g.push({id:m.id,type:m.type,isLocked:!1});g.length>0&&t.updateShapes(g)}},{id:"toggle-focus-mode",label:{default:"action.toggle-focus-mode",menu:"action.toggle-focus-mode.menu"},readonlyOk:!0,kbd:"$.",checkbox:!0,onSelect(h){t.timers.requestAnimationFrame(()=>{t.run(()=>{o("toggle-focus-mode",{source:h}),i.clearDialogs(),i.clearToasts(),t.updateInstanceState({isFocusMode:!t.getInstanceState().isFocusMode})})})}},{id:"toggle-grid",label:{default:"action.toggle-grid",menu:"action.toggle-grid.menu"},readonlyOk:!0,kbd:"$'",onSelect(h){o("toggle-grid-mode",{source:h}),t.updateInstanceState({isGridMode:!t.getInstanceState().isGridMode})},checkbox:!0},{id:"toggle-debug-mode",label:{default:"action.toggle-debug-mode",menu:"action.toggle-debug-mode.menu"},readonlyOk:!0,onSelect(h){o("toggle-debug-mode",{source:h}),t.updateInstanceState({isDebugMode:!t.getInstanceState().isDebugMode})},checkbox:!0},{id:"print",label:"action.print",kbd:"$p",readonlyOk:!0,onSelect(h){o("print",{source:h}),i.printSelectionOrPages()}},{id:"exit-pen-mode",label:"action.exit-pen-mode",icon:"cross-2",readonlyOk:!0,onSelect(h){o("exit-pen-mode",{source:h}),t.updateInstanceState({isPenMode:!1})}},{id:"stop-following",label:"action.stop-following",icon:"cross-2",readonlyOk:!0,onSelect(h){o("stop-following",{source:h}),t.stopFollowingUser()}},{id:"back-to-content",label:"action.back-to-content",icon:"arrow-left",readonlyOk:!0,onSelect(h){o("zoom-to-content",{source:h});const g=t.getSelectionPageBounds()??t.getCurrentPageBounds();g&&t.zoomToBounds(g,{targetZoom:Math.min(1,t.getZoomLevel()),animation:{duration:220}})}},{id:"toggle-lock",label:"action.toggle-lock",kbd:"!l",onSelect(h){t.markHistoryStoppingPoint("locking"),o("toggle-lock",{source:h}),t.toggleLock(t.getSelectedShapeIds())}},{id:"move-to-new-page",label:"context.pages.new-page",onSelect(h){const g=Fo.createId(),m=t.getSelectedShapeIds();t.run(()=>{t.markHistoryStoppingPoint("move_shapes_to_page"),t.createPage({name:i.msg("page-menu.new-page-initial-name"),id:g}),t.moveShapesToPage(m,g)}),o("move-to-new-page",{source:h})}},{id:"select-white-color",label:"color-style.white",kbd:"?t",onSelect(h){const g=Lo;t.run(()=>{t.markHistoryStoppingPoint("change-color"),t.isIn("select")&&t.setStyleForSelectedShapes(g,"white"),t.setStyleForNextShapes(g,"white")}),o("set-style",{source:h,id:g.id,value:"white"})}},{id:"select-fill-fill",label:"fill-style.fill",kbd:"?f",onSelect(h){const g=Zl;t.run(()=>{t.markHistoryStoppingPoint("change-fill"),t.isIn("select")&&t.setStyleForSelectedShapes(g,"fill"),t.setStyleForNextShapes(g,"fill")}),o("set-style",{source:h,id:g.id,value:"fill"})}},{id:"flatten-to-image",label:"action.flatten-to-image",kbd:"!f",onSelect:async h=>{const g=t.getSelectedShapeIds();if(g.length===0)return;t.markHistoryStoppingPoint("flattening to image"),o("flatten-to-image",{source:h});const m=await wDe(t,g,t.options.flattenImageBoundsExpand);m!=null&&m.length&&t.setSelectedShapes(m)}},{id:"select-geo-tool",kbd:"g",onSelect:async h=>{o("select-tool",{source:h,id:"geo-previous"}),t.setCurrentTool("geo")}}];n&&d.push({id:"open-cursor-chat",label:"action.open-cursor-chat",readonlyOk:!0,kbd:"/",onSelect(h){o("open-cursor-chat",{source:h}),!t.getInstanceState().isCoarsePointer&&t.timers.requestAnimationFrame(()=>{t.updateInstanceState({isChatting:!0})})}});const f=ILe(d);return r?r(t,f,i):f},[i,t,o,r,s,n]);return v.jsx(Uue.Provider,{value:a,children:e})}function bu(){const r=A.useContext(Uue);if(!r)throw new Error("useTools must be used within a ToolProvider");return r}function Th(r,e){return r?typeof r=="string"?r:e?r[e]??r.default:void 0:void 0}function Wo(){const r=ll();return ye("isReadonlyMode",()=>!!(r!=null&&r.getIsReadonly()),[r])}const CLe=Pr.isDarwin?"⌘":"Ctrl",TLe=Pr.isDarwin?"⌥":"Alt";function zue(r){return r===","?[","]:r.split(",")[0].split("").map(e=>{const t=e.replace(/\$/g,CLe).replace(/\?/g,TLe).replace(/!/g,"⇧");return t[0].toUpperCase()+t.slice(1)})}function iC(r){return"— "+zue(r).join(" ")}function uh({children:r,visibleOnMobileLayout:e=!1}){const t=Gi();return!e&&t<fn.MOBILE?null:v.jsx("kbd",{className:"tlui-kbd",children:zue(r).map((n,i)=>v.jsx("span",{children:n},i))})}const Hue=A.createContext(null);function eS(){const r=A.useContext(Hue);if(!r)throw new Error("useTldrawUiMenuContext must be used within a TldrawUiMenuContextProvider");return r}function ls({type:r,sourceId:e,children:t}){return v.jsx(Hue.Provider,{value:{type:r,sourceId:e},children:t})}function tS({id:r,kbd:e,label:t,readonlyOk:n,onSelect:i,toggle:o=!1,disabled:s=!1,checked:a=!1}){const{type:c,sourceId:l}=eS(),d=Wo(),f=ar();if(d&&!n)return null;const h=Th(t,c),g=h?f(h):void 0;switch(c){case"menu":return v.jsxs(Uje,{dir:"ltr",className:"tlui-button tlui-button__menu tlui-button__checkbox",title:g,onSelect:m=>{i==null||i(l),Qt(m)},disabled:s,checked:a,children:[v.jsx(Sa,{small:!0,icon:o?a?"toggle-on":"toggle-off":a?"check":"none"}),g&&v.jsx("span",{className:"tlui-button__label",draggable:!1,children:g}),e&&v.jsx(uh,{children:e})]});case"context-menu":return v.jsxs(yje,{className:"tlui-button tlui-button__menu tlui-button__checkbox",dir:"ltr",title:g,onSelect:m=>{i(l),Qt(m)},disabled:s,checked:a,children:[v.jsx(Sa,{small:!0,icon:o?a?"toggle-on":"toggle-off":a?"check":"none"}),g&&v.jsx("span",{className:"tlui-button__label",draggable:!1,children:g}),e&&v.jsx(uh,{children:e})]},r);default:return null}}function vc(r,e){const t=ll(),n=A.useCallback(s=>{s&&(t==null||t.complete()),e==null||e(s)},[t,e]),i=ai(),o=A.useCallback(s=>{i(s,{source:"unknown",id:r})},[r,i]);return O2e(t?`${r}-${t.contextId}`:r,n,o)}function tu({id:r,children:e,modal:t=!1,debugOpen:n=!1}){const[i,o]=vc(r);return v.jsx(WA,{open:n||i,dir:"ltr",modal:t,onOpenChange:o,children:e})}function ru({children:r,...e}){return v.jsx(KA,{dir:"ltr",asChild:!0,onTouchEnd:t=>Qt(t),...e,children:r})}function nu({className:r,side:e="bottom",align:t="start",sideOffset:n=8,alignOffset:i=8,children:o}){const s=Ln();return v.jsx(Ky,{container:s,children:v.jsx(GA,{className:bt("tlui-menu",r),side:e,sideOffset:n,align:t,alignOffset:i,collisionPadding:4,children:o})})}function ALe({id:r,children:e}){const[t,n]=vc(r);return v.jsx(zje,{open:t,onOpenChange:n,children:e})}function RLe({id:r,label:e,title:t,disabled:n}){return v.jsx(Hje,{dir:"ltr",asChild:!0,disabled:n,children:v.jsxs(It,{"data-testid":r,type:"menu",className:"tlui-menu__submenu__trigger",disabled:n,title:t,children:[v.jsx(Sn,{children:e}),v.jsx(rr,{icon:"chevron-right",small:!0})]})})}function kLe({id:r,alignOffset:e=-1,sideOffset:t=-6,size:n="small",children:i}){const o=Ln();return v.jsx(Ky,{container:o,children:v.jsx(Wje,{"data-testid":r,className:"tlui-menu tlui-menu__submenu__content",alignOffset:e,sideOffset:t,collisionPadding:4,"data-size":n,children:i})})}function OLe({children:r}){return v.jsx(qje,{dir:"ltr",className:"tlui-menu__group",children:r})}function Ah({noClose:r,children:e}){return v.jsx(Bje,{dir:"ltr",asChild:!0,onClick:r?Qt:void 0,children:e})}function Yt({id:r,label:e,children:t}){const{type:n,sourceId:i}=eS(),o=ar(),s=Th(e,n),a=s?o(s):void 0;switch(n){case"panel":return v.jsx("div",{className:"tlui-menu__group","data-testid":`${i}-group.${r}`,children:t});case"menu":return v.jsx(OLe,{"data-testid":`${i}-group.${r}`,children:t});case"context-menu":return v.jsx($le,{dir:"ltr",className:"tlui-menu__group","data-testid":`${i}-group.${r}`,children:t});case"keyboard-shortcuts":return v.jsxs("div",{className:"tlui-shortcuts-dialog__group","data-testid":`${i}-group.${r}`,children:[v.jsx("h2",{className:"tlui-shortcuts-dialog__group__title",children:a}),v.jsx("div",{className:"tlui-shortcuts-dialog__group__content",children:t})]});default:return t}}function xo({id:r,disabled:e=!1,label:t,size:n="small",children:i}){const{type:o,sourceId:s}=eS(),a=Ln(),c=ar(),l=t?typeof t=="string"?t:t[o]??t.default:void 0,d=l?c(l):void 0;switch(o){case"menu":return v.jsxs(ALe,{id:`${s}-sub.${r}`,children:[v.jsx(RLe,{id:`${s}-sub.${r}-button`,disabled:e,label:d,title:d}),v.jsx(kLe,{id:`${s}-sub.${r}-content`,size:n,children:i})]});case"context-menu":return e?null:v.jsxs(MLe,{id:`${s}-sub.${r}`,children:[v.jsx(zle,{dir:"ltr",disabled:e,asChild:!0,children:v.jsxs(It,{"data-testid":`${s}-sub.${r}-button`,type:"menu",className:"tlui-menu__submenu__trigger",children:[v.jsx(Sn,{children:d}),v.jsx(rr,{icon:"chevron-right",small:!0})]})}),v.jsx(zA,{container:a,children:v.jsx(Hle,{"data-testid":`${s}-sub.${r}-content`,className:"tlui-menu tlui-menu__submenu__content",alignOffset:-1,sideOffset:-4,collisionPadding:4,"data-size":n,children:i})})]});default:return i}}function MLe({id:r,children:e}){const[t,n]=vc(r);return v.jsx(Ule,{open:t,onOpenChange:n,children:e})}const jLe=[{colorScheme:"light",label:"theme.light"},{colorScheme:"dark",label:"theme.dark"},{colorScheme:"system",label:"theme.system"}];function DLe(){const r=he(),e=ai(),t=ye("colorScheme",()=>r.user.getUserPreferences().colorScheme??(r.user.getIsDarkMode()?"dark":"light"),[r]);return v.jsx(xo,{id:"help menu color-scheme",label:"menu.theme",children:v.jsx(Yt,{id:"theme",children:jLe.map(({colorScheme:n,label:i})=>v.jsx(tS,{id:`color-scheme-${n}`,label:i,checked:n===t,readonlyOk:!0,onSelect:()=>{r.user.updateUserPreferences({colorScheme:n}),e("color-scheme",{source:"menu",value:n})}},n))})})}const LLe=({id:r,component:e,onClose:t,preventBackgroundClose:n})=>{const{removeDialog:i}=vp(),o=A.useRef(!1),s=Ln(),a=A.useCallback(c=>{if(!c){if(t)try{t()}catch(l){console.warn(l)}i(r)}},[r,t,i]);return v.jsx(lDe,{onOpenChange:a,defaultOpen:!0,children:v.jsx(uDe,{container:s,children:v.jsx(dDe,{dir:"ltr",className:"tlui-dialog__overlay",onClick:c=>{o.current||!n&&c.target===c.currentTarget&&a(!1)},children:v.jsx(fDe,{dir:"ltr",className:"tlui-dialog__content","aria-describedby":void 0,onMouseDown:()=>o.current=!0,onMouseUp:()=>o.current=!1,onInteractOutside:c=>{o.current=!1,n&&c.preventDefault()},children:v.jsx(e,{onClose:()=>{o.current=!1,a(!1)}})})})})})},FLe=A.memo(function(){const{dialogs:e}=vp();return ye("dialogs",()=>e.get(),[e]).map(n=>v.jsx(LLe,{...n},n.id))}),NLe=4e3,$Le={success:"check-circle",warning:"warning-triangle",error:"cross-circle",info:"info-circle"};function qLe({toast:r}){const{removeToast:e}=gc(),t=ar(),n=s=>{s||e(r.id)},i=r.actions&&r.actions.length>0,o=r.icon||r.severity&&$Le[r.severity];return v.jsxs(HDe,{onOpenChange:n,className:"tlui-toast__container",duration:r.keepOpen?1/0:NLe,"data-severity":r.severity,children:[o&&v.jsx("div",{className:"tlui-toast__icon",children:v.jsx(Sa,{icon:o})}),v.jsxs("div",{className:"tlui-toast__main","data-title":!!r.title,"data-description":!!r.description,"data-actions":!!r.actions,children:[v.jsxs("div",{className:"tlui-toast__content",children:[r.title&&v.jsx(WDe,{className:"tlui-toast__title",children:r.title}),r.description&&v.jsx(KDe,{className:"tlui-toast__description",children:r.description})]}),r.actions&&v.jsxs("div",{className:"tlui-toast__actions",children:[r.actions.map((s,a)=>v.jsx(GDe,{altText:s.label,asChild:!0,onClick:s.onClick,children:v.jsx(It,{type:s.type,children:v.jsx(Sn,{children:s.label})})},a)),v.jsx(FQ,{asChild:!0,children:v.jsx(It,{type:"normal",className:"tlui-toast__close",style:{marginLeft:"auto"},children:v.jsx(Sn,{children:r.closeLabel??t("toast.close")})})})]})]}),!i&&v.jsx(FQ,{asChild:!0,children:v.jsx(It,{type:"normal",className:"tlui-toast__close",children:v.jsx(Sn,{children:r.closeLabel??t("toast.close")})})})]})}const BLe=A.memo(function(){const{toasts:e}=gc(),t=ye("toasts",()=>e.get(),[]);return v.jsxs(v.Fragment,{children:[t.map(n=>v.jsx(qLe,{toast:n},n.id)),v.jsx(Cue,{className:"tlui-toast__viewport"})]})});function Hs({actionId:r="",...e}){const n=bu()[r];return n?v.jsx(tS,{...n,...e}):null}function BQ(r){return v.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",...r,children:v.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[v.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),v.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:v.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}function Qn({disabled:r=!1,spinner:e=!1,readonlyOk:t=!1,id:n,kbd:i,label:o,icon:s,onSelect:a,noClose:c,isSelected:l}){const{type:d,sourceId:f}=eS(),h=ar(),[g,m]=A.useState(!1);if(Wo()&&!t)return null;const x=Th(o,d),_=i?iC(i):void 0,w=x?h(x):void 0,I=w&&_?`${w} ${_}`:w;switch(d){case"menu":return v.jsx(Ah,{children:v.jsxs(It,{type:"menu","data-testid":`${f}.${n}`,disabled:r,title:I,onClick:b=>{c&&Qt(b),g?m(!1):a(f)},children:[v.jsx(Sn,{children:w}),i&&v.jsx(uh,{children:i})]})});case"context-menu":return r?null:v.jsxs(qle,{dir:"ltr",title:I,draggable:!1,className:"tlui-button tlui-button__menu","data-testid":`${f}.${n}`,onSelect:b=>{c&&Qt(b),g?m(!1):a(f)},children:[v.jsx("span",{className:"tlui-button__label",draggable:!1,children:w}),i&&v.jsx(uh,{children:i}),e&&v.jsx(BQ,{})]});case"panel":return v.jsxs(It,{"data-testid":`${f}.${n}`,type:"menu",title:I,disabled:r,onClick:()=>a(f),children:[v.jsx(Sn,{children:w}),e?v.jsx(BQ,{}):s&&v.jsx(rr,{icon:s})]});case"small-icons":case"icons":return v.jsx(It,{"data-testid":`${f}.${n}`,type:"icon",title:I,disabled:r,onClick:()=>a(f),children:v.jsx(rr,{icon:s,small:d==="small-icons"})});case"keyboard-shortcuts":return i?v.jsxs("div",{className:"tlui-shortcuts-dialog__key-pair","data-testid":`${f}.${n}`,children:[v.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__key",children:w}),v.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__value",children:v.jsx(uh,{visibleOnMobileLayout:!0,children:i})})]}):(console.warn(`Menu item '${o}' isn't shown in the keyboard shortcuts dialog because it doesn't have a keyboard shortcut.`),null);case"helper-buttons":return v.jsxs(It,{type:"low",onClick:()=>a(f),children:[v.jsx(rr,{icon:s}),v.jsx(Sn,{children:w})]});case"toolbar":return v.jsx(It,{type:"tool","data-testid":`tools.${n}`,"aria-label":x,"data-value":n,onClick:()=>a("toolbar"),title:I,disabled:r,onTouchStart:b=>{Qt(b),a("toolbar")},role:"radio","aria-checked":l?"true":"false",children:v.jsx(rr,{icon:s})});case"toolbar-overflow":return v.jsx(Ah,{"aria-label":o,children:v.jsx(It,{type:"icon",className:"tlui-button-grid__button",onClick:()=>{a("toolbar")},"data-testid":`tools.more.${n}`,title:I,disabled:r,role:"radio","aria-checked":l?"true":"false","data-value":n,children:v.jsx(rr,{icon:s})})});default:throw An(d)}}function Ce({actionId:r="",...e}){const n=bu()[r];return n?v.jsx(Qn,{...n,...e}):null}const Wue=A.createContext(null);function ULe({overrides:r,children:e}){const t=he(),n=ai(),i=aR(),o=A.useMemo(()=>{const s=[{id:"select",label:"tool.select",icon:"tool-pointer",kbd:"v",readonlyOk:!0,onSelect(c){if(t.isIn("select")){const l=t.root.getCurrent();l.exit({},l.id),l.enter({},l.id)}t.setCurrentTool("select"),n("select-tool",{source:c,id:"select"})}},{id:"hand",label:"tool.hand",icon:"tool-hand",kbd:"h",readonlyOk:!0,onSelect(c){t.setCurrentTool("hand"),n("select-tool",{source:c,id:"hand"})}},{id:"eraser",label:"tool.eraser",icon:"tool-eraser",kbd:"e",onSelect(c){t.setCurrentTool("eraser"),n("select-tool",{source:c,id:"eraser"})}},{id:"draw",label:"tool.draw",icon:"tool-pencil",kbd:"d,b,x",onSelect(c){t.setCurrentTool("draw"),n("select-tool",{source:c,id:"draw"})}},...[...Ts.values].map(c=>({id:c,label:`tool.${c}`,meta:{geo:c},kbd:c==="rectangle"?"r":c==="ellipse"?"o":void 0,icon:"geo-"+c,onSelect(l){t.run(()=>{t.setStyleForNextShapes(Ts,c),t.setCurrentTool("geo"),n("select-tool",{source:l,id:`geo-${c}`})})}})),{id:"arrow",label:"tool.arrow",icon:"tool-arrow",kbd:"a",onSelect(c){t.setCurrentTool("arrow"),n("select-tool",{source:c,id:"arrow"})}},{id:"line",label:"tool.line",icon:"tool-line",kbd:"l",onSelect(c){t.setCurrentTool("line"),n("select-tool",{source:c,id:"line"})}},{id:"frame",label:"tool.frame",icon:"tool-frame",kbd:"f",onSelect(c){t.setCurrentTool("frame"),n("select-tool",{source:c,id:"frame"})}},{id:"text",label:"tool.text",icon:"tool-text",kbd:"t",onSelect(c){t.setCurrentTool("text"),n("select-tool",{source:c,id:"text"})}},{id:"asset",label:"tool.asset",icon:"tool-media",kbd:"$u",onSelect(c){i.insertMedia(),n("select-tool",{source:c,id:"media"})}},{id:"note",label:"tool.note",icon:"tool-note",kbd:"n",onSelect(c){t.setCurrentTool("note"),n("select-tool",{source:c,id:"note"})}},{id:"laser",label:"tool.laser",readonlyOk:!0,icon:"tool-laser",kbd:"k",onSelect(c){t.setCurrentTool("laser"),n("select-tool",{source:c,id:"laser"})}},{id:"embed",label:"tool.embed",icon:"dot",onSelect(c){i.addDialog({component:wue}),n("select-tool",{source:c,id:"embed"})}},{id:"highlight",label:"tool.highlight",icon:"tool-highlight",kbd:"!d",onSelect(c){t.setCurrentTool("highlight"),n("select-tool",{source:c,id:"highlight"})}}];s.push();const a=Object.fromEntries(s.map(c=>[c.id,c]));return r?r(t,a,i):a},[r,t,n,i]);return v.jsx(Wue.Provider,{value:o,children:e})}function cR(){const r=A.useContext(Wue);if(!r)throw new Error("useTools must be used within a ToolProvider");return r}function so({toolId:r="",...e}){const n=cR()[r];return n?v.jsx(Qn,{...n,...e}):null}function zLe({children:r}){const e=he();return ye("shouldDisplayHandles",()=>{if(e.isInAny("select.idle","select.pointing_handle","select.pointing_shape"))return!0;if(e.isInAny("select.editing_shape")){const n=e.getOnlySelectedShape();return n&&e.isShapeOfType(n,"note")}return!1},[e])?v.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:r}):null}const{PI:HLe}=Math,xd=HLe+1e-4;function Kue(r,e={}){const{size:t=16,smoothing:n=.5}=e;if(r.length===0||t<=0)return{left:[],right:[]};const i=r[0],o=r[r.length-1],s=o.runningLength,a=Math.pow(t*n,2),c=[],l=[];let d=r[0].vector,f=r[0].point,h=f,g=f,m=h,y=!1,x;for(let _=0;_<r.length;_++){x=r[_];const{point:w,vector:I}=r[_],b=x.vector.dpr(d),P=(_<r.length-1?r[_+1]:r[_]).vector,C=_<r.length-1?P.dpr(x.vector):1,k=b<0&&!y,O=C!==null&&C<.2;if(k||O){if(C>-.62&&s-x.runningLength>x.radius){const j=d.clone().mul(x.radius);d.clone().cpr(P)<0?(g=T.Add(w,j),m=T.Sub(w,j)):(g=T.Sub(w,j),m=T.Add(w,j)),c.push(g),l.push(m)}else{const j=d.clone().mul(x.radius).per(),F=T.Sub(x.input,j);for(let $=1/13,D=0;D<1;D+=$)g=T.RotWith(F,x.input,xd*D),c.push(g),m=T.RotWith(F,x.input,xd+xd*-D),l.push(m)}f=g,h=m,O&&(y=!0);continue}if(y=!1,x===i||x===o){const j=T.Per(I).mul(x.radius);c.push(T.Sub(w,j)),l.push(T.Add(w,j));continue}const L=T.Lrp(P,I,C).per().mul(x.radius);g=T.Sub(w,L),(_<=1||T.Dist2(f,g)>a)&&(c.push(g),f=g),m=T.Add(w,L),(_<=1||T.Dist2(h,m)>a)&&(l.push(m),h=m),d=I}return{left:c,right:l}}function lR(r,e={}){const{size:t=16,start:n={},end:i={},last:o=!1}=e,{cap:s=!0}=n,{cap:a=!0}=i;if(r.length===0||t<=0)return[];const c=r[0],l=r[r.length-1],d=l.runningLength,f=n.taper===!1?0:n.taper===!0?Math.max(t,d):n.taper,h=i.taper===!1?0:i.taper===!0?Math.max(t,d):i.taper,{left:g,right:m}=Kue(r,e),y=c.point,x=r.length>1?r[r.length-1].point:T.AddXY(c.point,1,1);if(r.length===1&&(!(f||h)||o)){const b=T.Add(y,T.Sub(y,x).uni().per().mul(-c.radius)),P=[];for(let C=1/13,k=C;k<=1;k+=C)P.push(T.RotWith(b,y,xd*2*k));return P}const _=[];if(!(f||h&&r.length===1))if(s)for(let b=1/8,P=b;P<=1;P+=b){const C=T.RotWith(m[0],y,xd*P);_.push(C)}else{const b=T.Sub(g[0],m[0]),P=T.Mul(b,.5),C=T.Mul(b,.51);_.push(T.Sub(y,P),T.Sub(y,C),T.Add(y,C),T.Add(y,P))}const w=[],I=l.vector.clone().per().neg();if(h||f&&r.length===1)w.push(x);else if(a){const b=T.Add(x,T.Mul(I,l.radius));for(let P=1/29,C=P;C<1;C+=P)w.push(T.RotWith(b,x,xd*3*C))}else w.push(T.Add(x,T.Mul(I,l.radius)),T.Add(x,T.Mul(I,l.radius*.99)),T.Sub(x,T.Mul(I,l.radius*.99)),T.Sub(x,T.Mul(I,l.radius)));return g.concat(w,m.reverse(),_)}const WLe=.025,KLe=.01;function xa(r,e={}){var x;const{streamline:t=.5,size:n=16,simulatePressure:i=!1}=e;if(r.length===0)return[];const o=.15+(1-t)*.85;let s=r.map(T.From),a=0;if(!i){let _=s[0];for(;_&&!(_.z>=WLe);)s.shift(),_=s[0]}if(!i){let _=s[s.length-1];for(;_&&!(_.z>=KLe);)s.pop(),_=s[s.length-1]}if(s.length===0)return[{point:T.From(r[0]),input:T.From(r[0]),pressure:i?.5:.15,vector:new T(1,1),distance:0,runningLength:0,radius:1}];let c=s[1];for(;c&&!(T.Dist2(c,s[0])>(n/3)**2);)s[0].z=Math.max(s[0].z,c.z),s.splice(1,1),c=s[1];const l=s.pop();for(c=s[s.length-1];c&&!(T.Dist2(c,l)>(n/3)**2);)s.pop(),c=s[s.length-1],a++;s.push(l);const d=e.last||!e.simulatePressure||s.length>1&&T.Dist2(s[s.length-1],s[s.length-2])<n**2||a>0;if(s.length===2&&e.simulatePressure){const _=s[1];s=s.slice(0,-1);for(let w=1;w<5;w++){const I=T.Lrp(s[0],_,w/4);I.z=(s[0].z+(_.z-s[0].z))*w/4,s.push(I)}}const f=[{point:s[0],input:s[0],pressure:i?.5:s[0].z,vector:new T(1,1),distance:0,runningLength:0,radius:1}];let h=0,g=f[0],m,y;d&&t>0&&s.push(s[s.length-1].clone());for(let _=1,w=s.length;_<w;_++)m=!o||e.last&&_===w-1?s[_].clone():s[_].clone().lrp(g.point,1-o),!g.point.equals(m)&&(y=T.Dist(m,g.point),h+=y,!(_<4&&h<n)&&(g={input:s[_],point:m,pressure:i?.5:s[_].z,vector:T.Sub(g.point,m).uni(),distance:y,runningLength:h,radius:1},f.push(g)));if((x=f[1])!=null&&x.vector&&(f[0].vector=f[1].vector.clone()),h<1){const _=Math.max(.5,...f.map(w=>w.pressure));f.forEach(w=>w.pressure=_)}return f}const{min:$c}=Math,FI=.275;function rS(r,e){const{size:t=16,thinning:n=.5,simulatePressure:i=!0,easing:o=x=>x,start:s={},end:a={}}=e,{easing:c=zn.easeOutQuad}=s,{easing:l=zn.easeOutCubic}=a,d=r[r.length-1].runningLength;let f,h=r[0].pressure,g;if(!i&&d<t){const x=r.reduce((_,w)=>Math.max(_,w.pressure),.5);return r.forEach(_=>{_.pressure=x,_.radius=t*o(.5-n*(.5-_.pressure))}),r}else{let x;for(let _=0,w=r.length;_<w&&(g=r[_],!(g.runningLength>t*5));_++){const I=$c(1,g.distance/t);if(i){const b=$c(1,1-I);x=$c(1,h+(b-h)*(I*FI))}else x=$c(1,h+(g.pressure-h)*.5);h=h+(x-h)*.5}for(let _=0;_<r.length;_++){if(g=r[_],n){let{pressure:w}=g;const I=$c(1,g.distance/t);if(i){const b=$c(1,1-I);w=$c(1,h+(b-h)*(I*FI))}else w=$c(1,h+(w-h)*(I*FI));g.radius=t*o(.5-n*(.5-w)),h=w}else g.radius=t/2;f===void 0&&(f=g.radius)}}const m=s.taper===!1?0:s.taper===!0?Math.max(t,d):s.taper,y=a.taper===!1?0:a.taper===!0?Math.max(t,d):a.taper;if(m||y)for(let x=0;x<r.length;x++){g=r[x];const{runningLength:_}=g,w=_<m?c(_/m):1,I=d-_<y?l((d-_)/y):1;g.radius=Math.max(.01,g.radius*Math.min(w,I))}return r}function GLe(r,e={}){return lR(rS(xa(r,e),e),e)}function UQ({scribble:r,zoom:e,color:t,opacity:n,className:i}){if(!r.points.length)return null;const o=GLe(r.points,{size:r.size/e,start:{taper:r.taper,easing:zn.linear},last:r.state==="stopping",simulatePressure:!1,streamline:.32});let s;if(o.length<4){const a=r.size/e/2,{x:c,y:l}=r.points[r.points.length-1];s=`M ${c-a},${l} a ${a},${a} 0 1,0 ${a*2},0 a ${a},${a} 0 1,0 ${-a*2},0`}else s=xT(o);return v.jsx("svg",{className:i&&bt("tl-overlays__item",i),children:v.jsx("path",{className:"tl-scribble",d:s,fill:t??`var(--color-${r.color})`,opacity:n??r.opacity})})}const VLe=({bounds:r,rotation:e})=>{const t=he();return ye("should display",()=>t.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_shape","select.pointing_selection","text.resizing"),[t])?v.jsx(rre,{bounds:r,rotation:e}):null};function YLe({size:r,width:e,height:t,hideAlternateHandles:n}){const i=fe(r/3),o=i/2;return v.jsxs("svg",{className:"tl-overlays__item",children:[v.jsx("polyline",{className:"tl-corner-crop-handle",points:`
330
- ${fe(0-o)},${fe(r)}
331
- ${fe(0-o)},${fe(0-o)}
332
- ${fe(r)},${fe(0-o)}`,strokeWidth:i,"data-testid":"selection.crop.top_left","aria-label":"top_left handle"}),v.jsx("line",{className:bt("tl-corner-crop-edge-handle",{"tl-hidden":n}),x1:fe(e/2-r),y1:fe(0-o),x2:fe(e/2+r),y2:fe(0-o),strokeWidth:i,"data-testid":"selection.crop.top","aria-label":"top handle"}),v.jsx("polyline",{className:bt("tl-corner-crop-handle",{"tl-hidden":n}),points:`
333
- ${fe(e-r)},${fe(0-o)}
334
- ${fe(e+o)},${fe(0-o)}
335
- ${fe(e+o)},${fe(r)}`,strokeWidth:i,"data-testid":"selection.crop.top_right","aria-label":"top_right handle"}),v.jsx("line",{className:bt("tl-corner-crop-edge-handle",{"tl-hidden":n}),x1:fe(e+o),y1:fe(t/2-r),x2:fe(e+o),y2:fe(t/2+r),strokeWidth:i,"data-testid":"selection.crop.right","aria-label":"right handle"}),v.jsx("polyline",{className:"tl-corner-crop-handle",points:`
336
- ${fe(e+o)},${fe(t-r)}
337
- ${fe(e+o)},${fe(t+o)}
338
- ${fe(e-r)},${fe(t+o)}`,strokeWidth:i,"data-testid":"selection.crop.bottom_right","aria-label":"bottom_right handle"}),v.jsx("line",{className:bt("tl-corner-crop-edge-handle",{"tl-hidden":n}),x1:fe(e/2-r),y1:fe(t+o),x2:fe(e/2+r),y2:fe(t+o),strokeWidth:i,"data-testid":"selection.crop.bottom","aria-label":"bottom handle"}),v.jsx("polyline",{className:bt("tl-corner-crop-handle",{"tl-hidden":n}),points:`
339
- ${fe(0+r)},${fe(t+o)}
340
- ${fe(0-o)},${fe(t+o)}
341
- ${fe(0-o)},${fe(t-r)}`,strokeWidth:i,"data-testid":"selection.crop.bottom_left","aria-label":"bottom_left handle"}),v.jsx("line",{className:bt("tl-corner-crop-edge-handle",{"tl-hidden":n}),x1:fe(0-o),y1:fe(t/2-r),x2:fe(0-o),y2:fe(t/2+r),strokeWidth:i,"data-testid":"selection.crop.left","aria-label":"left handle"})]})}const XLe=ii(function({bounds:e,rotation:t}){const n=he(),i=A.useRef(null),o=Wo(),s=oa("top"),a=oa("right"),c=oa("bottom"),l=oa("left"),d=oa("top_left"),f=oa("top_right"),h=oa("bottom_right"),g=oa("bottom_left"),m=n.getInstanceState().cursor.type==="default",y=n.getInstanceState().isCoarsePointer,x=n.getOnlySelectedShape(),_=x&&n.isShapeOrAncestorLocked(x),w=x?n.getShapeUtil(x).expandSelectionOutlinePx(x):0,I=w instanceof He?e.clone().expand(w).zeroFix():e.clone().expandBy(w).zeroFix();if(Fd(i,e==null?void 0:e.x,e==null?void 0:e.y,1,n.getSelectionRotation(),{x:I.x-e.x,y:I.y-e.y}),x&&n.isShapeHidden(x))return null;const b=n.getZoomLevel(),P=n.getInstanceState().isChangingStyle,C=I.width,k=I.height,O=8/b,L=C<O*2,j=k<O*2,F=C<O*4,$=k<O*4,D=C<O*5,N=k<O*5,B=y?1.75:1,W=6/b*B,G=(F?W/2:W)*(B*.75),z=($?W/2:W)*(B*.75),V=(x?!n.getShapeUtil(x).hideSelectionBoundsFg(x):!0)&&!P;let J=V&&n.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_canvas","select.pointing_selection","select.pointing_shape","select.crop.idle","select.crop.pointing_crop","select.crop.pointing_crop_handle","select.pointing_resize_handle")||V&&n.isIn("select.resizing")&&x&&n.isShapeOfType(x,"text");x&&J&&Pr.isFirefox&&n.isShapeOfType(x,"embed")&&(J=!1);const K=n.isInAny("select.crop.idle","select.crop.pointing_crop","select.crop.pointing_crop_handle")&&!P&&!o,Z=n.isInAny("select.idle","select.pointing_selection","select.pointing_shape","select.crop.idle")&&!P&&!o,ee=!y&&!(L||j)&&(Z||K)&&(x?!n.getShapeUtil(x).hideRotateHandle(x):!0)&&!_,re=y&&(!F||!$)&&(Z||K)&&(x?!n.getShapeUtil(x).hideRotateHandle(x):!0)&&!_,te=Z&&(x?n.getShapeUtil(x).canResize(x)&&!n.getShapeUtil(x).hideResizeHandles(x):!0)&&!K&&!_,le=L||j,ge=L&&j,se=D||N,ce=te||K,_e=!ee,Le=!Z||!re,Ge=!Z||!ce,qe=!Z||!ce||le,mt=!Z||!ce||le,St=!Z||!ce||ge&&!K;let et=!0,ct=!0;if(K)et=se,ct=se;else if(te){et=le||ge||y;const ut=y&&x&&x.type==="text";ct=et&&!ut}const At=Math.min(24/b,k-z*3),_t=Z&&y&&x&&n.isShapeOfType(x,"text")&&At*b>=4;return v.jsx("svg",{className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:v.jsxs("g",{ref:i,children:[J&&v.jsx("rect",{className:"tl-selection__fg__outline",width:fe(C),height:fe(k)}),v.jsx(Kg,{"data-testid":"selection.rotate.top-left",cx:0,cy:0,targetSize:W,corner:"top_left_rotate",cursor:m?Po("nwse-rotate",t):void 0,isHidden:_e}),v.jsx(Kg,{"data-testid":"selection.rotate.top-right",cx:C+W*3,cy:0,targetSize:W,corner:"top_right_rotate",cursor:m?Po("nesw-rotate",t):void 0,isHidden:_e}),v.jsx(Kg,{"data-testid":"selection.rotate.bottom-left",cx:0,cy:k+W*3,targetSize:W,corner:"bottom_left_rotate",cursor:m?Po("swne-rotate",t):void 0,isHidden:_e}),v.jsx(Kg,{"data-testid":"selection.rotate.bottom-right",cx:C+W*3,cy:k+W*3,targetSize:W,corner:"bottom_right_rotate",cursor:m?Po("senw-rotate",t):void 0,isHidden:_e}),v.jsx(QLe,{"data-testid":"selection.rotate.mobile",cx:F?-W*1.5:C/2,cy:F?k/2:-W*1.5,size:O,isHidden:Le}),v.jsx("rect",{className:bt("tl-transparent",{"tl-hidden":et}),"data-testid":"selection.resize.top","aria-label":"top target",pointerEvents:"all",x:0,y:fe(0-($?z*2:z)),width:fe(C),height:fe(Math.max(1,z*2)),style:m?{cursor:Po("ns-resize",t)}:void 0,...s}),v.jsx("rect",{className:bt("tl-transparent",{"tl-hidden":ct}),"data-testid":"selection.resize.right","aria-label":"right target",pointerEvents:"all",x:fe(C-(F?0:G)),y:0,height:fe(k),width:fe(Math.max(1,G*2)),style:m?{cursor:Po("ew-resize",t)}:void 0,...a}),v.jsx("rect",{className:bt("tl-transparent",{"tl-hidden":et}),"data-testid":"selection.resize.bottom","aria-label":"bottom target",pointerEvents:"all",x:0,y:fe(k-($?0:z)),width:fe(C),height:fe(Math.max(1,z*2)),style:m?{cursor:Po("ns-resize",t)}:void 0,...c}),v.jsx("rect",{className:bt("tl-transparent",{"tl-hidden":ct}),"data-testid":"selection.resize.left","aria-label":"left target",pointerEvents:"all",x:fe(0-(F?G*2:G)),y:0,height:fe(k),width:fe(Math.max(1,G*2)),style:m?{cursor:Po("ew-resize",t)}:void 0,...l}),v.jsx("rect",{className:bt("tl-transparent",{"tl-hidden":Ge}),"data-testid":"selection.target.top-left","aria-label":"top-left target",pointerEvents:"all",x:fe(0-(F?G*2:G*1.5)),y:fe(0-($?z*2:z*1.5)),width:fe(G*3),height:fe(z*3),style:m?{cursor:Po("nwse-resize",t)}:void 0,...d}),v.jsx("rect",{className:bt("tl-transparent",{"tl-hidden":qe}),"data-testid":"selection.target.top-right","aria-label":"top-right target",pointerEvents:"all",x:fe(C-(F?0:G*1.5)),y:fe(0-($?z*2:z*1.5)),width:fe(G*3),height:fe(z*3),style:m?{cursor:Po("nesw-resize",t)}:void 0,...f}),v.jsx("rect",{className:bt("tl-transparent",{"tl-hidden":St}),"data-testid":"selection.target.bottom-right","aria-label":"bottom-right target",pointerEvents:"all",x:fe(C-(F?G:G*1.5)),y:fe(k-($?z:z*1.5)),width:fe(G*3),height:fe(z*3),style:m?{cursor:Po("nwse-resize",t)}:void 0,...h}),v.jsx("rect",{className:bt("tl-transparent",{"tl-hidden":mt}),"data-testid":"selection.target.bottom-left","aria-label":"bottom-left target",pointerEvents:"all",x:fe(0-(F?G*3:G*1.5)),y:fe(k-($?0:z*1.5)),width:fe(G*3),height:fe(z*3),style:m?{cursor:Po("nesw-resize",t)}:void 0,...g}),te&&v.jsxs(v.Fragment,{children:[v.jsx("rect",{"data-testid":"selection.resize.top-left",className:bt("tl-corner-handle",{"tl-hidden":Ge}),"aria-label":"top_left handle",x:fe(0-O/2),y:fe(0-O/2),width:fe(O),height:fe(O)}),v.jsx("rect",{"data-testid":"selection.resize.top-right",className:bt("tl-corner-handle",{"tl-hidden":qe}),"aria-label":"top_right handle",x:fe(C-O/2),y:fe(0-O/2),width:fe(O),height:fe(O)}),v.jsx("rect",{"data-testid":"selection.resize.bottom-right",className:bt("tl-corner-handle",{"tl-hidden":St}),"aria-label":"bottom_right handle",x:fe(C-O/2),y:fe(k-O/2),width:fe(O),height:fe(O)}),v.jsx("rect",{"data-testid":"selection.resize.bottom-left",className:bt("tl-corner-handle",{"tl-hidden":mt}),"aria-label":"bottom_left handle",x:fe(0-O/2),y:fe(k-O/2),width:fe(O),height:fe(O)})]}),_t&&v.jsxs(v.Fragment,{children:[v.jsx("rect",{"data-testid":"selection.text-resize.left.handle",className:"tl-text-handle","aria-label":"bottom_left handle",x:fe(0-O/4),y:fe(k/2-At/2),rx:O/4,width:fe(O/2),height:fe(At)}),v.jsx("rect",{"data-testid":"selection.text-resize.right.handle",className:"tl-text-handle","aria-label":"bottom_left handle",rx:O/4,x:fe(C-O/4),y:fe(k/2-At/2),width:fe(O/2),height:fe(At)})]}),K&&v.jsx(YLe,{size:O,width:C,height:k,hideAlternateHandles:se})]})})}),Kg=function({cx:e,cy:t,targetSize:n,corner:i,cursor:o,isHidden:s,"data-testid":a}){const c=oa(i);return v.jsx("rect",{className:bt("tl-transparent","tl-rotate-corner",{"tl-hidden":s}),"data-testid":a,"aria-label":`${i} target`,pointerEvents:"all",x:fe(e-n*3),y:fe(t-n*3),width:fe(Math.max(1,n*3)),height:fe(Math.max(1,n*3)),cursor:o,...c})},ZLe=Math.sqrt(Math.PI),QLe=function({cx:e,cy:t,size:n,isHidden:i,"data-testid":o}){const s=oa("mobile_rotate"),a=he(),c=ye("zoom level",()=>a.getZoomLevel(),[a]),l=Math.max(14*(1/c),20/Math.max(1,c));return v.jsxs("g",{children:[v.jsx("circle",{"data-testid":o,pointerEvents:"all",className:bt("tl-transparent","tl-mobile-rotate__bg",{"tl-hidden":i}),cx:e,cy:t,r:l,...s}),v.jsx("circle",{className:bt("tl-mobile-rotate__fg",{"tl-hidden":i}),cx:e,cy:t,r:n/ZLe})]})};function JLe(){const r=he();return ye("is in a valid select state",()=>r.isInAny("select.idle","select.brushing","select.scribble_brushing","select.editing_shape","select.pointing_shape","select.pointing_selection","select.pointing_handle"),[r])?v.jsx(nre,{}):null}function oC(r,e,t){const{arrowheadStart:n,arrowheadEnd:i}=e.props,o=fd(r,e,t),s=o.start.clone(),a=o.end.clone(),c=T.Med(s,a);if(T.Equals(s,a))return{bindings:t,isStraight:!0,start:{handle:s,point:s,arrowhead:e.props.arrowheadStart},end:{handle:a,point:a,arrowhead:e.props.arrowheadEnd},middle:c,isValid:!1,length:0};const l=T.Sub(a,s).uni(),d=pm(r,e,"start"),f=pm(r,e,"end"),h=r.getShapePageTransform(e);zQ(a,o.start,h,f),zQ(s,o.end,h,d);let g=0,m=0,y=0,x=0,_=dh*e.props.scale;const w=d&&f&&d.shape===f.shape,I=d&&f?uR(r,d.shape.id,f.shape.id):"safe";I==="safe"&&d&&f&&!w&&!d.isExact&&!f.isExact&&(f.didIntersect&&!d.didIntersect?d.isClosed&&s.setTo(a.clone().add(l.clone().mul(dh*e.props.scale))):f.didIntersect||f.isClosed&&a.setTo(s.clone().sub(l.clone().mul(dh*e.props.scale))));const b=T.Sub(a,s),P=T.Len(b)?b.uni():T.From(b),C=!T.Equals(P,l);w||(I!=="start-contains-end"&&d&&n!=="none"&&!d.isExact&&(y=da[e.props.size]/2+("size"in d.shape.props?da[d.shape.props.size]/2:0),g=(gm+y)*e.props.scale,_+=y*e.props.scale),I!=="end-contains-start"&&f&&i!=="none"&&!f.isExact&&(x=da[e.props.size]/2+("size"in f.shape.props?da[f.shape.props.size]/2:0),m=(gm+x)*e.props.scale,_+=x*e.props.scale));const k=s.clone().add(P.clone().mul(g*(C?-1:1))),O=a.clone().sub(P.clone().mul(m*(C?-1:1)));T.DistMin(k,O,_)&&(g!==0&&m!==0?(g*=-1.5,m*=-1.5):g!==0?g*=-1:m!==0&&(m*=-1)),s.add(P.clone().mul(g*(C?-1:1))),a.sub(P.clone().mul(m*(C?-1:1))),C?(d&&f&&a.setTo(T.Add(s,P.clone().mul(-10*e.props.scale))),c.setTo(T.Med(o.start,o.end))):c.setTo(T.Med(s,a));const L=T.Dist(s,a);return{bindings:t,isStraight:!0,start:{handle:o.start,point:s,arrowhead:e.props.arrowheadStart},end:{handle:o.end,point:a,arrowhead:e.props.arrowheadEnd},middle:c,isValid:L>0,length:L}}function zQ(r,e,t,n){if(n===void 0||n.isExact)return;const i=Ke.applyToPoint(t,e),o=Ke.applyToPoint(t,r),s=Ke.applyToPoint(Ke.Inverse(n.transform),i),a=Ke.applyToPoint(Ke.Inverse(n.transform),o),c=n.isClosed,d=(c?oA:lTe)(s,a,n.outline);let f;if(d!==null&&(f=d.sort((m,y)=>T.Dist2(m,s)-T.Dist2(y,s))[0]??(c?void 0:a)),f===void 0)return;const h=Ke.applyToPoint(n.transform,f),g=Ke.applyToPoint(Ke.Inverse(t),h);r.setTo(g),n.didIntersect=!0}function eFe(r,e,t){const{arrowheadEnd:n,arrowheadStart:i}=e.props,o=e.props.bend;if(Math.abs(o)>Math.abs(e.props.bend*(oFe*e.props.scale)))return oC(r,e,t);const s=fd(r,e,t),a=T.Med(s.start,s.end),c=T.Sub(s.end,s.start),l=T.Len(c)?c.uni():T.From(c),d=T.Add(a,l.per().mul(-o)),f=pm(r,e,"start"),h=pm(r,e,"end"),g=s.start.clone(),m=s.end.clone(),y=d.clone();if(T.Equals(g,m))return{bindings:t,isStraight:!0,start:{handle:g,point:g,arrowhead:e.props.arrowheadStart},end:{handle:m,point:m,arrowhead:e.props.arrowheadEnd},middle:y,isValid:!1,length:0};const x=e.props.bend<0,_=x?zh:Fee,w=HQ(g,m,y),I=T.Angle(w.center,g),b=T.Angle(w.center,m),P=_(I,b);if(w.length===0||w.size===0||!jj(w.length)||!jj(w.size))return oC(r,e,t);const C=g.clone(),k=m.clone(),O=y.clone(),L=r.getShapePageTransform(e);let j=0,F=0,$=dh*e.props.scale;if(f&&!f.isExact){const J=Ke.applyToPoint(L,C),K=Ke.applyToPoint(L,w.center),Z=Ke.applyToPoint(L,k),ee=Ke.Inverse(f.transform),re=Ke.applyToPoint(ee,J),te=Ke.applyToPoint(ee,K),le=Ke.applyToPoint(ee,Z),{isClosed:ge}=f,se=ge?jP:zZ;let ce,_e=se(te,w.radius,f.outline);if(_e){const Le=te.angle(re),Ge=te.angle(le),qe=_(Le,Ge);_e=_e.filter(St=>_(Le,te.angle(St))<=qe);const mt=qe*.25;_e.sort(ge?(St,et)=>Math.abs(_(Le,te.angle(St))-mt)<Math.abs(_(Le,te.angle(et))-mt)?-1:1:(St,et)=>_(Le,te.angle(St))<_(Le,te.angle(et))?-1:1),ce=_e[0]??(ge?void 0:re)}else ce=ge?void 0:re;if(ce&&(C.setTo(r.getPointInShapeSpace(e,Ke.applyToPoint(f.transform,ce))),f.didIntersect=!0,i!=="none")){const Le=da[e.props.size]/2+("size"in f.shape.props?da[f.shape.props.size]/2:0);j=(gm+Le)*e.props.scale,$+=Le*e.props.scale}}if(h&&!h.isExact){const J=Ke.applyToPoint(L,C),K=Ke.applyToPoint(L,k),Z=Ke.applyToPoint(L,w.center),ee=Ke.Inverse(h.transform),re=Ke.applyToPoint(ee,J),te=Ke.applyToPoint(ee,Z),le=Ke.applyToPoint(ee,K),ge=h.isClosed,se=ge?jP:zZ;let ce,_e=se(te,w.radius,h.outline);if(_e){const Le=te.angle(re),Ge=te.angle(le),qe=_(Le,Ge),mt=qe*.75;_e=_e.filter(St=>_(Le,te.angle(St))<=qe),_e.sort(ge?(St,et)=>Math.abs(_(Le,te.angle(St))-mt)<Math.abs(_(Le,te.angle(et))-mt)?-1:1:(St,et)=>_(Le,te.angle(St))<_(Le,te.angle(et))?-1:1),_e[0]?ce=_e[0]:ce=ge?void 0:le}else ce=ge?void 0:le;if(ce&&(k.setTo(r.getPointInShapeSpace(e,Ke.applyToPoint(h.transform,ce))),h.didIntersect=!0,n!=="none")){const Le=da[e.props.size]/2+("size"in h.shape.props?da[h.shape.props.size]/2:0);F=(gm+Le)*e.props.scale,$+=Le*e.props.scale}}let D=T.Angle(w.center,C),N=T.Angle(w.center,k),B=_(D,N),W=B*w.radius;const G=C.clone(),z=k.clone();if(j!==0&&G.setTo(w.center).add(T.FromAngle(D+B*(j/W*(x?1:-1))).mul(w.radius)),F!==0&&z.setTo(w.center).add(T.FromAngle(N+B*(F/W*(x?-1:1))).mul(w.radius)),T.DistMin(G,z,$)&&(j!==0&&F!==0?(j*=-1.5,F*=-1.5):j!==0?j*=-2:F!==0&&(F*=-2)),j!==0&&C.setTo(w.center).add(T.FromAngle(D+B*(j/W*(x?1:-1))).mul(w.radius)),F!==0&&k.setTo(w.center).add(T.FromAngle(N+B*(F/W*(x?-1:1))).mul(w.radius)),f&&h&&!f.isExact&&!h.isExact){D=T.Angle(w.center,C),N=T.Angle(w.center,k),B=_(D,N),W=B*w.radius;const J=uR(r,f.shape.id,h.shape.id);J==="double-bound"&&W<30?(C.setTo(g),k.setTo(m),O.setTo(y)):J==="safe"&&(f&&!f.didIntersect&&C.setTo(g),(h&&!h.didIntersect||_(I,D)>_(I,N))&&k.setTo(w.center).add(T.FromAngle(D+B*(Math.min(.9,dh*e.props.scale/W)*(x?1:-1))).mul(w.radius)))}tFe(w.center,w.radius,C,k,O,P,x),C.equals(k)&&(C.setTo(O.clone().addXY(1,1)),k.setTo(O.clone().subXY(1,1))),g.setTo(C),m.setTo(k),y.setTo(O);const V=HQ(g,m,y);return{bindings:t,isStraight:!1,start:{point:g,handle:s.start,arrowhead:e.props.arrowheadStart},end:{point:m,handle:s.end,arrowhead:e.props.arrowheadEnd},middle:y,handleArc:w,bodyArc:V,isValid:V.length!==0&&isFinite(V.center.x)&&isFinite(V.center.y)}}function HQ(r,e,t){const n=JC(r,e,t)??T.Med(r,e),i=T.Dist(n,r),o=+T.Clockwise(r,t,e),s=((r.y-e.y)**2+(r.x-e.x)**2)**.5,a=((e.y-t.y)**2+(e.x-t.x)**2)**.5,c=((t.y-r.y)**2+(t.x-r.x)**2)**.5,l=Math.acos((a*a+c*c-s*s)/(2*a*c))*2,d=+(hr>l),f=(Cr-l)*(o?1:-1),h=f*i;return{center:n,radius:i,size:f,length:h,largeArcFlag:d,sweepFlag:o}}function tFe(r,e,t,n,i,o,s){const a=T.Angle(r,t),c=T.Angle(r,n);let l=zh(a,c);if(s||(l=Cr-l),i.setTo(r).add(T.FromAngle(a+l*(.5*(s?1:-1))).mul(e)),l>o){i.rotWith(r,hr);const d=n.clone();n.setTo(t),t.setTo(d)}}const rFe=8;function nFe(r){return Math.abs(r.props.bend)<rFe*r.props.scale}function pm(r,e,t){const n=r.getBindingsFromShape(e,"arrow").find(c=>c.props.terminal===t);if(!n)return;const i=r.getShape(n.toId);if(!i)return;const o=r.getShapePageTransform(i),s=r.getShapeGeometry(i,t==="start"?{context:"@tldraw/arrow-start"}:void 0),a=s instanceof cs?s.children[0].vertices:s.vertices;return{shape:i,transform:o,isClosed:s.isClosed,isExact:n.props.isExact,didIntersect:!1,outline:a}}function WQ(r,e,t,n){const i=r.getShape(t.toId);if(i){const{point:o,size:s}=r.getShapeGeometry(i).bounds,a=T.Add(o,T.MulV(t.props.isPrecise||n?t.props.normalizedAnchor:{x:.5,y:.5},s)),c=Ke.applyToPoint(r.getShapePageTransform(i),a);return Ke.applyToPoint(Ke.Inverse(e),c)}else return new T(0,0)}function fo(r,e){const t=r.getBindingsFromShape(e,"arrow");return{start:t.find(n=>n.props.terminal==="start"),end:t.find(n=>n.props.terminal==="end")}}const iFe=bme("arrow info",(r,e)=>{const t=fo(r,e);return nFe(e)?oC(r,e,t):eFe(r,e,t)});function ua(r,e){const t=typeof e=="string"?e:e.id;return iFe.get(r,t)}function fd(r,e,t){var a,c;const n=r.getShapePageTransform(e),i=uR(r,(a=t.start)==null?void 0:a.toId,(c=t.end)==null?void 0:c.toId),o=t.start?WQ(r,n,t.start,i==="double-bound"||i==="start-contains-end"):T.From(e.props.start),s=t.end?WQ(r,n,t.end,i==="double-bound"||i==="end-contains-start"):T.From(e.props.end);return{start:o,end:s}}function Hf(r,e,t,n){const i=typeof e=="string"?e:e.id,o=typeof t=="string"?t:t.id,s=r.getBindingsFromShape(i,"arrow").filter(c=>c.props.terminal===n.terminal);s.length>1&&r.deleteBindings(s.slice(1));const a=s[0];a?r.updateBinding({...a,toId:o,props:n}):r.createBinding({type:"arrow",fromId:i,toId:o,props:n})}function pv(r,e,t){const n=r.getBindingsFromShape(e,"arrow").filter(i=>i.props.terminal===t);r.deleteBindings(n)}const dh=10,gm=10,oFe=10,da={s:2,m:3.5,l:5,xl:10};function uR(r,e,t){if(!e||!t)return"safe";if(e===t)return"double-bound";const n=r.getShapePageBounds(e),i=r.getShapePageBounds(t);if(n&&i){if(n.contains(i))return"start-contains-end";if(i.contains(n))return"end-contains-start"}return"safe"}class gv extends uv{getDefaultProps(){return{isPrecise:!1,isExact:!1,normalizedAnchor:{x:.5,y:.5}}}onAfterCreate({binding:e}){const t=this.editor.getShape(e.fromId);t&&NI(this.editor,t)}onAfterChange({bindingAfter:e}){const t=this.editor.getShape(e.fromId);t&&NI(this.editor,t)}onAfterChangeFromShape({shapeAfter:e}){NI(this.editor,e)}onAfterChangeToShape({binding:e}){Gue(this.editor,e.fromId)}onBeforeIsolateFromShape({binding:e}){const t=this.editor.getShape(e.fromId);t&&vm({editor:this.editor,arrow:t,terminal:e.props.terminal})}}q(gv,"type","arrow"),q(gv,"props",ote),q(gv,"migrations",ste);function Gue(r,e){var x;const t=r.getShape(e);if(!t)return;const n=fo(r,t),{start:i,end:o}=n,s=i?r.getShape(i.toId):void 0,a=o?r.getShape(o.toId):void 0,c=r.getAncestorPageId(t);if(!c)return;let l;if(s&&a)l=r.findCommonAncestor([s,a])??c;else if(s||a){const _=(x=s||a)==null?void 0:x.parentId;_&&_===t.parentId?l=t.parentId:l=c}else return;l&&l!==t.parentId&&r.reparentShapes([e],l);const d=r.getShape(e);if(!d)throw Error("no reparented arrow");const f=r.getShapeNearestSibling(d,s),h=r.getShapeNearestSibling(d,a);let g;if(f&&h)g=f.index>h.index?f:h;else if(f&&!h)g=f;else if(h&&!f)g=h;else return;let m;const y=r.getSortedChildIdsForParent(g.parentId).map(_=>r.getShape(_)).filter(_=>_.index>g.index);if(y.length){const _=y.find(w=>w.type!=="arrow");if(d.index>g.index&&(!_||d.index<_.index))return;m=mh(g.index,y[0].index)}else m=ca(g.index);m!==d.index&&r.updateShapes([{id:e,type:"arrow",index:m}])}function NI(r,e){const t=fo(r,e);for(const n of["start","end"]){const i=t[n];if(!i)continue;const o=r.getShape(i.toId),s=r.getAncestorPageId(e)===r.getAncestorPageId(o);(!o||!s)&&vm({editor:r,arrow:e,terminal:n,unbind:!0})}Gue(r,e.id)}function vm({editor:r,arrow:e,terminal:t,unbind:n=!1,useHandle:i=!1}){const o=ua(r,e);if(!o)throw new Error("expected arrow info");const s=i?o.start.handle:o.start.point,a=i?o.end.handle:o.end.point,c=t==="start"?s:a,l={id:e.id,type:"arrow",props:{[t]:{x:c.x,y:c.y},bend:e.props.bend}};if(!o.isStraight){const d=t==="start"?s:o.start.handle,f=t==="end"?a:o.end.handle,h=T.Med(d,f),g=T.Sub(d,f).per().uni().mul(o.handleArc.radius*2*Math.sign(e.props.bend)),m=ip(o.handleArc.center,T.Add(h,g),o.handleArc.center,o.handleArc.radius);Jt((m==null?void 0:m.length)===1);const y=T.Dist(h,m[0])*Math.sign(e.props.bend);Yc(y,l.props.bend)||(l.props.bend=y)}r.updateShape(l),n&&pv(r,e,t)}const Vue=[gv],Ii={lineHeight:1.35,fontWeight:"normal",fontVariant:"normal",fontStyle:"normal",padding:"0px"},Ei={s:2,m:3.5,l:5,xl:10},Ed={s:18,m:24,l:36,xl:44},ic={s:18,m:22,l:26,xl:32},sFe={s:18,m:20,l:24,xl:28},ac={draw:"var(--tl-font-draw)",sans:"var(--tl-font-sans)",serif:"var(--tl-font-serif)",mono:"var(--tl-font-mono)"},aFe=20,dR=4.25,ts=16;function cFe(r,e){const t=r.w/e.w,n=r.h/e.h;return t<=1&&n<=1?r:t>n?{w:r.w/t,h:r.h/t}:{w:r.w/n,h:r.h/n}}async function lFe(r,e,t){var _,w,I;const{elements:n,files:i}=e,o={shapes:[],bindings:[],rootShapeIds:[],assets:[],schema:r.store.schema.serialize()},s=new Map,a=new Map,c=r.getCurrentPageId(),l=new Map,d=[],f=new Set;n.forEach(b=>{if(l.set(b.id,Tr()),b.boundElements!==null)for(const P of b.boundElements)P.type==="text"&&f.add(P.id)});let h=nee;for(const b of n){if(f.has(b.id))continue;const P=l.get(b.id),C={id:P,typeName:"shape",parentId:c,index:h,x:b.x,y:b.y,rotation:0,isLocked:b.locked,opacity:uFe(b.opacity),meta:{}};switch(b.angle!==0&&a.set(P,b.angle),b.groupIds&&b.groupIds.length>0?s.has(b.groupIds[0])?(_=s.get(b.groupIds[0]))==null||_.push(P):s.set(b.groupIds[0],[P]):d.push(P),b.type){case"rectangle":case"ellipse":case"diamond":{let k="",O="middle";if(b.boundElements!==null){for(const j of b.boundElements)if(j.type==="text"){const F=n.find($=>$.id===j.id);F&&(k=F.text,O=mFe[F.textAlign])}}const L=b.backgroundColor==="transparent"?b.strokeColor:b.backgroundColor;o.shapes.push({...C,type:"geo",props:{geo:b.type,url:b.link??"",w:b.width,h:b.height,size:Gg[b.strokeWidth]??"draw",color:Wf[L]??"black",text:k,align:O,dash:Vg(b),fill:xFe(b)}});break}case"freedraw":{o.shapes.push({...C,type:"draw",props:{dash:Vg(b),size:Gg[b.strokeWidth],color:Wf[b.strokeColor]??"black",segments:[{type:"free",points:b.points.map(([k,O,L=.5])=>({x:k,y:O,z:L}))}]}});break}case"line":{if(b.points.slice().length<2)break;const O=yh(b.points.length);o.shapes.push({...C,type:"line",props:{dash:Vg(b),size:Gg[b.strokeWidth],color:Wf[b.strokeColor]??"black",spline:b.roundness?"cubic":"line",points:{...Object.fromEntries(b.points.map(([L,j],F)=>{const $=O[F];return[$,{id:$,index:$,x:L,y:j}]}))}}});break}case"arrow":{let k="";if(b.boundElements!==null){for(const $ of b.boundElements)if($.type==="text"){const D=n.find(N=>N.id===$.id);D&&(k=D.text)}}const O=b.points[0],L=b.points[b.points.length-1],j=l.get((w=b.startBinding)==null?void 0:w.elementId),F=l.get((I=b.endBinding)==null?void 0:I.elementId);o.shapes.push({...C,type:"arrow",props:{text:k,bend:SFe(b,O,L),dash:Vg(b),size:Gg[b.strokeWidth]??"m",color:Wf[b.strokeColor]??"black",start:{x:O[0],y:O[1]},end:{x:L[0],y:L[1]},arrowheadEnd:KQ[b.endArrowhead]??"none",arrowheadStart:KQ[b.startArrowhead]??"none"}}),j&&o.bindings.push({id:Wl(),typeName:"binding",type:"arrow",fromId:P,toId:j,props:{terminal:"start",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}}),F&&o.bindings.push({id:Wl(),typeName:"binding",type:"arrow",fromId:P,toId:F,props:{terminal:"end",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}});break}case"text":{const{size:k,scale:O}=fFe(b.fontSize);o.shapes.push({...C,type:"text",props:{size:k,scale:O,font:hFe[b.fontFamily]??"draw",color:Wf[b.strokeColor]??"black",text:b.text,textAlign:yFe[b.textAlign]}});break}case"image":{const k=i[b.fileId];if(!k)break;const O=Qc.createId();o.assets.push({id:O,typeName:"asset",type:"image",props:{w:b.width,h:b.height,fileSize:k.size,name:b.id??"Untitled",isAnimated:!1,mimeType:k.mimeType,src:k.dataURL},meta:{}}),o.shapes.push({...C,type:"image",props:{w:b.width,h:b.height,assetId:O}})}}h=ca(h)}const g=t??(r.inputs.shiftKey?r.inputs.currentPagePoint:void 0);r.putContentOntoCurrentPage(o,{point:g,select:!1,preserveIds:!0});for(const b of s.values())if(b.length>1){r.groupShapes(b);const P=r.getShape(b[0]);P!=null&&P.parentId&&co(P.parentId)&&d.push(P.parentId)}for(const[b,P]of a)r.select(b),r.rotateShapesBy([b],P);const m=Gt(d.map(b=>r.getShape(b))),y=He.Common(m.map(b=>r.getShapePageBounds(b))),x=r.getViewportPageBounds().center;r.updateShapes(m.map(b=>{const P={x:(b.x??0)-(y.x+y.w/2),y:(b.y??0)-(y.y+y.h/2)};return{id:b.id,type:b.type,x:x.x+P.x,y:x.y+P.y}})),r.setSelectedShapes(d)}const uFe=r=>{const e=r/100;return e<.2?.1:e<.4?.25:e<.6?.5:e<.8?.75:1},Gg={1:"s",2:"m",3:"l",4:"xl"},dFe={16:"s",20:"m",28:"l",36:"xl"};function fFe(r){const e=dFe[r];return e?{size:e,scale:1}:r<16?{size:"s",scale:r/16}:r>36?{size:"xl",scale:r/36}:{size:"m",scale:1}}const hFe={1:"draw",2:"sans",3:"mono"},pFe={gray:["#f8f9fa","#e9ecef","#ced4da","#868e96","#343a40"],red:["#fff5f5","#ffc9c9","#ff8787","#fa5252","#e03131"],pink:["#fff0f6","#fcc2d7","#f783ac","#e64980","#c2255c"],grape:["#f8f0fc","#eebefa","#da77f2","#be4bdb","#9c36b5"],violet:["#f3f0ff","#d0bfff","#9775fa","#7950f2","#6741d9"],indigo:["#edf2ff","#bac8ff","#748ffc","#4c6ef5","#3b5bdb"],blue:["#e7f5ff","#a5d8ff","#4dabf7","#228be6","#1971c2"],cyan:["#e3fafc","#99e9f2","#3bc9db","#15aabf","#0c8599"],teal:["#e6fcf5","#96f2d7","#38d9a9","#12b886","#099268"],green:["#ebfbee","#b2f2bb","#69db7c","#40c057","#2f9e44"],lime:["#f4fce3","#d8f5a2","#a9e34b","#82c91e","#66a80f"],yellow:["#fff9db","#ffec99","#ffd43b","#fab005","#f08c00"],orange:["#fff4e6","#ffd8a8","#ffa94d","#fd7e14","#e8590c"]};function na(r,e,t){const n=[0,1,2,3,4].map(i=>pFe[r][i]);return Object.fromEntries(n.map((i,o)=>[i,o<3?e:t]))}const Wf={...na("gray","grey","black"),...na("red","light-red","red"),...na("pink","light-red","red"),...na("grape","light-violet","violet"),...na("blue","light-blue","blue"),...na("cyan","light-blue","blue"),...na("teal","light-green","green"),...na("green","light-green","green"),...na("yellow","yellow","orange"),...na("orange","yellow","orange"),"#ffffff":"white","#000000":"black"},gFe={solid:"draw",dashed:"dashed",dotted:"dotted"},vFe={"cross-hatch":"pattern",hachure:"pattern",solid:"solid"},mFe={left:"start",center:"middle",right:"end"},yFe={left:"start",center:"middle",right:"end"},KQ={arrow:"arrow",dot:"dot",triangle:"triangle",bar:"pipe"};function SFe(r,e,t){let n=0;if(r.points.length>2){const i=new T(e[0],e[1]),o=new T(t[0],t[1]),s=new T(r.points[1][0],r.points[1][1]),a=T.Sub(o,i),c=T.Per(a),l=T.Med(o,i),d=T.Sub(l,c),f=T.Add(l,c),h=T.NearestPointOnLineSegment(d,f,s,!1);n=T.Dist(h,l),T.Clockwise(h,o,l)&&(n*=-1)}return n}const Vg=r=>{let e=gFe[r.strokeStyle]??"draw";return e==="draw"&&r.roughness===0&&(e="solid"),e},xFe=r=>r.backgroundColor==="transparent"?"none":vFe[r.fillStyle]??"solid";/*!
342
- * MIT License
343
- * Adapted (mostly copied) the work of https://github.com/fregante/text-field-edit
344
- * Copyright (c) Federico Brigante <opensource@bfred.it> (bfred.it)
345
- */const hd=" ",$i=class $i{static insertTextFirefox(e,t){e.setRangeText(t,e.selectionStart||0,e.selectionEnd||0,"end"),e.dispatchEvent(new InputEvent("input",{data:t,inputType:"insertText",isComposing:!1}))}static insert(e,t){const n=e.ownerDocument,i=n.activeElement;i!==e&&e.focus(),n.execCommand("insertText",!1,t)||$i.insertTextFirefox(e,t),i===n.body?e.blur():i instanceof HTMLElement&&i!==e&&i.focus()}static set(e,t){e.select(),$i.insert(e,t)}static getSelection(e){const{selectionStart:t,selectionEnd:n}=e;return e.value.slice(t||void 0,n||void 0)}static wrapSelection(e,t,n){const{selectionStart:i,selectionEnd:o}=e,s=$i.getSelection(e);$i.insert(e,t+s+(n??t)),e.selectionStart=(i||0)+t.length,e.selectionEnd=(o||0)+t.length}static replace(e,t,n){let i=0;e.value.replace(t,(...o)=>{const s=i+o[o.length-2],a=o[0].length;e.selectionStart=s,e.selectionEnd=s+a;const c=typeof n=="string"?n:n(...o);return $i.insert(e,c),e.selectionStart=s,i+=c.length-a,c})}static findLineEnd(e,t){const n=e.lastIndexOf(`
346
- `,t-1)+1;return e.charAt(n)!==" "?t:n+1}static indent(e){var a;const{selectionStart:t,selectionEnd:n,value:i}=e,o=i.slice(t,n),s=(a=/\n/g.exec(o))==null?void 0:a.length;if(s&&s>0){const c=i.lastIndexOf(`
347
- `,t-1)+1,l=e.value.slice(c,n-1),d=l.replace(/^|\n/g,`$&${hd}`),f=d.length-l.length;e.setSelectionRange(c,n-1),$i.insert(e,d),e.setSelectionRange(t+1,n+f)}else $i.insert(e,hd)}static unindent(e){const{selectionStart:t,selectionEnd:n,value:i}=e,o=i.lastIndexOf(`
348
- `,t-1)+1,s=$i.findLineEnd(i,n),a=e.value.slice(o,s),c=a.replace(/(^|\n)(\t| {1,2})/g,"$1"),l=a.length-c.length;e.setSelectionRange(o,s),$i.insert(e,c);const d=/\t| {1,2}/.exec(i.slice(o,t)),f=d?d[0].length:0,h=t-f;e.setSelectionRange(t-f,Math.max(h,n-l))}static indentCE(e){var c;const t=window.getSelection(),n=e.innerText,i=Yg(e)??0,o=Yg(e)??0,s=n.slice(i,o),a=(c=/\n/g.exec(s))==null?void 0:c.length;if(a&&a>0){const l=n.lastIndexOf(`
349
- `,i-1)+1,d=n.slice(l,o-1),h=d.replace(/^|\n/g,`$&${hd}`).length-d.length;t&&t.setBaseAndExtent(e,i+1,e,o+h)}else{const l=window.getSelection();e.innerText=n.slice(0,i)+hd+n.slice(i),l==null||l.setBaseAndExtent(e,i+1,e,i+2)}}static unindentCE(e){const t=window.getSelection(),n=e.innerText,i=Yg(e)??0,o=Yg(e)??0,s=n.lastIndexOf(`
350
- `,i-1)+1,a=$i.findLineEnd(n,o),c=n.slice(s,a),l=c.replace(/(^|\n)(\t| {1,2})/g,"$1"),d=c.length-l.length;if(t){t.setBaseAndExtent(e,s,e,a);const f=/\t| {1,2}/.exec(n.slice(s,i)),h=f?f[0].length:0,g=i-h;t.setBaseAndExtent(e,i-h,e,Math.max(g,o-d))}}static normalizeText(e){return e.replace($i.fixNewLines,`
351
- `)}static normalizeTextForDom(e){return e.replace($i.fixNewLines,`
352
- `).split(`
353
- `).map(t=>t||" ").join(`
354
- `)}};q($i,"fixNewLines",/\r?\n|\r/g);let Id=$i;function Yg(r){if(typeof window.getSelection>"u")return;const e=window.getSelection();if(!e)return;let t=0;if(e.rangeCount!==0){const n=e.getRangeAt(0),i=n.cloneRange();i.selectNodeContents(r),i.setEnd(n.endContainer,n.endOffset),t=i.toString().length}return t}const _Fe=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;function Yue(r){return _Fe.test(r)}function wFe(r){return r.replace(/\t/g,hd)}function bFe(r){const e=r.split(`
355
- `);for(;e[0]&&e[0].trim().length===0;)e.shift();let t=1/0;for(const n of e)if(n.trim().length>0){const i=n.length-n.trimStart().length;t=Math.min(t,i)}return e.map(n=>n.slice(t)).join(`
356
- `)}const Xue={"&amp;":"&","&quot;":'"',"&apos;":"'","&#34;":'"',"&#38;":"&","&#39;":"'","&#8211;":"–","&#8212;":"—","&#8216;":"‘","&#8217;":"’","&#8220;":"“","&#8221;":"”","&#8230;":"…"},EFe=new RegExp(Object.keys(Xue).join("|"),"g");function IFe(r){return r.replace(EFe,e=>Xue[e])}function PFe(r){return r.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function CFe(r){return PFe(bFe(wFe(r)))}const Zue=5e3,Que=10*1024*1024;function TFe(r,e){r.registerExternalAssetHandler("file",async t=>AFe(r,t,e)),r.registerExternalAssetHandler("url",async t=>RFe(r,t,e)),r.registerExternalContentHandler("svg-text",async t=>kFe(r,t)),r.registerExternalContentHandler("embed",t=>OFe(r,t)),r.registerExternalContentHandler("files",async t=>MFe(r,t,e)),r.registerExternalContentHandler("text",async t=>jFe(r,t)),r.registerExternalContentHandler("url",async t=>DFe(r,t,e)),r.registerExternalContentHandler("tldraw",async t=>LFe(r,t)),r.registerExternalContentHandler("excalidraw",async t=>FFe(r,t))}async function AFe(r,{file:e,assetId:t},{acceptedImageMimeTypes:n=Mh,acceptedVideoMimeTypes:i=_m,maxAssetSize:o=Que,maxImageDimension:s=Zue,toasts:a,msg:c}){const l=n.includes(e.type),d=i.includes(e.type);!l&&!d&&a.addToast({title:c("assets.files.type-not-allowed"),severity:"error"}),Jt(l||d,`File type not allowed: ${e.type}`),e.size>o&&a.addToast({title:c("assets.files.size-too-big"),severity:"error"}),Jt(e.size<=o,`File size too big: ${(e.size/1024).toFixed()}kb > ${(o/1024).toFixed()}kb`);const f=qJ(await e.arrayBuffer());t=t??Qc.createId(f);const h=await Jue(e,t,l,d,s),g=await r.uploadAsset(h,e);return h.props.src=g.src,g.meta&&(h.meta={...h.meta,...g.meta}),Qc.create(h)}async function RFe(r,{url:e},{toasts:t,msg:n}){var o,s,a,c,l;let i;try{const f=await(await pa(e,{method:"GET",mode:"no-cors"})).text(),h=new DOMParser().parseFromString(f,"text/html");i={image:((o=h.head.querySelector('meta[property="og:image"]'))==null?void 0:o.getAttribute("content"))??"",favicon:((s=h.head.querySelector('link[rel="apple-touch-icon"]'))==null?void 0:s.getAttribute("href"))??((a=h.head.querySelector('link[rel="icon"]'))==null?void 0:a.getAttribute("href"))??"",title:((c=h.head.querySelector('meta[property="og:title"]'))==null?void 0:c.getAttribute("content"))??e,description:((l=h.head.querySelector('meta[property="og:description"]'))==null?void 0:l.getAttribute("content"))??""},i.image.startsWith("http")||(i.image=new URL(i.image,e).href),i.favicon.startsWith("http")||(i.favicon=new URL(i.favicon,e).href)}catch(d){console.error(d),t.addToast({title:n("assets.url.failed"),severity:"error"}),i={image:"",favicon:"",title:"",description:""}}return{id:Qc.createId(MC(e)),typeName:"asset",type:"bookmark",props:{src:e,description:i.description,image:i.image,favicon:i.favicon,title:i.title},meta:{}}}async function kFe(r,{point:e,text:t}){const n=e??(r.inputs.shiftKey?r.inputs.currentPagePoint:r.getViewportPageBounds().center),i=new DOMParser().parseFromString(t,"image/svg+xml").querySelector("svg");if(!i)throw new Error("No <svg/> element present");let o=parseFloat(i.getAttribute("width")||"0"),s=parseFloat(i.getAttribute("height")||"0");if(!(o&&s)){document.body.appendChild(i);const c=i.getBoundingClientRect();document.body.removeChild(i),o=c.width,s=c.height}const a=await r.getAssetForExternalContent({type:"file",file:new File([t],"asset.svg",{type:"image/svg+xml"})});if(!a)throw Error("Could not create an asset");ede(r,[a],n)}function OFe(r,{point:e,url:t,embed:n}){const i=e??(r.inputs.shiftKey?r.inputs.currentPagePoint:r.getViewportPageBounds().center),{width:o,height:s}=n,a=Tr(),c={id:a,type:"embed",x:i.x-(o||450)/2,y:i.y-(s||450)/2,props:{w:o,h:s,url:t}};r.createShapes([c]).select(a)}async function MFe(r,{point:e,files:t},{maxAssetSize:n=Que,maxImageDimension:i=Zue,acceptedImageMimeTypes:o=Mh,acceptedVideoMimeTypes:s=_m,toasts:a,msg:c}){if(t.length>r.options.maxFilesAtOnce){a.addToast({title:c("assets.files.amount-too-big"),severity:"error"});return}const l=e??(r.inputs.shiftKey?r.inputs.currentPagePoint:r.getViewportPageBounds().center),d=new T(l.x,l.y),f=[],h=[];for(const g of t){if(g.size>n){a.addToast({title:c("assets.files.size-too-big"),severity:"error"}),console.warn(`File size too big: ${(g.size/1024).toFixed()}kb > ${(n/1024).toFixed()}kb`);continue}if(!g.type){a.addToast({title:c("assets.files.upload-failed"),severity:"error"}),console.error("No mime type");continue}if(![...o,...s].includes(g.type)){a.addToast({title:c("assets.files.type-not-allowed"),severity:"error"}),console.warn(`${g.name} not loaded - Mime type not allowed ${g.type}.`);continue}const y=o.includes(g.type),x=s.includes(g.type),_=qJ(await g.arrayBuffer()),w=Qc.createId(_),I=await Jue(g,w,y,x,i);let b;y&&(b=r.createTemporaryAssetPreview(w,g)),f.push(I),h.push({asset:I,file:g,temporaryAssetPreview:b})}Promise.allSettled(h.map(async g=>{try{const m=await r.getAssetForExternalContent({type:"file",file:g.file});if(!m)throw Error("Could not create an asset");r.updateAssets([{...m,id:g.asset.id}])}catch(m){a.addToast({title:c("assets.files.upload-failed"),severity:"error"}),console.error(m);return}})),ede(r,f,d)}async function jFe(r,{point:e,text:t}){const n=e??(r.inputs.shiftKey?r.inputs.currentPagePoint:r.getViewportPageBounds().center),i=r.getShapeUtil("text").getDefaultProps(),o=CFe(t),s=r.getOnlySelectedShape();if(s&&"text"in s.props){r.updateShapes([{id:s.id,type:s.type,props:{text:o}}]);return}let a,c,l,d="middle";const f=o.split(`
357
- `).length>1,h=Yue(o);f&&(d=f?h?"end":"start":"middle");const g=r.textMeasure.measureText(o,{...Ii,fontFamily:ac[i.font],fontSize:Ed[i.size],maxWidth:null}),m=Math.min(f?r.getViewportPageBounds().width*.9:920,Math.max(200,r.getViewportPageBounds().width*.9));if(g.w>m){const y=r.textMeasure.measureText(o,{...Ii,fontFamily:ac[i.font],fontSize:Ed[i.size],maxWidth:m});a=y.w,c=y.h,l=!1,d=h?"end":"start"}else a=g.w,c=g.h,l=!0;n.y-c/2<r.getViewportPageBounds().minY+40&&(n.y=r.getViewportPageBounds().minY+40+c/2),r.createShapes([{id:Tr(),type:"text",x:n.x-a/2,y:n.y-c/2,props:{text:o,textAlign:d,autoSize:l,w:a}}])}async function DFe(r,{point:e,url:t},{toasts:n,msg:i}){const o=r.getShapeUtil("embed"),s=o==null?void 0:o.getEmbedDefinition(t);if(s)return r.putExternalContent({type:"embed",url:s.url,point:e,embed:s.definition});const a=e??(r.inputs.shiftKey?r.inputs.currentPagePoint:r.getViewportPageBounds().center),c=Qc.createId(MC(t)),l=NFe(r,t,a);let d=r.getAsset(c),f=!1;if(!d){f=!0;try{const h=await r.getAssetForExternalContent({type:"url",url:t});if(!h)throw Error("Could not create an asset");d=h}catch{n.addToast({title:i("assets.url.failed"),severity:"error"});return}}r.run(()=>{f&&r.createAssets([d]),r.updateShapes([{id:l.id,type:l.type,props:{assetId:d.id}}])})}async function LFe(r,{point:e,content:t}){r.run(()=>{const n=r.getSelectionPageBounds();r.markHistoryStoppingPoint("paste"),r.putContentOntoCurrentPage(t,{point:e,select:!0});const i=r.getSelectionPageBounds();n&&i&&(n!=null&&n.collides(i))&&(r.updateInstanceState({isChangingStyle:!0}),r.timers.setTimeout(()=>{r.updateInstanceState({isChangingStyle:!1})},150))})}async function FFe(r,{point:e,content:t}){r.run(()=>{lFe(r,t,e)})}async function Jue(r,e,t,n,i){let o=r.type;r.type==="video/quicktime"&&(o="video/mp4");const s=t?await To.getImageSize(r):await To.getVideoSize(r),a=await To.isAnimated(r)||n,c={id:e,type:t?"image":"video",typeName:"asset",props:{name:r.name,src:"",w:s.w,h:s.h,fileSize:r.size,mimeType:o,isAnimated:a},meta:{}};if(i&&isFinite(i)){const l={w:c.props.w,h:c.props.h},d=cFe(l,{w:i,h:i});l!==d&&To.isStaticImageType(r.type)&&(c.props.w=d.w,c.props.h=d.h)}return c}async function ede(r,e,t){if(!e.length)return[];const n=T.From(t),i=[];for(let o=0;o<e.length;o++){const s=e[o];switch(s.type){case"image":{i.push({id:Tr(),type:"image",x:n.x,y:n.y,opacity:1,props:{assetId:s.id,w:s.props.w,h:s.props.h}}),n.x+=s.props.w;break}case"video":i.push({id:Tr(),type:"video",x:n.x,y:n.y,opacity:1,props:{assetId:s.id,w:s.props.w,h:s.props.h}}),n.x+=s.props.w}}return r.run(()=>{const o=e.filter(s=>!r.getAsset(s.id));o.length&&r.createAssets(o),r.createShapes(i).select(...i.map(s=>s.id)),tde(r,t)}),i.map(o=>o.id)}function tde(r,e){const t=r.getViewportPageBounds();let n=r.getSelectionPageBounds();if(n){const i=n.center.sub(e);r.updateShapes(r.getSelectedShapes().map(o=>{const s=r.getShapeParentTransform(o).decompose().rotation,a=T.Rot(i,-s);return{id:o.id,type:o.type,x:o.x-a.x,y:o.y-a.y}}))}if(n=r.getSelectionPageBounds(),n&&r.getInstanceState().isGridMode){const i=r.getDocumentSettings().gridSize,o=new T(n.minX,n.minY),s=o.clone().snapToGrid(i),a=T.Sub(o,s);r.updateShapes(r.getSelectedShapes().map(c=>{const l={x:c.x-a.x,y:c.y-a.y};return{id:c.id,type:c.type,x:l.x,y:l.y}}))}n=r.getSelectionPageBounds(),n&&!t.contains(n)&&r.zoomToSelection({animation:{duration:r.options.animationMediumMs}})}function NFe(r,e,t){const n={id:Tr(),type:"bookmark",x:t.x-150,y:t.y-160,opacity:1,props:{assetId:null,url:e}};return r.run(()=>{r.createShapes([n]).select(n.id),tde(r,t)}),r.getShape(n.id)}var ZI;let $Fe=(ZI=class extends vt{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}onKeyUp(e){var t;if(e.key==="Enter"){if(this.editor.getIsReadonly())return null;const n=this.editor.getOnlySelectedShape();n&&this.editor.getShapeUtil(n).canEdit(n)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(n.id),(t=this.editor.root.getCurrent())==null||t.transition("editing_shape",{...e,target:"shape",shape:n}))}}},q(ZI,"id","idle"),ZI);var QI;let qFe=(QI=class extends vt{constructor(){super(...arguments);q(this,"shape");q(this,"markId","");q(this,"preciseTimeout",-1);q(this,"didTimeout",!1)}onEnter(){this.markId="",this.didTimeout=!1;const t=this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{filter:n=>!n.isLocked&&this.editor.canBindShapes({fromShape:"arrow",toShape:n,binding:"arrow"}),margin:0,hitInside:!0,renderingOnly:!0});t?this.editor.setHintingShapes([t.id]):this.createArrowShape(),this.startPreciseTimeout()}onExit(){this.shape=void 0,this.editor.setHintingShapes([]),this.clearPreciseTimeout()}onPointerMove(){if(this.editor.inputs.isDragging){if(this.shape||this.createArrowShape(),!this.shape)throw Error("expected shape");this.updateArrowShapeEndHandle(),this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,handle:{id:"end",type:"vertex",index:"a3",x:0,y:0},isCreating:!0,creatingMarkId:this.markId||void 0,onInteractionEnd:"arrow"})}}onPointerUp(){this.cancel()}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.shape&&this.editor.bailToMark(this.markId),this.editor.setHintingShapes([]),this.parent.transition("idle")}createArrowShape(){var f;const{originPagePoint:t}=this.editor.inputs,n=Tr();this.markId=this.editor.markHistoryStoppingPoint(`creating_arrow:${n}`);const i=ks(t,this.editor);this.editor.createShape({id:n,type:"arrow",x:i.x,y:i.y,props:{scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}});const o=this.editor.getShape(n);if(!o)throw Error("expected shape");const s=this.editor.getShapeHandles(o);if(!s)throw Error("expected handles for arrow");const a=this.editor.getShapeUtil("arrow"),c=this.shape,l=s.find(h=>h.id==="start"),d=(f=a.onHandleDrag)==null?void 0:f.call(a,o,{handle:{...l,x:0,y:0},isPrecise:!0,initial:c});d&&this.editor.updateShapes([d]),this.shape=this.editor.getShape(n),this.editor.select(n)}updateArrowShapeEndHandle(){var i,o;const t=this.shape;if(!t)throw Error("expected shape");const n=this.editor.getShapeHandles(t);if(!n)throw Error("expected handles for arrow");{const s=this.editor.getShapeUtil("arrow"),a=this.shape,c=n.find(d=>d.id==="start"),l=(i=s.onHandleDrag)==null?void 0:i.call(s,t,{handle:{...c,x:0,y:0},isPrecise:this.didTimeout,initial:a});l&&this.editor.updateShapes([l])}{const s=this.editor.getShapeUtil("arrow"),a=this.shape,c=this.editor.getPointInShapeSpace(t,this.editor.inputs.currentPagePoint),l=n.find(f=>f.id==="end"),d=(o=s.onHandleDrag)==null?void 0:o.call(s,this.editor.getShape(t),{handle:{...l,x:c.x,y:c.y},isPrecise:!1,initial:a});d&&this.editor.updateShapes([d])}this.shape=this.editor.getShape(t.id)}startPreciseTimeout(){this.preciseTimeout=this.editor.timers.setTimeout(()=>{this.getIsActive()&&(this.didTimeout=!0)},320)}clearPreciseTimeout(){clearTimeout(this.preciseTimeout)}},q(QI,"id","pointing"),QI);class sC extends vt{constructor(){super(...arguments);q(this,"shapeType","arrow")}static children(){return[$Fe,qFe]}}q(sC,"id","arrow"),q(sC,"initial","idle");class fR extends vt{constructor(){super(...arguments);q(this,"info",{});q(this,"initialShape");q(this,"shapeType",this.parent.id==="highlight"?"highlight":"draw");q(this,"util",this.editor.getShapeUtil(this.shapeType));q(this,"isPen",!1);q(this,"isPenOrStylus",!1);q(this,"segmentMode","free");q(this,"didJustShiftClickToExtendPreviousShapeLine",!1);q(this,"pagePointWhereCurrentSegmentChanged",{});q(this,"pagePointWhereNextSegmentChanged",null);q(this,"lastRecordedPoint",{});q(this,"mergeNextPoint",!1);q(this,"currentLineLength",0);q(this,"markId",null)}onEnter(t){this.markId=null,this.info=t,this.lastRecordedPoint=this.editor.inputs.currentPagePoint.clone(),this.startShape()}onPointerMove(){const{inputs:t}=this.editor;if(this.isPen&&!t.isPen&&this.markId){this.editor.bailToMark(this.markId),this.startShape();return}this.isPenOrStylus?T.Dist(t.currentPagePoint,this.lastRecordedPoint)>=1/this.editor.getZoomLevel()?(this.lastRecordedPoint=t.currentPagePoint.clone(),this.mergeNextPoint=!1):this.mergeNextPoint=!0:this.mergeNextPoint=!1,this.updateDrawingShape()}onKeyDown(t){if(t.key==="Shift")switch(this.segmentMode){case"free":{this.segmentMode="starting_straight",this.pagePointWhereNextSegmentChanged=this.editor.inputs.currentPagePoint.clone();break}case"starting_free":this.segmentMode="starting_straight"}this.updateDrawingShape()}onKeyUp(t){if(t.key==="Shift")switch(this.editor.snaps.clearIndicators(),this.segmentMode){case"straight":{this.segmentMode="starting_free",this.pagePointWhereNextSegmentChanged=this.editor.inputs.currentPagePoint.clone();break}case"starting_straight":{this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";break}}this.updateDrawingShape()}onExit(){this.editor.snaps.clearIndicators(),this.pagePointWhereCurrentSegmentChanged=this.editor.inputs.currentPagePoint.clone()}canClose(){return this.shapeType!=="highlight"}getIsClosed(t,n,i){if(!this.canClose())return!1;const o=Ei[n],s=t[0].points[0],a=t[t.length-1],c=a.points[a.points.length-1];return s!==c&&this.currentLineLength>o*4*i&&T.DistMin(s,c,o*2*i)}startShape(){const{inputs:{originPagePoint:t,isPen:n}}=this.editor;this.markId=this.editor.markHistoryStoppingPoint("draw start");const{z:i=.5}=this.info.point;this.isPen=n,this.isPenOrStylus=n||i>0&&i<.5||i>.5&&i<1;const o=this.isPenOrStylus?i*1.25:.5;if(this.segmentMode=this.editor.inputs.shiftKey?"straight":"free",this.didJustShiftClickToExtendPreviousShapeLine=!1,this.lastRecordedPoint=t.clone(),this.initialShape){const a=this.editor.getShape(this.initialShape.id);if(a&&this.segmentMode==="straight"){this.didJustShiftClickToExtendPreviousShapeLine=!0;const c=Zn(a.props.segments);if(!c)throw Error("Expected a previous segment!");const l=Zn(c.points);if(!l)throw Error("Expected a previous point!");const{x:d,y:f}=this.editor.getPointInShapeSpace(a,t).toFixed(),h={type:this.segmentMode,points:[{x:l.x,y:l.y,z:+o.toFixed(2)},{x:d,y:f,z:+o.toFixed(2)}]},g=Ke.applyToPoint(this.editor.getShapePageTransform(a.id),l);this.pagePointWhereCurrentSegmentChanged=g,this.pagePointWhereNextSegmentChanged=null;const m=[...a.props.segments,h];this.currentLineLength<Ei[a.props.size]*4&&(this.currentLineLength=this.getLineLength(m));const y={id:a.id,type:this.shapeType,props:{segments:m}};this.canClose()&&(y.props.isClosed=this.getIsClosed(m,a.props.size,a.props.scale)),this.editor.updateShapes([y]);return}}this.pagePointWhereCurrentSegmentChanged=t.clone();const s=Tr();this.editor.createShapes([{id:s,type:this.shapeType,x:t.x,y:t.y,props:{isPen:this.isPenOrStylus,scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1,segments:[{type:this.segmentMode,points:[{x:0,y:0,z:+o.toFixed(2)}]}]}}]),this.currentLineLength=0,this.initialShape=this.editor.getShape(s)}updateDrawingShape(){const{initialShape:t}=this,{inputs:n}=this.editor;if(!t)return;const{id:i,props:{size:o,scale:s}}=t,a=this.editor.getShape(i);if(!a)return;const{segments:c}=a.props,{x:l,y:d,z:f}=this.editor.getPointInShapeSpace(a,n.currentPagePoint).toFixed(),h=this.isPenOrStylus?+(n.currentPagePoint.z*1.25).toFixed(2):.5,g={x:l,y:d,z:h};switch(this.segmentMode){case"starting_straight":{const{pagePointWhereNextSegmentChanged:m}=this;if(m===null)throw Error("We should have a point where the segment changed");if(T.Dist2(m,n.currentPagePoint)>this.editor.options.dragDistanceSquared){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="straight";const x=Zn(c);if(!x)throw Error("Expected a previous segment!");const _=Zn(x.points);if(!_)throw Error("Expected a previous last point!");let w;const I=this.editor.getPointInShapeSpace(a,this.pagePointWhereCurrentSegmentChanged).toFixed().toJson();if(x.type==="straight"){this.currentLineLength+=T.Dist(_,I),w={type:"straight",points:[{..._},I]};const P=this.editor.getShapePageTransform(a);this.pagePointWhereCurrentSegmentChanged=Ke.applyToPoint(P,_)}else w={type:"straight",points:[I,g]};const b={id:i,type:this.shapeType,props:{segments:[...c,w]}};this.canClose()&&(b.props.isClosed=this.getIsClosed(c,o,s)),this.editor.updateShapes([b])}break}case"starting_free":{const{pagePointWhereNextSegmentChanged:m}=this;if(m===null)throw Error("We should have a point where the segment changed");if(T.Dist2(m,n.currentPagePoint)>this.editor.options.dragDistanceSquared){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";const x=c.slice(),_=x[x.length-1],w=Zn(_.points);if(!w)throw Error("No previous point!");const I={type:"free",points:[...T.PointsBetween(w,g,6).map(C=>({x:Za(C.x),y:Za(C.y),z:Za(C.z)}))]},b=[...x,I];this.currentLineLength<Ei[a.props.size]*4&&(this.currentLineLength=this.getLineLength(b));const P={id:i,type:this.shapeType,props:{segments:b}};this.canClose()&&(P.props.isClosed=this.getIsClosed(b,o,s)),this.editor.updateShapes([P])}break}case"straight":{const m=c.slice(),y=m[m.length-1],{pagePointWhereCurrentSegmentChanged:x}=this,{ctrlKey:_,currentPagePoint:w}=this.editor.inputs;if(!x)throw Error("We should have a point where the segment changed");let I,b=!1;this.didJustShiftClickToExtendPreviousShapeLine?this.editor.inputs.isDragging&&(b=!_,this.didJustShiftClickToExtendPreviousShapeLine=!1):b=!_;let P=this.editor.getPointInShapeSpace(a,w).toFixed().toJson(),C=!1,k;if((this.editor.user.getIsSnapMode()?!_:_)&&m.length>2){let j,F=8/this.editor.getZoomLevel();for(let $=0,D=c.length-2;$<D;$++){const N=c[$];if(!N)break;if(N.type==="free")continue;const B=N.points[0],W=Zn(N.points);if(!(B&&W))continue;const G=T.NearestPointOnLineSegment(B,W,P);if(T.DistMin(G,P,F)){j=G.toFixed().toJson(),F=T.Dist(G,P),k=N;break}}j&&(C=!0,P=j)}if(C&&k){const j=this.editor.getShapePageTransform(a),F=k.points[0],$=Zn(k.points);if(!$)throw Error("Expected a last point!");const D=Ke.applyToPoint(j,F),N=Ke.applyToPoint(j,$),B=Ke.applyToPoint(j,P);this.editor.snaps.setIndicators([{id:Er(),type:"points",points:[D,B,N]}])}else{if(this.editor.snaps.clearIndicators(),b){const j=T.Angle(x,w),$=Uv(j,24)-j;I=T.RotWith(w,x,$)}else I=w;P=this.editor.getPointInShapeSpace(a,I).toFixed().toJson()}this.currentLineLength+=T.Dist(y.points[0],P),m[m.length-1]={...y,type:"straight",points:[y.points[0],P]};const L={id:i,type:this.shapeType,props:{segments:m}};this.canClose()&&(L.props.isClosed=this.getIsClosed(c,o,s)),this.editor.updateShapes([L]);break}case"free":{const m=c.slice(),y=m[m.length-1],x=[...y.points];if(x.length&&this.mergeNextPoint){const{z:w}=x[x.length-1];x[x.length-1]={x:g.x,y:g.y,z:w?Math.max(w,g.z):g.z}}else this.currentLineLength+=T.Dist(x[x.length-1],g),x.push(g);m[m.length-1]={...y,points:x},this.currentLineLength<Ei[a.props.size]*4&&(this.currentLineLength=this.getLineLength(m));const _={id:i,type:this.shapeType,props:{segments:m}};if(this.canClose()&&(_.props.isClosed=this.getIsClosed(m,o,s)),this.editor.updateShapes([_]),x.length>this.util.options.maxPointsPerShape){this.editor.updateShapes([{id:i,type:this.shapeType,props:{isComplete:!0}}]);const w=Tr(),I=this.editor.getShape(i).props;this.editor.createShapes([{id:w,type:this.shapeType,x:Za(n.currentPagePoint.x),y:Za(n.currentPagePoint.y),props:{isPen:this.isPenOrStylus,scale:I.scale,segments:[{type:"free",points:[{x:0,y:0,z:this.isPenOrStylus?+(f*1.25).toFixed():.5}]}]}}]),this.initialShape=Kr(this.editor.getShape(w)),this.mergeNextPoint=!1,this.lastRecordedPoint=n.currentPagePoint.clone(),this.currentLineLength=0}break}}}getLineLength(t){let n=0;for(const i of t)for(let o=0;o<i.points.length-1;o++){const s=i.points[o],a=i.points[o+1];n+=T.Dist2(a,s)}return Math.sqrt(n)}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.editor.inputs.isDragging||(this.markId&&this.editor.bailToMark(this.markId),this.cancel())}complete(){const{initialShape:t}=this;t&&(this.editor.updateShapes([{id:t.id,type:t.type,props:{isComplete:!0}}]),this.parent.transition("idle"))}cancel(){this.parent.transition("idle",this.info)}}q(fR,"id","drawing");var JI;let rde=(JI=class extends vt{onPointerDown(e){this.parent.transition("drawing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},q(JI,"id","idle"),JI);class vv extends vt{constructor(){super(...arguments);q(this,"shapeType","draw")}static children(){return[rde,fR]}onExit(){const t=this.children.drawing;t.initialShape=void 0}}q(vv,"id","draw"),q(vv,"initial","idle"),q(vv,"isLockable",!1);class aC extends UP{constructor(){super(...arguments);q(this,"shapeType","frame")}onCreate(t){if(!t)return;const n=this.editor.getShapePageBounds(t),i=[],o=this.editor.getShapeAncestors(t).map(s=>s.id);this.editor.getSortedChildIdsForParent(t.parentId).map(s=>{const a=this.editor.getShape(s);if(!a||a.id===t.id||a.isLocked)return;const c=this.editor.getShapePageBounds(a);c&&n.contains(c)&&BFe(a,o,t)&&i.push(a.id)}),this.editor.reparentShapes(i,t.id),this.editor.getInstanceState().isToolLocked?this.editor.setCurrentTool("frame"):this.editor.setCurrentTool("select.idle")}}q(aC,"id","frame"),q(aC,"initial","idle");function BFe(r,e,t){return e.includes(r.id)?!1:r.parentId===t.parentId}var eP;let UFe=(eP=class extends vt{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onKeyUp(e){var t;if(e.key==="Enter"){if(this.editor.getIsReadonly())return null;const n=this.editor.getOnlySelectedShape();n&&this.editor.getShapeUtil(n).canEdit(n)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(n.id),(t=this.editor.root.getCurrent())==null||t.transition("editing_shape",{...e,target:"shape",shape:n}))}}onCancel(){this.editor.setCurrentTool("select")}},q(eP,"id","idle"),eP);var tP;let zFe=(tP=class extends vt{onPointerUp(){this.complete()}onPointerMove(e){if(this.editor.inputs.isDragging){const{originPagePoint:t}=this.editor.inputs,n=Tr(),i=this.editor.markHistoryStoppingPoint(`creating_geo:${n}`),o=ks(t,this.editor);this.editor.createShapes([{id:n,type:"geo",x:o.x,y:o.y,props:{w:1,h:1,geo:this.editor.getStyleForNextShape(Ts),scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}}]).select(n).setCurrentTool("select.resizing",{...e,target:"selection",handle:"bottom_right",isCreating:!0,creatingMarkId:i,creationCursorOffset:{x:1,y:1},onInteractionEnd:"geo"})}}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}complete(){const{originPagePoint:e}=this.editor.inputs,t=Tr();this.editor.markHistoryStoppingPoint(`creating_geo:${t}`);const n=this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1,i=this.editor.getStyleForNextShape(Ts),o=i==="star"?{w:200,h:190}:i==="cloud"?{w:300,h:180}:{w:200,h:200};this.editor.createShapes([{id:t,type:"geo",x:e.x,y:e.y,props:{geo:this.editor.getStyleForNextShape(Ts),scale:n,...o}}]);const s=this.editor.getShape(t);if(!s)return;const{w:a,h:c}=s.props,l=new T(a/2,c/2).mul(n),d=this.editor.getShapeParentTransform(s);d&&l.rot(-d.rotation());const f=ks(new T(s.x-l.x,s.y-l.y),this.editor);this.editor.select(t),this.editor.updateShape({id:s.id,type:"geo",x:f.x,y:f.y,props:{geo:this.editor.getStyleForNextShape(Ts),w:a*n,h:c*n}}),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select",{})}cancel(){this.parent.transition("idle")}},q(tP,"id","pointing"),tP);class cC extends vt{constructor(){super(...arguments);q(this,"shapeType","geo")}static children(){return[UFe,zFe]}}q(cC,"id","geo"),q(cC,"initial","idle");class mv extends vt{constructor(){super(...arguments);q(this,"shapeType","highlight")}static children(){return[rde,fR]}onExit(){const t=this.children.drawing;t.initialShape=void 0}}q(mv,"id","highlight"),q(mv,"initial","idle"),q(mv,"isLockable",!1);var rP;let HFe=(rP=class extends vt{constructor(){super(...arguments);q(this,"shapeId","")}onEnter(t){this.shapeId=t.shapeId,this.editor.setCursor({type:"cross",rotation:0})}onPointerDown(){this.parent.transition("pointing",{shapeId:this.shapeId})}onCancel(){this.editor.setCurrentTool("select")}},q(rP,"id","idle"),rP);const GQ=2;var nP;let WFe=(nP=class extends vt{constructor(){super(...arguments);q(this,"shape",{});q(this,"markId")}onEnter(t){const{inputs:n}=this.editor,{currentPagePoint:i}=n;this.markId=void 0;const o=t.shapeId&&this.editor.getShape(t.shapeId);if(o&&n.shiftKey){this.markId=this.editor.markHistoryStoppingPoint(`creating_line:${o.id}`),this.shape=o;const s=this.editor.getShapeHandles(this.shape);if(!s)return;const a=s.filter(m=>m.type==="vertex").sort(_i),c=a[a.length-1],l=a[a.length-2],d=Ke.applyToPoint(this.editor.getShapeParentTransform(this.shape),new T(this.shape.x,this.shape.y)),f=T.Sub(i,d).addXY(.1,.1),h=ks(f,this.editor),g=Kr(this.shape.props.points);if(T.DistMin(c,l,GQ)||T.DistMin(h,c,GQ))g[c.id]={id:c.id,index:c.index,x:h.x,y:h.y};else{const m=ca(c.index);g[m]={id:m,index:m,x:h.x,y:h.y}}this.editor.updateShapes([{id:this.shape.id,type:this.shape.type,props:{points:g}}])}else{const s=Tr();this.markId=this.editor.markHistoryStoppingPoint(`creating_line:${s}`);const a=ks(i,this.editor);this.editor.createShapes([{id:s,type:"line",x:a.x,y:a.y,props:{scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}}]),this.editor.select(s),this.shape=this.editor.getShape(s)}}onPointerMove(){if(this.shape&&this.editor.inputs.isDragging){const t=this.editor.getShapeHandles(this.shape);if(!t)throw this.markId&&this.editor.bailToMark(this.markId),Error("No handles found");const n=Zn(t);this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,isCreating:!0,creatingMarkId:this.markId,handle:{...n,x:n.x-.1,y:n.y-.1},onInteractionEnd:"line"})}}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.parent.transition("idle"),this.markId&&this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators()}complete(){this.parent.transition("idle",{shapeId:this.shape.id}),this.editor.snaps.clearIndicators()}cancel(){this.markId&&this.editor.bailToMark(this.markId),this.parent.transition("idle",{shapeId:this.shape.id}),this.editor.snaps.clearIndicators()}},q(nP,"id","pointing"),nP);class lC extends vt{constructor(){super(...arguments);q(this,"shapeType","line")}static children(){return[HFe,WFe]}}q(lC,"id","line"),q(lC,"initial","idle");var iP;let KFe=(iP=class extends vt{onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onCancel(){this.editor.setCurrentTool("select")}},q(iP,"id","idle"),iP);const GFe=0,Ir=200,nS=new T(Ir/2,Ir/2),nde=10,VFe=r=>[[["a1"],new T(Ir*.5,Ir*-.5-r.options.adjacentShapeMargin)],[["a2"],new T(Ir*1.5+r.options.adjacentShapeMargin,Ir*.5)],[["a3"],new T(Ir*.5,Ir*1.5+r.options.adjacentShapeMargin)],[["a4"],new T(Ir*-.5-r.options.adjacentShapeMargin,Ir*.5)]];function YFe(r,e){if(e===1)return VFe(r);const t=Ir*e,n=r.options.adjacentShapeMargin*e;return[[["a1"],new T(t*.5,t*-.5-n)],[["a2"],new T(t*1.5+n,t*.5)],[["a3"],new T(t*.5,t*1.5+n)],[["a4"],new T(t*-.5-n,t*.5)]]}function ide(r,e,t,n,i,o){return Object.fromEntries(YFe(r,o).map(([s,a],c)=>{const l=a.clone();return c===0&&i?l.y-=i:c===2&&n&&(l.y+=n),[s,l.rot(t).add(e)]}))}function ode(r,e,t,n){const i=new Set(r.getSelectedShapeIds()),o=(Ir+r.options.adjacentShapeMargin+n)**2,s=new Map,a=[];for(const d of r.getCurrentPageShapes()){if(!r.isShapeOfType(d,"note")||t!==d.props.scale||i.has(d.id))continue;const f=r.getShapePageTransform(d.id);e===f.rotation()&&(s.set(d,r.getShapePageBounds(d).center),a.push(...Object.values(ide(r,f.point(),e,d.props.growY,n,t))))}const c=a.length;let l;for(const[d,f]of s)for(let h=0;h<c;h++)l=a[h],l&&(T.Dist2(f,l)>o||r.isPointInShape(d,l)&&(a[h]=void 0));return Gt(a)}function sde(r,e,t,n,i=!1){let o;const s=r.getCurrentPageShapesSorted(),a=(Ir+r.options.adjacentShapeMargin**2)**e.props.scale;for(let c=s.length-1;c>=0;c--){const l=s[c];if(l.type==="note"&&l.id!==e.id){const d=r.getShapePageBounds(l);if(d&&T.Dist2(d.center,t)<a&&r.isPointInShape(l,t)){o=l;break}}}if(r.complete(),!o||i){r.markHistoryStoppingPoint("creating note shape");const c=Tr();r.createShape({id:c,type:"note",x:t.x,y:t.y,rotation:n,opacity:e.opacity,props:{...e.props,text:"",growY:0,fontSizeAdjustment:0,url:""}});const l=r.getShape(c);if(!l)return;const d=r.getPointInParentSpace(l,T.Sub(t,T.Rot(nS.clone().mul(l.props.scale),n)));r.updateShape({id:c,type:"note",x:d.x,y:d.y}),o=r.getShape(c)}return ZFe(r),o}const XFe=16;function ZFe(r){const e=r.getSelectionPageBounds(),t=r.getViewportPageBounds();if(e&&!t.contains(e)){const n=e.clone().expandBy(XFe/r.getZoomLevel()).expand(t),i=t.clone().translate({x:(n.center.x-t.center.x)*2,y:(n.center.y-t.center.y)*2});r.zoomToBounds(i,{animation:{duration:r.options.animationMediumMs},inset:0})}}var oP;let QFe=(oP=class extends vt{constructor(){super(...arguments);q(this,"dragged",!1);q(this,"info",{});q(this,"markId","");q(this,"shape",{})}onEnter(){const{editor:t}=this,n=Tr();this.markId=t.markHistoryStoppingPoint(`creating_note:${n}`);const i=this.editor.inputs.originPagePoint.clone(),o=JFe(this.editor,i,this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1);o&&i.sub(o),this.shape=eNe(this.editor,n,i)}onPointerMove(t){this.editor.inputs.isDragging&&this.editor.setCurrentTool("select.translating",{...t,target:"shape",shape:this.shape,onInteractionEnd:"note",isCreating:!0,creatingMarkId:this.markId,onCreate:()=>{this.editor.setEditingShape(this.shape.id),this.editor.setCurrentTool("select.editing_shape")}})}onPointerUp(){this.complete()}onInterrupt(){this.cancel()}onComplete(){this.complete()}onCancel(){this.cancel()}complete(){this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):(this.editor.setEditingShape(this.shape.id),this.editor.setCurrentTool("select.editing_shape",{...this.info,target:"shape",shape:this.shape}))}cancel(){this.editor.bailToMark(this.markId),this.parent.transition("idle",this.info)}},q(oP,"id","pointing"),oP);function JFe(r,e,t){let n=nde/r.getZoomLevel(),i;for(const o of ode(r,0,t,0)){const s=T.Sub(e,o),a=s.len();a<n&&(n=a,i=s)}return i}function eNe(r,e,t){r.createShape({id:e,type:"note",x:t.x,y:t.y,props:{scale:r.user.getIsDynamicResizeMode()?1/r.getZoomLevel():1}}).select(e);const n=r.getShape(e),i=r.getShapeGeometry(n).bounds,o=ks(new T(n.x-i.width/2,n.y-i.height/2),r);return r.updateShapes([{id:e,type:"note",x:o.x,y:o.y}]),r.getShape(e)}class uC extends vt{constructor(){super(...arguments);q(this,"shapeType","note")}static children(){return[KFe,QFe]}}q(uC,"id","note"),q(uC,"initial","idle");function tNe(r){const e=r.getShapeAtPoint(r.inputs.currentPagePoint,{hitInside:!1,hitLabels:!1,margin:r.options.hitTestMargin/r.getZoomLevel(),renderingOnly:!0});if(!e)return r.setHoveredShape(null);let t;const n=r.getOutermostSelectableShape(e);return n===e||n.id===r.getFocusedGroupId()||r.getSelectedShapeIds().includes(n.id)?t=e:t=n,r.setHoveredShape(t.id)}const Ja=LJ(tNe,32);var sP;let rNe=(sP=class extends vt{onPointerMove(e){switch(e.target){case"shape":case"canvas":Ja(this.editor)}}onPointerDown(e){this.parent.transition("pointing",e)}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}onExit(){Ja.cancel()}onKeyDown(e){var t;if(e.key==="Enter"){if(this.editor.getIsReadonly())return null;const n=this.editor.getOnlySelectedShape();n&&this.editor.getShapeUtil(n).canEdit(n)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(n.id),(t=this.editor.root.getCurrent())==null||t.transition("editing_shape",{...e,target:"shape",shape:n}))}}onCancel(){this.editor.setCurrentTool("select")}},q(sP,"id","idle"),sP);var aP;let nNe=(aP=class extends vt{constructor(){super(...arguments);q(this,"shape");q(this,"markId","");q(this,"enterTime",0)}onEnter(){this.enterTime=Date.now()}onExit(){this.editor.setHintingShapes([])}onPointerMove(t){if(Date.now()-this.enterTime<150)return;const{editor:n}=this,{isPointing:i}=n.inputs;if(!i)return;const{originPagePoint:o,currentPagePoint:s}=n.inputs,a=Math.abs(o.x-s.x),l=Math.sqrt(n.getInstanceState().isCoarsePointer?n.options.coarseDragDistanceSquared:n.options.dragDistanceSquared)*6/n.getZoomLevel();if(a>l){const d=Tr();this.markId=n.markHistoryStoppingPoint(`creating_text:${d}`);const f=this.createTextShape(d,o,!1,a);if(!f){this.cancel();return}this.shape=n.getShape(f),n.select(d),n.setCurrentTool("select.resizing",{...t,target:"selection",handle:"right",isCreating:!0,creatingMarkId:this.markId,creationCursorOffset:{x:a,y:1},onInteractionEnd:"text",onCreate:()=>{n.setEditingShape(f.id)}})}}onPointerUp(){this.complete()}onComplete(){this.cancel()}onCancel(){this.cancel()}onInterrupt(){this.cancel()}complete(){this.editor.markHistoryStoppingPoint("creating text shape");const t=Tr(),{originPagePoint:n}=this.editor.inputs;this.createTextShape(t,n,!0,20)&&(this.editor.select(t),this.editor.setEditingShape(t))}cancel(){this.parent.transition("idle"),this.editor.bailToMark(this.markId)}createTextShape(t,n,i,o){this.editor.createShape({id:t,type:"text",x:n.x,y:n.y,props:{text:"",autoSize:i,w:o,scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}});const s=this.editor.getShape(t);if(!s){this.cancel();return}const a=this.editor.getShapePageBounds(s),c=new T;if(i)switch(s.props.textAlign){case"start":{c.x=0;break}case"middle":{c.x=-a.width/2;break}case"end":{c.x=-a.width;break}}else c.x=0;if(c.y=-a.height/2,co(s.parentId)){const f=this.editor.getShapeParentTransform(s);c.rot(-f.rotation())}const l=s.x+c.x,d=s.y+c.y;if(this.editor.getInstanceState().isGridMode){const f=new T(l,d),h=ks(f,this.editor),g=T.Sub(f,h);this.editor.updateShape({...s,x:l-g.x,y:d-g.y})}else this.editor.updateShape({...s,x:l,y:d});return s}},q(aP,"id","pointing"),aP);class dC extends vt{constructor(){super(...arguments);q(this,"shapeType","text")}static children(){return[rNe,nNe]}}q(dC,"id","text"),q(dC,"initial","idle");const iNe=[dC,vv,cC,uC,lC,aC,sC,mv];function fs(){return uc({isDarkMode:lp()})}function iS(r){return{key:`${ga.id}:${r}`,async getElement(){const e=oNe(r);if(!e)return null;const{url:t,fontFaceRule:n}=e,i=await(await pa(t)).blob(),o=await ns.blobToDataUrl(i),s=n.replace(t,o);return v.jsx("style",{children:s})}}}function oNe(r){const e=tte[r];for(const t of document.fonts)if(e.includes(t.family)&&"$$_url"in t&&typeof t.$$_url=="string"&&"$$_fontface"in t&&typeof t.$$_fontface=="string")return{url:t.$$_url,fontFaceRule:t.$$_fontface};return null}function hR(r){return{key:`${ga.id}:${r}`,async getElement(){return r!=="pattern"?null:v.jsx(sNe,{})}}}function sNe(){const r=gR(),e=Ld(),t=fs(),n=8/12;return v.jsxs(v.Fragment,{children:[v.jsxs("mask",{id:e,children:[v.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:"white"}),v.jsxs("g",{strokeLinecap:"round",stroke:"black",children:[v.jsx("line",{x1:n*1,y1:n*3,x2:n*3,y2:n*1}),v.jsx("line",{x1:n*5,y1:n*7,x2:n*7,y2:n*5}),v.jsx("line",{x1:n*9,y1:n*11,x2:n*11,y2:n*9})]})]}),v.jsx("pattern",{id:r(1,t.id),width:"8",height:"8",patternUnits:"userSpaceOnUse",children:v.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:t.solid,mask:`url(#${e})`})})]})}function pR(){return{key:`${ga.id}:pattern`,component:uNe}}const rh=8,VQ=(r,e,t)=>new Promise((n,i)=>{const o=rh*e*r,s=document.createElement("canvas");s.width=o,s.height=o;const a=s.getContext("2d");if(!a)return;a.fillStyle=t?Yv.darkMode.solid:Yv.lightMode.solid,a.fillRect(0,0,o,o),a.globalCompositeOperation="destination-out",a.lineCap="round",a.lineWidth=1.25*e*r;const c=8/12,l=d=>d*e*r;a.beginPath(),a.moveTo(l(c*1),l(c*3)),a.lineTo(l(c*3),l(c*1)),a.moveTo(l(c*5),l(c*7)),a.lineTo(l(c*7),l(c*5)),a.moveTo(l(c*9),l(c*11)),a.lineTo(l(c*11),l(c*9)),a.stroke(),s.toBlob(d=>{!d||yn.throwToBlob.get()?i():n(d)})}),YQ=(r,e)=>{const t=document.createElement("canvas");t.width=r[0],t.height=r[1];const n=t.getContext("2d");return n?(e(n),t.toDataURL()):""};let $I=null;function aNe(){return $I||($I={white:YQ([1,1],r=>{r.fillStyle="#f8f9fa",r.fillRect(0,0,1,1)}),black:YQ([1,1],r=>{r.fillStyle="#212529",r.fillRect(0,0,1,1)})}),$I}function ade(r){return Math.ceil(Math.log2(Math.max(1,r)))}function gR(){const r=As("hash_pattern");return A.useCallback((e,t)=>{const n=ade(e);return pT(r,`${t}_${n}`)},[r])}function cde(r){const e=[],n=ade(r);for(let i=0;i<=n;i++)e.push(Math.pow(2,i));return e}function cNe(r){const e=aNe();return cde(r).flatMap(t=>[{zoom:t,url:e.white,theme:"light"},{zoom:t,url:e.black,theme:"dark"}])}function lNe(){const r=he(),e=ye("devicePixelRatio",()=>r.getInstanceState().devicePixelRatio,[r]),t=ye("maxZoom",()=>Math.ceil(Zn(r.getCameraOptions().zoomSteps)),[r]),[n,i]=A.useState(!1),[o,s]=A.useState(()=>cNe(t)),a=gR();return A.useEffect(()=>{const l=Promise.all(cde(t).flatMap(f=>[VQ(e,f,!1).then(h=>({zoom:f,theme:"light",url:URL.createObjectURL(h)})),VQ(e,f,!0).then(h=>({zoom:f,theme:"dark",url:URL.createObjectURL(h)}))]));let d=!1;return l.then(f=>{d||(s(f),i(!0))}),()=>{d=!0,i(!1),l.then(f=>{for(const{url:h}of f)URL.revokeObjectURL(h)})}},[e,t]),{defs:v.jsx(v.Fragment,{children:o.map(l=>{const d=a(l.zoom,l.theme);return v.jsx("pattern",{id:d,width:rh,height:rh,patternUnits:"userSpaceOnUse",children:v.jsx("image",{href:l.url,width:rh,height:rh})},d)})}),isReady:n}}function uNe(){const r=he(),e=A.useRef(null),{defs:t,isReady:n}=lNe();return A.useEffect(()=>{if(n&&Pr.isSafari){const i=lde(e.current);i&&r.timers.requestAnimationFrame(()=>{i.style.display="none",r.timers.requestAnimationFrame(()=>{i.style.display=""})})}},[r,n]),v.jsx("g",{ref:e,"data-testid":n?"ready-pattern-fill-defs":void 0,children:t})}function lde(r){return r.classList.contains("tl-html-layer")?r:r.parentElement?lde(r.parentElement):null}const mi=lr.memo(function({theme:e,d:t,color:n,fill:i,scale:o}){switch(i){case"none":return null;case"solid":return v.jsx("path",{fill:e[n].semi,d:t});case"semi":return v.jsx("path",{fill:e.solid,d:t});case"fill":return v.jsx("path",{fill:e[n].fill,d:t});case"pattern":return v.jsx(dNe,{theme:e,color:n,fill:i,d:t,scale:o})}});function dNe({d:r,color:e,theme:t}){const n=he(),i=op(),o=ye("zoomLevel",()=>n.getZoomLevel(),[n]),s=gR(),a=n.getZoomLevel()<=.18;return v.jsxs(v.Fragment,{children:[v.jsx("path",{fill:t[e].pattern,d:r}),v.jsx("path",{fill:i?`url(#${s(1,t.id)})`:a?t[e].semi:`url(#${s(o,t.id)})`,d:r})]})}function fNe(r){return r.replace(/\s/g," ")}function fC(r,e,t){const{padding:n=0}=t;if(e.length===0)return null;const i=He.From(e[0].box);for(const{box:l}of e)i.union(l);const o=n+(t.offsetX??0),s=(t.offsetY??0)+t.fontSize/2+(t.verticalTextAlign==="start"?n:t.verticalTextAlign==="end"?t.height-n-i.height:(Math.ceil(t.height)-i.height)/2);let a=null;const c=[];for(const{text:l,box:d}of e)a!==null&&d.y>a&&c.push(v.jsx("tspan",{alignmentBaseline:"mathematical",x:o,y:d.y+s,children:`
358
- `},c.length)),c.push(v.jsx("tspan",{alignmentBaseline:"mathematical",x:d.x+o,y:d.y+s,unicodeBidi:"plaintext",children:fNe(l)},c.length)),a=d.y;return v.jsx("text",{fontSize:t.fontSize,fontFamily:t.fontFamily,fontStyle:t.fontStyle,fontWeight:t.fontWeight,dominantBaseline:"mathematical",alignmentBaseline:"mathematical",stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,children:c})}function hNe(r,e,t,n){if((r==="start-legacy"||r==="end-legacy")&&t.length!==0){const i=He.From(t[0].box);for(const{box:o}of t)i.union(o);if(r==="start-legacy")return(n-2*e-i.width)/2;if(r==="end-legacy")return-(n-2*e-i.width)/2}}function pNe(r){return r==="start-legacy"||r==="middle-legacy"||r==="end-legacy"}function oS({fontSize:r,font:e,align:t,verticalAlign:n,text:i,labelColor:o,bounds:s,padding:a=16,stroke:c=!0}){const l=he(),d=fs(),f={fontSize:r,fontFamily:tte[e],textAlign:t,verticalTextAlign:n,width:Math.ceil(s.width),height:Math.ceil(s.height),padding:a,lineHeight:Ii.lineHeight,fontStyle:"normal",fontWeight:"normal",overflow:"wrap",offsetX:0,offsetY:0,fill:o,stroke:void 0,strokeWidth:void 0},h=l.textMeasure.measureTextSpans(i,f),g=hNe(t,a,h,s.width);g&&(f.offsetX=g),f.offsetX+=s.x,f.offsetY+=s.y;const m=fC(l,h,f);let y=null;return c&&(f.fill=d.background,f.stroke=d.background,f.strokeWidth=2,y=fC(l,h,f)),v.jsxs(v.Fragment,{children:[y,m]})}const gNe=A.forwardRef(function({isEditing:e,text:t,handleFocus:n,handleChange:i,handleKeyDown:o,handleBlur:s,handleInputPointerDown:a,handleDoubleClick:c},l){return v.jsx("textarea",{ref:l,className:"tl-text tl-text-input",name:"text",tabIndex:-1,disabled:!e,readOnly:!e,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",autoSave:"off",placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",defaultValue:t,onFocus:n,onChange:i,onKeyDown:o,onBlur:s,onTouchEnd:wn,onContextMenu:e?wn:void 0,onPointerDown:a,onDoubleClick:c,onDragStart:Qt})});function vNe(r,e,t){const n=he(),i=A.useRef(null),o=ye("isEditing",()=>n.getEditingShapeId()===r,[n]),s=ye("isEditingAnything",()=>!!n.getEditingShapeId(),[n]);A.useEffect(()=>{function d(f){var h;f.shapeId===r&&((h=i.current)==null||h.select())}return n.on("select-all-text",d),()=>{n.off("select-all-text",d)}},[n,r,o]),A.useEffect(()=>{var d,f,h,g;o&&(document.activeElement!==i.current&&((d=i.current)==null||d.focus()),n.getInstanceState().isCoarsePointer&&((f=i.current)==null||f.select()),Pr.isSafari&&((h=i.current)==null||h.blur(),(g=i.current)==null||g.focus()))},[n,o]);const a=A.useCallback(d=>{if(n.getEditingShapeId()===r)switch(d.key){case"Enter":{(d.ctrlKey||d.metaKey)&&n.complete();break}}},[n,r]),c=A.useCallback(d=>{if(n.getEditingShapeId()!==r)return;let f=Id.normalizeText(d.currentTarget.value);const h=f.replace(/\t/g,hd);if(h!==f){const g=d.currentTarget.selectionStart;d.currentTarget.value=h,d.currentTarget.selectionStart=g+(h.length-f.length),d.currentTarget.selectionEnd=g+(h.length-f.length),f=h}n.updateShape({id:r,type:e,props:{text:f}})},[n,r,e]),l=A.useCallback(d=>{n.dispatch({...Ao(d),type:"pointer",name:"pointer_down",target:"shape",shape:n.getShape(r)}),wn(d)},[n,r]);return{rInput:i,handleFocus:gh,handleBlur:gh,handleKeyDown:a,handleChange:c,handleInputPointerDown:l,handleDoubleClick:wn,isEmpty:t.trim().length===0,isEditing:o,isEditingAnything:s}}const sS=lr.memo(function({shapeId:e,type:t,text:n,labelColor:i,font:o,fontSize:s,lineHeight:a,align:c,verticalAlign:l,wrap:d,isSelected:f,padding:h=0,onKeyDown:g,classNamePrefix:m,style:y,textWidth:x,textHeight:_}){const{rInput:w,isEmpty:I,isEditing:b,isEditingAnything:P,...C}=vNe(e,t,n),[k,O]=A.useState(n);A.useEffect(()=>{b||O(n)},[b,n]);const L=Id.normalizeTextForDom(n),j=L.length>0,F=pNe(c);if(!b&&!j)return null;const $=m||"tl-text";return v.jsx("div",{className:`${$}-label tl-text-wrapper`,"data-font":o,"data-align":c,"data-hastext":!I,"data-isediting":b,"data-iseditinganything":P,"data-textwrap":!!d,"data-isselected":f,style:{justifyContent:c==="middle"||F?"center":c,alignItems:l==="middle"?"center":l,padding:h,...y},children:v.jsxs("div",{className:`${$}-label__inner tl-text-content__wrapper`,style:{fontSize:s,lineHeight:Math.floor(s*a)+"px",minHeight:Math.floor(s*a)+"px",minWidth:Math.ceil(x||0),color:i,width:x?Math.ceil(x):void 0,height:_?Math.ceil(_):void 0},children:[v.jsx("div",{className:`${$} tl-text tl-text-content`,dir:"auto",children:L.split(`
359
- `).map((D,N)=>v.jsx("div",{dir:"auto",children:D},N))}),(P||f)&&v.jsx(gNe,{ref:w,text:n,isEditing:b,...C,handleKeyDown:g??C.handleKeyDown},k)]})})}),mNe=new js;function yNe(r){return mNe.get(r,()=>r.store.createComputedCache("arrowLabelSize",e=>{const t=ua(r,e);let n=0,i=0;const o=t.isStraight?new Qa({start:T.From(t.start.point),end:T.From(t.end.point)}):new dd({center:T.Cast(t.handleArc.center),start:T.Cast(t.start.point),end:T.Cast(t.end.point),sweepFlag:t.bodyArc.sweepFlag,largeArcFlag:t.bodyArc.largeArcFlag});if(e.props.text.trim()){const s=o.bounds,a=hC(e),{w:c,h:l}=r.textMeasure.measureText(e.props.text,{...Ii,fontFamily:ac[e.props.font],fontSize:a,maxWidth:null});n=c,i=l;let d=!1;if(s.width>s.height?(n=Math.max(Math.min(c,64),Math.min(s.width-64,c)),d=!0):n>16*a&&(n=16*a,d=!0),d){const{w:f,h}=r.textMeasure.measureText(e.props.text,{...Ii,fontFamily:ac[e.props.font],fontSize:a,maxWidth:n});n=f,i=h}}return new T(n,i).addScalar(dR*2*e.props.scale)}))}function vR(r,e){return e.props.text.trim()===""?new T(0,0).addScalar(dR*2*e.props.scale):yNe(r).get(e.id)??new T(0,0)}function ude(r){const e=Ei[r.props.size];return(aFe+(e-Ei.s)*2+(e===Ei.xl?20:0))*r.props.scale}function SNe(r,e,t){const n=vR(r,e),i=ude(e),o=T.Nudge(t.start.point,t.end.point,i),s=T.Nudge(t.end.point,t.start.point,i),a=oA(o,s,He.FromCenter(t.middle,n).corners);if(!a||a.length!==2)return{start:.5,end:.5};let[c,l]=a;T.Dist2(c,o)>T.Dist2(l,o)&&([l,c]=a);const d=o.add(T.Sub(t.middle,c)),f=s.add(T.Sub(t.middle,l)),h=T.Dist(t.start.point,d)/t.length,g=T.Dist(t.start.point,f)/t.length;return{start:h,end:g}}function xNe(r,e,t){const n=vR(r,e),i=ude(e),o=Math.sign(e.props.bend),s=i/t.handleArc.radius*o,a=T.Angle(t.bodyArc.center,t.start.point)-s,c=T.Angle(t.bodyArc.center,t.end.point)+s,l=Gl(t.bodyArc.center,t.bodyArc.radius,a),d=Gl(t.bodyArc.center,t.bodyArc.radius,c),f=[],h=ZQ(t.bodyArc.center,t.bodyArc.radius,a,c,o,He.FromCenter(l,n).corners);f.push(new mn({points:He.FromCenter(l,n).corners,debugColor:"lime",isFilled:!1,ignore:!0}));const g=ZQ(t.bodyArc.center,t.bodyArc.radius,a,c,o,He.FromCenter(d,n).corners);f.push(new mn({points:He.FromCenter(d,n).corners,debugColor:"lime",isFilled:!1,ignore:!0}));for(const k of[...h??[],...g??[],l,d])f.push(new yA({x:k.x-3,y:k.y-3,radius:3,isFilled:!1,debugColor:"magenta",ignore:!0}));const m=(h&&QQ(t.start.point,h))??t.middle,y=(g&&QQ(t.end.point,g))??t.middle,x=T.Angle(t.bodyArc.center,t.start.point),_=T.Angle(t.bodyArc.center,t.end.point),w=T.Angle(t.bodyArc.center,m),I=T.Angle(t.bodyArc.center,y);if(zc(x,w,o)>zc(x,I,o))return{start:.5,end:.5,dbg:f};const b=zc(x,_,o),P=zc(x,w,o)/b,C=zc(x,I,o)/b;return{start:P,end:C,dbg:f}}function yv(r,e){let t;const n=[],i=ua(r,e),o={hasStartBinding:!!i.bindings.start,hasEndBinding:!!i.bindings.end,hasStartArrowhead:i.start.arrowhead!=="none",hasEndArrowhead:i.end.arrowhead!=="none"};if(i.isStraight){const a=SNe(r,e,i),c=XQ(r,e,a,o);t=T.Lrp(i.start.point,i.end.point,c)}else{const a=xNe(r,e,i);a.dbg&&n.push(...a.dbg);const c=XQ(r,e,a,o),l=_Ne(T.Angle(i.bodyArc.center,i.start.point),T.Angle(i.bodyArc.center,i.end.point),Math.sign(e.props.bend),c);t=Gl(i.bodyArc.center,i.bodyArc.radius,l)}const s=vR(r,e);return{box:He.FromCenter(t,s),debugGeom:n}}function XQ(r,e,t,n){const{hasEndArrowhead:i,hasEndBinding:o,hasStartBinding:s,hasStartArrowhead:a}=n,c=pde(r,e);let l=Yn(e.props.labelPosition,a||s?t.start:0,i||o?t.end:1);const d=Math.min(.02,500/c*.02);return l=l>=.5-d&&l<=.5+d?.5:l,l}function ZQ(r,e,t,n,i,o){const s=jP(r,e,o),a=zc(t,n,i);return s==null?void 0:s.filter(c=>{const l=zc(t,T.Angle(r,c),i);return l>=0&&l<=a})}function QQ(r,e){let t=null,n=-1/0;for(const i of e){const o=T.Dist2(r,i);o>n&&(t=i,n=o)}return t}function _Ne(r,e,t,n){const i=zc(r,e,t);return r+i*n*t*-1}function hC(r){return sFe[r.props.size]*r.props.scale}function wNe(r,e,t){const n=e==="end"?r.end.point:r.start.point,i=e==="end"?r.start.point:r.end.point,o=r.isStraight?T.Dist(i,n):Math.abs(r.bodyArc.length),s=Math.max(Math.min(o/5,t*3),t);let a;if(r.isStraight)a=T.Nudge(n,i,s);else{const c=uTe(n,s,r.handleArc.center,r.handleArc.radius);a=e==="end"?r.handleArc.sweepFlag?c[0]:c[1]:r.handleArc.sweepFlag?c[1]:c[0]}return T.IsNaN(a)&&(a=r.start.point),{point:n,int:a}}function bNe({point:r,int:e}){const t=T.RotWith(e,r,hr/6),n=T.RotWith(e,r,-hr/6);return`M ${t.x} ${t.y} L ${r.x} ${r.y} L ${n.x} ${n.y}`}function ENe({point:r,int:e}){const t=T.RotWith(e,r,hr/6),n=T.RotWith(e,r,-hr/6);return`M ${t.x} ${t.y} L ${n.x} ${n.y} L ${r.x} ${r.y} Z`}function INe({point:r,int:e}){const t=T.Sub(e,r).div(2),n=T.Add(r,T.Rot(t,Nr)),i=T.Sub(r,T.Rot(t,Nr));return`M ${n.x} ${n.y} L ${e.x} ${e.y} L ${i.x} ${i.y} Z`}function PNe({point:r,int:e}){const t=T.Lrp(r,e,.45),n=T.Dist(t,r);return`M ${t.x-n},${t.y}
360
- a ${n},${n} 0 1,0 ${n*2},0
361
- a ${n},${n} 0 1,0 -${n*2},0 `}function CNe({point:r,int:e}){const t=T.Lrp(r,e,.75),n=T.RotWith(t,r,hr/4),i=T.RotWith(t,r,-hr/4),o=T.Lrp(n,i,.5);return o.add(T.Sub(o,r)),`M ${o.x} ${o.y} L ${i.x} ${i.y} ${r.x} ${r.y} L ${n.x} ${n.y} Z`}function TNe({int:r,point:e}){const t=T.Lrp(e,r,.85),n=T.Sub(t,e).div(2),i=T.Add(e,T.Rot(n,Nr)),o=T.Sub(e,T.Rot(n,Nr)),s=T.Add(t,T.Rot(n,Nr)),a=T.Sub(t,T.Rot(n,Nr));return`M ${i.x} ${i.y} L ${s.x} ${s.y} L ${a.x} ${a.y} L ${o.x} ${o.y} Z`}function ANe({int:r,point:e}){const t=T.Sub(r,e).div(2),n=T.Add(e,T.Rot(t,Nr)),i=T.Sub(e,T.Rot(t,Nr));return`M ${n.x} ${n.y} L ${i.x} ${i.y}`}function mm(r,e,t){const n=e==="end"?r.end.arrowhead:r.start.arrowhead;if(n==="none")return;const i=wNe(r,e,t);if(i){switch(n){case"bar":return ANe(i);case"square":return TNe(i);case"diamond":return CNe(i);case"dot":return PNe(i);case"inverted":return INe(i);case"arrow":return bNe(i);case"triangle":return ENe(i)}return""}}function RNe(r){const{start:e,end:t,handleArc:{radius:n,largeArcFlag:i,sweepFlag:o}}=r;return`M${e.handle.x},${e.handle.y} A${n} ${n} 0 ${i} ${o} ${t.handle.x},${t.handle.y}`}function dde(r){const{start:e,end:t,bodyArc:{radius:n,largeArcFlag:i,sweepFlag:o}}=r;return`M${e.point.x},${e.point.y} A${n} ${n} 0 ${i} ${o} ${t.point.x},${t.point.y}`}function fde(r,e){return`M${r.x},${r.y}L${e.x},${e.y}`}function kNe(r){return fde(r.start.handle,r.end.handle)}function hde(r){return fde(r.start.point,r.end.point)}class Sv extends Rs{constructor(){super(...arguments);q(this,"_resizeInitialBindings",new js)}canEdit(){return!0}canBind({toShapeType:t}){return t!=="arrow"}canSnap(){return!1}hideResizeHandles(){return!0}hideRotateHandle(){return!0}hideSelectionBoundsBg(){return!0}hideSelectionBoundsFg(){return!0}canBeLaidOut(t,n){if(n.type==="flip"){const i=fo(this.editor,t),{start:o,end:s}=i,{shapes:a=[]}=n;if(o&&!a.find(c=>c.id===o.toId)||s&&!a.find(c=>c.id===s.toId))return!1}return!0}getDefaultProps(){return{dash:"draw",size:"m",fill:"none",color:"black",labelColor:"black",bend:0,start:{x:0,y:0},end:{x:2,y:0},arrowheadStart:"none",arrowheadEnd:"arrow",text:"",labelPosition:.5,font:"draw",scale:1}}getGeometry(t){const n=ua(this.editor,t),i=[],o=n.isStraight?new Qa({start:T.From(n.start.point),end:T.From(n.end.point)}):new dd({center:T.Cast(n.handleArc.center),start:T.Cast(n.start.point),end:T.Cast(n.end.point),sweepFlag:n.bodyArc.sweepFlag,largeArcFlag:n.bodyArc.largeArcFlag});let s;if(t.props.text.trim()){const a=yv(this.editor,t);i.push(...a.debugGeom),s=new ma({x:a.box.x,y:a.box.y,width:a.box.w,height:a.box.h,isFilled:!0,isLabel:!0})}return new cs({children:[...s?[o,s]:[o],...i]})}getHandles(t){const n=ua(this.editor,t);return[{id:"start",type:"vertex",index:"a0",x:n.start.handle.x,y:n.start.handle.y},{id:"middle",type:"virtual",index:"a2",x:n.middle.x,y:n.middle.y},{id:"end",type:"vertex",index:"a3",x:n.end.handle.x,y:n.end.handle.y}].filter(Boolean)}getText(t){return t.props.text}onHandleDrag(t,{handle:n,isPrecise:i}){const o=n.id,s=fo(this.editor,t);if(o==="middle"){const{start:C,end:k}=fd(this.editor,t,s),O=T.Sub(k,C),L=T.Per(O),j=T.Med(k,C),F=T.Sub(j,L),$=T.Add(j,L),D=T.NearestPointOnLineSegment(F,$,n,!1);let N=T.Dist(D,j);return T.Clockwise(D,k,j)&&(N*=-1),{id:t.id,type:t.type,props:{bend:N}}}const a={id:t.id,type:"arrow",props:{}},c=s[o],d=s[o==="start"?"end":"start"];if(this.editor.inputs.ctrlKey)return pv(this.editor,t,o),a.props[o]={x:n.x,y:n.y},a;const f=this.editor.getShapePageTransform(t.id).applyToPoint(n),h=this.editor.getShapeAtPoint(f,{hitInside:!0,hitFrameInside:!0,margin:0,filter:C=>!C.isLocked&&this.editor.canBindShapes({fromShape:t,toShape:C,binding:"arrow"})});if(!h){pv(this.editor,t,o);const C=ks(new T(n.x,n.y),this.editor);return a.props[o]={x:C.x,y:C.y},a}const g=this.editor.getShapeGeometry(h),m=He.ZeroFix(g.bounds),x=this.editor.getShapePageTransform(a.id).applyToPoint(n),_=this.editor.getPointInShapeSpace(h,x);let w=i;w||(!c||c&&h.id!==c.toId)&&(w=this.editor.inputs.pointerVelocity.len()<.5),i||(g.isClosed||(w=!0),d&&h.id===d.toId&&d.props.isPrecise&&(w=!0));const I={x:(_.x-m.minX)/m.width,y:(_.y-m.minY)/m.height};w&&T.Dist(_,m.center)<Math.max(4,Math.min(Math.min(m.width,m.height)*.15,16))/this.editor.getZoomLevel()&&(I.x=.5,I.y=.5);const b={terminal:o,normalizedAnchor:I,isPrecise:w,isExact:this.editor.inputs.altKey};Hf(this.editor,t,h.id,b),this.editor.setHintingShapes([h.id]);const P=fo(this.editor,t);return P.start&&P.end&&P.start.toId===P.end.toId&&T.Equals(P.start.props.normalizedAnchor,P.end.props.normalizedAnchor)&&Hf(this.editor,t,P.end.toId,{...P.end.props,normalizedAnchor:{x:P.end.props.normalizedAnchor.x+.05,y:P.end.props.normalizedAnchor.y}}),a}onTranslateStart(t){const n=fo(this.editor,t),i=fd(this.editor,t,n),o=this.editor.getShapePageTransform(t.id),s=this.editor.getSelectedShapeIds();if(!(n.start&&(s.includes(n.start.toId)||this.editor.isAncestorSelected(n.start.toId))||n.end&&(s.includes(n.end.toId)||this.editor.isAncestorSelected(n.end.toId)))){eJ.set(t,{pagePosition:o.applyToPoint(t),terminalBindings:jh(i,(a,c)=>{const l=n[a];return l?{binding:l,shapePosition:c,pagePosition:o.applyToPoint(c)}:null})}),n.start&&(vm({editor:this.editor,arrow:t,terminal:"start",useHandle:!0}),t=this.editor.getShape(t.id)),n.end&&vm({editor:this.editor,arrow:t,terminal:"end",useHandle:!0});for(const a of["start","end"]){const c=n[a];c&&this.editor.updateBinding({...c,props:{...c.props,isPrecise:!0}})}}}onTranslate(t,n){const i=eJ.get(t);if(!i)return;const o=this.editor.getShapePageTransform(n.id),s=T.Sub(o.applyToPoint(n),i.pagePosition);for(const a of Object.values(i.terminalBindings)){if(!a)continue;const c=T.Add(a.pagePosition,T.Mul(s,.5)),l=this.editor.getShapeAtPoint(c,{hitInside:!0,hitFrameInside:!0,margin:0,filter:d=>!d.isLocked&&this.editor.canBindShapes({fromShape:n,toShape:d,binding:"arrow"})});if((l==null?void 0:l.id)===a.binding.toId){const d=He.ZeroFix(this.editor.getShapeGeometry(l).bounds),f=this.editor.getPointInShapeSpace(l,c),h={x:(f.x-d.minX)/d.width,y:(f.y-d.minY)/d.height};Hf(this.editor,n,l.id,{...a.binding.props,normalizedAnchor:h,isPrecise:!0})}else pv(this.editor,n,a.binding.props.terminal)}}onResize(t,n){const{scaleX:i,scaleY:o}=n,s=this._resizeInitialBindings.get(t,()=>fo(this.editor,t)),a=fd(this.editor,t,s),{start:c,end:l}=Kr(t.props);let{bend:d}=t.props;s.start||(c.x=a.start.x*i,c.y=a.start.y*o),s.end||(l.x=a.end.x*i,l.y=a.end.y*o);const f=Math.abs(i),h=Math.abs(o),g=s!=null&&s.start?T.From(s.start.props.normalizedAnchor):null,m=s!=null&&s.end?T.From(s.end.props.normalizedAnchor):null;return i<0&&o>=0?(d!==0&&(d*=-1,d*=Math.max(f,h)),g&&(g.x=1-g.x),m&&(m.x=1-m.x)):i>=0&&o<0?(d!==0&&(d*=-1,d*=Math.max(f,h)),g&&(g.y=1-g.y),m&&(m.y=1-m.y)):i>=0&&o>=0?d!==0&&(d*=Math.max(f,h)):i<0&&o<0&&(d!==0&&(d*=Math.max(f,h)),g&&(g.x=1-g.x,g.y=1-g.y),m&&(m.x=1-m.x,m.y=1-m.y)),s.start&&g&&Hf(this.editor,t,s.start.toId,{...s.start.props,normalizedAnchor:g.toJson()}),s.end&&m&&Hf(this.editor,t,s.end.toId,{...s.end.props,normalizedAnchor:m.toJson()}),{props:{start:c,end:l,bend:d}}}onDoubleClickHandle(t,n){switch(n.id){case"start":return{id:t.id,type:t.type,props:{...t.props,arrowheadStart:t.props.arrowheadStart==="none"?"arrow":"none"}};case"end":return{id:t.id,type:t.type,props:{...t.props,arrowheadEnd:t.props.arrowheadEnd==="none"?"arrow":"none"}}}}component(t){const n=fs(),i=this.editor.getOnlySelectedShape(),o=this.editor.isInAny("select.idle","select.pointing_handle","select.dragging_handle","select.translating","arrow.dragging")&&!this.editor.getIsReadonly(),s=ua(this.editor,t);if(!(s!=null&&s.isValid))return null;const a=yv(this.editor,t),c=t.id===this.editor.getOnlySelectedShapeId(),d=this.editor.getEditingShapeId()===t.id||t.props.text;return v.jsxs(v.Fragment,{children:[v.jsx(Jc,{style:{minWidth:50,minHeight:50},children:v.jsx(JQ,{shape:t,shouldDisplayHandles:o&&(i==null?void 0:i.id)===t.id})}),d&&v.jsx(sS,{shapeId:t.id,classNamePrefix:"tl-arrow",type:"arrow",font:t.props.font,fontSize:hC(t),lineHeight:Ii.lineHeight,align:"middle",verticalAlign:"middle",text:t.props.text,labelColor:n[t.props.labelColor].solid,textWidth:a.box.w-dR*2*t.props.scale,isSelected:c,padding:0,style:{transform:`translate(${a.box.center.x}px, ${a.box.center.y}px)`}})]})}indicator(t){const n=My(t.id),i=As(t.id+"_clip"),o=ua(this.editor,t);if(!o)return null;const{start:s,end:a}=fd(this.editor,t,o==null?void 0:o.bindings),c=this.editor.getShapeGeometry(t),l=c.bounds,d=t.props.text.trim()?c.children[1]:null;if(T.Equals(s,a))return null;const f=Ei[t.props.size]*t.props.scale,h=o.start.arrowhead&&mm(o,"start",f),g=o.end.arrowhead&&mm(o,"end",f),m=o.isStraight?hde(o):dde(o),y=h&&o.start.arrowhead!=="arrow"||g&&o.end.arrowhead!=="arrow"||!!d;if(n&&d)return v.jsx("rect",{x:fe(d.x),y:fe(d.y),width:d.w,height:d.h,rx:3.5*t.props.scale,ry:3.5*t.props.scale});const x=!(o.start.arrowhead==="none"||o.start.arrowhead==="arrow"),_=!(o.end.arrowhead==="none"||o.end.arrowhead==="arrow");return v.jsxs("g",{children:[y&&v.jsx("defs",{children:v.jsx(gde,{hasText:t.props.text.trim().length>0,bounds:l,labelBounds:d?d.getBounds():new He(0,0,0,0),as:x&&h?h:"",ae:_&&g?g:""})}),v.jsxs("g",{style:{clipPath:y?`url(#${i})`:void 0,WebkitClipPath:y?`url(#${i})`:void 0},children:[y&&v.jsx("rect",{x:l.minX-100,y:l.minY-100,width:l.width+200,height:l.height+200,opacity:0}),v.jsx("path",{d:m})]}),h&&v.jsx("path",{d:h}),g&&v.jsx("path",{d:g}),d&&v.jsx("rect",{x:fe(d.x),y:fe(d.y),width:d.w,height:d.h,rx:3.5,ry:3.5})]})}onEditEnd(t){const{id:n,type:i,props:{text:o}}=t;o.trimEnd()!==t.props.text&&this.editor.updateShapes([{id:n,type:i,props:{text:o.trimEnd()}}])}toSvg(t,n){n.addExportDef(hR(t.props.fill)),t.props.text&&n.addExportDef(iS(t.props.font));const i=uc(n),o=1/t.props.scale;return v.jsxs("g",{transform:`scale(${o})`,children:[v.jsx(JQ,{shape:t,shouldDisplayHandles:!1}),v.jsx(oS,{fontSize:hC(t),font:t.props.font,align:"middle",verticalAlign:"middle",text:t.props.text,labelColor:i[t.props.labelColor].solid,bounds:yv(this.editor,t).box.clone().expandBy(-4.25*t.props.scale),padding:0})]})}getCanvasSvgDefs(){return[pR(),{key:"arrow:dot",component:ONe},{key:"arrow:cross",component:MNe}]}getInterpolatedProps(t,n,i){return{...i>.5?n.props:t.props,scale:or(t.props.scale,n.props.scale,i),start:{x:or(t.props.start.x,n.props.start.x,i),y:or(t.props.start.y,n.props.start.y,i)},end:{x:or(t.props.end.x,n.props.end.x,i),y:or(t.props.end.y,n.props.end.y,i)},bend:or(t.props.bend,n.props.bend,i),labelPosition:or(t.props.labelPosition,n.props.labelPosition,i)}}}q(Sv,"type","arrow"),q(Sv,"props",nte),q(Sv,"migrations",ite);function pde(r,e){const t=ua(r,e);return t.isStraight?T.Dist(t.start.handle,t.end.handle):Math.abs(t.handleArc.length)}const JQ=ii(function({shape:e,shouldDisplayHandles:t}){const n=he(),i=fs(),o=ua(n,e),s=He.ZeroFix(n.getShapeGeometry(e).bounds),a=fo(n,e),c=ye("force solid",()=>n.getZoomLevel()<.2,[n]),l=As(e.id+"_clip"),d=As("arrowhead-dot"),f=As("arrowhead-cross");if(!(o!=null&&o.isValid))return null;const h=Ei[e.props.size]*e.props.scale,g=o.start.arrowhead&&mm(o,"start",h),m=o.end.arrowhead&&mm(o,"end",h),y=o.isStraight?hde(o):dde(o);let x=null;if(t){const C=2/n.getZoomLevel(),{strokeDasharray:k,strokeDashoffset:O}=Ps(pde(n,e),C,{end:"skip",start:"skip",lengthRatio:2.5});x=a.start||a.end?v.jsx("path",{className:"tl-arrow-hint",d:o.isStraight?kNe(o):RNe(o),strokeDasharray:k,strokeDashoffset:O,strokeWidth:C,markerStart:a.start?a.start.props.isExact?"":a.start.props.isPrecise?`url(#${f})`:`url(#${d})`:"",markerEnd:a.end?a.end.props.isExact?"":a.end.props.isPrecise?`url(#${f})`:`url(#${d})`:"",opacity:.16}):null}const{strokeDasharray:_,strokeDashoffset:w}=Ps(o.isStraight?o.length:Math.abs(o.bodyArc.length),h,{style:e.props.dash,forceSolid:c}),I=yv(n,e),b=!(o.start.arrowhead==="none"||o.start.arrowhead==="arrow"),P=!(o.end.arrowhead==="none"||o.end.arrowhead==="arrow");return v.jsxs(v.Fragment,{children:[v.jsx("defs",{children:v.jsx("clipPath",{id:l,children:v.jsx(gde,{hasText:e.props.text.trim().length>0,bounds:s,labelBounds:I.box,as:b&&g?g:"",ae:P&&m?m:""})})}),v.jsxs("g",{fill:"none",stroke:i[e.props.color].solid,strokeWidth:h,strokeLinejoin:"round",strokeLinecap:"round",pointerEvents:"none",children:[x,v.jsxs("g",{style:{clipPath:`url(#${l})`,WebkitClipPath:`url(#${l})`},children:[v.jsx("rect",{x:fe(s.minX-100),y:fe(s.minY-100),width:fe(s.width+200),height:fe(s.height+200),opacity:0}),v.jsx("path",{d:y,strokeDasharray:_,strokeDashoffset:w})]}),g&&b&&e.props.fill!=="none"&&v.jsx(mi,{theme:i,d:g,color:e.props.color,fill:e.props.fill,scale:e.props.scale}),m&&P&&e.props.fill!=="none"&&v.jsx(mi,{theme:i,d:m,color:e.props.color,fill:e.props.fill,scale:e.props.scale}),g&&v.jsx("path",{d:g}),m&&v.jsx("path",{d:m})]})]})});function gde({hasText:r,bounds:e,labelBounds:t,as:n,ae:i}){const o=`M${fe(e.minX-100)},${fe(e.minY-100)} h${e.width+200} v${e.height+200} h-${e.width+200} Z`,s=`M${fe(t.minX)},${fe(t.minY)} v${t.height} h${t.width} v-${t.height} Z`;return v.jsx("path",{d:`${o}${r?s:""}${n}${i}`})}const eJ=new WeakMap;function ONe(){const r=As("arrowhead-dot");return v.jsx("marker",{id:r,className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"0",children:v.jsx("circle",{cx:"3",cy:"3",r:"2",strokeDasharray:"100%"})})}function MNe(){const r=As("arrowhead-cross");return v.jsxs("marker",{id:r,className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"auto",children:[v.jsx("line",{x1:"1.5",y1:"1.5",x2:"4.5",y2:"4.5",strokeDasharray:"100%"}),v.jsx("line",{x1:"1.5",y1:"4.5",x2:"4.5",y2:"1.5",strokeDasharray:"100%"})]})}const tJ="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' fill='none'%3E%3Cpath stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M13 5H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6M19 5h6m0 0v6m0-6L13 17'/%3E%3C/svg%3E";function Pd({url:r}){const e=he(),t=ye("zoomLevel",()=>e.getZoomLevel()<.32,[e]);return v.jsx("a",{className:bt("tl-hyperlink-button",{"tl-hyperlink-button__hidden":t}),href:r,target:"_blank",rel:"noopener noreferrer",onPointerDown:wn,onPointerUp:wn,title:r,draggable:!1,children:v.jsx("div",{className:"tl-hyperlink__icon",style:{mask:`url("${tJ}") center 100% / 100% no-repeat`,WebkitMask:`url("${tJ}") center 100% / 100% no-repeat`}})})}const rJ="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' fill='none'%3E%3Cpath stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M13 5H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6M19 5h6m0 0v6m0-6L13 17'/%3E%3C/svg%3E",jNe=[{offsetX:0,offsetY:2,blur:4,spread:0,color:"#00000029"},{offsetX:0,offsetY:3,blur:6,spread:0,color:"#0000001f"}];function ym(r){return jNe.map(t=>{const{offsetX:n,offsetY:i,blur:o,spread:s,color:a}=t,c=new T(n,i),{x:l,y:d}=c.rot(-r);return`${l}px ${d}px ${o}px ${s}px ${a}`}).join(", ")}const DNe=300,vde=320,LNe=46,FNe=101;class xv extends Qd{canResize(){return!1}hideSelectionBoundsFg(){return!0}getText(e){return e.props.url}getDefaultProps(){return{url:"",w:DNe,h:vde,assetId:null}}component(e){return v.jsx(NNe,{shape:e,util:this})}indicator(e){return v.jsx("rect",{width:fe(e.props.w),height:fe(e.props.h),rx:"6",ry:"6"})}onBeforeCreate(e){return nJ(this.editor,e)}onBeforeUpdate(e,t){if(e.props.url!==t.props.url)if(Do.isValid(t.props.url))qNe(this.editor,t);else return{...t,props:{...t.props,url:e.props.url}};if(e.props.assetId!==t.props.assetId)return nJ(this.editor,t)}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,w:or(e.props.w,t.props.w,n),h:or(e.props.h,t.props.h,n)}}}q(xv,"type","bookmark"),q(xv,"props",ute),q(xv,"migrations",dte);function NNe({shape:r,util:e}){const t=r.props.assetId?e.editor.getAsset(r.props.assetId):null,n=!!op()&&Pr.isSafari,i=e.editor.getShapePageTransform(r).rotation(),o=$Ne(r),[s,a]=A.useState(!0),c=()=>a(!1);return v.jsx(Xc,{children:v.jsxs("div",{className:bt("tl-bookmark__container",n&&"tl-bookmark__container--safariExport"),style:{boxShadow:n?void 0:ym(i),maxHeight:r.props.h},children:[(!t||t.props.image)&&v.jsxs("div",{className:"tl-bookmark__image_container",children:[t?v.jsx("img",{className:"tl-bookmark__image",draggable:!1,referrerPolicy:"strict-origin-when-cross-origin",src:t==null?void 0:t.props.image,alt:(t==null?void 0:t.props.title)||""}):v.jsx("div",{className:"tl-bookmark__placeholder"}),(t==null?void 0:t.props.image)&&v.jsx(Pd,{url:r.props.url})]}),v.jsxs("div",{className:"tl-bookmark__copy_container",children:[t!=null&&t.props.title?v.jsx("h2",{className:"tl-bookmark__heading",children:IFe(t.props.title)}):null,t!=null&&t.props.description&&(t!=null&&t.props.image)?v.jsx("p",{className:"tl-bookmark__description",children:t.props.description}):null,v.jsxs("a",{className:"tl-bookmark__link",href:r.props.url||"",target:"_blank",rel:"noopener noreferrer",onPointerDown:wn,onPointerUp:wn,onClick:wn,children:[s&&(t!=null&&t.props.favicon)?v.jsx("img",{className:"tl-bookmark__favicon",src:t==null?void 0:t.props.favicon,referrerPolicy:"strict-origin-when-cross-origin",onError:c,alt:`favicon of ${o}`}):v.jsx("div",{className:"tl-hyperlink__icon",style:{mask:`url("${rJ}") center 100% / 100% no-repeat`,WebkitMask:`url("${rJ}") center 100% / 100% no-repeat`}}),v.jsx("span",{children:o})]})]})]})})}function nJ(r,e){const t=e.props.assetId?r.getAsset(e.props.assetId):null;let n=vde;return t&&(t.props.image||(t.props.title?n=FNe:n=LNe)),{...e,props:{...e.props,h:n}}}const $Ne=r=>{try{return new URL(r.props.url).hostname.replace(/^www\./,"")}catch{return r.props.url}};function qNe(r,e){const{url:t}=e.props,n=Qc.createId(MC(t));r.getAsset(n)?e.props.assetId!==n&&r.updateShapes([{id:e.id,type:e.type,props:{assetId:n}}]):(r.updateShapes([{id:e.id,type:e.type,props:{assetId:null}}]),BNe(r,e))}const BNe=kC(async(r,e)=>{if(r.isDisposed)return;const{url:t}=e.props,n=await r.getAssetForExternalContent({type:"url",url:t});n&&r.run(()=>{r.createAssets([n]),r.updateShapes([{id:e.id,type:e.type,props:{assetId:n.id}}])})},500);function iu(r,e=!1){const t=r.length;if(t<2)return"";let n=r[0].point,i=r[1].point;if(t===2)return`M${vr(n)}L${vr(i)}`;let o="";for(let s=2,a=t-1;s<a;s++)n=r[s].point,i=r[s+1].point,o+=uo(n,i);return e?`M${uo(r[0].point,r[1].point)}Q${vr(r[1].point)}${uo(r[1].point,r[2].point)}T${o}${uo(r[t-1].point,r[0].point)}${uo(r[0].point,r[1].point)}Z`:`M${vr(r[0].point)}Q${vr(r[1].point)}${uo(r[1].point,r[2].point)}${r.length>3?"T":""}${o}L${vr(r[t-1].point)}`}function UNe(r,e={}){const{start:t={},end:n={}}=e,{cap:i=!0}=t,{cap:o=!0}=n;Jt(!t.taper&&!n.taper,"cap taper not supported here"),Jt(!t.easing&&!n.easing,"cap easing not supported here"),Jt(i&&o,"cap must be true");const s=xa(r,e);rS(s,e);const a=zNe(s);let c="";for(const l of a)c+=WNe(l,e);return c}function zNe(r){if(r.length<=2)return[r];const e=[];let t=[r[0]],n=T.Sub(r[1].point,r[0].point).uni(),i,o,s,a,c;for(let l=1,d=r.length;l<d-1;l++){if(s=r[l-1],a=r[l],c=r[l+1],i=T.Sub(c.point,a.point).uni(),o=T.Dpr(n,i),n=i,o<-.8){const f={...a,point:a.input};t.push(f),e.push(qI(t)),t=[f];continue}if(t.push(a),!(o>.7)&&(T.Dist2(s.point,a.point)+T.Dist2(a.point,c.point))/((s.radius+a.radius+c.radius)/3)**2<1.5){t.push(a),e.push(qI(t)),t=[a];continue}}return t.push(r[r.length-1]),e.push(qI(t)),e}function qI(r){const e=r[0];let t;for(;r.length>2&&(t=r[1],T.Dist2(e.point,t.point)<((e.radius+t.radius)/2*.5)**2);)r.splice(1,1);const n=r[r.length-1];let i;for(;r.length>2&&(i=r[r.length-2],T.Dist2(n.point,i.point)<((n.radius+i.radius)/2*.5)**2);)r.splice(r.length-2,1);return r.length>1&&(r[0]={...r[0],vector:T.Sub(r[0].point,r[1].point).uni()},r[r.length-1]={...r[r.length-1],vector:T.Sub(r[r.length-2].point,r[r.length-1].point).uni()}),r}function HNe(r,e,t){return"M "+r+" "+e+" m -"+t+", 0 a "+t+","+t+" 0 1,1 "+t*2+",0 a "+t+","+t+" 0 1,1 -"+t*2+",0"}function WNe(r,e={}){if(r.length===0)return"";if(r.length===1)return HNe(r[0].point.x,r[0].point.y,r[0].radius);const{left:t,right:n}=Kue(r,e);n.reverse();let i=`M${vr(t[0])}T`;for(let o=1;o<t.length;o++)i+=uo(t[o-1],t[o]);{const o=r[r.length-1],s=o.radius,a=o.vector.clone().per().neg(),c=T.Add(o.point,T.Mul(a,s)),l=T.Add(o.point,T.Mul(a,-s));i+=`${vr(c)}A${fe(s)},${fe(s)} 0 0 1 ${vr(l)}T`}for(let o=1;o<n.length;o++)i+=uo(n[o-1],n[o]);{const o=r[0],s=o.radius,a=o.vector.clone().per(),c=T.Add(o.point,T.Mul(a,s)),l=T.Add(o.point,T.Mul(a,-s));i+=`${vr(c)}A${fe(s)},${fe(s)} 0 0 1 ${vr(l)}Z`}return i}const mde=(r,e,t)=>{const n=[],i=[];r.forEach(l=>n.push(...l.points)),e.forEach(l=>i.push(...l.points));const o=Math.max(n.length,i.length),s=[],a=[];for(let l=0;l<o;l++)s.push(n[l]||n[n.length-1]),a.push(i[l]||i[i.length-1]);return[{type:"free",points:s.map((l,d)=>{let f=.5;return a[d].z!==void 0&&l.z!==void 0&&(f=or(l.z,a[d].z,t)),{x:or(l.x,a[d].x,t),y:or(l.y,a[d].y,t),z:f}})}]},KNe=r=>r*.65+Yve(r*hr/2)*.35,GNe=r=>({size:r,thinning:.5,streamline:_d(r,[9,16],[.64,.74],!0),smoothing:.62,easing:zn.easeOutSine,simulatePressure:!0}),VNe=r=>({size:1+r*1.2,thinning:.62,streamline:.62,smoothing:.62,simulatePressure:!1,easing:KNe}),iJ=r=>({size:r,thinning:0,streamline:_d(r,[9,16],[.64,.74],!0),smoothing:.62,simulatePressure:!1,easing:zn.linear}),YNe=r=>({size:r,thinning:0,streamline:.62,smoothing:.62,simulatePressure:!1,easing:zn.linear});function mR({strokeWidth:r,showAsComplete:e}){return{size:1+r,thinning:0,streamline:.5,smoothing:.5,simulatePressure:!1,easing:zn.easeOutSine,last:e}}function pC(r,e,t,n){const i=r.isComplete||t;return n?r.isPen?{...YNe(e),last:i}:{...iJ(e),last:i}:r.dash==="draw"?r.isPen?{...VNe(e),last:i}:{...GNe(e),last:i}:{...iJ(e),last:i}}function Cd(r){const e=[];for(const t of r)if(t.type==="free"||t.points.length<2)e.push(...t.points.map(T.Cast));else{const n=Math.max(4,Math.floor(T.Dist(t.points[0],t.points[1])/16));e.push(...T.PointsBetween(t.points[0],t.points[1],n))}return e}function XNe(r,e,t){return{draw:"none",solid:"none",dotted:`${t} ${e*2}`,dashed:`${e*2} ${e*2}`}[r.props.dash]}class _v extends Rs{constructor(){super(...arguments);q(this,"options",{maxPointsPerShape:600})}hideResizeHandles(t){return BI(t)}hideRotateHandle(t){return BI(t)}hideSelectionBoundsFg(t){return BI(t)}getDefaultProps(){return{segments:[],color:"black",fill:"none",dash:"draw",size:"m",isComplete:!1,isClosed:!1,isPen:!1,scale:1}}getGeometry(t){const n=Cd(t.props.segments),i=(Ei[t.props.size]+1)*t.props.scale;if(t.props.segments.length===1){const s=He.FromPoints(n);if(s.width<i*2&&s.height<i*2)return new yA({x:-i,y:-i,radius:i,isFilled:!0})}const o=xa(n,pC(t.props,i,t.props.isPen,!0)).map(s=>s.point);return t.props.isClosed?new mn({points:o,isFilled:t.props.fill!=="none"}):new Vd({points:o})}component(t){return v.jsx(Jc,{children:v.jsx(oJ,{shape:t})})}indicator(t){var d;const n=Cd(t.props.segments);let i=(Ei[t.props.size]+1)*t.props.scale;!ye("force solid",()=>{const f=this.editor.getZoomLevel();return f<.5&&f<1.5/i},[this.editor,i])&&!t.props.isPen&&t.props.dash==="draw"&&n.length===1&&(i+=Ds(t.id)()*(i/6));const s=t.props.isComplete||((d=Zn(t.props.segments))==null?void 0:d.type)==="straight",a=pC(t.props,i,s,!0),c=xa(n,a),l=c.length>1?iu(c,t.props.isClosed):yde(n[0],i);return v.jsx("path",{d:l})}toSvg(t,n){n.addExportDef(hR(t.props.fill));const i=1/t.props.scale;return v.jsx("g",{transform:`scale(${i})`,children:v.jsx(oJ,{shape:t,zoomOverride:1})})}getCanvasSvgDefs(){return[pR()]}onResize(t,n){const{scaleX:i,scaleY:o}=n,s=[];for(const a of t.props.segments)s.push({...a,points:a.points.map(({x:c,y:l,z:d})=>({x:Za(i*c),y:Za(o*l),z:d}))});return{props:{segments:s}}}expandSelectionOutlinePx(t){const n=t.props.dash==="draw"?1.6:1;return Ei[t.props.size]*n/2*t.props.scale}getInterpolatedProps(t,n,i){return{...i>.5?n.props:t.props,segments:mde(t.props.segments,n.props.segments,i),scale:or(t.props.scale,n.props.scale,i)}}}q(_v,"type","draw"),q(_v,"props",hte),q(_v,"migrations",pte);function yde(r,e){const t=(e+1)*.5;return`M ${r.x} ${r.y} m -${t}, 0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0`}function BI(r){return r.props.segments.length===1&&r.props.segments[0].points.length<2}function oJ({shape:r,zoomOverride:e}){var g;const t=fs(),n=he(),i=Cd(r.props.segments),o=r.props.isComplete||((g=Zn(r.props.segments))==null?void 0:g.type)==="straight";let s=(Ei[r.props.size]+1)*r.props.scale;const a=ye("force solid",()=>{const m=e??n.getZoomLevel();return m<.5&&m<1.5/s},[n,s,e]),c=ye("dot adjustment",()=>(e??n.getZoomLevel())<.2?0:.1,[n,e]);!a&&!r.props.isPen&&r.props.dash==="draw"&&i.length===1&&(s+=Ds(r.id)()*(s/6));const l=pC(r.props,s,o,a);if(!a&&r.props.dash==="draw")return v.jsxs(v.Fragment,{children:[r.props.isClosed&&r.props.fill&&i.length>1?v.jsx(mi,{d:iu(xa(i,l),r.props.isClosed),theme:t,color:r.props.color,fill:r.props.isClosed?r.props.fill:"none",scale:r.props.scale}):null,v.jsx("path",{d:UNe(i,l),strokeLinecap:"round",fill:t[r.props.color].solid})]});const d=xa(i,l),f=d.length<2,h=f?yde(i[0],0):iu(d,r.props.isClosed);return v.jsxs(v.Fragment,{children:[v.jsx(mi,{d:h,theme:t,color:r.props.color,fill:f||r.props.isClosed?r.props.fill:"none",scale:r.props.scale}),v.jsx("path",{d:h,strokeLinecap:"round",fill:f?t[r.props.color].solid:"none",stroke:t[r.props.color].solid,strokeWidth:s,strokeDasharray:f?"none":XNe(r,s,c),strokeDashoffset:"0"})]})}function ZNe(r){if(typeof r!="string")throw new TypeError("Expected a string");return r.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function QNe(r,e){const t=Ft(e);if(!t)return;const n=t.host.replace("www.","");for(const i of r)if(Sde(i.hostnames,n)){const o=i.fromEmbedUrl(e);if(o)return{definition:i,url:o,embedUrl:e}}}const JNe=r=>r.split("*").map(e=>ZNe(e)).join(".+"),Sde=(r,e)=>!!r.find(t=>{const n=new RegExp(JNe(t));return e.match(n)});function e3e(r,e){const t=Ft(e);if(!t)return;const n=t.host.replace("www.","");for(const i of r)if(Sde(i.hostnames,n)){const o=i.toEmbedUrl(e);if(o)return{definition:i,embedUrl:o,url:e}}}function t3e(r,e){try{return e3e(r,e)??QNe(r,e)}catch{return}}const r3e=r=>Object.entries(r).filter(([e,t])=>t).map(([e])=>e).join(" "),Xa=class Xa extends Qd{static setEmbedDefinitions(e){Xa.embedDefinitions=e}getEmbedDefinitions(){return Xa.embedDefinitions}getEmbedDefinition(e){return t3e(Xa.embedDefinitions,e)}getText(e){return e.props.url}hideSelectionBoundsFg(e){return!this.canResize(e)}canEdit(){return!0}canResize(e){var t,n;return!!((n=(t=this.getEmbedDefinition(e.props.url))==null?void 0:t.definition)!=null&&n.doesResize)}canEditInReadOnly(){return!0}getDefaultProps(){return{w:300,h:300,url:""}}isAspectRatioLocked(e){const t=this.getEmbedDefinition(e.props.url);return(t==null?void 0:t.definition.isAspectRatioLocked)??!1}onResize(e,t){const n=this.isAspectRatioLocked(e),i=this.getEmbedDefinition(e.props.url);let o=(i==null?void 0:i.definition.minWidth)??200,s=(i==null?void 0:i.definition.minHeight)??200;if(n){const a=e.props.w/e.props.h;a>1?o*=a:s/=a}return Oy(e,t,{minWidth:o,minHeight:s})}component(e){const t=op(),{w:n,h:i,url:o}=e.props,s=My(e.id),a=this.getEmbedDefinition(o),c=ye("is hovering",()=>{const{editingShapeId:g,hoveredShapeId:m}=this.editor.getCurrentPageState();if(g&&m!==g){const y=this.editor.getShape(g);if(y&&this.editor.isShapeOfType(y,"embed"))return!0}return!1},[]),l=this.editor.getShapePageTransform(e).rotation();if(t)return v.jsx(Xc,{className:"tl-embed-container",id:e.id,children:v.jsx("div",{className:"tl-embed",style:{border:0,boxShadow:ym(l),borderRadius:(a==null?void 0:a.definition.overrideOutlineRadius)??8,background:(a==null?void 0:a.definition.backgroundColor)??"var(--color-background)",width:n,height:i}})});const d=s||c;if(typeof window<"u"&&(window!==window.top||window.self!==window.parent)&&(a==null?void 0:a.definition.type)==="tldraw")return null;if((a==null?void 0:a.definition.type)==="github_gist"){const g=a.url.split("/").pop();if(!g)throw Error("No gist id!");return v.jsx(Xc,{className:"tl-embed-container",id:e.id,children:v.jsx(n3e,{id:g,width:fe(n),height:fe(i),isInteractive:d,pageRotation:l})})}const h=r3e({...mDe,...(a==null?void 0:a.definition.overridePermissions)??{}});return v.jsx(Xc,{className:"tl-embed-container",id:e.id,children:a!=null&&a.definition?v.jsx("iframe",{className:"tl-embed",sandbox:h,src:a.embedUrl,width:fe(n),height:fe(i),draggable:!1,frameBorder:"0",referrerPolicy:"no-referrer-when-downgrade",style:{border:0,pointerEvents:d?"auto":"none",zIndex:d?"":"-1",boxShadow:ym(l),borderRadius:(a==null?void 0:a.definition.overrideOutlineRadius)??8,background:a==null?void 0:a.definition.backgroundColor}}):null})}indicator(e){const t=this.getEmbedDefinition(e.props.url);return v.jsx("rect",{width:fe(e.props.w),height:fe(e.props.h),rx:(t==null?void 0:t.definition.overrideOutlineRadius)??8,ry:(t==null?void 0:t.definition.overrideOutlineRadius)??8})}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,w:or(e.props.w,t.props.w,n),h:or(e.props.h,t.props.h,n)}}};q(Xa,"type","embed"),q(Xa,"props",gte),q(Xa,"migrations",vte),q(Xa,"embedDefinitions",eR);let Sm=Xa;function n3e({id:r,isInteractive:e,width:t,height:n,style:i,pageRotation:o}){if(!r.match(/^[0-9a-f]+$/))throw Error("No gist id!");return v.jsx("iframe",{className:"tl-embed",draggable:!1,width:fe(t),height:fe(n),frameBorder:"0",scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",style:{...i,pointerEvents:e?"all":"none",zIndex:e?"":"-1",boxShadow:ym(o)},srcDoc:`
362
- <html>
363
- <head>
364
- <base target="_blank">
365
- </head>
366
- <body>
367
- <script src=${`https://gist.github.com/${r}.js`}><\/script>
368
- <style type="text/css">
369
- * { margin: 0px; }
370
- table { height: 100%; background-color: red; }
371
- .gist { background-color: none; height: 100%; }
372
- .gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
373
- </style>
374
- </body>
375
- </html>`})}function gC(r,e){const i=((Hl(r.getShapePageTransform(e.id).rotation())+Math.PI/4)*(2/Math.PI)+4)%4;return Math.floor(i)}const sJ=new WeakMap;function aJ(r,e,t){let n=sJ.get(e.props);if(!n){const i=yR(e.props.name,"Frame")+"​",o=r.textMeasure.measureTextSpans(i,t),s=o[0],a=Zn(o);n=a.box.w+a.box.x-s.box.x,sJ.set(e.props,n)}return new He(0,-t.height,n,t.height)}function cJ(r,e){return{fontSize:12,fontFamily:"Inter, sans-serif",textAlign:"start",width:r.props.w,height:32,padding:0,lineHeight:1,fontStyle:"normal",fontWeight:"normal",overflow:"truncate-ellipsis",verticalTextAlign:"middle",fill:e,offsetY:-34,offsetX:2}}function xde(r,e,t){const n=t?"":"px",i=t?"":"deg";let o;switch(e){case 0:o="";break;case 3:o=`translate(${fe(r.props.w)}${n}, 0${n}) rotate(90${i})`;break;case 2:o=`translate(${fe(r.props.w)}${n}, ${fe(r.props.h)}${n}) rotate(180${i})`;break;case 1:o=`translate(0${n}, ${fe(r.props.h)}${n}) rotate(270${i})`;break;default:throw Error("labelSide out of bounds")}return o}const i3e=A.forwardRef(({id:r,name:e,isEditing:t},n)=>{const i=he(),o=A.useCallback(c=>{c.key==="Enter"&&!c.nativeEvent.isComposing&&(wn(c),c.currentTarget.blur(),i.setEditingShape(null))},[i]),s=A.useCallback(c=>{const l=i.getShape(r);if(!l)return;const d=l.props.name,f=c.currentTarget.value.trim();d!==f&&i.updateShapes([{id:r,type:"frame",props:{name:f}}])},[r,i]),a=A.useCallback(c=>{const l=i.getShape(r);if(!l)return;const d=l.props.name,f=c.currentTarget.value;d!==f&&i.updateShapes([{id:r,type:"frame",props:{name:f}}])},[r,i]);return v.jsxs("div",{className:`tl-frame-label ${t?"tl-frame-label__editing":""}`,children:[v.jsx("input",{className:"tl-frame-name-input",ref:n,disabled:!t,readOnly:!t,style:{display:t?void 0:"none"},value:e,autoFocus:!0,onKeyDown:o,onBlur:s,onChange:a}),yR(e,"Frame")+"​"]})}),o3e=A.memo(function({id:e,name:t,width:n,height:i}){const o=he(),{side:s,translation:a}=ye("shape rotation",()=>{const d=o.getShape(e);if(!d)return{side:0,translation:"translate(0, 0)"};const f=gC(o,d);return{side:f,translation:xde(d,f,!1)}},[o,e]),c=A.useRef(null),l=My(e);return A.useEffect(()=>{const d=c.current;d&&l&&(d.focus(),d.select())},[c,l]),v.jsx("div",{className:"tl-frame-heading",style:{overflow:l?"visible":"hidden",maxWidth:`calc(var(--tl-zoom) * ${Math.ceil(s===0||s===2?n:i)}px + var(--space-5))`,bottom:"100%",transform:`${a} scale(var(--tl-scale)) translateX(calc(-1 * var(--space-3))`},children:v.jsx("div",{className:"tl-frame-heading-hit-area",children:v.jsx(i3e,{ref:c,id:e,name:t,isEditing:l})})})});function yR(r,e){return r.match(/^\s*$/)?e:r}class wv extends Qd{canEdit(){return!0}getDefaultProps(){return{w:160*2,h:90*2,name:""}}getGeometry(e){const{editor:t}=this,n=t.getZoomLevel(),i=cJ(e,"black"),o=aJ(t,e,i),s=gC(t,e);let a,c,l,d;const{w:f,h}=o,g=Math.min(f,e.props.w*n),m=Math.min(h,e.props.h*n);switch(s){case 0:{a=-8/n,c=(-h-4)/n,l=(g+16)/n,d=h/n;break}case 1:{a=(-h-4)/n,d=(m+16)/n,c=e.props.h-d+8/n,l=h/n;break}case 2:{a=e.props.w-(g+8)/n,c=e.props.h+4/n,l=(m+16)/n,d=h/n;break}case 3:{a=e.props.w+4/n,d=(m+16)/n,c=-8/n,l=h/n;break}}return new cs({children:[new ma({width:e.props.w,height:e.props.h,isFilled:!1}),new ma({x:a,y:c,width:l,height:d,isFilled:!0,isLabel:!0})]})}getText(e){return e.props.name}component(e){const t=fs(),n=ye("is creating this shape",()=>{const i=this.editor.getStateDescendant("select.resizing");if(!i||!i.getIsActive())return!1;const o=i==null?void 0:i.info;return o?o.isCreating&&this.editor.getOnlySelectedShapeId()===e.id:!1},[e.id]);return v.jsxs(v.Fragment,{children:[v.jsx(Jc,{children:v.jsx("rect",{className:bt("tl-frame__body",{"tl-frame__creating":n}),width:e.props.w,height:e.props.h,fill:t.solid,stroke:t.text})}),n?null:v.jsx(o3e,{id:e.id,name:e.props.name,width:e.props.w,height:e.props.h})]})}toSvg(e,t){const n=uc({isDarkMode:t.isDarkMode}),i=gC(this.editor,e),o=xde(e,i,!0),s=cJ(e,n.text),a=yR(e.props.name,"Frame")+"​",c=aJ(this.editor,e,s),l=this.editor.textMeasure.measureTextSpans(a,s),d=fC(this.editor,l,s);return v.jsxs(v.Fragment,{children:[v.jsx("rect",{width:e.props.w,height:e.props.h,fill:n.solid,stroke:n.black.solid,strokeWidth:1,rx:1,ry:1}),v.jsxs("g",{transform:o,children:[v.jsx("rect",{x:c.x-8,y:c.y-4,width:c.width+20,height:c.height,fill:n.background,rx:4,ry:4}),d]})]})}indicator(e){return v.jsx("rect",{width:fe(e.props.w),height:fe(e.props.h),className:"tl-frame-indicator"})}canReceiveNewChildrenOfType(e,t){return!e.isLocked}providesBackgroundForChildren(){return!0}canDropShapes(e,t){return!e.isLocked}onDragShapesOver(e,t){t.every(n=>n.parentId===e.id)||this.editor.reparentShapes(t,e.id)}onDragShapesOut(e,t){const n=this.editor.getShape(e.parentId);n&&this.editor.isShapeOfType(n,"group")?this.editor.reparentShapes(t,n.id):this.editor.reparentShapes(t,this.editor.getCurrentPageId())}onResize(e,t){return Oy(e,t)}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,w:or(e.props.w,t.props.w,n),h:or(e.props.h,t.props.h,n)}}}q(wv,"type","frame"),q(wv,"props",mte),q(wv,"migrations",yte);function lJ(r,e){return r>e?(hr*(e/2)+(r-e))*2:(hr*(r/2)+(e-r))*2}function _de(r,e){return SR(r,e).map((t,n)=>t.getSvgPathData(n===0)).join(" ")+" Z"}function s3e(r,e,t,n){const i=r/4,o=e/4,s=Ds(n),a=t*.75,c=w=>w.addXY(s()*a,s()*a),l=new T(r/2,e),d=new T(0,o*1.2),f=new T(r/2,o*.9),h=new T(r,o*1.2),g=c(new T(r/2,e)),m=c(new T(0,o*1.2)),y=c(new T(r/2,o*.9)),x=c(new T(r,o*1.2));return[new xi({start:l,cp1:new T(i*1.5,o*3),cp2:new T(0,o*2.5),end:d}),new xi({start:d,cp1:new T(0,-o*.32),cp2:new T(i*1.85,-o*.32),end:f}),new xi({start:f,cp1:new T(i*2.15,-o*.32),cp2:new T(r,-o*.32),end:h}),new xi({start:h,cp1:new T(r,o*2.5),cp2:new T(i*2.5,o*3),end:g}),new xi({start:g,cp1:new T(i*1.5,o*3),cp2:new T(0,o*2.5),end:m}),new xi({start:m,cp1:new T(0,-o*.32),cp2:new T(i*1.85,-o*.32),end:y}),new xi({start:y,cp1:new T(i*2.15,-o*.32),cp2:new T(r,-o*.32),end:x}),new xi({start:x,cp1:new T(r,o*2.5),cp2:new T(i*2.5,o*3),end:l})].map((w,I)=>w.getSvgPathData(I===0)).join(" ")+" Z"}function SR(r,e){const t=r/4,n=e/4;return[new xi({start:new T(r/2,e),cp1:new T(t*1.5,n*3),cp2:new T(0,n*2.5),end:new T(0,n*1.2)}),new xi({start:new T(0,n*1.2),cp1:new T(0,-n*.32),cp2:new T(t*1.85,-n*.32),end:new T(r/2,n*.9)}),new xi({start:new T(r/2,n*.9),cp1:new T(t*2.15,-n*.32),cp2:new T(r,-n*.32),end:new T(r,n*1.2)}),new xi({start:new T(r,n*1.2),cp1:new T(r,n*2.5),cp2:new T(t*2.5,n*3),end:new T(r/2,e)})]}function a3e(r){return{size:1+r,thinning:.25,end:{taper:r},start:{taper:r},streamline:0,smoothing:1,simulatePressure:!1}}function c3e(r,e,t,n){const i=Ds(r),o=e/2,s=t/2,a=Lee(o,s),c=[],l=Cr*i(),d=Cr+Nr/2+Math.abs(i())*Nr,f=Math.max(16,a/10);for(let h=0;h<f;h++){const g=h/(f-1),m=l+g*d,y=Math.cos(m),x=Math.sin(m);c.push(new T(o*y+e*.5+.05*i(),s*x+t/2+.05*i(),Math.min(1,.5+Math.abs(.5-(i()>0?zn.easeInOutSine(g):zn.easeInExpo(g)))/2)))}return xa(c,a3e(n))}function l3e(r,e,t,n){return iu(c3e(r,e,t,n))}function vC(r){let e="M";const t=r.length;let n,i,o;for(let s=0,a=t;s<a;s+=3)n=r[s],i=r[s+1],o=r[s+2],e+=`${vr(n)}L${vr(i)}Q${vr(o)}`;return e+=`${vr(r[0])}`,e}function mC(r,e,t,n,i){const o=[],s=Ds(r);let a=e[0],c;const l=e.length;for(let d=0,f=l*i;d<f;d++){c=T.AddXY(e[(d+1)%l],s()*t,s()*t);const h=T.Sub(c,a),g=T.Len(h),m=T.Div(h,g).mul(Math.min(g/4,n));o.push(T.Add(a,m),T.Add(c,m.neg()),c),a=c}return o}function u3e(r,e,t){const n=Math.min(r,e)/2,i=Math.max(r,e)-n*2,s=(Math.PI*(n*2)+2*i)/t,a=r>e?[{type:"straight",start:new T(n,0),delta:new T(1,0)},{type:"arc",center:new T(r-n,n),startAngle:-hr/2},{type:"straight",start:new T(r-n,e),delta:new T(-1,0)},{type:"arc",center:new T(n,n),startAngle:hr/2}]:[{type:"straight",start:new T(r,n),delta:new T(0,1)},{type:"arc",center:new T(n,e-n),startAngle:0},{type:"straight",start:new T(0,e-n),delta:new T(0,-1)},{type:"arc",center:new T(n,n),startAngle:hr}];let c=0;const l=[];for(let d=0;d<t;d++){const f=a[0];f.type==="straight"?l.push(T.Add(f.start,T.Mul(f.delta,c))):l.push(Gl(f.center,n,f.startAngle+c/n)),c+=s;let h=f.type==="straight"?i:hr*n;for(;c>h;)c-=h,a.push(a.shift()),h=a[0].type==="straight"?i:hr*n}return l}const d3e={s:50,m:70,l:100,xl:130},f3e=.2;function aS(r,e,t,n,i){const o=Ds(t),s=lJ(r,e),a=Math.max(Math.ceil(s/d3e[n]),6,Math.ceil(s/Math.min(r,e))),c=s/a*f3e,l=Math.max(r-c*2,1),d=Math.max(e-c*2,1),h=lJ(l,d)/a,g=(r-l)/2,m=(e-d)/2,y=u3e(l,d,a).map(b=>b.addXY(g,m)),x=r<20?0:c*.3,_=e<20?0:c*.3,w=y.slice(0);for(let b=0;b<Math.floor(a/2);b++)w[b]=T.AddXY(w[b],o()*x*i,o()*_*i),w[a-b-1]=T.AddXY(w[a-b-1],o()*x*i,o()*_*i);const I=[];for(let b=0;b<w.length;b++){const P=b===w.length-1?0:b+1,C=w[b],k=w[P],O=y[b],L=y[P],j=T.Dist(O,L),F=h-j,D=T.Dist(C,k)/j,N=(Math.max(g,m)+F)*D,B=T.Lrp(O,L,.5).add(T.Sub(L,O).uni().per().mul(N));B.x<0?B.x=0:B.x>r&&(B.x=r),B.y<0?B.y=0:B.y>e&&(B.y=e);const W=JC(C,k,B),G=T.Dist(W||T.Average([C,k]),C);I.push({leftPoint:C,rightPoint:k,arcPoint:B,center:W,radius:G})}return I}function h3e(r,e,t,n,i){const o=[],s=aS(r,e,t,n,i);for(const{center:a,radius:c,leftPoint:l,rightPoint:d}of s)o.push(...Jve(l,d,a,c,10));return o}function yC(r,e,t,n,i){const o=aS(r,e,t,n,i);let s=`M${o[0].leftPoint.toFixed()}`;for(const{leftPoint:a,rightPoint:c,radius:l,center:d}of o){if(d===null){s+=` L${c.toFixed()}`;continue}const f=T.Clockwise(a,c,d)?"0":"1";s+=` A${fe(l)},${fe(l)} 0 ${f},1 ${c.toFixed()}`}return s+=" Z",s}const p3e={s:.5,m:.7,l:.9,xl:1.6};function g3e(r,e,t,n,i){const o=Ds(t),s=p3e[n]*i,a=aS(r,e,t,n,i),d=a.reduce((m,y)=>m+T.Dist2(y.leftPoint,y.rightPoint),0)/a.length>(s*15)**2?m=>T.AddXY(m,o()*s*2,o()*s*2):m=>m;let f=`M${a[0].leftPoint.toFixed()}`,h=d(a[0].leftPoint),g=`M${h.toFixed()}`;for(const{leftPoint:m,center:y,rightPoint:x,radius:_,arcPoint:w}of a){if(y===null){f+=` L${x.toFixed()}`;const O=d(x);g+=` L${O.toFixed()}`,h=O;continue}const I=T.Clockwise(m,x,y)?"0":"1";f+=` A${fe(_)},${fe(_)} 0 ${I},1 ${x.toFixed()}`;const b=d(x),P=d(w),C=JC(h,b,P);if(!C){g+=` L${b.toFixed()}`,h=b;continue}const k=Math.abs(T.Dist(C,h));g+=` A${fe(k)},${fe(k)} 0 ${I},1 ${b.toFixed()}`,h=b}return f+g+" Z"}function SC(r,e){switch(r.geo){case"x-box":return v3e(r.w,r.h,e,r.dash);case"check-box":return m3e(r.w,r.h);default:return}}function v3e(r,e,t,n){const i=n==="draw"?.62:0;if(n==="dashed")return[[new T(0,0),new T(r/2,e/2)],[new T(r,e),new T(r/2,e/2)],[new T(0,e),new T(r/2,e/2)],[new T(r,0),new T(r/2,e/2)]];const o=a=>Math.max(0,Math.min(r,a)),s=a=>Math.max(0,Math.min(e,a));return[[new T(o(t*i),s(t*i)),new T(o(r-t*i),s(e-t*i))],[new T(o(t*i),s(e-t*i)),new T(o(r-t*i),s(t*i))]]}function m3e(r,e){const t=Math.min(r,e)*.82,n=(r-t)/2,i=(e-t)/2,o=a=>Math.max(0,Math.min(r,a)),s=a=>Math.max(0,Math.min(e,a));return[[new T(o(n+t*.25),s(i+t*.52)),new T(o(n+t*.45),s(i+t*.82))],[new T(o(n+t*.45),s(i+t*.82)),new T(o(n+t*.82),s(i+t*.22))]]}function uJ({shape:r,shouldScale:e,forceSolid:t}){const n=e?r.props.scale:1,i=he(),o=fs(),{id:s,props:a}=r,{w:c,color:l,fill:d,dash:f,growY:h,size:g,scale:m}=a,y=Ei[g]*n,x=a.h+h;switch(a.geo){case"cloud":if(f==="solid"){const _=yC(c,x,s,g,m);return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:_,color:l,fill:d,scale:n}),v.jsx("path",{d:_,stroke:o[l].solid,strokeWidth:y,fill:"none"})]})}else if(f==="draw"){const _=g3e(c,x,s,g,m);return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:_,color:l,fill:d,scale:n}),v.jsx("path",{d:_,stroke:o[l].solid,strokeWidth:y,fill:"none"})]})}else{const _=yC(c,x,s,g,m),w=aS(c,x,s,g,m);return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:_,color:l,fill:d,scale:n}),v.jsx("g",{strokeWidth:y,stroke:o[l].solid,fill:"none",pointerEvents:"all",children:w.map(({leftPoint:I,rightPoint:b,center:P,radius:C},k)=>{const O=P?C*Hl(Hl(T.Angle(P,b))-Hl(T.Angle(P,I))):T.Dist(I,b),{strokeDasharray:L,strokeDashoffset:j}=Ps(O,y,{style:f,start:"outset",end:"outset",forceSolid:t});return v.jsx("path",{d:P?`M${I.x},${I.y}A${C},${C},0,0,1,${b.x},${b.y}`:`M${I.x},${I.y}L${b.x},${b.y}`,strokeDasharray:L,strokeDashoffset:j},k)})})]})}case"ellipse":{const _=e?i.getShapeGeometry(r):i.getShapeUtil(r).getGeometry(r),w=_.getSvgPathData(!0);if(f==="dashed"||f==="dotted"){const I=_.length,{strokeDasharray:b,strokeDashoffset:P}=Ps(I<64?I*2:I,y,{style:f,snap:4,closed:!0,forceSolid:t});return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:w,color:l,fill:d,scale:n}),v.jsx("path",{d:w,strokeWidth:y,fill:"none",stroke:o[l].solid,strokeDasharray:b,strokeDashoffset:P})]})}else{const b=(e?i.getShapeGeometry(r):i.getShapeUtil(r).getGeometry(r)).getSvgPathData(!0);return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:b,color:l,fill:d,scale:n}),v.jsx("path",{d:b,stroke:o[l].solid,strokeWidth:y,fill:"none"})]})}}case"oval":{const _=e?i.getShapeGeometry(r):i.getShapeUtil(r).getGeometry(r),w=_.getSvgPathData(!0);if(f==="dashed"||f==="dotted"){const I=_.getLength(),{strokeDasharray:b,strokeDashoffset:P}=Ps(I<64?I*2:I,y,{style:f,snap:4,start:"outset",end:"outset",closed:!0,forceSolid:t});return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:w,color:l,fill:d,scale:n}),v.jsx("path",{d:w,strokeWidth:y,fill:"none",stroke:o[l].solid,strokeDasharray:b,strokeDashoffset:P})]})}else return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:w,color:l,fill:d,scale:n}),v.jsx("path",{d:w,stroke:o[l].solid,strokeWidth:y,fill:"none"})]})}case"heart":if(f==="dashed"||f==="dotted"||f==="solid"){const _=_de(c,x),w=SR(c,x);return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:_,color:l,fill:d,scale:n}),w.map((I,b)=>{const{strokeDasharray:P,strokeDashoffset:C}=Ps(I.length,y,{style:f,snap:1,start:"outset",end:"outset",closed:!0,forceSolid:t});return v.jsx("path",{d:I.getSvgPathData(),strokeWidth:y,fill:"none",stroke:o[l].solid,strokeDasharray:P,strokeDashoffset:C,pointerEvents:"all"},`curve_${b}`)})]})}else{const _=s3e(c,x,y,r.id);return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:_,color:l,fill:d,scale:n}),v.jsx("path",{d:_,stroke:o[l].solid,strokeWidth:y,fill:"none"})]})}default:{const _=e?i.getShapeGeometry(r):i.getShapeUtil(r).getGeometry(r),w=_ instanceof cs?_.children[0].vertices:_.vertices,I=SC(r.props,y);if(f==="solid"){let b="M"+w[0]+"L"+w.slice(1)+"Z";if(I)for(const[P,C]of I)b+=`M${P.x},${P.y}L${C.x},${C.y}`;return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:b,color:l,fill:d,scale:n}),v.jsx("path",{d:b,stroke:o[l].solid,strokeWidth:y,fill:"none"})]})}else if(f==="dashed"||f==="dotted"){const b="M"+w[0]+"L"+w.slice(1)+"Z";return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:b,color:l,fill:d,scale:n}),v.jsxs("g",{strokeWidth:y,stroke:o[l].solid,fill:"none",pointerEvents:"all",children:[Array.from(Array(w.length)).map((P,C)=>{const k=T.ToFixed(w[C]),O=T.ToFixed(w[(C+1)%w.length]),L=T.Dist(k,O),{strokeDasharray:j,strokeDashoffset:F}=Ps(L,y,{style:f,start:"outset",end:"outset",forceSolid:t});return v.jsx("line",{x1:k.x,y1:k.y,x2:O.x,y2:O.y,strokeDasharray:j,strokeDashoffset:F},C)}),I&&I.map(([P,C],k)=>{const O=T.Dist(P,C),{strokeDasharray:L,strokeDashoffset:j}=Ps(O,y,{style:f,start:"skip",end:"skip",snap:f==="dotted"?4:void 0,forceSolid:t});return v.jsx("path",{d:`M${P.x},${P.y}L${C.x},${C.y}`,stroke:o[l].solid,strokeWidth:y,fill:"none",strokeDasharray:L,strokeDashoffset:j},`line_fg_${k}`)})]})]})}else if(f==="draw"){let b=vC(mC(s,w,y/3,y*2,2));if(I)for(const[C,k]of I)b+=`M${C.toFixed()}L${k.toFixed()}`;const P=vC(mC(s,w,0,y*2,1));return v.jsxs(v.Fragment,{children:[v.jsx(mi,{theme:o,d:P,color:l,fill:d,scale:n}),v.jsx("path",{d:b,stroke:o[l].solid,strokeWidth:y,fill:"none"})]})}}}}const dJ=17*3;class bv extends Qd{canEdit(){return!0}getDefaultProps(){return{w:100,h:100,geo:"rectangle",color:"black",labelColor:"black",fill:"none",dash:"draw",size:"m",font:"draw",text:"",align:"middle",verticalAlign:"middle",growY:0,url:"",scale:1}}getGeometry(e){const t=Math.max(1,e.props.w),n=Math.max(1,e.props.h+e.props.growY),i=t/2,o=n/2,s=e.props.fill!=="none";let a;switch(e.props.geo){case"cloud":{a=new mn({points:h3e(t,n,e.id,e.props.size,e.props.scale),isFilled:s});break}case"triangle":{a=new mn({points:[new T(i,0),new T(t,n),new T(0,n)],isFilled:s});break}case"diamond":{a=new mn({points:[new T(i,0),new T(t,o),new T(i,n),new T(0,o)],isFilled:s});break}case"pentagon":{a=new mn({points:Xw(t,n,5),isFilled:s});break}case"hexagon":{a=new mn({points:Xw(t,n,6),isFilled:s});break}case"octagon":{a=new mn({points:Xw(t,n,8),isFilled:s});break}case"ellipse":{a=new F2e({width:t,height:n,isFilled:s});break}case"oval":{a=new N2e({width:t,height:n,isFilled:s});break}case"star":{const w=Cr/5/2,I=Math.floor(5/4)*2,b=5*2-I,P=0,C=Math.floor(5/2)*2,k=Math.cos(-Nr+I*w)*t/2,O=Math.cos(-Nr+b*w)*t/2,L=Math.sin(-Nr+P*w)*n/2,j=Math.sin(-Nr+C*w)*n/2,F=t-Math.abs(k-O),$=n-Math.abs(j-L),D=t/2+O-(t/2-k),N=n/2+L-(n/2-j),B=1,W=(t-D)/2,G=(n-N)/2,z=(t+F)/2,V=(n+$)/2,J=z*B/2,K=V*B/2;a=new mn({points:Array.from(Array(5*2)).map((Z,ee)=>{const re=-Nr+ee*w;return new T(W+(ee%2?J:z)*Math.cos(re),G+(ee%2?K:V)*Math.sin(re))}),isFilled:s});break}case"rhombus":{const _=Math.min(t*.38,n*.38);a=new mn({points:[new T(_,0),new T(t,0),new T(t-_,n),new T(0,n)],isFilled:s});break}case"rhombus-2":{const _=Math.min(t*.38,n*.38);a=new mn({points:[new T(0,0),new T(t-_,0),new T(t,n),new T(_,n)],isFilled:s});break}case"trapezoid":{const _=Math.min(t*.38,n*.38);a=new mn({points:[new T(_,0),new T(t-_,0),new T(t,n),new T(0,n)],isFilled:s});break}case"arrow-right":{const _=Math.min(t,n)*.38,w=n*.16;a=new mn({points:[new T(0,w),new T(t-_,w),new T(t-_,0),new T(t,n/2),new T(t-_,n),new T(t-_,n-w),new T(0,n-w)],isFilled:s});break}case"arrow-left":{const _=Math.min(t,n)*.38,w=n*.16;a=new mn({points:[new T(_,0),new T(_,w),new T(t,w),new T(t,n-w),new T(_,n-w),new T(_,n),new T(0,n/2)],isFilled:s});break}case"arrow-up":{const _=t*.16,w=Math.min(t,n)*.38;a=new mn({points:[new T(t/2,0),new T(t,w),new T(t-_,w),new T(t-_,n),new T(_,n),new T(_,w),new T(0,w)],isFilled:s});break}case"arrow-down":{const _=t*.16,w=Math.min(t,n)*.38;a=new mn({points:[new T(_,0),new T(t-_,0),new T(t-_,n-w),new T(t,n-w),new T(t/2,n),new T(0,n-w),new T(_,n-w)],isFilled:s});break}case"check-box":case"x-box":case"rectangle":{a=new ma({width:t,height:n,isFilled:s});break}case"heart":{const w=SR(t,n).reduce((I,b)=>(I.push(...b.vertices),I),[]);a=new mn({points:w,isFilled:s});break}default:An(e.props.geo)}const c=Xg(this.editor,e),l=t/e.props.scale,d=n/e.props.scale,f=Math.min(100,l/2),h=Math.min(ic[e.props.size]*Ii.lineHeight+ts*2,d/2),g=Math.min(l,Math.max(c.w,Math.min(f,Math.max(1,l-8)))),m=Math.min(d,Math.max(c.h,Math.min(h,Math.max(1,d-8)))),y=SC(e.props,Ei[e.props.size]*e.props.scale),x=y?y.map(_=>new Vd({points:_})):[];return new cs({children:[a,new ma({x:e.props.align==="start"?0:e.props.align==="end"?(l-g)*e.props.scale:(l-g)/2*e.props.scale,y:e.props.verticalAlign==="start"?0:e.props.verticalAlign==="end"?(d-m)*e.props.scale:(d-m)/2*e.props.scale,width:g*e.props.scale,height:m*e.props.scale,isFilled:!0,isLabel:!0}),...x]})}getHandleSnapGeometry(e){const t=this.getGeometry(e),n=t.children[0];switch(e.props.geo){case"arrow-down":case"arrow-left":case"arrow-right":case"arrow-up":case"check-box":case"diamond":case"hexagon":case"octagon":case"pentagon":case"rectangle":case"rhombus":case"rhombus-2":case"star":case"trapezoid":case"triangle":case"x-box":return{outline:n,points:[...n.getVertices(),t.bounds.center]};case"cloud":case"ellipse":case"heart":case"oval":return{outline:n,points:[t.bounds.center]};default:An(e.props.geo)}}getText(e){return e.props.text}onEditEnd(e){const{id:t,type:n,props:{text:i}}=e;i.trimEnd()!==e.props.text&&this.editor.updateShapes([{id:t,type:n,props:{text:i.trimEnd()}}])}component(e){const{id:t,type:n,props:i}=e,{fill:o,font:s,align:a,verticalAlign:c,size:l,text:d}=i,f=fs(),{editor:h}=this,g=ye("isGeoOnlySelected",()=>e.id===h.getOnlySelectedShapeId(),[]),y=h.getEditingShapeId()!==null||e.props.text,x=ye("force solid",()=>h.getZoomLevel()<.2,[h]);return v.jsxs(v.Fragment,{children:[v.jsx(Jc,{children:v.jsx(uJ,{shape:e,shouldScale:!0,forceSolid:x})}),y&&v.jsx(Xc,{style:{overflow:"hidden",width:e.props.w,height:e.props.h+i.growY},children:v.jsx(sS,{shapeId:t,type:n,font:s,fontSize:ic[l]*e.props.scale,lineHeight:Ii.lineHeight,padding:ts*e.props.scale,fill:o,align:a,verticalAlign:c,text:d,isSelected:g,labelColor:f[i.labelColor].solid,wrap:!0})}),e.props.url&&v.jsx(Pd,{url:e.props.url})]})}indicator(e){const{id:t,props:n}=e,{w:i,size:o}=n,s=n.h+n.growY,a=Ei[o],c=this.editor.getShapeGeometry(e);switch(n.geo){case"ellipse":return n.dash==="draw"?v.jsx("path",{d:l3e(t,i,s,a)}):v.jsx("path",{d:c.getSvgPathData(!0)});case"heart":return v.jsx("path",{d:_de(i,s)});case"oval":return v.jsx("path",{d:c.getSvgPathData(!0)});case"cloud":return v.jsx("path",{d:yC(i,s,t,o,e.props.scale)});default:{const l=this.editor.getShapeGeometry(e),d=l instanceof cs?l.children[0].vertices:l.vertices;let f;if(n.dash==="draw"){const g=mC(t,d,0,a*2*e.props.scale,1);f=vC(g)}else f="M"+d[0]+"L"+d.slice(1)+"Z";const h=SC(e.props,a);if(h)for(const[g,m]of h)f+=`M${g.x},${g.y}L${m.x},${m.y}`;return v.jsx("path",{d:f})}}}toSvg(e,t){const n={...e,props:{...e.props,w:e.props.w/e.props.scale,h:e.props.h/e.props.scale}},i=n.props;t.addExportDef(hR(i.fill));let o;if(i.text){t.addExportDef(iS(i.font));const s=uc(t),a=new He(0,0,i.w,i.h+i.growY);o=v.jsx(oS,{fontSize:ic[i.size],font:i.font,align:i.align,verticalAlign:i.verticalAlign,text:i.text,labelColor:s[i.labelColor].solid,bounds:a,padding:16})}return v.jsxs(v.Fragment,{children:[v.jsx(uJ,{shouldScale:!1,shape:n,forceSolid:!1}),o]})}getCanvasSvgDefs(){return[pR()]}onResize(e,{handle:t,newPoint:n,scaleX:i,scaleY:o,initialShape:s}){const a=s.props.w/s.props.scale,c=s.props.h/s.props.scale,l=s.props.growY/s.props.scale;let d=a*i,f=(c+l)*o,h=0,g=0;const m=dJ;if(e.props.text.trim()){let b=Math.max(Math.abs(d),m),P=Math.max(Math.abs(f),m);b<m&&P===m&&(b=m),b===m&&P<m&&(P=m);const C=Xg(this.editor,{...e,props:{...e.props,w:b*e.props.scale,h:P*e.props.scale}}),k=Math.max(Math.abs(d),C.w)*Math.sign(d),O=Math.max(Math.abs(f),C.h)*Math.sign(f);h=Math.abs(k)-Math.abs(d),g=Math.abs(O)-Math.abs(f),d=k,f=O}const y=d*e.props.scale,x=f*e.props.scale,_=new T(0,0);i<0&&(_.x+=y),(t==="left"||t==="top_left"||t==="bottom_left")&&(_.x+=i<0?h:-h),o<0&&(_.y+=x),(t==="top"||t==="top_left"||t==="top_right")&&(_.y+=o<0?g:-g);const{x:w,y:I}=_.rot(e.rotation).add(n);return{x:w,y:I,props:{w:Math.max(Math.abs(y),1),h:Math.max(Math.abs(x),1),growY:0}}}onBeforeCreate(e){if(!e.props.text)return e.props.growY?{...e,props:{...e.props,growY:0}}:void 0;const t=e.props.h/e.props.scale,n=Xg(this.editor,e).h;let i=null;if(n>t?i=n-t:e.props.growY&&(i=0),i!==null)return{...e,props:{...e.props,growY:i*e.props.scale}}}onBeforeUpdate(e,t){const n=e.props.text,i=t.props.text;if(n===i&&e.props.font===t.props.font&&e.props.size===t.props.size)return;if(n&&!i)return{...t,props:{...t.props,growY:0}};const o=e.props.w/e.props.scale,s=e.props.h/e.props.scale,a=e.props.growY/e.props.scale,c=Xg(this.editor,t);if(!n&&i&&i.length===1){let d=Math.max(o,c.w),f=Math.max(s,c.h);const h=dJ;return o<h&&s<h&&(d=Math.max(d,h),f=Math.max(f,h),d=Math.max(d,f),f=Math.max(d,f)),{...t,props:{...t.props,w:d*t.props.scale,h:f*t.props.scale,growY:0}}}let l=null;if(c.h>s?l=c.h-s:a&&(l=0),l!==null){const d=t.props.w/t.props.scale;return{...t,props:{...t.props,growY:l*t.props.scale,w:Math.max(d,c.w)*t.props.scale}}}if(c.w>o)return{...t,props:{...t.props,w:c.w*t.props.scale}}}onDoubleClick(e){if(this.editor.inputs.altKey)switch(e.props.geo){case"rectangle":return{...e,props:{geo:"check-box"}};case"check-box":return{...e,props:{geo:"rectangle"}}}}getInterpolatedProps(e,t,n){return{...n>.5?t.props:e.props,w:or(e.props.w,t.props.w,n),h:or(e.props.h,t.props.h,n),scale:or(e.props.scale,t.props.scale,n)}}}q(bv,"type","geo"),q(bv,"props",Ste),q(bv,"migrations",xte);function Xg(r,e){const{text:t,font:n,size:i,w:o}=e.props;if(!t)return{w:0,h:0};const s=r.textMeasure.measureText("w",{...Ii,fontFamily:ac[n],fontSize:ic[i],maxWidth:100}),a={s:2,m:3.5,l:5,xl:10},c=r.textMeasure.measureText(t,{...Ii,fontFamily:ac[n],fontSize:ic[i],minWidth:s.w,maxWidth:Math.max(0,Math.ceil(s.w+a[i]),Math.ceil(o/e.props.scale-ts*2))});return{w:c.w+ts*2,h:c.h+ts*2}}function y3e(){const[r,e]=A.useState(!1);return A.useEffect(()=>{const n=CSS.supports("color","color(display-p3 1 1 1)"),i=matchMedia("(color-gamut: p3)");e(n&&i.matches);const o=()=>e(n&&i.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),ye(yn.forceSrgb)||!r?"srgb":"p3"}class Ev extends Rs{constructor(){super(...arguments);q(this,"options",{maxPointsPerShape:600,underlayOpacity:.82,overlayOpacity:.35})}hideResizeHandles(t){return Zg(t)}hideRotateHandle(t){return Zg(t)}hideSelectionBoundsFg(t){return Zg(t)}getDefaultProps(){return{segments:[],color:"black",size:"m",isComplete:!1,isPen:!1,scale:1}}getGeometry(t){const n=Bl(t);if(Zg(t))return new yA({x:-n/2,y:-n/2,radius:n/2,isFilled:!0});const{strokePoints:i,sw:o}=fJ(t,n,!0),s=mR({strokeWidth:o,showAsComplete:!0});return rS(i,s),new mn({points:lR(i,s),isFilled:!0})}component(t){const n=UI(this.editor,t),i=Bl(t);return v.jsx(Jc,{children:v.jsx(Qg,{shape:t,forceSolid:n,strokeWidth:i,opacity:this.options.overlayOpacity})})}backgroundComponent(t){const n=UI(this.editor,t),i=Bl(t);return v.jsx(Jc,{children:v.jsx(Qg,{shape:t,forceSolid:n,strokeWidth:i,opacity:this.options.underlayOpacity})})}indicator(t){const n=UI(this.editor,t),i=Bl(t),{strokePoints:o,sw:s}=fJ(t,i,n),a=Cd(t.props.segments);let c;return o.length<2?c=x3e(a[0],s):c=iu(o,!1),v.jsx("path",{d:c})}toSvg(t){const n=Bl(t),i=n<1.5,o=1/t.props.scale;return v.jsx("g",{transform:`scale(${o})`,children:v.jsx(Qg,{forceSolid:i,strokeWidth:n,shape:t,opacity:this.options.overlayOpacity})})}toBackgroundSvg(t){const n=Bl(t),i=n<1.5,o=1/t.props.scale;return v.jsx("g",{transform:`scale(${o})`,children:v.jsx(Qg,{forceSolid:i,strokeWidth:n,shape:t,opacity:this.options.underlayOpacity})})}onResize(t,n){const{scaleX:i,scaleY:o}=n,s=[];for(const a of t.props.segments)s.push({...a,points:a.points.map(({x:c,y:l,z:d})=>({x:i*c,y:o*l,z:d}))});return{props:{segments:s}}}getInterpolatedProps(t,n,i){return{...i>.5?n.props:t.props,...n.props,segments:mde(t.props.segments,n.props.segments,i),scale:or(t.props.scale,n.props.scale,i)}}}q(Ev,"type","highlight"),q(Ev,"props",bte),q(Ev,"migrations",Ete);function S3e(r){return`M ${r.x} ${r.y} m -${.1}, 0 a ${.1},${.1} 0 1,0 ${.1*2},0 a ${.1},${.1} 0 1,0 -${.1*2},0`}function x3e(r,e){const t=e/2;return`M ${r.x} ${r.y} m -${t}, 0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0`}function fJ(r,e,t){var c;const n=Cd(r.props.segments),i=r.props.isComplete||((c=Zn(r.props.segments))==null?void 0:c.type)==="straight";let o=e;!t&&!r.props.isPen&&n.length===1&&(o+=Ds(r.id)()*(e/6));const s=mR({strokeWidth:o,showAsComplete:i});return{strokePoints:xa(n,s),sw:o}}function Bl(r){return Ed[r.props.size]*1.12*r.props.scale}function Zg(r){return r.props.segments.length===1&&r.props.segments[0].points.length<2}function Qg({strokeWidth:r,forceSolid:e,shape:t,opacity:n}){var h;const i=fs(),o=Cd(t.props.segments);let s=r;!e&&!t.props.isPen&&o.length===1&&(s+=Ds(t.id)()*(s/6));const a=mR({strokeWidth:s,showAsComplete:t.props.isComplete||((h=Zn(t.props.segments))==null?void 0:h.type)==="straight"}),c=xa(o,a),l=c.length>1?iu(c,!1):S3e(t.props.segments[0].points[0]),d=y3e(),f=i[t.props.color].highlight[d];return v.jsx("path",{d:l,strokeLinecap:"round",fill:"none",pointerEvents:"all",stroke:f,strokeWidth:s,opacity:n})}function UI(r,e){return ye("forceSolid",()=>{const t=Bl(e),n=r.getZoomLevel();return t/n<1.5},[r])}function wde(){return v.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 30 30",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[v.jsx("path",{d:"M3,11 L3,3 11,3",strokeWidth:"2"}),v.jsx("path",{d:"M19,27 L27,27 L27,19",strokeWidth:"2"}),v.jsx("path",{d:"M27,3 L3,27",strokeWidth:"2"})]})}const hJ=8;function _3e(){return{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}}}function Rh(r,e){if(!e)return{w:r.w,h:r.h};const t=r.w/(e.bottomRight.x-e.topLeft.x),n=r.h/(e.bottomRight.y-e.topLeft.y);return{w:t,h:n}}function w3e(r,e,t={}){const{handle:n,change:i,crop:o}=e,{w:s,h:a}=e.uncroppedSize,{minWidth:c=hJ,minHeight:l=hJ}=t,d=Kr(o),f=new T(r.x,r.y),h=new T(0,0);let g=!1;switch(n){case"top":case"top_left":case"top_right":{if(a<l)break;g=!0,d.topLeft.y=d.topLeft.y+i.y/a,a*(d.bottomRight.y-d.topLeft.y)<l?(d.topLeft.y=d.bottomRight.y-l/a,h.y=(d.topLeft.y-o.topLeft.y)*a):d.topLeft.y<=0?(d.topLeft.y=0,h.y=(d.topLeft.y-o.topLeft.y)*a):h.y=i.y;break}case"bottom":case"bottom_left":case"bottom_right":{if(a<l)break;g=!0,d.bottomRight.y=Math.min(1,d.bottomRight.y+i.y/a),a*(d.bottomRight.y-d.topLeft.y)<l&&(d.bottomRight.y=d.topLeft.y+l/a);break}}switch(n){case"left":case"top_left":case"bottom_left":{if(s<c)break;g=!0,d.topLeft.x=d.topLeft.x+i.x/s,s*(d.bottomRight.x-d.topLeft.x)<c?(d.topLeft.x=d.bottomRight.x-c/s,h.x=(d.topLeft.x-o.topLeft.x)*s):d.topLeft.x<=0?(d.topLeft.x=0,h.x=(d.topLeft.x-o.topLeft.x)*s):h.x=i.x;break}case"right":case"top_right":case"bottom_right":{if(s<c)break;g=!0,d.bottomRight.x=Math.min(1,d.bottomRight.x+i.x/s),s*(d.bottomRight.x-d.topLeft.x)<c&&(d.bottomRight.x=d.topLeft.x+c/s);break}}if(g)return f.add(h.rot(r.rotation)),{id:r.id,type:r.type,x:f.x,y:f.y,props:{w:(d.bottomRight.x-d.topLeft.x)*s,h:(d.bottomRight.y-d.topLeft.y)*a,crop:d}}}function bde({shapeId:r,assetId:e,width:t}){const n=he(),i=op(),o=KTe(),[s,a]=A.useState(()=>({asset:e?n.getAsset(e)??null:null,url:null})),c=A.useRef(!1),l=A.useRef(null);return A.useEffect(()=>{if(!e)return;let d=!1,f;const h=fa("update state",()=>{if(!i&&r&&n.getCulledShapes().has(r))return;const g=n.getAsset(e);if(!g)return;if(!g.props.src){const x=n.getTemporaryAssetPreview(g.id);if(x){l.current!==x&&(l.current=x,a(_=>({..._,isPlaceholder:!0,url:x})),o());return}}const m=i?i.scale*(t/g.props.w):n.getZoomLevel()*(t/g.props.w);function y(x,_){d||l.current!==_&&(c.current=!0,l.current=_,a({asset:x,url:_}),o())}if(c.current){let x=0;const _=()=>{x++,x>500/16&&(pJ(n,e,m,i,w=>y(g,w)),f==null||f())};f==null||f(),n.on("tick",_),f=()=>n.off("tick",_)}else pJ(n,e,m,i,x=>y(g,x))});return()=>{h(),f==null||f(),d=!0}},[n,e,i,o,r,t]),s}function pJ(r,e,t,n,i){r.resolveAssetUrl(e,{screenScale:t,shouldResolveToOriginal:n?n.pixelRatio===null:!1,dpr:(n==null?void 0:n.pixelRatio)??void 0}).then(o=>{i(o)})}async function b3e(r){const t=await(await pa(r)).blob();return ns.blobToDataUrl(t)}const E3e=new js;class Iv extends Qd{isAspectRatioLocked(){return!0}canCrop(){return!0}getDefaultProps(){return{w:100,h:100,assetId:null,playing:!0,url:"",crop:null,flipX:!1,flipY:!1}}onResize(e,t){let n=Oy(e,t);const{flipX:i,flipY:o}=t.initialShape.props,{scaleX:s,scaleY:a,mode:c}=t;if(n={...n,props:{...n.props,flipX:s<0!==i,flipY:a<0!==o}},!e.props.crop)return n;const l=c==="scale_shape"&&s===-1||c==="resize_bounds"&&i!==n.props.flipX,d=c==="scale_shape"&&a===-1||c==="resize_bounds"&&o!==n.props.flipY,{topLeft:f,bottomRight:h}=e.props.crop;return n.props.crop={topLeft:{x:l?1-h.x:f.x,y:d?1-h.y:f.y},bottomRight:{x:l?1-f.x:h.x,y:d?1-f.y:h.y}},n}component(e){return v.jsx(I3e,{shape:e})}indicator(e){return this.editor.getCroppingShapeId()===e.id?null:v.jsx("rect",{width:fe(e.props.w),height:fe(e.props.h)})}async toSvg(e,t){if(!e.props.assetId)return null;const n=this.editor.getAsset(e.props.assetId);if(!n)return null;const{w:i}=Rh(e.props,e.props.crop),o=await E3e.get(n,async()=>{let s=await t.resolveAssetUrl(n.id,i);if(!s)return null;if((s.startsWith("blob:")||s.startsWith("http")||s.startsWith("/")||s.startsWith("./"))&&(s=await b3e(s)||""),Ede(this.editor,n.id)){const{promise:a}=Pde(s);s=await a}return s});return o?v.jsx(P3e,{shape:e,src:o}):null}onDoubleClickEdge(e){const t=e.props;if(!t||this.editor.getCroppingShapeId()!==e.id)return;const n=Kr(t.crop)||{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},{w:i,h:o}=Rh(e.props,n),s=new T(n.topLeft.x*i,n.topLeft.y*o).rot(e.rotation),a={id:e.id,type:e.type,x:e.x-s.x,y:e.y-s.y,props:{crop:{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},w:i,h:o}};this.editor.updateShapes([a])}getInterpolatedProps(e,t,n){function i(o,s){var f,h,g,m;if(o.props.crop===null&&s.props.crop===null)return null;const a=((f=o.props.crop)==null?void 0:f.topLeft)||{x:0,y:0},c=((h=o.props.crop)==null?void 0:h.bottomRight)||{x:1,y:1},l=((g=s.props.crop)==null?void 0:g.topLeft)||{x:0,y:0},d=((m=s.props.crop)==null?void 0:m.bottomRight)||{x:1,y:1};return{topLeft:{x:or(a.x,l.x,n),y:or(a.y,l.y,n)},bottomRight:{x:or(c.x,d.x,n),y:or(c.y,d.y,n)}}}return{...n>.5?t.props:e.props,w:or(e.props.w,t.props.w,n),h:or(e.props.h,t.props.h,n),crop:i(e,t)}}}q(Iv,"type","image"),q(Iv,"props",Ite),q(Iv,"migrations",Pte);const I3e=A.memo(function({shape:e}){var w;const t=he(),{w:n}=Rh(e.props,e.props.crop),{asset:i,url:o}=bde({shapeId:e.id,assetId:e.props.assetId,width:n}),s=nce(),[a,c]=A.useState(""),[l,d]=A.useState(null),f=i&&Ede(t,i.id);A.useEffect(()=>{if(o&&f){const{promise:I,cancel:b}=Pde(o);return I.then(P=>{c(P),d(o)}),()=>{b()}}},[t,f,s,o]);const h=ye("show crop preview",()=>e.id===t.getOnlySelectedShapeId()&&t.getCroppingShapeId()===e.id&&t.isIn("select.crop"),[t,e.id]),g=s&&(((w=i==null?void 0:i.props.mimeType)==null?void 0:w.includes("video"))||f),m=Ide(e),y=o===l?null:o,x=g?a:l;if(!o&&!(i!=null&&i.props.src))return v.jsxs(Xc,{id:e.id,style:{overflow:"hidden",width:e.props.w,height:e.props.h,color:"var(--color-text-3)",backgroundColor:"var(--color-low)",border:"1px solid var(--color-low-border)"},children:[v.jsx("div",{className:bt("tl-image-container",i&&"tl-image-container-loading"),style:m,children:i?null:v.jsx(wde,{})}),"url"in e.props&&e.props.url&&v.jsx(Pd,{url:e.props.url})]});const _=f?"anonymous":void 0;return v.jsxs(v.Fragment,{children:[h&&x&&v.jsx("div",{style:m,children:v.jsx("img",{className:"tl-image",style:{...fh(e),opacity:.1},crossOrigin:_,src:x,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1})}),v.jsxs(Xc,{id:e.id,style:{overflow:"hidden",width:e.props.w,height:e.props.h},children:[v.jsxs("div",{className:bt("tl-image-container"),style:m,children:[x&&v.jsx("img",{className:"tl-image",style:fh(e),crossOrigin:_,src:x,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1},x),y&&v.jsx("img",{className:"tl-image",style:fh(e),crossOrigin:_,src:y,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1,onLoad:()=>d(y)},y)]}),e.props.url&&v.jsx(Pd,{url:e.props.url})]})]})});function Ede(r,e){const t=e?r.getAsset(e):void 0;return t?"mimeType"in t.props&&To.isAnimatedImageType(t==null?void 0:t.props.mimeType)||"isAnimated"in t.props&&t.props.isAnimated:!1}function Ide(r){const e=r.props.crop,t=e==null?void 0:e.topLeft;if(!t)return{width:r.props.w,height:r.props.h};const{w:n,h:i}=Rh(r.props,e),o=-t.x*n,s=-t.y*i;return{transform:`translate(${o}px, ${s}px)`,width:n,height:i}}function fh(r,e){const{flipX:t,flipY:n}=r.props;if(!t&&!n)return;const i=`scale(${t?-1:1}, ${n?-1:1})`;return{transform:`${e?`translate(${t?e.width:0}px, ${n?e.height:0}px)`:""} ${i}`,transformOrigin:e?"0 0":"center center"}}function P3e({shape:r,src:e}){const t=Ld(),n=Ide(r),i=r.props.crop;if(n.transform&&i){const{transform:o,width:s,height:a}=n,c=(i.bottomRight.x-i.topLeft.x)*s,l=(i.bottomRight.y-i.topLeft.y)*a,d=[new T(0,0),new T(c,0),new T(c,l),new T(0,l)],f=fh(r,{width:s,height:a});return v.jsxs(v.Fragment,{children:[v.jsx("defs",{children:v.jsx("clipPath",{id:t,children:v.jsx("polygon",{points:d.map(h=>`${h.x},${h.y}`).join(" ")})})}),v.jsx("g",{clipPath:`url(#${t})`,children:v.jsx("image",{href:e,width:s,height:a,style:f?{...f,transform:`${o} ${f.transform}`}:{transform:o}})})]})}else return v.jsx("image",{href:e,width:r.props.w,height:r.props.h,style:fh(r,{width:r.props.w,height:r.props.h})})}function Pde(r){let e=!1;return{promise:new Promise(n=>{const i=vh();i.onload=()=>{if(e)return;const o=document.createElement("canvas");o.width=i.width,o.height=i.height;const s=o.getContext("2d");s&&(s.drawImage(i,0,0),n(o.toDataURL()))},i.crossOrigin="anonymous",i.src=r}),cancel:()=>e=!0}}function Cde(r){return{size:r,thinning:.4,streamline:0,smoothing:.5,simulatePressure:!0,last:!0}}function Tde(r,e,t){const n=e.vertices,i=Cde(t);return xa(n,i)}function C3e(r,e,t){const n=Cde(t);return lR(rS(Tde(r,e,t),n),n)}function T3e(r,e,t){const n=C3e(r,e,t);return xT(n)}function A3e(r,e,t){if(r.props.dash==="draw"){const n=Tde(r,e,t);return iu(n)}return e.getSvgPathData()}function Ade(r,e,t){let n=`M ${vr(e[0])}L`,i=`M ${vr(e[0])}L`;const o=t/3,s=t*2,a=Ds(r);let c=e[0],l,d=e[0],f;const h=e.length;for(let g=0,m=h-1;g<m;g++){l=e[g+1],f=T.AddXY(e[g+1],a()*o,a()*o);const y=T.Sub(l,c),x=T.Len(y),_=T.Div(y,x).mul(Math.min(x/4,s)),w=T.Add(c,_),I=T.Add(l,_.neg()),b=T.Sub(f,d),P=T.Len(b),C=T.Div(b,P).mul(Math.min(P/4,s)),k=T.Add(d,C),O=T.Add(f,C.neg());g===m-1?(n+=`${vr(w)}L ${vr(l)}`,i+=`${vr(k)}L ${vr(f)}`):(n+=`${vr(w)}L ${vr(I)}Q ${vr(l)}`,i+=`${vr(k)}L ${vr(O)}Q ${vr(f)}`,c=l,d=f)}return[n,n+i]}const R3e=new js;class Pv extends Rs{hideResizeHandles(){return!0}hideRotateHandle(){return!0}hideSelectionBoundsFg(){return!0}hideSelectionBoundsBg(){return!0}getDefaultProps(){const[e,t]=yh(2);return{dash:"draw",size:"m",color:"black",spline:"line",points:{[e]:{id:e,index:e,x:0,y:0},[t]:{id:t,index:t,x:.1,y:.1}},scale:1}}getGeometry(e){return ih(e)}getHandles(e){return R3e.get(e.props,()=>{const t=ih(e),n=nh(e),i=n.map(o=>({...o,id:o.index,type:"vertex",canSnap:!0}));for(let o=0;o<n.length-1;o++){const s=mh(n[o].index,n[o+1].index),c=t.segments[o].midPoint();i.push({id:s,type:"create",index:s,x:c.x,y:c.y,canSnap:!0})}return i.sort(_i)})}onResize(e,t){const{scaleX:n,scaleY:i}=t;return{props:{points:jh(e.props.points,(o,{id:s,index:a,x:c,y:l})=>({id:s,index:a,x:c*n,y:l*i}))}}}onBeforeCreate(e){const{props:{points:t}}=e,n=Object.keys(t);if(n.length<2)return;const i=t[n[0]];if(n.every(s=>{const a=t[s];return a.x===i.x&&a.y===i.y})){const s=n[n.length-1];return t[s]={...t[s],x:t[s].x+.1,y:t[s].y+.1},e}}onHandleDrag(e,{handle:t}){if(t.type!=="vertex")return;const n=ks(new T(t.x,t.y),this.editor);return{...e,props:{...e.props,points:{...e.props.points,[t.id]:{id:t.id,index:t.index,x:n.x,y:n.y}}}}}component(e){return v.jsx(Jc,{style:{minWidth:50,minHeight:50},children:v.jsx(gJ,{shape:e})})}indicator(e){const t=da[e.props.size]*e.props.scale,n=ih(e),{dash:i}=e.props;let o;if(e.props.spline==="line"){const s=n.points;if(i==="solid"||i==="dotted"||i==="dashed")o="M"+s[0]+"L"+s.slice(1);else{const[a]=Ade(e.id,s,t);o=a}}else o=A3e(e,n,t);return v.jsx("path",{d:o})}toSvg(e){return v.jsx(gJ,{shouldScale:!0,shape:e})}getHandleSnapGeometry(e){const t=nh(e);return{points:t,getSelfSnapPoints:n=>{const i=this.getHandles(e).filter(o=>o.type==="vertex").findIndex(o=>o.id===n.id);return t.filter((o,s)=>Math.abs(s-i)>1).map(T.From)},getSelfSnapOutline:n=>{const i=this.getHandles(e).filter(s=>s.type==="vertex").findIndex(s=>s.id===n.id),o=ih(e).segments.filter((s,a)=>a!==i-1&&a!==i);return o.length?new cs({children:o}):null}}}getInterpolatedProps(e,t,n){const i=nh(e),o=nh(t),s=[],a=[];let c=nee;if(i.length>o.length)for(let l=0;l<i.length;l++)s[l]={...i[l]},o[l]===void 0?a[l]={...o[o.length-1],id:c}:a[l]={...o[l],id:c},c=ca(c);else if(o.length>i.length)for(let l=0;l<o.length;l++)a[l]={...o[l]},i[l]===void 0?s[l]={...i[i.length-1],id:c}:s[l]={...i[l],id:c},c=ca(c);else for(let l=0;l<o.length;l++)s[l]=i[l],a[l]=o[l];return{...n>.5?t.props:e.props,points:Object.fromEntries(s.map((l,d)=>{const f=a[d];return[l.id,{...l,x:or(l.x,f.x,n),y:or(l.y,f.y,n)}]})),scale:or(e.props.scale,t.props.scale,n)}}}q(Pv,"type","line"),q(Pv,"props",Cte),q(Pv,"migrations",Tte);function nh(r){return Object.values(r.props.points).sort(_i)}function ih(r){const e=nh(r).map(T.From);switch(r.props.spline){case"cubic":return new L2e({points:e});case"line":return new Vd({points:e})}}function gJ({shape:r,shouldScale:e=!1,forceSolid:t=!1}){const n=fs(),i=ih(r),{dash:o,color:s,size:a}=r.props,c=1/r.props.scale,l=e?c:1,d=da[a]*r.props.scale;if(r.props.spline==="line"){if(o==="solid"){const f=i.points,h="M"+f[0]+"L"+f.slice(1);return v.jsx("path",{d:h,stroke:n[s].solid,strokeWidth:d,fill:"none",transform:`scale(${l})`})}if(o==="dashed"||o==="dotted")return v.jsx("g",{stroke:n[s].solid,strokeWidth:d,transform:`scale(${l})`,children:i.segments.map((f,h)=>{const{strokeDasharray:g,strokeDashoffset:m}=t?{strokeDasharray:"none",strokeDashoffset:"none"}:Ps(f.length,d,{style:o,start:h>0?"outset":"none",end:h<i.segments.length-1?"outset":"none"});return v.jsx("path",{strokeDasharray:g,strokeDashoffset:m,d:f.getSvgPathData(!0),fill:"none"},h)})});if(o==="draw"){const f=i.points,[h,g]=Ade(r.id,f,d);return v.jsx("path",{d:g,stroke:n[s].solid,strokeWidth:d,fill:"none",transform:`scale(${l})`})}}if(r.props.spline==="cubic"){const f=i.getSvgPathData();if(o==="solid")return v.jsx("path",{strokeWidth:d,stroke:n[s].solid,fill:"none",d:f,transform:`scale(${l})`});if(o==="dashed"||o==="dotted")return v.jsx("g",{stroke:n[s].solid,strokeWidth:d,transform:`scale(${l})`,children:i.segments.map((h,g)=>{const{strokeDasharray:m,strokeDashoffset:y}=Ps(h.length,d,{style:o,start:g>0?"outset":"none",end:g<i.segments.length-1?"outset":"none",forceSolid:t});return v.jsx("path",{strokeDasharray:m,strokeDashoffset:y,d:h.getSvgPathData(),fill:"none"},g)})});if(o==="draw")return v.jsx("path",{d:T3e(r,i,d),strokeWidth:1,stroke:n[s].solid,fill:n[s].solid,transform:`scale(${l})`})}}class Cv extends Rs{constructor(){super(...arguments);q(this,"options",{resizeMode:"none"})}canEdit(){return!0}hideResizeHandles(){const{resizeMode:t}=this.options;switch(t){case"none":return!0;case"scale":return!1;default:throw An(t)}}isAspectRatioLocked(){return this.options.resizeMode==="scale"}hideSelectionBoundsFg(){return!1}getDefaultProps(){return{color:"black",size:"m",text:"",font:"draw",align:"middle",verticalAlign:"middle",labelColor:"black",growY:0,fontSizeAdjustment:0,url:"",scale:1}}getGeometry(t){const{labelHeight:n,labelWidth:i}=Rde(this.editor,t),{scale:o}=t.props,s=n*o,a=i*o,c=Ir*o,l=Jg(t);return new cs({children:[new ma({width:c,height:l,isFilled:!0}),new ma({x:t.props.align==="start"?0:t.props.align==="end"?c-a:(c-a)/2,y:t.props.verticalAlign==="start"?0:t.props.verticalAlign==="end"?l-s:(l-s)/2,width:a,height:s,isFilled:!0,isLabel:!0})]})}getHandles(t){const{scale:n}=t.props;if(this.editor.getInstanceState().isCoarsePointer)return[];const o=this.editor.getZoomLevel();if(o*n<.25)return[];const s=Jg(t),a=Ir*n,c=GFe/o*n;return o*n<.5?[{id:"bottom",index:"a3",type:"clone",x:a/2,y:s+c}]:[{id:"top",index:"a1",type:"clone",x:a/2,y:-c},{id:"right",index:"a2",type:"clone",x:a+c,y:s/2},{id:"bottom",index:"a3",type:"clone",x:a/2,y:s+c},{id:"left",index:"a4",type:"clone",x:-c,y:s/2}]}onResize(t,n){const{resizeMode:i}=this.options;switch(i){case"none":return;case"scale":return $ee(t,n);default:throw An(i)}}getText(t){return t.props.text}component(t){const{id:n,type:i,props:{labelColor:o,scale:s,color:a,font:c,size:l,align:d,text:f,verticalAlign:h,fontSizeAdjustment:g}}=t,m=M3e(n),y=fs(),x=Ir*s,_=Jg(t),w=ye("shape rotation",()=>{var C;return((C=this.editor.getShapePageTransform(n))==null?void 0:C.rotation())??0},[this.editor]),I=ye("zoom",()=>this.editor.getZoomLevel()<.35/s,[s,this.editor]),b=ye("dark mode",()=>this.editor.user.getIsDarkMode(),[this.editor]),P=t.id===this.editor.getOnlySelectedShapeId();return v.jsxs(v.Fragment,{children:[v.jsx("div",{id:n,className:"tl-note__container",style:{width:x,height:_,backgroundColor:y[a].note.fill,borderBottom:I?b?`${2*s}px solid rgb(20, 20, 20)`:`${2*s}px solid rgb(144, 144, 144)`:"none",boxShadow:I?"none":j3e(t.id,w,s)},children:v.jsx(sS,{shapeId:n,type:i,font:c,fontSize:(g||ic[l])*s,lineHeight:Ii.lineHeight,align:d,verticalAlign:h,text:f,isNote:!0,isSelected:P,labelColor:o==="black"?y[a].note.text:y[o].fill,wrap:!0,padding:16*s,onKeyDown:m})}),"url"in t.props&&t.props.url&&v.jsx(Pd,{url:t.props.url})]})}indicator(t){const{scale:n}=t.props;return v.jsx("rect",{rx:n,width:fe(Ir*n),height:fe(Jg(t))})}toSvg(t,n){t.props.text&&n.addExportDef(iS(t.props.font));const i=uc({isDarkMode:n.isDarkMode}),o=D3e(t);return v.jsxs(v.Fragment,{children:[v.jsx("rect",{x:5,y:5,rx:1,width:Ir-10,height:o.h,fill:"rgba(0,0,0,.1)"}),v.jsx("rect",{rx:1,width:Ir,height:o.h,fill:i[t.props.color].note.fill}),v.jsx(oS,{fontSize:t.props.fontSizeAdjustment||ic[t.props.size],font:t.props.font,align:t.props.align,verticalAlign:t.props.verticalAlign,text:t.props.text,labelColor:i[t.props.color].note.text,bounds:o,stroke:!1})]})}onBeforeCreate(t){return vJ(this.editor,t)}onBeforeUpdate(t,n){if(!(t.props.text===n.props.text&&t.props.font===n.props.font&&t.props.size===n.props.size))return vJ(this.editor,n)}onEditEnd(t){const{id:n,type:i,props:{text:o}}=t;o.trimEnd()!==t.props.text&&this.editor.updateShapes([{id:n,type:i,props:{text:o.trimEnd()}}])}getInterpolatedProps(t,n,i){return{...i>.5?n.props:t.props,scale:or(t.props.scale,n.props.scale,i)}}}q(Cv,"type","note"),q(Cv,"props",Ate),q(Cv,"migrations",Rte);function vJ(r,e){const{labelHeight:t,fontSizeAdjustment:n}=Rde(r,e),i=Math.max(0,t-Ir);if(i!==e.props.growY||n!==e.props.fontSizeAdjustment)return{...e,props:{...e.props,growY:i,fontSizeAdjustment:n}}}function k3e(r,e){const{text:t}=e.props;if(!t)return{labelHeight:ic[e.props.size]*Ii.lineHeight+ts*2,labelWidth:100,fontSizeAdjustment:0};const n=ic[e.props.size];let i=0,o=0,s=Ir,a=Ir;const c=1;do{i=Math.min(n,n-o);const l=r.textMeasure.measureText(t,{...Ii,fontFamily:ac[e.props.font],fontSize:i,maxWidth:Ir-ts*2-c,disableOverflowWrapBreaking:!0});if(s=l.h+ts*2,a=l.w+ts*2,i<=14){const d=r.textMeasure.measureText(t,{...Ii,fontFamily:ac[e.props.font],fontSize:i,maxWidth:Ir-ts*2-c});s=d.h+ts*2,a=d.w+ts*2;break}if(l.scrollWidth.toFixed(0)===l.w.toFixed(0))break}while(o++<50);return{labelHeight:s,labelWidth:a,fontSizeAdjustment:i}}const O3e=new js;function Rde(r,e){return O3e.get(e,()=>k3e(r,e))}function M3e(r){const e=he(),t=sue();return A.useCallback(n=>{const i=e.getShape(r);if(!i)return;const o=n.key==="Tab",s=(n.metaKey||n.ctrlKey)&&n.key==="Enter";if(o||s){n.preventDefault();const a=e.getShapePageTransform(r),c=a.rotation(),l=!!(t.dir==="rtl"||Yue(i.props.text)),d=(Ir+e.options.adjacentShapeMargin+(s&&!n.shiftKey?i.props.growY:0))*i.props.scale,f=new T(o?n.shiftKey!=l?-1:1:0,s?n.shiftKey?-1:1:0).mul(d).add(nS.clone().mul(i.props.scale)).rot(c).add(a.point()),h=sde(e,i,f,c);h&&(e.markHistoryStoppingPoint("editing adjacent shape"),dm(e,h,!0))}},[r,e,t.dir])}function Jg(r){return(Ir+r.props.growY)*r.props.scale}function j3e(r,e,t){const n=Ds(r),i=Math.abs(n())+.5,o=Math.cos(e),s=5*t,a=4*t,c=6*t,l=7*t;return`0px ${s-i}px ${s}px -${s}px rgba(15, 23, 31, .6),
376
- 0px ${(a+i*l)*Math.max(0,o)}px ${c+i*l}px -${a+i*c}px rgba(15, 23, 31, ${(.3+i*.1).toFixed(2)}),
377
- 0px ${48*t}px ${10*t}px -${10*t}px inset rgba(15, 23, 44, ${((.022+n()*.005)*((1+o)/2)).toFixed(2)})`}function D3e(r){return new He(0,0,Ir,Ir+r.props.growY)}const L3e=new js;class Tv extends Rs{constructor(){super(...arguments);q(this,"options",{extraArrowHorizontalPadding:10})}getDefaultProps(){return{color:"black",size:"m",w:8,text:"",font:"draw",textAlign:"start",autoSize:!0,scale:1}}getMinDimensions(t){return L3e.get(t.props,n=>mJ(this.editor,n))}getGeometry(t,n){const{scale:i}=t.props,{width:o,height:s}=this.getMinDimensions(t),a=(n==null?void 0:n.context)??"none";return new ma({x:(a==="@tldraw/arrow-start"?-this.options.extraArrowHorizontalPadding:0)*i,width:(o+(a==="@tldraw/arrow-start"?this.options.extraArrowHorizontalPadding*2:0))*i,height:s*i,isFilled:!0,isLabel:!0})}getText(t){return t.props.text}canEdit(){return!0}isAspectRatioLocked(){return!0}component(t){const{id:n,props:{font:i,size:o,text:s,color:a,scale:c,textAlign:l}}=t,{width:d,height:f}=this.getMinDimensions(t),h=t.id===this.editor.getOnlySelectedShapeId(),g=fs(),m=F3e(n);return v.jsx(sS,{shapeId:n,classNamePrefix:"tl-text-shape",type:"text",font:i,fontSize:Ed[o],lineHeight:Ii.lineHeight,align:l,verticalAlign:"middle",text:s,labelColor:g[a].solid,isSelected:h,textWidth:d,textHeight:f,style:{transform:`scale(${c})`,transformOrigin:"top left"},wrap:!0,onKeyDown:m})}indicator(t){const n=this.editor.getShapeGeometry(t).bounds,i=he();return t.props.autoSize&&i.getEditingShapeId()===t.id?null:v.jsx("rect",{width:fe(n.width),height:fe(n.height)})}toSvg(t,n){t.props.text&&n.addExportDef(iS(t.props.font));const i=this.editor.getShapeGeometry(t).bounds,o=i.width/(t.props.scale??1),s=i.height/(t.props.scale??1),a=uc(n);return v.jsx(oS,{fontSize:Ed[t.props.size],font:t.props.font,align:t.props.textAlign,verticalAlign:"middle",text:t.props.text,labelColor:a[t.props.color].solid,bounds:new He(0,0,o,s),padding:0})}onResize(t,n){const{newPoint:i,initialBounds:o,initialShape:s,scaleX:a,handle:c}=n;if(n.mode==="scale_shape"||c!=="right"&&c!=="left")return{id:t.id,type:t.type,...$ee(t,n)};{const l=Math.max(1,Math.abs(o.width*a)),{x:d,y:f}=a<0?T.Sub(i,T.FromAngle(t.rotation).mul(l)):i;return{id:t.id,type:t.type,x:d,y:f,props:{w:l/s.props.scale,autoSize:!1}}}}onEditEnd(t){const{id:n,type:i,props:{text:o}}=t,s=t.props.text.trimEnd();s.length===0?this.editor.deleteShapes([t.id]):s!==t.props.text&&this.editor.updateShapes([{id:n,type:i,props:{text:o.trimEnd()}}])}onBeforeUpdate(t,n){if(!n.props.autoSize)return;const i=t.props.size!==n.props.size||t.props.textAlign!==n.props.textAlign||t.props.font!==n.props.font||t.props.scale!==1&&n.props.scale===1,o=t.props.text!==n.props.text;if(!i&&!o)return;const s=this.getMinDimensions(t),a=mJ(this.editor,n.props),c=s.width*t.props.scale,l=s.height*t.props.scale,d=a.width*n.props.scale,f=a.height*n.props.scale;let h;switch(n.props.textAlign){case"middle":{h=new T((d-c)/2,o?0:(f-l)/2);break}case"end":{h=new T(d-c,o?0:(f-l)/2);break}default:{if(o)break;h=new T(0,(f-l)/2);break}}if(h){h.rot(n.rotation);const{x:g,y:m}=n;return{...n,x:g-h.x,y:m-h.y,props:{...n.props,w:d}}}else return{...n,props:{...n.props,w:d}}}}q(Tv,"type","text"),q(Tv,"props",kte),q(Tv,"migrations",Ote);function mJ(r,e){const{font:t,text:n,autoSize:i,size:o,w:s}=e,a=i?16:Math.max(16,s),c=Ed[o],l=i?null:Math.floor(Math.max(a,s)),d=r.textMeasure.measureText(n,{...Ii,fontFamily:ac[t],fontSize:c,maxWidth:l});return i&&(d.w+=1),{width:Math.max(a,d.w),height:Math.max(c,d.h)}}function F3e(r){const e=he();return A.useCallback(t=>{if(e.getEditingShapeId()===r)switch(t.key){case"Enter":{(t.ctrlKey||t.metaKey)&&e.complete();break}case"Tab":{Qt(t),t.shiftKey?Id.unindent(t.currentTarget):Id.indent(t.currentTarget);break}}},[e,r])}const N3e=new js;class Av extends Qd{canEdit(){return!0}isAspectRatioLocked(){return!0}getDefaultProps(){return{w:100,h:100,assetId:null,time:0,playing:!0,url:""}}component(e){return v.jsx($3e,{shape:e})}indicator(e){return v.jsx("rect",{width:fe(e.props.w),height:fe(e.props.h)})}async toSvg(e,t){if(!e.props.assetId)return null;const n=this.editor.getAsset(e.props.assetId);if(!n)return null;const i=await N3e.get(n,async()=>{const o=await t.resolveAssetUrl(n.id,e.props.w);if(!o)return null;const s=await To.loadVideo(o);return await To.getVideoFrameAsDataUrl(s,0)});return i?v.jsx("image",{href:i,width:e.props.w,height:e.props.h}):null}}q(Av,"type","video"),q(Av,"props",Mte),q(Av,"migrations",jte);const $3e=A.memo(function({shape:e}){const t=he(),n=t.getShapeGeometry(e).bounds.w*t.getZoomLevel()>=110,i=My(e.id),o=nce(),{Spinner:s}=Gr(),{asset:a,url:c}=bde({shapeId:e.id,assetId:e.props.assetId,width:e.props.w}),l=A.useRef(null),[d,f]=A.useState(!1),[h,g]=A.useState(!1);A.useEffect(()=>{const y=()=>g(document.fullscreenElement===l.current);return document.addEventListener("fullscreenchange",y),()=>document.removeEventListener("fullscreenchange",y)});const m=A.useCallback(y=>{y.currentTarget&&f(!0)},[]);return A.useEffect(()=>{const y=l.current;y&&i&&document.activeElement!==y&&y.focus()},[i,d]),A.useEffect(()=>{if(o){const y=l.current;if(!y)return;y.pause(),y.currentTime=0}},[l,o]),v.jsxs(v.Fragment,{children:[v.jsx(Xc,{id:e.id,style:{color:"var(--color-text-3)",backgroundColor:a?"transparent":"var(--color-low)",border:a?"none":"1px solid var(--color-low-border)"},children:v.jsx("div",{className:"tl-counter-scaled",children:v.jsx("div",{className:"tl-video-container",children:a?s&&!a.props.src?v.jsx(s,{}):c?v.jsxs(v.Fragment,{children:[v.jsx("video",{ref:l,style:i?{pointerEvents:"all"}:d?void 0:{display:"none"},className:bt("tl-video",`tl-video-shape-${e.id.split(":")[1]}`,{"tl-video-is-fullscreen":h}),width:"100%",height:"100%",draggable:!1,playsInline:!0,autoPlay:!0,muted:!0,loop:!0,disableRemotePlayback:!0,disablePictureInPicture:!0,controls:i&&n,onLoadedData:m,hidden:!d,children:v.jsx("source",{src:c})}),!d&&s&&v.jsx(s,{})]}):null:v.jsx(wde,{})})})}),"url"in e.props&&e.props.url&&v.jsx(Pd,{url:e.props.url})]})}),kde=[Tv,xv,_v,bv,Cv,Pv,wv,Sv,Ev,Sm,Iv,Av];function q3e(r){return r.sideEffects.register({instance_page_state:{afterChange:(e,t)=>{if(e.croppingShapeId!==t.croppingShapeId){const n=r.isIn("select.crop");!e.croppingShapeId&&t.croppingShapeId?n||r.setCurrentTool("select.crop.idle"):e.croppingShapeId&&!t.croppingShapeId&&n&&r.setCurrentTool("select.idle")}if(e.editingShapeId!==t.editingShapeId)if(!e.editingShapeId&&t.editingShapeId){if(!r.isIn("select.editing_shape")){const n=r.getEditingShape();n&&n.type==="text"&&r.isInAny("text.pointing","select.resizing")&&r.getInstanceState().isToolLocked?r.setCurrentTool("select.editing_shape",{isCreatingTextWhileToolLocked:!0}):r.setCurrentTool("select.editing_shape")}}else e.editingShapeId&&!t.editingShapeId&&r.isIn("select.editing_shape")&&r.setCurrentTool("select.idle")}}})}class Ode extends vt{constructor(){super(...arguments);q(this,"info",{});q(this,"scribbleId","id");q(this,"markId","");q(this,"excludedShapeIds",new Set)}onEnter(t){this.markId=this.editor.markHistoryStoppingPoint("erase scribble begin"),this.info=t;const{originPagePoint:n}=this.editor.inputs;this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(o=>{if(this.editor.isShapeOrAncestorLocked(o))return!0;if(this.editor.isShapeOfType(o,"group")||this.editor.isShapeOfType(o,"frame")){const s=this.editor.getPointInShapeSpace(o,n);return this.editor.getShapeGeometry(o).bounds.containsPoint(s)}return!1}).map(o=>o.id));const i=this.editor.scribbles.addScribble({color:"muted-1",size:12});this.scribbleId=i.id,this.update()}pushPointToScribble(){const{x:t,y:n}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,t,n)}onExit(){this.editor.setErasingShapes([]),this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}update(){const{editor:t,excludedShapeIds:n}=this,i=t.getErasingShapeIds(),o=t.getZoomLevel(),s=t.getCurrentPageRenderingShapesSorted(),{inputs:{currentPagePoint:a,previousPagePoint:c}}=t;this.pushPointToScribble();const l=new Set(i),d=this.editor.options.hitTestMargin/o;for(const f of s){if(t.isShapeOfType(f,"group"))continue;const h=t.getShapeMask(f.id);if(h&&!Oo(a,h))continue;const g=t.getShapeGeometry(f),m=t.getShapePageTransform(f);if(!g||!m)continue;const y=m.clone().invert(),x=y.applyToPoint(c),_=y.applyToPoint(a),{bounds:w}=g;w.minX-d>Math.max(x.x,_.x)||w.minY-d>Math.max(x.y,_.y)||w.maxX+d<Math.min(x.x,_.x)||w.maxY+d<Math.min(x.y,_.y)||g.hitTestLineSegment(x,_,d)&&l.add(t.getOutermostSelectableShape(f).id)}this.editor.setErasingShapes([...l].filter(f=>!n.has(f)))}complete(){const{editor:t}=this;t.deleteShapes(t.getCurrentPageState().erasingShapeIds),this.parent.transition("idle")}cancel(){const{editor:t}=this;t.bailToMark(this.markId),this.parent.transition("idle",this.info)}}q(Ode,"id","erasing");var cP;let B3e=(cP=class extends vt{onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){this.editor.setCurrentTool("select")}},q(cP,"id","idle"),cP);var lP;let U3e=(lP=class extends vt{onEnter(){const e=this.editor.getZoomLevel(),t=this.editor.getCurrentPageRenderingShapesSorted(),{inputs:{currentPagePoint:n}}=this.editor,i=new Set,o=i.size;for(let s=t.length,a=s-1;a>=0;a--){const c=t[a];if(!(this.editor.isShapeOrAncestorLocked(c)||this.editor.isShapeOfType(c,"group"))&&this.editor.isPointInShape(c,n,{hitInside:!1,margin:this.editor.options.hitTestMargin/e})){const l=this.editor.getOutermostSelectableShape(c);if(this.editor.isShapeOfType(l,"frame")&&i.size>o)break;i.add(l.id)}}this.editor.setErasingShapes([...i])}onLongPress(e){this.startErasing(e)}onExit(e,t){t!=="erasing"&&this.editor.setErasingShapes([])}onPointerMove(e){this.editor.inputs.isDragging&&this.startErasing(e)}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.complete()}onInterrupt(){this.cancel()}startErasing(e){this.parent.transition("erasing",e)}complete(){const e=this.editor.getErasingShapeIds();e.length&&(this.editor.markHistoryStoppingPoint("erase end"),this.editor.deleteShapes(e)),this.parent.transition("idle")}cancel(){this.parent.transition("idle")}},q(lP,"id","pointing"),lP);class Rv extends vt{static children(){return[B3e,U3e,Ode]}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}}q(Rv,"id","eraser"),q(Rv,"initial","idle"),q(Rv,"isLockable",!1);class Mde extends vt{constructor(){super(...arguments);q(this,"initialCamera",new T)}onEnter(){this.initialCamera=T.From(this.editor.getCamera()),this.update()}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.parent.transition("idle")}onComplete(){this.complete()}update(){const{initialCamera:t,editor:n}=this,{currentScreenPoint:i,originScreenPoint:o}=n.inputs,s=T.Sub(i,o).div(n.getZoomLevel());s.len2()!==0&&n.setCamera(t.clone().add(s))}complete(){const{editor:t}=this,{pointerVelocity:n}=t.inputs,i=Math.min(n.len(),2);i>.1&&this.editor.slideCamera({speed:i,direction:n}),this.parent.transition("idle")}}q(Mde,"id","dragging");var uP;let z3e=(uP=class extends vt{onEnter(){this.editor.setCursor({type:"grab",rotation:0})}onPointerDown(e){this.parent.transition("pointing",e)}onCancel(){this.editor.setCurrentTool("select")}},q(uP,"id","idle"),uP);var dP;let H3e=(dP=class extends vt{onEnter(){this.editor.stopCameraAnimation(),this.editor.setCursor({type:"grabbing",rotation:0})}onLongPress(){this.startDragging()}onPointerMove(){this.editor.inputs.isDragging&&this.startDragging()}startDragging(){this.parent.transition("dragging")}onPointerUp(){this.complete()}onCancel(){this.complete()}onComplete(){this.complete()}onInterrupt(){this.complete()}complete(){this.parent.transition("idle")}},q(dP,"id","pointing"),dP);class kv extends vt{static children(){return[z3e,H3e,Mde]}onDoubleClick(e){if(e.phase==="settle"){const{currentScreenPoint:t}=this.editor.inputs;this.editor.zoomIn(t,{animation:{duration:220,easing:zn.easeOutQuint}})}}onTripleClick(e){if(e.phase==="settle"){const{currentScreenPoint:t}=this.editor.inputs;this.editor.zoomOut(t,{animation:{duration:320,easing:zn.easeOutQuint}})}}onQuadrupleClick(e){if(e.phase==="settle"){const t=this.editor.getZoomLevel(),{inputs:{currentScreenPoint:n}}=this.editor;t===1?this.editor.zoomToFit({animation:{duration:400,easing:zn.easeOutQuint}}):this.editor.resetZoom(n,{animation:{duration:320,easing:zn.easeOutQuint}})}}}q(kv,"id","hand"),q(kv,"initial","idle"),q(kv,"isLockable",!1);var fP;let W3e=(fP=class extends vt{onPointerDown(e){this.parent.transition("lasering",e)}},q(fP,"id","idle"),fP);class jde extends vt{constructor(){super(...arguments);q(this,"scribbleId","id")}onEnter(){const t=this.editor.scribbles.addScribble({color:"laser",opacity:.7,size:4,delay:this.editor.options.laserDelayMs,shrink:.05,taper:!0});this.scribbleId=t.id,this.pushPointToScribble()}onExit(){this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.pushPointToScribble()}onPointerUp(){this.complete()}pushPointToScribble(){const{x:t,y:n}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,t,n)}onCancel(){this.cancel()}onComplete(){this.complete()}complete(){this.parent.transition("idle")}cancel(){this.parent.transition("idle")}}q(jde,"id","lasering");class Ov extends vt{static children(){return[W3e,jde]}onEnter(){this.editor.setCursor({type:"cross",rotation:0})}}q(Ov,"id","laser"),q(Ov,"initial","idle"),q(Ov,"isLockable",!1);class Dde extends vt{constructor(){super(...arguments);q(this,"info",{});q(this,"initialSelectedShapeIds",[]);q(this,"excludedShapeIds",new Set);q(this,"isWrapMode",!1);q(this,"initialStartShape",null)}onEnter(t){const{altKey:n,currentPagePoint:i}=this.editor.inputs;if(this.isWrapMode=this.editor.user.getIsWrapMode(),n){this.parent.transition("scribble_brushing",t);return}this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(o=>this.editor.isShapeOfType(o,"group")||this.editor.isShapeOrAncestorLocked(o)).map(o=>o.id)),this.info=t,this.initialSelectedShapeIds=this.editor.getSelectedShapeIds().slice(),this.initialStartShape=this.editor.getShapesAtPoint(i)[0],this.hitTestShapes()}onExit(){this.initialSelectedShapeIds=[],this.editor.updateInstanceState({brush:null})}onTick({elapsed:t}){const{editor:n}=this;n.edgeScrollManager.updateEdgeScrolling(t)}onPointerMove(){this.hitTestShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(t){this.editor.setSelectedShapes(this.initialSelectedShapeIds),this.parent.transition("idle",t)}onKeyDown(t){this.editor.inputs.altKey?this.parent.transition("scribble_brushing",t):this.hitTestShapes()}onKeyUp(){this.hitTestShapes()}complete(){this.hitTestShapes(),this.parent.transition("idle")}hitTestShapes(){const{editor:t,excludedShapeIds:n,isWrapMode:i}=this,{inputs:{originPagePoint:o,currentPagePoint:s,shiftKey:a,ctrlKey:c}}=t,l=new Set(a?this.initialSelectedShapeIds:[]),d=i?!c:c,f=He.FromPoints([o,s]),{corners:h}=f;let g,m,y,x,_,w;const I=t.getCurrentPageRenderingShapesSorted(),b=t.getCurrentPageId();e:for(let k=0,O=I.length;k<O;k++){if(y=I[k],n.has(y.id)||l.has(y.id)||(x=t.getShapePageBounds(y),!x))continue e;if(f.contains(x)){this.handleHit(y,s,b,l,h);continue e}if(d||t.isShapeOfType(y,"frame"))continue e;if(f.collides(x)){if(_=t.getShapePageTransform(y),!_)continue e;w=_.clone().invert().applyToPoints(h);const L=t.getShapeGeometry(y);t:for(let j=0;j<4;j++)if(g=w[j],m=w[(j+1)%4],L.hitTestLineSegment(g,m,0)){this.handleHit(y,s,b,l,h);break t}}}const P=t.getInstanceState().brush;(!P||!f.equals(P))&&t.updateInstanceState({brush:{...f.toJson()}});const C=t.getSelectedShapeIds();(C.length!==l.size||C.some(k=>!l.has(k)))&&t.setSelectedShapes(Array.from(l))}onInterrupt(){this.editor.updateInstanceState({brush:null})}handleHit(t,n,i,o,s){if(t.parentId===i){o.add(t.id);return}const a=this.editor.getOutermostSelectableShape(t),c=this.editor.getShapeMask(a.id);c&&!aA(c,s)&&!Oo(n,c)||o.add(a.id)}}q(Dde,"id","brushing");const Td={bottom:"ns-resize",top:"ns-resize",left:"ew-resize",right:"ew-resize",bottom_left:"nesw-resize",bottom_right:"nwse-resize",top_left:"nwse-resize",top_right:"nesw-resize",bottom_left_rotate:"swne-rotate",bottom_right_rotate:"senw-rotate",top_left_rotate:"nwse-rotate",top_right_rotate:"nesw-rotate",mobile_rotate:"grabbing"};class Lde extends vt{constructor(){super(...arguments);q(this,"info",{})}updateCursor(){const t=this.editor.getSelectedShapes(),n=Td[this.info.handle];this.editor.setCursor({type:n,rotation:t.length===1?this.editor.getSelectionRotation():0})}onEnter(t){this.info=t,this.updateCursor()}onPointerMove(){this.editor.inputs.isDragging&&this.startResizing()}onLongPress(){this.startResizing()}startResizing(){this.editor.getIsReadonly()||this.parent.transition("resizing",this.info)}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}q(Lde,"id","pointing_resize_handle");class xR extends vt{constructor(){super(...arguments);q(this,"info",{});q(this,"markId","");q(this,"snapshot",{})}onEnter(t){this.info=t,this.markId=this.editor.markHistoryStoppingPoint("cropping"),this.snapshot=this.createSnapshot(),this.updateShapes()}onPointerMove(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}updateCursor(){if(!this.editor.getSelectedShapes()[0])return;const n=Td[this.info.handle];this.editor.setCursor({type:n,rotation:this.editor.getSelectionRotation()})}updateShapes(){var h;const{shape:t,cursorHandleOffset:n}=this.snapshot;if(!t)return;const i=this.editor.getShapeUtil(t.type);if(!i)return;const o=this.editor.inputs.currentPagePoint.clone().sub(n),s=this.editor.inputs.originPagePoint.clone().sub(n),a=o.clone().sub(s).rot(-t.rotation),c=t.props.crop??_3e(),l={w:1/(c.bottomRight.x-c.topLeft.x)*t.props.w,h:1/(c.bottomRight.y-c.topLeft.y)*t.props.h},f=(((h=i.onCrop)==null?void 0:h.bind(i))??w3e)(t,{handle:this.info.handle,change:a,crop:c,uncroppedSize:l,initialShape:this.snapshot.shape});f&&(this.editor.updateShapes([{id:t.id,type:t.type,...f}]),this.updateCursor())}complete(){this.updateShapes(),Fr(this.editor,[this.snapshot.shape.id]),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}createSnapshot(){const t=this.editor.getSelectionRotation(),{inputs:{originPagePoint:n}}=this.editor,i=this.editor.getOnlySelectedShape(),o=this.editor.getSelectionRotatedPageBounds(),s=T.RotWith(o.getHandlePoint(this.info.handle),o.point,t),a=T.Sub(n,s);return{shape:i,cursorHandleOffset:a}}}q(xR,"id","cropping");function Fde(r,e=!1){const t=r.getZoomLevel(),{inputs:{currentPagePoint:n}}=r;return r.getShapeAtPoint(n,{hitInside:!1,hitLabels:e,margin:r.options.hitTestMargin/t,renderingOnly:!0})??r.getSelectedShapeAtPoint(n)}function Nde(r,e,t){if(!e)throw Error("Needs to translate a cropped shape!");const{crop:n}=e.props;if(!n)return;const i=r.inputs.shiftKey?Math.abs(t.x)<Math.abs(t.y)?"x":"y":null;i==="x"?t.x=0:i==="y"&&(t.y=0),t.rot(-e.rotation);const{w:o,h:s}=Rh(e.props,n),a=n.bottomRight.y-n.topLeft.y,c=n.bottomRight.x-n.topLeft.x,l=Kr(n);return l.topLeft.x=Math.min(1-c,Math.max(0,l.topLeft.x-t.x/o)),l.topLeft.y=Math.min(1-a,Math.max(0,l.topLeft.y-t.y/s)),l.bottomRight.x=l.topLeft.x+c,l.bottomRight.y=l.topLeft.y+a,{id:e.id,type:e.type,props:{crop:l}}}var hP;let K3e=(hP=class extends vt{onEnter(){this.editor.setCursor({type:"default",rotation:0});const e=this.editor.getOnlySelectedShape();e&&this.editor.setCroppingShape(e.id)}onExit(){this.editor.setCursor({type:"default",rotation:0})}onCancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}onPointerDown(e){var t;if(e.accelKey){this.cancel(),this.editor.root.handleEvent(e);return}switch(e.target){case"canvas":{const n=Fde(this.editor);if(n&&!this.editor.isShapeOfType(n,"group")){this.onPointerDown({...e,shape:n,target:"shape"});return}this.cancel(),this.editor.root.handleEvent(e);break}case"shape":{if(e.shape.id===this.editor.getCroppingShapeId()){this.editor.setCurrentTool("select.crop.pointing_crop",e);return}else(t=this.editor.getShapeUtil(e.shape))!=null&&t.canCrop(e.shape)?(this.editor.setCroppingShape(e.shape.id),this.editor.setSelectedShapes([e.shape.id]),this.editor.setCurrentTool("select.crop.pointing_crop",e)):(this.cancel(),this.editor.root.handleEvent(e));break}case"selection":{switch(e.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{this.editor.setCurrentTool("select.pointing_rotate_handle",{...e,onInteractionEnd:"select.crop.idle"});break}case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{this.editor.setCurrentTool("select.crop.pointing_crop_handle",{...e,onInteractionEnd:"select.crop.idle"});break}default:this.cancel()}break}}}onDoubleClick(e){var o;if(this.editor.inputs.shiftKey||e.phase!=="up")return;const t=this.editor.getCroppingShapeId();if(!t)return;const n=this.editor.getShape(t);if(!n)return;const i=this.editor.getShapeUtil(n);if(i){if(e.target==="selection"){(o=i.onDoubleClickEdge)==null||o.call(i,n);return}this.cancel(),this.editor.root.handleEvent(e)}}onKeyDown(){this.nudgeCroppingImage(!1)}onKeyRepeat(){this.nudgeCroppingImage(!0)}onKeyUp(e){switch(e.code){case"Enter":{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{});break}}}cancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}nudgeCroppingImage(e=!1){const{editor:{inputs:{keys:t}}}=this,n=t.has("ShiftLeft"),i=new T(0,0);if(t.has("ArrowLeft")&&(i.x+=1),t.has("ArrowRight")&&(i.x-=1),t.has("ArrowUp")&&(i.y+=1),t.has("ArrowDown")&&(i.y-=1),i.equals(new T(0,0)))return;n&&i.mul(10);const o=this.editor.getShape(this.editor.getCroppingShapeId());if(!o)return;const s=Nde(this.editor,o,i);s&&(e||this.editor.markHistoryStoppingPoint("translate crop"),this.editor.updateShapes([s]))}},q(hP,"id","idle"),hP);class $de extends vt{onCancel(){this.editor.setCurrentTool("select.crop.idle",{})}onPointerMove(e){this.editor.inputs.isDragging&&this.editor.setCurrentTool("select.crop.translating_crop",e)}onPointerUp(e){this.editor.setCurrentTool("select.crop.idle",e)}}q($de,"id","pointing_crop");class _R extends vt{constructor(){super(...arguments);q(this,"info",{})}onEnter(t){this.info=t,this.parent.setCurrentToolIdMask(t.onInteractionEnd);const n=this.editor.getSelectedShapes()[0];if(!n)return;const i=Td[this.info.handle];this.editor.setCursor({type:i,rotation:this.editor.getSelectionRotation()}),this.editor.setCroppingShape(n.id)}onExit(){this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0)}onPointerMove(){this.editor.inputs.isDragging&&this.startCropping()}onLongPress(){this.startCropping()}startCropping(){this.editor.getIsReadonly()||this.parent.transition("cropping",{...this.info,onInteractionEnd:this.info.onInteractionEnd})}onPointerUp(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}}q(_R,"id","pointing_crop_handle");class qde extends vt{constructor(){super(...arguments);q(this,"info",{});q(this,"markId","");q(this,"snapshot",{})}onEnter(t){this.info=t,this.snapshot=this.createSnapshot(),this.markId=this.editor.markHistoryStoppingPoint("translating_crop"),this.editor.setCursor({type:"move",rotation:0}),this.updateShapes()}onExit(){this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}onKeyDown(t){switch(t.key){case"Alt":case"Shift":{this.updateShapes();return}}}onKeyUp(t){switch(t.key){case"Enter":{this.complete();return}case"Alt":case"Shift":this.updateShapes()}}complete(){this.updateShapes(),this.editor.setCurrentTool("select.crop.idle",this.info)}cancel(){this.editor.bailToMark(this.markId),this.editor.setCurrentTool("select.crop.idle",this.info)}createSnapshot(){return{shape:this.editor.getOnlySelectedShape()}}updateShapes(){const t=this.snapshot.shape;if(!t)return;const{originPagePoint:n,currentPagePoint:i}=this.editor.inputs,o=i.clone().sub(n),s=Nde(this.editor,t,o);s&&this.editor.updateShapes([s])}}q(qde,"id","translating_crop");class xC extends vt{constructor(){super(...arguments);q(this,"markId","");q(this,"didExit",!1)}static children(){return[K3e,qde,$de,_R,xR]}onEnter(){this.didExit=!1,this.markId=this.editor.markHistoryStoppingPoint("crop")}onExit(){this.didExit||(this.didExit=!0,this.editor.squashToMark(this.markId))}onCancel(){this.didExit||(this.didExit=!0,this.editor.bailToMark(this.markId))}}q(xC,"id","crop"),q(xC,"initial","idle");class Bde extends vt{constructor(){super(...arguments);q(this,"shapeId","");q(this,"initialHandle",{});q(this,"initialAdjacentHandle",null);q(this,"initialPagePoint",{});q(this,"markId","");q(this,"initialPageTransform");q(this,"initialPageRotation");q(this,"info",{});q(this,"isPrecise",!1);q(this,"isPreciseId",null);q(this,"pointingId",null);q(this,"exactTimeout",-1)}onEnter(t){const{shape:n,isCreating:i,creatingMarkId:o,handle:s}=t;if(this.info=t,this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.shapeId=n.id,this.markId="",i)if(o)this.markId=o;else{const l=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);l&&(this.markId=l)}else this.markId=this.editor.markHistoryStoppingPoint("dragging handle");if(this.initialHandle=Kr(s),this.editor.isShapeOfType(n,"line")&&this.initialHandle.type==="create"){this.editor.updateShape({...n,props:{points:{...n.props.points,[s.index]:{id:s.index,index:s.index,x:s.x,y:s.y}}}});const d=this.editor.getShapeHandles(n).find(f=>f.index===s.index);this.initialHandle=Kr(d)}this.initialPageTransform=this.editor.getShapePageTransform(n),this.initialPageRotation=this.initialPageTransform.rotation(),this.initialPagePoint=this.editor.inputs.originPagePoint.clone(),this.editor.setCursor({type:i?"cross":"grabbing",rotation:0});const a=this.editor.getShapeHandles(n).sort(_i),c=a.findIndex(l=>l.id===t.handle.id);this.initialAdjacentHandle=null;for(let l=c+1;l<a.length;l++){const d=a[l];if(d.type==="vertex"&&d.id!=="middle"&&d.id!==t.handle.id){this.initialAdjacentHandle=d;break}}if(!this.initialAdjacentHandle)for(let l=a.length-1;l>=0;l--){const d=a[l];if(d.type==="vertex"&&d.id!=="middle"&&d.id!==t.handle.id){this.initialAdjacentHandle=d;break}}if(this.editor.isShapeOfType(n,"arrow")){const l=fo(this.editor,n)[t.handle.id];this.isPrecise=!1,l?(this.editor.setHintingShapes([l.toId]),this.isPrecise=l.props.isPrecise,this.isPrecise?this.isPreciseId=l.toId:this.resetExactTimeout()):this.editor.setHintingShapes([])}this.update(),this.editor.select(this.shapeId)}resetExactTimeout(){this.exactTimeout!==-1&&this.clearExactTimeout(),this.exactTimeout=this.editor.timers.setTimeout(()=>{this.getIsActive()&&!this.isPrecise&&(this.isPrecise=!0,this.isPreciseId=this.pointingId,this.update()),this.exactTimeout=-1},750)}clearExactTimeout(){this.exactTimeout!==-1&&(clearTimeout(this.exactTimeout),this.exactTimeout=-1)}onPointerMove(){this.update()}onKeyDown(){this.update()}onKeyUp(){this.update()}onPointerUp(){this.complete()}onComplete(){this.update(),this.complete()}onCancel(){this.cancel()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setHintingShapes([]),this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0})}complete(){this.editor.snaps.clearIndicators(),Fr(this.editor,[this.shapeId]);const{onInteractionEnd:t}=this.info;if(this.editor.getInstanceState().isToolLocked&&t){this.editor.setCurrentTool(t,{shapeId:this.shapeId});return}this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators();const{onInteractionEnd:t}=this.info;if(t){this.editor.setCurrentTool(t,{shapeId:this.shapeId});return}this.parent.transition("idle")}update(){var k;const{editor:t,shapeId:n,initialPagePoint:i}=this,{initialHandle:o,initialPageRotation:s,initialAdjacentHandle:a}=this,c=this.editor.getHintingShapeIds(),l=this.editor.user.getIsSnapMode(),{snaps:d,inputs:{currentPagePoint:f,shiftKey:h,ctrlKey:g,altKey:m,pointerVelocity:y}}=t,x=this.info.shape,_=t.getShape(n);if(!_)return;const w=t.getShapeUtil(_);let I=f.clone().sub(i).rot(-s).add(o);if(h&&a&&o.id!=="middle"){const O=T.Angle(a,I),j=Uv(O,24)-O;I=T.RotWith(I,a,j)}t.snaps.clearIndicators();let b={...o,x:I.x,y:I.y};if(o.canSnap&&(l?!g:g)){if(!t.getShapePageTransform(_.id))throw Error("Expected a page transform");const L=d.handles.snapHandle({currentShapeId:n,handle:b});L&&(L.nudge.rot(-t.getShapeParentTransform(_).rotation()),I.add(L.nudge),b={...o,x:I.x,y:I.y})}const P=(k=w.onHandleDrag)==null?void 0:k.call(w,_,{handle:b,isPrecise:this.isPrecise||m,initial:x}),C={id:_.id,type:_.type,...P};if(o.type==="vertex"&&this.editor.isShapeOfType(_,"arrow")){const O=fo(t,_)[o.id];O?c[0]!==O.toId&&(t.setHintingShapes([O.toId]),this.pointingId=O.toId,this.isPrecise=y.len()<.5||m,this.isPreciseId=this.isPrecise?O.toId:null,this.resetExactTimeout()):c.length>0&&(t.setHintingShapes([]),this.pointingId=null,this.isPrecise=!1,this.isPreciseId=null,this.resetExactTimeout())}P&&t.updateShapes([C])}}q(Bde,"id","dragging_handle");function Ude(r){return r.isLabel?[r]:r instanceof cs?r.children.filter(e=>e.isLabel):[]}class zde extends vt{constructor(){super(...arguments);q(this,"hitShapeForPointerUp",null);q(this,"info",{})}onEnter(t){const n=this.editor.getEditingShape();if(!n)throw Error("Entered editing state without an editing shape");this.hitShapeForPointerUp=null,this.info=t,t.isCreatingTextWhileToolLocked&&this.parent.setCurrentToolIdMask("text"),Ja(this.editor),this.editor.select(n)}onExit(){var o;const{editingShapeId:t}=this.editor.getCurrentPageState();if(!t)return;this.editor.setEditingShape(null),Ja.cancel();const n=this.editor.getShape(t),i=this.editor.getShapeUtil(n);(o=i.onEditEnd)==null||o.call(i,n),this.info.isCreatingTextWhileToolLocked&&(this.parent.setCurrentToolIdMask(void 0),this.editor.setCurrentTool("text",{}))}onPointerMove(t){if(this.hitShapeForPointerUp&&this.editor.inputs.isDragging){if(this.editor.getIsReadonly()||this.hitShapeForPointerUp.isLocked)return;this.editor.select(this.hitShapeForPointerUp),this.parent.transition("translating",t),this.hitShapeForPointerUp=null;return}switch(t.target){case"shape":case"canvas":{Ja(this.editor);return}}}onPointerDown(t){switch(this.hitShapeForPointerUp=null,t.target){case"shape":{const{shape:n}=t,i=this.editor.getEditingShape();if(!i)throw Error("Expected an editing shape!");const o=this.editor.getShapeUtil(n).getGeometry(n),s=Ude(o),a=s.length===1?s[0]:void 0,c=this.editor.isShapeOfType(i,"text")&&i.props.text.trim()==="";if(a&&!c){const l=this.editor.getPointInShapeSpace(n,this.editor.inputs.currentPagePoint);if(a.bounds.containsPoint(l,0)&&a.hitTestPoint(l)){if(n.id===i.id)return;this.hitShapeForPointerUp=n,this.editor.markHistoryStoppingPoint("editing on pointer up"),this.editor.select(n.id);return}}else{if(n.id===i.id)this.editor.isShapeOfType(n,"frame")&&(this.editor.setEditingShape(null),this.parent.transition("idle",t));else{this.parent.transition("pointing_shape",t);return}return}break}}this.parent.transition("idle",t),this.editor.root.handleEvent(t)}onPointerUp(t){const n=this.hitShapeForPointerUp;if(!n)return;this.hitShapeForPointerUp=null;const i=this.editor.getShapeUtil(n);if(!n.isLocked){if(this.editor.getIsReadonly()&&!i.canEditInReadOnly(n)){this.parent.transition("pointing_shape",t);return}this.editor.select(n.id),this.editor.setEditingShape(n.id),Ja(this.editor)}}onComplete(t){this.parent.transition("idle",t)}onCancel(t){this.parent.transition("idle",t)}}q(zde,"id","editing_shape");function yJ(r){const e=r.getOnlySelectedShape();return!!(e&&!r.isShapeOrAncestorLocked(e)&&r.getShapeUtil(e).canCrop(e))}function xm(r,e){const t=r.getSelectedShapeIds(),{currentPagePoint:n}=r.inputs,{shiftKey:i,altKey:o,accelKey:s}=e,a=i||s,c=r.getShapeAtPoint(n,{hitInside:!1,margin:r.options.hitTestMargin/r.getZoomLevel(),hitLabels:!0,renderingOnly:!0,filter:l=>!l.isLocked});if(c){const l=r.getOutermostSelectableShape(c);if(a&&!o)r.cancelDoubleClick(),t.includes(l.id)?(r.markHistoryStoppingPoint("deselecting shape"),r.deselect(l)):(r.markHistoryStoppingPoint("shift selecting shape"),r.setSelectedShapes([...t,l.id]));else{let d;l===c||l.id===r.getFocusedGroupId()||t.includes(l.id)?d=c:d=l,d&&!t.includes(d.id)&&(r.markHistoryStoppingPoint("selecting shape"),r.select(d.id))}}else{if(a)return;{t.length>0&&(r.markHistoryStoppingPoint("selecting none"),r.selectNone());const l=r.getFocusedGroupId();if(co(l)){const d=r.getShape(l);r.isPointInShape(d,n,{margin:0,hitInside:!0})||r.setFocusedGroup(null)}}}}const G3e=["Delete","Backspace","[","]","Enter"," ","Shift","Tab"];var pP;let V3e=(pP=class extends vt{onEnter(){this.parent.setCurrentToolIdMask(void 0),Ja(this.editor),this.editor.setCursor({type:"default",rotation:0})}onExit(){Ja.cancel()}onPointerMove(){Ja(this.editor)}onPointerDown(e){const t=e.ctrlKey&&yJ(this.editor);switch(e.target){case"canvas":{const n=Fde(this.editor);if(n&&!n.isLocked){this.onPointerDown({...e,shape:n,target:"shape"});return}const i=this.editor.getSelectedShapeIds(),o=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:s}}=this.editor;if((i.length>1||o&&!this.editor.getShapeUtil(o).hideSelectionBoundsBg(o))&&SJ(this.editor,s)){this.onPointerDown({...e,target:"selection"});return}this.parent.transition("pointing_canvas",e);break}case"shape":{const{shape:n}=e;if(this.isOverArrowLabelTest(n)){this.parent.transition("pointing_arrow_label",e);break}if(this.editor.isShapeOrAncestorLocked(n)){this.parent.transition("pointing_canvas",e);break}this.parent.transition("pointing_shape",e);break}case"handle":{if(this.editor.getIsReadonly())break;this.editor.inputs.altKey?this.parent.transition("pointing_shape",e):this.parent.transition("pointing_handle",e);break}case"selection":{switch(e.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{if(e.accelKey){this.parent.transition("brushing",e);break}this.parent.transition("pointing_rotate_handle",e);break}case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{if(t)this.parent.transition("crop.pointing_crop_handle",e);else{if(e.accelKey){this.parent.transition("brushing",e);break}this.parent.transition("pointing_resize_handle",e)}break}default:{const n=this.editor.getHoveredShape();if(n&&!this.editor.getSelectedShapeIds().includes(n.id)&&!n.isLocked){this.onPointerDown({...e,shape:n,target:"shape"});return}this.parent.transition("pointing_selection",e)}}break}}}onDoubleClick(e){var t,n,i,o;if(!(this.editor.inputs.shiftKey||e.phase!=="up")&&!(e.ctrlKey||e.shiftKey))switch(e.target){case"canvas":{const s=this.editor.getHoveredShape(),a=s&&!this.editor.isShapeOfType(s,"group")?s:this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint)??this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{margin:this.editor.options.hitTestMargin/this.editor.getZoomLevel(),hitInside:!1}),c=this.editor.getFocusedGroupId();if(a){if(this.editor.isShapeOfType(a,"group")){xm(this.editor,e);return}else{const l=this.editor.getShape(a.parentId);if(l&&this.editor.isShapeOfType(l,"group")&&!(c&&l.id===c)){xm(this.editor,e);return}}this.onDoubleClick({...e,shape:a,target:"shape"});return}this.editor.inputs.shiftKey||this.handleDoubleClickOnCanvas(e);break}case"selection":{if(this.editor.getIsReadonly())break;const s=this.editor.getOnlySelectedShape();if(s){const a=this.editor.getShapeUtil(s);if(!this.canInteractWithShapeInReadOnly(s))return;if(e.handle==="right"||e.handle==="left"||e.handle==="top"||e.handle==="bottom"){const c=(t=a.onDoubleClickEdge)==null?void 0:t.call(a,s);if(c){this.editor.markHistoryStoppingPoint("double click edge"),this.editor.updateShapes([c]),Fr(this.editor,[s.id]);return}}if(a.canCrop(s)&&!this.editor.isShapeOrAncestorLocked(s)){this.parent.transition("crop",e);return}this.shouldStartEditingShape(s)&&this.startEditingShape(s,e,!0)}break}case"shape":{const{shape:s}=e,a=this.editor.getShapeUtil(s);if(s.type!=="video"&&s.type!=="embed"&&this.editor.getIsReadonly())break;if(a.onDoubleClick){const c=(n=a.onDoubleClick)==null?void 0:n.call(a,s);if(c){this.editor.updateShapes([c]);return}}if(a.canCrop(s)&&!this.editor.isShapeOrAncestorLocked(s)){this.editor.markHistoryStoppingPoint("select and crop"),this.editor.select((i=e.shape)==null?void 0:i.id),this.parent.transition("crop",e);return}this.shouldStartEditingShape(s)?this.startEditingShape(s,e,!0):this.handleDoubleClickOnCanvas(e);break}case"handle":{if(this.editor.getIsReadonly())break;const{shape:s,handle:a}=e,c=this.editor.getShapeUtil(s),l=(o=c.onDoubleClickHandle)==null?void 0:o.call(c,s,a);l?this.editor.updateShapes([l]):this.shouldStartEditingShape(s)&&this.startEditingShape(s,e,!0)}}}onRightClick(e){switch(e.target){case"canvas":{const t=this.editor.getHoveredShape(),n=t&&!this.editor.isShapeOfType(t,"group")?t:this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{margin:this.editor.options.hitTestMargin/this.editor.getZoomLevel(),hitInside:!1,hitLabels:!0,hitLocked:!0,hitFrameInside:!0,renderingOnly:!0});if(n){this.onRightClick({...e,shape:n,target:"shape"});return}const i=this.editor.getSelectedShapeIds(),o=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:s}}=this.editor;if((i.length>1||o&&!this.editor.getShapeUtil(o).hideSelectionBoundsBg(o))&&SJ(this.editor,s)){this.onRightClick({...e,target:"selection"});return}this.editor.selectNone();break}case"shape":{const{selectedShapeIds:t}=this.editor.getCurrentPageState(),{shape:n}=e,i=this.editor.getOutermostSelectableShape(n,o=>!t.includes(o.id));!t.includes(i.id)&&!this.editor.findShapeAncestor(i,o=>t.includes(o.id))&&(this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([i.id]));break}}}onCancel(){this.editor.getFocusedGroupId()!==this.editor.getCurrentPageId()&&this.editor.getSelectedShapeIds().length>0?this.editor.popFocusedGroupId():(this.editor.markHistoryStoppingPoint("clearing selection"),this.editor.selectNone())}onKeyDown(e){switch(e.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!1);return}}if(yn.editOnType.get()&&!G3e.includes(e.key)&&!e.altKey&&!e.ctrlKey){const t=this.editor.getOnlySelectedShape();if(t&&this.editor.isShapeOfType(t,"note")&&this.shouldStartEditingShape(t)){this.startEditingShape(t,{...e,target:"shape",shape:t},!0);return}}}onKeyRepeat(e){switch(e.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!0);break}}}onKeyUp(e){switch(e.code){case"Enter":{const t=this.editor.getSelectedShapes();if(t.every(i=>this.editor.isShapeOfType(i,"group"))){this.editor.setSelectedShapes(t.flatMap(i=>this.editor.getSortedChildIdsForParent(i.id)));return}const n=this.editor.getOnlySelectedShape();if(n&&this.shouldStartEditingShape(n)){this.startEditingShape(n,{...e,target:"shape",shape:n},!0);return}yJ(this.editor)&&this.parent.transition("crop",e);break}}}shouldStartEditingShape(e=this.editor.getOnlySelectedShape()){return!e||this.editor.isShapeOrAncestorLocked(e)&&e.type!=="embed"||!this.canInteractWithShapeInReadOnly(e)?!1:this.editor.getShapeUtil(e).canEdit(e)}startEditingShape(e,t,n){this.editor.isShapeOrAncestorLocked(e)&&e.type!=="embed"||(this.editor.markHistoryStoppingPoint("editing shape"),dm(this.editor,e,n),this.parent.transition("editing_shape",t))}isOverArrowLabelTest(e){if(!e)return!1;const t=this.editor.getPointInShapeSpace(e,this.editor.inputs.currentPagePoint);if(this.editor.isShapeOfType(e,"arrow")){const n=this.editor.getShapeGeometry(e).children[1];if(n&&Oo(t,n.vertices))return!0}return!1}handleDoubleClickOnCanvas(e){if(this.editor.getIsReadonly()||!this.editor.options.createTextOnCanvasDoubleClick)return;this.editor.markHistoryStoppingPoint("creating text shape");const t=Tr(),{x:n,y:i}=this.editor.inputs.currentPagePoint;this.editor.createShapes([{id:t,type:"text",x:n,y:i,props:{text:"",autoSize:!0}}]);const o=this.editor.getShape(t);if(!o)return;const s=this.editor.getShapeUtil(o);this.editor.getIsReadonly()&&!s.canEditInReadOnly(o)||(this.editor.setEditingShape(t),this.editor.select(t),this.parent.transition("editing_shape",e))}nudgeSelectedShapes(e=!1){const{editor:{inputs:{keys:t}}}=this,n=t.has("ShiftLeft"),i=new T(0,0);if(t.has("ArrowLeft")&&(i.x-=1),t.has("ArrowRight")&&(i.x+=1),t.has("ArrowUp")&&(i.y-=1),t.has("ArrowDown")&&(i.y+=1),i.equals(new T(0,0)))return;e||this.editor.markHistoryStoppingPoint("nudge shapes");const{gridSize:o}=this.editor.getDocumentSettings(),s=this.editor.getInstanceState().isGridMode?n?o*Z3e:o:n?Y3e:X3e,a=this.editor.getSelectedShapeIds();this.editor.nudgeShapes(a,i.mul(s)),Fr(this.editor,a)}canInteractWithShapeInReadOnly(e){return!!(!this.editor.getIsReadonly()||this.editor.getShapeUtil(e).canEditInReadOnly(e))}},q(pP,"id","idle"),pP);const Y3e=10,X3e=1,Z3e=5;function SJ(r,e){const t=r.getSelectionRotatedPageBounds();if(!t)return!1;const n=r.getSelectionRotation();return n?Oo(e,t.corners.map(i=>T.RotWith(i,t.point,n))):t.containsPoint(e)}class Hde extends vt{constructor(){super(...arguments);q(this,"shapeId","");q(this,"markId","");q(this,"wasAlreadySelected",!1);q(this,"didDrag",!1);q(this,"didCtrlOnEnter",!1);q(this,"info",{});q(this,"_labelDragOffset",new T(0,0))}updateCursor(){this.editor.setCursor({type:"grabbing",rotation:0})}onEnter(t){const{shape:n}=t;this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.info=t,this.shapeId=n.id,this.didDrag=!1,this.didCtrlOnEnter=t.accelKey,this.wasAlreadySelected=this.editor.getOnlySelectedShapeId()===n.id,this.updateCursor();const o=this.editor.getShapeGeometry(n).children[1];if(!o)throw Error(`Expected to find an arrow label geometry for shape: ${n.id}`);const{currentPagePoint:s}=this.editor.inputs,a=this.editor.getPointInShapeSpace(n,s);if(this._labelDragOffset=T.Sub(o.center,a),this.markId=this.editor.markHistoryStoppingPoint("label-drag start"),t.shiftKey||t.accelKey){const l=this.editor.getSelectedShapeIds();this.editor.setSelectedShapes([...l,this.shapeId]);return}this.editor.setSelectedShapes([this.shapeId])}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){const{isDragging:t}=this.editor.inputs;if(!t)return;if(this.didCtrlOnEnter){this.parent.transition("brushing",this.info);return}const n=this.editor.getShape(this.shapeId);if(!n)return;const i=ua(this.editor,n),o=this.editor.getShapeGeometry(n),s=o.children[0],a=this.editor.getPointInShapeSpace(n,this.editor.inputs.currentPagePoint),c=s.nearestPoint(T.Add(a,this._labelDragOffset));let l;if(i.isStraight){const d=T.Dist(i.start.point,i.end.point);l=1-T.Dist(i.end.point,c)/d}else{const{_center:d,measure:f,angleEnd:h,angleStart:g}=o.children[0];l=wP(f,g,h,d.angle(c))}isNaN(l)&&(l=.5),this.didDrag=!0,this.editor.updateShape({id:n.id,type:n.type,props:{labelPosition:l}})}onPointerUp(){const t=this.editor.getShape(this.shapeId);t&&(this.didDrag||!this.wasAlreadySelected?this.complete():this.editor.getIsReadonly()||(this.editor.setEditingShape(t.id),this.editor.setCurrentTool("select.editing_shape")))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}q(Hde,"id","pointing_arrow_label");class Wde extends vt{onEnter(e){e.shiftKey||e.accelKey||this.editor.getSelectedShapeIds().length>0&&(this.editor.markHistoryStoppingPoint("selecting none"),this.editor.selectNone())}onPointerMove(e){this.editor.inputs.isDragging&&this.parent.transition("brushing",e)}onPointerUp(e){xm(this.editor,e),this.complete()}onComplete(){this.complete()}onInterrupt(){this.parent.transition("idle")}complete(){this.parent.transition("idle")}}q(Wde,"id","pointing_canvas");class Kde extends vt{constructor(){super(...arguments);q(this,"didCtrlOnEnter",!1);q(this,"info",{})}onEnter(t){this.info=t,this.didCtrlOnEnter=t.accelKey;const{shape:n}=t;if(this.editor.isShapeOfType(n,"arrow")){const i=fo(this.editor,n)[t.handle.id];i&&this.editor.setHintingShapes([i.toId])}this.editor.setCursor({type:"grabbing",rotation:0})}onExit(){this.editor.setHintingShapes([]),this.editor.setCursor({type:"default",rotation:0})}onPointerUp(){const{shape:t,handle:n}=this.info;if(this.editor.isShapeOfType(t,"note")){const{editor:i}=this,o=xJ(i,t,n,!1);if(o){dm(i,o,!0);return}}this.parent.transition("idle",this.info)}onPointerMove(t){const{editor:n}=this;n.inputs.isDragging&&(this.didCtrlOnEnter?this.parent.transition("brushing",t):this.startDraggingHandle())}onLongPress(){this.startDraggingHandle()}startDraggingHandle(){const{editor:t}=this;if(t.getIsReadonly())return;const{shape:n,handle:i}=this.info;if(t.isShapeOfType(n,"note")){const o=xJ(t,n,i,!0);if(o){const s=t.getPointInParentSpace(o,t.inputs.originPagePoint).sub(T.Rot(nS.clone().mul(n.props.scale),o.rotation));t.updateShape({...o,x:s.x,y:s.y}),t.setHoveredShape(o.id).select(o.id).setCurrentTool("select.translating",{...this.info,target:"shape",shape:t.getShape(o),onInteractionEnd:"note",isCreating:!0,onCreate:()=>{dm(t,o,!0)}});return}}this.parent.transition("dragging_handle",this.info)}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}q(Kde,"id","pointing_handle");function xJ(r,e,t,n){const i=r.getShapePageTransform(e.id),o=i.point(),s=i.rotation(),c=ide(r,o,s,e.props.growY*e.props.scale,0,e.props.scale)[t.index];if(c)return sde(r,e,c,s,n)}class Gde extends vt{constructor(){super(...arguments);q(this,"info",{})}updateCursor(){this.editor.setCursor({type:Td[this.info.handle],rotation:this.editor.getSelectionRotation()})}onEnter(t){this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.info=t,this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})}onPointerMove(){this.editor.inputs.isDragging&&this.startRotating()}onLongPress(){this.startRotating()}startRotating(){this.editor.getIsReadonly()||this.parent.transition("rotating",this.info)}onPointerUp(){this.complete()}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}q(Gde,"id","pointing_rotate_handle");class Vde extends vt{constructor(){super(...arguments);q(this,"info",{})}onEnter(t){this.info=t}onPointerUp(t){xm(this.editor,t),this.parent.transition("idle",t)}onPointerMove(t){this.editor.inputs.isDragging&&this.startTranslating(t)}onLongPress(t){this.startTranslating(t)}startTranslating(t){this.editor.getIsReadonly()||this.parent.transition("translating",t)}onDoubleClick(t){var o,s;const n=this.editor.getHoveredShape(),i=n&&!this.editor.isShapeOfType(n,"group")?n:this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{hitInside:!0,margin:0,renderingOnly:!0});if(i){this.parent.transition("idle"),(s=(o=this.parent).onDoubleClick)==null||s.call(o,{...t,target:"shape",shape:this.editor.getShape(i)});return}}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}q(Vde,"id","pointing_selection");class Yde extends vt{constructor(){super(...arguments);q(this,"hitShape",{});q(this,"hitShapeForPointerUp",{});q(this,"isDoubleClick",!1);q(this,"didCtrlOnEnter",!1);q(this,"didSelectOnEnter",!1)}onEnter(t){const n=this.editor.getSelectedShapeIds(),i=this.editor.getSelectionRotatedPageBounds(),o=this.editor.getFocusedGroupId(),{inputs:{currentPagePoint:s}}=this.editor,{shiftKey:a,altKey:c,accelKey:l}=t;this.hitShape=t.shape,this.isDoubleClick=!1,this.didCtrlOnEnter=l;const d=this.editor.getOutermostSelectableShape(t.shape),f=this.editor.findShapeAncestor(d,h=>n.includes(h.id));if(this.didCtrlOnEnter||this.editor.getShapeUtil(t.shape).onClick||d.id===o||n.includes(d.id)||f||n.length>1&&(i!=null&&i.containsPoint(s))){this.didSelectOnEnter=!1,this.hitShapeForPointerUp=d;return}this.didSelectOnEnter=!0,a&&!c?(this.editor.cancelDoubleClick(),n.includes(d.id)||(this.editor.markHistoryStoppingPoint("shift selecting shape"),this.editor.setSelectedShapes([...n,d.id]))):(this.editor.markHistoryStoppingPoint("selecting shape"),this.editor.setSelectedShapes([d.id]))}onPointerUp(t){var d;const n=this.editor.getSelectedShapeIds(),i=this.editor.getFocusedGroupId(),o=this.editor.getZoomLevel(),{inputs:{currentPagePoint:s}}=this.editor,a=t.shiftKey||t.accelKey,c=this.editor.getShapeAtPoint(s,{margin:this.editor.options.hitTestMargin/o,hitInside:!0,renderingOnly:!0})??this.hitShape,l=c?this.editor.getOutermostSelectableShape(c):this.hitShapeForPointerUp;if(l){const f=this.editor.getShapeUtil(l);if(f.onClick){const h=(d=f.onClick)==null?void 0:d.call(f,l);if(h){this.editor.markHistoryStoppingPoint("shape on click"),this.editor.updateShapes([h]),this.parent.transition("idle",t);return}}if(l.id===i){n.length>0?(this.editor.markHistoryStoppingPoint("clearing shape ids"),this.editor.setSelectedShapes([])):this.editor.popFocusedGroupId(),this.parent.transition("idle",t);return}}if(!this.didSelectOnEnter){const f=this.editor.getOutermostSelectableShape(c,h=>!n.includes(h.id));if(n.includes(f.id))if(a)this.editor.markHistoryStoppingPoint("deselecting on pointer up"),this.editor.deselect(l);else if(n.includes(l.id)){if(n.length===1){const h=this.editor.getShapeUtil(l).getGeometry(l),g=Ude(h),m=g.length===1?g[0]:void 0;if(m){const y=this.editor.getPointInShapeSpace(l,s);if(m.bounds.containsPoint(y,0)&&m.hitTestPoint(y)){this.editor.run(()=>{this.editor.markHistoryStoppingPoint("editing on pointer up"),this.editor.select(l.id);const x=this.editor.getShapeUtil(l);this.editor.getIsReadonly()&&!x.canEditInReadOnly(l)||(this.editor.setEditingShape(l.id),this.editor.setCurrentTool("select.editing_shape"),this.isDoubleClick&&this.editor.emit("select-all-text",{shapeId:l.id}))});return}}}this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.select(l.id)}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.select(l);else if(a){const h=this.editor.getShapeAncestors(f);this.editor.markHistoryStoppingPoint("shift deselecting on pointer up"),this.editor.setSelectedShapes([...this.editor.getSelectedShapeIds().filter(g=>!h.find(m=>m.id===g)),f.id])}else this.editor.markHistoryStoppingPoint("selecting on pointer up"),this.editor.setSelectedShapes([f.id])}this.parent.transition("idle",t)}onDoubleClick(){this.isDoubleClick=!0}onPointerMove(t){this.editor.inputs.isDragging&&(this.didCtrlOnEnter?this.parent.transition("brushing",t):this.startTranslating(t))}onLongPress(t){this.startTranslating(t)}startTranslating(t){this.editor.getIsReadonly()||(this.editor.focus(),this.parent.transition("translating",t))}onCancel(){this.cancel()}onComplete(){this.cancel()}onInterrupt(){this.cancel()}cancel(){this.parent.transition("idle")}}q(Yde,"id","pointing_shape");class Xde extends vt{constructor(){super(...arguments);q(this,"info",{});q(this,"markId","");q(this,"didHoldCommand",!1);q(this,"creationCursorOffset",{x:0,y:0});q(this,"snapshot",{})}onEnter(t){const{isCreating:n=!1,creatingMarkId:i,creationCursorOffset:o={x:0,y:0}}=t;if(this.info=t,this.didHoldCommand=!1,this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.creationCursorOffset=o,this.snapshot=this._createSnapshot(),this.markId="",n)if(i)this.markId=i;else{const s=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);s&&(this.markId=s)}else this.markId=this.editor.markHistoryStoppingPoint("starting resizing");n&&this.editor.setCursor({type:"cross",rotation:0}),this.handleResizeStart(),this.updateShapes()}onTick({elapsed:t}){const{editor:n}=this;n.edgeScrollManager.updateEdgeScrolling(t)}onPointerMove(){this.updateShapes()}onKeyDown(){this.updateShapes()}onKeyUp(){this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}complete(){var t,n;if(Fr(this.editor,this.snapshot.selectedShapeIds),this.handleResizeEnd(),this.info.isCreating&&this.info.onCreate){(n=(t=this.info).onCreate)==null||n.call(t,this.editor.getOnlySelectedShape());return}if(this.editor.getInstanceState().isToolLocked&&this.info.onInteractionEnd){this.editor.setCurrentTool(this.info.onInteractionEnd,{});return}this.parent.transition("idle")}handleResizeStart(){const{shapeSnapshots:t}=this.snapshot,n=[];t.forEach(({shape:i})=>{var a;const o=this.editor.getShapeUtil(i),s=(a=o.onResizeStart)==null?void 0:a.call(o,i);s&&n.push(s)}),n.length>0&&this.editor.updateShapes(n)}handleResizeEnd(){const{shapeSnapshots:t}=this.snapshot,n=[];t.forEach(({shape:i})=>{var c;const o=this.editor.getShape(i.id),s=this.editor.getShapeUtil(i),a=(c=s.onResizeEnd)==null?void 0:c.call(s,i,o);a&&n.push(a)}),n.length>0&&this.editor.updateShapes(n)}updateShapes(){const{altKey:t,shiftKey:n}=this.editor.inputs,{frames:i,shapeSnapshots:o,selectionBounds:s,cursorHandleOffset:a,selectedShapeIds:c,selectionRotation:l,canShapesDeform:d}=this.snapshot;let f=n||!d;if(o.size===1){const O=[...o.values()][0];this.editor.isShapeOfType(O.shape,"text")&&(f=!(this.info.handle==="left"||this.info.handle==="right"))}const{ctrlKey:h}=this.editor.inputs,g=this.editor.inputs.currentPagePoint.clone().sub(a).sub(this.creationCursorOffset),m=this.editor.inputs.originPagePoint.clone().sub(a);if(this.editor.getInstanceState().isGridMode&&!h){const{gridSize:O}=this.editor.getDocumentSettings();g.snapToGrid(O)}const y=this.info.handle,x=_J(y,Math.PI);if(this.editor.snaps.clearIndicators(),(this.editor.user.getIsSnapMode()?!h:h)&&l%Nr===0){const{nudge:O}=this.editor.snaps.shapeBounds.snapResizeShapes({dragDelta:T.Sub(g,m),initialSelectionPageBounds:this.snapshot.initialSelectionPageBounds,handle:_J(y,l),isAspectRatioLocked:f,isResizingFromCenter:t});g.add(O)}const w=T.RotWith(t?s.center:s.getHandlePoint(x),s.point,l),I=T.Sub(g,w).rot(-l),b=T.Sub(m,w).rot(-l),P=T.DivV(I,b);Number.isFinite(P.x)||(P.x=1),Number.isFinite(P.y)||(P.y=1);const C=y==="top"||y==="bottom",k=y==="left"||y==="right";f?k?P.y=Math.abs(P.x):C?P.x=Math.abs(P.y):Math.abs(P.x)>Math.abs(P.y)?P.y=Math.abs(P.x)*(P.y<0?-1:1):P.x=Math.abs(P.y)*(P.x<0?-1:1):(C&&(P.x=1),k&&(P.y=1)),this.info.isCreating||this.updateCursor({dragHandle:y,isFlippedX:P.x<0,isFlippedY:P.y<0,rotation:l});for(const O of o.keys()){const L=o.get(O);this.editor.resizeShape(O,P,{initialShape:L.shape,initialBounds:L.bounds,initialPageTransform:L.pageTransform,dragHandle:y,mode:c.length===1&&O===c[0]?"resize_bounds":"scale_shape",scaleOrigin:w,isAspectRatioLocked:f,scaleAxisRotation:l,skipStartAndEndCallbacks:!0})}if(this.editor.inputs.ctrlKey){this.didHoldCommand=!0;for(const{id:O,children:L}of i){if(!L.length)continue;const j=o.get(O).shape,F=this.editor.getShape(O);if(!(j&&F))continue;const $=F.x-j.x,D=F.y-j.y,N=new T($,D).rot(-j.rotation);if(N.x!==0||N.y!==0)for(const B of L)this.editor.updateShape({id:B.id,type:B.type,x:B.x-N.x,y:B.y-N.y})}}else if(this.didHoldCommand){this.didHoldCommand=!1;for(const{children:O}of i)if(O.length)for(const L of O)this.editor.updateShape({id:L.id,type:L.type,x:L.x,y:L.y})}}updateCursor({dragHandle:t,isFlippedX:n,isFlippedY:i,rotation:o}){const s={...this.editor.getInstanceState().cursor};switch(t){case"top_left":case"bottom_right":{s.type="nwse-resize",n!==i&&(s.type="nesw-resize");break}case"top_right":case"bottom_left":{s.type="nesw-resize",n!==i&&(s.type="nwse-resize");break}}s.rotation=o,this.editor.setCursor(s)}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),this.editor.snaps.clearIndicators()}_createSnapshot(){const t=this.editor.getSelectedShapeIds(),n=this.editor.getSelectionRotation(),{inputs:{originPagePoint:i}}=this.editor,o=this.editor.getSelectionRotatedPageBounds(),s=T.RotWith(o.getHandlePoint(this.info.handle),o.point,n),a=T.Sub(i,s),c=new Map,l=[];t.forEach(f=>{const h=this.editor.getShape(f);if(h){if(h.type==="frame"&&l.push({id:f,children:Gt(this.editor.getSortedChildIdsForParent(h).map(g=>this.editor.getShape(g)))}),c.set(h.id,this._createShapeSnapshot(h)),this.editor.isShapeOfType(h,"frame")&&t.length===1)return;this.editor.visitDescendants(h.id,g=>{const m=this.editor.getShape(g);if(m&&(c.set(m.id,this._createShapeSnapshot(m)),this.editor.isShapeOfType(m,"frame")))return!1})}});const d=![...c.values()].some(f=>!Nee(f.pageRotation,n)||f.isAspectRatioLocked);return{shapeSnapshots:c,selectionBounds:o,cursorHandleOffset:a,selectionRotation:n,selectedShapeIds:t,canShapesDeform:d,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:l}}_createShapeSnapshot(t){const n=this.editor.getShapePageTransform(t),i=this.editor.getShapeUtil(t);return{shape:t,bounds:this.editor.getShapeGeometry(t).bounds,pageTransform:n,pageRotation:Ke.Decompose(n).rotation,isAspectRatioLocked:i.isAspectRatioLocked(t)}}}q(Xde,"id","resizing");const zI=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function _J(r,e){e=e%Cr;const t=Math.round(e/(hr/4)),n=zI.indexOf(r);return zI[(n+t)%zI.length]}const wJ=Math.PI/180;class Zde extends vt{constructor(){super(...arguments);q(this,"snapshot",{});q(this,"info",{});q(this,"markId","")}onEnter(t){this.info=t,this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.markId=this.editor.markHistoryStoppingPoint("rotate start");const n=Eoe({editor:this.editor,ids:this.editor.getSelectedShapeIds()});if(!n)return this.parent.transition("idle",this.info);this.snapshot=n;const i=this._getRotationFromPointerPosition({snapToNearestDegree:!1});lv({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"}),this.editor.setCursor({type:Td[this.info.handle],rotation:i+this.snapshot.initialShapesRotation})}onExit(){this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0),this.snapshot={}}onPointerMove(){this.update()}onKeyDown(){this.update()}onKeyUp(){this.update()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}update(){const t=this._getRotationFromPointerPosition({snapToNearestDegree:!1});lv({editor:this.editor,delta:t,snapshot:this.snapshot,stage:"update"}),this.editor.setCursor({type:Td[this.info.handle],rotation:t+this.snapshot.initialShapesRotation})}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)}complete(){lv({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!0}),snapshot:this.snapshot,stage:"end"}),Fr(this.editor,this.snapshot.shapeSnapshots.map(t=>t.shape.id)),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)}_getRotationFromPointerPosition({snapToNearestDegree:t}){const n=this.editor.getSelectionRotation(),i=this.editor.getSelectionRotatedPageBounds(),{inputs:{shiftKey:o,currentPagePoint:s}}=this.editor,{initialCursorAngle:a,initialShapesRotation:c}=this.snapshot;if(!i)return c;const d=i.center.clone().rotWith(i.point,n).angle(s)-a;let f=c+d;if(o)f=Uv(f,24);else if(t&&(f=Math.round(f/wJ)*wJ,this.editor.getInstanceState().isCoarsePointer)){const h=Uv(f,4),g=iv(f,h);Math.abs(g)<Xve(5)&&(f=h)}return f-c}}q(Zde,"id","rotating");class Qde extends vt{constructor(){super(...arguments);q(this,"hits",new Set);q(this,"size",0);q(this,"scribbleId","id");q(this,"initialSelectedShapeIds",new Set);q(this,"newlySelectedShapeIds",new Set)}onEnter(){this.initialSelectedShapeIds=new Set(this.editor.inputs.shiftKey?this.editor.getSelectedShapeIds():[]),this.newlySelectedShapeIds=new Set,this.size=0,this.hits.clear();const t=this.editor.scribbles.addScribble({color:"selection-stroke",opacity:.32,size:12});this.scribbleId=t.id,this.updateScribbleSelection(!0),this.editor.updateInstanceState({brush:null})}onExit(){this.editor.scribbles.stop(this.scribbleId)}onPointerMove(){this.updateScribbleSelection(!0)}onPointerUp(){this.complete()}onKeyDown(){this.updateScribbleSelection(!1)}onKeyUp(){this.editor.inputs.altKey?this.updateScribbleSelection(!1):this.parent.transition("brushing")}onCancel(){this.cancel()}onComplete(){this.complete()}pushPointToScribble(){const{x:t,y:n}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,t,n)}updateScribbleSelection(t){const{editor:n}=this,i=this.editor.getCurrentPageRenderingShapesSorted(),{inputs:{shiftKey:o,originPagePoint:s,previousPagePoint:a,currentPagePoint:c}}=this.editor,{newlySelectedShapeIds:l,initialSelectedShapeIds:d}=this;t&&this.pushPointToScribble();const f=i;let h,g,m,y;const x=0;for(let I=0,b=f.length;I<b;I++){if(h=f[I],n.isShapeOfType(h,"group")||l.has(h.id)||n.isShapeOrAncestorLocked(h)||(g=n.getShapeGeometry(h),n.isShapeOfType(h,"frame")&&g.bounds.containsPoint(n.getPointInShapeSpace(h,s))))continue;const P=n.getShapePageTransform(h);if(!g||!P)continue;const C=P.clone().invert();m=C.applyToPoint(a),y=C.applyToPoint(c);const{bounds:k}=g;if(!(k.minX-x>Math.max(m.x,y.x)||k.minY-x>Math.max(m.y,y.y)||k.maxX+x<Math.min(m.x,y.x)||k.maxY+x<Math.min(m.y,y.y))&&g.hitTestLineSegment(m,y,x)){const O=this.editor.getOutermostSelectableShape(h),L=this.editor.getShapeMask(O.id);if(L&&oA(a,c,L)!==null&&!Oo(c,L))continue;l.add(O.id)}}const _=n.getSelectedShapeIds(),w=new Set(o?[...l,...d]:[...l]);(_.length!==w.size||_.some(I=>!w.has(I)))&&this.editor.setSelectedShapes(Array.from(w))}complete(){this.updateScribbleSelection(!0),this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds]),this.parent.transition("idle")}}q(Qde,"id","scribble_brushing");var Q3e=Object.create,Jde=Object.defineProperty,J3e=Object.getOwnPropertyDescriptor,e$e=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),efe=r=>{throw TypeError(r)},tfe=(r,e,t)=>e in r?Jde(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,t$e=r=>[,,,Q3e(null)],rfe=["class","method","getter","setter","accessor","field","value","get","set"],nfe=r=>r!==void 0&&typeof r!="function"?efe("Function expected"):r,r$e=(r,e,t,n,i)=>({kind:rfe[r],name:e,metadata:n,addInitializer:o=>t._?efe("Already initialized"):i.push(nfe(o||null))}),n$e=(r,e)=>tfe(e,e$e("metadata"),r[3]),i$e=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},o$e=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=rfe[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,J3e(i,t)),_=n.length-1;_>=0;_--)c=r$e(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,nfe(s)&&(x[m]=s);return x&&Jde(i,t,x),i},HI=(r,e,t)=>tfe(r,typeof e!="symbol"?e+"":e,t),ife,cS;const s$e=20,a$e=100;ife=[po];class wR{constructor(e){this.editor=e,i$e(cS,5,this),HI(this,"prevDroppingShapeId",null),HI(this,"droppingNodeTimer",null),HI(this,"first",!0),e.disposables.add(this.dispose)}updateDroppingNode(e,t){var n;this.first&&(this.editor.setHintingShapes(e.map(i=>this.editor.findShapeAncestor(i,o=>o.type!=="group")).filter(i=>i)),this.prevDroppingShapeId=((n=this.editor.getDroppingOverShape(this.editor.inputs.originPagePoint,e))==null?void 0:n.id)??null,this.first=!1),this.droppingNodeTimer===null?this.setDragTimer(e,s$e,t):this.editor.inputs.pointerVelocity.len()>.5&&(clearTimeout(this.droppingNodeTimer),this.setDragTimer(e,a$e,t))}setDragTimer(e,t,n){this.droppingNodeTimer=this.editor.timers.setTimeout(()=>{this.editor.run(()=>{this.handleDrag(this.editor.inputs.currentPagePoint,e,n)}),this.droppingNodeTimer=null},t)}handleDrag(e,t,n){var c,l,d,f,h;t=Gt(t.map(g=>this.editor.getShape(g.id)));const i=((c=this.editor.getDroppingOverShape(e,t))==null?void 0:c.id)??null;if(i===this.prevDroppingShapeId){this.hintParents(t);return}const{prevDroppingShapeId:o}=this,s=o&&this.editor.getShape(o),a=i&&this.editor.getShape(i);s&&((d=(l=this.editor.getShapeUtil(s)).onDragShapesOut)==null||d.call(l,s,t)),a&&((h=(f=this.editor.getShapeUtil(a)).onDragShapesOver)==null||h.call(f,a,t)),this.hintParents(t),n==null||n(),this.prevDroppingShapeId=i}hintParents(e){const t=new Map;for(const i of e){const o=this.editor.findShapeAncestor(i,s=>s.type!=="group");o&&(t.has(o.id)||t.set(o.id,[]),t.get(o.id).push(i.id))}const n=[];for(const[i,o]of t){const s=this.editor.getShape(i);s&&nue(this.editor,s).length<o.length&&n.push(s.id)}this.editor.setHintingShapes(n)}dropShapes(e){var n,i;const{prevDroppingShapeId:t}=this;if(this.handleDrag(this.editor.inputs.currentPagePoint,e),t){const o=this.editor.getShape(t);if(!o)return;(i=(n=this.editor.getShapeUtil(o)).onDropShapesOver)==null||i.call(n,o,e)}}clear(){this.prevDroppingShapeId=null,this.droppingNodeTimer!==null&&clearTimeout(this.droppingNodeTimer),this.droppingNodeTimer=null,this.editor.setHintingShapes([]),this.first=!0}dispose(){this.clear()}}cS=t$e();o$e(cS,1,"dispose",ife,wR);n$e(cS,wR);var c$e=Object.create,ofe=Object.defineProperty,l$e=Object.getOwnPropertyDescriptor,sfe=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),afe=r=>{throw TypeError(r)},cfe=(r,e,t)=>e in r?ofe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,u$e=r=>[,,,c$e((r==null?void 0:r[sfe("metadata")])??null)],lfe=["class","method","getter","setter","accessor","field","value","get","set"],ufe=r=>r!==void 0&&typeof r!="function"?afe("Function expected"):r,d$e=(r,e,t,n,i)=>({kind:lfe[r],name:e,metadata:n,addInitializer:o=>t._?afe("Already initialized"):i.push(ufe(o||null))}),f$e=(r,e)=>cfe(e,sfe("metadata"),r[3]),h$e=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},p$e=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=lfe[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,l$e(i,t)),_=n.length-1;_>=0;_--)c=d$e(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,ufe(s)&&(x[m]=s);return x&&ofe(i,t,x),i},Uc=(r,e,t)=>cfe(r,typeof e!="symbol"?e+"":e,t),dfe,_C,lS;class uS extends(_C=vt,dfe=[po],_C){constructor(){super(...arguments),h$e(lS,5,this),Uc(this,"info",{}),Uc(this,"selectionSnapshot",{}),Uc(this,"snapshot",{}),Uc(this,"markId",""),Uc(this,"isCloning",!1),Uc(this,"isCreating",!1),Uc(this,"dragAndDropManager",new wR(this.editor))}onCreate(e){}onEnter(e){var o;const{isCreating:t=!1,creatingMarkId:n,onCreate:i=()=>{}}=e;if(!((o=this.editor.getSelectedShapeIds())!=null&&o.length)){this.parent.transition("idle");return}if(this.info=e,this.parent.setCurrentToolIdMask(e.onInteractionEnd),this.isCreating=t,this.markId="",t)if(n)this.markId=n;else{const s=this.editor.getMarkIdMatching(`creating:${this.editor.getOnlySelectedShapeId()}`);s&&(this.markId=s)}else this.markId=this.editor.markHistoryStoppingPoint("translating");if(this.onCreate=i,this.isCloning=!1,this.info=e,this.editor.setCursor({type:"move",rotation:0}),this.selectionSnapshot=bJ(this.editor),!this.isCreating&&this.editor.inputs.altKey){this.startCloning();return}this.snapshot=this.selectionSnapshot,this.handleStart(),this.updateShapes()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.selectionSnapshot={},this.snapshot={},this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0}),this.dragAndDropManager.clear()}onTick({elapsed:e}){const{editor:t}=this;this.dragAndDropManager.updateDroppingNode(this.snapshot.movingShapes,this.updateParentTransforms),t.edgeScrollManager.updateEdgeScrolling(e)}onPointerMove(){this.updateShapes()}onKeyDown(){if(this.editor.inputs.altKey&&!this.isCloning){this.startCloning();return}this.updateShapes()}onKeyUp(){if(!this.editor.inputs.altKey&&this.isCloning){this.stopCloning();return}this.updateShapes()}onPointerUp(){this.complete()}onComplete(){this.complete()}onCancel(){this.cancel()}startCloning(){this.isCreating||(this.isCloning=!0,this.reset(),this.markId=this.editor.markHistoryStoppingPoint("translate cloning"),this.editor.duplicateShapes(Array.from(this.editor.getSelectedShapeIds())),this.snapshot=bJ(this.editor),this.handleStart(),this.updateShapes())}stopCloning(){this.isCloning=!1,this.snapshot=this.selectionSnapshot,this.reset(),this.markId=this.editor.markHistoryStoppingPoint("translate"),this.updateShapes()}reset(){this.editor.bailToMark(this.markId)}complete(){var e;this.updateShapes(),this.dragAndDropManager.dropShapes(this.snapshot.movingShapes),Fr(this.editor,this.snapshot.movingShapes.map(t=>t.id)),this.handleEnd(),this.editor.getInstanceState().isToolLocked&&this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd):this.isCreating?(e=this.onCreate)==null||e.call(this,this.editor.getOnlySelectedShape()):this.parent.transition("idle")}cancel(){this.reset(),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd):this.parent.transition("idle",this.info)}handleStart(){const{movingShapes:e}=this.snapshot,t=[];e.forEach(n=>{var s;const i=this.editor.getShapeUtil(n),o=(s=i.onTranslateStart)==null?void 0:s.call(i,n);o&&t.push(o)}),t.length>0&&this.editor.updateShapes(t),this.editor.setHoveredShape(null)}handleEnd(){const{movingShapes:e}=this.snapshot;if(this.isCloning&&e.length>0){const n=T.Average(e.map(o=>this.editor.getShapePageTransform(o.id).point())),i=T.Sub(n,this.selectionSnapshot.averagePagePoint);T.IsNaN(i)||this.editor.updateInstanceState({duplicateProps:{shapeIds:e.map(o=>o.id),offset:{x:i.x,y:i.y}}})}const t=[];e.forEach(n=>{var a;const i=this.editor.getShape(n.id),o=this.editor.getShapeUtil(n),s=(a=o.onTranslateEnd)==null?void 0:a.call(o,n,i);s&&t.push(s)}),t.length>0&&this.editor.updateShapes(t)}updateShapes(){const{snapshot:e}=this;this.dragAndDropManager.updateDroppingNode(e.movingShapes,this.updateParentTransforms),g$e({editor:this.editor,snapshot:e});const{movingShapes:t}=e,n=[];t.forEach(i=>{var c;const o=this.editor.getShape(i.id),s=this.editor.getShapeUtil(i),a=(c=s.onTranslate)==null?void 0:c.call(s,i,o);a&&n.push(a)}),n.length>0&&this.editor.updateShapes(n)}updateParentTransforms(){const{editor:e,snapshot:{shapeSnapshots:t}}=this;t.forEach(n=>{const i=e.getShape(n.shape.id);if(!i)return null;const o=oo(i.parentId)?null:Ke.Inverse(e.getShapePageTransform(i.parentId));n.parentTransform=o})}}lS=u$e(_C);p$e(lS,1,"updateParentTransforms",dfe,uS);f$e(lS,uS);Uc(uS,"id","translating");function bJ(r){var f;const e=[],t=[],n=r.getSelectedShapeIds(),i=Gt(n.map(h=>{const g=r.getShape(h);if(!g)return null;e.push(g);const m=r.getShapePageTransform(h),y=m.point(),x=m.rotation();t.push(y);const _=Fo.isId(g.parentId)?null:Ke.Inverse(r.getShapePageTransform(g.parentId));return{shape:g,pagePoint:y,pageRotation:x,parentTransform:_}})),o=r.getOnlySelectedShape();let s=[];if(o)s=r.snaps.shapeBounds.getSnapPoints(o.id);else{const h=r.getSelectionPageBounds();h&&(s=h.cornersAndCenter.map((g,m)=>({id:"selection:"+m,x:g.x,y:g.y})))}let a,c;const{originPagePoint:l}=r.inputs,d=i.filter(h=>r.isShapeOfType(h.shape,"note")&&r.isPointInShape(h.shape,l));if(d.length!==0)if(d.length===1)c=d[0];else{const h=r.getCurrentPageShapesSorted();c=(f=d.map(g=>({snapshot:g,index:h.findIndex(m=>m.id===g.shape.id)})).sort((g,m)=>m.index-g.index)[0])==null?void 0:f.snapshot}return c&&(a=ode(r,c.pageRotation,c.shape.props.scale,c.shape.props.growY??0)),{averagePagePoint:T.Average(t),movingShapes:e,shapeSnapshots:i,initialPageBounds:r.getSelectionPageBounds(),initialSnapPoints:s,noteAdjacentPositions:a,noteSnapshot:c}}function g$e({editor:r,snapshot:e}){const{inputs:t}=r,{noteSnapshot:n,noteAdjacentPositions:i,initialPageBounds:o,initialSnapPoints:s,shapeSnapshots:a,averagePagePoint:c}=e,l=r.getInstanceState().isGridMode,d=r.getDocumentSettings().gridSize,f=T.Sub(t.currentPagePoint,t.originPagePoint),h=r.inputs.shiftKey?Math.abs(f.x)<Math.abs(f.y)?"x":"y":null;h==="x"?f.x=0:h==="y"&&(f.y=0),r.snaps.clearIndicators();const g=r.user.getIsSnapMode()?!t.ctrlKey:t.ctrlKey;let m=!1;if(g&&r.inputs.pointerVelocity.len()<.5){const{nudge:w}=r.snaps.shapeBounds.snapTranslateShapes({dragDelta:f,initialSelectionPageBounds:o,lockedAxis:h,initialSelectionSnapPoints:s});f.add(w)}else if(n&&i){const{scale:w}=n.shape.props,I=n.pagePoint.clone().add(f).add(nS.clone().mul(w).rot(n.pageRotation));let b=nde/r.getZoomLevel(),P=new T(0,0);for(const C of i){const k=T.Sub(I,C),O=k.len();O<b&&(m=!0,b=O,P=k)}f.sub(P)}const y=T.Add(c,f),x=r.snaps.getIndicators();l&&!t.ctrlKey&&!m&&x.length===0&&y.snapToGrid(d);const _=T.Sub(y,c);r.updateShapes(Gt(a.map(({shape:w,pagePoint:I,parentTransform:b})=>{const P=T.Add(I,_),C=b?Ke.applyToPoint(b,P):P;return{id:w.id,type:w.type,x:C.x,y:C.y}})))}class Mv extends vt{constructor(){super(...arguments);q(this,"reactor")}static children(){return[xC,xR,V3e,Wde,Yde,uS,Dde,Qde,_R,Vde,Lde,zde,Xde,Zde,Gde,Hde,Kde,Bde]}cleanUpDuplicateProps(){const t=this.editor.getSelectedShapeIds(),n=this.editor.getInstanceState();if(!n.duplicateProps)return;const i=new Set(n.duplicateProps.shapeIds);t.length===i.size&&t.every(o=>i.has(o))||this.editor.updateInstanceState({duplicateProps:null})}onEnter(){this.reactor=fa("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(t){console.error(t)}})}onExit(){var t;(t=this.reactor)==null||t.call(this),this.editor.getCurrentPageState().editingShapeId&&this.editor.setEditingShape(null)}}q(Mv,"id","select"),q(Mv,"initial","idle"),q(Mv,"isLockable",!1);class ffe extends vt{constructor(){super(...arguments);q(this,"info",{})}onEnter(t){this.info=t}onPointerDown(){this.parent.transition("pointing",this.info)}}q(ffe,"id","idle");class hfe extends vt{constructor(){super(...arguments);q(this,"info",{})}onEnter(t){this.info=t}onPointerUp(){this.complete()}onPointerMove(){this.editor.inputs.isDragging&&this.parent.transition("zoom_brushing",this.info)}onCancel(){this.cancel()}complete(){const{currentScreenPoint:t}=this.editor.inputs;this.editor.inputs.altKey?this.editor.zoomOut(t,{animation:{duration:220}}):this.editor.zoomIn(t,{animation:{duration:220}}),this.parent.transition("idle",this.info)}cancel(){this.parent.transition("idle",this.info)}}q(hfe,"id","pointing");class pfe extends vt{constructor(){super(...arguments);q(this,"info",{});q(this,"zoomBrush",new He)}onEnter(t){this.info=t,this.update()}onExit(){this.editor.updateInstanceState({zoomBrush:null})}onPointerMove(){this.update()}onPointerUp(){this.complete()}onCancel(){this.cancel()}update(){const{inputs:{originPagePoint:t,currentPagePoint:n}}=this.editor;this.zoomBrush.setTo(He.FromPoints([t,n])),this.editor.updateInstanceState({zoomBrush:this.zoomBrush.toJson()})}cancel(){this.parent.transition("idle",this.info)}complete(){const{zoomBrush:t}=this,n=8/this.editor.getZoomLevel();if(t.width<n&&t.height<n){const i=this.editor.inputs.currentScreenPoint;this.editor.inputs.altKey?this.editor.zoomOut(i,{animation:{duration:220}}):this.editor.zoomIn(i,{animation:{duration:220}})}else{const i=this.editor.inputs.altKey?this.editor.getZoomLevel()/2:void 0;this.editor.zoomToBounds(t,{targetZoom:i,animation:{duration:220}})}this.parent.transition("idle",this.info)}}q(pfe,"id","zoom_brushing");class jv extends vt{constructor(){super(...arguments);q(this,"info",{})}static children(){return[ffe,pfe,hfe]}onEnter(t){this.info=t,this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.updateCursor()}onExit(){this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({zoomBrush:null,cursor:{type:"default",rotation:0}}),this.parent.setCurrentToolIdMask(void 0)}onKeyDown(){this.updateCursor()}onKeyUp(t){this.updateCursor(),t.code==="KeyZ"&&this.complete()}onInterrupt(){this.complete()}complete(){this.info.onInteractionEnd&&this.info.onInteractionEnd!=="select"?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("select")}updateCursor(){this.editor.inputs.altKey?this.editor.setCursor({type:"zoom-out",rotation:0}):this.editor.setCursor({type:"zoom-in",rotation:0})}}q(jv,"id","zoom"),q(jv,"initial","idle"),q(jv,"isLockable",!1);const v$e=[Rv,kv,Ov,jv,Mv];function m$e(){const r=he(),e=ye("follow",()=>r.getInstanceState().followingUserId,[r]);return e?v.jsx(y$e,{userId:e}):null}function y$e({userId:r}){const e=Hm(r);return e?v.jsx("div",{className:"tlui-following-indicator",style:{borderColor:e.color}}):null}let wC={fonts:{draw:`${Gc()}/fonts/Shantell_Sans-Tldrawish.woff2`,serif:`${Gc()}/fonts/IBMPlexSerif-Medium.woff2`,sansSerif:`${Gc()}/fonts/IBMPlexSans-Medium.woff2`,monospace:`${Gc()}/fonts/IBMPlexMono-Medium.woff2`}};function gfe(r){return A.useMemo(()=>r?{fonts:{...wC.fonts,...r==null?void 0:r.fonts}}:wC,[r])}const S$e=["align-bottom","align-center-horizontal","align-center-vertical","align-left","align-right","align-top","arrow-left","arrowhead-arrow","arrowhead-bar","arrowhead-diamond","arrowhead-dot","arrowhead-none","arrowhead-square","arrowhead-triangle-inverted","arrowhead-triangle","blob","bring-forward","bring-to-front","broken","check-circle","check","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","color","cross-2","cross-circle","dash-dashed","dash-dotted","dash-draw","dash-solid","disconnected","discord","distribute-horizontal","distribute-vertical","dot","dots-horizontal","dots-vertical","drag-handle-dots","duplicate","edit","external-link","fill-fill","fill-none","fill-pattern","fill-semi","fill-solid","follow","following","font-draw","font-mono","font-sans","font-serif","geo-arrow-down","geo-arrow-left","geo-arrow-right","geo-arrow-up","geo-check-box","geo-cloud","geo-diamond","geo-ellipse","geo-heart","geo-hexagon","geo-octagon","geo-oval","geo-pentagon","geo-rectangle","geo-rhombus-2","geo-rhombus","geo-star","geo-trapezoid","geo-triangle","geo-x-box","github","group","horizontal-align-end","horizontal-align-middle","horizontal-align-start","info-circle","leading","link","lock","menu","minus","mixed","pack","plus","question-mark-circle","question-mark","redo","reset-zoom","rotate-ccw","rotate-cw","send-backward","send-to-back","share-1","size-extra-large","size-large","size-medium","size-small","spline-cubic","spline-line","stack-horizontal","stack-vertical","status-offline","stretch-horizontal","stretch-vertical","text-align-center","text-align-left","text-align-right","toggle-off","toggle-on","tool-arrow","tool-eraser","tool-frame","tool-hand","tool-highlight","tool-laser","tool-line","tool-media","tool-note","tool-pencil","tool-pointer","tool-screenshot","tool-text","trash","twitter","undo","ungroup","unlock","vertical-align-end","vertical-align-middle","vertical-align-start","warning-triangle","zoom-in","zoom-out"];let Kf={...wC,icons:Object.fromEntries(S$e.map(r=>[r,`${Gc()}/icons/icon/0_merged.svg#${r}`])),translations:Object.fromEntries(xh.map(r=>[r.locale,`${Gc()}/translations/${r.locale}.json`])),embedIcons:Object.fromEntries(eR.map(r=>[r.type,`${Gc()}/embed-icons/${r.type}.png`]))};function x$e(r){return r?{fonts:Object.assign({...Kf.fonts},{...r==null?void 0:r.fonts}),icons:Object.assign({...Kf.icons},{...r==null?void 0:r.icons}),embedIcons:Object.assign({...Kf.embedIcons},{...r==null?void 0:r.embedIcons}),translations:Object.assign({...Kf.translations},{...r==null?void 0:r.translations})}:Kf}var bR="Popover",[vfe,Z4e]=Aa(bR,[qy]),mp=qy(),[_$e,Sl]=vfe(bR),mfe=r=>{const{__scopePopover:e,children:t,open:n,defaultOpen:i,onOpenChange:o,modal:s=!1}=r,a=mp(e),c=A.useRef(null),[l,d]=A.useState(!1),[f=!1,h]=ml({prop:n,defaultProp:i,onChange:o});return v.jsx(kA,{...a,children:v.jsx(_$e,{scope:e,contentId:nc(),triggerRef:c,open:f,onOpenChange:h,onOpenToggle:A.useCallback(()=>h(g=>!g),[h]),hasCustomAnchor:l,onCustomAnchorAdd:A.useCallback(()=>d(!0),[]),onCustomAnchorRemove:A.useCallback(()=>d(!1),[]),modal:s,children:t})})};mfe.displayName=bR;var yfe="PopoverAnchor",w$e=A.forwardRef((r,e)=>{const{__scopePopover:t,...n}=r,i=Sl(yfe,t),o=mp(t),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=i;return A.useEffect(()=>(s(),()=>a()),[s,a]),v.jsx(OA,{...o,...n,ref:e})});w$e.displayName=yfe;var Sfe="PopoverTrigger",xfe=A.forwardRef((r,e)=>{const{__scopePopover:t,...n}=r,i=Sl(Sfe,t),o=mp(t),s=$r(e,i.triggerRef),a=v.jsx(pr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Ife(i.open),...n,ref:s,onClick:pt(r.onClick,i.onOpenToggle)});return i.hasCustomAnchor?a:v.jsx(OA,{asChild:!0,...o,children:a})});xfe.displayName=Sfe;var ER="PopoverPortal",[b$e,E$e]=vfe(ER,{forceMount:void 0}),_fe=r=>{const{__scopePopover:e,forceMount:t,children:n,container:i}=r,o=Sl(ER,e);return v.jsx(b$e,{scope:e,forceMount:t,children:v.jsx(Us,{present:t||o.open,children:v.jsx(fp,{asChild:!0,container:i,children:n})})})};_fe.displayName=ER;var Ad="PopoverContent",wfe=A.forwardRef((r,e)=>{const t=E$e(Ad,r.__scopePopover),{forceMount:n=t.forceMount,...i}=r,o=Sl(Ad,r.__scopePopover);return v.jsx(Us,{present:n||o.open,children:o.modal?v.jsx(I$e,{...i,ref:e}):v.jsx(P$e,{...i,ref:e})})});wfe.displayName=Ad;var I$e=A.forwardRef((r,e)=>{const t=Sl(Ad,r.__scopePopover),n=A.useRef(null),i=$r(e,n),o=A.useRef(!1);return A.useEffect(()=>{const s=n.current;if(s)return MA(s)},[]),v.jsx(zy,{as:Ql,allowPinchZoom:!0,children:v.jsx(bfe,{...r,ref:i,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pt(r.onCloseAutoFocus,s=>{var a;s.preventDefault(),o.current||(a=t.triggerRef.current)==null||a.focus()}),onPointerDownOutside:pt(r.onPointerDownOutside,s=>{const a=s.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0,l=a.button===2||c;o.current=l},{checkForDefaultPrevented:!1}),onFocusOutside:pt(r.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),P$e=A.forwardRef((r,e)=>{const t=Sl(Ad,r.__scopePopover),n=A.useRef(!1),i=A.useRef(!1);return v.jsx(bfe,{...r,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var s,a;(s=r.onCloseAutoFocus)==null||s.call(r,o),o.defaultPrevented||(n.current||(a=t.triggerRef.current)==null||a.focus(),o.preventDefault()),n.current=!1,i.current=!1},onInteractOutside:o=>{var c,l;(c=r.onInteractOutside)==null||c.call(r,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=o.target;((l=t.triggerRef.current)==null?void 0:l.contains(s))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),bfe=A.forwardRef((r,e)=>{const{__scopePopover:t,trapFocus:n,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:d,...f}=r,h=Sl(Ad,t),g=mp(t);return _A(),v.jsx(Ly,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:i,onUnmountAutoFocus:o,children:v.jsx(up,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:d,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>h.onOpenChange(!1),children:v.jsx(kce,{"data-state":Ife(h.open),role:"dialog",id:h.contentId,...g,...f,ref:e,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Efe="PopoverClose",C$e=A.forwardRef((r,e)=>{const{__scopePopover:t,...n}=r,i=Sl(Efe,t);return v.jsx(pr.button,{type:"button",...n,ref:e,onClick:pt(r.onClick,()=>i.onOpenChange(!1))})});C$e.displayName=Efe;var T$e="PopoverArrow",A$e=A.forwardRef((r,e)=>{const{__scopePopover:t,...n}=r,i=mp(t);return v.jsx(Oce,{...i,...n,ref:e})});A$e.displayName=T$e;function Ife(r){return r?"open":"closed"}var IR=mfe,PR=xfe,CR=_fe,TR=wfe;function AR({id:r,children:e,onOpenChange:t,open:n}){const[i,o]=vc(r,t);return v.jsx(IR,{onOpenChange:o,open:n||i,children:v.jsx("div",{className:"tlui-popover",children:e})})}function RR({children:r}){return v.jsx(PR,{asChild:!0,dir:"ltr",children:r})}function kR({side:r,children:e,align:t="center",sideOffset:n=8,alignOffset:i=0,disableEscapeKeyDown:o=!1}){const s=Ln();return v.jsx(CR,{container:s,children:v.jsx(TR,{className:"tlui-popover__content",side:r,sideOffset:n,align:t,alignOffset:i,dir:"ltr",onEscapeKeyDown:a=>o&&a.preventDefault(),children:e})})}function R$e(r){return r.getSelectedShapeIds().map(n=>r.getShape(n)).filter(n=>{if(!n)return!1;if(r.isShapeOfType(n,"arrow")){const i=fo(r,n);if(i.start||i.end)return!1}return!0})}const Pfe=()=>{const r=he();return ye("threeStackableItems",()=>R$e(r).length>2,[r])},mc=()=>{const r=he();return ye("isInSelectState",()=>r.isIn("select"),[r])},Cfe=()=>{const r=he();return ye("allow group",()=>{const e=r.getSelectedShapes();if(e.length<2)return!1;for(const t of e)if(r.isShapeOfType(t,"arrow")){const n=fo(r,t);if(n.start&&!e.some(i=>i.id===n.start.toId)||n.end&&!e.some(i=>i.id===n.end.toId))return!1}return!0},[r])},Tfe=()=>{const r=he();return ye("allowUngroup",()=>r.getSelectedShapeIds().some(e=>{var t;return((t=r.getShape(e))==null?void 0:t.type)==="group"}),[r])},k$e=typeof window<"u"&&"navigator"in window&&!!navigator.clipboard&&!!navigator.clipboard.read;function Afe(r,e){const t=he();return ye("selectedShapes",()=>t.getSelectedShapes().length>=r,[t,r,e])}function Vi(r,e){const t=he();return ye("selectedShapes",()=>{const n=t.getSelectedShapes().filter(i=>!t.isShapeOrAncestorLocked(i)).length;return r===void 0?n:n>=r},[t])}function O$e(){const r=he();return ye("showAutoSizeToggle",()=>{const e=r.getSelectedShapes();return e.length===1&&r.isShapeOfType(e[0],"text")&&e[0].props.autoSize===!1},[r])}function Rfe(){const r=he();return ye("hasLinkShapeSelected",()=>{const e=r.getOnlySelectedShape();return!!(e&&e.type!=="embed"&&"url"in e.props&&!e.isLocked)},[r])}function M$e(){const r=he();return ye("onlyFlippableShape",()=>{const e=r.getOnlySelectedShape();return e&&(r.isShapeOfType(e,"group")||r.isShapeOfType(e,"image")||r.isShapeOfType(e,"arrow")||r.isShapeOfType(e,"line")||r.isShapeOfType(e,"draw"))},[r])}function kfe(){const r=he();return ye("useCanRedo",()=>r.getCanRedo(),[r])}function Ofe(){const r=he();return ye("useCanUndo",()=>r.getCanUndo(),[r])}function j$e(){return v.jsxs(v.Fragment,{children:[v.jsx(D$e,{}),v.jsx(L$e,{}),v.jsx(F$e,{}),v.jsx(N$e,{}),v.jsx($$e,{}),v.jsx(U$e,{}),v.jsx(z$e,{}),v.jsx(H$e,{})]})}function D$e(){const r=Vi(2),e=mc(),t=r&&e;return v.jsxs(v.Fragment,{children:[v.jsx(Ce,{actionId:"align-left",disabled:!t}),v.jsx(Ce,{actionId:"align-center-horizontal",disabled:!t}),v.jsx(Ce,{actionId:"align-right",disabled:!t}),v.jsx(Ce,{actionId:"stretch-horizontal",disabled:!t}),v.jsx(Ce,{actionId:"align-top",disabled:!t}),v.jsx(Ce,{actionId:"align-center-vertical",disabled:!t}),v.jsx(Ce,{actionId:"align-bottom",disabled:!t}),v.jsx(Ce,{actionId:"stretch-vertical",disabled:!t})]})}function L$e(){const r=Vi(3),e=mc(),t=r&&e;return v.jsxs(v.Fragment,{children:[v.jsx(Ce,{actionId:"distribute-horizontal",disabled:!t}),v.jsx(Ce,{actionId:"distribute-vertical",disabled:!t})]})}function F$e(){const r=Pfe(),e=mc(),t=r&&e;return v.jsxs(v.Fragment,{children:[v.jsx(Ce,{actionId:"stack-horizontal",disabled:!t}),v.jsx(Ce,{actionId:"stack-vertical",disabled:!t})]})}function N$e(){const r=Vi(1),e=mc(),t=r&&e;return v.jsxs(v.Fragment,{children:[v.jsx(Ce,{actionId:"send-to-back",disabled:!t}),v.jsx(Ce,{actionId:"send-backward",disabled:!t}),v.jsx(Ce,{actionId:"bring-forward",disabled:!t}),v.jsx(Ce,{actionId:"bring-to-front",disabled:!t})]})}function $$e(){return Gi()<fn.TABLET_SM?v.jsx(q$e,{}):v.jsx(B$e,{})}function q$e(){const r=he(),e=ye("zoom is 1",()=>r.getZoomLevel()===1,[r]);return v.jsx(Ce,{actionId:"zoom-to-100",disabled:e})}function B$e(){const r=Vi(1),e=mc(),t=r&&e;return v.jsx(Ce,{actionId:"rotate-ccw",disabled:!t})}function U$e(){const r=Vi(1),e=mc(),t=r&&e;return v.jsx(Ce,{actionId:"rotate-cw",disabled:!t})}function z$e(){const r=Rfe(),e=mc(),t=r&&e;return v.jsx(Ce,{actionId:"edit-link",disabled:!t})}function H$e(){const r=Cfe(),e=Tfe();return r?v.jsx(EJ,{}):e?v.jsx(W$e,{}):v.jsx(EJ,{})}function EJ(){const r=Vi(2),e=mc(),t=r&&e;return v.jsx(Ce,{actionId:"group",disabled:!t})}function W$e(){return v.jsx(Ce,{actionId:"ungroup"})}const K$e=A.memo(function({children:e}){const t=ar(),n=Gi(),i=Wo(),o=A.useRef(null);vl(o);const s=he(),a=ye("should display quick actions when in readonly",()=>s.isInAny("hand","zoom"),[s]),c=e??v.jsx(j$e,{});if(!(i&&!a))return v.jsxs(AR,{id:"actions-menu",children:[v.jsx(RR,{children:v.jsx(It,{type:"icon","data-testid":"actions-menu.button",title:t("actions-menu.title"),children:v.jsx(rr,{icon:"dots-vertical",small:!0})})}),v.jsx(kR,{side:n>=fn.TABLET?"bottom":"top",sideOffset:6,children:v.jsx("div",{ref:o,className:"tlui-actions-menu tlui-buttons__grid","data-testid":"actions-menu.content",children:v.jsx(ls,{type:"icons",sourceId:"actions-menu",children:c})})})]})});function Mfe(){return O$e()?v.jsx(Ce,{actionId:"toggle-auto-size"}):null}function jfe(){return Rfe()?v.jsx(Ce,{actionId:"edit-link"}):null}function G$e(){return Vi(1)?v.jsx(Ce,{actionId:"duplicate"}):null}function Dfe(){const r=he();return ye("should display flatten option",()=>{if(r.getSelectedShapeIds().length===0)return!1;const n=r.getOnlySelectedShape();return!(n&&r.isShapeOfType(n,"image"))},[r])?v.jsx(Ce,{actionId:"flatten-to-image"}):null}function Lfe(){return Cfe()?v.jsx(Ce,{actionId:"group"}):null}function Ffe(){return Tfe()?v.jsx(Ce,{actionId:"ungroup"}):null}function Nfe(){const r=he();return ye("allow unframe",()=>{const t=r.getSelectedShapes();return t.length===0?!1:t.every(n=>r.isShapeOfType(n,"frame"))},[r])?v.jsx(Ce,{actionId:"remove-frame"}):null}function $fe(){const r=he();return ye("allow fit frame to content",()=>{const t=r.getOnlySelectedShape();return t?r.isShapeOfType(t,"frame")&&r.getSortedChildIdsForParent(t).length>0:!1},[r])?v.jsx(Ce,{actionId:"fit-frame-to-content"}):null}function qfe(){const r=he();return ye("selected shapes",()=>r.getSelectedShapes().length>0,[r])?v.jsx(Ce,{actionId:"toggle-lock"}):null}function OR(){const r=he(),e=ye("isTransparentBg",()=>!r.getInstanceState().exportBackground,[r]);return v.jsx(Hs,{actionId:"toggle-transparent",checked:e,toggle:!0})}function V$e(){const r=he(),e=ye("any shapes",()=>r.getCurrentPageShapeIds().size>0,[r]);return v.jsx(Ce,{actionId:"unlock-all",disabled:!e})}function Bfe(){const r=he(),e=ye("zoomed to 100",()=>r.getZoomLevel()===1,[r]);return v.jsx(Ce,{actionId:"zoom-to-100",noClose:!0,disabled:e})}function Ufe(){const r=he(),e=ye("has shapes",()=>r.getCurrentPageShapeIds().size>0,[r]);return v.jsx(Ce,{actionId:"zoom-to-fit",disabled:!e,"data-testid":"minimap.zoom-menu.zoom-to-fit",noClose:!0})}function zfe(){const r=he(),e=ye("has shapes",()=>r.getSelectedShapeIds().length>0,[r]);return v.jsx(Ce,{actionId:"zoom-to-selection",disabled:!e,"data-testid":"minimap.zoom-menu.zoom-to-selection",noClose:!0})}function Hfe(){return v.jsxs(Yt,{id:"clipboard",children:[v.jsx(X$e,{}),v.jsx(Z$e,{}),v.jsx(Q$e,{}),v.jsx(G$e,{}),v.jsx(J$e,{})]})}function Y$e(){var t;const r=he(),e=ye("atLeastOneShapeOnPage",()=>r.getCurrentPageShapeIds().size>0,[r]);return v.jsxs(xo,{id:"copy-as",label:"context-menu.copy-as",size:"small",disabled:!e,children:[v.jsxs(Yt,{id:"copy-as-group",children:[v.jsx(Ce,{actionId:"copy-as-svg"}),!!((t=window.navigator.clipboard)!=null&&t.write)&&v.jsx(Ce,{actionId:"copy-as-png"})]}),v.jsx(Yt,{id:"copy-as-bg",children:v.jsx(OR,{})})]})}function X$e(){const r=Vi(1);return v.jsx(Ce,{actionId:"cut",disabled:!r})}function Z$e(){const r=Afe(1);return v.jsx(Ce,{actionId:"copy",disabled:!r})}function Q$e(){const r=k$e;return v.jsx(Ce,{actionId:"paste",disabled:!r})}function Wfe(){const r=he();return ye("atLeastOneShapeOnPage",()=>r.getCurrentPageShapeIds().size>0,[r])?v.jsxs(Yt,{id:"conversions",children:[v.jsx(Y$e,{}),v.jsxs(xo,{id:"export-as",label:"context-menu.export-as",size:"small",children:[v.jsxs(Yt,{id:"export-as-group",children:[v.jsx(Ce,{actionId:"export-as-svg"}),v.jsx(Ce,{actionId:"export-as-png"})]}),v.jsx(Yt,{id:"export-as-bg",children:v.jsx(OR,{})})]})]}):null}function Kfe(){const r=he(),e=ye("atLeastOneShapeOnPage",()=>r.getCurrentPageShapeIds().size>0,[r]);return v.jsx(Ce,{actionId:"select-all",disabled:!e})}function J$e(){const r=Vi(1);return v.jsx(Ce,{actionId:"delete",disabled:!r})}function eqe(){const r=Wo();return!Afe(1)||r?null:v.jsxs(xo,{id:"edit",label:"context-menu.edit",size:"small",children:[v.jsx(Lfe,{}),v.jsx(Ffe,{}),v.jsx(Dfe,{}),v.jsx(jfe,{}),v.jsx($fe,{}),v.jsx(Nfe,{}),v.jsx(Vfe,{}),v.jsx(Gfe,{}),v.jsx(Mfe,{}),v.jsx(qfe,{})]})}function tqe(){const r=Vi(2),e=M$e();return Wo()||!(r||e)?null:v.jsxs(xo,{id:"arrange",label:"context-menu.arrange",size:"small",children:[r&&v.jsxs(Yt,{id:"align",children:[v.jsx(Ce,{actionId:"align-left"}),v.jsx(Ce,{actionId:"align-center-horizontal"}),v.jsx(Ce,{actionId:"align-right"}),v.jsx(Ce,{actionId:"align-top"}),v.jsx(Ce,{actionId:"align-center-vertical"}),v.jsx(Ce,{actionId:"align-bottom"})]}),v.jsx(rqe,{}),r&&v.jsxs(Yt,{id:"stretch",children:[v.jsx(Ce,{actionId:"stretch-horizontal"}),v.jsx(Ce,{actionId:"stretch-vertical"})]}),(r||e)&&v.jsxs(Yt,{id:"flip",children:[v.jsx(Ce,{actionId:"flip-horizontal"}),v.jsx(Ce,{actionId:"flip-vertical"})]}),v.jsx(nqe,{})]})}function rqe(){return Vi(3)?v.jsxs(Yt,{id:"distribute",children:[v.jsx(Ce,{actionId:"distribute-horizontal"}),v.jsx(Ce,{actionId:"distribute-vertical"})]}):null}function nqe(){const r=Vi(2),e=Pfe();return r?v.jsxs(Yt,{id:"order",children:[v.jsx(Ce,{actionId:"pack"}),e&&v.jsx(Ce,{actionId:"stack-horizontal"}),e&&v.jsx(Ce,{actionId:"stack-vertical"})]}):null}function iqe(){const r=Wo(),e=Vi(1);return r||!e?null:v.jsx(xo,{id:"reorder",label:"context-menu.reorder",size:"small",children:v.jsxs(Yt,{id:"reorder",children:[v.jsx(Ce,{actionId:"bring-to-front"}),v.jsx(Ce,{actionId:"bring-forward"}),v.jsx(Ce,{actionId:"send-backward"}),v.jsx(Ce,{actionId:"send-to-back"})]})})}function oqe(){const r=he(),e=ye("pages",()=>r.getPages(),[r]),t=ye("current page id",()=>r.getCurrentPageId(),[r]),{addToast:n}=gc(),i=ai(),o=Wo();return!Vi(1)||o?null:v.jsxs(xo,{id:"move-to-page",label:"context-menu.move-to-page",size:"small",children:[v.jsx(Yt,{id:"pages",children:e.map(a=>v.jsx(Qn,{id:a.id,disabled:t===a.id,label:a.name.length>30?`${a.name.slice(0,30)}…`:a.name,onSelect:()=>{r.markHistoryStoppingPoint("move_shapes_to_page"),r.moveShapesToPage(r.getSelectedShapeIds(),a.id);const c=r.getPage(a.id);c&&n({title:"Changed Page",description:`Moved to ${c.name}.`,actions:[{label:"Go Back",type:"primary",onClick:()=>{r.markHistoryStoppingPoint("change-page"),r.setCurrentPage(t)}}]}),i("move-to-page",{source:"context-menu"})}},a.id))}),v.jsx(Yt,{id:"new-page",children:v.jsx(Ce,{actionId:"move-to-new-page"})})]})}function Gfe(){const r=he();return ye("oneEmbedSelected",()=>{const t=r.getOnlySelectedShape();return t?!!(r.isShapeOfType(t,"embed")&&t.props.url&&!r.isShapeOrAncestorLocked(t)):!1},[r])?v.jsx(Ce,{actionId:"convert-to-bookmark"}):null}function Vfe(){const r=he(),e=tR();return ye("oneEmbeddableBookmarkSelected",()=>{const n=r.getOnlySelectedShape();return n?!!(r.isShapeOfType(n,"bookmark")&&n.props.url&&e(n.props.url)&&!r.isShapeOrAncestorLocked(n)):!1},[r])?v.jsx(Ce,{actionId:"convert-to-embed"}):null}function sqe(){const r=he(),e=ye("isSnapMode",()=>r.user.getIsSnapMode(),[r]);return v.jsx(Hs,{actionId:"toggle-snap-mode",checked:e})}function aqe(){const r=he(),e=ye("isToolLock",()=>r.getInstanceState().isToolLocked,[r]);return v.jsx(Hs,{actionId:"toggle-tool-lock",checked:e})}function cqe(){const r=he(),e=ye("isGridMode",()=>r.getInstanceState().isGridMode,[r]);return v.jsx(Hs,{actionId:"toggle-grid",checked:e})}function lqe(){const r=he(),e=ye("isWrapMode",()=>r.user.getIsWrapMode(),[r]);return v.jsx(Hs,{actionId:"toggle-wrap-mode",checked:e})}function uqe(){const r=he(),e=ye("isFocusMode",()=>r.getInstanceState().isFocusMode,[r]);return v.jsx(Hs,{actionId:"toggle-focus-mode",checked:e})}function dqe(){const r=he(),e=ye("edgeScrollSpeed",()=>r.user.getEdgeScrollSpeed(),[r]);return v.jsx(Hs,{actionId:"toggle-edge-scrolling",checked:e===1})}function fqe(){const r=he(),e=ye("animationSpeed",()=>r.user.getAnimationSpeed(),[r]);return v.jsx(Hs,{actionId:"toggle-reduce-motion",checked:e===0})}function hqe(){const r=he(),e=ye("isDebugMode",()=>r.getInstanceState().isDebugMode,[r]);return v.jsx(Hs,{actionId:"toggle-debug-mode",checked:e})}function pqe(){const r=he(),e=ye("dynamic resize",()=>r.user.getIsDynamicResizeMode(),[r]);return v.jsx(Hs,{actionId:"toggle-dynamic-size-mode",checked:e})}function gqe(){const r=he(),e=ye("paste at cursor",()=>r.user.getIsPasteAtCursorMode(),[r]);return v.jsx(Hs,{actionId:"toggle-paste-at-cursor",checked:e})}function vqe(){const r=he();return ye("show cursor chat",()=>r.getCurrentToolId()==="select"&&!r.getInstanceState().isCoarsePointer,[r])?v.jsx(Ce,{actionId:"open-cursor-chat"}):null}function mqe(){const r=he(),e=Zy(),t=ye("isSelectToolActive",()=>r.getCurrentToolId()==="select",[r]),n=ye("isSinglePageMode",()=>r.options.maxPages<=1,[r]);return t?v.jsxs(v.Fragment,{children:[e&&v.jsx(vqe,{}),v.jsxs(Yt,{id:"modify",children:[v.jsx(eqe,{}),v.jsx(tqe,{}),v.jsx(iqe,{}),!n&&v.jsx(oqe,{})]}),v.jsx(Hfe,{}),v.jsx(Wfe,{}),v.jsx(Yt,{id:"select-all",children:v.jsx(Kfe,{})})]}):null}const yqe=A.memo(function({children:e,disabled:t=!1}){const n=he(),{Canvas:i}=Gr(),o=A.useCallback(d=>{if(d){if(n.getInstanceState().isCoarsePointer){const f=n.getSelectedShapes(),{inputs:{currentPagePoint:h}}=n,g=n.getShapesAtPoint(h);if(!n.getSelectedShapes().length||!g.some(m=>f.includes(m))){const m=g.filter(y=>n.isShapeOrAncestorLocked(y));m.length&&n.select(...m.map(y=>y.id))}}}else{const f=n.getOnlySelectedShape();f&&n.isShapeOrAncestorLocked(f)&&n.setSelectedShapes([])}},[n]),s=Ln(),[a,c]=vc("context menu",o),l=e??v.jsx(mqe,{});return v.jsxs(pje,{dir:"ltr",onOpenChange:c,modal:!1,children:[v.jsx(gje,{onContextMenu:void 0,dir:"ltr",disabled:t,children:i?v.jsx(i,{}):null}),a&&v.jsx(vje,{container:s,children:v.jsx(mje,{className:"tlui-menu scrollable","data-testid":"context-menu",alignOffset:-4,collisionPadding:4,onContextMenu:Qt,children:v.jsx(ls,{type:"context-menu",sourceId:"context-menu",children:l})})})]})}),Sqe=2e3,xqe=5e3,_qe=ii(function(){const e=he(),{isChatting:t,chatMessage:n}=e.getInstanceState(),i=A.useRef(-1),[o,s]=A.useState("");return A.useEffect(()=>{if(!t&&n||t){const c=t?xqe:Sqe;i.current=e.timers.setTimeout(()=>{e.updateInstanceState({chatMessage:"",isChatting:!1}),s(""),e.focus()},c)}return()=>{clearTimeout(i.current)}},[e,n,t]),t?v.jsx(bqe,{value:o,setValue:s,chatMessage:n}):n.trim()?v.jsx(wqe,{chatMessage:n}):null});function Yfe(r){const e=he();A.useLayoutEffect(()=>{var s;if(!r.current)return;const{x:n,y:i}=e.inputs.currentScreenPoint;(s=r.current)==null||s.style.setProperty("transform",`translate(${n}px, ${i}px)`);function o(a){var d;const{minX:c,minY:l}=e.getViewportScreenBounds();(d=r.current)==null||d.style.setProperty("transform",`translate(${a.clientX-c}px, ${a.clientY-l}px)`)}return window.addEventListener("pointermove",o),()=>{window.removeEventListener("pointermove",o)}},[r,e])}const wqe=({chatMessage:r})=>{const e=he(),t=A.useRef(null);return Yfe(t),v.jsx("div",{ref:t,className:"tl-cursor-chat tl-cursor-chat__bubble",style:{backgroundColor:e.user.getColor()},children:r})},bqe=ii(function({chatMessage:e,value:t,setValue:n}){const i=he(),o=ar(),s=A.useRef(null),a=e||o("cursor-chat.type-to-chat");Yfe(s),A.useLayoutEffect(()=>{const h=s.current;if(!h)return;const g=i.textMeasure.measureText(t||a,{fontFamily:"var(--font-body)",fontSize:12,fontWeight:"500",fontStyle:"normal",maxWidth:null,lineHeight:1,padding:"6px"});h.style.setProperty("width",g.w+"px")},[i,t,a]),A.useLayoutEffect(()=>{const h=i.timers.requestAnimationFrame(()=>{var g;(g=s.current)==null||g.focus()});return()=>{cancelAnimationFrame(h)}},[i]);const c=A.useCallback(()=>{i.updateInstanceState({isChatting:!1}),i.focus()},[i]),l=A.useCallback(h=>{const{value:g}=h.target;n(g.slice(0,64)),i.updateInstanceState({chatMessage:g})},[i,n]),d=A.useCallback(h=>{const g=s.current;if(!g)return;const{value:m}=g;switch(h.key){case"Enter":{if(Qt(h),h.stopPropagation(),!m){c();return}n("");break}case"Escape":{Qt(h),h.stopPropagation(),c();break}}},[c,n]),f=A.useCallback(h=>{h.stopPropagation()},[]);return v.jsx("input",{ref:s,className:"tl-cursor-chat",style:{backgroundColor:i.user.getColor()},onBlur:c,onChange:l,onKeyDown:d,onPaste:f,value:t,placeholder:a,spellCheck:!1})});function bC({checked:r}){return v.jsx(Sa,{icon:r?"check":"none",className:"tlui-button__icon",small:!0})}function Eqe(){const r=he(),{addToast:e}=gc(),{addDialog:t}=vp(),[n,i]=lr.useState(!1);return v.jsxs(v.Fragment,{children:[v.jsxs(Yt,{id:"items",children:[v.jsx(Qn,{id:"add-toast",onSelect:()=>{e({id:Er(),title:"Something good happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"success"}),e({id:Er(),title:"Something happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"info",actions:[{label:"Primary",type:"primary",onClick:()=>{}},{label:"Normal",type:"normal",onClick:()=>{}},{label:"Danger",type:"danger",onClick:()=>{}}]}),e({id:Er(),title:"Something maybe bad happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"warning",actions:[{label:"Primary",type:"primary",onClick:()=>{}},{label:"Normal",type:"normal",onClick:()=>{}},{label:"Danger",type:"danger",onClick:()=>{}}]}),e({id:Er(),title:"Something bad happened",severity:"error",keepOpen:!0})},label:"Show toast"}),v.jsx(Qn,{id:"show-dialog",label:"Show dialog",onSelect:()=>{t({component:({onClose:o})=>v.jsx(Cqe,{displayDontShowAgain:!0,onCancel:()=>o(),onContinue:()=>o()}),onClose:()=>{}})}}),v.jsx(Qn,{id:"create-shapes",label:"Create 100 shapes",onSelect:()=>Tqe(r,100)}),v.jsx(Qn,{id:"count-nodes",label:"Count shapes / nodes",onSelect:()=>{var a;const o=r.getSelectedShapes(),s=o.length===0?r.getRenderingShapes():o;window.alert(`Shapes ${s.length}, DOM nodes:${(a=document.querySelector(".tl-shapes").querySelectorAll("*"))==null?void 0:a.length}`)}}),(()=>{if(n)throw Error("oh no!");return null})(),v.jsx(Qn,{id:"throw-error",onSelect:()=>i(!0),label:"Throw error"}),v.jsx(Qn,{id:"hard-reset",onSelect:sre,label:"Hard reset"})]}),v.jsxs(Yt,{id:"flags",children:[v.jsx(Iqe,{}),v.jsx(Pqe,{})]})]})}function Iqe(){const r=Object.values(yn);return r.length?v.jsx(xo,{id:"debug flags",label:"Debug Flags",children:v.jsx(Yt,{id:"debug flags",children:r.map(e=>v.jsx(Xfe,{flag:e},e.name))})}):null}function Pqe(){const r=Object.values(Kye);return r.length?v.jsx(xo,{id:"feature flags",label:"Feature Flags",children:v.jsx(Yt,{id:"feature flags",children:r.map(e=>v.jsx(Xfe,{flag:e},e.name))})}):null}function Cqe({title:r="title",body:e="hello hello hello",cancel:t="Cancel",confirm:n="Continue",displayDontShowAgain:i=!1,onCancel:o,onContinue:s}){const[a,c]=lr.useState(!1);return v.jsxs(v.Fragment,{children:[v.jsxs(Gy,{children:[v.jsx(Vy,{children:r}),v.jsx(Yy,{})]}),v.jsx(Ch,{style:{maxWidth:350},children:e}),v.jsxs(JA,{className:"tlui-dialog__footer__actions",children:[i&&v.jsxs(It,{type:"normal",onClick:()=>c(!a),style:{marginRight:"auto"},children:[v.jsx(bC,{checked:a}),v.jsx(Sn,{children:"Don’t show again"})]}),v.jsx(It,{type:"normal",onClick:o,children:v.jsx(Sn,{children:t})}),v.jsx(It,{type:"primary",onClick:async()=>s(),children:v.jsx(Sn,{children:n})})]})]})}const Xfe=ii(function({flag:e,onChange:t}){const n=e.get();return v.jsx(tS,{id:e.name,title:e.name,label:e.name.replace(/([a-z0-9])([A-Z])/g,i=>`${i[0]} ${i[1].toLowerCase()}`).replace(/^[a-z]/,i=>i.toUpperCase()),checked:n,onSelect:()=>{e.set(!n),t==null||t(!n)}})});let IJ=0;function Tqe(r,e){const t=Array(e),n=Math.floor(Math.sqrt(e));for(let i=0;i<e;i++)IJ++,t[i]={id:Tr("box"+IJ),type:"geo",x:i%n*132,y:Math.floor(i/n)*132};r.run(()=>{r.createShapes(t).setSelectedShapes(t.map(i=>i.id))})}function Aqe({children:r}){const e=r??v.jsx(Eqe,{});return v.jsxs(tu,{id:"debug",children:[v.jsx(ru,{children:v.jsx(It,{type:"icon",title:"Debug menu",children:v.jsx(rr,{icon:"dots-horizontal"})})}),v.jsx(nu,{side:"top",align:"end",alignOffset:0,children:v.jsx(ls,{type:"menu",sourceId:"debug-panel",children:e})})]})}const Rqe=A.memo(function(){const{DebugMenu:e}=xl(),t=A.useRef(null);return vl(t),v.jsxs("div",{ref:t,className:"tlui-debug-panel",children:[v.jsx(Oqe,{}),v.jsx(Mqe,{}),e&&v.jsx(e,{})]})});function kqe(r=!0){const[e,t]=A.useState(0),n=he();A.useEffect(()=>{if(!r)return;const i=()=>t(o=>o+1);return n.on("tick",i),()=>{n.off("tick",i)}},[n,r])}const Oqe=ii(function(){kqe();const e=he(),t=e.getPath(),n=e.getHoveredShape(),i=e.getOnlySelectedShape(),o=t==="select.idle"||!t.includes("select.")?n:i,s=o&&t.includes("select.")?` / ${o.type||""}${"geo"in o.props?" / "+o.props.geo:""} / [${T.ToInt(e.getPointInShapeSpace(o,e.inputs.currentPagePoint))}]`:"",a=t.startsWith("select.")&&!t.includes(".idle")?` / [${T.ToInt(e.inputs.originPagePoint)}] → [${T.ToInt(e.inputs.currentPagePoint)}] = ${T.Dist(e.inputs.originPagePoint,e.inputs.currentPagePoint).toFixed(0)}`:"";return v.jsx("div",{className:"tlui-debug-panel__current-state",children:`${t}${s}${a}`})});function Mqe(){const r=he(),e=ye("show_fps",()=>yn.showFps.get(),[yn]),t=A.useRef(null);return A.useEffect(()=>{if(!e)return;const n=250;let i=0,o=-1,s=performance.now(),a=0,c=0,l=!1;function d(){if(c++,a=performance.now()-s,a>n){const f=Math.round(c*(n/a)*(1e3/n));f>i&&(i=f);const h=i*.75;(f<h&&!l||f>=h&&l)&&(l=!l),t.current.innerHTML=`FPS ${f.toString()}`,t.current.className="tlui-debug-panel__fps"+(l?" tlui-debug-panel__fps__slow":""),a-=n,c=0,s=performance.now()}o=r.timers.requestAnimationFrame(d)}return d(),()=>{cancelAnimationFrame(o)}},[e,r]),e?v.jsx("div",{ref:t}):null}const jqe=A.memo(function(){const e=Gi(),t=A.useRef(null);vl(t);const{MainMenu:n,QuickActions:i,ActionsMenu:o,PageMenu:s}=xl(),a=he(),c=ye("isSinglePageMode",()=>a.options.maxPages<=1,[a]),l=a.options.actionShortcutsLocation==="menu"?!0:a.options.actionShortcutsLocation==="toolbar"?!1:e>=fn.TABLET;return!n&&!s&&!l?null:v.jsx("div",{ref:t,className:"tlui-menu-zone",children:v.jsxs("div",{className:"tlui-buttons__horizontal",children:[n&&v.jsx(n,{}),s&&!c&&v.jsx(s,{}),l?v.jsxs(v.Fragment,{children:[i&&v.jsx(i,{}),o&&v.jsx(o,{})]}):null]})})});function Dqe(){const r=he(),e=bu(),[t,n]=A.useState(!1),i=A.useRef(!1);return Vc("toggle showback to content",()=>{const o=i.current,s=r.getCurrentPageShapeIds();let a=!1;s.size&&(a=s.size===r.getCulledShapes().size),o!==a&&(n(a),i.current=a)},[r]),t?v.jsx(Ce,{actionId:"back-to-content",onSelect:()=>{e["back-to-content"].onSelect("helper-buttons"),n(!1)}}):null}function Lqe(){const r=he();return ye("is pen mode",()=>r.getInstanceState().isPenMode,[r])?v.jsx(Ce,{actionId:"exit-pen-mode"}):null}function Fqe(){const r=he(),e=bu();return ye("is following user",()=>!!r.getInstanceState().followingUserId,[r])?v.jsx(Qn,{...e["stop-following"]}):null}function Nqe(){return v.jsxs(v.Fragment,{children:[v.jsx(Lqe,{}),v.jsx(Dqe,{}),v.jsx(Fqe,{})]})}function $qe({children:r}){const e=r??v.jsx(Nqe,{});return v.jsx("div",{className:"tlui-helper-buttons",children:v.jsx(ls,{type:"helper-buttons",sourceId:"helper-buttons",children:e})})}function qqe(){const r=Zy();return v.jsxs(v.Fragment,{children:[v.jsxs(Yt,{label:"shortcuts-dialog.tools",id:"tools",children:[v.jsx(Ce,{actionId:"toggle-tool-lock"}),v.jsx(Ce,{actionId:"insert-media"}),v.jsx(so,{toolId:"select"}),v.jsx(so,{toolId:"draw"}),v.jsx(so,{toolId:"eraser"}),v.jsx(so,{toolId:"hand"}),v.jsx(so,{toolId:"rectangle"}),v.jsx(so,{toolId:"ellipse"}),v.jsx(so,{toolId:"arrow"}),v.jsx(so,{toolId:"line"}),v.jsx(so,{toolId:"text"}),v.jsx(so,{toolId:"frame"}),v.jsx(so,{toolId:"note"}),v.jsx(so,{toolId:"laser"}),v.jsx(Qn,{id:"pointer-down",label:"tool.pointer-down",kbd:",",onSelect:()=>{}})]}),v.jsxs(Yt,{label:"shortcuts-dialog.preferences",id:"preferences",children:[v.jsx(Ce,{actionId:"toggle-dark-mode"}),v.jsx(Ce,{actionId:"toggle-focus-mode"}),v.jsx(Ce,{actionId:"toggle-grid"})]}),v.jsxs(Yt,{label:"shortcuts-dialog.edit",id:"edit",children:[v.jsx(Ce,{actionId:"undo"}),v.jsx(Ce,{actionId:"redo"}),v.jsx(Ce,{actionId:"cut"}),v.jsx(Ce,{actionId:"copy"}),v.jsx(Ce,{actionId:"paste"}),v.jsx(Ce,{actionId:"select-all"}),v.jsx(Ce,{actionId:"delete"}),v.jsx(Ce,{actionId:"duplicate"})]}),v.jsxs(Yt,{label:"shortcuts-dialog.view",id:"view",children:[v.jsx(Ce,{actionId:"zoom-in"}),v.jsx(Ce,{actionId:"zoom-out"}),v.jsx(Ce,{actionId:"zoom-to-100"}),v.jsx(Ce,{actionId:"zoom-to-fit"}),v.jsx(Ce,{actionId:"zoom-to-selection"})]}),v.jsxs(Yt,{label:"shortcuts-dialog.transform",id:"transform",children:[v.jsx(Ce,{actionId:"bring-to-front"}),v.jsx(Ce,{actionId:"bring-forward"}),v.jsx(Ce,{actionId:"send-backward"}),v.jsx(Ce,{actionId:"send-to-back"}),v.jsx(Ce,{actionId:"group"}),v.jsx(Ce,{actionId:"ungroup"}),v.jsx(Ce,{actionId:"flip-horizontal"}),v.jsx(Ce,{actionId:"flip-vertical"}),v.jsx(Ce,{actionId:"align-top"}),v.jsx(Ce,{actionId:"align-center-vertical"}),v.jsx(Ce,{actionId:"align-bottom"}),v.jsx(Ce,{actionId:"align-left"}),v.jsx(Ce,{actionId:"align-center-horizontal"}),v.jsx(Ce,{actionId:"align-right"})]}),r&&v.jsx(Yt,{label:"shortcuts-dialog.collaboration",id:"collaboration",children:v.jsx(Ce,{actionId:"open-cursor-chat"})})]})}const Bqe=A.memo(function({children:e}){const t=ar(),n=Gi(),i=e??v.jsx(qqe,{});return v.jsxs(v.Fragment,{children:[v.jsxs(Gy,{className:"tlui-shortcuts-dialog__header",children:[v.jsx(Vy,{children:t("shortcuts-dialog.title")}),v.jsx(Yy,{})]}),v.jsx(Ch,{className:bt("tlui-shortcuts-dialog__body",{"tlui-shortcuts-dialog__body__mobile":n<=fn.MOBILE_XS,"tlui-shortcuts-dialog__body__tablet":n<=fn.TABLET}),children:v.jsx(ls,{type:"keyboard-shortcuts",sourceId:"kbd",children:i})}),v.jsx("div",{className:"tlui-dialog__scrim"})]})});function Zfe(){const r=ll(),e=ai(),t=ye("locale",()=>r==null?void 0:r.user.getLocale(),[r]);return r?v.jsx(xo,{id:"help menu language",label:"menu.language",children:v.jsx(Yt,{id:"languages",children:xh.map(({locale:n,label:i})=>v.jsx(tS,{id:`language-${n}`,title:n,label:i,checked:n===t,readonlyOk:!0,onSelect:()=>{r.user.updateUserPreferences({locale:n}),e("change-language",{source:"menu",locale:n})}},n))})}):null}function Uqe(){return v.jsxs(v.Fragment,{children:[v.jsx(Zfe,{}),v.jsx(Qfe,{})]})}function Qfe(){const{KeyboardShortcutsDialog:r}=xl(),{addDialog:e}=vp(),t=A.useCallback(()=>{r&&e({component:r})},[e,r]);return r?v.jsx(Qn,{id:"keyboard-shortcuts-button",label:"help-menu.keyboard-shortcuts",readonlyOk:!0,onSelect:t}):null}function zqe(){return v.jsxs(v.Fragment,{children:[v.jsxs(Yt,{id:"basic",children:[v.jsx(Wqe,{}),v.jsx(Yqe,{}),v.jsx(Hqe,{}),v.jsx(Xqe,{})]}),v.jsx(Zqe,{})]})}function Hqe(){return v.jsxs(xo,{id:"export-all-as",label:"context-menu.export-all-as",size:"small",children:[v.jsxs(Yt,{id:"export-all-as-group",children:[v.jsx(Ce,{actionId:"export-all-as-svg"}),v.jsx(Ce,{actionId:"export-all-as-png"})]}),v.jsx(Yt,{id:"export-all-as-bg",children:v.jsx(OR,{})})]})}function Wqe(){return v.jsxs(xo,{id:"edit",label:"menu.edit",children:[v.jsx(Vqe,{}),v.jsx(Hfe,{}),v.jsx(Wfe,{}),v.jsx(Kqe,{}),v.jsx(Gqe,{}),v.jsx(Yt,{id:"select-all",children:v.jsx(Kfe,{})})]})}function Kqe(){return v.jsxs(Yt,{id:"misc",children:[v.jsx(Lfe,{}),v.jsx(Ffe,{}),v.jsx(jfe,{}),v.jsx(Mfe,{}),v.jsx(Nfe,{}),v.jsx($fe,{}),v.jsx(Vfe,{}),v.jsx(Gfe,{}),v.jsx(Dfe,{})]})}function Gqe(){return v.jsxs(Yt,{id:"lock",children:[v.jsx(qfe,{}),v.jsx(V$e,{})]})}function Vqe(){const r=Ofe(),e=kfe();return v.jsxs(Yt,{id:"undo-redo",children:[v.jsx(Ce,{actionId:"undo",disabled:!r}),v.jsx(Ce,{actionId:"redo",disabled:!e})]})}function Yqe(){return v.jsx(xo,{id:"view",label:"menu.view",children:v.jsxs(Yt,{id:"view-actions",children:[v.jsx(Ce,{actionId:"zoom-in"}),v.jsx(Ce,{actionId:"zoom-out"}),v.jsx(Bfe,{}),v.jsx(Ufe,{}),v.jsx(zfe,{})]})})}function Xqe(){return v.jsxs(v.Fragment,{children:[v.jsx(Ce,{actionId:"insert-embed"}),v.jsx(Ce,{actionId:"insert-media"})]})}function Zqe(){return v.jsxs(Yt,{id:"preferences",children:[v.jsxs(xo,{id:"preferences",label:"menu.preferences",children:[v.jsxs(Yt,{id:"preferences-actions",children:[v.jsx(sqe,{}),v.jsx(aqe,{}),v.jsx(cqe,{}),v.jsx(lqe,{}),v.jsx(uqe,{}),v.jsx(dqe,{}),v.jsx(fqe,{}),v.jsx(pqe,{}),v.jsx(gqe,{}),v.jsx(hqe,{})]}),v.jsx(Yt,{id:"color-scheme",children:v.jsx(DLe,{})})]}),v.jsx(Zfe,{}),v.jsx(Qfe,{})]})}const Qqe=A.memo(function({children:e}){const t=Ln(),[n,i]=vc("main menu"),o=ar(),s=e??v.jsx(zqe,{});return v.jsxs(WA,{dir:"ltr",open:n,onOpenChange:i,modal:!1,children:[v.jsx(KA,{asChild:!0,dir:"ltr",children:v.jsx(It,{type:"icon","data-testid":"main-menu.button",title:o("menu.title"),children:v.jsx(rr,{icon:"menu",small:!0})})}),v.jsx(Ky,{container:t,children:v.jsx(GA,{className:"tlui-menu",side:"bottom",align:"start",collisionPadding:4,alignOffset:0,sideOffset:6,children:v.jsx(ls,{type:"menu",sourceId:"main-menu",children:s})})})]})}),WI={};function Gf(r){if(WI[r])return WI[r];const t=document.createElement("canvas").getContext("2d");t.fillStyle=r,t.fillRect(0,0,1,1);const[n,i,o,s]=t.getImageData(0,0,1,1).data,a=new Float32Array([n/255,i/255,o/255,s/255]);return WI[r]=a,a}const Dv=10,Jfe=4*6*Dv+12+4*12;function sd(r,{center:e,radius:t,numArcSegments:n=20,startAngle:i=0,endAngle:o=Cr,offset:s=0}){const a=(o-i)/n;let c=s;for(let l=i;l<o;l+=a)r[c++]=e.x,r[c++]=e.y,r[c++]=e.x+Math.cos(l)*t,r[c++]=e.y+Math.sin(l)*t,r[c++]=e.x+Math.cos(l+a)*t,r[c++]=e.y+Math.sin(l+a)*t;return r}function ad(r,e,t,n,i,o){r[e++]=t,r[e++]=n,r[e++]=t,r[e++]=n+o,r[e++]=t+i,r[e++]=n,r[e++]=t+i,r[e++]=n,r[e++]=t,r[e++]=n+o,r[e++]=t+i,r[e++]=n+o}function Jqe(r,e,t){const n=Dv;t=Math.min(t,Math.min(e.w,e.h)/2);const i=He.ExpandBy(e,-t);if(i.w<=0||i.h<=0)return sd(r,{center:e.center,radius:t,numArcSegments:Dv*4}),Dv*4*6;let o=0;return ad(r,o,i.minX,i.minY,i.w,i.h),o+=12,ad(r,o,i.minX,e.minY,i.w,t),o+=12,ad(r,o,i.maxX,i.minY,t,i.h),o+=12,ad(r,o,i.minX,i.maxY,i.w,t),o+=12,ad(r,o,e.minX,i.minY,t,i.h),o+=12,sd(r,{numArcSegments:n,offset:o,center:i.point,radius:t,startAngle:hr,endAngle:hr*1.5}),o+=n*6,sd(r,{numArcSegments:n,offset:o,center:T.Add(i.point,new T(i.w,0)),radius:t,startAngle:hr*1.5,endAngle:Cr}),o+=n*6,sd(r,{numArcSegments:n,offset:o,center:T.Add(i.point,i.size),radius:t,startAngle:0,endAngle:Nr}),o+=n*6,sd(r,{numArcSegments:n,offset:o,center:T.Add(i.point,new T(0,i.h)),radius:t,startAngle:Nr,endAngle:hr}),Jfe}function e5e(r){if(!r)throw new Error("Canvas element not found");const e=r.getContext("webgl2",{premultipliedAlpha:!1});if(!e)throw new Error("Failed to get webgl2 context");const t=`#version 300 es
378
- precision mediump float;
379
-
380
- in vec2 shapeVertexPosition;
381
-
382
- uniform vec4 canvasPageBounds;
383
-
384
- // taken (with thanks) from
385
- // https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html
386
- void main() {
387
- // convert the position from pixels to 0.0 to 1.0
388
- vec2 zeroToOne = (shapeVertexPosition - canvasPageBounds.xy) / canvasPageBounds.zw;
389
-
390
- // convert from 0->1 to 0->2
391
- vec2 zeroToTwo = zeroToOne * 2.0;
392
-
393
- // convert from 0->2 to -1->+1 (clipspace)
394
- vec2 clipSpace = zeroToTwo - 1.0;
395
-
396
- gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
397
- }`,n=e.createShader(e.VERTEX_SHADER);if(!n)throw new Error("Failed to create vertex shader");if(e.shaderSource(n,t),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS))throw new Error("Failed to compile vertex shader");const i=`#version 300 es
398
- precision mediump float;
399
-
400
- uniform vec4 fillColor;
401
- out vec4 outputColor;
402
-
403
- void main() {
404
- outputColor = fillColor;
405
- }`,o=e.createShader(e.FRAGMENT_SHADER);if(!o)throw new Error("Failed to create fragment shader");if(e.shaderSource(o,i),e.compileShader(o),!e.getShaderParameter(o,e.COMPILE_STATUS))throw new Error("Failed to compile fragment shader");const s=e.createProgram();if(!s)throw new Error("Failed to create program");if(e.attachShader(s,n),e.attachShader(s,o),e.linkProgram(s),!e.getProgramParameter(s,e.LINK_STATUS))throw new Error("Failed to link program");e.useProgram(s);const a=e.getAttribLocation(s,"shapeVertexPosition");if(a<0)throw new Error("Failed to get shapeVertexPosition attribute location");e.enableVertexAttribArray(a);const c=e.getUniformLocation(s,"canvasPageBounds"),l=e.getUniformLocation(s,"fillColor");if(!e.createBuffer())throw new Error("Failed to create buffer");if(!e.createBuffer())throw new Error("Failed to create buffer");return{context:e,selectedShapes:ev(e,1024),unselectedShapes:ev(e,4096),viewport:ev(e,Jfe),collaborators:ev(e,1024),prepareTriangles(h,g){e.bindBuffer(e.ARRAY_BUFFER,h.buffer),e.bufferData(e.ARRAY_BUFFER,h.vertices,e.STATIC_DRAW,0,g),e.enableVertexAttribArray(a),e.vertexAttribPointer(a,2,e.FLOAT,!1,0,0)},drawTrianglesTransparently(h){e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.drawArrays(e.TRIANGLES,0,h/2),e.disable(e.BLEND)},drawTriangles(h){e.drawArrays(e.TRIANGLES,0,h/2)},setFillColor(h){e.uniform4fv(l,h)},setCanvasPageBounds(h){e.uniform4fv(c,h)}}}function ev(r,e){const t=r.createBuffer();if(!t)throw new Error("Failed to create buffer");return{buffer:t,vertices:new Float32Array(e)}}function PJ(r,e,t){let n=r.vertices.length;for(;n<e+t.length;)n*=2;if(n!=r.vertices.length){const i=new Float32Array(n);i.set(r.vertices),r.vertices=i}r.vertices.set(t,e)}var t5e=Object.create,ehe=Object.defineProperty,r5e=Object.getOwnPropertyDescriptor,n5e=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),the=r=>{throw TypeError(r)},rhe=(r,e,t)=>e in r?ehe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,i5e=r=>[,,,t5e(null)],nhe=["class","method","getter","setter","accessor","field","value","get","set"],ihe=r=>r!==void 0&&typeof r!="function"?the("Function expected"):r,o5e=(r,e,t,n,i)=>({kind:nhe[r],name:e,metadata:n,addInitializer:o=>t._?the("Already initialized"):i.push(ihe(o||null))}),s5e=(r,e)=>rhe(e,n5e("metadata"),r[3]),a5e=(r,e,t,n)=>{for(var i=0,o=r[e>>1],s=o&&o.length;i<s;i++)o[i].call(t);return n},ka=(r,e,t,n,i,o)=>{for(var s,a,c,l,d=e&7,f=!1,h=!1,g=2,m=nhe[d+5],y=r[g]||(r[g]=[]),x=(i=i.prototype,r5e(i,t)),_=n.length-1;_>=0;_--)c=o5e(d,t,a={},r[3],y),c.static=f,c.private=h,l=c.access={has:w=>t in w},l.get=w=>w[t],s=(0,n[_])(x[m],c),a._=1,ihe(s)&&(x[m]=s);return x&&ehe(i,t,x),i},Ka=(r,e,t)=>rhe(r,typeof e!="symbol"?e+"":e,t),ohe,she,ahe,che,lhe,uhe,dhe,fhe,hhe,phe,Ko;phe=[po],hhe=[Te],fhe=[Te],dhe=[Te],uhe=[Te],lhe=[Te],che=[Te],ahe=[Te],she=[Te],ohe=[po];class hs{constructor(e,t,n){this.editor=e,this.elem=t,this.container=n,a5e(Ko,5,this),Ka(this,"disposables",[]),Ka(this,"gl"),Ka(this,"shapeGeometryCache"),Ka(this,"colors"),Ka(this,"id",Er()),Ka(this,"canvasBoundingClientRect",xn("canvasBoundingClientRect",new He)),Ka(this,"originPagePoint",new T),Ka(this,"originPageCenter",new T),Ka(this,"isInViewport",!1),this.gl=e5e(t),this.shapeGeometryCache=e.store.createComputedCache("webgl-geometry",i=>{const o=e.getShapeMaskedPageBounds(i.id);if(!o)return null;const s=new Float32Array(12);return ad(s,0,o.x,o.y,o.w,o.h),s}),this.colors=this._getColors(),this.disposables.push(this._listenForCanvasResize(),fa("minimap render",this.render))}close(){return this.disposables.forEach(e=>e())}_getColors(){const e=getComputedStyle(this.editor.getContainer());return{shapeFill:Gf(e.getPropertyValue("--color-text-3").trim()),selectFill:Gf(e.getPropertyValue("--color-selected").trim()),viewportFill:Gf(e.getPropertyValue("--color-muted-1").trim()),background:Gf(e.getPropertyValue("--color-low").trim())}}updateColors(){this.colors=this._getColors()}getDpr(){return this.editor.getInstanceState().devicePixelRatio}getContentPageBounds(){const e=this.editor.getViewportPageBounds(),t=this.editor.getCurrentPageBounds();return t?He.Expand(t,e):e}getContentScreenBounds(){const e=this.getContentPageBounds(),t=this.editor.pageToScreen(e.point),n=this.editor.pageToScreen(new T(e.maxX,e.maxY));return new He(t.x,t.y,n.x-t.x,n.y-t.y)}_getCanvasBoundingRect(){const{x:e,y:t,width:n,height:i}=this.elem.getBoundingClientRect();return new He(e,t,n,i)}getCanvasScreenBounds(){return this.canvasBoundingClientRect.get()}_listenForCanvasResize(){const e=new ResizeObserver(()=>{const t=this._getCanvasBoundingRect();this.canvasBoundingClientRect.set(t)});return e.observe(this.elem),e.observe(this.container),()=>e.disconnect()}getCanvasSize(){const e=this.canvasBoundingClientRect.get(),t=this.getDpr();return new T(e.width*t,e.height*t)}getCanvasClientPosition(){return this.canvasBoundingClientRect.get().point}getCanvasPageBounds(){const e=this.getCanvasScreenBounds(),t=this.getContentPageBounds(),n=e.width/e.height;let i=t.width,o=i/n;o<t.height&&(o=t.height,i=o*n);const s=new He(0,0,i,o);return s.center=t.center,s}getZoom(){return this.getCanvasPageBounds().width/this.getCanvasScreenBounds().width}getCanvasPageBoundsArray(){const{x:e,y:t,w:n,h:i}=this.getCanvasPageBounds();return new Float32Array([e,t,n,i])}getMinimapPagePoint(e,t){const n=this.getCanvasPageBounds(),i=this.getCanvasScreenBounds();let o=e-i.x,s=t-i.y;return o*=n.width/i.width,s*=n.height/i.height,o+=n.minX,s+=n.minY,new T(o,s,1)}minimapScreenPointToPagePoint(e,t,n=!1,i=!1){const{editor:o}=this,s=o.getViewportPageBounds();let{x:a,y:c}=this.getMinimapPagePoint(e,t);if(i){const l=this.editor.getCurrentPageBounds()??new He,d=l.minX-s.width/2,f=l.maxX+s.width/2,h=l.minY-s.height/2,g=l.maxY+s.height/2,m=Math.max(0,d+s.width-a),y=Math.max(0,-(f-s.width-a)),x=Math.max(0,h+s.height-c),_=Math.max(0,-(g-s.height-c));a+=(m-y)/2,c+=(x-_)/2,a=Yn(a,d,f),c=Yn(c,h,g)}if(n){const{originPagePoint:l}=this,d=Math.abs(a-l.x),f=Math.abs(c-l.y);d>f?c=l.y:a=l.x}return new T(a,c)}render(){const e=this.gl.context,t=this.getCanvasSize();this.gl.setCanvasPageBounds(this.getCanvasPageBoundsArray()),this.elem.width=t.x,this.elem.height=t.y,e.viewport(0,0,t.x,t.y),e.clearColor(this.colors.background[0],this.colors.background[1],this.colors.background[2],1),e.clear(e.COLOR_BUFFER_BIT);const n=new Set(this.editor.getSelectedShapeIds()),i=this.colors;let o=0,s=0;const a=this.editor.getCurrentPageShapeIdsSorted();for(let c=0,l=a.length;c<l;c++){const d=a[c],f=this.shapeGeometryCache.get(d);if(!f)continue;const h=f.length;n.has(d)?(PJ(this.gl.selectedShapes,o,f),o+=h):(PJ(this.gl.unselectedShapes,s,f),s+=h)}this.drawShapes(this.gl.unselectedShapes,s,i.shapeFill),this.drawShapes(this.gl.selectedShapes,o,i.selectFill),this.drawViewport(),this.drawCollaborators()}drawShapes(e,t,n){this.gl.prepareTriangles(e,t),this.gl.setFillColor(n),this.gl.drawTriangles(t)}drawViewport(){const e=this.editor.getViewportPageBounds(),t=Jqe(this.gl.viewport.vertices,e,4*this.getZoom());this.gl.prepareTriangles(this.gl.viewport,t),this.gl.setFillColor(this.colors.viewportFill),this.gl.drawTrianglesTransparently(t),Pr.isSafari&&(this.gl.drawTrianglesTransparently(t),this.gl.drawTrianglesTransparently(t),this.gl.drawTrianglesTransparently(t))}drawCollaborators(){const e=this.editor.getCollaboratorsOnCurrentPage();if(!e.length)return;const t=20,n=t*6,i=n*e.length;this.gl.collaborators.vertices.length<i&&(this.gl.collaborators.vertices=new Float32Array(i));const o=this.gl.collaborators.vertices;let s=0;const a=this.getZoom();for(const{cursor:c}of e)c&&(sd(o,{center:T.From(c),radius:3*a,offset:s,numArcSegments:t}),s+=n);this.gl.prepareTriangles(this.gl.collaborators,i),s=0;for(const{color:c}of e)this.gl.setFillColor(Gf(c)),this.gl.context.drawArrays(this.gl.context.TRIANGLES,s/2,n/2),s+=n}}Ko=i5e();ka(Ko,1,"close",phe,hs);ka(Ko,1,"getDpr",hhe,hs);ka(Ko,1,"getContentPageBounds",fhe,hs);ka(Ko,1,"getContentScreenBounds",dhe,hs);ka(Ko,1,"getCanvasSize",uhe,hs);ka(Ko,1,"getCanvasClientPosition",lhe,hs);ka(Ko,1,"getCanvasPageBounds",che,hs);ka(Ko,1,"getZoom",ahe,hs);ka(Ko,1,"getCanvasPageBoundsArray",she,hs);ka(Ko,1,"render",ohe,hs);s5e(Ko,hs);function c5e(){const r=he(),e=Ln(),t=A.useRef(null),n=A.useRef(!1),i=A.useRef();A.useEffect(()=>{try{const d=new hs(r,t.current,e);return i.current=d,i.current.close}catch(d){r.annotateError(d,{origin:"minimap",willCrashApp:!1}),r.timers.setTimeout(()=>{throw d})}},[r,e]);const o=A.useCallback(d=>{if(!r.getCurrentPageShapeIds().size||!i.current)return;const f=i.current.minimapScreenPointToPagePoint(d.clientX,d.clientY,!1,!1),h=i.current.minimapScreenPointToPagePoint(d.clientX,d.clientY,!1,!0);i.current.originPagePoint.setTo(h),i.current.originPageCenter.setTo(r.getViewportPageBounds().center),r.centerOnPoint(f,{animation:{duration:r.options.animationMediumMs}})},[r]),s=A.useCallback(d=>{if(!i.current)return;const f=d.currentTarget;if(Hh(f,d),!r.getCurrentPageShapeIds().size)return;n.current=!0,i.current.isInViewport=!1;const h=i.current.minimapScreenPointToPagePoint(d.clientX,d.clientY,!1,!1),g=r.getViewportPageBounds(),m=i.current.getContentPageBounds();if(new He(m.x-g.width/2,m.y-g.height/2,m.width+g.width,m.height+g.height).containsPoint(h)&&!g.containsPoint(h)){i.current.isInViewport=g.containsPoint(h);const _=T.Sub(g.center,g.point),w=T.Add(h,_);i.current.originPagePoint.setTo(w),i.current.originPageCenter.setTo(h),r.centerOnPoint(h,{animation:{duration:r.options.animationMediumMs}})}else{const _=i.current.minimapScreenPointToPagePoint(d.clientX,d.clientY,!1,!0);i.current.isInViewport=g.containsPoint(_),i.current.originPagePoint.setTo(_),i.current.originPageCenter.setTo(g.center)}function x(_){f&&Wh(f,_),n.current=!1,document.body.removeEventListener("pointerup",x)}document.body.addEventListener("pointerup",x)},[r]),a=A.useCallback(d=>{if(!i.current)return;const f=i.current.minimapScreenPointToPagePoint(d.clientX,d.clientY,d.shiftKey,!0);if(n.current){if(i.current.isInViewport){const y=i.current.originPagePoint.clone().sub(i.current.originPageCenter);r.centerOnPoint(T.Sub(f,y));return}r.centerOnPoint(f)}const h=i.current.getMinimapPagePoint(d.clientX,d.clientY),g=r.pageToScreen(h),m={type:"pointer",target:"canvas",name:"pointer_move",...Ao(d),point:g,isPen:r.getInstanceState().isPenMode};r.dispatch(m)},[r]),c=A.useCallback(d=>{const f=Yte(d);r.dispatch({type:"wheel",name:"wheel",delta:f,point:new T(d.clientX,d.clientY),shiftKey:d.shiftKey,altKey:d.altKey,ctrlKey:d.metaKey||d.ctrlKey,metaKey:d.metaKey,accelKey:wi(d)})},[r]),l=lp();return A.useEffect(()=>{r.timers.setTimeout(()=>{var d,f;(d=i.current)==null||d.updateColors(),(f=i.current)==null||f.render()})},[l,r]),v.jsx("div",{className:"tlui-minimap",children:v.jsx("canvas",{role:"img","aria-label":"minimap",ref:t,className:"tlui-minimap__canvas",onDoubleClick:o,onPointerMove:a,onPointerDown:s,onWheelCapture:c})})}function l5e(r,e){const[t,n]=lr.useState(e);lr.useLayoutEffect(()=>{const o=FC(r);if(o)try{n(JSON.parse(o))}catch{console.error(`Could not restore value ${r} from local storage.`)}},[r]);const i=lr.useCallback(o=>{n(s=>{const a=typeof o=="function"?o(s):o;return NC(r,JSON.stringify(a)),a})},[r]);return[t,i]}const u5e=A.memo(function(){const e=bu(),t=ar(),n=Gi(),i=A.useRef(null);vl(i);const[o,s]=l5e("minimap",!0),a=A.useCallback(()=>{s(d=>!d)},[s]),{ZoomMenu:c,Minimap:l}=xl();return n<fn.MOBILE?null:v.jsxs("div",{ref:i,className:"tlui-navigation-panel",children:[v.jsx("div",{className:"tlui-buttons__horizontal",children:c&&n<fn.TABLET?v.jsx(c,{}):o?v.jsxs(v.Fragment,{children:[c&&v.jsx(c,{}),l&&v.jsx(It,{type:"icon","data-testid":"minimap.toggle-button",title:t("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:a,children:v.jsx(rr,{icon:o?"chevrons-ne":"chevrons-sw"})})]}):v.jsxs(v.Fragment,{children:[v.jsx(It,{type:"icon","data-testid":"minimap.zoom-out",title:`${t(Th(e["zoom-out"].label))} ${iC(e["zoom-out"].kbd)}`,onClick:()=>e["zoom-out"].onSelect("navigation-zone"),children:v.jsx(rr,{icon:"minus"})}),c&&v.jsx(c,{}),v.jsx(It,{type:"icon","data-testid":"minimap.zoom-in",title:`${t(Th(e["zoom-in"].label))} ${iC(e["zoom-in"].kbd)}`,onClick:()=>e["zoom-in"].onSelect("navigation-zone"),children:v.jsx(rr,{icon:"plus"})}),l&&v.jsx(It,{type:"icon","data-testid":"minimap.toggle-button",title:t("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:a,children:v.jsx(rr,{icon:o?"chevrons-ne":"chevrons-sw"})})]})}),l&&n>=fn.TABLET&&!o&&v.jsx(l,{})]})}),d5e=function({name:e,id:t,isCurrentPage:n,onCancel:i}){const o=he(),s=ai(),a=A.useRef(null),c=A.useRef(null),l=A.useCallback(()=>{c.current=o.markHistoryStoppingPoint("rename page")},[o]),d=A.useCallback(h=>{o.renamePage(t,h||"New Page"),s("rename-page",{source:"page-menu"})},[o,t,s]),f=A.useCallback(()=>{c.current&&o.bailToMark(c.current),i()},[o,i]);return v.jsx(Xy,{className:"tlui-page-menu__item__input",ref:h=>a.current=h,defaultValue:e,onValueChange:d,onCancel:f,onFocus:l,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:n,autoSelect:!0})},EC=(r,e,t,n,i)=>{let o;const s=r.getPages(),a=t>n?s[n-1]:s[n],c=t>n?s[n]:s[n+1];a&&!c?o=ca(a.index):!a&&c?o=cve(s[0].index):o=mh(a.index,c.index),o!==s[t].index&&(r.markHistoryStoppingPoint("moving page"),r.updatePage({id:e,index:o}),i("move-page",{source:"page-menu"}))},CJ=ii(function({index:e,listSize:t,item:n,onRename:i}){const o=he(),s=ar(),a=o.getPages(),c=ai(),l=A.useCallback(()=>{o.markHistoryStoppingPoint("creating page");const g=Fo.createId();o.duplicatePage(n.id,g),c("duplicate-page",{source:"page-menu"})},[o,n,c]),d=A.useCallback(()=>{EC(o,n.id,e,e-1,c)},[o,n,e,c]),f=A.useCallback(()=>{EC(o,n.id,e,e+1,c)},[o,n,e,c]),h=A.useCallback(()=>{o.markHistoryStoppingPoint("deleting page"),o.deletePage(n.id),c("delete-page",{source:"page-menu"})},[o,n,c]);return v.jsxs(tu,{id:`page item submenu ${e}`,children:[v.jsx(ru,{children:v.jsx(It,{type:"icon",title:s("page-menu.submenu.title"),children:v.jsx(rr,{icon:"dots-vertical",small:!0})})}),v.jsx(nu,{alignOffset:0,side:"right",sideOffset:-4,children:v.jsxs(ls,{type:"menu",sourceId:"page-menu",children:[v.jsxs(Yt,{id:"modify",children:[i&&v.jsx(Qn,{id:"rename",label:"page-menu.submenu.rename",onSelect:i}),v.jsx(Qn,{id:"duplicate",label:"page-menu.submenu.duplicate-page",onSelect:l,disabled:a.length>=o.options.maxPages}),e>0&&v.jsx(Qn,{id:"move-up",onSelect:d,label:"page-menu.submenu.move-up"}),e<t-1&&v.jsx(Qn,{id:"move-down",label:"page-menu.submenu.move-down",onSelect:f})]}),t>1&&v.jsx(Yt,{id:"delete",children:v.jsx(Qn,{id:"delete",onSelect:h,label:"page-menu.submenu.delete"})})]})})]})}),f5e=A.memo(function(){const e=he(),t=ai(),n=ar(),i=Gi(),o=A.useCallback(()=>_(!1),[]),[s,a]=vc("page-menu",o),c=36,l=A.useRef(null),d=ye("pages",()=>e.getPages(),[e]),f=ye("currentPage",()=>e.getCurrentPage(),[e]),h=ye("currentPageId",()=>e.getCurrentPageId(),[e]),g=Wo(),m=ye("maxPageCountReached",()=>e.getPages().length>=e.options.maxPages,[e]),y=ye("isCoarsePointer",()=>e.getInstanceState().isCoarsePointer,[e]),[x,_]=A.useState(!1),w=A.useCallback(()=>{g||_(D=>!D)},[g]),I=A.useRef({isPointing:!1,status:"idle",pointing:null,startY:0,startIndex:0,dragIndex:0}),[b,P]=A.useState(Object.fromEntries(d.map((D,N)=>[D.id,{y:N*c,offsetY:0,isSelected:!1}])));A.useLayoutEffect(()=>{P(Object.fromEntries(d.map((D,N)=>[D.id,{y:N*c,offsetY:0,isSelected:!1}])))},[c,d]),A.useEffect(()=>{s&&e.timers.requestAnimationFrame(()=>{const D=document.querySelector(`[data-testid="page-menu-item-${h}"]`);if(D){const N=l.current;if(!N)return;const B=D.offsetTop,W=N.scrollTop;B<W&&N.scrollTo({top:B});const G=B+c,z=N.scrollTop+N.offsetHeight;G>z&&N.scrollTo({top:G-N.offsetHeight})}})},[c,h,s,e]);const C=A.useCallback(D=>{const{clientY:N,currentTarget:B}=D,{dataset:{id:W,index:G}}=B;if(!W||!G)return;const z=I.current;Hh(D.currentTarget,D),z.status="pointing",z.pointing={id:W,index:+G};const J=b[W].y;z.startY=N,z.startIndex=Math.max(0,Math.min(Math.round(J/c),d.length-1))},[c,d.length,b]),k=A.useCallback(D=>{const N=I.current;if(N.status==="pointing"){const{clientY:B}=D,W=B-N.startY;Math.abs(W)>5&&(N.status="dragging")}if(N.status==="dragging"){const{clientY:B}=D,W=B-N.startY,G=b[N.pointing.id],{startIndex:z,pointing:V}=N,J=G.y+W,K=Math.max(0,Math.min(Math.round(J/c),d.length-1)),Z={...b};if(Z[V.id]={y:G.y,offsetY:W,isSelected:!0},K!==N.dragIndex){N.dragIndex=K;for(let ee=0;ee<d.length;ee++){const re=d[ee];if(re.id===N.pointing.id)continue;let{y:te}=Z[re.id];K===z?te=ee*c:K<z?K<=ee&&ee<z?te=(ee+1)*c:te=ee*c:K>z&&(K>=ee&&ee>z?te=(ee-1)*c:te=ee*c),te!==Z[re.id].y&&(Z[re.id]={y:te,offsetY:0,isSelected:!0})}}P(Z)}},[c,d,b]),O=A.useCallback(D=>{const N=I.current;if(N.status==="dragging"){const{id:B,index:W}=N.pointing;EC(e,B,W,N.dragIndex,t)}Wh(D.currentTarget,D),N.status="idle"},[e,t]),L=A.useCallback(D=>{const N=I.current;D.key==="Escape"&&(N.status==="dragging"&&P(Object.fromEntries(d.map((B,W)=>[B.id,{y:W*c,offsetY:0,isSelected:!1}]))),N.status="idle")},[c,d]),j=A.useCallback(()=>{g||(e.run(()=>{e.markHistoryStoppingPoint("creating page");const D=Fo.createId();e.createPage({name:n("page-menu.new-page-initial-name"),id:D}),e.setCurrentPage(D),_(!0)}),t("new-page",{source:"page-menu"}))},[e,n,g,t]),F=A.useCallback(D=>{e.setCurrentPage(D),t("change-page",{source:"page-menu"})},[e,t]),$=A.useCallback((D,N)=>{e.renamePage(D,N),t("rename-page",{source:"page-menu"})},[e,t]);return v.jsxs(AR,{id:"pages",onOpenChange:a,open:s,children:[v.jsx(RR,{"data-testid":"main.page-menu",children:v.jsxs(It,{type:"menu",title:f.name,"data-testid":"page-menu.button",className:"tlui-page-menu__trigger",children:[v.jsx("div",{className:"tlui-page-menu__name",children:f.name}),v.jsx(rr,{icon:"chevron-down",small:!0})]})}),v.jsx(kR,{side:"bottom",align:"start",sideOffset:6,disableEscapeKeyDown:x,children:v.jsxs("div",{className:"tlui-page-menu__wrapper",children:[v.jsxs("div",{className:"tlui-page-menu__header",children:[v.jsx("div",{className:"tlui-page-menu__header__title",children:n("page-menu.title")}),!g&&v.jsxs("div",{className:"tlui-buttons__horizontal",children:[v.jsx(It,{type:"icon","data-testid":"page-menu.edit",title:n(x?"page-menu.edit-done":"page-menu.edit-start"),onClick:w,children:v.jsx(rr,{icon:x?"check":"edit"})}),v.jsx(It,{type:"icon","data-testid":"page-menu.create",title:n(m?"page-menu.max-page-count-reached":"page-menu.create-new-page"),disabled:m,onClick:j,children:v.jsx(rr,{icon:"plus"})})]})]}),v.jsx("div",{"data-testid":"page-menu.list",className:"tlui-page-menu__list tlui-menu__group",style:{height:c*d.length+4},ref:l,children:d.map((D,N)=>{const B=b[D.id]??{offsetY:0};return x?v.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page_menu__item__sortable",style:{zIndex:D.id===f.id?888:N,transform:`translate(0px, ${B.y+B.offsetY}px)`},children:[v.jsx(It,{type:"icon",tabIndex:-1,className:"tlui-page_menu__item__sortable__handle",onPointerDown:C,onPointerUp:O,onPointerMove:k,onKeyDown:L,"data-id":D.id,"data-index":N,children:v.jsx(rr,{icon:"drag-handle-dots"})}),i<fn.TABLET_SM&&y?v.jsxs(It,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>{const W=window.prompt("Rename page",D.name);W&&W!==D.name&&$(D.id,W)},onDoubleClick:w,children:[v.jsx(bC,{checked:D.id===f.id}),v.jsx(Sn,{children:D.name})]}):v.jsx("div",{className:"tlui-page_menu__item__sortable__title",style:{height:c},children:v.jsx(d5e,{id:D.id,name:D.name,isCurrentPage:D.id===f.id,onCancel:()=>{_(!1),e.menus.clearOpenMenus()}})}),!g&&v.jsx("div",{className:"tlui-page_menu__item__submenu","data-isediting":x,children:v.jsx(CJ,{index:N,item:D,listSize:d.length})})]},D.id+"_editing"):v.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page-menu__item",children:[v.jsxs(It,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>F(D.id),onDoubleClick:w,title:n("page-menu.go-to-page"),children:[v.jsx(bC,{checked:D.id===f.id}),v.jsx(Sn,{children:D.name})]}),!g&&v.jsx("div",{className:"tlui-page_menu__item__submenu",children:v.jsx(CJ,{index:N,item:D,listSize:d.length,onRename:()=>{if(Pr.isIos){const W=window.prompt("Rename page",D.name);W&&W!==D.name&&$(D.id,W)}else _(!0),h!==D.id&&F(D.id)}})})]},D.id)})})]})})]})});function h5e(){const r=he(),e=Wo(),t=ye("should display quick actions",()=>r.isInAny("select","hand","zoom"),[r]);if(!(e&&!t))return v.jsxs(v.Fragment,{children:[v.jsx(g5e,{}),v.jsx(p5e,{})]})}function p5e(){const r=Vi(1),e=mc(),t=r&&e;return v.jsxs(v.Fragment,{children:[v.jsx(Ce,{actionId:"delete",disabled:!t}),v.jsx(Ce,{actionId:"duplicate",disabled:!t})]})}function g5e(){const r=Ofe(),e=kfe();return v.jsxs(v.Fragment,{children:[v.jsx(Ce,{actionId:"undo",disabled:!r}),v.jsx(Ce,{actionId:"redo",disabled:!e})]})}const v5e=A.memo(function({children:e}){const t=e??v.jsx(h5e,{});return v.jsx(ls,{type:"small-icons",sourceId:"quick-actions",children:t})});function m5e({userId:r}){const e=Hm(r);return e?v.jsx("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:e.color},children:e.userName==="New User"?"":e.userName[0]??""},r):null}const y5e=ii(function({userId:e}){const t=he(),n=ar(),i=ai(),o=Hm(e),s=A.useCallback(()=>{t.getInstanceState().followingUserId===e?(t.stopFollowingUser(),i("stop-following",{source:"people-menu"})):(t.startFollowingUser(e),i("start-following",{source:"people-menu"}))},[t,e,i]),a=(o==null?void 0:o.followingUserId)===t.user.getId(),c=t.getInstanceState().followingUserId===e;return o?v.jsxs("div",{className:"tlui-people-menu__item tlui-buttons__horizontal",children:[v.jsxs(It,{type:"menu",className:"tlui-people-menu__item__button",onClick:()=>t.zoomToUser(e),onDoubleClick:s,children:[v.jsx(Sa,{icon:"color",color:o.color}),v.jsx("div",{className:"tlui-people-menu__name",children:o.userName??"New User"})]}),v.jsx(It,{type:"icon",className:"tlui-people-menu__item__follow",title:n(a?"people-menu.leading":c?"people-menu.following":"people-menu.follow"),onClick:s,disabled:a,"data-active":c||a,children:v.jsx(rr,{icon:a?"leading":c?"following":"follow"})})]}):null});function S5e({count:r}){return v.jsx("div",{className:"tlui-people-menu__more",children:"+"+Math.abs(r)})}const x5e=ii(function(){const e=he(),t=Ln(),n=ar(),i=ai(),o=A.useRef(!1),[s,a]=A.useState(!1),c=A.useCallback(y=>{a(y)},[]),l=e.user.getColor(),d=A.useCallback(y=>{e.user.updateUserPreferences({color:y}),i("set-color",{source:"people-menu"})},[e,i]),{handleButtonClick:f,handleButtonPointerDown:h,handleButtonPointerEnter:g,handleButtonPointerUp:m}=lr.useMemo(()=>{const y=()=>{o.current=!1,window.removeEventListener("pointerup",y)};return{handleButtonClick:b=>{const{id:P}=b.currentTarget.dataset;P&&l!==P&&d(P)},handleButtonPointerDown:b=>{const{id:P}=b.currentTarget.dataset;P&&(d(P),o.current=!0,window.addEventListener("pointerup",y))},handleButtonPointerEnter:b=>{if(!o.current)return;const{id:P}=b.currentTarget.dataset;P&&d(P)},handleButtonPointerUp:b=>{const{id:P}=b.currentTarget.dataset;P&&d(P)}}},[l,d]);return v.jsxs(IR,{onOpenChange:c,open:s,children:[v.jsx(PR,{dir:"ltr",asChild:!0,children:v.jsx(It,{type:"icon",className:"tlui-people-menu__user__color",style:{color:e.user.getColor()},title:n("people-menu.change-color"),children:v.jsx(rr,{icon:"color"})})}),v.jsx(CR,{container:t,children:v.jsx(TR,{dir:"ltr",className:"tlui-menu tlui-people-menu__user__color-picker",align:"start",side:"left",sideOffset:8,children:v.jsx("div",{className:"tlui-buttons__grid",children:OP.map(y=>v.jsx(It,{type:"icon","data-id":y,"data-testid":y,"aria-label":y,"data-state":l===y?"hinted":void 0,title:y,className:"tlui-button-grid__button",style:{color:y},onPointerEnter:g,onPointerDown:h,onPointerUp:m,onClick:f,children:v.jsx(rr,{icon:"color"})},y))})})})]})});function _5e(){const r=he(),e=ai(),t=ye("userName",()=>r.user.getName(),[]),n=ar(),i=A.useRef(t),o=A.useRef(t),[s,a]=A.useState(!1),c=A.useCallback(()=>{a(h=>!h)},[]),l=A.useCallback(h=>{o.current=h,r.user.updateUserPreferences({name:h})},[r]),d=A.useCallback(()=>{i.current!==o.current&&(e("change-user-name",{source:"people-menu"}),i.current=o.current)},[e]),f=A.useCallback(()=>{a(!1),r.user.updateUserPreferences({name:i.current}),r.menus.clearOpenMenus()},[r]);return v.jsxs("div",{className:"tlui-people-menu__user",children:[v.jsx(x5e,{}),s?v.jsx(Xy,{className:"tlui-people-menu__user__input",defaultValue:t,onValueChange:l,onComplete:c,onCancel:f,onBlur:d,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:!0,autoSelect:!0}):v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"tlui-people-menu__user__name",onDoubleClick:()=>{s||a(!0)},children:t}),t==="New User"?v.jsx("div",{className:"tlui-people-menu__user__label",children:n("people-menu.user")}):null]}),v.jsx(It,{type:"icon",className:"tlui-people-menu__user__edit","data-testid":"people-menu.change-name",title:n("people-menu.change-name"),onClick:c,children:v.jsx(rr,{icon:s?"check":"edit"})})]})}function w5e({displayUserWhenAlone:r,children:e}){const t=ar(),n=Ln(),i=he(),o=Qte(),s=ye("user",()=>i.user.getColor(),[i]),a=ye("user",()=>i.user.getName(),[i]),[c,l]=vc("people menu");return v.jsxs(IR,{onOpenChange:l,open:c,children:[v.jsx(PR,{dir:"ltr",asChild:!0,children:v.jsxs("button",{className:"tlui-people-menu__avatars-button",title:t("people-menu.title"),children:[o.length>5&&v.jsx(S5e,{count:o.length-5}),v.jsxs("div",{className:"tlui-people-menu__avatars",children:[o.slice(-5).map(d=>v.jsx(m5e,{userId:d},d)),(r||o.length>0)&&v.jsx("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:s},children:a==="New User"?"":a[0]??""})]})]})}),v.jsx(CR,{container:n,children:v.jsx(TR,{dir:"ltr",className:"tlui-menu",side:"bottom",sideOffset:2,collisionPadding:4,onEscapeKeyDown:Qt,children:v.jsxs("div",{className:"tlui-people-menu__wrapper",children:[v.jsx("div",{className:"tlui-people-menu__section",children:v.jsx(_5e,{})}),o.length>0&&v.jsx("div",{className:"tlui-people-menu__section",children:o.map(d=>v.jsx(y5e,{userId:d},d+"_presence"))}),e]})})})]})}function b5e(){return v.jsx("div",{className:"tlui-share-zone",draggable:!1,children:v.jsx(w5e,{displayUserWhenAlone:!0})})}const E5e=Object.freeze([Lo,Xl,Zl,va]);function ghe(r=E5e){const e=he();return ye("getRelevantStyles",()=>{var o;const t=new NP(e.getSharedStyles()),n=!!((o=e.root.getCurrent())!=null&&o.shapeType),i=e.isIn("select")&&e.getSelectedShapeIds().length>0;if(t.size===0&&e.isIn("select")&&e.getSelectedShapeIds().length===0)for(const s of r)t.applyValue(s,e.getStyleForNextShape(s));return n||i||t.size>0?t:null},[e])}const is={color:[{value:"black",icon:"color"},{value:"grey",icon:"color"},{value:"light-violet",icon:"color"},{value:"violet",icon:"color"},{value:"blue",icon:"color"},{value:"light-blue",icon:"color"},{value:"yellow",icon:"color"},{value:"orange",icon:"color"},{value:"green",icon:"color"},{value:"light-green",icon:"color"},{value:"light-red",icon:"color"},{value:"red",icon:"color"}],fill:[{value:"none",icon:"fill-none"},{value:"semi",icon:"fill-semi"},{value:"solid",icon:"fill-solid"},{value:"pattern",icon:"fill-pattern"}],dash:[{value:"draw",icon:"dash-draw"},{value:"dashed",icon:"dash-dashed"},{value:"dotted",icon:"dash-dotted"},{value:"solid",icon:"dash-solid"}],size:[{value:"s",icon:"size-small"},{value:"m",icon:"size-medium"},{value:"l",icon:"size-large"},{value:"xl",icon:"size-extra-large"}],font:[{value:"draw",icon:"font-draw"},{value:"sans",icon:"font-sans"},{value:"serif",icon:"font-serif"},{value:"mono",icon:"font-mono"}],textAlign:[{value:"start",icon:"text-align-left"},{value:"middle",icon:"text-align-center"},{value:"end",icon:"text-align-right"}],horizontalAlign:[{value:"start",icon:"horizontal-align-start"},{value:"middle",icon:"horizontal-align-middle"},{value:"end",icon:"horizontal-align-end"}],verticalAlign:[{value:"start",icon:"vertical-align-start"},{value:"middle",icon:"vertical-align-middle"},{value:"end",icon:"vertical-align-end"}],geo:[{value:"rectangle",icon:"geo-rectangle"},{value:"ellipse",icon:"geo-ellipse"},{value:"triangle",icon:"geo-triangle"},{value:"diamond",icon:"geo-diamond"},{value:"star",icon:"geo-star"},{value:"pentagon",icon:"geo-pentagon"},{value:"hexagon",icon:"geo-hexagon"},{value:"octagon",icon:"geo-octagon"},{value:"rhombus",icon:"geo-rhombus"},{value:"rhombus-2",icon:"geo-rhombus-2"},{value:"oval",icon:"geo-oval"},{value:"trapezoid",icon:"geo-trapezoid"},{value:"arrow-left",icon:"geo-arrow-left"},{value:"arrow-up",icon:"geo-arrow-up"},{value:"arrow-down",icon:"geo-arrow-down"},{value:"arrow-right",icon:"geo-arrow-right"},{value:"cloud",icon:"geo-cloud"},{value:"x-box",icon:"geo-x-box"},{value:"check-box",icon:"geo-check-box"},{value:"heart",icon:"geo-heart"}],arrowheadStart:[{value:"none",icon:"arrowhead-none"},{value:"arrow",icon:"arrowhead-arrow"},{value:"triangle",icon:"arrowhead-triangle"},{value:"square",icon:"arrowhead-square"},{value:"dot",icon:"arrowhead-dot"},{value:"diamond",icon:"arrowhead-diamond"},{value:"inverted",icon:"arrowhead-triangle-inverted"},{value:"bar",icon:"arrowhead-bar"}],arrowheadEnd:[{value:"none",icon:"arrowhead-none"},{value:"arrow",icon:"arrowhead-arrow"},{value:"triangle",icon:"arrowhead-triangle"},{value:"square",icon:"arrowhead-square"},{value:"dot",icon:"arrowhead-dot"},{value:"diamond",icon:"arrowhead-diamond"},{value:"inverted",icon:"arrowhead-triangle-inverted"},{value:"bar",icon:"arrowhead-bar"}],spline:[{value:"line",icon:"spline-line"},{value:"cubic",icon:"spline-cubic"}]},Ul=A.memo(function(e){const{uiType:t,items:n,title:i,style:o,value:s,onValueChange:a,onHistoryMark:c,theme:l}=e,d=ar(),f=A.useRef(!1),h=A.useRef(null),{handleButtonClick:g,handleButtonPointerDown:m,handleButtonPointerEnter:y,handleButtonPointerUp:x}=A.useMemo(()=>{const _=()=>{f.current=!1,window.removeEventListener("pointerup",_);const C=h.current;C&&["TEXTAREA","INPUT"].includes(C.nodeName)&&C.focus(),h.current=null};return{handleButtonClick:C=>{const{id:k}=C.currentTarget.dataset;s.type==="shared"&&s.value===k||(c==null||c("point picker item"),a(o,k))},handleButtonPointerDown:C=>{const{id:k}=C.currentTarget.dataset;c==null||c("point picker item"),a(o,k),f.current=!0,h.current=document.activeElement,window.addEventListener("pointerup",_)},handleButtonPointerEnter:C=>{if(!f.current)return;const{id:k}=C.currentTarget.dataset;a(o,k)},handleButtonPointerUp:C=>{const{id:k}=C.currentTarget.dataset;s.type==="shared"&&s.value===k||a(o,k)}}},[s,c,a,o]);return v.jsx("div",{"data-testid":`style.${t}`,className:bt("tlui-buttons__grid"),children:n.map(_=>v.jsx(It,{type:"icon","data-id":_.value,"data-testid":`style.${t}.${_.value}`,"aria-label":_.value,"data-state":s.type==="shared"&&s.value===_.value?"hinted":void 0,title:i+" — "+d(`${t}-style.${_.value}`),className:bt("tlui-button-grid__button"),style:o===Lo?{color:l[_.value].solid}:void 0,onPointerEnter:y,onPointerDown:m,onPointerUp:x,onClick:g,children:v.jsx(rr,{icon:_.icon})},_.value))})});function vhe(r,[e,t]){return Math.min(t,Math.max(e,r))}function I5e(r){const e=A.useRef({value:r,previous:r});return A.useMemo(()=>(e.current.value!==r&&(e.current.previous=e.current.value,e.current.value=r),e.current.previous),[r])}var mhe=["PageUp","PageDown"],yhe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],She={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},tf="Slider",[IC,P5e,C5e]=Dy(tf),[xhe,Q4e]=Aa(tf,[C5e]),[T5e,dS]=xhe(tf),_he=A.forwardRef((r,e)=>{const{name:t,min:n=0,max:i=100,step:o=1,orientation:s="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:l=[n],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:g=!1,form:m,...y}=r,x=A.useRef(new Set),_=A.useRef(0),I=s==="horizontal"?A5e:R5e,[b=[],P]=ml({prop:d,defaultProp:l,onChange:F=>{var D;(D=[...x.current][_.current])==null||D.focus(),f(F)}}),C=A.useRef(b);function k(F){const $=D5e(b,F);j(F,$)}function O(F){j(F,_.current)}function L(){const F=C.current[_.current];b[_.current]!==F&&h(b)}function j(F,$,{commit:D}={commit:!1}){const N=$5e(o),B=q5e(Math.round((F-n)/o)*o+n,N),W=vhe(B,[n,i]);P((G=[])=>{const z=M5e(G,W,$);if(N5e(z,c*o)){_.current=z.indexOf(W);const V=String(z)!==String(G);return V&&D&&h(z),V?z:G}else return G})}return v.jsx(T5e,{scope:r.__scopeSlider,name:t,disabled:a,min:n,max:i,valueIndexToChangeRef:_,thumbs:x.current,values:b,orientation:s,form:m,children:v.jsx(IC.Provider,{scope:r.__scopeSlider,children:v.jsx(IC.Slot,{scope:r.__scopeSlider,children:v.jsx(I,{"aria-disabled":a,"data-disabled":a?"":void 0,...y,ref:e,onPointerDown:pt(y.onPointerDown,()=>{a||(C.current=b)}),min:n,max:i,inverted:g,onSlideStart:a?void 0:k,onSlideMove:a?void 0:O,onSlideEnd:a?void 0:L,onHomeKeyDown:()=>!a&&j(n,0,{commit:!0}),onEndKeyDown:()=>!a&&j(i,b.length-1,{commit:!0}),onStepKeyDown:({event:F,direction:$})=>{if(!a){const B=mhe.includes(F.key)||F.shiftKey&&yhe.includes(F.key)?10:1,W=_.current,G=b[W],z=o*B*$;j(G+z,W,{commit:!0})}}})})})})});_he.displayName=tf;var[whe,bhe]=xhe(tf,{startEdge:"left",endEdge:"right",size:"width",direction:1}),A5e=A.forwardRef((r,e)=>{const{min:t,max:n,dir:i,inverted:o,onSlideStart:s,onSlideMove:a,onSlideEnd:c,onStepKeyDown:l,...d}=r,[f,h]=A.useState(null),g=$r(e,I=>h(I)),m=A.useRef(void 0),y=xA(i),x=y==="ltr",_=x&&!o||!x&&o;function w(I){const b=m.current||f.getBoundingClientRect(),P=[0,b.width],k=MR(P,_?[t,n]:[n,t]);return m.current=b,k(I-b.left)}return v.jsx(whe,{scope:r.__scopeSlider,startEdge:_?"left":"right",endEdge:_?"right":"left",direction:_?1:-1,size:"width",children:v.jsx(Ehe,{dir:y,"data-orientation":"horizontal",...d,ref:g,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:I=>{const b=w(I.clientX);s==null||s(b)},onSlideMove:I=>{const b=w(I.clientX);a==null||a(b)},onSlideEnd:()=>{m.current=void 0,c==null||c()},onStepKeyDown:I=>{const P=She[_?"from-left":"from-right"].includes(I.key);l==null||l({event:I,direction:P?-1:1})}})})}),R5e=A.forwardRef((r,e)=>{const{min:t,max:n,inverted:i,onSlideStart:o,onSlideMove:s,onSlideEnd:a,onStepKeyDown:c,...l}=r,d=A.useRef(null),f=$r(e,d),h=A.useRef(void 0),g=!i;function m(y){const x=h.current||d.current.getBoundingClientRect(),_=[0,x.height],I=MR(_,g?[n,t]:[t,n]);return h.current=x,I(y-x.top)}return v.jsx(whe,{scope:r.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:v.jsx(Ehe,{"data-orientation":"vertical",...l,ref:f,style:{...l.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:y=>{const x=m(y.clientY);o==null||o(x)},onSlideMove:y=>{const x=m(y.clientY);s==null||s(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:y=>{const _=She[g?"from-bottom":"from-top"].includes(y.key);c==null||c({event:y,direction:_?-1:1})}})})}),Ehe=A.forwardRef((r,e)=>{const{__scopeSlider:t,onSlideStart:n,onSlideMove:i,onSlideEnd:o,onHomeKeyDown:s,onEndKeyDown:a,onStepKeyDown:c,...l}=r,d=dS(tf,t);return v.jsx(pr.span,{...l,ref:e,onKeyDown:pt(r.onKeyDown,f=>{f.key==="Home"?(s(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):mhe.concat(yhe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:pt(r.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():n(f)}),onPointerMove:pt(r.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&i(f)}),onPointerUp:pt(r.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),o(f))})})}),Ihe="SliderTrack",Phe=A.forwardRef((r,e)=>{const{__scopeSlider:t,...n}=r,i=dS(Ihe,t);return v.jsx(pr.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...n,ref:e})});Phe.displayName=Ihe;var PC="SliderRange",Che=A.forwardRef((r,e)=>{const{__scopeSlider:t,...n}=r,i=dS(PC,t),o=bhe(PC,t),s=A.useRef(null),a=$r(e,s),c=i.values.length,l=i.values.map(h=>Ahe(h,i.min,i.max)),d=c>1?Math.min(...l):0,f=100-Math.max(...l);return v.jsx(pr.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...n,ref:a,style:{...r.style,[o.startEdge]:d+"%",[o.endEdge]:f+"%"}})});Che.displayName=PC;var CC="SliderThumb",The=A.forwardRef((r,e)=>{const t=P5e(r.__scopeSlider),[n,i]=A.useState(null),o=$r(e,a=>i(a)),s=A.useMemo(()=>n?t().findIndex(a=>a.ref.current===n):-1,[t,n]);return v.jsx(k5e,{...r,ref:o,index:s})}),k5e=A.forwardRef((r,e)=>{const{__scopeSlider:t,index:n,name:i,...o}=r,s=dS(CC,t),a=bhe(CC,t),[c,l]=A.useState(null),d=$r(e,w=>l(w)),f=c?s.form||!!c.closest("form"):!0,h=_ce(c),g=s.values[n],m=g===void 0?0:Ahe(g,s.min,s.max),y=j5e(n,s.values.length),x=h==null?void 0:h[a.size],_=x?L5e(x,m,a.direction):0;return A.useEffect(()=>{if(c)return s.thumbs.add(c),()=>{s.thumbs.delete(c)}},[c,s.thumbs]),v.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${m}% + ${_}px)`},children:[v.jsx(IC.ItemSlot,{scope:r.__scopeSlider,children:v.jsx(pr.span,{role:"slider","aria-label":r["aria-label"]||y,"aria-valuemin":s.min,"aria-valuenow":g,"aria-valuemax":s.max,"aria-orientation":s.orientation,"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,tabIndex:s.disabled?void 0:0,...o,ref:d,style:g===void 0?{display:"none"}:r.style,onFocus:pt(r.onFocus,()=>{s.valueIndexToChangeRef.current=n})})}),f&&v.jsx(O5e,{name:i??(s.name?s.name+(s.values.length>1?"[]":""):void 0),form:s.form,value:g},n)]})});The.displayName=CC;var O5e=r=>{const{value:e,...t}=r,n=A.useRef(null),i=I5e(e);return A.useEffect(()=>{const o=n.current,s=window.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(s,"value").set;if(i!==e&&c){const l=new Event("input",{bubbles:!0});c.call(o,e),o.dispatchEvent(l)}},[i,e]),v.jsx("input",{style:{display:"none"},...t,ref:n,defaultValue:e})};function M5e(r=[],e,t){const n=[...r];return n[t]=e,n.sort((i,o)=>i-o)}function Ahe(r,e,t){const o=100/(t-e)*(r-e);return vhe(o,[0,100])}function j5e(r,e){return e>2?`Value ${r+1} of ${e}`:e===2?["Minimum","Maximum"][r]:void 0}function D5e(r,e){if(r.length===1)return 0;const t=r.map(i=>Math.abs(i-e)),n=Math.min(...t);return t.indexOf(n)}function L5e(r,e,t){const n=r/2,o=MR([0,50],[0,n]);return(n-o(e)*t)*t}function F5e(r){return r.slice(0,-1).map((e,t)=>r[t+1]-e)}function N5e(r,e){if(e>0){const t=F5e(r);return Math.min(...t)>=e}return!0}function MR(r,e){return t=>{if(r[0]===r[1]||e[0]===e[1])return e[0];const n=(e[1]-e[0])/(r[1]-r[0]);return e[0]+n*(t-r[0])}}function $5e(r){return(String(r).split(".")[1]||"").length}function q5e(r,e){const t=Math.pow(10,e);return Math.round(r*t)/t}var B5e=_he,U5e=Phe,z5e=Che,H5e=The;const W5e=A.memo(function({onHistoryMark:e,title:t,steps:n,value:i,label:o,onValueChange:s,["data-testid"]:a}){const c=ar(),l=A.useCallback(h=>{s(h[0])},[s]),d=A.useCallback(()=>{e("click slider")},[e]),f=A.useCallback(()=>{i&&s(i)},[i,s]);return v.jsx("div",{className:"tlui-slider__container",children:v.jsxs(B5e,{"data-testid":a,className:"tlui-slider","area-label":"Opacity",dir:"ltr",min:0,max:n,step:1,value:i?[i]:void 0,onPointerDown:d,onValueChange:l,onPointerUp:f,title:t+" — "+c(o),children:[v.jsx(U5e,{className:"tlui-slider__track",dir:"ltr",children:i!==null&&v.jsx(z5e,{className:"tlui-slider__range",dir:"ltr"})}),i!==null&&v.jsx(H5e,{className:"tlui-slider__thumb",dir:"ltr"})]})})});function K5e({label:r,uiTypeA:e,uiTypeB:t,labelA:n,labelB:i,itemsA:o,itemsB:s,styleA:a,styleB:c,valueA:l,valueB:d,onValueChange:f}){const h=ar(),g=A.useMemo(()=>{var y;return((y=o.find(x=>l.type==="shared"&&l.value===x.value))==null?void 0:y.icon)??"mixed"},[o,l]),m=A.useMemo(()=>{var y;return((y=s.find(x=>d.type==="shared"&&d.value===x.value))==null?void 0:y.icon)??"mixed"},[s,d]);return l===void 0&&d===void 0?null:v.jsxs("div",{className:"tlui-style-panel__double-select-picker",children:[v.jsx("div",{title:h(r),className:"tlui-style-panel__double-select-picker-label",children:h(r)}),v.jsxs("div",{className:"tlui-buttons__horizontal",children:[v.jsxs(tu,{id:`style panel ${e} A`,children:[v.jsx(ru,{children:v.jsx(It,{type:"icon","data-testid":`style.${e}`,title:h(n)+" — "+(l===null||l.type==="mixed"?h("style-panel.mixed"):h(`${e}-style.${l.value}`)),children:v.jsx(rr,{icon:g,small:!0,invertIcon:!0})})}),v.jsx(nu,{side:"left",align:"center",sideOffset:80,alignOffset:0,children:v.jsx("div",{className:"tlui-buttons__grid",children:o.map((y,x)=>v.jsx(Ah,{"data-testid":`style.${e}.${y.value}`,children:v.jsx(It,{type:"icon",onClick:()=>f(a,y.value),title:`${h(n)} — ${h(`${e}-style.${y.value}`)}`,children:v.jsx(rr,{icon:y.icon,invertIcon:!0})},y.value)},x))})})]}),v.jsxs(tu,{id:`style panel ${t}`,children:[v.jsx(ru,{children:v.jsx(It,{type:"icon","data-testid":`style.${t}`,title:h(i)+" — "+(d===null||d.type==="mixed"?h("style-panel.mixed"):h(`${t}-style.${d.value}`)),children:v.jsx(rr,{icon:m,small:!0})})}),v.jsx(nu,{side:"left",align:"center",sideOffset:116,alignOffset:0,children:v.jsx("div",{className:"tlui-buttons__grid",children:s.map(y=>v.jsx(Ah,{children:v.jsx(It,{type:"icon",title:`${h(i)} — ${h(`${t}-style.${y.value}`)}`,"data-testid":`style.${t}.${y.value}`,onClick:()=>f(c,y.value),children:v.jsx(rr,{icon:y.icon})})},y.value))})})]})]})]})}const G5e=A.memo(K5e);function V5e({id:r,label:e,uiType:t,stylePanelType:n,style:i,items:o,type:s,value:a,onValueChange:c}){const l=ar(),d=he(),f=A.useMemo(()=>{var y;return(y=o.find(x=>a.type==="shared"&&x.value===a.value))==null?void 0:y.icon},[o,a]),h=l(`style-panel.${n}`),g=a.type==="mixed"?l("style-panel.mixed"):h+" — "+l(`${t}-style.${a.value}`),m=e?l(e):"";return v.jsxs(tu,{id:`style panel ${r}`,children:[v.jsx(ru,{children:v.jsxs(It,{type:s,"data-testid":`style.${t}`,title:g,children:[m&&v.jsx(Sn,{children:m}),v.jsx(rr,{icon:f??"mixed"})]})}),v.jsx(nu,{side:"left",align:"center",alignOffset:0,children:v.jsx("div",{className:"tlui-buttons__grid",children:o.map(y=>v.jsx(Ah,{children:v.jsx(It,{type:"icon","data-testid":`style.${t}.${y.value}`,title:h+" — "+l(`${t}-style.${y.value}`),onClick:()=>{d.markHistoryStoppingPoint("select style dropdown item"),c(i,y.value)},children:v.jsx(rr,{icon:y.icon})})},y.value))})})]})}const jR=A.memo(V5e);function Y5e({styles:r}){const e=lp();if(!r)return null;const t=r.get(Ts),n=r.get(Zv),i=r.get(Xv),o=r.get(tm),s=r.get(ga),a=t===void 0,c=n===void 0&&i===void 0,l=o===void 0,d=s===void 0,f=uc({isDarkMode:e});return v.jsxs(v.Fragment,{children:[v.jsx(X5e,{theme:f,styles:r}),!d&&v.jsx(Z5e,{theme:f,styles:r}),!(a&&c&&l)&&v.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[v.jsx(Q5e,{styles:r}),v.jsx(eBe,{styles:r}),v.jsx(J5e,{styles:r})]})]})}function yp(){const r=he(),e=ai();return lr.useMemo(()=>function(n,i){r.run(()=>{r.isIn("select")&&r.setStyleForSelectedShapes(n,i),r.setStyleForNextShapes(n,i),r.updateInstanceState({isChangingStyle:!0})}),e("set-style",{source:"style-panel",id:n.id,value:i})},[r,e])}function X5e({styles:r,theme:e}){const t=ar(),n=he(),i=A.useCallback(f=>n.markHistoryStoppingPoint(f),[n]),o=yp(),s=r.get(Lo),a=r.get(Zl),c=r.get(Xl),l=r.get(va),d=a!==void 0||c!==void 0||l!==void 0;return v.jsxs(v.Fragment,{children:[v.jsxs("div",{tabIndex:-1,className:"tlui-style-panel__section__common","aria-label":"style panel styles","data-testid":"style.panel",children:[s===void 0?null:v.jsx(Ul,{title:t("style-panel.color"),uiType:"color",style:Lo,items:is.color,value:s,onValueChange:o,theme:e,onHistoryMark:i}),v.jsx(tBe,{})]}),d&&v.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[a===void 0?null:v.jsx(Ul,{title:t("style-panel.fill"),uiType:"fill",style:Zl,items:is.fill,value:a,onValueChange:o,theme:e,onHistoryMark:i}),c===void 0?null:v.jsx(Ul,{title:t("style-panel.dash"),uiType:"dash",style:Xl,items:is.dash,value:c,onValueChange:o,theme:e,onHistoryMark:i}),l===void 0?null:v.jsx(Ul,{title:t("style-panel.size"),uiType:"size",style:va,items:is.size,value:l,onValueChange:(f,h)=>{o(f,h);const g=n.getSelectedShapeIds();g.length>0&&Fr(n,g)},theme:e,onHistoryMark:i})]})]})}function Z5e({theme:r,styles:e}){const t=ar(),n=yp(),i=he(),o=A.useCallback(d=>i.markHistoryStoppingPoint(d),[i]),s=e.get(ga),a=e.get(AP),c=e.get(Jv),l=e.get(em);return s===void 0&&c===void 0?null:v.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel text",children:[s===void 0?null:v.jsx(Ul,{title:t("style-panel.font"),uiType:"font",style:ga,items:is.font,value:s,onValueChange:n,theme:r,onHistoryMark:o}),a===void 0?null:v.jsxs("div",{className:"tlui-style-panel__row",children:[v.jsx(Ul,{title:t("style-panel.align"),uiType:"align",style:AP,items:is.textAlign,value:a,onValueChange:n,theme:r,onHistoryMark:o}),v.jsx("div",{className:"tlui-style-panel__row__extra-button",children:v.jsx(It,{type:"icon",title:t("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:v.jsx(rr,{icon:"vertical-align-middle"})})})]}),c===void 0?null:v.jsxs("div",{className:"tlui-style-panel__row",children:[v.jsx(Ul,{title:t("style-panel.label-align"),uiType:"align",style:Jv,items:is.horizontalAlign,value:c,onValueChange:n,theme:r,onHistoryMark:o}),v.jsx("div",{className:"tlui-style-panel__row__extra-button",children:l===void 0?v.jsx(It,{type:"icon",title:t("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:v.jsx(rr,{icon:"vertical-align-middle"})}):v.jsx(jR,{type:"icon",id:"geo-vertical-alignment",uiType:"verticalAlign",stylePanelType:"vertical-align",style:em,items:is.verticalAlign,value:l,onValueChange:n})})]})]})}function Q5e({styles:r}){const e=yp(),t=r.get(Ts);return t===void 0?null:v.jsx(jR,{id:"geo",type:"menu",label:"style-panel.geo",uiType:"geo",stylePanelType:"geo",style:Ts,items:is.geo,value:t,onValueChange:e})}function J5e({styles:r}){const e=yp(),t=r.get(tm);return t===void 0?null:v.jsx(jR,{id:"spline",type:"menu",label:"style-panel.spline",uiType:"spline",stylePanelType:"spline",style:tm,items:is.spline,value:t,onValueChange:e})}function eBe({styles:r}){const e=yp(),t=r.get(Zv),n=r.get(Xv);return!t||!n?null:v.jsx(G5e,{label:"style-panel.arrowheads",uiTypeA:"arrowheadStart",styleA:Xv,itemsA:is.arrowheadStart,valueA:n,uiTypeB:"arrowheadEnd",styleB:Zv,itemsB:is.arrowheadEnd,valueB:t,onValueChange:e,labelA:"style-panel.arrowhead-start",labelB:"style-panel.arrowhead-end"})}const Vf=[.1,.25,.5,.75,1];function tBe(){const r=he(),e=A.useCallback(a=>r.markHistoryStoppingPoint(a),[r]),t=ye("opacity",()=>r.getSharedOpacity(),[r]),n=ai(),i=ar(),o=lr.useCallback(a=>{const c=Vf[a];r.run(()=>{r.isIn("select")&&r.setOpacityForSelectedShapes(c),r.setOpacityForNextShapes(c),r.updateInstanceState({isChangingStyle:!0})}),n("set-style",{source:"style-panel",id:"opacity",value:a})},[r,n]);if(t===void 0)return null;const s=t.type==="mixed"?-1:Vf.indexOf(Rge(Vf,a=>Math.abs(a-t.value)));return v.jsx(W5e,{"data-testid":"style.opacity",value:s>=0?s:Vf.length-1,label:t.type==="mixed"?"style-panel.mixed":`opacity-style.${t.value}`,onValueChange:o,steps:Vf.length-1,title:i("style-panel.opacity"),onHistoryMark:e})}const rBe=A.memo(function({isMobile:e,children:t}){const n=he(),i=A.useRef(null);vl(i);const o=ghe(),s=A.useCallback(()=>{e||n.updateInstanceState({isChangingStyle:!1})},[n,e]),a=t??v.jsx(Y5e,{styles:o});return v.jsx("div",{ref:i,className:bt("tlui-style-panel",{"tlui-style-panel__wrapper":!e}),"data-ismobile":e,onPointerLeave:s,children:a})});function nBe(){const r=he(),e=ar(),t=ghe(),n=t==null?void 0:t.get(Lo),i=uc({isDarkMode:r.user.getIsDarkMode()}),o=((n==null?void 0:n.type)==="shared"?i[n.value]:i.black).solid,s=ye("disable style panel",()=>r.isInAny("hand","zoom","eraser","laser"),[r]),a=A.useCallback(l=>{l||r.updateInstanceState({isChangingStyle:!1})},[r]),{StylePanel:c}=xl();return c?v.jsxs(AR,{id:"mobile style menu",onOpenChange:a,children:[v.jsx(RR,{children:v.jsx(It,{type:"tool","data-testid":"mobile-styles.button",style:{color:s?"var(--color-muted-1)":o},title:e("style-panel.title"),disabled:s,children:v.jsx(rr,{icon:s?"blob":(n==null?void 0:n.type)==="mixed"?"mixed":"blob"})})}),v.jsx(kR,{side:"top",align:"end",children:c&&v.jsx(c,{isMobile:!0})})]}):null}function iBe(){return v.jsxs(v.Fragment,{children:[v.jsx(sBe,{}),v.jsx(aBe,{}),v.jsx(cBe,{}),v.jsx(lBe,{}),v.jsx(uBe,{}),v.jsx(dBe,{}),v.jsx(fBe,{}),v.jsx(hBe,{}),v.jsx(pBe,{}),v.jsx(gBe,{}),v.jsx(mBe,{}),v.jsx(vBe,{}),v.jsx(xBe,{}),v.jsx(bBe,{}),v.jsx(yBe,{}),v.jsx(wBe,{}),v.jsx(_Be,{}),v.jsx(SBe,{}),v.jsx(EBe,{}),v.jsx(IBe,{}),v.jsx(PBe,{}),v.jsx(CBe,{}),v.jsx(TBe,{}),v.jsx(ABe,{}),v.jsx(RBe,{}),v.jsx(kBe,{}),v.jsx(MBe,{}),v.jsx(OBe,{})]})}function oBe(r){var n;const e=he(),t=(n=r.meta)==null?void 0:n.geo;return ye("is tool selected",()=>{const i=e.getCurrentToolId(),o=e.getSharedStyles().getAsKnownValue(Ts);return t?i==="geo"&&o===t:i===r.id},[e,r.id,t])}function Mr({tool:r}){const e=cR(),t=oBe(e[r]);return v.jsx(so,{toolId:r,isSelected:t})}function sBe(){return v.jsx(Mr,{tool:"select"})}function aBe(){return v.jsx(Mr,{tool:"hand"})}function cBe(){return v.jsx(Mr,{tool:"draw"})}function lBe(){return v.jsx(Mr,{tool:"eraser"})}function uBe(){return v.jsx(Mr,{tool:"arrow"})}function dBe(){return v.jsx(Mr,{tool:"text"})}function fBe(){return v.jsx(Mr,{tool:"note"})}function hBe(){return v.jsx(so,{toolId:"asset"})}function pBe(){return v.jsx(Mr,{tool:"rectangle"})}function gBe(){return v.jsx(Mr,{tool:"ellipse"})}function vBe(){return v.jsx(Mr,{tool:"diamond"})}function mBe(){return v.jsx(Mr,{tool:"triangle"})}function yBe(){return v.jsx(Mr,{tool:"rhombus"})}function SBe(){return v.jsx(Mr,{tool:"heart"})}function xBe(){return v.jsx(Mr,{tool:"hexagon"})}function _Be(){return v.jsx(Mr,{tool:"cloud"})}function wBe(){return v.jsx(Mr,{tool:"star"})}function bBe(){return v.jsx(Mr,{tool:"oval"})}function EBe(){return v.jsx(Mr,{tool:"x-box"})}function IBe(){return v.jsx(Mr,{tool:"check-box"})}function PBe(){return v.jsx(Mr,{tool:"arrow-left"})}function CBe(){return v.jsx(Mr,{tool:"arrow-up"})}function TBe(){return v.jsx(Mr,{tool:"arrow-down"})}function ABe(){return v.jsx(Mr,{tool:"arrow-right"})}function RBe(){return v.jsx(Mr,{tool:"line"})}function kBe(){return v.jsx(Mr,{tool:"highlight"})}function OBe(){return v.jsx(Mr,{tool:"frame"})}function MBe(){return v.jsx(Mr,{tool:"laser"})}const KI=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function GI(r,e,t,n){r.addEventListener?r.addEventListener(e,t,n):r.attachEvent&&r.attachEvent("on".concat(e),t)}function Yf(r,e,t,n){r.removeEventListener?r.removeEventListener(e,t,n):r.detachEvent&&r.detachEvent("on".concat(e),t)}function Rhe(r,e){const t=e.slice(0,e.length-1);for(let n=0;n<t.length;n++)t[n]=r[t[n].toLowerCase()];return t}function khe(r){typeof r!="string"&&(r=""),r=r.replace(/\s/g,"");const e=r.split(",");let t=e.lastIndexOf("");for(;t>=0;)e[t-1]+=",",e.splice(t,1),t=e.lastIndexOf("");return e}function jBe(r,e){const t=r.length>=e.length?r:e,n=r.length>=e.length?e:r;let i=!0;for(let o=0;o<t.length;o++)n.indexOf(t[o])===-1&&(i=!1);return i}const kh={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":KI?173:189,"=":KI?61:187,";":KI?59:186,"'":222,"[":219,"]":221,"\\":220},_a={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},Lv={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Xn={16:!1,18:!1,17:!1,91:!1},on={};for(let r=1;r<20;r++)kh["f".concat(r)]=111+r;let Qr=[],hh=null,Ohe="all";const Ya=new Map,Sp=r=>kh[r.toLowerCase()]||_a[r.toLowerCase()]||r.toUpperCase().charCodeAt(0),DBe=r=>Object.keys(kh).find(e=>kh[e]===r),LBe=r=>Object.keys(_a).find(e=>_a[e]===r);function Mhe(r){Ohe=r||"all"}function Oh(){return Ohe||"all"}function FBe(){return Qr.slice(0)}function NBe(){return Qr.map(r=>DBe(r)||LBe(r)||String.fromCharCode(r))}function $Be(){const r=[];return Object.keys(on).forEach(e=>{on[e].forEach(t=>{let{key:n,scope:i,mods:o,shortcut:s}=t;r.push({scope:i,shortcut:s,mods:o,keys:n.split("+").map(a=>Sp(a))})})}),r}function qBe(r){const e=r.target||r.srcElement,{tagName:t}=e;let n=!0;const i=t==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(e.type);return(e.isContentEditable||(i||t==="TEXTAREA"||t==="SELECT")&&!e.readOnly)&&(n=!1),n}function BBe(r){return typeof r=="string"&&(r=Sp(r)),Qr.indexOf(r)!==-1}function UBe(r,e){let t,n;r||(r=Oh());for(const i in on)if(Object.prototype.hasOwnProperty.call(on,i))for(t=on[i],n=0;n<t.length;)t[n].scope===r?t.splice(n,1).forEach(s=>{let{element:a}=s;return DR(a)}):n++;Oh()===r&&Mhe(e||"all")}function zBe(r){let e=r.keyCode||r.which||r.charCode;const t=Qr.indexOf(e);if(t>=0&&Qr.splice(t,1),r.key&&r.key.toLowerCase()==="meta"&&Qr.splice(0,Qr.length),(e===93||e===224)&&(e=91),e in Xn){Xn[e]=!1;for(const n in _a)_a[n]===e&&(os[n]=!1)}}function jhe(r){if(typeof r>"u")Object.keys(on).forEach(i=>{Array.isArray(on[i])&&on[i].forEach(o=>tv(o)),delete on[i]}),DR(null);else if(Array.isArray(r))r.forEach(i=>{i.key&&tv(i)});else if(typeof r=="object")r.key&&tv(r);else if(typeof r=="string"){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];let[i,o]=t;typeof i=="function"&&(o=i,i=""),tv({key:r,scope:i,method:o,splitKey:"+"})}}const tv=r=>{let{key:e,scope:t,method:n,splitKey:i="+"}=r;khe(e).forEach(s=>{const a=s.split(i),c=a.length,l=a[c-1],d=l==="*"?"*":Sp(l);if(!on[d])return;t||(t=Oh());const f=c>1?Rhe(_a,a):[],h=[];on[d]=on[d].filter(g=>{const y=(n?g.method===n:!0)&&g.scope===t&&jBe(g.mods,f);return y&&h.push(g.element),!y}),h.forEach(g=>DR(g))})};function TJ(r,e,t,n){if(e.element!==n)return;let i;if(e.scope===t||e.scope==="all"){i=e.mods.length>0;for(const o in Xn)Object.prototype.hasOwnProperty.call(Xn,o)&&(!Xn[o]&&e.mods.indexOf(+o)>-1||Xn[o]&&e.mods.indexOf(+o)===-1)&&(i=!1);(e.mods.length===0&&!Xn[16]&&!Xn[18]&&!Xn[17]&&!Xn[91]||i||e.shortcut==="*")&&(e.keys=[],e.keys=e.keys.concat(Qr),e.method(r,e)===!1&&(r.preventDefault?r.preventDefault():r.returnValue=!1,r.stopPropagation&&r.stopPropagation(),r.cancelBubble&&(r.cancelBubble=!0)))}}function AJ(r,e){const t=on["*"];let n=r.keyCode||r.which||r.charCode;if(!os.filter.call(this,r))return;if((n===93||n===224)&&(n=91),Qr.indexOf(n)===-1&&n!==229&&Qr.push(n),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{const c=Lv[a];r[a]&&Qr.indexOf(c)===-1?Qr.push(c):!r[a]&&Qr.indexOf(c)>-1?Qr.splice(Qr.indexOf(c),1):a==="metaKey"&&r[a]&&(Qr=Qr.filter(l=>l in Lv||l===n))}),n in Xn){Xn[n]=!0;for(const a in _a)_a[a]===n&&(os[a]=!0);if(!t)return}for(const a in Xn)Object.prototype.hasOwnProperty.call(Xn,a)&&(Xn[a]=r[Lv[a]]);r.getModifierState&&!(r.altKey&&!r.ctrlKey)&&r.getModifierState("AltGraph")&&(Qr.indexOf(17)===-1&&Qr.push(17),Qr.indexOf(18)===-1&&Qr.push(18),Xn[17]=!0,Xn[18]=!0);const i=Oh();if(t)for(let a=0;a<t.length;a++)t[a].scope===i&&(r.type==="keydown"&&t[a].keydown||r.type==="keyup"&&t[a].keyup)&&TJ(r,t[a],i,e);if(!(n in on))return;const o=on[n],s=o.length;for(let a=0;a<s;a++)if((r.type==="keydown"&&o[a].keydown||r.type==="keyup"&&o[a].keyup)&&o[a].key){const c=o[a],{splitKey:l}=c,d=c.key.split(l),f=[];for(let h=0;h<d.length;h++)f.push(Sp(d[h]));f.sort().join("")===Qr.sort().join("")&&TJ(r,c,i,e)}}function os(r,e,t){Qr=[];const n=khe(r);let i=[],o="all",s=document,a=0,c=!1,l=!0,d="+",f=!1,h=!1;for(t===void 0&&typeof e=="function"&&(t=e),Object.prototype.toString.call(e)==="[object Object]"&&(e.scope&&(o=e.scope),e.element&&(s=e.element),e.keyup&&(c=e.keyup),e.keydown!==void 0&&(l=e.keydown),e.capture!==void 0&&(f=e.capture),typeof e.splitKey=="string"&&(d=e.splitKey),e.single===!0&&(h=!0)),typeof e=="string"&&(o=e),h&&jhe(r,o);a<n.length;a++)r=n[a].split(d),i=[],r.length>1&&(i=Rhe(_a,r)),r=r[r.length-1],r=r==="*"?"*":Sp(r),r in on||(on[r]=[]),on[r].push({keyup:c,keydown:l,scope:o,mods:i,shortcut:n[a],method:t,key:n[a],splitKey:d,element:s});if(typeof s<"u"&&window){if(!Ya.has(s)){const g=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return AJ(y,s)},m=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;AJ(y,s),zBe(y)};Ya.set(s,{keydownListener:g,keyupListenr:m,capture:f}),GI(s,"keydown",g,f),GI(s,"keyup",m,f)}if(!hh){const g=()=>{Qr=[]};hh={listener:g,capture:f},GI(window,"focus",g,f)}}}function HBe(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(on).forEach(t=>{on[t].filter(i=>i.scope===e&&i.shortcut===r).forEach(i=>{i&&i.method&&i.method()})})}function DR(r){const e=Object.values(on).flat();if(e.findIndex(n=>{let{element:i}=n;return i===r})<0){const{keydownListener:n,keyupListenr:i,capture:o}=Ya.get(r)||{};n&&i&&(Yf(r,"keyup",i,o),Yf(r,"keydown",n,o),Ya.delete(r))}if((e.length<=0||Ya.size<=0)&&(Object.keys(Ya).forEach(i=>{const{keydownListener:o,keyupListenr:s,capture:a}=Ya.get(i)||{};o&&s&&(Yf(i,"keyup",s,a),Yf(i,"keydown",o,a),Ya.delete(i))}),Ya.clear(),Object.keys(on).forEach(i=>delete on[i]),hh)){const{listener:i,capture:o}=hh;Yf(window,"focus",i,o),hh=null}}const VI={getPressedKeyString:NBe,setScope:Mhe,getScope:Oh,deleteScope:UBe,getPressedKeyCodes:FBe,getAllKeyCodes:$Be,isPressed:BBe,filter:qBe,trigger:HBe,unbind:jhe,keyMap:kh,modifier:_a,modifierMap:Lv};for(const r in VI)Object.prototype.hasOwnProperty.call(VI,r)&&(os[r]=VI[r]);if(typeof window<"u"){const r=window.hotkeys;os.noConflict=e=>(e&&window.hotkeys===os&&(window.hotkeys=r),os),window.hotkeys=os}const RJ=["copy","cut","paste","asset"];function WBe(){const r=he(),e=Wo(),t=bu(),n=cR(),i=ye("is focused",()=>r.getInstanceState().isFocused,[r]);A.useEffect(()=>{if(!i)return;const o=new Array,s=(c,l)=>{os(c,{element:document.body},l),o.push(()=>{os.unbind(c,l)})},a=(c,l)=>{os(c,{element:document.body,keyup:!0,keydown:!1},l),o.push(()=>{os.unbind(c,l)})};for(const c of Object.values(t))c.kbd&&(e&&!c.readonlyOk||RJ.includes(c.id)||s(kJ(c.kbd),l=>{oh(r)||(Qt(l),c.onSelect("kbd"))}));for(const c of Object.values(n))!c.kbd||!c.readonlyOk&&r.getIsReadonly()||RJ.includes(c.id)||s(kJ(c.kbd),l=>{oh(r)||(Qt(l),c.onSelect("kbd"))});return s(",",c=>{if(oh(r)||r.inputs.keys.has("Comma"))return;Qt(c),r.focus(),r.inputs.keys.add("Comma");const{x:l,y:d,z:f}=r.inputs.currentPagePoint,h=r.pageToScreen({x:l,y:d}),g={type:"pointer",name:"pointer_down",point:{x:h.x,y:h.y,z:f},shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.metaKey||c.ctrlKey,metaKey:c.metaKey,accelKey:wi(c),pointerId:0,button:0,isPen:r.getInstanceState().isPenMode,target:"canvas"};r.dispatch(g)}),a(",",c=>{if(oh(r)||!r.inputs.keys.has("Comma"))return;r.inputs.keys.delete("Comma");const{x:l,y:d,z:f}=r.inputs.currentScreenPoint,h={type:"pointer",name:"pointer_up",point:{x:l,y:d,z:f},shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.metaKey||c.ctrlKey,metaKey:c.metaKey,accelKey:wi(c),pointerId:0,button:0,isPen:r.getInstanceState().isPenMode,target:"canvas"};r.dispatch(h)}),()=>{o.forEach(c=>c())}},[t,n,e,r,i])}function kJ(r){return KBe(r).map(e=>{let t="";const n=e.split("");return n.length===1?t=n[0]:n[0]==="!"?t=`shift+${n[1]}`:n[0]==="?"?n.length===3&&n[1]==="!"?t=`alt+shift+${n[2]}`:t=`alt+${n[1]}`:n[0]==="$"?n[1]==="!"?t=`cmd+shift+${n[2]},ctrl+shift+${n[2]}`:n[1]==="?"?t=`cmd+⌥+${n[2]},ctrl+alt+${n[2]}`:t=`cmd+${n[1]},ctrl+${n[1]}`:t=e,t}).join(",")}function KBe(r){typeof r!="string"&&(r=""),r=r.replace(/\s/g,"");const e=r.split(",");let t=e.lastIndexOf("");for(;t>=0;)e[t-1]+=",",e.splice(t,1),t=e.lastIndexOf("");return e}function oh(r){return r.menus.hasAnyOpenMenus()||r.getEditingShapeId()!==null||r.getCrashingError()}const GBe=A.createContext(!1),VBe={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,0:9};function YBe({children:r}){const e=he(),t=Ld(),n=Gi(),i=ar(),o=A.useRef([]),s=Math.min(8,5+n),[a,c]=A.useState(0),l=A.useRef(null),[d,f]=A.useState(null),h=A.useMemo(()=>{const m=d?`:not([data-value="${d}"])`:"";return`
406
- #${t}_main > *:nth-child(n + ${s+(d?1:2)})${m} {
407
- display: none;
408
- }
409
- #${t}_more > *:nth-child(-n + ${s}) {
410
- display: none;
411
- }
412
- `},[d,t,s]),g=Iy(()=>{var _;if(!l.current)return;const m=Array.from(l.current.children);c(m.length),m.findIndex(w=>w.getAttribute("data-value")===d)<=s&&f(null);const x=Array.from(l.current.children).findIndex(w=>w.getAttribute("aria-checked")==="true");x!==-1&&(x>=s&&f(m[x].getAttribute("data-value")),o.current=Array.from(((_=l.current)==null?void 0:_.children)??[]).filter(w=>!(w instanceof HTMLElement)||w.tagName.toLowerCase()!=="button"?!1:!!(w.offsetWidth||w.offsetHeight)))});return A.useLayoutEffect(()=>{g()}),A.useLayoutEffect(()=>{if(!l.current)return;const m=new MutationObserver(g);return m.observe(l.current,{childList:!0,subtree:!0,attributeFilter:["data-value","aria-checked"]}),()=>{m.disconnect()}},[g]),A.useEffect(()=>{if(!e.options.enableToolbarKeyboardShortcuts)return;function m(y){var _;if(oh(e)||Nte()||y.ctrlKey||y.metaKey||y.altKey||y.shiftKey)return;const x=VBe[y.key];typeof x=="number"&&(Qt(y),(_=o.current[x])==null||_.click())}return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m)}},[e]),v.jsxs(v.Fragment,{children:[v.jsx("style",{children:h}),v.jsxs("div",{className:bt("tlui-toolbar__tools",{"tlui-toolbar__tools__mobile":n<fn.TABLET_SM}),role:"radiogroup",children:[v.jsx("div",{id:`${t}_main`,ref:l,className:"tlui-toolbar__tools__list",children:v.jsx(ls,{type:"toolbar",sourceId:"toolbar",children:r})}),a>s+1&&v.jsx(GBe.Provider,{value:!0,children:v.jsxs(tu,{id:"toolbar overflow",modal:!1,children:[v.jsx(ru,{children:v.jsx(It,{title:i("tool-panel.more"),type:"tool",className:"tlui-toolbar__overflow","data-testid":"tools.more-button",children:v.jsx(rr,{icon:"chevron-up"})})}),v.jsx(nu,{side:"top",align:"center",children:v.jsx("div",{className:"tlui-buttons__grid","data-testid":"tools.more-content",id:`${t}_more`,children:v.jsx(ls,{type:"toolbar-overflow",sourceId:"toolbar",children:r})})})]})})]})]})}function XBe({activeToolId:r}){const e=he(),t=Gi(),n=ar(),i=ye("is tool locked",()=>e.getInstanceState().isToolLocked,[e]),o=ye("current tool",()=>e.getCurrentTool(),[e]);return!r||!o.isLockable?null:v.jsx(It,{type:"normal",title:n("action.toggle-tool-lock"),"data-testid":"tool-lock",className:bt("tlui-toolbar__lock-button",{"tlui-toolbar__lock-button__mobile":t<fn.TABLET_SM}),onClick:()=>e.updateInstanceState({isToolLocked:!i}),children:v.jsx(rr,{icon:i?"lock":"unlock",small:!0})})}const ZBe=A.memo(function({children:e}){const t=he(),n=Gi(),i=Wo(),o=ye("current tool id",()=>t.getCurrentToolId(),[t]),s=A.useRef(null);vl(s);const{ActionsMenu:a,QuickActions:c}=xl(),l=t.options.actionShortcutsLocation==="menu"?!1:t.options.actionShortcutsLocation==="toolbar"?!0:n<fn.TABLET;return v.jsx("div",{ref:s,className:"tlui-toolbar",children:v.jsxs("div",{className:"tlui-toolbar__inner",children:[v.jsxs("div",{className:"tlui-toolbar__left",children:[!i&&v.jsxs("div",{className:"tlui-toolbar__extras",children:[l&&v.jsxs("div",{className:"tlui-toolbar__extras__controls tlui-buttons__horizontal",children:[c&&v.jsx(c,{}),a&&v.jsx(a,{})]}),v.jsx(XBe,{activeToolId:o})]}),v.jsx(YBe,{children:e??v.jsx(iBe,{})})]}),n<fn.TABLET_SM&&!i&&v.jsx("div",{className:"tlui-toolbar__tools",children:v.jsx(nBe,{})})]})})});function QBe(){const r=ar();return v.jsxs("div",{className:bt("tlui-offline-indicator"),children:[r("status.offline"),v.jsx(Sa,{"aria-label":"offline",icon:"status-offline",small:!0})]})}function JBe({maxWidth:r=420,ignoreRightWidth:e=0,stylePanelWidth:t=148,marginBetweenZones:n=12,squeezeAmount:i=52,children:o}){const s=A.useRef(null),a=Gi(),c=A.useCallback(()=>{const l=s.current;if(!l)return;const d=l.parentElement.parentElement,f=d.querySelector(".tlui-layout__top__left"),h=d.querySelector(".tlui-layout__top__right"),g=d.offsetWidth,m=f.offsetWidth,y=h.offsetWidth,x=l.offsetWidth-e;let _=(g-x)/2;g%2!==0&&(_-=.5);const w=m+n,I=l.offsetLeft,b=Math.min(g-y-m-2*n,r),P=Math.max(_,w)-I;h.offsetWidth>t&&a<=6?l.style.setProperty("max-width",b-i+"px"):l.style.setProperty("max-width",b+"px"),l.style.setProperty("transform",`translate(${P}px, 0px)`)},[a,e,n,r,i,t]);return A.useLayoutEffect(()=>{const l=s.current;if(!l)return;const d=l.parentElement.parentElement,f=d.querySelector(".tlui-layout__top__left"),h=d.querySelector(".tlui-layout__top__right"),g=new ResizeObserver(c);return g.observe(f),g.observe(h),g.observe(d),g.observe(l),c(),()=>{g.disconnect()}},[c]),A.useLayoutEffect(()=>{c()}),v.jsx("div",{ref:s,className:"tlui-top-panel__container",children:o})}function e4e(){const r=bDe()==="offline";return v.jsx(JBe,{children:r&&v.jsx(QBe,{})})}function t4e(){return v.jsxs(v.Fragment,{children:[v.jsx(Ce,{actionId:"zoom-in",noClose:!0}),v.jsx(Ce,{actionId:"zoom-out",noClose:!0}),v.jsx(Bfe,{}),v.jsx(Ufe,{}),v.jsx(zfe,{})]})}const r4e=A.memo(function({children:e}){const t=Ln(),[n,i]=vc("zoom menu"),o=e??v.jsx(t4e,{});return v.jsxs(WA,{dir:"ltr",open:n,onOpenChange:i,modal:!1,children:[v.jsx(KA,{asChild:!0,dir:"ltr",children:v.jsx(n4e,{})}),v.jsx(Ky,{container:t,children:v.jsx(GA,{className:"tlui-menu",side:"top",align:"start",alignOffset:0,sideOffset:8,collisionPadding:4,children:v.jsx(ls,{type:"menu",sourceId:"zoom-menu",children:o})})})]})}),n4e=A.forwardRef(function(e,t){const n=he(),i=Gi(),o=ye("zoom",()=>n.getZoomLevel(),[n]),s=ar(),a=A.useCallback(()=>{n.resetZoom(n.getViewportScreenCenter(),{animation:{duration:n.options.animationMediumMs}})},[n]);return v.jsx(It,{ref:t,...e,type:"icon",title:`${s("navigation-zone.zoom")}`,"data-testid":"minimap.zoom-menu-button",className:i<fn.TABLET_SM?"tlui-zoom-menu__button":"tlui-zoom-menu__button__pct",onDoubleClick:a,children:i<fn.MOBILE?null:v.jsxs("span",{style:{flexGrow:0,textAlign:"center"},children:[Math.floor(o*100),"%"]})})}),Dhe=A.createContext(null);function i4e({overrides:r={},children:e}){const t=Nd(r),n=Zy();return v.jsx(Dhe.Provider,{value:A.useMemo(()=>({ContextMenu:yqe,ActionsMenu:K$e,HelpMenu:null,ZoomMenu:r4e,MainMenu:Qqe,Minimap:c5e,StylePanel:rBe,PageMenu:f5e,NavigationPanel:u5e,Toolbar:ZBe,KeyboardShortcutsDialog:Bqe,QuickActions:v5e,HelperButtons:$qe,DebugPanel:Rqe,DebugMenu:Aqe,MenuPanel:jqe,SharePanel:n?b5e:null,CursorChatBubble:n?_qe:null,TopPanel:n?e4e:null,Dialogs:FLe,Toasts:BLe,...t}),[t,n]),children:e})}function xl(){const r=A.useContext(Dhe);if(!r)throw new Error("useTldrawUiComponents must be used within a TldrawUiComponentsProvider");return r}const o4e=ii(function({overrides:e,components:t,assetUrls:n,onUiEvent:i,forceMobile:o,mediaMimeTypes:s,children:a}){const c=ll();return v.jsx(que.Provider,{value:s,children:v.jsx(Yje,{assetUrls:x$e(n),children:v.jsx(Qje,{overrides:bLe(e),locale:(c==null?void 0:c.user.getLocale())??ia.locale,children:v.jsx(B2e,{onEvent:i,children:v.jsx(VDe,{children:v.jsx(IDe,{context:"tla",children:v.jsx(EDe,{forceMobile:o,children:v.jsx(i4e,{overrides:t,children:c?v.jsx(s4e,{overrides:e,children:a}):a})})})})})})})})});function s4e({overrides:r,children:e}){const t=ELe(r);return v.jsx(PLe,{overrides:t.actions,children:v.jsx(ULe,{overrides:t.tools,children:e})})}function a4e(){const r=he(),{addToast:e}=gc();A.useEffect(()=>{function t({name:n,count:i}){e({title:"Maximum Shapes Reached",description:`You've reached the maximum number of shapes allowed on ${n} (${i}). Please delete some shapes or move to a different page to continue.`,severity:"warning"})}return r.addListener("max-shapes",t),()=>{r.removeListener("max-shapes",t)}},[r,e])}const c4e=lr.memo(function({renderDebugMenuItems:e,children:t,hideUi:n,components:i,...o}){return v.jsx(o4e,{...o,components:i,children:v.jsx(l4e,{hideUi:n,renderDebugMenuItems:e,children:t})})}),l4e=lr.memo(function({children:e,hideUi:t,...n}){return v.jsxs(v.Fragment,{children:[e,t?null:v.jsx(u4e,{...n})]})}),u4e=lr.memo(function(){const e=he(),t=ar(),n=Gi(),i=Wo(),o=ye("focus",()=>e.getInstanceState().isFocusMode,[e]),s=ye("debug",()=>e.getInstanceState().isDebugMode,[e]),{SharePanel:a,TopPanel:c,MenuPanel:l,StylePanel:d,Toolbar:f,HelpMenu:h,NavigationPanel:g,HelperButtons:m,DebugPanel:y,CursorChatBubble:x,Toasts:_,Dialogs:w}=xl();WBe(),fLe(),a4e();const{"toggle-focus-mode":I}=bu();return v.jsxs("div",{className:bt("tlui-layout",{"tlui-layout__mobile":n<fn.TABLET_SM}),"data-breakpoint":n,children:[o?v.jsx("div",{className:"tlui-layout__top",children:v.jsx(It,{type:"icon",className:"tlui-focus-button",title:t("focus-mode.toggle-focus-mode"),onClick:()=>I.onSelect("menu"),children:v.jsx(rr,{icon:"dot"})})}):v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"tlui-layout__top",children:[v.jsxs("div",{className:"tlui-layout__top__left",children:[l&&v.jsx(l,{}),m&&v.jsx(m,{})]}),v.jsx("div",{className:"tlui-layout__top__center",children:c&&v.jsx(c,{})}),v.jsxs("div",{className:"tlui-layout__top__right",children:[a&&v.jsx(a,{}),d&&n>=fn.TABLET_SM&&!i&&v.jsx(d,{})]})]}),v.jsxs("div",{className:"tlui-layout__bottom",children:[v.jsxs("div",{className:"tlui-layout__bottom__main",children:[g&&v.jsx(g,{}),f&&v.jsx(f,{}),h&&v.jsx(h,{})]}),s&&y&&v.jsx(y,{})]})]}),_&&v.jsx(_,{}),w&&v.jsx(w,{}),v.jsx(m$e,{}),x&&v.jsx(x,{})]})});async function d4e(r,e){const{url:t,style:n="normal",weight:i="500",display:o,featureSettings:s,stretch:a,unicodeRange:c,variant:l,format:d}=e,f={style:n,weight:i,display:o,featureSettings:s,stretch:a,unicodeRange:c,variant:l},h=new FontFace(r,`url(${t})`,f);return await h.load(),document.fonts.add(h),h.$$_url=t,h.$$_fontface=`
413
- @font-face {
414
- font-family: ${h.family};
415
- font-stretch: ${h.stretch};
416
- font-weight: ${h.weight};
417
- font-style: ${h.style};
418
- src: url("${t}") format("${d}")
419
- }`,h}const rv=(r,e)=>{const[t,n]=A.useState(2);return A.useEffect(()=>{let i=!1;return n(2),d4e(r,e).then(()=>{i||n(0)}).catch(o=>{i||(console.error(o),n(1))}),()=>{i=!0}},[r,e]),t};function f4e(r){return{draw:{url:r.fonts.draw,format:r.fonts.draw.split(".").pop()},serif:{url:r.fonts.serif,format:r.fonts.serif.split(".").pop()},sansSerif:{url:r.fonts.sansSerif,format:r.fonts.sansSerif.split(".").pop()},monospace:{url:r.fonts.monospace,format:r.fonts.monospace.split(".").pop()}}}function Lhe(r){const e=A.useMemo(()=>f4e(r),[r]),t=[rv("tldraw_draw",e.draw),rv("tldraw_serif",e.serif),rv("tldraw_sans",e.sansSerif),rv("tldraw_mono",e.monospace)];return{error:t.some(n=>n===1),done:!t.some(n=>n===2)}}const h4e=[...v$e,...iNe];function p4e(r){const{children:e,maxImageDimension:t,maxAssetSize:n,acceptedImageMimeTypes:i,acceptedVideoMimeTypes:o,onMount:s,components:a={},shapeUtils:c=[],bindingUtils:l=[],tools:d=[],embeds:f,...h}=r,g=Nd(a),m=A.useMemo(()=>({Scribble:UQ,ShapeIndicators:JLe,CollaboratorScribble:UQ,SelectionForeground:XLe,SelectionBackground:VLe,Handles:zLe,...g}),[g]),y=Hc(c),x=A.useMemo(()=>Xx("type",y,kde),[y]),_=Hc(l),w=A.useMemo(()=>Xx("type",_,Vue),[_]),I=Hc(d),b=A.useMemo(()=>Xx("id",h4e,I),[I]),P=Hc(i??Mh),C=Hc(o??_m),k=A.useMemo(()=>[...P,...C],[P,C]),O=gfe(h.assetUrls),{done:L,error:j}=Lhe(O);return j?v.jsx(tce,{children:"Could not load assets. Please refresh the page."}):L?(x.find($=>$.type==="embed")&&f&&Sm.setEmbedDefinitions(f),v.jsx(P2e,{initialState:"select",...h,components:m,shapeUtils:x,bindingUtils:w,tools:b,children:v.jsxs(c4e,{...h,components:m,mediaMimeTypes:k,children:[v.jsx(g4e,{maxImageDimension:t,maxAssetSize:n,acceptedImageMimeTypes:P,acceptedVideoMimeTypes:C,onMount:s}),e]})})):v.jsx(vA,{children:v.jsx(_T,{})})}function g4e({maxImageDimension:r,maxAssetSize:e,acceptedImageMimeTypes:t,acceptedVideoMimeTypes:n,onMount:i}){const o=he(),s=gc(),a=ar();rce(()=>{const d=[];return d.push(q3e(o)),TFe(o,{maxImageDimension:r,maxAssetSize:e,acceptedImageMimeTypes:t,acceptedVideoMimeTypes:n,toasts:s,msg:a}),d.push(o.store.props.onMount(o)),d.push(i==null?void 0:i(o)),()=>{d.forEach(f=>f==null?void 0:f())}});const{Canvas:c}=Gr(),{ContextMenu:l}=xl();return l?v.jsx(l,{}):c?v.jsx(c,{}):null}A.memo(function(e){const[t,n]=A.useState(null),[i,o]=A.useState(null),s=Hc(e.shapeUtils??[]),a=A.useMemo(()=>[...kde,...s],[s]),c=Hc(e.bindingUtils??[]),l=A.useMemo(()=>[...Vue,...c],[c]),d=M2e({snapshot:e.snapshot,shapeUtils:a}),f=gfe(e.assetUrls),{done:h,error:g}=Lhe(f),{pageId:m,bounds:y,scale:x,pixelRatio:_,background:w,padding:I,darkMode:b,preserveAspectRatio:P,format:C="svg",licenseKey:k}=e;return A.useLayoutEffect(()=>{if(!i||!d||!h)return;let O=!1;const L=document.createElement("div");i.appendChild(L),i.classList.add("tl-container","tl-theme__light");const j=new rt({store:d,shapeUtils:a,bindingUtils:l,tools:[],getContainer:()=>L,licenseKey:k});m&&j.setCurrentPage(m);const F=j.getCurrentPageShapeIds();async function $(){const D=await j.toImage([...F],{bounds:y,scale:x,background:w,padding:I,darkMode:b,preserveAspectRatio:P,format:C});if(!D||O)return;const N=URL.createObjectURL(D.blob);n(N),j.dispose()}return $(),()=>{O=!0}},[C,i,d,a,l,m,y,x,w,I,b,P,h,g,k,_]),A.useEffect(()=>()=>{t&&URL.revokeObjectURL(t)},[t]),g?v.jsx(tce,{children:"Could not load assets."}):h?v.jsx("div",{ref:o,style:{position:"relative",width:"100%",height:"100%"},children:t&&v.jsx("img",{src:t,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})}):v.jsx(vA,{children:v.jsx(_T,{})})});A.memo(function({children:e}){const t=ar(),n=Gi(),i=A.useRef(null);vl(i);const o=e??v.jsx(Uqe,{});return n<fn.MOBILE?null:v.jsx("div",{ref:i,className:"tlui-help-menu",children:v.jsxs(tu,{id:"help menu",children:[v.jsx(ru,{children:v.jsx(It,{type:"help",title:t("help-menu.title"),"data-testid":"help-menu.button",children:v.jsx(rr,{icon:"question-mark",small:!0})})}),v.jsx(nu,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:v.jsx(ls,{type:"menu",sourceId:"help-menu",children:o})})]})})});const v4e=1,m4e=nr({schemaVersion:Pi(1),storeVersion:sv,recordVersions:Vv(zt,nr({version:sv,subTypeVersions:Vv(zt,sv).optional(),subTypeKey:zt.optional()}))}),y4e=nr({schemaVersion:Pi(2),sequences:Vv(zt,sv)}),S4e=nr({tldrawFileFormatVersion:kme,schema:Ome("schemaVersion",{1:m4e,2:y4e}),records:Jn(nr({id:zt,typeName:zt}).allowUnknownProperties())});function x4e(r){var e;try{return!!((e=r.document)!=null&&e.version)}catch{return!1}}function _4e({json:r,schema:e}){let t;try{t=S4e.validate(JSON.parse(r))}catch(o){try{if(t=JSON.parse(r),x4e(t))return qi.err({type:"v1File",data:t})}catch{}return qi.err({type:"notATldrawFile",cause:o})}if(t.tldrawFileFormatVersion>v4e)return qi.err({type:"fileFormatVersionTooNew",version:t.tldrawFileFormatVersion});let n,i;try{const o=w4e(t.records);i=Object.fromEntries(o.map(s=>[s.id,s])),n=e.migrateStoreSnapshot({store:i,schema:t.schema})}catch(o){return qi.err({type:"invalidRecords",cause:o})}if(n.type==="error")return qi.err({type:"migrationFailed",reason:n.reason});try{return qi.ok(wh({snapshot:{store:i,schema:t.schema},schema:e}))}catch(o){return qi.err({type:"invalidRecords",cause:o})}}function w4e(r){const e=new Set;for(const t of r)t.typeName==="shape"&&"assetId"in t.props&&t.props.assetId&&e.add(t.props.assetId);return r.filter(t=>t.typeName!=="asset"||e.has(t.id))}il("tldraw","3.9.0","esm");function b4e(){const[r,e]=A.useState();function t(n){globalThis.editor=n,r===void 0?fetch("/tldr-data").then(async i=>{if(!i.ok){console.log(`No tldr data to load from local endpoint (${i.status})`);return}return i.text()}).then(i=>{if(i===void 0)return;const o=_4e({json:i,schema:n.store.schema});o.ok?(console.log("Loaded tldr file from local endpoint"),e(o.value)):console.error(`Couldn't parse tldr file: ${String(o.error.type)}`)}).catch(i=>{console.error("Couldn't fetch data:",i)}):(n.zoomToFit(),n.menus.clearOpenMenus())}return v.jsx("div",{style:{inset:0,position:"fixed"},children:v.jsx(p4e,{assetUrls:_ge(),onMount:t,store:r})})}xge.createRoot(document.querySelector("#root")).render(v.jsx(lr.StrictMode,{children:v.jsx(b4e,{})}));