mirror of https://gitee.com/godoos/godoos.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
345 lines
1.0 MiB
345 lines
1.0 MiB
var FO=Object.defineProperty;var NO=(e,t,n)=>t in e?FO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var m=(e,t,n)=>(NO(e,typeof t!="symbol"?t+"":t,n),n);function zO(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const s=Object.getOwnPropertyDescriptor(r,o);s&&Object.defineProperty(e,o,s.get?s:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(o){if(o.ep)return;o.ep=!0;const s=n(o);fetch(o.href,s)}})();var tn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xI={exports:{}},ff={},wI={exports:{}},xe={};/**
|
|
* @license React
|
|
* react.production.min.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/var Cu=Symbol.for("react.element"),BO=Symbol.for("react.portal"),UO=Symbol.for("react.fragment"),HO=Symbol.for("react.strict_mode"),KO=Symbol.for("react.profiler"),WO=Symbol.for("react.provider"),VO=Symbol.for("react.context"),GO=Symbol.for("react.forward_ref"),YO=Symbol.for("react.suspense"),XO=Symbol.for("react.memo"),qO=Symbol.for("react.lazy"),Bw=Symbol.iterator;function ZO(e){return e===null||typeof e!="object"?null:(e=Bw&&e[Bw]||e["@@iterator"],typeof e=="function"?e:null)}var bI={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},PI=Object.assign,CI={};function fc(e,t,n){this.props=e,this.context=t,this.refs=CI,this.updater=n||bI}fc.prototype.isReactComponent={};fc.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};fc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function II(){}II.prototype=fc.prototype;function Nv(e,t,n){this.props=e,this.context=t,this.refs=CI,this.updater=n||bI}var zv=Nv.prototype=new II;zv.constructor=Nv;PI(zv,fc.prototype);zv.isPureReactComponent=!0;var Uw=Array.isArray,EI=Object.prototype.hasOwnProperty,Bv={current:null},_I={key:!0,ref:!0,__self:!0,__source:!0};function kI(e,t,n){var r,o={},s=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(s=""+t.key),t)EI.call(t,r)&&!_I.hasOwnProperty(r)&&(o[r]=t[r]);var a=arguments.length-2;if(a===1)o.children=n;else if(1<a){for(var c=Array(a),l=0;l<a;l++)c[l]=arguments[l+2];o.children=c}if(e&&e.defaultProps)for(r in a=e.defaultProps,a)o[r]===void 0&&(o[r]=a[r]);return{$$typeof:Cu,type:e,key:s,ref:i,props:o,_owner:Bv.current}}function QO(e,t){return{$$typeof:Cu,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Uv(e){return typeof e=="object"&&e!==null&&e.$$typeof===Cu}function JO(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Hw=/\/+/g;function $g(e,t){return typeof e=="object"&&e!==null&&e.key!=null?JO(""+e.key):t.toString(36)}function nh(e,t,n,r,o){var s=typeof e;(s==="undefined"||s==="boolean")&&(e=null);var i=!1;if(e===null)i=!0;else switch(s){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case Cu:case BO:i=!0}}if(i)return i=e,o=o(i),e=r===""?"."+$g(i,0):r,Uw(o)?(n="",e!=null&&(n=e.replace(Hw,"$&/")+"/"),nh(o,t,n,"",function(l){return l})):o!=null&&(Uv(o)&&(o=QO(o,n+(!o.key||i&&i.key===o.key?"":(""+o.key).replace(Hw,"$&/")+"/")+e)),t.push(o)),1;if(i=0,r=r===""?".":r+":",Uw(e))for(var a=0;a<e.length;a++){s=e[a];var c=r+$g(s,a);i+=nh(s,t,n,c,o)}else if(c=ZO(e),typeof c=="function")for(e=c.call(e),a=0;!(s=e.next()).done;)s=s.value,c=r+$g(s,a++),i+=nh(s,t,n,c,o);else if(s==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return i}function td(e,t,n){if(e==null)return e;var r=[],o=0;return nh(e,r,"","",function(s){return t.call(n,s,o++)}),r}function eD(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var mn={current:null},rh={transition:null},tD={ReactCurrentDispatcher:mn,ReactCurrentBatchConfig:rh,ReactCurrentOwner:Bv};function TI(){throw Error("act(...) is not supported in production builds of React.")}xe.Children={map:td,forEach:function(e,t,n){td(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return td(e,function(){t++}),t},toArray:function(e){return td(e,function(t){return t})||[]},only:function(e){if(!Uv(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};xe.Component=fc;xe.Fragment=UO;xe.Profiler=KO;xe.PureComponent=Nv;xe.StrictMode=HO;xe.Suspense=YO;xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=tD;xe.act=TI;xe.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=PI({},e.props),o=e.key,s=e.ref,i=e._owner;if(t!=null){if(t.ref!==void 0&&(s=t.ref,i=Bv.current),t.key!==void 0&&(o=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(c in t)EI.call(t,c)&&!_I.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&a!==void 0?a[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){a=Array(c);for(var l=0;l<c;l++)a[l]=arguments[l+2];r.children=a}return{$$typeof:Cu,type:e.type,key:o,ref:s,props:r,_owner:i}};xe.createContext=function(e){return e={$$typeof:VO,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:WO,_context:e},e.Consumer=e};xe.createElement=kI;xe.createFactory=function(e){var t=kI.bind(null,e);return t.type=e,t};xe.createRef=function(){return{current:null}};xe.forwardRef=function(e){return{$$typeof:GO,render:e}};xe.isValidElement=Uv;xe.lazy=function(e){return{$$typeof:qO,_payload:{_status:-1,_result:e},_init:eD}};xe.memo=function(e,t){return{$$typeof:XO,type:e,compare:t===void 0?null:t}};xe.startTransition=function(e){var t=rh.transition;rh.transition={};try{e()}finally{rh.transition=t}};xe.unstable_act=TI;xe.useCallback=function(e,t){return mn.current.useCallback(e,t)};xe.useContext=function(e){return mn.current.useContext(e)};xe.useDebugValue=function(){};xe.useDeferredValue=function(e){return mn.current.useDeferredValue(e)};xe.useEffect=function(e,t){return mn.current.useEffect(e,t)};xe.useId=function(){return mn.current.useId()};xe.useImperativeHandle=function(e,t,n){return mn.current.useImperativeHandle(e,t,n)};xe.useInsertionEffect=function(e,t){return mn.current.useInsertionEffect(e,t)};xe.useLayoutEffect=function(e,t){return mn.current.useLayoutEffect(e,t)};xe.useMemo=function(e,t){return mn.current.useMemo(e,t)};xe.useReducer=function(e,t,n){return mn.current.useReducer(e,t,n)};xe.useRef=function(e){return mn.current.useRef(e)};xe.useState=function(e){return mn.current.useState(e)};xe.useSyncExternalStore=function(e,t,n){return mn.current.useSyncExternalStore(e,t,n)};xe.useTransition=function(){return mn.current.useTransition()};xe.version="18.3.1";wI.exports=xe;var x=wI.exports;const Se=pc(x),nD=zO({__proto__:null,default:Se},[x]);/**
|
|
* @license React
|
|
* react-jsx-runtime.production.min.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/var rD=x,oD=Symbol.for("react.element"),sD=Symbol.for("react.fragment"),iD=Object.prototype.hasOwnProperty,aD=rD.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,cD={key:!0,ref:!0,__self:!0,__source:!0};function $I(e,t,n){var r,o={},s=null,i=null;n!==void 0&&(s=""+n),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(i=t.ref);for(r in t)iD.call(t,r)&&!cD.hasOwnProperty(r)&&(o[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)o[r]===void 0&&(o[r]=t[r]);return{$$typeof:oD,type:e,key:s,ref:i,props:o,_owner:aD.current}}ff.Fragment=sD;ff.jsx=$I;ff.jsxs=$I;xI.exports=ff;var h=xI.exports,Fy={},MI={exports:{}},nr={},AI={exports:{}},jI={};/**
|
|
* @license React
|
|
* scheduler.production.min.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/(function(e){function t(H,U){var W=H.length;H.push(U);e:for(;0<W;){var Z=W-1>>>1,le=H[Z];if(0<o(le,U))H[Z]=U,H[W]=le,W=Z;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var U=H[0],W=H.pop();if(W!==U){H[0]=W;e:for(var Z=0,le=H.length,be=le>>>1;Z<be;){var Me=2*(Z+1)-1,ae=H[Me],Ae=Me+1,Re=H[Ae];if(0>o(ae,W))Ae<le&&0>o(Re,ae)?(H[Z]=Re,H[Ae]=W,Z=Ae):(H[Z]=ae,H[Me]=W,Z=Me);else if(Ae<le&&0>o(Re,W))H[Z]=Re,H[Ae]=W,Z=Ae;else break e}}return U}function o(H,U){var W=H.sortIndex-U.sortIndex;return W!==0?W:H.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var i=Date,a=i.now();e.unstable_now=function(){return i.now()-a}}var c=[],l=[],u=1,d=null,p=3,f=!1,y=!1,g=!1,w=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function b(H){for(var U=n(l);U!==null;){if(U.callback===null)r(l);else if(U.startTime<=H)r(l),U.sortIndex=U.expirationTime,t(c,U);else break;U=n(l)}}function E(H){if(g=!1,b(H),!y)if(n(c)!==null)y=!0,q(C);else{var U=n(l);U!==null&&Q(E,U.startTime-H)}}function C(H,U){y=!1,g&&(g=!1,S(k),k=-1),f=!0;var W=p;try{for(b(U),d=n(c);d!==null&&(!(d.expirationTime>U)||H&&!O());){var Z=d.callback;if(typeof Z=="function"){d.callback=null,p=d.priorityLevel;var le=Z(d.expirationTime<=U);U=e.unstable_now(),typeof le=="function"?d.callback=le:d===n(c)&&r(c),b(U)}else r(c);d=n(c)}if(d!==null)var be=!0;else{var Me=n(l);Me!==null&&Q(E,Me.startTime-U),be=!1}return be}finally{d=null,p=W,f=!1}}var I=!1,_=null,k=-1,$=5,T=-1;function O(){return!(e.unstable_now()-T<$)}function N(){if(_!==null){var H=e.unstable_now();T=H;var U=!0;try{U=_(!0,H)}finally{U?F():(I=!1,_=null)}}else I=!1}var F;if(typeof v=="function")F=function(){v(N)};else if(typeof MessageChannel<"u"){var L=new MessageChannel,B=L.port2;L.port1.onmessage=N,F=function(){B.postMessage(null)}}else F=function(){w(N,0)};function q(H){_=H,I||(I=!0,F())}function Q(H,U){k=w(function(){H(e.unstable_now())},U)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(H){H.callback=null},e.unstable_continueExecution=function(){y||f||(y=!0,q(C))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(H){switch(p){case 1:case 2:case 3:var U=3;break;default:U=p}var W=p;p=U;try{return H()}finally{p=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,U){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var W=p;p=H;try{return U()}finally{p=W}},e.unstable_scheduleCallback=function(H,U,W){var Z=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?Z+W:Z):W=Z,H){case 1:var le=-1;break;case 2:le=250;break;case 5:le=1073741823;break;case 4:le=1e4;break;default:le=5e3}return le=W+le,H={id:u++,callback:U,priorityLevel:H,startTime:W,expirationTime:le,sortIndex:-1},W>Z?(H.sortIndex=W,t(l,H),n(c)===null&&H===n(l)&&(g?(S(k),k=-1):g=!0,Q(E,W-Z))):(H.sortIndex=le,t(c,H),y||f||(y=!0,q(C))),H},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(H){var U=p;return function(){var W=p;p=U;try{return H.apply(this,arguments)}finally{p=W}}}})(jI);AI.exports=jI;var lD=AI.exports;/**
|
|
* @license React
|
|
* react-dom.production.min.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/var uD=x,Jn=lD;function Y(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var OI=new Set,Ll={};function zi(e,t){Za(e,t),Za(e+"Capture",t)}function Za(e,t){for(Ll[e]=t,e=0;e<t.length;e++)OI.add(t[e])}var No=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ny=Object.prototype.hasOwnProperty,dD=/^[: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]*$/,Kw={},Ww={};function hD(e){return Ny.call(Ww,e)?!0:Ny.call(Kw,e)?!1:dD.test(e)?Ww[e]=!0:(Kw[e]=!0,!1)}function pD(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function fD(e,t,n,r){if(t===null||typeof t>"u"||pD(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function yn(e,t,n,r,o,s,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=i}var Kt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Kt[e]=new yn(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Kt[t]=new yn(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Kt[e]=new yn(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Kt[e]=new yn(e,2,!1,e,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(e){Kt[e]=new yn(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Kt[e]=new yn(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Kt[e]=new yn(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Kt[e]=new yn(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Kt[e]=new yn(e,5,!1,e.toLowerCase(),null,!1,!1)});var Hv=/[\-:]([a-z])/g;function Kv(e){return e[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(e){var t=e.replace(Hv,Kv);Kt[t]=new yn(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Hv,Kv);Kt[t]=new yn(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Hv,Kv);Kt[t]=new yn(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Kt[e]=new yn(e,1,!1,e.toLowerCase(),null,!1,!1)});Kt.xlinkHref=new yn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Kt[e]=new yn(e,1,!1,e.toLowerCase(),null,!0,!0)});function Wv(e,t,n,r){var o=Kt.hasOwnProperty(t)?Kt[t]:null;(o!==null?o.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(fD(t,n,o,r)&&(n=null),r||o===null?hD(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):o.mustUseProperty?e[o.propertyName]=n===null?o.type===3?!1:"":n:(t=o.attributeName,r=o.attributeNamespace,n===null?e.removeAttribute(t):(o=o.type,n=o===3||o===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Xo=uD.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,nd=Symbol.for("react.element"),ma=Symbol.for("react.portal"),ya=Symbol.for("react.fragment"),Vv=Symbol.for("react.strict_mode"),zy=Symbol.for("react.profiler"),DI=Symbol.for("react.provider"),RI=Symbol.for("react.context"),Gv=Symbol.for("react.forward_ref"),By=Symbol.for("react.suspense"),Uy=Symbol.for("react.suspense_list"),Yv=Symbol.for("react.memo"),gs=Symbol.for("react.lazy"),LI=Symbol.for("react.offscreen"),Vw=Symbol.iterator;function Fc(e){return e===null||typeof e!="object"?null:(e=Vw&&e[Vw]||e["@@iterator"],typeof e=="function"?e:null)}var ut=Object.assign,Mg;function ll(e){if(Mg===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Mg=t&&t[1]||""}return`
|
|
`+Mg+e}var Ag=!1;function jg(e,t){if(!e||Ag)return"";Ag=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(l){var r=l}Reflect.construct(e,[],t)}else{try{t.call()}catch(l){r=l}e.call(t.prototype)}else{try{throw Error()}catch(l){r=l}e()}}catch(l){if(l&&r&&typeof l.stack=="string"){for(var o=l.stack.split(`
|
|
`),s=r.stack.split(`
|
|
`),i=o.length-1,a=s.length-1;1<=i&&0<=a&&o[i]!==s[a];)a--;for(;1<=i&&0<=a;i--,a--)if(o[i]!==s[a]){if(i!==1||a!==1)do if(i--,a--,0>a||o[i]!==s[a]){var c=`
|
|
`+o[i].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=i&&0<=a);break}}}finally{Ag=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?ll(e):""}function gD(e){switch(e.tag){case 5:return ll(e.type);case 16:return ll("Lazy");case 13:return ll("Suspense");case 19:return ll("SuspenseList");case 0:case 2:case 15:return e=jg(e.type,!1),e;case 11:return e=jg(e.type.render,!1),e;case 1:return e=jg(e.type,!0),e;default:return""}}function Hy(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case ya:return"Fragment";case ma:return"Portal";case zy:return"Profiler";case Vv:return"StrictMode";case By:return"Suspense";case Uy:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case RI:return(e.displayName||"Context")+".Consumer";case DI:return(e._context.displayName||"Context")+".Provider";case Gv:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Yv:return t=e.displayName||null,t!==null?t:Hy(e.type)||"Memo";case gs:t=e._payload,e=e._init;try{return Hy(e(t))}catch{}}return null}function mD(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Hy(t);case 8:return t===Vv?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Ds(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function FI(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function yD(e){var t=FI(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(i){r=""+i,s.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function rd(e){e._valueTracker||(e._valueTracker=yD(e))}function NI(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=FI(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function op(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ky(e,t){var n=t.checked;return ut({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Gw(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Ds(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function zI(e,t){t=t.checked,t!=null&&Wv(e,"checked",t,!1)}function Wy(e,t){zI(e,t);var n=Ds(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Vy(e,t.type,n):t.hasOwnProperty("defaultValue")&&Vy(e,t.type,Ds(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Yw(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Vy(e,t,n){(t!=="number"||op(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ul=Array.isArray;function La(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o<n.length;o++)t["$"+n[o]]=!0;for(n=0;n<e.length;n++)o=t.hasOwnProperty("$"+e[n].value),e[n].selected!==o&&(e[n].selected=o),o&&r&&(e[n].defaultSelected=!0)}else{for(n=""+Ds(n),t=null,o=0;o<e.length;o++){if(e[o].value===n){e[o].selected=!0,r&&(e[o].defaultSelected=!0);return}t!==null||e[o].disabled||(t=e[o])}t!==null&&(t.selected=!0)}}function Gy(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Y(91));return ut({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Xw(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Y(92));if(ul(n)){if(1<n.length)throw Error(Y(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Ds(n)}}function BI(e,t){var n=Ds(t.value),r=Ds(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function qw(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function UI(e){switch(e){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 Yy(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?UI(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var od,HI=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,o){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,o)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(od=od||document.createElement("div"),od.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=od.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Fl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var vl={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},SD=["Webkit","ms","Moz","O"];Object.keys(vl).forEach(function(e){SD.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),vl[t]=vl[e]})});function KI(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||vl.hasOwnProperty(e)&&vl[e]?(""+t).trim():t+"px"}function WI(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=KI(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var vD=ut({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 Xy(e,t){if(t){if(vD[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Y(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Y(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Y(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Y(62))}}function qy(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Zy=null;function Xv(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Qy=null,Fa=null,Na=null;function Zw(e){if(e=_u(e)){if(typeof Qy!="function")throw Error(Y(280));var t=e.stateNode;t&&(t=vf(t),Qy(e.stateNode,e.type,t))}}function VI(e){Fa?Na?Na.push(e):Na=[e]:Fa=e}function GI(){if(Fa){var e=Fa,t=Na;if(Na=Fa=null,Zw(e),t)for(e=0;e<t.length;e++)Zw(t[e])}}function YI(e,t){return e(t)}function XI(){}var Og=!1;function qI(e,t,n){if(Og)return e(t,n);Og=!0;try{return YI(e,t,n)}finally{Og=!1,(Fa!==null||Na!==null)&&(XI(),GI())}}function Nl(e,t){var n=e.stateNode;if(n===null)return null;var r=vf(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(Y(231,t,typeof n));return n}var Jy=!1;if(No)try{var Nc={};Object.defineProperty(Nc,"passive",{get:function(){Jy=!0}}),window.addEventListener("test",Nc,Nc),window.removeEventListener("test",Nc,Nc)}catch{Jy=!1}function xD(e,t,n,r,o,s,i,a,c){var l=Array.prototype.slice.call(arguments,3);try{t.apply(n,l)}catch(u){this.onError(u)}}var xl=!1,sp=null,ip=!1,eS=null,wD={onError:function(e){xl=!0,sp=e}};function bD(e,t,n,r,o,s,i,a,c){xl=!1,sp=null,xD.apply(wD,arguments)}function PD(e,t,n,r,o,s,i,a,c){if(bD.apply(this,arguments),xl){if(xl){var l=sp;xl=!1,sp=null}else throw Error(Y(198));ip||(ip=!0,eS=l)}}function Bi(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function ZI(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Qw(e){if(Bi(e)!==e)throw Error(Y(188))}function CD(e){var t=e.alternate;if(!t){if(t=Bi(e),t===null)throw Error(Y(188));return t!==e?null:e}for(var n=e,r=t;;){var o=n.return;if(o===null)break;var s=o.alternate;if(s===null){if(r=o.return,r!==null){n=r;continue}break}if(o.child===s.child){for(s=o.child;s;){if(s===n)return Qw(o),e;if(s===r)return Qw(o),t;s=s.sibling}throw Error(Y(188))}if(n.return!==r.return)n=o,r=s;else{for(var i=!1,a=o.child;a;){if(a===n){i=!0,n=o,r=s;break}if(a===r){i=!0,r=o,n=s;break}a=a.sibling}if(!i){for(a=s.child;a;){if(a===n){i=!0,n=s,r=o;break}if(a===r){i=!0,r=s,n=o;break}a=a.sibling}if(!i)throw Error(Y(189))}}if(n.alternate!==r)throw Error(Y(190))}if(n.tag!==3)throw Error(Y(188));return n.stateNode.current===n?e:t}function QI(e){return e=CD(e),e!==null?JI(e):null}function JI(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=JI(e);if(t!==null)return t;e=e.sibling}return null}var eE=Jn.unstable_scheduleCallback,Jw=Jn.unstable_cancelCallback,ID=Jn.unstable_shouldYield,ED=Jn.unstable_requestPaint,St=Jn.unstable_now,_D=Jn.unstable_getCurrentPriorityLevel,qv=Jn.unstable_ImmediatePriority,tE=Jn.unstable_UserBlockingPriority,ap=Jn.unstable_NormalPriority,kD=Jn.unstable_LowPriority,nE=Jn.unstable_IdlePriority,gf=null,to=null;function TD(e){if(to&&typeof to.onCommitFiberRoot=="function")try{to.onCommitFiberRoot(gf,e,void 0,(e.current.flags&128)===128)}catch{}}var Dr=Math.clz32?Math.clz32:AD,$D=Math.log,MD=Math.LN2;function AD(e){return e>>>=0,e===0?32:31-($D(e)/MD|0)|0}var sd=64,id=4194304;function dl(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function cp(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,s=e.pingedLanes,i=n&268435455;if(i!==0){var a=i&~o;a!==0?r=dl(a):(s&=i,s!==0&&(r=dl(s)))}else i=n&~o,i!==0?r=dl(i):s!==0&&(r=dl(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,s=t&-t,o>=s||o===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Dr(t),o=1<<n,r|=e[n],t&=~o;return r}function jD(e,t){switch(e){case 1:case 2:case 4:return t+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 t+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 OD(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,o=e.expirationTimes,s=e.pendingLanes;0<s;){var i=31-Dr(s),a=1<<i,c=o[i];c===-1?(!(a&n)||a&r)&&(o[i]=jD(a,t)):c<=t&&(e.expiredLanes|=a),s&=~a}}function tS(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function rE(){var e=sd;return sd<<=1,!(sd&4194240)&&(sd=64),e}function Dg(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Iu(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Dr(t),e[t]=n}function DD(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var o=31-Dr(n),s=1<<o;t[o]=0,r[o]=-1,e[o]=-1,n&=~s}}function Zv(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Dr(n),o=1<<r;o&t|e[r]&t&&(e[r]|=t),n&=~o}}var Fe=0;function oE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var sE,Qv,iE,aE,cE,nS=!1,ad=[],Is=null,Es=null,_s=null,zl=new Map,Bl=new Map,ys=[],RD="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 eb(e,t){switch(e){case"focusin":case"focusout":Is=null;break;case"dragenter":case"dragleave":Es=null;break;case"mouseover":case"mouseout":_s=null;break;case"pointerover":case"pointerout":zl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Bl.delete(t.pointerId)}}function zc(e,t,n,r,o,s){return e===null||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:s,targetContainers:[o]},t!==null&&(t=_u(t),t!==null&&Qv(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,o!==null&&t.indexOf(o)===-1&&t.push(o),e)}function LD(e,t,n,r,o){switch(t){case"focusin":return Is=zc(Is,e,t,n,r,o),!0;case"dragenter":return Es=zc(Es,e,t,n,r,o),!0;case"mouseover":return _s=zc(_s,e,t,n,r,o),!0;case"pointerover":var s=o.pointerId;return zl.set(s,zc(zl.get(s)||null,e,t,n,r,o)),!0;case"gotpointercapture":return s=o.pointerId,Bl.set(s,zc(Bl.get(s)||null,e,t,n,r,o)),!0}return!1}function lE(e){var t=pi(e.target);if(t!==null){var n=Bi(t);if(n!==null){if(t=n.tag,t===13){if(t=ZI(n),t!==null){e.blockedOn=t,cE(e.priority,function(){iE(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function oh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=rS(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Zy=r,n.target.dispatchEvent(r),Zy=null}else return t=_u(n),t!==null&&Qv(t),e.blockedOn=n,!1;t.shift()}return!0}function tb(e,t,n){oh(e)&&n.delete(t)}function FD(){nS=!1,Is!==null&&oh(Is)&&(Is=null),Es!==null&&oh(Es)&&(Es=null),_s!==null&&oh(_s)&&(_s=null),zl.forEach(tb),Bl.forEach(tb)}function Bc(e,t){e.blockedOn===t&&(e.blockedOn=null,nS||(nS=!0,Jn.unstable_scheduleCallback(Jn.unstable_NormalPriority,FD)))}function Ul(e){function t(o){return Bc(o,e)}if(0<ad.length){Bc(ad[0],e);for(var n=1;n<ad.length;n++){var r=ad[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Is!==null&&Bc(Is,e),Es!==null&&Bc(Es,e),_s!==null&&Bc(_s,e),zl.forEach(t),Bl.forEach(t),n=0;n<ys.length;n++)r=ys[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<ys.length&&(n=ys[0],n.blockedOn===null);)lE(n),n.blockedOn===null&&ys.shift()}var za=Xo.ReactCurrentBatchConfig,lp=!0;function ND(e,t,n,r){var o=Fe,s=za.transition;za.transition=null;try{Fe=1,Jv(e,t,n,r)}finally{Fe=o,za.transition=s}}function zD(e,t,n,r){var o=Fe,s=za.transition;za.transition=null;try{Fe=4,Jv(e,t,n,r)}finally{Fe=o,za.transition=s}}function Jv(e,t,n,r){if(lp){var o=rS(e,t,n,r);if(o===null)Wg(e,t,r,up,n),eb(e,r);else if(LD(o,e,t,n,r))r.stopPropagation();else if(eb(e,r),t&4&&-1<RD.indexOf(e)){for(;o!==null;){var s=_u(o);if(s!==null&&sE(s),s=rS(e,t,n,r),s===null&&Wg(e,t,r,up,n),s===o)break;o=s}o!==null&&r.stopPropagation()}else Wg(e,t,r,null,n)}}var up=null;function rS(e,t,n,r){if(up=null,e=Xv(r),e=pi(e),e!==null)if(t=Bi(e),t===null)e=null;else if(n=t.tag,n===13){if(e=ZI(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return up=e,null}function uE(e){switch(e){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(_D()){case qv:return 1;case tE:return 4;case ap:case kD:return 16;case nE:return 536870912;default:return 16}default:return 16}}var ws=null,e0=null,sh=null;function dE(){if(sh)return sh;var e,t=e0,n=t.length,r,o="value"in ws?ws.value:ws.textContent,s=o.length;for(e=0;e<n&&t[e]===o[e];e++);var i=n-e;for(r=1;r<=i&&t[n-r]===o[s-r];r++);return sh=o.slice(e,1<r?1-r:void 0)}function ih(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function cd(){return!0}function nb(){return!1}function rr(e){function t(n,r,o,s,i){this._reactName=n,this._targetInst=o,this.type=r,this.nativeEvent=s,this.target=i,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(s):s[a]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?cd:nb,this.isPropagationStopped=nb,this}return ut(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=cd)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=cd)},persist:function(){},isPersistent:cd}),t}var gc={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},t0=rr(gc),Eu=ut({},gc,{view:0,detail:0}),BD=rr(Eu),Rg,Lg,Uc,mf=ut({},Eu,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:n0,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Uc&&(Uc&&e.type==="mousemove"?(Rg=e.screenX-Uc.screenX,Lg=e.screenY-Uc.screenY):Lg=Rg=0,Uc=e),Rg)},movementY:function(e){return"movementY"in e?e.movementY:Lg}}),rb=rr(mf),UD=ut({},mf,{dataTransfer:0}),HD=rr(UD),KD=ut({},Eu,{relatedTarget:0}),Fg=rr(KD),WD=ut({},gc,{animationName:0,elapsedTime:0,pseudoElement:0}),VD=rr(WD),GD=ut({},gc,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),YD=rr(GD),XD=ut({},gc,{data:0}),ob=rr(XD),qD={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ZD={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"},QD={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function JD(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=QD[e])?!!t[e]:!1}function n0(){return JD}var eR=ut({},Eu,{key:function(e){if(e.key){var t=qD[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ih(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?ZD[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:n0,charCode:function(e){return e.type==="keypress"?ih(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ih(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),tR=rr(eR),nR=ut({},mf,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),sb=rr(nR),rR=ut({},Eu,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:n0}),oR=rr(rR),sR=ut({},gc,{propertyName:0,elapsedTime:0,pseudoElement:0}),iR=rr(sR),aR=ut({},mf,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),cR=rr(aR),lR=[9,13,27,32],r0=No&&"CompositionEvent"in window,wl=null;No&&"documentMode"in document&&(wl=document.documentMode);var uR=No&&"TextEvent"in window&&!wl,hE=No&&(!r0||wl&&8<wl&&11>=wl),ib=" ",ab=!1;function pE(e,t){switch(e){case"keyup":return lR.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Sa=!1;function dR(e,t){switch(e){case"compositionend":return fE(t);case"keypress":return t.which!==32?null:(ab=!0,ib);case"textInput":return e=t.data,e===ib&&ab?null:e;default:return null}}function hR(e,t){if(Sa)return e==="compositionend"||!r0&&pE(e,t)?(e=dE(),sh=e0=ws=null,Sa=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return hE&&t.locale!=="ko"?null:t.data;default:return null}}var pR={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 cb(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!pR[e.type]:t==="textarea"}function gE(e,t,n,r){VI(r),t=dp(t,"onChange"),0<t.length&&(n=new t0("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var bl=null,Hl=null;function fR(e){EE(e,0)}function yf(e){var t=wa(e);if(NI(t))return e}function gR(e,t){if(e==="change")return t}var mE=!1;if(No){var Ng;if(No){var zg="oninput"in document;if(!zg){var lb=document.createElement("div");lb.setAttribute("oninput","return;"),zg=typeof lb.oninput=="function"}Ng=zg}else Ng=!1;mE=Ng&&(!document.documentMode||9<document.documentMode)}function ub(){bl&&(bl.detachEvent("onpropertychange",yE),Hl=bl=null)}function yE(e){if(e.propertyName==="value"&&yf(Hl)){var t=[];gE(t,Hl,e,Xv(e)),qI(fR,t)}}function mR(e,t,n){e==="focusin"?(ub(),bl=t,Hl=n,bl.attachEvent("onpropertychange",yE)):e==="focusout"&&ub()}function yR(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return yf(Hl)}function SR(e,t){if(e==="click")return yf(t)}function vR(e,t){if(e==="input"||e==="change")return yf(t)}function xR(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var zr=typeof Object.is=="function"?Object.is:xR;function Kl(e,t){if(zr(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var o=n[r];if(!Ny.call(t,o)||!zr(e[o],t[o]))return!1}return!0}function db(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function hb(e,t){var n=db(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=db(n)}}function SE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?SE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function vE(){for(var e=window,t=op();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=op(e.document)}return t}function o0(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function wR(e){var t=vE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&SE(n.ownerDocument.documentElement,n)){if(r!==null&&o0(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,s=Math.min(r.start,o);r=r.end===void 0?s:Math.min(r.end,o),!e.extend&&s>r&&(o=r,r=s,s=o),o=hb(n,s);var i=hb(n,r);o&&i&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var bR=No&&"documentMode"in document&&11>=document.documentMode,va=null,oS=null,Pl=null,sS=!1;function pb(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;sS||va==null||va!==op(r)||(r=va,"selectionStart"in r&&o0(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Pl&&Kl(Pl,r)||(Pl=r,r=dp(oS,"onSelect"),0<r.length&&(t=new t0("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=va)))}function ld(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var xa={animationend:ld("Animation","AnimationEnd"),animationiteration:ld("Animation","AnimationIteration"),animationstart:ld("Animation","AnimationStart"),transitionend:ld("Transition","TransitionEnd")},Bg={},xE={};No&&(xE=document.createElement("div").style,"AnimationEvent"in window||(delete xa.animationend.animation,delete xa.animationiteration.animation,delete xa.animationstart.animation),"TransitionEvent"in window||delete xa.transitionend.transition);function Sf(e){if(Bg[e])return Bg[e];if(!xa[e])return e;var t=xa[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in xE)return Bg[e]=t[n];return e}var wE=Sf("animationend"),bE=Sf("animationiteration"),PE=Sf("animationstart"),CE=Sf("transitionend"),IE=new Map,fb="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 Ks(e,t){IE.set(e,t),zi(t,[e])}for(var Ug=0;Ug<fb.length;Ug++){var Hg=fb[Ug],PR=Hg.toLowerCase(),CR=Hg[0].toUpperCase()+Hg.slice(1);Ks(PR,"on"+CR)}Ks(wE,"onAnimationEnd");Ks(bE,"onAnimationIteration");Ks(PE,"onAnimationStart");Ks("dblclick","onDoubleClick");Ks("focusin","onFocus");Ks("focusout","onBlur");Ks(CE,"onTransitionEnd");Za("onMouseEnter",["mouseout","mouseover"]);Za("onMouseLeave",["mouseout","mouseover"]);Za("onPointerEnter",["pointerout","pointerover"]);Za("onPointerLeave",["pointerout","pointerover"]);zi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));zi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));zi("onBeforeInput",["compositionend","keypress","textInput","paste"]);zi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));zi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));zi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var hl="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(" "),IR=new Set("cancel close invalid load scroll toggle".split(" ").concat(hl));function gb(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,PD(r,t,void 0,e),e.currentTarget=null}function EE(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],o=r.event;r=r.listeners;e:{var s=void 0;if(t)for(var i=r.length-1;0<=i;i--){var a=r[i],c=a.instance,l=a.currentTarget;if(a=a.listener,c!==s&&o.isPropagationStopped())break e;gb(o,a,l),s=c}else for(i=0;i<r.length;i++){if(a=r[i],c=a.instance,l=a.currentTarget,a=a.listener,c!==s&&o.isPropagationStopped())break e;gb(o,a,l),s=c}}}if(ip)throw e=eS,ip=!1,eS=null,e}function Qe(e,t){var n=t[uS];n===void 0&&(n=t[uS]=new Set);var r=e+"__bubble";n.has(r)||(_E(t,e,2,!1),n.add(r))}function Kg(e,t,n){var r=0;t&&(r|=4),_E(n,e,r,t)}var ud="_reactListening"+Math.random().toString(36).slice(2);function Wl(e){if(!e[ud]){e[ud]=!0,OI.forEach(function(n){n!=="selectionchange"&&(IR.has(n)||Kg(n,!1,e),Kg(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[ud]||(t[ud]=!0,Kg("selectionchange",!1,t))}}function _E(e,t,n,r){switch(uE(t)){case 1:var o=ND;break;case 4:o=zD;break;default:o=Jv}n=o.bind(null,t,n,e),o=void 0,!Jy||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(o=!0),r?o!==void 0?e.addEventListener(t,n,{capture:!0,passive:o}):e.addEventListener(t,n,!0):o!==void 0?e.addEventListener(t,n,{passive:o}):e.addEventListener(t,n,!1)}function Wg(e,t,n,r,o){var s=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var i=r.tag;if(i===3||i===4){var a=r.stateNode.containerInfo;if(a===o||a.nodeType===8&&a.parentNode===o)break;if(i===4)for(i=r.return;i!==null;){var c=i.tag;if((c===3||c===4)&&(c=i.stateNode.containerInfo,c===o||c.nodeType===8&&c.parentNode===o))return;i=i.return}for(;a!==null;){if(i=pi(a),i===null)return;if(c=i.tag,c===5||c===6){r=s=i;continue e}a=a.parentNode}}r=r.return}qI(function(){var l=s,u=Xv(n),d=[];e:{var p=IE.get(e);if(p!==void 0){var f=t0,y=e;switch(e){case"keypress":if(ih(n)===0)break e;case"keydown":case"keyup":f=tR;break;case"focusin":y="focus",f=Fg;break;case"focusout":y="blur",f=Fg;break;case"beforeblur":case"afterblur":f=Fg;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":f=rb;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":f=HD;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":f=oR;break;case wE:case bE:case PE:f=VD;break;case CE:f=iR;break;case"scroll":f=BD;break;case"wheel":f=cR;break;case"copy":case"cut":case"paste":f=YD;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":f=sb}var g=(t&4)!==0,w=!g&&e==="scroll",S=g?p!==null?p+"Capture":null:p;g=[];for(var v=l,b;v!==null;){b=v;var E=b.stateNode;if(b.tag===5&&E!==null&&(b=E,S!==null&&(E=Nl(v,S),E!=null&&g.push(Vl(v,E,b)))),w)break;v=v.return}0<g.length&&(p=new f(p,y,null,n,u),d.push({event:p,listeners:g}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",f=e==="mouseout"||e==="pointerout",p&&n!==Zy&&(y=n.relatedTarget||n.fromElement)&&(pi(y)||y[zo]))break e;if((f||p)&&(p=u.window===u?u:(p=u.ownerDocument)?p.defaultView||p.parentWindow:window,f?(y=n.relatedTarget||n.toElement,f=l,y=y?pi(y):null,y!==null&&(w=Bi(y),y!==w||y.tag!==5&&y.tag!==6)&&(y=null)):(f=null,y=l),f!==y)){if(g=rb,E="onMouseLeave",S="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(g=sb,E="onPointerLeave",S="onPointerEnter",v="pointer"),w=f==null?p:wa(f),b=y==null?p:wa(y),p=new g(E,v+"leave",f,n,u),p.target=w,p.relatedTarget=b,E=null,pi(u)===l&&(g=new g(S,v+"enter",y,n,u),g.target=b,g.relatedTarget=w,E=g),w=E,f&&y)t:{for(g=f,S=y,v=0,b=g;b;b=Qi(b))v++;for(b=0,E=S;E;E=Qi(E))b++;for(;0<v-b;)g=Qi(g),v--;for(;0<b-v;)S=Qi(S),b--;for(;v--;){if(g===S||S!==null&&g===S.alternate)break t;g=Qi(g),S=Qi(S)}g=null}else g=null;f!==null&&mb(d,p,f,g,!1),y!==null&&w!==null&&mb(d,w,y,g,!0)}}e:{if(p=l?wa(l):window,f=p.nodeName&&p.nodeName.toLowerCase(),f==="select"||f==="input"&&p.type==="file")var C=gR;else if(cb(p))if(mE)C=vR;else{C=yR;var I=mR}else(f=p.nodeName)&&f.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(C=SR);if(C&&(C=C(e,l))){gE(d,C,n,u);break e}I&&I(e,p,l),e==="focusout"&&(I=p._wrapperState)&&I.controlled&&p.type==="number"&&Vy(p,"number",p.value)}switch(I=l?wa(l):window,e){case"focusin":(cb(I)||I.contentEditable==="true")&&(va=I,oS=l,Pl=null);break;case"focusout":Pl=oS=va=null;break;case"mousedown":sS=!0;break;case"contextmenu":case"mouseup":case"dragend":sS=!1,pb(d,n,u);break;case"selectionchange":if(bR)break;case"keydown":case"keyup":pb(d,n,u)}var _;if(r0)e:{switch(e){case"compositionstart":var k="onCompositionStart";break e;case"compositionend":k="onCompositionEnd";break e;case"compositionupdate":k="onCompositionUpdate";break e}k=void 0}else Sa?pE(e,n)&&(k="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(k="onCompositionStart");k&&(hE&&n.locale!=="ko"&&(Sa||k!=="onCompositionStart"?k==="onCompositionEnd"&&Sa&&(_=dE()):(ws=u,e0="value"in ws?ws.value:ws.textContent,Sa=!0)),I=dp(l,k),0<I.length&&(k=new ob(k,e,null,n,u),d.push({event:k,listeners:I}),_?k.data=_:(_=fE(n),_!==null&&(k.data=_)))),(_=uR?dR(e,n):hR(e,n))&&(l=dp(l,"onBeforeInput"),0<l.length&&(u=new ob("onBeforeInput","beforeinput",null,n,u),d.push({event:u,listeners:l}),u.data=_))}EE(d,t)})}function Vl(e,t,n){return{instance:e,listener:t,currentTarget:n}}function dp(e,t){for(var n=t+"Capture",r=[];e!==null;){var o=e,s=o.stateNode;o.tag===5&&s!==null&&(o=s,s=Nl(e,n),s!=null&&r.unshift(Vl(e,s,o)),s=Nl(e,t),s!=null&&r.push(Vl(e,s,o))),e=e.return}return r}function Qi(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function mb(e,t,n,r,o){for(var s=t._reactName,i=[];n!==null&&n!==r;){var a=n,c=a.alternate,l=a.stateNode;if(c!==null&&c===r)break;a.tag===5&&l!==null&&(a=l,o?(c=Nl(n,s),c!=null&&i.unshift(Vl(n,c,a))):o||(c=Nl(n,s),c!=null&&i.push(Vl(n,c,a)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var ER=/\r\n?/g,_R=/\u0000|\uFFFD/g;function yb(e){return(typeof e=="string"?e:""+e).replace(ER,`
|
|
`).replace(_R,"")}function dd(e,t,n){if(t=yb(t),yb(e)!==t&&n)throw Error(Y(425))}function hp(){}var iS=null,aS=null;function cS(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var lS=typeof setTimeout=="function"?setTimeout:void 0,kR=typeof clearTimeout=="function"?clearTimeout:void 0,Sb=typeof Promise=="function"?Promise:void 0,TR=typeof queueMicrotask=="function"?queueMicrotask:typeof Sb<"u"?function(e){return Sb.resolve(null).then(e).catch($R)}:lS;function $R(e){setTimeout(function(){throw e})}function Vg(e,t){var n=t,r=0;do{var o=n.nextSibling;if(e.removeChild(n),o&&o.nodeType===8)if(n=o.data,n==="/$"){if(r===0){e.removeChild(o),Ul(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=o}while(n);Ul(t)}function ks(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function vb(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var mc=Math.random().toString(36).slice(2),qr="__reactFiber$"+mc,Gl="__reactProps$"+mc,zo="__reactContainer$"+mc,uS="__reactEvents$"+mc,MR="__reactListeners$"+mc,AR="__reactHandles$"+mc;function pi(e){var t=e[qr];if(t)return t;for(var n=e.parentNode;n;){if(t=n[zo]||n[qr]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=vb(e);e!==null;){if(n=e[qr])return n;e=vb(e)}return t}e=n,n=e.parentNode}return null}function _u(e){return e=e[qr]||e[zo],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function wa(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Y(33))}function vf(e){return e[Gl]||null}var dS=[],ba=-1;function Ws(e){return{current:e}}function tt(e){0>ba||(e.current=dS[ba],dS[ba]=null,ba--)}function Ge(e,t){ba++,dS[ba]=e.current,e.current=t}var Rs={},rn=Ws(Rs),Tn=Ws(!1),Ci=Rs;function Qa(e,t){var n=e.type.contextTypes;if(!n)return Rs;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},s;for(s in n)o[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function $n(e){return e=e.childContextTypes,e!=null}function pp(){tt(Tn),tt(rn)}function xb(e,t,n){if(rn.current!==Rs)throw Error(Y(168));Ge(rn,t),Ge(Tn,n)}function kE(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(Y(108,mD(e)||"Unknown",o));return ut({},n,r)}function fp(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Rs,Ci=rn.current,Ge(rn,e),Ge(Tn,Tn.current),!0}function wb(e,t,n){var r=e.stateNode;if(!r)throw Error(Y(169));n?(e=kE(e,t,Ci),r.__reactInternalMemoizedMergedChildContext=e,tt(Tn),tt(rn),Ge(rn,e)):tt(Tn),Ge(Tn,n)}var To=null,xf=!1,Gg=!1;function TE(e){To===null?To=[e]:To.push(e)}function jR(e){xf=!0,TE(e)}function Vs(){if(!Gg&&To!==null){Gg=!0;var e=0,t=Fe;try{var n=To;for(Fe=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}To=null,xf=!1}catch(o){throw To!==null&&(To=To.slice(e+1)),eE(qv,Vs),o}finally{Fe=t,Gg=!1}}return null}var Pa=[],Ca=0,gp=null,mp=0,dr=[],hr=0,Ii=null,Mo=1,Ao="";function ui(e,t){Pa[Ca++]=mp,Pa[Ca++]=gp,gp=e,mp=t}function $E(e,t,n){dr[hr++]=Mo,dr[hr++]=Ao,dr[hr++]=Ii,Ii=e;var r=Mo;e=Ao;var o=32-Dr(r)-1;r&=~(1<<o),n+=1;var s=32-Dr(t)+o;if(30<s){var i=o-o%5;s=(r&(1<<i)-1).toString(32),r>>=i,o-=i,Mo=1<<32-Dr(t)+o|n<<o|r,Ao=s+e}else Mo=1<<s|n<<o|r,Ao=e}function s0(e){e.return!==null&&(ui(e,1),$E(e,1,0))}function i0(e){for(;e===gp;)gp=Pa[--Ca],Pa[Ca]=null,mp=Pa[--Ca],Pa[Ca]=null;for(;e===Ii;)Ii=dr[--hr],dr[hr]=null,Ao=dr[--hr],dr[hr]=null,Mo=dr[--hr],dr[hr]=null}var Xn=null,Yn=null,rt=!1,$r=null;function ME(e,t){var n=fr(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function bb(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Xn=e,Yn=ks(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Xn=e,Yn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ii!==null?{id:Mo,overflow:Ao}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=fr(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Xn=e,Yn=null,!0):!1;default:return!1}}function hS(e){return(e.mode&1)!==0&&(e.flags&128)===0}function pS(e){if(rt){var t=Yn;if(t){var n=t;if(!bb(e,t)){if(hS(e))throw Error(Y(418));t=ks(n.nextSibling);var r=Xn;t&&bb(e,t)?ME(r,n):(e.flags=e.flags&-4097|2,rt=!1,Xn=e)}}else{if(hS(e))throw Error(Y(418));e.flags=e.flags&-4097|2,rt=!1,Xn=e}}}function Pb(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Xn=e}function hd(e){if(e!==Xn)return!1;if(!rt)return Pb(e),rt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!cS(e.type,e.memoizedProps)),t&&(t=Yn)){if(hS(e))throw AE(),Error(Y(418));for(;t;)ME(e,t),t=ks(t.nextSibling)}if(Pb(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Y(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Yn=ks(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Yn=null}}else Yn=Xn?ks(e.stateNode.nextSibling):null;return!0}function AE(){for(var e=Yn;e;)e=ks(e.nextSibling)}function Ja(){Yn=Xn=null,rt=!1}function a0(e){$r===null?$r=[e]:$r.push(e)}var OR=Xo.ReactCurrentBatchConfig;function Hc(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Y(309));var r=n.stateNode}if(!r)throw Error(Y(147,e));var o=r,s=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===s?t.ref:(t=function(i){var a=o.refs;i===null?delete a[s]:a[s]=i},t._stringRef=s,t)}if(typeof e!="string")throw Error(Y(284));if(!n._owner)throw Error(Y(290,e))}return e}function pd(e,t){throw e=Object.prototype.toString.call(t),Error(Y(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Cb(e){var t=e._init;return t(e._payload)}function jE(e){function t(S,v){if(e){var b=S.deletions;b===null?(S.deletions=[v],S.flags|=16):b.push(v)}}function n(S,v){if(!e)return null;for(;v!==null;)t(S,v),v=v.sibling;return null}function r(S,v){for(S=new Map;v!==null;)v.key!==null?S.set(v.key,v):S.set(v.index,v),v=v.sibling;return S}function o(S,v){return S=As(S,v),S.index=0,S.sibling=null,S}function s(S,v,b){return S.index=b,e?(b=S.alternate,b!==null?(b=b.index,b<v?(S.flags|=2,v):b):(S.flags|=2,v)):(S.flags|=1048576,v)}function i(S){return e&&S.alternate===null&&(S.flags|=2),S}function a(S,v,b,E){return v===null||v.tag!==6?(v=em(b,S.mode,E),v.return=S,v):(v=o(v,b),v.return=S,v)}function c(S,v,b,E){var C=b.type;return C===ya?u(S,v,b.props.children,E,b.key):v!==null&&(v.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===gs&&Cb(C)===v.type)?(E=o(v,b.props),E.ref=Hc(S,v,b),E.return=S,E):(E=ph(b.type,b.key,b.props,null,S.mode,E),E.ref=Hc(S,v,b),E.return=S,E)}function l(S,v,b,E){return v===null||v.tag!==4||v.stateNode.containerInfo!==b.containerInfo||v.stateNode.implementation!==b.implementation?(v=tm(b,S.mode,E),v.return=S,v):(v=o(v,b.children||[]),v.return=S,v)}function u(S,v,b,E,C){return v===null||v.tag!==7?(v=bi(b,S.mode,E,C),v.return=S,v):(v=o(v,b),v.return=S,v)}function d(S,v,b){if(typeof v=="string"&&v!==""||typeof v=="number")return v=em(""+v,S.mode,b),v.return=S,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case nd:return b=ph(v.type,v.key,v.props,null,S.mode,b),b.ref=Hc(S,null,v),b.return=S,b;case ma:return v=tm(v,S.mode,b),v.return=S,v;case gs:var E=v._init;return d(S,E(v._payload),b)}if(ul(v)||Fc(v))return v=bi(v,S.mode,b,null),v.return=S,v;pd(S,v)}return null}function p(S,v,b,E){var C=v!==null?v.key:null;if(typeof b=="string"&&b!==""||typeof b=="number")return C!==null?null:a(S,v,""+b,E);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case nd:return b.key===C?c(S,v,b,E):null;case ma:return b.key===C?l(S,v,b,E):null;case gs:return C=b._init,p(S,v,C(b._payload),E)}if(ul(b)||Fc(b))return C!==null?null:u(S,v,b,E,null);pd(S,b)}return null}function f(S,v,b,E,C){if(typeof E=="string"&&E!==""||typeof E=="number")return S=S.get(b)||null,a(v,S,""+E,C);if(typeof E=="object"&&E!==null){switch(E.$$typeof){case nd:return S=S.get(E.key===null?b:E.key)||null,c(v,S,E,C);case ma:return S=S.get(E.key===null?b:E.key)||null,l(v,S,E,C);case gs:var I=E._init;return f(S,v,b,I(E._payload),C)}if(ul(E)||Fc(E))return S=S.get(b)||null,u(v,S,E,C,null);pd(v,E)}return null}function y(S,v,b,E){for(var C=null,I=null,_=v,k=v=0,$=null;_!==null&&k<b.length;k++){_.index>k?($=_,_=null):$=_.sibling;var T=p(S,_,b[k],E);if(T===null){_===null&&(_=$);break}e&&_&&T.alternate===null&&t(S,_),v=s(T,v,k),I===null?C=T:I.sibling=T,I=T,_=$}if(k===b.length)return n(S,_),rt&&ui(S,k),C;if(_===null){for(;k<b.length;k++)_=d(S,b[k],E),_!==null&&(v=s(_,v,k),I===null?C=_:I.sibling=_,I=_);return rt&&ui(S,k),C}for(_=r(S,_);k<b.length;k++)$=f(_,S,k,b[k],E),$!==null&&(e&&$.alternate!==null&&_.delete($.key===null?k:$.key),v=s($,v,k),I===null?C=$:I.sibling=$,I=$);return e&&_.forEach(function(O){return t(S,O)}),rt&&ui(S,k),C}function g(S,v,b,E){var C=Fc(b);if(typeof C!="function")throw Error(Y(150));if(b=C.call(b),b==null)throw Error(Y(151));for(var I=C=null,_=v,k=v=0,$=null,T=b.next();_!==null&&!T.done;k++,T=b.next()){_.index>k?($=_,_=null):$=_.sibling;var O=p(S,_,T.value,E);if(O===null){_===null&&(_=$);break}e&&_&&O.alternate===null&&t(S,_),v=s(O,v,k),I===null?C=O:I.sibling=O,I=O,_=$}if(T.done)return n(S,_),rt&&ui(S,k),C;if(_===null){for(;!T.done;k++,T=b.next())T=d(S,T.value,E),T!==null&&(v=s(T,v,k),I===null?C=T:I.sibling=T,I=T);return rt&&ui(S,k),C}for(_=r(S,_);!T.done;k++,T=b.next())T=f(_,S,k,T.value,E),T!==null&&(e&&T.alternate!==null&&_.delete(T.key===null?k:T.key),v=s(T,v,k),I===null?C=T:I.sibling=T,I=T);return e&&_.forEach(function(N){return t(S,N)}),rt&&ui(S,k),C}function w(S,v,b,E){if(typeof b=="object"&&b!==null&&b.type===ya&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case nd:e:{for(var C=b.key,I=v;I!==null;){if(I.key===C){if(C=b.type,C===ya){if(I.tag===7){n(S,I.sibling),v=o(I,b.props.children),v.return=S,S=v;break e}}else if(I.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===gs&&Cb(C)===I.type){n(S,I.sibling),v=o(I,b.props),v.ref=Hc(S,I,b),v.return=S,S=v;break e}n(S,I);break}else t(S,I);I=I.sibling}b.type===ya?(v=bi(b.props.children,S.mode,E,b.key),v.return=S,S=v):(E=ph(b.type,b.key,b.props,null,S.mode,E),E.ref=Hc(S,v,b),E.return=S,S=E)}return i(S);case ma:e:{for(I=b.key;v!==null;){if(v.key===I)if(v.tag===4&&v.stateNode.containerInfo===b.containerInfo&&v.stateNode.implementation===b.implementation){n(S,v.sibling),v=o(v,b.children||[]),v.return=S,S=v;break e}else{n(S,v);break}else t(S,v);v=v.sibling}v=tm(b,S.mode,E),v.return=S,S=v}return i(S);case gs:return I=b._init,w(S,v,I(b._payload),E)}if(ul(b))return y(S,v,b,E);if(Fc(b))return g(S,v,b,E);pd(S,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,v!==null&&v.tag===6?(n(S,v.sibling),v=o(v,b),v.return=S,S=v):(n(S,v),v=em(b,S.mode,E),v.return=S,S=v),i(S)):n(S,v)}return w}var ec=jE(!0),OE=jE(!1),yp=Ws(null),Sp=null,Ia=null,c0=null;function l0(){c0=Ia=Sp=null}function u0(e){var t=yp.current;tt(yp),e._currentValue=t}function fS(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Ba(e,t){Sp=e,c0=Ia=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(En=!0),e.firstContext=null)}function yr(e){var t=e._currentValue;if(c0!==e)if(e={context:e,memoizedValue:t,next:null},Ia===null){if(Sp===null)throw Error(Y(308));Ia=e,Sp.dependencies={lanes:0,firstContext:e}}else Ia=Ia.next=e;return t}var fi=null;function d0(e){fi===null?fi=[e]:fi.push(e)}function DE(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,d0(t)):(n.next=o.next,o.next=n),t.interleaved=n,Bo(e,r)}function Bo(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var ms=!1;function h0(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function RE(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Oo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Ts(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,_e&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,Bo(e,n)}return o=r.interleaved,o===null?(t.next=t,d0(r)):(t.next=o.next,o.next=t),r.interleaved=t,Bo(e,n)}function ah(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zv(e,n)}}function Ib(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var o=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?o=s=i:s=s.next=i,n=n.next}while(n!==null);s===null?o=s=t:s=s.next=t}else o=s=t;n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function vp(e,t,n,r){var o=e.updateQueue;ms=!1;var s=o.firstBaseUpdate,i=o.lastBaseUpdate,a=o.shared.pending;if(a!==null){o.shared.pending=null;var c=a,l=c.next;c.next=null,i===null?s=l:i.next=l,i=c;var u=e.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==i&&(a===null?u.firstBaseUpdate=l:a.next=l,u.lastBaseUpdate=c))}if(s!==null){var d=o.baseState;i=0,u=l=c=null,a=s;do{var p=a.lane,f=a.eventTime;if((r&p)===p){u!==null&&(u=u.next={eventTime:f,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var y=e,g=a;switch(p=t,f=n,g.tag){case 1:if(y=g.payload,typeof y=="function"){d=y.call(f,d,p);break e}d=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=g.payload,p=typeof y=="function"?y.call(f,d,p):y,p==null)break e;d=ut({},d,p);break e;case 2:ms=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,p=o.effects,p===null?o.effects=[a]:p.push(a))}else f={eventTime:f,lane:p,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(l=u=f,c=d):u=u.next=f,i|=p;if(a=a.next,a===null){if(a=o.shared.pending,a===null)break;p=a,a=p.next,p.next=null,o.lastBaseUpdate=p,o.shared.pending=null}}while(!0);if(u===null&&(c=d),o.baseState=c,o.firstBaseUpdate=l,o.lastBaseUpdate=u,t=o.shared.interleaved,t!==null){o=t;do i|=o.lane,o=o.next;while(o!==t)}else s===null&&(o.shared.lanes=0);_i|=i,e.lanes=i,e.memoizedState=d}}function Eb(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],o=r.callback;if(o!==null){if(r.callback=null,r=n,typeof o!="function")throw Error(Y(191,o));o.call(r)}}}var ku={},no=Ws(ku),Yl=Ws(ku),Xl=Ws(ku);function gi(e){if(e===ku)throw Error(Y(174));return e}function p0(e,t){switch(Ge(Xl,t),Ge(Yl,e),Ge(no,ku),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Yy(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Yy(t,e)}tt(no),Ge(no,t)}function tc(){tt(no),tt(Yl),tt(Xl)}function LE(e){gi(Xl.current);var t=gi(no.current),n=Yy(t,e.type);t!==n&&(Ge(Yl,e),Ge(no,n))}function f0(e){Yl.current===e&&(tt(no),tt(Yl))}var it=Ws(0);function xp(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Yg=[];function g0(){for(var e=0;e<Yg.length;e++)Yg[e]._workInProgressVersionPrimary=null;Yg.length=0}var ch=Xo.ReactCurrentDispatcher,Xg=Xo.ReactCurrentBatchConfig,Ei=0,lt=null,It=null,Tt=null,wp=!1,Cl=!1,ql=0,DR=0;function Vt(){throw Error(Y(321))}function m0(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!zr(e[n],t[n]))return!1;return!0}function y0(e,t,n,r,o,s){if(Ei=s,lt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ch.current=e===null||e.memoizedState===null?NR:zR,e=n(r,o),Cl){s=0;do{if(Cl=!1,ql=0,25<=s)throw Error(Y(301));s+=1,Tt=It=null,t.updateQueue=null,ch.current=BR,e=n(r,o)}while(Cl)}if(ch.current=bp,t=It!==null&&It.next!==null,Ei=0,Tt=It=lt=null,wp=!1,t)throw Error(Y(300));return e}function S0(){var e=ql!==0;return ql=0,e}function Yr(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Tt===null?lt.memoizedState=Tt=e:Tt=Tt.next=e,Tt}function Sr(){if(It===null){var e=lt.alternate;e=e!==null?e.memoizedState:null}else e=It.next;var t=Tt===null?lt.memoizedState:Tt.next;if(t!==null)Tt=t,It=e;else{if(e===null)throw Error(Y(310));It=e,e={memoizedState:It.memoizedState,baseState:It.baseState,baseQueue:It.baseQueue,queue:It.queue,next:null},Tt===null?lt.memoizedState=Tt=e:Tt=Tt.next=e}return Tt}function Zl(e,t){return typeof t=="function"?t(e):t}function qg(e){var t=Sr(),n=t.queue;if(n===null)throw Error(Y(311));n.lastRenderedReducer=e;var r=It,o=r.baseQueue,s=n.pending;if(s!==null){if(o!==null){var i=o.next;o.next=s.next,s.next=i}r.baseQueue=o=s,n.pending=null}if(o!==null){s=o.next,r=r.baseState;var a=i=null,c=null,l=s;do{var u=l.lane;if((Ei&u)===u)c!==null&&(c=c.next={lane:0,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null}),r=l.hasEagerState?l.eagerState:e(r,l.action);else{var d={lane:u,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null};c===null?(a=c=d,i=r):c=c.next=d,lt.lanes|=u,_i|=u}l=l.next}while(l!==null&&l!==s);c===null?i=r:c.next=a,zr(r,t.memoizedState)||(En=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){o=e;do s=o.lane,lt.lanes|=s,_i|=s,o=o.next;while(o!==e)}else o===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Zg(e){var t=Sr(),n=t.queue;if(n===null)throw Error(Y(311));n.lastRenderedReducer=e;var r=n.dispatch,o=n.pending,s=t.memoizedState;if(o!==null){n.pending=null;var i=o=o.next;do s=e(s,i.action),i=i.next;while(i!==o);zr(s,t.memoizedState)||(En=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function FE(){}function NE(e,t){var n=lt,r=Sr(),o=t(),s=!zr(r.memoizedState,o);if(s&&(r.memoizedState=o,En=!0),r=r.queue,v0(UE.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||Tt!==null&&Tt.memoizedState.tag&1){if(n.flags|=2048,Ql(9,BE.bind(null,n,r,o,t),void 0,null),At===null)throw Error(Y(349));Ei&30||zE(n,t,o)}return o}function zE(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=lt.updateQueue,t===null?(t={lastEffect:null,stores:null},lt.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function BE(e,t,n,r){t.value=n,t.getSnapshot=r,HE(t)&&KE(e)}function UE(e,t,n){return n(function(){HE(t)&&KE(e)})}function HE(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!zr(e,n)}catch{return!0}}function KE(e){var t=Bo(e,1);t!==null&&Rr(t,e,1,-1)}function _b(e){var t=Yr();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Zl,lastRenderedState:e},t.queue=e,e=e.dispatch=FR.bind(null,lt,e),[t.memoizedState,e]}function Ql(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=lt.updateQueue,t===null?(t={lastEffect:null,stores:null},lt.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function WE(){return Sr().memoizedState}function lh(e,t,n,r){var o=Yr();lt.flags|=e,o.memoizedState=Ql(1|t,n,void 0,r===void 0?null:r)}function wf(e,t,n,r){var o=Sr();r=r===void 0?null:r;var s=void 0;if(It!==null){var i=It.memoizedState;if(s=i.destroy,r!==null&&m0(r,i.deps)){o.memoizedState=Ql(t,n,s,r);return}}lt.flags|=e,o.memoizedState=Ql(1|t,n,s,r)}function kb(e,t){return lh(8390656,8,e,t)}function v0(e,t){return wf(2048,8,e,t)}function VE(e,t){return wf(4,2,e,t)}function GE(e,t){return wf(4,4,e,t)}function YE(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function XE(e,t,n){return n=n!=null?n.concat([e]):null,wf(4,4,YE.bind(null,t,e),n)}function x0(){}function qE(e,t){var n=Sr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&m0(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ZE(e,t){var n=Sr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&m0(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function QE(e,t,n){return Ei&21?(zr(n,t)||(n=rE(),lt.lanes|=n,_i|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,En=!0),e.memoizedState=n)}function RR(e,t){var n=Fe;Fe=n!==0&&4>n?n:4,e(!0);var r=Xg.transition;Xg.transition={};try{e(!1),t()}finally{Fe=n,Xg.transition=r}}function JE(){return Sr().memoizedState}function LR(e,t,n){var r=Ms(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},e_(e))t_(t,n);else if(n=DE(e,t,n,r),n!==null){var o=gn();Rr(n,e,r,o),n_(n,t,r)}}function FR(e,t,n){var r=Ms(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(e_(e))t_(t,o);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var i=t.lastRenderedState,a=s(i,n);if(o.hasEagerState=!0,o.eagerState=a,zr(a,i)){var c=t.interleaved;c===null?(o.next=o,d0(t)):(o.next=c.next,c.next=o),t.interleaved=o;return}}catch{}finally{}n=DE(e,t,o,r),n!==null&&(o=gn(),Rr(n,e,r,o),n_(n,t,r))}}function e_(e){var t=e.alternate;return e===lt||t!==null&&t===lt}function t_(e,t){Cl=wp=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function n_(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zv(e,n)}}var bp={readContext:yr,useCallback:Vt,useContext:Vt,useEffect:Vt,useImperativeHandle:Vt,useInsertionEffect:Vt,useLayoutEffect:Vt,useMemo:Vt,useReducer:Vt,useRef:Vt,useState:Vt,useDebugValue:Vt,useDeferredValue:Vt,useTransition:Vt,useMutableSource:Vt,useSyncExternalStore:Vt,useId:Vt,unstable_isNewReconciler:!1},NR={readContext:yr,useCallback:function(e,t){return Yr().memoizedState=[e,t===void 0?null:t],e},useContext:yr,useEffect:kb,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,lh(4194308,4,YE.bind(null,t,e),n)},useLayoutEffect:function(e,t){return lh(4194308,4,e,t)},useInsertionEffect:function(e,t){return lh(4,2,e,t)},useMemo:function(e,t){var n=Yr();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Yr();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=LR.bind(null,lt,e),[r.memoizedState,e]},useRef:function(e){var t=Yr();return e={current:e},t.memoizedState=e},useState:_b,useDebugValue:x0,useDeferredValue:function(e){return Yr().memoizedState=e},useTransition:function(){var e=_b(!1),t=e[0];return e=RR.bind(null,e[1]),Yr().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=lt,o=Yr();if(rt){if(n===void 0)throw Error(Y(407));n=n()}else{if(n=t(),At===null)throw Error(Y(349));Ei&30||zE(r,t,n)}o.memoizedState=n;var s={value:n,getSnapshot:t};return o.queue=s,kb(UE.bind(null,r,s,e),[e]),r.flags|=2048,Ql(9,BE.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Yr(),t=At.identifierPrefix;if(rt){var n=Ao,r=Mo;n=(r&~(1<<32-Dr(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ql++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=DR++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},zR={readContext:yr,useCallback:qE,useContext:yr,useEffect:v0,useImperativeHandle:XE,useInsertionEffect:VE,useLayoutEffect:GE,useMemo:ZE,useReducer:qg,useRef:WE,useState:function(){return qg(Zl)},useDebugValue:x0,useDeferredValue:function(e){var t=Sr();return QE(t,It.memoizedState,e)},useTransition:function(){var e=qg(Zl)[0],t=Sr().memoizedState;return[e,t]},useMutableSource:FE,useSyncExternalStore:NE,useId:JE,unstable_isNewReconciler:!1},BR={readContext:yr,useCallback:qE,useContext:yr,useEffect:v0,useImperativeHandle:XE,useInsertionEffect:VE,useLayoutEffect:GE,useMemo:ZE,useReducer:Zg,useRef:WE,useState:function(){return Zg(Zl)},useDebugValue:x0,useDeferredValue:function(e){var t=Sr();return It===null?t.memoizedState=e:QE(t,It.memoizedState,e)},useTransition:function(){var e=Zg(Zl)[0],t=Sr().memoizedState;return[e,t]},useMutableSource:FE,useSyncExternalStore:NE,useId:JE,unstable_isNewReconciler:!1};function Ir(e,t){if(e&&e.defaultProps){t=ut({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function gS(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:ut({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var bf={isMounted:function(e){return(e=e._reactInternals)?Bi(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=gn(),o=Ms(e),s=Oo(r,o);s.payload=t,n!=null&&(s.callback=n),t=Ts(e,s,o),t!==null&&(Rr(t,e,o,r),ah(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=gn(),o=Ms(e),s=Oo(r,o);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=Ts(e,s,o),t!==null&&(Rr(t,e,o,r),ah(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=gn(),r=Ms(e),o=Oo(n,r);o.tag=2,t!=null&&(o.callback=t),t=Ts(e,o,r),t!==null&&(Rr(t,e,r,n),ah(t,e,r))}};function Tb(e,t,n,r,o,s,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,s,i):t.prototype&&t.prototype.isPureReactComponent?!Kl(n,r)||!Kl(o,s):!0}function r_(e,t,n){var r=!1,o=Rs,s=t.contextType;return typeof s=="object"&&s!==null?s=yr(s):(o=$n(t)?Ci:rn.current,r=t.contextTypes,s=(r=r!=null)?Qa(e,o):Rs),t=new t(n,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=bf,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=o,e.__reactInternalMemoizedMaskedChildContext=s),t}function $b(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&bf.enqueueReplaceState(t,t.state,null)}function mS(e,t,n,r){var o=e.stateNode;o.props=n,o.state=e.memoizedState,o.refs={},h0(e);var s=t.contextType;typeof s=="object"&&s!==null?o.context=yr(s):(s=$n(t)?Ci:rn.current,o.context=Qa(e,s)),o.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(gS(e,t,s,n),o.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(t=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),t!==o.state&&bf.enqueueReplaceState(o,o.state,null),vp(e,n,o,r),o.state=e.memoizedState),typeof o.componentDidMount=="function"&&(e.flags|=4194308)}function nc(e,t){try{var n="",r=t;do n+=gD(r),r=r.return;while(r);var o=n}catch(s){o=`
|
|
Error generating stack: `+s.message+`
|
|
`+s.stack}return{value:e,source:t,stack:o,digest:null}}function Qg(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function yS(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var UR=typeof WeakMap=="function"?WeakMap:Map;function o_(e,t,n){n=Oo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Cp||(Cp=!0,_S=r),yS(e,t)},n}function s_(e,t,n){n=Oo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var o=t.value;n.payload=function(){return r(o)},n.callback=function(){yS(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){yS(e,t),typeof r!="function"&&($s===null?$s=new Set([this]):$s.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function Mb(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new UR;var o=new Set;r.set(t,o)}else o=r.get(t),o===void 0&&(o=new Set,r.set(t,o));o.has(n)||(o.add(n),e=n3.bind(null,e,t,n),t.then(e,e))}function Ab(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function jb(e,t,n,r,o){return e.mode&1?(e.flags|=65536,e.lanes=o,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Oo(-1,1),t.tag=2,Ts(n,t,1))),n.lanes|=1),e)}var HR=Xo.ReactCurrentOwner,En=!1;function un(e,t,n,r){t.child=e===null?OE(t,null,n,r):ec(t,e.child,n,r)}function Ob(e,t,n,r,o){n=n.render;var s=t.ref;return Ba(t,o),r=y0(e,t,n,r,s,o),n=S0(),e!==null&&!En?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,Uo(e,t,o)):(rt&&n&&s0(t),t.flags|=1,un(e,t,r,o),t.child)}function Db(e,t,n,r,o){if(e===null){var s=n.type;return typeof s=="function"&&!k0(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,i_(e,t,s,r,o)):(e=ph(n.type,null,r,t,t.mode,o),e.ref=t.ref,e.return=t,t.child=e)}if(s=e.child,!(e.lanes&o)){var i=s.memoizedProps;if(n=n.compare,n=n!==null?n:Kl,n(i,r)&&e.ref===t.ref)return Uo(e,t,o)}return t.flags|=1,e=As(s,r),e.ref=t.ref,e.return=t,t.child=e}function i_(e,t,n,r,o){if(e!==null){var s=e.memoizedProps;if(Kl(s,r)&&e.ref===t.ref)if(En=!1,t.pendingProps=r=s,(e.lanes&o)!==0)e.flags&131072&&(En=!0);else return t.lanes=e.lanes,Uo(e,t,o)}return SS(e,t,n,r,o)}function a_(e,t,n){var r=t.pendingProps,o=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ge(_a,Hn),Hn|=n;else{if(!(n&1073741824))return e=s!==null?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ge(_a,Hn),Hn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,Ge(_a,Hn),Hn|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,Ge(_a,Hn),Hn|=r;return un(e,t,o,n),t.child}function c_(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function SS(e,t,n,r,o){var s=$n(n)?Ci:rn.current;return s=Qa(t,s),Ba(t,o),n=y0(e,t,n,r,s,o),r=S0(),e!==null&&!En?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,Uo(e,t,o)):(rt&&r&&s0(t),t.flags|=1,un(e,t,n,o),t.child)}function Rb(e,t,n,r,o){if($n(n)){var s=!0;fp(t)}else s=!1;if(Ba(t,o),t.stateNode===null)uh(e,t),r_(t,n,r),mS(t,n,r,o),r=!0;else if(e===null){var i=t.stateNode,a=t.memoizedProps;i.props=a;var c=i.context,l=n.contextType;typeof l=="object"&&l!==null?l=yr(l):(l=$n(n)?Ci:rn.current,l=Qa(t,l));var u=n.getDerivedStateFromProps,d=typeof u=="function"||typeof i.getSnapshotBeforeUpdate=="function";d||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(a!==r||c!==l)&&$b(t,i,r,l),ms=!1;var p=t.memoizedState;i.state=p,vp(t,r,i,o),c=t.memoizedState,a!==r||p!==c||Tn.current||ms?(typeof u=="function"&&(gS(t,n,u,r),c=t.memoizedState),(a=ms||Tb(t,n,a,r,p,c,l))?(d||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),i.props=r,i.state=c,i.context=l,r=a):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,RE(e,t),a=t.memoizedProps,l=t.type===t.elementType?a:Ir(t.type,a),i.props=l,d=t.pendingProps,p=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=yr(c):(c=$n(n)?Ci:rn.current,c=Qa(t,c));var f=n.getDerivedStateFromProps;(u=typeof f=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(a!==d||p!==c)&&$b(t,i,r,c),ms=!1,p=t.memoizedState,i.state=p,vp(t,r,i,o);var y=t.memoizedState;a!==d||p!==y||Tn.current||ms?(typeof f=="function"&&(gS(t,n,f,r),y=t.memoizedState),(l=ms||Tb(t,n,l,r,p,y,c)||!1)?(u||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,y,c),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,y,c)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),i.props=r,i.state=y,i.context=c,r=l):(typeof i.componentDidUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return vS(e,t,n,r,s,o)}function vS(e,t,n,r,o,s){c_(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return o&&wb(t,n,!1),Uo(e,t,s);r=t.stateNode,HR.current=t;var a=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=ec(t,e.child,null,s),t.child=ec(t,null,a,s)):un(e,t,a,s),t.memoizedState=r.state,o&&wb(t,n,!0),t.child}function l_(e){var t=e.stateNode;t.pendingContext?xb(e,t.pendingContext,t.pendingContext!==t.context):t.context&&xb(e,t.context,!1),p0(e,t.containerInfo)}function Lb(e,t,n,r,o){return Ja(),a0(o),t.flags|=256,un(e,t,n,r),t.child}var xS={dehydrated:null,treeContext:null,retryLane:0};function wS(e){return{baseLanes:e,cachePool:null,transitions:null}}function u_(e,t,n){var r=t.pendingProps,o=it.current,s=!1,i=(t.flags&128)!==0,a;if((a=i)||(a=e!==null&&e.memoizedState===null?!1:(o&2)!==0),a?(s=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(o|=1),Ge(it,o&1),e===null)return pS(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(i=r.children,e=r.fallback,s?(r=t.mode,s=t.child,i={mode:"hidden",children:i},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=i):s=If(i,r,0,null),e=bi(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=wS(n),t.memoizedState=xS,e):w0(t,i));if(o=e.memoizedState,o!==null&&(a=o.dehydrated,a!==null))return KR(e,t,i,r,a,o,n);if(s){s=r.fallback,i=t.mode,o=e.child,a=o.sibling;var c={mode:"hidden",children:r.children};return!(i&1)&&t.child!==o?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=As(o,c),r.subtreeFlags=o.subtreeFlags&14680064),a!==null?s=As(a,s):(s=bi(s,i,n,null),s.flags|=2),s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,i=e.child.memoizedState,i=i===null?wS(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},s.memoizedState=i,s.childLanes=e.childLanes&~n,t.memoizedState=xS,r}return s=e.child,e=s.sibling,r=As(s,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function w0(e,t){return t=If({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function fd(e,t,n,r){return r!==null&&a0(r),ec(t,e.child,null,n),e=w0(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function KR(e,t,n,r,o,s,i){if(n)return t.flags&256?(t.flags&=-257,r=Qg(Error(Y(422))),fd(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,o=t.mode,r=If({mode:"visible",children:r.children},o,0,null),s=bi(s,o,i,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&ec(t,e.child,null,i),t.child.memoizedState=wS(i),t.memoizedState=xS,s);if(!(t.mode&1))return fd(e,t,i,null);if(o.data==="$!"){if(r=o.nextSibling&&o.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(Y(419)),r=Qg(s,r,void 0),fd(e,t,i,r)}if(a=(i&e.childLanes)!==0,En||a){if(r=At,r!==null){switch(i&-i){case 4:o=2;break;case 16:o=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:o=32;break;case 536870912:o=268435456;break;default:o=0}o=o&(r.suspendedLanes|i)?0:o,o!==0&&o!==s.retryLane&&(s.retryLane=o,Bo(e,o),Rr(r,e,o,-1))}return _0(),r=Qg(Error(Y(421))),fd(e,t,i,r)}return o.data==="$?"?(t.flags|=128,t.child=e.child,t=r3.bind(null,e),o._reactRetry=t,null):(e=s.treeContext,Yn=ks(o.nextSibling),Xn=t,rt=!0,$r=null,e!==null&&(dr[hr++]=Mo,dr[hr++]=Ao,dr[hr++]=Ii,Mo=e.id,Ao=e.overflow,Ii=t),t=w0(t,r.children),t.flags|=4096,t)}function Fb(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),fS(e.return,t,n)}function Jg(e,t,n,r,o){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:o}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=o)}function d_(e,t,n){var r=t.pendingProps,o=r.revealOrder,s=r.tail;if(un(e,t,r.children,n),r=it.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Fb(e,n,t);else if(e.tag===19)Fb(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ge(it,r),!(t.mode&1))t.memoizedState=null;else switch(o){case"forwards":for(n=t.child,o=null;n!==null;)e=n.alternate,e!==null&&xp(e)===null&&(o=n),n=n.sibling;n=o,n===null?(o=t.child,t.child=null):(o=n.sibling,n.sibling=null),Jg(t,!1,o,n,s);break;case"backwards":for(n=null,o=t.child,t.child=null;o!==null;){if(e=o.alternate,e!==null&&xp(e)===null){t.child=o;break}e=o.sibling,o.sibling=n,n=o,o=e}Jg(t,!0,n,null,s);break;case"together":Jg(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function uh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Uo(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),_i|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Y(153));if(t.child!==null){for(e=t.child,n=As(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=As(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function WR(e,t,n){switch(t.tag){case 3:l_(t),Ja();break;case 5:LE(t);break;case 1:$n(t.type)&&fp(t);break;case 4:p0(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,o=t.memoizedProps.value;Ge(yp,r._currentValue),r._currentValue=o;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Ge(it,it.current&1),t.flags|=128,null):n&t.child.childLanes?u_(e,t,n):(Ge(it,it.current&1),e=Uo(e,t,n),e!==null?e.sibling:null);Ge(it,it.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return d_(e,t,n);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),Ge(it,it.current),r)break;return null;case 22:case 23:return t.lanes=0,a_(e,t,n)}return Uo(e,t,n)}var h_,bS,p_,f_;h_=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};bS=function(){};p_=function(e,t,n,r){var o=e.memoizedProps;if(o!==r){e=t.stateNode,gi(no.current);var s=null;switch(n){case"input":o=Ky(e,o),r=Ky(e,r),s=[];break;case"select":o=ut({},o,{value:void 0}),r=ut({},r,{value:void 0}),s=[];break;case"textarea":o=Gy(e,o),r=Gy(e,r),s=[];break;default:typeof o.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=hp)}Xy(n,r);var i;n=null;for(l in o)if(!r.hasOwnProperty(l)&&o.hasOwnProperty(l)&&o[l]!=null)if(l==="style"){var a=o[l];for(i in a)a.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else l!=="dangerouslySetInnerHTML"&&l!=="children"&&l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&l!=="autoFocus"&&(Ll.hasOwnProperty(l)?s||(s=[]):(s=s||[]).push(l,null));for(l in r){var c=r[l];if(a=o!=null?o[l]:void 0,r.hasOwnProperty(l)&&c!==a&&(c!=null||a!=null))if(l==="style")if(a){for(i in a)!a.hasOwnProperty(i)||c&&c.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in c)c.hasOwnProperty(i)&&a[i]!==c[i]&&(n||(n={}),n[i]=c[i])}else n||(s||(s=[]),s.push(l,n)),n=c;else l==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,a=a?a.__html:void 0,c!=null&&a!==c&&(s=s||[]).push(l,c)):l==="children"?typeof c!="string"&&typeof c!="number"||(s=s||[]).push(l,""+c):l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&(Ll.hasOwnProperty(l)?(c!=null&&l==="onScroll"&&Qe("scroll",e),s||a===c||(s=[])):(s=s||[]).push(l,c))}n&&(s=s||[]).push("style",n);var l=s;(t.updateQueue=l)&&(t.flags|=4)}};f_=function(e,t,n,r){n!==r&&(t.flags|=4)};function Kc(e,t){if(!rt)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Gt(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags&14680064,r|=o.flags&14680064,o.return=e,o=o.sibling;else for(o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,o.return=e,o=o.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function VR(e,t,n){var r=t.pendingProps;switch(i0(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gt(t),null;case 1:return $n(t.type)&&pp(),Gt(t),null;case 3:return r=t.stateNode,tc(),tt(Tn),tt(rn),g0(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(hd(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,$r!==null&&($S($r),$r=null))),bS(e,t),Gt(t),null;case 5:f0(t);var o=gi(Xl.current);if(n=t.type,e!==null&&t.stateNode!=null)p_(e,t,n,r,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Y(166));return Gt(t),null}if(e=gi(no.current),hd(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[qr]=t,r[Gl]=s,e=(t.mode&1)!==0,n){case"dialog":Qe("cancel",r),Qe("close",r);break;case"iframe":case"object":case"embed":Qe("load",r);break;case"video":case"audio":for(o=0;o<hl.length;o++)Qe(hl[o],r);break;case"source":Qe("error",r);break;case"img":case"image":case"link":Qe("error",r),Qe("load",r);break;case"details":Qe("toggle",r);break;case"input":Gw(r,s),Qe("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},Qe("invalid",r);break;case"textarea":Xw(r,s),Qe("invalid",r)}Xy(n,s),o=null;for(var i in s)if(s.hasOwnProperty(i)){var a=s[i];i==="children"?typeof a=="string"?r.textContent!==a&&(s.suppressHydrationWarning!==!0&&dd(r.textContent,a,e),o=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(s.suppressHydrationWarning!==!0&&dd(r.textContent,a,e),o=["children",""+a]):Ll.hasOwnProperty(i)&&a!=null&&i==="onScroll"&&Qe("scroll",r)}switch(n){case"input":rd(r),Yw(r,s,!0);break;case"textarea":rd(r),qw(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=hp)}r=o,t.updateQueue=r,r!==null&&(t.flags|=4)}else{i=o.nodeType===9?o:o.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=UI(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[qr]=t,e[Gl]=r,h_(e,t,!1,!1),t.stateNode=e;e:{switch(i=qy(n,r),n){case"dialog":Qe("cancel",e),Qe("close",e),o=r;break;case"iframe":case"object":case"embed":Qe("load",e),o=r;break;case"video":case"audio":for(o=0;o<hl.length;o++)Qe(hl[o],e);o=r;break;case"source":Qe("error",e),o=r;break;case"img":case"image":case"link":Qe("error",e),Qe("load",e),o=r;break;case"details":Qe("toggle",e),o=r;break;case"input":Gw(e,r),o=Ky(e,r),Qe("invalid",e);break;case"option":o=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},o=ut({},r,{value:void 0}),Qe("invalid",e);break;case"textarea":Xw(e,r),o=Gy(e,r),Qe("invalid",e);break;default:o=r}Xy(n,o),a=o;for(s in a)if(a.hasOwnProperty(s)){var c=a[s];s==="style"?WI(e,c):s==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&HI(e,c)):s==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Fl(e,c):typeof c=="number"&&Fl(e,""+c):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Ll.hasOwnProperty(s)?c!=null&&s==="onScroll"&&Qe("scroll",e):c!=null&&Wv(e,s,c,i))}switch(n){case"input":rd(e),Yw(e,r,!1);break;case"textarea":rd(e),qw(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Ds(r.value));break;case"select":e.multiple=!!r.multiple,s=r.value,s!=null?La(e,!!r.multiple,s,!1):r.defaultValue!=null&&La(e,!!r.multiple,r.defaultValue,!0);break;default:typeof o.onClick=="function"&&(e.onclick=hp)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Gt(t),null;case 6:if(e&&t.stateNode!=null)f_(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Y(166));if(n=gi(Xl.current),gi(no.current),hd(t)){if(r=t.stateNode,n=t.memoizedProps,r[qr]=t,(s=r.nodeValue!==n)&&(e=Xn,e!==null))switch(e.tag){case 3:dd(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&dd(r.nodeValue,n,(e.mode&1)!==0)}s&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[qr]=t,t.stateNode=r}return Gt(t),null;case 13:if(tt(it),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(rt&&Yn!==null&&t.mode&1&&!(t.flags&128))AE(),Ja(),t.flags|=98560,s=!1;else if(s=hd(t),r!==null&&r.dehydrated!==null){if(e===null){if(!s)throw Error(Y(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(Y(317));s[qr]=t}else Ja(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Gt(t),s=!1}else $r!==null&&($S($r),$r=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||it.current&1?Et===0&&(Et=3):_0())),t.updateQueue!==null&&(t.flags|=4),Gt(t),null);case 4:return tc(),bS(e,t),e===null&&Wl(t.stateNode.containerInfo),Gt(t),null;case 10:return u0(t.type._context),Gt(t),null;case 17:return $n(t.type)&&pp(),Gt(t),null;case 19:if(tt(it),s=t.memoizedState,s===null)return Gt(t),null;if(r=(t.flags&128)!==0,i=s.rendering,i===null)if(r)Kc(s,!1);else{if(Et!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=xp(e),i!==null){for(t.flags|=128,Kc(s,!1),r=i.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)s=n,e=r,s.flags&=14680066,i=s.alternate,i===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=i.childLanes,s.lanes=i.lanes,s.child=i.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=i.memoizedProps,s.memoizedState=i.memoizedState,s.updateQueue=i.updateQueue,s.type=i.type,e=i.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Ge(it,it.current&1|2),t.child}e=e.sibling}s.tail!==null&&St()>rc&&(t.flags|=128,r=!0,Kc(s,!1),t.lanes=4194304)}else{if(!r)if(e=xp(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Kc(s,!0),s.tail===null&&s.tailMode==="hidden"&&!i.alternate&&!rt)return Gt(t),null}else 2*St()-s.renderingStartTime>rc&&n!==1073741824&&(t.flags|=128,r=!0,Kc(s,!1),t.lanes=4194304);s.isBackwards?(i.sibling=t.child,t.child=i):(n=s.last,n!==null?n.sibling=i:t.child=i,s.last=i)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=St(),t.sibling=null,n=it.current,Ge(it,r?n&1|2:n&1),t):(Gt(t),null);case 22:case 23:return E0(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Hn&1073741824&&(Gt(t),t.subtreeFlags&6&&(t.flags|=8192)):Gt(t),null;case 24:return null;case 25:return null}throw Error(Y(156,t.tag))}function GR(e,t){switch(i0(t),t.tag){case 1:return $n(t.type)&&pp(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return tc(),tt(Tn),tt(rn),g0(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return f0(t),null;case 13:if(tt(it),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Y(340));Ja()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return tt(it),null;case 4:return tc(),null;case 10:return u0(t.type._context),null;case 22:case 23:return E0(),null;case 24:return null;default:return null}}var gd=!1,Qt=!1,YR=typeof WeakSet=="function"?WeakSet:Set,te=null;function Ea(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ft(e,t,r)}else n.current=null}function PS(e,t,n){try{n()}catch(r){ft(e,t,r)}}var Nb=!1;function XR(e,t){if(iS=lp,e=vE(),o0(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var i=0,a=-1,c=-1,l=0,u=0,d=e,p=null;t:for(;;){for(var f;d!==n||o!==0&&d.nodeType!==3||(a=i+o),d!==s||r!==0&&d.nodeType!==3||(c=i+r),d.nodeType===3&&(i+=d.nodeValue.length),(f=d.firstChild)!==null;)p=d,d=f;for(;;){if(d===e)break t;if(p===n&&++l===o&&(a=i),p===s&&++u===r&&(c=i),(f=d.nextSibling)!==null)break;d=p,p=d.parentNode}d=f}n=a===-1||c===-1?null:{start:a,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(aS={focusedElem:e,selectionRange:n},lp=!1,te=t;te!==null;)if(t=te,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,te=e;else for(;te!==null;){t=te;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var g=y.memoizedProps,w=y.memoizedState,S=t.stateNode,v=S.getSnapshotBeforeUpdate(t.elementType===t.type?g:Ir(t.type,g),w);S.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var b=t.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Y(163))}}catch(E){ft(t,t.return,E)}if(e=t.sibling,e!==null){e.return=t.return,te=e;break}te=t.return}return y=Nb,Nb=!1,y}function Il(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var s=o.destroy;o.destroy=void 0,s!==void 0&&PS(t,n,s)}o=o.next}while(o!==r)}}function Pf(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function CS(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function g_(e){var t=e.alternate;t!==null&&(e.alternate=null,g_(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[qr],delete t[Gl],delete t[uS],delete t[MR],delete t[AR])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function m_(e){return e.tag===5||e.tag===3||e.tag===4}function zb(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||m_(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function IS(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=hp));else if(r!==4&&(e=e.child,e!==null))for(IS(e,t,n),e=e.sibling;e!==null;)IS(e,t,n),e=e.sibling}function ES(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ES(e,t,n),e=e.sibling;e!==null;)ES(e,t,n),e=e.sibling}var Rt=null,Er=!1;function ls(e,t,n){for(n=n.child;n!==null;)y_(e,t,n),n=n.sibling}function y_(e,t,n){if(to&&typeof to.onCommitFiberUnmount=="function")try{to.onCommitFiberUnmount(gf,n)}catch{}switch(n.tag){case 5:Qt||Ea(n,t);case 6:var r=Rt,o=Er;Rt=null,ls(e,t,n),Rt=r,Er=o,Rt!==null&&(Er?(e=Rt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Rt.removeChild(n.stateNode));break;case 18:Rt!==null&&(Er?(e=Rt,n=n.stateNode,e.nodeType===8?Vg(e.parentNode,n):e.nodeType===1&&Vg(e,n),Ul(e)):Vg(Rt,n.stateNode));break;case 4:r=Rt,o=Er,Rt=n.stateNode.containerInfo,Er=!0,ls(e,t,n),Rt=r,Er=o;break;case 0:case 11:case 14:case 15:if(!Qt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var s=o,i=s.destroy;s=s.tag,i!==void 0&&(s&2||s&4)&&PS(n,t,i),o=o.next}while(o!==r)}ls(e,t,n);break;case 1:if(!Qt&&(Ea(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){ft(n,t,a)}ls(e,t,n);break;case 21:ls(e,t,n);break;case 22:n.mode&1?(Qt=(r=Qt)||n.memoizedState!==null,ls(e,t,n),Qt=r):ls(e,t,n);break;default:ls(e,t,n)}}function Bb(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new YR),t.forEach(function(r){var o=o3.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function Cr(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var o=n[r];try{var s=e,i=t,a=i;e:for(;a!==null;){switch(a.tag){case 5:Rt=a.stateNode,Er=!1;break e;case 3:Rt=a.stateNode.containerInfo,Er=!0;break e;case 4:Rt=a.stateNode.containerInfo,Er=!0;break e}a=a.return}if(Rt===null)throw Error(Y(160));y_(s,i,o),Rt=null,Er=!1;var c=o.alternate;c!==null&&(c.return=null),o.return=null}catch(l){ft(o,t,l)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)S_(t,e),t=t.sibling}function S_(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Cr(t,e),Vr(e),r&4){try{Il(3,e,e.return),Pf(3,e)}catch(g){ft(e,e.return,g)}try{Il(5,e,e.return)}catch(g){ft(e,e.return,g)}}break;case 1:Cr(t,e),Vr(e),r&512&&n!==null&&Ea(n,n.return);break;case 5:if(Cr(t,e),Vr(e),r&512&&n!==null&&Ea(n,n.return),e.flags&32){var o=e.stateNode;try{Fl(o,"")}catch(g){ft(e,e.return,g)}}if(r&4&&(o=e.stateNode,o!=null)){var s=e.memoizedProps,i=n!==null?n.memoizedProps:s,a=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{a==="input"&&s.type==="radio"&&s.name!=null&&zI(o,s),qy(a,i);var l=qy(a,s);for(i=0;i<c.length;i+=2){var u=c[i],d=c[i+1];u==="style"?WI(o,d):u==="dangerouslySetInnerHTML"?HI(o,d):u==="children"?Fl(o,d):Wv(o,u,d,l)}switch(a){case"input":Wy(o,s);break;case"textarea":BI(o,s);break;case"select":var p=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!s.multiple;var f=s.value;f!=null?La(o,!!s.multiple,f,!1):p!==!!s.multiple&&(s.defaultValue!=null?La(o,!!s.multiple,s.defaultValue,!0):La(o,!!s.multiple,s.multiple?[]:"",!1))}o[Gl]=s}catch(g){ft(e,e.return,g)}}break;case 6:if(Cr(t,e),Vr(e),r&4){if(e.stateNode===null)throw Error(Y(162));o=e.stateNode,s=e.memoizedProps;try{o.nodeValue=s}catch(g){ft(e,e.return,g)}}break;case 3:if(Cr(t,e),Vr(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Ul(t.containerInfo)}catch(g){ft(e,e.return,g)}break;case 4:Cr(t,e),Vr(e);break;case 13:Cr(t,e),Vr(e),o=e.child,o.flags&8192&&(s=o.memoizedState!==null,o.stateNode.isHidden=s,!s||o.alternate!==null&&o.alternate.memoizedState!==null||(C0=St())),r&4&&Bb(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(Qt=(l=Qt)||u,Cr(t,e),Qt=l):Cr(t,e),Vr(e),r&8192){if(l=e.memoizedState!==null,(e.stateNode.isHidden=l)&&!u&&e.mode&1)for(te=e,u=e.child;u!==null;){for(d=te=u;te!==null;){switch(p=te,f=p.child,p.tag){case 0:case 11:case 14:case 15:Il(4,p,p.return);break;case 1:Ea(p,p.return);var y=p.stateNode;if(typeof y.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(g){ft(r,n,g)}}break;case 5:Ea(p,p.return);break;case 22:if(p.memoizedState!==null){Hb(d);continue}}f!==null?(f.return=p,te=f):Hb(d)}u=u.sibling}e:for(u=null,d=e;;){if(d.tag===5){if(u===null){u=d;try{o=d.stateNode,l?(s=o.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(a=d.stateNode,c=d.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,a.style.display=KI("display",i))}catch(g){ft(e,e.return,g)}}}else if(d.tag===6){if(u===null)try{d.stateNode.nodeValue=l?"":d.memoizedProps}catch(g){ft(e,e.return,g)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===e)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;d.sibling===null;){if(d.return===null||d.return===e)break e;u===d&&(u=null),d=d.return}u===d&&(u=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:Cr(t,e),Vr(e),r&4&&Bb(e);break;case 21:break;default:Cr(t,e),Vr(e)}}function Vr(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(m_(n)){var r=n;break e}n=n.return}throw Error(Y(160))}switch(r.tag){case 5:var o=r.stateNode;r.flags&32&&(Fl(o,""),r.flags&=-33);var s=zb(e);ES(e,s,o);break;case 3:case 4:var i=r.stateNode.containerInfo,a=zb(e);IS(e,a,i);break;default:throw Error(Y(161))}}catch(c){ft(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function qR(e,t,n){te=e,v_(e)}function v_(e,t,n){for(var r=(e.mode&1)!==0;te!==null;){var o=te,s=o.child;if(o.tag===22&&r){var i=o.memoizedState!==null||gd;if(!i){var a=o.alternate,c=a!==null&&a.memoizedState!==null||Qt;a=gd;var l=Qt;if(gd=i,(Qt=c)&&!l)for(te=o;te!==null;)i=te,c=i.child,i.tag===22&&i.memoizedState!==null?Kb(o):c!==null?(c.return=i,te=c):Kb(o);for(;s!==null;)te=s,v_(s),s=s.sibling;te=o,gd=a,Qt=l}Ub(e)}else o.subtreeFlags&8772&&s!==null?(s.return=o,te=s):Ub(e)}}function Ub(e){for(;te!==null;){var t=te;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Qt||Pf(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Qt)if(n===null)r.componentDidMount();else{var o=t.elementType===t.type?n.memoizedProps:Ir(t.type,n.memoizedProps);r.componentDidUpdate(o,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;s!==null&&Eb(t,s,r);break;case 3:var i=t.updateQueue;if(i!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Eb(t,i,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var l=t.alternate;if(l!==null){var u=l.memoizedState;if(u!==null){var d=u.dehydrated;d!==null&&Ul(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Y(163))}Qt||t.flags&512&&CS(t)}catch(p){ft(t,t.return,p)}}if(t===e){te=null;break}if(n=t.sibling,n!==null){n.return=t.return,te=n;break}te=t.return}}function Hb(e){for(;te!==null;){var t=te;if(t===e){te=null;break}var n=t.sibling;if(n!==null){n.return=t.return,te=n;break}te=t.return}}function Kb(e){for(;te!==null;){var t=te;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Pf(4,t)}catch(c){ft(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var o=t.return;try{r.componentDidMount()}catch(c){ft(t,o,c)}}var s=t.return;try{CS(t)}catch(c){ft(t,s,c)}break;case 5:var i=t.return;try{CS(t)}catch(c){ft(t,i,c)}}}catch(c){ft(t,t.return,c)}if(t===e){te=null;break}var a=t.sibling;if(a!==null){a.return=t.return,te=a;break}te=t.return}}var ZR=Math.ceil,Pp=Xo.ReactCurrentDispatcher,b0=Xo.ReactCurrentOwner,gr=Xo.ReactCurrentBatchConfig,_e=0,At=null,Ct=null,Bt=0,Hn=0,_a=Ws(0),Et=0,Jl=null,_i=0,Cf=0,P0=0,El=null,Pn=null,C0=0,rc=1/0,_o=null,Cp=!1,_S=null,$s=null,md=!1,bs=null,Ip=0,_l=0,kS=null,dh=-1,hh=0;function gn(){return _e&6?St():dh!==-1?dh:dh=St()}function Ms(e){return e.mode&1?_e&2&&Bt!==0?Bt&-Bt:OR.transition!==null?(hh===0&&(hh=rE()),hh):(e=Fe,e!==0||(e=window.event,e=e===void 0?16:uE(e.type)),e):1}function Rr(e,t,n,r){if(50<_l)throw _l=0,kS=null,Error(Y(185));Iu(e,n,r),(!(_e&2)||e!==At)&&(e===At&&(!(_e&2)&&(Cf|=n),Et===4&&Ss(e,Bt)),Mn(e,r),n===1&&_e===0&&!(t.mode&1)&&(rc=St()+500,xf&&Vs()))}function Mn(e,t){var n=e.callbackNode;OD(e,t);var r=cp(e,e===At?Bt:0);if(r===0)n!==null&&Jw(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Jw(n),t===1)e.tag===0?jR(Wb.bind(null,e)):TE(Wb.bind(null,e)),TR(function(){!(_e&6)&&Vs()}),n=null;else{switch(oE(r)){case 1:n=qv;break;case 4:n=tE;break;case 16:n=ap;break;case 536870912:n=nE;break;default:n=ap}n=__(n,x_.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function x_(e,t){if(dh=-1,hh=0,_e&6)throw Error(Y(327));var n=e.callbackNode;if(Ua()&&e.callbackNode!==n)return null;var r=cp(e,e===At?Bt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Ep(e,r);else{t=r;var o=_e;_e|=2;var s=b_();(At!==e||Bt!==t)&&(_o=null,rc=St()+500,wi(e,t));do try{e3();break}catch(a){w_(e,a)}while(!0);l0(),Pp.current=s,_e=o,Ct!==null?t=0:(At=null,Bt=0,t=Et)}if(t!==0){if(t===2&&(o=tS(e),o!==0&&(r=o,t=TS(e,o))),t===1)throw n=Jl,wi(e,0),Ss(e,r),Mn(e,St()),n;if(t===6)Ss(e,r);else{if(o=e.current.alternate,!(r&30)&&!QR(o)&&(t=Ep(e,r),t===2&&(s=tS(e),s!==0&&(r=s,t=TS(e,s))),t===1))throw n=Jl,wi(e,0),Ss(e,r),Mn(e,St()),n;switch(e.finishedWork=o,e.finishedLanes=r,t){case 0:case 1:throw Error(Y(345));case 2:di(e,Pn,_o);break;case 3:if(Ss(e,r),(r&130023424)===r&&(t=C0+500-St(),10<t)){if(cp(e,0)!==0)break;if(o=e.suspendedLanes,(o&r)!==r){gn(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=lS(di.bind(null,e,Pn,_o),t);break}di(e,Pn,_o);break;case 4:if(Ss(e,r),(r&4194240)===r)break;for(t=e.eventTimes,o=-1;0<r;){var i=31-Dr(r);s=1<<i,i=t[i],i>o&&(o=i),r&=~s}if(r=o,r=St()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*ZR(r/1960))-r,10<r){e.timeoutHandle=lS(di.bind(null,e,Pn,_o),r);break}di(e,Pn,_o);break;case 5:di(e,Pn,_o);break;default:throw Error(Y(329))}}}return Mn(e,St()),e.callbackNode===n?x_.bind(null,e):null}function TS(e,t){var n=El;return e.current.memoizedState.isDehydrated&&(wi(e,t).flags|=256),e=Ep(e,t),e!==2&&(t=Pn,Pn=n,t!==null&&$S(t)),e}function $S(e){Pn===null?Pn=e:Pn.push.apply(Pn,e)}function QR(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var o=n[r],s=o.getSnapshot;o=o.value;try{if(!zr(s(),o))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ss(e,t){for(t&=~P0,t&=~Cf,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Dr(t),r=1<<n;e[n]=-1,t&=~r}}function Wb(e){if(_e&6)throw Error(Y(327));Ua();var t=cp(e,0);if(!(t&1))return Mn(e,St()),null;var n=Ep(e,t);if(e.tag!==0&&n===2){var r=tS(e);r!==0&&(t=r,n=TS(e,r))}if(n===1)throw n=Jl,wi(e,0),Ss(e,t),Mn(e,St()),n;if(n===6)throw Error(Y(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,di(e,Pn,_o),Mn(e,St()),null}function I0(e,t){var n=_e;_e|=1;try{return e(t)}finally{_e=n,_e===0&&(rc=St()+500,xf&&Vs())}}function ki(e){bs!==null&&bs.tag===0&&!(_e&6)&&Ua();var t=_e;_e|=1;var n=gr.transition,r=Fe;try{if(gr.transition=null,Fe=1,e)return e()}finally{Fe=r,gr.transition=n,_e=t,!(_e&6)&&Vs()}}function E0(){Hn=_a.current,tt(_a)}function wi(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,kR(n)),Ct!==null)for(n=Ct.return;n!==null;){var r=n;switch(i0(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&pp();break;case 3:tc(),tt(Tn),tt(rn),g0();break;case 5:f0(r);break;case 4:tc();break;case 13:tt(it);break;case 19:tt(it);break;case 10:u0(r.type._context);break;case 22:case 23:E0()}n=n.return}if(At=e,Ct=e=As(e.current,null),Bt=Hn=t,Et=0,Jl=null,P0=Cf=_i=0,Pn=El=null,fi!==null){for(t=0;t<fi.length;t++)if(n=fi[t],r=n.interleaved,r!==null){n.interleaved=null;var o=r.next,s=n.pending;if(s!==null){var i=s.next;s.next=o,r.next=i}n.pending=r}fi=null}return e}function w_(e,t){do{var n=Ct;try{if(l0(),ch.current=bp,wp){for(var r=lt.memoizedState;r!==null;){var o=r.queue;o!==null&&(o.pending=null),r=r.next}wp=!1}if(Ei=0,Tt=It=lt=null,Cl=!1,ql=0,b0.current=null,n===null||n.return===null){Et=1,Jl=t,Ct=null;break}e:{var s=e,i=n.return,a=n,c=t;if(t=Bt,a.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var l=c,u=a,d=u.tag;if(!(u.mode&1)&&(d===0||d===11||d===15)){var p=u.alternate;p?(u.updateQueue=p.updateQueue,u.memoizedState=p.memoizedState,u.lanes=p.lanes):(u.updateQueue=null,u.memoizedState=null)}var f=Ab(i);if(f!==null){f.flags&=-257,jb(f,i,a,s,t),f.mode&1&&Mb(s,l,t),t=f,c=l;var y=t.updateQueue;if(y===null){var g=new Set;g.add(c),t.updateQueue=g}else y.add(c);break e}else{if(!(t&1)){Mb(s,l,t),_0();break e}c=Error(Y(426))}}else if(rt&&a.mode&1){var w=Ab(i);if(w!==null){!(w.flags&65536)&&(w.flags|=256),jb(w,i,a,s,t),a0(nc(c,a));break e}}s=c=nc(c,a),Et!==4&&(Et=2),El===null?El=[s]:El.push(s),s=i;do{switch(s.tag){case 3:s.flags|=65536,t&=-t,s.lanes|=t;var S=o_(s,c,t);Ib(s,S);break e;case 1:a=c;var v=s.type,b=s.stateNode;if(!(s.flags&128)&&(typeof v.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&($s===null||!$s.has(b)))){s.flags|=65536,t&=-t,s.lanes|=t;var E=s_(s,a,t);Ib(s,E);break e}}s=s.return}while(s!==null)}C_(n)}catch(C){t=C,Ct===n&&n!==null&&(Ct=n=n.return);continue}break}while(!0)}function b_(){var e=Pp.current;return Pp.current=bp,e===null?bp:e}function _0(){(Et===0||Et===3||Et===2)&&(Et=4),At===null||!(_i&268435455)&&!(Cf&268435455)||Ss(At,Bt)}function Ep(e,t){var n=_e;_e|=2;var r=b_();(At!==e||Bt!==t)&&(_o=null,wi(e,t));do try{JR();break}catch(o){w_(e,o)}while(!0);if(l0(),_e=n,Pp.current=r,Ct!==null)throw Error(Y(261));return At=null,Bt=0,Et}function JR(){for(;Ct!==null;)P_(Ct)}function e3(){for(;Ct!==null&&!ID();)P_(Ct)}function P_(e){var t=E_(e.alternate,e,Hn);e.memoizedProps=e.pendingProps,t===null?C_(e):Ct=t,b0.current=null}function C_(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=GR(n,t),n!==null){n.flags&=32767,Ct=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Et=6,Ct=null;return}}else if(n=VR(n,t,Hn),n!==null){Ct=n;return}if(t=t.sibling,t!==null){Ct=t;return}Ct=t=e}while(t!==null);Et===0&&(Et=5)}function di(e,t,n){var r=Fe,o=gr.transition;try{gr.transition=null,Fe=1,t3(e,t,n,r)}finally{gr.transition=o,Fe=r}return null}function t3(e,t,n,r){do Ua();while(bs!==null);if(_e&6)throw Error(Y(327));n=e.finishedWork;var o=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Y(177));e.callbackNode=null,e.callbackPriority=0;var s=n.lanes|n.childLanes;if(DD(e,s),e===At&&(Ct=At=null,Bt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||md||(md=!0,__(ap,function(){return Ua(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=gr.transition,gr.transition=null;var i=Fe;Fe=1;var a=_e;_e|=4,b0.current=null,XR(e,n),S_(n,e),wR(aS),lp=!!iS,aS=iS=null,e.current=n,qR(n),ED(),_e=a,Fe=i,gr.transition=s}else e.current=n;if(md&&(md=!1,bs=e,Ip=o),s=e.pendingLanes,s===0&&($s=null),TD(n.stateNode),Mn(e,St()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)o=t[n],r(o.value,{componentStack:o.stack,digest:o.digest});if(Cp)throw Cp=!1,e=_S,_S=null,e;return Ip&1&&e.tag!==0&&Ua(),s=e.pendingLanes,s&1?e===kS?_l++:(_l=0,kS=e):_l=0,Vs(),null}function Ua(){if(bs!==null){var e=oE(Ip),t=gr.transition,n=Fe;try{if(gr.transition=null,Fe=16>e?16:e,bs===null)var r=!1;else{if(e=bs,bs=null,Ip=0,_e&6)throw Error(Y(331));var o=_e;for(_e|=4,te=e.current;te!==null;){var s=te,i=s.child;if(te.flags&16){var a=s.deletions;if(a!==null){for(var c=0;c<a.length;c++){var l=a[c];for(te=l;te!==null;){var u=te;switch(u.tag){case 0:case 11:case 15:Il(8,u,s)}var d=u.child;if(d!==null)d.return=u,te=d;else for(;te!==null;){u=te;var p=u.sibling,f=u.return;if(g_(u),u===l){te=null;break}if(p!==null){p.return=f,te=p;break}te=f}}}var y=s.alternate;if(y!==null){var g=y.child;if(g!==null){y.child=null;do{var w=g.sibling;g.sibling=null,g=w}while(g!==null)}}te=s}}if(s.subtreeFlags&2064&&i!==null)i.return=s,te=i;else e:for(;te!==null;){if(s=te,s.flags&2048)switch(s.tag){case 0:case 11:case 15:Il(9,s,s.return)}var S=s.sibling;if(S!==null){S.return=s.return,te=S;break e}te=s.return}}var v=e.current;for(te=v;te!==null;){i=te;var b=i.child;if(i.subtreeFlags&2064&&b!==null)b.return=i,te=b;else e:for(i=v;te!==null;){if(a=te,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:Pf(9,a)}}catch(C){ft(a,a.return,C)}if(a===i){te=null;break e}var E=a.sibling;if(E!==null){E.return=a.return,te=E;break e}te=a.return}}if(_e=o,Vs(),to&&typeof to.onPostCommitFiberRoot=="function")try{to.onPostCommitFiberRoot(gf,e)}catch{}r=!0}return r}finally{Fe=n,gr.transition=t}}return!1}function Vb(e,t,n){t=nc(n,t),t=o_(e,t,1),e=Ts(e,t,1),t=gn(),e!==null&&(Iu(e,1,t),Mn(e,t))}function ft(e,t,n){if(e.tag===3)Vb(e,e,n);else for(;t!==null;){if(t.tag===3){Vb(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&($s===null||!$s.has(r))){e=nc(n,e),e=s_(t,e,1),t=Ts(t,e,1),e=gn(),t!==null&&(Iu(t,1,e),Mn(t,e));break}}t=t.return}}function n3(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=gn(),e.pingedLanes|=e.suspendedLanes&n,At===e&&(Bt&n)===n&&(Et===4||Et===3&&(Bt&130023424)===Bt&&500>St()-C0?wi(e,0):P0|=n),Mn(e,t)}function I_(e,t){t===0&&(e.mode&1?(t=id,id<<=1,!(id&130023424)&&(id=4194304)):t=1);var n=gn();e=Bo(e,t),e!==null&&(Iu(e,t,n),Mn(e,n))}function r3(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),I_(e,n)}function o3(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Y(314))}r!==null&&r.delete(t),I_(e,n)}var E_;E_=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Tn.current)En=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return En=!1,WR(e,t,n);En=!!(e.flags&131072)}else En=!1,rt&&t.flags&1048576&&$E(t,mp,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;uh(e,t),e=t.pendingProps;var o=Qa(t,rn.current);Ba(t,n),o=y0(null,t,r,e,o,n);var s=S0();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,$n(r)?(s=!0,fp(t)):s=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,h0(t),o.updater=bf,t.stateNode=o,o._reactInternals=t,mS(t,r,e,n),t=vS(null,t,r,!0,s,n)):(t.tag=0,rt&&s&&s0(t),un(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(uh(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=i3(r),e=Ir(r,e),o){case 0:t=SS(null,t,r,e,n);break e;case 1:t=Rb(null,t,r,e,n);break e;case 11:t=Ob(null,t,r,e,n);break e;case 14:t=Db(null,t,r,Ir(r.type,e),n);break e}throw Error(Y(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Ir(r,o),SS(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Ir(r,o),Rb(e,t,r,o,n);case 3:e:{if(l_(t),e===null)throw Error(Y(387));r=t.pendingProps,s=t.memoizedState,o=s.element,RE(e,t),vp(t,r,null,n);var i=t.memoizedState;if(r=i.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){o=nc(Error(Y(423)),t),t=Lb(e,t,r,n,o);break e}else if(r!==o){o=nc(Error(Y(424)),t),t=Lb(e,t,r,n,o);break e}else for(Yn=ks(t.stateNode.containerInfo.firstChild),Xn=t,rt=!0,$r=null,n=OE(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ja(),r===o){t=Uo(e,t,n);break e}un(e,t,r,n)}t=t.child}return t;case 5:return LE(t),e===null&&pS(t),r=t.type,o=t.pendingProps,s=e!==null?e.memoizedProps:null,i=o.children,cS(r,o)?i=null:s!==null&&cS(r,s)&&(t.flags|=32),c_(e,t),un(e,t,i,n),t.child;case 6:return e===null&&pS(t),null;case 13:return u_(e,t,n);case 4:return p0(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ec(t,null,r,n):un(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Ir(r,o),Ob(e,t,r,o,n);case 7:return un(e,t,t.pendingProps,n),t.child;case 8:return un(e,t,t.pendingProps.children,n),t.child;case 12:return un(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,s=t.memoizedProps,i=o.value,Ge(yp,r._currentValue),r._currentValue=i,s!==null)if(zr(s.value,i)){if(s.children===o.children&&!Tn.current){t=Uo(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){i=s.child;for(var c=a.firstContext;c!==null;){if(c.context===r){if(s.tag===1){c=Oo(-1,n&-n),c.tag=2;var l=s.updateQueue;if(l!==null){l=l.shared;var u=l.pending;u===null?c.next=c:(c.next=u.next,u.next=c),l.pending=c}}s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),fS(s.return,n,t),a.lanes|=n;break}c=c.next}}else if(s.tag===10)i=s.type===t.type?null:s.child;else if(s.tag===18){if(i=s.return,i===null)throw Error(Y(341));i.lanes|=n,a=i.alternate,a!==null&&(a.lanes|=n),fS(i,n,t),i=s.sibling}else i=s.child;if(i!==null)i.return=s;else for(i=s;i!==null;){if(i===t){i=null;break}if(s=i.sibling,s!==null){s.return=i.return,i=s;break}i=i.return}s=i}un(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,Ba(t,n),o=yr(o),r=r(o),t.flags|=1,un(e,t,r,n),t.child;case 14:return r=t.type,o=Ir(r,t.pendingProps),o=Ir(r.type,o),Db(e,t,r,o,n);case 15:return i_(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Ir(r,o),uh(e,t),t.tag=1,$n(r)?(e=!0,fp(t)):e=!1,Ba(t,n),r_(t,r,o),mS(t,r,o,n),vS(null,t,r,!0,e,n);case 19:return d_(e,t,n);case 22:return a_(e,t,n)}throw Error(Y(156,t.tag))};function __(e,t){return eE(e,t)}function s3(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fr(e,t,n,r){return new s3(e,t,n,r)}function k0(e){return e=e.prototype,!(!e||!e.isReactComponent)}function i3(e){if(typeof e=="function")return k0(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Gv)return 11;if(e===Yv)return 14}return 2}function As(e,t){var n=e.alternate;return n===null?(n=fr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function ph(e,t,n,r,o,s){var i=2;if(r=e,typeof e=="function")k0(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case ya:return bi(n.children,o,s,t);case Vv:i=8,o|=8;break;case zy:return e=fr(12,n,t,o|2),e.elementType=zy,e.lanes=s,e;case By:return e=fr(13,n,t,o),e.elementType=By,e.lanes=s,e;case Uy:return e=fr(19,n,t,o),e.elementType=Uy,e.lanes=s,e;case LI:return If(n,o,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case DI:i=10;break e;case RI:i=9;break e;case Gv:i=11;break e;case Yv:i=14;break e;case gs:i=16,r=null;break e}throw Error(Y(130,e==null?e:typeof e,""))}return t=fr(i,n,t,o),t.elementType=e,t.type=r,t.lanes=s,t}function bi(e,t,n,r){return e=fr(7,e,r,t),e.lanes=n,e}function If(e,t,n,r){return e=fr(22,e,r,t),e.elementType=LI,e.lanes=n,e.stateNode={isHidden:!1},e}function em(e,t,n){return e=fr(6,e,null,t),e.lanes=n,e}function tm(e,t,n){return t=fr(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function a3(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Dg(0),this.expirationTimes=Dg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Dg(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function T0(e,t,n,r,o,s,i,a,c){return e=new a3(e,t,n,a,c),t===1?(t=1,s===!0&&(t|=8)):t=0,s=fr(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},h0(s),e}function c3(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ma,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function k_(e){if(!e)return Rs;e=e._reactInternals;e:{if(Bi(e)!==e||e.tag!==1)throw Error(Y(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if($n(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Y(171))}if(e.tag===1){var n=e.type;if($n(n))return kE(e,n,t)}return t}function T_(e,t,n,r,o,s,i,a,c){return e=T0(n,r,!0,e,o,s,i,a,c),e.context=k_(null),n=e.current,r=gn(),o=Ms(n),s=Oo(r,o),s.callback=t??null,Ts(n,s,o),e.current.lanes=o,Iu(e,o,r),Mn(e,r),e}function Ef(e,t,n,r){var o=t.current,s=gn(),i=Ms(o);return n=k_(n),t.context===null?t.context=n:t.pendingContext=n,t=Oo(s,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Ts(o,t,i),e!==null&&(Rr(e,o,i,s),ah(e,o,i)),i}function _p(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Gb(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function $0(e,t){Gb(e,t),(e=e.alternate)&&Gb(e,t)}function l3(){return null}var $_=typeof reportError=="function"?reportError:function(e){console.error(e)};function M0(e){this._internalRoot=e}_f.prototype.render=M0.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Y(409));Ef(e,t,null,null)};_f.prototype.unmount=M0.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ki(function(){Ef(null,e,null,null)}),t[zo]=null}};function _f(e){this._internalRoot=e}_f.prototype.unstable_scheduleHydration=function(e){if(e){var t=aE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<ys.length&&t!==0&&t<ys[n].priority;n++);ys.splice(n,0,e),n===0&&lE(e)}};function A0(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function kf(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Yb(){}function u3(e,t,n,r,o){if(o){if(typeof r=="function"){var s=r;r=function(){var l=_p(i);s.call(l)}}var i=T_(t,r,e,0,null,!1,!1,"",Yb);return e._reactRootContainer=i,e[zo]=i.current,Wl(e.nodeType===8?e.parentNode:e),ki(),i}for(;o=e.lastChild;)e.removeChild(o);if(typeof r=="function"){var a=r;r=function(){var l=_p(c);a.call(l)}}var c=T0(e,0,!1,null,null,!1,!1,"",Yb);return e._reactRootContainer=c,e[zo]=c.current,Wl(e.nodeType===8?e.parentNode:e),ki(function(){Ef(t,c,n,r)}),c}function Tf(e,t,n,r,o){var s=n._reactRootContainer;if(s){var i=s;if(typeof o=="function"){var a=o;o=function(){var c=_p(i);a.call(c)}}Ef(t,i,e,o)}else i=u3(n,t,e,o,r);return _p(i)}sE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=dl(t.pendingLanes);n!==0&&(Zv(t,n|1),Mn(t,St()),!(_e&6)&&(rc=St()+500,Vs()))}break;case 13:ki(function(){var r=Bo(e,1);if(r!==null){var o=gn();Rr(r,e,1,o)}}),$0(e,1)}};Qv=function(e){if(e.tag===13){var t=Bo(e,134217728);if(t!==null){var n=gn();Rr(t,e,134217728,n)}$0(e,134217728)}};iE=function(e){if(e.tag===13){var t=Ms(e),n=Bo(e,t);if(n!==null){var r=gn();Rr(n,e,t,r)}$0(e,t)}};aE=function(){return Fe};cE=function(e,t){var n=Fe;try{return Fe=e,t()}finally{Fe=n}};Qy=function(e,t,n){switch(t){case"input":if(Wy(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var o=vf(r);if(!o)throw Error(Y(90));NI(r),Wy(r,o)}}}break;case"textarea":BI(e,n);break;case"select":t=n.value,t!=null&&La(e,!!n.multiple,t,!1)}};YI=I0;XI=ki;var d3={usingClientEntryPoint:!1,Events:[_u,wa,vf,VI,GI,I0]},Wc={findFiberByHostInstance:pi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},h3={bundleType:Wc.bundleType,version:Wc.version,rendererPackageName:Wc.rendererPackageName,rendererConfig:Wc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Xo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=QI(e),e===null?null:e.stateNode},findFiberByHostInstance:Wc.findFiberByHostInstance||l3,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 yd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yd.isDisabled&&yd.supportsFiber)try{gf=yd.inject(h3),to=yd}catch{}}nr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=d3;nr.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!A0(t))throw Error(Y(200));return c3(e,t,null,n)};nr.createRoot=function(e,t){if(!A0(e))throw Error(Y(299));var n=!1,r="",o=$_;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(o=t.onRecoverableError)),t=T0(e,1,!1,null,null,n,!1,r,o),e[zo]=t.current,Wl(e.nodeType===8?e.parentNode:e),new M0(t)};nr.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(Y(188)):(e=Object.keys(e).join(","),Error(Y(268,e)));return e=QI(t),e=e===null?null:e.stateNode,e};nr.flushSync=function(e){return ki(e)};nr.hydrate=function(e,t,n){if(!kf(t))throw Error(Y(200));return Tf(null,e,t,!0,n)};nr.hydrateRoot=function(e,t,n){if(!A0(e))throw Error(Y(405));var r=n!=null&&n.hydratedSources||null,o=!1,s="",i=$_;if(n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=T_(t,null,e,1,n??null,o,!1,s,i),e[zo]=t.current,Wl(e),r)for(e=0;e<r.length;e++)n=r[e],o=n._getVersion,o=o(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,o]:t.mutableSourceEagerHydrationData.push(n,o);return new _f(t)};nr.render=function(e,t,n){if(!kf(t))throw Error(Y(200));return Tf(null,e,t,!1,n)};nr.unmountComponentAtNode=function(e){if(!kf(e))throw Error(Y(40));return e._reactRootContainer?(ki(function(){Tf(null,null,e,!1,function(){e._reactRootContainer=null,e[zo]=null})}),!0):!1};nr.unstable_batchedUpdates=I0;nr.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!kf(n))throw Error(Y(200));if(e==null||e._reactInternals===void 0)throw Error(Y(38));return Tf(e,t,n,!1,r)};nr.version="18.3.1-next-f1338f8080-20240426";function M_(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(M_)}catch(e){console.error(e)}}M_(),MI.exports=nr;var Ui=MI.exports;const p3=pc(Ui);var A_,Xb=Ui;A_=Fy.createRoot=Xb.createRoot,Fy.hydrateRoot=Xb.hydrateRoot;async function f3(e,t){const{url:n,style:r="normal",weight:o="500",display:s,featureSettings:i,stretch:a,unicodeRange:c,variant:l,format:u}=t,d={style:r,weight:o,display:s,featureSettings:i,stretch:a,unicodeRange:c,variant:l},p=new FontFace(e,`url(${n})`,d);return await p.load(),document.fonts.add(p),p.$$_url=n,p.$$_fontface=`
|
|
@font-face {
|
|
font-family: ${p.family};
|
|
font-stretch: ${p.stretch};
|
|
font-weight: ${p.weight};
|
|
font-style: ${p.style};
|
|
src: url("${n}") format("${u}")
|
|
}`,p}function j_(e){return e&&typeof e=="object"&&"parents"in e}function O_(e){for(let t=0,n=e.parents.length;t<n;t++)if(e.parents[t].__unsafe__getWithoutCapture(!0),e.parents[t].lastChangedEpoch!==e.parentEpochs[t])return!0;return!1}const kp=(e,t)=>{if(e.children.remove(t)&&e.children.isEmpty&&j_(e))for(let n=0,r=e.parents.length;n<r;n++)kp(e.parents[n],e)},j0=(e,t)=>{if(e.children.add(t)&&j_(e))for(let n=0,r=e.parents.length;n<r;n++)j0(e.parents[n],e)};function D_(e,t){return e===t||Object.is(e,t)||!!(e&&t&&typeof e.equals=="function"&&e.equals(t))}function Gs(e,t){const n=Symbol.for(`com.tldraw.state/${e}`),r=globalThis;return r[n]??(r[n]=t()),r[n]}const Do=Gs("empty_array",()=>Object.freeze([])),qb=8;class Tp{constructor(){m(this,"arraySize",0);m(this,"array",Array(qb));m(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(t){if(this.array)return this.array.indexOf(t)!==-1?!1:this.arraySize<qb?(this.array[this.arraySize]=t,this.arraySize++,!0):(this.set=new Set(this.array),this.array=null,this.set.add(t),!0);if(this.set)return this.set.has(t)?!1:(this.set.add(t),!0);throw new Error("no set or array")}remove(t){if(this.array){const n=this.array.indexOf(t);return n===-1?!1:(this.array[n]=void 0,this.arraySize--,n!==this.arraySize&&(this.array[n]=this.array[this.arraySize],this.array[this.arraySize]=void 0),!0)}if(this.set)return this.set.has(t)?(this.set.delete(t),!0):!1;throw new Error("no set or array")}visit(t){if(this.array){for(let n=0;n<this.arraySize;n++){const r=this.array[n];typeof r<"u"&&t(r)}return}if(this.set){this.set.forEach(t);return}throw new Error("no set or array")}has(t){return this.array?this.array.indexOf(t)!==-1:this.set.has(t)}clear(){this.set?this.set.clear():(this.arraySize=0,this.array=[])}size(){return this.set?this.set.size:this.arraySize}}const qn=Symbol.for("com.tldraw.state/RESET_VALUE");class R_{constructor(t){m(this,"index",0);m(this,"buffer");this.capacity=t,this.buffer=new Array(t)}pushEntry(t,n,r){if(r!==void 0){if(r===qn){this.clear();return}this.buffer[this.index]=[t,n,r],this.index=(this.index+1)%this.capacity}}clear(){this.index=0,this.buffer.fill(void 0)}getChangesSince(t){const{index:n,capacity:r,buffer:o}=this;for(let s=0;s<r;s++){const i=(n-1+r-s)%r,a=o[i];if(!a)return qn;const[c,l]=a;if(s===0&&t>=l)return[];if(c<=t&&t<l){const u=s+1,d=new Array(u);for(let p=0;p<u;p++)d[p]=o[(i+p)%r][2];return d}}return qn}}class g3{constructor(t,n){m(this,"offset",0);m(this,"maybeRemoved");this.below=t,this.child=n}}const yt=Gs("capture",()=>({stack:null}));function L_(e){yt.stack=new g3(yt.stack,e),e.parentSet.clear()}function F_(){const e=yt.stack;if(yt.stack=e.below,e.offset<e.child.parents.length){for(let t=e.offset;t<e.child.parents.length;t++){const n=e.child.parents[t];e.child.parentSet.has(n)||kp(n,e.child)}e.child.parents.length=e.offset,e.child.parentEpochs.length=e.offset}if(e.maybeRemoved)for(let t=0;t<e.maybeRemoved.length;t++){const n=e.maybeRemoved[t];e.child.parentSet.has(n)||kp(n,e.child)}}function $p(e){if(yt.stack){if(yt.stack.child.parentSet.has(e))return;if(yt.stack.child.parentSet.add(e),yt.stack.child.isActivelyListening&&j0(e,yt.stack.child),yt.stack.offset<yt.stack.child.parents.length){const n=yt.stack.child.parents[yt.stack.offset];n!==e&&(yt.stack.maybeRemoved?yt.stack.maybeRemoved.push(n):yt.stack.maybeRemoved=[n])}yt.stack.child.parents[yt.stack.offset]=e,yt.stack.child.parentEpochs[yt.stack.offset]=e.lastChangedEpoch,yt.stack.offset++}}const mi=-1;class m3{constructor(t,n,r){m(this,"_isActivelyListening",!1);m(this,"lastTraversedEpoch",mi);m(this,"lastReactedEpoch",mi);m(this,"_scheduleCount",0);m(this,"parentSet",new Tp);m(this,"parentEpochs",[]);m(this,"parents",[]);m(this,"_scheduleEffect");m(this,"maybeExecute",()=>{this._isActivelyListening&&this.execute()});this.name=t,this.runEffect=n,this._scheduleEffect=r==null?void 0:r.scheduleEffect}get isActivelyListening(){return this._isActivelyListening}get scheduleCount(){return this._scheduleCount}maybeScheduleEffect(){if(this._isActivelyListening&&this.lastReactedEpoch!==dn()){if(this.parents.length&&!O_(this)){this.lastReactedEpoch=dn();return}this.scheduleEffect()}}scheduleEffect(){this._scheduleCount++,this._scheduleEffect?this._scheduleEffect(this.maybeExecute):this.execute()}attach(){this._isActivelyListening=!0;for(let t=0,n=this.parents.length;t<n;t++)j0(this.parents[t],this)}detach(){this._isActivelyListening=!1;for(let t=0,n=this.parents.length;t<n;t++)kp(this.parents[t],this)}execute(){try{L_(this);const t=this.runEffect(this.lastReactedEpoch);return this.lastReactedEpoch=dn(),t}finally{F_()}}}const yc=Gs("EffectScheduler",()=>m3);function Sc(e,t,n){const r=new yc(e,t,n);return r.attach(),r.scheduleEffect(),()=>{r.detach()}}function y3(e,t,n){const r=new yc(e,t,n);return{scheduler:r,start:o=>{const s=(o==null?void 0:o.force)??!1;r.attach(),s?r.scheduleEffect():r.maybeScheduleEffect()},stop:()=>{r.detach()}}}class S3{constructor(t){m(this,"initialAtomValues",new Map);this.parent=t}get isRoot(){return this.parent===null}commit(){if(this.isRoot){const t=this.initialAtomValues;this.initialAtomValues=new Map,N_(t.keys())}else this.initialAtomValues.forEach((t,n)=>{this.parent.initialAtomValues.has(n)||this.parent.initialAtomValues.set(n,t)})}abort(){Jt.globalEpoch++,this.initialAtomValues.forEach((t,n)=>{var r;n.set(t),(r=n.historyBuffer)==null||r.clear()}),this.commit()}}const Jt=Gs("transactions",()=>({globalEpoch:mi+1,globalIsReacting:!1,currentTransaction:null}));function dn(){return Jt.globalEpoch}function N_(e){if(Jt.globalIsReacting)throw new Error("cannot change atoms during reaction cycle");try{Jt.globalIsReacting=!0;const t=new Set,n=r=>{r.lastTraversedEpoch!==Jt.globalEpoch&&(r.lastTraversedEpoch=Jt.globalEpoch,r instanceof yc?t.add(r):r.children.visit(n))};for(const r of e)r.children.visit(n);for(const r of t)r.maybeScheduleEffect()}finally{Jt.globalIsReacting=!1}}function v3(e,t){Jt.currentTransaction?Jt.currentTransaction.initialAtomValues.has(e)||Jt.currentTransaction.initialAtomValues.set(e,t):N_([e])}function x3(){Jt.globalEpoch++}function w3(e){const t=new S3(Jt.currentTransaction);Jt.currentTransaction=t;try{let n=!1;const r=e(()=>n=!0);return n?t.abort():t.commit(),r}catch(n){throw t.abort(),n}finally{Jt.currentTransaction=Jt.currentTransaction.parent}}function Mr(e){return Jt.currentTransaction?e():w3(e)}class b3{constructor(t,n,r){m(this,"isEqual");m(this,"computeDiff");m(this,"lastChangedEpoch",dn());m(this,"children",new Tp);m(this,"historyBuffer");this.name=t,this.current=n,this.isEqual=(r==null?void 0:r.isEqual)??null,r&&(r.historyLength&&(this.historyBuffer=new R_(r.historyLength)),this.computeDiff=r.computeDiff)}__unsafe__getWithoutCapture(t){return this.current}get(){return $p(this),this.current}set(t,n){var o,s;if(((o=this.isEqual)==null?void 0:o.call(this,this.current,t))??D_(this.current,t))return this.current;x3(),this.historyBuffer&&this.historyBuffer.pushEntry(this.lastChangedEpoch,dn(),n??((s=this.computeDiff)==null?void 0:s.call(this,this.current,t,this.lastChangedEpoch,dn()))??qn),this.lastChangedEpoch=dn();const r=this.current;return this.current=t,v3(this,r),t}update(t){return this.set(t(this.current))}getDiffSince(t){var n;return $p(this),t>=this.lastChangedEpoch?Do:((n=this.historyBuffer)==null?void 0:n.getChangesSince(t))??qn}}const P3=Gs("Atom",()=>b3);function fn(e,t,n){return new P3(e,t,n)}let Zb=!1;function C3(){Zb||(Zb=!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.
|
|
|
|
// Before
|
|
@computed
|
|
get foo() {
|
|
return 'foo'
|
|
}
|
|
|
|
// After
|
|
@computed
|
|
getFoo() {
|
|
return 'foo'
|
|
}
|
|
`))}const pl=Symbol.for("com.tldraw.state/UNINITIALIZED"),Pi=e=>e===pl,MS=Gs("WithDiff",()=>class{constructor(t,n){this.value=t,this.diff=n}});function fl(e,t){return new MS(e,t)}class I3{constructor(t,n,r){m(this,"lastChangedEpoch",mi);m(this,"lastTraversedEpoch",mi);m(this,"lastCheckedEpoch",mi);m(this,"parentSet",new Tp);m(this,"parents",[]);m(this,"parentEpochs",[]);m(this,"children",new Tp);m(this,"historyBuffer");m(this,"state",pl);m(this,"error",null);m(this,"computeDiff");m(this,"isEqual");this.name=t,this.derive=n,r!=null&&r.historyLength&&(this.historyBuffer=new R_(r.historyLength)),this.computeDiff=r==null?void 0:r.computeDiff,this.isEqual=(r==null?void 0:r.isEqual)??D_}get isActivelyListening(){return!this.children.isEmpty}__unsafe__getWithoutCapture(t){var r;if(!(this.lastChangedEpoch===mi)&&(this.lastCheckedEpoch===dn()||!O_(this)))if(this.lastCheckedEpoch=dn(),this.error){if(t)return this.state;throw this.error.thrownValue}else return this.state;try{L_(this);const o=this.derive(this.state,this.lastCheckedEpoch),s=o instanceof MS?o.value:o,i=this.state===pl;if(i||!this.isEqual(s,this.state)){if(this.historyBuffer&&!i){const a=o instanceof MS?o.diff:void 0;this.historyBuffer.pushEntry(this.lastChangedEpoch,dn(),a??((r=this.computeDiff)==null?void 0:r.call(this,this.state,s,this.lastCheckedEpoch,dn()))??qn)}this.lastChangedEpoch=dn(),this.state=s}return this.error=null,this.lastCheckedEpoch=dn(),this.state}catch(o){if(this.state!==pl&&(this.state=pl,this.lastChangedEpoch=dn()),this.lastCheckedEpoch=dn(),this.historyBuffer&&this.historyBuffer.clear(),this.error={thrownValue:o},!t)throw o;return this.state}finally{F_()}}get(){try{return this.__unsafe__getWithoutCapture()}finally{$p(this)}}getDiffSince(t){var n;return this.__unsafe__getWithoutCapture(!0),$p(this),t>=this.lastChangedEpoch?Do:((n=this.historyBuffer)==null?void 0:n.getChangesSince(t))??qn}}const O0=Gs("Computed",()=>I3);function E3(e={},t,n,r){const o=r.value,s=Symbol.for("__@tldraw/state__computed__"+n);return r.value=function(){let i=this[s];return i||(i=new O0(n,o.bind(this),e),Object.defineProperty(this,s,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()},r.value[k3]=!0,r}function Qb(e={},t,n,r){return r.get?(C3(),_3(e,t,n,r)):E3(e,t,n,r)}function _3(e={},t,n,r){const o=r.get,s=Symbol.for("__@tldraw/state__computed__"+n);return r.get=function(){let i=this[s];return i||(i=new O0(n,o.bind(this),e),Object.defineProperty(this,s,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()},r}const k3="@@__isComputedMethod__@@";function V(){if(arguments.length===1){const e=arguments[0];return(t,n,r)=>Qb(e,t,n,r)}else return typeof arguments[0]=="string"?new O0(arguments[0],arguments[1],arguments[2]):Qb(void 0,arguments[0],arguments[1],arguments[2])}const z_=1,T3=Gs("apiVersion",()=>z_);if(T3!==z_)throw new Error("You have multiple incompatible versions of @tldraw/state in your app. Please deduplicate the package.");function $f(e,t){const n=Se.useRef(t);n.current=t;const[r,o,s]=Se.useMemo(()=>{let i=null;const a=u=>(i=u,()=>{i=null}),c=new yc(`useStateTracking(${e})`,()=>{var u;return(u=n.current)==null?void 0:u.call(n)},{scheduleEffect(){i==null||i()}});return[c,a,()=>c.scheduleCount]},[e]);return Se.useSyncExternalStore(o,s,s),Se.useEffect(()=>(r.attach(),r.maybeScheduleEffect(),()=>{r.detach()}),[r]),r.execute()}const Jb={apply(e,t,n){return $f(e.displayName??e.name??"tracked(???)",()=>e.apply(t,n))}},$3=Symbol.for("react.memo"),M3=Symbol.for("react.forward_ref");function or(e){let t=null;const n=e.$$typeof;return n===$3&&(e=e.type,t=e.compare),n===M3?x.memo(x.forwardRef(new Proxy(e.render,Jb))):x.memo(new Proxy(e,Jb),t)}function A3(){const e=arguments[0],t=arguments[1],n=arguments.length===3?void 0:arguments[2],r=arguments.length===3?arguments[2]:arguments[3];return x.useMemo(()=>V(`useComputed(${e})`,t,n),r)}function js(e,t,n=Do){x.useEffect(()=>{const r=new yc(e,t);return r.attach(),r.execute(),()=>{r.detach()}},n)}function K(){const e=arguments,t=e.length===3?e[2]:[e[0]],n=e.length===3?e[0]:`useValue(${e[0].name})`,r=x.useRef(!0);r.current=!0;const o=x.useMemo(()=>e.length===1?e[0]:V(n,()=>{if(r.current)return e[1]();try{return e[1]()}catch{return{}}}),t);try{const{subscribe:s,getSnapshot:i}=x.useMemo(()=>({subscribe:a=>Sc(`useValue(${n})`,()=>{o.get(),a()}),getSnapshot:()=>o.get()}),[o]);return x.useSyncExternalStore(s,i,i)}finally{r.current=!1}}class fh{constructor(t){m(this,"nextValue");m(this,"diff");this.previousValue=t}get(){var r,o,s,i;const t=((o=(r=this.diff)==null?void 0:r.removed)==null?void 0:o.size)??0,n=((i=(s=this.diff)==null?void 0:s.added)==null?void 0:i.size)??0;if(!(t===0&&n===0))return{value:this.nextValue,diff:this.diff}}_add(t,n){var r,o;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.add(t),this.diff??(this.diff={}),n?(r=this.diff.removed)==null||r.delete(t):((o=this.diff).added??(o.added=new Set),this.diff.added.add(t))}add(t){var o,s,i;const n=this.previousValue.has(t);if(n)return((s=(o=this.diff)==null?void 0:o.removed)==null?void 0:s.has(t))?this._add(t,n):void 0;(i=this.nextValue)!=null&&i.has(t)||this._add(t,n)}_remove(t,n){var r,o;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.delete(t),this.diff??(this.diff={}),n?((r=this.diff).removed??(r.removed=new Set),this.diff.removed.add(t)):(o=this.diff.added)==null||o.delete(t)}remove(t){var o,s,i,a;const n=this.previousValue.has(t);if(!n)return((s=(o=this.diff)==null?void 0:o.added)==null?void 0:s.has(t))?this._remove(t,n):void 0;(a=(i=this.diff)==null?void 0:i.removed)!=null&&a.has(t)||this._remove(t,n)}}function Mp(e,t){const n=[];e:for(const r of e){for(const o of n)if(t?t(r,o):r===o)continue e;n.push(r)}return n}function fe(e){return e.filter(t=>t!=null)}function Wn(e){return e[e.length-1]}function j3(e,t){let n,r=1/0;for(const o of e){const s=t(o);s<r&&(n=o,r=s)}return n}function O3(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function B_(e,t){let n,r;return function(...o){return n||(n=!0,setTimeout(()=>n=!1,t),r=e(...o)),r}}function U_(e){const t=(...n)=>{try{return e(...n)}catch(r){throw r instanceof Error&&Error.captureStackTrace&&Error.captureStackTrace(r,t),r}};return t}const Ha={ok(e){return{ok:!0,value:e}},err(e){return{ok:!1,error:e}}};function qo(e,t){const n=t&&e&&typeof e=="object"&&t in e?e[t]:e;throw new Error(`Unknown switch case ${n}`)}const _t=U_((e,t)=>{if(!e)throw new Error(t||"Assertion Error")}),yi=U_((e,t)=>{if(e==null)throw new Error(t??"value must be defined");return e});function H_(e,t){let n;const r=(...o)=>(n||(n={},n.promise=new Promise((s,i)=>{n.resolve=s,n.reject=i})),clearTimeout(n.timeout),n.latestArgs=o,n.timeout=setTimeout(()=>{const s=n;n=void 0;try{s.resolve(e(...s.latestArgs))}catch(i){s.reject(i)}},t),n.promise);return r.cancel=()=>{n&&clearTimeout(n.timeout)},r}const e1=new WeakMap;function D0(e,t){if(typeof e!="object"||e===null)return;let n=e1.get(e);n||(n={tags:{},extras:{}},e1.set(e,n)),t.tags&&(n.tags={...n.tags,...t.tags}),t.extras&&(n.extras={...n.extras,...t.extras})}class Ka{static async dataUrlToArrayBuffer(t){return fetch(t).then(function(n){return n.arrayBuffer()})}static async blobToDataUrl(t){return await new Promise((n,r)=>{if(t){const o=new FileReader;o.onload=()=>n(o.result),o.onerror=s=>r(s),o.onabort=s=>r(s),o.readAsDataURL(t)}})}static async blobToText(t){return await new Promise((n,r)=>{if(t){const o=new FileReader;o.onload=()=>n(o.result),o.onerror=s=>r(s),o.onabort=s=>r(s),o.readAsText(t)}})}}function AS(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t+""}function D3(e){const t=new DataView(e);let n=0;for(let r=0;r<t.byteLength;r++)n=(n<<5)-n+t.getUint8(r),n|=0;return n+""}let jS=[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"&&(jS=new Int32Array(jS));const R3=(e,t)=>{let n=~~t^-1;for(let r=0;r<e.length;r++)n=jS[(n^e[r])&255]^n>>>8;return n^-1},t1=4,n1=4;class Zr{static isPng(t,n){return t.getUint8(n+0)===137&&t.getUint8(n+1)===80&&t.getUint8(n+2)===78&&t.getUint8(n+3)===71&&t.getUint8(n+4)===13&&t.getUint8(n+5)===10&&t.getUint8(n+6)===26&&t.getUint8(n+7)===10}static getChunkType(t,n){return[String.fromCharCode(t.getUint8(n)),String.fromCharCode(t.getUint8(n+1)),String.fromCharCode(t.getUint8(n+2)),String.fromCharCode(t.getUint8(n+3))].join("")}static readChunks(t,n=0){const r={};if(!Zr.isPng(t,n))throw new Error("Not a PNG");for(n+=8;n<=t.buffer.byteLength;){const o=n,s=t.getInt32(n);n+=4;const i=Zr.getChunkType(t,n);if(i==="IDAT"&&r[i]){n+=s+t1+n1;continue}if(i==="IEND")break;r[i]={start:o,dataOffset:n+4,size:s},n+=s+t1+n1}return r}static parsePhys(t,n){return{ppux:t.getUint32(n),ppuy:t.getUint32(n+4),unit:t.getUint8(n+4)}}static findChunk(t,n){return Zr.readChunks(t)[n]}static setPhysChunk(t,n=1,r){let o=46,s=0;const i=Zr.findChunk(t,"pHYs");i&&(o=i.start,s=i.size);const a=Zr.findChunk(t,"IDAT");a&&(o=a.start,s=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 u=2835.5;l.setInt32(8,u*n),l.setInt32(12,u*n),l.setInt8(16,1);const d=new Uint8Array(c.slice(4,17));l.setInt32(17,R3(d));const p=t.buffer.slice(0,o),f=t.buffer.slice(o+s);return new Blob([p,c,f],r)}}class jo{static loadVideo(t){return new Promise((n,r)=>{const o=document.createElement("video");o.onloadeddata=()=>n(o),o.onerror=s=>{console.error(s),r(new Error("Could not load video"))},o.crossOrigin="anonymous",o.src=t})}static loadImage(t){return new Promise((n,r)=>{const o=new Image;o.onload=()=>n(o),o.onerror=s=>{console.error(s),r(new Error("Could not load image"))},o.crossOrigin="anonymous",o.src=t})}static async getVideoSize(t){return jo.usingObjectURL(t,async n=>{const r=await jo.loadVideo(n);return{w:r.videoWidth,h:r.videoHeight}})}static async getImageSize(t){const n=await jo.usingObjectURL(t,jo.loadImage);try{if(t.type==="image/png"){const r=new DataView(await t.arrayBuffer());if(Zr.isPng(r,0)){const o=Zr.findChunk(r,"pHYs");if(o){const s=Zr.parsePhys(r,o.dataOffset);if(s.unit===0&&s.ppux===s.ppuy){const i=Math.max(s.ppux/2834.5,1);return{w:Math.round(n.naturalWidth/i),h:Math.round(n.naturalHeight/i)}}}}}}catch(r){return console.error(r),{w:n.naturalWidth,h:n.naturalHeight}}return{w:n.naturalWidth,h:n.naturalHeight}}static async usingObjectURL(t,n){const r=URL.createObjectURL(t);try{return await n(r)}finally{URL.revokeObjectURL(r)}}}function Ys(e=""){let t=0,n=0,r=0,o=0;function s(){const i=t^t<<11;return t=n,n=r,r=o,o^=(o>>>19^i^i>>>8)>>>0,o/4294967296*2}for(let i=0;i<e.length+64;i++)t^=e.charCodeAt(i)|0,s();return s}function Ap(e,t,n,r=!1){const[o,s]=t,[i,a]=n,c=i+(e-o)/(s-o)*(a-i);return r?i<a?Math.max(Math.min(c,a),i):Math.max(Math.min(c,i),a):c}function ro(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Lr(e,t){if(ro(e,t))return e[t]}function r1(e){return Object.keys(e)}function bt(e){return Object.values(e)}function An(e){return Object.entries(e)}function R0(e){return Object.fromEntries(e)}function nm(e,t){const n={};let r=!1;for(const[o,s]of An(e))t(o,s)?n[o]=s:r=!0;return r?n:e}function Mf(e,t){const n={};for(const[r,o]of An(e)){const s=t(r,o);n[r]=s}return n}function K_(e,t){if(e===t)return!0;const n=new Set(Object.keys(e)),r=new Set(Object.keys(t));if(n.size!==r.size)return!1;for(const o of n)if(!r.has(o)||!Object.is(e[o],t[o]))return!1;return!0}const Gn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",W_="a0",V_="A00000000000000000000000000";function G_(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw new Error("Invalid index key head: "+e)}function Y_(e){if(e.length!==G_(e.charAt(0)))throw new Error("invalid integer part of index key: "+e)}function o1(e){if(e===void 0)throw Error("n is undefined")}function s1(e){Y_(e);const[t,...n]=e.split("");let r=!0;for(let o=n.length-1;r&&o>=0;o--){const s=Gn.indexOf(n[o])+1;s===Gn.length?n[o]="0":(n[o]=Gn.charAt(s),r=!1)}if(r){if(t==="Z")return"a0";if(t==="z")return;const o=String.fromCharCode(t.charCodeAt(0)+1);return o>"a"?n.push("0"):n.pop(),o+n.join("")}else return t+n.join("")}function L3(e){Y_(e);const[t,...n]=e.split("");let r=!0;for(let o=n.length-1;r&&o>=0;o--){const s=Gn.indexOf(n[o])-1;s===-1?n[o]=Gn.slice(-1):(n[o]=Gn.charAt(s),r=!1)}if(r){if(t==="a")return"Z"+Gn.slice(-1);if(t==="A")return;const o=String.fromCharCode(t.charCodeAt(0)-1);return o<"Z"?n.push(Gn.slice(-1)):n.pop(),o+n.join("")}else return t+n.join("")}function ka(e,t){if(t!==void 0&&e>=t)throw new Error(e+" >= "+t);if(e.slice(-1)==="0"||t&&t.slice(-1)==="0")throw new Error("trailing zero");if(t){let o=0;for(;(e.charAt(o)||"0")===t.charAt(o);)o++;if(o>0)return t.slice(0,o)+ka(e.slice(o),t.slice(o))}const n=e?Gn.indexOf(e.charAt(0)):0,r=t!==void 0?Gn.indexOf(t.charAt(0)):Gn.length;if(r-n>1){const o=Math.round(.5*(n+r));return Gn.charAt(o)}else return t&&t.length>1?t.slice(0,1):Gn.charAt(n)+ka(e.slice(1),void 0)}function gl(e){const t=G_(e.charAt(0));if(t>e.length)throw new Error("invalid index: "+e);return e.slice(0,t)}function OS(e){if(e===V_)throw new Error("invalid index: "+e);const t=gl(e);if(e.slice(t.length).slice(-1)==="0")throw new Error("invalid index: "+e)}function Ji(e,t){if(e!==void 0&&OS(e),t!==void 0&&OS(t),e!==void 0&&t!==void 0&&e>=t)throw new Error(e+" >= "+t);if(e===void 0&&t===void 0)return W_;if(e===void 0){if(t===void 0)throw Error("b is undefined");const a=gl(t),c=t.slice(a.length);if(a===V_)return a+ka("",c);if(a<t)return a;const l=L3(a);return o1(l),l}if(t===void 0){const a=gl(e),c=e.slice(a.length),l=s1(a);return l===void 0?a+ka(c,void 0):l}const n=gl(e),r=e.slice(n.length),o=gl(t),s=t.slice(o.length);if(n===o)return n+ka(r,s);const i=s1(n);return o1(i),i<t?i:n+ka(r,void 0)}function Ls(e,t,n){if(n===0)return[];if(n===1)return[Ji(e,t)];if(t===void 0){let s=Ji(e,t);const i=[s];for(let a=0;a<n-1;a++)s=Ji(s,t),i.push(s);return i}if(e===void 0){let s=Ji(e,t);const i=[s];for(let a=0;a<n-1;a++)s=Ji(e,s),i.push(s);return i.reverse(),i}const r=Math.floor(n/2),o=Ji(e,t);return[...Ls(e,o,r),o,...Ls(o,t,n-r-1)]}const F3=W_;function N3(e){OS(e)}function oc(e,t,n){return Ls(e,t,n)}function rm(e,t){return Ls(e,void 0,t)}function kl(e,t){return Ls(e,t,1)[0]}function $o(e){return Ls(e,void 0,1)[0]}function z3(e){return Ls(void 0,e,1)[0]}function eu(e,t="a1"){return[t,...Ls(t,void 0,e)]}function en(e,t){return e.index<t.index?-1:e.index>t.index?1:0}function B3(e,t){return e.id>t.id?1:-1}function L0(e){try{return localStorage.getItem(e)}catch{return null}}function F0(e,t){try{localStorage.setItem(e,t)}catch{}}function U3(){try{localStorage.clear()}catch{}}function X_(e){try{return sessionStorage.getItem(e)}catch{return null}}function N0(e,t){try{sessionStorage.setItem(e,t)}catch{}}function q_(e){try{sessionStorage.removeItem(e)}catch{}}function H3(){try{sessionStorage.clear()}catch{}}const K3=()=>typeof process<"u"&&!1,Ta=[],W3=60,gh=Math.ceil(1e3/W3);let Vc,om=0,DS=0;const V3=()=>{const e=Ta.splice(0,Ta.length);for(const t of e)t()};function Z_(){if(Vc)return;const e=Date.now(),t=e-DS;if(om+t<gh){Vc=requestAnimationFrame(()=>{Vc=void 0,Z_()});return}Vc=requestAnimationFrame(()=>{Vc=void 0,DS=e,om=Math.min(om+t-gh,gh*10),V3()})}let i1=!1;function Q_(e){return K3()?(e(),()=>{}):(Ta.includes(e)||(Ta.push(e),i1||(i1=!0,DS=Date.now()-gh-1),Z_()),()=>{const t=Ta.indexOf(e);t>-1&&Ta.splice(t,1)})}function G3(e){return e!==null}function Y3(){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]:[e=>e&&JSON.parse(JSON.stringify(e)),!1]}const J_=Y3(),Ye=J_[0];J_[1];const X3=Object.getPrototypeOf(Ye({}));let ek=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");class z0{constructor(t,n){m(this,"createDefaultProperties");m(this,"validator");m(this,"scope");m(this,"isInstance",t=>(t==null?void 0:t.typeName)===this.typeName);this.typeName=t,this.createDefaultProperties=n.createDefaultProperties,this.validator=n.validator??{validate:r=>r},this.scope=n.scope??"document"}create(t){const n={...this.createDefaultProperties(),id:this.createId()};for(const[r,o]of Object.entries(t))o!==void 0&&(n[r]=o);return n.typeName=this.typeName,n}clone(t){return{...Ye(t),id:this.createId()}}createId(t){return this.typeName+":"+(t??ek())}createCustomId(t){return this.typeName+":"+t}parseId(t){if(!this.isId(t))throw new Error(`ID "${t}" is not a valid ID for type "${this.typeName}"`);return t.slice(this.typeName.length+1)}isId(t){if(!t)return!1;for(let n=0;n<this.typeName.length;n++)if(t[n]!==this.typeName[n])return!1;return t[this.typeName.length]===":"}withDefaultProperties(t){return new z0(this.typeName,{createDefaultProperties:t,validator:this.validator,scope:this.scope})}validate(t,n){return n&&this.validator.validateUsingKnownGoodVersion?this.validator.validateUsingKnownGoodVersion(n,t):this.validator.validate(t)}}function Zo(e,t){return new z0(e,{createDefaultProperties:()=>({}),validator:t.validator,scope:t.scope})}class a1{constructor(){m(this,"items",new WeakMap)}get(t,n){return this.items.has(t)||this.items.set(t,n(t)),this.items.get(t)}}var jp={exports:{}};jp.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=1,s=2,i=9007199254740991,a="[object Arguments]",c="[object Array]",l="[object AsyncFunction]",u="[object Boolean]",d="[object Date]",p="[object Error]",f="[object Function]",y="[object GeneratorFunction]",g="[object Map]",w="[object Number]",S="[object Null]",v="[object Object]",b="[object Promise]",E="[object Proxy]",C="[object RegExp]",I="[object Set]",_="[object String]",k="[object Symbol]",$="[object Undefined]",T="[object WeakMap]",O="[object ArrayBuffer]",N="[object DataView]",F="[object Float32Array]",L="[object Float64Array]",B="[object Int8Array]",q="[object Int16Array]",Q="[object Int32Array]",H="[object Uint8Array]",U="[object Uint8ClampedArray]",W="[object Uint16Array]",Z="[object Uint32Array]",le=/[\\^$.*+?()[\]{}|]/g,be=/^\[object .+?Constructor\]$/,Me=/^(?:0|[1-9]\d*)$/,ae={};ae[F]=ae[L]=ae[B]=ae[q]=ae[Q]=ae[H]=ae[U]=ae[W]=ae[Z]=!0,ae[a]=ae[c]=ae[O]=ae[u]=ae[N]=ae[d]=ae[p]=ae[f]=ae[g]=ae[w]=ae[v]=ae[C]=ae[I]=ae[_]=ae[T]=!1;var Ae=typeof tn=="object"&&tn&&tn.Object===Object&&tn,Re=typeof self=="object"&&self&&self.Object===Object&&self,ot=Ae||Re||Function("return this")(),Ie=t&&!t.nodeType&&t,ht=Ie&&!0&&e&&!e.nodeType&&e,He=ht&&ht.exports===Ie,ir=He&&Ae.process,Ln=function(){try{return ir&&ir.binding&&ir.binding("util")}catch{}}(),Fn=Ln&&Ln.isTypedArray;function qe(M,D){for(var G=-1,ee=M==null?0:M.length,Ze=0,me=[];++G<ee;){var pt=M[G];D(pt,G,M)&&(me[Ze++]=pt)}return me}function Ot(M,D){for(var G=-1,ee=D.length,Ze=M.length;++G<ee;)M[Ze+G]=D[G];return M}function wo(M,D){for(var G=-1,ee=M==null?0:M.length;++G<ee;)if(D(M[G],G,M))return!0;return!1}function Ac(M,D){for(var G=-1,ee=Array(M);++G<M;)ee[G]=D(G);return ee}function jc(M){return function(D){return M(D)}}function bg(M,D){return M.has(D)}function qi(M,D){return M==null?void 0:M[D]}function Dj(M){var D=-1,G=Array(M.size);return M.forEach(function(ee,Ze){G[++D]=[Ze,ee]}),G}function Rj(M,D){return function(G){return M(D(G))}}function Lj(M){var D=-1,G=Array(M.size);return M.forEach(function(ee){G[++D]=ee}),G}var Fj=Array.prototype,Nj=Function.prototype,Gu=Object.prototype,Pg=ot["__core-js_shared__"],Pw=Nj.toString,Wr=Gu.hasOwnProperty,Cw=function(){var M=/[^.]+$/.exec(Pg&&Pg.keys&&Pg.keys.IE_PROTO||"");return M?"Symbol(src)_1."+M:""}(),Iw=Gu.toString,zj=RegExp("^"+Pw.call(Wr).replace(le,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ew=He?ot.Buffer:void 0,Yu=ot.Symbol,_w=ot.Uint8Array,kw=Gu.propertyIsEnumerable,Bj=Fj.splice,ni=Yu?Yu.toStringTag:void 0,Tw=Object.getOwnPropertySymbols,Uj=Ew?Ew.isBuffer:void 0,Hj=Rj(Object.keys,Object),Cg=Zi(ot,"DataView"),Oc=Zi(ot,"Map"),Ig=Zi(ot,"Promise"),Eg=Zi(ot,"Set"),_g=Zi(ot,"WeakMap"),Dc=Zi(Object,"create"),Kj=si(Cg),Wj=si(Oc),Vj=si(Ig),Gj=si(Eg),Yj=si(_g),$w=Yu?Yu.prototype:void 0,kg=$w?$w.valueOf:void 0;function ri(M){var D=-1,G=M==null?0:M.length;for(this.clear();++D<G;){var ee=M[D];this.set(ee[0],ee[1])}}function Xj(){this.__data__=Dc?Dc(null):{},this.size=0}function qj(M){var D=this.has(M)&&delete this.__data__[M];return this.size-=D?1:0,D}function Zj(M){var D=this.__data__;if(Dc){var G=D[M];return G===r?void 0:G}return Wr.call(D,M)?D[M]:void 0}function Qj(M){var D=this.__data__;return Dc?D[M]!==void 0:Wr.call(D,M)}function Jj(M,D){var G=this.__data__;return this.size+=this.has(M)?0:1,G[M]=Dc&&D===void 0?r:D,this}ri.prototype.clear=Xj,ri.prototype.delete=qj,ri.prototype.get=Zj,ri.prototype.has=Qj,ri.prototype.set=Jj;function bo(M){var D=-1,G=M==null?0:M.length;for(this.clear();++D<G;){var ee=M[D];this.set(ee[0],ee[1])}}function eO(){this.__data__=[],this.size=0}function tO(M){var D=this.__data__,G=qu(D,M);if(G<0)return!1;var ee=D.length-1;return G==ee?D.pop():Bj.call(D,G,1),--this.size,!0}function nO(M){var D=this.__data__,G=qu(D,M);return G<0?void 0:D[G][1]}function rO(M){return qu(this.__data__,M)>-1}function oO(M,D){var G=this.__data__,ee=qu(G,M);return ee<0?(++this.size,G.push([M,D])):G[ee][1]=D,this}bo.prototype.clear=eO,bo.prototype.delete=tO,bo.prototype.get=nO,bo.prototype.has=rO,bo.prototype.set=oO;function oi(M){var D=-1,G=M==null?0:M.length;for(this.clear();++D<G;){var ee=M[D];this.set(ee[0],ee[1])}}function sO(){this.size=0,this.__data__={hash:new ri,map:new(Oc||bo),string:new ri}}function iO(M){var D=Zu(this,M).delete(M);return this.size-=D?1:0,D}function aO(M){return Zu(this,M).get(M)}function cO(M){return Zu(this,M).has(M)}function lO(M,D){var G=Zu(this,M),ee=G.size;return G.set(M,D),this.size+=G.size==ee?0:1,this}oi.prototype.clear=sO,oi.prototype.delete=iO,oi.prototype.get=aO,oi.prototype.has=cO,oi.prototype.set=lO;function Xu(M){var D=-1,G=M==null?0:M.length;for(this.__data__=new oi;++D<G;)this.add(M[D])}function uO(M){return this.__data__.set(M,r),this}function dO(M){return this.__data__.has(M)}Xu.prototype.add=Xu.prototype.push=uO,Xu.prototype.has=dO;function is(M){var D=this.__data__=new bo(M);this.size=D.size}function hO(){this.__data__=new bo,this.size=0}function pO(M){var D=this.__data__,G=D.delete(M);return this.size=D.size,G}function fO(M){return this.__data__.get(M)}function gO(M){return this.__data__.has(M)}function mO(M,D){var G=this.__data__;if(G instanceof bo){var ee=G.__data__;if(!Oc||ee.length<n-1)return ee.push([M,D]),this.size=++G.size,this;G=this.__data__=new oi(ee)}return G.set(M,D),this.size=G.size,this}is.prototype.clear=hO,is.prototype.delete=pO,is.prototype.get=fO,is.prototype.has=gO,is.prototype.set=mO;function yO(M,D){var G=Qu(M),ee=!G&&AO(M),Ze=!G&&!ee&&Tg(M),me=!G&&!ee&&!Ze&&Nw(M),pt=G||ee||Ze||me,kt=pt?Ac(M.length,String):[],Dt=kt.length;for(var st in M)Wr.call(M,st)&&!(pt&&(st=="length"||Ze&&(st=="offset"||st=="parent")||me&&(st=="buffer"||st=="byteLength"||st=="byteOffset")||_O(st,Dt)))&&kt.push(st);return kt}function qu(M,D){for(var G=M.length;G--;)if(Dw(M[G][0],D))return G;return-1}function SO(M,D,G){var ee=D(M);return Qu(M)?ee:Ot(ee,G(M))}function Rc(M){return M==null?M===void 0?$:S:ni&&ni in Object(M)?IO(M):MO(M)}function Mw(M){return Lc(M)&&Rc(M)==a}function Aw(M,D,G,ee,Ze){return M===D?!0:M==null||D==null||!Lc(M)&&!Lc(D)?M!==M&&D!==D:vO(M,D,G,ee,Aw,Ze)}function vO(M,D,G,ee,Ze,me){var pt=Qu(M),kt=Qu(D),Dt=pt?c:as(M),st=kt?c:as(D);Dt=Dt==a?v:Dt,st=st==a?v:st;var Nn=Dt==v,Pr=st==v,Wt=Dt==st;if(Wt&&Tg(M)){if(!Tg(D))return!1;pt=!0,Nn=!1}if(Wt&&!Nn)return me||(me=new is),pt||Nw(M)?jw(M,D,G,ee,Ze,me):PO(M,D,Dt,G,ee,Ze,me);if(!(G&o)){var ar=Nn&&Wr.call(M,"__wrapped__"),cr=Pr&&Wr.call(D,"__wrapped__");if(ar||cr){var cs=ar?M.value():M,Po=cr?D.value():D;return me||(me=new is),Ze(cs,Po,G,ee,me)}}return Wt?(me||(me=new is),CO(M,D,G,ee,Ze,me)):!1}function xO(M){if(!Fw(M)||TO(M))return!1;var D=Rw(M)?zj:be;return D.test(si(M))}function wO(M){return Lc(M)&&Lw(M.length)&&!!ae[Rc(M)]}function bO(M){if(!$O(M))return Hj(M);var D=[];for(var G in Object(M))Wr.call(M,G)&&G!="constructor"&&D.push(G);return D}function jw(M,D,G,ee,Ze,me){var pt=G&o,kt=M.length,Dt=D.length;if(kt!=Dt&&!(pt&&Dt>kt))return!1;var st=me.get(M);if(st&&me.get(D))return st==D;var Nn=-1,Pr=!0,Wt=G&s?new Xu:void 0;for(me.set(M,D),me.set(D,M);++Nn<kt;){var ar=M[Nn],cr=D[Nn];if(ee)var cs=pt?ee(cr,ar,Nn,D,M,me):ee(ar,cr,Nn,M,D,me);if(cs!==void 0){if(cs)continue;Pr=!1;break}if(Wt){if(!wo(D,function(Po,ii){if(!bg(Wt,ii)&&(ar===Po||Ze(ar,Po,G,ee,me)))return Wt.push(ii)})){Pr=!1;break}}else if(!(ar===cr||Ze(ar,cr,G,ee,me))){Pr=!1;break}}return me.delete(M),me.delete(D),Pr}function PO(M,D,G,ee,Ze,me,pt){switch(G){case N:if(M.byteLength!=D.byteLength||M.byteOffset!=D.byteOffset)return!1;M=M.buffer,D=D.buffer;case O:return!(M.byteLength!=D.byteLength||!me(new _w(M),new _w(D)));case u:case d:case w:return Dw(+M,+D);case p:return M.name==D.name&&M.message==D.message;case C:case _:return M==D+"";case g:var kt=Dj;case I:var Dt=ee&o;if(kt||(kt=Lj),M.size!=D.size&&!Dt)return!1;var st=pt.get(M);if(st)return st==D;ee|=s,pt.set(M,D);var Nn=jw(kt(M),kt(D),ee,Ze,me,pt);return pt.delete(M),Nn;case k:if(kg)return kg.call(M)==kg.call(D)}return!1}function CO(M,D,G,ee,Ze,me){var pt=G&o,kt=Ow(M),Dt=kt.length,st=Ow(D),Nn=st.length;if(Dt!=Nn&&!pt)return!1;for(var Pr=Dt;Pr--;){var Wt=kt[Pr];if(!(pt?Wt in D:Wr.call(D,Wt)))return!1}var ar=me.get(M);if(ar&&me.get(D))return ar==D;var cr=!0;me.set(M,D),me.set(D,M);for(var cs=pt;++Pr<Dt;){Wt=kt[Pr];var Po=M[Wt],ii=D[Wt];if(ee)var zw=pt?ee(ii,Po,Wt,D,M,me):ee(Po,ii,Wt,M,D,me);if(!(zw===void 0?Po===ii||Ze(Po,ii,G,ee,me):zw)){cr=!1;break}cs||(cs=Wt=="constructor")}if(cr&&!cs){var Ju=M.constructor,ed=D.constructor;Ju!=ed&&"constructor"in M&&"constructor"in D&&!(typeof Ju=="function"&&Ju instanceof Ju&&typeof ed=="function"&&ed instanceof ed)&&(cr=!1)}return me.delete(M),me.delete(D),cr}function Ow(M){return SO(M,DO,EO)}function Zu(M,D){var G=M.__data__;return kO(D)?G[typeof D=="string"?"string":"hash"]:G.map}function Zi(M,D){var G=qi(M,D);return xO(G)?G:void 0}function IO(M){var D=Wr.call(M,ni),G=M[ni];try{M[ni]=void 0;var ee=!0}catch{}var Ze=Iw.call(M);return ee&&(D?M[ni]=G:delete M[ni]),Ze}var EO=Tw?function(M){return M==null?[]:(M=Object(M),qe(Tw(M),function(D){return kw.call(M,D)}))}:RO,as=Rc;(Cg&&as(new Cg(new ArrayBuffer(1)))!=N||Oc&&as(new Oc)!=g||Ig&&as(Ig.resolve())!=b||Eg&&as(new Eg)!=I||_g&&as(new _g)!=T)&&(as=function(M){var D=Rc(M),G=D==v?M.constructor:void 0,ee=G?si(G):"";if(ee)switch(ee){case Kj:return N;case Wj:return g;case Vj:return b;case Gj:return I;case Yj:return T}return D});function _O(M,D){return D=D??i,!!D&&(typeof M=="number"||Me.test(M))&&M>-1&&M%1==0&&M<D}function kO(M){var D=typeof M;return D=="string"||D=="number"||D=="symbol"||D=="boolean"?M!=="__proto__":M===null}function TO(M){return!!Cw&&Cw in M}function $O(M){var D=M&&M.constructor,G=typeof D=="function"&&D.prototype||Gu;return M===G}function MO(M){return Iw.call(M)}function si(M){if(M!=null){try{return Pw.call(M)}catch{}try{return M+""}catch{}}return""}function Dw(M,D){return M===D||M!==M&&D!==D}var AO=Mw(function(){return arguments}())?Mw:function(M){return Lc(M)&&Wr.call(M,"callee")&&!kw.call(M,"callee")},Qu=Array.isArray;function jO(M){return M!=null&&Lw(M.length)&&!Rw(M)}var Tg=Uj||LO;function OO(M,D){return Aw(M,D)}function Rw(M){if(!Fw(M))return!1;var D=Rc(M);return D==f||D==y||D==l||D==E}function Lw(M){return typeof M=="number"&&M>-1&&M%1==0&&M<=i}function Fw(M){var D=typeof M;return M!=null&&(D=="object"||D=="function")}function Lc(M){return M!=null&&typeof M=="object"}var Nw=Fn?jc(Fn):wO;function DO(M){return jO(M)?yO(M):bO(M)}function RO(){return[]}function LO(){return!1}e.exports=OO})(jp,jp.exports);var q3=jp.exports;const Z3=pc(q3);function Q3(e){if(e.length===0)return new Set;const t=e[0],n=e.slice(1),r=new Set;for(const o of t)n.every(s=>s.has(o))&&r.add(o);return r}function J3(e,t){const n={};for(const r of t)e.has(r)||(n.added??(n.added=new Set),n.added.add(r));for(const r of e)t.has(r)||(n.removed??(n.removed=new Set),n.removed.add(r));return n.added||n.removed?n:void 0}function c1(e,t){for(const[n,r]of Object.entries(e)){const o=r,s=t[n];if("eq"in o&&s!==o.eq||"neq"in o&&s===o.neq||"gt"in o&&(typeof s!="number"||s<=o.gt))return!1}return!0}function l1(e,t,n){const r=Object.fromEntries(Object.keys(n).map(o=>[o,new Set]));for(const[o,s]of Object.entries(n))if("eq"in s){const a=e.index(t,o).get().get(s.eq);if(a)for(const c of a)r[o].add(c)}else if("neq"in s){const i=e.index(t,o);for(const[a,c]of i.get())if(a!==s.neq)for(const l of c)r[o].add(l)}else if("gt"in s){const i=e.index(t,o);for(const[a,c]of i.get())if(a>s.gt)for(const l of c)r[o].add(l)}return Q3(Object.values(r))}class eL{constructor(t,n){m(this,"indexCache",new Map);m(this,"historyCache",new Map);this.atoms=t,this.history=n}filterHistory(t){if(this.historyCache.has(t))return this.historyCache.get(t);const n=V("filterHistory:"+t,(r,o)=>{if(Pi(r))return this.history.get();const s=this.history.getDiffSince(o);if(s===qn)return this.history.get();const i={added:{},removed:{},updated:{}};let a=0,c=0,l=0;for(const u of s){for(const d of bt(u.added))if(d.typeName===t)if(i.removed[d.id]){const p=i.removed[d.id];delete i.removed[d.id],c--,p!==d&&(i.updated[d.id]=[p,d],l++)}else i.added[d.id]=d,a++;for(const[d,p]of bt(u.updated))p.typeName===t&&(i.added[p.id]?i.added[p.id]=p:i.updated[p.id]?i.updated[p.id]=[i.updated[p.id][0],p]:(i.updated[p.id]=[d,p],l++));for(const d of bt(u.removed))d.typeName===t&&(i.added[d.id]?(delete i.added[d.id],a--):i.updated[d.id]?(i.removed[d.id]=i.updated[d.id][0],delete i.updated[d.id],l--,c++):(i.removed[d.id]=d,c++))}return a||c||l?fl(this.history.get(),i):r},{historyLength:100});return this.historyCache.set(t,n),n}index(t,n){const r=t+":"+n;if(this.indexCache.has(r))return this.indexCache.get(r);const o=this.__uncached_createIndex(t,n);return this.indexCache.set(r,o),o}__uncached_createIndex(t,n){const r=this.filterHistory(t),o=()=>{r.get();const s=new Map;for(const i of bt(this.atoms.get())){const a=i.get();if(a.typeName===t){const c=a[n];s.has(c)||s.set(c,new Set),s.get(c).add(a.id)}}return s};return V("index:"+t+":"+n,(s,i)=>{if(Pi(s))return o();const a=r.getDiffSince(i);if(a===qn)return o();const c=new Map,l=(f,y)=>{let g=c.get(f);g||(g=new fh(s.get(f)??new Set)),g.add(y),c.set(f,g)},u=(f,y)=>{let g=c.get(f);g||(g=new fh(s.get(f)??new Set)),g.remove(y),c.set(f,g)};for(const f of a){for(const y of bt(f.added))if(y.typeName===t){const g=y[n];l(g,y.id)}for(const[y,g]of bt(f.updated))if(g.typeName===t){const w=y[n],S=g[n];w!==S&&(u(w,g.id),l(S,g.id))}for(const y of bt(f.removed))if(y.typeName===t){const g=y[n];u(g,y.id)}}let d,p;for(const[f,y]of c){const g=y.get();g&&(d||(d=new Map(s)),p||(p=new Map),g.value.size===0?d.delete(f):d.set(f,g.value),p.set(f,g.diff))}return d&&p?fl(d,p):s},{historyLength:100})}record(t,n=()=>({}),r="record:"+t+(n?":"+n.toString():"")){const o=this.ids(t,n,r);return V(r,()=>{var s;for(const i of o.get())return(s=this.atoms.get()[i])==null?void 0:s.get()})}records(t,n=()=>({}),r="records:"+t+(n?":"+n.toString():"")){const o=this.ids(t,n,"ids:"+r);return V(r,()=>[...o.get()].map(s=>{const i=this.atoms.get()[s];if(!i)throw new Error("no atom found for record id: "+s);return i.get()}))}ids(t,n=()=>({}),r="ids:"+t+(n?":"+n.toString():"")){const o=this.filterHistory(t),s=()=>{o.get();const c=n();return Object.keys(c).length===0?new Set(bt(this.atoms.get()).flatMap(l=>{const u=l.get();return u.typeName===t?u.id:[]})):l1(this,t,c)},i=c=>{const l=s(),u=J3(c,l);return u?fl(l,u):c},a=V("ids_query:"+r,n,{isEqual:Z3});return V("query:"+r,(c,l)=>{const u=a.get();if(Pi(c))return s();if(l<a.lastChangedEpoch)return i(c);const d=o.getDiffSince(l);if(d===qn)return i(c);const p=new fh(c);for(const y of d){for(const g of bt(y.added))g.typeName===t&&c1(u,g)&&p.add(g.id);for(const[g,w]of bt(y.updated))w.typeName===t&&(c1(u,w)?p.add(w.id):p.remove(w.id));for(const g of bt(y.removed))g.typeName===t&&p.remove(g.id)}const f=p.get();return f?fl(f.value,f.diff):c},{historyLength:50})}exec(t,n){const r=l1(this,t,n);if(r.size===0)return Do;const o=this.atoms.get();return[...r].map(s=>o[s].get())}}class tk{constructor(t){m(this,"id",ek());m(this,"atoms",fn("store_atoms",{}));m(this,"history",fn("history",0,{historyLength:1e3}));m(this,"query",new eL(this.atoms,this.history));m(this,"listeners",new Set);m(this,"historyAccumulator",new nL);m(this,"historyReactor");m(this,"schema");m(this,"props");m(this,"scopedTypes");m(this,"onBeforeCreate");m(this,"onAfterCreate");m(this,"onBeforeChange");m(this,"onAfterChange");m(this,"onBeforeDelete");m(this,"onAfterDelete");m(this,"_runCallbacks",!0);m(this,"put",(t,n)=>{Mr(()=>{const r={},o={},s=this.atoms.__unsafe__getWithoutCapture();let i=null,a,c=!1;const l=this.onBeforeCreate&&this._runCallbacks?this.onBeforeCreate:null,u=this.onBeforeChange&&this._runCallbacks?this.onBeforeChange:null,d=this.isMergingRemoteChanges?"remote":"user";for(let p=0,f=t.length;p<f;p++){a=t[p];const y=(i??s)[a.id];if(y){const g=y.__unsafe__getWithoutCapture();if(u&&(a=u(g,a,d)),this.schema.validateRecord(this,a,n??"updateRecord",g)===g)continue;y.set(a),c=!0,r[a.id]=[g,y.__unsafe__getWithoutCapture()]}else l&&(a=l(a,d)),c=!0,a=this.schema.validateRecord(this,a,n??"createRecord",null),o[a.id]=a,i||(i={...s}),i[a.id]=fn("atom:"+a.id,a)}if(i&&this.atoms.set(i),!!c&&(this.updateHistory({added:o,updated:r,removed:{}}),this._runCallbacks)){const{onAfterCreate:p,onAfterChange:f}=this;p&&Object.values(o).forEach(y=>{p(y,d)}),f&&Object.values(r).forEach(([y,g])=>{f(y,g,d)})}})});m(this,"remove",t=>{Mr(()=>{const n=[],r=this.isMergingRemoteChanges?"remote":"user";if(this.onBeforeDelete&&this._runCallbacks)for(const s of t){const i=this.atoms.__unsafe__getWithoutCapture()[s];i&&this.onBeforeDelete(i.get(),r)===!1&&n.push(s)}let o;if(this.atoms.update(s=>{let i;for(const a of t)n.includes(a)||a in s&&(i||(i={...s}),o||(o={}),delete i[a],o[a]=s[a].get());return i??s}),!!o&&(this.updateHistory({added:{},updated:{},removed:o}),this.onAfterDelete&&this._runCallbacks)){let s;for(let i=0,a=t.length;i<a;i++)s=o[t[i]],s&&this.onAfterDelete(s,r)}})});m(this,"get",t=>{var n;return(n=this.atoms.get()[t])==null?void 0:n.get()});m(this,"unsafeGetWithoutCapture",t=>{var n;return(n=this.atoms.get()[t])==null?void 0:n.__unsafe__getWithoutCapture()});m(this,"serialize",(t="document")=>{const n={};for(const[r,o]of An(this.atoms.get())){const s=o.get();(t==="all"||this.scopedTypes[t].has(s.typeName))&&(n[r]=s)}return n});m(this,"allRecords",()=>bt(this.atoms.get()).map(t=>t.get()));m(this,"clear",()=>{this.remove(r1(this.atoms.get()))});m(this,"update",(t,n)=>{const r=this.atoms.get()[t];if(!r){console.error(`Record ${t} not found. This is probably an error`);return}this.put([n(r.__unsafe__getWithoutCapture())])});m(this,"has",t=>!!this.atoms.get()[t]);m(this,"listen",(t,n)=>{this._flushHistory();const r={onHistory:t,filters:{source:(n==null?void 0:n.source)??"all",scope:(n==null?void 0:n.scope)??"all"}};return this.listeners.add(r),this.historyReactor.scheduler.isActivelyListening||this.historyReactor.start(),()=>{this.listeners.delete(r),this.listeners.size===0&&this.historyReactor.stop()}});m(this,"isMergingRemoteChanges",!1);m(this,"mergeRemoteChanges",t=>{if(this.isMergingRemoteChanges)return t();try{this.isMergingRemoteChanges=!0,Mr(t)}finally{this.isMergingRemoteChanges=!1}});m(this,"createComputedCache",(t,n,r)=>{const o=new a1;return{get:s=>{const i=this.atoms.get()[s];if(i)return o.get(i,()=>{const a=r?V(i.name+":equals",()=>i.get(),{isEqual:r}):i;return V(t+":"+s,()=>n(a.get()))}).get()}}});m(this,"createSelectedComputedCache",(t,n,r)=>{const o=new a1;return{get:s=>{const i=this.atoms.get()[s];if(!i)return;const a=V(t+":"+s+":selector",()=>n(i.get()));return o.get(i,()=>V(t+":"+s,()=>r(a.get()))).get()}}});m(this,"getRecordType",t=>{const n=this.schema.types[t.typeName];if(!n)throw new Error(`Record type ${t.typeName} not found`);return n});m(this,"_integrityChecker");m(this,"_isPossiblyCorrupted",!1);const{initialData:n,schema:r}=t;this.schema=r,this.props=t.props,n&&this.atoms.set(R0(An(n).map(([o,s])=>[o,fn("atom:"+o,this.schema.validateRecord(this,s,"initialize",null))]))),this.historyReactor=y3("Store.historyReactor",()=>{this.history.get(),this._flushHistory()},{scheduleEffect:o=>Q_(o)}),this.scopedTypes={document:new Set(bt(this.schema.types).filter(o=>o.scope==="document").map(o=>o.typeName)),session:new Set(bt(this.schema.types).filter(o=>o.scope==="session").map(o=>o.typeName)),presence:new Set(bt(this.schema.types).filter(o=>o.scope==="presence").map(o=>o.typeName))}}_flushHistory(){if(this.historyAccumulator.hasChanges()){const t=this.historyAccumulator.flush();for(const{changes:n,source:r}of t){let o=null,s=null,i=null;for(const{onHistory:a,filters:c}of this.listeners)if(!(c.source!=="all"&&c.source!==r))if(c.scope!=="all")if(c.scope==="document"){if(s??(s=this.filterChangesByScope(n,"document")),!s)continue;a({changes:s,source:r})}else if(c.scope==="session"){if(o??(o=this.filterChangesByScope(n,"session")),!o)continue;a({changes:o,source:r})}else{if(i??(i=this.filterChangesByScope(n,"presence")),!i)continue;a({changes:i,source:r})}else a({changes:n,source:r})}}}filterChangesByScope(t,n){const r={added:nm(t.added,(o,s)=>this.scopedTypes[n].has(s.typeName)),updated:nm(t.updated,(o,s)=>this.scopedTypes[n].has(s[1].typeName)),removed:nm(t.removed,(o,s)=>this.scopedTypes[n].has(s.typeName))};return Object.keys(r.added).length===0&&Object.keys(r.updated).length===0&&Object.keys(r.removed).length===0?null:r}updateHistory(t){this.historyAccumulator.add({changes:t,source:this.isMergingRemoteChanges?"remote":"user"}),this.listeners.size===0&&this.historyAccumulator.clear(),this.history.set(this.history.get()+1,t)}validate(t){this.allRecords().forEach(n=>this.schema.validateRecord(this,n,t,null))}getSnapshot(t="document"){return{store:this.serialize(t),schema:this.schema.serialize()}}migrateSnapshot(t){const n=this.schema.migrateStoreSnapshot(t);if(n.type==="error")throw new Error(`Failed to migrate snapshot: ${n.reason}`);return{store:n.value,schema:this.schema.serialize()}}loadSnapshot(t){const n=this.schema.migrateStoreSnapshot(t);if(n.type==="error")throw new Error(`Failed to migrate snapshot: ${n.reason}`);const r=this._runCallbacks;try{this._runCallbacks=!1,Mr(()=>{this.clear(),this.put(Object.values(n.value)),this.ensureStoreIsUsable()})}finally{this._runCallbacks=r}}extractingChanges(t){const n=[],r=this.historyAccumulator.intercepting(o=>n.push(o.changes));try{return Mr(t),Af(n)}finally{r()}}applyDiff(t,n=!0){const r=this._runCallbacks;try{this._runCallbacks=n,Mr(()=>{const o=bt(t.added).concat(bt(t.updated).map(([i,a])=>a)),s=r1(t.removed);o.length&&this.put(o),s.length&&this.remove(s)})}finally{this._runCallbacks=r}}ensureStoreIsUsable(){var t;this._integrityChecker??(this._integrityChecker=this.schema.createIntegrityChecker(this)),(t=this._integrityChecker)==null||t.call(this)}markAsPossiblyCorrupted(){this._isPossiblyCorrupted=!0}isPossiblyCorrupted(){return this._isPossiblyCorrupted}}function Af(e){const t={added:{},removed:{},updated:{}};for(const n of e){for(const[r,o]of An(n.added))if(t.removed[r]){const s=t.removed[r];delete t.removed[r],s!==o&&(t.updated[r]=[s,o])}else t.added[r]=o;for(const[r,[o,s]]of An(n.updated)){if(t.added[r]){t.added[r]=s,delete t.updated[r],delete t.removed[r];continue}if(t.updated[r]){t.updated[r]=[t.updated[r][0],s],delete t.removed[r];continue}t.updated[r]=n.updated[r],delete t.removed[r]}for(const[r,o]of An(n.removed))t.added[r]?delete t.added[r]:t.updated[r]?(t.removed[r]=t.updated[r][0],delete t.updated[r]):t.removed[r]=o}return t}function tL(e){if(e.length===0)return[];const t=[];let n=[e[0]],r;for(let o=1,s=e.length;o<s;o++)r=e[o],n[0].source!==r.source&&(t.push(n),n=[]),n.push(r);return t.push(n),t.map(o=>({source:o[0].source,changes:Af(o.map(s=>s.changes))}))}class nL{constructor(){m(this,"_history",[]);m(this,"_interceptors",new Set)}intercepting(t){return this._interceptors.add(t),()=>{this._interceptors.delete(t)}}add(t){this._history.push(t);for(const n of this._interceptors)n(t)}flush(){const t=tL(this._history);return this._history=[],t}clear(){this._history=[]}hasChanges(){return this._history.length>0}}function rL(e){const t=[];for(let n=e.length-1;n>=0;n--){const r=e[n];if("id"in r)t.unshift(r);else{const o=r.dependsOn,s=t[0];s&&(t[0]={...s,dependsOn:o.concat(s.dependsOn??[])})}}return t}function Tl({sequence:e,sequenceId:t,retroactive:n=!0}){const r={sequenceId:t,retroactive:n,sequence:rL(e)};return nk(r),r}function sr(e,t){return Object.fromEntries(An(t).map(([n,r])=>[n,`${e}/${r}`]))}function xr(e){const t=e.sequenceId;return Tl({sequenceId:t,retroactive:e.retroactive??!0,sequence:e.sequence.map(n=>"id"in n?{...n,scope:"record",filter:r=>{var o,s;return r.typeName===e.recordType&&(((o=n.filter)==null?void 0:o.call(n,r))??!0)&&(((s=e.filter)==null?void 0:s.call(e,r))??!0)}}:n)})}function oL(e){const t=new Map(e.map(s=>[s.id,s])),n=new Set,r=[];function o(s){_t(!n.has(s.id),`Circular dependency in migrations: ${s.id}`),n.add(s.id);const{version:i,sequenceId:a}=Op(s.id),c=t.get(`${a}/${i-1}`);if(c&&o(c),s.dependsOn)for(const l of s.dependsOn){const u=t.get(l);u&&o(u)}t.delete(s.id),r.push(s)}for(const s of t.values())o(s);return r}function Op(e){const[t,n]=e.split("/");return{sequenceId:t,version:parseInt(n)}}function u1(e,t){t&&_t(e.startsWith(t+"/"),`Every migration in sequence '${t}' must have an id starting with '${t}/'. Got invalid id: '${e}'`),_t(e.match(/^(.*?)\/(0|[1-9]\d*)$/),`Invalid migration id: '${e}'`)}function nk(e){if(_t(!e.sequenceId.includes("/"),`sequenceId cannot contain a '/', got ${e.sequenceId}`),_t(e.sequenceId.length,"sequenceId must be a non-empty string"),e.sequence.length===0)return;u1(e.sequence[0].id,e.sequenceId);let t=Op(e.sequence[0].id).version;_t(t===1,`Expected the first migrationId to be '${e.sequenceId}/1' but got '${e.sequence[0].id}'`);for(let n=1;n<e.sequence.length;n++){const r=e.sequence[n].id;u1(r,e.sequenceId);const o=Op(r).version;_t(o===t+1,`Migration id numbers must increase in increments of 1, expected ${e.sequenceId}/${t+1} but got '${e.sequence[n].id}'`),t=o}}var ps=(e=>(e.IncompatibleSubtype="incompatible-subtype",e.UnknownType="unknown-type",e.TargetVersionTooNew="target-version-too-new",e.TargetVersionTooOld="target-version-too-old",e.MigrationError="migration-error",e.UnrecognizedSubtype="unrecognized-subtype",e))(ps||{});function sL(e){if(e.schemaVersion>2||e.schemaVersion<1)return Ha.err("Bad schema version");if(e.schemaVersion===2)return Ha.ok(e);const t={schemaVersion:2,sequences:{}};for(const[n,r]of Object.entries(e.recordVersions))if(t.sequences[`com.tldraw.${n}`]=r.version,"subTypeKey"in r)for(const[o,s]of Object.entries(r.subTypeVersions))t.sequences[`com.tldraw.${n}.${o}`]=s;return Ha.ok(t)}class B0{constructor(t,n){m(this,"migrations",{});m(this,"sortedMigrations");var o;this.types=t,this.options=n;for(const s of n.migrations??[])_t(!this.migrations[s.sequenceId],`Duplicate migration sequenceId ${s.sequenceId}`),nk(s),this.migrations[s.sequenceId]=s;const r=Object.values(this.migrations).flatMap(s=>s.sequence);this.sortedMigrations=oL(r);for(const s of this.sortedMigrations)if((o=s.dependsOn)!=null&&o.length)for(const i of s.dependsOn){const a=r.find(c=>c.id===i);_t(a,`Migration '${s.id}' depends on missing migration '${i}'`)}}static create(t,n){return new B0(t,n??{})}validateRecord(t,n,r,o){try{const s=Lr(this.types,n.typeName);if(!s)throw new Error(`Missing definition for record type ${n.typeName}`);return s.validate(n,o??void 0)}catch(s){if(this.options.onValidationFailure)return this.options.onValidationFailure({store:t,record:n,phase:r,recordBefore:o,error:s});throw s}}getMigrationsSince(t){const n=sL(t);if(!n.ok)return n;const r=n.value,o=new Set(Object.keys(r.sequences).filter(i=>this.migrations[i]));for(const i in this.migrations)r.sequences[i]===void 0&&this.migrations[i].retroactive&&o.add(i);if(o.size===0)return Ha.ok([]);const s=new Set;for(const i of o){const a=r.sequences[i];if(typeof a!="number"&&this.migrations[i].retroactive||a===0){for(const u of this.migrations[i].sequence)s.add(u.id);continue}const c=`${i}/${a}`,l=this.migrations[i].sequence.findIndex(u=>u.id===c);if(l===-1)return Ha.err("Incompatible schema?");for(const u of this.migrations[i].sequence.slice(l+1))s.add(u.id)}return Ha.ok(this.sortedMigrations.filter(({id:i})=>s.has(i)))}migratePersistedRecord(t,n,r="up"){const o=this.getMigrationsSince(n);if(!o.ok)return console.error("Error migrating record",o.error),{type:"error",reason:ps.MigrationError};let s=o.value;if(s.length===0)return{type:"success",value:t};if(s.some(i=>i.scope==="store"))return{type:"error",reason:r==="down"?ps.TargetVersionTooOld:ps.TargetVersionTooNew};if(r==="down"){if(!s.every(i=>i.down))return{type:"error",reason:ps.TargetVersionTooOld};s=s.slice().reverse()}t=Ye(t);try{for(const i of s){if(i.scope==="store")throw new Error;if(!(i.filter?i.filter(t):!0))continue;const c=i[r](t);c&&(t=Ye(c))}}catch(i){return console.error("Error migrating record",i),{type:"error",reason:ps.MigrationError}}return{type:"success",value:t}}migrateStoreSnapshot(t){let{store:n}=t;const r=this.getMigrationsSince(t.schema);if(!r.ok)return console.error("Error migrating store",r.error),{type:"error",reason:ps.MigrationError};const o=r.value;if(o.length===0)return{type:"success",value:n};n=Ye(n);try{for(const s of o)if(s.scope==="record")for(const[i,a]of Object.entries(n)){if(!(s.filter?s.filter(a):!0))continue;const l=s.up(a);l&&(n[i]=Ye(l))}else if(s.scope==="store"){const i=s.up(n);i&&(n=Ye(i))}else qo(s)}catch(s){return console.error("Error migrating store",s),{type:"error",reason:ps.MigrationError}}return{type:"success",value:n}}createIntegrityChecker(t){var n,r;return((r=(n=this.options).createIntegrityChecker)==null?void 0:r.call(n,t))??void 0}serialize(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:t,sequence:n})=>[t,n.length?Op(n.at(-1).id).version:0]))}}serializeEarliestVersion(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:t})=>[t,0]))}}}function iL(e){if(!e.length)return null;let t="";for(const n of e)typeof n=="number"?t+=`.${n}`:n.startsWith("(")?t.endsWith(")")?t=`${t.slice(0,-1)}, ${n.slice(1)}`:t+=n:t+=`.${n}`;return t=t.replace(/id = [^,]+, /,"").replace(/id = [^)]+/,""),t.startsWith(".")?t.slice(1):t}class Ce extends Error{constructor(n,r=[]){const o=iL(r),s=n.split(`
|
|
`).map((i,a)=>a===0?i:` ${i}`).join(`
|
|
`);super(r?`At ${o}: ${s}`:s);m(this,"name","ValidationError");this.rawMessage=n,this.path=r}}function jn(e,t){try{return t()}catch(n){throw n instanceof Ce?new Ce(n.rawMessage,[e,...n.path]):new Ce(n.toString(),[e])}}function Fs(e){if(e===null)return"null";if(Array.isArray(e))return"an array";const t=typeof e;switch(t){case"bigint":case"boolean":case"function":case"number":case"string":case"symbol":return`a ${t}`;case"object":return`an ${t}`;case"undefined":return"undefined";default:qo(t)}}class Sn{constructor(t,n){this.validationFn=t,this.validateUsingKnownGoodVersionFn=n}validate(t){return this.validationFn(t)}validateUsingKnownGoodVersion(t,n){return Object.is(t,n)?t:this.validateUsingKnownGoodVersionFn?this.validateUsingKnownGoodVersionFn(t,n):this.validate(n)}isValid(t){try{return this.validate(t),!0}catch{return!1}}nullable(){return hL(this)}optional(){return ok(this)}refine(t){return new Sn(n=>t(this.validate(n)),(n,r)=>{const o=this.validateUsingKnownGoodVersion(n,r);return Object.is(n,o)?n:t(o)})}check(t,n){return typeof t=="string"?this.refine(r=>(jn(`(check ${t})`,()=>n(r)),r)):this.refine(r=>(t(r),r))}}class aL extends Sn{constructor(t){super(n=>{const r=d1.validate(n);for(let o=0;o<r.length;o++)jn(o,()=>t.validate(r[o]));return r},(n,r)=>{if(!t.validateUsingKnownGoodVersion)return this.validate(r);const o=d1.validate(r);let s=n.length!==o.length;for(let i=0;i<o.length;i++){const a=o[i];if(i>=n.length){s=!0,jn(i,()=>t.validate(a));continue}if(Object.is(n[i],a))continue;const c=jn(i,()=>t.validateUsingKnownGoodVersion(n[i],a));Object.is(c,n[i])||(s=!0)}return s?r:n}),this.itemValidator=t}nonEmpty(){return this.check(t=>{if(t.length===0)throw new Ce("Expected a non-empty array")})}lengthGreaterThan1(){return this.check(t=>{if(t.length<=1)throw new Ce("Expected an array with length greater than 1")})}}class Dp extends Sn{constructor(t,n=!1){super(r=>{if(typeof r!="object"||r===null)throw new Ce(`Expected object, got ${Fs(r)}`);for(const[o,s]of Object.entries(t))jn(o,()=>{s.validate(Lr(r,o))});if(!n){for(const o of Object.keys(r))if(!ro(t,o))throw new Ce("Unexpected property",[o])}return r},(r,o)=>{if(typeof o!="object"||o===null)throw new Ce(`Expected object, got ${Fs(o)}`);let s=!1;for(const[i,a]of Object.entries(t)){const c=Lr(r,i),l=Lr(o,i);if(Object.is(c,l))continue;const u=jn(i,()=>{const d=a;return d.validateUsingKnownGoodVersion?d.validateUsingKnownGoodVersion(c,l):d.validate(l)});Object.is(u,c)||(s=!0)}if(!n){for(const i of Object.keys(o))if(!ro(t,i))throw new Ce("Unexpected property",[i])}for(const i of Object.keys(r))if(!ro(o,i)){s=!0;break}return s?o:r}),this.config=t,this.shouldAllowUnknownProperties=n}allowUnknownProperties(){return new Dp(this.config,!0)}extend(t){return new Dp({...this.config,...t})}}class jf extends Sn{constructor(t,n,r,o){super(s=>{this.expectObject(s);const{matchingSchema:i,variant:a}=this.getMatchingSchemaAndVariant(s);return i===void 0?this.unknownValueValidation(s,a):jn(`(${t} = ${a})`,()=>i.validate(s))},(s,i)=>{this.expectObject(i),this.expectObject(s);const{matchingSchema:a,variant:c}=this.getMatchingSchemaAndVariant(i);return a===void 0?this.unknownValueValidation(i,c):Lr(s,t)!==Lr(i,t)?jn(`(${t} = ${c})`,()=>a.validate(i)):jn(`(${t} = ${c})`,()=>a.validateUsingKnownGoodVersion?a.validateUsingKnownGoodVersion(s,i):a.validate(i))}),this.key=t,this.config=n,this.unknownValueValidation=r,this.useNumberKeys=o}expectObject(t){if(typeof t!="object"||t===null)throw new Ce(`Expected an object, got ${Fs(t)}`,[])}getMatchingSchemaAndVariant(t){const n=Lr(t,this.key);if(!this.useNumberKeys&&typeof n!="string")throw new Ce(`Expected a string for key "${this.key}", got ${Fs(n)}`);if(this.useNumberKeys&&!Number.isFinite(Number(n)))throw new Ce(`Expected a number for key "${this.key}", got "${n}"`);return{matchingSchema:ro(this.config,n)?this.config[n]:void 0,variant:n}}validateUnknownVariants(t){return new jf(this.key,this.config,t,this.useNumberKeys)}}class cL extends Sn{constructor(t,n){super(r=>{if(typeof r!="object"||r===null)throw new Ce(`Expected object, got ${Fs(r)}`);for(const[o,s]of Object.entries(r))jn(o,()=>{t.validate(o),n.validate(s)});return r},(r,o)=>{if(typeof o!="object"||o===null)throw new Ce(`Expected object, got ${Fs(o)}`);let s=!1;for(const[i,a]of Object.entries(o)){if(!ro(r,i)){s=!0,jn(i,()=>{t.validate(i),n.validate(a)});continue}const c=Lr(r,i),l=a;if(Object.is(c,l))continue;const u=jn(i,()=>n.validateUsingKnownGoodVersion?n.validateUsingKnownGoodVersion(c,l):n.validate(l));Object.is(u,c)||(s=!0)}for(const i of Object.keys(r))if(!ro(o,i)){s=!0;break}return s?o:r}),this.keyValidator=t,this.valueValidator=n}}function U0(e){return new Sn(t=>{if(typeof t!==e)throw new Ce(`Expected ${e}, got ${Fs(t)}`);return t})}const lL=new Sn(e=>e),ge=U0("string"),he=U0("number").check(e=>{if(Number.isNaN(e))throw new Ce("Expected a number, got NaN");if(!Number.isFinite(e))throw new Ce(`Expected a finite number, got ${e}`)}),Rp=he.check(e=>{if(e<0)throw new Ce(`Expected a positive number, got ${e}`)}),On=he.check(e=>{if(e<=0)throw new Ce(`Expected a non-zero positive number, got ${e}`)}),rk=he.check(e=>{if(!Number.isInteger(e))throw new Ce(`Expected an integer, got ${e}`)}),mh=rk.check(e=>{if(e<0)throw new Ce(`Expected a positive integer, got ${e}`)}),uL=rk.check(e=>{if(e<=0)throw new Ce(`Expected a non-zero positive integer, got ${e}`)}),we=U0("boolean");function on(e){return new Sn(t=>{if(t!==e)throw new Ce(`Expected ${e}, got ${JSON.stringify(t)}`);return e})}const d1=new Sn(e=>{if(!Array.isArray(e))throw new Ce(`Expected an array, got ${Fs(e)}`);return e});function Nt(e){return new aL(e)}function ve(e){return new Dp(e)}function RS(e){return typeof e=="object"&&e!==null&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null||Object.getPrototypeOf(e)===X3)}function LS(e){return e===null||typeof e=="number"||typeof e=="string"||typeof e=="boolean"?!0:Array.isArray(e)?e.every(LS):RS(e)?Object.values(e).every(LS):!1}const pn=new Sn(e=>{if(LS(e))return e;throw new Ce(`Expected json serializable value, got ${typeof e}`)},(e,t)=>{if(Array.isArray(e)&&Array.isArray(t)){let n=e.length!==t.length;for(let r=0;r<t.length;r++){if(r>=e.length){n=!0,pn.validate(t[r]);continue}const o=e[r],s=t[r];if(Object.is(o,s))continue;const i=pn.validateUsingKnownGoodVersion(o,s);Object.is(i,o)||(n=!0)}return n?t:e}else if(RS(e)&&RS(t)){let n=!1;for(const r of Object.keys(t)){if(!ro(e,r)){n=!0,pn.validate(t[r]);continue}const o=e[r],s=t[r];if(Object.is(o,s))continue;const i=pn.validateUsingKnownGoodVersion(o,s);Object.is(i,o)||(n=!0)}for(const r of Object.keys(e))if(!ro(t,r)){n=!0;break}return n?t:e}else return pn.validate(t)});function Lp(e,t){return new cL(e,t)}function H0(e,t){return new jf(e,t,(n,r)=>{throw new Ce(`Expected one of ${Object.keys(t).map(o=>JSON.stringify(o)).join(" or ")}, got ${JSON.stringify(r)}`,[e])},!1)}function dL(e,t){return new jf(e,t,(n,r)=>{throw new Ce(`Expected one of ${Object.keys(t).map(o=>JSON.stringify(o)).join(" or ")}, got ${JSON.stringify(r)}`,[e])},!0)}function Qo(e,t){return new Sn(n=>jn(e,()=>t.validate(n)),(n,r)=>jn(e,()=>t.validateUsingKnownGoodVersion?t.validateUsingKnownGoodVersion(n,r):t.validate(r)))}function Of(e){return new Sn(t=>{if(!e.has(t)){const n=Array.from(e,r=>JSON.stringify(r)).join(" or ");throw new Ce(`Expected ${n}, got ${t}`)}return t})}function ok(e){return new Sn(t=>{if(t!==void 0)return e.validate(t)},(t,n)=>{if(!(t===void 0&&n===void 0)&&n!==void 0)return e.validateUsingKnownGoodVersion&&t!==void 0?e.validateUsingKnownGoodVersion(t,n):e.validate(n)})}function hL(e){return new Sn(t=>t===null?null:e.validate(t),(t,n)=>n===null?null:e.validateUsingKnownGoodVersion&&t!==null?e.validateUsingKnownGoodVersion(t,n):e.validate(n))}function sk(...e){return Of(new Set(e))}function ik(e){try{return new URL(e)}catch{if(e.startsWith("/")||e.startsWith("./"))try{return new URL(e,"http://example.com")}catch{throw new Ce(`Expected a valid url, got ${JSON.stringify(e)}`)}throw new Ce(`Expected a valid url, got ${JSON.stringify(e)}`)}}const pL=new Set(["http:","https:","mailto:"]),er=ge.check(e=>{if(e==="")return;const t=ik(e);if(!pL.has(t.protocol.toLowerCase()))throw new Ce(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)}),fL=new Set(["http:","https:","data:"]),vc=ge.check(e=>{if(e==="")return;const t=ik(e);if(!fL.has(t.protocol.toLowerCase()))throw new Ce(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)}),K0=ge.refine(e=>{try{return N3(e),e}catch{throw new Ce(`Expected an index key, got ${JSON.stringify(e)}`)}});function mr(e){return ge.refine(t=>{if(!t.startsWith(`${e}:`))throw new Error(`${e} ID must start with "${e}:"`);return t})}const Df=mr("asset");function W0(e,t){return ve({id:Df,typeName:on("asset"),type:on(e),props:t,meta:pn})}const gL=Qo("camera",ve({typeName:on("camera"),id:mr("camera"),x:he,y:he,z:he,meta:pn})),mL=sr("com.tldraw.camera",{AddMeta:1}),yL=xr({sequenceId:"com.tldraw.camera",recordType:"camera",sequence:[{id:mL.AddMeta,up:e=>{e.meta={}}}]}),hn=Zo("camera",{validator:gL,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,z:1,meta:{}})),tu=ve({x:he,y:he,z:he.optional()}),$l=ve({x:he,y:he,w:he,h:he}),SL=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"]),ak=Of(SL),vL=ve({type:ak,rotation:he}),ck=he.check(e=>{if(e<0||e>1)throw new Ce("Opacity must be between 0 and 1")}),xL=new Set(["accent","white","black","selection-stroke","selection-fill","laser","muted-1"]),wL=Of(xL),bL=new Set(["starting","paused","active","stopping"]),lk=ve({id:ge,points:Nt(tu),size:Rp,color:wL,opacity:he,state:Of(bL),delay:he,shrink:he,taper:we}),nu=mr("page"),PL=Qo("page",ve({typeName:on("page"),id:nu,name:ge,index:K0,meta:pn})),CL=sr("com.tldraw.page",{AddMeta:1}),IL=xr({sequenceId:"com.tldraw.page",recordType:"page",sequence:[{id:CL.AddMeta,up:e=>{e.meta={}}}]}),Ho=Zo("page",{validator:PL,scope:"document"}).withDefaultProperties(()=>({meta:{}}));function bn(e){return Ho.isId(e)}mr("instance");function EL(e){const t={};for(const[r,o]of e)t[r]=ok(o);const n=Qo("instance",ve({typeName:on("instance"),id:mr("instance"),currentPageId:nu,followingUserId:ge.nullable(),brush:$l.nullable(),opacityForNextShape:ck,stylesForNextShape:ve(t),cursor:vL,scribbles:Nt(lk),isFocusMode:we,isDebugMode:we,isToolLocked:we,exportBackground:we,screenBounds:$l,insets:Nt(we),zoomBrush:$l.nullable(),isPenMode:we,isGridMode:we,chatMessage:ge,isChatting:we,highlightedUserIds:Nt(ge),canMoveCamera:we,isFocused:we,devicePixelRatio:he,isCoarsePointer:we,isHoveringCanvas:we.nullable(),openMenus:Nt(ge),isChangingStyle:we,isReadonly:we,meta:pn,duplicateProps:ve({shapeIds:Nt(mr("shape")),offset:ve({x:he,y:he})}).nullable()}));return Zo("instance",{validator:n,scope:"session"}).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:[],canMoveCamera:!0,isFocused:!1,devicePixelRatio:typeof window>"u"?1:window.devicePixelRatio,isCoarsePointer:!1,isHoveringCanvas:null,openMenus:[],isChangingStyle:!1,isReadonly:!1,meta:{},duplicateProps:null}))}const nt=sr("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}),_L=xr({sequenceId:"com.tldraw.instance",recordType:"instance",sequence:[{id:nt.AddTransparentExportBgs,up:e=>({...e,exportBackground:!0})},{id:nt.RemoveDialog,up:({dialog:e,...t})=>t},{id:nt.AddToolLockMode,up:e=>({...e,isToolLocked:!1})},{id:nt.RemoveExtraPropsForNextShape,up:({propsForNextShape:e,...t})=>({...t,propsForNextShape:Object.fromEntries(Object.entries(e).filter(([n])=>["color","labelColor","dash","fill","size","font","align","verticalAlign","icon","geo","arrowheadStart","arrowheadEnd","spline"].includes(n)))})},{id:nt.AddLabelColor,up:({propsForNextShape:e,...t})=>({...t,propsForNextShape:{...e,labelColor:"black"}})},{id:nt.AddFollowingUserId,up:e=>({...e,followingUserId:null})},{id:nt.RemoveAlignJustify,up:e=>{let t=e.propsForNextShape.align;return t==="justify"&&(t="start"),{...e,propsForNextShape:{...e.propsForNextShape,align:t}}}},{id:nt.AddZoom,up:e=>({...e,zoomBrush:null})},{id:nt.AddVerticalAlign,up:e=>({...e,propsForNextShape:{...e.propsForNextShape,verticalAlign:"middle"}})},{id:nt.AddScribbleDelay,up:e=>e.scribble!==null?{...e,scribble:{...e.scribble,delay:0}}:{...e}},{id:nt.RemoveUserId,up:({userId:e,...t})=>t},{id:nt.AddIsPenModeAndIsGridMode,up:e=>({...e,isPenMode:!1,isGridMode:!1})},{id:nt.HoistOpacity,up:({propsForNextShape:{opacity:e,...t},...n})=>({...n,opacityForNextShape:Number(e??"1"),propsForNextShape:t})},{id:nt.AddChat,up:e=>({...e,chatMessage:"",isChatting:!1})},{id:nt.AddHighlightedUserIds,up:e=>({...e,highlightedUserIds:[]})},{id:nt.ReplacePropsForNextShapeWithStylesForNextShape,up:({propsForNextShape:e,...t})=>({...t,stylesForNextShape:{}})},{id:nt.AddMeta,up:e=>({...e,meta:{}})},{id:nt.RemoveCursorColor,up:e=>{const{color:t,...n}=e.cursor;return{...e,cursor:n}}},{id:nt.AddLonelyProperties,up:e=>({...e,canMoveCamera:!0,isFocused:!1,devicePixelRatio:1,isCoarsePointer:!1,openMenus:[],isChangingStyle:!1,isReadOnly:!1})},{id:nt.ReadOnlyReadonly,up:({isReadOnly:e,...t})=>({...t,isReadonly:e})},{id:nt.AddHoveringCanvas,up:e=>({...e,isHoveringCanvas:null})},{id:nt.AddScribbles,up:({scribble:e,...t})=>({...t,scribbles:[]})},{id:nt.AddInset,up:e=>({...e,insets:[!1,!1,!1,!1]}),down:({insets:e,...t})=>({...t})},{id:nt.AddDuplicateProps,up:e=>({...e,duplicateProps:null}),down:({duplicateProps:e,...t})=>({...t})}]}),In="instance:instance",kL=ge.refine(e=>{if(!e.startsWith("page:")&&!e.startsWith("shape:"))throw new Error('Parent ID must start with "page:" or "shape:"');return e}),_r=mr("shape");function TL(e,t,n){return ve({id:_r,typeName:on("shape"),x:he,y:he,rotation:he,index:K0,parentId:kL,type:on(e),isLocked:we,opacity:ck,props:t?ve(t):pn,meta:n?ve(n):pn})}const $L=Qo("instance_page_state",ve({typeName:on("instance_page_state"),id:mr("instance_page_state"),pageId:nu,selectedShapeIds:Nt(_r),hintingShapeIds:Nt(_r),erasingShapeIds:Nt(_r),hoveredShapeId:_r.nullable(),editingShapeId:_r.nullable(),croppingShapeId:_r.nullable(),focusedGroupId:_r.nullable(),meta:pn})),Gc=sr("com.tldraw.instance_page_state",{AddCroppingId:1,RemoveInstanceIdAndCameraId:2,AddMeta:3,RenameProperties:4,RenamePropertiesAgain:5}),ML=xr({sequenceId:"com.tldraw.instance_page_state",recordType:"instance_page_state",sequence:[{id:Gc.AddCroppingId,up(e){e.croppingShapeId=null}},{id:Gc.RemoveInstanceIdAndCameraId,up(e){delete e.instanceId,delete e.cameraId}},{id:Gc.AddMeta,up:e=>{e.meta={}}},{id:Gc.RenameProperties,up:e=>{},down:e=>{}},{id:Gc.RenamePropertiesAgain,up:e=>{e.selectedShapeIds=e.selectedIds,delete e.selectedIds,e.hintingShapeIds=e.hintingIds,delete e.hintingIds,e.erasingShapeIds=e.erasingIds,delete e.erasingIds,e.hoveredShapeId=e.hoveredId,delete e.hoveredId,e.editingShapeId=e.editingId,delete e.editingId,e.croppingShapeId=e.croppingShapeId??e.croppingId??null,delete e.croppingId,e.focusedGroupId=e.focusLayerId,delete e.focusLayerId},down:e=>{e.selectedIds=e.selectedShapeIds,delete e.selectedShapeIds,e.hintingIds=e.hintingShapeIds,delete e.hintingShapeIds,e.erasingIds=e.erasingShapeIds,delete e.erasingShapeIds,e.hoveredId=e.hoveredShapeId,delete e.hoveredShapeId,e.editingId=e.editingShapeId,delete e.editingShapeId,e.croppingId=e.croppingShapeId,delete e.croppingShapeId,e.focusLayerId=e.focusedGroupId,delete e.focusedGroupId}}]}),Zt=Zo("instance_page_state",{validator:$L,scope:"session"}).withDefaultProperties(()=>({editingShapeId:null,croppingShapeId:null,selectedShapeIds:[],hoveredShapeId:null,erasingShapeIds:[],hintingShapeIds:[],focusedGroupId:null,meta:{}})),AL=Qo("pointer",ve({typeName:on("pointer"),id:mr("pointer"),x:he,y:he,lastActivityTimestamp:he,meta:pn})),jL=sr("com.tldraw.pointer",{AddMeta:1}),OL=xr({sequenceId:"com.tldraw.pointer",recordType:"pointer",sequence:[{id:jL.AddMeta,up:e=>{e.meta={}}}]}),V0=Zo("pointer",{validator:AL,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,lastActivityTimestamp:0,meta:{}})),Fp=V0.createId("pointer"),DL=Qo("instance_presence",ve({typeName:on("instance_presence"),id:mr("instance_presence"),userId:ge,userName:ge,lastActivityTimestamp:he,followingUserId:ge.nullable(),cursor:ve({x:he,y:he,type:ak,rotation:he}),color:ge,camera:ve({x:he,y:he,z:he}),screenBounds:$l,selectedShapeIds:Nt(mr("shape")),currentPageId:mr("page"),brush:$l.nullable(),scribbles:Nt(lk),chatMessage:ge,meta:pn})),Yc=sr("com.tldraw.instance_presence",{AddScribbleDelay:1,RemoveInstanceId:2,AddChatMessage:3,AddMeta:4,RenameSelectedShapeIds:5}),RL=xr({sequenceId:"com.tldraw.instance_presence",recordType:"instance_presence",sequence:[{id:Yc.AddScribbleDelay,up:e=>{e.scribble!==null&&(e.scribble.delay=0)}},{id:Yc.RemoveInstanceId,up:e=>{delete e.instanceId}},{id:Yc.AddChatMessage,up:e=>{e.chatMessage=""}},{id:Yc.AddMeta,up:e=>{e.meta={}}},{id:Yc.RenameSelectedShapeIds,up:e=>{}}]}),LL=Zo("instance_presence",{validator:DL,scope:"presence"}).withDefaultProperties(()=>({lastActivityTimestamp:0,followingUserId:null,color:"#FF0000",camera:{x:0,y:0,z:1},cursor:{x:0,y:0,type:"default",rotation:0},screenBounds:{x:0,y:0,w:1,h:1},selectedShapeIds:[],brush:null,scribbles:[],chatMessage:"",meta:{}})),FL=Qo("document",ve({typeName:on("document"),id:on("document:document"),gridSize:he,name:ge,meta:pn})),h1=sr("com.tldraw.document",{AddName:1,AddMeta:2}),NL=xr({sequenceId:"com.tldraw.document",recordType:"document",sequence:[{id:h1.AddName,up:e=>{e.name=""},down:e=>{delete e.name}},{id:h1.AddMeta,up:e=>{e.meta={}}}]}),G0=Zo("document",{validator:FL,scope:"document"}).withDefaultProperties(()=>({gridSize:10,name:"",meta:{}})),FS=G0.createId("document");function zL(e,t){return e.index<t.index?-1:e.index>t.index?1:0}function p1(e){e.typeName==="asset"&&("src"in e&&(e.src="<redacted>"),"src"in e.props&&(e.props.src="<redacted>"))}const BL=({error:e,phase:t,record:n,recordBefore:r})=>{throw D0(e,{tags:{origin:"store.validateRecord",storePhase:t,isExistingValidationIssue:t==="initialize"},extras:{recordBefore:r?p1(Ye(r)):void 0,recordAfter:p1(Ye(n))}}),e};function UL(){return[Ho.create({id:"page:page",name:"Page 1",index:"a1",meta:{}})]}function HL(e){const t=e.query.ids("page"),n=()=>{if(!e.has(FS))return e.put([G0.create({id:FS,name:e.props.defaultName})]),n();if(!e.has(Fp))return e.put([V0.create({id:Fp})]),n();const r=t.get();if(r.size===0)return e.put(UL()),n();const o=()=>[...r].map(c=>e.get(c)).sort(zL)[0].id,s=e.get(In);if(s){if(!r.has(s.currentPageId))return e.put([{...s,currentPageId:o()}]),n()}else return e.put([e.schema.types.instance.create({id:In,currentPageId:o(),exportBackground:!0})]),n();const i=new Set,a=new Set;for(const c of r){const l=Zt.createId(c);e.has(l)||i.add(l);const u=hn.createId(c);e.has(u)||a.add(u)}i.size>0&&e.put([...i].map(c=>Zt.create({id:c,pageId:Zt.parseId(c)}))),a.size>0&&e.put([...a].map(c=>hn.create({id:c})))};return n}const KL=W0("bookmark",ve({title:ge,description:ge,image:ge,src:vc.nullable()})),WL=sr("com.tldraw.asset.bookmark",{MakeUrlsValid:1}),VL=xr({sequenceId:"com.tldraw.asset.bookmark",recordType:"asset",filter:e=>e.type==="bookmark",sequence:[{id:WL.MakeUrlsValid,up:e=>{vc.isValid(e.props.src)||(e.props.src="")},down:e=>{}}]}),GL=W0("image",ve({w:he,h:he,name:ge,isAnimated:we,mimeType:ge.nullable(),src:vc.nullable()})),sm=sr("com.tldraw.asset.image",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3}),YL=xr({sequenceId:"com.tldraw.asset.image",recordType:"asset",filter:e=>e.type==="image",sequence:[{id:sm.AddIsAnimated,up:e=>{e.props.isAnimated=!1},down:e=>{delete e.props.isAnimated}},{id:sm.RenameWidthHeight,up:e=>{e.props.w=e.props.width,e.props.h=e.props.height,delete e.props.width,delete e.props.height},down:e=>{e.props.width=e.props.w,e.props.height=e.props.h,delete e.props.w,delete e.props.h}},{id:sm.MakeUrlsValid,up:e=>{vc.isValid(e.props.src)||(e.props.src="")},down:e=>{}}]}),XL=W0("video",ve({w:he,h:he,name:ge,isAnimated:we,mimeType:ge.nullable(),src:vc.nullable()})),im=sr("com.tldraw.asset.video",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3}),qL=xr({sequenceId:"com.tldraw.asset.video",recordType:"asset",filter:e=>e.type==="video",sequence:[{id:im.AddIsAnimated,up:e=>{e.props.isAnimated=!1},down:e=>{delete e.props.isAnimated}},{id:im.RenameWidthHeight,up:e=>{e.props.w=e.props.width,e.props.h=e.props.height,delete e.props.width,delete e.props.height},down:e=>{e.props.width=e.props.w,e.props.height=e.props.h,delete e.props.w,delete e.props.h}},{id:im.MakeUrlsValid,up:e=>{vc.isValid(e.props.src)||(e.props.src="")},down:e=>{}}]}),ZL=Qo("asset",H0("type",{image:GL,video:XL,bookmark:KL})),QL=sr("com.tldraw.asset",{AddMeta:1}),JL=xr({sequenceId:"com.tldraw.asset",recordType:"asset",sequence:[{id:QL.AddMeta,up:e=>{e.meta={}}}]}),Si=Zo("asset",{validator:ZL,scope:"document"}).withDefaultProperties(()=>({meta:{}}));let e5=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");class an{constructor(t,n,r){this.id=t,this.defaultValue=n,this.type=r}static define(t,n){const{defaultValue:r,type:o=lL}=n;return new an(t,r,o)}static defineEnum(t,n){const{defaultValue:r,values:o}=n;return new t5(t,r,o)}validate(t){return this.type.validate(t)}validateUsingKnownGoodVersion(t,n){return this.type.validateUsingKnownGoodVersion?this.type.validateUsingKnownGoodVersion(t,n):this.validate(n)}}class t5 extends an{constructor(t,n,r){super(t,n,sk(...r)),this.values=r}}const Sd=sr("com.tldraw.shape",{AddIsLocked:1,HoistOpacity:2,AddMeta:3,AddWhite:4}),n5=xr({sequenceId:"com.tldraw.shape",recordType:"shape",sequence:[{id:Sd.AddIsLocked,up:e=>{e.isLocked=!1},down:e=>{delete e.isLocked}},{id:Sd.HoistOpacity,up:e=>{e.opacity=Number(e.props.opacity??"1"),delete e.props.opacity},down:e=>{const t=e.opacity;delete e.opacity,e.props.opacity=t<.175?"0.1":t<.375?"0.25":t<.625?"0.5":t<.875?"0.75":"1"}},{id:Sd.AddMeta,up:e=>{e.meta={}}},{id:Sd.AddWhite,up:e=>{},down:e=>{e.props.color==="white"&&(e.props.color="black")}}]});function $a(e){return e?e.typeName==="shape":!1}function Kn(e){return e?e.startsWith("shape:"):!1}function Be(e){return`shape:${e??e5()}`}function uk(e){const t=new Map;for(const[n,r]of Object.entries(e))if(r instanceof an){if(t.has(r))throw new Error(`Duplicate style prop ${r.id}. Each style prop can only be used once within a shape.`);t.set(r,n)}return t}const gt="retired";function fo(e,t){return Mf(t,(n,r)=>`com.tldraw.shape.${e}/${r}`)}function r5(e){const t=[];for(const[n,{migrations:r}]of Object.entries(e)){const o=`com.tldraw.shape.${n}`;r?"sequenceId"in r?(_t(o===r.sequenceId,`sequenceId mismatch for ${n} shape migrations. Expected '${o}', got '${r.sequenceId}'`),t.push(r)):"sequence"in r?t.push(Tl({sequenceId:o,retroactive:!1,sequence:r.sequence.map(s=>"id"in s?{id:s.id,scope:"record",filter:i=>i.typeName==="shape"&&i.type===n,dependsOn:s.dependsOn,up:i=>{const a=s.up(i.props);a&&(i.props=a)},down:typeof s.down=="function"?i=>{const a=s.down(i.props);a&&(i.props=a)}:void 0}:s)})):t.push(Tl({sequenceId:o,retroactive:!1,sequence:Object.keys(r.migrators).map(s=>Number(s)).sort((s,i)=>s-i).map(s=>({id:`${o}/${s}`,scope:"record",filter:i=>i.typeName==="shape"&&i.type===n,up:i=>{const a=r.migrators[s].up(i);if(a)return a},down:i=>{const a=r.migrators[s].down(i);if(a)return a}}))})):t.push(Tl({sequenceId:o,retroactive:!1,sequence:[]}))}return t}function o5(e){return Zo("shape",{scope:"document",validator:Qo("shape",H0("type",Mf(e,(t,{props:n,meta:r})=>TL(t,n,r))))}).withDefaultProperties(()=>({x:0,y:0,rotation:0,isLocked:!1,opacity:1,meta:{}}))}const dk=["black","grey","light-violet","violet","blue","light-blue","yellow","orange","green","light-green","light-red","red","white"],Np={lightMode:{id:"light",text:"#000000",background:"rgb(249, 250, 251)",solid:"#fcfffe",black:{solid:"#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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",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",semi:"#f5f5f5",pattern:"#f9f9f9",note:{fill:"#eaeaea",text:"#1d1d1d"},highlight:{srgb:"#ffffff",p3:"color(display-p3 1 1 1)"}}}};function Jo(e){return e.isDarkMode?Np.darkMode:Np.lightMode}const tr=an.defineEnum("tldraw:color",{defaultValue:"black",values:dk}),hk=an.defineEnum("tldraw:labelColor",{defaultValue:"black",values:dk}),Ti=an.defineEnum("tldraw:dash",{defaultValue:"draw",values:["draw","solid","dashed","dotted"]}),sc=an.defineEnum("tldraw:fill",{defaultValue:"none",values:["none","semi","solid","pattern"]}),ao=an.defineEnum("tldraw:font",{defaultValue:"draw",values:["draw","sans","serif","mono"]}),pk={draw:"'tldraw_draw', sans-serif",sans:"'tldraw_sans', sans-serif",serif:"'tldraw_serif', serif",mono:"'tldraw_mono', monospace"},co=an.defineEnum("tldraw:size",{defaultValue:"m",values:["s","m","l","xl"]}),fk=["arrow","triangle","square","dot","pipe","diamond","inverted","bar","none"],zp=an.defineEnum("tldraw:arrowheadStart",{defaultValue:"none",values:fk}),Bp=an.defineEnum("tldraw:arrowheadEnd",{defaultValue:"arrow",values:fk}),f1=H0("type",{binding:ve({type:on("binding"),boundShapeId:_r,normalizedAnchor:tu,isExact:we,isPrecise:we}),point:ve({type:on("point"),x:he,y:he})}),gk={labelColor:hk,color:tr,fill:sc,dash:Ti,size:co,arrowheadStart:zp,arrowheadEnd:Bp,font:ao,start:f1,end:f1,bend:he,text:ge,labelPosition:he},am=fo("arrow",{AddLabelColor:1,AddIsPrecise:2,AddLabelPosition:3}),mk={sequence:[{id:am.AddLabelColor,up:e=>{e.labelColor="black"},down:gt},{id:am.AddIsPrecise,up:({start:e,end:t})=>{e.type==="binding"&&(e.isPrecise=!(e.normalizedAnchor.x===.5&&e.normalizedAnchor.y===.5)),t.type==="binding"&&(t.isPrecise=!(t.normalizedAnchor.x===.5&&t.normalizedAnchor.y===.5))},down:({start:e,end:t})=>{e.type==="binding"&&(e.isPrecise||(e.normalizedAnchor={x:.5,y:.5}),delete e.isPrecise),t.type==="binding"&&(t.isPrecise||(t.normalizedAnchor={x:.5,y:.5}),delete t.isPrecise)}},{id:am.AddLabelPosition,up:e=>{e.labelPosition=.5},down:e=>{delete e.labelPosition}}]},yk={w:On,h:On,assetId:Df.nullable(),url:er},g1=fo("bookmark",{NullAssetId:1,MakeUrlsValid:2}),Sk={sequence:[{id:g1.NullAssetId,up:e=>{e.assetId===void 0&&(e.assetId=null)},down:gt},{id:g1.MakeUrlsValid,up:e=>{er.isValid(e.url)||(e.url="")},down:e=>{}}]},vk=ve({type:sk("free","straight"),points:Nt(tu)}),xk={color:tr,fill:sc,dash:Ti,size:co,segments:Nt(vk),isComplete:we,isClosed:we,isPen:we},s5=fo("draw",{AddInPen:1}),wk={sequence:[{id:s5.AddInPen,up:e=>{const{points:t}=e.segments[0];if(t.length===0){e.isPen=!1;return}let n=!(t[0].z===0||t[0].z===.5);t[1]&&(n=n&&!(t[1].z===0||t[1].z===.5)),e.isPen=n},down:gt}]};var i5={};const m1=/(^\/r\/[^/]+\/?$)/,Ne=e=>{try{return new URL(e)}catch{return}},Tu=[{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:e=>{const t=Ne(e);if(t&&t.pathname.match(m1))return e},fromEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(m1))return e}},{type:"figma",title:"Figma",hostnames:["figma.com"],width:720,height:500,doesResize:!0,toEmbedUrl:e=>{if(e.match(/https:\/\/([\w\.-]+\.)?figma.com\/(file|proto)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/)&&!e.includes("figma.com/embed"))return`https://www.figma.com/embed?embed_host=share&url=${e}`},fromEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(/^\/embed\/?$/)){const n=t.searchParams.get("url");if(n)return n}}},{type:"google_maps",title:"Google Maps",hostnames:["google.*"],width:720,height:500,doesResize:!0,toEmbedUrl:e=>{if(e.includes("/maps/")){const t=e.match(/@(.*),(.*),(.*)z/);let n;if(t){const[,r,o,s]=t;n=`https://${new URL(e).host.replace("www.","")}/maps/embed/v1/view?key=${i5.NEXT_PUBLIC_GC_API_KEY}¢er=${r},${o}&zoom=${s}`}else n="";return n}},fromEmbedUrl:e=>{const t=Ne(e);if(!t)return;if(t.pathname.match(/^\/maps\/embed\/v1\/view\/?$/)&&t.searchParams.has("center")&&t.searchParams.get("zoom")){const r=t.searchParams.get("zoom"),[o,s]=t.searchParams.get("center").split(",");return`https://www.google.com/maps/@${o},${s},${r}z`}}},{type:"val_town",title:"Val Town",hostnames:["val.town"],minWidth:260,minHeight:100,width:720,height:500,doesResize:!0,toEmbedUrl:e=>{const t=Ne(e),n=t&&t.pathname.match(/\/v\/([^/]+)\/?/);if(n)return`https://www.val.town/embed/${n[1]}`},fromEmbedUrl:e=>{const t=Ne(e),n=t&&t.pathname.match(/\/embed\/([^/]+)\/?/);if(n)return`https://www.val.town/v/${n[1]}`}},{type:"codesandbox",title:"CodeSandbox",hostnames:["codesandbox.io"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,toEmbedUrl:e=>{const t=Ne(e),n=t&&t.pathname.match(/\/s\/([^/]+)\/?/);if(n)return`https://codesandbox.io/embed/${n[1]}`},fromEmbedUrl:e=>{const t=Ne(e),n=t&&t.pathname.match(/\/embed\/([^/]+)\/?/);if(n)return`https://codesandbox.io/s/${n[1]}`}},{type:"codepen",title:"Codepen",hostnames:["codepen.io"],minWidth:300,minHeight:300,width:520,height:400,doesResize:!0,toEmbedUrl:e=>{const t=/https:\/\/codepen.io\/([^/]+)\/pen\/([^/]+)/,n=e.match(t);if(n){const[r,o,s]=n;return`https://codepen.io/${o}/embed/${s}`}},fromEmbedUrl:e=>{const t=/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/,n=e.match(t);if(n){const[r,o,s]=n;return`https://codepen.io/${o}/pen/${s}`}}},{type:"scratch",title:"Scratch",hostnames:["scratch.mit.edu"],width:520,height:400,doesResize:!1,toEmbedUrl:e=>{const t=/https?:\/\/scratch.mit.edu\/projects\/([^/]+)/,n=e.match(t);if(n){const[r,o]=n;return`https://scratch.mit.edu/projects/embed/${o}`}},fromEmbedUrl:e=>{const t=/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/,n=e.match(t);if(n){const[r,o]=n;return`https://scratch.mit.edu/projects/${o}`}}},{type:"youtube",title:"YouTube",hostnames:["*.youtube.com","youtube.com","youtu.be"],width:800,height:450,doesResize:!0,overridePermissions:{"allow-presentation":!0},isAspectRatioLocked:!0,toEmbedUrl:e=>{const t=Ne(e);if(!t)return;const n=t.hostname.replace(/^www./,"");if(n==="youtu.be")return`https://www.youtube.com/embed/${t.pathname.split("/").filter(Boolean)[0]}`;if((n==="youtube.com"||n==="m.youtube.com")&&t.pathname.match(/^\/watch/))return`https://www.youtube.com/embed/${t.searchParams.get("v")}`},fromEmbedUrl:e=>{const t=Ne(e);if(!t)return;if(t.hostname.replace(/^www./,"")==="youtube.com"){const r=t.pathname.match(/^\/embed\/([^/]+)\/?/);if(r)return`https://www.youtube.com/watch?v=${r[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",toEmbedUrl:e=>{const t=Ne(e),n=t==null?void 0:t.searchParams.get("cid");if(t!=null&&t.pathname.match(/\/calendar\/u\/0/)&&n){t.pathname="/calendar/embed";const r=Array.from(t.searchParams.keys());for(const o of r)t.searchParams.delete(o);return t.searchParams.set("src",n),t.href}},fromEmbedUrl:e=>{const t=Ne(e),n=t==null?void 0:t.searchParams.get("src");if(t!=null&&t.pathname.match(/\/calendar\/embed/)&&n){t.pathname="/calendar/u/0";const r=Array.from(t.searchParams.keys());for(const o of r)t.searchParams.delete(o);return t.searchParams.set("cid",n),t.href}}},{type:"google_slides",title:"Google Slides",hostnames:["docs.google.*"],width:720,height:500,minWidth:460,minHeight:360,doesResize:!0,toEmbedUrl:e=>{const t=Ne(e);if(t!=null&&t.pathname.match(/^\/presentation/)&&(t!=null&&t.pathname.match(/\/pub\/?$/))){t.pathname=t.pathname.replace(/\/pub$/,"/embed");const n=Array.from(t.searchParams.keys());for(const r of n)t.searchParams.delete(r);return t.href}},fromEmbedUrl:e=>{const t=Ne(e);if(t!=null&&t.pathname.match(/^\/presentation/)&&(t!=null&&t.pathname.match(/\/embed\/?$/))){t.pathname=t.pathname.replace(/\/embed$/,"/pub");const n=Array.from(t.searchParams.keys());for(const r of n)t.searchParams.delete(r);return t.href}}},{type:"github_gist",title:"GitHub Gist",hostnames:["gist.github.com"],width:720,height:500,doesResize:!0,toEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(/\/([^/]+)\/([^/]+)/))return e.split("/").pop()?e:void 0},fromEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(/\/([^/]+)\/([^/]+)/))return e.split("/").pop()?e:void 0}},{type:"replit",title:"Replit",hostnames:["replit.com"],width:720,height:500,doesResize:!0,toEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(/\/@([^/]+)\/([^/]+)/))return`${e}?embed=true`},fromEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(/\/@([^/]+)\/([^/]+)/)&&t.searchParams.has("embed"))return t.searchParams.delete("embed"),t.href}},{type:"felt",title:"Felt",hostnames:["felt.com"],width:720,height:500,doesResize:!0,toEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(/^\/map\//))return t.origin+"/embed"+t.pathname},fromEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(/^\/embed\/map\//))return t.pathname=t.pathname.replace(/^\/embed/,""),t.href}},{type:"spotify",title:"Spotify",hostnames:["open.spotify.com"],width:720,height:500,minHeight:500,overrideOutlineRadius:12,doesResize:!0,toEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(/^\/(artist|album)\//))return t.origin+"/embed"+t.pathname},fromEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(/^\/embed\/(artist|album)\//))return t.origin+t.pathname.replace(/^\/embed/,"")}},{type:"vimeo",title:"Vimeo",hostnames:["vimeo.com","player.vimeo.com"],width:640,height:360,doesResize:!0,isAspectRatioLocked:!0,toEmbedUrl:e=>{const t=Ne(e);if(t&&t.hostname==="vimeo.com"&&t.pathname.match(/^\/[0-9]+/))return"https://player.vimeo.com/video/"+t.pathname.split("/")[1]+"?title=0&byline=0"},fromEmbedUrl:e=>{const t=Ne(e);if(t&&t.hostname==="player.vimeo.com"){const n=t.pathname.match(/^\/video\/([^/]+)\/?$/);if(n)return"https://vimeo.com/"+n[1]}}},{type:"excalidraw",title:"Excalidraw",hostnames:["excalidraw.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!0,toEmbedUrl:e=>{const t=Ne(e);if(t&&t.hash.match(/#room=/))return e},fromEmbedUrl:e=>{const t=Ne(e);if(t&&t.hash.match(/#room=/))return e}},{type:"observable",title:"Observable",hostnames:["observablehq.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!1,backgroundColor:"#fff",toEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(/^\/@([^/]+)\/([^/]+)\/?$/))return`${t.origin}/embed${t.pathname}?cell=*`;if(t&&t.pathname.match(/^\/d\/([^/]+)\/?$/)){const n=t.pathname.replace(/^\/d/,"");return`${t.origin}/embed${n}?cell=*`}},fromEmbedUrl:e=>{const t=Ne(e);if(t&&t.pathname.match(/^\/embed\/@([^/]+)\/([^/]+)\/?$/))return`${t.origin}${t.pathname.replace("/embed","")}#cell-*`;if(t&&t.pathname.match(/^\/embed\/([^/]+)\/?$/))return`${t.origin}${t.pathname.replace("/embed","/d")}#cell-*`}}],a5={"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},bk={w:On,h:On,url:ge},vd=fo("embed",{GenOriginalUrlInEmbed:1,RemoveDoesResize:2,RemoveTmpOldUrl:3,RemovePermissionOverrides:4}),Pk={sequence:[{id:vd.GenOriginalUrlInEmbed,up:e=>{try{const t=e.url,n=new URL(t).host.replace("www.","");let r;for(const o of Tu)if(o.hostnames.includes(n))try{r=o.fromEmbedUrl(t)}catch(s){console.warn(s)}e.tmpOldUrl=e.url,e.url=r??""}catch{e.url="",e.tmpOldUrl=e.url}},down:gt},{id:vd.RemoveDoesResize,up:e=>{delete e.doesResize},down:gt},{id:vd.RemoveTmpOldUrl,up:e=>{delete e.tmpOldUrl},down:gt},{id:vd.RemovePermissionOverrides,up:e=>{delete e.overridePermissions},down:gt}]},Ck={w:On,h:On,name:ge},Ik={sequence:[]},ru=an.defineEnum("tldraw:horizontalAlign",{defaultValue:"middle",values:["start","middle","end","start-legacy","end-legacy","middle-legacy"]}),Up=an.defineEnum("tldraw:verticalAlign",{defaultValue:"middle",values:["start","middle","end"]}),oo=an.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"]}),Ek={geo:oo,labelColor:hk,color:tr,fill:sc,dash:Ti,size:co,font:ao,align:ru,verticalAlign:Up,url:er,w:On,h:On,growY:Rp,text:ge},us=fo("geo",{AddUrlProp:1,AddLabelColor:2,RemoveJustify:3,AddCheckBox:4,AddVerticalAlign:5,MigrateLegacyAlign:6,AddCloud:7,MakeUrlsValid:8}),_k={sequence:[{id:us.AddUrlProp,up:e=>{e.url=""},down:gt},{id:us.AddLabelColor,up:e=>{e.labelColor="black"},down:gt},{id:us.RemoveJustify,up:e=>{e.align==="justify"&&(e.align="start")},down:gt},{id:us.AddCheckBox,up:e=>{},down:gt},{id:us.AddVerticalAlign,up:e=>{e.verticalAlign="middle"},down:gt},{id:us.MigrateLegacyAlign,up:e=>{let t;switch(e.align){case"start":t="start-legacy";break;case"end":t="end-legacy";break;default:t="middle-legacy";break}e.align=t},down:gt},{id:us.AddCloud,up:e=>{},down:gt},{id:us.MakeUrlsValid,up:e=>{er.isValid(e.url)||(e.url="")},down:e=>{}}]},kk={},Tk={sequence:[]},$k={color:tr,size:co,segments:Nt(vk),isComplete:we,isPen:we},Mk={sequence:[]},c5=ve({topLeft:tu,bottomRight:tu}),Ak={w:On,h:On,playing:we,url:er,assetId:Df.nullable(),crop:c5.nullable()},cm=fo("image",{AddUrlProp:1,AddCropProp:2,MakeUrlsValid:3}),jk={sequence:[{id:cm.AddUrlProp,up:e=>{e.url=""},down:gt},{id:cm.AddCropProp,up:e=>{e.crop=null},down:e=>{delete e.crop}},{id:cm.MakeUrlsValid,up:e=>{er.isValid(e.url)||(e.url="")},down:e=>{}}]},Hp=an.defineEnum("tldraw:spline",{defaultValue:"line",values:["cubic","line"]}),l5=ve({id:ge,index:K0,x:he,y:he}),Ok={color:tr,dash:Ti,size:co,spline:Hp,points:Lp(ge,l5)},xd=fo("line",{AddSnapHandles:1,RemoveExtraHandleProps:2,HandlesToPoints:3,PointIndexIds:4}),Dk={sequence:[{id:xd.AddSnapHandles,up:e=>{for(const t of Object.values(e.handles))t.canSnap=!0},down:gt},{id:xd.RemoveExtraHandleProps,up:e=>{e.handles=R0(Object.values(e.handles).map(t=>[t.index,{x:t.x,y:t.y}]))},down:e=>{const t=Object.entries(e.handles).map(([n,r])=>({index:n,...r})).sort(en);e.handles=Object.fromEntries(t.map((n,r)=>{const o=r===0?"start":r===t.length-1?"end":`handle:${n.index}`;return[o,{id:o,type:"vertex",canBind:!1,canSnap:!0,index:n.index,x:n.x,y:n.y}]}))}},{id:xd.HandlesToPoints,up:e=>{const t=Object.entries(e.handles).map(([n,{x:r,y:o}])=>({x:r,y:o,index:n})).sort(en);e.points=t.map(({x:n,y:r})=>({x:n,y:r})),delete e.handles},down:e=>{const t=eu(e.points.length);e.handles=Object.fromEntries(e.points.map((n,r)=>[t[r],{x:n.x,y:n.y}])),delete e.points}},{id:xd.PointIndexIds,up:e=>{const t=eu(e.points.length);e.points=Object.fromEntries(e.points.map((n,r)=>{const o=t[r];return[o,{id:o,index:o,x:n.x,y:n.y}]}))},down:e=>{const t=Object.values(e.points).sort(en);e.points=t.map(({x:n,y:r})=>({x:n,y:r}))}}]},Rk={color:tr,size:co,font:ao,fontSizeAdjustment:Rp,align:ru,verticalAlign:Up,growY:Rp,url:er,text:ge},ea=fo("note",{AddUrlProp:1,RemoveJustify:2,MigrateLegacyAlign:3,AddVerticalAlign:4,MakeUrlsValid:5,AddFontSizeAdjustment:6}),Lk={sequence:[{id:ea.AddUrlProp,up:e=>{e.url=""},down:gt},{id:ea.RemoveJustify,up:e=>{e.align==="justify"&&(e.align="start")},down:gt},{id:ea.MigrateLegacyAlign,up:e=>{switch(e.align){case"start":e.align="start-legacy";return;case"end":e.align="end-legacy";return;default:e.align="middle-legacy";return}},down:gt},{id:ea.AddVerticalAlign,up:e=>{e.verticalAlign="middle"},down:gt},{id:ea.MakeUrlsValid,up:e=>{er.isValid(e.url)||(e.url="")},down:e=>{}},{id:ea.AddFontSizeAdjustment,up:e=>{e.fontSizeAdjustment=0},down:e=>{delete e.fontSizeAdjustment}}]},Fk={color:tr,size:co,font:ao,align:ru,w:On,text:ge,scale:On,autoSize:we},u5=fo("text",{RemoveJustify:1}),Nk={sequence:[{id:u5.RemoveJustify,up:e=>{e.align==="justify"&&(e.align="start")},down:gt}]},zk={w:On,h:On,time:he,playing:we,url:er,assetId:Df.nullable()},y1=fo("video",{AddUrlProp:1,MakeUrlsValid:2}),Bk={sequence:[{id:y1.AddUrlProp,up:e=>{e.url=""},down:gt},{id:y1.MakeUrlsValid,up:e=>{er.isValid(e.url)||(e.url="")},down:e=>{}}]},wd=sr("com.tldraw.store",{RemoveCodeAndIconShapeTypes:1,AddInstancePresenceType:2,RemoveTLUserAndPresenceAndAddPointer:3,RemoveUserDocument:4}),d5=Tl({sequenceId:"com.tldraw.store",retroactive:!1,sequence:[{id:wd.RemoveCodeAndIconShapeTypes,scope:"store",up:e=>{for(const[t,n]of An(e))n.typeName==="shape"&&(n.type==="icon"||n.type==="code")&&delete e[t]}},{id:wd.AddInstancePresenceType,scope:"store",up(e){}},{id:wd.RemoveTLUserAndPresenceAndAddPointer,scope:"store",up:e=>{for(const[t,n]of An(e))n.typeName.match(/^(user|user_presence)$/)&&delete e[t]}},{id:wd.RemoveUserDocument,scope:"store",up:e=>{for(const[t,n]of An(e))n.typeName.match("user_document")&&delete e[t]}}]}),h5={arrow:{migrations:mk,props:gk},bookmark:{migrations:Sk,props:yk},draw:{migrations:wk,props:xk},embed:{migrations:Pk,props:bk},frame:{migrations:Ik,props:Ck},geo:{migrations:_k,props:Ek},group:{migrations:Tk,props:kk},highlight:{migrations:Mk,props:$k},image:{migrations:jk,props:Ak},line:{migrations:Dk,props:Ok},note:{migrations:Lk,props:Rk},text:{migrations:Nk,props:Fk},video:{migrations:Bk,props:zk}};function p5({shapes:e=h5,migrations:t}={}){const n=new Map;for(const s of bt(e))for(const i of uk(s.props??{}).keys()){if(n.has(i.id)&&n.get(i.id)!==i)throw new Error(`Multiple StyleProp instances with the same id: ${i.id}`);n.set(i.id,i)}const r=o5(e),o=EL(n);return B0.create({asset:Si,camera:hn,document:G0,instance:o,instance_page_state:Zt,page:Ho,instance_presence:LL,pointer:V0,shape:r},{migrations:[d5,JL,yL,NL,_L,ML,IL,RL,OL,n5,VL,YL,qL,...r5(e),...t??[]],onValidationFailure:BL,createIntegrityChecker:HL})}const ou=[{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:"fr",label:"Français"},{locale:"gl",label:"Galego"},{locale:"hr",label:"Hrvatski"},{locale:"it",label:"Italiano"},{locale:"hu",label:"Magyar"},{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:"ru",label:"Russian"},{locale:"sl",label:"Slovenščina"},{locale:"fi",label:"Suomi"},{locale:"sv",label:"Svenska"},{locale:"vi",label:"Tiếng Việt"},{locale:"tr",label:"Türkçe"},{locale:"uk",label:"Ukrainian"},{locale:"he",label:"עברית"},{locale:"ar",label:"عربي"},{locale:"fa",label:"فارسی"},{locale:"ku",label:"کوردی"},{locale:"ne",label:"नेपाली"},{locale:"hi-in",label:"हिन्दी"},{locale:"te",label:"తెలుగు"},{locale:"th",label:"ภาษาไทย"},{locale:"my",label:"မြန်မာစာ"},{locale:"ko-kr",label:"한국어"},{locale:"ja",label:"日本語"},{locale:"zh-cn",label:"简体中文"},{locale:"zh-tw",label:"繁體中文 (台灣)"}];function f5(){const e=typeof window<"u"?window.navigator.languages??["en"]:["en"];return g5(e)}function g5(e){for(const t of e){const n=m5(t);if(n)return n}return"en"}const S1={zh:"zh-cn",pt:"pt-br",ko:"ko-kr",hi:"hi-in"};function m5(e){const t=ou.find(o=>o.locale===e.toLowerCase());if(t)return t.locale;const[n,r]=e.split(/[-_]/).map(o=>o.toLowerCase());if(r){const o=ou.find(s=>s.locale===n);if(o)return o.locale}return n in S1?S1[n]:null}var Uk={exports:{}};/*!
|
|
Copyright (c) 2018 Jed Watson.
|
|
Licensed under the MIT License (MIT), see
|
|
http://jedwatson.github.io/classnames
|
|
*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var s="",i=0;i<arguments.length;i++){var a=arguments[i];a&&(s=o(s,r(a)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var i="";for(var a in s)t.call(s,a)&&s[a]&&(i=o(i,a));return i}function o(s,i){return i?s?s+" "+i:s+i:s}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(Uk);var y5=Uk.exports;const ue=pc(y5),S5={error:null};class Hk extends x.Component{constructor(){super(...arguments);m(this,"state",S5)}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n){var r,o;(o=(r=this.props).onError)==null||o.call(r,n)}render(){const{error:n}=this.state;if(n!==null){const{fallback:r}=this.props;return h.jsx(r,{error:n})}return this.props.children}}function su({children:e,fallback:t,...n}){return t===null?h.jsx(h.Fragment,{children:e}):h.jsx(Hk,{fallback:t,...n,children:e})}const Rf=Se.createContext({});function z(){return Se.useContext(Rf)}function v5(){return h.jsx("div",{className:"tl-background"})}function xc(e,t,n,r,o,s){x.useLayoutEffect(()=>{const i=e.current;if(!i||t===void 0)return;let a=`translate(${t}px, ${n}px)`;r!==void 0&&(a+=` scale(${r})`),o!==void 0&&(a+=` rotate(${o}rad)`),s&&(a+=` translate(${s.x}px, ${s.y}px)`),i.style.transform=a})}const nn={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:-1+(4-2*e)*e,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1,easeInQuart:e=>e*e*e*e,easeOutQuart:e=>1- --e*e*e*e,easeInOutQuart:e=>e<.5?8*e*e*e*e:1-8*--e*e*e*e,easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>1+--e*e*e*e*e,easeInOutQuint:e=>e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e,easeInSine:e=>1-Math.cos(e*Math.PI/2),easeOutSine:e=>Math.sin(e*Math.PI/2),easeInOutSine:e=>-(Math.cos(Math.PI*e)-1)/2,easeInExpo:e=>e<=0?0:Math.pow(2,10*e-10),easeOutExpo:e=>e>=1?1:1-Math.pow(2,-10*e),easeInOutExpo:e=>e<=0?0:e>=1?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2};class P{constructor(t=0,n=0,r=1){this.x=t,this.y=n,this.z=r}get pressure(){return this.z}set(t=this.x,n=this.y,r=this.z){return this.x=t,this.y=n,this.z=r,this}setTo({x:t=0,y:n=0,z:r=1}){return this.x=t,this.y=n,this.z=r,this}rot(t){if(t===0)return this;const{x:n,y:r}=this,o=Math.sin(t),s=Math.cos(t);return this.x=n*s-r*o,this.y=n*o+r*s,this}rotWith(t,n){if(n===0)return this;const r=this.x-t.x,o=this.y-t.y,s=Math.sin(n),i=Math.cos(n);return this.x=t.x+(r*i-o*s),this.y=t.y+(r*s+o*i),this}clone(){const{x:t,y:n,z:r}=this;return new P(t,n,r)}sub(t){return this.x-=t.x,this.y-=t.y,this}subXY(t,n){return this.x-=t,this.y-=n,this}subScalar(t){return this.x-=t,this.y-=t,this}add(t){return this.x+=t.x,this.y+=t.y,this}addXY(t,n){return this.x+=t,this.y+=n,this}addScalar(t){return this.x+=t,this.y+=t,this}clamp(t,n){return this.x=Math.max(this.x,t),this.y=Math.max(this.y,t),n!==void 0&&(this.x=Math.min(this.x,n),this.y=Math.min(this.y,n)),this}div(t){return this.x/=t,this.y/=t,this}divV(t){return this.x/=t.x,this.y/=t.y,this}mul(t){return this.x*=t,this.y*=t,this}mulV(t){return this.x*=t.x,this.y*=t.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(t,n){const r=P.Tan(t,this);return this.add(r.mul(n))}neg(){return this.x*=-1,this.y*=-1,this}cross(t){return this.x=this.y*t.z-this.z*t.y,this.y=this.z*t.x-this.x*t.z,this}dpr(t){return P.Dpr(this,t)}cpr(t){return P.Cpr(this,t)}len2(){return P.Len2(this)}len(){return P.Len(this)}pry(t){return P.Pry(this,t)}per(){const{x:t,y:n}=this;return this.x=n,this.y=-t,this}uni(){return P.Uni(this)}tan(t){return P.Tan(this,t)}dist(t){return P.Dist(this,t)}distanceToLineSegment(t,n){return P.DistanceToLineSegment(t,n,this)}slope(t){return P.Slope(this,t)}snapToGrid(t){return this.x=Math.round(this.x/t)*t,this.y=Math.round(this.y/t)*t,this}angle(t){return P.Angle(this,t)}toAngle(){return P.ToAngle(this)}lrp(t,n){return this.x=this.x+(t.x-this.x)*n,this.y=this.y+(t.y-this.y)*n,this}equals(t){return P.Equals(this,t)}equalsXY(t,n){return P.EqualsXY(this,t,n)}norm(){const t=this.len();return this.x=t===0?0:this.x/t,this.y=t===0?0:this.y/t,this}toFixed(){return P.ToFixed(this)}toString(){return P.ToString(P.ToFixed(this))}toJson(){return P.ToJson(this)}toArray(){return P.ToArray(this)}static Add(t,n){return new P(t.x+n.x,t.y+n.y)}static AddXY(t,n,r){return new P(t.x+n,t.y+r)}static Sub(t,n){return new P(t.x-n.x,t.y-n.y)}static SubXY(t,n,r){return new P(t.x-n,t.y-r)}static AddScalar(t,n){return new P(t.x+n,t.y+n)}static SubScalar(t,n){return new P(t.x-n,t.y-n)}static Div(t,n){return new P(t.x/n,t.y/n)}static Mul(t,n){return new P(t.x*n,t.y*n)}static DivV(t,n){return new P(t.x/n.x,t.y/n.y)}static MulV(t,n){return new P(t.x*n.x,t.y*n.y)}static Neg(t){return new P(-t.x,-t.y)}static Per(t){return new P(t.y,-t.x)}static Abs(t){return new P(Math.abs(t.x),Math.abs(t.y))}static Dist(t,n){return((t.y-n.y)**2+(t.x-n.x)**2)**.5}static DistMin(t,n,r){return(t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y)<r**2}static Dist2(t,n){return(t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y)}static Dpr(t,n){return t.x*n.x+t.y*n.y}static Cross(t,n){return new P(t.y*n.z-t.z*n.y,t.z*n.x-t.x*n.z)}static Cpr(t,n){return t.x*n.y-n.x*t.y}static Len2(t){return t.x*t.x+t.y*t.y}static Len(t){return(t.x*t.x+t.y*t.y)**.5}static Pry(t,n){return P.Dpr(t,n)/P.Len(n)}static Uni(t){return P.Div(t,P.Len(t))}static Tan(t,n){return P.Uni(P.Sub(t,n))}static Min(t,n){return new P(Math.min(t.x,n.x),Math.min(t.y,n.y))}static Max(t,n){return new P(Math.max(t.x,n.x),Math.max(t.y,n.y))}static From({x:t,y:n,z:r=1}){return new P(t,n,r)}static FromArray(t){return new P(t[0],t[1])}static Rot(t,n=0){const r=Math.sin(n),o=Math.cos(n);return new P(t.x*o-t.y*r,t.x*r+t.y*o)}static RotWith(t,n,r){const o=t.x-n.x,s=t.y-n.y,i=Math.sin(r),a=Math.cos(r);return new P(n.x+(o*a-s*i),n.y+(o*i+s*a))}static NearestPointOnLineThroughPoint(t,n,r){return P.Mul(n,P.Sub(r,t).pry(n)).add(t)}static NearestPointOnLineSegment(t,n,r,o=!0){if(P.Equals(t,r)||P.Equals(n,r))return P.From(r);const s=P.Tan(n,t),i=P.Add(t,P.Mul(s,P.Sub(r,t).pry(s)));if(o){if(i.x<Math.min(t.x,n.x))return P.Cast(t.x<n.x?t:n);if(i.x>Math.max(t.x,n.x))return P.Cast(t.x>n.x?t:n);if(i.y<Math.min(t.y,n.y))return P.Cast(t.y<n.y?t:n);if(i.y>Math.max(t.y,n.y))return P.Cast(t.y>n.y?t:n)}return i}static DistanceToLineThroughPoint(t,n,r){return P.Dist(r,P.NearestPointOnLineThroughPoint(t,n,r))}static DistanceToLineSegment(t,n,r,o=!0){return P.Dist(r,P.NearestPointOnLineSegment(t,n,r,o))}static Snap(t,n=1){return new P(Math.round(t.x/n)*n,Math.round(t.y/n)*n)}static Cast(t){return t instanceof P?t:P.From(t)}static Slope(t,n){return t.x===n.y?NaN:(t.y-n.y)/(t.x-n.x)}static IsNaN(t){return isNaN(t.x)||isNaN(t.y)}static Angle(t,n){return Math.atan2(n.y-t.y,n.x-t.x)}static Lrp(t,n,r){return P.Sub(n,t).mul(r).add(t)}static Med(t,n){return new P((t.x+n.x)/2,(t.y+n.y)/2)}static Equals(t,n){return Math.abs(t.x-n.x)<1e-4&&Math.abs(t.y-n.y)<1e-4}static EqualsXY(t,n,r){return t.x===n&&t.y===r}static Clockwise(t,n,r){return(r.x-t.x)*(n.y-t.y)-(n.x-t.x)*(r.y-t.y)<0}static Rescale(t,n){const r=P.Len(t);return new P(n*t.x/r,n*t.y/r)}static ScaleWithOrigin(t,n,r){return P.Sub(t,r).mul(n).add(r)}static ToFixed(t,n=2){return new P(+t.x.toFixed(n),+t.y.toFixed(n),+t.z.toFixed(n))}static Nudge(t,n,r){return P.Add(t,P.Tan(n,t).mul(r))}static ToString(t){return`${t.x}, ${t.y}`}static ToAngle(t){let n=Math.atan2(t.y,t.x);return n<0&&(n+=Math.PI*2),n}static FromAngle(t,n=1){return new P(Math.cos(t)*n,Math.sin(t)*n)}static ToArray(t){return[t.x,t.y,t.z]}static ToJson(t){const{x:n,y:r,z:o}=t;return{x:n,y:r,z:o}}static Average(t){const n=t.length,r=new P(0,0);if(n===0)return r;for(let o=0;o<n;o++)r.add(t[o]);return r.div(n)}static Clamp(t,n,r){return r===void 0?new P(Math.min(Math.max(t.x,n)),Math.min(Math.max(t.y,n))):new P(Math.min(Math.max(t.x,n),r),Math.min(Math.max(t.y,n),r))}static PointsBetween(t,n,r=6){const o=[];for(let s=0;s<r;s++){const i=nn.easeInQuad(s/(r-1)),a=P.Lrp(t,n,i);a.z=Math.min(1,.5+Math.abs(.5-x5(i))*.65),o.push(a)}return o}static SnapToGrid(t,n=8){return new P(Math.round(t.x/n)*n,Math.round(t.y/n)*n)}}const x5=e=>e<.5?2*e*e:-1+(4-2*e)*e;function Ft(e){return`${j(e.x)},${j(e.y)} `}function Cn(e,t){return`${j((e.x+t.x)/2)},${j((e.y+t.y)/2)} `}const Pe=Math.PI,ze=Pe/2,Oe=Pe*2,w5=Math.sin;function Ns(e,t,n){return Math.max(t,typeof n<"u"?Math.min(e,n):e)}function bd(e,t=1e10){return e?Math.round(e*t)/t:0}function Ml(e,t,n=1e-6){return Math.abs(e-t)<=n}function Kp(e,t){const n=Math.pow(e-t,2)/Math.pow(e+t,2);return Pe*(e+t)*(1+3*n/(10+Math.sqrt(4-3*n)))}function Os(e){return e=e%Oe,e<0?e=e+Oe:e===0&&(e=0),e}function $u(e,t){return e=Os(e),t=Os(t),e>t&&(t+=Oe),t-e}function Kk(e,t){return Oe-$u(e,t)}function yh(e,t){const n=(t-e)%Oe;return 2*n%Oe-n}function NS(e){return(Oe+e)%Oe}function Wp(e,t){const n=Oe/t;let r=Math.floor((NS(e)+n/2)/n)*n%Oe;return r<Pe&&(r+=Oe),r>Pe&&(r-=Oe),r}function Wk(e,t){return e===t||Ml(e%(Math.PI/2)-t%(Math.PI/2),0)}function b5(e){return e*Pe/180}function P5(e){return e*180/Pe}function $i(e,t,n){return new P(e.x,e.y).add(P.FromAngle(n,t))}function lm(e,t,n){const r=e/2,o=t/2,s=[];let i=1/0,a=-1/0,c=1/0,l=-1/0;for(let y=0;y<n;y++){const g=Oe/n,w=-ze+y*g,S=r+r*Math.cos(w),v=o+o*Math.sin(w);S<i&&(i=S),v<c&&(c=v),S>a&&(a=S),v>l&&(l=v),s.push(new P(S,v))}const u=a-i,d=l-c,p=e-u,f=t-d;if(p!==0||f!==0)for(let y=0;y<s.length;y++){const g=s[y];g.x=(g.x-i)/u*e,g.y=(g.y-c)/d*t}return s}function Xc(e,t,n,r){return e<r&&n<t}function kr(e,t,n,r){const o=Math.max(e,n),s=Math.min(t,r);return o<=s?[o,s]:null}function v1(e,t,n){return(t.x-e.x)*(n.y-e.y)-(n.x-e.x)*(t.y-e.y)}function Zn(e,t){let n=0,r,o;for(let s=0;s<t.length;s++){if(r=t[s],r.x===e.x&&r.y===e.y||(o=t[(s+1)%t.length],P.Dist(e,r)+P.Dist(e,o)===P.Dist(r,o)))return!0;r.y<=e.y?o.y>e.y&&v1(r,o,e)>0&&(n+=1):o.y<=e.y&&v1(r,o,e)<0&&(n-=1)}return n!==0}function j(e){return Math.round(e*1e4)/1e4}function Vp(e){return Math.round(e*100)/100}const x1=e=>Math.abs(e)<Number.MAX_SAFE_INTEGER;function vs(e,t,n){return n<0?$u(e,t):Kk(e,t)}function zS(e,t,n,r){let o;if(Math.abs(e)>Pe){o=yh(t,r);const s=yh(r,n);return Math.abs(o)<Math.abs(s)?o/e:(e-s)/e}else{o=yh(t,r);const s=o/e;return Math.sign(o)!==Math.sign(e)?Math.abs(s)>.5?1:0:s}}function C5(e,t,n,r){const o=2*((t-e)%Oe)%Oe-(t-e)%Oe;return r?(Oe-Math.abs(o))*(n?1:-1):o}const Pd=({brush:e,color:t,opacity:n,className:r})=>{const o=x.useRef(null);xc(o,e.x,e.y);const s=j(Math.max(1,e.w)),i=j(Math.max(1,e.h));return h.jsx("svg",{className:"tl-overlays__item",ref:o,children:t?h.jsxs("g",{className:"tl-brush",opacity:n,children:[h.jsx("rect",{width:s,height:i,fill:t,opacity:.75}),h.jsx("rect",{width:s,height:i,fill:"none",stroke:t,opacity:.1})]}):h.jsx("rect",{className:`tl-brush tl-brush__default ${r}`,width:s,height:i})})},Io=2e3,Gp=40,Qr=320,ta=[.1,.25,.5,1,2,4,8],qc=.1,xs=8,I5=.5,E5=.1,_5=.2,k5=.005,T5=.05,$5=450,M5=200,BS=36,iu=16,A5=32,ic={};for(let e=1;e<=Math.ceil(xs);e++)ic[e+"_dark"]=`hash_pattern_zoom_${e}_dark`,ic[e+"_light"]=`hash_pattern_zoom_${e}_light`;const j5={duration:0,easing:nn.easeInOutCubic},Sh=.09,w1=[{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}],O5=6e4,Vk=3e3,D5=1200,b1={CAMERA_MOVE:-10},R5=64,Ko=8,L5=20,F5=8,N5=12,Gk=20,Yk=12,z5=["top","right","bottom","left"],B5=500,P1=.35;var um={};const U5={},Xk=zn("pointerCaptureTrackingObject",{defaults:{all:new Map},shouldStoreForSession:!1}),$t={logPreventDefaults:zn("logPreventDefaults",{defaults:{all:!1}}),logPointerCaptures:zn("logPointerCaptures",{defaults:{all:!1}}),logElementRemoves:zn("logElementRemoves",{defaults:{all:!1}}),debugSvg:zn("debugSvg",{defaults:{all:!1}}),showFps:zn("showFps",{defaults:{all:!1}}),throwToBlob:zn("throwToBlob",{defaults:{all:!1}}),reconnectOnPing:zn("reconnectOnPing",{defaults:{all:!1}}),debugCursors:zn("debugCursors",{defaults:{all:!1}}),forceSrgb:zn("forceSrgbColors",{defaults:{all:!1}}),debugGeometry:zn("debugGeometry",{defaults:{all:!1}}),hideShapes:zn("hideShapes",{defaults:{all:!1}}),editOnType:zn("editOnType",{defaults:{all:!1}})};if(typeof Element<"u"){const e=Element.prototype.removeChild;Sc("element removal logging",()=>{$t.logElementRemoves.get()?Element.prototype.removeChild=function(t){return console.warn("[tldraw] removing child:",t),e.call(this,t)}:Element.prototype.removeChild=e})}function zn(e,{defaults:t,shouldStoreForSession:n=!0}){return H5({name:e,defaults:t,shouldStoreForSession:n})}function H5(e){const t=W5(e),n=e.shouldStoreForSession?K5(e.name):null,r=fn(`debug:${e.name}`,n??t);return typeof window<"u"&&(e.shouldStoreForSession&&Sc(`debug:${e.name}`,()=>{const o=r.get();o===t?q_(`tldraw_debug:${e.name}`):N0(`tldraw_debug:${e.name}`,JSON.stringify(o))}),Object.defineProperty(window,`tldraw${e.name.replace(/^[a-z]/,o=>o.toUpperCase())}`,{get(){return r.get()},set(o){r.set(o)},configurable:!0})),Object.assign(r,e)}function K5(e){try{return JSON.parse(X_(`tldraw_debug:${e}`)??"null")}catch{return null}}function dm(e){try{return e()}catch{return null}}function W5(e){switch(dm(()=>um.TLDRAW_ENV)??dm(()=>um.VERCEL_PUBLIC_TLDRAW_ENV)??dm(()=>um.NEXT_PUBLIC_TLDRAW_ENV)??"production"){case"production":return e.defaults.production??e.defaults.all;case"preview":case"staging":return e.defaults.staging??e.defaults.all;default:return e.defaults.development??e.defaults.all}}function Yp(e){if(e instanceof HTMLElement)return e;if(e.parentElement)return Yp(e.parentElement);throw Error("Could not find a parent element of an HTML type!")}function Ee(e){e.preventDefault(),$t.logPreventDefaults.get()&&console.warn("preventDefault called on event:",e)}function Mu(e,t){if(e.setPointerCapture(t.pointerId),$t.logPointerCaptures.get()){const n=Xk.get();n.set(e,(n.get(e)??0)+1),console.warn("setPointerCapture called on element:",e,t)}}function Au(e,t){if(e.hasPointerCapture(t.pointerId)&&(e.releasePointerCapture(t.pointerId),$t.logPointerCaptures.get())){const n=Xk.get();n.get(e)===1?n.delete(e):n.has(e)?n.set(e,n.get(e)-1):console.warn("Release without capture"),console.warn("releasePointerCapture called on element:",e,t)}}const Ut=e=>e.stopPropagation(),Yt=(e,t,n)=>{e&&e.style.setProperty(t,n)};function _n(e){return e.isKilled=!0,{point:{x:e.clientX,y:e.clientY,z:e.pressure},shiftKey:e.shiftKey,altKey:e.altKey,ctrlKey:e.metaKey||e.ctrlKey,pointerId:e.pointerId,button:e.button,isPen:e.pointerType==="pen"}}function V5(){const e=z();return x.useMemo(function(){let r,o;function s(g){if(!g.isKilled){if(g.button===2){e.dispatch({type:"pointer",target:"canvas",name:"right_click",..._n(g)});return}g.button!==0&&g.button!==1&&g.button!==5||(Mu(g.currentTarget,g),e.dispatch({type:"pointer",target:"canvas",name:"pointer_down",..._n(g)}),e.getOpenMenus().length>0&&(e.updateInstanceState({openMenus:[]}),document.body.click(),e.getContainer().focus()))}}function i(g){g.isKilled||g.clientX===r&&g.clientY===o||(r=g.clientX,o=g.clientY,e.dispatch({type:"pointer",target:"canvas",name:"pointer_move",..._n(g)}))}function a(g){g.isKilled||g.button!==0&&g.button!==1&&g.button!==2&&g.button!==5||(r=g.clientX,o=g.clientY,Au(g.currentTarget,g),e.dispatch({type:"pointer",target:"canvas",name:"pointer_up",..._n(g)}))}function c(g){if(g.isKilled||e.getInstanceState().isPenMode&&g.pointerType!=="pen")return;const w=g.pointerType==="mouse"||g.pointerType==="pen";e.updateInstanceState({isHoveringCanvas:w?!0:null})}function l(g){if(g.isKilled||e.getInstanceState().isPenMode&&g.pointerType!=="pen")return;const w=g.pointerType==="mouse"||g.pointerType==="pen";e.updateInstanceState({isHoveringCanvas:w?!1:null})}function u(g){g.isKilled=!0,document.body.click(),Ee(g)}function d(g){g.isKilled=!0,g.target.tagName!=="A"&&g.target.tagName!=="TEXTAREA"&&!(e.getEditingShape()&&g.target.className.includes("tl-text-content"))&&Ee(g)}function p(g){Ee(g)}async function f(g){var S,v;if(Ee(g),!((v=(S=g.dataTransfer)==null?void 0:S.files)!=null&&v.length))return;const w=Array.from(g.dataTransfer.files);await e.putExternalContent({type:"files",files:w,point:e.screenToPage({x:g.clientX,y:g.clientY}),ignoreParent:!1})}function y(g){Ut(g)}return{onPointerDown:s,onPointerMove:i,onPointerUp:a,onPointerEnter:c,onPointerLeave:l,onDragOver:p,onDrop:f,onTouchStart:u,onTouchEnd:d,onClick:y}},[e])}function G5(){const e=z();x.useEffect(()=>{if(e.environment.isFirefox&&!e.environment.isAndroid&&!e.environment.isIos){e.updateInstanceState({isCoarsePointer:!1});return}if(window.matchMedia){const t=window.matchMedia("(pointer: coarse)"),n=()=>{e.updateInstanceState({isCoarsePointer:!!t.matches})};if(n(),t)return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}},[e])}const qk=x.createContext(null);function Y5({container:e,children:t}){return h.jsx(qk.Provider,{value:e,children:t})}function cn(){return yi(x.useContext(qk),"useContainer used outside of <Tldraw />")}function X5(){const e=z(),t=cn(),n=K("isFocused",()=>e.getInstanceState().isFocused,[e]);x.useEffect(()=>{if(typeof matchMedia===void 0)return;let r=null;const o=()=>{r!=null&&r();const s=`(resolution: ${window.devicePixelRatio}dppx)`,i=matchMedia(s),a=c=>{c.type==="change"&&o()};i.addEventListener?i.addEventListener("change",o):i.addListener&&i.addListener(a),r=()=>{i.removeEventListener?i.removeEventListener("change",o):i.removeListener&&i.removeListener(a)},e.updateInstanceState({devicePixelRatio:window.devicePixelRatio})};return o(),()=>{r==null||r()}},[e]),x.useEffect(()=>{if(!n)return;const r=a=>{if(a.altKey&&(e.isIn("zoom")||!e.getPath().endsWith(".idle"))&&!Cd()&&Ee(a),a.isKilled)return;switch(a.isKilled=!0,a.key){case"=":case"-":case"0":{if(a.metaKey||a.ctrlKey){Ee(a);return}break}case"Tab":{if(Cd()||e.getIsMenuOpen())return;break}case",":return;case"Escape":{if((e.getEditingShape()||e.getSelectedShapeIds().length>0)&&a.preventDefault(),e.getOpenMenus().length>0)return;e.inputs.keys.has("Escape")||(e.inputs.keys.add("Escape"),e.cancel(),t.focus());return}default:if(Cd()||e.getIsMenuOpen())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};e.dispatch(c)},o=a=>{if(a.isKilled||(a.isKilled=!0,Cd()||e.getIsMenuOpen())||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};e.dispatch(c)};function s(a){var c,l;if(t.contains(a.target)){const u=a.touches[0].pageX,d=a.touches[0].radiusX||0;(u-d<10||u+d>e.getViewportScreenBounds().width-10)&&(((c=a.target)==null?void 0:c.tagName)==="BUTTON"&&((l=a.target)==null||l.click()),Ee(a))}}const i=a=>{t.contains(a.target)&&(a.ctrlKey||a.metaKey)&&Ee(a)};return t.addEventListener("touchstart",s,{passive:!1}),t.addEventListener("wheel",i,{passive:!1}),document.addEventListener("gesturestart",Ee),document.addEventListener("gesturechange",Ee),document.addEventListener("gestureend",Ee),t.addEventListener("keydown",r),t.addEventListener("keyup",o),()=>{t.removeEventListener("touchstart",s),t.removeEventListener("wheel",i),document.removeEventListener("gesturestart",Ee),document.removeEventListener("gesturechange",Ee),document.removeEventListener("gestureend",Ee),t.removeEventListener("keydown",r),t.removeEventListener("keyup",o)}},[e,t,n])}const q5=["input","select","button","textarea"];function Cd(){const{activeElement:e}=document;return!!(e&&(e.getAttribute("contenteditable")||q5.indexOf(e.tagName.toLowerCase())>-1))}const Z5=["textarea","input"];function Q5(e){const t=z();x.useEffect(()=>{const n=e.current;if(!n)return;const r=o=>{var s;if(o instanceof PointerEvent&&o.pointerType==="pen"){o.isKilled=!0;const{target:i}=o;if(Z5.includes((s=i.tagName)==null?void 0:s.toLocaleLowerCase())||t.isIn("select.editing_shape"))return;Ee(o)}};return n.addEventListener("touchstart",r),n.addEventListener("touchend",r),()=>{n.removeEventListener("touchstart",r),n.removeEventListener("touchend",r)}},[t,e])}function J5(e,t,n){return Math.max(t,Math.min(e,n))}const zt={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function C1(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function I1(e,t,n,r=.15){return r===0?J5(e,t,n):e<t?-C1(t-e,n-t,r)+t:e>n?+C1(e-n,n-t,r)+n:e}function e6(e,[t,n],[r,o]){const[[s,i],[a,c]]=e;return[I1(t,s,i,r),I1(n,a,c,o)]}function t6(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function n6(e){var t=t6(e,"string");return typeof t=="symbol"?t:String(t)}function qt(e,t,n){return t=n6(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E1(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function at(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?E1(Object(n),!0).forEach(function(r){qt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E1(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}const Zk={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 _1(e){return e?e[0].toUpperCase()+e.slice(1):""}const r6=["enter","leave"];function o6(e=!1,t){return e&&!r6.includes(t)}function s6(e,t="",n=!1){const r=Zk[e],o=r&&r[t]||t;return"on"+_1(e)+_1(o)+(o6(n,o)?"Capture":"")}const i6=["gotpointercapture","lostpointercapture"];function a6(e){let t=e.substring(2).toLowerCase();const n=!!~t.indexOf("passive");n&&(t=t.replace("passive",""));const r=i6.includes(t)?"capturecapture":"capture",o=!!~t.indexOf(r);return o&&(t=t.replace("capture","")),{device:t,capture:o,passive:n}}function c6(e,t=""){const n=Zk[e],r=n&&n[t]||t;return e+r}function Qk(e){return"touches"in e}function l6(e){return Qk(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function u6(e){return Array.from(e.touches).filter(t=>{var n,r;return t.target===e.currentTarget||((n=e.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,t.target))})}function US(e,t){try{const n=t.clientX-e.clientX,r=t.clientY-e.clientY,o=(t.clientX+e.clientX)/2,s=(t.clientY+e.clientY)/2,i=Math.hypot(n,r);return{angle:-(Math.atan2(n,r)*180)/Math.PI,distance:i,origin:[o,s]}}catch{}return null}function d6(e){return u6(e).map(t=>t.identifier)}function k1(e,t){const[n,r]=Array.from(e.touches).filter(o=>t.includes(o.identifier));return US(n,r)}const T1=40,$1=800;function Jk(e){let{deltaX:t,deltaY:n,deltaMode:r}=e;return r===1?(t*=T1,n*=T1):r===2&&(t*=$1,n*=$1),[t,n]}function h6(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:n,altKey:r,metaKey:o,ctrlKey:s}=e;Object.assign(t,{shiftKey:n,altKey:r,metaKey:o,ctrlKey:s})}return t}function Xp(e,...t){return typeof e=="function"?e(...t):e}function p6(){}function f6(...e){return e.length===0?p6:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function M1(e,t){return Object.assign({},t,e||{})}const g6=32;class e2{constructor(t,n,r){this.ctrl=t,this.args=n,this.key=r,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(t){this.ctrl.state[this.key]=t}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:t,shared:n,ingKey:r,args:o}=this;n[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=o,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=t.target,n.currentTarget=t.currentTarget,n.lastOffset=r.from?Xp(r.from,n):n.offset,n.offset=n.lastOffset,n.startTime=n.timeStamp=t.timeStamp)}computeValues(t){const n=this.state;n._values=t,n.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:n,config:r,shared:o}=this;n.args=this.args;let s=0;if(t&&(n.event=t,r.preventDefault&&t.cancelable&&n.event.preventDefault(),n.type=t.type,o.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,o.locked=!!document.pointerLockElement,Object.assign(o,h6(t)),o.down=o.pressed=o.buttons%2===1||o.touches>0,s=t.timeStamp-n.timeStamp,n.timeStamp=t.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const I=n._delta.map(Math.abs);zt.addTo(n._distance,I)}this.axisIntent&&this.axisIntent(t);const[i,a]=n._movement,[c,l]=r.threshold,{_step:u,values:d}=n;if(r.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(i)>=c&&d[0]),u[1]===!1&&(u[1]=Math.abs(a)>=l&&d[1])):(u[0]===!1&&(u[0]=Math.abs(i)>=c&&Math.sign(i)*c),u[1]===!1&&(u[1]=Math.abs(a)>=l&&Math.sign(a)*l)),n.intentional=u[0]!==!1||u[1]!==!1,!n.intentional)return;const p=[0,0];if(r.hasCustomTransform){const[I,_]=d;p[0]=u[0]!==!1?I-u[0]:0,p[1]=u[1]!==!1?_-u[1]:0}else p[0]=u[0]!==!1?i-u[0]:0,p[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(p);const f=n.offset,y=n._active&&!n._blocked||n.active;y&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=o[this.ingKey]=n._active,t&&(n.first&&("bounds"in r&&(n._bounds=Xp(r.bounds,n)),this.setup&&this.setup()),n.movement=p,this.computeOffset()));const[g,w]=n.offset,[[S,v],[b,E]]=n._bounds;n.overflow=[g<S?-1:g>v?1:0,w<b?-1:w>E?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const C=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=e6(n._bounds,n.offset,C),n.delta=zt.sub(n.offset,f),this.computeMovement(),y&&(!n.last||s>g6)){n.delta=zt.sub(n.offset,f);const I=n.delta.map(Math.abs);zt.addTo(n.distance,I),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&s>0&&(n.velocity=[I[0]/s,I[1]/s],n.timeDelta=s)}}emit(){const t=this.state,n=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const o=this.handler(at(at(at({},n),t),{},{[this.aliasKey]:t.values}));o!==void 0&&(t.memo=o)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function m6([e,t],n){const r=Math.abs(e),o=Math.abs(t);if(r>o&&r>n)return"x";if(o>r&&o>n)return"y"}class y6 extends e2{constructor(...t){super(...t),qt(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=zt.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=zt.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const n=this.state,r=this.config;if(!n.axis&&t){const o=typeof r.axisThreshold=="object"?r.axisThreshold[l6(t)]:r.axisThreshold;n.axis=m6(n._movement,o)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const S6=e=>e,A1=.15,t2={enabled(e=!0){return e},eventOptions(e,t,n){return at(at({},n.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[A1,A1];case!1:return[0,0];default:return zt.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return zt.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||S6},threshold(e){return zt.toVector(e,0)}},v6=0,ju=at(at({},t2),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(e=v6){return e},bounds(e={}){if(typeof e=="function")return s=>ju.bounds(e(s));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:n=1/0,top:r=-1/0,bottom:o=1/0}=e;return[[t,n],[r,o]]}}),Ou=typeof window<"u"&&window.document&&window.document.createElement;function n2(){return Ou&&"ontouchstart"in window}function x6(){return n2()||Ou&&window.navigator.maxTouchPoints>1}function w6(){return Ou&&"onpointerdown"in window}function b6(){return Ou&&"exitPointerLock"in window.document}function P6(){try{return"constructor"in GestureEvent}catch{return!1}}const pr={isBrowser:Ou,gesture:P6(),touch:n2(),touchscreen:x6(),pointer:w6(),pointerLock:b6()},C6=250,I6=180,E6=.5,_6=50,k6=250,T6=10,j1={mouse:0,touch:0,pen:8};at(at({},ju),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:o=!1}={}}){return this.pointerLock=r&&pr.pointerLock,pr.touch&&n?"touch":this.pointerLock?"mouse":pr.pointer&&!o?"pointer":pr.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?C6:void 0,!(!pr.touchscreen||n===!1))return e||(n!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:n=!0,buttons:r=1,keys:o=!0}={}}){return this.pointerButtons=r,this.keys=o,!this.pointerLock&&this.device==="pointer"&&n},threshold(e,t,{filterTaps:n=!1,tapsThreshold:r=3,axis:o=void 0}){const s=zt.toVector(e,n?r:o?1:0);return this.filterTaps=n,this.tapsThreshold=r,s},swipe({velocity:e=E6,distance:t=_6,duration:n=k6}={}){return{velocity:this.transform(zt.toVector(e)),distance:this.transform(zt.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return I6;case!1:return 0;default:return e}},axisThreshold(e){return e?at(at({},j1),e):j1},keyboardDisplacement(e=T6){return e}});function r2(e){const[t,n]=e.overflow,[r,o]=e._delta,[s,i]=e._direction;(t<0&&r>0&&s<0||t>0&&r<0&&s>0)&&(e._movement[0]=e._movementBound[0]),(n<0&&o>0&&i<0||n>0&&o<0&&i>0)&&(e._movement[1]=e._movementBound[1])}const $6=30,M6=100;class A6 extends e2{constructor(...t){super(...t),qt(this,"ingKey","pinching"),qt(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const t=this.state;t._touchIds=[],t.canceled=!1,t.cancel=this.cancel.bind(this),t.turns=0}computeOffset(){const{type:t,movement:n,lastOffset:r}=this.state;t==="wheel"?this.state.offset=zt.add(n,r):this.state.offset=[(1+n[0])*r[0],n[1]+r[1]]}computeMovement(){const{offset:t,lastOffset:n}=this.state;this.state.movement=[t[0]/n[0],t[1]-n[1]]}axisIntent(){const t=this.state,[n,r]=t._movement;if(!t.axis){const o=Math.abs(n)*$6-Math.abs(r);o<0?t.axis="angle":o>0&&(t.axis="scale")}}restrictToAxis(t){this.config.lockDirection&&(this.state.axis==="scale"?t[1]=0:this.state.axis==="angle"&&(t[0]=0))}cancel(){const t=this.state;t.canceled||setTimeout(()=>{t.canceled=!0,t._active=!1,this.compute(),this.emit()},0)}touchStart(t){this.ctrl.setEventIds(t);const n=this.state,r=this.ctrl.touchIds;if(n._active&&n._touchIds.every(s=>r.has(s))||r.size<2)return;this.start(t),n._touchIds=Array.from(r).slice(0,2);const o=k1(t,n._touchIds);o&&this.pinchStart(t,o)}pointerStart(t){if(t.buttons!=null&&t.buttons%2!==1)return;this.ctrl.setEventIds(t),t.target.setPointerCapture(t.pointerId);const n=this.state,r=n._pointerEvents,o=this.ctrl.pointerIds;if(n._active&&Array.from(r.keys()).every(i=>o.has(i))||(r.size<2&&r.set(t.pointerId,t),n._pointerEvents.size<2))return;this.start(t);const s=US(...Array.from(r.values()));s&&this.pinchStart(t,s)}pinchStart(t,n){const r=this.state;r.origin=n.origin,this.computeValues([n.distance,n.angle]),this.computeInitial(),this.compute(t),this.emit()}touchMove(t){if(!this.state._active)return;const n=k1(t,this.state._touchIds);n&&this.pinchMove(t,n)}pointerMove(t){const n=this.state._pointerEvents;if(n.has(t.pointerId)&&n.set(t.pointerId,t),!this.state._active)return;const r=US(...Array.from(n.values()));r&&this.pinchMove(t,r)}pinchMove(t,n){const r=this.state,o=r._values[1],s=n.angle-o;let i=0;Math.abs(s)>270&&(i+=Math.sign(s)),this.computeValues([n.distance,n.angle-360*i]),r.origin=n.origin,r.turns=i,r._movement=[r._values[0]/r._initial[0]-1,r._values[1]-r._initial[1]],this.compute(t),this.emit()}touchEnd(t){this.ctrl.setEventIds(t),this.state._active&&this.state._touchIds.some(n=>!this.ctrl.touchIds.has(n))&&(this.state._active=!1,this.compute(t),this.emit())}pointerEnd(t){const n=this.state;this.ctrl.setEventIds(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}n._pointerEvents.has(t.pointerId)&&n._pointerEvents.delete(t.pointerId),n._active&&n._pointerEvents.size<2&&(n._active=!1,this.compute(t),this.emit())}gestureStart(t){t.cancelable&&t.preventDefault();const n=this.state;n._active||(this.start(t),this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY],this.compute(t),this.emit())}gestureMove(t){if(t.cancelable&&t.preventDefault(),!this.state._active)return;const n=this.state;this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY];const r=n._movement;n._movement=[t.scale-1,t.rotation],n._delta=zt.sub(n._movement,r),this.compute(t),this.emit()}gestureEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}wheel(t){const n=this.config.modifierKey;n&&(Array.isArray(n)?!n.find(r=>t[r]):!t[n])||(this.state._active?this.wheelChange(t):this.wheelStart(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(t){this.start(t),this.wheelChange(t)}wheelChange(t){"uv"in t||t.cancelable&&t.preventDefault();const r=this.state;r._delta=[-Jk(t)[1]/M6*r.offset[0],0],zt.addTo(r._movement,r._delta),r2(r),this.state.origin=[t.clientX,t.clientY],this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){const n=this.config.device;n&&(t(n,"start",this[n+"Start"].bind(this)),t(n,"change",this[n+"Move"].bind(this)),t(n,"end",this[n+"End"].bind(this)),t(n,"cancel",this[n+"End"].bind(this)),t("lostPointerCapture","",this[n+"End"].bind(this))),this.config.pinchOnWheel&&t("wheel","",this.wheel.bind(this),{passive:!1})}}const j6=at(at({},t2),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!pr.touch&&pr.gesture)return"gesture";if(pr.touch&&r)return"touch";if(pr.touchscreen){if(pr.pointer)return"pointer";if(pr.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const o=i=>{const a=M1(Xp(n,i),{min:-1/0,max:1/0});return[a.min,a.max]},s=i=>{const a=M1(Xp(r,i),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof n!="function"&&typeof r!="function"?[o(),s()]:i=>[o(i),s(i)]},threshold(e,t,n){return this.lockDirection=n.axis==="lock",zt.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});at(at({},ju),{},{mouseOnly:(e=!0)=>e});class O6 extends y6{constructor(...t){super(...t),qt(this,"ingKey","wheeling")}wheel(t){this.state._active||this.start(t),this.wheelChange(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(t){const n=this.state;n._delta=Jk(t),zt.addTo(n._movement,n._delta),r2(n),this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("wheel","",this.wheel.bind(this))}}const D6=ju;at(at({},ju),{},{mouseOnly:(e=!0)=>e});const Y0=new Map,HS=new Map;function R6(e){Y0.set(e.key,e.engine),HS.set(e.key,e.resolver)}const L6={key:"pinch",engine:A6,resolver:j6},F6={key:"wheel",engine:O6,resolver:D6};function N6(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function z6(e,t){if(e==null)return{};var n=N6(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const B6={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=pr.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},U6=["target","eventOptions","window","enabled","transform"];function vh(e={},t){const n={};for(const[r,o]of Object.entries(t))switch(typeof o){case"function":n[r]=o.call(n,e[r],r,e);break;case"object":n[r]=vh(e[r],o);break;case"boolean":o&&(n[r]=e[r]);break}return n}function H6(e,t,n={}){const r=e,{target:o,eventOptions:s,window:i,enabled:a,transform:c}=r,l=z6(r,U6);if(n.shared=vh({target:o,eventOptions:s,window:i,enabled:a,transform:c},B6),t){const u=HS.get(t);n[t]=vh(at({shared:n.shared},l),u)}else for(const u in l){const d=HS.get(u);d&&(n[u]=vh(at({shared:n.shared},l[u]),d))}return n}class o2{constructor(t,n){qt(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=n}add(t,n,r,o,s){const i=this._listeners,a=c6(n,r),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},l=at(at({},c),s);t.addEventListener(a,o,l);const u=()=>{t.removeEventListener(a,o,l),i.delete(u)};return i.add(u),u}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class K6{constructor(){qt(this,"_timeouts",new Map)}add(t,n,r=140,...o){this.remove(t),this._timeouts.set(t,window.setTimeout(n,r,...o))}remove(t){const n=this._timeouts.get(t);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(t=>void window.clearTimeout(t)),this._timeouts.clear()}}class W6{constructor(t){qt(this,"gestures",new Set),qt(this,"_targetEventStore",new o2(this)),qt(this,"gestureEventStores",{}),qt(this,"gestureTimeoutStores",{}),qt(this,"handlers",{}),qt(this,"config",{}),qt(this,"pointerIds",new Set),qt(this,"touchIds",new Set),qt(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),V6(this,t)}setEventIds(t){if(Qk(t))return this.touchIds=new Set(d6(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,n){this.handlers=t,this.nativeHandlers=n}applyConfig(t,n){this.config=H6(t,n,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const n=this.config.shared,r={};let o;if(!(n.target&&(o=n.target(),!o))){if(n.enabled){for(const i of this.gestures){const a=this.config[i],c=O1(r,a.eventOptions,!!o);if(a.enabled){const l=Y0.get(i);new l(this,t,i).bind(c)}}const s=O1(r,n.eventOptions,!!o);for(const i in this.nativeHandlers)s(i,"",a=>this.nativeHandlers[i](at(at({},this.state.shared),{},{event:a,args:t})),void 0,!0)}for(const s in r)r[s]=f6(...r[s]);if(!o)return r;for(const s in r){const{device:i,capture:a,passive:c}=a6(s);this._targetEventStore.add(o,i,"",r[s],{capture:a,passive:c})}}}}function na(e,t){e.gestures.add(t),e.gestureEventStores[t]=new o2(e,t),e.gestureTimeoutStores[t]=new K6}function V6(e,t){t.drag&&na(e,"drag"),t.wheel&&na(e,"wheel"),t.scroll&&na(e,"scroll"),t.move&&na(e,"move"),t.pinch&&na(e,"pinch"),t.hover&&na(e,"hover")}const O1=(e,t,n)=>(r,o,s,i={},a=!1)=>{var c,l;const u=(c=i.capture)!==null&&c!==void 0?c:t.capture,d=(l=i.passive)!==null&&l!==void 0?l:t.passive;let p=a?r:s6(r,o,u);n&&d&&(p+="Passive"),e[p]=e[p]||[],e[p].push(s)},G6=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function Y6(e){const t={},n={},r=new Set;for(let o in e)G6.test(o)?(r.add(RegExp.lastMatch),n[o]=e[o]):t[o]=e[o];return[n,t,r]}function ra(e,t,n,r,o,s){if(!e.has(n)||!Y0.has(r))return;const i=n+"Start",a=n+"End",c=l=>{let u;return l.first&&i in t&&t[i](l),n in t&&(u=t[n](l)),l.last&&a in t&&t[a](l),u};o[r]=c,s[r]=s[r]||{}}function X6(e,t){const[n,r,o]=Y6(e),s={};return ra(o,n,"onDrag","drag",s,t),ra(o,n,"onWheel","wheel",s,t),ra(o,n,"onScroll","scroll",s,t),ra(o,n,"onPinch","pinch",s,t),ra(o,n,"onMove","move",s,t),ra(o,n,"onHover","hover",s,t),{handlers:s,config:t,nativeHandlers:r}}function q6(e,t={},n,r){const o=Se.useMemo(()=>new W6(e),[]);if(o.applyHandlers(e,r),o.applyConfig(t,n),Se.useEffect(o.effect.bind(o)),Se.useEffect(()=>o.clean.bind(o),[]),t.target===void 0)return o.bind.bind(o)}function Z6(e){return e.forEach(R6),function(n,r){const{handlers:o,nativeHandlers:s,config:i}=X6(n,r||{});return q6(o,i,void 0,s)}}const D1=10,Q6=/Mac|iPod|iPhone|iPad/.test(typeof window>"u"?"node":window.navigator.platform);function s2(e){let{deltaY:t,deltaX:n}=e,r=0;if(e.ctrlKey||e.altKey||e.metaKey){const o=Math.sign(e.deltaY),s=Math.abs(e.deltaY);let i=t;s>D1&&(i=D1*o),r=i/100}else e.shiftKey&&!Q6&&(n=t,t=0);return{x:-n,y:-t,z:-r}}const J6=Z6([F6,L6]);let oa;const eF=e=>oa===void 0?(oa=e,!1):e-oa>120&&e-oa<160?(oa=e,!0):(oa=e,!1);function tF(e){const t=z(),n=x.useMemo(()=>{let r="not sure";const o=({event:g})=>{if(!t.getInstanceState().isFocused||(r="not sure",eF(Date.now())))return;const w=t.getEditingShapeId();if(w){const b=t.getShape(w);if(b&&t.getShapeUtil(b).canScroll(b)){const C=t.getShapePageBounds(w);if(C!=null&&C.containsPoint(t.inputs.currentPagePoint))return}}Ee(g),Ut(g);const S=s2(g);if(S.x===0&&S.y===0)return;const v={type:"wheel",name:"wheel",delta:S,point:new P(g.clientX,g.clientY),shiftKey:g.shiftKey,altKey:g.altKey,ctrlKey:g.metaKey||g.ctrlKey};t.dispatch(v)};let s=1,i=1,a=1,c=0;const l=new P,u=new P,d=g=>{const w=e.current;r="not sure";const{event:S,origin:v,da:b}=g;S instanceof WheelEvent||(S.target===w||w!=null&&w.contains(S.target))&&(u.x=v[0],u.y=v[1],l.x=v[0],l.y=v[1],s=b[0],i=t.getZoomLevel(),t.dispatch({type:"pinch",name:"pinch_start",point:{x:v[0],y:v[1],z:t.getZoomLevel()},delta:{x:0,y:0},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey}))},p=g=>{if(g&&(r="zooming"),r==="zooming")return;const w=Math.abs(c-s),S=P.Dist(l,u);switch(r){case"not sure":{w>24?r="zooming":S>16&&(r="panning");break}case"panning":{w>64&&(r="zooming");break}}};return{onWheel:o,onPinchStart:d,onPinchEnd:g=>{const w=e.current,{event:S,origin:v,offset:b}=g;if(S instanceof WheelEvent||!(S.target===w||w!=null&&w.contains(S.target)))return;const E=b[0];r="not sure",requestAnimationFrame(()=>{t.dispatch({type:"pinch",name:"pinch_end",point:{x:v[0],y:v[1],z:E},delta:{x:v[0],y:v[1]},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey})})},onPinch:g=>{const w=e.current,{event:S,origin:v,offset:b,da:E}=g;if(S instanceof WheelEvent||!(S.target===w||w!=null&&w.contains(S.target)))return;const C=g.type==="gesturechange"||g.type==="gestureend";c=E[0];const I=v[0]-u.x,_=v[1]-u.y;switch(u.x=v[0],u.y=v[1],p(C),r){case"zooming":{a=b[0],t.dispatch({type:"pinch",name:"pinch",point:{x:v[0],y:v[1],z:a},delta:{x:I,y:_},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey});break}case"panning":{t.dispatch({type:"pinch",name:"pinch",point:{x:v[0],y:v[1],z:i},delta:{x:I,y:_},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey});break}}}}},[t,e]);J6(n,{target:e,eventOptions:{passive:!1},pinch:{from:()=>[t.getZoomLevel(),0],scaleBounds:()=>({from:t.getZoomLevel(),max:8,min:.05})}})}function hm(e,t,n){const r=e.getShape(t),o=e.getShapeHandles(r);return{shape:r,handle:o.find(s=>s.id===n)}}function nF(e,t){const n=z();return x.useMemo(()=>{const r=c=>{if(c.isKilled)return;const l=Yp(c.currentTarget);Mu(l,c);const{shape:u,handle:d}=hm(n,e,t);d&&n.dispatch({type:"pointer",target:"handle",handle:d,shape:u,name:"pointer_down",..._n(c)})};let o,s;return{onPointerDown:r,onPointerMove:c=>{if(c.isKilled||c.clientX===o&&c.clientY===s)return;o=c.clientX,s=c.clientY;const{shape:l,handle:u}=hm(n,e,t);u&&n.dispatch({type:"pointer",target:"handle",handle:u,shape:l,name:"pointer_move",..._n(c)})},onPointerUp:c=>{if(c.isKilled)return;const l=Yp(c.currentTarget);Au(l,c);const{shape:u,handle:d}=hm(n,e,t);d&&n.dispatch({type:"pointer",target:"handle",handle:d,shape:u,name:"pointer_up",..._n(c)})}}},[n,e,t])}var i2="Expected a function",R1=NaN,rF="[object Symbol]",oF=/^\s+|\s+$/g,sF=/^[-+]0x[0-9a-f]+$/i,iF=/^0b[01]+$/i,aF=/^0o[0-7]+$/i,cF=parseInt,lF=typeof tn=="object"&&tn&&tn.Object===Object&&tn,uF=typeof self=="object"&&self&&self.Object===Object&&self,dF=lF||uF||Function("return this")(),hF=Object.prototype,pF=hF.toString,fF=Math.max,gF=Math.min,pm=function(){return dF.Date.now()};function mF(e,t,n){var r,o,s,i,a,c,l=0,u=!1,d=!1,p=!0;if(typeof e!="function")throw new TypeError(i2);t=L1(t)||0,qp(n)&&(u=!!n.leading,d="maxWait"in n,s=d?fF(L1(n.maxWait)||0,t):s,p="trailing"in n?!!n.trailing:p);function f(I){var _=r,k=o;return r=o=void 0,l=I,i=e.apply(k,_),i}function y(I){return l=I,a=setTimeout(S,t),u?f(I):i}function g(I){var _=I-c,k=I-l,$=t-_;return d?gF($,s-k):$}function w(I){var _=I-c,k=I-l;return c===void 0||_>=t||_<0||d&&k>=s}function S(){var I=pm();if(w(I))return v(I);a=setTimeout(S,g(I))}function v(I){return a=void 0,p&&r?f(I):(r=o=void 0,i)}function b(){a!==void 0&&clearTimeout(a),l=0,r=c=o=a=void 0}function E(){return a===void 0?i:v(pm())}function C(){var I=pm(),_=w(I);if(r=arguments,o=this,c=I,_){if(a===void 0)return y(c);if(d)return a=setTimeout(S,t),f(c)}return a===void 0&&(a=setTimeout(S,t)),i}return C.cancel=b,C.flush=E,C}function yF(e,t,n){var r=!0,o=!0;if(typeof e!="function")throw new TypeError(i2);return qp(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),mF(e,t,{leading:r,maxWait:t,trailing:o})}function qp(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function SF(e){return!!e&&typeof e=="object"}function vF(e){return typeof e=="symbol"||SF(e)&&pF.call(e)==rF}function L1(e){if(typeof e=="number")return e;if(vF(e))return R1;if(qp(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=qp(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(oF,"");var n=iF.test(e);return n||aF.test(e)?cF(e.slice(2),n?2:8):sF.test(e)?R1:+e}var xF=yF;const wF=pc(xF),Je=class Je{constructor(t=0,n=0,r=0,o=0){m(this,"x",0);m(this,"y",0);m(this,"w",0);m(this,"h",0);this.x=t,this.y=n,this.w=r,this.h=o}get point(){return new P(this.x,this.y)}set point(t){this.x=t.x,this.y=t.y}get minX(){return this.x}set minX(t){this.x=t}get midX(){return this.x+this.w/2}get maxX(){return this.x+this.w}get minY(){return this.y}set minY(t){this.y=t}get midY(){return this.y+this.h/2}get maxY(){return this.y+this.h}get width(){return this.w}set width(t){this.w=t}get height(){return this.h}set height(t){this.h=t}get aspectRatio(){return this.width/this.height}get center(){return new P(this.midX,this.midY)}set center(t){this.minX=t.x-this.width/2,this.minY=t.y-this.height/2}get corners(){return[new P(this.minX,this.minY),new P(this.maxX,this.minY),new P(this.maxX,this.maxY),new P(this.minX,this.maxY)]}get cornersAndCenter(){return[new P(this.minX,this.minY),new P(this.maxX,this.minY),new P(this.maxX,this.maxY),new P(this.minX,this.maxY),this.center]}get sides(){const{corners:t}=this;return[[t[0],t[1]],[t[1],t[2]],[t[2],t[3]],[t[3],t[0]]]}get size(){return new P(this.w,this.h)}toFixed(){return this.x=bd(this.x),this.y=bd(this.y),this.w=bd(this.w),this.h=bd(this.h),this}setTo(t){return this.x=t.x,this.y=t.y,this.w=t.w,this.h=t.h,this}set(t=0,n=0,r=0,o=0){return this.x=t,this.y=n,this.w=r,this.h=o,this}expand(t){const n=Math.min(this.minX,t.minX),r=Math.min(this.minY,t.minY),o=Math.max(this.maxX,t.maxX),s=Math.max(this.maxY,t.maxY);return this.x=n,this.y=r,this.w=o-n,this.h=s-r,this}expandBy(t){return this.x-=t,this.y-=t,this.w+=t*2,this.h+=t*2,this}scale(t){return this.x/=t,this.y/=t,this.w/=t,this.h/=t,this}clone(){const{x:t,y:n,w:r,h:o}=this;return new Je(t,n,r,o)}translate(t){return this.x+=t.x,this.y+=t.y,this}snapToGrid(t){const n=Math.round(this.minX/t)*t,r=Math.round(this.minY/t)*t,o=Math.round(this.maxX/t)*t,s=Math.round(this.maxY/t)*t;this.minX=n,this.minY=r,this.width=Math.max(1,o-n),this.height=Math.max(1,s-r)}collides(t){return Je.Collides(this,t)}contains(t){return Je.Contains(this,t)}includes(t){return Je.Includes(this,t)}containsPoint(t,n=0){return Je.ContainsPoint(this,t,n)}getHandlePoint(t){switch(t){case"top_left":return new P(this.minX,this.minY);case"top_right":return new P(this.maxX,this.minY);case"bottom_left":return new P(this.minX,this.maxY);case"bottom_right":return new P(this.maxX,this.maxY);case"top":return new P(this.midX,this.minY);case"right":return new P(this.maxX,this.midY);case"bottom":return new P(this.midX,this.maxY);case"left":return new P(this.minX,this.midY)}}toJson(){return{x:this.minX,y:this.minY,w:this.w,h:this.h}}resize(t,n,r){const{minX:o,minY:s,maxX:i,maxY:a}=this;let{minX:c,minY:l,maxX:u,maxY:d}=this;switch(t){case"left":case"top_left":case"bottom_left":{c+=n;break}case"right":case"top_right":case"bottom_right":{u+=n;break}}switch(t){case"top":case"top_left":case"top_right":{l+=r;break}case"bottom":case"bottom_left":case"bottom_right":{d+=r;break}}const p=(u-c)/(i-o),f=(d-l)/(a-s),y=p<0,g=f<0;if(y){const w=u;u=c,c=w}if(g){const w=d;d=l,l=w}this.minX=c,this.minY=l,this.width=Math.abs(u-c),this.height=Math.abs(d-l)}union(t){const n=Math.min(this.minX,t.x),r=Math.min(this.minY,t.y),o=Math.max(this.maxX,t.w+t.x),s=Math.max(this.maxY,t.h+t.y);return this.x=n,this.y=r,this.width=o-n,this.height=s-r,this}static From(t){return new Je(t.x,t.y,t.w,t.h)}static FromCenter(t,n){return new Je(t.x-n.x/2,t.y-n.y/2,n.x,n.y)}static FromPoints(t){if(t.length===0)return new Je;let n=1/0,r=1/0,o=-1/0,s=-1/0,i;for(let a=0,c=t.length;a<c;a++)i=t[a],n=Math.min(i.x,n),r=Math.min(i.y,r),o=Math.max(i.x,o),s=Math.max(i.y,s);return new Je(n,r,o-n,s-r)}static Expand(t,n){const r=Math.min(n.minX,t.minX),o=Math.min(n.minY,t.minY),s=Math.max(n.maxX,t.maxX),i=Math.max(n.maxY,t.maxY);return new Je(r,o,s-r,i-o)}static ExpandBy(t,n){return new Je(t.minX-n,t.minY-n,t.width+n*2,t.height+n*2)}static Resize(t,n,r,o,s=!1){const{minX:i,minY:a,maxX:c,maxY:l}=t;let{minX:u,minY:d,maxX:p,maxY:f}=t;switch(n){case"left":case"top_left":case"bottom_left":{u+=r;break}case"right":case"top_right":case"bottom_right":{p+=r;break}}switch(n){case"top":case"top_left":case"top_right":{d+=o;break}case"bottom":case"bottom_left":case"bottom_right":{f+=o;break}}const y=(p-u)/(c-i),g=(f-d)/(l-a),w=y<0,S=g<0;if(s){const b=(c-i)/(l-a),E=Math.abs(p-u),C=Math.abs(f-d),I=E*(g<0?1:-1)*(1/b),_=C*(y<0?1:-1)*b,k=b<E/C;switch(n){case"top_left":{k?d=f+I:u=p+_;break}case"top_right":{k?d=f+I:p=u-_;break}case"bottom_right":{k?f=d-I:p=u-_;break}case"bottom_left":{k?f=d-I:u=p+_;break}case"bottom":case"top":{const $=(u+p)/2,T=C*b;u=$-T/2,p=$+T/2;break}case"left":case"right":{const $=(d+f)/2,T=E/b;d=$-T/2,f=$+T/2;break}}}if(w){const b=p;p=u,u=b}if(S){const b=f;f=d,d=b}const v=new Je(u,d,Math.abs(p-u),Math.abs(f-d));return{box:v,scaleX:+(v.width/t.width*(y>0?1:-1)).toFixed(5),scaleY:+(v.height/t.height*(g>0?1:-1)).toFixed(5)}}equals(t){return Je.Equals(this,t)}static Equals(t,n){return n.x===t.x&&n.y===t.y&&n.w===t.w&&n.h===t.h}zeroFix(){return this.w=Math.max(1,this.w),this.h=Math.max(1,this.h),this}static ZeroFix(t){return new Je(t.x,t.y,Math.max(1,t.w),Math.max(1,t.h))}};m(Je,"Collides",(t,n)=>!(t.maxX<n.minX||t.minX>n.maxX||t.maxY<n.minY||t.minY>n.maxY)),m(Je,"Contains",(t,n)=>t.minX<n.minX&&t.minY<n.minY&&t.maxY>n.maxY&&t.maxX>n.maxX),m(Je,"Includes",(t,n)=>Je.Collides(t,n)||Je.Contains(t,n)),m(Je,"ContainsPoint",(t,n,r=0)=>!(n.x<t.minX-r||n.y<t.minY-r||n.x>t.maxX+r||n.y>t.maxY+r)),m(Je,"Common",t=>{let n=1/0,r=1/0,o=-1/0,s=-1/0;for(let i=0;i<t.length;i++){const a=t[i];n=Math.min(n,a.minX),r=Math.min(r,a.minY),o=Math.max(o,a.maxX),s=Math.max(s,a.maxY)}return new Je(n,r,o-n,s-r)}),m(Je,"Sides",(t,n=0)=>{const{corners:r}=t;return[[r[0],r[1]],[r[1],r[2]],[r[2],r[3]],[r[3],r[0]]]});let ne=Je;function bF(e){switch(e){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 e}}function PF(e){switch(e){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 e}}function CF(e){return e==="top_left"||e==="top_right"||e==="bottom_right"||e==="bottom_left"}function IF(e){const t=z();x.useLayoutEffect(()=>{let n=new ne;function r(){const l=e.current;if(!l)return null;const u=l.getBoundingClientRect(),d=new ne(u.left||u.x,u.top||u.y,Math.max(u.width,1),Math.max(u.height,1));n.equals(d)||(t.updateViewportScreenBounds(d),n=d)}r();const o=wF(r,200,{trailing:!0}),s=setInterval(o,1e3);window.addEventListener("resize",o);const i=new ResizeObserver(l=>{l[0].contentRect&&o()}),a=e.current;let c=null;return a&&(i.observe(a),c=EF(a),c.addEventListener("scroll",o)),()=>{clearInterval(s),window.removeEventListener("resize",o),i.disconnect(),c==null||c.removeEventListener("scroll",o)}},[t,e])}/*!
|
|
* Author: excalidraw
|
|
* MIT License: https://github.com/excalidraw/excalidraw/blob/master/LICENSE
|
|
* https://github.com/excalidraw/excalidraw/blob/48c3465b19f10ec755b3eb84e21a01a468e96e43/packages/excalidraw/utils.ts#L600
|
|
*/const EF=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;const{overflowY:n}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(n==="auto"||n==="scroll"||n==="overlay"))return t;t=t.parentElement}return document},je=class je{constructor(t,n,r,o,s,i){m(this,"a",1);m(this,"b",0);m(this,"c",0);m(this,"d",1);m(this,"e",0);m(this,"f",0);this.a=t,this.b=n,this.c=r,this.d=o,this.e=s,this.f=i}equals(t){return this===t||this.a===t.a&&this.b===t.b&&this.c===t.c&&this.d===t.d&&this.e===t.e&&this.f===t.f}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this}multiply(t){const n=t,{a:r,b:o,c:s,d:i,e:a,f:c}=this;return this.a=r*n.a+s*n.b,this.c=r*n.c+s*n.d,this.e=r*n.e+s*n.f+a,this.b=o*n.a+i*n.b,this.d=o*n.c+i*n.d,this.f=o*n.e+i*n.f+c,this}rotate(t,n,r){return t===0?this:n===void 0?this.multiply(je.Rotate(t)):this.translate(n,r).multiply(je.Rotate(t)).translate(-n,-r)}translate(t,n){return this.multiply(je.Translate(t,n))}scale(t,n){return this.multiply(je.Scale(t,n))}invert(){const{a:t,b:n,c:r,d:o,e:s,f:i}=this,a=t*o-n*r;return this.a=o/a,this.b=n/-a,this.c=r/-a,this.d=t/a,this.e=(o*s-r*i)/-a,this.f=(n*s-t*i)/a,this}applyToPoint(t){return je.applyToPoint(this,t)}applyToPoints(t){return je.applyToPoints(this,t)}rotation(){return je.Rotation(this)}point(){return je.Point(this)}decomposed(){return je.Decompose(this)}toCssString(){return je.toCssString(this)}setTo(t){return Object.assign(this,t),this}decompose(){return je.Decompose(this)}clone(){return new je(this.a,this.b,this.c,this.d,this.e,this.f)}static Identity(){return new je(1,0,0,1,0,0)}static Translate(t,n){return new je(1,0,0,1,t,n)}static Rotate(t,n,r){if(t===0)return je.Identity();const o=Math.cos(t),s=Math.sin(t),i=new je(o,s,-s,o,0,0);return n===void 0?i:je.Compose(je.Translate(n,r),i,je.Translate(-n,-r))}static Multiply(t,n){return{a:t.a*n.a+t.c*n.b,c:t.a*n.c+t.c*n.d,e:t.a*n.e+t.c*n.f+t.e,b:t.b*n.a+t.d*n.b,d:t.b*n.c+t.d*n.d,f:t.b*n.e+t.d*n.f+t.f}}static Inverse(t){const n=t.a*t.d-t.b*t.c;return{a:t.d/n,b:t.b/-n,c:t.c/-n,d:t.a/n,e:(t.d*t.e-t.c*t.f)/-n,f:(t.b*t.e-t.a*t.f)/n}}static Absolute(t){const n=t.a*t.d-t.b*t.c;return{a:t.d/n,b:t.b/-n,c:t.c/-n,d:t.a/n,e:(t.d*t.e-t.c*t.f)/n,f:(t.b*t.e-t.a*t.f)/-n}}static Compose(...t){const n=je.Identity();for(let r=0,o=t.length;r<o;r++)n.multiply(t[r]);return n}static Point(t){return new P(t.e,t.f)}static Rotation(t){let n;if(t.a!==0||t.c!==0){const r=(t.a*t.a+t.c*t.c)**.5;n=Math.acos(t.a/r)*(t.c>0?-1:1)}else if(t.b!==0||t.d!==0){const r=(t.b*t.b+t.d*t.d)**.5;n=ze+Math.acos(t.b/r)*(t.d>0?-1:1)}else n=0;return NS(n)}static Decompose(t){let n,r,o;if(t.a!==0||t.c!==0){const s=(t.a*t.a+t.c*t.c)**.5;n=s,r=(t.a*t.d-t.b*t.c)/s,o=Math.acos(t.a/s)*(t.c>0?-1:1)}else if(t.b!==0||t.d!==0){const s=(t.b*t.b+t.d*t.d)**.5;n=(t.a*t.d-t.b*t.c)/s,r=s,o=ze+Math.acos(t.b/s)*(t.d>0?-1:1)}else n=0,r=0,o=0;return{x:t.e,y:t.f,scaleX:n,scaleY:r,rotation:NS(o)}}static Smooth(t,n=1e10){return t.a=Math.round(t.a*n)/n,t.b=Math.round(t.b*n)/n,t.c=Math.round(t.c*n)/n,t.d=Math.round(t.d*n)/n,t.e=Math.round(t.e*n)/n,t.f=Math.round(t.f*n)/n,t}static toCssString(t){return`matrix(${j(t.a)}, ${j(t.b)}, ${j(t.c)}, ${j(t.d)}, ${j(t.e)}, ${j(t.f)})`}static applyToPoint(t,n){return new P(t.a*n.x+t.c*n.y+t.e,t.b*n.x+t.d*n.y+t.f,n.z)}static applyToXY(t,n,r){return[t.a*n+t.c*r+t.e,t.b*n+t.d*r+t.f]}static applyToPoints(t,n){return n.map(r=>new P(t.a*r.x+t.c*r.y+t.e,t.b*r.x+t.d*r.y+t.f,r.z))}static applyToBounds(t,n){return new ne(t.e+n.minX,t.f+n.minY,n.width,n.height)}static From(t){return new je(t.a,t.b,t.c,t.d,t.e,t.f)}static Cast(t){return t instanceof je?t:je.From(t)}};m(je,"Scale",(t,n,r,o)=>{const s=new je(t,0,0,n,0,0);return r===void 0?s:je.Compose(je.Translate(r,o),s,je.Translate(-r,-o))});let oe=je;function a2(e,t){return t===0?e:a2(t,e%t)}function c2(e){const t=e.toString().split(".")[1];if(!t)return 1;const n=Math.pow(10,t.length),r=parseInt(t,10);return n/a2(r,n)}class Hi{constructor(t){m(this,"isFilled",!1);m(this,"isClosed",!0);m(this,"isLabel",!1);m(this,"debugColor");m(this,"ignore");m(this,"_vertices");m(this,"_bounds");m(this,"_area");this.isFilled=t.isFilled,this.isClosed=t.isClosed,this.isLabel=t.isLabel??!1,this.debugColor=t.debugColor,this.ignore=t.ignore}hitTestPoint(t,n=0,r=!1){return this.isClosed&&(this.isFilled||r)&&Zn(t,this.vertices)?!0:P.Dist2(t,this.nearestPoint(t))<=n*n}distanceToPoint(t,n=!1){return t.dist(this.nearestPoint(t))*(this.isClosed&&(this.isFilled||n)&&Zn(t,this.vertices)?-1:1)}distanceToLineSegment(t,n){if(t.equals(n))return this.distanceToPoint(t);const{vertices:r}=this;let o,s=1/0,i,a,c;for(let l=0;l<r.length;l++)a=r[l],c=P.NearestPointOnLineSegment(t,n,a,!0),i=P.Dist2(a,c),i<s&&(s=i,o=c);if(!o)throw Error("nearest point not found");return this.isClosed&&this.isFilled&&Zn(o,this.vertices)?-s:s}hitTestLineSegment(t,n,r=0){return this.distanceToLineSegment(t,n)<=r}nearestPointOnLineSegment(t,n){const{vertices:r}=this;let o,s=1/0,i,a,c;for(let l=0;l<r.length;l++)a=r[l],c=P.NearestPointOnLineSegment(t,n,a,!0),i=P.Dist2(a,c),i<s&&(s=i,o=c);if(!o)throw Error("nearest point not found");return o}isPointInBounds(t,n=0){const{bounds:r}=this;return!(t.x<r.minX-n||t.y<r.minY-n||t.x>r.maxX+n||t.y>r.maxY+n)}get vertices(){return this._vertices||(this._vertices=this.getVertices()),this._vertices}getBounds(){return ne.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:t}=this;let n=0;for(let r=0,o=t.length;r<o;r++){const s=t[r],i=t[(r+1)%o];n+=s.x*i.y-i.x*s.y}return n/2}toSimpleSvgPath(){let t="";const{vertices:n}=this,r=n.length;if(r===0)return t;t+=`M${n[0].x},${n[0].y}`;for(let o=1;o<r;o++)t+=`L${n[o].x},${n[o].y}`;return this.isClosed&&(t+="Z"),t}}class Br extends Hi{constructor(n){super({...n,isClosed:!0,isFilled:!1});m(this,"children",[]);m(this,"ignoredChildren",[]);for(const r of n.children)r.ignore?this.ignoredChildren.push(r):this.children.push(r);if(this.children.length===0)throw Error("Group2d must have at least one child")}getVertices(){return this.children.filter(n=>!n.isLabel).flatMap(n=>n.vertices)}nearestPoint(n){let r=1/0,o;const{children:s}=this;if(s.length===0)throw Error("no children");let i,a;for(const c of s)i=c.nearestPoint(n),a=P.Dist2(i,n),a<r&&(r=a,o=i);if(!o)throw Error("nearest point not found");return o}distanceToPoint(n,r=!1){return Math.min(...this.children.map((o,s)=>o.distanceToPoint(n,r||s>0)))}hitTestPoint(n,r,o){return!!this.children.filter(s=>!s.isLabel).find(s=>s.hitTestPoint(n,r,o))}hitTestLineSegment(n,r,o){return!!this.children.filter(s=>!s.isLabel).find(s=>s.hitTestLineSegment(n,r,o))}getArea(){return this.children[0].area}toSimpleSvgPath(){let n="";for(const o of this.children)n+=o.toSimpleSvgPath();const r=ne.FromPoints(this.vertices).corners;for(let o=0,s=r.length;o<s;o++){const i=r[o],a=r[(o-1+s)%s],c=i.dist(a),l=r[(o+1)%s],u=i.dist(l),d=i.clone().lrp(a,4/c),p=i,f=i.clone().lrp(l,4/u);n+=`M${d.x},${d.y} L${p.x},${p.y} L${f.x},${f.y} `}return n}}function _F(e=!0){const[t,n]=x.useState(0),r=z();x.useEffect(()=>{if(!e)return;const o=()=>n(s=>s+1);return r.on("tick",o),()=>{r.off("tick",o)}},[r,e])}const kF=or(function({showStroke:t=!0,showVertices:n=!0,showClosestPointOnOutline:r=!0}){const o=z();_F(r);const s=o.getZoomLevel(),i=o.getRenderingShapes(),{inputs:{currentPagePoint:a}}=o;return h.jsx("svg",{style:{position:"absolute",pointerEvents:"none",zIndex:999999999,top:0,left:0,overflow:"visible"},children:i.map(c=>{const l=o.getShape(c.id);if(l.type==="group")return null;const u=o.getShapeGeometry(l),d=o.getShapePageTransform(l),p=o.getPointInShapeSpace(l,a),f=u.nearestPoint(p),y=u.distanceToPoint(p,!0),g=Math.abs(y)*s,w=y<0,{vertices:S}=u;return h.jsxs("g",{transform:d.toCssString(),strokeLinecap:"round",strokeLinejoin:"round",children:[t&&h.jsx(l2,{geometry:u}),n&&S.map((v,b)=>h.jsx("circle",{cx:v.x,cy:v.y,r:"2",fill:`hsl(${Ap(b,[0,S.length-1],[120,200])}, 100%, 50%)`,stroke:"black",strokeWidth:"1"},`v${b}`)),r&&g<150&&h.jsx("line",{x1:f.x,y1:f.y,x2:p.x,y2:p.y,opacity:1-g/150,stroke:w?"goldenrod":"dodgerblue",strokeWidth:"2"})]},c.id+"_outline")})})});function l2({geometry:e}){return e instanceof Br?h.jsx(h.Fragment,{children:[...e.children,...e.ignoredChildren].map((t,n)=>h.jsx(l2,{geometry:t},n))}):h.jsx("path",{stroke:e.debugColor??"red",strokeWidth:"2",fill:"none",opacity:"1",d:e.toSimpleSvgPath()})}var TF=200,X0="__lodash_hash_undefined__",$F=1/0,MF="[object Function]",AF="[object GeneratorFunction]",jF=/[\\^$.*+?()[\]{}|]/g,OF=/^\[object .+?Constructor\]$/,DF=typeof tn=="object"&&tn&&tn.Object===Object&&tn,RF=typeof self=="object"&&self&&self.Object===Object&&self,q0=DF||RF||Function("return this")();function LF(e,t){var n=e?e.length:0;return!!n&&NF(e,t,0)>-1}function FF(e,t,n,r){for(var o=e.length,s=n+-1;++s<o;)if(t(e[s],s,e))return s;return-1}function NF(e,t,n){if(t!==t)return FF(e,zF,n);for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}function zF(e){return e!==e}function BF(e,t){return e.has(t)}function UF(e,t){return e==null?void 0:e[t]}function HF(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function u2(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var KF=Array.prototype,WF=Function.prototype,d2=Object.prototype,fm=q0["__core-js_shared__"],F1=function(){var e=/[^.]+$/.exec(fm&&fm.keys&&fm.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),h2=WF.toString,Z0=d2.hasOwnProperty,VF=d2.toString,GF=RegExp("^"+h2.call(Z0).replace(jF,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),YF=KF.splice,XF=Q0(q0,"Map"),gm=Q0(q0,"Set"),au=Q0(Object,"create");function Mi(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function qF(){this.__data__=au?au(null):{}}function ZF(e){return this.has(e)&&delete this.__data__[e]}function QF(e){var t=this.__data__;if(au){var n=t[e];return n===X0?void 0:n}return Z0.call(t,e)?t[e]:void 0}function JF(e){var t=this.__data__;return au?t[e]!==void 0:Z0.call(t,e)}function eN(e,t){var n=this.__data__;return n[e]=au&&t===void 0?X0:t,this}Mi.prototype.clear=qF;Mi.prototype.delete=ZF;Mi.prototype.get=QF;Mi.prototype.has=JF;Mi.prototype.set=eN;function wc(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function tN(){this.__data__=[]}function nN(e){var t=this.__data__,n=Lf(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():YF.call(t,n,1),!0}function rN(e){var t=this.__data__,n=Lf(t,e);return n<0?void 0:t[n][1]}function oN(e){return Lf(this.__data__,e)>-1}function sN(e,t){var n=this.__data__,r=Lf(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}wc.prototype.clear=tN;wc.prototype.delete=nN;wc.prototype.get=rN;wc.prototype.has=oN;wc.prototype.set=sN;function bc(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function iN(){this.__data__={hash:new Mi,map:new(XF||wc),string:new Mi}}function aN(e){return Ff(this,e).delete(e)}function cN(e){return Ff(this,e).get(e)}function lN(e){return Ff(this,e).has(e)}function uN(e,t){return Ff(this,e).set(e,t),this}bc.prototype.clear=iN;bc.prototype.delete=aN;bc.prototype.get=cN;bc.prototype.has=lN;bc.prototype.set=uN;function Zp(e){var t=-1,n=e?e.length:0;for(this.__data__=new bc;++t<n;)this.add(e[t])}function dN(e){return this.__data__.set(e,X0),this}function hN(e){return this.__data__.has(e)}Zp.prototype.add=Zp.prototype.push=dN;Zp.prototype.has=hN;function Lf(e,t){for(var n=e.length;n--;)if(xN(e[n][0],t))return n;return-1}function pN(e){if(!p2(e)||yN(e))return!1;var t=wN(e)||HF(e)?GF:OF;return t.test(SN(e))}function fN(e,t,n){var r=-1,o=LF,s=e.length,i=!0,a=[],c=a;if(s>=TF){var l=gN(e);if(l)return u2(l);i=!1,o=BF,c=new Zp}else c=a;e:for(;++r<s;){var u=e[r],d=u;if(u=u!==0?u:0,i&&d===d){for(var p=c.length;p--;)if(c[p]===d)continue e;a.push(u)}else o(c,d,n)||(c!==a&&c.push(d),a.push(u))}return a}var gN=gm&&1/u2(new gm([,-0]))[1]==$F?function(e){return new gm(e)}:bN;function Ff(e,t){var n=e.__data__;return mN(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Q0(e,t){var n=UF(e,t);return pN(n)?n:void 0}function mN(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function yN(e){return!!F1&&F1 in e}function SN(e){if(e!=null){try{return h2.call(e)}catch{}try{return e+""}catch{}}return""}function vN(e){return e&&e.length?fN(e):[]}function xN(e,t){return e===t||e!==e&&t!==t}function wN(e){var t=p2(e)?VF.call(e):"";return t==MF||t==AF}function p2(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function bN(){}var PN=vN;const CN=pc(PN);function f2(e){return CN(e)}function IN(){const e=z(),t=A3("userIds",()=>f2(e.getCollaborators().map(n=>n.userId)).sort(),{isEqual:(n,r)=>{var o;return n.join(",")===((o=r.join)==null?void 0:o.call(r,","))}},[e]);return K(t)}function g2(e){const t=z();return K(`latestPresence:${e}`,()=>t.getCollaborators().find(r=>r.userId===e),[t])??null}const EN=or(function(){const t=IN();return h.jsx(h.Fragment,{children:t.map(n=>h.jsx(_N,{collaboratorId:n},n))})}),_N=or(function({collaboratorId:t}){const n=z(),r=g2(t),o=TN(r);if(!(r&&r.currentPageId===n.getCurrentPageId()))return null;switch(o){case"inactive":{const{followingUserId:s,highlightedUserIds:i}=n.getInstanceState();if(!(s===r.userId||i.includes(r.userId)))return null;break}case"idle":{const{highlightedUserIds:s}=n.getInstanceState();if(r.followingUserId===n.user.getId()&&!(r.chatMessage||s.includes(r.userId)))return null;break}}return h.jsx(kN,{latestPresence:r})}),kN=or(function({latestPresence:t}){const n=z(),{CollaboratorBrush:r,CollaboratorScribble:o,CollaboratorCursor:s,CollaboratorHint:i,CollaboratorShapeIndicator:a}=dt(),c=n.getZoomLevel(),l=n.getViewportPageBounds(),{userId:u,chatMessage:d,brush:p,scribbles:f,selectedShapeIds:y,userName:g,cursor:w,color:S}=t,v=!(w.x<l.minX-12/c||w.y<l.minY-16/c||w.x>l.maxX-12/c||w.y>l.maxY-16/c);return h.jsxs(h.Fragment,{children:[p&&r?h.jsx(r,{className:"tl-collaborator__brush",brush:p,color:S,opacity:.1},u+"_brush"):null,v&&s?h.jsx(s,{className:"tl-collaborator__cursor",point:w,color:S,zoom:c,name:g!=="New User"?g:null,chatMessage:d},u+"_cursor"):i?h.jsx(i,{className:"tl-collaborator__cursor-hint",point:w,color:S,zoom:c,viewport:l},u+"_cursor_hint"):null,o&&f.length?h.jsx(h.Fragment,{children:f.map(b=>h.jsx(o,{className:"tl-collaborator__scribble",scribble:b,color:S,zoom:c,opacity:b.color==="laser"?.5:.1},u+"_scribble_"+b.id))}):null,a&&y.map(b=>h.jsx(a,{className:"tl-collaborator__shape-indicator",shapeId:b,color:S,opacity:.5},u+"_"+b))]})});function N1(e){return e>O5?"inactive":e>Vk?"idle":"active"}function TN(e){const t=x.useRef((e==null?void 0:e.lastActivityTimestamp)??-1),[n,r]=x.useState(()=>N1(Date.now()-t.current));return x.useEffect(()=>{const o=setInterval(()=>{r(N1(Date.now()-t.current))},D5);return()=>clearInterval(o)},[]),e&&(t.current=e.lastActivityTimestamp),n}const m2=x.memo(function({id:t,shape:n,util:r,index:o,backgroundIndex:s,opacity:i,dprMultiple:a}){const c=z(),{ShapeErrorFallback:l}=dt(),u=x.useRef(null),d=x.useRef(null),p=x.useRef({transform:"",clipPath:"none",width:0,height:0,x:0,y:0,isCulled:!1});js("set shape stuff",()=>{const g=c.getShape(t);if(!g)return;const w=p.current,S=c.getShapeClipPath(t)??"none";S!==w.clipPath&&(Yt(u.current,"clip-path",S),Yt(d.current,"clip-path",S),w.clipPath=S);const v=c.getShapePageTransform(t),b=oe.toCssString(v),E=c.getShapeGeometry(g).bounds;b!==w.transform&&(Yt(u.current,"transform",b),Yt(d.current,"transform",b),w.transform=b);const C=E.w%a,I=E.h%a,_=C===0?E.w:E.w+(a-C),k=I===0?E.h:E.h+(a-I);(_!==w.width||k!==w.height)&&(Yt(u.current,"width",Math.max(_,a)+"px"),Yt(u.current,"height",Math.max(k,a)+"px"),Yt(d.current,"width",Math.max(_,a)+"px"),Yt(d.current,"height",Math.max(k,a)+"px"),w.width=_,w.height=k)},[c]),js("set opacity and z-index",()=>{const g=u.current,w=d.current;Yt(g,"opacity",i),Yt(w,"opacity",i),Yt(g,"z-index",o),Yt(w,"z-index",s)},[i,o,s]),js("set display",()=>{if(!c.getShape(t))return;const S=c.getCulledShapes().has(t);S!==p.current.isCulled&&(Yt(u.current,"display",S?"none":"block"),Yt(d.current,"display",S?"none":"block"),p.current.isCulled=S)},[c]);const f=x.useCallback(g=>c.annotateError(g,{origin:"shape",willCrashApp:!1}),[c]);if(!n)return null;const y="fill"in n.props&&n.props.fill!=="none";return h.jsxs(h.Fragment,{children:[r.backgroundComponent&&h.jsx("div",{ref:d,className:"tl-shape tl-shape-background","data-shape-type":n.type,draggable:!1,children:h.jsx(su,{fallback:l,onError:f,children:h.jsx(MN,{shape:n,util:r})})}),h.jsx("div",{ref:u,className:"tl-shape","data-shape-type":n.type,"data-shape-is-filled":y,draggable:!1,children:h.jsx(su,{fallback:l,onError:f,children:h.jsx($N,{shape:n,util:r})})})]})}),$N=x.memo(function({shape:t,util:n}){return $f("InnerShape:"+t.type,()=>n.component(t))},(e,t)=>e.shape.props===t.shape.props&&e.shape.meta===t.shape.meta),MN=x.memo(function({shape:t,util:n}){return $f("InnerShape:"+t.type,()=>{var r;return(r=n.backgroundComponent)==null?void 0:r.call(n,t)})},(e,t)=>e.shape.props===t.shape.props&&e.shape.meta===t.shape.meta);function AN({className:e}){const t=z(),{Background:n,SvgDefs:r}=dt(),o=x.useRef(null),s=x.useRef(null),i=x.useRef(null),a=cn();IF(o),X5(),G5(),tF(o),Q5(o);const c=x.useRef({lodDisableTextOutline:!1,allowTextOutline:!0});js("position layers",function(){const{x:S,y:v,z:b}=t.getCamera();if(c.current.allowTextOutline&&t.environment.isSafari&&(a.style.setProperty("--tl-text-outline","none"),c.current.allowTextOutline=!1),c.current.allowTextOutline&&b<P1!==c.current.lodDisableTextOutline){const I=b<P1;a.style.setProperty("--tl-text-outline",I?"none":`0 var(--b) 0 var(--color-background), 0 var(--a) 0 var(--color-background),
|
|
var(--b) var(--b) 0 var(--color-background), var(--a) var(--b) 0 var(--color-background),
|
|
var(--a) var(--a) 0 var(--color-background), var(--b) var(--a) 0 var(--color-background)`),c.current.lodDisableTextOutline=I}const E=b>=1?Ap(b,[1,8],[.125,.5],!0):Ap(b,[.1,1],[-2,.125],!0),C=`scale(${j(b)}) translate(${j(S+E)}px,${j(v+E)}px)`;Yt(s.current,"transform",C),Yt(i.current,"transform",C)},[t,a]);const l=V5(),u=K("shapeSvgDefs",()=>{const w=new Map;for(const S of bt(t.shapeUtils)){if(!S)return;const v=S.getCanvasSvgDefs();for(const{key:b,component:E}of v)w.has(b)||w.set(b,h.jsx(E,{},b))}return[...w.values()]},[t]),d=K("debug_shapes",()=>$t.hideShapes.get(),[$t]),p=K("debug_svg",()=>$t.debugSvg.get(),[$t]),f=K("debug_geometry",()=>$t.debugGeometry.get(),[$t]),y=K("isEditingAnything",()=>t.getEditingShapeId()!==null,[t]),g=K("isSelectingAnything",()=>!!t.getSelectedShapeIds().length,[t]);return h.jsxs("div",{ref:o,draggable:!1,"data-iseditinganything":y,"data-isselectinganything":g,className:ue("tl-canvas",e),"data-testid":"canvas",...l,children:[h.jsx("svg",{className:"tl-svg-context",children:h.jsxs("defs",{children:[u,h.jsx(VN,{}),h.jsx(GN,{}),r&&h.jsx(r,{})]})}),n&&h.jsx("div",{className:"tl-background__wrapper",children:h.jsx(n,{})}),h.jsx(jN,{}),h.jsxs("div",{ref:s,className:"tl-html-layer tl-shapes",draggable:!1,children:[h.jsx(ZN,{}),h.jsx(qN,{}),d?null:p?h.jsx(BN,{}):h.jsx(HN,{})]}),h.jsxs("div",{className:"tl-overlays",children:[h.jsxs("div",{ref:i,className:"tl-html-layer",children:[f?h.jsx(kF,{}):null,h.jsx(FN,{}),h.jsx(DN,{}),h.jsx(ON,{}),h.jsx(RN,{}),h.jsx(KN,{}),h.jsx(WN,{}),h.jsx(LN,{}),h.jsx(XN,{}),h.jsx(EN,{})]}),h.jsx(QN,{})]}),h.jsx(JN,{})]})}function jN(){const e=z(),t=K("gridSize",()=>e.getDocumentSettings().gridSize,[e]),{x:n,y:r,z:o}=K("camera",()=>e.getCamera(),[e]),s=K("isGridMode",()=>e.getInstanceState().isGridMode,[e]),{Grid:i}=dt();return i&&s?h.jsx(i,{x:n,y:r,z:o,size:t}):null}function ON(){const e=z(),t=K("scribbles",()=>e.getInstanceState().scribbles,[e]),n=K("zoomLevel",()=>e.getZoomLevel(),[e]),{Scribble:r}=dt();return r&&t.length?h.jsx(h.Fragment,{children:t.map(o=>h.jsx(r,{className:"tl-user-scribble",scribble:o,zoom:n},o.id))}):null}function DN(){const e=z(),t=K("brush",()=>e.getInstanceState().brush,[e]),{Brush:n}=dt();return n&&t?h.jsx(n,{className:"tl-user-brush",brush:t}):null}function RN(){const e=z(),t=K("zoomBrush",()=>e.getInstanceState().zoomBrush,[e]),{ZoomBrush:n}=dt();return n&&t?h.jsx(n,{className:"tl-user-brush tl-zoom-brush",brush:t}):null}function LN(){const e=z(),t=K("snapLines",()=>e.snaps.getIndicators(),[e]),n=K("zoomLevel",()=>e.getZoomLevel(),[e]),{SnapIndicator:r}=dt();return r&&t.length>0?h.jsx(h.Fragment,{children:t.map(o=>h.jsx(r,{className:"tl-user-snapline",line:o,zoom:n},o.id))}):null}function FN(){const e=z(),t=K("handles shapeIdWithHandles",()=>{const{isReadonly:n,isChangingStyle:r}=e.getInstanceState();if(n||r)return!1;const o=e.getOnlySelectedShape();return!o||!e.getShapeHandles(o)?!1:o.id},[e]);return t?h.jsx(NN,{shapeId:t}):null}function NN({shapeId:e}){const t=z(),{Handles:n}=dt(),r=K("zoomLevel",()=>t.getZoomLevel(),[t]),o=K("coarse pointer",()=>t.getInstanceState().isCoarsePointer,[t]),s=K("handles transform",()=>t.getShapePageTransform(e),[t,e]),i=K("handles",()=>{const a=t.getShapeHandles(e);if(!a)return null;const c=(o?Gk:Yk)/r*2;return a.filter(l=>l.type!=="virtual"||!a.some(u=>u!==l&&u.type==="vertex"&&P.Dist(l,u)<c)).sort(l=>l.type==="vertex"?1:-1)},[t,r,o,e]);return!n||!i||!s?null:h.jsx(n,{children:h.jsx("g",{transform:oe.toCssString(s),children:i.map(a=>h.jsx(zN,{shapeId:e,handle:a,zoom:r,isCoarse:o},a.id))})})}function zN({shapeId:e,handle:t,zoom:n,isCoarse:r}){const o=nF(e,t.id),{Handle:s}=dt();return s?h.jsx("g",{"aria-label":"handle",transform:`translate(${t.x}, ${t.y})`,...o,children:h.jsx(s,{shapeId:e,handle:t,zoom:n,isCoarse:r})}):null}function BN(){const e=z(),t=K("rendering shapes",()=>e.getRenderingShapes(),[e]),n=K("dpr multiple",()=>c2(Math.floor(e.getInstanceState().devicePixelRatio*100)/100),[e]);return h.jsx(h.Fragment,{children:t.map(r=>h.jsxs(x.Fragment,{children:[h.jsx(m2,{...r,dprMultiple:n}),h.jsx(YN,{id:r.id})]},r.id+"_fragment"))})}function UN(){const e=z(),t=x.useRef(new Set);return js("reflow for culled shapes",()=>{const n=e.getCulledShapes();if(t.current.size===n.size&&[...n].every(o=>t.current.has(o)))return;t.current=n;const r=document.getElementsByClassName("tl-canvas");r.length!==0&&r[0].offsetHeight},[e]),null}function HN(){const e=z(),t=K("rendering shapes",()=>e.getRenderingShapes(),[e]),n=K("dpr multiple",()=>c2(Math.floor(e.getInstanceState().devicePixelRatio*100)/100),[e]);return h.jsxs(h.Fragment,{children:[t.map(r=>h.jsx(m2,{...r,dprMultiple:n},r.id+"_shape")),e.environment.isSafari&&h.jsx(UN,{})]})}function KN(){const e=z(),t=K("rendering shapes",()=>e.getRenderingShapes(),[e]),n=x.useRef(new Set),r=K("should display selected ids",()=>{const s=n.current,i=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 a=e.getSelectedShapeIds();for(const c of a)i.add(c);if(e.isInAny("select.idle","select.editing_shape")){const c=e.getInstanceState();if(c.isHoveringCanvas&&!c.isCoarsePointer){const l=e.getHoveredShapeId();l&&i.add(l)}}}if(s.size!==i.size)return n.current=i,i;for(const a of i)if(!s.has(a))return n.current=i,i;return s},[e]),{ShapeIndicator:o}=dt();return o?h.jsx(h.Fragment,{children:t.map(({id:s})=>h.jsx(o,{shapeId:s,hidden:!r.has(s)},s+"_indicator"))}):null}function WN(){const e=z(),{ShapeIndicator:t}=dt(),n=K("hinting shape ids",()=>Mp(e.getHintingShapeIds()),[e]);return!n.length||!t?null:h.jsx(h.Fragment,{children:n.map(r=>h.jsx(t,{className:"tl-user-indicator__hint",shapeId:r},r+"_hinting"))})}function VN(){return h.jsxs("g",{id:"cursor",children:[h.jsxs("g",{fill:"rgba(0,0,0,.2)",transform:"translate(-11,-11)",children:[h.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),h.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),h.jsxs("g",{fill:"white",transform:"translate(-12,-12)",children:[h.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),h.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),h.jsxs("g",{fill:"currentColor",transform:"translate(-12,-12)",children:[h.jsx("path",{d:"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"}),h.jsx("path",{d:"m13 10.814v11.188l2.969-2.866.428-.139h4.768z"})]})]})}function GN(){return h.jsx("path",{id:"cursor_hint",fill:"currentColor",d:"M -2,-5 2,0 -2,5 Z"})}function YN({id:e}){const t=z(),[n,r]=x.useState(null),o=K("is in root",()=>{const s=t.getShape(e);return(s==null?void 0:s.parentId)===t.getCurrentPageId()},[t,e]);return x.useEffect(()=>{if(!o)return;let s=null;const i=Sc("shape to svg",async()=>{const a=Math.random();s=a;const l=t.isShapeOfType(e,"frame")?0:10;let u=t.getShapePageBounds(e);if(!u)return;u=u.clone().expandBy(l);const d=await t.getSvgString([e],{padding:l,background:t.getInstanceState().exportBackground});if(s!==a||!d)return;const p=`data:image/svg+xml;utf8,${encodeURIComponent(d.svg)}`;r({src:p,bounds:u})});return()=>{s=null,i()}},[t,e,o]),!o||!n?null:h.jsx("img",{src:n.src,width:n.bounds.width,height:n.bounds.height,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 XN(){const e=z(),t=K("selection rotation",()=>e.getSelectionRotation(),[e]),n=K("selection bounds",()=>e.getSelectionRotatedPageBounds(),[e]),{SelectionForeground:r}=dt();return!n||!r?null:h.jsx(r,{bounds:n,rotation:t})}function qN(){const e=z(),t=K("selection rotation",()=>e.getSelectionRotation(),[e]),n=K("selection bounds",()=>e.getSelectionRotatedPageBounds(),[e]),{SelectionBackground:r}=dt();return!n||!r?null:h.jsx(r,{bounds:n,rotation:t})}function ZN(){const{OnTheCanvas:e}=dt();return e?h.jsx(e,{}):null}function QN(){const{InFrontOfTheCanvas:e}=dt();return e?h.jsx(e,{}):null}function JN(){const e=z(),t=K("camera state",()=>e.getCameraState(),[e]);return h.jsx("div",{className:ue("tl-hit-test-blocker",{"tl-hit-test-blocker__hidden":t==="idle"})})}function e4({className:e,zoom:t,point:n,color:r,viewport:o,opacity:s=1}){const i=x.useRef(null);return xc(i,Ns(n.x,o.minX+5/t,o.maxX-5/t),Ns(n.y,o.minY+5/t,o.maxY-5/t),1/t,P.Angle(o.center,n)),h.jsxs("svg",{ref:i,className:ue("tl-overlays__item",e),children:[h.jsx("use",{href:"#cursor_hint",color:r,strokeWidth:3,stroke:"var(--color-background)"}),h.jsx("use",{href:"#cursor_hint",color:r,opacity:s})]})}const z1=x.memo(function({className:t,zoom:n,point:r,color:o,name:s,chatMessage:i}){const a=x.useRef(null);return xc(a,r==null?void 0:r.x,r==null?void 0:r.y,1/n),r?h.jsxs("div",{ref:a,className:ue("tl-overlays__item",t),children:[h.jsx("svg",{className:"tl-cursor",children:h.jsx("use",{href:"#cursor",color:o})}),i?h.jsxs(h.Fragment,{children:[s&&h.jsx("div",{className:"tl-nametag-title",style:{color:o},children:s}),h.jsx("div",{className:"tl-nametag-chat",style:{backgroundColor:o},children:i})]}):s&&h.jsx("div",{className:"tl-nametag",style:{backgroundColor:o},children:s})]}):null});function t4({x:e,y:t,z:n,size:r}){return h.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("defs",{children:w1.map(({min:o,mid:s,step:i},a)=>{const c=i*r*n,l=.5+e*n,u=.5+t*n,d=l>0?l%c:c+l%c,p=u>0?u%c:c+u%c,f=n<s?Ap(n,[o,s],[0,1]):1;return h.jsx("pattern",{id:`grid-${i}`,width:c,height:c,patternUnits:"userSpaceOnUse",children:h.jsx("circle",{className:"tl-grid-dot",cx:d,cy:p,r:1,opacity:f})},`grid-pattern-${a}`)})}),w1.map(({step:o},s)=>h.jsx("rect",{width:"100%",height:"100%",fill:`url(#grid-${o})`},`grid-rect-${s}`))]})}function n4({handle:e,isCoarse:t,className:n,zoom:r}){const o=(t?Gk:Yk)/r;if(e.type==="clone"){const i=3/Math.max(r,.35),a=`M0,${-i} A${i},${i} 0 0,1 0,${i}`,c=z5.indexOf(e.id);return h.jsxs("g",{className:ue(`tl-handle tl-handle__${e.type}`,n),children:[h.jsx("circle",{className:"tl-handle__bg",r:o}),h.jsx("path",{className:"tl-handle__fg",d:a,transform:`rotate(${-90+90*c})`})]})}const s=(e.type==="create"&&t?3:4)/Math.max(r,.35);return h.jsxs("g",{className:ue(`tl-handle tl-handle__${e.type}`,n),children:[h.jsx("circle",{className:"tl-handle__bg",r:o}),h.jsx("circle",{className:"tl-handle__fg",r:s})]})}const r4=({children:e})=>h.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:e});function J0(e,t=!0){const n=e.length;if(n<2)return"";let r=e[0],o=e[1];if(n===2)return`M${Ft(r)}L${Ft(o)}`;let s="";for(let i=2,a=n-1;i<a;i++)r=e[i],o=e[i+1],s+=Cn(r,o);return t?`M${Cn(e[0],e[1])}Q${Ft(e[1])}${Cn(e[1],e[2])}T${s}${Cn(e[n-1],e[0])}${Cn(e[0],e[1])}Z`:`M${Ft(e[0])}Q${Ft(e[1])}${Cn(e[1],e[2])}${e.length>3?"T":""}${s}L${Ft(e[n-1])}`}function B1({scribble:e,zoom:t,color:n,opacity:r,className:o}){return e.points.length?h.jsx("svg",{className:o&&ue("tl-overlays__item",o),children:h.jsx("path",{className:"tl-scribble",d:J0(e.points,!1),stroke:n??`var(--color-${e.color})`,fill:"none",strokeWidth:8/t,opacity:r??e.opacity})}):null}function y2({bounds:e,rotation:t}){const n=x.useRef(null);return xc(n,e.x,e.y,1,t),x.useLayoutEffect(()=>{const r=n.current;r&&(r.style.width=j(Math.max(1,e.width))+"px",r.style.height=j(Math.max(1,e.height))+"px")},[e.width,e.height]),h.jsx("div",{ref:n,className:"tl-selection__bg",draggable:!1})}function o4({bounds:e,rotation:t}){const n=z(),r=x.useRef(null),o=K("only selected shape",()=>n.getOnlySelectedShape(),[n]),s=o?n.getShapeUtil(o).expandSelectionOutlinePx(o):0;return xc(r,e==null?void 0:e.x,e==null?void 0:e.y,1,t,{x:-s,y:-s}),e=e.clone().expandBy(s).zeroFix(),h.jsx("svg",{ref:r,className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:h.jsx("rect",{className:ue("tl-selection__fg__outline"),width:j(e.width),height:j(e.height)})})}const s4=()=>h.jsx("div",{className:"tl-shape-error-boundary"}),i4=({shape:e,util:t})=>$f("Indicator: "+e.type,()=>t.indicator(e)),a4=({editor:e,id:t})=>{const n=K("shape for indicator",()=>e.store.get(t),[e,t]),{ShapeIndicatorErrorFallback:r}=dt();return!n||n.isLocked?null:h.jsx(su,{fallback:r,onError:o=>e.annotateError(o,{origin:"react.shapeIndicator",willCrashApp:!1}),children:h.jsx(i4,{shape:n,util:e.getShapeUtil(n)},n.id)})},U1=x.memo(function({shapeId:t,className:n,color:r,hidden:o,opacity:s}){const i=z(),a=x.useRef(null);return js("indicator transform",()=>{const c=a.current;if(!c)return;const l=i.getShapePageTransform(t);l&&c.style.setProperty("transform",l.toCssString())},[i,t]),x.useLayoutEffect(()=>{const c=a.current;c&&c.style.setProperty("display",o?"none":"block")},[o]),h.jsx("svg",{ref:a,className:ue("tl-overlays__item",n),children:h.jsx("g",{className:"tl-shape-indicator",stroke:r??"var(--color-selected)",opacity:s,children:h.jsx(a4,{editor:i,id:t})})})}),c4=()=>h.jsx("circle",{cx:4,cy:4,r:8,strokeWidth:"1",stroke:"red"});function l4({points:e,zoom:t}){const n=2.5/t,r=e.reduce((p,f)=>Math.min(p,f.x),1/0),o=e.reduce((p,f)=>Math.max(p,f.x),-1/0),s=e.reduce((p,f)=>Math.min(p,f.y),1/0),i=e.reduce((p,f)=>Math.max(p,f.y),-1/0),a=e.some(p=>p.x===r&&p.y===s);let c,l,u,d;return a?(c=r,l=s,u=o,d=i):(c=r,l=i,u=o,d=s),h.jsxs("g",{className:"tl-snap-indicator",stroke:"lime",children:[h.jsx("line",{x1:c,y1:l,x2:u,y2:d}),e.map((p,f)=>h.jsx("g",{transform:`translate(${p.x},${p.y})`,children:h.jsx("path",{className:"tl-snap-point",d:`M ${-n},${-n} L ${n},${n} M ${-n},${n} L ${n},${-n}`})},f))]})}function u4({gaps:e,direction:t,zoom:n}){const r=3.5/n;let o=[-1/0,1/0],s=null;const i=t==="horizontal";for(const c of e){if(s=kr(o[0],o[1],i?c.startEdge[0].y:c.startEdge[0].x,i?c.startEdge[1].y:c.startEdge[1].x),s)o=s;else continue;if(s=kr(o[0],o[1],i?c.endEdge[0].y:c.endEdge[0].x,i?c.endEdge[1].y:c.endEdge[1].x),s)o=s;else continue}if(o===null)return null;const a=(o[0]+o[1])/2;return h.jsx("g",{className:"tl-snap-indicator",stroke:"cyan",children:e.map(({startEdge:c,endEdge:l},u)=>h.jsx(x.Fragment,{children:i?h.jsxs(h.Fragment,{children:[h.jsx("line",{x1:c[0].x,y1:a-2*r,x2:c[1].x,y2:a+2*r}),h.jsx("line",{x1:l[0].x,y1:a-2*r,x2:l[1].x,y2:a+2*r}),h.jsx("line",{x1:c[0].x,y1:a,x2:l[0].x,y2:a}),h.jsx("line",{x1:(c[0].x+l[0].x)/2,y1:a-r,x2:(c[0].x+l[0].x)/2,y2:a+r})]}):h.jsxs(h.Fragment,{children:[h.jsx("line",{x1:a-2*r,y1:c[0].y,x2:a+2*r,y2:c[1].y}),h.jsx("line",{x1:a-2*r,y1:l[0].y,x2:a+2*r,y2:l[1].y}),h.jsx("line",{x1:a,y1:c[0].y,x2:a,y2:l[0].y}),h.jsx("line",{x1:a-r,y1:(c[0].y+l[0].y)/2,x2:a+r,y2:(c[0].y+l[0].y)/2})]})},u))})}function d4({className:e,line:t,zoom:n}){return h.jsx("svg",{className:ue("tl-overlays__item",e),children:t.type==="points"?h.jsx(l4,{...t,zoom:n}):t.type==="gaps"?h.jsx(u4,{...t,zoom:n}):null})}function h4(){return h.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",children:h.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[h.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"var(--color-text-1)"}),h.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"var(--color-text-1)",children:h.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}const p4=()=>null;function S2(e,t){const n=x.useRef(e);return t(e,n.current)?n.current:(n.current=e,e)}function KS(e){return S2(e,O3)}function ex(e){return S2(e,K_)}const v2=x.createContext({});function f4({overrides:e={},children:t}){const n=ex(e);return h.jsx(v2.Provider,{value:x.useMemo(()=>({Background:v5,SvgDefs:p4,Brush:Pd,ZoomBrush:Pd,ScreenshotBrush:Pd,CollaboratorBrush:Pd,Cursor:z1,CollaboratorCursor:z1,CollaboratorHint:e4,CollaboratorShapeIndicator:U1,Grid:t4,Scribble:B1,SnapIndicator:d4,Handles:r4,Handle:n4,CollaboratorScribble:B1,ErrorFallback:w2,ShapeErrorFallback:s4,ShapeIndicatorErrorFallback:c4,Spinner:h4,SelectionBackground:y2,SelectionForeground:o4,ShapeIndicator:U1,OnTheCanvas:null,InFrontOfTheCanvas:null,Canvas:AN,...n}),[n]),children:t})}function dt(){return x.useContext(v2)}const tx={openWindow:(e,t)=>window.open(e,t,"noopener noreferrer"),refreshPage:()=>window.location.reload(),hardReset:async()=>{var e;return await((e=window.__tldraw__hardReset)==null?void 0:e.call(window))}};function x2(){tx.hardReset()}function g4(){tx.refreshPage()}const m4="https://github.com/tldraw/tldraw/issues/new";function y4(){}const w2=({error:e,editor:t})=>{const n=x.useRef(null),[r,o]=x.useState(!1),[s,i]=x.useState(!1),[a,c]=x.useState(!1),{Canvas:l}=dt(),u=e instanceof Error?e.message:String(e),d=e instanceof Error?e.stack:null,p=K("isDarkMode",()=>{try{if(t)return t.user.getIsDarkMode()}catch{}return null},[t]),[f,y]=x.useState(null);x.useLayoutEffect(()=>{var C;p!==null&&y(p);let b=(C=n.current)==null?void 0:C.parentElement,E=!1;for(;b;){if(b.classList.contains("tl-theme__dark")||b.classList.contains("tl-theme__light")){E=!0;break}b=b.parentElement}if(E){y(null);return}y(window.matchMedia("(prefers-color-scheme: dark)").matches)},[p]),x.useEffect(()=>{if(s){const b=setTimeout(()=>{i(!1)},2e3);return()=>clearTimeout(b)}},[s]);const g=()=>{const b=document.createElement("textarea");b.value=d??u,document.body.appendChild(b),b.select(),document.execCommand("copy"),b.remove(),i(!0)},w=()=>{g4()},S=async()=>{x2()},v=new URL(m4);return v.searchParams.set("title",u),v.searchParams.set("labels","bug"),v.searchParams.set("body",`Hey, I ran into an error while using tldraw:
|
|
|
|
\`\`\`js
|
|
${d??u}
|
|
\`\`\`
|
|
|
|
My browser: ${navigator.userAgent}`),h.jsxs("div",{ref:n,className:ue("tl-container tl-error-boundary",f===null?"":f?"tl-theme__dark":"tl-theme__light"),children:[h.jsx("div",{className:"tl-error-boundary__overlay"}),t&&h.jsx(Hk,{onError:y4,fallback:()=>null,children:h.jsx(Rf.Provider,{value:t,children:h.jsx("div",{className:"tl-overlay tl-error-boundary__canvas",children:l?h.jsx(l,{}):null})})}),h.jsx("div",{className:ue("tl-modal","tl-error-boundary__content",{"tl-error-boundary__content__expanded":r&&!a}),children:a?h.jsxs(h.Fragment,{children:[h.jsx("h2",{children:"Are you sure?"}),h.jsx("p",{children:"Resetting your data will delete your drawing and cannot be undone."}),h.jsxs("div",{className:"tl-error-boundary__content__actions",children:[h.jsx("button",{onClick:()=>c(!1),children:"Cancel"}),h.jsx("button",{className:"tl-error-boundary__reset",onClick:S,children:"Reset data"})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("h2",{children:"Something's gone wrong."}),h.jsxs("p",{children:["Sorry, we encountered an error. Please refresh the page to continue. If you keep seeing this error, you can ",h.jsx("a",{href:v.toString(),children:"create a GitHub issue"})," or"," ",h.jsx("a",{href:"https://discord.gg/Cq6cPsTfNy",children:"ask for help on Discord"}),"."]}),r&&h.jsxs(h.Fragment,{children:["Message:",h.jsx("h4",{children:h.jsx("code",{children:u})}),"Stack trace:",h.jsxs("div",{className:"tl-error-boundary__content__error",children:[h.jsx("pre",{children:h.jsx("code",{children:d??u})}),h.jsx("button",{onClick:g,children:s?"Copied!":"Copy"})]})]}),h.jsxs("div",{className:"tl-error-boundary__content__actions",children:[h.jsx("button",{onClick:()=>o(!r),children:r?"Hide details":"Show details"}),h.jsxs("div",{className:"tl-error-boundary__content__actions__group",children:[h.jsx("button",{className:"tl-error-boundary__reset",onClick:()=>c(!0),children:"Reset data"}),h.jsx("button",{className:"tl-error-boundary__refresh",onClick:w,children:"Refresh Page"})]})]})]})})]})};let S4=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");function et(){return S4()}const b2="TLDRAW_USER_DATA_v3",P2=ve({id:ge,name:ge.nullable().optional(),locale:ge.nullable().optional(),color:ge.nullable().optional(),isDarkMode:we.nullable().optional(),animationSpeed:he.nullable().optional(),edgeScrollSpeed:he.nullable().optional(),isSnapMode:we.nullable().optional(),isWrapMode:we.nullable().optional()}),pa={AddAnimationSpeed:1,AddIsSnapMode:2,MakeFieldsNullable:3,AddEdgeScrollSpeed:4,AddExcalidrawSelectMode:5},nx=Math.max(...Object.values(pa));function v4(e){e.version<pa.AddAnimationSpeed&&(e.user.animationSpeed=1),e.version<pa.AddIsSnapMode&&(e.user.isSnapMode=!1),e.version<pa.MakeFieldsNullable,e.version<pa.AddEdgeScrollSpeed&&(e.user.edgeScrollSpeed=1),e.version<pa.AddExcalidrawSelectMode&&(e.user.isWrapMode=!1),e.version=nx}const H1=["#FF802B","#EC5E41","#F2555A","#F04F88","#E34BA9","#BD54C6","#9D5BD2","#7B66DC","#02B1CC","#11B3A3","#39B178","#55B467"];function x4(){return H1[Math.floor(Math.random()*H1.length)]}function w4(){var e,t;return typeof window>"u"?!1:((t=(e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)"))==null?void 0:t.matches)??!1}function b4(){var e,t;return typeof window>"u"?!1:((t=(e=window.matchMedia)==null?void 0:e.call(window,"(prefers-reduced-motion: reduce)"))==null?void 0:t.matches)??!1}const ai=Object.freeze({name:"New User",locale:f5(),color:x4(),isDarkMode:!1,edgeScrollSpeed:1,animationSpeed:b4()?0:1,isSnapMode:!1,isWrapMode:!1});function mm(){return{id:et()}}function C2(e){if(e===null||typeof e!="object"||!("version"in e)||!("user"in e)||typeof e.version!="number")return mm();const t=Ye(e);v4(t);try{return P2.validate(t.user)}catch{return mm()}}function P4(){const e=JSON.parse(L0(b2)||"null")??null;return C2(e)}const cu=fn("globalUserData",null);function C4(){F0(b2,JSON.stringify({version:nx,user:cu.get()}))}function I4(e){P2.validate(e),cu.set(e),C4(),_4()}const E4=typeof process<"u"&&!1,Wa=typeof BroadcastChannel<"u"&&!E4?new BroadcastChannel("tldraw-user-sync"):null;Wa==null||Wa.addEventListener("message",e=>{const t=e.data;(t==null?void 0:t.type)===E2&&(t==null?void 0:t.origin)!==I2()&&cu.set(C2(t.data))});let ym=null;function I2(){return ym===null&&(ym=et()),ym}const E2="tldraw-user-preferences-change";function _4(){Wa==null||Wa.postMessage({type:E2,origin:I2(),data:{user:_2(),version:nx}})}function _2(){let e=cu.get();return e||(e=P4(),cu.set(e)),e}function k2(e={}){return{derivePresenceState:e.derivePresenceState??(()=>V("presence",()=>null)),userPreferences:e.userPreferences??V("userPreferences",()=>_2()),setUserPreferences:e.setUserPreferences??I4}}var T2={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function o(c,l,u){this.fn=c,this.context=l,this.once=u||!1}function s(c,l,u,d,p){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new o(u,d||c,p),y=n?n+l:l;return c._events[y]?c._events[y].fn?c._events[y]=[c._events[y],f]:c._events[y].push(f):(c._events[y]=f,c._eventsCount++),c}function i(c,l){--c._eventsCount===0?c._events=new r:delete c._events[l]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],u,d;if(this._eventsCount===0)return l;for(d in u=this._events)t.call(u,d)&&l.push(n?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},a.prototype.listeners=function(l){var u=n?n+l:l,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var p=0,f=d.length,y=new Array(f);p<f;p++)y[p]=d[p].fn;return y},a.prototype.listenerCount=function(l){var u=n?n+l:l,d=this._events[u];return d?d.fn?1:d.length:0},a.prototype.emit=function(l,u,d,p,f,y){var g=n?n+l:l;if(!this._events[g])return!1;var w=this._events[g],S=arguments.length,v,b;if(w.fn){switch(w.once&&this.removeListener(l,w.fn,void 0,!0),S){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,u),!0;case 3:return w.fn.call(w.context,u,d),!0;case 4:return w.fn.call(w.context,u,d,p),!0;case 5:return w.fn.call(w.context,u,d,p,f),!0;case 6:return w.fn.call(w.context,u,d,p,f,y),!0}for(b=1,v=new Array(S-1);b<S;b++)v[b-1]=arguments[b];w.fn.apply(w.context,v)}else{var E=w.length,C;for(b=0;b<E;b++)switch(w[b].once&&this.removeListener(l,w[b].fn,void 0,!0),S){case 1:w[b].fn.call(w[b].context);break;case 2:w[b].fn.call(w[b].context,u);break;case 3:w[b].fn.call(w[b].context,u,d);break;case 4:w[b].fn.call(w[b].context,u,d,p);break;default:if(!v)for(C=1,v=new Array(S-1);C<S;C++)v[C-1]=arguments[C];w[b].fn.apply(w[b].context,v)}}return!0},a.prototype.on=function(l,u,d){return s(this,l,u,d,!1)},a.prototype.once=function(l,u,d){return s(this,l,u,d,!0)},a.prototype.removeListener=function(l,u,d,p){var f=n?n+l:l;if(!this._events[f])return this;if(!u)return i(this,f),this;var y=this._events[f];if(y.fn)y.fn===u&&(!p||y.once)&&(!d||y.context===d)&&i(this,f);else{for(var g=0,w=[],S=y.length;g<S;g++)(y[g].fn!==u||p&&!y[g].once||d&&y[g].context!==d)&&w.push(y[g]);w.length?this._events[f]=w.length===1?w[0]:w:i(this,f)}return this},a.prototype.removeAllListeners=function(l){var u;return l?(u=n?n+l:l,this._events[u]&&i(this,u)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a})(T2);var k4=T2.exports;function zs({children:e,className:t="",...n}){return h.jsx("svg",{...n,className:ue("tl-svg-container",t),children:e})}function rx(e,t,n,r){const o=e.x-n.x,s=e.y-n.y,i=r.x-n.x,a=r.y-n.y,c=t.x-e.x,l=t.y-e.y,u=i*s-a*o,d=c*s-l*o,p=a*c-i*l;if(u===0||d===0||p===0)return null;if(p!==0){const f=u/p,y=d/p;if(0<=f&&f<=1&&0<=y&&y<=1)return P.AddXY(e,f*c,f*l)}return null}function Nf(e,t,n,r){const o=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y),s=2*((t.x-e.x)*(e.x-n.x)+(t.y-e.y)*(e.y-n.y)),i=n.x*n.x+n.y*n.y+e.x*e.x+e.y*e.y-2*(n.x*e.x+n.y*e.y)-r*r,a=s*s-4*o*i;if(a<0||a===0)return null;const c=Math.sqrt(a),l=(-s+c)/(2*o),u=(-s-c)/(2*o);if((l<0||l>1)&&(u<0||u>1))return null;const d=[];return 0<=l&&l<=1&&d.push(P.Lrp(e,t,l)),0<=u&&u<=1&&d.push(P.Lrp(e,t,u)),d.length===0?null:d}function T4(e,t,n){const r=[];let o;for(let s=0,i=n.length-1;s<i;s++)o=rx(e,t,n[s],n[s+1]),o&&r.push(o);return r.length===0?null:r}function ox(e,t,n){const r=[];let o;for(let s=1,i=n.length;s<i+1;s++)o=rx(e,t,n[s-1],n[s%n.length]),o&&r.push(o);return r.length===0?null:r}function $4(e,t,n,r){let o=n.x-e.x,s=n.y-e.y;const i=Math.sqrt(o*o+s*s),a=(i*i-r*r+t*t)/(2*i),c=Math.sqrt(t*t-a*a);return o/=i,s/=i,[new P(e.x+o*a-s*c,e.y+s*a+o*c),new P(e.x+o*a+s*c,e.y+s*a-o*c)]}function WS(e,t,n){const r=[];let o,s,i;for(let a=0,c=n.length;a<c;a++)o=n[a],s=n[(a+1)%n.length],i=Nf(o,s,e,t),i&&r.push(...i);return r.length===0?null:r}function K1(e,t,n){const r=[];let o,s,i;for(let a=1,c=n.length;a<c;a++)o=n[a-1],s=n[a],i=Nf(o,s,e,t),i&&r.push(...i);return r.length===0?null:r}function Id(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function sx(e,t,n,r){return Id(e,n,r)!==Id(t,n,r)&&Id(e,t,n)!==Id(e,t,r)}function W1(e,t){const n=new Map;let r,o,s,i;for(let a=0,c=e.length;a<c;a++)if(r=e[a],Zn(r,t)){const l=Sm(r);n.has(l)||n.set(l,r)}for(let a=0,c=t.length;a<c;a++)if(r=t[a],Zn(r,e)){const l=Sm(r);n.has(l)||n.set(l,r)}for(let a=0,c=e.length;a<c;a++){r=e[a],o=e[(a+1)%e.length];for(let l=0,u=t.length;l<u;l++){s=t[l],i=t[(l+1)%t.length];const d=rx(r,o,s,i);if(d!==null){const p=Sm(d);n.has(p)||n.set(p,d)}}}return n.size===0?null:M4([...n.values()])}function Sm(e){return`${e.x},${e.y}`}function M4(e){const t=P.Average(e);return e.sort((n,r)=>P.Angle(t,n)-P.Angle(t,r))}function $2(e,t){let n,r,o,s;for(let i=0,a=e.length;i<a;i++){n=e[i],r=e[(i+1)%a];for(let c=0,l=t.length;c<l;c++)if(o=t[c],s=t[(c+1)%l],sx(n,r,o,s))return!0}return!1}function A4(e,t){let n,r,o,s;for(let i=0,a=e.length;i<a;i++){n=e[i],r=e[(i+1)%a];for(let c=1,l=t.length;c<l;c++)if(o=t[c-1],s=t[c],sx(n,r,o,s))return!0}return!1}class lu extends Hi{constructor(n){super({...n,isClosed:!1,isFilled:!1});m(this,"start");m(this,"end");m(this,"d");m(this,"u");m(this,"ul");m(this,"_length");const{start:r,end:o}=n;this.start=r,this.end=o,this.d=r.clone().sub(o),this.u=this.d.clone().uni(),this.ul=this.u.len()}get length(){return this._length?this._length:this.d.len()}midPoint(){return this.start.lrp(this.end,.5)}getVertices(){return[this.start,this.end]}nearestPoint(n){const{start:r,end:o,u:s,ul:i}=this;if(i===0)return r;const a=P.Sub(n,r).dpr(s)/i,c=r.x+s.x*a;if(c<Math.min(r.x,o.x))return r.x<o.x?r:o;if(c>Math.max(r.x,o.x))return r.x>o.x?r:o;const l=r.y+s.y*a;return l<Math.min(r.y,o.y)?r.y<o.y?r:o:l>Math.max(r.y,o.y)?r.y>o.y?r:o:new P(c,l)}hitTestLineSegment(n,r,o=0){return sx(n,r,this.start,this.end)||this.distanceToLineSegment(n,r)<=o}}class Ki extends Hi{constructor(n){super({isClosed:!1,isFilled:!1,...n});m(this,"points");m(this,"_segments");m(this,"_length");const{points:r}=n;this.points=r}get segments(){if(!this._segments){this._segments=[];const{vertices:n}=this;for(let r=0,o=n.length-1;r<o;r++){const s=n[r],i=n[r+1];this._segments.push(new lu({start:s,end:i}))}this.isClosed&&this._segments.push(new lu({start:n[n.length-1],end:n[0]}))}return this._segments}get length(){return this._length||(this._length=this.segments.reduce((n,r)=>n+r.length,0)),this._length}getVertices(){return this.points}nearestPoint(n){const{segments:r}=this;let o=this.points[0],s=1/0,i,a;for(let c=0;c<r.length;c++)i=r[c].nearestPoint(n),a=P.Dist2(i,n),a<s&&(o=i,s=a);if(!o)throw Error("nearest point not found");return o}hitTestLineSegment(n,r,o=0){const{segments:s}=this;for(let i=0,a=s.length;i<a;i++)if(s[i].hitTestLineSegment(n,r,o))return!0;return!1}}class wt extends Ki{constructor(t){super({...t}),this.isClosed=!0}}class Wo extends wt{constructor(n){const{x:r=0,y:o=0,width:s,height:i}=n;super({...n,points:[new P(r,o),new P(r+s,o),new P(r+s,o+i),new P(r,o+i)]});m(this,"x");m(this,"y");m(this,"w");m(this,"h");this.x=r,this.y=o,this.w=s,this.h=i}getBounds(){return new ne(this.x,this.y,this.w,this.h)}}class Fr{constructor(t){m(this,"canSnap",()=>!0);m(this,"canScroll",()=>!1);m(this,"canBind",(t,n)=>!0);m(this,"canEdit",()=>!1);m(this,"canResize",()=>!0);m(this,"canEditInReadOnly",()=>!1);m(this,"canCrop",()=>!1);m(this,"hideResizeHandles",()=>!1);m(this,"hideRotateHandle",()=>!1);m(this,"hideSelectionBoundsBg",()=>!1);m(this,"hideSelectionBoundsFg",()=>!1);m(this,"isAspectRatioLocked",()=>!1);m(this,"onBeforeCreate");m(this,"onBeforeUpdate");m(this,"onDragShapesOver");m(this,"onDragShapesOut");m(this,"onDropShapesOver");m(this,"onResizeStart");m(this,"onResize");m(this,"onResizeEnd");m(this,"onTranslateStart");m(this,"onTranslate");m(this,"onTranslateEnd");m(this,"onHandleDrag");m(this,"onRotateStart");m(this,"onRotate");m(this,"onRotateEnd");m(this,"onBindingChange");m(this,"onChildrenChange");m(this,"onDoubleClickHandle");m(this,"onDoubleClickEdge");m(this,"onDoubleClick");m(this,"onClick");m(this,"onEditEnd");this.editor=t}providesBackgroundForChildren(t){return!1}canReceiveNewChildrenOfType(t,n){return!1}canDropShapes(t,n){return!1}expandSelectionOutlinePx(t){return 0}getCanvasSvgDefs(){return[]}getBoundsSnapGeometry(t){return{}}getHandleSnapGeometry(t){return{}}}m(Fr,"props"),m(Fr,"migrations"),m(Fr,"type");function j4(e,t,n={}){const{closed:r=!1,snap:o=1,start:s="outset",end:i="outset",lengthRatio:a=2,style:c="dashed"}=n;let l=0,u=0,d=1,p=0,f=0;switch(c){case"dashed":{d=1,l=Math.min(t*a,e/4);break}case"dotted":{d=100,l=t/d;break}default:return{strokeDasharray:"none",strokeDashoffset:"none"}}return r||(s==="outset"?(e+=l/2,f+=l/2):s==="skip"&&(e-=l,f-=l),i==="outset"?e+=l/2:i==="skip"&&(e-=l)),u=Math.floor(e/l/(2*d)),u-=u%o,u<3&&c==="dashed"?e/t<5?(l=e,u=1,p=0):(l=e*.333,p=e*.333):(u=Math.max(u,3),l=e/u/(2*d),r?(f=l/2,p=(e-u*l)/u):p=(e-u*l)/Math.max(1,u-1)),{strokeDasharray:[l,p].join(" "),strokeDashoffset:f.toString()}}function V1({bounds:e,className:t}){const n=z(),r=K("zoom level",()=>n.getZoomLevel(),[n]);return h.jsx("g",{className:t,pointerEvents:"none",strokeLinecap:"round",strokeLinejoin:"round",children:e.sides.map((o,s)=>{const{strokeDasharray:i,strokeDashoffset:a}=j4(o[0].dist(o[1]),1/r,{style:"dashed",lengthRatio:4});return h.jsx("line",{x1:o[0].x,y1:o[0].y,x2:o[1].x,y2:o[1].y,strokeDasharray:i,strokeDashoffset:a},s)})})}class xh extends Fr{constructor(){super(...arguments);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"canBind",()=>!1);m(this,"onChildrenChange",n=>{const r=this.editor.getSortedChildIdsForParent(n.id);if(r.length===0){this.editor.getCurrentPageState().focusedGroupId===n.id&&this.editor.popFocusedGroupId(),this.editor.deleteShapes([n.id]);return}else if(r.length===1){this.editor.getCurrentPageState().focusedGroupId===n.id&&this.editor.popFocusedGroupId(),this.editor.reparentShapes(r,n.parentId),this.editor.deleteShapes([n.id]);return}})}getDefaultProps(){return{}}getGeometry(n){const r=this.editor.getSortedChildIdsForParent(n.id);return r.length===0?new Wo({width:1,height:1,isFilled:!1}):new Br({children:r.map(o=>{const s=this.editor.getShape(o),i=this.editor.getShapeGeometry(o),a=this.editor.getShapeLocalTransform(s).applyToPoints(i.vertices);return i.isClosed?new wt({points:a,isFilled:!0}):new Ki({points:a})})})}component(n){const r=this.editor.getErasingShapeIds().includes(n.id),{hintingShapeIds:o}=this.editor.getCurrentPageState(),s=o.length>0&&o.some(c=>c!==n.id&&this.editor.isShapeOfType(this.editor.getShape(c),"group")),i=this.editor.getCurrentPageState().focusedGroupId!==n.id;if(!r&&(i||s))return null;const a=this.editor.getShapeGeometry(n).bounds;return h.jsx(zs,{id:n.id,children:h.jsx(V1,{className:"tl-group",bounds:a})})}indicator(n){const r=this.editor.getShapeGeometry(n).bounds;return h.jsx(V1,{className:"",bounds:r})}}m(xh,"type","group"),m(xh,"props",kk),m(xh,"migrations",Tk);const M2=[xh],O4=new Set(M2.map(e=>e.type));function A2(e){const t=[...M2],n=new Set;for(const r of e){if(O4.has(r.type))throw new Error(`Shape type "${r.type}" is a core shapes type and cannot be overridden`);if(n.has(r.type))throw new Error(`Shape type "${r.type}" is defined more than once`);t.push(r),n.add(r.type)}return t}function G1(e,t){if(!t)return!1;switch(e.type){case"mixed":return t.type==="mixed";case"shared":return t.type==="shared"&&e.value===t.value;default:throw qo(e)}}class D4{constructor(t){m(this,"map");this.map=new Map(t)}get(t){return this.map.get(t)}getAsKnownValue(t){const n=this.get(t);if(n&&n.type!=="mixed")return n.value}get size(){return this.map.size}equals(t){if(this.size!==t.size)return!1;const n=new Set;for(const[r,o]of this){if(!G1(o,t.get(r)))return!1;n.add(r)}for(const[r,o]of t)if(!n.has(r)&&!G1(o,this.get(r)))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 VS extends D4{set(t,n){this.map.set(t,n)}applyValue(t,n){const r=this.get(t);if(!r){this.set(t,{type:"shared",value:n});return}switch(r.type){case"mixed":return;case"shared":r.value!==n&&this.set(t,{type:"mixed"});return;default:qo(r,"type")}}}class zf{constructor(){m(this,"items",new WeakMap)}get(t,n){return this.items.has(t)||this.items.set(t,n(t)),this.items.get(t)}access(t){return this.items.get(t)}set(t,n){this.items.set(t,n)}has(t){return this.items.has(t)}invalidate(t){this.items.delete(t)}bust(){this.items=new WeakMap}}function R4(e,t,n){return fetch(e).then(function(r){return r.arrayBuffer()}).then(function(r){return new File([r],t,{type:n})})}function L4(e,t){var o;let n=e;const r=new Set(t);for(;r.has(n);)n=(o=/^.*(\d+)$/.exec(n))!=null&&o[1]?n.replace(/(\d+)(?=\D?)$/,s=>(+s+1).toString()):`${n} 1`;return n}function Ed(e,t,n){if(n.length===0)return[];const r=new Map;for(const s of fe(n.map(i=>e.getShape(i)))){const{parentId:i}=s;r.has(i)||r.set(i,{children:fe(e.getSortedChildIdsForParent(i).map(a=>e.getShape(a))),moving:new Set}),r.get(i).moving.add(s)}const o=[];switch(t){case"toBack":{r.forEach(({moving:s,children:i})=>F4(s,i,o));break}case"toFront":{r.forEach(({moving:s,children:i})=>N4(s,i,o));break}case"forward":{r.forEach(({moving:s,children:i})=>z4(s,i,o));break}case"backward":{r.forEach(({moving:s,children:i})=>B4(s,i,o));break}}return o}function F4(e,t,n){const r=t.length;if(e.size===r)return;let o,s;for(let i=0;i<r;i++){const a=t[i];if(e.has(a))o=a.index,e.delete(a);else{s=a.index;break}}if(e.size!==0){const i=oc(o,s,e.size);n.push(...Array.from(e.values()).sort(en).map((a,c)=>({...a,index:i[c]})))}}function N4(e,t,n){const r=t.length;if(e.size===r)return;let o,s;for(let i=r-1;i>-1;i--){const a=t[i];if(e.has(a))s=a.index,e.delete(a);else{o=a.index;break}}if(e.size!==0){const i=oc(o,s,e.size);n.push(...Array.from(e.values()).sort(en).map((a,c)=>({...a,index:i[c]})))}}function z4(e,t,n){var s;const r=t.length;if(e.size===r)return;let o={name:"skipping"};for(let i=0;i<r;i++){const a=e.has(t[i]);switch(o.name){case"skipping":{if(!a)continue;o={name:"selecting",selectIndex:i};break}case"selecting":{if(a)continue;const{selectIndex:c}=o;oc(t[i].index,(s=t[i+1])==null?void 0:s.index,i-c).forEach((l,u)=>n.push({...t[c+u],index:l})),o={name:"skipping"};break}}}}function B4(e,t,n){var s;const r=t.length;if(e.size===r)return;let o={name:"skipping"};for(let i=r-1;i>-1;i--){const a=e.has(t[i]);switch(o.name){case"skipping":{if(!a)continue;o={name:"selecting",selectIndex:i};break}case"selecting":{if(a)continue;oc((s=t[i-1])==null?void 0:s.index,t[i].index,o.selectIndex-i).forEach((c,l)=>{n.push({...t[i+l+1],index:c})}),o={name:"skipping"};break}}}}function j2({editor:e}){const t=e.getSelectedShapes(),n=e.getSelectionRotation(),r=e.getSelectionRotatedPageBounds(),{inputs:{originPagePoint:o}}=e;if(!r)return null;const s=r.center.clone().rotWith(r.point,n);return{selectionPageCenter:s,initialCursorAngle:s.angle(o),initialSelectionRotation:n,shapeSnapshots:t.map(i=>({shape:Ye(i),initialPagePoint:e.getShapePageTransform(i.id).point()}))}}function wh({delta:e,editor:t,snapshot:n,stage:r}){const{selectionPageCenter:o,shapeSnapshots:s}=n;t.updateShapes(s.map(({shape:a,initialPagePoint:c})=>{const l=Kn(a.parentId)?t.getShapePageTransform(a.parentId):oe.Identity(),u=P.RotWith(c,o,e),d=oe.applyToPoint(oe.Inverse(l),u),p=Os(a.rotation+e);return{id:a.id,type:a.type,x:d.x,y:d.y,rotation:p}}));const i=[];s.forEach(({shape:a})=>{var d,p,f;const c=t.getShape(a.id);if(!c)return;const l=t.getShapeUtil(a);if(r==="start"||r==="one-off"){const y=(d=l.onRotateStart)==null?void 0:d.call(l,a);y&&i.push(y)}const u=(p=l.onRotate)==null?void 0:p.call(l,a,c);if(u&&i.push(u),r==="end"||r==="one-off"){const y=(f=l.onRotateEnd)==null?void 0:f.call(l,a,c);y&&i.push(y)}}),i.length>0&&t.updateShapes(i)}const U4=e=>{const{store:t}=e,n=t.query.filterHistory("shape"),r=t.query.records("shape",()=>({type:{eq:"arrow"}}));function o(){const s=r.get(),i={};for(const a of s){const{start:c,end:l}=a.props;if(c.type==="binding"){const u=i[c.boundShapeId];u?u.push({arrowId:a.id,handleId:"start"}):i[c.boundShapeId]=[{arrowId:a.id,handleId:"start"}]}if(l.type==="binding"){const u=i[l.boundShapeId];u?u.push({arrowId:a.id,handleId:"end"}):i[l.boundShapeId]=[{arrowId:a.id,handleId:"end"}]}}return i}return V("arrowBindingsIndex",(s,i)=>{if(Pi(s))return o();const a=s,c=n.getDiffSince(i);if(c===qn)return o();let l;function u(f){l||(l={...a}),l[f]?l[f]===a[f]&&(l[f]=[...l[f]]):l[f]=[]}function d(f,y,g){u(f),l[f]=l[f].filter(w=>w.arrowId!==y||w.handleId!==g),l[f].length===0&&delete l[f]}function p(f,y,g){u(f),l[f].push({arrowId:y,handleId:g})}for(const f of c){for(const y of Object.values(f.added))if(e.isShapeOfType(y,"arrow")){const{start:g,end:w}=y.props;g.type==="binding"&&p(g.boundShapeId,y.id,"start"),w.type==="binding"&&p(w.boundShapeId,y.id,"end")}for(const[y,g]of Object.values(f.updated))if(!(!e.isShapeOfType(y,"arrow")||!e.isShapeOfType(g,"arrow")))for(const w of["start","end"]){const S=y.props[w],v=g.props[w];S.type==="binding"&&v.type==="point"?d(S.boundShapeId,y.id,w):S.type==="point"&&v.type==="binding"?p(v.boundShapeId,g.id,w):S.type==="binding"&&v.type==="binding"&&S.boundShapeId!==v.boundShapeId&&(d(S.boundShapeId,y.id,w),p(v.boundShapeId,g.id,w))}for(const y of Object.values(f.removed))if(e.isShapeOfType(y,"arrow")){const{start:g,end:w}=y.props;g.type==="binding"&&d(g.boundShapeId,y.id,"start"),w.type==="binding"&&d(w.boundShapeId,y.id,"end")}}return l??a})};function H4(e,t,n){const r=e.getShapeMaskedPageBounds(t);return r===void 0?!0:!n.includes(r)}const K4=e=>{const t=Number.isFinite(e.renderingBoundsMargin);function n(r){const o=r.getCurrentPageShapeIds(),s=r.getViewportPageBounds(),i=new Set;return o.forEach(a=>{H4(r,a,s)&&i.add(a)}),i}return V("getCulledShapes",r=>{if(!t)return new Set;if(Pi(r))return n(e);const o=n(e);if(r.size!==o.size)return o;for(const s of r)if(!o.has(s))return o;return r})},W4=e=>{const t=e.query.ids("shape"),n=e.query.filterHistory("shape");function r(){const o={},s=t.get(),i=Array(s.size);return s.forEach(a=>i.push(e.get(a))),i.sort(en),i.forEach(a=>{o[a.parentId]||(o[a.parentId]=[]),o[a.parentId].push(a.id)}),o}return V("parentsToChildrenWithIndexes",(o,s)=>{if(Pi(o))return r();const i=n.getDiffSince(s);if(i===qn)return r();if(i.length===0)return o;let a=null;const c=d=>{a||(a={...o}),a[d]?a[d]===o[d]&&(a[d]=[...a[d]]):a[d]=[]},l=new Set;let u;for(let d=0,p=i.length;d<p;d++){u=i[d];for(const f of Object.values(u.added))$a(f)&&(c(f.parentId),a[f.parentId].push(f.id),l.add(a[f.parentId]));for(const[f,y]of Object.values(u.updated))if($a(y)&&$a(f)){if(f.parentId!==y.parentId)c(f.parentId),c(y.parentId),a[f.parentId].splice(a[f.parentId].indexOf(y.id),1),a[y.parentId].push(y.id),l.add(a[y.parentId]);else if(f.index!==y.index){c(y.parentId);const g=a[y.parentId].indexOf(y.id);a[y.parentId][g]=y.id,l.add(a[y.parentId])}}for(const f of Object.values(u.removed))$a(f)&&(c(f.parentId),a[f.parentId].splice(a[f.parentId].indexOf(f.id),1))}for(const d of l){const p=fe(d.map(f=>e.get(f)));p.sort(en),d.splice(0,d.length,...p.map(f=>f.id))}return a??o})},vm=(e,t,n)=>{for(;!bn(n.parentId);){const r=e.get(n.parentId);if(!r)return!1;n=r}return n.parentId===t},V4=(e,t)=>{const n=e.query.ids("shape");let r=null;function o(){const s=t();return r=s,new Set([...n.get()].filter(i=>vm(e,s,e.get(i))))}return V("_shapeIdsInCurrentPage",(s,i)=>{if(Pi(s))return o();const a=t();if(a!==r)return o();const c=e.history.getDiffSince(i);if(c===qn)return o();const l=new fh(s);for(const d of c){for(const p of Object.values(d.added))$a(p)&&vm(e,a,p)&&l.add(p.id);for(const[p,f]of Object.values(d.updated))$a(f)&&(vm(e,a,f)?l.add(f.id):l.remove(f.id));for(const p of Object.keys(d.removed))Kn(p)&&l.remove(p)}const u=l.get();return u?fl(u.value,u.diff):s})},O2=x.createContext(null);function G4({context:e,editor:t,children:n}){return h.jsx(Rf.Provider,{value:t,children:h.jsx(O2.Provider,{value:e,children:n})})}function D2(){const e=x.useContext(O2);return e?{isDarkMode:e.isDarkMode}:null}async function Y4(e,t,n={}){var C,I;const r=typeof t[0]=="string"?t:t.map(_=>_.id);if(r.length===0)return;if(!window.document)throw Error("No document");const{scale:o=1,background:s=!1,padding:i=A5,preserveAspectRatio:a=!1}=n,c=n.darkMode??e.user.getIsDarkMode(),l=Jo({isDarkMode:c}),u=e.getShapeAndDescendantIds(r),d=e.getUnorderedRenderingShapes(!1).filter(({id:_})=>u.has(_));let p=null;if(n.bounds)p=n.bounds;else for(const{id:_}of d){const k=e.getShapeMaskedPageBounds(_);k&&(p?p.union(k):p=k.clone())}if(!p)return;const f=r.length===1&&e.isShapeOfType(e.getShape(r[0]),"frame")?r[0]:null;f||p.expandBy(i);const y=p.width*o,g=p.height*o;try{(I=(C=document.body).focus)==null||I.call(C)}catch{}const w=[],S=new Map,v={isDarkMode:c,addExportDef:_=>{if(S.has(_.key))return;const k=(async()=>{const $=await _.getElement();$&&w.push(h.jsx(x.Fragment,{children:$},w.length))})();S.set(_.key,k)}},b=(await Promise.all(d.map(async({id:_,opacity:k,index:$,backgroundIndex:T})=>{var H,U;if(_===f)return[];const O=e.getShape(_);if(e.isShapeOfType(O,"group"))return[];const N=e.getShapeUtil(O);let F=await((H=N.toSvg)==null?void 0:H.call(N,O,v)),L=await((U=N.toBackgroundSvg)==null?void 0:U.call(N,O,v));if(!F&&!L){const W=e.getShapePageBounds(O);F=h.jsx("rect",{width:W.w,height:W.h,fill:l.solid,stroke:l.grey.pattern,strokeWidth:1})}let B=e.getShapePageTransform(O).toCssString();"scale"in O.props&&O.props.scale!==1&&(B=`${B} scale(${O.props.scale}, ${O.props.scale})`),F&&(F=h.jsx("g",{transform:B,opacity:k,children:F},O.id)),L&&(L=h.jsx("g",{transform:B,opacity:k,children:L},`bg_${O.id}`));const q=e.getShapeMask(O.id);if(q){const W=`mask_${O.id.replace(":","_")}`;w.push(h.jsx("clipPath",{id:W,children:h.jsx("path",{d:`M${q.map(({x:Z,y:le})=>`${Z},${le}`).join("L")}Z`})},w.length)),F&&(F=h.jsx("g",{clipPath:`url(#${W})`,children:F},O.id)),L&&(L=h.jsx("g",{clipPath:`url(#${W})`,children:L},`bg_${O.id}`))}const Q=[];return F&&Q.push({zIndex:$,element:F}),L&&Q.push({zIndex:T,element:L}),Q}))).flat();return await Promise.all(S.values()),{jsx:h.jsx(G4,{editor:e,context:v,children:h.jsxs("svg",{preserveAspectRatio:a||void 0,direction:"ltr",width:y,height:g,viewBox:`${p.minX} ${p.minY} ${p.width} ${p.height}`,strokeLinecap:"round",strokeLinejoin:"round",style:{backgroundColor:s?f?l.solid:l.background:"transparent"},children:[h.jsx("defs",{children:w}),b.sort((_,k)=>_.zIndex-k.zIndex).map(({element:_})=>_)]})}),width:y,height:g}}const X4=40;class q4{constructor(t){m(this,"_clickId","");m(this,"_clickTimeout");m(this,"_clickScreenPoint");m(this,"_previousScreenPoint");m(this,"_getClickTimeout",(t,n=et())=>{this._clickId=n,clearTimeout(this._clickTimeout),this._clickTimeout=setTimeout(()=>{if(this._clickState===t&&this._clickId===n){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"}},t==="idle"||t==="pendingDouble"?$5:M5)});m(this,"_clickState","idle");m(this,"lastPointerInfo",{});m(this,"transformPointerDownEvent",t=>{if(!this._clickState)return t;switch(this._clickScreenPoint=P.From(t.point),this._previousScreenPoint&&this._previousScreenPoint.dist(this._clickScreenPoint)>X4&&(this._clickState="idle"),this._previousScreenPoint=this._clickScreenPoint,this.lastPointerInfo=t,this._clickState){case"idle":return this._clickState="pendingDouble",this._clickTimeout=this._getClickTimeout(this._clickState),t;case"pendingDouble":return this._clickState="pendingTriple",this._clickTimeout=this._getClickTimeout(this._clickState),{...t,type:"click",name:"double_click",phase:"down"};case"pendingTriple":return this._clickState="pendingQuadruple",this._clickTimeout=this._getClickTimeout(this._clickState),{...t,type:"click",name:"triple_click",phase:"down"};case"pendingQuadruple":return this._clickState="pendingOverflow",this._clickTimeout=this._getClickTimeout(this._clickState),{...t,type:"click",name:"quadruple_click",phase:"down"};case"pendingOverflow":return this._clickState="overflow",this._clickTimeout=this._getClickTimeout(this._clickState),t;default:return this._clickTimeout=this._getClickTimeout(this._clickState),t}});m(this,"transformPointerUpEvent",t=>{if(!this._clickState)return t;switch(this._clickScreenPoint=P.From(t.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"};default:return t}});m(this,"cancelDoubleClickTimeout",()=>{this._clickTimeout=clearTimeout(this._clickTimeout),this._clickState="idle"});m(this,"handleMove",()=>{this._clickState!=="idle"&&this._clickScreenPoint&&P.Dist2(this._clickScreenPoint,this.editor.inputs.currentScreenPoint)>(this.editor.getInstanceState().isCoarsePointer?BS:iu)&&this.cancelDoubleClickTimeout()});this.editor=t}get clickState(){return this._clickState}}class Z4{constructor(t){m(this,"isSafari");m(this,"isIos");m(this,"isChromeForIos");m(this,"isFirefox");m(this,"isAndroid");this.editor=t,typeof window<"u"&&"navigator"in window?(this.isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),this.isIos=!!navigator.userAgent.match(/iPad/i)||!!navigator.userAgent.match(/iPhone/i),this.isChromeForIos=/crios.*safari/i.test(navigator.userAgent),this.isFirefox=/firefox/i.test(navigator.userAgent),this.isAndroid=/android/i.test(navigator.userAgent)):(this.isSafari=!1,this.isIos=!1,this.isChromeForIos=!1,this.isFirefox=!1,this.isAndroid=!1)}}function ci(e){return J4}class Q4{constructor(){m(this,"length",0);m(this,"head",null);m(this,"tail",this)}push(t){return new ix(t,this)}toArray(){return Do}[Symbol.iterator](){return{next(){return{value:void 0,done:!0}}}}}const J4=new Q4;class ix{constructor(t,n){m(this,"length");this.head=t,this.tail=n,this.length=n.length+1}push(t){return new ix(t,this)}toArray(){return Array.from(this)}[Symbol.iterator](){let t=this;return{next(){if(t.length){const n=t.head;return t=t.tail,{value:n,done:!1}}else return{value:void 0,done:!0}}}}}class ez{constructor(t,n){m(this,"_undos",fn("HistoryManager.undos",ci()));m(this,"_redos",fn("HistoryManager.redos",ci()));m(this,"_batchDepth",0);m(this,"onBatchComplete",()=>{});m(this,"_commands",{});m(this,"createCommand",(t,n,r)=>{if(this._commands[t])throw new Error(`Duplicate command: ${t}`);this._commands[t]=r;const o=(...s)=>{if(!this._batchDepth)return this.batch(()=>o(...s)),this.ctx;const i=n(...s);if(!i)return this.ctx;const{data:a,ephemeral:c,squashing:l,preservesRedoStack:u}=i;if(this.ignoringUpdates((d,p)=>(r.do(a),{undos:d,redos:p})),!c){const d=this._undos.get().head;l&&d&&d.type==="command"&&d.name===t&&d.preservesRedoStack===u?this._undos.update(p=>p.tail.push({...d,data:r.squash(d.data,a)})):this._undos.update(p=>p.push({type:"command",name:t,data:a,preservesRedoStack:u})),i.preservesRedoStack||this._redos.set(ci()),this.ctx.emit("change-history",{reason:"push"})}return this.ctx};return o});m(this,"batch",t=>{try{this._batchDepth++,this._batchDepth===1?Mr(()=>{const n=this._undos.get().head;t(),n!==this._undos.get().head&&this.onBatchComplete()}):t()}catch(n){throw this.annotateError(n),n}finally{this._batchDepth--}return this});m(this,"ignoringUpdates",t=>{let n=this._undos.get(),r=this._redos.get();this._undos.set(ci()),this._redos.set(ci());try{({undos:n,redos:r}=Mr(()=>t(n,r)))}finally{this._undos.set(n),this._redos.set(r)}});m(this,"_undo",({pushToRedoStack:t,toMark:n=void 0})=>(this.ignoringUpdates((r,o)=>{var s;if(r.length===0)return{undos:r,redos:o};for(;((s=r.head)==null?void 0:s.type)==="STOP";){const i=r.head;if(r=r.tail,t&&(o=o.push(i)),i.id===n)return this.ctx.emit("change-history",t?{reason:"undo"}:{reason:"bail",markId:n}),{undos:r,redos:o}}if(r.length===0)return this.ctx.emit("change-history",t?{reason:"undo"}:{reason:"bail",markId:n}),{undos:r,redos:o};for(;r.head;){const i=r.head;if(r=r.tail,t&&(o=o.push(i)),i.type==="STOP"){if(i.onUndo&&(!n||i.id===n))return this.ctx.emit("change-history",t?{reason:"undo"}:{reason:"bail",markId:n}),{undos:r,redos:o}}else this._commands[i.name].undo(i.data)}return this.ctx.emit("change-history",t?{reason:"undo"}:{reason:"bail",markId:n}),{undos:r,redos:o}}),this));m(this,"undo",()=>(this._undo({pushToRedoStack:!0}),this));m(this,"redo",()=>(this.ignoringUpdates((t,n)=>{var r;if(n.length===0)return{undos:t,redos:n};for(;((r=n.head)==null?void 0:r.type)==="STOP";)t=t.push(n.head),n=n.tail;if(n.length===0)return this.ctx.emit("change-history",{reason:"redo"}),{undos:t,redos:n};for(;n.head;){const o=n.head;if(t=t.push(n.head),n=n.tail,o.type==="STOP"){if(o.onRedo)break}else{const s=this._commands[o.name];s.redo?s.redo(o.data):s.do(o.data)}}return this.ctx.emit("change-history",{reason:"redo"}),{undos:t,redos:n}}),this));m(this,"bail",()=>(this._undo({pushToRedoStack:!1}),this));m(this,"bailToMark",t=>(this._undo({pushToRedoStack:!1,toMark:t}),this));m(this,"mark",(t=et(),n=!0,r=!0)=>{const o=this._undos.get().head;return o&&o.type==="STOP"&&o.id===t&&o.onUndo===n&&o.onRedo===r?o.id:(this._undos.update(s=>s.push({type:"STOP",id:t,onUndo:n,onRedo:r})),this.ctx.emit("mark-history",{id:t}),t)});this.ctx=t,this.annotateError=n}getNumUndos(){return this._undos.get().length}getNumRedos(){return this._redos.get().length}clear(){this._undos.set(ci()),this._redos.set(ci())}}class tz{constructor(t){m(this,"scribbleItems",new Map);m(this,"state","paused");m(this,"addScribble",(t,n=et())=>{const r={id:n,scribble:{id:n,size:20,color:"accent",opacity:.8,delay:0,points:[],shrink:.1,taper:!0,...t,state:"starting"},timeoutMs:0,delayRemaining:t.delay??0,prev:null,next:null};return this.scribbleItems.set(n,r),r});m(this,"stop",t=>{const n=this.scribbleItems.get(t);if(!n)throw Error(`Scribble with id ${t} not found`);return n.delayRemaining=Math.min(n.delayRemaining,200),n.scribble.state="stopping",n});m(this,"addPoint",(t,n,r)=>{const o=this.scribbleItems.get(t);if(!o)throw Error(`Scribble with id ${t} not found`);const{prev:s}=o,i={x:n,y:r,z:.5};return(!s||P.Dist(s,i)>=1)&&(o.next=i),o});m(this,"tick",t=>{this.scribbleItems.size!==0&&this.editor.batch(()=>{this.scribbleItems.forEach(n=>{if(n.scribble.state==="starting"){const{next:c,prev:l}=n;c&&c!==l&&(n.prev=c,n.scribble.points.push(c)),n.scribble.points.length>8&&(n.scribble.state="active");return}n.delayRemaining>0&&(n.delayRemaining=Math.max(0,n.delayRemaining-t)),n.timeoutMs+=t,n.timeoutMs>=16&&(n.timeoutMs=0);const{delayRemaining:r,timeoutMs:o,prev:s,next:i,scribble:a}=n;switch(a.state){case"active":{i&&i!==s?(n.prev=i,a.points.push(i),r===0&&a.points.length>8&&a.points.shift()):o===0&&(a.points.length>1?a.points.shift():n.delayRemaining=a.delay);break}case"stopping":{if(n.delayRemaining===0&&o===0){if(a.points.length===1){this.scribbleItems.delete(n.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:n})=>({...n,points:[...n.points]})).slice(-5)})})});this.editor=t}reset(){this.editor.updateInstanceState({scribbles:[]}),this.scribbleItems.clear()}}class nz{constructor(t){m(this,"_beforeCreateHandlers",{});m(this,"_afterCreateHandlers",{});m(this,"_beforeChangeHandlers",{});m(this,"_afterChangeHandlers",{});m(this,"_beforeDeleteHandlers",{});m(this,"_afterDeleteHandlers",{});m(this,"_batchCompleteHandlers",[]);this.editor=t,t.store.onBeforeCreate=(r,o)=>{const s=this._beforeCreateHandlers[r.typeName];if(s){let i=r;for(const a of s)i=a(i,o);return i}return r},t.store.onAfterCreate=(r,o)=>{const s=this._afterCreateHandlers[r.typeName];if(s)for(const i of s)i(r,o)},t.store.onBeforeChange=(r,o,s)=>{const i=this._beforeChangeHandlers[o.typeName];if(i){let a=o;for(const c of i)a=c(r,a,s);return a}return o};let n=0;t.store.onAfterChange=(r,o,s)=>{if(n++,n>1e3)console.error("[CleanupManager.onAfterChange] Maximum update depth exceeded, bailing out.");else{const i=this._afterChangeHandlers[o.typeName];if(i)for(const a of i)a(r,o,s)}n--},t.store.onBeforeDelete=(r,o)=>{const s=this._beforeDeleteHandlers[r.typeName];if(s){for(const i of s)if(i(r,o)===!1)return!1}},t.store.onAfterDelete=(r,o)=>{const s=this._afterDeleteHandlers[r.typeName];if(s)for(const i of s)i(r,o)},t.history.onBatchComplete=()=>{this._batchCompleteHandlers.forEach(r=>r())}}registerBeforeCreateHandler(t,n){return this._beforeCreateHandlers[t]||(this._beforeCreateHandlers[t]=[]),this._beforeCreateHandlers[t].push(n),()=>li(this._beforeCreateHandlers[t],n)}registerAfterCreateHandler(t,n){return this._afterCreateHandlers[t]||(this._afterCreateHandlers[t]=[]),this._afterCreateHandlers[t].push(n),()=>li(this._afterCreateHandlers[t],n)}registerBeforeChangeHandler(t,n){return this._beforeChangeHandlers[t]||(this._beforeChangeHandlers[t]=[]),this._beforeChangeHandlers[t].push(n),()=>li(this._beforeChangeHandlers[t],n)}registerAfterChangeHandler(t,n){return this._afterChangeHandlers[t]||(this._afterChangeHandlers[t]=[]),this._afterChangeHandlers[t].push(n),()=>li(this._afterChangeHandlers[t],n)}registerBeforeDeleteHandler(t,n){return this._beforeDeleteHandlers[t]||(this._beforeDeleteHandlers[t]=[]),this._beforeDeleteHandlers[t].push(n),()=>li(this._beforeDeleteHandlers[t],n)}registerAfterDeleteHandler(t,n){return this._afterDeleteHandlers[t]||(this._afterDeleteHandlers[t]=[]),this._afterDeleteHandlers[t].push(n),()=>li(this._afterDeleteHandlers[t],n)}registerBatchCompleteHandler(t){return this._batchCompleteHandlers.push(t),()=>li(this._batchCompleteHandlers,t)}}function li(e,t){const n=e.indexOf(t);n>=0&&e.splice(n,1)}var rz=Object.defineProperty,oz=Object.getOwnPropertyDescriptor,Bf=(e,t,n,r)=>{for(var o=oz(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&rz(t,n,o),o};const de=e=>Math.round(e*10**8)/10**8;function Eo(e,t,n,r,o){const s=e.filter(a=>(r==="forward"?a.startNode.id===t:a.endNode.id===t)&&de(a.length)===de(n)&&kr(a.breadthIntersection[0],a.breadthIntersection[1],o[0],o[1]));if(s.length===0)return[];const i=new Set;return s.forEach(a=>{const c=r==="forward"?a.endNode.id:a.startNode.id;if(!i.has(c)){i.add(c);const l=Eo(e,c,n,r,kr(a.breadthIntersection[0],a.breadthIntersection[1],o[0],o[1]));s.push(...l)}}),s}function sz(e){e.sort((t,n)=>n.gaps.length-t.gaps.length);for(let t=e.length-1;t>0;t--){const n=e[t];for(let r=t-1;r>=0;r--){const o=e[r];if(o.direction===n.direction&&n.gaps.every(s=>o.gaps.some(i=>de(s.startEdge[0].x)===de(i.startEdge[0].x)&&de(s.startEdge[0].y)===de(i.startEdge[0].y)&&de(s.startEdge[1].x)===de(i.startEdge[1].x)&&de(s.startEdge[1].y)===de(i.startEdge[1].y))&&o.gaps.some(i=>de(s.endEdge[0].x)===de(i.endEdge[0].x)&&de(s.endEdge[0].y)===de(i.endEdge[0].y)&&de(s.endEdge[1].x)===de(i.endEdge[1].x)&&de(s.endEdge[1].y)===de(i.endEdge[1].y)))){e.splice(t,1);break}}}}class Du{constructor(t){m(this,"editor");this.manager=t,this.editor=t.editor}getSnapPointsCache(){const{editor:t}=this;return t.store.createComputedCache("snapPoints",n=>{const r=t.getShapePageTransform(n.id);if(!r)return;const s=t.getShapeUtil(n).getBoundsSnapGeometry(n).points??t.getShapeGeometry(n).bounds.cornersAndCenter;if(!(!r||!s))return s.map((i,a)=>{const{x:c,y:l}=oe.applyToPoint(r,i);return{x:c,y:l,id:`${n.id}:${a}`}})})}getSnapPoints(t){return this.getSnapPointsCache().get(t)??[]}getSnappablePoints(){const t=this.getSnapPointsCache(),n=this.manager.getSnappableShapes(),r=[];for(const o of n){const s=t.get(o);s&&r.push(...s)}return r}getSnappableGapNodes(){return Array.from(this.manager.getSnappableShapes(),t=>({id:t,pageBounds:yi(this.editor.getShapePageBounds(t))}))}getVisibleGaps(){const t=[],n=[];let r,o;const s=this.getSnappableGapNodes().sort((a,c)=>a.pageBounds.minX-c.pageBounds.minX);for(let a=0;a<s.length;a++){r=s[a];for(let c=a+1;c<s.length;c++)o=s[c],r.pageBounds.maxX<o.pageBounds.minX&&Xc(r.pageBounds.minY,r.pageBounds.maxY,o.pageBounds.minY,o.pageBounds.maxY)&&t.push({startNode:r,endNode:o,startEdge:[new P(r.pageBounds.maxX,r.pageBounds.minY),new P(r.pageBounds.maxX,r.pageBounds.maxY)],endEdge:[new P(o.pageBounds.minX,o.pageBounds.minY),new P(o.pageBounds.minX,o.pageBounds.maxY)],length:o.pageBounds.minX-r.pageBounds.maxX,breadthIntersection:kr(r.pageBounds.minY,r.pageBounds.maxY,o.pageBounds.minY,o.pageBounds.maxY)})}const i=s.sort((a,c)=>a.pageBounds.minY-c.pageBounds.minY);for(let a=0;a<i.length;a++){r=i[a];for(let c=a+1;c<i.length;c++)o=i[c],r.pageBounds.maxY<o.pageBounds.minY&&Xc(r.pageBounds.minX,r.pageBounds.maxX,o.pageBounds.minX,o.pageBounds.maxX)&&n.push({startNode:r,endNode:o,startEdge:[new P(r.pageBounds.minX,r.pageBounds.maxY),new P(r.pageBounds.maxX,r.pageBounds.maxY)],endEdge:[new P(o.pageBounds.minX,o.pageBounds.minY),new P(o.pageBounds.maxX,o.pageBounds.minY)],length:o.pageBounds.minY-r.pageBounds.maxY,breadthIntersection:kr(r.pageBounds.minX,r.pageBounds.maxX,o.pageBounds.minX,o.pageBounds.maxX)})}return{horizontal:t,vertical:n}}snapTranslateShapes({lockedAxis:t,initialSelectionPageBounds:n,initialSelectionSnapPoints:r,dragDelta:o}){var w,S;const s=this.manager.getSnapThreshold(),i=this.getSnappablePoints(),a=n.clone().translate(o),c=r.map(({x:v,y:b},E)=>({id:"selection:"+E,x:v+o.x,y:b+o.y})),l=i,u=[],d=[],p=new P(s,s);this.collectPointSnaps({minOffset:p,nearestSnapsX:u,nearestSnapsY:d,otherNodeSnapPoints:l,selectionSnapPoints:c}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d,minOffset:p});const f=new P(t==="x"?0:((w=u[0])==null?void 0:w.nudge)??0,t==="y"?0:((S=d[0])==null?void 0:S.nudge)??0);p.x=0,p.y=0,u.length=0,d.length=0,c.forEach(v=>{v.x+=f.x,v.y+=f.y}),a.translate(f),this.collectPointSnaps({minOffset:p,nearestSnapsX:u,nearestSnapsY:d,otherNodeSnapPoints:l,selectionSnapPoints:c}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d,minOffset:p});const y=this.getPointSnapLines({nearestSnapsX:u,nearestSnapsY:d}),g=this.getGapSnapLines({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d});return this.manager.setIndicators([...g,...y]),{nudge:f}}snapResizeShapes({initialSelectionPageBounds:t,dragDelta:n,handle:r,isAspectRatioLocked:o,isResizingFromCenter:s}){var _,k;const i=this.manager.getSnapThreshold(),{box:a,scaleX:c,scaleY:l}=ne.Resize(t,r,s?n.x*2:n.x,s?n.y*2:n.y,o);let u=r;c<0&&(u=PF(u)),l<0&&(u=bF(u)),s&&(a.center=t.center);const d=u==="top"||u==="bottom",p=u==="left"||u==="right",f=Y1(u,a),y=this.getSnappablePoints(),g=[],w=[],S=new P(i,i);this.collectPointSnaps({minOffset:S,nearestSnapsX:g,nearestSnapsY:w,otherNodeSnapPoints:y,selectionSnapPoints:f});const v=new P(d?0:((_=g[0])==null?void 0:_.nudge)??0,p?0:((k=w[0])==null?void 0:k.nudge)??0);if(o&&CF(u)&&v.len()!==0){const $=g.length&&w.length?Math.abs(v.x)<Math.abs(v.y)?"x":"y":g.length?"x":"y",T=t.aspectRatio;$==="x"?(w.length=0,v.y=v.x/T,(u==="bottom_left"||u==="top_right")&&(v.y=-v.y)):(g.length=0,v.x=v.y*T,(u==="bottom_left"||u==="top_right")&&(v.x=-v.x))}const b=P.Add(n,v),{box:E}=ne.Resize(t,r,s?b.x*2:b.x,s?b.y*2:b.y,o);s&&(E.center=t.center);const C=Y1("any",E);g.length=0,w.length=0,S.x=0,S.y=0,this.collectPointSnaps({minOffset:S,nearestSnapsX:g,nearestSnapsY:w,otherNodeSnapPoints:y,selectionSnapPoints:C});const I=this.getPointSnapLines({nearestSnapsX:g,nearestSnapsY:w});return this.manager.setIndicators([...I]),{nudge:v}}collectPointSnaps({selectionSnapPoints:t,otherNodeSnapPoints:n,minOffset:r,nearestSnapsX:o,nearestSnapsY:s}){for(const i of t)for(const a of n){const c=P.Sub(i,a),l=Math.abs(c.x),u=Math.abs(c.y);de(l)<=de(r.x)&&(de(l)<de(r.x)&&(o.length=0),o.push({type:"points",points:{thisPoint:i,otherPoint:a},nudge:a.x-i.x}),r.x=l),de(u)<=de(r.y)&&(de(u)<de(r.y)&&(s.length=0),s.push({type:"points",points:{thisPoint:i,otherPoint:a},nudge:a.y-i.y}),r.y=u)}}collectGapSnaps({selectionPageBounds:t,minOffset:n,nearestSnapsX:r,nearestSnapsY:o}){const{horizontal:s,vertical:i}=this.getVisibleGaps();for(const a of s){if(!Xc(a.breadthIntersection[0],a.breadthIntersection[1],t.minY,t.maxY))continue;const l=a.startEdge[0].x+a.length/2-t.center.x;if(a.length>t.width&&de(Math.abs(l))<=de(n.x)){de(Math.abs(l))<de(n.x)&&(r.length=0),n.x=Math.abs(l);const S={type:"gap_center",gap:a,nudge:l},v=r.find(({type:E})=>E==="gap_center"),b=v&&kr(a.breadthIntersection[0],a.breadthIntersection[1],v.gap.breadthIntersection[0],v.gap.breadthIntersection[1]);v&&v.gap.length>a.length&&b?r[r.indexOf(v)]=S:(!v||!b)&&r.push(S)}const d=a.startNode.pageBounds.minX-a.length,p=t.maxX,f=d-p;de(Math.abs(f))<=de(n.x)&&(de(Math.abs(f))<de(n.x)&&(r.length=0),n.x=Math.abs(f),r.push({type:"gap_duplicate",gap:a,protrusionDirection:"left",nudge:f}));const y=a.endNode.pageBounds.maxX+a.length,g=t.minX,w=y-g;de(Math.abs(w))<=de(n.x)&&(de(Math.abs(w))<de(n.x)&&(r.length=0),n.x=Math.abs(w),r.push({type:"gap_duplicate",gap:a,protrusionDirection:"right",nudge:w}))}for(const a of i){if(!Xc(a.breadthIntersection[0],a.breadthIntersection[1],t.minX,t.maxX))continue;const l=a.startEdge[0].y+a.length/2-t.center.y;if(a.length>t.height&&de(Math.abs(l))<=de(n.y)){de(Math.abs(l))<de(n.y)&&(o.length=0),n.y=Math.abs(l);const S={type:"gap_center",gap:a,nudge:l},v=o.find(({type:E})=>E==="gap_center"),b=v&&Xc(v.gap.breadthIntersection[0],v.gap.breadthIntersection[1],a.breadthIntersection[0],a.breadthIntersection[1]);v&&v.gap.length>a.length&&b?o[o.indexOf(v)]=S:(!v||!b)&&o.push(S);continue}const d=a.startNode.pageBounds.minY-a.length,p=t.maxY,f=d-p;de(Math.abs(f))<=de(n.y)&&(de(Math.abs(f))<de(n.y)&&(o.length=0),n.y=Math.abs(f),o.push({type:"gap_duplicate",gap:a,protrusionDirection:"top",nudge:f}));const y=a.endNode.pageBounds.maxY+a.length,g=t.minY,w=y-g;de(Math.abs(w))<=de(n.y)&&(de(Math.abs(w))<de(n.y)&&(o.length=0),n.y=Math.abs(w),o.push({type:"gap_duplicate",gap:a,protrusionDirection:"bottom",nudge:w}))}}getPointSnapLines({nearestSnapsX:t,nearestSnapsY:n}){const r={},o={};if(t.length>0){for(const s of t)if(s.type==="points"){const i=de(s.points.otherPoint.x);r[i]||(r[i]=[]),r[i].push(s.points)}}if(n.length>0){for(const s of n)if(s.type==="points"){const i=de(s.points.otherPoint.y);o[i]||(o[i]=[]),o[i].push(s.points)}}return Object.values(r).concat(Object.values(o)).map(s=>({id:et(),type:"points",points:Mp(s.map(i=>P.From(i.otherPoint)).concat(s.map(i=>P.From(i.thisPoint))),(i,a)=>i.equals(a))}))}getGapSnapLines({selectionPageBounds:t,nearestSnapsX:n,nearestSnapsY:r}){const{vertical:o,horizontal:s}=this.getVisibleGaps(),i={top:t.sides[0],right:t.sides[1],bottom:[t.corners[3],t.corners[2]],left:[t.corners[0],t.corners[3]]},a=[];if(n.length>0)for(const c of n){if(c.type==="points")continue;const{gap:{breadthIntersection:l,startEdge:u,startNode:d,endNode:p,length:f,endEdge:y}}=c;switch(c.type){case"gap_center":{const g=(f-t.width)/2,w=kr(l[0],l[1],t.minY,t.maxY);a.push({type:"gaps",direction:"horizontal",id:et(),gaps:[...Eo(s,d.id,g,"backward",w),{startEdge:u,endEdge:i.left},{startEdge:i.right,endEdge:y},...Eo(s,p.id,g,"forward",w)]});break}case"gap_duplicate":{const g=kr(l[0],l[1],t.minY,t.maxY);a.push({type:"gaps",direction:"horizontal",id:et(),gaps:c.protrusionDirection==="left"?[{startEdge:i.right,endEdge:u.map(w=>w.clone().addXY(-d.pageBounds.width,0))},{startEdge:u,endEdge:y},...Eo(s,p.id,f,"forward",g)]:[...Eo(s,d.id,f,"backward",g),{startEdge:u,endEdge:y},{startEdge:y.map(w=>w.clone().addXY(c.gap.endNode.pageBounds.width,0)),endEdge:i.left}]});break}}}if(r.length>0)for(const c of r){if(c.type==="points")continue;const{gap:{breadthIntersection:l,startEdge:u,startNode:d,endNode:p,length:f,endEdge:y}}=c;switch(c.type){case"gap_center":{const g=(f-t.height)/2,w=kr(l[0],l[1],t.minX,t.maxX);a.push({type:"gaps",direction:"vertical",id:et(),gaps:[...Eo(o,d.id,g,"backward",w),{startEdge:u,endEdge:i.top},{startEdge:i.bottom,endEdge:y},...Eo(o,c.gap.endNode.id,g,"forward",w)]});break}case"gap_duplicate":{const g=kr(l[0],l[1],t.minX,t.maxX);a.push({type:"gaps",direction:"vertical",id:et(),gaps:c.protrusionDirection==="top"?[{startEdge:i.bottom,endEdge:u.map(w=>w.clone().addXY(0,-d.pageBounds.height))},{startEdge:u,endEdge:y},...Eo(o,p.id,f,"forward",g)]:[...Eo(o,d.id,f,"backward",g),{startEdge:u,endEdge:y},{startEdge:y.map(w=>w.clone().addXY(0,p.pageBounds.height)),endEdge:i.top}]})}break}}return sz(a),a}}Bf([V],Du.prototype,"getSnapPointsCache");Bf([V],Du.prototype,"getSnappablePoints");Bf([V],Du.prototype,"getSnappableGapNodes");Bf([V],Du.prototype,"getVisibleGaps");function Y1(e,t){const{minX:n,maxX:r,minY:o,maxY:s}=t,i=[];switch(e){case"top":case"left":case"top_left":case"any":i.push({id:"top_left",handle:"top_left",x:n,y:o})}switch(e){case"top":case"right":case"top_right":case"any":i.push({id:"top_right",handle:"top_right",x:r,y:o})}switch(e){case"bottom":case"right":case"bottom_right":case"any":i.push({id:"bottom_right",handle:"bottom_right",x:r,y:s})}switch(e){case"bottom":case"left":case"bottom_left":case"any":i.push({id:"bottom_left",handle:"bottom_left",x:n,y:s})}return i}var iz=Object.defineProperty,az=Object.getOwnPropertyDescriptor,cz=(e,t,n,r)=>{for(var o=az(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&iz(t,n,o),o};const lz=()=>null,uz=()=>[];class R2{constructor(t){m(this,"editor");this.manager=t,this.editor=t.editor}getSnapGeometryCache(){const{editor:t}=this;return t.store.createComputedCache("handle snap geometry",n=>{const r=t.getShapeUtil(n).getHandleSnapGeometry(n);return{outline:r.outline===void 0?t.getShapeGeometry(n):r.outline,points:r.points??[],getSelfSnapOutline:r.getSelfSnapOutline??lz,getSelfSnapPoints:r.getSelfSnapPoints??uz}})}*iterateSnapPointsInPageSpace(t,n){var o,s;const r=(o=this.getSnapGeometryCache().get(t))==null?void 0:o.getSelfSnapPoints(n);if(r&&r.length){const i=yi(this.editor.getShapePageTransform(t));for(const a of r)yield i.applyToPoint(a)}for(const i of this.manager.getSnappableShapes()){if(i===t)continue;const a=(s=this.getSnapGeometryCache().get(i))==null?void 0:s.points;if(!a||!a.length)continue;const c=yi(this.editor.getShapePageTransform(i));for(const l of a)yield c.applyToPoint(l)}}*iterateSnapOutlines(t,n){var o,s;const r=(o=this.getSnapGeometryCache().get(t))==null?void 0:o.getSelfSnapOutline(n);r&&(yield{shapeId:t,outline:r});for(const i of this.manager.getSnappableShapes()){if(i===t)continue;const a=(s=this.getSnapGeometryCache().get(i))==null?void 0:s.outline;a&&(yield{shapeId:i,outline:a})}}getHandleSnapPosition({currentShapeId:t,handle:n,handleInPageSpace:r}){const o=this.manager.getSnapThreshold();let s=o,i=null;for(const l of this.iterateSnapPointsInPageSpace(t,n))P.DistMin(r,l,s)&&(s=P.Dist(r,l),i=l);if(i)return i;let a=o,c=null;for(const{shapeId:l,outline:u}of this.iterateSnapOutlines(t,n)){const d=yi(this.editor.getShapePageTransform(l)),p=this.editor.getPointInShapeSpace(l,r),f=u.nearestPoint(p),y=d.applyToPoint(f);P.DistMin(r,y,a)&&(a=P.Dist(r,y),c=y)}return c||null}snapHandle({currentShapeId:t,handle:n}){const o=yi(this.editor.getShapePageTransform(t)).applyToPoint(n),s=this.getHandleSnapPosition({currentShapeId:t,handle:n,handleInPageSpace:o});return s?(this.manager.setIndicators([{id:et(),type:"points",points:[s]}]),{nudge:P.Sub(s,o)}):null}}cz([V],R2.prototype,"getSnapGeometryCache");var dz=Object.defineProperty,hz=Object.getOwnPropertyDescriptor,ax=(e,t,n,r)=>{for(var o=hz(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&dz(t,n,o),o};class Uf{constructor(t){m(this,"shapeBounds");m(this,"handles");m(this,"_snapIndicators",fn("snapLines",void 0));this.editor=t,this.shapeBounds=new Du(this),this.handles=new R2(this)}getIndicators(){return this._snapIndicators.get()??Do}clearIndicators(){this.getIndicators().length&&this._snapIndicators.set(void 0)}setIndicators(t){this._snapIndicators.set(t)}getSnapThreshold(){return 8/this.editor.getZoomLevel()}getSnappableShapes(){const{editor:t}=this,n=t.getRenderingBounds(),r=t.getSelectedShapeIds(),o=new Set,s=i=>{if(Kn(i)){const c=t.getShape(i);c&&t.isShapeOfType(c,"frame")&&o.add(i)}const a=t.getSortedChildIdsForParent(i);for(const c of a){if(r.includes(c))continue;const l=t.getShape(c);if(!l||!t.getShapeUtil(l).canSnap(l))continue;const d=t.getShapePageBounds(c);if(d&&n.includes(d)){if(t.isShapeOfType(l,"group")){s(c);continue}o.add(c)}}};return s(this.getCurrentCommonAncestor()??t.getCurrentPageId()),o}getCurrentCommonAncestor(){return this.editor.findCommonAncestor(this.editor.getSelectedShapes())}}ax([V],Uf.prototype,"getSnapThreshold");ax([V],Uf.prototype,"getSnappableShapes");ax([V],Uf.prototype,"getCurrentCommonAncestor");const pz=/\r?\n|\r/g;function X1(e){return e.replace(pz,`
|
|
`).split(`
|
|
`).map(t=>t||" ").join(`
|
|
`)}const fz={start:"left","start-legacy":"left",middle:"center","middle-legacy":"center",end:"right","end-legacy":"right"},gz=/\s/;class mz{constructor(t){m(this,"baseElm");m(this,"measureText",(t,n)=>{var i;const r=(i=this.baseElm)==null?void 0:i.cloneNode();this.baseElm.insertAdjacentElement("afterend",r),r.setAttribute("dir","ltr"),r.style.setProperty("font-family",n.fontFamily),r.style.setProperty("font-style",n.fontStyle),r.style.setProperty("font-weight",n.fontWeight),r.style.setProperty("font-size",n.fontSize+"px"),r.style.setProperty("line-height",n.lineHeight*n.fontSize+"px"),r.style.setProperty("max-width",n.maxWidth===null?null:n.maxWidth+"px"),r.style.setProperty("min-width",n.minWidth===null?null:n.minWidth+"px"),r.style.setProperty("padding",n.padding),r.style.setProperty("overflow-wrap",n.disableOverflowWrapBreaking?"normal":"break-word"),r.textContent=X1(t);const o=r.scrollWidth,s=r.getBoundingClientRect();return r.remove(),{x:0,y:0,w:s.width,h:s.height,scrollWidth:o}});var o;this.editor=t;const n=this.editor.getContainer();(o=n.querySelector("#tldraw_text_measure"))==null||o.remove();const r=document.createElement("div");r.id="tldraw_text_measure",r.classList.add("tl-text"),r.classList.add("tl-text-measure"),r.tabIndex=-1,n.appendChild(r),this.baseElm=r}measureElementTextNodeSpans(t,{shouldTruncateToFirstLine:n=!1}={}){const r=[],o=t.getBoundingClientRect(),s=-o.left,i=-o.top,a=new Range,c=t.childNodes[0];let l=0,u=null,d=null,p=0,f=!1;for(const y of t.childNodes)if(y.nodeType===Node.TEXT_NODE)for(const g of y.textContent??""){a.setStart(c,l),a.setEnd(c,l+g.length);const w=a.getClientRects(),S=w[w.length-1],v=S.top+i,b=S.left+s,E=S.right+s,C=gz.test(g);if(C!==d||v!==p||!u){if(u){if(n&&v!==p){f=!0;break}r.push(u)}u={box:{x:b,y:v,w:S.width,h:S.height},text:g}}else u.box.w=E-u.box.x,u.text+=g;d=C,p=v,l+=g.length}return u&&r.push(u),{spans:r,didTruncate:f}}measureTextSpans(t,n){var l;if(t==="")return[];const r=(l=this.baseElm)==null?void 0:l.cloneNode();this.baseElm.insertAdjacentElement("afterend",r);const o=Math.ceil(n.width-n.padding*2);r.style.setProperty("width",`${o}px`),r.style.setProperty("height","min-content"),r.style.setProperty("dir","ltr"),r.style.setProperty("font-size",`${n.fontSize}px`),r.style.setProperty("font-family",n.fontFamily),r.style.setProperty("font-weight",n.fontWeight),r.style.setProperty("line-height",`${n.lineHeight*n.fontSize}px`),r.style.setProperty("text-align",fz[n.textAlign]);const s=n.overflow==="truncate-ellipsis"||n.overflow==="truncate-clip";s&&(r.style.setProperty("overflow-wrap","anywhere"),r.style.setProperty("word-break","break-all"));const i=X1(t);r.textContent=i;const{spans:a,didTruncate:c}=this.measureElementTextNodeSpans(r,{shouldTruncateToFirstLine:s});if(n.overflow==="truncate-ellipsis"&&c){r.textContent="…";const u=Math.ceil(this.measureElementTextNodeSpans(r).spans[0].box.w);r.style.setProperty("width",`${o-u}px`),r.textContent=i;const d=this.measureElementTextNodeSpans(r,{shouldTruncateToFirstLine:!0}).spans,p=d[d.length-1];return d.push({text:"…",box:{x:Math.min(p.box.x+p.box.w,n.width-n.padding-u),y:p.box.y,w:u,h:p.box.h}}),d}return r.remove(),a}}const q1=(typeof process<"u",Q_);class yz{constructor(t){m(this,"cancelRaf");m(this,"isPaused",!0);m(this,"now",0);m(this,"start",()=>{var t;this.isPaused=!1,(t=this.cancelRaf)==null||t.call(this),this.cancelRaf=q1(this.tick),this.now=Date.now()});m(this,"tick",()=>{if(this.isPaused)return;const t=Date.now(),n=t-this.now;this.now=t,this.updatePointerVelocity(n),this.editor.emit("frame",n),this.editor.emit("tick",n),this.cancelRaf=q1(this.tick)});m(this,"dispose",()=>{var t;this.isPaused=!0,(t=this.cancelRaf)==null||t.call(this)});m(this,"prevPoint",new P);m(this,"updatePointerVelocity",t=>{const{prevPoint:n,editor:{inputs:{currentScreenPoint:r,pointerVelocity:o}}}=this;if(t===0)return;const s=P.Sub(r,n);this.prevPoint=r.clone();const i=s.len(),a=i?s.div(i):new P(0,0),c=o.clone().lrp(a.mul(i/t),.5);Math.abs(c.x)<.01&&(c.x=0),Math.abs(c.y)<.01&&(c.y=0),o.equals(c)||(this.editor.inputs.pointerVelocity=c)});this.editor=t,this.editor.disposables.add(this.dispose),this.start()}}var Sz=Object.defineProperty,vz=Object.getOwnPropertyDescriptor,go=(e,t,n,r)=>{for(var o=vz(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&Sz(t,n,o),o};class Hr{constructor(t,n){m(this,"updateUserPreferences",t=>{this.user.setUserPreferences({...this.user.userPreferences.get(),...t})});this.user=t,this.inferDarkMode=n}getUserPreferences(){return{id:this.getId(),name:this.getName(),locale:this.getLocale(),color:this.getColor(),animationSpeed:this.getAnimationSpeed(),isSnapMode:this.getIsSnapMode(),isDarkMode:this.getIsDarkMode(),isWrapMode:this.getIsWrapMode()}}getIsDarkMode(){return this.user.userPreferences.get().isDarkMode??(this.inferDarkMode?w4():!1)}getEdgeScrollSpeed(){return this.user.userPreferences.get().edgeScrollSpeed??ai.edgeScrollSpeed}getAnimationSpeed(){return this.user.userPreferences.get().animationSpeed??ai.animationSpeed}getId(){return this.user.userPreferences.get().id}getName(){return this.user.userPreferences.get().name??ai.name}getLocale(){return this.user.userPreferences.get().locale??ai.locale}getColor(){return this.user.userPreferences.get().color??ai.color}getIsSnapMode(){return this.user.userPreferences.get().isSnapMode??ai.isSnapMode}getIsWrapMode(){return this.user.userPreferences.get().isWrapMode??ai.isWrapMode}}go([V],Hr.prototype,"getUserPreferences");go([V],Hr.prototype,"getIsDarkMode");go([V],Hr.prototype,"getEdgeScrollSpeed");go([V],Hr.prototype,"getAnimationSpeed");go([V],Hr.prototype,"getId");go([V],Hr.prototype,"getName");go([V],Hr.prototype,"getLocale");go([V],Hr.prototype,"getColor");go([V],Hr.prototype,"getIsSnapMode");go([V],Hr.prototype,"getIsWrapMode");function Zc(e){return Math.abs(e.props.bend)<8}function Qp(e,t){if(t.type==="point")return;const n=e.getShape(t.boundShapeId),r=e.getShapePageTransform(n),o=e.getShapeGeometry(n),s=o instanceof Br?o.children[0].vertices:o.vertices;return{shape:n,transform:r,isClosed:o.isClosed,isExact:t.isExact,didIntersect:!1,outline:s}}function Z1(e,t,n,r){if(n.type==="point")return P.From(n);const o=e.getShape(n.boundShapeId);if(o){const{point:s,size:i}=e.getShapeGeometry(o).bounds,a=P.Add(s,P.MulV(n.isPrecise||r?n.normalizedAnchor:{x:.5,y:.5},i)),c=oe.applyToPoint(e.getShapePageTransform(o),a);return oe.applyToPoint(oe.Inverse(t),c)}else return new P(0,0)}function jr(e,t){const n=e.getShapePageTransform(t);let r,o;t.props.start.type==="binding"&&t.props.end.type==="binding"&&(r=t.props.start.boundShapeId,o=t.props.end.boundShapeId);const s=cx(e,r,o),i=Z1(e,n,t.props.start,s==="double-bound"||s==="start-contains-end"),a=Z1(e,n,t.props.end,s==="double-bound"||s==="end-contains-start");return{start:i,end:a}}const Ma=10,Jp=10,xz=10,Ps={s:2,m:3.5,l:5,xl:10};function cx(e,t,n){if(!t||!n)return"safe";if(t===n)return"double-bound";const r=e.getShapePageBounds(t),o=e.getShapePageBounds(n);if(r&&o){if(r.contains(o))return"start-contains-end";if(o.contains(r))return"end-contains-start"}return"safe"}function Al(e,t){const{start:n,end:r,arrowheadStart:o,arrowheadEnd:s}=t.props,i=jr(e,t),a=i.start.clone(),c=i.end.clone(),l=P.Med(a,c);if(P.Equals(a,c))return{isStraight:!0,start:{handle:a,point:a,arrowhead:t.props.arrowheadStart},end:{handle:c,point:c,arrowhead:t.props.arrowheadEnd},middle:l,isValid:!1,length:0};const u=P.Sub(c,a).uni(),d=Qp(e,n),p=Qp(e,r),f=e.getShapePageTransform(t);Q1(c,i.start,f,p),Q1(a,i.end,f,d);let y=0,g=0,w=0,S=0,v=Ma;const b=d&&p&&d.shape===p.shape,E=d&&p?cx(e,d.shape.id,p.shape.id):"safe";E==="safe"&&d&&p&&!b&&!d.isExact&&!p.isExact&&(p.didIntersect&&!d.didIntersect?d.isClosed&&a.setTo(c.clone().add(u.clone().mul(Ma))):p.didIntersect||p.isClosed&&c.setTo(a.clone().sub(u.clone().mul(Ma))));const C=P.Sub(c,a),I=P.Len(C)?C.uni():P.From(C),_=!P.Equals(I,u);b||(E!=="start-contains-end"&&d&&o!=="none"&&!d.isExact&&(w=Ps[t.props.size]/2+("size"in d.shape.props?Ps[d.shape.props.size]/2:0),y=Jp+w,v+=w),E!=="end-contains-start"&&p&&s!=="none"&&!p.isExact&&(S=Ps[t.props.size]/2+("size"in p.shape.props?Ps[p.shape.props.size]/2:0),g=Jp+S,v+=S));const k=a.clone().add(I.clone().mul(y*(_?-1:1))),$=c.clone().sub(I.clone().mul(g*(_?-1:1)));P.DistMin(k,$,v)&&(y!==0&&g!==0?(y*=-1.5,g*=-1.5):y!==0?y*=-1:g!==0&&(g*=-1)),a.add(I.clone().mul(y*(_?-1:1))),c.sub(I.clone().mul(g*(_?-1:1))),_?(d&&p&&c.setTo(P.Add(a,I.clone().mul(-Ma))),l.setTo(P.Med(i.start,i.end))):l.setTo(P.Med(a,c));const T=P.Dist(a,c);return{isStraight:!0,start:{handle:i.start,point:a,arrowhead:t.props.arrowheadStart},end:{handle:i.end,point:c,arrowhead:t.props.arrowheadEnd},middle:l,isValid:T>0,length:T}}function Q1(e,t,n,r){if(r===void 0||r.isExact)return;const o=oe.applyToPoint(n,t),s=oe.applyToPoint(n,e),i=oe.applyToPoint(oe.Inverse(r.transform),o),a=oe.applyToPoint(oe.Inverse(r.transform),s),c=r.isClosed,u=(c?ox:T4)(i,a,r.outline);let d;if(u!==null&&(d=u.sort((y,g)=>P.Dist2(y,i)-P.Dist2(g,i))[0]??(c?void 0:a)),d===void 0)return;const p=oe.applyToPoint(r.transform,d),f=oe.applyToPoint(oe.Inverse(n),p);e.setTo(f),r.didIntersect=!0}function xm(e,t,n=0){const{arrowheadEnd:r,arrowheadStart:o}=t.props,s=t.props.bend+n;if(Math.abs(s)>Math.abs(t.props.bend*xz))return Al(e,t);const i=jr(e,t),a=P.Med(i.start,i.end),c=P.Sub(i.end,i.start),l=P.Len(c)?c.uni():P.From(c),u=P.Add(a,l.per().mul(-s)),d=Qp(e,t.props.start),p=Qp(e,t.props.end),f=i.start.clone(),y=i.end.clone(),g=u.clone();if(P.Equals(f,y))return{isStraight:!0,start:{handle:f,point:f,arrowhead:t.props.arrowheadStart},end:{handle:y,point:y,arrowhead:t.props.arrowheadEnd},middle:g,isValid:!1,length:0};const w=t.props.bend<0,S=w?$u:Kk,v=J1(f,y,g),b=P.Angle(v.center,f),E=P.Angle(v.center,y),C=S(b,E);if(v.length===0||v.size===0||!x1(v.length)||!x1(v.size))return Al(e,t);const I=f.clone(),_=y.clone(),k=g.clone(),$=e.getShapePageTransform(t);let T=0,O=0,N=Ma;if(d&&!d.isExact){const W=oe.applyToPoint($,I),Z=oe.applyToPoint($,v.center),le=oe.applyToPoint($,_),be=oe.Inverse(d.transform),Me=oe.applyToPoint(be,W),ae=oe.applyToPoint(be,Z),Ae=oe.applyToPoint(be,le),{isClosed:Re}=d,ot=Re?WS:K1;let Ie,ht=ot(ae,v.radius,d.outline);if(ht){const He=ae.angle(Me),ir=ae.angle(Ae),Ln=S(He,ir);ht=ht.filter(qe=>S(He,ae.angle(qe))<=Ln);const Fn=Ln*.25;ht.sort(Re?(qe,Ot)=>Math.abs(S(He,ae.angle(qe))-Fn)<Math.abs(S(He,ae.angle(Ot))-Fn)?-1:1:(qe,Ot)=>S(He,ae.angle(qe))<S(He,ae.angle(Ot))?-1:1),Ie=ht[0]??(Re?void 0:Me)}else Ie=Re?void 0:Me;if(Ie&&(I.setTo(e.getPointInShapeSpace(t,oe.applyToPoint(d.transform,Ie))),d.didIntersect=!0,o!=="none")){const He=Ps[t.props.size]/2+("size"in d.shape.props?Ps[d.shape.props.size]/2:0);T=Jp+He,N+=He}}if(p&&!p.isExact){const W=oe.applyToPoint($,I),Z=oe.applyToPoint($,_),le=oe.applyToPoint($,v.center),be=oe.Inverse(p.transform),Me=oe.applyToPoint(be,W),ae=oe.applyToPoint(be,le),Ae=oe.applyToPoint(be,Z),Re=p.isClosed,ot=Re?WS:K1;let Ie,ht=ot(ae,v.radius,p.outline);if(ht){const He=ae.angle(Me),ir=ae.angle(Ae),Ln=S(He,ir),Fn=Ln*.75;ht=ht.filter(qe=>S(He,ae.angle(qe))<=Ln),ht.sort(Re?(qe,Ot)=>Math.abs(S(He,ae.angle(qe))-Fn)<Math.abs(S(He,ae.angle(Ot))-Fn)?-1:1:(qe,Ot)=>S(He,ae.angle(qe))<S(He,ae.angle(Ot))?-1:1),ht[0]?Ie=ht[0]:Ie=Re?void 0:Ae}else Ie=Re?void 0:Ae;if(Ie&&(_.setTo(e.getPointInShapeSpace(t,oe.applyToPoint(p.transform,Ie))),p.didIntersect=!0,r!=="none")){const He=Ps[t.props.size]/2+("size"in p.shape.props?Ps[p.shape.props.size]/2:0);O=Jp+He,N+=He}}let F=P.Angle(v.center,I),L=P.Angle(v.center,_),B=S(F,L),q=B*v.radius;const Q=I.clone(),H=_.clone();if(T!==0){const W=T/q*(w?1:-1),Z=P.FromAngle(F+B*W);Q.setTo(v.center).add(Z.mul(v.radius))}if(O!==0){const W=O/q*(w?-1:1),Z=P.FromAngle(L+B*W);H.setTo(v.center).add(Z.mul(v.radius))}if(P.DistMin(Q,H,N)&&(T!==0&&O!==0?(T*=-1.5,O*=-1.5):T!==0?T*=-2:O!==0&&(O*=-2)),T!==0){const W=T/q*(w?1:-1),Z=P.FromAngle(F+B*W);I.setTo(v.center).add(Z.mul(v.radius))}if(O!==0){const W=O/q*(w?-1:1),Z=P.FromAngle(L+B*W);_.setTo(v.center).add(Z.mul(v.radius))}if(d&&p&&!d.isExact&&!p.isExact){F=P.Angle(v.center,I),L=P.Angle(v.center,_),B=S(F,L),q=B*v.radius;const W=cx(e,d.shape.id,p.shape.id);if(W==="double-bound"&&q<30)I.setTo(f),_.setTo(y),k.setTo(g);else if(W==="safe"&&(d&&!d.didIntersect&&I.setTo(f),p&&!p.didIntersect||S(b,F)>S(b,L))){const Z=Math.min(.9,Ma/q)*(w?1:-1),le=P.FromAngle(F+B*Z);_.setTo(v.center).add(le.mul(v.radius))}}wz(v.center,v.radius,I,_,k,C,w),I.equals(_)&&(I.setTo(k.clone().addXY(1,1)),_.setTo(k.clone().subXY(1,1))),f.setTo(I),y.setTo(_),g.setTo(k);const U=J1(f,y,g);return{isStraight:!1,start:{point:f,handle:i.start,arrowhead:t.props.arrowheadStart},end:{point:y,handle:i.end,arrowhead:t.props.arrowheadEnd},middle:g,handleArc:v,bodyArc:U,isValid:U.length!==0&&isFinite(U.center.x)&&isFinite(U.center.y)}}function J1(e,t,n){const r=-2*(e.x*(t.y-n.y)-e.y*(t.x-n.x)+t.x*n.y-n.x*t.y),o={x:((e.x*e.x+e.y*e.y)*(n.y-t.y)+(t.x*t.x+t.y*t.y)*(e.y-n.y)+(n.x*n.x+n.y*n.y)*(t.y-e.y))/r,y:((e.x*e.x+e.y*e.y)*(t.x-n.x)+(t.x*t.x+t.y*t.y)*(n.x-e.x)+(n.x*n.x+n.y*n.y)*(e.x-t.x))/r},s=P.Dist(o,e),i=+P.Clockwise(e,n,t),a=((e.y-t.y)**2+(e.x-t.x)**2)**.5,c=((t.y-n.y)**2+(t.x-n.x)**2)**.5,l=((n.y-e.y)**2+(n.x-e.x)**2)**.5,u=Math.acos((c*c+l*l-a*a)/(2*c*l))*2,d=+(Pe>u),p=(Oe-u)*(i?1:-1),f=p*s;return{center:o,radius:s,size:p,length:f,largeArcFlag:d,sweepFlag:i}}function wz(e,t,n,r,o,s,i){const a=P.Angle(e,n),c=P.Angle(e,r);let l=$u(a,c);i||(l=Oe-l);const u=.5*(i?1:-1),d=P.FromAngle(a+l*u);if(o.setTo(e).add(d.mul(t)),l>s){o.rotWith(e,Pe);const p=r.clone();r.setTo(n),n.setTo(p)}}const bz={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"};class se{constructor(t,n){m(this,"id");m(this,"type");m(this,"shapeType");m(this,"initial");m(this,"children");m(this,"parent");m(this,"_path");m(this,"_current");m(this,"_isActive");m(this,"transition",(t,n={})=>{var s;const r=t.split(".");let o=this;for(let i=0;i<r.length;i++){const a=r[i],c=o.getCurrent(),l=(s=o.children)==null?void 0:s[a];if(!l)throw Error(`${o.id} - no child state exists with the id ${a}.`);if((c==null?void 0:c.id)!==l.id&&(c==null||c.exit(n,a),o._current.set(l),l.enter(n,(c==null?void 0:c.id)||"initial"),!l.getIsActive()))break;o=l}return this});m(this,"handleEvent",t=>{var o;const n=bz[t.name],r=this._current.__unsafe__getWithoutCapture();(o=this[n])==null||o.call(this,t),this._isActive.__unsafe__getWithoutCapture()&&r&&r===this._current.__unsafe__getWithoutCapture()&&r.handleEvent(t)});m(this,"enter",(t,n)=>{var r;if(this._isActive.set(!0),(r=this.onEnter)==null||r.call(this,t,n),this.children&&this.initial&&this.getIsActive()){const o=this.children[this.initial];this._current.set(o),o.enter(t,n)}});m(this,"exit",(t,n)=>{var r,o;this._isActive.set(!1),(r=this.onExit)==null||r.call(this,t,n),this.getIsActive()||(o=this.getCurrent())==null||o.exit(t,n)});m(this,"_currentToolIdMask",fn("curent tool id mask",void 0));m(this,"onWheel");m(this,"onPointerDown");m(this,"onPointerMove");m(this,"onLongPress");m(this,"onPointerUp");m(this,"onDoubleClick");m(this,"onTripleClick");m(this,"onQuadrupleClick");m(this,"onRightClick");m(this,"onMiddleClick");m(this,"onKeyDown");m(this,"onKeyUp");m(this,"onKeyRepeat");m(this,"onCancel");m(this,"onComplete");m(this,"onInterrupt");m(this,"onTick");m(this,"onEnter");m(this,"onExit");this.editor=t;const{id:r,children:o,initial:s}=this.constructor;this.id=r,this._isActive=fn("toolIsActive"+this.id,!1),this._current=fn("toolState"+this.id,void 0),this._path=V("toolPath"+this.id,()=>{const i=this.getCurrent();return this.id+(i?`.${i.getPath()}`:"")}),this.parent=n??{},this.parent?o&&s?(this.type="branch",this.initial=s,this.children=Object.fromEntries(o().map(i=>[i.id,new i(this.editor,this)])),this._current.set(this.children[this.initial])):this.type="leaf":(this.type="root",o&&s&&(this.initial=s,this.children=Object.fromEntries(o().map(i=>[i.id,new i(this.editor,this)])),this._current.set(this.children[this.initial])))}getPath(){return this._path.get()}getCurrent(){return this._current.get()}getIsActive(){return this._isActive.get()}getCurrentToolIdMask(){return this._currentToolIdMask.get()}setCurrentToolIdMask(t){this._currentToolIdMask.set(t)}}m(se,"id"),m(se,"initial"),m(se,"children");class bh extends se{constructor(){super(...arguments);m(this,"onKeyDown",n=>{var r;switch(n.code){case"KeyZ":{if(!(n.shiftKey||n.ctrlKey)){const o=this.getCurrent();o&&((r=o.getCurrent())==null?void 0:r.id)==="idle"&&this.children.zoom&&this.editor.setCurrentTool("zoom",{...n,onInteractionEnd:o.id})}break}}})}}m(bh,"id","root"),m(bh,"initial",""),m(bh,"children",()=>[]);var Pz=Object.defineProperty,Cz=Object.getOwnPropertyDescriptor,re=(e,t,n,r)=>{for(var o=Cz(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&Pz(t,n,o),o};class J extends k4.EventEmitter{constructor({store:n,user:r,shapeUtils:o,tools:s,getContainer:i,initialState:a,inferDarkMode:c}){super();m(this,"store");m(this,"root");m(this,"disposables",new Set);m(this,"_tickManager");m(this,"snaps");m(this,"user");m(this,"textMeasure");m(this,"environment");m(this,"scribbles");m(this,"getContainer");m(this,"sideEffects");m(this,"shapeUtils");m(this,"styleProps");m(this,"history",new ez(this,n=>{this.annotateError(n,{origin:"history.batch",willCrashApp:!0}),this.crash(n)}));m(this,"_crashingError",null);m(this,"_updateInstanceState",this.history.createCommand("updateInstanceState",(n,r)=>{const o=this.store.get(this.getInstanceState().id),s={...o,...n};return{data:{prev:o,next:s},ephemeral:!1,squashing:!1,...r}},{do:({next:n})=>{this.store.put([n])},undo:({prev:n})=>{this.store.put([n])},squash({prev:n},{next:r}){return{prev:n,next:r}}}));m(this,"_isChangingStyleTimeout",-1);m(this,"setCursor",n=>(this.updateInstanceState({cursor:{...this.getInstanceState().cursor,...n}},{ephemeral:!0}),this));m(this,"_setInstancePageState",this.history.createCommand("setInstancePageState",(n,r)=>({data:{prev:this.store.get(n.id??this.getCurrentPageState().id),partial:n},...r}),{do:({prev:n,partial:r})=>{this.store.update(n.id,o=>({...o,...r}))},undo:({prev:n})=>{this.store.update(n.id,()=>n)}}));m(this,"_setSelectedShapes",this.history.createCommand("setSelectedShapes",(n,r)=>{const{selectedShapeIds:o}=this.getCurrentPageState(),s=new Set(o);return n.length===s.size&&n.every(i=>s.has(i))?null:{data:{selectedShapeIds:n,prevSelectedShapeIds:o},preservesRedoStack:!0,...r}},{do:({selectedShapeIds:n})=>{this.store.put([{...this.getCurrentPageState(),selectedShapeIds:n}])},undo:({prevSelectedShapeIds:n})=>{this.store.put([{...this.getCurrentPageState(),selectedShapeIds:n}])},squash({prevSelectedShapeIds:n},{selectedShapeIds:r}){return{selectedShapeIds:r,prevSelectedShapeIds:n}}}));m(this,"_setFocusedGroupId",this.history.createCommand("setFocusedGroupId",n=>{const r=this.getCurrentPageState().focusedGroupId;if(r!==n)return{data:{prev:r,next:n},preservesRedoStack:!0,squashing:!0}},{do:({next:n})=>{this.store.update(this.getCurrentPageState().id,r=>({...r,focusedGroupId:n}))},undo:({prev:n})=>{this.store.update(this.getCurrentPageState().id,r=>({...r,focusedGroupId:n}))},squash({prev:n},{next:r}){return{prev:n,next:r}}}));m(this,"_viewportAnimation",null);m(this,"_willSetInitialBounds",!0);m(this,"_wasInset",!1);m(this,"_cameraState",fn("camera state","idle"));m(this,"_cameraStateTimeoutRemaining",0);m(this,"_lastUpdateRenderingBoundsTimestamp",Date.now());m(this,"_decayCameraStateTimeout",n=>{this._cameraStateTimeoutRemaining-=n,this._cameraStateTimeoutRemaining<=0&&(this.off("tick",this._decayCameraStateTimeout),this._cameraState.set("idle"),this.updateRenderingBounds())});m(this,"_tickCameraState",()=>{this._cameraStateTimeoutRemaining=R5;const n=Date.now();this._cameraState.__unsafe__getWithoutCapture()==="idle"&&(this._lastUpdateRenderingBoundsTimestamp=n,this._cameraState.set("moving"),this.on("tick",this._decayCameraStateTimeout))});m(this,"_renderingBounds",fn("rendering viewport",new ne));m(this,"renderingBoundsMargin",100);m(this,"_currentPageShapeIds");m(this,"_setCurrentPageId",this.history.createCommand("setCurrentPage",(n,r)=>{if(!this.store.has(n)){console.error("Tried to set the current page id to a page that doesn't exist.");return}return this.stopFollowingUser(),{data:{toId:n,fromId:this.getCurrentPageId()},squashing:!0,preservesRedoStack:!0,...r}},{do:({toId:n})=>{if(this.store.has(n)){if(!this.getPageStates().find(r=>r.pageId===n)){const r=hn.create({id:hn.createId(n)});this.store.put([r,Zt.create({id:Zt.createId(n),pageId:n})])}this.store.put([{...this.getInstanceState(),currentPageId:n}]),this.updateRenderingBounds()}},undo:({fromId:n})=>{this.store.has(n)&&(this.store.put([{...this.getInstanceState(),currentPageId:n}]),this.updateRenderingBounds())},squash:({fromId:n},{toId:r})=>({toId:r,fromId:n})}));m(this,"_updatePage",this.history.createCommand("updatePage",(n,r)=>{if(this.getInstanceState().isReadonly)return null;const o=this.getPage(n.id);return o?{data:{prev:o,partial:n},...r}:null},{do:({partial:n})=>{this.store.update(n.id,r=>({...r,...n}))},undo:({prev:n,partial:r})=>{this.store.update(r.id,()=>n)},squash(n,r){return{prev:{...n.prev,...r.prev},partial:r.partial}}}));m(this,"_createPage",this.history.createCommand("createPage",n=>{if(this.getInstanceState().isReadonly||this.getPages().length>=Gp)return null;const r=this.getPages(),o=L4(n.name??"Page 1",r.map(l=>l.name));let s=n.index;(!s||r.some(l=>l.index===s))&&(s=$o(r[r.length-1].index));const i=Ho.create({meta:{},...n,name:o,index:s}),a=hn.create({id:hn.createId(i.id)}),c=Zt.create({id:Zt.createId(i.id),pageId:i.id});return{data:{newPage:i,newTabPageState:c,newCamera:a}}},{do:({newPage:n,newTabPageState:r,newCamera:o})=>{this.store.put([n,o,r])},undo:({newPage:n,newTabPageState:r,newCamera:o})=>{this.getPages().length!==1&&this.store.remove([r.id,n.id,o.id])}}));m(this,"_deletePage",this.history.createCommand("delete_page",n=>{if(this.getInstanceState().isReadonly)return null;const r=this.getPages();if(r.length===1)return null;const o=this.getPage(n),s=this.getPageStates().filter(i=>i.pageId===n);if(!o)return null;if(n===this.getCurrentPageId()){const i=r.findIndex(c=>c.id===n),a=r[i-1]??r[i+1];this.setCurrentPage(a.id)}return{data:{id:n,deletedPage:o,deletedPageStates:s}}},{do:({deletedPage:n,deletedPageStates:r})=>{const o=this.getPages();if(o.length!==1){if(n.id===this.getCurrentPageId()){const s=o.findIndex(a=>a.id===n.id),i=o[s-1]??o[s+1];this.setCurrentPage(i.id)}this.store.remove(r.map(s=>s.id)),this.store.remove([n.id]),this.updateRenderingBounds()}},undo:({deletedPage:n,deletedPageStates:r})=>{this.store.put([n]),this.store.put(r),this.updateRenderingBounds()}}));m(this,"_createAssets",this.history.createCommand("createAssets",n=>this.getInstanceState().isReadonly||n.length<=0?null:{data:{assets:n}},{do:({assets:n})=>{this.store.put(n)},undo:({assets:n})=>{this.store.remove(n.map(r=>r.id))}}));m(this,"_updateAssets",this.history.createCommand("updateAssets",n=>this.getInstanceState().isReadonly||n.length<=0?void 0:{data:{snapshots:{},assets:n}},{do:({assets:n,snapshots:r})=>{this.store.put(n.map(o=>{const s=this.store.get(o.id);return r[o.id]=s,{...s,...o}}))},undo:({snapshots:n})=>{this.store.put(Object.values(n))}}));m(this,"_deleteAssets",this.history.createCommand("deleteAssets",n=>{if(this.getInstanceState().isReadonly||n.length<=0)return;const r=fe(n.map(o=>this.store.get(o)));return{data:{ids:n,prev:r}}},{do:({ids:n})=>{this.store.remove(n)},undo:({prev:n})=>{this.store.put(n)}}));m(this,"_parentIdsToChildIds");m(this,"_childIdsCache",new zf);m(this,"_createShapes",this.history.createCommand("createShapes",n=>{if(this.getInstanceState().isReadonly||n.length<=0)return null;const r=this.getCurrentPageShapeIds();if(n.length+r.size>Io){_d(this);return}return n.length===0?null:{data:{currentPageId:this.getCurrentPageId(),partials:n.map(s=>s.id?s:{...s,id:Be()})}}},{do:({partials:n})=>{var a,c;const r=this.getFocusedGroupId(),o=this.getCurrentPageShapesSorted();n=n.map(l=>{if(!l.parentId||!(this.store.has(l.parentId)||n.some(u=>u.id===l.parentId))){let u=this.getFocusedGroupId();for(let p=o.length-1;p>=0;p--){const f=o[p];if(this.getShapeUtil(f).canReceiveNewChildrenOfType(f,l.type)&&this.isPointInShape(f,{x:l.x??0,y:l.y??0},{margin:0,hitInside:!0})){u=f.id;break}}const d=l.parentId;if(u===l.id&&(u=r),u!==d&&(l={...l},l.parentId=u,Kn(u))){const p=this.getPointInShapeSpace(this.getShape(u),{x:l.x??0,y:l.y??0});l.x=p.x,l.y=p.y,l.rotation=-this.getShapePageTransform(u).rotation()+(l.rotation??0)}}return l});const s=new Map,i=[];for(const l of n){const u=this.getShapeUtil(l);let d=l.index;if(!d){const g=l.parentId??r;s.has(g)||s.set(g,this.getHighestIndexForParent(g)),d=s.get(g),s.set(g,$o(d))}const p=u.getDefaultProps();for(const[g,w]of this.styleProps[l.type])p[w]=this.getStyleForNextShape(g);let f=this.store.schema.types.shape.create({...l,index:d,opacity:l.opacity??this.getInstanceState().opacityForNextShape,parentId:l.parentId??r,props:"props"in l?{...p,...l.props}:p});if(f.index===void 0)throw Error("no index!");const y=(c=(a=this.getShapeUtil(f)).onBeforeCreate)==null?void 0:c.call(a,f);y&&(f=y),i.push(f)}i.forEach(l=>{l.meta={...this.getInitialMetaForShape(l),...l.meta}}),this.store.put(i)},undo:({partials:n})=>{this.store.remove(n.map(r=>r.id))}}));m(this,"animatingShapes",new Map);m(this,"_updateShapes",this.history.createCommand("updateShapes",(n,r)=>{if(this.getInstanceState().isReadonly)return null;const o={},s={};let i,a;for(let c=0,l=n.length;c<l;c++){const u=n[c];u&&(i=this.getShape(u.id),i&&(a=Qc(i,u),a!==i&&(o[i.id]=i,s[i.id]=a)))}return{data:{snapshots:o,updates:s},...r}},{do:({updates:n})=>{this.store.put(bt(n).map(r=>{var s,i;const o=this.store.get(r.id);if(o){const a=(i=(s=this.getShapeUtil(r)).onBeforeUpdate)==null?void 0:i.call(s,o,r);if(a)return a}return r}))},undo:({snapshots:n})=>{this.store.put(Object.values(n))},squash(n,r){return{snapshots:{...r.snapshots,...n.snapshots},updates:{...n.updates,...r.updates}}}}));m(this,"_deleteShapes",this.history.createCommand("delete_shapes",n=>{if(this.getInstanceState().isReadonly||n.length===0)return null;const r=[...this.getCurrentPageState().selectedShapeIds],o=new Set(n);for(const l of n)this.visitDescendants(l,u=>{o.add(u)});const s=[...o],i=this._getArrowBindingsIndex().get(),a=fe(s.flatMap(l=>{const u=this.getShape(l),d=i[l];return d&&d.length>0?d.map(({arrowId:p})=>this.getShape(p)).concat(u):u})),c=r.filter(l=>!o.has(l));return{data:{deletedIds:s,snapshots:a,prevSelectedShapeIds:r,postSelectedShapeIds:c}}},{do:({deletedIds:n,postSelectedShapeIds:r})=>{this.store.remove(n),this.store.update(this.getCurrentPageState().id,o=>({...o,selectedShapeIds:r}))},undo:({snapshots:n,prevSelectedShapeIds:r})=>{this.store.put(n),this.store.update(this.getCurrentPageState().id,o=>({...o,selectedShapeIds:r}))}}));m(this,"externalAssetContentHandlers",{file:null,url:null});m(this,"externalContentHandlers",{text:null,files:null,embed:null,"svg-text":null,url:null});m(this,"inputs",{originPagePoint:new P,originScreenPoint:new P,previousPagePoint:new P,previousScreenPoint:new P,currentPagePoint:new P,currentScreenPoint:new P,keys:new Set,buttons:new Set,isPen:!1,shiftKey:!1,ctrlKey:!1,altKey:!1,isDragging:!1,isPointing:!1,isPinching:!1,isEditing:!1,isPanning:!1,pointerVelocity:new P});m(this,"_clickManager",new q4(this));m(this,"_prevCursor","default");m(this,"_shiftKeyTimeout",-1);m(this,"_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,code:"ShiftLeft"})});m(this,"_altKeyTimeout",-1);m(this,"_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,code:"AltLeft"})});m(this,"_ctrlKeyTimeout",-1);m(this,"_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,code:"ControlLeft"})});m(this,"_restoreToolId","select");m(this,"_pinchStart",1);m(this,"_didPinch",!1);m(this,"_selectedShapeIdsAtPointerDown",[]);m(this,"_longPressTimeout",-1);m(this,"capturedPointerId",null);m(this,"dispatch",n=>(this._pendingEventsForNextTick.push(n),n.type==="pointer"&&n.name==="pointer_move"||n.type==="wheel"||n.type==="pinch"||this._flushEventsForTick(0),this));m(this,"_pendingEventsForNextTick",[]);m(this,"_flushEventForTick",n=>{if(this.getCrashingError())return this;const{inputs:r}=this,{type:o}=n;if(n.type==="misc"){(n.name==="cancel"||n.name==="complete")&&(this.inputs.isDragging=!1,this.inputs.isPanning&&(this.inputs.isPanning=!1,this.updateInstanceState({cursor:{type:this._prevCursor,rotation:0}}))),this.root.handleEvent(n);return}n.shiftKey?(clearInterval(this._shiftKeyTimeout),this._shiftKeyTimeout=-1,r.shiftKey=!0):!n.shiftKey&&r.shiftKey&&this._shiftKeyTimeout===-1&&(this._shiftKeyTimeout=setTimeout(this._setShiftKeyTimeout,150)),n.altKey?(clearInterval(this._altKeyTimeout),this._altKeyTimeout=-1,r.altKey=!0):!n.altKey&&r.altKey&&this._altKeyTimeout===-1&&(this._altKeyTimeout=setTimeout(this._setAltKeyTimeout,150)),n.ctrlKey?(clearInterval(this._ctrlKeyTimeout),this._ctrlKeyTimeout=-1,r.ctrlKey=!0):!n.ctrlKey&&r.ctrlKey&&this._ctrlKeyTimeout===-1&&(this._ctrlKeyTimeout=setTimeout(this._setCtrlKeyTimeout,150));const{originPagePoint:s,originScreenPoint:i,currentPagePoint:a,currentScreenPoint:c}=r;switch(r.isPointing||(r.isDragging=!1),o){case"pinch":{if(!this.getInstanceState().canMoveCamera)return;switch(clearTimeout(this._longPressTimeout),this._updateInputsFromEvent(n),n.name){case"pinch_start":{if(r.isPinching)return;r.isEditing||(this._pinchStart=this.getCamera().z,this._selectedShapeIdsAtPointerDown.length||(this._selectedShapeIdsAtPointerDown=this.getSelectedShapeIds()),this._didPinch=!0,r.isPinching=!0,this.interrupt());return}case"pinch":{if(!r.isPinching)return;const{point:{z:l=1},delta:{x:u,y:d}}=n,{screenBounds:p}=this.store.unsafeGetWithoutCapture(In),{x:f,y}=P.SubXY(n.point,p.x,p.y),{x:g,y:w,z:S}=this.getCamera(),v=Math.min(xs,Math.max(qc,l));this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),this._setCamera({x:g+u/S-f/S+f/v,y:w+d/S-y/S+y/v,z:v},!0);return}case"pinch_end":{if(!r.isPinching)return this;r.isPinching=!1;const{_selectedShapeIdsAtPointerDown:l}=this;this.setSelectedShapes(this._selectedShapeIdsAtPointerDown,{squashing:!0}),this._selectedShapeIdsAtPointerDown=[],this._didPinch&&(this._didPinch=!1,this.once("tick",()=>{this._didPinch||this.setSelectedShapes(l,{squashing:!0})}));return}}}case"wheel":{if(!this.getInstanceState().canMoveCamera)return;if(this._updateInputsFromEvent(n),!this.getIsMenuOpen()){if(this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),r.ctrlKey){const{x:p,y:f}=this.inputs.currentScreenPoint,{x:y,y:g,z:w}=this.getCamera(),S=Math.min(xs,Math.max(qc,w+(n.delta.z??0)*w));this._setCamera({x:y+(p/S-p)-(p/w-p),y:g+(f/S-f)-(f/w-f),z:S},!0);return}const{x:l,y:u,z:d}=this.getCamera();this._setCamera({x:l+n.delta.x/d,y:u+n.delta.y/d,z:d},!0),!r.isDragging&&r.isPointing&&P.Dist2(s,a)>(this.getInstanceState().isCoarsePointer?BS:iu)/this.getZoomLevel()&&(clearTimeout(this._longPressTimeout),r.isDragging=!0)}break}case"pointer":{if(r.isPinching)return;this._updateInputsFromEvent(n);const{isPen:l}=n;switch(n.name){case"pointer_down":{if(this.clearOpenMenus(),this._longPressTimeout=setTimeout(()=>{this.dispatch({...n,name:"long_press"})},B5),this._selectedShapeIdsAtPointerDown=this.getSelectedShapeIds(),n.button===0&&(this.capturedPointerId=n.pointerId),r.buttons.add(n.button),r.isPointing=!0,r.isDragging=!1,this.getInstanceState().isPenMode){if(!l)return}else l&&this.updateInstanceState({isPenMode:!0});if(n.button===5?(this._restoreToolId=this.getCurrentToolId(),this.complete(),this.setCurrentTool("eraser")):n.button===1&&(this.inputs.isPanning||(this._prevCursor=this.getInstanceState().cursor.type),this.inputs.isPanning=!0),this.inputs.isPanning)return this.stopCameraAnimation(),this.setCursor({type:"grabbing",rotation:0}),this;i.setTo(c),s.setTo(a);break}case"pointer_move":{if(!l&&this.getInstanceState().isPenMode)return;if(this.inputs.isPanning&&this.inputs.isPointing){clearTimeout(this._longPressTimeout);const{currentScreenPoint:u,previousScreenPoint:d}=this.inputs;this.pan(P.Sub(u,d));return}!r.isDragging&&r.isPointing&&P.Dist2(s,a)>(this.getInstanceState().isCoarsePointer?BS:iu)/this.getZoomLevel()&&(clearTimeout(this._longPressTimeout),r.isDragging=!0);break}case"pointer_up":{if(r.buttons.delete(n.button),r.isPointing=!1,r.isDragging=!1,this.getIsMenuOpen()||!l&&this.getInstanceState().isPenMode)return;this.capturedPointerId===n.pointerId&&(this.capturedPointerId=null,n.button=0),r.isPanning?n.button===1?this.inputs.keys.has(" ")?(this.slideCamera({speed:Math.min(2,this.inputs.pointerVelocity.len()),direction:this.inputs.pointerVelocity,friction:Sh}),this.setCursor({type:"grab",rotation:0})):(r.isPanning=!1,this.slideCamera({speed:Math.min(2,this.inputs.pointerVelocity.len()),direction:this.inputs.pointerVelocity,friction:Sh}),this.setCursor({type:this._prevCursor,rotation:0})):n.button===0&&(this.slideCamera({speed:Math.min(2,this.inputs.pointerVelocity.len()),direction:this.inputs.pointerVelocity,friction:Sh}),this.setCursor({type:"grab",rotation:0})):n.button===5&&(this.complete(),this.setCurrentTool(this._restoreToolId));break}}break}case"keyboard":{switch(n.key==="ShiftRight"&&(n.key="ShiftLeft"),n.key==="AltRight"&&(n.key="AltLeft"),n.code==="ControlRight"&&(n.code="ControlLeft"),n.name){case"key_down":{r.keys.add(n.code),!n.ctrlKey&&n.code==="Space"&&(this.inputs.isPanning||(this._prevCursor=this.getInstanceState().cursor.type),this.inputs.isPanning=!0,this.setCursor({type:this.inputs.isPointing?"grabbing":"grab",rotation:0}));break}case"key_up":{r.keys.delete(n.code),n.code==="Space"&&!this.inputs.buttons.has(1)&&(this.inputs.isPanning=!1,this.setCursor({type:this._prevCursor,rotation:0}));break}}break}}if(n.type==="pointer"&&(n.button===1?n.name="middle_click":n.button===2&&(n.name="right_click"),n.isPen===this.getInstanceState().isPenMode))switch(n.name){case"pointer_down":{const l=this._clickManager.transformPointerDownEvent(n);if(n.name!==l.name){this.root.handleEvent(n),this.emit("event",n),this.root.handleEvent(l),this.emit("event",l);return}break}case"pointer_up":{clearTimeout(this._longPressTimeout);const l=this._clickManager.transformPointerUpEvent(n);if(n.name!==l.name){this.root.handleEvent(n),this.emit("event",n),this.root.handleEvent(l),this.emit("event",l);return}break}case"pointer_move":{this._clickManager.handleMove();break}}return this.root.handleEvent(n),this.emit("event",n),this});this.store=n,this.snaps=new Uf(this),this.user=new Hr(r??k2(),c??!1),this.getContainer=i??(()=>document.body),this.textMeasure=new mz(this),this._tickManager=new yz(this);class l extends bh{}m(l,"initial",a??""),this.root=new l(this),this.root.children={};const u=A2(o),d={},p={},f=new Map;for(const b of u){const E=new b(this);d[b.type]=E;const C=uk(b.props??{});p[b.type]=C;for(const I of C.keys())if(!f.has(I.id))f.set(I.id,I);else if(f.get(I.id)!==I)throw Error(`Multiple style props with id "${I.id}" in use. Style prop IDs must be unique.`)}this.shapeUtils=d,this.styleProps=p;for(const b of[...s]){if(ro(this.root.children,b.id))throw Error(`Can't override tool with id "${b.id}"`);this.root.children[b.id]=new b(this,this.root)}this.environment=new Z4(this),this.scribbles=new tz(this);const y=new Set,g=b=>{var Q;const E=this.getShape(b);if(!E)return;const{start:C,end:I}=E.props,_=C.type==="binding"?this.getShape(C.boundShapeId):void 0,k=I.type==="binding"?this.getShape(I.boundShapeId):void 0,$=this.getAncestorPageId(E);if(!$)return;let T;if(_&&k)T=this.findCommonAncestor([_,k])??$;else if(_||k){const H=(Q=_||k)==null?void 0:Q.parentId;H&&H===E.parentId?T=E.parentId:T=$}else return;T&&T!==E.parentId&&this.reparentShapes([b],T);const O=this.getShape(b);if(!O)throw Error("no reparented arrow");const N=this.getShapeNearestSibling(O,_),F=this.getShapeNearestSibling(O,k);let L;if(N&&F)L=N.index>F.index?N:F;else if(N&&!F)L=N;else if(F&&!N)L=F;else return;let B;const q=this.getSortedChildIdsForParent(L.parentId).map(H=>this.getShape(H)).filter(H=>H.index>L.index);if(q.length){const H=q.find(U=>U.type!=="arrow");if(O.index>L.index&&(!H||O.index<H.index))return;B=kl(L.index,q[0].index)}else B=$o(L.index);B!==O.index&&this.updateShapes([{id:b,type:"arrow",index:B}])},w=(b,E)=>{const{x:C,y:I}=jr(this,b)[E];this.store.put([{...b,props:{...b.props,[E]:{type:"point",x:C,y:I}}}])},S=b=>{for(const E of["start","end"]){const C=b.props[E];if(C.type!=="binding")continue;const I=this.getShape(C.boundShapeId),_=this.getAncestorPageId(b)===this.getAncestorPageId(I);(!I||!_)&&w(b,E)}g(b.id)},v=(b,E)=>{let C=null;const I=b.selectedShapeIds.filter($=>!E.has($));I.length!==b.selectedShapeIds.length&&(C||(C={...b}),C.selectedShapeIds=I);const _=b.erasingShapeIds.filter($=>!E.has($));_.length!==b.erasingShapeIds.length&&(C||(C={...b}),C.erasingShapeIds=_),b.hoveredShapeId&&E.has(b.hoveredShapeId)&&(C||(C={...b}),C.hoveredShapeId=null),b.editingShapeId&&E.has(b.editingShapeId)&&(C||(C={...b}),C.editingShapeId=null);const k=b.hintingShapeIds.filter($=>!E.has($));return k.length!==b.hintingShapeIds.length&&(C||(C={...b}),C.hintingShapeIds=k),b.focusedGroupId&&E.has(b.focusedGroupId)&&(C||(C={...b}),C.focusedGroupId=null),C};if(this.sideEffects=new nz(this),this.sideEffects.registerBatchCompleteHandler(()=>{var b;for(const E of y){y.delete(E);const C=this.getShape(E);if(!C)continue;const I=this.getShapeUtil(C),_=(b=I.onChildrenChange)==null?void 0:b.call(I,C);_!=null&&_.length&&this.updateShapes(_,{squashing:!0})}this.emit("update")}),this.sideEffects.registerBeforeDeleteHandler("shape",b=>{b.parentId&&Kn(b.parentId)&&y.add(b.parentId);const E=this._getArrowBindingsIndex().get()[b.id];if(E!=null&&E.length)for(const{arrowId:_,handleId:k}of E){const $=this.getShape(_);$&&w($,k)}const C=new Set([b.id]),I=fe(this.getPageStates().map(_=>v(_,C)));I.length&&this.store.put(I)}),this.sideEffects.registerBeforeDeleteHandler("page",b=>{var _;if(this.getInstanceState().currentPageId!==b.id)return;const E=(_=this.getPages().find(k=>k.id!==b.id))==null?void 0:_.id;if(!E)return;this.store.put([{...this.getInstanceState(),currentPageId:E}]);const C=hn.createId(b.id),I=Zt.createId(b.id);this.store.remove([C,I])}),this.sideEffects.registerAfterChangeHandler("shape",(b,E)=>{if(this.isShapeOfType(E,"arrow")&&S(E),b.parentId!==E.parentId){const C=I=>{const _=this._getArrowBindingsIndex().get()[I];if(_!=null&&_.length)for(const k of _)g(k.arrowId)};C(E.id),this.visitDescendants(E.id,C)}if(b.parentId!==E.parentId&&bn(E.parentId)){const C=new Set([b.id]);this.visitDescendants(b.id,I=>{C.add(I)});for(const I of this.getPageStates()){if(I.pageId===E.parentId)continue;const _=v(I,C);_&&this.store.put([_])}}b.parentId&&Kn(b.parentId)&&y.add(b.parentId),E.parentId!==b.parentId&&Kn(E.parentId)&&y.add(E.parentId)}),this.sideEffects.registerAfterChangeHandler("instance_page_state",(b,E)=>{if((b==null?void 0:b.selectedShapeIds)!==(E==null?void 0:E.selectedShapeIds)){const C=E.selectedShapeIds.filter(_=>{var $,T;let k=($=this.getShape(_))==null?void 0:$.parentId;for(;Kn(k);){if(E.selectedShapeIds.includes(k))return!1;k=(T=this.getShape(k))==null?void 0:T.parentId}return!0});let I=null;if(C.length>0){const _=this.findCommonAncestor(fe(C.map(k=>this.getShape(k))),k=>this.isShapeOfType(k,"group"));_&&(I=_)}else E!=null&&E.focusedGroupId&&(I=E.focusedGroupId);(C.length!==E.selectedShapeIds.length||I!==E.focusedGroupId)&&this.store.put([{...E,selectedShapeIds:C,focusedGroupId:I??null}])}}),this.sideEffects.registerAfterCreateHandler("shape",b=>{this.isShapeOfType(b,"arrow")&&S(b)}),this.sideEffects.registerAfterCreateHandler("page",b=>{const E=hn.createId(b.id),C=Zt.createId(b.id);this.store.has(E)||this.store.put([hn.create({id:E})]),this.store.has(C)||this.store.put([Zt.create({id:C,pageId:b.id})])}),this._currentPageShapeIds=V4(this.store,()=>this.getCurrentPageId()),this._parentIdsToChildIds=W4(this.store),this.disposables.add(this.store.listen(b=>{this.emit("change",b)})),this.store.ensureStoreIsUsable(),this._setInstancePageState({editingShapeId:null,hoveredShapeId:null,erasingShapeIds:[]},{ephemeral:!0}),a&&this.root.children[a]===void 0)throw Error(`No state found for initialState "${a}".`);this.root.enter(void 0,"initial"),this.getInstanceState().followingUserId&&this.stopFollowingUser(),this.updateRenderingBounds(),this.on("tick",this._flushEventsForTick),requestAnimationFrame(()=>{this._tickManager.start()})}dispose(){this.disposables.forEach(n=>n()),this.disposables.clear()}getShapeUtil(n){const r=typeof n=="string"?n:n.type,o=Lr(this.shapeUtils,r);return _t(o,`No shape util found for type "${r}"`),o}undo(){return this._flushEventsForTick(0),this.history.undo(),this}getCanUndo(){return this.history.getNumUndos()>0}redo(){return this._flushEventsForTick(0),this.history.redo(),this}getCanRedo(){return this.history.getNumRedos()>0}mark(n,r,o){return this.history.mark(n,r,o),this}bail(){return this.history.bail(),this}bailToMark(n){return this.history.bailToMark(n),this}batch(n){return this.history.batch(n),this}_getArrowBindingsIndex(){return U4(this)}getArrowsBoundTo(n){return this._getArrowBindingsIndex().get()[n]||Do}getArrowInfoCache(){return this.store.createComputedCache("arrow infoCache",n=>Zc(n)?Al(this,n):xm(this,n))}getArrowInfo(n){const r=typeof n=="string"?n:n.id;return this.getArrowInfoCache().get(r)}annotateError(n,{origin:r,willCrashApp:o,tags:s,extras:i}){const a=this.createErrorAnnotations(r,o);return D0(n,{tags:{...a.tags,...s},extras:{...a.extras,...i}}),o&&this.store.markAsPossiblyCorrupted(),this}createErrorAnnotations(n,r){try{const o=this.getEditingShapeId();return{tags:{origin:n,willCrashApp:r},extras:{activeStateNode:this.root.getPath(),selectedShapes:this.getSelectedShapes(),editingShape:o?this.getShape(o):void 0,inputs:this.inputs}}}catch{return{tags:{origin:n,willCrashApp:r},extras:{}}}}getCrashingError(){return this._crashingError}crash(n){return this._crashingError=n,this.store.markAsPossiblyCorrupted(),this.emit("crash",{error:n}),this}getPath(){return this.root.getPath().split("root.")[1]}isIn(n){const r=n.split(".").reverse();let o=this.root;for(;r.length>0;){const s=r.pop();if(!s)return!0;const i=o.getCurrent();if((i==null?void 0:i.id)===s){if(r.length===0)return!0;o=i;continue}else return!1}return!1}isInAny(...n){return n.some(r=>this.isIn(r))}setCurrentTool(n,r={}){return this.root.transition(n,r),this}getCurrentTool(){return this.root.getCurrent()}getCurrentToolId(){const n=this.getCurrentTool();return n?n.getCurrentToolIdMask()??n.id:""}getStateDescendant(n){var s;const r=n.split(".").reverse();let o=this.root;for(;r.length>0;){const i=r.pop();if(!i)return o;const a=(s=o.children)==null?void 0:s[i];if(!a)return;o=a}return o}getDocumentSettings(){return this.store.get(FS)}updateDocumentSettings(n){return this.store.put([{...this.getDocumentSettings(),...n}]),this}getInstanceState(){return this.store.get(In)}updateInstanceState(n,r){return this._updateInstanceState(n,{ephemeral:!0,squashing:!0,...r}),n.isChangingStyle!==void 0&&(clearTimeout(this._isChangingStyleTimeout),n.isChangingStyle===!0&&(this._isChangingStyleTimeout=setTimeout(()=>{this.updateInstanceState({isChangingStyle:!1},{ephemeral:!0})},2e3))),this}getOpenMenus(){return this.getInstanceState().openMenus}addOpenMenu(n){const r=new Set(this.getOpenMenus());return r.has(n)||(r.add(n),this.updateInstanceState({openMenus:[...r]})),this}deleteOpenMenu(n){const r=new Set(this.getOpenMenus());return r.has(n)&&(r.delete(n),this.updateInstanceState({openMenus:[...r]})),this}clearOpenMenus(){return this.getOpenMenus().length&&this.updateInstanceState({openMenus:[]}),this}getIsMenuOpen(){return this.getOpenMenus().length>0}getPageStates(){return this._getPageStatesQuery().get()}_getPageStatesQuery(){return this.store.query.records("instance_page_state")}getCurrentPageState(){return this.store.get(this._getCurrentPageStateId())}_getCurrentPageStateId(){return Zt.createId(this.getCurrentPageId())}updateCurrentPageState(n,r){return this._setInstancePageState(n,r),this}getSelectedShapeIds(){return this.getCurrentPageState().selectedShapeIds}getSelectedShapes(){const{selectedShapeIds:n}=this.getCurrentPageState();return fe(n.map(r=>this.store.get(r)))}setSelectedShapes(n,r){const o=n.map(s=>typeof s=="string"?s:s.id);return this._setSelectedShapes(o,r),this}select(...n){const r=typeof n[0]=="string"?n:n.map(o=>o.id);return this.setSelectedShapes(r),this}deselect(...n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=this.getSelectedShapeIds();return o.length>0&&r.length>0&&this.setSelectedShapes(o.filter(s=>!r.includes(s))),this}selectAll(){const n=this.getSortedChildIdsForParent(this.getCurrentPageId());return n.length<=0?this:(this.setSelectedShapes(this._getUnlockedShapeIds(n)),this)}selectNone(){return this.getSelectedShapeIds().length>0&&this.setSelectedShapes([]),this}getOnlySelectedShapeId(){var n;return((n=this.getOnlySelectedShape())==null?void 0:n.id)??null}getOnlySelectedShape(){const n=this.getSelectedShapes();return n.length===1?n[0]:null}getSelectionPageBounds(){const n=this.getCurrentPageState().selectedShapeIds;return n.length===0?null:ne.Common(fe(n.map(r=>this.getShapePageBounds(r))))}getSelectionRotation(){const n=this.getSelectedShapeIds();let r=!1,o=0;for(let s=0,i=n.length;s<i;s++){const a=this.getShapePageTransform(n[s]);if(a)if(r){if(a.rotation()!==o)return 0}else r=!0,o=a.rotation()}return o}getSelectionRotatedPageBounds(){const n=this.getSelectedShapeIds();if(n.length===0)return;const r=this.getSelectionRotation();if(r===0)return this.getSelectionPageBounds();if(n.length===1){const s=this.getShapeGeometry(n[0]).bounds.clone(),i=this.getShapePageTransform(n[0]);return s.point=i.applyToPoint(s.point),s}const o=ne.FromPoints(this.getSelectedShapeIds().flatMap(s=>{const i=this.getShapePageTransform(s);return i?i.applyToPoints(this.getShapeGeometry(s).bounds.corners):[]}).map(s=>s.rot(-r)));return o.point=o.point.rot(r),o}getSelectionRotatedScreenBounds(){const n=this.getSelectionRotatedPageBounds();if(!n)return;const{x:r,y:o}=this.pageToScreen(n.point),s=this.getZoomLevel();return new ne(r,o,n.width*s,n.height*s)}getFocusedGroupId(){return this.getCurrentPageState().focusedGroupId??this.getCurrentPageId()}getFocusedGroup(){const n=this.getFocusedGroupId();return n?this.getShape(n):void 0}setFocusedGroup(n){const r=typeof n=="string"?n:(n==null?void 0:n.id)??null;if(r!==null){const o=this.getShape(r);if(!o)throw Error(`Editor.setFocusedGroup: Shape with id ${r} does not exist`);if(!this.isShapeOfType(o,"group"))throw Error(`Editor.setFocusedGroup: Cannot set focused group to shape of type ${o.type}`)}return r===this.getFocusedGroupId()?this:(this._setFocusedGroupId(r),this)}popFocusedGroupId(){const n=this.getFocusedGroup();if(n){const r=this.findShapeAncestor(n,o=>this.isShapeOfType(o,"group"));this.setFocusedGroup((r==null?void 0:r.id)??null),this.select(n.id)}else this.setFocusedGroup(null),this.selectNone();return this}getEditingShapeId(){return this.getCurrentPageState().editingShapeId}getEditingShape(){const n=this.getEditingShapeId();return n?this.getShape(n):void 0}setEditingShape(n){const r=typeof n=="string"?n:(n==null?void 0:n.id)??null;if(r!==this.getEditingShapeId()){if(r){const o=this.getShape(r);if(o&&this.getShapeUtil(o).canEdit(o))return this._setInstancePageState({editingShapeId:r}),this}this._setInstancePageState({editingShapeId:null})}return this}getHoveredShapeId(){return this.getCurrentPageState().hoveredShapeId}getHoveredShape(){const n=this.getHoveredShapeId();return n?this.getShape(n):void 0}setHoveredShape(n){const r=typeof n=="string"?n:(n==null?void 0:n.id)??null;return r===this.getHoveredShapeId()?this:(this.updateCurrentPageState({hoveredShapeId:r},{ephemeral:!0}),this)}getHintingShapeIds(){return this.getCurrentPageState().hintingShapeIds}getHintingShape(){const n=this.getHintingShapeIds();return fe(n.map(r=>this.getShape(r)))}setHintingShapes(n){const r=typeof n[0]=="string"?n:n.map(o=>o.id);return this.updateCurrentPageState({hintingShapeIds:Mp(r)},{ephemeral:!0}),this}getErasingShapeIds(){return this.getCurrentPageState().erasingShapeIds}getErasingShapes(){const n=this.getErasingShapeIds();return fe(n.map(r=>this.getShape(r)))}setErasingShapes(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id);r.sort();const o=this.getErasingShapeIds();if(r.length===o.length){for(let s=0;s<r.length;s++)if(r[s]!==o[s]){this._setInstancePageState({erasingShapeIds:r},{ephemeral:!0});break}}else this._setInstancePageState({erasingShapeIds:r},{ephemeral:!0});return this}getCroppingShapeId(){return this.getCurrentPageState().croppingShapeId}setCroppingShape(n){const r=typeof n=="string"?n:(n==null?void 0:n.id)??null;if(r!==this.getCroppingShapeId())if(!r)this.updateCurrentPageState({croppingShapeId:null});else{const o=this.getShape(r),s=this.getShapeUtil(o);o&&s.canCrop(o)&&this.updateCurrentPageState({croppingShapeId:r})}return this}getCameraId(){return hn.createId(this.getCurrentPageId())}getCamera(){return this.store.get(this.getCameraId())}getZoomLevel(){return this.getCamera().z}_setCamera(n,r=!1){const o=this.getCamera();return o.x===n.x&&o.y===n.y&&o.z===n.z?this:(this.batch(()=>{const s={...o,...n};this.store.put([s]);const{currentScreenPoint:i,currentPagePoint:a}=this.inputs,{screenBounds:c}=this.store.unsafeGetWithoutCapture(In);if(i.x/s.z-s.x!==a.x||i.y/s.z-s.y!==a.y){const l={type:"pointer",target:"canvas",name:"pointer_move",point:P.AddXY(i,c.x,c.y),pointerId:b1.CAMERA_MOVE,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,shiftKey:this.inputs.shiftKey,button:0,isPen:this.getInstanceState().isPenMode??!1};r?this._flushEventForTick(l):this.dispatch(l)}this._tickCameraState()}),this)}setCamera(n,r){const o=Number.isFinite(n.x)?n.x:0,s=Number.isFinite(n.y)?n.y:0,i=Number.isFinite(n.z)?n.z:this.getZoomLevel();if(this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),r){const{width:a,height:c}=this.getViewportScreenBounds();return this._animateToViewport(new ne(-o,-s,a/i,c/i),r)}else this._setCamera({x:o,y:s,z:i});return this}centerOnPoint(n,r){if(!this.getInstanceState().canMoveCamera)return this;const{width:o,height:s}=this.getViewportPageBounds();return this.setCamera({x:-(n.x-o/2),y:-(n.y-s/2),z:this.getCamera().z},r),this}zoomToContent(n={duration:220}){const r=this.getSelectionPageBounds()??this.getCurrentPageBounds();return r&&this.zoomToBounds(r,{targetZoom:Math.min(1,this.getZoomLevel()),...n}),this}zoomToFit(n){if(!this.getInstanceState().canMoveCamera)return this;const r=[...this.getCurrentPageShapeIds()];if(r.length<=0)return this;const o=ne.Common(fe(r.map(s=>this.getShapePageBounds(s))));return this.zoomToBounds(o,n),this}resetZoom(n=this.getViewportScreenCenter(),r){if(!this.getInstanceState().canMoveCamera)return this;const{x:o,y:s,z:i}=this.getCamera(),{x:a,y:c}=n;return this.setCamera({x:o+(a/1-a)-(a/i-a),y:s+(c/1-c)-(c/i-c),z:1},r),this}zoomIn(n=this.getViewportScreenCenter(),r){if(!this.getInstanceState().canMoveCamera)return this;const{x:o,y:s,z:i}=this.getCamera();let a=xs;for(let u=1;u<ta.length;u++){const d=ta[u-1],p=ta[u];if(!(p-i<=(p-d)/2)){a=p;break}}const{x:c,y:l}=n;return this.setCamera({x:o+(c/a-c)-(c/i-c),y:s+(l/a-l)-(l/i-l),z:a},r),this}zoomOut(n=this.getViewportScreenCenter(),r){if(!this.getInstanceState().canMoveCamera)return this;const{x:o,y:s,z:i}=this.getCamera();let a=qc;for(let u=ta.length-1;u>0;u--){const d=ta[u-1],p=ta[u];if(!(p-i>=(p-d)/2)){a=d;break}}const{x:c,y:l}=n;return this.setCamera({x:o+(c/a-c)-(c/i-c),y:s+(l/a-l)-(l/i-l),z:a},r),this}zoomToSelection(n){if(!this.getInstanceState().canMoveCamera)return this;const r=this.getSelectionPageBounds();return r?(this.zoomToBounds(r,{targetZoom:Math.max(1,this.getZoomLevel()),...n}),this):this}panZoomIntoView(n,r){if(!this.getInstanceState().canMoveCamera)return this;if(n.length<=0)return this;const o=ne.Common(fe(n.map(i=>this.getShapePageBounds(i)))),s=this.getViewportPageBounds();if(s.h<o.h||s.w<o.w)return this.zoomToBounds(o,{targetZoom:this.getCamera().z,...r}),this;{const i=this.getViewportPageBounds().clone().expandBy(-32/this.getZoomLevel());let a=0,c=0;i.maxY<o.maxY?c=i.maxY-o.maxY:i.minY>o.minY&&(c=i.minY-o.minY),i.maxX<o.maxX?a=i.maxX-o.maxX:i.minX>o.minX&&(a=i.minX-o.minX);const l=this.getCamera();this.setCamera({x:l.x+a,y:l.y+c,z:l.z},r)}return this}zoomToBounds(n,r){if(!this.getInstanceState().canMoveCamera)return this;const o=this.getViewportScreenBounds(),s=(r==null?void 0:r.inset)??Math.min(256,o.width*.28);let i=Ns(Math.min((o.width-s)/n.width,(o.height-s)/n.height),qc,xs);return(r==null?void 0:r.targetZoom)!==void 0&&(i=Math.min(r.targetZoom,i)),this.setCamera({x:-n.minX+(o.width-n.width*i)/2/i,y:-n.minY+(o.height-n.height*i)/2/i,z:i},r),this}pan(n,r){if(!this.getInstanceState().canMoveCamera)return this;const{x:o,y:s,z:i}=this.getCamera();return this.setCamera({x:o+n.x/i,y:s+n.y/i,z:i},r),this._flushEventsForTick(0),this}stopCameraAnimation(){return this.emit("stop-camera-animation"),this}_animateViewport(n){if(!this._viewportAnimation)return;const r=()=>{this.removeListener("tick",this._animateViewport),this.removeListener("stop-camera-animation",r),this._viewportAnimation=null};this.once("stop-camera-animation",r),this._viewportAnimation.elapsed+=n;const{elapsed:o,easing:s,duration:i,start:a,end:c}=this._viewportAnimation;if(o>i){this._setCamera({x:-c.x,y:-c.y,z:this.getViewportScreenBounds().width/c.width}),r();return}const l=i-o,u=s(1-l/i),d=a.minX+(c.minX-a.minX)*u,p=a.minY+(c.minY-a.minY)*u,f=a.maxX+(c.maxX-a.maxX)*u;this._setCamera({x:-d,y:-p,z:this.getViewportScreenBounds().width/(f-d)})}_animateToViewport(n,r={}){const{duration:o=0,easing:s=nn.easeInOutCubic}=r,i=this.user.getAnimationSpeed(),a=this.getViewportPageBounds();return this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),o===0||i===0?this._setCamera({x:-n.x,y:-n.y,z:this.getViewportScreenBounds().width/n.width}):(this._viewportAnimation={elapsed:0,duration:o/i,easing:s,start:a.clone(),end:n.clone()},this.addListener("tick",this._animateViewport),this)}slideCamera(n={}){if(!this.getInstanceState().canMoveCamera)return this;if(this.stopCameraAnimation(),this.user.getAnimationSpeed()===0)return this;const{speed:o,friction:s,direction:i,speedThreshold:a=.01}=n;let c=Math.min(o,1);const l=()=>{this.removeListener("tick",u),this.removeListener("stop-camera-animation",l)};this.once("stop-camera-animation",l);const u=d=>{const{x:p,y:f,z:y}=this.getCamera(),g=P.Mul(i,c*d/y);c*=1-s,c<a?l():this._setCamera({x:p+g.x,y:f+g.y,z:y})};return this.addListener("tick",u),this}animateToUser(n){const r=this.getCollaborators().find(o=>o.userId===n);return r?(this.batch(()=>{this.getInstanceState().followingUserId!==null&&this.stopFollowingUser();const o=r.currentPageId===this.getCurrentPageId();o||this.setCurrentPage(r.currentPageId);const s=o?{duration:500}:void 0;this.centerOnPoint(r.cursor,s);const{highlightedUserIds:i}=this.getInstanceState();this.updateInstanceState({highlightedUserIds:[...i,n]}),setTimeout(()=>{const a=[...this.getInstanceState().highlightedUserIds],c=a.indexOf(n);c<0||(a.splice(c,1),this.updateInstanceState({highlightedUserIds:a}))},Vk)}),this):this}animateToShape(n,r=j5){if(!this.getInstanceState().canMoveCamera)return this;const o=this.getViewportScreenBounds().clone().expandBy(-32),s=o.width/o.height,i=this.getShapePageBounds(n);if(!i)return this;const a=i.width/i.height,c=i.clone(),l=i.width/o.width;return c.width+=(o.minX+o.maxX)*l,c.height+=(o.minY+o.maxY)*l,c.x-=o.minX*l,c.y-=o.minY*l,a>s?(c.height=i.width/s,c.y-=(c.height-i.height)/2):(c.width=i.height*s,c.x-=(c.width-i.width)/2),this._animateToViewport(c,r)}updateViewportScreenBounds(n,r=!1){n.width=Math.max(n.width,1),n.height=Math.max(n.height,1);const o=[n.minY!==0,document.body.scrollWidth!==n.maxX,document.body.scrollHeight!==n.maxY,n.minX!==0],s=n.equals(this.getViewportScreenBounds()),{_willSetInitialBounds:i}=this;if(s)this._willSetInitialBounds=!1;else if(i)this._willSetInitialBounds=!1,this.updateInstanceState({screenBounds:n.toJson(),insets:o},{squashing:!0,ephemeral:!0});else if(r&&!this.getInstanceState().followingUserId){const a=this.getViewportPageCenter();this.updateInstanceState({screenBounds:n.toJson(),insets:o},{squashing:!0,ephemeral:!0}),this.centerOnPoint(a)}else this.updateInstanceState({screenBounds:n.toJson(),insets:o},{squashing:!0,ephemeral:!0});return this._tickCameraState(),this.updateRenderingBounds(),this}getViewportScreenBounds(){const{x:n,y:r,w:o,h:s}=this.getInstanceState().screenBounds;return new ne(n,r,o,s)}getViewportScreenCenter(){const n=this.getViewportScreenBounds();return new P(n.midX-n.minX,n.midY-n.minY)}getViewportPageBounds(){const{w:n,h:r}=this.getViewportScreenBounds(),{x:o,y:s,z:i}=this.getCamera();return new ne(-o,-s,n/i,r/i)}getViewportPageCenter(){return this.getViewportPageBounds().center}screenToPage(n){const{screenBounds:r}=this.store.unsafeGetWithoutCapture(In),{x:o,y:s,z:i=1}=this.getCamera();return{x:(n.x-r.x)/i-o,y:(n.y-r.y)/i-s,z:n.z??.5}}pageToScreen(n){const r=this.getViewportScreenBounds(),{x:o,y:s,z:i=1}=this.getCamera();return{x:(n.x+o)*i+r.x,y:(n.y+s)*i+r.y,z:n.z??.5}}pageToViewport(n){const{x:r,y:o,z:s=1}=this.getCamera();return{x:(n.x+r)*s,y:(n.y+o)*s,z:n.z??.5}}_getCollaboratorsQuery(){return this.store.query.records("instance_presence",()=>({userId:{neq:this.user.getId()}}))}getCollaborators(){const n=this._getCollaboratorsQuery().get();return n.length?[...new Set(n.map(o=>o.userId))].sort().map(o=>n.filter(i=>i.userId===o).sort((i,a)=>a.lastActivityTimestamp-i.lastActivityTimestamp)[0]):Do}getCollaboratorsOnCurrentPage(){const n=this.getCurrentPageId();return this.getCollaborators().filter(r=>r.currentPageId===n)}startFollowingUser(n){const r=this._getCollaboratorsQuery().get().filter(c=>c.userId===n),o=this.user.getId();if(o||console.warn("You should set the userId for the current instance before following a user"),r.some(c=>c.followingUserId===o))return this;Mr(()=>{this.stopFollowingUser(),this.updateInstanceState({followingUserId:n},{ephemeral:!0})});const s=()=>{this.removeListener("frame",a),this.removeListener("stop-following",s)};let i=!1;const a=()=>{const c=[...r].sort((F,L)=>F.lastActivityTimestamp-L.lastActivityTimestamp).pop();if(!c){this.stopFollowingUser();return}const l=c.currentPageId===this.getCurrentPageId(),u=l?I5:1;if(!l){this.stopFollowingUser(),this.setCurrentPage(c.currentPageId),this.startFollowingUser(n);return}const{center:d,width:p,height:f}=this.getViewportPageBounds(),y=ne.From(c.screenBounds),g=y.width/c.camera.z,w=y.height/c.camera.z,S=new P(g/2-c.camera.x,w/2-c.camera.y),v=c.followingUserId===o,b=p+(g-p)*u,E=f+(w-f)*u,C=v?f/E:Math.min(p/b,f/E),I=Ns(this.getCamera().z*C,qc,xs),_=this.getViewportScreenBounds().w/I,k=this.getViewportScreenBounds().h/I,$=S.sub(d),T=P.Add(d,P.Mul($,u)),O=P.Sub(T,d).len(),N=Math.abs(I-this.getCamera().z);if(O<E5&&N<k5){i=!0;return}i&&O<_5&&N<T5||(i=!1,this.stopCameraAnimation(),this._setCamera({x:-(T.x-_/2),y:-(T.y-k/2),z:I}))};return this.once("stop-following",s),this.addListener("frame",a),this}stopFollowingUser(){return this.updateInstanceState({followingUserId:null},{ephemeral:!0}),this.emit("stop-following"),this}getCameraState(){return this._cameraState.get()}getUnorderedRenderingShapes(n){const r=[];let o=Io*2,s=Io;const i=this.getErasingShapeIds(),a=(l,u,d)=>{const p=this.getShape(l);if(!p)return;u*=p.opacity;let f=!1;const y=this.getShapeUtil(p);n&&(f=!d&&i.includes(l),f&&(u*=.32)),r.push({id:l,shape:p,util:y,index:o,backgroundIndex:s,opacity:u}),o+=1,s+=1;const g=this.getSortedChildIdsForParent(l);if(!g.length)return;let w=null;y.providesBackgroundForChildren(p)&&(w=s,s=o,o+=Io);for(const S of g)a(S,u,d||f);w!==null&&(s=w)},c=n?[this.getCurrentPage()]:this.getPages();for(const l of c)for(const u of this.getSortedChildIdsForParent(l.id))a(u,1,!1);return r}getRenderingShapes(){return this.getUnorderedRenderingShapes(!0).sort(B3)}getRenderingBounds(){return this._renderingBounds.get()}updateRenderingBounds(){const n=this.getViewportPageBounds();return n.equals(this._renderingBounds.__unsafe__getWithoutCapture())?this:(this._renderingBounds.set(n.clone()),this)}_getAllPagesQuery(){return this.store.query.records("page")}getPages(){return this._getAllPagesQuery().get().sort(en)}getCurrentPage(){return this.getPage(this.getCurrentPageId())}getCurrentPageId(){return this.getInstanceState().currentPageId}getPage(n){return this.store.get(typeof n=="string"?n:n.id)}getCurrentPageShapeIds(){return this._currentPageShapeIds.get()}getCurrentPageShapeIdsSorted(){return Array.from(this.getCurrentPageShapeIds()).sort()}getPageShapeIds(n){const r=typeof n=="string"?n:n.id,o=this.store.query.exec("shape",{parentId:{eq:r}});return this.getShapeAndDescendantIds(o.map(s=>s.id))}setCurrentPage(n,r){const o=typeof n=="string"?n:n.id;return this._setCurrentPageId(o,r),this}updatePage(n,r){return this._updatePage(n,r),this}createPage(n){return this._createPage(n),this}deletePage(n){const r=typeof n=="string"?n:n.id;return this._deletePage(r),this}duplicatePage(n,r=Ho.createId()){if(this.getPages().length>=Gp)return this;const o=typeof n=="string"?n:n.id,s=this.getPage(o);if(!s)return this;const i={...this.getCamera()},a=this.getContentFromCurrentPage(this.getSortedChildIdsForParent(s.id));return this.batch(()=>{var u;const c=this.getPages(),l=kl(s.index,(u=c[c.indexOf(s)+1])==null?void 0:u.index);if(this.createPage({name:s.name+" Copy",id:r,index:l}),this.setCurrentPage(r),this.setCamera(i),a)return this.putContentOntoCurrentPage(a)}),this}renamePage(n,r,o){const s=typeof n=="string"?n:n.id;return this.getInstanceState().isReadonly?this:(this.updatePage({id:s,name:r},o),this)}_getAllAssetsQuery(){return this.store.query.records("asset")}getAssets(){return this._getAllAssetsQuery().get()}createAssets(n){return this._createAssets(n),this}updateAssets(n){return this._updateAssets(n),this}deleteAssets(n){const r=typeof n[0]=="string"?n:n.map(o=>o.id);return this._deleteAssets(r),this}getAsset(n){return this.store.get(typeof n=="string"?n:n.id)}_getShapeGeometryCache(){return this.store.createComputedCache("bounds",n=>this.getShapeUtil(n).getGeometry(n),(n,r)=>n.props===r.props)}getShapeGeometry(n){return this._getShapeGeometryCache().get(typeof n=="string"?n:n.id)}_getShapeHandlesCache(){return this.store.createComputedCache("handles",n=>{var r,o;return(o=(r=this.getShapeUtil(n)).getHandles)==null?void 0:o.call(r,n)})}getShapeHandles(n){return this._getShapeHandlesCache().get(typeof n=="string"?n:n.id)}getShapeLocalTransform(n){const r=typeof n=="string"?n:n.id,o=this.getShape(r);if(!o)throw Error("Editor.getTransform: shape not found");return oe.Identity().translate(o.x,o.y).rotate(o.rotation)}_getShapePageTransformCache(){return this.store.createComputedCache("pageTransformCache",n=>{if(bn(n.parentId))return this.getShapeLocalTransform(n);const r=this._getShapePageTransformCache().get(n.parentId)??oe.Identity();return oe.Compose(r,this.getShapeLocalTransform(n))})}getShapeParentTransform(n){const r=typeof n=="string"?n:n.id,o=this.getShape(r);return!o||bn(o.parentId)?oe.Identity():this._getShapePageTransformCache().get(o.parentId)??oe.Identity()}getShapePageTransform(n){const r=typeof n=="string"?n:n.id;return this._getShapePageTransformCache().get(r)??oe.Identity()}_getShapePageBoundsCache(){return this.store.createComputedCache("pageBoundsCache",n=>{const r=this._getShapePageTransformCache().get(n.id);return r?ne.FromPoints(oe.applyToPoints(r,this.getShapeGeometry(n).vertices)):new ne})}getShapePageBounds(n){return this._getShapePageBoundsCache().get(typeof n=="string"?n:n.id)}_getShapeClipPathCache(){return this.store.createComputedCache("clipPathCache",n=>{const r=this._getShapeMaskCache().get(n.id);if(!r)return;if(r.length===0)return"polygon(0px 0px, 0px 0px, 0px 0px)";const o=this._getShapePageTransformCache().get(n.id);return o?`polygon(${oe.applyToPoints(oe.Inverse(o),r).map(i=>`${i.x}px ${i.y}px`).join(",")})`:void 0})}getShapeClipPath(n){return this._getShapeClipPathCache().get(typeof n=="string"?n:n.id)}_getShapeMaskCache(){return this.store.createComputedCache("pageMaskCache",n=>{if(bn(n.parentId))return;const r=this.getShapeAncestors(n.id).filter(s=>this.isShapeOfType(s,"frame"));return r.length===0?void 0:r.map(s=>this._getShapePageTransformCache().get(s.id).applyToPoints(this.getShapeGeometry(s).vertices)).reduce((s,i)=>{if(!(i&&s))return;const a=W1(s,i);return a?a.map(P.Cast):[]})})}getShapeMask(n){return this._getShapeMaskCache().get(typeof n=="string"?n:n.id)}getShapeMaskedPageBounds(n){return typeof n!="string"&&(n=n.id),this._getShapeMaskedPageBoundsCache().get(n)}_getShapeMaskedPageBoundsCache(){return this.store.createComputedCache("shapeMaskedPageBoundsCache",n=>{const r=this._getShapePageBoundsCache().get(n.id);if(!r)return;const o=this._getShapeMaskCache().get(n.id);if(o){if(o.length===0)return;const{corners:s}=r;if(s.every((a,c)=>a&&P.Equals(a,o[c])))return r.clone();const i=W1(o,s);return i?ne.FromPoints(i):void 0}return r})}getShapeAncestors(n,r=[]){const o=typeof n=="string"?n:n.id,s=this.getShape(o);if(!s)return r;const i=s.parentId;if(bn(i))return r.reverse(),r;const a=this.store.get(i);return a?(r.push(a),this.getShapeAncestors(a,r)):r}findShapeAncestor(n,r){const o=typeof n=="string"?n:n.id,s=this.getShape(o);if(!s)return;const i=s.parentId;if(bn(i))return;const a=this.getShape(i);if(a)return r(a)?a:this.findShapeAncestor(a,r)}hasAncestor(n,r){const o=typeof n=="string"?n:n==null?void 0:n.id,s=o&&this.getShape(o);return s?s.parentId===r?!0:this.hasAncestor(this.getShapeParent(s),r):!1}findCommonAncestor(n,r){var l;if(n.length===0)return;const o=typeof n[0]=="string"?n:n.map(u=>u.id),s=fe(o.map(u=>this.getShape(u)));if(s.length===1){const u=s[0].parentId;return bn(u)?void 0:r?(l=this.findShapeAncestor(s[0],r))==null?void 0:l.id:u}const[i,...a]=s;let c=this.getShapeParent(i);for(;c;){if(r&&!r(c)){c=this.getShapeParent(c);continue}if(a.every(u=>this.hasAncestor(u,c.id)))return c.id;c=this.getShapeParent(c)}}isShapeOrAncestorLocked(n){const r=typeof n=="string"?this.getShape(n):n;return r===void 0?!1:r.isLocked?!0:this.isShapeOrAncestorLocked(this.getShapeParent(r))}_notVisibleShapes(){return K4(this)}getCulledShapes(){const n=this._notVisibleShapes().get(),r=this.getSelectedShapeIds(),o=this.getEditingShapeId(),s=new Set(n);return o&&s.delete(o),r.forEach(i=>{s.delete(i)}),s}getCurrentPageBounds(){let n;return this.getCurrentPageShapeIdsSorted().forEach(r=>{const o=this.getShapeMaskedPageBounds(r);o&&(n?n=n.expand(o):n=o.clone())}),n}getSelectedShapeAtPoint(n){const r=this.getSelectedShapeIds();return this.getCurrentPageShapesSorted().filter(o=>o.type!=="group"&&r.includes(o.id)).reverse().find(o=>this.isPointInShape(o,n,{hitInside:!0,margin:0}))}getShapeAtPoint(n,r={}){const o=this.getZoomLevel(),s=this.getViewportPageBounds(),{filter:i,margin:a=0,hitLabels:c=!1,hitInside:l=!1,hitFrameInside:u=!1}=r;let d=1/0,p=null,f=1/0,y=null;const g=(r.renderingOnly?this.getCurrentPageRenderingShapesSorted():this.getCurrentPageShapesSorted()).filter(w=>{if(this.isShapeOfType(w,"group"))return!1;const S=this.getShapeMask(w);return S&&!Zn(n,S)?!1:i?i(w):!0});for(let w=g.length-1;w>=0;w--){const S=g[w],v=this.getShapeGeometry(S),b=v instanceof Br,E=this.getPointInShapeSpace(S,n);if((this.isShapeOfType(S,"arrow")||this.isShapeOfType(S,"geo")&&S.props.fill==="none")&&S.props.text.trim()){for(const I of v.children)if(I.isLabel&&I.isPointInBounds(E))return S}if(this.isShapeOfType(S,"frame")){const I=v.distanceToPoint(E,l);if(Math.abs(I)<=a)return y||S;if(v.hitTestPoint(E,0,!0))return y||p||(u?S:void 0);continue}let C;if(b){let I=1/0;for(const _ of v.children){if(_.isLabel&&!c)continue;const k=_.distanceToPoint(E,l);k<I&&(I=k)}C=I}else a===0&&(v.bounds.w<1||v.bounds.h<1)||v.bounds.containsPoint(E,a)?C=v.distanceToPoint(E,l):C=1/0;if(v.isClosed){if(C<=a){if(v.isFilled||b&&v.children[0].isFilled)return y||S;if(this.getShapePageBounds(S).contains(s))continue;if(Math.abs(C)<a)Math.abs(C)<f&&(f=Math.abs(C),y=S);else if(!y){const{area:I}=v;I<d&&(d=I,p=S)}}}else if(C<Ko/o)return S}return y||p||void 0}getShapesAtPoint(n,r={}){return this.getCurrentPageShapes().filter(o=>this.isPointInShape(o,n,r))}isPointInShape(n,r,o={}){const{hitInside:s=!1,margin:i=0}=o,a=typeof n=="string"?n:n.id,c=this.getShapeMask(a);return c&&!Zn(r,c)?!1:this.getShapeGeometry(a).hitTestPoint(this.getPointInShapeSpace(n,r),i,s)}getPointInShapeSpace(n,r){const o=typeof n=="string"?n:n.id;return this._getShapePageTransformCache().get(o).clone().invert().applyToPoint(r)}getPointInParentSpace(n,r){const o=typeof n=="string"?n:n.id,s=this.getShape(o);if(!s)return new P(0,0);if(bn(s.parentId))return P.From(r);const i=this.getShapePageTransform(s.parentId);return i?i.clone().invert().applyToPoint(r):P.From(r)}getCurrentPageShapes(){return Array.from(this.getCurrentPageShapeIds(),n=>this.store.get(n))}getCurrentPageShapesSorted(){const n=[],r=this.getSortedChildIdsForParent(this.getCurrentPageId());for(let o=0,s=r.length;o<s;o++)L2(this,r[o],n);return n}getCurrentPageRenderingShapesSorted(){const n=this.getCulledShapes();return this.getCurrentPageShapesSorted().filter(({id:r})=>!n.has(r))}isShapeOfType(n,r){const o=typeof n=="string"?this.getShape(n):n;return o?o.type===r:!1}getShape(n){const r=typeof n=="string"?n:n.id;if(Kn(r))return this.store.get(r)}getShapeParent(n){const r=typeof n=="string"?n:n==null?void 0:n.id;if(!r)return;const o=this.getShape(r);if(!(o===void 0||!Kn(o.parentId)))return this.store.get(o.parentId)}getShapeNearestSibling(n,r){return r?r.parentId===n.parentId?r:this.findShapeAncestor(r,s=>s.parentId===n.parentId):void 0}isShapeInPage(n,r=this.getCurrentPageId()){const o=typeof n=="string"?n:n.id,s=this.getShape(o);if(!s)return!1;let i=!1;if(s.parentId===r)i=!0;else{let a=this.getShape(s.parentId);e:for(;a;){if(a.parentId===r){i=!0;break e}a=this.getShape(a.parentId)}}return i}getAncestorPageId(n){const r=typeof n=="string"?n:n==null?void 0:n.id,o=r&&this.getShape(r);if(o)return bn(o.parentId)?o.parentId:this.getAncestorPageId(this.getShape(o.parentId))}reparentShapes(n,r,o){const s=typeof n[0]=="string"?n:n.map(y=>y.id);if(s.length===0)return this;const i=[],a=bn(r)?oe.Identity():this.getShapePageTransform(r),c=a.rotation();let l=[];const u=fe(this.getSortedChildIdsForParent(r).map(y=>this.getShape(y)));if(o){const y=u.find(g=>g.index===o);if(y){const g=u[u.indexOf(y)+1];g?l=oc(o,g.index,s.length):l=rm(o,s.length)}else{const g=u.sort(en).find(w=>w.index>o);g?l=oc(o,g.index,s.length):l=rm(o,s.length)}}else{const y=u.length&&u[u.length-1];l=y?rm(y.index,s.length):eu(s.length)}const d=a.clone().invert(),p=fe(s.map(y=>this.getShape(y))),f=p.filter(y=>y.isLocked);f.length&&this.updateShapes(f.map(({id:y,type:g})=>({id:y,type:g,isLocked:!1})));for(let y=0;y<p.length;y++){const g=p[y],w=this.getShapePageTransform(g);if(!w)continue;const S=w.point();if(!S)continue;const v=d.applyToPoint(S),b=w.rotation()-c;i.push({id:g.id,type:g.type,parentId:r,x:v.x,y:v.y,rotation:b,index:l[y],isLocked:g.isLocked})}return this.updateShapes(i),this}getHighestIndexForParent(n){const r=typeof n=="string"?n:n.id,o=this._parentIdsToChildIds.get()[r];if(!o||o.length===0)return"a1";const s=this.getShape(o[o.length-1]);return $o(s.index)}getSortedChildIdsForParent(n){const r=typeof n=="string"?n:n.id,o=this._parentIdsToChildIds.get()[r];return o?this._childIdsCache.get(o,()=>o):Do}visitDescendants(n,r){const o=typeof n=="string"?n:n.id,s=this.getSortedChildIdsForParent(o);for(const i of s)r(i)!==!1&&this.visitDescendants(i,r);return this}getShapeAndDescendantIds(n){const r=new Set,o=[...n];for(;o.length>0;){const s=o.pop();if(!s)break;if(!r.has(s)){r.add(s);for(const i of this.getSortedChildIdsForParent(s))o.push(i)}}return r}getDroppingOverShape(n,r=[]){const o=this.getCurrentPageShapesSorted();for(let s=o.length-1;s>=0;s--){const i=o[s];if(this.getSelectedShapeIds().includes(i.id)||!this.getShapeUtil(i).canDropShapes(i,r)||r.find(c=>c.id===i.id||this.hasAncestor(i,c.id)))continue;const a=this.getShapeMaskedPageBounds(i.id);if(a&&a.containsPoint(n)&&this.getShapeGeometry(i).hitTestPoint(this.getPointInShapeSpace(i,n),0,!0))return i}}getOutermostSelectableShape(n,r){const o=typeof n=="string"?n:n.id,s=this.getShape(o);let i=s,a=s;const c=this.getFocusedGroup();for(;a;){if(this.isShapeOfType(a,"group")&&(c==null?void 0:c.id)!==a.id&&!this.hasAncestor(c,a.id)&&((r==null?void 0:r(a))??!0))i=a;else if((c==null?void 0:c.id)===a.id)break;a=this.getShapeParent(a)}return i}rotateShapesBy(n,r){if((typeof n[0]=="string"?n:n.map(i=>i.id)).length<=0)return this;const s=j2({editor:this});return s?(wh({delta:r,snapshot:s,editor:this,stage:"one-off"}),this):this}getChangesToTranslateShape(n,r){var i,a,c;let o=n;const s=this.getShapeUtil(n);return o=Qc(o,((i=s.onTranslateStart)==null?void 0:i.call(s,o))??void 0),o=Qc(o,{id:n.id,type:n.type,x:r.x,y:r.y}),o=Qc(o,((a=s.onTranslate)==null?void 0:a.call(s,n,o))??void 0),o=Qc(o,((c=s.onTranslateEnd)==null?void 0:c.call(s,n,o))??void 0),o}nudgeShapes(n,r,o){const s=typeof n[0]=="string"?n:n.map(a=>a.id);if(s.length<=0)return this;const i=[];for(const a of s){const c=this.getShape(a),l=P.From(r),u=this.getShapeParentTransform(c);u&&l.rot(-u.rotation()),i.push(this.getChangesToTranslateShape(c,l.add(c)))}return this.updateShapes(i,{squashing:!0,...o}),this}duplicateShapes(n,r){const o=typeof n[0]=="string"?n:n.map(u=>u.id);if(o.length<=0)return this;const s=new Set(o),i=[],a=[...o];for(;a.length>0;){const u=a.pop();if(!u)break;i.push(u),this.getSortedChildIdsForParent(u).forEach(d=>a.push(d))}i.reverse();const c=new Map(i.map(u=>[u,Be()])),l=fe(i.map(u=>{const d=this.getShape(u);if(!d)return null;const p=c.get(u);let f=0,y=0;if(r&&s.has(u)){const I=this.getShapeParentTransform(d),_=new P(r.x,r.y).rot(-I.rotation());f=_.x,y=_.y}const g=d.parentId??this.getCurrentPageId(),w=this.getSortedChildIdsForParent(g),S=w.indexOf(d.id),v=w[S+1],b=v?this.getShape(v):null,E=b?kl(d.index,b.index):$o(d.index);let C=Ye(d);if(this.isShapeOfType(d,"arrow")&&this.isShapeOfType(C,"arrow")){const I=this.getArrowInfo(d);let _,k;if(d.props.start.type==="binding"&&(_=c.get(d.props.start.boundShapeId),!_))if(I!=null&&I.isValid){const{x:T,y:O}=I.start.point;C.props.start={type:"point",x:T,y:O}}else{const{start:T}=jr(this,d);C.props.start={type:"point",x:T.x,y:T.y}}if(d.props.end.type==="binding"&&(k=c.get(d.props.end.boundShapeId),!k))if(I!=null&&I.isValid){const{x:T,y:O}=I.end.point;C.props.end={type:"point",x:T,y:O}}else{const{end:T}=jr(this,d);C.props.start={type:"point",x:T.x,y:T.y}}const $=Zc(C)?Al(this,C):xm(this,C);if(I!=null&&I.isValid&&($!=null&&$.isValid)&&!Zc(d)){const T=P.Med(I.start.handle,I.end.handle),O=P.Dist(I.middle,T),N=P.Dist($.middle,T);C.props.bend<0?C.props.bend+=N-O:C.props.bend-=N-O}C.props.start.type==="binding"&&_&&(C.props.start.boundShapeId=_),C.props.end.type==="binding"&&k&&(C.props.end.boundShapeId=k)}return C={...C,id:p,x:d.x+f,y:d.y+y,index:E},C}));return l.forEach(u=>{Kn(u.parentId)&&c.has(u.parentId)&&(u.parentId=c.get(u.parentId))}),this.history.batch(()=>{const u=l.length+this.getCurrentPageShapeIds().size>Io;u&&_d(this);const d=u?l.slice(0,Io-this.getCurrentPageShapeIds().size):l,p=d.map(f=>f.id);if(this.createShapes(d),this.setSelectedShapes(p),r!==void 0){const f=this.getSelectionPageBounds(),y=this.getViewportPageBounds();f&&!y.contains(f)&&this.centerOnPoint(f.center,{duration:Qr})}}),this}moveShapesToPage(n,r){const o=typeof n[0]=="string"?n:n.map(c=>c.id);if(o.length===0)return this;if(this.getInstanceState().isReadonly)return this;const s=this.getCurrentPageId();if(r===s)return this;if(!this.store.has(r))return this;const i=this.getContentFromCurrentPage(o);if(!i)return this;if(this.getPageShapeIds(r).size+i.shapes.length>Io)return _d(this,r),this;const a=this.getCamera().z;return this.history.batch(()=>{this.deleteShapes(o),this.setCurrentPage(r),this.setFocusedGroup(null),this.selectNone(),this.putContentOntoCurrentPage(i,{select:!0,preserveIds:!0,preservePosition:!0}),this.setCamera({...this.getCamera(),z:a}),this.centerOnPoint(this.getSelectionRotatedPageBounds().center)}),this}toggleLock(n){const r=typeof n[0]=="string"?n:n.map(a=>a.id);if(this.getInstanceState().isReadonly||r.length===0)return this;let o=!0,s=!0;const i=[];for(const a of r){const c=this.getShape(a);c&&(i.push(c),c.isLocked?s=!1:o=!1)}return this.batch(()=>{s?(this.updateShapes(i.map(a=>({id:a.id,type:a.type,isLocked:!0}))),this.setSelectedShapes([])):o?this.updateShapes(i.map(a=>({id:a.id,type:a.type,isLocked:!1}))):this.updateShapes(i.map(a=>({id:a.id,type:a.type,isLocked:!0})))}),this}sendToBack(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=Ed(this,"toBack",r);return o&&this.updateShapes(o),this}sendBackward(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=Ed(this,"backward",r);return o&&this.updateShapes(o),this}bringForward(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=Ed(this,"forward",r);return o&&this.updateShapes(o),this}bringToFront(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=Ed(this,"toFront",r);return o&&this.updateShapes(o),this}flipShapes(n,r){const o=typeof n[0]=="string"?n:n.map(a=>a.id);if(this.getInstanceState().isReadonly)return this;let s=fe(o.map(a=>this.getShape(a)));if(!s.length)return this;s=fe(s.map(a=>this.isShapeOfType(a,"group")?this.getSortedChildIdsForParent(a.id).map(c=>this.getShape(c)):a).flat());const i=ne.Common(fe(s.map(a=>this.getShapePageBounds(a)))).center;return this.batch(()=>{for(const a of s){const c=this.getShapeGeometry(a).bounds,l=this.getShapePageTransform(a.id);l&&this.resizeShape(a.id,{x:r==="horizontal"?-1:1,y:r==="vertical"?-1:1},{initialBounds:c,initialPageTransform:l,initialShape:a,mode:"scale_shape",scaleOrigin:i,scaleAxisRotation:0})}}),this}stackShapes(n,r,o){const s=typeof n[0]=="string"?n:n.map(w=>w.id);if(this.getInstanceState().isReadonly)return this;const i=fe(s.map(w=>this.getShape(w)).filter(w=>!(!w||this.isShapeOfType(w,"arrow")&&(w.props.start.type==="binding"||w.props.end.type==="binding")))),a=i.length;if(o===0&&a<3||a<2)return this;const c=Object.fromEntries(i.map(w=>[w.id,this.getShapePageBounds(w)]));let l,u,d,p;r==="horizontal"?(l="x",u="minX",d="maxX",p="width"):(l="y",u="minY",d="maxY",p="height");let f;if(o===0){const w=[];i.sort((v,b)=>c[v.id][u]-c[b.id][u]);for(let v=0;v<a-1;v++){const b=i[v],E=i[v+1],C=c[b.id],_=c[E.id][u]-C[d],k=w.find($=>$.gap===_);k?k.count++:w.push({gap:_,count:1})}let S=0;w.forEach(v=>{v.count>S&&(S=v.count,f=v.gap)}),S===1&&(f=Math.max(0,w.reduce((v,b)=>v+b.gap*b.count,0)/(a-1)))}else f=o;const y=[];let g=c[i[0].id][d];return i.forEach((w,S)=>{var I,_;if(S===0)return;const v={x:0,y:0};v[l]=g+f-c[w.id][l];const b=this.getShapeParent(w),E=b?P.Rot(v,-this.getShapePageTransform(b).decompose().rotation):v,C=(_=(I=this.getShapeUtil(w)).onTranslateStart)==null?void 0:_.call(I,w);y.push(C?{...C,[l]:w[l]+E[l]}:{id:w.id,type:w.type,[l]:w[l]+E[l]}),g+=c[w.id][p]+f}),this.updateShapes(y),this}packShapes(n,r){var _,k;const o=typeof n[0]=="string"?n:n.map($=>$.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=fe(o.map($=>this.getShape($)).filter($=>!(!$||this.isShapeOfType($,"arrow")&&($.props.start.type==="binding"||$.props.end.type==="binding")))),i={},a={};let c,l,u=0;for(let $=0;$<s.length;$++)c=s[$],l=this.getShapePageBounds(c),i[c.id]=l,a[c.id]=l.clone(),u+=l.width*l.height;const d=ne.Common(fe(Object.values(i))),p=d.width;s.sort(($,T)=>i[T.id].height-i[$.id].height);const f=Math.max(Math.ceil(Math.sqrt(u/.95)),p),y=[new ne(d.x,d.y,f,1/0)];let g=0,w=0,S,v;for(let $=0;$<s.length;$++){c=s[$],l=a[c.id];for(let T=y.length-1;T>=0;T--)if(S=y[T],!(l.width>S.width||l.height>S.height)){l.x=S.x,l.y=S.y,w=Math.max(w,l.maxY),g=Math.max(g,l.maxX),l.width===S.width&&l.height===S.height?(v=y.pop(),T<y.length&&(y[T]=v)):l.height===S.height?(S.x+=l.width+r,S.width-=l.width+r):l.width===S.width?(S.y+=l.height+r,S.height-=l.height+r):(y.push(new ne(S.x+(l.width+r),S.y,S.width-(l.width+r),l.height)),S.y+=l.height+r,S.height-=l.height+r);break}}const b=ne.Common(Object.values(a)),E=P.Sub(d.center,b.center);let C;const I=[];for(let $=0;$<s.length;$++){c=s[$],l=i[c.id],C=a[c.id];const T=P.Sub(C.point,l.point).add(E),O=this.getShapeParentTransform(c);O&&T.rot(-O.rotation());const N={id:c.id,type:c.type,x:c.x+T.x,y:c.y+T.y},F=(k=(_=this.getShapeUtil(c)).onTranslateStart)==null?void 0:k.call(_,{...c,...N});F?I.push({...N,...F}):I.push(N)}return I.length&&this.updateShapes(I),this}alignShapes(n,r){const o=typeof n[0]=="string"?n:n.map(l=>l.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=fe(o.map(l=>this.getShape(l))),i=Object.fromEntries(s.map(l=>[l.id,this.getShapePageBounds(l)])),a=ne.Common(fe(Object.values(i))),c=[];return s.forEach(l=>{const u=i[l.id];if(!u)return;const d={x:0,y:0};switch(r){case"top":{d.y=a.minY-u.minY;break}case"center-vertical":{d.y=a.midY-u.minY-u.height/2;break}case"bottom":{d.y=a.maxY-u.minY-u.height;break}case"left":{d.x=a.minX-u.minX;break}case"center-horizontal":{d.x=a.midX-u.minX-u.width/2;break}case"right":{d.x=a.maxX-u.minX-u.width;break}}const p=this.getShapeParent(l),f=p?P.Rot(d,-this.getShapePageTransform(p).decompose().rotation):d;c.push(this.getChangesToTranslateShape(l,P.Add(l,f)))}),this.updateShapes(c),this}distributeShapes(n,r){const o=typeof n[0]=="string"?n:n.map(b=>b.id);if(this.getInstanceState().isReadonly)return this;if(o.length<3)return this;const s=o.length,i=fe(o.map(b=>this.getShape(b))),a=Object.fromEntries(i.map(b=>[b.id,this.getShapePageBounds(b)]));let c,l,u,d,p;r==="horizontal"?(c="x",l="minX",u="maxX",d="midX",p="width"):(c="y",l="minY",u="maxY",d="midY",p="height");const f=[],y=i.sort((b,E)=>a[b.id][l]-a[E.id][l])[0],g=i.sort((b,E)=>a[E.id][u]-a[b.id][u])[0],w=a[y.id][d],S=(a[g.id][d]-w)/(s-1),v=w+S;return i.filter(b=>b!==y&&b!==g).sort((b,E)=>a[b.id][d]-a[E.id][d]).forEach((b,E)=>{const C={x:0,y:0};C[c]=v+S*E-a[b.id][p]/2-a[b.id][c];const I=this.getShapeParent(b),_=I?P.Rot(C,-this.getShapePageTransform(I).rotation()):C;f.push(this.getChangesToTranslateShape(b,P.Add(b,_)))}),this.updateShapes(f),this}stretchShapes(n,r){const o=typeof n[0]=="string"?n:n.map(l=>l.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=fe(o.map(l=>this.getShape(l))),i=Object.fromEntries(o.map(l=>[l,this.getShapeGeometry(l).bounds])),a=Object.fromEntries(o.map(l=>[l,this.getShapePageBounds(l)])),c=ne.Common(fe(Object.values(a)));switch(r){case"vertical":{this.batch(()=>{for(const l of s){if(this.getShapePageTransform(l).rotation()%Oe)continue;const d=i[l.id],p=a[l.id],f=new P(0,c.minY-p.minY),y=this.getShapeParentTransform(l);y&&f.rot(-y.rotation());const{x:g,y:w}=P.Add(f,l);this.updateShapes([{id:l.id,type:l.type,x:g,y:w}],{squashing:!0});const S=new P(1,c.height/p.height);this.resizeShape(l.id,S,{initialBounds:d,scaleOrigin:new P(p.center.x,c.minY),scaleAxisRotation:0})}});break}case"horizontal":{this.batch(()=>{for(const l of s){const u=i[l.id],d=a[l.id];if(this.getShapePageTransform(l).rotation()%Oe)continue;const f=new P(c.minX-d.minX,0),y=this.getShapeParentTransform(l);y&&f.rot(-y.rotation());const{x:g,y:w}=P.Add(f,l);this.updateShapes([{id:l.id,type:l.type,x:g,y:w}],{squashing:!0});const S=new P(c.width/d.width,1);this.resizeShape(l.id,S,{initialBounds:u,scaleOrigin:new P(c.minX,d.center.y),scaleAxisRotation:0})}});break}}return this}resizeShape(n,r,o={}){var f;const s=typeof n=="string"?n:n.id;if(this.getInstanceState().isReadonly)return this;Number.isFinite(r.x)||(r=new P(1,r.y)),Number.isFinite(r.y)||(r=new P(r.x,1));const i=o.initialShape??this.getShape(s);if(!i)return this;const a=o.scaleOrigin??((f=this.getShapePageBounds(s))==null?void 0:f.center);if(!a)return this;const c=o.initialPageTransform?oe.Cast(o.initialPageTransform):this.getShapePageTransform(s);if(!c)return this;const l=c.rotation();if(l==null)return this;const u=o.scaleAxisRotation??l,d=o.initialBounds??this.getShapeGeometry(s).bounds;if(!d)return this;if(!Wk(l,u))return this._resizeUnalignedShape(s,r,{...o,initialBounds:d,scaleOrigin:a,scaleAxisRotation:u,initialPageTransform:c,initialShape:i});const p=this.getShapeUtil(i);if(p.isAspectRatioLocked(i)&&(Math.abs(r.x)>Math.abs(r.y)?r=new P(r.x,Math.sign(r.y)*Math.abs(r.x)):r=new P(Math.sign(r.x)*Math.abs(r.y),r.y)),p.onResize&&p.canResize(i)){const y=this._scalePagePoint(oe.applyToPoint(c,new P(0,0)),a,r,u),g=this.getPointInParentSpace(i.id,y),w=new P(r.x,r.y),S=Ml((l-u)%Math.PI,0);w.x=S?r.x:r.y,w.y=S?r.y:r.x;const v=oe.applyToPoint(c,new P),{x:b,y:E}=this.getPointInParentSpace(i.id,v);this.updateShapes([{id:s,type:i.type,x:g.x,y:g.y,...p.onResize({...i,x:b,y:E},{newPoint:g,handle:o.dragHandle??"bottom_right",mode:o.mode??"scale_shape",scaleX:w.x,scaleY:w.y,initialBounds:d,initialShape:i})}],{squashing:!0})}else{const y=oe.applyToPoint(c,d.center),g=this._scalePagePoint(y,a,r,u),w=this.getPointInParentSpace(i.id,y),S=this.getPointInParentSpace(i.id,g),v=P.Sub(S,w);this.updateShapes([{id:s,type:i.type,x:i.x+v.x,y:i.y+v.y}],{squashing:!0})}return this}_scalePagePoint(n,r,o,s){const i=P.RotWith(n,r,-s).sub(r),a=P.MulV(i,o);return P.Add(a,r).rotWith(r,s)}_resizeUnalignedShape(n,r,o){const{type:s}=o.initialShape,i=new P(r.x,r.y);if(Math.abs(r.x)>Math.abs(r.y)?i.x=Math.sign(r.x)*Math.abs(r.y):i.y=Math.sign(r.y)*Math.abs(r.x),this.resizeShape(n,i,{initialShape:o.initialShape,initialBounds:o.initialBounds}),Math.sign(r.x)*Math.sign(r.y)<0){let{rotation:S}=oe.Decompose(o.initialPageTransform);S-=2*S,this.updateShapes([{id:n,type:s,rotation:S}],{squashing:!0})}const a=oe.applyToPoint(o.initialPageTransform,o.initialBounds.center),c=this._scalePagePoint(a,o.scaleOrigin,r,o.scaleAxisRotation),l=this.getShapePageBounds(n),u=this.getShapePageTransform(n),d=l.center,p=u.point();if(!d||!p)return this;const f=P.Sub(c,d),y=P.Add(p,f),{x:g,y:w}=this.getPointInParentSpace(n,y);return this.updateShapes([{id:n,type:s,x:g,y:w}],{squashing:!0}),this}getInitialMetaForShape(n){return{}}createShape(n){return this._createShapes([n]),this}createShapes(n){if(!Array.isArray(n))throw Error("Editor.createShapes: must provide an array of shapes or shape partials");return this._createShapes(n),this}animateShape(n,r){return this.animateShapes([n],r)}animateShapes(n,r={}){const{duration:o=500,easing:s=nn.linear}=r,i=et();let a=o,c;const l=[];let u,d;for(let y=0,g=n.length;y<g;y++){if(u=n[y],!u)continue;d={partial:u,values:[]};const w=this.getShape(u.id);if(w){for(const S of["x","y","rotation"])u[S]!==void 0&&w[S]!==u[S]&&d.values.push({prop:S,from:w[S],to:u[S]});l.push(d),this.animatingShapes.set(w.id,i)}}let p;const f=y=>{if(a-=y,a<0){const{animatingShapes:v}=this,b=n.filter(E=>E&&v.get(E.id)===i);b.length&&this.updateShapes(b,{squashing:!1}),this.removeListener("tick",f);return}c=s(1-a/o);const{animatingShapes:g}=this,w=[];let S;for(let v=0,b=l.length;v<b;v++)p=l[v],S=g.get(p.partial.id),S===i&&w.push({id:p.partial.id,type:p.partial.type,...p.values.reduce((E,{prop:C,from:I,to:_})=>(E[C]=I+(_-I)*c,E),{})});this._updateShapes(w,{squashing:!0})};return this.addListener("tick",f),this}groupShapes(n,r=Be()){var f;if(!Array.isArray(n))throw Error("Editor.groupShapes: must provide an array of shapes or shape ids");if(this.getInstanceState().isReadonly)return this;const o=typeof n[0]=="string"?n:n.map(y=>y.id);if(o.length<=1)return this;const s=fe(this._getUnlockedShapeIds(o).map(y=>this.getShape(y))),i=s.sort(en).map(y=>y.id),a=ne.Common(fe(s.map(y=>this.getShapePageBounds(y)))),{x:c,y:l}=a.point,u=this.findCommonAncestor(s)??this.getCurrentPageId();if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const d=s.filter(y=>y.parentId===u).sort(en),p=(f=d[d.length-1])==null?void 0:f.index;return this.batch(()=>{this.createShapes([{id:r,type:"group",parentId:u,index:p,x:c,y:l,opacity:1,props:{}}]),this.reparentShapes(i,r),this.select(r)}),this}ungroupShapes(n){const r=typeof n[0]=="string"?n:n.map(a=>a.id);if(this.getInstanceState().isReadonly)return this;if(r.length===0)return this;if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const o=new Set,s=fe(r.map(a=>this.getShape(a))),i=[];return s.forEach(a=>{this.isShapeOfType(a,"group")?i.push(a):o.add(a.id)}),i.length===0?this:(this.batch(()=>{let a;for(let c=0,l=i.length;c<l;c++){a=i[c];const u=this.getSortedChildIdsForParent(a.id);for(let d=0,p=u.length;d<p;d++)o.add(u[d]);this.reparentShapes(u,a.parentId,a.index)}this.deleteShapes(i.map(c=>c.id)),this.select(...o)}),this)}updateShape(n,r){return this.updateShapes([n],r),this}updateShapes(n,r){const o=Array(n.length);for(let s=0,i=n.length;s<i;s++){const a=n[s];if(!a)continue;const c=this.getShape(a.id);c&&(this.isShapeOrAncestorLocked(c)&&!Object.hasOwn(a,"isLocked")||(this.animatingShapes.delete(a.id),o.push(a)))}return this._updateShapes(o,r),this}_getUnlockedShapeIds(n){return n.filter(r=>{var o;return!((o=this.getShape(r))!=null&&o.isLocked)})}deleteShapes(n){if(!Array.isArray(n))throw Error("Editor.deleteShapes: must provide an array of shapes or shapeIds");return this._deleteShapes(this._getUnlockedShapeIds(typeof n[0]=="string"?n:n.map(r=>r.id))),this}deleteShape(n){return this.deleteShapes([typeof n=="string"?n:n.id]),this}_extractSharedStyles(n,r){if(this.isShapeOfType(n,"group")){const o=this._parentIdsToChildIds.get()[n.id];if(!o)return;for(let s=0,i=o.length;s<i;s++)this._extractSharedStyles(this.getShape(o[s]),r)}else for(const[o,s]of this.styleProps[n.type])r.applyValue(o,Lr(n.props,s))}_getSelectionSharedStyles(){const n=this.getSelectedShapes(),r=new VS;for(const o of n)this._extractSharedStyles(o,r);return r}getStyleForNextShape(n){const r=this.getInstanceState().stylesForNextShape[n.id];return r===void 0?n.defaultValue:r}getShapeStyleIfExists(n,r){const o=this.styleProps[n.type].get(r);if(o!==void 0)return Lr(n.props,o)}getSharedStyles(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0)return this._getSelectionSharedStyles();const n=this.root.getCurrent(),r=new VS;if(!n)return r;if(n.shapeType)for(const o of this.styleProps[n.shapeType].keys())r.applyValue(o,this.getStyleForNextShape(o));return r}getSharedOpacity(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0){const n=[],r=s=>{const i=this.getShape(s);if(i)if(this.isShapeOfType(i,"group"))for(const a of this.getSortedChildIdsForParent(i.id))r(a);else n.push(i)};for(const s of this.getSelectedShapeIds())r(s);let o=null;for(const s of n)if(o===null)o=s.opacity;else if(o!==s.opacity)return{type:"mixed"};if(o!==null)return{type:"shared",value:o}}return{type:"shared",value:this.getInstanceState().opacityForNextShape}}setOpacityForNextShapes(n,r){return this.updateInstanceState({opacityForNextShape:n},r),this}setOpacityForSelectedShapes(n,r){const o=this.getSelectedShapes();if(o.length>0){const s=[],i=a=>{if(this.isShapeOfType(a,"group")){const c=this.getSortedChildIdsForParent(a);for(const l of c)i(this.getShape(l))}else s.push(a)};for(const a of o)i(a);this.updateShapes(s.map(a=>({id:a.id,type:a.type,opacity:n})),r)}return this}setStyleForNextShapes(n,r,o){const s=this.getInstanceState().stylesForNextShape;return this.updateInstanceState({stylesForNextShape:{...s,[n.id]:r}},o),this}setStyleForSelectedShapes(n,r,o){const s=this.getSelectedShapes();if(s.length>0){const i=[],a=c=>{if(this.isShapeOfType(c,"group")){const l=this.getSortedChildIdsForParent(c.id);for(const u of l)a(this.getShape(u))}else{const l=this.getShapeUtil(c),u=this.styleProps[c.type].get(n);if(u){const d={id:c.id,type:c.type,props:{[u]:r}};i.push({util:l,originalShape:c,updatePartial:d})}}};for(const c of s)a(c);this.updateShapes(i.map(({updatePartial:c})=>c),o)}return this}registerExternalAssetHandler(n,r){return this.externalAssetContentHandlers[n]=r,this}async getAssetForExternalContent(n){var r,o;return await((o=(r=this.externalAssetContentHandlers)[n.type])==null?void 0:o.call(r,n))}registerExternalContentHandler(n,r){return this.externalContentHandlers[n]=r,this}async putExternalContent(n){var r,o;return(o=(r=this.externalContentHandlers)[n.type])==null?void 0:o.call(r,n)}getContentFromCurrentPage(n){const r=typeof n[0]=="string"?n:n.map(c=>c.id);if(!r||r.length===0)return;const o={};let s=Mp(r.map(c=>this.getShape(c)).sort(en).flatMap(c=>{const l=[c];return this.visitDescendants(c.id,u=>{l.push(this.getShape(u))}),l}));s=s.map(c=>{if(o[c.id]=this.getShapePageTransform(c.id),c=Ye(c),this.isShapeOfType(c,"arrow")){const l=c.props.start.type==="binding"?c.props.start.boundShapeId:void 0,u=c.props.end.type==="binding"?c.props.end.boundShapeId:void 0,d=this.getArrowInfo(c);if(c.props.start.type==="binding"&&!s.some(f=>f.id===l))if(d!=null&&d.isValid){const{x:f,y}=d.start.point;c.props.start={type:"point",x:f,y}}else{const{start:f}=jr(this,c);c.props.start={type:"point",x:f.x,y:f.y}}if(c.props.end.type==="binding"&&!s.some(f=>f.id===u))if(d!=null&&d.isValid){const{x:f,y}=d.end.point;c.props.end={type:"point",x:f,y}}else{const{end:f}=jr(this,c);c.props.end={type:"point",x:f.x,y:f.y}}const p=Zc(c)?Al(this,c):xm(this,c);if(d!=null&&d.isValid&&(p!=null&&p.isValid)&&!Zc(c)){const f=P.Med(d.start.handle,d.end.handle),y=P.Dist(d.middle,f),g=P.Dist(p.middle,f);c.props.bend<0?c.props.bend+=g-y:c.props.bend-=g-y}return c}return c});const i=[];s.forEach(c=>{if(s.find(l=>l.id===c.parentId)===void 0){const l=this.getShapePageTransform(c.id),u=l.point(),d=l.rotation();c.x=u.x,c.y=u.y,c.rotation=d,c.parentId=this.getCurrentPageId(),i.push(c.id)}});const a=new Set;return s.forEach(c=>{"assetId"in c.props&&c.props.assetId!==null&&a.add(c.props.assetId)}),{shapes:s,rootShapeIds:i,schema:this.store.schema.serialize(),assets:fe(Array.from(a).map(c=>this.getAsset(c)))}}putContentOntoCurrentPage(n,r={}){var k;if(this.getInstanceState().isReadonly)return this;if(!n.schema)throw Error(`Could not put content:
|
|
content is missing a schema.`);const{select:o=!1,preserveIds:s=!1,preservePosition:i=!1}=r;let{point:a=void 0}=r;const c=this.getCurrentPageId(),{rootShapeIds:l}=n,u=[],d=[],p={store:{...Object.fromEntries(n.assets.map($=>[$.id,$])),...Object.fromEntries(n.shapes.map($=>[$.id,$]))},schema:n.schema},f=this.store.schema.migrateStoreSnapshot(p);if(f.type==="error")throw Error("Could not put content: could not migrate content");for(const $ of Object.values(f.value))switch($.typeName){case"asset":{u.push($);break}case"shape":{d.push($);break}}const y=new Map(d.map($=>[$.id,Be()]));let g=this.getCurrentPageId(),w=1/0,S=[];for(const $ of this.getSelectedShapes()){if(w===0)break;const T=this.isShapeOfType($,"frame"),O=this.getShapeAncestors($);T&&O.push($);const N=T?O.length+1:O.length;if(N<w)w=N,S=O,g=T?$.id:$.parentId;else if(N===w){if(S.length!==O.length)throw Error(`Ancestors: ${S.length} !== ${O.length}`);if(S.length===0){g=c;break}else{g=c;for(let F=0;F<S.length&&O[F]===S[F];F++)g=O[F].id}}}let v=!1;if(!bn(g)){const $=this.getShape(g);if($){if(!this.getViewportPageBounds().includes(this.getShapePageBounds($)))g=c;else if(l.length===1){const T=d.find(O=>O.id===l[0]);this.isShapeOfType($,"frame")&&this.isShapeOfType(T,"frame")&&T.props.w===($==null?void 0:$.props.w)&&T.props.h===($==null?void 0:$.props.h)&&(v=!0)}}else g=c}v||(v=y.has(g)),v&&(g=this.getShape(g).parentId);let b=this.getHighestIndexForParent(g);const E=[],C=d.map($=>{let T;if(s)T=Ye($),y.set($.id,$.id);else{const O=y.get($.id);T=Ye({...$,id:O})}if(l.includes($.id)&&(T.parentId=c,E.push(T)),y.has(T.parentId)?T.parentId=y.get($.parentId):(l.push(T.id),T.index=b,b=$o(b)),this.isShapeOfType(T,"arrow")){if(T.props.start.type==="binding"){const O=y.get(T.props.start.boundShapeId);T.props.start=O?{...T.props.start,boundShapeId:O}:{type:"point",x:0,y:0}}if(T.props.end.type==="binding"){const O=y.get(T.props.end.boundShapeId);T.props.end=O?{...T.props.end,boundShapeId:O}:{type:"point",x:0,y:0}}}return T});if(C.length+this.getCurrentPageShapeIds().size>Io)return _d(this),this;const I=[],_=[];for(const $ of u)this.store.has($.id)||(($.type==="image"||$.type==="video")&&((k=$.props.src)!=null&&k.startsWith("data:image"))&&(_.push(Ye($)),$.props.src=null),I.push($));return Promise.allSettled(_.map(async $=>{const T=await R4($.props.src,$.props.name,$.props.mimeType??"image/png"),O=await this.getAssetForExternalContent({type:"file",file:T});if(!O){this.deleteAssets([$.id]);return}this.updateAssets([{...O,id:$.id}])})),this.batch(()=>{I.length>0&&this.createAssets(I),this.createShapes(C),o&&this.select(...E.map(F=>F.id)),g!==c&&this.reparentShapes(E.map(F=>F.id),g);const $=C.map(F=>this.getShape(F.id)),T=ne.Common($.map(F=>this.getShapePageBounds(F)));if(a===void 0)if(bn(g)){const F=this.getViewportPageBounds();i||F.includes(ne.From(T))?a=T.center:a=F.center}else{const F=this.getShape(g);a=oe.applyToPoint(this.getShapePageTransform(F),this.getShapeGeometry(F).bounds.center)}if(E.length===1){const F=E[0];if(this.isShapeOfType(F,"frame"))for(;this.getShapesAtPoint(a).some(L=>this.isShapeOfType(L,"frame")&&L.props.w===F.props.w&&L.props.h===F.props.h);)a.x+=T.w+16}const O=ne.Common(fe(E.map(({id:F})=>this.getShapePageBounds(F)))).center,N=P.Sub(a,O);this.updateShapes(E.map(({id:F})=>{const L=this.getShape(F),B=this.getShapeParentTransform(F).decompose().rotation,q=P.Rot(N,-B);return{id:L.id,type:L.type,x:L.x+q.x,y:L.y+q.y}}))}),this}async getSvgElement(n,r={}){const o=await Y4(this,n,r);if(!o)return;const s=document.createDocumentFragment(),i=A_(s);Ui.flushSync(()=>{i.render(o.jsx)});const a=s.firstElementChild;return _t(a instanceof SVGSVGElement,"Expected an SVG element"),i.unmount(),{svg:a,width:o.width,height:o.height}}async getSvgString(n,r={}){const o=await this.getSvgElement(n,r);return o?{svg:new XMLSerializer().serializeToString(o.svg),width:o.width,height:o.height}:void 0}async getSvg(n,r={}){const o=await this.getSvgElement(n,r);if(o)return o.svg}_updateInputsFromEvent(n){var S;const{pointerVelocity:r,previousScreenPoint:o,previousPagePoint:s,currentScreenPoint:i,currentPagePoint:a}=this.inputs,{screenBounds:c}=this.store.unsafeGetWithoutCapture(In),{x:l,y:u,z:d}=this.store.unsafeGetWithoutCapture(this.getCameraId()),p=n.point.x-c.x,f=n.point.y-c.y,y=n.point.z??.5;o.setTo(i),s.setTo(a),i.set(p,f);const g=p/d-l,w=f/d-u;isFinite(g)&&isFinite(w)&&a.set(g,w,y),this.inputs.isPen=n.type==="pointer"&&n.isPen,(n.name==="pointer_down"||this.inputs.isPinching)&&r.set(0,0),this.store.put([{id:Fp,typeName:"pointer",x:a.x,y:a.y,lastActivityTimestamp:n.type==="pointer"&&n.pointerId===b1.CAMERA_MOVE?((S=this.store.unsafeGetWithoutCapture(Fp))==null?void 0:S.lastActivityTimestamp)??this._tickManager.now:this._tickManager.now,meta:{}}])}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}cancelDoubleClick(){this._clickManager.cancelDoubleClickTimeout()}_flushEventsForTick(n){this.batch(()=>{if(this._pendingEventsForNextTick.length>0){const r=[...this._pendingEventsForNextTick];this._pendingEventsForNextTick.length=0;for(const o of r)this._flushEventForTick(o)}n>0&&this.root.handleEvent({type:"misc",name:"tick",elapsed:n}),this.scribbles.tick(n)})}}re([V],J.prototype,"getCanUndo");re([V],J.prototype,"getCanRedo");re([V],J.prototype,"_getArrowBindingsIndex");re([V],J.prototype,"getArrowInfoCache");re([V],J.prototype,"getPath");re([V],J.prototype,"getCurrentTool");re([V],J.prototype,"getCurrentToolId");re([V],J.prototype,"getDocumentSettings");re([V],J.prototype,"getInstanceState");re([V],J.prototype,"getOpenMenus");re([V],J.prototype,"getIsMenuOpen");re([V],J.prototype,"getPageStates");re([V],J.prototype,"_getPageStatesQuery");re([V],J.prototype,"getCurrentPageState");re([V],J.prototype,"_getCurrentPageStateId");re([V],J.prototype,"getSelectedShapeIds");re([V],J.prototype,"getSelectedShapes");re([V],J.prototype,"getOnlySelectedShapeId");re([V],J.prototype,"getOnlySelectedShape");re([V],J.prototype,"getSelectionPageBounds");re([V],J.prototype,"getSelectionRotation");re([V],J.prototype,"getSelectionRotatedPageBounds");re([V],J.prototype,"getSelectionRotatedScreenBounds");re([V],J.prototype,"getFocusedGroupId");re([V],J.prototype,"getFocusedGroup");re([V],J.prototype,"getEditingShapeId");re([V],J.prototype,"getEditingShape");re([V],J.prototype,"getHoveredShapeId");re([V],J.prototype,"getHoveredShape");re([V],J.prototype,"getHintingShapeIds");re([V],J.prototype,"getHintingShape");re([V],J.prototype,"getErasingShapeIds");re([V],J.prototype,"getErasingShapes");re([V],J.prototype,"getCameraId");re([V],J.prototype,"getCamera");re([V],J.prototype,"getZoomLevel");re([V],J.prototype,"getViewportScreenBounds");re([V],J.prototype,"getViewportScreenCenter");re([V],J.prototype,"getViewportPageBounds");re([V],J.prototype,"getViewportPageCenter");re([V],J.prototype,"_getCollaboratorsQuery");re([V],J.prototype,"getCollaborators");re([V],J.prototype,"getCollaboratorsOnCurrentPage");re([V],J.prototype,"getRenderingShapes");re([V],J.prototype,"_getAllPagesQuery");re([V],J.prototype,"getPages");re([V],J.prototype,"getCurrentPageId");re([V],J.prototype,"getCurrentPageShapeIdsSorted");re([V],J.prototype,"_getAllAssetsQuery");re([V],J.prototype,"_getShapeGeometryCache");re([V],J.prototype,"_getShapeHandlesCache");re([V],J.prototype,"_getShapePageTransformCache");re([V],J.prototype,"_getShapePageBoundsCache");re([V],J.prototype,"_getShapeClipPathCache");re([V],J.prototype,"_getShapeMaskCache");re([V],J.prototype,"_getShapeMaskedPageBoundsCache");re([V],J.prototype,"_notVisibleShapes");re([V],J.prototype,"getCulledShapes");re([V],J.prototype,"getCurrentPageBounds");re([V],J.prototype,"getCurrentPageShapes");re([V],J.prototype,"getCurrentPageShapesSorted");re([V],J.prototype,"getCurrentPageRenderingShapesSorted");re([V],J.prototype,"_getSelectionSharedStyles");re([V({isEqual:(e,t)=>e.equals(t)})],J.prototype,"getSharedStyles");re([V],J.prototype,"getSharedOpacity");function _d(e,t=e.getCurrentPageId()){const n=e.getPage(t).name;e.emit("max-shapes",{name:n,pageId:t,count:Io})}function Qc(e,t){if(!t)return e;let n=null;const r=Object.entries(t);for(let o=0,s=r.length;o<s;o++){const[i,a]=r[o];if(a!==void 0&&!(i==="id"||i==="type"||i==="typeName")&&a!==e[i]){if(n||(n={...e}),i==="props"||i==="meta"){n[i]={...e[i]};for(const[c,l]of Object.entries(a))l!==void 0&&(n[i][c]=l);continue}n[i]=a}}return n||e}function L2(e,t,n){const r=e.getShape(t);if(!r)return;n.push(r);const o=e.getSortedChildIdsForParent(t);for(let s=0,i=o.length;s<i;s++)L2(e,o[s],n)}function Ru(){const e=z(),t=D2();return K("isDarkMode",()=>(t==null?void 0:t.isDarkMode)??e.user.getIsDarkMode(),[t,e])}const eP="<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'/>",tP="<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'/>",kd='<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 ds(e,t,n,r,o,s=16,i=16){const a=(-n-t)*(Pe/180),c=Math.sin(a),l=Math.cos(a),u=1*l-1*c,d=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: ${o};'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='${u}' dy='${d}' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(${t+n} 16 16)${r?" scale(-1,-1) translate(0, -32)":""}' filter='url(%23shadow)'>`+e.replaceAll('"',"'")+`</g></svg>") ${s} ${i}, pointer`}const Iz=["default","pointer","cross","move","grab","grabbing","text","zoom-in","zoom-out"],Ez={none:()=>"none","ew-resize":(e,t,n)=>ds(tP,e,0,t,n),"ns-resize":(e,t,n)=>ds(tP,e,90,t,n),"nesw-resize":(e,t,n)=>ds(eP,e,0,t,n),"nwse-resize":(e,t,n)=>ds(eP,e,90,t,n),"nwse-rotate":(e,t,n)=>ds(kd,e,0,t,n),"nesw-rotate":(e,t,n)=>ds(kd,e,90,t,n),"senw-rotate":(e,t,n)=>ds(kd,e,180,t,n),"swne-rotate":(e,t,n)=>ds(kd,e,270,t,n)};function Bn(e,t=0,n="black"){return Ez[e](P5(t),!1,n)}function _z(){const e=z(),t=cn(),n=Ru();js("useCursor",()=>{const{type:r,rotation:o}=e.getInstanceState().cursor;if(Iz.includes(r)){t.style.setProperty("--tl-cursor",`var(--tl-cursor-${r})`);return}t.style.setProperty("--tl-cursor",Bn(r,o,n?"white":"black"))},[e,t,n])}function kz(){const e=z(),t=cn(),n=Ru(),r=K($t.forceSrgb);Se.useEffect(()=>{n?(t.setAttribute("data-color-mode","dark"),t.classList.remove("tl-theme__light"),t.classList.add("tl-theme__dark")):(t.setAttribute("data-color-mode","light"),t.classList.remove("tl-theme__dark"),t.classList.add("tl-theme__light")),r?t.classList.add("tl-theme__force-sRGB"):t.classList.remove("tl-theme__force-sRGB")},[e,t,r,n])}function lx(e){const t=x.useRef();return x.useLayoutEffect(()=>{t.current=e}),x.useDebugValue(e),x.useCallback((...n)=>{const r=t.current;return _t(r,"fn does not exist"),r(...n)},[])}function Tz(e){const t=z(),n=cn();x.useLayoutEffect(()=>{e?(t.getInstanceState().isFocused||t.updateInstanceState({isFocused:!0}),t.getContainer().focus()):t.getInstanceState().isFocused&&t.updateInstanceState({isFocused:!1})},[t,n,e])}function $z(){const[e,t]=x.useState(0);x.useEffect(()=>t(n=>n+1),[])}const Va="TLDRAW_TAB_ID_v2",so=globalThis.window;function Mz(){return so?["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(so.navigator.platform)||so.navigator.userAgent.includes("Mac")&&"ontouchend"in document:!1}const ef=so?so[Va]??X_(Va)??"TLDRAW_INSTANCE_STATE_V1_"+et():"<error>";so&&(so[Va]=ef,Mz()?N0(Va,ef):q_(Va));so==null||so.addEventListener("beforeunload",()=>{N0(Va,ef)});const F2={Initial:0},Hf=Math.max(...Object.values(F2));function Az(e){e.version<F2.Initial,e.version=Hf}const N2=ve({version:he,currentPageId:nu,isFocusMode:we,exportBackground:we,isDebugMode:we,isToolLocked:we,isGridMode:we,pageStates:Nt(ve({pageId:nu,camera:ve({x:he,y:he,z:he}),selectedShapeIds:Nt(_r),focusedGroupId:_r.nullable()}))});function jz(e){if(!e||typeof e!="object")return console.warn("Invalid instance state"),null;if(!("version"in e)||typeof e.version!="number")return console.warn("No version in instance state"),null;e.version!==Hf&&(e=Ye(e),Az(e));try{return N2.validate(e)}catch(t){return console.warn(t),null}}function Oz(e){const t=e.query.ids("page");return V("sessionStateSnapshot",()=>{const n=e.get(In);if(!n)return null;const r=[...t.get()];return{version:Hf,currentPageId:n.currentPageId,exportBackground:n.exportBackground,isFocusMode:n.isFocusMode,isDebugMode:n.isDebugMode,isToolLocked:n.isToolLocked,isGridMode:n.isGridMode,pageStates:r.map(o=>{const s=e.get(Zt.createId(o)),i=e.get(hn.createId(o));return{pageId:o,camera:{x:(i==null?void 0:i.x)??0,y:(i==null?void 0:i.y)??0,z:(i==null?void 0:i.z)??1},selectedShapeIds:(s==null?void 0:s.selectedShapeIds)??[],focusedGroupId:(s==null?void 0:s.focusedGroupId)??null}})}})}function Dz(e,t){const n=jz(t);if(!n)return;const r=e.allRecords().filter(i=>i.typeName==="instance_page_state"||i.typeName==="camera"),o={added:{},updated:{},removed:{...R0(r.map(i=>[i.id,i]))}};e.has(In)&&(o.removed[In]=e.get(In));const s={removed:{},updated:{},added:{[In]:e.schema.types.instance.create({id:In,currentPageId:n.currentPageId,isDebugMode:n.isDebugMode,isFocusMode:n.isFocusMode,isToolLocked:n.isToolLocked,isGridMode:n.isGridMode,exportBackground:n.exportBackground})}};for(const i of n.pageStates){const a=hn.createId(i.pageId),c=Zt.createId(i.pageId);s.added[a]=hn.create({id:hn.createId(i.pageId),x:i.camera.x,y:i.camera.y,z:i.camera.z}),s.added[c]=Zt.create({id:Zt.createId(i.pageId),pageId:i.pageId,selectedShapeIds:i.selectedShapeIds,focusedGroupId:i.focusedGroupId})}Mr(()=>{e.applyDiff(Af([o,s])),e.ensureStoreIsUsable()})}function Rz(e){var o;const t=[];for(const s of Object.values(e))(o=s.typeName)!=null&&o.match(/^(instance.*|pointer|camera)$/)&&t.push(s);const n=t.filter(s=>s.typeName==="instance"&&s.id!==In)[0];if(!n)return null;const r={version:Hf,currentPageId:n.currentPageId,exportBackground:!!n.exportBackground,isFocusMode:!!n.isFocusMode,isDebugMode:!!n.isDebugMode,isToolLocked:!!n.isToolLocked,isGridMode:!1,pageStates:t.filter(s=>s.typeName==="instance_page_state"&&s.instanceId===n.id).map(s=>{const i=e[s.cameraId]??{x:0,y:0,z:1};return{pageId:s.pageId,camera:{x:i.x,y:i.y,z:i.z},selectedShapeIds:s.selectedShapeIds,focusedGroupId:s.focusedGroupId}})};try{return N2.validate(r),r}catch{return null}}function Lz(){window.alert(`Oops! We could not save changes to your browser's storage. We now need to reload the page and try again.
|
|
|
|
Keep seeing this message?
|
|
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.
|
|
• If your hard disk is full, try clearing up some space and then reload the page.`)}function Fz(){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.
|
|
|
|
Keep seeing this message?
|
|
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.`)}const Nz=(e,t)=>t.some(n=>e instanceof n);let nP,rP;function zz(){return nP||(nP=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Bz(){return rP||(rP=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const z2=new WeakMap,GS=new WeakMap,B2=new WeakMap,wm=new WeakMap,ux=new WeakMap;function Uz(e){const t=new Promise((n,r)=>{const o=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{n(Ro(e.result)),o()},i=()=>{r(e.error),o()};e.addEventListener("success",s),e.addEventListener("error",i)});return t.then(n=>{n instanceof IDBCursor&&z2.set(n,e)}).catch(()=>{}),ux.set(t,e),t}function Hz(e){if(GS.has(e))return;const t=new Promise((n,r)=>{const o=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{n(),o()},i=()=>{r(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)});GS.set(e,t)}let YS={get(e,t,n){if(e instanceof IDBTransaction){if(t==="done")return GS.get(e);if(t==="objectStoreNames")return e.objectStoreNames||B2.get(e);if(t==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Ro(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Kz(e){YS=e(YS)}function Wz(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...n){const r=e.call(bm(this),t,...n);return B2.set(r,t.sort?t.sort():[t]),Ro(r)}:Bz().includes(e)?function(...t){return e.apply(bm(this),t),Ro(z2.get(this))}:function(...t){return Ro(e.apply(bm(this),t))}}function Vz(e){return typeof e=="function"?Wz(e):(e instanceof IDBTransaction&&Hz(e),Nz(e,zz())?new Proxy(e,YS):e)}function Ro(e){if(e instanceof IDBRequest)return Uz(e);if(wm.has(e))return wm.get(e);const t=Vz(e);return t!==e&&(wm.set(e,t),ux.set(t,e)),t}const bm=e=>ux.get(e);function Gz(e,t,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(e,t),a=Ro(i);return r&&i.addEventListener("upgradeneeded",c=>{r(Ro(i.result),c.oldVersion,c.newVersion,Ro(i.transaction),c)}),n&&i.addEventListener("blocked",c=>n(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),o&&c.addEventListener("versionchange",l=>o(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}function Yz(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",r=>t(r.oldVersion,r)),Ro(n).then(()=>{})}const Xz=["get","getKey","getAll","getAllKeys","count"],qz=["put","add","delete","clear"],Pm=new Map;function oP(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(Pm.get(t))return Pm.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=qz.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(o||Xz.includes(n)))return;const s=async function(i,...a){const c=this.transaction(i,o?"readwrite":"readonly");let l=c.store;return r&&(l=l.index(a.shift())),(await Promise.all([l[n](...a),o&&c.done]))[0]};return Pm.set(t,s),s}Kz(e=>({...e,get:(t,n,r)=>oP(t,n)||e.get(t,n,r),has:(t,n)=>!!oP(t,n)||e.has(t,n)}));const Kf="TLDRAW_DOCUMENT_v2",U2="TLDRAW_DB_NAME_INDEX_v2",Le={Records:"records",Schema:"schema",SessionState:"session_state"};async function Wf(e,t){t8(e);const n=await Gz(e,3,{upgrade(r){r.objectStoreNames.contains(Le.Records)||r.createObjectStore(Le.Records),r.objectStoreNames.contains(Le.Schema)||r.createObjectStore(Le.Schema),r.objectStoreNames.contains(Le.SessionState)||r.createObjectStore(Le.SessionState)}});try{return await t(n)}finally{n.close()}}async function Zz({persistenceKey:e,sessionId:t,didCancel:n}){const r=Kf+e;if(dx().includes(r))return await e8({persistenceKey:e,didCancel:n}),await Wf(r,async o=>{var d,p;if(n!=null&&n())return;const s=o.transaction([Le.Records,Le.Schema,Le.SessionState],"readonly"),i=s.objectStore(Le.Records),a=s.objectStore(Le.Schema),c=s.objectStore(Le.SessionState);let l=t?(d=await c.get(t))==null?void 0:d.snapshot:null;l||(l=(p=(await c.getAll()).sort((y,g)=>y.updatedAt-g.updatedAt).pop())==null?void 0:p.snapshot);const u={records:await i.getAll(),schema:await a.get(Le.Schema),sessionStateSnapshot:l};if(n!=null&&n()){s.abort();return}return await s.done,u})}async function Qz({persistenceKey:e,schema:t,changes:n,sessionId:r,sessionStateSnapshot:o,didCancel:s}){const i=Kf+e;await Wf(i,async a=>{const c=a.transaction([Le.Records,Le.Schema,Le.SessionState],"readwrite"),l=c.objectStore(Le.Records),u=c.objectStore(Le.Schema),d=c.objectStore(Le.SessionState);for(const[p,f]of Object.entries(n.added))await l.put(f,p);for(const[p,f]of Object.values(n.updated))await l.put(f,f.id);for(const p of Object.keys(n.removed))await l.delete(p);if(u.put(t.serialize(),Le.Schema),o&&r?d.put({snapshot:o,updatedAt:Date.now(),id:r},r):(o||r)&&console.error("sessionStateSnapshot and instanceId must be provided together"),s!=null&&s())return c.abort();await c.done})}async function Jz({persistenceKey:e,schema:t,snapshot:n,sessionId:r,sessionStateSnapshot:o,didCancel:s}){const i=Kf+e;await Wf(i,async a=>{const c=a.transaction([Le.Records,Le.Schema,Le.SessionState],"readwrite"),l=c.objectStore(Le.Records),u=c.objectStore(Le.Schema),d=c.objectStore(Le.SessionState);await l.clear();for(const[p,f]of Object.entries(n))await l.put(f,p);if(u.put(t.serialize(),Le.Schema),o&&r?d.put({snapshot:o,updatedAt:Date.now(),id:r},r):(o||r)&&console.error("sessionStateSnapshot and instanceId must be provided together"),s!=null&&s())return c.abort();await c.done})}async function e8({persistenceKey:e,didCancel:t}){await Wf(Kf+e,async n=>{const r=n.transaction([Le.SessionState],"readwrite"),o=r.objectStore(Le.SessionState),s=(await o.getAll()).sort((a,c)=>a.updatedAt-c.updatedAt);if(s.length<10){await r.done;return}const i=s.slice(0,s.length-10);for(const{id:a}of i)await o.delete(a);if(t!=null&&t())return r.abort();await r.done})}function dx(){const e=JSON.parse(L0(U2)||"[]")??[];return Array.isArray(e)?e:[]}function t8(e){const t=new Set(dx());t.add(e),F0(U2,JSON.stringify([...t]))}const n8=350,r8=1e4,sP=Symbol("UPDATE_INSTANCE_STATE"),o8=e=>e;class s8{constructor(t){m(this,"onmessage")}postMessage(t){}close(){}}const i8=typeof BroadcastChannel>"u"?s8:BroadcastChannel;class a8{constructor(t,{persistenceKey:n,sessionId:r=ef,onLoad:o,onLoadError:s},i=new i8(`tldraw-tab-sync-${n}`)){m(this,"disposables",new Set);m(this,"diffQueue",[]);m(this,"didDispose",!1);m(this,"shouldDoFullDBWrite",!0);m(this,"isReloading",!1);m(this,"persistenceKey");m(this,"sessionId");m(this,"serializedSchema");m(this,"isDebugging",!1);m(this,"documentTypes");m(this,"$sessionStateSnapshot");m(this,"initTime",Date.now());m(this,"isPersisting",!1);m(this,"didLastWriteError",!1);m(this,"scheduledPersistTimeout",null);this.store=t,this.channel=i,typeof window<"u"&&(window.tlsync=this),this.persistenceKey=n,this.sessionId=r,this.serializedSchema=this.store.schema.serialize(),this.$sessionStateSnapshot=Oz(this.store),this.disposables.add(t.listen(({changes:a})=>{this.diffQueue.push(a),this.channel.postMessage(o8({type:"diff",storeId:this.store.id,changes:a,schema:this.serializedSchema})),this.schedulePersist()},{source:"user",scope:"document"})),this.disposables.add(t.listen(()=>{this.diffQueue.push(sP),this.schedulePersist()},{scope:"session"})),this.connect(o,s),this.documentTypes=new Set(Object.values(this.store.schema.types).filter(a=>a.scope==="document").map(a=>a.typeName))}debug(...t){this.isDebugging&&console.debug(...t)}async connect(t,n){this.debug("connecting");let r;try{r=await Zz({persistenceKey:this.persistenceKey,sessionId:this.sessionId,didCancel:()=>this.didDispose})}catch(o){n(o),Fz(),typeof window<"u"&&window.location.reload();return}if(this.debug("loaded data from store",r,"didDispose",this.didDispose),!this.didDispose)try{if(r){const o=Object.fromEntries(r.records.map(a=>[a.id,a])),s=r.sessionStateSnapshot??Rz(o),i=this.store.schema.migrateStoreSnapshot({store:o,schema:r.schema??this.store.schema.serializeEarliestVersion()});if(i.type==="error"){console.error("failed to migrate store",i),n(new Error(`Failed to migrate store: ${i.reason}`));return}this.store.mergeRemoteChanges(()=>{this.store.put(Object.values(i.value).filter(a=>this.documentTypes.has(a.typeName)),"initialize")}),s&&Dz(this.store,s)}this.channel.onmessage=({data:o})=>{var a,c;this.debug("got message",o);const s=o,i=this.store.schema.getMigrationsSince(s.schema);if(i.ok){if(i.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){n(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}s.type==="diff"&&(this.debug("applying diff"),Mr(()=>{this.store.mergeRemoteChanges(()=>{this.store.applyDiff(s.changes),this.store.ensureStoreIsUsable()})}))},this.channel.postMessage({type:"announce",schema:this.serializedSchema}),this.disposables.add(()=>{this.channel.close()}),t(this)}catch(o){if(this.debug("error loading data from store",o),this.didDispose)return;n(o);return}}close(){this.debug("closing"),this.didDispose=!0,this.disposables.forEach(t=>t())}schedulePersist(){this.debug("schedulePersist",this.scheduledPersistTimeout),!this.scheduledPersistTimeout&&(this.scheduledPersistTimeout=setTimeout(()=>{this.scheduledPersistTimeout=null,this.persistIfNeeded()},this.didLastWriteError?r8:n8))}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(){_t(!this.isPersisting,"persist already in progress"),this.isPersisting=!0,this.debug("doPersist start");const t=this.diffQueue;this.diffQueue=[];try{if(this.shouldDoFullDBWrite)this.shouldDoFullDBWrite=!1,await Jz({persistenceKey:this.persistenceKey,schema:this.store.schema,snapshot:this.store.serialize(),didCancel:()=>this.didDispose,sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()});else{const n=Af(t.filter(r=>r!==sP));await Qz({persistenceKey:this.persistenceKey,changes:n,schema:this.store.schema,didCancel:()=>this.didDispose,sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()})}this.didLastWriteError=!1}catch(n){this.shouldDoFullDBWrite=!0,this.didLastWriteError=!0,console.error("failed to store changes in indexed db",n),Lz(),typeof window<"u"&&window.location.reload()}this.isPersisting=!1,this.debug("doPersist end"),this.schedulePersist()}}function H2({initialData:e,defaultName:t="",...n}){const r="schema"in n&&n.schema?n.schema:p5({shapes:c8(A2("shapeUtils"in n&&n.shapeUtils?n.shapeUtils:[])),migrations:"migrations"in n?n.migrations:[]});return new tk({schema:r,initialData:e,props:{defaultName:t}})}function c8(e){return Object.fromEntries(e.map(t=>[t.type,{props:t.props,migrations:t.migrations}]))}function iP(e){const t=H2(e);return e.snapshot&&t.loadSnapshot(e.snapshot),{store:t,opts:e}}function K2(e){const[t,n]=x.useState(()=>iP(e));if(!K_(t.opts,e)){const r=iP(e);return n(r),r.store}return t.store}function l8({persistenceKey:e,sessionId:t,...n}){const[r,o]=x.useState(null),s=K2(n);return x.useEffect(()=>{const i=et();if(!e){o({id:i,storeWithStatus:{status:"not-synced",store:s}});return}o({id:i,storeWithStatus:{status:"loading"}});const a=l=>{o(u=>(u==null?void 0:u.id)===i?{id:i,storeWithStatus:l}:u)},c=new a8(s,{sessionId:t,persistenceKey:e,onLoad(){a({store:s,status:"synced-local"})},onLoadError(l){a({status:"error",error:l})}});return()=>{o(l=>(l==null?void 0:l.id)===i?null:l),c.close()}},[e,s,t]),(r==null?void 0:r.storeWithStatus)??{status:"loading"}}let W2=!1;if(typeof window<"u"){const e=window.navigator.userAgent,t=!!e.match(/iPad/i)||!!e.match(/iPhone/i),n=!!e.match(/WebKit/i);W2=t&&n&&!e.match(/CriOS/i)}function u8(){const e=z();x.useEffect(()=>{if(!W2)return;function t(n){(n.target instanceof HTMLInputElement&&n.target.type==="text"||n.target instanceof HTMLTextAreaElement)&&e.complete()}return document.addEventListener("focusout",t),()=>document.removeEventListener("focusout",t)},[e])}function d8(){const e=z(),t=cn();x.useEffect(()=>{const n=s=>t.style.setProperty("--tl-zoom",s.toString()),r=H_(n,100),o=new yc("useZoomCss",()=>{e.getCurrentPageShapeIds().size<300?n(e.getZoomLevel()):r(e.getZoomLevel())});return o.attach(),o.execute(),()=>{o.detach()}},[e,t])}const h8=[],p8=[],f8=x.memo(function({store:t,components:n,className:r,user:o,...s}){const[i,a]=Se.useState(null),c=x.useMemo(()=>o??k2(),[o]),l=(n==null?void 0:n.ErrorFallback)===void 0?w2:n==null?void 0:n.ErrorFallback,u={...s,shapeUtils:s.shapeUtils??h8,tools:s.tools??p8,components:n};return h.jsx("div",{ref:a,draggable:!1,className:ue("tl-container tl-theme__light",r),onPointerDown:Ut,tabIndex:-1,children:h.jsx(su,{fallback:l,onError:d=>D0(d,{tags:{origin:"react.tldraw-before-app"}}),children:i&&h.jsx(Y5,{container:i,children:h.jsx(f4,{overrides:n,children:t?t instanceof tk?h.jsx(G2,{...u,store:t,user:c}):h.jsx(V2,{...u,store:t,user:c}):h.jsx(g8,{...u,store:t,user:c})})})})})});function g8(e){const{defaultName:t,snapshot:n,initialData:r,shapeUtils:o,persistenceKey:s,sessionId:i,user:a}=e,c=l8({shapeUtils:o,initialData:r,persistenceKey:s,sessionId:i,defaultName:t,snapshot:n});return h.jsx(V2,{...e,store:c,user:a})}const V2=x.memo(function({store:t,user:n,...r}){const o=cn();x.useLayoutEffect(()=>{n.userPreferences.get().isDarkMode&&(o.classList.remove("tl-theme__light"),o.classList.add("tl-theme__dark"))},[o,n]);const{LoadingScreen:s}=dt();switch(t.status){case"error":throw t.error;case"loading":return s?h.jsx(s,{}):null}return h.jsx(G2,{...r,store:t.store,user:n})});function G2({onMount:e,children:t,store:n,tools:r,shapeUtils:o,user:s,initialState:i,autoFocus:a=!0,inferDarkMode:c}){const{ErrorFallback:l}=dt(),u=cn(),[d,p]=x.useState(null);x.useLayoutEffect(()=>{const g=new J({store:n,shapeUtils:o,tools:r,getContainer:()=>u,user:s,initialState:i,inferDarkMode:c});return p(g),()=>{g.dispose()}},[u,o,r,n,s,i,c]);const f=x.useSyncExternalStore(x.useCallback(g=>d?(d.on("crash",g),()=>d.off("crash",g)):()=>{},[d]),()=>(d==null?void 0:d.getCrashingError())??null),{Canvas:y}=dt();return d?h.jsx(su,{fallback:l,onError:g=>d.annotateError(g,{origin:"react.tldraw",willCrashApp:!0}),children:f?h.jsx(y8,{crashingError:f}):h.jsx(Rf.Provider,{value:d,children:h.jsx(m8,{autoFocus:a,onMount:e,children:t??(y?h.jsx(y,{}):null)})})}):null}function m8({children:e,onMount:t,autoFocus:n}){return d8(),_z(),kz(),u8(),$z(),Tz(n),S8(t),h.jsx(h.Fragment,{children:e})}function y8({crashingError:e}){throw e}function Y2({children:e}){return h.jsx("div",{className:"tl-loading",children:e})}function X2({children:e}){return h.jsx("div",{className:"tl-loading",children:e})}function S8(e){const t=z(),n=lx(r=>{const o=e==null?void 0:e(r);return r.emit("mount"),window.tldrawReady=!0,o});Se.useLayoutEffect(()=>{if(t)return n==null?void 0:n(t)},[t,n])}function Ai({children:e,className:t="",...n}){return h.jsx("div",{...n,className:ue("tl-html-container",t),children:e})}function q2(e,t,n={}){const{newPoint:r,handle:o,scaleX:s,scaleY:i}=t,{minWidth:a=1,maxWidth:c=1/0,minHeight:l=1,maxHeight:u=1/0}=n;let d=e.props.w*s,p=e.props.h*i;const f=new P(0,0);if(d>0){if(d<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=d-a;break}case"top":case"bottom":{f.x=(d-a)/2;break}default:f.x=0}d=a}}else if(f.x=d,d=-d,d<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=-d;break}default:f.x=-a}d=a}if(p>0){if(p<l){switch(o){case"top_left":case"top":case"top_right":{f.y=p-l;break}case"right":case"left":{f.y=(p-l)/2;break}default:f.y=0}p=l}}else if(f.y=p,p=-p,p<l){switch(o){case"top_left":case"top":case"top_right":{f.y=-p;break}default:f.y=-l}p=l}const{x:y,y:g}=f.rot(e.rotation).add(r);return{x:y,y:g,props:{w:Math.min(c,d),h:Math.min(u,p)}}}class Pc extends Fr{constructor(){super(...arguments);m(this,"onResize",(n,r)=>q2(n,r))}getGeometry(n){return new Wo({width:n.props.w,height:n.props.h,isFilled:!0})}getHandleSnapGeometry(n){return{points:this.getGeometry(n).bounds.cornersAndCenter}}}var Sy;let v8=(Sy=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(Sy,"id","idle"),Sy);var vy;let x8=(vy=class extends se{constructor(){super(...arguments);m(this,"markId","");m(this,"wasFocusedOnEnter",!1);m(this,"onEnter",()=>{this.wasFocusedOnEnter=!this.editor.getIsMenuOpen()});m(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){const{originPagePoint:r}=this.editor.inputs,o=this.parent.shapeType,s=Be();this.markId=`creating:${s}`,this.editor.mark(this.markId),this.editor.createShapes([{id:s,type:o,x:r.x,y:r.y,props:{w:1,h:1}}]).select(s),this.editor.setCurrentTool("select.resizing",{...n,target:"selection",handle:"bottom_right",isCreating:!0,creationCursorOffset:{x:1,y:1},onInteractionEnd:this.parent.id,onCreate:this.parent.onCreate})}});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()})}complete(){const{originPagePoint:n}=this.editor.inputs;if(!this.wasFocusedOnEnter)return;this.editor.mark(this.markId);const r=this.parent.shapeType,o=Be();this.editor.mark(this.markId),this.editor.createShapes([{id:o,type:r,x:n.x,y:n.y}]);const s=this.editor.getShape(o),{w:i,h:a}=this.editor.getShapeUtil(s).getDefaultProps(),c=new P(i/2,a/2),l=this.editor.getShapeParentTransform(s);l&&c.rot(-l.rotation()),this.editor.updateShapes([{id:o,type:r,x:s.x-c.x,y:s.y-c.y}]),this.editor.setSelectedShapes([o]),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select.idle")}cancel(){this.parent.transition("idle")}},m(vy,"id","pointing"),vy);class Ph extends se{constructor(){super(...arguments);m(this,"onCreate")}}m(Ph,"id","box"),m(Ph,"initial","idle"),m(Ph,"children",()=>[v8,x8]);function Vf(e){const t=z();return K("isEditing",()=>t.getEditingShapeId()===e,[t,e])}function w8(){return x.useId().replace(/:/g,"_")}function Xr(e){const t=z();return x.useMemo(function(){const o=l=>{if(l.isKilled)return;if(l.button===2){t.dispatch({type:"pointer",target:"selection",handle:e,name:"right_click",..._n(l)});return}if(l.button!==0)return;const u=Yp(l.currentTarget);function d(){u.removeEventListener("pointerup",d),Au(u,l)}Mu(u,l),u.addEventListener("pointerup",d),t.dispatch({name:"pointer_down",type:"pointer",target:"selection",handle:e,..._n(l)}),Ut(l)};let s,i;function a(l){l.isKilled||l.button===0&&(l.clientX===s&&l.clientY===i||(s=l.clientX,i=l.clientY,t.dispatch({name:"pointer_move",type:"pointer",target:"selection",handle:e,..._n(l)})))}return{onPointerDown:o,onPointerMove:a,onPointerUp:l=>{l.isKilled||l.button===0&&t.dispatch({name:"pointer_up",type:"pointer",target:"selection",handle:e,..._n(l)})}}},[t,e])}const b8=20,P8=8;function hx(e,t=b8){return Math.max(P8,Math.ceil(e/t))}class Z2 extends Hi{constructor(n){super({...n,isFilled:!1,isClosed:!1});m(this,"_center");m(this,"radius");m(this,"start");m(this,"end");m(this,"measure");m(this,"length");m(this,"angleStart");m(this,"angleEnd");const{center:r,radius:o,sweepFlag:s,largeArcFlag:i,start:a,end:c}=n;if(a.equals(c))throw Error("Arc must have different start and end points.");this.angleStart=P.Angle(r,a),this.angleEnd=P.Angle(r,c),this.measure=C5(this.angleStart,this.angleEnd,s,i),this.length=this.measure*o,this.start=a,this.end=c,this._center=r,this.radius=o}nearestPoint(n){const{_center:r,measure:o,radius:s,angleEnd:i,angleStart:a,start:c,end:l}=this,u=zS(o,a,i,r.angle(n));if(u<=0)return c;if(u>=1)return l;const d=r.clone().add(n.clone().sub(r).uni().mul(s));let p,f=1/0,y;for(const g of[c,l,d])y=P.Dist2(n,g),y<f&&(p=g,f=y);if(!p)throw Error("nearest point not found");return p}hitTestLineSegment(n,r){const{_center:o,radius:s,measure:i,angleStart:a,angleEnd:c}=this,l=Nf(n,r,o,s);return l===null?!1:l.some(u=>{const d=zS(i,a,c,o.angle(u));return d>=0&&d<=1})}getVertices(){const{_center:n,measure:r,length:o,radius:s,angleStart:i}=this,a=[];for(let c=0,l=hx(Math.abs(o));c<l+1;c++){const u=c/l*r,d=i+u;a.push($i(n,s,d))}return a}}class px extends Hi{constructor(n){super({isClosed:!0,...n});m(this,"_center");m(this,"radius");m(this,"x");m(this,"y");this.config=n;const{x:r=0,y:o=0,radius:s}=n;this.x=r,this.y=o,this._center=new P(s+r,s+o),this.radius=s}getBounds(){return new ne(this.x,this.y,this.radius*2,this.radius*2)}getVertices(){const{_center:n,radius:r}=this,o=Oe*r,s=[];for(let i=0,a=hx(o);i<a;i++){const c=i/a*Oe;s.push($i(n,r,c))}return s}nearestPoint(n){const{_center:r,radius:o}=this;return r.equals(n)?P.AddXY(r,o,0):r.clone().add(n.clone().sub(r).uni().mul(o))}hitTestLineSegment(n,r,o=0){const{_center:s,radius:i}=this;return Nf(n,r,s,i+o)!==null}}class C8 extends Ki{constructor(n){const{start:r,cp1:o,cp2:s,end:i}=n;super({...n,points:[r,i]});m(this,"a");m(this,"b");m(this,"c");m(this,"d");this.a=r,this.b=o,this.c=s,this.d=i}getVertices(){const n=[],{a:r,b:o,c:s,d:i}=this;for(let a=0,c=10;a<=c;a++){const l=a/c;n.push(new P((1-l)*(1-l)*(1-l)*r.x+3*((1-l)*(1-l))*l*o.x+3*(1-l)*(l*l)*s.x+l*l*l*i.x,(1-l)*(1-l)*(1-l)*r.y+3*((1-l)*(1-l))*l*o.y+3*(1-l)*(l*l)*s.y+l*l*l*i.y))}return n}midPoint(){return I8(this,.5)}nearestPoint(n){let r,o=1/0,s,i;for(const a of this.segments)i=a.nearestPoint(n),s=P.Dist2(i,n),s<o&&(r=i,o=s);if(!r)throw Error("nearest point not found");return r}}function I8(e,t){const{a:n,b:r,c:o,d:s}=e;return new P((1-t)*(1-t)*(1-t)*n.x+3*((1-t)*(1-t))*t*r.x+3*(1-t)*(t*t)*o.x+t*t*t*s.x,(1-t)*(1-t)*(1-t)*n.y+3*((1-t)*(1-t))*t*r.y+3*(1-t)*(t*t)*o.y+t*t*t*s.y)}class E8 extends Hi{constructor(n){super({...n,isClosed:!1,isFilled:!1});m(this,"points");m(this,"_segments");m(this,"_length");const{points:r}=n;this.points=r}get segments(){if(!this._segments){this._segments=[];const{points:n}=this,r=n.length,o=r-2,s=1.25;for(let i=0;i<r-1;i++){const a=i===0?n[0]:n[i-1],c=n[i],l=n[i+1],u=i===o?l:n[i+2],d=c,p=i===0?a:new P(c.x+(l.x-a.x)/6*s,c.y+(l.y-a.y)/6*s),f=i===o?l:new P(l.x-(u.x-c.x)/6*s,l.y-(u.y-c.y)/6*s),y=l;this._segments.push(new C8({start:d,cp1:p,cp2:f,end:y}))}}return this._segments}get length(){return this._length||(this._length=this.segments.reduce((n,r)=>n+r.length,0)),this._length}getVertices(){const n=this.segments.reduce((r,o)=>r.concat(o.vertices),[]);return n.push(this.points[this.points.length-1]),n}nearestPoint(n){let r,o=1/0,s,i;for(const a of this.segments)i=a.nearestPoint(n),s=P.Dist2(i,n),s<o&&(r=i,o=s);if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(n,r){return this.segments.some(o=>o.hitTestLineSegment(n,r))}}class Q2 extends Hi{constructor(n){super({...n,isClosed:!0});m(this,"w");m(this,"h");m(this,"_edges");this.config=n;const{width:r,height:o}=n;this.w=r,this.h=o}get edges(){if(!this._edges){const{vertices:n}=this;this._edges=[];for(let r=0,o=n.length;r<o;r++){const s=n[r],i=n[(r+1)%o];this._edges.push(new lu({start:s,end:i}))}}return this._edges}getVertices(){const n=Math.max(1,this.w),r=Math.max(1,this.h),o=n/2,s=r/2,i=Math.pow(o-s,2)/Math.pow(o+s,2),a=Pe*(o+s)*(1+3*i/(10+Math.sqrt(4-3*i))),c=hx(a),l=Oe/c,u=Math.cos(l),d=Math.sin(l);let p=0,f=1,y=0,g=1;const w=Array(c);for(let S=0;S<c;S++)w[S]=new P(o+o*f,s+s*p),y=d*f+u*p,g=u*f-d*p,p=y,f=g;return w}nearestPoint(n){let r,o=1/0,s,i;for(const a of this.edges)i=a.nearestPoint(n),s=P.Dist2(i,n),s<o&&(r=i,o=s);if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(n,r){return this.edges.some(o=>o.hitTestLineSegment(n,r))}getBounds(){return new ne(0,0,this.w,this.h)}}const Co=18;class _8 extends Q2{constructor(t){super({...t}),this.config=t}getVertices(){const t=Math.max(1,this.w),n=Math.max(1,this.h),r=t/2,o=n/2,s=Array(Co);let i,a;if(n>t)for(let c=0;c<Co-1;c++)i=-Pe+Pe*c/(Co-2),a=Pe*c/(Co-2),s[c]=new P(r+r*Math.cos(i),r+r*Math.sin(i)),s[c+(Co-1)]=new P(r+r*Math.cos(a),n-r+r*Math.sin(a));else for(let c=0;c<Co-1;c++)i=-ze+Pe*c/(Co-2),a=ze+Pe*-c/(Co-2),s[c]=new P(t-o+o*Math.cos(i),n-o+o*Math.sin(i)),s[c+(Co-1)]=new P(o-o*Math.cos(a),n-o+o*Math.sin(a));return s}}function aP(e,t,n,r,o){const s=F5,i=n?N5:0,a=e-i,c=e+i,l=r?0:s,u=o?t:t-s;return a<l?Math.min(1,(l-a)/s):c>u?-Math.min(1,(c-u)/s):0}function fx(e){if(!e.inputs.isDragging||e.inputs.isPanning||!e.getInstanceState().canMoveCamera)return;const{inputs:{currentScreenPoint:{x:t,y:n}}}=e,r=e.getZoomLevel(),o=e.getViewportScreenBounds(),s=o.w<1e3?.612:1,i=o.h<1e3?.612:1,{isCoarsePointer:a,insets:[c,l,u,d]}=e.getInstanceState(),p=aP(t,o.w,a,d,l),f=aP(n,o.h,a,c,u);if(p===0&&f===0)return;const y=e.user.getEdgeScrollSpeed()*L5,g=y*p*s/r,w=y*f*i/r,S=e.getCamera();e.setCamera({x:S.x+g,y:S.y+w})}async function k8({shouldReload:e=!0}={}){H3(),await Promise.all(dx().map(t=>Yz(t))),U3(),e&&window.location.reload()}typeof window<"u"&&(window.__tldraw__hardReset=k8);function T8(e,t="_blank"){tx.openWindow(e,t)}var Jc=function(e){return e&&e.Math===Math&&e},Dn=Jc(typeof globalThis=="object"&&globalThis)||Jc(typeof window=="object"&&window)||Jc(typeof self=="object"&&self)||Jc(typeof tn=="object"&&tn)||Jc(typeof tn=="object"&&tn)||function(){return this}()||Function("return this")(),gx={},vn=function(e){try{return!!e()}catch{return!0}},$8=vn,Xs=!$8(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),M8=vn,Gf=!M8(function(){var e=(function(){}).bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),A8=Gf,Td=Function.prototype.call,es=A8?Td.bind(Td):function(){return Td.apply(Td,arguments)},J2={},eT={}.propertyIsEnumerable,tT=Object.getOwnPropertyDescriptor,j8=tT&&!eT.call({1:2},1);J2.f=j8?function(t){var n=tT(this,t);return!!n&&n.enumerable}:eT;var nT=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}},rT=Gf,oT=Function.prototype,XS=oT.call,O8=rT&&oT.bind.bind(XS,XS),jt=rT?O8:function(e){return function(){return XS.apply(e,arguments)}},sT=jt,D8=sT({}.toString),R8=sT("".slice),Cc=function(e){return R8(D8(e),8,-1)},L8=jt,F8=vn,N8=Cc,Cm=Object,z8=L8("".split),B8=F8(function(){return!Cm("z").propertyIsEnumerable(0)})?function(e){return N8(e)==="String"?z8(e,""):Cm(e)}:Cm,Yf=function(e){return e==null},U8=Yf,H8=TypeError,Ic=function(e){if(U8(e))throw new H8("Can't call method on "+e);return e},K8=B8,W8=Ic,Xf=function(e){return K8(W8(e))},Im=typeof document=="object"&&document.all,xn=typeof Im>"u"&&Im!==void 0?function(e){return typeof e=="function"||e===Im}:function(e){return typeof e=="function"},V8=xn,Wi=function(e){return typeof e=="object"?e!==null:V8(e)},Em=Dn,G8=xn,Y8=function(e){return G8(e)?e:void 0},qf=function(e,t){return arguments.length<2?Y8(Em[e]):Em[e]&&Em[e][t]},X8=jt,iT=X8({}.isPrototypeOf),q8=typeof navigator<"u"&&String(navigator.userAgent)||"",aT=Dn,_m=q8,cP=aT.process,lP=aT.Deno,uP=cP&&cP.versions||lP&&lP.version,dP=uP&&uP.v8,Ar,tf;dP&&(Ar=dP.split("."),tf=Ar[0]>0&&Ar[0]<4?1:+(Ar[0]+Ar[1]));!tf&&_m&&(Ar=_m.match(/Edge\/(\d+)/),(!Ar||Ar[1]>=74)&&(Ar=_m.match(/Chrome\/(\d+)/),Ar&&(tf=+Ar[1])));var Z8=tf,hP=Z8,Q8=vn,J8=Dn,e7=J8.String,cT=!!Object.getOwnPropertySymbols&&!Q8(function(){var e=Symbol("symbol detection");return!e7(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&hP&&hP<41}),t7=cT,lT=t7&&!Symbol.sham&&typeof Symbol.iterator=="symbol",n7=qf,r7=xn,o7=iT,s7=lT,i7=Object,uT=s7?function(e){return typeof e=="symbol"}:function(e){var t=n7("Symbol");return r7(t)&&o7(t.prototype,i7(e))},a7=String,c7=function(e){try{return a7(e)}catch{return"Object"}},l7=xn,u7=c7,d7=TypeError,mx=function(e){if(l7(e))return e;throw new d7(u7(e)+" is not a function")},h7=mx,p7=Yf,yx=function(e,t){var n=e[t];return p7(n)?void 0:h7(n)},km=es,Tm=xn,$m=Wi,f7=TypeError,g7=function(e,t){var n,r;if(t==="string"&&Tm(n=e.toString)&&!$m(r=km(n,e))||Tm(n=e.valueOf)&&!$m(r=km(n,e))||t!=="string"&&Tm(n=e.toString)&&!$m(r=km(n,e)))return r;throw new f7("Can't convert object to primitive value")},dT={exports:{}},pP=Dn,m7=Object.defineProperty,Sx=function(e,t){try{m7(pP,e,{value:t,configurable:!0,writable:!0})}catch{pP[e]=t}return t},y7=Dn,S7=Sx,fP="__core-js_shared__",gP=dT.exports=y7[fP]||S7(fP,{});(gP.versions||(gP.versions=[])).push({version:"3.37.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE",source:"https://github.com/zloirock/core-js"});var vx=dT.exports,mP=vx,xx=function(e,t){return mP[e]||(mP[e]=t||{})},v7=Ic,x7=Object,Lu=function(e){return x7(v7(e))},w7=jt,b7=Lu,P7=w7({}.hasOwnProperty),qs=Object.hasOwn||function(t,n){return P7(b7(t),n)},C7=jt,I7=0,E7=Math.random(),_7=C7(1 .toString),hT=function(e){return"Symbol("+(e===void 0?"":e)+")_"+_7(++I7+E7,36)},k7=Dn,T7=xx,yP=qs,$7=hT,M7=cT,A7=lT,Aa=k7.Symbol,Mm=T7("wks"),j7=A7?Aa.for||Aa:Aa&&Aa.withoutSetter||$7,ts=function(e){return yP(Mm,e)||(Mm[e]=M7&&yP(Aa,e)?Aa[e]:j7("Symbol."+e)),Mm[e]},O7=es,SP=Wi,vP=uT,D7=yx,R7=g7,L7=ts,F7=TypeError,N7=L7("toPrimitive"),z7=function(e,t){if(!SP(e)||vP(e))return e;var n=D7(e,N7),r;if(n){if(t===void 0&&(t="default"),r=O7(n,e,t),!SP(r)||vP(r))return r;throw new F7("Can't convert object to primitive value")}return t===void 0&&(t="number"),R7(e,t)},B7=z7,U7=uT,pT=function(e){var t=B7(e,"string");return U7(t)?t:t+""},H7=Dn,xP=Wi,qS=H7.document,K7=xP(qS)&&xP(qS.createElement),fT=function(e){return K7?qS.createElement(e):{}},W7=Xs,V7=vn,G7=fT,gT=!W7&&!V7(function(){return Object.defineProperty(G7("div"),"a",{get:function(){return 7}}).a!==7}),Y7=Xs,X7=es,q7=J2,Z7=nT,Q7=Xf,J7=pT,eB=qs,tB=gT,wP=Object.getOwnPropertyDescriptor;gx.f=Y7?wP:function(t,n){if(t=Q7(t),n=J7(n),tB)try{return wP(t,n)}catch{}if(eB(t,n))return Z7(!X7(q7.f,t,n),t[n])};var Ec={},nB=Xs,rB=vn,mT=nB&&rB(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),oB=Wi,sB=String,iB=TypeError,Vi=function(e){if(oB(e))return e;throw new iB(sB(e)+" is not an object")},aB=Xs,cB=gT,lB=mT,$d=Vi,bP=pT,uB=TypeError,Am=Object.defineProperty,dB=Object.getOwnPropertyDescriptor,jm="enumerable",Om="configurable",Dm="writable";Ec.f=aB?lB?function(t,n,r){if($d(t),n=bP(n),$d(r),typeof t=="function"&&n==="prototype"&&"value"in r&&Dm in r&&!r[Dm]){var o=dB(t,n);o&&o[Dm]&&(t[n]=r.value,r={configurable:Om in r?r[Om]:o[Om],enumerable:jm in r?r[jm]:o[jm],writable:!1})}return Am(t,n,r)}:Am:function(t,n,r){if($d(t),n=bP(n),$d(r),cB)try{return Am(t,n,r)}catch{}if("get"in r||"set"in r)throw new uB("Accessors not supported");return"value"in r&&(t[n]=r.value),t};var hB=Xs,pB=Ec,fB=nT,wx=hB?function(e,t,n){return pB.f(e,t,fB(1,n))}:function(e,t,n){return e[t]=n,e},yT={exports:{}},ZS=Xs,gB=qs,ST=Function.prototype,mB=ZS&&Object.getOwnPropertyDescriptor,bx=gB(ST,"name"),yB=bx&&(function(){}).name==="something",SB=bx&&(!ZS||ZS&&mB(ST,"name").configurable),vB={EXISTS:bx,PROPER:yB,CONFIGURABLE:SB},xB=jt,wB=xn,QS=vx,bB=xB(Function.toString);wB(QS.inspectSource)||(QS.inspectSource=function(e){return bB(e)});var vT=QS.inspectSource,PB=Dn,CB=xn,PP=PB.WeakMap,IB=CB(PP)&&/native code/.test(String(PP)),EB=xx,_B=hT,CP=EB("keys"),xT=function(e){return CP[e]||(CP[e]=_B(e))},Px={},kB=IB,wT=Dn,TB=Wi,$B=wx,Rm=qs,Lm=vx,MB=xT,AB=Px,IP="Object already initialized",JS=wT.TypeError,jB=wT.WeakMap,nf,uu,rf,OB=function(e){return rf(e)?uu(e):nf(e,{})},DB=function(e){return function(t){var n;if(!TB(t)||(n=uu(t)).type!==e)throw new JS("Incompatible receiver, "+e+" required");return n}};if(kB||Lm.state){var Gr=Lm.state||(Lm.state=new jB);Gr.get=Gr.get,Gr.has=Gr.has,Gr.set=Gr.set,nf=function(e,t){if(Gr.has(e))throw new JS(IP);return t.facade=e,Gr.set(e,t),t},uu=function(e){return Gr.get(e)||{}},rf=function(e){return Gr.has(e)}}else{var sa=MB("state");AB[sa]=!0,nf=function(e,t){if(Rm(e,sa))throw new JS(IP);return t.facade=e,$B(e,sa,t),t},uu=function(e){return Rm(e,sa)?e[sa]:{}},rf=function(e){return Rm(e,sa)}}var bT={set:nf,get:uu,has:rf,enforce:OB,getterFor:DB},Cx=jt,RB=vn,LB=xn,Md=qs,ev=Xs,FB=vB.CONFIGURABLE,NB=vT,PT=bT,zB=PT.enforce,BB=PT.get,EP=String,Ch=Object.defineProperty,UB=Cx("".slice),HB=Cx("".replace),KB=Cx([].join),WB=ev&&!RB(function(){return Ch(function(){},"length",{value:8}).length!==8}),VB=String(String).split("String"),GB=yT.exports=function(e,t,n){UB(EP(t),0,7)==="Symbol("&&(t="["+HB(EP(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Md(e,"name")||FB&&e.name!==t)&&(ev?Ch(e,"name",{value:t,configurable:!0}):e.name=t),WB&&n&&Md(n,"arity")&&e.length!==n.arity&&Ch(e,"length",{value:n.arity});try{n&&Md(n,"constructor")&&n.constructor?ev&&Ch(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var r=zB(e);return Md(r,"source")||(r.source=KB(VB,typeof t=="string"?t:"")),e};Function.prototype.toString=GB(function(){return LB(this)&&BB(this).source||NB(this)},"toString");var YB=yT.exports,XB=xn,qB=Ec,ZB=YB,QB=Sx,CT=function(e,t,n,r){r||(r={});var o=r.enumerable,s=r.name!==void 0?r.name:t;if(XB(n)&&ZB(n,s,r),r.global)o?e[t]=n:QB(t,n);else{try{r.unsafe?e[t]&&(o=!0):delete e[t]}catch{}o?e[t]=n:qB.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},IT={},JB=Math.ceil,e9=Math.floor,t9=Math.trunc||function(t){var n=+t;return(n>0?e9:JB)(n)},n9=t9,Gi=function(e){var t=+e;return t!==t||t===0?0:n9(t)},r9=Gi,o9=Math.max,s9=Math.min,i9=function(e,t){var n=r9(e);return n<0?o9(n+t,0):s9(n,t)},a9=Gi,c9=Math.min,ET=function(e){var t=a9(e);return t>0?c9(t,9007199254740991):0},l9=ET,Fu=function(e){return l9(e.length)},u9=Xf,d9=i9,h9=Fu,_P=function(e){return function(t,n,r){var o=u9(t),s=h9(o);if(s===0)return!e&&-1;var i=d9(r,s),a;if(e&&n!==n){for(;s>i;)if(a=o[i++],a!==a)return!0}else for(;s>i;i++)if((e||i in o)&&o[i]===n)return e||i||0;return!e&&-1}},p9={includes:_P(!0),indexOf:_P(!1)},f9=jt,Fm=qs,g9=Xf,m9=p9.indexOf,y9=Px,kP=f9([].push),_T=function(e,t){var n=g9(e),r=0,o=[],s;for(s in n)!Fm(y9,s)&&Fm(n,s)&&kP(o,s);for(;t.length>r;)Fm(n,s=t[r++])&&(~m9(o,s)||kP(o,s));return o},Ix=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],S9=_T,v9=Ix,x9=v9.concat("length","prototype");IT.f=Object.getOwnPropertyNames||function(t){return S9(t,x9)};var kT={};kT.f=Object.getOwnPropertySymbols;var w9=qf,b9=jt,P9=IT,C9=kT,I9=Vi,E9=b9([].concat),_9=w9("Reflect","ownKeys")||function(t){var n=P9.f(I9(t)),r=C9.f;return r?E9(n,r(t)):n},TP=qs,k9=_9,T9=gx,$9=Ec,M9=function(e,t,n){for(var r=k9(t),o=$9.f,s=T9.f,i=0;i<r.length;i++){var a=r[i];!TP(e,a)&&!(n&&TP(n,a))&&o(e,a,s(t,a))}},A9=vn,j9=xn,O9=/#|\.prototype\./,Nu=function(e,t){var n=R9[D9(e)];return n===F9?!0:n===L9?!1:j9(t)?A9(t):!!t},D9=Nu.normalize=function(e){return String(e).replace(O9,".").toLowerCase()},R9=Nu.data={},L9=Nu.NATIVE="N",F9=Nu.POLYFILL="P",N9=Nu,Ad=Dn,z9=gx.f,B9=wx,U9=CT,H9=Sx,K9=M9,W9=N9,_c=function(e,t){var n=e.target,r=e.global,o=e.stat,s,i,a,c,l,u;if(r?i=Ad:o?i=Ad[n]||H9(n,{}):i=Ad[n]&&Ad[n].prototype,i)for(a in t){if(l=t[a],e.dontCallGetSet?(u=z9(i,a),c=u&&u.value):c=i[a],s=W9(r?a:n+(o?".":"#")+a,e.forced),!s&&c!==void 0){if(typeof l==typeof c)continue;K9(l,c)}(e.sham||c&&c.sham)&&B9(l,"sham",!0),U9(i,a,l,e)}},TT={},V9=_T,G9=Ix,Y9=Object.keys||function(t){return V9(t,G9)},X9=Xs,q9=mT,Z9=Ec,Q9=Vi,J9=Xf,eU=Y9;TT.f=X9&&!q9?Object.defineProperties:function(t,n){Q9(t);for(var r=J9(n),o=eU(n),s=o.length,i=0,a;s>i;)Z9.f(t,a=o[i++],r[a]);return t};var tU=qf,nU=tU("document","documentElement"),rU=Vi,oU=TT,$P=Ix,sU=Px,iU=nU,aU=fT,cU=xT,MP=">",AP="<",tv="prototype",nv="script",$T=cU("IE_PROTO"),Nm=function(){},MT=function(e){return AP+nv+MP+e+AP+"/"+nv+MP},jP=function(e){e.write(MT("")),e.close();var t=e.parentWindow.Object;return e=null,t},lU=function(){var e=aU("iframe"),t="java"+nv+":",n;return e.style.display="none",iU.appendChild(e),e.src=String(t),n=e.contentWindow.document,n.open(),n.write(MT("document.F=Object")),n.close(),n.F},jd,Ih=function(){try{jd=new ActiveXObject("htmlfile")}catch{}Ih=typeof document<"u"?document.domain&&jd?jP(jd):lU():jP(jd);for(var e=$P.length;e--;)delete Ih[tv][$P[e]];return Ih()};sU[$T]=!0;var AT=Object.create||function(t,n){var r;return t!==null?(Nm[tv]=rU(t),r=new Nm,Nm[tv]=null,r[$T]=t):r=Ih(),n===void 0?r:oU.f(r,n)},uU=ts,dU=AT,hU=Ec.f,rv=uU("unscopables"),ov=Array.prototype;ov[rv]===void 0&&hU(ov,rv,{configurable:!0,value:dU(null)});var Ex=function(e){ov[rv][e]=!0},pU=_c,fU=Lu,gU=Fu,mU=Gi,yU=Ex;pU({target:"Array",proto:!0},{at:function(t){var n=fU(this),r=gU(n),o=mU(t),s=o>=0?o:r+o;return s<0||s>=r?void 0:n[s]}});yU("at");var SU=Dn,vU=jt,zu=function(e,t){return vU(SU[e].prototype[t])},xU=zu;xU("Array","at");var wU=Cc,jT=Array.isArray||function(t){return wU(t)==="Array"},bU=TypeError,PU=9007199254740991,CU=function(e){if(e>PU)throw bU("Maximum allowed index exceeded");return e},IU=Cc,EU=jt,_U=function(e){if(IU(e)==="Function")return EU(e)},OP=_U,kU=mx,TU=Gf,$U=OP(OP.bind),MU=function(e,t){return kU(e),t===void 0?e:TU?$U(e,t):function(){return e.apply(t,arguments)}},AU=jT,jU=Fu,OU=CU,DU=MU,OT=function(e,t,n,r,o,s,i,a){for(var c=o,l=0,u=i?DU(i,a):!1,d,p;l<r;)l in n&&(d=u?u(n[l],l,t):n[l],s>0&&AU(d)?(p=jU(d),c=OT(e,t,d,p,c,s-1)-1):(OU(c+1),e[c]=d),c++),l++;return c},DT=OT,RU=ts,LU=RU("toStringTag"),RT={};RT[LU]="z";var FU=String(RT)==="[object z]",NU=FU,zU=xn,Eh=Cc,BU=ts,UU=BU("toStringTag"),HU=Object,KU=Eh(function(){return arguments}())==="Arguments",WU=function(e,t){try{return e[t]}catch{}},LT=NU?Eh:function(e){var t,n,r;return e===void 0?"Undefined":e===null?"Null":typeof(n=WU(t=HU(e),UU))=="string"?n:KU?Eh(t):(r=Eh(t))==="Object"&&zU(t.callee)?"Arguments":r},VU=jt,GU=vn,FT=xn,YU=LT,XU=qf,qU=vT,NT=function(){},zT=XU("Reflect","construct"),_x=/^\s*(?:class|function)\b/,ZU=VU(_x.exec),QU=!_x.test(NT),el=function(t){if(!FT(t))return!1;try{return zT(NT,[],t),!0}catch{return!1}},BT=function(t){if(!FT(t))return!1;switch(YU(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return QU||!!ZU(_x,qU(t))}catch{return!0}};BT.sham=!0;var JU=!zT||GU(function(){var e;return el(el.call)||!el(Object)||!el(function(){e=!0})||e})?BT:el,DP=jT,eH=JU,tH=Wi,nH=ts,rH=nH("species"),RP=Array,oH=function(e){var t;return DP(e)&&(t=e.constructor,eH(t)&&(t===RP||DP(t.prototype))?t=void 0:tH(t)&&(t=t[rH],t===null&&(t=void 0))),t===void 0?RP:t},sH=oH,UT=function(e,t){return new(sH(e))(t===0?0:t)},iH=_c,aH=DT,cH=mx,lH=Lu,uH=Fu,dH=UT;iH({target:"Array",proto:!0},{flatMap:function(t){var n=lH(this),r=uH(n),o;return cH(t),o=dH(n,0),o.length=aH(o,n,n,r,0,1,t,arguments.length>1?arguments[1]:void 0),o}});var hH=Ex;hH("flatMap");var pH=zu;pH("Array","flatMap");var fH=_c,gH=DT,mH=Lu,yH=Fu,SH=Gi,vH=UT;fH({target:"Array",proto:!0},{flat:function(){var t=arguments.length?arguments[0]:void 0,n=mH(this),r=yH(n),o=vH(n,0);return o.length=gH(o,n,n,r,0,t===void 0?1:SH(t)),o}});var xH=Ex;xH("flat");var wH=zu;wH("Array","flat");var bH=LT,PH=String,Bu=function(e){if(bH(e)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return PH(e)},CH=_c,IH=jt,EH=Ic,_H=Gi,kH=Bu,TH=vn,$H=IH("".charAt),MH=TH(function(){return"𠮷".at(-2)!=="\uD842"});CH({target:"String",proto:!0,forced:MH},{at:function(t){var n=kH(EH(this)),r=n.length,o=_H(t),s=o>=0?o:r+o;return s<0||s>=r?void 0:$H(n,s)}});var AH=zu;AH("String","at");var jH=Vi,HT=function(){var e=jH(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},kx=vn,OH=Dn,Tx=OH.RegExp,$x=kx(function(){var e=Tx("a","y");return e.lastIndex=2,e.exec("abcd")!==null}),DH=$x||kx(function(){return!Tx("a","y").sticky}),RH=$x||kx(function(){var e=Tx("^r","gy");return e.lastIndex=2,e.exec("str")!==null}),LH={BROKEN_CARET:RH,MISSED_STICKY:DH,UNSUPPORTED_Y:$x},FH=vn,NH=Dn,zH=NH.RegExp,BH=FH(function(){var e=zH(".","s");return!(e.dotAll&&e.test(`
|
|
`)&&e.flags==="s")}),UH=vn,HH=Dn,KH=HH.RegExp,WH=UH(function(){var e=KH("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),ja=es,Zf=jt,VH=Bu,GH=HT,YH=LH,XH=xx,qH=AT,ZH=bT.get,QH=BH,JH=WH,eK=XH("native-string-replace",String.prototype.replace),of=RegExp.prototype.exec,sv=of,tK=Zf("".charAt),nK=Zf("".indexOf),rK=Zf("".replace),zm=Zf("".slice),iv=function(){var e=/a/,t=/b*/g;return ja(of,e,"a"),ja(of,t,"a"),e.lastIndex!==0||t.lastIndex!==0}(),KT=YH.BROKEN_CARET,av=/()??/.exec("")[1]!==void 0,oK=iv||av||KT||QH||JH;oK&&(sv=function(t){var n=this,r=ZH(n),o=VH(t),s=r.raw,i,a,c,l,u,d,p;if(s)return s.lastIndex=n.lastIndex,i=ja(sv,s,o),n.lastIndex=s.lastIndex,i;var f=r.groups,y=KT&&n.sticky,g=ja(GH,n),w=n.source,S=0,v=o;if(y&&(g=rK(g,"y",""),nK(g,"g")===-1&&(g+="g"),v=zm(o,n.lastIndex),n.lastIndex>0&&(!n.multiline||n.multiline&&tK(o,n.lastIndex-1)!==`
|
|
`)&&(w="(?: "+w+")",v=" "+v,S++),a=new RegExp("^(?:"+w+")",g)),av&&(a=new RegExp("^"+w+"$(?!\\s)",g)),iv&&(c=n.lastIndex),l=ja(of,y?a:n,v),y?l?(l.input=zm(l.input,S),l[0]=zm(l[0],S),l.index=n.lastIndex,n.lastIndex+=l[0].length):n.lastIndex=0:iv&&l&&(n.lastIndex=n.global?l.index+l[0].length:c),av&&l&&l.length>1&&ja(eK,l[0],a,function(){for(u=1;u<arguments.length-2;u++)arguments[u]===void 0&&(l[u]=void 0)}),l&&f)for(l.groups=d=qH(null),u=0;u<f.length;u++)p=f[u],d[p[0]]=l[p[1]];return l});var Mx=sv,sK=_c,LP=Mx;sK({target:"RegExp",proto:!0,forced:/./.exec!==LP},{exec:LP});var iK=Gf,WT=Function.prototype,FP=WT.apply,NP=WT.call,aK=typeof Reflect=="object"&&Reflect.apply||(iK?NP.bind(FP):function(){return NP.apply(FP,arguments)}),zP=es,BP=CT,cK=Mx,UP=vn,VT=ts,lK=wx,uK=VT("species"),Bm=RegExp.prototype,dK=function(e,t,n,r){var o=VT(e),s=!UP(function(){var l={};return l[o]=function(){return 7},""[e](l)!==7}),i=s&&!UP(function(){var l=!1,u=/a/;return e==="split"&&(u={},u.constructor={},u.constructor[uK]=function(){return u},u.flags="",u[o]=/./[o]),u.exec=function(){return l=!0,null},u[o](""),!l});if(!s||!i||n){var a=/./[o],c=t(o,""[e],function(l,u,d,p,f){var y=u.exec;return y===cK||y===Bm.exec?s&&!f?{done:!0,value:zP(a,u,d,p)}:{done:!0,value:zP(l,d,u,p)}:{done:!1}});BP(String.prototype,e,c[0]),BP(Bm,o,c[1])}r&&lK(Bm[o],"sham",!0)},Ax=jt,hK=Gi,pK=Bu,fK=Ic,gK=Ax("".charAt),HP=Ax("".charCodeAt),mK=Ax("".slice),KP=function(e){return function(t,n){var r=pK(fK(t)),o=hK(n),s=r.length,i,a;return o<0||o>=s?e?"":void 0:(i=HP(r,o),i<55296||i>56319||o+1===s||(a=HP(r,o+1))<56320||a>57343?e?gK(r,o):i:e?mK(r,o,o+2):(i-55296<<10)+(a-56320)+65536)}},yK={codeAt:KP(!1),charAt:KP(!0)},SK=yK.charAt,vK=function(e,t,n){return t+(n?SK(e,t).length:1)},jx=jt,xK=Lu,wK=Math.floor,Um=jx("".charAt),bK=jx("".replace),Hm=jx("".slice),PK=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,CK=/\$([$&'`]|\d{1,2})/g,GT=function(e,t,n,r,o,s){var i=n+e.length,a=r.length,c=CK;return o!==void 0&&(o=xK(o),c=PK),bK(s,c,function(l,u){var d;switch(Um(u,0)){case"$":return"$";case"&":return e;case"`":return Hm(t,0,n);case"'":return Hm(t,i);case"<":d=o[Hm(u,1,-1)];break;default:var p=+u;if(p===0)return l;if(p>a){var f=wK(p/10);return f===0?l:f<=a?r[f-1]===void 0?Um(u,1):r[f-1]+Um(u,1):l}d=r[p-1]}return d===void 0?"":d})},WP=es,IK=Vi,EK=xn,_K=Cc,kK=Mx,TK=TypeError,$K=function(e,t){var n=e.exec;if(EK(n)){var r=WP(n,e,t);return r!==null&&IK(r),r}if(_K(e)==="RegExp")return WP(kK,e,t);throw new TK("RegExp#exec called on incompatible receiver")},MK=aK,VP=es,Qf=jt,AK=dK,jK=vn,OK=Vi,DK=xn,RK=Yf,LK=Gi,FK=ET,ia=Bu,NK=Ic,zK=vK,BK=yx,UK=GT,HK=$K,KK=ts,cv=KK("replace"),WK=Math.max,VK=Math.min,GK=Qf([].concat),Km=Qf([].push),GP=Qf("".indexOf),YP=Qf("".slice),YK=function(e){return e===void 0?e:String(e)},XK=function(){return"a".replace(/./,"$0")==="$0"}(),XP=function(){return/./[cv]?/./[cv]("a","$0")==="":!1}(),qK=!jK(function(){var e=/./;return e.exec=function(){var t=[];return t.groups={a:"7"},t},"".replace(e,"$<a>")!=="7"});AK("replace",function(e,t,n){var r=XP?"$":"$0";return[function(s,i){var a=NK(this),c=RK(s)?void 0:BK(s,cv);return c?VP(c,s,a,i):VP(t,ia(a),s,i)},function(o,s){var i=OK(this),a=ia(o);if(typeof s=="string"&&GP(s,r)===-1&&GP(s,"$<")===-1){var c=n(t,i,a,s);if(c.done)return c.value}var l=DK(s);l||(s=ia(s));var u=i.global,d;u&&(d=i.unicode,i.lastIndex=0);for(var p=[],f;f=HK(i,a),!(f===null||(Km(p,f),!u));){var y=ia(f[0]);y===""&&(i.lastIndex=zK(a,FK(i.lastIndex),d))}for(var g="",w=0,S=0;S<p.length;S++){f=p[S];for(var v=ia(f[0]),b=WK(VK(LK(f.index),a.length),0),E=[],C,I=1;I<f.length;I++)Km(E,YK(f[I]));var _=f.groups;if(l){var k=GK([v],E,b,a);_!==void 0&&Km(k,_),C=ia(MK(s,void 0,k))}else C=UK(v,a,b,E,_,s);b>=w&&(g+=YP(a,w,b)+C,w=b+v.length)}return g+YP(a,w)}]},!qK||!XK||XP);var ZK=Wi,QK=Cc,JK=ts,eW=JK("match"),tW=function(e){var t;return ZK(e)&&((t=e[eW])!==void 0?!!t:QK(e)==="RegExp")},nW=es,rW=qs,oW=iT,sW=HT,qP=RegExp.prototype,iW=function(e){var t=e.flags;return t===void 0&&!("flags"in qP)&&!rW(e,"flags")&&oW(qP,e)?nW(sW,e):t},aW=_c,cW=es,Ox=jt,ZP=Ic,lW=xn,uW=Yf,dW=tW,tl=Bu,hW=yx,pW=iW,fW=GT,gW=ts,mW=gW("replace"),yW=TypeError,Wm=Ox("".indexOf);Ox("".replace);var QP=Ox("".slice),SW=Math.max;aW({target:"String",proto:!0},{replaceAll:function(t,n){var r=ZP(this),o,s,i,a,c,l,u,d,p,f=0,y=0,g="";if(!uW(t)){if(o=dW(t),o&&(s=tl(ZP(pW(t))),!~Wm(s,"g")))throw new yW("`.replaceAll` does not allow non-global regexes");if(i=hW(t,mW),i)return cW(i,t,r,n)}for(a=tl(r),c=tl(t),l=lW(n),l||(n=tl(n)),u=c.length,d=SW(1,u),f=Wm(a,c);f!==-1;)p=l?tl(n(c,f,a)):fW(c,a,f,[],void 0,n),g+=QP(a,y,f)+p,y=f+u,f=f+d>a.length?-1:Wm(a,c,f+d);return y<a.length&&(g+=QP(a,y)),g}});var vW=zu;vW("String","replaceAll");function xW(e){return e.getSelectedShapeIds().map(r=>e.getShape(r)).filter(r=>!(!r||e.isShapeOfType(r,"arrow")&&r.props.start.type==="binding"||e.isShapeOfType(r,"arrow")&&r.props.end.type==="binding"))}const YT=()=>{const e=z();return K("threeStackableItems",()=>xW(e).length>2,[e])},XT=()=>{const e=z();return K("allow group",()=>{const t=e.getSelectedShapes();if(t.length<2)return!1;for(const n of t)if(e.isShapeOfType(n,"arrow")){const{start:r,end:o}=n.props;if(r.type==="binding"&&!t.some(s=>s.id===r.boundShapeId)||o.type==="binding"&&!t.some(s=>s.id===o.boundShapeId))return!1}return!0},[e])},qT=()=>{const e=z();return K("allowUngroup",()=>e.getSelectedShapeIds().some(t=>{var n;return((n=e.getShape(t))==null?void 0:n.type)==="group"}),[e])},wW=typeof window<"u"&&"navigator"in window&&!!navigator.clipboard&&!!navigator.clipboard.read;function bW(e,t){const n=z();return K("selectedShapes",()=>n.getSelectedShapes().length>=e,[n,e,t])}function wn(e,t){const n=z();return K("selectedShapes",()=>{const r=n.getSelectedShapes().filter(o=>!n.isShapeOrAncestorLocked(o)).length;return e===void 0?r:r>=e},[n])}function PW(){const e=z();return K("showAutoSizeToggle",()=>{const t=e.getSelectedShapes();return t.length===1&&e.isShapeOfType(t[0],"text")&&t[0].props.autoSize===!1},[e])}function ZT(){const e=z();return K("hasLinkShapeSelected",()=>{const t=e.getOnlySelectedShape();return!!(t&&t.type!=="embed"&&"url"in t.props&&!t.isLocked)},[e])}function CW(){const e=z();return K("onlyFlippableShape",()=>{const t=e.getOnlySelectedShape();return t&&(e.isShapeOfType(t,"group")||e.isShapeOfType(t,"arrow")||e.isShapeOfType(t,"line")||e.isShapeOfType(t,"draw"))},[e])}function QT(){const e=z();return K("useCanRedo",()=>e.getCanRedo(),[e])}function JT(){const e=z();return K("useCanUndo",()=>e.getCanUndo(),[e])}function IW({children:e}){const t=z();return K("shouldDisplayHandles",()=>{if(t.isInAny("select.idle","select.pointing_handle","select.pointing_shape"))return!0;if(t.isInAny("select.editing_shape")){const r=t.getOnlySelectedShape();return r&&t.isShapeOfType(r,"note")}return!1},[t])?h.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:e}):null}const{PI:EW}=Math,Ga=EW+1e-4;function e$(e,t={}){const{size:n=16,smoothing:r=.5}=t;if(e.length===0||n<=0)return{left:[],right:[]};const o=e[0],s=e[e.length-1],i=s.runningLength,a=Math.pow(n*r,2),c=[],l=[];let u=e[0].vector,d=e[0].point,p=d,f=d,y=p,g=!1,w;for(let S=0;S<e.length;S++){w=e[S];const{point:v,vector:b}=e[S],E=w.vector.dpr(u),C=(S<e.length-1?e[S+1]:e[S]).vector,I=S<e.length-1?C.dpr(w.vector):1,_=E<0&&!g,k=I!==null&&I<.2;if(_||k){if(I>-.62&&i-w.runningLength>w.radius){const T=u.clone().mul(w.radius);u.clone().cpr(C)<0?(f=P.Add(v,T),y=P.Sub(v,T)):(f=P.Sub(v,T),y=P.Add(v,T)),c.push(f),l.push(y)}else{const T=u.clone().mul(w.radius).per(),O=P.Sub(w.input,T);for(let N=1/13,F=0;F<1;F+=N)f=P.RotWith(O,w.input,Ga*F),c.push(f),y=P.RotWith(O,w.input,Ga+Ga*-F),l.push(y)}d=f,p=y,k&&(g=!0);continue}if(g=!1,w===o||w===s){const T=P.Per(b).mul(w.radius);c.push(P.Sub(v,T)),l.push(P.Add(v,T));continue}const $=P.Lrp(C,b,I).per().mul(w.radius);f=P.Sub(v,$),(S<=1||P.Dist2(d,f)>a)&&(c.push(f),d=f),y=P.Add(v,$),(S<=1||P.Dist2(p,y)>a)&&(l.push(y),p=y),u=b}return{left:c,right:l}}function Dx(e,t={}){const{size:n=16,start:r={},end:o={},last:s=!1}=t,{cap:i=!0}=r,{cap:a=!0}=o;if(e.length===0||n<=0)return[];const c=e[0],l=e[e.length-1],u=l.runningLength,d=r.taper===!1?0:r.taper===!0?Math.max(n,u):r.taper,p=o.taper===!1?0:o.taper===!0?Math.max(n,u):o.taper,{left:f,right:y}=e$(e,t),g=c.point,w=e.length>1?e[e.length-1].point:P.AddXY(c.point,1,1);if(e.length===1&&(!(d||p)||s)){const E=P.Add(g,P.Sub(g,w).uni().per().mul(-c.radius)),C=[];for(let I=1/13,_=I;_<=1;_+=I)C.push(P.RotWith(E,g,Ga*2*_));return C}const S=[];if(!(d||p&&e.length===1))if(i)for(let E=1/8,C=E;C<=1;C+=E){const I=P.RotWith(y[0],g,Ga*C);S.push(I)}else{const E=P.Sub(f[0],y[0]),C=P.Mul(E,.5),I=P.Mul(E,.51);S.push(P.Sub(g,C),P.Sub(g,I),P.Add(g,I),P.Add(g,C))}const v=[],b=l.vector.clone().per().neg();if(p||d&&e.length===1)v.push(w);else if(a){const E=P.Add(w,P.Mul(b,l.radius));for(let C=1/29,I=C;I<1;I+=C)v.push(P.RotWith(E,w,Ga*3*I))}else v.push(P.Add(w,P.Mul(b,l.radius)),P.Add(w,P.Mul(b,l.radius*.99)),P.Sub(w,P.Mul(b,l.radius*.99)),P.Sub(w,P.Mul(b,l.radius)));return f.concat(v,y.reverse(),S)}const _W=.025,kW=.01;function lo(e,t={}){var w;const{streamline:n=.5,size:r=16,simulatePressure:o=!1}=t;if(e.length===0)return[];const s=.15+(1-n)*.85;let i=e.map(P.From),a=0;if(!o){let S=i[0];for(;S&&!(S.z>=_W);)i.shift(),S=i[0]}if(!o){let S=i[i.length-1];for(;S&&!(S.z>=kW);)i.pop(),S=i[i.length-1]}if(i.length===0)return[{point:P.From(e[0]),input:P.From(e[0]),pressure:o?.5:.15,vector:new P(1,1),distance:0,runningLength:0,radius:1}];let c=i[1];for(;c&&!(P.Dist2(c,i[0])>(r/3)**2);)i[0].z=Math.max(i[0].z,c.z),i.splice(1,1),c=i[1];const l=i.pop();for(c=i[i.length-1];c&&!(P.Dist2(c,l)>(r/3)**2);)i.pop(),c=i[i.length-1],a++;i.push(l);const u=t.last||!t.simulatePressure||i.length>1&&P.Dist2(i[i.length-1],i[i.length-2])<r**2||a>0;if(i.length===2&&t.simulatePressure){const S=i[1];i=i.slice(0,-1);for(let v=1;v<5;v++){const b=P.Lrp(i[0],S,v/4);b.z=(i[0].z+(S.z-i[0].z))*v/4,i.push(b)}}const d=[{point:i[0],input:i[0],pressure:o?.5:i[0].z,vector:new P(1,1),distance:0,runningLength:0,radius:1}];let p=0,f=d[0],y,g;u&&n>0&&i.push(i[i.length-1].clone());for(let S=1,v=i.length;S<v;S++)y=!s||t.last&&S===v-1?i[S].clone():i[S].clone().lrp(f.point,1-s),!f.point.equals(y)&&(g=P.Dist(y,f.point),p+=g,!(S<4&&p<r)&&(f={input:i[S],point:y,pressure:o?.5:i[S].z,vector:P.Sub(f.point,y).uni(),distance:g,runningLength:p,radius:1},d.push(f)));if((w=d[1])!=null&&w.vector&&(d[0].vector=d[1].vector.clone()),p<1){const S=Math.max(.5,...d.map(v=>v.pressure));d.forEach(v=>v.pressure=S)}return d}const{min:hs}=Math,Vm=.275;function Jf(e,t){const{size:n=16,thinning:r=.5,simulatePressure:o=!0,easing:s=w=>w,start:i={},end:a={}}=t,{easing:c=nn.easeOutQuad}=i,{easing:l=nn.easeOutCubic}=a,u=e[e.length-1].runningLength;let d,p=e[0].pressure,f;if(!o&&u<n){const w=e.reduce((S,v)=>Math.max(S,v.pressure),.5);return e.forEach(S=>{S.pressure=w,S.radius=n*s(.5-r*(.5-S.pressure))}),e}else{let w;for(let S=0,v=e.length;S<v&&(f=e[S],!(f.runningLength>n*5));S++){const b=hs(1,f.distance/n);if(o){const E=hs(1,1-b);w=hs(1,p+(E-p)*(b*Vm))}else w=hs(1,p+(f.pressure-p)*.5);p=p+(w-p)*.5}for(let S=0;S<e.length;S++){if(f=e[S],r){let{pressure:v}=f;const b=hs(1,f.distance/n);if(o){const E=hs(1,1-b);v=hs(1,p+(E-p)*(b*Vm))}else v=hs(1,p+(v-p)*(b*Vm));f.radius=n*s(.5-r*(.5-v)),p=v}else f.radius=n/2;d===void 0&&(d=f.radius)}}const y=i.taper===!1?0:i.taper===!0?Math.max(n,u):i.taper,g=a.taper===!1?0:a.taper===!0?Math.max(n,u):a.taper;if(y||g)for(let w=0;w<e.length;w++){f=e[w];const{runningLength:S}=f,v=S<y?c(S/y):1,b=u-S<g?l((u-S)/g):1;f.radius=Math.max(.01,f.radius*Math.min(v,b))}return e}function TW(e,t={}){return Dx(Jf(lo(e,t),t),t)}function JP({scribble:e,zoom:t,color:n,opacity:r,className:o}){if(!e.points.length)return null;const s=TW(e.points,{size:e.size/t,start:{taper:e.taper,easing:nn.linear},last:e.state==="stopping",simulatePressure:!1,streamline:.32});let i;if(s.length<4){const a=e.size/t/2,{x:c,y:l}=e.points[e.points.length-1];i=`M ${c-a},${l} a ${a},${a} 0 1,0 ${a*2},0 a ${a},${a} 0 1,0 ${-a*2},0`}else i=J0(s);return h.jsx("svg",{className:o&&ue("tl-overlays__item",o),children:h.jsx("path",{className:"tl-scribble",d:i,fill:n??`var(--color-${e.color})`,opacity:r??e.opacity})})}const $W=({bounds:e,rotation:t})=>{const n=z();return K("should display",()=>n.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_shape","select.pointing_selection","text.resizing"),[n])?h.jsx(y2,{bounds:e,rotation:t}):null};function ns(){const e=z();return K("isReadonlyMode",()=>e.getInstanceState().isReadonly,[e])}function MW({size:e,width:t,height:n,hideAlternateHandles:r}){const o=j(e/3),s=o/2;return h.jsxs("svg",{className:"tl-overlays__item",children:[h.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
${j(0-s)},${j(e)}
|
|
${j(0-s)},${j(0-s)}
|
|
${j(e)},${j(0-s)}`,strokeWidth:o,"data-testid":"selection.crop.top_left","aria-label":"top_left handle"}),h.jsx("line",{className:ue("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(t/2-e),y1:j(0-s),x2:j(t/2+e),y2:j(0-s),strokeWidth:o,"data-testid":"selection.crop.top","aria-label":"top handle"}),h.jsx("polyline",{className:ue("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
${j(t-e)},${j(0-s)}
|
|
${j(t+s)},${j(0-s)}
|
|
${j(t+s)},${j(e)}`,strokeWidth:o,"data-testid":"selection.crop.top_right","aria-label":"top_right handle"}),h.jsx("line",{className:ue("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(t+s),y1:j(n/2-e),x2:j(t+s),y2:j(n/2+e),strokeWidth:o,"data-testid":"selection.crop.right","aria-label":"right handle"}),h.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
${j(t+s)},${j(n-e)}
|
|
${j(t+s)},${j(n+s)}
|
|
${j(t-e)},${j(n+s)}`,strokeWidth:o,"data-testid":"selection.crop.bottom_right","aria-label":"bottom_right handle"}),h.jsx("line",{className:ue("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(t/2-e),y1:j(n+s),x2:j(t/2+e),y2:j(n+s),strokeWidth:o,"data-testid":"selection.crop.bottom","aria-label":"bottom handle"}),h.jsx("polyline",{className:ue("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
${j(0+e)},${j(n+s)}
|
|
${j(0-s)},${j(n+s)}
|
|
${j(0-s)},${j(n-e)}`,strokeWidth:o,"data-testid":"selection.crop.bottom_left","aria-label":"bottom_left handle"}),h.jsx("line",{className:ue("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(0-s),y1:j(n/2-e),x2:j(0-s),y2:j(n/2+e),strokeWidth:o,"data-testid":"selection.crop.left","aria-label":"left handle"})]})}const AW=or(function({bounds:t,rotation:n}){const r=z(),o=x.useRef(null),s=ns(),i=Xr("top"),a=Xr("right"),c=Xr("bottom"),l=Xr("left"),u=Xr("top_left"),d=Xr("top_right"),p=Xr("bottom_right"),f=Xr("bottom_left"),y=!r.getIsMenuOpen()&&r.getInstanceState().cursor.type==="default",g=r.getInstanceState().isCoarsePointer,w=r.getOnlySelectedShape(),S=w&&r.isShapeOrAncestorLocked(w),v=w?r.getShapeUtil(w).expandSelectionOutlinePx(w):0;if(xc(o,t==null?void 0:t.x,t==null?void 0:t.y,1,r.getSelectionRotation(),{x:-v,y:-v}),!t)return null;t=t.clone().expandBy(v).zeroFix();const b=r.getZoomLevel(),E=r.getInstanceState().isChangingStyle,C=t.width,I=t.height,_=8/b,k=C<_*2,$=I<_*2,T=C<_*4,O=I<_*4,N=C<_*5,F=I<_*5,L=g?1.75:1,B=6/b*L,q=(T?B/2:B)*(L*.75),Q=(O?B/2:B)*(L*.75),H=(w?!r.getShapeUtil(w).hideSelectionBoundsFg(w):!0)&&!E;let U=H&&r.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.pointing_resize_handle","select.pointing_crop_handle")||H&&r.isIn("select.resizing")&&w&&r.isShapeOfType(w,"text");w&&U&&r.environment.isFirefox&&r.isShapeOfType(w,"embed")&&(U=!1);const W=r.isInAny("select.pointing_crop_handle","select.crop.idle","select.crop.pointing_crop")&&!E&&!s,Z=r.isInAny("select.idle","select.pointing_selection","select.pointing_shape","select.crop.idle")&&!E&&!s,le=!g&&!(k||$)&&(Z||W)&&(w?!r.getShapeUtil(w).hideRotateHandle(w):!0)&&!S,be=g&&(!T||!O)&&(Z||W)&&(w?!r.getShapeUtil(w).hideRotateHandle(w):!0)&&!S,Me=Z&&(w?r.getShapeUtil(w).canResize(w)&&!r.getShapeUtil(w).hideResizeHandles(w):!0)&&!W&&!S,ae=k||$,Ae=k&&$,Re=N||F,ot=Me||W,Ie=!le,ht=!Z||!be,He=!Z||!ot,ir=!Z||!ot||ae,Ln=!Z||!ot||ae,Fn=!Z||!ot||Ae&&!W;let qe=!0,Ot=!0;if(W)qe=Re,Ot=Re;else if(Me){qe=ae||Ae||g;const jc=g&&w&&w.type==="text";Ot=qe&&!jc}const wo=Math.min(24/b,I-Q*3),Ac=Z&&g&&w&&r.isShapeOfType(w,"text")&&wo*b>=4;return h.jsx("svg",{className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:h.jsxs("g",{ref:o,children:[U&&h.jsx("rect",{className:"tl-selection__fg__outline",width:j(C),height:j(I)}),h.jsx(Od,{"data-testid":"selection.rotate.top-left",cx:0,cy:0,targetSize:B,corner:"top_left_rotate",cursor:y?Bn("nwse-rotate",n):void 0,isHidden:Ie}),h.jsx(Od,{"data-testid":"selection.rotate.top-right",cx:C+B*3,cy:0,targetSize:B,corner:"top_right_rotate",cursor:y?Bn("nesw-rotate",n):void 0,isHidden:Ie}),h.jsx(Od,{"data-testid":"selection.rotate.bottom-left",cx:0,cy:I+B*3,targetSize:B,corner:"bottom_left_rotate",cursor:y?Bn("swne-rotate",n):void 0,isHidden:Ie}),h.jsx(Od,{"data-testid":"selection.rotate.bottom-right",cx:C+B*3,cy:I+B*3,targetSize:B,corner:"bottom_right_rotate",cursor:y?Bn("senw-rotate",n):void 0,isHidden:Ie}),h.jsx(OW,{"data-testid":"selection.rotate.mobile",cx:T?-B*1.5:C/2,cy:T?I/2:-B*1.5,size:_,isHidden:ht}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":qe}),"data-testid":"selection.resize.top","aria-label":"top target",pointerEvents:"all",x:0,y:j(0-(O?Q*2:Q)),width:j(C),height:j(Math.max(1,Q*2)),style:y?{cursor:Bn("ns-resize",n)}:void 0,...i}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":Ot}),"data-testid":"selection.resize.right","aria-label":"right target",pointerEvents:"all",x:j(C-(T?0:q)),y:0,height:j(I),width:j(Math.max(1,q*2)),style:y?{cursor:Bn("ew-resize",n)}:void 0,...a}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":qe}),"data-testid":"selection.resize.bottom","aria-label":"bottom target",pointerEvents:"all",x:0,y:j(I-(O?0:Q)),width:j(C),height:j(Math.max(1,Q*2)),style:y?{cursor:Bn("ns-resize",n)}:void 0,...c}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":Ot}),"data-testid":"selection.resize.left","aria-label":"left target",pointerEvents:"all",x:j(0-(T?q*2:q)),y:0,height:j(I),width:j(Math.max(1,q*2)),style:y?{cursor:Bn("ew-resize",n)}:void 0,...l}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":He}),"data-testid":"selection.target.top-left","aria-label":"top-left target",pointerEvents:"all",x:j(0-(T?q*2:q*1.5)),y:j(0-(O?Q*2:Q*1.5)),width:j(q*3),height:j(Q*3),style:y?{cursor:Bn("nwse-resize",n)}:void 0,...u}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":ir}),"data-testid":"selection.target.top-right","aria-label":"top-right target",pointerEvents:"all",x:j(C-(T?0:q*1.5)),y:j(0-(O?Q*2:Q*1.5)),width:j(q*3),height:j(Q*3),style:y?{cursor:Bn("nesw-resize",n)}:void 0,...d}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":Fn}),"data-testid":"selection.target.bottom-right","aria-label":"bottom-right target",pointerEvents:"all",x:j(C-(T?q:q*1.5)),y:j(I-(O?Q:Q*1.5)),width:j(q*3),height:j(Q*3),style:y?{cursor:Bn("nwse-resize",n)}:void 0,...p}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":Ln}),"data-testid":"selection.target.bottom-left","aria-label":"bottom-left target",pointerEvents:"all",x:j(0-(T?q*3:q*1.5)),y:j(I-(O?0:Q*1.5)),width:j(q*3),height:j(Q*3),style:y?{cursor:Bn("nesw-resize",n)}:void 0,...f}),Me&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{"data-testid":"selection.resize.top-left",className:ue("tl-corner-handle",{"tl-hidden":He}),"aria-label":"top_left handle",x:j(0-_/2),y:j(0-_/2),width:j(_),height:j(_)}),h.jsx("rect",{"data-testid":"selection.resize.top-right",className:ue("tl-corner-handle",{"tl-hidden":ir}),"aria-label":"top_right handle",x:j(C-_/2),y:j(0-_/2),width:j(_),height:j(_)}),h.jsx("rect",{"data-testid":"selection.resize.bottom-right",className:ue("tl-corner-handle",{"tl-hidden":Fn}),"aria-label":"bottom_right handle",x:j(C-_/2),y:j(I-_/2),width:j(_),height:j(_)}),h.jsx("rect",{"data-testid":"selection.resize.bottom-left",className:ue("tl-corner-handle",{"tl-hidden":Ln}),"aria-label":"bottom_left handle",x:j(0-_/2),y:j(I-_/2),width:j(_),height:j(_)})]}),Ac&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{"data-testid":"selection.text-resize.left.handle",className:"tl-text-handle","aria-label":"bottom_left handle",x:j(0-_/4),y:j(I/2-wo/2),rx:_/4,width:j(_/2),height:j(wo)}),h.jsx("rect",{"data-testid":"selection.text-resize.right.handle",className:"tl-text-handle","aria-label":"bottom_left handle",rx:_/4,x:j(C-_/4),y:j(I/2-wo/2),width:j(_/2),height:j(wo)})]}),W&&h.jsx(MW,{size:_,width:C,height:I,hideAlternateHandles:Re})]})})}),Od=function({cx:t,cy:n,targetSize:r,corner:o,cursor:s,isHidden:i,"data-testid":a}){const c=Xr(o);return h.jsx("rect",{className:ue("tl-transparent","tl-rotate-corner",{"tl-hidden":i}),"data-testid":a,"aria-label":`${o} target`,pointerEvents:"all",x:j(t-r*3),y:j(n-r*3),width:j(Math.max(1,r*3)),height:j(Math.max(1,r*3)),cursor:s,...c})},jW=Math.sqrt(Math.PI),OW=function({cx:t,cy:n,size:r,isHidden:o,"data-testid":s}){const i=Xr("mobile_rotate"),a=z(),c=K("zoom level",()=>a.getZoomLevel(),[a]),l=Math.max(14*(1/c),20/Math.max(1,c));return h.jsxs("g",{children:[h.jsx("circle",{"data-testid":s,pointerEvents:"all",className:ue("tl-transparent","tl-mobile-rotate__bg",{"tl-hidden":o}),cx:t,cy:n,r:l,...i}),h.jsx("circle",{className:ue("tl-mobile-rotate__fg",{"tl-hidden":o}),cx:t,cy:n,r:r/jW})]})},Ht={lineHeight:1.35,fontWeight:"normal",fontVariant:"normal",fontStyle:"normal",padding:"0px"},Mt={s:2,m:3.5,l:5,xl:10},ac={s:18,m:24,l:36,xl:44},Lo={s:18,m:22,l:26,xl:32},hi={s:18,m:20,l:24,xl:28},io={draw:"var(--tl-font-draw)",sans:"var(--tl-font-sans)",serif:"var(--tl-font-serif)",mono:"var(--tl-font-mono)"},DW=20,RW=4.25,Tr=16;/*!
|
|
* canvas-size
|
|
* v1.2.6
|
|
* https://github.com/jhildenbiddle/canvas-size
|
|
* (c) 2015-2023 John Hildenbiddle <http://hildenbiddle.com>
|
|
* MIT license
|
|
*/function LW(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,s,i,a=[],c=!0,l=!1;try{if(s=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(u){l=!0,o=u}finally{try{if(!c&&n.return!=null&&(i=n.return(),Object(i)!==i))return}finally{if(l)throw o}}return a}}function eC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Un(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?eC(Object(n),!0).forEach(function(r){FW(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eC(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function FW(e,t,n){return t=GW(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function NW(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function zW(e,t){if(e==null)return{};var n=NW(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function tC(e,t){return UW(e)||LW(e,t)||t$(e,t)||WW()}function Dd(e){return BW(e)||HW(e)||t$(e)||KW()}function BW(e){if(Array.isArray(e))return lv(e)}function UW(e){if(Array.isArray(e))return e}function HW(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function t$(e,t){if(e){if(typeof e=="string")return lv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return lv(e,t)}}function lv(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function KW(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function WW(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function VW(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function GW(e){var t=VW(e,"string");return typeof t=="symbol"?t:String(t)}function jl(e){var t=e.sizes.shift(),n=Math.max(Math.ceil(t[0]),1),r=Math.max(Math.ceil(t[1]),1),o=[n-1,r-1,1,1],s=Date.now(),i=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,a,c;i?(a=new OffscreenCanvas(1,1),c=new OffscreenCanvas(n,r)):(a=document.createElement("canvas"),a.width=1,a.height=1,c=document.createElement("canvas"),c.width=n,c.height=r);var l=a.getContext("2d"),u=c.getContext("2d");u&&(u.fillRect.apply(u,o),l.drawImage(c,n-1,r-1,1,1,0,0,1,1));var d=l&&l.getImageData(0,0,1,1).data[3]!==0,p=Date.now()-s;return[a,c].forEach(function(f){f.height=0,f.width=0}),i?(postMessage({width:n,height:r,benchmark:p,isTestPass:d}),!d&&e.sizes.length&&jl(e)):d?e.onSuccess(n,r,p):(e.onError(n,r,p),e.sizes.length&&jl(e)),d}var Gm={area:[16384,14188,11402,11180,10836,8192,4096,1],height:[8388607,65535,32767,16384,8192,4096,1],width:[4194303,65535,32767,16384,8192,4096,1]},YW=["onError","onSuccess"],Oa={max:null,min:1,sizes:[],step:1024,usePromise:!1,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},nl={};function Ym(e){var t=e.width===e.height,n=e.height===1,r=e.width===1,o=[];if(!e.width||!e.height)e.sizes.forEach(function(u){var d=t||n?u:1,p=t||r?u:1;o.push([d,p])});else for(var s=e.min||Oa.min,i=e.step||Oa.step,a=Math.max(e.width,e.height);a>=s;){var c=t||n?a:1,l=t||r?a:1;o.push([c,l]),a-=i}return o}function Rd(e){var t=window&&"HTMLCanvasElement"in window,n=window&&"OffscreenCanvas"in window,r=Date.now(),o=e.onError,s=e.onSuccess,i=zW(e,YW),a=null;if(!t)return!1;if(e.useWorker&&n){var c=`
|
|
var canvasTest = `.concat(jl.toString(),`;
|
|
onmessage = function(e) {
|
|
canvasTest(e.data);
|
|
};
|
|
`),l=new Blob([c],{type:"application/javascript"}),u=URL.createObjectURL(l);a=new Worker(u),URL.revokeObjectURL(u),a.onmessage=function(d){var p=d.data,f=p.width,y=p.height,g=p.benchmark,w=p.isTestPass;w?(nl[r].onSuccess(f,y,g),delete nl[r]):nl[r].onError(f,y,g)}}if(e.usePromise)return new Promise(function(d,p){var f=Un(Un({},e),{},{onError:function(S,v,b){var E;if(e.sizes.length===0)E=!0;else{var C=e.sizes.slice(-1),I=tC(C,1),_=tC(I[0],2),k=_[0],$=_[1];E=S===k&&v===$}o(S,v,b),E&&p({width:S,height:v,benchmark:b})},onSuccess:function(S,v,b){s(S,v,b),d({width:S,height:v,benchmark:b})}});if(a){var y=f.onError,g=f.onSuccess;nl[r]={onError:y,onSuccess:g},a.postMessage(i)}else jl(f)});if(a)nl[r]={onError:o,onSuccess:s},a.postMessage(i);else return jl(e)}var Xm={maxArea:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Ym({width:t.max,height:t.max,min:t.min,step:t.step,sizes:Dd(Gm.area)}),r=Un(Un(Un({},Oa),t),{},{sizes:n});return Rd(r)},maxHeight:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Ym({width:1,height:t.max,min:t.min,step:t.step,sizes:Dd(Gm.height)}),r=Un(Un(Un({},Oa),t),{},{sizes:n});return Rd(r)},maxWidth:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Ym({width:t.max,height:1,min:t.min,step:t.step,sizes:Dd(Gm.width)}),r=Un(Un(Un({},Oa),t),{},{sizes:n});return Rd(r)},test:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Un(Un({},Oa),t);return n.sizes=Dd(n.sizes),n.width&&n.height&&(n.sizes=[[n.width,n.height]]),Rd(n)}};let qm=null;function XW(){return qm||(qm=qW()),qm}async function qW(){const e=await Xm.maxWidth({usePromise:!0}),t=await Xm.maxHeight({usePromise:!0}),n=await Xm.maxArea({usePromise:!0});return{maxWidth:e.width,maxHeight:t.height,maxArea:n.width*n.height}}const nC=8192,ZW=4096*4096;async function n$(e,t){if(e<=nC&&t<=nC&&e*t<=ZW)return[e,t];const{maxWidth:n,maxHeight:r,maxArea:o}=await XW(),s=e/t;if(e>n&&(e=n,t=e/s),t>r&&(t=r,e=t*s),e*t>o){const i=Math.sqrt(o/(e*t));e*=i,t*=i}return[e,t]}/*!
|
|
* MIT License
|
|
* Modified code originally from <https://github.com/qzb/is-animated>
|
|
* Copyright (c) 2016 Józef Sokołowski <j.k.sokolowski@gmail.com>
|
|
*/function rC(e,t){let n=0;for(;e[t+n];)n+=e[t+n]+1;return n+1}function QW(e){return new TextDecoder("ascii").decode(e.slice(0,3))==="GIF"}function JW(e){const t=new Uint8Array(e);let n,r,o=0,s=0;if(!QW(e))return!1;for(n=t[10]&128,r=t[10]&7,o+=6,o+=7,o+=n?3*Math.pow(2,r+1):0;s<2&&o<t.length;)switch(t[o]){case 44:s+=1,n=t[o+9]&128,r=t[o+9]&7,o+=10,o+=n?3*Math.pow(2,r+1):0,o+=rC(t,o+1)+1;break;case 33:o+=2,o+=rC(t,o);break;case 59:o=t.length;break;default:o=t.length;break}return s>1}function eV(e,t){const n=e.w/t.w,r=e.h/t.h;return n<=1&&r<=1?e:n>r?{w:e.w/n,h:e.h/n}:{w:e.w/r,h:e.h/r}}async function tV(e,t,n,r={}){const o=await jo.usingObjectURL(e,jo.loadImage),{type:s=e.type,quality:i=.92}=r,[a,c]=await n$(Math.min(t*2,o.naturalWidth),Math.min(n*2,o.naturalHeight)),l=document.createElement("canvas");l.width=a,l.height=c;const u=yi(l.getContext("2d",{willReadFrequently:!0}),"Could not get canvas context");return u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(o,0,0,a,c),new Promise((d,p)=>{l.toBlob(f=>{f?d(f):p(new Error("Could not resize image"))},s,i)})}async function nV(e){return JW(await e.arrayBuffer())}function rV(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function oV(e){const t=new URL(e).host.replace("www.","");for(const n of Tu)if(r$(n.hostnames,t)){const r=n.fromEmbedUrl(e);if(r)return{definition:n,url:r,embedUrl:e}}}const sV=e=>e.split("*").map(t=>rV(t)).join(".+"),r$=(e,t)=>!!e.find(n=>{const r=new RegExp(sV(n));return t.match(r)});function iV(e){const t=new URL(e).host.replace("www.","");for(const n of Tu)if(r$(n.hostnames,t)){const r=n.toEmbedUrl(e);if(r)return{definition:n,embedUrl:r,url:e}}}function o$(e){return iV(e)??oV(e)}function Cs(e){try{return o$(e)}catch(t){console.error(t)}}/*!
|
|
* MIT License
|
|
* Adapted (mostly copied) the work of https://github.com/fregante/text-field-edit
|
|
* Copyright (c) Federico Brigante <opensource@bfred.it> (bfred.it)
|
|
*/const Da=" ",ln=class ln{static insertTextFirefox(t,n){t.setRangeText(n,t.selectionStart||0,t.selectionEnd||0,"end"),t.dispatchEvent(new InputEvent("input",{data:n,inputType:"insertText",isComposing:!1}))}static insert(t,n){const r=t.ownerDocument,o=r.activeElement;o!==t&&t.focus(),r.execCommand("insertText",!1,n)||ln.insertTextFirefox(t,n),o===r.body?t.blur():o instanceof HTMLElement&&o!==t&&o.focus()}static set(t,n){t.select(),ln.insert(t,n)}static getSelection(t){const{selectionStart:n,selectionEnd:r}=t;return t.value.slice(n||void 0,r||void 0)}static wrapSelection(t,n,r){const{selectionStart:o,selectionEnd:s}=t,i=ln.getSelection(t);ln.insert(t,n+i+(r??n)),t.selectionStart=(o||0)+n.length,t.selectionEnd=(s||0)+n.length}static replace(t,n,r){let o=0;t.value.replace(n,(...s)=>{const i=o+s[s.length-2],a=s[0].length;t.selectionStart=i,t.selectionEnd=i+a;const c=typeof r=="string"?r:r(...s);return ln.insert(t,c),t.selectionStart=i,o+=c.length-a,c})}static findLineEnd(t,n){const r=t.lastIndexOf(`
|
|
`,n-1)+1;return t.charAt(r)!==" "?n:r+1}static indent(t){var a;const{selectionStart:n,selectionEnd:r,value:o}=t,s=o.slice(n,r),i=(a=/\n/g.exec(s))==null?void 0:a.length;if(i&&i>0){const c=o.lastIndexOf(`
|
|
`,n-1)+1,l=t.value.slice(c,r-1),u=l.replace(/^|\n/g,`$&${Da}`),d=u.length-l.length;t.setSelectionRange(c,r-1),ln.insert(t,u),t.setSelectionRange(n+1,r+d)}else ln.insert(t,Da)}static unindent(t){const{selectionStart:n,selectionEnd:r,value:o}=t,s=o.lastIndexOf(`
|
|
`,n-1)+1,i=ln.findLineEnd(o,r),a=t.value.slice(s,i),c=a.replace(/(^|\n)(\t| {1,2})/g,"$1"),l=a.length-c.length;t.setSelectionRange(s,i),ln.insert(t,c);const u=/\t| {1,2}/.exec(o.slice(s,n)),d=u?u[0].length:0,p=n-d;t.setSelectionRange(n-d,Math.max(p,r-l))}static indentCE(t){var c;const n=window.getSelection(),r=t.innerText,o=Ld(t)??0,s=Ld(t)??0,i=r.slice(o,s),a=(c=/\n/g.exec(i))==null?void 0:c.length;if(a&&a>0){const l=r.lastIndexOf(`
|
|
`,o-1)+1,u=r.slice(l,s-1),p=u.replace(/^|\n/g,`$&${Da}`).length-u.length;n&&n.setBaseAndExtent(t,o+1,t,s+p)}else{const l=window.getSelection();t.innerText=r.slice(0,o)+Da+r.slice(o),l==null||l.setBaseAndExtent(t,o+1,t,o+2)}}static unindentCE(t){const n=window.getSelection(),r=t.innerText,o=Ld(t)??0,s=Ld(t)??0,i=r.lastIndexOf(`
|
|
`,o-1)+1,a=ln.findLineEnd(r,s),c=r.slice(i,a),l=c.replace(/(^|\n)(\t| {1,2})/g,"$1"),u=c.length-l.length;if(n){n.setBaseAndExtent(t,i,t,a);const d=/\t| {1,2}/.exec(r.slice(i,o)),p=d?d[0].length:0,f=o-p;n.setBaseAndExtent(t,o-p,t,Math.max(f,s-u))}}static normalizeText(t){return t.replace(ln.fixNewLines,`
|
|
`)}static normalizeTextForDom(t){return t.replace(ln.fixNewLines,`
|
|
`).split(`
|
|
`).map(n=>n||" ").join(`
|
|
`)}};m(ln,"fixNewLines",/\r?\n|\r/g);let cc=ln;function Ld(e){if(typeof window.getSelection>"u")return;const t=window.getSelection();if(!t)return;let n=0;if(t.rangeCount!==0){const r=t.getRangeAt(0),o=r.cloneRange();o.selectNodeContents(e),o.setEnd(r.endContainer,r.endOffset),n=o.toString().length}return n}const aV=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;function s$(e){return aV.test(e)}function cV(e){return e.replace(/\t/g,Da)}function lV(e){const t=e.split(`
|
|
`);for(;t[0]&&t[0].trim().length===0;)t.shift();let n=1/0;for(const r of t)if(r.trim().length>0){const o=r.length-r.trimStart().length;n=Math.min(n,o)}return t.map(r=>r.slice(n)).join(`
|
|
`)}function uV(e){return e.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function dV(e){return uV(lV(cV(e)))}const Ol=(e,t)=>e.length<=t?e:e.substring(0,t-3)+"...";function hV(e,{maxImageDimension:t,maxAssetSize:n,acceptedImageMimeTypes:r,acceptedVideoMimeTypes:o},{toasts:s,msg:i}){e.registerExternalAssetHandler("file",async({file:a})=>{const c=a.name;let l=a;const u=r.includes(l.type),d=o.includes(l.type);_t(u||d,`File type not allowed: ${l.type}`),_t(l.size<=n,`File size too big: ${(l.size/1024).toFixed()}kb > ${(n/1024).toFixed()}kb`),l.type==="video/quicktime"&&(l=new Blob([l],{type:"video/mp4"}));let p=u?await jo.getImageSize(l):await jo.getVideoSize(l);const f=l.type==="image/gif"?await nV(l):d,y=await D3(await l.arrayBuffer());if(isFinite(t)){const S=eV(p,{w:t,h:t});p!==S&&(l.type==="image/jpeg"||l.type==="image/png")&&(p=S)}(l.type==="image/jpeg"||l.type==="image/png")&&(l=await tV(l,p.w,p.h,{type:l.type,quality:.92}));const g=Si.createId(y);return Si.create({id:g,type:u?"image":"video",typeName:"asset",props:{name:c,src:await Ka.blobToDataUrl(l),w:p.w,h:p.h,mimeType:l.type,isAnimated:f}})}),e.registerExternalAssetHandler("url",async({url:a})=>{var l,u,d;let c;try{const f=await(await fetch(a,{method:"GET",mode:"no-cors"})).text(),y=new DOMParser().parseFromString(f,"text/html");c={image:((l=y.head.querySelector('meta[property="og:image"]'))==null?void 0:l.getAttribute("content"))??"",title:((u=y.head.querySelector('meta[property="og:title"]'))==null?void 0:u.getAttribute("content"))??Ol(a,32),description:((d=y.head.querySelector('meta[property="og:description"]'))==null?void 0:d.getAttribute("content"))??""}}catch(p){console.error(p),s.addToast({title:i("assets.url.failed"),severity:"error"}),c={image:"",title:Ol(a,32),description:""}}return{id:Si.createId(AS(a)),typeName:"asset",type:"bookmark",props:{src:a,description:c.description,image:c.image,title:c.title},meta:{}}}),e.registerExternalContentHandler("svg-text",async({point:a,text:c})=>{const l=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageCenter()),u=new DOMParser().parseFromString(c,"image/svg+xml").querySelector("svg");if(!u)throw new Error("No <svg/> element present");let d=parseFloat(u.getAttribute("width")||"0"),p=parseFloat(u.getAttribute("height")||"0");if(!(d&&p)){document.body.appendChild(u);const y=u.getBoundingClientRect();document.body.removeChild(u),d=y.width,p=y.height}const f=await e.getAssetForExternalContent({type:"file",file:new File([c],"asset.svg",{type:"image/svg+xml"})});if(!f)throw Error("Could not create an asset");oC(e,[f],l)}),e.registerExternalContentHandler("embed",({point:a,url:c,embed:l})=>{const u=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageCenter()),{width:d,height:p}=l,f=Be(),y={id:f,type:"embed",x:u.x-(d||450)/2,y:u.y-(p||450)/2,props:{w:d,h:p,url:c}};e.createShapes([y]).select(f)}),e.registerExternalContentHandler("files",async({point:a,files:c})=>{const l=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageCenter()),u=new P(l.x,l.y),d=[];await Promise.all(c.map(async(p,f)=>{if(p.size>n)return console.warn(`File size too big: ${(p.size/1024).toFixed()}kb > ${(n/1024).toFixed()}kb`),null;if(!p.type)throw new Error("No mime type");if(!r.concat(o).includes(p.type))return console.warn(`${p.name} not loaded - Extension not allowed.`),null;try{const y=await e.getAssetForExternalContent({type:"file",file:p});if(!y)throw Error("Could not create an asset");d[f]=y}catch(y){return s.addToast({title:i("assets.files.upload-failed"),severity:"error"}),console.error(y),null}})),oC(e,fe(d),u)}),e.registerExternalContentHandler("text",async({point:a,text:c})=>{const l=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageCenter()),u=e.getShapeUtil("text").getDefaultProps(),d=dV(c),p=e.getOnlySelectedShape();if(p&&"text"in p.props){e.updateShapes([{id:p.id,type:p.type,props:{text:d}}]);return}let f,y,g,w="middle";const S=d.split(`
|
|
`).length>1,v=s$(d);S&&(w=S?v?"end":"start":"middle");const b=e.textMeasure.measureText(d,{...Ht,fontFamily:io[u.font],fontSize:ac[u.size],maxWidth:null}),E=Math.min(S?e.getViewportPageBounds().width*.9:920,Math.max(200,e.getViewportPageBounds().width*.9));if(b.w>E){const C=e.textMeasure.measureText(d,{...Ht,fontFamily:io[u.font],fontSize:ac[u.size],maxWidth:E});f=C.w,y=C.h,g=!1,w=v?"end":"start"}else f=b.w,y=b.h,g=!0;l.y-y/2<e.getViewportPageBounds().minY+40&&(l.y=e.getViewportPageBounds().minY+40+y/2),e.createShapes([{id:Be(),type:"text",x:l.x-f/2,y:l.y-y/2,props:{text:d,align:w,autoSize:g,w:f}}])}),e.registerExternalContentHandler("url",async({point:a,url:c})=>{const l=Cs(c);if(l)return e.putExternalContent({type:"embed",url:l.url,point:a,embed:l.definition});const u=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageCenter()),d=Si.createId(AS(c)),p=pV(e,c,u);let f=e.getAsset(d),y=!1;if(!f){y=!0;try{const g=await e.getAssetForExternalContent({type:"url",url:c});if(!g)throw Error("Could not create an asset");f=g}catch{s.addToast({title:i("assets.url.failed"),severity:"error"});return}}e.batch(()=>{y&&e.createAssets([f]),e.updateShapes([{id:p.id,type:p.type,props:{assetId:f.id}}])})})}async function oC(e,t,n){if(!t.length)return[];const r=P.From(n),o=[];for(const s of t)switch(s.type){case"bookmark":{o.push({id:Be(),type:"bookmark",x:r.x-150,y:r.y-160,opacity:1,props:{assetId:s.id,url:s.props.src}}),r.x+=300;break}case"image":{o.push({id:Be(),type:"image",x:r.x-s.props.w/2,y:r.y-s.props.h/2,opacity:1,props:{assetId:s.id,w:s.props.w,h:s.props.h}}),r.x+=s.props.w;break}case"video":o.push({id:Be(),type:"video",x:r.x-s.props.w/2,y:r.y-s.props.h/2,opacity:1,props:{assetId:s.id,w:s.props.w,h:s.props.h}}),r.x+=s.props.w}return e.batch(()=>{const s=t.filter(i=>!e.getAsset(i.id));s.length&&e.createAssets(s),e.createShapes(o).select(...o.map(i=>i.id)),i$(e,n)}),o.map(s=>s.id)}function i$(e,t){const n=e.getViewportPageBounds();let r=e.getSelectionPageBounds();if(r){const o=r.center.sub(t);e.updateShapes(e.getSelectedShapes().map(s=>{const i=e.getShapeParentTransform(s).decompose().rotation,a=P.Rot(o,-i);return{id:s.id,type:s.type,x:s.x-a.x,y:s.y-a.y}}))}r=e.getSelectionPageBounds(),r&&!n.contains(r)&&e.zoomToSelection()}function pV(e,t,n){const r={id:Be(),type:"bookmark",x:n.x-150,y:n.y-160,opacity:1,props:{assetId:null,url:t}};return e.batch(()=>{e.createShapes([r]).select(r.id),i$(e,n)}),e.getShape(r.id)}var xy;let fV=(xy=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")});m(this,"onKeyUp",n=>{var r;if(n.key==="Enter"){if(this.editor.getInstanceState().isReadonly)return null;const o=this.editor.getOnlySelectedShape();o&&this.editor.getShapeUtil(o).canEdit(o)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(o.id),(r=this.editor.root.getCurrent())==null||r.transition("editing_shape",{...n,target:"shape",shape:o}))}})}},m(xy,"id","idle"),xy);var wy;let gV=(wy=class extends se{constructor(){super(...arguments);m(this,"shape");m(this,"markId","");m(this,"onEnter",()=>{this.didTimeout=!1;const n=this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{filter:r=>!r.isLocked&&this.editor.getShapeUtil(r).canBind(r),margin:0,hitInside:!0,renderingOnly:!0});n?this.editor.setHintingShapes([n.id]):this.createArrowShape(),this.startPreciseTimeout()});m(this,"onExit",()=>{this.shape=void 0,this.editor.setHintingShapes([]),this.clearPreciseTimeout()});m(this,"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:this.editor.getShapeHandles(this.shape).find(n=>n.id==="end"),isCreating:!0,onInteractionEnd:"arrow"})}});m(this,"onPointerUp",()=>{this.cancel()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()});m(this,"preciseTimeout",-1);m(this,"didTimeout",!1)}cancel(){this.shape&&this.editor.bailToMark(this.markId),this.editor.setHintingShapes([]),this.parent.transition("idle")}createArrowShape(){var u,d;const{originPagePoint:n}=this.editor.inputs,r=Be();this.markId=`creating:${r}`,this.editor.mark(this.markId),this.editor.createShapes([{id:r,type:"arrow",x:n.x,y:n.y}]);const o=this.editor.getShape(r);if(!o)throw Error("expected shape");const s=this.editor.getShapeHandles(o);if(!s)throw Error("expected handles for arrow");const i=this.editor.getShapeUtil("arrow"),a=this.shape,c=s.find(p=>p.id==="start"),l=(u=i.onHandleDrag)==null?void 0:u.call(i,o,{handle:{...c,x:0,y:0},isPrecise:!0,initial:a});if(l){const p=(d=l.props)==null?void 0:d.start;(p==null?void 0:p.type)==="binding"&&this.editor.setHintingShapes([p.boundShapeId]),this.editor.updateShapes([l],{squashing:!0})}this.shape=this.editor.getShape(r),this.editor.select(r)}updateArrowShapeEndHandle(){var s,i,a;const n=this.shape;if(!n)throw Error("expected shape");const r=this.editor.getShapeHandles(n);if(!r)throw Error("expected handles for arrow");const o={...n,props:{...n.props,end:{...n.props.end,x:0,y:0}}};{const c=this.editor.getShapeUtil("arrow"),l=this.shape,u=this.editor.getPointInShapeSpace(n,this.editor.inputs.currentPagePoint),d=r.find(f=>f.id==="end"),p=(s=c.onHandleDrag)==null?void 0:s.call(c,o,{handle:{...d,x:u.x,y:u.y},isPrecise:!1,initial:l});if(p){const f=(i=p.props)==null?void 0:i.end;(f==null?void 0:f.type)==="binding"&&this.editor.setHintingShapes([f.boundShapeId]),this.editor.updateShapes([p],{squashing:!0})}}{const c=this.editor.getShapeUtil("arrow"),l=this.shape,u=r.find(p=>p.id==="start"),d=(a=c.onHandleDrag)==null?void 0:a.call(c,o,{handle:{...u,x:0,y:0},isPrecise:this.didTimeout,initial:l});d&&this.editor.updateShapes([d],{squashing:!0})}this.shape=this.editor.getShape(n.id)}startPreciseTimeout(){this.preciseTimeout=window.setTimeout(()=>{this.getIsActive()&&(this.didTimeout=!0)},320)}clearPreciseTimeout(){clearTimeout(this.preciseTimeout)}},m(wy,"id","pointing"),wy);class _h extends se{constructor(){super(...arguments);m(this,"shapeType","arrow")}}m(_h,"id","arrow"),m(_h,"initial","idle"),m(_h,"children",()=>[fV,gV]);class Rx extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"initialShape");m(this,"shapeType",this.parent.id==="highlight"?"highlight":"draw");m(this,"util",this.editor.getShapeUtil(this.shapeType));m(this,"isPen",!1);m(this,"segmentMode","free");m(this,"didJustShiftClickToExtendPreviousShapeLine",!1);m(this,"pagePointWhereCurrentSegmentChanged",{});m(this,"pagePointWhereNextSegmentChanged",null);m(this,"lastRecordedPoint",{});m(this,"mergeNextPoint",!1);m(this,"currentLineLength",0);m(this,"canDraw",!1);m(this,"markId",null);m(this,"onEnter",n=>{this.markId=null,this.info=n,this.canDraw=!this.editor.getIsMenuOpen(),this.lastRecordedPoint=this.editor.inputs.currentPagePoint.clone(),this.canDraw&&this.startShape()});m(this,"onPointerMove",()=>{const{inputs:n}=this.editor;if(this.isPen!==n.isPen){if(this.markId){this.editor.bailToMark(this.markId),this.startShape();return}}else!this.canDraw&&n.isDragging&&(this.startShape(),this.canDraw=!0);this.canDraw&&(n.isPen?P.Dist(n.currentPagePoint,this.lastRecordedPoint)>=1/this.editor.getZoomLevel()?(this.lastRecordedPoint=n.currentPagePoint.clone(),this.mergeNextPoint=!1):this.mergeNextPoint=!0:this.mergeNextPoint=!1,this.updateDrawingShape())});m(this,"onKeyDown",n=>{if(n.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()});m(this,"onKeyUp",n=>{if(n.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()});m(this,"onExit",()=>{this.editor.snaps.clearIndicators(),this.pagePointWhereCurrentSegmentChanged=this.editor.inputs.currentPagePoint.clone()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.editor.inputs.isDragging||(this.markId&&this.editor.bailToMark(this.markId),this.cancel())})}canClose(){return this.shapeType!=="highlight"}getIsClosed(n,r){if(!this.canClose())return!1;const o=Mt[r],s=n[0].points[0],i=n[n.length-1],a=i.points[i.points.length-1];return s!==a&&this.currentLineLength>o*4&&P.DistMin(s,a,o*2)}startShape(){const{inputs:{originPagePoint:n,isPen:r}}=this.editor;this.markId="draw start "+et(),this.editor.mark(this.markId),this.isPen=r;const o=this.isPen?this.info.point.z*1.25:.5;if(this.segmentMode=this.editor.inputs.shiftKey?"straight":"free",this.didJustShiftClickToExtendPreviousShapeLine=!1,this.lastRecordedPoint=n.clone(),this.initialShape){const i=this.editor.getShape(this.initialShape.id);if(i&&this.segmentMode==="straight"){this.didJustShiftClickToExtendPreviousShapeLine=!0;const a=Wn(i.props.segments);if(!a)throw Error("Expected a previous segment!");const c=Wn(a.points);if(!c)throw Error("Expected a previous point!");const{x:l,y:u}=this.editor.getPointInShapeSpace(i,n).toFixed(),d=this.isPen?this.info.point.z*1.25:.5,p={type:this.segmentMode,points:[{x:c.x,y:c.y,z:+d.toFixed(2)},{x:l,y:u,z:+d.toFixed(2)}]},f=oe.applyToPoint(this.editor.getShapePageTransform(i.id),c);this.pagePointWhereCurrentSegmentChanged=f,this.pagePointWhereNextSegmentChanged=null;const y=[...i.props.segments,p];this.currentLineLength<Mt[i.props.size]*4&&(this.currentLineLength=this.getLineLength(y));const g={id:i.id,type:this.shapeType,props:{segments:y}};this.canClose()&&(g.props.isClosed=this.getIsClosed(y,i.props.size)),this.editor.updateShapes([g]);return}}this.pagePointWhereCurrentSegmentChanged=n.clone();const s=Be();this.editor.createShapes([{id:s,type:this.shapeType,x:n.x,y:n.y,props:{isPen:this.isPen,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:n}=this,{inputs:r}=this.editor;if(!n)return;const{id:o,props:{size:s}}=n,i=this.editor.getShape(o);if(!i)return;const{segments:a}=i.props,{x:c,y:l,z:u}=this.editor.getPointInShapeSpace(i,r.currentPagePoint).toFixed(),d={x:c,y:l,z:this.isPen?+(u*1.25).toFixed(2):.5};switch(this.segmentMode){case"starting_straight":{const{pagePointWhereNextSegmentChanged:p}=this;if(p===null)throw Error("We should have a point where the segment changed");if(P.Dist2(p,r.currentPagePoint)>iu){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="straight";const y=Wn(a);if(!y)throw Error("Expected a previous segment!");const g=Wn(y.points);if(!g)throw Error("Expected a previous last point!");let w;const S=this.editor.getPointInShapeSpace(i,this.pagePointWhereCurrentSegmentChanged).toFixed().toJson();if(y.type==="straight"){this.currentLineLength+=P.Dist(g,S),w={type:"straight",points:[{...g},S]};const b=this.editor.getShapePageTransform(i);this.pagePointWhereCurrentSegmentChanged=oe.applyToPoint(b,g)}else w={type:"straight",points:[S,d]};const v={id:o,type:this.shapeType,props:{segments:[...a,w]}};this.canClose()&&(v.props.isClosed=this.getIsClosed(a,s)),this.editor.updateShapes([v],{squashing:!0})}break}case"starting_free":{const{pagePointWhereNextSegmentChanged:p}=this;if(p===null)throw Error("We should have a point where the segment changed");if(P.Dist2(p,r.currentPagePoint)>iu){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";const y=a.slice(),g=y[y.length-1],w=Wn(g.points);if(!w)throw Error("No previous point!");const S={type:"free",points:[...P.PointsBetween(w,d,6).map(E=>E.toFixed().toJson())]},v=[...y,S];this.currentLineLength<Mt[i.props.size]*4&&(this.currentLineLength=this.getLineLength(v));const b={id:o,type:this.shapeType,props:{segments:v}};this.canClose()&&(b.props.isClosed=this.getIsClosed(v,s)),this.editor.updateShapes([b],{squashing:!0})}break}case"straight":{const p=a.slice(),f=p[p.length-1],{pagePointWhereCurrentSegmentChanged:y}=this,{ctrlKey:g,currentPagePoint:w}=this.editor.inputs;if(!y)throw Error("We should have a point where the segment changed");let S,v=!1;this.didJustShiftClickToExtendPreviousShapeLine?this.editor.inputs.isDragging&&(v=!g,this.didJustShiftClickToExtendPreviousShapeLine=!1):v=!g;let b=this.editor.getPointInShapeSpace(i,w).toFixed().toJson(),E=!1,C;if((this.editor.user.getIsSnapMode()?!g:g)&&p.length>2){let k,$=8/this.editor.getZoomLevel();for(let T=0,O=a.length-2;T<O;T++){const N=a[T];if(!N)break;if(N.type==="free")continue;const F=N.points[0],L=Wn(N.points);if(!(F&&L))continue;const B=P.NearestPointOnLineSegment(F,L,b);if(P.DistMin(B,b,$)){k=B.toFixed().toJson(),$=P.Dist(B,b),C=N;break}}k&&(E=!0,b=k)}if(E&&C){const k=this.editor.getShapePageTransform(i),$=C.points[0],T=Wn(C.points);if(!T)throw Error("Expected a last point!");const O=oe.applyToPoint(k,$),N=oe.applyToPoint(k,T),F=oe.applyToPoint(k,b);this.editor.snaps.setIndicators([{id:et(),type:"points",points:[O,F,N]}])}else{if(this.editor.snaps.clearIndicators(),v){const k=P.Angle(y,w),T=Wp(k,24)-k;S=P.RotWith(w,y,T)}else S=w;b=this.editor.getPointInShapeSpace(i,S).toFixed().toJson()}this.currentLineLength+=P.Dist(f.points[0],b),p[p.length-1]={...f,type:"straight",points:[f.points[0],b]};const _={id:o,type:this.shapeType,props:{segments:p}};this.canClose()&&(_.props.isClosed=this.getIsClosed(a,s)),this.editor.updateShapes([_],{squashing:!0});break}case"free":{const p=a.slice(),f=p[p.length-1],y=[...f.points];if(y.length&&this.mergeNextPoint){const{z:w}=y[y.length-1];y[y.length-1]={x:d.x,y:d.y,z:w?Math.max(w,d.z):d.z}}else this.currentLineLength+=P.Dist(y[y.length-1],d),y.push(d);p[p.length-1]={...f,points:y},this.currentLineLength<Mt[i.props.size]*4&&(this.currentLineLength=this.getLineLength(p));const g={id:o,type:this.shapeType,props:{segments:p}};if(this.canClose()&&(g.props.isClosed=this.getIsClosed(p,s)),this.editor.updateShapes([g],{squashing:!0}),y.length>500){this.editor.updateShapes([{id:o,type:this.shapeType,props:{isComplete:!0}}]);const w=Be();this.editor.createShapes([{id:w,type:this.shapeType,x:Vp(r.currentPagePoint.x),y:Vp(r.currentPagePoint.y),props:{isPen:this.isPen,segments:[{type:"free",points:[{x:0,y:0,z:this.isPen?+(u*1.25).toFixed():.5}]}]}}]),this.initialShape=Ye(this.editor.getShape(w)),this.mergeNextPoint=!1,this.lastRecordedPoint=r.currentPagePoint.clone(),this.currentLineLength=0}break}}}getLineLength(n){let r=0;for(const o of n)for(let s=0;s<o.points.length-1;s++){const i=o.points[s],a=o.points[s+1];r+=P.Dist2(a,i)}return Math.sqrt(r)}complete(){if(!this.canDraw){this.cancel();return}const{initialShape:n}=this;n&&(this.editor.updateShapes([{id:n.id,type:n.type,props:{isComplete:!0}}]),this.parent.transition("idle"))}cancel(){this.parent.transition("idle",this.info)}}m(Rx,"id","drawing");var by;let a$=(by=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("drawing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(by,"id","idle"),by);class kh extends se{constructor(){super(...arguments);m(this,"shapeType","draw");m(this,"onExit",()=>{const n=this.children.drawing;n.initialShape=void 0})}}m(kh,"id","draw"),m(kh,"initial","idle"),m(kh,"children",()=>[a$,Rx]);class uv extends Ph{constructor(){super(...arguments);m(this,"shapeType","frame");m(this,"onCreate",n=>{if(!n)return;const r=this.editor.getShapePageBounds(n),o=[],s=this.editor.getShapeAncestors(n).map(i=>i.id);this.editor.getSortedChildIdsForParent(n.parentId).map(i=>{const a=this.editor.getShape(i);if(!a||a.id===n.id||a.isLocked)return;const c=this.editor.getShapePageBounds(a);c&&r.contains(c)&&mV(a,s,n)&&o.push(a.id)}),this.editor.reparentShapes(o,n.id),this.editor.getInstanceState().isToolLocked?this.editor.setCurrentTool("frame"):this.editor.setCurrentTool("select.idle")})}}m(uv,"id","frame"),m(uv,"initial","idle");function mV(e,t,n){return t.includes(e.id)?!1:e.parentId===n.parentId}var Py;let yV=(Py=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onKeyUp",n=>{var r;if(n.key==="Enter"){if(this.editor.getInstanceState().isReadonly)return null;const o=this.editor.getOnlySelectedShape();o&&this.editor.getShapeUtil(o).canEdit(o)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(o.id),(r=this.editor.root.getCurrent())==null||r.transition("editing_shape",{...n,target:"shape",shape:o}))}});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(Py,"id","idle"),Py);var Cy;let SV=(Cy=class extends se{constructor(){super(...arguments);m(this,"markId","");m(this,"onPointerUp",()=>{this.complete()});m(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){const{originPagePoint:r}=this.editor.inputs,o=Be();this.markId=`creating:${o}`,this.editor.mark(this.markId),this.editor.createShapes([{id:o,type:"geo",x:r.x,y:r.y,props:{w:1,h:1,geo:this.editor.getStyleForNextShape(oo)}}]).select(o).setCurrentTool("select.resizing",{...n,target:"selection",handle:"bottom_right",isCreating:!0,creationCursorOffset:{x:1,y:1},onInteractionEnd:"geo"})}});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()})}complete(){const{originPagePoint:n}=this.editor.inputs,r=Be();this.markId=`creating:${r}`,this.editor.mark(this.markId),this.editor.createShapes([{id:r,type:"geo",x:n.x,y:n.y,props:{geo:this.editor.getStyleForNextShape(oo),w:1,h:1}}]);const o=this.editor.getShape(r);if(!o)return;const s=o.props.geo==="star"?new ne(0,0,200,190):o.props.geo==="cloud"?new ne(0,0,300,180):new ne(0,0,200,200),i=s.center,a=this.editor.getShapeParentTransform(o);a&&i.rot(-a.rotation()),this.editor.select(r),this.editor.updateShapes([{id:o.id,type:"geo",x:o.x-i.x,y:o.y-i.y,props:{geo:this.editor.getStyleForNextShape(oo),w:s.width,h:s.height}}]),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select",{})}cancel(){this.parent.transition("idle")}},m(Cy,"id","pointing"),Cy);class Th extends se{constructor(){super(...arguments);m(this,"shapeType","geo")}}m(Th,"id","geo"),m(Th,"initial","idle"),m(Th,"children",()=>[yV,SV]);class $h extends se{constructor(){super(...arguments);m(this,"shapeType","highlight");m(this,"onExit",()=>{const n=this.children.drawing;n.initialShape=void 0})}}m($h,"id","highlight"),m($h,"initial","idle"),m($h,"children",()=>[a$,Rx]);var Iy;let vV=(Iy=class extends se{constructor(){super(...arguments);m(this,"shapeId","");m(this,"onEnter",n=>{this.shapeId=n.shapeId,this.editor.setCursor({type:"cross",rotation:0})});m(this,"onPointerDown",()=>{this.parent.transition("pointing",{shapeId:this.shapeId})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(Iy,"id","idle"),Iy);const sC=2;var Ey;let xV=(Ey=class extends se{constructor(){super(...arguments);m(this,"shape",{});m(this,"markId");m(this,"onEnter",n=>{const{inputs:r}=this.editor,{currentPagePoint:o}=r;this.markId=void 0;const s=n.shapeId&&this.editor.getShape(n.shapeId);if(s&&r.shiftKey){this.markId=`creating:${s.id}`,this.editor.mark(this.markId),this.shape=s;const i=this.editor.getShapeHandles(this.shape);if(!i)return;const a=i.filter(f=>f.type==="vertex").sort(en),c=a[a.length-1],l=a[a.length-2],u=oe.applyToPoint(this.editor.getShapeParentTransform(this.shape),new P(this.shape.x,this.shape.y)),d=P.Sub(o,u).addXY(.1,.1),p=Ye(this.shape.props.points);if(P.DistMin(c,l,sC)||P.DistMin(d,c,sC))p[c.id]={id:c.id,index:c.index,x:d.x,y:d.y};else{const f=$o(c.index);p[f]={id:f,index:f,x:d.x,y:d.y}}this.editor.updateShapes([{id:this.shape.id,type:this.shape.type,props:{points:p}}])}else{const i=Be();this.markId=`creating:${i}`,this.editor.mark(this.markId),this.editor.createShapes([{id:i,type:"line",x:o.x,y:o.y}]),this.editor.select(i),this.shape=this.editor.getShape(i)}});m(this,"onPointerMove",()=>{if(this.shape&&this.editor.inputs.isDragging){const n=this.editor.getShapeHandles(this.shape);if(!n)throw this.markId&&this.editor.bailToMark(this.markId),Error("No handles found");const r=Wn(n);this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,isCreating:!0,handle:{...r,x:r.x-.1,y:r.y-.1},onInteractionEnd:"line"})}});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"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()}},m(Ey,"id","pointing"),Ey);class Mh extends se{constructor(){super(...arguments);m(this,"shapeType","line")}}m(Mh,"id","line"),m(Mh,"initial","idle"),m(Mh,"children",()=>[vV,xV]);var _y;let wV=(_y=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(_y,"id","idle"),_y);function We(e,t){var o;const n=new Set;for(const s of t){const i=e.getShape(s);if(!i)continue;e.getShapeUtil(i).onDragShapesOut&&n.add(i);const a=e.getShape(i.parentId);a&&e.getShapeUtil(a).onDragShapesOut&&n.add(a)}const r=new Map;for(const s of n){const i=c$(e,s);i.length&&r.set(s,i)}for(const[s,i]of r){const a=e.getShapeUtil(s),c=fe(i.map(l=>e.getShape(l)));(o=a.onDragShapesOut)==null||o.call(a,s,c)}}function c$(e,t){const n=e.getSortedChildIdsForParent(t.id);if(n.length===0)return[];const r=e.getShapePageBounds(t);if(!r)return[];let o,s,i;const a=[];for(const c of n){const l=e.getShapePageBounds(c);if(!l)continue;if(!r.includes(l)){a.push(c);continue}o??(o=e.getShapeGeometry(t)),s??(s=e.getShapePageTransform(t)),i??(i=s.applyToPoints(o.vertices));const u=e.getShapePageTransform(c).clone().invert().applyToPoints(i),{vertices:d,isClosed:p}=e.getShapeGeometry(c);if(!d.some(f=>Zn(f,u))){if(p){if($2(u,d))continue}else if(A4(u,d))continue;a.push(c)}}return a}function sf(e,t,n=!1){e.select(t),e.setEditingShape(t),e.setCurrentTool("select.editing_shape",{target:"shape",shape:t}),n&&e.emit("select-all-text",{shapeId:t.id}),l$(e)}const bV=16;function l$(e){const t=e.getSelectionPageBounds(),n=e.getViewportPageBounds();if(t&&!n.contains(t)){const r=t.clone().expandBy(bV/e.getZoomLevel()).expand(n),o=n.clone().translate({x:(r.center.x-n.center.x)*2,y:(r.center.y-n.center.y)*2});e.zoomToBounds(o,{duration:Qr,inset:0})}}const vi=20,PV=0,Te=200,Lx={x:Te/2,y:Te/2},u$=10,CV={a1:new P(Te*.5,Te*-.5-vi),a2:new P(Te*1.5+vi,Te*.5),a3:new P(Te*.5,Te*1.5+vi),a4:new P(Te*-.5-vi,Te*.5)};function d$(e,t,n,r){return Object.fromEntries(Object.entries(CV).map(([o,s],i)=>{const a=s.clone();return i===0&&r?a.y-=r:i===2&&n&&(a.y+=n),[o,a.rot(t).add(e)]}))}function h$(e,t,n){const r=new Set(e.getSelectedShapeIds()),o=(Te+vi+n)**2,s=new Map,i=[];for(const l of e.getCurrentPageShapes()){if(!e.isShapeOfType(l,"note")||r.has(l.id))continue;const u=e.getShapePageTransform(l.id);t===u.rotation()&&(s.set(l,e.getShapePageBounds(l).center),i.push(...Object.values(d$(u.point(),t,l.props.growY,n))))}const a=i.length;let c;for(const[l,u]of s)for(let d=0;d<a;d++)c=i[d],c&&(P.Dist2(u,c)>o||e.isPointInShape(l,c)&&(i[d]=void 0));return fe(i)}function p$(e,t,n,r,o=!1){let s;const i=e.getCurrentPageShapesSorted(),a=Te+vi**2;for(let c=i.length-1;c>=0;c--){const l=i[c];if(l.type==="note"&&l.id!==t.id){const u=e.getShapePageBounds(l);if(u&&P.Dist2(u.center,n)<a&&e.isPointInShape(l,n)){s=l;break}}}if(e.complete(),!s||o){e.mark("creating note shape");const c=Be();e.createShape({id:c,type:"note",x:n.x,y:n.y,rotation:r,opacity:t.opacity,props:{...t.props,text:"",growY:0,fontSizeAdjustment:0,url:""}});const l=e.getShape(c),u=e.getPointInParentSpace(l,P.Sub(n,P.Rot(Lx,r)));e.updateShape({id:c,type:"note",x:u.x,y:u.y}),s=e.getShape(c)}return l$(e),s}var ky;let IV=(ky=class extends se{constructor(){super(...arguments);m(this,"dragged",!1);m(this,"info",{});m(this,"wasFocusedOnEnter",!1);m(this,"markId","");m(this,"shape",{});m(this,"onEnter",()=>{const{editor:n}=this;if(this.wasFocusedOnEnter=!n.getIsMenuOpen(),this.wasFocusedOnEnter){const r=Be();this.markId=`creating:${r}`,n.mark(this.markId);const o=this.editor.inputs.originPagePoint.clone(),s=iC(this.editor,o);s&&o.sub(s),this.shape=aC(this.editor,r,o)}});m(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){if(!this.wasFocusedOnEnter){const r=Be(),o=this.editor.inputs.originPagePoint.clone(),s=iC(this.editor,o);s&&o.sub(s),this.shape=aC(this.editor,r,o)}this.editor.setCurrentTool("select.translating",{...n,target:"shape",shape:this.shape,onInteractionEnd:"note",isCreating:!0,onCreate:()=>{this.editor.setEditingShape(this.shape.id),this.editor.setCurrentTool("select.editing_shape")}})}});m(this,"onPointerUp",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()})}complete(){this.wasFocusedOnEnter&&(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)}},m(ky,"id","pointing"),ky);function iC(e,t){let n=u$/e.getZoomLevel(),r;for(const o of h$(e,0,0)){const s=P.Sub(t,o),i=s.len();i<n&&(n=i,r=s)}return r}function aC(e,t,n){e.createShape({id:t,type:"note",x:n.x,y:n.y}).select(t);const r=e.getShape(t),o=e.getShapeGeometry(r).bounds;return e.updateShapes([{id:t,type:"note",x:r.x-o.width/2,y:r.y-o.height/2}]),e.getShape(t)}class Ah extends se{constructor(){super(...arguments);m(this,"shapeType","note")}}m(Ah,"id","note"),m(Ah,"initial","idle"),m(Ah,"children",()=>[wV,IV]);function EV(e){const t=e.getShapeAtPoint(e.inputs.currentPagePoint,{hitInside:!1,hitLabels:!1,margin:Ko/e.getZoomLevel(),renderingOnly:!0});if(!t)return e.setHoveredShape(null);let n;const r=e.getOutermostSelectableShape(t);return r===t||r.id===e.getFocusedGroupId()||e.getSelectedShapeIds().includes(r.id)?n=t:n=r,e.setHoveredShape(n.id)}const Ya=B_(EV,32);var Ty;let _V=(Ty=class extends se{constructor(){super(...arguments);m(this,"onPointerMove",n=>{switch(n.target){case"shape":case"canvas":Ya(this.editor)}});m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onKeyDown",n=>{var r;if(n.key==="Enter"){if(this.editor.getInstanceState().isReadonly)return null;const o=this.editor.getOnlySelectedShape();o&&this.editor.getShapeUtil(o).canEdit(o)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(o.id),(r=this.editor.root.getCurrent())==null||r.transition("editing_shape",{...n,target:"shape",shape:o}))}});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(Ty,"id","idle"),Ty);var $y;let kV=($y=class extends se{constructor(){super(...arguments);m(this,"shape");m(this,"markId","");m(this,"onExit",()=>{this.editor.setHintingShapes([])});m(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){const{inputs:{originPagePoint:r}}=this.editor,o=Be();if(this.markId=`creating:${o}`,this.editor.mark(this.markId),this.editor.createShapes([{id:o,type:"text",x:r.x,y:r.y,props:{text:"",autoSize:!1,w:20}}]),this.editor.select(o),this.shape=this.editor.getShape(o),!this.shape)return;const{shape:s}=this;this.editor.setCurrentTool("select.resizing",{...n,target:"selection",handle:"right",isCreating:!0,creationCursorOffset:{x:1,y:1},onInteractionEnd:"text",onCreate:()=>{this.editor.setEditingShape(s.id),this.editor.setCurrentTool("select.editing_shape")}})}});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.cancel()});m(this,"onCancel",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}complete(){var s;this.editor.mark("creating text shape");const n=Be(),{x:r,y:o}=this.editor.inputs.currentPagePoint;this.editor.createShapes([{id:n,type:"text",x:r,y:o,props:{text:"",autoSize:!0}}]).select(n),this.editor.setEditingShape(n),this.editor.setCurrentTool("select"),(s=this.editor.root.getCurrent())==null||s.transition("editing_shape")}cancel(){this.parent.transition("idle"),this.editor.bailToMark(this.markId)}},m($y,"id","pointing"),$y);class jh extends se{constructor(){super(...arguments);m(this,"shapeType","text")}}m(jh,"id","text"),m(jh,"initial","idle"),m(jh,"children",()=>[_V,kV]);const TV=[jh,kh,Th,Ah,Mh,uv,_h,$h];function xt(){return Jo({isDarkMode:Ru()})}const Pt=Se.memo(function({theme:t,d:n,color:r,fill:o}){switch(o){case"none":return null;case"solid":return h.jsx("path",{fill:t[r].semi,d:n});case"semi":return h.jsx("path",{fill:t.solid,d:n});case"pattern":return h.jsx($V,{theme:t,color:r,fill:o,d:n})}}),$V=function({d:t,color:n,theme:r}){const o=z(),s=D2(),i=K("zoomLevel",()=>o.getZoomLevel(),[o]),a=Math.ceil(i),c=o.getZoomLevel()<=.18;return h.jsxs(h.Fragment,{children:[h.jsx("path",{fill:r[n].pattern,d:t}),h.jsx("path",{fill:s?`url(#${ic[`1_${r.id}`]})`:c?r[n].semi:`url(#${ic[`${a}_${r.id}`]})`,d:t})]})};function MV(e){return e.replace(/\s/g," ")}function dv(e,t,n){const{padding:r=0}=n;if(t.length===0)return null;const o=ne.From(t[0].box);for(const{box:l}of t)o.union(l);const s=r+(n.offsetX??0),i=(n.offsetY??0)+n.fontSize/2+(n.verticalTextAlign==="start"?r:n.verticalTextAlign==="end"?n.height-r-o.height:(Math.ceil(n.height)-o.height)/2);let a=null;const c=[];for(const{text:l,box:u}of t)a!==null&&u.y>a&&c.push(h.jsx("tspan",{alignmentBaseline:"mathematical",x:s,y:u.y+i,children:`
|
|
`},c.length)),c.push(h.jsx("tspan",{alignmentBaseline:"mathematical",x:u.x+s,y:u.y+i,children:MV(l)},c.length)),a=u.y;return h.jsx("text",{fontSize:n.fontSize,fontFamily:n.fontFamily,fontStyle:n.fontFamily,fontWeight:n.fontWeight,dominantBaseline:"mathematical",alignmentBaseline:"mathematical",stroke:n.stroke,strokeWidth:n.strokeWidth,fill:n.fill,children:c})}function AV(e,t,n,r){if((e==="start-legacy"||e==="end-legacy")&&n.length!==0){const o=ne.From(n[0].box);for(const{box:s}of n)o.union(s);if(e==="start-legacy")return(r-2*t-o.width)/2;if(e==="end-legacy")return-(r-2*t-o.width)/2}}function jV(e){return e==="start-legacy"||e==="middle-legacy"||e==="end-legacy"}function eg({fontSize:e,font:t,align:n,verticalAlign:r,text:o,labelColor:s,bounds:i,padding:a=16,stroke:c=!0}){const l=z(),u=xt(),d={fontSize:e,fontFamily:pk[t],textAlign:n,verticalTextAlign:r,width:Math.ceil(i.width),height:Math.ceil(i.height),padding:a,lineHeight:Ht.lineHeight,fontStyle:"normal",fontWeight:"normal",overflow:"wrap",offsetX:0,offsetY:0,fill:s,stroke:void 0,strokeWidth:void 0},p=l.textMeasure.measureTextSpans(o,d),f=AV(n,a,p,i.width);f&&(d.offsetX=f),d.offsetX+=i.x,d.offsetY+=i.y;const y=dv(l,p,d);let g=null;return c&&(d.fill=u.background,d.stroke=u.background,d.strokeWidth=2,g=dv(l,p,d)),h.jsxs(h.Fragment,{children:[g,y]})}function lc(e){return{key:`${ao.id}:${e}`,getElement:async()=>{const t=OV(e);if(!t)return null;const n=t.$$_url,r=t.$$_fontface;if(!n||!r)return null;const o=await(await fetch(n)).blob(),s=await Ka.blobToDataUrl(o),i=r.replace(n,s);return h.jsx("style",{children:i})}}}function OV(e){const t=pk[e];for(const n of document.fonts)if(t.includes(n.family))return n;return null}function Fx(e){return{key:`${ao.id}:${e}`,getElement:async()=>e!=="pattern"?null:h.jsx(DV,{})}}function DV(){const e=xt(),t=8/12;return h.jsxs(h.Fragment,{children:[h.jsxs("mask",{id:"hash_pattern_mask",children:[h.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:"white"}),h.jsxs("g",{strokeLinecap:"round",stroke:"black",children:[h.jsx("line",{x1:t*1,y1:t*3,x2:t*3,y2:t*1}),h.jsx("line",{x1:t*5,y1:t*7,x2:t*7,y2:t*5}),h.jsx("line",{x1:t*9,y1:t*11,x2:t*11,y2:t*9})]})]}),h.jsx("pattern",{id:ic[`1_${e.id}`],width:"8",height:"8",patternUnits:"userSpaceOnUse",children:h.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:e.solid,mask:"url(#hash_pattern_mask)"})})]})}function Nx(){return{key:`${ao.id}:pattern`,component:FV}}const ml=8,cC=(e,t,n)=>new Promise((r,o)=>{const s=ml*t*e,i=document.createElement("canvas");i.width=s,i.height=s;const a=i.getContext("2d");if(!a)return;a.fillStyle=n?"#212529":"#f8f9fa",a.fillRect(0,0,s,s),a.globalCompositeOperation="destination-out",a.lineCap="round",a.lineWidth=1.25*t*e;const c=8/12,l=u=>u*t*e;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(),i.toBlob(u=>{!u||$t.throwToBlob.get()?o():r(u)})}),lC=(e,t)=>{const n=document.createElement("canvas");n.width=e[0],n.height=e[1];const r=n.getContext("2d");return r?(t(r),n.toDataURL()):""},RV=()=>{const e=[];for(let t=1;t<=Math.ceil(xs);t++){const n=lC([1,1],o=>{o.fillStyle=Np.lightMode.black.semi,o.fillRect(0,0,1,1)}),r=lC([1,1],o=>{o.fillStyle=Np.darkMode.black.semi,o.fillRect(0,0,1,1)});e.push({zoom:t,url:n,darkMode:!1}),e.push({zoom:t,url:r,darkMode:!0})}return e};function LV(){const t=z().getInstanceState().devicePixelRatio,[n,r]=x.useState(!1),o=x.useMemo(()=>RV(),[]),[s,i]=x.useState(o);return x.useEffect(()=>{const c=[];for(let u=1;u<=Math.ceil(xs);u++)c.push(cC(t,u,!1).then(d=>({zoom:u,url:URL.createObjectURL(d),darkMode:!1}))),c.push(cC(t,u,!0).then(d=>({zoom:u,url:URL.createObjectURL(d),darkMode:!0})));let l=!1;return Promise.all(c).then(u=>{l||(i(u),r(!0))}),()=>{l=!0,r(!1)}},[t]),{defs:h.jsx(h.Fragment,{children:s.map(c=>{const l=c.zoom+(c.darkMode?"_dark":"_light");return h.jsx("pattern",{id:ic[l],width:ml,height:ml,patternUnits:"userSpaceOnUse",children:h.jsx("image",{href:c.url,width:ml,height:ml})},l)})}),isReady:n}}function FV(){const e=z(),t=x.useRef(null),{defs:n,isReady:r}=LV();return x.useEffect(()=>{if(r&&e.environment.isSafari){const o=f$(t.current);o&&requestAnimationFrame(()=>{o.style.display="none",requestAnimationFrame(()=>{o.style.display=""})})}},[e,r]),h.jsx("g",{ref:t,"data-testid":r?"ready-pattern-fill-defs":void 0,children:n})}function f$(e){return e.classList.contains("tl-html-layer")?e:e.parentElement?f$(e.parentElement):null}function Vo(e,t,n={}){const{closed:r=!1,snap:o=1,start:s="outset",end:i="outset",lengthRatio:a=2,style:c="dashed"}=n;let l=0,u=0,d=1,p=0,f=0;switch(c){case"dashed":{d=1,l=Math.min(t*a,e/4);break}case"dotted":{d=100,l=t/d;break}default:return{strokeDasharray:"none",strokeDashoffset:"none"}}return r||(s==="outset"?(e+=l/2,f+=l/2):s==="skip"&&(e-=l,f-=l),i==="outset"?e+=l/2:i==="skip"&&(e-=l)),u=Math.floor(e/l/(2*d)),u-=u%o,u<3&&c==="dashed"?e/t<5?(l=e,u=1,p=0):(l=e*.333,p=e*.333):(u=Math.max(u,3),l=e/u/(2*d),r?(f=l/2,p=(e-u*l)/u):p=(e-u*l)/Math.max(1,u-1)),{strokeDasharray:[l,p].join(" "),strokeDashoffset:f.toString()}}const uC=new WeakMap;function zx(e,t){const n=uC.get(t);if(n)return n;const r=e.getArrowInfo(t);let o=0,s=0;const i=r.isStraight?new lu({start:P.From(r.start.point),end:P.From(r.end.point)}):new Z2({center:P.Cast(r.handleArc.center),radius:r.handleArc.radius,start:P.Cast(r.start.point),end:P.Cast(r.end.point),sweepFlag:r.bodyArc.sweepFlag,largeArcFlag:r.bodyArc.largeArcFlag});if(t.props.text.trim()){const c=i.bounds,{w:l,h:u}=e.textMeasure.measureText(t.props.text,{...Ht,fontFamily:io[t.props.font],fontSize:hi[t.props.size],maxWidth:null});if(o=l,s=u,c.width>c.height){o=Math.max(Math.min(l,64),Math.min(c.width-64,l));const{w:d,h:p}=e.textMeasure.measureText(t.props.text,{...Ht,fontFamily:io[t.props.font],fontSize:hi[t.props.size],maxWidth:o});o=d,s=p}if(o>16*hi[t.props.size]){o=16*hi[t.props.size];const{w:d,h:p}=e.textMeasure.measureText(t.props.text,{...Ht,fontFamily:io[t.props.font],fontSize:hi[t.props.size],maxWidth:o});o=d,s=p}}const a=new P(o,s).addScalar(RW*2);return uC.set(t,a),a}function g$(e,t){const n=Mt[t.props.size];return DW+(n-Mt.s)*2+(n===Mt.xl?20:0)}function NV(e,t,n){const r=zx(e,t),o=g$(e,t),s=P.Nudge(n.start.point,n.end.point,o),i=P.Nudge(n.end.point,n.start.point,o),a=ox(s,i,ne.FromCenter(n.middle,r).corners);if(!a||a.length!==2)return{start:.5,end:.5};let[c,l]=a;P.Dist2(c,s)>P.Dist2(l,s)&&([l,c]=a);const u=s.add(P.Sub(n.middle,c)),d=i.add(P.Sub(n.middle,l)),p=P.Dist(n.start.point,u)/n.length,f=P.Dist(n.start.point,d)/n.length;return{start:p,end:f}}function zV(e,t,n){const r=zx(e,t),o=g$(e,t),s=Math.sign(t.props.bend),i=o/n.handleArc.radius*s,a=P.Angle(n.bodyArc.center,n.start.point)-i,c=P.Angle(n.bodyArc.center,n.end.point)+i,l=$i(n.bodyArc.center,n.bodyArc.radius,a),u=$i(n.bodyArc.center,n.bodyArc.radius,c),d=[],p=dC(n.bodyArc.center,n.bodyArc.radius,a,c,s,ne.FromCenter(l,r).corners);d.push(new wt({points:ne.FromCenter(l,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));const f=dC(n.bodyArc.center,n.bodyArc.radius,a,c,s,ne.FromCenter(u,r).corners);d.push(new wt({points:ne.FromCenter(u,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));for(const _ of[...p??[],...f??[],l,u])d.push(new px({x:_.x-3,y:_.y-3,radius:3,isFilled:!1,debugColor:"magenta",ignore:!0}));const y=(p&&hC(n.start.point,p))??n.middle,g=(f&&hC(n.end.point,f))??n.middle,w=P.Angle(n.bodyArc.center,n.start.point),S=P.Angle(n.bodyArc.center,n.end.point),v=P.Angle(n.bodyArc.center,y),b=P.Angle(n.bodyArc.center,g);if(vs(w,v,s)>vs(w,b,s))return{start:.5,end:.5,dbg:d};const E=vs(w,S,s),C=vs(w,v,s)/E,I=vs(w,b,s)/E;return{start:C,end:I,dbg:d}}function Oh(e,t){let n;const r=[],o=e.getArrowInfo(t),s=t.props.start.type==="binding",i=t.props.end.type==="binding",a=o.start.arrowhead!=="none",c=o.end.arrowhead!=="none";if(o.isStraight){const u=NV(e,t,o);let d=Ns(t.props.labelPosition,a||s?u.start:0,c||i?u.end:1);d=d>=.48&&d<=.52?.5:d,n=P.Lrp(o.start.point,o.end.point,d)}else{const u=zV(e,t,o);u.dbg&&r.push(...u.dbg);let d=Ns(t.props.labelPosition,a||s?u.start:0,c||i?u.end:1);d=d>=.48&&d<=.52?.5:d;const p=BV(P.Angle(o.bodyArc.center,o.start.point),P.Angle(o.bodyArc.center,o.end.point),Math.sign(t.props.bend),d);n=$i(o.bodyArc.center,o.bodyArc.radius,p)}const l=zx(e,t);return{box:ne.FromCenter(n,l),debugGeom:r}}function dC(e,t,n,r,o,s){const i=WS(e,t,s),a=vs(n,r,o);return i==null?void 0:i.filter(c=>{const l=vs(n,P.Angle(e,c),o);return l>=0&&l<=a})}function hC(e,t){let n=null,r=-1/0;for(const o of t){const s=P.Dist2(e,o);s>r&&(n=o,r=s)}return n}function BV(e,t,n,r){const o=vs(e,t,n);return e+o*r*n*-1}function UV(e,t,n){const r=t==="end"?e.end.point:e.start.point,o=t==="end"?e.start.point:e.end.point,s=e.isStraight?P.Dist(o,r):Math.abs(e.bodyArc.length),i=Math.max(Math.min(s/5,n*3),n);let a;if(e.isStraight)a=P.Nudge(r,o,i);else{const c=$4(r,i,e.handleArc.center,e.handleArc.radius);a=t==="end"?e.handleArc.sweepFlag?c[0]:c[1]:e.handleArc.sweepFlag?c[1]:c[0]}return P.IsNaN(a)&&(a=e.start.point),{point:r,int:a}}function HV({point:e,int:t}){const n=P.RotWith(t,e,Pe/6),r=P.RotWith(t,e,-Pe/6);return`M ${n.x} ${n.y} L ${e.x} ${e.y} L ${r.x} ${r.y}`}function KV({point:e,int:t}){const n=P.RotWith(t,e,Pe/6),r=P.RotWith(t,e,-Pe/6);return`M ${n.x} ${n.y} L ${e.x} ${e.y} L ${r.x} ${r.y} Z`}function WV({point:e,int:t}){const n=P.Sub(t,e).div(2),r=P.Add(e,P.Rot(n,ze)),o=P.Sub(e,P.Rot(n,ze));return`M ${r.x} ${r.y} L ${t.x} ${t.y} L ${o.x} ${o.y} Z`}function VV({point:e,int:t}){const n=P.Lrp(e,t,.45),r=P.Dist(n,e);return`M ${n.x-r},${n.y}
|
|
a ${r},${r} 0 1,0 ${r*2},0
|
|
a ${r},${r} 0 1,0 -${r*2},0 `}function GV({point:e,int:t}){const n=P.Lrp(e,t,.75),r=P.RotWith(n,e,Pe/4),o=P.RotWith(n,e,-Pe/4),s=P.Lrp(r,o,.5);return s.add(P.Sub(s,e)),`M ${s.x} ${s.y} L ${r.x} ${r.y} ${e.x} ${e.y} L ${o.x} ${o.y} Z`}function YV({int:e,point:t}){const n=P.Lrp(t,e,.85),r=P.Sub(n,t).div(2),o=P.Add(t,P.Rot(r,ze)),s=P.Sub(t,P.Rot(r,ze)),i=P.Add(n,P.Rot(r,ze)),a=P.Sub(n,P.Rot(r,ze));return`M ${o.x} ${o.y} L ${i.x} ${i.y} L ${a.x} ${a.y} L ${s.x} ${s.y} Z`}function XV({int:e,point:t}){const n=P.Sub(e,t).div(2),r=P.Add(t,P.Rot(n,ze)),o=P.Sub(t,P.Rot(n,ze));return`M ${r.x} ${r.y} L ${o.x} ${o.y}`}function af(e,t,n){const r=t==="end"?e.end.arrowhead:e.start.arrowhead;if(r==="none")return;const o=UV(e,t,n);if(o){switch(r){case"bar":return XV(o);case"square":return YV(o);case"diamond":return GV(o);case"dot":return VV(o);case"inverted":return WV(o);case"arrow":return HV(o);case"triangle":return KV(o)}return""}}function qV(e){const{start:t,end:n,handleArc:{radius:r,largeArcFlag:o,sweepFlag:s}}=e;return`M${t.handle.x},${t.handle.y} A${r} ${r} 0 ${o} ${s} ${n.handle.x},${n.handle.y}`}function m$(e){const{start:t,end:n,bodyArc:{radius:r,largeArcFlag:o,sweepFlag:s}}=e;return`M${t.point.x},${t.point.y} A${r} ${r} 0 ${o} ${s} ${n.point.x},${n.point.y}`}function y$(e,t){return`M${e.x},${e.y}L${t.x},${t.y}`}function ZV(e){return y$(e.start.handle,e.end.handle)}function S$(e){return y$(e.start.point,e.end.point)}const QV=x.forwardRef(function({isEditing:t,text:n,handleFocus:r,handleChange:o,handleKeyDown:s,handleBlur:i,handleInputPointerDown:a,handleDoubleClick:c},l){return h.jsx("textarea",{ref:l,className:"tl-text tl-text-input",name:"text",tabIndex:-1,readOnly:!t,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",autoSave:"off",placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",datatype:"wysiwyg",defaultValue:n,onFocus:r,onChange:o,onKeyDown:s,onBlur:i,onTouchEnd:Ut,onContextMenu:t?Ut:void 0,onPointerDown:a,onDoubleClick:c,onDragStart:Ee})});function JV(e,t,n){const r=z(),o=x.useRef(null),s=x.useRef(),i=K("isEditing",()=>r.getEditingShapeId()===e,[r]),a=K("isEditingAnything",()=>!!r.getEditingShapeId(),[r]);x.useEffect(()=>{function p({shapeId:f}){requestAnimationFrame(()=>{if(f===e){const y=o.current;y&&(document.activeElement!==y&&y.focus(),y.select())}})}return r.on("select-all-text",p),()=>{r.off("select-all-text",p)}},[r,e]),x.useEffect(()=>{if(!i)return;const p=o.current;if(!p)return;document.activeElement!==p?(p.focus(),r.getInstanceState().isCoarsePointer&&p.select()):r.environment.isSafari&&(p.blur(),p.focus());function f(){var g,w;const y=(g=window.getSelection)==null?void 0:g.call(window);if(y&&y.type!=="None"){const S=[];for(let v=0;v<y.rangeCount;v++)S.push((w=y.getRangeAt)==null?void 0:w.call(y,v));s.current=S}}return document.addEventListener("selectionchange",f),()=>{document.removeEventListener("selectionchange",f)}},[r,i]);const c=x.useCallback(()=>{const p=s.current;requestAnimationFrame(()=>{var g;const f=o.current,y=r.getEditingShapeId();if(y){if(f&&y===e&&(f.focus(),p&&p.length)){const w=window.getSelection();w&&p.forEach(S=>w.addRange(S))}}else(g=window.getSelection())==null||g.removeAllRanges()})},[r,e]),l=x.useCallback(p=>{if(r.getEditingShapeId()===e)switch(p.key){case"Enter":{(p.ctrlKey||p.metaKey)&&r.complete();break}}},[r,e]),u=x.useCallback(p=>{if(r.getEditingShapeId()!==e)return;let f=cc.normalizeText(p.currentTarget.value);const y=f.replace(/\t/g,Da);if(y!==f){const g=p.currentTarget.selectionStart;p.currentTarget.value=y,p.currentTarget.selectionStart=g+(y.length-f.length),p.currentTarget.selectionEnd=g+(y.length-f.length),f=y}r.updateShape({id:e,type:t,props:{text:f}})},[r,e,t]),d=x.useCallback(p=>{r.dispatch({..._n(p),type:"pointer",name:"pointer_down",target:"shape",shape:r.getShape(e)}),Ut(p)},[r,e]);return{rInput:o,handleFocus:eG,handleBlur:c,handleKeyDown:l,handleChange:u,handleInputPointerDown:d,handleDoubleClick:Ut,isEmpty:n.trim().length===0,isEditing:i,isEditingAnything:a}}function eG(){}const tg=Se.memo(function({id:t,type:n,text:r,labelColor:o,font:s,fontSize:i,lineHeight:a,align:c,verticalAlign:l,wrap:u,isSelected:d,onKeyDown:p,classNamePrefix:f,style:y,textWidth:g,textHeight:w}){const{rInput:S,isEmpty:v,isEditing:b,isEditingAnything:E,...C}=JV(t,n,r),[I,_]=x.useState(r);x.useEffect(()=>{b||_(r)},[b,r]);const k=cc.normalizeTextForDom(r),$=k.length>0,T=jV(c);if(!b&&!$)return null;const O=f||"tl-text";return h.jsx("div",{className:`${O}-label tl-text-wrapper`,"data-font":s,"data-align":c,"data-hastext":!v,"data-isediting":b,"data-iseditinganything":E,"data-textwrap":!!u,"data-isselected":d,style:{justifyContent:c==="middle"||T?"center":c,alignItems:l==="middle"?"center":l,...y},children:h.jsxs("div",{className:`${O}-label__inner tl-text-content__wrapper`,style:{fontSize:i,lineHeight:i*a+"px",minHeight:a+32,minWidth:g||0,color:o,width:g,height:w},children:[h.jsx("div",{className:`${O} tl-text tl-text-content`,dir:"ltr",children:k}),(E||d)&&h.jsx(QV,{ref:S,text:r,isEditing:b,...C,handleKeyDown:p??C.handleKeyDown},I)]})})}),tG=x.memo(function({id:t,text:n,size:r,font:o,position:s,width:i,isSelected:a,labelColor:c}){const l=xt();return h.jsx(tg,{id:t,classNamePrefix:"tl-arrow",type:"arrow",font:o,fontSize:hi[r],lineHeight:Ht.lineHeight,align:"middle",verticalAlign:"middle",text:n,labelColor:l[c].solid,textWidth:i,isSelected:a,style:{transform:`translate(${s.x}px, ${s.y}px)`}})});let nG=0;class Dh extends Fr{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"canBind",()=>!1);m(this,"canSnap",()=>!1);m(this,"hideResizeHandles",()=>!0);m(this,"hideRotateHandle",()=>!0);m(this,"hideSelectionBoundsBg",()=>!0);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"onHandleDrag",(n,{handle:r,isPrecise:o})=>{const s=r.id;if(s==="middle"){const{start:w,end:S}=jr(this.editor,n),v=P.Sub(S,w),b=P.Per(v),E=P.Med(S,w),C=P.Sub(E,b),I=P.Add(E,b),_=P.NearestPointOnLineSegment(C,I,r,!1);let k=P.Dist(_,E);return P.Clockwise(_,S,E)&&(k*=-1),{id:n.id,type:n.type,props:{bend:k}}}const i=Ye(n);if(this.editor.inputs.ctrlKey)return i.props[s]={type:"point",x:r.x,y:r.y},i;const a=this.editor.getShapePageTransform(n.id).applyToPoint(r),c=this.editor.getShapeAtPoint(a,{hitInside:!0,hitFrameInside:!0,margin:0,filter:w=>!w.isLocked&&this.editor.getShapeUtil(w).canBind(w)});if(!c)return i.props[s]={type:"point",x:r.x,y:r.y},i;const l=this.editor.getShapeGeometry(c),u=ne.ZeroFix(l.bounds),p=this.editor.getShapePageTransform(i.id).applyToPoint(r),f=this.editor.getPointInShapeSpace(c,p);let y=o;if(!y){const w=i.props[s];(w.type==="point"||w.type==="binding"&&c.id!==w.boundShapeId)&&(y=this.editor.inputs.pointerVelocity.len()<.5)}if(!o){l.isClosed||(y=!0);const w=i.props[s==="start"?"end":"start"];w.type==="binding"&&c.id===w.boundShapeId&&w.isPrecise&&(y=!0)}const g={x:(f.x-u.minX)/u.width,y:(f.y-u.minY)/u.height};return y&&P.Dist(f,u.center)<Math.max(4,Math.min(Math.min(u.width,u.height)*.15,16))/this.editor.getZoomLevel()&&(g.x=.5,g.y=.5),i.props[s]={type:"binding",boundShapeId:c.id,normalizedAnchor:g,isPrecise:y,isExact:this.editor.inputs.altKey},i.props.start.type==="binding"&&i.props.end.type==="binding"&&i.props.start.boundShapeId===i.props.end.boundShapeId&&P.Equals(i.props.start.normalizedAnchor,i.props.end.normalizedAnchor)&&(i.props.end.normalizedAnchor.x+=.05),i});m(this,"onTranslateStart",n=>{const r=n.props.start.type==="binding"?n.props.start.boundShapeId:null,o=n.props.end.type==="binding"?n.props.end.boundShapeId:null,s=jr(this.editor,n),i=this.editor.getShapePageTransform(n.id),a=this.editor.getSelectedShapeIds(),c=new Set;r&&(c.add(r),this.editor.getShapeAncestors(r).forEach(u=>c.add(u.id))),o&&(c.add(o),this.editor.getShapeAncestors(o).forEach(u=>c.add(u.id)));for(const u of a)if(c.has(u))return;let l=n;fC.set(n,{pagePosition:i.applyToPoint(n),terminalBindings:Mf(s,(u,d)=>{const p=n.props[u];return p.type!=="binding"?null:{binding:p,shapePosition:d,pagePosition:i.applyToPoint(d)}})});for(const u of["start","end"]){const d=n.props[u];d.type==="binding"&&(l={...n,props:{...n.props,[u]:{...d,isPrecise:!0}}})}return l});m(this,"onTranslate",(n,r)=>{const o=fC.get(n);if(!o)return;const s=this.editor.getShapePageTransform(r.id),i=P.Sub(s.applyToPoint(r),o.pagePosition);let a=r;for(const[c,l]of An(o.terminalBindings)){if(!l)continue;const u=P.Add(l.pagePosition,P.Mul(i,.5)),d=this.editor.getShapeAtPoint(u,{hitInside:!0,hitFrameInside:!0,margin:0,filter:p=>!p.isLocked&&this.editor.getShapeUtil(p).canBind(p)});if((d==null?void 0:d.id)===l.binding.boundShapeId){const p=ne.ZeroFix(this.editor.getShapeGeometry(d).bounds),f=this.editor.getPointInShapeSpace(d,u),y={x:(f.x-p.minX)/p.width,y:(f.y-p.minY)/p.height};a={...a,props:{...a.props,[c]:{...l.binding,isPrecise:!0,normalizedAnchor:y}}}}else a={...a,props:{...a.props,[c]:{type:"point",x:l.shapePosition.x,y:l.shapePosition.y}}}}return a});m(this,"onResize",(n,r)=>{const{scaleX:o,scaleY:s}=r,i=jr(this.editor,n),{start:a,end:c}=Ye(n.props);let{bend:l}=n.props;a.type==="point"&&(a.x=i.start.x*o,a.y=i.start.y*s),c.type==="point"&&(c.x=i.end.x*o,c.y=i.end.y*s);const u=Math.abs(o),d=Math.abs(s);return o<0&&s>=0?(l!==0&&(l*=-1,l*=Math.max(u,d)),a.type==="binding"&&(a.normalizedAnchor.x=1-a.normalizedAnchor.x),c.type==="binding"&&(c.normalizedAnchor.x=1-c.normalizedAnchor.x)):o>=0&&s<0?(l!==0&&(l*=-1,l*=Math.max(u,d)),a.type==="binding"&&(a.normalizedAnchor.y=1-a.normalizedAnchor.y),c.type==="binding"&&(c.normalizedAnchor.y=1-c.normalizedAnchor.y)):o>=0&&s>=0?l!==0&&(l*=Math.max(u,d)):o<0&&s<0&&(l!==0&&(l*=Math.max(u,d)),a.type==="binding"&&(a.normalizedAnchor.x=1-a.normalizedAnchor.x,a.normalizedAnchor.y=1-a.normalizedAnchor.y),c.type==="binding"&&(c.normalizedAnchor.x=1-c.normalizedAnchor.x,c.normalizedAnchor.y=1-c.normalizedAnchor.y)),{props:{start:a,end:c,bend:l}}});m(this,"onDoubleClickHandle",(n,r)=>{switch(r.id){case"start":return{id:n.id,type:n.type,props:{...n.props,arrowheadStart:n.props.arrowheadStart==="none"?"arrow":"none"}};case"end":return{id:n.id,type:n.type,props:{...n.props,arrowheadEnd:n.props.arrowheadEnd==="none"?"arrow":"none"}}}});m(this,"onEditEnd",n=>{const{id:r,type:o,props:{text:s}}=n;s.trimEnd()!==n.props.text&&this.editor.updateShapes([{id:r,type:o,props:{text:s.trimEnd()}}])})}getDefaultProps(){return{dash:"draw",size:"m",fill:"none",color:"black",labelColor:"black",bend:0,start:{type:"point",x:0,y:0},end:{type:"point",x:2,y:0},arrowheadStart:"none",arrowheadEnd:"arrow",text:"",labelPosition:.5,font:"draw"}}getGeometry(n){const r=this.editor.getArrowInfo(n),o=[],s=r.isStraight?new lu({start:P.From(r.start.point),end:P.From(r.end.point)}):new Z2({center:P.Cast(r.handleArc.center),radius:r.handleArc.radius,start:P.Cast(r.start.point),end:P.Cast(r.end.point),sweepFlag:r.bodyArc.sweepFlag,largeArcFlag:r.bodyArc.largeArcFlag});let i;if(n.props.text.trim()){const a=Oh(this.editor,n);o.push(...a.debugGeom),i=new Wo({x:a.box.x,y:a.box.y,width:a.box.w,height:a.box.h,isFilled:!0,isLabel:!0})}return new Br({children:[...i?[s,i]:[s],...o]})}getHandles(n){const r=this.editor.getArrowInfo(n);return[{id:"start",type:"vertex",index:"a0",x:r.start.handle.x,y:r.start.handle.y,canBind:!0},{id:"middle",type:"virtual",index:"a2",x:r.middle.x,y:r.middle.y,canBind:!1},{id:"end",type:"vertex",index:"a3",x:r.end.handle.x,y:r.end.handle.y,canBind:!0}].filter(Boolean)}component(n){const r=this.editor.getOnlySelectedShape(),o=this.editor.isInAny("select.idle","select.pointing_handle","select.dragging_handle","select.translating","arrow.dragging")&&!this.editor.getInstanceState().isReadonly,s=this.editor.getArrowInfo(n);if(!(s!=null&&s.isValid))return null;const i=Oh(this.editor,n),a=n.id===this.editor.getOnlySelectedShapeId(),l=this.editor.getEditingShapeId()===n.id||n.props.text;return h.jsxs(h.Fragment,{children:[h.jsx(zs,{id:n.id,style:{minWidth:50,minHeight:50},children:h.jsx(pC,{shape:n,shouldDisplayHandles:o&&r===n})}),l&&h.jsx(tG,{id:n.id,text:n.props.text,font:n.props.font,size:n.props.size,position:i.box.center,width:i.box.w,isSelected:a,labelColor:n.props.labelColor})]})}indicator(n){const{start:r,end:o}=jr(this.editor,n),s=this.editor.getArrowInfo(n),i=this.editor.getShapeGeometry(n),a=i.bounds,c=n.props.text.trim()?i.children[1]:null,l=Vf(n.id);if(!s||P.Equals(r,o))return null;const u=Mt[n.props.size],d=s.start.arrowhead&&af(s,"start",u),p=s.end.arrowhead&&af(s,"end",u),f=s.isStraight?S$(s):m$(s),y=d&&s.start.arrowhead!=="arrow"||p&&s.end.arrowhead!=="arrow"||!!c,g=(n.id+"_clip").replace(":","_");return l&&c?h.jsx("rect",{x:j(c.x),y:j(c.y),width:c.w,height:c.h,rx:3.5,ry:3.5}):h.jsxs("g",{children:[y&&h.jsx("defs",{children:h.jsxs("mask",{id:g,children:[h.jsx("rect",{x:a.minX-100,y:a.minY-100,width:a.w+200,height:a.h+200,fill:"white"}),c&&h.jsx("rect",{x:j(c.x),y:j(c.y),width:c.w,height:c.h,fill:"black",rx:3.5,ry:3.5}),d&&h.jsx("path",{d,fill:s.start.arrowhead==="arrow"?"none":"black",stroke:"none"}),p&&h.jsx("path",{d:p,fill:s.end.arrowhead==="arrow"?"none":"black",stroke:"none"})]})}),h.jsxs("g",{...y?{mask:`url(#${g})`}:void 0,children:[y&&h.jsx("rect",{x:a.minX-100,y:a.minY-100,width:a.width+200,height:a.height+200,opacity:0}),h.jsx("path",{d:f})]}),d&&h.jsx("path",{d}),p&&h.jsx("path",{d:p}),c&&h.jsx("rect",{x:j(c.x),y:j(c.y),width:c.w,height:c.h,rx:3.5,ry:3.5})]})}toSvg(n,r){r.addExportDef(Fx(n.props.fill)),n.props.text&&r.addExportDef(lc(n.props.font));const o=Jo(r);return h.jsxs(h.Fragment,{children:[h.jsx(pC,{shape:n,shouldDisplayHandles:!1}),h.jsx(eg,{fontSize:hi[n.props.size],font:n.props.font,align:"middle",verticalAlign:"middle",text:n.props.text,labelColor:o[n.props.labelColor].solid,bounds:Oh(this.editor,n).box,padding:4})]})}getCanvasSvgDefs(){return[Nx(),{key:"arrow:dot",component:oG},{key:"arrow:cross",component:sG}]}}m(Dh,"type","arrow"),m(Dh,"props",gk),m(Dh,"migrations",mk);function rG(e,t){const n=e.getArrowInfo(t);return n.isStraight?P.Dist(n.start.handle,n.end.handle):Math.abs(n.handleArc.length)}const pC=or(function({shape:t,shouldDisplayHandles:n}){const r=z(),o=xt(),s=r.getArrowInfo(t),i=ne.ZeroFix(r.getShapeGeometry(t).bounds),a=Se.useMemo(()=>r.environment.isSafari?nG+=1:0,[t]);if(!(s!=null&&s.isValid))return null;const c=Mt[t.props.size],l=s.start.arrowhead&&af(s,"start",c),u=s.end.arrowhead&&af(s,"end",c),d=s.isStraight?S$(s):m$(s);let p=null;if(n){const{strokeDasharray:E,strokeDashoffset:C}=Vo(rG(r,t),2,{end:"skip",start:"skip",lengthRatio:2.5});p=t.props.start.type==="binding"||t.props.end.type==="binding"?h.jsx("path",{className:"tl-arrow-hint",d:s.isStraight?ZV(s):qV(s),strokeDasharray:E,strokeDashoffset:C,strokeWidth:2,markerStart:t.props.start.type==="binding"?t.props.start.isExact?"":t.props.start.isPrecise?"url(#arrowhead-cross)":"url(#arrowhead-dot)":"",markerEnd:t.props.end.type==="binding"?t.props.end.isExact?"":t.props.end.isPrecise?"url(#arrowhead-cross)":"url(#arrowhead-dot)":"",opacity:.16}):null}const{strokeDasharray:f,strokeDashoffset:y}=Vo(s.isStraight?s.length:Math.abs(s.bodyArc.length),c,{style:t.props.dash}),g=Oh(r,t),w=!(s.start.arrowhead==="none"||s.start.arrowhead==="arrow"),S=!(s.end.arrowhead==="none"||s.end.arrowhead==="arrow"),v=(t.id+"_clip_"+a).replace(":","_");return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsxs("mask",{id:v,children:[h.jsx("rect",{x:j(-100+i.minX),y:j(-100+i.minY),width:j(i.width+200),height:j(i.height+200),fill:"white"}),t.props.text.trim()&&h.jsx("rect",{x:g.box.x,y:g.box.y,width:g.box.w,height:g.box.h,fill:"black",rx:4,ry:4}),l&&w&&h.jsx("path",{d:l,fill:s.start.arrowhead==="arrow"?"none":"black",stroke:"none"}),u&&S&&h.jsx("path",{d:u,fill:s.end.arrowhead==="arrow"?"none":"black",stroke:"none"})]})}),h.jsxs("g",{fill:"none",stroke:o[t.props.color].solid,strokeWidth:c,strokeLinejoin:"round",strokeLinecap:"round",pointerEvents:"none",children:[p,h.jsxs("g",{mask:`url(#${v})`,children:[h.jsx("rect",{x:j(i.minX-100),y:j(i.minY-100),width:j(i.width+200),height:j(i.height+200),opacity:0}),h.jsx("path",{d,strokeDasharray:f,strokeDashoffset:y})]}),l&&w&&t.props.fill!=="none"&&h.jsx(Pt,{theme:o,d:l,color:t.props.color,fill:t.props.fill}),u&&S&&t.props.fill!=="none"&&h.jsx(Pt,{theme:o,d:u,color:t.props.color,fill:t.props.fill}),l&&h.jsx("path",{d:l}),u&&h.jsx("path",{d:u})]})]})}),fC=new WeakMap;function oG(){return h.jsx("marker",{id:"arrowhead-dot",className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"0",children:h.jsx("circle",{cx:"3",cy:"3",r:"2",strokeDasharray:"100%"})})}function sG(){return h.jsxs("marker",{id:"arrowhead-cross",className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"auto",children:[h.jsx("line",{x1:"1.5",y1:"1.5",x2:"4.5",y2:"4.5",strokeDasharray:"100%"}),h.jsx("line",{x1:"1.5",y1:"4.5",x2:"4.5",y2:"1.5",strokeDasharray:"100%"})]})}const gC="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 uc({url:e,zoomLevel:t}){return h.jsx("a",{className:ue("tl-hyperlink-button",{"tl-hyperlink-button__hidden":t<.32}),href:e,target:"_blank",rel:"noopener noreferrer",onPointerDown:Ut,onPointerUp:Ut,title:e,draggable:!1,children:h.jsx("div",{className:"tl-hyperlink-button__icon",style:{mask:`url("${gC}") center 100% / 100% no-repeat`,WebkitMask:`url("${gC}") center 100% / 100% no-repeat`}})})}const iG=[{offsetX:0,offsetY:2,blur:4,spread:0,color:"#00000029"},{offsetX:0,offsetY:3,blur:6,spread:0,color:"#0000001f"}];function Bx(e){return iG.map(n=>{const{offsetX:r,offsetY:o,blur:s,spread:i,color:a}=n,c=new P(r,o),{x:l,y:u}=c.rot(-e);return`${l}px ${u}px ${s}px ${i}px ${a}`}).join(", ")}class Rh extends Pc{constructor(){super(...arguments);m(this,"canResize",()=>!1);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"onBeforeCreate",n=>{mC(this.editor,n)});m(this,"onBeforeUpdate",(n,r)=>{if(n.props.url!==r.props.url)if(er.isValid(r.props.url))mC(this.editor,r);else return{...r,props:{...r.props,url:n.props.url}}})}getDefaultProps(){return{url:"",w:300,h:320,assetId:null}}component(n){const r=n.props.assetId?this.editor.getAsset(n.props.assetId):null,o=this.editor.getShapePageTransform(n).rotation(),s=aG(n);return h.jsx(Ai,{children:h.jsxs("div",{className:"tl-bookmark__container",style:{boxShadow:Bx(o)},children:[h.jsxs("div",{className:"tl-bookmark__image_container",children:[r!=null&&r.props.image?h.jsx("img",{className:"tl-bookmark__image",draggable:!1,src:r==null?void 0:r.props.image,alt:(r==null?void 0:r.props.title)||""}):h.jsx("div",{className:"tl-bookmark__placeholder"}),h.jsx(uc,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]}),h.jsxs("div",{className:"tl-bookmark__copy_container",children:[(r==null?void 0:r.props.title)&&h.jsx("h2",{className:"tl-bookmark__heading",children:Ol((r==null?void 0:r.props.title)||"",54)}),(r==null?void 0:r.props.description)&&h.jsx("p",{className:"tl-bookmark__description",children:Ol((r==null?void 0:r.props.description)||"",128)}),h.jsx("a",{className:"tl-bookmark__link",href:n.props.url||"",target:"_blank",rel:"noopener noreferrer",onPointerDown:Ut,onPointerUp:Ut,onClick:Ut,children:Ol(s,45)})]})]})})}indicator(n){return h.jsx("rect",{width:j(n.props.w),height:j(n.props.h),rx:"6",ry:"6"})}}m(Rh,"type","bookmark"),m(Rh,"props",yk),m(Rh,"migrations",Sk);const aG=e=>{try{const t=new URL(e.props.url),n=t.pathname.replace(/\/*$/,"");return`${t.hostname}${n}`}catch{return e.props.url}};function mC(e,t){const{url:n}=t.props,r=Si.createId(AS(n));e.getAsset(r)?t.props.assetId!==r&&e.updateShapes([{id:t.id,type:t.type,props:{assetId:r}}]):(e.updateShapes([{id:t.id,type:t.type,props:{assetId:null}}]),cG(e,t))}const cG=H_(async(e,t)=>{const{url:n}=t.props,r=await e.getAssetForExternalContent({type:"url",url:n});r&&e.batch(()=>{e.createAssets([r]),e.updateShapes([{id:t.id,type:t.type,props:{assetId:r.id}}])})},500);function ji(e,t=!1){const n=e.length;if(n<2)return"";let r=e[0].point,o=e[1].point;if(n===2)return`M${Ft(r)}L${Ft(o)}`;let s="";for(let i=2,a=n-1;i<a;i++)r=e[i].point,o=e[i+1].point,s+=Cn(r,o);return t?`M${Cn(e[0].point,e[1].point)}Q${Ft(e[1].point)}${Cn(e[1].point,e[2].point)}T${s}${Cn(e[n-1].point,e[0].point)}${Cn(e[0].point,e[1].point)}Z`:`M${Ft(e[0].point)}Q${Ft(e[1].point)}${Cn(e[1].point,e[2].point)}${e.length>3?"T":""}${s}L${Ft(e[n-1].point)}`}function lG(e,t={}){const{start:n={},end:r={}}=t,{cap:o=!0}=n,{cap:s=!0}=r;_t(!n.taper&&!r.taper,"cap taper not supported here"),_t(!n.easing&&!r.easing,"cap easing not supported here"),_t(o&&s,"cap must be true");const i=lo(e,t);Jf(i,t);const a=uG(i);let c="";for(const l of a)c+=hG(l,t);return c}function uG(e){if(e.length<=2)return[e];const t=[];let n=[e[0]],r=P.Sub(e[1].point,e[0].point).uni(),o,s,i,a,c;for(let l=1,u=e.length;l<u-1;l++){if(i=e[l-1],a=e[l],c=e[l+1],o=P.Sub(c.point,a.point).uni(),s=P.Dpr(r,o),r=o,s<-.8){const d={...a,point:a.input};n.push(d),t.push(Zm(n)),n=[d];continue}if(n.push(a),!(s>.7)&&(P.Dist2(i.point,a.point)+P.Dist2(a.point,c.point))/((i.radius+a.radius+c.radius)/3)**2<1.5){n.push(a),t.push(Zm(n)),n=[a];continue}}return n.push(e[e.length-1]),t.push(Zm(n)),t}function Zm(e){const t=e[0];let n;for(;e.length>2&&(n=e[1],P.Dist2(t.point,n.point)<((t.radius+n.radius)/2*.5)**2);)e.splice(1,1);const r=e[e.length-1];let o;for(;e.length>2&&(o=e[e.length-2],P.Dist2(r.point,o.point)<((r.radius+o.radius)/2*.5)**2);)e.splice(e.length-2,1);return e.length>1&&(e[0]={...e[0],vector:P.Sub(e[0].point,e[1].point).uni()},e[e.length-1]={...e[e.length-1],vector:P.Sub(e[e.length-2].point,e[e.length-1].point).uni()}),e}function dG(e,t,n){return"M "+e+" "+t+" m -"+n+", 0 a "+n+","+n+" 0 1,1 "+n*2+",0 a "+n+","+n+" 0 1,1 -"+n*2+",0"}function hG(e,t={}){if(e.length===0)return"";if(e.length===1)return dG(e[0].point.x,e[0].point.y,e[0].radius);const{left:n,right:r}=e$(e,t);r.reverse();let o=`M${Ft(n[0])}T`;for(let s=1;s<n.length;s++)o+=Cn(n[s-1],n[s]);{const s=e[e.length-1],i=s.radius,a=s.vector.clone().per().neg(),c=P.Add(s.point,P.Mul(a,i)),l=P.Add(s.point,P.Mul(a,-i));o+=`${Ft(c)}A${j(i)},${j(i)} 0 0 1 ${Ft(l)}T`}for(let s=1;s<r.length;s++)o+=Cn(r[s-1],r[s]);{const s=e[0],i=s.radius,a=s.vector.clone().per(),c=P.Add(s.point,P.Mul(a,i)),l=P.Add(s.point,P.Mul(a,-i));o+=`${Ft(c)}A${j(i)},${j(i)} 0 0 1 ${Ft(l)}Z`}return o}function du(){const e=z();return K("zoom",()=>e.getZoomLevel()<.35,[e])}const pG=e=>e*.65+w5(e*Pe/2)*.35,fG=e=>({size:1+e,thinning:.5,streamline:.62+(1+e)/8*.06,smoothing:.62,easing:nn.easeOutSine,simulatePressure:!0}),gG=e=>({size:1+e*1.2,thinning:.62,streamline:.62,smoothing:.62,simulatePressure:!1,easing:pG}),yC=e=>({size:1+e,thinning:0,streamline:.62+(1+e)/8*.06,smoothing:.62,simulatePressure:!1,easing:nn.linear});function hv({strokeWidth:e,showAsComplete:t}){return{size:1+e,thinning:0,streamline:.5,smoothing:.5,simulatePressure:!1,easing:nn.easeOutSine,last:t}}function pv(e,t,n,r){return{...r?yC(t):e.dash==="draw"?e.isPen?gG(t):fG(t):yC(t),last:e.isComplete||n}}function hu(e){const t=[];for(const n of e)if(n.type==="free"||n.points.length<2)t.push(...n.points.map(P.Cast));else{const r=Math.max(4,Math.floor(P.Dist(n.points[0],n.points[1])/16));t.push(...P.PointsBetween(n.points[0],n.points[1],r))}return t}function mG(e,t){return{draw:"none",solid:"none",dotted:`0.1 ${t*2}`,dashed:`${t*2} ${t*2}`}[e.props.dash]}class Lh extends Fr{constructor(){super(...arguments);m(this,"hideResizeHandles",n=>Qm(n));m(this,"hideRotateHandle",n=>Qm(n));m(this,"hideSelectionBoundsFg",n=>Qm(n));m(this,"onResize",(n,r)=>{const{scaleX:o,scaleY:s}=r,i=[];for(const a of n.props.segments)i.push({...a,points:a.points.map(({x:c,y:l,z:u})=>({x:Vp(o*c),y:Vp(s*l),z:u}))});return{props:{segments:i}}})}getDefaultProps(){return{segments:[],color:"black",fill:"none",dash:"draw",size:"m",isComplete:!1,isClosed:!1,isPen:!1}}getGeometry(n){const r=hu(n.props.segments),o=Mt[n.props.size];if(n.props.segments.length===1){const i=ne.FromPoints(r);if(i.width<o*2&&i.height<o*2)return new px({x:-o,y:-o,radius:o,isFilled:!0})}const s=lo(r,pv(n.props,o,!0,!0)).map(i=>i.point);return n.props.isClosed?new wt({points:s,isFilled:n.props.fill!=="none"}):new Ki({points:s})}component(n){return h.jsx(zs,{id:n.id,children:h.jsx(SC,{shape:n,forceSolid:du()})})}indicator(n){var d;const r=du(),o=Mt[n.props.size],s=hu(n.props.segments);let i=o;!r&&!n.props.isPen&&n.props.dash==="draw"&&s.length===1&&(i+=Ys(n.id)()*(o/6));const a=n.props.isComplete||((d=Wn(n.props.segments))==null?void 0:d.type)==="straight",c=pv(n.props,i,a,!0),l=lo(s,c),u=l.length>1?ji(l,n.props.isClosed):v$(s[0],i);return h.jsx("path",{d:u})}toSvg(n,r){return r.addExportDef(Fx(n.props.fill)),h.jsx(SC,{shape:n,forceSolid:!1})}getCanvasSvgDefs(){return[Nx()]}expandSelectionOutlinePx(n){const r=n.props.dash==="draw"?1.6:1;return Mt[n.props.size]*r/2}}m(Lh,"type","draw"),m(Lh,"props",xk),m(Lh,"migrations",wk);function v$(e,t){const n=(t+1)*.5;return`M ${e.x} ${e.y} m -${n}, 0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0`}function Qm(e){return e.props.segments.length===1&&e.props.segments[0].points.length<2}function SC({shape:e,forceSolid:t}){var d;const n=xt(),r=Mt[e.props.size],o=hu(e.props.segments),s=e.props.isComplete||((d=Wn(e.props.segments))==null?void 0:d.type)==="straight";let i=r;!t&&!e.props.isPen&&e.props.dash==="draw"&&o.length===1&&(i+=Ys(e.id)()*(r/6));const a=pv(e.props,i,s,t);if(!t&&e.props.dash==="draw")return h.jsxs(h.Fragment,{children:[e.props.isClosed&&e.props.fill&&o.length>1?h.jsx(Pt,{theme:n,fill:e.props.isClosed?e.props.fill:"none",color:e.props.color,d:ji(lo(o,a),e.props.isClosed)}):null,h.jsx("path",{d:lG(o,a),strokeLinecap:"round",fill:n[e.props.color].solid})]});const c=lo(o,a),l=c.length<2,u=l?v$(o[0],0):ji(c,e.props.isClosed);return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{theme:n,color:e.props.color,fill:l||e.props.isClosed?e.props.fill:"none",d:u}),h.jsx("path",{d:u,strokeLinecap:"round",fill:l?n[e.props.color].solid:"none",stroke:n[e.props.color].solid,strokeWidth:r,strokeDasharray:l?"none":mG(e,r),strokeDashoffset:"0"})]})}function yG(e,t,n={}){const{newPoint:r,handle:o,scaleX:s,scaleY:i}=t,{minWidth:a=1,maxWidth:c=1/0,minHeight:l=1,maxHeight:u=1/0}=n;let d=e.props.w*s,p=e.props.h*i;const f=new P(0,0);if(d>0){if(d<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=d-a;break}case"top":case"bottom":{f.x=(d-a)/2;break}default:f.x=0}d=a}}else if(f.x=d,d=-d,d<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=-d;break}default:f.x=-a}d=a}if(p>0){if(p<l){switch(o){case"top_left":case"top":case"top_right":{f.y=p-l;break}case"right":case"left":{f.y=(p-l)/2;break}default:f.y=0}p=l}}else if(f.y=p,p=-p,p<l){switch(o){case"top_left":case"top":case"top_right":{f.y=-p;break}default:f.y=-l}p=l}const{x:y,y:g}=f.rot(e.rotation).add(r);return{x:y,y:g,props:{w:Math.min(c,d),h:Math.min(u,p)}}}const SG=e=>Object.entries(e).filter(([t,n])=>n).map(([t])=>t).join(" ");class Fh extends Pc{constructor(){super(...arguments);m(this,"hideSelectionBoundsFg",n=>!this.canResize(n));m(this,"canEdit",()=>!0);m(this,"canResize",n=>{var r,o;return!!((o=(r=Cs(n.props.url))==null?void 0:r.definition)!=null&&o.doesResize)});m(this,"canEditInReadOnly",()=>!0);m(this,"isAspectRatioLocked",n=>{const r=Cs(n.props.url);return(r==null?void 0:r.definition.isAspectRatioLocked)??!1});m(this,"onResize",(n,r)=>{const o=this.isAspectRatioLocked(n),s=Cs(n.props.url);let i=(s==null?void 0:s.definition.minWidth)??200,a=(s==null?void 0:s.definition.minHeight)??200;if(o){const c=n.props.w/n.props.h;c>1?i*=c:a/=c}return yG(n,r,{minWidth:i,minHeight:a})})}getDefaultProps(){return{w:300,h:300,url:""}}component(n){const{w:r,h:o,url:s}=n.props,i=Vf(n.id),a=x.useMemo(()=>o$(s),[s]),c=K("is hovering",()=>{const{editingShapeId:p,hoveredShapeId:f}=this.editor.getCurrentPageState();if(p&&f!==p){const y=this.editor.getShape(p);if(y&&this.editor.isShapeOfType(y,"embed"))return!0}return!1},[]),l=this.editor.getShapePageTransform(n).rotation(),u=i||c;if((a==null?void 0:a.definition.type)==="github_gist"){const p=a.url.split("/").pop();if(!p)throw Error("No gist id!");return h.jsx(Ai,{className:"tl-embed-container",id:n.id,children:h.jsx(vG,{id:p,width:j(r),height:j(o),isInteractive:u,pageRotation:l})})}const d=SG({...a5,...(a==null?void 0:a.definition.overridePermissions)??{}});return h.jsx(Ai,{className:"tl-embed-container",id:n.id,children:a!=null&&a.definition?h.jsx("iframe",{className:"tl-embed",sandbox:d,src:a.embedUrl,width:j(r),height:j(o),draggable:!1,frameBorder:"0",referrerPolicy:"no-referrer-when-downgrade",style:{border:0,pointerEvents:u?"auto":"none",zIndex:u?"":"-1",boxShadow:Bx(l),borderRadius:(a==null?void 0:a.definition.overrideOutlineRadius)??8,background:a==null?void 0:a.definition.backgroundColor}}):null})}indicator(n){const r=x.useMemo(()=>Cs(n.props.url),[n.props.url]);return h.jsx("rect",{width:j(n.props.w),height:j(n.props.h),rx:(r==null?void 0:r.definition.overrideOutlineRadius)??8,ry:(r==null?void 0:r.definition.overrideOutlineRadius)??8})}}m(Fh,"type","embed"),m(Fh,"props",bk),m(Fh,"migrations",Pk);function vG({id:e,file:t,isInteractive:n,width:r,height:o,style:s,pageRotation:i}){return h.jsx("iframe",{className:"tl-embed",draggable:!1,width:j(r),height:j(o),frameBorder:"0",scrolling:"no",seamless:!0,referrerPolicy:"no-referrer-when-downgrade",style:{...s,pointerEvents:n?"all":"none",zIndex:n?"":"-1",boxShadow:Bx(i)},srcDoc:`
|
|
<html>
|
|
<head>
|
|
<base target="_blank">
|
|
</head>
|
|
<body>
|
|
<script src=${`https://gist.github.com/${e}.js${t?`?file=${t}`:""}`}><\/script>
|
|
<style type="text/css">
|
|
* { margin: 0px; }
|
|
table { height: 100%; background-color: red; }
|
|
.gist { background-color: none; height: 100%; }
|
|
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
|
|
</style>
|
|
</body>
|
|
</html>`})}const xG=x.forwardRef(({id:e,name:t,isEditing:n},r)=>{const o=z(),s=x.useCallback(c=>{c.key==="Enter"&&!c.nativeEvent.isComposing&&(Ut(c),c.currentTarget.blur(),o.setEditingShape(null))},[o]),i=x.useCallback(c=>{const l=o.getShape(e);if(!l)return;const u=l.props.name,d=c.currentTarget.value.trim();u!==d&&o.updateShapes([{id:e,type:"frame",props:{name:d}}],{squashing:!0})},[e,o]),a=x.useCallback(c=>{const l=o.getShape(e);if(!l)return;const u=l.props.name,d=c.currentTarget.value;u!==d&&o.updateShapes([{id:e,type:"frame",props:{name:d}}],{squashing:!0})},[e,o]);return h.jsxs("div",{className:`tl-frame-label ${n?"tl-frame-label__editing":""}`,children:[h.jsx("input",{className:"tl-frame-name-input",ref:r,style:{display:n?void 0:"none"},value:t,autoFocus:!0,onKeyDown:s,onBlur:i,onChange:a}),x$(t,"Frame")+""]})}),wG=function({id:t,name:n,width:r,height:o}){const s=z(),i=K("shape rotation",()=>Os(s.getShapePageTransform(t).rotation()),[s,t]),a=Vf(t),c=x.useRef(null),l=x.useCallback(y=>{const g=_n(y);s.getEditingShapeId()!==t&&(s.dispatch({type:"pointer",name:"pointer_down",target:"shape",shape:s.getShape(t),...g}),y.preventDefault())},[s,t]);x.useEffect(()=>{const y=c.current;y&&a&&(y.focus(),y.select(),requestAnimationFrame(()=>{document.activeElement!==y&&(y.focus(),y.select())}))},[c,a]);const d=((i+Math.PI/4)*(2/Math.PI)+4)%4,p=["top","left","bottom","right"][Math.floor(d)];let f;switch(p){case"top":f="";break;case"right":f=`translate(${j(r)}px, 0px) rotate(90deg)`;break;case"bottom":f=`translate(${j(r)}px, ${j(o)}px) rotate(180deg)`;break;case"left":f=`translate(0px, ${j(o)}px) rotate(270deg)`;break}return h.jsx("div",{className:"tl-frame-heading",style:{overflow:a?"visible":"hidden",maxWidth:`calc(var(--tl-zoom) * ${Math.ceil(p==="top"||p==="bottom"?r:o)}px + var(--space-5))`,bottom:"100%",transform:`${f} scale(var(--tl-scale)) translateX(calc(-1 * var(--space-3))`},onPointerDown:l,children:h.jsx("div",{className:"tl-frame-heading-hit-area",children:h.jsx(xG,{ref:c,id:t,name:n,isEditing:a})})})};function x$(e,t){return e.match(/^\s*$/)?t:e}class Nh extends Pc{constructor(){super(...arguments);m(this,"canBind",()=>!0);m(this,"canEdit",()=>!0);m(this,"canReceiveNewChildrenOfType",(n,r)=>!n.isLocked);m(this,"canDropShapes",(n,r)=>!n.isLocked);m(this,"onDragShapesOver",(n,r)=>{r.every(o=>o.parentId===n.id)||this.editor.reparentShapes(r,n.id)});m(this,"onDragShapesOut",(n,r)=>{const o=this.editor.getShape(n.parentId);o&&this.editor.isShapeOfType(o,"group")?this.editor.reparentShapes(r,o.id):this.editor.reparentShapes(r,this.editor.getCurrentPageId())});m(this,"onResize",(n,r)=>q2(n,r))}getDefaultProps(){return{w:160*2,h:90*2,name:""}}getGeometry(n){return new Wo({width:n.props.w,height:n.props.h,isFilled:!1})}component(n){const r=this.editor.getShapeGeometry(n).bounds,o=xt(),s=K("is creating this shape",()=>{const i=this.editor.getStateDescendant("select.resizing");if(!i||!i.getIsActive())return!1;const a=i==null?void 0:i.info;return a?a.isCreating&&this.editor.getOnlySelectedShapeId()===n.id:!1},[n.id]);return h.jsxs(h.Fragment,{children:[h.jsx(zs,{children:h.jsx("rect",{className:ue("tl-frame__body",{"tl-frame__creating":s}),width:r.width,height:r.height,fill:o.solid,stroke:o.text})}),s?null:h.jsx(wG,{id:n.id,name:n.props.name,width:r.width,height:r.height})]})}toSvg(n,r){const o=Jo({isDarkMode:r.isDarkMode}),a=((Os(this.editor.getShapePageTransform(n.id).rotation())+Math.PI/4)*(2/Math.PI)+4)%4,c=Math.floor(a);let l;switch(c){case 0:l="";break;case 3:l=`translate(${j(n.props.w)}, 0) rotate(90)`;break;case 2:l=`translate(${j(n.props.w)}, ${j(n.props.h)}) rotate(180)`;break;case 1:l=`translate(0, ${j(n.props.h)}) rotate(270)`;break;default:throw Error("labelSide out of bounds")}const u={fontSize:12,fontFamily:"Inter, sans-serif",textAlign:"start",width:n.props.w,height:32,padding:0,lineHeight:1,fontStyle:"normal",fontWeight:"normal",overflow:"truncate-ellipsis",verticalTextAlign:"middle"},d=this.editor.textMeasure.measureTextSpans(x$(n.props.name,"Frame")+"",u),p=d[0],f=Wn(d),y=f.box.w+f.box.x-p.box.x,g=dv(this.editor,d,{offsetY:-u.height-2,...u});return h.jsxs(h.Fragment,{children:[h.jsx("rect",{width:n.props.w,height:n.props.h,fill:o.solid,stroke:o.black.solid,strokeWidth:1,rx:1,ry:1}),h.jsxs("g",{transform:l,children:[h.jsx("rect",{x:-8,y:-u.height-4,width:y+16,height:u.height,fill:o.background,rx:4,ry:4}),g]})]})}indicator(n){const r=this.editor.getShapeGeometry(n).bounds;return h.jsx("rect",{width:j(r.width),height:j(r.height),className:"tl-frame-indicator"})}providesBackgroundForChildren(){return!0}}m(Nh,"type","frame"),m(Nh,"props",Ck),m(Nh,"migrations",Ik);function Xt(e){return`${j(e.x)},${j(e.y)} `}function w$(e=""){let t=0,n=0,r=0,o=0;function s(){const i=t^t<<11;return t=n,n=r,r=o,o^=(o>>>19^i^i>>>8)>>>0,o/4294967296*2}for(let i=0;i<e.length+64;i++)t^=e.charCodeAt(i)|0,s();return s}function fv(e){let t="M";const n=e.length;let r,o,s;for(let i=0,a=n;i<a;i+=3)r=e[i],o=e[i+1],s=e[i+2],t+=`${Xt(r)}L${Xt(o)}Q${Xt(s)}`;return t+=`${Xt(e[0])}`,t}function gv(e,t,n,r,o){const s=[],i=w$(e);let a=t[0],c;const l=t.length;for(let u=0,d=l*o;u<d;u++){c=P.AddXY(t[(u+1)%l],i()*n,i()*n);const p=P.Sub(c,a),f=P.Len(p),y=P.Div(p,f).mul(Math.min(f/4,r));s.push(P.Add(a,y),P.Add(c,y.neg()),c),a=c}return s}function b$(e,t,n){let r=`M ${Xt(t[0])}L`,o=`M ${Xt(t[0])}L`;const s=n/3,i=n*2,a=w$(e);let c=t[0],l,u=t[0],d;const p=t.length;for(let f=0,y=p-1;f<y;f++){l=t[f+1],d=P.AddXY(t[f+1],a()*s,a()*s);const g=P.Sub(l,c),w=P.Len(g),S=P.Div(g,w).mul(Math.min(w/4,i)),v=P.Add(c,S),b=P.Add(l,S.neg()),E=P.Sub(d,u),C=P.Len(E),I=P.Div(E,C).mul(Math.min(C/4,i)),_=P.Add(u,I),k=P.Add(d,I.neg());f===y-1?(r+=`${Xt(v)}L ${Xt(l)}`,o+=`${Xt(_)}L ${Xt(d)}`):(r+=`${Xt(v)}L ${Xt(b)}Q ${Xt(l)}`,o+=`${Xt(_)}L ${Xt(k)}Q ${Xt(d)}`,c=l,u=d)}return[r,r+o]}function vC(e,t){const n=Math.min(e,t)/2,r=Math.max(e,t)-n*2;return Math.PI*(n*2)+2*r}function bG(e,t,n){const r=Math.min(e,t)/2,o=Math.max(e,t)-r*2,i=(Math.PI*(r*2)+2*o)/n,a=e>t?[{type:"straight",start:new P(r,0),delta:new P(1,0)},{type:"arc",center:new P(e-r,r),startAngle:-Pe/2},{type:"straight",start:new P(e-r,t),delta:new P(-1,0)},{type:"arc",center:new P(r,r),startAngle:Pe/2}]:[{type:"straight",start:new P(e,r),delta:new P(0,1)},{type:"arc",center:new P(r,t-r),startAngle:0},{type:"straight",start:new P(0,t-r),delta:new P(0,-1)},{type:"arc",center:new P(r,r),startAngle:Pe}];let c=0;const l=[];for(let u=0;u<n;u++){const d=a[0];d.type==="straight"?l.push(P.Add(d.start,P.Mul(d.delta,c))):l.push($i(d.center,r,d.startAngle+c/r)),c+=i;let p=d.type==="straight"?o:Pe*r;for(;c>p;)c-=p,a.push(a.shift()),p=a[0].type==="straight"?o:Pe*r}return l}const PG=(e,t,n,r,o)=>{switch(e){case"s":return t;case"m":return n;case"l":return r;case"xl":return o}};function ng(e,t,n,r){const o=Ys(n),s=vC(e,t),i=Math.max(Math.ceil(s/PG(r,50,70,100,130)),6,Math.ceil(s/Math.min(e,t))),a=s/i*.2,c=Math.max(e-a*2,1),l=Math.max(t-a*2,1),u=(e-c)/2,d=(t-l)/2,p=vC(c,l)/i,f=bG(c,l,i).map(v=>v.addXY(u,d)),y=e<20?0:a*.3,g=t<20?0:a*.3,w=f.slice(0);for(let v=0;v<Math.floor(i/2);v++)w[v]=P.AddXY(w[v],o()*y,o()*g),w[i-v-1]=P.AddXY(w[i-v-1],o()*y,o()*g);const S=[];for(let v=0;v<w.length;v++){const b=v===w.length-1?0:v+1,E=w[v],C=w[b],I=f[v],_=f[b],k=P.Average([I,_]),$=P.Angle(I,_)-Math.PI/2,T=P.Dist(I,_),O=p-T,F=P.Dist(E,C)/T,L=(Math.max(u,d)+O)*F,B=P.Add(k,P.FromAngle($,L));B.x<0?B.x=0:B.x>e&&(B.x=e),B.y<0?B.y=0:B.y>t&&(B.y=t);const q=P$(E,C,B),Q=P.Dist(q||P.Average([E,C]),E);S.push({leftPoint:E,rightPoint:C,arcPoint:B,center:q,radius:Q})}return S}function P$(e,t,n){const r=e.x*(t.y-n.y)-e.y*(t.x-n.x)+t.x*n.y-n.x*t.y,o=(e.x*e.x+e.y*e.y)*(n.y-t.y)+(t.x*t.x+t.y*t.y)*(e.y-n.y)+(n.x*n.x+n.y*n.y)*(t.y-e.y),s=(e.x*e.x+e.y*e.y)*(t.x-n.x)+(t.x*t.x+t.y*t.y)*(n.x-e.x)+(n.x*n.x+n.y*n.y)*(e.x-t.x),i=-o/(2*r),a=-s/(2*r);return!Number.isFinite(i)||!Number.isFinite(a)?null:new P(i,a)}function CG(e,t,n,r){const o=[],s=ng(e,t,n,r);for(const{center:i,radius:a,leftPoint:c,rightPoint:l}of s)o.push(...EG(c,l,i,a,10));return o}function Ux(e,t,n,r){const o=ng(e,t,n,r);let s=`M${j(o[0].leftPoint.x)},${j(o[0].leftPoint.y)}`;for(const{leftPoint:i,rightPoint:a,radius:c,center:l}of o){if(l===null){s+=` L${j(a.x)},${j(a.y)}`;continue}const u=C$(i,a,l)?"0":"1";s+=` A${j(c)},${j(c)} 0 ${u},1 ${j(a.x)},${j(a.y)}`}return s+=" Z",s}function IG(e,t,n,r){const o=Ys(n),s=r==="s"?.5:r==="m"?.7:r==="l"?.9:1.6,i=y=>y+o()*s*2,a=ng(e,t,n,r),u=a.reduce((y,g)=>y+P.Dist2(g.leftPoint,g.rightPoint),0)/a.length>(s*15)**2?y=>new P(i(y.x),i(y.y)):y=>y;let d=`M${j(a[0].leftPoint.x)},${j(a[0].leftPoint.y)}`,p=u(a[0].leftPoint),f=`M${j(p.x)},${j(p.y)}`;for(const{leftPoint:y,center:g,rightPoint:w,radius:S,arcPoint:v}of a){if(g===null){d+=` L${j(w.x)},${j(w.y)}`;const k=u(w);f+=` L${j(k.x)},${j(k.y)}`,p=k;continue}const b=C$(y,w,g)?"0":"1";d+=` A${j(S)},${j(S)} 0 ${b},1 ${j(w.x)},${j(w.y)}`;const E=u(w),C=u(v),I=P$(p,E,C);if(!I){f+=` L${j(E.x)},${j(E.y)}`,p=E;continue}const _=Math.abs(P.Dist(I,p));f+=` A${j(_)},${j(_)} 0 ${b},1 ${j(E.x)},${j(E.y)}`,p=E}return d+f+" Z"}function EG(e,t,n,r,o){if(n===null)return[P.From(e),P.From(t)];const s=[],i=P.Angle(n,e),a=P.Angle(n,t),c=$u(i,a);for(let l=0;l<o;l++){const u=l/(o-1),d=i+c*u,p=$i(n,r,d);s.push(p)}return s}function C$(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)>0}function _G(e){return{size:1+e,thinning:.25,end:{taper:e},start:{taper:e},streamline:0,smoothing:1,simulatePressure:!1}}function kG(e,t,n,r){const o=Ys(e),s=t/2,i=n/2,a=Kp(s,i),c=[],l=Oe*o(),u=Oe+ze/2+Math.abs(o())*ze,d=Math.max(16,a/10);for(let p=0;p<d;p++){const f=p/(d-1),y=l+f*u,g=Math.cos(y),w=Math.sin(y);c.push(new P(s*g+t*.5+.05*o(),i*w+n/2+.05*o(),Math.min(1,.5+Math.abs(.5-(o()>0?nn.easeInOutSine(f):nn.easeInExpo(f)))/2)))}return lo(c,_G(r))}function TG(e,t,n,r){return ji(kG(e,t,n,r))}function mv(e,t){switch(e.geo){case"x-box":return $G(e.w,e.h,t,e.dash);case"check-box":return MG(e.w,e.h);default:return}}function $G(e,t,n,r){const o=r==="draw"?.62:0;if(r==="dashed")return[[new P(0,0),new P(e/2,t/2)],[new P(e,t),new P(e/2,t/2)],[new P(0,t),new P(e/2,t/2)],[new P(e,0),new P(e/2,t/2)]];const s=a=>Math.max(0,Math.min(e,a)),i=a=>Math.max(0,Math.min(t,a));return[[new P(s(n*o),i(n*o)),new P(s(e-n*o),i(t-n*o))],[new P(s(n*o),i(t-n*o)),new P(s(e-n*o),i(n*o))]]}function MG(e,t){const n=Math.min(e,t)*.82,r=(e-n)/2,o=(t-n)/2,s=a=>Math.max(0,Math.min(e,a)),i=a=>Math.max(0,Math.min(t,a));return[[new P(s(r+n*.25),i(o+n*.52)),new P(s(r+n*.45),i(o+n*.82))],[new P(s(r+n*.45),i(o+n*.82)),new P(s(r+n*.82),i(o+n*.22))]]}const AG=x.memo(function({dash:t,fill:n,color:r,strokeWidth:o,w:s,h:i,id:a,size:c}){const l=xt(),u=Ux(s,i,a,c),d=ng(s,i,a,c);return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{theme:l,d:u,fill:n,color:r}),h.jsx("g",{strokeWidth:o,stroke:l[r].solid,fill:"none",pointerEvents:"all",children:d.map(({leftPoint:p,rightPoint:f,center:y,radius:g},w)=>{const S=y?g*Os(Os(P.Angle(y,f))-Os(P.Angle(y,p))):P.Dist(p,f),{strokeDasharray:v,strokeDashoffset:b}=Vo(S,o,{style:t,start:"outset",end:"outset"});return h.jsx("path",{d:y?`M${p.x},${p.y}A${g},${g},0,0,1,${f.x},${f.y}`:`M${p.x},${p.y}L${f.x},${f.y}`,strokeDasharray:v,strokeDashoffset:b},w)})})]})}),jG=x.memo(function({w:t,h:n,strokeWidth:r,dash:o,color:s,fill:i}){const a=xt(),c=t/2,l=n/2,u=Math.max(0,c),d=Math.max(0,l),p=Kp(u,d),{strokeDasharray:f,strokeDashoffset:y}=Vo(p<64?p*2:p,r,{style:o,snap:4,closed:!0}),g=`M${c-u},${l}a${u},${d},0,1,1,${u*2},0a${u},${d},0,1,1,-${u*2},0`;return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{theme:a,d:g,color:s,fill:i}),h.jsx("path",{d:g,strokeWidth:r,width:j(t),height:j(n),fill:"none",stroke:a[s].solid,strokeDasharray:f,strokeDashoffset:y,pointerEvents:"all"})]})});function OG(e,t){if(t>e){const r=e/2;return`
|
|
M0,${r}
|
|
a${r},${r},0,1,1,${r*2},0
|
|
L${e},${t-r}
|
|
a${r},${r},0,1,1,-${r*2},0
|
|
Z`}const n=t/2;return`
|
|
M${n},0
|
|
L${e-n},0
|
|
a${n},${n},0,1,1,0,${n*2}
|
|
L${n},${t}
|
|
a${n},${n},0,1,1,0,${-n*2}
|
|
Z`}function DG(e,t){if(e>t){const r=t/2;return Kp(r,r)+(e-r*2)*2}const n=e/2;return Kp(n,n)+(t-n*2)*2}const RG=x.memo(function({w:t,h:n,strokeWidth:r,dash:o,color:s,fill:i}){const a=xt(),c=OG(t,n),l=DG(t,n),{strokeDasharray:u,strokeDashoffset:d}=Vo(l<64?l*2:l,r,{style:o,snap:4,start:"outset",end:"outset",closed:!0});return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{theme:a,d:c,color:s,fill:i}),h.jsx("path",{d:c,strokeWidth:r,width:j(t),height:j(n),fill:"none",stroke:a[s].solid,strokeDasharray:u,strokeDashoffset:d,pointerEvents:"all"})]})}),LG=x.memo(function({dash:t,fill:n,color:r,strokeWidth:o,outline:s,lines:i}){const a=xt(),c="M"+s[0]+"L"+s.slice(1)+"Z";return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{theme:a,d:c,fill:n,color:r}),h.jsxs("g",{strokeWidth:o,stroke:a[r].solid,fill:"none",pointerEvents:"all",children:[Array.from(Array(s.length)).map((l,u)=>{const d=s[u],p=s[(u+1)%s.length],f=P.Dist(d,p),{strokeDasharray:y,strokeDashoffset:g}=Vo(f,o,{style:t,start:"outset",end:"outset"});return h.jsx("line",{x1:d.x,y1:d.y,x2:p.x,y2:p.y,strokeDasharray:y,strokeDashoffset:g},u)}),i&&i.map(([l,u],d)=>{const p=P.Dist(l,u),{strokeDasharray:f,strokeDashoffset:y}=Vo(p,o,{style:t,start:"skip",end:"outset",snap:t==="dotted"?4:void 0});return h.jsx("path",{d:`M${l.x},${l.y}L${u.x},${u.y}`,stroke:a[r].solid,strokeWidth:o,fill:"none",strokeDasharray:f,strokeDashoffset:y},`line_fg_${d}`)})]})]})}),FG=x.memo(function({fill:t,color:n,strokeWidth:r,w:o,h:s,id:i,size:a}){const c=xt(),l=IG(o,s,i,a);return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{theme:c,d:l,fill:t,color:n}),h.jsx("path",{d:l,stroke:c[n].solid,strokeWidth:r,fill:"none"})]})}),NG=x.memo(function({id:t,outline:n,lines:r,fill:o,color:s,strokeWidth:i}){const a=xt(),c=gv(t,n,i/3,i*2,2);let l=fv(c);if(r)for(const[p,f]of r)l+=`M${p.x},${p.y}L${f.x},${f.y}`;const u=gv(t,n,0,i*2,1),d=fv(u);return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{d,fill:o,color:s,theme:a}),h.jsx("path",{d:l,stroke:a[s].solid,strokeWidth:i,fill:"none"})]})}),zG=x.memo(function({fill:t,color:n,strokeWidth:r,w:o,h:s,id:i,size:a}){const c=xt(),l=Ux(o,s,i,a);return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{theme:c,d:l,fill:t,color:n}),h.jsx("path",{d:l,stroke:c[n].solid,strokeWidth:r,fill:"none"})]})}),xC=x.memo(function({w:t,h:n,strokeWidth:r,fill:o,color:s}){const i=xt(),a=t/2,c=n/2,l=Math.max(0,a),u=Math.max(0,c),d=`M${a-l},${c}a${l},${u},0,1,1,${l*2},0a${l},${u},0,1,1,-${l*2},0`;return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{d,color:s,fill:o,theme:i}),h.jsx("path",{d,stroke:i[s].solid,strokeWidth:r,fill:"none"})]})}),wC=x.memo(function({w:t,h:n,strokeWidth:r,fill:o,color:s}){const i=xt(),a=I$(t,n);return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{d:a,color:s,fill:o,theme:i}),h.jsx("path",{d:a,stroke:i[s].solid,strokeWidth:r,fill:"none"})]})});function I$(e,t){let n;if(t>e){const r=e/2;n=`
|
|
M0,${r}
|
|
a${r},${r},0,1,1,${r*2},0
|
|
L${e},${t-r}
|
|
a${r},${r},0,1,1,-${r*2},0
|
|
Z`}else{const r=t/2;n=`
|
|
M${r},0
|
|
L${e-r},0
|
|
a${r},${r},0,1,1,0,${r*2}
|
|
L${r},${t}
|
|
a${r},${r},0,1,1,0,${-r*2}
|
|
Z`}return n}const BG=x.memo(function({outline:t,lines:n,fill:r,color:o,strokeWidth:s}){const i=xt();let a="M"+t[0]+"L"+t.slice(1)+"Z";if(n)for(const[c,l]of n)a+=`M${c.x},${c.y}L${l.x},${l.y}`;return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{d:a,fill:r,color:o,theme:i}),h.jsx("path",{d:a,stroke:i[o].solid,strokeWidth:s,fill:"none"})]})});function bC({shape:e}){const t=z(),{id:n,props:r}=e,{w:o,color:s,fill:i,dash:a,growY:c,size:l}=r,u=Mt[l],d=r.h+c;switch(r.geo){case"cloud":{if(a==="solid")return h.jsx(zG,{color:s,fill:i,strokeWidth:u,w:o,h:d,id:n,size:l});if(a==="dashed"||a==="dotted")return h.jsx(AG,{color:s,fill:i,strokeWidth:u,w:o,h:d,id:n,size:l,dash:a});if(a==="draw")return h.jsx(FG,{color:s,fill:i,strokeWidth:u,w:o,h:d,id:n,size:l});break}case"ellipse":{if(a==="solid")return h.jsx(xC,{strokeWidth:u,w:o,h:d,color:s,fill:i});if(a==="dashed"||a==="dotted")return h.jsx(jG,{id:n,strokeWidth:u,w:o,h:d,dash:a,color:s,fill:i});if(a==="draw")return h.jsx(xC,{strokeWidth:u,w:o,h:d,color:s,fill:i});break}case"oval":{if(a==="solid")return h.jsx(wC,{strokeWidth:u,w:o,h:d,color:s,fill:i});if(a==="dashed"||a==="dotted")return h.jsx(RG,{id:n,strokeWidth:u,w:o,h:d,dash:a,color:s,fill:i});if(a==="draw")return h.jsx(wC,{strokeWidth:u,w:o,h:d,color:s,fill:i});break}default:{const p=t.getShapeGeometry(e),f=p instanceof Br?p.children[0].vertices:p.vertices,y=mv(e.props,u);if(a==="solid")return h.jsx(BG,{fill:i,color:s,strokeWidth:u,outline:f,lines:y});if(a==="dashed"||a==="dotted")return h.jsx(LG,{dash:a,fill:i,color:s,strokeWidth:u,outline:f,lines:y});if(a==="draw")return h.jsx(NG,{id:n,fill:i,color:s,strokeWidth:u,outline:f,lines:y})}}}const lr=17*3;class zh extends Pc{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"onEditEnd",n=>{const{id:r,type:o,props:{text:s}}=n;s.trimEnd()!==n.props.text&&this.editor.updateShapes([{id:r,type:o,props:{text:s.trimEnd()}}])});m(this,"onResize",(n,{handle:r,newPoint:o,scaleX:s,scaleY:i,initialShape:a})=>{let c=a.props.w*s,l=(a.props.h+a.props.growY)*i,u=0,d=0;if(n.props.text.trim()){let g=Math.max(Math.abs(c),lr),w=Math.max(Math.abs(l),lr);g<lr&&w===lr&&(g=lr),g===lr&&w<lr&&(w=lr);const S=Fd(this.editor,{...n,props:{...n.props,w:g,h:w}}),v=Math.max(Math.abs(c),S.w)*Math.sign(c),b=Math.max(Math.abs(l),S.h)*Math.sign(l);u=Math.abs(v)-Math.abs(c),d=Math.abs(b)-Math.abs(l),c=v,l=b}const p=new P(0,0);s<0&&(p.x+=c),(r==="left"||r==="top_left"||r==="bottom_left")&&(p.x+=s<0?u:-u),i<0&&(p.y+=l),(r==="top"||r==="top_left"||r==="top_right")&&(p.y+=i<0?d:-d);const{x:f,y}=p.rot(n.rotation).add(o);return{x:f,y,props:{w:Math.max(Math.abs(c),1),h:Math.max(Math.abs(l),1),growY:0}}});m(this,"onBeforeCreate",n=>{if(!n.props.text)return n.props.growY?{...n,props:{...n.props,growY:0}}:void 0;const r=n.props.h,o=Fd(this.editor,n).h;let s=null;if(o>r?s=o-r:n.props.growY&&(s=0),s!==null)return{...n,props:{...n.props,growY:s}}});m(this,"onBeforeUpdate",(n,r)=>{const o=n.props.text,s=r.props.text;if(o===s&&n.props.font===r.props.font&&n.props.size===r.props.size)return;if(o&&!s)return{...r,props:{...r.props,growY:0}};const i=n.props.w,a=n.props.h,c=Fd(this.editor,r),l=c.w,u=c.h;if(!o&&s&&s.length===1){let p=Math.max(i,l),f=Math.max(a,u);return n.props.w<lr&&n.props.h<lr&&(p=Math.max(p,lr),f=Math.max(f,lr),p=Math.max(p,f),f=Math.max(p,f)),{...r,props:{...r.props,w:p,h:f,growY:0}}}let d=null;if(u>a?d=u-a:n.props.growY&&(d=0),d!==null)return{...r,props:{...r.props,growY:d,w:Math.max(r.props.w,l)}};if(l>n.props.w)return{...r,props:{...r.props,w:l}}});m(this,"onDoubleClick",n=>{if(this.editor.inputs.altKey)switch(n.props.geo){case"rectangle":return{...n,props:{geo:"check-box"}};case"check-box":return{...n,props:{geo:"rectangle"}}}})}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:""}}getGeometry(n){const r=Math.max(1,n.props.w),o=Math.max(1,n.props.h+n.props.growY),s=r/2,i=o/2,a=Mt[n.props.size],c=n.props.fill!=="none";let l;switch(n.props.geo){case"cloud":{l=new wt({points:CG(r,o,n.id,n.props.size),isFilled:c});break}case"triangle":{l=new wt({points:[new P(s,0),new P(r,o),new P(0,o)],isFilled:c});break}case"diamond":{l=new wt({points:[new P(s,0),new P(r,i),new P(s,o),new P(0,i)],isFilled:c});break}case"pentagon":{l=new wt({points:lm(r,o,5),isFilled:c});break}case"hexagon":{l=new wt({points:lm(r,o,6),isFilled:c});break}case"octagon":{l=new wt({points:lm(r,o,8),isFilled:c});break}case"ellipse":{l=new Q2({width:r,height:o,isFilled:c});break}case"oval":{l=new _8({width:r,height:o,isFilled:c});break}case"star":{const v=Oe/5/2,b=Math.floor(5/4)*2,E=5*2-b,C=0,I=Math.floor(5/2)*2,_=Math.cos(-ze+b*v)*r/2,k=Math.cos(-ze+E*v)*r/2,$=Math.sin(-ze+C*v)*o/2,T=Math.sin(-ze+I*v)*o/2,O=r-Math.abs(_-k),N=o-Math.abs(T-$),F=r/2+k-(r/2-_),L=o/2+$-(o/2-T),B=1,q=(r-F)/2,Q=(o-L)/2,H=(r+O)/2,U=(o+N)/2,W=H*B/2,Z=U*B/2;l=new wt({points:Array.from(Array(5*2)).map((le,be)=>{const Me=-ze+be*v;return new P(q+(be%2?W:H)*Math.cos(Me),Q+(be%2?Z:U)*Math.sin(Me))}),isFilled:c});break}case"rhombus":{const S=Math.min(r*.38,o*.38);l=new wt({points:[new P(S,0),new P(r,0),new P(r-S,o),new P(0,o)],isFilled:c});break}case"rhombus-2":{const S=Math.min(r*.38,o*.38);l=new wt({points:[new P(0,0),new P(r-S,0),new P(r,o),new P(S,o)],isFilled:c});break}case"trapezoid":{const S=Math.min(r*.38,o*.38);l=new wt({points:[new P(S,0),new P(r-S,0),new P(r,o),new P(0,o)],isFilled:c});break}case"arrow-right":{const S=Math.min(r,o)*.38,v=o*.16;l=new wt({points:[new P(0,v),new P(r-S,v),new P(r-S,0),new P(r,o/2),new P(r-S,o),new P(r-S,o-v),new P(0,o-v)],isFilled:c});break}case"arrow-left":{const S=Math.min(r,o)*.38,v=o*.16;l=new wt({points:[new P(S,0),new P(S,v),new P(r,v),new P(r,o-v),new P(S,o-v),new P(S,o),new P(0,o/2)],isFilled:c});break}case"arrow-up":{const S=r*.16,v=Math.min(r,o)*.38;l=new wt({points:[new P(r/2,0),new P(r,v),new P(r-S,v),new P(r-S,o),new P(S,o),new P(S,v),new P(0,v)],isFilled:c});break}case"arrow-down":{const S=r*.16,v=Math.min(r,o)*.38;l=new wt({points:[new P(S,0),new P(r-S,0),new P(r-S,o-v),new P(r,o-v),new P(r/2,o),new P(0,o-v),new P(S,o-v)],isFilled:c});break}case"check-box":case"x-box":case"rectangle":{l=new Wo({width:r,height:o,isFilled:c});break}}const u=Fd(this.editor,n),d=Math.min(100,r/2),p=Math.min(r,Math.max(u.w,Math.min(d,Math.max(1,r-8)))),f=Math.min(Lo[n.props.size]*Ht.lineHeight+Tr*2,o/2),y=Math.min(o,Math.max(u.h,Math.min(f,Math.max(1,r-8)))),g=mv(n.props,a),w=g?g.map(S=>new Ki({points:S})):[];return new Br({children:[l,new Wo({x:n.props.align==="start"?0:n.props.align==="end"?r-p:(r-p)/2,y:n.props.verticalAlign==="start"?0:n.props.verticalAlign==="end"?o-y:(o-y)/2,width:p,height:y,isFilled:!0,isLabel:!0}),...w]})}getHandleSnapGeometry(n){const r=this.getGeometry(n),o=r.children[0];switch(n.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:o,points:[...o.getVertices(),r.bounds.center]};case"cloud":case"ellipse":case"oval":return{outline:o,points:[r.bounds.center]};default:qo(n.props.geo)}}component(n){const{id:r,type:o,props:s}=n,{fill:i,font:a,align:c,verticalAlign:l,size:u,text:d}=s,p=n.id===this.editor.getOnlySelectedShapeId(),f=xt(),g=this.editor.getEditingShapeId()!==null||n.props.text;return h.jsxs(h.Fragment,{children:[h.jsx(zs,{id:r,children:h.jsx(bC,{shape:n})}),g&&h.jsx(Ai,{style:{overflow:"hidden",width:n.props.w,height:n.props.h+s.growY},children:h.jsx(tg,{id:r,type:o,font:a,fontSize:Lo[u],lineHeight:Ht.lineHeight,fill:i,align:c,verticalAlign:l,text:d,isSelected:p,labelColor:f[s.labelColor].solid,wrap:!0})}),n.props.url&&h.jsx(uc,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]})}indicator(n){const{id:r,props:o}=n,{w:s,size:i}=o,a=o.h+o.growY,c=Mt[i];switch(o.geo){case"ellipse":return o.dash==="draw"?h.jsx("path",{d:TG(r,s,a,c)}):h.jsx("ellipse",{cx:s/2,cy:a/2,rx:s/2,ry:a/2});case"oval":return h.jsx("path",{d:I$(s,a)});case"cloud":return h.jsx("path",{d:Ux(s,a,r,i)});default:{const l=this.editor.getShapeGeometry(n),u=l instanceof Br?l.children[0].vertices:l.vertices;let d;if(o.dash==="draw"){const f=gv(r,u,0,c*2,1);d=fv(f)}else d="M"+u[0]+"L"+u.slice(1)+"Z";const p=mv(n.props,c);if(p)for(const[f,y]of p)d+=`M${f.x},${f.y}L${y.x},${y.y}`;return h.jsx("path",{d})}}}toSvg(n,r){const{props:o}=n;r.addExportDef(Fx(n.props.fill));let s;if(o.text){r.addExportDef(lc(n.props.font));const i=Jo(r),a=this.editor.getShapeGeometry(n).bounds;s=h.jsx(eg,{fontSize:Lo[o.size],font:o.font,align:o.align,verticalAlign:o.verticalAlign,text:o.text,labelColor:i[o.labelColor].solid,bounds:a})}return h.jsxs(h.Fragment,{children:[h.jsx(bC,{shape:n}),s]})}getCanvasSvgDefs(){return[Nx()]}}m(zh,"type","geo"),m(zh,"props",Ek),m(zh,"migrations",_k);function Fd(e,t){const n=t.props.text;if(!n)return{w:0,h:0};const r=e.textMeasure.measureText("w",{...Ht,fontFamily:io[t.props.font],fontSize:Lo[t.props.size],maxWidth:100}),o={s:2,m:3.5,l:5,xl:10},s=e.textMeasure.measureText(n,{...Ht,fontFamily:io[t.props.font],fontSize:Lo[t.props.size],minWidth:r.w,maxWidth:Math.max(0,Math.ceil(r.w+o[t.props.size]),Math.ceil(t.props.w-Tr*2))});return{w:s.w+Tr*2,h:s.h+Tr*2}}function UG(){const[e,t]=x.useState(!1);return x.useEffect(()=>{const r=CSS.supports("color","color(display-p3 1 1 1)"),o=matchMedia("(color-gamut: p3)");t(r&&o.matches);const s=()=>t(r&&o.matches);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[]),K($t.forceSrgb)||!e?"srgb":"p3"}const PC=.35,CC=.82;class Bh extends Fr{constructor(){super(...arguments);m(this,"hideResizeHandles",n=>zd(n));m(this,"hideRotateHandle",n=>zd(n));m(this,"hideSelectionBoundsFg",n=>zd(n));m(this,"onResize",(n,r)=>{const{scaleX:o,scaleY:s}=r,i=[];for(const a of n.props.segments)i.push({...a,points:a.points.map(({x:c,y:l,z:u})=>({x:o*c,y:s*l,z:u}))});return{props:{segments:i}}})}getDefaultProps(){return{segments:[],color:"black",size:"m",isComplete:!1,isPen:!1}}getGeometry(n){const r=aa(n);if(zd(n))return new px({x:-r/2,y:-r/2,radius:r/2,isFilled:!0});const{strokePoints:o,sw:s}=E$(n,r,!0),i=hv({strokeWidth:s,showAsComplete:!0});return Jf(o,i),new wt({points:Dx(o,i),isFilled:!0})}component(n){return h.jsx(zs,{id:n.id,style:{opacity:PC},children:h.jsx(Nd,{strokeWidth:aa(n),shape:n})})}backgroundComponent(n){return h.jsx(zs,{id:n.id,style:{opacity:CC},children:h.jsx(Nd,{strokeWidth:aa(n),shape:n})})}indicator(n){var d;const r=du(),o=aa(n),s=hu(n.props.segments);let i=o;!r&&!n.props.isPen&&s.length===1&&(i+=Ys(n.id)()*(o/6));const a=n.props.isComplete||((d=Wn(n.props.segments))==null?void 0:d.type)==="straight",c=hv({strokeWidth:o,showAsComplete:a}),l=lo(s,c);let u;return l.length<2?u=KG(s[0],i):u=ji(l,!1),h.jsx("path",{d:u})}toSvg(n){return h.jsx(Nd,{strokeWidth:aa(n),shape:n,opacity:PC})}toBackgroundSvg(n){return h.jsx(Nd,{strokeWidth:aa(n),shape:n,opacity:CC})}}m(Bh,"type","highlight"),m(Bh,"props",$k),m(Bh,"migrations",Mk);function HG(e){return`M ${e.x} ${e.y} m -${.1}, 0 a ${.1},${.1} 0 1,0 ${.1*2},0 a ${.1},${.1} 0 1,0 -${.1*2},0`}function KG(e,t){const n=t/2;return`M ${e.x} ${e.y} m -${n}, 0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0`}function E$(e,t,n){var c;const r=hu(e.props.segments),o=e.props.isComplete||((c=Wn(e.props.segments))==null?void 0:c.type)==="straight";let s=t;!n&&!e.props.isPen&&r.length===1&&(s+=Ys(e.id)()*(t/6));const i=hv({strokeWidth:s,showAsComplete:o});return{strokePoints:lo(r,i),sw:s}}function WG(e,t,n){const{strokePoints:r,sw:o}=E$(e,t,n);return{solidStrokePath:r.length>1?ji(r,!1):HG(e.props.segments[0].points[0]),sw:o}}function Nd({strokeWidth:e,shape:t,opacity:n}){const r=xt(),o=du(),{solidStrokePath:s,sw:i}=WG(t,e,o),a=UG(),c=r[t.props.color].highlight[a];return h.jsx("path",{d:s,strokeLinecap:"round",fill:"none",pointerEvents:"all",stroke:c,strokeWidth:i,opacity:n})}function aa(e){return ac[e.props.size]*1.12}function zd(e){return e.props.segments.length===1&&e.props.segments[0].points.length<2}function _$(){return h.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:[h.jsx("path",{d:"M3,11 L3,3 11,3",strokeWidth:"2"}),h.jsx("path",{d:"M19,27 L27,27 L27,19",strokeWidth:"2"}),h.jsx("path",{d:"M27,3 L3,27",strokeWidth:"2"})]})}function k$(){const[e,t]=x.useState(!1);return x.useEffect(()=>{const n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=()=>{t(n.matches)};return r(),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}async function VG(e){const n=await(await fetch(e)).blob();return Ka.blobToDataUrl(n)}class Uh extends Pc{constructor(){super(...arguments);m(this,"isAspectRatioLocked",()=>!0);m(this,"canCrop",()=>!0);m(this,"onDoubleClick",n=>{const r=n.props.assetId?this.editor.getAsset(n.props.assetId):void 0;!r||!(r.props.src&&"mimeType"in r.props&&r.props.mimeType==="image/gif")||this.editor.updateShapes([{type:"image",id:n.id,props:{playing:!n.props.playing}}])});m(this,"onDoubleClickEdge",n=>{const r=n.props;if(!r||this.editor.getCroppingShapeId()!==n.id)return;const o=Ye(r.crop)||{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},s=1/(o.bottomRight.x-o.topLeft.x)*n.props.w,i=1/(o.bottomRight.y-o.topLeft.y)*n.props.h,a=new P(o.topLeft.x*s,o.topLeft.y*i).rot(n.rotation),c={id:n.id,type:n.type,x:n.x-a.x,y:n.y-a.y,props:{crop:{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},w:s,h:i}};this.editor.updateShapes([c])})}getDefaultProps(){return{w:100,h:100,assetId:null,playing:!0,url:"",crop:null}}component(n){var p,f;const r=this.editor.getCroppingShapeId()===n.id,o=k$(),[s,i]=x.useState(""),a=n.props.assetId?this.editor.getAsset(n.props.assetId):void 0,c=n.id===this.editor.getOnlySelectedShapeId();if(x.useEffect(()=>{if(a!=null&&a.props.src&&"mimeType"in a.props&&(a==null?void 0:a.props.mimeType)==="image/gif"){let y=!1;const g=a.props.src;if(!g)return;const w=new Image;return w.onload=()=>{if(y)return;const S=document.createElement("canvas");S.width=w.width,S.height=w.height;const v=S.getContext("2d");v&&(v.drawImage(w,0,0),i(S.toDataURL()))},w.crossOrigin="anonymous",w.src=g,()=>{y=!0}}},[o,a==null?void 0:a.props]),(a==null?void 0:a.type)==="bookmark")throw Error("Bookmark assets can't be rendered as images");const l=c&&r&&this.editor.isInAny("select.crop","select.cropping","select.pointing_crop_handle"),u=o&&(((p=a==null?void 0:a.props.mimeType)==null?void 0:p.includes("video"))||((f=a==null?void 0:a.props.mimeType)==null?void 0:f.includes("gif"))),d=IC(n);return a!=null&&a.props.src?h.jsxs(h.Fragment,{children:[l&&h.jsx("div",{style:d,children:h.jsx("div",{className:"tl-image",style:{opacity:.1,backgroundImage:`url(${!n.props.playing||u?s:a.props.src})`},draggable:!1})}),h.jsxs(Ai,{id:n.id,style:{overflow:"hidden",width:n.props.w,height:n.props.h},children:[h.jsxs("div",{className:"tl-image-container",style:d,children:[h.jsx("div",{className:"tl-image",style:{backgroundImage:`url(${!n.props.playing||u?s:a.props.src})`},draggable:!1}),a.props.isAnimated&&!n.props.playing&&h.jsx("div",{className:"tl-image__tg",children:"GIF"})]}),")",n.props.url&&h.jsx(uc,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]})]}):h.jsxs(Ai,{id:n.id,style:{overflow:"hidden",width:n.props.w,height:n.props.h,color:"var(--color-text-3)",backgroundColor:a?"transparent":"var(--color-low)",border:a?"none":"1px solid var(--color-low-border)"},children:[h.jsx("div",{className:"tl-image-container",style:d,children:a?null:h.jsx(_$,{})}),")","url"in n.props&&n.props.url&&h.jsx(uc,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]})}indicator(n){return this.editor.getCroppingShapeId()===n.id?null:h.jsx("rect",{width:j(n.props.w),height:j(n.props.h)})}async toSvg(n){const r=n.props.assetId?this.editor.getAsset(n.props.assetId):null;if(!r)return null;let o=(r==null?void 0:r.props.src)||"";(o.startsWith("http")||o.startsWith("/")||o.startsWith("./"))&&(o=await VG(o)||"");const s=IC(n),i=n.props.crop;if(s.transform&&i){const{transform:a,width:c,height:l}=s,u=(i.bottomRight.x-i.topLeft.x)*c,d=(i.bottomRight.y-i.topLeft.y)*l,p=[new P(0,0),new P(u,0),new P(u,d),new P(0,d)],f=`cropClipPath_${n.id.replace(":","_")}`;return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("clipPath",{id:f,children:h.jsx("polygon",{points:p.map(y=>`${y.x},${y.y}`).join(" ")})})}),h.jsx("g",{clipPath:"url(#{cropClipId})",children:h.jsx("image",{href:o,width:c,height:l,style:{transform:a}})})]})}else return h.jsx("image",{href:o,width:n.props.w,height:n.props.h})}}m(Uh,"type","image"),m(Uh,"props",Ak),m(Uh,"migrations",jk);function IC(e){const t=e.props.crop,n=t==null?void 0:t.topLeft;if(!n)return{width:e.props.w,height:e.props.h};const r=1/(t.bottomRight.x-t.topLeft.x)*e.props.w,o=1/(t.bottomRight.y-t.topLeft.y)*e.props.h,s=-n.x*r,i=-n.y*o;return{transform:`translate(${s}px, ${i}px)`,width:r,height:o}}function T$(e,t){const{start:n,end:r}=e;return t?`M${j(n.x)},${j(n.y)} L${j(r.x)},${j(r.y)} `:`${j(r.x)},${j(r.y)} `}function $$(e,t){const{a:n,b:r,c:o,d:s}=e;return P.Equals(n,s)?"":`${t?`M${j(n.x)},${j(n.y)}`:""}C${j(r.x)},${j(r.y)} ${j(o.x)},${j(o.y)} ${j(s.x)},${j(s.y)}`}function GG(e,t){let n=e.segments.reduce((r,o,s)=>r+$$(o,s===0),"");return t&&(n+="Z"),n}function YG(e,t){let n=e.segments.reduce((r,o,s)=>r+T$(o,s===0),"");return t&&(n+="Z"),n}function M$(e,t=!1){return e instanceof Ki?YG(e,t):GG(e,t)}function A$(e){return{size:e,thinning:.4,streamline:0,smoothing:.5,simulatePressure:!0,last:!0}}function j$(e,t,n){const r=t.vertices,o=A$(n);return lo(r,o)}function XG(e,t,n){const r=A$(n);return Dx(Jf(j$(e,t,n),r),r)}function qG(e,t,n){const r=XG(e,t,n);return J0(r)}function ZG(e,t,n){if(e.props.dash==="draw"){const r=j$(e,t,n);return ji(r)}return M$(t)}const QG=new zf;class Hh extends Fr{constructor(){super(...arguments);m(this,"hideResizeHandles",()=>!0);m(this,"hideRotateHandle",()=>!0);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"hideSelectionBoundsBg",()=>!0);m(this,"onResize",(n,r)=>{const{scaleX:o,scaleY:s}=r;return{props:{points:Mf(n.props.points,(i,{id:a,index:c,x:l,y:u})=>({id:a,index:c,x:l*o,y:u*s}))}}});m(this,"onHandleDrag",(n,{handle:r})=>{if(r.type==="vertex")return{...n,props:{...n.props,points:{...n.props.points,[r.id]:{id:r.id,index:r.index,x:r.x,y:r.y}}}}})}getDefaultProps(){const[n,r]=eu(2);return{dash:"draw",size:"m",color:"black",spline:"line",points:{[n]:{id:n,index:n,x:0,y:0},[r]:{id:r,index:r,x:.1,y:.1}}}}getGeometry(n){return yl(n)}getHandles(n){return QG.get(n.props,()=>{const r=yl(n),o=yv(n),s=o.map(i=>({...i,id:i.index,type:"vertex",canSnap:!0}));for(let i=0;i<o.length-1;i++){const a=kl(o[i].index,o[i+1].index),l=r.segments[i].midPoint();s.push({id:a,type:"create",index:a,x:l.x,y:l.y,canSnap:!0})}return s.sort(en)})}component(n){return h.jsx(zs,{id:n.id,children:h.jsx(EC,{shape:n})})}indicator(n){const r=Mt[n.props.size],o=yl(n),{dash:s}=n.props;let i;if(n.props.spline==="line"){const a=o.points;if(s==="solid"||s==="dotted"||s==="dashed")i="M"+a[0]+"L"+a.slice(1);else{const[c]=b$(n.id,a,r);i=c}}else i=ZG(n,o,r);return h.jsx("path",{d:i})}toSvg(n){return h.jsx(EC,{shape:n})}getHandleSnapGeometry(n){const r=yv(n);return{points:r,getSelfSnapPoints:o=>{const s=this.getHandles(n).filter(i=>i.type==="vertex").findIndex(i=>i.id===o.id);return r.filter((i,a)=>Math.abs(a-s)>1).map(P.From)},getSelfSnapOutline:o=>{const s=this.getHandles(n).filter(a=>a.type==="vertex").findIndex(a=>a.id===o.id),i=yl(n).segments.filter((a,c)=>c!==s-1&&c!==s);return i.length?new Br({children:i}):null}}}}m(Hh,"type","line"),m(Hh,"props",Ok),m(Hh,"migrations",Dk);function yv(e){return Object.values(e.props.points).sort(en)}function yl(e){const t=yv(e).map(P.From);switch(e.props.spline){case"cubic":return new E8({points:t});case"line":return new Ki({points:t})}}function EC({shape:e}){const t=xt(),n=yl(e),r=Mt[e.props.size],{dash:o,color:s}=e.props;if(e.props.spline==="line"){if(o==="solid"){const i=n.points,a="M"+i[0]+"L"+i.slice(1);return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{d:a,fill:"none",color:s,theme:t}),h.jsx("path",{d:a,stroke:t[s].solid,strokeWidth:r,fill:"none"})]})}if(o==="dashed"||o==="dotted"){const i=n.points,a="M"+i[0]+"L"+i.slice(1);return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{d:a,fill:"none",color:s,theme:t}),h.jsx("g",{stroke:t[s].solid,strokeWidth:r,children:n.segments.map((c,l)=>{const{strokeDasharray:u,strokeDashoffset:d}=Vo(c.length,r,{style:o,start:l>0?"outset":"none",end:l<n.segments.length-1?"outset":"none"});return h.jsx("path",{strokeDasharray:u,strokeDashoffset:d,d:T$(c,!0),fill:"none"},l)})})]})}if(o==="draw"){const i=n.points,[a,c]=b$(e.id,i,r);return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{d:a,fill:"none",color:s,theme:t}),h.jsx("path",{d:c,stroke:t[s].solid,strokeWidth:r,fill:"none"})]})}}if(e.props.spline==="cubic"){const i=M$(n);if(o==="solid")return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{d:i,fill:"none",color:s,theme:t}),h.jsx("path",{strokeWidth:r,stroke:t[s].solid,fill:"none",d:i})]});if(o==="dashed"||o==="dotted")return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{d:i,fill:"none",color:s,theme:t}),h.jsx("g",{stroke:t[s].solid,strokeWidth:r,children:n.segments.map((a,c)=>{const{strokeDasharray:l,strokeDashoffset:u}=Vo(a.length,r,{style:o,start:c>0?"outset":"none",end:c<n.segments.length-1?"outset":"none"});return h.jsx("path",{strokeDasharray:l,strokeDashoffset:u,d:$$(a,!0),fill:"none"},c)})})]});if(o==="draw")return h.jsxs(h.Fragment,{children:[h.jsx(Pt,{d:i,fill:"none",color:s,theme:t}),h.jsx("path",{d:qG(e,n,r),strokeWidth:1,stroke:t[s].solid,fill:t[s].solid})]})}}const O$=x.createContext(null);function JG({assetUrls:e,children:t}){return x.useEffect(()=>{for(const n of Object.values(e.icons)){const r=new Image;r.src=n,r.decode()}for(const n of Object.values(e.embedIcons)){const r=new Image;r.src=n,r.decode()}},[e]),h.jsx(O$.Provider,{value:e,children:t})}function Hx(){const e=x.useContext(O$);if(!e)throw new Error("useAssetUrls must be used within an AssetUrlsProvider");return e}const Sv={"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-json.short":"JSON","action.copy-as-json":"Copy as JSON","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-json.short":"JSON","action.export-as-json":"Export as JSON","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-json.short":"JSON","action.export-all-as-json":"Export as JSON","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.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.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-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-grid.menu":"Show grid","action.toggle-grid":"Toggle grid","action.toggle-lock":"Toggle locked","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.upload-failed":"Upload failed","assets.url.failed":"Couldn't load URL preview","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","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","menu.title":"Menu","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.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.default-project-name":"Shared Project","share-menu.copy-link":"Copy share link","share-menu.readonly-link":"Read-only","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 read-only 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 view (but not edit) 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.","status.offline":"Offline","status.online":"Online","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.title":"Help and resources","help-menu.about":"About","help-menu.discord":"Discord","help-menu.github":"GitHub","help-menu.keyboard-shortcuts":"Keyboard shortcuts","help-menu.twitter":"Twitter","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.","edit-pages-dialog.move-down":"Move down","edit-pages-dialog.move-up":"Move up","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","home-project-dialog.title":"Home project","home-project-dialog.description":"This is your local home project. It's just for you!","rename-project-dialog.title":"Rename project","rename-project-dialog.cancel":"Cancel","rename-project-dialog.rename":"Rename","home-project-dialog.ok":"Ok","style-panel.title":"Styles","style-panel.align":"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.drawing":"Drawing","tool-panel.shapes":"Shapes","tool-panel.more":"More","debug-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..."},eY=new Set(["ar","fa","he","ur","ku"]),ca={locale:"en",label:"English",messages:Sv,dir:"ltr"};async function tY(e,t){if(!(await fetch(t.translations.en)).ok)return console.warn("No main translations found."),ca;if(e==="en")return ca;const r=ou.find(a=>a.locale===e);if(!r)return console.warn(`No translation found for locale ${e}`),ca;const s=await(await fetch(t.translations[r.locale])).json();if(!s)return console.warn(`No messages found for locale ${e}`),ca;const i=[];for(const a in ca.messages)s[a]||i.push(a);return i.length>0,{locale:e,label:r.label,dir:eY.has(r.locale)?"rtl":"ltr",messages:{...ca.messages,...s}}}const D$=x.createContext({}),R$=()=>x.useContext(D$),nY=or(function({overrides:t,children:n}){const o=z().user.getLocale(),s=Hx(),[i,a]=x.useState(()=>t&&t.en?{locale:"en",label:"English",dir:"ltr",messages:{...Sv,...t.en}}:{locale:"en",label:"English",dir:"ltr",messages:Sv});return x.useEffect(()=>{let c=!1;async function l(){const u=await tY(o,s);u&&!c&&(t&&t[o]?a({...u,messages:{...u.messages,...t[o]}}):a(u))}return l(),()=>{c=!0}},[s,o,t]),h.jsx(D$.Provider,{value:i,children:n})});function $e(){const e=R$();return x.useCallback(function(n){return e.messages[n]??n},[e])}class Kh extends Fr{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"hideResizeHandles",()=>!0);m(this,"hideSelectionBoundsFg",()=>!1);m(this,"onBeforeCreate",n=>_C(this.editor,n));m(this,"onBeforeUpdate",(n,r)=>{if(!(n.props.text===r.props.text&&n.props.font===r.props.font&&n.props.size===r.props.size))return _C(this.editor,r)});m(this,"onEditEnd",n=>{const{id:r,type:o,props:{text:s}}=n;s.trimEnd()!==n.props.text&&this.editor.updateShapes([{id:r,type:o,props:{text:s.trimEnd()}}])})}getDefaultProps(){return{color:"black",size:"m",text:"",font:"draw",align:"middle",verticalAlign:"middle",growY:0,fontSizeAdjustment:0,url:""}}getGeometry(n){const r=Bd(n),{labelHeight:o,labelWidth:s}=L$(this.editor,n);return new Br({children:[new Wo({width:Te,height:r,isFilled:!0}),new Wo({x:n.props.align==="start"?0:n.props.align==="end"?Te-s:(Te-s)/2,y:n.props.verticalAlign==="start"?0:n.props.verticalAlign==="end"?r-o:(r-o)/2,width:s,height:o,isFilled:!0,isLabel:!0})]})}getHandles(n){const r=this.editor.getZoomLevel(),o=PV/r,s=Bd(n),i=this.editor.getInstanceState().isCoarsePointer;return r<.25||i?[]:r<.5?[{id:"bottom",index:"a3",type:"clone",x:Te/2,y:s+o}]:[{id:"top",index:"a1",type:"clone",x:Te/2,y:-o},{id:"right",index:"a2",type:"clone",x:Te+o,y:s/2},{id:"bottom",index:"a3",type:"clone",x:Te/2,y:s+o},{id:"left",index:"a4",type:"clone",x:-o,y:s/2}]}component(n){const{id:r,type:o,props:{color:s,font:i,size:a,align:c,text:l,verticalAlign:u,fontSizeAdjustment:d}}=n,p=sY(r),f=xt(),y=Bd(n),g=K("shape rotation",()=>{var v;return((v=this.editor.getShapePageTransform(r))==null?void 0:v.rotation())??0},[this.editor]),w=du(),S=n.id===this.editor.getOnlySelectedShapeId();return h.jsxs(h.Fragment,{children:[h.jsx("div",{id:r,className:"tl-note__container",style:{width:Te,height:y,backgroundColor:f[s].note.fill,borderBottom:w?"3px solid rgb(15, 23, 31, .2)":"none",boxShadow:w?"none":iY(n.id,g)},children:h.jsx(tg,{id:r,type:o,font:i,fontSize:d||Lo[a],lineHeight:Ht.lineHeight,align:c,verticalAlign:u,text:l,isNote:!0,isSelected:S,labelColor:f[s].note.text,wrap:!0,onKeyDown:p})}),"url"in n.props&&n.props.url&&h.jsx(uc,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]})}indicator(n){return h.jsx("rect",{rx:"1",width:j(Te),height:j(Bd(n))})}toSvg(n,r){r.addExportDef(lc(n.props.font)),n.props.text&&r.addExportDef(lc(n.props.font));const o=Jo({isDarkMode:r.isDarkMode}),s=this.editor.getShapeGeometry(n).bounds;return h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:5,y:5,rx:1,width:Te-10,height:s.h,fill:"rgba(0,0,0,.1)"}),h.jsx("rect",{rx:1,width:Te,height:s.h,fill:o[n.props.color].note.fill}),h.jsx(eg,{fontSize:n.props.fontSizeAdjustment||Lo[n.props.size],font:n.props.font,align:n.props.align,verticalAlign:n.props.verticalAlign,text:n.props.text,labelColor:o[n.props.color].note.text,bounds:s,stroke:!1})]})}}m(Kh,"type","note"),m(Kh,"props",Rk),m(Kh,"migrations",Lk);function _C(e,t){const{labelHeight:n,fontSizeAdjustment:r}=L$(e,t),o=Math.max(0,n-Te);if(o!==t.props.growY||r!==t.props.fontSizeAdjustment)return{...t,props:{...t.props,growY:o,fontSizeAdjustment:r}}}function rY(e,t){const n=t.props.text;if(!n)return{labelHeight:Lo[t.props.size]*Ht.lineHeight+Tr*2,labelWidth:100,fontSizeAdjustment:0};const r=Lo[t.props.size];let o=0,s=0,i=Te,a=Te;const c=1;do{o=Math.min(r,r-s);const l=e.textMeasure.measureText(n,{...Ht,fontFamily:io[t.props.font],fontSize:o,maxWidth:Te-Tr*2-c,disableOverflowWrapBreaking:!0});if(i=l.h+Tr*2,a=l.w+Tr*2,o<=14){const u=e.textMeasure.measureText(n,{...Ht,fontFamily:io[t.props.font],fontSize:o,maxWidth:Te-Tr*2-c});i=u.h+Tr*2,a=u.w+Tr*2;break}if(l.scrollWidth.toFixed(0)===l.w.toFixed(0))break}while(s++<50);return{labelHeight:i,labelWidth:a,fontSizeAdjustment:o}}const oY=new zf;function L$(e,t){return oY.get(t,()=>rY(e,t))}function sY(e){const t=z(),n=R$();return x.useCallback(r=>{const o=t.getShape(e);if(!o)return;const s=r.key==="Tab",i=(r.metaKey||r.ctrlKey)&&r.key==="Enter";if(s||i){r.preventDefault();const a=t.getShapePageTransform(e),c=a.rotation(),l=!!(n.dir==="rtl"||s$(o.props.text)),u=Te+vi+(i&&!r.shiftKey?o.props.growY:0),d=new P(s?r.shiftKey!=l?-1:1:0,i?r.shiftKey?-1:1:0).mul(u).add(Lx).rot(c).add(a.point()),p=p$(t,o,d,c);p&&(t.mark("editing adjacent shape"),sf(t,p,!0))}},[e,t,n.dir])}function Bd(e){return Te+e.props.growY}function iY(e,t){const n=Ys(e),r=Math.abs(n())+.5,o=Math.cos(t);return`0px ${5-r}px 5px -5px rgba(15, 23, 31, .6),
|
|
0px ${(4+r*7)*Math.max(0,o)}px ${6+r*7}px -${4+r*6}px rgba(15, 23, 31, ${(.3+r*.1).toFixed(2)}),
|
|
0px 48px 10px -10px inset rgba(15, 23, 44, ${((.022+n()*.005)*((1+o)/2)).toFixed(2)})`}function aY(e,{initialBounds:t,scaleX:n,scaleY:r,newPoint:o}){const s=Math.max(.01,Math.min(Math.abs(n),Math.abs(r))),i=new P(0,0);n<0&&(i.x=-(t.width*s)),r<0&&(i.y=-(t.height*s));const{x:a,y:c}=P.Add(o,i.rot(e.rotation));return{x:a,y:c,props:{scale:s*e.props.scale}}}const cY=new zf;class Wh extends Fr{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"isAspectRatioLocked",()=>!0);m(this,"onResize",(n,r)=>{const{initialBounds:o,initialShape:s,scaleX:i,handle:a}=r;if(r.mode==="scale_shape"||a!=="right"&&a!=="left")return{id:n.id,type:n.type,...aY(n,r)};{const c=o.width;let l=c*i;const u=new P(0,0);l=Math.max(1,Math.abs(l)),a==="left"?(u.x=c-l,i<0&&(u.x+=l)):i<0&&(u.x-=l);const{x:d,y:p}=u.rot(n.rotation).add(s);return{id:n.id,type:n.type,x:d,y:p,props:{w:l/s.props.scale,autoSize:!1}}}});m(this,"onBeforeCreate",n=>{if(!n.props.autoSize||n.props.text.trim())return;const r=this.getMinDimensions(n);return{...n,x:n.x-r.width/2,y:n.y-r.height/2}});m(this,"onEditEnd",n=>{const{id:r,type:o,props:{text:s}}=n,i=n.props.text.trimEnd();i.length===0?this.editor.deleteShapes([n.id]):i!==n.props.text&&this.editor.updateShapes([{id:r,type:o,props:{text:s.trimEnd()}}])});m(this,"onBeforeUpdate",(n,r)=>{if(!r.props.autoSize)return;const o=n.props.size!==r.props.size||n.props.align!==r.props.align||n.props.font!==r.props.font||n.props.scale!==1&&r.props.scale===1,s=n.props.text!==r.props.text;if(!o&&!s)return;const i=this.getMinDimensions(n),a=kC(this.editor,r.props),c=i.width*n.props.scale,l=i.height*n.props.scale,u=a.width*r.props.scale,d=a.height*r.props.scale;let p;switch(r.props.align){case"middle":{p=new P((u-c)/2,s?0:(d-l)/2);break}case"end":{p=new P(u-c,s?0:(d-l)/2);break}default:{if(s)break;p=new P(0,(d-l)/2);break}}if(p){p.rot(r.rotation);const{x:f,y}=r;return{...r,x:f-p.x,y:y-p.y,props:{...r.props,w:u}}}else return{...r,props:{...r.props,w:u}}});m(this,"onDoubleClickEdge",n=>{if(!n.props.autoSize)return{id:n.id,type:n.type,props:{autoSize:!0}};if(n.props.scale!==1)return{id:n.id,type:n.type,props:{scale:1}}})}getDefaultProps(){return{color:"black",size:"m",w:8,text:"",font:"draw",align:"middle",autoSize:!0,scale:1}}getMinDimensions(n){return cY.get(n.props,r=>kC(this.editor,r))}getGeometry(n){const{scale:r}=n.props,{width:o,height:s}=this.getMinDimensions(n);return new Wo({width:o*r,height:s*r,isFilled:!0,isLabel:!0})}component(n){const{id:r,props:{font:o,size:s,text:i,color:a,scale:c,align:l}}=n,{width:u,height:d}=this.getMinDimensions(n),p=n.id===this.editor.getOnlySelectedShapeId(),f=xt(),y=lY(r);return h.jsx(tg,{id:r,classNamePrefix:"tl-text-shape",type:"text",font:o,fontSize:ac[s],lineHeight:Ht.lineHeight,align:l,verticalAlign:"middle",text:i,labelColor:f[a].solid,isSelected:p,textWidth:u,textHeight:d,style:{transform:`scale(${c})`,transformOrigin:"top left"},wrap:!0,onKeyDown:y})}indicator(n){const r=this.editor.getShapeGeometry(n).bounds,o=z();return n.props.autoSize&&o.getEditingShapeId()===n.id?null:h.jsx("rect",{width:j(r.width),height:j(r.height)})}toSvg(n,r){r.addExportDef(lc(n.props.font)),n.props.text&&r.addExportDef(lc(n.props.font));const o=this.editor.getShapeGeometry(n).bounds,s=o.width/(n.props.scale??1),i=o.height/(n.props.scale??1),a=Jo(r);return h.jsx(eg,{fontSize:ac[n.props.size],font:n.props.font,align:n.props.align,verticalAlign:"middle",text:n.props.text,labelColor:a[n.props.color].solid,bounds:new ne(0,0,s,i),padding:0})}}m(Wh,"type","text"),m(Wh,"props",Fk),m(Wh,"migrations",Nk);function kC(e,t){const{font:n,text:r,autoSize:o,size:s,w:i}=t,a=o?16:Math.max(16,i),c=ac[s],l=o?null:Math.floor(Math.max(a,i)),u=e.textMeasure.measureText(r,{...Ht,fontFamily:io[n],fontSize:c,maxWidth:l});return o&&(u.w+=1),{width:Math.max(a,u.w),height:Math.max(c,u.h)}}function lY(e){const t=z();return x.useCallback(n=>{if(t.getEditingShapeId()===e)switch(n.key){case"Enter":{(n.ctrlKey||n.metaKey)&&t.complete();break}case"Tab":{Ee(n),n.shiftKey?cc.unindent(n.currentTarget):cc.indent(n.currentTarget);break}}},[t,e])}class Vh extends Pc{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"isAspectRatioLocked",()=>!0)}getDefaultProps(){return{w:100,h:100,assetId:null,time:0,playing:!0,url:""}}component(n){const{editor:r}=this,o=r.getShapeGeometry(n).bounds.w*r.getZoomLevel()>=110,s=n.props.assetId?r.getAsset(n.props.assetId):null,{time:i,playing:a}=n.props,c=Vf(n.id),l=k$(),u=x.useRef(null),d=x.useCallback(S=>{const v=S.currentTarget;v&&r.updateShapes([{type:"video",id:n.id,props:{playing:!0,time:v.currentTime}}])},[n.id,r]),p=x.useCallback(S=>{const v=S.currentTarget;v&&r.updateShapes([{type:"video",id:n.id,props:{playing:!1,time:v.currentTime}}])},[n.id,r]),f=x.useCallback(S=>{const v=S.currentTarget;v&&c&&r.updateShapes([{type:"video",id:n.id,props:{time:v.currentTime}}])},[c,n.id,r]),[y,g]=x.useState(!1),w=x.useCallback(S=>{const v=S.currentTarget;v&&(i!==v.currentTime&&(v.currentTime=i),a||v.pause(),g(!0))},[a,i]);return x.useEffect(()=>{const S=u.current;S&&(y&&!c&&i!==S.currentTime&&(S.currentTime=i),c&&document.activeElement!==S&&S.focus())},[c,y,i]),x.useEffect(()=>{if(l){const S=u.current;if(!S)return;S.pause(),S.currentTime=0}},[u,l]),h.jsxs(h.Fragment,{children:[h.jsx(Ai,{id:n.id,style:{color:"var(--color-text-3)",backgroundColor:s?"transparent":"var(--color-low)",border:s?"none":"1px solid var(--color-low-border)"},children:h.jsx("div",{className:"tl-counter-scaled",children:h.jsx("div",{className:"tl-video-container",children:s!=null&&s.props.src?h.jsx("video",{ref:u,style:c?{pointerEvents:"all"}:void 0,className:`tl-video tl-video-shape-${n.id.split(":")[1]}`,width:"100%",height:"100%",draggable:!1,playsInline:!0,autoPlay:!0,muted:!0,loop:!0,disableRemotePlayback:!0,disablePictureInPicture:!0,controls:c&&o,onPlay:d,onPause:p,onTimeUpdate:f,onLoadedData:w,hidden:!y,children:h.jsx("source",{src:s.props.src})}):h.jsx(_$,{})})})}),"url"in n.props&&n.props.url&&h.jsx(uc,{url:n.props.url,zoomLevel:r.getZoomLevel()})]})}indicator(n){return h.jsx("rect",{width:j(n.props.w),height:j(n.props.h)})}toSvg(n){return h.jsx("image",{href:uY(n.id),width:n.props.w,height:n.props.h})}}m(Vh,"type","video"),m(Vh,"props",zk),m(Vh,"migrations",Bk);function uY(e){const t=e.split(":")[1],n=document.querySelector(`.tl-video-shape-${t}`);if(n){const r=document.createElement("canvas");return r.width=n.videoWidth,r.height=n.videoHeight,r.getContext("2d").drawImage(n,0,0),r.toDataURL("image/png")}else throw new Error("Video with not found when attempting serialization.")}const Kx=[Wh,Rh,Lh,zh,Kh,Hh,Nh,Dh,Bh,Fh,Uh,Vh];function dY(e){return[e.sideEffects.registerAfterChangeHandler("instance",(t,n)=>{t.isFocused!==n.isFocused&&(n.isFocused?e.getContainer().focus():(e.complete(),e.getContainer().blur()))}),e.sideEffects.registerAfterChangeHandler("instance_page_state",(t,n)=>{if(t.croppingShapeId!==n.croppingShapeId){const r=e.isInAny("select.crop","select.pointing_crop_handle","select.cropping");!t.croppingShapeId&&n.croppingShapeId?r||e.setCurrentTool("select.crop.idle"):t.croppingShapeId&&!n.croppingShapeId&&r&&e.setCurrentTool("select.idle")}t.editingShapeId!==n.editingShapeId&&(!t.editingShapeId&&n.editingShapeId?e.isIn("select.editing_shape")||e.setCurrentTool("select.editing_shape"):t.editingShapeId&&!n.editingShapeId&&e.isIn("select.editing_shape")&&e.setCurrentTool("select.idle"))})]}class F$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"scribbleId","id");m(this,"markId","");m(this,"excludedShapeIds",new Set);m(this,"onEnter",n=>{this.markId="erase scribble begin",this.editor.mark(this.markId),this.info=n;const{originPagePoint:r}=this.editor.inputs;this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(s=>{if(this.editor.isShapeOrAncestorLocked(s))return!0;if(this.editor.isShapeOfType(s,"group")||this.editor.isShapeOfType(s,"frame")){const i=this.editor.getPointInShapeSpace(s,r);return this.editor.getShapeGeometry(s).bounds.containsPoint(i)}return!1}).map(s=>s.id));const o=this.editor.scribbles.addScribble({color:"muted-1",size:12});this.scribbleId=o.id,this.update()});m(this,"pushPointToScribble",()=>{const{x:n,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,n,r)});m(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});m(this,"onPointerMove",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()})}update(){const{editor:n,excludedShapeIds:r}=this,o=n.getErasingShapeIds(),s=n.getZoomLevel(),i=n.getCurrentPageShapes(),{inputs:{currentPagePoint:a,previousPagePoint:c}}=n;this.pushPointToScribble();const l=new Set(o),u=Ko/s;for(const d of i){if(n.isShapeOfType(d,"group"))continue;const p=n.getShapeMask(d.id);if(p&&!Zn(a,p))continue;const f=n.getShapeGeometry(d),y=n.getShapePageTransform(d);if(!f||!y)continue;const g=y.clone().invert(),w=g.applyToPoint(c),S=g.applyToPoint(a),{bounds:v}=f;v.minX-u>Math.max(w.x,S.x)||v.minY-u>Math.max(w.y,S.y)||v.maxX+u<Math.min(w.x,S.x)||v.maxY+u<Math.min(w.y,S.y)||f.hitTestLineSegment(w,S,u)&&l.add(n.getOutermostSelectableShape(d).id)}this.editor.setErasingShapes([...l].filter(d=>!r.has(d)))}complete(){const{editor:n}=this;n.deleteShapes(n.getCurrentPageState().erasingShapeIds),n.setErasingShapes([]),this.parent.transition("idle")}cancel(){const{editor:n}=this;n.setErasingShapes([]),n.bailToMark(this.markId),this.parent.transition("idle",this.info)}}m(F$,"id","erasing");var My;let hY=(My=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(My,"id","idle"),My);var Ay;let pY=(Ay=class extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{const n=this.editor.getZoomLevel(),r=this.editor.getCurrentPageShapesSorted(),{inputs:{currentPagePoint:o}}=this.editor,s=new Set,i=s.size;for(let a=r.length,c=a-1;c>=0;c--){const l=r[c];if(!(this.editor.isShapeOrAncestorLocked(l)||this.editor.isShapeOfType(l,"group"))&&this.editor.isPointInShape(l,o,{hitInside:!1,margin:Ko/n})){const u=this.editor.getOutermostSelectableShape(l);if(this.editor.isShapeOfType(u,"frame")&&s.size>i)break;s.add(u.id)}}this.editor.setErasingShapes([...s])});m(this,"onLongPress",n=>{this.startErasing(n)});m(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.startErasing(n)});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()})}startErasing(n){this.parent.transition("erasing",n)}complete(){const n=this.editor.getErasingShapeIds();n.length&&(this.editor.mark("erase end"),this.editor.deleteShapes(n)),this.editor.setErasingShapes([]),this.parent.transition("idle")}cancel(){this.editor.setErasingShapes([]),this.parent.transition("idle")}},m(Ay,"id","pointing"),Ay);class Gh extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})})}}m(Gh,"id","eraser"),m(Gh,"initial","idle"),m(Gh,"children",()=>[hY,pY,F$]);class N$ extends se{constructor(){super(...arguments);m(this,"initialCamera",new P);m(this,"onEnter",()=>{this.initialCamera=P.From(this.editor.getCamera()),this.update()});m(this,"onPointerMove",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.parent.transition("idle")});m(this,"onComplete",()=>{this.complete()})}update(){const{initialCamera:n,editor:r}=this,{currentScreenPoint:o,originScreenPoint:s}=r.inputs,i=P.Sub(o,s).div(r.getZoomLevel());i.len2()!==0&&r.setCamera(n.clone().add(i))}complete(){const{editor:n}=this,{pointerVelocity:r}=n.inputs,o=Math.min(r.len(),2);o>.1&&this.editor.slideCamera({speed:o,direction:r,friction:Sh}),this.parent.transition("idle")}}m(N$,"id","dragging");var jy;let fY=(jy=class extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.setCursor({type:"grab",rotation:0})});m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(jy,"id","idle"),jy);var Oy;let gY=(Oy=class extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.stopCameraAnimation(),this.editor.updateInstanceState({cursor:{type:"grabbing",rotation:0}},{ephemeral:!0})});m(this,"onLongPress",()=>{this.startDragging()});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startDragging()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.complete()})}startDragging(){this.parent.transition("dragging")}complete(){this.parent.transition("idle")}},m(Oy,"id","pointing"),Oy);class Yh extends se{constructor(){super(...arguments);m(this,"onDoubleClick",n=>{if(n.phase==="settle"){const{currentScreenPoint:r}=this.editor.inputs;this.editor.zoomIn(r,{duration:220,easing:nn.easeOutQuint})}});m(this,"onTripleClick",n=>{if(n.phase==="settle"){const{currentScreenPoint:r}=this.editor.inputs;this.editor.zoomOut(r,{duration:320,easing:nn.easeOutQuint})}});m(this,"onQuadrupleClick",n=>{if(n.phase==="settle"){const r=this.editor.getZoomLevel(),{inputs:{currentScreenPoint:o}}=this.editor;r===1?this.editor.zoomToFit({duration:400,easing:nn.easeOutQuint}):this.editor.resetZoom(o,{duration:320,easing:nn.easeOutQuint})}})}}m(Yh,"id","hand"),m(Yh,"initial","idle"),m(Yh,"children",()=>[fY,gY,N$]);var Dy;let mY=(Dy=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("lasering",n)})}},m(Dy,"id","idle"),Dy);class z$ extends se{constructor(){super(...arguments);m(this,"scribbleId","id");m(this,"onEnter",()=>{const n=this.editor.scribbles.addScribble({color:"laser",opacity:.7,size:4,delay:1200,shrink:.05,taper:!0});this.scribbleId=n.id,this.pushPointToScribble()});m(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});m(this,"onPointerMove",()=>{this.pushPointToScribble()});m(this,"onPointerUp",()=>{this.complete()});m(this,"pushPointToScribble",()=>{const{x:n,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,n,r)});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()})}complete(){this.parent.transition("idle")}cancel(){this.parent.transition("idle")}}m(z$,"id","lasering");class Xh extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})})}}m(Xh,"id","laser"),m(Xh,"initial","idle"),m(Xh,"children",()=>[mY,z$]);class B$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"initialSelectedShapeIds",[]);m(this,"excludedShapeIds",new Set);m(this,"isWrapMode",!1);m(this,"initialStartShape",null);m(this,"onEnter",n=>{const{altKey:r,currentPagePoint:o}=this.editor.inputs;if(this.isWrapMode=this.editor.user.getIsWrapMode(),r){this.parent.transition("scribble_brushing",n);return}this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(s=>this.editor.isShapeOfType(s,"group")||this.editor.isShapeOrAncestorLocked(s)).map(s=>s.id)),this.info=n,this.initialSelectedShapeIds=this.editor.getSelectedShapeIds().slice(),this.initialStartShape=this.editor.getShapesAtPoint(o)[0],this.hitTestShapes()});m(this,"onExit",()=>{this.initialSelectedShapeIds=[],this.editor.updateInstanceState({brush:null})});m(this,"onTick",()=>{fx(this.editor)});m(this,"onPointerMove",()=>{this.hitTestShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",n=>{this.editor.setSelectedShapes(this.initialSelectedShapeIds,{squashing:!0}),this.parent.transition("idle",n)});m(this,"onKeyDown",n=>{this.editor.inputs.altKey?this.parent.transition("scribble_brushing",n):this.hitTestShapes()});m(this,"onKeyUp",()=>{this.hitTestShapes()});m(this,"onInterrupt",()=>{this.editor.updateInstanceState({brush:null})})}complete(){this.hitTestShapes(),this.parent.transition("idle")}hitTestShapes(){const{editor:n,excludedShapeIds:r,isWrapMode:o}=this,{inputs:{originPagePoint:s,currentPagePoint:i,shiftKey:a,ctrlKey:c}}=n,l=new Set(a?this.initialSelectedShapeIds:[]),u=o?!c:c,d=ne.FromPoints([s,i]),{corners:p}=d;let f,y,g,w,S,v;const b=n.getCurrentPageShapes(),E=n.getCurrentPageId();e:for(let _=0,k=b.length;_<k;_++){if(g=b[_],r.has(g.id)||l.has(g.id)||(w=n.getShapePageBounds(g),!w))continue e;if(d.contains(w)){this.handleHit(g,i,E,l,p);continue e}if(u||n.isShapeOfType(g,"frame"))continue e;if(d.collides(w)){if(S=n.getShapePageTransform(g),!S)continue e;v=S.clone().invert().applyToPoints(p);const $=n.getShapeGeometry(g);t:for(let T=0;T<4;T++)if(f=v[T],y=v[(T+1)%4],$.hitTestLineSegment(f,y,0)){this.handleHit(g,i,E,l,p);break t}}}n.getInstanceState().isCoarsePointer;const C=n.getInstanceState().brush;(!C||!d.equals(C))&&n.updateInstanceState({brush:{...d.toJson()}});const I=n.getSelectedShapeIds();(I.length!==l.size||I.some(_=>!l.has(_)))&&n.setSelectedShapes(Array.from(l),{squashing:!0})}handleHit(n,r,o,s,i){if(n.parentId===o){s.add(n.id);return}const a=this.editor.getOutermostSelectableShape(n),c=this.editor.getShapeMask(a.id);c&&!$2(c,i)&&!Zn(r,c)||s.add(a.id)}}m(B$,"id","brushing");function Wx(e,t=!1){const n=e.getZoomLevel(),{inputs:{currentPagePoint:r}}=e;return e.getShapeAtPoint(r,{hitInside:!1,hitLabels:t,margin:Ko/n,renderingOnly:!0})??e.getSelectedShapeAtPoint(r)}function U$(e,t,n){if(!t)throw Error("Needs to translate a cropped shape!");const{crop:r}=t.props;if(!r)return;const o=e.inputs.shiftKey?Math.abs(n.x)<Math.abs(n.y)?"x":"y":null;o==="x"?n.x=0:o==="y"&&(n.y=0),n.rot(-t.rotation);const s=1/(r.bottomRight.x-r.topLeft.x)*t.props.w,i=1/(r.bottomRight.y-r.topLeft.y)*t.props.h,a=r.bottomRight.y-r.topLeft.y,c=r.bottomRight.x-r.topLeft.x,l=Ye(r);return l.topLeft.x=Math.min(1-c,Math.max(0,l.topLeft.x-n.x/s)),l.topLeft.y=Math.min(1-a,Math.max(0,l.topLeft.y-n.y/i)),l.bottomRight.x=l.topLeft.x+c,l.bottomRight.y=l.topLeft.y+a,{id:t.id,type:t.type,props:{crop:l}}}var Ry;let yY=(Ry=class extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0});const n=this.editor.getOnlySelectedShape();this.editor.on("change-history",this.cleanupCroppingState),n&&(this.editor.mark("crop"),this.editor.setCroppingShape(n.id))});m(this,"onExit",()=>{this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0}),this.editor.off("change-history",this.cleanupCroppingState)});m(this,"onCancel",()=>{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})});m(this,"onPointerDown",n=>{var r;if(!this.editor.getIsMenuOpen()){if(n.ctrlKey){this.cancel(),this.editor.root.handleEvent(n);return}switch(n.target){case"canvas":{const o=Wx(this.editor);if(o&&!this.editor.isShapeOfType(o,"group")){this.onPointerDown({...n,shape:o,target:"shape"});return}this.cancel(),this.editor.root.handleEvent(n);break}case"shape":{if(n.shape.id===this.editor.getCroppingShapeId()){this.editor.setCurrentTool("select.crop.pointing_crop",n);return}else(r=this.editor.getShapeUtil(n.shape))!=null&&r.canCrop(n.shape)?(this.editor.setCroppingShape(n.shape.id),this.editor.setSelectedShapes([n.shape.id]),this.editor.setCurrentTool("select.crop.pointing_crop",n)):(this.cancel(),this.editor.root.handleEvent(n));break}case"selection":{switch(n.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",{...n,onInteractionEnd:"select.crop"});break}case"top":case"right":case"bottom":case"left":{this.editor.setCurrentTool("select.pointing_crop_handle",{...n,onInteractionEnd:"select.crop"});break}case"top_left":case"top_right":case"bottom_left":case"bottom_right":{this.editor.setCurrentTool("select.pointing_crop_handle",{...n,onInteractionEnd:"select.crop"});break}default:this.cancel()}break}}}});m(this,"onDoubleClick",n=>{var i;if(this.editor.inputs.shiftKey||n.phase!=="up")return;const r=this.editor.getCroppingShapeId();if(!r)return;const o=this.editor.getShape(r);if(!o)return;const s=this.editor.getShapeUtil(o);s&&n.target==="selection"&&((i=s.onDoubleClickEdge)==null||i.call(s,o))});m(this,"onKeyDown",()=>{this.nudgeCroppingImage(!1)});m(this,"onKeyRepeat",()=>{this.nudgeCroppingImage(!0)});m(this,"onKeyUp",n=>{switch(n.code){case"Enter":{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{});break}}});m(this,"cleanupCroppingState",()=>{this.editor.getCroppingShapeId()||this.editor.setCurrentTool("select.idle",{})})}cancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}nudgeCroppingImage(n=!1){const{editor:{inputs:{keys:r}}}=this,o=r.has("ShiftLeft"),s=new P(0,0);if(r.has("ArrowLeft")&&(s.x+=1),r.has("ArrowRight")&&(s.x-=1),r.has("ArrowUp")&&(s.y+=1),r.has("ArrowDown")&&(s.y-=1),s.equals(new P(0,0)))return;o&&s.mul(10);const i=this.editor.getShape(this.editor.getCroppingShapeId());if(!i)return;const a=U$(this.editor,i,s);a&&(n||this.editor.mark("translate crop"),this.editor.updateShapes([a]))}},m(Ry,"id","idle"),Ry);class H$ extends se{constructor(){super(...arguments);m(this,"onCancel",()=>{this.editor.setCurrentTool("select.crop.idle",{})});m(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.editor.setCurrentTool("select.crop.translating_crop",n)});m(this,"onPointerUp",n=>{this.editor.setCurrentTool("select.crop.idle",n)})}}m(H$,"id","pointing_crop");class K$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"markId","translating crop");m(this,"snapshot",{});m(this,"onEnter",n=>{this.info=n,this.snapshot=this.createSnapshot(),this.editor.mark(this.markId),this.editor.setCursor({type:"move",rotation:0}),this.updateShapes()});m(this,"onExit",()=>{this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})});m(this,"onPointerMove",()=>{this.updateShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onKeyDown",n=>{switch(n.key){case"Alt":case"Shift":{this.updateShapes();return}}});m(this,"onKeyUp",n=>{switch(n.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 n=this.snapshot.shape;if(!n)return;const{originPagePoint:r,currentPagePoint:o}=this.editor.inputs,s=o.clone().sub(r),i=U$(this.editor,n,s);i&&this.editor.updateShapes([i],{squashing:!0})}}m(K$,"id","translating_crop");class qh extends se{}m(qh,"id","crop"),m(qh,"initial","idle"),m(qh,"children",()=>[yY,K$,H$]);const ur=8,dc={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 W$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n,this.updateCursor()});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startResizing()});m(this,"onLongPress",()=>{this.startResizing()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}updateCursor(){const n=this.editor.getSelectedShapes(),r=dc[this.info.handle];this.editor.updateInstanceState({cursor:{type:r,rotation:n.length===1?this.editor.getSelectionRotation():0}})}startResizing(){this.editor.getInstanceState().isReadonly||this.parent.transition("resizing",this.info)}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")}}m(W$,"id","pointing_resize_handle");class V$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"markId","");m(this,"snapshot",{});m(this,"onEnter",n=>{this.info=n,this.markId="cropping",this.editor.mark(this.markId),this.snapshot=this.createSnapshot(),this.updateShapes()});m(this,"onPointerMove",()=>{this.updateShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"getDefaultCrop",()=>({topLeft:{x:0,y:0},bottomRight:{x:1,y:1}}))}updateCursor(){if(!this.editor.getSelectedShapes()[0])return;const r=dc[this.info.handle];this.editor.updateInstanceState({cursor:{type:r,rotation:this.editor.getSelectionRotation()}})}updateShapes(){const{shape:n,cursorHandleOffset:r}=this.snapshot;if(!n||!this.editor.getShapeUtil("image"))return;const s=n.props,i=this.editor.inputs.currentPagePoint.clone().sub(r),a=this.editor.inputs.originPagePoint.clone().sub(r),c=i.clone().sub(a).rot(-n.rotation),l=s.crop??this.getDefaultCrop(),u=Ye(l),d=new P(n.x,n.y),p=new P(0,0),f=1/(l.bottomRight.x-l.topLeft.x)*s.w,y=1/(l.bottomRight.y-l.topLeft.y)*s.h;let g=!1;switch(this.info.handle){case"top":case"top_left":case"top_right":{if(y<ur)break;g=!0,u.topLeft.y=u.topLeft.y+c.y/y,y*(u.bottomRight.y-u.topLeft.y)<ur?(u.topLeft.y=u.bottomRight.y-ur/y,p.y=(u.topLeft.y-l.topLeft.y)*y):u.topLeft.y<=0?(u.topLeft.y=0,p.y=(u.topLeft.y-l.topLeft.y)*y):p.y=c.y;break}case"bottom":case"bottom_left":case"bottom_right":{if(y<ur)break;g=!0,u.bottomRight.y=Math.min(1,u.bottomRight.y+c.y/y),y*(u.bottomRight.y-u.topLeft.y)<ur&&(u.bottomRight.y=u.topLeft.y+ur/y);break}}switch(this.info.handle){case"left":case"top_left":case"bottom_left":{if(f<ur)break;g=!0,u.topLeft.x=u.topLeft.x+c.x/f,f*(u.bottomRight.x-u.topLeft.x)<ur?(u.topLeft.x=u.bottomRight.x-ur/f,p.x=(u.topLeft.x-l.topLeft.x)*f):u.topLeft.x<=0?(u.topLeft.x=0,p.x=(u.topLeft.x-l.topLeft.x)*f):p.x=c.x;break}case"right":case"top_right":case"bottom_right":{if(f<ur)break;g=!0,u.bottomRight.x=Math.min(1,u.bottomRight.x+c.x/f),f*(u.bottomRight.x-u.topLeft.x)<ur&&(u.bottomRight.x=u.topLeft.x+ur/f);break}}if(!g)return;d.add(p.rot(n.rotation));const w={id:n.id,type:n.type,x:d.x,y:d.y,props:{crop:u,w:(u.bottomRight.x-u.topLeft.x)*f,h:(u.bottomRight.y-u.topLeft.y)*y}};this.editor.updateShapes([w],{squashing:!0}),this.updateCursor()}complete(){this.updateShapes(),We(this.editor,[this.snapshot.shape.id]),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))}createSnapshot(){const n=this.editor.getSelectionRotation(),{inputs:{originPagePoint:r}}=this.editor,o=this.editor.getOnlySelectedShape(),s=this.editor.getSelectionRotatedPageBounds(),i=P.RotWith(s.getHandlePoint(this.info.handle),s.point,n),a=P.Sub(r,i);return{shape:o,cursorHandleOffset:a}}}m(V$,"id","cropping");class G$ extends se{constructor(){super(...arguments);m(this,"shapeId","");m(this,"initialHandle",{});m(this,"initialAdjacentHandle",null);m(this,"initialPagePoint",{});m(this,"markId","");m(this,"initialPageTransform");m(this,"initialPageRotation");m(this,"info",{});m(this,"isPrecise",!1);m(this,"isPreciseId",null);m(this,"pointingId",null);m(this,"onEnter",n=>{const{shape:r,isCreating:o,handle:s}=n;if(this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.shapeId=r.id,this.markId=o?`creating:${r.id}`:"dragging handle",o||this.editor.mark(this.markId),this.initialHandle=Ye(s),this.editor.isShapeOfType(r,"line")&&this.initialHandle.type==="create"){this.editor.updateShape({...r,props:{points:{...r.props.points,[s.index]:{id:s.index,index:s.index,x:s.x,y:s.y}}}});const l=this.editor.getShapeHandles(r).find(u=>u.index===s.index);this.initialHandle=Ye(l)}this.initialPageTransform=this.editor.getShapePageTransform(r),this.initialPageRotation=this.initialPageTransform.rotation(),this.initialPagePoint=this.editor.inputs.originPagePoint.clone(),this.editor.updateInstanceState({cursor:{type:o?"cross":"grabbing",rotation:0}},{ephemeral:!0});const i=this.editor.getShapeHandles(r).sort(en),a=i.findIndex(c=>c.id===n.handle.id);this.initialAdjacentHandle=null;for(let c=a+1;c<i.length;c++){const l=i[c];if(l.type==="vertex"&&l.id!=="middle"&&l.id!==n.handle.id){this.initialAdjacentHandle=l;break}}if(!this.initialAdjacentHandle)for(let c=i.length-1;c>=0;c--){const l=i[c];if(l.type==="vertex"&&l.id!=="middle"&&l.id!==n.handle.id){this.initialAdjacentHandle=l;break}}if(this.editor.isShapeOfType(r,"arrow")){const c=r.props[n.handle.id];this.isPrecise=!1,(c==null?void 0:c.type)==="binding"?(this.editor.setHintingShapes([c.boundShapeId]),this.isPrecise=c.isPrecise,this.isPrecise?this.isPreciseId=c.boundShapeId:this.resetExactTimeout()):this.editor.setHintingShapes([])}this.update(),this.editor.select(this.shapeId)});m(this,"exactTimeout",-1);m(this,"onPointerMove",()=>{this.update()});m(this,"onKeyDown",()=>{this.update()});m(this,"onKeyUp",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.update(),this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.setHintingShapes([]),this.editor.snaps.clearIndicators(),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})})}resetExactTimeout(){this.exactTimeout!==-1&&this.clearExactTimeout(),this.exactTimeout=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)}complete(){this.editor.snaps.clearIndicators(),We(this.editor,[this.shapeId]);const{onInteractionEnd:n}=this.info;if(this.editor.getInstanceState().isToolLocked&&n){this.editor.setCurrentTool(n,{shapeId:this.shapeId});return}this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators();const{onInteractionEnd:n}=this.info;if(n){this.editor.setCurrentTool(n,{shapeId:this.shapeId});return}this.parent.transition("idle")}update(){var _;const{editor:n,shapeId:r,initialPagePoint:o}=this,{initialHandle:s,initialPageRotation:i,initialAdjacentHandle:a}=this,c=this.editor.getHintingShapeIds(),l=this.editor.user.getIsSnapMode(),{snaps:u,inputs:{currentPagePoint:d,shiftKey:p,ctrlKey:f,altKey:y,pointerVelocity:g}}=n,w=this.info.shape,S=n.getShape(r);if(!S)return;const v=n.getShapeUtil(S);let b=d.clone().sub(o).rot(-i).add(s);if(p&&a&&s.id!=="middle"){const k=P.Angle(a,b),T=Wp(k,24)-k;b=P.RotWith(b,a,T)}n.snaps.clearIndicators();let E={...s,x:b.x,y:b.y};if(s.canSnap&&(l?!f:f)){if(!n.getShapePageTransform(S.id))throw Error("Expected a page transform");const $=u.handles.snapHandle({currentShapeId:r,handle:E});$&&($.nudge.rot(-n.getShapeParentTransform(S).rotation()),b.add($.nudge),E={...s,x:b.x,y:b.y})}const C=(_=v.onHandleDrag)==null?void 0:_.call(v,S,{handle:E,isPrecise:this.isPrecise||y,initial:w}),I={...S,...C};if(s.canBind){const k=I.props[s.id];(k==null?void 0:k.type)==="binding"?c[0]!==k.boundShapeId&&(n.setHintingShapes([k.boundShapeId]),this.pointingId=k.boundShapeId,this.isPrecise=g.len()<.5||y,this.isPreciseId=this.isPrecise?k.boundShapeId:null,this.resetExactTimeout()):c.length>0&&(n.setHintingShapes([]),this.pointingId=null,this.isPrecise=!1,this.isPreciseId=null,this.resetExactTimeout())}C&&n.updateShapes([I],{squashing:!0})}}m(G$,"id","dragging_handle");function Y$(e){return e.isLabel?[e]:e instanceof Br?e.children.filter(t=>t.isLabel):[]}class X$ extends se{constructor(){super(...arguments);m(this,"hitShapeForPointerUp",null);m(this,"onEnter",()=>{const n=this.editor.getEditingShape();if(!n)throw Error("Entered editing state without an editing shape");this.hitShapeForPointerUp=null,Ya(this.editor),this.editor.select(n)});m(this,"onExit",()=>{var s;const{editingShapeId:n}=this.editor.getCurrentPageState();if(!n)return;this.editor.setEditingShape(null);const r=this.editor.getShape(n),o=this.editor.getShapeUtil(r);(s=o.onEditEnd)==null||s.call(o,r)});m(this,"onPointerMove",n=>{if(this.hitShapeForPointerUp&&this.editor.inputs.isDragging){if(this.editor.getInstanceState().isReadonly)return;this.editor.select(this.hitShapeForPointerUp),this.parent.transition("translating",n),this.hitShapeForPointerUp=null;return}switch(n.target){case"shape":case"canvas":{Ya(this.editor);return}}});m(this,"onPointerDown",n=>{switch(this.hitShapeForPointerUp=null,n.target){case"canvas":{const r=Wx(this.editor,!0);if(r){this.onPointerDown({...n,shape:r,target:"shape"});return}break}case"shape":{const{shape:r}=n,o=this.editor.getEditingShape();if(!o)throw Error("Expected an editing shape!");const s=this.editor.getShapeUtil(r).getGeometry(r),i=Y$(s),a=i.length===1?i[0]:void 0,c=this.editor.isShapeOfType(o,"text")&&o.props.text.trim()==="";if(a&&!c){const l=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint);if(a.bounds.containsPoint(l,0)&&a.hitTestPoint(l)){if(r.id===o.id)return;this.hitShapeForPointerUp=r,this.editor.mark("editing on pointer up"),this.editor.select(r.id);return}}else{if(r.id===o.id)this.editor.isShapeOfType(r,"frame")&&this.editor.setEditingShape(null);else{this.parent.transition("pointing_shape",n);return}return}break}}this.parent.transition("idle",n),this.editor.root.handleEvent(n)});m(this,"onPointerUp",n=>{const r=this.hitShapeForPointerUp;if(!r)return;this.hitShapeForPointerUp=null;const o=this.editor.getShapeUtil(r);if(this.editor.getInstanceState().isReadonly&&!o.canEditInReadOnly(r)){this.parent.transition("pointing_shape",n);return}this.editor.select(r.id),this.editor.setEditingShape(r.id),Ya(this.editor)});m(this,"onComplete",n=>{this.parent.transition("idle",n)});m(this,"onCancel",n=>{this.parent.transition("idle",n)})}}m(X$,"id","editing_shape");function TC(e){const t=e.getOnlySelectedShape();return!!(t&&!e.isShapeOrAncestorLocked(t)&&e.getShapeUtil(t).canCrop(t))}function cf(e){const t=e.getSelectedShapeIds(),{shiftKey:n,altKey:r,currentPagePoint:o}=e.inputs,s=e.getShapeAtPoint(o,{hitInside:!1,margin:Ko/e.getZoomLevel(),hitLabels:!0,renderingOnly:!0,filter:i=>!i.isLocked});if(s){const i=e.getOutermostSelectableShape(s);if(n&&!r)e.cancelDoubleClick(),t.includes(i.id)?(e.mark("deselecting shape"),e.deselect(i)):(e.mark("shift selecting shape"),e.setSelectedShapes([...t,i.id]));else{let a;i===s||i.id===e.getFocusedGroupId()||t.includes(i.id)?a=s:a=i,a&&!t.includes(a.id)&&(e.mark("selecting shape"),e.select(a.id))}}else{if(n)return;{t.length>0&&(e.mark("selecting none"),e.selectNone());const i=e.getFocusedGroupId();if(Kn(i)){const a=e.getShape(i);e.isPointInShape(a,o,{margin:0,hitInside:!0})||e.setFocusedGroup(null)}}}}const SY=["Delete","Backspace","[","]","Enter"," ","Shift","Tab"];var Ly;let vY=(Ly=class extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.parent.setCurrentToolIdMask(void 0),Ya(this.editor),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})});m(this,"onPointerMove",()=>{Ya(this.editor)});m(this,"onPointerDown",n=>{if(this.editor.getIsMenuOpen())return;const r=n.ctrlKey&&TC(this.editor);if(n.ctrlKey&&!r){if(n.target==="shape"&&this.isDarwin&&this.editor.inputs.keys.has("ControlLeft")&&!this.editor.isShapeOrAncestorLocked(n.shape)){this.parent.transition("pointing_shape",n);return}this.parent.transition("brushing",n);return}switch(n.target){case"canvas":{const o=Wx(this.editor);if(o&&!o.isLocked){this.onPointerDown({...n,shape:o,target:"shape"});return}const s=this.editor.getSelectedShapeIds(),i=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:a}}=this.editor;if((s.length>1||i&&!this.editor.getShapeUtil(i).hideSelectionBoundsBg(i))&&$C(this.editor,a)){this.onPointerDown({...n,target:"selection"});return}this.parent.transition("pointing_canvas",n);break}case"shape":{const{shape:o}=n;if(this.isOverArrowLabelTest(o)){this.parent.transition("pointing_arrow_label",n);break}if(this.editor.isShapeOrAncestorLocked(o)){this.parent.transition("pointing_canvas",n);break}this.parent.transition("pointing_shape",n);break}case"handle":{if(this.editor.getInstanceState().isReadonly)break;this.editor.inputs.altKey?this.parent.transition("pointing_shape",n):this.parent.transition("pointing_handle",n);break}case"selection":{switch(n.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{this.parent.transition("pointing_rotate_handle",n);break}case"top":case"right":case"bottom":case"left":{r?this.parent.transition("pointing_crop_handle",n):this.parent.transition("pointing_resize_handle",n);break}case"top_left":case"top_right":case"bottom_left":case"bottom_right":{r?this.parent.transition("pointing_crop_handle",n):this.parent.transition("pointing_resize_handle",n);break}default:{const o=this.editor.getHoveredShape();if(o&&!this.editor.getSelectedShapeIds().includes(o.id)&&!o.isLocked){this.onPointerDown({...n,shape:o,target:"shape"});return}this.parent.transition("pointing_selection",n)}}break}}});m(this,"onDoubleClick",n=>{var r,o,s,i;if(!(this.editor.inputs.shiftKey||n.phase!=="up"))switch(n.target){case"canvas":{const a=this.editor.getHoveredShape(),c=a&&!this.editor.isShapeOfType(a,"group")?a:this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint)??this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{margin:Ko/this.editor.getZoomLevel(),hitInside:!1}),l=this.editor.getFocusedGroupId();if(c){if(this.editor.isShapeOfType(c,"group")){cf(this.editor);return}else{const u=this.editor.getShape(c.parentId);if(u&&this.editor.isShapeOfType(u,"group")&&!(l&&u.id===l)){cf(this.editor);return}}this.onDoubleClick({...n,shape:c,target:"shape"});return}this.editor.inputs.shiftKey||this.handleDoubleClickOnCanvas(n);break}case"selection":{if(this.editor.getInstanceState().isReadonly)break;const a=this.editor.getOnlySelectedShape();if(a){const c=this.editor.getShapeUtil(a);if(!this.canInteractWithShapeInReadOnly(a))return;if(n.handle==="right"||n.handle==="left"||n.handle==="top"||n.handle==="bottom"){const l=(r=c.onDoubleClickEdge)==null?void 0:r.call(c,a);if(l){this.editor.mark("double click edge"),this.editor.updateShapes([l]),We(this.editor,[a.id]);return}}if(c.canCrop(a)&&!this.editor.isShapeOrAncestorLocked(a)){this.parent.transition("crop",n);return}this.shouldStartEditingShape(a)&&this.startEditingShape(a,n,!0)}break}case"shape":{const{shape:a}=n,c=this.editor.getShapeUtil(a);if(a.type!=="video"&&a.type!=="embed"&&this.editor.getInstanceState().isReadonly)break;if(c.onDoubleClick){const l=(o=c.onDoubleClick)==null?void 0:o.call(c,a);if(l){this.editor.updateShapes([l]);return}else if(c.canCrop(a)&&!this.editor.isShapeOrAncestorLocked(a)){this.editor.mark("select and crop"),this.editor.select((s=n.shape)==null?void 0:s.id),this.parent.transition("crop",n);return}}this.shouldStartEditingShape(a)?this.startEditingShape(a,n,!0):this.handleDoubleClickOnCanvas(n);break}case"handle":{if(this.editor.getInstanceState().isReadonly)break;const{shape:a,handle:c}=n,l=this.editor.getShapeUtil(a),u=(i=l.onDoubleClickHandle)==null?void 0:i.call(l,a,c);u?this.editor.updateShapes([u]):this.shouldStartEditingShape(a)&&this.startEditingShape(a,n,!0)}}});m(this,"onRightClick",n=>{switch(n.target){case"canvas":{const r=this.editor.getHoveredShape(),o=r&&!this.editor.isShapeOfType(r,"group")?r:this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{margin:Ko/this.editor.getZoomLevel(),hitInside:!1,hitLabels:!0,hitFrameInside:!1,renderingOnly:!0});if(o){this.onRightClick({...n,shape:o,target:"shape"});return}const s=this.editor.getSelectedShapeIds(),i=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:a}}=this.editor;if((s.length>1||i&&!this.editor.getShapeUtil(i).hideSelectionBoundsBg(i))&&$C(this.editor,a)){this.onRightClick({...n,target:"selection"});return}this.editor.selectNone();break}case"shape":{const{selectedShapeIds:r}=this.editor.getCurrentPageState(),{shape:o}=n,s=this.editor.getOutermostSelectableShape(o,i=>!r.includes(i.id));r.includes(s.id)||(this.editor.mark("selecting shape"),this.editor.setSelectedShapes([s.id]));break}}});m(this,"onCancel",()=>{this.editor.getFocusedGroupId()!==this.editor.getCurrentPageId()&&this.editor.getSelectedShapeIds().length>0?this.editor.popFocusedGroupId():(this.editor.mark("clearing selection"),this.editor.selectNone())});m(this,"onKeyDown",n=>{switch(n.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!1);return}}if($t.editOnType.get()&&!SY.includes(n.key)&&!n.altKey&&!n.ctrlKey){const r=this.editor.getOnlySelectedShape();if(r&&this.editor.isShapeOfType(r,"note")&&this.shouldStartEditingShape(r)){this.startEditingShape(r,{...n,target:"shape",shape:r},!0);return}}});m(this,"onKeyRepeat",n=>{switch(n.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!0);break}}});m(this,"onKeyUp",n=>{switch(n.code){case"Enter":{const r=this.editor.getSelectedShapes();if(r.every(s=>this.editor.isShapeOfType(s,"group"))){this.editor.setSelectedShapes(r.flatMap(s=>this.editor.getSortedChildIdsForParent(s.id)));return}const o=this.editor.getOnlySelectedShape();if(o&&this.shouldStartEditingShape(o)){this.startEditingShape(o,{...n,target:"shape",shape:o},!0);return}TC(this.editor)&&this.parent.transition("crop",n);break}}});m(this,"isDarwin",window.navigator.userAgent.toLowerCase().indexOf("mac")>-1)}shouldStartEditingShape(n=this.editor.getOnlySelectedShape()){return!n||this.editor.isShapeOrAncestorLocked(n)&&n.type!=="embed"||!this.canInteractWithShapeInReadOnly(n)?!1:this.editor.getShapeUtil(n).canEdit(n)}startEditingShape(n,r,o){this.editor.isShapeOrAncestorLocked(n)&&n.type!=="embed"||(this.editor.mark("editing shape"),sf(this.editor,n,o),this.parent.transition("editing_shape",r))}isOverArrowLabelTest(n){if(!n)return!1;const r=this.editor.getPointInShapeSpace(n,this.editor.inputs.currentPagePoint);if(this.editor.isShapeOfType(n,"arrow")){const o=this.editor.getShapeGeometry(n).children[1];if(o&&Zn(r,o.vertices))return!0}return!1}handleDoubleClickOnCanvas(n){if(this.editor.getInstanceState().isReadonly)return;this.editor.mark("creating text shape");const r=Be(),{x:o,y:s}=this.editor.inputs.currentPagePoint;this.editor.createShapes([{id:r,type:"text",x:o,y:s,props:{text:"",autoSize:!0}}]);const i=this.editor.getShape(r);if(!i)return;const a=this.editor.getShapeUtil(i);this.editor.getInstanceState().isReadonly&&!a.canEditInReadOnly(i)||(this.editor.setEditingShape(r),this.editor.select(r),this.parent.transition("editing_shape",n))}nudgeSelectedShapes(n=!1){const{editor:{inputs:{keys:r}}}=this,o=r.has("ShiftLeft"),s=new P(0,0);if(r.has("ArrowLeft")&&(s.x-=1),r.has("ArrowRight")&&(s.x+=1),r.has("ArrowUp")&&(s.y-=1),r.has("ArrowDown")&&(s.y+=1),s.equals(new P(0,0)))return;n||this.editor.mark("nudge shapes");const{gridSize:i}=this.editor.getDocumentSettings(),a=this.editor.getInstanceState().isGridMode?o?i*bY:i:o?xY:wY,c=this.editor.getSelectedShapeIds();this.editor.nudgeShapes(c,s.mul(a)),We(this.editor,c)}canInteractWithShapeInReadOnly(n){return!!(!this.editor.getInstanceState().isReadonly||this.editor.getShapeUtil(n).canEditInReadOnly(n))}},m(Ly,"id","idle"),Ly);const xY=10,wY=1,bY=5;function $C(e,t){const n=e.getSelectionRotatedPageBounds();if(!n)return!1;const r=e.getSelectionRotation();return r?Zn(t,n.corners.map(o=>P.RotWith(o,n.point,r))):n.containsPoint(t)}class q$ extends se{constructor(){super(...arguments);m(this,"shapeId","");m(this,"markId","");m(this,"wasAlreadySelected",!1);m(this,"didDrag",!1);m(this,"info",{});m(this,"onEnter",n=>{const{shape:r}=n;this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.info=n,this.shapeId=r.id,this.didDrag=!1,this.wasAlreadySelected=this.editor.getOnlySelectedShapeId()===r.id,this.updateCursor();const s=this.editor.getShapeGeometry(r).children[1];if(!s)throw Error(`Expected to find an arrow label geometry for shape: ${r.id}`);const{currentPagePoint:i}=this.editor.inputs,a=this.editor.getPointInShapeSpace(r,i);this._labelDragOffset=P.Sub(s.center,a),this.markId="label-drag start",this.editor.mark(this.markId),this.editor.setSelectedShapes([this.shapeId])});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})});m(this,"_labelDragOffset",new P(0,0));m(this,"onPointerMove",()=>{const{isDragging:n}=this.editor.inputs;if(!n)return;const r=this.editor.getShape(this.shapeId);if(!r)return;const o=this.editor.getArrowInfo(r),s=this.editor.getShapeGeometry(r),i=s.children[0],a=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint),c=i.nearestPoint(P.Add(a,this._labelDragOffset));let l;if(o.isStraight){const u=P.Dist(o.start.point,o.end.point);l=1-P.Dist(o.end.point,c)/u}else{const{_center:u,measure:d,angleEnd:p,angleStart:f}=s.children[0];l=zS(d,f,p,u.angle(c))}isNaN(l)&&(l=.5),this.didDrag=!0,this.editor.updateShape({id:r.id,type:r.type,props:{labelPosition:l}},{squashing:!0})});m(this,"onPointerUp",()=>{const n=this.editor.getShape(this.shapeId);n&&(this.didDrag||!this.wasAlreadySelected?this.complete():(this.editor.setEditingShape(n.id),this.editor.setCurrentTool("select.editing_shape")))});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}updateCursor(){this.editor.setCursor({type:"grabbing",rotation:0})}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")}}m(q$,"id","pointing_arrow_label");class Z$ extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{const{inputs:n}=this.editor;n.shiftKey||this.editor.getSelectedShapeIds().length>0&&(this.editor.mark("selecting none"),this.editor.selectNone())});m(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.parent.transition("brushing",n)});m(this,"onPointerUp",()=>{cf(this.editor),this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.parent.transition("idle")})}complete(){this.parent.transition("idle")}}m(Z$,"id","pointing_canvas");class Q$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd);const r=this.editor.getSelectedShapes()[0];if(!r)return;const o=dc[this.info.handle];this.editor.updateInstanceState({cursor:{type:o,rotation:this.editor.getSelectionRotation()}}),this.editor.setCroppingShape(r.id)});m(this,"onExit",()=>{this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0}),this.parent.setCurrentToolIdMask(void 0)});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startCropping()});m(this,"onLongPress",()=>{this.startCropping()});m(this,"onPointerUp",()=>{this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}startCropping(){this.editor.getInstanceState().isReadonly||this.parent.transition("cropping",{...this.info,onInteractionEnd:this.info.onInteractionEnd})}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))}}m(Q$,"id","pointing_crop_handle");class J$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n;const{shape:r}=n;if(this.editor.isShapeOfType(r,"arrow")){const o=r.props[n.handle.id];(o==null?void 0:o.type)==="binding"&&this.editor.setHintingShapes([o.boundShapeId])}this.editor.updateInstanceState({cursor:{type:"grabbing",rotation:0}},{ephemeral:!0})});m(this,"onExit",()=>{this.editor.setHintingShapes([]),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})});m(this,"onPointerUp",()=>{const{shape:n,handle:r}=this.info;if(this.editor.isShapeOfType(n,"note")){const{editor:o}=this,s=MC(o,n,r,!1);if(s){sf(o,s,!0);return}}this.parent.transition("idle",this.info)});m(this,"onPointerMove",()=>{const{editor:n}=this;n.inputs.isDragging&&this.startDraggingHandle()});m(this,"onLongPress",()=>{this.startDraggingHandle()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}startDraggingHandle(){const{editor:n}=this;if(n.getInstanceState().isReadonly)return;const{shape:r,handle:o}=this.info;if(n.isShapeOfType(r,"note")){const s=MC(n,r,o,!0);if(s){const i=n.getPointInParentSpace(s,n.inputs.originPagePoint).sub(P.Rot(Lx,s.rotation));n.updateShape({...s,x:i.x,y:i.y}),n.setHoveredShape(s.id).select(s.id).setCurrentTool("select.translating",{...this.info,target:"shape",shape:n.getShape(s),onInteractionEnd:"note",isCreating:!0,onCreate:()=>{sf(n,s,!0)}});return}}this.parent.transition("dragging_handle",this.info)}cancel(){this.parent.transition("idle")}}m(J$,"id","pointing_handle");function MC(e,t,n,r){const o=e.getShapePageTransform(t.id),s=o.point(),i=o.rotation(),c=d$(s,i,t.props.growY,0)[n.index];if(c)return p$(e,t,c,i,r)}class eM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.info=n,this.updateCursor()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startRotating()});m(this,"onLongPress",()=>{this.startRotating()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}updateCursor(){this.editor.updateInstanceState({cursor:{type:dc[this.info.handle],rotation:this.editor.getSelectionRotation()}})}startRotating(){this.editor.getInstanceState().isReadonly||this.parent.transition("rotating",this.info)}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")}}m(eM,"id","pointing_rotate_handle");class tM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n});m(this,"onPointerUp",n=>{cf(this.editor),this.parent.transition("idle",n)});m(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.startTranslating(n)});m(this,"onLongPress",n=>{this.startTranslating(n)});m(this,"onDoubleClick",n=>{var s,i;const r=this.editor.getHoveredShape(),o=r&&!this.editor.isShapeOfType(r,"group")?r:this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{hitInside:!0,margin:0,renderingOnly:!0});if(o){this.parent.transition("idle"),(i=(s=this.parent).onDoubleClick)==null||i.call(s,{...n,target:"shape",shape:this.editor.getShape(o)});return}});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}startTranslating(n){this.editor.getInstanceState().isReadonly||this.parent.transition("translating",n)}cancel(){this.parent.transition("idle")}}m(tM,"id","pointing_selection");class nM extends se{constructor(){super(...arguments);m(this,"hitShape",{});m(this,"hitShapeForPointerUp",{});m(this,"isDoubleClick",!1);m(this,"didSelectOnEnter",!1);m(this,"onEnter",n=>{const r=this.editor.getSelectedShapeIds(),o=this.editor.getSelectionRotatedPageBounds(),s=this.editor.getFocusedGroupId(),{inputs:{currentPagePoint:i,shiftKey:a,altKey:c}}=this.editor;this.hitShape=n.shape,this.isDoubleClick=!1;const l=this.editor.getOutermostSelectableShape(n.shape),u=this.editor.findShapeAncestor(l,d=>r.includes(d.id));if(this.editor.getShapeUtil(n.shape).onClick||l.id===s||r.includes(l.id)||u||r.length>1&&(o!=null&&o.containsPoint(i))){this.didSelectOnEnter=!1,this.hitShapeForPointerUp=l;return}this.didSelectOnEnter=!0,a&&!c?(this.editor.cancelDoubleClick(),r.includes(l.id)||(this.editor.mark("shift selecting shape"),this.editor.setSelectedShapes([...r,l.id]))):(this.editor.mark("selecting shape"),this.editor.setSelectedShapes([l.id]))});m(this,"onPointerUp",n=>{var u;const r=this.editor.getSelectedShapeIds(),o=this.editor.getFocusedGroupId(),s=this.editor.getZoomLevel(),{inputs:{currentPagePoint:i,shiftKey:a}}=this.editor,c=this.editor.getShapeAtPoint(i,{margin:Ko/s,hitInside:!0,renderingOnly:!0})??this.hitShape,l=c?this.editor.getOutermostSelectableShape(c):this.hitShapeForPointerUp;if(l){const d=this.editor.getShapeUtil(l);if(d.onClick){const p=(u=d.onClick)==null?void 0:u.call(d,l);if(p){this.editor.mark("shape on click"),this.editor.updateShapes([p]),this.parent.transition("idle",n);return}}if(l.id===o){r.length>0?(this.editor.mark("clearing shape ids"),this.editor.setSelectedShapes([])):this.editor.popFocusedGroupId(),this.parent.transition("idle",n);return}}if(!this.didSelectOnEnter){const d=this.editor.getOutermostSelectableShape(c,p=>!r.includes(p.id));if(r.includes(d.id))if(a)this.editor.mark("deselecting on pointer up"),this.editor.deselect(l);else if(r.includes(l.id)){if(r.length===1){const p=this.editor.getShapeUtil(l).getGeometry(l),f=Y$(p),y=f.length===1?f[0]:void 0;if(y){const g=this.editor.getPointInShapeSpace(l,i);if(y.bounds.containsPoint(g,0)&&y.hitTestPoint(g)){this.editor.batch(()=>{this.editor.mark("editing on pointer up"),this.editor.select(l.id);const w=this.editor.getShapeUtil(l);this.editor.getInstanceState().isReadonly&&!w.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.mark("selecting on pointer up"),this.editor.select(l.id)}else this.editor.mark("selecting on pointer up"),this.editor.select(l);else if(a){const p=this.editor.getShapeAncestors(d);this.editor.mark("shift deselecting on pointer up"),this.editor.setSelectedShapes([...this.editor.getSelectedShapeIds().filter(f=>!p.find(y=>y.id===f)),d.id])}else this.editor.mark("selecting on pointer up"),this.editor.setSelectedShapes([d.id])}this.parent.transition("idle",n)});m(this,"onDoubleClick",()=>{this.isDoubleClick=!0});m(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.startTranslating(n)});m(this,"onLongPress",n=>{this.startTranslating(n)});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}startTranslating(n){this.editor.getInstanceState().isReadonly||(this.editor.getContainer().focus(),this.parent.transition("translating",n))}cancel(){this.parent.transition("idle")}}m(nM,"id","pointing_shape");class rM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"markId","");m(this,"didHoldCommand",!1);m(this,"creationCursorOffset",{x:0,y:0});m(this,"snapshot",{});m(this,"onEnter",n=>{const{isCreating:r=!1,creationCursorOffset:o={x:0,y:0}}=n;this.info=n,this.didHoldCommand=!1,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.creationCursorOffset=o,this.snapshot=this._createSnapshot(),r?(this.markId=`creating:${this.editor.getOnlySelectedShape().id}`,this.editor.updateInstanceState({cursor:{type:"cross",rotation:0}},{ephemeral:!0})):(this.markId="starting resizing",this.editor.mark(this.markId)),this.handleResizeStart(),this.updateShapes()});m(this,"onTick",()=>{fx(this.editor)});m(this,"onPointerMove",()=>{this.updateShapes()});m(this,"onKeyDown",()=>{this.updateShapes()});m(this,"onKeyUp",()=>{this.updateShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0}),this.editor.snaps.clearIndicators()});m(this,"_createSnapshot",()=>{const n=this.editor.getSelectedShapeIds(),r=this.editor.getSelectionRotation(),{inputs:{originPagePoint:o}}=this.editor,s=this.editor.getSelectionRotatedPageBounds(),i=P.RotWith(s.getHandlePoint(this.info.handle),s.point,r),a=P.Sub(o,i),c=new Map,l=[];n.forEach(d=>{const p=this.editor.getShape(d);if(p){if(p.type==="frame"&&l.push({id:d,children:fe(this.editor.getSortedChildIdsForParent(p).map(f=>this.editor.getShape(f)))}),c.set(p.id,this._createShapeSnapshot(p)),this.editor.isShapeOfType(p,"frame")&&n.length===1)return;this.editor.visitDescendants(p.id,f=>{const y=this.editor.getShape(f);if(y&&(c.set(y.id,this._createShapeSnapshot(y)),this.editor.isShapeOfType(y,"frame")))return!1})}});const u=![...c.values()].some(d=>!Wk(d.pageRotation,r)||d.isAspectRatioLocked);return{shapeSnapshots:c,selectionBounds:s,cursorHandleOffset:a,selectionRotation:r,selectedShapeIds:n,canShapesDeform:u,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:l}});m(this,"_createShapeSnapshot",n=>{const r=this.editor.getShapePageTransform(n),o=this.editor.getShapeUtil(n);return{shape:n,bounds:this.editor.getShapeGeometry(n).bounds,pageTransform:r,pageRotation:oe.Decompose(r).rotation,isAspectRatioLocked:o.isAspectRatioLocked(n)}})}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}complete(){var n,r;if(We(this.editor,this.snapshot.selectedShapeIds),this.handleResizeEnd(),this.info.isCreating&&this.info.onCreate){(r=(n=this.info).onCreate)==null||r.call(n,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:n}=this.snapshot,r=[];n.forEach(({shape:o})=>{var a;const s=this.editor.getShapeUtil(o),i=(a=s.onResizeStart)==null?void 0:a.call(s,o);i&&r.push(i)}),r.length>0&&this.editor.updateShapes(r)}handleResizeEnd(){const{shapeSnapshots:n}=this.snapshot,r=[];n.forEach(({shape:o})=>{var c;const s=this.editor.getShape(o.id),i=this.editor.getShapeUtil(o),a=(c=i.onResizeEnd)==null?void 0:c.call(i,o,s);a&&r.push(a)}),r.length>0&&this.editor.updateShapes(r)}updateShapes(){const{altKey:n,shiftKey:r}=this.editor.inputs,{frames:o,shapeSnapshots:s,selectionBounds:i,cursorHandleOffset:a,selectedShapeIds:c,selectionRotation:l,canShapesDeform:u}=this.snapshot,d=r||!u,{ctrlKey:p}=this.editor.inputs,f=this.editor.inputs.currentPagePoint.clone().sub(a).sub(this.creationCursorOffset),y=this.editor.inputs.originPagePoint.clone().sub(a);if(this.editor.getInstanceState().isGridMode&&!p){const{gridSize:k}=this.editor.getDocumentSettings();f.snapToGrid(k)}const g=this.info.handle,w=AC(g,Math.PI);if(this.editor.snaps.clearIndicators(),(this.editor.user.getIsSnapMode()?!p:p)&&l%ze===0){const{nudge:k}=this.editor.snaps.shapeBounds.snapResizeShapes({dragDelta:P.Sub(f,y),initialSelectionPageBounds:this.snapshot.initialSelectionPageBounds,handle:AC(g,l),isAspectRatioLocked:d,isResizingFromCenter:n});f.add(k)}const v=P.RotWith(n?i.center:i.getHandlePoint(w),i.point,l),b=P.Sub(f,v).rot(-l),E=P.Sub(y,v).rot(-l),C=P.DivV(b,E);Number.isFinite(C.x)||(C.x=1),Number.isFinite(C.y)||(C.y=1);const I=g==="top"||g==="bottom",_=g==="left"||g==="right";d?_?C.y=Math.abs(C.x):I?C.x=Math.abs(C.y):Math.abs(C.x)>Math.abs(C.y)?C.y=Math.abs(C.x)*(C.y<0?-1:1):C.x=Math.abs(C.y)*(C.x<0?-1:1):(I&&(C.x=1),_&&(C.y=1)),this.info.isCreating||this.updateCursor({dragHandle:g,isFlippedX:C.x<0,isFlippedY:C.y<0,rotation:l});for(const k of s.keys()){const $=s.get(k);this.editor.resizeShape(k,C,{initialShape:$.shape,initialBounds:$.bounds,initialPageTransform:$.pageTransform,dragHandle:g,mode:c.length===1&&k===c[0]?"resize_bounds":"scale_shape",scaleOrigin:v,scaleAxisRotation:l})}if(this.editor.inputs.ctrlKey){this.didHoldCommand=!0;for(const{id:k,children:$}of o){if(!$.length)continue;const T=s.get(k).shape,O=this.editor.getShape(k);if(!(T&&O))continue;const N=O.x-T.x,F=O.y-T.y,L=new P(N,F).rot(-T.rotation);if(L.x!==0||L.y!==0)for(const B of $)this.editor.updateShape({id:B.id,type:B.type,x:B.x-L.x,y:B.y-L.y})}}else if(this.didHoldCommand){this.didHoldCommand=!1;for(const{children:k}of o)if(k.length)for(const $ of k)this.editor.updateShape({id:$.id,type:$.type,x:$.x,y:$.y})}}updateCursor({dragHandle:n,isFlippedX:r,isFlippedY:o,rotation:s}){const i={...this.editor.getInstanceState().cursor};switch(n){case"top_left":case"bottom_right":{i.type="nwse-resize",r!==o&&(i.type="nesw-resize");break}case"top_right":case"bottom_left":{i.type="nesw-resize",r!==o&&(i.type="nwse-resize");break}}i.rotation=s,this.editor.setCursor(i)}}m(rM,"id","resizing");const Jm=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function AC(e,t){t=t%Oe;const n=Math.round(t/(Pe/4)),r=Jm.indexOf(e);return Jm[(r+n)%Jm.length]}const jC=Math.PI/180;class oM extends se{constructor(){super(...arguments);m(this,"snapshot",{});m(this,"info",{});m(this,"markId","");m(this,"onEnter",n=>{this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.markId="rotate start",this.editor.mark(this.markId);const r=j2({editor:this.editor});if(!r)return this.parent.transition("idle",this.info);this.snapshot=r;const o=this._getRotationFromPointerPosition({snapToNearestDegree:!1});wh({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"}),this.editor.updateInstanceState({cursor:{type:dc[this.info.handle],rotation:o+this.snapshot.initialSelectionRotation}})});m(this,"onExit",()=>{this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0),this.snapshot={}});m(this,"onPointerMove",()=>{this.update()});m(this,"onKeyDown",()=>{this.update()});m(this,"onKeyUp",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"update",()=>{const n=this._getRotationFromPointerPosition({snapToNearestDegree:!1});wh({editor:this.editor,delta:n,snapshot:this.snapshot,stage:"update"}),this.editor.updateInstanceState({cursor:{type:dc[this.info.handle],rotation:n+this.snapshot.initialSelectionRotation}})});m(this,"cancel",()=>{this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)});m(this,"complete",()=>{wh({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!0}),snapshot:this.snapshot,stage:"end"}),We(this.editor,this.snapshot.shapeSnapshots.map(n=>n.shape.id)),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)})}_getRotationFromPointerPosition({snapToNearestDegree:n}){const r=this.editor.getSelectionRotation(),o=this.editor.getSelectionRotatedPageBounds(),{inputs:{shiftKey:s,currentPagePoint:i}}=this.editor,{initialCursorAngle:a,initialSelectionRotation:c}=this.snapshot;if(!o)return c;const u=o.center.clone().rotWith(o.point,r).angle(i)-a;let d=c+u;if(s)d=Wp(d,24);else if(n&&(d=Math.round(d/jC)*jC,this.editor.getInstanceState().isCoarsePointer)){const p=Wp(d,4),f=yh(d,p);Math.abs(f)<b5(5)&&(d=p)}return d-c}}m(oM,"id","rotating");class sM extends se{constructor(){super(...arguments);m(this,"hits",new Set);m(this,"size",0);m(this,"scribbleId","id");m(this,"initialSelectedShapeIds",new Set);m(this,"newlySelectedShapeIds",new Set);m(this,"onEnter",()=>{this.initialSelectedShapeIds=new Set(this.editor.inputs.shiftKey?this.editor.getSelectedShapeIds():[]),this.newlySelectedShapeIds=new Set,this.size=0,this.hits.clear();const n=this.editor.scribbles.addScribble({color:"selection-stroke",opacity:.32,size:12});this.scribbleId=n.id,this.updateScribbleSelection(!0),this.editor.updateInstanceState({brush:null})});m(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});m(this,"onPointerMove",()=>{this.updateScribbleSelection(!0)});m(this,"onPointerUp",()=>{this.complete()});m(this,"onKeyDown",()=>{this.updateScribbleSelection(!1)});m(this,"onKeyUp",()=>{this.editor.inputs.altKey?this.updateScribbleSelection(!1):this.parent.transition("brushing")});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"pushPointToScribble",()=>{const{x:n,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,n,r)})}updateScribbleSelection(n){const{editor:r}=this,o=this.editor.getCurrentPageShapes(),{inputs:{shiftKey:s,originPagePoint:i,previousPagePoint:a,currentPagePoint:c}}=this.editor,{newlySelectedShapeIds:l,initialSelectedShapeIds:u}=this;n&&this.pushPointToScribble();const d=o;let p,f,y,g;const w=0;for(let b=0,E=d.length;b<E;b++){if(p=d[b],r.isShapeOfType(p,"group")||l.has(p.id)||r.isShapeOrAncestorLocked(p)||(f=r.getShapeGeometry(p),r.isShapeOfType(p,"frame")&&f.bounds.containsPoint(r.getPointInShapeSpace(p,i))))continue;const C=r.getShapePageTransform(p);if(!f||!C)continue;const I=C.clone().invert();y=I.applyToPoint(a),g=I.applyToPoint(c);const{bounds:_}=f;if(!(_.minX-w>Math.max(y.x,g.x)||_.minY-w>Math.max(y.y,g.y)||_.maxX+w<Math.min(y.x,g.x)||_.maxY+w<Math.min(y.y,g.y))&&f.hitTestLineSegment(y,g,w)){const k=this.editor.getOutermostSelectableShape(p),$=this.editor.getShapeMask(k.id);if($&&ox(a,c,$)!==null&&!Zn(c,$))continue;l.add(k.id)}}const S=r.getSelectedShapeIds(),v=new Set(s?[...l,...u]:[...l]);(S.length!==v.size||S.some(b=>!v.has(b)))&&this.editor.setSelectedShapes(Array.from(v),{squashing:!0})}complete(){this.updateScribbleSelection(!0),this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds],{squashing:!0}),this.parent.transition("idle")}}m(sM,"id","scribble_brushing");const PY=20,CY=100;class IY{constructor(t){m(this,"prevDroppingShapeId",null);m(this,"droppingNodeTimer",null);m(this,"first",!0);m(this,"dispose",()=>{this.clear()});this.editor=t,t.disposables.add(this.dispose)}updateDroppingNode(t,n){var r;this.first&&(this.editor.setHintingShapes(t.map(o=>this.editor.findShapeAncestor(o,s=>s.type!=="group")).filter(o=>o)),this.prevDroppingShapeId=((r=this.editor.getDroppingOverShape(this.editor.inputs.originPagePoint,t))==null?void 0:r.id)??null,this.first=!1),this.droppingNodeTimer===null?this.setDragTimer(t,PY,n):this.editor.inputs.pointerVelocity.len()>.5&&(clearInterval(this.droppingNodeTimer),this.setDragTimer(t,CY,n))}setDragTimer(t,n,r){this.droppingNodeTimer=setTimeout(()=>{this.editor.batch(()=>{this.handleDrag(this.editor.inputs.currentPagePoint,t,r)}),this.droppingNodeTimer=null},n)}handleDrag(t,n,r){var c,l,u,d,p;n=fe(n.map(f=>this.editor.getShape(f.id)));const o=((c=this.editor.getDroppingOverShape(t,n))==null?void 0:c.id)??null;if(o===this.prevDroppingShapeId){this.hintParents(n);return}const{prevDroppingShapeId:s}=this,i=s&&this.editor.getShape(s),a=o&&this.editor.getShape(o);i&&((u=(l=this.editor.getShapeUtil(i)).onDragShapesOut)==null||u.call(l,i,n)),a&&((p=(d=this.editor.getShapeUtil(a)).onDragShapesOver)==null||p.call(d,a,n)),this.hintParents(n),r==null||r(),this.prevDroppingShapeId=o}hintParents(t){const n=new Map;for(const o of t){const s=this.editor.findShapeAncestor(o,i=>i.type!=="group");s&&(n.has(s.id)||n.set(s.id,[]),n.get(s.id).push(o.id))}const r=[];for(const[o,s]of n){const i=this.editor.getShape(o);i&&c$(this.editor,i).length<s.length&&r.push(i.id)}this.editor.setHintingShapes(r)}dropShapes(t){var r,o;const{prevDroppingShapeId:n}=this;if(this.handleDrag(this.editor.inputs.currentPagePoint,t),n){const s=this.editor.getShape(n);if(!s)return;(o=(r=this.editor.getShapeUtil(s)).onDropShapesOver)==null||o.call(r,s,t)}}clear(){this.prevDroppingShapeId=null,this.droppingNodeTimer!==null&&clearInterval(this.droppingNodeTimer),this.droppingNodeTimer=null,this.editor.setHintingShapes([]),this.first=!0}}class iM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"selectionSnapshot",{});m(this,"snapshot",{});m(this,"markId","");m(this,"isCloning",!1);m(this,"isCreating",!1);m(this,"onCreate",()=>{});m(this,"dragAndDropManager",new IY(this.editor));m(this,"onEnter",n=>{const{isCreating:r=!1,onCreate:o=()=>{}}=n;if(this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.isCreating=r,this.onCreate=o,r?this.markId=`creating:${this.editor.getOnlySelectedShape().id}`:(this.markId="translating",this.editor.mark(this.markId)),this.isCloning=!1,this.info=n,this.editor.setCursor({type:"move",rotation:0}),this.selectionSnapshot=OC(this.editor),!this.isCreating&&this.editor.inputs.altKey){this.startCloning();return}this.snapshot=this.selectionSnapshot,this.handleStart(),this.updateShapes()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.selectionSnapshot={},this.snapshot={},this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0}),this.dragAndDropManager.clear()});m(this,"onTick",()=>{this.dragAndDropManager.updateDroppingNode(this.snapshot.movingShapes,this.updateParentTransforms),fx(this.editor)});m(this,"onPointerMove",()=>{this.updateShapes()});m(this,"onKeyDown",()=>{if(this.editor.inputs.altKey&&!this.isCloning){this.startCloning();return}this.updateShapes()});m(this,"onKeyUp",()=>{if(!this.editor.inputs.altKey&&this.isCloning){this.stopCloning();return}this.updateShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"updateParentTransforms",()=>{const{editor:n,snapshot:{shapeSnapshots:r}}=this;r.forEach(o=>{const s=n.getShape(o.shape.id);if(!s)return null;const i=bn(s.parentId)?null:oe.Inverse(n.getShapePageTransform(s.parentId));o.parentTransform=i})})}startCloning(){this.isCreating||(this.isCloning=!0,this.reset(),this.markId="translating",this.editor.mark(this.markId),this.editor.duplicateShapes(Array.from(this.editor.getSelectedShapeIds())),this.snapshot=OC(this.editor),this.handleStart(),this.updateShapes())}stopCloning(){this.isCloning=!1,this.snapshot=this.selectionSnapshot,this.reset(),this.markId="translating",this.editor.mark(this.markId),this.updateShapes()}reset(){this.editor.bailToMark(this.markId)}complete(){var n;this.updateShapes(),this.dragAndDropManager.dropShapes(this.snapshot.movingShapes),We(this.editor,this.snapshot.movingShapes.map(r=>r.id)),this.handleEnd(),this.editor.getInstanceState().isToolLocked&&this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd):this.isCreating?(n=this.onCreate)==null||n.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:n}=this.snapshot,r=[];n.forEach(o=>{var a;const s=this.editor.getShapeUtil(o),i=(a=s.onTranslateStart)==null?void 0:a.call(s,o);i&&r.push(i)}),r.length>0&&this.editor.updateShapes(r),this.editor.setHoveredShape(null)}handleEnd(){const{movingShapes:n}=this.snapshot;if(this.isCloning&&n.length>0){const o=P.Average(n.map(i=>this.editor.getShapePageTransform(i.id).point())),s=P.Sub(o,this.selectionSnapshot.averagePagePoint);P.IsNaN(s)||this.editor.updateInstanceState({duplicateProps:{shapeIds:n.map(i=>i.id),offset:{x:s.x,y:s.y}}})}const r=[];n.forEach(o=>{var c;const s=this.editor.getShape(o.id),i=this.editor.getShapeUtil(o),a=(c=i.onTranslateEnd)==null?void 0:c.call(i,o,s);a&&r.push(a)}),r.length>0&&this.editor.updateShapes(r)}handleChange(){const{movingShapes:n}=this.snapshot,r=[];n.forEach(o=>{var c;const s=this.editor.getShape(o.id),i=this.editor.getShapeUtil(o),a=(c=i.onTranslate)==null?void 0:c.call(i,o,s);a&&r.push(a)}),r.length>0&&this.editor.updateShapes(r)}updateShapes(){const{snapshot:n}=this;this.dragAndDropManager.updateDroppingNode(n.movingShapes,this.updateParentTransforms),EY({editor:this.editor,snapshot:n}),this.handleChange()}}m(iM,"id","translating");function OC(e){var d;const t=[],n=[],r=e.getSelectedShapeIds(),o=fe(r.map(p=>{const f=e.getShape(p);if(!f)return null;t.push(f);const y=e.getShapePageTransform(p),g=y.point(),w=y.rotation();n.push(g);const S=Ho.isId(f.parentId)?null:oe.Inverse(e.getShapePageTransform(f.parentId));return{shape:f,pagePoint:g,pageRotation:w,parentTransform:S}})),s=e.getOnlySelectedShape();let i=[];if(s)i=e.snaps.shapeBounds.getSnapPoints(s.id);else{const p=e.getSelectionPageBounds();p&&(i=p.cornersAndCenter.map((f,y)=>({id:"selection:"+y,x:f.x,y:f.y})))}let a,c;const{originPagePoint:l}=e.inputs,u=o.filter(p=>e.isShapeOfType(p.shape,"note")&&e.isPointInShape(p.shape,l));if(u.length!==0)if(u.length===1)c=u[0];else{const p=e.getCurrentPageShapesSorted();c=(d=u.map(f=>({snapshot:f,index:p.findIndex(y=>y.id===f.shape.id)})).sort((f,y)=>y.index-f.index)[0])==null?void 0:d.snapshot}return c&&(a=h$(e,c.pageRotation,c.shape.props.growY??0)),{averagePagePoint:P.Average(n),movingShapes:t,shapeSnapshots:o,initialPageBounds:e.getSelectionPageBounds(),initialSnapPoints:i,noteAdjacentPositions:a,noteSnapshot:c}}function EY({editor:e,snapshot:t}){const{inputs:n}=e,{noteSnapshot:r,noteAdjacentPositions:o,initialPageBounds:s,initialSnapPoints:i,shapeSnapshots:a,averagePagePoint:c}=t,l=e.getInstanceState().isGridMode,u=e.getDocumentSettings().gridSize,d=P.Sub(n.currentPagePoint,n.originPagePoint),p=e.inputs.shiftKey?Math.abs(d.x)<Math.abs(d.y)?"x":"y":null;if(p==="x"?d.x=0:p==="y"&&(d.y=0),e.snaps.clearIndicators(),(e.user.getIsSnapMode()?!n.ctrlKey:n.ctrlKey)&&e.inputs.pointerVelocity.len()<.5){const{nudge:w}=e.snaps.shapeBounds.snapTranslateShapes({dragDelta:d,initialSelectionPageBounds:s,lockedAxis:p,initialSelectionSnapPoints:i});d.add(w)}else if(r&&o){let w=u$/e.getZoomLevel(),S=new P(0,0);const v=P.Add(P.Add(r.pagePoint,d),new P(Te/2,Te/2).rot(r.pageRotation));for(const b of o){const E=P.Sub(v,b),C=E.len();C<w&&(w=C,S=E)}d.sub(S)}const y=P.Add(c,d);l&&!n.ctrlKey&&y.snapToGrid(u);const g=P.Sub(y,c);e.updateShapes(fe(a.map(({shape:w,pagePoint:S,parentTransform:v})=>{const b=P.Add(S,g),E=v?oe.applyToPoint(v,b):b;return{id:w.id,type:w.type,x:E.x,y:E.y}})),{squashing:!0})}class Zh extends se{constructor(){super(...arguments);m(this,"reactor");m(this,"cleanUpDuplicateProps",()=>{const n=this.editor.getSelectedShapeIds(),r=this.editor.getInstanceState();if(!r.duplicateProps)return;const o=new Set(r.duplicateProps.shapeIds);n.length===o.size&&n.every(s=>o.has(s))||this.editor.updateInstanceState({duplicateProps:null})});m(this,"onEnter",()=>{this.reactor=Sc("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(n){typeof process<"u",console.error(n)}})});m(this,"onExit",()=>{var n;(n=this.reactor)==null||n.call(this),this.editor.getCurrentPageState().editingShapeId&&this.editor.setEditingShape(null)})}}m(Zh,"id","select"),m(Zh,"initial","idle"),m(Zh,"children",()=>[qh,V$,vY,Z$,nM,iM,B$,sM,Q$,tM,W$,X$,rM,oM,eM,q$,J$,G$]);class aM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n});m(this,"onPointerDown",()=>{this.parent.transition("pointing",this.info)})}}m(aM,"id","idle");class cM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n});m(this,"onPointerUp",()=>{this.complete()});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.parent.transition("zoom_brushing",this.info)});m(this,"onCancel",()=>{this.cancel()})}complete(){const{currentScreenPoint:n}=this.editor.inputs;this.editor.inputs.altKey?this.editor.zoomOut(n,{duration:220}):this.editor.zoomIn(n,{duration:220}),this.parent.transition("idle",this.info)}cancel(){this.parent.transition("idle",this.info)}}m(cM,"id","pointing");class lM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"zoomBrush",new ne);m(this,"onEnter",n=>{this.info=n,this.update()});m(this,"onExit",()=>{this.editor.updateInstanceState({zoomBrush:null})});m(this,"onPointerMove",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()})}update(){const{inputs:{originPagePoint:n,currentPagePoint:r}}=this.editor;this.zoomBrush.setTo(ne.FromPoints([n,r])),this.editor.updateInstanceState({zoomBrush:this.zoomBrush.toJson()})}cancel(){this.parent.transition("idle",this.info)}complete(){const{zoomBrush:n}=this,r=8/this.editor.getZoomLevel();if(n.width<r&&n.height<r){const o=this.editor.inputs.currentScreenPoint;this.editor.inputs.altKey?this.editor.zoomOut(o,{duration:220}):this.editor.zoomIn(o,{duration:220})}else{const o=this.editor.inputs.altKey?this.editor.getZoomLevel()/2:void 0;this.editor.zoomToBounds(n,{targetZoom:o,duration:220})}this.parent.transition("idle",this.info)}}m(lM,"id","zoom_brushing");class Qh extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.updateCursor()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({zoomBrush:null,cursor:{type:"default",rotation:0}},{ephemeral:!0}),this.parent.setCurrentToolIdMask(void 0)});m(this,"onKeyDown",()=>{this.updateCursor()});m(this,"onKeyUp",n=>{this.updateCursor(),n.code==="KeyZ"&&this.complete()});m(this,"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.updateInstanceState({cursor:{type:"zoom-out",rotation:0}},{ephemeral:!0}):this.editor.updateInstanceState({cursor:{type:"zoom-in",rotation:0}},{ephemeral:!0})}}m(Qh,"id","zoom"),m(Qh,"initial","idle"),m(Qh,"children",()=>[aM,lM,cM]);const _Y=[Gh,Yh,Xh,Qh,Zh];function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function ie(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function kY(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function rg(...e){return t=>e.forEach(n=>kY(n,t))}function Xe(...e){return x.useCallback(rg(...e),e)}function mo(e,t=[]){let n=[];function r(s,i){const a=x.createContext(i),c=n.length;n=[...n,i];function l(d){const{scope:p,children:f,...y}=d,g=(p==null?void 0:p[e][c])||a,w=x.useMemo(()=>y,Object.values(y));return x.createElement(g.Provider,{value:w},f)}function u(d,p){const f=(p==null?void 0:p[e][c])||a,y=x.useContext(f);if(y)return y;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${s}\``)}return l.displayName=s+"Provider",[l,u]}const o=()=>{const s=n.map(i=>x.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return x.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,TY(o,...t)]}function TY(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:c,scopeName:l})=>{const d=c(s)[`__scope${l}`];return{...a,...d}},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}const Oi=x.forwardRef((e,t)=>{const{children:n,...r}=e,o=x.Children.toArray(n),s=o.find(MY);if(s){const i=s.props.children,a=o.map(c=>c===s?x.Children.count(i)>1?x.Children.only(null):x.isValidElement(i)?i.props.children:null:c);return x.createElement(vv,X({},r,{ref:t}),x.isValidElement(i)?x.cloneElement(i,void 0,a):null)}return x.createElement(vv,X({},r,{ref:t}),n)});Oi.displayName="Slot";const vv=x.forwardRef((e,t)=>{const{children:n,...r}=e;return x.isValidElement(n)?x.cloneElement(n,{...AY(r,n.props),ref:t?rg(t,n.ref):n.ref}):x.Children.count(n)>1?x.Children.only(null):null});vv.displayName="SlotClone";const $Y=({children:e})=>x.createElement(x.Fragment,null,e);function MY(e){return x.isValidElement(e)&&e.type===$Y}function AY(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function og(e){const t=e+"CollectionProvider",[n,r]=mo(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=f=>{const{scope:y,children:g}=f,w=Se.useRef(null),S=Se.useRef(new Map).current;return Se.createElement(o,{scope:y,itemMap:S,collectionRef:w},g)},a=e+"CollectionSlot",c=Se.forwardRef((f,y)=>{const{scope:g,children:w}=f,S=s(a,g),v=Xe(y,S.collectionRef);return Se.createElement(Oi,{ref:v},w)}),l=e+"CollectionItemSlot",u="data-radix-collection-item",d=Se.forwardRef((f,y)=>{const{scope:g,children:w,...S}=f,v=Se.useRef(null),b=Xe(y,v),E=s(l,g);return Se.useEffect(()=>(E.itemMap.set(v,{ref:v,...S}),()=>void E.itemMap.delete(v))),Se.createElement(Oi,{[u]:"",ref:b},w)});function p(f){const y=s(e+"CollectionConsumer",f);return Se.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${u}]`));return Array.from(y.itemMap.values()).sort((E,C)=>S.indexOf(E.ref.current)-S.indexOf(C.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:c,ItemSlot:d},p,r]}const jY=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Ke=jY.reduce((e,t)=>{const n=x.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Oi:t;return x.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),x.createElement(a,X({},i,{ref:o}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Vx(e,t){e&&Ui.flushSync(()=>e.dispatchEvent(t))}function sn(e){const t=x.useRef(e);return x.useEffect(()=>{t.current=e}),x.useMemo(()=>(...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function OY(e,t=globalThis==null?void 0:globalThis.document){const n=sn(e);x.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)},[n,t])}const xv="dismissableLayer.update",DY="dismissableLayer.pointerDownOutside",RY="dismissableLayer.focusOutside";let DC;const uM=x.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),sg=x.forwardRef((e,t)=>{var n;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:a,onDismiss:c,...l}=e,u=x.useContext(uM),[d,p]=x.useState(null),f=(n=d==null?void 0:d.ownerDocument)!==null&&n!==void 0?n:globalThis==null?void 0:globalThis.document,[,y]=x.useState({}),g=Xe(t,k=>p(k)),w=Array.from(u.layers),[S]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=w.indexOf(S),b=d?w.indexOf(d):-1,E=u.layersWithOutsidePointerEventsDisabled.size>0,C=b>=v,I=FY(k=>{const $=k.target,T=[...u.branches].some(O=>O.contains($));!C||T||(s==null||s(k),a==null||a(k),k.defaultPrevented||c==null||c())},f),_=NY(k=>{const $=k.target;[...u.branches].some(O=>O.contains($))||(i==null||i(k),a==null||a(k),k.defaultPrevented||c==null||c())},f);return OY(k=>{b===u.layers.size-1&&(o==null||o(k),!k.defaultPrevented&&c&&(k.preventDefault(),c()))},f),x.useEffect(()=>{if(d)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(DC=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),RC(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=DC)}},[d,f,r,u]),x.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),RC())},[d,u]),x.useEffect(()=>{const k=()=>y({});return document.addEventListener(xv,k),()=>document.removeEventListener(xv,k)},[]),x.createElement(Ke.div,X({},l,{ref:g,style:{pointerEvents:E?C?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,_.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,I.onPointerDownCapture)}))}),LY=x.forwardRef((e,t)=>{const n=x.useContext(uM),r=x.useRef(null),o=Xe(t,r);return x.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),x.createElement(Ke.div,X({},e,{ref:o}))});function FY(e,t=globalThis==null?void 0:globalThis.document){const n=sn(e),r=x.useRef(!1),o=x.useRef(()=>{});return x.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let u=function(){dM(DY,n,l,{discrete:!0})};var c=u;const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function NY(e,t=globalThis==null?void 0:globalThis.document){const n=sn(e),r=x.useRef(!1);return x.useEffect(()=>{const o=s=>{s.target&&!r.current&&dM(RY,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function RC(){const e=new CustomEvent(xv);document.dispatchEvent(e)}function dM(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Vx(o,s):o.dispatchEvent(s)}const zY=sg,BY=LY,ig=x.forwardRef((e,t)=>{var n;const{container:r=globalThis==null||(n=globalThis.document)===null||n===void 0?void 0:n.body,...o}=e;return r?p3.createPortal(x.createElement(Ke.div,X({},o,{ref:t})),r):null}),Di=globalThis!=null&&globalThis.document?x.useLayoutEffect:()=>{};function UY(e,t){return x.useReducer((n,r)=>{const o=t[n][r];return o??n},e)}const yo=e=>{const{present:t,children:n}=e,r=HY(t),o=typeof n=="function"?n({present:r.isPresent}):x.Children.only(n),s=Xe(r.ref,o.ref);return typeof n=="function"||r.isPresent?x.cloneElement(o,{ref:s}):null};yo.displayName="Presence";function HY(e){const[t,n]=x.useState(),r=x.useRef({}),o=x.useRef(e),s=x.useRef("none"),i=e?"mounted":"unmounted",[a,c]=UY(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const l=Ud(r.current);s.current=a==="mounted"?l:"none"},[a]),Di(()=>{const l=r.current,u=o.current;if(u!==e){const p=s.current,f=Ud(l);e?c("MOUNT"):f==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(u&&p!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Di(()=>{if(t){const l=d=>{const f=Ud(r.current).includes(d.animationName);d.target===t&&f&&Ui.flushSync(()=>c("ANIMATION_END"))},u=d=>{d.target===t&&(s.current=Ud(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",l),t.addEventListener("animationend",l),()=>{t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",l),t.removeEventListener("animationend",l)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:x.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function Ud(e){return(e==null?void 0:e.animationName)||"none"}function Zs({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=KY({defaultProp:t,onChange:n}),s=e!==void 0,i=s?e:r,a=sn(n),c=x.useCallback(l=>{if(s){const d=typeof l=="function"?l(e):l;d!==e&&a(d)}else o(l)},[s,e,o,a]);return[i,c]}function KY({defaultProp:e,onChange:t}){const n=x.useState(e),[r]=n,o=x.useRef(r),s=sn(t);return x.useEffect(()=>{o.current!==r&&(s(r),o.current=r)},[r,o,s]),n}const hM=x.forwardRef((e,t)=>x.createElement(Ke.span,X({},e,{ref:t,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",...e.style}}))),pM="ToastProvider",[Gx,WY,VY]=og("Toast"),[fM,Poe]=mo("Toast",[VY]),[GY,ag]=fM(pM),gM=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,c]=x.useState(null),[l,u]=x.useState(0),d=x.useRef(!1),p=x.useRef(!1);return x.createElement(Gx.Provider,{scope:t},x.createElement(GY,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:l,viewport:a,onViewportChange:c,onToastAdd:x.useCallback(()=>u(f=>f+1),[]),onToastRemove:x.useCallback(()=>u(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:d,isClosePausedRef:p},i))};gM.propTypes={label(e){if(e.label&&typeof e.label=="string"&&!e.label.trim()){const t=`Invalid prop \`label\` supplied to \`${pM}\`. Expected non-empty \`string\`.`;return new Error(t)}return null}};const YY="ToastViewport",XY=["F8"],wv="toast.viewportPause",bv="toast.viewportResume",qY=x.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=XY,label:o="Notifications ({hotkey})",...s}=e,i=ag(YY,n),a=WY(n),c=x.useRef(null),l=x.useRef(null),u=x.useRef(null),d=x.useRef(null),p=Xe(t,d,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),y=i.toastCount>0;x.useEffect(()=>{const w=S=>{var v;r.every(E=>S[E]||S.code===E)&&((v=d.current)===null||v===void 0||v.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[r]),x.useEffect(()=>{const w=c.current,S=d.current;if(y&&w&&S){const v=()=>{if(!i.isClosePausedRef.current){const I=new CustomEvent(wv);S.dispatchEvent(I),i.isClosePausedRef.current=!0}},b=()=>{if(i.isClosePausedRef.current){const I=new CustomEvent(bv);S.dispatchEvent(I),i.isClosePausedRef.current=!1}},E=I=>{!w.contains(I.relatedTarget)&&b()},C=()=>{w.contains(document.activeElement)||b()};return w.addEventListener("focusin",v),w.addEventListener("focusout",E),w.addEventListener("pointermove",v),w.addEventListener("pointerleave",C),window.addEventListener("blur",v),window.addEventListener("focus",b),()=>{w.removeEventListener("focusin",v),w.removeEventListener("focusout",E),w.removeEventListener("pointermove",v),w.removeEventListener("pointerleave",C),window.removeEventListener("blur",v),window.removeEventListener("focus",b)}}},[y,i.isClosePausedRef]);const g=x.useCallback(({tabbingDirection:w})=>{const v=a().map(b=>{const E=b.ref.current,C=[E,...hX(E)];return w==="forwards"?C:C.reverse()});return(w==="forwards"?v.reverse():v).flat()},[a]);return x.useEffect(()=>{const w=d.current;if(w){const S=v=>{const b=v.altKey||v.ctrlKey||v.metaKey;if(v.key==="Tab"&&!b){const k=document.activeElement,$=v.shiftKey;if(v.target===w&&$){var C;(C=l.current)===null||C===void 0||C.focus();return}const N=g({tabbingDirection:$?"backwards":"forwards"}),F=N.findIndex(L=>L===k);if(ey(N.slice(F+1)))v.preventDefault();else{var I,_;$?(I=l.current)===null||I===void 0||I.focus():(_=u.current)===null||_===void 0||_.focus()}}};return w.addEventListener("keydown",S),()=>w.removeEventListener("keydown",S)}},[a,g]),x.createElement(BY,{ref:c,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:y?void 0:"none"}},y&&x.createElement(LC,{ref:l,onFocusFromOutsideViewport:()=>{const w=g({tabbingDirection:"forwards"});ey(w)}}),x.createElement(Gx.Slot,{scope:n},x.createElement(Ke.ol,X({tabIndex:-1},s,{ref:p}))),y&&x.createElement(LC,{ref:u,onFocusFromOutsideViewport:()=>{const w=g({tabbingDirection:"backwards"});ey(w)}}))}),ZY="ToastFocusProxy",LC=x.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=ag(ZY,n);return x.createElement(hM,X({"aria-hidden":!0,tabIndex:0},o,{ref:t,style:{position:"fixed"},onFocus:i=>{var a;const c=i.relatedTarget;!((a=s.viewport)!==null&&a!==void 0&&a.contains(c))&&r()}}))}),cg="Toast",QY="toast.swipeStart",JY="toast.swipeMove",eX="toast.swipeCancel",tX="toast.swipeEnd",nX=x.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a=!0,c]=Zs({prop:r,defaultProp:o,onChange:s});return x.createElement(yo,{present:n||a},x.createElement(mM,X({open:a},i,{ref:t,onClose:()=>c(!1),onPause:sn(e.onPause),onResume:sn(e.onResume),onSwipeStart:ie(e.onSwipeStart,l=>{l.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,l=>{const{x:u,y:d}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","move"),l.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${d}px`)}),onSwipeCancel:ie(e.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:ie(e.onSwipeEnd,l=>{const{x:u,y:d}=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",`${u}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${d}px`),c(!1)})})))}),[rX,oX]=fM(cg,{onClose(){}}),mM=x.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:c,onResume:l,onSwipeStart:u,onSwipeMove:d,onSwipeCancel:p,onSwipeEnd:f,...y}=e,g=ag(cg,n),[w,S]=x.useState(null),v=Xe(t,L=>S(L)),b=x.useRef(null),E=x.useRef(null),C=o||g.duration,I=x.useRef(0),_=x.useRef(C),k=x.useRef(0),{onToastAdd:$,onToastRemove:T}=g,O=sn(()=>{var L;(w==null?void 0:w.contains(document.activeElement))&&((L=g.viewport)===null||L===void 0||L.focus()),i()}),N=x.useCallback(L=>{!L||L===1/0||(window.clearTimeout(k.current),I.current=new Date().getTime(),k.current=window.setTimeout(O,L))},[O]);x.useEffect(()=>{const L=g.viewport;if(L){const B=()=>{N(_.current),l==null||l()},q=()=>{const Q=new Date().getTime()-I.current;_.current=_.current-Q,window.clearTimeout(k.current),c==null||c()};return L.addEventListener(wv,q),L.addEventListener(bv,B),()=>{L.removeEventListener(wv,q),L.removeEventListener(bv,B)}}},[g.viewport,C,c,l,N]),x.useEffect(()=>{s&&!g.isClosePausedRef.current&&N(C)},[s,C,g.isClosePausedRef,N]),x.useEffect(()=>($(),()=>T()),[$,T]);const F=x.useMemo(()=>w?xM(w):null,[w]);return g.viewport?x.createElement(x.Fragment,null,F&&x.createElement(sX,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0},F),x.createElement(rX,{scope:n,onClose:O},Ui.createPortal(x.createElement(Gx.ItemSlot,{scope:n},x.createElement(zY,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||O(),g.isFocusedToastEscapeKeyDownRef.current=!1})},x.createElement(Ke.li,X({role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection},y,{ref:v,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,L=>{L.key==="Escape"&&(a==null||a(L.nativeEvent),L.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,O()))}),onPointerDown:ie(e.onPointerDown,L=>{L.button===0&&(b.current={x:L.clientX,y:L.clientY})}),onPointerMove:ie(e.onPointerMove,L=>{if(!b.current)return;const B=L.clientX-b.current.x,q=L.clientY-b.current.y,Q=!!E.current,H=["left","right"].includes(g.swipeDirection),U=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,W=H?U(0,B):0,Z=H?0:U(0,q),le=L.pointerType==="touch"?10:2,be={x:W,y:Z},Me={originalEvent:L,delta:be};Q?(E.current=be,Hd(JY,d,Me,{discrete:!1})):FC(be,g.swipeDirection,le)?(E.current=be,Hd(QY,u,Me,{discrete:!1}),L.target.setPointerCapture(L.pointerId)):(Math.abs(B)>le||Math.abs(q)>le)&&(b.current=null)}),onPointerUp:ie(e.onPointerUp,L=>{const B=E.current,q=L.target;if(q.hasPointerCapture(L.pointerId)&&q.releasePointerCapture(L.pointerId),E.current=null,b.current=null,B){const Q=L.currentTarget,H={originalEvent:L,delta:B};FC(B,g.swipeDirection,g.swipeThreshold)?Hd(tX,f,H,{discrete:!0}):Hd(eX,p,H,{discrete:!0}),Q.addEventListener("click",U=>U.preventDefault(),{once:!0})}})})))),g.viewport))):null});mM.propTypes={type(e){if(e.type&&!["foreground","background"].includes(e.type)){const t=`Invalid prop \`type\` supplied to \`${cg}\`. Expected \`foreground | background\`.`;return new Error(t)}return null}};const sX=e=>{const{__scopeToast:t,children:n,...r}=e,o=ag(cg,t),[s,i]=x.useState(!1),[a,c]=x.useState(!1);return uX(()=>i(!0)),x.useEffect(()=>{const l=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(l)},[]),a?null:x.createElement(ig,{asChild:!0},x.createElement(hM,r,s&&x.createElement(x.Fragment,null,o.label," ",n)))},iX=x.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return x.createElement(Ke.div,X({},r,{ref:t}))}),aX=x.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return x.createElement(Ke.div,X({},r,{ref:t}))}),cX="ToastAction",yM=x.forwardRef((e,t)=>{const{altText:n,...r}=e;return n?x.createElement(vM,{altText:n,asChild:!0},x.createElement(SM,X({},r,{ref:t}))):null});yM.propTypes={altText(e){return e.altText?null:new Error(`Missing prop \`altText\` expected on \`${cX}\``)}};const lX="ToastClose",SM=x.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=oX(lX,n);return x.createElement(vM,{asChild:!0},x.createElement(Ke.button,X({type:"button"},r,{ref:t,onClick:ie(e.onClick,o.onClose)})))}),vM=x.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return x.createElement(Ke.div,X({"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0},o,{ref:t}))});function xM(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),dX(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...xM(r))}}),t}function Hd(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Vx(o,s):o.dispatchEvent(s)}const FC=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function uX(e=()=>{}){const t=sn(e);Di(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function dX(e){return e.nodeType===e.ELEMENT_NODE}function hX(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ey(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}const pX=nX,fX=iX,gX=aX,mX=yM,NC=SM,yX=nD.useId||(()=>{});let SX=0;function Fo(e){const[t,n]=x.useState(yX());return Di(()=>{e||n(r=>r??String(SX++))},[e]),e||(t?`radix-${t}`:"")}const ty="focusScope.autoFocusOnMount",ny="focusScope.autoFocusOnUnmount",zC={bubbles:!1,cancelable:!0},Yx=x.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=x.useState(null),l=sn(o),u=sn(s),d=x.useRef(null),p=Xe(t,g=>c(g)),f=x.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;x.useEffect(()=>{if(r){let v=function(I){if(f.paused||!a)return;const _=I.target;a.contains(_)?d.current=_:fs(d.current,{select:!0})},b=function(I){if(f.paused||!a)return;const _=I.relatedTarget;_!==null&&(a.contains(_)||fs(d.current,{select:!0}))},E=function(I){if(document.activeElement===document.body)for(const k of I)k.removedNodes.length>0&&fs(a)};var g=v,w=b,S=E;document.addEventListener("focusin",v),document.addEventListener("focusout",b);const C=new MutationObserver(E);return a&&C.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",b),C.disconnect()}}},[r,a,f.paused]),x.useEffect(()=>{if(a){UC.add(f);const g=document.activeElement;if(!a.contains(g)){const S=new CustomEvent(ty,zC);a.addEventListener(ty,l),a.dispatchEvent(S),S.defaultPrevented||(vX(CX(wM(a)),{select:!0}),document.activeElement===g&&fs(a))}return()=>{a.removeEventListener(ty,l),setTimeout(()=>{const S=new CustomEvent(ny,zC);a.addEventListener(ny,u),a.dispatchEvent(S),S.defaultPrevented||fs(g??document.body,{select:!0}),a.removeEventListener(ny,u),UC.remove(f)},0)}}},[a,l,u,f]);const y=x.useCallback(g=>{if(!n&&!r||f.paused)return;const w=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,S=document.activeElement;if(w&&S){const v=g.currentTarget,[b,E]=xX(v);b&&E?!g.shiftKey&&S===E?(g.preventDefault(),n&&fs(b,{select:!0})):g.shiftKey&&S===b&&(g.preventDefault(),n&&fs(E,{select:!0})):S===v&&g.preventDefault()}},[n,r,f.paused]);return x.createElement(Ke.div,X({tabIndex:-1},i,{ref:p,onKeyDown:y}))});function vX(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(fs(r,{select:t}),document.activeElement!==n)return}function xX(e){const t=wM(e),n=BC(t,e),r=BC(t.reverse(),e);return[n,r]}function wM(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function BC(e,t){for(const n of e)if(!wX(n,{upTo:t}))return n}function wX(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function bX(e){return e instanceof HTMLInputElement&&"select"in e}function fs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&bX(e)&&t&&e.select()}}const UC=PX();function PX(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=HC(e,t),e.unshift(t)},remove(t){var n;e=HC(e,t),(n=e[0])===null||n===void 0||n.resume()}}}function HC(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function CX(e){return e.filter(t=>t.tagName!=="A")}let ry=0;function Xx(){x.useEffect(()=>{var e,t;const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(e=n[0])!==null&&e!==void 0?e:KC()),document.body.insertAdjacentElement("beforeend",(t=n[1])!==null&&t!==void 0?t:KC()),ry++,()=>{ry===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),ry--}},[])}function KC(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}var Jr=function(){return Jr=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Jr.apply(this,arguments)};function bM(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function IX(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var Jh="right-scroll-bar-position",ep="width-before-scroll-bar",EX="with-scroll-bars-hidden",_X="--removed-body-scroll-bar-size";function oy(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function kX(e,t){var n=x.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var TX=typeof window<"u"?x.useLayoutEffect:x.useEffect,WC=new WeakMap;function $X(e,t){var n=kX(null,function(r){return e.forEach(function(o){return oy(o,r)})});return TX(function(){var r=WC.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||oy(a,null)}),s.forEach(function(a){o.has(a)||oy(a,i)})}WC.set(n,e)},[e]),n}function MX(e){return e}function AX(e,t){t===void 0&&(t=MX);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var c=function(){var u=i;i=[],u.forEach(s)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(u){i.push(u),l()},filter:function(u){return i=i.filter(u),n}}}};return o}function jX(e){e===void 0&&(e={});var t=AX(null);return t.options=Jr({async:!0,ssr:!1},e),t}var PM=function(e){var t=e.sideCar,n=bM(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return x.createElement(r,Jr({},n))};PM.isSideCarExport=!0;function OX(e,t){return e.useMedium(t),PM}var CM=jX(),sy=function(){},lg=x.forwardRef(function(e,t){var n=x.useRef(null),r=x.useState({onScrollCapture:sy,onWheelCapture:sy,onTouchMoveCapture:sy}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,p=e.sideCar,f=e.noIsolation,y=e.inert,g=e.allowPinchZoom,w=e.as,S=w===void 0?"div":w,v=bM(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),b=p,E=$X([n,t]),C=Jr(Jr({},v),o);return x.createElement(x.Fragment,null,u&&x.createElement(b,{sideCar:CM,removeScrollBar:l,shards:d,noIsolation:f,inert:y,setCallbacks:s,allowPinchZoom:!!g,lockRef:n}),i?x.cloneElement(x.Children.only(a),Jr(Jr({},C),{ref:E})):x.createElement(S,Jr({},C,{className:c,ref:E}),a))});lg.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};lg.classNames={fullWidth:ep,zeroRight:Jh};var DX=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function RX(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=DX();return t&&e.setAttribute("nonce",t),e}function LX(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function FX(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var NX=function(){var e=0,t=null;return{add:function(n){e==0&&(t=RX())&&(LX(t,n),FX(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},zX=function(){var e=NX();return function(t,n){x.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},IM=function(){var e=zX(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},BX={left:0,top:0,right:0,gap:0},iy=function(e){return parseInt(e||"",10)||0},UX=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[iy(n),iy(r),iy(o)]},HX=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return BX;var t=UX(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},KX=IM(),Xa="data-scroll-locked",WX=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
.`.concat(EX,` {
|
|
overflow: hidden `).concat(r,`;
|
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
}
|
|
body[`).concat(Xa,`] {
|
|
overflow: hidden `).concat(r,`;
|
|
overscroll-behavior: contain;
|
|
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
padding-left: `.concat(o,`px;
|
|
padding-top: `).concat(s,`px;
|
|
padding-right: `).concat(i,`px;
|
|
margin-left:0;
|
|
margin-top:0;
|
|
margin-right: `).concat(a,"px ").concat(r,`;
|
|
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
}
|
|
|
|
.`).concat(Jh,` {
|
|
right: `).concat(a,"px ").concat(r,`;
|
|
}
|
|
|
|
.`).concat(ep,` {
|
|
margin-right: `).concat(a,"px ").concat(r,`;
|
|
}
|
|
|
|
.`).concat(Jh," .").concat(Jh,` {
|
|
right: 0 `).concat(r,`;
|
|
}
|
|
|
|
.`).concat(ep," .").concat(ep,` {
|
|
margin-right: 0 `).concat(r,`;
|
|
}
|
|
|
|
body[`).concat(Xa,`] {
|
|
`).concat(_X,": ").concat(a,`px;
|
|
}
|
|
`)},VC=function(){var e=parseInt(document.body.getAttribute(Xa)||"0",10);return isFinite(e)?e:0},VX=function(){x.useEffect(function(){return document.body.setAttribute(Xa,(VC()+1).toString()),function(){var e=VC()-1;e<=0?document.body.removeAttribute(Xa):document.body.setAttribute(Xa,e.toString())}},[])},GX=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;VX();var s=x.useMemo(function(){return HX(o)},[o]);return x.createElement(KX,{styles:WX(s,!t,o,n?"":"!important")})},Pv=!1;if(typeof window<"u")try{var Kd=Object.defineProperty({},"passive",{get:function(){return Pv=!0,!0}});window.addEventListener("test",Kd,Kd),window.removeEventListener("test",Kd,Kd)}catch{Pv=!1}var la=Pv?{passive:!1}:!1,YX=function(e){return e.tagName==="TEXTAREA"},EM=function(e,t){var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!YX(e)&&n[t]==="visible")},XX=function(e){return EM(e,"overflowY")},qX=function(e){return EM(e,"overflowX")},GC=function(e,t){var n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var r=_M(e,n);if(r){var o=kM(e,n),s=o[1],i=o[2];if(s>i)return!0}n=n.parentNode}while(n&&n!==document.body);return!1},ZX=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},QX=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},_M=function(e,t){return e==="v"?XX(t):qX(t)},kM=function(e,t){return e==="v"?ZX(t):QX(t)},JX=function(e,t){return e==="h"&&t==="rtl"?-1:1},eq=function(e,t,n,r,o){var s=JX(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,c=t.contains(a),l=!1,u=i>0,d=0,p=0;do{var f=kM(e,a),y=f[0],g=f[1],w=f[2],S=g-w-s*y;(y||S)&&_M(e,a)&&(d+=S,p+=y),a=a.parentNode}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(u&&(d===0||!o)||!u&&(p===0||!o))&&(l=!0),l},Wd=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},YC=function(e){return[e.deltaX,e.deltaY]},XC=function(e){return e&&"current"in e?e.current:e},tq=function(e,t){return e[0]===t[0]&&e[1]===t[1]},nq=function(e){return`
|
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
`)},rq=0,ua=[];function oq(e){var t=x.useRef([]),n=x.useRef([0,0]),r=x.useRef(),o=x.useState(rq++)[0],s=x.useState(function(){return IM()})[0],i=x.useRef(e);x.useEffect(function(){i.current=e},[e]),x.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=IX([e.lockRef.current],(e.shards||[]).map(XC),!0).filter(Boolean);return g.forEach(function(w){return w.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=x.useCallback(function(g,w){if("touches"in g&&g.touches.length===2)return!i.current.allowPinchZoom;var S=Wd(g),v=n.current,b="deltaX"in g?g.deltaX:v[0]-S[0],E="deltaY"in g?g.deltaY:v[1]-S[1],C,I=g.target,_=Math.abs(b)>Math.abs(E)?"h":"v";if("touches"in g&&_==="h"&&I.type==="range")return!1;var k=GC(_,I);if(!k)return!0;if(k?C=_:(C=_==="v"?"h":"v",k=GC(_,I)),!k)return!1;if(!r.current&&"changedTouches"in g&&(b||E)&&(r.current=C),!C)return!0;var $=r.current||C;return eq($,w,g,$==="h"?b:E,!0)},[]),c=x.useCallback(function(g){var w=g;if(!(!ua.length||ua[ua.length-1]!==s)){var S="deltaY"in w?YC(w):Wd(w),v=t.current.filter(function(C){return C.name===w.type&&C.target===w.target&&tq(C.delta,S)})[0];if(v&&v.should){w.cancelable&&w.preventDefault();return}if(!v){var b=(i.current.shards||[]).map(XC).filter(Boolean).filter(function(C){return C.contains(w.target)}),E=b.length>0?a(w,b[0]):!i.current.noIsolation;E&&w.cancelable&&w.preventDefault()}}},[]),l=x.useCallback(function(g,w,S,v){var b={name:g,delta:w,target:S,should:v};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(E){return E!==b})},1)},[]),u=x.useCallback(function(g){n.current=Wd(g),r.current=void 0},[]),d=x.useCallback(function(g){l(g.type,YC(g),g.target,a(g,e.lockRef.current))},[]),p=x.useCallback(function(g){l(g.type,Wd(g),g.target,a(g,e.lockRef.current))},[]);x.useEffect(function(){return ua.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:p}),document.addEventListener("wheel",c,la),document.addEventListener("touchmove",c,la),document.addEventListener("touchstart",u,la),function(){ua=ua.filter(function(g){return g!==s}),document.removeEventListener("wheel",c,la),document.removeEventListener("touchmove",c,la),document.removeEventListener("touchstart",u,la)}},[]);var f=e.removeScrollBar,y=e.inert;return x.createElement(x.Fragment,null,y?x.createElement(s,{styles:nq(o)}):null,f?x.createElement(GX,{gapMode:"margin"}):null)}const sq=OX(CM,oq);var ug=x.forwardRef(function(e,t){return x.createElement(lg,Jr({},e,{ref:t,sideCar:sq}))});ug.classNames=lg.classNames;var iq=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},da=new WeakMap,Vd=new WeakMap,Gd={},ay=0,TM=function(e){return e&&(e.host||TM(e.parentNode))},aq=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=TM(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},cq=function(e,t,n,r){var o=aq(t,Array.isArray(e)?e:[e]);Gd[n]||(Gd[n]=new WeakMap);var s=Gd[n],i=[],a=new Set,c=new Set(o),l=function(d){!d||a.has(d)||(a.add(d),l(d.parentNode))};o.forEach(l);var u=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(p){if(a.has(p))u(p);else try{var f=p.getAttribute(r),y=f!==null&&f!=="false",g=(da.get(p)||0)+1,w=(s.get(p)||0)+1;da.set(p,g),s.set(p,w),i.push(p),g===1&&y&&Vd.set(p,!0),w===1&&p.setAttribute(n,"true"),y||p.setAttribute(r,"true")}catch(S){console.error("aria-hidden: cannot operate on ",p,S)}})};return u(t),a.clear(),ay++,function(){i.forEach(function(d){var p=da.get(d)-1,f=s.get(d)-1;da.set(d,p),s.set(d,f),p||(Vd.has(d)||d.removeAttribute(r),Vd.delete(d)),f||d.removeAttribute(n)}),ay--,ay||(da=new WeakMap,da=new WeakMap,Vd=new WeakMap,Gd={})}},qx=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=iq(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),cq(r,o,n,"aria-hidden")):function(){return null}};const $M="Dialog",[MM,Coe]=mo($M),[lq,rs]=MM($M),uq=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=x.useRef(null),c=x.useRef(null),[l=!1,u]=Zs({prop:r,defaultProp:o,onChange:s});return x.createElement(lq,{scope:t,triggerRef:a,contentRef:c,contentId:Fo(),titleId:Fo(),descriptionId:Fo(),open:l,onOpenChange:u,onOpenToggle:x.useCallback(()=>u(d=>!d),[u]),modal:i},n)},AM="DialogPortal",[dq,jM]=MM(AM,{forceMount:void 0}),hq=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=rs(AM,t);return x.createElement(dq,{scope:t,forceMount:n},x.Children.map(r,i=>x.createElement(yo,{present:n||s.open},x.createElement(ig,{asChild:!0,container:o},i))))},Cv="DialogOverlay",pq=x.forwardRef((e,t)=>{const n=jM(Cv,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=rs(Cv,e.__scopeDialog);return s.modal?x.createElement(yo,{present:r||s.open},x.createElement(fq,X({},o,{ref:t}))):null}),fq=x.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=rs(Cv,n);return x.createElement(ug,{as:Oi,allowPinchZoom:!0,shards:[o.contentRef]},x.createElement(Ke.div,X({"data-state":DM(o.open)},r,{ref:t,style:{pointerEvents:"auto",...r.style}})))}),pu="DialogContent",gq=x.forwardRef((e,t)=>{const n=jM(pu,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=rs(pu,e.__scopeDialog);return x.createElement(yo,{present:r||s.open},s.modal?x.createElement(mq,X({},o,{ref:t})):x.createElement(yq,X({},o,{ref:t})))}),mq=x.forwardRef((e,t)=>{const n=rs(pu,e.__scopeDialog),r=x.useRef(null),o=Xe(t,n.contentRef,r);return x.useEffect(()=>{const s=r.current;if(s)return qx(s)},[]),x.createElement(OM,X({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)===null||i===void 0||i.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault())}))}),yq=x.forwardRef((e,t)=>{const n=rs(pu,e.__scopeDialog),r=x.useRef(!1),o=x.useRef(!1);return x.createElement(OM,X({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i;if((i=e.onCloseAutoFocus)===null||i===void 0||i.call(e,s),!s.defaultPrevented){var a;r.current||(a=n.triggerRef.current)===null||a===void 0||a.focus(),s.preventDefault()}r.current=!1,o.current=!1},onInteractOutside:s=>{var i,a;(i=e.onInteractOutside)===null||i===void 0||i.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=s.target;((a=n.triggerRef.current)===null||a===void 0?void 0:a.contains(c))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}}))}),OM=x.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=rs(pu,n),c=x.useRef(null),l=Xe(t,c);return Xx(),x.createElement(x.Fragment,null,x.createElement(Yx,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s},x.createElement(sg,X({role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":DM(a.open)},i,{ref:l,onDismiss:()=>a.onOpenChange(!1)}))),!1)}),Sq="DialogTitle",vq=x.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=rs(Sq,n);return x.createElement(Ke.h2,X({id:o.titleId},r,{ref:t}))});const xq="DialogClose",wq=x.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=rs(xq,n);return x.createElement(Ke.button,X({type:"button"},r,{ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))}))});function DM(e){return e?"open":"closed"}const bq=uq,Pq=hq,Cq=pq,Iq=gq,RM=()=>{},LM=x.createContext({});function Eq({onEvent:e,children:t}){return h.jsx(LM.Provider,{value:e??RM,children:t})}function So(){return x.useContext(LM)??RM}const FM=x.createContext({});function _q({children:e}){const t=z(),n=So(),[r,o]=x.useState([]),s=x.useCallback(l=>{const u=l.id??et();return o(d=>[...d.filter(p=>p.id!==l.id),{...l,id:u}]),n("open-menu",{source:"dialog",id:u}),t.addOpenMenu(u),u},[t,n]),i=x.useCallback((l,u)=>(o(d=>d.map(p=>p.id===l?{...p,...u}:p)),n("open-menu",{source:"dialog",id:l}),t.addOpenMenu(l),l),[t,n]),a=x.useCallback(l=>(o(u=>u.filter(d=>{var p;return d.id===l?((p=d.onClose)==null||p.call(d),!1):!0})),n("close-menu",{source:"dialog",id:l}),t.deleteOpenMenu(l),l),[t,n]),c=x.useCallback(()=>{o(l=>(l.forEach(u=>{var d;(d=u.onClose)==null||d.call(u),n("close-menu",{source:"dialog",id:u.id}),t.deleteOpenMenu(u.id)}),[]))},[t,n]);return h.jsx(FM.Provider,{value:{dialogs:r,addDialog:s,removeDialog:a,clearDialogs:c,updateDialog:i},children:e})}function Yi(){const e=x.useContext(FM);if(!e)throw new Error("useDialogs must be used within a DialogsProvider");return e}const kq=({id:e,component:t,onClose:n})=>{const{removeDialog:r}=Yi(),o=cn(),s=x.useCallback(i=>{if(!i){if(n)try{n()}catch(a){console.warn(a)}r(e)}},[e,n,r]);return h.jsx(bq,{onOpenChange:s,defaultOpen:!0,children:h.jsx(Pq,{container:o,children:h.jsx(Cq,{dir:"ltr",className:"tlui-dialog__overlay",onClick:i=>{i.target===i.currentTarget&&s(!1)},children:h.jsx(Iq,{dir:"ltr",className:"tlui-dialog__content",children:h.jsx(t,{onClose:()=>s(!1)})})})})})};function Tq(){const{dialogs:e}=Yi();return h.jsx(h.Fragment,{children:e.map(t=>h.jsx(kq,{...t},t.id))})}const $q=Se.memo(Tq);function Mq(){const e=z(),t=K("follow",()=>e.getInstanceState().followingUserId,[e]);return t?h.jsx(Aq,{userId:t}):null}function Aq({userId:e}){const t=g2(e);return t?h.jsx("div",{className:"tlui-following-indicator",style:{borderColor:t.color}}):null}const NM=x.createContext({});function jq({children:e}){const[t,n]=x.useState([]),r=x.useCallback(i=>{const a=i.id??et();return n(c=>[...c.filter(l=>l.id!==i.id),{...i,id:a}]),a},[]),o=x.useCallback(i=>(n(a=>a.filter(c=>c.id!==i)),i),[]),s=x.useCallback(()=>{n(()=>[])},[]);return h.jsx(NM.Provider,{value:{toasts:t,addToast:r,removeToast:o,clearToasts:s},children:e})}function Kr(){const e=x.useContext(NM);if(!e)throw new Error("useToasts must be used within a ToastsProvider");return e}const pe=x.forwardRef(function({children:t,disabled:n,type:r,...o},s){const i=z(),a=s==null?void 0:s.current;return n&&a===document.activeElement&&i.getContainer().focus(),h.jsx("button",{ref:s,type:"button",draggable:!1,disabled:n,...o,className:ue("tlui-button",`tlui-button__${r}`,o.className),children:t})});function vt({children:e}){return h.jsx("span",{className:"tlui-button__label",children:e})}const Bs=x.memo(function({small:t,invertIcon:n,icon:r,color:o,className:s,...i}){const a=Hx(),c=a.icons[r]??a.icons["question-mark-circle"],l=x.useRef(null);return x.useLayoutEffect(()=>{c||console.error(`Icon not found: ${r}. Add it to the assetUrls.icons object.`),l!=null&&l.current&&(l.current.style.webkitMask=`url(${c}) center 100% / 100% no-repeat`)},[l,c,r]),h.jsx("div",{...i,ref:l,className:ue("tlui-icon",{"tlui-icon__small":t},s),style:{color:o,mask:`url(${c}) center 100% / 100% no-repeat`,transform:n?"scale(-1, 1)":void 0}})}),Oq={success:"check-circle",warning:"warning-triangle",error:"cross-circle",info:"info-circle"};function Dq({toast:e}){const{removeToast:t}=Kr(),n=$e(),r=i=>{i||t(e.id)},o=e.actions&&e.actions.length>0,s=e.icon||e.severity&&Oq[e.severity];return h.jsxs(pX,{onOpenChange:r,className:"tlui-toast__container",duration:e.keepOpen?1/0:5e3,"data-severity":e.severity,children:[s&&h.jsx("div",{className:"tlui-toast__icon",children:h.jsx(Bs,{icon:s})}),h.jsxs("div",{className:"tlui-toast__main",children:[h.jsxs("div",{className:"tlui-toast__content",children:[e.title&&h.jsx(fX,{className:"tlui-toast__title",children:e.title}),e.description&&h.jsx(gX,{className:"tlui-toast__description",children:e.description})]}),e.actions&&h.jsxs("div",{className:"tlui-toast__actions",children:[e.actions.map((i,a)=>h.jsx(mX,{altText:i.label,asChild:!0,onClick:i.onClick,children:h.jsx(pe,{type:i.type,children:h.jsx(vt,{children:i.label})})},a)),h.jsx(NC,{asChild:!0,children:h.jsx(pe,{type:"normal",className:"tlui-toast__close",style:{marginLeft:"auto"},children:h.jsx(vt,{children:e.closeLabel??n("toast.close")})})})]})]}),!o&&h.jsx(NC,{asChild:!0,children:h.jsx(pe,{type:"normal",className:"tlui-toast__close",children:h.jsx(vt,{children:e.closeLabel??n("toast.close")})})})]})}function Rq(){const{toasts:e}=Kr();return h.jsx(h.Fragment,{children:e.map(t=>h.jsx(Dq,{toast:t},t.id))})}const Lq=x.memo(Rq);function Fq(){const{toasts:e}=Kr(),[t,n]=x.useState(!1);return x.useEffect(()=>{let r=!1;return e.length?n(!0):setTimeout(()=>{r||n(!1)},1e3),()=>{r=!0}},[e.length,n]),t?h.jsx(qY,{className:"tlui-toast__viewport"}):null}function ke({icon:e,small:t,invertIcon:n}){return h.jsx(Bs,{className:"tlui-button__icon",icon:e,small:t,invertIcon:n})}const cy=[0,390,428,468,580,640,840,1023];var mt=(e=>(e[e.ZERO=0]="ZERO",e[e.MOBILE_XXS=1]="MOBILE_XXS",e[e.MOBILE_XS=2]="MOBILE_XS",e[e.MOBILE_SM=3]="MOBILE_SM",e[e.MOBILE=4]="MOBILE",e[e.TABLET_SM=5]="TABLET_SM",e[e.TABLET=6]="TABLET",e[e.DESKTOP=7]="DESKTOP",e))(mt||{});const xi="2.1.4";let Iv={fonts:{draw:`https://unpkg.com/@tldraw/assets@${xi}/fonts/Shantell_Sans-Tldrawish.woff2`,serif:`https://unpkg.com/@tldraw/assets@${xi}/fonts/IBMPlexSerif-Medium.woff2`,sansSerif:`https://unpkg.com/@tldraw/assets@${xi}/fonts/IBMPlexSans-Medium.woff2`,monospace:`https://unpkg.com/@tldraw/assets@${xi}/fonts/IBMPlexMono-Medium.woff2`}};function zM(e){return x.useMemo(()=>e?{fonts:{...Iv.fonts,...e==null?void 0:e.fonts}}:Iv,[e])}const Nq=["align-bottom-center","align-bottom-left","align-bottom-right","align-bottom","align-center-center","align-center-horizontal","align-center-left","align-center-right","align-center-vertical","align-left","align-right","align-top-center","align-top-left","align-top-right","align-top","arrow-left","arrowhead-arrow","arrowhead-bar","arrowhead-diamond","arrowhead-dot","arrowhead-none","arrowhead-square","arrowhead-triangle-inverted","arrowhead-triangle","aspect-ratio","avatar","blob","bring-forward","bring-to-front","check-circle","check","checkbox-checked","checkbox-empty","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","code","collab","color","comment","cross-2","cross-circle","cross","dash-dashed","dash-dotted","dash-draw","dash-solid","discord","distribute-horizontal","distribute-vertical","dot","dots-horizontal","dots-vertical","drag-handle-dots","duplicate","edit","error","external-link","file","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-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","hidden","image","info-circle","leading","link","lock-small","lock","menu","minus","mixed","pack","page","plus","question-mark-circle","question-mark","redo","reset-zoom","rotate-ccw","rotate-cw","ruler","search","send-backward","send-to-back","settings-horizontal","settings-vertical-1","settings-vertical","share-1","share-2","size-extra-large","size-large","size-medium","size-small","spline-cubic","spline-line","stack-horizontal","stack-vertical","status-offline","status-online","stretch-horizontal","stretch-vertical","text-align-center","text-align-justify","text-align-left","text-align-right","tool-arrow","tool-embed","tool-eraser","tool-frame","tool-hand","tool-highlight","tool-laser","tool-line","tool-media","tool-note","tool-pencil","tool-pointer","tool-text","trash","triangle-down","triangle-up","twitter","undo","ungroup","unlock-small","unlock","vertical-align-center","vertical-align-end","vertical-align-start","visible","warning-triangle","zoom-in","zoom-out"];let rl={...Iv,icons:Object.fromEntries(Nq.map(e=>[e,`https://unpkg.com/@tldraw/assets@${xi}/icons/icon/${e}.svg`])),translations:Object.fromEntries(ou.map(e=>[e.locale,`https://unpkg.com/@tldraw/assets@${xi}/translations/${e.locale}.json`])),embedIcons:Object.fromEntries(Tu.map(e=>[e.type,`https://unpkg.com/@tldraw/assets@${xi}/embed-icons/${e.type}.png`]))};function zq(e){return e?{fonts:Object.assign({...rl.fonts},{...e==null?void 0:e.fonts}),icons:Object.assign({...rl.icons},{...e==null?void 0:e.icons}),embedIcons:Object.assign({...rl.embedIcons},{...e==null?void 0:e.embedIcons}),translations:Object.assign({...rl.translations},{...e==null?void 0:e.translations})}:rl}function dg({className:e,children:t}){return h.jsx("div",{className:ue("tlui-dialog__header",e),children:t})}function hg({className:e,children:t}){return h.jsx(vq,{dir:"ltr",className:ue("tlui-dialog__header__title",e),children:t})}function pg(){return h.jsx("div",{className:"tlui-dialog__header__close",children:h.jsx(wq,{"data-testid":"dialog.close",dir:"ltr",asChild:!0,children:h.jsx(pe,{type:"icon","aria-label":"Close",onTouchEnd:e=>e.target.click(),children:h.jsx(ke,{small:!0,icon:"cross-2"})})})})}function fu({className:e,children:t,style:n}){return h.jsx("div",{className:ue("tlui-dialog__body",e),style:n,children:t})}function Zx({className:e,children:t}){return h.jsx("div",{className:ue("tlui-dialog__footer",e),children:t})}const Qx=x.forwardRef(function({className:t,label:n,icon:r,iconLeft:o,autoselect:s=!1,autofocus:i=!1,defaultValue:a,placeholder:c,onComplete:l,onValueChange:u,onCancel:d,onBlur:p,shouldManuallyMaintainScrollPositionWhenFocused:f=!1,children:y,value:g},w){const S=z(),v=x.useRef(null);x.useImperativeHandle(w,()=>v.current);const b=$e(),E=x.useRef(a??""),C=x.useRef(a??""),[I,_]=x.useState(!1),k=x.useCallback(N=>{_(!0);const F=N.currentTarget;C.current=F.value,requestAnimationFrame(()=>{s&&F.select()})},[s]),$=x.useCallback(N=>{const F=N.currentTarget.value;C.current=F,u==null||u(F)},[u]),T=x.useCallback(N=>{switch(N.key){case"Enter":{N.currentTarget.blur(),Ut(N),l==null||l(N.currentTarget.value);break}case"Escape":{N.currentTarget.value=E.current,N.currentTarget.blur(),Ut(N),d==null||d(N.currentTarget.value);break}}},[l,d]),O=x.useCallback(N=>{_(!1);const F=N.currentTarget.value;p==null||p(F)},[p]);return x.useEffect(()=>{if(!S.environment.isIos)return;const N=window.visualViewport;if(I&&f&&N){const F=()=>{var L;(L=v.current)==null||L.scrollIntoView({block:"center"})};return N.addEventListener("resize",F),N.addEventListener("scroll",F),requestAnimationFrame(()=>{var L;(L=v.current)==null||L.scrollIntoView({block:"center"})}),()=>{N.removeEventListener("resize",F),N.removeEventListener("scroll",F)}}},[S,I,f]),h.jsxs("div",{draggable:!1,className:"tlui-input__wrapper",children:[y,n&&h.jsx("label",{children:b(n)}),o&&h.jsx(Bs,{icon:o,className:"tlui-icon-left",small:!0}),h.jsx("input",{ref:v,className:ue("tlui-input",t),type:"text",defaultValue:a,onKeyUp:T,onChange:$,onFocus:k,onBlur:O,autoFocus:i,placeholder:c,value:g}),r&&h.jsx(Bs,{icon:r,small:!!n})]})}),BM=or(function({onClose:t}){const n=z(),r=$e(),o=Hx(),[s,i]=x.useState(null),[a,c]=x.useState(""),[l,u]=x.useState(null),[d,p]=x.useState(!1),f=x.useRef(-1);return h.jsxs(h.Fragment,{children:[h.jsxs(dg,{children:[h.jsx(hg,{children:s?`${r("embed-dialog.title")} — ${s.title}`:r("embed-dialog.title")}),h.jsx(pg,{})]}),s?h.jsxs(h.Fragment,{children:[h.jsxs(fu,{className:"tlui-embed-dialog__enter",children:[h.jsx(Qx,{className:"tlui-embed-dialog__input",label:"embed-dialog.url",placeholder:"http://example.com",autofocus:!0,onValueChange:y=>{c(y);const g=Cs(y);u(g&&g.definition.type===s.type?g:null),p(!1),clearTimeout(f.current),f.current=setTimeout(()=>p(!g),320)}}),a===""?h.jsxs("div",{className:"tlui-embed-dialog__instruction",children:[h.jsx("span",{children:r("embed-dialog.instruction")})," ",s.instructionLink&&h.jsxs("a",{target:"_blank",rel:"noopener noreferrer",href:s.instructionLink,className:"tlui-embed-dialog__instruction__link",children:["Learn more.",h.jsx(Bs,{icon:"external-link",small:!0})]})]}):h.jsx("div",{className:"tlui-embed-dialog__warning",children:d?r("embed-dialog.invalid-url"):" "})]}),h.jsxs(Zx,{className:"tlui-dialog__footer__actions",children:[h.jsx(pe,{type:"normal",onClick:()=>{i(null),u(null),c("")},children:h.jsx(vt,{children:r("embed-dialog.back")})}),h.jsx("div",{className:"tlui-embed__spacer"}),h.jsx(pe,{type:"normal",onClick:t,children:h.jsx(vt,{children:r("embed-dialog.cancel")})}),h.jsx(pe,{type:"primary",disabled:!l,onClick:()=>{l&&(n.putExternalContent({type:"embed",url:a,point:n.getViewportPageCenter(),embed:l.definition}),t())},children:h.jsx(vt,{children:r("embed-dialog.create")})})]})]}):h.jsx(h.Fragment,{children:h.jsx(fu,{className:"tlui-embed-dialog__list",children:Tu.map(y=>h.jsxs(pe,{type:"menu",onClick:()=>i(y),children:[h.jsx(vt,{children:y.title}),h.jsx("div",{className:"tlui-embed-dialog__item__image",style:{backgroundImage:`url(${o.embedIcons[y.type]})`}})]},y.type))})})]})});function UM(){const e=z(),t=x.useRef();return x.useEffect(()=>{const n=window.document.createElement("input");n.type="file",n.accept="image/jpeg,image/png,image/gif,image/svg+xml,video/mp4,video/quicktime",n.multiple=!0,t.current=n;async function r(o){const s=o.target.files;!s||s.length===0||(await e.putExternalContent({type:"files",files:Array.from(s),point:e.getViewportPageBounds().center,ignoreParent:!1}),n.value="")}return n.addEventListener("change",r),()=>{t.current=void 0,n.removeEventListener("change",r)}},[e]),x.useCallback(()=>{var n;(n=t.current)==null||n.click()},[t])}const HM=x.createContext({});function Bq({overrides:e,children:t}){const n=z(),r=So(),{addDialog:o}=Yi(),s=UM(),i=x.useMemo(()=>{const a=[{id:"select",label:"tool.select",icon:"tool-pointer",kbd:"v",readonlyOk:!0,onSelect(l){n.setCurrentTool("select"),r("select-tool",{source:l,id:"select"})}},{id:"hand",label:"tool.hand",icon:"tool-hand",kbd:"h",readonlyOk:!0,onSelect(l){n.setCurrentTool("hand"),r("select-tool",{source:l,id:"hand"})}},{id:"eraser",label:"tool.eraser",icon:"tool-eraser",kbd:"e",onSelect(l){n.setCurrentTool("eraser"),r("select-tool",{source:l,id:"eraser"})}},{id:"draw",label:"tool.draw",icon:"tool-pencil",kbd:"d,b,x",onSelect(l){n.setCurrentTool("draw"),r("select-tool",{source:l,id:"draw"})}},...[...oo.values].map(l=>({id:l,label:`tool.${l}`,meta:{geo:l},kbd:l==="rectangle"?"r":l==="ellipse"?"o":void 0,icon:"geo-"+l,onSelect(u){n.batch(()=>{n.updateInstanceState({stylesForNextShape:{...n.getInstanceState().stylesForNextShape,[oo.id]:l}},{ephemeral:!0}),n.setCurrentTool("geo"),r("select-tool",{source:u,id:`geo-${l}`})})}})),{id:"arrow",label:"tool.arrow",icon:"tool-arrow",kbd:"a",onSelect(l){n.setCurrentTool("arrow"),r("select-tool",{source:l,id:"arrow"})}},{id:"line",label:"tool.line",icon:"tool-line",kbd:"l",onSelect(l){n.setCurrentTool("line"),r("select-tool",{source:l,id:"line"})}},{id:"frame",label:"tool.frame",icon:"tool-frame",kbd:"f",onSelect(l){n.setCurrentTool("frame"),r("select-tool",{source:l,id:"frame"})}},{id:"text",label:"tool.text",icon:"tool-text",kbd:"t",onSelect(l){n.setCurrentTool("text"),r("select-tool",{source:l,id:"text"})}},{id:"asset",label:"tool.asset",icon:"tool-media",kbd:"$u",onSelect(l){s(),r("select-tool",{source:l,id:"media"})}},{id:"note",label:"tool.note",icon:"tool-note",kbd:"n",onSelect(l){n.setCurrentTool("note"),r("select-tool",{source:l,id:"note"})}},{id:"laser",label:"tool.laser",readonlyOk:!0,icon:"tool-laser",kbd:"k",onSelect(l){n.setCurrentTool("laser"),r("select-tool",{source:l,id:"laser"})}},{id:"embed",label:"tool.embed",icon:"tool-embed",onSelect(l){o({component:BM}),r("select-tool",{source:l,id:"embed"})}},{id:"highlight",label:"tool.highlight",icon:"tool-highlight",kbd:"!d",onSelect(l){n.setCurrentTool("highlight"),r("select-tool",{source:l,id:"highlight"})}}];a.push();const c=Object.fromEntries(a.map(l=>[l.id,l]));return e?e(n,c,{insertMedia:s}):c},[e,n,r,s,o]);return h.jsx(HM.Provider,{value:i,children:t})}function De(){const e=x.useContext(HM);if(!e)throw new Error("useTools must be used within a ToolProvider");return e}const KM=Se.createContext(0);function Uq({forceMobile:e=!1,children:t}){const n=z(),r=K("breakpoint",()=>{const{width:o}=n.getViewportScreenBounds(),s=e?mt.MOBILE_SM:cy.length-1;for(let i=0;i<s;i++)if(o>cy[i]&&o<=cy[i+1])return i;return s},[n]);return h.jsx(KM.Provider,{value:r,children:t})}function Rn(){return x.useContext(KM)}function Hq(){const{addToast:e,removeToast:t,clearToasts:n}=Kr(),{addDialog:r,clearDialogs:o,removeDialog:s,updateDialog:i}=Yi(),c=Rn()<mt.TABLET_SM,l=$e();return x.useMemo(()=>({addToast:e,removeToast:t,clearToasts:n,addDialog:r,clearDialogs:o,removeDialog:s,updateDialog:i,msg:l,isMobile:c}),[r,e,o,n,l,s,t,i,c])}function Kq(e,t){const n={};for(const r of e)if(r.translations)for(const[o,s]of An(r.translations)){let i=n[o];i||(i=n[o]={}),Object.assign(i,s)}return{actions:(r,o)=>{for(const s of e)s.actions&&(o=s.actions(r,o,t));return o},tools:(r,o,s)=>{for(const i of e)i.tools&&(o=i.tools(r,o,{...t,...s}));return o},translations:n}}function WM(e){return x.useMemo(()=>e,e)}function Wq(e){const t=WM(e==null?[]:Array.isArray(e)?e:[e]);return x.useMemo(()=>{const n={};for(const r of t)if(r.translations)for(const[o,s]of An(r.translations)){let i=n[o];i||(i=n[o]={}),Object.assign(i,s)}return n},[t])}function Vq(e){const t=Hq(),n=WM(e==null?[]:Array.isArray(e)?e:[e]);return x.useMemo(()=>Kq(n,t),[n,t])}function Gq(e,t){const n=fe(t.map(o=>e.getShape(o)).filter(o=>o&&e.isShapeOfType(o,"frame")));if(!n.length)return;const r=[];e.batch(()=>{n.map(o=>{const s=e.getSortedChildIdsForParent(o.id);s.length&&(e.reparentShapes(s,o.parentId,o.index),r.push(...s))}),e.setSelectedShapes(r),e.deleteShapes(t)})}const Yq=50;function Xq(e,t,n={}){const r=e.getShape(t);if(!r)return;const o=e.getSortedChildIdsForParent(r.id),s=fe(o.map(f=>e.getShape(f)));if(!s.length)return;const i=ne.FromPoints(s.flatMap(f=>{const y=e.getShapeGeometry(f.id);return e.getShapeLocalTransform(f).applyToPoints(y.vertices)})),{padding:a=Yq}=n,c=i.w+2*a,l=i.h+2*a,u=a-i.minX,d=a-i.minY;if(u===0&&d===0&&r.props.w===c&&r.props.h===l)return;const p=new P(u,d).rot(r.rotation);e.batch(()=>{const f=o.map(y=>{const g=e.getShape(y);return{id:g.id,type:g.type,x:g.x+u,y:g.y+d}});f.push({id:r.id,type:r.type,x:r.x-p.x,y:r.y-p.y,props:{w:c,h:l}}),e.updateShapes(f)})}function qC(e){return er.isValid(e)?{isValid:!0,hasProtocol:!0}:er.isValid("https://"+e)?{isValid:!0,hasProtocol:!1}:{isValid:!1,hasProtocol:!1}}const qq=or(function({onClose:t}){const r=z().getOnlySelectedShape();return r&&"url"in r.props&&typeof r.props.url=="string"?h.jsx(Zq,{onClose:t,selectedShape:r}):null}),Zq=or(function({onClose:t,selectedShape:n}){const r=z(),o=$e(),s=x.useRef(null);x.useEffect(()=>{requestAnimationFrame(()=>{var y;return(y=s.current)==null?void 0:y.focus()})},[]);const i=x.useRef(n.props.url),[a,c]=x.useState(()=>{const y=qC(n.props.url),g=y.isValid===!0?y.hasProtocol?n.props.url:"https://"+n.props.url:"https://";return{actual:g,safe:g,valid:!0}}),l=x.useCallback(y=>{const g=y.replace(/https?:\/\/(https?:\/\/)/,(v,b)=>b),w=qC(g),S=w.isValid===!0?w.hasProtocol?g:"https://"+g:"https://";c({actual:g,safe:S,valid:w.isValid})},[]),u=x.useCallback(()=>{const y=r.getOnlySelectedShape();y&&(r.updateShapes([{id:y.id,type:y.type,props:{url:""}}]),t())},[r,t]),d=x.useCallback(()=>{const y=r.getOnlySelectedShape();y&&(y&&"url"in y.props&&y.props.url!==a.safe&&r.updateShapes([{id:y.id,type:y.type,props:{url:a.safe}}]),t())},[r,t,a]),p=x.useCallback(()=>{t()},[t]);if(!n)return t(),null;const f=i.current&&!a.valid;return h.jsxs(h.Fragment,{children:[h.jsxs(dg,{children:[h.jsx(hg,{children:o("edit-link-dialog.title")}),h.jsx(pg,{})]}),h.jsx(fu,{children:h.jsxs("div",{className:"tlui-edit-link-dialog",children:[h.jsx(Qx,{ref:s,className:"tlui-edit-link-dialog__input",label:"edit-link-dialog.url",autofocus:!0,value:a.actual,onValueChange:l,onComplete:d,onCancel:p}),h.jsx("div",{children:a.valid?o("edit-link-dialog.detail"):o("edit-link-dialog.invalid-url")})]})}),h.jsxs(Zx,{className:"tlui-dialog__footer__actions",children:[h.jsx(pe,{type:"normal",onClick:p,onTouchEnd:p,children:h.jsx(vt,{children:o("edit-link-dialog.cancel")})}),f?h.jsx(pe,{type:"danger",onTouchEnd:u,onClick:u,children:h.jsx(vt,{children:o("edit-link-dialog.clear")})}):h.jsx(pe,{type:"primary",disabled:!a.valid,onTouchEnd:d,onClick:d,children:h.jsx(vt,{children:o("edit-link-dialog.save")})})]})]})});var Jx={exports:{}};Jx.exports;(function(e){var t=function(){var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function i(c,l){if(!s[c]){s[c]={};for(var u=0;u<c.length;u++)s[c][c.charAt(u)]=u}return s[c][l]}var a={compressToBase64:function(c){if(c==null)return"";var l=a._compress(c,6,function(u){return r.charAt(u)});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 i(r,c.charAt(l))})},compressToUTF16:function(c){return c==null?"":a._compress(c,15,function(l){return n(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),u=new Uint8Array(l.length*2),d=0,p=l.length;d<p;d++){var f=l.charCodeAt(d);u[d*2]=f>>>8,u[d*2+1]=f%256}return u},decompressFromUint8Array:function(c){if(c==null)return a.decompress(c);for(var l=new Array(c.length/2),u=0,d=l.length;u<d;u++)l[u]=c[u*2]*256+c[u*2+1];var p=[];return l.forEach(function(f){p.push(n(f))}),a.decompress(p.join(""))},compressToEncodedURIComponent:function(c){return c==null?"":a._compress(c,6,function(l){return o.charAt(l)})},decompressFromEncodedURIComponent:function(c){return c==null?"":c==""?null:(c=c.replace(/ /g,"+"),a._decompress(c.length,32,function(l){return i(o,c.charAt(l))}))},compress:function(c){return a._compress(c,16,function(l){return n(l)})},_compress:function(c,l,u){if(c==null)return"";var d,p,f={},y={},g="",w="",S="",v=2,b=3,E=2,C=[],I=0,_=0,k;for(k=0;k<c.length;k+=1)if(g=c.charAt(k),Object.prototype.hasOwnProperty.call(f,g)||(f[g]=b++,y[g]=!0),w=S+g,Object.prototype.hasOwnProperty.call(f,w))S=w;else{if(Object.prototype.hasOwnProperty.call(y,S)){if(S.charCodeAt(0)<256){for(d=0;d<E;d++)I=I<<1,_==l-1?(_=0,C.push(u(I)),I=0):_++;for(p=S.charCodeAt(0),d=0;d<8;d++)I=I<<1|p&1,_==l-1?(_=0,C.push(u(I)),I=0):_++,p=p>>1}else{for(p=1,d=0;d<E;d++)I=I<<1|p,_==l-1?(_=0,C.push(u(I)),I=0):_++,p=0;for(p=S.charCodeAt(0),d=0;d<16;d++)I=I<<1|p&1,_==l-1?(_=0,C.push(u(I)),I=0):_++,p=p>>1}v--,v==0&&(v=Math.pow(2,E),E++),delete y[S]}else for(p=f[S],d=0;d<E;d++)I=I<<1|p&1,_==l-1?(_=0,C.push(u(I)),I=0):_++,p=p>>1;v--,v==0&&(v=Math.pow(2,E),E++),f[w]=b++,S=String(g)}if(S!==""){if(Object.prototype.hasOwnProperty.call(y,S)){if(S.charCodeAt(0)<256){for(d=0;d<E;d++)I=I<<1,_==l-1?(_=0,C.push(u(I)),I=0):_++;for(p=S.charCodeAt(0),d=0;d<8;d++)I=I<<1|p&1,_==l-1?(_=0,C.push(u(I)),I=0):_++,p=p>>1}else{for(p=1,d=0;d<E;d++)I=I<<1|p,_==l-1?(_=0,C.push(u(I)),I=0):_++,p=0;for(p=S.charCodeAt(0),d=0;d<16;d++)I=I<<1|p&1,_==l-1?(_=0,C.push(u(I)),I=0):_++,p=p>>1}v--,v==0&&(v=Math.pow(2,E),E++),delete y[S]}else for(p=f[S],d=0;d<E;d++)I=I<<1|p&1,_==l-1?(_=0,C.push(u(I)),I=0):_++,p=p>>1;v--,v==0&&(v=Math.pow(2,E),E++)}for(p=2,d=0;d<E;d++)I=I<<1|p&1,_==l-1?(_=0,C.push(u(I)),I=0):_++,p=p>>1;for(;;)if(I=I<<1,_==l-1){C.push(u(I));break}else _++;return C.join("")},decompress:function(c){return c==null?"":c==""?null:a._decompress(c.length,32768,function(l){return c.charCodeAt(l)})},_decompress:function(c,l,u){var d=[],p=4,f=4,y=3,g="",w=[],S,v,b,E,C,I,_,k={val:u(0),position:l,index:1};for(S=0;S<3;S+=1)d[S]=S;for(b=0,C=Math.pow(2,2),I=1;I!=C;)E=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),b|=(E>0?1:0)*I,I<<=1;switch(b){case 0:for(b=0,C=Math.pow(2,8),I=1;I!=C;)E=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),b|=(E>0?1:0)*I,I<<=1;_=n(b);break;case 1:for(b=0,C=Math.pow(2,16),I=1;I!=C;)E=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),b|=(E>0?1:0)*I,I<<=1;_=n(b);break;case 2:return""}for(d[3]=_,v=_,w.push(_);;){if(k.index>c)return"";for(b=0,C=Math.pow(2,y),I=1;I!=C;)E=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),b|=(E>0?1:0)*I,I<<=1;switch(_=b){case 0:for(b=0,C=Math.pow(2,8),I=1;I!=C;)E=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),b|=(E>0?1:0)*I,I<<=1;d[f++]=n(b),_=f-1,p--;break;case 1:for(b=0,C=Math.pow(2,16),I=1;I!=C;)E=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),b|=(E>0?1:0)*I,I<<=1;d[f++]=n(b),_=f-1,p--;break;case 2:return w.join("")}if(p==0&&(p=Math.pow(2,y),y++),d[_])g=d[_];else if(_===f)g=v+v.charAt(0);else return null;w.push(g),d[f++]=v+g.charAt(0),p--,v=g,p==0&&(p=Math.pow(2,y),y++)}}};return a}();e!=null?e.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})})(Jx);var VM=Jx.exports;async function Qq(e,t,n){var S,v,b;const{elements:r,files:o}=t,s={shapes:[],rootShapeIds:[],assets:[],schema:e.store.schema.serialize()},i=new Map,a=new Map,c=e.getCurrentPageId(),l=new Map,u=[],d=new Set;r.forEach(E=>{if(l.set(E.id,Be()),E.boundElements!==null)for(const C of E.boundElements)C.type==="text"&&d.add(C.id)});let p=F3;for(const E of r){if(d.has(E.id))continue;const C=l.get(E.id),I={id:C,typeName:"shape",parentId:c,index:p,x:E.x,y:E.y,rotation:0,isLocked:E.locked,opacity:Jq(E.opacity),meta:{}};switch(E.angle!==0&&a.set(C,E.angle),E.groupIds&&E.groupIds.length>0?i.has(E.groupIds[0])?(S=i.get(E.groupIds[0]))==null||S.push(C):i.set(E.groupIds[0],[C]):u.push(C),E.type){case"rectangle":case"ellipse":case"diamond":{let _="",k="middle";if(E.boundElements!==null){for(const T of E.boundElements)if(T.type==="text"){const O=r.find(N=>N.id===T.id);O&&(_=O.text,k=ZC[O.textAlign])}}const $=E.backgroundColor==="transparent"?E.strokeColor:E.backgroundColor;s.shapes.push({...I,type:"geo",props:{geo:E.type,url:E.link??"",w:E.width,h:E.height,size:Yd[E.strokeWidth]??"draw",color:ol[$]??"black",text:_,align:k,dash:Xd(E),fill:iZ(E)}});break}case"freedraw":{s.shapes.push({...I,type:"draw",props:{dash:Xd(E),size:Yd[E.strokeWidth],color:ol[E.strokeColor]??"black",segments:[{type:"free",points:E.points.map(([_,k,$=.5])=>({x:_,y:k,z:$}))}]}});break}case"line":{const _=E.points[0],k=E.points[E.points.length-1],$=eu(E.points.length);s.shapes.push({...I,type:"line",props:{dash:Xd(E),size:Yd[E.strokeWidth],color:ol[E.strokeColor]??"black",spline:E.roundness?"cubic":"line",handles:{start:{id:"start",type:"vertex",index:$[0],x:_[0],y:_[1]},end:{id:"end",type:"vertex",index:$[$.length-1],x:k[0],y:k[1]},...Object.fromEntries(E.points.slice(1,-1).map(([T,O],N)=>{const F=et();return[F,{id:F,type:"vertex",index:$[N+1],x:T,y:O}]}))}}});break}case"arrow":{let _="";if(E.boundElements!==null){for(const N of E.boundElements)if(N.type==="text"){const F=r.find(L=>L.id===N.id);F&&(_=F.text)}}const k=E.points[0],$=E.points[E.points.length-1],T=l.get((v=E.startBinding)==null?void 0:v.elementId),O=l.get((b=E.endBinding)==null?void 0:b.elementId);s.shapes.push({...I,type:"arrow",props:{text:_,bend:sZ(E,k,$),dash:Xd(E),size:Yd[E.strokeWidth]??"m",color:ol[E.strokeColor]??"black",start:T?{type:"binding",boundShapeId:T,normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1}:{type:"point",x:k[0],y:k[1]},end:O?{type:"binding",boundShapeId:O,normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1}:{type:"point",x:$[0],y:$[1]},arrowheadEnd:QC[E.endArrowhead]??"none",arrowheadStart:QC[E.startArrowhead]??"none"}});break}case"text":{const{size:_,scale:k}=tZ(E.fontSize);s.shapes.push({...I,type:"text",props:{size:_,scale:k,font:nZ[E.fontFamily]??"draw",color:ol[E.strokeColor]??"black",text:E.text,align:ZC[E.textAlign]}});break}case"image":{const _=o[E.fileId];if(!_)break;const k=Si.createId();s.assets.push({id:k,typeName:"asset",type:"image",props:{w:E.width,h:E.height,name:E.id??"Untitled",isAnimated:!1,mimeType:_.mimeType,src:_.dataURL},meta:{}}),s.shapes.push({...I,type:"image",props:{w:E.width,h:E.height,assetId:k}})}}p=$o(p)}const f=n??(e.inputs.shiftKey?e.inputs.currentPagePoint:void 0);e.mark("paste"),e.putContentOntoCurrentPage(s,{point:f,select:!1,preserveIds:!0});for(const E of i.values())if(E.length>1){e.groupShapes(E);const C=e.getShape(E[0]);C!=null&&C.parentId&&Kn(C.parentId)&&u.push(C.parentId)}for(const[E,C]of a)e.select(E),e.rotateShapesBy([E],C);const y=fe(u.map(E=>e.getShape(E))),g=ne.Common(y.map(E=>e.getShapePageBounds(E))),w=e.getViewportPageBounds().center;e.updateShapes(y.map(E=>{const C={x:(E.x??0)-(g.x+g.w/2),y:(E.y??0)-(g.y+g.h/2)};return{id:E.id,type:E.type,x:w.x+C.x,y:w.y+C.y}})),e.setSelectedShapes(u)}const Jq=e=>{const t=e/100;return t<.2?.1:t<.4?.25:t<.6?.5:t<.8?.75:1},Yd={1:"s",2:"m",3:"l",4:"xl"},eZ={16:"s",20:"m",28:"l",36:"xl"};function tZ(e){const t=eZ[e];return t?{size:t,scale:1}:e<16?{size:"s",scale:e/16}:e>36?{size:"xl",scale:e/36}:{size:"m",scale:1}}const nZ={1:"draw",2:"sans",3:"mono"},ol={"#ffffff":"grey","#000000":"black","#343a40":"black","#495057":"grey","#c92a2a":"red","#a61e4d":"light-red","#862e9c":"violet","#5f3dc4":"light-violet","#364fc7":"blue","#1864ab":"light-blue","#0b7285":"light-green","#087f5b":"light-green","#2b8a3e":"green","#5c940d":"light-green","#e67700":"yellow","#d9480f":"orange","#ced4da":"grey","#868e96":"grey","#fa5252":"light-red","#e64980":"red","#be4bdb":"light-violet","#7950f2":"violet","#4c6ef5":"blue","#228be6":"light-blue","#15aabf":"light-green","#12b886":"green","#40c057":"green","#82c91e":"light-green","#fab005":"yellow","#fd7e14":"orange","#212529":"grey"},rZ={solid:"draw",dashed:"dashed",dotted:"dotted"},oZ={"cross-hatch":"pattern",hachure:"pattern",solid:"solid"},ZC={left:"start",center:"middle",right:"end"},QC={arrow:"arrow",dot:"dot",triangle:"triangle",bar:"pipe"};function sZ(e,t,n){let r=0;if(e.points.length>2){const o=new P(t[0],t[1]),s=new P(n[0],n[1]),i=new P(e.points[1][0],e.points[1][1]),a=P.Sub(s,o),c=P.Per(a),l=P.Med(s,o),u=P.Sub(l,c),d=P.Add(l,c),p=P.NearestPointOnLineSegment(u,d,i,!1);r=P.Dist(p,l),P.Clockwise(p,s,l)&&(r*=-1)}return r}const Xd=e=>{let t=rZ[e.strokeStyle]??"draw";return t==="draw"&&e.roughness===0&&(t="solid"),t},iZ=e=>e.backgroundColor==="transparent"?"none":oZ[e.fillStyle]??"solid";async function GM(e,t,n,r){const s=(await Promise.all(t.map(async i=>await(await fetch(i)).blob()))).map(i=>new File([i],"tldrawFile",{type:i.type}));e.mark("paste"),await e.putExternalContent({type:"files",files:s,point:n,ignoreParent:!1,sources:r}),t.forEach(i=>URL.revokeObjectURL(i))}function aZ(e,t,n){const r=n??(e.inputs.shiftKey?e.inputs.currentPagePoint:void 0),o=e.getSelectionPageBounds();e.mark("paste"),e.putContentOntoCurrentPage(t,{point:r,select:!0});const s=e.getSelectionPageBounds();o&&s&&(o!=null&&o.collides(s))&&(e.updateInstanceState({isChangingStyle:!0},{ephemeral:!0}),setTimeout(()=>{e.updateInstanceState({isChangingStyle:!1},{ephemeral:!0})},150))}async function Ev(e,t,n,r){var o;try{if(new URL(t).pathname.match(/\.(png|jpe?g|gif|svg|webp)$/i)&&(o=(await fetch(t,{method:"HEAD"})).headers.get("content-type"))!=null&&o.match(/^image\//)){e.mark("paste"),GM(e,[t]);return}}catch(s){s.message!=="Failed to fetch"&&console.error(s)}return e.mark("paste"),await e.putExternalContent({type:"url",point:n,url:t,sources:r})}function cZ(e){const t=document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=e.trim(),t.body.textContent||t.body.innerText||""}const lZ=e=>{try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},uZ=e=>{const t=e.split(/[\n\s]/);for(const n of t)try{const r=new URL(n);if(!(r.protocol==="http:"||r.protocol==="https:"))return}catch{return}return f2(t)},dZ=e=>/^<svg/.test(e),hZ=["input","select","textarea"];function tp(e){const{activeElement:t}=document;return e.getIsMenuOpen()||t&&(t.getAttribute("contenteditable")||hZ.indexOf(t.tagName.toLowerCase())>-1)}const pZ=e=>e.types.find(t=>t.match(/^image\//)),ly=(e,t,n,r)=>{const o=uZ(t);if(o)for(const s of o)Ev(e,s,n);else lZ(t)?Ev(e,t,n):dZ(t)?(e.mark("paste"),e.putExternalContent({type:"svg-text",text:t,point:n,sources:r})):(e.mark("paste"),e.putExternalContent({type:"text",text:t,point:n,sources:r}))},fZ=async(e,t,n)=>{if(e.getEditingShapeId()!==null)return;if(!t)throw Error("No clipboard data");const r=[];for(const o of Object.values(t.items))switch(o.kind){case"file":{r.push({type:"file",source:new Promise(s=>s(o.getAsFile()))});break}case"string":{o.type==="text/html"?r.push({type:"html",source:new Promise(s=>o.getAsString(s))}):o.type==="text/plain"?r.push({type:"text",source:new Promise(s=>o.getAsString(s))}):r.push({type:o.type,source:new Promise(s=>o.getAsString(s))});break}}XM(e,r,n)},YM=async(e,t,n)=>{const r=[];for(const o of t){if(pZ(o))for(const s of o.types)s.match(/^image\//)&&r.push({type:"blob",source:o.getType(s)});o.types.includes("text/html")&&r.push({type:"html",source:(async()=>{const s=await o.getType("text/html");return await Ka.blobToText(s)})()}),o.types.includes("text/uri-list")&&r.push({type:"url",source:(async()=>{const s=await o.getType("text/uri-list");return await Ka.blobToText(s)})()}),o.types.includes("text/plain")&&r.push({type:"text",source:(async()=>{const s=await o.getType("text/plain");return await Ka.blobToText(s)})()})}return await XM(e,r,n)};async function XM(e,t,n){const r=t.filter(s=>(s.type==="file"||s.type==="blob")&&s.source!==null);if(r.length){const i=(await Promise.all(r.map(a=>a.source))).filter(Boolean).map(a=>URL.createObjectURL(a));return await GM(e,i,n)}const o=await Promise.all(t.filter(s=>s.type!=="file").map(s=>new Promise(i=>{const a=s;if(a.type==="file"){i({type:"error",data:null,reason:"unexpected file"});return}a.source.then(c=>{var u;const l=(u=c.match(/<tldraw[^>]*>(.*)<\/tldraw>/))==null?void 0:u[1];if(l)try{const d=VM.decompressFromBase64(l);if(d===null){i({type:"error",data:d,reason:"found tldraw data comment but could not parse base64"});return}else{const p=JSON.parse(d);if(p.type!=="application/tldraw"&&i({type:"error",data:p,reason:`found tldraw data comment but JSON was of a different type: ${p.type}`}),typeof p.data=="string"){i({type:"error",data:p,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}i({type:"tldraw",data:p.data});return}}catch{i({type:"error",data:l,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}else{if(a.type==="html"){i({type:"text",data:c,subtype:"html"});return}if(a.type==="url"){i({type:"text",data:c,subtype:"url"});return}try{const d=JSON.parse(c);if(d.type==="excalidraw/clipboard"){i({type:"excalidraw",data:d});return}else{i({type:"text",data:c,subtype:"json"});return}}catch{i({type:"text",data:c,subtype:"text"});return}}i({type:"error",data:c,reason:"unhandled case"})})})));for(const s of o)if(s.type==="tldraw"){aZ(e,s.data,n);return}for(const s of o)if(s.type==="excalidraw"){Qq(e,s.data,n);return}for(const s of o)if(s.type==="text"&&s.subtype==="html"){const a=new DOMParser().parseFromString(s.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");ly(e,l,n,o);return}if(!o.some(l=>l.type==="text"&&l.subtype!=="html")&&s.data.trim()){ly(e,cZ(s.data),n,o);return}}for(const s of o)if(s.type==="text"&&s.subtype==="url"){Ev(e,s.data,n,o);return}for(const s of o)if(s.type==="text"&&s.subtype==="text"&&s.data.trim()){ly(e,s.data,n,o);return}}const lf=e=>{var r;const t=e.getContentFromCurrentPage(e.getSelectedShapeIds());if(!t){navigator&&navigator.clipboard&&navigator.clipboard.writeText("");return}const n=VM.compressToBase64(JSON.stringify({type:"application/tldraw",kind:"content",data:t}));if(!(typeof navigator>"u")){const o=t.shapes.map(s=>e.isShapeOfType(s,"text")||e.isShapeOfType(s,"geo")||e.isShapeOfType(s,"arrow")?s.props.text:e.isShapeOfType(s,"bookmark")||e.isShapeOfType(s,"embed")?s.props.url:null).filter(G3);if((r=navigator.clipboard)!=null&&r.write){const s=new Blob([`<tldraw>${n}</tldraw>`],{type:"text/html"});let i=o.join(" ");i===""&&(i=" "),navigator.clipboard.write([new ClipboardItem({"text/html":s,"text/plain":new Blob([i],{type:"text/plain"})})])}else navigator.clipboard.writeText&&navigator.clipboard.writeText(`<tldraw>${n}</tldraw>`)}};function gZ(){const e=z(),t=So(),n=x.useCallback(function(i){e.getSelectedShapeIds().length!==0&&(lf(e),t("copy",{source:i}))},[e,t]),r=x.useCallback(function(i){e.getSelectedShapeIds().length!==0&&(lf(e),e.deleteShapes(e.getSelectedShapeIds()),t("cut",{source:i}))},[e,t]),o=x.useCallback(async function(i,a,c){e.getEditingShapeId()!==null||tp(e)||(Array.isArray(i)&&i[0]instanceof ClipboardItem?(YM(e,i,c),t("paste",{source:"menu"})):navigator.clipboard.read().then(l=>{o(l,a,c)}))},[e,t]);return{copy:n,cut:r,paste:o}}function mZ(){const e=z(),t=So(),n=K("editor.isFocused",()=>e.getInstanceState().isFocused,[e]);x.useEffect(()=>{if(!n)return;const r=c=>{e.getSelectedShapeIds().length===0||e.getEditingShapeId()!==null||tp(e)||(Ee(c),lf(e),t("copy",{source:"kbd"}))};function o(c){e.getSelectedShapeIds().length===0||e.getEditingShapeId()!==null||tp(e)||(Ee(c),lf(e),e.deleteShapes(e.getSelectedShapeIds()),t("cut",{source:"kbd"}))}let s=!1;const i=c=>{c.button===1&&(s=!0,requestAnimationFrame(()=>{s=!1}))},a=c=>{if(s){Ut(c);return}e.getEditingShapeId()!==null||tp(e)||(c.clipboardData&&!e.inputs.shiftKey?fZ(e,c.clipboardData):navigator.clipboard.read().then(l=>{Array.isArray(l)&&l[0]instanceof ClipboardItem&&YM(e,l,e.inputs.currentPagePoint)}),Ee(c),t("paste",{source:"kbd"}))};return document.addEventListener("copy",r),document.addEventListener("cut",o),document.addEventListener("paste",a),document.addEventListener("pointerup",i),()=>{document.removeEventListener("copy",r),document.removeEventListener("cut",o),document.removeEventListener("paste",a),document.removeEventListener("pointerup",i)}},[e,t,n])}async function qM(e,t,n){const{type:r,quality:o,scale:s,width:i,height:a}=n;let[c,l]=await n$(i*s,a*s);c=Math.floor(c),l=Math.floor(l);const u=c/i,d=URL.createObjectURL(new Blob([e],{type:"image/svg+xml"})),p=await new Promise(y=>{const g=new Image;g.crossOrigin="anonymous",g.onload=async()=>{t&&await new Promise(v=>setTimeout(v,250));const w=document.createElement("canvas"),S=w.getContext("2d");w.width=c,w.height=l,S.imageSmoothingEnabled=!0,S.imageSmoothingQuality="high",S.drawImage(g,0,0,c,l),URL.revokeObjectURL(d),y(w)},g.onerror=()=>{y(null)},g.src=d});if(!p)return null;const f=await new Promise(y=>p.toBlob(g=>{(!g||$t.throwToBlob.get())&&y(null),y(g)},"image/"+r,o));if(!f)return null;if(r==="png"){const y=new DataView(await f.arrayBuffer());return Zr.setPhysChunk(y,u,{type:"image/"+r})}else return f}async function ZM(e,t,n){const r=await e.getSvgString(t!=null&&t.length?t:[...e.getCurrentPageShapeIds()],{scale:1,background:e.getInstanceState().exportBackground,...n});if(!r)throw new Error("Could not construct SVG.");return r}async function _v(e,t,n,r={}){var o;switch(n){case"svg":return(o=await ZM(e,t,r))==null?void 0:o.svg;case"json":{const s=e.getContentFromCurrentPage(t);return JSON.stringify(s)}default:qo(n)}}async function QM({editor:e,ids:t,format:n,opts:r={}}){switch(n){case"svg":return new Blob([await _v(e,t,"svg",r)],{type:"text/plain"});case"json":return new Blob([await _v(e,t,"json",r)],{type:"text/plain"});case"jpeg":case"png":case"webp":{const o=await ZM(e,t,r);if(!o)throw new Error("Could not construct image.");const s=await qM(o.svg,e.environment.isSafari,{type:n,quality:1,scale:2,width:o.width,height:o.height});if(!s)throw new Error("Could not construct image.");return s}default:qo(n)}}const yZ={jpeg:"image/jpeg",png:"image/png",webp:"image/webp",json:"text/plain",svg:"text/plain"};function SZ(e,t,n,r={}){return{blobPromise:QM({editor:e,ids:t,format:n,opts:r}),mimeType:yZ[n]}}function vZ(e,t,n="svg",r={}){if(!window.navigator.clipboard)return Promise.reject(new Error("Copy not supported"));if(window.navigator.clipboard.write){const{blobPromise:o,mimeType:s}=SZ(e,t,n,r);return window.navigator.clipboard.write([new ClipboardItem({[s]:o})]).catch(i=>(console.error(i),o.then(a=>window.navigator.clipboard.write([new ClipboardItem({[s]:a})]))))}switch(n){case"json":case"svg":return xZ(async()=>_v(e,t,n,r));case"jpeg":case"png":throw new Error("Copy not supported");default:qo(n)}}async function xZ(e){var t,n;await((n=(t=navigator.clipboard)==null?void 0:t.writeText)==null?void 0:n.call(t,await e()))}function wZ(){const e=z(),{addToast:t}=Kr(),n=$e();return x.useCallback((r,o="svg")=>{vZ(e,r,o).catch(()=>{t({id:"copy-fail",severity:"warning",title:n("toast.error.copy-fail.title"),description:n("toast.error.copy-fail.desc")})})},[e,t,n])}async function bZ(e,t,n="png",r,o={}){if(!r&&(r=`shapes at ${JC()}`,t.length===1)){const a=e.getShape(t[0]);e.isShapeOfType(a,"frame")?r=a.props.name??"frame":r=`${a.id.replace(/:/,"_")} at ${JC()}`}r+=`.${n}`;const s=await QM({editor:e,ids:t,format:n,opts:o}),i=new File([s],r,{type:s.type});PZ(i)}function JC(){const e=new Date,t=String(e.getFullYear()).slice(2),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),s=String(e.getMinutes()).padStart(2,"0"),i=String(e.getSeconds()).padStart(2,"0");return`${t}-${n}-${r} ${o}.${s}.${i}`}function PZ(e){const t=document.createElement("a"),n=URL.createObjectURL(e);t.href=n,t.download=e.name,t.click(),URL.revokeObjectURL(n)}function CZ(){const e=z(),{addToast:t}=Kr(),n=$e();return x.useCallback((r,o="png",s)=>{bZ(e,r,o,s,{scale:1,background:e.getInstanceState().exportBackground}).catch(i=>{console.error(i.message),t({id:"export-fail",title:n("toast.error.export-fail.title"),description:n("toast.error.export-fail.desc"),severity:"error"})})},[e,t,n])}function IZ(){const e=z(),t=x.useRef(null),n=x.useRef(null);return x.useCallback(async function(){const o=document.createElement("div"),s=document.createElement("style"),i=(S,v)=>{S&&(S.innerHTML=""),v&&document.head.contains(v)&&document.head.removeChild(v),S&&document.body.contains(S)&&document.body.removeChild(S)};i(t.current,n.current),t.current=o,n.current=s;const a=`tl-print-surface-${et()}`;o.className=a,s.innerHTML=`
|
|
.${a} {
|
|
display: none;
|
|
}
|
|
|
|
.${a} svg {
|
|
max-width: 100%;
|
|
height: 100%;
|
|
display: block;
|
|
}
|
|
|
|
@media print {
|
|
html, body {
|
|
min-height: 100%;
|
|
height: 100%;
|
|
margin: 0;
|
|
}
|
|
|
|
body {
|
|
position: relative;
|
|
}
|
|
|
|
body > * {
|
|
display: none;
|
|
}
|
|
|
|
.tldraw__editor {
|
|
display: none;
|
|
}
|
|
|
|
.${a} {
|
|
display: block !important;
|
|
background: white;
|
|
min-height: 100%;
|
|
height: 100%;
|
|
max-width: 100%;
|
|
}
|
|
|
|
.${a}__item {
|
|
padding: 10mm;
|
|
display: flex;
|
|
min-height: 100%;
|
|
flex-direction: column;
|
|
page-break-after: always;
|
|
position: relative;
|
|
overflow: hidden;
|
|
height: 100%;
|
|
}
|
|
|
|
.${a}__item__main {
|
|
flex: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
max-height: 100%;
|
|
}
|
|
|
|
.${a}__item__header {
|
|
display: none;
|
|
}
|
|
|
|
.${a}__item__footer {
|
|
display: none;
|
|
text-align: right;
|
|
}
|
|
|
|
.${a}__item__footer__hide {
|
|
display: none;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
`;const c=()=>{document.head.appendChild(s),document.body.appendChild(o)},l=()=>{e.once("change-history",()=>{i(o,s)})};window.addEventListener("beforeprint",c),window.addEventListener("afterprint",l);function u(S,v,b){try{o.innerHTML+=`<div class="${a}__item">
|
|
<div class="${a}__item__header">
|
|
${S.replace(/</g,"<").replace(/>/g,">")}
|
|
</div>
|
|
<div class="${a}__item__main">
|
|
${b}
|
|
</div>
|
|
<div class="${a}__item__footer ${a}__item__footer__${v?"":"hide"}">
|
|
${v??""}
|
|
</div>
|
|
</div>`}catch(E){console.error(E)}}function d(){e.environment.isChromeForIos?(c(),window.print()):e.environment.isSafari?(c(),document.execCommand("print",!1)):window.print()}const p=e.getSelectedShapeIds(),f=e.getCurrentPageId(),y=e.getPages(),w={scale:1,background:!1,darkMode:!1,preserveAspectRatio:"xMidYMid meet"};if(e.getSelectedShapeIds().length>0){const S=await e.getSvgString(p,w);if(S){const v=y.find(b=>b.id===f);u(`tldraw — ${v==null?void 0:v.name}`,null,S.svg),d()}}else{const S=e.getCurrentPage(),v=await e.getSvgString(e.getSortedChildIdsForParent(S.id),w);v&&(u(`tldraw — ${S.name}`,null,v.svg),d())}window.removeEventListener("beforeprint",c),window.removeEventListener("afterprint",l)},[e])}const JM=x.createContext({});function EZ(e){return Object.fromEntries(e.map(t=>[t.id,t]))}function ha(e,t){if(e.getSelectedShapes().length===0)return e.getDocumentSettings().name||t}function _Z({overrides:e,children:t}){const n=z(),{addDialog:r,clearDialogs:o}=Yi(),{clearToasts:s}=Kr(),i=$e(),a=UM(),c=IZ(),{cut:l,copy:u,paste:d}=gZ(),p=wZ(),f=CZ(),y=i("document.default-name"),g=So(),w=x.useMemo(()=>{function S(){return n.isIn("select")||(n.complete(),n.setCurrentTool("select")),!1}function v(){return n.isIn("select")&&n.getSelectedShapeIds().length>0}const E=EZ([{id:"edit-link",label:"action.edit-link",icon:"link",onSelect(C){v()&&(S()||(g("edit-link",{source:C}),n.mark("edit-link"),r({component:qq})))}},{id:"insert-embed",label:"action.insert-embed",kbd:"$i",onSelect(C){g("insert-embed",{source:C}),r({component:BM})}},{id:"insert-media",label:"action.insert-media",kbd:"$u",onSelect(C){g("insert-media",{source:C}),a()}},{id:"undo",label:"action.undo",icon:"undo",kbd:"$z",onSelect(C){g("undo",{source:C}),n.undo()}},{id:"redo",label:"action.redo",icon:"redo",kbd:"$!z",onSelect(C){g("redo",{source:C}),n.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(C){let I=n.getSelectedShapeIds();I.length===0&&(I=Array.from(n.getCurrentPageShapeIds().values())),I.length!==0&&(g("export-as",{format:"svg",source:C}),f(I,"svg",ha(n,y)))}},{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(C){let I=n.getSelectedShapeIds();I.length===0&&(I=Array.from(n.getCurrentPageShapeIds().values())),I.length!==0&&(g("export-as",{format:"png",source:C}),f(I,"png",ha(n,y)))}},{id:"export-as-json",label:{default:"action.export-as-json",menu:"action.export-as-json.short","context-menu":"action.export-as-json.short"},readonlyOk:!0,onSelect(C){let I=n.getSelectedShapeIds();I.length===0&&(I=Array.from(n.getCurrentPageShapeIds().values())),I.length!==0&&(g("export-as",{format:"json",source:C}),f(I,"json",ha(n,y)))}},{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(C){let I=n.getSelectedShapeIds();I.length===0&&(I=Array.from(n.getCurrentPageShapeIds().values())),I.length!==0&&(g("export-all-as",{format:"svg",source:C}),f(Array.from(n.getCurrentPageShapeIds()),"svg",ha(n,y)))}},{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(C){const I=Array.from(n.getCurrentPageShapeIds().values());I.length!==0&&(g("export-all-as",{format:"png",source:C}),f(I,"png",ha(n,y)))}},{id:"export-all-as-json",label:{default:"action.export-all-as-json",menu:"action.export-all-as-json.short","context-menu":"action.export-all-as-json.short"},readonlyOk:!0,onSelect(C){const I=Array.from(n.getCurrentPageShapeIds().values());I.length!==0&&(g("export-all-as",{format:"json",source:C}),f(I,"json",ha(n,y)))}},{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(C){let I=n.getSelectedShapeIds();I.length===0&&(I=Array.from(n.getCurrentPageShapeIds().values())),I.length!==0&&(g("copy-as",{format:"svg",source:C}),p(I,"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(C){let I=n.getSelectedShapeIds();I.length===0&&(I=Array.from(n.getCurrentPageShapeIds().values())),I.length!==0&&(g("copy-as",{format:"png",source:C}),p(I,"png"))}},{id:"copy-as-json",label:{default:"action.copy-as-json",menu:"action.copy-as-json.short","context-menu":"action.copy-as-json.short"},readonlyOk:!0,onSelect(C){let I=n.getSelectedShapeIds();I.length===0&&(I=Array.from(n.getCurrentPageShapeIds().values())),I.length!==0&&(g("copy-as",{format:"json",source:C}),p(I,"json"))}},{id:"toggle-auto-size",label:"action.toggle-auto-size",onSelect(C){if(!v()||S())return;g("toggle-auto-size",{source:C}),n.mark("toggling auto size");const I=n.getSelectedShapes().filter(_=>n.isShapeOfType(_,"text")&&_.props.autoSize===!1);n.updateShapes(I.map(_=>({id:_.id,type:_.type,props:{..._.props,w:8,autoSize:!0}}))),We(n,I.map(_=>_.id))}},{id:"open-embed-link",label:"action.open-embed-link",readonlyOk:!0,onSelect(C){g("open-embed-link",{source:C});const I=n.getSelectedShapeIds(),_="No embed shapes selected";if(I.length!==1){console.error(_);return}const k=n.getShape(I[0]);if(!k||!n.isShapeOfType(k,"embed")){console.error(_);return}T8(k.props.url,"_blank")}},{id:"select-zoom-tool",readonlyOk:!0,kbd:"z",onSelect(C){var I,_;if(((I=n.root.getCurrent())==null?void 0:I.id)!=="zoom"&&(g("zoom-tool",{source:C}),!(n.inputs.shiftKey||n.inputs.ctrlKey))){const k=n.root.getCurrent();k&&((_=k.getCurrent())==null?void 0:_.id)==="idle"&&n.setCurrentTool("zoom",{onInteractionEnd:k.id,maskAs:"zoom"})}}},{id:"convert-to-bookmark",label:"action.convert-to-bookmark",onSelect(C){v()&&(S()||n.batch(()=>{g("convert-to-bookmark",{source:C});const I=n.getSelectedShapes(),_=[],k=[];for(const $ of I){if(!$||!n.isShapeOfType($,"embed")||!$.props.url)continue;const T=new P($.x,$.y);T.rot(-$.rotation),T.add(new P($.props.w/2-300/2,$.props.h/2-320/2)),T.rot($.rotation);const O={id:Be(),type:"bookmark",rotation:$.rotation,x:T.x,y:T.y,opacity:1,props:{url:$.props.url}};_.push(O),k.push($.id)}n.mark("convert shapes to bookmark"),n.deleteShapes(k),n.createShapes(_)}))}},{id:"convert-to-embed",label:"action.convert-to-embed",onSelect(C){v()&&(S()||(g("convert-to-embed",{source:C}),n.batch(()=>{const I=n.getSelectedShapeIds(),_=fe(I.map(T=>n.getShape(T))),k=[],$=[];for(const T of _){if(!n.isShapeOfType(T,"bookmark"))continue;const{url:O}=T.props,N=Cs(T.props.url);if(!N||!N.definition)continue;const{width:F,height:L}=N.definition,B=new P(T.x,T.y);B.rot(-T.rotation),B.add(new P(T.props.w/2-F/2,T.props.h/2-L/2)),B.rot(T.rotation);const q={id:Be(),type:"embed",x:B.x,y:B.y,rotation:T.rotation,props:{url:O,w:F,h:L}};k.push(q),$.push(T.id)}n.mark("convert shapes to embed"),n.deleteShapes($),n.createShapes(k)})))}},{id:"duplicate",kbd:"$d",label:"action.duplicate",icon:"duplicate",onSelect(C){if(!v()||S())return;g("duplicate-shapes",{source:C});const I=n.getInstanceState();let _,k;if(I.duplicateProps)_=I.duplicateProps.shapeIds,k=I.duplicateProps.offset;else{_=n.getSelectedShapeIds();const $=ne.Common(fe(_.map(T=>n.getShapePageBounds(T))));k=I.canMoveCamera?{x:$.width+20,y:0}:{x:20,y:20}}n.mark("duplicate shapes"),n.duplicateShapes(_,k),I.duplicateProps&&n.updateInstanceState({duplicateProps:{...I.duplicateProps,shapeIds:n.getSelectedShapeIds()}})}},{id:"ungroup",label:"action.ungroup",kbd:"$!g",icon:"ungroup",onSelect(C){v()&&(S()||(g("ungroup-shapes",{source:C}),n.mark("ungroup"),n.ungroupShapes(n.getSelectedShapeIds())))}},{id:"group",label:"action.group",kbd:"$g",icon:"group",onSelect(C){if(!v()||S())return;g("group-shapes",{source:C});const I=n.getOnlySelectedShape();I&&n.isShapeOfType(I,"group")?(n.mark("ungroup"),n.ungroupShapes(n.getSelectedShapeIds())):(n.mark("group"),n.groupShapes(n.getSelectedShapeIds()))}},{id:"remove-frame",label:"action.remove-frame",kbd:"$!f",onSelect(C){if(!v())return;g("remove-frame",{source:C});const I=n.getSelectedShapes();I.length>0&&I.every(_=>n.isShapeOfType(_,"frame"))&&(n.mark("remove-frame"),Gq(n,I.map(_=>_.id)))}},{id:"fit-frame-to-content",label:"action.fit-frame-to-content",onSelect(C){if(!v())return;g("fit-frame-to-content",{source:C});const I=n.getOnlySelectedShape();I&&n.isShapeOfType(I,"frame")&&(n.mark("fit-frame-to-content"),Xq(n,I.id))}},{id:"align-left",label:"action.align-left",kbd:"?A",icon:"align-left",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"left",source:C}),n.mark("align left");const I=n.getSelectedShapeIds();n.alignShapes(I,"left"),We(n,I)}},{id:"align-center-horizontal",label:{default:"action.align-center-horizontal","context-menu":"action.align-center-horizontal.short"},kbd:"?H",icon:"align-center-horizontal",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"center-horizontal",source:C}),n.mark("align center horizontal");const I=n.getSelectedShapeIds();n.alignShapes(I,"center-horizontal"),We(n,I)}},{id:"align-right",label:"action.align-right",kbd:"?D",icon:"align-right",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"right",source:C}),n.mark("align right");const I=n.getSelectedShapeIds();n.alignShapes(I,"right"),We(n,I)}},{id:"align-center-vertical",label:{default:"action.align-center-vertical","context-menu":"action.align-center-vertical.short"},kbd:"?V",icon:"align-center-vertical",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"center-vertical",source:C}),n.mark("align center vertical");const I=n.getSelectedShapeIds();n.alignShapes(I,"center-vertical"),We(n,I)}},{id:"align-top",label:"action.align-top",icon:"align-top",kbd:"?W",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"top",source:C}),n.mark("align top");const I=n.getSelectedShapeIds();n.alignShapes(I,"top"),We(n,I)}},{id:"align-bottom",label:"action.align-bottom",icon:"align-bottom",kbd:"?S",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"bottom",source:C}),n.mark("align bottom");const I=n.getSelectedShapeIds();n.alignShapes(I,"bottom"),We(n,I)}},{id:"distribute-horizontal",label:{default:"action.distribute-horizontal","context-menu":"action.distribute-horizontal.short"},icon:"distribute-horizontal",kbd:"?!h",onSelect(C){if(!v()||S())return;g("distribute-shapes",{operation:"horizontal",source:C}),n.mark("distribute horizontal");const I=n.getSelectedShapeIds();n.distributeShapes(I,"horizontal"),We(n,I)}},{id:"distribute-vertical",label:{default:"action.distribute-vertical","context-menu":"action.distribute-vertical.short"},icon:"distribute-vertical",kbd:"?!V",onSelect(C){if(!v()||S())return;g("distribute-shapes",{operation:"vertical",source:C}),n.mark("distribute vertical");const I=n.getSelectedShapeIds();n.distributeShapes(I,"vertical"),We(n,I)}},{id:"stretch-horizontal",label:{default:"action.stretch-horizontal","context-menu":"action.stretch-horizontal.short"},icon:"stretch-horizontal",onSelect(C){if(!v()||S())return;g("stretch-shapes",{operation:"horizontal",source:C}),n.mark("stretch horizontal");const I=n.getSelectedShapeIds();n.stretchShapes(I,"horizontal"),We(n,I)}},{id:"stretch-vertical",label:{default:"action.stretch-vertical","context-menu":"action.stretch-vertical.short"},icon:"stretch-vertical",onSelect(C){if(!v()||S())return;g("stretch-shapes",{operation:"vertical",source:C}),n.mark("stretch vertical");const I=n.getSelectedShapeIds();n.stretchShapes(I,"vertical"),We(n,I)}},{id:"flip-horizontal",label:{default:"action.flip-horizontal","context-menu":"action.flip-horizontal.short"},kbd:"!h",onSelect(C){if(!v()||S())return;g("flip-shapes",{operation:"horizontal",source:C}),n.mark("flip horizontal");const I=n.getSelectedShapeIds();n.flipShapes(I,"horizontal"),We(n,I)}},{id:"flip-vertical",label:{default:"action.flip-vertical","context-menu":"action.flip-vertical.short"},kbd:"!v",onSelect(C){if(!v()||S())return;g("flip-shapes",{operation:"vertical",source:C}),n.mark("flip vertical");const I=n.getSelectedShapeIds();n.flipShapes(I,"vertical"),We(n,I)}},{id:"pack",label:"action.pack",icon:"pack",onSelect(C){if(!v()||S())return;g("pack-shapes",{source:C}),n.mark("pack");const I=n.getSelectedShapeIds();n.packShapes(I,16),We(n,I)}},{id:"stack-vertical",label:{default:"action.stack-vertical","context-menu":"action.stack-vertical.short"},icon:"stack-vertical",onSelect(C){if(!v()||S())return;g("stack-shapes",{operation:"vertical",source:C}),n.mark("stack-vertical");const I=n.getSelectedShapeIds();n.stackShapes(I,"vertical",16),We(n,I)}},{id:"stack-horizontal",label:{default:"action.stack-horizontal","context-menu":"action.stack-horizontal.short"},icon:"stack-horizontal",onSelect(C){if(!v()||S())return;g("stack-shapes",{operation:"horizontal",source:C}),n.mark("stack-horizontal");const I=n.getSelectedShapeIds();n.stackShapes(I,"horizontal",16),We(n,I)}},{id:"bring-to-front",label:"action.bring-to-front",kbd:"]",icon:"bring-to-front",onSelect(C){v()&&(S()||(g("reorder-shapes",{operation:"toFront",source:C}),n.mark("bring to front"),n.bringToFront(n.getSelectedShapeIds())))}},{id:"bring-forward",label:"action.bring-forward",icon:"bring-forward",kbd:"?]",onSelect(C){v()&&(S()||(g("reorder-shapes",{operation:"forward",source:C}),n.mark("bring forward"),n.bringForward(n.getSelectedShapeIds())))}},{id:"send-backward",label:"action.send-backward",icon:"send-backward",kbd:"?[",onSelect(C){v()&&(S()||(g("reorder-shapes",{operation:"backward",source:C}),n.mark("send backward"),n.sendBackward(n.getSelectedShapeIds())))}},{id:"send-to-back",label:"action.send-to-back",icon:"send-to-back",kbd:"[",onSelect(C){v()&&(S()||(g("reorder-shapes",{operation:"toBack",source:C}),n.mark("send to back"),n.sendToBack(n.getSelectedShapeIds())))}},{id:"cut",label:"action.cut",kbd:"$x",onSelect(C){v()&&(S()||(n.mark("cut"),l(C)))}},{id:"copy",label:"action.copy",kbd:"$c",readonlyOk:!0,onSelect(C){v()&&(S()||u(C))}},{id:"paste",label:"action.paste",kbd:"$v",onSelect(C){var I;(I=navigator.clipboard)==null||I.read().then(_=>{d(_,C,C==="context-menu"?n.inputs.currentPagePoint:void 0)})}},{id:"select-all",label:"action.select-all",kbd:"$a",readonlyOk:!0,onSelect(C){n.batch(()=>{S()||(g("select-all-shapes",{source:C}),n.mark("select all kbd"),n.selectAll())})}},{id:"select-none",label:"action.select-none",readonlyOk:!0,onSelect(C){v()&&(S()||(g("select-none-shapes",{source:C}),n.mark("select none"),n.selectNone()))}},{id:"delete",label:"action.delete",kbd:"⌫,del,backspace",icon:"trash",onSelect(C){v()&&(S()||(g("delete-shapes",{source:C}),n.mark("delete"),n.deleteShapes(n.getSelectedShapeIds())))}},{id:"rotate-cw",label:"action.rotate-cw",icon:"rotate-cw",onSelect(C){if(!v()||S())return;g("rotate-cw",{source:C}),n.mark("rotate-cw");const I=n.getSelectionRotation()%(ze/2),_=Ml(I,0)||Ml(I,ze/2),k=n.getSelectedShapeIds();n.rotateShapesBy(k,ze/2-(_?0:I)),We(n,k)}},{id:"rotate-ccw",label:"action.rotate-ccw",icon:"rotate-ccw",onSelect(C){if(!v()||S())return;g("rotate-ccw",{source:C}),n.mark("rotate-ccw");const I=n.getSelectionRotation()%(ze/2),_=Ml(I,0),k=n.getSelectedShapeIds();n.rotateShapesBy(k,_?-(ze/2):-I),We(n,k)}},{id:"zoom-in",label:"action.zoom-in",kbd:"$=,=",readonlyOk:!0,onSelect(C){g("zoom-in",{source:C}),n.zoomIn(n.getViewportScreenCenter(),{duration:Qr})}},{id:"zoom-out",label:"action.zoom-out",kbd:"$-,-",readonlyOk:!0,onSelect(C){g("zoom-out",{source:C}),n.zoomOut(n.getViewportScreenCenter(),{duration:Qr})}},{id:"zoom-to-100",label:"action.zoom-to-100",icon:"reset-zoom",kbd:"!0",readonlyOk:!0,onSelect(C){g("reset-zoom",{source:C}),n.resetZoom(n.getViewportScreenCenter(),{duration:Qr})}},{id:"zoom-to-fit",label:"action.zoom-to-fit",kbd:"!1",readonlyOk:!0,onSelect(C){g("zoom-to-fit",{source:C}),n.zoomToFit({duration:Qr})}},{id:"zoom-to-selection",label:"action.zoom-to-selection",kbd:"!2",readonlyOk:!0,onSelect(C){v()&&(S()||(g("zoom-to-selection",{source:C}),n.zoomToSelection({duration:Qr})))}},{id:"toggle-snap-mode",label:{default:"action.toggle-snap-mode",menu:"action.toggle-snap-mode.menu"},onSelect(C){g("toggle-snap-mode",{source:C}),n.user.updateUserPreferences({isSnapMode:!n.user.getIsSnapMode()})},checkbox:!0},{id:"toggle-dark-mode",label:{default:"action.toggle-dark-mode",menu:"action.toggle-dark-mode.menu"},kbd:"$/",readonlyOk:!0,onSelect(C){g("toggle-dark-mode",{source:C}),n.user.updateUserPreferences({isDarkMode:!n.user.getIsDarkMode()})},checkbox:!0},{id:"toggle-wrap-mode",label:{default:"action.toggle-wrap-mode",menu:"action.toggle-wrap-mode.menu"},readonlyOk:!0,onSelect(C){g("toggle-wrap-mode",{source:C}),n.user.updateUserPreferences({isWrapMode:!n.user.getIsWrapMode()})},checkbox:!0},{id:"toggle-reduce-motion",label:{default:"action.toggle-reduce-motion",menu:"action.toggle-reduce-motion.menu"},readonlyOk:!0,onSelect(C){g("toggle-reduce-motion",{source:C}),n.user.updateUserPreferences({animationSpeed:n.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(C){g("toggle-edge-scrolling",{source:C}),n.user.updateUserPreferences({edgeScrollSpeed:n.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(C){g("toggle-transparent",{source:C}),n.updateInstanceState({exportBackground:!n.getInstanceState().exportBackground},{ephemeral:!0})},checkbox:!0},{id:"toggle-tool-lock",label:{default:"action.toggle-tool-lock",menu:"action.toggle-tool-lock.menu"},kbd:"q",onSelect(C){g("toggle-tool-lock",{source:C}),n.updateInstanceState({isToolLocked:!n.getInstanceState().isToolLocked})},checkbox:!0},{id:"unlock-all",label:"action.unlock-all",onSelect(C){g("unlock-all",{source:C});const I=[];for(const _ of n.getCurrentPageShapes())_.isLocked&&I.push({id:_.id,type:_.type,isLocked:!1});I.length>0&&n.updateShapes(I)}},{id:"toggle-focus-mode",label:{default:"action.toggle-focus-mode",menu:"action.toggle-focus-mode.menu"},readonlyOk:!0,kbd:"$.",checkbox:!0,onSelect(C){requestAnimationFrame(()=>{n.batch(()=>{g("toggle-focus-mode",{source:C}),o(),s(),n.updateInstanceState({isFocusMode:!n.getInstanceState().isFocusMode})})})}},{id:"toggle-grid",label:{default:"action.toggle-grid",menu:"action.toggle-grid.menu"},readonlyOk:!0,kbd:"$'",onSelect(C){g("toggle-grid-mode",{source:C}),n.updateInstanceState({isGridMode:!n.getInstanceState().isGridMode})},checkbox:!0},{id:"toggle-debug-mode",label:{default:"action.toggle-debug-mode",menu:"action.toggle-debug-mode.menu"},readonlyOk:!0,onSelect(C){g("toggle-debug-mode",{source:C}),n.updateInstanceState({isDebugMode:!n.getInstanceState().isDebugMode})},checkbox:!0},{id:"print",label:"action.print",kbd:"$p",readonlyOk:!0,onSelect(C){g("print",{source:C}),c()}},{id:"exit-pen-mode",label:"action.exit-pen-mode",icon:"cross-2",readonlyOk:!0,onSelect(C){g("exit-pen-mode",{source:C}),n.updateInstanceState({isPenMode:!1})}},{id:"stop-following",label:"action.stop-following",icon:"cross-2",readonlyOk:!0,onSelect(C){g("stop-following",{source:C}),n.stopFollowingUser()}},{id:"back-to-content",label:"action.back-to-content",icon:"arrow-left",readonlyOk:!0,onSelect(C){g("zoom-to-content",{source:C}),n.zoomToContent()}},{id:"toggle-lock",label:"action.toggle-lock",kbd:"!l",onSelect(C){n.mark("locking"),g("toggle-lock",{source:C}),n.toggleLock(n.getSelectedShapeIds())}},{id:"new-page",label:"context.pages.new-page",onSelect(C){const I=Ho.createId(),_=n.getSelectedShapeIds();n.batch(()=>{n.mark("move_shapes_to_page"),n.createPage({name:i("page-menu.new-page-initial-name"),id:I}),n.moveShapesToPage(_,I)}),g("new-page",{source:C})}},{id:"select-white-color",label:"color-style.white",kbd:"?t",onSelect(C){const I=tr;n.batch(()=>{n.mark("change-color"),n.isIn("select")&&n.setStyleForSelectedShapes(I,"white",{squashing:!1}),n.setStyleForNextShapes(I,"white",{squashing:!1}),n.updateInstanceState({isChangingStyle:!0},{ephemeral:!0})}),g("set-style",{source:C,id:I.id,value:"white"})}}]);return e?e(n,E,void 0):E},[n,g,e,r,a,f,p,l,u,d,o,s,c,i,y]);return h.jsx(JM.Provider,{value:w,children:t})}function ce(){const e=x.useContext(JM);if(!e)throw new Error("useTools must be used within a ToolProvider");return e}function gu(e,t){return e?typeof e=="string"?e:t?e[t]??e.default:void 0:void 0}const kZ=["top","right","bottom","left"],eo=Math.min,Vn=Math.max,uf=Math.round,qd=Math.floor,Us=e=>({x:e,y:e}),TZ={left:"right",right:"left",bottom:"top",top:"bottom"},$Z={start:"end",end:"start"};function kv(e,t,n){return Vn(e,eo(t,n))}function Go(e,t){return typeof e=="function"?e(t):e}function Yo(e){return e.split("-")[0]}function kc(e){return e.split("-")[1]}function ew(e){return e==="x"?"y":"x"}function tw(e){return e==="y"?"height":"width"}function Tc(e){return["top","bottom"].includes(Yo(e))?"y":"x"}function nw(e){return ew(Tc(e))}function MZ(e,t,n){n===void 0&&(n=!1);const r=kc(e),o=nw(e),s=tw(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=df(i)),[i,df(i)]}function AZ(e){const t=df(e);return[Tv(e),t,Tv(t)]}function Tv(e){return e.replace(/start|end/g,t=>$Z[t])}function jZ(e,t,n){const r=["left","right"],o=["right","left"],s=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?s:i;default:return[]}}function OZ(e,t,n,r){const o=kc(e);let s=jZ(Yo(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Tv)))),s}function df(e){return e.replace(/left|right|bottom|top/g,t=>TZ[t])}function DZ(e){return{top:0,right:0,bottom:0,left:0,...e}}function eA(e){return typeof e!="number"?DZ(e):{top:e,right:e,bottom:e,left:e}}function hf(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function eI(e,t,n){let{reference:r,floating:o}=e;const s=Tc(t),i=nw(t),a=tw(i),c=Yo(t),l=s==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let f;switch(c){case"top":f={x:u,y:r.y-o.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-o.width,y:d};break;default:f={x:r.x,y:r.y}}switch(kc(t)){case"start":f[i]-=p*(n&&l?-1:1);break;case"end":f[i]+=p*(n&&l?-1:1);break}return f}const RZ=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=eI(l,r,c),p=r,f={},y=0;for(let g=0;g<a.length;g++){const{name:w,fn:S}=a[g],{x:v,y:b,data:E,reset:C}=await S({x:u,y:d,initialPlacement:r,placement:p,strategy:o,middlewareData:f,rects:l,platform:i,elements:{reference:e,floating:t}});u=v??u,d=b??d,f={...f,[w]:{...f[w],...E}},C&&y<=50&&(y++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(l=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:u,y:d}=eI(l,p,c)),g=-1)}return{x:u,y:d,placement:p,strategy:o,middlewareData:f}};async function mu(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:p=!1,padding:f=0}=Go(t,e),y=eA(f),w=a[p?d==="floating"?"reference":"floating":d],S=hf(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:l,rootBoundary:u,strategy:c})),v=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,b=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(b))?await(s.getScale==null?void 0:s.getScale(b))||{x:1,y:1}:{x:1,y:1},C=hf(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:b,strategy:c}):v);return{top:(S.top-C.top+y.top)/E.y,bottom:(C.bottom-S.bottom+y.bottom)/E.y,left:(S.left-C.left+y.left)/E.x,right:(C.right-S.right+y.right)/E.x}}const LZ=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:l,padding:u=0}=Go(e,t)||{};if(l==null)return{};const d=eA(u),p={x:n,y:r},f=nw(o),y=tw(f),g=await i.getDimensions(l),w=f==="y",S=w?"top":"left",v=w?"bottom":"right",b=w?"clientHeight":"clientWidth",E=s.reference[y]+s.reference[f]-p[f]-s.floating[y],C=p[f]-s.reference[f],I=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let _=I?I[b]:0;(!_||!await(i.isElement==null?void 0:i.isElement(I)))&&(_=a.floating[b]||s.floating[y]);const k=E/2-C/2,$=_/2-g[y]/2-1,T=eo(d[S],$),O=eo(d[v],$),N=T,F=_-g[y]-O,L=_/2-g[y]/2+k,B=kv(N,L,F),q=!c.arrow&&kc(o)!=null&&L!==B&&s.reference[y]/2-(L<N?T:O)-g[y]/2<0,Q=q?L<N?L-N:L-F:0;return{[f]:p[f]+Q,data:{[f]:B,centerOffset:L-B-Q,...q&&{alignmentOffset:Q}},reset:q}}}),FZ=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:c,elements:l}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:g=!0,...w}=Go(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const S=Yo(o),v=Yo(a)===a,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),E=p||(v||!g?[df(a)]:AZ(a));!p&&y!=="none"&&E.push(...OZ(a,g,y,b));const C=[a,...E],I=await mu(t,w),_=[];let k=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&_.push(I[S]),d){const N=MZ(o,i,b);_.push(I[N[0]],I[N[1]])}if(k=[...k,{placement:o,overflows:_}],!_.every(N=>N<=0)){var $,T;const N=((($=s.flip)==null?void 0:$.index)||0)+1,F=C[N];if(F)return{data:{index:N,overflows:k},reset:{placement:F}};let L=(T=k.filter(B=>B.overflows[0]<=0).sort((B,q)=>B.overflows[1]-q.overflows[1])[0])==null?void 0:T.placement;if(!L)switch(f){case"bestFit":{var O;const B=(O=k.map(q=>[q.placement,q.overflows.filter(Q=>Q>0).reduce((Q,H)=>Q+H,0)]).sort((q,Q)=>q[1]-Q[1])[0])==null?void 0:O[0];B&&(L=B);break}case"initialPlacement":L=a;break}if(o!==L)return{reset:{placement:L}}}return{}}}};function tI(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function nI(e){return kZ.some(t=>e[t]>=0)}const NZ=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Go(e,t);switch(r){case"referenceHidden":{const s=await mu(t,{...o,elementContext:"reference"}),i=tI(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:nI(i)}}}case"escaped":{const s=await mu(t,{...o,altBoundary:!0}),i=tI(s,n.floating);return{data:{escapedOffsets:i,escaped:nI(i)}}}default:return{}}}}};async function zZ(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Yo(n),a=kc(n),c=Tc(n)==="y",l=["left","top"].includes(i)?-1:1,u=s&&c?-1:1,d=Go(t,e);let{mainAxis:p,crossAxis:f,alignmentAxis:y}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return a&&typeof y=="number"&&(f=a==="end"?y*-1:y),c?{x:f*u,y:p*l}:{x:p*l,y:f*u}}const BZ=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,c=await zZ(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},UZ=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:w=>{let{x:S,y:v}=w;return{x:S,y:v}}},...c}=Go(e,t),l={x:n,y:r},u=await mu(t,c),d=Tc(Yo(o)),p=ew(d);let f=l[p],y=l[d];if(s){const w=p==="y"?"top":"left",S=p==="y"?"bottom":"right",v=f+u[w],b=f-u[S];f=kv(v,f,b)}if(i){const w=d==="y"?"top":"left",S=d==="y"?"bottom":"right",v=y+u[w],b=y-u[S];y=kv(v,y,b)}const g=a.fn({...t,[p]:f,[d]:y});return{...g,data:{x:g.x-n,y:g.y-r}}}}},HZ=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:l=!0}=Go(e,t),u={x:n,y:r},d=Tc(o),p=ew(d);let f=u[p],y=u[d];const g=Go(a,t),w=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const b=p==="y"?"height":"width",E=s.reference[p]-s.floating[b]+w.mainAxis,C=s.reference[p]+s.reference[b]-w.mainAxis;f<E?f=E:f>C&&(f=C)}if(l){var S,v;const b=p==="y"?"width":"height",E=["top","left"].includes(Yo(o)),C=s.reference[d]-s.floating[b]+(E&&((S=i.offset)==null?void 0:S[d])||0)+(E?0:w.crossAxis),I=s.reference[d]+s.reference[b]+(E?0:((v=i.offset)==null?void 0:v[d])||0)-(E?w.crossAxis:0);y<C?y=C:y>I&&(y=I)}return{[p]:f,[d]:y}}}},KZ=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:o,elements:s}=t,{apply:i=()=>{},...a}=Go(e,t),c=await mu(t,a),l=Yo(n),u=kc(n),d=Tc(n)==="y",{width:p,height:f}=r.floating;let y,g;l==="top"||l==="bottom"?(y=l,g=u===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(g=l,y=u==="end"?"top":"bottom");const w=f-c.top-c.bottom,S=p-c.left-c.right,v=eo(f-c[y],w),b=eo(p-c[g],S),E=!t.middlewareData.shift;let C=v,I=b;if(d?I=u||E?eo(b,S):S:C=u||E?eo(v,w):w,E&&!u){const k=Vn(c.left,0),$=Vn(c.right,0),T=Vn(c.top,0),O=Vn(c.bottom,0);d?I=p-2*(k!==0||$!==0?k+$:Vn(c.left,c.right)):C=f-2*(T!==0||O!==0?T+O:Vn(c.top,c.bottom))}await i({...t,availableWidth:I,availableHeight:C});const _=await o.getDimensions(s.floating);return p!==_.width||f!==_.height?{reset:{rects:!0}}:{}}}};function $c(e){return tA(e)?(e.nodeName||"").toLowerCase():"#document"}function Qn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function os(e){var t;return(t=(tA(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function tA(e){return e instanceof Node||e instanceof Qn(e).Node}function uo(e){return e instanceof Element||e instanceof Qn(e).Element}function ho(e){return e instanceof HTMLElement||e instanceof Qn(e).HTMLElement}function rI(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qn(e).ShadowRoot}function Uu(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Ur(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function WZ(e){return["table","td","th"].includes($c(e))}function rw(e){const t=ow(),n=Ur(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function VZ(e){let t=Hs(e);for(;ho(t)&&!hc(t);){if(rw(t))return t;t=Hs(t)}return null}function ow(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function hc(e){return["html","body","#document"].includes($c(e))}function Ur(e){return Qn(e).getComputedStyle(e)}function fg(e){return uo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Hs(e){if($c(e)==="html")return e;const t=e.assignedSlot||e.parentNode||rI(e)&&e.host||os(e);return rI(t)?t.host:t}function nA(e){const t=Hs(e);return hc(t)?e.ownerDocument?e.ownerDocument.body:e.body:ho(t)&&Uu(t)?t:nA(t)}function yu(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=nA(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qn(o);return s?t.concat(i,i.visualViewport||[],Uu(o)?o:[],i.frameElement&&n?yu(i.frameElement):[]):t.concat(o,yu(o,[],n))}function rA(e){const t=Ur(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=ho(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=uf(n)!==s||uf(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function sw(e){return uo(e)?e:e.contextElement}function qa(e){const t=sw(e);if(!ho(t))return Us(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=rA(t);let i=(s?uf(n.width):n.width)/r,a=(s?uf(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const GZ=Us(0);function oA(e){const t=Qn(e);return!ow()||!t.visualViewport?GZ:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function YZ(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qn(e)?!1:t}function Ri(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=sw(e);let i=Us(1);t&&(r?uo(r)&&(i=qa(r)):i=qa(e));const a=YZ(s,n,r)?oA(s):Us(0);let c=(o.left+a.x)/i.x,l=(o.top+a.y)/i.y,u=o.width/i.x,d=o.height/i.y;if(s){const p=Qn(s),f=r&&uo(r)?Qn(r):r;let y=p,g=y.frameElement;for(;g&&r&&f!==y;){const w=qa(g),S=g.getBoundingClientRect(),v=Ur(g),b=S.left+(g.clientLeft+parseFloat(v.paddingLeft))*w.x,E=S.top+(g.clientTop+parseFloat(v.paddingTop))*w.y;c*=w.x,l*=w.y,u*=w.x,d*=w.y,c+=b,l+=E,y=Qn(g),g=y.frameElement}}return hf({width:u,height:d,x:c,y:l})}const XZ=[":popover-open",":modal"];function iw(e){return XZ.some(t=>{try{return e.matches(t)}catch{return!1}})}function qZ(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=os(r),a=t?iw(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},l=Us(1);const u=Us(0),d=ho(r);if((d||!d&&!s)&&(($c(r)!=="body"||Uu(i))&&(c=fg(r)),ho(r))){const p=Ri(r);l=qa(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x,y:n.y*l.y-c.scrollTop*l.y+u.y}}function ZZ(e){return Array.from(e.getClientRects())}function sA(e){return Ri(os(e)).left+fg(e).scrollLeft}function QZ(e){const t=os(e),n=fg(e),r=e.ownerDocument.body,o=Vn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Vn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+sA(e);const a=-n.scrollTop;return Ur(r).direction==="rtl"&&(i+=Vn(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function JZ(e,t){const n=Qn(e),r=os(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const l=ow();(!l||l&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}function eQ(e,t){const n=Ri(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=ho(e)?qa(e):Us(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,l=r*s.y;return{width:i,height:a,x:c,y:l}}function oI(e,t,n){let r;if(t==="viewport")r=JZ(e,n);else if(t==="document")r=QZ(os(e));else if(uo(t))r=eQ(t,n);else{const o=oA(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return hf(r)}function iA(e,t){const n=Hs(e);return n===t||!uo(n)||hc(n)?!1:Ur(n).position==="fixed"||iA(n,t)}function tQ(e,t){const n=t.get(e);if(n)return n;let r=yu(e,[],!1).filter(a=>uo(a)&&$c(a)!=="body"),o=null;const s=Ur(e).position==="fixed";let i=s?Hs(e):e;for(;uo(i)&&!hc(i);){const a=Ur(i),c=rw(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Uu(i)&&!c&&iA(e,i))?r=r.filter(u=>u!==i):o=a,i=Hs(i)}return t.set(e,r),r}function nQ(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?iw(t)?[]:tQ(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((l,u)=>{const d=oI(t,u,o);return l.top=Vn(d.top,l.top),l.right=eo(d.right,l.right),l.bottom=eo(d.bottom,l.bottom),l.left=Vn(d.left,l.left),l},oI(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function rQ(e){const{width:t,height:n}=rA(e);return{width:t,height:n}}function oQ(e,t,n){const r=ho(t),o=os(t),s=n==="fixed",i=Ri(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=Us(0);if(r||!r&&!s)if(($c(t)!=="body"||Uu(o))&&(a=fg(t)),r){const d=Ri(t,!0,s,t);c.x=d.x+t.clientLeft,c.y=d.y+t.clientTop}else o&&(c.x=sA(o));const l=i.left+a.scrollLeft-c.x,u=i.top+a.scrollTop-c.y;return{x:l,y:u,width:i.width,height:i.height}}function uy(e){return Ur(e).position==="static"}function sI(e,t){return!ho(e)||Ur(e).position==="fixed"?null:t?t(e):e.offsetParent}function aA(e,t){const n=Qn(e);if(iw(e))return n;if(!ho(e)){let o=Hs(e);for(;o&&!hc(o);){if(uo(o)&&!uy(o))return o;o=Hs(o)}return n}let r=sI(e,t);for(;r&&WZ(r)&&uy(r);)r=sI(r,t);return r&&hc(r)&&uy(r)&&!rw(r)?n:r||VZ(e)||n}const sQ=async function(e){const t=this.getOffsetParent||aA,n=this.getDimensions,r=await n(e.floating);return{reference:oQ(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function iQ(e){return Ur(e).direction==="rtl"}const aQ={convertOffsetParentRelativeRectToViewportRelativeRect:qZ,getDocumentElement:os,getClippingRect:nQ,getOffsetParent:aA,getElementRects:sQ,getClientRects:ZZ,getDimensions:rQ,getScale:qa,isElement:uo,isRTL:iQ};function cQ(e,t){let n=null,r;const o=os(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const{left:l,top:u,width:d,height:p}=e.getBoundingClientRect();if(a||t(),!d||!p)return;const f=qd(u),y=qd(o.clientWidth-(l+d)),g=qd(o.clientHeight-(u+p)),w=qd(l),v={rootMargin:-f+"px "+-y+"px "+-g+"px "+-w+"px",threshold:Vn(0,eo(1,c))||1};let b=!0;function E(C){const I=C[0].intersectionRatio;if(I!==c){if(!b)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}b=!1}try{n=new IntersectionObserver(E,{...v,root:o.ownerDocument})}catch{n=new IntersectionObserver(E,v)}n.observe(e)}return i(!0),s}function lQ(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,l=sw(e),u=o||s?[...l?yu(l):[],...yu(t)]:[];u.forEach(S=>{o&&S.addEventListener("scroll",n,{passive:!0}),s&&S.addEventListener("resize",n)});const d=l&&a?cQ(l,n):null;let p=-1,f=null;i&&(f=new ResizeObserver(S=>{let[v]=S;v&&v.target===l&&f&&(f.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var b;(b=f)==null||b.observe(t)})),n()}),l&&!c&&f.observe(l),f.observe(t));let y,g=c?Ri(e):null;c&&w();function w(){const S=Ri(e);g&&(S.x!==g.x||S.y!==g.y||S.width!==g.width||S.height!==g.height)&&n(),g=S,y=requestAnimationFrame(w)}return n(),()=>{var S;u.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),d==null||d(),(S=f)==null||S.disconnect(),f=null,c&&cancelAnimationFrame(y)}}const uQ=BZ,dQ=UZ,hQ=FZ,pQ=KZ,fQ=NZ,iI=LZ,gQ=HZ,mQ=(e,t,n)=>{const r=new Map,o={platform:aQ,...n},s={...o.platform,_c:r};return RZ(e,t,{...o,platform:s})};var np=typeof document<"u"?x.useLayoutEffect:x.useEffect;function pf(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!pf(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!pf(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function cA(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function aI(e,t){const n=cA(e);return Math.round(t*n)/n}function cI(e){const t=x.useRef(e);return np(()=>{t.current=e}),t}function yQ(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:c,open:l}=e,[u,d]=x.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,f]=x.useState(r);pf(p,r)||f(r);const[y,g]=x.useState(null),[w,S]=x.useState(null),v=x.useCallback(Q=>{Q!==I.current&&(I.current=Q,g(Q))},[]),b=x.useCallback(Q=>{Q!==_.current&&(_.current=Q,S(Q))},[]),E=s||y,C=i||w,I=x.useRef(null),_=x.useRef(null),k=x.useRef(u),$=c!=null,T=cI(c),O=cI(o),N=x.useCallback(()=>{if(!I.current||!_.current)return;const Q={placement:t,strategy:n,middleware:p};O.current&&(Q.platform=O.current),mQ(I.current,_.current,Q).then(H=>{const U={...H,isPositioned:!0};F.current&&!pf(k.current,U)&&(k.current=U,Ui.flushSync(()=>{d(U)}))})},[p,t,n,O]);np(()=>{l===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,d(Q=>({...Q,isPositioned:!1})))},[l]);const F=x.useRef(!1);np(()=>(F.current=!0,()=>{F.current=!1}),[]),np(()=>{if(E&&(I.current=E),C&&(_.current=C),E&&C){if(T.current)return T.current(E,C,N);N()}},[E,C,N,T,$]);const L=x.useMemo(()=>({reference:I,floating:_,setReference:v,setFloating:b}),[v,b]),B=x.useMemo(()=>({reference:E,floating:C}),[E,C]),q=x.useMemo(()=>{const Q={position:n,left:0,top:0};if(!B.floating)return Q;const H=aI(B.floating,u.x),U=aI(B.floating,u.y);return a?{...Q,transform:"translate("+H+"px, "+U+"px)",...cA(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:H,top:U}},[n,a,B.floating,u.x,u.y]);return x.useMemo(()=>({...u,update:N,refs:L,elements:B,floatingStyles:q}),[u,N,L,B,q])}const SQ=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?iI({element:r.current,padding:o}).fn(n):{}:r?iI({element:r,padding:o}).fn(n):{}}}},vQ=(e,t)=>({...uQ(e),options:[e,t]}),xQ=(e,t)=>({...dQ(e),options:[e,t]}),wQ=(e,t)=>({...gQ(e),options:[e,t]}),bQ=(e,t)=>({...hQ(e),options:[e,t]}),PQ=(e,t)=>({...pQ(e),options:[e,t]}),CQ=(e,t)=>({...fQ(e),options:[e,t]}),IQ=(e,t)=>({...SQ(e),options:[e,t]});function lA(e){const[t,n]=x.useState(void 0);return Di(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const c=s.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,a=l.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const uA="Popper",[dA,gg]=mo(uA),[EQ,hA]=dA(uA),_Q=e=>{const{__scopePopper:t,children:n}=e,[r,o]=x.useState(null);return x.createElement(EQ,{scope:t,anchor:r,onAnchorChange:o},n)},kQ="PopperAnchor",TQ=x.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=hA(kQ,n),i=x.useRef(null),a=Xe(t,i);return x.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:x.createElement(Ke.div,X({},o,{ref:a}))}),pA="PopperContent",[$Q,Ioe]=dA(pA),MQ=x.forwardRef((e,t)=>{var n,r,o,s,i,a,c,l;const{__scopePopper:u,side:d="bottom",sideOffset:p=0,align:f="center",alignOffset:y=0,arrowPadding:g=0,avoidCollisions:w=!0,collisionBoundary:S=[],collisionPadding:v=0,sticky:b="partial",hideWhenDetached:E=!1,updatePositionStrategy:C="optimized",onPlaced:I,..._}=e,k=hA(pA,u),[$,T]=x.useState(null),O=Xe(t,qe=>T(qe)),[N,F]=x.useState(null),L=lA(N),B=(n=L==null?void 0:L.width)!==null&&n!==void 0?n:0,q=(r=L==null?void 0:L.height)!==null&&r!==void 0?r:0,Q=d+(f!=="center"?"-"+f:""),H=typeof v=="number"?v:{top:0,right:0,bottom:0,left:0,...v},U=Array.isArray(S)?S:[S],W=U.length>0,Z={padding:H,boundary:U.filter(AQ),altBoundary:W},{refs:le,floatingStyles:be,placement:Me,isPositioned:ae,middlewareData:Ae}=yQ({strategy:"fixed",placement:Q,whileElementsMounted:(...qe)=>lQ(...qe,{animationFrame:C==="always"}),elements:{reference:k.anchor},middleware:[vQ({mainAxis:p+q,alignmentAxis:y}),w&&xQ({mainAxis:!0,crossAxis:!1,limiter:b==="partial"?wQ():void 0,...Z}),w&&bQ({...Z}),PQ({...Z,apply:({elements:qe,rects:Ot,availableWidth:wo,availableHeight:Ac})=>{const{width:jc,height:bg}=Ot.reference,qi=qe.floating.style;qi.setProperty("--radix-popper-available-width",`${wo}px`),qi.setProperty("--radix-popper-available-height",`${Ac}px`),qi.setProperty("--radix-popper-anchor-width",`${jc}px`),qi.setProperty("--radix-popper-anchor-height",`${bg}px`)}}),N&&IQ({element:N,padding:g}),jQ({arrowWidth:B,arrowHeight:q}),E&&CQ({strategy:"referenceHidden",...Z})]}),[Re,ot]=fA(Me),Ie=sn(I);Di(()=>{ae&&(Ie==null||Ie())},[ae,Ie]);const ht=(o=Ae.arrow)===null||o===void 0?void 0:o.x,He=(s=Ae.arrow)===null||s===void 0?void 0:s.y,ir=((i=Ae.arrow)===null||i===void 0?void 0:i.centerOffset)!==0,[Ln,Fn]=x.useState();return Di(()=>{$&&Fn(window.getComputedStyle($).zIndex)},[$]),x.createElement("div",{ref:le.setFloating,"data-radix-popper-content-wrapper":"",style:{...be,transform:ae?be.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ln,"--radix-popper-transform-origin":[(a=Ae.transformOrigin)===null||a===void 0?void 0:a.x,(c=Ae.transformOrigin)===null||c===void 0?void 0:c.y].join(" ")},dir:e.dir},x.createElement($Q,{scope:u,placedSide:Re,onArrowChange:F,arrowX:ht,arrowY:He,shouldHideArrow:ir},x.createElement(Ke.div,X({"data-side":Re,"data-align":ot},_,{ref:O,style:{..._.style,animation:ae?void 0:"none",opacity:(l=Ae.hide)!==null&&l!==void 0&&l.referenceHidden?0:void 0}}))))});function AQ(e){return e!==null}const jQ=e=>({name:"transformOrigin",options:e,fn(t){var n,r,o,s,i;const{placement:a,rects:c,middlewareData:l}=t,d=((n=l.arrow)===null||n===void 0?void 0:n.centerOffset)!==0,p=d?0:e.arrowWidth,f=d?0:e.arrowHeight,[y,g]=fA(a),w={start:"0%",center:"50%",end:"100%"}[g],S=((r=(o=l.arrow)===null||o===void 0?void 0:o.x)!==null&&r!==void 0?r:0)+p/2,v=((s=(i=l.arrow)===null||i===void 0?void 0:i.y)!==null&&s!==void 0?s:0)+f/2;let b="",E="";return y==="bottom"?(b=d?w:`${S}px`,E=`${-f}px`):y==="top"?(b=d?w:`${S}px`,E=`${c.floating.height+f}px`):y==="right"?(b=`${-f}px`,E=d?w:`${v}px`):y==="left"&&(b=`${c.floating.width+f}px`,E=d?w:`${v}px`),{data:{x:b,y:E}}}});function fA(e){const[t,n="center"]=e.split("-");return[t,n]}const aw=_Q,gA=TQ,mA=MQ,yA="Popover",[SA,Eoe]=mo(yA,[gg]),cw=gg(),[OQ,Mc]=SA(yA),DQ=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=cw(t),c=x.useRef(null),[l,u]=x.useState(!1),[d=!1,p]=Zs({prop:r,defaultProp:o,onChange:s});return x.createElement(aw,a,x.createElement(OQ,{scope:t,contentId:Fo(),triggerRef:c,open:d,onOpenChange:p,onOpenToggle:x.useCallback(()=>p(f=>!f),[p]),hasCustomAnchor:l,onCustomAnchorAdd:x.useCallback(()=>u(!0),[]),onCustomAnchorRemove:x.useCallback(()=>u(!1),[]),modal:i},n))},RQ="PopoverTrigger",LQ=x.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Mc(RQ,n),s=cw(n),i=Xe(t,o.triggerRef),a=x.createElement(Ke.button,X({type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":wA(o.open)},r,{ref:i,onClick:ie(e.onClick,o.onOpenToggle)}));return o.hasCustomAnchor?a:x.createElement(gA,X({asChild:!0},s),a)}),vA="PopoverPortal",[FQ,NQ]=SA(vA,{forceMount:void 0}),zQ=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=Mc(vA,t);return x.createElement(FQ,{scope:t,forceMount:n},x.createElement(yo,{present:n||s.open},x.createElement(ig,{asChild:!0,container:o},r)))},Su="PopoverContent",BQ=x.forwardRef((e,t)=>{const n=NQ(Su,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=Mc(Su,e.__scopePopover);return x.createElement(yo,{present:r||s.open},s.modal?x.createElement(UQ,X({},o,{ref:t})):x.createElement(HQ,X({},o,{ref:t})))}),UQ=x.forwardRef((e,t)=>{const n=Mc(Su,e.__scopePopover),r=x.useRef(null),o=Xe(t,r),s=x.useRef(!1);return x.useEffect(()=>{const i=r.current;if(i)return qx(i)},[]),x.createElement(ug,{as:Oi,allowPinchZoom:!0},x.createElement(xA,X({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,i=>{var a;i.preventDefault(),s.current||(a=n.triggerRef.current)===null||a===void 0||a.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0,l=a.button===2||c;s.current=l},{checkForDefaultPrevented:!1}),onFocusOutside:ie(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})))}),HQ=x.forwardRef((e,t)=>{const n=Mc(Su,e.__scopePopover),r=x.useRef(!1),o=x.useRef(!1);return x.createElement(xA,X({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i;if((i=e.onCloseAutoFocus)===null||i===void 0||i.call(e,s),!s.defaultPrevented){var a;r.current||(a=n.triggerRef.current)===null||a===void 0||a.focus(),s.preventDefault()}r.current=!1,o.current=!1},onInteractOutside:s=>{var i,a;(i=e.onInteractOutside)===null||i===void 0||i.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=s.target;((a=n.triggerRef.current)===null||a===void 0?void 0:a.contains(c))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}}))}),xA=x.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,p=Mc(Su,n),f=cw(n);return Xx(),x.createElement(Yx,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s},x.createElement(sg,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>p.onOpenChange(!1)},x.createElement(mA,X({"data-state":wA(p.open),role:"dialog",id:p.contentId},f,d,{ref:t,style:{...d.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)"}}))))});function wA(e){return e?"open":"closed"}const KQ=DQ,WQ=LQ,VQ=zQ,GQ=BQ;function Qs(e,t){const n=z(),r=x.useRef(!1),o=So(),s=x.useCallback(a=>{r.current=a,n.batch(()=>{a?(n.complete(),n.addOpenMenu(e)):n.updateInstanceState({openMenus:n.getOpenMenus().filter(c=>!c.startsWith(e))}),t==null||t(a)})},[n,e,t]),i=K("is menu open",()=>n.getOpenMenus().includes(e),[n,e]);return x.useEffect(()=>(r.current&&(o("open-menu",{source:"unknown",id:e}),n.addOpenMenu(e)),()=>{r.current&&(n.deleteOpenMenu(e),n.getOpenMenus().forEach(a=>{a.startsWith(e)&&(o("close-menu",{source:"unknown",id:e}),n.deleteOpenMenu(a))}),r.current=!1)}),[n,e,o]),[i,s]}function lw({id:e,children:t,onOpenChange:n,open:r}){const[o,s]=Qs(e,n);return h.jsx(KQ,{onOpenChange:s,open:r||o,children:h.jsx("div",{className:"tlui-popover",children:t})})}function uw({children:e}){return h.jsx(WQ,{asChild:!0,dir:"ltr",children:e})}function dw({side:e,children:t,align:n="center",sideOffset:r=8,alignOffset:o=0}){const s=cn();return h.jsx(VQ,{container:s,children:h.jsx(GQ,{className:"tlui-popover__content",side:e,sideOffset:r,align:n,alignOffset:o,dir:"ltr",children:t})})}const bA=x.createContext({type:"menu",sourceId:"main-menu"});function mg(){return x.useContext(bA)}function vr({type:e,sourceId:t,children:n}){return h.jsx(bA.Provider,{value:{type:e,sourceId:t},children:n})}const YQ=x.createContext(void 0);function hw(e){const t=x.useContext(YQ);return e||t||"ltr"}const dy="rovingFocusGroup.onEntryFocus",XQ={bubbles:!1,cancelable:!0},pw="RovingFocusGroup",[$v,PA,qQ]=og(pw),[ZQ,CA]=mo(pw,[qQ]),[QQ,JQ]=ZQ(pw),eJ=x.forwardRef((e,t)=>x.createElement($v.Provider,{scope:e.__scopeRovingFocusGroup},x.createElement($v.Slot,{scope:e.__scopeRovingFocusGroup},x.createElement(tJ,X({},e,{ref:t}))))),tJ=x.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:l,...u}=e,d=x.useRef(null),p=Xe(t,d),f=hw(s),[y=null,g]=Zs({prop:i,defaultProp:a,onChange:c}),[w,S]=x.useState(!1),v=sn(l),b=PA(n),E=x.useRef(!1),[C,I]=x.useState(0);return x.useEffect(()=>{const _=d.current;if(_)return _.addEventListener(dy,v),()=>_.removeEventListener(dy,v)},[v]),x.createElement(QQ,{scope:n,orientation:r,dir:f,loop:o,currentTabStopId:y,onItemFocus:x.useCallback(_=>g(_),[g]),onItemShiftTab:x.useCallback(()=>S(!0),[]),onFocusableItemAdd:x.useCallback(()=>I(_=>_+1),[]),onFocusableItemRemove:x.useCallback(()=>I(_=>_-1),[])},x.createElement(Ke.div,X({tabIndex:w||C===0?-1:0,"data-orientation":r},u,{ref:p,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{E.current=!0}),onFocus:ie(e.onFocus,_=>{const k=!E.current;if(_.target===_.currentTarget&&k&&!w){const $=new CustomEvent(dy,XQ);if(_.currentTarget.dispatchEvent($),!$.defaultPrevented){const T=b().filter(B=>B.focusable),O=T.find(B=>B.active),N=T.find(B=>B.id===y),L=[O,N,...T].filter(Boolean).map(B=>B.ref.current);IA(L)}}E.current=!1}),onBlur:ie(e.onBlur,()=>S(!1))})))}),nJ="RovingFocusGroupItem",rJ=x.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,...i}=e,a=Fo(),c=s||a,l=JQ(nJ,n),u=l.currentTabStopId===c,d=PA(n),{onFocusableItemAdd:p,onFocusableItemRemove:f}=l;return x.useEffect(()=>{if(r)return p(),()=>f()},[r,p,f]),x.createElement($v.ItemSlot,{scope:n,id:c,focusable:r,active:o},x.createElement(Ke.span,X({tabIndex:u?0:-1,"data-orientation":l.orientation},i,{ref:t,onMouseDown:ie(e.onMouseDown,y=>{r?l.onItemFocus(c):y.preventDefault()}),onFocus:ie(e.onFocus,()=>l.onItemFocus(c)),onKeyDown:ie(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){l.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const g=iJ(y,l.orientation,l.dir);if(g!==void 0){y.preventDefault();let S=d().filter(v=>v.focusable).map(v=>v.ref.current);if(g==="last")S.reverse();else if(g==="prev"||g==="next"){g==="prev"&&S.reverse();const v=S.indexOf(y.currentTarget);S=l.loop?aJ(S,v+1):S.slice(v+1)}setTimeout(()=>IA(S))}})})))}),oJ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function sJ(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function iJ(e,t,n){const r=sJ(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return oJ[r]}function IA(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function aJ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const cJ=eJ,lJ=rJ,Mv=["Enter"," "],uJ=["ArrowDown","PageUp","Home"],EA=["ArrowUp","PageDown","End"],dJ=[...uJ,...EA],hJ={ltr:[...Mv,"ArrowRight"],rtl:[...Mv,"ArrowLeft"]},pJ={ltr:["ArrowLeft"],rtl:["ArrowRight"]},yg="Menu",[vu,fJ,gJ]=og(yg),[Xi,Sg]=mo(yg,[gJ,gg,CA]),vg=gg(),_A=CA(),[kA,Js]=Xi(yg),[mJ,Hu]=Xi(yg),yJ=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=vg(t),[c,l]=x.useState(null),u=x.useRef(!1),d=sn(s),p=hw(o);return x.useEffect(()=>{const f=()=>{u.current=!0,document.addEventListener("pointerdown",y,{capture:!0,once:!0}),document.addEventListener("pointermove",y,{capture:!0,once:!0})},y=()=>u.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",y,{capture:!0}),document.removeEventListener("pointermove",y,{capture:!0})}},[]),x.createElement(aw,a,x.createElement(kA,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l},x.createElement(mJ,{scope:t,onClose:x.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:p,modal:i},r)))},TA=x.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=vg(n);return x.createElement(gA,X({},o,r,{ref:t}))}),$A="MenuPortal",[SJ,MA]=Xi($A,{forceMount:void 0}),vJ=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Js($A,t);return x.createElement(SJ,{scope:t,forceMount:n},x.createElement(yo,{present:n||s.open},x.createElement(ig,{asChild:!0,container:o},r)))},Nr="MenuContent",[xJ,fw]=Xi(Nr),wJ=x.forwardRef((e,t)=>{const n=MA(Nr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Js(Nr,e.__scopeMenu),i=Hu(Nr,e.__scopeMenu);return x.createElement(vu.Provider,{scope:e.__scopeMenu},x.createElement(yo,{present:r||s.open},x.createElement(vu.Slot,{scope:e.__scopeMenu},i.modal?x.createElement(bJ,X({},o,{ref:t})):x.createElement(PJ,X({},o,{ref:t})))))}),bJ=x.forwardRef((e,t)=>{const n=Js(Nr,e.__scopeMenu),r=x.useRef(null),o=Xe(t,r);return x.useEffect(()=>{const s=r.current;if(s)return qx(s)},[]),x.createElement(gw,X({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))}),PJ=x.forwardRef((e,t)=>{const n=Js(Nr,e.__scopeMenu);return x.createElement(gw,X({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))}),gw=x.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:p,onDismiss:f,disableOutsideScroll:y,...g}=e,w=Js(Nr,n),S=Hu(Nr,n),v=vg(n),b=_A(n),E=fJ(n),[C,I]=x.useState(null),_=x.useRef(null),k=Xe(t,_,w.onContentChange),$=x.useRef(0),T=x.useRef(""),O=x.useRef(0),N=x.useRef(null),F=x.useRef("right"),L=x.useRef(0),B=y?ug:x.Fragment,q=y?{as:Oi,allowPinchZoom:!0}:void 0,Q=U=>{var W,Z;const le=T.current+U,be=E().filter(Ie=>!Ie.disabled),Me=document.activeElement,ae=(W=be.find(Ie=>Ie.ref.current===Me))===null||W===void 0?void 0:W.textValue,Ae=be.map(Ie=>Ie.textValue),Re=LJ(Ae,le,ae),ot=(Z=be.find(Ie=>Ie.textValue===Re))===null||Z===void 0?void 0:Z.ref.current;(function Ie(ht){T.current=ht,window.clearTimeout($.current),ht!==""&&($.current=window.setTimeout(()=>Ie(""),1e3))})(le),ot&&setTimeout(()=>ot.focus())};x.useEffect(()=>()=>window.clearTimeout($.current),[]),Xx();const H=x.useCallback(U=>{var W,Z;return F.current===((W=N.current)===null||W===void 0?void 0:W.side)&&NJ(U,(Z=N.current)===null||Z===void 0?void 0:Z.area)},[]);return x.createElement(xJ,{scope:n,searchRef:T,onItemEnter:x.useCallback(U=>{H(U)&&U.preventDefault()},[H]),onItemLeave:x.useCallback(U=>{var W;H(U)||((W=_.current)===null||W===void 0||W.focus(),I(null))},[H]),onTriggerLeave:x.useCallback(U=>{H(U)&&U.preventDefault()},[H]),pointerGraceTimerRef:O,onPointerGraceIntentChange:x.useCallback(U=>{N.current=U},[])},x.createElement(B,q,x.createElement(Yx,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,U=>{var W;U.preventDefault(),(W=_.current)===null||W===void 0||W.focus()}),onUnmountAutoFocus:i},x.createElement(sg,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:p,onDismiss:f},x.createElement(cJ,X({asChild:!0},b,{dir:S.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:I,onEntryFocus:ie(c,U=>{S.isUsingKeyboardRef.current||U.preventDefault()})}),x.createElement(mA,X({role:"menu","aria-orientation":"vertical","data-state":RA(w.open),"data-radix-menu-content":"",dir:S.dir},v,g,{ref:k,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,U=>{const Z=U.target.closest("[data-radix-menu-content]")===U.currentTarget,le=U.ctrlKey||U.altKey||U.metaKey,be=U.key.length===1;Z&&(U.key==="Tab"&&U.preventDefault(),!le&&be&&Q(U.key));const Me=_.current;if(U.target!==Me||!dJ.includes(U.key))return;U.preventDefault();const Ae=E().filter(Re=>!Re.disabled).map(Re=>Re.ref.current);EA.includes(U.key)&&Ae.reverse(),DJ(Ae)}),onBlur:ie(e.onBlur,U=>{U.currentTarget.contains(U.target)||(window.clearTimeout($.current),T.current="")}),onPointerMove:ie(e.onPointerMove,xu(U=>{const W=U.target,Z=L.current!==U.clientX;if(U.currentTarget.contains(W)&&Z){const le=U.clientX>L.current?"right":"left";F.current=le,L.current=U.clientX}}))})))))))}),CJ=x.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return x.createElement(Ke.div,X({role:"group"},r,{ref:t}))}),Av="MenuItem",lI="menu.itemSelect",AA=x.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=x.useRef(null),i=Hu(Av,e.__scopeMenu),a=fw(Av,e.__scopeMenu),c=Xe(t,s),l=x.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const p=new CustomEvent(lI,{bubbles:!0,cancelable:!0});d.addEventListener(lI,f=>r==null?void 0:r(f),{once:!0}),Vx(d,p),p.defaultPrevented?l.current=!1:i.onClose()}};return x.createElement(jA,X({},o,{ref:c,disabled:n,onClick:ie(e.onClick,u),onPointerDown:d=>{var p;(p=e.onPointerDown)===null||p===void 0||p.call(e,d),l.current=!0},onPointerUp:ie(e.onPointerUp,d=>{var p;l.current||(p=d.currentTarget)===null||p===void 0||p.click()}),onKeyDown:ie(e.onKeyDown,d=>{const p=a.searchRef.current!=="";n||p&&d.key===" "||Mv.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})}))}),jA=x.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=fw(Av,n),a=_A(n),c=x.useRef(null),l=Xe(t,c),[u,d]=x.useState(!1),[p,f]=x.useState("");return x.useEffect(()=>{const y=c.current;if(y){var g;f(((g=y.textContent)!==null&&g!==void 0?g:"").trim())}},[s.children]),x.createElement(vu.ItemSlot,{scope:n,disabled:r,textValue:o??p},x.createElement(lJ,X({asChild:!0},a,{focusable:!r}),x.createElement(Ke.div,X({role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0},s,{ref:l,onPointerMove:ie(e.onPointerMove,xu(y=>{r?i.onItemLeave(y):(i.onItemEnter(y),y.defaultPrevented||y.currentTarget.focus())})),onPointerLeave:ie(e.onPointerLeave,xu(y=>i.onItemLeave(y))),onFocus:ie(e.onFocus,()=>d(!0)),onBlur:ie(e.onBlur,()=>d(!1))}))))}),IJ=x.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return x.createElement(kJ,{scope:e.__scopeMenu,checked:n},x.createElement(AA,X({role:"menuitemcheckbox","aria-checked":jv(n)?"mixed":n},o,{ref:t,"data-state":OJ(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r(jv(n)?!0:!n),{checkForDefaultPrevented:!1})})))}),EJ="MenuRadioGroup";Xi(EJ,{value:void 0,onValueChange:()=>{}});const _J="MenuItemIndicator",[kJ,_oe]=Xi(_J,{checked:!1}),OA="MenuSub",[TJ,DA]=Xi(OA),$J=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:o}=e,s=Js(OA,t),i=vg(t),[a,c]=x.useState(null),[l,u]=x.useState(null),d=sn(o);return x.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),x.createElement(aw,i,x.createElement(kA,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u},x.createElement(TJ,{scope:t,contentId:Fo(),triggerId:Fo(),trigger:a,onTriggerChange:c},n)))},Zd="MenuSubTrigger",MJ=x.forwardRef((e,t)=>{const n=Js(Zd,e.__scopeMenu),r=Hu(Zd,e.__scopeMenu),o=DA(Zd,e.__scopeMenu),s=fw(Zd,e.__scopeMenu),i=x.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,l={__scopeMenu:e.__scopeMenu},u=x.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return x.useEffect(()=>u,[u]),x.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),c(null)}},[a,c]),x.createElement(TA,X({asChild:!0},l),x.createElement(jA,X({id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":RA(n.open)},e,{ref:rg(t,o.onTriggerChange),onClick:d=>{var p;(p=e.onClick)===null||p===void 0||p.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ie(e.onPointerMove,xu(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:ie(e.onPointerLeave,xu(d=>{var p;u();const f=(p=n.content)===null||p===void 0?void 0:p.getBoundingClientRect();if(f){var y;const g=(y=n.content)===null||y===void 0?void 0:y.dataset.side,w=g==="right",S=w?-5:5,v=f[w?"left":"right"],b=f[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+S,y:d.clientY},{x:v,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x:v,y:f.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ie(e.onKeyDown,d=>{const p=s.searchRef.current!=="";if(!(e.disabled||p&&d.key===" ")&&hJ[r.dir].includes(d.key)){var f;n.onOpenChange(!0),(f=n.content)===null||f===void 0||f.focus(),d.preventDefault()}})})))}),AJ="MenuSubContent",jJ=x.forwardRef((e,t)=>{const n=MA(Nr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Js(Nr,e.__scopeMenu),i=Hu(Nr,e.__scopeMenu),a=DA(AJ,e.__scopeMenu),c=x.useRef(null),l=Xe(t,c);return x.createElement(vu.Provider,{scope:e.__scopeMenu},x.createElement(yo,{present:r||s.open},x.createElement(vu.Slot,{scope:e.__scopeMenu},x.createElement(gw,X({id:a.contentId,"aria-labelledby":a.triggerId},o,{ref:l,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;i.isUsingKeyboardRef.current&&((d=c.current)===null||d===void 0||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ie(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ie(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:ie(e.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),p=pJ[i.dir].includes(u.key);if(d&&p){var f;s.onOpenChange(!1),(f=a.trigger)===null||f===void 0||f.focus(),u.preventDefault()}})})))))});function RA(e){return e?"open":"closed"}function jv(e){return e==="indeterminate"}function OJ(e){return jv(e)?"indeterminate":e?"checked":"unchecked"}function DJ(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function RJ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function LJ(e,t,n){const o=t.length>1&&Array.from(t).every(l=>l===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=RJ(e,Math.max(s,0));o.length===1&&(i=i.filter(l=>l!==n));const c=i.find(l=>l.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function FJ(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s].x,c=t[s].y,l=t[i].x,u=t[i].y;c>r!=u>r&&n<(l-a)*(r-c)/(u-c)+a&&(o=!o)}return o}function NJ(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return FJ(n,t)}function xu(e){return t=>t.pointerType==="mouse"?e(t):void 0}const LA=yJ,FA=TA,NA=vJ,zA=wJ,BA=CJ,UA=AA,HA=IJ,KA=$J,WA=MJ,VA=jJ,GA="ContextMenu",[zJ,koe]=mo(GA,[Sg]),vo=Sg(),[BJ,YA]=zJ(GA),UJ=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:o,modal:s=!0}=e,[i,a]=x.useState(!1),c=vo(t),l=sn(r),u=x.useCallback(d=>{a(d),l(d)},[l]);return x.createElement(BJ,{scope:t,open:i,onOpenChange:u,modal:s},x.createElement(LA,X({},c,{dir:o,open:i,onOpenChange:u,modal:s}),n))},HJ="ContextMenuTrigger",KJ=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...o}=e,s=YA(HJ,n),i=vo(n),a=x.useRef({x:0,y:0}),c=x.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),l=x.useRef(0),u=x.useCallback(()=>window.clearTimeout(l.current),[]),d=p=>{a.current={x:p.clientX,y:p.clientY},s.onOpenChange(!0)};return x.useEffect(()=>u,[u]),x.useEffect(()=>void(r&&u()),[r,u]),x.createElement(x.Fragment,null,x.createElement(FA,X({},i,{virtualRef:c})),x.createElement(Ke.span,X({"data-state":s.open?"open":"closed","data-disabled":r?"":void 0},o,{ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:ie(e.onContextMenu,p=>{u(),d(p),p.preventDefault()}),onPointerDown:r?e.onPointerDown:ie(e.onPointerDown,Qd(p=>{u(),l.current=window.setTimeout(()=>d(p),700)})),onPointerMove:r?e.onPointerMove:ie(e.onPointerMove,Qd(u)),onPointerCancel:r?e.onPointerCancel:ie(e.onPointerCancel,Qd(u)),onPointerUp:r?e.onPointerUp:ie(e.onPointerUp,Qd(u))})))}),XA=e=>{const{__scopeContextMenu:t,...n}=e,r=vo(t);return x.createElement(NA,X({},r,n))},WJ="ContextMenuContent",VJ=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=YA(WJ,n),s=vo(n),i=x.useRef(!1);return x.createElement(zA,X({},s,r,{ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var c;(c=e.onCloseAutoFocus)===null||c===void 0||c.call(e,a),!a.defaultPrevented&&i.current&&a.preventDefault(),i.current=!1},onInteractOutside:a=>{var c;(c=e.onInteractOutside)===null||c===void 0||c.call(e,a),!a.defaultPrevented&&!o.modal&&(i.current=!0)},style:{...e.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)"}}))}),GJ=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vo(n);return x.createElement(BA,X({},o,r,{ref:t}))}),YJ=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vo(n);return x.createElement(UA,X({},o,r,{ref:t}))}),XJ=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vo(n);return x.createElement(HA,X({},o,r,{ref:t}))}),qJ=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,open:o,defaultOpen:s}=e,i=vo(t),[a,c]=Zs({prop:o,defaultProp:s,onChange:r});return x.createElement(KA,X({},i,{open:a,onOpenChange:c}),n)},ZJ=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vo(n);return x.createElement(WA,X({},o,r,{ref:t}))}),QJ=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vo(n);return x.createElement(VA,X({},o,r,{ref:t,style:{...e.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)"}}))});function Qd(e){return t=>t.pointerType!=="mouse"?e(t):void 0}const JJ=UJ,eee=KJ,tee=XA,nee=VJ,ree=XJ,qA=typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("mac")>-1,oee=qA?"⌘":"Ctrl",see=qA?"⌥":"Alt";function ZA(e){return e.split(",")[0].split("").map(t=>{const n=t.replace(/\$/g,oee).replace(/\?/g,see).replace(/!/g,"⇧");return n[0].toUpperCase()+n.slice(1)})}function Ov(e){return"— "+ZA(e).join(" ")}function iee(e){return h.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",...e,children:h.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[h.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),h.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:h.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}const QA="DropdownMenu",[aee,Toe]=mo(QA,[Sg]),xo=Sg(),[cee,JA]=aee(QA),lee=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=xo(t),l=x.useRef(null),[u=!1,d]=Zs({prop:o,defaultProp:s,onChange:i});return x.createElement(cee,{scope:t,triggerId:Fo(),triggerRef:l,contentId:Fo(),open:u,onOpenChange:d,onOpenToggle:x.useCallback(()=>d(p=>!p),[d]),modal:a},x.createElement(LA,X({},c,{open:u,onOpenChange:d,dir:r,modal:a}),n))},uee="DropdownMenuTrigger",dee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=JA(uee,n),i=xo(n);return x.createElement(FA,X({asChild:!0},i),x.createElement(Ke.button,X({type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r},o,{ref:rg(t,s.triggerRef),onPointerDown:ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})))}),hee=e=>{const{__scopeDropdownMenu:t,...n}=e,r=xo(t);return x.createElement(NA,X({},r,n))},pee="DropdownMenuContent",fee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=JA(pee,n),s=xo(n),i=x.useRef(!1);return x.createElement(zA,X({id:o.contentId,"aria-labelledby":o.triggerId},s,r,{ref:t,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)===null||c===void 0||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ie(e.onInteractOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0,u=c.button===2||l;(!o.modal||u)&&(i.current=!0)}),style:{...e.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)"}}))}),gee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xo(n);return x.createElement(BA,X({},o,r,{ref:t}))}),mee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xo(n);return x.createElement(UA,X({},o,r,{ref:t}))}),yee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xo(n);return x.createElement(HA,X({},o,r,{ref:t}))}),See=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:o,defaultOpen:s}=e,i=xo(t),[a=!1,c]=Zs({prop:r,defaultProp:s,onChange:o});return x.createElement(KA,X({},i,{open:a,onOpenChange:c}),n)},vee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xo(n);return x.createElement(WA,X({},o,r,{ref:t}))}),xee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xo(n);return x.createElement(VA,X({},o,r,{ref:t,style:{...e.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)"}}))}),mw=lee,yw=dee,xg=hee,Sw=fee,wee=gee,bee=mee,Pee=yee,Cee=See,Iee=vee,Eee=xee;function Li({id:e,children:t,modal:n=!1,debugOpen:r=!1}){const[o,s]=Qs(e);return h.jsx(mw,{open:r||o,dir:"ltr",modal:n,onOpenChange:s,children:t})}function Fi({children:e,...t}){return h.jsx(yw,{dir:"ltr",asChild:!0,onTouchEnd:n=>Ee(n),...t,children:e})}function Ni({side:e="bottom",align:t="start",sideOffset:n=8,alignOffset:r=8,children:o}){const s=cn();return h.jsx(xg,{container:s,children:h.jsx(Sw,{className:"tlui-menu",side:e,sideOffset:n,align:t,alignOffset:r,collisionPadding:4,children:o})})}function _ee({id:e,children:t}){const[n,r]=Qs(e);return h.jsx(Cee,{open:n,onOpenChange:r,children:t})}function kee({id:e,label:t,title:n,disabled:r}){return h.jsx(Iee,{dir:"ltr",asChild:!0,disabled:r,children:h.jsxs(pe,{"data-testid":e,type:"menu",className:"tlui-menu__submenu__trigger",disabled:r,title:n,children:[h.jsx(vt,{children:t}),h.jsx(ke,{icon:"chevron-right",small:!0})]})})}function Tee({id:e,alignOffset:t=-1,sideOffset:n=-4,size:r="small",children:o}){const s=cn();return h.jsx(xg,{container:s,children:h.jsx(Eee,{"data-testid":e,className:"tlui-menu tlui-menu__submenu__content",alignOffset:t,sideOffset:n,collisionPadding:4,"data-size":r,children:o})})}function $ee({children:e}){return h.jsx(wee,{dir:"ltr",className:"tlui-menu__group",children:e})}function wu({noClose:e,children:t}){return h.jsx(bee,{dir:"ltr",asChild:!0,onClick:e?Ee:void 0,children:t})}function Dl({children:e,visibleOnMobileLayout:t=!1}){const n=Rn();return!t&&n<mt.MOBILE?null:h.jsx("kbd",{className:"tlui-kbd",children:ZA(e).map((r,o)=>h.jsx("span",{children:r},o))})}function R({disabled:e=!1,spinner:t=!1,readonlyOk:n=!1,id:r,kbd:o,label:s,icon:i,onSelect:a,noClose:c,isSelected:l}){const{type:u,sourceId:d}=mg(),p=$e(),[f,y]=x.useState(!1);if(ns()&&!n)return null;const w=gu(s,u),S=o?Ov(o):void 0,v=w?p(w):void 0,b=v&&S?`${v} ${S}`:v;switch(u){case"menu":return h.jsx(wu,{children:h.jsxs(pe,{type:"menu","data-testid":`${d}.${r}`,disabled:e,title:b,onClick:E=>{c&&Ee(E),f?y(!1):a(d)},children:[h.jsx(vt,{children:v}),o&&h.jsx(Dl,{children:o})]})});case"context-menu":return e?null:h.jsxs(YJ,{dir:"ltr",title:b,draggable:!1,className:"tlui-button tlui-button__menu","data-testid":`${d}.${r}`,onSelect:E=>{c&&Ee(E),f?y(!1):a(d)},children:[h.jsx("span",{className:"tlui-button__label",draggable:!1,children:v}),o&&h.jsx(Dl,{children:o}),t&&h.jsx(iee,{})]});case"panel":return h.jsxs(pe,{"data-testid":`${d}.${r}`,type:"menu",title:b,disabled:e,onClick:()=>a(d),children:[h.jsx(vt,{children:v}),i&&h.jsx(ke,{icon:i})]});case"small-icons":case"icons":return h.jsx(pe,{"data-testid":`${d}.${r}`,type:"icon",title:b,disabled:e,onClick:()=>a(d),children:h.jsx(ke,{icon:i,small:u==="small-icons"})});case"keyboard-shortcuts":return o?h.jsxs("div",{className:"tlui-shortcuts-dialog__key-pair","data-testid":`${d}.${r}`,children:[h.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__key",children:v}),h.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__value",children:h.jsx(Dl,{visibleOnMobileLayout:!0,children:o})})]}):(console.warn(`Menu item '${s}' isn't shown in the keyboard shortcuts dialog because it doesn't have a keyboard shortcut.`),null);case"helper-buttons":return h.jsxs(pe,{type:"low",onClick:()=>a(d),children:[h.jsx(ke,{icon:i}),h.jsx(vt,{children:v})]});case"toolbar":return h.jsx(pe,{type:"tool","data-testid":`tools.${r}`,"aria-label":w,"data-value":r,onClick:()=>a("toolbar"),title:b,onTouchStart:E=>{Ee(E),a("toolbar")},role:"radio","aria-checked":l?"true":"false",children:h.jsx(ke,{icon:i})});case"toolbar-overflow":return h.jsx(wu,{"aria-label":s,children:h.jsx(pe,{type:"icon",className:"tlui-button-grid__button",onClick:()=>{a("toolbar")},"data-testid":`tools.more.${r}`,title:b,role:"radio","aria-checked":l?"true":"false","data-value":r,children:h.jsx(ke,{icon:i})})});default:throw qo(u)}}function Mee(){return h.jsxs(h.Fragment,{children:[h.jsx(Aee,{}),h.jsx(jee,{}),h.jsx(Oee,{}),h.jsx(Dee,{}),h.jsx(Ree,{}),h.jsx(Nee,{}),h.jsx(zee,{}),h.jsx(Bee,{})]})}function Aee(){const e=ce(),t=wn(2);return h.jsxs(h.Fragment,{children:[h.jsx(R,{...e["align-left"],disabled:!t}),h.jsx(R,{...e["align-center-horizontal"],disabled:!t}),h.jsx(R,{...e["align-right"],disabled:!t}),h.jsx(R,{...e["stretch-horizontal"],disabled:!t}),h.jsx(R,{...e["align-top"],disabled:!t}),h.jsx(R,{...e["align-center-vertical"],disabled:!t}),h.jsx(R,{...e["align-bottom"],disabled:!t}),h.jsx(R,{...e["stretch-vertical"],disabled:!t})]})}function jee(){const e=ce(),t=wn(3);return h.jsxs(h.Fragment,{children:[h.jsx(R,{...e["distribute-horizontal"],disabled:!t}),h.jsx(R,{...e["distribute-vertical"],disabled:!t})]})}function Oee(){const e=ce(),t=YT();return h.jsxs(h.Fragment,{children:[h.jsx(R,{...e["stack-horizontal"],disabled:!t}),h.jsx(R,{...e["stack-vertical"],disabled:!t})]})}function Dee(){const e=ce(),t=wn(1);return h.jsxs(h.Fragment,{children:[h.jsx(R,{...e["send-to-back"],disabled:!t}),h.jsx(R,{...e["send-backward"],disabled:!t}),h.jsx(R,{...e["bring-forward"],disabled:!t}),h.jsx(R,{...e["bring-to-front"],disabled:!t})]})}function Ree(){return Rn()<mt.TABLET_SM?h.jsx(Lee,{}):h.jsx(Fee,{})}function Lee(){const e=ce(),t=z(),n=K("zoom is 1",()=>t.getZoomLevel()===1,[t]);return h.jsx(R,{...e["zoom-to-100"],disabled:n})}function Fee(){const e=ce(),t=wn(1);return h.jsx(R,{...e["rotate-ccw"],disabled:!t})}function Nee(){const e=ce(),t=wn(1);return h.jsx(R,{...e["rotate-cw"],disabled:!t})}function zee(){const e=ce(),t=ZT();return h.jsx(R,{...e["edit-link"],disabled:!t})}function Bee(){const e=XT(),t=qT();return e?h.jsx(uI,{}):t?h.jsx(Uee,{}):h.jsx(uI,{})}function uI(){const e=ce(),t=wn(2);return h.jsx(R,{...e.group,disabled:!t})}function Uee(){const e=ce();return h.jsx(R,{...e.ungroup})}const Hee=x.memo(function({children:t}){const n=$e(),r=Rn(),o=ns(),s=z(),i=K("should display quick actions when in readonly",()=>s.isInAny("hand","zoom"),[s]),a=t??h.jsx(Mee,{});if(!(o&&!i))return h.jsxs(lw,{id:"actions-menu",children:[h.jsx(uw,{children:h.jsx(pe,{type:"icon","data-testid":"actions-menu.button",title:n("actions-menu.title"),children:h.jsx(ke,{icon:"dots-vertical",small:!0})})}),h.jsx(dw,{side:r>=mt.TABLET?"bottom":"top",sideOffset:6,children:h.jsx("div",{className:"tlui-actions-menu tlui-buttons__grid","data-testid":"actions-menu.content",children:h.jsx(vr,{type:"icons",sourceId:"actions-menu",children:a})})})]})});function wr({id:e,kbd:t,label:n,readonlyOk:r,onSelect:o,disabled:s=!1,checked:i=!1}){const{type:a,sourceId:c}=mg(),l=ns(),u=$e();if(l&&!r)return null;const d=gu(n,a),p=d?u(d):void 0;switch(a){case"menu":return h.jsxs(Pee,{dir:"ltr",className:"tlui-button tlui-button__menu tlui-button__checkbox",title:p,onSelect:f=>{o==null||o(c),Ee(f)},disabled:s,checked:i,children:[h.jsx(Bs,{small:!0,icon:i?"check":"checkbox-empty"}),p&&h.jsx("span",{className:"tlui-button__label",draggable:!1,children:p}),t&&h.jsx(Dl,{children:t})]});case"context-menu":return h.jsxs(ree,{className:"tlui-button tlui-button__menu tlui-button__checkbox",dir:"ltr",title:p,onSelect:f=>{o(c),Ee(f)},disabled:s,checked:i,children:[h.jsx(Bs,{small:!0,icon:i?"check":"checkbox-empty"}),p&&h.jsx("span",{className:"tlui-button__label",draggable:!1,children:p}),t&&h.jsx(Dl,{children:t})]},e);default:return null}}function ye({id:e,label:t,children:n}){const{type:r,sourceId:o}=mg(),s=$e(),i=gu(t,r),a=i?s(i):void 0;switch(r){case"panel":return h.jsx("div",{className:"tlui-menu__group","data-testid":`${o}-group.${e}`,children:n});case"menu":return h.jsx($ee,{"data-testid":`${o}-group.${e}`,children:n});case"context-menu":return h.jsx(GJ,{dir:"ltr",className:"tlui-menu__group","data-testid":`${o}-group.${e}`,children:n});case"keyboard-shortcuts":return h.jsxs("div",{className:"tlui-shortcuts-dialog__group","data-testid":`${o}-group.${e}`,children:[h.jsx("h2",{className:"tlui-shortcuts-dialog__group__title",children:a}),h.jsx("div",{className:"tlui-shortcuts-dialog__group__content",children:n})]});default:return n}}function br({id:e,disabled:t=!1,label:n,size:r="small",children:o}){const{type:s,sourceId:i}=mg(),a=cn(),c=$e(),l=n?typeof n=="string"?n:n[s]??n.default:void 0,u=l?c(l):void 0;switch(s){case"menu":return h.jsxs(_ee,{id:`${i}-sub.${e}`,children:[h.jsx(kee,{id:`${i}-sub.${u?u.toLowerCase()+"-button":""}`,disabled:t,label:u,title:u}),h.jsx(Tee,{id:`${i}-sub.${u?u.toLowerCase()+"-content":""}`,size:r,children:o})]});case"context-menu":return t?null:h.jsxs(Kee,{id:`${i}-sub.${e}`,children:[h.jsx(ZJ,{dir:"ltr",disabled:t,asChild:!0,children:h.jsxs(pe,{"data-testid":`${i}-sub-trigger.${e}`,type:"menu",className:"tlui-menu__submenu__trigger",children:[h.jsx(vt,{children:u}),h.jsx(ke,{icon:"chevron-right",small:!0})]})}),h.jsx(XA,{container:a,children:h.jsx(QJ,{"data-testid":`${i}-sub-content.${e}`,className:"tlui-menu tlui-menu__submenu__content",alignOffset:-1,sideOffset:-4,collisionPadding:4,"data-size":r,children:o})})]});default:return o}}function Kee({id:e,children:t}){const[n,r]=Qs(e);return h.jsx(qJ,{open:n,onOpenChange:r,children:t})}function ej(){const e=ce();return PW()?h.jsx(R,{...e["toggle-auto-size"]}):null}function tj(){const e=ce();return ZT()?h.jsx(R,{...e["edit-link"]}):null}function Wee(){const e=ce();return wn(1)?h.jsx(R,{...e.duplicate}):null}function nj(){const e=ce();return XT()?h.jsx(R,{...e.group}):null}function rj(){const e=ce();return qT()?h.jsx(R,{...e.ungroup}):null}function oj(){const e=z(),t=ce();return K("allow unframe",()=>{const r=e.getSelectedShapes();return r.length===0?!1:r.every(o=>e.isShapeOfType(o,"frame"))},[e])?h.jsx(R,{...t["remove-frame"]}):null}function sj(){const e=z(),t=ce();return K("allow fit frame to content",()=>{const r=e.getOnlySelectedShape();return r?e.isShapeOfType(r,"frame")&&e.getSortedChildIdsForParent(r).length>0:!1},[e])?h.jsx(R,{...t["fit-frame-to-content"]}):null}function ij(){const e=z(),t=ce();return K("selected shapes",()=>e.getSelectedShapes().length>0,[e])?h.jsx(R,{...t["toggle-lock"]}):null}function vw(){const e=ce(),t=z(),n=K("isTransparentBg",()=>!t.getInstanceState().exportBackground,[t]);return h.jsx(wr,{...e["toggle-transparent"],checked:n})}function Vee(){const e=z(),t=ce(),n=K("any shapes",()=>e.getCurrentPageShapeIds().size>0,[e]);return h.jsx(R,{...t["unlock-all"],disabled:!n})}function aj(){const e=z(),t=K("zoomed to 100",()=>e.getZoomLevel()===1,[e]),n=ce();return h.jsx(R,{...n["zoom-to-100"],noClose:!0,disabled:t})}function cj(){const e=z(),t=K("has shapes",()=>e.getCurrentPageShapeIds().size>0,[e]),n=ce();return h.jsx(R,{...n["zoom-to-fit"],disabled:!t,"data-testid":"minimap.zoom-menu.zoom-to-fit",noClose:!0})}function lj(){const e=z(),t=K("has shapes",()=>e.getSelectedShapeIds().length>0,[e]),n=ce();return h.jsx(R,{...n["zoom-to-selection"],disabled:!t,"data-testid":"minimap.zoom-menu.zoom-to-selection",noClose:!0})}function uj(){return h.jsxs(ye,{id:"clipboard",children:[h.jsx(Yee,{}),h.jsx(Xee,{}),h.jsx(qee,{}),h.jsx(Wee,{}),h.jsx(Zee,{})]})}function Gee(){var r;const e=z(),t=ce(),n=K("atLeastOneShapeOnPage",()=>e.getCurrentPageShapeIds().size>0,[e]);return h.jsxs(br,{id:"copy-as",label:"context-menu.copy-as",size:"small",disabled:!n,children:[h.jsxs(ye,{id:"copy-as-group",children:[h.jsx(R,{...t["copy-as-svg"]}),!!((r=window.navigator.clipboard)!=null&&r.write)&&h.jsx(R,{...t["copy-as-png"]}),h.jsx(R,{...t["copy-as-json"]})]}),h.jsx(ye,{id:"copy-as-bg",children:h.jsx(vw,{})})]})}function Yee(){const e=ce(),t=wn(1);return h.jsx(R,{...e.cut,disabled:!t})}function Xee(){const e=ce(),t=bW(1);return h.jsx(R,{...e.copy,disabled:!t})}function qee(){const e=ce(),t=wW;return h.jsx(R,{...e.paste,disabled:!t})}function dj(){const e=z(),t=ce();return K("atLeastOneShapeOnPage",()=>e.getCurrentPageShapeIds().size>0,[e])?h.jsxs(ye,{id:"conversions",children:[h.jsx(Gee,{}),h.jsxs(br,{id:"export-as",label:"context-menu.export-as",size:"small",children:[h.jsxs(ye,{id:"export-as-group",children:[h.jsx(R,{...t["export-as-svg"]}),h.jsx(R,{...t["export-as-png"]}),h.jsx(R,{...t["export-as-json"]})]}),h.jsx(ye,{id:"export-as-bg",children:h.jsx(vw,{})})]})]}):null}function hj(){const e=ce(),t=z(),n=K("atLeastOneShapeOnPage",()=>t.getCurrentPageShapeIds().size>0,[t]);return h.jsx(R,{...e["select-all"],disabled:!n})}function Zee(){const e=ce(),t=wn(1);return h.jsx(R,{...e.delete,disabled:!t})}function Qee(){const e=wn(2),t=CW(),n=ce();return e||t?h.jsxs(br,{id:"arrange",label:"context-menu.arrange",size:"small",children:[e&&h.jsxs(ye,{id:"align",children:[h.jsx(R,{...n["align-left"]}),h.jsx(R,{...n["align-center-horizontal"]}),h.jsx(R,{...n["align-right"]}),h.jsx(R,{...n["align-top"]}),h.jsx(R,{...n["align-center-vertical"]}),h.jsx(R,{...n["align-bottom"]})]}),h.jsx(Jee,{}),e&&h.jsxs(ye,{id:"stretch",children:[h.jsx(R,{...n["stretch-horizontal"]}),h.jsx(R,{...n["stretch-vertical"]})]}),(e||t)&&h.jsxs(ye,{id:"flip",children:[h.jsx(R,{...n["flip-horizontal"]}),h.jsx(R,{...n["flip-vertical"]})]}),h.jsx(ete,{})]}):null}function Jee(){const e=ce();return wn(3)?h.jsxs(ye,{id:"distribute",children:[h.jsx(R,{...e["distribute-horizontal"]}),h.jsx(R,{...e["distribute-vertical"]})]}):null}function ete(){const e=ce(),t=wn(2),n=YT();return t?h.jsxs(ye,{id:"order",children:[h.jsx(R,{...e.pack}),n&&h.jsx(R,{...e["stack-horizontal"]}),n&&h.jsx(R,{...e["stack-vertical"]})]}):null}function tte(){const e=ce();return wn(1)?h.jsx(br,{id:"reorder",label:"context-menu.reorder",size:"small",children:h.jsxs(ye,{id:"reorder",children:[h.jsx(R,{...e["bring-to-front"]}),h.jsx(R,{...e["bring-forward"]}),h.jsx(R,{...e["send-backward"]}),h.jsx(R,{...e["send-to-back"]})]})}):null}function nte(){const e=z(),t=K("pages",()=>e.getPages(),[e]),n=K("current page id",()=>e.getCurrentPageId(),[e]),{addToast:r}=Kr(),o=ce(),s=So();return wn(1)?h.jsxs(br,{id:"move-to-page",label:"context-menu.move-to-page",size:"small",children:[h.jsx(ye,{id:"pages",children:t.map(a=>h.jsx(R,{id:a.id,disabled:n===a.id,label:a.name,onSelect:()=>{e.mark("move_shapes_to_page"),e.moveShapesToPage(e.getSelectedShapeIds(),a.id);const c=e.getPage(a.id);c&&r({title:"Changed Page",description:`Moved to ${c.name}.`,actions:[{label:"Go Back",type:"primary",onClick:()=>{e.mark("change-page"),e.setCurrentPage(n)}}]}),s("move-to-page",{source:"context-menu"})}},a.id))}),h.jsx(ye,{id:"new-page",children:h.jsx(R,{...o["new-page"]})})]}):null}function pj(){const e=z(),t=ce();return K("oneEmbedSelected",()=>{const r=e.getOnlySelectedShape();return r?!!(e.isShapeOfType(r,"embed")&&r.props.url&&!e.isShapeOrAncestorLocked(r)):!1},[e])?h.jsx(R,{...t["convert-to-bookmark"]}):null}function fj(){const e=z(),t=ce();return K("oneEmbeddableBookmarkSelected",()=>{const r=e.getOnlySelectedShape();return r?!!(e.isShapeOfType(r,"bookmark")&&r.props.url&&Cs(r.props.url)&&!e.isShapeOrAncestorLocked(r)):!1},[e])?h.jsx(R,{...t["convert-to-embed"]}):null}function rte(){const e=ce(),t=z(),n=K("isSnapMode",()=>t.user.getIsSnapMode(),[t]);return h.jsx(wr,{...e["toggle-snap-mode"],checked:n})}function ote(){const e=ce(),t=z(),n=K("isToolLock",()=>t.getInstanceState().isToolLocked,[t]);return h.jsx(wr,{...e["toggle-tool-lock"],checked:n})}function ste(){const e=ce(),t=z(),n=K("isGridMode",()=>t.getInstanceState().isGridMode,[t]);return h.jsx(wr,{...e["toggle-grid"],checked:n})}function ite(){const e=ce(),t=z(),n=K("isWrapMode",()=>t.user.getIsWrapMode(),[t]);return h.jsx(wr,{...e["toggle-wrap-mode"],checked:n})}function ate(){const e=ce(),t=z(),n=K("isDarkMode",()=>t.user.getIsDarkMode(),[t]);return h.jsx(wr,{...e["toggle-dark-mode"],checked:n})}function cte(){const e=ce(),t=z(),n=K("isFocusMode",()=>t.getInstanceState().isFocusMode,[t]);return h.jsx(wr,{...e["toggle-focus-mode"],checked:n})}function lte(){const e=ce(),t=z(),n=K("edgeScrollSpeed",()=>t.user.getEdgeScrollSpeed(),[t]);return h.jsx(wr,{...e["toggle-edge-scrolling"],checked:n===1})}function ute(){const e=ce(),t=z(),n=K("animationSpeed",()=>t.user.getAnimationSpeed(),[t]);return h.jsx(wr,{...e["toggle-reduce-motion"],checked:n===0})}function dte(){const e=ce(),t=z(),n=K("isDebugMode",()=>t.getInstanceState().isDebugMode,[t]);return h.jsx(wr,{...e["toggle-debug-mode"],checked:n})}function hte(){const e=z();return K("isSelectToolActive",()=>e.getCurrentToolId()==="select",[e])?h.jsxs(h.Fragment,{children:[h.jsxs(ye,{id:"misc",children:[h.jsx(nj,{}),h.jsx(rj,{}),h.jsx(tj,{}),h.jsx(ej,{}),h.jsx(oj,{}),h.jsx(sj,{}),h.jsx(fj,{}),h.jsx(pj,{}),h.jsx(ij,{})]}),h.jsxs(ye,{id:"modify",children:[h.jsx(Qee,{}),h.jsx(tte,{}),h.jsx(nte,{})]}),h.jsx(uj,{}),h.jsx(dj,{}),h.jsx(ye,{id:"select-all",children:h.jsx(hj,{})})]}):null}const pte=x.memo(function({children:t}){const n=z(),{Canvas:r}=dt(),o=x.useCallback(l=>{if(l){if(n.getInstanceState().isCoarsePointer){const u=n.getSelectedShapes(),{inputs:{currentPagePoint:d}}=n,p=n.getShapesAtPoint(d);if(!n.getSelectedShapes().length||!p.some(f=>u.includes(f))){const f=p.filter(y=>n.isShapeOrAncestorLocked(y));f.length&&n.select(...f.map(y=>y.id))}}}else{const u=n.getOnlySelectedShape();u&&n.isShapeOrAncestorLocked(u)&&n.setSelectedShapes([])}},[n]),s=cn(),[i,a]=Qs("context menu",o),c=t??h.jsx(hte,{});return h.jsxs(JJ,{dir:"ltr",onOpenChange:a,modal:!1,children:[h.jsx(eee,{onContextMenu:void 0,dir:"ltr",children:r?h.jsx(r,{}):null}),i&&h.jsx(tee,{container:s,children:h.jsx(nee,{className:"tlui-menu scrollable","data-testid":"context-menu",alignOffset:-4,collisionPadding:4,onContextMenu:Ee,children:h.jsx(vr,{type:"context-menu",sourceId:"context-menu",children:c})})})]})});function Dv({checked:e}){return h.jsx(Bs,{icon:e?"check":"checkbox-empty",className:"tlui-button__icon",small:!0})}function fte(){const e=z(),{addToast:t}=Kr(),{addDialog:n}=Yi(),[r,o]=Se.useState(!1);return h.jsxs(h.Fragment,{children:[h.jsxs(ye,{id:"items",children:[h.jsx(R,{id:"add-toast",onSelect:()=>{t({id:et(),title:"Something good happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"success"}),t({id:et(),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:()=>{}}]}),t({id:et(),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:()=>{}}]}),t({id:et(),title:"Something bad happened",severity:"error",keepOpen:!0})},label:"Show toast"}),h.jsx(R,{id:"show-dialog",label:"Show dialog",onSelect:()=>{n({component:({onClose:s})=>h.jsx(yte,{displayDontShowAgain:!0,onCancel:()=>s(),onContinue:()=>s()}),onClose:()=>{}})}}),h.jsx(R,{id:"create-shapes",label:"Create 100 shapes",onSelect:()=>Ste(e,100)}),h.jsx(R,{id:"count-nodes",label:"Count shapes / nodes",onSelect:()=>{var a;const s=e.getSelectedShapes(),i=s.length===0?e.getRenderingShapes():s;window.alert(`Shapes ${i.length}, DOM nodes:${(a=document.querySelector(".tl-shapes").querySelectorAll("*"))==null?void 0:a.length}`)}}),(()=>{if(r)throw Error("oh no!");return null})(),h.jsx(R,{id:"throw-error",onSelect:()=>o(!0),label:"Throw error"}),h.jsx(R,{id:"hard-reset",onSelect:x2,label:"Hard reset"})]}),h.jsxs(ye,{id:"flags",children:[h.jsx(gte,{}),h.jsx(mte,{})]})]})}function gte(){const e=Object.values($t);return e.length?h.jsx(br,{id:"debug flags",label:"Debug Flags",children:h.jsx(ye,{id:"debug flags",children:e.map(t=>h.jsx(gj,{flag:t},t.name))})}):null}function mte(){const e=Object.values(U5);return e.length?h.jsx(br,{id:"feature flags",label:"Feature Flags",children:h.jsx(ye,{id:"feature flags",children:e.map(t=>h.jsx(gj,{flag:t},t.name))})}):null}function yte({title:e="title",body:t="hello hello hello",cancel:n="Cancel",confirm:r="Continue",displayDontShowAgain:o=!1,onCancel:s,onContinue:i}){const[a,c]=Se.useState(!1);return h.jsxs(h.Fragment,{children:[h.jsxs(dg,{children:[h.jsx(hg,{children:e}),h.jsx(pg,{})]}),h.jsx(fu,{style:{maxWidth:350},children:t}),h.jsxs(Zx,{className:"tlui-dialog__footer__actions",children:[o&&h.jsxs(pe,{type:"normal",onClick:()=>c(!a),style:{marginRight:"auto"},children:[h.jsx(Dv,{checked:a}),h.jsx(vt,{children:"Don't show again"})]}),h.jsx(pe,{type:"normal",onClick:s,children:h.jsx(vt,{children:n})}),h.jsx(pe,{type:"primary",onClick:async()=>i(),children:h.jsx(vt,{children:r})})]})]})}const gj=or(function({flag:t,onChange:n}){const r=t.get();return h.jsx(wr,{id:t.name,title:t.name,label:t.name.replace(/([a-z0-9])([A-Z])/g,o=>`${o[0]} ${o[1].toLowerCase()}`).replace(/^[a-z]/,o=>o.toUpperCase()),checked:r,onSelect:()=>{t.set(!r),n==null||n(!r)}})});let dI=0;function Ste(e,t){const n=Array(t),r=Math.floor(Math.sqrt(t));for(let o=0;o<t;o++)dI++,n[o]={id:Be("box"+dI),type:"geo",x:o%r*132,y:Math.floor(o/r)*132};e.batch(()=>{e.createShapes(n).setSelectedShapes(n.map(o=>o.id))})}function vte({children:e}){const t=e??h.jsx(fte,{});return h.jsxs(Li,{id:"debug",children:[h.jsx(Fi,{children:h.jsx(pe,{type:"icon",title:"Debug menu",children:h.jsx(ke,{icon:"dots-horizontal"})})}),h.jsx(Ni,{side:"top",align:"end",alignOffset:0,children:h.jsx(vr,{type:"menu",sourceId:"debug-panel",children:t})})]})}const xte=x.memo(function(){const{DebugMenu:t}=ti();return h.jsxs("div",{className:"tlui-debug-panel",children:[h.jsx(bte,{}),h.jsx(Pte,{}),t&&h.jsx(t,{})]})});function wte(e=!0){const[t,n]=x.useState(0),r=z();x.useEffect(()=>{if(!e)return;const o=()=>n(s=>s+1);return r.on("tick",o),()=>{r.off("tick",o)}},[r,e])}const bte=or(function(){wte();const t=z(),n=t.getPath(),r=t.getHoveredShape(),o=t.getOnlySelectedShape(),s=n==="select.idle"||!n.includes("select.")?r:o,i=s&&n.includes("select.")?` / ${s.type||""}${"geo"in s.props?" / "+s.props.geo:""} / [${P.ToFixed(t.getPointInShapeSpace(s,t.inputs.currentPagePoint),0)}]`:"",a=n.startsWith("select.")&&!n.includes(".idle")?` / [${P.ToFixed(t.inputs.originPagePoint,0)}] → [${P.ToFixed(t.inputs.currentPagePoint,0)}] = ${P.Dist(t.inputs.originPagePoint,t.inputs.currentPagePoint).toFixed(0)}`:"";return h.jsx("div",{className:"tlui-debug-panel__current-state",children:`${n}${i}${a}`})});function Pte(){const e=K("show_fps",()=>$t.showFps.get(),[$t]),t=x.useRef(null);return x.useEffect(()=>{if(!e)return;const n=250;let r=0,o=!1,s=performance.now(),i=0,a=0,c=!1;function l(){if(!o){if(a++,i=performance.now()-s,i>n){const u=Math.round(a*(n/i)*(1e3/n));u>r&&(r=u);const d=r*.75;(u<d&&!c||u>=d&&c)&&(c=!c),t.current.innerHTML=`FPS ${u.toString()}`,t.current.className="tlui-debug-panel__fps"+(c?" tlui-debug-panel__fps__slow":""),i-=n,a=0,s=performance.now()}requestAnimationFrame(l)}}return l(),()=>{o=!0}},[e]),e?h.jsx("div",{ref:t}):null}function mj(){const e=z(),t=So(),n=K("locale",()=>e.user.getLocale(),[e]);return h.jsx(br,{id:"help menu language",label:"menu.language",children:h.jsx(ye,{id:"languages",children:ou.map(({locale:r,label:o})=>h.jsx(wr,{id:`language-${r}`,title:r,label:o,checked:r===n,onSelect:()=>{e.user.updateUserPreferences({locale:r}),t("change-language",{source:"menu",locale:r})}},r))})})}function Cte(){return h.jsxs(h.Fragment,{children:[h.jsx(mj,{}),h.jsx(Ite,{})]})}function Ite(){const{KeyboardShortcutsDialog:e}=ti(),{addDialog:t}=Yi();return e?h.jsx(R,{id:"keyboard-shortcuts-button",label:"help-menu.keyboard-shortcuts",readonlyOk:!0,onSelect:()=>{t({component:e})}}):null}const Ete=x.memo(function({children:t}){const n=$e(),r=Rn(),o=t??h.jsx(Cte,{});return r<mt.MOBILE?null:h.jsx("div",{className:"tlui-help-menu",children:h.jsxs(Li,{id:"help menu",children:[h.jsx(Fi,{children:h.jsx(pe,{type:"help",title:n("help-menu.title"),"data-testid":"help-menu.button",children:h.jsx(ke,{icon:"question-mark",small:!0})})}),h.jsx(Ni,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:h.jsx(vr,{type:"menu",sourceId:"help-menu",children:o})})]})})});function _te(){const e=z(),t=ce(),[n,r]=x.useState(!1),o=x.useRef(!1);return js("toggle showback to content",()=>{const s=o.current,i=e.getCurrentPageShapeIds();let a=!1;i.size&&(a=i.size===e.getCulledShapes().size),s!==a&&(r(a),o.current=a)},[e]),n?h.jsx(R,{...t["back-to-content"],onSelect:()=>{t["back-to-content"].onSelect("helper-buttons"),r(!1)}}):null}function kte(){const e=z(),t=ce();return K("is pen mode",()=>e.getInstanceState().isPenMode,[e])?h.jsx(R,{...t["exit-pen-mode"]}):null}function Tte(){const e=z(),t=ce();return K("is following user",()=>!!e.getInstanceState().followingUserId,[e])?h.jsx(R,{...t["stop-following"]}):null}function $te(){return h.jsxs(h.Fragment,{children:[h.jsx(kte,{}),h.jsx(_te,{}),h.jsx(Tte,{})]})}function Mte({children:e}){const t=e??h.jsx($te,{});return h.jsx("div",{className:"tlui-helper-buttons",children:h.jsx(vr,{type:"helper-buttons",sourceId:"helper-buttons",children:t})})}function Ate(){const e=ce(),t=De();return h.jsxs(h.Fragment,{children:[h.jsxs(ye,{label:"shortcuts-dialog.tools",id:"tools",children:[h.jsx(R,{...e["toggle-tool-lock"]}),h.jsx(R,{...e["insert-media"]}),h.jsx(R,{...t.select}),h.jsx(R,{...t.draw}),h.jsx(R,{...t.eraser}),h.jsx(R,{...t.hand}),h.jsx(R,{...t.rectangle}),h.jsx(R,{...t.ellipse}),h.jsx(R,{...t.arrow}),h.jsx(R,{...t.line}),h.jsx(R,{...t.text}),h.jsx(R,{...t.frame}),h.jsx(R,{...t.note}),h.jsx(R,{...t.laser})]}),h.jsxs(ye,{label:"shortcuts-dialog.preferences",id:"preferences",children:[h.jsx(R,{...e["toggle-dark-mode"]}),h.jsx(R,{...e["toggle-focus-mode"]}),h.jsx(R,{...e["toggle-grid"]})]}),h.jsxs(ye,{label:"shortcuts-dialog.edit",id:"edit",children:[h.jsx(R,{...e.undo}),h.jsx(R,{...e.redo}),h.jsx(R,{...e.cut}),h.jsx(R,{...e.copy}),h.jsx(R,{...e.paste}),h.jsx(R,{...e["select-all"]}),h.jsx(R,{...e.delete}),h.jsx(R,{...e.duplicate})]}),h.jsxs(ye,{label:"shortcuts-dialog.view",id:"view",children:[h.jsx(R,{...e["zoom-in"]}),h.jsx(R,{...e["zoom-out"]}),h.jsx(R,{...e["zoom-to-100"]}),h.jsx(R,{...e["zoom-to-fit"]}),h.jsx(R,{...e["zoom-to-selection"]})]}),h.jsxs(ye,{label:"shortcuts-dialog.transform",id:"transform",children:[h.jsx(R,{...e["bring-to-front"]}),h.jsx(R,{...e["bring-forward"]}),h.jsx(R,{...e["send-backward"]}),h.jsx(R,{...e["send-to-back"]}),h.jsx(R,{...e.group}),h.jsx(R,{...e.ungroup}),h.jsx(R,{...e["flip-horizontal"]}),h.jsx(R,{...e["flip-vertical"]}),h.jsx(R,{...e["align-top"]}),h.jsx(R,{...e["align-center-vertical"]}),h.jsx(R,{...e["align-bottom"]}),h.jsx(R,{...e["align-left"]}),h.jsx(R,{...e["align-center-horizontal"]}),h.jsx(R,{...e["align-right"]})]})]})}const jte=x.memo(function({children:t}){const n=$e(),r=Rn(),o=t??h.jsx(Ate,{});return h.jsxs(h.Fragment,{children:[h.jsxs(dg,{className:"tlui-shortcuts-dialog__header",children:[h.jsx(hg,{children:n("shortcuts-dialog.title")}),h.jsx(pg,{})]}),h.jsx(fu,{className:ue("tlui-shortcuts-dialog__body",{"tlui-shortcuts-dialog__body__mobile":r<=mt.MOBILE_XS,"tlui-shortcuts-dialog__body__tablet":r<=mt.TABLET}),children:h.jsx(vr,{type:"keyboard-shortcuts",sourceId:"kbd",children:o})}),h.jsx("div",{className:"tlui-dialog__scrim"})]})});function Ote(){return h.jsxs(h.Fragment,{children:[h.jsx(Rte,{}),h.jsx(zte,{}),h.jsx(Dte,{}),h.jsx(Bte,{}),h.jsx(Ute,{})]})}function Dte(){const e=ce();return h.jsxs(br,{id:"export-all-as",label:"context-menu.export-all-as",size:"small",children:[h.jsxs(ye,{id:"export-all-as-group",children:[h.jsx(R,{...e["export-all-as-svg"]}),h.jsx(R,{...e["export-all-as-png"]}),h.jsx(R,{...e["export-all-as-json"]})]}),h.jsx(ye,{id:"export-all-as-bg",children:h.jsx(vw,{})})]})}function Rte(){const e=z(),t=K("isSelectToolActive",()=>e.getCurrentToolId()==="select",[e]);return h.jsxs(br,{id:"edit",label:"menu.edit",disabled:!t,children:[h.jsx(Nte,{}),h.jsx(uj,{}),h.jsx(dj,{}),h.jsx(Lte,{}),h.jsx(Fte,{}),h.jsx(ye,{id:"select-all",children:h.jsx(hj,{})})]})}function Lte(){return h.jsxs(ye,{id:"misc",children:[h.jsx(nj,{}),h.jsx(rj,{}),h.jsx(tj,{}),h.jsx(ej,{}),h.jsx(oj,{}),h.jsx(sj,{}),h.jsx(fj,{}),h.jsx(pj,{})]})}function Fte(){return h.jsxs(ye,{id:"lock",children:[h.jsx(ij,{}),h.jsx(Vee,{})]})}function Nte(){const e=ce(),t=JT(),n=QT();return h.jsxs(ye,{id:"undo-redo",children:[h.jsx(R,{...e.undo,disabled:!t}),h.jsx(R,{...e.redo,disabled:!n})]})}function zte(){const e=ce();return h.jsx(br,{id:"view",label:"menu.view",children:h.jsxs(ye,{id:"view-actions",children:[h.jsx(R,{...e["zoom-in"]}),h.jsx(R,{...e["zoom-out"]}),h.jsx(aj,{}),h.jsx(cj,{}),h.jsx(lj,{})]})})}function Bte(){const e=ce();return h.jsxs(ye,{id:"extras",children:[h.jsx(R,{...e["insert-embed"]}),h.jsx(R,{...e["insert-media"]})]})}function Ute(){return h.jsx(ye,{id:"preferences",children:h.jsxs(br,{id:"preferences",label:"menu.preferences",children:[h.jsxs(ye,{id:"preferences-actions",children:[h.jsx(rte,{}),h.jsx(ote,{}),h.jsx(ste,{}),h.jsx(ite,{}),h.jsx(ate,{}),h.jsx(cte,{}),h.jsx(lte,{}),h.jsx(ute,{}),h.jsx(dte,{})]}),h.jsx(ye,{id:"language",children:h.jsx(mj,{})})]})})}const Hte=x.memo(function({children:t}){const n=cn(),[r,o]=Qs("main menu"),s=$e(),i=t??h.jsx(Ote,{});return h.jsxs(mw,{dir:"ltr",open:r,onOpenChange:o,modal:!1,children:[h.jsx(yw,{asChild:!0,dir:"ltr",children:h.jsx(pe,{type:"icon","data-testid":"main-menu.button",title:s("menu.title"),children:h.jsx(ke,{icon:"menu",small:!0})})}),h.jsx(xg,{container:n,children:h.jsx(Sw,{className:"tlui-menu",side:"bottom",align:"start",collisionPadding:4,alignOffset:0,sideOffset:6,children:h.jsx(vr,{type:"menu",sourceId:"main-menu",children:i})})})]})}),Kte=x.memo(function(){const t=Rn(),{MainMenu:n,QuickActions:r,ActionsMenu:o,PageMenu:s}=ti();return!n&&!s&&t<6?null:h.jsx("div",{className:"tlui-menu-zone",children:h.jsxs("div",{className:"tlui-buttons__horizontal",children:[n&&h.jsx(n,{}),s&&h.jsx(s,{}),t<6?null:h.jsxs(h.Fragment,{children:[r&&h.jsx(r,{}),o&&h.jsx(o,{})]})]})})}),hy={};function sl(e){if(hy[e])return hy[e];const n=document.createElement("canvas").getContext("2d");n.fillStyle=e,n.fillRect(0,0,1,1);const[r,o,s,i]=n.getImageData(0,0,1,1).data,a=new Float32Array([r/255,o/255,s/255,i/255]);return hy[e]=a,a}const rp=10,yj=4*6*rp+12+4*12;function fa(e,{center:t,radius:n,numArcSegments:r=20,startAngle:o=0,endAngle:s=Oe,offset:i=0}){const a=(s-o)/r;let c=i;for(let l=o;l<s;l+=a)e[c++]=t.x,e[c++]=t.y,e[c++]=t.x+Math.cos(l)*n,e[c++]=t.y+Math.sin(l)*n,e[c++]=t.x+Math.cos(l+a)*n,e[c++]=t.y+Math.sin(l+a)*n;return e}function ga(e,t,n,r,o,s){e[t++]=n,e[t++]=r,e[t++]=n,e[t++]=r+s,e[t++]=n+o,e[t++]=r,e[t++]=n+o,e[t++]=r,e[t++]=n,e[t++]=r+s,e[t++]=n+o,e[t++]=r+s}function Wte(e,t,n){const r=rp;n=Math.min(n,Math.min(t.w,t.h)/2);const o=ne.ExpandBy(t,-n);if(o.w<=0||o.h<=0)return fa(e,{center:t.center,radius:n,numArcSegments:rp*4}),rp*4*6;let s=0;return ga(e,s,o.minX,o.minY,o.w,o.h),s+=12,ga(e,s,o.minX,t.minY,o.w,n),s+=12,ga(e,s,o.maxX,o.minY,n,o.h),s+=12,ga(e,s,o.minX,o.maxY,o.w,n),s+=12,ga(e,s,t.minX,o.minY,n,o.h),s+=12,fa(e,{numArcSegments:r,offset:s,center:o.point,radius:n,startAngle:Pe,endAngle:Pe*1.5}),s+=r*6,fa(e,{numArcSegments:r,offset:s,center:P.Add(o.point,new P(o.w,0)),radius:n,startAngle:Pe*1.5,endAngle:Oe}),s+=r*6,fa(e,{numArcSegments:r,offset:s,center:P.Add(o.point,o.size),radius:n,startAngle:0,endAngle:ze}),s+=r*6,fa(e,{numArcSegments:r,offset:s,center:P.Add(o.point,new P(0,o.h)),radius:n,startAngle:ze,endAngle:Pe}),yj}function Vte(e){if(!e)throw new Error("Canvas element not found");const t=e.getContext("webgl2",{premultipliedAlpha:!1});if(!t)throw new Error("Failed to get webgl2 context");const n=`#version 300 es
|
|
precision mediump float;
|
|
|
|
in vec2 shapeVertexPosition;
|
|
|
|
uniform vec4 canvasPageBounds;
|
|
|
|
// taken (with thanks) from
|
|
// https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html
|
|
void main() {
|
|
// convert the position from pixels to 0.0 to 1.0
|
|
vec2 zeroToOne = (shapeVertexPosition - canvasPageBounds.xy) / canvasPageBounds.zw;
|
|
|
|
// convert from 0->1 to 0->2
|
|
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
|
|
// convert from 0->2 to -1->+1 (clipspace)
|
|
vec2 clipSpace = zeroToTwo - 1.0;
|
|
|
|
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
|
|
}`,r=t.createShader(t.VERTEX_SHADER);if(!r)throw new Error("Failed to create vertex shader");if(t.shaderSource(r,n),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("Failed to compile vertex shader");const o=`#version 300 es
|
|
precision mediump float;
|
|
|
|
uniform vec4 fillColor;
|
|
out vec4 outputColor;
|
|
|
|
void main() {
|
|
outputColor = fillColor;
|
|
}`,s=t.createShader(t.FRAGMENT_SHADER);if(!s)throw new Error("Failed to create fragment shader");if(t.shaderSource(s,o),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw new Error("Failed to compile fragment shader");const i=t.createProgram();if(!i)throw new Error("Failed to create program");if(t.attachShader(i,r),t.attachShader(i,s),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS))throw new Error("Failed to link program");t.useProgram(i);const a=t.getAttribLocation(i,"shapeVertexPosition");if(a<0)throw new Error("Failed to get shapeVertexPosition attribute location");t.enableVertexAttribArray(a);const c=t.getUniformLocation(i,"canvasPageBounds"),l=t.getUniformLocation(i,"fillColor");if(!t.createBuffer())throw new Error("Failed to create buffer");if(!t.createBuffer())throw new Error("Failed to create buffer");return{context:t,selectedShapes:Jd(t,1024),unselectedShapes:Jd(t,4096),viewport:Jd(t,yj),collaborators:Jd(t,1024),prepareTriangles(p,f){t.bindBuffer(t.ARRAY_BUFFER,p.buffer),t.bufferData(t.ARRAY_BUFFER,p.vertices,t.STATIC_DRAW,0,f),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,0,0)},drawTrianglesTransparently(p){t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.drawArrays(t.TRIANGLES,0,p/2),t.disable(t.BLEND)},drawTriangles(p){t.drawArrays(t.TRIANGLES,0,p/2)},setFillColor(p){t.uniform4fv(l,p)},setCanvasPageBounds(p){t.uniform4fv(c,p)}}}function Jd(e,t){const n=e.createBuffer();if(!n)throw new Error("Failed to create buffer");return{buffer:n,vertices:new Float32Array(t)}}function hI(e,t,n){let r=e.vertices.length;for(;r<t+n.length;)r*=2;if(r!=e.vertices.length){const o=new Float32Array(r);o.set(e.vertices),e.vertices=o}e.vertices.set(n,t)}var Gte=Object.defineProperty,Yte=Object.getOwnPropertyDescriptor,ei=(e,t,n,r)=>{for(var o=Yte(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&Gte(t,n,o),o};class ss{constructor(t,n){m(this,"disposables",[]);m(this,"close",()=>this.disposables.forEach(t=>t()));m(this,"gl");m(this,"shapeGeometryCache");m(this,"colors");m(this,"id",et());m(this,"canvasBoundingClientRect",fn("canvasBoundingClientRect",new ne));m(this,"originPagePoint",new P);m(this,"originPageCenter",new P);m(this,"isInViewport",!1);m(this,"getMinimapPagePoint",(t,n)=>{const r=this.getCanvasPageBounds(),o=this.getCanvasScreenBounds();let s=t-o.x,i=n-o.y;return s*=r.width/o.width,i*=r.height/o.height,s+=r.minX,i+=r.minY,new P(s,i,1)});m(this,"minimapScreenPointToPagePoint",(t,n,r=!1,o=!1)=>{const{editor:s}=this,i=s.getViewportPageBounds();let{x:a,y:c}=this.getMinimapPagePoint(t,n);if(o){const l=this.editor.getCurrentPageBounds()??new ne,u=i,d=l.minX-u.width/2,p=l.maxX+u.width/2,f=l.minY-u.height/2,y=l.maxY+u.height/2,g=Math.max(0,d+u.width-a),w=Math.max(0,-(p-u.width-a)),S=Math.max(0,f+u.height-c),v=Math.max(0,-(y-u.height-c)),b=Math.max(0,g-w),E=Math.max(0,w-g),C=Math.max(0,S-v),I=Math.max(0,v-S);b&&b>E?a+=b/2:E&&(a-=E/2),C&&C>I?c+=C/2:I&&(c-=I/2),a=Ns(a,d,p),c=Ns(c,f,y)}if(r){const{originPagePoint:l}=this,u=Math.abs(a-l.x),d=Math.abs(c-l.y);u>d?c=l.y:a=l.x}return new P(a,c)});m(this,"render",()=>{const t=this.gl.context,n=this.getCanvasSize();this.gl.setCanvasPageBounds(this.getCanvasPageBoundsArray()),this.elem.width=n.x,this.elem.height=n.y,t.viewport(0,0,n.x,n.y),t.clearColor(this.colors.background[0],this.colors.background[1],this.colors.background[2],1),t.clear(t.COLOR_BUFFER_BIT);const r=new Set(this.editor.getSelectedShapeIds()),o=this.colors;let s=0,i=0;const a=this.editor.getCurrentPageShapeIdsSorted();for(let c=0,l=a.length;c<l;c++){const u=a[c],d=this.shapeGeometryCache.get(u);if(!d)continue;const p=d.length;r.has(u)?(hI(this.gl.selectedShapes,s,d),s+=p):(hI(this.gl.unselectedShapes,i,d),i+=p)}this.drawShapes(this.gl.unselectedShapes,i,o.shapeFill),this.drawShapes(this.gl.selectedShapes,s,o.selectFill),this.drawViewport(),this.drawCollaborators()});this.editor=t,this.elem=n,this.gl=Vte(n),this.shapeGeometryCache=t.store.createComputedCache("webgl-geometry",r=>{const o=t.getShapeMaskedPageBounds(r.id);if(!o)return null;const s=new Float32Array(12);return ga(s,0,o.x,o.y,o.w,o.h),s}),this.colors=this._getColors(),this.disposables.push(this._listenForCanvasResize(),Sc("minimap render",this.render))}_getColors(){const t=getComputedStyle(this.editor.getContainer());return{shapeFill:sl(t.getPropertyValue("--color-text-3").trim()),selectFill:sl(t.getPropertyValue("--color-selected").trim()),viewportFill:sl(t.getPropertyValue("--color-muted-1").trim()),background:sl(t.getPropertyValue("--color-low").trim())}}updateColors(){this.colors=this._getColors()}getDpr(){return this.editor.getInstanceState().devicePixelRatio}getContentPageBounds(){const t=this.editor.getViewportPageBounds(),n=this.editor.getCurrentPageBounds();return n?ne.Expand(n,t):t}getContentScreenBounds(){const t=this.getContentPageBounds(),n=this.editor.pageToScreen(t.point),r=this.editor.pageToScreen(new P(t.maxX,t.maxY));return new ne(n.x,n.y,r.x-n.x,r.y-n.y)}_getCanvasBoundingRect(){const{x:t,y:n,width:r,height:o}=this.elem.getBoundingClientRect();return new ne(t,n,r,o)}getCanvasScreenBounds(){return this.canvasBoundingClientRect.get()}_listenForCanvasResize(){const t=new ResizeObserver(()=>{const n=this._getCanvasBoundingRect();this.canvasBoundingClientRect.set(n)});return t.observe(this.elem),()=>t.disconnect()}getCanvasSize(){const t=this.canvasBoundingClientRect.get(),n=this.getDpr();return new P(t.width*n,t.height*n)}getCanvasClientPosition(){return this.canvasBoundingClientRect.get().point}getCanvasPageBounds(){const t=this.getCanvasScreenBounds(),n=this.getContentPageBounds(),r=t.width/t.height;let o=n.width,s=o/r;s<n.height&&(s=n.height,o=s*r);const i=new ne(0,0,o,s);return i.center=n.center,i}getZoom(){return this.getCanvasPageBounds().width/this.getCanvasScreenBounds().width}getCanvasPageBoundsArray(){const{x:t,y:n,w:r,h:o}=this.getCanvasPageBounds();return new Float32Array([t,n,r,o])}drawShapes(t,n,r){this.gl.prepareTriangles(t,n),this.gl.setFillColor(r),this.gl.drawTriangles(n)}drawViewport(){const t=this.editor.getViewportPageBounds(),n=Wte(this.gl.viewport.vertices,t,4*this.getZoom());this.gl.prepareTriangles(this.gl.viewport,n),this.gl.setFillColor(this.colors.viewportFill),this.gl.drawTrianglesTransparently(n)}drawCollaborators(){const t=this.editor.getCollaboratorsOnCurrentPage();if(!t.length)return;const n=20,r=n*6,o=r*t.length;this.gl.collaborators.vertices.length<o&&(this.gl.collaborators.vertices=new Float32Array(o));const s=this.gl.collaborators.vertices;let i=0;const a=this.getZoom();for(const{cursor:c}of t)fa(s,{center:P.From(c),radius:3*a,offset:i,numArcSegments:n}),i+=r;this.gl.prepareTriangles(this.gl.collaborators,o),i=0;for(const{color:c}of t)this.gl.setFillColor(sl(c)),this.gl.context.drawArrays(this.gl.context.TRIANGLES,i/2,r/2),i+=r}}ei([V],ss.prototype,"getDpr");ei([V],ss.prototype,"getContentPageBounds");ei([V],ss.prototype,"getContentScreenBounds");ei([V],ss.prototype,"getCanvasSize");ei([V],ss.prototype,"getCanvasClientPosition");ei([V],ss.prototype,"getCanvasPageBounds");ei([V],ss.prototype,"getZoom");ei([V],ss.prototype,"getCanvasPageBoundsArray");function Xte(){const e=z(),t=x.useRef(null),n=x.useRef(!1),r=x.useRef();x.useEffect(()=>{const l=new ss(e,t.current);return r.current=l,r.current.close},[e]);const o=x.useCallback(l=>{if(!e.getCurrentPageShapeIds().size||!r.current)return;const u=r.current.minimapScreenPointToPagePoint(l.clientX,l.clientY,!1,!1),d=r.current.minimapScreenPointToPagePoint(l.clientX,l.clientY,!1,!0);r.current.originPagePoint.setTo(d),r.current.originPageCenter.setTo(e.getViewportPageBounds().center),e.centerOnPoint(u,{duration:Qr})},[e]),s=x.useCallback(l=>{if(!r.current)return;const u=l.currentTarget;if(Mu(u,l),!e.getCurrentPageShapeIds().size)return;n.current=!0,r.current.isInViewport=!1;const d=r.current.minimapScreenPointToPagePoint(l.clientX,l.clientY,!1,!1),p=r.current.minimapScreenPointToPagePoint(l.clientX,l.clientY,!1,!0),f=e.getViewportPageBounds();if(r.current.isInViewport=f.containsPoint(p),r.current.isInViewport)r.current.originPagePoint.setTo(p),r.current.originPageCenter.setTo(f.center);else{const g=P.Sub(f.center,f.point),w=P.Add(d,g);r.current.originPagePoint.setTo(w),r.current.originPageCenter.setTo(d),e.centerOnPoint(d,{duration:Qr})}function y(g){u&&Au(u,g),n.current=!1,document.body.removeEventListener("pointerup",y)}document.body.addEventListener("pointerup",y)},[e]),i=x.useCallback(l=>{if(!r.current)return;const u=r.current.minimapScreenPointToPagePoint(l.clientX,l.clientY,l.shiftKey,!0);if(n.current){if(r.current.isInViewport){const y=r.current.originPagePoint.clone().sub(r.current.originPageCenter);e.centerOnPoint(P.Sub(u,y));return}e.centerOnPoint(u)}const d=r.current.getMinimapPagePoint(l.clientX,l.clientY),p=e.pageToScreen(d),f={type:"pointer",target:"canvas",name:"pointer_move",..._n(l),point:p,isPen:e.getInstanceState().isPenMode};e.dispatch(f)},[e]),a=x.useCallback(l=>{const u=s2(l);e.dispatch({type:"wheel",name:"wheel",delta:u,point:new P(l.clientX,l.clientY),shiftKey:l.shiftKey,altKey:l.altKey,ctrlKey:l.metaKey||l.ctrlKey})},[e]),c=Ru();return x.useEffect(()=>{setTimeout(()=>{var l,u;(l=r.current)==null||l.updateColors(),(u=r.current)==null||u.render()})},[c]),h.jsx("div",{className:"tlui-minimap",children:h.jsx("canvas",{role:"img","aria-label":"minimap",ref:t,className:"tlui-minimap__canvas",onDoubleClick:o,onPointerMove:i,onPointerDown:s,onWheel:a})})}function qte(e,t){const[n,r]=Se.useState(t);Se.useLayoutEffect(()=>{const s=L0(e);if(s)try{r(JSON.parse(s))}catch{console.error(`Could not restore value ${e} from local storage.`)}},[e]);const o=Se.useCallback(s=>{r(i=>{const a=typeof s=="function"?s(i):s;return F0(e,JSON.stringify(a)),a})},[e]);return[n,o]}const Zte=x.memo(function(){const t=ce(),n=$e(),r=Rn(),[o,s]=qte("minimap",!0),i=x.useCallback(()=>{s(l=>!l)},[s]),{ZoomMenu:a,Minimap:c}=ti();return r<mt.MOBILE?null:h.jsxs("div",{className:"tlui-navigation-panel",children:[h.jsx("div",{className:"tlui-buttons__horizontal",children:a&&r<mt.TABLET?h.jsx(a,{}):o?h.jsxs(h.Fragment,{children:[a&&h.jsx(a,{}),c&&h.jsx(pe,{type:"icon","data-testid":"minimap.toggle-button",title:n("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:i,children:h.jsx(ke,{icon:o?"chevrons-ne":"chevrons-sw"})})]}):h.jsxs(h.Fragment,{children:[h.jsx(pe,{type:"icon","data-testid":"minimap.zoom-out",title:`${n(gu(t["zoom-out"].label))} ${Ov(t["zoom-out"].kbd)}`,onClick:()=>t["zoom-out"].onSelect("navigation-zone"),children:h.jsx(ke,{icon:"minus"})}),a&&h.jsx(a,{}),h.jsx(pe,{type:"icon","data-testid":"minimap.zoom-in",title:`${n(gu(t["zoom-in"].label))} ${Ov(t["zoom-in"].kbd)}`,onClick:()=>t["zoom-in"].onSelect("navigation-zone"),children:h.jsx(ke,{icon:"plus"})}),c&&h.jsx(pe,{type:"icon","data-testid":"minimap.toggle-button",title:n("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:i,children:h.jsx(ke,{icon:o?"chevrons-ne":"chevrons-sw"})})]})}),c&&r>=mt.TABLET&&!o&&h.jsx(c,{})]})}),Qte=function({name:t,id:n,isCurrentPage:r}){const o=z(),s=x.useRef(null),i=x.useCallback(c=>{o.renamePage(n,c||"New Page",{ephemeral:!0})},[o,n]),a=x.useCallback(c=>{o.mark("rename page"),o.renamePage(n,c||"New Page",{ephemeral:!1})},[o,n]);return h.jsx(Qx,{className:"tlui-page-menu__item__input",ref:c=>s.current=c,defaultValue:t,onValueChange:i,onComplete:a,onCancel:a,shouldManuallyMaintainScrollPositionWhenFocused:!0,autofocus:r,autoselect:!0})},Rv=(e,t,n,r)=>{let o;const s=e.getPages(),i=n>r?s[r-1]:s[r],a=n>r?s[r]:s[r+1];i&&!a?o=$o(i.index):!i&&a?o=z3(s[0].index):o=kl(i.index,a.index),o!==s[n].index&&(e.mark("moving page"),e.updatePage({id:t,index:o}))},pI=or(function({index:t,listSize:n,item:r,onRename:o}){const s=z(),i=$e(),a=s.getPages(),c=x.useCallback(()=>{s.mark("creating page");const p=Ho.createId();s.duplicatePage(r.id,p)},[s,r]),l=x.useCallback(()=>{Rv(s,r.id,t,t-1)},[s,r,t]),u=x.useCallback(()=>{Rv(s,r.id,t,t+1)},[s,r,t]),d=x.useCallback(()=>{s.mark("deleting page"),s.deletePage(r.id)},[s,r]);return h.jsxs(Li,{id:`page item submenu ${t}`,children:[h.jsx(Fi,{children:h.jsx(pe,{type:"icon",title:i("page-menu.submenu.title"),children:h.jsx(ke,{icon:"dots-vertical"})})}),h.jsx(Ni,{alignOffset:0,side:"right",sideOffset:-4,children:h.jsxs(vr,{type:"menu",sourceId:"page-menu",children:[h.jsxs(ye,{id:"modify",children:[o&&h.jsx(R,{id:"rename",label:"page-menu.submenu.rename",onSelect:o}),h.jsx(R,{id:"duplicate",label:"page-menu.submenu.duplicate-page",onSelect:c,disabled:a.length>=Gp}),t>0&&h.jsx(R,{id:"move-up",onSelect:l,label:"page-menu.submenu.move-up"}),t<n-1&&h.jsx(R,{id:"move-down",label:"page-menu.submenu.move-down",onSelect:u})]}),n>1&&h.jsx(ye,{id:"delete",children:h.jsx(R,{id:"delete",onSelect:d,label:"page-menu.submenu.delete"})})]})})]})}),Jte=x.memo(function(){const t=z(),n=$e(),r=Rn(),o=x.useCallback(()=>w(!1),[]),[s,i]=Qs("page-menu",o),a=36,c=x.useRef(null),l=K("pages",()=>t.getPages(),[t]),u=K("currentPage",()=>t.getCurrentPage(),[t]),d=K("currentPageId",()=>t.getCurrentPageId(),[t]),p=ns(),f=K("maxPageCountReached",()=>t.getPages().length>=Gp,[t]),y=K("isCoarsePointer",()=>t.getInstanceState().isCoarsePointer,[t]),[g,w]=x.useState(!1),S=x.useCallback(()=>{p||w(T=>!T)},[p]),v=x.useRef({isPointing:!1,status:"idle",pointing:null,startY:0,startIndex:0,dragIndex:0}),[b,E]=x.useState(Object.fromEntries(l.map((T,O)=>[T.id,{y:O*a,offsetY:0,isSelected:!1}])));x.useLayoutEffect(()=>{E(Object.fromEntries(l.map((T,O)=>[T.id,{y:O*a,offsetY:0,isSelected:!1}])))},[a,l]),x.useEffect(()=>{s&&requestAnimationFrame(()=>{const T=document.querySelector(`[data-testid="page-menu-item-${d}"]`);if(T){const O=c.current;if(!O)return;const N=T.offsetTop,F=O.scrollTop;N<F&&O.scrollTo({top:N});const L=N+a,B=O.scrollTop+O.offsetHeight;L>B&&O.scrollTo({top:L-O.offsetHeight})}})},[a,d,s]);const C=x.useCallback(T=>{const{clientY:O,currentTarget:N}=T,{dataset:{id:F,index:L}}=N;if(!F||!L)return;const B=v.current;Mu(T.currentTarget,T),B.status="pointing",B.pointing={id:F,index:+L};const Q=b[F].y;B.startY=O,B.startIndex=Math.max(0,Math.min(Math.round(Q/a),l.length-1))},[a,l.length,b]),I=x.useCallback(T=>{const O=v.current;if(O.status==="pointing"){const{clientY:N}=T,F=N-O.startY;Math.abs(F)>5&&(O.status="dragging")}if(O.status==="dragging"){const{clientY:N}=T,F=N-O.startY,L=b[O.pointing.id],{startIndex:B,pointing:q}=O,Q=L.y+F,H=Math.max(0,Math.min(Math.round(Q/a),l.length-1)),U={...b};if(U[q.id]={y:L.y,offsetY:F,isSelected:!0},H!==O.dragIndex){O.dragIndex=H;for(let W=0;W<l.length;W++){const Z=l[W];if(Z.id===O.pointing.id)continue;let{y:le}=U[Z.id];H===B?le=W*a:H<B?H<=W&&W<B?le=(W+1)*a:le=W*a:H>B&&(H>=W&&W>B?le=(W-1)*a:le=W*a),le!==U[Z.id].y&&(U[Z.id]={y:le,offsetY:0,isSelected:!0})}}E(U)}},[a,l,b]),_=x.useCallback(T=>{const O=v.current;if(O.status==="dragging"){const{id:N,index:F}=O.pointing;Rv(t,N,F,O.dragIndex)}Au(T.currentTarget,T),O.status="idle"},[t]),k=x.useCallback(T=>{const O=v.current;T.key==="Escape"&&(O.status==="dragging"&&E(Object.fromEntries(l.map((N,F)=>[N.id,{y:F*a,offsetY:0,isSelected:!1}]))),O.status="idle")},[a,l]),$=x.useCallback(()=>{p||t.batch(()=>{t.mark("creating page");const T=Ho.createId();t.createPage({name:n("page-menu.new-page-initial-name"),id:T}),t.setCurrentPage(T),w(!0)})},[t,n,p]);return h.jsxs(lw,{id:"pages",onOpenChange:i,open:s,children:[h.jsx(uw,{"data-testid":"main.page-menu",children:h.jsxs(pe,{type:"menu",title:u.name,"data-testid":"page-menu.button",className:"tlui-page-menu__trigger",children:[h.jsx("div",{className:"tlui-page-menu__name",children:u.name}),h.jsx(ke,{icon:"chevron-down",small:!0})]})}),h.jsx(dw,{side:"bottom",align:"start",sideOffset:6,children:h.jsxs("div",{className:"tlui-page-menu__wrapper",children:[h.jsxs("div",{className:"tlui-page-menu__header",children:[h.jsx("div",{className:"tlui-page-menu__header__title",children:n("page-menu.title")}),!p&&h.jsxs("div",{className:"tlui-buttons__horizontal",children:[h.jsx(pe,{type:"icon","data-testid":"page-menu.edit",title:n(g?"page-menu.edit-done":"page-menu.edit-start"),onClick:S,children:h.jsx(ke,{icon:g?"check":"edit"})}),h.jsx(pe,{type:"icon","data-testid":"page-menu.create",title:n(f?"page-menu.max-page-count-reached":"page-menu.create-new-page"),disabled:f,onClick:$,children:h.jsx(ke,{icon:"plus"})})]})]}),h.jsx("div",{"data-testid":"page-menu.list",className:"tlui-page-menu__list tlui-menu__group",style:{height:a*l.length+4},ref:c,children:l.map((T,O)=>{const N=b[T.id]??{position:O*40,offsetY:0};return g?h.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page_menu__item__sortable",style:{zIndex:T.id===u.id?888:O,transform:`translate(0px, ${N.y+N.offsetY}px)`},children:[h.jsx(pe,{type:"icon",tabIndex:-1,className:"tlui-page_menu__item__sortable__handle",onPointerDown:C,onPointerUp:_,onPointerMove:I,onKeyDown:k,"data-id":T.id,"data-index":O,children:h.jsx(ke,{icon:"drag-handle-dots"})}),r<mt.TABLET_SM&&y?h.jsxs(pe,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>{const F=window.prompt("Rename page",T.name);F&&F!==T.name&&t.renamePage(T.id,F)},onDoubleClick:S,children:[h.jsx(Dv,{checked:T.id===u.id}),h.jsx(vt,{children:T.name})]}):h.jsx("div",{className:"tlui-page_menu__item__sortable__title",style:{height:a},children:h.jsx(Qte,{id:T.id,name:T.name,isCurrentPage:T.id===u.id})}),!p&&h.jsx("div",{className:"tlui-page_menu__item__submenu","data-isediting":g,children:h.jsx(pI,{index:O,item:T,listSize:l.length})})]},T.id+"_editing"):h.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page-menu__item",children:[h.jsxs(pe,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>t.setCurrentPage(T.id),onDoubleClick:S,title:n("page-menu.go-to-page"),children:[h.jsx(Dv,{checked:T.id===u.id}),h.jsx(vt,{children:T.name})]}),!p&&h.jsx("div",{className:"tlui-page_menu__item__submenu",children:h.jsx(pI,{index:O,item:T,listSize:l.length,onRename:()=>{if(t.environment.isIos){const F=window.prompt("Rename page",T.name);F&&F!==T.name&&t.renamePage(T.id,F)}else t.batch(()=>{w(!0),t.setCurrentPage(T.id)})}})})]},T.id)})})]})})]})});function ene(){const e=ce(),t=z(),n=JT(),r=QT(),o=wn(1),s=ns(),i=K("should display quick actions",()=>t.isInAny("select","hand","zoom"),[t]);if(!(s&&!i))return h.jsxs(h.Fragment,{children:[h.jsx(R,{...e.undo,disabled:!n}),h.jsx(R,{...e.redo,disabled:!r}),h.jsx(R,{...e.delete,disabled:!o}),h.jsx(R,{...e.duplicate,disabled:!o})]})}const tne=x.memo(function({children:t}){const n=t??h.jsx(ene,{});return h.jsx(vr,{type:"small-icons",sourceId:"quick-actions",children:n})}),nne=Object.freeze([tr,Ti,sc,co]);function Sj(e=nne){const t=z();return K("getRelevantStyles",()=>{var s;const n=new VS(t.getSharedStyles()),r=!!((s=t.root.getCurrent())!=null&&s.shapeType),o=t.isIn("select")&&t.getSelectedShapeIds().length>0;if(n.size===0&&t.isIn("select")&&t.getSelectedShapeIds().length===0)for(const i of e)n.applyValue(i,t.getStyleForNextShape(i));return r||o||n.size>0?n:null},[t])}const Or={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"}],horizontalAlign:[{value:"start",icon:"text-align-left"},{value:"middle",icon:"text-align-center"},{value:"end",icon:"text-align-right"}],verticalAlign:[{value:"start",icon:"vertical-align-start"},{value:"middle",icon:"vertical-align-center"},{value:"end",icon:"vertical-align-end"}],geo:[{value:"rectangle",icon:"geo-rectangle"},{value:"ellipse",icon:"geo-ellipse"},{value:"cloud",icon:"geo-cloud"},{value:"triangle",icon:"geo-triangle"},{value:"diamond",icon:"geo-diamond"},{value:"pentagon",icon:"geo-pentagon"},{value:"hexagon",icon:"geo-hexagon"},{value:"octagon",icon:"geo-octagon"},{value:"star",icon:"geo-star"},{value:"rhombus",icon:"geo-rhombus"},{value:"rhombus-2",icon:"geo-rhombus-2"},{value:"oval",icon:"geo-oval"},{value:"trapezoid",icon:"geo-trapezoid"},{value:"arrow-right",icon:"geo-arrow-right"},{value:"arrow-left",icon:"geo-arrow-left"},{value:"arrow-up",icon:"geo-arrow-up"},{value:"arrow-down",icon:"geo-arrow-down"},{value:"x-box",icon:"geo-x-box"},{value:"check-box",icon:"geo-check-box"}],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"}]};function rne(e){const{uiType:t,items:n,title:r,style:o,value:s,onValueChange:i,theme:a}=e,c=z(),l=$e(),u=x.useRef(!1),{handleButtonClick:d,handleButtonPointerDown:p,handleButtonPointerEnter:f,handleButtonPointerUp:y}=x.useMemo(()=>{const g=()=>{u.current=!1,window.removeEventListener("pointerup",g)};return{handleButtonClick:E=>{const{id:C}=E.currentTarget.dataset;s.type==="shared"&&s.value===C||(c.mark("point picker item"),i(o,C,!1))},handleButtonPointerDown:E=>{const{id:C}=E.currentTarget.dataset;c.mark("point picker item"),i(o,C,!0),u.current=!0,window.addEventListener("pointerup",g)},handleButtonPointerEnter:E=>{if(!u.current)return;const{id:C}=E.currentTarget.dataset;i(o,C,!0)},handleButtonPointerUp:E=>{const{id:C}=E.currentTarget.dataset;s.type==="shared"&&s.value===C||i(o,C,!1)}}},[s,c,i,o]);return h.jsx("div",{"data-testid":`style.${t}`,className:ue("tlui-buttons__grid"),children:n.map(g=>h.jsx(pe,{type:"icon","data-id":g.value,"data-testid":`style.${t}.${g.value}`,"aria-label":g.value,"data-state":s.type==="shared"&&s.value===g.value?"hinted":void 0,title:r+" — "+l(`${t}-style.${g.value}`),className:ue("tlui-button-grid__button"),style:o===tr?{color:a[g.value].solid}:void 0,onPointerEnter:f,onPointerDown:p,onPointerUp:y,onClick:d,children:h.jsx(ke,{icon:g.icon})},g.value))})}const Ra=x.memo(rne);function vj(e,[t,n]){return Math.min(n,Math.max(t,e))}function one(e){const t=x.useRef({value:e,previous:e});return x.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}const xj=["PageUp","PageDown"],wj=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],bj={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Ku="Slider",[Lv,sne,ine]=og(Ku),[Pj,$oe]=mo(Ku,[ine]),[ane,wg]=Pj(Ku),cne=x.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:l=[r],value:u,onValueChange:d=()=>{},onValueCommit:p=()=>{},inverted:f=!1,...y}=e,[g,w]=x.useState(null),S=Xe(t,L=>w(L)),v=x.useRef(new Set),b=x.useRef(0),E=i==="horizontal",C=g?!!g.closest("form"):!0,I=E?lne:une,[_=[],k]=Zs({prop:u,defaultProp:l,onChange:L=>{var B;(B=[...v.current][b.current])===null||B===void 0||B.focus(),d(L)}}),$=x.useRef(_);function T(L){const B=vne(_,L);F(L,B)}function O(L){F(L,b.current)}function N(){const L=$.current[b.current];_[b.current]!==L&&p(_)}function F(L,B,{commit:q}={commit:!1}){const Q=Pne(s),H=Cne(Math.round((L-r)/s)*s+r,Q),U=vj(H,[r,o]);k((W=[])=>{const Z=yne(W,U,B);if(bne(Z,c*s)){b.current=Z.indexOf(U);const le=String(Z)!==String(W);return le&&q&&p(Z),le?Z:W}else return W})}return x.createElement(ane,{scope:e.__scopeSlider,disabled:a,min:r,max:o,valueIndexToChangeRef:b,thumbs:v.current,values:_,orientation:i},x.createElement(Lv.Provider,{scope:e.__scopeSlider},x.createElement(Lv.Slot,{scope:e.__scopeSlider},x.createElement(I,X({"aria-disabled":a,"data-disabled":a?"":void 0},y,{ref:S,onPointerDown:ie(y.onPointerDown,()=>{a||($.current=_)}),min:r,max:o,inverted:f,onSlideStart:a?void 0:T,onSlideMove:a?void 0:O,onSlideEnd:a?void 0:N,onHomeKeyDown:()=>!a&&F(r,0,{commit:!0}),onEndKeyDown:()=>!a&&F(o,_.length-1,{commit:!0}),onStepKeyDown:({event:L,direction:B})=>{if(!a){const H=xj.includes(L.key)||L.shiftKey&&wj.includes(L.key)?10:1,U=b.current,W=_[U],Z=s*H*B;F(W+Z,U,{commit:!0})}}})))),C&&_.map((L,B)=>x.createElement(mne,{key:B,name:n?n+(_.length>1?"[]":""):void 0,value:L})))}),[Cj,Ij]=Pj(Ku,{startEdge:"left",endEdge:"right",size:"width",direction:1}),lne=x.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:l,...u}=e,[d,p]=x.useState(null),f=Xe(t,b=>p(b)),y=x.useRef(),g=hw(o),w=g==="ltr",S=w&&!s||!w&&s;function v(b){const E=y.current||d.getBoundingClientRect(),C=[0,E.width],_=xw(C,S?[n,r]:[r,n]);return y.current=E,_(b-E.left)}return x.createElement(Cj,{scope:e.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width"},x.createElement(Ej,X({dir:g,"data-orientation":"horizontal"},u,{ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:b=>{const E=v(b.clientX);i==null||i(E)},onSlideMove:b=>{const E=v(b.clientX);a==null||a(E)},onSlideEnd:()=>{y.current=void 0,c==null||c()},onStepKeyDown:b=>{const C=bj[S?"from-left":"from-right"].includes(b.key);l==null||l({event:b,direction:C?-1:1})}})))}),une=x.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...l}=e,u=x.useRef(null),d=Xe(t,u),p=x.useRef(),f=!o;function y(g){const w=p.current||u.current.getBoundingClientRect(),S=[0,w.height],b=xw(S,f?[r,n]:[n,r]);return p.current=w,b(g-w.top)}return x.createElement(Cj,{scope:e.__scopeSlider,startEdge:f?"bottom":"top",endEdge:f?"top":"bottom",size:"height",direction:f?1:-1},x.createElement(Ej,X({"data-orientation":"vertical"},l,{ref:d,style:{...l.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:g=>{const w=y(g.clientY);s==null||s(w)},onSlideMove:g=>{const w=y(g.clientY);i==null||i(w)},onSlideEnd:()=>{p.current=void 0,a==null||a()},onStepKeyDown:g=>{const S=bj[f?"from-bottom":"from-top"].includes(g.key);c==null||c({event:g,direction:S?-1:1})}})))}),Ej=x.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...l}=e,u=wg(Ku,n);return x.createElement(Ke.span,X({},l,{ref:t,onKeyDown:ie(e.onKeyDown,d=>{d.key==="Home"?(i(d),d.preventDefault()):d.key==="End"?(a(d),d.preventDefault()):xj.concat(wj).includes(d.key)&&(c(d),d.preventDefault())}),onPointerDown:ie(e.onPointerDown,d=>{const p=d.target;p.setPointerCapture(d.pointerId),d.preventDefault(),u.thumbs.has(p)?p.focus():r(d)}),onPointerMove:ie(e.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&o(d)}),onPointerUp:ie(e.onPointerUp,d=>{const p=d.target;p.hasPointerCapture(d.pointerId)&&(p.releasePointerCapture(d.pointerId),s(d))})}))}),dne="SliderTrack",hne=x.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=wg(dne,n);return x.createElement(Ke.span,X({"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation},r,{ref:t}))}),fI="SliderRange",pne=x.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=wg(fI,n),s=Ij(fI,n),i=x.useRef(null),a=Xe(t,i),c=o.values.length,l=o.values.map(p=>_j(p,o.min,o.max)),u=c>1?Math.min(...l):0,d=100-Math.max(...l);return x.createElement(Ke.span,X({"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0},r,{ref:a,style:{...e.style,[s.startEdge]:u+"%",[s.endEdge]:d+"%"}}))}),gI="SliderThumb",fne=x.forwardRef((e,t)=>{const n=sne(e.__scopeSlider),[r,o]=x.useState(null),s=Xe(t,a=>o(a)),i=x.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return x.createElement(gne,X({},e,{ref:s,index:i}))}),gne=x.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,...o}=e,s=wg(gI,n),i=Ij(gI,n),[a,c]=x.useState(null),l=Xe(t,w=>c(w)),u=lA(a),d=s.values[r],p=d===void 0?0:_j(d,s.min,s.max),f=Sne(r,s.values.length),y=u==null?void 0:u[i.size],g=y?xne(y,p,i.direction):0;return x.useEffect(()=>{if(a)return s.thumbs.add(a),()=>{s.thumbs.delete(a)}},[a,s.thumbs]),x.createElement("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${p}% + ${g}px)`}},x.createElement(Lv.ItemSlot,{scope:e.__scopeSlider},x.createElement(Ke.span,X({role:"slider","aria-label":e["aria-label"]||f,"aria-valuemin":s.min,"aria-valuenow":d,"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:l,style:d===void 0?{display:"none"}:e.style,onFocus:ie(e.onFocus,()=>{s.valueIndexToChangeRef.current=r})}))))}),mne=e=>{const{value:t,...n}=e,r=x.useRef(null),o=one(t);return x.useEffect(()=>{const s=r.current,i=window.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(i,"value").set;if(o!==t&&c){const l=new Event("input",{bubbles:!0});c.call(s,t),s.dispatchEvent(l)}},[o,t]),x.createElement("input",X({style:{display:"none"}},n,{ref:r,defaultValue:t}))};function yne(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function _j(e,t,n){const s=100/(n-t)*(e-t);return vj(s,[0,100])}function Sne(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function vne(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function xne(e,t,n){const r=e/2,s=xw([0,50],[0,r]);return(r-s(t)*n)*n}function wne(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function bne(e,t){if(t>0){const n=wne(e);return Math.min(...n)>=t}return!0}function xw(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Pne(e){return(String(e).split(".")[1]||"").length}function Cne(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}const Ine=cne,Ene=hne,_ne=pne,kne=fne,Tne=x.memo(function(t){const{title:n,steps:r,value:o,label:s,onValueChange:i}=t,a=z(),c=$e(),l=x.useCallback(p=>{i(p[0],!0)},[i]),u=x.useCallback(()=>{a.mark("click slider")},[a]),d=x.useCallback(()=>{o&&i(o,!1)},[o,i]);return h.jsx("div",{className:"tlui-slider__container",children:h.jsxs(Ine,{"data-testid":t["data-testid"],className:"tlui-slider","area-label":"Opacity",dir:"ltr",min:0,max:r,step:1,value:o?[o]:void 0,onPointerDown:u,onValueChange:l,onPointerUp:d,title:n+" — "+c(s),children:[h.jsx(Ene,{className:"tlui-slider__track",dir:"ltr",children:o!==null&&h.jsx(_ne,{className:"tlui-slider__range",dir:"ltr"})}),o!==null&&h.jsx(kne,{className:"tlui-slider__thumb",dir:"ltr"})]})})});function $ne({label:e,uiTypeA:t,uiTypeB:n,labelA:r,labelB:o,itemsA:s,itemsB:i,styleA:a,styleB:c,valueA:l,valueB:u,onValueChange:d}){const p=$e(),f=x.useMemo(()=>{var g;return((g=s.find(w=>l.type==="shared"&&l.value===w.value))==null?void 0:g.icon)??"mixed"},[s,l]),y=x.useMemo(()=>{var g;return((g=i.find(w=>u.type==="shared"&&u.value===w.value))==null?void 0:g.icon)??"mixed"},[i,u]);return l===void 0&&u===void 0?null:h.jsxs("div",{className:"tlui-style-panel__double-select-picker",children:[h.jsx("div",{title:p(e),className:"tlui-style-panel__double-select-picker-label",children:p(e)}),h.jsxs("div",{className:"tlui-buttons__horizontal",children:[h.jsxs(Li,{id:`style panel ${t} A`,children:[h.jsx(Fi,{children:h.jsx(pe,{type:"icon","data-testid":`style.${t}`,title:p(r)+" — "+(l===null||l.type==="mixed"?p("style-panel.mixed"):p(`${t}-style.${l.value}`)),children:h.jsx(ke,{icon:f,small:!0,invertIcon:!0})})}),h.jsx(Ni,{side:"bottom",align:"end",sideOffset:0,alignOffset:-2,children:h.jsx("div",{className:"tlui-buttons__grid",children:s.map((g,w)=>h.jsx(wu,{"data-testid":`style.${t}.${g.value}`,children:h.jsx(pe,{type:"icon",onClick:()=>d(a,g.value,!1),title:`${p(r)} — ${p(`${t}-style.${g.value}`)}`,children:h.jsx(ke,{icon:g.icon,invertIcon:!0})},g.value)},w))})})]}),h.jsxs(Li,{id:`style panel ${n}`,children:[h.jsx(Fi,{children:h.jsx(pe,{type:"icon","data-testid":`style.${n}`,title:p(o)+" — "+(u===null||u.type==="mixed"?p("style-panel.mixed"):p(`${n}-style.${u.value}`)),children:h.jsx(ke,{icon:y,small:!0})})}),h.jsx(Ni,{side:"bottom",align:"end",sideOffset:0,alignOffset:-2,children:h.jsx("div",{className:"tlui-buttons__grid",children:i.map(g=>h.jsx(wu,{children:h.jsx(pe,{type:"icon",title:`${p(o)} — ${p(`${n}-style.${g.value}`)}`,"data-testid":`style.${n}.${g.value}`,onClick:()=>d(c,g.value,!1),children:h.jsx(ke,{icon:g.icon})})},g.value))})})]})]})]})}const Mne=x.memo($ne);function Ane({id:e,label:t,uiType:n,style:r,items:o,type:s,value:i,onValueChange:a}){const c=$e(),l=z(),u=x.useMemo(()=>{var f;return(f=o.find(y=>i.type==="shared"&&y.value===i.value))==null?void 0:f.icon},[o,i]),d=i.type==="mixed"?c("style-panel.mixed"):c(`${n}-style.${i.value}`),p=t?c(t):"";return h.jsxs(Li,{id:`style panel ${e}`,children:[h.jsx(Fi,{children:h.jsxs(pe,{type:s,"data-testid":`style.${n}`,title:d,children:[h.jsx(vt,{children:p}),h.jsx(ke,{icon:u??"mixed"})]})}),h.jsx(Ni,{side:"left",align:"center",alignOffset:0,children:h.jsx("div",{className:"tlui-buttons__grid",children:o.map(f=>h.jsx(wu,{children:h.jsx(pe,{type:"icon","data-testid":`style.${n}.${f.value}`,title:c(`${n}-style.${f.value}`),onClick:()=>{l.mark("select style dropdown item"),a(r,f.value,!1)},children:h.jsx(ke,{icon:f.icon})})},f.value))})})]})}const ww=x.memo(Ane);function jne({styles:e}){const t=Ru();if(!e)return null;const n=e.get(oo),r=e.get(Bp),o=e.get(zp),s=e.get(Hp),i=e.get(ao),a=n===void 0,c=r===void 0&&o===void 0,l=s===void 0,u=i===void 0,d=Jo({isDarkMode:t});return h.jsxs(h.Fragment,{children:[h.jsx(One,{theme:d,styles:e}),!u&&h.jsx(Dne,{theme:d,styles:e}),!(a&&c&&l)&&h.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[h.jsx(Rne,{styles:e}),h.jsx(Fne,{styles:e}),h.jsx(Lne,{styles:e})]})]})}function Wu(){const e=z(),t=So();return Se.useMemo(()=>function(r,o,s){e.batch(()=>{e.isIn("select")&&e.setStyleForSelectedShapes(r,o,{squashing:s}),e.setStyleForNextShapes(r,o,{squashing:s}),e.updateInstanceState({isChangingStyle:!0},{ephemeral:!0})}),t("set-style",{source:"style-panel",id:r.id,value:o})},[e,t])}function One({styles:e,theme:t}){const n=$e(),r=z(),o=Wu(),s=e.get(tr),i=e.get(sc),a=e.get(Ti),c=e.get(co),l=i!==void 0||a!==void 0||c!==void 0;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{tabIndex:-1,className:"tlui-style-panel__section__common","aria-label":"style panel styles","data-testid":"style.panel",children:[s===void 0?null:h.jsx(Ra,{title:n("style-panel.color"),uiType:"color",style:tr,items:Or.color,value:s,onValueChange:o,theme:t}),h.jsx(Nne,{})]}),l&&h.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[i===void 0?null:h.jsx(Ra,{title:n("style-panel.fill"),uiType:"fill",style:sc,items:Or.fill,value:i,onValueChange:o,theme:t}),a===void 0?null:h.jsx(Ra,{title:n("style-panel.dash"),uiType:"dash",style:Ti,items:Or.dash,value:a,onValueChange:o,theme:t}),c===void 0?null:h.jsx(Ra,{title:n("style-panel.size"),uiType:"size",style:co,items:Or.size,value:c,onValueChange:(u,d,p)=>{o(u,d,p);const f=r.getSelectedShapeIds();f.length>0&&We(r,f)},theme:t})]})]})}function Dne({theme:e,styles:t}){const n=$e(),r=Wu(),o=t.get(ao),s=t.get(ru),i=t.get(Up);return o===void 0&&s===void 0?null:h.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel text",children:[o===void 0?null:h.jsx(Ra,{title:n("style-panel.font"),uiType:"font",style:ao,items:Or.font,value:o,onValueChange:r,theme:e}),s===void 0?null:h.jsxs("div",{className:"tlui-style-panel__row",children:[h.jsx(Ra,{title:n("style-panel.align"),uiType:"align",style:ru,items:Or.horizontalAlign,value:s,onValueChange:r,theme:e}),h.jsx("div",{className:"tlui-style-panel__row__extra-button",children:i===void 0?h.jsx(pe,{type:"icon",title:n("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:h.jsx(ke,{icon:"vertical-align-center"})}):h.jsx(ww,{type:"icon",id:"geo-vertical-alignment",uiType:"verticalAlign",style:Up,items:Or.verticalAlign,value:i,onValueChange:r})})]})]})}function Rne({styles:e}){const t=Wu(),n=e.get(oo);return n===void 0?null:h.jsx(ww,{id:"geo",type:"menu",label:"style-panel.geo",uiType:"geo",style:oo,items:Or.geo,value:n,onValueChange:t})}function Lne({styles:e}){const t=Wu(),n=e.get(Hp);return n===void 0?null:h.jsx(ww,{id:"spline",type:"menu",label:"style-panel.spline",uiType:"spline",style:Hp,items:Or.spline,value:n,onValueChange:t})}function Fne({styles:e}){const t=Wu(),n=e.get(Bp),r=e.get(zp);return!n||!r?null:h.jsx(Mne,{label:"style-panel.arrowheads",uiTypeA:"arrowheadStart",styleA:zp,itemsA:Or.arrowheadStart,valueA:r,uiTypeB:"arrowheadEnd",styleB:Bp,itemsB:Or.arrowheadEnd,valueB:n,onValueChange:t,labelA:"style-panel.arrowhead-start",labelB:"style-panel.arrowhead-end"})}const il=[.1,.25,.5,.75,1];function Nne(){const e=z(),t=K("opacity",()=>e.getSharedOpacity(),[e]),n=So(),r=$e(),o=Se.useCallback((i,a)=>{const c=il[i];e.batch(()=>{e.isIn("select")&&e.setOpacityForSelectedShapes(c,{squashing:a}),e.setOpacityForNextShapes(c,{squashing:a}),e.updateInstanceState({isChangingStyle:!0},{ephemeral:!0})}),n("set-style",{source:"style-panel",id:"opacity",value:i})},[e,n]);if(t===void 0)return null;const s=t.type==="mixed"?-1:il.indexOf(j3(il,i=>Math.abs(i-t.value)));return h.jsx(Tne,{"data-testid":"style.opacity",value:s>=0?s:il.length-1,label:t.type==="mixed"?"style-panel.mixed":`opacity-style.${t.value}`,onValueChange:o,steps:il.length-1,title:r("style-panel.opacity")})}const zne=x.memo(function({isMobile:t,children:n}){const r=z(),o=Sj(),s=x.useCallback(()=>{t||r.updateInstanceState({isChangingStyle:!1},{ephemeral:!0})},[r,t]),i=n??h.jsx(jne,{styles:o});return h.jsx("div",{className:ue("tlui-style-panel",{"tlui-style-panel__wrapper":!t}),"data-ismobile":t,onPointerLeave:s,children:i})});function Bne(){const e=z(),t=$e(),n=Sj(),r=n==null?void 0:n.get(tr),o=Jo({isDarkMode:e.user.getIsDarkMode()}),s=((r==null?void 0:r.type)==="shared"?o[r.value]:o.black).solid,i=K("disable style panel",()=>e.isInAny("hand","zoom","eraser","laser"),[e]),a=x.useCallback(l=>{l||e.updateInstanceState({isChangingStyle:!1},{ephemeral:!0})},[e]),{StylePanel:c}=ti();return c?h.jsxs(lw,{id:"mobile style menu",onOpenChange:a,children:[h.jsx(uw,{children:h.jsx(pe,{type:"tool","data-testid":"mobile-styles.button",style:{color:i?"var(--color-muted-1)":s},title:t("style-panel.title"),disabled:i,children:h.jsx(ke,{icon:i?"blob":(r==null?void 0:r.type)==="mixed"?"mixed":"blob"})})}),h.jsx(dw,{side:"top",align:"end",children:c&&h.jsx(c,{isMobile:!0})})]}):null}function Une(){return h.jsxs(h.Fragment,{children:[h.jsx(Hne,{}),h.jsx(Kne,{}),h.jsx(Wne,{}),h.jsx(Vne,{}),h.jsx(Gne,{}),h.jsx(Yne,{}),h.jsx(Xne,{}),h.jsx(qne,{}),h.jsx(Zne,{}),h.jsx(Qne,{}),h.jsx(Jne,{}),h.jsx(ere,{}),h.jsx(tre,{}),h.jsx(nre,{}),h.jsx(rre,{}),h.jsx(ore,{}),h.jsx(sre,{}),h.jsx(ire,{}),h.jsx(are,{}),h.jsx(cre,{}),h.jsx(lre,{}),h.jsx(ure,{}),h.jsx(dre,{}),h.jsx(hre,{}),h.jsx(pre,{}),h.jsx(fre,{}),h.jsx(gre,{}),h.jsx(mre,{})]})}function Ue(e){var r;const t=z(),n=(r=e.meta)==null?void 0:r.geo;return K("is tool selected",()=>{const o=t.getCurrentToolId(),s=t.getSharedStyles().getAsKnownValue(oo);return n?o==="geo"&&s===n:o===e.id},[t,e.id,n])}function Hne(){const e=De(),t=Ue(e.select);return h.jsx(R,{...e.select,isSelected:t})}function Kne(){const e=De(),t=Ue(e.hand);return h.jsx(R,{...e.hand,isSelected:t})}function Wne(){const e=De(),t=Ue(e.draw);return h.jsx(R,{...e.draw,isSelected:t})}function Vne(){const e=De(),t=Ue(e.eraser);return h.jsx(R,{...e.eraser,isSelected:t})}function Gne(){const e=De(),t=Ue(e.arrow);return h.jsx(R,{...e.arrow,isSelected:t})}function Yne(){const e=De(),t=Ue(e.text);return h.jsx(R,{...e.text,isSelected:t})}function Xne(){const e=De(),t=Ue(e.note);return h.jsx(R,{...e.note,isSelected:t})}function qne(){const e=De(),t=Ue(e.asset);return h.jsx(R,{...e.asset,isSelected:t})}function Zne(){const e=De(),t=Ue(e.rectangle);return h.jsx(R,{...e.rectangle,isSelected:t})}function Qne(){const e=De(),t=Ue(e.ellipse);return h.jsx(R,{...e.ellipse,isSelected:t})}function Jne(){const e=De(),t=Ue(e.diamond);return h.jsx(R,{...e.diamond,isSelected:t})}function ere(){const e=De(),t=Ue(e.triangle);return h.jsx(R,{...e.triangle,isSelected:t})}function tre(){const e=De(),t=Ue(e.trapezoid);return h.jsx(R,{...e.trapezoid,isSelected:t})}function nre(){const e=De(),t=Ue(e.rhombus);return h.jsx(R,{...e.rhombus,isSelected:t})}function rre(){const e=De(),t=Ue(e.hexagon);return h.jsx(R,{...e.hexagon,isSelected:t})}function ore(){const e=De(),t=Ue(e.cloud);return h.jsx(R,{...e.cloud,isSelected:t})}function sre(){const e=De(),t=Ue(e.star);return h.jsx(R,{...e.star,isSelected:t})}function ire(){const e=De(),t=Ue(e.oval);return h.jsx(R,{...e.oval,isSelected:t})}function are(){const e=De(),t=Ue(e["x-box"]);return h.jsx(R,{...e["x-box"],isSelected:t})}function cre(){const e=De(),t=Ue(e["check-box"]);return h.jsx(R,{...e["check-box"],isSelected:t})}function lre(){const e=De(),t=Ue(e["arrow-left"]);return h.jsx(R,{...e["arrow-left"],isSelected:t})}function ure(){const e=De(),t=Ue(e["arrow-up"]);return h.jsx(R,{...e["arrow-up"],isSelected:t})}function dre(){const e=De(),t=Ue(e["arrow-down"]);return h.jsx(R,{...e["arrow-down"],isSelected:t})}function hre(){const e=De(),t=Ue(e["arrow-right"]);return h.jsx(R,{...e["arrow-right"],isSelected:t})}function pre(){const e=De(),t=Ue(e.line);return h.jsx(R,{...e.line,isSelected:t})}function fre(){const e=De(),t=Ue(e.highlight);return h.jsx(R,{...e.highlight,isSelected:t})}function gre(){const e=De(),t=Ue(e.frame);return h.jsx(R,{...e.frame,isSelected:t})}function mre(){const e=De(),t=Ue(e.laser);return h.jsx(R,{...e.laser,isSelected:t})}const py=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function fy(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on".concat(t),n)}function al(e,t,n,r){e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on".concat(t),n)}function kj(e,t){const n=t.slice(0,t.length-1);for(let r=0;r<n.length;r++)n[r]=e[n[r].toLowerCase()];return n}function Tj(e){typeof e!="string"&&(e=""),e=e.replace(/\s/g,"");const t=e.split(",");let n=t.lastIndexOf("");for(;n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function yre(e,t){const n=e.length>=t.length?e:t,r=e.length>=t.length?t:e;let o=!0;for(let s=0;s<n.length;s++)r.indexOf(n[s])===-1&&(o=!1);return o}const bu={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,"-":py?173:189,"=":py?61:187,";":py?59:186,"'":222,"[":219,"]":221,"\\":220},po={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},Fv={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Lt={16:!1,18:!1,17:!1,91:!1},ct={};for(let e=1;e<20;e++)bu["f".concat(e)]=111+e;let Ve=[],Rl=null,$j="all";const ko=new Map,Vu=e=>bu[e.toLowerCase()]||po[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),Sre=e=>Object.keys(bu).find(t=>bu[t]===e),vre=e=>Object.keys(po).find(t=>po[t]===e);function Mj(e){$j=e||"all"}function Pu(){return $j||"all"}function xre(){return Ve.slice(0)}function wre(){return Ve.map(e=>Sre(e)||vre(e)||String.fromCharCode(e))}function bre(){const e=[];return Object.keys(ct).forEach(t=>{ct[t].forEach(n=>{let{key:r,scope:o,mods:s,shortcut:i}=n;e.push({scope:o,shortcut:i,mods:s,keys:r.split("+").map(a=>Vu(a))})})}),e}function Pre(e){const t=e.target||e.srcElement,{tagName:n}=t;let r=!0;const o=n==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(o||n==="TEXTAREA"||n==="SELECT")&&!t.readOnly)&&(r=!1),r}function Cre(e){return typeof e=="string"&&(e=Vu(e)),Ve.indexOf(e)!==-1}function Ire(e,t){let n,r;e||(e=Pu());for(const o in ct)if(Object.prototype.hasOwnProperty.call(ct,o))for(n=ct[o],r=0;r<n.length;)n[r].scope===e?n.splice(r,1).forEach(i=>{let{element:a}=i;return bw(a)}):r++;Pu()===e&&Mj(t||"all")}function Ere(e){let t=e.keyCode||e.which||e.charCode;const n=Ve.indexOf(t);if(n>=0&&Ve.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&Ve.splice(0,Ve.length),(t===93||t===224)&&(t=91),t in Lt){Lt[t]=!1;for(const r in po)po[r]===t&&(kn[r]=!1)}}function Aj(e){if(typeof e>"u")Object.keys(ct).forEach(o=>{Array.isArray(ct[o])&&ct[o].forEach(s=>eh(s)),delete ct[o]}),bw(null);else if(Array.isArray(e))e.forEach(o=>{o.key&&eh(o)});else if(typeof e=="object")e.key&&eh(e);else if(typeof e=="string"){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];let[o,s]=n;typeof o=="function"&&(s=o,o=""),eh({key:e,scope:o,method:s,splitKey:"+"})}}const eh=e=>{let{key:t,scope:n,method:r,splitKey:o="+"}=e;Tj(t).forEach(i=>{const a=i.split(o),c=a.length,l=a[c-1],u=l==="*"?"*":Vu(l);if(!ct[u])return;n||(n=Pu());const d=c>1?kj(po,a):[],p=[];ct[u]=ct[u].filter(f=>{const g=(r?f.method===r:!0)&&f.scope===n&&yre(f.mods,d);return g&&p.push(f.element),!g}),p.forEach(f=>bw(f))})};function mI(e,t,n,r){if(t.element!==r)return;let o;if(t.scope===n||t.scope==="all"){o=t.mods.length>0;for(const s in Lt)Object.prototype.hasOwnProperty.call(Lt,s)&&(!Lt[s]&&t.mods.indexOf(+s)>-1||Lt[s]&&t.mods.indexOf(+s)===-1)&&(o=!1);(t.mods.length===0&&!Lt[16]&&!Lt[18]&&!Lt[17]&&!Lt[91]||o||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(Ve),t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function yI(e,t){const n=ct["*"];let r=e.keyCode||e.which||e.charCode;if(!kn.filter.call(this,e))return;if((r===93||r===224)&&(r=91),Ve.indexOf(r)===-1&&r!==229&&Ve.push(r),["ctrlKey","altKey","shiftKey","metaKey"].forEach(a=>{const c=Fv[a];e[a]&&Ve.indexOf(c)===-1?Ve.push(c):!e[a]&&Ve.indexOf(c)>-1?Ve.splice(Ve.indexOf(c),1):a==="metaKey"&&e[a]&&Ve.length===3&&(e.ctrlKey||e.shiftKey||e.altKey||(Ve=Ve.slice(Ve.indexOf(c))))}),r in Lt){Lt[r]=!0;for(const a in po)po[a]===r&&(kn[a]=!0);if(!n)return}for(const a in Lt)Object.prototype.hasOwnProperty.call(Lt,a)&&(Lt[a]=e[Fv[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(Ve.indexOf(17)===-1&&Ve.push(17),Ve.indexOf(18)===-1&&Ve.push(18),Lt[17]=!0,Lt[18]=!0);const o=Pu();if(n)for(let a=0;a<n.length;a++)n[a].scope===o&&(e.type==="keydown"&&n[a].keydown||e.type==="keyup"&&n[a].keyup)&&mI(e,n[a],o,t);if(!(r in ct))return;const s=ct[r],i=s.length;for(let a=0;a<i;a++)if((e.type==="keydown"&&s[a].keydown||e.type==="keyup"&&s[a].keyup)&&s[a].key){const c=s[a],{splitKey:l}=c,u=c.key.split(l),d=[];for(let p=0;p<u.length;p++)d.push(Vu(u[p]));d.sort().join("")===Ve.sort().join("")&&mI(e,c,o,t)}}function kn(e,t,n){Ve=[];const r=Tj(e);let o=[],s="all",i=document,a=0,c=!1,l=!0,u="+",d=!1,p=!1;for(n===void 0&&typeof t=="function"&&(n=t),Object.prototype.toString.call(t)==="[object Object]"&&(t.scope&&(s=t.scope),t.element&&(i=t.element),t.keyup&&(c=t.keyup),t.keydown!==void 0&&(l=t.keydown),t.capture!==void 0&&(d=t.capture),typeof t.splitKey=="string"&&(u=t.splitKey),t.single===!0&&(p=!0)),typeof t=="string"&&(s=t),p&&Aj(e,s);a<r.length;a++)e=r[a].split(u),o=[],e.length>1&&(o=kj(po,e)),e=e[e.length-1],e=e==="*"?"*":Vu(e),e in ct||(ct[e]=[]),ct[e].push({keyup:c,keydown:l,scope:s,mods:o,shortcut:r[a],method:n,key:r[a],splitKey:u,element:i});if(typeof i<"u"&&window){if(!ko.has(i)){const f=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return yI(g,i)},y=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;yI(g,i),Ere(g)};ko.set(i,{keydownListener:f,keyupListenr:y,capture:d}),fy(i,"keydown",f,d),fy(i,"keyup",y,d)}if(!Rl){const f=()=>{Ve=[]};Rl={listener:f,capture:d},fy(window,"focus",f,d)}}}function _re(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(ct).forEach(n=>{ct[n].filter(o=>o.scope===t&&o.shortcut===e).forEach(o=>{o&&o.method&&o.method()})})}function bw(e){const t=Object.values(ct).flat();if(t.findIndex(r=>{let{element:o}=r;return o===e})<0){const{keydownListener:r,keyupListenr:o,capture:s}=ko.get(e)||{};r&&o&&(al(e,"keyup",o,s),al(e,"keydown",r,s),ko.delete(e))}if((t.length<=0||ko.size<=0)&&(Object.keys(ko).forEach(o=>{const{keydownListener:s,keyupListenr:i,capture:a}=ko.get(o)||{};s&&i&&(al(o,"keyup",i,a),al(o,"keydown",s,a),ko.delete(o))}),ko.clear(),Object.keys(ct).forEach(o=>delete ct[o]),Rl)){const{listener:o,capture:s}=Rl;al(window,"focus",o,s),Rl=null}}const gy={getPressedKeyString:wre,setScope:Mj,getScope:Pu,deleteScope:Ire,getPressedKeyCodes:xre,getAllKeyCodes:bre,isPressed:Cre,filter:Pre,trigger:_re,unbind:Aj,keyMap:bu,modifier:po,modifierMap:Fv};for(const e in gy)Object.prototype.hasOwnProperty.call(gy,e)&&(kn[e]=gy[e]);if(typeof window<"u"){const e=window.hotkeys;kn.noConflict=t=>(t&&window.hotkeys===kn&&(window.hotkeys=e),kn),window.hotkeys=kn}const SI=["copy","cut","paste","asset"];function kre(){const e=z(),t=ns(),n=ce(),r=De(),o=K("is focused",()=>e.getInstanceState().isFocused,[e]);x.useEffect(()=>{if(!o)return;const s=e.getContainer();kn.setScope(e.store.id);const i=(c,l)=>{kn(c,{element:document.body,scope:e.store.id},l)},a=(c,l)=>{kn(c,{element:document.body,keyup:!0,keydown:!1,scope:e.store.id},l)};for(const c of Object.values(n))c.kbd&&(t&&!c.readonlyOk||SI.includes(c.id)||i(vI(c.kbd),l=>{Sl(e)||(Ee(l),c.onSelect("kbd"))}));for(const c of Object.values(r))!c.kbd||!c.readonlyOk&&e.getInstanceState().isReadonly||SI.includes(c.id)||i(vI(c.kbd),l=>{Sl(e)||(Ee(l),c.onSelect("kbd"))});return i(",",c=>{if(Sl(e)||e.inputs.keys.has("Comma"))return;Ee(c),s.focus(),e.inputs.keys.add("Comma");const{x:l,y:u,z:d}=e.inputs.currentScreenPoint,p={type:"pointer",name:"pointer_down",point:{x:l,y:u,z:d},shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.metaKey||c.ctrlKey,pointerId:0,button:0,isPen:e.getInstanceState().isPenMode,target:"canvas"};e.dispatch(p)}),a(",",c=>{if(Sl(e)||!e.inputs.keys.has("Comma"))return;e.inputs.keys.delete("Comma");const{x:l,y:u,z:d}=e.inputs.currentScreenPoint,p={type:"pointer",name:"pointer_up",point:{x:l,y:u,z:d},shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.metaKey||c.ctrlKey,pointerId:0,button:0,isPen:e.getInstanceState().isPenMode,target:"canvas"};e.dispatch(p)}),()=>{kn.deleteScope(e.store.id)}},[n,r,t,e,o])}function vI(e){return Tre(e).map(t=>{let n="";const r=t.split("");return r.length===1?n=r[0]:r[0]==="!"?n=`shift+${r[1]}`:r[0]==="?"?r.length===3&&r[1]==="!"?n=`alt+shift+${r[2]}`:n=`alt+${r[1]}`:r[0]==="$"?r[1]==="!"?n=`cmd+shift+${r[2]},ctrl+shift+${r[2]}`:r[1]==="?"?n=`cmd+⌥+${r[2]},ctrl+alt+${r[2]}`:n=`cmd+${r[1]},ctrl+${r[1]}`:n=t,n}).join(",")}function Tre(e){typeof e!="string"&&(e=""),e=e.replace(/\s/g,"");const t=e.split(",");let n=t.lastIndexOf("");for(;n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function Sl(e){return e.getIsMenuOpen()||e.getEditingShapeId()!==null||e.getCrashingError()}const $re=x.createContext(!1);function Mre({children:e}){const t=z(),n=w8(),r=Rn(),o=$e(),s=Math.min(8,5+r),[i,a]=x.useState(0),c=x.useRef(null),[l,u]=x.useState(null),d=x.useMemo(()=>{const f=[],y=[];l?f.push(`[data-value="${l}"]`):f.push(`:nth-child(${s+1})`);for(let g=0;g<s;g++)f.push(`:nth-child(${g+1})`),y.push(`:nth-child(${g+1})`);return`
|
|
#${n}_main > *:not(${f.join(", ")}) {
|
|
display: none;
|
|
}
|
|
${y.map(g=>`#${n}_more > *${g}`).join(", ")} {
|
|
display: none;
|
|
}
|
|
`},[l,n,s]),p=lx(()=>{if(!c.current)return;const f=Array.from(c.current.children);a(f.length),f.findIndex(w=>w.getAttribute("data-value")===l)<=s&&u(null);const g=Array.from(c.current.children).findIndex(w=>w.getAttribute("aria-checked")==="true");g!==-1&&g>=s&&u(f[g].getAttribute("data-value"))});return x.useLayoutEffect(()=>{p()}),x.useLayoutEffect(()=>{if(!c.current)return;const f=new MutationObserver(p);return f.observe(c.current,{childList:!0,subtree:!0,attributeFilter:["data-value","aria-checked"]}),()=>{f.disconnect()}},[p]),x.useEffect(()=>{const f=[["1",0],["2",1],["3",2],["4",3],["5",4],["6",5],["7",6],["8",7],["9",8],["0",9]];for(const[y,g]of f)kn(y,w=>{var b;if(Sl(t))return;Ee(w);const v=Array.from(((b=c.current)==null?void 0:b.children)??[]).filter(E=>!(E instanceof HTMLElement)||E.tagName.toLowerCase()!=="button"?!1:!!(E.offsetWidth||E.offsetHeight))[g];v&&v.click()});return()=>{kn.unbind("1,2,3,4,5,6,7,8,9,0")}},[t]),h.jsxs(h.Fragment,{children:[h.jsx("style",{children:d}),h.jsxs("div",{className:ue("tlui-toolbar__tools",{"tlui-toolbar__tools__mobile":r<mt.TABLET_SM}),role:"radiogroup",children:[h.jsx("div",{id:`${n}_main`,ref:c,className:"tlui-toolbar__tools__list",children:h.jsx(vr,{type:"toolbar",sourceId:"toolbar",children:e})}),i>s&&h.jsx($re.Provider,{value:!0,children:h.jsxs(Li,{id:"toolbar overflow",modal:!1,children:[h.jsx(Fi,{children:h.jsx(pe,{title:o("tool-panel.more"),type:"tool",className:"tlui-toolbar__overflow","data-testid":"tools.more-button",children:h.jsx(ke,{icon:"chevron-up"})})}),h.jsx(Ni,{side:"top",align:"center",children:h.jsx("div",{className:"tlui-buttons__grid","data-testid":"tools.more-content",id:`${n}_more`,children:h.jsx(vr,{type:"toolbar-overflow",sourceId:"toolbar",children:e})})})]})})]})]})}const Are=["select","hand","draw","eraser","text","zoom","laser","highlight"];function jre({activeToolId:e}){const t=z(),n=Rn(),r=$e(),o=K("is tool locked",()=>t.getInstanceState().isToolLocked,[t]);return!e||Are.includes(e)?null:h.jsx(pe,{type:"normal",title:r("action.toggle-tool-lock"),"data-testid":"tool-lock",className:ue("tlui-toolbar__lock-button",{"tlui-toolbar__lock-button__mobile":n<mt.TABLET_SM}),onClick:()=>t.updateInstanceState({isToolLocked:!o}),children:h.jsx(ke,{icon:o?"lock":"unlock",small:!0})})}const Ore=x.memo(function({children:t}){const n=z(),r=Rn(),o=ns(),s=K("current tool id",()=>n.getCurrentToolId(),[n]),{ActionsMenu:i,QuickActions:a}=ti();return h.jsx("div",{className:"tlui-toolbar",children:h.jsxs("div",{className:"tlui-toolbar__inner",children:[h.jsxs("div",{className:"tlui-toolbar__left",children:[!o&&h.jsxs("div",{className:"tlui-toolbar__extras",children:[r<mt.TABLET&&h.jsxs("div",{className:"tlui-toolbar__extras__controls tlui-buttons__horizontal",children:[a&&h.jsx(a,{}),i&&h.jsx(i,{})]}),h.jsx(jre,{activeToolId:s})]}),h.jsx(Mre,{children:t??h.jsx(Une,{})})]}),r<mt.TABLET_SM&&!o&&h.jsx("div",{className:"tlui-toolbar__tools",children:h.jsx(Bne,{})})]})})});function Dre(){const e=ce();return h.jsxs(h.Fragment,{children:[h.jsx(R,{...e["zoom-in"],noClose:!0}),h.jsx(R,{...e["zoom-out"],noClose:!0}),h.jsx(aj,{}),h.jsx(cj,{}),h.jsx(lj,{})]})}const Rre=x.memo(function({children:t}){const n=cn(),[r,o]=Qs("zoom menu"),s=t??h.jsx(Dre,{});return h.jsxs(mw,{dir:"ltr",open:r,onOpenChange:o,modal:!1,children:[h.jsx(yw,{asChild:!0,dir:"ltr",children:h.jsx(Lre,{})}),h.jsx(xg,{container:n,children:h.jsx(Sw,{className:"tlui-menu",side:"top",align:"start",alignOffset:0,sideOffset:8,collisionPadding:4,children:h.jsx(vr,{type:"menu",sourceId:"zoom-menu",children:s})})})]})}),Lre=x.forwardRef(function(t,n){const r=z(),o=Rn(),s=K("zoom",()=>r.getZoomLevel(),[r]),i=$e(),a=x.useCallback(()=>{r.resetZoom(r.getViewportScreenCenter(),{duration:Qr})},[r]);return h.jsx(pe,{ref:n,...t,type:"icon",title:`${i("navigation-zone.zoom")}`,"data-testid":"minimap.zoom-menu-button",className:o<mt.TABLET_SM?"tlui-zoom-menu__button":"tlui-zoom-menu__button__pct",onDoubleClick:a,icon:o<mt.MOBILE?"zoom-in":void 0,children:o<mt.MOBILE?null:h.jsxs("span",{style:{flexGrow:0,textAlign:"center"},children:[Math.floor(s*100),"%"]})})}),jj=x.createContext({});function Fre({overrides:e={},children:t}){const n=ex(e);return h.jsx(jj.Provider,{value:x.useMemo(()=>({ContextMenu:pte,ActionsMenu:Hee,HelpMenu:Ete,ZoomMenu:Rre,MainMenu:Hte,Minimap:Xte,StylePanel:zne,PageMenu:Jte,NavigationPanel:Zte,Toolbar:Ore,KeyboardShortcutsDialog:jte,QuickActions:tne,HelperButtons:Mte,DebugPanel:xte,DebugMenu:vte,MenuPanel:Kte,...n}),[n]),children:t})}function ti(){return x.useContext(jj)}function Nre({overrides:e,components:t,assetUrls:n,onUiEvent:r,forceMobile:o,children:s}){return h.jsx(JG,{assetUrls:zq(n),children:h.jsx(nY,{overrides:Wq(e),children:h.jsx(Eq,{onEvent:r,children:h.jsx(jq,{children:h.jsx(_q,{children:h.jsx(Uq,{forceMobile:o,children:h.jsx(Fre,{overrides:t,children:h.jsx(zre,{overrides:e,children:s})})})})})})})})}function zre({overrides:e,children:t}){const n=Vq(e);return h.jsx(_Z,{overrides:n.actions,children:h.jsx(Bq,{overrides:n.tools,children:t})})}function Bre(){const e=z(),{addToast:t}=Kr();x.useEffect(()=>{function n({name:r,count:o}){t({title:"Maximum Shapes Reached",description:`You've reached the maximum number of shapes allowed on ${r} (${o}). Please delete some shapes or move to a different page to continue.`,severity:"warning"})}return e.addListener("max-shapes",n),()=>{e.removeListener("max-shapes",n)}},[e,t])}const Ure=Se.memo(function({renderDebugMenuItems:t,children:n,hideUi:r,components:o,...s}){return h.jsx(Nre,{...s,components:o,children:h.jsx(Hre,{hideUi:r,renderDebugMenuItems:t,children:n})})}),Hre=Se.memo(function({children:t,hideUi:n,...r}){return h.jsxs(h.Fragment,{children:[t,n?null:h.jsx(Kre,{...r})]})}),Kre=Se.memo(function(){const t=z(),n=$e(),r=Rn(),o=ns(),s=K("focus",()=>t.getInstanceState().isFocusMode,[t]),i=K("debug",()=>t.getInstanceState().isDebugMode,[t]),{SharePanel:a,TopPanel:c,MenuPanel:l,StylePanel:u,Toolbar:d,HelpMenu:p,NavigationPanel:f,HelperButtons:y,DebugPanel:g}=ti();kre(),mZ(),Bre();const{"toggle-focus-mode":w}=ce();return h.jsx(gM,{children:h.jsxs("div",{className:ue("tlui-layout",{"tlui-layout__mobile":r<mt.TABLET_SM}),"data-breakpoint":r,children:[s?h.jsx("div",{className:"tlui-layout__top",children:h.jsx(pe,{type:"icon",className:"tlui-focus-button",title:n("focus-mode.toggle-focus-mode"),onClick:()=>w.onSelect("menu"),children:h.jsx(ke,{icon:"dot"})})}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"tlui-layout__top",children:[h.jsxs("div",{className:"tlui-layout__top__left",children:[l&&h.jsx(l,{}),y&&h.jsx(y,{})]}),h.jsx("div",{className:"tlui-layout__top__center",children:c&&h.jsx(c,{})}),h.jsxs("div",{className:"tlui-layout__top__right",children:[a&&h.jsx(a,{}),u&&r>=mt.TABLET_SM&&!o&&h.jsx(u,{})]})]}),h.jsxs("div",{className:"tlui-layout__bottom",children:[h.jsxs("div",{className:"tlui-layout__bottom__main",children:[f&&h.jsx(f,{}),d&&h.jsx(d,{}),p&&h.jsx(p,{})]}),i&&g&&h.jsx(g,{})]})]}),h.jsx(Lq,{}),h.jsx($q,{}),h.jsx(Fq,{}),h.jsx(Mq,{})]})})}),th=(e,t)=>{const[n,r]=x.useState(2);return x.useEffect(()=>{let o=!1;return r(2),f3(e,t).then(()=>{o||r(0)}).catch(s=>{o||(console.error(s),r(1))}),()=>{o=!0}},[e,t]),n};function Wre(e){return{draw:{url:e.fonts.draw,format:e.fonts.draw.split(".").pop()},serif:{url:e.fonts.serif,format:e.fonts.serif.split(".").pop()},sansSerif:{url:e.fonts.sansSerif,format:e.fonts.sansSerif.split(".").pop()},monospace:{url:e.fonts.monospace,format:e.fonts.monospace.split(".").pop()}}}function Oj(e){const t=x.useMemo(()=>Wre(e),[e]),n=[th("tldraw_draw",t.draw),th("tldraw_serif",t.serif),th("tldraw_sans",t.sansSerif),th("tldraw_mono",t.monospace)];return{error:n.some(r=>r===1),done:!n.some(r=>r===2)}}function Vre(e){const{children:t,maxImageDimension:n,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i,components:a={},shapeUtils:c=[],tools:l=[],...u}=e,d=ex(a),p=x.useMemo(()=>({Scribble:JP,CollaboratorScribble:JP,SelectionForeground:AW,SelectionBackground:$W,Handles:IW,...d}),[d]),f=KS(c),y=x.useMemo(()=>[...Kx,...f],[f]),g=KS(l),w=x.useMemo(()=>[..._Y,...TV,...g],[g]),S=zM(u.assetUrls),{done:v,error:b}=Oj(S);return b?h.jsx(X2,{children:"Could not load assets. Please refresh the page."}):v?h.jsx(f8,{initialState:"select",...u,components:p,shapeUtils:y,tools:w,children:h.jsxs(Ure,{...u,components:p,children:[h.jsx(Xre,{maxImageDimension:n,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i}),t]})}):h.jsx(Y2,{children:"Loading assets..."})}const Gre=Object.freeze(["image/jpeg","image/png","image/gif","image/svg+xml"]),Yre=Object.freeze(["video/mp4","video/quicktime"]);function Xre({maxImageDimension:e=1e3,maxAssetSize:t=10*1024*1024,acceptedImageMimeTypes:n=Gre,acceptedVideoMimeTypes:r=Yre,onMount:o}){const s=z(),i=Kr(),a=$e(),c=lx(d=>{const p=[];return p.push(...dY(d)),hV(d,{maxImageDimension:e,maxAssetSize:t,acceptedImageMimeTypes:n,acceptedVideoMimeTypes:r},{toasts:i,msg:a}),p.push(o==null?void 0:o(d)),()=>{p.forEach(f=>f==null?void 0:f())}});x.useLayoutEffect(()=>{if(s)return c==null?void 0:c(s)},[s,c]);const{Canvas:l}=dt(),{ContextMenu:u}=ti();return u?h.jsx(u,{}):l?h.jsx(l,{}):null}x.memo(function(t){const[n,r]=x.useState(null),[o,s]=x.useState(null),i=KS(t.shapeUtils??[]),a=x.useMemo(()=>[...Kx,...i],[i]),c=K2({snapshot:t.snapshot,shapeUtils:a}),l=zM(),{done:u,error:d}=Oj(l),{pageId:p,bounds:f,scale:y,background:g,padding:w,darkMode:S,preserveAspectRatio:v,format:b="svg"}=t;return x.useLayoutEffect(()=>{if(!o||!c||!u)return;let E=!1;const C=document.createElement("div");o.appendChild(C),o.classList.add("tl-container","tl-theme__light");const I=new J({store:c,shapeUtils:a??[],tools:[],getContainer:()=>C});p&&I.setCurrentPage(p);const _=I.getCurrentPageShapeIds();async function k(){const $=await I.getSvgString([..._],{bounds:f,scale:y,background:g,padding:w,darkMode:S,preserveAspectRatio:v});if($&&!E){if(b==="svg"){if(!E){const T=new Blob([$.svg],{type:"image/svg+xml"}),O=URL.createObjectURL(T);r(O)}}else if(b==="png"){const T=await qM($.svg,I.environment.isSafari,{type:b,quality:1,scale:2,width:$.width,height:$.height});if(T&&!E){const O=URL.createObjectURL(T);r(O)}}}I.dispose()}return k(),()=>{E=!0}},[b,o,c,a,p,f,y,g,w,S,v,u,d]),d?h.jsx(X2,{children:"Could not load assets."}):u?h.jsx("div",{ref:s,style:{position:"relative",width:"100%",height:"100%"},children:n&&h.jsx("img",{src:n,style:{width:"100%",height:"100%"}})}):h.jsx(Y2,{children:"Loading assets..."})});const qre=ve({schemaVersion:on(1),storeVersion:mh,recordVersions:Lp(ge,ve({version:mh,subTypeVersions:Lp(ge,mh).optional(),subTypeKey:ge.optional()}))}),Zre=ve({schemaVersion:on(2),sequences:Lp(ge,mh)});ve({tldrawFileFormatVersion:uL,schema:dL("schemaVersion",{1:qre,2:Zre}),records:Nt(ve({id:ge,typeName:ge}).allowUnknownProperties())});function A(e,t={}){const n=typeof e=="string"?e:e.src;if(typeof t=="function")return t(n);const{baseUrl:r=""}=t;return n.startsWith("data:")||n.match(/^https?:\/\//)?n:`${r.replace(/\/$/,"")}/${n.replace(/^\.?\//,"")}`}function Qre(e){return{fonts:{monospace:A("./fonts/IBMPlexMono-Medium.woff2",e),sansSerif:A("./fonts/IBMPlexSans-Medium.woff2",e),serif:A("./fonts/IBMPlexSerif-Medium.woff2",e),draw:A("./fonts/Shantell_Sans-Tldrawish.woff2",e)},icons:{"align-bottom-center":A("./icons/icon/align-bottom-center.svg",e),"align-bottom-left":A("./icons/icon/align-bottom-left.svg",e),"align-bottom-right":A("./icons/icon/align-bottom-right.svg",e),"align-bottom":A("./icons/icon/align-bottom.svg",e),"align-center-center":A("./icons/icon/align-center-center.svg",e),"align-center-horizontal":A("./icons/icon/align-center-horizontal.svg",e),"align-center-left":A("./icons/icon/align-center-left.svg",e),"align-center-right":A("./icons/icon/align-center-right.svg",e),"align-center-vertical":A("./icons/icon/align-center-vertical.svg",e),"align-left":A("./icons/icon/align-left.svg",e),"align-right":A("./icons/icon/align-right.svg",e),"align-top-center":A("./icons/icon/align-top-center.svg",e),"align-top-left":A("./icons/icon/align-top-left.svg",e),"align-top-right":A("./icons/icon/align-top-right.svg",e),"align-top":A("./icons/icon/align-top.svg",e),"arrow-left":A("./icons/icon/arrow-left.svg",e),"arrowhead-arrow":A("./icons/icon/arrowhead-arrow.svg",e),"arrowhead-bar":A("./icons/icon/arrowhead-bar.svg",e),"arrowhead-diamond":A("./icons/icon/arrowhead-diamond.svg",e),"arrowhead-dot":A("./icons/icon/arrowhead-dot.svg",e),"arrowhead-none":A("./icons/icon/arrowhead-none.svg",e),"arrowhead-square":A("./icons/icon/arrowhead-square.svg",e),"arrowhead-triangle-inverted":A("./icons/icon/arrowhead-triangle-inverted.svg",e),"arrowhead-triangle":A("./icons/icon/arrowhead-triangle.svg",e),"aspect-ratio":A("./icons/icon/aspect-ratio.svg",e),avatar:A("./icons/icon/avatar.svg",e),blob:A("./icons/icon/blob.svg",e),"bring-forward":A("./icons/icon/bring-forward.svg",e),"bring-to-front":A("./icons/icon/bring-to-front.svg",e),"check-circle":A("./icons/icon/check-circle.svg",e),check:A("./icons/icon/check.svg",e),"checkbox-checked":A("./icons/icon/checkbox-checked.svg",e),"checkbox-empty":A("./icons/icon/checkbox-empty.svg",e),"chevron-down":A("./icons/icon/chevron-down.svg",e),"chevron-left":A("./icons/icon/chevron-left.svg",e),"chevron-right":A("./icons/icon/chevron-right.svg",e),"chevron-up":A("./icons/icon/chevron-up.svg",e),"chevrons-ne":A("./icons/icon/chevrons-ne.svg",e),"chevrons-sw":A("./icons/icon/chevrons-sw.svg",e),"clipboard-copied":A("./icons/icon/clipboard-copied.svg",e),"clipboard-copy":A("./icons/icon/clipboard-copy.svg",e),code:A("./icons/icon/code.svg",e),collab:A("./icons/icon/collab.svg",e),color:A("./icons/icon/color.svg",e),comment:A("./icons/icon/comment.svg",e),"cross-2":A("./icons/icon/cross-2.svg",e),"cross-circle":A("./icons/icon/cross-circle.svg",e),cross:A("./icons/icon/cross.svg",e),"dash-dashed":A("./icons/icon/dash-dashed.svg",e),"dash-dotted":A("./icons/icon/dash-dotted.svg",e),"dash-draw":A("./icons/icon/dash-draw.svg",e),"dash-solid":A("./icons/icon/dash-solid.svg",e),discord:A("./icons/icon/discord.svg",e),"distribute-horizontal":A("./icons/icon/distribute-horizontal.svg",e),"distribute-vertical":A("./icons/icon/distribute-vertical.svg",e),dot:A("./icons/icon/dot.svg",e),"dots-horizontal":A("./icons/icon/dots-horizontal.svg",e),"dots-vertical":A("./icons/icon/dots-vertical.svg",e),"drag-handle-dots":A("./icons/icon/drag-handle-dots.svg",e),duplicate:A("./icons/icon/duplicate.svg",e),edit:A("./icons/icon/edit.svg",e),error:A("./icons/icon/error.svg",e),"external-link":A("./icons/icon/external-link.svg",e),file:A("./icons/icon/file.svg",e),"fill-none":A("./icons/icon/fill-none.svg",e),"fill-pattern":A("./icons/icon/fill-pattern.svg",e),"fill-semi":A("./icons/icon/fill-semi.svg",e),"fill-solid":A("./icons/icon/fill-solid.svg",e),follow:A("./icons/icon/follow.svg",e),following:A("./icons/icon/following.svg",e),"font-draw":A("./icons/icon/font-draw.svg",e),"font-mono":A("./icons/icon/font-mono.svg",e),"font-sans":A("./icons/icon/font-sans.svg",e),"font-serif":A("./icons/icon/font-serif.svg",e),"geo-arrow-down":A("./icons/icon/geo-arrow-down.svg",e),"geo-arrow-left":A("./icons/icon/geo-arrow-left.svg",e),"geo-arrow-right":A("./icons/icon/geo-arrow-right.svg",e),"geo-arrow-up":A("./icons/icon/geo-arrow-up.svg",e),"geo-check-box":A("./icons/icon/geo-check-box.svg",e),"geo-cloud":A("./icons/icon/geo-cloud.svg",e),"geo-diamond":A("./icons/icon/geo-diamond.svg",e),"geo-ellipse":A("./icons/icon/geo-ellipse.svg",e),"geo-hexagon":A("./icons/icon/geo-hexagon.svg",e),"geo-octagon":A("./icons/icon/geo-octagon.svg",e),"geo-oval":A("./icons/icon/geo-oval.svg",e),"geo-pentagon":A("./icons/icon/geo-pentagon.svg",e),"geo-rectangle":A("./icons/icon/geo-rectangle.svg",e),"geo-rhombus-2":A("./icons/icon/geo-rhombus-2.svg",e),"geo-rhombus":A("./icons/icon/geo-rhombus.svg",e),"geo-star":A("./icons/icon/geo-star.svg",e),"geo-trapezoid":A("./icons/icon/geo-trapezoid.svg",e),"geo-triangle":A("./icons/icon/geo-triangle.svg",e),"geo-x-box":A("./icons/icon/geo-x-box.svg",e),github:A("./icons/icon/github.svg",e),group:A("./icons/icon/group.svg",e),hidden:A("./icons/icon/hidden.svg",e),image:A("./icons/icon/image.svg",e),"info-circle":A("./icons/icon/info-circle.svg",e),leading:A("./icons/icon/leading.svg",e),link:A("./icons/icon/link.svg",e),"lock-small":A("./icons/icon/lock-small.svg",e),lock:A("./icons/icon/lock.svg",e),menu:A("./icons/icon/menu.svg",e),minus:A("./icons/icon/minus.svg",e),mixed:A("./icons/icon/mixed.svg",e),pack:A("./icons/icon/pack.svg",e),page:A("./icons/icon/page.svg",e),plus:A("./icons/icon/plus.svg",e),"question-mark-circle":A("./icons/icon/question-mark-circle.svg",e),"question-mark":A("./icons/icon/question-mark.svg",e),redo:A("./icons/icon/redo.svg",e),"reset-zoom":A("./icons/icon/reset-zoom.svg",e),"rotate-ccw":A("./icons/icon/rotate-ccw.svg",e),"rotate-cw":A("./icons/icon/rotate-cw.svg",e),ruler:A("./icons/icon/ruler.svg",e),search:A("./icons/icon/search.svg",e),"send-backward":A("./icons/icon/send-backward.svg",e),"send-to-back":A("./icons/icon/send-to-back.svg",e),"settings-horizontal":A("./icons/icon/settings-horizontal.svg",e),"settings-vertical-1":A("./icons/icon/settings-vertical-1.svg",e),"settings-vertical":A("./icons/icon/settings-vertical.svg",e),"share-1":A("./icons/icon/share-1.svg",e),"share-2":A("./icons/icon/share-2.svg",e),"size-extra-large":A("./icons/icon/size-extra-large.svg",e),"size-large":A("./icons/icon/size-large.svg",e),"size-medium":A("./icons/icon/size-medium.svg",e),"size-small":A("./icons/icon/size-small.svg",e),"spline-cubic":A("./icons/icon/spline-cubic.svg",e),"spline-line":A("./icons/icon/spline-line.svg",e),"stack-horizontal":A("./icons/icon/stack-horizontal.svg",e),"stack-vertical":A("./icons/icon/stack-vertical.svg",e),"status-offline":A("./icons/icon/status-offline.svg",e),"status-online":A("./icons/icon/status-online.svg",e),"stretch-horizontal":A("./icons/icon/stretch-horizontal.svg",e),"stretch-vertical":A("./icons/icon/stretch-vertical.svg",e),"text-align-center":A("./icons/icon/text-align-center.svg",e),"text-align-justify":A("./icons/icon/text-align-justify.svg",e),"text-align-left":A("./icons/icon/text-align-left.svg",e),"text-align-right":A("./icons/icon/text-align-right.svg",e),"tool-arrow":A("./icons/icon/tool-arrow.svg",e),"tool-embed":A("./icons/icon/tool-embed.svg",e),"tool-eraser":A("./icons/icon/tool-eraser.svg",e),"tool-frame":A("./icons/icon/tool-frame.svg",e),"tool-hand":A("./icons/icon/tool-hand.svg",e),"tool-highlight":A("./icons/icon/tool-highlight.svg",e),"tool-laser":A("./icons/icon/tool-laser.svg",e),"tool-line":A("./icons/icon/tool-line.svg",e),"tool-media":A("./icons/icon/tool-media.svg",e),"tool-note":A("./icons/icon/tool-note.svg",e),"tool-pencil":A("./icons/icon/tool-pencil.svg",e),"tool-pointer":A("./icons/icon/tool-pointer.svg",e),"tool-text":A("./icons/icon/tool-text.svg",e),trash:A("./icons/icon/trash.svg",e),"triangle-down":A("./icons/icon/triangle-down.svg",e),"triangle-up":A("./icons/icon/triangle-up.svg",e),twitter:A("./icons/icon/twitter.svg",e),undo:A("./icons/icon/undo.svg",e),ungroup:A("./icons/icon/ungroup.svg",e),"unlock-small":A("./icons/icon/unlock-small.svg",e),unlock:A("./icons/icon/unlock.svg",e),"vertical-align-center":A("./icons/icon/vertical-align-center.svg",e),"vertical-align-end":A("./icons/icon/vertical-align-end.svg",e),"vertical-align-start":A("./icons/icon/vertical-align-start.svg",e),visible:A("./icons/icon/visible.svg",e),"warning-triangle":A("./icons/icon/warning-triangle.svg",e),"zoom-in":A("./icons/icon/zoom-in.svg",e),"zoom-out":A("./icons/icon/zoom-out.svg",e)},translations:{ar:A("./translations/ar.json",e),ca:A("./translations/ca.json",e),cs:A("./translations/cs.json",e),da:A("./translations/da.json",e),de:A("./translations/de.json",e),en:A("./translations/en.json",e),es:A("./translations/es.json",e),fa:A("./translations/fa.json",e),fi:A("./translations/fi.json",e),fr:A("./translations/fr.json",e),gl:A("./translations/gl.json",e),he:A("./translations/he.json",e),"hi-in":A("./translations/hi-in.json",e),hr:A("./translations/hr.json",e),hu:A("./translations/hu.json",e),it:A("./translations/it.json",e),ja:A("./translations/ja.json",e),"ko-kr":A("./translations/ko-kr.json",e),ku:A("./translations/ku.json",e),languages:A("./translations/languages.json",e),main:A("./translations/main.json",e),my:A("./translations/my.json",e),ne:A("./translations/ne.json",e),no:A("./translations/no.json",e),pl:A("./translations/pl.json",e),"pt-br":A("./translations/pt-br.json",e),"pt-pt":A("./translations/pt-pt.json",e),ro:A("./translations/ro.json",e),ru:A("./translations/ru.json",e),sl:A("./translations/sl.json",e),sv:A("./translations/sv.json",e),te:A("./translations/te.json",e),th:A("./translations/th.json",e),tr:A("./translations/tr.json",e),uk:A("./translations/uk.json",e),vi:A("./translations/vi.json",e),"zh-cn":A("./translations/zh-cn.json",e),"zh-tw":A("./translations/zh-tw.json",e)},embedIcons:{codepen:A("./embed-icons/codepen.png",e),codesandbox:A("./embed-icons/codesandbox.png",e),excalidraw:A("./embed-icons/excalidraw.png",e),felt:A("./embed-icons/felt.png",e),figma:A("./embed-icons/figma.png",e),github_gist:A("./embed-icons/github_gist.png",e),google_calendar:A("./embed-icons/google_calendar.png",e),google_maps:A("./embed-icons/google_maps.png",e),google_slides:A("./embed-icons/google_slides.png",e),observable:A("./embed-icons/observable.png",e),replit:A("./embed-icons/replit.png",e),scratch:A("./embed-icons/scratch.png",e),spotify:A("./embed-icons/spotify.png",e),tldraw:A("./embed-icons/tldraw.png",e),val_town:A("./embed-icons/val_town.png",e),vimeo:A("./embed-icons/vimeo.png",e),youtube:A("./embed-icons/youtube.png",e)}}}const Jre=({onSave:e})=>{const t=()=>{e&&e()};return h.jsx("button",{type:"button",className:"bg-transparent border border-gray-300 mr-3 rounded-lg p-1 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-600",onClick:t,children:h.jsx("img",{src:"./save.svg",alt:"Save",className:"w-6 h-6 inline-block align-middle"})})};let my=!1,yy=!1;const cl="PERSISTENCE_KEY";function eoe(){const e=Qre({baseUrl:"./static/"});localStorage.removeItem(cl);const[t]=x.useState(()=>H2({shapeUtils:Kx})),[n,r]=x.useState({status:"loading"}),[o,s]=x.useState(!1),[i,a]=x.useState("未命名白板"),c=p=>{a(p.target.value)},l=()=>{s(!0)},u=()=>{i.trim()===""?alert("请输入标题!"):s(!1)};x.useLayoutEffect(()=>{r({status:"loading"});const p=localStorage.getItem(cl);if(p)try{const g=JSON.parse(p);t.loadSnapshot(g),r({status:"ready"})}catch(g){r({status:"error",error:g.message})}else r({status:"ready"});const f=g=>{try{const w=g.data;if(w.type==="start"&&w.title){const S=w.title.substring(0,w.title.lastIndexOf("."));S&&a(S)}if(w.type==="init"){const S=w.data;if(!S||!S.title)return;my=S.isShare===!0,yy=S.isRefresh===!0;const v=S.title.substring(0,S.title.lastIndexOf("."));a(v),S.content&&(S.content=JSON.parse(S.content),t.loadSnapshot(S.content),localStorage.setItem(cl,JSON.stringify(S.content)))}}catch(w){console.log(w)}};window.parent.postMessage({type:"initSuccess"},"*"),window.addEventListener("message",f);const y=t.listen(B_(()=>{const g=t.getSnapshot();if(localStorage.setItem(cl,JSON.stringify(g)),my){if(yy){yy=!1;return}d()}},200));return()=>{y(),window.removeEventListener("unload",f)}},[t]);const d=()=>{const p=localStorage.getItem(cl)||"{}",y={data:JSON.stringify({title:i,content:p,isShare:my}),type:"exportBaiban"};window.parent.postMessage(y,"*")};return n.status==="loading"?h.jsx("div",{className:"tldraw__editor",children:h.jsx("h2",{children:"Loading..."})}):n.status==="error"?h.jsxs("div",{className:"tldraw__editor",children:[h.jsx("h2",{children:"Error!"}),h.jsx("p",{children:n.error})]}):h.jsxs("div",{className:"tldraw__editor",children:[h.jsxs("div",{style:{position:"absolute",zIndex:2e3,top:3,left:"calc(50% - 90px)",display:"flex",alignItems:"center"},children:[h.jsx(Jre,{onSave:()=>d()}),h.jsx("div",{className:"flex items-center bottom-12 right-4 space-x-2",children:o?h.jsx("input",{type:"text",value:i,onChange:c,onBlur:u,className:`\r
|
|
bg-gray-100 \r
|
|
border \r
|
|
border-gray-200 \r
|
|
rounded-lg \r
|
|
py-1.5 \r
|
|
px-3 \r
|
|
w-64 \r
|
|
focus:outline-none \r
|
|
focus:border-slate-500\r
|
|
`,style:{height:"38px"}}):h.jsx("span",{onClick:l,className:"cursor-pointer select-none text-gray-400 hover:text-gray-600 transition duration-200 ease-in-out mt-2",children:i})})]}),h.jsx(Vre,{assetUrls:e,persistenceKey:"my-persistence-key",store:t})]})}try{Fy.createRoot(document.getElementById("root")).render(h.jsx(Se.StrictMode,{children:h.jsx(eoe,{})}))}catch(e){console.log(e)}
|