@kitschpatrol/tldraw-cli 4.6.10 → 4.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
var w3=Object.defineProperty;var b3=(e,t,n)=>t in e?w3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var g=(e,t,n)=>b3(e,typeof t!="symbol"?t+"":t,n);function P3(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 cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ni(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var bE={exports:{}},jf={},PE={exports:{}},Ie={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Ru=Symbol.for("react.element"),C3=Symbol.for("react.portal"),I3=Symbol.for("react.fragment"),E3=Symbol.for("react.strict_mode"),k3=Symbol.for("react.profiler"),_3=Symbol.for("react.provider"),T3=Symbol.for("react.context"),M3=Symbol.for("react.forward_ref"),A3=Symbol.for("react.suspense"),j3=Symbol.for("react.memo"),O3=Symbol.for("react.lazy"),z1=Symbol.iterator;function D3(e){return e===null||typeof e!="object"?null:(e=z1&&e[z1]||e["@@iterator"],typeof e=="function"?e:null)}var CE={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},IE=Object.assign,EE={};function bl(e,t,n){this.props=e,this.context=t,this.refs=EE,this.updater=n||CE}bl.prototype.isReactComponent={};bl.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")};bl.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function kE(){}kE.prototype=bl.prototype;function ux(e,t,n){this.props=e,this.context=t,this.refs=EE,this.updater=n||CE}var dx=ux.prototype=new kE;dx.constructor=ux;IE(dx,bl.prototype);dx.isPureReactComponent=!0;var B1=Array.isArray,_E=Object.prototype.hasOwnProperty,hx={current:null},TE={key:!0,ref:!0,__self:!0,__source:!0};function ME(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)_E.call(t,r)&&!TE.hasOwnProperty(r)&&(o[r]=t[r]);var a=arguments.length-2;if(a===1)o.children=n;else if(1<a){for(var l=Array(a),c=0;c<a;c++)l[c]=arguments[c+2];o.children=l}if(e&&e.defaultProps)for(r in a=e.defaultProps,a)o[r]===void 0&&(o[r]=a[r]);return{$$typeof:Ru,type:e,key:s,ref:i,props:o,_owner:hx.current}}function R3(e,t){return{$$typeof:Ru,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function px(e){return typeof e=="object"&&e!==null&&e.$$typeof===Ru}function L3(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var U1=/\/+/g;function Zg(e,t){return typeof e=="object"&&e!==null&&e.key!=null?L3(""+e.key):t.toString(36)}function Ph(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 Ru:case C3:i=!0}}if(i)return i=e,o=o(i),e=r===""?"."+Zg(i,0):r,B1(o)?(n="",e!=null&&(n=e.replace(U1,"$&/")+"/"),Ph(o,t,n,"",function(c){return c})):o!=null&&(px(o)&&(o=R3(o,n+(!o.key||i&&i.key===o.key?"":(""+o.key).replace(U1,"$&/")+"/")+e)),t.push(o)),1;if(i=0,r=r===""?".":r+":",B1(e))for(var a=0;a<e.length;a++){s=e[a];var l=r+Zg(s,a);i+=Ph(s,t,n,l,o)}else if(l=D3(e),typeof l=="function")for(e=l.call(e),a=0;!(s=e.next()).done;)s=s.value,l=r+Zg(s,a++),i+=Ph(s,t,n,l,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 vd(e,t,n){if(e==null)return e;var r=[],o=0;return Ph(e,r,"","",function(s){return t.call(n,s,o++)}),r}function $3(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 xn={current:null},Ch={transition:null},N3={ReactCurrentDispatcher:xn,ReactCurrentBatchConfig:Ch,ReactCurrentOwner:hx};function AE(){throw Error("act(...) is not supported in production builds of React.")}Ie.Children={map:vd,forEach:function(e,t,n){vd(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return vd(e,function(){t++}),t},toArray:function(e){return vd(e,function(t){return t})||[]},only:function(e){if(!px(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Ie.Component=bl;Ie.Fragment=I3;Ie.Profiler=k3;Ie.PureComponent=ux;Ie.StrictMode=E3;Ie.Suspense=A3;Ie.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=N3;Ie.act=AE;Ie.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=IE({},e.props),o=e.key,s=e.ref,i=e._owner;if(t!=null){if(t.ref!==void 0&&(s=t.ref,i=hx.current),t.key!==void 0&&(o=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(l in t)_E.call(t,l)&&!TE.hasOwnProperty(l)&&(r[l]=t[l]===void 0&&a!==void 0?a[l]:t[l])}var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];r.children=a}return{$$typeof:Ru,type:e.type,key:o,ref:s,props:r,_owner:i}};Ie.createContext=function(e){return e={$$typeof:T3,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:_3,_context:e},e.Consumer=e};Ie.createElement=ME;Ie.createFactory=function(e){var t=ME.bind(null,e);return t.type=e,t};Ie.createRef=function(){return{current:null}};Ie.forwardRef=function(e){return{$$typeof:M3,render:e}};Ie.isValidElement=px;Ie.lazy=function(e){return{$$typeof:O3,_payload:{_status:-1,_result:e},_init:$3}};Ie.memo=function(e,t){return{$$typeof:j3,type:e,compare:t===void 0?null:t}};Ie.startTransition=function(e){var t=Ch.transition;Ch.transition={};try{e()}finally{Ch.transition=t}};Ie.unstable_act=AE;Ie.useCallback=function(e,t){return xn.current.useCallback(e,t)};Ie.useContext=function(e){return xn.current.useContext(e)};Ie.useDebugValue=function(){};Ie.useDeferredValue=function(e){return xn.current.useDeferredValue(e)};Ie.useEffect=function(e,t){return xn.current.useEffect(e,t)};Ie.useId=function(){return xn.current.useId()};Ie.useImperativeHandle=function(e,t,n){return xn.current.useImperativeHandle(e,t,n)};Ie.useInsertionEffect=function(e,t){return xn.current.useInsertionEffect(e,t)};Ie.useLayoutEffect=function(e,t){return xn.current.useLayoutEffect(e,t)};Ie.useMemo=function(e,t){return xn.current.useMemo(e,t)};Ie.useReducer=function(e,t,n){return xn.current.useReducer(e,t,n)};Ie.useRef=function(e){return xn.current.useRef(e)};Ie.useState=function(e){return xn.current.useState(e)};Ie.useSyncExternalStore=function(e,t,n){return xn.current.useSyncExternalStore(e,t,n)};Ie.useTransition=function(){return xn.current.useTransition()};Ie.version="18.3.1";PE.exports=Ie;var P=PE.exports;const Ce=ni(P),F3=P3({__proto__:null,default:Ce},[P]);/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.production.min.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var z3=P,B3=Symbol.for("react.element"),U3=Symbol.for("react.fragment"),H3=Object.prototype.hasOwnProperty,K3=z3.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,W3={key:!0,ref:!0,__self:!0,__source:!0};function jE(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)H3.call(t,r)&&!W3.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:B3,type:e,key:s,ref:i,props:o,_owner:K3.current}}jf.Fragment=U3;jf.jsx=jE;jf.jsxs=jE;bE.exports=jf;var d=bE.exports;function ie(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 G3(e){const t=ie("./icons/icon/0_merged.svg",e);return{fonts:{monospace:ie("./fonts/IBMPlexMono-Medium.woff2",e),sansSerif:ie("./fonts/IBMPlexSans-Medium.woff2",e),serif:ie("./fonts/IBMPlexSerif-Medium.woff2",e),draw:ie("./fonts/Shantell_Sans-Tldrawish.woff2",e)},icons:{"align-bottom":t+"#align-bottom","align-center-horizontal":t+"#align-center-horizontal","align-center-vertical":t+"#align-center-vertical","align-left":t+"#align-left","align-right":t+"#align-right","align-top":t+"#align-top","arrow-left":t+"#arrow-left","arrowhead-arrow":t+"#arrowhead-arrow","arrowhead-bar":t+"#arrowhead-bar","arrowhead-diamond":t+"#arrowhead-diamond","arrowhead-dot":t+"#arrowhead-dot","arrowhead-none":t+"#arrowhead-none","arrowhead-square":t+"#arrowhead-square","arrowhead-triangle-inverted":t+"#arrowhead-triangle-inverted","arrowhead-triangle":t+"#arrowhead-triangle",blob:t+"#blob","bring-forward":t+"#bring-forward","bring-to-front":t+"#bring-to-front",broken:t+"#broken","check-circle":t+"#check-circle",check:t+"#check","chevron-down":t+"#chevron-down","chevron-left":t+"#chevron-left","chevron-right":t+"#chevron-right","chevron-up":t+"#chevron-up","chevrons-ne":t+"#chevrons-ne","chevrons-sw":t+"#chevrons-sw","clipboard-copied":t+"#clipboard-copied","clipboard-copy":t+"#clipboard-copy",color:t+"#color","cross-2":t+"#cross-2","cross-circle":t+"#cross-circle","dash-dashed":t+"#dash-dashed","dash-dotted":t+"#dash-dotted","dash-draw":t+"#dash-draw","dash-solid":t+"#dash-solid",disconnected:t+"#disconnected",discord:t+"#discord","distribute-horizontal":t+"#distribute-horizontal","distribute-vertical":t+"#distribute-vertical",dot:t+"#dot","dots-horizontal":t+"#dots-horizontal","dots-vertical":t+"#dots-vertical","drag-handle-dots":t+"#drag-handle-dots",duplicate:t+"#duplicate",edit:t+"#edit","external-link":t+"#external-link","fill-fill":t+"#fill-fill","fill-none":t+"#fill-none","fill-pattern":t+"#fill-pattern","fill-semi":t+"#fill-semi","fill-solid":t+"#fill-solid",follow:t+"#follow",following:t+"#following","font-draw":t+"#font-draw","font-mono":t+"#font-mono","font-sans":t+"#font-sans","font-serif":t+"#font-serif","geo-arrow-down":t+"#geo-arrow-down","geo-arrow-left":t+"#geo-arrow-left","geo-arrow-right":t+"#geo-arrow-right","geo-arrow-up":t+"#geo-arrow-up","geo-check-box":t+"#geo-check-box","geo-cloud":t+"#geo-cloud","geo-diamond":t+"#geo-diamond","geo-ellipse":t+"#geo-ellipse","geo-heart":t+"#geo-heart","geo-hexagon":t+"#geo-hexagon","geo-octagon":t+"#geo-octagon","geo-oval":t+"#geo-oval","geo-pentagon":t+"#geo-pentagon","geo-rectangle":t+"#geo-rectangle","geo-rhombus-2":t+"#geo-rhombus-2","geo-rhombus":t+"#geo-rhombus","geo-star":t+"#geo-star","geo-trapezoid":t+"#geo-trapezoid","geo-triangle":t+"#geo-triangle","geo-x-box":t+"#geo-x-box",github:t+"#github",group:t+"#group","horizontal-align-end":t+"#horizontal-align-end","horizontal-align-middle":t+"#horizontal-align-middle","horizontal-align-start":t+"#horizontal-align-start","info-circle":t+"#info-circle",leading:t+"#leading",link:t+"#link",lock:t+"#lock",menu:t+"#menu",minus:t+"#minus",mixed:t+"#mixed",pack:t+"#pack",plus:t+"#plus","question-mark-circle":t+"#question-mark-circle","question-mark":t+"#question-mark",redo:t+"#redo","reset-zoom":t+"#reset-zoom","rotate-ccw":t+"#rotate-ccw","rotate-cw":t+"#rotate-cw","send-backward":t+"#send-backward","send-to-back":t+"#send-to-back","share-1":t+"#share-1","size-extra-large":t+"#size-extra-large","size-large":t+"#size-large","size-medium":t+"#size-medium","size-small":t+"#size-small","spline-cubic":t+"#spline-cubic","spline-line":t+"#spline-line","stack-horizontal":t+"#stack-horizontal","stack-vertical":t+"#stack-vertical","status-offline":t+"#status-offline","stretch-horizontal":t+"#stretch-horizontal","stretch-vertical":t+"#stretch-vertical","text-align-center":t+"#text-align-center","text-align-left":t+"#text-align-left","text-align-right":t+"#text-align-right","toggle-off":t+"#toggle-off","toggle-on":t+"#toggle-on","tool-arrow":t+"#tool-arrow","tool-eraser":t+"#tool-eraser","tool-frame":t+"#tool-frame","tool-hand":t+"#tool-hand","tool-highlight":t+"#tool-highlight","tool-laser":t+"#tool-laser","tool-line":t+"#tool-line","tool-media":t+"#tool-media","tool-note":t+"#tool-note","tool-pencil":t+"#tool-pencil","tool-pointer":t+"#tool-pointer","tool-screenshot":t+"#tool-screenshot","tool-text":t+"#tool-text",trash:t+"#trash",twitter:t+"#twitter",undo:t+"#undo",ungroup:t+"#ungroup",unlock:t+"#unlock","vertical-align-end":t+"#vertical-align-end","vertical-align-middle":t+"#vertical-align-middle","vertical-align-start":t+"#vertical-align-start","warning-triangle":t+"#warning-triangle","zoom-in":t+"#zoom-in","zoom-out":t+"#zoom-out"},translations:{ar:ie("./translations/ar.json",e),ca:ie("./translations/ca.json",e),cs:ie("./translations/cs.json",e),da:ie("./translations/da.json",e),de:ie("./translations/de.json",e),en:ie("./translations/en.json",e),es:ie("./translations/es.json",e),fa:ie("./translations/fa.json",e),fi:ie("./translations/fi.json",e),fr:ie("./translations/fr.json",e),gl:ie("./translations/gl.json",e),he:ie("./translations/he.json",e),"hi-in":ie("./translations/hi-in.json",e),hr:ie("./translations/hr.json",e),hu:ie("./translations/hu.json",e),id:ie("./translations/id.json",e),it:ie("./translations/it.json",e),ja:ie("./translations/ja.json",e),"ko-kr":ie("./translations/ko-kr.json",e),ku:ie("./translations/ku.json",e),languages:ie("./translations/languages.json",e),main:ie("./translations/main.json",e),my:ie("./translations/my.json",e),ne:ie("./translations/ne.json",e),no:ie("./translations/no.json",e),pl:ie("./translations/pl.json",e),"pt-br":ie("./translations/pt-br.json",e),"pt-pt":ie("./translations/pt-pt.json",e),ro:ie("./translations/ro.json",e),ru:ie("./translations/ru.json",e),sl:ie("./translations/sl.json",e),sv:ie("./translations/sv.json",e),te:ie("./translations/te.json",e),th:ie("./translations/th.json",e),tr:ie("./translations/tr.json",e),uk:ie("./translations/uk.json",e),vi:ie("./translations/vi.json",e),"zh-cn":ie("./translations/zh-cn.json",e),"zh-tw":ie("./translations/zh-tw.json",e)},embedIcons:{codepen:ie("./embed-icons/codepen.png",e),codesandbox:ie("./embed-icons/codesandbox.png",e),desmos:ie("./embed-icons/desmos.png",e),excalidraw:ie("./embed-icons/excalidraw.png",e),felt:ie("./embed-icons/felt.png",e),figma:ie("./embed-icons/figma.png",e),github_gist:ie("./embed-icons/github_gist.png",e),google_calendar:ie("./embed-icons/google_calendar.png",e),google_maps:ie("./embed-icons/google_maps.png",e),google_slides:ie("./embed-icons/google_slides.png",e),observable:ie("./embed-icons/observable.png",e),replit:ie("./embed-icons/replit.png",e),scratch:ie("./embed-icons/scratch.png",e),spotify:ie("./embed-icons/spotify.png",e),tldraw:ie("./embed-icons/tldraw.png",e),val_town:ie("./embed-icons/val_town.png",e),vimeo:ie("./embed-icons/vimeo.png",e),youtube:ie("./embed-icons/youtube.png",e)}}}var Hl=function(e){return e&&e.Math===Math&&e},wn=Hl(typeof globalThis=="object"&&globalThis)||Hl(typeof window=="object"&&window)||Hl(typeof self=="object"&&self)||Hl(typeof cn=="object"&&cn)||Hl(typeof cn=="object"&&cn)||function(){return this}()||Function("return this")(),fx={},bn=function(e){try{return!!e()}catch{return!0}},V3=bn,ri=!V3(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),Y3=bn,Of=!Y3(function(){var e=(function(){}).bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),X3=Of,xd=Function.prototype.call,as=X3?xd.bind(xd):function(){return xd.apply(xd,arguments)},OE={},DE={}.propertyIsEnumerable,RE=Object.getOwnPropertyDescriptor,q3=RE&&!DE.call({1:2},1);OE.f=q3?function(t){var n=RE(this,t);return!!n&&n.enumerable}:DE;var LE=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}},$E=Of,NE=Function.prototype,sS=NE.call,Z3=$E&&NE.bind.bind(sS,sS),Rt=$E?Z3:function(e){return function(){return sS.apply(e,arguments)}},FE=Rt,Q3=FE({}.toString),J3=FE("".slice),Pl=function(e){return J3(Q3(e),8,-1)},e5=Rt,t5=bn,n5=Pl,Qg=Object,r5=e5("".split),o5=t5(function(){return!Qg("z").propertyIsEnumerable(0)})?function(e){return n5(e)==="String"?r5(e,""):Qg(e)}:Qg,Df=function(e){return e==null},s5=Df,i5=TypeError,Cl=function(e){if(s5(e))throw new i5("Can't call method on "+e);return e},a5=o5,l5=Cl,Rf=function(e){return a5(l5(e))},Jg=typeof document=="object"&&document.all,Pn=typeof Jg>"u"&&Jg!==void 0?function(e){return typeof e=="function"||e===Jg}:function(e){return typeof e=="function"},c5=Pn,ea=function(e){return typeof e=="object"?e!==null:c5(e)},em=wn,u5=Pn,d5=function(e){return u5(e)?e:void 0},Lf=function(e,t){return arguments.length<2?d5(em[e]):em[e]&&em[e][t]},h5=Rt,zE=h5({}.isPrototypeOf),p5=wn,H1=p5.navigator,K1=H1&&H1.userAgent,f5=K1?String(K1):"",BE=wn,tm=f5,W1=BE.process,G1=BE.Deno,V1=W1&&W1.versions||G1&&G1.version,Y1=V1&&V1.v8,Nr,vp;Y1&&(Nr=Y1.split("."),vp=Nr[0]>0&&Nr[0]<4?1:+(Nr[0]+Nr[1]));!vp&&tm&&(Nr=tm.match(/Edge\/(\d+)/),(!Nr||Nr[1]>=74)&&(Nr=tm.match(/Chrome\/(\d+)/),Nr&&(vp=+Nr[1])));var g5=vp,X1=g5,m5=bn,y5=wn,S5=y5.String,UE=!!Object.getOwnPropertySymbols&&!m5(function(){var e=Symbol("symbol detection");return!S5(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&X1&&X1<41}),v5=UE,HE=v5&&!Symbol.sham&&typeof Symbol.iterator=="symbol",x5=Lf,w5=Pn,b5=zE,P5=HE,C5=Object,KE=P5?function(e){return typeof e=="symbol"}:function(e){var t=x5("Symbol");return w5(t)&&b5(t.prototype,C5(e))},I5=String,E5=function(e){try{return I5(e)}catch{return"Object"}},k5=Pn,_5=E5,T5=TypeError,gx=function(e){if(k5(e))return e;throw new T5(_5(e)+" is not a function")},M5=gx,A5=Df,mx=function(e,t){var n=e[t];return A5(n)?void 0:M5(n)},nm=as,rm=Pn,om=ea,j5=TypeError,O5=function(e,t){var n,r;if(t==="string"&&rm(n=e.toString)&&!om(r=nm(n,e))||rm(n=e.valueOf)&&!om(r=nm(n,e))||t!=="string"&&rm(n=e.toString)&&!om(r=nm(n,e)))return r;throw new j5("Can't convert object to primitive value")},WE={exports:{}},q1=wn,D5=Object.defineProperty,yx=function(e,t){try{D5(q1,e,{value:t,configurable:!0,writable:!0})}catch{q1[e]=t}return t},R5=wn,L5=yx,Z1="__core-js_shared__",Q1=WE.exports=R5[Z1]||L5(Z1,{});(Q1.versions||(Q1.versions=[])).push({version:"3.38.0",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Sx=WE.exports,J1=Sx,vx=function(e,t){return J1[e]||(J1[e]=t||{})},$5=Cl,N5=Object,Lu=function(e){return N5($5(e))},F5=Rt,z5=Lu,B5=F5({}.hasOwnProperty),oi=Object.hasOwn||function(t,n){return B5(z5(t),n)},U5=Rt,H5=0,K5=Math.random(),W5=U5(1 .toString),GE=function(e){return"Symbol("+(e===void 0?"":e)+")_"+W5(++H5+K5,36)},G5=wn,V5=vx,eb=oi,Y5=GE,X5=UE,q5=HE,Ia=G5.Symbol,sm=V5("wks"),Z5=q5?Ia.for||Ia:Ia&&Ia.withoutSetter||Y5,ls=function(e){return eb(sm,e)||(sm[e]=X5&&eb(Ia,e)?Ia[e]:Z5("Symbol."+e)),sm[e]},Q5=as,tb=ea,nb=KE,J5=mx,e$=O5,t$=ls,n$=TypeError,r$=t$("toPrimitive"),o$=function(e,t){if(!tb(e)||nb(e))return e;var n=J5(e,r$),r;if(n){if(t===void 0&&(t="default"),r=Q5(n,e,t),!tb(r)||nb(r))return r;throw new n$("Can't convert object to primitive value")}return t===void 0&&(t="number"),e$(e,t)},s$=o$,i$=KE,VE=function(e){var t=s$(e,"string");return i$(t)?t:t+""},a$=wn,rb=ea,iS=a$.document,l$=rb(iS)&&rb(iS.createElement),YE=function(e){return l$?iS.createElement(e):{}},c$=ri,u$=bn,d$=YE,XE=!c$&&!u$(function(){return Object.defineProperty(d$("div"),"a",{get:function(){return 7}}).a!==7}),h$=ri,p$=as,f$=OE,g$=LE,m$=Rf,y$=VE,S$=oi,v$=XE,ob=Object.getOwnPropertyDescriptor;fx.f=h$?ob:function(t,n){if(t=m$(t),n=y$(n),v$)try{return ob(t,n)}catch{}if(S$(t,n))return g$(!p$(f$.f,t,n),t[n])};var Il={},x$=ri,w$=bn,qE=x$&&w$(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),b$=ea,P$=String,C$=TypeError,ta=function(e){if(b$(e))return e;throw new C$(P$(e)+" is not an object")},I$=ri,E$=XE,k$=qE,wd=ta,sb=VE,_$=TypeError,im=Object.defineProperty,T$=Object.getOwnPropertyDescriptor,am="enumerable",lm="configurable",cm="writable";Il.f=I$?k$?function(t,n,r){if(wd(t),n=sb(n),wd(r),typeof t=="function"&&n==="prototype"&&"value"in r&&cm in r&&!r[cm]){var o=T$(t,n);o&&o[cm]&&(t[n]=r.value,r={configurable:lm in r?r[lm]:o[lm],enumerable:am in r?r[am]:o[am],writable:!1})}return im(t,n,r)}:im:function(t,n,r){if(wd(t),n=sb(n),wd(r),E$)try{return im(t,n,r)}catch{}if("get"in r||"set"in r)throw new _$("Accessors not supported");return"value"in r&&(t[n]=r.value),t};var M$=ri,A$=Il,j$=LE,xx=M$?function(e,t,n){return A$.f(e,t,j$(1,n))}:function(e,t,n){return e[t]=n,e},ZE={exports:{}},aS=ri,O$=oi,QE=Function.prototype,D$=aS&&Object.getOwnPropertyDescriptor,wx=O$(QE,"name"),R$=wx&&(function(){}).name==="something",L$=wx&&(!aS||aS&&D$(QE,"name").configurable),$$={EXISTS:wx,PROPER:R$,CONFIGURABLE:L$},N$=Rt,F$=Pn,lS=Sx,z$=N$(Function.toString);F$(lS.inspectSource)||(lS.inspectSource=function(e){return z$(e)});var JE=lS.inspectSource,B$=wn,U$=Pn,ib=B$.WeakMap,H$=U$(ib)&&/native code/.test(String(ib)),K$=vx,W$=GE,ab=K$("keys"),ek=function(e){return ab[e]||(ab[e]=W$(e))},bx={},G$=H$,tk=wn,V$=ea,Y$=xx,um=oi,dm=Sx,X$=ek,q$=bx,lb="Object already initialized",cS=tk.TypeError,Z$=tk.WeakMap,xp,eu,wp,Q$=function(e){return wp(e)?eu(e):xp(e,{})},J$=function(e){return function(t){var n;if(!V$(t)||(n=eu(t)).type!==e)throw new cS("Incompatible receiver, "+e+" required");return n}};if(G$||dm.state){var no=dm.state||(dm.state=new Z$);no.get=no.get,no.has=no.has,no.set=no.set,xp=function(e,t){if(no.has(e))throw new cS(lb);return t.facade=e,no.set(e,t),t},eu=function(e){return no.get(e)||{}},wp=function(e){return no.has(e)}}else{var ua=X$("state");q$[ua]=!0,xp=function(e,t){if(um(e,ua))throw new cS(lb);return t.facade=e,Y$(e,ua,t),t},eu=function(e){return um(e,ua)?e[ua]:{}},wp=function(e){return um(e,ua)}}var nk={set:xp,get:eu,has:wp,enforce:Q$,getterFor:J$},Px=Rt,eN=bn,tN=Pn,bd=oi,uS=ri,nN=$$.CONFIGURABLE,rN=JE,rk=nk,oN=rk.enforce,sN=rk.get,cb=String,Ih=Object.defineProperty,iN=Px("".slice),aN=Px("".replace),lN=Px([].join),cN=uS&&!eN(function(){return Ih(function(){},"length",{value:8}).length!==8}),uN=String(String).split("String"),dN=ZE.exports=function(e,t,n){iN(cb(t),0,7)==="Symbol("&&(t="["+aN(cb(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!bd(e,"name")||nN&&e.name!==t)&&(uS?Ih(e,"name",{value:t,configurable:!0}):e.name=t),cN&&n&&bd(n,"arity")&&e.length!==n.arity&&Ih(e,"length",{value:n.arity});try{n&&bd(n,"constructor")&&n.constructor?uS&&Ih(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var r=oN(e);return bd(r,"source")||(r.source=lN(uN,typeof t=="string"?t:"")),e};Function.prototype.toString=dN(function(){return tN(this)&&sN(this).source||rN(this)},"toString");var hN=ZE.exports,pN=Pn,fN=Il,gN=hN,mN=yx,ok=function(e,t,n,r){r||(r={});var o=r.enumerable,s=r.name!==void 0?r.name:t;if(pN(n)&&gN(n,s,r),r.global)o?e[t]=n:mN(t,n);else{try{r.unsafe?e[t]&&(o=!0):delete e[t]}catch{}o?e[t]=n:fN.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},sk={},yN=Math.ceil,SN=Math.floor,vN=Math.trunc||function(t){var n=+t;return(n>0?SN:yN)(n)},xN=vN,na=function(e){var t=+e;return t!==t||t===0?0:xN(t)},wN=na,bN=Math.max,PN=Math.min,CN=function(e,t){var n=wN(e);return n<0?bN(n+t,0):PN(n,t)},IN=na,EN=Math.min,ik=function(e){var t=IN(e);return t>0?EN(t,9007199254740991):0},kN=ik,$u=function(e){return kN(e.length)},_N=Rf,TN=CN,MN=$u,ub=function(e){return function(t,n,r){var o=_N(t),s=MN(o);if(s===0)return!e&&-1;var i=TN(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}},AN={includes:ub(!0),indexOf:ub(!1)},jN=Rt,hm=oi,ON=Rf,DN=AN.indexOf,RN=bx,db=jN([].push),ak=function(e,t){var n=ON(e),r=0,o=[],s;for(s in n)!hm(RN,s)&&hm(n,s)&&db(o,s);for(;t.length>r;)hm(n,s=t[r++])&&(~DN(o,s)||db(o,s));return o},Cx=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],LN=ak,$N=Cx,NN=$N.concat("length","prototype");sk.f=Object.getOwnPropertyNames||function(t){return LN(t,NN)};var lk={};lk.f=Object.getOwnPropertySymbols;var FN=Lf,zN=Rt,BN=sk,UN=lk,HN=ta,KN=zN([].concat),WN=FN("Reflect","ownKeys")||function(t){var n=BN.f(HN(t)),r=UN.f;return r?KN(n,r(t)):n},hb=oi,GN=WN,VN=fx,YN=Il,XN=function(e,t,n){for(var r=GN(t),o=YN.f,s=VN.f,i=0;i<r.length;i++){var a=r[i];!hb(e,a)&&!(n&&hb(n,a))&&o(e,a,s(t,a))}},qN=bn,ZN=Pn,QN=/#|\.prototype\./,Nu=function(e,t){var n=eF[JN(e)];return n===nF?!0:n===tF?!1:ZN(t)?qN(t):!!t},JN=Nu.normalize=function(e){return String(e).replace(QN,".").toLowerCase()},eF=Nu.data={},tF=Nu.NATIVE="N",nF=Nu.POLYFILL="P",rF=Nu,Pd=wn,oF=fx.f,sF=xx,iF=ok,aF=yx,lF=XN,cF=rF,El=function(e,t){var n=e.target,r=e.global,o=e.stat,s,i,a,l,c,u;if(r?i=Pd:o?i=Pd[n]||aF(n,{}):i=Pd[n]&&Pd[n].prototype,i)for(a in t){if(c=t[a],e.dontCallGetSet?(u=oF(i,a),l=u&&u.value):l=i[a],s=cF(r?a:n+(o?".":"#")+a,e.forced),!s&&l!==void 0){if(typeof c==typeof l)continue;lF(c,l)}(e.sham||l&&l.sham)&&sF(c,"sham",!0),iF(i,a,c,e)}},ck={},uF=ak,dF=Cx,hF=Object.keys||function(t){return uF(t,dF)},pF=ri,fF=qE,gF=Il,mF=ta,yF=Rf,SF=hF;ck.f=pF&&!fF?Object.defineProperties:function(t,n){mF(t);for(var r=yF(n),o=SF(n),s=o.length,i=0,a;s>i;)gF.f(t,a=o[i++],r[a]);return t};var vF=Lf,xF=vF("document","documentElement"),wF=ta,bF=ck,pb=Cx,PF=bx,CF=xF,IF=YE,EF=ek,fb=">",gb="<",dS="prototype",hS="script",uk=EF("IE_PROTO"),pm=function(){},dk=function(e){return gb+hS+fb+e+gb+"/"+hS+fb},mb=function(e){e.write(dk("")),e.close();var t=e.parentWindow.Object;return e=null,t},kF=function(){var e=IF("iframe"),t="java"+hS+":",n;return e.style.display="none",CF.appendChild(e),e.src=String(t),n=e.contentWindow.document,n.open(),n.write(dk("document.F=Object")),n.close(),n.F},Cd,Eh=function(){try{Cd=new ActiveXObject("htmlfile")}catch{}Eh=typeof document<"u"?document.domain&&Cd?mb(Cd):kF():mb(Cd);for(var e=pb.length;e--;)delete Eh[dS][pb[e]];return Eh()};PF[uk]=!0;var hk=Object.create||function(t,n){var r;return t!==null?(pm[dS]=wF(t),r=new pm,pm[dS]=null,r[uk]=t):r=Eh(),n===void 0?r:bF.f(r,n)},_F=ls,TF=hk,MF=Il.f,pS=_F("unscopables"),fS=Array.prototype;fS[pS]===void 0&&MF(fS,pS,{configurable:!0,value:TF(null)});var Ix=function(e){fS[pS][e]=!0},AF=El,jF=Lu,OF=$u,DF=na,RF=Ix;AF({target:"Array",proto:!0},{at:function(t){var n=jF(this),r=OF(n),o=DF(t),s=o>=0?o:r+o;return s<0||s>=r?void 0:n[s]}});RF("at");var LF=wn,$F=Rt,Fu=function(e,t){return $F(LF[e].prototype[t])},NF=Fu;NF("Array","at");var FF=Pl,pk=Array.isArray||function(t){return FF(t)==="Array"},zF=TypeError,BF=9007199254740991,UF=function(e){if(e>BF)throw zF("Maximum allowed index exceeded");return e},HF=Pl,KF=Rt,WF=function(e){if(HF(e)==="Function")return KF(e)},yb=WF,GF=gx,VF=Of,YF=yb(yb.bind),XF=function(e,t){return GF(e),t===void 0?e:VF?YF(e,t):function(){return e.apply(t,arguments)}},qF=pk,ZF=$u,QF=UF,JF=XF,fk=function(e,t,n,r,o,s,i,a){for(var l=o,c=0,u=i?JF(i,a):!1,h,p;c<r;)c in n&&(h=u?u(n[c],c,t):n[c],s>0&&qF(h)?(p=ZF(h),l=fk(e,t,h,p,l,s-1)-1):(QF(l+1),e[l]=h),l++),c++;return l},gk=fk,e4=ls,t4=e4("toStringTag"),mk={};mk[t4]="z";var n4=String(mk)==="[object z]",r4=n4,o4=Pn,kh=Pl,s4=ls,i4=s4("toStringTag"),a4=Object,l4=kh(function(){return arguments}())==="Arguments",c4=function(e,t){try{return e[t]}catch{}},yk=r4?kh:function(e){var t,n,r;return e===void 0?"Undefined":e===null?"Null":typeof(n=c4(t=a4(e),i4))=="string"?n:l4?kh(t):(r=kh(t))==="Object"&&o4(t.callee)?"Arguments":r},u4=Rt,d4=bn,Sk=Pn,h4=yk,p4=Lf,f4=JE,vk=function(){},xk=p4("Reflect","construct"),Ex=/^\s*(?:class|function)\b/,g4=u4(Ex.exec),m4=!Ex.test(vk),Kl=function(t){if(!Sk(t))return!1;try{return xk(vk,[],t),!0}catch{return!1}},wk=function(t){if(!Sk(t))return!1;switch(h4(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return m4||!!g4(Ex,f4(t))}catch{return!0}};wk.sham=!0;var y4=!xk||d4(function(){var e;return Kl(Kl.call)||!Kl(Object)||!Kl(function(){e=!0})||e})?wk:Kl,Sb=pk,S4=y4,v4=ea,x4=ls,w4=x4("species"),vb=Array,b4=function(e){var t;return Sb(e)&&(t=e.constructor,S4(t)&&(t===vb||Sb(t.prototype))?t=void 0:v4(t)&&(t=t[w4],t===null&&(t=void 0))),t===void 0?vb:t},P4=b4,bk=function(e,t){return new(P4(e))(t===0?0:t)},C4=El,I4=gk,E4=gx,k4=Lu,_4=$u,T4=bk;C4({target:"Array",proto:!0},{flatMap:function(t){var n=k4(this),r=_4(n),o;return E4(t),o=T4(n,0),o.length=I4(o,n,n,r,0,1,t,arguments.length>1?arguments[1]:void 0),o}});var M4=Ix;M4("flatMap");var A4=Fu;A4("Array","flatMap");var j4=El,O4=gk,D4=Lu,R4=$u,L4=na,$4=bk;j4({target:"Array",proto:!0},{flat:function(){var t=arguments.length?arguments[0]:void 0,n=D4(this),r=R4(n),o=$4(n,0);return o.length=O4(o,n,n,r,0,t===void 0?1:L4(t)),o}});var N4=Ix;N4("flat");var F4=Fu;F4("Array","flat");var z4=yk,B4=String,zu=function(e){if(z4(e)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return B4(e)},U4=El,H4=Rt,K4=Cl,W4=na,G4=zu,V4=bn,Y4=H4("".charAt),X4=V4(function(){return"𠮷".at(-2)!=="\uD842"});U4({target:"String",proto:!0,forced:X4},{at:function(t){var n=G4(K4(this)),r=n.length,o=W4(t),s=o>=0?o:r+o;return s<0||s>=r?void 0:Y4(n,s)}});var q4=Fu;q4("String","at");var Z4=ta,Pk=function(){var e=Z4(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=bn,Q4=wn,_x=Q4.RegExp,Tx=kx(function(){var e=_x("a","y");return e.lastIndex=2,e.exec("abcd")!==null}),J4=Tx||kx(function(){return!_x("a","y").sticky}),ez=Tx||kx(function(){var e=_x("^r","gy");return e.lastIndex=2,e.exec("str")!==null}),tz={BROKEN_CARET:ez,MISSED_STICKY:J4,UNSUPPORTED_Y:Tx},nz=bn,rz=wn,oz=rz.RegExp,sz=nz(function(){var e=oz(".","s");return!(e.dotAll&&e.test(`
|
|
18
|
+
`)&&e.flags==="s")}),iz=bn,az=wn,lz=az.RegExp,cz=iz(function(){var e=lz("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),Ea=as,$f=Rt,uz=zu,dz=Pk,hz=tz,pz=vx,fz=hk,gz=nk.get,mz=sz,yz=cz,Sz=pz("native-string-replace",String.prototype.replace),bp=RegExp.prototype.exec,gS=bp,vz=$f("".charAt),xz=$f("".indexOf),wz=$f("".replace),fm=$f("".slice),mS=function(){var e=/a/,t=/b*/g;return Ea(bp,e,"a"),Ea(bp,t,"a"),e.lastIndex!==0||t.lastIndex!==0}(),Ck=hz.BROKEN_CARET,yS=/()??/.exec("")[1]!==void 0,bz=mS||yS||Ck||mz||yz;bz&&(gS=function(t){var n=this,r=gz(n),o=uz(t),s=r.raw,i,a,l,c,u,h,p;if(s)return s.lastIndex=n.lastIndex,i=Ea(gS,s,o),n.lastIndex=s.lastIndex,i;var f=r.groups,S=Ck&&n.sticky,y=Ea(dz,n),x=n.source,m=0,v=o;if(S&&(y=wz(y,"y",""),xz(y,"g")===-1&&(y+="g"),v=fm(o,n.lastIndex),n.lastIndex>0&&(!n.multiline||n.multiline&&vz(o,n.lastIndex-1)!==`
|
|
19
|
+
`)&&(x="(?: "+x+")",v=" "+v,m++),a=new RegExp("^(?:"+x+")",y)),yS&&(a=new RegExp("^"+x+"$(?!\\s)",y)),mS&&(l=n.lastIndex),c=Ea(bp,S?a:n,v),S?c?(c.input=fm(c.input,m),c[0]=fm(c[0],m),c.index=n.lastIndex,n.lastIndex+=c[0].length):n.lastIndex=0:mS&&c&&(n.lastIndex=n.global?c.index+c[0].length:l),yS&&c&&c.length>1&&Ea(Sz,c[0],a,function(){for(u=1;u<arguments.length-2;u++)arguments[u]===void 0&&(c[u]=void 0)}),c&&f)for(c.groups=h=fz(null),u=0;u<f.length;u++)p=f[u],h[p[0]]=c[p[1]];return c});var Mx=gS,Pz=El,xb=Mx;Pz({target:"RegExp",proto:!0,forced:/./.exec!==xb},{exec:xb});var Cz=Of,Ik=Function.prototype,wb=Ik.apply,bb=Ik.call,Iz=typeof Reflect=="object"&&Reflect.apply||(Cz?bb.bind(wb):function(){return bb.apply(wb,arguments)}),Pb=as,Cb=ok,Ez=Mx,Ib=bn,Ek=ls,kz=xx,_z=Ek("species"),gm=RegExp.prototype,Tz=function(e,t,n,r){var o=Ek(e),s=!Ib(function(){var c={};return c[o]=function(){return 7},""[e](c)!==7}),i=s&&!Ib(function(){var c=!1,u=/a/;return e==="split"&&(u={},u.constructor={},u.constructor[_z]=function(){return u},u.flags="",u[o]=/./[o]),u.exec=function(){return c=!0,null},u[o](""),!c});if(!s||!i||n){var a=/./[o],l=t(o,""[e],function(c,u,h,p,f){var S=u.exec;return S===Ez||S===gm.exec?s&&!f?{done:!0,value:Pb(a,u,h,p)}:{done:!0,value:Pb(c,h,u,p)}:{done:!1}});Cb(String.prototype,e,l[0]),Cb(gm,o,l[1])}r&&kz(gm[o],"sham",!0)},Ax=Rt,Mz=na,Az=zu,jz=Cl,Oz=Ax("".charAt),Eb=Ax("".charCodeAt),Dz=Ax("".slice),kb=function(e){return function(t,n){var r=Az(jz(t)),o=Mz(n),s=r.length,i,a;return o<0||o>=s?e?"":void 0:(i=Eb(r,o),i<55296||i>56319||o+1===s||(a=Eb(r,o+1))<56320||a>57343?e?Oz(r,o):i:e?Dz(r,o,o+2):(i-55296<<10)+(a-56320)+65536)}},Rz={codeAt:kb(!1),charAt:kb(!0)},Lz=Rz.charAt,$z=function(e,t,n){return t+(n?Lz(e,t).length:1)},jx=Rt,Nz=Lu,Fz=Math.floor,mm=jx("".charAt),zz=jx("".replace),ym=jx("".slice),Bz=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Uz=/\$([$&'`]|\d{1,2})/g,kk=function(e,t,n,r,o,s){var i=n+e.length,a=r.length,l=Uz;return o!==void 0&&(o=Nz(o),l=Bz),zz(s,l,function(c,u){var h;switch(mm(u,0)){case"$":return"$";case"&":return e;case"`":return ym(t,0,n);case"'":return ym(t,i);case"<":h=o[ym(u,1,-1)];break;default:var p=+u;if(p===0)return c;if(p>a){var f=Fz(p/10);return f===0?c:f<=a?r[f-1]===void 0?mm(u,1):r[f-1]+mm(u,1):c}h=r[p-1]}return h===void 0?"":h})},_b=as,Hz=ta,Kz=Pn,Wz=Pl,Gz=Mx,Vz=TypeError,Yz=function(e,t){var n=e.exec;if(Kz(n)){var r=_b(n,e,t);return r!==null&&Hz(r),r}if(Wz(e)==="RegExp")return _b(Gz,e,t);throw new Vz("RegExp#exec called on incompatible receiver")},Xz=Iz,Tb=as,Nf=Rt,qz=Tz,Zz=bn,Qz=ta,Jz=Pn,e6=Df,t6=na,n6=ik,da=zu,r6=Cl,o6=$z,s6=mx,i6=kk,a6=Yz,l6=ls,SS=l6("replace"),c6=Math.max,u6=Math.min,d6=Nf([].concat),Sm=Nf([].push),Mb=Nf("".indexOf),Ab=Nf("".slice),h6=function(e){return e===void 0?e:String(e)},p6=function(){return"a".replace(/./,"$0")==="$0"}(),jb=function(){return/./[SS]?/./[SS]("a","$0")==="":!1}(),f6=!Zz(function(){var e=/./;return e.exec=function(){var t=[];return t.groups={a:"7"},t},"".replace(e,"$<a>")!=="7"});qz("replace",function(e,t,n){var r=jb?"$":"$0";return[function(s,i){var a=r6(this),l=e6(s)?void 0:s6(s,SS);return l?Tb(l,s,a,i):Tb(t,da(a),s,i)},function(o,s){var i=Qz(this),a=da(o);if(typeof s=="string"&&Mb(s,r)===-1&&Mb(s,"$<")===-1){var l=n(t,i,a,s);if(l.done)return l.value}var c=Jz(s);c||(s=da(s));var u=i.global,h;u&&(h=i.unicode,i.lastIndex=0);for(var p=[],f;f=a6(i,a),!(f===null||(Sm(p,f),!u));){var S=da(f[0]);S===""&&(i.lastIndex=o6(a,n6(i.lastIndex),h))}for(var y="",x=0,m=0;m<p.length;m++){f=p[m];for(var v=da(f[0]),w=c6(u6(t6(f.index),a.length),0),C=[],E,_=1;_<f.length;_++)Sm(C,h6(f[_]));var I=f.groups;if(c){var k=d6([v],C,w,a);I!==void 0&&Sm(k,I),E=da(Xz(s,void 0,k))}else E=i6(v,a,w,C,I,s);w>=x&&(y+=Ab(a,x,w)+E,x=w+v.length)}return y+Ab(a,x)}]},!f6||!p6||jb);var g6=ea,m6=Pl,y6=ls,S6=y6("match"),v6=function(e){var t;return g6(e)&&((t=e[S6])!==void 0?!!t:m6(e)==="RegExp")},x6=as,w6=oi,b6=zE,P6=Pk,Ob=RegExp.prototype,C6=function(e){var t=e.flags;return t===void 0&&!("flags"in Ob)&&!w6(e,"flags")&&b6(Ob,e)?x6(P6,e):t},I6=El,E6=as,Ox=Rt,Db=Cl,k6=Pn,_6=Df,T6=v6,Wl=zu,M6=mx,A6=C6,j6=kk,O6=ls,D6=O6("replace"),R6=TypeError,vm=Ox("".indexOf);Ox("".replace);var Rb=Ox("".slice),L6=Math.max;I6({target:"String",proto:!0},{replaceAll:function(t,n){var r=Db(this),o,s,i,a,l,c,u,h,p,f,S=0,y="";if(!_6(t)){if(o=T6(t),o&&(s=Wl(Db(A6(t))),!~vm(s,"g")))throw new R6("`.replaceAll` does not allow non-global regexes");if(i=M6(t,D6),i)return E6(i,t,r,n)}for(a=Wl(r),l=Wl(t),c=k6(n),c||(n=Wl(n)),u=l.length,h=L6(1,u),p=vm(a,l);p!==-1;)f=c?Wl(n(l,p,a)):j6(l,a,p,[],void 0,n),y+=Rb(a,S,p)+f,S=p+u,p=p+h>a.length?-1:vm(a,l,p+h);return S<a.length&&(y+=Rb(a,S)),y}});var $6=Fu;$6("String","replaceAll");function _k(e){return e&&typeof e=="object"&&"parents"in e}function Tk(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 Pp=(e,t)=>{if(e.children.remove(t)&&e.children.isEmpty&&_k(e))for(let n=0,r=e.parents.length;n<r;n++)Pp(e.parents[n],e)},Dx=(e,t)=>{if(e.children.add(t)&&_k(e))for(let n=0,r=e.parents.length;n<r;n++)Dx(e.parents[n],e)};function Mk(e,t){return e===t||Object.is(e,t)||!!(e&&t&&typeof e.equals=="function"&&e.equals(t))}function si(e,t){const n=Symbol.for(`com.tldraw.state/${e}`),r=globalThis;return r[n]??(r[n]=t()),r[n]}const Vo=si("empty_array",()=>Object.freeze([])),Lb=8;class Cp{constructor(){g(this,"arraySize",0);g(this,"array",Array(Lb));g(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<Lb?(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 rr=Symbol.for("com.tldraw.state/RESET_VALUE");class Ak{constructor(t){g(this,"index",0);g(this,"buffer");this.capacity=t,this.buffer=new Array(t)}pushEntry(t,n,r){if(r!==void 0){if(r===rr){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 rr;const[l,c]=a;if(s===0&&t>=c)return[];if(l<=t&&t<c){const u=s+1,h=new Array(u);for(let p=0;p<u;p++)h[p]=o[(i+p)%r][2];return h}}return rr}}class N6{constructor(t,n){g(this,"offset",0);g(this,"maybeRemoved");this.below=t,this.child=n}}const rt=si("capture",()=>({stack:null}));function Id(e){const t=rt.stack;rt.stack=null;try{return e()}finally{rt.stack=t}}function jk(e){rt.stack=new N6(rt.stack,e),e.parentSet.clear()}function Ok(){const e=rt.stack;if(rt.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)||Pp(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)||Pp(n,e.child)}}function Ip(e){if(rt.stack){if(rt.stack.child.parentSet.has(e))return;if(rt.stack.child.parentSet.add(e),rt.stack.child.isActivelyListening&&Dx(e,rt.stack.child),rt.stack.offset<rt.stack.child.parents.length){const n=rt.stack.child.parents[rt.stack.offset];n!==e&&(rt.stack.maybeRemoved?rt.stack.maybeRemoved.push(n):rt.stack.maybeRemoved=[n])}rt.stack.child.parents[rt.stack.offset]=e,rt.stack.child.parentEpochs[rt.stack.offset]=e.lastChangedEpoch,rt.stack.offset++}}const Ms=-1;class F6{constructor(t,n,r){g(this,"_isActivelyListening",!1);g(this,"lastTraversedEpoch",Ms);g(this,"lastReactedEpoch",Ms);g(this,"_scheduleCount",0);g(this,"parentSet",new Cp);g(this,"parentEpochs",[]);g(this,"parents",[]);g(this,"_scheduleEffect");g(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!==jn()){if(this.parents.length&&!Tk(this)){this.lastReactedEpoch=jn();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++)Dx(this.parents[t],this)}detach(){this._isActivelyListening=!1;for(let t=0,n=this.parents.length;t<n;t++)Pp(this.parents[t],this)}execute(){try{jk(this);const t=jn(),n=this.runEffect(this.lastReactedEpoch);return this.lastReactedEpoch=t,n}finally{Ok()}}}const kl=si("EffectScheduler",()=>F6);function ra(e,t,n){const r=new kl(e,t,n);return r.attach(),r.scheduleEffect(),()=>{r.detach()}}function z6(e,t,n){const r=new kl(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 B6{constructor(t){g(this,"initialAtomValues",new Map);this.parent=t}get isRoot(){return this.parent===null}commit(){this.isRoot?Dk(this.initialAtomValues.keys()):this.initialAtomValues.forEach((t,n)=>{this.parent.initialAtomValues.has(n)||this.parent.initialAtomValues.set(n,t)})}abort(){ze.globalEpoch++,this.initialAtomValues.forEach((t,n)=>{var r;n.set(t),(r=n.historyBuffer)==null||r.clear()}),this.commit()}}const ze=si("transactions",()=>({globalEpoch:Ms+1,globalIsReacting:!1,currentTransaction:null,cleanupReactors:null,reactionEpoch:Ms+1}));function U6(){return ze.reactionEpoch}function jn(){return ze.globalEpoch}function H6(){return ze.globalIsReacting}function Rx(e,t){t.lastTraversedEpoch!==ze.globalEpoch&&(t.lastTraversedEpoch=ze.globalEpoch,t instanceof kl?e.add(t):t.children.visit(n=>Rx(e,n)))}function Dk(e){var t;if(ze.globalIsReacting)throw new Error("cannot change atoms during reaction cycle");try{ze.globalIsReacting=!0,ze.reactionEpoch=ze.globalEpoch;const n=new Set;for(const o of e)o.children.visit(s=>Rx(n,s));for(const o of n)o.maybeScheduleEffect();let r=0;for(;(t=ze.cleanupReactors)!=null&&t.size;){if(r++>1e3)throw new Error("Reaction update depth limit exceeded");const o=ze.cleanupReactors;ze.cleanupReactors=null;for(const s of o)s.maybeScheduleEffect()}}finally{ze.cleanupReactors=null,ze.globalIsReacting=!1}}function K6(e,t){if(ze.globalIsReacting){const n=ze.cleanupReactors??(ze.cleanupReactors=new Set);e.children.visit(r=>Rx(n,r))}else ze.currentTransaction?ze.currentTransaction.initialAtomValues.has(e)||ze.currentTransaction.initialAtomValues.set(e,t):Dk([e])}function W6(){ze.globalEpoch++}function G6(e){const t=new B6(ze.currentTransaction);ze.currentTransaction=t;try{let n,r=!1;try{n=e(()=>r=!0)}catch(o){throw t.abort(),o}return r?t.abort():t.commit(),n}finally{ze.currentTransaction=ze.currentTransaction.parent}}function mo(e){return ze.currentTransaction?e():G6(e)}class V6{constructor(t,n,r){g(this,"isEqual");g(this,"computeDiff");g(this,"lastChangedEpoch",jn());g(this,"children",new Cp);g(this,"historyBuffer");this.name=t,this.current=n,this.isEqual=(r==null?void 0:r.isEqual)??null,r&&(r.historyLength&&(this.historyBuffer=new Ak(r.historyLength)),this.computeDiff=r.computeDiff)}__unsafe__getWithoutCapture(t){return this.current}get(){return Ip(this),this.current}set(t,n){var o,s;if(((o=this.isEqual)==null?void 0:o.call(this,this.current,t))??Mk(this.current,t))return this.current;W6(),this.historyBuffer&&this.historyBuffer.pushEntry(this.lastChangedEpoch,jn(),n??((s=this.computeDiff)==null?void 0:s.call(this,this.current,t,this.lastChangedEpoch,jn()))??rr),this.lastChangedEpoch=jn();const r=this.current;return this.current=t,K6(this,r),t}update(t){return this.set(t(this.current))}getDiffSince(t){var n;return Ip(this),t>=this.lastChangedEpoch?Vo:((n=this.historyBuffer)==null?void 0:n.getChangesSince(t))??rr}}const Y6=si("Atom",()=>V6);function Mt(e,t,n){return new Y6(e,t,n)}let $b=!1;function X6(){$b||($b=!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.
|
|
20
|
+
|
|
21
|
+
// Before
|
|
22
|
+
@computed
|
|
23
|
+
get foo() {
|
|
24
|
+
return 'foo'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// After
|
|
28
|
+
@computed
|
|
29
|
+
getFoo() {
|
|
30
|
+
return 'foo'
|
|
31
|
+
}
|
|
32
|
+
`))}const gc=Symbol.for("com.tldraw.state/UNINITIALIZED"),Mi=e=>e===gc,vS=si("WithDiff",()=>class{constructor(t,n){this.value=t,this.diff=n}});function mc(e,t){return new vS(e,t)}class q6{constructor(t,n,r){g(this,"lastChangedEpoch",Ms);g(this,"lastTraversedEpoch",Ms);g(this,"lastCheckedEpoch",Ms);g(this,"parentSet",new Cp);g(this,"parents",[]);g(this,"parentEpochs",[]);g(this,"children",new Cp);g(this,"historyBuffer");g(this,"state",gc);g(this,"error",null);g(this,"computeDiff");g(this,"isEqual");this.name=t,this.derive=n,r!=null&&r.historyLength&&(this.historyBuffer=new Ak(r.historyLength)),this.computeDiff=r==null?void 0:r.computeDiff,this.isEqual=(r==null?void 0:r.isEqual)??Mk}get isActivelyListening(){return!this.children.isEmpty}__unsafe__getWithoutCapture(t){var o;const n=this.lastChangedEpoch===Ms,r=jn();if(!n&&(this.lastCheckedEpoch===r||this.isActivelyListening&&H6()&&this.lastTraversedEpoch<U6()||!Tk(this)))if(this.lastCheckedEpoch=r,this.error){if(t)return this.state;throw this.error.thrownValue}else return this.state;try{jk(this);const s=this.derive(this.state,this.lastCheckedEpoch),i=s instanceof vS?s.value:s,a=this.state===gc;if(a||!this.isEqual(i,this.state)){if(this.historyBuffer&&!a){const l=s instanceof vS?s.diff:void 0;this.historyBuffer.pushEntry(this.lastChangedEpoch,jn(),l??((o=this.computeDiff)==null?void 0:o.call(this,this.state,i,this.lastCheckedEpoch,jn()))??rr)}this.lastChangedEpoch=jn(),this.state=i}return this.error=null,this.lastCheckedEpoch=jn(),this.state}catch(s){if(this.state!==gc&&(this.state=gc,this.lastChangedEpoch=jn()),this.lastCheckedEpoch=jn(),this.historyBuffer&&this.historyBuffer.clear(),this.error={thrownValue:s},!t)throw s;return this.state}finally{Ok()}}get(){try{return this.__unsafe__getWithoutCapture()}finally{Ip(this)}}getDiffSince(t){var n;return this.__unsafe__getWithoutCapture(!0),Ip(this),t>=this.lastChangedEpoch?Vo:((n=this.historyBuffer)==null?void 0:n.getChangesSince(t))??rr}}const Lx=si("Computed",()=>q6);function Z6(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 Lx(n,o.bind(this),e),Object.defineProperty(this,s,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()},r.value[J6]=!0,r}function Nb(e={},t,n,r){return r.get?(X6(),Q6(e,t,n,r)):Z6(e,t,n,r)}function Q6(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 Lx(n,o.bind(this),e),Object.defineProperty(this,s,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()},r}const J6="@@__isComputedMethod__@@";function G(){if(arguments.length===1){const e=arguments[0];return(t,n,r)=>Nb(e,t,n,r)}else return typeof arguments[0]=="string"?new Lx(arguments[0],arguments[1],arguments[2]):Nb(void 0,arguments[0],arguments[1],arguments[2])}const Rk=1,e8=si("apiVersion",()=>Rk);if(e8!==Rk)throw new Error("You have multiple incompatible versions of @tldraw/state in your app. Please deduplicate the package.");var Lk="Expected a function",Fb=NaN,t8="[object Symbol]",n8=/^\s+|\s+$/g,r8=/^[-+]0x[0-9a-f]+$/i,o8=/^0b[01]+$/i,s8=/^0o[0-7]+$/i,i8=parseInt,a8=typeof cn=="object"&&cn&&cn.Object===Object&&cn,l8=typeof self=="object"&&self&&self.Object===Object&&self,c8=a8||l8||Function("return this")(),u8=Object.prototype,d8=u8.toString,h8=Math.max,p8=Math.min,xm=function(){return c8.Date.now()};function f8(e,t,n){var r,o,s,i,a,l,c=0,u=!1,h=!1,p=!0;if(typeof e!="function")throw new TypeError(Lk);t=zb(t)||0,Ep(n)&&(u=!!n.leading,h="maxWait"in n,s=h?h8(zb(n.maxWait)||0,t):s,p="trailing"in n?!!n.trailing:p);function f(_){var I=r,k=o;return r=o=void 0,c=_,i=e.apply(k,I),i}function S(_){return c=_,a=setTimeout(m,t),u?f(_):i}function y(_){var I=_-l,k=_-c,T=t-I;return h?p8(T,s-k):T}function x(_){var I=_-l,k=_-c;return l===void 0||I>=t||I<0||h&&k>=s}function m(){var _=xm();if(x(_))return v(_);a=setTimeout(m,y(_))}function v(_){return a=void 0,p&&r?f(_):(r=o=void 0,i)}function w(){a!==void 0&&clearTimeout(a),c=0,r=l=o=a=void 0}function C(){return a===void 0?i:v(xm())}function E(){var _=xm(),I=x(_);if(r=arguments,o=this,l=_,I){if(a===void 0)return S(l);if(h)return a=setTimeout(m,t),f(l)}return a===void 0&&(a=setTimeout(m,t)),i}return E.cancel=w,E.flush=C,E}function g8(e,t,n){var r=!0,o=!0;if(typeof e!="function")throw new TypeError(Lk);return Ep(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),f8(e,t,{leading:r,maxWait:t,trailing:o})}function Ep(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function m8(e){return!!e&&typeof e=="object"}function y8(e){return typeof e=="symbol"||m8(e)&&d8.call(e)==t8}function zb(e){if(typeof e=="number")return e;if(y8(e))return Fb;if(Ep(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Ep(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(n8,"");var n=o8.test(e);return n||s8.test(e)?i8(e.slice(2),n?2:8):r8.test(e)?Fb:+e}var S8=g8;const $k=ni(S8);var v8=200,$x="__lodash_hash_undefined__",x8=1/0,w8="[object Function]",b8="[object GeneratorFunction]",P8=/[\\^$.*+?()[\]{}|]/g,C8=/^\[object .+?Constructor\]$/,I8=typeof cn=="object"&&cn&&cn.Object===Object&&cn,E8=typeof self=="object"&&self&&self.Object===Object&&self,Nx=I8||E8||Function("return this")();function k8(e,t){var n=e?e.length:0;return!!n&&T8(e,t,0)>-1}function _8(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 T8(e,t,n){if(t!==t)return _8(e,M8,n);for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}function M8(e){return e!==e}function A8(e,t){return e.has(t)}function j8(e,t){return e==null?void 0:e[t]}function O8(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function Nk(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var D8=Array.prototype,R8=Function.prototype,Fk=Object.prototype,wm=Nx["__core-js_shared__"],Bb=function(){var e=/[^.]+$/.exec(wm&&wm.keys&&wm.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),zk=R8.toString,Fx=Fk.hasOwnProperty,L8=Fk.toString,$8=RegExp("^"+zk.call(Fx).replace(P8,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),N8=D8.splice,F8=zx(Nx,"Map"),bm=zx(Nx,"Set"),tu=zx(Object,"create");function Ri(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 z8(){this.__data__=tu?tu(null):{}}function B8(e){return this.has(e)&&delete this.__data__[e]}function U8(e){var t=this.__data__;if(tu){var n=t[e];return n===$x?void 0:n}return Fx.call(t,e)?t[e]:void 0}function H8(e){var t=this.__data__;return tu?t[e]!==void 0:Fx.call(t,e)}function K8(e,t){var n=this.__data__;return n[e]=tu&&t===void 0?$x:t,this}Ri.prototype.clear=z8;Ri.prototype.delete=B8;Ri.prototype.get=U8;Ri.prototype.has=H8;Ri.prototype.set=K8;function _l(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 W8(){this.__data__=[]}function G8(e){var t=this.__data__,n=Ff(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():N8.call(t,n,1),!0}function V8(e){var t=this.__data__,n=Ff(t,e);return n<0?void 0:t[n][1]}function Y8(e){return Ff(this.__data__,e)>-1}function X8(e,t){var n=this.__data__,r=Ff(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}_l.prototype.clear=W8;_l.prototype.delete=G8;_l.prototype.get=V8;_l.prototype.has=Y8;_l.prototype.set=X8;function Tl(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 q8(){this.__data__={hash:new Ri,map:new(F8||_l),string:new Ri}}function Z8(e){return zf(this,e).delete(e)}function Q8(e){return zf(this,e).get(e)}function J8(e){return zf(this,e).has(e)}function eB(e,t){return zf(this,e).set(e,t),this}Tl.prototype.clear=q8;Tl.prototype.delete=Z8;Tl.prototype.get=Q8;Tl.prototype.has=J8;Tl.prototype.set=eB;function kp(e){var t=-1,n=e?e.length:0;for(this.__data__=new Tl;++t<n;)this.add(e[t])}function tB(e){return this.__data__.set(e,$x),this}function nB(e){return this.__data__.has(e)}kp.prototype.add=kp.prototype.push=tB;kp.prototype.has=nB;function Ff(e,t){for(var n=e.length;n--;)if(uB(e[n][0],t))return n;return-1}function rB(e){if(!Bk(e)||aB(e))return!1;var t=dB(e)||O8(e)?$8:C8;return t.test(lB(e))}function oB(e,t,n){var r=-1,o=k8,s=e.length,i=!0,a=[],l=a;if(s>=v8){var c=sB(e);if(c)return Nk(c);i=!1,o=A8,l=new kp}else l=a;e:for(;++r<s;){var u=e[r],h=u;if(u=u!==0?u:0,i&&h===h){for(var p=l.length;p--;)if(l[p]===h)continue e;a.push(u)}else o(l,h,n)||(l!==a&&l.push(h),a.push(u))}return a}var sB=bm&&1/Nk(new bm([,-0]))[1]==x8?function(e){return new bm(e)}:hB;function zf(e,t){var n=e.__data__;return iB(t)?n[typeof t=="string"?"string":"hash"]:n.map}function zx(e,t){var n=j8(e,t);return rB(n)?n:void 0}function iB(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function aB(e){return!!Bb&&Bb in e}function lB(e){if(e!=null){try{return zk.call(e)}catch{}try{return e+""}catch{}}return""}function cB(e){return e&&e.length?oB(e):[]}function uB(e,t){return e===t||e!==e&&t!==t}function dB(e){var t=Bk(e)?L8.call(e):"";return t==w8||t==b8}function Bk(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function hB(){}var pB=cB;const fB=ni(pB),yc={Good:"#40C057",Mid:"#FFC078",Poor:"#E03131"},gB=yc.Good;class Uk{constructor(){g(this,"startTime",0);g(this,"name","");g(this,"frames",0);g(this,"started",!1);g(this,"frame",null);g(this,"recordFrame",()=>{this.frames++,this.started&&(this.frame=requestAnimationFrame(this.recordFrame))})}start(t){this.name=t,this.frames=0,this.started=!0,this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(this.recordFrame),this.startTime=performance.now()}stop(){this.started=!1,this.frame!==null&&cancelAnimationFrame(this.frame);const t=(performance.now()-this.startTime)/1e3,n=t===0?0:Math.floor(this.frames/t),r=n>55?yc.Good:n>30?yc.Mid:yc.Poor,o=r===yc.Mid?"black":"white",s=this.name[0].toUpperCase()+this.name.slice(1);console.debug(`%cPerf%c ${s} %c${n}%c fps`,`color: white; background: ${gB};padding: 2px;border-radius: 3px;`,"font-weight: normal",`font-weight: bold; padding: 2px; background: ${r};color: ${o};`,"font-weight: normal")}isStarted(){return this.started}}function Bx(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 ye(e){return e.filter(t=>t!=null)}function Ut(e){return e[e.length-1]}function mB(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 yB(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}class Qo{constructor(){g(this,"items",new WeakMap)}get(t,n){return this.items.has(t)||this.items.set(t,n(t)),this.items.get(t)}}function Hk(e){const t=(...n)=>{try{return e(...n)}catch(r){throw r instanceof Error&&Error.captureStackTrace&&Error.captureStackTrace(r,t),r}};return t}const nu=()=>{},yn={ok(e){return{ok:!0,value:e}},err(e){return{ok:!1,error:e}}};function un(e,t){const n=t&&e&&typeof e=="object"&&t in e?e[t]:e;throw new Error(`Unknown switch case ${n}`)}const Xe=Hk((e,t)=>{if(!e)throw new Error(t||"Assertion Error")}),xr=Hk((e,t)=>{if(e==null)throw new Error(t??"value must be defined");return e});function Kk(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 Ub=new WeakMap;function Ux(e,t){if(typeof e!="object"||e===null)return;let n=Ub.get(e);n||(n={tags:{},extras:{}},Ub.set(e,n)),t.tags&&(n.tags={...n.tags,...t.tags}),t.extras&&(n.extras={...n.extras,...t.extras})}async function bo(e,t){return window.fetch(e,{referrerPolicy:"strict-origin-when-cross-origin",...t})}const sl=(e,t)=>{const n=new window.Image(e,t);return n.referrerPolicy="strict-origin-when-cross-origin",n};class Ai{static async dataUrlToArrayBuffer(t){return bo(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 xS(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t+""}function SB(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+""}/*!
|
|
33
|
+
* MIT License: https://github.com/vHeemstra/is-apng/blob/main/license
|
|
34
|
+
* Copyright (c) Philip van Heemstra
|
|
35
|
+
*/function vB(e){const t=new Uint8Array(e);if(!t||!(typeof Buffer<"u"&&Buffer.isBuffer(t)||t instanceof Uint8Array)||t.length<16||!(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71&&t[4]===13&&t[5]===10&&t[6]===26&&t[7]===10))return!1;function r(s,i,a,l,c=1024){if(!i)return-1;i=new RegExp(i,"g");const u=i.source.length,h=new TextDecoder,p=s.length;if(typeof l>"u"&&(l=p),a>=p||l<=0||a>=l)return-1;s=s.subarray(a,l);let f=-1,S=0,y=0,x="";e:for(;S<s.length;){const m=S+c,v=s.subarray(S,m),w=h.decode(v,{stream:!0}),C=x+w;let E,_=-1;for(;(E=i.exec(C))!==null;){_=E.index-x.length,f=y+_;break e}S=m,y+=w.length;const I=_>-1?_+u:w.length-u;x=w.slice(I)}return f>=0&&(f+=a>=0?a:p+a),f}const o=r(t,"IDAT",12);return o>=12?r(t,"acTL",8,o)>=8:!1}const xB=e=>new Uint8Array(e)[3]===44;/*!
|
|
36
|
+
* MIT License
|
|
37
|
+
* Modified code originally from <https://github.com/qzb/is-animated>
|
|
38
|
+
* Copyright (c) 2016 Józef Sokołowski <j.k.sokolowski@gmail.com>
|
|
39
|
+
*/function Hb(e,t){let n=0;for(;e[t+n];)n+=e[t+n]+1;return n+1}function wB(e){return new TextDecoder("ascii").decode(e.slice(0,3))==="GIF"}function bB(e){const t=new Uint8Array(e);let n,r,o=0,s=0;if(!wB(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+=Hb(t,o+1)+1;break;case 33:o+=2,o+=Hb(t,o);break;case 59:o=t.length;break;default:o=t.length;break}return s>1}let wS=[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"&&(wS=new Int32Array(wS));/*!
|
|
40
|
+
* MIT License: https://github.com/alexgorbatchev/crc/blob/master/LICENSE
|
|
41
|
+
* Copyright: 2014 Alex Gorbatchev
|
|
42
|
+
* Code: crc32, https://github.com/alexgorbatchev/crc/blob/master/src/calculators/crc32.ts
|
|
43
|
+
*/const PB=(e,t)=>{let n=~~t^-1;for(let r=0;r<e.length;r++)n=wS[(n^e[r])&255]^n>>>8;return n^-1},Kb=4,Wb=4;class lo{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(!lo.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=lo.getChunkType(t,n);if(i==="IDAT"&&r[i]){n+=s+Kb+Wb;continue}if(i==="IEND")break;r[i]={start:o,dataOffset:n+4,size:s},n+=s+Kb+Wb}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 lo.readChunks(t)[n]}static setPhysChunk(t,n=1,r){let o=46,s=0;const i=lo.findChunk(t,"pHYs");i&&(o=i.start,s=i.size);const a=lo.findChunk(t,"IDAT");a&&(o=a.start,s=0);const l=new ArrayBuffer(21),c=new DataView(l);c.setUint32(0,9),c.setUint8(4,112),c.setUint8(5,72),c.setUint8(6,89),c.setUint8(7,115);const u=2835.5;c.setInt32(8,u*n),c.setInt32(12,u*n),c.setInt8(16,1);const h=new Uint8Array(l.slice(4,17));c.setInt32(17,PB(h));const p=t.buffer.slice(0,o),f=t.buffer.slice(o+s);return new Blob([p,l,f],r)}}/*!
|
|
44
|
+
* MIT License: https://github.com/sindresorhus/is-webp/blob/main/license
|
|
45
|
+
* Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
46
|
+
*/function CB(e){return!e||e.length<12?!1:e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80}function IB(e){const t=new Uint8Array(e);return!CB(t)||!t||t.length<21?!1:(t[20]>>1&1)===1}const Wk=Object.freeze(["image/svg+xml"]),Gk=Object.freeze(["image/jpeg","image/png","image/webp"]),Vk=Object.freeze(["image/gif","image/apng","image/avif"]),Hx=Object.freeze([...Gk,...Wk,...Vk]),Yk=Object.freeze(["video/mp4","video/webm","video/quicktime"]),EB=[...Hx,...Yk].join(",");class ho{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=sl();o.onload=()=>n(o),o.onerror=s=>{console.error(s),r(new Error("Could not load image"))},o.crossOrigin="anonymous",o.referrerPolicy="strict-origin-when-cross-origin",o.src=t})}static async getVideoSize(t){return ho.usingObjectURL(t,async n=>{const r=await ho.loadVideo(n);return{w:r.videoWidth,h:r.videoHeight}})}static async getImageSize(t){const n=await ho.usingObjectURL(t,ho.loadImage);try{if(t.type==="image/png"){const r=new DataView(await t.arrayBuffer());if(lo.isPng(r,0)){const o=lo.findChunk(r,"pHYs");if(o){const s=lo.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 isAnimated(t){return t.type==="image/gif"?bB(await t.arrayBuffer()):t.type==="image/avif"?xB(await t.arrayBuffer()):t.type==="image/webp"?IB(await t.arrayBuffer()):t.type==="image/apng"?vB(await t.arrayBuffer()):!1}static isAnimatedImageType(t){return Vk.includes(t||"")}static isStaticImageType(t){return Gk.includes(t||"")}static isVectorImageType(t){return Wk.includes(t||"")}static isImageType(t){return Hx.includes(t)}static async usingObjectURL(t,n){const r=URL.createObjectURL(t);try{return await n(r)}finally{URL.revokeObjectURL(r)}}}function Dn(e,t,n){return e+(t-e)*n}function qr(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 il(e,t,n,r=!1){const[o,s]=t,[i,a]=n,l=i+(e-o)/(s-o)*(a-i);return r?i<a?Math.max(Math.min(l,a),i):Math.max(Math.min(l,i),a):l}function yo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Nn(e,t){if(yo(e,t))return e[t]}function Gb(e){return Object.keys(e)}function gt(e){return Object.values(e)}function Un(e){return Object.entries(e)}function Xk(e){return Object.fromEntries(e)}function $c(e,t){const n={};let r=!1;for(const[o,s]of Un(e))t(o,s)?n[o]=s:r=!0;return r?n:e}function Bu(e,t){const n={};for(const[r,o]of Un(e)){const s=t(r,o);n[r]=s}return n}function qk(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 tr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Zk="a0",Qk="A00000000000000000000000000";function Jk(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 e_(e){if(e.length!==Jk(e.charAt(0)))throw new Error("invalid integer part of index key: "+e)}function Vb(e){if(e===void 0)throw Error("n is undefined")}function Yb(e){e_(e);const[t,...n]=e.split("");let r=!0;for(let o=n.length-1;r&&o>=0;o--){const s=tr.indexOf(n[o])+1;s===tr.length?n[o]="0":(n[o]=tr.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 kB(e){e_(e);const[t,...n]=e.split("");let r=!0;for(let o=n.length-1;r&&o>=0;o--){const s=tr.indexOf(n[o])-1;s===-1?n[o]=tr.slice(-1):(n[o]=tr.charAt(s),r=!1)}if(r){if(t==="a")return"Z"+tr.slice(-1);if(t==="A")return;const o=String.fromCharCode(t.charCodeAt(0)-1);return o<"Z"?n.push(tr.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?tr.indexOf(e.charAt(0)):0,r=t!==void 0?tr.indexOf(t.charAt(0)):tr.length;if(r-n>1){const o=Math.round(.5*(n+r));return tr.charAt(o)}else return t&&t.length>1?t.slice(0,1):tr.charAt(n)+ka(e.slice(1),void 0)}function Sc(e){const t=Jk(e.charAt(0));if(t>e.length)throw new Error("invalid index: "+e);return e.slice(0,t)}function bS(e){if(e===Qk)throw new Error("invalid index: "+e);const t=Sc(e);if(e.slice(t.length).slice(-1)==="0")throw new Error("invalid index: "+e)}function ha(e,t){if(e!==void 0&&bS(e),t!==void 0&&bS(t),e!==void 0&&t!==void 0&&e>=t)throw new Error(e+" >= "+t);if(e===void 0&&t===void 0)return Zk;if(e===void 0){if(t===void 0)throw Error("b is undefined");const a=Sc(t),l=t.slice(a.length);if(a===Qk)return a+ka("",l);if(a<t)return a;const c=kB(a);return Vb(c),c}if(t===void 0){const a=Sc(e),l=e.slice(a.length),c=Yb(a);return c===void 0?a+ka(l,void 0):c}const n=Sc(e),r=e.slice(n.length),o=Sc(t),s=t.slice(o.length);if(n===o)return n+ka(r,s);const i=Yb(n);return Vb(i),i<t?i:n+ka(r,void 0)}function Vs(e,t,n){if(n===0)return[];if(n===1)return[ha(e,t)];if(t===void 0){let s=ha(e,t);const i=[s];for(let a=0;a<n-1;a++)s=ha(s,t),i.push(s);return i}if(e===void 0){let s=ha(e,t);const i=[s];for(let a=0;a<n-1;a++)s=ha(e,s),i.push(s);return i.reverse(),i}const r=Math.floor(n/2),o=ha(e,t);return[...Vs(e,o,r),o,...Vs(o,t,n-r-1)]}const t_=Zk;function _B(e){bS(e)}function al(e,t,n){return Vs(e,t,n)}function Pm(e,t){return Vs(e,void 0,t)}function ru(e,t){return Vs(e,t,1)[0]}function zr(e){return Vs(e,void 0,1)[0]}function TB(e){return Vs(void 0,e,1)[0]}function ou(e,t="a1"){return[t,...Vs(t,void 0,e)]}function ln(e,t){return e.index<t.index?-1:e.index>t.index?1:0}function MB(e,t){return e.id>t.id?1:-1}function Kx(e){try{return localStorage.getItem(e)}catch{return null}}function Wx(e,t){try{localStorage.setItem(e,t)}catch{}}function AB(){try{localStorage.clear()}catch{}}function n_(e){try{return sessionStorage.getItem(e)}catch{return null}}function Gx(e,t){try{sessionStorage.setItem(e,t)}catch{}}function r_(e){try{sessionStorage.removeItem(e)}catch{}}function jB(){try{sessionStorage.clear()}catch{}}const OB=()=>typeof process<"u"&&!1,_a=[],DB=60,_h=Math.ceil(1e3/DB);let Gl,Cm=0,PS=0;const RB=()=>{const e=_a.splice(0,_a.length);for(const t of e)t()};function o_(){if(Gl)return;const e=Date.now(),t=e-PS;if(Cm+t<_h){Gl=requestAnimationFrame(()=>{Gl=void 0,o_()});return}Gl=requestAnimationFrame(()=>{Gl=void 0,PS=e,Cm=Math.min(Cm+t-_h,_h*10),RB()})}let Xb=!1;function s_(e){return OB()?(e(),()=>{}):(_a.includes(e)||(_a.push(e),Xb||(Xb=!0,PS=Date.now()-_h-1),o_()),()=>{const t=_a.indexOf(e);t>-1&&_a.splice(t,1)})}class LB{constructor(){g(this,"timeouts",[]);g(this,"intervals",[]);g(this,"rafs",[])}setTimeout(t,n,...r){const o=window.setTimeout(t,n,r);return this.timeouts.push(o),o}setInterval(t,n,...r){const o=window.setInterval(t,n,r);return this.intervals.push(o),o}requestAnimationFrame(t){const n=window.requestAnimationFrame(t);return this.rafs.push(n),n}dispose(){this.timeouts.forEach(t=>clearTimeout(t)),this.intervals.forEach(t=>clearInterval(t)),this.rafs.forEach(t=>cancelAnimationFrame(t)),this.timeouts.length=0,this.intervals.length=0,this.rafs.length=0}}function $B(e){return e!==null}function NB(){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 i_=NB(),Ge=i_[0];i_[1];const FB=Object.getPrototypeOf(Ge({}));var Im={};const Vx={enableLicensing:zB("enableLicensing",{defaults:{all:!0,production:!1}})},a_=Mn("pointerCaptureTrackingObject",{defaults:{all:new Map},shouldStoreForSession:!1}),xt={logPreventDefaults:Mn("logPreventDefaults",{defaults:{all:!1}}),logPointerCaptures:Mn("logPointerCaptures",{defaults:{all:!1}}),logElementRemoves:Mn("logElementRemoves",{defaults:{all:!1}}),debugSvg:Mn("debugSvg",{defaults:{all:!1}}),showFps:Mn("showFps",{defaults:{all:!1}}),measurePerformance:Mn("measurePerformance",{defaults:{all:!1}}),throwToBlob:Mn("throwToBlob",{defaults:{all:!1}}),reconnectOnPing:Mn("reconnectOnPing",{defaults:{all:!1}}),debugCursors:Mn("debugCursors",{defaults:{all:!1}}),forceSrgb:Mn("forceSrgbColors",{defaults:{all:!1}}),debugGeometry:Mn("debugGeometry",{defaults:{all:!1}}),hideShapes:Mn("hideShapes",{defaults:{all:!1}}),editOnType:Mn("editOnType",{defaults:{all:!1}})};if(typeof Element<"u"){const e=Element.prototype.removeChild;ra("element removal logging",()=>{xt.logElementRemoves.get()?Element.prototype.removeChild=function(t){return console.warn("[tldraw] removing child:",t),e.call(this,t)}:Element.prototype.removeChild=e})}function Mn(e,{defaults:t,shouldStoreForSession:n=!0}){return l_({name:e,defaults:t,shouldStoreForSession:n})}function zB(e,{defaults:t,shouldStoreForSession:n=!0}){return l_({name:e,defaults:t,shouldStoreForSession:n})}function l_(e){const t=UB(e),n=e.shouldStoreForSession?BB(e.name):null,r=Mt(`debug:${e.name}`,n??t);return typeof window<"u"&&(e.shouldStoreForSession&&ra(`debug:${e.name}`,()=>{const o=r.get();o===t?r_(`tldraw_debug:${e.name}`):Gx(`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 BB(e){try{return JSON.parse(n_(`tldraw_debug:${e}`)??"null")}catch{return null}}function Em(e){try{return e()}catch{return null}}function UB(e){switch(Em(()=>Im.TLDRAW_ENV)??Em(()=>Im.VERCEL_PUBLIC_TLDRAW_ENV)??Em(()=>Im.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}}class Th{constructor(t){g(this,"nextValue");g(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)}}let Uu=(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 Bf{constructor(t,n){g(this,"createDefaultProperties");g(this,"validator");g(this,"ephemeralKeys");g(this,"ephemeralKeySet");g(this,"scope");g(this,"isInstance",t=>(t==null?void 0:t.typeName)===this.typeName);this.typeName=t,this.createDefaultProperties=n.createDefaultProperties,this.validator=n.validator??{validate:o=>o},this.scope=n.scope??"document",this.ephemeralKeys=n.ephemeralKeys;const r=new Set;if(n.ephemeralKeys)for(const[o,s]of Un(n.ephemeralKeys))s&&r.add(o);this.ephemeralKeySet=r}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{...Ge(t),id:this.createId()}}createId(t){return this.typeName+":"+(t??Uu())}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 Bf(this.typeName,{createDefaultProperties:t,validator:this.validator,scope:this.scope,ephemeralKeys:this.ephemeralKeys})}validate(t,n){return n&&this.validator.validateUsingKnownGoodVersion?this.validator.validateUsingKnownGoodVersion(n,t):this.validator.validate(t)}}function To(e,t){return new Bf(e,{createDefaultProperties:()=>({}),validator:t.validator,scope:t.scope,ephemeralKeys:t.ephemeralKeys})}function _p(){return{added:{},updated:{},removed:{}}}function CS(e){const t={added:e.removed,removed:e.added,updated:{}};for(const[n,r]of Object.values(e.updated))t.updated[n.id]=[r,n];return t}function c_(e){return Object.keys(e.added).length===0&&Object.keys(e.updated).length===0&&Object.keys(e.removed).length===0}function Yx(e){const t={added:{},removed:{},updated:{}};return Nc(t,e),t}function Nc(e,t){for(const n of t){for(const[r,o]of Un(n.added))if(e.removed[r]){const s=e.removed[r];delete e.removed[r],s!==o&&(e.updated[r]=[s,o])}else e.added[r]=o;for(const[r,[o,s]]of Un(n.updated)){if(e.added[r]){e.added[r]=s,delete e.updated[r],delete e.removed[r];continue}if(e.updated[r]){e.updated[r]=[e.updated[r][0],s],delete e.removed[r];continue}e.updated[r]=n.updated[r],delete e.removed[r]}for(const[r,o]of Un(n.removed))e.added[r]?delete e.added[r]:e.updated[r]?(e.removed[r]=e.updated[r][0],delete e.updated[r]):e.removed[r]=o}}var Tp={exports:{}};Tp.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=1,s=2,i=9007199254740991,a="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",h="[object Date]",p="[object Error]",f="[object Function]",S="[object GeneratorFunction]",y="[object Map]",x="[object Number]",m="[object Null]",v="[object Object]",w="[object Promise]",C="[object Proxy]",E="[object RegExp]",_="[object Set]",I="[object String]",k="[object Symbol]",T="[object Undefined]",M="[object WeakMap]",D="[object ArrayBuffer]",$="[object DataView]",j="[object Float32Array]",O="[object Float64Array]",R="[object Int8Array]",H="[object Int16Array]",B="[object Int32Array]",z="[object Uint8Array]",W="[object Uint8ClampedArray]",Y="[object Uint16Array]",q="[object Uint32Array]",le=/[\\^$.*+?()[\]{}|]/g,ge=/^\[object .+?Constructor\]$/,be=/^(?:0|[1-9]\d*)$/,J={};J[j]=J[O]=J[R]=J[H]=J[B]=J[z]=J[W]=J[Y]=J[q]=!0,J[a]=J[l]=J[D]=J[u]=J[$]=J[h]=J[p]=J[f]=J[y]=J[x]=J[v]=J[E]=J[_]=J[I]=J[M]=!1;var Ue=typeof cn=="object"&&cn&&cn.Object===Object&&cn,Oe=typeof self=="object"&&self&&self.Object===Object&&self,nt=Ue||Oe||Function("return this")(),je=t&&!t.nodeType&&t,it=je&&!0&&e&&!e.nodeType&&e,Fe=it&&it.exports===je,Xn=Fe&&Ue.process,Nt=function(){try{return Xn&&Xn.binding&&Xn.binding("util")}catch{}}(),Tn=Nt&&Nt.isTypedArray;function St(A,L){for(var V=-1,ee=A==null?0:A.length,Ze=0,me=[];++V<ee;){var ft=A[V];L(ft,V,A)&&(me[Ze++]=ft)}return me}function Qt(A,L){for(var V=-1,ee=L.length,Ze=A.length;++V<ee;)A[Ze+V]=L[V];return A}function jo(A,L){for(var V=-1,ee=A==null?0:A.length;++V<ee;)if(L(A[V],V,A))return!0;return!1}function Nl(A,L){for(var V=-1,ee=Array(A);++V<A;)ee[V]=L(V);return ee}function ms(A){return function(L){return A(L)}}function mL(A,L){return A.has(L)}function yL(A,L){return A==null?void 0:A[L]}function SL(A){var L=-1,V=Array(A.size);return A.forEach(function(ee,Ze){V[++L]=[Ze,ee]}),V}function vL(A,L){return function(V){return A(L(V))}}function xL(A){var L=-1,V=Array(A.size);return A.forEach(function(ee){V[++L]=ee}),V}var wL=Array.prototype,bL=Function.prototype,dd=Object.prototype,Kg=nt["__core-js_shared__"],b1=bL.toString,to=dd.hasOwnProperty,P1=function(){var A=/[^.]+$/.exec(Kg&&Kg.keys&&Kg.keys.IE_PROTO||"");return A?"Symbol(src)_1."+A:""}(),C1=dd.toString,PL=RegExp("^"+b1.call(to).replace(le,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),I1=Fe?nt.Buffer:void 0,hd=nt.Symbol,E1=nt.Uint8Array,k1=dd.propertyIsEnumerable,CL=wL.splice,gi=hd?hd.toStringTag:void 0,_1=Object.getOwnPropertySymbols,IL=I1?I1.isBuffer:void 0,EL=vL(Object.keys,Object),Wg=ca(nt,"DataView"),Fl=ca(nt,"Map"),Gg=ca(nt,"Promise"),Vg=ca(nt,"Set"),Yg=ca(nt,"WeakMap"),zl=ca(Object,"create"),kL=Si(Wg),_L=Si(Fl),TL=Si(Gg),ML=Si(Vg),AL=Si(Yg),T1=hd?hd.prototype:void 0,Xg=T1?T1.valueOf:void 0;function mi(A){var L=-1,V=A==null?0:A.length;for(this.clear();++L<V;){var ee=A[L];this.set(ee[0],ee[1])}}function jL(){this.__data__=zl?zl(null):{},this.size=0}function OL(A){var L=this.has(A)&&delete this.__data__[A];return this.size-=L?1:0,L}function DL(A){var L=this.__data__;if(zl){var V=L[A];return V===r?void 0:V}return to.call(L,A)?L[A]:void 0}function RL(A){var L=this.__data__;return zl?L[A]!==void 0:to.call(L,A)}function LL(A,L){var V=this.__data__;return this.size+=this.has(A)?0:1,V[A]=zl&&L===void 0?r:L,this}mi.prototype.clear=jL,mi.prototype.delete=OL,mi.prototype.get=DL,mi.prototype.has=RL,mi.prototype.set=LL;function Oo(A){var L=-1,V=A==null?0:A.length;for(this.clear();++L<V;){var ee=A[L];this.set(ee[0],ee[1])}}function $L(){this.__data__=[],this.size=0}function NL(A){var L=this.__data__,V=fd(L,A);if(V<0)return!1;var ee=L.length-1;return V==ee?L.pop():CL.call(L,V,1),--this.size,!0}function FL(A){var L=this.__data__,V=fd(L,A);return V<0?void 0:L[V][1]}function zL(A){return fd(this.__data__,A)>-1}function BL(A,L){var V=this.__data__,ee=fd(V,A);return ee<0?(++this.size,V.push([A,L])):V[ee][1]=L,this}Oo.prototype.clear=$L,Oo.prototype.delete=NL,Oo.prototype.get=FL,Oo.prototype.has=zL,Oo.prototype.set=BL;function yi(A){var L=-1,V=A==null?0:A.length;for(this.clear();++L<V;){var ee=A[L];this.set(ee[0],ee[1])}}function UL(){this.size=0,this.__data__={hash:new mi,map:new(Fl||Oo),string:new mi}}function HL(A){var L=gd(this,A).delete(A);return this.size-=L?1:0,L}function KL(A){return gd(this,A).get(A)}function WL(A){return gd(this,A).has(A)}function GL(A,L){var V=gd(this,A),ee=V.size;return V.set(A,L),this.size+=V.size==ee?0:1,this}yi.prototype.clear=UL,yi.prototype.delete=HL,yi.prototype.get=KL,yi.prototype.has=WL,yi.prototype.set=GL;function pd(A){var L=-1,V=A==null?0:A.length;for(this.__data__=new yi;++L<V;)this.add(A[L])}function VL(A){return this.__data__.set(A,r),this}function YL(A){return this.__data__.has(A)}pd.prototype.add=pd.prototype.push=VL,pd.prototype.has=YL;function ys(A){var L=this.__data__=new Oo(A);this.size=L.size}function XL(){this.__data__=new Oo,this.size=0}function qL(A){var L=this.__data__,V=L.delete(A);return this.size=L.size,V}function ZL(A){return this.__data__.get(A)}function QL(A){return this.__data__.has(A)}function JL(A,L){var V=this.__data__;if(V instanceof Oo){var ee=V.__data__;if(!Fl||ee.length<n-1)return ee.push([A,L]),this.size=++V.size,this;V=this.__data__=new yi(ee)}return V.set(A,L),this.size=V.size,this}ys.prototype.clear=XL,ys.prototype.delete=qL,ys.prototype.get=ZL,ys.prototype.has=QL,ys.prototype.set=JL;function e3(A,L){var V=md(A),ee=!V&&g3(A),Ze=!V&&!ee&&qg(A),me=!V&&!ee&&!Ze&&N1(A),ft=V||ee||Ze||me,kt=ft?Nl(A.length,String):[],Ft=kt.length;for(var at in A)to.call(A,at)&&!(ft&&(at=="length"||Ze&&(at=="offset"||at=="parent")||me&&(at=="buffer"||at=="byteLength"||at=="byteOffset")||u3(at,Ft)))&&kt.push(at);return kt}function fd(A,L){for(var V=A.length;V--;)if(D1(A[V][0],L))return V;return-1}function t3(A,L,V){var ee=L(A);return md(A)?ee:Qt(ee,V(A))}function Bl(A){return A==null?A===void 0?T:m:gi&&gi in Object(A)?l3(A):f3(A)}function M1(A){return Ul(A)&&Bl(A)==a}function A1(A,L,V,ee,Ze){return A===L?!0:A==null||L==null||!Ul(A)&&!Ul(L)?A!==A&&L!==L:n3(A,L,V,ee,A1,Ze)}function n3(A,L,V,ee,Ze,me){var ft=md(A),kt=md(L),Ft=ft?l:Ss(A),at=kt?l:Ss(L);Ft=Ft==a?v:Ft,at=at==a?v:at;var qn=Ft==v,Or=at==v,Jt=Ft==at;if(Jt&&qg(A)){if(!qg(L))return!1;ft=!0,qn=!1}if(Jt&&!qn)return me||(me=new ys),ft||N1(A)?j1(A,L,V,ee,Ze,me):i3(A,L,Ft,V,ee,Ze,me);if(!(V&o)){var gr=qn&&to.call(A,"__wrapped__"),mr=Or&&to.call(L,"__wrapped__");if(gr||mr){var vs=gr?A.value():A,Do=mr?L.value():L;return me||(me=new ys),Ze(vs,Do,V,ee,me)}}return Jt?(me||(me=new ys),a3(A,L,V,ee,Ze,me)):!1}function r3(A){if(!$1(A)||h3(A))return!1;var L=R1(A)?PL:ge;return L.test(Si(A))}function o3(A){return Ul(A)&&L1(A.length)&&!!J[Bl(A)]}function s3(A){if(!p3(A))return EL(A);var L=[];for(var V in Object(A))to.call(A,V)&&V!="constructor"&&L.push(V);return L}function j1(A,L,V,ee,Ze,me){var ft=V&o,kt=A.length,Ft=L.length;if(kt!=Ft&&!(ft&&Ft>kt))return!1;var at=me.get(A);if(at&&me.get(L))return at==L;var qn=-1,Or=!0,Jt=V&s?new pd:void 0;for(me.set(A,L),me.set(L,A);++qn<kt;){var gr=A[qn],mr=L[qn];if(ee)var vs=ft?ee(mr,gr,qn,L,A,me):ee(gr,mr,qn,A,L,me);if(vs!==void 0){if(vs)continue;Or=!1;break}if(Jt){if(!jo(L,function(Do,vi){if(!mL(Jt,vi)&&(gr===Do||Ze(gr,Do,V,ee,me)))return Jt.push(vi)})){Or=!1;break}}else if(!(gr===mr||Ze(gr,mr,V,ee,me))){Or=!1;break}}return me.delete(A),me.delete(L),Or}function i3(A,L,V,ee,Ze,me,ft){switch(V){case $:if(A.byteLength!=L.byteLength||A.byteOffset!=L.byteOffset)return!1;A=A.buffer,L=L.buffer;case D:return!(A.byteLength!=L.byteLength||!me(new E1(A),new E1(L)));case u:case h:case x:return D1(+A,+L);case p:return A.name==L.name&&A.message==L.message;case E:case I:return A==L+"";case y:var kt=SL;case _:var Ft=ee&o;if(kt||(kt=xL),A.size!=L.size&&!Ft)return!1;var at=ft.get(A);if(at)return at==L;ee|=s,ft.set(A,L);var qn=j1(kt(A),kt(L),ee,Ze,me,ft);return ft.delete(A),qn;case k:if(Xg)return Xg.call(A)==Xg.call(L)}return!1}function a3(A,L,V,ee,Ze,me){var ft=V&o,kt=O1(A),Ft=kt.length,at=O1(L),qn=at.length;if(Ft!=qn&&!ft)return!1;for(var Or=Ft;Or--;){var Jt=kt[Or];if(!(ft?Jt in L:to.call(L,Jt)))return!1}var gr=me.get(A);if(gr&&me.get(L))return gr==L;var mr=!0;me.set(A,L),me.set(L,A);for(var vs=ft;++Or<Ft;){Jt=kt[Or];var Do=A[Jt],vi=L[Jt];if(ee)var F1=ft?ee(vi,Do,Jt,L,A,me):ee(Do,vi,Jt,A,L,me);if(!(F1===void 0?Do===vi||Ze(Do,vi,V,ee,me):F1)){mr=!1;break}vs||(vs=Jt=="constructor")}if(mr&&!vs){var yd=A.constructor,Sd=L.constructor;yd!=Sd&&"constructor"in A&&"constructor"in L&&!(typeof yd=="function"&&yd instanceof yd&&typeof Sd=="function"&&Sd instanceof Sd)&&(mr=!1)}return me.delete(A),me.delete(L),mr}function O1(A){return t3(A,S3,c3)}function gd(A,L){var V=A.__data__;return d3(L)?V[typeof L=="string"?"string":"hash"]:V.map}function ca(A,L){var V=yL(A,L);return r3(V)?V:void 0}function l3(A){var L=to.call(A,gi),V=A[gi];try{A[gi]=void 0;var ee=!0}catch{}var Ze=C1.call(A);return ee&&(L?A[gi]=V:delete A[gi]),Ze}var c3=_1?function(A){return A==null?[]:(A=Object(A),St(_1(A),function(L){return k1.call(A,L)}))}:v3,Ss=Bl;(Wg&&Ss(new Wg(new ArrayBuffer(1)))!=$||Fl&&Ss(new Fl)!=y||Gg&&Ss(Gg.resolve())!=w||Vg&&Ss(new Vg)!=_||Yg&&Ss(new Yg)!=M)&&(Ss=function(A){var L=Bl(A),V=L==v?A.constructor:void 0,ee=V?Si(V):"";if(ee)switch(ee){case kL:return $;case _L:return y;case TL:return w;case ML:return _;case AL:return M}return L});function u3(A,L){return L=L??i,!!L&&(typeof A=="number"||be.test(A))&&A>-1&&A%1==0&&A<L}function d3(A){var L=typeof A;return L=="string"||L=="number"||L=="symbol"||L=="boolean"?A!=="__proto__":A===null}function h3(A){return!!P1&&P1 in A}function p3(A){var L=A&&A.constructor,V=typeof L=="function"&&L.prototype||dd;return A===V}function f3(A){return C1.call(A)}function Si(A){if(A!=null){try{return b1.call(A)}catch{}try{return A+""}catch{}}return""}function D1(A,L){return A===L||A!==A&&L!==L}var g3=M1(function(){return arguments}())?M1:function(A){return Ul(A)&&to.call(A,"callee")&&!k1.call(A,"callee")},md=Array.isArray;function m3(A){return A!=null&&L1(A.length)&&!R1(A)}var qg=IL||x3;function y3(A,L){return A1(A,L)}function R1(A){if(!$1(A))return!1;var L=Bl(A);return L==f||L==S||L==c||L==C}function L1(A){return typeof A=="number"&&A>-1&&A%1==0&&A<=i}function $1(A){var L=typeof A;return A!=null&&(L=="object"||L=="function")}function Ul(A){return A!=null&&typeof A=="object"}var N1=Tn?ms(Tn):o3;function S3(A){return m3(A)?e3(A):s3(A)}function v3(){return[]}function x3(){return!1}e.exports=y3})(Tp,Tp.exports);var HB=Tp.exports;const KB=ni(HB);function WB(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 GB(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 qb(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 Zb(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 l of a)r[o].add(l)}else if("neq"in s){const i=e.index(t,o);for(const[a,l]of i.get())if(a!==s.neq)for(const c of l)r[o].add(c)}else if("gt"in s){const i=e.index(t,o);for(const[a,l]of i.get())if(a>s.gt)for(const c of l)r[o].add(c)}return WB(Object.values(r))}class VB{constructor(t,n){g(this,"indexCache",new Map);g(this,"historyCache",new Map);this.atoms=t,this.history=n}filterHistory(t){if(this.historyCache.has(t))return this.historyCache.get(t);const n=G("filterHistory:"+t,(r,o)=>{if(Mi(r))return this.history.get();const s=this.history.getDiffSince(o);if(s===rr)return this.history.get();const i={added:{},removed:{},updated:{}};let a=0,l=0,c=0;for(const u of s){for(const h of gt(u.added))if(h.typeName===t)if(i.removed[h.id]){const p=i.removed[h.id];delete i.removed[h.id],l--,p!==h&&(i.updated[h.id]=[p,h],c++)}else i.added[h.id]=h,a++;for(const[h,p]of gt(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]=[h,p],c++));for(const h of gt(u.removed))h.typeName===t&&(i.added[h.id]?(delete i.added[h.id],a--):i.updated[h.id]?(i.removed[h.id]=i.updated[h.id][0],delete i.updated[h.id],c--,l++):(i.removed[h.id]=h,l++))}return a||l||c?mc(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 gt(this.atoms.get())){const a=i.get();if(a.typeName===t){const l=a[n];s.has(l)||s.set(l,new Set),s.get(l).add(a.id)}}return s};return G("index:"+t+":"+n,(s,i)=>{if(Mi(s))return o();const a=r.getDiffSince(i);if(a===rr)return o();const l=new Map,c=(f,S)=>{let y=l.get(f);y||(y=new Th(s.get(f)??new Set)),y.add(S),l.set(f,y)},u=(f,S)=>{let y=l.get(f);y||(y=new Th(s.get(f)??new Set)),y.remove(S),l.set(f,y)};for(const f of a){for(const S of gt(f.added))if(S.typeName===t){const y=S[n];c(y,S.id)}for(const[S,y]of gt(f.updated))if(y.typeName===t){const x=S[n],m=y[n];x!==m&&(u(x,y.id),c(m,y.id))}for(const S of gt(f.removed))if(S.typeName===t){const y=S[n];u(y,S.id)}}let h,p;for(const[f,S]of l){const y=S.get();y&&(h||(h=new Map(s)),p||(p=new Map),y.value.size===0?h.delete(f):h.set(f,y.value),p.set(f,y.diff))}return h&&p?mc(h,p):s},{historyLength:100})}record(t,n=()=>({}),r="record:"+t+(n?":"+n.toString():"")){const o=this.ids(t,n,r);return G(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 G(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 l=n();return Object.keys(l).length===0?new Set(gt(this.atoms.get()).flatMap(c=>{const u=c.get();return u.typeName===t?u.id:[]})):Zb(this,t,l)},i=l=>{const c=s(),u=GB(l,c);return u?mc(c,u):l},a=G("ids_query:"+r,n,{isEqual:KB});return G("query:"+r,(l,c)=>{const u=a.get();if(Mi(l))return s();if(c<a.lastChangedEpoch)return i(l);const h=o.getDiffSince(c);if(h===rr)return i(l);const p=new Th(l);for(const S of h){for(const y of gt(S.added))y.typeName===t&&qb(u,y)&&p.add(y.id);for(const[y,x]of gt(S.updated))x.typeName===t&&(qb(u,x)?p.add(x.id):p.remove(x.id));for(const y of gt(S.removed))y.typeName===t&&p.remove(y.id)}const f=p.get();return f?mc(f.value,f.diff):l},{historyLength:50})}exec(t,n){const r=Zb(this,t,n);if(r.size===0)return Vo;const o=this.atoms.get();return[...r].map(s=>o[s].get())}}class YB{constructor(t){g(this,"_beforeCreateHandlers",{});g(this,"_afterCreateHandlers",{});g(this,"_beforeChangeHandlers",{});g(this,"_afterChangeHandlers",{});g(this,"_beforeDeleteHandlers",{});g(this,"_afterDeleteHandlers",{});g(this,"_operationCompleteHandlers",[]);g(this,"_isEnabled",!0);this.store=t}isEnabled(){return this._isEnabled}setIsEnabled(t){this._isEnabled=t}handleBeforeCreate(t,n){if(!this._isEnabled)return t;const r=this._beforeCreateHandlers[t.typeName];if(r){let o=t;for(const s of r)o=s(o,n);return o}return t}handleAfterCreate(t,n){if(!this._isEnabled)return;const r=this._afterCreateHandlers[t.typeName];if(r)for(const o of r)o(t,n)}handleBeforeChange(t,n,r){if(!this._isEnabled)return n;const o=this._beforeChangeHandlers[n.typeName];if(o){let s=n;for(const i of o)s=i(t,s,r);return s}return n}handleAfterChange(t,n,r){if(!this._isEnabled)return;const o=this._afterChangeHandlers[n.typeName];if(o)for(const s of o)s(t,n,r)}handleBeforeDelete(t,n){if(!this._isEnabled)return!0;const r=this._beforeDeleteHandlers[t.typeName];if(r){for(const o of r)if(o(t,n)===!1)return!1}return!0}handleAfterDelete(t,n){if(!this._isEnabled)return;const r=this._afterDeleteHandlers[t.typeName];if(r)for(const o of r)o(t,n)}handleOperationComplete(t){if(this._isEnabled)for(const n of this._operationCompleteHandlers)n(t)}register(t){const n=[];for(const[r,o]of Object.entries(t))o!=null&&o.beforeCreate&&n.push(this.registerBeforeCreateHandler(r,o.beforeCreate)),o!=null&&o.afterCreate&&n.push(this.registerAfterCreateHandler(r,o.afterCreate)),o!=null&&o.beforeChange&&n.push(this.registerBeforeChangeHandler(r,o.beforeChange)),o!=null&&o.afterChange&&n.push(this.registerAfterChangeHandler(r,o.afterChange)),o!=null&&o.beforeDelete&&n.push(this.registerBeforeDeleteHandler(r,o.beforeDelete)),o!=null&&o.afterDelete&&n.push(this.registerAfterDeleteHandler(r,o.afterDelete));return()=>{for(const r of n)r()}}registerBeforeCreateHandler(t,n){return this._beforeCreateHandlers[t]||(this._beforeCreateHandlers[t]=[]),this._beforeCreateHandlers[t].push(n),()=>xi(this._beforeCreateHandlers[t],n)}registerAfterCreateHandler(t,n){return this._afterCreateHandlers[t]||(this._afterCreateHandlers[t]=[]),this._afterCreateHandlers[t].push(n),()=>xi(this._afterCreateHandlers[t],n)}registerBeforeChangeHandler(t,n){return this._beforeChangeHandlers[t]||(this._beforeChangeHandlers[t]=[]),this._beforeChangeHandlers[t].push(n),()=>xi(this._beforeChangeHandlers[t],n)}registerAfterChangeHandler(t,n){return this._afterChangeHandlers[t]||(this._afterChangeHandlers[t]=[]),this._afterChangeHandlers[t].push(n),()=>xi(this._afterChangeHandlers[t],n)}registerBeforeDeleteHandler(t,n){return this._beforeDeleteHandlers[t]||(this._beforeDeleteHandlers[t]=[]),this._beforeDeleteHandlers[t].push(n),()=>xi(this._beforeDeleteHandlers[t],n)}registerAfterDeleteHandler(t,n){return this._afterDeleteHandlers[t]||(this._afterDeleteHandlers[t]=[]),this._afterDeleteHandlers[t].push(n),()=>xi(this._afterDeleteHandlers[t],n)}registerOperationCompleteHandler(t){return this._operationCompleteHandlers.push(t),()=>xi(this._operationCompleteHandlers,t)}}function xi(e,t){const n=e.indexOf(t);n>=0&&e.splice(n,1)}class Xx{constructor(t){g(this,"id");g(this,"atoms",Mt("store_atoms",{}));g(this,"history",Mt("history",0,{historyLength:1e3}));g(this,"query",new VB(this.atoms,this.history));g(this,"listeners",new Set);g(this,"historyAccumulator",new qB);g(this,"historyReactor");g(this,"cancelHistoryReactor",()=>{});g(this,"schema");g(this,"props");g(this,"scopedTypes");g(this,"sideEffects",new YB(this));g(this,"put",(t,n)=>{this.atomic(()=>{const r={},o={},s=this.atoms.__unsafe__getWithoutCapture();let i=null,a,l=!1;const c=this.isMergingRemoteChanges?"remote":"user";for(let u=0,h=t.length;u<h;u++){a=t[u];const p=(i??s)[a.id];if(p){const f=p.__unsafe__getWithoutCapture();if(a=this.sideEffects.handleBeforeChange(f,a,c),this.schema.validateRecord(this,a,n??"updateRecord",f)===f)continue;p.set(a),l=!0;const y=p.__unsafe__getWithoutCapture();r[a.id]=[f,y],this.addDiffForAfterEvent(f,y)}else a=this.sideEffects.handleBeforeCreate(a,c),l=!0,a=this.schema.validateRecord(this,a,n??"createRecord",null),o[a.id]=a,this.addDiffForAfterEvent(null,a),i||(i={...s}),i[a.id]=Mt("atom:"+a.id,a)}i&&this.atoms.set(i),l&&this.updateHistory({added:o,updated:r,removed:{}})})});g(this,"remove",t=>{this.atomic(()=>{const n=new Set,r=this.isMergingRemoteChanges?"remote":"user";if(this.sideEffects.isEnabled())for(const s of t){const i=this.atoms.__unsafe__getWithoutCapture()[s];i&&this.sideEffects.handleBeforeDelete(i.get(),r)===!1&&n.add(s)}let o;this.atoms.update(s=>{let i;for(const a of t){if(n.has(a)||!(a in s))continue;i||(i={...s}),o||(o={}),delete i[a];const l=s[a].get();o[a]=l,this.addDiffForAfterEvent(l,null)}return i??s}),o&&this.updateHistory({added:{},updated:{},removed:o})})});g(this,"get",t=>{var n;return(n=this.atoms.get()[t])==null?void 0:n.get()});g(this,"unsafeGetWithoutCapture",t=>{var n;return(n=this.atoms.get()[t])==null?void 0:n.__unsafe__getWithoutCapture()});g(this,"serialize",(t="document")=>{const n={};for(const[r,o]of Un(this.atoms.get())){const s=o.get();(t==="all"||this.scopedTypes[t].has(s.typeName))&&(n[r]=s)}return n});g(this,"allRecords",()=>gt(this.atoms.get()).map(t=>t.get()));g(this,"clear",()=>{this.remove(Gb(this.atoms.get()))});g(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())])});g(this,"has",t=>!!this.atoms.get()[t]);g(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()}});g(this,"isMergingRemoteChanges",!1);g(this,"mergeRemoteChanges",t=>{if(this.isMergingRemoteChanges)return t();if(this._isInAtomicOp)throw new Error("Cannot merge remote changes while in atomic operation");try{this.isMergingRemoteChanges=!0,mo(t)}finally{this.isMergingRemoteChanges=!1}});g(this,"createComputedCache",(t,n,r)=>{const o=new Qo;return{get:s=>{const i=this.atoms.get()[s];if(i)return o.get(i,()=>{const a=r?G(i.name+":equals",()=>i.get(),{isEqual:r}):i;return G(t+":"+s,()=>n(a.get()))}).get()}}});g(this,"createSelectedComputedCache",(t,n,r)=>{const o=new Qo;return{get:s=>{const i=this.atoms.get()[s];if(i)return o.get(i,()=>{const a=G(t+":"+s+":selector",()=>n(i.get()));return G(t+":"+s,()=>r(a.get()))}).get()}}});g(this,"_integrityChecker");g(this,"_isPossiblyCorrupted",!1);g(this,"pendingAfterEvents",null);g(this,"_isInAtomicOp",!1);const{initialData:n,schema:r,id:o}=t;this.id=o??Uu(),this.schema=r,this.props=t.props,n&&this.atoms.set(Xk(Un(n).map(([s,i])=>[s,Mt("atom:"+s,this.schema.validateRecord(this,i,"initialize",null))]))),this.historyReactor=z6("Store.historyReactor",()=>{this.history.get(),this._flushHistory()},{scheduleEffect:s=>this.cancelHistoryReactor=s_(s)}),this.scopedTypes={document:new Set(gt(this.schema.types).filter(s=>s.scope==="document").map(s=>s.typeName)),session:new Set(gt(this.schema.types).filter(s=>s.scope==="session").map(s=>s.typeName)),presence:new Set(gt(this.schema.types).filter(s=>s.scope==="presence").map(s=>s.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:l}of this.listeners)if(!(l.source!=="all"&&l.source!==r))if(l.scope!=="all")if(l.scope==="document"){if(s??(s=this.filterChangesByScope(n,"document")),!s)continue;a({changes:s,source:r})}else if(l.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})}}}dispose(){this.cancelHistoryReactor()}filterChangesByScope(t,n){const r={added:$c(t.added,(o,s)=>this.scopedTypes[n].has(s.typeName)),updated:$c(t.updated,(o,s)=>this.scopedTypes[n].has(s[1].typeName)),removed:$c(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))}getStoreSnapshot(t="document"){return{store:this.serialize(t),schema:this.schema.serialize()}}getSnapshot(t="document"){return console.warn("[tldraw] `Store.getSnapshot` is deprecated and will be removed in a future release. Use `getSnapshot` from the `tldraw` package instead."),this.getStoreSnapshot(t)}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()}}loadStoreSnapshot(t){const n=this.schema.migrateStoreSnapshot(t);if(n.type==="error")throw new Error(`Failed to migrate snapshot: ${n.reason}`);const r=this.sideEffects.isEnabled();try{this.sideEffects.setIsEnabled(!1),this.atomic(()=>{this.clear(),this.put(Object.values(n.value)),this.ensureStoreIsUsable()})}finally{this.sideEffects.setIsEnabled(r)}}loadSnapshot(t){console.warn("[tldraw] `Store.loadSnapshot` is deprecated and will be removed in a future release. Use `loadSnapshot` from the 'tldraw' package instead."),this.loadStoreSnapshot(t)}extractingChanges(t){const n=[],r=this.historyAccumulator.addInterceptor(o=>n.push(o.changes));try{return mo(t),Yx(n)}finally{r()}}applyDiff(t,{runCallbacks:n=!0,ignoreEphemeralKeys:r=!1}={}){this.atomic(()=>{const o=gt(t.added);for(const[i,a]of gt(t.updated)){const l=this.schema.getType(a.typeName);if(r&&l.ephemeralKeySet.size){const c=this.get(a.id);if(!c){o.push(a);continue}let u=null;for(const[h,p]of Object.entries(a))l.ephemeralKeySet.has(h)||Object.is(p,Nn(c,h))||(u||(u={...c}),u[h]=p);u&&o.push(u)}else o.push(a)}const s=Gb(t.removed);o.length&&this.put(o),s.length&&this.remove(s)},n)}ensureStoreIsUsable(){this.atomic(()=>{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}addDiffForAfterEvent(t,n){if(Xe(this.pendingAfterEvents,"must be in event operation"),t===n||(t&&n&&Xe(t.id===n.id),!t&&!n))return;const r=(t||n).id,o=this.pendingAfterEvents.get(r);o?o.after=n:this.pendingAfterEvents.set(r,{before:t,after:n})}flushAtomicCallbacks(){let t=0;const n=this.isMergingRemoteChanges?"remote":"user";for(;this.pendingAfterEvents;){const r=this.pendingAfterEvents;if(this.pendingAfterEvents=null,!!this.sideEffects.isEnabled()){if(t++,t>100)throw new Error("Maximum store update depth exceeded, bailing out");for(const{before:o,after:s}of r.values())o&&s?this.sideEffects.handleAfterChange(o,s,n):o&&!s?this.sideEffects.handleAfterDelete(o,n):!o&&s&&this.sideEffects.handleAfterCreate(s,n);this.pendingAfterEvents||this.sideEffects.handleOperationComplete(n)}}}atomic(t,n=!0){return mo(()=>{if(this._isInAtomicOp)return this.pendingAfterEvents||(this.pendingAfterEvents=new Map),t();this.pendingAfterEvents=new Map;const r=this.sideEffects.isEnabled();this.sideEffects.setIsEnabled(n??r),this._isInAtomicOp=!0;try{const o=t();return this.flushAtomicCallbacks(),o}finally{this.pendingAfterEvents=null,this.sideEffects.setIsEnabled(r),this._isInAtomicOp=!1}})}addHistoryInterceptor(t){return this.historyAccumulator.addInterceptor(n=>t(n,this.isMergingRemoteChanges?"remote":"user"))}}function XB(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:Yx(o.map(s=>s.changes))}))}class qB{constructor(){g(this,"_history",[]);g(this,"_interceptors",new Set)}addInterceptor(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=XB(this._history);return this._history=[],t}clear(){this._history=[]}hasChanges(){return this._history.length>0}}function ZB(e,t,n){const r=new Qo;return{get(o,s){return r.get(o,()=>(o instanceof Xx?o:o.store).createComputedCache(e,l=>t(o,l),n)).get(s)}}}function QB(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 Va({sequence:e,sequenceId:t,retroactive:n=!0}){const r={sequenceId:t,retroactive:n,sequence:QB(e)};return u_(r),r}function Vn(e,t){return Object.fromEntries(Un(t).map(([n,r])=>[n,`${e}/${r}`]))}function dr(e){const t=e.sequenceId;return Va({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 JB(e){const t=new Map(e.map(s=>[s.id,s])),n=new Set,r=[];function o(s){Xe(!n.has(s.id),`Circular dependency in migrations: ${s.id}`),n.add(s.id);const{version:i,sequenceId:a}=Mp(s.id),l=t.get(`${a}/${i-1}`);if(l&&o(l),s.dependsOn)for(const c of s.dependsOn){const u=t.get(c);u&&o(u)}t.delete(s.id),r.push(s)}for(const s of t.values())o(s);return r}function Mp(e){const[t,n]=e.split("/");return{sequenceId:t,version:parseInt(n)}}function Qb(e,t){t&&Xe(e.startsWith(t+"/"),`Every migration in sequence '${t}' must have an id starting with '${t}/'. Got invalid id: '${e}'`),Xe(e.match(/^(.*?)\/(0|[1-9]\d*)$/),`Invalid migration id: '${e}'`)}function u_(e){if(Xe(!e.sequenceId.includes("/"),`sequenceId cannot contain a '/', got ${e.sequenceId}`),Xe(e.sequenceId.length,"sequenceId must be a non-empty string"),e.sequence.length===0)return;Qb(e.sequence[0].id,e.sequenceId);let t=Mp(e.sequence[0].id).version;Xe(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;Qb(r,e.sequenceId);const o=Mp(r).version;Xe(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 eU(e){if(e.schemaVersion>2||e.schemaVersion<1)return yn.err("Bad schema version");if(e.schemaVersion===2)return yn.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 yn.ok(t)}class qx{constructor(t,n){g(this,"migrations",{});g(this,"sortedMigrations");var o;this.types=t,this.options=n;for(const s of n.migrations??[])Xe(!this.migrations[s.sequenceId],`Duplicate migration sequenceId ${s.sequenceId}`),u_(s),this.migrations[s.sequenceId]=s;const r=Object.values(this.migrations).flatMap(s=>s.sequence);this.sortedMigrations=JB(r);for(const s of this.sortedMigrations)if((o=s.dependsOn)!=null&&o.length)for(const i of s.dependsOn){const a=r.find(l=>l.id===i);Xe(a,`Migration '${s.id}' depends on missing migration '${i}'`)}}static create(t,n){return new qx(t,n??{})}validateRecord(t,n,r,o){try{const s=Nn(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=eU(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 yn.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 l=`${i}/${a}`,c=this.migrations[i].sequence.findIndex(u=>u.id===l);if(c===-1)return yn.err("Incompatible schema?");for(const u of this.migrations[i].sequence.slice(c+1))s.add(u.id)}return yn.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=Ge(t);try{for(const i of s){if(i.scope==="store")throw new Error;if(!(i.filter?i.filter(t):!0))continue;const l=i[r](t);l&&(t=Ge(l))}}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=Ge(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 c=s.up(a);c&&(n[i]=Ge(c))}else if(s.scope==="store"){const i=s.up(n);i&&(n=Ge(i))}else un(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?Mp(n.at(-1).id).version:0]))}}serializeEarliestVersion(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:t})=>[t,0]))}}getType(t){const n=Nn(this.types,t);return Xe(n,"record type does not exists"),n}}function tU(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 ke extends Error{constructor(n,r=[]){const o=tU(r),s=n.split(`
|
|
47
|
+
`).map((i,a)=>a===0?i:` ${i}`).join(`
|
|
48
|
+
`);super(r?`At ${o}: ${s}`:s);g(this,"name","ValidationError");this.rawMessage=n,this.path=r}}function Hn(e,t){try{return t()}catch(n){throw n instanceof ke?new ke(n.rawMessage,[e,...n.path]):new ke(n.toString(),[e])}}function Ys(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:un(t)}}class Cn{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 aU(this)}optional(){return h_(this)}refine(t){return new Cn(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=>(Hn(`(check ${t})`,()=>n(r)),r)):this.refine(r=>(t(r),r))}}class nU extends Cn{constructor(t){super(n=>{const r=Jb.validate(n);for(let o=0;o<r.length;o++)Hn(o,()=>t.validate(r[o]));return r},(n,r)=>{if(!t.validateUsingKnownGoodVersion)return this.validate(r);const o=Jb.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,Hn(i,()=>t.validate(a));continue}if(Object.is(n[i],a))continue;const l=Hn(i,()=>t.validateUsingKnownGoodVersion(n[i],a));Object.is(l,n[i])||(s=!0)}return s?r:n}),this.itemValidator=t}nonEmpty(){return this.check(t=>{if(t.length===0)throw new ke("Expected a non-empty array")})}lengthGreaterThan1(){return this.check(t=>{if(t.length<=1)throw new ke("Expected an array with length greater than 1")})}}class Ap extends Cn{constructor(t,n=!1){super(r=>{if(typeof r!="object"||r===null)throw new ke(`Expected object, got ${Ys(r)}`);for(const[o,s]of Object.entries(t))Hn(o,()=>{s.validate(Nn(r,o))});if(!n){for(const o of Object.keys(r))if(!yo(t,o))throw new ke("Unexpected property",[o])}return r},(r,o)=>{if(typeof o!="object"||o===null)throw new ke(`Expected object, got ${Ys(o)}`);let s=!1;for(const[i,a]of Object.entries(t)){const l=Nn(r,i),c=Nn(o,i);if(Object.is(l,c))continue;const u=Hn(i,()=>{const h=a;return h.validateUsingKnownGoodVersion?h.validateUsingKnownGoodVersion(l,c):h.validate(c)});Object.is(u,l)||(s=!0)}if(!n){for(const i of Object.keys(o))if(!yo(t,i))throw new ke("Unexpected property",[i])}for(const i of Object.keys(r))if(!yo(o,i)){s=!0;break}return s?o:r}),this.config=t,this.shouldAllowUnknownProperties=n}allowUnknownProperties(){return new Ap(this.config,!0)}extend(t){return new Ap({...this.config,...t})}}class Uf extends Cn{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):Hn(`(${t} = ${a})`,()=>i.validate(s))},(s,i)=>{this.expectObject(i),this.expectObject(s);const{matchingSchema:a,variant:l}=this.getMatchingSchemaAndVariant(i);return a===void 0?this.unknownValueValidation(i,l):Nn(s,t)!==Nn(i,t)?Hn(`(${t} = ${l})`,()=>a.validate(i)):Hn(`(${t} = ${l})`,()=>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 ke(`Expected an object, got ${Ys(t)}`,[])}getMatchingSchemaAndVariant(t){const n=Nn(t,this.key);if(!this.useNumberKeys&&typeof n!="string")throw new ke(`Expected a string for key "${this.key}", got ${Ys(n)}`);if(this.useNumberKeys&&!Number.isFinite(Number(n)))throw new ke(`Expected a number for key "${this.key}", got "${n}"`);return{matchingSchema:yo(this.config,n)?this.config[n]:void 0,variant:n}}validateUnknownVariants(t){return new Uf(this.key,this.config,t,this.useNumberKeys)}}class rU extends Cn{constructor(t,n){super(r=>{if(typeof r!="object"||r===null)throw new ke(`Expected object, got ${Ys(r)}`);for(const[o,s]of Object.entries(r))Hn(o,()=>{t.validate(o),n.validate(s)});return r},(r,o)=>{if(typeof o!="object"||o===null)throw new ke(`Expected object, got ${Ys(o)}`);let s=!1;for(const[i,a]of Object.entries(o)){if(!yo(r,i)){s=!0,Hn(i,()=>{t.validate(i),n.validate(a)});continue}const l=Nn(r,i),c=a;if(Object.is(l,c))continue;const u=Hn(i,()=>n.validateUsingKnownGoodVersion?n.validateUsingKnownGoodVersion(l,c):n.validate(c));Object.is(u,l)||(s=!0)}for(const i of Object.keys(r))if(!yo(o,i)){s=!0;break}return s?o:r}),this.keyValidator=t,this.valueValidator=n}}function Zx(e){return new Cn(t=>{if(typeof t!==e)throw new ke(`Expected ${e}, got ${Ys(t)}`);return t})}const oU=new Cn(e=>e),fe=Zx("string"),he=Zx("number").check(e=>{if(Number.isNaN(e))throw new ke("Expected a number, got NaN");if(!Number.isFinite(e))throw new ke(`Expected a finite number, got ${e}`)}),jp=he.check(e=>{if(e<0)throw new ke(`Expected a positive number, got ${e}`)}),Pt=he.check(e=>{if(e<=0)throw new ke(`Expected a non-zero positive number, got ${e}`)}),d_=he.check(e=>{if(!Number.isInteger(e))throw new ke(`Expected an integer, got ${e}`)}),Mh=d_.check(e=>{if(e<0)throw new ke(`Expected a positive integer, got ${e}`)}),sU=d_.check(e=>{if(e<=0)throw new ke(`Expected a non-zero positive integer, got ${e}`)}),Se=Zx("boolean");function dn(e){return new Cn(t=>{if(t!==e)throw new ke(`Expected ${e}, got ${JSON.stringify(t)}`);return e})}const Jb=new Cn(e=>{if(!Array.isArray(e))throw new ke(`Expected an array, got ${Ys(e)}`);return e});function Ht(e){return new nU(e)}function xe(e){return new Ap(e)}function IS(e){return typeof e=="object"&&e!==null&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null||Object.getPrototypeOf(e)===FB)}function ES(e){return e===null||typeof e=="number"||typeof e=="string"||typeof e=="boolean"?!0:Array.isArray(e)?e.every(ES):IS(e)?Object.values(e).every(ES):!1}const Kt=new Cn(e=>{if(ES(e))return e;throw new ke(`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,Kt.validate(t[r]);continue}const o=e[r],s=t[r];if(Object.is(o,s))continue;const i=Kt.validateUsingKnownGoodVersion(o,s);Object.is(i,o)||(n=!0)}return n?t:e}else if(IS(e)&&IS(t)){let n=!1;for(const r of Object.keys(t)){if(!yo(e,r)){n=!0,Kt.validate(t[r]);continue}const o=e[r],s=t[r];if(Object.is(o,s))continue;const i=Kt.validateUsingKnownGoodVersion(o,s);Object.is(i,o)||(n=!0)}for(const r of Object.keys(e))if(!yo(t,r)){n=!0;break}return n?t:e}else return Kt.validate(t)});function Op(e,t){return new rU(e,t)}function Qx(e,t){return new Uf(e,t,(n,r)=>{throw new ke(`Expected one of ${Object.keys(t).map(o=>JSON.stringify(o)).join(" or ")}, got ${JSON.stringify(r)}`,[e])},!1)}function iU(e,t){return new Uf(e,t,(n,r)=>{throw new ke(`Expected one of ${Object.keys(t).map(o=>JSON.stringify(o)).join(" or ")}, got ${JSON.stringify(r)}`,[e])},!0)}function Mo(e,t){return new Cn(n=>Hn(e,()=>t.validate(n)),(n,r)=>Hn(e,()=>t.validateUsingKnownGoodVersion?t.validateUsingKnownGoodVersion(n,r):t.validate(r)))}function Hf(e){return new Cn(t=>{if(!e.has(t)){const n=Array.from(e,r=>JSON.stringify(r)).join(" or ");throw new ke(`Expected ${n}, got ${t}`)}return t})}function h_(e){return new Cn(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 aU(e){return new Cn(t=>t===null?null:e.validate(t),(t,n)=>n===null?null:e.validateUsingKnownGoodVersion&&t!==null?e.validateUsingKnownGoodVersion(t,n):e.validate(n))}function Kf(...e){return Hf(new Set(e))}function Jx(e){try{return new URL(e)}catch{if(e.startsWith("/")||e.startsWith("./"))try{return new URL(e,"http://example.com")}catch{throw new ke(`Expected a valid url, got ${JSON.stringify(e)}`)}throw new ke(`Expected a valid url, got ${JSON.stringify(e)}`)}}const lU=new Set(["http:","https:","mailto:"]),lr=fe.check(e=>{if(e==="")return;const t=Jx(e);if(!lU.has(t.protocol.toLowerCase()))throw new ke(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)}),cU=new Set(["http:","https:","data:","asset:"]),Li=fe.check(e=>{if(e==="")return;const t=Jx(e);if(!cU.has(t.protocol.toLowerCase()))throw new ke(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)});fe.check(e=>{if(e==="")return;if(!Jx(e).protocol.toLowerCase().match(/^https?:$/))throw new ke(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)});const e0=fe.refine(e=>{try{return _B(e),e}catch{throw new ke(`Expected an index key, got ${JSON.stringify(e)}`)}});function or(e){return fe.refine(t=>{if(!t.startsWith(`${e}:`))throw new Error(`${e} ID must start with "${e}:"`);return t})}const Wf=or("asset");function t0(e,t){return xe({id:Wf,typeName:dn("asset"),type:dn(e),props:t,meta:Kt})}const $i=xe({x:he,y:he,z:he.optional()}),Fc=xe({x:he,y:he,w:he,h:he}),p_=he.check(e=>{if(e<0||e>1)throw new ke("Opacity must be between 0 and 1")}),uU=fe.refine(e=>{if(!e.startsWith("page:")&&!e.startsWith("shape:"))throw new Error('Parent ID must start with "page:" or "shape:"');return e}),Sr=or("shape");function dU(e,t,n){return xe({id:Sr,typeName:dn("shape"),x:he,y:he,rotation:he,index:e0,parentId:uU,type:dn(e),isLocked:Se,opacity:p_,props:t?xe(t):Kt,meta:n?xe(n):Kt})}const hU=or("binding");function pU(e,t,n){return xe({id:hU,typeName:dn("binding"),type:dn(e),fromId:Sr,toId:Sr,props:t?xe(t):Kt,meta:n?xe(n):Kt})}Vn("com.tldraw.binding",{});dr({sequenceId:"com.tldraw.binding",recordType:"binding",sequence:[]});function ji(e){return`binding:${Uu()}`}function fU(e){return To("binding",{scope:"document",validator:Mo("binding",Qx("type",Bu(e,(t,{props:n,meta:r})=>pU(t,n,r))))}).withDefaultProperties(()=>({meta:{}}))}class qt{constructor(t,n,r){this.id=t,this.defaultValue=n,this.type=r}static define(t,n){const{defaultValue:r,type:o=oU}=n;return new qt(t,r,o)}static defineEnum(t,n){const{defaultValue:r,values:o}=n;return new gU(t,r,o)}setDefaultValue(t){this.defaultValue=t}validate(t){return this.type.validate(t)}validateUsingKnownGoodVersion(t,n){return this.type.validateUsingKnownGoodVersion?this.type.validateUsingKnownGoodVersion(t,n):this.validate(n)}}class gU extends qt{constructor(t,n,r){super(t,n,Kf(...r)),this.values=r}}const Ed=Vn("com.tldraw.shape",{AddIsLocked:1,HoistOpacity:2,AddMeta:3,AddWhite:4}),mU=dr({sequenceId:"com.tldraw.shape",recordType:"shape",sequence:[{id:Ed.AddIsLocked,up:e=>{e.isLocked=!1},down:e=>{delete e.isLocked}},{id:Ed.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:Ed.AddMeta,up:e=>{e.meta={}}},{id:Ed.AddWhite,up:e=>{},down:e=>{e.props.color==="white"&&(e.props.color="black")}}]});function Ta(e){return e?e.typeName==="shape":!1}function On(e){return e?e.startsWith("shape:"):!1}function $e(e){return`shape:${e??Uu()}`}function f_(e){const t=new Map;for(const[n,r]of Object.entries(e))if(r instanceof qt){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}function Zr(e,t){return Bu(t,(n,r)=>`com.tldraw.shape.${e}/${r}`)}function yU(e){return To("shape",{scope:"document",validator:Mo("shape",Qx("type",Bu(e,(t,{props:n,meta:r})=>dU(t,n,r))))}).withDefaultProperties(()=>({x:0,y:0,rotation:0,isLocked:!1,opacity:1,meta:{}}))}function eP(e,t){const n=[];for(const[r,{migrations:o}]of Object.entries(t)){const s=`com.tldraw.${e}.${r}`;o?"sequenceId"in o?(Xe(s===o.sequenceId,`sequenceId mismatch for ${r} ${Bf} migrations. Expected '${s}', got '${o.sequenceId}'`),n.push(o)):"sequence"in o?n.push(Va({sequenceId:s,retroactive:!1,sequence:o.sequence.map(i=>"id"in i?g_(e,r,i):i)})):n.push(Va({sequenceId:s,retroactive:!1,sequence:Object.keys(o.migrators).map(i=>Number(i)).sort((i,a)=>i-a).map(i=>({id:`${s}/${i}`,scope:"record",filter:a=>a.typeName===e&&a.type===r,up:a=>{const l=o.migrators[i].up(a);if(l)return l},down:a=>{const l=o.migrators[i].down(a);if(l)return l}}))})):n.push(Va({sequenceId:s,retroactive:!1,sequence:[]}))}return n}function g_(e,t,n){return{id:n.id,dependsOn:n.dependsOn,scope:"record",filter:r=>r.typeName===e&&r.type===t,up:r=>{const o=n.up(r.props);o&&(r.props=o)},down:typeof n.down=="function"?r=>{const o=n.down(r.props);o&&(r.props=o)}:void 0}}const m_=["black","grey","light-violet","violet","blue","light-blue","yellow","orange","green","light-green","light-red","red","white"],Dp={lightMode:{id:"light",text:"#000000",background:"rgb(249, 250, 251)",solid:"#fcfffe",black:{solid:"#1d1d1d",fill:"#1d1d1d",note:{fill:"#FCE19C",text:"#000000"},semi:"#e8e8e8",pattern:"#494949",highlight:{srgb:"#fddd00",p3:"color(display-p3 0.972 0.8705 0.05)"}},blue:{solid:"#4465e9",fill:"#4465e9",note:{fill:"#8AA3FF",text:"#000000"},semi:"#dce1f8",pattern:"#6681ee",highlight:{srgb:"#10acff",p3:"color(display-p3 0.308 0.6632 0.9996)"}},green:{solid:"#099268",fill:"#099268",note:{fill:"#6FC896",text:"#000000"},semi:"#d3e9e3",pattern:"#39a785",highlight:{srgb:"#00ffc8",p3:"color(display-p3 0.2536 0.984 0.7981)"}},grey:{solid:"#9fa8b2",fill:"#9fa8b2",note:{fill:"#C0CAD3",text:"#000000"},semi:"#eceef0",pattern:"#bcc3c9",highlight:{srgb:"#cbe7f1",p3:"color(display-p3 0.8163 0.9023 0.9416)"}},"light-blue":{solid:"#4ba1f1",fill:"#4ba1f1",note:{fill:"#9BC4FD",text:"#000000"},semi:"#ddedfa",pattern:"#6fbbf8",highlight:{srgb:"#00f4ff",p3:"color(display-p3 0.1512 0.9414 0.9996)"}},"light-green":{solid:"#4cb05e",fill:"#4cb05e",note:{fill:"#98D08A",text:"#000000"},semi:"#dbf0e0",pattern:"#65cb78",highlight:{srgb:"#65f641",p3:"color(display-p3 0.563 0.9495 0.3857)"}},"light-red":{solid:"#f87777",fill:"#f87777",note:{fill:"#F7A5A1",text:"#000000"},semi:"#f4dadb",pattern:"#fe9e9e",highlight:{srgb:"#ff7fa3",p3:"color(display-p3 0.9988 0.5301 0.6397)"}},"light-violet":{solid:"#e085f4",fill:"#e085f4",note:{fill:"#DFB0F9",text:"#000000"},semi:"#f5eafa",pattern:"#e9acf8",highlight:{srgb:"#ff88ff",p3:"color(display-p3 0.9676 0.5652 0.9999)"}},orange:{solid:"#e16919",fill:"#e16919",note:{fill:"#FAA475",text:"#000000"},semi:"#f8e2d4",pattern:"#f78438",highlight:{srgb:"#ffa500",p3:"color(display-p3 0.9988 0.6905 0.266)"}},red:{solid:"#e03131",fill:"#e03131",note:{fill:"#FC8282",text:"#000000"},semi:"#f4dadb",pattern:"#e55959",highlight:{srgb:"#ff636e",p3:"color(display-p3 0.9992 0.4376 0.45)"}},violet:{solid:"#ae3ec9",fill:"#ae3ec9",note:{fill:"#DB91FD",text:"#000000"},semi:"#ecdcf2",pattern:"#bd63d3",highlight:{srgb:"#c77cff",p3:"color(display-p3 0.7469 0.5089 0.9995)"}},yellow:{solid:"#f1ac4b",fill:"#f1ac4b",note:{fill:"#FED49A",text:"#000000"},semi:"#f9f0e6",pattern:"#fecb92",highlight:{srgb:"#fddd00",p3:"color(display-p3 0.972 0.8705 0.05)"}},white:{solid:"#FFFFFF",fill:"#FFFFFF",semi:"#f5f5f5",pattern:"#f9f9f9",note:{fill:"#FFFFFF",text:"#000000"},highlight:{srgb:"#ffffff",p3:"color(display-p3 1 1 1)"}}},darkMode:{id:"dark",text:"hsl(210, 17%, 98%)",background:"hsl(240, 5%, 6.5%)",solid:"#010403",black:{solid:"#f2f2f2",fill:"#f2f2f2",note:{fill:"#2c2c2c",text:"#f2f2f2"},semi:"#2c3036",pattern:"#989898",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.7225 0.0312)"}},blue:{solid:"#4f72fc",fill:"#4f72fc",note:{fill:"#2A3F98",text:"#f2f2f2"},semi:"#262d40",pattern:"#3a4b9e",highlight:{srgb:"#0079d2",p3:"color(display-p3 0.0032 0.4655 0.7991)"}},green:{solid:"#099268",fill:"#099268",note:{fill:"#014429",text:"#f2f2f2"},semi:"#253231",pattern:"#366a53",highlight:{srgb:"#009774",p3:"color(display-p3 0.0085 0.582 0.4604)"}},grey:{solid:"#9398b0",fill:"#9398b0",note:{fill:"#56595F",text:"#f2f2f2"},semi:"#33373c",pattern:"#7c8187",highlight:{srgb:"#9cb4cb",p3:"color(display-p3 0.6299 0.7012 0.7856)"}},"light-blue":{solid:"#4dabf7",fill:"#4dabf7",note:{fill:"#1F5495",text:"#f2f2f2"},semi:"#2a3642",pattern:"#4d7aa9",highlight:{srgb:"#00bdc8",p3:"color(display-p3 0.0023 0.7259 0.7735)"}},"light-green":{solid:"#40c057",fill:"#40c057",note:{fill:"#21581D",text:"#f2f2f2"},semi:"#2a3830",pattern:"#4e874e",highlight:{srgb:"#00a000",p3:"color(display-p3 0.2711 0.6172 0.0195)"}},"light-red":{solid:"#ff8787",fill:"#ff8787",note:{fill:"#923632",text:"#f2f2f2"},semi:"#3b3235",pattern:"#a56767",highlight:{srgb:"#db005b",p3:"color(display-p3 0.7849 0.0585 0.3589)"}},"light-violet":{solid:"#e599f7",fill:"#e599f7",note:{fill:"#762F8E",text:"#f2f2f2"},semi:"#383442",pattern:"#9770a9",highlight:{srgb:"#c400c7",p3:"color(display-p3 0.7024 0.0403 0.753)"}},orange:{solid:"#f76707",fill:"#f76707",note:{fill:"#843906",text:"#f2f2f2"},semi:"#3a2e2a",pattern:"#9f552d",highlight:{srgb:"#d07a00",p3:"color(display-p3 0.7699 0.4937 0.0085)"}},red:{solid:"#e03131",fill:"#e03131",note:{fill:"#89231A",text:"#f2f2f2"},semi:"#36292b",pattern:"#8f3734",highlight:{srgb:"#de002c",p3:"color(display-p3 0.7978 0.0509 0.2035)"}},violet:{solid:"#ae3ec9",fill:"#ae3ec9",note:{fill:"#681683",text:"#f2f2f2"},semi:"#31293c",pattern:"#763a8b",highlight:{srgb:"#9e00ee",p3:"color(display-p3 0.5651 0.0079 0.8986)"}},yellow:{solid:"#ffc034",fill:"#ffc034",note:{fill:"#98571B",text:"#f2f2f2"},semi:"#3c3934",pattern:"#fecb92",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.7225 0.0312)"}},white:{solid:"#f3f3f3",fill:"#f3f3f3",semi:"#f5f5f5",pattern:"#f9f9f9",note:{fill:"#eaeaea",text:"#1d1d1d"},highlight:{srgb:"#ffffff",p3:"color(display-p3 1 1 1)"}}}};function cs(e){return e.isDarkMode?Dp.darkMode:Dp.lightMode}const cr=qt.defineEnum("tldraw:color",{defaultValue:"black",values:m_}),y_=qt.defineEnum("tldraw:labelColor",{defaultValue:"black",values:m_}),Ni=qt.defineEnum("tldraw:dash",{defaultValue:"draw",values:["draw","solid","dashed","dotted"]}),Fi=qt.defineEnum("tldraw:fill",{defaultValue:"none",values:["none","semi","solid","pattern","fill"]}),Po=qt.defineEnum("tldraw:font",{defaultValue:"draw",values:["draw","sans","serif","mono"]}),S_={draw:"'tldraw_draw', sans-serif",sans:"'tldraw_sans', sans-serif",serif:"'tldraw_serif', serif",mono:"'tldraw_mono', monospace"},Co=qt.defineEnum("tldraw:size",{defaultValue:"m",values:["s","m","l","xl"]}),v_=["arrow","triangle","square","dot","pipe","diamond","inverted","bar","none"],Rp=qt.defineEnum("tldraw:arrowheadStart",{defaultValue:"none",values:v_}),Lp=qt.defineEnum("tldraw:arrowheadEnd",{defaultValue:"arrow",values:v_}),x_={labelColor:y_,color:cr,fill:Fi,dash:Ni,size:Co,arrowheadStart:Rp,arrowheadEnd:Lp,font:Po,start:$i,end:$i,bend:he,text:fe,labelPosition:he,scale:Pt},ba=Zr("arrow",{AddLabelColor:1,AddIsPrecise:2,AddLabelPosition:3,ExtractBindings:4,AddScale:5});function kd(e){return g_("shape","arrow",e)}const w_=Va({sequenceId:"com.tldraw.shape.arrow",retroactive:!1,sequence:[kd({id:ba.AddLabelColor,up:e=>{e.labelColor="black"},down:"retired"}),kd({id:ba.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)}}),kd({id:ba.AddLabelPosition,up:e=>{e.labelPosition=.5},down:e=>{delete e.labelPosition}}),{id:ba.ExtractBindings,scope:"store",up:e=>{const t=Object.values(e).filter(n=>n.typeName==="shape"&&n.type==="arrow");for(const n of t){const{start:r,end:o}=n.props;if(r.type==="binding"){const s=ji(),i={typeName:"binding",id:s,type:"arrow",fromId:n.id,toId:r.boundShapeId,meta:{},props:{terminal:"start",normalizedAnchor:r.normalizedAnchor,isExact:r.isExact,isPrecise:r.isPrecise}};e[s]=i,n.props.start={x:0,y:0}}else delete n.props.start.type;if(o.type==="binding"){const s=ji(),i={typeName:"binding",id:s,type:"arrow",fromId:n.id,toId:o.boundShapeId,meta:{},props:{terminal:"end",normalizedAnchor:o.normalizedAnchor,isExact:o.isExact,isPrecise:o.isPrecise}};e[s]=i,n.props.end={x:0,y:0}}else delete n.props.end.type}}},kd({id:ba.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}})]}),b_={terminal:Kf("start","end"),normalizedAnchor:$i,isExact:Se,isPrecise:Se},P_={sequence:[{dependsOn:[ba.ExtractBindings]}]},SU=Mo("camera",xe({typeName:dn("camera"),id:or("camera"),x:he,y:he,z:he,meta:Kt})),vU=Vn("com.tldraw.camera",{AddMeta:1}),xU=dr({sequenceId:"com.tldraw.camera",recordType:"camera",sequence:[{id:vU.AddMeta,up:e=>{e.meta={}}}]}),po=To("camera",{validator:SU,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,z:1,meta:{}})),wU=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"]),C_=Hf(wU),bU=xe({type:C_,rotation:he}),PU=new Set(["accent","white","black","selection-stroke","selection-fill","laser","muted-1"]),CU=Hf(PU),IU=new Set(["starting","paused","active","stopping"]),I_=xe({id:fe,points:Ht($i),size:jp,color:CU,opacity:he,state:Hf(IU),delay:he,shrink:he,taper:Se}),su=or("page"),EU=Mo("page",xe({typeName:dn("page"),id:su,name:fe,index:e0,meta:Kt})),kU=Vn("com.tldraw.page",{AddMeta:1}),_U=dr({sequenceId:"com.tldraw.page",recordType:"page",sequence:[{id:kU.AddMeta,up:e=>{e.meta={}}}]}),Jo=To("page",{validator:EU,scope:"document"}).withDefaultProperties(()=>({meta:{}}));function An(e){return Jo.isId(e)}const TU={id:!1,typeName:!1,currentPageId:!1,opacityForNextShape:!1,stylesForNextShape:!1,followingUserId:!1,highlightedUserIds:!1,brush:!1,cursor:!1,scribbles:!1,isFocusMode:!0,isDebugMode:!0,isToolLocked:!0,exportBackground:!0,screenBounds:!0,insets:!0,zoomBrush:!1,chatMessage:!1,isChatting:!1,isPenMode:!1,isGridMode:!0,isFocused:!0,devicePixelRatio:!0,isCoarsePointer:!0,isHoveringCanvas:!1,openMenus:!1,isChangingStyle:!1,isReadonly:!0,meta:!1,duplicateProps:!1},E_=e=>e?$c(e,t=>TU[t]):null;or("instance");function MU(e){const t={};for(const[r,o]of e)t[r]=h_(o);const n=Mo("instance",xe({typeName:dn("instance"),id:or("instance"),currentPageId:su,followingUserId:fe.nullable(),brush:Fc.nullable(),opacityForNextShape:p_,stylesForNextShape:xe(t),cursor:bU,scribbles:Ht(I_),isFocusMode:Se,isDebugMode:Se,isToolLocked:Se,exportBackground:Se,screenBounds:Fc,insets:Ht(Se),zoomBrush:Fc.nullable(),isPenMode:Se,isGridMode:Se,chatMessage:fe,isChatting:Se,highlightedUserIds:Ht(fe),isFocused:Se,devicePixelRatio:he,isCoarsePointer:Se,isHoveringCanvas:Se.nullable(),openMenus:Ht(fe),isChangingStyle:Se,isReadonly:Se,meta:Kt,duplicateProps:xe({shapeIds:Ht(or("shape")),offset:xe({x:he,y:he})}).nullable()}));return To("instance",{validator:n,scope:"session",ephemeralKeys:{currentPageId:!1,meta:!1,followingUserId:!0,opacityForNextShape:!0,stylesForNextShape:!0,brush:!0,cursor:!0,scribbles:!0,isFocusMode:!0,isDebugMode:!0,isToolLocked:!0,exportBackground:!0,screenBounds:!0,insets:!0,zoomBrush:!0,isPenMode:!0,isGridMode:!0,chatMessage:!0,isChatting:!0,highlightedUserIds:!0,isFocused:!0,devicePixelRatio:!0,isCoarsePointer:!0,isHoveringCanvas:!0,openMenus:!0,isChangingStyle:!0,isReadonly:!0,duplicateProps:!0}}).withDefaultProperties(()=>({followingUserId:null,opacityForNextShape:1,stylesForNextShape:{},brush:null,scribbles:[],cursor:{type:"default",rotation:0},isFocusMode:!1,exportBackground:!1,isDebugMode:!1,isToolLocked:!1,screenBounds:{x:0,y:0,w:1080,h:720},insets:[!1,!1,!1,!1],zoomBrush:null,isGridMode:!1,isPenMode:!1,chatMessage:"",isChatting:!1,highlightedUserIds:[],isFocused:!1,devicePixelRatio:typeof window>"u"?1:window.devicePixelRatio,isCoarsePointer:!1,isHoveringCanvas:null,openMenus:[],isChangingStyle:!1,isReadonly:!1,meta:{},duplicateProps:null}))}const Qe=Vn("com.tldraw.instance",{AddTransparentExportBgs:1,RemoveDialog:2,AddToolLockMode:3,RemoveExtraPropsForNextShape:4,AddLabelColor:5,AddFollowingUserId:6,RemoveAlignJustify:7,AddZoom:8,AddVerticalAlign:9,AddScribbleDelay:10,RemoveUserId:11,AddIsPenModeAndIsGridMode:12,HoistOpacity:13,AddChat:14,AddHighlightedUserIds:15,ReplacePropsForNextShapeWithStylesForNextShape:16,AddMeta:17,RemoveCursorColor:18,AddLonelyProperties:19,ReadOnlyReadonly:20,AddHoveringCanvas:21,AddScribbles:22,AddInset:23,AddDuplicateProps:24,RemoveCanMoveCamera:25}),AU=dr({sequenceId:"com.tldraw.instance",recordType:"instance",sequence:[{id:Qe.AddTransparentExportBgs,up:e=>({...e,exportBackground:!0})},{id:Qe.RemoveDialog,up:({dialog:e,...t})=>t},{id:Qe.AddToolLockMode,up:e=>({...e,isToolLocked:!1})},{id:Qe.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:Qe.AddLabelColor,up:({propsForNextShape:e,...t})=>({...t,propsForNextShape:{...e,labelColor:"black"}})},{id:Qe.AddFollowingUserId,up:e=>({...e,followingUserId:null})},{id:Qe.RemoveAlignJustify,up:e=>{let t=e.propsForNextShape.align;return t==="justify"&&(t="start"),{...e,propsForNextShape:{...e.propsForNextShape,align:t}}}},{id:Qe.AddZoom,up:e=>({...e,zoomBrush:null})},{id:Qe.AddVerticalAlign,up:e=>({...e,propsForNextShape:{...e.propsForNextShape,verticalAlign:"middle"}})},{id:Qe.AddScribbleDelay,up:e=>e.scribble!==null?{...e,scribble:{...e.scribble,delay:0}}:{...e}},{id:Qe.RemoveUserId,up:({userId:e,...t})=>t},{id:Qe.AddIsPenModeAndIsGridMode,up:e=>({...e,isPenMode:!1,isGridMode:!1})},{id:Qe.HoistOpacity,up:({propsForNextShape:{opacity:e,...t},...n})=>({...n,opacityForNextShape:Number(e??"1"),propsForNextShape:t})},{id:Qe.AddChat,up:e=>({...e,chatMessage:"",isChatting:!1})},{id:Qe.AddHighlightedUserIds,up:e=>({...e,highlightedUserIds:[]})},{id:Qe.ReplacePropsForNextShapeWithStylesForNextShape,up:({propsForNextShape:e,...t})=>({...t,stylesForNextShape:{}})},{id:Qe.AddMeta,up:e=>({...e,meta:{}})},{id:Qe.RemoveCursorColor,up:e=>{const{color:t,...n}=e.cursor;return{...e,cursor:n}}},{id:Qe.AddLonelyProperties,up:e=>({...e,canMoveCamera:!0,isFocused:!1,devicePixelRatio:1,isCoarsePointer:!1,openMenus:[],isChangingStyle:!1,isReadOnly:!1})},{id:Qe.ReadOnlyReadonly,up:({isReadOnly:e,...t})=>({...t,isReadonly:e})},{id:Qe.AddHoveringCanvas,up:e=>({...e,isHoveringCanvas:null})},{id:Qe.AddScribbles,up:({scribble:e,...t})=>({...t,scribbles:[]})},{id:Qe.AddInset,up:e=>({...e,insets:[!1,!1,!1,!1]}),down:({insets:e,...t})=>({...t})},{id:Qe.AddDuplicateProps,up:e=>({...e,duplicateProps:null}),down:({duplicateProps:e,...t})=>({...t})},{id:Qe.RemoveCanMoveCamera,up:({canMoveCamera:e,...t})=>({...t}),down:e=>({...e,canMoveCamera:!0})}]}),Sn="instance:instance",jU=Mo("instance_page_state",xe({typeName:dn("instance_page_state"),id:or("instance_page_state"),pageId:su,selectedShapeIds:Ht(Sr),hintingShapeIds:Ht(Sr),erasingShapeIds:Ht(Sr),hoveredShapeId:Sr.nullable(),editingShapeId:Sr.nullable(),croppingShapeId:Sr.nullable(),focusedGroupId:Sr.nullable(),meta:Kt})),Vl=Vn("com.tldraw.instance_page_state",{AddCroppingId:1,RemoveInstanceIdAndCameraId:2,AddMeta:3,RenameProperties:4,RenamePropertiesAgain:5}),OU=dr({sequenceId:"com.tldraw.instance_page_state",recordType:"instance_page_state",sequence:[{id:Vl.AddCroppingId,up(e){e.croppingShapeId=null}},{id:Vl.RemoveInstanceIdAndCameraId,up(e){delete e.instanceId,delete e.cameraId}},{id:Vl.AddMeta,up:e=>{e.meta={}}},{id:Vl.RenameProperties,up:e=>{},down:e=>{}},{id:Vl.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}}]}),Br=To("instance_page_state",{validator:jU,scope:"session",ephemeralKeys:{pageId:!1,selectedShapeIds:!1,editingShapeId:!1,croppingShapeId:!1,meta:!1,hintingShapeIds:!0,erasingShapeIds:!0,hoveredShapeId:!0,focusedGroupId:!0}}).withDefaultProperties(()=>({editingShapeId:null,croppingShapeId:null,selectedShapeIds:[],hoveredShapeId:null,erasingShapeIds:[],hintingShapeIds:[],focusedGroupId:null,meta:{}})),DU=Mo("pointer",xe({typeName:dn("pointer"),id:or("pointer"),x:he,y:he,lastActivityTimestamp:he,meta:Kt})),RU=Vn("com.tldraw.pointer",{AddMeta:1}),LU=dr({sequenceId:"com.tldraw.pointer",recordType:"pointer",sequence:[{id:RU.AddMeta,up:e=>{e.meta={}}}]}),n0=To("pointer",{validator:DU,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,lastActivityTimestamp:0,meta:{}})),$p=n0.createId("pointer"),$U=Mo("instance_presence",xe({typeName:dn("instance_presence"),id:or("instance_presence"),userId:fe,userName:fe,lastActivityTimestamp:he,followingUserId:fe.nullable(),cursor:xe({x:he,y:he,type:C_,rotation:he}),color:fe,camera:xe({x:he,y:he,z:he}),screenBounds:Fc,selectedShapeIds:Ht(or("shape")),currentPageId:or("page"),brush:Fc.nullable(),scribbles:Ht(I_),chatMessage:fe,meta:Kt})),Yl=Vn("com.tldraw.instance_presence",{AddScribbleDelay:1,RemoveInstanceId:2,AddChatMessage:3,AddMeta:4,RenameSelectedShapeIds:5}),NU=dr({sequenceId:"com.tldraw.instance_presence",recordType:"instance_presence",sequence:[{id:Yl.AddScribbleDelay,up:e=>{e.scribble!==null&&(e.scribble.delay=0)}},{id:Yl.RemoveInstanceId,up:e=>{delete e.instanceId}},{id:Yl.AddChatMessage,up:e=>{e.chatMessage=""}},{id:Yl.AddMeta,up:e=>{e.meta={}}},{id:Yl.RenameSelectedShapeIds,up:e=>{}}]}),FU=To("instance_presence",{validator:$U,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:{}})),zU=Mo("document",xe({typeName:dn("document"),id:dn("document:document"),gridSize:he,name:fe,meta:Kt})),tP=Vn("com.tldraw.document",{AddName:1,AddMeta:2}),BU=dr({sequenceId:"com.tldraw.document",recordType:"document",sequence:[{id:tP.AddName,up:e=>{e.name=""},down:e=>{delete e.name}},{id:tP.AddMeta,up:e=>{e.meta={}}}]}),r0=To("document",{validator:zU,scope:"document"}).withDefaultProperties(()=>({gridSize:10,name:"",meta:{}})),kS=r0.createId("document");function UU(e,t){return e.index<t.index?-1:e.index>t.index?1:0}function nP(e){e.typeName==="asset"&&("src"in e&&(e.src="<redacted>"),"src"in e.props&&(e.props.src="<redacted>"))}const HU=({error:e,phase:t,record:n,recordBefore:r})=>{throw Ux(e,{tags:{origin:"store.validateRecord",storePhase:t,isExistingValidationIssue:t==="initialize"},extras:{recordBefore:r?nP(Ge(r)):void 0,recordAfter:nP(Ge(n))}}),e};function KU(){return[Jo.create({id:"page:page",name:"Page 1",index:"a1",meta:{}})]}function WU(e){const t=e.query.ids("page"),n=()=>{if(!e.has(kS))return e.put([r0.create({id:kS,name:e.props.defaultName})]),n();if(!e.has($p))return e.put([n0.create({id:$p})]),n();const r=t.get();if(r.size===0)return e.put(KU()),n();const o=()=>[...r].map(l=>e.get(l)).sort(UU)[0].id,s=e.get(Sn);if(s){if(!r.has(s.currentPageId))return e.put([{...s,currentPageId:o()}]),n()}else return e.put([e.schema.types.instance.create({id:Sn,currentPageId:o(),exportBackground:!0})]),n();const i=new Set,a=new Set;for(const l of r){const c=Br.createId(l);e.has(c)||i.add(c);const u=po.createId(l);e.has(u)||a.add(u)}i.size>0&&e.put([...i].map(l=>Br.create({id:l,pageId:Br.parseId(l)}))),a.size>0&&e.put([...a].map(l=>po.create({id:l})))};return n}const GU=t0("bookmark",xe({title:fe,description:fe,image:fe,favicon:fe,src:Li.nullable()})),rP=Vn("com.tldraw.asset.bookmark",{MakeUrlsValid:1,AddFavicon:2}),VU=dr({sequenceId:"com.tldraw.asset.bookmark",recordType:"asset",filter:e=>e.type==="bookmark",sequence:[{id:rP.MakeUrlsValid,up:e=>{Li.isValid(e.props.src)||(e.props.src="")},down:e=>{}},{id:rP.AddFavicon,up:e=>{Li.isValid(e.props.favicon)||(e.props.favicon="")},down:e=>{delete e.props.favicon}}]}),YU=t0("image",xe({w:he,h:he,name:fe,isAnimated:Se,mimeType:fe.nullable(),src:Li.nullable(),fileSize:Pt.optional()})),Xl=Vn("com.tldraw.asset.image",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5}),XU=dr({sequenceId:"com.tldraw.asset.image",recordType:"asset",filter:e=>e.type==="image",sequence:[{id:Xl.AddIsAnimated,up:e=>{e.props.isAnimated=!1},down:e=>{delete e.props.isAnimated}},{id:Xl.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:Xl.MakeUrlsValid,up:e=>{Li.isValid(e.props.src)||(e.props.src="")},down:e=>{}},{id:Xl.AddFileSize,up:e=>{e.props.fileSize=-1},down:e=>{delete e.props.fileSize}},{id:Xl.MakeFileSizeOptional,up:e=>{e.props.fileSize===-1&&(e.props.fileSize=void 0)},down:e=>{e.props.fileSize===void 0&&(e.props.fileSize=-1)}}]}),qU=t0("video",xe({w:he,h:he,name:fe,isAnimated:Se,mimeType:fe.nullable(),src:Li.nullable(),fileSize:he.optional()})),ql=Vn("com.tldraw.asset.video",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3,AddFileSize:4,MakeFileSizeOptional:5}),ZU=dr({sequenceId:"com.tldraw.asset.video",recordType:"asset",filter:e=>e.type==="video",sequence:[{id:ql.AddIsAnimated,up:e=>{e.props.isAnimated=!1},down:e=>{delete e.props.isAnimated}},{id:ql.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:ql.MakeUrlsValid,up:e=>{Li.isValid(e.props.src)||(e.props.src="")},down:e=>{}},{id:ql.AddFileSize,up:e=>{e.props.fileSize=-1},down:e=>{delete e.props.fileSize}},{id:ql.MakeFileSizeOptional,up:e=>{e.props.fileSize===-1&&(e.props.fileSize=void 0)},down:e=>{e.props.fileSize===void 0&&(e.props.fileSize=-1)}}]}),QU=Mo("asset",Qx("type",{image:YU,video:qU,bookmark:GU})),JU=Vn("com.tldraw.asset",{AddMeta:1}),e9=dr({sequenceId:"com.tldraw.asset",recordType:"asset",sequence:[{id:JU.AddMeta,up:e=>{e.meta={}}}]}),Ii=To("asset",{validator:QU,scope:"document"}).withDefaultProperties(()=>({meta:{}})),k_={w:Pt,h:Pt,assetId:Wf.nullable(),url:lr},oP=Zr("bookmark",{NullAssetId:1,MakeUrlsValid:2}),__={sequence:[{id:oP.NullAssetId,up:e=>{e.assetId===void 0&&(e.assetId=null)},down:"retired"},{id:oP.MakeUrlsValid,up:e=>{lr.isValid(e.url)||(e.url="")},down:e=>{}}]},T_=xe({type:Kf("free","straight"),points:Ht($i)}),M_={color:cr,fill:Fi,dash:Ni,size:Co,segments:Ht(T_),isComplete:Se,isClosed:Se,isPen:Se,scale:Pt},sP=Zr("draw",{AddInPen:1,AddScale:2}),A_={sequence:[{id:sP.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:"retired"},{id:sP.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}}]};var t9={};const iP=/(^\/r\/[^/]+\/?$)/,De=e=>{try{return new URL(e)}catch{return}},Hu=[{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=De(e);if(t&&t.pathname.match(iP))return e},fromEmbedUrl:e=>{const t=De(e);if(t&&t.pathname.match(iP))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=De(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,overridePermissions:{"allow-presentation":!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=${t9.NEXT_PUBLIC_GC_API_KEY}¢er=${r},${o}&zoom=${s}`}else n="";return n}},fromEmbedUrl:e=>{const t=De(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=De(e),n=t&&t.pathname.match(/\/v\/(.+)\/?/);if(n)return`https://www.val.town/embed/${n[1]}`},fromEmbedUrl:e=>{const t=De(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=De(e),n=t&&t.pathname.match(/\/s\/([^/]+)\/?/);if(n)return`https://codesandbox.io/embed/${n[1]}`},fromEmbedUrl:e=>{const t=De(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,"allow-popups-to-escape-sandbox":!0},isAspectRatioLocked:!0,toEmbedUrl:e=>{const t=De(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=De(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",overridePermissions:{"allow-popups-to-escape-sandbox":!0},toEmbedUrl:e=>{const t=De(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=De(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,overridePermissions:{"allow-popups-to-escape-sandbox":!0},toEmbedUrl:e=>{const t=De(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=De(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=De(e);if(t&&t.pathname.match(/\/([^/]+)\/([^/]+)/))return e.split("/").pop()?e:void 0},fromEmbedUrl:e=>{const t=De(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=De(e);if(t&&t.pathname.match(/\/@([^/]+)\/([^/]+)/))return`${e}?embed=true`},fromEmbedUrl:e=>{const t=De(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=De(e);if(t&&t.pathname.match(/^\/map\//))return t.origin+"/embed"+t.pathname},fromEmbedUrl:e=>{const t=De(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=De(e);if(t&&t.pathname.match(/^\/(artist|album)\//))return t.origin+"/embed"+t.pathname},fromEmbedUrl:e=>{const t=De(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=De(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=De(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=De(e);if(t&&t.hash.match(/#room=/))return e},fromEmbedUrl:e=>{const t=De(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=De(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=De(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-*`}},{type:"desmos",title:"Desmos",hostnames:["desmos.com"],width:700,height:450,doesResize:!0,toEmbedUrl:e=>{const t=De(e);if(t&&t.hostname==="www.desmos.com"&&t.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&t.search===""&&t.hash==="")return`${e}?embed`},fromEmbedUrl:e=>{const t=De(e);if(t&&t.hostname==="www.desmos.com"&&t.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&t.search==="?embed"&&t.hash==="")return e.replace("?embed","")}}],n9={"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},j_={w:Pt,h:Pt,url:fe},_d=Zr("embed",{GenOriginalUrlInEmbed:1,RemoveDoesResize:2,RemoveTmpOldUrl:3,RemovePermissionOverrides:4}),O_={sequence:[{id:_d.GenOriginalUrlInEmbed,up:e=>{try{const t=e.url,n=new URL(t).host.replace("www.","");let r;for(const o of Hu)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:"retired"},{id:_d.RemoveDoesResize,up:e=>{delete e.doesResize},down:"retired"},{id:_d.RemoveTmpOldUrl,up:e=>{delete e.tmpOldUrl},down:"retired"},{id:_d.RemovePermissionOverrides,up:e=>{delete e.overridePermissions},down:"retired"}]},D_={w:Pt,h:Pt,name:fe},R_={sequence:[]},Np=qt.defineEnum("tldraw:horizontalAlign",{defaultValue:"middle",values:["start","middle","end","start-legacy","end-legacy","middle-legacy"]}),Fp=qt.defineEnum("tldraw:verticalAlign",{defaultValue:"middle",values:["start","middle","end"]}),Ur=qt.defineEnum("tldraw:geo",{defaultValue:"rectangle",values:["cloud","rectangle","ellipse","triangle","diamond","pentagon","hexagon","octagon","star","rhombus","rhombus-2","oval","trapezoid","arrow-right","arrow-left","arrow-up","arrow-down","x-box","check-box","heart"]}),L_={geo:Ur,labelColor:y_,color:cr,fill:Fi,dash:Ni,size:Co,font:Po,align:Np,verticalAlign:Fp,url:lr,w:Pt,h:Pt,growY:jp,text:fe,scale:Pt},Ro=Zr("geo",{AddUrlProp:1,AddLabelColor:2,RemoveJustify:3,AddCheckBox:4,AddVerticalAlign:5,MigrateLegacyAlign:6,AddCloud:7,MakeUrlsValid:8,AddScale:9}),$_={sequence:[{id:Ro.AddUrlProp,up:e=>{e.url=""},down:"retired"},{id:Ro.AddLabelColor,up:e=>{e.labelColor="black"},down:"retired"},{id:Ro.RemoveJustify,up:e=>{e.align==="justify"&&(e.align="start")},down:"retired"},{id:Ro.AddCheckBox,up:e=>{},down:"retired"},{id:Ro.AddVerticalAlign,up:e=>{e.verticalAlign="middle"},down:"retired"},{id:Ro.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:"retired"},{id:Ro.AddCloud,up:e=>{},down:"retired"},{id:Ro.MakeUrlsValid,up:e=>{lr.isValid(e.url)||(e.url="")},down:e=>{}},{id:Ro.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}}]},N_={},F_={sequence:[]},z_={color:cr,size:Co,segments:Ht(T_),isComplete:Se,isPen:Se,scale:Pt},r9=Zr("highlight",{AddScale:1}),B_={sequence:[{id:r9.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}}]},o9=xe({topLeft:$i,bottomRight:$i}),U_={w:Pt,h:Pt,playing:Se,url:lr,assetId:Wf.nullable(),crop:o9.nullable(),flipX:Se,flipY:Se},Td=Zr("image",{AddUrlProp:1,AddCropProp:2,MakeUrlsValid:3,AddFlipProps:4}),H_={sequence:[{id:Td.AddUrlProp,up:e=>{e.url=""},down:"retired"},{id:Td.AddCropProp,up:e=>{e.crop=null},down:e=>{delete e.crop}},{id:Td.MakeUrlsValid,up:e=>{lr.isValid(e.url)||(e.url="")},down:e=>{}},{id:Td.AddFlipProps,up:e=>{e.flipX=!1,e.flipY=!1},down:e=>{delete e.flipX,delete e.flipY}}]},zp=qt.defineEnum("tldraw:spline",{defaultValue:"line",values:["cubic","line"]}),s9=xe({id:fe,index:e0,x:he,y:he}),K_={color:cr,dash:Ni,size:Co,spline:zp,points:Op(fe,s9),scale:Pt},Zl=Zr("line",{AddSnapHandles:1,RemoveExtraHandleProps:2,HandlesToPoints:3,PointIndexIds:4,AddScale:5}),W_={sequence:[{id:Zl.AddSnapHandles,up:e=>{for(const t of Object.values(e.handles))t.canSnap=!0},down:"retired"},{id:Zl.RemoveExtraHandleProps,up:e=>{e.handles=Xk(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(ln);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:Zl.HandlesToPoints,up:e=>{const t=Object.entries(e.handles).map(([n,{x:r,y:o}])=>({x:r,y:o,index:n})).sort(ln);e.points=t.map(({x:n,y:r})=>({x:n,y:r})),delete e.handles},down:e=>{const t=ou(e.points.length);e.handles=Object.fromEntries(e.points.map((n,r)=>[t[r],{x:n.x,y:n.y}])),delete e.points}},{id:Zl.PointIndexIds,up:e=>{const t=ou(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(ln);e.points=t.map(({x:n,y:r})=>({x:n,y:r}))}},{id:Zl.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}}]},G_={color:cr,size:Co,font:Po,fontSizeAdjustment:jp,align:Np,verticalAlign:Fp,growY:jp,url:lr,text:fe,scale:Pt},wi=Zr("note",{AddUrlProp:1,RemoveJustify:2,MigrateLegacyAlign:3,AddVerticalAlign:4,MakeUrlsValid:5,AddFontSizeAdjustment:6,AddScale:7}),V_={sequence:[{id:wi.AddUrlProp,up:e=>{e.url=""},down:"retired"},{id:wi.RemoveJustify,up:e=>{e.align==="justify"&&(e.align="start")},down:"retired"},{id:wi.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:"retired"},{id:wi.AddVerticalAlign,up:e=>{e.verticalAlign="middle"},down:"retired"},{id:wi.MakeUrlsValid,up:e=>{lr.isValid(e.url)||(e.url="")},down:e=>{}},{id:wi.AddFontSizeAdjustment,up:e=>{e.fontSizeAdjustment=0},down:e=>{delete e.fontSizeAdjustment}},{id:wi.AddScale,up:e=>{e.scale=1},down:e=>{delete e.scale}}]},_S=qt.defineEnum("tldraw:textAlign",{defaultValue:"start",values:["start","middle","end"]}),Y_={color:cr,size:Co,font:Po,textAlign:_S,w:Pt,text:fe,scale:Pt,autoSize:Se},aP=Zr("text",{RemoveJustify:1,AddTextAlign:2}),X_={sequence:[{id:aP.RemoveJustify,up:e=>{e.align==="justify"&&(e.align="start")},down:"retired"},{id:aP.AddTextAlign,up:e=>{e.textAlign=e.align,delete e.align},down:e=>{e.align=e.textAlign,delete e.textAlign}}]},q_={w:Pt,h:Pt,time:he,playing:Se,url:lr,assetId:Wf.nullable()},lP=Zr("video",{AddUrlProp:1,MakeUrlsValid:2}),Z_={sequence:[{id:lP.AddUrlProp,up:e=>{e.url=""},down:"retired"},{id:lP.MakeUrlsValid,up:e=>{lr.isValid(e.url)||(e.url="")},down:e=>{}}]},Md=Vn("com.tldraw.store",{RemoveCodeAndIconShapeTypes:1,AddInstancePresenceType:2,RemoveTLUserAndPresenceAndAddPointer:3,RemoveUserDocument:4}),i9=Va({sequenceId:"com.tldraw.store",retroactive:!1,sequence:[{id:Md.RemoveCodeAndIconShapeTypes,scope:"store",up:e=>{for(const[t,n]of Un(e))n.typeName==="shape"&&(n.type==="icon"||n.type==="code")&&delete e[t]}},{id:Md.AddInstancePresenceType,scope:"store",up(e){}},{id:Md.RemoveTLUserAndPresenceAndAddPointer,scope:"store",up:e=>{for(const[t,n]of Un(e))n.typeName.match(/^(user|user_presence)$/)&&delete e[t]}},{id:Md.RemoveUserDocument,scope:"store",up:e=>{for(const[t,n]of Un(e))n.typeName.match("user_document")&&delete e[t]}}]}),a9={arrow:{migrations:w_,props:x_},bookmark:{migrations:__,props:k_},draw:{migrations:A_,props:M_},embed:{migrations:O_,props:j_},frame:{migrations:R_,props:D_},geo:{migrations:$_,props:L_},group:{migrations:F_,props:N_},highlight:{migrations:B_,props:z_},image:{migrations:H_,props:U_},line:{migrations:W_,props:K_},note:{migrations:V_,props:G_},text:{migrations:X_,props:Y_},video:{migrations:Z_,props:q_}},l9={arrow:{migrations:P_,props:b_}};function c9({shapes:e=a9,bindings:t=l9,migrations:n}={}){const r=new Map;for(const a of gt(e))for(const l of f_(a.props??{}).keys()){if(r.has(l.id)&&r.get(l.id)!==l)throw new Error(`Multiple StyleProp instances with the same id: ${l.id}`);r.set(l.id,l)}const o=yU(e),s=fU(t),i=MU(r);return qx.create({asset:Ii,binding:s,camera:po,document:r0,instance:i,instance_page_state:Br,page:Jo,instance_presence:FU,pointer:n0,shape:o},{migrations:[i9,e9,xU,BU,AU,OU,_U,NU,LU,mU,VU,XU,ZU,...eP("shape",e),...eP("binding",t),...n??[]],onValidationFailure:HU,createIntegrityChecker:WU})}const iu=[{locale:"id",label:"Bahasa Indonesia"},{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 u9(){const e=typeof window<"u"?window.navigator.languages??["en"]:["en"];return d9(e)}function d9(e){for(const t of e){const n=h9(t);if(n)return n}return"en"}const cP={zh:"zh-cn",pt:"pt-br",ko:"ko-kr",hi:"hi-in"};function h9(e){const t=iu.find(o=>o.locale===e.toLowerCase());if(t)return t.locale;const[n,r]=e.split(/[-_]/).map(o=>o.toLowerCase());if(r){const o=iu.find(s=>s.locale===n);if(o)return o.locale}return n in cP?cP[n]:null}function Gf(e,t){const n=Ce.useRef(t);n.current=t;const[r,o,s]=Ce.useMemo(()=>{let i=null;const a=u=>(i=u,()=>{i=null}),l=new kl(`useStateTracking(${e})`,()=>{var u;return(u=n.current)==null?void 0:u.call(n)},{scheduleEffect(){i==null||i()}});return[l,a,()=>l.scheduleCount]},[e]);return Ce.useSyncExternalStore(o,s,s),Ce.useEffect(()=>(r.attach(),r.maybeScheduleEffect(),()=>{r.detach()}),[r]),r.execute()}const uP={apply(e,t,n){return Gf(e.displayName??e.name??"tracked(???)",()=>e.apply(t,n))}},p9=Symbol.for("react.memo"),f9=Symbol.for("react.forward_ref");function Lt(e){let t=null;const n=e.$$typeof;return n===p9&&(e=e.type,t=e.compare),n===f9?P.memo(P.forwardRef(new Proxy(e.render,uP))):P.memo(new Proxy(e,uP),t)}function g9(){const e=arguments[0],t=arguments[1],n=arguments.length===3?void 0:arguments[2],r=arguments.length===3?arguments[2]:arguments[3];return P.useMemo(()=>G(`useComputed(${e})`,t,n),r)}function Ls(e,t,n=Vo){P.useEffect(()=>{const r=new kl(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=P.useRef(!0);r.current=!0;const o=P.useMemo(()=>e.length===1?e[0]:G(n,()=>{if(r.current)return e[1]();try{return e[1]()}catch{return{}}}),t);try{const{subscribe:s,getSnapshot:i}=P.useMemo(()=>({subscribe:a=>ra(`useValue(${n})`,()=>{o.get(),a()}),getSnapshot:()=>o.get()}),[o]);return P.useSyncExternalStore(s,i,i)}finally{r.current=!1}}var Q_={exports:{}};/*!
|
|
49
|
+
Copyright (c) 2018 Jed Watson.
|
|
50
|
+
Licensed under the MIT License (MIT), see
|
|
51
|
+
http://jedwatson.github.io/classnames
|
|
52
|
+
*/(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})()})(Q_);var m9=Q_.exports;const ce=ni(m9),J_="2.4.4",dP={major:"2024-06-28T10:56:07.893Z",minor:"2024-07-22T16:42:50.301Z",patch:"2024-08-05T17:56:04.722Z"},y9={error:null};class e2 extends P.Component{constructor(){super(...arguments);g(this,"state",y9)}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 d.jsx(r,{error:n})}return this.props.children}}function au({children:e,fallback:t,...n}){return t===null?e:d.jsx(e2,{fallback:t,...n,children:e})}const Vf=P.createContext(null);function F(){const e=Ce.useContext(Vf);if(!e)throw new Error("useEditor must be used inside of the <Tldraw /> or <TldrawEditor /> components");return e}function S9(){return d.jsx("div",{className:"tl-background"})}function Ml(e,t,n,r,o,s){P.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 At={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 b{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 b(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=b.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 b.Dpr(this,t)}cpr(t){return b.Cpr(this,t)}len2(){return b.Len2(this)}len(){return b.Len(this)}pry(t){return b.Pry(this,t)}per(){const{x:t,y:n}=this;return this.x=n,this.y=-t,this}uni(){return b.Uni(this)}tan(t){return b.Tan(this,t)}dist(t){return b.Dist(this,t)}distanceToLineSegment(t,n){return b.DistanceToLineSegment(t,n,this)}slope(t){return b.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 b.Angle(this,t)}toAngle(){return b.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 b.Equals(this,t)}equalsXY(t,n){return b.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 b.ToFixed(this)}toString(){return b.ToString(b.ToFixed(this))}toJson(){return b.ToJson(this)}toArray(){return b.ToArray(this)}static Add(t,n){return new b(t.x+n.x,t.y+n.y)}static AddXY(t,n,r){return new b(t.x+n,t.y+r)}static Sub(t,n){return new b(t.x-n.x,t.y-n.y)}static SubXY(t,n,r){return new b(t.x-n,t.y-r)}static AddScalar(t,n){return new b(t.x+n,t.y+n)}static SubScalar(t,n){return new b(t.x-n,t.y-n)}static Div(t,n){return new b(t.x/n,t.y/n)}static Mul(t,n){return new b(t.x*n,t.y*n)}static DivV(t,n){return new b(t.x/n.x,t.y/n.y)}static MulV(t,n){return new b(t.x*n.x,t.y*n.y)}static Neg(t){return new b(-t.x,-t.y)}static Per(t){return new b(t.y,-t.x)}static Abs(t){return new b(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 b(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 b.Dpr(t,n)/b.Len(n)}static Uni(t){return b.Div(t,b.Len(t))}static Tan(t,n){return b.Uni(b.Sub(t,n))}static Min(t,n){return new b(Math.min(t.x,n.x),Math.min(t.y,n.y))}static Max(t,n){return new b(Math.max(t.x,n.x),Math.max(t.y,n.y))}static From({x:t,y:n,z:r=1}){return new b(t,n,r)}static FromArray(t){return new b(t[0],t[1])}static Rot(t,n=0){const r=Math.sin(n),o=Math.cos(n);return new b(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 b(n.x+(o*a-s*i),n.y+(o*i+s*a))}static NearestPointOnLineThroughPoint(t,n,r){return b.Mul(n,b.Sub(r,t).pry(n)).add(t)}static NearestPointOnLineSegment(t,n,r,o=!0){if(b.Equals(t,r)||b.Equals(n,r))return b.From(r);const s=b.Tan(n,t),i=b.Add(t,b.Mul(s,b.Sub(r,t).pry(s)));if(o){if(i.x<Math.min(t.x,n.x))return b.Cast(t.x<n.x?t:n);if(i.x>Math.max(t.x,n.x))return b.Cast(t.x>n.x?t:n);if(i.y<Math.min(t.y,n.y))return b.Cast(t.y<n.y?t:n);if(i.y>Math.max(t.y,n.y))return b.Cast(t.y>n.y?t:n)}return i}static DistanceToLineThroughPoint(t,n,r){return b.Dist(r,b.NearestPointOnLineThroughPoint(t,n,r))}static DistanceToLineSegment(t,n,r,o=!0){return b.Dist(r,b.NearestPointOnLineSegment(t,n,r,o))}static Snap(t,n=1){return new b(Math.round(t.x/n)*n,Math.round(t.y/n)*n)}static Cast(t){return t instanceof b?t:b.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 b.Sub(n,t).mul(r).add(t)}static Med(t,n){return new b((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=b.Len(t);return new b(n*t.x/r,n*t.y/r)}static ScaleWithOrigin(t,n,r){return b.Sub(t,r).mul(n).add(r)}static ToFixed(t){return new b(Uo(t.x),Uo(t.y))}static ToInt(t){return new b(parseInt(t.x.toFixed(0)),parseInt(t.y.toFixed(0)),parseInt((t.z??0).toFixed(0)))}static ToCss(t){return`${t.x},${t.y}`}static Nudge(t,n,r){return b.Add(t,b.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 b(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 b(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 b(Math.min(Math.max(t.x,n)),Math.min(Math.max(t.y,n))):new b(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=At.easeInQuad(s/(r-1)),a=b.Lrp(t,n,i);a.z=Math.min(1,.5+Math.abs(.5-v9(i))*.65),o.push(a)}return o}static SnapToGrid(t,n=8){return new b(Math.round(t.x/n)*n,Math.round(t.y/n)*n)}}const v9=e=>e<.5?2*e*e:-1+(4-2*e)*e;function Te(e){return`${N(e.x)},${N(e.y)} `}function Rn(e,t){return`${N((e.x+t.x)/2)},${N((e.y+t.y)/2)} `}const Me=Math.PI,Ve=Me/2,Le=Me*2,x9=Math.sin;function _t(e,t,n){return Math.max(t,typeof n<"u"?Math.min(e,n):e)}function Ad(e,t=1e10){return e?Math.round(e*t)/t:0}function $s(e,t,n=1e-6){return Math.abs(e-t)<=n}function t2(e,t){const n=Math.pow(e-t,2)/Math.pow(e+t,2);return Me*(e+t)*(1+3*n/(10+Math.sqrt(4-3*n)))}function Ns(e){return e=e%Le,e<0?e=e+Le:e===0&&(e=0),e}function Ku(e,t){return e=Ns(e),t=Ns(t),e>t&&(t+=Le),t-e}function n2(e,t){return Le-Ku(e,t)}function Ah(e,t){const n=(t-e)%Le;return 2*n%Le-n}function TS(e){return(Le+e)%Le}function Bp(e,t){const n=Le/t;let r=Math.floor((TS(e)+n/2)/n)*n%Le;return r<Me&&(r+=Le),r>Me&&(r-=Le),r}function r2(e,t){return e===t||$s(e%(Math.PI/2)-t%(Math.PI/2),0)}function w9(e){return e*Me/180}function b9(e){return e*180/Me}function zi(e,t,n){return new b(e.x,e.y).add(b.FromAngle(n,t))}function km(e,t,n){const r=e/2,o=t/2,s=[];let i=1/0,a=-1/0,l=1/0,c=-1/0;for(let S=0;S<n;S++){const y=Le/n,x=-Ve+S*y,m=r+r*Math.cos(x),v=o+o*Math.sin(x);m<i&&(i=m),v<l&&(l=v),m>a&&(a=m),v>c&&(c=v),s.push(new b(m,v))}const u=a-i,h=c-l,p=e-u,f=t-h;if(p!==0||f!==0)for(let S=0;S<s.length;S++){const y=s[S];y.x=(y.x-i)/u*e,y.y=(y.y-l)/h*t}return s}function Ql(e,t,n,r){return e<r&&n<t}function Lr(e,t,n,r){const o=Math.max(e,n),s=Math.min(t,r);return o<=s?[o,s]:null}function hP(e,t,n){return(t.x-e.x)*(n.y-e.y)-(n.x-e.x)*(t.y-e.y)}function sr(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],b.Dist(e,r)+b.Dist(e,o)===b.Dist(r,o)))return!0;r.y<=e.y?o.y>e.y&&hP(r,o,e)>0&&(n+=1):o.y<=e.y&&hP(r,o,e)<0&&(n-=1)}return n!==0}function N(e){return Math.round(e*1e4)/1e4}function Uo(e){return Math.round(e*100)/100}const pP=e=>Math.abs(e)<Number.MAX_SAFE_INTEGER;function ks(e,t,n){return n<0?Ku(e,t):n2(e,t)}function MS(e,t,n,r){let o;if(Math.abs(e)>Me){o=Ah(t,r);const s=Ah(r,n);return Math.abs(o)<Math.abs(s)?o/e:(e-s)/e}else{o=Ah(t,r);const s=o/e;return Math.sign(o)!==Math.sign(e)?Math.abs(s)>.5?1:0:s}}function P9(e,t,n,r){const o=2*((t-e)%Le)%Le-(t-e)%Le;return r?(Le-Math.abs(o))*(n?1:-1):o}function o0(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);return new b(((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,((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)}function C9(e,t,n,r,o){if(n===null)return[b.From(e),b.From(t)];const s=[],i=b.Angle(n,e),a=b.Angle(n,t),l=Ku(i,a);for(let c=0;c<o;c++){const u=c/(o-1),h=i+l*u,p=zi(n,r,h);s.push(p)}return s}const _m=({brush:e,color:t,opacity:n,className:r})=>{const o=P.useRef(null);Ml(o,e.x,e.y);const s=N(Math.max(1,e.w)),i=N(Math.max(1,e.h));return d.jsx("svg",{className:"tl-overlays__item",ref:o,children:t?d.jsxs("g",{className:"tl-brush",opacity:n,children:[d.jsx("rect",{width:s,height:i,fill:t,opacity:.75}),d.jsx("rect",{width:s,height:i,fill:"none",stroke:t,opacity:.1})]}):d.jsx("rect",{className:`tl-brush tl-brush__default ${r}`,width:s,height:i})})},fP={isLocked:!1,wheelBehavior:"pan",panSpeed:1,zoomSpeed:1,zoomSteps:[.1,.25,.5,1,2,4,8]},Tm={duration:0,easing:At.easeInOutCubic},gP={CAMERA_MOVE:-10},I9=["top","right","bottom","left"],mP=0,s0=2,jd=1,yP=5,E9=128;function Up(e){if(e instanceof HTMLElement)return e;if(e.parentElement)return Up(e.parentElement);throw Error("Could not find a parent element of an HTML type!")}function Ee(e){e.preventDefault(),xt.logPreventDefaults.get()&&console.warn("preventDefault called on event:",e)}function Wu(e,t){if(e.setPointerCapture(t.pointerId),xt.logPointerCaptures.get()){const n=a_.get();n.set(e,(n.get(e)??0)+1),console.warn("setPointerCapture called on element:",e,t)}}function Gu(e,t){if(e.hasPointerCapture(t.pointerId)&&(e.releasePointerCapture(t.pointerId),xt.logPointerCaptures.get())){const n=a_.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 Ot=e=>e.stopPropagation(),nn=(e,t,n)=>{e&&e.style.setProperty(t,n)};function Fn(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 o2(){const e=F();return P.useMemo(function(){let r,o;function s(y){if(!y.isKilled){if(y.button===s0){e.dispatch({type:"pointer",target:"canvas",name:"right_click",...Fn(y)});return}y.button!==0&&y.button!==1&&y.button!==5||(Wu(y.currentTarget,y),e.dispatch({type:"pointer",target:"canvas",name:"pointer_down",...Fn(y)}))}}function i(y){y.isKilled||y.clientX===r&&y.clientY===o||(r=y.clientX,o=y.clientY,e.dispatch({type:"pointer",target:"canvas",name:"pointer_move",...Fn(y)}))}function a(y){y.isKilled||y.button!==0&&y.button!==1&&y.button!==2&&y.button!==5||(r=y.clientX,o=y.clientY,Gu(y.currentTarget,y),e.dispatch({type:"pointer",target:"canvas",name:"pointer_up",...Fn(y)}))}function l(y){if(y.isKilled||e.getInstanceState().isPenMode&&y.pointerType!=="pen")return;const x=y.pointerType==="mouse"||y.pointerType==="pen";e.updateInstanceState({isHoveringCanvas:x?!0:null})}function c(y){if(y.isKilled||e.getInstanceState().isPenMode&&y.pointerType!=="pen")return;const x=y.pointerType==="mouse"||y.pointerType==="pen";e.updateInstanceState({isHoveringCanvas:x?!1:null})}function u(y){y.isKilled=!0,Ee(y)}function h(y){y.isKilled=!0,y.target instanceof HTMLElement&&y.target.tagName!=="A"&&y.target.tagName!=="TEXTAREA"&&!(e.getEditingShape()&&y.target.className.includes("tl-text-content"))&&Ee(y)}function p(y){Ee(y)}async function f(y){var m,v;if(Ee(y),!((v=(m=y.dataTransfer)==null?void 0:m.files)!=null&&v.length))return;const x=Array.from(y.dataTransfer.files);await e.putExternalContent({type:"files",files:x,point:e.screenToPage({x:y.clientX,y:y.clientY}),ignoreParent:!1})}function S(y){Ot(y)}return{onPointerDown:s,onPointerMove:i,onPointerUp:a,onPointerEnter:l,onPointerLeave:c,onDragOver:p,onDrop:f,onTouchStart:u,onTouchEnd:h,onClick:S}},[e])}function k9(){const e=F();P.useEffect(()=>{let t=e.getInstanceState().isCoarsePointer;const n=i=>{const a=i.pointerType!=="mouse";t!==a&&(t=a,e.updateInstanceState({isCoarsePointer:a}))};window.addEventListener("pointerdown",n,{capture:!0});const r=window.matchMedia&&window.matchMedia("(any-pointer: coarse)"),o=e.environment.isFirefox&&!e.environment.isAndroid&&!e.environment.isIos,s=()=>{const i=o?!1:r.matches;t===i&&(t=i,e.updateInstanceState({isCoarsePointer:i}))};return r&&(r.addEventListener("change",s),s()),()=>{window.removeEventListener("pointerdown",n,{capture:!0}),r&&r.removeEventListener("change",s)}},[e])}const s2=P.createContext(null);function _9({container:e,children:t}){return d.jsx(s2.Provider,{value:e,children:t})}function $t(){return xr(P.useContext(s2),"useContainer used outside of <Tldraw />")}function T9(){const e=F(),t=$t(),n=K("isFocused",()=>e.getIsFocused(),[e]);P.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;let r=null;const o=()=>{r!=null&&r();const s=`(resolution: ${window.devicePixelRatio}dppx)`,i=matchMedia(s),a=l=>{l.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]),P.useEffect(()=>{if(!n)return;const r=a=>{if(a.altKey&&(e.isIn("zoom")||!e.getPath().endsWith(".idle"))&&!Od()&&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(Od()||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(),e.focus());return}default:if(Od()||e.getIsMenuOpen())return}const l={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(l)},o=a=>{if(a.isKilled||(a.isKilled=!0,Od()||e.getIsMenuOpen())||a.key===",")return;const l={type:"keyboard",name:"key_up",key:a.key,code:a.code,shiftKey:a.shiftKey,altKey:a.altKey,ctrlKey:a.metaKey||a.ctrlKey};e.dispatch(l)};function s(a){var l,c;if(t.contains(a.target)){const u=a.touches[0].pageX,h=a.touches[0].radiusX||0;(u-h<10||u+h>e.getViewportScreenBounds().width-10)&&(((l=a.target)==null?void 0:l.tagName)==="BUTTON"&&((c=a.target)==null||c.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 M9=["input","select","button","textarea"];function Od(){const{activeElement:e}=document;return!!(e&&(e.getAttribute("contenteditable")||M9.indexOf(e.tagName.toLowerCase())>-1))}const A9=["textarea","input"];function j9(e){const t=F();P.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(A9.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 O9(e,t,n){return Math.max(t,Math.min(e,n))}const Wt={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 SP(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function vP(e,t,n,r=.15){return r===0?O9(e,t,n):e<t?-SP(t-e,n-t,r)+t:e>n?+SP(e-n,n-t,r)+n:e}function D9(e,[t,n],[r,o]){const[[s,i],[a,l]]=e;return[vP(t,s,i,r),vP(n,a,l,o)]}function R9(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 L9(e){var t=R9(e,"string");return typeof t=="symbol"?t:String(t)}function on(e,t,n){return t=L9(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function xP(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 ut(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?xP(Object(n),!0).forEach(function(r){on(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xP(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}const i2={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 wP(e){return e?e[0].toUpperCase()+e.slice(1):""}const $9=["enter","leave"];function N9(e=!1,t){return e&&!$9.includes(t)}function F9(e,t="",n=!1){const r=i2[e],o=r&&r[t]||t;return"on"+wP(e)+wP(o)+(N9(n,o)?"Capture":"")}const z9=["gotpointercapture","lostpointercapture"];function B9(e){let t=e.substring(2).toLowerCase();const n=!!~t.indexOf("passive");n&&(t=t.replace("passive",""));const r=z9.includes(t)?"capturecapture":"capture",o=!!~t.indexOf(r);return o&&(t=t.replace("capture","")),{device:t,capture:o,passive:n}}function U9(e,t=""){const n=i2[e],r=n&&n[t]||t;return e+r}function a2(e){return"touches"in e}function H9(e){return a2(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function K9(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 AS(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 W9(e){return K9(e).map(t=>t.identifier)}function bP(e,t){const[n,r]=Array.from(e.touches).filter(o=>t.includes(o.identifier));return AS(n,r)}const PP=40,CP=800;function l2(e){let{deltaX:t,deltaY:n,deltaMode:r}=e;return r===1?(t*=PP,n*=PP):r===2&&(t*=CP,n*=CP),[t,n]}function G9(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 Hp(e,...t){return typeof e=="function"?e(...t):e}function V9(){}function Y9(...e){return e.length===0?V9:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function IP(e,t){return Object.assign({},t,e||{})}const X9=32;class c2{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?Hp(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,G9(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 _=n._delta.map(Math.abs);Wt.addTo(n._distance,_)}this.axisIntent&&this.axisIntent(t);const[i,a]=n._movement,[l,c]=r.threshold,{_step:u,values:h}=n;if(r.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(i)>=l&&h[0]),u[1]===!1&&(u[1]=Math.abs(a)>=c&&h[1])):(u[0]===!1&&(u[0]=Math.abs(i)>=l&&Math.sign(i)*l),u[1]===!1&&(u[1]=Math.abs(a)>=c&&Math.sign(a)*c)),n.intentional=u[0]!==!1||u[1]!==!1,!n.intentional)return;const p=[0,0];if(r.hasCustomTransform){const[_,I]=h;p[0]=u[0]!==!1?_-u[0]:0,p[1]=u[1]!==!1?I-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,S=n._active&&!n._blocked||n.active;S&&(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=Hp(r.bounds,n)),this.setup&&this.setup()),n.movement=p,this.computeOffset()));const[y,x]=n.offset,[[m,v],[w,C]]=n._bounds;n.overflow=[y<m?-1:y>v?1:0,x<w?-1:x>C?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 E=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=D9(n._bounds,n.offset,E),n.delta=Wt.sub(n.offset,f),this.computeMovement(),S&&(!n.last||s>X9)){n.delta=Wt.sub(n.offset,f);const _=n.delta.map(Math.abs);Wt.addTo(n.distance,_),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&s>0&&(n.velocity=[_[0]/s,_[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(ut(ut(ut({},n),t),{},{[this.aliasKey]:t.values}));o!==void 0&&(t.memo=o)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function q9([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 Z9 extends c2{constructor(...t){super(...t),on(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=Wt.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Wt.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[H9(t)]:r.axisThreshold;n.axis=q9(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 Q9=e=>e,EP=.15,u2={enabled(e=!0){return e},eventOptions(e,t,n){return ut(ut({},n.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[EP,EP];case!1:return[0,0];default:return Wt.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return Wt.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||Q9},threshold(e){return Wt.toVector(e,0)}},J9=0,Vu=ut(ut({},u2),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(e=J9){return e},bounds(e={}){if(typeof e=="function")return s=>Vu.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]]}}),Yu=typeof window<"u"&&window.document&&window.document.createElement;function d2(){return Yu&&"ontouchstart"in window}function e7(){return d2()||Yu&&window.navigator.maxTouchPoints>1}function t7(){return Yu&&"onpointerdown"in window}function n7(){return Yu&&"exitPointerLock"in window.document}function r7(){try{return"constructor"in GestureEvent}catch{return!1}}const wr={isBrowser:Yu,gesture:r7(),touch:d2(),touchscreen:e7(),pointer:t7(),pointerLock:n7()},o7=250,s7=180,i7=.5,a7=50,l7=250,c7=10,kP={mouse:0,touch:0,pen:8};ut(ut({},Vu),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:o=!1}={}}){return this.pointerLock=r&&wr.pointerLock,wr.touch&&n?"touch":this.pointerLock?"mouse":wr.pointer&&!o?"pointer":wr.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?o7:void 0,!(!wr.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=Wt.toVector(e,n?r:o?1:0);return this.filterTaps=n,this.tapsThreshold=r,s},swipe({velocity:e=i7,distance:t=a7,duration:n=l7}={}){return{velocity:this.transform(Wt.toVector(e)),distance:this.transform(Wt.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return s7;case!1:return 0;default:return e}},axisThreshold(e){return e?ut(ut({},kP),e):kP},keyboardDisplacement(e=c7){return e}});function h2(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 u7=30,d7=100;class h7 extends c2{constructor(...t){super(...t),on(this,"ingKey","pinching"),on(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=Wt.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)*u7-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=bP(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=AS(...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=bP(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=AS(...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=Wt.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=[-l2(t)[1]/d7*r.offset[0],0],Wt.addTo(r._movement,r._delta),h2(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 p7=ut(ut({},u2),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!wr.touch&&wr.gesture)return"gesture";if(wr.touch&&r)return"touch";if(wr.touchscreen){if(wr.pointer)return"pointer";if(wr.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const o=i=>{const a=IP(Hp(n,i),{min:-1/0,max:1/0});return[a.min,a.max]},s=i=>{const a=IP(Hp(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",Wt.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});ut(ut({},Vu),{},{mouseOnly:(e=!0)=>e});class f7 extends Z9{constructor(...t){super(...t),on(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=l2(t),Wt.addTo(n._movement,n._delta),h2(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 g7=Vu;ut(ut({},Vu),{},{mouseOnly:(e=!0)=>e});const i0=new Map,jS=new Map;function m7(e){i0.set(e.key,e.engine),jS.set(e.key,e.resolver)}const y7={key:"pinch",engine:h7,resolver:p7},S7={key:"wheel",engine:f7,resolver:g7};function v7(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 x7(e,t){if(e==null)return{};var n=v7(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 w7={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=wr.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},b7=["target","eventOptions","window","enabled","transform"];function jh(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]=jh(e[r],o);break;case"boolean":o&&(n[r]=e[r]);break}return n}function P7(e,t,n={}){const r=e,{target:o,eventOptions:s,window:i,enabled:a,transform:l}=r,c=x7(r,b7);if(n.shared=jh({target:o,eventOptions:s,window:i,enabled:a,transform:l},w7),t){const u=jS.get(t);n[t]=jh(ut({shared:n.shared},c),u)}else for(const u in c){const h=jS.get(u);h&&(n[u]=jh(ut({shared:n.shared},c[u]),h))}return n}class p2{constructor(t,n){on(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=n}add(t,n,r,o,s){const i=this._listeners,a=U9(n,r),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},c=ut(ut({},l),s);t.addEventListener(a,o,c);const u=()=>{t.removeEventListener(a,o,c),i.delete(u)};return i.add(u),u}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class C7{constructor(){on(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 I7{constructor(t){on(this,"gestures",new Set),on(this,"_targetEventStore",new p2(this)),on(this,"gestureEventStores",{}),on(this,"gestureTimeoutStores",{}),on(this,"handlers",{}),on(this,"config",{}),on(this,"pointerIds",new Set),on(this,"touchIds",new Set),on(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),E7(this,t)}setEventIds(t){if(a2(t))return this.touchIds=new Set(W9(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=P7(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],l=_P(r,a.eventOptions,!!o);if(a.enabled){const c=i0.get(i);new c(this,t,i).bind(l)}}const s=_P(r,n.eventOptions,!!o);for(const i in this.nativeHandlers)s(i,"",a=>this.nativeHandlers[i](ut(ut({},this.state.shared),{},{event:a,args:t})),void 0,!0)}for(const s in r)r[s]=Y9(...r[s]);if(!o)return r;for(const s in r){const{device:i,capture:a,passive:l}=B9(s);this._targetEventStore.add(o,i,"",r[s],{capture:a,passive:l})}}}}function pa(e,t){e.gestures.add(t),e.gestureEventStores[t]=new p2(e,t),e.gestureTimeoutStores[t]=new C7}function E7(e,t){t.drag&&pa(e,"drag"),t.wheel&&pa(e,"wheel"),t.scroll&&pa(e,"scroll"),t.move&&pa(e,"move"),t.pinch&&pa(e,"pinch"),t.hover&&pa(e,"hover")}const _P=(e,t,n)=>(r,o,s,i={},a=!1)=>{var l,c;const u=(l=i.capture)!==null&&l!==void 0?l:t.capture,h=(c=i.passive)!==null&&c!==void 0?c:t.passive;let p=a?r:F9(r,o,u);n&&h&&(p+="Passive"),e[p]=e[p]||[],e[p].push(s)},k7=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function _7(e){const t={},n={},r=new Set;for(let o in e)k7.test(o)?(r.add(RegExp.lastMatch),n[o]=e[o]):t[o]=e[o];return[n,t,r]}function fa(e,t,n,r,o,s){if(!e.has(n)||!i0.has(r))return;const i=n+"Start",a=n+"End",l=c=>{let u;return c.first&&i in t&&t[i](c),n in t&&(u=t[n](c)),c.last&&a in t&&t[a](c),u};o[r]=l,s[r]=s[r]||{}}function T7(e,t){const[n,r,o]=_7(e),s={};return fa(o,n,"onDrag","drag",s,t),fa(o,n,"onWheel","wheel",s,t),fa(o,n,"onScroll","scroll",s,t),fa(o,n,"onPinch","pinch",s,t),fa(o,n,"onMove","move",s,t),fa(o,n,"onHover","hover",s,t),{handlers:s,config:t,nativeHandlers:r}}function M7(e,t={},n,r){const o=Ce.useMemo(()=>new I7(e),[]);if(o.applyHandlers(e,r),o.applyConfig(t,n),Ce.useEffect(o.effect.bind(o)),Ce.useEffect(()=>o.clean.bind(o),[]),t.target===void 0)return o.bind.bind(o)}function A7(e){return e.forEach(m7),function(n,r){const{handlers:o,nativeHandlers:s,config:i}=T7(n,r||{});return M7(o,i,void 0,s)}}const TP=10,j7=/Mac|iPod|iPhone|iPad/.test(typeof window>"u"?"node":window.navigator.platform);function f2(e){let{deltaY:t,deltaX:n}=e,r=0;return e.ctrlKey||e.altKey||e.metaKey?r=(Math.abs(t)>TP?TP*Math.sign(t):t)/100:e.shiftKey&&!j7&&(n=t,t=0),{x:-n,y:-t,z:-r}}const O7=A7([S7,y7]);let ga;const D7=e=>ga===void 0?(ga=e,!1):e-ga>120&&e-ga<160?(ga=e,!0):(ga=e,!1);function R7(e){const t=F(),n=P.useMemo(()=>{let r="not sure";const o=({event:y})=>{if(!t.getInstanceState().isFocused||(r="not sure",D7(Date.now())))return;const x=t.getEditingShapeId();if(x){const w=t.getShape(x);if(w&&t.getShapeUtil(w).canScroll(w)){const E=t.getShapePageBounds(x);if(E!=null&&E.containsPoint(t.inputs.currentPagePoint))return}}Ee(y),Ot(y);const m=f2(y);if(m.x===0&&m.y===0)return;const v={type:"wheel",name:"wheel",delta:m,point:new b(y.clientX,y.clientY),shiftKey:y.shiftKey,altKey:y.altKey,ctrlKey:y.metaKey||y.ctrlKey};t.dispatch(v)};let s=1,i=1,a=1,l=0;const c=new b,u=new b,h=y=>{const x=e.current;r="not sure";const{event:m,origin:v,da:w}=y;m instanceof WheelEvent||(m.target===x||x!=null&&x.contains(m.target))&&(u.x=v[0],u.y=v[1],c.x=v[0],c.y=v[1],s=w[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:m.shiftKey,altKey:m.altKey,ctrlKey:m.metaKey||m.ctrlKey}))},p=y=>{if(y&&(r="zooming"),r==="zooming")return;const x=Math.abs(l-s),m=b.Dist(c,u);switch(r){case"not sure":{x>24?r="zooming":m>16&&(r="panning");break}case"panning":{x>64&&(r="zooming");break}}};return{onWheel:o,onPinchStart:h,onPinchEnd:y=>{const x=e.current,{event:m,origin:v,offset:w}=y;if(m instanceof WheelEvent||!(m.target===x||x!=null&&x.contains(m.target)))return;const C=w[0];r="not sure",t.timers.requestAnimationFrame(()=>{t.dispatch({type:"pinch",name:"pinch_end",point:{x:v[0],y:v[1],z:C},delta:{x:v[0],y:v[1]},shiftKey:m.shiftKey,altKey:m.altKey,ctrlKey:m.metaKey||m.ctrlKey})})},onPinch:y=>{const x=e.current,{event:m,origin:v,offset:w,da:C}=y;if(m instanceof WheelEvent||!(m.target===x||x!=null&&x.contains(m.target)))return;const E=y.type==="gesturechange"||y.type==="gestureend";l=C[0];const _=v[0]-u.x,I=v[1]-u.y;switch(u.x=v[0],u.y=v[1],p(E),r){case"zooming":{a=w[0],t.dispatch({type:"pinch",name:"pinch",point:{x:v[0],y:v[1],z:a},delta:{x:_,y:I},shiftKey:m.shiftKey,altKey:m.altKey,ctrlKey:m.metaKey||m.ctrlKey});break}case"panning":{t.dispatch({type:"pinch",name:"pinch",point:{x:v[0],y:v[1],z:i},delta:{x:_,y:I},shiftKey:m.shiftKey,altKey:m.altKey,ctrlKey:m.metaKey||m.ctrlKey});break}}}}},[t,e]);O7(n,{target:e,eventOptions:{passive:!1},pinch:{from:()=>[t.getZoomLevel(),0],scaleBounds:()=>({from:t.getZoomLevel(),max:8,min:.05})}})}function Mm(e,t,n){const r=e.getShape(t),o=e.getShapeHandles(r);return{shape:r,handle:o.find(s=>s.id===n)}}function L7(e,t){const n=F();return P.useMemo(()=>{const r=l=>{if(l.isKilled)return;const c=Up(l.currentTarget);Wu(c,l);const{shape:u,handle:h}=Mm(n,e,t);h&&n.dispatch({type:"pointer",target:"handle",handle:h,shape:u,name:"pointer_down",...Fn(l)})};let o,s;return{onPointerDown:r,onPointerMove:l=>{if(l.isKilled||l.clientX===o&&l.clientY===s)return;o=l.clientX,s=l.clientY;const{shape:c,handle:u}=Mm(n,e,t);u&&n.dispatch({type:"pointer",target:"handle",handle:u,shape:c,name:"pointer_move",...Fn(l)})},onPointerUp:l=>{if(l.isKilled)return;const c=Up(l.currentTarget);Gu(c,l);const{shape:u,handle:h}=Mm(n,e,t);h&&n.dispatch({type:"pointer",target:"handle",handle:h,shape:u,name:"pointer_up",...Fn(l)})}}},[n,e,t])}const et=class et{constructor(t=0,n=0,r=0,o=0){g(this,"x",0);g(this,"y",0);g(this,"w",0);g(this,"h",0);this.x=t,this.y=n,this.w=r,this.h=o}get point(){return new b(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 b(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 b(this.minX,this.minY),new b(this.maxX,this.minY),new b(this.maxX,this.maxY),new b(this.minX,this.maxY)]}get cornersAndCenter(){return[new b(this.minX,this.minY),new b(this.maxX,this.minY),new b(this.maxX,this.maxY),new b(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 b(this.w,this.h)}toFixed(){return this.x=Ad(this.x),this.y=Ad(this.y),this.w=Ad(this.w),this.h=Ad(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 et(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 et.Collides(this,t)}contains(t){return et.Contains(this,t)}includes(t){return et.Includes(this,t)}containsPoint(t,n=0){return et.ContainsPoint(this,t,n)}getHandlePoint(t){switch(t){case"top_left":return new b(this.minX,this.minY);case"top_right":return new b(this.maxX,this.minY);case"bottom_left":return new b(this.minX,this.maxY);case"bottom_right":return new b(this.maxX,this.maxY);case"top":return new b(this.midX,this.minY);case"right":return new b(this.maxX,this.midY);case"bottom":return new b(this.midX,this.maxY);case"left":return new b(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:l,minY:c,maxX:u,maxY:h}=this;switch(t){case"left":case"top_left":case"bottom_left":{l+=n;break}case"right":case"top_right":case"bottom_right":{u+=n;break}}switch(t){case"top":case"top_left":case"top_right":{c+=r;break}case"bottom":case"bottom_left":case"bottom_right":{h+=r;break}}const p=(u-l)/(i-o),f=(h-c)/(a-s),S=p<0,y=f<0;if(S){const x=u;u=l,l=x}if(y){const x=h;h=c,c=x}this.minX=l,this.minY=c,this.width=Math.abs(u-l),this.height=Math.abs(h-c)}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 et(t.x,t.y,t.w,t.h)}static FromCenter(t,n){return new et(t.x-n.x/2,t.y-n.y/2,n.x,n.y)}static FromPoints(t){if(t.length===0)return new et;let n=1/0,r=1/0,o=-1/0,s=-1/0,i;for(let a=0,l=t.length;a<l;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 et(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 et(r,o,s-r,i-o)}static ExpandBy(t,n){return new et(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:l,maxY:c}=t;let{minX:u,minY:h,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":{h+=o;break}case"bottom":case"bottom_left":case"bottom_right":{f+=o;break}}const S=(p-u)/(l-i),y=(f-h)/(c-a),x=S<0,m=y<0;if(s){const w=(l-i)/(c-a),C=Math.abs(p-u),E=Math.abs(f-h),_=C*(y<0?1:-1)*(1/w),I=E*(S<0?1:-1)*w,k=w<C/E;switch(n){case"top_left":{k?h=f+_:u=p+I;break}case"top_right":{k?h=f+_:p=u-I;break}case"bottom_right":{k?f=h-_:p=u-I;break}case"bottom_left":{k?f=h-_:u=p+I;break}case"bottom":case"top":{const T=(u+p)/2,M=E*w;u=T-M/2,p=T+M/2;break}case"left":case"right":{const T=(h+f)/2,M=C/w;h=T-M/2,f=T+M/2;break}}}if(x){const w=p;p=u,u=w}if(m){const w=f;f=h,h=w}const v=new et(u,h,Math.abs(p-u),Math.abs(f-h));return{box:v,scaleX:+(v.width/t.width*(S>0?1:-1)).toFixed(5),scaleY:+(v.height/t.height*(y>0?1:-1)).toFixed(5)}}equals(t){return et.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 et(t.x,t.y,Math.max(1,t.w),Math.max(1,t.h))}};g(et,"Collides",(t,n)=>!(t.maxX<n.minX||t.minX>n.maxX||t.maxY<n.minY||t.minY>n.maxY)),g(et,"Contains",(t,n)=>t.minX<n.minX&&t.minY<n.minY&&t.maxY>n.maxY&&t.maxX>n.maxX),g(et,"Includes",(t,n)=>et.Collides(t,n)||et.Contains(t,n)),g(et,"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)),g(et,"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 et(n,r,o-n,s-r)}),g(et,"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 Q=et;function $7(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 N7(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 F7(e){return e==="top_left"||e==="top_right"||e==="bottom_right"||e==="bottom_left"}function z7(e){const t=F();P.useLayoutEffect(()=>{let n=new Q;function r(){const c=e.current;if(!c)return null;const u=c.getBoundingClientRect(),h=new Q(u.left||u.x,u.top||u.y,Math.max(u.width,1),Math.max(u.height,1));n.equals(h)||(t.updateViewportScreenBounds(h),n=h)}r();const o=$k(r,200,{trailing:!0}),s=t.timers.setInterval(o,1e3);window.addEventListener("resize",o);const i=new ResizeObserver(c=>{c[0].contentRect&&o()}),a=e.current;let l=null;return a&&(i.observe(a),l=B7(a),l.addEventListener("scroll",o)),()=>{clearInterval(s),window.removeEventListener("resize",o),i.disconnect(),l==null||l.removeEventListener("scroll",o),o.cancel()}},[t,e])}/*!
|
|
53
|
+
* Author: excalidraw
|
|
54
|
+
* MIT License: https://github.com/excalidraw/excalidraw/blob/master/LICENSE
|
|
55
|
+
* https://github.com/excalidraw/excalidraw/blob/48c3465b19f10ec755b3eb84e21a01a468e96e43/packages/excalidraw/utils.ts#L600
|
|
56
|
+
*/const B7=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},Re=class Re{constructor(t,n,r,o,s,i){g(this,"a",1);g(this,"b",0);g(this,"c",0);g(this,"d",1);g(this,"e",0);g(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:l}=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+l,this}rotate(t,n,r){return t===0?this:n===void 0?this.multiply(Re.Rotate(t)):this.translate(n,r).multiply(Re.Rotate(t)).translate(-n,-r)}translate(t,n){return this.multiply(Re.Translate(t,n))}scale(t,n){return this.multiply(Re.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 Re.applyToPoint(this,t)}applyToPoints(t){return Re.applyToPoints(this,t)}rotation(){return Re.Rotation(this)}point(){return Re.Point(this)}decomposed(){return Re.Decompose(this)}toCssString(){return Re.toCssString(this)}setTo(t){return Object.assign(this,t),this}decompose(){return Re.Decompose(this)}clone(){return new Re(this.a,this.b,this.c,this.d,this.e,this.f)}static Identity(){return new Re(1,0,0,1,0,0)}static Translate(t,n){return new Re(1,0,0,1,t,n)}static Rotate(t,n,r){if(t===0)return Re.Identity();const o=Math.cos(t),s=Math.sin(t),i=new Re(o,s,-s,o,0,0);return n===void 0?i:Re.Compose(Re.Translate(n,r),i,Re.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=Re.Identity();for(let r=0,o=t.length;r<o;r++)n.multiply(t[r]);return n}static Point(t){return new b(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=Ve+Math.acos(t.b/r)*(t.d>0?-1:1)}else n=0;return TS(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=Ve+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:TS(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(${N(t.a)}, ${N(t.b)}, ${N(t.c)}, ${N(t.d)}, ${N(t.e)}, ${N(t.f)})`}static applyToPoint(t,n){return new b(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 b(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 Q(t.e+n.minX,t.f+n.minY,n.width,n.height)}static From(t){return new Re(t.a,t.b,t.c,t.d,t.e,t.f)}static Cast(t){return t instanceof Re?t:Re.From(t)}};g(Re,"Scale",(t,n,r,o)=>{const s=new Re(t,0,0,n,0,0);return r===void 0?s:Re.Compose(Re.Translate(r,o),s,Re.Translate(-r,-o))});let se=Re;function g2(e,t){return t===0?e:g2(t,e%t)}function m2(e){const t=e.toString().split(".")[1];if(!t)return 1;const n=Math.pow(10,t.length),r=parseInt(t,10);return n/g2(r,n)}class ii{constructor(t){g(this,"isFilled",!1);g(this,"isClosed",!0);g(this,"isLabel",!1);g(this,"debugColor");g(this,"ignore");g(this,"_vertices");g(this,"_bounds");g(this,"_area");g(this,"_length");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)&&sr(t,this.vertices)?!0:b.Dist2(t,this.nearestPoint(t))<=n*n}distanceToPoint(t,n=!1){return t.dist(this.nearestPoint(t))*(this.isClosed&&(this.isFilled||n)&&sr(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,l;for(let c=0;c<r.length;c++)a=r[c],l=b.NearestPointOnLineSegment(t,n,a,!0),i=b.Dist2(a,l),i<s&&(s=i,o=l);if(!o)throw Error("nearest point not found");return this.isClosed&&this.isFilled&&sr(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,l;for(let c=0;c<r.length;c++)a=r[c],l=b.NearestPointOnLineSegment(t,n,a,!0),i=b.Dist2(a,l),i<s&&(s=i,o=l);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 Q.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}get length(){return this._length?this._length:(this._length=this.getLength(),this._length)}getLength(){const{vertices:t}=this;let n,r=t[0],o=0;for(let s=1;s<t.length;s++)n=t[s],o+=b.Dist2(r,n),r=n;return Math.sqrt(o)}}class Gr extends ii{constructor(n){super({...n,isClosed:!0,isFilled:!1});g(this,"children",[]);g(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 l of s)i=l.nearestPoint(n),a=b.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=Q.FromPoints(this.vertices).corners;for(let o=0,s=r.length;o<s;o++){const i=r[o],a=r[(o-1+s)%s],l=i.dist(a),c=r[(o+1)%s],u=i.dist(c),h=i.clone().lrp(a,4/l),p=i,f=i.clone().lrp(c,4/u);n+=`M${h.x},${h.y} L${p.x},${p.y} L${f.x},${f.y} `}return n}getLength(){return this.children.reduce((n,r)=>r.isLabel?n:n+r.length,0)}getSvgPathData(){return this.children.map((n,r)=>n.isLabel?"":n.getSvgPathData(r===0)).join(" ")}}function U7(e=!0){const[t,n]=P.useState(0),r=F();P.useEffect(()=>{if(!e)return;const o=()=>n(s=>s+1);return r.on("tick",o),()=>{r.off("tick",o)}},[r,e])}const H7=Lt(function({showStroke:t=!0,showVertices:n=!0,showClosestPointOnOutline:r=!0}){const o=F();U7(r);const s=o.getZoomLevel(),i=o.getRenderingShapes(),{inputs:{currentPagePoint:a}}=o;return d.jsx("svg",{style:{position:"absolute",pointerEvents:"none",zIndex:999999999,top:0,left:0,overflow:"visible"},children:i.map(l=>{const c=o.getShape(l.id);if(c.type==="group")return null;const u=o.getShapeGeometry(c),h=o.getShapePageTransform(c),p=o.getPointInShapeSpace(c,a),f=u.nearestPoint(p),S=u.distanceToPoint(p,!0),y=Math.abs(S)*s,x=S<0,{vertices:m}=u;return d.jsxs("g",{transform:h.toCssString(),strokeLinecap:"round",strokeLinejoin:"round",children:[t&&d.jsx("g",{stroke:u.debugColor??"red",opacity:"1",strokeWidth:2/s,fill:"none",children:d.jsx(y2,{geometry:u})}),n&&m.map((v,w)=>d.jsx("circle",{cx:v.x,cy:v.y,r:2/s,fill:`hsl(${il(w,[0,m.length-1],[120,200])}, 100%, 50%)`,stroke:"black",strokeWidth:1/s},`v${w}`)),r&&y<150&&d.jsx("line",{x1:f.x,y1:f.y,x2:p.x,y2:p.y,opacity:1-y/150,stroke:x?"goldenrod":"dodgerblue",strokeWidth:2/s})]},l.id+"_outline")})})});function y2({geometry:e}){return e instanceof Gr?d.jsx(d.Fragment,{children:[...e.children,...e.ignoredChildren].map((t,n)=>d.jsx(y2,{geometry:t},n))}):d.jsx("path",{d:e.toSimpleSvgPath()})}function S2(e){return fB(e)}function v2(){const e=F(),t=g9("userIds",()=>S2(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 Yf(e){const t=F();return K(`latestPresence:${e}`,()=>t.getCollaborators().find(r=>r.userId===e),[t,e])??null}const K7=Lt(function(){return v2().map(n=>d.jsx(W7,{collaboratorId:n},n))}),W7=Lt(function({collaboratorId:t}){const n=F(),r=Yf(t),o=V7(n,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 d.jsx(G7,{latestPresence:r})}),G7=Lt(function({latestPresence:t}){const n=F(),{CollaboratorBrush:r,CollaboratorScribble:o,CollaboratorCursor:s,CollaboratorHint:i,CollaboratorShapeIndicator:a}=st(),l=n.getZoomLevel(),c=n.getViewportPageBounds(),{userId:u,chatMessage:h,brush:p,scribbles:f,selectedShapeIds:S,userName:y,cursor:x,color:m}=t,v=!(x.x<c.minX-12/l||x.y<c.minY-16/l||x.x>c.maxX-12/l||x.y>c.maxY-16/l);return d.jsxs(d.Fragment,{children:[p&&r?d.jsx(r,{className:"tl-collaborator__brush",brush:p,color:m,opacity:.1},u+"_brush"):null,v&&s?d.jsx(s,{className:"tl-collaborator__cursor",point:x,color:m,zoom:l,name:y!=="New User"?y:null,chatMessage:h},u+"_cursor"):i?d.jsx(i,{className:"tl-collaborator__cursor-hint",point:x,color:m,zoom:l,viewport:c},u+"_cursor_hint"):null,o&&f.length?d.jsx(d.Fragment,{children:f.map(w=>d.jsx(o,{className:"tl-collaborator__scribble",scribble:w,color:m,zoom:l,opacity:w.color==="laser"?.5:.1},u+"_scribble_"+w.id))}):null,a&&S.map(w=>d.jsx(a,{className:"tl-collaborator__shape-indicator",shapeId:w,color:m,opacity:.5},u+"_"+w))]})});function MP(e,t){return t>e.options.collaboratorInactiveTimeoutMs?"inactive":t>e.options.collaboratorIdleTimeoutMs?"idle":"active"}function V7(e,t){const n=P.useRef((t==null?void 0:t.lastActivityTimestamp)??-1),[r,o]=P.useState(()=>MP(e,Date.now()-n.current));return P.useEffect(()=>{const s=e.timers.setInterval(()=>{o(MP(e,Date.now()-n.current))},e.options.collaboratorCheckIntervalMs);return()=>clearInterval(s)},[e]),t&&(n.current=t.lastActivityTimestamp),r}const x2=P.memo(function({id:t,shape:n,util:r,index:o,backgroundIndex:s,opacity:i,dprMultiple:a}){const l=F(),{ShapeErrorFallback:c}=st(),u=P.useRef(null),h=P.useRef(null),p=P.useRef({transform:"",clipPath:"none",width:0,height:0,x:0,y:0,isCulled:!1});Ls("set shape stuff",()=>{const y=l.getShape(t);if(!y)return;const x=p.current,m=l.getShapeClipPath(t)??"none";m!==x.clipPath&&(nn(u.current,"clip-path",m),nn(h.current,"clip-path",m),x.clipPath=m);const v=l.getShapePageTransform(t),w=se.toCssString(v),C=l.getShapeGeometry(y).bounds;w!==x.transform&&(nn(u.current,"transform",w),nn(h.current,"transform",w),x.transform=w);const E=C.w%a,_=C.h%a,I=E===0?C.w:C.w+(a-E),k=_===0?C.h:C.h+(a-_);(I!==x.width||k!==x.height)&&(nn(u.current,"width",Math.max(I,a)+"px"),nn(u.current,"height",Math.max(k,a)+"px"),nn(h.current,"width",Math.max(I,a)+"px"),nn(h.current,"height",Math.max(k,a)+"px"),x.width=I,x.height=k)},[l]),Ls("set opacity and z-index",()=>{const y=u.current,x=h.current;nn(y,"opacity",i),nn(x,"opacity",i),nn(y,"z-index",o),nn(x,"z-index",s)},[i,o,s]),Ls("set display",()=>{if(!l.getShape(t))return;const m=l.getCulledShapes().has(t);m!==p.current.isCulled&&(nn(u.current,"display",m?"none":"block"),nn(h.current,"display",m?"none":"block"),p.current.isCulled=m)},[l]);const f=P.useCallback(y=>l.annotateError(y,{origin:"shape",willCrashApp:!1}),[l]);if(!n)return null;const S="fill"in n.props&&n.props.fill!=="none";return d.jsxs(d.Fragment,{children:[r.backgroundComponent&&d.jsx("div",{ref:h,className:"tl-shape tl-shape-background","data-shape-type":n.type,draggable:!1,children:d.jsx(au,{fallback:c,onError:f,children:d.jsx(X7,{shape:n,util:r})})}),d.jsx("div",{ref:u,className:"tl-shape","data-shape-type":n.type,"data-shape-is-filled":S,draggable:!1,children:d.jsx(au,{fallback:c,onError:f,children:d.jsx(Y7,{shape:n,util:r})})})]})}),Y7=P.memo(function({shape:t,util:n}){return Gf("InnerShape:"+t.type,()=>n.component(n.editor.store.unsafeGetWithoutCapture(t.id)))},(e,t)=>e.shape.props===t.shape.props&&e.shape.meta===t.shape.meta),X7=P.memo(function({shape:t,util:n}){return Gf("InnerShape:"+t.type,()=>{var r;return(r=n.backgroundComponent)==null?void 0:r.call(n,n.editor.store.unsafeGetWithoutCapture(t.id))})},(e,t)=>e.shape.props===t.shape.props&&e.shape.meta===t.shape.meta);function q7({className:e}){const t=F(),{Background:n,SvgDefs:r,ShapeIndicators:o}=st(),s=P.useRef(null),i=P.useRef(null),a=P.useRef(null),l=$t();z7(s),T9(),k9(),R7(s),j9(s);const c=P.useRef({lodDisableTextOutline:!1,allowTextOutline:!0});Ls("position layers",function(){const{x:v,y:w,z:C}=t.getCamera();if(c.current.allowTextOutline&&t.environment.isSafari&&(l.style.setProperty("--tl-text-outline","none"),c.current.allowTextOutline=!1),c.current.allowTextOutline&&C<t.options.textShadowLod!==c.current.lodDisableTextOutline){const I=C<t.options.textShadowLod;l.style.setProperty("--tl-text-outline",I?"none":"var(--tl-text-outline-reference)"),c.current.lodDisableTextOutline=I}const E=C>=1?il(C,[1,8],[.125,.5],!0):il(C,[.1,1],[-2,.125],!0),_=`scale(${N(C)}) translate(${N(v+E)}px,${N(w+E)}px)`;nn(i.current,"transform",_),nn(a.current,"transform",_)},[t,l]);const u=o2(),h=K("shapeSvgDefs",()=>{const m=new Map;for(const v of gt(t.shapeUtils)){if(!v)return;const w=v.getCanvasSvgDefs();for(const{key:C,component:E}of w)m.has(C)||m.set(C,d.jsx(E,{},C))}return[...m.values()]},[t]),p=K("debug_shapes",()=>xt.hideShapes.get(),[xt]),f=K("debug_svg",()=>xt.debugSvg.get(),[xt]),S=K("debug_geometry",()=>xt.debugGeometry.get(),[xt]),y=K("isEditingAnything",()=>t.getEditingShapeId()!==null,[t]),x=K("isSelectingAnything",()=>!!t.getSelectedShapeIds().length,[t]);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{ref:s,draggable:!1,"data-iseditinganything":y,"data-isselectinganything":x,className:ce("tl-canvas",e),"data-testid":"canvas",...u,children:[d.jsx("svg",{className:"tl-svg-context",children:d.jsxs("defs",{children:[h,d.jsx(uH,{}),d.jsx(dH,{}),r&&d.jsx(r,{})]})}),n&&d.jsx("div",{className:"tl-background__wrapper",children:d.jsx(n,{})}),d.jsx(Q7,{}),d.jsxs("div",{ref:i,className:"tl-html-layer tl-shapes",draggable:!1,children:[d.jsx(gH,{}),d.jsx(fH,{}),p?null:f?d.jsx(iH,{}):d.jsx(lH,{})]}),d.jsx("div",{className:"tl-overlays",children:d.jsxs("div",{ref:a,className:"tl-html-layer",children:[S?d.jsx(H7,{}):null,d.jsx(rH,{}),d.jsx(eH,{}),d.jsx(J7,{}),d.jsx(tH,{}),o&&d.jsx(o,{}),d.jsx(cH,{}),d.jsx(nH,{}),d.jsx(pH,{}),d.jsx(K7,{})]})}),d.jsx(mH,{})]}),d.jsx(Z7,{})]})}function Z7(){const{InFrontOfTheCanvas:e}=st();return e?d.jsx(e,{}):null}function Q7(){const e=F(),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}=st();return i&&s?d.jsx(i,{x:n,y:r,z:o,size:t}):null}function J7(){const e=F(),t=K("scribbles",()=>e.getInstanceState().scribbles,[e]),n=K("zoomLevel",()=>e.getZoomLevel(),[e]),{Scribble:r}=st();return r&&t.length?t.map(o=>d.jsx(r,{className:"tl-user-scribble",scribble:o,zoom:n},o.id)):null}function eH(){const e=F(),t=K("brush",()=>e.getInstanceState().brush,[e]),{Brush:n}=st();return n&&t?d.jsx(n,{className:"tl-user-brush",brush:t}):null}function tH(){const e=F(),t=K("zoomBrush",()=>e.getInstanceState().zoomBrush,[e]),{ZoomBrush:n}=st();return n&&t?d.jsx(n,{className:"tl-user-brush tl-zoom-brush",brush:t}):null}function nH(){const e=F(),t=K("snapLines",()=>e.snaps.getIndicators(),[e]),n=K("zoomLevel",()=>e.getZoomLevel(),[e]),{SnapIndicator:r}=st();return r&&t.length>0?t.map(o=>d.jsx(r,{className:"tl-user-snapline",line:o,zoom:n},o.id)):null}function rH(){const e=F(),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?d.jsx(oH,{shapeId:t}):null}function oH({shapeId:e}){const t=F(),{Handles:n}=st(),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 l=(o?t.options.coarseHandleRadius:t.options.handleRadius)/r*2;return a.filter(c=>c.type!=="virtual"||!a.some(u=>u!==c&&u.type==="vertex"&&b.Dist(c,u)<l)).sort(c=>c.type==="vertex"?1:-1)},[t,r,o,e]);return!n||!i||!s?null:d.jsx(n,{children:d.jsx("g",{transform:se.toCssString(s),children:i.map(a=>d.jsx(sH,{shapeId:e,handle:a,zoom:r,isCoarse:o},a.id))})})}function sH({shapeId:e,handle:t,zoom:n,isCoarse:r}){const o=L7(e,t.id),{Handle:s}=st();return s?d.jsx("g",{"aria-label":"handle",transform:`translate(${t.x}, ${t.y})`,...o,children:d.jsx(s,{shapeId:e,handle:t,zoom:n,isCoarse:r})}):null}function iH(){const e=F(),t=K("rendering shapes",()=>e.getRenderingShapes(),[e]),n=K("dpr multiple",()=>m2(Math.floor(e.getInstanceState().devicePixelRatio*100)/100),[e]);return t.map(r=>d.jsxs(P.Fragment,{children:[d.jsx(x2,{...r,dprMultiple:n}),d.jsx(hH,{id:r.id})]},r.id+"_fragment"))}function aH(){const e=F(),t=P.useRef(new Set);return Ls("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 lH(){const e=F(),t=K("rendering shapes",()=>e.getRenderingShapes(),[e]),n=K("dpr multiple",()=>m2(Math.floor(e.getInstanceState().devicePixelRatio*100)/100),[e]);return d.jsxs(d.Fragment,{children:[t.map(r=>d.jsx(x2,{...r,dprMultiple:n},r.id+"_shape")),e.environment.isSafari&&d.jsx(aH,{})]})}function cH(){const e=F(),{ShapeIndicator:t}=st(),n=K("hinting shape ids",()=>Bx(e.getHintingShapeIds()),[e]);return!n.length||!t?null:n.map(r=>d.jsx(t,{className:"tl-user-indicator__hint",shapeId:r},r+"_hinting"))}function uH(){return d.jsxs("g",{id:"cursor",children:[d.jsxs("g",{fill:"rgba(0,0,0,.2)",transform:"translate(-11,-11)",children:[d.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),d.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),d.jsxs("g",{fill:"white",transform:"translate(-12,-12)",children:[d.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),d.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),d.jsxs("g",{fill:"currentColor",transform:"translate(-12,-12)",children:[d.jsx("path",{d:"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"}),d.jsx("path",{d:"m13 10.814v11.188l2.969-2.866.428-.139h4.768z"})]})]})}function dH(){return d.jsx("path",{id:"cursor_hint",fill:"currentColor",d:"M -2,-5 2,0 -2,5 Z"})}function hH({id:e}){const t=F(),[n,r]=P.useState(null),o=K("is in root",()=>{const s=t.getShape(e);return(s==null?void 0:s.parentId)===t.getCurrentPageId()},[t,e]);return P.useEffect(()=>{if(!o)return;let s=null;const i=ra("shape to svg",async()=>{const a=Math.random();s=a;const c=t.isShapeOfType(e,"frame")?0:10;let u=t.getShapePageBounds(e);if(!u)return;u=u.clone().expandBy(c);const h=await t.getSvgString([e],{padding:c,background:t.getInstanceState().exportBackground});if(s!==a||!h)return;const p=`data:image/svg+xml;utf8,${encodeURIComponent(h.svg)}`;r({src:p,bounds:u})});return()=>{s=null,i()}},[t,e,o]),!o||!n?null:d.jsx("img",{src:n.src,width:n.bounds.width,height:n.bounds.height,referrerPolicy:"no-referrer",style:{position:"absolute",top:0,left:0,transform:`translate(${n.bounds.x}px, ${n.bounds.maxY+12}px)`,outline:"1px solid black",maxWidth:"none"}})}function pH(){const e=F(),t=K("selection rotation",()=>e.getSelectionRotation(),[e]),n=K("selection bounds",()=>e.getSelectionRotatedPageBounds(),[e]),{SelectionForeground:r}=st();return!n||!r?null:d.jsx(r,{bounds:n,rotation:t})}function fH(){const e=F(),t=K("selection rotation",()=>e.getSelectionRotation(),[e]),n=K("selection bounds",()=>e.getSelectionRotatedPageBounds(),[e]),{SelectionBackground:r}=st();return!n||!r?null:d.jsx(r,{bounds:n,rotation:t})}function gH(){const{OnTheCanvas:e}=st();return e?d.jsx(e,{}):null}function mH(){const e=F(),t=K("camera state",()=>e.getCameraState(),[e]);return d.jsx("div",{className:ce("tl-hit-test-blocker",{"tl-hit-test-blocker__hidden":t==="idle"})})}function yH({className:e,zoom:t,point:n,color:r,viewport:o,opacity:s=1}){const i=P.useRef(null);return Ml(i,_t(n.x,o.minX+5/t,o.maxX-5/t),_t(n.y,o.minY+5/t,o.maxY-5/t),1/t,b.Angle(o.center,n)),d.jsxs("svg",{ref:i,className:ce("tl-overlays__item",e),children:[d.jsx("use",{href:"#cursor_hint",color:r,strokeWidth:3,stroke:"var(--color-background)"}),d.jsx("use",{href:"#cursor_hint",color:r,opacity:s})]})}const AP=P.memo(function({className:t,zoom:n,point:r,color:o,name:s,chatMessage:i}){const a=P.useRef(null);return Ml(a,r==null?void 0:r.x,r==null?void 0:r.y,1/n),r?d.jsxs("div",{ref:a,className:ce("tl-overlays__item",t),children:[d.jsx("svg",{className:"tl-cursor",children:d.jsx("use",{href:"#cursor",color:o})}),i?d.jsxs(d.Fragment,{children:[s&&d.jsx("div",{className:"tl-nametag-title",style:{color:o},children:s}),d.jsx("div",{className:"tl-nametag-chat",style:{backgroundColor:o},children:i})]}):s&&d.jsx("div",{className:"tl-nametag",style:{backgroundColor:o},children:s})]}):null});function w2(){return P.useId().replace(/:/g,"_")}function SH({x:e,y:t,z:n,size:r}){const o=`grid_${w2()}`,s=F(),{gridSteps:i}=s.options;return d.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("defs",{children:i.map(({min:a,mid:l,step:c},u)=>{const h=c*r*n,p=.5+e*n,f=.5+t*n,S=p>0?p%h:h+p%h,y=f>0?f%h:h+f%h,x=n<l?il(n,[a,l],[0,1]):1;return d.jsx("pattern",{id:`${o}_${c}`,width:h,height:h,patternUnits:"userSpaceOnUse",children:d.jsx("circle",{className:"tl-grid-dot",cx:S,cy:y,r:1,opacity:x})},u)})}),i.map(({step:a},l)=>d.jsx("rect",{width:"100%",height:"100%",fill:`url(#${o}_${a})`},l))]})}function vH({handle:e,isCoarse:t,className:n,zoom:r}){const o=F(),s=(t?o.options.coarseHandleRadius:o.options.handleRadius)/r;if(e.type==="clone"){const a=3/r,l=`M0,${-a} A${a},${a} 0 0,1 0,${a}`,c=I9.indexOf(e.id);return d.jsxs("g",{className:ce(`tl-handle tl-handle__${e.type}`,n),children:[d.jsx("circle",{className:"tl-handle__bg",r:s}),d.jsx("path",{className:"tl-handle__fg",d:l,transform:`rotate(${-90+90*c})`})]})}const i=(e.type==="create"&&t?3:4)/Math.max(r,.25);return d.jsxs("g",{className:ce(`tl-handle tl-handle__${e.type}`,n),children:[d.jsx("circle",{className:"tl-handle__bg",r:s}),d.jsx("circle",{className:"tl-handle__fg",r:i})]})}const xH=({children:e})=>d.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:e}),wH=()=>{const{Spinner:e}=st();return d.jsx(cw,{children:e?d.jsx(e,{}):null})};function a0(e,t=!0){const n=e.length;if(n<2)return"";let r=e[0],o=e[1];if(n===2)return`M${Te(r)}L${Te(o)}`;let s="";for(let i=2,a=n-1;i<a;i++)r=e[i],o=e[i+1],s+=Rn(r,o);return t?`M${Rn(e[0],e[1])}Q${Te(e[1])}${Rn(e[1],e[2])}T${s}${Rn(e[n-1],e[0])}${Rn(e[0],e[1])}Z`:`M${Te(e[0])}Q${Te(e[1])}${Rn(e[1],e[2])}${e.length>3?"T":""}${s}L${Te(e[n-1])}`}function jP({scribble:e,zoom:t,color:n,opacity:r,className:o}){return e.points.length?d.jsx("svg",{className:o&&ce("tl-overlays__item",o),children:d.jsx("path",{className:"tl-scribble",d:a0(e.points,!1),stroke:n??`var(--color-${e.color})`,fill:"none",strokeWidth:8/t,opacity:r??e.opacity})}):null}function b2({bounds:e,rotation:t}){const n=P.useRef(null);return Ml(n,e.x,e.y,1,t),P.useLayoutEffect(()=>{const r=n.current;r&&(r.style.width=N(Math.max(1,e.width))+"px",r.style.height=N(Math.max(1,e.height))+"px")},[e.width,e.height]),d.jsx("div",{ref:n,className:"tl-selection__bg",draggable:!1})}function bH({bounds:e,rotation:t}){const n=F(),r=P.useRef(null),o=K("only selected shape",()=>n.getOnlySelectedShape(),[n]),s=o?n.getShapeUtil(o).expandSelectionOutlinePx(o):0;return Ml(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(),d.jsx("svg",{ref:r,className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:d.jsx("rect",{className:ce("tl-selection__fg__outline"),width:N(e.width),height:N(e.height)})})}const PH=()=>d.jsx("div",{className:"tl-shape-error-boundary"}),CH=({shape:e,util:t})=>Gf("Indicator: "+e.type,()=>t.indicator(t.editor.store.unsafeGetWithoutCapture(e.id))),IH=({editor:e,id:t})=>{const n=K("shape for indicator",()=>e.store.get(t),[e,t]),{ShapeIndicatorErrorFallback:r}=st();return!n||n.isLocked?null:d.jsx(au,{fallback:r,onError:o=>e.annotateError(o,{origin:"react.shapeIndicator",willCrashApp:!1}),children:d.jsx(CH,{shape:n,util:e.getShapeUtil(n)},n.id)})},OP=P.memo(function({shapeId:t,className:n,color:r,hidden:o,opacity:s}){const i=F(),a=P.useRef(null);return Ls("indicator transform",()=>{const l=a.current;if(!l)return;const c=i.getShapePageTransform(t);c&&l.style.setProperty("transform",c.toCssString())},[i,t]),P.useLayoutEffect(()=>{const l=a.current;l&&l.style.setProperty("display",o?"none":"block")},[o]),d.jsx("svg",{ref:a,className:ce("tl-overlays__item",n),children:d.jsx("g",{className:"tl-shape-indicator",stroke:r??"var(--color-selected)",opacity:s,children:d.jsx(IH,{editor:i,id:t})})})}),EH=()=>d.jsx("circle",{cx:4,cy:4,r:8,strokeWidth:"1",stroke:"red"}),P2=P.memo(function(){const t=F(),n=P.useRef(new Set),r=K("should display selected ids",()=>{const i=n.current,a=new Set;if(t.isInAny("select.idle","select.brushing","select.scribble_brushing","select.editing_shape","select.pointing_shape","select.pointing_selection","select.pointing_handle")&&!t.getInstanceState().isChangingStyle){const l=t.getSelectedShapeIds();for(const c of l)a.add(c);if(t.isInAny("select.idle","select.editing_shape")){const c=t.getInstanceState();if(c.isHoveringCanvas&&!c.isCoarsePointer){const u=t.getHoveredShapeId();u&&a.add(u)}}}if(i.size!==a.size)return n.current=a,a;for(const l of a)if(!i.has(l))return n.current=a,a;return i},[t]),o=K("rendering shapes",()=>t.getRenderingShapes(),[t]),{ShapeIndicator:s}=st();return s?o.map(({id:i})=>d.jsx(s,{shapeId:i,hidden:!r.has(i)},i+"_indicator")):null});function kH({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 l,c,u,h;return a?(l=r,c=s,u=o,h=i):(l=r,c=i,u=o,h=s),d.jsxs("g",{className:"tl-snap-indicator",stroke:"lime",children:[d.jsx("line",{x1:l,y1:c,x2:u,y2:h}),e.map((p,f)=>d.jsx("g",{transform:`translate(${p.x},${p.y})`,children:d.jsx("path",{className:"tl-snap-point",d:`M ${-n},${-n} L ${n},${n} M ${-n},${n} L ${n},${-n}`})},f))]})}function _H({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 l of e){if(s=Lr(o[0],o[1],i?l.startEdge[0].y:l.startEdge[0].x,i?l.startEdge[1].y:l.startEdge[1].x),s)o=s;else continue;if(s=Lr(o[0],o[1],i?l.endEdge[0].y:l.endEdge[0].x,i?l.endEdge[1].y:l.endEdge[1].x),s)o=s;else continue}if(o===null)return null;const a=(o[0]+o[1])/2;return d.jsx("g",{className:"tl-snap-indicator",stroke:"cyan",children:e.map(({startEdge:l,endEdge:c},u)=>d.jsx(P.Fragment,{children:i?d.jsxs(d.Fragment,{children:[d.jsx("line",{x1:l[0].x,y1:a-2*r,x2:l[1].x,y2:a+2*r}),d.jsx("line",{x1:c[0].x,y1:a-2*r,x2:c[1].x,y2:a+2*r}),d.jsx("line",{x1:l[0].x,y1:a,x2:c[0].x,y2:a}),d.jsx("line",{x1:(l[0].x+c[0].x)/2,y1:a-r,x2:(l[0].x+c[0].x)/2,y2:a+r})]}):d.jsxs(d.Fragment,{children:[d.jsx("line",{x1:a-2*r,y1:l[0].y,x2:a+2*r,y2:l[1].y}),d.jsx("line",{x1:a-2*r,y1:c[0].y,x2:a+2*r,y2:c[1].y}),d.jsx("line",{x1:a,y1:l[0].y,x2:a,y2:c[0].y}),d.jsx("line",{x1:a-r,y1:(l[0].y+c[0].y)/2,x2:a+r,y2:(l[0].y+c[0].y)/2})]})},u))})}function TH({className:e,line:t,zoom:n}){return d.jsx("svg",{className:ce("tl-overlays__item",e),children:t.type==="points"?d.jsx(kH,{...t,zoom:n}):t.type==="gaps"?d.jsx(_H,{...t,zoom:n}):null})}function l0(){return d.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",children:d.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[d.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),d.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:d.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}const MH=()=>null;function C2(e,t){const n=P.useRef(e);return t(e,n.current)?n.current:(n.current=e,e)}function zc(e){return C2(e,yB)}const AH=(e,t)=>(e??(e=null),t??(t=null),e===t?!0:!e||!t?!1:qk(e,t));function Xf(e){return C2(e,AH)}const I2=P.createContext(null);function jH({overrides:e={},children:t}){const n=Xf(e),r=P.useMemo(()=>({Background:S9,SvgDefs:MH,Brush:_m,ZoomBrush:_m,CollaboratorBrush:_m,Cursor:AP,CollaboratorCursor:AP,CollaboratorHint:yH,CollaboratorShapeIndicator:OP,Grid:SH,Scribble:jP,SnapIndicator:TH,Handles:xH,Handle:vH,CollaboratorScribble:jP,ErrorFallback:k2,ShapeErrorFallback:PH,ShapeIndicatorErrorFallback:EH,Spinner:l0,SelectionBackground:b2,SelectionForeground:bH,ShapeIndicators:P2,ShapeIndicator:OP,OnTheCanvas:null,InFrontOfTheCanvas:null,Canvas:q7,LoadingScreen:wH,...n}),[n]);return d.jsx(I2.Provider,{value:r,children:t})}function st(){const e=P.useContext(I2);if(!e)throw new Error("useEditorComponents must be used inside of <EditorComponentsProvider />");return e}const c0={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 E2(){c0.hardReset()}function OH(){c0.refreshPage()}const DH="https://github.com/tldraw/tldraw/issues/new",k2=({error:e,editor:t})=>{const n=P.useRef(null),[r,o]=P.useState(!1),[s,i]=P.useState(!1),[a,l]=P.useState(!1);let c=null;try{c=st().Canvas??null}catch{}const u=e instanceof Error?e.message:String(e),h=e instanceof Error?e.stack:null,p=K("isDarkMode",()=>{try{if(t)return t.user.getIsDarkMode()}catch{}return null},[t]),[f,S]=P.useState(null);P.useLayoutEffect(()=>{var E;p!==null&&S(p);let w=(E=n.current)==null?void 0:E.parentElement,C=!1;for(;w;){if(w.classList.contains("tl-theme__dark")||w.classList.contains("tl-theme__light")){C=!0;break}w=w.parentElement}if(C){S(null);return}typeof window<"u"&&"matchMedia"in window&&S(window.matchMedia("(prefers-color-scheme: dark)").matches)},[p]),P.useEffect(()=>{if(s){const w=t==null?void 0:t.timers.setTimeout(()=>{i(!1)},2e3);return()=>clearTimeout(w)}},[s,t]);const y=()=>{const w=document.createElement("textarea");w.value=h??u,document.body.appendChild(w),w.select(),document.execCommand("copy"),w.remove(),i(!0)},x=()=>{OH()},m=async()=>{E2()},v=new URL(DH);return v.searchParams.set("title",u),v.searchParams.set("labels","bug"),v.searchParams.set("body",`Hey, I ran into an error while using tldraw:
|
|
57
|
+
|
|
58
|
+
\`\`\`js
|
|
59
|
+
${h??u}
|
|
60
|
+
\`\`\`
|
|
61
|
+
|
|
62
|
+
My browser: ${navigator.userAgent}`),d.jsxs("div",{ref:n,className:ce("tl-container tl-error-boundary",f===null?"":f?"tl-theme__dark":"tl-theme__light"),children:[d.jsx("div",{className:"tl-error-boundary__overlay"}),t&&d.jsx(e2,{onError:nu,fallback:()=>null,children:d.jsx(Vf.Provider,{value:t,children:d.jsx("div",{className:"tl-overlay tl-error-boundary__canvas",children:c?d.jsx(c,{}):null})})}),d.jsx("div",{className:ce("tl-modal","tl-error-boundary__content",{"tl-error-boundary__content__expanded":r&&!a}),children:a?d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:"Are you sure?"}),d.jsx("p",{children:"Resetting your data will delete your drawing and cannot be undone."}),d.jsxs("div",{className:"tl-error-boundary__content__actions",children:[d.jsx("button",{onClick:()=>l(!1),children:"Cancel"}),d.jsx("button",{className:"tl-error-boundary__reset",onClick:m,children:"Reset data"})]})]}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{children:"Something's gone wrong."}),d.jsxs("p",{children:["Sorry, we encountered an error. Please refresh the page to continue. If you keep seeing this error, you can ",d.jsx("a",{href:v.toString(),children:"create a GitHub issue"})," or"," ",d.jsx("a",{href:"https://discord.gg/Cq6cPsTfNy",children:"ask for help on Discord"}),"."]}),r&&d.jsxs(d.Fragment,{children:["Message:",d.jsx("h4",{children:d.jsx("code",{children:u})}),"Stack trace:",d.jsxs("div",{className:"tl-error-boundary__content__error",children:[d.jsx("pre",{children:d.jsx("code",{children:h??u})}),d.jsx("button",{onClick:y,children:s?"Copied!":"Copy"})]})]}),d.jsxs("div",{className:"tl-error-boundary__content__actions",children:[d.jsx("button",{onClick:()=>o(!r),children:r?"Hide details":"Show details"}),d.jsxs("div",{className:"tl-error-boundary__content__actions__group",children:[d.jsx("button",{className:"tl-error-boundary__reset",onClick:()=>l(!0),children:"Reset data"}),d.jsx("button",{className:"tl-error-boundary__refresh",onClick:x,children:"Refresh Page"})]})]})]})})]})};function ct(){return Uu()}const _2="TLDRAW_USER_DATA_v3",T2=xe({id:fe,name:fe.nullable().optional(),locale:fe.nullable().optional(),color:fe.nullable().optional(),colorScheme:Kf("light","dark","system").optional(),animationSpeed:he.nullable().optional(),edgeScrollSpeed:he.nullable().optional(),isSnapMode:Se.nullable().optional(),isWrapMode:Se.nullable().optional(),isDynamicSizeMode:Se.nullable().optional(),isPasteAtCursorMode:Se.nullable().optional()}),$o={AddAnimationSpeed:1,AddIsSnapMode:2,MakeFieldsNullable:3,AddEdgeScrollSpeed:4,AddExcalidrawSelectMode:5,AddDynamicSizeMode:6,AllowSystemColorScheme:7,AddPasteAtCursor:8},u0=Math.max(...Object.values($o));function RH(e){e.version<$o.AddAnimationSpeed&&(e.user.animationSpeed=1),e.version<$o.AddIsSnapMode&&(e.user.isSnapMode=!1),e.version<$o.MakeFieldsNullable,e.version<$o.AddEdgeScrollSpeed&&(e.user.edgeScrollSpeed=1),e.version<$o.AddExcalidrawSelectMode&&(e.user.isWrapMode=!1),e.version<$o.AllowSystemColorScheme&&(e.user.isDarkMode===!0?e.user.colorScheme="dark":e.user.isDarkMode===!1&&(e.user.colorScheme="light"),delete e.user.isDarkMode),e.version<$o.AddDynamicSizeMode&&(e.user.isDynamicSizeMode=!1),e.version<$o.AddPasteAtCursor&&(e.user.isPasteAtCursorMode=!1),e.version=u0}const OS=["#FF802B","#EC5E41","#F2555A","#F04F88","#E34BA9","#BD54C6","#9D5BD2","#7B66DC","#02B1CC","#11B3A3","#39B178","#55B467"];function M2(){return OS[Math.floor(Math.random()*OS.length)]}function LH(){var e,t;return typeof window<"u"&&"matchMedia"in window?((t=(e=window.matchMedia)==null?void 0:e.call(window,"(prefers-reduced-motion: reduce)"))==null?void 0:t.matches)??!1:!1}const Lo=Object.freeze({name:"New User",locale:u9(),color:M2(),edgeScrollSpeed:1,animationSpeed:LH()?0:1,isSnapMode:!1,isWrapMode:!1,isDynamicSizeMode:!1,isPasteAtCursorMode:!1,colorScheme:"system"});function Am(){return{id:ct(),color:M2()}}function A2(e){if(e===null||typeof e!="object"||!("version"in e)||!("user"in e)||typeof e.version!="number")return Am();const t=Ge(e);RH(t);try{return T2.validate(t.user)}catch{return Am()}}function $H(){const e=JSON.parse(Kx(_2)||"null")??null;return A2(e)}const qf=Mt("globalUserData",null);function NH(){Wx(_2,JSON.stringify({version:u0,user:qf.get()}))}function j2(e){T2.validate(e),qf.set(e),NH(),zH()}const FH=typeof process<"u"&&!1,Ya=typeof BroadcastChannel<"u"&&!FH?new BroadcastChannel("tldraw-user-sync"):null;Ya==null||Ya.addEventListener("message",e=>{const t=e.data;(t==null?void 0:t.type)===D2&&(t==null?void 0:t.origin)!==O2()&&qf.set(A2(t.data))});let jm=null;function O2(){return jm===null&&(jm=ct()),jm}const D2="tldraw-user-preferences-change";function zH(){Ya==null||Ya.postMessage({type:D2,origin:O2(),data:{user:R2(),version:u0}})}function R2(){let e=qf.get();return e||(e=$H(),j2(e)),e}const BH=G("defaultLocalStorageUserPrefs",()=>R2());function L2(e={}){return{userPreferences:e.userPreferences??BH,setUserPreferences:e.setUserPreferences??j2}}var $2={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(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function s(l,c,u,h,p){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new o(u,h||l,p),S=n?n+c:c;return l._events[S]?l._events[S].fn?l._events[S]=[l._events[S],f]:l._events[S].push(f):(l._events[S]=f,l._eventsCount++),l}function i(l,c){--l._eventsCount===0?l._events=new r:delete l._events[c]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var c=[],u,h;if(this._eventsCount===0)return c;for(h in u=this._events)t.call(u,h)&&c.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},a.prototype.listeners=function(c){var u=n?n+c:c,h=this._events[u];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,f=h.length,S=new Array(f);p<f;p++)S[p]=h[p].fn;return S},a.prototype.listenerCount=function(c){var u=n?n+c:c,h=this._events[u];return h?h.fn?1:h.length:0},a.prototype.emit=function(c,u,h,p,f,S){var y=n?n+c:c;if(!this._events[y])return!1;var x=this._events[y],m=arguments.length,v,w;if(x.fn){switch(x.once&&this.removeListener(c,x.fn,void 0,!0),m){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,u),!0;case 3:return x.fn.call(x.context,u,h),!0;case 4:return x.fn.call(x.context,u,h,p),!0;case 5:return x.fn.call(x.context,u,h,p,f),!0;case 6:return x.fn.call(x.context,u,h,p,f,S),!0}for(w=1,v=new Array(m-1);w<m;w++)v[w-1]=arguments[w];x.fn.apply(x.context,v)}else{var C=x.length,E;for(w=0;w<C;w++)switch(x[w].once&&this.removeListener(c,x[w].fn,void 0,!0),m){case 1:x[w].fn.call(x[w].context);break;case 2:x[w].fn.call(x[w].context,u);break;case 3:x[w].fn.call(x[w].context,u,h);break;case 4:x[w].fn.call(x[w].context,u,h,p);break;default:if(!v)for(E=1,v=new Array(m-1);E<m;E++)v[E-1]=arguments[E];x[w].fn.apply(x[w].context,v)}}return!0},a.prototype.on=function(c,u,h){return s(this,c,u,h,!1)},a.prototype.once=function(c,u,h){return s(this,c,u,h,!0)},a.prototype.removeListener=function(c,u,h,p){var f=n?n+c:c;if(!this._events[f])return this;if(!u)return i(this,f),this;var S=this._events[f];if(S.fn)S.fn===u&&(!p||S.once)&&(!h||S.context===h)&&i(this,f);else{for(var y=0,x=[],m=S.length;y<m;y++)(S[y].fn!==u||p&&!S[y].once||h&&S[y].context!==h)&&x.push(S[y]);x.length?this._events[f]=x.length===1?x[0]:x:i(this,f)}return this},a.prototype.removeAllListeners=function(c){var u;return c?(u=n?n+c:c,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})($2);var UH=$2.exports;const HH=ni(UH);var N2={exports:{}},hr={},F2={exports:{}},z2={};/**
|
|
63
|
+
* @license React
|
|
64
|
+
* scheduler.production.min.js
|
|
65
|
+
*
|
|
66
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
67
|
+
*
|
|
68
|
+
* This source code is licensed under the MIT license found in the
|
|
69
|
+
* LICENSE file in the root directory of this source tree.
|
|
70
|
+
*/(function(e){function t(z,W){var Y=z.length;z.push(W);e:for(;0<Y;){var q=Y-1>>>1,le=z[q];if(0<o(le,W))z[q]=W,z[Y]=le,Y=q;else break e}}function n(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var W=z[0],Y=z.pop();if(Y!==W){z[0]=Y;e:for(var q=0,le=z.length,ge=le>>>1;q<ge;){var be=2*(q+1)-1,J=z[be],Ue=be+1,Oe=z[Ue];if(0>o(J,Y))Ue<le&&0>o(Oe,J)?(z[q]=Oe,z[Ue]=Y,q=Ue):(z[q]=J,z[be]=Y,q=be);else if(Ue<le&&0>o(Oe,Y))z[q]=Oe,z[Ue]=Y,q=Ue;else break e}}return W}function o(z,W){var Y=z.sortIndex-W.sortIndex;return Y!==0?Y:z.id-W.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 l=[],c=[],u=1,h=null,p=3,f=!1,S=!1,y=!1,x=typeof setTimeout=="function"?setTimeout:null,m=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 w(z){for(var W=n(c);W!==null;){if(W.callback===null)r(c);else if(W.startTime<=z)r(c),W.sortIndex=W.expirationTime,t(l,W);else break;W=n(c)}}function C(z){if(y=!1,w(z),!S)if(n(l)!==null)S=!0,H(E);else{var W=n(c);W!==null&&B(C,W.startTime-z)}}function E(z,W){S=!1,y&&(y=!1,m(k),k=-1),f=!0;var Y=p;try{for(w(W),h=n(l);h!==null&&(!(h.expirationTime>W)||z&&!D());){var q=h.callback;if(typeof q=="function"){h.callback=null,p=h.priorityLevel;var le=q(h.expirationTime<=W);W=e.unstable_now(),typeof le=="function"?h.callback=le:h===n(l)&&r(l),w(W)}else r(l);h=n(l)}if(h!==null)var ge=!0;else{var be=n(c);be!==null&&B(C,be.startTime-W),ge=!1}return ge}finally{h=null,p=Y,f=!1}}var _=!1,I=null,k=-1,T=5,M=-1;function D(){return!(e.unstable_now()-M<T)}function $(){if(I!==null){var z=e.unstable_now();M=z;var W=!0;try{W=I(!0,z)}finally{W?j():(_=!1,I=null)}}else _=!1}var j;if(typeof v=="function")j=function(){v($)};else if(typeof MessageChannel<"u"){var O=new MessageChannel,R=O.port2;O.port1.onmessage=$,j=function(){R.postMessage(null)}}else j=function(){x($,0)};function H(z){I=z,_||(_=!0,j())}function B(z,W){k=x(function(){z(e.unstable_now())},W)}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(z){z.callback=null},e.unstable_continueExecution=function(){S||f||(S=!0,H(E))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(l)},e.unstable_next=function(z){switch(p){case 1:case 2:case 3:var W=3;break;default:W=p}var Y=p;p=W;try{return z()}finally{p=Y}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,W){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var Y=p;p=z;try{return W()}finally{p=Y}},e.unstable_scheduleCallback=function(z,W,Y){var q=e.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?q+Y:q):Y=q,z){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=Y+le,z={id:u++,callback:W,priorityLevel:z,startTime:Y,expirationTime:le,sortIndex:-1},Y>q?(z.sortIndex=Y,t(c,z),n(l)===null&&z===n(c)&&(y?(m(k),k=-1):y=!0,B(C,Y-q))):(z.sortIndex=le,t(l,z),S||f||(S=!0,H(E))),z},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(z){var W=p;return function(){var Y=p;p=W;try{return z.apply(this,arguments)}finally{p=Y}}}})(z2);F2.exports=z2;var KH=F2.exports;/**
|
|
71
|
+
* @license React
|
|
72
|
+
* react-dom.production.min.js
|
|
73
|
+
*
|
|
74
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
75
|
+
*
|
|
76
|
+
* This source code is licensed under the MIT license found in the
|
|
77
|
+
* LICENSE file in the root directory of this source tree.
|
|
78
|
+
*/var WH=P,ur=KH;function X(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 B2=new Set,lu={};function oa(e,t){ll(e,t),ll(e+"Capture",t)}function ll(e,t){for(lu[e]=t,e=0;e<t.length;e++)B2.add(t[e])}var es=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),DS=Object.prototype.hasOwnProperty,GH=/^[: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]*$/,DP={},RP={};function VH(e){return DS.call(RP,e)?!0:DS.call(DP,e)?!1:GH.test(e)?RP[e]=!0:(DP[e]=!0,!1)}function YH(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 XH(e,t,n,r){if(t===null||typeof t>"u"||YH(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 In(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 Yt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Yt[e]=new In(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Yt[t]=new In(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Yt[e]=new In(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Yt[e]=new In(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){Yt[e]=new In(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Yt[e]=new In(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Yt[e]=new In(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Yt[e]=new In(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Yt[e]=new In(e,5,!1,e.toLowerCase(),null,!1,!1)});var d0=/[\-:]([a-z])/g;function h0(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(d0,h0);Yt[t]=new In(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(d0,h0);Yt[t]=new In(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(d0,h0);Yt[t]=new In(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Yt[e]=new In(e,1,!1,e.toLowerCase(),null,!1,!1)});Yt.xlinkHref=new In("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Yt[e]=new In(e,1,!1,e.toLowerCase(),null,!0,!0)});function p0(e,t,n,r){var o=Yt.hasOwnProperty(t)?Yt[t]:null;(o!==null?o.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(XH(t,n,o,r)&&(n=null),r||o===null?VH(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 us=WH.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Dd=Symbol.for("react.element"),Ma=Symbol.for("react.portal"),Aa=Symbol.for("react.fragment"),f0=Symbol.for("react.strict_mode"),RS=Symbol.for("react.profiler"),U2=Symbol.for("react.provider"),H2=Symbol.for("react.context"),g0=Symbol.for("react.forward_ref"),LS=Symbol.for("react.suspense"),$S=Symbol.for("react.suspense_list"),m0=Symbol.for("react.memo"),Is=Symbol.for("react.lazy"),K2=Symbol.for("react.offscreen"),LP=Symbol.iterator;function Jl(e){return e===null||typeof e!="object"?null:(e=LP&&e[LP]||e["@@iterator"],typeof e=="function"?e:null)}var pt=Object.assign,Om;function vc(e){if(Om===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Om=t&&t[1]||""}return`
|
|
79
|
+
`+Om+e}var Dm=!1;function Rm(e,t){if(!e||Dm)return"";Dm=!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(c){var r=c}Reflect.construct(e,[],t)}else{try{t.call()}catch(c){r=c}e.call(t.prototype)}else{try{throw Error()}catch(c){r=c}e()}}catch(c){if(c&&r&&typeof c.stack=="string"){for(var o=c.stack.split(`
|
|
80
|
+
`),s=r.stack.split(`
|
|
81
|
+
`),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 l=`
|
|
82
|
+
`+o[i].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}while(1<=i&&0<=a);break}}}finally{Dm=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?vc(e):""}function qH(e){switch(e.tag){case 5:return vc(e.type);case 16:return vc("Lazy");case 13:return vc("Suspense");case 19:return vc("SuspenseList");case 0:case 2:case 15:return e=Rm(e.type,!1),e;case 11:return e=Rm(e.type.render,!1),e;case 1:return e=Rm(e.type,!0),e;default:return""}}function NS(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 Aa:return"Fragment";case Ma:return"Portal";case RS:return"Profiler";case f0:return"StrictMode";case LS:return"Suspense";case $S:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case H2:return(e.displayName||"Context")+".Consumer";case U2:return(e._context.displayName||"Context")+".Provider";case g0:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case m0:return t=e.displayName||null,t!==null?t:NS(e.type)||"Memo";case Is:t=e._payload,e=e._init;try{return NS(e(t))}catch{}}return null}function ZH(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 NS(t);case 8:return t===f0?"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 Xs(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function W2(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function QH(e){var t=W2(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=QH(e))}function G2(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=W2(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Kp(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 FS(e,t){var n=t.checked;return pt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function $P(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Xs(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 V2(e,t){t=t.checked,t!=null&&p0(e,"checked",t,!1)}function zS(e,t){V2(e,t);var n=Xs(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")?BS(e,t.type,n):t.hasOwnProperty("defaultValue")&&BS(e,t.type,Xs(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function NP(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 BS(e,t,n){(t!=="number"||Kp(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var xc=Array.isArray;function Xa(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=""+Xs(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 US(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(X(91));return pt({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function FP(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(X(92));if(xc(n)){if(1<n.length)throw Error(X(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Xs(n)}}function Y2(e,t){var n=Xs(t.value),r=Xs(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 zP(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function X2(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 HS(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?X2(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Ld,q2=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(Ld=Ld||document.createElement("div"),Ld.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Ld.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function cu(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Bc={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},JH=["Webkit","ms","Moz","O"];Object.keys(Bc).forEach(function(e){JH.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Bc[t]=Bc[e]})});function Z2(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Bc.hasOwnProperty(e)&&Bc[e]?(""+t).trim():t+"px"}function Q2(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=Z2(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var eK=pt({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 KS(e,t){if(t){if(eK[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(X(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(X(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(X(61))}if(t.style!=null&&typeof t.style!="object")throw Error(X(62))}}function WS(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 GS=null;function y0(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var VS=null,qa=null,Za=null;function BP(e){if(e=Zu(e)){if(typeof VS!="function")throw Error(X(280));var t=e.stateNode;t&&(t=tg(t),VS(e.stateNode,e.type,t))}}function J2(e){qa?Za?Za.push(e):Za=[e]:qa=e}function eT(){if(qa){var e=qa,t=Za;if(Za=qa=null,BP(e),t)for(e=0;e<t.length;e++)BP(t[e])}}function tT(e,t){return e(t)}function nT(){}var Lm=!1;function rT(e,t,n){if(Lm)return e(t,n);Lm=!0;try{return tT(e,t,n)}finally{Lm=!1,(qa!==null||Za!==null)&&(nT(),eT())}}function uu(e,t){var n=e.stateNode;if(n===null)return null;var r=tg(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(X(231,t,typeof n));return n}var YS=!1;if(es)try{var ec={};Object.defineProperty(ec,"passive",{get:function(){YS=!0}}),window.addEventListener("test",ec,ec),window.removeEventListener("test",ec,ec)}catch{YS=!1}function tK(e,t,n,r,o,s,i,a,l){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(u){this.onError(u)}}var Uc=!1,Wp=null,Gp=!1,XS=null,nK={onError:function(e){Uc=!0,Wp=e}};function rK(e,t,n,r,o,s,i,a,l){Uc=!1,Wp=null,tK.apply(nK,arguments)}function oK(e,t,n,r,o,s,i,a,l){if(rK.apply(this,arguments),Uc){if(Uc){var c=Wp;Uc=!1,Wp=null}else throw Error(X(198));Gp||(Gp=!0,XS=c)}}function sa(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 oT(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 UP(e){if(sa(e)!==e)throw Error(X(188))}function sK(e){var t=e.alternate;if(!t){if(t=sa(e),t===null)throw Error(X(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 UP(o),e;if(s===r)return UP(o),t;s=s.sibling}throw Error(X(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(X(189))}}if(n.alternate!==r)throw Error(X(190))}if(n.tag!==3)throw Error(X(188));return n.stateNode.current===n?e:t}function sT(e){return e=sK(e),e!==null?iT(e):null}function iT(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=iT(e);if(t!==null)return t;e=e.sibling}return null}var aT=ur.unstable_scheduleCallback,HP=ur.unstable_cancelCallback,iK=ur.unstable_shouldYield,aK=ur.unstable_requestPaint,wt=ur.unstable_now,lK=ur.unstable_getCurrentPriorityLevel,S0=ur.unstable_ImmediatePriority,lT=ur.unstable_UserBlockingPriority,Vp=ur.unstable_NormalPriority,cK=ur.unstable_LowPriority,cT=ur.unstable_IdlePriority,Zf=null,So=null;function uK(e){if(So&&typeof So.onCommitFiberRoot=="function")try{So.onCommitFiberRoot(Zf,e,void 0,(e.current.flags&128)===128)}catch{}}var Hr=Math.clz32?Math.clz32:pK,dK=Math.log,hK=Math.LN2;function pK(e){return e>>>=0,e===0?32:31-(dK(e)/hK|0)|0}var $d=64,Nd=4194304;function wc(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 Yp(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=wc(a):(s&=i,s!==0&&(r=wc(s)))}else i=n&~o,i!==0?r=wc(i):s!==0&&(r=wc(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-Hr(t),o=1<<n,r|=e[n],t&=~o;return r}function fK(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 gK(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,o=e.expirationTimes,s=e.pendingLanes;0<s;){var i=31-Hr(s),a=1<<i,l=o[i];l===-1?(!(a&n)||a&r)&&(o[i]=fK(a,t)):l<=t&&(e.expiredLanes|=a),s&=~a}}function qS(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function uT(){var e=$d;return $d<<=1,!($d&4194240)&&($d=64),e}function $m(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Xu(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Hr(t),e[t]=n}function mK(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-Hr(n),s=1<<o;t[o]=0,r[o]=-1,e[o]=-1,n&=~s}}function v0(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Hr(n),o=1<<r;o&t|e[r]&t&&(e[r]|=t),n&=~o}}var Ne=0;function dT(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var hT,x0,pT,fT,gT,ZS=!1,Fd=[],Fs=null,zs=null,Bs=null,du=new Map,hu=new Map,_s=[],yK="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 KP(e,t){switch(e){case"focusin":case"focusout":Fs=null;break;case"dragenter":case"dragleave":zs=null;break;case"mouseover":case"mouseout":Bs=null;break;case"pointerover":case"pointerout":du.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":hu.delete(t.pointerId)}}function tc(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=Zu(t),t!==null&&x0(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,o!==null&&t.indexOf(o)===-1&&t.push(o),e)}function SK(e,t,n,r,o){switch(t){case"focusin":return Fs=tc(Fs,e,t,n,r,o),!0;case"dragenter":return zs=tc(zs,e,t,n,r,o),!0;case"mouseover":return Bs=tc(Bs,e,t,n,r,o),!0;case"pointerover":var s=o.pointerId;return du.set(s,tc(du.get(s)||null,e,t,n,r,o)),!0;case"gotpointercapture":return s=o.pointerId,hu.set(s,tc(hu.get(s)||null,e,t,n,r,o)),!0}return!1}function mT(e){var t=Ei(e.target);if(t!==null){var n=sa(t);if(n!==null){if(t=n.tag,t===13){if(t=oT(n),t!==null){e.blockedOn=t,gT(e.priority,function(){pT(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=QS(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);GS=r,n.target.dispatchEvent(r),GS=null}else return t=Zu(n),t!==null&&x0(t),e.blockedOn=n,!1;t.shift()}return!0}function WP(e,t,n){Oh(e)&&n.delete(t)}function vK(){ZS=!1,Fs!==null&&Oh(Fs)&&(Fs=null),zs!==null&&Oh(zs)&&(zs=null),Bs!==null&&Oh(Bs)&&(Bs=null),du.forEach(WP),hu.forEach(WP)}function nc(e,t){e.blockedOn===t&&(e.blockedOn=null,ZS||(ZS=!0,ur.unstable_scheduleCallback(ur.unstable_NormalPriority,vK)))}function pu(e){function t(o){return nc(o,e)}if(0<Fd.length){nc(Fd[0],e);for(var n=1;n<Fd.length;n++){var r=Fd[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Fs!==null&&nc(Fs,e),zs!==null&&nc(zs,e),Bs!==null&&nc(Bs,e),du.forEach(t),hu.forEach(t),n=0;n<_s.length;n++)r=_s[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<_s.length&&(n=_s[0],n.blockedOn===null);)mT(n),n.blockedOn===null&&_s.shift()}var Qa=us.ReactCurrentBatchConfig,Xp=!0;function xK(e,t,n,r){var o=Ne,s=Qa.transition;Qa.transition=null;try{Ne=1,w0(e,t,n,r)}finally{Ne=o,Qa.transition=s}}function wK(e,t,n,r){var o=Ne,s=Qa.transition;Qa.transition=null;try{Ne=4,w0(e,t,n,r)}finally{Ne=o,Qa.transition=s}}function w0(e,t,n,r){if(Xp){var o=QS(e,t,n,r);if(o===null)Vm(e,t,r,qp,n),KP(e,r);else if(SK(o,e,t,n,r))r.stopPropagation();else if(KP(e,r),t&4&&-1<yK.indexOf(e)){for(;o!==null;){var s=Zu(o);if(s!==null&&hT(s),s=QS(e,t,n,r),s===null&&Vm(e,t,r,qp,n),s===o)break;o=s}o!==null&&r.stopPropagation()}else Vm(e,t,r,null,n)}}var qp=null;function QS(e,t,n,r){if(qp=null,e=y0(r),e=Ei(e),e!==null)if(t=sa(e),t===null)e=null;else if(n=t.tag,n===13){if(e=oT(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 qp=e,null}function yT(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(lK()){case S0:return 1;case lT:return 4;case Vp:case cK:return 16;case cT:return 536870912;default:return 16}default:return 16}}var As=null,b0=null,Dh=null;function ST(){if(Dh)return Dh;var e,t=b0,n=t.length,r,o="value"in As?As.value:As.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 Dh=o.slice(e,1<r?1-r:void 0)}function Rh(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 zd(){return!0}function GP(){return!1}function pr(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)?zd:GP,this.isPropagationStopped=GP,this}return pt(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=zd)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=zd)},persist:function(){},isPersistent:zd}),t}var Al={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},P0=pr(Al),qu=pt({},Al,{view:0,detail:0}),bK=pr(qu),Nm,Fm,rc,Qf=pt({},qu,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:C0,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!==rc&&(rc&&e.type==="mousemove"?(Nm=e.screenX-rc.screenX,Fm=e.screenY-rc.screenY):Fm=Nm=0,rc=e),Nm)},movementY:function(e){return"movementY"in e?e.movementY:Fm}}),VP=pr(Qf),PK=pt({},Qf,{dataTransfer:0}),CK=pr(PK),IK=pt({},qu,{relatedTarget:0}),zm=pr(IK),EK=pt({},Al,{animationName:0,elapsedTime:0,pseudoElement:0}),kK=pr(EK),_K=pt({},Al,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),TK=pr(_K),MK=pt({},Al,{data:0}),YP=pr(MK),AK={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jK={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"},OK={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function DK(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=OK[e])?!!t[e]:!1}function C0(){return DK}var RK=pt({},qu,{key:function(e){if(e.key){var t=AK[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Rh(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?jK[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:C0,charCode:function(e){return e.type==="keypress"?Rh(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Rh(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),LK=pr(RK),$K=pt({},Qf,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),XP=pr($K),NK=pt({},qu,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:C0}),FK=pr(NK),zK=pt({},Al,{propertyName:0,elapsedTime:0,pseudoElement:0}),BK=pr(zK),UK=pt({},Qf,{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}),HK=pr(UK),KK=[9,13,27,32],I0=es&&"CompositionEvent"in window,Hc=null;es&&"documentMode"in document&&(Hc=document.documentMode);var WK=es&&"TextEvent"in window&&!Hc,vT=es&&(!I0||Hc&&8<Hc&&11>=Hc),qP=" ",ZP=!1;function xT(e,t){switch(e){case"keyup":return KK.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wT(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ja=!1;function GK(e,t){switch(e){case"compositionend":return wT(t);case"keypress":return t.which!==32?null:(ZP=!0,qP);case"textInput":return e=t.data,e===qP&&ZP?null:e;default:return null}}function VK(e,t){if(ja)return e==="compositionend"||!I0&&xT(e,t)?(e=ST(),Dh=b0=As=null,ja=!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 vT&&t.locale!=="ko"?null:t.data;default:return null}}var YK={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 QP(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!YK[e.type]:t==="textarea"}function bT(e,t,n,r){J2(r),t=Zp(t,"onChange"),0<t.length&&(n=new P0("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Kc=null,fu=null;function XK(e){OT(e,0)}function Jf(e){var t=Ra(e);if(G2(t))return e}function qK(e,t){if(e==="change")return t}var PT=!1;if(es){var Bm;if(es){var Um="oninput"in document;if(!Um){var JP=document.createElement("div");JP.setAttribute("oninput","return;"),Um=typeof JP.oninput=="function"}Bm=Um}else Bm=!1;PT=Bm&&(!document.documentMode||9<document.documentMode)}function eC(){Kc&&(Kc.detachEvent("onpropertychange",CT),fu=Kc=null)}function CT(e){if(e.propertyName==="value"&&Jf(fu)){var t=[];bT(t,fu,e,y0(e)),rT(XK,t)}}function ZK(e,t,n){e==="focusin"?(eC(),Kc=t,fu=n,Kc.attachEvent("onpropertychange",CT)):e==="focusout"&&eC()}function QK(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Jf(fu)}function JK(e,t){if(e==="click")return Jf(t)}function eW(e,t){if(e==="input"||e==="change")return Jf(t)}function tW(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Vr=typeof Object.is=="function"?Object.is:tW;function gu(e,t){if(Vr(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(!DS.call(t,o)||!Vr(e[o],t[o]))return!1}return!0}function tC(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function nC(e,t){var n=tC(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=tC(n)}}function IT(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?IT(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ET(){for(var e=window,t=Kp();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Kp(e.document)}return t}function E0(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 nW(e){var t=ET(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&IT(n.ownerDocument.documentElement,n)){if(r!==null&&E0(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=nC(n,s);var i=nC(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 rW=es&&"documentMode"in document&&11>=document.documentMode,Oa=null,JS=null,Wc=null,ev=!1;function rC(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ev||Oa==null||Oa!==Kp(r)||(r=Oa,"selectionStart"in r&&E0(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}),Wc&&gu(Wc,r)||(Wc=r,r=Zp(JS,"onSelect"),0<r.length&&(t=new P0("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Oa)))}function Bd(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Da={animationend:Bd("Animation","AnimationEnd"),animationiteration:Bd("Animation","AnimationIteration"),animationstart:Bd("Animation","AnimationStart"),transitionend:Bd("Transition","TransitionEnd")},Hm={},kT={};es&&(kT=document.createElement("div").style,"AnimationEvent"in window||(delete Da.animationend.animation,delete Da.animationiteration.animation,delete Da.animationstart.animation),"TransitionEvent"in window||delete Da.transitionend.transition);function eg(e){if(Hm[e])return Hm[e];if(!Da[e])return e;var t=Da[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in kT)return Hm[e]=t[n];return e}var _T=eg("animationend"),TT=eg("animationiteration"),MT=eg("animationstart"),AT=eg("transitionend"),jT=new Map,oC="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 ai(e,t){jT.set(e,t),oa(t,[e])}for(var Km=0;Km<oC.length;Km++){var Wm=oC[Km],oW=Wm.toLowerCase(),sW=Wm[0].toUpperCase()+Wm.slice(1);ai(oW,"on"+sW)}ai(_T,"onAnimationEnd");ai(TT,"onAnimationIteration");ai(MT,"onAnimationStart");ai("dblclick","onDoubleClick");ai("focusin","onFocus");ai("focusout","onBlur");ai(AT,"onTransitionEnd");ll("onMouseEnter",["mouseout","mouseover"]);ll("onMouseLeave",["mouseout","mouseover"]);ll("onPointerEnter",["pointerout","pointerover"]);ll("onPointerLeave",["pointerout","pointerover"]);oa("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));oa("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));oa("onBeforeInput",["compositionend","keypress","textInput","paste"]);oa("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));oa("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));oa("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var bc="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(" "),iW=new Set("cancel close invalid load scroll toggle".split(" ").concat(bc));function sC(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,oK(r,t,void 0,e),e.currentTarget=null}function OT(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],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==s&&o.isPropagationStopped())break e;sC(o,a,c),s=l}else for(i=0;i<r.length;i++){if(a=r[i],l=a.instance,c=a.currentTarget,a=a.listener,l!==s&&o.isPropagationStopped())break e;sC(o,a,c),s=l}}}if(Gp)throw e=XS,Gp=!1,XS=null,e}function Je(e,t){var n=t[sv];n===void 0&&(n=t[sv]=new Set);var r=e+"__bubble";n.has(r)||(DT(t,e,2,!1),n.add(r))}function Gm(e,t,n){var r=0;t&&(r|=4),DT(n,e,r,t)}var Ud="_reactListening"+Math.random().toString(36).slice(2);function mu(e){if(!e[Ud]){e[Ud]=!0,B2.forEach(function(n){n!=="selectionchange"&&(iW.has(n)||Gm(n,!1,e),Gm(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ud]||(t[Ud]=!0,Gm("selectionchange",!1,t))}}function DT(e,t,n,r){switch(yT(t)){case 1:var o=xK;break;case 4:o=wK;break;default:o=w0}n=o.bind(null,t,n,e),o=void 0,!YS||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 Vm(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 l=i.tag;if((l===3||l===4)&&(l=i.stateNode.containerInfo,l===o||l.nodeType===8&&l.parentNode===o))return;i=i.return}for(;a!==null;){if(i=Ei(a),i===null)return;if(l=i.tag,l===5||l===6){r=s=i;continue e}a=a.parentNode}}r=r.return}rT(function(){var c=s,u=y0(n),h=[];e:{var p=jT.get(e);if(p!==void 0){var f=P0,S=e;switch(e){case"keypress":if(Rh(n)===0)break e;case"keydown":case"keyup":f=LK;break;case"focusin":S="focus",f=zm;break;case"focusout":S="blur",f=zm;break;case"beforeblur":case"afterblur":f=zm;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=VP;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":f=CK;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":f=FK;break;case _T:case TT:case MT:f=kK;break;case AT:f=BK;break;case"scroll":f=bK;break;case"wheel":f=HK;break;case"copy":case"cut":case"paste":f=TK;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":f=XP}var y=(t&4)!==0,x=!y&&e==="scroll",m=y?p!==null?p+"Capture":null:p;y=[];for(var v=c,w;v!==null;){w=v;var C=w.stateNode;if(w.tag===5&&C!==null&&(w=C,m!==null&&(C=uu(v,m),C!=null&&y.push(yu(v,C,w)))),x)break;v=v.return}0<y.length&&(p=new f(p,S,null,n,u),h.push({event:p,listeners:y}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",f=e==="mouseout"||e==="pointerout",p&&n!==GS&&(S=n.relatedTarget||n.fromElement)&&(Ei(S)||S[ts]))break e;if((f||p)&&(p=u.window===u?u:(p=u.ownerDocument)?p.defaultView||p.parentWindow:window,f?(S=n.relatedTarget||n.toElement,f=c,S=S?Ei(S):null,S!==null&&(x=sa(S),S!==x||S.tag!==5&&S.tag!==6)&&(S=null)):(f=null,S=c),f!==S)){if(y=VP,C="onMouseLeave",m="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(y=XP,C="onPointerLeave",m="onPointerEnter",v="pointer"),x=f==null?p:Ra(f),w=S==null?p:Ra(S),p=new y(C,v+"leave",f,n,u),p.target=x,p.relatedTarget=w,C=null,Ei(u)===c&&(y=new y(m,v+"enter",S,n,u),y.target=w,y.relatedTarget=x,C=y),x=C,f&&S)t:{for(y=f,m=S,v=0,w=y;w;w=ma(w))v++;for(w=0,C=m;C;C=ma(C))w++;for(;0<v-w;)y=ma(y),v--;for(;0<w-v;)m=ma(m),w--;for(;v--;){if(y===m||m!==null&&y===m.alternate)break t;y=ma(y),m=ma(m)}y=null}else y=null;f!==null&&iC(h,p,f,y,!1),S!==null&&x!==null&&iC(h,x,S,y,!0)}}e:{if(p=c?Ra(c):window,f=p.nodeName&&p.nodeName.toLowerCase(),f==="select"||f==="input"&&p.type==="file")var E=qK;else if(QP(p))if(PT)E=eW;else{E=QK;var _=ZK}else(f=p.nodeName)&&f.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(E=JK);if(E&&(E=E(e,c))){bT(h,E,n,u);break e}_&&_(e,p,c),e==="focusout"&&(_=p._wrapperState)&&_.controlled&&p.type==="number"&&BS(p,"number",p.value)}switch(_=c?Ra(c):window,e){case"focusin":(QP(_)||_.contentEditable==="true")&&(Oa=_,JS=c,Wc=null);break;case"focusout":Wc=JS=Oa=null;break;case"mousedown":ev=!0;break;case"contextmenu":case"mouseup":case"dragend":ev=!1,rC(h,n,u);break;case"selectionchange":if(rW)break;case"keydown":case"keyup":rC(h,n,u)}var I;if(I0)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 ja?xT(e,n)&&(k="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(k="onCompositionStart");k&&(vT&&n.locale!=="ko"&&(ja||k!=="onCompositionStart"?k==="onCompositionEnd"&&ja&&(I=ST()):(As=u,b0="value"in As?As.value:As.textContent,ja=!0)),_=Zp(c,k),0<_.length&&(k=new YP(k,e,null,n,u),h.push({event:k,listeners:_}),I?k.data=I:(I=wT(n),I!==null&&(k.data=I)))),(I=WK?GK(e,n):VK(e,n))&&(c=Zp(c,"onBeforeInput"),0<c.length&&(u=new YP("onBeforeInput","beforeinput",null,n,u),h.push({event:u,listeners:c}),u.data=I))}OT(h,t)})}function yu(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Zp(e,t){for(var n=t+"Capture",r=[];e!==null;){var o=e,s=o.stateNode;o.tag===5&&s!==null&&(o=s,s=uu(e,n),s!=null&&r.unshift(yu(e,s,o)),s=uu(e,t),s!=null&&r.push(yu(e,s,o))),e=e.return}return r}function ma(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function iC(e,t,n,r,o){for(var s=t._reactName,i=[];n!==null&&n!==r;){var a=n,l=a.alternate,c=a.stateNode;if(l!==null&&l===r)break;a.tag===5&&c!==null&&(a=c,o?(l=uu(n,s),l!=null&&i.unshift(yu(n,l,a))):o||(l=uu(n,s),l!=null&&i.push(yu(n,l,a)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var aW=/\r\n?/g,lW=/\u0000|\uFFFD/g;function aC(e){return(typeof e=="string"?e:""+e).replace(aW,`
|
|
83
|
+
`).replace(lW,"")}function Hd(e,t,n){if(t=aC(t),aC(e)!==t&&n)throw Error(X(425))}function Qp(){}var tv=null,nv=null;function rv(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 ov=typeof setTimeout=="function"?setTimeout:void 0,cW=typeof clearTimeout=="function"?clearTimeout:void 0,lC=typeof Promise=="function"?Promise:void 0,uW=typeof queueMicrotask=="function"?queueMicrotask:typeof lC<"u"?function(e){return lC.resolve(null).then(e).catch(dW)}:ov;function dW(e){setTimeout(function(){throw e})}function Ym(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),pu(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=o}while(n);pu(t)}function Us(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 cC(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 jl=Math.random().toString(36).slice(2),co="__reactFiber$"+jl,Su="__reactProps$"+jl,ts="__reactContainer$"+jl,sv="__reactEvents$"+jl,hW="__reactListeners$"+jl,pW="__reactHandles$"+jl;function Ei(e){var t=e[co];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ts]||n[co]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=cC(e);e!==null;){if(n=e[co])return n;e=cC(e)}return t}e=n,n=e.parentNode}return null}function Zu(e){return e=e[co]||e[ts],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Ra(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(X(33))}function tg(e){return e[Su]||null}var iv=[],La=-1;function li(e){return{current:e}}function tt(e){0>La||(e.current=iv[La],iv[La]=null,La--)}function Ye(e,t){La++,iv[La]=e.current,e.current=t}var qs={},hn=li(qs),Kn=li(!1),Bi=qs;function cl(e,t){var n=e.type.contextTypes;if(!n)return qs;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 Wn(e){return e=e.childContextTypes,e!=null}function Jp(){tt(Kn),tt(hn)}function uC(e,t,n){if(hn.current!==qs)throw Error(X(168));Ye(hn,t),Ye(Kn,n)}function RT(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(X(108,ZH(e)||"Unknown",o));return pt({},n,r)}function ef(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||qs,Bi=hn.current,Ye(hn,e),Ye(Kn,Kn.current),!0}function dC(e,t,n){var r=e.stateNode;if(!r)throw Error(X(169));n?(e=RT(e,t,Bi),r.__reactInternalMemoizedMergedChildContext=e,tt(Kn),tt(hn),Ye(hn,e)):tt(Kn),Ye(Kn,n)}var Bo=null,ng=!1,Xm=!1;function LT(e){Bo===null?Bo=[e]:Bo.push(e)}function fW(e){ng=!0,LT(e)}function ci(){if(!Xm&&Bo!==null){Xm=!0;var e=0,t=Ne;try{var n=Bo;for(Ne=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Bo=null,ng=!1}catch(o){throw Bo!==null&&(Bo=Bo.slice(e+1)),aT(S0,ci),o}finally{Ne=t,Xm=!1}}return null}var $a=[],Na=0,tf=null,nf=0,br=[],Pr=0,Ui=null,Ho=1,Ko="";function bi(e,t){$a[Na++]=nf,$a[Na++]=tf,tf=e,nf=t}function $T(e,t,n){br[Pr++]=Ho,br[Pr++]=Ko,br[Pr++]=Ui,Ui=e;var r=Ho;e=Ko;var o=32-Hr(r)-1;r&=~(1<<o),n+=1;var s=32-Hr(t)+o;if(30<s){var i=o-o%5;s=(r&(1<<i)-1).toString(32),r>>=i,o-=i,Ho=1<<32-Hr(t)+o|n<<o|r,Ko=s+e}else Ho=1<<s|n<<o|r,Ko=e}function k0(e){e.return!==null&&(bi(e,1),$T(e,1,0))}function _0(e){for(;e===tf;)tf=$a[--Na],$a[Na]=null,nf=$a[--Na],$a[Na]=null;for(;e===Ui;)Ui=br[--Pr],br[Pr]=null,Ko=br[--Pr],br[Pr]=null,Ho=br[--Pr],br[Pr]=null}var ir=null,nr=null,ot=!1,Fr=null;function NT(e,t){var n=Cr(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 hC(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,ir=e,nr=Us(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ir=e,nr=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ui!==null?{id:Ho,overflow:Ko}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Cr(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ir=e,nr=null,!0):!1;default:return!1}}function av(e){return(e.mode&1)!==0&&(e.flags&128)===0}function lv(e){if(ot){var t=nr;if(t){var n=t;if(!hC(e,t)){if(av(e))throw Error(X(418));t=Us(n.nextSibling);var r=ir;t&&hC(e,t)?NT(r,n):(e.flags=e.flags&-4097|2,ot=!1,ir=e)}}else{if(av(e))throw Error(X(418));e.flags=e.flags&-4097|2,ot=!1,ir=e}}}function pC(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ir=e}function Kd(e){if(e!==ir)return!1;if(!ot)return pC(e),ot=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!rv(e.type,e.memoizedProps)),t&&(t=nr)){if(av(e))throw FT(),Error(X(418));for(;t;)NT(e,t),t=Us(t.nextSibling)}if(pC(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(X(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){nr=Us(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}nr=null}}else nr=ir?Us(e.stateNode.nextSibling):null;return!0}function FT(){for(var e=nr;e;)e=Us(e.nextSibling)}function ul(){nr=ir=null,ot=!1}function T0(e){Fr===null?Fr=[e]:Fr.push(e)}var gW=us.ReactCurrentBatchConfig;function oc(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(X(309));var r=n.stateNode}if(!r)throw Error(X(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(X(284));if(!n._owner)throw Error(X(290,e))}return e}function Wd(e,t){throw e=Object.prototype.toString.call(t),Error(X(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function fC(e){var t=e._init;return t(e._payload)}function zT(e){function t(m,v){if(e){var w=m.deletions;w===null?(m.deletions=[v],m.flags|=16):w.push(v)}}function n(m,v){if(!e)return null;for(;v!==null;)t(m,v),v=v.sibling;return null}function r(m,v){for(m=new Map;v!==null;)v.key!==null?m.set(v.key,v):m.set(v.index,v),v=v.sibling;return m}function o(m,v){return m=Gs(m,v),m.index=0,m.sibling=null,m}function s(m,v,w){return m.index=w,e?(w=m.alternate,w!==null?(w=w.index,w<v?(m.flags|=2,v):w):(m.flags|=2,v)):(m.flags|=1048576,v)}function i(m){return e&&m.alternate===null&&(m.flags|=2),m}function a(m,v,w,C){return v===null||v.tag!==6?(v=ny(w,m.mode,C),v.return=m,v):(v=o(v,w),v.return=m,v)}function l(m,v,w,C){var E=w.type;return E===Aa?u(m,v,w.props.children,C,w.key):v!==null&&(v.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Is&&fC(E)===v.type)?(C=o(v,w.props),C.ref=oc(m,v,w),C.return=m,C):(C=Uh(w.type,w.key,w.props,null,m.mode,C),C.ref=oc(m,v,w),C.return=m,C)}function c(m,v,w,C){return v===null||v.tag!==4||v.stateNode.containerInfo!==w.containerInfo||v.stateNode.implementation!==w.implementation?(v=ry(w,m.mode,C),v.return=m,v):(v=o(v,w.children||[]),v.return=m,v)}function u(m,v,w,C,E){return v===null||v.tag!==7?(v=Di(w,m.mode,C,E),v.return=m,v):(v=o(v,w),v.return=m,v)}function h(m,v,w){if(typeof v=="string"&&v!==""||typeof v=="number")return v=ny(""+v,m.mode,w),v.return=m,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Dd:return w=Uh(v.type,v.key,v.props,null,m.mode,w),w.ref=oc(m,null,v),w.return=m,w;case Ma:return v=ry(v,m.mode,w),v.return=m,v;case Is:var C=v._init;return h(m,C(v._payload),w)}if(xc(v)||Jl(v))return v=Di(v,m.mode,w,null),v.return=m,v;Wd(m,v)}return null}function p(m,v,w,C){var E=v!==null?v.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return E!==null?null:a(m,v,""+w,C);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Dd:return w.key===E?l(m,v,w,C):null;case Ma:return w.key===E?c(m,v,w,C):null;case Is:return E=w._init,p(m,v,E(w._payload),C)}if(xc(w)||Jl(w))return E!==null?null:u(m,v,w,C,null);Wd(m,w)}return null}function f(m,v,w,C,E){if(typeof C=="string"&&C!==""||typeof C=="number")return m=m.get(w)||null,a(v,m,""+C,E);if(typeof C=="object"&&C!==null){switch(C.$$typeof){case Dd:return m=m.get(C.key===null?w:C.key)||null,l(v,m,C,E);case Ma:return m=m.get(C.key===null?w:C.key)||null,c(v,m,C,E);case Is:var _=C._init;return f(m,v,w,_(C._payload),E)}if(xc(C)||Jl(C))return m=m.get(w)||null,u(v,m,C,E,null);Wd(v,C)}return null}function S(m,v,w,C){for(var E=null,_=null,I=v,k=v=0,T=null;I!==null&&k<w.length;k++){I.index>k?(T=I,I=null):T=I.sibling;var M=p(m,I,w[k],C);if(M===null){I===null&&(I=T);break}e&&I&&M.alternate===null&&t(m,I),v=s(M,v,k),_===null?E=M:_.sibling=M,_=M,I=T}if(k===w.length)return n(m,I),ot&&bi(m,k),E;if(I===null){for(;k<w.length;k++)I=h(m,w[k],C),I!==null&&(v=s(I,v,k),_===null?E=I:_.sibling=I,_=I);return ot&&bi(m,k),E}for(I=r(m,I);k<w.length;k++)T=f(I,m,k,w[k],C),T!==null&&(e&&T.alternate!==null&&I.delete(T.key===null?k:T.key),v=s(T,v,k),_===null?E=T:_.sibling=T,_=T);return e&&I.forEach(function(D){return t(m,D)}),ot&&bi(m,k),E}function y(m,v,w,C){var E=Jl(w);if(typeof E!="function")throw Error(X(150));if(w=E.call(w),w==null)throw Error(X(151));for(var _=E=null,I=v,k=v=0,T=null,M=w.next();I!==null&&!M.done;k++,M=w.next()){I.index>k?(T=I,I=null):T=I.sibling;var D=p(m,I,M.value,C);if(D===null){I===null&&(I=T);break}e&&I&&D.alternate===null&&t(m,I),v=s(D,v,k),_===null?E=D:_.sibling=D,_=D,I=T}if(M.done)return n(m,I),ot&&bi(m,k),E;if(I===null){for(;!M.done;k++,M=w.next())M=h(m,M.value,C),M!==null&&(v=s(M,v,k),_===null?E=M:_.sibling=M,_=M);return ot&&bi(m,k),E}for(I=r(m,I);!M.done;k++,M=w.next())M=f(I,m,k,M.value,C),M!==null&&(e&&M.alternate!==null&&I.delete(M.key===null?k:M.key),v=s(M,v,k),_===null?E=M:_.sibling=M,_=M);return e&&I.forEach(function($){return t(m,$)}),ot&&bi(m,k),E}function x(m,v,w,C){if(typeof w=="object"&&w!==null&&w.type===Aa&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Dd:e:{for(var E=w.key,_=v;_!==null;){if(_.key===E){if(E=w.type,E===Aa){if(_.tag===7){n(m,_.sibling),v=o(_,w.props.children),v.return=m,m=v;break e}}else if(_.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Is&&fC(E)===_.type){n(m,_.sibling),v=o(_,w.props),v.ref=oc(m,_,w),v.return=m,m=v;break e}n(m,_);break}else t(m,_);_=_.sibling}w.type===Aa?(v=Di(w.props.children,m.mode,C,w.key),v.return=m,m=v):(C=Uh(w.type,w.key,w.props,null,m.mode,C),C.ref=oc(m,v,w),C.return=m,m=C)}return i(m);case Ma:e:{for(_=w.key;v!==null;){if(v.key===_)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(m,v.sibling),v=o(v,w.children||[]),v.return=m,m=v;break e}else{n(m,v);break}else t(m,v);v=v.sibling}v=ry(w,m.mode,C),v.return=m,m=v}return i(m);case Is:return _=w._init,x(m,v,_(w._payload),C)}if(xc(w))return S(m,v,w,C);if(Jl(w))return y(m,v,w,C);Wd(m,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(m,v.sibling),v=o(v,w),v.return=m,m=v):(n(m,v),v=ny(w,m.mode,C),v.return=m,m=v),i(m)):n(m,v)}return x}var dl=zT(!0),BT=zT(!1),rf=li(null),of=null,Fa=null,M0=null;function A0(){M0=Fa=of=null}function j0(e){var t=rf.current;tt(rf),e._currentValue=t}function cv(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 Ja(e,t){of=e,M0=Fa=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(zn=!0),e.firstContext=null)}function _r(e){var t=e._currentValue;if(M0!==e)if(e={context:e,memoizedValue:t,next:null},Fa===null){if(of===null)throw Error(X(308));Fa=e,of.dependencies={lanes:0,firstContext:e}}else Fa=Fa.next=e;return t}var ki=null;function O0(e){ki===null?ki=[e]:ki.push(e)}function UT(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,O0(t)):(n.next=o.next,o.next=n),t.interleaved=n,ns(e,r)}function ns(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 Es=!1;function D0(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function HT(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 Yo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Hs(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ae&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,ns(e,n)}return o=r.interleaved,o===null?(t.next=t,O0(r)):(t.next=o.next,o.next=t),r.interleaved=t,ns(e,n)}function Lh(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,v0(e,n)}}function gC(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 sf(e,t,n,r){var o=e.updateQueue;Es=!1;var s=o.firstBaseUpdate,i=o.lastBaseUpdate,a=o.shared.pending;if(a!==null){o.shared.pending=null;var l=a,c=l.next;l.next=null,i===null?s=c:i.next=c,i=l;var u=e.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==i&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(s!==null){var h=o.baseState;i=0,u=c=l=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 S=e,y=a;switch(p=t,f=n,y.tag){case 1:if(S=y.payload,typeof S=="function"){h=S.call(f,h,p);break e}h=S;break e;case 3:S.flags=S.flags&-65537|128;case 0:if(S=y.payload,p=typeof S=="function"?S.call(f,h,p):S,p==null)break e;h=pt({},h,p);break e;case 2:Es=!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?(c=u=f,l=h):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&&(l=h),o.baseState=l,o.firstBaseUpdate=c,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);Ki|=i,e.lanes=i,e.memoizedState=h}}function mC(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(X(191,o));o.call(r)}}}var Qu={},vo=li(Qu),vu=li(Qu),xu=li(Qu);function _i(e){if(e===Qu)throw Error(X(174));return e}function R0(e,t){switch(Ye(xu,t),Ye(vu,e),Ye(vo,Qu),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:HS(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=HS(t,e)}tt(vo),Ye(vo,t)}function hl(){tt(vo),tt(vu),tt(xu)}function KT(e){_i(xu.current);var t=_i(vo.current),n=HS(t,e.type);t!==n&&(Ye(vu,e),Ye(vo,n))}function L0(e){vu.current===e&&(tt(vo),tt(vu))}var lt=li(0);function af(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 qm=[];function $0(){for(var e=0;e<qm.length;e++)qm[e]._workInProgressVersionPrimary=null;qm.length=0}var $h=us.ReactCurrentDispatcher,Zm=us.ReactCurrentBatchConfig,Hi=0,ht=null,It=null,Tt=null,lf=!1,Gc=!1,wu=0,mW=0;function en(){throw Error(X(321))}function N0(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Vr(e[n],t[n]))return!1;return!0}function F0(e,t,n,r,o,s){if(Hi=s,ht=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,$h.current=e===null||e.memoizedState===null?xW:wW,e=n(r,o),Gc){s=0;do{if(Gc=!1,wu=0,25<=s)throw Error(X(301));s+=1,Tt=It=null,t.updateQueue=null,$h.current=bW,e=n(r,o)}while(Gc)}if($h.current=cf,t=It!==null&&It.next!==null,Hi=0,Tt=It=ht=null,lf=!1,t)throw Error(X(300));return e}function z0(){var e=wu!==0;return wu=0,e}function so(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Tt===null?ht.memoizedState=Tt=e:Tt=Tt.next=e,Tt}function Tr(){if(It===null){var e=ht.alternate;e=e!==null?e.memoizedState:null}else e=It.next;var t=Tt===null?ht.memoizedState:Tt.next;if(t!==null)Tt=t,It=e;else{if(e===null)throw Error(X(310));It=e,e={memoizedState:It.memoizedState,baseState:It.baseState,baseQueue:It.baseQueue,queue:It.queue,next:null},Tt===null?ht.memoizedState=Tt=e:Tt=Tt.next=e}return Tt}function bu(e,t){return typeof t=="function"?t(e):t}function Qm(e){var t=Tr(),n=t.queue;if(n===null)throw Error(X(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,l=null,c=s;do{var u=c.lane;if((Hi&u)===u)l!==null&&(l=l.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:e(r,c.action);else{var h={lane:u,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=h,i=r):l=l.next=h,ht.lanes|=u,Ki|=u}c=c.next}while(c!==null&&c!==s);l===null?i=r:l.next=a,Vr(r,t.memoizedState)||(zn=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=l,n.lastRenderedState=r}if(e=n.interleaved,e!==null){o=e;do s=o.lane,ht.lanes|=s,Ki|=s,o=o.next;while(o!==e)}else o===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Jm(e){var t=Tr(),n=t.queue;if(n===null)throw Error(X(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);Vr(s,t.memoizedState)||(zn=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function WT(){}function GT(e,t){var n=ht,r=Tr(),o=t(),s=!Vr(r.memoizedState,o);if(s&&(r.memoizedState=o,zn=!0),r=r.queue,B0(XT.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||Tt!==null&&Tt.memoizedState.tag&1){if(n.flags|=2048,Pu(9,YT.bind(null,n,r,o,t),void 0,null),Dt===null)throw Error(X(349));Hi&30||VT(n,t,o)}return o}function VT(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=ht.updateQueue,t===null?(t={lastEffect:null,stores:null},ht.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function YT(e,t,n,r){t.value=n,t.getSnapshot=r,qT(t)&&ZT(e)}function XT(e,t,n){return n(function(){qT(t)&&ZT(e)})}function qT(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Vr(e,n)}catch{return!0}}function ZT(e){var t=ns(e,1);t!==null&&Kr(t,e,1,-1)}function yC(e){var t=so();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:bu,lastRenderedState:e},t.queue=e,e=e.dispatch=vW.bind(null,ht,e),[t.memoizedState,e]}function Pu(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=ht.updateQueue,t===null?(t={lastEffect:null,stores:null},ht.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 QT(){return Tr().memoizedState}function Nh(e,t,n,r){var o=so();ht.flags|=e,o.memoizedState=Pu(1|t,n,void 0,r===void 0?null:r)}function rg(e,t,n,r){var o=Tr();r=r===void 0?null:r;var s=void 0;if(It!==null){var i=It.memoizedState;if(s=i.destroy,r!==null&&N0(r,i.deps)){o.memoizedState=Pu(t,n,s,r);return}}ht.flags|=e,o.memoizedState=Pu(1|t,n,s,r)}function SC(e,t){return Nh(8390656,8,e,t)}function B0(e,t){return rg(2048,8,e,t)}function JT(e,t){return rg(4,2,e,t)}function eM(e,t){return rg(4,4,e,t)}function tM(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 nM(e,t,n){return n=n!=null?n.concat([e]):null,rg(4,4,tM.bind(null,t,e),n)}function U0(){}function rM(e,t){var n=Tr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&N0(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function oM(e,t){var n=Tr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&N0(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function sM(e,t,n){return Hi&21?(Vr(n,t)||(n=uT(),ht.lanes|=n,Ki|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,zn=!0),e.memoizedState=n)}function yW(e,t){var n=Ne;Ne=n!==0&&4>n?n:4,e(!0);var r=Zm.transition;Zm.transition={};try{e(!1),t()}finally{Ne=n,Zm.transition=r}}function iM(){return Tr().memoizedState}function SW(e,t,n){var r=Ws(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},aM(e))lM(t,n);else if(n=UT(e,t,n,r),n!==null){var o=vn();Kr(n,e,r,o),cM(n,t,r)}}function vW(e,t,n){var r=Ws(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(aM(e))lM(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,Vr(a,i)){var l=t.interleaved;l===null?(o.next=o,O0(t)):(o.next=l.next,l.next=o),t.interleaved=o;return}}catch{}finally{}n=UT(e,t,o,r),n!==null&&(o=vn(),Kr(n,e,r,o),cM(n,t,r))}}function aM(e){var t=e.alternate;return e===ht||t!==null&&t===ht}function lM(e,t){Gc=lf=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function cM(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,v0(e,n)}}var cf={readContext:_r,useCallback:en,useContext:en,useEffect:en,useImperativeHandle:en,useInsertionEffect:en,useLayoutEffect:en,useMemo:en,useReducer:en,useRef:en,useState:en,useDebugValue:en,useDeferredValue:en,useTransition:en,useMutableSource:en,useSyncExternalStore:en,useId:en,unstable_isNewReconciler:!1},xW={readContext:_r,useCallback:function(e,t){return so().memoizedState=[e,t===void 0?null:t],e},useContext:_r,useEffect:SC,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Nh(4194308,4,tM.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Nh(4194308,4,e,t)},useInsertionEffect:function(e,t){return Nh(4,2,e,t)},useMemo:function(e,t){var n=so();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=so();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=SW.bind(null,ht,e),[r.memoizedState,e]},useRef:function(e){var t=so();return e={current:e},t.memoizedState=e},useState:yC,useDebugValue:U0,useDeferredValue:function(e){return so().memoizedState=e},useTransition:function(){var e=yC(!1),t=e[0];return e=yW.bind(null,e[1]),so().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ht,o=so();if(ot){if(n===void 0)throw Error(X(407));n=n()}else{if(n=t(),Dt===null)throw Error(X(349));Hi&30||VT(r,t,n)}o.memoizedState=n;var s={value:n,getSnapshot:t};return o.queue=s,SC(XT.bind(null,r,s,e),[e]),r.flags|=2048,Pu(9,YT.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=so(),t=Dt.identifierPrefix;if(ot){var n=Ko,r=Ho;n=(r&~(1<<32-Hr(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=wu++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=mW++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},wW={readContext:_r,useCallback:rM,useContext:_r,useEffect:B0,useImperativeHandle:nM,useInsertionEffect:JT,useLayoutEffect:eM,useMemo:oM,useReducer:Qm,useRef:QT,useState:function(){return Qm(bu)},useDebugValue:U0,useDeferredValue:function(e){var t=Tr();return sM(t,It.memoizedState,e)},useTransition:function(){var e=Qm(bu)[0],t=Tr().memoizedState;return[e,t]},useMutableSource:WT,useSyncExternalStore:GT,useId:iM,unstable_isNewReconciler:!1},bW={readContext:_r,useCallback:rM,useContext:_r,useEffect:B0,useImperativeHandle:nM,useInsertionEffect:JT,useLayoutEffect:eM,useMemo:oM,useReducer:Jm,useRef:QT,useState:function(){return Jm(bu)},useDebugValue:U0,useDeferredValue:function(e){var t=Tr();return It===null?t.memoizedState=e:sM(t,It.memoizedState,e)},useTransition:function(){var e=Jm(bu)[0],t=Tr().memoizedState;return[e,t]},useMutableSource:WT,useSyncExternalStore:GT,useId:iM,unstable_isNewReconciler:!1};function Rr(e,t){if(e&&e.defaultProps){t=pt({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function uv(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:pt({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var og={isMounted:function(e){return(e=e._reactInternals)?sa(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=vn(),o=Ws(e),s=Yo(r,o);s.payload=t,n!=null&&(s.callback=n),t=Hs(e,s,o),t!==null&&(Kr(t,e,o,r),Lh(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=vn(),o=Ws(e),s=Yo(r,o);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=Hs(e,s,o),t!==null&&(Kr(t,e,o,r),Lh(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=vn(),r=Ws(e),o=Yo(n,r);o.tag=2,t!=null&&(o.callback=t),t=Hs(e,o,r),t!==null&&(Kr(t,e,r,n),Lh(t,e,r))}};function vC(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?!gu(n,r)||!gu(o,s):!0}function uM(e,t,n){var r=!1,o=qs,s=t.contextType;return typeof s=="object"&&s!==null?s=_r(s):(o=Wn(t)?Bi:hn.current,r=t.contextTypes,s=(r=r!=null)?cl(e,o):qs),t=new t(n,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=og,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=o,e.__reactInternalMemoizedMaskedChildContext=s),t}function xC(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&&og.enqueueReplaceState(t,t.state,null)}function dv(e,t,n,r){var o=e.stateNode;o.props=n,o.state=e.memoizedState,o.refs={},D0(e);var s=t.contextType;typeof s=="object"&&s!==null?o.context=_r(s):(s=Wn(t)?Bi:hn.current,o.context=cl(e,s)),o.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(uv(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&&og.enqueueReplaceState(o,o.state,null),sf(e,n,o,r),o.state=e.memoizedState),typeof o.componentDidMount=="function"&&(e.flags|=4194308)}function pl(e,t){try{var n="",r=t;do n+=qH(r),r=r.return;while(r);var o=n}catch(s){o=`
|
|
84
|
+
Error generating stack: `+s.message+`
|
|
85
|
+
`+s.stack}return{value:e,source:t,stack:o,digest:null}}function ey(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function hv(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var PW=typeof WeakMap=="function"?WeakMap:Map;function dM(e,t,n){n=Yo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){df||(df=!0,bv=r),hv(e,t)},n}function hM(e,t,n){n=Yo(-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(){hv(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){hv(e,t),typeof r!="function"&&(Ks===null?Ks=new Set([this]):Ks.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function wC(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new PW;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=$W.bind(null,e,t,n),t.then(e,e))}function bC(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 PC(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=Yo(-1,1),t.tag=2,Hs(n,t,1))),n.lanes|=1),e)}var CW=us.ReactCurrentOwner,zn=!1;function mn(e,t,n,r){t.child=e===null?BT(t,null,n,r):dl(t,e.child,n,r)}function CC(e,t,n,r,o){n=n.render;var s=t.ref;return Ja(t,o),r=F0(e,t,n,r,s,o),n=z0(),e!==null&&!zn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,rs(e,t,o)):(ot&&n&&k0(t),t.flags|=1,mn(e,t,r,o),t.child)}function IC(e,t,n,r,o){if(e===null){var s=n.type;return typeof s=="function"&&!q0(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,pM(e,t,s,r,o)):(e=Uh(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:gu,n(i,r)&&e.ref===t.ref)return rs(e,t,o)}return t.flags|=1,e=Gs(s,r),e.ref=t.ref,e.return=t,t.child=e}function pM(e,t,n,r,o){if(e!==null){var s=e.memoizedProps;if(gu(s,r)&&e.ref===t.ref)if(zn=!1,t.pendingProps=r=s,(e.lanes&o)!==0)e.flags&131072&&(zn=!0);else return t.lanes=e.lanes,rs(e,t,o)}return pv(e,t,n,r,o)}function fM(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},Ye(Ba,Jn),Jn|=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,Ye(Ba,Jn),Jn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,Ye(Ba,Jn),Jn|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,Ye(Ba,Jn),Jn|=r;return mn(e,t,o,n),t.child}function gM(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function pv(e,t,n,r,o){var s=Wn(n)?Bi:hn.current;return s=cl(t,s),Ja(t,o),n=F0(e,t,n,r,s,o),r=z0(),e!==null&&!zn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,rs(e,t,o)):(ot&&r&&k0(t),t.flags|=1,mn(e,t,n,o),t.child)}function EC(e,t,n,r,o){if(Wn(n)){var s=!0;ef(t)}else s=!1;if(Ja(t,o),t.stateNode===null)Fh(e,t),uM(t,n,r),dv(t,n,r,o),r=!0;else if(e===null){var i=t.stateNode,a=t.memoizedProps;i.props=a;var l=i.context,c=n.contextType;typeof c=="object"&&c!==null?c=_r(c):(c=Wn(n)?Bi:hn.current,c=cl(t,c));var u=n.getDerivedStateFromProps,h=typeof u=="function"||typeof i.getSnapshotBeforeUpdate=="function";h||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(a!==r||l!==c)&&xC(t,i,r,c),Es=!1;var p=t.memoizedState;i.state=p,sf(t,r,i,o),l=t.memoizedState,a!==r||p!==l||Kn.current||Es?(typeof u=="function"&&(uv(t,n,u,r),l=t.memoizedState),(a=Es||vC(t,n,a,r,p,l,c))?(h||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=l),i.props=r,i.state=l,i.context=c,r=a):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,HT(e,t),a=t.memoizedProps,c=t.type===t.elementType?a:Rr(t.type,a),i.props=c,h=t.pendingProps,p=i.context,l=n.contextType,typeof l=="object"&&l!==null?l=_r(l):(l=Wn(n)?Bi:hn.current,l=cl(t,l));var f=n.getDerivedStateFromProps;(u=typeof f=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(a!==h||p!==l)&&xC(t,i,r,l),Es=!1,p=t.memoizedState,i.state=p,sf(t,r,i,o);var S=t.memoizedState;a!==h||p!==S||Kn.current||Es?(typeof f=="function"&&(uv(t,n,f,r),S=t.memoizedState),(c=Es||vC(t,n,c,r,p,S,l)||!1)?(u||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,S,l),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,S,l)),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=S),i.props=r,i.state=S,i.context=l,r=c):(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 fv(e,t,n,r,s,o)}function fv(e,t,n,r,o,s){gM(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return o&&dC(t,n,!1),rs(e,t,s);r=t.stateNode,CW.current=t;var a=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=dl(t,e.child,null,s),t.child=dl(t,null,a,s)):mn(e,t,a,s),t.memoizedState=r.state,o&&dC(t,n,!0),t.child}function mM(e){var t=e.stateNode;t.pendingContext?uC(e,t.pendingContext,t.pendingContext!==t.context):t.context&&uC(e,t.context,!1),R0(e,t.containerInfo)}function kC(e,t,n,r,o){return ul(),T0(o),t.flags|=256,mn(e,t,n,r),t.child}var gv={dehydrated:null,treeContext:null,retryLane:0};function mv(e){return{baseLanes:e,cachePool:null,transitions:null}}function yM(e,t,n){var r=t.pendingProps,o=lt.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),Ye(lt,o&1),e===null)return lv(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=ag(i,r,0,null),e=Di(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=mv(n),t.memoizedState=gv,e):H0(t,i));if(o=e.memoizedState,o!==null&&(a=o.dehydrated,a!==null))return IW(e,t,i,r,a,o,n);if(s){s=r.fallback,i=t.mode,o=e.child,a=o.sibling;var l={mode:"hidden",children:r.children};return!(i&1)&&t.child!==o?(r=t.child,r.childLanes=0,r.pendingProps=l,t.deletions=null):(r=Gs(o,l),r.subtreeFlags=o.subtreeFlags&14680064),a!==null?s=Gs(a,s):(s=Di(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?mv(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},s.memoizedState=i,s.childLanes=e.childLanes&~n,t.memoizedState=gv,r}return s=e.child,e=s.sibling,r=Gs(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 H0(e,t){return t=ag({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Gd(e,t,n,r){return r!==null&&T0(r),dl(t,e.child,null,n),e=H0(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function IW(e,t,n,r,o,s,i){if(n)return t.flags&256?(t.flags&=-257,r=ey(Error(X(422))),Gd(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,o=t.mode,r=ag({mode:"visible",children:r.children},o,0,null),s=Di(s,o,i,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&dl(t,e.child,null,i),t.child.memoizedState=mv(i),t.memoizedState=gv,s);if(!(t.mode&1))return Gd(e,t,i,null);if(o.data==="$!"){if(r=o.nextSibling&&o.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(X(419)),r=ey(s,r,void 0),Gd(e,t,i,r)}if(a=(i&e.childLanes)!==0,zn||a){if(r=Dt,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,ns(e,o),Kr(r,e,o,-1))}return X0(),r=ey(Error(X(421))),Gd(e,t,i,r)}return o.data==="$?"?(t.flags|=128,t.child=e.child,t=NW.bind(null,e),o._reactRetry=t,null):(e=s.treeContext,nr=Us(o.nextSibling),ir=t,ot=!0,Fr=null,e!==null&&(br[Pr++]=Ho,br[Pr++]=Ko,br[Pr++]=Ui,Ho=e.id,Ko=e.overflow,Ui=t),t=H0(t,r.children),t.flags|=4096,t)}function _C(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),cv(e.return,t,n)}function ty(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 SM(e,t,n){var r=t.pendingProps,o=r.revealOrder,s=r.tail;if(mn(e,t,r.children,n),r=lt.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&&_C(e,n,t);else if(e.tag===19)_C(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ye(lt,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&&af(e)===null&&(o=n),n=n.sibling;n=o,n===null?(o=t.child,t.child=null):(o=n.sibling,n.sibling=null),ty(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&&af(e)===null){t.child=o;break}e=o.sibling,o.sibling=n,n=o,o=e}ty(t,!0,n,null,s);break;case"together":ty(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Fh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function rs(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Ki|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(X(153));if(t.child!==null){for(e=t.child,n=Gs(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Gs(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function EW(e,t,n){switch(t.tag){case 3:mM(t),ul();break;case 5:KT(t);break;case 1:Wn(t.type)&&ef(t);break;case 4:R0(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,o=t.memoizedProps.value;Ye(rf,r._currentValue),r._currentValue=o;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Ye(lt,lt.current&1),t.flags|=128,null):n&t.child.childLanes?yM(e,t,n):(Ye(lt,lt.current&1),e=rs(e,t,n),e!==null?e.sibling:null);Ye(lt,lt.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return SM(e,t,n);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),Ye(lt,lt.current),r)break;return null;case 22:case 23:return t.lanes=0,fM(e,t,n)}return rs(e,t,n)}var vM,yv,xM,wM;vM=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}};yv=function(){};xM=function(e,t,n,r){var o=e.memoizedProps;if(o!==r){e=t.stateNode,_i(vo.current);var s=null;switch(n){case"input":o=FS(e,o),r=FS(e,r),s=[];break;case"select":o=pt({},o,{value:void 0}),r=pt({},r,{value:void 0}),s=[];break;case"textarea":o=US(e,o),r=US(e,r),s=[];break;default:typeof o.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Qp)}KS(n,r);var i;n=null;for(c in o)if(!r.hasOwnProperty(c)&&o.hasOwnProperty(c)&&o[c]!=null)if(c==="style"){var a=o[c];for(i in a)a.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(lu.hasOwnProperty(c)?s||(s=[]):(s=s||[]).push(c,null));for(c in r){var l=r[c];if(a=o!=null?o[c]:void 0,r.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(i in a)!a.hasOwnProperty(i)||l&&l.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in l)l.hasOwnProperty(i)&&a[i]!==l[i]&&(n||(n={}),n[i]=l[i])}else n||(s||(s=[]),s.push(c,n)),n=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(s=s||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(s=s||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(lu.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&Je("scroll",e),s||a===l||(s=[])):(s=s||[]).push(c,l))}n&&(s=s||[]).push("style",n);var c=s;(t.updateQueue=c)&&(t.flags|=4)}};wM=function(e,t,n,r){n!==r&&(t.flags|=4)};function sc(e,t){if(!ot)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 tn(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 kW(e,t,n){var r=t.pendingProps;switch(_0(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return tn(t),null;case 1:return Wn(t.type)&&Jp(),tn(t),null;case 3:return r=t.stateNode,hl(),tt(Kn),tt(hn),$0(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Kd(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Fr!==null&&(Iv(Fr),Fr=null))),yv(e,t),tn(t),null;case 5:L0(t);var o=_i(xu.current);if(n=t.type,e!==null&&t.stateNode!=null)xM(e,t,n,r,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(X(166));return tn(t),null}if(e=_i(vo.current),Kd(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[co]=t,r[Su]=s,e=(t.mode&1)!==0,n){case"dialog":Je("cancel",r),Je("close",r);break;case"iframe":case"object":case"embed":Je("load",r);break;case"video":case"audio":for(o=0;o<bc.length;o++)Je(bc[o],r);break;case"source":Je("error",r);break;case"img":case"image":case"link":Je("error",r),Je("load",r);break;case"details":Je("toggle",r);break;case"input":$P(r,s),Je("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},Je("invalid",r);break;case"textarea":FP(r,s),Je("invalid",r)}KS(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&&Hd(r.textContent,a,e),o=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(s.suppressHydrationWarning!==!0&&Hd(r.textContent,a,e),o=["children",""+a]):lu.hasOwnProperty(i)&&a!=null&&i==="onScroll"&&Je("scroll",r)}switch(n){case"input":Rd(r),NP(r,s,!0);break;case"textarea":Rd(r),zP(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=Qp)}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=X2(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[co]=t,e[Su]=r,vM(e,t,!1,!1),t.stateNode=e;e:{switch(i=WS(n,r),n){case"dialog":Je("cancel",e),Je("close",e),o=r;break;case"iframe":case"object":case"embed":Je("load",e),o=r;break;case"video":case"audio":for(o=0;o<bc.length;o++)Je(bc[o],e);o=r;break;case"source":Je("error",e),o=r;break;case"img":case"image":case"link":Je("error",e),Je("load",e),o=r;break;case"details":Je("toggle",e),o=r;break;case"input":$P(e,r),o=FS(e,r),Je("invalid",e);break;case"option":o=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},o=pt({},r,{value:void 0}),Je("invalid",e);break;case"textarea":FP(e,r),o=US(e,r),Je("invalid",e);break;default:o=r}KS(n,o),a=o;for(s in a)if(a.hasOwnProperty(s)){var l=a[s];s==="style"?Q2(e,l):s==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&q2(e,l)):s==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&cu(e,l):typeof l=="number"&&cu(e,""+l):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(lu.hasOwnProperty(s)?l!=null&&s==="onScroll"&&Je("scroll",e):l!=null&&p0(e,s,l,i))}switch(n){case"input":Rd(e),NP(e,r,!1);break;case"textarea":Rd(e),zP(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Xs(r.value));break;case"select":e.multiple=!!r.multiple,s=r.value,s!=null?Xa(e,!!r.multiple,s,!1):r.defaultValue!=null&&Xa(e,!!r.multiple,r.defaultValue,!0);break;default:typeof o.onClick=="function"&&(e.onclick=Qp)}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 tn(t),null;case 6:if(e&&t.stateNode!=null)wM(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(X(166));if(n=_i(xu.current),_i(vo.current),Kd(t)){if(r=t.stateNode,n=t.memoizedProps,r[co]=t,(s=r.nodeValue!==n)&&(e=ir,e!==null))switch(e.tag){case 3:Hd(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Hd(r.nodeValue,n,(e.mode&1)!==0)}s&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[co]=t,t.stateNode=r}return tn(t),null;case 13:if(tt(lt),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ot&&nr!==null&&t.mode&1&&!(t.flags&128))FT(),ul(),t.flags|=98560,s=!1;else if(s=Kd(t),r!==null&&r.dehydrated!==null){if(e===null){if(!s)throw Error(X(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(X(317));s[co]=t}else ul(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;tn(t),s=!1}else Fr!==null&&(Iv(Fr),Fr=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||lt.current&1?Et===0&&(Et=3):X0())),t.updateQueue!==null&&(t.flags|=4),tn(t),null);case 4:return hl(),yv(e,t),e===null&&mu(t.stateNode.containerInfo),tn(t),null;case 10:return j0(t.type._context),tn(t),null;case 17:return Wn(t.type)&&Jp(),tn(t),null;case 19:if(tt(lt),s=t.memoizedState,s===null)return tn(t),null;if(r=(t.flags&128)!==0,i=s.rendering,i===null)if(r)sc(s,!1);else{if(Et!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=af(e),i!==null){for(t.flags|=128,sc(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 Ye(lt,lt.current&1|2),t.child}e=e.sibling}s.tail!==null&&wt()>fl&&(t.flags|=128,r=!0,sc(s,!1),t.lanes=4194304)}else{if(!r)if(e=af(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),sc(s,!0),s.tail===null&&s.tailMode==="hidden"&&!i.alternate&&!ot)return tn(t),null}else 2*wt()-s.renderingStartTime>fl&&n!==1073741824&&(t.flags|=128,r=!0,sc(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=wt(),t.sibling=null,n=lt.current,Ye(lt,r?n&1|2:n&1),t):(tn(t),null);case 22:case 23:return Y0(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Jn&1073741824&&(tn(t),t.subtreeFlags&6&&(t.flags|=8192)):tn(t),null;case 24:return null;case 25:return null}throw Error(X(156,t.tag))}function _W(e,t){switch(_0(t),t.tag){case 1:return Wn(t.type)&&Jp(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return hl(),tt(Kn),tt(hn),$0(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return L0(t),null;case 13:if(tt(lt),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(X(340));ul()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return tt(lt),null;case 4:return hl(),null;case 10:return j0(t.type._context),null;case 22:case 23:return Y0(),null;case 24:return null;default:return null}}var Vd=!1,an=!1,TW=typeof WeakSet=="function"?WeakSet:Set,te=null;function za(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){mt(e,t,r)}else n.current=null}function Sv(e,t,n){try{n()}catch(r){mt(e,t,r)}}var TC=!1;function MW(e,t){if(tv=Xp,e=ET(),E0(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,l=-1,c=0,u=0,h=e,p=null;t:for(;;){for(var f;h!==n||o!==0&&h.nodeType!==3||(a=i+o),h!==s||r!==0&&h.nodeType!==3||(l=i+r),h.nodeType===3&&(i+=h.nodeValue.length),(f=h.firstChild)!==null;)p=h,h=f;for(;;){if(h===e)break t;if(p===n&&++c===o&&(a=i),p===s&&++u===r&&(l=i),(f=h.nextSibling)!==null)break;h=p,p=h.parentNode}h=f}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(nv={focusedElem:e,selectionRange:n},Xp=!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 S=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(S!==null){var y=S.memoizedProps,x=S.memoizedState,m=t.stateNode,v=m.getSnapshotBeforeUpdate(t.elementType===t.type?y:Rr(t.type,y),x);m.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(X(163))}}catch(C){mt(t,t.return,C)}if(e=t.sibling,e!==null){e.return=t.return,te=e;break}te=t.return}return S=TC,TC=!1,S}function Vc(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&&Sv(t,n,s)}o=o.next}while(o!==r)}}function sg(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 vv(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 bM(e){var t=e.alternate;t!==null&&(e.alternate=null,bM(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[co],delete t[Su],delete t[sv],delete t[hW],delete t[pW])),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 PM(e){return e.tag===5||e.tag===3||e.tag===4}function MC(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||PM(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 xv(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=Qp));else if(r!==4&&(e=e.child,e!==null))for(xv(e,t,n),e=e.sibling;e!==null;)xv(e,t,n),e=e.sibling}function wv(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(wv(e,t,n),e=e.sibling;e!==null;)wv(e,t,n),e=e.sibling}var zt=null,$r=!1;function xs(e,t,n){for(n=n.child;n!==null;)CM(e,t,n),n=n.sibling}function CM(e,t,n){if(So&&typeof So.onCommitFiberUnmount=="function")try{So.onCommitFiberUnmount(Zf,n)}catch{}switch(n.tag){case 5:an||za(n,t);case 6:var r=zt,o=$r;zt=null,xs(e,t,n),zt=r,$r=o,zt!==null&&($r?(e=zt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):zt.removeChild(n.stateNode));break;case 18:zt!==null&&($r?(e=zt,n=n.stateNode,e.nodeType===8?Ym(e.parentNode,n):e.nodeType===1&&Ym(e,n),pu(e)):Ym(zt,n.stateNode));break;case 4:r=zt,o=$r,zt=n.stateNode.containerInfo,$r=!0,xs(e,t,n),zt=r,$r=o;break;case 0:case 11:case 14:case 15:if(!an&&(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)&&Sv(n,t,i),o=o.next}while(o!==r)}xs(e,t,n);break;case 1:if(!an&&(za(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){mt(n,t,a)}xs(e,t,n);break;case 21:xs(e,t,n);break;case 22:n.mode&1?(an=(r=an)||n.memoizedState!==null,xs(e,t,n),an=r):xs(e,t,n);break;default:xs(e,t,n)}}function AC(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new TW),t.forEach(function(r){var o=FW.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function Dr(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:zt=a.stateNode,$r=!1;break e;case 3:zt=a.stateNode.containerInfo,$r=!0;break e;case 4:zt=a.stateNode.containerInfo,$r=!0;break e}a=a.return}if(zt===null)throw Error(X(160));CM(s,i,o),zt=null,$r=!1;var l=o.alternate;l!==null&&(l.return=null),o.return=null}catch(c){mt(o,t,c)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)IM(t,e),t=t.sibling}function IM(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Dr(t,e),ro(e),r&4){try{Vc(3,e,e.return),sg(3,e)}catch(y){mt(e,e.return,y)}try{Vc(5,e,e.return)}catch(y){mt(e,e.return,y)}}break;case 1:Dr(t,e),ro(e),r&512&&n!==null&&za(n,n.return);break;case 5:if(Dr(t,e),ro(e),r&512&&n!==null&&za(n,n.return),e.flags&32){var o=e.stateNode;try{cu(o,"")}catch(y){mt(e,e.return,y)}}if(r&4&&(o=e.stateNode,o!=null)){var s=e.memoizedProps,i=n!==null?n.memoizedProps:s,a=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{a==="input"&&s.type==="radio"&&s.name!=null&&V2(o,s),WS(a,i);var c=WS(a,s);for(i=0;i<l.length;i+=2){var u=l[i],h=l[i+1];u==="style"?Q2(o,h):u==="dangerouslySetInnerHTML"?q2(o,h):u==="children"?cu(o,h):p0(o,u,h,c)}switch(a){case"input":zS(o,s);break;case"textarea":Y2(o,s);break;case"select":var p=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!s.multiple;var f=s.value;f!=null?Xa(o,!!s.multiple,f,!1):p!==!!s.multiple&&(s.defaultValue!=null?Xa(o,!!s.multiple,s.defaultValue,!0):Xa(o,!!s.multiple,s.multiple?[]:"",!1))}o[Su]=s}catch(y){mt(e,e.return,y)}}break;case 6:if(Dr(t,e),ro(e),r&4){if(e.stateNode===null)throw Error(X(162));o=e.stateNode,s=e.memoizedProps;try{o.nodeValue=s}catch(y){mt(e,e.return,y)}}break;case 3:if(Dr(t,e),ro(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{pu(t.containerInfo)}catch(y){mt(e,e.return,y)}break;case 4:Dr(t,e),ro(e);break;case 13:Dr(t,e),ro(e),o=e.child,o.flags&8192&&(s=o.memoizedState!==null,o.stateNode.isHidden=s,!s||o.alternate!==null&&o.alternate.memoizedState!==null||(G0=wt())),r&4&&AC(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(an=(c=an)||u,Dr(t,e),an=c):Dr(t,e),ro(e),r&8192){if(c=e.memoizedState!==null,(e.stateNode.isHidden=c)&&!u&&e.mode&1)for(te=e,u=e.child;u!==null;){for(h=te=u;te!==null;){switch(p=te,f=p.child,p.tag){case 0:case 11:case 14:case 15:Vc(4,p,p.return);break;case 1:za(p,p.return);var S=p.stateNode;if(typeof S.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,S.props=t.memoizedProps,S.state=t.memoizedState,S.componentWillUnmount()}catch(y){mt(r,n,y)}}break;case 5:za(p,p.return);break;case 22:if(p.memoizedState!==null){OC(h);continue}}f!==null?(f.return=p,te=f):OC(h)}u=u.sibling}e:for(u=null,h=e;;){if(h.tag===5){if(u===null){u=h;try{o=h.stateNode,c?(s=o.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(a=h.stateNode,l=h.memoizedProps.style,i=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=Z2("display",i))}catch(y){mt(e,e.return,y)}}}else if(h.tag===6){if(u===null)try{h.stateNode.nodeValue=c?"":h.memoizedProps}catch(y){mt(e,e.return,y)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===e)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;h.sibling===null;){if(h.return===null||h.return===e)break e;u===h&&(u=null),h=h.return}u===h&&(u=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:Dr(t,e),ro(e),r&4&&AC(e);break;case 21:break;default:Dr(t,e),ro(e)}}function ro(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(PM(n)){var r=n;break e}n=n.return}throw Error(X(160))}switch(r.tag){case 5:var o=r.stateNode;r.flags&32&&(cu(o,""),r.flags&=-33);var s=MC(e);wv(e,s,o);break;case 3:case 4:var i=r.stateNode.containerInfo,a=MC(e);xv(e,a,i);break;default:throw Error(X(161))}}catch(l){mt(e,e.return,l)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function AW(e,t,n){te=e,EM(e)}function EM(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||Vd;if(!i){var a=o.alternate,l=a!==null&&a.memoizedState!==null||an;a=Vd;var c=an;if(Vd=i,(an=l)&&!c)for(te=o;te!==null;)i=te,l=i.child,i.tag===22&&i.memoizedState!==null?DC(o):l!==null?(l.return=i,te=l):DC(o);for(;s!==null;)te=s,EM(s),s=s.sibling;te=o,Vd=a,an=c}jC(e)}else o.subtreeFlags&8772&&s!==null?(s.return=o,te=s):jC(e)}}function jC(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:an||sg(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!an)if(n===null)r.componentDidMount();else{var o=t.elementType===t.type?n.memoizedProps:Rr(t.type,n.memoizedProps);r.componentDidUpdate(o,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;s!==null&&mC(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}mC(t,i,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var l=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var c=t.alternate;if(c!==null){var u=c.memoizedState;if(u!==null){var h=u.dehydrated;h!==null&&pu(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(X(163))}an||t.flags&512&&vv(t)}catch(p){mt(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 OC(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 DC(e){for(;te!==null;){var t=te;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{sg(4,t)}catch(l){mt(t,n,l)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var o=t.return;try{r.componentDidMount()}catch(l){mt(t,o,l)}}var s=t.return;try{vv(t)}catch(l){mt(t,s,l)}break;case 5:var i=t.return;try{vv(t)}catch(l){mt(t,i,l)}}}catch(l){mt(t,t.return,l)}if(t===e){te=null;break}var a=t.sibling;if(a!==null){a.return=t.return,te=a;break}te=t.return}}var jW=Math.ceil,uf=us.ReactCurrentDispatcher,K0=us.ReactCurrentOwner,Er=us.ReactCurrentBatchConfig,Ae=0,Dt=null,Ct=null,Gt=0,Jn=0,Ba=li(0),Et=0,Cu=null,Ki=0,ig=0,W0=0,Yc=null,Ln=null,G0=0,fl=1/0,Fo=null,df=!1,bv=null,Ks=null,Yd=!1,js=null,hf=0,Xc=0,Pv=null,zh=-1,Bh=0;function vn(){return Ae&6?wt():zh!==-1?zh:zh=wt()}function Ws(e){return e.mode&1?Ae&2&&Gt!==0?Gt&-Gt:gW.transition!==null?(Bh===0&&(Bh=uT()),Bh):(e=Ne,e!==0||(e=window.event,e=e===void 0?16:yT(e.type)),e):1}function Kr(e,t,n,r){if(50<Xc)throw Xc=0,Pv=null,Error(X(185));Xu(e,n,r),(!(Ae&2)||e!==Dt)&&(e===Dt&&(!(Ae&2)&&(ig|=n),Et===4&&Ts(e,Gt)),Gn(e,r),n===1&&Ae===0&&!(t.mode&1)&&(fl=wt()+500,ng&&ci()))}function Gn(e,t){var n=e.callbackNode;gK(e,t);var r=Yp(e,e===Dt?Gt:0);if(r===0)n!==null&&HP(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&HP(n),t===1)e.tag===0?fW(RC.bind(null,e)):LT(RC.bind(null,e)),uW(function(){!(Ae&6)&&ci()}),n=null;else{switch(dT(r)){case 1:n=S0;break;case 4:n=lT;break;case 16:n=Vp;break;case 536870912:n=cT;break;default:n=Vp}n=DM(n,kM.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function kM(e,t){if(zh=-1,Bh=0,Ae&6)throw Error(X(327));var n=e.callbackNode;if(el()&&e.callbackNode!==n)return null;var r=Yp(e,e===Dt?Gt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=pf(e,r);else{t=r;var o=Ae;Ae|=2;var s=TM();(Dt!==e||Gt!==t)&&(Fo=null,fl=wt()+500,Oi(e,t));do try{RW();break}catch(a){_M(e,a)}while(!0);A0(),uf.current=s,Ae=o,Ct!==null?t=0:(Dt=null,Gt=0,t=Et)}if(t!==0){if(t===2&&(o=qS(e),o!==0&&(r=o,t=Cv(e,o))),t===1)throw n=Cu,Oi(e,0),Ts(e,r),Gn(e,wt()),n;if(t===6)Ts(e,r);else{if(o=e.current.alternate,!(r&30)&&!OW(o)&&(t=pf(e,r),t===2&&(s=qS(e),s!==0&&(r=s,t=Cv(e,s))),t===1))throw n=Cu,Oi(e,0),Ts(e,r),Gn(e,wt()),n;switch(e.finishedWork=o,e.finishedLanes=r,t){case 0:case 1:throw Error(X(345));case 2:Pi(e,Ln,Fo);break;case 3:if(Ts(e,r),(r&130023424)===r&&(t=G0+500-wt(),10<t)){if(Yp(e,0)!==0)break;if(o=e.suspendedLanes,(o&r)!==r){vn(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=ov(Pi.bind(null,e,Ln,Fo),t);break}Pi(e,Ln,Fo);break;case 4:if(Ts(e,r),(r&4194240)===r)break;for(t=e.eventTimes,o=-1;0<r;){var i=31-Hr(r);s=1<<i,i=t[i],i>o&&(o=i),r&=~s}if(r=o,r=wt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*jW(r/1960))-r,10<r){e.timeoutHandle=ov(Pi.bind(null,e,Ln,Fo),r);break}Pi(e,Ln,Fo);break;case 5:Pi(e,Ln,Fo);break;default:throw Error(X(329))}}}return Gn(e,wt()),e.callbackNode===n?kM.bind(null,e):null}function Cv(e,t){var n=Yc;return e.current.memoizedState.isDehydrated&&(Oi(e,t).flags|=256),e=pf(e,t),e!==2&&(t=Ln,Ln=n,t!==null&&Iv(t)),e}function Iv(e){Ln===null?Ln=e:Ln.push.apply(Ln,e)}function OW(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(!Vr(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 Ts(e,t){for(t&=~W0,t&=~ig,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Hr(t),r=1<<n;e[n]=-1,t&=~r}}function RC(e){if(Ae&6)throw Error(X(327));el();var t=Yp(e,0);if(!(t&1))return Gn(e,wt()),null;var n=pf(e,t);if(e.tag!==0&&n===2){var r=qS(e);r!==0&&(t=r,n=Cv(e,r))}if(n===1)throw n=Cu,Oi(e,0),Ts(e,t),Gn(e,wt()),n;if(n===6)throw Error(X(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Pi(e,Ln,Fo),Gn(e,wt()),null}function V0(e,t){var n=Ae;Ae|=1;try{return e(t)}finally{Ae=n,Ae===0&&(fl=wt()+500,ng&&ci())}}function Wi(e){js!==null&&js.tag===0&&!(Ae&6)&&el();var t=Ae;Ae|=1;var n=Er.transition,r=Ne;try{if(Er.transition=null,Ne=1,e)return e()}finally{Ne=r,Er.transition=n,Ae=t,!(Ae&6)&&ci()}}function Y0(){Jn=Ba.current,tt(Ba)}function Oi(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,cW(n)),Ct!==null)for(n=Ct.return;n!==null;){var r=n;switch(_0(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Jp();break;case 3:hl(),tt(Kn),tt(hn),$0();break;case 5:L0(r);break;case 4:hl();break;case 13:tt(lt);break;case 19:tt(lt);break;case 10:j0(r.type._context);break;case 22:case 23:Y0()}n=n.return}if(Dt=e,Ct=e=Gs(e.current,null),Gt=Jn=t,Et=0,Cu=null,W0=ig=Ki=0,Ln=Yc=null,ki!==null){for(t=0;t<ki.length;t++)if(n=ki[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}ki=null}return e}function _M(e,t){do{var n=Ct;try{if(A0(),$h.current=cf,lf){for(var r=ht.memoizedState;r!==null;){var o=r.queue;o!==null&&(o.pending=null),r=r.next}lf=!1}if(Hi=0,Tt=It=ht=null,Gc=!1,wu=0,K0.current=null,n===null||n.return===null){Et=1,Cu=t,Ct=null;break}e:{var s=e,i=n.return,a=n,l=t;if(t=Gt,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,u=a,h=u.tag;if(!(u.mode&1)&&(h===0||h===11||h===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=bC(i);if(f!==null){f.flags&=-257,PC(f,i,a,s,t),f.mode&1&&wC(s,c,t),t=f,l=c;var S=t.updateQueue;if(S===null){var y=new Set;y.add(l),t.updateQueue=y}else S.add(l);break e}else{if(!(t&1)){wC(s,c,t),X0();break e}l=Error(X(426))}}else if(ot&&a.mode&1){var x=bC(i);if(x!==null){!(x.flags&65536)&&(x.flags|=256),PC(x,i,a,s,t),T0(pl(l,a));break e}}s=l=pl(l,a),Et!==4&&(Et=2),Yc===null?Yc=[s]:Yc.push(s),s=i;do{switch(s.tag){case 3:s.flags|=65536,t&=-t,s.lanes|=t;var m=dM(s,l,t);gC(s,m);break e;case 1:a=l;var v=s.type,w=s.stateNode;if(!(s.flags&128)&&(typeof v.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Ks===null||!Ks.has(w)))){s.flags|=65536,t&=-t,s.lanes|=t;var C=hM(s,a,t);gC(s,C);break e}}s=s.return}while(s!==null)}AM(n)}catch(E){t=E,Ct===n&&n!==null&&(Ct=n=n.return);continue}break}while(!0)}function TM(){var e=uf.current;return uf.current=cf,e===null?cf:e}function X0(){(Et===0||Et===3||Et===2)&&(Et=4),Dt===null||!(Ki&268435455)&&!(ig&268435455)||Ts(Dt,Gt)}function pf(e,t){var n=Ae;Ae|=2;var r=TM();(Dt!==e||Gt!==t)&&(Fo=null,Oi(e,t));do try{DW();break}catch(o){_M(e,o)}while(!0);if(A0(),Ae=n,uf.current=r,Ct!==null)throw Error(X(261));return Dt=null,Gt=0,Et}function DW(){for(;Ct!==null;)MM(Ct)}function RW(){for(;Ct!==null&&!iK();)MM(Ct)}function MM(e){var t=OM(e.alternate,e,Jn);e.memoizedProps=e.pendingProps,t===null?AM(e):Ct=t,K0.current=null}function AM(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=_W(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=kW(n,t,Jn),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 Pi(e,t,n){var r=Ne,o=Er.transition;try{Er.transition=null,Ne=1,LW(e,t,n,r)}finally{Er.transition=o,Ne=r}return null}function LW(e,t,n,r){do el();while(js!==null);if(Ae&6)throw Error(X(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(X(177));e.callbackNode=null,e.callbackPriority=0;var s=n.lanes|n.childLanes;if(mK(e,s),e===Dt&&(Ct=Dt=null,Gt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Yd||(Yd=!0,DM(Vp,function(){return el(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=Er.transition,Er.transition=null;var i=Ne;Ne=1;var a=Ae;Ae|=4,K0.current=null,MW(e,n),IM(n,e),nW(nv),Xp=!!tv,nv=tv=null,e.current=n,AW(n),aK(),Ae=a,Ne=i,Er.transition=s}else e.current=n;if(Yd&&(Yd=!1,js=e,hf=o),s=e.pendingLanes,s===0&&(Ks=null),uK(n.stateNode),Gn(e,wt()),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(df)throw df=!1,e=bv,bv=null,e;return hf&1&&e.tag!==0&&el(),s=e.pendingLanes,s&1?e===Pv?Xc++:(Xc=0,Pv=e):Xc=0,ci(),null}function el(){if(js!==null){var e=dT(hf),t=Er.transition,n=Ne;try{if(Er.transition=null,Ne=16>e?16:e,js===null)var r=!1;else{if(e=js,js=null,hf=0,Ae&6)throw Error(X(331));var o=Ae;for(Ae|=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 l=0;l<a.length;l++){var c=a[l];for(te=c;te!==null;){var u=te;switch(u.tag){case 0:case 11:case 15:Vc(8,u,s)}var h=u.child;if(h!==null)h.return=u,te=h;else for(;te!==null;){u=te;var p=u.sibling,f=u.return;if(bM(u),u===c){te=null;break}if(p!==null){p.return=f,te=p;break}te=f}}}var S=s.alternate;if(S!==null){var y=S.child;if(y!==null){S.child=null;do{var x=y.sibling;y.sibling=null,y=x}while(y!==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:Vc(9,s,s.return)}var m=s.sibling;if(m!==null){m.return=s.return,te=m;break e}te=s.return}}var v=e.current;for(te=v;te!==null;){i=te;var w=i.child;if(i.subtreeFlags&2064&&w!==null)w.return=i,te=w;else e:for(i=v;te!==null;){if(a=te,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:sg(9,a)}}catch(E){mt(a,a.return,E)}if(a===i){te=null;break e}var C=a.sibling;if(C!==null){C.return=a.return,te=C;break e}te=a.return}}if(Ae=o,ci(),So&&typeof So.onPostCommitFiberRoot=="function")try{So.onPostCommitFiberRoot(Zf,e)}catch{}r=!0}return r}finally{Ne=n,Er.transition=t}}return!1}function LC(e,t,n){t=pl(n,t),t=dM(e,t,1),e=Hs(e,t,1),t=vn(),e!==null&&(Xu(e,1,t),Gn(e,t))}function mt(e,t,n){if(e.tag===3)LC(e,e,n);else for(;t!==null;){if(t.tag===3){LC(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Ks===null||!Ks.has(r))){e=pl(n,e),e=hM(t,e,1),t=Hs(t,e,1),e=vn(),t!==null&&(Xu(t,1,e),Gn(t,e));break}}t=t.return}}function $W(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=vn(),e.pingedLanes|=e.suspendedLanes&n,Dt===e&&(Gt&n)===n&&(Et===4||Et===3&&(Gt&130023424)===Gt&&500>wt()-G0?Oi(e,0):W0|=n),Gn(e,t)}function jM(e,t){t===0&&(e.mode&1?(t=Nd,Nd<<=1,!(Nd&130023424)&&(Nd=4194304)):t=1);var n=vn();e=ns(e,t),e!==null&&(Xu(e,t,n),Gn(e,n))}function NW(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),jM(e,n)}function FW(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(X(314))}r!==null&&r.delete(t),jM(e,n)}var OM;OM=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Kn.current)zn=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return zn=!1,EW(e,t,n);zn=!!(e.flags&131072)}else zn=!1,ot&&t.flags&1048576&&$T(t,nf,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Fh(e,t),e=t.pendingProps;var o=cl(t,hn.current);Ja(t,n),o=F0(null,t,r,e,o,n);var s=z0();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,Wn(r)?(s=!0,ef(t)):s=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,D0(t),o.updater=og,t.stateNode=o,o._reactInternals=t,dv(t,r,e,n),t=fv(null,t,r,!0,s,n)):(t.tag=0,ot&&s&&k0(t),mn(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Fh(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=BW(r),e=Rr(r,e),o){case 0:t=pv(null,t,r,e,n);break e;case 1:t=EC(null,t,r,e,n);break e;case 11:t=CC(null,t,r,e,n);break e;case 14:t=IC(null,t,r,Rr(r.type,e),n);break e}throw Error(X(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),pv(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),EC(e,t,r,o,n);case 3:e:{if(mM(t),e===null)throw Error(X(387));r=t.pendingProps,s=t.memoizedState,o=s.element,HT(e,t),sf(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=pl(Error(X(423)),t),t=kC(e,t,r,n,o);break e}else if(r!==o){o=pl(Error(X(424)),t),t=kC(e,t,r,n,o);break e}else for(nr=Us(t.stateNode.containerInfo.firstChild),ir=t,ot=!0,Fr=null,n=BT(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(ul(),r===o){t=rs(e,t,n);break e}mn(e,t,r,n)}t=t.child}return t;case 5:return KT(t),e===null&&lv(t),r=t.type,o=t.pendingProps,s=e!==null?e.memoizedProps:null,i=o.children,rv(r,o)?i=null:s!==null&&rv(r,s)&&(t.flags|=32),gM(e,t),mn(e,t,i,n),t.child;case 6:return e===null&&lv(t),null;case 13:return yM(e,t,n);case 4:return R0(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=dl(t,null,r,n):mn(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),CC(e,t,r,o,n);case 7:return mn(e,t,t.pendingProps,n),t.child;case 8:return mn(e,t,t.pendingProps.children,n),t.child;case 12:return mn(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,Ye(rf,r._currentValue),r._currentValue=i,s!==null)if(Vr(s.value,i)){if(s.children===o.children&&!Kn.current){t=rs(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 l=a.firstContext;l!==null;){if(l.context===r){if(s.tag===1){l=Yo(-1,n&-n),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),cv(s.return,n,t),a.lanes|=n;break}l=l.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(X(341));i.lanes|=n,a=i.alternate,a!==null&&(a.lanes|=n),cv(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}mn(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,Ja(t,n),o=_r(o),r=r(o),t.flags|=1,mn(e,t,r,n),t.child;case 14:return r=t.type,o=Rr(r,t.pendingProps),o=Rr(r.type,o),IC(e,t,r,o,n);case 15:return pM(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),Fh(e,t),t.tag=1,Wn(r)?(e=!0,ef(t)):e=!1,Ja(t,n),uM(t,r,o),dv(t,r,o,n),fv(null,t,r,!0,e,n);case 19:return SM(e,t,n);case 22:return fM(e,t,n)}throw Error(X(156,t.tag))};function DM(e,t){return aT(e,t)}function zW(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 Cr(e,t,n,r){return new zW(e,t,n,r)}function q0(e){return e=e.prototype,!(!e||!e.isReactComponent)}function BW(e){if(typeof e=="function")return q0(e)?1:0;if(e!=null){if(e=e.$$typeof,e===g0)return 11;if(e===m0)return 14}return 2}function Gs(e,t){var n=e.alternate;return n===null?(n=Cr(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 Uh(e,t,n,r,o,s){var i=2;if(r=e,typeof e=="function")q0(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Aa:return Di(n.children,o,s,t);case f0:i=8,o|=8;break;case RS:return e=Cr(12,n,t,o|2),e.elementType=RS,e.lanes=s,e;case LS:return e=Cr(13,n,t,o),e.elementType=LS,e.lanes=s,e;case $S:return e=Cr(19,n,t,o),e.elementType=$S,e.lanes=s,e;case K2:return ag(n,o,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case U2:i=10;break e;case H2:i=9;break e;case g0:i=11;break e;case m0:i=14;break e;case Is:i=16,r=null;break e}throw Error(X(130,e==null?e:typeof e,""))}return t=Cr(i,n,t,o),t.elementType=e,t.type=r,t.lanes=s,t}function Di(e,t,n,r){return e=Cr(7,e,r,t),e.lanes=n,e}function ag(e,t,n,r){return e=Cr(22,e,r,t),e.elementType=K2,e.lanes=n,e.stateNode={isHidden:!1},e}function ny(e,t,n){return e=Cr(6,e,null,t),e.lanes=n,e}function ry(e,t,n){return t=Cr(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function UW(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=$m(0),this.expirationTimes=$m(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$m(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function Z0(e,t,n,r,o,s,i,a,l){return e=new UW(e,t,n,a,l),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Cr(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},D0(s),e}function HW(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 RM(e){if(!e)return qs;e=e._reactInternals;e:{if(sa(e)!==e||e.tag!==1)throw Error(X(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Wn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(X(171))}if(e.tag===1){var n=e.type;if(Wn(n))return RT(e,n,t)}return t}function LM(e,t,n,r,o,s,i,a,l){return e=Z0(n,r,!0,e,o,s,i,a,l),e.context=RM(null),n=e.current,r=vn(),o=Ws(n),s=Yo(r,o),s.callback=t??null,Hs(n,s,o),e.current.lanes=o,Xu(e,o,r),Gn(e,r),e}function lg(e,t,n,r){var o=t.current,s=vn(),i=Ws(o);return n=RM(n),t.context===null?t.context=n:t.pendingContext=n,t=Yo(s,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Hs(o,t,i),e!==null&&(Kr(e,o,i,s),Lh(e,o,i)),i}function ff(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 $C(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Q0(e,t){$C(e,t),(e=e.alternate)&&$C(e,t)}function KW(){return null}var $M=typeof reportError=="function"?reportError:function(e){console.error(e)};function J0(e){this._internalRoot=e}cg.prototype.render=J0.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(X(409));lg(e,t,null,null)};cg.prototype.unmount=J0.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Wi(function(){lg(null,e,null,null)}),t[ts]=null}};function cg(e){this._internalRoot=e}cg.prototype.unstable_scheduleHydration=function(e){if(e){var t=fT();e={blockedOn:null,target:e,priority:t};for(var n=0;n<_s.length&&t!==0&&t<_s[n].priority;n++);_s.splice(n,0,e),n===0&&mT(e)}};function ew(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ug(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function NC(){}function WW(e,t,n,r,o){if(o){if(typeof r=="function"){var s=r;r=function(){var c=ff(i);s.call(c)}}var i=LM(t,r,e,0,null,!1,!1,"",NC);return e._reactRootContainer=i,e[ts]=i.current,mu(e.nodeType===8?e.parentNode:e),Wi(),i}for(;o=e.lastChild;)e.removeChild(o);if(typeof r=="function"){var a=r;r=function(){var c=ff(l);a.call(c)}}var l=Z0(e,0,!1,null,null,!1,!1,"",NC);return e._reactRootContainer=l,e[ts]=l.current,mu(e.nodeType===8?e.parentNode:e),Wi(function(){lg(t,l,n,r)}),l}function dg(e,t,n,r,o){var s=n._reactRootContainer;if(s){var i=s;if(typeof o=="function"){var a=o;o=function(){var l=ff(i);a.call(l)}}lg(t,i,e,o)}else i=WW(n,t,e,o,r);return ff(i)}hT=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=wc(t.pendingLanes);n!==0&&(v0(t,n|1),Gn(t,wt()),!(Ae&6)&&(fl=wt()+500,ci()))}break;case 13:Wi(function(){var r=ns(e,1);if(r!==null){var o=vn();Kr(r,e,1,o)}}),Q0(e,1)}};x0=function(e){if(e.tag===13){var t=ns(e,134217728);if(t!==null){var n=vn();Kr(t,e,134217728,n)}Q0(e,134217728)}};pT=function(e){if(e.tag===13){var t=Ws(e),n=ns(e,t);if(n!==null){var r=vn();Kr(n,e,t,r)}Q0(e,t)}};fT=function(){return Ne};gT=function(e,t){var n=Ne;try{return Ne=e,t()}finally{Ne=n}};VS=function(e,t,n){switch(t){case"input":if(zS(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=tg(r);if(!o)throw Error(X(90));G2(r),zS(r,o)}}}break;case"textarea":Y2(e,n);break;case"select":t=n.value,t!=null&&Xa(e,!!n.multiple,t,!1)}};tT=V0;nT=Wi;var GW={usingClientEntryPoint:!1,Events:[Zu,Ra,tg,J2,eT,V0]},ic={findFiberByHostInstance:Ei,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},VW={bundleType:ic.bundleType,version:ic.version,rendererPackageName:ic.rendererPackageName,rendererConfig:ic.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:us.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=sT(e),e===null?null:e.stateNode},findFiberByHostInstance:ic.findFiberByHostInstance||KW,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 Xd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xd.isDisabled&&Xd.supportsFiber)try{Zf=Xd.inject(VW),So=Xd}catch{}}hr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=GW;hr.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ew(t))throw Error(X(200));return HW(e,t,null,n)};hr.createRoot=function(e,t){if(!ew(e))throw Error(X(299));var n=!1,r="",o=$M;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(o=t.onRecoverableError)),t=Z0(e,1,!1,null,null,n,!1,r,o),e[ts]=t.current,mu(e.nodeType===8?e.parentNode:e),new J0(t)};hr.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(X(188)):(e=Object.keys(e).join(","),Error(X(268,e)));return e=sT(t),e=e===null?null:e.stateNode,e};hr.flushSync=function(e){return Wi(e)};hr.hydrate=function(e,t,n){if(!ug(t))throw Error(X(200));return dg(null,e,t,!0,n)};hr.hydrateRoot=function(e,t,n){if(!ew(e))throw Error(X(405));var r=n!=null&&n.hydratedSources||null,o=!1,s="",i=$M;if(n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=LM(t,null,e,1,n??null,o,!1,s,i),e[ts]=t.current,mu(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 cg(t)};hr.render=function(e,t,n){if(!ug(t))throw Error(X(200));return dg(null,e,t,!1,n)};hr.unmountComponentAtNode=function(e){if(!ug(e))throw Error(X(40));return e._reactRootContainer?(Wi(function(){dg(null,null,e,!1,function(){e._reactRootContainer=null,e[ts]=null})}),!0):!1};hr.unstable_batchedUpdates=V0;hr.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!ug(n))throw Error(X(200));if(e==null||e._reactInternals===void 0)throw Error(X(38));return dg(e,t,n,!1,r)};hr.version="18.3.1-next-f1338f8080-20240426";function NM(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(NM)}catch(e){console.error(e)}}NM(),N2.exports=hr;var ia=N2.exports;const YW=ni(ia);var Ev={},FM,FC=ia;FM=Ev.createRoot=FC.createRoot,Ev.hydrateRoot=FC.hydrateRoot;const tl="TLDRAW_TAB_ID_v2",xo=globalThis.window;function XW(){return xo?["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(xo.navigator.platform)||xo.navigator.userAgent.includes("Mac")&&"ontouchend"in document:!1}const gf=xo?xo[tl]??n_(tl)??"TLDRAW_INSTANCE_STATE_V1_"+ct():"<error>";xo&&(xo[tl]=gf,XW()?Gx(tl,gf):r_(tl));xo==null||xo.addEventListener("beforeunload",()=>{Gx(tl,gf)});const zM={Initial:0},hg=Math.max(...Object.values(zM));function qW(e){e.version<zM.Initial,e.version=hg}const BM=xe({version:he,currentPageId:su,isFocusMode:Se,exportBackground:Se,isDebugMode:Se,isToolLocked:Se,isGridMode:Se,pageStates:Ht(xe({pageId:su,camera:xe({x:he,y:he,z:he}),selectedShapeIds:Ht(Sr),focusedGroupId:Sr.nullable()}))});function ZW(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!==hg&&(e=Ge(e),qW(e));try{return BM.validate(e)}catch(t){return console.warn(t),null}}function UM(e){const t=e.query.ids("page");return G("sessionStateSnapshot",()=>{const n=e.get(Sn);if(!n)return null;const r=[...t.get()];return{version:hg,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(Br.createId(o)),i=e.get(po.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 HM(e,t){const n=ZW(t);if(!n)return;const r=e.schema.types.instance.create({id:Sn,...E_(e.get(Sn)),currentPageId:n.currentPageId,isDebugMode:n.isDebugMode,isFocusMode:n.isFocusMode,isToolLocked:n.isToolLocked,isGridMode:n.isGridMode,exportBackground:n.exportBackground}),o=e.allRecords().filter(s=>s.typeName==="instance_page_state"||s.typeName==="camera");e.atomic(()=>{e.remove(o.map(s=>s.id));for(const s of n.pageStates)e.put([po.create({id:po.createId(s.pageId),x:s.camera.x,y:s.camera.y,z:s.camera.z}),Br.create({id:Br.createId(s.pageId),pageId:s.pageId,selectedShapeIds:s.selectedShapeIds,focusedGroupId:s.focusedGroupId})]);e.put([r]),e.ensureStoreIsUsable()})}function QW(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!==Sn)[0];if(!n)return null;const r={version:hg,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 BM.validate(r),r}catch{return null}}function KM(e,t){let n={};if("store"in t){const o=e.schema.migrateStoreSnapshot(t);if(o.type!=="success")throw new Error("Failed to migrate store snapshot: "+o.reason);n.document={schema:e.schema.serialize(),store:$c(o.value,(s,{typeName:i})=>e.scopedTypes.document.has(i))}}else n=t;const r=E_(e.get(Sn));e.atomic(()=>{n.document&&e.loadStoreSnapshot(n.document),r&&e.update(Sn,o=>({...o,...r})),n.session&&HM(e,n.session)})}const JW=new Qo;function eG(e){const n=JW.get(e,UM).get();if(!n)throw new Error("Session state is not ready yet");return{document:e.getStoreSnapshot(),session:n}}function WM(e){const t=[],n=new Set;for(const r of e){if(n.has(r.type))throw new Error(`Binding type "${r.type}" is defined more than once`);t.push(r),n.add(r.type)}return t}function Zs({children:e,className:t="",...n}){return d.jsx("svg",{...n,className:ce("tl-svg-container",t),children:e})}function tw(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,l=t.x-e.x,c=t.y-e.y,u=i*s-a*o,h=l*s-c*o,p=a*l-i*c;if(u===0||h===0||p===0)return null;if(p!==0){const f=u/p,S=h/p;if(0<=f&&f<=1&&0<=S&&S<=1)return b.AddXY(e,f*l,f*c)}return null}function Ju(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 l=Math.sqrt(a),c=(-s+l)/(2*o),u=(-s-l)/(2*o);if((c<0||c>1)&&(u<0||u>1))return null;const h=[];return 0<=c&&c<=1&&h.push(b.Lrp(e,t,c)),0<=u&&u<=1&&h.push(b.Lrp(e,t,u)),h.length===0?null:h}function tG(e,t,n){const r=[];let o;for(let s=0,i=n.length-1;s<i;s++)o=tw(e,t,n[s],n[s+1]),o&&r.push(o);return r.length===0?null:r}function nw(e,t,n){const r=[];let o;for(let s=1,i=n.length;s<i+1;s++)o=tw(e,t,n[s-1],n[s%n.length]),o&&r.push(o);return r.length===0?null:r}function nG(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),l=Math.sqrt(t*t-a*a);return o/=i,s/=i,[new b(e.x+o*a-s*l,e.y+s*a+o*l),new b(e.x+o*a+s*l,e.y+s*a-o*l)]}function kv(e,t,n){const r=[];let o,s,i;for(let a=0,l=n.length;a<l;a++)o=n[a],s=n[(a+1)%n.length],i=Ju(o,s,e,t),i&&r.push(...i);return r.length===0?null:r}function zC(e,t,n){const r=[];let o,s,i;for(let a=1,l=n.length;a<l;a++)o=n[a-1],s=n[a],i=Ju(o,s,e,t),i&&r.push(...i);return r.length===0?null:r}function qd(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function rw(e,t,n,r){return qd(e,n,r)!==qd(t,n,r)&&qd(e,t,n)!==qd(e,t,r)}function BC(e,t){const n=new Map;let r,o,s,i;for(let a=0,l=e.length;a<l;a++)if(r=e[a],sr(r,t)){const c=oy(r);n.has(c)||n.set(c,r)}for(let a=0,l=t.length;a<l;a++)if(r=t[a],sr(r,e)){const c=oy(r);n.has(c)||n.set(c,r)}for(let a=0,l=e.length;a<l;a++){r=e[a],o=e[(a+1)%e.length];for(let c=0,u=t.length;c<u;c++){s=t[c],i=t[(c+1)%t.length];const h=tw(r,o,s,i);if(h!==null){const p=oy(h);n.has(p)||n.set(p,h)}}}return n.size===0?null:rG([...n.values()])}function oy(e){return`${e.x},${e.y}`}function rG(e){const t=b.Average(e);return e.sort((n,r)=>b.Angle(t,n)-b.Angle(t,r))}function GM(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 l=0,c=t.length;l<c;l++)if(o=t[l],s=t[(l+1)%c],rw(n,r,o,s))return!0}return!1}function oG(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 l=1,c=t.length;l<c;l++)if(o=t[l-1],s=t[l],rw(n,r,o,s))return!0}return!1}class Wo extends ii{constructor(n){super({...n,isClosed:!1,isFilled:!1});g(this,"start");g(this,"end");g(this,"d");g(this,"u");g(this,"ul");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()}getLength(){return 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=b.Sub(n,r).dpr(s)/i,l=r.x+s.x*a;if(l<Math.min(r.x,o.x))return r.x<o.x?r:o;if(l>Math.max(r.x,o.x))return r.x>o.x?r:o;const c=r.y+s.y*a;return c<Math.min(r.y,o.y)?r.y<o.y?r:o:c>Math.max(r.y,o.y)?r.y>o.y?r:o:new b(l,c)}hitTestLineSegment(n,r,o=0){return rw(n,r,this.start,this.end)||this.distanceToLineSegment(n,r)<=o}getSvgPathData(n=!0){const{start:r,end:o}=this;return`${n?`M${r.toFixed()}`:""} L${o.toFixed()}`}}class Ol extends ii{constructor(n){super({isClosed:!1,isFilled:!1,...n});g(this,"points");g(this,"_segments");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 Wo({start:s,end:i}))}this.isClosed&&this._segments.push(new Wo({start:n[n.length-1],end:n[0]}))}return this._segments}getLength(){return this.segments.reduce((n,r)=>n+r.length,0)}getVertices(){return this.points}nearestPoint(n){const{segments:r}=this;let o=this.points[0],s=1/0,i,a;for(let l=0;l<r.length;l++)i=r[l].nearestPoint(n),a=b.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}getSvgPathData(){const{vertices:n}=this;return n.length<2?"":n.reduce((r,o,s)=>s===0?`M ${o.x} ${o.y}`:`${r} L ${o.x} ${o.y}`,"")}}class vt extends Ol{constructor(t){super({...t}),this.isClosed=!0}}class os extends vt{constructor(n){const{x:r=0,y:o=0,width:s,height:i}=n;super({...n,points:[new b(r,o),new b(r+s,o),new b(r+s,o+i),new b(r,o+i)]});g(this,"x");g(this,"y");g(this,"w");g(this,"h");this.x=r,this.y=o,this.w=s,this.h=i}getBounds(){return new Q(this.x,this.y,this.w,this.h)}getSvgPathData(){const{x:n,y:r,w:o,h:s}=this;return`M${n},${r} h${o} v${s} h-${o}z`}}class Wr{constructor(t){g(this,"canSnap",()=>!0);g(this,"canScroll",()=>!1);g(this,"canEdit",()=>!1);g(this,"canResize",()=>!0);g(this,"canEditInReadOnly",()=>!1);g(this,"canCrop",()=>!1);g(this,"canBeLaidOut",()=>!0);g(this,"hideResizeHandles",()=>!1);g(this,"hideRotateHandle",()=>!1);g(this,"hideSelectionBoundsBg",()=>!1);g(this,"hideSelectionBoundsFg",()=>!1);g(this,"isAspectRatioLocked",()=>!1);g(this,"onBeforeCreate");g(this,"onBeforeUpdate");g(this,"onDragShapesOver");g(this,"onDragShapesOut");g(this,"onDropShapesOver");g(this,"onResizeStart");g(this,"onResize");g(this,"onResizeEnd");g(this,"onTranslateStart");g(this,"onTranslate");g(this,"onTranslateEnd");g(this,"onHandleDrag");g(this,"onRotateStart");g(this,"onRotate");g(this,"onRotateEnd");g(this,"onBindingChange");g(this,"onChildrenChange");g(this,"onDoubleClickHandle");g(this,"onDoubleClickEdge");g(this,"onDoubleClick");g(this,"onClick");g(this,"onEditEnd");this.editor=t}canBind(t){return!0}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{}}}g(Wr,"props"),g(Wr,"migrations"),g(Wr,"type");function sG(e,t,n={}){const{closed:r=!1,snap:o=1,start:s="outset",end:i="outset",lengthRatio:a=2,style:l="dashed"}=n;let c=0,u=0,h=1,p=0,f=0;switch(l){case"dashed":{h=1,c=Math.min(t*a,e/4);break}case"dotted":{h=100,c=t/h;break}default:return{strokeDasharray:"none",strokeDashoffset:"none"}}return r||(s==="outset"?(e+=c/2,f+=c/2):s==="skip"&&(e-=c,f-=c),i==="outset"?e+=c/2:i==="skip"&&(e-=c)),u=Math.floor(e/c/(2*h)),u-=u%o,u<3&&l==="dashed"?e/t<5?(c=e,u=1,p=0):(c=e*.333,p=e*.333):(u=Math.max(u,3),c=e/u/(2*h),r?(f=c/2,p=(e-u*c)/u):p=(e-u*c)/Math.max(1,u-1)),{strokeDasharray:[c,p].join(" "),strokeDashoffset:f.toString()}}function UC({bounds:e,className:t}){const n=F(),r=K("zoom level",()=>n.getZoomLevel(),[n]);return d.jsx("g",{className:t,pointerEvents:"none",strokeLinecap:"round",strokeLinejoin:"round",children:e.sides.map((o,s)=>{const{strokeDasharray:i,strokeDashoffset:a}=sG(o[0].dist(o[1]),1/r,{style:"dashed",lengthRatio:4});return d.jsx("line",{x1:o[0].x,y1:o[0].y,x2:o[1].x,y2:o[1].y,strokeDasharray:i,strokeDashoffset:a},s)})})}class Hh extends Wr{constructor(){super(...arguments);g(this,"hideSelectionBoundsFg",()=>!0);g(this,"canBind",()=>!1);g(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 os({width:1,height:1,isFilled:!1}):new Gr({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 vt({points:a,isFilled:!0}):new Ol({points:a})})})}component(n){const r=this.editor.getErasingShapeIds().includes(n.id),{hintingShapeIds:o}=this.editor.getCurrentPageState(),s=o.length>0&&o.some(l=>l!==n.id&&this.editor.isShapeOfType(this.editor.getShape(l),"group")),i=this.editor.getCurrentPageState().focusedGroupId!==n.id;if(!r&&(i||s))return null;const a=this.editor.getShapeGeometry(n).bounds;return d.jsx(Zs,{id:n.id,children:d.jsx(UC,{className:"tl-group",bounds:a})})}indicator(n){const r=this.editor.getShapeGeometry(n).bounds;return d.jsx(UC,{className:"",bounds:r})}}g(Hh,"type","group"),g(Hh,"props",N_),g(Hh,"migrations",F_);const VM=[Hh],iG=new Set(VM.map(e=>e.type));function YM(e){const t=[...VM],n=new Set;for(const r of e){if(iG.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}const aG={maxShapesPerPage:4e3,maxPages:40,animationMediumMs:320,followChaseViewportSnap:2,doubleClickDurationMs:450,multiClickDurationMs:200,coarseDragDistanceSquared:36,dragDistanceSquared:16,defaultSvgPadding:32,cameraSlideFriction:.09,maxPointsPerDrawShape:500,gridSteps:[{min:-1,mid:.15,step:64},{min:.05,mid:.375,step:16},{min:.15,mid:1,step:4},{min:.7,mid:2.5,step:1}],collaboratorInactiveTimeoutMs:6e4,collaboratorIdleTimeoutMs:3e3,collaboratorCheckIntervalMs:1200,cameraMovingTimeoutMs:64,hitTestMargin:8,edgeScrollDelay:200,edgeScrollEaseDuration:200,edgeScrollSpeed:25,edgeScrollDistance:8,coarsePointerWidth:12,coarseHandleRadius:20,handleRadius:12,longPressDurationMs:500,textShadowLod:.35,adjacentShapeMargin:10,flattenImageBoundsExpand:64,flattenImageBoundsPadding:16};function HC(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 un(e)}}class lG{constructor(t){g(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(!HC(o,t.get(r)))return!1;n.add(r)}for(const[r,o]of t)if(!n.has(r)&&!HC(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 _v extends lG{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:un(r,"type")}}}function cG(e,t,n){return bo(e).then(function(r){return r.arrayBuffer()}).then(function(r){return new File([r],t,{type:n})})}const uG="https://cdn.tldraw.com";function Os(){return`${uG}/${J_}`}function dG(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 Zd(e,t,n){if(n.length===0)return[];const r=new Map;for(const s of ye(n.map(i=>e.getShape(i)))){const{parentId:i}=s;r.has(i)||r.set(i,{children:ye(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})=>hG(s,i,o));break}case"toFront":{r.forEach(({moving:s,children:i})=>pG(s,i,o));break}case"forward":{r.forEach(({moving:s,children:i})=>fG(s,i,o));break}case"backward":{r.forEach(({moving:s,children:i})=>gG(s,i,o));break}}return o}function hG(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=al(o,s,e.size);n.push(...Array.from(e.values()).sort(ln).map((a,l)=>({...a,index:i[l]})))}}function pG(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=al(o,s,e.size);n.push(...Array.from(e.values()).sort(ln).map((a,l)=>({...a,index:i[l]})))}}function fG(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:l}=o;al(t[i].index,(s=t[i+1])==null?void 0:s.index,i-l).forEach((c,u)=>n.push({...t[l+u],index:c})),o={name:"skipping"};break}}}}function gG(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;al((s=t[i-1])==null?void 0:s.index,t[i].index,o.selectIndex-i).forEach((l,c)=>{n.push({...t[i+c+1],index:l})}),o={name:"skipping"};break}}}}function XM({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:Ge(i),initialPagePoint:e.getShapePageTransform(i.id).point()}))}}function Kh({delta:e,editor:t,snapshot:n,stage:r}){const{selectionPageCenter:o,shapeSnapshots:s}=n;t.updateShapes(s.map(({shape:a,initialPagePoint:l})=>{const c=On(a.parentId)?t.getShapePageTransform(a.parentId):se.Identity(),u=b.RotWith(l,o,e),h=se.applyToPoint(se.Inverse(c),u),p=Ns(a.rotation+e);return{id:a.id,type:a.type,x:h.x,y:h.y,rotation:p}}));const i=[];s.forEach(({shape:a})=>{var h,p,f;const l=t.getShape(a.id);if(!l)return;const c=t.getShapeUtil(a);if(r==="start"||r==="one-off"){const S=(h=c.onRotateStart)==null?void 0:h.call(c,a);S&&i.push(S)}const u=(p=c.onRotate)==null?void 0:p.call(c,a,l);if(u&&i.push(u),r==="end"||r==="one-off"){const S=(f=c.onRotateEnd)==null?void 0:f.call(c,a,l);S&&i.push(S)}}),i.length>0&&t.updateShapes(i)}const mG=e=>{const{store:t}=e,n=t.query.filterHistory("binding"),r=t.query.records("binding");function o(){const s=r.get(),i=new Map;for(const a of s){const{fromId:l,toId:c}=a,u=i.get(l);u?u.push(a):i.set(l,[a]);const h=i.get(c);h?h.push(a):i.set(c,[a])}return i}return G("arrowBindingsIndex",(s,i)=>{if(Mi(s))return o();const a=s,l=n.getDiffSince(i);if(l===rr)return o();let c;function u(f){c??(c=new Map(a));const S=c.get(f.fromId),y=S==null?void 0:S.filter(v=>v.id!==f.id);y!=null&&y.length?c.set(f.fromId,y):c.delete(f.fromId);const x=c.get(f.toId),m=x==null?void 0:x.filter(v=>v.id!==f.id);m!=null&&m.length?c.set(f.toId,m):c.delete(f.toId)}function h(f){c??(c=new Map(a));let S=c.get(f);return S?S===a.get(f)&&(S=S.slice(0),c.set(f,S)):(S=[],c.set(f,S)),S}function p(f){h(f.fromId).push(f),h(f.toId).push(f)}for(const f of l){for(const S of gt(f.added))p(S);for(const[S,y]of gt(f.updated))u(S),p(y);for(const S of gt(f.removed))u(S)}return c??a})};function yG(e,t,n){const r=e.getShapeMaskedPageBounds(t);return r===void 0?!0:!n.includes(r)}const SG=e=>{function t(n){const r=n.getCurrentPageShapeIds(),o=n.getViewportPageBounds(),s=new Set;return r.forEach(i=>{yG(n,i,o)&&s.add(i)}),s}return G("getCulledShapes",n=>{if(Mi(n))return t(e);const r=t(e);if(n.size!==r.size)return r;for(const o of n)if(!r.has(o))return r;return n})},vG=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(ln),i.forEach(a=>{o[a.parentId]||(o[a.parentId]=[]),o[a.parentId].push(a.id)}),o}return G("parentsToChildrenWithIndexes",(o,s)=>{if(Mi(o))return r();const i=n.getDiffSince(s);if(i===rr)return r();if(i.length===0)return o;let a=null;const l=h=>{a||(a={...o}),a[h]?a[h]===o[h]&&(a[h]=[...a[h]]):a[h]=[]},c=new Set;let u;for(let h=0,p=i.length;h<p;h++){u=i[h];for(const f of Object.values(u.added))Ta(f)&&(l(f.parentId),a[f.parentId].push(f.id),c.add(a[f.parentId]));for(const[f,S]of Object.values(u.updated))if(Ta(S)&&Ta(f)){if(f.parentId!==S.parentId)l(f.parentId),l(S.parentId),a[f.parentId].splice(a[f.parentId].indexOf(S.id),1),a[S.parentId].push(S.id),c.add(a[S.parentId]);else if(f.index!==S.index){l(S.parentId);const y=a[S.parentId].indexOf(S.id);a[S.parentId][y]=S.id,c.add(a[S.parentId])}}for(const f of Object.values(u.removed))Ta(f)&&(l(f.parentId),a[f.parentId].splice(a[f.parentId].indexOf(f.id),1))}for(const h of c){const p=ye(h.map(f=>e.get(f)));p.sort(ln),h.splice(0,h.length,...p.map(f=>f.id))}return a??o})},sy=(e,t,n)=>{for(;!An(n.parentId);){const r=e.get(n.parentId);if(!r)return!1;n=r}return n.parentId===t},xG=(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=>sy(e,s,e.get(i))))}return G("_shapeIdsInCurrentPage",(s,i)=>{if(Mi(s))return o();const a=t();if(a!==r)return o();const l=e.history.getDiffSince(i);if(l===rr)return o();const c=new Th(s);for(const h of l){for(const p of Object.values(h.added))Ta(p)&&sy(e,a,p)&&c.add(p.id);for(const[p,f]of Object.values(h.updated))Ta(f)&&(sy(e,a,f)?c.add(f.id):c.remove(f.id));for(const p of Object.keys(h.removed))On(p)&&c.remove(p)}const u=c.get();return u?mc(u.value,u.diff):s})},qM=P.createContext(null);function wG({context:e,editor:t,children:n}){return d.jsx(Vf.Provider,{value:t,children:d.jsx(qM.Provider,{value:e,children:n})})}function ZM(){const e=P.useContext(qM);return e?{isDarkMode:e.isDarkMode}:null}async function bG(e,t,n={}){var E,_;const r=typeof t[0]=="string"?t:t.map(I=>I.id);if(r.length===0)return;if(!window.document)throw Error("No document");const{scale:o=1,background:s=!1,padding:i=e.options.defaultSvgPadding,preserveAspectRatio:a=!1}=n,l=n.darkMode??e.user.getIsDarkMode(),c=cs({isDarkMode:l}),u=e.getShapeAndDescendantIds(r),h=e.getUnorderedRenderingShapes(!1).filter(({id:I})=>u.has(I));let p=null;if(n.bounds)p=n.bounds;else for(const{id:I}of h){const k=e.getShapeMaskedPageBounds(I);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 S=p.width*o,y=p.height*o;try{(_=(E=document.body).focus)==null||_.call(E)}catch{}const x=[],m=new Map,v={isDarkMode:l,addExportDef:I=>{if(m.has(I.key))return;const k=(async()=>{const T=await I.getElement();T&&x.push(d.jsx(P.Fragment,{children:T},x.length))})();m.set(I.key,k)}},w=(await Promise.all(h.map(async({id:I,opacity:k,index:T,backgroundIndex:M})=>{var z,W;if(I===f)return[];const D=e.getShape(I);if(e.isShapeOfType(D,"group"))return[];const $=e.getShapeUtil(D);let j=await((z=$.toSvg)==null?void 0:z.call($,D,v)),O=await((W=$.toBackgroundSvg)==null?void 0:W.call($,D,v));if(!j&&!O){const Y=e.getShapePageBounds(D);j=d.jsx("rect",{width:Y.w,height:Y.h,fill:c.solid,stroke:c.grey.pattern,strokeWidth:1})}let R=e.getShapePageTransform(D).toCssString();"scale"in D.props&&D.props.scale!==1&&(R=`${R} scale(${D.props.scale}, ${D.props.scale})`),j&&(j=d.jsx("g",{transform:R,opacity:k,children:j},D.id)),O&&(O=d.jsx("g",{transform:R,opacity:k,children:O},`bg_${D.id}`));const H=e.getShapeMask(D.id);if(H){const Y=`mask_${D.id.replace(":","_")}`;x.push(d.jsx("clipPath",{id:Y,children:d.jsx("path",{d:`M${H.map(({x:q,y:le})=>`${q},${le}`).join("L")}Z`})},x.length)),j&&(j=d.jsx("g",{clipPath:`url(#${Y})`,children:j},D.id)),O&&(O=d.jsx("g",{clipPath:`url(#${Y})`,children:O},`bg_${D.id}`))}const B=[];return j&&B.push({zIndex:T,element:j}),O&&B.push({zIndex:M,element:O}),B}))).flat();return await Promise.all(m.values()),{jsx:d.jsx(wG,{editor:e,context:v,children:d.jsxs("svg",{preserveAspectRatio:a||void 0,direction:"ltr",width:S,height:y,viewBox:`${p.minX} ${p.minY} ${p.width} ${p.height}`,strokeLinecap:"round",strokeLinejoin:"round",style:{backgroundColor:s?f?c.solid:c.background:"transparent"},children:[d.jsx("defs",{children:x}),w.sort((I,k)=>I.zIndex-k.zIndex).map(({element:I})=>I)]})}),width:S,height:y}}const PG=40;class CG{constructor(t){g(this,"_clickId","");g(this,"_clickTimeout");g(this,"_clickScreenPoint");g(this,"_previousScreenPoint");g(this,"_getClickTimeout",(t,n=ct())=>{this._clickId=n,clearTimeout(this._clickTimeout),this._clickTimeout=this.editor.timers.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"?this.editor.options.doubleClickDurationMs:this.editor.options.multiClickDurationMs)});g(this,"_clickState","idle");g(this,"lastPointerInfo",{});g(this,"handlePointerEvent",t=>{switch(t.name){case"pointer_down":{if(!this._clickState)return t;switch(this._clickScreenPoint=b.From(t.point),this._previousScreenPoint&&b.Dist2(this._previousScreenPoint,this._clickScreenPoint)>PG**2&&(this._clickState="idle"),this._previousScreenPoint=this._clickScreenPoint,this.lastPointerInfo=t,this._clickState){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"idle":{this._clickState="pendingDouble";break}case"pendingOverflow":{this._clickState="overflow";break}}return this._clickTimeout=this._getClickTimeout(this._clickState),t}case"pointer_up":{if(!this._clickState)return t;switch(this._clickScreenPoint=b.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"}}return t}case"pointer_move":return this._clickState!=="idle"&&this._clickScreenPoint&&b.Dist2(this._clickScreenPoint,this.editor.inputs.currentScreenPoint)>(this.editor.getInstanceState().isCoarsePointer?this.editor.options.coarseDragDistanceSquared:this.editor.options.dragDistanceSquared)&&this.cancelDoubleClickTimeout(),t}return t});g(this,"cancelDoubleClickTimeout",()=>{this._clickTimeout=clearTimeout(this._clickTimeout),this._clickState="idle"});this.editor=t}get clickState(){return this._clickState}}class IG{constructor(t){g(this,"_isEdgeScrolling",!1);g(this,"_edgeScrollDuration",-1);this.editor=t}updateEdgeScrolling(t){const{editor:n}=this,r=this.getEdgeScroll();if(r.x===0&&r.y===0)this._isEdgeScrolling&&(this._isEdgeScrolling=!1,this._edgeScrollDuration=0);else if(this._isEdgeScrolling||(this._isEdgeScrolling=!0,this._edgeScrollDuration=0),this._edgeScrollDuration+=t,this._edgeScrollDuration>n.options.edgeScrollDelay){const o=n.options.edgeScrollEaseDuration>0?At.easeInCubic(Math.min(1,this._edgeScrollDuration/(n.options.edgeScrollDelay+n.options.edgeScrollEaseDuration))):1;this.moveCameraWhenCloseToEdge({x:r.x*o,y:r.y*o})}}getEdgeProximityFactors(t,n,r,o,s){const{editor:i}=this,a=i.options.edgeScrollDistance,l=r?i.options.coarsePointerWidth:0,c=t-l,u=t+l,h=o?0:a,p=s?n:n-a;return c<h?Math.min(1,(h-c)/a):u>p?-Math.min(1,(u-p)/a):0}getEdgeScroll(){const{editor:t}=this,{inputs:{currentScreenPoint:{x:n,y:r}}}=t,o=t.getViewportScreenBounds(),{isCoarsePointer:s,insets:[i,a,l,c]}=t.getInstanceState(),u=this.getEdgeProximityFactors(n,o.w,s,c,a),h=this.getEdgeProximityFactors(r,o.h,s,i,l);return{x:u,y:h}}moveCameraWhenCloseToEdge(t){const{editor:n}=this;if(!n.inputs.isDragging||n.inputs.isPanning||n.getCameraOptions().isLocked||t.x===0&&t.y===0)return;const r=n.getViewportScreenBounds(),o=r.w<1e3?.612:1,s=r.h<1e3?.612:1,i=n.getZoomLevel(),a=n.user.getEdgeScrollSpeed()*n.options.edgeScrollSpeed,l=a*t.x*o/i,c=a*t.y*s/i,{x:u,y:h,z:p}=n.getCamera();n.setCamera(new b(u+l,h+c,p))}}class EG{constructor(t){g(this,"isSafari");g(this,"isIos");g(this,"isChromeForIos");g(this,"isFirefox");g(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)}}class kG{constructor(t,n){g(this,"disposeSideEffectListener");this.editor=t,this.disposeSideEffectListener=t.sideEffects.registerAfterChangeHandler("instance",(o,s)=>{o.isFocused!==s.isFocused&&(s.isFocused?this.focus():this.blur(),this.updateContainerClass())});const r=t.getInstanceState().isFocused;n!==r&&t.updateInstanceState({isFocused:!!n}),this.updateContainerClass()}updateContainerClass(){const t=this.editor.getContainer();this.editor.getInstanceState().isFocused?t.classList.add("tl-container__focused"):t.classList.remove("tl-container__focused")}focus(){this.editor.getContainer().focus()}blur(){this.editor.complete(),this.editor.getContainer().blur()}dispose(){var t;(t=this.disposeSideEffectListener)==null||t.call(this)}}function ac(e){return TG}class _G{constructor(){g(this,"length",0);g(this,"head",null);g(this,"tail",this)}push(t){return new ow(t,this)}toArray(){return Vo}[Symbol.iterator](){return{next(){return{value:void 0,done:!0}}}}}const TG=new _G;class ow{constructor(t,n){g(this,"length");this.head=t,this.tail=n,this.length=n.length+1}push(t){return new ow(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 MG{constructor(t){g(this,"store");g(this,"dispose");g(this,"state","recording");g(this,"pendingDiff",new jG);g(this,"stacks",Mt("HistoryManager.stacks",{undos:ac(),redos:ac()},{isEqual:(t,n)=>t.undos===n.undos&&t.redos===n.redos}));g(this,"annotateError");g(this,"_isInBatch",!1);g(this,"batch",(t,n)=>{const r=this.state;r!=="paused"&&(n!=null&&n.history)&&(this.state=AG[n.history]);try{if(this._isInBatch)return mo(t),this;this._isInBatch=!0;try{mo(t)}catch(o){throw this.annotateError(o),o}finally{this._isInBatch=!1}return this}finally{this.state=r}});g(this,"_undo",({pushToRedoStack:t,toMark:n=void 0})=>{var o;const r=this.state;this.state="paused";try{let{undos:s,redos:i}=this.stacks.get();const a=this.pendingDiff.clear(),l=c_(a),c=CS(a);t&&!l&&(i=i.push({type:"diff",diff:a}));let u=!1;if(l)for(;((o=s.head)==null?void 0:o.type)==="stop";){const h=s.head;if(s=s.tail,t&&(i=i.push(h)),h.id===n){u=!0;break}}if(!u)e:for(;s.head;){const h=s.head;switch(s=s.tail,t&&(i=i.push(h)),h.type){case"diff":Nc(c,[CS(h.diff)]);break;case"stop":if(!n||h.id===n)break e;break;default:un(h)}}this.store.applyDiff(c,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:s,redos:i})}finally{this.state=r}return this});g(this,"undo",()=>(this._undo({pushToRedoStack:!0}),this));g(this,"redo",()=>{var n;const t=this.state;this.state="paused";try{this.flushPendingDiff();let{undos:r,redos:o}=this.stacks.get();if(o.length===0)return this;for(;((n=o.head)==null?void 0:n.type)==="stop";)r=r.push(o.head),o=o.tail;const s=_p();for(;o.head;){const i=o.head;if(r=r.push(i),o=o.tail,i.type==="diff")Nc(s,[i.diff]);else break}this.store.applyDiff(s,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:r,redos:o})}finally{this.state=t}return this});g(this,"bail",()=>(this._undo({pushToRedoStack:!1}),this));g(this,"bailToMark",t=>(this._undo({pushToRedoStack:!1,toMark:t}),this));g(this,"squashToMark",t=>{var s;let n=this.stacks.get().undos;const r=[];for(;n.head&&!(n.head.type==="stop"&&n.head.id===t);)n.head.type==="diff"&&r.push(n.head.diff),n=n.tail;if(!n.head||((s=n.head)==null?void 0:s.id)!==t)return console.error("Could not find mark to squash to: ",t),this;if(r.length===0)return this;const o=_p();return Nc(o,r.reverse()),this.stacks.update(({redos:i})=>({undos:n.push({type:"diff",diff:o}),redos:i})),this});g(this,"mark",(t=ct())=>(mo(()=>{this.flushPendingDiff(),this.stacks.update(({undos:n,redos:r})=>({undos:n.push({type:"stop",id:t}),redos:r}))}),t));this.store=t.store,this.annotateError=t.annotateError??nu,this.dispose=this.store.addHistoryInterceptor((n,r)=>{if(r==="user")switch(this.state){case"recording":this.pendingDiff.apply(n.changes),this.stacks.update(({undos:o})=>({undos:o,redos:ac()}));break;case"recordingPreserveRedoStack":this.pendingDiff.apply(n.changes);break;case"paused":break;default:un(this.state)}})}flushPendingDiff(){if(this.pendingDiff.isEmpty())return;const t=this.pendingDiff.clear();this.stacks.update(({undos:n,redos:r})=>({undos:n.push({type:"diff",diff:t}),redos:r}))}getNumUndos(){return this.stacks.get().undos.length+(this.pendingDiff.isEmpty()?0:1)}getNumRedos(){return this.stacks.get().redos.length}clear(){this.stacks.set({undos:ac(),redos:ac()}),this.pendingDiff.clear()}debug(){const{undos:t,redos:n}=this.stacks.get();return{undos:t.toArray(),redos:n.toArray(),pendingDiff:this.pendingDiff.debug(),state:this.state}}}const AG={record:"recording","record-preserveRedoStack":"recordingPreserveRedoStack",ignore:"paused"};class jG{constructor(){g(this,"diff",_p());g(this,"isEmptyAtom",Mt("PendingDiff.isEmpty",!0))}clear(){const t=this.diff;return this.diff=_p(),this.isEmptyAtom.set(!0),t}isEmpty(){return this.isEmptyAtom.get()}apply(t){Nc(this.diff,[t]),this.isEmptyAtom.set(c_(this.diff))}debug(){return{diff:this.diff,isEmpty:this.isEmpty()}}}class OG{constructor(t){g(this,"scribbleItems",new Map);g(this,"state","paused");g(this,"addScribble",(t,n=ct())=>{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});g(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});g(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||b.Dist(s,i)>=1)&&(o.next=i),o});g(this,"tick",t=>{this.scribbleItems.size!==0&&this.editor.run(()=>{this.scribbleItems.forEach(n=>{if(n.scribble.state==="starting"){const{next:l,prev:c}=n;l&&l!==c&&(n.prev=l,n.scribble.points.push(l)),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()}}var DG=Object.defineProperty,RG=Object.getOwnPropertyDescriptor,pg=(e,t,n,r)=>{for(var o=RG(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&DG(t,n,o),o};const de=e=>Math.round(e*10**8)/10**8;function No(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)&&Lr(a.breadthIntersection[0],a.breadthIntersection[1],o[0],o[1]));if(s.length===0)return[];const i=new Set;return s.forEach(a=>{const l=r==="forward"?a.endNode.id:a.startNode.id;if(!i.has(l)){i.add(l);const c=No(e,l,n,r,Lr(a.breadthIntersection[0],a.breadthIntersection[1],o[0],o[1]));s.push(...c)}}),s}function LG(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 ed{constructor(t){g(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:l,y:c}=se.applyToPoint(r,i);return{x:l,y:c,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:xr(this.editor.getShapePageBounds(t))}))}getVisibleGaps(){const t=[],n=[];let r,o;const s=this.getSnappableGapNodes().sort((a,l)=>a.pageBounds.minX-l.pageBounds.minX);for(let a=0;a<s.length;a++){r=s[a];for(let l=a+1;l<s.length;l++)o=s[l],r.pageBounds.maxX<o.pageBounds.minX&&Ql(r.pageBounds.minY,r.pageBounds.maxY,o.pageBounds.minY,o.pageBounds.maxY)&&t.push({startNode:r,endNode:o,startEdge:[new b(r.pageBounds.maxX,r.pageBounds.minY),new b(r.pageBounds.maxX,r.pageBounds.maxY)],endEdge:[new b(o.pageBounds.minX,o.pageBounds.minY),new b(o.pageBounds.minX,o.pageBounds.maxY)],length:o.pageBounds.minX-r.pageBounds.maxX,breadthIntersection:Lr(r.pageBounds.minY,r.pageBounds.maxY,o.pageBounds.minY,o.pageBounds.maxY)})}const i=s.sort((a,l)=>a.pageBounds.minY-l.pageBounds.minY);for(let a=0;a<i.length;a++){r=i[a];for(let l=a+1;l<i.length;l++)o=i[l],r.pageBounds.maxY<o.pageBounds.minY&&Ql(r.pageBounds.minX,r.pageBounds.maxX,o.pageBounds.minX,o.pageBounds.maxX)&&n.push({startNode:r,endNode:o,startEdge:[new b(r.pageBounds.minX,r.pageBounds.maxY),new b(r.pageBounds.maxX,r.pageBounds.maxY)],endEdge:[new b(o.pageBounds.minX,o.pageBounds.minY),new b(o.pageBounds.maxX,o.pageBounds.minY)],length:o.pageBounds.minY-r.pageBounds.maxY,breadthIntersection:Lr(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 x,m;const s=this.manager.getSnapThreshold(),i=this.getSnappablePoints(),a=n.clone().translate(o),l=r.map(({x:v,y:w},C)=>({id:"selection:"+C,x:v+o.x,y:w+o.y})),c=i,u=[],h=[],p=new b(s,s);this.collectPointSnaps({minOffset:p,nearestSnapsX:u,nearestSnapsY:h,otherNodeSnapPoints:c,selectionSnapPoints:l}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:h,minOffset:p});const f=new b(t==="x"?0:((x=u[0])==null?void 0:x.nudge)??0,t==="y"?0:((m=h[0])==null?void 0:m.nudge)??0);p.x=0,p.y=0,u.length=0,h.length=0,l.forEach(v=>{v.x+=f.x,v.y+=f.y}),a.translate(f),this.collectPointSnaps({minOffset:p,nearestSnapsX:u,nearestSnapsY:h,otherNodeSnapPoints:c,selectionSnapPoints:l}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:h,minOffset:p});const S=this.getPointSnapLines({nearestSnapsX:u,nearestSnapsY:h}),y=this.getGapSnapLines({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:h});return this.manager.setIndicators([...y,...S]),{nudge:f}}snapResizeShapes({initialSelectionPageBounds:t,dragDelta:n,handle:r,isAspectRatioLocked:o,isResizingFromCenter:s}){var I,k;const i=this.manager.getSnapThreshold(),{box:a,scaleX:l,scaleY:c}=Q.Resize(t,r,s?n.x*2:n.x,s?n.y*2:n.y,o);let u=r;l<0&&(u=N7(u)),c<0&&(u=$7(u)),s&&(a.center=t.center);const h=u==="top"||u==="bottom",p=u==="left"||u==="right",f=KC(u,a),S=this.getSnappablePoints(),y=[],x=[],m=new b(i,i);this.collectPointSnaps({minOffset:m,nearestSnapsX:y,nearestSnapsY:x,otherNodeSnapPoints:S,selectionSnapPoints:f});const v=new b(h?0:((I=y[0])==null?void 0:I.nudge)??0,p?0:((k=x[0])==null?void 0:k.nudge)??0);if(o&&F7(u)&&v.len()!==0){const T=y.length&&x.length?Math.abs(v.x)<Math.abs(v.y)?"x":"y":y.length?"x":"y",M=t.aspectRatio;T==="x"?(x.length=0,v.y=v.x/M,(u==="bottom_left"||u==="top_right")&&(v.y=-v.y)):(y.length=0,v.x=v.y*M,(u==="bottom_left"||u==="top_right")&&(v.x=-v.x))}const w=b.Add(n,v),{box:C}=Q.Resize(t,r,s?w.x*2:w.x,s?w.y*2:w.y,o);s&&(C.center=t.center);const E=KC("any",C);y.length=0,x.length=0,m.x=0,m.y=0,this.collectPointSnaps({minOffset:m,nearestSnapsX:y,nearestSnapsY:x,otherNodeSnapPoints:S,selectionSnapPoints:E});const _=this.getPointSnapLines({nearestSnapsX:y,nearestSnapsY:x});return this.manager.setIndicators([..._]),{nudge:v}}collectPointSnaps({selectionSnapPoints:t,otherNodeSnapPoints:n,minOffset:r,nearestSnapsX:o,nearestSnapsY:s}){for(const i of t)for(const a of n){const l=b.Sub(i,a),c=Math.abs(l.x),u=Math.abs(l.y);de(c)<=de(r.x)&&(de(c)<de(r.x)&&(o.length=0),o.push({type:"points",points:{thisPoint:i,otherPoint:a},nudge:a.x-i.x}),r.x=c),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(!Ql(a.breadthIntersection[0],a.breadthIntersection[1],t.minY,t.maxY))continue;const c=a.startEdge[0].x+a.length/2-t.center.x;if(a.length>t.width&&de(Math.abs(c))<=de(n.x)){de(Math.abs(c))<de(n.x)&&(r.length=0),n.x=Math.abs(c);const m={type:"gap_center",gap:a,nudge:c},v=r.find(({type:C})=>C==="gap_center"),w=v&&Lr(a.breadthIntersection[0],a.breadthIntersection[1],v.gap.breadthIntersection[0],v.gap.breadthIntersection[1]);v&&v.gap.length>a.length&&w?r[r.indexOf(v)]=m:(!v||!w)&&r.push(m)}const h=a.startNode.pageBounds.minX-a.length,p=t.maxX,f=h-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 S=a.endNode.pageBounds.maxX+a.length,y=t.minX,x=S-y;de(Math.abs(x))<=de(n.x)&&(de(Math.abs(x))<de(n.x)&&(r.length=0),n.x=Math.abs(x),r.push({type:"gap_duplicate",gap:a,protrusionDirection:"right",nudge:x}))}for(const a of i){if(!Ql(a.breadthIntersection[0],a.breadthIntersection[1],t.minX,t.maxX))continue;const c=a.startEdge[0].y+a.length/2-t.center.y;if(a.length>t.height&&de(Math.abs(c))<=de(n.y)){de(Math.abs(c))<de(n.y)&&(o.length=0),n.y=Math.abs(c);const m={type:"gap_center",gap:a,nudge:c},v=o.find(({type:C})=>C==="gap_center"),w=v&&Ql(v.gap.breadthIntersection[0],v.gap.breadthIntersection[1],a.breadthIntersection[0],a.breadthIntersection[1]);v&&v.gap.length>a.length&&w?o[o.indexOf(v)]=m:(!v||!w)&&o.push(m);continue}const h=a.startNode.pageBounds.minY-a.length,p=t.maxY,f=h-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 S=a.endNode.pageBounds.maxY+a.length,y=t.minY,x=S-y;de(Math.abs(x))<=de(n.y)&&(de(Math.abs(x))<de(n.y)&&(o.length=0),n.y=Math.abs(x),o.push({type:"gap_duplicate",gap:a,protrusionDirection:"bottom",nudge:x}))}}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:ct(),type:"points",points:Bx(s.map(i=>b.From(i.otherPoint)).concat(s.map(i=>b.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 l of n){if(l.type==="points")continue;const{gap:{breadthIntersection:c,startEdge:u,startNode:h,endNode:p,length:f,endEdge:S}}=l;switch(l.type){case"gap_center":{const y=(f-t.width)/2,x=Lr(c[0],c[1],t.minY,t.maxY);a.push({type:"gaps",direction:"horizontal",id:ct(),gaps:[...No(s,h.id,y,"backward",x),{startEdge:u,endEdge:i.left},{startEdge:i.right,endEdge:S},...No(s,p.id,y,"forward",x)]});break}case"gap_duplicate":{const y=Lr(c[0],c[1],t.minY,t.maxY);a.push({type:"gaps",direction:"horizontal",id:ct(),gaps:l.protrusionDirection==="left"?[{startEdge:i.right,endEdge:u.map(x=>x.clone().addXY(-h.pageBounds.width,0))},{startEdge:u,endEdge:S},...No(s,p.id,f,"forward",y)]:[...No(s,h.id,f,"backward",y),{startEdge:u,endEdge:S},{startEdge:S.map(x=>x.clone().addXY(l.gap.endNode.pageBounds.width,0)),endEdge:i.left}]});break}}}if(r.length>0)for(const l of r){if(l.type==="points")continue;const{gap:{breadthIntersection:c,startEdge:u,startNode:h,endNode:p,length:f,endEdge:S}}=l;switch(l.type){case"gap_center":{const y=(f-t.height)/2,x=Lr(c[0],c[1],t.minX,t.maxX);a.push({type:"gaps",direction:"vertical",id:ct(),gaps:[...No(o,h.id,y,"backward",x),{startEdge:u,endEdge:i.top},{startEdge:i.bottom,endEdge:S},...No(o,l.gap.endNode.id,y,"forward",x)]});break}case"gap_duplicate":{const y=Lr(c[0],c[1],t.minX,t.maxX);a.push({type:"gaps",direction:"vertical",id:ct(),gaps:l.protrusionDirection==="top"?[{startEdge:i.bottom,endEdge:u.map(x=>x.clone().addXY(0,-h.pageBounds.height))},{startEdge:u,endEdge:S},...No(o,p.id,f,"forward",y)]:[...No(o,h.id,f,"backward",y),{startEdge:u,endEdge:S},{startEdge:S.map(x=>x.clone().addXY(0,p.pageBounds.height)),endEdge:i.top}]})}break}}return LG(a),a}}pg([G],ed.prototype,"getSnapPointsCache");pg([G],ed.prototype,"getSnappablePoints");pg([G],ed.prototype,"getSnappableGapNodes");pg([G],ed.prototype,"getVisibleGaps");function KC(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 $G=Object.defineProperty,NG=Object.getOwnPropertyDescriptor,FG=(e,t,n,r)=>{for(var o=NG(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&$G(t,n,o),o};const zG=()=>null,BG=()=>[];class QM{constructor(t){g(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??zG,getSelfSnapPoints:r.getSelfSnapPoints??BG}})}*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=xr(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 l=xr(this.editor.getShapePageTransform(i));for(const c of a)yield l.applyToPoint(c)}}*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 c of this.iterateSnapPointsInPageSpace(t,n))b.DistMin(r,c,s)&&(s=b.Dist(r,c),i=c);if(i)return i;let a=o,l=null;for(const{shapeId:c,outline:u}of this.iterateSnapOutlines(t,n)){const h=xr(this.editor.getShapePageTransform(c)),p=this.editor.getPointInShapeSpace(c,r),f=u.nearestPoint(p),S=h.applyToPoint(f);b.DistMin(r,S,a)&&(a=b.Dist(r,S),l=S)}return l||null}snapHandle({currentShapeId:t,handle:n}){const o=xr(this.editor.getShapePageTransform(t)).applyToPoint(n),s=this.getHandleSnapPosition({currentShapeId:t,handle:n,handleInPageSpace:o});return s?(this.manager.setIndicators([{id:ct(),type:"points",points:[s]}]),{nudge:b.Sub(s,o)}):null}}FG([G],QM.prototype,"getSnapGeometryCache");var UG=Object.defineProperty,HG=Object.getOwnPropertyDescriptor,sw=(e,t,n,r)=>{for(var o=HG(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&UG(t,n,o),o};class fg{constructor(t){g(this,"shapeBounds");g(this,"handles");g(this,"_snapIndicators",Mt("snapLines",void 0));this.editor=t,this.shapeBounds=new ed(this),this.handles=new QM(this)}getIndicators(){return this._snapIndicators.get()??Vo}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.getViewportPageBounds(),r=t.getSelectedShapeIds(),o=new Set,s=i=>{if(On(i)){const l=t.getShape(i);l&&t.isShapeOfType(l,"frame")&&o.add(i)}const a=t.getSortedChildIdsForParent(i);for(const l of a){if(r.includes(l))continue;const c=t.getShape(l);if(!c||!t.getShapeUtil(c).canSnap(c))continue;const h=t.getShapePageBounds(l);if(h&&n.includes(h)){if(t.isShapeOfType(c,"group")){s(l);continue}o.add(l)}}};return s(this.getCurrentCommonAncestor()??t.getCurrentPageId()),o}getCurrentCommonAncestor(){return this.editor.findCommonAncestor(this.editor.getSelectedShapes())}}sw([G],fg.prototype,"getSnapThreshold");sw([G],fg.prototype,"getSnappableShapes");sw([G],fg.prototype,"getCurrentCommonAncestor");const KG=/\r?\n|\r/g;function WC(e){return e.replace(KG,`
|
|
86
|
+
`).split(`
|
|
87
|
+
`).map(t=>t||" ").join(`
|
|
88
|
+
`)}const WG={start:"left","start-legacy":"left",middle:"center","middle-legacy":"center",end:"right","end-legacy":"right"},GG=/\s/;class VG{constructor(t){g(this,"baseElm");g(this,"measureText",(t,n)=>{var i;const r=(i=this.baseElm)==null?void 0:i.cloneNode();this.baseElm.insertAdjacentElement("afterend",r),r.setAttribute("dir","auto"),r.style.setProperty("unicode-bidi","plaintext"),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=WC(t);const o=r.scrollWidth,s=r.getBoundingClientRect();return r.remove(),{x:0,y:0,w:s.width,h:s.height,scrollWidth:o}});this.editor=t;const n=this.editor.getContainer(),r=document.createElement("div");r.classList.add("tl-text"),r.classList.add("tl-text-measure"),r.tabIndex=-1,n.appendChild(r),this.baseElm=r,t.disposables.add(()=>{r.remove()})}measureElementTextNodeSpans(t,{shouldTruncateToFirstLine:n=!1}={}){const r=[],o=t.getBoundingClientRect(),s=-o.left,i=-o.top,a=new Range,l=t.childNodes[0];let c=0,u=null,h=null,p=0,f=0,S=!1;for(const y of t.childNodes)if(y.nodeType===Node.TEXT_NODE)for(const x of y.textContent??""){a.setStart(l,c),a.setEnd(l,c+x.length);const m=a.getClientRects(),v=m[m.length-1],w=v.top+i,C=v.left+s,E=v.right+s,_=C<f,I=GG.test(x);if(I!==h||w!==p||!u){if(u){if(n&&w!==p){S=!0;break}r.push(u)}u={box:{x:C,y:w,w:v.width,h:v.height},text:x},f=C}else _&&(u.box.x=C),u.box.w=_?u.box.w+v.width:E-u.box.x,u.text+=x;x===`
|
|
89
|
+
`&&(f=0),h=I,p=w,c+=x.length}return u&&r.push(u),{spans:r,didTruncate:S}}measureTextSpans(t,n){var c;if(t==="")return[];const r=(c=this.baseElm)==null?void 0:c.cloneNode();this.baseElm.insertAdjacentElement("afterend",r);const o=Math.ceil(n.width-n.padding*2);r.setAttribute("dir","auto"),r.style.setProperty("unicode-bidi","plaintext"),r.style.setProperty("width",`${o}px`),r.style.setProperty("height","min-content"),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",WG[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=WC(t);r.textContent=i;const{spans:a,didTruncate:l}=this.measureElementTextNodeSpans(r,{shouldTruncateToFirstLine:s});if(n.overflow==="truncate-ellipsis"&&l){r.textContent="…";const u=Math.ceil(this.measureElementTextNodeSpans(r).spans[0].box.w);r.style.setProperty("width",`${o-u}px`),r.textContent=i;const h=this.measureElementTextNodeSpans(r,{shouldTruncateToFirstLine:!0}).spans,p=h[h.length-1];return h.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}}),h}return r.remove(),a}}const GC=(typeof process<"u",s_);class YG{constructor(t){g(this,"cancelRaf");g(this,"isPaused",!0);g(this,"now",0);g(this,"start",()=>{var t;this.isPaused=!1,(t=this.cancelRaf)==null||t.call(this),this.cancelRaf=GC(this.tick),this.now=Date.now()});g(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=GC(this.tick)});g(this,"dispose",()=>{var t;this.isPaused=!0,(t=this.cancelRaf)==null||t.call(this)});g(this,"prevPoint",new b);g(this,"updatePointerVelocity",t=>{const{prevPoint:n,editor:{inputs:{currentScreenPoint:r,pointerVelocity:o}}}=this;if(t===0)return;const s=b.Sub(r,n);this.prevPoint=r.clone();const i=s.len(),a=i?s.div(i):new b(0,0),l=o.clone().lrp(a.mul(i/t),.5);Math.abs(l.x)<.01&&(l.x=0),Math.abs(l.y)<.01&&(l.y=0),o.equals(l)||(this.editor.inputs.pointerVelocity=l)});this.editor=t,this.editor.disposables.add(this.dispose),this.start()}}var XG=Object.defineProperty,qG=Object.getOwnPropertyDescriptor,Ar=(e,t,n,r)=>{for(var o=qG(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&XG(t,n,o),o};class fr{constructor(t,n){g(this,"systemColorScheme",Mt("systemColorScheme","light"));g(this,"updateUserPreferences",t=>{this.user.setUserPreferences({...this.user.userPreferences.get(),...t})});if(this.user=t,this.inferDarkMode=n,typeof window>"u"||!("matchMedia"in window))return;const r=window.matchMedia("(prefers-color-scheme: dark)");r!=null&&r.matches&&this.systemColorScheme.set("dark"),r==null||r.addEventListener("change",o=>{o.matches?this.systemColorScheme.set("dark"):this.systemColorScheme.set("light")})}getUserPreferences(){return{id:this.getId(),name:this.getName(),locale:this.getLocale(),color:this.getColor(),animationSpeed:this.getAnimationSpeed(),isSnapMode:this.getIsSnapMode(),colorScheme:this.user.userPreferences.get().colorScheme,isDarkMode:this.getIsDarkMode(),isWrapMode:this.getIsWrapMode(),isDynamicResizeMode:this.getIsDynamicResizeMode()}}getIsDarkMode(){switch(this.user.userPreferences.get().colorScheme){case"dark":return!0;case"light":return!1;case"system":return this.systemColorScheme.get()==="dark";default:return this.inferDarkMode?this.systemColorScheme.get()==="dark":!1}}getEdgeScrollSpeed(){return this.user.userPreferences.get().edgeScrollSpeed??Lo.edgeScrollSpeed}getAnimationSpeed(){return this.user.userPreferences.get().animationSpeed??Lo.animationSpeed}getId(){return this.user.userPreferences.get().id}getName(){return this.user.userPreferences.get().name??Lo.name}getLocale(){return this.user.userPreferences.get().locale??Lo.locale}getColor(){return this.user.userPreferences.get().color??Lo.color}getIsSnapMode(){return this.user.userPreferences.get().isSnapMode??Lo.isSnapMode}getIsWrapMode(){return this.user.userPreferences.get().isWrapMode??Lo.isWrapMode}getIsDynamicResizeMode(){return this.user.userPreferences.get().isDynamicSizeMode??Lo.isDynamicSizeMode}getIsPasteAtCursorMode(){return this.user.userPreferences.get().isPasteAtCursorMode??Lo.isPasteAtCursorMode}}Ar([G],fr.prototype,"getUserPreferences");Ar([G],fr.prototype,"getIsDarkMode");Ar([G],fr.prototype,"getEdgeScrollSpeed");Ar([G],fr.prototype,"getAnimationSpeed");Ar([G],fr.prototype,"getId");Ar([G],fr.prototype,"getName");Ar([G],fr.prototype,"getLocale");Ar([G],fr.prototype,"getColor");Ar([G],fr.prototype,"getIsSnapMode");Ar([G],fr.prototype,"getIsWrapMode");Ar([G],fr.prototype,"getIsDynamicResizeMode");Ar([G],fr.prototype,"getIsPasteAtCursorMode");const ZG={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"},QG=["brushing","cropping","dragging","dragging_handle","drawing","erasing","lasering","resizing","rotating","scribble_brushing","translating"];class oe{constructor(t,n){g(this,"performanceTracker");g(this,"id");g(this,"type");g(this,"shapeType");g(this,"initial");g(this,"children");g(this,"isLockable");g(this,"parent");g(this,"_path");g(this,"_current");g(this,"_isActive");g(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],l=o.getCurrent(),c=(s=o.children)==null?void 0:s[a];if(!c)throw Error(`${o.id} - no child state exists with the id ${a}.`);if((l==null?void 0:l.id)!==c.id&&(l==null||l.exit(n,a),o._current.set(c),c.enter(n,(l==null?void 0:l.id)||"initial"),!c.getIsActive()))break;o=c}return this});g(this,"handleEvent",t=>{var o;const n=ZG[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)});g(this,"enter",(t,n)=>{var r;if(xt.measurePerformance.get()&&QG.includes(this.id)&&this.performanceTracker.start(this.id),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)}});g(this,"exit",(t,n)=>{var r,o;xt.measurePerformance.get()&&this.performanceTracker.isStarted()&&this.performanceTracker.stop(),this._isActive.set(!1),(r=this.onExit)==null||r.call(this,t,n),this.getIsActive()||(o=this.getCurrent())==null||o.exit(t,n)});g(this,"_currentToolIdMask",Mt("curent tool id mask",void 0));g(this,"onWheel");g(this,"onPointerDown");g(this,"onPointerMove");g(this,"onLongPress");g(this,"onPointerUp");g(this,"onDoubleClick");g(this,"onTripleClick");g(this,"onQuadrupleClick");g(this,"onRightClick");g(this,"onMiddleClick");g(this,"onKeyDown");g(this,"onKeyUp");g(this,"onKeyRepeat");g(this,"onCancel");g(this,"onComplete");g(this,"onInterrupt");g(this,"onTick");g(this,"onEnter");g(this,"onExit");this.editor=t;const{id:r,children:o,initial:s,isLockable:i}=this.constructor;this.id=r,this._isActive=Mt("toolIsActive"+this.id,!1),this._current=Mt("toolState"+this.id,void 0),this._path=G("toolPath"+this.id,()=>{const a=this.getCurrent();return this.id+(a?`.${a.getPath()}`:"")}),this.parent=n??{},this.parent?o&&s?(this.type="branch",this.initial=s,this.children=Object.fromEntries(o().map(a=>[a.id,new a(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(a=>[a.id,new a(this.editor,this)])),this._current.set(this.children[this.initial]))),this.isLockable=i,this.performanceTracker=new Uk}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)}}g(oe,"id"),g(oe,"initial"),g(oe,"children"),g(oe,"isLockable",!0);class Wh extends oe{constructor(){super(...arguments);g(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}}})}}g(Wh,"id","root"),g(Wh,"initial",""),g(Wh,"children",()=>[]);var JG=Object.defineProperty,eV=Object.getOwnPropertyDescriptor,ne=(e,t,n,r)=>{for(var o=eV(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&JG(t,n,o),o};class Z extends HH{constructor({store:n,user:r,shapeUtils:o,bindingUtils:s,tools:i,getContainer:a,cameraOptions:l,initialState:c,autoFocus:u,inferDarkMode:h,options:p}){super();g(this,"options");g(this,"store");g(this,"root");g(this,"disposables",new Set);g(this,"isDisposed",!1);g(this,"_tickManager");g(this,"snaps");g(this,"timers");g(this,"user");g(this,"textMeasure");g(this,"environment");g(this,"scribbles");g(this,"sideEffects");g(this,"edgeScrollManager");g(this,"focusManager");g(this,"getContainer");g(this,"shapeUtils");g(this,"styleProps");g(this,"bindingUtils");g(this,"history");g(this,"_shouldIgnoreShapeLock",!1);g(this,"_crashingError",null);g(this,"_updateInstanceState",(n,r)=>{this.run(()=>{this.store.put([{...this.getInstanceState(),...n}])},r)});g(this,"_isChangingStyleTimeout",-1);g(this,"setCursor",n=>(this.updateInstanceState({cursor:{...this.getInstanceState().cursor,...n}}),this));g(this,"_updateCurrentPageState",n=>{this.store.update(n.id??this.getCurrentPageState().id,r=>({...r,...n}))});g(this,"_cameraOptions",Mt("camera options",fP));g(this,"_viewportAnimation",null);g(this,"_willSetInitialBounds",!0);g(this,"_isLockedOnFollowingUser",Mt("isLockedOnFollowingUser",!1));g(this,"_cameraState",Mt("camera state","idle"));g(this,"_cameraStateTimeoutRemaining",0);g(this,"_decayCameraStateTimeout",n=>{this._cameraStateTimeoutRemaining-=n,!(this._cameraStateTimeoutRemaining>0)&&(this.off("tick",this._decayCameraStateTimeout),this._cameraState.set("idle"))});g(this,"_tickCameraState",()=>{this._cameraStateTimeoutRemaining=this.options.cameraMovingTimeoutMs,this._cameraState.__unsafe__getWithoutCapture()==="idle"&&(this._cameraState.set("moving"),this.on("tick",this._decayCameraStateTimeout))});g(this,"_currentPageShapeIds");g(this,"_parentIdsToChildIds");g(this,"animatingShapes",new Map);g(this,"_updateShapes",n=>{this.getInstanceState().isReadonly||this.run(()=>{var i,a;const r=[];let o,s;for(let l=0,c=n.length;l<c;l++){const u=n[l];u&&(o=this.getShape(u.id),o&&(s=oo(o,u),s!==o&&(s=((a=(i=this.getShapeUtil(o)).onBeforeUpdate)==null?void 0:a.call(i,o,s))??s,r.push(s))))}this.store.put(r)})});g(this,"externalAssetContentHandlers",{file:null,url:null});g(this,"externalContentHandlers",{text:null,files:null,embed:null,"svg-text":null,url:null});g(this,"inputs",{originPagePoint:new b,originScreenPoint:new b,previousPagePoint:new b,previousScreenPoint:new b,currentPagePoint:new b,currentScreenPoint:new b,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 b});g(this,"_clickManager",new CG(this));g(this,"_prevCursor","default");g(this,"_shiftKeyTimeout",-1);g(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"})});g(this,"_altKeyTimeout",-1);g(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"})});g(this,"_ctrlKeyTimeout",-1);g(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"})});g(this,"_restoreToolId","select");g(this,"_pinchStart",1);g(this,"_didPinch",!1);g(this,"_selectedShapeIdsAtPointerDown",[]);g(this,"_longPressTimeout",-1);g(this,"capturedPointerId",null);g(this,"performanceTracker");g(this,"performanceTrackerTimeout",-1);g(this,"dispatch",n=>(this._pendingEventsForNextTick.push(n),n.type==="pointer"&&n.name==="pointer_move"||n.type==="wheel"||n.type==="pinch"||this._flushEventsForTick(0),this));g(this,"_pendingEventsForNextTick",[]);g(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.setCursor({type:this._prevCursor,rotation:0}))),this.root.handleEvent(n);return}n.shiftKey?(clearTimeout(this._shiftKeyTimeout),this._shiftKeyTimeout=-1,r.shiftKey=!0):!n.shiftKey&&r.shiftKey&&this._shiftKeyTimeout===-1&&(this._shiftKeyTimeout=this.timers.setTimeout(this._setShiftKeyTimeout,150)),n.altKey?(clearTimeout(this._altKeyTimeout),this._altKeyTimeout=-1,r.altKey=!0):!n.altKey&&r.altKey&&this._altKeyTimeout===-1&&(this._altKeyTimeout=this.timers.setTimeout(this._setAltKeyTimeout,150)),n.ctrlKey?(clearTimeout(this._ctrlKeyTimeout),this._ctrlKeyTimeout=-1,r.ctrlKey=!0):!n.ctrlKey&&r.ctrlKey&&this._ctrlKeyTimeout===-1&&(this._ctrlKeyTimeout=this.timers.setTimeout(this._setCtrlKeyTimeout,150));const{originPagePoint:s,currentPagePoint:i}=r;r.isPointing||(r.isDragging=!1);const a=this.store.unsafeGetWithoutCapture(Sn),l=this.store.get(this._getCurrentPageStateId()),c=this._cameraOptions.__unsafe__getWithoutCapture();switch(o){case"pinch":{if(c.isLocked)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=[...l.selectedShapeIds]),this._didPinch=!0,r.isPinching=!0,this.interrupt());return}case"pinch":{if(!r.isPinching)return;const{point:{z:u=1},delta:{x:h,y:p}}=n,{x:f,y:S}=b.SubXY(n.point,a.screenBounds.x,a.screenBounds.y);this.stopCameraAnimation(),a.followingUserId&&this.stopFollowingUser();const{x:y,y:x,z:m}=Id(()=>this.getCamera()),{panSpeed:v,zoomSpeed:w}=c;this._setCamera(new b(y+h*v/m-f/m+f/(u*w),x+p*v/m-S/m+S/(u*w),u*w),{immediate:!0});return}case"pinch_end":{if(!r.isPinching)return this;r.isPinching=!1;const{_selectedShapeIdsAtPointerDown:u}=this;this.setSelectedShapes(this._selectedShapeIdsAtPointerDown),this._selectedShapeIdsAtPointerDown=[],this._didPinch&&(this._didPinch=!1,u.length>0&&this.once("tick",()=>{this._didPinch||this.setSelectedShapes(u)}));return}}}case"wheel":{if(c.isLocked)return;if(this._updateInputsFromEvent(n),!this.getIsMenuOpen()){const{panSpeed:u,zoomSpeed:h,wheelBehavior:p}=c;if(p!=="none"){this.stopCameraAnimation(),a.followingUserId&&this.stopFollowingUser();const{x:f,y:S,z:y}=Id(()=>this.getCamera()),{x,y:m,z:v=0}=n.delta;let w=p;switch(r.ctrlKey&&(w=p==="pan"?"zoom":"pan"),w){case"zoom":{const{x:C,y:E}=this.inputs.currentScreenPoint;let _=v;p==="zoom"&&(Math.abs(m)>10?_=10*Math.sign(m)/100:_=m/100);const I=y+(_??0)*h*y;this._setCamera(new b(f+(C/I-C)-(C/y-C),S+(E/I-E)-(E/y-E),I),{immediate:!0}),this.maybeTrackPerformance("Zooming");return}case"pan":{this._setCamera(new b(f+x*u/y,S+m*u/y,y),{immediate:!0}),this.maybeTrackPerformance("Panning");return}}}}break}case"pointer":{if(r.isPinching)return;this._updateInputsFromEvent(n);const{isPen:u}=n,{isPenMode:h}=a;switch(n.name){case"pointer_down":{if(h&&!u)return;if(this.clearOpenMenus(),this.inputs.isPanning||(this._longPressTimeout=this.timers.setTimeout(()=>{this.dispatch({...n,point:this.inputs.currentScreenPoint,name:"long_press"})},this.options.longPressDurationMs)),this._selectedShapeIdsAtPointerDown=this.getSelectedShapeIds(),n.button===mP&&(this.capturedPointerId=n.pointerId),r.buttons.add(n.button),r.isPointing=!0,r.isDragging=!1,!h&&u&&this.updateInstanceState({isPenMode:!0}),n.button===yP?(this._restoreToolId=this.getCurrentToolId(),this.complete(),this.setCurrentTool("eraser")):n.button===jd&&(this.inputs.isPanning||(this._prevCursor=this.getInstanceState().cursor.type),this.inputs.isPanning=!0,clearTimeout(this._longPressTimeout)),this.inputs.isPanning)return this.stopCameraAnimation(),this.setCursor({type:"grabbing",rotation:0}),this;break}case"pointer_move":{if(!u&&h)return;const{x:p,y:f,z:S}=Id(()=>this.getCamera());if(this.inputs.isPanning&&this.inputs.isPointing){const{currentScreenPoint:y,previousScreenPoint:x}=this.inputs,{panSpeed:m}=c,v=b.Sub(y,x);this.setCamera(new b(p+v.x*m/S,f+v.y*m/S,S),{immediate:!0}),this.maybeTrackPerformance("Panning");return}r.isPointing&&!r.isDragging&&b.Dist2(s,i)*this.getZoomLevel()>(a.isCoarsePointer?this.options.coarseDragDistanceSquared:this.options.dragDistanceSquared)/S&&(r.isDragging=!0,clearTimeout(this._longPressTimeout));break}case"pointer_up":{if(r.isDragging=!1,r.isPointing=!1,clearTimeout(this._longPressTimeout),r.buttons.delete(n.button),this.getIsMenuOpen()||a.isPenMode&&!u)return;if(this.capturedPointerId===n.pointerId&&(this.capturedPointerId=null,n.button=0),r.isPanning){r.keys.has("Space")||(r.isPanning=!1);const p=this.inputs.pointerVelocity,f=Math.min(2,p.len());switch(n.button){case mP:{this.setCursor({type:"grab",rotation:0});break}case jd:this.inputs.keys.has(" ")?this.setCursor({type:"grab",rotation:0}):this.setCursor({type:this._prevCursor,rotation:0})}f>0&&this.slideCamera({speed:f,direction:p})}else n.button===yP&&(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.code==="Space"&&!n.ctrlKey&&(this.inputs.isPanning||(this._prevCursor=a.cursor.type),this.inputs.isPanning=!0,clearTimeout(this._longPressTimeout),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(jd)||(this.inputs.isPanning=!1,this.setCursor({type:this._prevCursor,rotation:0})));break}}break}}if(n.type==="pointer"){n.button===jd?n.name="middle_click":n.button===s0&&(n.name="right_click");const{isPenMode:u}=this.store.unsafeGetWithoutCapture(Sn);if(n.isPen===u){const h=this._clickManager.handlePointerEvent(n);if(n.name!==h.name){this.root.handleEvent(n),this.emit("event",n),this.root.handleEvent(h),this.emit("event",h);return}}}return this.root.handleEvent(n),this.emit("event",n),this});this.options={...aG,...p},this.store=n,this.disposables.add(this.store.dispose.bind(this.store)),this.history=new MG({store:n,annotateError:T=>{this.annotateError(T,{origin:"history.batch",willCrashApp:!0}),this.crash(T)}}),this.snaps=new fg(this),this.timers=new LB,this.disposables.add(this.timers.dispose.bind(this.timers)),this._cameraOptions.set({...fP,...l}),this.user=new fr(r??L2(),h??!1),this.getContainer=a??(()=>document.body),this.textMeasure=new VG(this),this._tickManager=new YG(this);class f extends Wh{}g(f,"initial",c??""),this.root=new f(this),this.root.children={};const S=YM(o),y={},x={},m=new Map;for(const T of S){const M=new T(this);y[T.type]=M;const D=f_(T.props??{});x[T.type]=D;for(const $ of D.keys())if(!m.has($.id))m.set($.id,$);else if(m.get($.id)!==$)throw Error(`Multiple style props with id "${$.id}" in use. Style prop IDs must be unique.`)}this.shapeUtils=y,this.styleProps=x;const v=WM(s),w={};for(const T of v){const M=new T(this);w[T.type]=M}this.bindingUtils=w;for(const T of[...i]){if(yo(this.root.children,T.id))throw Error(`Can't override tool with id "${T.id}"`);this.root.children[T.id]=new T(this,this.root)}this.environment=new EG(this),this.scribbles=new OG(this);const C=(T,M)=>{let D=null;const $=T.selectedShapeIds.filter(R=>!M.has(R));$.length!==T.selectedShapeIds.length&&(D||(D={...T}),D.selectedShapeIds=$);const j=T.erasingShapeIds.filter(R=>!M.has(R));j.length!==T.erasingShapeIds.length&&(D||(D={...T}),D.erasingShapeIds=j),T.hoveredShapeId&&M.has(T.hoveredShapeId)&&(D||(D={...T}),D.hoveredShapeId=null),T.editingShapeId&&M.has(T.editingShapeId)&&(D||(D={...T}),D.editingShapeId=null);const O=T.hintingShapeIds.filter(R=>!M.has(R));return O.length!==T.hintingShapeIds.length&&(D||(D={...T}),D.hintingShapeIds=O),T.focusedGroupId&&M.has(T.focusedGroupId)&&(D||(D={...T}),D.focusedGroupId=null),D};this.sideEffects=this.store.sideEffects;let E=new Map;const _=new Set,I=new Set;let k=new Set;if(this.disposables.add(this.sideEffects.registerOperationCompleteHandler(()=>{var T,M,D,$;_.clear();for(const j of I){I.delete(j);const O=this.getShape(j);if(!O)continue;const R=this.getShapeUtil(O),H=(T=R.onChildrenChange)==null?void 0:T.call(R,O);H!=null&&H.length&&this.updateShapes(H)}if(k.size){const j=k;k=new Set;for(const O of j){const R=this.getBindingUtil(O);(M=R.onOperationComplete)==null||M.call(R)}}if(E.size){const j=E;E=new Map;for(const O of j.values())($=(D=this.getBindingUtil(O.binding)).onAfterDelete)==null||$.call(D,O)}this.emit("update")})),this.disposables.add(this.sideEffects.register({shape:{afterChange:(T,M)=>{var D,$,j,O;for(const R of this.getBindingsInvolvingShape(M))k.add(R.type),R.fromId===M.id&&(($=(D=this.getBindingUtil(R)).onAfterChangeFromShape)==null||$.call(D,{binding:R,shapeBefore:T,shapeAfter:M})),R.toId===M.id&&((O=(j=this.getBindingUtil(R)).onAfterChangeToShape)==null||O.call(j,{binding:R,shapeBefore:T,shapeAfter:M}));if(T.parentId!==M.parentId){const R=H=>{var z,W,Y,q;const B=this.getShape(H);if(B)for(const le of this.getBindingsInvolvingShape(B))k.add(le.type),le.fromId===B.id&&((W=(z=this.getBindingUtil(le)).onAfterChangeFromShape)==null||W.call(z,{binding:le,shapeBefore:B,shapeAfter:B})),le.toId===B.id&&((q=(Y=this.getBindingUtil(le)).onAfterChangeToShape)==null||q.call(Y,{binding:le,shapeBefore:B,shapeAfter:B}))};R(M.id),this.visitDescendants(M.id,R)}if(T.parentId!==M.parentId&&An(M.parentId)){const R=new Set([T.id]);this.visitDescendants(T.id,H=>{R.add(H)});for(const H of this.getPageStates()){if(H.pageId===M.parentId)continue;const B=C(H,R);B&&this.store.put([B])}}T.parentId&&On(T.parentId)&&I.add(T.parentId),M.parentId!==T.parentId&&On(M.parentId)&&I.add(M.parentId)},beforeDelete:T=>{var j,O,R,H;if(_.has(T.id))return;T.parentId&&On(T.parentId)&&I.add(T.parentId),_.add(T.id);const M=[];for(const B of this.getBindingsInvolvingShape(T)){k.add(B.type),M.push(B.id);const z=this.getBindingUtil(B);B.fromId===T.id?((j=z.onBeforeIsolateToShape)==null||j.call(z,{binding:B,removedShape:T}),(O=z.onBeforeDeleteFromShape)==null||O.call(z,{binding:B,shape:T})):((R=z.onBeforeIsolateFromShape)==null||R.call(z,{binding:B,removedShape:T}),(H=z.onBeforeDeleteToShape)==null||H.call(z,{binding:B,shape:T}))}M.length&&this.deleteBindings(M);const D=new Set([T.id]),$=ye(this.getPageStates().map(B=>C(B,D)));$.length&&this.store.put($)}},binding:{beforeCreate:T=>{var D,$;const M=($=(D=this.getBindingUtil(T)).onBeforeCreate)==null?void 0:$.call(D,{binding:T});return M||T},afterCreate:T=>{var M,D;k.add(T.type),(D=(M=this.getBindingUtil(T)).onAfterCreate)==null||D.call(M,{binding:T})},beforeChange:(T,M)=>{var $,j;const D=(j=($=this.getBindingUtil(M)).onBeforeChange)==null?void 0:j.call($,{bindingBefore:T,bindingAfter:M});return D||M},afterChange:(T,M)=>{var D,$;k.add(M.type),($=(D=this.getBindingUtil(M)).onAfterChange)==null||$.call(D,{bindingBefore:T,bindingAfter:M})},beforeDelete:T=>{var M,D;(D=(M=this.getBindingUtil(T)).onBeforeDelete)==null||D.call(M,{binding:T})},afterDelete:T=>{var M,D;(D=(M=this.getBindingUtil(T)).onAfterDelete)==null||D.call(M,{binding:T}),k.add(T.type)}},page:{afterCreate:T=>{const M=po.createId(T.id),D=Br.createId(T.id);this.store.has(M)||this.store.put([po.create({id:M})]),this.store.has(D)||this.store.put([Br.create({id:D,pageId:T.id})])},afterDelete:(T,M)=>{var j,O;if(((j=this.getInstanceState())==null?void 0:j.currentPageId)===T.id){const R=(O=this.getPages().find(H=>H.id!==T.id))==null?void 0:O.id;R?this.store.put([{...this.getInstanceState(),currentPageId:R}]):M==="user"&&this.store.ensureStoreIsUsable()}const D=po.createId(T.id),$=Br.createId(T.id);this.store.remove([D,$])}},instance:{afterChange:(T,M,D)=>{var $;if(!this.store.has(M.currentPageId)){const j=this.store.has(T.currentPageId)?T.currentPageId:($=this.getPages()[0])==null?void 0:$.id;j?this.store.update(M.id,O=>({...O,currentPageId:j})):D==="user"&&this.store.ensureStoreIsUsable()}}},instance_page_state:{afterChange:(T,M)=>{if((T==null?void 0:T.selectedShapeIds)!==(M==null?void 0:M.selectedShapeIds)){const D=M.selectedShapeIds.filter(j=>{var R,H;let O=(R=this.getShape(j))==null?void 0:R.parentId;for(;On(O);){if(M.selectedShapeIds.includes(O))return!1;O=(H=this.getShape(O))==null?void 0:H.parentId}return!0});let $=null;if(D.length>0){const j=this.findCommonAncestor(ye(D.map(O=>this.getShape(O))),O=>this.isShapeOfType(O,"group"));j&&($=j)}else M!=null&&M.focusedGroupId&&($=M.focusedGroupId);(D.length!==M.selectedShapeIds.length||$!==M.focusedGroupId)&&this.store.put([{...M,selectedShapeIds:D,focusedGroupId:$??null}])}}}})),this._currentPageShapeIds=xG(this.store,()=>this.getCurrentPageId()),this._parentIdsToChildIds=vG(this.store),this.disposables.add(this.store.listen(T=>{this.emit("change",T)})),this.disposables.add(this.history.dispose),this.run(()=>{this.store.ensureStoreIsUsable(),this._updateCurrentPageState({editingShapeId:null,hoveredShapeId:null,erasingShapeIds:[]})},{history:"ignore"}),c&&this.root.children[c]===void 0)throw Error(`No state found for initialState "${c}".`);this.root.enter(void 0,"initial"),this.edgeScrollManager=new IG(this),this.focusManager=new kG(this,u),this.disposables.add(this.focusManager.dispose.bind(this.focusManager)),this.getInstanceState().followingUserId&&this.stopFollowingUser(),this.on("tick",this._flushEventsForTick),this.timers.requestAnimationFrame(()=>{this._tickManager.start()}),this.performanceTracker=new Uk}dispose(){this.disposables.forEach(n=>n()),this.disposables.clear(),this.isDisposed=!0}getShapeUtil(n){const r=typeof n=="string"?n:n.type,o=Nn(this.shapeUtils,r);return Xe(o,`No shape util found for type "${r}"`),o}getBindingUtil(n){const r=typeof n=="string"?n:n.type,o=Nn(this.bindingUtils,r);return Xe(o,`No binding util found for type "${r}"`),o}undo(){return this._flushEventsForTick(0),this.complete(),this.history.undo(),this}getCanUndo(){return this.history.getNumUndos()>0}redo(){return this._flushEventsForTick(0),this.complete(),this.history.redo(),this}clearHistory(){return this.history.clear(),this}getCanRedo(){return this.history.getNumRedos()>0}mark(n){return this.history.mark(n),this}squashToMark(n){return this.history.squashToMark(n),this}bail(){return this.history.bail(),this}bailToMark(n){return this.history.bailToMark(n),this}run(n,r){const o=this._shouldIgnoreShapeLock;this._shouldIgnoreShapeLock=(r==null?void 0:r.ignoreShapeLock)??o;try{this.history.batch(n,r)}finally{this._shouldIgnoreShapeLock=o}return this}batch(n,r){return this.run(n,r)}annotateError(n,{origin:r,willCrashApp:o,tags:s,extras:i}){const a=this.createErrorAnnotations(r,o);return Ux(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(kS)}updateDocumentSettings(n){return this.run(()=>{this.store.put([{...this.getDocumentSettings(),...n}])},{history:"ignore"}),this}getInstanceState(){return this.store.get(Sn)}updateInstanceState(n,r){return this._updateInstanceState(n,{history:"ignore",...r}),n.isChangingStyle!==void 0&&(clearTimeout(this._isChangingStyleTimeout),n.isChangingStyle===!0&&(this._isChangingStyleTimeout=this.timers.setTimeout(()=>{this._updateInstanceState({isChangingStyle:!1},{history:"ignore"})},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 Br.createId(this.getCurrentPageId())}updateCurrentPageState(n){return this._updateCurrentPageState(n),this}getSelectedShapeIds(){return this.getCurrentPageState().selectedShapeIds}getSelectedShapes(){const{selectedShapeIds:n}=this.getCurrentPageState();return ye(n.map(r=>this.store.get(r)))}setSelectedShapes(n){return this.run(()=>{const r=n.map(i=>typeof i=="string"?i:i.id),{selectedShapeIds:o}=this.getCurrentPageState(),s=new Set(o);if(r.length===s.size&&r.every(i=>s.has(i)))return null;this.store.put([{...this.getCurrentPageState(),selectedShapeIds:r}])},{history:"record-preserveRedoStack"})}isAncestorSelected(n){const r=typeof n=="string"?n:(n==null?void 0:n.id)??null,o=this.getShape(r);if(!o)return!1;const s=this.getSelectedShapeIds();return!!this.findShapeAncestor(o,i=>s.includes(i.id))}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:Q.Common(ye(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=Q.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 Q(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.run(()=>{this.store.update(this.getCurrentPageState().id,o=>({...o,focusedGroupId:r}))},{history:"record-preserveRedoStack"})}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.run(()=>{this._updateCurrentPageState({editingShapeId:r})},{history:"ignore"}),this}this.run(()=>{this._updateCurrentPageState({editingShapeId:null})},{history:"ignore"})}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.run(()=>{this.updateCurrentPageState({hoveredShapeId:r})},{history:"ignore"}),this)}getHintingShapeIds(){return this.getCurrentPageState().hintingShapeIds}getHintingShape(){const n=this.getHintingShapeIds();return ye(n.map(r=>this.getShape(r)))}setHintingShapes(n){const r=typeof n[0]=="string"?n:n.map(o=>o.id);return this.run(()=>{this._updateCurrentPageState({hintingShapeIds:Bx(r)})},{history:"ignore"}),this}getErasingShapeIds(){return this.getCurrentPageState().erasingShapeIds}getErasingShapes(){const n=this.getErasingShapeIds();return ye(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();return this.run(()=>{if(r.length===o.length){for(let s=0;s<r.length;s++)if(r[s]!==o[s]){this._updateCurrentPageState({erasingShapeIds:r});break}}else this._updateCurrentPageState({erasingShapeIds:r})},{history:"ignore"}),this}getCroppingShapeId(){return this.getCurrentPageState().croppingShapeId}setCroppingShape(n){const r=typeof n=="string"?n:(n==null?void 0:n.id)??null;return r!==this.getCroppingShapeId()&&this.run(()=>{if(!r)this.updateCurrentPageState({croppingShapeId:null});else{const o=this.getShape(r),s=this.getShapeUtil(o);o&&s.canCrop(o)&&this.updateCurrentPageState({croppingShapeId:r})}},{history:"ignore"}),this}_unsafe_getCameraId(){return po.createId(this.getCurrentPageId())}getCamera(){const n=this.store.get(this._unsafe_getCameraId());if(this._isLockedOnFollowingUser.get()){const r=this.getCameraForFollowing();if(r)return{...n,...r}}return n}getViewportPageBoundsForFollowing(){const n=this.getInstanceState().followingUserId;if(!n)return null;const r=this.getCollaborators().find(p=>p.userId===n);if(!r)return null;const{w:o,h:s}=r.screenBounds,{x:i,y:a,z:l}=r.camera,c=new Q(-i,-a,o/l,s/l),u=this.getViewportScreenBounds().clone(),h=u.width/u.height;return u.width=c.width,u.height=u.width/h,u.height<c.height&&(u.height=c.height,u.width=u.height*h),u.center=c.center,u}getCameraForFollowing(){const n=this.getViewportPageBoundsForFollowing();return n?{x:-n.x,y:-n.y,z:this.getViewportScreenBounds().w/n.width}:null}getZoomLevel(){return this.getCamera().z}getInitialZoom(){const n=this.getCameraOptions();if(!n.constraints||n.constraints.initialZoom==="default")return 1;const{zx:r,zy:o}=YC(this,n);switch(n.constraints.initialZoom){case"fit-min":return Math.max(r,o);case"fit-max":return Math.min(r,o);case"fit-x":return r;case"fit-y":return o;case"fit-min-100":return Math.min(1,Math.max(r,o));case"fit-max-100":return Math.min(1,Math.min(r,o));case"fit-x-100":return Math.min(1,r);case"fit-y-100":return Math.min(1,o);default:throw un(n.constraints.initialZoom)}}getBaseZoom(){const n=this.getCameraOptions();if(!n.constraints||n.constraints.baseZoom==="default")return 1;const{zx:r,zy:o}=YC(this,n);switch(n.constraints.baseZoom){case"fit-min":return Math.max(r,o);case"fit-max":return Math.min(r,o);case"fit-x":return r;case"fit-y":return o;case"fit-min-100":return Math.min(1,Math.max(r,o));case"fit-max-100":return Math.min(1,Math.min(r,o));case"fit-x-100":return Math.min(1,r);case"fit-y-100":return Math.min(1,o);default:throw un(n.constraints.baseZoom)}}getCameraOptions(){return this._cameraOptions.get()}setCameraOptions(n){var o;const r=Ge({...this._cameraOptions.__unsafe__getWithoutCapture(),...n});return((o=r.zoomSteps)==null?void 0:o.length)<1&&(r.zoomSteps=[1]),this._cameraOptions.set(r),this}getConstrainedCamera(n,r){const o=this.getCamera();let{x:s,y:i,z:a=o.z}=n;if(!(r!=null&&r.force)){const l=this.getCameraOptions(),c=l.zoomSteps[0],u=Ut(l.zoomSteps),h=this.getViewportScreenBounds();if(l.constraints){const{constraints:p}=l,f=Math.min(p.padding.y,h.w/2),S=Math.min(p.padding.x,h.h/2),y=Q.From(l.constraints.bounds),x=(h.w-S*2)/y.w,m=(h.h-f*2)/y.h,v=this.getBaseZoom(),w=u*v,C=c*v;if(r!=null&&r.reset&&(a=this.getInitialZoom()),a<C||a>w){const{x:j,y:O,z:R}=o,H=-j+h.w/R/2,B=-O+h.h/R/2;a=_t(a,C,w);const z=-j+h.w/a/2,W=-O+h.h/a/2;s=j+z-H,i=O+W-B}const E=S/a-y.x,_=f/a-y.y,I=(h.w-S*2)/a-y.w,k=(h.h-f*2)/a-y.h,T=E+I*p.origin.x,M=_+k*p.origin.y,D=typeof p.behavior=="string"?p.behavior:p.behavior.x,$=typeof p.behavior=="string"?p.behavior:p.behavior.y;if(r!=null&&r.reset)s=T,i=M;else{switch(D){case"fixed":{s=T;break}case"contain":{a<x?s=T:s=_t(s,E+I,E);break}case"inside":{a<x?s=_t(s,E,(h.w-S)/a-y.w):s=_t(s,E+I,E);break}case"outside":{s=_t(s,S/a-y.w,(h.w-S)/a);break}case"free":break;default:throw un(D)}switch($){case"fixed":{i=M;break}case"contain":{a<m?i=M:i=_t(i,_+k,_);break}case"inside":{a<m?i=_t(i,_,(h.h-f)/a-y.h):i=_t(i,_+k,_);break}case"outside":{i=_t(i,f/a-y.h,(h.h-f)/a);break}case"free":break;default:throw un($)}}}else if(a>u||a<c){const{x:p,y:f,z:S}=o;a=_t(a,c,u),s=p+(-p+h.w/a/2)-(-p+h.w/S/2),i=f+(-f+h.h/a/2)-(-f+h.h/S/2)}}return{x:s,y:i,z:a}}_setCamera(n,r){const o=this.getCamera(),{x:s,y:i,z:a}=this.getConstrainedCamera(n,r);return o.x===s&&o.y===i&&o.z===a?this:(mo(()=>{const l={...o,x:s,y:i,z:a};this.run(()=>{this.store.put([l])},{history:"ignore"});const{currentScreenPoint:c,currentPagePoint:u}=this.inputs,{screenBounds:h}=this.store.unsafeGetWithoutCapture(Sn);if(c.x/a-s!==u.x||c.y/a-i!==u.y){const p={type:"pointer",target:"canvas",name:"pointer_move",point:b.AddXY(c,h.x,h.y),pointerId:gP.CAMERA_MOVE,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,shiftKey:this.inputs.shiftKey,button:0,isPen:this.getInstanceState().isPenMode??!1};r!=null&&r.immediate?this._flushEventForTick(p):this.dispatch(p)}this._tickCameraState()}),this)}setCamera(n,r){const{isLocked:o}=this._cameraOptions.__unsafe__getWithoutCapture();if(o&&!(r!=null&&r.force))return this;this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser();const s=b.Cast(n);Number.isFinite(s.x)||(s.x=0),Number.isFinite(s.y)||(s.y=0),(s.z===void 0||!Number.isFinite(s.z))&&(n.z=this.getZoomLevel());const i=this.getConstrainedCamera(s,r);if(r!=null&&r.animation){const{width:a,height:l}=this.getViewportScreenBounds();this._animateToViewport(new Q(-i.x,-i.y,a/i.z,l/i.z),r)}else this._setCamera(i,{...r,force:!0});return this}centerOnPoint(n,r){const{isLocked:o}=this.getCameraOptions();if(o&&!(r!=null&&r.force))return this;const{width:s,height:i}=this.getViewportPageBounds();return this.setCamera(new b(-(n.x-s/2),-(n.y-i/2),this.getCamera().z),r),this}zoomToFit(n){const r=[...this.getCurrentPageShapeIds()];if(r.length<=0)return this;const o=Q.Common(ye(r.map(s=>this.getShapePageBounds(s))));return this.zoomToBounds(o,n),this}resetZoom(n=this.getViewportScreenCenter(),r){const{isLocked:o,constraints:s}=this.getCameraOptions();if(o&&!(r!=null&&r.force))return this;const i=this.getCamera(),{x:a,y:l,z:c}=i,{x:u,y:h}=n;let p=1;if(s){const f=this.getInitialZoom();c!==f&&(p=f)}return this.setCamera(new b(a+(u/p-u)-(u/c-u),l+(h/p-h)-(h/c-h),p),r),this}zoomIn(n=this.getViewportScreenCenter(),r){const{isLocked:o}=this.getCameraOptions();if(o&&!(r!=null&&r.force))return this;const{x:s,y:i,z:a}=this.getCamera(),{zoomSteps:l}=this.getCameraOptions();if(l!==null&&l.length>1){const c=this.getBaseZoom();let u=Ut(l)*c;for(let h=1;h<l.length;h++){const p=l[h-1]*c,f=l[h]*c;if(!(f-a<=(f-p)/2)){u=f;break}}this.setCamera(new b(s+(n.x/u-n.x)-(n.x/a-n.x),i+(n.y/u-n.y)-(n.y/a-n.y),u),r)}return this}zoomOut(n=this.getViewportScreenCenter(),r){const{isLocked:o}=this.getCameraOptions();if(o&&!(r!=null&&r.force))return this;const{zoomSteps:s}=this.getCameraOptions();if(s!==null&&s.length>1){const i=this.getBaseZoom(),{x:a,y:l,z:c}=this.getCamera();let u=s[0]*i;for(let h=s.length-1;h>0;h--){const p=s[h-1]*i,f=s[h]*i;if(!(f-c>=(f-p)/2)){u=p;break}}this.setCamera(new b(a+(n.x/u-n.x)-(n.x/c-n.x),l+(n.y/u-n.y)-(n.y/c-n.y),u),r)}return this}zoomToSelection(n){const{isLocked:r}=this.getCameraOptions();if(r&&!(n!=null&&n.force))return this;const o=this.getSelectionPageBounds();return o&&this.zoomToBounds(o,{targetZoom:Math.max(1,this.getZoomLevel()),...n}),this}zoomToBounds(n,r){const o=this._cameraOptions.__unsafe__getWithoutCapture();if(o.isLocked&&!(r!=null&&r.force))return this;const s=this.getViewportScreenBounds(),i=(r==null?void 0:r.inset)??Math.min(E9,s.width*.28),a=this.getBaseZoom(),l=o.zoomSteps[0],c=Ut(o.zoomSteps);let u=_t(Math.min((s.width-i)/n.w,(s.height-i)/n.h),l*a,c*a);return(r==null?void 0:r.targetZoom)!==void 0&&(u=Math.min(r.targetZoom,u)),this.setCamera(new b(-n.x+(s.width-n.w*u)/2/u,-n.y+(s.height-n.h*u)/2/u,u),r),this}stopCameraAnimation(){return this.emit("stop-camera-animation"),this}_animateViewport(n){if(!this._viewportAnimation)return;this._viewportAnimation.elapsed+=n;const{elapsed:r,easing:o,duration:s,start:i,end:a}=this._viewportAnimation;if(r>s){this.off("tick",this._animateViewport),this._viewportAnimation=null,this._setCamera(new b(-a.x,-a.y,this.getViewportScreenBounds().width/a.width));return}const l=s-r,c=o(1-l/s),u=i.minX+(a.minX-i.minX)*c,h=i.minY+(a.minY-i.minY)*c,p=i.maxX+(a.maxX-i.maxX)*c;this._setCamera(new b(-u,-h,this.getViewportScreenBounds().width/(p-u)),{force:!0})}_animateToViewport(n,r={animation:Tm}){const{animation:o,...s}=r;if(!o)return;const{duration:i=0,easing:a=At.easeInOutCubic}=o,l=this.user.getAnimationSpeed(),c=this.getViewportPageBounds();return this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),i===0||l===0?this._setCamera(new b(-n.x,-n.y,this.getViewportScreenBounds().width/n.width),{...s}):(this._viewportAnimation={elapsed:0,duration:i/l,easing:a,start:c.clone(),end:n.clone()},this.once("stop-camera-animation",()=>{this.off("tick",this._animateViewport),this._viewportAnimation=null}),this.on("tick",this._animateViewport),this)}slideCamera(n={}){const{isLocked:r}=this.getCameraOptions();if(r&&!(n!=null&&n.force))return this;if(this.user.getAnimationSpeed()===0)return this;this.stopCameraAnimation();const{speed:s,friction:i=this.options.cameraSlideFriction,direction:a,speedThreshold:l=.01}=n;let c=Math.min(s,1);const u=()=>{this.off("tick",h),this.off("stop-camera-animation",u)};this.once("stop-camera-animation",u);const h=p=>{const{x:f,y:S,z:y}=this.getCamera(),x=b.Mul(a,c*p/y);c*=1-i,c<l?u():this._setCamera(new b(f+x.x,S+x.y,y))};return this.on("tick",h),this}zoomToUser(n,r={animation:{duration:500}}){const o=this.getCollaborators().find(s=>s.userId===n);return o?(this.run(()=>{this.getInstanceState().followingUserId!==null&&this.stopFollowingUser();const s=o.currentPageId===this.getCurrentPageId();s||this.setCurrentPage(o.currentPageId),r&&r.animation&&!s&&(r.animation=void 0),this.centerOnPoint(o.cursor,r);const{highlightedUserIds:i}=this.getInstanceState();this.updateInstanceState({highlightedUserIds:[...i,n]}),this.timers.setTimeout(()=>{const a=[...this.getInstanceState().highlightedUserIds],l=a.indexOf(n);l<0||(a.splice(l,1),this.updateInstanceState({highlightedUserIds:a}))},this.options.collaboratorIdleTimeoutMs)}),this):this}updateViewportScreenBounds(n,r=!1){n.width=Math.max(n.width,1),n.height=Math.max(n.height,1);const o=[n.minY!==0,!$s(document.body.scrollWidth,n.maxX,1),!$s(document.body.scrollHeight,n.maxY,1),n.minX!==0],{screenBounds:s,insets:i}=this.getInstanceState();if(n.equals(s)&&o.every((l,c)=>l===i[c]))return this;const{_willSetInitialBounds:a}=this;if(this._willSetInitialBounds=!1,a)this.updateInstanceState({screenBounds:n.toJson(),insets:o}),this.setCamera(this.getCamera());else if(r&&!this.getInstanceState().followingUserId){const l=this.getViewportPageBounds().center;this.updateInstanceState({screenBounds:n.toJson(),insets:o}),this.centerOnPoint(l)}else this.updateInstanceState({screenBounds:n.toJson(),insets:o}),this._setCamera(b.From({...this.getCamera()}));return this._tickCameraState(),this}getViewportScreenBounds(){const{x:n,y:r,w:o,h:s}=this.getInstanceState().screenBounds;return new Q(n,r,o,s)}getViewportScreenCenter(){const n=this.getViewportScreenBounds();return new b(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 Q(-o,-s,n/i,r/i)}screenToPage(n){const{screenBounds:r}=this.store.unsafeGetWithoutCapture(Sn),{x:o,y:s,z:i=1}=this.getCamera();return new b((n.x-r.x)/i-o,(n.y-r.y)/i-s,n.z??.5)}pageToScreen(n){const{screenBounds:r}=this.store.unsafeGetWithoutCapture(Sn),{x:o,y:s,z:i=1}=this.getCamera();return new b((n.x+o)*i+r.x,(n.y+s)*i+r.y,n.z??.5)}pageToViewport(n){const{x:r,y:o,z:s=1}=this.getCamera();return new b((n.x+r)*s,(n.y+o)*s,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]):Vo}getCollaboratorsOnCurrentPage(){const n=this.getCurrentPageId();return this.getCollaborators().filter(r=>r.currentPageId===n)}startFollowingUser(n){this.stopFollowingUser();const r=this._getCollaboratorsQuery().get().filter(i=>i.userId===n);if(!r.length)return console.warn("User not found"),this;const o=this.user.getId();if(o||console.warn("You should set the userId for the current instance before following a user"),r.some(i=>i.followingUserId===o))return this;const s=G("latestLeaderPresence",()=>this.getCollaborators().find(i=>i.userId===n));return mo(()=>{this.updateInstanceState({followingUserId:n},{history:"ignore"});const i=ra("update current page",()=>{const c=s.get();if(!c){this.stopFollowingUser();return}c.currentPageId!==this.getCurrentPageId()&&this.getPage(c.currentPageId)&&this.run(()=>{this.store.put([{...this.getInstanceState(),currentPageId:c.currentPageId}]),this._isLockedOnFollowingUser.set(!0)},{history:"ignore"})}),a=()=>{i(),this._isLockedOnFollowingUser.set(!1),this.off("frame",l),this.off("stop-following",a)},l=()=>{if(!s.get()){this.stopFollowingUser();return}if(this._isLockedOnFollowingUser.get())return;const u=this.user.getAnimationSpeed();if(u===0){this._isLockedOnFollowingUser.set(!0);return}const h=this.getViewportPageBoundsForFollowing();if(!h){this.stopFollowingUser();return}const p=this.getViewportPageBounds(),f=Math.abs(h.minX-p.minX)+Math.abs(h.maxX-p.maxX),S=Math.abs(h.minY-p.minY)+Math.abs(h.maxY-p.maxY);if(f<this.options.followChaseViewportSnap&&S<this.options.followChaseViewportSnap){this._isLockedOnFollowingUser.set(!0);return}const y=_t(u*.5,.1,.8),x=new Q(Dn(p.minX,h.minX,y),Dn(p.minY,h.minY,y),Dn(p.width,h.width,y),Dn(p.height,h.height,y)),m=new b(-x.x,-x.y,this.getViewportScreenBounds().width/x.width);this.stopCameraAnimation(),this._setCamera(m)};this.once("stop-following",a),this.addListener("frame",l),l()}),this}stopFollowingUser(){return this.run(()=>{this.store.put([this.getCamera()]),this._isLockedOnFollowingUser.set(!1),this.updateInstanceState({followingUserId:null}),this.emit("stop-following")},{history:"ignore"}),this}getUnorderedRenderingShapes(n){const r=[];let o=this.options.maxShapesPerPage*2,s=this.options.maxShapesPerPage;const i=this.getErasingShapeIds(),a=(c,u,h)=>{const p=this.getShape(c);if(!p)return;u*=p.opacity;let f=!1;const S=this.getShapeUtil(p);n&&(f=!h&&i.includes(c),f&&(u*=.32)),r.push({id:c,shape:p,util:S,index:o,backgroundIndex:s,opacity:u}),o+=1,s+=1;const y=this.getSortedChildIdsForParent(c);if(!y.length)return;let x=null;S.providesBackgroundForChildren(p)&&(x=s,s=o,o+=this.options.maxShapesPerPage);for(const m of y)a(m,u,h||f);x!==null&&(s=x)},l=n?[this.getCurrentPage()]:this.getPages();for(const c of l)for(const u of this.getSortedChildIdsForParent(c.id))a(u,1,!1);return r}getCameraState(){return this._cameraState.get()}getRenderingShapes(){return this.getUnorderedRenderingShapes(!0).sort(MB)}_getAllPagesQuery(){return this.store.query.records("page")}getPages(){return this._getAllPagesQuery().get().sort(ln)}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){const r=typeof n=="string"?n:n.id;return this.store.has(r)?(this.stopFollowingUser(),this.complete(),this.run(()=>{this.store.put([{...this.getInstanceState(),currentPageId:r}])},{history:"record-preserveRedoStack"})):(console.error("Tried to set the current page id to a page that doesn't exist."),this)}updatePage(n){return this.getInstanceState().isReadonly?this:this.getPage(n.id)?this.run(()=>this.store.update(n.id,o=>({...o,...n}))):this}createPage(n){return this.run(()=>{if(this.getInstanceState().isReadonly||this.getPages().length>=this.options.maxPages)return;const r=this.getPages(),o=dG(n.name??"Page 1",r.map(a=>a.name));let s=n.index;(!s||r.some(a=>a.index===s))&&(s=zr(r[r.length-1].index));const i=Jo.create({meta:{},...n,name:o,index:s});this.store.put([i])}),this}deletePage(n){const r=typeof n=="string"?n:n.id;return this.run(()=>{if(this.getInstanceState().isReadonly)return;const o=this.getPages();if(o.length===1)return;const s=this.getPage(r);if(s){if(r===this.getCurrentPageId()){const i=o.findIndex(l=>l.id===r),a=o[i-1]??o[i+1];this.setCurrentPage(a.id)}this.store.remove([s.id])}}),this}duplicatePage(n,r=Jo.createId()){if(this.getPages().length>=this.options.maxPages)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.run(()=>{var u;const l=this.getPages(),c=ru(s.index,(u=l[l.indexOf(s)+1])==null?void 0:u.index);if(this.createPage({name:s.name+" Copy",id:r,index:c}),this.setCurrentPage(r),this.setCamera(i),a)return this.putContentOntoCurrentPage(a)}),this}renamePage(n,r){const o=typeof n=="string"?n:n.id;return this.getInstanceState().isReadonly?this:(this.updatePage({id:o,name:r}),this)}_getAllAssetsQuery(){return this.store.query.records("asset")}getAssets(){return this._getAllAssetsQuery().get()}createAssets(n){return this.getInstanceState().isReadonly?this:n.length<=0?this:(this.run(()=>this.store.put(n),{history:"ignore"}),this)}updateAssets(n){return this.getInstanceState().isReadonly?this:n.length<=0?this:(this.run(()=>{this.store.put(n.map(r=>({...this.store.get(r.id),...r})))},{history:"ignore"}),this)}deleteAssets(n){if(this.getInstanceState().isReadonly)return this;const r=typeof n[0]=="string"?n:n.map(o=>o.id);return r.length<=0?this:(this.run(()=>this.store.remove(r),{history:"ignore"}),this)}getAsset(n){return this.store.get(typeof n=="string"?n:n.id)}async resolveAssetUrl(n,r){if(!n)return null;const o=this.getAsset(n);if(!o)return null;const{screenScale:s=1,shouldResolveToOriginal:i=!1}=r,l=Math.max(.125,(h=>Math.pow(2,Math.ceil(Math.log2(h))))(s)),c="connection"in navigator?navigator.connection.effectiveType:null,u=this.getInstanceState().devicePixelRatio;return await this.store.props.assets.resolve(o,{screenScale:s||1,steppedScreenScale:l,dpr:u,networkEffectiveType:c,shouldResolveToOriginal:i})}async uploadAsset(n,r){return await this.store.props.assets.upload(n,r)}_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 se.Identity().translate(o.x,o.y).rotate(o.rotation)}_getShapePageTransformCache(){return this.store.createComputedCache("pageTransformCache",n=>{if(An(n.parentId))return this.getShapeLocalTransform(n);const r=this._getShapePageTransformCache().get(n.parentId)??se.Identity();return se.Compose(r,this.getShapeLocalTransform(n))})}getShapeParentTransform(n){const r=typeof n=="string"?n:n.id,o=this.getShape(r);return!o||An(o.parentId)?se.Identity():this._getShapePageTransformCache().get(o.parentId)??se.Identity()}getShapePageTransform(n){const r=typeof n=="string"?n:n.id;return this._getShapePageTransformCache().get(r)??se.Identity()}_getShapePageBoundsCache(){return this.store.createComputedCache("pageBoundsCache",n=>{const r=this._getShapePageTransformCache().get(n.id);return r?Q.FromPoints(se.applyToPoints(r,this.getShapeGeometry(n).vertices)):new Q})}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(${se.applyToPoints(se.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(An(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=BC(s,i);return a?a.map(b.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,l)=>a&&b.Equals(a,o[l])))return r.clone();const i=BC(o,s);return i?Q.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(An(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(An(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 c;if(n.length===0)return;const o=typeof n[0]=="string"?n:n.map(u=>u.id),s=ye(o.map(u=>this.getShape(u)));if(s.length===1){const u=s[0].parentId;return An(u)?void 0:r?(c=this.findShapeAncestor(s[0],r))==null?void 0:c.id:u}const[i,...a]=s;let l=this.getShapeParent(i);for(;l;){if(r&&!r(l)){l=this.getShapeParent(l);continue}if(a.every(u=>this.hasAncestor(u,l.id)))return l.id;l=this.getShapeParent(l)}}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 SG(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,hitLocked:l=!1,hitLabels:c=!1,hitInside:u=!1,hitFrameInside:h=!1}=r;let p=1/0,f=null,S=1/0,y=null;const x=(r.renderingOnly?this.getCurrentPageRenderingShapesSorted():this.getCurrentPageShapesSorted()).filter(m=>{if(m.isLocked&&!l||this.isShapeOfType(m,"group"))return!1;const v=this.getShapeMask(m);return v&&!sr(n,v)?!1:i?i(m):!0});for(let m=x.length-1;m>=0;m--){const v=x[m],w=this.getShapeGeometry(v),C=w instanceof Gr,E=this.getPointInShapeSpace(v,n);if((this.isShapeOfType(v,"arrow")||this.isShapeOfType(v,"geo")&&v.props.fill==="none")&&v.props.text.trim()){for(const I of w.children)if(I.isLabel&&I.isPointInBounds(E))return v}if(this.isShapeOfType(v,"frame")){const I=w.distanceToPoint(E,u);if(Math.abs(I)<=a)return y||v;if(w.hitTestPoint(E,0,!0))return y||f||(h?v:void 0);continue}let _;if(C){let I=1/0;for(const k of w.children){if(k.isLabel&&!c)continue;const T=k.distanceToPoint(E,u);T<I&&(I=T)}_=I}else a===0&&(w.bounds.w<1||w.bounds.h<1)||w.bounds.containsPoint(E,a)?_=w.distanceToPoint(E,u):_=1/0;if(w.isClosed){if(_<=a){if(w.isFilled||C&&w.children[0].isFilled)return y||v;if(this.getShapePageBounds(v).contains(s))continue;if(Math.abs(_)<a)Math.abs(_)<S&&(S=Math.abs(_),y=v);else if(!y){const{area:I}=w;I<p&&(p=I,f=v)}}}else if(_<this.options.hitTestMargin/o)return v}return y||f||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,l=this.getShapeMask(a);return l&&!sr(r,l)?!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 b(0,0);if(An(s.parentId))return b.From(r);const i=this.getShapePageTransform(s.parentId);return i?i.clone().invert().applyToPoint(r):b.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++)JM(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(On(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||!On(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 An(o.parentId)?o.parentId:this.getAncestorPageId(this.getShape(o.parentId))}reparentShapes(n,r,o){const s=typeof n[0]=="string"?n:n.map(f=>f.id);if(s.length===0)return this;const i=[],a=An(r)?se.Identity():this.getShapePageTransform(r),l=a.rotation();let c=[];const u=ye(this.getSortedChildIdsForParent(r).map(f=>this.getShape(f)));if(o){const f=u.find(S=>S.index===o);if(f){const S=u[u.indexOf(f)+1];S?c=al(o,S.index,s.length):c=Pm(o,s.length)}else{const S=u.sort(ln).find(y=>y.index>o);S?c=al(o,S.index,s.length):c=Pm(o,s.length)}}else{const f=u.length&&u[u.length-1];c=f?Pm(f.index,s.length):ou(s.length)}const h=a.clone().invert(),p=ye(s.map(f=>this.getShape(f)));return this.run(()=>{for(let f=0;f<p.length;f++){const S=p[f],y=this.getShapePageTransform(S);if(!y)continue;const x=y.point();if(!x)continue;const m=h.applyToPoint(x),v=y.rotation()-l;i.push({id:S.id,type:S.type,parentId:r,x:m.x,y:m.y,rotation:v,index:c[f]})}this.updateShapes(i)},{ignoreShapeLock:!0}),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 zr(s.index)}getSortedChildIdsForParent(n){const r=typeof n=="string"?n:n.id,o=this._parentIdsToChildIds.get()[r];return o||Vo}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;for(const o of n.map(s=>this.getShape(s)).sort(ln))r.add(o.id),this.visitDescendants(o,s=>{r.add(s)});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(l=>l.id===i.id||this.hasAncestor(i,l.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 l=this.getFocusedGroup();for(;a;){if(this.isShapeOfType(a,"group")&&(l==null?void 0:l.id)!==a.id&&!this.hasAncestor(l,a.id)&&((r==null?void 0:r(a))??!0))i=a;else if((l==null?void 0:l.id)===a.id)break;a=this.getShapeParent(a)}return i}_getBindingsIndexCache(){const n=mG(this);return this.store.createComputedCache("bindingsIndex",r=>n.get().get(r.id))}getBinding(n){return this.store.get(n)}getBindingsFromShape(n,r){const o=typeof n=="string"?n:n.id;return this.getBindingsInvolvingShape(o).filter(s=>s.fromId===o&&s.type===r)}getBindingsToShape(n,r){const o=typeof n=="string"?n:n.id;return this.getBindingsInvolvingShape(o).filter(s=>s.toId===o&&s.type===r)}getBindingsInvolvingShape(n,r){const o=typeof n=="string"?n:n.id,s=this._getBindingsIndexCache().get(o)??Vo;return r?s.filter(i=>i.type===r):s}createBindings(n){const r=[];for(const o of n){const s=this.getShape(o.fromId),i=this.getShape(o.toId);if(!s||!i||!this.canBindShapes({fromShape:s,toShape:i,binding:o}))continue;const l=this.getBindingUtil(o.type).getDefaultProps(),c=this.store.schema.types.binding.create({...o,id:o.id??ji(),props:{...l,...o.props}});r.push(c)}return this.store.put(r),this}createBinding(n){return this.createBindings([n])}updateBindings(n){const r=[];for(const o of n){if(!o)continue;const s=this.getBinding(o.id);if(!s)continue;const i=oo(s,o);if(i===s)continue;const a=this.getShape(i.fromId),l=this.getShape(i.toId);!a||!l||this.canBindShapes({fromShape:a,toShape:l,binding:i})&&r.push(i)}return this.store.put(r),this}updateBinding(n){return this.updateBindings([n])}deleteBindings(n,{isolateShapes:r=!1}={}){const o=n.map(s=>typeof s=="string"?s:s.id);return r?this.store.atomic(()=>{var s,i;for(const a of o){const l=this.getBinding(a);if(!l)continue;const c=this.getBindingUtil(l);(s=c.onBeforeIsolateFromShape)==null||s.call(c,{binding:l,removedShape:this.getShape(l.toId)}),(i=c.onBeforeIsolateToShape)==null||i.call(c,{binding:l,removedShape:this.getShape(l.fromId)}),this.store.remove([a])}}):this.store.remove(o),this}deleteBinding(n,r){return this.deleteBindings([n],r)}canBindShapes({fromShape:n,toShape:r,binding:o}){const s=typeof n=="string"?n:n.type,i=typeof r=="string"?r:r.type,a=typeof o=="string"?o:o.type,l={fromShapeType:s,toShapeType:i,bindingType:a};return s===i?this.getShapeUtil(s).canBind(l):this.getShapeUtil(s).canBind(l)&&this.getShapeUtil(i).canBind(l)}rotateShapesBy(n,r){if((typeof n[0]=="string"?n:n.map(i=>i.id)).length<=0)return this;const s=XM({editor:this});return s?(Kh({delta:r,snapshot:s,editor:this,stage:"one-off"}),this):this}getChangesToTranslateShape(n,r){var i,a,l;let o=n;const s=this.getShapeUtil(n);return o=oo(o,((i=s.onTranslateStart)==null?void 0:i.call(s,o))??void 0),o=oo(o,{id:n.id,type:n.type,x:r.x,y:r.y}),o=oo(o,((a=s.onTranslate)==null?void 0:a.call(s,n,o))??void 0),o=oo(o,((l=s.onTranslateEnd)==null?void 0:l.call(s,n,o))??void 0),o}nudgeShapes(n,r){const o=typeof n[0]=="string"?n:n.map(i=>i.id);if(o.length<=0)return this;const s=[];for(const i of o){const a=this.getShape(i),l=b.From(r),c=this.getShapeParentTransform(a);c&&l.rot(-c.rotation()),s.push(this.getChangesToTranslateShape(a,l.add(a)))}return this.updateShapes(s),this}duplicateShapes(n,r){return this.run(()=>{const o=typeof n[0]=="string"?n:n.map(p=>p.id);if(o.length<=0)return this;const s=new Set(o),i=this.getShapeAndDescendantIds(o),a=[...i].reverse(),l=new Map;for(const p of i)l.set(p,$e());const{shapesToCreate:c,bindingsToCreate:u}=VC(this,i,p=>{const f=[];for(const y of p){const x=this.getBinding(y);if(!x)continue;const m=ji();f.push({...x,id:m,fromId:xr(l.get(x.fromId)),toId:xr(l.get(x.toId))})}const S=[];for(const y of a){const x=xr(l.get(y)),m=this.getShape(y);if(!m)continue;let v=0,w=0;if(r&&s.has(y)){const M=this.getShapeParentTransform(m),D=new b(r.x,r.y).rot(-M.rotation());v=D.x,w=D.y}const C=m.parentId,E=this.getSortedChildIdsForParent(C),_=E.indexOf(m.id),I=E[_+1],k=I?this.getShape(I):null,T=k?ru(m.index,k.index):zr(m.index);S.push({...m,id:x,x:m.x+v,y:m.y+w,index:T,parentId:l.get(m.parentId)??m.parentId})}return{shapesToCreate:S,bindingsToCreate:f}});if(c.length+this.getCurrentPageShapeIds().size>this.options.maxShapesPerPage){Qd(this);return}if(this.createShapes(c),this.createBindings(u),this.setSelectedShapes(ye(o.map(p=>l.get(p)))),r!==void 0){const p=this.getSelectionPageBounds(),f=this.getViewportPageBounds();p&&!f.contains(p)&&this.centerOnPoint(p.center,{animation:{duration:this.options.animationMediumMs}})}}),this}moveShapesToPage(n,r){const o=typeof n[0]=="string"?n:n.map(l=>l.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>this.options.maxShapesPerPage)return Qd(this,r),this;const a=this.getCamera().z;return this.run(()=>{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 l=this.getShape(a);l&&(i.push(l),l.isLocked?s=!1:o=!1)}return this.run(()=>{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=Zd(this,"toBack",r);return o&&this.updateShapes(o),this}sendBackward(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=Zd(this,"backward",r);return o&&this.updateShapes(o),this}bringForward(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=Zd(this,"forward",r);return o&&this.updateShapes(o),this}bringToFront(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=Zd(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=ye(o.map(a=>this.getShape(a)));if(!s.length)return this;s=ye(s.map(a=>this.isShapeOfType(a,"group")?this.getSortedChildIdsForParent(a.id).map(l=>this.getShape(l)):a).flat());const i=Q.Common(ye(s.map(a=>this.getShapePageBounds(a)))).center;return this.run(()=>{for(const a of s){const l=this.getShapeGeometry(a).bounds,c=this.getShapePageTransform(a.id);c&&this.resizeShape(a.id,{x:r==="horizontal"?-1:1,y:r==="vertical"?-1:1},{initialBounds:l,initialPageTransform:c,initialShape:a,mode:"scale_shape",isAspectRatioLocked:this.getShapeUtil(a).isAspectRatioLocked(a),scaleOrigin:i,scaleAxisRotation:0})}}),this}stackShapes(n,r,o){const s=typeof n[0]=="string"?n:n.map(x=>x.id);if(this.getInstanceState().isReadonly)return this;const i=s.map(x=>this.getShape(x)).filter(x=>x?this.getShapeUtil(x).canBeLaidOut(x):!1),a=i.length;if(o===0&&a<3||a<2)return this;const l=Object.fromEntries(i.map(x=>[x.id,this.getShapePageBounds(x)]));let c,u,h,p;r==="horizontal"?(c="x",u="minX",h="maxX",p="width"):(c="y",u="minY",h="maxY",p="height");let f;if(o===0){const x=[];i.sort((v,w)=>l[v.id][u]-l[w.id][u]);for(let v=0;v<a-1;v++){const w=i[v],C=i[v+1],E=l[w.id],I=l[C.id][u]-E[h],k=x.find(T=>T.gap===I);k?k.count++:x.push({gap:I,count:1})}let m=0;x.forEach(v=>{v.count>m&&(m=v.count,f=v.gap)}),m===1&&(f=Math.max(0,x.reduce((v,w)=>v+w.gap*w.count,0)/(a-1)))}else f=o;const S=[];let y=l[i[0].id][h];return i.forEach((x,m)=>{var _,I;if(m===0)return;const v={x:0,y:0};v[c]=y+f-l[x.id][c];const w=this.getShapeParent(x),C=w?b.Rot(v,-this.getShapePageTransform(w).decompose().rotation):v,E=(I=(_=this.getShapeUtil(x)).onTranslateStart)==null?void 0:I.call(_,x);S.push(E?{...E,[c]:x[c]+C[c]}:{id:x.id,type:x.type,[c]:x[c]+C[c]}),y+=l[x.id][p]+f}),this.updateShapes(S),this}packShapes(n,r){var I,k;const o=typeof n[0]=="string"?n:n.map(T=>T.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=o.map(T=>this.getShape(T)).filter(T=>T?this.getShapeUtil(T).canBeLaidOut(T):!1),i={},a={};let l,c,u=0;for(let T=0;T<s.length;T++)l=s[T],c=this.getShapePageBounds(l),i[l.id]=c,a[l.id]=c.clone(),u+=c.width*c.height;const h=Q.Common(ye(Object.values(i))),p=h.width;s.sort((T,M)=>i[M.id].height-i[T.id].height);const f=Math.max(Math.ceil(Math.sqrt(u/.95)),p),S=[new Q(h.x,h.y,f,1/0)];let y=0,x=0,m,v;for(let T=0;T<s.length;T++){l=s[T],c=a[l.id];for(let M=S.length-1;M>=0;M--)if(m=S[M],!(c.width>m.width||c.height>m.height)){c.x=m.x,c.y=m.y,x=Math.max(x,c.maxY),y=Math.max(y,c.maxX),c.width===m.width&&c.height===m.height?(v=S.pop(),M<S.length&&(S[M]=v)):c.height===m.height?(m.x+=c.width+r,m.width-=c.width+r):c.width===m.width?(m.y+=c.height+r,m.height-=c.height+r):(S.push(new Q(m.x+(c.width+r),m.y,m.width-(c.width+r),c.height)),m.y+=c.height+r,m.height-=c.height+r);break}}const w=Q.Common(Object.values(a)),C=b.Sub(h.center,w.center);let E;const _=[];for(let T=0;T<s.length;T++){l=s[T],c=i[l.id],E=a[l.id];const M=b.Sub(E.point,c.point).add(C),D=this.getShapeParentTransform(l);D&&M.rot(-D.rotation());const $={id:l.id,type:l.type,x:l.x+M.x,y:l.y+M.y},j=(k=(I=this.getShapeUtil(l)).onTranslateStart)==null?void 0:k.call(I,{...l,...$});j?_.push({...$,...j}):_.push($)}return _.length&&this.updateShapes(_),this}alignShapes(n,r){const o=typeof n[0]=="string"?n:n.map(c=>c.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=ye(o.map(c=>this.getShape(c))),i=Object.fromEntries(s.map(c=>[c.id,this.getShapePageBounds(c)])),a=Q.Common(ye(Object.values(i))),l=[];return s.forEach(c=>{const u=i[c.id];if(!u)return;const h={x:0,y:0};switch(r){case"top":{h.y=a.minY-u.minY;break}case"center-vertical":{h.y=a.midY-u.minY-u.height/2;break}case"bottom":{h.y=a.maxY-u.minY-u.height;break}case"left":{h.x=a.minX-u.minX;break}case"center-horizontal":{h.x=a.midX-u.minX-u.width/2;break}case"right":{h.x=a.maxX-u.minX-u.width;break}}const p=this.getShapeParent(c),f=p?b.Rot(h,-this.getShapePageTransform(p).decompose().rotation):h;l.push(this.getChangesToTranslateShape(c,b.Add(c,f)))}),this.updateShapes(l),this}distributeShapes(n,r){const o=typeof n[0]=="string"?n:n.map(w=>w.id);if(this.getInstanceState().isReadonly)return this;if(o.length<3)return this;const s=o.length,i=ye(o.map(w=>this.getShape(w))),a=Object.fromEntries(i.map(w=>[w.id,this.getShapePageBounds(w)]));let l,c,u,h,p;r==="horizontal"?(l="x",c="minX",u="maxX",h="midX",p="width"):(l="y",c="minY",u="maxY",h="midY",p="height");const f=[],S=i.sort((w,C)=>a[w.id][c]-a[C.id][c])[0],y=i.sort((w,C)=>a[C.id][u]-a[w.id][u])[0],x=a[S.id][h],m=(a[y.id][h]-x)/(s-1),v=x+m;return i.filter(w=>w!==S&&w!==y).sort((w,C)=>a[w.id][h]-a[C.id][h]).forEach((w,C)=>{const E={x:0,y:0};E[l]=v+m*C-a[w.id][p]/2-a[w.id][l];const _=this.getShapeParent(w),I=_?b.Rot(E,-this.getShapePageTransform(_).rotation()):E;f.push(this.getChangesToTranslateShape(w,b.Add(w,I)))}),this.updateShapes(f),this}stretchShapes(n,r){const o=typeof n[0]=="string"?n:n.map(c=>c.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=ye(o.map(c=>this.getShape(c))),i=Object.fromEntries(o.map(c=>[c,this.getShapeGeometry(c).bounds])),a=Object.fromEntries(o.map(c=>[c,this.getShapePageBounds(c)])),l=Q.Common(ye(Object.values(a)));switch(r){case"vertical":{this.run(()=>{for(const c of s){if(this.getShapePageTransform(c).rotation()%Le)continue;const h=i[c.id],p=a[c.id],f=new b(0,l.minY-p.minY),S=this.getShapeParentTransform(c);S&&f.rot(-S.rotation());const{x:y,y:x}=b.Add(f,c);this.updateShapes([{id:c.id,type:c.type,x:y,y:x}]);const m=new b(1,l.height/p.height);this.resizeShape(c.id,m,{initialBounds:h,scaleOrigin:new b(p.center.x,l.minY),isAspectRatioLocked:this.getShapeUtil(c).isAspectRatioLocked(c),scaleAxisRotation:0})}});break}case"horizontal":{this.run(()=>{for(const c of s){const u=i[c.id],h=a[c.id];if(this.getShapePageTransform(c).rotation()%Le)continue;const f=new b(l.minX-h.minX,0),S=this.getShapeParentTransform(c);S&&f.rot(-S.rotation());const{x:y,y:x}=b.Add(f,c);this.updateShapes([{id:c.id,type:c.type,x:y,y:x}]);const m=new b(l.width/h.width,1);this.resizeShape(c.id,m,{initialBounds:u,scaleOrigin:new b(l.minX,h.center.y),isAspectRatioLocked:this.getShapeUtil(c).isAspectRatioLocked(c),scaleAxisRotation:0})}});break}}return this}resizeShape(n,r,o={}){var S,y,x;const s=typeof n=="string"?n:n.id;if(this.getInstanceState().isReadonly)return this;Number.isFinite(r.x)||(r=new b(1,r.y)),Number.isFinite(r.y)||(r=new b(r.x,1));const i=o.initialShape??this.getShape(s);if(!i)return this;const a=o.scaleOrigin??((S=this.getShapePageBounds(s))==null?void 0:S.center);if(!a)return this;const l=o.initialPageTransform?se.Cast(o.initialPageTransform):this.getShapePageTransform(s);if(!l)return this;const c=l.rotation();if(c==null)return this;const u=o.scaleAxisRotation??c,h=o.initialBounds??this.getShapeGeometry(s).bounds;if(!h)return this;const p=o.isAspectRatioLocked??this.getShapeUtil(i).isAspectRatioLocked(i);if(!r2(c,u))return this._resizeUnalignedShape(s,r,{...o,initialBounds:h,scaleOrigin:a,scaleAxisRotation:u,initialPageTransform:l,isAspectRatioLocked:p,initialShape:i});const f=this.getShapeUtil(i);if(p&&(Math.abs(r.x)>Math.abs(r.y)?r=new b(r.x,Math.sign(r.y)*Math.abs(r.x)):r=new b(Math.sign(r.x)*Math.abs(r.y),r.y)),f.onResize&&f.canResize(i)){const m=this._scalePagePoint(se.applyToPoint(l,new b(0,0)),a,r,u),v=this.getPointInParentSpace(i.id,m),w=new b(r.x,r.y),C=$s((c-u)%Math.PI,0);w.x=C?r.x:r.y,w.y=C?r.y:r.x;const E=se.applyToPoint(l,new b),{x:_,y:I}=this.getPointInParentSpace(i.id,E);let k=i;o.skipStartAndEndCallbacks||(k=oo(i,((y=f.onResizeStart)==null?void 0:y.call(f,i))??void 0)),k=oo(k,{id:s,type:i.type,x:v.x,y:v.y,...f.onResize({...i,x:_,y:I},{newPoint:v,handle:o.dragHandle??"bottom_right",mode:o.mode??"scale_shape",scaleX:w.x,scaleY:w.y,initialBounds:h,initialShape:i})}),o.skipStartAndEndCallbacks||(k=oo(k,((x=f.onResizeEnd)==null?void 0:x.call(f,i,k))??void 0)),this.updateShapes([k])}else{const m=se.applyToPoint(l,h.center),v=this._scalePagePoint(m,a,r,u),w=this.getPointInParentSpace(i.id,m),C=this.getPointInParentSpace(i.id,v),E=b.Sub(C,w);this.updateShapes([{id:s,type:i.type,x:i.x+E.x,y:i.y+E.y}])}return this}_scalePagePoint(n,r,o,s){const i=b.RotWith(n,r,-s).sub(r),a=b.MulV(i,o);return b.Add(a,r).rotWith(r,s)}_resizeUnalignedShape(n,r,o){const{type:s}=o.initialShape,i=new b(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,isAspectRatioLocked:o.isAspectRatioLocked}),Math.sign(r.x)*Math.sign(r.y)<0){let{rotation:m}=se.Decompose(o.initialPageTransform);m-=2*m,this.updateShapes([{id:n,type:s,rotation:m}])}const a=se.applyToPoint(o.initialPageTransform,o.initialBounds.center),l=this._scalePagePoint(a,o.scaleOrigin,r,o.scaleAxisRotation),c=this.getShapePageBounds(n),u=this.getShapePageTransform(n),h=c.center,p=u.point();if(!h||!p)return this;const f=b.Sub(l,h),S=b.Add(p,f),{x:y,y:x}=this.getPointInParentSpace(n,S);return this.updateShapes([{id:n,type:s,x:y,y:x}]),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");if(this.getInstanceState().isReadonly)return this;if(n.length<=0)return this;const r=this.getCurrentPageShapeIds();if(n.length+r.size>this.options.maxShapesPerPage)return Qd(this),this;const s=this.getFocusedGroupId();return this.run(()=>{var h,p;const i=this.getCurrentPageShapesSorted(),a=n.map(f=>{if(f.id||(f={id:$e(),...f}),!f.parentId||!(this.store.has(f.parentId)||n.some(S=>S.id===f.parentId))){let S=this.getFocusedGroupId();for(let x=i.length-1;x>=0;x--){const m=i[x];if(this.getShapeUtil(m).canReceiveNewChildrenOfType(m,f.type)&&this.isPointInShape(m,{x:f.x??0,y:f.y??0},{margin:0,hitInside:!0})){S=m.id;break}}const y=f.parentId;if(S===f.id&&(S=s),S!==y&&(f={...f},f.parentId=S,On(S))){const x=this.getPointInShapeSpace(this.getShape(S),{x:f.x??0,y:f.y??0});f.x=x.x,f.y=x.y,f.rotation=-this.getShapePageTransform(S).rotation()+(f.rotation??0)}}return f}),l=new Map,c=[],{opacityForNextShape:u}=this.getInstanceState();for(const f of a){const S=this.getShapeUtil(f);let y=f.index;if(!y){const w=f.parentId??s;l.has(w)||l.set(w,this.getHighestIndexForParent(w)),y=l.get(w),l.set(w,zr(y))}const x=S.getDefaultProps();for(const[w,C]of this.styleProps[f.type])x[C]=this.getStyleForNextShape(w);let m=this.store.schema.types.shape.create({...f,index:y,opacity:f.opacity??u,parentId:f.parentId??s,props:"props"in f?{...x,...f.props}:x});if(m.index===void 0)throw Error("no index!");const v=(p=(h=this.getShapeUtil(m)).onBeforeCreate)==null?void 0:p.call(h,m);v&&(m=v),c.push(m)}c.forEach(f=>{f.meta={...this.getInitialMetaForShape(f),...f.meta}}),this.store.put(c)}),this}animateShape(n,r={animation:Tm}){return this.animateShapes([n],r)}animateShapes(n,r={animation:Tm}){if(!r.animation)return this;const{duration:o=500,easing:s=At.linear}=r.animation,i=ct();let a=o,l;const c=[];let u,h;for(let f=0,S=n.length;f<S;f++){if(u=n[f],!u)continue;const y=this.getShape(u.id);y&&(h={start:Ge(y),end:oo(Ge(y),u)},c.push(h),this.animatingShapes.set(y.id,i))}const p=f=>{var m,v;if(a-=f,a<0){const{animatingShapes:w}=this,C=n.filter(E=>E&&w.get(E.id)===i);C.length&&this.updateShapes(C),this.off("tick",p);return}l=s(1-a/o);const{animatingShapes:S}=this,y=[];let x;for(let w=0,C=c.length;w<C;w++){const{start:E,end:_}=c[w];x=S.get(E.id),x===i&&y.push({..._,x:E.x+(_.x-E.x)*l,y:E.y+(_.y-E.y)*l,opacity:E.opacity+(_.opacity-E.opacity)*l,rotation:E.rotation+(_.rotation-E.rotation)*l,props:((v=(m=this.getShapeUtil(_)).getInterpolatedProps)==null?void 0:v.call(m,E,_,l))??_.props})}this._updateShapes(y)};return this.on("tick",p),this}groupShapes(n,r={}){var y;const{groupId:o=$e(),select:s=!0}=r;if(!Array.isArray(n))throw Error("Editor.groupShapes: must provide an array of shapes or shape ids");if(this.getInstanceState().isReadonly)return this;const i=typeof n[0]=="string"?n:n.map(x=>x.id);if(i.length<=1)return this;const a=ye((this._shouldIgnoreShapeLock?i:this._getUnlockedShapeIds(i)).map(x=>this.getShape(x))),l=a.sort(ln).map(x=>x.id),c=Q.Common(ye(a.map(x=>this.getShapePageBounds(x)))),{x:u,y:h}=c.point,p=this.findCommonAncestor(a)??this.getCurrentPageId();if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const f=a.filter(x=>x.parentId===p).sort(ln),S=(y=f[f.length-1])==null?void 0:y.index;return this.run(()=>{this.createShapes([{id:o,type:"group",parentId:p,index:S,x:u,y:h,opacity:1,props:{}}]),this.reparentShapes(l,o),s&&this.select(o)}),this}ungroupShapes(n,r={}){if(this.getInstanceState().isReadonly)return this;const{select:o=!0}=r,s=typeof n[0]=="string"?n:n.map(c=>c.id),i=ye((this._shouldIgnoreShapeLock?s:this._getUnlockedShapeIds(s)).map(c=>this.getShape(c)));if(i.length===0)return this;if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const a=new Set,l=[];return i.forEach(c=>{this.isShapeOfType(c,"group")?l.push(c):a.add(c.id)}),l.length===0?this:(this.run(()=>{let c;for(let u=0,h=l.length;u<h;u++){c=l[u];const p=this.getSortedChildIdsForParent(c.id);for(let f=0,S=p.length;f<S;f++)a.add(p[f]);this.reparentShapes(p,c.parentId,c.index)}this.deleteShapes(l.map(u=>u.id)),o&&this.select(...a)}),this)}updateShape(n){return this.updateShapes([n]),this}updateShapes(n){const r=Array(n.length);for(let o=0,s=n.length;o<s;o++){const i=n[o];if(!i)continue;const a=this.getShape(i.id);if(a){if(!this._shouldIgnoreShapeLock){if(a.isLocked){if(!(Object.hasOwn(i,"isLocked")&&!i.isLocked))continue}else if(this.isShapeOrAncestorLocked(a))continue}this.animatingShapes.delete(i.id),r.push(i)}}return this._updateShapes(r),this}_getUnlockedShapeIds(n){return n.filter(r=>{var o;return!((o=this.getShape(r))!=null&&o.isLocked)})}deleteShapes(n){if(this.getInstanceState().isReadonly)return this;if(!Array.isArray(n))throw Error("Editor.deleteShapes: must provide an array of shapes or shapeIds");const r=typeof n[0]=="string"?n:n.map(i=>i.id),o=this._shouldIgnoreShapeLock?r:this._getUnlockedShapeIds(r);if(o.length===0)return this;const s=new Set(o);for(const i of o)this.visitDescendants(i,a=>{s.add(a)});return this.run(()=>this.store.remove([...s]))}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,Nn(n.props,s))}_getSelectionSharedStyles(){const n=this.getSelectedShapes(),r=new _v;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 Nn(n.props,o)}getSharedStyles(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0)return this._getSelectionSharedStyles();const n=this.root.getCurrent(),r=new _v;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){const r=this.getSelectedShapes();if(r.length>0){const o=[],s=i=>{if(this.isShapeOfType(i,"group")){const a=this.getSortedChildIdsForParent(i);for(const l of a)s(this.getShape(l))}else o.push(i)};for(const i of r)s(i);this.updateShapes(o.map(i=>({id:i.id,type:i.type,opacity:n})))}return this}setStyleForNextShapes(n,r,o){const s=this.getInstanceState().stylesForNextShape;return this.updateInstanceState({stylesForNextShape:{...s,[n.id]:r}},o),this}setStyleForSelectedShapes(n,r){const o=this.getSelectedShapes();if(o.length>0){const s=[],i=a=>{if(this.isShapeOfType(a,"group")){const l=this.getSortedChildIdsForParent(a.id);for(const c of l)i(this.getShape(c))}else{const l=this.getShapeUtil(a),c=this.styleProps[a.type].get(n);if(c){const u={id:a.id,type:a.type,props:{[c]:r}};s.push({util:l,originalShape:a,updatePartial:u})}}};for(const a of o)i(a);this.updateShapes(s.map(({updatePartial:a})=>a))}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))}hasExternalAssetHandler(n){return!!this.externalAssetContentHandlers[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(s=>s.id);if(!r||r.length===0)return;const o=this.getShapeAndDescendantIds(r);return VC(this,o,s=>{const i=[];for(const h of s){const p=this.getBinding(h);p&&i.push(p)}const a=[],l=[];for(const h of o){const p=this.getShape(h);if(!p)continue;if(!o.has(p.parentId)){const S=this.getShapePageTransform(p.id),y=S.point();l.push({...p,x:y.x,y:y.y,rotation:S.rotation(),parentId:this.getCurrentPageId()}),a.push(p.id)}else l.push(p)}const c=[],u=new Set;for(const h of l){if(!("assetId"in h.props))continue;const p=h.props.assetId;if(!p||u.has(p))continue;u.add(p);const f=this.getAsset(p);f&&c.push(f)}return{schema:this.store.schema.serialize(),shapes:l,rootShapeIds:a,bindings:i,assets:c}})}async resolveAssetsInContent(n){if(!n)return;const r=[];return await Promise.allSettled(n.assets.map(async o=>{var s,i;if((o.type==="image"||o.type==="video")&&!((s=o.props.src)!=null&&s.startsWith("data:image"))&&!((i=o.props.src)!=null&&i.startsWith("http"))){const a=Ge(o),l=await this.store.props.assets.resolve(o,{screenScale:1,steppedScreenScale:1,dpr:1,networkEffectiveType:null,shouldResolveToOriginal:!0});a.props.src=await Ai.blobToDataUrl(await bo(l).then(c=>c.blob())),r.push(a)}else r.push(o)})),n.assets=r,n}putContentOntoCurrentPage(n,r={}){var D,$;if(this.getInstanceState().isReadonly)return this;if(!n.schema)throw Error(`Could not put content:
|
|
90
|
+
content is missing a schema.`);const{select:o=!1,preserveIds:s=!1,preservePosition:i=!1}=r;let{point:a=void 0}=r;const l=this.getCurrentPageId(),{rootShapeIds:c}=n,u=[],h=[],p=[],f={store:{...Object.fromEntries(n.assets.map(j=>[j.id,j])),...Object.fromEntries(n.shapes.map(j=>[j.id,j])),...Object.fromEntries(((D=n.bindings)==null?void 0:D.map(j=>[j.id,j]))??[])},schema:n.schema},S=this.store.schema.migrateStoreSnapshot(f);if(S.type==="error")throw Error("Could not put content: could not migrate content");for(const j of Object.values(S.value))switch(j.typeName){case"asset":{u.push(j);break}case"shape":{h.push(j);break}case"binding":{p.push(j);break}}const y=new Map(s?h.map(j=>[j.id,j.id]):h.map(j=>[j.id,$e()])),x=new Map(s?p.map(j=>[j.id,j.id]):p.map(j=>[j.id,ji()]));let m=this.getCurrentPageId(),v=1/0,w=[];for(const j of this.getSelectedShapes()){if(v===0)break;const O=this.isShapeOfType(j,"frame"),R=this.getShapeAncestors(j);O&&R.push(j);const H=O?R.length+1:R.length;if(H<v)v=H,w=R,m=O?j.id:j.parentId;else if(H===v){if(w.length!==R.length)throw Error(`Ancestors: ${w.length} !== ${R.length}`);if(w.length===0){m=l;break}else{m=l;for(let B=0;B<w.length&&R[B]===w[B];B++)m=R[B].id}}}let C=!1;if(!An(m)){const j=this.getShape(m);if(j){if(!this.getViewportPageBounds().includes(this.getShapePageBounds(j)))m=l;else if(c.length===1){const O=h.find(R=>R.id===c[0]);this.isShapeOfType(j,"frame")&&this.isShapeOfType(O,"frame")&&O.props.w===(j==null?void 0:j.props.w)&&O.props.h===(j==null?void 0:j.props.h)&&(C=!0)}}else m=l}C||(C=y.has(m)),C&&(m=this.getShape(m).parentId);let E=this.getHighestIndexForParent(m);const _=[],I=h.map(j=>{const O=y.get(j.id),R={...j,id:O};return c.includes(j.id)&&(R.parentId=l,_.push(R)),y.has(R.parentId)?R.parentId=y.get(j.parentId):(c.push(R.id),R.index=E,E=zr(E)),R});if(I.length+this.getCurrentPageShapeIds().size>this.options.maxShapesPerPage)return Qd(this),this;const k=p.map(j=>({...j,id:xr(x.get(j.id)),fromId:xr(y.get(j.fromId)),toId:xr(y.get(j.toId))})),T=[],M=[];for(const j of u)this.store.has(j.id)||((j.type==="image"||j.type==="video")&&(($=j.props.src)!=null&&$.startsWith("data:image"))&&(M.push(Ge(j)),j.props.src=null),T.push(j));return Promise.allSettled(M.map(async j=>{const O=await cG(j.props.src,j.props.name,j.props.mimeType??"image/png"),R=await this.getAssetForExternalContent({type:"file",file:O});if(!R){this.deleteAssets([j.id]);return}this.updateAssets([{...R,id:j.id}])})),this.run(()=>{T.length>0&&this.createAssets(T),this.createShapes(I),this.createBindings(k),o&&this.select(..._.map(B=>B.id)),m!==l&&this.reparentShapes(_.map(B=>B.id),m);const j=I.map(B=>this.getShape(B.id)),O=Q.Common(j.map(B=>this.getShapePageBounds(B)));if(a===void 0)if(An(m)){const B=this.getViewportPageBounds();i||B.includes(Q.From(O))?a=O.center:a=B.center}else{const B=this.getShape(m);a=se.applyToPoint(this.getShapePageTransform(B),this.getShapeGeometry(B).bounds.center)}if(_.length===1){const B=_[0];if(this.isShapeOfType(B,"frame"))for(;this.getShapesAtPoint(a).some(z=>this.isShapeOfType(z,"frame")&&z.props.w===B.props.w&&z.props.h===B.props.h);)a.x+=O.w+16}const R=Q.Common(ye(_.map(({id:B})=>this.getShapePageBounds(B)))).center,H=b.Sub(a,R);this.updateShapes(_.map(({id:B})=>{const z=this.getShape(B),W=this.getShapeParentTransform(B).decompose().rotation,Y=b.Rot(H,-W);return{id:z.id,type:z.type,x:z.x+Y.x,y:z.y+Y.y}}))}),this}async getSvgElement(n,r={}){const o=await bG(this,n,r);if(!o)return;const s=document.createDocumentFragment(),i=FM(s);ia.flushSync(()=>{i.render(o.jsx)});const a=s.firstElementChild;return Xe(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){const{pointerVelocity:r,previousScreenPoint:o,previousPagePoint:s,currentScreenPoint:i,currentPagePoint:a}=this.inputs,{screenBounds:l}=this.store.unsafeGetWithoutCapture(Sn),{x:c,y:u,z:h}=Id(()=>this.getCamera()),p=n.point.x-l.x,f=n.point.y-l.y,S=n.point.z??.5;o.setTo(i),s.setTo(a),i.set(p,f);const y=p/h-c,x=f/h-u;isFinite(y)&&isFinite(x)&&a.set(y,x,S),this.inputs.isPen=n.type==="pointer"&&n.isPen,(n.name==="pointer_down"||this.inputs.isPinching)&&(r.set(0,0),this.inputs.originScreenPoint.setTo(i),this.inputs.originPagePoint.setTo(a)),this.run(()=>{var m;this.store.put([{id:$p,typeName:"pointer",x:a.x,y:a.y,lastActivityTimestamp:n.type==="pointer"&&n.pointerId===gP.CAMERA_MOVE?((m=this.store.unsafeGetWithoutCapture($p))==null?void 0:m.lastActivityTimestamp)??this._tickManager.now:this._tickManager.now,meta:{}}])},{history:"ignore"})}cancel(){return this.dispatch({type:"misc",name:"cancel"}),this}interrupt(){return this.dispatch({type:"misc",name:"interrupt"}),this}complete(){return this.dispatch({type:"misc",name:"complete"}),this}focus({focusContainer:n=!0}={}){return this.getIsFocused()?this:(n&&this.focusManager.focus(),this.updateInstanceState({isFocused:!0}),this)}blur({blurContainer:n=!0}={}){return this.getIsFocused()?(n?this.focusManager.blur():this.complete(),this.updateInstanceState({isFocused:!1}),this):this}getIsFocused(){return this.getInstanceState().isFocused}getSnapshot(){return eG(this.store)}loadSnapshot(n){return KM(this.store,n),this}cancelDoubleClick(){this._clickManager.cancelDoubleClickTimeout()}_flushEventsForTick(n){this.run(()=>{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)})}maybeTrackPerformance(n){xt.measurePerformance.get()&&(this.performanceTracker.isStarted()?clearTimeout(this.performanceTrackerTimeout):this.performanceTracker.start(n),this.performanceTrackerTimeout=this.timers.setTimeout(()=>{this.performanceTracker.stop()},50))}}ne([G],Z.prototype,"getCanUndo");ne([G],Z.prototype,"getCanRedo");ne([G],Z.prototype,"getPath");ne([G],Z.prototype,"getCurrentTool");ne([G],Z.prototype,"getCurrentToolId");ne([G],Z.prototype,"getDocumentSettings");ne([G],Z.prototype,"getInstanceState");ne([G],Z.prototype,"getOpenMenus");ne([G],Z.prototype,"getIsMenuOpen");ne([G],Z.prototype,"getPageStates");ne([G],Z.prototype,"_getPageStatesQuery");ne([G],Z.prototype,"getCurrentPageState");ne([G],Z.prototype,"_getCurrentPageStateId");ne([G],Z.prototype,"getSelectedShapeIds");ne([G],Z.prototype,"getSelectedShapes");ne([G],Z.prototype,"getOnlySelectedShapeId");ne([G],Z.prototype,"getOnlySelectedShape");ne([G],Z.prototype,"getSelectionPageBounds");ne([G],Z.prototype,"getSelectionRotation");ne([G],Z.prototype,"getSelectionRotatedPageBounds");ne([G],Z.prototype,"getSelectionRotatedScreenBounds");ne([G],Z.prototype,"getFocusedGroupId");ne([G],Z.prototype,"getFocusedGroup");ne([G],Z.prototype,"getEditingShapeId");ne([G],Z.prototype,"getEditingShape");ne([G],Z.prototype,"getHoveredShapeId");ne([G],Z.prototype,"getHoveredShape");ne([G],Z.prototype,"getHintingShapeIds");ne([G],Z.prototype,"getHintingShape");ne([G],Z.prototype,"getErasingShapeIds");ne([G],Z.prototype,"getErasingShapes");ne([G],Z.prototype,"_unsafe_getCameraId");ne([G],Z.prototype,"getCamera");ne([G],Z.prototype,"getViewportPageBoundsForFollowing");ne([G],Z.prototype,"getCameraForFollowing");ne([G],Z.prototype,"getZoomLevel");ne([G],Z.prototype,"getViewportScreenBounds");ne([G],Z.prototype,"getViewportScreenCenter");ne([G],Z.prototype,"getViewportPageBounds");ne([G],Z.prototype,"_getCollaboratorsQuery");ne([G],Z.prototype,"getCollaborators");ne([G],Z.prototype,"getCollaboratorsOnCurrentPage");ne([G],Z.prototype,"getRenderingShapes");ne([G],Z.prototype,"_getAllPagesQuery");ne([G],Z.prototype,"getPages");ne([G],Z.prototype,"getCurrentPageId");ne([G],Z.prototype,"getCurrentPageShapeIdsSorted");ne([G],Z.prototype,"_getAllAssetsQuery");ne([G],Z.prototype,"_getShapeGeometryCache");ne([G],Z.prototype,"_getShapeHandlesCache");ne([G],Z.prototype,"_getShapePageTransformCache");ne([G],Z.prototype,"_getShapePageBoundsCache");ne([G],Z.prototype,"_getShapeClipPathCache");ne([G],Z.prototype,"_getShapeMaskCache");ne([G],Z.prototype,"_getShapeMaskedPageBoundsCache");ne([G],Z.prototype,"_notVisibleShapes");ne([G],Z.prototype,"getCulledShapes");ne([G],Z.prototype,"getCurrentPageBounds");ne([G],Z.prototype,"getCurrentPageShapes");ne([G],Z.prototype,"getCurrentPageShapesSorted");ne([G],Z.prototype,"getCurrentPageRenderingShapesSorted");ne([G],Z.prototype,"_getBindingsIndexCache");ne([G],Z.prototype,"_getSelectionSharedStyles");ne([G({isEqual:(e,t)=>e.equals(t)})],Z.prototype,"getSharedStyles");ne([G],Z.prototype,"getSharedOpacity");ne([G],Z.prototype,"getIsFocused");function Qd(e,t=e.getCurrentPageId()){const n=e.getPage(t).name;e.emit("max-shapes",{name:n,pageId:t,count:e.options.maxShapesPerPage})}function oo(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[l,c]of Object.entries(a))c!==void 0&&(n[i][l]=c);continue}n[i]=a}}return n||e}function JM(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++)JM(e,o[s],n)}function VC(e,t,n){let r;if(e.run(()=>{const o=e.store.extractingChanges(()=>{const s=new Set,i=new Set;for(const a of t)if(e.getShape(a))for(const c of e.getBindingsInvolvingShape(a)){const u=t.has(c.fromId),h=t.has(c.toId);if(u&&h){s.add(c.id);continue}(!u||!h)&&i.add(c.id)}e.deleteBindings([...i],{isolateShapes:!0});try{r=yn.ok(n(s))}catch(a){r=yn.err(a)}});e.store.applyDiff(CS(o))},{history:"ignore"}),r.ok)return r.value;throw r.error}function YC(e,t){if(!t.constraints)throw Error("Should have constraints here");const{padding:{x:n,y:r}}=t.constraints,o=e.getViewportScreenBounds(),s=Q.From(t.constraints.bounds),i=(o.w-n*2)/s.w,a=(o.h-r*2)/s.h;return{zx:i,zy:a}}function td(){const e=F(),t=ZM();return K("isDarkMode",()=>(t==null?void 0:t.isDarkMode)??e.user.getIsDarkMode(),[t,e])}const XC="<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'/>",qC="<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'/>",Jd='<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 ws(e,t,n,r,o,s=16,i=16){const a=(-n-t)*(Me/180),l=Math.sin(a),c=Math.cos(a),u=1*c-1*l,h=1*l+1*c;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='${h}' 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 tV=["default","pointer","cross","move","grab","grabbing","text","zoom-in","zoom-out"],nV={none:()=>"none","ew-resize":(e,t,n)=>ws(qC,e,0,t,n),"ns-resize":(e,t,n)=>ws(qC,e,90,t,n),"nesw-resize":(e,t,n)=>ws(XC,e,0,t,n),"nwse-resize":(e,t,n)=>ws(XC,e,90,t,n),"nwse-rotate":(e,t,n)=>ws(Jd,e,0,t,n),"nesw-rotate":(e,t,n)=>ws(Jd,e,90,t,n),"senw-rotate":(e,t,n)=>ws(Jd,e,180,t,n),"swne-rotate":(e,t,n)=>ws(Jd,e,270,t,n)};function Zn(e,t=0,n="black"){return nV[e](b9(t),!1,n)}function rV(){const e=F(),t=$t(),n=td();Ls("useCursor",()=>{const{type:r,rotation:o}=e.getInstanceState().cursor;if(tV.includes(r)){t.style.setProperty("--tl-cursor",`var(--tl-cursor-${r})`);return}t.style.setProperty("--tl-cursor",Zn(r,o,n?"white":"black"))},[e,t,n])}function oV(){const e=F(),t=$t(),n=td(),r=K(xt.forceSrgb);Ce.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 eA(e){const t=P.useRef();return P.useLayoutEffect(()=>{t.current=e}),P.useDebugValue(e),P.useCallback((...n)=>{const r=t.current;return Xe(r,"fn does not exist"),r(...n)},[])}function sV(){const[e,t]=P.useState(0);P.useEffect(()=>t(n=>n+1),[])}const iV=e=>e.props.src,aV={upload:(e,t)=>Ai.blobToDataUrl(t)};function lV(e){return"schema"in e&&e.schema?e.schema:c9({shapes:"shapeUtils"in e&&e.shapeUtils?ZC(YM(e.shapeUtils)):void 0,bindings:"bindingUtils"in e&&e.bindingUtils?ZC(WM(e.bindingUtils)):void 0,migrations:"migrations"in e?e.migrations:void 0})}function Iu({initialData:e,defaultName:t="",id:n,assets:r=aV,onMount:o,collaboration:s,...i}={}){const a=lV(i),l=new Xx({id:n,schema:a,initialData:e,props:{defaultName:t,assets:{upload:r.upload,resolve:r.resolve??iV},onMount:c=>{Xe(c instanceof Z),o==null||o(c)},collaboration:s}});if(i.snapshot){if(e)throw new Error("Cannot provide both initialData and snapshot");KM(l,i.snapshot)}return l}function ZC(e){return Object.fromEntries(e.map(t=>[t.type,{props:t.props,migrations:t.migrations}]))}const cV=(e,t)=>t.some(n=>e instanceof n);let QC,JC;function uV(){return QC||(QC=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function dV(){return JC||(JC=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const tA=new WeakMap,Tv=new WeakMap,nA=new WeakMap,iy=new WeakMap,iw=new WeakMap;function hV(e){const t=new Promise((n,r)=>{const o=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{n(Xo(e.result)),o()},i=()=>{r(e.error),o()};e.addEventListener("success",s),e.addEventListener("error",i)});return t.then(n=>{n instanceof IDBCursor&&tA.set(n,e)}).catch(()=>{}),iw.set(t,e),t}function pV(e){if(Tv.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)});Tv.set(e,t)}let Mv={get(e,t,n){if(e instanceof IDBTransaction){if(t==="done")return Tv.get(e);if(t==="objectStoreNames")return e.objectStoreNames||nA.get(e);if(t==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Xo(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 fV(e){Mv=e(Mv)}function gV(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...n){const r=e.call(ay(this),t,...n);return nA.set(r,t.sort?t.sort():[t]),Xo(r)}:dV().includes(e)?function(...t){return e.apply(ay(this),t),Xo(tA.get(this))}:function(...t){return Xo(e.apply(ay(this),t))}}function mV(e){return typeof e=="function"?gV(e):(e instanceof IDBTransaction&&pV(e),cV(e,uV())?new Proxy(e,Mv):e)}function Xo(e){if(e instanceof IDBRequest)return hV(e);if(iy.has(e))return iy.get(e);const t=mV(e);return t!==e&&(iy.set(e,t),iw.set(t,e)),t}const ay=e=>iw.get(e);function rA(e,t,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(e,t),a=Xo(i);return r&&i.addEventListener("upgradeneeded",l=>{r(Xo(i.result),l.oldVersion,l.newVersion,Xo(i.transaction),l)}),n&&i.addEventListener("blocked",l=>n(l.oldVersion,l.newVersion,l)),a.then(l=>{s&&l.addEventListener("close",()=>s()),o&&l.addEventListener("versionchange",c=>o(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}function oA(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",r=>t(r.oldVersion,r)),Xo(n).then(()=>{})}const yV=["get","getKey","getAll","getAllKeys","count"],SV=["put","add","delete","clear"],ly=new Map;function eI(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(ly.get(t))return ly.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=SV.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(o||yV.includes(n)))return;const s=async function(i,...a){const l=this.transaction(i,o?"readwrite":"readonly");let c=l.store;return r&&(c=c.index(a.shift())),(await Promise.all([c[n](...a),o&&l.done]))[0]};return ly.set(t,s),s}fV(e=>({...e,get:(t,n,r)=>eI(t,n)||e.get(t,n,r),has:(t,n)=>!!eI(t,n)||e.has(t,n)}));const vV="TLDRAW_DOCUMENT_v2",xV="TLDRAW_ASSET_STORE_v1",sA="TLDRAW_DB_NAME_INDEX_v2",Pe={Records:"records",Schema:"schema",SessionState:"session_state",Assets:"assets"};async function iA(e){const t=vV+e;return bV(t),await rA(t,4,{upgrade(n){n.objectStoreNames.contains(Pe.Records)||n.createObjectStore(Pe.Records),n.objectStoreNames.contains(Pe.Schema)||n.createObjectStore(Pe.Schema),n.objectStoreNames.contains(Pe.SessionState)||n.createObjectStore(Pe.SessionState),n.objectStoreNames.contains(Pe.Assets)||n.createObjectStore(Pe.Assets)}})}async function wV(e){const t=window.indexedDB.databases?(await window.indexedDB.databases()).map(p=>p.name):aw(),n=xV+e;if(!t.find(p=>p===n))return;const o=await rA(n,1,{upgrade(p){p.objectStoreNames.contains("assets")||p.createObjectStore("assets")}}),s=o.transaction(["assets"],"readonly"),i=s.objectStore("assets"),a=await i.getAllKeys(),l=await Promise.all(a.map(async p=>[p,await i.get(p)]));await s.done;const c=await iA(e),u=c.transaction([Pe.Assets],"readwrite"),h=u.objectStore(Pe.Assets);for(const[p,f]of l)h.put(f,p);await u.done,o.close(),c.close(),await oA(n)}const Jc=class Jc{constructor(t){g(this,"getDbPromise");g(this,"isClosed",!1);g(this,"pendingTransactionSet",new Set);Jc.connectedInstances.add(this),this.getDbPromise=(async()=>(await wV(t),await iA(t)))()}getDb(){return this.getDbPromise}pending(){return Promise.allSettled([this.getDbPromise,...this.pendingTransactionSet]).then(nu)}async close(){this.isClosed||(this.isClosed=!0,await this.pending(),(await this.getDb()).close(),Jc.connectedInstances.delete(this))}tx(t,n,r){const o=(async()=>{Xe(!this.isClosed,"db is closed");const i=(await this.getDb()).transaction(n,t);try{return await r(i)}finally{this.isClosed?i.abort():await i.done}})();return this.pendingTransactionSet.add(o),o.finally(()=>this.pendingTransactionSet.delete(o)),o}async load({sessionId:t}={}){return await this.tx("readonly",[Pe.Records,Pe.Schema,Pe.SessionState],async n=>{var l,c;const r=n.objectStore(Pe.Records),o=n.objectStore(Pe.Schema),s=n.objectStore(Pe.SessionState);let i=t?(l=await s.get(t))==null?void 0:l.snapshot:null;return i||(i=(c=(await s.getAll()).sort((h,p)=>h.updatedAt-p.updatedAt).pop())==null?void 0:c.snapshot),{records:await r.getAll(),schema:await o.get(Pe.Schema),sessionStateSnapshot:i}})}async storeChanges({schema:t,changes:n,sessionId:r,sessionStateSnapshot:o}){await this.tx("readwrite",[Pe.Records,Pe.Schema,Pe.SessionState],async s=>{const i=s.objectStore(Pe.Records),a=s.objectStore(Pe.Schema),l=s.objectStore(Pe.SessionState);for(const[c,u]of Object.entries(n.added))await i.put(u,c);for(const[c,u]of Object.values(n.updated))await i.put(u,u.id);for(const c of Object.keys(n.removed))await i.delete(c);a.put(t.serialize(),Pe.Schema),o&&r?l.put({snapshot:o,updatedAt:Date.now(),id:r},r):(o||r)&&console.error("sessionStateSnapshot and instanceId must be provided together")})}async storeSnapshot({schema:t,snapshot:n,sessionId:r,sessionStateSnapshot:o}){await this.tx("readwrite",[Pe.Records,Pe.Schema,Pe.SessionState],async s=>{const i=s.objectStore(Pe.Records),a=s.objectStore(Pe.Schema),l=s.objectStore(Pe.SessionState);await i.clear();for(const[c,u]of Object.entries(n))await i.put(u,c);a.put(t.serialize(),Pe.Schema),o&&r?l.put({snapshot:o,updatedAt:Date.now(),id:r},r):(o||r)&&console.error("sessionStateSnapshot and instanceId must be provided together")})}async pruneSessions(){await this.tx("readwrite",[Pe.SessionState],async t=>{const n=t.objectStore(Pe.SessionState),r=(await n.getAll()).sort((s,i)=>s.updatedAt-i.updatedAt);if(r.length<10){await t.done;return}const o=r.slice(0,r.length-10);for(const{id:s}of o)await n.delete(s)})}async getAsset(t){return await this.tx("readonly",[Pe.Assets],async n=>await n.objectStore(Pe.Assets).get(t))}async storeAsset(t,n){await this.tx("readwrite",[Pe.Assets],async r=>{await r.objectStore(Pe.Assets).put(n,t)})}};g(Jc,"connectedInstances",new Set);let mf=Jc;function aw(){const e=JSON.parse(Kx(sA)||"[]")??[];return Array.isArray(e)?e:[]}function bV(e){const t=new Set(aw());t.add(e),Wx(sA,JSON.stringify([...t]))}function PV(){window.alert(`Oops! We could not save changes to your browser's storage. We now need to reload the page and try again.
|
|
91
|
+
|
|
92
|
+
Keep seeing this message?
|
|
93
|
+
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.
|
|
94
|
+
• If your hard disk is full, try clearing up some space and then reload the page.`)}function CV(){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.
|
|
95
|
+
|
|
96
|
+
Keep seeing this message?
|
|
97
|
+
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.`)}const IV=350,EV=1e4,tI=Symbol("UPDATE_INSTANCE_STATE"),kV=e=>e;class _V{constructor(t){g(this,"onmessage")}postMessage(t){}close(){}}const TV=typeof BroadcastChannel>"u"?_V:BroadcastChannel;class MV{constructor(t,{persistenceKey:n,sessionId:r=gf,onLoad:o,onLoadError:s},i=new TV(`tldraw-tab-sync-${n}`)){g(this,"disposables",new Set);g(this,"diffQueue",[]);g(this,"didDispose",!1);g(this,"shouldDoFullDBWrite",!0);g(this,"isReloading",!1);g(this,"persistenceKey");g(this,"sessionId");g(this,"serializedSchema");g(this,"isDebugging",!1);g(this,"documentTypes");g(this,"$sessionStateSnapshot");g(this,"db");g(this,"initTime",Date.now());g(this,"isPersisting",!1);g(this,"didLastWriteError",!1);g(this,"scheduledPersistTimeout",null);this.store=t,this.channel=i,typeof window<"u"&&(window.tlsync=this),this.persistenceKey=n,this.sessionId=r,this.db=new mf(n),this.disposables.add(()=>this.db.close()),this.serializedSchema=this.store.schema.serialize(),this.$sessionStateSnapshot=UM(this.store),this.disposables.add(t.listen(({changes:a})=>{this.diffQueue.push(a),this.channel.postMessage(kV({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(tI),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 this.db.load({sessionId:this.sessionId})}catch(o){n(o),CV();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??QW(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&&HM(this.store,s)}this.channel.onmessage=({data:o})=>{var a,l;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,(l=(a=window==null?void 0:window.location)==null?void 0:a.reload)==null||l.call(a);return}s.type==="diff"&&(this.debug("applying diff"),mo(()=>{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?EV:IV))}persistIfNeeded(){this.debug("persistIfNeeded",{isPersisting:this.isPersisting,isReloading:this.isReloading,shouldDoFullDBWrite:this.shouldDoFullDBWrite,diffQueueLength:this.diffQueue.length,storeIsPossiblyCorrupt:this.store.isPossiblyCorrupted()}),this.scheduledPersistTimeout&&(clearTimeout(this.scheduledPersistTimeout),this.scheduledPersistTimeout=null),!this.isPersisting&&(this.isReloading||this.store.isPossiblyCorrupted()||(this.shouldDoFullDBWrite||this.diffQueue.length>0)&&this.doPersist())}async doPersist(){if(Xe(!this.isPersisting,"persist already in progress"),this.didDispose)return;this.isPersisting=!0,this.debug("doPersist start");const t=this.diffQueue;this.diffQueue=[];try{if(this.shouldDoFullDBWrite)this.shouldDoFullDBWrite=!1,await this.db.storeSnapshot({schema:this.store.schema,snapshot:this.store.serialize(),sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()});else{const n=Yx(t.filter(r=>r!==tI));await this.db.storeChanges({changes:n,schema:this.store.schema,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),PV(),typeof window<"u"&&window.location.reload()}this.isPersisting=!1,this.debug("doPersist end"),this.schedulePersist()}}function aA(e){const t=P.useRef(e),[n,r]=P.useState(e);n!==t.current&&r(t.current);const o=P.useCallback(s=>{typeof s=="function"?t.current=s(t.current):t.current=s,r(t.current)},[]);return[n,o]}function AV(e){const[t,n]=aA({status:"loading"});return e=Xf(e),P.useEffect(()=>{const{persistenceKey:r,sessionId:o,...s}=e;if(!r){n({status:"not-synced",store:Iu(s)});return}n({status:"loading"});const i=new Qo,a={upload:async(h,p)=>(await u.db.storeAsset(h.id,p),h.id),resolve:async h=>h.props.src?h.props.src.startsWith("asset:")?await i.get(h,async()=>{const p=await u.db.getAsset(h.id);return p?URL.createObjectURL(p):null}):h.props.src:null,...s.assets},l=Iu({...s,assets:a});let c=!1;const u=new MV(l,{sessionId:o,persistenceKey:r,onLoad(){c||n({store:l,status:"synced-local"})},onLoadError(h){c||n({status:"error",error:h})}});return()=>{c=!0,u.close()}},[e,n]),t}function jV(){const e=F(),t=$t();P.useEffect(()=>{const n=s=>t.style.setProperty("--tl-zoom",s.toString()),r=Kk(n,100),o=new kl("useZoomCss",()=>{e.getCurrentPageShapeIds().size<300?n(e.getZoomLevel()):r(e.getZoomLevel())});return o.attach(),o.execute(),()=>{o.detach(),r.cancel()}},[e,t])}function Av(e){const t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let r=0,o=e.length;r<o;r++)n[r]=e.charCodeAt(r);return t}function OV(e){const t=atob(e),n=Av(t);return crypto.subtle.importKey("spki",new Uint8Array(n),{name:"ECDSA",namedCurve:"P-256"},!0,["verify"])}const DV=5,Gh={ANNUAL_LICENSE:1,PERPETUAL_LICENSE:2,INTERNAL_LICENSE:4},RV=Math.max(...Object.values(Gh)),Pc={ID:0,HOSTS:1,FLAGS:2,EXPIRY_DATE:3},LV=Object.keys(Pc).length,eh="sales@tldraw.com";class lw{constructor(t,n,r){g(this,"publicKey","MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHJh0uUfxHtCGyerXmmatE368Hd9rI6LH9oPDQihnaCryRFWEVeOvf9U/SPbyxX74LFyJs5tYeAHq5Nc0Ax25LQ");g(this,"isDevelopment");g(this,"isTest");g(this,"isCryptoAvailable");g(this,"state",Mt("license state","pending"));this.isTest=!1,this.isDevelopment=this.getIsDevelopment(r),this.publicKey=n||this.publicKey,this.isCryptoAvailable=!!crypto.subtle,Vx.enableLicensing.get()?this.getLicenseFromKey(t).then(o=>{const s=$V(o);this.state.set(s?"unlicensed":"licensed")}):this.state.set("licensed")}getIsDevelopment(t){return t==="development"?!0:t==="production"?!1:window.location.protocol!=="https:"}async extractLicenseKey(t){const[n,r]=t.split("."),[o,s]=n.split("/");if(!o.startsWith("tldraw-"))throw new Error(`Unsupported prefix '${o}'`);const i=await OV(this.publicKey);let a;try{a=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},i,new Uint8Array(Av(atob(r))),new Uint8Array(Av(atob(s))))}catch(c){throw console.error(c),new Error("Could not perform signature validation")}if(!a)throw new Error("Invalid signature");let l;try{l=JSON.parse(atob(s))}catch{throw new Error("Could not parse object")}return l.length>LV&&this.outputMessages(["License key contains some unknown properties.","You may want to update tldraw packages to a newer version to get access to new functionality."]),{id:l[Pc.ID],hosts:l[Pc.HOSTS],flags:l[Pc.FLAGS],expiryDate:l[Pc.EXPIRY_DATE]}}async getLicenseFromKey(t){if(!t)return this.isDevelopment||this.outputNoLicenseKeyProvided(),{isLicenseParseable:!1,reason:"no-key-provided"};if(this.isDevelopment&&!this.isCryptoAvailable)return console.log("tldraw: you seem to be in a development environment that does not support crypto. License not verified."),console.log("You should check that this works in production separately."),{isLicenseParseable:!1,reason:"has-key-development-mode"};let n=t.replace(/[\u200B-\u200D\uFEFF]/g,"");n=n.replace(/\r?\n|\r/g,"");try{const r=await this.extractLicenseKey(n),o=new Date(r.expiryDate),s=this.isFlagEnabled(r.flags,Gh.ANNUAL_LICENSE),i=this.isFlagEnabled(r.flags,Gh.PERPETUAL_LICENSE),a={license:r,isLicenseParseable:!0,isDevelopment:this.isDevelopment,isDomainValid:this.isDomainValid(r),expiryDate:o,isAnnualLicense:s,isAnnualLicenseExpired:s&&this.isAnnualLicenseExpired(o),isPerpetualLicense:i,isPerpetualLicenseExpired:i&&this.isPerpetualLicenseExpired(o),isInternalLicense:this.isFlagEnabled(r.flags,Gh.INTERNAL_LICENSE)};return this.outputLicenseInfoIfNeeded(a),a}catch(r){return this.outputInvalidLicenseKey(r.message),{isLicenseParseable:!1,reason:"invalid-license-key"}}}isDomainValid(t){const n=window.location.hostname.toLowerCase();return t.hosts.some(r=>{const o=r.toLowerCase().trim();return o===n||`www.${o}`===n||o===`www.${n}`||r==="*"?!0:r.includes("*")?new RegExp(r.replace(/\*/g,".*?")).test(n):!1})}getExpirationDateWithoutGracePeriod(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}getExpirationDateWithGracePeriod(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate()+DV+1)}isAnnualLicenseExpired(t){const n=this.getExpirationDateWithGracePeriod(t),r=new Date>=n;return!r&&new Date>=this.getExpirationDateWithoutGracePeriod(t)&&this.outputMessages(["tldraw license is about to expire, you are in a grace period.",`Please reach out to ${eh} if you would like to renew your license.`]),r}isPerpetualLicenseExpired(t){const n=this.getExpirationDateWithGracePeriod(t),r={major:new Date(dP.major),minor:new Date(dP.minor)};return r.major>=n||r.minor>=n}isFlagEnabled(t,n){return(t&n)===n}outputNoLicenseKeyProvided(){this.outputMessages(["No tldraw license key provided!",`Please reach out to ${eh} if you would like to license tldraw or if you'd like a trial.`])}outputInvalidLicenseKey(t){this.outputMessages(["Invalid tldraw license key",`Reason: ${t}`])}outputLicenseInfoIfNeeded(t){t.isAnnualLicenseExpired&&this.outputMessages(["Your tldraw license has expired!",`Please reach out to ${eh} to renew.`]),!t.isDomainValid&&!t.isDevelopment&&this.outputMessages(["This tldraw license key is not valid for this domain!",`Please reach out to ${eh} if you would like to use tldraw on other domains.`]),t.license.flags>=RV*2&&this.outputMessages(["This tldraw license contains some unknown flags.","You may want to update tldraw packages to a newer version to get access to new functionality."])}outputMessages(t){if(!this.isTest){this.outputDelimiter();for(const n of t)console.log(`%c${n}`,"color: white; background: crimson; padding: 2px; border-radius: 3px;");this.outputDelimiter()}}outputDelimiter(){console.log("%c-------------------------------------------------------------------","color: white; background: crimson; padding: 2px; border-radius: 3px;")}}g(lw,"className","tl-watermark_SEE-LICENSE");function $V(e){if(!e.isLicenseParseable||!e.isDomainValid&&!e.isDevelopment)return!0;if(e.isPerpetualLicenseExpired||e.isAnnualLicenseExpired){if(e.isInternalLicense)throw new Error("License: Internal license expired.");return!0}return!1}const lA=P.createContext({}),NV=()=>P.useContext(lA);function FV({licenseKey:e,children:t}){const[n]=P.useState(()=>new lw(e));return d.jsx(lA.Provider,{value:n,children:t})}const zV='<svg xmlns="http://www.w3.org/2000/svg" width="3001" height="1000" fill="none"><path fill="#000" d="M590.656 300.449c0 49.706-40.294 90-90 90-49.705 0-90-40.294-90-90 0-49.705 40.295-90 90-90 49.706 0 90 40.295 90 90M569.431 719.011c-15.247 32.821-56.006 91.589-98.338 91.438-32.004-.115-38.642-30.904-17.414-50.856 17.381-16.337 28.246-48.075 31.995-72.719.415-2.728-1.556-5.197-4.272-5.679-39.666-7.04-70.746-40.877-70.746-83.417 0-48.23 38.983-87.329 87.07-87.329 39.936 0 70.172 22.237 83.369 52.397 18.839 43.055 7.117 115.733-11.664 156.165M2613.29 385.681V239.319c0-11.363 9.22-20.569 20.59-20.569h8.26c11.37 0 20.59 9.206 20.59 20.569v36.911c0 8.629 7 15.625 15.63 15.625h35.25c8.63 0 15.63-6.996 15.63-15.625v-36.911c0-11.363 9.22-20.569 20.59-20.569h8.17c11.37 0 20.59 9.206 20.59 20.569v146.362c0 11.363-9.22 20.569-20.59 20.569h-8.17c-11.37 0-20.59-9.206-20.59-20.569v-36.999c0-8.63-7-15.625-15.63-15.625h-35.25c-8.63 0-15.63 6.995-15.63 15.625v36.999c0 11.363-9.22 20.569-20.59 20.569h-8.26c-11.37 0-20.59-9.206-20.59-20.569M2391.97 239.319v146.362c0 11.348-9.16 20.569-20.49 20.569h-8.2c-11.33 0-20.49-9.221-20.49-20.569V239.319c0-11.348 9.16-20.569 20.49-20.569h8.2c11.33 0 20.49 9.221 20.49 20.569M2098.23 391.43l-42.69-146.361c-3.85-13.171 6.06-26.319 19.79-26.319h10.6c9.59 0 17.93 6.611 20.08 15.952l17.01 73.045c1.48 6.348 10.47 6.478 12.14.176l19.47-73.838c2.38-9.04 10.57-15.335 19.93-15.335h12.1c9.37 0 17.56 6.3 19.94 15.346l19.49 74.067c1.66 6.305 10.65 6.178 12.13-.171l17.09-73.294c2.15-9.339 10.49-15.948 20.08-15.948h10.53c13.72 0 23.63 13.141 19.79 26.31l-42.63 146.361c-2.56 8.789-10.63 14.829-19.79 14.829h-15.68c-9.12 0-17.16-5.98-19.76-14.709l-21.17-71.059c-1.77-5.948-10.19-5.957-11.97-.012l-21.33 71.071c-2.6 8.729-10.64 14.709-19.76 14.709h-15.59c-9.17 0-17.23-6.035-19.8-14.82M2443.23 218.75h118.59c11.38 0 20.62 9.195 20.62 20.557s-9.24 20.556-20.62 20.556h-24.79c-5.53 0-10 4.477-10 10v115.818c0 11.368-9.25 20.569-20.63 20.569h-7.65c-11.39 0-20.63-9.201-20.63-20.569V269.863c0-5.523-4.48-10-10-10h-24.89c-11.37 0-20.61-9.195-20.61-20.556s9.24-20.557 20.61-20.557M1174.15 218.75h24.64c8.35 0 15.88 5.042 19.04 12.764l34.61 83.942c2.13 5.161 9.44 5.155 11.56-.01l34.43-83.932a20.58 20.58 0 0 1 19.04-12.764h24.64c11.37 0 20.58 9.208 20.58 20.569v146.362c0 11.361-9.21 20.569-20.58 20.569h-7.09c-11.36 0-20.58-9.208-20.58-20.569l-.12-50.645c-.01-6.888-9.53-8.688-12.06-2.283l-23.46 59.332a20.57 20.57 0 0 1-19.14 13.009h-3.03a20.57 20.57 0 0 1-19.15-13.046l-23.47-59.68c-2.52-6.416-12.05-4.623-12.06 2.271l-.13 51.042c0 11.361-9.21 20.569-20.57 20.569h-7.1c-11.36 0-20.57-9.208-20.57-20.569V239.319c0-11.361 9.21-20.569 20.57-20.569"/><path fill="#000" fill-rule="evenodd" d="m1449.94 391.836 6.12-19.392a6.255 6.255 0 0 1 5.96-4.369l50.22-.061a6.24 6.24 0 0 1 5.96 4.348l6.23 19.486c2.71 8.581 10.71 14.402 19.74 14.402h9.34c14.13 0 24.15-13.791 19.61-27.151l-49.74-146.361c-2.85-8.37-10.74-13.988-19.61-13.988h-33.16c-8.87 0-16.77 5.618-19.61 13.988l-49.74 146.361c-4.54 13.36 5.48 27.151 19.61 27.151h9.32c9.04 0 17.04-5.827 19.75-14.414m31.1-98.858c1.85-5.807 10.08-5.796 11.91.016l8.83 27.916c1.28 4.028-1.73 8.134-5.96 8.134h-17.74c-4.23 0-7.24-4.119-5.95-8.151zM1681.81 406.25c18.91 0 35.39-3.686 49.36-11.168 13.97-7.544 24.73-18.394 32.24-32.489 7.56-14.105 11.29-30.866 11.29-50.182 0-19.256-3.73-35.957-11.29-50.004-7.57-14.094-18.35-24.912-32.32-32.397-13.91-7.545-30.4-11.26-49.37-11.26h-49.5c-11.38 0-20.63 9.201-20.63 20.569v146.362c0 11.368 9.25 20.569 20.63 20.569zm23.13-47.701c-6.62 3.215-14.85 4.886-24.79 4.886-10.49 0-19-8.507-19-19v-64.34c0-10.149 8.23-18.376 18.38-18.376 10.18 0 18.56 1.703 25.23 4.974 6.59 3.149 11.63 8.315 15.08 15.633 3.45 7.269 5.28 17.268 5.28 30.162 0 12.891-1.82 22.951-5.28 30.347-3.39 7.319-8.36 12.509-14.9 15.714" clip-rule="evenodd"/><path fill="#000" d="M1804.21 385.681V239.319c0-11.361 9.21-20.569 20.58-20.569h91.28c11.36 0 20.57 9.202 20.57 20.557s-9.21 20.556-20.57 20.556h-54.64a7.807 7.807 0 0 0-7.81 7.813v16.366a7.806 7.806 0 0 0 7.81 7.812h48.13c11.37 0 20.58 9.246 20.58 20.602s-9.21 20.601-20.58 20.601h-48.13a7.806 7.806 0 0 0-7.81 7.812v16.455a7.807 7.807 0 0 0 7.81 7.813h54.64c11.36 0 20.57 9.202 20.57 20.556s-9.21 20.557-20.57 20.557h-91.28c-11.37 0-20.58-9.208-20.58-20.569"/><path fill="#000" fill-rule="evenodd" d="M2875.5 68.75h-2750c-31.066 0-56.25 25.184-56.25 56.25v750c0 31.066 25.184 56.25 56.25 56.25h2750c31.07 0 56.25-25.184 56.25-56.25V125c0-31.066-25.18-56.25-56.25-56.25M125.5 0C56.464 0 .5 55.964.5 125v750c0 69.036 55.965 125 125 125h2750c69.04 0 125-55.964 125-125V125c0-69.036-55.96-125-125-125z" clip-rule="evenodd"/><path fill="#000" d="M2476.06 804.813c-10.54 0-19.82-6.947-22.81-17.068L2390.79 575.7c-4.49-15.248 6.92-30.534 22.8-30.534h27.75c11.1 0 20.72 7.686 23.18 18.52L2489 671.402c2.07 9.093 14.93 9.321 17.32.308l28.83-108.844c2.76-10.435 12.19-17.7 22.98-17.7h25.17c10.8 0 20.25 7.293 22.99 17.755l28.27 107.739c2.36 9.001 15.18 8.829 17.3-.232l25.01-106.888c2.51-10.763 12.1-18.374 23.14-18.374h27.87c15.88 0 27.29 15.286 22.8 30.534l-62.46 212.045a23.78 23.78 0 0 1-22.81 17.068h-32.12c-10.39 0-19.58-6.763-22.69-16.696l-32.08-102.694c-2.62-8.397-14.51-8.331-17.04.095l-30.74 102.346c-3.02 10.061-12.27 16.949-22.76 16.949zM1742.44 804.813h-75.81c-13.09 0-23.71-10.656-23.71-23.801V568.967c0-13.145 10.62-23.801 23.71-23.801h74.8c26.6 0 49.59 5.198 68.95 15.594 19.45 10.312 34.44 25.187 44.96 44.627 10.61 19.355 15.91 42.556 15.91 69.602q0 40.57-15.78 69.73c-10.53 19.355-25.43 34.231-44.71 44.627-19.28 10.311-42.05 15.467-68.32 15.467m-29.3-83.642c0 13.145 10.61 23.801 23.71 23.801h3.06c12.8 0 23.7-2.07 32.71-6.212 9.09-4.141 16-11.283 20.71-21.426q7.2-15.213 7.2-42.345 0-27.13-7.32-42.344c-4.8-10.143-11.87-17.285-21.22-21.426-9.26-4.142-20.63-6.212-34.1-6.212h-1.04c-13.1 0-23.71 10.656-23.71 23.801zM1460.86 804.813c-13.12 0-23.76-10.656-23.76-23.801V568.967c0-13.145 10.64-23.801 23.76-23.801h22.84c13.13 0 23.76 10.656 23.76 23.801v155.247c0 13.145 10.64 23.801 23.76 23.801h57.27c13.12 0 23.76 10.656 23.76 23.801v9.196c0 13.145-10.64 23.801-23.76 23.801zM1204.45 601.964c-13.13 0-23.77-10.656-23.77-23.801v-9.196c0-13.145 10.64-23.801 23.77-23.801h177.89c13.13 0 23.78 10.656 23.78 23.801v9.196c0 13.145-10.65 23.801-23.78 23.801h-39.38c-8.21 0-14.86 6.66-14.86 14.875v164.173c0 13.145-10.64 23.801-23.78 23.801h-21.85c-13.13 0-23.78-10.656-23.78-23.801V616.839c0-8.215-6.65-14.875-14.86-14.875z"/><path fill="#000" fill-rule="evenodd" d="M2223.05 787.891c-3.02 10.047-12.27 16.922-22.74 16.922h-25.43c-16.19 0-27.64-15.862-22.57-31.261l69.88-212.045c3.21-9.753 12.31-16.341 22.56-16.341h61.84c10.25 0 19.35 6.588 22.56 16.341l69.87 212.045c5.08 15.399-6.37 31.261-22.56 31.261h-25.43c-10.48 0-19.72-6.875-22.74-16.922l-6.7-22.2a14.84 14.84 0 0 0-14.21-10.576h-63.42c-6.55 0-12.32 4.296-14.22 10.576zm76.13-96.945-14.13-48.436c-2.46-8.451-14.36-8.602-17.04-.217l-15.46 48.436c-1.84 5.759 2.45 11.645 8.48 11.645h29.6c5.94 0 10.22-5.715 8.55-11.428" clip-rule="evenodd"/><path fill="#000" d="M1939.6 804.813c-13.13 0-23.77-10.656-23.77-23.801V568.967c0-13.145 10.64-23.801 23.77-23.801h88.13c19.24 0 36.08 3.508 50.51 10.523s25.65 17.115 33.67 30.3q12.03 19.779 12.03 47.416c0 18.595-4.14 34.273-12.41 47.036-7.64 11.913-18.18 21.101-31.63 27.564-16.98 8.159-36 11.104-54.7 11.104h-43.07c-76.56 0 4.08-135.84 4.08-84.706v7.996c0 12.117 9.81 21.941 21.91 21.941 8.12 0 16.3-.345 24.04-3.043 5.91-2.113 10.43-5.451 13.55-10.015 3.2-4.565 4.81-10.523 4.81-17.877 0-7.437-1.61-13.481-4.81-18.129-3.12-4.733-7.64-8.199-13.55-10.396-7.05-2.766-14.67-3.423-22.18-3.423-13.13 0-23.77 10.656-23.77 23.801v47.71c0 11.825 11.14 16.003 19.91 20.752 12.31 6.671 7.58 25.389-6.42 25.389-7.45 0-13.49 6.048-13.49 13.508v48.395c0 13.145-10.63 23.801-23.76 23.801zm134.89-106.758 5.41 9.95 33.51 61.622c8.62 15.86-2.84 35.186-20.87 35.186h-22.27c-8.74 0-16.77-4.798-20.92-12.496l-35.05-65.04a15.52 15.52 0 0 0-13.66-8.168c-42.24 0 40.62-82.154 73.85-21.054M931.652 0h68.748v1000h-68.748z"/></svg>',BV=`${Os()}/watermarks/watermark-desktop.svg`,th=`data:image/svg+xml;utf8,${encodeURIComponent(zV)}`;let cy=null;async function UV(e){return e?th:(cy||(cy=Promise.race([(async()=>{try{const t=await bo(BV);if(!t.ok)return th;const n=await t.blob();return URL.createObjectURL(n)}catch{return th}})(),new Promise(t=>{setTimeout(()=>{t(th)},3e3)})])),cy)}const HV=Ce.memo(function({forceLocal:t=!1}){const n=o2(),r=F(),o=NV(),s=K("show watermark",()=>Vx.enableLicensing.get()&&r.getViewportScreenBounds().width>760&&o.state.get()==="unlicensed",[r,o]),i=K("debug mode",()=>r.getInstanceState().isDebugMode,[r]),a=K("is menu open",()=>r.getIsMenuOpen(),[r]),[l,c]=P.useState(null),u=t||o.isDevelopment;if(P.useEffect(()=>{if(!s)return;let f=!1;return(async()=>{const S=await UV(u);f||c(S)})(),()=>{f=!0}},[u,s]),!s||!l)return null;const h=lw.className,p=`url('${l}') center 100% / 100% no-repeat`;return d.jsxs(d.Fragment,{children:[d.jsx("style",{children:`
|
|
98
|
+
/* ------------------- SEE LICENSE -------------------
|
|
99
|
+
The tldraw watermark is part of tldraw's license. It is shown for unlicensed
|
|
100
|
+
users. By using this library, you agree to keep the watermark's behavior,
|
|
101
|
+
keeping it visible, unobscured, and available to user-interaction.
|
|
102
|
+
|
|
103
|
+
To remove the watermark, please purchase a license at tldraw.dev.
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
.${h} {
|
|
107
|
+
position: absolute;
|
|
108
|
+
bottom: var(--space-2);
|
|
109
|
+
right: var(--space-2);
|
|
110
|
+
width: 96px;
|
|
111
|
+
height: 32px;
|
|
112
|
+
z-index: 2147483647 !important;
|
|
113
|
+
pointer-events: ${a?"none":"all"};
|
|
114
|
+
background-color: color-mix(in srgb, var(--color-background) 62%, transparent);
|
|
115
|
+
border-radius: 5px;
|
|
116
|
+
padding: 2px;
|
|
117
|
+
box-sizing: content-box;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.${h}[data-debug='true'] {
|
|
121
|
+
bottom: 46px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.${h} > a {
|
|
125
|
+
position: absolute;
|
|
126
|
+
width: 96px;
|
|
127
|
+
height: 32px;
|
|
128
|
+
pointer-events: none;
|
|
129
|
+
cursor: inherit;
|
|
130
|
+
color: var(--color-text);
|
|
131
|
+
background-color: currentColor;
|
|
132
|
+
opacity: .28;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@media (hover: hover) {
|
|
136
|
+
.${h}:hover {
|
|
137
|
+
background-color: var(--color-background);
|
|
138
|
+
transition: background-color 0.2s ease-in-out;
|
|
139
|
+
transition-delay: 0.32s;
|
|
140
|
+
}
|
|
141
|
+
.${h}:hover > a {
|
|
142
|
+
animation: delayed_link 0.2s forwards ease-in-out;
|
|
143
|
+
animation-delay: 0.32s;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@keyframes delayed_link {
|
|
148
|
+
0% {
|
|
149
|
+
cursor: inherit;
|
|
150
|
+
opacity: .38;
|
|
151
|
+
pointer-events: none;
|
|
152
|
+
}
|
|
153
|
+
100% {
|
|
154
|
+
cursor: pointer;
|
|
155
|
+
opacity: 1;
|
|
156
|
+
pointer-events: all;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
`}),d.jsx("div",{className:h,"data-debug":i,draggable:!1,...n,children:d.jsx("a",{href:"https://tldraw.dev",target:"_blank",rel:"noreferrer",draggable:!1,onPointerDown:Ot,style:{mask:p,WebkitMask:p}})})]})}),KV=[],WV=[],GV=[],VV="tl-container",YV=P.memo(function({store:t,components:n,className:r,user:o,...s}){const[i,a]=Ce.useState(null),l=P.useMemo(()=>o??L2(),[o]),c=(n==null?void 0:n.ErrorFallback)===void 0?k2:n==null?void 0:n.ErrorFallback,u={...s,shapeUtils:s.shapeUtils??KV,bindingUtils:s.bindingUtils??WV,tools:s.tools??GV,components:n};return d.jsx("div",{ref:a,"data-tldraw":J_,draggable:!1,className:ce(`${VV} tl-theme__light`,r),onPointerDown:Ot,tabIndex:-1,children:d.jsx(au,{fallback:c,onError:h=>Ux(h,{tags:{origin:"react.tldraw-before-app"}}),children:i&&d.jsx(FV,{licenseKey:s.licenseKey,children:d.jsx(_9,{container:i,children:d.jsx(jH,{overrides:n,children:t?t instanceof Xx?d.jsx(uA,{...u,store:t,user:l}):d.jsx(cA,{...u,store:t,user:l}):d.jsx(XV,{...u,store:t,user:l})})})})})})});function XV(e){const{defaultName:t,snapshot:n,initialData:r,shapeUtils:o,bindingUtils:s,persistenceKey:i,sessionId:a,user:l,assets:c}=e,u=AV({shapeUtils:o,bindingUtils:s,initialData:r,persistenceKey:i,sessionId:a,defaultName:t,snapshot:n,assets:c});return d.jsx(cA,{...e,store:u,user:l})}const cA=P.memo(function({store:t,user:n,...r}){const o=$t();P.useLayoutEffect(()=>{n.userPreferences.get().colorScheme==="dark"&&(o.classList.remove("tl-theme__light"),o.classList.add("tl-theme__dark"))},[o,n]);const{LoadingScreen:s}=st();switch(t.status){case"error":throw t.error;case"loading":return s?d.jsx(s,{}):null}return d.jsx(uA,{...r,store:t.store,user:n})}),uy=()=>document.location.search.includes("tldraw_preserve_focus");function uA({onMount:e,children:t,store:n,tools:r,shapeUtils:o,bindingUtils:s,user:i,initialState:a,autoFocus:l=!0,inferDarkMode:c,cameraOptions:u,options:h,licenseKey:p}){const{ErrorFallback:f}=st(),S=$t(),[y,x]=aA(null),m=P.useRef({autoFocus:l&&!uy(),inferDarkMode:c,initialState:a,cameraOptions:u});P.useLayoutEffect(()=>{m.current={autoFocus:l&&!uy(),inferDarkMode:c,initialState:a,cameraOptions:u}},[l,c,a,u]),P.useLayoutEffect(()=>{const{autoFocus:C,inferDarkMode:E,initialState:_,cameraOptions:I}=m.current,k=new Z({store:n,shapeUtils:o,bindingUtils:s,tools:r,getContainer:()=>S,user:i,initialState:_,autoFocus:C,inferDarkMode:E,cameraOptions:I,options:h,licenseKey:p});return x(k),()=>{k.dispose()}},[s,S,h,o,n,r,i,x,p]),P.useLayoutEffect(()=>{y&&u&&y.setCameraOptions(u)},[y,u]);const v=P.useSyncExternalStore(P.useCallback(C=>y?(y.on("crash",C),()=>y.off("crash",C)):()=>{},[y]),()=>(y==null?void 0:y.getCrashingError())??null);P.useEffect(function(){if(!y)return;function E(){y&&y.focus()}function _(){y&&y.blur()}if(l&&uy())return y.getContainer().addEventListener("pointerdown",E),document.body.addEventListener("pointerdown",_),()=>{var I;(I=y.getContainer())==null||I.removeEventListener("pointerdown",E),document.body.removeEventListener("pointerdown",_)}},[y,l]);const{Canvas:w}=st();return y?d.jsx(au,{fallback:f,onError:C=>y.annotateError(C,{origin:"react.tldraw",willCrashApp:!0}),children:v?d.jsx(ZV,{crashingError:v}):d.jsx(Vf.Provider,{value:y,children:d.jsxs(qV,{onMount:e,children:[t??(w?d.jsx(w,{}):null),d.jsx(HV,{})]})})}):null}function qV({children:e,onMount:t}){return jV(),rV(),oV(),sV(),hA(n=>{const r=n.store.props.onMount(n),o=t==null?void 0:t(n);return()=>{r==null||r(),o==null||o()}}),e}function ZV({crashingError:e}){throw e}function cw({children:e}){return d.jsx("div",{className:"tl-loading",children:e})}function dA({children:e}){return d.jsx("div",{className:"tl-loading",children:e})}function hA(e){const t=F(),n=eA(r=>{let o;return r.run(()=>{o=e==null?void 0:e(r),r.emit("mount")},{history:"ignore"}),window.tldrawReady=!0,o});Ce.useLayoutEffect(()=>{if(t)return n==null?void 0:n(t)},[t,n])}function Gi({children:e,className:t="",...n}){return d.jsx("div",{...n,className:ce("tl-html-container",t),children:e})}class Vh{constructor(t){this.editor=t}}g(Vh,"props"),g(Vh,"migrations"),g(Vh,"type");function uw(e,t,n={}){const{newPoint:r,handle:o,scaleX:s,scaleY:i}=t,{minWidth:a=1,maxWidth:l=1/0,minHeight:c=1,maxHeight:u=1/0}=n;let h=e.props.w*s,p=e.props.h*i;const f=new b(0,0);if(h>0){if(h<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=h-a;break}case"top":case"bottom":{f.x=(h-a)/2;break}default:f.x=0}h=a}}else if(f.x=h,h=-h,h<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=-h;break}default:f.x=-a}h=a}if(p>0){if(p<c){switch(o){case"top_left":case"top":case"top_right":{f.y=p-c;break}case"right":case"left":{f.y=(p-c)/2;break}default:f.y=0}p=c}}else if(f.y=p,p=-p,p<c){switch(o){case"top_left":case"top":case"top_right":{f.y=-p;break}default:f.y=-c}p=c}const{x:S,y}=f.rot(e.rotation).add(r);return{...e,x:S,y,props:{w:Math.min(l,h),h:Math.min(u,p)}}}class Dl extends Wr{constructor(){super(...arguments);g(this,"onResize",(n,r)=>uw(n,r))}getGeometry(n){return new os({width:n.props.w,height:n.props.h,isFilled:!0})}getHandleSnapGeometry(n){return{points:this.getGeometry(n).bounds.cornersAndCenter}}getInterpolatedProps(n,r,o){return{...r.props,w:Dn(n.props.w,r.props.w,o),h:Dn(n.props.h,r.props.h,o)}}}var Fy;let QV=(Fy=class extends oe{constructor(){super(...arguments);g(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});g(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});g(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},g(Fy,"id","idle"),Fy);var zy;let JV=(zy=class extends oe{constructor(){super(...arguments);g(this,"markId","");g(this,"wasFocusedOnEnter",!1);g(this,"onEnter",()=>{this.wasFocusedOnEnter=!this.editor.getIsMenuOpen()});g(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){const{originPagePoint:r}=this.editor.inputs,o=this.parent.shapeType,s=$e();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})}});g(this,"onPointerUp",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.complete()});g(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=$e();this.editor.mark(this.markId),this.editor.createShapes([{id:o,type:r,x:n.x,y:n.y}]);const s=this.editor.getShape(o);if(!s){this.cancel();return}let{w:i,h:a}=s.props;const l=new b(i/2,a/2),c=this.editor.getShapeParentTransform(s);c&&l.rot(-c.rotation());let u=1;this.editor.user.getIsDynamicResizeMode()&&(u=1/this.editor.getZoomLevel(),i*=u,a*=u,l.mul(u));const h=Ge(s);h.x=s.x-l.x,h.y=s.y-l.y,h.props.w=i,h.props.h=a,"scale"in s.props&&(h.props.scale=u),this.editor.updateShape(h),this.editor.setSelectedShapes([o]),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select.idle")}cancel(){this.parent.transition("idle")}},g(zy,"id","pointing"),zy);class Yh extends oe{constructor(){super(...arguments);g(this,"onCreate")}}g(Yh,"id","box"),g(Yh,"initial","idle"),g(Yh,"children",()=>[QV,JV]);function gg(e){const t=F();return K("isEditing",()=>t.getEditingShapeId()===e,[t,e])}function io(e){const t=F();return P.useMemo(function(){const o=c=>{if(c.isKilled)return;if(c.button===s0){t.dispatch({type:"pointer",target:"selection",handle:e,name:"right_click",...Fn(c)});return}if(c.button!==0)return;const u=Up(c.currentTarget);function h(){u.removeEventListener("pointerup",h),Gu(u,c)}Wu(u,c),u.addEventListener("pointerup",h),t.dispatch({name:"pointer_down",type:"pointer",target:"selection",handle:e,...Fn(c)}),Ot(c)};let s,i;function a(c){c.isKilled||c.button===0&&(c.clientX===s&&c.clientY===i||(s=c.clientX,i=c.clientY,t.dispatch({name:"pointer_move",type:"pointer",target:"selection",handle:e,...Fn(c)})))}return{onPointerDown:o,onPointerMove:a,onPointerUp:c=>{c.isKilled||c.button===0&&t.dispatch({name:"pointer_up",type:"pointer",target:"selection",handle:e,...Fn(c)})}}},[t,e])}function eY(e){const[t,n]=P.useState(()=>({store:Iu(e),opts:e}));if(!qk(t.opts,e)){const r={store:Iu(e),opts:e};return n(r),r.store}return t.store}const tY=20,nY=8;function dw(e,t=tY){return Math.max(nY,Math.ceil(e/t))}class Ua extends ii{constructor(n){super({...n,isFilled:!1,isClosed:!1});g(this,"_center");g(this,"radius");g(this,"start");g(this,"end");g(this,"largeArcFlag");g(this,"sweepFlag");g(this,"measure");g(this,"angleStart");g(this,"angleEnd");const{center:r,sweepFlag:o,largeArcFlag:s,start:i,end:a}=n;if(i.equals(a))throw Error("Arc must have different start and end points.");this.angleStart=b.Angle(r,i),this.angleEnd=b.Angle(r,a),this.radius=b.Dist(r,i),this.measure=P9(this.angleStart,this.angleEnd,o,s),this.start=i,this.end=a,this.sweepFlag=o,this.largeArcFlag=s,this._center=r}nearestPoint(n){const{_center:r,measure:o,radius:s,angleEnd:i,angleStart:a,start:l,end:c}=this,u=MS(o,a,i,r.angle(n));if(u<=0)return l;if(u>=1)return c;const h=r.clone().add(n.clone().sub(r).uni().mul(s));let p,f=1/0,S;for(const y of[l,c,h])S=b.Dist2(n,y),S<f&&(p=y,f=S);if(!p)throw Error("nearest point not found");return p}hitTestLineSegment(n,r){const{_center:o,radius:s,measure:i,angleStart:a,angleEnd:l}=this,c=Ju(n,r,o,s);return c===null?!1:c.some(u=>{const h=MS(i,a,l,o.angle(u));return h>=0&&h<=1})}getVertices(){const{_center:n,measure:r,length:o,radius:s,angleStart:i}=this,a=[];for(let l=0,c=dw(Math.abs(o));l<c+1;l++){const u=l/c*r,h=i+u;a.push(zi(n,s,h))}return a}getSvgPathData(n=!0){const{start:r,end:o,radius:s,largeArcFlag:i,sweepFlag:a}=this;return`${n?`M${r.toFixed()}`:""} A${s} ${s} 0 ${i} ${a} ${o.toFixed()}`}getLength(){return this.measure*this.radius}}class hw extends ii{constructor(n){super({isClosed:!0,...n});g(this,"_center");g(this,"radius");g(this,"x");g(this,"y");this.config=n;const{x:r=0,y:o=0,radius:s}=n;this.x=r,this.y=o,this._center=new b(s+r,s+o),this.radius=s}getBounds(){return new Q(this.x,this.y,this.radius*2,this.radius*2)}getVertices(){const{_center:n,radius:r}=this,o=Le*r,s=[];for(let i=0,a=dw(o);i<a;i++){const l=i/a*Le;s.push(zi(n,r,l))}return s}nearestPoint(n){const{_center:r,radius:o}=this;return r.equals(n)?b.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 Ju(n,r,s,i+o)!==null}getSvgPathData(){const{_center:n,radius:r}=this;return`M${n.x+r},${n.y} a${r},${r} 0 1,0 ${r*2},0a${r},${r} 0 1,0 -${r*2},0`}}class sn extends Ol{constructor(n){const{start:r,cp1:o,cp2:s,end:i}=n;super({...n,points:[r,i]});g(this,"a");g(this,"b");g(this,"c");g(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,l=10;a<=l;a++){const c=a/l;n.push(new b((1-c)*(1-c)*(1-c)*r.x+3*((1-c)*(1-c))*c*o.x+3*(1-c)*(c*c)*s.x+c*c*c*i.x,(1-c)*(1-c)*(1-c)*r.y+3*((1-c)*(1-c))*c*o.y+3*(1-c)*(c*c)*s.y+c*c*c*i.y))}return n}midPoint(){return sn.GetAtT(this,.5)}nearestPoint(n){let r,o=1/0,s,i;for(const a of this.segments)i=a.nearestPoint(n),s=b.Dist2(i,n),s<o&&(r=i,o=s);if(!r)throw Error("nearest point not found");return r}getSvgPathData(n=!0){const{a:r,b:o,c:s,d:i}=this;return`${n?`M ${r.toFixed()} `:""} C${o.toFixed()} ${s.toFixed()} ${i.toFixed()}`}static GetAtT(n,r){const{a:o,b:s,c:i,d:a}=n;return new b((1-r)*(1-r)*(1-r)*o.x+3*((1-r)*(1-r))*r*s.x+3*(1-r)*(r*r)*i.x+r*r*r*a.x,(1-r)*(1-r)*(1-r)*o.y+3*((1-r)*(1-r))*r*s.y+3*(1-r)*(r*r)*i.y+r*r*r*a.y)}getLength(n=32){let r,o=this.a,s=0;for(let i=1;i<=n;i++)r=sn.GetAtT(this,i/n),s+=b.Dist(o,r),o=r;return s}}class rY extends ii{constructor(n){super({...n,isClosed:!1,isFilled:!1});g(this,"points");g(this,"_segments");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],l=n[i],c=n[i+1],u=i===o?c:n[i+2],h=l,p=i===0?a:new b(l.x+(c.x-a.x)/6*s,l.y+(c.y-a.y)/6*s),f=i===o?c:new b(c.x-(u.x-l.x)/6*s,c.y-(u.y-l.y)/6*s),S=c;this._segments.push(new sn({start:h,cp1:p,cp2:f,end:S}))}}return this._segments}getLength(){return this.segments.reduce((n,r)=>n+r.length,0)}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=b.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))}getSvgPathData(){let n=this.segments.reduce((r,o,s)=>r+o.getSvgPathData(s===0),"");return this.isClosed&&(n+="Z"),n}}class oY extends ii{constructor(n){super({...n,isClosed:!0});g(this,"w");g(this,"h");g(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 Wo({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=Me*(o+s)*(1+3*i/(10+Math.sqrt(4-3*i))),l=dw(a),c=Le/l,u=Math.cos(c),h=Math.sin(c);let p=0,f=1,S=0,y=1;const x=Array(l);for(let m=0;m<l;m++)x[m]=new b(o+o*f,s+s*p),S=h*f+u*p,y=u*f-h*p,p=S,f=y;return x}nearestPoint(n){let r,o=1/0,s,i;for(const a of this.edges)i=a.nearestPoint(n),s=b.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 Q(0,0,this.w,this.h)}getLength(){const{w:n,h:r}=this,o=n/2,s=r/2,i=Math.max(0,o),a=Math.max(0,s);return t2(i,a)}getSvgPathData(n=!1){const{w:r,h:o}=this,s=r/2,i=o/2,a=Math.max(0,s),l=Math.max(0,i);return`${n?`M${s-a},${i}`:""} a${a},${l},0,1,1,${a*2},0a${a},${l},0,1,1,-${a*2},0`}}class sY extends ii{constructor(n){super({...n,isClosed:!0});g(this,"w");g(this,"h");g(this,"a");g(this,"b");g(this,"c");g(this,"d");this.config=n;const{width:r,height:o}=n;if(this.w=r,this.h=o,o>r){const s=r/2;this.a=new Ua({start:new b(0,s),end:new b(r,s),center:new b(r/2,s),sweepFlag:1,largeArcFlag:1}),this.b=new Wo({start:new b(r,s),end:new b(r,o-s)}),this.c=new Ua({start:new b(r,o-s),end:new b(0,o-s),center:new b(r/2,o-s),sweepFlag:1,largeArcFlag:1}),this.d=new Wo({start:new b(0,o-s),end:new b(0,s)})}else{const s=o/2;this.a=new Ua({start:new b(s,o),end:new b(s,0),center:new b(s,s),sweepFlag:1,largeArcFlag:1}),this.b=new Wo({start:new b(s,0),end:new b(r-s,0)}),this.c=new Ua({start:new b(r-s,0),end:new b(r-s,o),center:new b(r-s,s),sweepFlag:1,largeArcFlag:1}),this.d=new Wo({start:new b(r-s,o),end:new b(s,o)})}}nearestPoint(n){let r,o=1/0,s,i;const{a,b:l,c,d:u}=this;for(const h of[a,l,c,u])i=h.nearestPoint(n),s=b.Dist2(i,n),s<o&&(r=i,o=s);if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(n,r){const{a:o,b:s,c:i,d:a}=this;return[o,s,i,a].some(l=>l.hitTestLineSegment(n,r))}getVertices(){const{a:n,b:r,c:o,d:s}=this;return[n,r,o,s].reduce((i,a)=>(i.push(...a.vertices),i),[])}getBounds(){return new Q(0,0,this.w,this.h)}getLength(){const{h:n,w:r}=this;return n>r?(Me*(r/2)+(n-r))*2:(Me*(n/2)+(r-n))*2}getSvgPathData(){const{a:n,b:r,c:o,d:s}=this;return[n,r,o,s].map((i,a)=>i.getSvgPathData(a===0)).join(" ")+" Z"}}async function iY({shouldReload:e=!0}={}){jB();for(const t of mf.connectedInstances)await t.close();await Promise.all(aw().map(t=>oA(t))),AB(),e&&window.location.reload()}typeof window<"u"&&(window.__tldraw__hardReset=iY);function aY(e,t="_blank"){c0.openWindow(e,t)}function lY({children:e}){const t=F();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])?d.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:e}):null}const{PI:cY}=Math,nl=cY+1e-4;function pA(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),l=[],c=[];let u=e[0].vector,h=e[0].point,p=h,f=h,S=p,y=!1,x;for(let m=0;m<e.length;m++){x=e[m];const{point:v,vector:w}=e[m],C=x.vector.dpr(u),E=(m<e.length-1?e[m+1]:e[m]).vector,_=m<e.length-1?E.dpr(x.vector):1,I=C<0&&!y,k=_!==null&&_<.2;if(I||k){if(_>-.62&&i-x.runningLength>x.radius){const M=u.clone().mul(x.radius);u.clone().cpr(E)<0?(f=b.Add(v,M),S=b.Sub(v,M)):(f=b.Sub(v,M),S=b.Add(v,M)),l.push(f),c.push(S)}else{const M=u.clone().mul(x.radius).per(),D=b.Sub(x.input,M);for(let $=1/13,j=0;j<1;j+=$)f=b.RotWith(D,x.input,nl*j),l.push(f),S=b.RotWith(D,x.input,nl+nl*-j),c.push(S)}h=f,p=S,k&&(y=!0);continue}if(y=!1,x===o||x===s){const M=b.Per(w).mul(x.radius);l.push(b.Sub(v,M)),c.push(b.Add(v,M));continue}const T=b.Lrp(E,w,_).per().mul(x.radius);f=b.Sub(v,T),(m<=1||b.Dist2(h,f)>a)&&(l.push(f),h=f),S=b.Add(v,T),(m<=1||b.Dist2(p,S)>a)&&(c.push(S),p=S),u=w}return{left:l,right:c}}function pw(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 l=e[0],c=e[e.length-1],u=c.runningLength,h=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:S}=pA(e,t),y=l.point,x=e.length>1?e[e.length-1].point:b.AddXY(l.point,1,1);if(e.length===1&&(!(h||p)||s)){const C=b.Add(y,b.Sub(y,x).uni().per().mul(-l.radius)),E=[];for(let _=1/13,I=_;I<=1;I+=_)E.push(b.RotWith(C,y,nl*2*I));return E}const m=[];if(!(h||p&&e.length===1))if(i)for(let C=1/8,E=C;E<=1;E+=C){const _=b.RotWith(S[0],y,nl*E);m.push(_)}else{const C=b.Sub(f[0],S[0]),E=b.Mul(C,.5),_=b.Mul(C,.51);m.push(b.Sub(y,E),b.Sub(y,_),b.Add(y,_),b.Add(y,E))}const v=[],w=c.vector.clone().per().neg();if(p||h&&e.length===1)v.push(x);else if(a){const C=b.Add(x,b.Mul(w,c.radius));for(let E=1/29,_=E;_<1;_+=E)v.push(b.RotWith(C,x,nl*3*_))}else v.push(b.Add(x,b.Mul(w,c.radius)),b.Add(x,b.Mul(w,c.radius*.99)),b.Sub(x,b.Mul(w,c.radius*.99)),b.Sub(x,b.Mul(w,c.radius)));return f.concat(v,S.reverse(),m)}const uY=.025,dY=.01;function Io(e,t={}){var x;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(b.From),a=0;if(!o){let m=i[0];for(;m&&!(m.z>=uY);)i.shift(),m=i[0]}if(!o){let m=i[i.length-1];for(;m&&!(m.z>=dY);)i.pop(),m=i[i.length-1]}if(i.length===0)return[{point:b.From(e[0]),input:b.From(e[0]),pressure:o?.5:.15,vector:new b(1,1),distance:0,runningLength:0,radius:1}];let l=i[1];for(;l&&!(b.Dist2(l,i[0])>(r/3)**2);)i[0].z=Math.max(i[0].z,l.z),i.splice(1,1),l=i[1];const c=i.pop();for(l=i[i.length-1];l&&!(b.Dist2(l,c)>(r/3)**2);)i.pop(),l=i[i.length-1],a++;i.push(c);const u=t.last||!t.simulatePressure||i.length>1&&b.Dist2(i[i.length-1],i[i.length-2])<r**2||a>0;if(i.length===2&&t.simulatePressure){const m=i[1];i=i.slice(0,-1);for(let v=1;v<5;v++){const w=b.Lrp(i[0],m,v/4);w.z=(i[0].z+(m.z-i[0].z))*v/4,i.push(w)}}const h=[{point:i[0],input:i[0],pressure:o?.5:i[0].z,vector:new b(1,1),distance:0,runningLength:0,radius:1}];let p=0,f=h[0],S,y;u&&n>0&&i.push(i[i.length-1].clone());for(let m=1,v=i.length;m<v;m++)S=!s||t.last&&m===v-1?i[m].clone():i[m].clone().lrp(f.point,1-s),!f.point.equals(S)&&(y=b.Dist(S,f.point),p+=y,!(m<4&&p<r)&&(f={input:i[m],point:S,pressure:o?.5:i[m].z,vector:b.Sub(f.point,S).uni(),distance:y,runningLength:p,radius:1},h.push(f)));if((x=h[1])!=null&&x.vector&&(h[0].vector=h[1].vector.clone()),p<1){const m=Math.max(.5,...h.map(v=>v.pressure));h.forEach(v=>v.pressure=m)}return h}const{min:bs}=Math,dy=.275;function mg(e,t){const{size:n=16,thinning:r=.5,simulatePressure:o=!0,easing:s=x=>x,start:i={},end:a={}}=t,{easing:l=At.easeOutQuad}=i,{easing:c=At.easeOutCubic}=a,u=e[e.length-1].runningLength;let h,p=e[0].pressure,f;if(!o&&u<n){const x=e.reduce((m,v)=>Math.max(m,v.pressure),.5);return e.forEach(m=>{m.pressure=x,m.radius=n*s(.5-r*(.5-m.pressure))}),e}else{let x;for(let m=0,v=e.length;m<v&&(f=e[m],!(f.runningLength>n*5));m++){const w=bs(1,f.distance/n);if(o){const C=bs(1,1-w);x=bs(1,p+(C-p)*(w*dy))}else x=bs(1,p+(f.pressure-p)*.5);p=p+(x-p)*.5}for(let m=0;m<e.length;m++){if(f=e[m],r){let{pressure:v}=f;const w=bs(1,f.distance/n);if(o){const C=bs(1,1-w);v=bs(1,p+(C-p)*(w*dy))}else v=bs(1,p+(v-p)*(w*dy));f.radius=n*s(.5-r*(.5-v)),p=v}else f.radius=n/2;h===void 0&&(h=f.radius)}}const S=i.taper===!1?0:i.taper===!0?Math.max(n,u):i.taper,y=a.taper===!1?0:a.taper===!0?Math.max(n,u):a.taper;if(S||y)for(let x=0;x<e.length;x++){f=e[x];const{runningLength:m}=f,v=m<S?l(m/S):1,w=u-m<y?c((u-m)/y):1;f.radius=Math.max(.01,f.radius*Math.min(v,w))}return e}function hY(e,t={}){return pw(mg(Io(e,t),t),t)}function nI({scribble:e,zoom:t,color:n,opacity:r,className:o}){if(!e.points.length)return null;const s=hY(e.points,{size:e.size/t,start:{taper:e.taper,easing:At.linear},last:e.state==="stopping",simulatePressure:!1,streamline:.32});let i;if(s.length<4){const a=e.size/t/2,{x:l,y:c}=e.points[e.points.length-1];i=`M ${l-a},${c} a ${a},${a} 0 1,0 ${a*2},0 a ${a},${a} 0 1,0 ${-a*2},0`}else i=a0(s);return d.jsx("svg",{className:o&&ce("tl-overlays__item",o),children:d.jsx("path",{className:"tl-scribble",d:i,fill:n??`var(--color-${e.color})`,opacity:r??e.opacity})})}const pY=({bounds:e,rotation:t})=>{const n=F();return K("should display",()=>n.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_shape","select.pointing_selection","text.resizing"),[n])?d.jsx(b2,{bounds:e,rotation:t}):null};function ds(){const e=F();return K("isReadonlyMode",()=>e.getInstanceState().isReadonly,[e])}function fY({size:e,width:t,height:n,hideAlternateHandles:r}){const o=N(e/3),s=o/2;return d.jsxs("svg",{className:"tl-overlays__item",children:[d.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
160
|
+
${N(0-s)},${N(e)}
|
|
161
|
+
${N(0-s)},${N(0-s)}
|
|
162
|
+
${N(e)},${N(0-s)}`,strokeWidth:o,"data-testid":"selection.crop.top_left","aria-label":"top_left handle"}),d.jsx("line",{className:ce("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:N(t/2-e),y1:N(0-s),x2:N(t/2+e),y2:N(0-s),strokeWidth:o,"data-testid":"selection.crop.top","aria-label":"top handle"}),d.jsx("polyline",{className:ce("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
163
|
+
${N(t-e)},${N(0-s)}
|
|
164
|
+
${N(t+s)},${N(0-s)}
|
|
165
|
+
${N(t+s)},${N(e)}`,strokeWidth:o,"data-testid":"selection.crop.top_right","aria-label":"top_right handle"}),d.jsx("line",{className:ce("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:N(t+s),y1:N(n/2-e),x2:N(t+s),y2:N(n/2+e),strokeWidth:o,"data-testid":"selection.crop.right","aria-label":"right handle"}),d.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
166
|
+
${N(t+s)},${N(n-e)}
|
|
167
|
+
${N(t+s)},${N(n+s)}
|
|
168
|
+
${N(t-e)},${N(n+s)}`,strokeWidth:o,"data-testid":"selection.crop.bottom_right","aria-label":"bottom_right handle"}),d.jsx("line",{className:ce("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:N(t/2-e),y1:N(n+s),x2:N(t/2+e),y2:N(n+s),strokeWidth:o,"data-testid":"selection.crop.bottom","aria-label":"bottom handle"}),d.jsx("polyline",{className:ce("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
169
|
+
${N(0+e)},${N(n+s)}
|
|
170
|
+
${N(0-s)},${N(n+s)}
|
|
171
|
+
${N(0-s)},${N(n-e)}`,strokeWidth:o,"data-testid":"selection.crop.bottom_left","aria-label":"bottom_left handle"}),d.jsx("line",{className:ce("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:N(0-s),y1:N(n/2-e),x2:N(0-s),y2:N(n/2+e),strokeWidth:o,"data-testid":"selection.crop.left","aria-label":"left handle"})]})}const gY=Lt(function({bounds:t,rotation:n}){const r=F(),o=P.useRef(null),s=ds(),i=io("top"),a=io("right"),l=io("bottom"),c=io("left"),u=io("top_left"),h=io("top_right"),p=io("bottom_right"),f=io("bottom_left"),S=!r.getIsMenuOpen()&&r.getInstanceState().cursor.type==="default",y=r.getInstanceState().isCoarsePointer,x=r.getOnlySelectedShape(),m=x&&r.isShapeOrAncestorLocked(x),v=x?r.getShapeUtil(x).expandSelectionOutlinePx(x):0;if(Ml(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 w=r.getZoomLevel(),C=r.getInstanceState().isChangingStyle,E=t.width,_=t.height,I=8/w,k=E<I*2,T=_<I*2,M=E<I*4,D=_<I*4,$=E<I*5,j=_<I*5,O=y?1.75:1,R=6/w*O,H=(M?R/2:R)*(O*.75),B=(D?R/2:R)*(O*.75),z=(x?!r.getShapeUtil(x).hideSelectionBoundsFg(x):!0)&&!C;let W=z&&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.crop.pointing_crop_handle","select.pointing_resize_handle")||z&&r.isIn("select.resizing")&&x&&r.isShapeOfType(x,"text");x&&W&&r.environment.isFirefox&&r.isShapeOfType(x,"embed")&&(W=!1);const Y=r.isInAny("select.crop.idle","select.crop.pointing_crop","select.crop.pointing_crop_handle")&&!C&&!s,q=r.isInAny("select.idle","select.pointing_selection","select.pointing_shape","select.crop.idle")&&!C&&!s,le=!y&&!(k||T)&&(q||Y)&&(x?!r.getShapeUtil(x).hideRotateHandle(x):!0)&&!m,ge=y&&(!M||!D)&&(q||Y)&&(x?!r.getShapeUtil(x).hideRotateHandle(x):!0)&&!m,be=q&&(x?r.getShapeUtil(x).canResize(x)&&!r.getShapeUtil(x).hideResizeHandles(x):!0)&&!Y&&!m,J=k||T,Ue=k&&T,Oe=$||j,nt=be||Y,je=!le,it=!q||!ge,Fe=!q||!nt,Xn=!q||!nt||J,Nt=!q||!nt||J,Tn=!q||!nt||Ue&&!Y;let St=!0,Qt=!0;if(Y)St=Oe,Qt=Oe;else if(be){St=J||Ue||y;const ms=y&&x&&x.type==="text";Qt=St&&!ms}const jo=Math.min(24/w,_-B*3),Nl=q&&y&&x&&r.isShapeOfType(x,"text")&&jo*w>=4;return d.jsx("svg",{className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:d.jsxs("g",{ref:o,children:[W&&d.jsx("rect",{className:"tl-selection__fg__outline",width:N(E),height:N(_)}),d.jsx(nh,{"data-testid":"selection.rotate.top-left",cx:0,cy:0,targetSize:R,corner:"top_left_rotate",cursor:S?Zn("nwse-rotate",n):void 0,isHidden:je}),d.jsx(nh,{"data-testid":"selection.rotate.top-right",cx:E+R*3,cy:0,targetSize:R,corner:"top_right_rotate",cursor:S?Zn("nesw-rotate",n):void 0,isHidden:je}),d.jsx(nh,{"data-testid":"selection.rotate.bottom-left",cx:0,cy:_+R*3,targetSize:R,corner:"bottom_left_rotate",cursor:S?Zn("swne-rotate",n):void 0,isHidden:je}),d.jsx(nh,{"data-testid":"selection.rotate.bottom-right",cx:E+R*3,cy:_+R*3,targetSize:R,corner:"bottom_right_rotate",cursor:S?Zn("senw-rotate",n):void 0,isHidden:je}),d.jsx(yY,{"data-testid":"selection.rotate.mobile",cx:M?-R*1.5:E/2,cy:M?_/2:-R*1.5,size:I,isHidden:it}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":St}),"data-testid":"selection.resize.top","aria-label":"top target",pointerEvents:"all",x:0,y:N(0-(D?B*2:B)),width:N(E),height:N(Math.max(1,B*2)),style:S?{cursor:Zn("ns-resize",n)}:void 0,...i}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":Qt}),"data-testid":"selection.resize.right","aria-label":"right target",pointerEvents:"all",x:N(E-(M?0:H)),y:0,height:N(_),width:N(Math.max(1,H*2)),style:S?{cursor:Zn("ew-resize",n)}:void 0,...a}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":St}),"data-testid":"selection.resize.bottom","aria-label":"bottom target",pointerEvents:"all",x:0,y:N(_-(D?0:B)),width:N(E),height:N(Math.max(1,B*2)),style:S?{cursor:Zn("ns-resize",n)}:void 0,...l}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":Qt}),"data-testid":"selection.resize.left","aria-label":"left target",pointerEvents:"all",x:N(0-(M?H*2:H)),y:0,height:N(_),width:N(Math.max(1,H*2)),style:S?{cursor:Zn("ew-resize",n)}:void 0,...c}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":Fe}),"data-testid":"selection.target.top-left","aria-label":"top-left target",pointerEvents:"all",x:N(0-(M?H*2:H*1.5)),y:N(0-(D?B*2:B*1.5)),width:N(H*3),height:N(B*3),style:S?{cursor:Zn("nwse-resize",n)}:void 0,...u}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":Xn}),"data-testid":"selection.target.top-right","aria-label":"top-right target",pointerEvents:"all",x:N(E-(M?0:H*1.5)),y:N(0-(D?B*2:B*1.5)),width:N(H*3),height:N(B*3),style:S?{cursor:Zn("nesw-resize",n)}:void 0,...h}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":Tn}),"data-testid":"selection.target.bottom-right","aria-label":"bottom-right target",pointerEvents:"all",x:N(E-(M?H:H*1.5)),y:N(_-(D?B:B*1.5)),width:N(H*3),height:N(B*3),style:S?{cursor:Zn("nwse-resize",n)}:void 0,...p}),d.jsx("rect",{className:ce("tl-transparent",{"tl-hidden":Nt}),"data-testid":"selection.target.bottom-left","aria-label":"bottom-left target",pointerEvents:"all",x:N(0-(M?H*3:H*1.5)),y:N(_-(D?0:B*1.5)),width:N(H*3),height:N(B*3),style:S?{cursor:Zn("nesw-resize",n)}:void 0,...f}),be&&d.jsxs(d.Fragment,{children:[d.jsx("rect",{"data-testid":"selection.resize.top-left",className:ce("tl-corner-handle",{"tl-hidden":Fe}),"aria-label":"top_left handle",x:N(0-I/2),y:N(0-I/2),width:N(I),height:N(I)}),d.jsx("rect",{"data-testid":"selection.resize.top-right",className:ce("tl-corner-handle",{"tl-hidden":Xn}),"aria-label":"top_right handle",x:N(E-I/2),y:N(0-I/2),width:N(I),height:N(I)}),d.jsx("rect",{"data-testid":"selection.resize.bottom-right",className:ce("tl-corner-handle",{"tl-hidden":Tn}),"aria-label":"bottom_right handle",x:N(E-I/2),y:N(_-I/2),width:N(I),height:N(I)}),d.jsx("rect",{"data-testid":"selection.resize.bottom-left",className:ce("tl-corner-handle",{"tl-hidden":Nt}),"aria-label":"bottom_left handle",x:N(0-I/2),y:N(_-I/2),width:N(I),height:N(I)})]}),Nl&&d.jsxs(d.Fragment,{children:[d.jsx("rect",{"data-testid":"selection.text-resize.left.handle",className:"tl-text-handle","aria-label":"bottom_left handle",x:N(0-I/4),y:N(_/2-jo/2),rx:I/4,width:N(I/2),height:N(jo)}),d.jsx("rect",{"data-testid":"selection.text-resize.right.handle",className:"tl-text-handle","aria-label":"bottom_left handle",rx:I/4,x:N(E-I/4),y:N(_/2-jo/2),width:N(I/2),height:N(jo)})]}),Y&&d.jsx(fY,{size:I,width:E,height:_,hideAlternateHandles:Oe})]})})}),nh=function({cx:t,cy:n,targetSize:r,corner:o,cursor:s,isHidden:i,"data-testid":a}){const l=io(o);return d.jsx("rect",{className:ce("tl-transparent","tl-rotate-corner",{"tl-hidden":i}),"data-testid":a,"aria-label":`${o} target`,pointerEvents:"all",x:N(t-r*3),y:N(n-r*3),width:N(Math.max(1,r*3)),height:N(Math.max(1,r*3)),cursor:s,...l})},mY=Math.sqrt(Math.PI),yY=function({cx:t,cy:n,size:r,isHidden:o,"data-testid":s}){const i=io("mobile_rotate"),a=F(),l=K("zoom level",()=>a.getZoomLevel(),[a]),c=Math.max(14*(1/l),20/Math.max(1,l));return d.jsxs("g",{children:[d.jsx("circle",{"data-testid":s,pointerEvents:"all",className:ce("tl-transparent","tl-mobile-rotate__bg",{"tl-hidden":o}),cx:t,cy:n,r:c,...i}),d.jsx("circle",{className:ce("tl-mobile-rotate__fg",{"tl-hidden":o}),cx:t,cy:n,r:r/mY})]})};function SY(){const e=F();return K("is in a valid select state",()=>e.isInAny("select.idle","select.brushing","select.scribble_brushing","select.editing_shape","select.pointing_shape","select.pointing_selection","select.pointing_handle"),[e])?d.jsx(P2,{}):null}function jv(e,t,n){const{arrowheadStart:r,arrowheadEnd:o}=t.props,s=Ha(e,t,n),i=s.start.clone(),a=s.end.clone(),l=b.Med(i,a);if(b.Equals(i,a))return{bindings:n,isStraight:!0,start:{handle:i,point:i,arrowhead:t.props.arrowheadStart},end:{handle:a,point:a,arrowhead:t.props.arrowheadEnd},middle:l,isValid:!1,length:0};const c=b.Sub(a,i).uni(),u=yf(e,t,"start"),h=yf(e,t,"end"),p=e.getShapePageTransform(t);rI(a,s.start,p,h),rI(i,s.end,p,u);let f=0,S=0,y=0,x=0,m=Ka*t.props.scale;const v=u&&h&&u.shape===h.shape,w=u&&h?fw(e,u.shape.id,h.shape.id):"safe";w==="safe"&&u&&h&&!v&&!u.isExact&&!h.isExact&&(h.didIntersect&&!u.didIntersect?u.isClosed&&i.setTo(a.clone().add(c.clone().mul(Ka*t.props.scale))):h.didIntersect||h.isClosed&&a.setTo(i.clone().sub(c.clone().mul(Ka*t.props.scale))));const C=b.Sub(a,i),E=b.Len(C)?C.uni():b.From(C),_=!b.Equals(E,c);v||(w!=="start-contains-end"&&u&&r!=="none"&&!u.isExact&&(y=Ds[t.props.size]/2+("size"in u.shape.props?Ds[u.shape.props.size]/2:0),f=(Sf+y)*t.props.scale,m+=y*t.props.scale),w!=="end-contains-start"&&h&&o!=="none"&&!h.isExact&&(x=Ds[t.props.size]/2+("size"in h.shape.props?Ds[h.shape.props.size]/2:0),S=(Sf+x)*t.props.scale,m+=x*t.props.scale));const I=i.clone().add(E.clone().mul(f*(_?-1:1))),k=a.clone().sub(E.clone().mul(S*(_?-1:1)));b.DistMin(I,k,m)&&(f!==0&&S!==0?(f*=-1.5,S*=-1.5):f!==0?f*=-1:S!==0&&(S*=-1)),i.add(E.clone().mul(f*(_?-1:1))),a.sub(E.clone().mul(S*(_?-1:1))),_?(u&&h&&a.setTo(b.Add(i,E.clone().mul(-Ka*t.props.scale))),l.setTo(b.Med(s.start,s.end))):l.setTo(b.Med(i,a));const T=b.Dist(i,a);return{bindings:n,isStraight:!0,start:{handle:s.start,point:i,arrowhead:t.props.arrowheadStart},end:{handle:s.end,point:a,arrowhead:t.props.arrowheadEnd},middle:l,isValid:T>0,length:T}}function rI(e,t,n,r){if(r===void 0||r.isExact)return;const o=se.applyToPoint(n,t),s=se.applyToPoint(n,e),i=se.applyToPoint(se.Inverse(r.transform),o),a=se.applyToPoint(se.Inverse(r.transform),s),l=r.isClosed,u=(l?nw:tG)(i,a,r.outline);let h;if(u!==null&&(h=u.sort((S,y)=>b.Dist2(S,i)-b.Dist2(y,i))[0]??(l?void 0:a)),h===void 0)return;const p=se.applyToPoint(r.transform,h),f=se.applyToPoint(se.Inverse(n),p);e.setTo(f),r.didIntersect=!0}function vY(e,t,n){const{arrowheadEnd:r,arrowheadStart:o}=t.props,s=t.props.bend;if(Math.abs(s)>Math.abs(t.props.bend*(CY*t.props.scale)))return jv(e,t,n);const i=Ha(e,t,n),a=b.Med(i.start,i.end),l=b.Sub(i.end,i.start),c=b.Len(l)?l.uni():b.From(l),u=b.Add(a,c.per().mul(-s)),h=yf(e,t,"start"),p=yf(e,t,"end"),f=i.start.clone(),S=i.end.clone(),y=u.clone();if(b.Equals(f,S))return{bindings:n,isStraight:!0,start:{handle:f,point:f,arrowhead:t.props.arrowheadStart},end:{handle:S,point:S,arrowhead:t.props.arrowheadEnd},middle:y,isValid:!1,length:0};const x=t.props.bend<0,m=x?Ku:n2,v=oI(f,S,y),w=b.Angle(v.center,f),C=b.Angle(v.center,S),E=m(w,C);if(v.length===0||v.size===0||!pP(v.length)||!pP(v.size))return jv(e,t,n);const _=f.clone(),I=S.clone(),k=y.clone(),T=e.getShapePageTransform(t);let M=0,D=0,$=Ka*t.props.scale;if(h&&!h.isExact){const Y=se.applyToPoint(T,_),q=se.applyToPoint(T,v.center),le=se.applyToPoint(T,I),ge=se.Inverse(h.transform),be=se.applyToPoint(ge,Y),J=se.applyToPoint(ge,q),Ue=se.applyToPoint(ge,le),{isClosed:Oe}=h,nt=Oe?kv:zC;let je,it=nt(J,v.radius,h.outline);if(it){const Fe=J.angle(be),Xn=J.angle(Ue),Nt=m(Fe,Xn);it=it.filter(St=>m(Fe,J.angle(St))<=Nt);const Tn=Nt*.25;it.sort(Oe?(St,Qt)=>Math.abs(m(Fe,J.angle(St))-Tn)<Math.abs(m(Fe,J.angle(Qt))-Tn)?-1:1:(St,Qt)=>m(Fe,J.angle(St))<m(Fe,J.angle(Qt))?-1:1),je=it[0]??(Oe?void 0:be)}else je=Oe?void 0:be;if(je&&(_.setTo(e.getPointInShapeSpace(t,se.applyToPoint(h.transform,je))),h.didIntersect=!0,o!=="none")){const Fe=Ds[t.props.size]/2+("size"in h.shape.props?Ds[h.shape.props.size]/2:0);M=(Sf+Fe)*t.props.scale,$+=Fe*t.props.scale}}if(p&&!p.isExact){const Y=se.applyToPoint(T,_),q=se.applyToPoint(T,I),le=se.applyToPoint(T,v.center),ge=se.Inverse(p.transform),be=se.applyToPoint(ge,Y),J=se.applyToPoint(ge,le),Ue=se.applyToPoint(ge,q),Oe=p.isClosed,nt=Oe?kv:zC;let je,it=nt(J,v.radius,p.outline);if(it){const Fe=J.angle(be),Xn=J.angle(Ue),Nt=m(Fe,Xn),Tn=Nt*.75;it=it.filter(St=>m(Fe,J.angle(St))<=Nt),it.sort(Oe?(St,Qt)=>Math.abs(m(Fe,J.angle(St))-Tn)<Math.abs(m(Fe,J.angle(Qt))-Tn)?-1:1:(St,Qt)=>m(Fe,J.angle(St))<m(Fe,J.angle(Qt))?-1:1),it[0]?je=it[0]:je=Oe?void 0:Ue}else je=Oe?void 0:Ue;if(je&&(I.setTo(e.getPointInShapeSpace(t,se.applyToPoint(p.transform,je))),p.didIntersect=!0,r!=="none")){const Fe=Ds[t.props.size]/2+("size"in p.shape.props?Ds[p.shape.props.size]/2:0);D=(Sf+Fe)*t.props.scale,$+=Fe*t.props.scale}}let j=b.Angle(v.center,_),O=b.Angle(v.center,I),R=m(j,O),H=R*v.radius;const B=_.clone(),z=I.clone();if(M!==0&&B.setTo(v.center).add(b.FromAngle(j+R*(M/H*(x?1:-1))).mul(v.radius)),D!==0&&z.setTo(v.center).add(b.FromAngle(O+R*(D/H*(x?-1:1))).mul(v.radius)),b.DistMin(B,z,$)&&(M!==0&&D!==0?(M*=-1.5,D*=-1.5):M!==0?M*=-2:D!==0&&(D*=-2)),M!==0&&_.setTo(v.center).add(b.FromAngle(j+R*(M/H*(x?1:-1))).mul(v.radius)),D!==0&&I.setTo(v.center).add(b.FromAngle(O+R*(D/H*(x?-1:1))).mul(v.radius)),h&&p&&!h.isExact&&!p.isExact){j=b.Angle(v.center,_),O=b.Angle(v.center,I),R=m(j,O),H=R*v.radius;const Y=fw(e,h.shape.id,p.shape.id);Y==="double-bound"&&H<30?(_.setTo(f),I.setTo(S),k.setTo(y)):Y==="safe"&&(h&&!h.didIntersect&&_.setTo(f),(p&&!p.didIntersect||m(w,j)>m(w,O))&&I.setTo(v.center).add(b.FromAngle(j+R*(Math.min(.9,Ka*t.props.scale/H)*(x?1:-1))).mul(v.radius)))}xY(v.center,v.radius,_,I,k,E,x),_.equals(I)&&(_.setTo(k.clone().addXY(1,1)),I.setTo(k.clone().subXY(1,1))),f.setTo(_),S.setTo(I),y.setTo(k);const W=oI(f,S,y);return{bindings:n,isStraight:!1,start:{point:f,handle:i.start,arrowhead:t.props.arrowheadStart},end:{point:S,handle:i.end,arrowhead:t.props.arrowheadEnd},middle:y,handleArc:v,bodyArc:W,isValid:W.length!==0&&isFinite(W.center.x)&&isFinite(W.center.y)}}function oI(e,t,n){const r=o0(e,t,n),o=b.Dist(r,e),s=+b.Clockwise(e,n,t),i=((e.y-t.y)**2+(e.x-t.x)**2)**.5,a=((t.y-n.y)**2+(t.x-n.x)**2)**.5,l=((n.y-e.y)**2+(n.x-e.x)**2)**.5,c=Math.acos((a*a+l*l-i*i)/(2*a*l))*2,u=+(Me>c),h=(Le-c)*(s?1:-1),p=h*o;return{center:r,radius:o,size:h,length:p,largeArcFlag:u,sweepFlag:s}}function xY(e,t,n,r,o,s,i){const a=b.Angle(e,n),l=b.Angle(e,r);let c=Ku(a,l);if(i||(c=Le-c),o.setTo(e).add(b.FromAngle(a+c*(.5*(i?1:-1))).mul(t)),c>s){o.rotWith(e,Me);const u=r.clone();r.setTo(n),n.setTo(u)}}const wY=8;function bY(e){return Math.abs(e.props.bend)<wY*e.props.scale}function yf(e,t,n){const r=e.getBindingsFromShape(t,"arrow").find(l=>l.props.terminal===n);if(!r)return;const o=e.getShape(r.toId);if(!o)return;const s=e.getShapePageTransform(o),i=e.getShapeGeometry(o),a=i instanceof Gr?i.children[0].vertices:i.vertices;return{shape:o,transform:s,isClosed:i.isClosed,isExact:r.props.isExact,didIntersect:!1,outline:a}}function sI(e,t,n,r){const o=e.getShape(n.toId);if(o){const{point:s,size:i}=e.getShapeGeometry(o).bounds,a=b.Add(s,b.MulV(n.props.isPrecise||r?n.props.normalizedAnchor:{x:.5,y:.5},i)),l=se.applyToPoint(e.getShapePageTransform(o),a);return se.applyToPoint(se.Inverse(t),l)}else return new b(0,0)}function $n(e,t){const n=e.getBindingsFromShape(t,"arrow");return{start:n.find(r=>r.props.terminal==="start"),end:n.find(r=>r.props.terminal==="end")}}const PY=ZB("arrow info",(e,t)=>{const n=$n(e,t);return bY(t)?jv(e,t,n):vY(e,t,n)});function fo(e,t){const n=typeof t=="string"?t:t.id;return PY.get(e,n)}function Ha(e,t,n){var a,l;const r=e.getShapePageTransform(t),o=fw(e,(a=n.start)==null?void 0:a.toId,(l=n.end)==null?void 0:l.toId),s=n.start?sI(e,r,n.start,o==="double-bound"||o==="start-contains-end"):b.From(t.props.start),i=n.end?sI(e,r,n.end,o==="double-bound"||o==="end-contains-start"):b.From(t.props.end);return{start:s,end:i}}function lc(e,t,n,r){const o=typeof t=="string"?t:t.id,s=typeof n=="string"?n:n.id,i=e.getBindingsFromShape(o,"arrow").filter(l=>l.props.terminal===r.terminal);i.length>1&&e.deleteBindings(i.slice(1));const a=i[0];a?e.updateBinding({...a,toId:s,props:r}):e.createBinding({type:"arrow",fromId:o,toId:s,props:r})}function Xh(e,t,n){const r=e.getBindingsFromShape(t,"arrow").filter(o=>o.props.terminal===n);e.deleteBindings(r)}const Ka=10,Sf=10,CY=10,Ds={s:2,m:3.5,l:5,xl:10};function fw(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"}class qh extends Vh{getDefaultProps(){return{isPrecise:!1,isExact:!1,normalizedAnchor:{x:.5,y:.5}}}onAfterCreate({binding:t}){hy(this.editor,this.editor.getShape(t.fromId))}onAfterChange({bindingAfter:t}){hy(this.editor,this.editor.getShape(t.fromId))}onAfterChangeFromShape({shapeAfter:t}){hy(this.editor,t)}onAfterChangeToShape({binding:t}){fA(this.editor,t.fromId)}onBeforeIsolateFromShape({binding:t}){const n=this.editor.getShape(t.fromId);n&&vf({editor:this.editor,arrow:n,terminal:t.props.terminal})}}g(qh,"type","arrow"),g(qh,"props",b_),g(qh,"migrations",P_);function fA(e,t){var x;const n=e.getShape(t);if(!n)return;const r=$n(e,n),{start:o,end:s}=r,i=o?e.getShape(o.toId):void 0,a=s?e.getShape(s.toId):void 0,l=e.getAncestorPageId(n);if(!l)return;let c;if(i&&a)c=e.findCommonAncestor([i,a])??l;else if(i||a){const m=(x=i||a)==null?void 0:x.parentId;m&&m===n.parentId?c=n.parentId:c=l}else return;c&&c!==n.parentId&&e.reparentShapes([t],c);const u=e.getShape(t);if(!u)throw Error("no reparented arrow");const h=e.getShapeNearestSibling(u,i),p=e.getShapeNearestSibling(u,a);let f;if(h&&p)f=h.index>p.index?h:p;else if(h&&!p)f=h;else if(p&&!h)f=p;else return;let S;const y=e.getSortedChildIdsForParent(f.parentId).map(m=>e.getShape(m)).filter(m=>m.index>f.index);if(y.length){const m=y.find(v=>v.type!=="arrow");if(u.index>f.index&&(!m||u.index<m.index))return;S=ru(f.index,y[0].index)}else S=zr(f.index);S!==u.index&&e.updateShapes([{id:t,type:"arrow",index:S}])}function hy(e,t){const n=$n(e,t);for(const r of["start","end"]){const o=n[r];if(!o)continue;const s=e.getShape(o.toId),i=e.getAncestorPageId(t)===e.getAncestorPageId(s);(!s||!i)&&vf({editor:e,arrow:t,terminal:r,unbind:!0})}fA(e,t.id)}function vf({editor:e,arrow:t,terminal:n,unbind:r=!1,useHandle:o=!1}){const s=fo(e,t);if(!s)throw new Error("expected arrow info");const i=o?s.start.handle:s.start.point,a=o?s.end.handle:s.end.point,l=n==="start"?i:a,c={id:t.id,type:"arrow",props:{[n]:{x:l.x,y:l.y},bend:t.props.bend}};if(!s.isStraight){const u=n==="start"?i:s.start.handle,h=n==="end"?a:s.end.handle,p=b.Med(u,h),f=b.Sub(u,h).per().uni().mul(s.handleArc.radius*2*Math.sign(t.props.bend)),S=Ju(s.handleArc.center,b.Add(p,f),s.handleArc.center,s.handleArc.radius);Xe((S==null?void 0:S.length)===1);const y=b.Dist(p,S[0])*Math.sign(t.props.bend);$s(y,c.props.bend)||(c.props.bend=y)}e.updateShape(c),r&&Xh(e,t,n)}const gA=[qh],Vt={lineHeight:1.35,fontWeight:"normal",fontVariant:"normal",fontStyle:"normal",padding:"0px"},jt={s:2,m:3.5,l:5,xl:10},gl={s:18,m:24,l:36,xl:44},qo={s:18,m:22,l:26,xl:32},IY={s:18,m:20,l:24,xl:28},wo={draw:"var(--tl-font-draw)",sans:"var(--tl-font-sans)",serif:"var(--tl-font-serif)",mono:"var(--tl-font-mono)"},EY=20,kY=4.25,vr=16;/*!
|
|
172
|
+
* canvas-size
|
|
173
|
+
* v1.2.6
|
|
174
|
+
* https://github.com/jhildenbiddle/canvas-size
|
|
175
|
+
* (c) 2015-2023 John Hildenbiddle <http://hildenbiddle.com>
|
|
176
|
+
* MIT license
|
|
177
|
+
*/function _Y(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,s,i,a=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);l=!0);}catch(u){c=!0,o=u}finally{try{if(!l&&n.return!=null&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw o}}return a}}function iI(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 Qn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?iI(Object(n),!0).forEach(function(r){TY(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):iI(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function TY(e,t,n){return t=NY(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function MY(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 AY(e,t){if(e==null)return{};var n=MY(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 aI(e,t){return OY(e)||_Y(e,t)||mA(e,t)||LY()}function rh(e){return jY(e)||DY(e)||mA(e)||RY()}function jY(e){if(Array.isArray(e))return Ov(e)}function OY(e){if(Array.isArray(e))return e}function DY(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function mA(e,t){if(e){if(typeof e=="string")return Ov(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 Ov(e,t)}}function Ov(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 RY(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
178
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function LY(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
179
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $Y(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 NY(e){var t=$Y(e,"string");return typeof t=="symbol"?t:String(t)}function qc(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,l;i?(a=new OffscreenCanvas(1,1),l=new OffscreenCanvas(n,r)):(a=document.createElement("canvas"),a.width=1,a.height=1,l=document.createElement("canvas"),l.width=n,l.height=r);var c=a.getContext("2d"),u=l.getContext("2d");u&&(u.fillRect.apply(u,o),c.drawImage(l,n-1,r-1,1,1,0,0,1,1));var h=c&&c.getImageData(0,0,1,1).data[3]!==0,p=Date.now()-s;return[a,l].forEach(function(f){f.height=0,f.width=0}),i?(postMessage({width:n,height:r,benchmark:p,isTestPass:h}),!h&&e.sizes.length&&qc(e)):h?e.onSuccess(n,r,p):(e.onError(n,r,p),e.sizes.length&&qc(e)),h}var py={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]},FY=["onError","onSuccess"],Wa={max:null,min:1,sizes:[],step:1024,usePromise:!1,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},cc={};function fy(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 h=t||n?u:1,p=t||r?u:1;o.push([h,p])});else for(var s=e.min||Wa.min,i=e.step||Wa.step,a=Math.max(e.width,e.height);a>=s;){var l=t||n?a:1,c=t||r?a:1;o.push([l,c]),a-=i}return o}function oh(e){var t=window&&"HTMLCanvasElement"in window,n=window&&"OffscreenCanvas"in window,r=Date.now(),o=e.onError,s=e.onSuccess,i=AY(e,FY),a=null;if(!t)return!1;if(e.useWorker&&n){var l=`
|
|
180
|
+
var canvasTest = `.concat(qc.toString(),`;
|
|
181
|
+
onmessage = function(e) {
|
|
182
|
+
canvasTest(e.data);
|
|
183
|
+
};
|
|
184
|
+
`),c=new Blob([l],{type:"application/javascript"}),u=URL.createObjectURL(c);a=new Worker(u),URL.revokeObjectURL(u),a.onmessage=function(h){var p=h.data,f=p.width,S=p.height,y=p.benchmark,x=p.isTestPass;x?(cc[r].onSuccess(f,S,y),delete cc[r]):cc[r].onError(f,S,y)}}if(e.usePromise)return new Promise(function(h,p){var f=Qn(Qn({},e),{},{onError:function(m,v,w){var C;if(e.sizes.length===0)C=!0;else{var E=e.sizes.slice(-1),_=aI(E,1),I=aI(_[0],2),k=I[0],T=I[1];C=m===k&&v===T}o(m,v,w),C&&p({width:m,height:v,benchmark:w})},onSuccess:function(m,v,w){s(m,v,w),h({width:m,height:v,benchmark:w})}});if(a){var S=f.onError,y=f.onSuccess;cc[r]={onError:S,onSuccess:y},a.postMessage(i)}else qc(f)});if(a)cc[r]={onError:o,onSuccess:s},a.postMessage(i);else return qc(e)}var gy={maxArea:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=fy({width:t.max,height:t.max,min:t.min,step:t.step,sizes:rh(py.area)}),r=Qn(Qn(Qn({},Wa),t),{},{sizes:n});return oh(r)},maxHeight:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=fy({width:1,height:t.max,min:t.min,step:t.step,sizes:rh(py.height)}),r=Qn(Qn(Qn({},Wa),t),{},{sizes:n});return oh(r)},maxWidth:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=fy({width:t.max,height:1,min:t.min,step:t.step,sizes:rh(py.width)}),r=Qn(Qn(Qn({},Wa),t),{},{sizes:n});return oh(r)},test:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Qn(Qn({},Wa),t);return n.sizes=rh(n.sizes),n.width&&n.height&&(n.sizes=[[n.width,n.height]]),oh(n)}};let my=null;function zY(){return my||(my=BY()),my}async function BY(){const e=await gy.maxWidth({usePromise:!0}),t=await gy.maxHeight({usePromise:!0}),n=await gy.maxArea({usePromise:!0});return{maxWidth:e.width,maxHeight:t.height,maxArea:n.width*n.height}}const lI=8192,UY=4096*4096;async function HY(e,t){if(e<=lI&&t<=lI&&e*t<=UY)return[e,t];const{maxWidth:n,maxHeight:r,maxArea:o}=await zY(),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]}function KY(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}}function WY(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function GY(e){const t=new URL(e).host.replace("www.","");for(const n of Hu)if(yA(n.hostnames,t)){const r=n.fromEmbedUrl(e);if(r)return{definition:n,url:r,embedUrl:e}}}const VY=e=>e.split("*").map(t=>WY(t)).join(".+"),yA=(e,t)=>!!e.find(n=>{const r=new RegExp(VY(n));return t.match(r)});function YY(e){const t=new URL(e).host.replace("www.","");for(const n of Hu)if(yA(n.hostnames,t)){const r=n.toEmbedUrl(e);if(r)return{definition:n,embedUrl:r,url:e}}}function SA(e){return YY(e)??GY(e)}function Rs(e){try{return SA(e)}catch(t){console.error(t)}}/*!
|
|
185
|
+
* MIT License
|
|
186
|
+
* Adapted (mostly copied) the work of https://github.com/fregante/text-field-edit
|
|
187
|
+
* Copyright (c) Federico Brigante <opensource@bfred.it> (bfred.it)
|
|
188
|
+
*/const Ga=" ",gn=class gn{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)||gn.insertTextFirefox(t,n),o===r.body?t.blur():o instanceof HTMLElement&&o!==t&&o.focus()}static set(t,n){t.select(),gn.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=gn.getSelection(t);gn.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 l=typeof r=="string"?r:r(...s);return gn.insert(t,l),t.selectionStart=i,o+=l.length-a,l})}static findLineEnd(t,n){const r=t.lastIndexOf(`
|
|
189
|
+
`,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 l=o.lastIndexOf(`
|
|
190
|
+
`,n-1)+1,c=t.value.slice(l,r-1),u=c.replace(/^|\n/g,`$&${Ga}`),h=u.length-c.length;t.setSelectionRange(l,r-1),gn.insert(t,u),t.setSelectionRange(n+1,r+h)}else gn.insert(t,Ga)}static unindent(t){const{selectionStart:n,selectionEnd:r,value:o}=t,s=o.lastIndexOf(`
|
|
191
|
+
`,n-1)+1,i=gn.findLineEnd(o,r),a=t.value.slice(s,i),l=a.replace(/(^|\n)(\t| {1,2})/g,"$1"),c=a.length-l.length;t.setSelectionRange(s,i),gn.insert(t,l);const u=/\t| {1,2}/.exec(o.slice(s,n)),h=u?u[0].length:0,p=n-h;t.setSelectionRange(n-h,Math.max(p,r-c))}static indentCE(t){var l;const n=window.getSelection(),r=t.innerText,o=sh(t)??0,s=sh(t)??0,i=r.slice(o,s),a=(l=/\n/g.exec(i))==null?void 0:l.length;if(a&&a>0){const c=r.lastIndexOf(`
|
|
192
|
+
`,o-1)+1,u=r.slice(c,s-1),p=u.replace(/^|\n/g,`$&${Ga}`).length-u.length;n&&n.setBaseAndExtent(t,o+1,t,s+p)}else{const c=window.getSelection();t.innerText=r.slice(0,o)+Ga+r.slice(o),c==null||c.setBaseAndExtent(t,o+1,t,o+2)}}static unindentCE(t){const n=window.getSelection(),r=t.innerText,o=sh(t)??0,s=sh(t)??0,i=r.lastIndexOf(`
|
|
193
|
+
`,o-1)+1,a=gn.findLineEnd(r,s),l=r.slice(i,a),c=l.replace(/(^|\n)(\t| {1,2})/g,"$1"),u=l.length-c.length;if(n){n.setBaseAndExtent(t,i,t,a);const h=/\t| {1,2}/.exec(r.slice(i,o)),p=h?h[0].length:0,f=o-p;n.setBaseAndExtent(t,o-p,t,Math.max(f,s-u))}}static normalizeText(t){return t.replace(gn.fixNewLines,`
|
|
194
|
+
`)}static normalizeTextForDom(t){return t.replace(gn.fixNewLines,`
|
|
195
|
+
`).split(`
|
|
196
|
+
`).map(n=>n||" ").join(`
|
|
197
|
+
`)}};g(gn,"fixNewLines",/\r?\n|\r/g);let ml=gn;function sh(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 XY=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;function vA(e){return XY.test(e)}function qY(e){return e.replace(/\t/g,Ga)}function ZY(e){const t=e.split(`
|
|
198
|
+
`);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(`
|
|
199
|
+
`)}function QY(e){return e.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function JY(e){return QY(ZY(qY(e)))}function eX(e,{maxImageDimension:t,maxAssetSize:n,acceptedImageMimeTypes:r,acceptedVideoMimeTypes:o},{toasts:s,msg:i}){e.registerExternalAssetHandler("file",async({file:a})=>{const l=a.name;let c=a;const u=r.includes(c.type),h=o.includes(c.type);!u&&!h&&s.addToast({title:i("assets.files.type-not-allowed"),severity:"error"}),Xe(u||h,`File type not allowed: ${c.type}`),c.size>n&&s.addToast({title:i("assets.files.size-too-big"),severity:"error"}),Xe(c.size<=n,`File size too big: ${(c.size/1024).toFixed()}kb > ${(n/1024).toFixed()}kb`),c.type==="video/quicktime"&&(c=new File([c],c.name,{type:"video/mp4"}));let p=u?await ho.getImageSize(c):await ho.getVideoSize(c);const f=await ho.isAnimated(c)||h,S=SB(await c.arrayBuffer());if(isFinite(t)){const m=KY(p,{w:t,h:t});p!==m&&ho.isStaticImageType(c.type)&&(p=m)}const x={id:Ii.createId(S),type:u?"image":"video",typeName:"asset",props:{name:l,src:"",w:p.w,h:p.h,fileSize:c.size,mimeType:c.type,isAnimated:f}};return x.props.src=await e.uploadAsset(x,c),Ii.create(x)}),e.registerExternalAssetHandler("url",async({url:a})=>{var c,u,h,p,f;let l;try{const y=await(await bo(a,{method:"GET",mode:"no-cors"})).text(),x=new DOMParser().parseFromString(y,"text/html");l={image:((c=x.head.querySelector('meta[property="og:image"]'))==null?void 0:c.getAttribute("content"))??"",favicon:((u=x.head.querySelector('link[rel="apple-touch-icon"]'))==null?void 0:u.getAttribute("href"))??((h=x.head.querySelector('link[rel="icon"]'))==null?void 0:h.getAttribute("href"))??"",title:((p=x.head.querySelector('meta[property="og:title"]'))==null?void 0:p.getAttribute("content"))??a,description:((f=x.head.querySelector('meta[property="og:description"]'))==null?void 0:f.getAttribute("content"))??""},l.image.startsWith("http")||(l.image=new URL(l.image,a).href),l.favicon.startsWith("http")||(l.favicon=new URL(l.favicon,a).href)}catch(S){console.error(S),s.addToast({title:i("assets.url.failed"),severity:"error"}),l={image:"",favicon:"",title:"",description:""}}return{id:Ii.createId(xS(a)),typeName:"asset",type:"bookmark",props:{src:a,description:l.description,image:l.image,favicon:l.favicon,title:l.title},meta:{}}}),e.registerExternalContentHandler("svg-text",async({point:a,text:l})=>{const c=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageBounds().center),u=new DOMParser().parseFromString(l,"image/svg+xml").querySelector("svg");if(!u)throw new Error("No <svg/> element present");let h=parseFloat(u.getAttribute("width")||"0"),p=parseFloat(u.getAttribute("height")||"0");if(!(h&&p)){document.body.appendChild(u);const S=u.getBoundingClientRect();document.body.removeChild(u),h=S.width,p=S.height}const f=await e.getAssetForExternalContent({type:"file",file:new File([l],"asset.svg",{type:"image/svg+xml"})});if(!f)throw Error("Could not create an asset");cI(e,[f],c)}),e.registerExternalContentHandler("embed",({point:a,url:l,embed:c})=>{const u=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageBounds().center),{width:h,height:p}=c,f=$e(),S={id:f,type:"embed",x:u.x-(h||450)/2,y:u.y-(p||450)/2,props:{w:h,h:p,url:l}};e.createShapes([S]).select(f)}),e.registerExternalContentHandler("files",async({point:a,files:l})=>{const c=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageBounds().center),u=new b(c.x,c.y),h=[];await Promise.all(l.map(async(p,f)=>{if(p.size>n)return s.addToast({title:i("assets.files.size-too-big"),severity:"error"}),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 s.addToast({title:i("assets.files.type-not-allowed"),severity:"error"}),console.warn(`${p.name} not loaded - Extension not allowed.`),null;try{const S=await e.getAssetForExternalContent({type:"file",file:p});if(!S)throw Error("Could not create an asset");h[f]=S}catch(S){return s.addToast({title:i("assets.files.upload-failed"),severity:"error"}),console.error(S),null}})),cI(e,ye(h),u)}),e.registerExternalContentHandler("text",async({point:a,text:l})=>{const c=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageBounds().center),u=e.getShapeUtil("text").getDefaultProps(),h=JY(l),p=e.getOnlySelectedShape();if(p&&"text"in p.props){e.updateShapes([{id:p.id,type:p.type,props:{text:h}}]);return}let f,S,y,x="middle";const m=h.split(`
|
|
200
|
+
`).length>1,v=vA(h);m&&(x=m?v?"end":"start":"middle");const w=e.textMeasure.measureText(h,{...Vt,fontFamily:wo[u.font],fontSize:gl[u.size],maxWidth:null}),C=Math.min(m?e.getViewportPageBounds().width*.9:920,Math.max(200,e.getViewportPageBounds().width*.9));if(w.w>C){const E=e.textMeasure.measureText(h,{...Vt,fontFamily:wo[u.font],fontSize:gl[u.size],maxWidth:C});f=E.w,S=E.h,y=!1,x=v?"end":"start"}else f=w.w,S=w.h,y=!0;c.y-S/2<e.getViewportPageBounds().minY+40&&(c.y=e.getViewportPageBounds().minY+40+S/2),e.createShapes([{id:$e(),type:"text",x:c.x-f/2,y:c.y-S/2,props:{text:h,textAlign:x,autoSize:y,w:f}}])}),e.registerExternalContentHandler("url",async({point:a,url:l})=>{const c=Rs(l);if(c)return e.putExternalContent({type:"embed",url:c.url,point:a,embed:c.definition});const u=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageBounds().center),h=Ii.createId(xS(l)),p=tX(e,l,u);let f=e.getAsset(h),S=!1;if(!f){S=!0;try{const y=await e.getAssetForExternalContent({type:"url",url:l});if(!y)throw Error("Could not create an asset");f=y}catch{s.addToast({title:i("assets.url.failed"),severity:"error"});return}}e.run(()=>{S&&e.createAssets([f]),e.updateShapes([{id:p.id,type:p.type,props:{assetId:f.id}}])})})}async function cI(e,t,n){if(!t.length)return[];const r=b.From(n),o=[];for(let s=0;s<t.length;s++){const i=t[s];switch(i.type){case"bookmark":{o.push({id:$e(),type:"bookmark",x:r.x,y:r.y,opacity:1,props:{assetId:i.id,url:i.props.src}}),r.x+=300;break}case"image":{o.push({id:$e(),type:"image",x:r.x,y:r.y,opacity:1,props:{assetId:i.id,w:i.props.w,h:i.props.h}}),r.x+=i.props.w;break}case"video":o.push({id:$e(),type:"video",x:r.x,y:r.y,opacity:1,props:{assetId:i.id,w:i.props.w,h:i.props.h}}),r.x+=i.props.w}}return e.run(()=>{const s=t.filter(i=>!e.getAsset(i.id));s.length&&e.createAssets(s),e.createShapes(o).select(...o.map(i=>i.id)),xA(e,n)}),o.map(s=>s.id)}function xA(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=b.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 tX(e,t,n){const r={id:$e(),type:"bookmark",x:n.x-150,y:n.y-160,opacity:1,props:{assetId:null,url:t}};return e.run(()=>{e.createShapes([r]).select(r.id),xA(e,n)}),e.getShape(r.id)}var By;let nX=(By=class extends oe{constructor(){super(...arguments);g(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});g(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});g(this,"onCancel",()=>{this.editor.setCurrentTool("select")});g(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}))}})}},g(By,"id","idle"),By);var Uy;let rX=(Uy=class extends oe{constructor(){super(...arguments);g(this,"shape");g(this,"markId","");g(this,"onEnter",()=>{this.didTimeout=!1;const n=this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{filter:r=>!r.isLocked&&this.editor.canBindShapes({fromShape:"arrow",toShape:r,binding:"arrow"}),margin:0,hitInside:!0,renderingOnly:!0});n?this.editor.setHintingShapes([n.id]):this.createArrowShape(),this.startPreciseTimeout()});g(this,"onExit",()=>{this.shape=void 0,this.editor.setHintingShapes([]),this.clearPreciseTimeout()});g(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:{id:"end",type:"vertex",index:"a3",x:0,y:0},isCreating:!0,onInteractionEnd:"arrow"})}});g(this,"onPointerUp",()=>{this.cancel()});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.cancel()});g(this,"onInterrupt",()=>{this.cancel()});g(this,"preciseTimeout",-1);g(this,"didTimeout",!1)}cancel(){this.shape&&this.editor.bailToMark(this.markId),this.editor.setHintingShapes([]),this.parent.transition("idle")}createArrowShape(){var u;const{originPagePoint:n}=this.editor.inputs,r=$e();this.markId=`creating:${r}`,this.editor.mark(this.markId),this.editor.createShape({id:r,type:"arrow",x:n.x,y:n.y,props:{scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}});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,l=s.find(h=>h.id==="start"),c=(u=i.onHandleDrag)==null?void 0:u.call(i,o,{handle:{...l,x:0,y:0},isPrecise:!0,initial:a});c&&this.editor.updateShapes([c]),this.shape=this.editor.getShape(r),this.editor.select(r)}updateArrowShapeEndHandle(){var o,s;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 i=this.editor.getShapeUtil("arrow"),a=this.shape,l=r.find(u=>u.id==="start"),c=(o=i.onHandleDrag)==null?void 0:o.call(i,n,{handle:{...l,x:0,y:0},isPrecise:this.didTimeout,initial:a});c&&this.editor.updateShapes([c])}{const i=this.editor.getShapeUtil("arrow"),a=this.shape,l=this.editor.getPointInShapeSpace(n,this.editor.inputs.currentPagePoint),c=r.find(h=>h.id==="end"),u=(s=i.onHandleDrag)==null?void 0:s.call(i,this.editor.getShape(n),{handle:{...c,x:l.x,y:l.y},isPrecise:!1,initial:a});u&&this.editor.updateShapes([u])}this.shape=this.editor.getShape(n.id)}startPreciseTimeout(){this.preciseTimeout=this.editor.timers.setTimeout(()=>{this.getIsActive()&&(this.didTimeout=!0)},320)}clearPreciseTimeout(){clearTimeout(this.preciseTimeout)}},g(Uy,"id","pointing"),Uy);class Zh extends oe{constructor(){super(...arguments);g(this,"shapeType","arrow")}}g(Zh,"id","arrow"),g(Zh,"initial","idle"),g(Zh,"children",()=>[nX,rX]);class gw extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"initialShape");g(this,"shapeType",this.parent.id==="highlight"?"highlight":"draw");g(this,"util",this.editor.getShapeUtil(this.shapeType));g(this,"isPen",!1);g(this,"isPenOrStylus",!1);g(this,"segmentMode","free");g(this,"didJustShiftClickToExtendPreviousShapeLine",!1);g(this,"pagePointWhereCurrentSegmentChanged",{});g(this,"pagePointWhereNextSegmentChanged",null);g(this,"lastRecordedPoint",{});g(this,"mergeNextPoint",!1);g(this,"currentLineLength",0);g(this,"canDraw",!1);g(this,"markId",null);g(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()});g(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&&(this.isPenOrStylus?b.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())});g(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()});g(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()});g(this,"onExit",()=>{this.editor.snaps.clearIndicators(),this.pagePointWhereCurrentSegmentChanged=this.editor.inputs.currentPagePoint.clone()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.complete()});g(this,"onInterrupt",()=>{this.editor.inputs.isDragging||(this.markId&&this.editor.bailToMark(this.markId),this.cancel())})}canClose(){return this.shapeType!=="highlight"}getIsClosed(n,r,o){if(!this.canClose())return!1;const s=jt[r],i=n[0].points[0],a=n[n.length-1],l=a.points[a.points.length-1];return i!==l&&this.currentLineLength>s*4*o&&b.DistMin(i,l,s*2*o)}startShape(){const{inputs:{originPagePoint:n,isPen:r}}=this.editor;this.markId="draw start "+ct(),this.editor.mark(this.markId);const{z:o=.5}=this.info.point;this.isPen=r,this.isPenOrStylus=r||o>0&&o<.5||o>.5&&o<1;const s=this.isPenOrStylus?o*1.25:.5;if(this.segmentMode=this.editor.inputs.shiftKey?"straight":"free",this.didJustShiftClickToExtendPreviousShapeLine=!1,this.lastRecordedPoint=n.clone(),this.initialShape){const a=this.editor.getShape(this.initialShape.id);if(a&&this.segmentMode==="straight"){this.didJustShiftClickToExtendPreviousShapeLine=!0;const l=Ut(a.props.segments);if(!l)throw Error("Expected a previous segment!");const c=Ut(l.points);if(!c)throw Error("Expected a previous point!");const{x:u,y:h}=this.editor.getPointInShapeSpace(a,n).toFixed(),p={type:this.segmentMode,points:[{x:c.x,y:c.y,z:+s.toFixed(2)},{x:u,y:h,z:+s.toFixed(2)}]},f=se.applyToPoint(this.editor.getShapePageTransform(a.id),c);this.pagePointWhereCurrentSegmentChanged=f,this.pagePointWhereNextSegmentChanged=null;const S=[...a.props.segments,p];this.currentLineLength<jt[a.props.size]*4&&(this.currentLineLength=this.getLineLength(S));const y={id:a.id,type:this.shapeType,props:{segments:S}};this.canClose()&&(y.props.isClosed=this.getIsClosed(S,a.props.size,a.props.scale)),this.editor.updateShapes([y]);return}}this.pagePointWhereCurrentSegmentChanged=n.clone();const i=$e();this.editor.createShapes([{id:i,type:this.shapeType,x:n.x,y:n.y,props:{isPen:this.isPenOrStylus,scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1,segments:[{type:this.segmentMode,points:[{x:0,y:0,z:+s.toFixed(2)}]}]}}]),this.currentLineLength=0,this.initialShape=this.editor.getShape(i)}updateDrawingShape(){const{initialShape:n}=this,{inputs:r}=this.editor;if(!n)return;const{id:o,props:{size:s,scale:i}}=n,a=this.editor.getShape(o);if(!a)return;const{segments:l}=a.props,{x:c,y:u,z:h}=this.editor.getPointInShapeSpace(a,r.currentPagePoint).toFixed(),p=this.isPenOrStylus?+(r.currentPagePoint.z*1.25).toFixed(2):.5,f={x:c,y:u,z:p};switch(this.segmentMode){case"starting_straight":{const{pagePointWhereNextSegmentChanged:S}=this;if(S===null)throw Error("We should have a point where the segment changed");if(b.Dist2(S,r.currentPagePoint)>this.editor.options.dragDistanceSquared){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="straight";const x=Ut(l);if(!x)throw Error("Expected a previous segment!");const m=Ut(x.points);if(!m)throw Error("Expected a previous last point!");let v;const w=this.editor.getPointInShapeSpace(a,this.pagePointWhereCurrentSegmentChanged).toFixed().toJson();if(x.type==="straight"){this.currentLineLength+=b.Dist(m,w),v={type:"straight",points:[{...m},w]};const E=this.editor.getShapePageTransform(a);this.pagePointWhereCurrentSegmentChanged=se.applyToPoint(E,m)}else v={type:"straight",points:[w,f]};const C={id:o,type:this.shapeType,props:{segments:[...l,v]}};this.canClose()&&(C.props.isClosed=this.getIsClosed(l,s,i)),this.editor.updateShapes([C])}break}case"starting_free":{const{pagePointWhereNextSegmentChanged:S}=this;if(S===null)throw Error("We should have a point where the segment changed");if(b.Dist2(S,r.currentPagePoint)>this.editor.options.dragDistanceSquared){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";const x=l.slice(),m=x[x.length-1],v=Ut(m.points);if(!v)throw Error("No previous point!");const w={type:"free",points:[...b.PointsBetween(v,f,6).map(_=>({x:Uo(_.x),y:Uo(_.y),z:Uo(_.z)}))]},C=[...x,w];this.currentLineLength<jt[a.props.size]*4&&(this.currentLineLength=this.getLineLength(C));const E={id:o,type:this.shapeType,props:{segments:C}};this.canClose()&&(E.props.isClosed=this.getIsClosed(C,s,i)),this.editor.updateShapes([E])}break}case"straight":{const S=l.slice(),y=S[S.length-1],{pagePointWhereCurrentSegmentChanged:x}=this,{ctrlKey:m,currentPagePoint:v}=this.editor.inputs;if(!x)throw Error("We should have a point where the segment changed");let w,C=!1;this.didJustShiftClickToExtendPreviousShapeLine?this.editor.inputs.isDragging&&(C=!m,this.didJustShiftClickToExtendPreviousShapeLine=!1):C=!m;let E=this.editor.getPointInShapeSpace(a,v).toFixed().toJson(),_=!1,I;if((this.editor.user.getIsSnapMode()?!m:m)&&S.length>2){let M,D=8/this.editor.getZoomLevel();for(let $=0,j=l.length-2;$<j;$++){const O=l[$];if(!O)break;if(O.type==="free")continue;const R=O.points[0],H=Ut(O.points);if(!(R&&H))continue;const B=b.NearestPointOnLineSegment(R,H,E);if(b.DistMin(B,E,D)){M=B.toFixed().toJson(),D=b.Dist(B,E),I=O;break}}M&&(_=!0,E=M)}if(_&&I){const M=this.editor.getShapePageTransform(a),D=I.points[0],$=Ut(I.points);if(!$)throw Error("Expected a last point!");const j=se.applyToPoint(M,D),O=se.applyToPoint(M,$),R=se.applyToPoint(M,E);this.editor.snaps.setIndicators([{id:ct(),type:"points",points:[j,R,O]}])}else{if(this.editor.snaps.clearIndicators(),C){const M=b.Angle(x,v),$=Bp(M,24)-M;w=b.RotWith(v,x,$)}else w=v;E=this.editor.getPointInShapeSpace(a,w).toFixed().toJson()}this.currentLineLength+=b.Dist(y.points[0],E),S[S.length-1]={...y,type:"straight",points:[y.points[0],E]};const T={id:o,type:this.shapeType,props:{segments:S}};this.canClose()&&(T.props.isClosed=this.getIsClosed(l,s,i)),this.editor.updateShapes([T]);break}case"free":{const S=l.slice(),y=S[S.length-1],x=[...y.points];if(x.length&&this.mergeNextPoint){const{z:v}=x[x.length-1];x[x.length-1]={x:f.x,y:f.y,z:v?Math.max(v,f.z):f.z}}else this.currentLineLength+=b.Dist(x[x.length-1],f),x.push(f);S[S.length-1]={...y,points:x},this.currentLineLength<jt[a.props.size]*4&&(this.currentLineLength=this.getLineLength(S));const m={id:o,type:this.shapeType,props:{segments:S}};if(this.canClose()&&(m.props.isClosed=this.getIsClosed(S,s,i)),this.editor.updateShapes([m]),x.length>this.editor.options.maxPointsPerDrawShape){this.editor.updateShapes([{id:o,type:this.shapeType,props:{isComplete:!0}}]);const v=$e(),w=this.editor.getShape(o).props;this.editor.createShapes([{id:v,type:this.shapeType,x:Uo(r.currentPagePoint.x),y:Uo(r.currentPagePoint.y),props:{isPen:this.isPenOrStylus,scale:w.scale,segments:[{type:"free",points:[{x:0,y:0,z:this.isPenOrStylus?+(h*1.25).toFixed():.5}]}]}}]),this.initialShape=Ge(this.editor.getShape(v)),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+=b.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)}}g(gw,"id","drawing");var Hy;let wA=(Hy=class extends oe{constructor(){super(...arguments);g(this,"onPointerDown",n=>{this.parent.transition("drawing",n)});g(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});g(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},g(Hy,"id","idle"),Hy);class Cc extends oe{constructor(){super(...arguments);g(this,"shapeType","draw");g(this,"onExit",()=>{const n=this.children.drawing;n.initialShape=void 0})}}g(Cc,"id","draw"),g(Cc,"initial","idle"),g(Cc,"isLockable",!1),g(Cc,"children",()=>[wA,gw]);class Dv extends Yh{constructor(){super(...arguments);g(this,"shapeType","frame");g(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 l=this.editor.getShapePageBounds(a);l&&r.contains(l)&&oX(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")})}}g(Dv,"id","frame"),g(Dv,"initial","idle");function oX(e,t,n){return t.includes(e.id)?!1:e.parentId===n.parentId}var Ky;let sX=(Ky=class extends oe{constructor(){super(...arguments);g(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});g(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});g(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}))}});g(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},g(Ky,"id","idle"),Ky);var Wy;let iX=(Wy=class extends oe{constructor(){super(...arguments);g(this,"markId","");g(this,"onPointerUp",()=>{this.complete()});g(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){const{originPagePoint:r}=this.editor.inputs,o=$e();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(Ur),scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}}]).select(o).setCurrentTool("select.resizing",{...n,target:"selection",handle:"bottom_right",isCreating:!0,creationCursorOffset:{x:1,y:1},onInteractionEnd:"geo"})}});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.complete()});g(this,"onInterrupt",()=>{this.cancel()})}complete(){const{originPagePoint:n}=this.editor.inputs,r=$e();this.markId=`creating:${r}`,this.editor.mark(this.markId);const o=this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1,s=this.editor.getStyleForNextShape(Ur),i=s==="star"?{w:200,h:190}:s==="cloud"?{w:300,h:180}:{w:200,h:200};this.editor.createShapes([{id:r,type:"geo",x:n.x,y:n.y,props:{geo:this.editor.getStyleForNextShape(Ur),scale:o,...i}}]);const a=this.editor.getShape(r);if(!a)return;const{w:l,h:c}=a.props,u=new b(l/2,c/2).mul(o),h=this.editor.getShapeParentTransform(a);h&&u.rot(-h.rotation()),this.editor.select(r),this.editor.updateShape({id:a.id,type:"geo",x:a.x-u.x,y:a.y-u.y,props:{geo:this.editor.getStyleForNextShape(Ur),w:l*o,h:c*o}}),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select",{})}cancel(){this.parent.transition("idle")}},g(Wy,"id","pointing"),Wy);class Qh extends oe{constructor(){super(...arguments);g(this,"shapeType","geo")}}g(Qh,"id","geo"),g(Qh,"initial","idle"),g(Qh,"children",()=>[sX,iX]);class Ic extends oe{constructor(){super(...arguments);g(this,"shapeType","highlight");g(this,"onExit",()=>{const n=this.children.drawing;n.initialShape=void 0})}}g(Ic,"id","highlight"),g(Ic,"initial","idle"),g(Ic,"children",()=>[wA,gw]),g(Ic,"isLockable",!1);var Gy;let aX=(Gy=class extends oe{constructor(){super(...arguments);g(this,"shapeId","");g(this,"onEnter",n=>{this.shapeId=n.shapeId,this.editor.setCursor({type:"cross",rotation:0})});g(this,"onPointerDown",()=>{this.parent.transition("pointing",{shapeId:this.shapeId})});g(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},g(Gy,"id","idle"),Gy);const uI=2;var Vy;let lX=(Vy=class extends oe{constructor(){super(...arguments);g(this,"shape",{});g(this,"markId");g(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(ln),l=a[a.length-1],c=a[a.length-2],u=se.applyToPoint(this.editor.getShapeParentTransform(this.shape),new b(this.shape.x,this.shape.y)),h=b.Sub(o,u).addXY(.1,.1),p=Ge(this.shape.props.points);if(b.DistMin(l,c,uI)||b.DistMin(h,l,uI))p[l.id]={id:l.id,index:l.index,x:h.x,y:h.y};else{const f=zr(l.index);p[f]={id:f,index:f,x:h.x,y:h.y}}this.editor.updateShapes([{id:this.shape.id,type:this.shape.type,props:{points:p}}])}else{const i=$e();this.markId=`creating:${i}`,this.editor.mark(this.markId),this.editor.createShapes([{id:i,type:"line",x:o.x,y:o.y,props:{scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}}]),this.editor.select(i),this.shape=this.editor.getShape(i)}});g(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=Ut(n);this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,isCreating:!0,handle:{...r,x:r.x-.1,y:r.y-.1},onInteractionEnd:"line"})}});g(this,"onPointerUp",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.complete()});g(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()}},g(Vy,"id","pointing"),Vy);class Jh extends oe{constructor(){super(...arguments);g(this,"shapeType","line")}}g(Jh,"id","line"),g(Jh,"initial","idle"),g(Jh,"children",()=>[aX,lX]);var Yy;let cX=(Yy=class extends oe{constructor(){super(...arguments);g(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});g(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});g(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},g(Yy,"id","idle"),Yy);function Ke(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=bA(e,s);i.length&&r.set(s,i)}for(const[s,i]of r){const a=e.getShapeUtil(s),l=ye(i.map(c=>e.getShape(c)));(o=a.onDragShapesOut)==null||o.call(a,s,l)}}function bA(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 l of n){const c=e.getShapePageBounds(l);if(!c)continue;if(!r.includes(c)){a.push(l);continue}o??(o=e.getShapeGeometry(t)),s??(s=e.getShapePageTransform(t)),i??(i=s.applyToPoints(o.vertices));const u=e.getShapePageTransform(l).clone().invert().applyToPoints(i),{vertices:h,isClosed:p}=e.getShapeGeometry(l);if(!h.some(f=>sr(f,u))){if(p){if(GM(u,h))continue}else if(oG(u,h))continue;a.push(l)}}return a}function xf(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}),PA(e)}const uX=16;function PA(e){const t=e.getSelectionPageBounds(),n=e.getViewportPageBounds();if(t&&!n.contains(t)){const r=t.clone().expandBy(uX/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,{animation:{duration:e.options.animationMediumMs},inset:0})}}const dX=0,Be=200,yg=new b(Be/2,Be/2),CA=10,hX=e=>[[["a1"],new b(Be*.5,Be*-.5-e.options.adjacentShapeMargin)],[["a2"],new b(Be*1.5+e.options.adjacentShapeMargin,Be*.5)],[["a3"],new b(Be*.5,Be*1.5+e.options.adjacentShapeMargin)],[["a4"],new b(Be*-.5-e.options.adjacentShapeMargin,Be*.5)]];function pX(e,t){if(t===1)return hX(e);const n=Be*t,r=e.options.adjacentShapeMargin*t;return[[["a1"],new b(n*.5,n*-.5-r)],[["a2"],new b(n*1.5+r,n*.5)],[["a3"],new b(n*.5,n*1.5+r)],[["a4"],new b(n*-.5-r,n*.5)]]}function IA(e,t,n,r,o,s){return Object.fromEntries(pX(e,s).map(([i,a],l)=>{const c=a.clone();return l===0&&o?c.y-=o:l===2&&r&&(c.y+=r),[i,c.rot(n).add(t)]}))}function EA(e,t,n,r){const o=new Set(e.getSelectedShapeIds()),s=(Be+e.options.adjacentShapeMargin+r)**2,i=new Map,a=[];for(const u of e.getCurrentPageShapes()){if(!e.isShapeOfType(u,"note")||n!==u.props.scale||o.has(u.id))continue;const h=e.getShapePageTransform(u.id);t===h.rotation()&&(i.set(u,e.getShapePageBounds(u).center),a.push(...Object.values(IA(e,h.point(),t,u.props.growY,r,n))))}const l=a.length;let c;for(const[u,h]of i)for(let p=0;p<l;p++)c=a[p],c&&(b.Dist2(h,c)>s||e.isPointInShape(u,c)&&(a[p]=void 0));return ye(a)}function kA(e,t,n,r,o=!1){let s;const i=e.getCurrentPageShapesSorted(),a=(Be+e.options.adjacentShapeMargin**2)**t.props.scale;for(let l=i.length-1;l>=0;l--){const c=i[l];if(c.type==="note"&&c.id!==t.id){const u=e.getShapePageBounds(c);if(u&&b.Dist2(u.center,n)<a&&e.isPointInShape(c,n)){s=c;break}}}if(e.complete(),!s||o){e.mark("creating note shape");const l=$e();e.createShape({id:l,type:"note",x:n.x,y:n.y,rotation:r,opacity:t.opacity,props:{...t.props,text:"",growY:0,fontSizeAdjustment:0,url:""}});const c=e.getShape(l);if(!c)return;const u=e.getPointInParentSpace(c,b.Sub(n,b.Rot(yg.clone().mul(c.props.scale),r)));e.updateShape({id:l,type:"note",x:u.x,y:u.y}),s=e.getShape(l)}return PA(e),s}var Xy;let fX=(Xy=class extends oe{constructor(){super(...arguments);g(this,"dragged",!1);g(this,"info",{});g(this,"wasFocusedOnEnter",!1);g(this,"markId","");g(this,"shape",{});g(this,"onEnter",()=>{const{editor:n}=this;if(this.wasFocusedOnEnter=!n.getIsMenuOpen(),this.wasFocusedOnEnter){const r=$e();this.markId=`creating:${r}`,n.mark(this.markId);const o=this.editor.inputs.originPagePoint.clone(),s=dI(this.editor,o,this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1);s&&o.sub(s),this.shape=hI(this.editor,r,o)}});g(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){if(!this.wasFocusedOnEnter){const r=$e(),o=this.editor.inputs.originPagePoint.clone(),s=dI(this.editor,o,this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1);s&&o.sub(s),this.shape=hI(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")}})}});g(this,"onPointerUp",()=>{this.complete()});g(this,"onInterrupt",()=>{this.cancel()});g(this,"onComplete",()=>{this.complete()});g(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)}},g(Xy,"id","pointing"),Xy);function dI(e,t,n){let r=CA/e.getZoomLevel(),o;for(const s of EA(e,0,n,0)){const i=b.Sub(t,s),a=i.len();a<r&&(r=a,o=i)}return o}function hI(e,t,n){e.createShape({id:t,type:"note",x:n.x,y:n.y,props:{scale:e.user.getIsDynamicResizeMode()?1/e.getZoomLevel():1}}).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 ep extends oe{constructor(){super(...arguments);g(this,"shapeType","note")}}g(ep,"id","note"),g(ep,"initial","idle"),g(ep,"children",()=>[cX,fX]);function gX(e){const t=e.getShapeAtPoint(e.inputs.currentPagePoint,{hitInside:!1,hitLabels:!1,margin:e.options.hitTestMargin/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 Go=$k(gX,32);var qy;let mX=(qy=class extends oe{constructor(){super(...arguments);g(this,"onPointerMove",n=>{switch(n.target){case"shape":case"canvas":Go(this.editor)}});g(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});g(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});g(this,"onExit",()=>{Go.cancel()});g(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}))}});g(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},g(qy,"id","idle"),qy);var Zy;let yX=(Zy=class extends oe{constructor(){super(...arguments);g(this,"shape");g(this,"markId","");g(this,"onExit",()=>{this.editor.setHintingShapes([])});g(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){const{inputs:{originPagePoint:r}}=this.editor,o=$e();this.markId=`creating:${o}`,this.editor.mark(this.markId);const s=this.createTextShape(o,r,!1);if(!s){this.cancel();return}this.shape=this.editor.getShape(s),this.editor.select(o),this.editor.setCurrentTool("select.resizing",{...n,target:"selection",handle:"right",isCreating:!0,creationCursorOffset:{x:18,y:1},onInteractionEnd:"text",onCreate:()=>{this.editor.setEditingShape(s.id),this.editor.setCurrentTool("select.editing_shape")}})}});g(this,"onPointerUp",()=>{this.complete()});g(this,"onComplete",()=>{this.cancel()});g(this,"onCancel",()=>{this.cancel()});g(this,"onInterrupt",()=>{this.cancel()})}complete(){var s;this.editor.mark("creating text shape");const n=$e(),{currentPagePoint:r}=this.editor.inputs;this.createTextShape(n,r,!0)&&(this.editor.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)}createTextShape(n,r,o){this.editor.createShape({id:n,type:"text",x:r.x,y:r.y,props:{text:"",autoSize:o,w:20,scale:this.editor.user.getIsDynamicResizeMode()?1/this.editor.getZoomLevel():1}});const s=this.editor.getShape(n);if(!s){this.cancel();return}const i=this.editor.getShapePageBounds(s),a=new b;if(o)switch(s.props.textAlign){case"start":{a.x=0;break}case"middle":{a.x=-i.width/2;break}case"end":{a.x=-i.width;break}}else a.x=0;if(a.y=-i.height/2,On(s.parentId)){const l=this.editor.getShapeParentTransform(s);a.rot(-l.rotation())}return this.editor.updateShape({...s,x:s.x+a.x,y:s.y+a.y}),s}},g(Zy,"id","pointing"),Zy);class Ec extends oe{constructor(){super(...arguments);g(this,"shapeType","text")}}g(Ec,"id","text"),g(Ec,"initial","idle"),g(Ec,"children",()=>[mX,yX]),g(Ec,"isLockable",!1);const SX=[Ec,Cc,Qh,ep,Jh,Dv,Zh,Ic];function jr(){return cs({isDarkMode:td()})}function Sg(e){return{key:`${Po.id}:${e}`,getElement:async()=>{const t=vX(e);if(!t)return null;const n=t.$$_url,r=t.$$_fontface;if(!n||!r)return null;const o=await(await bo(n)).blob(),s=await Ai.blobToDataUrl(o),i=r.replace(n,s);return d.jsx("style",{children:i})}}}function vX(e){const t=S_[e];for(const n of document.fonts)if(t.includes(n.family))return n;return null}function mw(e){return{key:`${Po.id}:${e}`,getElement:async()=>e!=="pattern"?null:d.jsx(xX,{})}}function xX(){const e=jr(),t=8/12;return d.jsxs(d.Fragment,{children:[d.jsxs("mask",{id:"hash_pattern_mask",children:[d.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:"white"}),d.jsxs("g",{strokeLinecap:"round",stroke:"black",children:[d.jsx("line",{x1:t*1,y1:t*3,x2:t*3,y2:t*1}),d.jsx("line",{x1:t*5,y1:t*7,x2:t*7,y2:t*5}),d.jsx("line",{x1:t*9,y1:t*11,x2:t*11,y2:t*9})]})]}),d.jsx("pattern",{id:wf(1,e.id),width:"8",height:"8",patternUnits:"userSpaceOnUse",children:d.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:e.solid,mask:"url(#hash_pattern_mask)"})})]})}function yw(){return{key:`${Po.id}:pattern`,component:CX}}const kc=8,pI=(e,t,n)=>new Promise((r,o)=>{const s=kc*t*e,i=document.createElement("canvas");i.width=s,i.height=s;const a=i.getContext("2d");if(!a)return;a.fillStyle=n?Dp.darkMode.solid:Dp.lightMode.solid,a.fillRect(0,0,s,s),a.globalCompositeOperation="destination-out",a.lineCap="round",a.lineWidth=1.25*t*e;const l=8/12,c=u=>u*t*e;a.beginPath(),a.moveTo(c(l*1),c(l*3)),a.lineTo(c(l*3),c(l*1)),a.moveTo(c(l*5),c(l*7)),a.lineTo(c(l*7),c(l*5)),a.moveTo(c(l*9),c(l*11)),a.lineTo(c(l*11),c(l*9)),a.stroke(),i.toBlob(u=>{!u||xt.throwToBlob.get()?o():r(u)})}),fI=(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()):""};let yy=null;function wX(){return yy||(yy={white:fI([1,1],e=>{e.fillStyle="#f8f9fa",e.fillRect(0,0,1,1)}),black:fI([1,1],e=>{e.fillStyle="#212529",e.fillRect(0,0,1,1)})}),yy}function _A(e){return Math.ceil(Math.log2(Math.max(1,e)))}function wf(e,t){const n=_A(e);return`tldraw_hash_pattern_${t}_${n}`}function TA(e){const t=[],r=_A(e);for(let o=0;o<=r;o++)t.push(Math.pow(2,o));return t}function bX(e){const t=wX();return TA(e).flatMap(n=>[{zoom:n,url:t.white,theme:"light"},{zoom:n,url:t.black,theme:"dark"}])}function PX(){const e=F(),t=K("devicePixelRatio",()=>e.getInstanceState().devicePixelRatio,[e]),n=K("maxZoom",()=>Math.ceil(Ut(e.getCameraOptions().zoomSteps)),[e]),[r,o]=P.useState(!1),[s,i]=P.useState(()=>bX(n));return P.useEffect(()=>{const l=Promise.all(TA(n).flatMap(u=>[pI(t,u,!1).then(h=>({zoom:u,theme:"light",url:URL.createObjectURL(h)})),pI(t,u,!0).then(h=>({zoom:u,theme:"dark",url:URL.createObjectURL(h)}))]));let c=!1;return l.then(u=>{c||(i(u),o(!0))}),()=>{c=!0,o(!1),l.then(u=>{for(const{url:h}of u)URL.revokeObjectURL(h)})}},[t,n]),{defs:d.jsx(d.Fragment,{children:s.map(l=>{const c=wf(l.zoom,l.theme);return d.jsx("pattern",{id:c,width:kc,height:kc,patternUnits:"userSpaceOnUse",children:d.jsx("image",{href:l.url,width:kc,height:kc})},c)})}),isReady:r}}function CX(){const e=F(),t=P.useRef(null),{defs:n,isReady:r}=PX();return P.useEffect(()=>{if(r&&e.environment.isSafari){const o=MA(t.current);o&&e.timers.requestAnimationFrame(()=>{o.style.display="none",e.timers.requestAnimationFrame(()=>{o.style.display=""})})}},[e,r]),d.jsx("g",{ref:t,"data-testid":r?"ready-pattern-fill-defs":void 0,children:n})}function MA(e){return e.classList.contains("tl-html-layer")?e:e.parentElement?MA(e.parentElement):null}const rn=Ce.memo(function({theme:t,d:n,color:r,fill:o,scale:s}){switch(o){case"none":return null;case"solid":return d.jsx("path",{fill:t[r].semi,d:n});case"semi":return d.jsx("path",{fill:t.solid,d:n});case"fill":return d.jsx("path",{fill:t[r].fill,d:n});case"pattern":return d.jsx(IX,{theme:t,color:r,fill:o,d:n,scale:s})}});function IX({d:e,color:t,theme:n}){const r=F(),o=ZM(),s=K("zoomLevel",()=>r.getZoomLevel(),[r]),i=r.getZoomLevel()<=.18;return d.jsxs(d.Fragment,{children:[d.jsx("path",{fill:n[t].pattern,d:e}),d.jsx("path",{fill:o?`url(#${wf(1,n.id)})`:i?n[t].semi:`url(#${wf(s,n.id)})`,d:e})]})}function EX(e){return e.replace(/\s/g," ")}function Rv(e,t,n){const{padding:r=0}=n;if(t.length===0)return null;const o=Q.From(t[0].box);for(const{box:c}of t)o.union(c);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 l=[];for(const{text:c,box:u}of t)a!==null&&u.y>a&&l.push(d.jsx("tspan",{alignmentBaseline:"mathematical",x:s,y:u.y+i,children:`
|
|
201
|
+
`},l.length)),l.push(d.jsx("tspan",{alignmentBaseline:"mathematical",x:u.x+s,y:u.y+i,unicodeBidi:"plaintext",children:EX(c)},l.length)),a=u.y;return d.jsx("text",{fontSize:n.fontSize,fontFamily:n.fontFamily,fontStyle:n.fontStyle,fontWeight:n.fontWeight,dominantBaseline:"mathematical",alignmentBaseline:"mathematical",stroke:n.stroke,strokeWidth:n.strokeWidth,fill:n.fill,children:l})}function kX(e,t,n,r){if((e==="start-legacy"||e==="end-legacy")&&n.length!==0){const o=Q.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 _X(e){return e==="start-legacy"||e==="middle-legacy"||e==="end-legacy"}function vg({fontSize:e,font:t,align:n,verticalAlign:r,text:o,labelColor:s,bounds:i,padding:a=16,stroke:l=!0}){const c=F(),u=jr(),h={fontSize:e,fontFamily:S_[t],textAlign:n,verticalTextAlign:r,width:Math.ceil(i.width),height:Math.ceil(i.height),padding:a,lineHeight:Vt.lineHeight,fontStyle:"normal",fontWeight:"normal",overflow:"wrap",offsetX:0,offsetY:0,fill:s,stroke:void 0,strokeWidth:void 0},p=c.textMeasure.measureTextSpans(o,h),f=kX(n,a,p,i.width);f&&(h.offsetX=f),h.offsetX+=i.x,h.offsetY+=i.y;const S=Rv(c,p,h);let y=null;return l&&(h.fill=u.background,h.stroke=u.background,h.strokeWidth=2,y=Rv(c,p,h)),d.jsxs(d.Fragment,{children:[y,S]})}const TX=P.forwardRef(function({isEditing:t,text:n,handleFocus:r,handleChange:o,handleKeyDown:s,handleBlur:i,handleInputPointerDown:a,handleDoubleClick:l},c){return d.jsx("textarea",{ref:c,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",defaultValue:n,onFocus:r,onChange:o,onKeyDown:s,onBlur:i,onTouchEnd:Ot,onContextMenu:t?Ot:void 0,onPointerDown:a,onDoubleClick:l,onDragStart:Ee})});function MX(e,t,n){const r=F(),o=P.useRef(null),s=K("isEditing",()=>r.getEditingShapeId()===e,[r]),i=K("isEditingAnything",()=>!!r.getEditingShapeId(),[r]);P.useEffect(()=>{function u({shapeId:h}){var p;h===e&&((p=o.current)==null||p.select())}return r.on("select-all-text",u),()=>{r.off("select-all-text",u)}},[r,e,s]),P.useEffect(()=>{var u,h,p,f;s&&(document.activeElement!==o.current&&((u=o.current)==null||u.focus()),r.getInstanceState().isCoarsePointer&&((h=o.current)==null||h.select()),r.environment.isSafari&&((p=o.current)==null||p.blur(),(f=o.current)==null||f.focus()))},[r,s]);const a=P.useCallback(u=>{if(r.getEditingShapeId()===e)switch(u.key){case"Enter":{(u.ctrlKey||u.metaKey)&&r.complete();break}}},[r,e]),l=P.useCallback(u=>{if(r.getEditingShapeId()!==e)return;let h=ml.normalizeText(u.currentTarget.value);const p=h.replace(/\t/g,Ga);if(p!==h){const f=u.currentTarget.selectionStart;u.currentTarget.value=p,u.currentTarget.selectionStart=f+(p.length-h.length),u.currentTarget.selectionEnd=f+(p.length-h.length),h=p}r.updateShape({id:e,type:t,props:{text:h}})},[r,e,t]),c=P.useCallback(u=>{r.dispatch({...Fn(u),type:"pointer",name:"pointer_down",target:"shape",shape:r.getShape(e)}),Ot(u)},[r,e]);return{rInput:o,handleFocus:nu,handleBlur:nu,handleKeyDown:a,handleChange:l,handleInputPointerDown:c,handleDoubleClick:Ot,isEmpty:n.trim().length===0,isEditing:s,isEditingAnything:i}}const xg=Ce.memo(function({id:t,type:n,text:r,labelColor:o,font:s,fontSize:i,lineHeight:a,align:l,verticalAlign:c,wrap:u,isSelected:h,padding:p=0,onKeyDown:f,classNamePrefix:S,style:y,textWidth:x,textHeight:m}){const{rInput:v,isEmpty:w,isEditing:C,isEditingAnything:E,..._}=MX(t,n,r),[I,k]=P.useState(r);P.useEffect(()=>{C||k(r)},[C,r]);const T=ml.normalizeTextForDom(r),M=T.length>0,D=_X(l);if(!C&&!M)return null;const $=S||"tl-text";return d.jsx("div",{className:`${$}-label tl-text-wrapper`,"data-font":s,"data-align":l,"data-hastext":!w,"data-isediting":C,"data-iseditinganything":E,"data-textwrap":!!u,"data-isselected":h,style:{justifyContent:l==="middle"||D?"center":l,alignItems:c==="middle"?"center":c,padding:p,...y},children:d.jsxs("div",{className:`${$}-label__inner tl-text-content__wrapper`,style:{fontSize:i,lineHeight:Math.floor(i*a)+"px",minHeight:Math.floor(i*a)+"px",minWidth:Math.ceil(x||0),color:o,width:x?Math.ceil(x):void 0,height:m?Math.ceil(m):void 0},children:[d.jsx("div",{className:`${$} tl-text tl-text-content`,dir:"auto",children:T.split(`
|
|
202
|
+
`).map((j,O)=>d.jsx("div",{dir:"auto",children:j},O))}),(E||h)&&d.jsx(TX,{ref:v,text:r,isEditing:C,..._,handleKeyDown:f??_.handleKeyDown},I)]})})});function ao(e,t,n={}){const{closed:r=!1,snap:o=1,start:s="outset",end:i="outset",lengthRatio:a=2,style:l="dashed"}=n;let c=0,u=0,h=1,p=0,f=0;switch(l){case"dashed":{h=1,c=Math.min(t*a,e/4);break}case"dotted":{h=100,c=t/h;break}default:return{strokeDasharray:"none",strokeDashoffset:"none"}}return r||(s==="outset"?(e+=c/2,f+=c/2):s==="skip"&&(e-=c,f-=c),i==="outset"?e+=c/2:i==="skip"&&(e-=c)),u=Math.floor(e/c/(2*h)),u-=u%o,u<3&&l==="dashed"?e/t<4?(c=e,u=1,p=0):(c=e*(1/3),p=e*(1/3)):(c=e/u/(2*h),r?(f=c/2,p=(e-u*c)/u):p=(e-u*c)/Math.max(1,u-1)),{strokeDasharray:[c,p].join(" "),strokeDashoffset:f.toString()}}const gI=new WeakMap;function Sw(e,t){const n=gI.get(t);if(n)return n;const r=fo(e,t);let o=0,s=0;const i=r.isStraight?new Wo({start:b.From(r.start.point),end:b.From(r.end.point)}):new Ua({center:b.Cast(r.handleArc.center),start:b.Cast(r.start.point),end:b.Cast(r.end.point),sweepFlag:r.bodyArc.sweepFlag,largeArcFlag:r.bodyArc.largeArcFlag});if(t.props.text.trim()){const l=i.bounds,c=Lv(t),{w:u,h}=e.textMeasure.measureText(t.props.text,{...Vt,fontFamily:wo[t.props.font],fontSize:c,maxWidth:null});if(o=u,s=h,l.width>l.height){o=Math.max(Math.min(u,64),Math.min(l.width-64,u));const{w:p,h:f}=e.textMeasure.measureText(t.props.text,{...Vt,fontFamily:wo[t.props.font],fontSize:c,maxWidth:o});o=p,s=f}if(o>16*c){o=16*c;const{w:p,h:f}=e.textMeasure.measureText(t.props.text,{...Vt,fontFamily:wo[t.props.font],fontSize:c,maxWidth:o});o=p,s=f}}const a=new b(o,s).addScalar(kY*2*t.props.scale);return gI.set(t,a),a}function AA(e){const t=jt[e.props.size];return(EY+(t-jt.s)*2+(t===jt.xl?20:0))*e.props.scale}function AX(e,t,n){const r=Sw(e,t),o=AA(t),s=b.Nudge(n.start.point,n.end.point,o),i=b.Nudge(n.end.point,n.start.point,o),a=nw(s,i,Q.FromCenter(n.middle,r).corners);if(!a||a.length!==2)return{start:.5,end:.5};let[l,c]=a;b.Dist2(l,s)>b.Dist2(c,s)&&([c,l]=a);const u=s.add(b.Sub(n.middle,l)),h=i.add(b.Sub(n.middle,c)),p=b.Dist(n.start.point,u)/n.length,f=b.Dist(n.start.point,h)/n.length;return{start:p,end:f}}function jX(e,t,n){const r=Sw(e,t),o=AA(t),s=Math.sign(t.props.bend),i=o/n.handleArc.radius*s,a=b.Angle(n.bodyArc.center,n.start.point)-i,l=b.Angle(n.bodyArc.center,n.end.point)+i,c=zi(n.bodyArc.center,n.bodyArc.radius,a),u=zi(n.bodyArc.center,n.bodyArc.radius,l),h=[],p=mI(n.bodyArc.center,n.bodyArc.radius,a,l,s,Q.FromCenter(c,r).corners);h.push(new vt({points:Q.FromCenter(c,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));const f=mI(n.bodyArc.center,n.bodyArc.radius,a,l,s,Q.FromCenter(u,r).corners);h.push(new vt({points:Q.FromCenter(u,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));for(const I of[...p??[],...f??[],c,u])h.push(new hw({x:I.x-3,y:I.y-3,radius:3,isFilled:!1,debugColor:"magenta",ignore:!0}));const S=(p&&yI(n.start.point,p))??n.middle,y=(f&&yI(n.end.point,f))??n.middle,x=b.Angle(n.bodyArc.center,n.start.point),m=b.Angle(n.bodyArc.center,n.end.point),v=b.Angle(n.bodyArc.center,S),w=b.Angle(n.bodyArc.center,y);if(ks(x,v,s)>ks(x,w,s))return{start:.5,end:.5,dbg:h};const C=ks(x,m,s),E=ks(x,v,s)/C,_=ks(x,w,s)/C;return{start:E,end:_,dbg:h}}function tp(e,t){let n;const r=[],o=fo(e,t),s=!!o.bindings.start,i=!!o.bindings.end,a=o.start.arrowhead!=="none",l=o.end.arrowhead!=="none";if(o.isStraight){const u=AX(e,t,o);let h=_t(t.props.labelPosition,a||s?u.start:0,l||i?u.end:1);h=h>=.48&&h<=.52?.5:h,n=b.Lrp(o.start.point,o.end.point,h)}else{const u=jX(e,t,o);u.dbg&&r.push(...u.dbg);let h=_t(t.props.labelPosition,a||s?u.start:0,l||i?u.end:1);h=h>=.48&&h<=.52?.5:h;const p=OX(b.Angle(o.bodyArc.center,o.start.point),b.Angle(o.bodyArc.center,o.end.point),Math.sign(t.props.bend),h);n=zi(o.bodyArc.center,o.bodyArc.radius,p)}const c=Sw(e,t);return{box:Q.FromCenter(n,c),debugGeom:r}}function mI(e,t,n,r,o,s){const i=kv(e,t,s),a=ks(n,r,o);return i==null?void 0:i.filter(l=>{const c=ks(n,b.Angle(e,l),o);return c>=0&&c<=a})}function yI(e,t){let n=null,r=-1/0;for(const o of t){const s=b.Dist2(e,o);s>r&&(n=o,r=s)}return n}function OX(e,t,n,r){const o=ks(e,t,n);return e+o*r*n*-1}function Lv(e){return IY[e.props.size]*e.props.scale}function DX(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?b.Dist(o,r):Math.abs(e.bodyArc.length),i=Math.max(Math.min(s/5,n*3),n);let a;if(e.isStraight)a=b.Nudge(r,o,i);else{const l=nG(r,i,e.handleArc.center,e.handleArc.radius);a=t==="end"?e.handleArc.sweepFlag?l[0]:l[1]:e.handleArc.sweepFlag?l[1]:l[0]}return b.IsNaN(a)&&(a=e.start.point),{point:r,int:a}}function RX({point:e,int:t}){const n=b.RotWith(t,e,Me/6),r=b.RotWith(t,e,-Me/6);return`M ${n.x} ${n.y} L ${e.x} ${e.y} L ${r.x} ${r.y}`}function LX({point:e,int:t}){const n=b.RotWith(t,e,Me/6),r=b.RotWith(t,e,-Me/6);return`M ${n.x} ${n.y} L ${e.x} ${e.y} L ${r.x} ${r.y} Z`}function $X({point:e,int:t}){const n=b.Sub(t,e).div(2),r=b.Add(e,b.Rot(n,Ve)),o=b.Sub(e,b.Rot(n,Ve));return`M ${r.x} ${r.y} L ${t.x} ${t.y} L ${o.x} ${o.y} Z`}function NX({point:e,int:t}){const n=b.Lrp(e,t,.45),r=b.Dist(n,e);return`M ${n.x-r},${n.y}
|
|
203
|
+
a ${r},${r} 0 1,0 ${r*2},0
|
|
204
|
+
a ${r},${r} 0 1,0 -${r*2},0 `}function FX({point:e,int:t}){const n=b.Lrp(e,t,.75),r=b.RotWith(n,e,Me/4),o=b.RotWith(n,e,-Me/4),s=b.Lrp(r,o,.5);return s.add(b.Sub(s,e)),`M ${s.x} ${s.y} L ${r.x} ${r.y} ${e.x} ${e.y} L ${o.x} ${o.y} Z`}function zX({int:e,point:t}){const n=b.Lrp(t,e,.85),r=b.Sub(n,t).div(2),o=b.Add(t,b.Rot(r,Ve)),s=b.Sub(t,b.Rot(r,Ve)),i=b.Add(n,b.Rot(r,Ve)),a=b.Sub(n,b.Rot(r,Ve));return`M ${o.x} ${o.y} L ${i.x} ${i.y} L ${a.x} ${a.y} L ${s.x} ${s.y} Z`}function BX({int:e,point:t}){const n=b.Sub(e,t).div(2),r=b.Add(t,b.Rot(n,Ve)),o=b.Sub(t,b.Rot(n,Ve));return`M ${r.x} ${r.y} L ${o.x} ${o.y}`}function bf(e,t,n){const r=t==="end"?e.end.arrowhead:e.start.arrowhead;if(r==="none")return;const o=DX(e,t,n);if(o){switch(r){case"bar":return BX(o);case"square":return zX(o);case"diamond":return FX(o);case"dot":return NX(o);case"inverted":return $X(o);case"arrow":return RX(o);case"triangle":return LX(o)}return""}}function UX(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 jA(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 OA(e,t){return`M${e.x},${e.y}L${t.x},${t.y}`}function HX(e){return OA(e.start.handle,e.end.handle)}function DA(e){return OA(e.start.point,e.end.point)}let KX=0;class np extends Wr{constructor(){super(...arguments);g(this,"canEdit",()=>!0);g(this,"canSnap",()=>!1);g(this,"hideResizeHandles",()=>!0);g(this,"hideRotateHandle",()=>!0);g(this,"hideSelectionBoundsBg",()=>!0);g(this,"hideSelectionBoundsFg",()=>!0);g(this,"canBeLaidOut",n=>{const r=$n(this.editor,n);return!r.start&&!r.end});g(this,"onHandleDrag",(n,{handle:r,isPrecise:o})=>{const s=r.id,i=$n(this.editor,n);if(s==="middle"){const{start:_,end:I}=Ha(this.editor,n,i),k=b.Sub(I,_),T=b.Per(k),M=b.Med(I,_),D=b.Sub(M,T),$=b.Add(M,T),j=b.NearestPointOnLineSegment(D,$,r,!1);let O=b.Dist(j,M);return b.Clockwise(j,I,M)&&(O*=-1),{id:n.id,type:n.type,props:{bend:O}}}const a={id:n.id,type:"arrow",props:{}},l=i[s],u=i[s==="start"?"end":"start"];if(this.editor.inputs.ctrlKey)return Xh(this.editor,n,s),a.props[s]={x:r.x,y:r.y},a;const h=this.editor.getShapePageTransform(n.id).applyToPoint(r),p=this.editor.getShapeAtPoint(h,{hitInside:!0,hitFrameInside:!0,margin:0,filter:_=>!_.isLocked&&this.editor.canBindShapes({fromShape:n,toShape:_,binding:"arrow"})});if(!p)return Xh(this.editor,n,s),a.props[s]={x:r.x,y:r.y},a;const f=this.editor.getShapeGeometry(p),S=Q.ZeroFix(f.bounds),x=this.editor.getShapePageTransform(a.id).applyToPoint(r),m=this.editor.getPointInShapeSpace(p,x);let v=o;v||(!l||l&&p.id!==l.toId)&&(v=this.editor.inputs.pointerVelocity.len()<.5),o||(f.isClosed||(v=!0),u&&p.id===u.toId&&u.props.isPrecise&&(v=!0));const w={x:(m.x-S.minX)/S.width,y:(m.y-S.minY)/S.height};v&&b.Dist(m,S.center)<Math.max(4,Math.min(Math.min(S.width,S.height)*.15,16))/this.editor.getZoomLevel()&&(w.x=.5,w.y=.5);const C={terminal:s,normalizedAnchor:w,isPrecise:v,isExact:this.editor.inputs.altKey};lc(this.editor,n,p.id,C),this.editor.setHintingShapes([p.id]);const E=$n(this.editor,n);return E.start&&E.end&&E.start.toId===E.end.toId&&b.Equals(E.start.props.normalizedAnchor,E.end.props.normalizedAnchor)&&lc(this.editor,n,E.end.toId,{...E.end.props,normalizedAnchor:{x:E.end.props.normalizedAnchor.x+.05,y:E.end.props.normalizedAnchor.y}}),a});g(this,"onTranslateStart",n=>{const r=$n(this.editor,n),o=Ha(this.editor,n,r),s=this.editor.getShapePageTransform(n.id),i=this.editor.getSelectedShapeIds();if(!(r.start&&(i.includes(r.start.toId)||this.editor.isAncestorSelected(r.start.toId))||r.end&&(i.includes(r.end.toId)||this.editor.isAncestorSelected(r.end.toId)))){vI.set(n,{pagePosition:s.applyToPoint(n),terminalBindings:Bu(o,(a,l)=>{const c=r[a];return c?{binding:c,shapePosition:l,pagePosition:s.applyToPoint(l)}:null})}),r.start&&(vf({editor:this.editor,arrow:n,terminal:"start",useHandle:!0}),n=this.editor.getShape(n.id)),r.end&&vf({editor:this.editor,arrow:n,terminal:"end",useHandle:!0});for(const a of["start","end"]){const l=r[a];l&&this.editor.updateBinding({...l,props:{...l.props,isPrecise:!0}})}}});g(this,"onTranslate",(n,r)=>{const o=vI.get(n);if(!o)return;const s=this.editor.getShapePageTransform(r.id),i=b.Sub(s.applyToPoint(r),o.pagePosition);for(const a of Object.values(o.terminalBindings)){if(!a)continue;const l=b.Add(a.pagePosition,b.Mul(i,.5)),c=this.editor.getShapeAtPoint(l,{hitInside:!0,hitFrameInside:!0,margin:0,filter:u=>!u.isLocked&&this.editor.canBindShapes({fromShape:r,toShape:u,binding:"arrow"})});if((c==null?void 0:c.id)===a.binding.toId){const u=Q.ZeroFix(this.editor.getShapeGeometry(c).bounds),h=this.editor.getPointInShapeSpace(c,l),p={x:(h.x-u.minX)/u.width,y:(h.y-u.minY)/u.height};lc(this.editor,r,c.id,{...a.binding.props,normalizedAnchor:p,isPrecise:!0})}else Xh(this.editor,r,a.binding.props.terminal)}});g(this,"_resizeInitialBindings",new Qo);g(this,"onResize",(n,r)=>{const{scaleX:o,scaleY:s}=r,i=this._resizeInitialBindings.get(n,()=>$n(this.editor,n)),a=Ha(this.editor,n,i),{start:l,end:c}=Ge(n.props);let{bend:u}=n.props;i.start||(l.x=a.start.x*o,l.y=a.start.y*s),i.end||(c.x=a.end.x*o,c.y=a.end.y*s);const h=Math.abs(o),p=Math.abs(s),f=i!=null&&i.start?b.From(i.start.props.normalizedAnchor):null,S=i!=null&&i.end?b.From(i.end.props.normalizedAnchor):null;return o<0&&s>=0?(u!==0&&(u*=-1,u*=Math.max(h,p)),f&&(f.x=1-f.x),S&&(S.x=1-S.x)):o>=0&&s<0?(u!==0&&(u*=-1,u*=Math.max(h,p)),f&&(f.y=1-f.y),S&&(S.y=1-S.y)):o>=0&&s>=0?u!==0&&(u*=Math.max(h,p)):o<0&&s<0&&(u!==0&&(u*=Math.max(h,p)),f&&(f.x=1-f.x,f.y=1-f.y),S&&(S.x=1-S.x,S.y=1-S.y)),i.start&&f&&lc(this.editor,n,i.start.toId,{...i.start.props,normalizedAnchor:f.toJson()}),i.end&&S&&lc(this.editor,n,i.end.toId,{...i.end.props,normalizedAnchor:S.toJson()}),{props:{start:l,end:c,bend:u}}});g(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"}}}});g(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()}}])})}canBind({toShapeType:n}){return n!=="arrow"}getDefaultProps(){return{dash:"draw",size:"m",fill:"none",color:"black",labelColor:"black",bend:0,start:{x:0,y:0},end:{x:2,y:0},arrowheadStart:"none",arrowheadEnd:"arrow",text:"",labelPosition:.5,font:"draw",scale:1}}getGeometry(n){const r=fo(this.editor,n),o=[],s=r.isStraight?new Wo({start:b.From(r.start.point),end:b.From(r.end.point)}):new Ua({center:b.Cast(r.handleArc.center),start:b.Cast(r.start.point),end:b.Cast(r.end.point),sweepFlag:r.bodyArc.sweepFlag,largeArcFlag:r.bodyArc.largeArcFlag});let i;if(n.props.text.trim()){const a=tp(this.editor,n);o.push(...a.debugGeom),i=new os({x:a.box.x,y:a.box.y,width:a.box.w,height:a.box.h,isFilled:!0,isLabel:!0})}return new Gr({children:[...i?[s,i]:[s],...o]})}getHandles(n){const r=fo(this.editor,n);return[{id:"start",type:"vertex",index:"a0",x:r.start.handle.x,y:r.start.handle.y},{id:"middle",type:"virtual",index:"a2",x:r.middle.x,y:r.middle.y},{id:"end",type:"vertex",index:"a3",x:r.end.handle.x,y:r.end.handle.y}].filter(Boolean)}component(n){const r=jr(),o=this.editor.getOnlySelectedShape(),s=this.editor.isInAny("select.idle","select.pointing_handle","select.dragging_handle","select.translating","arrow.dragging")&&!this.editor.getInstanceState().isReadonly,i=fo(this.editor,n);if(!(i!=null&&i.isValid))return null;const a=tp(this.editor,n),l=n.id===this.editor.getOnlySelectedShapeId(),u=this.editor.getEditingShapeId()===n.id||n.props.text;return d.jsxs(d.Fragment,{children:[d.jsx(Zs,{id:n.id,style:{minWidth:50,minHeight:50},children:d.jsx(SI,{shape:n,shouldDisplayHandles:s&&(o==null?void 0:o.id)===n.id})}),u&&d.jsx(xg,{id:n.id,classNamePrefix:"tl-arrow",type:"arrow",font:n.props.font,fontSize:Lv(n),lineHeight:Vt.lineHeight,align:"middle",verticalAlign:"middle",text:n.props.text,labelColor:r[n.props.labelColor].solid,textWidth:a.box.w,isSelected:l,padding:0,style:{transform:`translate(${a.box.center.x}px, ${a.box.center.y}px)`}})]})}indicator(n){const r=gg(n.id),o=fo(this.editor,n);if(!o)return null;const{start:s,end:i}=Ha(this.editor,n,o==null?void 0:o.bindings),a=this.editor.getShapeGeometry(n),l=a.bounds,c=n.props.text.trim()?a.children[1]:null;if(b.Equals(s,i))return null;const u=jt[n.props.size]*n.props.scale,h=o.start.arrowhead&&bf(o,"start",u),p=o.end.arrowhead&&bf(o,"end",u),f=o.isStraight?DA(o):jA(o),S=h&&o.start.arrowhead!=="arrow"||p&&o.end.arrowhead!=="arrow"||!!c,y=(n.id+"_clip").replace(":","_");return r&&c?d.jsx("rect",{x:N(c.x),y:N(c.y),width:c.w,height:c.h,rx:3.5*n.props.scale,ry:3.5*n.props.scale}):d.jsxs("g",{children:[S&&d.jsx("defs",{children:d.jsxs("mask",{id:y,children:[d.jsx("rect",{x:l.minX-100,y:l.minY-100,width:l.w+200,height:l.h+200,fill:"white"}),c&&d.jsx("rect",{x:N(c.x),y:N(c.y),width:c.w,height:c.h,fill:"black",rx:3.5*n.props.scale,ry:3.5*n.props.scale}),h&&d.jsx("path",{d:h,fill:o.start.arrowhead==="arrow"?"none":"black",stroke:"none"}),p&&d.jsx("path",{d:p,fill:o.end.arrowhead==="arrow"?"none":"black",stroke:"none"})]})}),d.jsxs("g",{...S?{mask:`url(#${y})`}:void 0,children:[S&&d.jsx("rect",{x:l.minX-100,y:l.minY-100,width:l.width+200,height:l.height+200,opacity:0}),d.jsx("path",{d:f})]}),h&&d.jsx("path",{d:h}),p&&d.jsx("path",{d:p}),c&&d.jsx("rect",{x:N(c.x),y:N(c.y),width:c.w,height:c.h,rx:3.5,ry:3.5})]})}toSvg(n,r){r.addExportDef(mw(n.props.fill)),n.props.text&&r.addExportDef(Sg(n.props.font));const o=cs(r),s=1/n.props.scale;return d.jsxs("g",{transform:`scale(${s})`,children:[d.jsx(SI,{shape:n,shouldDisplayHandles:!1}),d.jsx(vg,{fontSize:Lv(n),font:n.props.font,align:"middle",verticalAlign:"middle",text:n.props.text,labelColor:o[n.props.labelColor].solid,bounds:tp(this.editor,n).box,padding:4*n.props.scale})]})}getCanvasSvgDefs(){return[yw(),{key:"arrow:dot",component:GX},{key:"arrow:cross",component:VX}]}getInterpolatedProps(n,r,o){return{...r.props,start:{x:Dn(n.props.start.x,r.props.start.x,o),y:Dn(n.props.start.y,r.props.start.y,o)},end:{x:Dn(n.props.end.x,r.props.end.x,o),y:Dn(n.props.end.y,r.props.end.y,o)},bend:Dn(n.props.bend,r.props.bend,o),labelPosition:Dn(n.props.labelPosition,r.props.labelPosition,o)}}}g(np,"type","arrow"),g(np,"props",x_),g(np,"migrations",w_);function WX(e,t){const n=fo(e,t);return n.isStraight?b.Dist(n.start.handle,n.end.handle):Math.abs(n.handleArc.length)}const SI=Lt(function({shape:t,shouldDisplayHandles:n}){const r=F(),o=jr(),s=fo(r,t),i=Q.ZeroFix(r.getShapeGeometry(t).bounds),a=$n(r,t),l=Ce.useMemo(()=>r.environment.isSafari?KX+=1:0,[t]);if(!(s!=null&&s.isValid))return null;const c=jt[t.props.size]*t.props.scale,u=s.start.arrowhead&&bf(s,"start",c),h=s.end.arrowhead&&bf(s,"end",c),p=s.isStraight?DA(s):jA(s);let f=null;if(n){const C=2/r.getZoomLevel(),{strokeDasharray:E,strokeDashoffset:_}=ao(WX(r,t),C,{end:"skip",start:"skip",lengthRatio:2.5});f=a.start||a.end?d.jsx("path",{className:"tl-arrow-hint",d:s.isStraight?HX(s):UX(s),strokeDasharray:E,strokeDashoffset:_,strokeWidth:C,markerStart:a.start?a.start.props.isExact?"":a.start.props.isPrecise?"url(#arrowhead-cross)":"url(#arrowhead-dot)":"",markerEnd:a.end?a.end.props.isExact?"":a.end.props.isPrecise?"url(#arrowhead-cross)":"url(#arrowhead-dot)":"",opacity:.16}):null}const{strokeDasharray:S,strokeDashoffset:y}=ao(s.isStraight?s.length:Math.abs(s.bodyArc.length),c,{style:t.props.dash}),x=tp(r,t),m=!(s.start.arrowhead==="none"||s.start.arrowhead==="arrow"),v=!(s.end.arrowhead==="none"||s.end.arrowhead==="arrow"),w=(t.id+"_clip_"+l).replace(":","_");return d.jsxs(d.Fragment,{children:[d.jsx("defs",{children:d.jsxs("mask",{id:w,children:[d.jsx("rect",{x:N(-100+i.minX),y:N(-100+i.minY),width:N(i.width+200),height:N(i.height+200),fill:"white"}),t.props.text.trim()&&d.jsx("rect",{x:x.box.x,y:x.box.y,width:x.box.w,height:x.box.h,fill:"black",rx:4,ry:4}),u&&m&&d.jsx("path",{d:u,fill:s.start.arrowhead==="arrow"?"none":"black",stroke:"none"}),h&&v&&d.jsx("path",{d:h,fill:s.end.arrowhead==="arrow"?"none":"black",stroke:"none"})]})}),d.jsxs("g",{fill:"none",stroke:o[t.props.color].solid,strokeWidth:c,strokeLinejoin:"round",strokeLinecap:"round",pointerEvents:"none",children:[f,d.jsxs("g",{mask:`url(#${w})`,children:[d.jsx("rect",{x:N(i.minX-100),y:N(i.minY-100),width:N(i.width+200),height:N(i.height+200),opacity:0}),d.jsx("path",{d:p,strokeDasharray:S,strokeDashoffset:y})]}),u&&m&&t.props.fill!=="none"&&d.jsx(rn,{theme:o,d:u,color:t.props.color,fill:t.props.fill,scale:t.props.scale}),h&&v&&t.props.fill!=="none"&&d.jsx(rn,{theme:o,d:h,color:t.props.color,fill:t.props.fill,scale:t.props.scale}),u&&d.jsx("path",{d:u}),h&&d.jsx("path",{d:h})]})]})}),vI=new WeakMap;function GX(){return d.jsx("marker",{id:"arrowhead-dot",className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"0",children:d.jsx("circle",{cx:"3",cy:"3",r:"2",strokeDasharray:"100%"})})}function VX(){return d.jsxs("marker",{id:"arrowhead-cross",className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"auto",children:[d.jsx("line",{x1:"1.5",y1:"1.5",x2:"4.5",y2:"4.5",strokeDasharray:"100%"}),d.jsx("line",{x1:"1.5",y1:"4.5",x2:"4.5",y2:"1.5",strokeDasharray:"100%"})]})}const xI="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 yl({url:e,zoomLevel:t}){return d.jsx("a",{className:ce("tl-hyperlink-button",{"tl-hyperlink-button__hidden":t<.32}),href:e,target:"_blank",rel:"noopener noreferrer",onPointerDown:Ot,onPointerUp:Ot,title:e,draggable:!1,children:d.jsx("div",{className:"tl-hyperlink__icon",style:{mask:`url("${xI}") center 100% / 100% no-repeat`,WebkitMask:`url("${xI}") center 100% / 100% no-repeat`}})})}const wI="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",YX=[{offsetX:0,offsetY:2,blur:4,spread:0,color:"#00000029"},{offsetX:0,offsetY:3,blur:6,spread:0,color:"#0000001f"}];function vw(e){return YX.map(n=>{const{offsetX:r,offsetY:o,blur:s,spread:i,color:a}=n,l=new b(r,o),{x:c,y:u}=l.rot(-e);return`${c}px ${u}px ${s}px ${i}px ${a}`}).join(", ")}const XX=300,RA=320,qX=46,ZX=101;class rp extends Dl{constructor(){super(...arguments);g(this,"canResize",()=>!1);g(this,"hideSelectionBoundsFg",()=>!0);g(this,"onBeforeCreate",n=>bI(this.editor,n));g(this,"onBeforeUpdate",(n,r)=>{if(n.props.url!==r.props.url)if(lr.isValid(r.props.url))JX(this.editor,r);else return{...r,props:{...r.props,url:n.props.url}};if(n.props.assetId!==r.props.assetId)return bI(this.editor,r)})}getDefaultProps(){return{url:"",w:XX,h:RA,assetId:null}}component(n){const r=n.props.assetId?this.editor.getAsset(n.props.assetId):null,o=this.editor.getShapePageTransform(n).rotation(),s=QX(n);return d.jsx(Gi,{children:d.jsxs("div",{className:"tl-bookmark__container",style:{boxShadow:vw(o),maxHeight:n.props.h},children:[(!r||r.props.image)&&d.jsxs("div",{className:"tl-bookmark__image_container",children:[r?d.jsx("img",{className:"tl-bookmark__image",draggable:!1,referrerPolicy:"strict-origin-when-cross-origin",src:r==null?void 0:r.props.image,alt:(r==null?void 0:r.props.title)||""}):d.jsx("div",{className:"tl-bookmark__placeholder"}),(r==null?void 0:r.props.image)&&d.jsx(yl,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]}),d.jsxs("div",{className:"tl-bookmark__copy_container",children:[r!=null&&r.props.title?d.jsx("h2",{className:"tl-bookmark__heading",children:r.props.title}):null,r!=null&&r.props.description&&(r!=null&&r.props.image)?d.jsx("p",{className:"tl-bookmark__description",children:r.props.description}):null,d.jsxs("a",{className:"tl-bookmark__link",href:n.props.url||"",target:"_blank",rel:"noopener noreferrer",onPointerDown:Ot,onPointerUp:Ot,onClick:Ot,children:[r!=null&&r.props.favicon?d.jsx("img",{className:"tl-bookmark__favicon",src:r==null?void 0:r.props.favicon,referrerPolicy:"strict-origin-when-cross-origin",alt:`favicon of ${s}`}):d.jsx("div",{className:"tl-hyperlink__icon",style:{mask:`url("${wI}") center 100% / 100% no-repeat`,WebkitMask:`url("${wI}") center 100% / 100% no-repeat`}}),d.jsx("span",{children:s})]})]})]})})}indicator(n){return d.jsx("rect",{width:N(n.props.w),height:N(n.props.h),rx:"6",ry:"6"})}}g(rp,"type","bookmark"),g(rp,"props",k_),g(rp,"migrations",__);function bI(e,t){const n=t.props.assetId?e.getAsset(t.props.assetId):null;let r=RA;return n&&(n.props.image||(n.props.title?r=ZX:r=qX)),{...t,props:{...t.props,h:r}}}const QX=e=>{try{return new URL(e.props.url).hostname.replace(/^www\./,"")}catch{return e.props.url}};function JX(e,t){const{url:n}=t.props,r=Ii.createId(xS(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}}]),eq(e,t))}const eq=Kk(async(e,t)=>{if(e.isDisposed)return;const{url:n}=t.props,r=await e.getAssetForExternalContent({type:"url",url:n});r&&e.run(()=>{e.createAssets([r]),e.updateShapes([{id:t.id,type:t.type,props:{assetId:r.id}}])})},500);function Vi(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${Te(r)}L${Te(o)}`;let s="";for(let i=2,a=n-1;i<a;i++)r=e[i].point,o=e[i+1].point,s+=Rn(r,o);return t?`M${Rn(e[0].point,e[1].point)}Q${Te(e[1].point)}${Rn(e[1].point,e[2].point)}T${s}${Rn(e[n-1].point,e[0].point)}${Rn(e[0].point,e[1].point)}Z`:`M${Te(e[0].point)}Q${Te(e[1].point)}${Rn(e[1].point,e[2].point)}${e.length>3?"T":""}${s}L${Te(e[n-1].point)}`}function tq(e,t={}){const{start:n={},end:r={}}=t,{cap:o=!0}=n,{cap:s=!0}=r;Xe(!n.taper&&!r.taper,"cap taper not supported here"),Xe(!n.easing&&!r.easing,"cap easing not supported here"),Xe(o&&s,"cap must be true");const i=Io(e,t);mg(i,t);const a=nq(i);let l="";for(const c of a)l+=oq(c,t);return l}function nq(e){if(e.length<=2)return[e];const t=[];let n=[e[0]],r=b.Sub(e[1].point,e[0].point).uni(),o,s,i,a,l;for(let c=1,u=e.length;c<u-1;c++){if(i=e[c-1],a=e[c],l=e[c+1],o=b.Sub(l.point,a.point).uni(),s=b.Dpr(r,o),r=o,s<-.8){const h={...a,point:a.input};n.push(h),t.push(Sy(n)),n=[h];continue}if(n.push(a),!(s>.7)&&(b.Dist2(i.point,a.point)+b.Dist2(a.point,l.point))/((i.radius+a.radius+l.radius)/3)**2<1.5){n.push(a),t.push(Sy(n)),n=[a];continue}}return n.push(e[e.length-1]),t.push(Sy(n)),t}function Sy(e){const t=e[0];let n;for(;e.length>2&&(n=e[1],b.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],b.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:b.Sub(e[0].point,e[1].point).uni()},e[e.length-1]={...e[e.length-1],vector:b.Sub(e[e.length-2].point,e[e.length-1].point).uni()}),e}function rq(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 oq(e,t={}){if(e.length===0)return"";if(e.length===1)return rq(e[0].point.x,e[0].point.y,e[0].radius);const{left:n,right:r}=pA(e,t);r.reverse();let o=`M${Te(n[0])}T`;for(let s=1;s<n.length;s++)o+=Rn(n[s-1],n[s]);{const s=e[e.length-1],i=s.radius,a=s.vector.clone().per().neg(),l=b.Add(s.point,b.Mul(a,i)),c=b.Add(s.point,b.Mul(a,-i));o+=`${Te(l)}A${N(i)},${N(i)} 0 0 1 ${Te(c)}T`}for(let s=1;s<r.length;s++)o+=Rn(r[s-1],r[s]);{const s=e[0],i=s.radius,a=s.vector.clone().per(),l=b.Add(s.point,b.Mul(a,i)),c=b.Add(s.point,b.Mul(a,-i));o+=`${Te(l)}A${N(i)},${N(i)} 0 0 1 ${Te(c)}Z`}return o}const sq=e=>e*.65+x9(e*Me/2)*.35,iq=e=>({size:e,thinning:.5,streamline:il(e,[9,16],[.64,.74],!0),smoothing:.62,easing:At.easeOutSine,simulatePressure:!0}),aq=e=>({size:1+e*1.2,thinning:.62,streamline:.62,smoothing:.62,simulatePressure:!1,easing:sq}),PI=e=>({size:e,thinning:0,streamline:il(e,[9,16],[.64,.74],!0),smoothing:.62,simulatePressure:!1,easing:At.linear}),lq=e=>({size:e,thinning:0,streamline:.62,smoothing:.62,simulatePressure:!1,easing:At.linear});function xw({strokeWidth:e,showAsComplete:t}){return{size:1+e,thinning:0,streamline:.5,smoothing:.5,simulatePressure:!1,easing:At.easeOutSine,last:t}}function $v(e,t,n,r){const o=e.isComplete||n;return r?e.isPen?{...lq(t),last:o}:{...PI(t),last:o}:e.dash==="draw"?e.isPen?{...aq(t),last:o}:{...iq(t),last:o}:{...PI(t),last:o}}function Sl(e){const t=[];for(const n of e)if(n.type==="free"||n.points.length<2)t.push(...n.points.map(b.Cast));else{const r=Math.max(4,Math.floor(b.Dist(n.points[0],n.points[1])/16));t.push(...b.PointsBetween(n.points[0],n.points[1],r))}return t}function cq(e,t){return{draw:"none",solid:"none",dotted:`0.1 ${t*2}`,dashed:`${t*2} ${t*2}`}[e.props.dash]}class op extends Wr{constructor(){super(...arguments);g(this,"hideResizeHandles",n=>vy(n));g(this,"hideRotateHandle",n=>vy(n));g(this,"hideSelectionBoundsFg",n=>vy(n));g(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:l,y:c,z:u})=>({x:Uo(o*l),y:Uo(s*c),z:u}))});return{props:{segments:i}}})}getDefaultProps(){return{segments:[],color:"black",fill:"none",dash:"draw",size:"m",isComplete:!1,isClosed:!1,isPen:!1,scale:1}}getGeometry(n){const r=Sl(n.props.segments),o=(jt[n.props.size]+1)*n.props.scale;if(n.props.segments.length===1){const i=Q.FromPoints(r);if(i.width<o*2&&i.height<o*2)return new hw({x:-o,y:-o,radius:o,isFilled:!0})}const s=Io(r,$v(n.props,o,n.props.isPen,!0)).map(i=>i.point);return n.props.isClosed?new vt({points:s,isFilled:n.props.fill!=="none"}):new Ol({points:s})}component(n){return d.jsx(Zs,{id:n.id,children:d.jsx(CI,{shape:n,zoomLevel:this.editor.getZoomLevel()})})}indicator(n){var h;const r=Sl(n.props.segments);let o=(jt[n.props.size]+1)*n.props.scale;const s=this.editor.getZoomLevel();!(s<.5&&s<1.5/o)&&!n.props.isPen&&n.props.dash==="draw"&&r.length===1&&(o+=qr(n.id)()*(o/6));const a=n.props.isComplete||((h=Ut(n.props.segments))==null?void 0:h.type)==="straight",l=$v(n.props,o,a,!0),c=Io(r,l),u=c.length>1?Vi(c,n.props.isClosed):LA(r[0],o);return d.jsx("path",{d:u})}toSvg(n,r){r.addExportDef(mw(n.props.fill));const o=1/n.props.scale;return d.jsx("g",{transform:`scale(${o})`,children:d.jsx(CI,{shape:n,zoomLevel:1})})}getCanvasSvgDefs(){return[yw()]}expandSelectionOutlinePx(n){const r=n.props.dash==="draw"?1.6:1;return jt[n.props.size]*r/2*n.props.scale}}g(op,"type","draw"),g(op,"props",M_),g(op,"migrations",A_);function LA(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 vy(e){return e.props.segments.length===1&&e.props.segments[0].points.length<2}function CI({shape:e,zoomLevel:t}){var h;const n=jr(),r=Sl(e.props.segments),o=e.props.isComplete||((h=Ut(e.props.segments))==null?void 0:h.type)==="straight";let s=(jt[e.props.size]+1)*e.props.scale;const i=t<.5&&t<1.5/s;!i&&!e.props.isPen&&e.props.dash==="draw"&&r.length===1&&(s+=qr(e.id)()*(s/6));const a=$v(e.props,s,o,i);if(!i&&e.props.dash==="draw")return d.jsxs(d.Fragment,{children:[e.props.isClosed&&e.props.fill&&r.length>1?d.jsx(rn,{d:Vi(Io(r,a),e.props.isClosed),theme:n,color:e.props.color,fill:e.props.isClosed?e.props.fill:"none",scale:e.props.scale}):null,d.jsx("path",{d:tq(r,a),strokeLinecap:"round",fill:n[e.props.color].solid})]});const l=Io(r,a),c=l.length<2,u=c?LA(r[0],0):Vi(l,e.props.isClosed);return d.jsxs(d.Fragment,{children:[d.jsx(rn,{d:u,theme:n,color:e.props.color,fill:c||e.props.isClosed?e.props.fill:"none",scale:e.props.scale}),d.jsx("path",{d:u,strokeLinecap:"round",fill:c?n[e.props.color].solid:"none",stroke:n[e.props.color].solid,strokeWidth:s,strokeDasharray:c?"none":cq(e,s),strokeDashoffset:"0"})]})}function uq(e,t,n={}){const{newPoint:r,handle:o,scaleX:s,scaleY:i}=t,{minWidth:a=1,maxWidth:l=1/0,minHeight:c=1,maxHeight:u=1/0}=n;let h=e.props.w*s,p=e.props.h*i;const f=new b(0,0);if(h>0){if(h<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=h-a;break}case"top":case"bottom":{f.x=(h-a)/2;break}default:f.x=0}h=a}}else if(f.x=h,h=-h,h<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=-h;break}default:f.x=-a}h=a}if(p>0){if(p<c){switch(o){case"top_left":case"top":case"top_right":{f.y=p-c;break}case"right":case"left":{f.y=(p-c)/2;break}default:f.y=0}p=c}}else if(f.y=p,p=-p,p<c){switch(o){case"top_left":case"top":case"top_right":{f.y=-p;break}default:f.y=-c}p=c}const{x:S,y}=f.rot(e.rotation).add(r);return{x:S,y,props:{w:Math.min(l,h),h:Math.min(u,p)}}}const dq=e=>Object.entries(e).filter(([t,n])=>n).map(([t])=>t).join(" ");class sp extends Dl{constructor(){super(...arguments);g(this,"hideSelectionBoundsFg",n=>!this.canResize(n));g(this,"canEdit",()=>!0);g(this,"canResize",n=>{var r,o;return!!((o=(r=Rs(n.props.url))==null?void 0:r.definition)!=null&&o.doesResize)});g(this,"canEditInReadOnly",()=>!0);g(this,"isAspectRatioLocked",n=>{const r=Rs(n.props.url);return(r==null?void 0:r.definition.isAspectRatioLocked)??!1});g(this,"onResize",(n,r)=>{const o=this.isAspectRatioLocked(n),s=Rs(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 l=n.props.w/n.props.h;l>1?i*=l:a/=l}return uq(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=gg(n.id),a=P.useMemo(()=>SA(s),[s]),l=K("is hovering",()=>{const{editingShapeId:f,hoveredShapeId:S}=this.editor.getCurrentPageState();if(f&&S!==f){const y=this.editor.getShape(f);if(y&&this.editor.isShapeOfType(y,"embed"))return!0}return!1},[]),c=this.editor.getShapePageTransform(n).rotation(),u=i||l;if(typeof window<"u"&&(window!==window.top||window.self!==window.parent)&&(a==null?void 0:a.definition.type)==="tldraw")return null;if((a==null?void 0:a.definition.type)==="github_gist"){const f=a.url.split("/").pop();if(!f)throw Error("No gist id!");return d.jsx(Gi,{className:"tl-embed-container",id:n.id,children:d.jsx(hq,{id:f,width:N(r),height:N(o),isInteractive:u,pageRotation:c})})}const p=dq({...n9,...(a==null?void 0:a.definition.overridePermissions)??{}});return d.jsx(Gi,{className:"tl-embed-container",id:n.id,children:a!=null&&a.definition?d.jsx("iframe",{className:"tl-embed",sandbox:p,src:a.embedUrl,width:N(r),height:N(o),draggable:!1,frameBorder:"0",referrerPolicy:"no-referrer-when-downgrade",style:{border:0,pointerEvents:u?"auto":"none",zIndex:u?"":"-1",boxShadow:vw(c),borderRadius:(a==null?void 0:a.definition.overrideOutlineRadius)??8,background:a==null?void 0:a.definition.backgroundColor}}):null})}indicator(n){const r=P.useMemo(()=>Rs(n.props.url),[n.props.url]);return d.jsx("rect",{width:N(n.props.w),height:N(n.props.h),rx:(r==null?void 0:r.definition.overrideOutlineRadius)??8,ry:(r==null?void 0:r.definition.overrideOutlineRadius)??8})}}g(sp,"type","embed"),g(sp,"props",j_),g(sp,"migrations",O_);function hq({id:e,file:t,isInteractive:n,width:r,height:o,style:s,pageRotation:i}){return d.jsx("iframe",{className:"tl-embed",draggable:!1,width:N(r),height:N(o),frameBorder:"0",scrolling:"no",seamless:!0,referrerPolicy:"no-referrer-when-downgrade",style:{...s,pointerEvents:n?"all":"none",zIndex:n?"":"-1",boxShadow:vw(i)},srcDoc:`
|
|
205
|
+
<html>
|
|
206
|
+
<head>
|
|
207
|
+
<base target="_blank">
|
|
208
|
+
</head>
|
|
209
|
+
<body>
|
|
210
|
+
<script src=${`https://gist.github.com/${e}.js${t?`?file=${t}`:""}`}><\/script>
|
|
211
|
+
<style type="text/css">
|
|
212
|
+
* { margin: 0px; }
|
|
213
|
+
table { height: 100%; background-color: red; }
|
|
214
|
+
.gist { background-color: none; height: 100%; }
|
|
215
|
+
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
|
|
216
|
+
</style>
|
|
217
|
+
</body>
|
|
218
|
+
</html>`})}const pq=P.forwardRef(({id:e,name:t,isEditing:n},r)=>{const o=F(),s=P.useCallback(l=>{l.key==="Enter"&&!l.nativeEvent.isComposing&&(Ot(l),l.currentTarget.blur(),o.setEditingShape(null))},[o]),i=P.useCallback(l=>{const c=o.getShape(e);if(!c)return;const u=c.props.name,h=l.currentTarget.value.trim();u!==h&&o.updateShapes([{id:e,type:"frame",props:{name:h}}])},[e,o]),a=P.useCallback(l=>{const c=o.getShape(e);if(!c)return;const u=c.props.name,h=l.currentTarget.value;u!==h&&o.updateShapes([{id:e,type:"frame",props:{name:h}}])},[e,o]);return d.jsxs("div",{className:`tl-frame-label ${n?"tl-frame-label__editing":""}`,children:[d.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}),$A(t,"Frame")+""]})}),fq=function({id:t,name:n,width:r,height:o}){const s=F(),i=K("shape rotation",()=>Ns(s.getShapePageTransform(t).rotation()),[s,t]),a=gg(t),l=P.useRef(null),c=P.useCallback(S=>{const y=Fn(S);S.preventDefault(),s.getEditingShapeId()!==t&&s.dispatch({type:"pointer",name:"pointer_down",target:"shape",shape:s.getShape(t),...y})},[s,t]);P.useEffect(()=>{const S=l.current;S&&a&&(S.focus(),S.select())},[l,a]);const h=((i+Math.PI/4)*(2/Math.PI)+4)%4,p=["top","left","bottom","right"][Math.floor(h)];let f;switch(p){case"top":f="";break;case"right":f=`translate(${N(r)}px, 0px) rotate(90deg)`;break;case"bottom":f=`translate(${N(r)}px, ${N(o)}px) rotate(180deg)`;break;case"left":f=`translate(0px, ${N(o)}px) rotate(270deg)`;break}return d.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:c,children:d.jsx("div",{className:"tl-frame-heading-hit-area",children:d.jsx(pq,{ref:l,id:t,name:n,isEditing:a})})})};function $A(e,t){return e.match(/^\s*$/)?t:e}class ip extends Dl{constructor(){super(...arguments);g(this,"canEdit",()=>!0);g(this,"canReceiveNewChildrenOfType",(n,r)=>!n.isLocked);g(this,"canDropShapes",(n,r)=>!n.isLocked);g(this,"onDragShapesOver",(n,r)=>{r.every(o=>o.parentId===n.id)||this.editor.reparentShapes(r,n.id)});g(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())});g(this,"onResize",(n,r)=>uw(n,r))}getDefaultProps(){return{w:160*2,h:90*2,name:""}}getGeometry(n){return new os({width:n.props.w,height:n.props.h,isFilled:!1})}component(n){const r=this.editor.getShapeGeometry(n).bounds,o=jr(),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 d.jsxs(d.Fragment,{children:[d.jsx(Zs,{children:d.jsx("rect",{className:ce("tl-frame__body",{"tl-frame__creating":s}),width:r.width,height:r.height,fill:o.solid,stroke:o.text})}),s?null:d.jsx(fq,{id:n.id,name:n.props.name,width:r.width,height:r.height})]})}toSvg(n,r){const o=cs({isDarkMode:r.isDarkMode}),a=((Ns(this.editor.getShapePageTransform(n.id).rotation())+Math.PI/4)*(2/Math.PI)+4)%4,l=Math.floor(a);let c;switch(l){case 0:c="";break;case 3:c=`translate(${N(n.props.w)}, 0) rotate(90)`;break;case 2:c=`translate(${N(n.props.w)}, ${N(n.props.h)}) rotate(180)`;break;case 1:c=`translate(0, ${N(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"},h=this.editor.textMeasure.measureTextSpans($A(n.props.name,"Frame")+"",u),p=h[0],f=Ut(h),S=f.box.w+f.box.x-p.box.x,y=Rv(this.editor,h,{offsetY:-u.height-2,...u});return d.jsxs(d.Fragment,{children:[d.jsx("rect",{width:n.props.w,height:n.props.h,fill:o.solid,stroke:o.black.solid,strokeWidth:1,rx:1,ry:1}),d.jsxs("g",{transform:c,children:[d.jsx("rect",{x:-8,y:-u.height-4,width:S+16,height:u.height,fill:o.background,rx:4,ry:4}),y]})]})}indicator(n){const r=this.editor.getShapeGeometry(n).bounds;return d.jsx("rect",{width:N(r.width),height:N(r.height),className:"tl-frame-indicator"})}providesBackgroundForChildren(){return!0}}g(ip,"type","frame"),g(ip,"props",D_),g(ip,"migrations",R_);function II(e,t){return e>t?(Me*(t/2)+(e-t))*2:(Me*(e/2)+(t-e))*2}function NA(e,t){return ww(e,t).map((n,r)=>n.getSvgPathData(r===0)).join(" ")+" Z"}function gq(e,t,n,r){const o=e/4,s=t/4,i=qr(r),a=n*.75,l=v=>v.addXY(i()*a,i()*a),c=new b(e/2,t),u=new b(0,s*1.2),h=new b(e/2,s*.9),p=new b(e,s*1.2),f=l(new b(e/2,t)),S=l(new b(0,s*1.2)),y=l(new b(e/2,s*.9)),x=l(new b(e,s*1.2));return[new sn({start:c,cp1:new b(o*1.5,s*3),cp2:new b(0,s*2.5),end:u}),new sn({start:u,cp1:new b(0,-s*.32),cp2:new b(o*1.85,-s*.32),end:h}),new sn({start:h,cp1:new b(o*2.15,-s*.32),cp2:new b(e,-s*.32),end:p}),new sn({start:p,cp1:new b(e,s*2.5),cp2:new b(o*2.5,s*3),end:f}),new sn({start:f,cp1:new b(o*1.5,s*3),cp2:new b(0,s*2.5),end:S}),new sn({start:S,cp1:new b(0,-s*.32),cp2:new b(o*1.85,-s*.32),end:y}),new sn({start:y,cp1:new b(o*2.15,-s*.32),cp2:new b(e,-s*.32),end:x}),new sn({start:x,cp1:new b(e,s*2.5),cp2:new b(o*2.5,s*3),end:c})].map((v,w)=>v.getSvgPathData(w===0)).join(" ")+" Z"}function ww(e,t){const n=e/4,r=t/4;return[new sn({start:new b(e/2,t),cp1:new b(n*1.5,r*3),cp2:new b(0,r*2.5),end:new b(0,r*1.2)}),new sn({start:new b(0,r*1.2),cp1:new b(0,-r*.32),cp2:new b(n*1.85,-r*.32),end:new b(e/2,r*.9)}),new sn({start:new b(e/2,r*.9),cp1:new b(n*2.15,-r*.32),cp2:new b(e,-r*.32),end:new b(e,r*1.2)}),new sn({start:new b(e,r*1.2),cp1:new b(e,r*2.5),cp2:new b(n*2.5,r*3),end:new b(e/2,t)})]}function mq(e){return{size:1+e,thinning:.25,end:{taper:e},start:{taper:e},streamline:0,smoothing:1,simulatePressure:!1}}function yq(e,t,n,r){const o=qr(e),s=t/2,i=n/2,a=t2(s,i),l=[],c=Le*o(),u=Le+Ve/2+Math.abs(o())*Ve,h=Math.max(16,a/10);for(let p=0;p<h;p++){const f=p/(h-1),S=c+f*u,y=Math.cos(S),x=Math.sin(S);l.push(new b(s*y+t*.5+.05*o(),i*x+n/2+.05*o(),Math.min(1,.5+Math.abs(.5-(o()>0?At.easeInOutSine(f):At.easeInExpo(f)))/2)))}return Io(l,mq(r))}function Sq(e,t,n,r){return Vi(yq(e,t,n,r))}function Nv(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+=`${Te(r)}L${Te(o)}Q${Te(s)}`;return t+=`${Te(e[0])}`,t}function Fv(e,t,n,r,o){const s=[],i=qr(e);let a=t[0],l;const c=t.length;for(let u=0,h=c*o;u<h;u++){l=b.AddXY(t[(u+1)%c],i()*n,i()*n);const p=b.Sub(l,a),f=b.Len(p),S=b.Div(p,f).mul(Math.min(f/4,r));s.push(b.Add(a,S),b.Add(l,S.neg()),l),a=l}return s}function vq(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 b(r,0),delta:new b(1,0)},{type:"arc",center:new b(e-r,r),startAngle:-Me/2},{type:"straight",start:new b(e-r,t),delta:new b(-1,0)},{type:"arc",center:new b(r,r),startAngle:Me/2}]:[{type:"straight",start:new b(e,r),delta:new b(0,1)},{type:"arc",center:new b(r,t-r),startAngle:0},{type:"straight",start:new b(0,t-r),delta:new b(0,-1)},{type:"arc",center:new b(r,r),startAngle:Me}];let l=0;const c=[];for(let u=0;u<n;u++){const h=a[0];h.type==="straight"?c.push(b.Add(h.start,b.Mul(h.delta,l))):c.push(zi(h.center,r,h.startAngle+l/r)),l+=i;let p=h.type==="straight"?o:Me*r;for(;l>p;)l-=p,a.push(a.shift()),p=a[0].type==="straight"?o:Me*r}return c}const xq={s:50,m:70,l:100,xl:130},wq=.2;function wg(e,t,n,r){const o=qr(n),s=II(e,t),i=Math.max(Math.ceil(s/xq[r]),6,Math.ceil(s/Math.min(e,t))),a=s/i*wq,l=Math.max(e-a*2,1),c=Math.max(t-a*2,1),h=II(l,c)/i,p=(e-l)/2,f=(t-c)/2,S=vq(l,c,i).map(w=>w.addXY(p,f)),y=e<20?0:a*.3,x=t<20?0:a*.3,m=S.slice(0);for(let w=0;w<Math.floor(i/2);w++)m[w]=b.AddXY(m[w],o()*y,o()*x),m[i-w-1]=b.AddXY(m[i-w-1],o()*y,o()*x);const v=[];for(let w=0;w<m.length;w++){const C=w===m.length-1?0:w+1,E=m[w],_=m[C],I=S[w],k=S[C],T=b.Dist(I,k),M=h-T,$=b.Dist(E,_)/T,j=(Math.max(p,f)+M)*$,O=b.Lrp(I,k,.5).add(b.Sub(k,I).uni().per().mul(j));O.x<0?O.x=0:O.x>e&&(O.x=e),O.y<0?O.y=0:O.y>t&&(O.y=t);const R=o0(E,_,O),H=b.Dist(R||b.Average([E,_]),E);v.push({leftPoint:E,rightPoint:_,arcPoint:O,center:R,radius:H})}return v}function bq(e,t,n,r){const o=[],s=wg(e,t,n,r);for(const{center:i,radius:a,leftPoint:l,rightPoint:c}of s)o.push(...C9(l,c,i,a,10));return o}function zv(e,t,n,r){const o=wg(e,t,n,r);let s=`M${o[0].leftPoint.toFixed()}`;for(const{leftPoint:i,rightPoint:a,radius:l,center:c}of o){if(c===null){s+=` L${a.toFixed()}`;continue}const u=b.Clockwise(i,a,c)?"0":"1";s+=` A${N(l)},${N(l)} 0 ${u},1 ${a.toFixed()}`}return s+=" Z",s}const Pq={s:.5,m:.7,l:.9,xl:1.6};function Cq(e,t,n,r){const o=qr(n),s=Pq[r],i=wg(e,t,n,r),c=i.reduce((f,S)=>f+b.Dist2(S.leftPoint,S.rightPoint),0)/i.length>(s*15)**2?f=>f.addXY(o()*s*2,o()*s*2):f=>f;let u=`M${i[0].leftPoint.toFixed()}`,h=c(i[0].leftPoint),p=`M${h.toFixed()}`;for(const{leftPoint:f,center:S,rightPoint:y,radius:x,arcPoint:m}of i){if(S===null){u+=` L${y.toFixed()}`;const I=c(y);p+=` L${I.toFixed()}`,h=I;continue}const v=b.Clockwise(f,y,S)?"0":"1";u+=` A${N(x)},${N(x)} 0 ${v},1 ${y.toFixed()}`;const w=c(y),C=c(m),E=o0(h,w,C);if(!Number.isFinite(E.x)||!Number.isFinite(E.y)){p+=` L${w.toFixed()}`,h=w;continue}const _=Math.abs(b.Dist(E,h));p+=` A${N(_)},${N(_)} 0 ${v},1 ${w.toFixed()}`,h=w}return u+p+" Z"}function Bv(e,t){switch(e.geo){case"x-box":return Iq(e.w,e.h,t,e.dash);case"check-box":return Eq(e.w,e.h);default:return}}function Iq(e,t,n,r){const o=r==="draw"?.62:0;if(r==="dashed")return[[new b(0,0),new b(e/2,t/2)],[new b(e,t),new b(e/2,t/2)],[new b(0,t),new b(e/2,t/2)],[new b(e,0),new b(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 b(s(n*o),i(n*o)),new b(s(e-n*o),i(t-n*o))],[new b(s(n*o),i(t-n*o)),new b(s(e-n*o),i(n*o))]]}function Eq(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 b(s(r+n*.25),i(o+n*.52)),new b(s(r+n*.45),i(o+n*.82))],[new b(s(r+n*.45),i(o+n*.82)),new b(s(r+n*.82),i(o+n*.22))]]}function EI({shape:e,shouldScale:t}){const n=t?e.props.scale:1,r=F(),o=jr(),{id:s,props:i}=e,{w:a,color:l,fill:c,dash:u,growY:h,size:p}=i,f=jt[p]*n,S=i.h+h;switch(i.geo){case"cloud":if(u==="solid"){const y=zv(a,S,s,p);return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:y,color:l,fill:c,scale:n}),d.jsx("path",{d:y,stroke:o[l].solid,strokeWidth:f,fill:"none"})]})}else if(u==="draw"){const y=Cq(a,S,s,p);return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:y,color:l,fill:c,scale:n}),d.jsx("path",{d:y,stroke:o[l].solid,strokeWidth:f,fill:"none"})]})}else{const y=zv(a,S,s,p),x=wg(a,S,s,p);return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:y,color:l,fill:c,scale:n}),d.jsx("g",{strokeWidth:f,stroke:o[l].solid,fill:"none",pointerEvents:"all",children:x.map(({leftPoint:m,rightPoint:v,center:w,radius:C},E)=>{const _=w?C*Ns(Ns(b.Angle(w,v))-Ns(b.Angle(w,m))):b.Dist(m,v),{strokeDasharray:I,strokeDashoffset:k}=ao(_,f,{style:u,start:"outset",end:"outset"});return d.jsx("path",{d:w?`M${m.x},${m.y}A${C},${C},0,0,1,${v.x},${v.y}`:`M${m.x},${m.y}L${v.x},${v.y}`,strokeDasharray:I,strokeDashoffset:k},E)})})]})}case"ellipse":{const y=t?r.getShapeGeometry(e):r.getShapeUtil(e).getGeometry(e),x=y.getSvgPathData(!0);if(u==="dashed"||u==="dotted"){const m=y.length,{strokeDasharray:v,strokeDashoffset:w}=ao(m<64?m*2:m,f,{style:u,snap:4,closed:!0});return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:x,color:l,fill:c,scale:n}),d.jsx("path",{d:x,strokeWidth:f,fill:"none",stroke:o[l].solid,strokeDasharray:v,strokeDashoffset:w})]})}else{const v=(t?r.getShapeGeometry(e):r.getShapeUtil(e).getGeometry(e)).getSvgPathData(!0);return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:v,color:l,fill:c,scale:n}),d.jsx("path",{d:v,stroke:o[l].solid,strokeWidth:f,fill:"none"})]})}}case"oval":{const y=t?r.getShapeGeometry(e):r.getShapeUtil(e).getGeometry(e),x=y.getSvgPathData(!0);if(u==="dashed"||u==="dotted"){const m=y.getLength(),{strokeDasharray:v,strokeDashoffset:w}=ao(m<64?m*2:m,f,{style:u,snap:4,start:"outset",end:"outset",closed:!0});return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:x,color:l,fill:c,scale:n}),d.jsx("path",{d:x,strokeWidth:f,fill:"none",stroke:o[l].solid,strokeDasharray:v,strokeDashoffset:w})]})}else return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:x,color:l,fill:c,scale:n}),d.jsx("path",{d:x,stroke:o[l].solid,strokeWidth:f,fill:"none"})]})}case"heart":if(u==="dashed"||u==="dotted"||u==="solid"){const y=NA(a,S),x=ww(a,S);return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:y,color:l,fill:c,scale:n}),x.map((m,v)=>{const{strokeDasharray:w,strokeDashoffset:C}=ao(m.length,f,{style:u,snap:1,start:"outset",end:"outset",closed:!0});return d.jsx("path",{d:m.getSvgPathData(),strokeWidth:f,fill:"none",stroke:o[l].solid,strokeDasharray:w,strokeDashoffset:C,pointerEvents:"all"},`curve_${v}`)})]})}else{const y=gq(a,S,f,e.id);return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:y,color:l,fill:c,scale:n}),d.jsx("path",{d:y,stroke:o[l].solid,strokeWidth:f,fill:"none"})]})}default:{const y=t?r.getShapeGeometry(e):r.getShapeUtil(e).getGeometry(e),x=y instanceof Gr?y.children[0].vertices:y.vertices,m=Bv(e.props,f);if(u==="solid"){let v="M"+x[0]+"L"+x.slice(1)+"Z";if(m)for(const[w,C]of m)v+=`M${w.x},${w.y}L${C.x},${C.y}`;return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:v,color:l,fill:c,scale:n}),d.jsx("path",{d:v,stroke:o[l].solid,strokeWidth:f,fill:"none"})]})}else if(u==="dashed"||u==="dotted"){const v="M"+x[0]+"L"+x.slice(1)+"Z";return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:v,color:l,fill:c,scale:n}),d.jsxs("g",{strokeWidth:f,stroke:o[l].solid,fill:"none",pointerEvents:"all",children:[Array.from(Array(x.length)).map((w,C)=>{const E=b.ToFixed(x[C]),_=b.ToFixed(x[(C+1)%x.length]),I=b.Dist(E,_),{strokeDasharray:k,strokeDashoffset:T}=ao(I,f,{style:u,start:"outset",end:"outset"});return d.jsx("line",{x1:E.x,y1:E.y,x2:_.x,y2:_.y,strokeDasharray:k,strokeDashoffset:T},C)}),m&&m.map(([w,C],E)=>{const _=b.Dist(w,C),{strokeDasharray:I,strokeDashoffset:k}=ao(_,f,{style:u,start:"skip",end:"skip",snap:u==="dotted"?4:void 0});return d.jsx("path",{d:`M${w.x},${w.y}L${C.x},${C.y}`,stroke:o[l].solid,strokeWidth:f,fill:"none",strokeDasharray:I,strokeDashoffset:k},`line_fg_${E}`)})]})]})}else if(u==="draw"){let v=Nv(Fv(s,x,f/3,f*2,2));if(m)for(const[C,E]of m)v+=`M${C.toFixed()}L${E.toFixed()}`;const w=Nv(Fv(s,x,0,f*2,1));return d.jsxs(d.Fragment,{children:[d.jsx(rn,{theme:o,d:w,color:l,fill:c,scale:n}),d.jsx("path",{d:v,stroke:o[l].solid,strokeWidth:f,fill:"none"})]})}}}}const kI=17*3;class ap extends Dl{constructor(){super(...arguments);g(this,"canEdit",()=>!0);g(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()}}])});g(this,"onResize",(n,{handle:r,newPoint:o,scaleX:s,scaleY:i,initialShape:a})=>{const l=a.props.w/a.props.scale,c=a.props.h/a.props.scale,u=a.props.growY/a.props.scale;let h=l*s,p=(c+u)*i,f=0,S=0;const y=kI;if(n.props.text.trim()){let E=Math.max(Math.abs(h),y),_=Math.max(Math.abs(p),y);E<y&&_===y&&(E=y),E===y&&_<y&&(_=y);const I=ih(this.editor,{...n,props:{...n.props,w:E*n.props.scale,h:_*n.props.scale}}),k=Math.max(Math.abs(h),I.w)*Math.sign(h),T=Math.max(Math.abs(p),I.h)*Math.sign(p);f=Math.abs(k)-Math.abs(h),S=Math.abs(T)-Math.abs(p),h=k,p=T}const x=h*n.props.scale,m=p*n.props.scale,v=new b(0,0);s<0&&(v.x+=x),(r==="left"||r==="top_left"||r==="bottom_left")&&(v.x+=s<0?f:-f),i<0&&(v.y+=m),(r==="top"||r==="top_left"||r==="top_right")&&(v.y+=i<0?S:-S);const{x:w,y:C}=v.rot(n.rotation).add(o);return{x:w,y:C,props:{w:Math.max(Math.abs(x),1),h:Math.max(Math.abs(m),1),growY:0}}});g(this,"onBeforeCreate",n=>{if(!n.props.text)return n.props.growY?{...n,props:{...n.props,growY:0}}:void 0;const r=n.props.h/n.props.scale,o=ih(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*n.props.scale}}});g(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/n.props.scale,a=n.props.h/n.props.scale,l=n.props.growY/n.props.scale,c=ih(this.editor,r);if(!o&&s&&s.length===1){let h=Math.max(i,c.w),p=Math.max(a,c.h);const f=kI;return i<f&&a<f&&(h=Math.max(h,f),p=Math.max(p,f),h=Math.max(h,p),p=Math.max(h,p)),{...r,props:{...r.props,w:h*r.props.scale,h:p*r.props.scale,growY:0}}}let u=null;if(c.h>a?u=c.h-a:l&&(u=0),u!==null){const h=r.props.w/r.props.scale;return{...r,props:{...r.props,growY:u*r.props.scale,w:Math.max(h,c.w)*r.props.scale}}}if(c.w>i)return{...r,props:{...r.props,w:c.w*r.props.scale}}});g(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:"",scale:1}}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=n.props.fill!=="none";let l;switch(n.props.geo){case"cloud":{l=new vt({points:bq(r,o,n.id,n.props.size),isFilled:a});break}case"triangle":{l=new vt({points:[new b(s,0),new b(r,o),new b(0,o)],isFilled:a});break}case"diamond":{l=new vt({points:[new b(s,0),new b(r,i),new b(s,o),new b(0,i)],isFilled:a});break}case"pentagon":{l=new vt({points:km(r,o,5),isFilled:a});break}case"hexagon":{l=new vt({points:km(r,o,6),isFilled:a});break}case"octagon":{l=new vt({points:km(r,o,8),isFilled:a});break}case"ellipse":{l=new oY({width:r,height:o,isFilled:a});break}case"oval":{l=new sY({width:r,height:o,isFilled:a});break}case"star":{const w=Le/5/2,C=Math.floor(5/4)*2,E=5*2-C,_=0,I=Math.floor(5/2)*2,k=Math.cos(-Ve+C*w)*r/2,T=Math.cos(-Ve+E*w)*r/2,M=Math.sin(-Ve+_*w)*o/2,D=Math.sin(-Ve+I*w)*o/2,$=r-Math.abs(k-T),j=o-Math.abs(D-M),O=r/2+T-(r/2-k),R=o/2+M-(o/2-D),H=1,B=(r-O)/2,z=(o-R)/2,W=(r+$)/2,Y=(o+j)/2,q=W*H/2,le=Y*H/2;l=new vt({points:Array.from(Array(5*2)).map((ge,be)=>{const J=-Ve+be*w;return new b(B+(be%2?q:W)*Math.cos(J),z+(be%2?le:Y)*Math.sin(J))}),isFilled:a});break}case"rhombus":{const v=Math.min(r*.38,o*.38);l=new vt({points:[new b(v,0),new b(r,0),new b(r-v,o),new b(0,o)],isFilled:a});break}case"rhombus-2":{const v=Math.min(r*.38,o*.38);l=new vt({points:[new b(0,0),new b(r-v,0),new b(r,o),new b(v,o)],isFilled:a});break}case"trapezoid":{const v=Math.min(r*.38,o*.38);l=new vt({points:[new b(v,0),new b(r-v,0),new b(r,o),new b(0,o)],isFilled:a});break}case"arrow-right":{const v=Math.min(r,o)*.38,w=o*.16;l=new vt({points:[new b(0,w),new b(r-v,w),new b(r-v,0),new b(r,o/2),new b(r-v,o),new b(r-v,o-w),new b(0,o-w)],isFilled:a});break}case"arrow-left":{const v=Math.min(r,o)*.38,w=o*.16;l=new vt({points:[new b(v,0),new b(v,w),new b(r,w),new b(r,o-w),new b(v,o-w),new b(v,o),new b(0,o/2)],isFilled:a});break}case"arrow-up":{const v=r*.16,w=Math.min(r,o)*.38;l=new vt({points:[new b(r/2,0),new b(r,w),new b(r-v,w),new b(r-v,o),new b(v,o),new b(v,w),new b(0,w)],isFilled:a});break}case"arrow-down":{const v=r*.16,w=Math.min(r,o)*.38;l=new vt({points:[new b(v,0),new b(r-v,0),new b(r-v,o-w),new b(r,o-w),new b(r/2,o),new b(0,o-w),new b(v,o-w)],isFilled:a});break}case"check-box":case"x-box":case"rectangle":{l=new os({width:r,height:o,isFilled:a});break}case"heart":{const w=ww(r,o).reduce((C,E)=>(C.push(...E.vertices),C),[]);l=new vt({points:w,isFilled:a});break}default:un(n.props.geo)}const c=ih(this.editor,n),u=r/n.props.scale,h=o/n.props.scale,p=Math.min(100,u/2),f=Math.min(qo[n.props.size]*Vt.lineHeight+vr*2,h/2),S=Math.min(u,Math.max(c.w,Math.min(p,Math.max(1,u-8)))),y=Math.min(h,Math.max(c.h,Math.min(f,Math.max(1,h-8)))),x=Bv(n.props,jt[n.props.size]*n.props.scale),m=x?x.map(v=>new Ol({points:v})):[];return new Gr({children:[l,new os({x:n.props.align==="start"?0:n.props.align==="end"?(u-S)*n.props.scale:(u-S)/2*n.props.scale,y:n.props.verticalAlign==="start"?0:n.props.verticalAlign==="end"?(h-y)*n.props.scale:(h-y)/2*n.props.scale,width:S*n.props.scale,height:y*n.props.scale,isFilled:!0,isLabel:!0}),...m]})}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"heart":case"oval":return{outline:o,points:[r.bounds.center]};default:un(n.props.geo)}}component(n){const{id:r,type:o,props:s}=n,{fill:i,font:a,align:l,verticalAlign:c,size:u,text:h}=s,p=n.id===this.editor.getOnlySelectedShapeId(),f=jr(),y=this.editor.getEditingShapeId()!==null||n.props.text;return d.jsxs(d.Fragment,{children:[d.jsx(Zs,{id:r,children:d.jsx(EI,{shape:n,shouldScale:!0})}),y&&d.jsx(Gi,{style:{overflow:"hidden",width:n.props.w,height:n.props.h+s.growY},children:d.jsx(xg,{id:r,type:o,font:a,fontSize:qo[u]*n.props.scale,lineHeight:Vt.lineHeight,padding:vr*n.props.scale,fill:i,align:l,verticalAlign:c,text:h,isSelected:p,labelColor:f[s.labelColor].solid,wrap:!0})}),n.props.url&&d.jsx(yl,{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,l=jt[i],c=this.editor.getShapeGeometry(n);switch(o.geo){case"ellipse":return o.dash==="draw"?d.jsx("path",{d:Sq(r,s,a,l)}):d.jsx("path",{d:c.getSvgPathData(!0)});case"heart":return d.jsx("path",{d:NA(s,a)});case"oval":return d.jsx("path",{d:c.getSvgPathData(!0)});case"cloud":return d.jsx("path",{d:zv(s,a,r,i)});default:{const u=this.editor.getShapeGeometry(n),h=u instanceof Gr?u.children[0].vertices:u.vertices;let p;if(o.dash==="draw"){const S=Fv(r,h,0,l*2*n.props.scale,1);p=Nv(S)}else p="M"+h[0]+"L"+h.slice(1)+"Z";const f=Bv(n.props,l);if(f)for(const[S,y]of f)p+=`M${S.x},${S.y}L${y.x},${y.y}`;return d.jsx("path",{d:p})}}}toSvg(n,r){const o={...n,props:{...n.props,w:n.props.w/n.props.scale,h:n.props.h/n.props.scale}},s=o.props;r.addExportDef(mw(s.fill));let i;if(s.text){r.addExportDef(Sg(s.font));const a=cs(r),l=new Q(0,0,s.w,s.h+s.growY);i=d.jsx(vg,{fontSize:qo[s.size],font:s.font,align:s.align,verticalAlign:s.verticalAlign,text:s.text,labelColor:a[s.labelColor].solid,bounds:l,padding:16})}return d.jsxs(d.Fragment,{children:[d.jsx(EI,{shouldScale:!1,shape:o}),i]})}getCanvasSvgDefs(){return[yw()]}}g(ap,"type","geo"),g(ap,"props",L_),g(ap,"migrations",$_);function ih(e,t){const{text:n,font:r,size:o,w:s}=t.props;if(!n)return{w:0,h:0};const i=e.textMeasure.measureText("w",{...Vt,fontFamily:wo[r],fontSize:qo[o],maxWidth:100}),a={s:2,m:3.5,l:5,xl:10},l=e.textMeasure.measureText(n,{...Vt,fontFamily:wo[r],fontSize:qo[o],minWidth:i.w,maxWidth:Math.max(0,Math.ceil(i.w+a[o]),Math.ceil(s/t.props.scale-vr*2))});return{w:l.w+vr*2,h:l.h+vr*2}}function kq(){const[e,t]=P.useState(!1);return P.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(xt.forceSrgb)||!e?"srgb":"p3"}const _I=.35,TI=.82;class lp extends Wr{constructor(){super(...arguments);g(this,"hideResizeHandles",n=>ah(n));g(this,"hideRotateHandle",n=>ah(n));g(this,"hideSelectionBoundsFg",n=>ah(n));g(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:l,y:c,z:u})=>({x:o*l,y:s*c,z:u}))});return{props:{segments:i}}})}getDefaultProps(){return{segments:[],color:"black",size:"m",isComplete:!1,isPen:!1,scale:1}}getGeometry(n){const r=Ci(n);if(ah(n))return new hw({x:-r/2,y:-r/2,radius:r/2,isFilled:!0});const{strokePoints:o,sw:s}=MI(n,r,!0),i=xw({strokeWidth:s,showAsComplete:!0});return mg(o,i),new vt({points:pw(o,i),isFilled:!0})}component(n){const r=xy(this.editor,n),o=Ci(n);return d.jsx(Zs,{id:n.id,children:d.jsx(lh,{shape:n,forceSolid:r,strokeWidth:o,opacity:_I})})}backgroundComponent(n){const r=xy(this.editor,n),o=Ci(n);return d.jsx(Zs,{id:n.id,children:d.jsx(lh,{shape:n,forceSolid:r,strokeWidth:o,opacity:TI})})}indicator(n){const r=xy(this.editor,n),o=Ci(n),{strokePoints:s,sw:i}=MI(n,o,r),a=Sl(n.props.segments);let l;return s.length<2?l=Tq(a[0],i):l=Vi(s,!1),d.jsx("path",{d:l})}toSvg(n){const r=Ci(n),o=r<1.5,s=1/n.props.scale;return d.jsx("g",{transform:`scale(${s})`,children:d.jsx(lh,{forceSolid:o,strokeWidth:r,shape:n,opacity:_I})})}toBackgroundSvg(n){const r=Ci(n),o=r<1.5,s=1/n.props.scale;return d.jsx("g",{transform:`scale(${s})`,children:d.jsx(lh,{forceSolid:o,strokeWidth:r,shape:n,opacity:TI})})}}g(lp,"type","highlight"),g(lp,"props",z_),g(lp,"migrations",B_);function _q(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 Tq(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 MI(e,t,n){var l;const r=Sl(e.props.segments),o=e.props.isComplete||((l=Ut(e.props.segments))==null?void 0:l.type)==="straight";let s=t;!n&&!e.props.isPen&&r.length===1&&(s+=qr(e.id)()*(t/6));const i=xw({strokeWidth:s,showAsComplete:o});return{strokePoints:Io(r,i),sw:s}}function Ci(e){return gl[e.props.size]*1.12*e.props.scale}function ah(e){return e.props.segments.length===1&&e.props.segments[0].points.length<2}function lh({strokeWidth:e,forceSolid:t,shape:n,opacity:r}){var p;const o=jr(),s=Sl(n.props.segments);let i=e;!t&&!n.props.isPen&&s.length===1&&(i+=qr(n.id)()*(i/6));const a=xw({strokeWidth:i,showAsComplete:n.props.isComplete||((p=Ut(n.props.segments))==null?void 0:p.type)==="straight"}),l=Io(s,a),c=l.length>1?Vi(l,!1):_q(n.props.segments[0].points[0]),u=kq(),h=o[n.props.color].highlight[u];return d.jsx("path",{d:c,strokeLinecap:"round",fill:"none",pointerEvents:"all",stroke:h,strokeWidth:i,opacity:r})}function xy(e,t){return K("forceSolid",()=>{const n=Ci(t),r=e.getZoomLevel();return n/r<1.5},[e])}function FA(){return d.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:[d.jsx("path",{d:"M3,11 L3,3 11,3",strokeWidth:"2"}),d.jsx("path",{d:"M19,27 L27,27 L27,19",strokeWidth:"2"}),d.jsx("path",{d:"M27,3 L3,27",strokeWidth:"2"})]})}function zA(e,t,n){const r=F(),[o,s]=P.useState(null),i=t?r.getAsset(t):null,l=r.getCulledShapes().has(e),c=P.useRef(!1);P.useEffect(()=>{o&&(c.current=!0)},[o]);const u=i&&"w"in i.props?n/i.props.w:1,h=K("zoom level",()=>r.getZoomLevel()*u,[r,u]);return P.useEffect(()=>{if(l)return;let p=!1;const f=r.timers.setTimeout(async()=>{const S=await r.resolveAssetUrl(t,{screenScale:h});p||s(S)},c.current?500:0);return()=>{clearTimeout(f),p=!0}},[t,i==null?void 0:i.props.src,l,h,r]),{asset:i,url:o}}function BA(){const[e,t]=P.useState(!1);return P.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;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 Mq(e){const n=await(await bo(e)).blob();return Ai.blobToDataUrl(n)}class cp extends Dl{constructor(){super(...arguments);g(this,"isAspectRatioLocked",()=>!0);g(this,"canCrop",()=>!0);g(this,"onResize",(n,r)=>{let o=uw(n,r);const{flipX:s,flipY:i}=r.initialShape.props;return o={...o,props:{...o.props,flipX:r.scaleX<0!==s,flipY:r.scaleY<0!==i}},o});g(this,"onDoubleClick",n=>{const r=n.props.assetId?this.editor.getAsset(n.props.assetId):void 0;!r||!(r.props.src&&this.isAnimated(n))||this.editor.updateShapes([{type:"image",id:n.id,props:{playing:!n.props.playing}}])});g(this,"onDoubleClickEdge",n=>{const r=n.props;if(!r||this.editor.getCroppingShapeId()!==n.id)return;const o=Ge(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 b(o.topLeft.x*s,o.topLeft.y*i).rot(n.rotation),l={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([l])})}getDefaultProps(){return{w:100,h:100,assetId:null,playing:!0,url:"",crop:null,flipX:!1,flipY:!1}}isAnimated(n){const r=n.props.assetId?this.editor.getAsset(n.props.assetId):void 0;return r?"mimeType"in r.props&&ho.isAnimatedImageType(r==null?void 0:r.props.mimeType)||"isAnimated"in r.props&&r.props.isAnimated:!1}component(n){var y;const r=this.editor.getCroppingShapeId()===n.id,o=BA(),[s,i]=P.useState(""),[a,l]=P.useState(""),c=n.id===this.editor.getOnlySelectedShapeId(),{asset:u,url:h}=zA(n.id,n.props.assetId,n.props.w);if(P.useEffect(()=>{if(h){let x=!1;const m=sl();return m.onload=()=>{x||l(h)},m.src=h,()=>{x=!0}}},[h,n]),P.useEffect(()=>{if(h&&this.isAnimated(n)){let x=!1;const m=sl();return m.onload=()=>{if(x)return;const v=document.createElement("canvas");v.width=m.width,v.height=m.height;const w=v.getContext("2d");w&&(w.drawImage(m,0,0),i(v.toDataURL()),l(h))},m.crossOrigin="anonymous",m.src=h,()=>{x=!0}}},[o,h,n]),(u==null?void 0:u.type)==="bookmark")throw Error("Bookmark assets can't be rendered as images");const p=c&&r&&this.editor.isIn("select.crop"),f=o&&(((y=u==null?void 0:u.props.mimeType)==null?void 0:y.includes("video"))||this.isAnimated(n)),S=AI(n);return u!=null&&u.props.src?a?d.jsxs(d.Fragment,{children:[p&&d.jsx("div",{style:S,children:d.jsx("img",{className:"tl-image",crossOrigin:this.isAnimated(n)?"anonymous":void 0,src:!n.props.playing||f?s:a,referrerPolicy:"strict-origin-when-cross-origin",style:{opacity:.1},draggable:!1})}),d.jsxs(Gi,{id:n.id,style:{overflow:"hidden",width:n.props.w,height:n.props.h},children:[d.jsxs("div",{className:"tl-image-container",style:S,children:[d.jsx("img",{className:ce("tl-image",{"tl-flip-x":n.props.flipX&&!n.props.flipY,"tl-flip-y":n.props.flipY&&!n.props.flipX,"tl-flip-xy":n.props.flipY&&n.props.flipX}),crossOrigin:this.isAnimated(n)?"anonymous":void 0,src:!n.props.playing||f?s:a,referrerPolicy:"strict-origin-when-cross-origin",draggable:!1}),this.isAnimated(n)&&!n.props.playing&&d.jsx("div",{className:"tl-image__tg",children:"GIF"})]}),n.props.url&&d.jsx(yl,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]})]}):null:d.jsxs(Gi,{id:n.id,style:{overflow:"hidden",width:n.props.w,height:n.props.h,color:"var(--color-text-3)",backgroundColor:u?"transparent":"var(--color-low)",border:u?"none":"1px solid var(--color-low-border)"},children:[d.jsx("div",{className:"tl-image-container",style:S,children:u?null:d.jsx(FA,{})}),"url"in n.props&&n.props.url&&d.jsx(yl,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]})}indicator(n){return this.editor.getCroppingShapeId()===n.id?null:d.jsx("rect",{width:N(n.props.w),height:N(n.props.h)})}async toSvg(n){if(!n.props.assetId||!this.editor.getAsset(n.props.assetId))return null;let o=await this.editor.resolveAssetUrl(n.props.assetId,{shouldResolveToOriginal:!0});if(!o)return null;(o.startsWith("blob:")||o.startsWith("http")||o.startsWith("/")||o.startsWith("./"))&&(o=await Mq(o)||"");const s=AI(n),i=n.props.crop;if(s.transform&&i){const{transform:a,width:l,height:c}=s,u=(i.bottomRight.x-i.topLeft.x)*l,h=(i.bottomRight.y-i.topLeft.y)*c,p=[new b(0,0),new b(u,0),new b(u,h),new b(0,h)],f=`cropClipPath_${n.id.replace(":","_")}`;return d.jsxs(d.Fragment,{children:[d.jsx("defs",{children:d.jsx("clipPath",{id:f,children:d.jsx("polygon",{points:p.map(S=>`${S.x},${S.y}`).join(" ")})})}),d.jsx("g",{clipPath:`url(#${f})`,children:d.jsx("image",{href:o,width:l,height:c,style:{transform:a}})})]})}else return d.jsx("image",{href:o,width:n.props.w,height:n.props.h})}}g(cp,"type","image"),g(cp,"props",U_),g(cp,"migrations",H_);function AI(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 UA(e){return{size:e,thinning:.4,streamline:0,smoothing:.5,simulatePressure:!0,last:!0}}function HA(e,t,n){const r=t.vertices,o=UA(n);return Io(r,o)}function Aq(e,t,n){const r=UA(n);return pw(mg(HA(e,t,n),r),r)}function jq(e,t,n){const r=Aq(e,t,n);return a0(r)}function Oq(e,t,n){if(e.props.dash==="draw"){const r=HA(e,t,n);return Vi(r)}return t.getSvgPathData()}function KA(e,t,n){let r=`M ${Te(t[0])}L`,o=`M ${Te(t[0])}L`;const s=n/3,i=n*2,a=qr(e);let l=t[0],c,u=t[0],h;const p=t.length;for(let f=0,S=p-1;f<S;f++){c=t[f+1],h=b.AddXY(t[f+1],a()*s,a()*s);const y=b.Sub(c,l),x=b.Len(y),m=b.Div(y,x).mul(Math.min(x/4,i)),v=b.Add(l,m),w=b.Add(c,m.neg()),C=b.Sub(h,u),E=b.Len(C),_=b.Div(C,E).mul(Math.min(E/4,i)),I=b.Add(u,_),k=b.Add(h,_.neg());f===S-1?(r+=`${Te(v)}L ${Te(c)}`,o+=`${Te(I)}L ${Te(h)}`):(r+=`${Te(v)}L ${Te(w)}Q ${Te(c)}`,o+=`${Te(I)}L ${Te(k)}Q ${Te(h)}`,l=c,u=h)}return[r,r+o]}const Dq=new Qo;class up extends Wr{constructor(){super(...arguments);g(this,"hideResizeHandles",()=>!0);g(this,"hideRotateHandle",()=>!0);g(this,"hideSelectionBoundsFg",()=>!0);g(this,"hideSelectionBoundsBg",()=>!0);g(this,"onResize",(n,r)=>{const{scaleX:o,scaleY:s}=r;return{props:{points:Bu(n.props.points,(i,{id:a,index:l,x:c,y:u})=>({id:a,index:l,x:c*o,y:u*s}))}}});g(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]=ou(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}},scale:1}}getGeometry(n){return Tc(n)}getHandles(n){return Dq.get(n.props,()=>{const r=Tc(n),o=_c(n),s=o.map(i=>({...i,id:i.index,type:"vertex",canSnap:!0}));for(let i=0;i<o.length-1;i++){const a=ru(o[i].index,o[i+1].index),c=r.segments[i].midPoint();s.push({id:a,type:"create",index:a,x:c.x,y:c.y,canSnap:!0})}return s.sort(ln)})}component(n){return d.jsx(Zs,{id:n.id,children:d.jsx(jI,{shape:n})})}indicator(n){const r=jt[n.props.size]*n.props.scale,o=Tc(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[l]=KA(n.id,a,r);i=l}}else i=Oq(n,o,r);return d.jsx("path",{d:i})}toSvg(n){return d.jsx(jI,{shouldScale:!0,shape:n})}getHandleSnapGeometry(n){const r=_c(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(b.From)},getSelfSnapOutline:o=>{const s=this.getHandles(n).filter(a=>a.type==="vertex").findIndex(a=>a.id===o.id),i=Tc(n).segments.filter((a,l)=>l!==s-1&&l!==s);return i.length?new Gr({children:i}):null}}}getInterpolatedProps(n,r,o){const s=_c(n),i=_c(r),a=[],l=[];let c=t_;if(s.length>i.length)for(let u=0;u<s.length;u++)a[u]={...s[u]},i[u]===void 0?l[u]={...i[i.length-1],id:c}:l[u]={...i[u],id:c},c=zr(c);else if(i.length>s.length)for(let u=0;u<i.length;u++)l[u]={...i[u]},s[u]===void 0?a[u]={...s[s.length-1],id:c}:a[u]={...s[u],id:c},c=zr(c);else for(let u=0;u<i.length;u++)a[u]=s[u],l[u]=i[u];return{...r.props,points:Object.fromEntries(a.map((u,h)=>{const p=l[h];return[u.id,{...u,x:Dn(u.x,p.x,o),y:Dn(u.y,p.y,o)}]}))}}}g(up,"type","line"),g(up,"props",K_),g(up,"migrations",W_);function _c(e){return Object.values(e.props.points).sort(ln)}function Tc(e){const t=_c(e).map(b.From);switch(e.props.spline){case"cubic":return new rY({points:t});case"line":return new Ol({points:t})}}function jI({shape:e,shouldScale:t=!1}){const n=jr(),r=Tc(e),{dash:o,color:s,size:i}=e.props,a=1/e.props.scale,l=t?a:1,c=jt[i]*e.props.scale;if(e.props.spline==="line"){if(o==="solid"){const u=r.points,h="M"+u[0]+"L"+u.slice(1);return d.jsx("path",{d:h,stroke:n[s].solid,strokeWidth:c,fill:"none",transform:`scale(${l})`})}if(o==="dashed"||o==="dotted")return d.jsx("g",{stroke:n[s].solid,strokeWidth:c,transform:`scale(${l})`,children:r.segments.map((u,h)=>{const{strokeDasharray:p,strokeDashoffset:f}=ao(u.length,c,{style:o,start:h>0?"outset":"none",end:h<r.segments.length-1?"outset":"none"});return d.jsx("path",{strokeDasharray:p,strokeDashoffset:f,d:u.getSvgPathData(!0),fill:"none"},h)})});if(o==="draw"){const u=r.points,[h,p]=KA(e.id,u,c);return d.jsx("path",{d:p,stroke:n[s].solid,strokeWidth:c,fill:"none",transform:`scale(${l})`})}}if(e.props.spline==="cubic"){const u=r.getSvgPathData();if(o==="solid")return d.jsx("path",{strokeWidth:c,stroke:n[s].solid,fill:"none",d:u,transform:`scale(${l})`});if(o==="dashed"||o==="dotted")return d.jsx("g",{stroke:n[s].solid,strokeWidth:c,transform:`scale(${l})`,children:r.segments.map((h,p)=>{const{strokeDasharray:f,strokeDashoffset:S}=ao(h.length,c,{style:o,start:p>0?"outset":"none",end:p<r.segments.length-1?"outset":"none"});return d.jsx("path",{strokeDasharray:f,strokeDashoffset:S,d:h.getSvgPathData(),fill:"none"},p)})});if(o==="draw")return d.jsx("path",{d:jq(e,r,c),strokeWidth:1,stroke:n[s].solid,fill:n[s].solid,transform:`scale(${l})`})}}const WA=P.createContext(null);function Rq({assetUrls:e,children:t}){return P.useEffect(()=>{for(const n of Object.values(e.icons)){const r=sl();r.src=n,r.decode()}for(const n of Object.values(e.embedIcons)){const r=sl();r.src=n,r.decode()}},[e]),d.jsx(WA.Provider,{value:e,children:t})}function bw(){const e=P.useContext(WA);if(!e)throw new Error("useAssetUrls must be used within an AssetUrlsProvider");return e}const Uv={"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.fork-project-on-tldraw":"Fork project on tldraw","action.group":"Group","action.insert-embed":"Insert embed","action.insert-media":"Upload media","action.leave-shared-project":"Leave shared project","action.new-project":"New project","action.new-shared-project":"New shared project","action.open-cursor-chat":"Cursor chat","action.open-file":"Open file","action.pack":"Pack","action.paste":"Paste","action.paste-error-title":"Pasting failed","action.paste-error-description":"Could not paste due to missing clipboard permissions. Please enable the permissions and try again.","action.print":"Print","action.redo":"Redo","action.remove-frame":"Remove frame","action.rename":"Rename","action.rotate-ccw":"Rotate counterclockwise","action.rotate-cw":"Rotate clockwise","action.save-copy":"Save a copy","action.select-all":"Select all","action.select-none":"Select none","action.send-backward":"Send backward","action.send-to-back":"Send to back","action.share-project":"Share this project","action.stack-horizontal":"Stack horizontally","action.stack-vertical":"Stack vertically","action.stack-horizontal.short":"Stack H","action.stack-vertical.short":"Stack V","action.stop-following":"Stop following","action.stretch-horizontal":"Stretch horizontally","action.stretch-vertical":"Stretch vertically","action.stretch-horizontal.short":"Stretch H","action.stretch-vertical.short":"Stretch V","action.toggle-auto-size":"Toggle auto size","action.toggle-dark-mode.menu":"Dark mode","action.toggle-dark-mode":"Toggle dark mode","action.toggle-paste-at-cursor.menu":"Paste at cursor","action.toggle-paste-at-cursor":"Toggle paste at cursor","action.toggle-wrap-mode.menu":"Select on wrap","action.toggle-wrap-mode":"Toggle Select on wrap","action.toggle-reduce-motion.menu":"Reduce motion","action.toggle-reduce-motion":"Toggle reduce motion","action.toggle-edge-scrolling.menu":"Edge scrolling","action.toggle-edge-scrolling":"Toggle edge scrolling","action.toggle-debug-mode.menu":"Debug mode","action.toggle-debug-mode":"Toggle debug mode","action.toggle-focus-mode.menu":"Focus mode","action.toggle-focus-mode":"Toggle focus mode","action.toggle-dynamic-size-mode.menu":"Dynamic size","action.toggle-dynamic-size-mode":"Toggle dynamic size","action.toggle-grid.menu":"Show grid","action.toggle-grid":"Toggle grid","action.toggle-lock":"Toggle locked","action.flatten-to-image":"Flatten","action.toggle-snap-mode.menu":"Always snap","action.toggle-snap-mode":"Toggle always snap","action.toggle-tool-lock.menu":"Tool lock","action.toggle-tool-lock":"Toggle tool lock","action.toggle-transparent.context-menu":"Transparent","action.toggle-transparent.menu":"Transparent","action.toggle-transparent":"Toggle transparent background","action.undo":"Undo","action.ungroup":"Ungroup","action.zoom-in":"Zoom in","action.zoom-out":"Zoom out","action.zoom-to-100":"Zoom to 100%","action.zoom-to-fit":"Zoom to fit","action.zoom-to-selection":"Zoom to selection","assets.files.size-too-big":"File size is too big","assets.files.type-not-allowed":"File type is not allowed","assets.files.upload-failed":"Upload failed","assets.url.failed":"Couldn't load URL preview","theme.dark":"Dark","theme.light":"Light","theme.system":"System","color-style.white":"White","color-style.black":"Black","color-style.blue":"Blue","color-style.green":"Green","color-style.grey":"Grey","color-style.light-blue":"Light blue","color-style.light-green":"Light green","color-style.light-red":"Light red","color-style.light-violet":"Light violet","color-style.orange":"Orange","color-style.red":"Red","color-style.violet":"Violet","color-style.yellow":"Yellow","fill-style.none":"None","document.default-name":"Untitled","fill-style.semi":"Semi","fill-style.solid":"Solid","fill-style.pattern":"Pattern","fill-style.fill":"Fill","dash-style.dashed":"Dashed","dash-style.dotted":"Dotted","dash-style.draw":"Draw","dash-style.solid":"Solid","size-style.s":"Small","size-style.m":"Medium","size-style.l":"Large","size-style.xl":"Extra large","opacity-style.0.1":"10%","opacity-style.0.25":"25%","opacity-style.0.5":"50%","opacity-style.0.75":"75%","opacity-style.1":"100%","font-style.draw":"Draw","font-style.sans":"Sans","font-style.serif":"Serif","font-style.mono":"Mono","align-style.start":"Start","align-style.middle":"Middle","align-style.end":"End","align-style.justify":"Justify","verticalAlign-style.start":"Top","verticalAlign-style.middle":"Middle","verticalAlign-style.end":"Bottom","geo-style.arrow-down":"Arrow down","geo-style.arrow-left":"Arrow left","geo-style.arrow-right":"Arrow right","geo-style.arrow-up":"Arrow up","geo-style.diamond":"Diamond","geo-style.ellipse":"Ellipse","geo-style.hexagon":"Hexagon","geo-style.octagon":"Octagon","geo-style.oval":"Oval","geo-style.cloud":"Cloud","geo-style.pentagon":"Pentagon","geo-style.rectangle":"Rectangle","geo-style.rhombus-2":"Rhombus 2","geo-style.rhombus":"Rhombus","geo-style.star":"Star","geo-style.trapezoid":"Trapezoid","geo-style.triangle":"Triangle","geo-style.x-box":"X box","geo-style.check-box":"Check box","arrowheadStart-style.none":"None","arrowheadStart-style.arrow":"Arrow","arrowheadStart-style.bar":"Bar","arrowheadStart-style.diamond":"Diamond","arrowheadStart-style.dot":"Dot","arrowheadStart-style.inverted":"Inverted","arrowheadStart-style.pipe":"Pipe","arrowheadStart-style.square":"Square","arrowheadStart-style.triangle":"Triangle","arrowheadEnd-style.none":"None","arrowheadEnd-style.arrow":"Arrow","arrowheadEnd-style.bar":"Bar","arrowheadEnd-style.diamond":"Diamond","arrowheadEnd-style.dot":"Dot","arrowheadEnd-style.inverted":"Inverted","arrowheadEnd-style.pipe":"Pipe","arrowheadEnd-style.square":"Square","arrowheadEnd-style.triangle":"Triangle","spline-style.line":"Line","spline-style.cubic":"Cubic","tool.select":"Select","tool.hand":"Hand","tool.draw":"Draw","tool.eraser":"Eraser","tool.arrow-down":"Arrow down","tool.arrow-left":"Arrow left","tool.arrow-right":"Arrow right","tool.arrow-up":"Arrow up","tool.arrow":"Arrow","tool.cloud":"Cloud","tool.diamond":"Diamond","tool.ellipse":"Ellipse","tool.hexagon":"Hexagon","tool.highlight":"Highlight","tool.line":"Line","tool.octagon":"Octagon","tool.oval":"Oval","tool.pentagon":"Pentagon","tool.rectangle":"Rectangle","tool.rhombus":"Rhombus","tool.star":"Star","tool.trapezoid":"Trapezoid","tool.triangle":"Triangle","tool.x-box":"X box","tool.check-box":"Check box","tool.asset":"Asset","tool.frame":"Frame","tool.note":"Note","tool.laser":"Laser","tool.embed":"Embed","tool.text":"Text","menu.title":"Menu","menu.theme":"Theme","menu.copy-as":"Copy as","menu.edit":"Edit","menu.export-as":"Export as","menu.file":"File","menu.language":"Language","menu.preferences":"Preferences","menu.help":"Help","menu.view":"View","context-menu.edit":"Edit","context-menu.arrange":"Arrange","context-menu.copy-as":"Copy as","context-menu.export-as":"Export as","context-menu.export-all-as":"Export","context-menu.move-to-page":"Move to page","context-menu.reorder":"Reorder","page-menu.title":"Pages","page-menu.create-new-page":"Create new page","page-menu.max-page-count-reached":"Max pages reached","page-menu.new-page-initial-name":"Page 1","page-menu.edit-start":"Edit","page-menu.edit-done":"Done","page-menu.go-to-page":"Go to page","page-menu.submenu.rename":"Rename","page-menu.submenu.duplicate-page":"Duplicate","page-menu.submenu.title":"Menu","page-menu.submenu.move-down":"Move down","page-menu.submenu.move-up":"Move up","page-menu.submenu.delete":"Delete","share-menu.title":"Share","share-menu.save-note":"Download this project to your computer as a .tldr file.","share-menu.fork-note":"Create a new shared project based on this snapshot.","share-menu.share-project":"Share this project","share-menu.default-project-name":"Shared Project","share-menu.copy-link":"Copy editor 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 viewer link","share-menu.offline-note":"Create a new shared project based on your current project.","share-menu.copy-link-note":"Anyone with the link will be able to view and edit this project.","share-menu.copy-readonly-link-note":"Anyone with the link will be able to access this project.","share-menu.project-too-large":"Sorry, this project can't be shared because it's too large. We're working on it!","share-menu.upload-failed":"Sorry, we couldn't upload your project at the moment. Please try again or let us know if the problem persists.","share-menu.creating-project":"Creating the new project…","share-menu.copied":"Copied link","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.docs":"Documentation & API","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..."},Lq=new Set(["ar","fa","he","ur","ku"]),ya={locale:"en",label:"English",messages:Uv,dir:"ltr"};async function $q(e,t){if(!(await bo(t.translations.en)).ok)return console.warn("No main translations found."),ya;if(e==="en")return ya;const r=iu.find(a=>a.locale===e);if(!r)return console.warn(`No translation found for locale ${e}`),ya;const s=await(await bo(t.translations[r.locale])).json();if(!s)return console.warn(`No messages found for locale ${e}`),ya;const i=[];for(const a in ya.messages)s[a]||i.push(a);return i.length>0,{locale:e,label:r.label,dir:Lq.has(r.locale)?"rtl":"ltr",messages:{...ya.messages,...s}}}const GA=P.createContext(null);function VA(){const e=P.useContext(GA);if(!e)throw new Error("useCurrentTranslation must be used inside of <TldrawUiContextProvider />");return e}const Nq=Lt(function({overrides:t,children:n}){const o=F().user.getLocale(),s=bw(),[i,a]=P.useState(()=>t&&t.en?{locale:"en",label:"English",dir:"ltr",messages:{...Uv,...t.en}}:{locale:"en",label:"English",dir:"ltr",messages:Uv});return P.useEffect(()=>{let l=!1;async function c(){const u=await $q(o,s);u&&!l&&(t&&t[o]?a({...u,messages:{...u.messages,...t[o]}}):a(u))}return c(),()=>{l=!0}},[s,o,t]),d.jsx(GA.Provider,{value:i,children:n})});function we(){const e=VA();return P.useCallback(function(n){return e.messages[n]??n},[e])}class dp extends Wr{constructor(){super(...arguments);g(this,"canEdit",()=>!0);g(this,"hideResizeHandles",()=>!0);g(this,"hideSelectionBoundsFg",()=>!1);g(this,"onBeforeCreate",n=>OI(this.editor,n));g(this,"onBeforeUpdate",(n,r)=>{if(!(n.props.text===r.props.text&&n.props.font===r.props.font&&n.props.size===r.props.size))return OI(this.editor,r)});g(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:"",scale:1}}getGeometry(n){const{labelHeight:r,labelWidth:o}=YA(this.editor,n),{scale:s}=n.props,i=r*s,a=o*s,l=Be*s,c=ch(n);return new Gr({children:[new os({width:l,height:c,isFilled:!0}),new os({x:n.props.align==="start"?0:n.props.align==="end"?l-a:(l-a)/2,y:n.props.verticalAlign==="start"?0:n.props.verticalAlign==="end"?c-i:(c-i)/2,width:a,height:i,isFilled:!0,isLabel:!0})]})}getHandles(n){const{scale:r}=n.props;if(this.editor.getInstanceState().isCoarsePointer)return[];const s=this.editor.getZoomLevel();if(s*r<.25)return[];const i=ch(n),a=Be*r,l=dX/s*r;return s*r<.5?[{id:"bottom",index:"a3",type:"clone",x:a/2,y:i+l}]:[{id:"top",index:"a1",type:"clone",x:a/2,y:-l},{id:"right",index:"a2",type:"clone",x:a+l,y:i/2},{id:"bottom",index:"a3",type:"clone",x:a/2,y:i+l},{id:"left",index:"a4",type:"clone",x:-l,y:i/2}]}component(n){const{id:r,type:o,props:{scale:s,color:i,font:a,size:l,align:c,text:u,verticalAlign:h,fontSizeAdjustment:p}}=n,f=Bq(r),S=jr(),y=Be*s,x=ch(n),m=K("shape rotation",()=>{var C;return((C=this.editor.getShapePageTransform(r))==null?void 0:C.rotation())??0},[this.editor]),v=K("zoom",()=>this.editor.getZoomLevel()<.35/s,[s,this.editor]),w=n.id===this.editor.getOnlySelectedShapeId();return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:r,className:"tl-note__container",style:{width:y,height:x,backgroundColor:S[i].note.fill,borderBottom:v?`${3*s}px solid rgb(15, 23, 31, .2)`:"none",boxShadow:v?"none":Uq(n.id,m,s)},children:d.jsx(xg,{id:r,type:o,font:a,fontSize:(p||qo[l])*s,lineHeight:Vt.lineHeight,align:c,verticalAlign:h,text:u,isNote:!0,isSelected:w,labelColor:S[i].note.text,wrap:!0,padding:16*s,onKeyDown:f})}),"url"in n.props&&n.props.url&&d.jsx(yl,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]})}indicator(n){const{scale:r}=n.props;return d.jsx("rect",{rx:r,width:N(Be*r),height:N(ch(n))})}toSvg(n,r){n.props.text&&r.addExportDef(Sg(n.props.font));const o=cs({isDarkMode:r.isDarkMode}),s=Hq(n);return d.jsxs(d.Fragment,{children:[d.jsx("rect",{x:5,y:5,rx:1,width:Be-10,height:s.h,fill:"rgba(0,0,0,.1)"}),d.jsx("rect",{rx:1,width:Be,height:s.h,fill:o[n.props.color].note.fill}),d.jsx(vg,{fontSize:n.props.fontSizeAdjustment||qo[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})]})}}g(dp,"type","note"),g(dp,"props",G_),g(dp,"migrations",V_);function OI(e,t){const{labelHeight:n,fontSizeAdjustment:r}=YA(e,t),o=Math.max(0,n-Be);if(o!==t.props.growY||r!==t.props.fontSizeAdjustment)return{...t,props:{...t.props,growY:o,fontSizeAdjustment:r}}}function Fq(e,t){const{text:n}=t.props;if(!n)return{labelHeight:qo[t.props.size]*Vt.lineHeight+vr*2,labelWidth:100,fontSizeAdjustment:0};const r=qo[t.props.size];let o=0,s=0,i=Be,a=Be;const l=1;do{o=Math.min(r,r-s);const c=e.textMeasure.measureText(n,{...Vt,fontFamily:wo[t.props.font],fontSize:o,maxWidth:Be-vr*2-l,disableOverflowWrapBreaking:!0});if(i=c.h+vr*2,a=c.w+vr*2,o<=14){const u=e.textMeasure.measureText(n,{...Vt,fontFamily:wo[t.props.font],fontSize:o,maxWidth:Be-vr*2-l});i=u.h+vr*2,a=u.w+vr*2;break}if(c.scrollWidth.toFixed(0)===c.w.toFixed(0))break}while(s++<50);return{labelHeight:i,labelWidth:a,fontSizeAdjustment:o}}const zq=new Qo;function YA(e,t){return zq.get(t,()=>Fq(e,t))}function Bq(e){const t=F(),n=VA();return P.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),l=a.rotation(),c=!!(n.dir==="rtl"||vA(o.props.text)),u=(Be+t.options.adjacentShapeMargin+(i&&!r.shiftKey?o.props.growY:0))*o.props.scale,h=new b(s?r.shiftKey!=c?-1:1:0,i?r.shiftKey?-1:1:0).mul(u).add(yg.clone().mul(o.props.scale)).rot(l).add(a.point()),p=kA(t,o,h,l);p&&(t.mark("editing adjacent shape"),xf(t,p,!0))}},[e,t,n.dir])}function ch(e){return(Be+e.props.growY)*e.props.scale}function Uq(e,t,n){const r=qr(e),o=Math.abs(r())+.5,s=Math.cos(t),i=5*n,a=4*n,l=6*n,c=7*n;return`0px ${i-o}px ${i}px -${i}px rgba(15, 23, 31, .6),
|
|
219
|
+
0px ${(a+o*c)*Math.max(0,s)}px ${l+o*c}px -${a+o*l}px rgba(15, 23, 31, ${(.3+o*.1).toFixed(2)}),
|
|
220
|
+
0px ${48*n}px ${10*n}px -${10*n}px inset rgba(15, 23, 44, ${((.022+r()*.005)*((1+s)/2)).toFixed(2)})`}function Hq(e){return new Q(0,0,Be,Be+e.props.growY)}function Kq(e,{initialBounds:t,scaleX:n,scaleY:r,newPoint:o}){const s=Math.max(.01,Math.min(Math.abs(n),Math.abs(r))),i=new b(0,0);n<0&&(i.x=-(t.width*s)),r<0&&(i.y=-(t.height*s));const{x:a,y:l}=b.Add(o,i.rot(e.rotation));return{x:a,y:l,props:{scale:s*e.props.scale}}}const Wq=new Qo;class hp extends Wr{constructor(){super(...arguments);g(this,"canEdit",()=>!0);g(this,"isAspectRatioLocked",()=>!0);g(this,"onResize",(n,r)=>{const{newPoint:o,initialBounds:s,initialShape:i,scaleX:a,handle:l}=r;if(r.mode==="scale_shape"||l!=="right"&&l!=="left")return{id:n.id,type:n.type,...Kq(n,r)};{const c=Math.max(1,Math.abs(s.width*a)),{x:u,y:h}=a<0?b.Sub(o,b.FromAngle(n.rotation).mul(c)):o;return{id:n.id,type:n.type,x:u,y:h,props:{w:c/i.props.scale,autoSize:!1}}}});g(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()}}])});g(this,"onBeforeUpdate",(n,r)=>{if(!r.props.autoSize)return;const o=n.props.size!==r.props.size||n.props.textAlign!==r.props.textAlign||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=DI(this.editor,r.props),l=i.width*n.props.scale,c=i.height*n.props.scale,u=a.width*r.props.scale,h=a.height*r.props.scale;let p;switch(r.props.textAlign){case"middle":{p=new b((u-l)/2,s?0:(h-c)/2);break}case"end":{p=new b(u-l,s?0:(h-c)/2);break}default:{if(s)break;p=new b(0,(h-c)/2);break}}if(p){p.rot(r.rotation);const{x:f,y:S}=r;return{...r,x:f-p.x,y:S-p.y,props:{...r.props,w:u}}}else return{...r,props:{...r.props,w:u}}})}getDefaultProps(){return{color:"black",size:"m",w:8,text:"",font:"draw",textAlign:"start",autoSize:!0,scale:1}}getMinDimensions(n){return Wq.get(n.props,r=>DI(this.editor,r))}getGeometry(n){const{scale:r}=n.props,{width:o,height:s}=this.getMinDimensions(n);return new os({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:l,textAlign:c}}=n,{width:u,height:h}=this.getMinDimensions(n),p=n.id===this.editor.getOnlySelectedShapeId(),f=jr(),S=Gq(r);return d.jsx(xg,{id:r,classNamePrefix:"tl-text-shape",type:"text",font:o,fontSize:gl[s],lineHeight:Vt.lineHeight,align:c,verticalAlign:"middle",text:i,labelColor:f[a].solid,isSelected:p,textWidth:u,textHeight:h,style:{transform:`scale(${l})`,transformOrigin:"top left"},wrap:!0,onKeyDown:S})}indicator(n){const r=this.editor.getShapeGeometry(n).bounds,o=F();return n.props.autoSize&&o.getEditingShapeId()===n.id?null:d.jsx("rect",{width:N(r.width),height:N(r.height)})}toSvg(n,r){n.props.text&&r.addExportDef(Sg(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=cs(r);return d.jsx(vg,{fontSize:gl[n.props.size],font:n.props.font,align:n.props.textAlign,verticalAlign:"middle",text:n.props.text,labelColor:a[n.props.color].solid,bounds:new Q(0,0,s,i),padding:0})}}g(hp,"type","text"),g(hp,"props",Y_),g(hp,"migrations",X_);function DI(e,t){const{font:n,text:r,autoSize:o,size:s,w:i}=t,a=o?16:Math.max(16,i),l=gl[s],c=o?null:Math.floor(Math.max(a,i)),u=e.textMeasure.measureText(r,{...Vt,fontFamily:wo[n],fontSize:l,maxWidth:c});return o&&(u.w+=1),{width:Math.max(a,u.w),height:Math.max(l,u.h)}}function Gq(e){const t=F();return P.useCallback(n=>{if(t.getEditingShapeId()===e)switch(n.key){case"Enter":{(n.ctrlKey||n.metaKey)&&t.complete();break}case"Tab":{Ee(n),n.shiftKey?ml.unindent(n.currentTarget):ml.indent(n.currentTarget);break}}},[t,e])}class pp extends Dl{constructor(){super(...arguments);g(this,"canEdit",()=>!0);g(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,{asset:s,url:i}=zA(n.id,n.props.assetId,n.props.w),{time:a,playing:l}=n.props,c=gg(n.id),u=BA(),h=P.useRef(null),p=P.useCallback(v=>{const w=v.currentTarget;w&&r.updateShapes([{type:"video",id:n.id,props:{playing:!0,time:w.currentTime}}])},[n.id,r]),f=P.useCallback(v=>{const w=v.currentTarget;w&&r.updateShapes([{type:"video",id:n.id,props:{playing:!1,time:w.currentTime}}])},[n.id,r]),S=P.useCallback(v=>{const w=v.currentTarget;w&&c&&r.updateShapes([{type:"video",id:n.id,props:{time:w.currentTime}}])},[c,n.id,r]),[y,x]=P.useState(!1),m=P.useCallback(v=>{const w=v.currentTarget;w&&(a!==w.currentTime&&(w.currentTime=a),l||w.pause(),x(!0))},[l,a]);return P.useEffect(()=>{const v=h.current;v&&(y&&!c&&a!==v.currentTime&&(v.currentTime=a),c&&document.activeElement!==v&&v.focus())},[c,y,a]),P.useEffect(()=>{if(u){const v=h.current;if(!v)return;v.pause(),v.currentTime=0}},[h,u]),d.jsxs(d.Fragment,{children:[d.jsx(Gi,{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:d.jsx("div",{className:"tl-counter-scaled",children:d.jsx("div",{className:"tl-video-container",children:s!=null&&s.props.src?i?d.jsx("video",{ref:h,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:p,onPause:f,onTimeUpdate:S,onLoadedData:m,hidden:!y,children:d.jsx("source",{src:i})}):null:d.jsx(FA,{})})})}),"url"in n.props&&n.props.url&&d.jsx(yl,{url:n.props.url,zoomLevel:r.getZoomLevel()})]})}indicator(n){return d.jsx("rect",{width:N(n.props.w),height:N(n.props.h)})}toSvg(n){return d.jsx("image",{href:Vq(n.id),width:n.props.w,height:n.props.h})}}g(pp,"type","video"),g(pp,"props",q_),g(pp,"migrations",Z_);function Vq(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 XA=[hp,rp,op,ap,dp,up,ip,np,lp,sp,cp,pp];function Yq(e){return e.sideEffects.register({instance_page_state:{afterChange:(t,n)=>{if(t.croppingShapeId!==n.croppingShapeId){const r=e.isIn("select.crop");!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 qA extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"scribbleId","id");g(this,"markId","");g(this,"excludedShapeIds",new Set);g(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()});g(this,"pushPointToScribble",()=>{const{x:n,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,n,r)});g(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});g(this,"onPointerMove",()=>{this.update()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.complete()})}update(){const{editor:n,excludedShapeIds:r}=this,o=n.getErasingShapeIds(),s=n.getZoomLevel(),i=n.getCurrentPageShapes(),{inputs:{currentPagePoint:a,previousPagePoint:l}}=n;this.pushPointToScribble();const c=new Set(o),u=this.editor.options.hitTestMargin/s;for(const h of i){if(n.isShapeOfType(h,"group"))continue;const p=n.getShapeMask(h.id);if(p&&!sr(a,p))continue;const f=n.getShapeGeometry(h),S=n.getShapePageTransform(h);if(!f||!S)continue;const y=S.clone().invert(),x=y.applyToPoint(l),m=y.applyToPoint(a),{bounds:v}=f;v.minX-u>Math.max(x.x,m.x)||v.minY-u>Math.max(x.y,m.y)||v.maxX+u<Math.min(x.x,m.x)||v.maxY+u<Math.min(x.y,m.y)||f.hitTestLineSegment(x,m,u)&&c.add(n.getOutermostSelectableShape(h).id)}this.editor.setErasingShapes([...c].filter(h=>!r.has(h)))}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)}}g(qA,"id","erasing");var Qy;let Xq=(Qy=class extends oe{constructor(){super(...arguments);g(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});g(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},g(Qy,"id","idle"),Qy);var Jy;let qq=(Jy=class extends oe{constructor(){super(...arguments);g(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,l=a-1;l>=0;l--){const c=r[l];if(!(this.editor.isShapeOrAncestorLocked(c)||this.editor.isShapeOfType(c,"group"))&&this.editor.isPointInShape(c,o,{hitInside:!1,margin:this.editor.options.hitTestMargin/n})){const u=this.editor.getOutermostSelectableShape(c);if(this.editor.isShapeOfType(u,"frame")&&s.size>i)break;s.add(u.id)}}this.editor.setErasingShapes([...s])});g(this,"onLongPress",n=>{this.startErasing(n)});g(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.startErasing(n)});g(this,"onPointerUp",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.complete()});g(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")}},g(Jy,"id","pointing"),Jy);class Mc extends oe{constructor(){super(...arguments);g(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})})}}g(Mc,"id","eraser"),g(Mc,"initial","idle"),g(Mc,"isLockable",!1),g(Mc,"children",()=>[Xq,qq,qA]);class ZA extends oe{constructor(){super(...arguments);g(this,"initialCamera",new b);g(this,"onEnter",()=>{this.initialCamera=b.From(this.editor.getCamera()),this.update()});g(this,"onPointerMove",()=>{this.update()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onCancel",()=>{this.parent.transition("idle")});g(this,"onComplete",()=>{this.complete()})}update(){const{initialCamera:n,editor:r}=this,{currentScreenPoint:o,originScreenPoint:s}=r.inputs,i=b.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}),this.parent.transition("idle")}}g(ZA,"id","dragging");var eS;let Zq=(eS=class extends oe{constructor(){super(...arguments);g(this,"onEnter",()=>{this.editor.setCursor({type:"grab",rotation:0})});g(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});g(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},g(eS,"id","idle"),eS);var tS;let Qq=(tS=class extends oe{constructor(){super(...arguments);g(this,"onEnter",()=>{this.editor.stopCameraAnimation(),this.editor.setCursor({type:"grabbing",rotation:0})});g(this,"onLongPress",()=>{this.startDragging()});g(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startDragging()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onCancel",()=>{this.complete()});g(this,"onComplete",()=>{this.complete()});g(this,"onInterrupt",()=>{this.complete()})}startDragging(){this.parent.transition("dragging")}complete(){this.parent.transition("idle")}},g(tS,"id","pointing"),tS);class Ac extends oe{constructor(){super(...arguments);g(this,"onDoubleClick",n=>{if(n.phase==="settle"){const{currentScreenPoint:r}=this.editor.inputs;this.editor.zoomIn(r,{animation:{duration:220,easing:At.easeOutQuint}})}});g(this,"onTripleClick",n=>{if(n.phase==="settle"){const{currentScreenPoint:r}=this.editor.inputs;this.editor.zoomOut(r,{animation:{duration:320,easing:At.easeOutQuint}})}});g(this,"onQuadrupleClick",n=>{if(n.phase==="settle"){const r=this.editor.getZoomLevel(),{inputs:{currentScreenPoint:o}}=this.editor;r===1?this.editor.zoomToFit({animation:{duration:400,easing:At.easeOutQuint}}):this.editor.resetZoom(o,{animation:{duration:320,easing:At.easeOutQuint}})}})}}g(Ac,"id","hand"),g(Ac,"initial","idle"),g(Ac,"isLockable",!1),g(Ac,"children",()=>[Zq,Qq,ZA]);var nS;let Jq=(nS=class extends oe{constructor(){super(...arguments);g(this,"onPointerDown",n=>{this.parent.transition("lasering",n)})}},g(nS,"id","idle"),nS);class QA extends oe{constructor(){super(...arguments);g(this,"scribbleId","id");g(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()});g(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});g(this,"onPointerMove",()=>{this.pushPointToScribble()});g(this,"onPointerUp",()=>{this.complete()});g(this,"pushPointToScribble",()=>{const{x:n,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,n,r)});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.complete()})}complete(){this.parent.transition("idle")}cancel(){this.parent.transition("idle")}}g(QA,"id","lasering");class jc extends oe{constructor(){super(...arguments);g(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})})}}g(jc,"id","laser"),g(jc,"initial","idle"),g(jc,"children",()=>[Jq,QA]),g(jc,"isLockable",!1);class JA extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"initialSelectedShapeIds",[]);g(this,"excludedShapeIds",new Set);g(this,"isWrapMode",!1);g(this,"initialStartShape",null);g(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()});g(this,"onExit",()=>{this.initialSelectedShapeIds=[],this.editor.updateInstanceState({brush:null})});g(this,"onTick",({elapsed:n})=>{const{editor:r}=this;r.edgeScrollManager.updateEdgeScrolling(n)});g(this,"onPointerMove",()=>{this.hitTestShapes()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onComplete",()=>{this.complete()});g(this,"onCancel",n=>{this.editor.setSelectedShapes(this.initialSelectedShapeIds),this.parent.transition("idle",n)});g(this,"onKeyDown",n=>{this.editor.inputs.altKey?this.parent.transition("scribble_brushing",n):this.hitTestShapes()});g(this,"onKeyUp",()=>{this.hitTestShapes()});g(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:l}}=n,c=new Set(a?this.initialSelectedShapeIds:[]),u=o?!l:l,h=Q.FromPoints([s,i]),{corners:p}=h;let f,S,y,x,m,v;const w=n.getCurrentPageShapes(),C=n.getCurrentPageId();e:for(let I=0,k=w.length;I<k;I++){if(y=w[I],r.has(y.id)||c.has(y.id)||(x=n.getShapePageBounds(y),!x))continue e;if(h.contains(x)){this.handleHit(y,i,C,c,p);continue e}if(u||n.isShapeOfType(y,"frame"))continue e;if(h.collides(x)){if(m=n.getShapePageTransform(y),!m)continue e;v=m.clone().invert().applyToPoints(p);const T=n.getShapeGeometry(y);t:for(let M=0;M<4;M++)if(f=v[M],S=v[(M+1)%4],T.hitTestLineSegment(f,S,0)){this.handleHit(y,i,C,c,p);break t}}}n.getInstanceState().isCoarsePointer;const E=n.getInstanceState().brush;(!E||!h.equals(E))&&n.updateInstanceState({brush:{...h.toJson()}});const _=n.getSelectedShapeIds();(_.length!==c.size||_.some(I=>!c.has(I)))&&n.setSelectedShapes(Array.from(c))}handleHit(n,r,o,s,i){if(n.parentId===o){s.add(n.id);return}const a=this.editor.getOutermostSelectableShape(n),l=this.editor.getShapeMask(a.id);l&&!GM(l,i)&&!sr(r,l)||s.add(a.id)}}g(JA,"id","brushing");const vl={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 ej extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"onEnter",n=>{this.info=n,this.updateCursor()});g(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startResizing()});g(this,"onLongPress",()=>{this.startResizing()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.cancel()});g(this,"onInterrupt",()=>{this.cancel()})}updateCursor(){const n=this.editor.getSelectedShapes(),r=vl[this.info.handle];this.editor.setCursor({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")}}g(ej,"id","pointing_resize_handle");const yr=8;class Pw extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"markId","");g(this,"snapshot",{});g(this,"onEnter",n=>{this.info=n,this.markId="cropping",this.editor.mark(this.markId),this.snapshot=this.createSnapshot(),this.updateShapes()});g(this,"onPointerMove",()=>{this.updateShapes()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onComplete",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"getDefaultCrop",()=>({topLeft:{x:0,y:0},bottomRight:{x:1,y:1}}))}updateCursor(){if(!this.editor.getSelectedShapes()[0])return;const r=vl[this.info.handle];this.editor.setCursor({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),l=i.clone().sub(a).rot(-n.rotation),c=s.crop??this.getDefaultCrop(),u=Ge(c),h=new b(n.x,n.y),p=new b(0,0),f=1/(c.bottomRight.x-c.topLeft.x)*s.w,S=1/(c.bottomRight.y-c.topLeft.y)*s.h;let y=!1;switch(this.info.handle){case"top":case"top_left":case"top_right":{if(S<yr)break;y=!0,u.topLeft.y=u.topLeft.y+l.y/S,S*(u.bottomRight.y-u.topLeft.y)<yr?(u.topLeft.y=u.bottomRight.y-yr/S,p.y=(u.topLeft.y-c.topLeft.y)*S):u.topLeft.y<=0?(u.topLeft.y=0,p.y=(u.topLeft.y-c.topLeft.y)*S):p.y=l.y;break}case"bottom":case"bottom_left":case"bottom_right":{if(S<yr)break;y=!0,u.bottomRight.y=Math.min(1,u.bottomRight.y+l.y/S),S*(u.bottomRight.y-u.topLeft.y)<yr&&(u.bottomRight.y=u.topLeft.y+yr/S);break}}switch(this.info.handle){case"left":case"top_left":case"bottom_left":{if(f<yr)break;y=!0,u.topLeft.x=u.topLeft.x+l.x/f,f*(u.bottomRight.x-u.topLeft.x)<yr?(u.topLeft.x=u.bottomRight.x-yr/f,p.x=(u.topLeft.x-c.topLeft.x)*f):u.topLeft.x<=0?(u.topLeft.x=0,p.x=(u.topLeft.x-c.topLeft.x)*f):p.x=l.x;break}case"right":case"top_right":case"bottom_right":{if(f<yr)break;y=!0,u.bottomRight.x=Math.min(1,u.bottomRight.x+l.x/f),f*(u.bottomRight.x-u.topLeft.x)<yr&&(u.bottomRight.x=u.topLeft.x+yr/f);break}}if(!y)return;h.add(p.rot(n.rotation));const x={id:n.id,type:n.type,x:h.x,y:h.y,props:{crop:u,w:(u.bottomRight.x-u.topLeft.x)*f,h:(u.bottomRight.y-u.topLeft.y)*S}};this.editor.updateShapes([x]),this.updateCursor()}complete(){this.updateShapes(),Ke(this.editor,[this.snapshot.shape.id]),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))}createSnapshot(){const n=this.editor.getSelectionRotation(),{inputs:{originPagePoint:r}}=this.editor,o=this.editor.getOnlySelectedShape(),s=this.editor.getSelectionRotatedPageBounds(),i=b.RotWith(s.getHandlePoint(this.info.handle),s.point,n),a=b.Sub(r,i);return{shape:o,cursorHandleOffset:a}}}g(Pw,"id","cropping");function tj(e,t=!1){const n=e.getZoomLevel(),{inputs:{currentPagePoint:r}}=e;return e.getShapeAtPoint(r,{hitInside:!1,hitLabels:t,margin:e.options.hitTestMargin/n,renderingOnly:!0})??e.getSelectedShapeAtPoint(r)}function nj(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,l=r.bottomRight.x-r.topLeft.x,c=Ge(r);return c.topLeft.x=Math.min(1-l,Math.max(0,c.topLeft.x-n.x/s)),c.topLeft.y=Math.min(1-a,Math.max(0,c.topLeft.y-n.y/i)),c.bottomRight.x=c.topLeft.x+l,c.bottomRight.y=c.topLeft.y+a,{id:t.id,type:t.type,props:{crop:c}}}var rS;let eZ=(rS=class extends oe{constructor(){super(...arguments);g(this,"onEnter",()=>{this.editor.setCursor({type:"default",rotation:0});const n=this.editor.getOnlySelectedShape();n&&this.editor.setCroppingShape(n.id)});g(this,"onExit",()=>{this.editor.setCursor({type:"default",rotation:0})});g(this,"onCancel",()=>{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})});g(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=tj(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.idle"});break}case"top":case"right":case"bottom":case"left":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{this.editor.setCurrentTool("select.crop.pointing_crop_handle",{...n,onInteractionEnd:"select.crop.idle"});break}default:this.cancel()}break}}}});g(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);if(s){if(n.target==="selection"){(i=s.onDoubleClickEdge)==null||i.call(s,o);return}this.cancel(),this.editor.root.handleEvent(n)}});g(this,"onKeyDown",()=>{this.nudgeCroppingImage(!1)});g(this,"onKeyRepeat",()=>{this.nudgeCroppingImage(!0)});g(this,"onKeyUp",n=>{switch(n.code){case"Enter":{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{});break}}})}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 b(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 b(0,0)))return;o&&s.mul(10);const i=this.editor.getShape(this.editor.getCroppingShapeId());if(!i)return;const a=nj(this.editor,i,s);a&&(n||this.editor.mark("translate crop"),this.editor.updateShapes([a]))}},g(rS,"id","idle"),rS);class rj extends oe{constructor(){super(...arguments);g(this,"onCancel",()=>{this.editor.setCurrentTool("select.crop.idle",{})});g(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.editor.setCurrentTool("select.crop.translating_crop",n)});g(this,"onPointerUp",n=>{this.editor.setCurrentTool("select.crop.idle",n)})}}g(rj,"id","pointing_crop");class Cw extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"onEnter",n=>{this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd);const r=this.editor.getSelectedShapes()[0];if(!r)return;const o=vl[this.info.handle];this.editor.setCursor({type:o,rotation:this.editor.getSelectionRotation()}),this.editor.setCroppingShape(r.id)});g(this,"onExit",()=>{this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0)});g(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startCropping()});g(this,"onLongPress",()=>{this.startCropping()});g(this,"onPointerUp",()=>{this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle"))});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.cancel()});g(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.editor.setCurrentTool("select.idle"))}}g(Cw,"id","pointing_crop_handle");class oj extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"markId","translating crop");g(this,"snapshot",{});g(this,"onEnter",n=>{this.info=n,this.snapshot=this.createSnapshot(),this.editor.mark(this.markId),this.editor.setCursor({type:"move",rotation:0}),this.updateShapes()});g(this,"onExit",()=>{this.editor.setCursor({type:"default",rotation:0})});g(this,"onPointerMove",()=>{this.updateShapes()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onComplete",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"onKeyDown",n=>{switch(n.key){case"Alt":case"Shift":{this.updateShapes();return}}});g(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=nj(this.editor,n,s);i&&this.editor.updateShapes([i])}}g(oj,"id","translating_crop");class fp extends oe{constructor(){super(...arguments);g(this,"markId","");g(this,"onEnter",()=>{this.didCancel=!1,this.markId="crop",this.editor.mark(this.markId)});g(this,"didCancel",!1);g(this,"onExit",()=>{this.didCancel?this.editor.bailToMark(this.markId):this.editor.squashToMark(this.markId)});g(this,"onCancel",()=>{this.didCancel=!0})}}g(fp,"id","crop"),g(fp,"initial","idle"),g(fp,"children",()=>[eZ,oj,rj,Cw,Pw]);class sj extends oe{constructor(){super(...arguments);g(this,"shapeId","");g(this,"initialHandle",{});g(this,"initialAdjacentHandle",null);g(this,"initialPagePoint",{});g(this,"markId","");g(this,"initialPageTransform");g(this,"initialPageRotation");g(this,"info",{});g(this,"isPrecise",!1);g(this,"isPreciseId",null);g(this,"pointingId",null);g(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=Ge(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 c=this.editor.getShapeHandles(r).find(u=>u.index===s.index);this.initialHandle=Ge(c)}this.initialPageTransform=this.editor.getShapePageTransform(r),this.initialPageRotation=this.initialPageTransform.rotation(),this.initialPagePoint=this.editor.inputs.originPagePoint.clone(),this.editor.setCursor({type:o?"cross":"grabbing",rotation:0});const i=this.editor.getShapeHandles(r).sort(ln),a=i.findIndex(l=>l.id===n.handle.id);this.initialAdjacentHandle=null;for(let l=a+1;l<i.length;l++){const c=i[l];if(c.type==="vertex"&&c.id!=="middle"&&c.id!==n.handle.id){this.initialAdjacentHandle=c;break}}if(!this.initialAdjacentHandle)for(let l=i.length-1;l>=0;l--){const c=i[l];if(c.type==="vertex"&&c.id!=="middle"&&c.id!==n.handle.id){this.initialAdjacentHandle=c;break}}if(this.editor.isShapeOfType(r,"arrow")){const l=$n(this.editor,r)[n.handle.id];this.isPrecise=!1,l?(this.editor.setHintingShapes([l.toId]),this.isPrecise=l.props.isPrecise,this.isPrecise?this.isPreciseId=l.toId:this.resetExactTimeout()):this.editor.setHintingShapes([])}this.update(),this.editor.select(this.shapeId)});g(this,"exactTimeout",-1);g(this,"onPointerMove",()=>{this.update()});g(this,"onKeyDown",()=>{this.update()});g(this,"onKeyUp",()=>{this.update()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onComplete",()=>{this.update(),this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.setHintingShapes([]),this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0})})}resetExactTimeout(){this.exactTimeout!==-1&&this.clearExactTimeout(),this.exactTimeout=this.editor.timers.setTimeout(()=>{this.getIsActive()&&!this.isPrecise&&(this.isPrecise=!0,this.isPreciseId=this.pointingId,this.update()),this.exactTimeout=-1},750)}clearExactTimeout(){this.exactTimeout!==-1&&(clearTimeout(this.exactTimeout),this.exactTimeout=-1)}complete(){this.editor.snaps.clearIndicators(),Ke(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 I;const{editor:n,shapeId:r,initialPagePoint:o}=this,{initialHandle:s,initialPageRotation:i,initialAdjacentHandle:a}=this,l=this.editor.getHintingShapeIds(),c=this.editor.user.getIsSnapMode(),{snaps:u,inputs:{currentPagePoint:h,shiftKey:p,ctrlKey:f,altKey:S,pointerVelocity:y}}=n,x=this.info.shape,m=n.getShape(r);if(!m)return;const v=n.getShapeUtil(m);let w=h.clone().sub(o).rot(-i).add(s);if(p&&a&&s.id!=="middle"){const k=b.Angle(a,w),M=Bp(k,24)-k;w=b.RotWith(w,a,M)}n.snaps.clearIndicators();let C={...s,x:w.x,y:w.y};if(s.canSnap&&(c?!f:f)){if(!n.getShapePageTransform(m.id))throw Error("Expected a page transform");const T=u.handles.snapHandle({currentShapeId:r,handle:C});T&&(T.nudge.rot(-n.getShapeParentTransform(m).rotation()),w.add(T.nudge),C={...s,x:w.x,y:w.y})}const E=(I=v.onHandleDrag)==null?void 0:I.call(v,m,{handle:C,isPrecise:this.isPrecise||S,initial:x}),_={id:m.id,type:m.type,...E};if(s.type==="vertex"&&this.editor.isShapeOfType(m,"arrow")){const k=$n(n,m)[s.id];k?l[0]!==k.toId&&(n.setHintingShapes([k.toId]),this.pointingId=k.toId,this.isPrecise=y.len()<.5||S,this.isPreciseId=this.isPrecise?k.toId:null,this.resetExactTimeout()):l.length>0&&(n.setHintingShapes([]),this.pointingId=null,this.isPrecise=!1,this.isPreciseId=null,this.resetExactTimeout())}E&&n.updateShapes([_])}}g(sj,"id","dragging_handle");function ij(e){return e.isLabel?[e]:e instanceof Gr?e.children.filter(t=>t.isLabel):[]}class aj extends oe{constructor(){super(...arguments);g(this,"hitShapeForPointerUp",null);g(this,"onEnter",()=>{const n=this.editor.getEditingShape();if(!n)throw Error("Entered editing state without an editing shape");this.hitShapeForPointerUp=null,Go(this.editor),this.editor.select(n)});g(this,"onExit",()=>{var s;const{editingShapeId:n}=this.editor.getCurrentPageState();if(!n)return;this.editor.setEditingShape(null),Go.cancel();const r=this.editor.getShape(n),o=this.editor.getShapeUtil(r);(s=o.onEditEnd)==null||s.call(o,r)});g(this,"onPointerMove",n=>{if(this.hitShapeForPointerUp&&this.editor.inputs.isDragging){if(this.editor.getInstanceState().isReadonly||this.hitShapeForPointerUp.isLocked)return;this.editor.select(this.hitShapeForPointerUp),this.parent.transition("translating",n),this.hitShapeForPointerUp=null;return}switch(n.target){case"shape":case"canvas":{Go(this.editor);return}}});g(this,"onPointerDown",n=>{switch(this.hitShapeForPointerUp=null,n.target){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=ij(s),a=i.length===1?i[0]:void 0,l=this.editor.isShapeOfType(o,"text")&&o.props.text.trim()==="";if(a&&!l){const c=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint);if(a.bounds.containsPoint(c,0)&&a.hitTestPoint(c)){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),this.parent.transition("idle",n));else{this.parent.transition("pointing_shape",n);return}return}break}}this.parent.transition("idle",n),this.editor.root.handleEvent(n)});g(this,"onPointerUp",n=>{const r=this.hitShapeForPointerUp;if(!r)return;this.hitShapeForPointerUp=null;const o=this.editor.getShapeUtil(r);if(!r.isLocked){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),Go(this.editor)}});g(this,"onComplete",n=>{this.parent.transition("idle",n)});g(this,"onCancel",n=>{this.parent.transition("idle",n)})}}g(aj,"id","editing_shape");function RI(e){const t=e.getOnlySelectedShape();return!!(t&&!e.isShapeOrAncestorLocked(t)&&e.getShapeUtil(t).canCrop(t))}function Pf(e){const t=e.getSelectedShapeIds(),{shiftKey:n,altKey:r,currentPagePoint:o}=e.inputs,s=e.getShapeAtPoint(o,{hitInside:!1,margin:e.options.hitTestMargin/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(On(i)){const a=e.getShape(i);e.isPointInShape(a,o,{margin:0,hitInside:!0})||e.setFocusedGroup(null)}}}}const tZ=["Delete","Backspace","[","]","Enter"," ","Shift","Tab"];var oS;let nZ=(oS=class extends oe{constructor(){super(...arguments);g(this,"onEnter",()=>{this.parent.setCurrentToolIdMask(void 0),Go(this.editor),this.editor.setCursor({type:"default",rotation:0})});g(this,"onExit",()=>{Go.cancel()});g(this,"onPointerMove",()=>{Go(this.editor)});g(this,"onPointerDown",n=>{if(this.editor.getIsMenuOpen())return;const r=n.ctrlKey&&RI(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=tj(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))&&LI(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":case"top_left":case"top_right":case"bottom_left":case"bottom_right":{r?this.parent.transition("crop.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}}});g(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(),l=a&&!this.editor.isShapeOfType(a,"group")?a:this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint)??this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{margin:this.editor.options.hitTestMargin/this.editor.getZoomLevel(),hitInside:!1}),c=this.editor.getFocusedGroupId();if(l){if(this.editor.isShapeOfType(l,"group")){Pf(this.editor);return}else{const u=this.editor.getShape(l.parentId);if(u&&this.editor.isShapeOfType(u,"group")&&!(c&&u.id===c)){Pf(this.editor);return}}this.onDoubleClick({...n,shape:l,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 l=this.editor.getShapeUtil(a);if(!this.canInteractWithShapeInReadOnly(a))return;if(n.handle==="right"||n.handle==="left"||n.handle==="top"||n.handle==="bottom"){const c=(r=l.onDoubleClickEdge)==null?void 0:r.call(l,a);if(c){this.editor.mark("double click edge"),this.editor.updateShapes([c]),Ke(this.editor,[a.id]);return}}if(l.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,l=this.editor.getShapeUtil(a);if(a.type!=="video"&&a.type!=="embed"&&this.editor.getInstanceState().isReadonly)break;if(l.onDoubleClick){const c=(o=l.onDoubleClick)==null?void 0:o.call(l,a);if(c){this.editor.updateShapes([c]);return}else if(l.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:l}=n,c=this.editor.getShapeUtil(a),u=(i=c.onDoubleClickHandle)==null?void 0:i.call(c,a,l);u?this.editor.updateShapes([u]):this.shouldStartEditingShape(a)&&this.startEditingShape(a,n,!0)}}});g(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:this.editor.options.hitTestMargin/this.editor.getZoomLevel(),hitInside:!1,hitLabels:!0,hitLocked:!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))&&LI(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.findShapeAncestor(s,i=>r.includes(i.id))&&(this.editor.mark("selecting shape"),this.editor.setSelectedShapes([s.id]));break}}});g(this,"onCancel",()=>{this.editor.getFocusedGroupId()!==this.editor.getCurrentPageId()&&this.editor.getSelectedShapeIds().length>0?this.editor.popFocusedGroupId():(this.editor.mark("clearing selection"),this.editor.selectNone())});g(this,"onKeyDown",n=>{switch(n.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!1);return}}if(xt.editOnType.get()&&!tZ.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}}});g(this,"onKeyRepeat",n=>{switch(n.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!0);break}}});g(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}RI(this.editor)&&this.parent.transition("crop",n);break}}});g(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"),xf(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&&sr(r,o.vertices))return!0}return!1}handleDoubleClickOnCanvas(n){if(this.editor.getInstanceState().isReadonly)return;this.editor.mark("creating text shape");const r=$e(),{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 b(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 b(0,0)))return;n||this.editor.mark("nudge shapes");const{gridSize:i}=this.editor.getDocumentSettings(),a=this.editor.getInstanceState().isGridMode?o?i*sZ:i:o?rZ:oZ,l=this.editor.getSelectedShapeIds();this.editor.nudgeShapes(l,s.mul(a)),Ke(this.editor,l)}canInteractWithShapeInReadOnly(n){return!!(!this.editor.getInstanceState().isReadonly||this.editor.getShapeUtil(n).canEditInReadOnly(n))}},g(oS,"id","idle"),oS);const rZ=10,oZ=1,sZ=5;function LI(e,t){const n=e.getSelectionRotatedPageBounds();if(!n)return!1;const r=e.getSelectionRotation();return r?sr(t,n.corners.map(o=>b.RotWith(o,n.point,r))):n.containsPoint(t)}class lj extends oe{constructor(){super(...arguments);g(this,"shapeId","");g(this,"markId","");g(this,"wasAlreadySelected",!1);g(this,"didDrag",!1);g(this,"info",{});g(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=b.Sub(s.center,a),this.markId="label-drag start",this.editor.mark(this.markId),this.editor.setSelectedShapes([this.shapeId])});g(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})});g(this,"_labelDragOffset",new b(0,0));g(this,"onPointerMove",()=>{const{isDragging:n}=this.editor.inputs;if(!n)return;const r=this.editor.getShape(this.shapeId);if(!r)return;const o=fo(this.editor,r),s=this.editor.getShapeGeometry(r),i=s.children[0],a=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint),l=i.nearestPoint(b.Add(a,this._labelDragOffset));let c;if(o.isStraight){const u=b.Dist(o.start.point,o.end.point);c=1-b.Dist(o.end.point,l)/u}else{const{_center:u,measure:h,angleEnd:p,angleStart:f}=s.children[0];c=MS(h,f,p,u.angle(l))}isNaN(c)&&(c=.5),this.didDrag=!0,this.editor.updateShape({id:r.id,type:r.type,props:{labelPosition:c}})});g(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")))});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.cancel()});g(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")}}g(lj,"id","pointing_arrow_label");class cj extends oe{constructor(){super(...arguments);g(this,"onEnter",()=>{const{inputs:n}=this.editor;n.shiftKey||this.editor.getSelectedShapeIds().length>0&&(this.editor.mark("selecting none"),this.editor.selectNone())});g(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.parent.transition("brushing",n)});g(this,"onPointerUp",()=>{Pf(this.editor),this.complete()});g(this,"onComplete",()=>{this.complete()});g(this,"onInterrupt",()=>{this.parent.transition("idle")})}complete(){this.parent.transition("idle")}}g(cj,"id","pointing_canvas");class uj extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"onEnter",n=>{this.info=n;const{shape:r}=n;if(this.editor.isShapeOfType(r,"arrow")){const o=$n(this.editor,r)[n.handle.id];o&&this.editor.setHintingShapes([o.toId])}this.editor.setCursor({type:"grabbing",rotation:0})});g(this,"onExit",()=>{this.editor.setHintingShapes([]),this.editor.setCursor({type:"default",rotation:0})});g(this,"onPointerUp",()=>{const{shape:n,handle:r}=this.info;if(this.editor.isShapeOfType(n,"note")){const{editor:o}=this,s=$I(o,n,r,!1);if(s){xf(o,s,!0);return}}this.parent.transition("idle",this.info)});g(this,"onPointerMove",()=>{const{editor:n}=this;n.inputs.isDragging&&this.startDraggingHandle()});g(this,"onLongPress",()=>{this.startDraggingHandle()});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.cancel()});g(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=$I(n,r,o,!0);if(s){const i=n.getPointInParentSpace(s,n.inputs.originPagePoint).sub(b.Rot(yg.clone().mul(r.props.scale),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:()=>{xf(n,s,!0)}});return}}this.parent.transition("dragging_handle",this.info)}cancel(){this.parent.transition("idle")}}g(uj,"id","pointing_handle");function $I(e,t,n,r){const o=e.getShapePageTransform(t.id),s=o.point(),i=o.rotation(),l=IA(e,s,i,t.props.growY,0,t.props.scale)[n.index];if(l)return kA(e,t,l,i,r)}class dj extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"onEnter",n=>{this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.info=n,this.updateCursor()});g(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})});g(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startRotating()});g(this,"onLongPress",()=>{this.startRotating()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.cancel()});g(this,"onInterrupt",()=>{this.cancel()})}updateCursor(){this.editor.setCursor({type:vl[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")}}g(dj,"id","pointing_rotate_handle");class hj extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"onEnter",n=>{this.info=n});g(this,"onPointerUp",n=>{Pf(this.editor),this.parent.transition("idle",n)});g(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.startTranslating(n)});g(this,"onLongPress",n=>{this.startTranslating(n)});g(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}});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.cancel()});g(this,"onInterrupt",()=>{this.cancel()})}startTranslating(n){this.editor.getInstanceState().isReadonly||this.parent.transition("translating",n)}cancel(){this.parent.transition("idle")}}g(hj,"id","pointing_selection");class pj extends oe{constructor(){super(...arguments);g(this,"hitShape",{});g(this,"hitShapeForPointerUp",{});g(this,"isDoubleClick",!1);g(this,"didSelectOnEnter",!1);g(this,"onEnter",n=>{const r=this.editor.getSelectedShapeIds(),o=this.editor.getSelectionRotatedPageBounds(),s=this.editor.getFocusedGroupId(),{inputs:{currentPagePoint:i,shiftKey:a,altKey:l}}=this.editor;this.hitShape=n.shape,this.isDoubleClick=!1;const c=this.editor.getOutermostSelectableShape(n.shape),u=this.editor.findShapeAncestor(c,h=>r.includes(h.id));if(this.editor.getShapeUtil(n.shape).onClick||c.id===s||r.includes(c.id)||u||r.length>1&&(o!=null&&o.containsPoint(i))){this.didSelectOnEnter=!1,this.hitShapeForPointerUp=c;return}this.didSelectOnEnter=!0,a&&!l?(this.editor.cancelDoubleClick(),r.includes(c.id)||(this.editor.mark("shift selecting shape"),this.editor.setSelectedShapes([...r,c.id]))):(this.editor.mark("selecting shape"),this.editor.setSelectedShapes([c.id]))});g(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,l=this.editor.getShapeAtPoint(i,{margin:this.editor.options.hitTestMargin/s,hitInside:!0,renderingOnly:!0})??this.hitShape,c=l?this.editor.getOutermostSelectableShape(l):this.hitShapeForPointerUp;if(c){const h=this.editor.getShapeUtil(c);if(h.onClick){const p=(u=h.onClick)==null?void 0:u.call(h,c);if(p){this.editor.mark("shape on click"),this.editor.updateShapes([p]),this.parent.transition("idle",n);return}}if(c.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 h=this.editor.getOutermostSelectableShape(l,p=>!r.includes(p.id));if(r.includes(h.id))if(a)this.editor.mark("deselecting on pointer up"),this.editor.deselect(c);else if(r.includes(c.id)){if(r.length===1){const p=this.editor.getShapeUtil(c).getGeometry(c),f=ij(p),S=f.length===1?f[0]:void 0;if(S){const y=this.editor.getPointInShapeSpace(c,i);if(S.bounds.containsPoint(y,0)&&S.hitTestPoint(y)){this.editor.run(()=>{this.editor.mark("editing on pointer up"),this.editor.select(c.id);const x=this.editor.getShapeUtil(c);this.editor.getInstanceState().isReadonly&&!x.canEditInReadOnly(c)||(this.editor.setEditingShape(c.id),this.editor.setCurrentTool("select.editing_shape"),this.isDoubleClick&&this.editor.emit("select-all-text",{shapeId:c.id}))});return}}}this.editor.mark("selecting on pointer up"),this.editor.select(c.id)}else this.editor.mark("selecting on pointer up"),this.editor.select(c);else if(a){const p=this.editor.getShapeAncestors(h);this.editor.mark("shift deselecting on pointer up"),this.editor.setSelectedShapes([...this.editor.getSelectedShapeIds().filter(f=>!p.find(S=>S.id===f)),h.id])}else this.editor.mark("selecting on pointer up"),this.editor.setSelectedShapes([h.id])}this.parent.transition("idle",n)});g(this,"onDoubleClick",()=>{this.isDoubleClick=!0});g(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.startTranslating(n)});g(this,"onLongPress",n=>{this.startTranslating(n)});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.cancel()});g(this,"onInterrupt",()=>{this.cancel()})}startTranslating(n){this.editor.getInstanceState().isReadonly||(this.editor.focus(),this.parent.transition("translating",n))}cancel(){this.parent.transition("idle")}}g(pj,"id","pointing_shape");class fj extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"markId","");g(this,"didHoldCommand",!1);g(this,"creationCursorOffset",{x:0,y:0});g(this,"snapshot",{});g(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.setCursor({type:"cross",rotation:0})):(this.markId="starting resizing",this.editor.mark(this.markId)),this.handleResizeStart(),this.updateShapes()});g(this,"onTick",({elapsed:n})=>{const{editor:r}=this;r.edgeScrollManager.updateEdgeScrolling(n)});g(this,"onPointerMove",()=>{this.updateShapes()});g(this,"onKeyDown",()=>{this.updateShapes()});g(this,"onKeyUp",()=>{this.updateShapes()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onComplete",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0}),this.editor.snaps.clearIndicators()});g(this,"_createSnapshot",()=>{const n=this.editor.getSelectedShapeIds(),r=this.editor.getSelectionRotation(),{inputs:{originPagePoint:o}}=this.editor,s=this.editor.getSelectionRotatedPageBounds(),i=b.RotWith(s.getHandlePoint(this.info.handle),s.point,r),a=b.Sub(o,i),l=new Map,c=[];n.forEach(h=>{const p=this.editor.getShape(h);if(p){if(p.type==="frame"&&c.push({id:h,children:ye(this.editor.getSortedChildIdsForParent(p).map(f=>this.editor.getShape(f)))}),l.set(p.id,this._createShapeSnapshot(p)),this.editor.isShapeOfType(p,"frame")&&n.length===1)return;this.editor.visitDescendants(p.id,f=>{const S=this.editor.getShape(f);if(S&&(l.set(S.id,this._createShapeSnapshot(S)),this.editor.isShapeOfType(S,"frame")))return!1})}});const u=![...l.values()].some(h=>!r2(h.pageRotation,r)||h.isAspectRatioLocked);return{shapeSnapshots:l,selectionBounds:s,cursorHandleOffset:a,selectionRotation:r,selectedShapeIds:n,canShapesDeform:u,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:c}});g(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:se.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(Ke(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 l;const s=this.editor.getShape(o.id),i=this.editor.getShapeUtil(o),a=(l=i.onResizeEnd)==null?void 0:l.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:l,selectionRotation:c,canShapesDeform:u}=this.snapshot;let h=r||!u;if(s.size===1){const k=[...s.values()][0];this.editor.isShapeOfType(k.shape,"text")&&(h=!(this.info.handle==="left"||this.info.handle==="right"))}const{ctrlKey:p}=this.editor.inputs,f=this.editor.inputs.currentPagePoint.clone().sub(a).sub(this.creationCursorOffset),S=this.editor.inputs.originPagePoint.clone().sub(a);if(this.editor.getInstanceState().isGridMode&&!p){const{gridSize:k}=this.editor.getDocumentSettings();f.snapToGrid(k)}const y=this.info.handle,x=NI(y,Math.PI);if(this.editor.snaps.clearIndicators(),(this.editor.user.getIsSnapMode()?!p:p)&&c%Ve===0){const{nudge:k}=this.editor.snaps.shapeBounds.snapResizeShapes({dragDelta:b.Sub(f,S),initialSelectionPageBounds:this.snapshot.initialSelectionPageBounds,handle:NI(y,c),isAspectRatioLocked:h,isResizingFromCenter:n});f.add(k)}const v=b.RotWith(n?i.center:i.getHandlePoint(x),i.point,c),w=b.Sub(f,v).rot(-c),C=b.Sub(S,v).rot(-c),E=b.DivV(w,C);Number.isFinite(E.x)||(E.x=1),Number.isFinite(E.y)||(E.y=1);const _=y==="top"||y==="bottom",I=y==="left"||y==="right";h?I?E.y=Math.abs(E.x):_?E.x=Math.abs(E.y):Math.abs(E.x)>Math.abs(E.y)?E.y=Math.abs(E.x)*(E.y<0?-1:1):E.x=Math.abs(E.y)*(E.x<0?-1:1):(_&&(E.x=1),I&&(E.y=1)),this.info.isCreating||this.updateCursor({dragHandle:y,isFlippedX:E.x<0,isFlippedY:E.y<0,rotation:c});for(const k of s.keys()){const T=s.get(k);this.editor.resizeShape(k,E,{initialShape:T.shape,initialBounds:T.bounds,initialPageTransform:T.pageTransform,dragHandle:y,mode:l.length===1&&k===l[0]?"resize_bounds":"scale_shape",scaleOrigin:v,isAspectRatioLocked:h,scaleAxisRotation:c,skipStartAndEndCallbacks:!0})}if(this.editor.inputs.ctrlKey){this.didHoldCommand=!0;for(const{id:k,children:T}of o){if(!T.length)continue;const M=s.get(k).shape,D=this.editor.getShape(k);if(!(M&&D))continue;const $=D.x-M.x,j=D.y-M.y,O=new b($,j).rot(-M.rotation);if(O.x!==0||O.y!==0)for(const R of T)this.editor.updateShape({id:R.id,type:R.type,x:R.x-O.x,y:R.y-O.y})}}else if(this.didHoldCommand){this.didHoldCommand=!1;for(const{children:k}of o)if(k.length)for(const T of k)this.editor.updateShape({id:T.id,type:T.type,x:T.x,y:T.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)}}g(fj,"id","resizing");const wy=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function NI(e,t){t=t%Le;const n=Math.round(t/(Me/4)),r=wy.indexOf(e);return wy[(r+n)%wy.length]}const FI=Math.PI/180;class gj extends oe{constructor(){super(...arguments);g(this,"snapshot",{});g(this,"info",{});g(this,"markId","");g(this,"onEnter",n=>{this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.markId="rotate start",this.editor.mark(this.markId);const r=XM({editor:this.editor});if(!r)return this.parent.transition("idle",this.info);this.snapshot=r;const o=this._getRotationFromPointerPosition({snapToNearestDegree:!1});Kh({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"}),this.editor.setCursor({type:vl[this.info.handle],rotation:o+this.snapshot.initialSelectionRotation})});g(this,"onExit",()=>{this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0),this.snapshot={}});g(this,"onPointerMove",()=>{this.update()});g(this,"onKeyDown",()=>{this.update()});g(this,"onKeyUp",()=>{this.update()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onComplete",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(this,"update",()=>{const n=this._getRotationFromPointerPosition({snapToNearestDegree:!1});Kh({editor:this.editor,delta:n,snapshot:this.snapshot,stage:"update"}),this.editor.setCursor({type:vl[this.info.handle],rotation:n+this.snapshot.initialSelectionRotation})});g(this,"cancel",()=>{this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)});g(this,"complete",()=>{Kh({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!0}),snapshot:this.snapshot,stage:"end"}),Ke(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:l}=this.snapshot;if(!o)return l;const u=o.center.clone().rotWith(o.point,r).angle(i)-a;let h=l+u;if(s)h=Bp(h,24);else if(n&&(h=Math.round(h/FI)*FI,this.editor.getInstanceState().isCoarsePointer)){const p=Bp(h,4),f=Ah(h,p);Math.abs(f)<w9(5)&&(h=p)}return h-l}}g(gj,"id","rotating");class mj extends oe{constructor(){super(...arguments);g(this,"hits",new Set);g(this,"size",0);g(this,"scribbleId","id");g(this,"initialSelectedShapeIds",new Set);g(this,"newlySelectedShapeIds",new Set);g(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})});g(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});g(this,"onPointerMove",()=>{this.updateScribbleSelection(!0)});g(this,"onPointerUp",()=>{this.complete()});g(this,"onKeyDown",()=>{this.updateScribbleSelection(!1)});g(this,"onKeyUp",()=>{this.editor.inputs.altKey?this.updateScribbleSelection(!1):this.parent.transition("brushing")});g(this,"onCancel",()=>{this.cancel()});g(this,"onComplete",()=>{this.complete()});g(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:l}}=this.editor,{newlySelectedShapeIds:c,initialSelectedShapeIds:u}=this;n&&this.pushPointToScribble();const h=o;let p,f,S,y;const x=0;for(let w=0,C=h.length;w<C;w++){if(p=h[w],r.isShapeOfType(p,"group")||c.has(p.id)||r.isShapeOrAncestorLocked(p)||(f=r.getShapeGeometry(p),r.isShapeOfType(p,"frame")&&f.bounds.containsPoint(r.getPointInShapeSpace(p,i))))continue;const E=r.getShapePageTransform(p);if(!f||!E)continue;const _=E.clone().invert();S=_.applyToPoint(a),y=_.applyToPoint(l);const{bounds:I}=f;if(!(I.minX-x>Math.max(S.x,y.x)||I.minY-x>Math.max(S.y,y.y)||I.maxX+x<Math.min(S.x,y.x)||I.maxY+x<Math.min(S.y,y.y))&&f.hitTestLineSegment(S,y,x)){const k=this.editor.getOutermostSelectableShape(p),T=this.editor.getShapeMask(k.id);if(T&&nw(a,l,T)!==null&&!sr(l,T))continue;c.add(k.id)}}const m=r.getSelectedShapeIds(),v=new Set(s?[...c,...u]:[...c]);(m.length!==v.size||m.some(w=>!v.has(w)))&&this.editor.setSelectedShapes(Array.from(v))}complete(){this.updateScribbleSelection(!0),this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds]),this.parent.transition("idle")}}g(mj,"id","scribble_brushing");const iZ=20,aZ=100;class lZ{constructor(t){g(this,"prevDroppingShapeId",null);g(this,"droppingNodeTimer",null);g(this,"first",!0);g(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,iZ,n):this.editor.inputs.pointerVelocity.len()>.5&&(clearTimeout(this.droppingNodeTimer),this.setDragTimer(t,aZ,n))}setDragTimer(t,n,r){this.droppingNodeTimer=this.editor.timers.setTimeout(()=>{this.editor.run(()=>{this.handleDrag(this.editor.inputs.currentPagePoint,t,r)}),this.droppingNodeTimer=null},n)}handleDrag(t,n,r){var l,c,u,h,p;n=ye(n.map(f=>this.editor.getShape(f.id)));const o=((l=this.editor.getDroppingOverShape(t,n))==null?void 0:l.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=(c=this.editor.getShapeUtil(i)).onDragShapesOut)==null||u.call(c,i,n)),a&&((p=(h=this.editor.getShapeUtil(a)).onDragShapesOver)==null||p.call(h,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&&bA(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&&clearTimeout(this.droppingNodeTimer),this.droppingNodeTimer=null,this.editor.setHintingShapes([]),this.first=!0}}class yj extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"selectionSnapshot",{});g(this,"snapshot",{});g(this,"markId","");g(this,"isCloning",!1);g(this,"isCreating",!1);g(this,"onCreate",()=>{});g(this,"dragAndDropManager",new lZ(this.editor));g(this,"onEnter",n=>{var s;const{isCreating:r=!1,onCreate:o=()=>{}}=n;if(!((s=this.editor.getSelectedShapeIds())!=null&&s.length)){this.parent.transition("idle");return}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=zI(this.editor),!this.isCreating&&this.editor.inputs.altKey){this.startCloning();return}this.snapshot=this.selectionSnapshot,this.handleStart(),this.updateShapes()});g(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()});g(this,"onTick",({elapsed:n})=>{const{editor:r}=this;this.dragAndDropManager.updateDroppingNode(this.snapshot.movingShapes,this.updateParentTransforms),r.edgeScrollManager.updateEdgeScrolling(n)});g(this,"onPointerMove",()=>{this.updateShapes()});g(this,"onKeyDown",()=>{if(this.editor.inputs.altKey&&!this.isCloning){this.startCloning();return}this.updateShapes()});g(this,"onKeyUp",()=>{if(!this.editor.inputs.altKey&&this.isCloning){this.stopCloning();return}this.updateShapes()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onComplete",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()});g(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=An(s.parentId)?null:se.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=zI(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),Ke(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=b.Average(n.map(i=>this.editor.getShapePageTransform(i.id).point())),s=b.Sub(o,this.selectionSnapshot.averagePagePoint);b.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 l;const s=this.editor.getShape(o.id),i=this.editor.getShapeUtil(o),a=(l=i.onTranslateEnd)==null?void 0:l.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),cZ({editor:this.editor,snapshot:n});const{movingShapes:r}=n,o=[];r.forEach(s=>{var c;const i=this.editor.getShape(s.id),a=this.editor.getShapeUtil(s),l=(c=a.onTranslate)==null?void 0:c.call(a,s,i);l&&o.push(l)}),o.length>0&&this.editor.updateShapes(o)}}g(yj,"id","translating");function zI(e){var h;const t=[],n=[],r=e.getSelectedShapeIds(),o=ye(r.map(p=>{const f=e.getShape(p);if(!f)return null;t.push(f);const S=e.getShapePageTransform(p),y=S.point(),x=S.rotation();n.push(y);const m=Jo.isId(f.parentId)?null:se.Inverse(e.getShapePageTransform(f.parentId));return{shape:f,pagePoint:y,pageRotation:x,parentTransform:m}})),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,S)=>({id:"selection:"+S,x:f.x,y:f.y})))}let a,l;const{originPagePoint:c}=e.inputs,u=o.filter(p=>e.isShapeOfType(p.shape,"note")&&e.isPointInShape(p.shape,c));if(u.length!==0)if(u.length===1)l=u[0];else{const p=e.getCurrentPageShapesSorted();l=(h=u.map(f=>({snapshot:f,index:p.findIndex(S=>S.id===f.shape.id)})).sort((f,S)=>S.index-f.index)[0])==null?void 0:h.snapshot}return l&&(a=EA(e,l.pageRotation,l.shape.props.scale,l.shape.props.growY??0)),{averagePagePoint:b.Average(n),movingShapes:t,shapeSnapshots:o,initialPageBounds:e.getSelectionPageBounds(),initialSnapPoints:i,noteAdjacentPositions:a,noteSnapshot:l}}function cZ({editor:e,snapshot:t}){const{inputs:n}=e,{noteSnapshot:r,noteAdjacentPositions:o,initialPageBounds:s,initialSnapPoints:i,shapeSnapshots:a,averagePagePoint:l}=t,c=e.getInstanceState().isGridMode,u=e.getDocumentSettings().gridSize,h=b.Sub(n.currentPagePoint,n.originPagePoint),p=e.inputs.shiftKey?Math.abs(h.x)<Math.abs(h.y)?"x":"y":null;if(p==="x"?h.x=0:p==="y"&&(h.y=0),e.snaps.clearIndicators(),(e.user.getIsSnapMode()?!n.ctrlKey:n.ctrlKey)&&e.inputs.pointerVelocity.len()<.5){const{nudge:x}=e.snaps.shapeBounds.snapTranslateShapes({dragDelta:h,initialSelectionPageBounds:s,lockedAxis:p,initialSelectionSnapPoints:i});h.add(x)}else if(r&&o){const{scale:x}=r.shape.props,m=r.pagePoint.clone().add(h).add(yg.clone().mul(x).rot(r.pageRotation));let v=CA/e.getZoomLevel(),w=new b(0,0);for(const C of o){const E=b.Sub(m,C),_=E.len();_<v&&(v=_,w=E)}h.sub(w)}const S=b.Add(l,h);c&&!n.ctrlKey&&S.snapToGrid(u);const y=b.Sub(S,l);e.updateShapes(ye(a.map(({shape:x,pagePoint:m,parentTransform:v})=>{const w=b.Add(m,y),C=v?se.applyToPoint(v,w):w;return{id:x.id,type:x.type,x:C.x,y:C.y}})))}class Oc extends oe{constructor(){super(...arguments);g(this,"reactor");g(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})});g(this,"onEnter",()=>{this.reactor=ra("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(n){typeof process<"u",console.error(n)}})});g(this,"onExit",()=>{var n;(n=this.reactor)==null||n.call(this),this.editor.getCurrentPageState().editingShapeId&&this.editor.setEditingShape(null)})}}g(Oc,"id","select"),g(Oc,"initial","idle"),g(Oc,"isLockable",!1),g(Oc,"children",()=>[fp,Pw,nZ,cj,pj,yj,JA,mj,Cw,hj,ej,aj,fj,gj,dj,lj,uj,sj]);class Sj extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"onEnter",n=>{this.info=n});g(this,"onPointerDown",()=>{this.parent.transition("pointing",this.info)})}}g(Sj,"id","idle");class vj extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"onEnter",n=>{this.info=n});g(this,"onPointerUp",()=>{this.complete()});g(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.parent.transition("zoom_brushing",this.info)});g(this,"onCancel",()=>{this.cancel()})}complete(){const{currentScreenPoint:n}=this.editor.inputs;this.editor.inputs.altKey?this.editor.zoomOut(n,{animation:{duration:220}}):this.editor.zoomIn(n,{animation:{duration:220}}),this.parent.transition("idle",this.info)}cancel(){this.parent.transition("idle",this.info)}}g(vj,"id","pointing");class xj extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"zoomBrush",new Q);g(this,"onEnter",n=>{this.info=n,this.update()});g(this,"onExit",()=>{this.editor.updateInstanceState({zoomBrush:null})});g(this,"onPointerMove",()=>{this.update()});g(this,"onPointerUp",()=>{this.complete()});g(this,"onCancel",()=>{this.cancel()})}update(){const{inputs:{originPagePoint:n,currentPagePoint:r}}=this.editor;this.zoomBrush.setTo(Q.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,{animation:{duration:220}}):this.editor.zoomIn(o,{animation:{duration:220}})}else{const o=this.editor.inputs.altKey?this.editor.getZoomLevel()/2:void 0;this.editor.zoomToBounds(n,{targetZoom:o,animation:{duration:220}})}this.parent.transition("idle",this.info)}}g(xj,"id","zoom_brushing");class Dc extends oe{constructor(){super(...arguments);g(this,"info",{});g(this,"onEnter",n=>{this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.updateCursor()});g(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({zoomBrush:null,cursor:{type:"default",rotation:0}}),this.parent.setCurrentToolIdMask(void 0)});g(this,"onKeyDown",()=>{this.updateCursor()});g(this,"onKeyUp",n=>{this.updateCursor(),n.code==="KeyZ"&&this.complete()});g(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.setCursor({type:"zoom-out",rotation:0}):this.editor.setCursor({type:"zoom-in",rotation:0})}}g(Dc,"id","zoom"),g(Dc,"initial","idle"),g(Dc,"children",()=>[Sj,xj,vj]),g(Dc,"isLockable",!1);const uZ=[Mc,Ac,jc,Dc,Oc];function re(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 dZ(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function bg(...e){return t=>e.forEach(n=>dZ(n,t))}function qe(...e){return P.useCallback(bg(...e),e)}function hZ(e,t){const n=P.createContext(t);function r(s){const{children:i,...a}=s,l=P.useMemo(()=>a,Object.values(a));return d.jsx(n.Provider,{value:l,children:i})}function o(s){const i=P.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return r.displayName=e+"Provider",[r,o]}function Ao(e,t=[]){let n=[];function r(s,i){const a=P.createContext(i),l=n.length;n=[...n,i];function c(h){const{scope:p,children:f,...S}=h,y=(p==null?void 0:p[e][l])||a,x=P.useMemo(()=>S,Object.values(S));return d.jsx(y.Provider,{value:x,children:f})}function u(h,p){const f=(p==null?void 0:p[e][l])||a,S=P.useContext(f);if(S)return S;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,u]}const o=()=>{const s=n.map(i=>P.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return P.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,pZ(o,...t)]}function pZ(...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:l,scopeName:c})=>{const h=l(s)[`__scope${c}`];return{...a,...h}},{});return P.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Qs=globalThis!=null&&globalThis.document?P.useLayoutEffect:()=>{},fZ=F3.useId||(()=>{}),gZ=0;function Zo(e){const[t,n]=P.useState(fZ());return Qs(()=>{e||n(r=>r??String(gZ++))},[e]),e||(t?`radix-${t}`:"")}function Xt(e){const t=P.useRef(e);return P.useEffect(()=>{t.current=e}),P.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function ui({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=mZ({defaultProp:t,onChange:n}),s=e!==void 0,i=s?e:r,a=Xt(n),l=P.useCallback(c=>{if(s){const h=typeof c=="function"?c(e):c;h!==e&&a(h)}else o(c)},[s,e,o,a]);return[i,l]}function mZ({defaultProp:e,onChange:t}){const n=P.useState(e),[r]=n,o=P.useRef(r),s=Xt(t);return P.useEffect(()=>{o.current!==r&&(s(r),o.current=r)},[r,o,s]),n}var Yi=P.forwardRef((e,t)=>{const{children:n,...r}=e,o=P.Children.toArray(n),s=o.find(SZ);if(s){const i=s.props.children,a=o.map(l=>l===s?P.Children.count(i)>1?P.Children.only(null):P.isValidElement(i)?i.props.children:null:l);return d.jsx(Hv,{...r,ref:t,children:P.isValidElement(i)?P.cloneElement(i,void 0,a):null})}return d.jsx(Hv,{...r,ref:t,children:n})});Yi.displayName="Slot";var Hv=P.forwardRef((e,t)=>{const{children:n,...r}=e;if(P.isValidElement(n)){const o=xZ(n);return P.cloneElement(n,{...vZ(r,n.props),ref:t?bg(t,o):o})}return P.Children.count(n)>1?P.Children.only(null):null});Hv.displayName="SlotClone";var yZ=({children:e})=>d.jsx(d.Fragment,{children:e});function SZ(e){return P.isValidElement(e)&&e.type===yZ}function vZ(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 xZ(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var wZ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],_e=wZ.reduce((e,t)=>{const n=P.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Yi:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Iw(e,t){e&&ia.flushSync(()=>e.dispatchEvent(t))}function bZ(e,t=globalThis==null?void 0:globalThis.document){const n=Xt(e);P.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var PZ="DismissableLayer",Kv="dismissableLayer.update",CZ="dismissableLayer.pointerDownOutside",IZ="dismissableLayer.focusOutside",BI,wj=P.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),nd=P.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=P.useContext(wj),[u,h]=P.useState(null),p=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=P.useState({}),S=qe(t,I=>h(I)),y=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),m=y.indexOf(x),v=u?y.indexOf(u):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,C=v>=m,E=kZ(I=>{const k=I.target,T=[...c.branches].some(M=>M.contains(k));!C||T||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},p),_=_Z(I=>{const k=I.target;[...c.branches].some(M=>M.contains(k))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},p);return bZ(I=>{v===c.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},p),P.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(BI=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),UI(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=BI)}},[u,p,n,c]),P.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),UI())},[u,c]),P.useEffect(()=>{const I=()=>f({});return document.addEventListener(Kv,I),()=>document.removeEventListener(Kv,I)},[]),d.jsx(_e.div,{...l,ref:S,style:{pointerEvents:w?C?"auto":"none":void 0,...e.style},onFocusCapture:re(e.onFocusCapture,_.onFocusCapture),onBlurCapture:re(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:re(e.onPointerDownCapture,E.onPointerDownCapture)})});nd.displayName=PZ;var EZ="DismissableLayerBranch",bj=P.forwardRef((e,t)=>{const n=P.useContext(wj),r=P.useRef(null),o=qe(t,r);return P.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),d.jsx(_e.div,{...e,ref:o})});bj.displayName=EZ;function kZ(e,t=globalThis==null?void 0:globalThis.document){const n=Xt(e),r=P.useRef(!1),o=P.useRef(()=>{});return P.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Pj(CZ,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}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 _Z(e,t=globalThis==null?void 0:globalThis.document){const n=Xt(e),r=P.useRef(!1);return P.useEffect(()=>{const o=s=>{s.target&&!r.current&&Pj(IZ,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 UI(){const e=new CustomEvent(Kv);document.dispatchEvent(e)}function Pj(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?Iw(o,s):o.dispatchEvent(s)}var TZ=nd,MZ=bj,by="focusScope.autoFocusOnMount",Py="focusScope.autoFocusOnUnmount",HI={bubbles:!1,cancelable:!0},AZ="FocusScope",Pg=P.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=P.useState(null),c=Xt(o),u=Xt(s),h=P.useRef(null),p=qe(t,y=>l(y)),f=P.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;P.useEffect(()=>{if(r){let y=function(w){if(f.paused||!a)return;const C=w.target;a.contains(C)?h.current=C:Cs(h.current,{select:!0})},x=function(w){if(f.paused||!a)return;const C=w.relatedTarget;C!==null&&(a.contains(C)||Cs(h.current,{select:!0}))},m=function(w){if(document.activeElement===document.body)for(const E of w)E.removedNodes.length>0&&Cs(a)};document.addEventListener("focusin",y),document.addEventListener("focusout",x);const v=new MutationObserver(m);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",x),v.disconnect()}}},[r,a,f.paused]),P.useEffect(()=>{if(a){WI.add(f);const y=document.activeElement;if(!a.contains(y)){const m=new CustomEvent(by,HI);a.addEventListener(by,c),a.dispatchEvent(m),m.defaultPrevented||(jZ($Z(Cj(a)),{select:!0}),document.activeElement===y&&Cs(a))}return()=>{a.removeEventListener(by,c),setTimeout(()=>{const m=new CustomEvent(Py,HI);a.addEventListener(Py,u),a.dispatchEvent(m),m.defaultPrevented||Cs(y??document.body,{select:!0}),a.removeEventListener(Py,u),WI.remove(f)},0)}}},[a,c,u,f]);const S=P.useCallback(y=>{if(!n&&!r||f.paused)return;const x=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,m=document.activeElement;if(x&&m){const v=y.currentTarget,[w,C]=OZ(v);w&&C?!y.shiftKey&&m===C?(y.preventDefault(),n&&Cs(w,{select:!0})):y.shiftKey&&m===w&&(y.preventDefault(),n&&Cs(C,{select:!0})):m===v&&y.preventDefault()}},[n,r,f.paused]);return d.jsx(_e.div,{tabIndex:-1,...i,ref:p,onKeyDown:S})});Pg.displayName=AZ;function jZ(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Cs(r,{select:t}),document.activeElement!==n)return}function OZ(e){const t=Cj(e),n=KI(t,e),r=KI(t.reverse(),e);return[n,r]}function Cj(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 KI(e,t){for(const n of e)if(!DZ(n,{upTo:t}))return n}function DZ(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 RZ(e){return e instanceof HTMLInputElement&&"select"in e}function Cs(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&RZ(e)&&t&&e.select()}}var WI=LZ();function LZ(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=GI(e,t),e.unshift(t)},remove(t){var n;e=GI(e,t),(n=e[0])==null||n.resume()}}}function GI(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function $Z(e){return e.filter(t=>t.tagName!=="A")}var NZ="Portal",rd=P.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=P.useState(!1);Qs(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?YW.createPortal(d.jsx(_e.div,{...r,ref:t}),i):null});rd.displayName=NZ;function FZ(e,t){return P.useReducer((n,r)=>t[n][r]??n,e)}var Qr=e=>{const{present:t,children:n}=e,r=zZ(t),o=typeof n=="function"?n({present:r.isPresent}):P.Children.only(n),s=qe(r.ref,BZ(o));return typeof n=="function"||r.isPresent?P.cloneElement(o,{ref:s}):null};Qr.displayName="Presence";function zZ(e){const[t,n]=P.useState(),r=P.useRef({}),o=P.useRef(e),s=P.useRef("none"),i=e?"mounted":"unmounted",[a,l]=FZ(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return P.useEffect(()=>{const c=uh(r.current);s.current=a==="mounted"?c:"none"},[a]),Qs(()=>{const c=r.current,u=o.current;if(u!==e){const p=s.current,f=uh(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&p!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Qs(()=>{if(t){const c=h=>{const f=uh(r.current).includes(h.animationName);h.target===t&&f&&ia.flushSync(()=>l("ANIMATION_END"))},u=h=>{h.target===t&&(s.current=uh(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",c),t.addEventListener("animationend",c),()=>{t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",c),t.removeEventListener("animationend",c)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:P.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function uh(e){return(e==null?void 0:e.animationName)||"none"}function BZ(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Cy=0;function Ew(){P.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??VI()),document.body.insertAdjacentElement("beforeend",e[1]??VI()),Cy++,()=>{Cy===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Cy--}},[])}function VI(){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 uo=function(){return uo=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},uo.apply(this,arguments)};function Ij(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 UZ(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 gp="right-scroll-bar-position",mp="width-before-scroll-bar",HZ="with-scroll-bars-hidden",KZ="--removed-body-scroll-bar-size";function Iy(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function WZ(e,t){var n=P.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 GZ=typeof window<"u"?P.useLayoutEffect:P.useEffect,YI=new WeakMap;function VZ(e,t){var n=WZ(null,function(r){return e.forEach(function(o){return Iy(o,r)})});return GZ(function(){var r=YI.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Iy(a,null)}),s.forEach(function(a){o.has(a)||Iy(a,i)})}YI.set(n,e)},[e]),n}function YZ(e){return e}function XZ(e,t){t===void 0&&(t=YZ);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 l=function(){var u=i;i=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){i.push(u),c()},filter:function(u){return i=i.filter(u),n}}}};return o}function qZ(e){e===void 0&&(e={});var t=XZ(null);return t.options=uo({async:!0,ssr:!1},e),t}var Ej=function(e){var t=e.sideCar,n=Ij(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 P.createElement(r,uo({},n))};Ej.isSideCarExport=!0;function ZZ(e,t){return e.useMedium(t),Ej}var kj=qZ(),Ey=function(){},Cg=P.forwardRef(function(e,t){var n=P.useRef(null),r=P.useState({onScrollCapture:Ey,onWheelCapture:Ey,onTouchMoveCapture:Ey}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,h=e.shards,p=e.sideCar,f=e.noIsolation,S=e.inert,y=e.allowPinchZoom,x=e.as,m=x===void 0?"div":x,v=e.gapMode,w=Ij(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=p,E=VZ([n,t]),_=uo(uo({},w),o);return P.createElement(P.Fragment,null,u&&P.createElement(C,{sideCar:kj,removeScrollBar:c,shards:h,noIsolation:f,inert:S,setCallbacks:s,allowPinchZoom:!!y,lockRef:n,gapMode:v}),i?P.cloneElement(P.Children.only(a),uo(uo({},_),{ref:E})):P.createElement(m,uo({},_,{className:l,ref:E}),a))});Cg.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Cg.classNames={fullWidth:mp,zeroRight:gp};var QZ=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function JZ(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=QZ();return t&&e.setAttribute("nonce",t),e}function eQ(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function tQ(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var nQ=function(){var e=0,t=null;return{add:function(n){e==0&&(t=JZ())&&(eQ(t,n),tQ(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},rQ=function(){var e=nQ();return function(t,n){P.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},_j=function(){var e=rQ(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},oQ={left:0,top:0,right:0,gap:0},ky=function(e){return parseInt(e||"",10)||0},sQ=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[ky(n),ky(r),ky(o)]},iQ=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return oQ;var t=sQ(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])}},aQ=_j(),rl="data-scroll-locked",lQ=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
221
|
+
.`.concat(HZ,` {
|
|
222
|
+
overflow: hidden `).concat(r,`;
|
|
223
|
+
padding-right: `).concat(a,"px ").concat(r,`;
|
|
224
|
+
}
|
|
225
|
+
body[`).concat(rl,`] {
|
|
226
|
+
overflow: hidden `).concat(r,`;
|
|
227
|
+
overscroll-behavior: contain;
|
|
228
|
+
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
229
|
+
padding-left: `.concat(o,`px;
|
|
230
|
+
padding-top: `).concat(s,`px;
|
|
231
|
+
padding-right: `).concat(i,`px;
|
|
232
|
+
margin-left:0;
|
|
233
|
+
margin-top:0;
|
|
234
|
+
margin-right: `).concat(a,"px ").concat(r,`;
|
|
235
|
+
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.`).concat(gp,` {
|
|
239
|
+
right: `).concat(a,"px ").concat(r,`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.`).concat(mp,` {
|
|
243
|
+
margin-right: `).concat(a,"px ").concat(r,`;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.`).concat(gp," .").concat(gp,` {
|
|
247
|
+
right: 0 `).concat(r,`;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.`).concat(mp," .").concat(mp,` {
|
|
251
|
+
margin-right: 0 `).concat(r,`;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
body[`).concat(rl,`] {
|
|
255
|
+
`).concat(KZ,": ").concat(a,`px;
|
|
256
|
+
}
|
|
257
|
+
`)},XI=function(){var e=parseInt(document.body.getAttribute(rl)||"0",10);return isFinite(e)?e:0},cQ=function(){P.useEffect(function(){return document.body.setAttribute(rl,(XI()+1).toString()),function(){var e=XI()-1;e<=0?document.body.removeAttribute(rl):document.body.setAttribute(rl,e.toString())}},[])},uQ=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;cQ();var s=P.useMemo(function(){return iQ(o)},[o]);return P.createElement(aQ,{styles:lQ(s,!t,o,n?"":"!important")})},Wv=!1;if(typeof window<"u")try{var dh=Object.defineProperty({},"passive",{get:function(){return Wv=!0,!0}});window.addEventListener("test",dh,dh),window.removeEventListener("test",dh,dh)}catch{Wv=!1}var Sa=Wv?{passive:!1}:!1,dQ=function(e){return e.tagName==="TEXTAREA"},Tj=function(e,t){var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!dQ(e)&&n[t]==="visible")},hQ=function(e){return Tj(e,"overflowY")},pQ=function(e){return Tj(e,"overflowX")},qI=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Mj(e,r);if(o){var s=Aj(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},fQ=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},gQ=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Mj=function(e,t){return e==="v"?hQ(t):pQ(t)},Aj=function(e,t){return e==="v"?fQ(t):gQ(t)},mQ=function(e,t){return e==="h"&&t==="rtl"?-1:1},yQ=function(e,t,n,r,o){var s=mQ(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,u=i>0,h=0,p=0;do{var f=Aj(e,a),S=f[0],y=f[1],x=f[2],m=y-x-s*S;(S||m)&&Mj(e,a)&&(h+=m,p+=S),a instanceof ShadowRoot?a=a.host:a=a.parentNode}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&(Math.abs(h)<1||!o)||!u&&(Math.abs(p)<1||!o))&&(c=!0),c},hh=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},ZI=function(e){return[e.deltaX,e.deltaY]},QI=function(e){return e&&"current"in e?e.current:e},SQ=function(e,t){return e[0]===t[0]&&e[1]===t[1]},vQ=function(e){return`
|
|
258
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
259
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
260
|
+
`)},xQ=0,va=[];function wQ(e){var t=P.useRef([]),n=P.useRef([0,0]),r=P.useRef(),o=P.useState(xQ++)[0],s=P.useState(_j)[0],i=P.useRef(e);P.useEffect(function(){i.current=e},[e]),P.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var y=UZ([e.lockRef.current],(e.shards||[]).map(QI),!0).filter(Boolean);return y.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),y.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=P.useCallback(function(y,x){if("touches"in y&&y.touches.length===2)return!i.current.allowPinchZoom;var m=hh(y),v=n.current,w="deltaX"in y?y.deltaX:v[0]-m[0],C="deltaY"in y?y.deltaY:v[1]-m[1],E,_=y.target,I=Math.abs(w)>Math.abs(C)?"h":"v";if("touches"in y&&I==="h"&&_.type==="range")return!1;var k=qI(I,_);if(!k)return!0;if(k?E=I:(E=I==="v"?"h":"v",k=qI(I,_)),!k)return!1;if(!r.current&&"changedTouches"in y&&(w||C)&&(r.current=E),!E)return!0;var T=r.current||E;return yQ(T,x,y,T==="h"?w:C,!0)},[]),l=P.useCallback(function(y){var x=y;if(!(!va.length||va[va.length-1]!==s)){var m="deltaY"in x?ZI(x):hh(x),v=t.current.filter(function(E){return E.name===x.type&&(E.target===x.target||x.target===E.shadowParent)&&SQ(E.delta,m)})[0];if(v&&v.should){x.cancelable&&x.preventDefault();return}if(!v){var w=(i.current.shards||[]).map(QI).filter(Boolean).filter(function(E){return E.contains(x.target)}),C=w.length>0?a(x,w[0]):!i.current.noIsolation;C&&x.cancelable&&x.preventDefault()}}},[]),c=P.useCallback(function(y,x,m,v){var w={name:y,delta:x,target:m,should:v,shadowParent:bQ(m)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(C){return C!==w})},1)},[]),u=P.useCallback(function(y){n.current=hh(y),r.current=void 0},[]),h=P.useCallback(function(y){c(y.type,ZI(y),y.target,a(y,e.lockRef.current))},[]),p=P.useCallback(function(y){c(y.type,hh(y),y.target,a(y,e.lockRef.current))},[]);P.useEffect(function(){return va.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:p}),document.addEventListener("wheel",l,Sa),document.addEventListener("touchmove",l,Sa),document.addEventListener("touchstart",u,Sa),function(){va=va.filter(function(y){return y!==s}),document.removeEventListener("wheel",l,Sa),document.removeEventListener("touchmove",l,Sa),document.removeEventListener("touchstart",u,Sa)}},[]);var f=e.removeScrollBar,S=e.inert;return P.createElement(P.Fragment,null,S?P.createElement(s,{styles:vQ(o)}):null,f?P.createElement(uQ,{gapMode:e.gapMode}):null)}function bQ(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const PQ=ZZ(kj,wQ);var Ig=P.forwardRef(function(e,t){return P.createElement(Cg,uo({},e,{ref:t,sideCar:PQ}))});Ig.classNames=Cg.classNames;var CQ=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},xa=new WeakMap,ph=new WeakMap,fh={},_y=0,jj=function(e){return e&&(e.host||jj(e.parentNode))},IQ=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=jj(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})},EQ=function(e,t,n,r){var o=IQ(t,Array.isArray(e)?e:[e]);fh[n]||(fh[n]=new WeakMap);var s=fh[n],i=[],a=new Set,l=new Set(o),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};o.forEach(c);var u=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(p){if(a.has(p))u(p);else try{var f=p.getAttribute(r),S=f!==null&&f!=="false",y=(xa.get(p)||0)+1,x=(s.get(p)||0)+1;xa.set(p,y),s.set(p,x),i.push(p),y===1&&S&&ph.set(p,!0),x===1&&p.setAttribute(n,"true"),S||p.setAttribute(r,"true")}catch(m){console.error("aria-hidden: cannot operate on ",p,m)}})};return u(t),a.clear(),_y++,function(){i.forEach(function(h){var p=xa.get(h)-1,f=s.get(h)-1;xa.set(h,p),s.set(h,f),p||(ph.has(h)||h.removeAttribute(r),ph.delete(h)),f||h.removeAttribute(n)}),_y--,_y||(xa=new WeakMap,xa=new WeakMap,ph=new WeakMap,fh={})}},kw=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=CQ(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),EQ(r,o,n,"aria-hidden")):function(){return null}},_w="Dialog",[Oj,Oae]=Ao(_w),[kQ,Jr]=Oj(_w),Dj=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=P.useRef(null),l=P.useRef(null),[c=!1,u]=ui({prop:r,defaultProp:o,onChange:s});return d.jsx(kQ,{scope:t,triggerRef:a,contentRef:l,contentId:Zo(),titleId:Zo(),descriptionId:Zo(),open:c,onOpenChange:u,onOpenToggle:P.useCallback(()=>u(h=>!h),[u]),modal:i,children:n})};Dj.displayName=_w;var Rj="DialogTrigger",_Q=P.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Jr(Rj,n),s=qe(t,o.triggerRef);return d.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Aw(o.open),...r,ref:s,onClick:re(e.onClick,o.onOpenToggle)})});_Q.displayName=Rj;var Tw="DialogPortal",[TQ,Lj]=Oj(Tw,{forceMount:void 0}),$j=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Jr(Tw,t);return d.jsx(TQ,{scope:t,forceMount:n,children:P.Children.map(r,i=>d.jsx(Qr,{present:n||s.open,children:d.jsx(rd,{asChild:!0,container:o,children:i})}))})};$j.displayName=Tw;var Cf="DialogOverlay",Nj=P.forwardRef((e,t)=>{const n=Lj(Cf,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Jr(Cf,e.__scopeDialog);return s.modal?d.jsx(Qr,{present:r||s.open,children:d.jsx(MQ,{...o,ref:t})}):null});Nj.displayName=Cf;var MQ=P.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Jr(Cf,n);return d.jsx(Ig,{as:Yi,allowPinchZoom:!0,shards:[o.contentRef],children:d.jsx(_e.div,{"data-state":Aw(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Xi="DialogContent",Fj=P.forwardRef((e,t)=>{const n=Lj(Xi,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Jr(Xi,e.__scopeDialog);return d.jsx(Qr,{present:r||s.open,children:s.modal?d.jsx(AQ,{...o,ref:t}):d.jsx(jQ,{...o,ref:t})})});Fj.displayName=Xi;var AQ=P.forwardRef((e,t)=>{const n=Jr(Xi,e.__scopeDialog),r=P.useRef(null),o=qe(t,n.contentRef,r);return P.useEffect(()=>{const s=r.current;if(s)return kw(s)},[]),d.jsx(zj,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:re(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:re(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:re(e.onFocusOutside,s=>s.preventDefault())})}),jQ=P.forwardRef((e,t)=>{const n=Jr(Xi,e.__scopeDialog),r=P.useRef(!1),o=P.useRef(!1);return d.jsx(zj,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),zj=P.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Jr(Xi,n),l=P.useRef(null),c=qe(t,l);return Ew(),d.jsxs(d.Fragment,{children:[d.jsx(Pg,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(nd,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Aw(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(DQ,{titleId:a.titleId}),d.jsx(LQ,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Mw="DialogTitle",Bj=P.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Jr(Mw,n);return d.jsx(_e.h2,{id:o.titleId,...r,ref:t})});Bj.displayName=Mw;var Uj="DialogDescription",OQ=P.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Jr(Uj,n);return d.jsx(_e.p,{id:o.descriptionId,...r,ref:t})});OQ.displayName=Uj;var Hj="DialogClose",Kj=P.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Jr(Hj,n);return d.jsx(_e.button,{type:"button",...r,ref:t,onClick:re(e.onClick,()=>o.onOpenChange(!1))})});Kj.displayName=Hj;function Aw(e){return e?"open":"closed"}var Wj="DialogTitleWarning",[Dae,Gj]=hZ(Wj,{contentName:Xi,titleName:Mw,docsSlug:"dialog"}),DQ=({titleId:e})=>{const t=Gj(Wj),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
261
|
+
|
|
262
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
263
|
+
|
|
264
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return P.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},RQ="DialogDescriptionWarning",LQ=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Gj(RQ).contentName}}.`;return P.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},$Q=Dj,NQ=$j,FQ=Nj,zQ=Fj;const Vj=()=>{},Yj=P.createContext(null);function BQ({onEvent:e,children:t}){return d.jsx(Yj.Provider,{value:e??Vj,children:t})}function Zt(){return P.useContext(Yj)??Vj}const Xj=P.createContext(null);function UQ({children:e}){const t=F(),n=Zt(),[r,o]=P.useState([]),s=P.useCallback(c=>{const u=c.id??ct();return o(h=>[...h.filter(p=>p.id!==c.id),{...c,id:u}]),n("open-menu",{source:"dialog",id:u}),t.addOpenMenu(u),u},[t,n]),i=P.useCallback((c,u)=>(o(h=>h.map(p=>p.id===c?{...p,...u}:p)),n("open-menu",{source:"dialog",id:c}),t.addOpenMenu(c),c),[t,n]),a=P.useCallback(c=>(o(u=>u.filter(h=>{var p;return h.id===c?((p=h.onClose)==null||p.call(h),!1):!0})),n("close-menu",{source:"dialog",id:c}),t.deleteOpenMenu(c),c),[t,n]),l=P.useCallback(()=>{o(c=>(c.forEach(u=>{var h;(h=u.onClose)==null||h.call(u),n("close-menu",{source:"dialog",id:u.id}),t.deleteOpenMenu(u.id)}),[]))},[t,n]);return d.jsx(Xj.Provider,{value:{dialogs:r,addDialog:s,removeDialog:a,clearDialogs:l,updateDialog:i},children:e})}function aa(){const e=P.useContext(Xj);if(!e)throw new Error("useDialogs must be used within a DialogsProvider");return e}const HQ=({id:e,component:t,onClose:n})=>{const{removeDialog:r}=aa(),o=$t(),s=P.useCallback(i=>{if(!i){if(n)try{n()}catch(a){console.warn(a)}r(e)}},[e,n,r]);return d.jsx($Q,{onOpenChange:s,defaultOpen:!0,children:d.jsx(NQ,{container:o,children:d.jsx(FQ,{dir:"ltr",className:"tlui-dialog__overlay",onClick:i=>{i.target===i.currentTarget&&s(!1)},children:d.jsx(zQ,{dir:"ltr",className:"tlui-dialog__content",children:d.jsx(t,{onClose:()=>s(!1)})})})})})};function KQ(){const{dialogs:e}=aa();return e.map(t=>d.jsx(HQ,{...t},t.id))}const WQ=Ce.memo(KQ);function GQ(){const e=F(),t=K("follow",()=>e.getInstanceState().followingUserId,[e]);return t?d.jsx(VQ,{userId:t}):null}function VQ({userId:e}){const t=Yf(e);return t?d.jsx("div",{className:"tlui-following-indicator",style:{borderColor:t.color}}):null}function Eg(e){const t=e+"CollectionProvider",[n,r]=Ao(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=f=>{const{scope:S,children:y}=f,x=Ce.useRef(null),m=Ce.useRef(new Map).current;return d.jsx(o,{scope:S,itemMap:m,collectionRef:x,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Ce.forwardRef((f,S)=>{const{scope:y,children:x}=f,m=s(a,y),v=qe(S,m.collectionRef);return d.jsx(Yi,{ref:v,children:x})});l.displayName=a;const c=e+"CollectionItemSlot",u="data-radix-collection-item",h=Ce.forwardRef((f,S)=>{const{scope:y,children:x,...m}=f,v=Ce.useRef(null),w=qe(S,v),C=s(c,y);return Ce.useEffect(()=>(C.itemMap.set(v,{ref:v,...m}),()=>void C.itemMap.delete(v))),d.jsx(Yi,{[u]:"",ref:w,children:x})});h.displayName=c;function p(f){const S=s(e+"CollectionConsumer",f);return Ce.useCallback(()=>{const x=S.collectionRef.current;if(!x)return[];const m=Array.from(x.querySelectorAll(`[${u}]`));return Array.from(S.itemMap.values()).sort((C,E)=>m.indexOf(C.ref.current)-m.indexOf(E.ref.current))},[S.collectionRef,S.itemMap])}return[{Provider:i,Slot:l,ItemSlot:h},p,r]}var YQ="VisuallyHidden",jw=P.forwardRef((e,t)=>d.jsx(_e.span,{...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}}));jw.displayName=YQ;var Ow="ToastProvider",[Dw,XQ,qQ]=Eg("Toast"),[qj,Rae]=Ao("Toast",[qQ]),[ZQ,kg]=qj(Ow),Zj=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=P.useState(null),[c,u]=P.useState(0),h=P.useRef(!1),p=P.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Ow}\`. Expected non-empty \`string\`.`),d.jsx(Dw.Provider,{scope:t,children:d.jsx(ZQ,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:P.useCallback(()=>u(f=>f+1),[]),onToastRemove:P.useCallback(()=>u(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:p,children:i})})};Zj.displayName=Ow;var Qj="ToastViewport",QQ=["F8"],Gv="toast.viewportPause",Vv="toast.viewportResume",Jj=P.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=QQ,label:o="Notifications ({hotkey})",...s}=e,i=kg(Qj,n),a=XQ(n),l=P.useRef(null),c=P.useRef(null),u=P.useRef(null),h=P.useRef(null),p=qe(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),S=i.toastCount>0;P.useEffect(()=>{const x=m=>{var w;r.every(C=>m[C]||m.code===C)&&((w=h.current)==null||w.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),P.useEffect(()=>{const x=l.current,m=h.current;if(S&&x&&m){const v=()=>{if(!i.isClosePausedRef.current){const _=new CustomEvent(Gv);m.dispatchEvent(_),i.isClosePausedRef.current=!0}},w=()=>{if(i.isClosePausedRef.current){const _=new CustomEvent(Vv);m.dispatchEvent(_),i.isClosePausedRef.current=!1}},C=_=>{!x.contains(_.relatedTarget)&&w()},E=()=>{x.contains(document.activeElement)||w()};return x.addEventListener("focusin",v),x.addEventListener("focusout",C),x.addEventListener("pointermove",v),x.addEventListener("pointerleave",E),window.addEventListener("blur",v),window.addEventListener("focus",w),()=>{x.removeEventListener("focusin",v),x.removeEventListener("focusout",C),x.removeEventListener("pointermove",v),x.removeEventListener("pointerleave",E),window.removeEventListener("blur",v),window.removeEventListener("focus",w)}}},[S,i.isClosePausedRef]);const y=P.useCallback(({tabbingDirection:x})=>{const v=a().map(w=>{const C=w.ref.current,E=[C,...dJ(C)];return x==="forwards"?E:E.reverse()});return(x==="forwards"?v.reverse():v).flat()},[a]);return P.useEffect(()=>{const x=h.current;if(x){const m=v=>{var E,_,I;const w=v.altKey||v.ctrlKey||v.metaKey;if(v.key==="Tab"&&!w){const k=document.activeElement,T=v.shiftKey;if(v.target===x&&T){(E=c.current)==null||E.focus();return}const $=y({tabbingDirection:T?"backwards":"forwards"}),j=$.findIndex(O=>O===k);Ty($.slice(j+1))?v.preventDefault():T?(_=c.current)==null||_.focus():(I=u.current)==null||I.focus()}};return x.addEventListener("keydown",m),()=>x.removeEventListener("keydown",m)}},[a,y]),d.jsxs(MZ,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:S?void 0:"none"},children:[S&&d.jsx(Yv,{ref:c,onFocusFromOutsideViewport:()=>{const x=y({tabbingDirection:"forwards"});Ty(x)}}),d.jsx(Dw.Slot,{scope:n,children:d.jsx(_e.ol,{tabIndex:-1,...s,ref:p})}),S&&d.jsx(Yv,{ref:u,onFocusFromOutsideViewport:()=>{const x=y({tabbingDirection:"backwards"});Ty(x)}})]})});Jj.displayName=Qj;var eO="ToastFocusProxy",Yv=P.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=kg(eO,n);return d.jsx(jw,{"aria-hidden":!0,tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Yv.displayName=eO;var _g="Toast",JQ="toast.swipeStart",eJ="toast.swipeMove",tJ="toast.swipeCancel",nJ="toast.swipeEnd",tO=P.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a=!0,l]=ui({prop:r,defaultProp:o,onChange:s});return d.jsx(Qr,{present:n||a,children:d.jsx(sJ,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:Xt(e.onPause),onResume:Xt(e.onResume),onSwipeStart:re(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:re(e.onSwipeMove,c=>{const{x:u,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:re(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:re(e.onSwipeEnd,c=>{const{x:u,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${u}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),l(!1)})})})});tO.displayName=_g;var[rJ,oJ]=qj(_g,{onClose(){}}),sJ=P.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:u,onSwipeMove:h,onSwipeCancel:p,onSwipeEnd:f,...S}=e,y=kg(_g,n),[x,m]=P.useState(null),v=qe(t,O=>m(O)),w=P.useRef(null),C=P.useRef(null),E=o||y.duration,_=P.useRef(0),I=P.useRef(E),k=P.useRef(0),{onToastAdd:T,onToastRemove:M}=y,D=Xt(()=>{var R;(x==null?void 0:x.contains(document.activeElement))&&((R=y.viewport)==null||R.focus()),i()}),$=P.useCallback(O=>{!O||O===1/0||(window.clearTimeout(k.current),_.current=new Date().getTime(),k.current=window.setTimeout(D,O))},[D]);P.useEffect(()=>{const O=y.viewport;if(O){const R=()=>{$(I.current),c==null||c()},H=()=>{const B=new Date().getTime()-_.current;I.current=I.current-B,window.clearTimeout(k.current),l==null||l()};return O.addEventListener(Gv,H),O.addEventListener(Vv,R),()=>{O.removeEventListener(Gv,H),O.removeEventListener(Vv,R)}}},[y.viewport,E,l,c,$]),P.useEffect(()=>{s&&!y.isClosePausedRef.current&&$(E)},[s,E,y.isClosePausedRef,$]),P.useEffect(()=>(T(),()=>M()),[T,M]);const j=P.useMemo(()=>x?lO(x):null,[x]);return y.viewport?d.jsxs(d.Fragment,{children:[j&&d.jsx(iJ,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:j}),d.jsx(rJ,{scope:n,onClose:D,children:ia.createPortal(d.jsx(Dw.ItemSlot,{scope:n,children:d.jsx(TZ,{asChild:!0,onEscapeKeyDown:re(a,()=>{y.isFocusedToastEscapeKeyDownRef.current||D(),y.isFocusedToastEscapeKeyDownRef.current=!1}),children:d.jsx(_e.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":y.swipeDirection,...S,ref:v,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:re(e.onKeyDown,O=>{O.key==="Escape"&&(a==null||a(O.nativeEvent),O.nativeEvent.defaultPrevented||(y.isFocusedToastEscapeKeyDownRef.current=!0,D()))}),onPointerDown:re(e.onPointerDown,O=>{O.button===0&&(w.current={x:O.clientX,y:O.clientY})}),onPointerMove:re(e.onPointerMove,O=>{if(!w.current)return;const R=O.clientX-w.current.x,H=O.clientY-w.current.y,B=!!C.current,z=["left","right"].includes(y.swipeDirection),W=["left","up"].includes(y.swipeDirection)?Math.min:Math.max,Y=z?W(0,R):0,q=z?0:W(0,H),le=O.pointerType==="touch"?10:2,ge={x:Y,y:q},be={originalEvent:O,delta:ge};B?(C.current=ge,gh(eJ,h,be,{discrete:!1})):JI(ge,y.swipeDirection,le)?(C.current=ge,gh(JQ,u,be,{discrete:!1}),O.target.setPointerCapture(O.pointerId)):(Math.abs(R)>le||Math.abs(H)>le)&&(w.current=null)}),onPointerUp:re(e.onPointerUp,O=>{const R=C.current,H=O.target;if(H.hasPointerCapture(O.pointerId)&&H.releasePointerCapture(O.pointerId),C.current=null,w.current=null,R){const B=O.currentTarget,z={originalEvent:O,delta:R};JI(R,y.swipeDirection,y.swipeThreshold)?gh(nJ,f,z,{discrete:!0}):gh(tJ,p,z,{discrete:!0}),B.addEventListener("click",W=>W.preventDefault(),{once:!0})}})})})}),y.viewport)})]}):null}),iJ=e=>{const{__scopeToast:t,children:n,...r}=e,o=kg(_g,t),[s,i]=P.useState(!1),[a,l]=P.useState(!1);return cJ(()=>i(!0)),P.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:d.jsx(rd,{asChild:!0,children:d.jsx(jw,{...r,children:s&&d.jsxs(d.Fragment,{children:[o.label," ",n]})})})},aJ="ToastTitle",nO=P.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return d.jsx(_e.div,{...r,ref:t})});nO.displayName=aJ;var lJ="ToastDescription",rO=P.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return d.jsx(_e.div,{...r,ref:t})});rO.displayName=lJ;var oO="ToastAction",sO=P.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?d.jsx(aO,{altText:n,asChild:!0,children:d.jsx(Rw,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${oO}\`. Expected non-empty \`string\`.`),null)});sO.displayName=oO;var iO="ToastClose",Rw=P.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=oJ(iO,n);return d.jsx(aO,{asChild:!0,children:d.jsx(_e.button,{type:"button",...r,ref:t,onClick:re(e.onClick,o.onClose)})})});Rw.displayName=iO;var aO=P.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return d.jsx(_e.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function lO(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),uJ(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(...lO(r))}}),t}function gh(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?Iw(o,s):o.dispatchEvent(s)}var JI=(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 cJ(e=()=>{}){const t=Xt(e);Qs(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function uJ(e){return e.nodeType===e.ELEMENT_NODE}function dJ(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 Ty(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var hJ=tO,pJ=nO,fJ=rO,gJ=sO,eE=Rw;const cO=P.createContext(null);function mJ({children:e}){const[t,n]=P.useState([]),r=P.useCallback(i=>{const a=i.id??ct();return n(l=>[...l.filter(c=>c.id!==i.id),{...i,id:a}]),a},[]),o=P.useCallback(i=>(n(a=>a.filter(l=>l.id!==i)),i),[]),s=P.useCallback(()=>{n(()=>[])},[]);return d.jsx(Zj,{children:d.jsx(cO.Provider,{value:{toasts:t,addToast:r,removeToast:o,clearToasts:s},children:e})})}function eo(){const e=P.useContext(cO);if(!e)throw new Error("useToasts must be used within a ToastsProvider");return e}const ue=P.forwardRef(function({children:t,disabled:n,type:r,...o},s){return d.jsx("button",{ref:s,type:"button",draggable:!1,disabled:n,...o,className:ce("tlui-button",`tlui-button__${r}`,o.className),children:t})});function bt({children:e}){return d.jsx("span",{className:"tlui-button__label",children:e})}const Eo=P.memo(function({small:t,invertIcon:n,icon:r,color:o,className:s,...i}){const a=bw(),l=a.icons[r]??a.icons["question-mark-circle"],c=P.useRef(null);return P.useLayoutEffect(()=>{l||console.error(`Icon not found: ${r}. Add it to the assetUrls.icons object.`),c!=null&&c.current&&(c.current.style.webkitMask=`url(${l}) center 100% / 100% no-repeat`)},[c,l,r]),r==="none"?d.jsx("div",{className:ce("tlui-icon tlui-icon__placeholder",{"tlui-icon__small":t},s)}):d.jsx("div",{...i,ref:c,className:ce("tlui-icon",{"tlui-icon__small":t},s),style:{color:o,mask:`url(${l}) center 100% / 100% no-repeat`,transform:n?"scale(-1, 1)":void 0}})}),yJ={success:"check-circle",warning:"warning-triangle",error:"cross-circle",info:"info-circle"};function SJ({toast:e}){const{removeToast:t}=eo(),n=we(),r=i=>{i||t(e.id)},o=e.actions&&e.actions.length>0,s=e.icon||e.severity&&yJ[e.severity];return d.jsxs(hJ,{onOpenChange:r,className:"tlui-toast__container",duration:e.keepOpen?1/0:5e3,"data-severity":e.severity,children:[s&&d.jsx("div",{className:"tlui-toast__icon",children:d.jsx(Eo,{icon:s})}),d.jsxs("div",{className:"tlui-toast__main",children:[d.jsxs("div",{className:"tlui-toast__content",children:[e.title&&d.jsx(pJ,{className:"tlui-toast__title",children:e.title}),e.description&&d.jsx(fJ,{className:"tlui-toast__description",children:e.description})]}),e.actions&&d.jsxs("div",{className:"tlui-toast__actions",children:[e.actions.map((i,a)=>d.jsx(gJ,{altText:i.label,asChild:!0,onClick:i.onClick,children:d.jsx(ue,{type:i.type,children:d.jsx(bt,{children:i.label})})},a)),d.jsx(eE,{asChild:!0,children:d.jsx(ue,{type:"normal",className:"tlui-toast__close",style:{marginLeft:"auto"},children:d.jsx(bt,{children:e.closeLabel??n("toast.close")})})})]})]}),!o&&d.jsx(eE,{asChild:!0,children:d.jsx(ue,{type:"normal",className:"tlui-toast__close",children:d.jsx(bt,{children:e.closeLabel??n("toast.close")})})})]})}function vJ(){const{toasts:e}=eo();return e.map(t=>d.jsx(SJ,{toast:t},t.id))}const xJ=P.memo(vJ);function wJ(){const e=F(),{toasts:t}=eo(),[n,r]=P.useState(!1);return P.useEffect(()=>{let o=-1;return t.length?r(!0):o=e.timers.setTimeout(()=>{r(!1)},1e3),()=>{clearTimeout(o)}},[t.length,r,e]),n?d.jsx(Jj,{className:"tlui-toast__viewport"}):null}function ve({icon:e,small:t,invertIcon:n}){return d.jsx(Eo,{className:"tlui-button__icon",icon:e,small:t,invertIcon:n})}const My=[0,390,428,468,580,640,840,1023];var yt=(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))(yt||{});let Xv={fonts:{draw:`${Os()}/fonts/Shantell_Sans-Tldrawish.woff2`,serif:`${Os()}/fonts/IBMPlexSerif-Medium.woff2`,sansSerif:`${Os()}/fonts/IBMPlexSans-Medium.woff2`,monospace:`${Os()}/fonts/IBMPlexMono-Medium.woff2`}};function uO(e){return P.useMemo(()=>e?{fonts:{...Xv.fonts,...e==null?void 0:e.fonts}}:Xv,[e])}const bJ=["align-bottom","align-center-horizontal","align-center-vertical","align-left","align-right","align-top","arrow-left","arrowhead-arrow","arrowhead-bar","arrowhead-diamond","arrowhead-dot","arrowhead-none","arrowhead-square","arrowhead-triangle-inverted","arrowhead-triangle","blob","bring-forward","bring-to-front","broken","check-circle","check","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","color","cross-2","cross-circle","dash-dashed","dash-dotted","dash-draw","dash-solid","disconnected","discord","distribute-horizontal","distribute-vertical","dot","dots-horizontal","dots-vertical","drag-handle-dots","duplicate","edit","external-link","fill-fill","fill-none","fill-pattern","fill-semi","fill-solid","follow","following","font-draw","font-mono","font-sans","font-serif","geo-arrow-down","geo-arrow-left","geo-arrow-right","geo-arrow-up","geo-check-box","geo-cloud","geo-diamond","geo-ellipse","geo-heart","geo-hexagon","geo-octagon","geo-oval","geo-pentagon","geo-rectangle","geo-rhombus-2","geo-rhombus","geo-star","geo-trapezoid","geo-triangle","geo-x-box","github","group","horizontal-align-end","horizontal-align-middle","horizontal-align-start","info-circle","leading","link","lock","menu","minus","mixed","pack","plus","question-mark-circle","question-mark","redo","reset-zoom","rotate-ccw","rotate-cw","send-backward","send-to-back","share-1","size-extra-large","size-large","size-medium","size-small","spline-cubic","spline-line","stack-horizontal","stack-vertical","status-offline","stretch-horizontal","stretch-vertical","text-align-center","text-align-left","text-align-right","toggle-off","toggle-on","tool-arrow","tool-eraser","tool-frame","tool-hand","tool-highlight","tool-laser","tool-line","tool-media","tool-note","tool-pencil","tool-pointer","tool-screenshot","tool-text","trash","twitter","undo","ungroup","unlock","vertical-align-end","vertical-align-middle","vertical-align-start","warning-triangle","zoom-in","zoom-out"];let uc={...Xv,icons:Object.fromEntries(bJ.map(e=>[e,`${Os()}/icons/icon/${e}.svg`])),translations:Object.fromEntries(iu.map(e=>[e.locale,`${Os()}/translations/${e.locale}.json`])),embedIcons:Object.fromEntries(Hu.map(e=>[e.type,`${Os()}/embed-icons/${e.type}.png`]))};function PJ(e){return e?{fonts:Object.assign({...uc.fonts},{...e==null?void 0:e.fonts}),icons:Object.assign({...uc.icons},{...e==null?void 0:e.icons}),embedIcons:Object.assign({...uc.embedIcons},{...e==null?void 0:e.embedIcons}),translations:Object.assign({...uc.translations},{...e==null?void 0:e.translations})}:uc}function Tg({className:e,children:t}){return d.jsx("div",{className:ce("tlui-dialog__header",e),children:t})}function Mg({className:e,children:t}){return d.jsx(Bj,{dir:"ltr",className:ce("tlui-dialog__header__title",e),children:t})}function Ag(){return d.jsx("div",{className:"tlui-dialog__header__close",children:d.jsx(Kj,{"data-testid":"dialog.close",dir:"ltr",asChild:!0,children:d.jsx(ue,{type:"icon","aria-label":"Close",onTouchEnd:e=>e.target.click(),children:d.jsx(ve,{small:!0,icon:"cross-2"})})})})}function Eu({className:e,children:t,style:n}){return d.jsx("div",{className:ce("tlui-dialog__body",e),style:n,children:t})}function Lw({className:e,children:t}){return d.jsx("div",{className:ce("tlui-dialog__footer",e),children:t})}const jg=P.forwardRef(function({className:t,label:n,icon:r,iconLeft:o,autoSelect:s=!1,autoFocus:i=!1,defaultValue:a,placeholder:l,onComplete:c,onValueChange:u,onCancel:h,onFocus:p,onBlur:f,shouldManuallyMaintainScrollPositionWhenFocused:S=!1,children:y,value:x},m){const v=F(),w=P.useRef(null);P.useImperativeHandle(m,()=>w.current);const C=we(),E=P.useRef(a??""),_=P.useRef(a??""),[I,k]=P.useState(!1),T=P.useCallback(j=>{k(!0);const O=j.currentTarget;_.current=O.value,v.timers.requestAnimationFrame(()=>{s&&O.select()}),p==null||p()},[s,p,v.timers]),M=P.useCallback(j=>{const O=j.currentTarget.value;_.current=O,u==null||u(O)},[u]),D=P.useCallback(j=>{switch(j.key){case"Enter":{j.currentTarget.blur(),Ot(j),c==null||c(j.currentTarget.value);break}case"Escape":{j.currentTarget.value=E.current,j.currentTarget.blur(),Ot(j),h==null||h(j.currentTarget.value);break}}},[c,h]),$=P.useCallback(j=>{k(!1);const O=j.currentTarget.value;f==null||f(O)},[f]);return P.useEffect(()=>{if(!v.environment.isIos)return;const j=window.visualViewport;if(I&&S&&j){const O=()=>{var R;(R=w.current)==null||R.scrollIntoView({block:"center"})};return j.addEventListener("resize",O),j.addEventListener("scroll",O),v.timers.requestAnimationFrame(()=>{var R;(R=w.current)==null||R.scrollIntoView({block:"center"})}),()=>{j.removeEventListener("resize",O),j.removeEventListener("scroll",O)}}},[v,I,S]),d.jsxs("div",{draggable:!1,className:"tlui-input__wrapper",children:[y,n&&d.jsx("label",{children:C(n)}),o&&d.jsx(Eo,{icon:o,className:"tlui-icon-left",small:!0}),d.jsx("input",{ref:w,className:ce("tlui-input",t),type:"text",defaultValue:a,onKeyUp:D,onChange:M,onFocus:T,onBlur:$,autoFocus:i,placeholder:l,value:x}),r&&d.jsx(Eo,{icon:r,small:!!n})]})}),dO=Lt(function({onClose:t}){const n=F(),r=we(),o=bw(),[s,i]=P.useState(null),[a,l]=P.useState(""),[c,u]=P.useState(null),[h,p]=P.useState(!1),f=P.useRef(-1);return d.jsxs(d.Fragment,{children:[d.jsxs(Tg,{children:[d.jsx(Mg,{children:s?`${r("embed-dialog.title")} — ${s.title}`:r("embed-dialog.title")}),d.jsx(Ag,{})]}),s?d.jsxs(d.Fragment,{children:[d.jsxs(Eu,{className:"tlui-embed-dialog__enter",children:[d.jsx(jg,{className:"tlui-embed-dialog__input",label:"embed-dialog.url",placeholder:"http://example.com",autoFocus:!0,onValueChange:S=>{l(S);const y=Rs(S);u(y&&y.definition.type===s.type?y:null),p(!1),clearTimeout(f.current),f.current=n.timers.setTimeout(()=>p(!y),320)}}),a===""?d.jsxs("div",{className:"tlui-embed-dialog__instruction",children:[d.jsx("span",{children:r("embed-dialog.instruction")})," ",s.instructionLink&&d.jsxs("a",{target:"_blank",rel:"noopener noreferrer",href:s.instructionLink,className:"tlui-embed-dialog__instruction__link",children:["Learn more.",d.jsx(Eo,{icon:"external-link",small:!0})]})]}):d.jsx("div",{className:"tlui-embed-dialog__warning",children:h?r("embed-dialog.invalid-url"):" "})]}),d.jsxs(Lw,{className:"tlui-dialog__footer__actions",children:[d.jsx(ue,{type:"normal",onClick:()=>{i(null),u(null),l("")},children:d.jsx(bt,{children:r("embed-dialog.back")})}),d.jsx("div",{className:"tlui-embed__spacer"}),d.jsx(ue,{type:"normal",onClick:t,children:d.jsx(bt,{children:r("embed-dialog.cancel")})}),d.jsx(ue,{type:"primary",disabled:!c,onClick:()=>{c&&(n.putExternalContent({type:"embed",url:a,point:n.getViewportPageBounds().center,embed:c.definition}),t())},children:d.jsx(bt,{children:r("embed-dialog.create")})})]})]}):d.jsx(d.Fragment,{children:d.jsx(Eu,{className:"tlui-embed-dialog__list",children:Hu.map(S=>d.jsxs(ue,{type:"menu",onClick:()=>i(S),children:[d.jsx(bt,{children:S.title}),d.jsx("div",{className:"tlui-embed-dialog__item__image",style:{backgroundImage:`url(${o.embedIcons[S.type]})`}})]},S.type))})})]})});function hO(){const e=F(),t=P.useRef();return P.useEffect(()=>{const n=window.document.createElement("input");n.type="file",n.accept=EB,n.multiple=!0,t.current=n;async function r(o){const s=o.target.files;!s||s.length===0||(e.mark("insert media"),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]),P.useCallback(()=>{var n;(n=t.current)==null||n.click()},[t])}const pO=P.createContext(null);function CJ({overrides:e,children:t}){const n=F(),r=Zt(),{addDialog:o}=aa(),s=hO(),i=P.useMemo(()=>{const a=[{id:"select",label:"tool.select",icon:"tool-pointer",kbd:"v",readonlyOk:!0,onSelect(c){n.setCurrentTool("select"),r("select-tool",{source:c,id:"select"})}},{id:"hand",label:"tool.hand",icon:"tool-hand",kbd:"h",readonlyOk:!0,onSelect(c){n.setCurrentTool("hand"),r("select-tool",{source:c,id:"hand"})}},{id:"eraser",label:"tool.eraser",icon:"tool-eraser",kbd:"e",onSelect(c){n.setCurrentTool("eraser"),r("select-tool",{source:c,id:"eraser"})}},{id:"draw",label:"tool.draw",icon:"tool-pencil",kbd:"d,b,x",onSelect(c){n.setCurrentTool("draw"),r("select-tool",{source:c,id:"draw"})}},...[...Ur.values].map(c=>({id:c,label:`tool.${c}`,meta:{geo:c},kbd:c==="rectangle"?"r":c==="ellipse"?"o":void 0,icon:"geo-"+c,onSelect(u){n.run(()=>{n.setStyleForNextShapes(Ur,c),n.setCurrentTool("geo"),r("select-tool",{source:u,id:`geo-${c}`})})}})),{id:"arrow",label:"tool.arrow",icon:"tool-arrow",kbd:"a",onSelect(c){n.setCurrentTool("arrow"),r("select-tool",{source:c,id:"arrow"})}},{id:"line",label:"tool.line",icon:"tool-line",kbd:"l",onSelect(c){n.setCurrentTool("line"),r("select-tool",{source:c,id:"line"})}},{id:"frame",label:"tool.frame",icon:"tool-frame",kbd:"f",onSelect(c){n.setCurrentTool("frame"),r("select-tool",{source:c,id:"frame"})}},{id:"text",label:"tool.text",icon:"tool-text",kbd:"t",onSelect(c){n.setCurrentTool("text"),r("select-tool",{source:c,id:"text"})}},{id:"asset",label:"tool.asset",icon:"tool-media",kbd:"$u",onSelect(c){s(),r("select-tool",{source:c,id:"media"})}},{id:"note",label:"tool.note",icon:"tool-note",kbd:"n",onSelect(c){n.setCurrentTool("note"),r("select-tool",{source:c,id:"note"})}},{id:"laser",label:"tool.laser",readonlyOk:!0,icon:"tool-laser",kbd:"k",onSelect(c){n.setCurrentTool("laser"),r("select-tool",{source:c,id:"laser"})}},{id:"embed",label:"tool.embed",icon:"dot",onSelect(c){o({component:dO}),r("select-tool",{source:c,id:"embed"})}},{id:"highlight",label:"tool.highlight",icon:"tool-highlight",kbd:"!d",onSelect(c){n.setCurrentTool("highlight"),r("select-tool",{source:c,id:"highlight"})}}];a.push();const l=Object.fromEntries(a.map(c=>[c.id,c]));return e?e(n,l,{insertMedia:s}):l},[e,n,r,s,o]);return d.jsx(pO.Provider,{value:i,children:t})}function Og(){const e=P.useContext(pO);if(!e)throw new Error("useTools must be used within a ToolProvider");return e}const fO=Ce.createContext(null);function IJ({forceMobile:e=!1,children:t}){const n=F(),r=K("breakpoint",()=>{const{width:o}=n.getViewportScreenBounds(),s=e?yt.MOBILE_SM:My.length-1;for(let i=0;i<s;i++)if(o>My[i]&&o<=My[i+1])return i;return s},[n]);return d.jsx(fO.Provider,{value:r,children:t})}function En(){const e=P.useContext(fO);if(e===null)throw new Error("useBreakpoint must be used inside of the <BreakpointProvider /> component");return e}function EJ(){const{addToast:e,removeToast:t,clearToasts:n}=eo(),{addDialog:r,clearDialogs:o,removeDialog:s,updateDialog:i}=aa(),l=En()<yt.TABLET_SM,c=we();return P.useMemo(()=>({addToast:e,removeToast:t,clearToasts:n,addDialog:r,clearDialogs:o,removeDialog:s,updateDialog:i,msg:c,isMobile:l}),[r,e,o,n,c,s,t,i,l])}function kJ(e,t){const n={};for(const r of e)if(r.translations)for(const[o,s]of Un(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 gO(e){return P.useMemo(()=>e,e)}function _J(e){const t=gO(e==null?[]:Array.isArray(e)?e:[e]);return P.useMemo(()=>{const n={};for(const r of t)if(r.translations)for(const[o,s]of Un(r.translations)){let i=n[o];i||(i=n[o]={}),Object.assign(i,s)}return n},[t])}function TJ(e){const t=EJ(),n=gO(e==null?[]:Array.isArray(e)?e:[e]);return P.useMemo(()=>kJ(n,t),[n,t])}function MJ(e,t){const n=ye(t.map(o=>e.getShape(o)).filter(o=>o&&e.isShapeOfType(o,"frame")));if(!n.length)return;const r=[];e.run(()=>{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 AJ=50;function jJ(e,t,n={}){const r=e.getShape(t);if(!r)return;const o=e.getSortedChildIdsForParent(r.id),s=ye(o.map(f=>e.getShape(f)));if(!s.length)return;const i=Q.FromPoints(s.flatMap(f=>{const S=e.getShapeGeometry(f.id);return e.getShapeLocalTransform(f).applyToPoints(S.vertices)})),{padding:a=AJ}=n,l=i.w+2*a,c=i.h+2*a,u=a-i.minX,h=a-i.minY;if(u===0&&h===0&&r.props.w===l&&r.props.h===c)return;const p=new b(u,h).rot(r.rotation);e.run(()=>{const f=o.map(S=>{const y=e.getShape(S);return{id:y.id,type:y.type,x:y.x+u,y:y.y+h}});f.push({id:r.id,type:r.type,x:r.x-p.x,y:r.y-p.y,props:{w:l,h:c}}),e.updateShapes(f)})}function tE(e){return lr.isValid(e)?{isValid:!0,hasProtocol:!0}:lr.isValid("https://"+e)?{isValid:!0,hasProtocol:!1}:{isValid:!1,hasProtocol:!1}}const OJ=Lt(function({onClose:t}){const r=F().getOnlySelectedShape();return r&&"url"in r.props&&typeof r.props.url=="string"?d.jsx(DJ,{onClose:t,selectedShape:r}):null}),DJ=Lt(function({onClose:t,selectedShape:n}){const r=F(),o=we(),s=P.useRef(null);P.useEffect(()=>{r.timers.requestAnimationFrame(()=>{var S;return(S=s.current)==null?void 0:S.focus()})},[r]);const i=P.useRef(n.props.url),[a,l]=P.useState(()=>{const S=tE(n.props.url),y=S.isValid===!0?S.hasProtocol?n.props.url:"https://"+n.props.url:"https://";return{actual:y,safe:y,valid:!0}}),c=P.useCallback(S=>{const y=S.replace(/https?:\/\/(https?:\/\/)/,(v,w)=>w),x=tE(y),m=x.isValid===!0?x.hasProtocol?y:"https://"+y:"https://";l({actual:y,safe:m,valid:x.isValid})},[]),u=P.useCallback(()=>{const S=r.getOnlySelectedShape();S&&(r.updateShapes([{id:S.id,type:S.type,props:{url:""}}]),t())},[r,t]),h=P.useCallback(()=>{const S=r.getOnlySelectedShape();S&&(S&&"url"in S.props&&S.props.url!==a.safe&&r.updateShapes([{id:S.id,type:S.type,props:{url:a.safe}}]),t())},[r,t,a]),p=P.useCallback(()=>{t()},[t]);if(!n)return t(),null;const f=i.current&&!a.valid;return d.jsxs(d.Fragment,{children:[d.jsxs(Tg,{children:[d.jsx(Mg,{children:o("edit-link-dialog.title")}),d.jsx(Ag,{})]}),d.jsx(Eu,{children:d.jsxs("div",{className:"tlui-edit-link-dialog",children:[d.jsx(jg,{ref:s,className:"tlui-edit-link-dialog__input",label:"edit-link-dialog.url",autoFocus:!0,value:a.actual,onValueChange:c,onComplete:h,onCancel:p}),d.jsx("div",{children:a.valid?o("edit-link-dialog.detail"):o("edit-link-dialog.invalid-url")})]})}),d.jsxs(Lw,{className:"tlui-dialog__footer__actions",children:[d.jsx(ue,{type:"normal",onClick:p,onTouchEnd:p,children:d.jsx(bt,{children:o("edit-link-dialog.cancel")})}),f?d.jsx(ue,{type:"danger",onTouchEnd:u,onClick:u,children:d.jsx(bt,{children:o("edit-link-dialog.clear")})}):d.jsx(ue,{type:"primary",disabled:!a.valid,onTouchEnd:h,onClick:h,children:d.jsx(bt,{children:o("edit-link-dialog.save")})})]})]})});var $w={exports:{}};$w.exports;(function(e){var t=function(){var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function i(l,c){if(!s[l]){s[l]={};for(var u=0;u<l.length;u++)s[l][l.charAt(u)]=u}return s[l][c]}var a={compressToBase64:function(l){if(l==null)return"";var c=a._compress(l,6,function(u){return r.charAt(u)});switch(c.length%4){default:case 0:return c;case 1:return c+"===";case 2:return c+"==";case 3:return c+"="}},decompressFromBase64:function(l){return l==null?"":l==""?null:a._decompress(l.length,32,function(c){return i(r,l.charAt(c))})},compressToUTF16:function(l){return l==null?"":a._compress(l,15,function(c){return n(c+32)})+" "},decompressFromUTF16:function(l){return l==null?"":l==""?null:a._decompress(l.length,16384,function(c){return l.charCodeAt(c)-32})},compressToUint8Array:function(l){for(var c=a.compress(l),u=new Uint8Array(c.length*2),h=0,p=c.length;h<p;h++){var f=c.charCodeAt(h);u[h*2]=f>>>8,u[h*2+1]=f%256}return u},decompressFromUint8Array:function(l){if(l==null)return a.decompress(l);for(var c=new Array(l.length/2),u=0,h=c.length;u<h;u++)c[u]=l[u*2]*256+l[u*2+1];var p=[];return c.forEach(function(f){p.push(n(f))}),a.decompress(p.join(""))},compressToEncodedURIComponent:function(l){return l==null?"":a._compress(l,6,function(c){return o.charAt(c)})},decompressFromEncodedURIComponent:function(l){return l==null?"":l==""?null:(l=l.replace(/ /g,"+"),a._decompress(l.length,32,function(c){return i(o,l.charAt(c))}))},compress:function(l){return a._compress(l,16,function(c){return n(c)})},_compress:function(l,c,u){if(l==null)return"";var h,p,f={},S={},y="",x="",m="",v=2,w=3,C=2,E=[],_=0,I=0,k;for(k=0;k<l.length;k+=1)if(y=l.charAt(k),Object.prototype.hasOwnProperty.call(f,y)||(f[y]=w++,S[y]=!0),x=m+y,Object.prototype.hasOwnProperty.call(f,x))m=x;else{if(Object.prototype.hasOwnProperty.call(S,m)){if(m.charCodeAt(0)<256){for(h=0;h<C;h++)_=_<<1,I==c-1?(I=0,E.push(u(_)),_=0):I++;for(p=m.charCodeAt(0),h=0;h<8;h++)_=_<<1|p&1,I==c-1?(I=0,E.push(u(_)),_=0):I++,p=p>>1}else{for(p=1,h=0;h<C;h++)_=_<<1|p,I==c-1?(I=0,E.push(u(_)),_=0):I++,p=0;for(p=m.charCodeAt(0),h=0;h<16;h++)_=_<<1|p&1,I==c-1?(I=0,E.push(u(_)),_=0):I++,p=p>>1}v--,v==0&&(v=Math.pow(2,C),C++),delete S[m]}else for(p=f[m],h=0;h<C;h++)_=_<<1|p&1,I==c-1?(I=0,E.push(u(_)),_=0):I++,p=p>>1;v--,v==0&&(v=Math.pow(2,C),C++),f[x]=w++,m=String(y)}if(m!==""){if(Object.prototype.hasOwnProperty.call(S,m)){if(m.charCodeAt(0)<256){for(h=0;h<C;h++)_=_<<1,I==c-1?(I=0,E.push(u(_)),_=0):I++;for(p=m.charCodeAt(0),h=0;h<8;h++)_=_<<1|p&1,I==c-1?(I=0,E.push(u(_)),_=0):I++,p=p>>1}else{for(p=1,h=0;h<C;h++)_=_<<1|p,I==c-1?(I=0,E.push(u(_)),_=0):I++,p=0;for(p=m.charCodeAt(0),h=0;h<16;h++)_=_<<1|p&1,I==c-1?(I=0,E.push(u(_)),_=0):I++,p=p>>1}v--,v==0&&(v=Math.pow(2,C),C++),delete S[m]}else for(p=f[m],h=0;h<C;h++)_=_<<1|p&1,I==c-1?(I=0,E.push(u(_)),_=0):I++,p=p>>1;v--,v==0&&(v=Math.pow(2,C),C++)}for(p=2,h=0;h<C;h++)_=_<<1|p&1,I==c-1?(I=0,E.push(u(_)),_=0):I++,p=p>>1;for(;;)if(_=_<<1,I==c-1){E.push(u(_));break}else I++;return E.join("")},decompress:function(l){return l==null?"":l==""?null:a._decompress(l.length,32768,function(c){return l.charCodeAt(c)})},_decompress:function(l,c,u){var h=[],p=4,f=4,S=3,y="",x=[],m,v,w,C,E,_,I,k={val:u(0),position:c,index:1};for(m=0;m<3;m+=1)h[m]=m;for(w=0,E=Math.pow(2,2),_=1;_!=E;)C=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),w|=(C>0?1:0)*_,_<<=1;switch(w){case 0:for(w=0,E=Math.pow(2,8),_=1;_!=E;)C=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),w|=(C>0?1:0)*_,_<<=1;I=n(w);break;case 1:for(w=0,E=Math.pow(2,16),_=1;_!=E;)C=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),w|=(C>0?1:0)*_,_<<=1;I=n(w);break;case 2:return""}for(h[3]=I,v=I,x.push(I);;){if(k.index>l)return"";for(w=0,E=Math.pow(2,S),_=1;_!=E;)C=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),w|=(C>0?1:0)*_,_<<=1;switch(I=w){case 0:for(w=0,E=Math.pow(2,8),_=1;_!=E;)C=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),w|=(C>0?1:0)*_,_<<=1;h[f++]=n(w),I=f-1,p--;break;case 1:for(w=0,E=Math.pow(2,16),_=1;_!=E;)C=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),w|=(C>0?1:0)*_,_<<=1;h[f++]=n(w),I=f-1,p--;break;case 2:return x.join("")}if(p==0&&(p=Math.pow(2,S),S++),h[I])y=h[I];else if(I===f)y=v+v.charAt(0);else return null;x.push(y),h[f++]=v+y.charAt(0),p--,v=y,p==0&&(p=Math.pow(2,S),S++)}}};return a}();e!=null?e.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})})($w);var RJ=$w.exports;const mO=ni(RJ);async function LJ(e,t,n){var m,v,w;const{elements:r,files:o}=t,s={shapes:[],bindings:[],rootShapeIds:[],assets:[],schema:e.store.schema.serialize()},i=new Map,a=new Map,l=e.getCurrentPageId(),c=new Map,u=[],h=new Set;r.forEach(C=>{if(c.set(C.id,$e()),C.boundElements!==null)for(const E of C.boundElements)E.type==="text"&&h.add(E.id)});let p=t_;for(const C of r){if(h.has(C.id))continue;const E=c.get(C.id),_={id:E,typeName:"shape",parentId:l,index:p,x:C.x,y:C.y,rotation:0,isLocked:C.locked,opacity:$J(C.opacity),meta:{}};switch(C.angle!==0&&a.set(E,C.angle),C.groupIds&&C.groupIds.length>0?i.has(C.groupIds[0])?(m=i.get(C.groupIds[0]))==null||m.push(E):i.set(C.groupIds[0],[E]):u.push(E),C.type){case"rectangle":case"ellipse":case"diamond":{let I="",k="middle";if(C.boundElements!==null){for(const M of C.boundElements)if(M.type==="text"){const D=r.find($=>$.id===M.id);D&&(I=D.text,k=HJ[D.textAlign])}}const T=C.backgroundColor==="transparent"?C.strokeColor:C.backgroundColor;s.shapes.push({..._,type:"geo",props:{geo:C.type,url:C.link??"",w:C.width,h:C.height,size:mh[C.strokeWidth]??"draw",color:dc[T]??"black",text:I,align:k,dash:yh(C),fill:GJ(C)}});break}case"freedraw":{s.shapes.push({..._,type:"draw",props:{dash:yh(C),size:mh[C.strokeWidth],color:dc[C.strokeColor]??"black",segments:[{type:"free",points:C.points.map(([I,k,T=.5])=>({x:I,y:k,z:T}))}]}});break}case"line":{if(C.points.slice().length<2)break;const k=ou(C.points.length);s.shapes.push({..._,type:"line",props:{dash:yh(C),size:mh[C.strokeWidth],color:dc[C.strokeColor]??"black",spline:C.roundness?"cubic":"line",points:{...Object.fromEntries(C.points.map(([T,M],D)=>{const $=k[D];return[$,{id:$,index:$,x:T,y:M}]}))}}});break}case"arrow":{let I="";if(C.boundElements!==null){for(const $ of C.boundElements)if($.type==="text"){const j=r.find(O=>O.id===$.id);j&&(I=j.text)}}const k=C.points[0],T=C.points[C.points.length-1],M=c.get((v=C.startBinding)==null?void 0:v.elementId),D=c.get((w=C.endBinding)==null?void 0:w.elementId);s.shapes.push({..._,type:"arrow",props:{text:I,bend:WJ(C,k,T),dash:yh(C),size:mh[C.strokeWidth]??"m",color:dc[C.strokeColor]??"black",start:{x:k[0],y:k[1]},end:{x:T[0],y:T[1]},arrowheadEnd:nE[C.endArrowhead]??"none",arrowheadStart:nE[C.startArrowhead]??"none"}}),M&&s.bindings.push({id:ji(),typeName:"binding",type:"arrow",fromId:E,toId:M,props:{terminal:"start",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}}),D&&s.bindings.push({id:ji(),typeName:"binding",type:"arrow",fromId:E,toId:D,props:{terminal:"end",normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1},meta:{}});break}case"text":{const{size:I,scale:k}=FJ(C.fontSize);s.shapes.push({..._,type:"text",props:{size:I,scale:k,font:zJ[C.fontFamily]??"draw",color:dc[C.strokeColor]??"black",text:C.text,textAlign:KJ[C.textAlign]}});break}case"image":{const I=o[C.fileId];if(!I)break;const k=Ii.createId();s.assets.push({id:k,typeName:"asset",type:"image",props:{w:C.width,h:C.height,fileSize:I.size,name:C.id??"Untitled",isAnimated:!1,mimeType:I.mimeType,src:I.dataURL},meta:{}}),s.shapes.push({..._,type:"image",props:{w:C.width,h:C.height,assetId:k}})}}p=zr(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 C of i.values())if(C.length>1){e.groupShapes(C);const E=e.getShape(C[0]);E!=null&&E.parentId&&On(E.parentId)&&u.push(E.parentId)}for(const[C,E]of a)e.select(C),e.rotateShapesBy([C],E);const S=ye(u.map(C=>e.getShape(C))),y=Q.Common(S.map(C=>e.getShapePageBounds(C))),x=e.getViewportPageBounds().center;e.updateShapes(S.map(C=>{const E={x:(C.x??0)-(y.x+y.w/2),y:(C.y??0)-(y.y+y.h/2)};return{id:C.id,type:C.type,x:x.x+E.x,y:x.y+E.y}})),e.setSelectedShapes(u)}const $J=e=>{const t=e/100;return t<.2?.1:t<.4?.25:t<.6?.5:t<.8?.75:1},mh={1:"s",2:"m",3:"l",4:"xl"},NJ={16:"s",20:"m",28:"l",36:"xl"};function FJ(e){const t=NJ[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 zJ={1:"draw",2:"sans",3:"mono"},dc={"#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"},BJ={solid:"draw",dashed:"dashed",dotted:"dotted"},UJ={"cross-hatch":"pattern",hachure:"pattern",solid:"solid"},HJ={left:"start",center:"middle",right:"end"},KJ={left:"start",center:"middle",right:"end"},nE={arrow:"arrow",dot:"dot",triangle:"triangle",bar:"pipe"};function WJ(e,t,n){let r=0;if(e.points.length>2){const o=new b(t[0],t[1]),s=new b(n[0],n[1]),i=new b(e.points[1][0],e.points[1][1]),a=b.Sub(s,o),l=b.Per(a),c=b.Med(s,o),u=b.Sub(c,l),h=b.Add(c,l),p=b.NearestPointOnLineSegment(u,h,i,!1);r=b.Dist(p,c),b.Clockwise(p,s,c)&&(r*=-1)}return r}const yh=e=>{let t=BJ[e.strokeStyle]??"draw";return t==="draw"&&e.roughness===0&&(t="solid"),t},GJ=e=>e.backgroundColor==="transparent"?"none":UJ[e.fillStyle]??"solid";async function VJ(e,t,n,r){const s=(await Promise.all(t.map(async i=>await(await bo(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 YJ(e,t,n){const r=e.getSelectionPageBounds();e.mark("paste"),e.putContentOntoCurrentPage(t,{point:n,select:!0});const o=e.getSelectionPageBounds();r&&o&&(r!=null&&r.collides(o))&&(e.updateInstanceState({isChangingStyle:!0}),e.timers.setTimeout(()=>{e.updateInstanceState({isChangingStyle:!1})},150))}async function qv(e,t,n,r){return e.mark("paste"),await e.putExternalContent({type:"url",point:n,url:t,sources:r})}function XJ(e){const t=document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=e.trim(),t.body.textContent||t.body.innerText||""}const qJ=e=>{try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},ZJ=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 S2(t)},QJ=e=>/^<svg/.test(e),JJ=["input","select","textarea"];function Ay(e){const{activeElement:t}=document;return e.getIsMenuOpen()||t&&(t.getAttribute("contenteditable")||JJ.indexOf(t.tagName.toLowerCase())>-1)}const eee=e=>e.types.find(t=>t.match(/^image\//)),jy=(e,t,n,r)=>{const o=ZJ(t);if(o)for(const s of o)qv(e,s,n);else qJ(t)?qv(e,t,n):QJ(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}))},tee=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}}SO(e,r,n)},yO=async(e,t,n)=>{const r=[];for(const o of t){if(eee(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 Ai.blobToText(s)})()}),o.types.includes("text/uri-list")&&r.push({type:"url",source:(async()=>{const s=await o.getType("text/uri-list");return await Ai.blobToText(s)})()}),o.types.includes("text/plain")&&r.push({type:"text",source:(async()=>{const s=await o.getType("text/plain");return await Ai.blobToText(s)})()})}return await SO(e,r,n)};async function SO(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 VJ(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(l=>{var u;const c=(u=l.match(/<div data-tldraw[^>]*>(.*)<\/div>/))==null?void 0:u[1];if(c)try{const h=mO.decompressFromBase64(c);if(h===null){i({type:"error",data:h,reason:"found tldraw data comment but could not parse base64"});return}else{const p=JSON.parse(h);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:c,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}else{if(a.type==="html"){i({type:"text",data:l,subtype:"html"});return}if(a.type==="url"){i({type:"text",data:l,subtype:"url"});return}try{const h=JSON.parse(l);if(h.type==="excalidraw/clipboard"){i({type:"excalidraw",data:h});return}else{i({type:"text",data:l,subtype:"json"});return}}catch{i({type:"text",data:l,subtype:"text"});return}}i({type:"error",data:l,reason:"unhandled case"})})})));for(const s of o)if(s.type==="tldraw"){YJ(e,s.data,n);return}for(const s of o)if(s.type==="excalidraw"){LJ(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(c=>c.nodeType===1).length===1&&a.firstElementChild&&a.firstElementChild.tagName==="A"&&a.firstElementChild.hasAttribute("href")&&a.firstElementChild.getAttribute("href")!==""){const c=a.firstElementChild.getAttribute("href");jy(e,c,n,o);return}if(!o.some(c=>c.type==="text"&&c.subtype!=="html")&&s.data.trim()){jy(e,XJ(s.data),n,o);return}}for(const s of o)if(s.type==="text"&&s.subtype==="url"){qv(e,s.data,n,o);return}for(const s of o)if(s.type==="text"&&s.subtype==="text"&&s.data.trim()){jy(e,s.data,n,o);return}}const If=async e=>{var r;const t=await e.resolveAssetsInContent(e.getContentFromCurrentPage(e.getSelectedShapeIds()));if(!t){navigator&&navigator.clipboard&&navigator.clipboard.writeText("");return}const n=mO.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($B);if((r=navigator.clipboard)!=null&&r.write){const s=new Blob([`<div data-tldraw>${n}</div>`],{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(`<div data-tldraw>${n}</div>`)}};function nee(){const e=F(),t=Zt(),n=P.useCallback(async function(i){e.getSelectedShapeIds().length!==0&&(await If(e),t("copy",{source:i}))},[e,t]),r=P.useCallback(async function(i){e.getSelectedShapeIds().length!==0&&(await If(e),e.deleteShapes(e.getSelectedShapeIds()),t("cut",{source:i}))},[e,t]),o=P.useCallback(async function(i,a,l){e.getEditingShapeId()===null&&(Array.isArray(i)&&i[0]instanceof ClipboardItem?(yO(e,i,l),t("paste",{source:"menu"})):navigator.clipboard.read().then(c=>{o(c,a,l)}))},[e,t]);return{copy:n,cut:r,paste:o}}function ree(){const e=F(),t=Zt(),n=K("editor.isFocused",()=>e.getInstanceState().isFocused,[e]);P.useEffect(()=>{if(!n)return;const r=async l=>{e.getSelectedShapeIds().length===0||e.getEditingShapeId()!==null||Ay(e)||(Ee(l),await If(e),t("copy",{source:"kbd"}))};async function o(l){e.getSelectedShapeIds().length===0||e.getEditingShapeId()!==null||Ay(e)||(Ee(l),await If(e),e.deleteShapes(e.getSelectedShapeIds()),t("cut",{source:"kbd"}))}let s=!1;const i=l=>{l.button===1&&(s=!0,e.timers.requestAnimationFrame(()=>{s=!1}))},a=l=>{if(s){Ot(l);return}if(e.getEditingShapeId()!==null||Ay(e))return;let c,u=!1;e.inputs.shiftKey&&(u=!0),e.user.getIsPasteAtCursorMode()&&(u=!u),u&&(c=e.inputs.currentPagePoint),l.clipboardData&&!e.inputs.shiftKey?tee(e,l.clipboardData,c):navigator.clipboard.read().then(h=>{Array.isArray(h)&&h[0]instanceof ClipboardItem&&yO(e,h,c)}),Ee(l),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 vO(e,t,n){const{type:r,quality:o,scale:s,width:i,height:a}=n;let[l,c]=await HY(i*s,a*s);l=Math.floor(l),c=Math.floor(c);const u=l/i,h=URL.createObjectURL(new Blob([t],{type:"image/svg+xml"})),p=await new Promise(S=>{const y=sl();y.crossOrigin="anonymous",y.onload=async()=>{e.environment.isSafari&&await new Promise(v=>e.timers.setTimeout(v,250));const x=document.createElement("canvas"),m=x.getContext("2d");x.width=l,x.height=c,m.imageSmoothingEnabled=!0,m.imageSmoothingQuality="high",m.drawImage(y,0,0,l,c),URL.revokeObjectURL(h),S(x)},y.onerror=()=>{S(null)},y.src=h});if(!p)return null;const f=await new Promise(S=>p.toBlob(y=>{(!y||xt.throwToBlob.get())&&S(null),S(y)},"image/"+r,o));if(!f)return null;if(r==="png"){const S=new DataView(await f.arrayBuffer());return lo.setPhysChunk(S,u,{type:"image/"+r})}else return f}async function xO(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 Zv(e,t,n,r={}){var o;switch(n){case"svg":return(o=await xO(e,t,r))==null?void 0:o.svg;case"json":{const s=await e.resolveAssetsInContent(e.getContentFromCurrentPage(t));return JSON.stringify(s)}default:un(n)}}async function wO({editor:e,ids:t,format:n,opts:r={}}){switch(n){case"svg":return new Blob([await Zv(e,t,"svg",r)],{type:"text/plain"});case"json":return new Blob([await Zv(e,t,"json",r)],{type:"text/plain"});case"jpeg":case"png":case"webp":{const o=await xO(e,t,r);if(!o)throw new Error("Could not construct image.");const s=await vO(e,o.svg,{type:n,quality:1,scale:2,width:o.width,height:o.height});if(!s)throw new Error("Could not construct image.");return s}default:un(n)}}const oee={jpeg:"image/jpeg",png:"image/png",webp:"image/webp",json:"text/plain",svg:"text/plain"};function see(e,t,n,r={}){return{blobPromise:wO({editor:e,ids:t,format:n,opts:r}),mimeType:oee[n]}}function iee(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}=see(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 aee(async()=>Zv(e,t,n,r));case"jpeg":case"png":throw new Error("Copy not supported");default:un(n)}}async function aee(e){var t,n;await((n=(t=navigator.clipboard)==null?void 0:t.writeText)==null?void 0:n.call(t,await e()))}function lee(){const e=F(),{addToast:t}=eo(),n=we();return P.useCallback((r,o="svg")=>{iee(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 cee(e,t,n="png",r,o={}){if(!r&&(r=`shapes at ${rE()}`,t.length===1)){const a=e.getShape(t[0]);e.isShapeOfType(a,"frame")?r=a.props.name??"frame":r=`${a.id.replace(/:/,"_")} at ${rE()}`}r+=`.${n}`;const s=await wO({editor:e,ids:t,format:n,opts:o}),i=new File([s],r,{type:s.type});uee(i)}function rE(){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 uee(e){const t=document.createElement("a"),n=URL.createObjectURL(e);t.href=n,t.download=e.name,t.click(),URL.revokeObjectURL(n)}function dee(){const e=F(),{addToast:t}=eo(),n=we();return P.useCallback((r,o="png",s)=>{cee(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])}async function hee(e,t,n){const r=ye(t.map(a=>{const l=e.getShape(a);if(!(!l||e.getShapeUtil(l.type).toSvg===void 0))return l}));if(r.length===0)return;if(r.length===1){const a=r[0];if(!a||e.isShapeOfType(a,"image"))return}const o=[];if(n!==void 0){const a=r.map(l=>({shape:l,bounds:e.getShapeMaskedPageBounds(l).clone().expandBy(n)}));for(let l=0;l<a.length;l++){const c=a[l];if(l===0){o[0]={shapes:[c.shape],bounds:c.bounds};continue}let u=!1;for(const h of o)if(h.bounds.includes(c.bounds)){h.shapes.push(c.shape),h.bounds.expand(c.bounds),u=!0;break}u||o.push({shapes:[c.shape],bounds:c.bounds})}}else{const a=Q.Common(r.map(l=>e.getShapeMaskedPageBounds(l)));o.push({shapes:r,bounds:a})}const s=e.options.flattenImageBoundsPadding;for(const a of o){n!==void 0&&a.bounds.expandBy(-n);const l=await e.getSvgString(a.shapes,{padding:s});if(!(l!=null&&l.svg))continue;const c=new Blob([l.svg],{type:"image/svg+xml"}),u=await e.getAssetForExternalContent({type:"file",file:new File([c],"asset.svg",{type:"image/svg+xml"})});u&&(a.asset=u)}const i=[];return mo(()=>{for(const a of o){const{asset:l,bounds:c,shapes:u}=a;if(!l)continue;const h=e.findCommonAncestor(u)??e.getCurrentPageId();if(!h)continue;let p="a1";for(const m of u)if(m.parentId===h){m.index>p&&(p=m.index);break}let f,S,y;if(On(h)){const m=e.getShape(h);if(!m)continue;const v=e.getPointInShapeSpace(m,{x:c.x,y:c.y});y=e.getShapePageTransform(h).rotation(),v.sub(new b(s,s).rot(-y)),f=v.x,S=v.y}else f=c.x-s,S=c.y-s,y=0;e.deleteShapes(u),e.createAssets([{...l,id:l.id}]);const x=$e();e.createShape({id:x,type:"image",index:p,parentId:h,x:f,y:S,rotation:-y,props:{assetId:l.id,w:c.w+s*2,h:c.h+s*2}}),i.push(x)}}),i}function Dg(){return F().store.props.collaboration!==void 0}function pee(){const e=F();return K("sync status",()=>{var t;return(t=e.store.props.collaboration)!=null&&t.status?e.store.props.collaboration.status.get():null},[e])}function fee(){const e=F(),t=P.useRef(null),n=P.useRef(null);return P.useCallback(async function(){const o=document.createElement("div"),s=document.createElement("style"),i=(m,v)=>{m&&(m.innerHTML=""),v&&document.head.contains(v)&&document.head.removeChild(v),m&&document.body.contains(m)&&document.body.removeChild(m)};i(t.current,n.current),t.current=o,n.current=s;const a=`tl-print-surface-${ct()}`;o.className=a,s.innerHTML=`
|
|
265
|
+
.${a} {
|
|
266
|
+
display: none;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.${a} svg {
|
|
270
|
+
max-width: 100%;
|
|
271
|
+
height: 100%;
|
|
272
|
+
display: block;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
@media print {
|
|
276
|
+
html, body {
|
|
277
|
+
min-height: 100%;
|
|
278
|
+
height: 100%;
|
|
279
|
+
margin: 0;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
body {
|
|
283
|
+
position: relative;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
body > * {
|
|
287
|
+
display: none;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.tldraw__editor {
|
|
291
|
+
display: none;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.${a} {
|
|
295
|
+
display: block !important;
|
|
296
|
+
background: white;
|
|
297
|
+
min-height: 100%;
|
|
298
|
+
height: 100%;
|
|
299
|
+
max-width: 100%;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.${a}__item {
|
|
303
|
+
padding: 10mm;
|
|
304
|
+
display: flex;
|
|
305
|
+
min-height: 100%;
|
|
306
|
+
flex-direction: column;
|
|
307
|
+
page-break-after: always;
|
|
308
|
+
position: relative;
|
|
309
|
+
overflow: hidden;
|
|
310
|
+
height: 100%;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.${a}__item__main {
|
|
314
|
+
flex: 1;
|
|
315
|
+
display: flex;
|
|
316
|
+
align-items: center;
|
|
317
|
+
justify-content: center;
|
|
318
|
+
max-height: 100%;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.${a}__item__header {
|
|
322
|
+
display: none;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.${a}__item__footer {
|
|
326
|
+
display: none;
|
|
327
|
+
text-align: right;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.${a}__item__footer__hide {
|
|
331
|
+
display: none;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
`;const l=()=>{document.head.appendChild(s),document.body.appendChild(o)},c=()=>{e.once("tick",()=>{i(o,s)})};window.addEventListener("beforeprint",l),window.addEventListener("afterprint",c);function u(m,v,w){try{o.innerHTML+=`<div class="${a}__item">
|
|
338
|
+
<div class="${a}__item__header">
|
|
339
|
+
${m.replace(/</g,"<").replace(/>/g,">")}
|
|
340
|
+
</div>
|
|
341
|
+
<div class="${a}__item__main">
|
|
342
|
+
${w}
|
|
343
|
+
</div>
|
|
344
|
+
<div class="${a}__item__footer ${a}__item__footer__${v?"":"hide"}">
|
|
345
|
+
${v??""}
|
|
346
|
+
</div>
|
|
347
|
+
</div>`}catch(C){console.error(C)}}function h(){e.environment.isChromeForIos?(l(),window.print()):e.environment.isSafari?(l(),document.execCommand("print",!1)):window.print()}const p=e.getSelectedShapeIds(),f=e.getCurrentPageId(),S=e.getPages(),x={scale:1,background:!1,darkMode:!1,preserveAspectRatio:"xMidYMid meet"};if(e.getSelectedShapeIds().length>0){const m=await e.getSvgString(p,x);if(m){const v=S.find(w=>w.id===f);u(`tldraw — ${v==null?void 0:v.name}`,null,m.svg),h()}}else{const m=e.getCurrentPage(),v=await e.getSvgString(e.getSortedChildIdsForParent(m.id),x);v&&(u(`tldraw — ${m.name}`,null,v.svg),h())}window.removeEventListener("beforeprint",l),window.removeEventListener("afterprint",c)},[e])}const bO=P.createContext(null);function gee(e){return Object.fromEntries(e.map(t=>[t.id,t]))}function wa(e,t){if(e.getSelectedShapes().length===0)return e.getDocumentSettings().name||t}function mee({overrides:e,children:t}){const n=F(),r=Dg(),{addDialog:o,clearDialogs:s}=aa(),{clearToasts:i,addToast:a}=eo(),l=we(),c=hO(),u=fee(),{cut:h,copy:p,paste:f}=nee(),S=lee(),y=dee(),x=l("document.default-name"),m=Zt(),v=P.useMemo(()=>{function w(){return n.isIn("select")||(n.complete(),n.setCurrentTool("select")),!1}function C(){return n.isIn("select")&&n.getSelectedShapeIds().length>0}const E=[{id:"edit-link",label:"action.edit-link",icon:"link",onSelect(I){C()&&(w()||(m("edit-link",{source:I}),n.mark("edit-link"),o({component:OJ})))}},{id:"insert-embed",label:"action.insert-embed",kbd:"$i",onSelect(I){m("insert-embed",{source:I}),o({component:dO})}},{id:"insert-media",label:"action.insert-media",kbd:"$u",onSelect(I){m("insert-media",{source:I}),c()}},{id:"undo",label:"action.undo",icon:"undo",kbd:"$z",onSelect(I){m("undo",{source:I}),n.undo()}},{id:"redo",label:"action.redo",icon:"redo",kbd:"$!z",onSelect(I){m("redo",{source:I}),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(I){let k=n.getSelectedShapeIds();k.length===0&&(k=Array.from(n.getCurrentPageShapeIds().values())),k.length!==0&&(m("export-as",{format:"svg",source:I}),y(k,"svg",wa(n,x)))}},{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(I){let k=n.getSelectedShapeIds();k.length===0&&(k=Array.from(n.getCurrentPageShapeIds().values())),k.length!==0&&(m("export-as",{format:"png",source:I}),y(k,"png",wa(n,x)))}},{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(I){let k=n.getSelectedShapeIds();k.length===0&&(k=Array.from(n.getCurrentPageShapeIds().values())),k.length!==0&&(m("export-as",{format:"json",source:I}),y(k,"json",wa(n,x)))}},{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(I){let k=n.getSelectedShapeIds();k.length===0&&(k=Array.from(n.getCurrentPageShapeIds().values())),k.length!==0&&(m("export-all-as",{format:"svg",source:I}),y(Array.from(n.getCurrentPageShapeIds()),"svg",wa(n,x)))}},{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(I){const k=Array.from(n.getCurrentPageShapeIds().values());k.length!==0&&(m("export-all-as",{format:"png",source:I}),y(k,"png",wa(n,x)))}},{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(I){const k=Array.from(n.getCurrentPageShapeIds().values());k.length!==0&&(m("export-all-as",{format:"json",source:I}),y(k,"json",wa(n,x)))}},{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(I){let k=n.getSelectedShapeIds();k.length===0&&(k=Array.from(n.getCurrentPageShapeIds().values())),k.length!==0&&(m("copy-as",{format:"svg",source:I}),S(k,"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(I){let k=n.getSelectedShapeIds();k.length===0&&(k=Array.from(n.getCurrentPageShapeIds().values())),k.length!==0&&(m("copy-as",{format:"png",source:I}),S(k,"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(I){let k=n.getSelectedShapeIds();k.length===0&&(k=Array.from(n.getCurrentPageShapeIds().values())),k.length!==0&&(m("copy-as",{format:"json",source:I}),S(k,"json"))}},{id:"toggle-auto-size",label:"action.toggle-auto-size",onSelect(I){if(!C()||w())return;m("toggle-auto-size",{source:I}),n.mark("toggling auto size");const k=n.getSelectedShapes().filter(T=>n.isShapeOfType(T,"text")&&T.props.autoSize===!1);n.updateShapes(k.map(T=>({id:T.id,type:T.type,props:{...T.props,w:8,autoSize:!0}}))),Ke(n,k.map(T=>T.id))}},{id:"open-embed-link",label:"action.open-embed-link",readonlyOk:!0,onSelect(I){m("open-embed-link",{source:I});const k=n.getSelectedShapeIds(),T="No embed shapes selected";if(k.length!==1){console.error(T);return}const M=n.getShape(k[0]);if(!M||!n.isShapeOfType(M,"embed")){console.error(T);return}aY(M.props.url,"_blank")}},{id:"select-zoom-tool",readonlyOk:!0,kbd:"z",onSelect(I){var k,T;if(((k=n.root.getCurrent())==null?void 0:k.id)!=="zoom"&&(m("zoom-tool",{source:I}),!(n.inputs.shiftKey||n.inputs.ctrlKey))){const M=n.root.getCurrent();M&&((T=M.getCurrent())==null?void 0:T.id)==="idle"&&n.setCurrentTool("zoom",{onInteractionEnd:M.id,maskAs:"zoom"})}}},{id:"convert-to-bookmark",label:"action.convert-to-bookmark",onSelect(I){C()&&(w()||n.run(()=>{m("convert-to-bookmark",{source:I});const k=n.getSelectedShapes(),T=[],M=[];for(const D of k){if(!D||!n.isShapeOfType(D,"embed")||!D.props.url)continue;const $=new b(D.x,D.y);$.rot(-D.rotation),$.add(new b(D.props.w/2-300/2,D.props.h/2-320/2)),$.rot(D.rotation);const j={id:$e(),type:"bookmark",rotation:D.rotation,x:$.x,y:$.y,opacity:1,props:{url:D.props.url}};T.push(j),M.push(D.id)}n.mark("convert shapes to bookmark"),n.deleteShapes(M),n.createShapes(T)}))}},{id:"convert-to-embed",label:"action.convert-to-embed",onSelect(I){C()&&(w()||(m("convert-to-embed",{source:I}),n.run(()=>{const k=n.getSelectedShapeIds(),T=ye(k.map($=>n.getShape($))),M=[],D=[];for(const $ of T){if(!n.isShapeOfType($,"bookmark"))continue;const{url:j}=$.props,O=Rs($.props.url);if(!O||!O.definition)continue;const{width:R,height:H}=O.definition,B=new b($.x,$.y);B.rot(-$.rotation),B.add(new b($.props.w/2-R/2,$.props.h/2-H/2)),B.rot($.rotation);const z={id:$e(),type:"embed",x:B.x,y:B.y,rotation:$.rotation,props:{url:j,w:R,h:H}};M.push(z),D.push($.id)}n.mark("convert shapes to embed"),n.deleteShapes(D),n.createShapes(M)})))}},{id:"duplicate",kbd:"$d",label:"action.duplicate",icon:"duplicate",onSelect(I){if(!C()||w())return;m("duplicate-shapes",{source:I});const k=n.getInstanceState();let T,M;if(k.duplicateProps)T=k.duplicateProps.shapeIds,M=k.duplicateProps.offset;else{T=n.getSelectedShapeIds();const D=Q.Common(ye(T.map($=>n.getShapePageBounds($))));M=n.getCameraOptions().isLocked?{x:n.options.adjacentShapeMargin,y:n.options.adjacentShapeMargin}:{x:D.width+n.options.adjacentShapeMargin,y:0}}n.mark("duplicate shapes"),n.duplicateShapes(T,M),k.duplicateProps&&n.updateInstanceState({duplicateProps:{...k.duplicateProps,shapeIds:n.getSelectedShapeIds()}})}},{id:"ungroup",label:"action.ungroup",kbd:"$!g",icon:"ungroup",onSelect(I){C()&&(w()||(m("ungroup-shapes",{source:I}),n.mark("ungroup"),n.ungroupShapes(n.getSelectedShapeIds())))}},{id:"group",label:"action.group",kbd:"$g",icon:"group",onSelect(I){if(!C()||w())return;m("group-shapes",{source:I});const k=n.getOnlySelectedShape();k&&n.isShapeOfType(k,"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(I){if(!C())return;m("remove-frame",{source:I});const k=n.getSelectedShapes();k.length>0&&k.every(T=>n.isShapeOfType(T,"frame"))&&(n.mark("remove-frame"),MJ(n,k.map(T=>T.id)))}},{id:"fit-frame-to-content",label:"action.fit-frame-to-content",onSelect(I){if(!C())return;m("fit-frame-to-content",{source:I});const k=n.getOnlySelectedShape();k&&n.isShapeOfType(k,"frame")&&(n.mark("fit-frame-to-content"),jJ(n,k.id))}},{id:"align-left",label:"action.align-left",kbd:"?A",icon:"align-left",onSelect(I){if(!C()||w())return;m("align-shapes",{operation:"left",source:I}),n.mark("align left");const k=n.getSelectedShapeIds();n.alignShapes(k,"left"),Ke(n,k)}},{id:"align-center-horizontal",label:{default:"action.align-center-horizontal","context-menu":"action.align-center-horizontal.short"},kbd:"?H",icon:"align-center-horizontal",onSelect(I){if(!C()||w())return;m("align-shapes",{operation:"center-horizontal",source:I}),n.mark("align center horizontal");const k=n.getSelectedShapeIds();n.alignShapes(k,"center-horizontal"),Ke(n,k)}},{id:"align-right",label:"action.align-right",kbd:"?D",icon:"align-right",onSelect(I){if(!C()||w())return;m("align-shapes",{operation:"right",source:I}),n.mark("align right");const k=n.getSelectedShapeIds();n.alignShapes(k,"right"),Ke(n,k)}},{id:"align-center-vertical",label:{default:"action.align-center-vertical","context-menu":"action.align-center-vertical.short"},kbd:"?V",icon:"align-center-vertical",onSelect(I){if(!C()||w())return;m("align-shapes",{operation:"center-vertical",source:I}),n.mark("align center vertical");const k=n.getSelectedShapeIds();n.alignShapes(k,"center-vertical"),Ke(n,k)}},{id:"align-top",label:"action.align-top",icon:"align-top",kbd:"?W",onSelect(I){if(!C()||w())return;m("align-shapes",{operation:"top",source:I}),n.mark("align top");const k=n.getSelectedShapeIds();n.alignShapes(k,"top"),Ke(n,k)}},{id:"align-bottom",label:"action.align-bottom",icon:"align-bottom",kbd:"?S",onSelect(I){if(!C()||w())return;m("align-shapes",{operation:"bottom",source:I}),n.mark("align bottom");const k=n.getSelectedShapeIds();n.alignShapes(k,"bottom"),Ke(n,k)}},{id:"distribute-horizontal",label:{default:"action.distribute-horizontal","context-menu":"action.distribute-horizontal.short"},icon:"distribute-horizontal",kbd:"?!h",onSelect(I){if(!C()||w())return;m("distribute-shapes",{operation:"horizontal",source:I}),n.mark("distribute horizontal");const k=n.getSelectedShapeIds();n.distributeShapes(k,"horizontal"),Ke(n,k)}},{id:"distribute-vertical",label:{default:"action.distribute-vertical","context-menu":"action.distribute-vertical.short"},icon:"distribute-vertical",kbd:"?!V",onSelect(I){if(!C()||w())return;m("distribute-shapes",{operation:"vertical",source:I}),n.mark("distribute vertical");const k=n.getSelectedShapeIds();n.distributeShapes(k,"vertical"),Ke(n,k)}},{id:"stretch-horizontal",label:{default:"action.stretch-horizontal","context-menu":"action.stretch-horizontal.short"},icon:"stretch-horizontal",onSelect(I){if(!C()||w())return;m("stretch-shapes",{operation:"horizontal",source:I}),n.mark("stretch horizontal");const k=n.getSelectedShapeIds();n.stretchShapes(k,"horizontal"),Ke(n,k)}},{id:"stretch-vertical",label:{default:"action.stretch-vertical","context-menu":"action.stretch-vertical.short"},icon:"stretch-vertical",onSelect(I){if(!C()||w())return;m("stretch-shapes",{operation:"vertical",source:I}),n.mark("stretch vertical");const k=n.getSelectedShapeIds();n.stretchShapes(k,"vertical"),Ke(n,k)}},{id:"flip-horizontal",label:{default:"action.flip-horizontal","context-menu":"action.flip-horizontal.short"},kbd:"!h",onSelect(I){if(!C()||w())return;m("flip-shapes",{operation:"horizontal",source:I}),n.mark("flip horizontal");const k=n.getSelectedShapeIds();n.flipShapes(k,"horizontal"),Ke(n,k)}},{id:"flip-vertical",label:{default:"action.flip-vertical","context-menu":"action.flip-vertical.short"},kbd:"!v",onSelect(I){if(!C()||w())return;m("flip-shapes",{operation:"vertical",source:I}),n.mark("flip vertical");const k=n.getSelectedShapeIds();n.flipShapes(k,"vertical"),Ke(n,k)}},{id:"pack",label:"action.pack",icon:"pack",onSelect(I){if(!C()||w())return;m("pack-shapes",{source:I}),n.mark("pack");const k=n.getSelectedShapeIds();n.packShapes(k,n.options.adjacentShapeMargin),Ke(n,k)}},{id:"stack-vertical",label:{default:"action.stack-vertical","context-menu":"action.stack-vertical.short"},icon:"stack-vertical",onSelect(I){if(!C()||w())return;m("stack-shapes",{operation:"vertical",source:I}),n.mark("stack-vertical");const k=n.getSelectedShapeIds();n.stackShapes(k,"vertical",16),Ke(n,k)}},{id:"stack-horizontal",label:{default:"action.stack-horizontal","context-menu":"action.stack-horizontal.short"},icon:"stack-horizontal",onSelect(I){if(!C()||w())return;m("stack-shapes",{operation:"horizontal",source:I}),n.mark("stack-horizontal");const k=n.getSelectedShapeIds();n.stackShapes(k,"horizontal",16),Ke(n,k)}},{id:"bring-to-front",label:"action.bring-to-front",kbd:"]",icon:"bring-to-front",onSelect(I){C()&&(w()||(m("reorder-shapes",{operation:"toFront",source:I}),n.mark("bring to front"),n.bringToFront(n.getSelectedShapeIds())))}},{id:"bring-forward",label:"action.bring-forward",icon:"bring-forward",kbd:"?]",onSelect(I){C()&&(w()||(m("reorder-shapes",{operation:"forward",source:I}),n.mark("bring forward"),n.bringForward(n.getSelectedShapeIds())))}},{id:"send-backward",label:"action.send-backward",icon:"send-backward",kbd:"?[",onSelect(I){C()&&(w()||(m("reorder-shapes",{operation:"backward",source:I}),n.mark("send backward"),n.sendBackward(n.getSelectedShapeIds())))}},{id:"send-to-back",label:"action.send-to-back",icon:"send-to-back",kbd:"[",onSelect(I){C()&&(w()||(m("reorder-shapes",{operation:"toBack",source:I}),n.mark("send to back"),n.sendToBack(n.getSelectedShapeIds())))}},{id:"cut",label:"action.cut",kbd:"$x",onSelect(I){C()&&(w()||(n.mark("cut"),h(I)))}},{id:"copy",label:"action.copy",kbd:"$c",readonlyOk:!0,onSelect(I){C()&&(w()||p(I))}},{id:"paste",label:"action.paste",kbd:"$v",onSelect(I){var k;(k=navigator.clipboard)==null||k.read().then(T=>{f(T,I,I==="context-menu"?n.inputs.currentPagePoint:void 0)}).catch(()=>{a({title:l("action.paste-error-title"),description:l("action.paste-error-description"),severity:"error"})})}},{id:"select-all",label:"action.select-all",kbd:"$a",readonlyOk:!0,onSelect(I){n.run(()=>{w()||(m("select-all-shapes",{source:I}),n.mark("select all kbd"),n.selectAll())})}},{id:"select-none",label:"action.select-none",readonlyOk:!0,onSelect(I){C()&&(w()||(m("select-none-shapes",{source:I}),n.mark("select none"),n.selectNone()))}},{id:"delete",label:"action.delete",kbd:"⌫,del,backspace",icon:"trash",onSelect(I){C()&&(w()||(m("delete-shapes",{source:I}),n.mark("delete"),n.deleteShapes(n.getSelectedShapeIds())))}},{id:"rotate-cw",label:"action.rotate-cw",icon:"rotate-cw",onSelect(I){if(!C()||w())return;m("rotate-cw",{source:I}),n.mark("rotate-cw");const k=n.getSelectionRotation()%(Ve/2),T=$s(k,0)||$s(k,Ve/2),M=n.getSelectedShapeIds();n.rotateShapesBy(M,Ve/2-(T?0:k)),Ke(n,M)}},{id:"rotate-ccw",label:"action.rotate-ccw",icon:"rotate-ccw",onSelect(I){if(!C()||w())return;m("rotate-ccw",{source:I}),n.mark("rotate-ccw");const k=n.getSelectionRotation()%(Ve/2),T=$s(k,0),M=n.getSelectedShapeIds();n.rotateShapesBy(M,T?-(Ve/2):-k),Ke(n,M)}},{id:"zoom-in",label:"action.zoom-in",kbd:"$=,=",readonlyOk:!0,onSelect(I){m("zoom-in",{source:I}),n.zoomIn(void 0,{animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-out",label:"action.zoom-out",kbd:"$-,-",readonlyOk:!0,onSelect(I){m("zoom-out",{source:I}),n.zoomOut(void 0,{animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-to-100",label:"action.zoom-to-100",icon:"reset-zoom",kbd:"!0",readonlyOk:!0,onSelect(I){m("reset-zoom",{source:I}),n.resetZoom(void 0,{animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-to-fit",label:"action.zoom-to-fit",kbd:"!1",readonlyOk:!0,onSelect(I){m("zoom-to-fit",{source:I}),n.zoomToFit({animation:{duration:n.options.animationMediumMs}})}},{id:"zoom-to-selection",label:"action.zoom-to-selection",kbd:"!2",readonlyOk:!0,onSelect(I){C()&&(w()||(m("zoom-to-selection",{source:I}),n.zoomToSelection({animation:{duration:n.options.animationMediumMs}})))}},{id:"toggle-snap-mode",label:{default:"action.toggle-snap-mode",menu:"action.toggle-snap-mode.menu"},onSelect(I){m("toggle-snap-mode",{source:I}),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(I){const k=n.user.getIsDarkMode()?"light":"dark";m("color-scheme",{source:I,value:k}),n.user.updateUserPreferences({colorScheme:k})},checkbox:!0},{id:"toggle-wrap-mode",label:{default:"action.toggle-wrap-mode",menu:"action.toggle-wrap-mode.menu"},readonlyOk:!0,onSelect(I){m("toggle-wrap-mode",{source:I}),n.user.updateUserPreferences({isWrapMode:!n.user.getIsWrapMode()})},checkbox:!0},{id:"toggle-dynamic-size-mode",label:{default:"action.toggle-dynamic-size-mode",menu:"action.toggle-dynamic-size-mode.menu"},readonlyOk:!1,onSelect(I){m("toggle-dynamic-size-mode",{source:I}),n.user.updateUserPreferences({isDynamicSizeMode:!n.user.getIsDynamicResizeMode()})},checkbox:!0},{id:"toggle-paste-at-cursor",label:{default:"action.toggle-paste-at-cursor",menu:"action.toggle-paste-at-cursor.menu"},readonlyOk:!1,onSelect(I){m("toggle-paste-at-cursor",{source:I}),n.user.updateUserPreferences({isPasteAtCursorMode:!n.user.getIsPasteAtCursorMode()})},checkbox:!0},{id:"toggle-reduce-motion",label:{default:"action.toggle-reduce-motion",menu:"action.toggle-reduce-motion.menu"},readonlyOk:!0,onSelect(I){m("toggle-reduce-motion",{source:I}),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(I){m("toggle-edge-scrolling",{source:I}),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(I){m("toggle-transparent",{source:I}),n.updateInstanceState({exportBackground:!n.getInstanceState().exportBackground})},checkbox:!0},{id:"toggle-tool-lock",label:{default:"action.toggle-tool-lock",menu:"action.toggle-tool-lock.menu"},kbd:"q",onSelect(I){m("toggle-tool-lock",{source:I}),n.updateInstanceState({isToolLocked:!n.getInstanceState().isToolLocked})},checkbox:!0},{id:"unlock-all",label:"action.unlock-all",onSelect(I){m("unlock-all",{source:I});const k=[];for(const T of n.getCurrentPageShapes())T.isLocked&&k.push({id:T.id,type:T.type,isLocked:!1});k.length>0&&n.updateShapes(k)}},{id:"toggle-focus-mode",label:{default:"action.toggle-focus-mode",menu:"action.toggle-focus-mode.menu"},readonlyOk:!0,kbd:"$.",checkbox:!0,onSelect(I){n.timers.requestAnimationFrame(()=>{n.run(()=>{m("toggle-focus-mode",{source:I}),s(),i(),n.updateInstanceState({isFocusMode:!n.getInstanceState().isFocusMode})})})}},{id:"toggle-grid",label:{default:"action.toggle-grid",menu:"action.toggle-grid.menu"},readonlyOk:!0,kbd:"$'",onSelect(I){m("toggle-grid-mode",{source:I}),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(I){m("toggle-debug-mode",{source:I}),n.updateInstanceState({isDebugMode:!n.getInstanceState().isDebugMode})},checkbox:!0},{id:"print",label:"action.print",kbd:"$p",readonlyOk:!0,onSelect(I){m("print",{source:I}),u()}},{id:"exit-pen-mode",label:"action.exit-pen-mode",icon:"cross-2",readonlyOk:!0,onSelect(I){m("exit-pen-mode",{source:I}),n.updateInstanceState({isPenMode:!1})}},{id:"stop-following",label:"action.stop-following",icon:"cross-2",readonlyOk:!0,onSelect(I){m("stop-following",{source:I}),n.stopFollowingUser()}},{id:"back-to-content",label:"action.back-to-content",icon:"arrow-left",readonlyOk:!0,onSelect(I){m("zoom-to-content",{source:I});const k=n.getSelectionPageBounds()??n.getCurrentPageBounds();k&&n.zoomToBounds(k,{targetZoom:Math.min(1,n.getZoomLevel()),animation:{duration:220}})}},{id:"toggle-lock",label:"action.toggle-lock",kbd:"!l",onSelect(I){n.mark("locking"),m("toggle-lock",{source:I}),n.toggleLock(n.getSelectedShapeIds())}},{id:"move-to-new-page",label:"context.pages.new-page",onSelect(I){const k=Jo.createId(),T=n.getSelectedShapeIds();n.run(()=>{n.mark("move_shapes_to_page"),n.createPage({name:l("page-menu.new-page-initial-name"),id:k}),n.moveShapesToPage(T,k)}),m("move-to-new-page",{source:I})}},{id:"select-white-color",label:"color-style.white",kbd:"?t",onSelect(I){const k=cr;n.run(()=>{n.mark("change-color"),n.isIn("select")&&n.setStyleForSelectedShapes(k,"white"),n.setStyleForNextShapes(k,"white")}),m("set-style",{source:I,id:k.id,value:"white"})}},{id:"select-fill-fill",label:"fill-style.fill",kbd:"?f",onSelect(I){const k=Fi;n.run(()=>{n.mark("change-fill"),n.isIn("select")&&n.setStyleForSelectedShapes(k,"fill"),n.setStyleForNextShapes(k,"fill")}),m("set-style",{source:I,id:k.id,value:"fill"})}},{id:"flatten-to-image",label:"action.flatten-to-image",kbd:"!f",onSelect:async I=>{const k=n.getSelectedShapeIds();if(k.length===0)return;n.mark("flattening to image"),m("flatten-to-image",{source:I});const T=await hee(n,k,n.options.flattenImageBoundsExpand);T!=null&&T.length&&n.setSelectedShapes(T)}}];r&&E.push({id:"open-cursor-chat",label:"action.open-cursor-chat",readonlyOk:!0,kbd:"/",onSelect(I){m("open-cursor-chat",{source:I}),!n.getInstanceState().isCoarsePointer&&n.timers.requestAnimationFrame(()=>{n.updateInstanceState({isChatting:!0})})}});const _=gee(E);return e?e(n,_,void 0):_},[n,m,e,o,a,c,y,S,h,p,f,s,i,u,l,x,r]);return d.jsx(bO.Provider,{value:v,children:t})}function ae(){const e=P.useContext(bO);if(!e)throw new Error("useTools must be used within a ToolProvider");return e}function ku(e,t){return e?typeof e=="string"?e:t?e[t]??e.default:void 0:void 0}const yee=["top","right","bottom","left"],go=Math.min,er=Math.max,Ef=Math.round,Sh=Math.floor,Js=e=>({x:e,y:e}),See={left:"right",right:"left",bottom:"top",top:"bottom"},vee={start:"end",end:"start"};function Qv(e,t,n){return er(e,go(t,n))}function ss(e,t){return typeof e=="function"?e(t):e}function is(e){return e.split("-")[0]}function Rl(e){return e.split("-")[1]}function Nw(e){return e==="x"?"y":"x"}function Fw(e){return e==="y"?"height":"width"}function ei(e){return["top","bottom"].includes(is(e))?"y":"x"}function zw(e){return Nw(ei(e))}function xee(e,t,n){n===void 0&&(n=!1);const r=Rl(e),o=zw(e),s=Fw(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=kf(i)),[i,kf(i)]}function wee(e){const t=kf(e);return[Jv(e),t,Jv(t)]}function Jv(e){return e.replace(/start|end/g,t=>vee[t])}function bee(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 Pee(e,t,n,r){const o=Rl(e);let s=bee(is(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Jv)))),s}function kf(e){return e.replace(/left|right|bottom|top/g,t=>See[t])}function Cee(e){return{top:0,right:0,bottom:0,left:0,...e}}function PO(e){return typeof e!="number"?Cee(e):{top:e,right:e,bottom:e,left:e}}function _f(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 oE(e,t,n){let{reference:r,floating:o}=e;const s=ei(t),i=zw(t),a=Fw(i),l=is(t),c=s==="y",u=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let f;switch(l){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:h};break;case"left":f={x:r.x-o.width,y:h};break;default:f={x:r.x,y:r.y}}switch(Rl(t)){case"start":f[i]-=p*(n&&c?-1:1);break;case"end":f[i]+=p*(n&&c?-1:1);break}return f}const Iee=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:h}=oE(c,r,l),p=r,f={},S=0;for(let y=0;y<a.length;y++){const{name:x,fn:m}=a[y],{x:v,y:w,data:C,reset:E}=await m({x:u,y:h,initialPlacement:r,placement:p,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});u=v??u,h=w??h,f={...f,[x]:{...f[x],...C}},E&&S<=50&&(S++,typeof E=="object"&&(E.placement&&(p=E.placement),E.rects&&(c=E.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):E.rects),{x:u,y:h}=oE(c,p,l)),y=-1)}return{x:u,y:h,placement:p,strategy:o,middlewareData:f}};async function _u(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:p=!1,padding:f=0}=ss(t,e),S=PO(f),x=a[p?h==="floating"?"reference":"floating":h],m=_f(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,w=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),C=await(s.isElement==null?void 0:s.isElement(w))?await(s.getScale==null?void 0:s.getScale(w))||{x:1,y:1}:{x:1,y:1},E=_f(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:w,strategy:l}):v);return{top:(m.top-E.top+S.top)/C.y,bottom:(E.bottom-m.bottom+S.bottom)/C.y,left:(m.left-E.left+S.left)/C.x,right:(E.right-m.right+S.right)/C.x}}const Eee=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=ss(e,t)||{};if(c==null)return{};const h=PO(u),p={x:n,y:r},f=zw(o),S=Fw(f),y=await i.getDimensions(c),x=f==="y",m=x?"top":"left",v=x?"bottom":"right",w=x?"clientHeight":"clientWidth",C=s.reference[S]+s.reference[f]-p[f]-s.floating[S],E=p[f]-s.reference[f],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let I=_?_[w]:0;(!I||!await(i.isElement==null?void 0:i.isElement(_)))&&(I=a.floating[w]||s.floating[S]);const k=C/2-E/2,T=I/2-y[S]/2-1,M=go(h[m],T),D=go(h[v],T),$=M,j=I-y[S]-D,O=I/2-y[S]/2+k,R=Qv($,O,j),H=!l.arrow&&Rl(o)!=null&&O!==R&&s.reference[S]/2-(O<$?M:D)-y[S]/2<0,B=H?O<$?O-$:O-j:0;return{[f]:p[f]+B,data:{[f]:R,centerOffset:O-R-B,...H&&{alignmentOffset:B}},reset:H}}}),kee=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:l,elements:c}=t,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:S="none",flipAlignment:y=!0,...x}=ss(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const m=is(o),v=ei(a),w=is(a)===a,C=await(l.isRTL==null?void 0:l.isRTL(c.floating)),E=p||(w||!y?[kf(a)]:wee(a)),_=S!=="none";!p&&_&&E.push(...Pee(a,y,S,C));const I=[a,...E],k=await _u(t,x),T=[];let M=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&T.push(k[m]),h){const O=xee(o,i,C);T.push(k[O[0]],k[O[1]])}if(M=[...M,{placement:o,overflows:T}],!T.every(O=>O<=0)){var D,$;const O=(((D=s.flip)==null?void 0:D.index)||0)+1,R=I[O];if(R)return{data:{index:O,overflows:M},reset:{placement:R}};let H=($=M.filter(B=>B.overflows[0]<=0).sort((B,z)=>B.overflows[1]-z.overflows[1])[0])==null?void 0:$.placement;if(!H)switch(f){case"bestFit":{var j;const B=(j=M.filter(z=>{if(_){const W=ei(z.placement);return W===v||W==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(W=>W>0).reduce((W,Y)=>W+Y,0)]).sort((z,W)=>z[1]-W[1])[0])==null?void 0:j[0];B&&(H=B);break}case"initialPlacement":H=a;break}if(o!==H)return{reset:{placement:H}}}return{}}}};function sE(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function iE(e){return yee.some(t=>e[t]>=0)}const _ee=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=ss(e,t);switch(r){case"referenceHidden":{const s=await _u(t,{...o,elementContext:"reference"}),i=sE(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:iE(i)}}}case"escaped":{const s=await _u(t,{...o,altBoundary:!0}),i=sE(s,n.floating);return{data:{escapedOffsets:i,escaped:iE(i)}}}default:return{}}}}};async function Tee(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=is(n),a=Rl(n),l=ei(n)==="y",c=["left","top"].includes(i)?-1:1,u=s&&l?-1:1,h=ss(t,e);let{mainAxis:p,crossAxis:f,alignmentAxis:S}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...h};return a&&typeof S=="number"&&(f=a==="end"?S*-1:S),l?{x:f*u,y:p*c}:{x:p*c,y:f*u}}const Mee=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,l=await Tee(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},Aee=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:x=>{let{x:m,y:v}=x;return{x:m,y:v}}},...l}=ss(e,t),c={x:n,y:r},u=await _u(t,l),h=ei(is(o)),p=Nw(h);let f=c[p],S=c[h];if(s){const x=p==="y"?"top":"left",m=p==="y"?"bottom":"right",v=f+u[x],w=f-u[m];f=Qv(v,f,w)}if(i){const x=h==="y"?"top":"left",m=h==="y"?"bottom":"right",v=S+u[x],w=S-u[m];S=Qv(v,S,w)}const y=a.fn({...t,[p]:f,[h]:S});return{...y,data:{x:y.x-n,y:y.y-r}}}}},jee=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:l=!0,crossAxis:c=!0}=ss(e,t),u={x:n,y:r},h=ei(o),p=Nw(h);let f=u[p],S=u[h];const y=ss(a,t),x=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const w=p==="y"?"height":"width",C=s.reference[p]-s.floating[w]+x.mainAxis,E=s.reference[p]+s.reference[w]-x.mainAxis;f<C?f=C:f>E&&(f=E)}if(c){var m,v;const w=p==="y"?"width":"height",C=["top","left"].includes(is(o)),E=s.reference[h]-s.floating[w]+(C&&((m=i.offset)==null?void 0:m[h])||0)+(C?0:x.crossAxis),_=s.reference[h]+s.reference[w]+(C?0:((v=i.offset)==null?void 0:v[h])||0)-(C?x.crossAxis:0);S<E?S=E:S>_&&(S=_)}return{[p]:f,[h]:S}}}},Oee=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}=ss(e,t),l=await _u(t,a),c=is(n),u=Rl(n),h=ei(n)==="y",{width:p,height:f}=r.floating;let S,y;c==="top"||c==="bottom"?(S=c,y=u===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(y=c,S=u==="end"?"top":"bottom");const x=f-l.top-l.bottom,m=p-l.left-l.right,v=go(f-l[S],x),w=go(p-l[y],m),C=!t.middlewareData.shift;let E=v,_=w;if(h?_=u||C?go(w,m):m:E=u||C?go(v,x):x,C&&!u){const k=er(l.left,0),T=er(l.right,0),M=er(l.top,0),D=er(l.bottom,0);h?_=p-2*(k!==0||T!==0?k+T:er(l.left,l.right)):E=f-2*(M!==0||D!==0?M+D:er(l.top,l.bottom))}await i({...t,availableWidth:_,availableHeight:E});const I=await o.getDimensions(s.floating);return p!==I.width||f!==I.height?{reset:{rects:!0}}:{}}}};function Ll(e){return CO(e)?(e.nodeName||"").toLowerCase():"#document"}function ar(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function hs(e){var t;return(t=(CO(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function CO(e){return e instanceof Node||e instanceof ar(e).Node}function Yr(e){return e instanceof Element||e instanceof ar(e).Element}function ko(e){return e instanceof HTMLElement||e instanceof ar(e).HTMLElement}function aE(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ar(e).ShadowRoot}function od(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Xr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Dee(e){return["table","td","th"].includes(Ll(e))}function Rg(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function Bw(e){const t=Uw(),n=Yr(e)?Xr(e):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 Ree(e){let t=ti(e);for(;ko(t)&&!xl(t);){if(Bw(t))return t;if(Rg(t))return null;t=ti(t)}return null}function Uw(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function xl(e){return["html","body","#document"].includes(Ll(e))}function Xr(e){return ar(e).getComputedStyle(e)}function Lg(e){return Yr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ti(e){if(Ll(e)==="html")return e;const t=e.assignedSlot||e.parentNode||aE(e)&&e.host||hs(e);return aE(t)?t.host:t}function IO(e){const t=ti(e);return xl(t)?e.ownerDocument?e.ownerDocument.body:e.body:ko(t)&&od(t)?t:IO(t)}function Tu(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=IO(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=ar(o);if(s){const a=ex(i);return t.concat(i,i.visualViewport||[],od(o)?o:[],a&&n?Tu(a):[])}return t.concat(o,Tu(o,[],n))}function ex(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function EO(e){const t=Xr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=ko(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ef(n)!==s||Ef(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Hw(e){return Yr(e)?e:e.contextElement}function ol(e){const t=Hw(e);if(!ko(t))return Js(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=EO(t);let i=(s?Ef(n.width):n.width)/r,a=(s?Ef(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Lee=Js(0);function kO(e){const t=ar(e);return!Uw()||!t.visualViewport?Lee:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $ee(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ar(e)?!1:t}function qi(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Hw(e);let i=Js(1);t&&(r?Yr(r)&&(i=ol(r)):i=ol(e));const a=$ee(s,n,r)?kO(s):Js(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,h=o.height/i.y;if(s){const p=ar(s),f=r&&Yr(r)?ar(r):r;let S=p,y=ex(S);for(;y&&r&&f!==S;){const x=ol(y),m=y.getBoundingClientRect(),v=Xr(y),w=m.left+(y.clientLeft+parseFloat(v.paddingLeft))*x.x,C=m.top+(y.clientTop+parseFloat(v.paddingTop))*x.y;l*=x.x,c*=x.y,u*=x.x,h*=x.y,l+=w,c+=C,S=ar(y),y=ex(S)}}return _f({width:u,height:h,x:l,y:c})}function Nee(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=hs(r),a=t?Rg(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Js(1);const u=Js(0),h=ko(r);if((h||!h&&!s)&&((Ll(r)!=="body"||od(i))&&(l=Lg(r)),ko(r))){const p=qi(r);c=ol(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x,y:n.y*c.y-l.scrollTop*c.y+u.y}}function Fee(e){return Array.from(e.getClientRects())}function _O(e){return qi(hs(e)).left+Lg(e).scrollLeft}function zee(e){const t=hs(e),n=Lg(e),r=e.ownerDocument.body,o=er(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=er(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+_O(e);const a=-n.scrollTop;return Xr(r).direction==="rtl"&&(i+=er(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function Bee(e,t){const n=ar(e),r=hs(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const c=Uw();(!c||c&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a,y:l}}function Uee(e,t){const n=qi(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=ko(e)?ol(e):Js(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function lE(e,t,n){let r;if(t==="viewport")r=Bee(e,n);else if(t==="document")r=zee(hs(e));else if(Yr(t))r=Uee(t,n);else{const o=kO(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return _f(r)}function TO(e,t){const n=ti(e);return n===t||!Yr(n)||xl(n)?!1:Xr(n).position==="fixed"||TO(n,t)}function Hee(e,t){const n=t.get(e);if(n)return n;let r=Tu(e,[],!1).filter(a=>Yr(a)&&Ll(a)!=="body"),o=null;const s=Xr(e).position==="fixed";let i=s?ti(e):e;for(;Yr(i)&&!xl(i);){const a=Xr(i),l=Bw(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||od(i)&&!l&&TO(e,i))?r=r.filter(u=>u!==i):o=a,i=ti(i)}return t.set(e,r),r}function Kee(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Rg(t)?[]:Hee(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const h=lE(t,u,o);return c.top=er(h.top,c.top),c.right=go(h.right,c.right),c.bottom=go(h.bottom,c.bottom),c.left=er(h.left,c.left),c},lE(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Wee(e){const{width:t,height:n}=EO(e);return{width:t,height:n}}function Gee(e,t,n){const r=ko(t),o=hs(t),s=n==="fixed",i=qi(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Js(0);if(r||!r&&!s)if((Ll(t)!=="body"||od(o))&&(a=Lg(t)),r){const h=qi(t,!0,s,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&(l.x=_O(o));const c=i.left+a.scrollLeft-l.x,u=i.top+a.scrollTop-l.y;return{x:c,y:u,width:i.width,height:i.height}}function Oy(e){return Xr(e).position==="static"}function cE(e,t){return!ko(e)||Xr(e).position==="fixed"?null:t?t(e):e.offsetParent}function MO(e,t){const n=ar(e);if(Rg(e))return n;if(!ko(e)){let o=ti(e);for(;o&&!xl(o);){if(Yr(o)&&!Oy(o))return o;o=ti(o)}return n}let r=cE(e,t);for(;r&&Dee(r)&&Oy(r);)r=cE(r,t);return r&&xl(r)&&Oy(r)&&!Bw(r)?n:r||Ree(e)||n}const Vee=async function(e){const t=this.getOffsetParent||MO,n=this.getDimensions,r=await n(e.floating);return{reference:Gee(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Yee(e){return Xr(e).direction==="rtl"}const Xee={convertOffsetParentRelativeRectToViewportRelativeRect:Nee,getDocumentElement:hs,getClippingRect:Kee,getOffsetParent:MO,getElementRects:Vee,getClientRects:Fee,getDimensions:Wee,getScale:ol,isElement:Yr,isRTL:Yee};function qee(e,t){let n=null,r;const o=hs(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const{left:c,top:u,width:h,height:p}=e.getBoundingClientRect();if(a||t(),!h||!p)return;const f=Sh(u),S=Sh(o.clientWidth-(c+h)),y=Sh(o.clientHeight-(u+p)),x=Sh(c),v={rootMargin:-f+"px "+-S+"px "+-y+"px "+-x+"px",threshold:er(0,go(1,l))||1};let w=!0;function C(E){const _=E[0].intersectionRatio;if(_!==l){if(!w)return i();_?i(!1,_):r=setTimeout(()=>{i(!1,1e-7)},1e3)}w=!1}try{n=new IntersectionObserver(C,{...v,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,v)}n.observe(e)}return i(!0),s}function Zee(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:l=!1}=r,c=Hw(e),u=o||s?[...c?Tu(c):[],...Tu(t)]:[];u.forEach(m=>{o&&m.addEventListener("scroll",n,{passive:!0}),s&&m.addEventListener("resize",n)});const h=c&&a?qee(c,n):null;let p=-1,f=null;i&&(f=new ResizeObserver(m=>{let[v]=m;v&&v.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=f)==null||w.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let S,y=l?qi(e):null;l&&x();function x(){const m=qi(e);y&&(m.x!==y.x||m.y!==y.y||m.width!==y.width||m.height!==y.height)&&n(),y=m,S=requestAnimationFrame(x)}return n(),()=>{var m;u.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),h==null||h(),(m=f)==null||m.disconnect(),f=null,l&&cancelAnimationFrame(S)}}const Qee=Mee,Jee=Aee,ete=kee,tte=Oee,nte=_ee,uE=Eee,rte=jee,ote=(e,t,n)=>{const r=new Map,o={platform:Xee,...n},s={...o.platform,_c:r};return Iee(e,t,{...o,platform:s})};var yp=typeof document<"u"?P.useLayoutEffect:P.useEffect;function Tf(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(!Tf(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)&&!Tf(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function AO(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function dE(e,t){const n=AO(e);return Math.round(t*n)/n}function hE(e){const t=P.useRef(e);return yp(()=>{t.current=e}),t}function ste(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:l,open:c}=e,[u,h]=P.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,f]=P.useState(r);Tf(p,r)||f(r);const[S,y]=P.useState(null),[x,m]=P.useState(null),v=P.useCallback(B=>{B!==_.current&&(_.current=B,y(B))},[]),w=P.useCallback(B=>{B!==I.current&&(I.current=B,m(B))},[]),C=s||S,E=i||x,_=P.useRef(null),I=P.useRef(null),k=P.useRef(u),T=l!=null,M=hE(l),D=hE(o),$=P.useCallback(()=>{if(!_.current||!I.current)return;const B={placement:t,strategy:n,middleware:p};D.current&&(B.platform=D.current),ote(_.current,I.current,B).then(z=>{const W={...z,isPositioned:!0};j.current&&!Tf(k.current,W)&&(k.current=W,ia.flushSync(()=>{h(W)}))})},[p,t,n,D]);yp(()=>{c===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,h(B=>({...B,isPositioned:!1})))},[c]);const j=P.useRef(!1);yp(()=>(j.current=!0,()=>{j.current=!1}),[]),yp(()=>{if(C&&(_.current=C),E&&(I.current=E),C&&E){if(M.current)return M.current(C,E,$);$()}},[C,E,$,M,T]);const O=P.useMemo(()=>({reference:_,floating:I,setReference:v,setFloating:w}),[v,w]),R=P.useMemo(()=>({reference:C,floating:E}),[C,E]),H=P.useMemo(()=>{const B={position:n,left:0,top:0};if(!R.floating)return B;const z=dE(R.floating,u.x),W=dE(R.floating,u.y);return a?{...B,transform:"translate("+z+"px, "+W+"px)",...AO(R.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:W}},[n,a,R.floating,u.x,u.y]);return P.useMemo(()=>({...u,update:$,refs:O,elements:R,floatingStyles:H}),[u,$,O,R,H])}const ite=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?uE({element:r.current,padding:o}).fn(n):{}:r?uE({element:r,padding:o}).fn(n):{}}}},ate=(e,t)=>({...Qee(e),options:[e,t]}),lte=(e,t)=>({...Jee(e),options:[e,t]}),cte=(e,t)=>({...rte(e),options:[e,t]}),ute=(e,t)=>({...ete(e),options:[e,t]}),dte=(e,t)=>({...tte(e),options:[e,t]}),hte=(e,t)=>({...nte(e),options:[e,t]}),pte=(e,t)=>({...ite(e),options:[e,t]});var fte="Arrow",jO=P.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return d.jsx(_e.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});jO.displayName=fte;var gte=jO;function OO(e){const[t,n]=P.useState(void 0);return Qs(()=>{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 l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.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}var Kw="Popper",[DO,$g]=Ao(Kw),[mte,RO]=DO(Kw),LO=e=>{const{__scopePopper:t,children:n}=e,[r,o]=P.useState(null);return d.jsx(mte,{scope:t,anchor:r,onAnchorChange:o,children:n})};LO.displayName=Kw;var $O="PopperAnchor",NO=P.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=RO($O,n),i=P.useRef(null),a=qe(t,i);return P.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:d.jsx(_e.div,{...o,ref:a})});NO.displayName=$O;var Ww="PopperContent",[yte,Ste]=DO(Ww),FO=P.forwardRef((e,t)=>{var Oe,nt,je,it,Fe,Xn;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:f="optimized",onPlaced:S,...y}=e,x=RO(Ww,n),[m,v]=P.useState(null),w=qe(t,Nt=>v(Nt)),[C,E]=P.useState(null),_=OO(C),I=(_==null?void 0:_.width)??0,k=(_==null?void 0:_.height)??0,T=r+(s!=="center"?"-"+s:""),M=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],$=D.length>0,j={padding:M,boundary:D.filter(xte),altBoundary:$},{refs:O,floatingStyles:R,placement:H,isPositioned:B,middlewareData:z}=ste({strategy:"fixed",placement:T,whileElementsMounted:(...Nt)=>Zee(...Nt,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[ate({mainAxis:o+k,alignmentAxis:i}),l&<e({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?cte():void 0,...j}),l&&ute({...j}),dte({...j,apply:({elements:Nt,rects:Tn,availableWidth:St,availableHeight:Qt})=>{const{width:jo,height:Nl}=Tn.reference,ms=Nt.floating.style;ms.setProperty("--radix-popper-available-width",`${St}px`),ms.setProperty("--radix-popper-available-height",`${Qt}px`),ms.setProperty("--radix-popper-anchor-width",`${jo}px`),ms.setProperty("--radix-popper-anchor-height",`${Nl}px`)}}),C&&pte({element:C,padding:a}),wte({arrowWidth:I,arrowHeight:k}),p&&hte({strategy:"referenceHidden",...j})]}),[W,Y]=UO(H),q=Xt(S);Qs(()=>{B&&(q==null||q())},[B,q]);const le=(Oe=z.arrow)==null?void 0:Oe.x,ge=(nt=z.arrow)==null?void 0:nt.y,be=((je=z.arrow)==null?void 0:je.centerOffset)!==0,[J,Ue]=P.useState();return Qs(()=>{m&&Ue(window.getComputedStyle(m).zIndex)},[m]),d.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...R,transform:B?R.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(it=z.transformOrigin)==null?void 0:it.x,(Fe=z.transformOrigin)==null?void 0:Fe.y].join(" "),...((Xn=z.hide)==null?void 0:Xn.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(yte,{scope:n,placedSide:W,onArrowChange:E,arrowX:le,arrowY:ge,shouldHideArrow:be,children:d.jsx(_e.div,{"data-side":W,"data-align":Y,...y,ref:w,style:{...y.style,animation:B?void 0:"none"}})})})});FO.displayName=Ww;var zO="PopperArrow",vte={top:"bottom",right:"left",bottom:"top",left:"right"},BO=P.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Ste(zO,r),i=vte[s.placedSide];return d.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:d.jsx(gte,{...o,ref:n,style:{...o.style,display:"block"}})})});BO.displayName=zO;function xte(e){return e!==null}var wte=e=>({name:"transformOrigin",options:e,fn(t){var x,m,v;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,u]=UO(n),h={start:"0%",center:"50%",end:"100%"}[u],p=(((m=o.arrow)==null?void 0:m.x)??0)+a/2,f=(((v=o.arrow)==null?void 0:v.y)??0)+l/2;let S="",y="";return c==="bottom"?(S=i?h:`${p}px`,y=`${-l}px`):c==="top"?(S=i?h:`${p}px`,y=`${r.floating.height+l}px`):c==="right"?(S=`${-l}px`,y=i?h:`${f}px`):c==="left"&&(S=`${r.floating.width+l}px`,y=i?h:`${f}px`),{data:{x:S,y}}}});function UO(e){const[t,n="center"]=e.split("-");return[t,n]}var Gw=LO,Vw=NO,HO=FO,KO=BO,Yw="Popover",[WO,Lae]=Ao(Yw,[$g]),sd=$g(),[bte,di]=WO(Yw),GO=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=sd(t),l=P.useRef(null),[c,u]=P.useState(!1),[h=!1,p]=ui({prop:r,defaultProp:o,onChange:s});return d.jsx(Gw,{...a,children:d.jsx(bte,{scope:t,contentId:Zo(),triggerRef:l,open:h,onOpenChange:p,onOpenToggle:P.useCallback(()=>p(f=>!f),[p]),hasCustomAnchor:c,onCustomAnchorAdd:P.useCallback(()=>u(!0),[]),onCustomAnchorRemove:P.useCallback(()=>u(!1),[]),modal:i,children:n})})};GO.displayName=Yw;var VO="PopoverAnchor",Pte=P.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=di(VO,n),s=sd(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return P.useEffect(()=>(i(),()=>a()),[i,a]),d.jsx(Vw,{...s,...r,ref:t})});Pte.displayName=VO;var YO="PopoverTrigger",XO=P.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=di(YO,n),s=sd(n),i=qe(t,o.triggerRef),a=d.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":eD(o.open),...r,ref:i,onClick:re(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:d.jsx(Vw,{asChild:!0,...s,children:a})});XO.displayName=YO;var Xw="PopoverPortal",[Cte,Ite]=WO(Xw,{forceMount:void 0}),qO=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=di(Xw,t);return d.jsx(Cte,{scope:t,forceMount:n,children:d.jsx(Qr,{present:n||s.open,children:d.jsx(rd,{asChild:!0,container:o,children:r})})})};qO.displayName=Xw;var wl="PopoverContent",ZO=P.forwardRef((e,t)=>{const n=Ite(wl,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=di(wl,e.__scopePopover);return d.jsx(Qr,{present:r||s.open,children:s.modal?d.jsx(Ete,{...o,ref:t}):d.jsx(kte,{...o,ref:t})})});ZO.displayName=wl;var Ete=P.forwardRef((e,t)=>{const n=di(wl,e.__scopePopover),r=P.useRef(null),o=qe(t,r),s=P.useRef(!1);return P.useEffect(()=>{const i=r.current;if(i)return kw(i)},[]),d.jsx(Ig,{as:Yi,allowPinchZoom:!0,children:d.jsx(QO,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:re(e.onCloseAutoFocus,i=>{var a;i.preventDefault(),s.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:re(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:re(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),kte=P.forwardRef((e,t)=>{const n=di(wl,e.__scopePopover),r=P.useRef(!1),o=P.useRef(!1);return d.jsx(QO,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),QO=P.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...h}=e,p=di(wl,n),f=sd(n);return Ew(),d.jsx(Pg,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:d.jsx(nd,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>p.onOpenChange(!1),children:d.jsx(HO,{"data-state":eD(p.open),role:"dialog",id:p.contentId,...f,...h,ref:t,style:{...h.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)"}})})})}),JO="PopoverClose",_te=P.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=di(JO,n);return d.jsx(_e.button,{type:"button",...r,ref:t,onClick:re(e.onClick,()=>o.onOpenChange(!1))})});_te.displayName=JO;var Tte="PopoverArrow",Mte=P.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=sd(n);return d.jsx(KO,{...o,...r,ref:t})});Mte.displayName=Tte;function eD(e){return e?"open":"closed"}var qw=GO,Zw=XO,Qw=qO,Jw=ZO;function ps(e,t){const n=F(),r=P.useRef(!1),o=Zt(),s=P.useCallback(a=>{r.current=a,n.run(()=>{a?(n.complete(),n.addOpenMenu(e)):n.updateInstanceState({openMenus:n.getOpenMenus().filter(l=>!l.startsWith(e))}),t==null||t(a)})},[n,e,t]),i=K("is menu open",()=>n.getOpenMenus().includes(e),[n,e]);return P.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 e1({id:e,children:t,onOpenChange:n,open:r}){const[o,s]=ps(e,n);return d.jsx(qw,{onOpenChange:s,open:r||o,children:d.jsx("div",{className:"tlui-popover",children:t})})}function t1({children:e}){return d.jsx(Zw,{asChild:!0,dir:"ltr",children:e})}function n1({side:e,children:t,align:n="center",sideOffset:r=8,alignOffset:o=0}){const s=$t();return d.jsx(Qw,{container:s,children:d.jsx(Jw,{className:"tlui-popover__content",side:e,sideOffset:r,align:n,alignOffset:o,dir:"ltr",children:t})})}const tD=P.createContext(null);function Ng(){const e=P.useContext(tD);if(!e)throw new Error("useTldrawUiMenuContext must be used within a TldrawUiMenuContextProvider");return e}function Mr({type:e,sourceId:t,children:n}){return d.jsx(tD.Provider,{value:{type:e,sourceId:t},children:n})}function Ate(e){return e.getSelectedShapeIds().map(r=>e.getShape(r)).filter(r=>{if(!r)return!1;if(e.isShapeOfType(r,"arrow")){const o=$n(e,r);if(o.start||o.end)return!1}return!0})}const nD=()=>{const e=F();return K("threeStackableItems",()=>Ate(e).length>2,[e])},fs=()=>{const e=F();return K("isInSelectState",()=>e.isIn("select"),[e])},rD=()=>{const e=F();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 r=$n(e,n);if(r.start&&!t.some(o=>o.id===r.start.toId)||r.end&&!t.some(o=>o.id===r.end.toId))return!1}return!0},[e])},oD=()=>{const e=F();return K("allowUngroup",()=>e.getSelectedShapeIds().some(t=>{var n;return((n=e.getShape(t))==null?void 0:n.type)==="group"}),[e])},jte=typeof window<"u"&&"navigator"in window&&!!navigator.clipboard&&!!navigator.clipboard.read;function sD(e,t){const n=F();return K("selectedShapes",()=>n.getSelectedShapes().length>=e,[n,e,t])}function kn(e,t){const n=F();return K("selectedShapes",()=>{const r=n.getSelectedShapes().filter(o=>!n.isShapeOrAncestorLocked(o)).length;return e===void 0?r:r>=e},[n])}function Ote(){const e=F();return K("showAutoSizeToggle",()=>{const t=e.getSelectedShapes();return t.length===1&&e.isShapeOfType(t[0],"text")&&t[0].props.autoSize===!1},[e])}function iD(){const e=F();return K("hasLinkShapeSelected",()=>{const t=e.getOnlySelectedShape();return!!(t&&t.type!=="embed"&&"url"in t.props&&!t.isLocked)},[e])}function Dte(){const e=F();return K("onlyFlippableShape",()=>{const t=e.getOnlySelectedShape();return t&&(e.isShapeOfType(t,"group")||e.isShapeOfType(t,"image")||e.isShapeOfType(t,"arrow")||e.isShapeOfType(t,"line")||e.isShapeOfType(t,"draw"))},[e])}function aD(){const e=F();return K("useCanRedo",()=>e.getCanRedo(),[e])}function lD(){const e=F();return K("useCanUndo",()=>e.getCanUndo(),[e])}var Rte=P.createContext(void 0);function r1(e){const t=P.useContext(Rte);return e||t||"ltr"}var Dy="rovingFocusGroup.onEntryFocus",Lte={bubbles:!1,cancelable:!0},Fg="RovingFocusGroup",[tx,cD,$te]=Eg(Fg),[Nte,uD]=Ao(Fg,[$te]),[Fte,zte]=Nte(Fg),dD=P.forwardRef((e,t)=>d.jsx(tx.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(tx.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(Bte,{...e,ref:t})})}));dD.displayName=Fg;var Bte=P.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...h}=e,p=P.useRef(null),f=qe(t,p),S=r1(s),[y=null,x]=ui({prop:i,defaultProp:a,onChange:l}),[m,v]=P.useState(!1),w=Xt(c),C=cD(n),E=P.useRef(!1),[_,I]=P.useState(0);return P.useEffect(()=>{const k=p.current;if(k)return k.addEventListener(Dy,w),()=>k.removeEventListener(Dy,w)},[w]),d.jsx(Fte,{scope:n,orientation:r,dir:S,loop:o,currentTabStopId:y,onItemFocus:P.useCallback(k=>x(k),[x]),onItemShiftTab:P.useCallback(()=>v(!0),[]),onFocusableItemAdd:P.useCallback(()=>I(k=>k+1),[]),onFocusableItemRemove:P.useCallback(()=>I(k=>k-1),[]),children:d.jsx(_e.div,{tabIndex:m||_===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:re(e.onMouseDown,()=>{E.current=!0}),onFocus:re(e.onFocus,k=>{const T=!E.current;if(k.target===k.currentTarget&&T&&!m){const M=new CustomEvent(Dy,Lte);if(k.currentTarget.dispatchEvent(M),!M.defaultPrevented){const D=C().filter(H=>H.focusable),$=D.find(H=>H.active),j=D.find(H=>H.id===y),R=[$,j,...D].filter(Boolean).map(H=>H.ref.current);fD(R,u)}}E.current=!1}),onBlur:re(e.onBlur,()=>v(!1))})})}),hD="RovingFocusGroupItem",pD=P.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,...i}=e,a=Zo(),l=s||a,c=zte(hD,n),u=c.currentTabStopId===l,h=cD(n),{onFocusableItemAdd:p,onFocusableItemRemove:f}=c;return P.useEffect(()=>{if(r)return p(),()=>f()},[r,p,f]),d.jsx(tx.ItemSlot,{scope:n,id:l,focusable:r,active:o,children:d.jsx(_e.span,{tabIndex:u?0:-1,"data-orientation":c.orientation,...i,ref:t,onMouseDown:re(e.onMouseDown,S=>{r?c.onItemFocus(l):S.preventDefault()}),onFocus:re(e.onFocus,()=>c.onItemFocus(l)),onKeyDown:re(e.onKeyDown,S=>{if(S.key==="Tab"&&S.shiftKey){c.onItemShiftTab();return}if(S.target!==S.currentTarget)return;const y=Kte(S,c.orientation,c.dir);if(y!==void 0){if(S.metaKey||S.ctrlKey||S.altKey||S.shiftKey)return;S.preventDefault();let m=h().filter(v=>v.focusable).map(v=>v.ref.current);if(y==="last")m.reverse();else if(y==="prev"||y==="next"){y==="prev"&&m.reverse();const v=m.indexOf(S.currentTarget);m=c.loop?Wte(m,v+1):m.slice(v+1)}setTimeout(()=>fD(m))}})})})});pD.displayName=hD;var Ute={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Hte(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Kte(e,t,n){const r=Hte(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ute[r]}function fD(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Wte(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Gte=dD,Vte=pD,nx=["Enter"," "],Yte=["ArrowDown","PageUp","Home"],gD=["ArrowUp","PageDown","End"],Xte=[...Yte,...gD],qte={ltr:[...nx,"ArrowRight"],rtl:[...nx,"ArrowLeft"]},Zte={ltr:["ArrowLeft"],rtl:["ArrowRight"]},id="Menu",[Mu,Qte,Jte]=Eg(id),[la,zg]=Ao(id,[Jte,$g,uD]),ad=$g(),mD=uD(),[yD,hi]=la(id),[ene,ld]=la(id),SD=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ad(t),[l,c]=P.useState(null),u=P.useRef(!1),h=Xt(s),p=r1(o);return P.useEffect(()=>{const f=()=>{u.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>u.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),d.jsx(Gw,{...a,children:d.jsx(yD,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:d.jsx(ene,{scope:t,onClose:P.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:u,dir:p,modal:i,children:r})})})};SD.displayName=id;var tne="MenuAnchor",o1=P.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ad(n);return d.jsx(Vw,{...o,...r,ref:t})});o1.displayName=tne;var s1="MenuPortal",[nne,vD]=la(s1,{forceMount:void 0}),xD=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=hi(s1,t);return d.jsx(nne,{scope:t,forceMount:n,children:d.jsx(Qr,{present:n||s.open,children:d.jsx(rd,{asChild:!0,container:o,children:r})})})};xD.displayName=s1;var kr="MenuContent",[rne,i1]=la(kr),wD=P.forwardRef((e,t)=>{const n=vD(kr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=hi(kr,e.__scopeMenu),i=ld(kr,e.__scopeMenu);return d.jsx(Mu.Provider,{scope:e.__scopeMenu,children:d.jsx(Qr,{present:r||s.open,children:d.jsx(Mu.Slot,{scope:e.__scopeMenu,children:i.modal?d.jsx(one,{...o,ref:t}):d.jsx(sne,{...o,ref:t})})})})}),one=P.forwardRef((e,t)=>{const n=hi(kr,e.__scopeMenu),r=P.useRef(null),o=qe(t,r);return P.useEffect(()=>{const s=r.current;if(s)return kw(s)},[]),d.jsx(a1,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:re(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),sne=P.forwardRef((e,t)=>{const n=hi(kr,e.__scopeMenu);return d.jsx(a1,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),a1=P.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:p,onDismiss:f,disableOutsideScroll:S,...y}=e,x=hi(kr,n),m=ld(kr,n),v=ad(n),w=mD(n),C=Qte(n),[E,_]=P.useState(null),I=P.useRef(null),k=qe(t,I,x.onContentChange),T=P.useRef(0),M=P.useRef(""),D=P.useRef(0),$=P.useRef(null),j=P.useRef("right"),O=P.useRef(0),R=S?Ig:P.Fragment,H=S?{as:Yi,allowPinchZoom:!0}:void 0,B=W=>{var Oe,nt;const Y=M.current+W,q=C().filter(je=>!je.disabled),le=document.activeElement,ge=(Oe=q.find(je=>je.ref.current===le))==null?void 0:Oe.textValue,be=q.map(je=>je.textValue),J=yne(be,Y,ge),Ue=(nt=q.find(je=>je.textValue===J))==null?void 0:nt.ref.current;(function je(it){M.current=it,window.clearTimeout(T.current),it!==""&&(T.current=window.setTimeout(()=>je(""),1e3))})(Y),Ue&&setTimeout(()=>Ue.focus())};P.useEffect(()=>()=>window.clearTimeout(T.current),[]),Ew();const z=P.useCallback(W=>{var q,le;return j.current===((q=$.current)==null?void 0:q.side)&&vne(W,(le=$.current)==null?void 0:le.area)},[]);return d.jsx(rne,{scope:n,searchRef:M,onItemEnter:P.useCallback(W=>{z(W)&&W.preventDefault()},[z]),onItemLeave:P.useCallback(W=>{var Y;z(W)||((Y=I.current)==null||Y.focus(),_(null))},[z]),onTriggerLeave:P.useCallback(W=>{z(W)&&W.preventDefault()},[z]),pointerGraceTimerRef:D,onPointerGraceIntentChange:P.useCallback(W=>{$.current=W},[]),children:d.jsx(R,{...H,children:d.jsx(Pg,{asChild:!0,trapped:o,onMountAutoFocus:re(s,W=>{var Y;W.preventDefault(),(Y=I.current)==null||Y.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:d.jsx(nd,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:p,onDismiss:f,children:d.jsx(Gte,{asChild:!0,...w,dir:m.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:_,onEntryFocus:re(l,W=>{m.isUsingKeyboardRef.current||W.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(HO,{role:"menu","aria-orientation":"vertical","data-state":ND(x.open),"data-radix-menu-content":"",dir:m.dir,...v,...y,ref:k,style:{outline:"none",...y.style},onKeyDown:re(y.onKeyDown,W=>{const q=W.target.closest("[data-radix-menu-content]")===W.currentTarget,le=W.ctrlKey||W.altKey||W.metaKey,ge=W.key.length===1;q&&(W.key==="Tab"&&W.preventDefault(),!le&&ge&&B(W.key));const be=I.current;if(W.target!==be||!Xte.includes(W.key))return;W.preventDefault();const Ue=C().filter(Oe=>!Oe.disabled).map(Oe=>Oe.ref.current);gD.includes(W.key)&&Ue.reverse(),gne(Ue)}),onBlur:re(e.onBlur,W=>{W.currentTarget.contains(W.target)||(window.clearTimeout(T.current),M.current="")}),onPointerMove:re(e.onPointerMove,Au(W=>{const Y=W.target,q=O.current!==W.clientX;if(W.currentTarget.contains(Y)&&q){const le=W.clientX>O.current?"right":"left";j.current=le,O.current=W.clientX}}))})})})})})})});wD.displayName=kr;var ine="MenuGroup",l1=P.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(_e.div,{role:"group",...r,ref:t})});l1.displayName=ine;var ane="MenuLabel",bD=P.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(_e.div,{...r,ref:t})});bD.displayName=ane;var Mf="MenuItem",pE="menu.itemSelect",Bg=P.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=P.useRef(null),i=ld(Mf,e.__scopeMenu),a=i1(Mf,e.__scopeMenu),l=qe(t,s),c=P.useRef(!1),u=()=>{const h=s.current;if(!n&&h){const p=new CustomEvent(pE,{bubbles:!0,cancelable:!0});h.addEventListener(pE,f=>r==null?void 0:r(f),{once:!0}),Iw(h,p),p.defaultPrevented?c.current=!1:i.onClose()}};return d.jsx(PD,{...o,ref:l,disabled:n,onClick:re(e.onClick,u),onPointerDown:h=>{var p;(p=e.onPointerDown)==null||p.call(e,h),c.current=!0},onPointerUp:re(e.onPointerUp,h=>{var p;c.current||(p=h.currentTarget)==null||p.click()}),onKeyDown:re(e.onKeyDown,h=>{const p=a.searchRef.current!=="";n||p&&h.key===" "||nx.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Bg.displayName=Mf;var PD=P.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=i1(Mf,n),a=mD(n),l=P.useRef(null),c=qe(t,l),[u,h]=P.useState(!1),[p,f]=P.useState("");return P.useEffect(()=>{const S=l.current;S&&f((S.textContent??"").trim())},[s.children]),d.jsx(Mu.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:d.jsx(Vte,{asChild:!0,...a,focusable:!r,children:d.jsx(_e.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:re(e.onPointerMove,Au(S=>{r?i.onItemLeave(S):(i.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:re(e.onPointerLeave,Au(S=>i.onItemLeave(S))),onFocus:re(e.onFocus,()=>h(!0)),onBlur:re(e.onBlur,()=>h(!1))})})})}),lne="MenuCheckboxItem",CD=P.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return d.jsx(TD,{scope:e.__scopeMenu,checked:n,children:d.jsx(Bg,{role:"menuitemcheckbox","aria-checked":Af(n)?"mixed":n,...o,ref:t,"data-state":d1(n),onSelect:re(o.onSelect,()=>r==null?void 0:r(Af(n)?!0:!n),{checkForDefaultPrevented:!1})})})});CD.displayName=lne;var ID="MenuRadioGroup",[cne,une]=la(ID,{value:void 0,onValueChange:()=>{}}),ED=P.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Xt(r);return d.jsx(cne,{scope:e.__scopeMenu,value:n,onValueChange:s,children:d.jsx(l1,{...o,ref:t})})});ED.displayName=ID;var kD="MenuRadioItem",_D=P.forwardRef((e,t)=>{const{value:n,...r}=e,o=une(kD,e.__scopeMenu),s=n===o.value;return d.jsx(TD,{scope:e.__scopeMenu,checked:s,children:d.jsx(Bg,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":d1(s),onSelect:re(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});_D.displayName=kD;var c1="MenuItemIndicator",[TD,dne]=la(c1,{checked:!1}),MD=P.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=dne(c1,n);return d.jsx(Qr,{present:r||Af(s.checked)||s.checked===!0,children:d.jsx(_e.span,{...o,ref:t,"data-state":d1(s.checked)})})});MD.displayName=c1;var hne="MenuSeparator",AD=P.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(_e.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});AD.displayName=hne;var pne="MenuArrow",jD=P.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ad(n);return d.jsx(KO,{...o,...r,ref:t})});jD.displayName=pne;var u1="MenuSub",[fne,OD]=la(u1),DD=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:o}=e,s=hi(u1,t),i=ad(t),[a,l]=P.useState(null),[c,u]=P.useState(null),h=Xt(o);return P.useEffect(()=>(s.open===!1&&h(!1),()=>h(!1)),[s.open,h]),d.jsx(Gw,{...i,children:d.jsx(yD,{scope:t,open:r,onOpenChange:h,content:c,onContentChange:u,children:d.jsx(fne,{scope:t,contentId:Zo(),triggerId:Zo(),trigger:a,onTriggerChange:l,children:n})})})};DD.displayName=u1;var Rc="MenuSubTrigger",RD=P.forwardRef((e,t)=>{const n=hi(Rc,e.__scopeMenu),r=ld(Rc,e.__scopeMenu),o=OD(Rc,e.__scopeMenu),s=i1(Rc,e.__scopeMenu),i=P.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=P.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return P.useEffect(()=>u,[u]),P.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),d.jsx(o1,{asChild:!0,...c,children:d.jsx(PD,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":ND(n.open),...e,ref:bg(t,o.onTriggerChange),onClick:h=>{var p;(p=e.onClick)==null||p.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:re(e.onPointerMove,Au(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:re(e.onPointerLeave,Au(h=>{var f,S;u();const p=(f=n.content)==null?void 0:f.getBoundingClientRect();if(p){const y=(S=n.content)==null?void 0:S.dataset.side,x=y==="right",m=x?-5:5,v=p[x?"left":"right"],w=p[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+m,y:h.clientY},{x:v,y:p.top},{x:w,y:p.top},{x:w,y:p.bottom},{x:v,y:p.bottom}],side:y}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:re(e.onKeyDown,h=>{var f;const p=s.searchRef.current!=="";e.disabled||p&&h.key===" "||qte[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});RD.displayName=Rc;var LD="MenuSubContent",$D=P.forwardRef((e,t)=>{const n=vD(kr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=hi(kr,e.__scopeMenu),i=ld(kr,e.__scopeMenu),a=OD(LD,e.__scopeMenu),l=P.useRef(null),c=qe(t,l);return d.jsx(Mu.Provider,{scope:e.__scopeMenu,children:d.jsx(Qr,{present:r||s.open,children:d.jsx(Mu.Slot,{scope:e.__scopeMenu,children:d.jsx(a1,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var h;i.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:re(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:re(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:re(e.onKeyDown,u=>{var f;const h=u.currentTarget.contains(u.target),p=Zte[i.dir].includes(u.key);h&&p&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),u.preventDefault())})})})})})});$D.displayName=LD;function ND(e){return e?"open":"closed"}function Af(e){return e==="indeterminate"}function d1(e){return Af(e)?"indeterminate":e?"checked":"unchecked"}function gne(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function mne(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function yne(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=mne(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Sne(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,l=t[s].y,c=t[i].x,u=t[i].y;l>r!=u>r&&n<(c-a)*(r-l)/(u-l)+a&&(o=!o)}return o}function vne(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Sne(n,t)}function Au(e){return t=>t.pointerType==="mouse"?e(t):void 0}var FD=SD,zD=o1,BD=xD,UD=wD,HD=l1,KD=bD,WD=Bg,GD=CD,VD=ED,YD=_D,XD=MD,qD=AD,ZD=jD,QD=DD,JD=RD,eR=$D,h1="ContextMenu",[xne,$ae]=Ao(h1,[zg]),pn=zg(),[wne,tR]=xne(h1),nR=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:o,modal:s=!0}=e,[i,a]=P.useState(!1),l=pn(t),c=Xt(r),u=P.useCallback(h=>{a(h),c(h)},[c]);return d.jsx(wne,{scope:t,open:i,onOpenChange:u,modal:s,children:d.jsx(FD,{...l,dir:o,open:i,onOpenChange:u,modal:s,children:n})})};nR.displayName=h1;var rR="ContextMenuTrigger",oR=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...o}=e,s=tR(rR,n),i=pn(n),a=P.useRef({x:0,y:0}),l=P.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),c=P.useRef(0),u=P.useCallback(()=>window.clearTimeout(c.current),[]),h=p=>{a.current={x:p.clientX,y:p.clientY},s.onOpenChange(!0)};return P.useEffect(()=>u,[u]),P.useEffect(()=>void(r&&u()),[r,u]),d.jsxs(d.Fragment,{children:[d.jsx(zD,{...i,virtualRef:l}),d.jsx(_e.span,{"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,...o,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:re(e.onContextMenu,p=>{u(),h(p),p.preventDefault()}),onPointerDown:r?e.onPointerDown:re(e.onPointerDown,vh(p=>{u(),c.current=window.setTimeout(()=>h(p),700)})),onPointerMove:r?e.onPointerMove:re(e.onPointerMove,vh(u)),onPointerCancel:r?e.onPointerCancel:re(e.onPointerCancel,vh(u)),onPointerUp:r?e.onPointerUp:re(e.onPointerUp,vh(u))})]})});oR.displayName=rR;var bne="ContextMenuPortal",p1=e=>{const{__scopeContextMenu:t,...n}=e,r=pn(t);return d.jsx(BD,{...r,...n})};p1.displayName=bne;var sR="ContextMenuContent",iR=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=tR(sR,n),s=pn(n),i=P.useRef(!1);return d.jsx(UD,{...s,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var l;(l=e.onCloseAutoFocus)==null||l.call(e,a),!a.defaultPrevented&&i.current&&a.preventDefault(),i.current=!1},onInteractOutside:a=>{var l;(l=e.onInteractOutside)==null||l.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)"}})});iR.displayName=sR;var Pne="ContextMenuGroup",aR=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return d.jsx(HD,{...o,...r,ref:t})});aR.displayName=Pne;var Cne="ContextMenuLabel",Ine=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return d.jsx(KD,{...o,...r,ref:t})});Ine.displayName=Cne;var Ene="ContextMenuItem",lR=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return d.jsx(WD,{...o,...r,ref:t})});lR.displayName=Ene;var kne="ContextMenuCheckboxItem",cR=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return d.jsx(GD,{...o,...r,ref:t})});cR.displayName=kne;var _ne="ContextMenuRadioGroup",Tne=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return d.jsx(VD,{...o,...r,ref:t})});Tne.displayName=_ne;var Mne="ContextMenuRadioItem",Ane=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return d.jsx(YD,{...o,...r,ref:t})});Ane.displayName=Mne;var jne="ContextMenuItemIndicator",One=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return d.jsx(XD,{...o,...r,ref:t})});One.displayName=jne;var Dne="ContextMenuSeparator",Rne=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return d.jsx(qD,{...o,...r,ref:t})});Rne.displayName=Dne;var Lne="ContextMenuArrow",$ne=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return d.jsx(ZD,{...o,...r,ref:t})});$ne.displayName=Lne;var Nne="ContextMenuSub",uR=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,open:o,defaultOpen:s}=e,i=pn(t),[a,l]=ui({prop:o,defaultProp:s,onChange:r});return d.jsx(QD,{...i,open:a,onOpenChange:l,children:n})};uR.displayName=Nne;var Fne="ContextMenuSubTrigger",dR=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return d.jsx(JD,{...o,...r,ref:t})});dR.displayName=Fne;var zne="ContextMenuSubContent",hR=P.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=pn(n);return d.jsx(eR,{...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)"}})});hR.displayName=zne;function vh(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var Bne=nR,Une=oR,Hne=p1,Kne=iR,Wne=cR;const pR=typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("mac")>-1,Gne=pR?"⌘":"Ctrl",Vne=pR?"⌥":"Alt";function fR(e){return e.split(",")[0].split("").map(t=>{const n=t.replace(/\$/g,Gne).replace(/\?/g,Vne).replace(/!/g,"⇧");return n[0].toUpperCase()+n.slice(1)})}function rx(e){return"— "+fR(e).join(" ")}function Yne(e){return d.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",...e,children:d.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[d.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),d.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:d.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}var f1="DropdownMenu",[Xne,Nae]=Ao(f1,[zg]),fn=zg(),[qne,gR]=Xne(f1),mR=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=fn(t),c=P.useRef(null),[u=!1,h]=ui({prop:o,defaultProp:s,onChange:i});return d.jsx(qne,{scope:t,triggerId:Zo(),triggerRef:c,contentId:Zo(),open:u,onOpenChange:h,onOpenToggle:P.useCallback(()=>h(p=>!p),[h]),modal:a,children:d.jsx(FD,{...l,open:u,onOpenChange:h,dir:r,modal:a,children:n})})};mR.displayName=f1;var yR="DropdownMenuTrigger",SR=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=gR(yR,n),i=fn(n);return d.jsx(zD,{asChild:!0,...i,children:d.jsx(_e.button,{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:bg(t,s.triggerRef),onPointerDown:re(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:re(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});SR.displayName=yR;var Zne="DropdownMenuPortal",vR=e=>{const{__scopeDropdownMenu:t,...n}=e,r=fn(t);return d.jsx(BD,{...r,...n})};vR.displayName=Zne;var xR="DropdownMenuContent",wR=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gR(xR,n),s=fn(n),i=P.useRef(!1);return d.jsx(UD,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:re(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:re(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!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)"}})});wR.displayName=xR;var Qne="DropdownMenuGroup",bR=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fn(n);return d.jsx(HD,{...o,...r,ref:t})});bR.displayName=Qne;var Jne="DropdownMenuLabel",ere=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fn(n);return d.jsx(KD,{...o,...r,ref:t})});ere.displayName=Jne;var tre="DropdownMenuItem",PR=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fn(n);return d.jsx(WD,{...o,...r,ref:t})});PR.displayName=tre;var nre="DropdownMenuCheckboxItem",CR=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fn(n);return d.jsx(GD,{...o,...r,ref:t})});CR.displayName=nre;var rre="DropdownMenuRadioGroup",ore=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fn(n);return d.jsx(VD,{...o,...r,ref:t})});ore.displayName=rre;var sre="DropdownMenuRadioItem",ire=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fn(n);return d.jsx(YD,{...o,...r,ref:t})});ire.displayName=sre;var are="DropdownMenuItemIndicator",lre=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fn(n);return d.jsx(XD,{...o,...r,ref:t})});lre.displayName=are;var cre="DropdownMenuSeparator",ure=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fn(n);return d.jsx(qD,{...o,...r,ref:t})});ure.displayName=cre;var dre="DropdownMenuArrow",hre=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fn(n);return d.jsx(ZD,{...o,...r,ref:t})});hre.displayName=dre;var pre=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:o,defaultOpen:s}=e,i=fn(t),[a=!1,l]=ui({prop:r,defaultProp:s,onChange:o});return d.jsx(QD,{...i,open:a,onOpenChange:l,children:n})},fre="DropdownMenuSubTrigger",IR=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fn(n);return d.jsx(JD,{...o,...r,ref:t})});IR.displayName=fre;var gre="DropdownMenuSubContent",ER=P.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fn(n);return d.jsx(eR,{...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)"}})});ER.displayName=gre;var g1=mR,m1=SR,Ug=vR,y1=wR,mre=bR,yre=PR,Sre=CR,vre=pre,xre=IR,wre=ER;function Zi({id:e,children:t,modal:n=!1,debugOpen:r=!1}){const[o,s]=ps(e);return d.jsx(g1,{open:r||o,dir:"ltr",modal:n,onOpenChange:s,children:t})}function Qi({children:e,...t}){return d.jsx(m1,{dir:"ltr",asChild:!0,onTouchEnd:n=>Ee(n),...t,children:e})}function Ji({side:e="bottom",align:t="start",sideOffset:n=8,alignOffset:r=8,children:o}){const s=$t();return d.jsx(Ug,{container:s,children:d.jsx(y1,{className:"tlui-menu",side:e,sideOffset:n,align:t,alignOffset:r,collisionPadding:4,children:o})})}function bre({id:e,children:t}){const[n,r]=ps(e);return d.jsx(vre,{open:n,onOpenChange:r,children:t})}function Pre({id:e,label:t,title:n,disabled:r}){return d.jsx(xre,{dir:"ltr",asChild:!0,disabled:r,children:d.jsxs(ue,{"data-testid":e,type:"menu",className:"tlui-menu__submenu__trigger",disabled:r,title:n,children:[d.jsx(bt,{children:t}),d.jsx(ve,{icon:"chevron-right",small:!0})]})})}function Cre({id:e,alignOffset:t=-1,sideOffset:n=-4,size:r="small",children:o}){const s=$t();return d.jsx(Ug,{container:s,children:d.jsx(wre,{"data-testid":e,className:"tlui-menu tlui-menu__submenu__content",alignOffset:t,sideOffset:n,collisionPadding:4,"data-size":r,children:o})})}function Ire({children:e}){return d.jsx(mre,{dir:"ltr",className:"tlui-menu__group",children:e})}function ju({noClose:e,children:t}){return d.jsx(yre,{dir:"ltr",asChild:!0,onClick:e?Ee:void 0,children:t})}function Zc({children:e,visibleOnMobileLayout:t=!1}){const n=En();return!t&&n<yt.MOBILE?null:d.jsx("kbd",{className:"tlui-kbd",children:fR(e).map((r,o)=>d.jsx("span",{children:r},o))})}function U({disabled:e=!1,spinner:t=!1,readonlyOk:n=!1,id:r,kbd:o,label:s,icon:i,onSelect:a,noClose:l,isSelected:c}){const{type:u,sourceId:h}=Ng(),p=we(),[f,S]=P.useState(!1);if(ds()&&!n)return null;const x=ku(s,u),m=o?rx(o):void 0,v=x?p(x):void 0,w=v&&m?`${v} ${m}`:v;switch(u){case"menu":return d.jsx(ju,{children:d.jsxs(ue,{type:"menu","data-testid":`${h}.${r}`,disabled:e,title:w,onClick:C=>{l&&Ee(C),f?S(!1):a(h)},children:[d.jsx(bt,{children:v}),o&&d.jsx(Zc,{children:o})]})});case"context-menu":return e?null:d.jsxs(lR,{dir:"ltr",title:w,draggable:!1,className:"tlui-button tlui-button__menu","data-testid":`${h}.${r}`,onSelect:C=>{l&&Ee(C),f?S(!1):a(h)},children:[d.jsx("span",{className:"tlui-button__label",draggable:!1,children:v}),o&&d.jsx(Zc,{children:o}),t&&d.jsx(Yne,{})]});case"panel":return d.jsxs(ue,{"data-testid":`${h}.${r}`,type:"menu",title:w,disabled:e,onClick:()=>a(h),children:[d.jsx(bt,{children:v}),i&&d.jsx(ve,{icon:i})]});case"small-icons":case"icons":return d.jsx(ue,{"data-testid":`${h}.${r}`,type:"icon",title:w,disabled:e,onClick:()=>a(h),children:d.jsx(ve,{icon:i,small:u==="small-icons"})});case"keyboard-shortcuts":return o?d.jsxs("div",{className:"tlui-shortcuts-dialog__key-pair","data-testid":`${h}.${r}`,children:[d.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__key",children:v}),d.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__value",children:d.jsx(Zc,{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 d.jsxs(ue,{type:"low",onClick:()=>a(h),children:[d.jsx(ve,{icon:i}),d.jsx(bt,{children:v})]});case"toolbar":return d.jsx(ue,{type:"tool","data-testid":`tools.${r}`,"aria-label":x,"data-value":r,onClick:()=>a("toolbar"),title:w,onTouchStart:C=>{Ee(C),a("toolbar")},role:"radio","aria-checked":c?"true":"false",children:d.jsx(ve,{icon:i})});case"toolbar-overflow":return d.jsx(ju,{"aria-label":s,children:d.jsx(ue,{type:"icon",className:"tlui-button-grid__button",onClick:()=>{a("toolbar")},"data-testid":`tools.more.${r}`,title:w,role:"radio","aria-checked":c?"true":"false","data-value":r,children:d.jsx(ve,{icon:i})})});default:throw un(u)}}function Ere(){return d.jsxs(d.Fragment,{children:[d.jsx(kre,{}),d.jsx(_re,{}),d.jsx(Tre,{}),d.jsx(Mre,{}),d.jsx(Are,{}),d.jsx(Dre,{}),d.jsx(Rre,{}),d.jsx(Lre,{})]})}function kre(){const e=ae(),t=kn(2),n=fs(),r=t&&n;return d.jsxs(d.Fragment,{children:[d.jsx(U,{...e["align-left"],disabled:!r}),d.jsx(U,{...e["align-center-horizontal"],disabled:!r}),d.jsx(U,{...e["align-right"],disabled:!r}),d.jsx(U,{...e["stretch-horizontal"],disabled:!r}),d.jsx(U,{...e["align-top"],disabled:!r}),d.jsx(U,{...e["align-center-vertical"],disabled:!r}),d.jsx(U,{...e["align-bottom"],disabled:!r}),d.jsx(U,{...e["stretch-vertical"],disabled:!r})]})}function _re(){const e=ae(),t=kn(3),n=fs(),r=t&&n;return d.jsxs(d.Fragment,{children:[d.jsx(U,{...e["distribute-horizontal"],disabled:!r}),d.jsx(U,{...e["distribute-vertical"],disabled:!r})]})}function Tre(){const e=ae(),t=nD(),n=fs(),r=t&&n;return d.jsxs(d.Fragment,{children:[d.jsx(U,{...e["stack-horizontal"],disabled:!r}),d.jsx(U,{...e["stack-vertical"],disabled:!r})]})}function Mre(){const e=ae(),t=kn(1),n=fs(),r=t&&n;return d.jsxs(d.Fragment,{children:[d.jsx(U,{...e["send-to-back"],disabled:!r}),d.jsx(U,{...e["send-backward"],disabled:!r}),d.jsx(U,{...e["bring-forward"],disabled:!r}),d.jsx(U,{...e["bring-to-front"],disabled:!r})]})}function Are(){return En()<yt.TABLET_SM?d.jsx(jre,{}):d.jsx(Ore,{})}function jre(){const e=ae(),t=F(),n=K("zoom is 1",()=>t.getZoomLevel()===1,[t]);return d.jsx(U,{...e["zoom-to-100"],disabled:n})}function Ore(){const e=ae(),t=kn(1),n=fs(),r=t&&n;return d.jsx(U,{...e["rotate-ccw"],disabled:!r})}function Dre(){const e=ae(),t=kn(1),n=fs(),r=t&&n;return d.jsx(U,{...e["rotate-cw"],disabled:!r})}function Rre(){const e=ae(),t=iD(),n=fs(),r=t&&n;return d.jsx(U,{...e["edit-link"],disabled:!r})}function Lre(){const e=rD(),t=oD();return e?d.jsx(fE,{}):t?d.jsx($re,{}):d.jsx(fE,{})}function fE(){const e=ae(),t=kn(2),n=fs(),r=t&&n;return d.jsx(U,{...e.group,disabled:!r})}function $re(){const e=ae();return d.jsx(U,{...e.ungroup})}const Nre=P.memo(function({children:t}){const n=we(),r=En(),o=ds(),s=F(),i=K("should display quick actions when in readonly",()=>s.isInAny("hand","zoom"),[s]),a=t??d.jsx(Ere,{});if(!(o&&!i))return d.jsxs(e1,{id:"actions-menu",children:[d.jsx(t1,{children:d.jsx(ue,{type:"icon","data-testid":"actions-menu.button",title:n("actions-menu.title"),children:d.jsx(ve,{icon:"dots-vertical",small:!0})})}),d.jsx(n1,{side:r>=yt.TABLET?"bottom":"top",sideOffset:6,children:d.jsx("div",{className:"tlui-actions-menu tlui-buttons__grid","data-testid":"actions-menu.content",children:d.jsx(Mr,{type:"icons",sourceId:"actions-menu",children:a})})})]})});function Yn({id:e,kbd:t,label:n,readonlyOk:r,onSelect:o,toggle:s=!1,disabled:i=!1,checked:a=!1}){const{type:l,sourceId:c}=Ng(),u=ds(),h=we();if(u&&!r)return null;const p=ku(n,l),f=p?h(p):void 0;switch(l){case"menu":return d.jsxs(Sre,{dir:"ltr",className:"tlui-button tlui-button__menu tlui-button__checkbox",title:f,onSelect:S=>{o==null||o(c),Ee(S)},disabled:i,checked:a,children:[d.jsx(Eo,{small:!0,icon:s?a?"toggle-on":"toggle-off":a?"check":"none"}),f&&d.jsx("span",{className:"tlui-button__label",draggable:!1,children:f}),t&&d.jsx(Zc,{children:t})]});case"context-menu":return d.jsxs(Wne,{className:"tlui-button tlui-button__menu tlui-button__checkbox",dir:"ltr",title:f,onSelect:S=>{o(c),Ee(S)},disabled:i,checked:a,children:[d.jsx(Eo,{small:!0,icon:s?a?"toggle-on":"toggle-off":a?"check":"none"}),f&&d.jsx("span",{className:"tlui-button__label",draggable:!1,children:f}),t&&d.jsx(Zc,{children:t})]},e);default:return null}}function pe({id:e,label:t,children:n}){const{type:r,sourceId:o}=Ng(),s=we(),i=ku(t,r),a=i?s(i):void 0;switch(r){case"panel":return d.jsx("div",{className:"tlui-menu__group","data-testid":`${o}-group.${e}`,children:n});case"menu":return d.jsx(Ire,{"data-testid":`${o}-group.${e}`,children:n});case"context-menu":return d.jsx(aR,{dir:"ltr",className:"tlui-menu__group","data-testid":`${o}-group.${e}`,children:n});case"keyboard-shortcuts":return d.jsxs("div",{className:"tlui-shortcuts-dialog__group","data-testid":`${o}-group.${e}`,children:[d.jsx("h2",{className:"tlui-shortcuts-dialog__group__title",children:a}),d.jsx("div",{className:"tlui-shortcuts-dialog__group__content",children:n})]});default:return n}}function _n({id:e,disabled:t=!1,label:n,size:r="small",children:o}){const{type:s,sourceId:i}=Ng(),a=$t(),l=we(),c=n?typeof n=="string"?n:n[s]??n.default:void 0,u=c?l(c):void 0;switch(s){case"menu":return d.jsxs(bre,{id:`${i}-sub.${e}`,children:[d.jsx(Pre,{id:`${i}-sub.${u?u.toLowerCase()+"-button":""}`,disabled:t,label:u,title:u}),d.jsx(Cre,{id:`${i}-sub.${u?u.toLowerCase()+"-content":""}`,size:r,children:o})]});case"context-menu":return t?null:d.jsxs(Fre,{id:`${i}-sub.${e}`,children:[d.jsx(dR,{dir:"ltr",disabled:t,asChild:!0,children:d.jsxs(ue,{"data-testid":`${i}-sub-trigger.${e}`,type:"menu",className:"tlui-menu__submenu__trigger",children:[d.jsx(bt,{children:u}),d.jsx(ve,{icon:"chevron-right",small:!0})]})}),d.jsx(p1,{container:a,children:d.jsx(hR,{"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 Fre({id:e,children:t}){const[n,r]=ps(e);return d.jsx(uR,{open:n,onOpenChange:r,children:t})}function kR(){const e=ae();return Ote()?d.jsx(U,{...e["toggle-auto-size"]}):null}function _R(){const e=ae();return iD()?d.jsx(U,{...e["edit-link"]}):null}function zre(){const e=ae();return kn(1)?d.jsx(U,{...e.duplicate}):null}function TR(){const e=ae(),t=F();return K("should display flatten option",()=>{if(t.getSelectedShapeIds().length===0)return!1;const o=t.getOnlySelectedShape();return!(o&&t.isShapeOfType(o,"image"))},[t])?d.jsx(U,{...e["flatten-to-image"]}):null}function MR(){const e=ae();return rD()?d.jsx(U,{...e.group}):null}function AR(){const e=ae();return oD()?d.jsx(U,{...e.ungroup}):null}function jR(){const e=F(),t=ae();return K("allow unframe",()=>{const r=e.getSelectedShapes();return r.length===0?!1:r.every(o=>e.isShapeOfType(o,"frame"))},[e])?d.jsx(U,{...t["remove-frame"]}):null}function OR(){const e=F(),t=ae();return K("allow fit frame to content",()=>{const r=e.getOnlySelectedShape();return r?e.isShapeOfType(r,"frame")&&e.getSortedChildIdsForParent(r).length>0:!1},[e])?d.jsx(U,{...t["fit-frame-to-content"]}):null}function DR(){const e=F(),t=ae();return K("selected shapes",()=>e.getSelectedShapes().length>0,[e])?d.jsx(U,{...t["toggle-lock"]}):null}function S1(){const e=ae(),t=F(),n=K("isTransparentBg",()=>!t.getInstanceState().exportBackground,[t]);return d.jsx(Yn,{...e["toggle-transparent"],checked:n,toggle:!0})}function Bre(){const e=F(),t=ae(),n=K("any shapes",()=>e.getCurrentPageShapeIds().size>0,[e]);return d.jsx(U,{...t["unlock-all"],disabled:!n})}function RR(){const e=F(),t=K("zoomed to 100",()=>e.getZoomLevel()===1,[e]),n=ae();return d.jsx(U,{...n["zoom-to-100"],noClose:!0,disabled:t})}function LR(){const e=F(),t=K("has shapes",()=>e.getCurrentPageShapeIds().size>0,[e]),n=ae();return d.jsx(U,{...n["zoom-to-fit"],disabled:!t,"data-testid":"minimap.zoom-menu.zoom-to-fit",noClose:!0})}function $R(){const e=F(),t=K("has shapes",()=>e.getSelectedShapeIds().length>0,[e]),n=ae();return d.jsx(U,{...n["zoom-to-selection"],disabled:!t,"data-testid":"minimap.zoom-menu.zoom-to-selection",noClose:!0})}function NR(){return d.jsxs(pe,{id:"clipboard",children:[d.jsx(Hre,{}),d.jsx(Kre,{}),d.jsx(Wre,{}),d.jsx(zre,{}),d.jsx(Gre,{})]})}function Ure(){var r;const e=F(),t=ae(),n=K("atLeastOneShapeOnPage",()=>e.getCurrentPageShapeIds().size>0,[e]);return d.jsxs(_n,{id:"copy-as",label:"context-menu.copy-as",size:"small",disabled:!n,children:[d.jsxs(pe,{id:"copy-as-group",children:[d.jsx(U,{...t["copy-as-svg"]}),!!((r=window.navigator.clipboard)!=null&&r.write)&&d.jsx(U,{...t["copy-as-png"]}),d.jsx(U,{...t["copy-as-json"]})]}),d.jsx(pe,{id:"copy-as-bg",children:d.jsx(S1,{})})]})}function Hre(){const e=ae(),t=kn(1);return d.jsx(U,{...e.cut,disabled:!t})}function Kre(){const e=ae(),t=sD(1);return d.jsx(U,{...e.copy,disabled:!t})}function Wre(){const e=ae(),t=jte;return d.jsx(U,{...e.paste,disabled:!t})}function FR(){const e=F(),t=ae();return K("atLeastOneShapeOnPage",()=>e.getCurrentPageShapeIds().size>0,[e])?d.jsxs(pe,{id:"conversions",children:[d.jsx(Ure,{}),d.jsxs(_n,{id:"export-as",label:"context-menu.export-as",size:"small",children:[d.jsxs(pe,{id:"export-as-group",children:[d.jsx(U,{...t["export-as-svg"]}),d.jsx(U,{...t["export-as-png"]}),d.jsx(U,{...t["export-as-json"]})]}),d.jsx(pe,{id:"export-as-bg",children:d.jsx(S1,{})})]})]}):null}function zR(){const e=ae(),t=F(),n=K("atLeastOneShapeOnPage",()=>t.getCurrentPageShapeIds().size>0,[t]);return d.jsx(U,{...e["select-all"],disabled:!n})}function Gre(){const e=ae(),t=kn(1);return d.jsx(U,{...e.delete,disabled:!t})}function Vre(){return sD(1)?d.jsxs(_n,{id:"edit",label:"context-menu.edit",size:"small",children:[d.jsx(MR,{}),d.jsx(AR,{}),d.jsx(TR,{}),d.jsx(_R,{}),d.jsx(OR,{}),d.jsx(jR,{}),d.jsx(UR,{}),d.jsx(BR,{}),d.jsx(kR,{}),d.jsx(DR,{})]}):null}function Yre(){const e=kn(2),t=Dte(),n=ae();return e||t?d.jsxs(_n,{id:"arrange",label:"context-menu.arrange",size:"small",children:[e&&d.jsxs(pe,{id:"align",children:[d.jsx(U,{...n["align-left"]}),d.jsx(U,{...n["align-center-horizontal"]}),d.jsx(U,{...n["align-right"]}),d.jsx(U,{...n["align-top"]}),d.jsx(U,{...n["align-center-vertical"]}),d.jsx(U,{...n["align-bottom"]})]}),d.jsx(Xre,{}),e&&d.jsxs(pe,{id:"stretch",children:[d.jsx(U,{...n["stretch-horizontal"]}),d.jsx(U,{...n["stretch-vertical"]})]}),(e||t)&&d.jsxs(pe,{id:"flip",children:[d.jsx(U,{...n["flip-horizontal"]}),d.jsx(U,{...n["flip-vertical"]})]}),d.jsx(qre,{})]}):null}function Xre(){const e=ae();return kn(3)?d.jsxs(pe,{id:"distribute",children:[d.jsx(U,{...e["distribute-horizontal"]}),d.jsx(U,{...e["distribute-vertical"]})]}):null}function qre(){const e=ae(),t=kn(2),n=nD();return t?d.jsxs(pe,{id:"order",children:[d.jsx(U,{...e.pack}),n&&d.jsx(U,{...e["stack-horizontal"]}),n&&d.jsx(U,{...e["stack-vertical"]})]}):null}function Zre(){const e=ae();return kn(1)?d.jsx(_n,{id:"reorder",label:"context-menu.reorder",size:"small",children:d.jsxs(pe,{id:"reorder",children:[d.jsx(U,{...e["bring-to-front"]}),d.jsx(U,{...e["bring-forward"]}),d.jsx(U,{...e["send-backward"]}),d.jsx(U,{...e["send-to-back"]})]})}):null}function Qre(){const e=F(),t=K("pages",()=>e.getPages(),[e]),n=K("current page id",()=>e.getCurrentPageId(),[e]),{addToast:r}=eo(),o=ae(),s=Zt();return kn(1)?d.jsxs(_n,{id:"move-to-page",label:"context-menu.move-to-page",size:"small",children:[d.jsx(pe,{id:"pages",children:t.map(a=>d.jsx(U,{id:a.id,disabled:n===a.id,label:a.name,onSelect:()=>{e.mark("move_shapes_to_page"),e.moveShapesToPage(e.getSelectedShapeIds(),a.id);const l=e.getPage(a.id);l&&r({title:"Changed Page",description:`Moved to ${l.name}.`,actions:[{label:"Go Back",type:"primary",onClick:()=>{e.mark("change-page"),e.setCurrentPage(n)}}]}),s("move-to-page",{source:"context-menu"})}},a.id))}),d.jsx(pe,{id:"new-page",children:d.jsx(U,{...o["move-to-new-page"]})})]}):null}function BR(){const e=F(),t=ae();return K("oneEmbedSelected",()=>{const r=e.getOnlySelectedShape();return r?!!(e.isShapeOfType(r,"embed")&&r.props.url&&!e.isShapeOrAncestorLocked(r)):!1},[e])?d.jsx(U,{...t["convert-to-bookmark"]}):null}function UR(){const e=F(),t=ae();return K("oneEmbeddableBookmarkSelected",()=>{const r=e.getOnlySelectedShape();return r?!!(e.isShapeOfType(r,"bookmark")&&r.props.url&&Rs(r.props.url)&&!e.isShapeOrAncestorLocked(r)):!1},[e])?d.jsx(U,{...t["convert-to-embed"]}):null}function Jre(){const e=ae(),t=F(),n=K("isSnapMode",()=>t.user.getIsSnapMode(),[t]);return d.jsx(Yn,{...e["toggle-snap-mode"],checked:n})}function eoe(){const e=ae(),t=F(),n=K("isToolLock",()=>t.getInstanceState().isToolLocked,[t]);return d.jsx(Yn,{...e["toggle-tool-lock"],checked:n})}function toe(){const e=ae(),t=F(),n=K("isGridMode",()=>t.getInstanceState().isGridMode,[t]);return d.jsx(Yn,{...e["toggle-grid"],checked:n})}function noe(){const e=ae(),t=F(),n=K("isWrapMode",()=>t.user.getIsWrapMode(),[t]);return d.jsx(Yn,{...e["toggle-wrap-mode"],checked:n})}function roe(){const e=ae(),t=F(),n=K("isFocusMode",()=>t.getInstanceState().isFocusMode,[t]);return d.jsx(Yn,{...e["toggle-focus-mode"],checked:n})}function ooe(){const e=ae(),t=F(),n=K("edgeScrollSpeed",()=>t.user.getEdgeScrollSpeed(),[t]);return d.jsx(Yn,{...e["toggle-edge-scrolling"],checked:n===1})}function soe(){const e=ae(),t=F(),n=K("animationSpeed",()=>t.user.getAnimationSpeed(),[t]);return d.jsx(Yn,{...e["toggle-reduce-motion"],checked:n===0})}function ioe(){const e=ae(),t=F(),n=K("isDebugMode",()=>t.getInstanceState().isDebugMode,[t]);return d.jsx(Yn,{...e["toggle-debug-mode"],checked:n})}function aoe(){const e=ae(),t=F(),n=K("dynamic resize",()=>t.user.getIsDynamicResizeMode(),[t]);return d.jsx(Yn,{...e["toggle-dynamic-size-mode"],checked:n})}function loe(){const e=ae(),t=F(),n=K("paste at cursor",()=>t.user.getIsPasteAtCursorMode(),[t]);return d.jsx(Yn,{...e["toggle-paste-at-cursor"],checked:n})}function coe(){const e=F(),t=ae();return K("show cursor chat",()=>e.getCurrentToolId()==="select"&&!e.getInstanceState().isCoarsePointer,[e])?d.jsx(U,{...t["open-cursor-chat"]}):null}function uoe(){const e=F(),t=Dg();return K("isSelectToolActive",()=>e.getCurrentToolId()==="select",[e])?d.jsxs(d.Fragment,{children:[t&&d.jsx(coe,{}),d.jsxs(pe,{id:"modify",children:[d.jsx(Vre,{}),d.jsx(Yre,{}),d.jsx(Zre,{}),d.jsx(Qre,{})]}),d.jsx(NR,{}),d.jsx(FR,{}),d.jsx(pe,{id:"select-all",children:d.jsx(zR,{})})]}):null}const doe=P.memo(function({children:t}){const n=F(),{Canvas:r}=st(),o=P.useCallback(c=>{if(c){if(n.getInstanceState().isCoarsePointer){const u=n.getSelectedShapes(),{inputs:{currentPagePoint:h}}=n,p=n.getShapesAtPoint(h);if(!n.getSelectedShapes().length||!p.some(f=>u.includes(f))){const f=p.filter(S=>n.isShapeOrAncestorLocked(S));f.length&&n.select(...f.map(S=>S.id))}}}else{const u=n.getOnlySelectedShape();u&&n.isShapeOrAncestorLocked(u)&&n.setSelectedShapes([])}},[n]),s=$t(),[i,a]=ps("context menu",o),l=t??d.jsx(uoe,{});return d.jsxs(Bne,{dir:"ltr",onOpenChange:a,modal:!1,children:[d.jsx(Une,{onContextMenu:void 0,dir:"ltr",children:r?d.jsx(r,{}):null}),i&&d.jsx(Hne,{container:s,children:d.jsx(Kne,{className:"tlui-menu scrollable","data-testid":"context-menu",alignOffset:-4,collisionPadding:4,onContextMenu:Ee,children:d.jsx(Mr,{type:"context-menu",sourceId:"context-menu",children:l})})})]})}),hoe=2e3,poe=5e3,foe=Lt(function(){const t=F(),{isChatting:n,chatMessage:r}=t.getInstanceState(),o=P.useRef(-1),[s,i]=P.useState("");return P.useEffect(()=>{if(!n&&r||n){const l=n?poe:hoe;o.current=t.timers.setTimeout(()=>{t.updateInstanceState({chatMessage:"",isChatting:!1}),i(""),t.focus()},l)}return()=>{clearTimeout(o.current)}},[t,r,n]),n?d.jsx(moe,{value:s,setValue:i,chatMessage:r}):r.trim()?d.jsx(goe,{chatMessage:r}):null});function HR(e){const t=F();P.useLayoutEffect(()=>{var i;if(!e.current)return;const{x:r,y:o}=t.inputs.currentScreenPoint;(i=e.current)==null||i.style.setProperty("transform",`translate(${r}px, ${o}px)`);function s(a){var u;const{minX:l,minY:c}=t.getViewportScreenBounds();(u=e.current)==null||u.style.setProperty("transform",`translate(${a.clientX-l}px, ${a.clientY-c}px)`)}return window.addEventListener("pointermove",s),()=>{window.removeEventListener("pointermove",s)}},[e,t])}const goe=({chatMessage:e})=>{const t=F(),n=P.useRef(null);return HR(n),d.jsx("div",{ref:n,className:"tl-cursor-chat tl-cursor-chat__bubble",style:{backgroundColor:t.user.getColor()},children:e})},moe=Lt(function({chatMessage:t,value:n,setValue:r}){const o=F(),s=we(),i=P.useRef(null),a=t||s("cursor-chat.type-to-chat");HR(i),P.useLayoutEffect(()=>{const p=i.current;if(!p)return;const f=o.textMeasure.measureText(n||a,{fontFamily:"var(--font-body)",fontSize:12,fontWeight:"500",fontStyle:"normal",maxWidth:null,lineHeight:1,padding:"6px"});p.style.setProperty("width",f.w+"px")},[o,n,a]),P.useLayoutEffect(()=>{const p=o.timers.requestAnimationFrame(()=>{var f;(f=i.current)==null||f.focus()});return()=>{cancelAnimationFrame(p)}},[o]);const l=P.useCallback(()=>{o.updateInstanceState({isChatting:!1}),o.focus()},[o]),c=P.useCallback(p=>{const{value:f}=p.target;r(f.slice(0,64)),o.updateInstanceState({chatMessage:f})},[o,r]),u=P.useCallback(p=>{const f=i.current;if(!f)return;const{value:S}=f;switch(p.key){case"Enter":{if(Ee(p),p.stopPropagation(),!S){l();return}r("");break}case"Escape":{Ee(p),p.stopPropagation(),l();break}}},[l,r]),h=P.useCallback(p=>{p.stopPropagation()},[]);return d.jsx("input",{ref:i,className:"tl-cursor-chat",style:{backgroundColor:o.user.getColor()},onBlur:l,onChange:c,onKeyDown:u,onPaste:h,value:n,placeholder:a,spellCheck:!1})});function ox({checked:e}){return d.jsx(Eo,{icon:e?"check":"none",className:"tlui-button__icon",small:!0})}function yoe(){const e=F(),{addToast:t}=eo(),{addDialog:n}=aa(),[r,o]=Ce.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsxs(pe,{id:"items",children:[d.jsx(U,{id:"add-toast",onSelect:()=>{t({id:ct(),title:"Something good happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"success"}),t({id:ct(),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:ct(),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:ct(),title:"Something bad happened",severity:"error",keepOpen:!0})},label:"Show toast"}),d.jsx(U,{id:"show-dialog",label:"Show dialog",onSelect:()=>{n({component:({onClose:s})=>d.jsx(xoe,{displayDontShowAgain:!0,onCancel:()=>s(),onContinue:()=>s()}),onClose:()=>{}})}}),d.jsx(U,{id:"create-shapes",label:"Create 100 shapes",onSelect:()=>woe(e,100)}),d.jsx(U,{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})(),d.jsx(U,{id:"throw-error",onSelect:()=>o(!0),label:"Throw error"}),d.jsx(U,{id:"hard-reset",onSelect:E2,label:"Hard reset"})]}),d.jsxs(pe,{id:"flags",children:[d.jsx(Soe,{}),d.jsx(voe,{})]})]})}function Soe(){const e=Object.values(xt);return e.length?d.jsx(_n,{id:"debug flags",label:"Debug Flags",children:d.jsx(pe,{id:"debug flags",children:e.map(t=>d.jsx(KR,{flag:t},t.name))})}):null}function voe(){const e=Object.values(Vx);return e.length?d.jsx(_n,{id:"feature flags",label:"Feature Flags",children:d.jsx(pe,{id:"feature flags",children:e.map(t=>d.jsx(KR,{flag:t},t.name))})}):null}function xoe({title:e="title",body:t="hello hello hello",cancel:n="Cancel",confirm:r="Continue",displayDontShowAgain:o=!1,onCancel:s,onContinue:i}){const[a,l]=Ce.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsxs(Tg,{children:[d.jsx(Mg,{children:e}),d.jsx(Ag,{})]}),d.jsx(Eu,{style:{maxWidth:350},children:t}),d.jsxs(Lw,{className:"tlui-dialog__footer__actions",children:[o&&d.jsxs(ue,{type:"normal",onClick:()=>l(!a),style:{marginRight:"auto"},children:[d.jsx(ox,{checked:a}),d.jsx(bt,{children:"Don’t show again"})]}),d.jsx(ue,{type:"normal",onClick:s,children:d.jsx(bt,{children:n})}),d.jsx(ue,{type:"primary",onClick:async()=>i(),children:d.jsx(bt,{children:r})})]})]})}const KR=Lt(function({flag:t,onChange:n}){const r=t.get();return d.jsx(Yn,{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 gE=0;function woe(e,t){const n=Array(t),r=Math.floor(Math.sqrt(t));for(let o=0;o<t;o++)gE++,n[o]={id:$e("box"+gE),type:"geo",x:o%r*132,y:Math.floor(o/r)*132};e.run(()=>{e.createShapes(n).setSelectedShapes(n.map(o=>o.id))})}function boe({children:e}){const t=e??d.jsx(yoe,{});return d.jsxs(Zi,{id:"debug",children:[d.jsx(Qi,{children:d.jsx(ue,{type:"icon",title:"Debug menu",children:d.jsx(ve,{icon:"dots-horizontal"})})}),d.jsx(Ji,{side:"top",align:"end",alignOffset:0,children:d.jsx(Mr,{type:"menu",sourceId:"debug-panel",children:t})})]})}const Poe=P.memo(function(){const{DebugMenu:t}=fi();return d.jsxs("div",{className:"tlui-debug-panel",children:[d.jsx(Ioe,{}),d.jsx(Eoe,{}),t&&d.jsx(t,{})]})});function Coe(e=!0){const[t,n]=P.useState(0),r=F();P.useEffect(()=>{if(!e)return;const o=()=>n(s=>s+1);return r.on("tick",o),()=>{r.off("tick",o)}},[r,e])}const Ioe=Lt(function(){Coe();const t=F(),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:""} / [${b.ToInt(t.getPointInShapeSpace(s,t.inputs.currentPagePoint))}]`:"",a=n.startsWith("select.")&&!n.includes(".idle")?` / [${b.ToInt(t.inputs.originPagePoint)}] → [${b.ToInt(t.inputs.currentPagePoint)}] = ${b.Dist(t.inputs.originPagePoint,t.inputs.currentPagePoint).toFixed(0)}`:"";return d.jsx("div",{className:"tlui-debug-panel__current-state",children:`${n}${i}${a}`})});function Eoe(){const e=F(),t=K("show_fps",()=>xt.showFps.get(),[xt]),n=P.useRef(null);return P.useEffect(()=>{if(!t)return;const r=250;let o=0,s=-1,i=performance.now(),a=0,l=0,c=!1;function u(){if(l++,a=performance.now()-i,a>r){const h=Math.round(l*(r/a)*(1e3/r));h>o&&(o=h);const p=o*.75;(h<p&&!c||h>=p&&c)&&(c=!c),n.current.innerHTML=`FPS ${h.toString()}`,n.current.className="tlui-debug-panel__fps"+(c?" tlui-debug-panel__fps__slow":""),a-=r,l=0,i=performance.now()}s=e.timers.requestAnimationFrame(u)}return u(),()=>{cancelAnimationFrame(s)}},[t,e]),t?d.jsx("div",{ref:n}):null}const koe=P.memo(function(){const t=En(),{MainMenu:n,QuickActions:r,ActionsMenu:o,PageMenu:s}=fi();return!n&&!s&&t<6?null:d.jsx("div",{className:"tlui-menu-zone",children:d.jsxs("div",{className:"tlui-buttons__horizontal",children:[n&&d.jsx(n,{}),s&&d.jsx(s,{}),t<6?null:d.jsxs(d.Fragment,{children:[r&&d.jsx(r,{}),o&&d.jsx(o,{})]})]})})});function _oe(){const e=F(),t=ae(),[n,r]=P.useState(!1),o=P.useRef(!1);return Ls("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?d.jsx(U,{...t["back-to-content"],onSelect:()=>{t["back-to-content"].onSelect("helper-buttons"),r(!1)}}):null}function Toe(){const e=F(),t=ae();return K("is pen mode",()=>e.getInstanceState().isPenMode,[e])?d.jsx(U,{...t["exit-pen-mode"]}):null}function Moe(){const e=F(),t=ae();return K("is following user",()=>!!e.getInstanceState().followingUserId,[e])?d.jsx(U,{...t["stop-following"]}):null}function Aoe(){return d.jsxs(d.Fragment,{children:[d.jsx(Toe,{}),d.jsx(_oe,{}),d.jsx(Moe,{})]})}function joe({children:e}){const t=e??d.jsx(Aoe,{});return d.jsx("div",{className:"tlui-helper-buttons",children:d.jsx(Mr,{type:"helper-buttons",sourceId:"helper-buttons",children:t})})}function Ooe(){const e=ae(),t=Og(),n=Dg();return d.jsxs(d.Fragment,{children:[d.jsxs(pe,{label:"shortcuts-dialog.tools",id:"tools",children:[d.jsx(U,{...e["toggle-tool-lock"]}),d.jsx(U,{...e["insert-media"]}),d.jsx(U,{...t.select}),d.jsx(U,{...t.draw}),d.jsx(U,{...t.eraser}),d.jsx(U,{...t.hand}),d.jsx(U,{...t.rectangle}),d.jsx(U,{...t.ellipse}),d.jsx(U,{...t.arrow}),d.jsx(U,{...t.line}),d.jsx(U,{...t.text}),d.jsx(U,{...t.frame}),d.jsx(U,{...t.note}),d.jsx(U,{...t.laser})]}),d.jsxs(pe,{label:"shortcuts-dialog.preferences",id:"preferences",children:[d.jsx(U,{...e["toggle-dark-mode"]}),d.jsx(U,{...e["toggle-focus-mode"]}),d.jsx(U,{...e["toggle-grid"]})]}),d.jsxs(pe,{label:"shortcuts-dialog.edit",id:"edit",children:[d.jsx(U,{...e.undo}),d.jsx(U,{...e.redo}),d.jsx(U,{...e.cut}),d.jsx(U,{...e.copy}),d.jsx(U,{...e.paste}),d.jsx(U,{...e["select-all"]}),d.jsx(U,{...e.delete}),d.jsx(U,{...e.duplicate})]}),d.jsxs(pe,{label:"shortcuts-dialog.view",id:"view",children:[d.jsx(U,{...e["zoom-in"]}),d.jsx(U,{...e["zoom-out"]}),d.jsx(U,{...e["zoom-to-100"]}),d.jsx(U,{...e["zoom-to-fit"]}),d.jsx(U,{...e["zoom-to-selection"]})]}),d.jsxs(pe,{label:"shortcuts-dialog.transform",id:"transform",children:[d.jsx(U,{...e["bring-to-front"]}),d.jsx(U,{...e["bring-forward"]}),d.jsx(U,{...e["send-backward"]}),d.jsx(U,{...e["send-to-back"]}),d.jsx(U,{...e.group}),d.jsx(U,{...e.ungroup}),d.jsx(U,{...e["flip-horizontal"]}),d.jsx(U,{...e["flip-vertical"]}),d.jsx(U,{...e["align-top"]}),d.jsx(U,{...e["align-center-vertical"]}),d.jsx(U,{...e["align-bottom"]}),d.jsx(U,{...e["align-left"]}),d.jsx(U,{...e["align-center-horizontal"]}),d.jsx(U,{...e["align-right"]})]}),n&&d.jsx(pe,{label:"shortcuts-dialog.collaboration",id:"collaboration",children:d.jsx(U,{...e["open-cursor-chat"]})})]})}const Doe=P.memo(function({children:t}){const n=we(),r=En(),o=t??d.jsx(Ooe,{});return d.jsxs(d.Fragment,{children:[d.jsxs(Tg,{className:"tlui-shortcuts-dialog__header",children:[d.jsx(Mg,{children:n("shortcuts-dialog.title")}),d.jsx(Ag,{})]}),d.jsx(Eu,{className:ce("tlui-shortcuts-dialog__body",{"tlui-shortcuts-dialog__body__mobile":r<=yt.MOBILE_XS,"tlui-shortcuts-dialog__body__tablet":r<=yt.TABLET}),children:d.jsx(Mr,{type:"keyboard-shortcuts",sourceId:"kbd",children:o})}),d.jsx("div",{className:"tlui-dialog__scrim"})]})}),Roe=[{colorScheme:"light",label:"theme.light"},{colorScheme:"dark",label:"theme.dark"},{colorScheme:"system",label:"theme.system"}];function Loe(){const e=F(),t=Zt(),n=K("colorScheme",()=>e.user.getUserPreferences().colorScheme??e.user.getIsDarkMode()?"dark":"light",[e]);return d.jsx(_n,{id:"help menu color-scheme",label:"menu.theme",children:d.jsx(pe,{id:"languages",children:Roe.map(({colorScheme:r,label:o})=>d.jsx(Yn,{id:`color-scheme-${r}`,label:o,checked:r===n,onSelect:()=>{e.user.updateUserPreferences({colorScheme:r}),t("color-scheme",{source:"menu",value:r})}},r))})})}function WR(){const e=F(),t=Zt(),n=K("locale",()=>e.user.getLocale(),[e]);return d.jsx(_n,{id:"help menu language",label:"menu.language",children:d.jsx(pe,{id:"languages",children:iu.map(({locale:r,label:o})=>d.jsx(Yn,{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 $oe(){return d.jsxs(d.Fragment,{children:[d.jsx(WR,{}),d.jsx(GR,{})]})}function GR(){const{KeyboardShortcutsDialog:e}=fi(),{addDialog:t}=aa();return e?d.jsx(U,{id:"keyboard-shortcuts-button",label:"help-menu.keyboard-shortcuts",readonlyOk:!0,onSelect:()=>{t({component:e})}}):null}function Noe(){return d.jsxs(d.Fragment,{children:[d.jsx(zoe,{}),d.jsx(Koe,{}),d.jsx(Foe,{}),d.jsx(Woe,{}),d.jsx(Voe,{}),d.jsx(Goe,{})]})}function Foe(){const e=ae();return d.jsxs(_n,{id:"export-all-as",label:"context-menu.export-all-as",size:"small",children:[d.jsxs(pe,{id:"export-all-as-group",children:[d.jsx(U,{...e["export-all-as-svg"]}),d.jsx(U,{...e["export-all-as-png"]}),d.jsx(U,{...e["export-all-as-json"]})]}),d.jsx(pe,{id:"export-all-as-bg",children:d.jsx(S1,{})})]})}function zoe(){const e=F(),t=K("isSelectToolActive",()=>e.getCurrentToolId()==="select",[e]);return d.jsxs(_n,{id:"edit",label:"menu.edit",disabled:!t,children:[d.jsx(Hoe,{}),d.jsx(NR,{}),d.jsx(FR,{}),d.jsx(Boe,{}),d.jsx(Uoe,{}),d.jsx(pe,{id:"select-all",children:d.jsx(zR,{})})]})}function Boe(){return d.jsxs(pe,{id:"misc",children:[d.jsx(MR,{}),d.jsx(AR,{}),d.jsx(_R,{}),d.jsx(kR,{}),d.jsx(jR,{}),d.jsx(OR,{}),d.jsx(UR,{}),d.jsx(BR,{}),d.jsx(TR,{})]})}function Uoe(){return d.jsxs(pe,{id:"lock",children:[d.jsx(DR,{}),d.jsx(Bre,{})]})}function Hoe(){const e=ae(),t=lD(),n=aD();return d.jsxs(pe,{id:"undo-redo",children:[d.jsx(U,{...e.undo,disabled:!t}),d.jsx(U,{...e.redo,disabled:!n})]})}function Koe(){const e=ae();return d.jsx(_n,{id:"view",label:"menu.view",children:d.jsxs(pe,{id:"view-actions",children:[d.jsx(U,{...e["zoom-in"]}),d.jsx(U,{...e["zoom-out"]}),d.jsx(RR,{}),d.jsx(LR,{}),d.jsx($R,{})]})})}function Woe(){const e=ae();return d.jsxs(pe,{id:"extras",children:[d.jsx(U,{...e["insert-embed"]}),d.jsx(U,{...e["insert-media"]})]})}function Goe(){function e(t){window.open(t,"_blank")}return d.jsx(pe,{id:"help",children:d.jsx(_n,{id:"help",label:"menu.help",children:d.jsxs(pe,{id:"help-actions",children:[d.jsx(GR,{}),d.jsx(U,{id:"about",label:"help-menu.docs",icon:"external-link",readonlyOk:!0,onSelect:()=>{e("https://tldraw.dev")}})]})})})}function Voe(){return d.jsx(pe,{id:"preferences",children:d.jsxs(_n,{id:"preferences",label:"menu.preferences",children:[d.jsxs(pe,{id:"preferences-actions",children:[d.jsx(Jre,{}),d.jsx(eoe,{}),d.jsx(toe,{}),d.jsx(noe,{}),d.jsx(roe,{}),d.jsx(ooe,{}),d.jsx(soe,{}),d.jsx(aoe,{}),d.jsx(loe,{}),d.jsx(ioe,{})]}),d.jsx(pe,{id:"color-scheme",children:d.jsx(Loe,{})}),d.jsx(pe,{id:"language",children:d.jsx(WR,{})})]})})}const Yoe=P.memo(function({children:t}){const n=$t(),[r,o]=ps("main menu"),s=we(),i=t??d.jsx(Noe,{});return d.jsxs(g1,{dir:"ltr",open:r,onOpenChange:o,modal:!1,children:[d.jsx(m1,{asChild:!0,dir:"ltr",children:d.jsx(ue,{type:"icon","data-testid":"main-menu.button",title:s("menu.title"),children:d.jsx(ve,{icon:"menu",small:!0})})}),d.jsx(Ug,{container:n,children:d.jsx(y1,{className:"tlui-menu",side:"bottom",align:"start",collisionPadding:4,alignOffset:0,sideOffset:6,children:d.jsx(Mr,{type:"menu",sourceId:"main-menu",children:i})})})]})}),Ry={};function hc(e){if(Ry[e])return Ry[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 Ry[e]=a,a}const Sp=10,VR=4*6*Sp+12+4*12;function Pa(e,{center:t,radius:n,numArcSegments:r=20,startAngle:o=0,endAngle:s=Le,offset:i=0}){const a=(s-o)/r;let l=i;for(let c=o;c<s;c+=a)e[l++]=t.x,e[l++]=t.y,e[l++]=t.x+Math.cos(c)*n,e[l++]=t.y+Math.sin(c)*n,e[l++]=t.x+Math.cos(c+a)*n,e[l++]=t.y+Math.sin(c+a)*n;return e}function Ca(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 Xoe(e,t,n){const r=Sp;n=Math.min(n,Math.min(t.w,t.h)/2);const o=Q.ExpandBy(t,-n);if(o.w<=0||o.h<=0)return Pa(e,{center:t.center,radius:n,numArcSegments:Sp*4}),Sp*4*6;let s=0;return Ca(e,s,o.minX,o.minY,o.w,o.h),s+=12,Ca(e,s,o.minX,t.minY,o.w,n),s+=12,Ca(e,s,o.maxX,o.minY,n,o.h),s+=12,Ca(e,s,o.minX,o.maxY,o.w,n),s+=12,Ca(e,s,t.minX,o.minY,n,o.h),s+=12,Pa(e,{numArcSegments:r,offset:s,center:o.point,radius:n,startAngle:Me,endAngle:Me*1.5}),s+=r*6,Pa(e,{numArcSegments:r,offset:s,center:b.Add(o.point,new b(o.w,0)),radius:n,startAngle:Me*1.5,endAngle:Le}),s+=r*6,Pa(e,{numArcSegments:r,offset:s,center:b.Add(o.point,o.size),radius:n,startAngle:0,endAngle:Ve}),s+=r*6,Pa(e,{numArcSegments:r,offset:s,center:b.Add(o.point,new b(0,o.h)),radius:n,startAngle:Ve,endAngle:Me}),VR}function qoe(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
|
|
348
|
+
precision mediump float;
|
|
349
|
+
|
|
350
|
+
in vec2 shapeVertexPosition;
|
|
351
|
+
|
|
352
|
+
uniform vec4 canvasPageBounds;
|
|
353
|
+
|
|
354
|
+
// taken (with thanks) from
|
|
355
|
+
// https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html
|
|
356
|
+
void main() {
|
|
357
|
+
// convert the position from pixels to 0.0 to 1.0
|
|
358
|
+
vec2 zeroToOne = (shapeVertexPosition - canvasPageBounds.xy) / canvasPageBounds.zw;
|
|
359
|
+
|
|
360
|
+
// convert from 0->1 to 0->2
|
|
361
|
+
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
362
|
+
|
|
363
|
+
// convert from 0->2 to -1->+1 (clipspace)
|
|
364
|
+
vec2 clipSpace = zeroToTwo - 1.0;
|
|
365
|
+
|
|
366
|
+
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
|
|
367
|
+
}`,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
|
|
368
|
+
precision mediump float;
|
|
369
|
+
|
|
370
|
+
uniform vec4 fillColor;
|
|
371
|
+
out vec4 outputColor;
|
|
372
|
+
|
|
373
|
+
void main() {
|
|
374
|
+
outputColor = fillColor;
|
|
375
|
+
}`,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 l=t.getUniformLocation(i,"canvasPageBounds"),c=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:xh(t,1024),unselectedShapes:xh(t,4096),viewport:xh(t,VR),collaborators:xh(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(c,p)},setCanvasPageBounds(p){t.uniform4fv(l,p)}}}function xh(e,t){const n=e.createBuffer();if(!n)throw new Error("Failed to create buffer");return{buffer:n,vertices:new Float32Array(t)}}function mE(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 Zoe=Object.defineProperty,Qoe=Object.getOwnPropertyDescriptor,pi=(e,t,n,r)=>{for(var o=Qoe(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&Zoe(t,n,o),o};class gs{constructor(t,n,r){g(this,"disposables",[]);g(this,"close",()=>this.disposables.forEach(t=>t()));g(this,"gl");g(this,"shapeGeometryCache");g(this,"colors");g(this,"id",ct());g(this,"canvasBoundingClientRect",Mt("canvasBoundingClientRect",new Q));g(this,"originPagePoint",new b);g(this,"originPageCenter",new b);g(this,"isInViewport",!1);g(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 b(s,i,1)});g(this,"minimapScreenPointToPagePoint",(t,n,r=!1,o=!1)=>{const{editor:s}=this,i=s.getViewportPageBounds();let{x:a,y:l}=this.getMinimapPagePoint(t,n);if(o){const c=this.editor.getCurrentPageBounds()??new Q,u=c.minX-i.width/2,h=c.maxX+i.width/2,p=c.minY-i.height/2,f=c.maxY+i.height/2,S=Math.max(0,u+i.width-a),y=Math.max(0,-(h-i.width-a)),x=Math.max(0,p+i.height-l),m=Math.max(0,-(f-i.height-l));a+=(S-y)/2,l+=(x-m)/2,a=_t(a,u,h),l=_t(l,p,f)}if(r){const{originPagePoint:c}=this,u=Math.abs(a-c.x),h=Math.abs(l-c.y);u>h?l=c.y:a=c.x}return new b(a,l)});g(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 l=0,c=a.length;l<c;l++){const u=a[l],h=this.shapeGeometryCache.get(u);if(!h)continue;const p=h.length;r.has(u)?(mE(this.gl.selectedShapes,s,h),s+=p):(mE(this.gl.unselectedShapes,i,h),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.container=r,this.gl=qoe(n),this.shapeGeometryCache=t.store.createComputedCache("webgl-geometry",o=>{const s=t.getShapeMaskedPageBounds(o.id);if(!s)return null;const i=new Float32Array(12);return Ca(i,0,s.x,s.y,s.w,s.h),i}),this.colors=this._getColors(),this.disposables.push(this._listenForCanvasResize(),ra("minimap render",this.render))}_getColors(){const t=getComputedStyle(this.editor.getContainer());return{shapeFill:hc(t.getPropertyValue("--color-text-3").trim()),selectFill:hc(t.getPropertyValue("--color-selected").trim()),viewportFill:hc(t.getPropertyValue("--color-muted-1").trim()),background:hc(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?Q.Expand(n,t):t}getContentScreenBounds(){const t=this.getContentPageBounds(),n=this.editor.pageToScreen(t.point),r=this.editor.pageToScreen(new b(t.maxX,t.maxY));return new Q(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 Q(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.observe(this.container),()=>t.disconnect()}getCanvasSize(){const t=this.canvasBoundingClientRect.get(),n=this.getDpr();return new b(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 Q(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=Xoe(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),this.editor.environment.isSafari&&(this.gl.drawTrianglesTransparently(n),this.gl.drawTrianglesTransparently(n),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:l}of t)Pa(s,{center:b.From(l),radius:3*a,offset:i,numArcSegments:n}),i+=r;this.gl.prepareTriangles(this.gl.collaborators,o),i=0;for(const{color:l}of t)this.gl.setFillColor(hc(l)),this.gl.context.drawArrays(this.gl.context.TRIANGLES,i/2,r/2),i+=r}}pi([G],gs.prototype,"getDpr");pi([G],gs.prototype,"getContentPageBounds");pi([G],gs.prototype,"getContentScreenBounds");pi([G],gs.prototype,"getCanvasSize");pi([G],gs.prototype,"getCanvasClientPosition");pi([G],gs.prototype,"getCanvasPageBounds");pi([G],gs.prototype,"getZoom");pi([G],gs.prototype,"getCanvasPageBoundsArray");function Joe(){const e=F(),t=$t(),n=P.useRef(null),r=P.useRef(!1),o=P.useRef();P.useEffect(()=>{try{const u=new gs(e,n.current,t);return o.current=u,o.current.close}catch(u){e.annotateError(u,{origin:"minimap",willCrashApp:!1}),e.timers.setTimeout(()=>{throw u})}},[e,t]);const s=P.useCallback(u=>{if(!e.getCurrentPageShapeIds().size||!o.current)return;const h=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!1),p=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!0);o.current.originPagePoint.setTo(p),o.current.originPageCenter.setTo(e.getViewportPageBounds().center),e.centerOnPoint(h,{animation:{duration:e.options.animationMediumMs}})},[e]),i=P.useCallback(u=>{if(!o.current)return;const h=u.currentTarget;if(Wu(h,u),!e.getCurrentPageShapeIds().size)return;r.current=!0,o.current.isInViewport=!1;const p=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!1),f=e.getViewportPageBounds(),S=o.current.getContentPageBounds();if(new Q(S.x-f.width/2,S.y-f.height/2,S.width+f.width,S.height+f.height).containsPoint(p)&&!f.containsPoint(p)){o.current.isInViewport=f.containsPoint(p);const m=b.Sub(f.center,f.point),v=b.Add(p,m);o.current.originPagePoint.setTo(v),o.current.originPageCenter.setTo(p),e.centerOnPoint(p,{animation:{duration:e.options.animationMediumMs}})}else{const m=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!0);o.current.isInViewport=f.containsPoint(m),o.current.originPagePoint.setTo(m),o.current.originPageCenter.setTo(f.center)}function x(m){h&&Gu(h,m),r.current=!1,document.body.removeEventListener("pointerup",x)}document.body.addEventListener("pointerup",x)},[e]),a=P.useCallback(u=>{if(!o.current)return;const h=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,u.shiftKey,!0);if(r.current){if(o.current.isInViewport){const y=o.current.originPagePoint.clone().sub(o.current.originPageCenter);e.centerOnPoint(b.Sub(h,y));return}e.centerOnPoint(h)}const p=o.current.getMinimapPagePoint(u.clientX,u.clientY),f=e.pageToScreen(p),S={type:"pointer",target:"canvas",name:"pointer_move",...Fn(u),point:f,isPen:e.getInstanceState().isPenMode};e.dispatch(S)},[e]),l=P.useCallback(u=>{const h=f2(u);e.dispatch({type:"wheel",name:"wheel",delta:h,point:new b(u.clientX,u.clientY),shiftKey:u.shiftKey,altKey:u.altKey,ctrlKey:u.metaKey||u.ctrlKey})},[e]),c=td();return P.useEffect(()=>{e.timers.setTimeout(()=>{var u,h;(u=o.current)==null||u.updateColors(),(h=o.current)==null||h.render()})},[c,e]),d.jsx("div",{className:"tlui-minimap",children:d.jsx("canvas",{role:"img","aria-label":"minimap",ref:n,className:"tlui-minimap__canvas",onDoubleClick:s,onPointerMove:a,onPointerDown:i,onWheel:l})})}function ese(e,t){const[n,r]=Ce.useState(t);Ce.useLayoutEffect(()=>{const s=Kx(e);if(s)try{r(JSON.parse(s))}catch{console.error(`Could not restore value ${e} from local storage.`)}},[e]);const o=Ce.useCallback(s=>{r(i=>{const a=typeof s=="function"?s(i):s;return Wx(e,JSON.stringify(a)),a})},[e]);return[n,o]}const tse=P.memo(function(){const t=ae(),n=we(),r=En(),[o,s]=ese("minimap",!0),i=P.useCallback(()=>{s(c=>!c)},[s]),{ZoomMenu:a,Minimap:l}=fi();return r<yt.MOBILE?null:d.jsxs("div",{className:"tlui-navigation-panel",children:[d.jsx("div",{className:"tlui-buttons__horizontal",children:a&&r<yt.TABLET?d.jsx(a,{}):o?d.jsxs(d.Fragment,{children:[a&&d.jsx(a,{}),l&&d.jsx(ue,{type:"icon","data-testid":"minimap.toggle-button",title:n("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:i,children:d.jsx(ve,{icon:o?"chevrons-ne":"chevrons-sw"})})]}):d.jsxs(d.Fragment,{children:[d.jsx(ue,{type:"icon","data-testid":"minimap.zoom-out",title:`${n(ku(t["zoom-out"].label))} ${rx(t["zoom-out"].kbd)}`,onClick:()=>t["zoom-out"].onSelect("navigation-zone"),children:d.jsx(ve,{icon:"minus"})}),a&&d.jsx(a,{}),d.jsx(ue,{type:"icon","data-testid":"minimap.zoom-in",title:`${n(ku(t["zoom-in"].label))} ${rx(t["zoom-in"].kbd)}`,onClick:()=>t["zoom-in"].onSelect("navigation-zone"),children:d.jsx(ve,{icon:"plus"})}),l&&d.jsx(ue,{type:"icon","data-testid":"minimap.toggle-button",title:n("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:i,children:d.jsx(ve,{icon:o?"chevrons-ne":"chevrons-sw"})})]})}),l&&r>=yt.TABLET&&!o&&d.jsx(l,{})]})}),nse=function({name:t,id:n,isCurrentPage:r}){const o=F(),s=Zt(),i=P.useRef(null),a=P.useCallback(()=>{o.mark("rename page")},[o]),l=P.useCallback(c=>{o.renamePage(n,c||"New Page"),s("rename-page",{source:"page-menu"})},[o,n,s]);return d.jsx(jg,{className:"tlui-page-menu__item__input",ref:c=>i.current=c,defaultValue:t,onValueChange:l,onFocus:a,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:r,autoSelect:!0})},sx=(e,t,n,r,o)=>{let s;const i=e.getPages(),a=n>r?i[r-1]:i[r],l=n>r?i[r]:i[r+1];a&&!l?s=zr(a.index):!a&&l?s=TB(i[0].index):s=ru(a.index,l.index),s!==i[n].index&&(e.mark("moving page"),e.updatePage({id:t,index:s}),o("move-page",{source:"page-menu"}))},yE=Lt(function({index:t,listSize:n,item:r,onRename:o}){const s=F(),i=we(),a=s.getPages(),l=Zt(),c=P.useCallback(()=>{s.mark("creating page");const f=Jo.createId();s.duplicatePage(r.id,f),l("duplicate-page",{source:"page-menu"})},[s,r,l]),u=P.useCallback(()=>{sx(s,r.id,t,t-1,l)},[s,r,t,l]),h=P.useCallback(()=>{sx(s,r.id,t,t+1,l)},[s,r,t,l]),p=P.useCallback(()=>{s.mark("deleting page"),s.deletePage(r.id),l("delete-page",{source:"page-menu"})},[s,r,l]);return d.jsxs(Zi,{id:`page item submenu ${t}`,children:[d.jsx(Qi,{children:d.jsx(ue,{type:"icon",title:i("page-menu.submenu.title"),children:d.jsx(ve,{icon:"dots-vertical"})})}),d.jsx(Ji,{alignOffset:0,side:"right",sideOffset:-4,children:d.jsxs(Mr,{type:"menu",sourceId:"page-menu",children:[d.jsxs(pe,{id:"modify",children:[o&&d.jsx(U,{id:"rename",label:"page-menu.submenu.rename",onSelect:o}),d.jsx(U,{id:"duplicate",label:"page-menu.submenu.duplicate-page",onSelect:c,disabled:a.length>=s.options.maxPages}),t>0&&d.jsx(U,{id:"move-up",onSelect:u,label:"page-menu.submenu.move-up"}),t<n-1&&d.jsx(U,{id:"move-down",label:"page-menu.submenu.move-down",onSelect:h})]}),n>1&&d.jsx(pe,{id:"delete",children:d.jsx(U,{id:"delete",onSelect:p,label:"page-menu.submenu.delete"})})]})})]})}),rse=P.memo(function(){const t=F(),n=Zt(),r=we(),o=En(),s=P.useCallback(()=>m(!1),[]),[i,a]=ps("page-menu",s),l=36,c=P.useRef(null),u=K("pages",()=>t.getPages(),[t]),h=K("currentPage",()=>t.getCurrentPage(),[t]),p=K("currentPageId",()=>t.getCurrentPageId(),[t]),f=ds(),S=K("maxPageCountReached",()=>t.getPages().length>=t.options.maxPages,[t]),y=K("isCoarsePointer",()=>t.getInstanceState().isCoarsePointer,[t]),[x,m]=P.useState(!1),v=P.useCallback(()=>{f||m(j=>!j)},[f]),w=P.useRef({isPointing:!1,status:"idle",pointing:null,startY:0,startIndex:0,dragIndex:0}),[C,E]=P.useState(Object.fromEntries(u.map((j,O)=>[j.id,{y:O*l,offsetY:0,isSelected:!1}])));P.useLayoutEffect(()=>{E(Object.fromEntries(u.map((j,O)=>[j.id,{y:O*l,offsetY:0,isSelected:!1}])))},[l,u]),P.useEffect(()=>{i&&t.timers.requestAnimationFrame(()=>{const j=document.querySelector(`[data-testid="page-menu-item-${p}"]`);if(j){const O=c.current;if(!O)return;const R=j.offsetTop,H=O.scrollTop;R<H&&O.scrollTo({top:R});const B=R+l,z=O.scrollTop+O.offsetHeight;B>z&&O.scrollTo({top:B-O.offsetHeight})}})},[l,p,i,t]);const _=P.useCallback(j=>{const{clientY:O,currentTarget:R}=j,{dataset:{id:H,index:B}}=R;if(!H||!B)return;const z=w.current;Wu(j.currentTarget,j),z.status="pointing",z.pointing={id:H,index:+B};const Y=C[H].y;z.startY=O,z.startIndex=Math.max(0,Math.min(Math.round(Y/l),u.length-1))},[l,u.length,C]),I=P.useCallback(j=>{const O=w.current;if(O.status==="pointing"){const{clientY:R}=j,H=R-O.startY;Math.abs(H)>5&&(O.status="dragging")}if(O.status==="dragging"){const{clientY:R}=j,H=R-O.startY,B=C[O.pointing.id],{startIndex:z,pointing:W}=O,Y=B.y+H,q=Math.max(0,Math.min(Math.round(Y/l),u.length-1)),le={...C};if(le[W.id]={y:B.y,offsetY:H,isSelected:!0},q!==O.dragIndex){O.dragIndex=q;for(let ge=0;ge<u.length;ge++){const be=u[ge];if(be.id===O.pointing.id)continue;let{y:J}=le[be.id];q===z?J=ge*l:q<z?q<=ge&&ge<z?J=(ge+1)*l:J=ge*l:q>z&&(q>=ge&&ge>z?J=(ge-1)*l:J=ge*l),J!==le[be.id].y&&(le[be.id]={y:J,offsetY:0,isSelected:!0})}}E(le)}},[l,u,C]),k=P.useCallback(j=>{const O=w.current;if(O.status==="dragging"){const{id:R,index:H}=O.pointing;sx(t,R,H,O.dragIndex,n)}Gu(j.currentTarget,j),O.status="idle"},[t,n]),T=P.useCallback(j=>{const O=w.current;j.key==="Escape"&&(O.status==="dragging"&&E(Object.fromEntries(u.map((R,H)=>[R.id,{y:H*l,offsetY:0,isSelected:!1}]))),O.status="idle")},[l,u]),M=P.useCallback(()=>{f||(t.run(()=>{t.mark("creating page");const j=Jo.createId();t.createPage({name:r("page-menu.new-page-initial-name"),id:j}),t.setCurrentPage(j),m(!0)}),n("new-page",{source:"page-menu"}))},[t,r,f,n]),D=P.useCallback(j=>{t.setCurrentPage(j),n("change-page",{source:"page-menu"})},[t,n]),$=P.useCallback((j,O)=>{t.renamePage(j,O),n("rename-page",{source:"page-menu"})},[t,n]);return d.jsxs(e1,{id:"pages",onOpenChange:a,open:i,children:[d.jsx(t1,{"data-testid":"main.page-menu",children:d.jsxs(ue,{type:"menu",title:h.name,"data-testid":"page-menu.button",className:"tlui-page-menu__trigger",children:[d.jsx("div",{className:"tlui-page-menu__name",children:h.name}),d.jsx(ve,{icon:"chevron-down",small:!0})]})}),d.jsx(n1,{side:"bottom",align:"start",sideOffset:6,children:d.jsxs("div",{className:"tlui-page-menu__wrapper",children:[d.jsxs("div",{className:"tlui-page-menu__header",children:[d.jsx("div",{className:"tlui-page-menu__header__title",children:r("page-menu.title")}),!f&&d.jsxs("div",{className:"tlui-buttons__horizontal",children:[d.jsx(ue,{type:"icon","data-testid":"page-menu.edit",title:r(x?"page-menu.edit-done":"page-menu.edit-start"),onClick:v,children:d.jsx(ve,{icon:x?"check":"edit"})}),d.jsx(ue,{type:"icon","data-testid":"page-menu.create",title:r(S?"page-menu.max-page-count-reached":"page-menu.create-new-page"),disabled:S,onClick:M,children:d.jsx(ve,{icon:"plus"})})]})]}),d.jsx("div",{"data-testid":"page-menu.list",className:"tlui-page-menu__list tlui-menu__group",style:{height:l*u.length+4},ref:c,children:u.map((j,O)=>{const R=C[j.id]??{position:O*40,offsetY:0};return x?d.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page_menu__item__sortable",style:{zIndex:j.id===h.id?888:O,transform:`translate(0px, ${R.y+R.offsetY}px)`},children:[d.jsx(ue,{type:"icon",tabIndex:-1,className:"tlui-page_menu__item__sortable__handle",onPointerDown:_,onPointerUp:k,onPointerMove:I,onKeyDown:T,"data-id":j.id,"data-index":O,children:d.jsx(ve,{icon:"drag-handle-dots"})}),o<yt.TABLET_SM&&y?d.jsxs(ue,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>{const H=window.prompt("Rename page",j.name);H&&H!==j.name&&$(j.id,H)},onDoubleClick:v,children:[d.jsx(ox,{checked:j.id===h.id}),d.jsx(bt,{children:j.name})]}):d.jsx("div",{className:"tlui-page_menu__item__sortable__title",style:{height:l},children:d.jsx(nse,{id:j.id,name:j.name,isCurrentPage:j.id===h.id})}),!f&&d.jsx("div",{className:"tlui-page_menu__item__submenu","data-isediting":x,children:d.jsx(yE,{index:O,item:j,listSize:u.length})})]},j.id+"_editing"):d.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page-menu__item",children:[d.jsxs(ue,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>D(j.id),onDoubleClick:v,title:r("page-menu.go-to-page"),children:[d.jsx(ox,{checked:j.id===h.id}),d.jsx(bt,{children:j.name})]}),!f&&d.jsx("div",{className:"tlui-page_menu__item__submenu",children:d.jsx(yE,{index:O,item:j,listSize:u.length,onRename:()=>{if(t.environment.isIos){const H=window.prompt("Rename page",j.name);H&&H!==j.name&&$(j.id,H)}else m(!0),p!==j.id&&D(j.id)}})})]},j.id)})})]})})]})});function ose(){const e=ae(),t=F(),n=lD(),r=aD(),o=kn(1),s=ds(),i=K("should display quick actions",()=>t.isInAny("select","hand","zoom"),[t]),a=fs(),l=o&&a;if(!(s&&!i))return d.jsxs(d.Fragment,{children:[d.jsx(U,{...e.undo,disabled:!n}),d.jsx(U,{...e.redo,disabled:!r}),d.jsx(U,{...e.delete,disabled:!l}),d.jsx(U,{...e.duplicate,disabled:!l})]})}const sse=P.memo(function({children:t}){const n=t??d.jsx(ose,{});return d.jsx(Mr,{type:"small-icons",sourceId:"quick-actions",children:n})});function ise({userId:e}){const t=Yf(e);return t?d.jsx("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:t.color},children:t.userName==="New User"?"":t.userName[0]??""},e):null}const ase=Lt(function({userId:t}){const n=F(),r=we(),o=Zt(),s=Yf(t),i=P.useCallback(()=>{n.getInstanceState().followingUserId===t?(n.stopFollowingUser(),o("stop-following",{source:"people-menu"})):(n.startFollowingUser(t),o("start-following",{source:"people-menu"}))},[n,t,o]),a=(s==null?void 0:s.followingUserId)===n.user.getId(),l=n.getInstanceState().followingUserId===t;return s?d.jsxs("div",{className:"tlui-people-menu__item tlui-buttons__horizontal",children:[d.jsxs(ue,{type:"menu",className:"tlui-people-menu__item__button",onClick:()=>n.zoomToUser(t),onDoubleClick:i,children:[d.jsx(Eo,{icon:"color",color:s.color}),d.jsx("div",{className:"tlui-people-menu__name",children:s.userName??"New User"})]}),d.jsx(ue,{type:"icon",className:"tlui-people-menu__item__follow",title:r(a?"people-menu.leading":l?"people-menu.following":"people-menu.follow"),onClick:i,disabled:a,"data-active":l||a,children:d.jsx(ve,{icon:a?"leading":l?"following":"follow"})})]}):null});function lse({count:e}){return d.jsx("div",{className:"tlui-people-menu__more",children:"+"+Math.abs(e)})}const cse=Lt(function(){const t=F(),n=$t(),r=we(),o=Zt(),s=P.useRef(!1),[i,a]=P.useState(!1),l=P.useCallback(y=>{a(y)},[]),c=t.user.getColor(),u=P.useCallback(y=>{t.user.updateUserPreferences({color:y}),o("set-color",{source:"people-menu"})},[t,o]),{handleButtonClick:h,handleButtonPointerDown:p,handleButtonPointerEnter:f,handleButtonPointerUp:S}=Ce.useMemo(()=>{const y=()=>{s.current=!1,window.removeEventListener("pointerup",y)};return{handleButtonClick:C=>{const{id:E}=C.currentTarget.dataset;E&&c!==E&&u(E)},handleButtonPointerDown:C=>{const{id:E}=C.currentTarget.dataset;E&&(u(E),s.current=!0,window.addEventListener("pointerup",y))},handleButtonPointerEnter:C=>{if(!s.current)return;const{id:E}=C.currentTarget.dataset;E&&u(E)},handleButtonPointerUp:C=>{const{id:E}=C.currentTarget.dataset;E&&u(E)}}},[c,u]);return d.jsxs(qw,{onOpenChange:l,open:i,children:[d.jsx(Zw,{dir:"ltr",asChild:!0,children:d.jsx(ue,{type:"icon",className:"tlui-people-menu__user__color",style:{color:t.user.getColor()},title:r("people-menu.change-color"),children:d.jsx(ve,{icon:"color"})})}),d.jsx(Qw,{container:n,children:d.jsx(Jw,{dir:"ltr",className:"tlui-menu tlui-people-menu__user__color-picker",align:"start",side:"left",sideOffset:8,children:d.jsx("div",{className:"tlui-buttons__grid",children:OS.map(y=>d.jsx(ue,{type:"icon","data-id":y,"data-testid":y,"aria-label":y,"data-state":c===y?"hinted":void 0,title:y,className:"tlui-button-grid__button",style:{color:y},onPointerEnter:f,onPointerDown:p,onPointerUp:S,onClick:h,children:d.jsx(ve,{icon:"color"})},y))})})})]})});function use(){const e=F(),t=Zt(),n=K("userName",()=>e.user.getName(),[]),r=we(),o=P.useRef(n),s=P.useRef(n),[i,a]=P.useState(!1),l=P.useCallback(()=>{a(h=>!h)},[]),c=P.useCallback(h=>{s.current=h,e.user.updateUserPreferences({name:h})},[e]),u=P.useCallback(()=>{o.current!==s.current&&(t("change-user-name",{source:"people-menu"}),o.current=s.current)},[t]);return d.jsxs("div",{className:"tlui-people-menu__user",children:[d.jsx(cse,{}),i?d.jsx(jg,{className:"tlui-people-menu__user__input",defaultValue:n,onValueChange:c,onComplete:l,onCancel:l,onBlur:u,shouldManuallyMaintainScrollPositionWhenFocused:!0,autoFocus:!0,autoSelect:!0}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"tlui-people-menu__user__name",onDoubleClick:()=>{i||a(!0)},children:n}),n==="New User"?d.jsx("div",{className:"tlui-people-menu__user__label",children:r("people-menu.user")}):null]}),d.jsx(ue,{type:"icon",className:"tlui-people-menu__user__edit","data-testid":"people-menu.change-name",title:r("people-menu.change-name"),onClick:l,children:d.jsx(ve,{icon:i?"check":"edit"})})]})}const dse=Lt(function({children:t}){const n=we(),r=$t(),o=F(),s=v2(),i=K("user",()=>o.user.getColor(),[o]),a=K("user",()=>o.user.getName(),[o]),[l,c]=ps("people menu");return d.jsxs(qw,{onOpenChange:c,open:l,children:[d.jsx(Zw,{dir:"ltr",asChild:!0,children:d.jsxs("button",{className:"tlui-people-menu__avatars-button",title:n("people-menu.title"),children:[s.length>5&&d.jsx(lse,{count:s.length-5}),d.jsxs("div",{className:"tlui-people-menu__avatars",children:[s.slice(-5).map(u=>d.jsx(ise,{userId:u},u)),d.jsx("div",{className:"tlui-people-menu__avatar",style:{backgroundColor:i},children:a==="New User"?"":a[0]??""})]})]})}),d.jsx(Qw,{container:r,children:d.jsx(Jw,{dir:"ltr",className:"tlui-menu",align:"end",side:"bottom",sideOffset:2,alignOffset:-5,children:d.jsxs("div",{className:"tlui-people-menu__wrapper",children:[d.jsx("div",{className:"tlui-people-menu__section",children:d.jsx(use,{})}),s.length>0&&d.jsx("div",{className:"tlui-people-menu__section",children:s.map(u=>d.jsx(ase,{userId:u},u+"_presence"))}),t]})})})]})});function hse(){return d.jsx("div",{className:"tlui-share-zone",draggable:!1,children:d.jsx(dse,{})})}const pse=Object.freeze([cr,Ni,Fi,Co]);function YR(e=pse){const t=F();return K("getRelevantStyles",()=>{var s;const n=new _v(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 Ir={color:[{value:"black",icon:"color"},{value:"grey",icon:"color"},{value:"light-violet",icon:"color"},{value:"violet",icon:"color"},{value:"blue",icon:"color"},{value:"light-blue",icon:"color"},{value:"yellow",icon:"color"},{value:"orange",icon:"color"},{value:"green",icon:"color"},{value:"light-green",icon:"color"},{value:"light-red",icon:"color"},{value:"red",icon:"color"}],fill:[{value:"none",icon:"fill-none"},{value:"semi",icon:"fill-semi"},{value:"solid",icon:"fill-solid"},{value:"pattern",icon:"fill-pattern"}],dash:[{value:"draw",icon:"dash-draw"},{value:"dashed",icon:"dash-dashed"},{value:"dotted",icon:"dash-dotted"},{value:"solid",icon:"dash-solid"}],size:[{value:"s",icon:"size-small"},{value:"m",icon:"size-medium"},{value:"l",icon:"size-large"},{value:"xl",icon:"size-extra-large"}],font:[{value:"draw",icon:"font-draw"},{value:"sans",icon:"font-sans"},{value:"serif",icon:"font-serif"},{value:"mono",icon:"font-mono"}],textAlign:[{value:"start",icon:"text-align-left"},{value:"middle",icon:"text-align-center"},{value:"end",icon:"text-align-right"}],horizontalAlign:[{value:"start",icon:"horizontal-align-start"},{value:"middle",icon:"horizontal-align-middle"},{value:"end",icon:"horizontal-align-end"}],verticalAlign:[{value:"start",icon:"vertical-align-start"},{value:"middle",icon:"vertical-align-middle"},{value:"end",icon:"vertical-align-end"}],geo:[{value:"rectangle",icon:"geo-rectangle"},{value:"ellipse",icon:"geo-ellipse"},{value:"triangle",icon:"geo-triangle"},{value:"diamond",icon:"geo-diamond"},{value:"star",icon:"geo-star"},{value:"pentagon",icon:"geo-pentagon"},{value:"hexagon",icon:"geo-hexagon"},{value:"octagon",icon:"geo-octagon"},{value:"rhombus",icon:"geo-rhombus"},{value:"rhombus-2",icon:"geo-rhombus-2"},{value:"oval",icon:"geo-oval"},{value:"trapezoid",icon:"geo-trapezoid"},{value:"arrow-left",icon:"geo-arrow-left"},{value:"arrow-up",icon:"geo-arrow-up"},{value:"arrow-down",icon:"geo-arrow-down"},{value:"arrow-right",icon:"geo-arrow-right"},{value:"cloud",icon:"geo-cloud"},{value:"x-box",icon:"geo-x-box"},{value:"check-box",icon:"geo-check-box"},{value:"heart",icon:"geo-heart"}],arrowheadStart:[{value:"none",icon:"arrowhead-none"},{value:"arrow",icon:"arrowhead-arrow"},{value:"triangle",icon:"arrowhead-triangle"},{value:"square",icon:"arrowhead-square"},{value:"dot",icon:"arrowhead-dot"},{value:"diamond",icon:"arrowhead-diamond"},{value:"inverted",icon:"arrowhead-triangle-inverted"},{value:"bar",icon:"arrowhead-bar"}],arrowheadEnd:[{value:"none",icon:"arrowhead-none"},{value:"arrow",icon:"arrowhead-arrow"},{value:"triangle",icon:"arrowhead-triangle"},{value:"square",icon:"arrowhead-square"},{value:"dot",icon:"arrowhead-dot"},{value:"diamond",icon:"arrowhead-diamond"},{value:"inverted",icon:"arrowhead-triangle-inverted"},{value:"bar",icon:"arrowhead-bar"}],spline:[{value:"line",icon:"spline-line"},{value:"cubic",icon:"spline-cubic"}]},Ti=P.memo(function(t){const{uiType:n,items:r,title:o,style:s,value:i,onValueChange:a,theme:l}=t,c=F(),u=we(),h=P.useRef(!1),p=P.useRef(null),{handleButtonClick:f,handleButtonPointerDown:S,handleButtonPointerEnter:y,handleButtonPointerUp:x}=P.useMemo(()=>{const m=()=>{h.current=!1,window.removeEventListener("pointerup",m);const _=p.current;_&&["TEXTAREA","INPUT"].includes(_.nodeName)&&_.focus(),p.current=null};return{handleButtonClick:_=>{const{id:I}=_.currentTarget.dataset;i.type==="shared"&&i.value===I||(c.mark("point picker item"),a(s,I))},handleButtonPointerDown:_=>{const{id:I}=_.currentTarget.dataset;c.mark("point picker item"),a(s,I),h.current=!0,p.current=document.activeElement,window.addEventListener("pointerup",m)},handleButtonPointerEnter:_=>{if(!h.current)return;const{id:I}=_.currentTarget.dataset;a(s,I)},handleButtonPointerUp:_=>{const{id:I}=_.currentTarget.dataset;i.type==="shared"&&i.value===I||a(s,I)}}},[i,c,a,s]);return d.jsx("div",{"data-testid":`style.${n}`,className:ce("tlui-buttons__grid"),children:r.map(m=>d.jsx(ue,{type:"icon","data-id":m.value,"data-testid":`style.${n}.${m.value}`,"aria-label":m.value,"data-state":i.type==="shared"&&i.value===m.value?"hinted":void 0,title:o+" — "+u(`${n}-style.${m.value}`),className:ce("tlui-button-grid__button"),style:s===cr?{color:l[m.value].solid}:void 0,onPointerEnter:y,onPointerDown:S,onPointerUp:x,onClick:f,children:d.jsx(ve,{icon:m.icon})},m.value))})});function XR(e,[t,n]){return Math.min(n,Math.max(t,e))}function fse(e){const t=P.useRef({value:e,previous:e});return P.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var qR=["PageUp","PageDown"],ZR=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],QR={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},$l="Slider",[ix,gse,mse]=Eg($l),[JR,Fae]=Ao($l,[mse]),[yse,Hg]=JR($l),eL=P.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[r],value:u,onValueChange:h=()=>{},onValueCommit:p=()=>{},inverted:f=!1,...S}=e,y=P.useRef(new Set),x=P.useRef(0),v=i==="horizontal"?Sse:vse,[w=[],C]=ui({prop:u,defaultProp:c,onChange:M=>{var $;($=[...y.current][x.current])==null||$.focus(),h(M)}}),E=P.useRef(w);function _(M){const D=Cse(w,M);T(M,D)}function I(M){T(M,x.current)}function k(){const M=E.current[x.current];w[x.current]!==M&&p(w)}function T(M,D,{commit:$}={commit:!1}){const j=_se(s),O=Tse(Math.round((M-r)/s)*s+r,j),R=XR(O,[r,o]);C((H=[])=>{const B=bse(H,R,D);if(kse(B,l*s)){x.current=B.indexOf(R);const z=String(B)!==String(H);return z&&$&&p(B),z?B:H}else return H})}return d.jsx(yse,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:x,thumbs:y.current,values:w,orientation:i,children:d.jsx(ix.Provider,{scope:e.__scopeSlider,children:d.jsx(ix.Slot,{scope:e.__scopeSlider,children:d.jsx(v,{"aria-disabled":a,"data-disabled":a?"":void 0,...S,ref:t,onPointerDown:re(S.onPointerDown,()=>{a||(E.current=w)}),min:r,max:o,inverted:f,onSlideStart:a?void 0:_,onSlideMove:a?void 0:I,onSlideEnd:a?void 0:k,onHomeKeyDown:()=>!a&&T(r,0,{commit:!0}),onEndKeyDown:()=>!a&&T(o,w.length-1,{commit:!0}),onStepKeyDown:({event:M,direction:D})=>{if(!a){const O=qR.includes(M.key)||M.shiftKey&&ZR.includes(M.key)?10:1,R=x.current,H=w[R],B=s*O*D;T(H+B,R,{commit:!0})}}})})})})});eL.displayName=$l;var[tL,nL]=JR($l,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Sse=P.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:l,onStepKeyDown:c,...u}=e,[h,p]=P.useState(null),f=qe(t,w=>p(w)),S=P.useRef(),y=r1(o),x=y==="ltr",m=x&&!s||!x&&s;function v(w){const C=S.current||h.getBoundingClientRect(),E=[0,C.width],I=v1(E,m?[n,r]:[r,n]);return S.current=C,I(w-C.left)}return d.jsx(tL,{scope:e.__scopeSlider,startEdge:m?"left":"right",endEdge:m?"right":"left",direction:m?1:-1,size:"width",children:d.jsx(rL,{dir:y,"data-orientation":"horizontal",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:w=>{const C=v(w.clientX);i==null||i(C)},onSlideMove:w=>{const C=v(w.clientX);a==null||a(C)},onSlideEnd:()=>{S.current=void 0,l==null||l()},onStepKeyDown:w=>{const E=QR[m?"from-left":"from-right"].includes(w.key);c==null||c({event:w,direction:E?-1:1})}})})}),vse=P.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:l,...c}=e,u=P.useRef(null),h=qe(t,u),p=P.useRef(),f=!o;function S(y){const x=p.current||u.current.getBoundingClientRect(),m=[0,x.height],w=v1(m,f?[r,n]:[n,r]);return p.current=x,w(y-x.top)}return d.jsx(tL,{scope:e.__scopeSlider,startEdge:f?"bottom":"top",endEdge:f?"top":"bottom",size:"height",direction:f?1:-1,children:d.jsx(rL,{"data-orientation":"vertical",...c,ref:h,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:y=>{const x=S(y.clientY);s==null||s(x)},onSlideMove:y=>{const x=S(y.clientY);i==null||i(x)},onSlideEnd:()=>{p.current=void 0,a==null||a()},onStepKeyDown:y=>{const m=QR[f?"from-bottom":"from-top"].includes(y.key);l==null||l({event:y,direction:m?-1:1})}})})}),rL=P.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:l,...c}=e,u=Hg($l,n);return d.jsx(_e.span,{...c,ref:t,onKeyDown:re(e.onKeyDown,h=>{h.key==="Home"?(i(h),h.preventDefault()):h.key==="End"?(a(h),h.preventDefault()):qR.concat(ZR).includes(h.key)&&(l(h),h.preventDefault())}),onPointerDown:re(e.onPointerDown,h=>{const p=h.target;p.setPointerCapture(h.pointerId),h.preventDefault(),u.thumbs.has(p)?p.focus():r(h)}),onPointerMove:re(e.onPointerMove,h=>{h.target.hasPointerCapture(h.pointerId)&&o(h)}),onPointerUp:re(e.onPointerUp,h=>{const p=h.target;p.hasPointerCapture(h.pointerId)&&(p.releasePointerCapture(h.pointerId),s(h))})})}),oL="SliderTrack",sL=P.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Hg(oL,n);return d.jsx(_e.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});sL.displayName=oL;var ax="SliderRange",iL=P.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=Hg(ax,n),s=nL(ax,n),i=P.useRef(null),a=qe(t,i),l=o.values.length,c=o.values.map(p=>lL(p,o.min,o.max)),u=l>1?Math.min(...c):0,h=100-Math.max(...c);return d.jsx(_e.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:u+"%",[s.endEdge]:h+"%"}})});iL.displayName=ax;var lx="SliderThumb",aL=P.forwardRef((e,t)=>{const n=gse(e.__scopeSlider),[r,o]=P.useState(null),s=qe(t,a=>o(a)),i=P.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return d.jsx(xse,{...e,ref:s,index:i})}),xse=P.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=Hg(lx,n),a=nL(lx,n),[l,c]=P.useState(null),u=qe(t,v=>c(v)),h=l?!!l.closest("form"):!0,p=OO(l),f=i.values[r],S=f===void 0?0:lL(f,i.min,i.max),y=Pse(r,i.values.length),x=p==null?void 0:p[a.size],m=x?Ise(x,S,a.direction):0;return P.useEffect(()=>{if(l)return i.thumbs.add(l),()=>{i.thumbs.delete(l)}},[l,i.thumbs]),d.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${S}% + ${m}px)`},children:[d.jsx(ix.ItemSlot,{scope:e.__scopeSlider,children:d.jsx(_e.span,{role:"slider","aria-label":e["aria-label"]||y,"aria-valuemin":i.min,"aria-valuenow":f,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:u,style:f===void 0?{display:"none"}:e.style,onFocus:re(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),h&&d.jsx(wse,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),value:f},r)]})});aL.displayName=lx;var wse=e=>{const{value:t,...n}=e,r=P.useRef(null),o=fse(t);return P.useEffect(()=>{const s=r.current,i=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(i,"value").set;if(o!==t&&l){const c=new Event("input",{bubbles:!0});l.call(s,t),s.dispatchEvent(c)}},[o,t]),d.jsx("input",{style:{display:"none"},...n,ref:r,defaultValue:t})};function bse(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function lL(e,t,n){const s=100/(n-t)*(e-t);return XR(s,[0,100])}function Pse(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Cse(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 Ise(e,t,n){const r=e/2,s=v1([0,50],[0,r]);return(r-s(t)*n)*n}function Ese(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function kse(e,t){if(t>0){const n=Ese(e);return Math.min(...n)>=t}return!0}function v1(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 _se(e){return(String(e).split(".")[1]||"").length}function Tse(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var Mse=eL,Ase=sL,jse=iL,Ose=aL;const Dse=P.memo(function(t){const{title:n,steps:r,value:o,label:s,onValueChange:i}=t,a=F(),l=we(),c=P.useCallback(p=>{i(p[0])},[i]),u=P.useCallback(()=>{a.mark("click slider")},[a]),h=P.useCallback(()=>{o&&i(o)},[o,i]);return d.jsx("div",{className:"tlui-slider__container",children:d.jsxs(Mse,{"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:c,onPointerUp:h,title:n+" — "+l(s),children:[d.jsx(Ase,{className:"tlui-slider__track",dir:"ltr",children:o!==null&&d.jsx(jse,{className:"tlui-slider__range",dir:"ltr"})}),o!==null&&d.jsx(Ose,{className:"tlui-slider__thumb",dir:"ltr"})]})})});function Rse({label:e,uiTypeA:t,uiTypeB:n,labelA:r,labelB:o,itemsA:s,itemsB:i,styleA:a,styleB:l,valueA:c,valueB:u,onValueChange:h}){const p=we(),f=P.useMemo(()=>{var y;return((y=s.find(x=>c.type==="shared"&&c.value===x.value))==null?void 0:y.icon)??"mixed"},[s,c]),S=P.useMemo(()=>{var y;return((y=i.find(x=>u.type==="shared"&&u.value===x.value))==null?void 0:y.icon)??"mixed"},[i,u]);return c===void 0&&u===void 0?null:d.jsxs("div",{className:"tlui-style-panel__double-select-picker",children:[d.jsx("div",{title:p(e),className:"tlui-style-panel__double-select-picker-label",children:p(e)}),d.jsxs("div",{className:"tlui-buttons__horizontal",children:[d.jsxs(Zi,{id:`style panel ${t} A`,children:[d.jsx(Qi,{children:d.jsx(ue,{type:"icon","data-testid":`style.${t}`,title:p(r)+" — "+(c===null||c.type==="mixed"?p("style-panel.mixed"):p(`${t}-style.${c.value}`)),children:d.jsx(ve,{icon:f,small:!0,invertIcon:!0})})}),d.jsx(Ji,{side:"left",align:"center",sideOffset:80,alignOffset:0,children:d.jsx("div",{className:"tlui-buttons__grid",children:s.map((y,x)=>d.jsx(ju,{"data-testid":`style.${t}.${y.value}`,children:d.jsx(ue,{type:"icon",onClick:()=>h(a,y.value),title:`${p(r)} — ${p(`${t}-style.${y.value}`)}`,children:d.jsx(ve,{icon:y.icon,invertIcon:!0})},y.value)},x))})})]}),d.jsxs(Zi,{id:`style panel ${n}`,children:[d.jsx(Qi,{children:d.jsx(ue,{type:"icon","data-testid":`style.${n}`,title:p(o)+" — "+(u===null||u.type==="mixed"?p("style-panel.mixed"):p(`${n}-style.${u.value}`)),children:d.jsx(ve,{icon:S,small:!0})})}),d.jsx(Ji,{side:"left",align:"center",sideOffset:116,alignOffset:0,children:d.jsx("div",{className:"tlui-buttons__grid",children:i.map(y=>d.jsx(ju,{children:d.jsx(ue,{type:"icon",title:`${p(o)} — ${p(`${n}-style.${y.value}`)}`,"data-testid":`style.${n}.${y.value}`,onClick:()=>h(l,y.value),children:d.jsx(ve,{icon:y.icon})})},y.value))})})]})]})]})}const Lse=P.memo(Rse);function $se({id:e,label:t,uiType:n,style:r,items:o,type:s,value:i,onValueChange:a}){const l=we(),c=F(),u=P.useMemo(()=>{var f;return(f=o.find(S=>i.type==="shared"&&S.value===i.value))==null?void 0:f.icon},[o,i]),h=i.type==="mixed"?l("style-panel.mixed"):l(`${n}-style.${i.value}`),p=t?l(t):"";return d.jsxs(Zi,{id:`style panel ${e}`,children:[d.jsx(Qi,{children:d.jsxs(ue,{type:s,"data-testid":`style.${n}`,title:h,children:[d.jsx(bt,{children:p}),d.jsx(ve,{icon:u??"mixed"})]})}),d.jsx(Ji,{side:"left",align:"center",alignOffset:0,children:d.jsx("div",{className:"tlui-buttons__grid",children:o.map(f=>d.jsx(ju,{children:d.jsx(ue,{type:"icon","data-testid":`style.${n}.${f.value}`,title:l(`${n}-style.${f.value}`),onClick:()=>{c.mark("select style dropdown item"),a(r,f.value)},children:d.jsx(ve,{icon:f.icon})})},f.value))})})]})}const x1=P.memo($se);function Nse({styles:e}){const t=td();if(!e)return null;const n=e.get(Ur),r=e.get(Lp),o=e.get(Rp),s=e.get(zp),i=e.get(Po),a=n===void 0,l=r===void 0&&o===void 0,c=s===void 0,u=i===void 0,h=cs({isDarkMode:t});return d.jsxs(d.Fragment,{children:[d.jsx(Fse,{theme:h,styles:e}),!u&&d.jsx(zse,{theme:h,styles:e}),!(a&&l&&c)&&d.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[d.jsx(Bse,{styles:e}),d.jsx(Hse,{styles:e}),d.jsx(Use,{styles:e})]})]})}function cd(){const e=F(),t=Zt();return Ce.useMemo(()=>function(r,o){e.run(()=>{e.isIn("select")&&e.setStyleForSelectedShapes(r,o),e.setStyleForNextShapes(r,o),e.updateInstanceState({isChangingStyle:!0})}),t("set-style",{source:"style-panel",id:r.id,value:o})},[e,t])}function Fse({styles:e,theme:t}){const n=we(),r=F(),o=cd(),s=e.get(cr),i=e.get(Fi),a=e.get(Ni),l=e.get(Co),c=i!==void 0||a!==void 0||l!==void 0;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{tabIndex:-1,className:"tlui-style-panel__section__common","aria-label":"style panel styles","data-testid":"style.panel",children:[s===void 0?null:d.jsx(Ti,{title:n("style-panel.color"),uiType:"color",style:cr,items:Ir.color,value:s,onValueChange:o,theme:t}),d.jsx(Kse,{})]}),c&&d.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[i===void 0?null:d.jsx(Ti,{title:n("style-panel.fill"),uiType:"fill",style:Fi,items:Ir.fill,value:i,onValueChange:o,theme:t}),a===void 0?null:d.jsx(Ti,{title:n("style-panel.dash"),uiType:"dash",style:Ni,items:Ir.dash,value:a,onValueChange:o,theme:t}),l===void 0?null:d.jsx(Ti,{title:n("style-panel.size"),uiType:"size",style:Co,items:Ir.size,value:l,onValueChange:(u,h)=>{o(u,h);const p=r.getSelectedShapeIds();p.length>0&&Ke(r,p)},theme:t})]})]})}function zse({theme:e,styles:t}){const n=we(),r=cd(),o=t.get(Po),s=t.get(_S),i=t.get(Np),a=t.get(Fp);return o===void 0&&i===void 0?null:d.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel text",children:[o===void 0?null:d.jsx(Ti,{title:n("style-panel.font"),uiType:"font",style:Po,items:Ir.font,value:o,onValueChange:r,theme:e}),s===void 0?null:d.jsxs("div",{className:"tlui-style-panel__row",children:[d.jsx(Ti,{title:n("style-panel.align"),uiType:"align",style:_S,items:Ir.textAlign,value:s,onValueChange:r,theme:e}),d.jsx("div",{className:"tlui-style-panel__row__extra-button",children:d.jsx(ue,{type:"icon",title:n("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:d.jsx(ve,{icon:"vertical-align-middle"})})})]}),i===void 0?null:d.jsxs("div",{className:"tlui-style-panel__row",children:[d.jsx(Ti,{title:n("style-panel.align"),uiType:"align",style:Np,items:Ir.horizontalAlign,value:i,onValueChange:r,theme:e}),d.jsx("div",{className:"tlui-style-panel__row__extra-button",children:a===void 0?d.jsx(ue,{type:"icon",title:n("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:d.jsx(ve,{icon:"vertical-align-middle"})}):d.jsx(x1,{type:"icon",id:"geo-vertical-alignment",uiType:"verticalAlign",style:Fp,items:Ir.verticalAlign,value:a,onValueChange:r})})]})]})}function Bse({styles:e}){const t=cd(),n=e.get(Ur);return n===void 0?null:d.jsx(x1,{id:"geo",type:"menu",label:"style-panel.geo",uiType:"geo",style:Ur,items:Ir.geo,value:n,onValueChange:t})}function Use({styles:e}){const t=cd(),n=e.get(zp);return n===void 0?null:d.jsx(x1,{id:"spline",type:"menu",label:"style-panel.spline",uiType:"spline",style:zp,items:Ir.spline,value:n,onValueChange:t})}function Hse({styles:e}){const t=cd(),n=e.get(Lp),r=e.get(Rp);return!n||!r?null:d.jsx(Lse,{label:"style-panel.arrowheads",uiTypeA:"arrowheadStart",styleA:Rp,itemsA:Ir.arrowheadStart,valueA:r,uiTypeB:"arrowheadEnd",styleB:Lp,itemsB:Ir.arrowheadEnd,valueB:n,onValueChange:t,labelA:"style-panel.arrowhead-start",labelB:"style-panel.arrowhead-end"})}const pc=[.1,.25,.5,.75,1];function Kse(){const e=F(),t=K("opacity",()=>e.getSharedOpacity(),[e]),n=Zt(),r=we(),o=Ce.useCallback(i=>{const a=pc[i];e.run(()=>{e.isIn("select")&&e.setOpacityForSelectedShapes(a),e.setOpacityForNextShapes(a),e.updateInstanceState({isChangingStyle:!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:pc.indexOf(mB(pc,i=>Math.abs(i-t.value)));return d.jsx(Dse,{"data-testid":"style.opacity",value:s>=0?s:pc.length-1,label:t.type==="mixed"?"style-panel.mixed":`opacity-style.${t.value}`,onValueChange:o,steps:pc.length-1,title:r("style-panel.opacity")})}const Wse=P.memo(function({isMobile:t,children:n}){const r=F(),o=YR(),s=P.useCallback(()=>{t||r.updateInstanceState({isChangingStyle:!1})},[r,t]),i=n??d.jsx(Nse,{styles:o});return d.jsx("div",{className:ce("tlui-style-panel",{"tlui-style-panel__wrapper":!t}),"data-ismobile":t,onPointerLeave:s,children:i})});function Gse(){const e=F(),t=we(),n=YR(),r=n==null?void 0:n.get(cr),o=cs({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=P.useCallback(c=>{c||e.updateInstanceState({isChangingStyle:!1})},[e]),{StylePanel:l}=fi();return l?d.jsxs(e1,{id:"mobile style menu",onOpenChange:a,children:[d.jsx(t1,{children:d.jsx(ue,{type:"tool","data-testid":"mobile-styles.button",style:{color:i?"var(--color-muted-1)":s},title:t("style-panel.title"),disabled:i,children:d.jsx(ve,{icon:i?"blob":(r==null?void 0:r.type)==="mixed"?"mixed":"blob"})})}),d.jsx(n1,{side:"top",align:"end",children:l&&d.jsx(l,{isMobile:!0})})]}):null}function Vse(){return d.jsxs(d.Fragment,{children:[d.jsx(Xse,{}),d.jsx(qse,{}),d.jsx(Zse,{}),d.jsx(Qse,{}),d.jsx(Jse,{}),d.jsx(eie,{}),d.jsx(tie,{}),d.jsx(nie,{}),d.jsx(rie,{}),d.jsx(oie,{}),d.jsx(iie,{}),d.jsx(sie,{}),d.jsx(cie,{}),d.jsx(hie,{}),d.jsx(aie,{}),d.jsx(die,{}),d.jsx(uie,{}),d.jsx(lie,{}),d.jsx(pie,{}),d.jsx(fie,{}),d.jsx(gie,{}),d.jsx(mie,{}),d.jsx(yie,{}),d.jsx(Sie,{}),d.jsx(vie,{}),d.jsx(xie,{}),d.jsx(bie,{}),d.jsx(wie,{})]})}function Yse(e){var r;const t=F(),n=(r=e.meta)==null?void 0:r.geo;return K("is tool selected",()=>{const o=t.getCurrentToolId(),s=t.getSharedStyles().getAsKnownValue(Ur);return n?o==="geo"&&s===n:o===e.id},[t,e.id,n])}function He({tool:e}){const t=Og(),n=Yse(t[e]);return d.jsx(U,{...t[e],isSelected:n})}function Xse(){return d.jsx(He,{tool:"select"})}function qse(){return d.jsx(He,{tool:"hand"})}function Zse(){return d.jsx(He,{tool:"draw"})}function Qse(){return d.jsx(He,{tool:"eraser"})}function Jse(){return d.jsx(He,{tool:"arrow"})}function eie(){return d.jsx(He,{tool:"text"})}function tie(){return d.jsx(He,{tool:"note"})}function nie(){const e=Og();return d.jsx(U,{...e.asset})}function rie(){return d.jsx(He,{tool:"rectangle"})}function oie(){return d.jsx(He,{tool:"ellipse"})}function sie(){return d.jsx(He,{tool:"diamond"})}function iie(){return d.jsx(He,{tool:"triangle"})}function aie(){return d.jsx(He,{tool:"rhombus"})}function lie(){return d.jsx(He,{tool:"heart"})}function cie(){return d.jsx(He,{tool:"hexagon"})}function uie(){return d.jsx(He,{tool:"cloud"})}function die(){return d.jsx(He,{tool:"star"})}function hie(){return d.jsx(He,{tool:"oval"})}function pie(){return d.jsx(He,{tool:"x-box"})}function fie(){return d.jsx(He,{tool:"check-box"})}function gie(){return d.jsx(He,{tool:"arrow-left"})}function mie(){return d.jsx(He,{tool:"arrow-up"})}function yie(){return d.jsx(He,{tool:"arrow-down"})}function Sie(){return d.jsx(He,{tool:"arrow-right"})}function vie(){return d.jsx(He,{tool:"line"})}function xie(){return d.jsx(He,{tool:"highlight"})}function wie(){return d.jsx(He,{tool:"frame"})}function bie(){return d.jsx(He,{tool:"laser"})}const Ly=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function $y(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on".concat(t),n)}function fc(e,t,n,r){e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on".concat(t),n)}function cL(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 uL(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 Pie(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 Ou={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,"-":Ly?173:189,"=":Ly?61:187,";":Ly?59:186,"'":222,"[":219,"]":221,"\\":220},_o={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},cx={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Bt={16:!1,18:!1,17:!1,91:!1},dt={};for(let e=1;e<20;e++)Ou["f".concat(e)]=111+e;let We=[],Qc=null,dL="all";const zo=new Map,ud=e=>Ou[e.toLowerCase()]||_o[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),Cie=e=>Object.keys(Ou).find(t=>Ou[t]===e),Iie=e=>Object.keys(_o).find(t=>_o[t]===e);function hL(e){dL=e||"all"}function Du(){return dL||"all"}function Eie(){return We.slice(0)}function kie(){return We.map(e=>Cie(e)||Iie(e)||String.fromCharCode(e))}function _ie(){const e=[];return Object.keys(dt).forEach(t=>{dt[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=>ud(a))})})}),e}function Tie(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 Mie(e){return typeof e=="string"&&(e=ud(e)),We.indexOf(e)!==-1}function Aie(e,t){let n,r;e||(e=Du());for(const o in dt)if(Object.prototype.hasOwnProperty.call(dt,o))for(n=dt[o],r=0;r<n.length;)n[r].scope===e?n.splice(r,1).forEach(i=>{let{element:a}=i;return w1(a)}):r++;Du()===e&&hL(t||"all")}function jie(e){let t=e.keyCode||e.which||e.charCode;const n=We.indexOf(t);if(n>=0&&We.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&We.splice(0,We.length),(t===93||t===224)&&(t=91),t in Bt){Bt[t]=!1;for(const r in _o)_o[r]===t&&(Bn[r]=!1)}}function pL(e){if(typeof e>"u")Object.keys(dt).forEach(o=>{Array.isArray(dt[o])&&dt[o].forEach(s=>wh(s)),delete dt[o]}),w1(null);else if(Array.isArray(e))e.forEach(o=>{o.key&&wh(o)});else if(typeof e=="object")e.key&&wh(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=""),wh({key:e,scope:o,method:s,splitKey:"+"})}}const wh=e=>{let{key:t,scope:n,method:r,splitKey:o="+"}=e;uL(t).forEach(i=>{const a=i.split(o),l=a.length,c=a[l-1],u=c==="*"?"*":ud(c);if(!dt[u])return;n||(n=Du());const h=l>1?cL(_o,a):[],p=[];dt[u]=dt[u].filter(f=>{const y=(r?f.method===r:!0)&&f.scope===n&&Pie(f.mods,h);return y&&p.push(f.element),!y}),p.forEach(f=>w1(f))})};function SE(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 Bt)Object.prototype.hasOwnProperty.call(Bt,s)&&(!Bt[s]&&t.mods.indexOf(+s)>-1||Bt[s]&&t.mods.indexOf(+s)===-1)&&(o=!1);(t.mods.length===0&&!Bt[16]&&!Bt[18]&&!Bt[17]&&!Bt[91]||o||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(We),t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function vE(e,t){const n=dt["*"];let r=e.keyCode||e.which||e.charCode;if(!Bn.filter.call(this,e))return;if((r===93||r===224)&&(r=91),We.indexOf(r)===-1&&r!==229&&We.push(r),["ctrlKey","altKey","shiftKey","metaKey"].forEach(a=>{const l=cx[a];e[a]&&We.indexOf(l)===-1?We.push(l):!e[a]&&We.indexOf(l)>-1?We.splice(We.indexOf(l),1):a==="metaKey"&&e[a]&&We.length===3&&(e.ctrlKey||e.shiftKey||e.altKey||(We=We.slice(We.indexOf(l))))}),r in Bt){Bt[r]=!0;for(const a in _o)_o[a]===r&&(Bn[a]=!0);if(!n)return}for(const a in Bt)Object.prototype.hasOwnProperty.call(Bt,a)&&(Bt[a]=e[cx[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(We.indexOf(17)===-1&&We.push(17),We.indexOf(18)===-1&&We.push(18),Bt[17]=!0,Bt[18]=!0);const o=Du();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)&&SE(e,n[a],o,t);if(!(r in dt))return;const s=dt[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 l=s[a],{splitKey:c}=l,u=l.key.split(c),h=[];for(let p=0;p<u.length;p++)h.push(ud(u[p]));h.sort().join("")===We.sort().join("")&&SE(e,l,o,t)}}function Bn(e,t,n){We=[];const r=uL(e);let o=[],s="all",i=document,a=0,l=!1,c=!0,u="+",h=!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&&(l=t.keyup),t.keydown!==void 0&&(c=t.keydown),t.capture!==void 0&&(h=t.capture),typeof t.splitKey=="string"&&(u=t.splitKey),t.single===!0&&(p=!0)),typeof t=="string"&&(s=t),p&&pL(e,s);a<r.length;a++)e=r[a].split(u),o=[],e.length>1&&(o=cL(_o,e)),e=e[e.length-1],e=e==="*"?"*":ud(e),e in dt||(dt[e]=[]),dt[e].push({keyup:l,keydown:c,scope:s,mods:o,shortcut:r[a],method:n,key:r[a],splitKey:u,element:i});if(typeof i<"u"&&window){if(!zo.has(i)){const f=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return vE(y,i)},S=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;vE(y,i),jie(y)};zo.set(i,{keydownListener:f,keyupListenr:S,capture:h}),$y(i,"keydown",f,h),$y(i,"keyup",S,h)}if(!Qc){const f=()=>{We=[]};Qc={listener:f,capture:h},$y(window,"focus",f,h)}}}function Oie(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(dt).forEach(n=>{dt[n].filter(o=>o.scope===t&&o.shortcut===e).forEach(o=>{o&&o.method&&o.method()})})}function w1(e){const t=Object.values(dt).flat();if(t.findIndex(r=>{let{element:o}=r;return o===e})<0){const{keydownListener:r,keyupListenr:o,capture:s}=zo.get(e)||{};r&&o&&(fc(e,"keyup",o,s),fc(e,"keydown",r,s),zo.delete(e))}if((t.length<=0||zo.size<=0)&&(Object.keys(zo).forEach(o=>{const{keydownListener:s,keyupListenr:i,capture:a}=zo.get(o)||{};s&&i&&(fc(o,"keyup",i,a),fc(o,"keydown",s,a),zo.delete(o))}),zo.clear(),Object.keys(dt).forEach(o=>delete dt[o]),Qc)){const{listener:o,capture:s}=Qc;fc(window,"focus",o,s),Qc=null}}const Ny={getPressedKeyString:kie,setScope:hL,getScope:Du,deleteScope:Aie,getPressedKeyCodes:Eie,getAllKeyCodes:_ie,isPressed:Mie,filter:Tie,trigger:Oie,unbind:pL,keyMap:Ou,modifier:_o,modifierMap:cx};for(const e in Ny)Object.prototype.hasOwnProperty.call(Ny,e)&&(Bn[e]=Ny[e]);if(typeof window<"u"){const e=window.hotkeys;Bn.noConflict=t=>(t&&window.hotkeys===Bn&&(window.hotkeys=e),Bn),window.hotkeys=Bn}const xE=["copy","cut","paste","asset"];function Die(){const e=F(),t=ds(),n=ae(),r=Og(),o=K("is focused",()=>e.getInstanceState().isFocused,[e]);P.useEffect(()=>{if(!o)return;const s=new Array,i=(l,c)=>{Bn(l,{element:document.body},c),s.push(()=>{Bn.unbind(l,c)})},a=(l,c)=>{Bn(l,{element:document.body,keyup:!0,keydown:!1},c),s.push(()=>{Bn.unbind(l,c)})};for(const l of Object.values(n))l.kbd&&(t&&!l.readonlyOk||xE.includes(l.id)||i(wE(l.kbd),c=>{Lc(e)||(Ee(c),l.onSelect("kbd"))}));for(const l of Object.values(r))!l.kbd||!l.readonlyOk&&e.getInstanceState().isReadonly||xE.includes(l.id)||i(wE(l.kbd),c=>{Lc(e)||(Ee(c),l.onSelect("kbd"))});return i(",",l=>{if(Lc(e)||e.inputs.keys.has("Comma"))return;Ee(l),e.focus(),e.inputs.keys.add("Comma");const{x:c,y:u,z:h}=e.inputs.currentScreenPoint,p={type:"pointer",name:"pointer_down",point:{x:c,y:u,z:h},shiftKey:l.shiftKey,altKey:l.altKey,ctrlKey:l.metaKey||l.ctrlKey,pointerId:0,button:0,isPen:e.getInstanceState().isPenMode,target:"canvas"};e.dispatch(p)}),a(",",l=>{if(Lc(e)||!e.inputs.keys.has("Comma"))return;e.inputs.keys.delete("Comma");const{x:c,y:u,z:h}=e.inputs.currentScreenPoint,p={type:"pointer",name:"pointer_up",point:{x:c,y:u,z:h},shiftKey:l.shiftKey,altKey:l.altKey,ctrlKey:l.metaKey||l.ctrlKey,pointerId:0,button:0,isPen:e.getInstanceState().isPenMode,target:"canvas"};e.dispatch(p)}),()=>{s.forEach(l=>l())}},[n,r,t,e,o])}function wE(e){return Rie(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 Rie(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 Lc(e){return e.getIsMenuOpen()||e.getEditingShapeId()!==null||e.getCrashingError()}const Lie=P.createContext(!1);function $ie({children:e}){const t=F(),n=w2(),r=En(),o=we(),s=Math.min(8,5+r),[i,a]=P.useState(0),l=P.useRef(null),[c,u]=P.useState(null),h=P.useMemo(()=>{const f=c?`:not([data-value="${c}"])`:"";return`
|
|
376
|
+
#${n}_main > *:nth-child(n + ${s+(c?1:2)})${f} {
|
|
377
|
+
display: none;
|
|
378
|
+
}
|
|
379
|
+
#${n}_more > *:nth-child(-n + ${s}) {
|
|
380
|
+
display: none;
|
|
381
|
+
}
|
|
382
|
+
`},[c,n,s]),p=eA(()=>{if(!l.current)return;const f=Array.from(l.current.children);a(f.length),f.findIndex(x=>x.getAttribute("data-value")===c)<=s&&u(null);const y=Array.from(l.current.children).findIndex(x=>x.getAttribute("aria-checked")==="true");y!==-1&&y>=s&&u(f[y].getAttribute("data-value"))});return P.useLayoutEffect(()=>{p()}),P.useLayoutEffect(()=>{if(!l.current)return;const f=new MutationObserver(p);return f.observe(l.current,{childList:!0,subtree:!0,attributeFilter:["data-value","aria-checked"]}),()=>{f.disconnect()}},[p]),P.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[S,y]of f)Bn(S,x=>{var w;if(Lc(t))return;Ee(x);const v=Array.from(((w=l.current)==null?void 0:w.children)??[]).filter(C=>!(C instanceof HTMLElement)||C.tagName.toLowerCase()!=="button"?!1:!!(C.offsetWidth||C.offsetHeight))[y];v&&v.click()});return()=>{Bn.unbind("1,2,3,4,5,6,7,8,9,0")}},[t]),d.jsxs(d.Fragment,{children:[d.jsx("style",{children:h}),d.jsxs("div",{className:ce("tlui-toolbar__tools",{"tlui-toolbar__tools__mobile":r<yt.TABLET_SM}),role:"radiogroup",children:[d.jsx("div",{id:`${n}_main`,ref:l,className:"tlui-toolbar__tools__list",children:d.jsx(Mr,{type:"toolbar",sourceId:"toolbar",children:e})}),i>s+1&&d.jsx(Lie.Provider,{value:!0,children:d.jsxs(Zi,{id:"toolbar overflow",modal:!1,children:[d.jsx(Qi,{children:d.jsx(ue,{title:o("tool-panel.more"),type:"tool",className:"tlui-toolbar__overflow","data-testid":"tools.more-button",children:d.jsx(ve,{icon:"chevron-up"})})}),d.jsx(Ji,{side:"top",align:"center",children:d.jsx("div",{className:"tlui-buttons__grid","data-testid":"tools.more-content",id:`${n}_more`,children:d.jsx(Mr,{type:"toolbar-overflow",sourceId:"toolbar",children:e})})})]})})]})]})}function Nie({activeToolId:e}){const t=F(),n=En(),r=we(),o=K("is tool locked",()=>t.getInstanceState().isToolLocked,[t]),s=K("current tool",()=>t.getCurrentTool(),[t]);return!e||!s.isLockable?null:d.jsx(ue,{type:"normal",title:r("action.toggle-tool-lock"),"data-testid":"tool-lock",className:ce("tlui-toolbar__lock-button",{"tlui-toolbar__lock-button__mobile":n<yt.TABLET_SM}),onClick:()=>t.updateInstanceState({isToolLocked:!o}),children:d.jsx(ve,{icon:o?"lock":"unlock",small:!0})})}const Fie=P.memo(function({children:t}){const n=F(),r=En(),o=ds(),s=K("current tool id",()=>n.getCurrentToolId(),[n]),{ActionsMenu:i,QuickActions:a}=fi();return d.jsx("div",{className:"tlui-toolbar",children:d.jsxs("div",{className:"tlui-toolbar__inner",children:[d.jsxs("div",{className:"tlui-toolbar__left",children:[!o&&d.jsxs("div",{className:"tlui-toolbar__extras",children:[r<yt.TABLET&&d.jsxs("div",{className:"tlui-toolbar__extras__controls tlui-buttons__horizontal",children:[a&&d.jsx(a,{}),i&&d.jsx(i,{})]}),d.jsx(Nie,{activeToolId:s})]}),d.jsx($ie,{children:t??d.jsx(Vse,{})})]}),r<yt.TABLET_SM&&!o&&d.jsx("div",{className:"tlui-toolbar__tools",children:d.jsx(Gse,{})})]})})});function zie(){const e=we();return d.jsxs("div",{className:ce("tlui-offline-indicator"),children:[e("status.offline"),d.jsx(Eo,{"aria-label":"offline",icon:"status-offline",small:!0})]})}function Bie({maxWidth:e=420,ignoreRightWidth:t=0,stylePanelWidth:n=148,marginBetweenZones:r=12,squeezeAmount:o=52,children:s}){const i=P.useRef(null),a=En(),l=P.useCallback(()=>{const c=i.current;if(!c)return;const u=c.parentElement.parentElement,h=u.querySelector(".tlui-layout__top__left"),p=u.querySelector(".tlui-layout__top__right"),f=u.offsetWidth,S=h.offsetWidth,y=p.offsetWidth,x=c.offsetWidth-t;let m=(f-x)/2;f%2!==0&&(m-=.5);const v=S+r,w=c.offsetLeft,C=Math.min(f-y-S-2*r,e),E=Math.max(m,v)-w;p.offsetWidth>n&&a<=6?c.style.setProperty("max-width",C-o+"px"):c.style.setProperty("max-width",C+"px"),c.style.setProperty("transform",`translate(${E}px, 0px)`)},[a,t,r,e,o,n]);return P.useLayoutEffect(()=>{const c=i.current;if(!c)return;const u=c.parentElement.parentElement,h=u.querySelector(".tlui-layout__top__left"),p=u.querySelector(".tlui-layout__top__right"),f=new ResizeObserver(l);return f.observe(h),f.observe(p),f.observe(u),f.observe(c),l(),()=>{f.disconnect()}},[l]),P.useLayoutEffect(()=>{l()}),d.jsx("div",{ref:i,className:"tlui-top-panel__container",children:s})}function Uie(){const e=pee()==="offline";return d.jsx(Bie,{children:e&&d.jsx(zie,{})})}function Hie(){const e=ae();return d.jsxs(d.Fragment,{children:[d.jsx(U,{...e["zoom-in"],noClose:!0}),d.jsx(U,{...e["zoom-out"],noClose:!0}),d.jsx(RR,{}),d.jsx(LR,{}),d.jsx($R,{})]})}const Kie=P.memo(function({children:t}){const n=$t(),[r,o]=ps("zoom menu"),s=t??d.jsx(Hie,{});return d.jsxs(g1,{dir:"ltr",open:r,onOpenChange:o,modal:!1,children:[d.jsx(m1,{asChild:!0,dir:"ltr",children:d.jsx(Wie,{})}),d.jsx(Ug,{container:n,children:d.jsx(y1,{className:"tlui-menu",side:"top",align:"start",alignOffset:0,sideOffset:8,collisionPadding:4,children:d.jsx(Mr,{type:"menu",sourceId:"zoom-menu",children:s})})})]})}),Wie=P.forwardRef(function(t,n){const r=F(),o=En(),s=K("zoom",()=>r.getZoomLevel(),[r]),i=we(),a=P.useCallback(()=>{r.resetZoom(r.getViewportScreenCenter(),{animation:{duration:r.options.animationMediumMs}})},[r]);return d.jsx(ue,{ref:n,...t,type:"icon",title:`${i("navigation-zone.zoom")}`,"data-testid":"minimap.zoom-menu-button",className:o<yt.TABLET_SM?"tlui-zoom-menu__button":"tlui-zoom-menu__button__pct",onDoubleClick:a,icon:o<yt.MOBILE?"zoom-in":void 0,children:o<yt.MOBILE?null:d.jsxs("span",{style:{flexGrow:0,textAlign:"center"},children:[Math.floor(s*100),"%"]})})}),fL=P.createContext(null);function Gie({overrides:e={},children:t}){const n=Xf(e),r=Dg();return d.jsx(fL.Provider,{value:P.useMemo(()=>({ContextMenu:doe,ActionsMenu:Nre,HelpMenu:null,ZoomMenu:Kie,MainMenu:Yoe,Minimap:Joe,StylePanel:Wse,PageMenu:rse,NavigationPanel:tse,Toolbar:Fie,KeyboardShortcutsDialog:Doe,QuickActions:sse,HelperButtons:joe,DebugPanel:Poe,DebugMenu:boe,MenuPanel:koe,SharePanel:r?hse:null,CursorChatBubble:r?foe:null,TopPanel:r?Uie:null,...n}),[n,r]),children:t})}function fi(){const e=P.useContext(fL);if(!e)throw new Error("useTldrawUiComponents must be used within a TldrawUiComponentsProvider");return e}function Vie({overrides:e,components:t,assetUrls:n,onUiEvent:r,forceMobile:o,children:s}){return d.jsx(Rq,{assetUrls:PJ(n),children:d.jsx(Nq,{overrides:_J(e),children:d.jsx(BQ,{onEvent:r,children:d.jsx(mJ,{children:d.jsx(UQ,{children:d.jsx(IJ,{forceMobile:o,children:d.jsx(Gie,{overrides:t,children:d.jsx(Yie,{overrides:e,children:s})})})})})})})})}function Yie({overrides:e,children:t}){const n=TJ(e);return d.jsx(mee,{overrides:n.actions,children:d.jsx(CJ,{overrides:n.tools,children:t})})}function Xie(){const e=F(),{addToast:t}=eo();P.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 qie=Ce.memo(function({renderDebugMenuItems:t,children:n,hideUi:r,components:o,...s}){return d.jsx(Vie,{...s,components:o,children:d.jsx(Zie,{hideUi:r,renderDebugMenuItems:t,children:n})})}),Zie=Ce.memo(function({children:t,hideUi:n,...r}){return d.jsxs(d.Fragment,{children:[t,n?null:d.jsx(Qie,{...r})]})}),Qie=Ce.memo(function(){const t=F(),n=we(),r=En(),o=ds(),s=K("focus",()=>t.getInstanceState().isFocusMode,[t]),i=K("debug",()=>t.getInstanceState().isDebugMode,[t]),{SharePanel:a,TopPanel:l,MenuPanel:c,StylePanel:u,Toolbar:h,HelpMenu:p,NavigationPanel:f,HelperButtons:S,DebugPanel:y,CursorChatBubble:x}=fi();Die(),ree(),Xie();const{"toggle-focus-mode":m}=ae();return d.jsxs("div",{className:ce("tlui-layout",{"tlui-layout__mobile":r<yt.TABLET_SM}),"data-breakpoint":r,children:[s?d.jsx("div",{className:"tlui-layout__top",children:d.jsx(ue,{type:"icon",className:"tlui-focus-button",title:n("focus-mode.toggle-focus-mode"),onClick:()=>m.onSelect("menu"),children:d.jsx(ve,{icon:"dot"})})}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"tlui-layout__top",children:[d.jsxs("div",{className:"tlui-layout__top__left",children:[c&&d.jsx(c,{}),S&&d.jsx(S,{})]}),d.jsx("div",{className:"tlui-layout__top__center",children:l&&d.jsx(l,{})}),d.jsxs("div",{className:"tlui-layout__top__right",children:[a&&d.jsx(a,{}),u&&r>=yt.TABLET_SM&&!o&&d.jsx(u,{})]})]}),d.jsxs("div",{className:"tlui-layout__bottom",children:[d.jsxs("div",{className:"tlui-layout__bottom__main",children:[f&&d.jsx(f,{}),h&&d.jsx(h,{}),p&&d.jsx(p,{})]}),i&&y&&d.jsx(y,{})]})]}),d.jsx(xJ,{}),d.jsx(WQ,{}),d.jsx(wJ,{}),d.jsx(GQ,{}),x&&d.jsx(x,{})]})});async function Jie(e,t){const{url:n,style:r="normal",weight:o="500",display:s,featureSettings:i,stretch:a,unicodeRange:l,variant:c,format:u}=t,h={style:r,weight:o,display:s,featureSettings:i,stretch:a,unicodeRange:l,variant:c},p=new FontFace(e,`url(${n})`,h);return await p.load(),document.fonts.add(p),p.$$_url=n,p.$$_fontface=`
|
|
383
|
+
@font-face {
|
|
384
|
+
font-family: ${p.family};
|
|
385
|
+
font-stretch: ${p.stretch};
|
|
386
|
+
font-weight: ${p.weight};
|
|
387
|
+
font-style: ${p.style};
|
|
388
|
+
src: url("${n}") format("${u}")
|
|
389
|
+
}`,p}const bh=(e,t)=>{const[n,r]=P.useState(2);return P.useEffect(()=>{let o=!1;return r(2),Jie(e,t).then(()=>{o||r(0)}).catch(s=>{o||(console.error(s),r(1))}),()=>{o=!0}},[e,t]),n};function eae(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 gL(e){const t=P.useMemo(()=>eae(e),[e]),n=[bh("tldraw_draw",t.draw),bh("tldraw_serif",t.serif),bh("tldraw_sans",t.sansSerif),bh("tldraw_mono",t.monospace)];return{error:n.some(r=>r===1),done:!n.some(r=>r===2)}}function tae(e){const{children:t,maxImageDimension:n,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i,components:a={},shapeUtils:l=[],bindingUtils:c=[],tools:u=[],...h}=e,p=Xf(a),f=P.useMemo(()=>({Scribble:nI,ShapeIndicators:SY,CollaboratorScribble:nI,SelectionForeground:gY,SelectionBackground:pY,Handles:lY,...p}),[p]),S=zc(l),y=P.useMemo(()=>[...XA,...S],[S]),x=zc(c),m=P.useMemo(()=>[...gA,...x],[x]),v=zc(u),w=P.useMemo(()=>[...uZ,...SX,...v],[v]),C=uO(h.assetUrls),{done:E,error:_}=gL(C);return _?d.jsx(dA,{children:"Could not load assets. Please refresh the page."}):E?d.jsx(YV,{initialState:"select",...h,components:f,shapeUtils:y,bindingUtils:m,tools:w,children:d.jsxs(qie,{...h,components:f,children:[d.jsx(nae,{maxImageDimension:n,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i}),t]})}):d.jsx(cw,{children:d.jsx(l0,{})})}function nae({maxImageDimension:e=5e3,maxAssetSize:t=10*1024*1024,acceptedImageMimeTypes:n=Hx,acceptedVideoMimeTypes:r=Yk,onMount:o}){const s=F(),i=eo(),a=we();hA(()=>{const u=[];return u.push(Yq(s)),eX(s,{maxImageDimension:e,maxAssetSize:t,acceptedImageMimeTypes:n,acceptedVideoMimeTypes:r},{toasts:i,msg:a}),u.push(s.store.props.onMount(s)),u.push(o==null?void 0:o(s)),()=>{u.forEach(h=>h==null?void 0:h())}});const{Canvas:l}=st(),{ContextMenu:c}=fi();return c?d.jsx(c,{}):l?d.jsx(l,{}):null}P.memo(function(t){const[n,r]=P.useState(null),[o,s]=P.useState(null),i=zc(t.shapeUtils??[]),a=P.useMemo(()=>[...XA,...i],[i]),l=zc(t.bindingUtils??[]),c=P.useMemo(()=>[...gA,...l],[l]),u=eY({snapshot:t.snapshot,shapeUtils:a}),h=uO(),{done:p,error:f}=gL(h),{pageId:S,bounds:y,scale:x,background:m,padding:v,darkMode:w,preserveAspectRatio:C,format:E="svg",licenseKey:_}=t;return P.useLayoutEffect(()=>{if(!o||!u||!p)return;let I=!1;const k=document.createElement("div");o.appendChild(k),o.classList.add("tl-container","tl-theme__light");const T=new Z({store:u,shapeUtils:a,bindingUtils:c,tools:[],getContainer:()=>k,licenseKey:_});S&&T.setCurrentPage(S);const M=T.getCurrentPageShapeIds();async function D(){const $=await T.getSvgString([...M],{bounds:y,scale:x,background:m,padding:v,darkMode:w,preserveAspectRatio:C});if($&&!I){if(E==="svg"){if(!I){const j=new Blob([$.svg],{type:"image/svg+xml"}),O=URL.createObjectURL(j);r(O)}}else if(E==="png"){const j=await vO(T,$.svg,{type:E,quality:1,scale:2,width:$.width,height:$.height});if(j&&!I){const O=URL.createObjectURL(j);r(O)}}}T.dispose()}return D(),()=>{I=!0}},[E,o,u,a,c,S,y,x,m,v,w,C,p,f,_]),f?d.jsx(dA,{children:"Could not load assets."}):p?d.jsx("div",{ref:s,style:{position:"relative",width:"100%",height:"100%"},children:n&&d.jsx("img",{src:n,referrerPolicy:"strict-origin-when-cross-origin",style:{width:"100%",height:"100%"}})}):d.jsx(cw,{children:d.jsx(l0,{})})});P.memo(function({children:t}){const n=we(),r=En(),o=t??d.jsx($oe,{});return r<yt.MOBILE?null:d.jsx("div",{className:"tlui-help-menu",children:d.jsxs(Zi,{id:"help menu",children:[d.jsx(Qi,{children:d.jsx(ue,{type:"help",title:n("help-menu.title"),"data-testid":"help-menu.button",children:d.jsx(ve,{icon:"question-mark",small:!0})})}),d.jsx(Ji,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:d.jsx(Mr,{type:"menu",sourceId:"help-menu",children:o})})]})})});const rae=1,oae=xe({schemaVersion:dn(1),storeVersion:Mh,recordVersions:Op(fe,xe({version:Mh,subTypeVersions:Op(fe,Mh).optional(),subTypeKey:fe.optional()}))}),sae=xe({schemaVersion:dn(2),sequences:Op(fe,Mh)}),iae=xe({tldrawFileFormatVersion:sU,schema:iU("schemaVersion",{1:oae,2:sae}),records:Ht(xe({id:fe,typeName:fe}).allowUnknownProperties())});function aae(e){var t;try{return!!((t=e.document)!=null&&t.version)}catch{return!1}}function lae({json:e,schema:t}){let n;try{n=iae.validate(JSON.parse(e))}catch(o){try{if(n=JSON.parse(e),aae(n))return yn.err({type:"v1File",data:n})}catch{}return yn.err({type:"notATldrawFile",cause:o})}if(n.tldrawFileFormatVersion>rae)return yn.err({type:"fileFormatVersionTooNew",version:n.tldrawFileFormatVersion});let r;try{const o=cae(n.records),s=Object.fromEntries(o.map(i=>[i.id,i]));r=t.migrateStoreSnapshot({store:s,schema:n.schema})}catch(o){return yn.err({type:"invalidRecords",cause:o})}if(r.type==="error")return yn.err({type:"migrationFailed",reason:r.reason});try{return yn.ok(Iu({initialData:r.value,schema:t}))}catch(o){return yn.err({type:"invalidRecords",cause:o})}}function cae(e){const t=new Set;for(const n of e)n.typeName==="shape"&&"assetId"in n.props&&n.props.assetId&&t.add(n.props.assetId);return e.filter(n=>n.typeName!=="asset"||t.has(n.id))}function uae(){const[e,t]=P.useState();function n(r){window.editor=r,e===void 0?fetch("/tldr-data").then(async o=>{if(!o.ok){console.log(`No tldr data to load from local endpoint (${o.status})`);return}return o.text()}).then(o=>{if(o===void 0)return;const s=lae({json:o,schema:r.store.schema});s.ok?(console.log("Loaded tldr file from local endpoint"),t(s.value)):console.error(`Couldn't parse tldr file: ${String(s.error.type)}`)}).catch(o=>{console.error("Couldn't fetch data:",o)}):(r.zoomToFit(),r.clearOpenMenus())}return d.jsx("div",{style:{inset:0,position:"fixed"},children:d.jsx(tae,{assetUrls:G3(),onMount:n,store:e})})}Ev.createRoot(document.querySelector("#root")).render(d.jsx(Ce.StrictMode,{children:d.jsx(uae,{})}));
|