@kitschpatrol/tldraw-cli 4.1.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +161 -136
- package/dist/.DS_Store +0 -0
- package/dist/lib/TldrawController.d.ts +25 -0
- package/dist/lib/index.js +149 -116
- package/dist/lib/inline/download-image.d.ts +7 -0
- package/dist/lib/inline/download-tldr.d.ts +7 -0
- package/dist/lib/inline/get-image-blob.d.ts +13 -0
- package/dist/lib/inline/get-image.d.ts +13 -0
- package/dist/lib/inline/get-tldr.d.ts +7 -0
- package/dist/lib/inline/set-tldr.d.ts +7 -0
- package/dist/lib/inline/upload-tldr.d.ts +7 -0
- package/dist/lib/tldraw-controller.d.ts +4 -10
- package/dist/tldraw/assets/index-BsbCikiv.js +320 -0
- package/dist/tldraw/assets/index-CtzsHuLd.css +1 -0
- package/dist/tldraw/icons/icon/checkbox-empty.svg +1 -1
- package/dist/tldraw/index.html +2 -2
- package/dist/tldraw/translations/ar.json +156 -156
- package/dist/tldraw/translations/ca.json +156 -156
- package/dist/tldraw/translations/cs.json +211 -211
- package/dist/tldraw/translations/da.json +94 -94
- package/dist/tldraw/translations/de.json +169 -169
- package/dist/tldraw/translations/es.json +160 -160
- package/dist/tldraw/translations/fa.json +202 -202
- package/dist/tldraw/translations/fi.json +172 -172
- package/dist/tldraw/translations/fr.json +156 -156
- package/dist/tldraw/translations/gl.json +208 -208
- package/dist/tldraw/translations/hi-in.json +152 -152
- package/dist/tldraw/translations/hr.json +358 -0
- package/dist/tldraw/translations/hu.json +220 -217
- package/dist/tldraw/translations/it.json +189 -189
- package/dist/tldraw/translations/ja.json +210 -210
- package/dist/tldraw/translations/ko-kr.json +217 -214
- package/dist/tldraw/translations/languages.json +8 -0
- package/dist/tldraw/translations/main.json +14 -0
- package/dist/tldraw/translations/ne.json +156 -156
- package/dist/tldraw/translations/ro.json +210 -210
- package/dist/tldraw/translations/ru.json +206 -206
- package/dist/tldraw/translations/sl.json +358 -0
- package/dist/tldraw/translations/th.json +156 -156
- package/dist/tldraw/translations/tr.json +214 -214
- package/dist/tldraw/translations/uk.json +206 -206
- package/dist/tldraw/translations/vi.json +156 -156
- package/dist/tldraw/translations/zh-cn.json +212 -212
- package/dist/tldraw/translations/zh-tw.json +176 -176
- package/package.json +20 -17
- package/readme.md +36 -27
- package/dist/tldraw/assets/index-C93mJRxX.js +0 -315
- package/dist/tldraw/assets/index-DWCRF5Ys.css +0 -1
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
var hO=Object.defineProperty;var pO=(e,n,t)=>n in e?hO(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var m=(e,n,t)=>(pO(e,typeof n!="symbol"?n+"":n,t),t);function fO(e,n){for(var t=0;t<n.length;t++){const r=n[t];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 n=document.createElement("link").relList;if(n&&n.supports&&n.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 t(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=t(o);fetch(o.href,s)}})();var en=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function el(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var aI={exports:{}},af={},lI={exports:{}},Pe={};/**
|
|
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 fu=Symbol.for("react.element"),gO=Symbol.for("react.portal"),mO=Symbol.for("react.fragment"),yO=Symbol.for("react.strict_mode"),SO=Symbol.for("react.profiler"),vO=Symbol.for("react.provider"),wO=Symbol.for("react.context"),xO=Symbol.for("react.forward_ref"),bO=Symbol.for("react.suspense"),PO=Symbol.for("react.memo"),CO=Symbol.for("react.lazy"),Ix=Symbol.iterator;function IO(e){return e===null||typeof e!="object"?null:(e=Ix&&e[Ix]||e["@@iterator"],typeof e=="function"?e:null)}var cI={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},uI=Object.assign,dI={};function tl(e,n,t){this.props=e,this.context=n,this.refs=dI,this.updater=t||cI}tl.prototype.isReactComponent={};tl.prototype.setState=function(e,n){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,n,"setState")};tl.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function hI(){}hI.prototype=tl.prototype;function Ev(e,n,t){this.props=e,this.context=n,this.refs=dI,this.updater=t||cI}var _v=Ev.prototype=new hI;_v.constructor=Ev;uI(_v,tl.prototype);_v.isPureReactComponent=!0;var Ex=Array.isArray,pI=Object.prototype.hasOwnProperty,kv={current:null},fI={key:!0,ref:!0,__self:!0,__source:!0};function gI(e,n,t){var r,o={},s=null,i=null;if(n!=null)for(r in n.ref!==void 0&&(i=n.ref),n.key!==void 0&&(s=""+n.key),n)pI.call(n,r)&&!fI.hasOwnProperty(r)&&(o[r]=n[r]);var a=arguments.length-2;if(a===1)o.children=t;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:fu,type:e,key:s,ref:i,props:o,_owner:kv.current}}function EO(e,n){return{$$typeof:fu,type:e.type,key:n,ref:e.ref,props:e.props,_owner:e._owner}}function Tv(e){return typeof e=="object"&&e!==null&&e.$$typeof===fu}function _O(e){var n={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(t){return n[t]})}var _x=/\/+/g;function Sg(e,n){return typeof e=="object"&&e!==null&&e.key!=null?_O(""+e.key):n.toString(36)}function eh(e,n,t,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 fu:case gO:i=!0}}if(i)return i=e,o=o(i),e=r===""?"."+Sg(i,0):r,Ex(o)?(t="",e!=null&&(t=e.replace(_x,"$&/")+"/"),eh(o,n,t,"",function(c){return c})):o!=null&&(Tv(o)&&(o=EO(o,t+(!o.key||i&&i.key===o.key?"":(""+o.key).replace(_x,"$&/")+"/")+e)),n.push(o)),1;if(i=0,r=r===""?".":r+":",Ex(e))for(var a=0;a<e.length;a++){s=e[a];var l=r+Sg(s,a);i+=eh(s,n,t,l,o)}else if(l=IO(e),typeof l=="function")for(e=l.call(e),a=0;!(s=e.next()).done;)s=s.value,l=r+Sg(s,a++),i+=eh(s,n,t,l,o);else if(s==="object")throw n=String(e),Error("Objects are not valid as a React child (found: "+(n==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.");return i}function qu(e,n,t){if(e==null)return e;var r=[],o=0;return eh(e,r,"","",function(s){return n.call(t,s,o++)}),r}function kO(e){if(e._status===-1){var n=e._result;n=n(),n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var fn={current:null},th={transition:null},TO={ReactCurrentDispatcher:fn,ReactCurrentBatchConfig:th,ReactCurrentOwner:kv};Pe.Children={map:qu,forEach:function(e,n,t){qu(e,function(){n.apply(this,arguments)},t)},count:function(e){var n=0;return qu(e,function(){n++}),n},toArray:function(e){return qu(e,function(n){return n})||[]},only:function(e){if(!Tv(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Pe.Component=tl;Pe.Fragment=mO;Pe.Profiler=SO;Pe.PureComponent=Ev;Pe.StrictMode=yO;Pe.Suspense=bO;Pe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=TO;Pe.cloneElement=function(e,n,t){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=uI({},e.props),o=e.key,s=e.ref,i=e._owner;if(n!=null){if(n.ref!==void 0&&(s=n.ref,i=kv.current),n.key!==void 0&&(o=""+n.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(l in n)pI.call(n,l)&&!fI.hasOwnProperty(l)&&(r[l]=n[l]===void 0&&a!==void 0?a[l]:n[l])}var l=arguments.length-2;if(l===1)r.children=t;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];r.children=a}return{$$typeof:fu,type:e.type,key:o,ref:s,props:r,_owner:i}};Pe.createContext=function(e){return e={$$typeof:wO,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:vO,_context:e},e.Consumer=e};Pe.createElement=gI;Pe.createFactory=function(e){var n=gI.bind(null,e);return n.type=e,n};Pe.createRef=function(){return{current:null}};Pe.forwardRef=function(e){return{$$typeof:xO,render:e}};Pe.isValidElement=Tv;Pe.lazy=function(e){return{$$typeof:CO,_payload:{_status:-1,_result:e},_init:kO}};Pe.memo=function(e,n){return{$$typeof:PO,type:e,compare:n===void 0?null:n}};Pe.startTransition=function(e){var n=th.transition;th.transition={};try{e()}finally{th.transition=n}};Pe.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};Pe.useCallback=function(e,n){return fn.current.useCallback(e,n)};Pe.useContext=function(e){return fn.current.useContext(e)};Pe.useDebugValue=function(){};Pe.useDeferredValue=function(e){return fn.current.useDeferredValue(e)};Pe.useEffect=function(e,n){return fn.current.useEffect(e,n)};Pe.useId=function(){return fn.current.useId()};Pe.useImperativeHandle=function(e,n,t){return fn.current.useImperativeHandle(e,n,t)};Pe.useInsertionEffect=function(e,n){return fn.current.useInsertionEffect(e,n)};Pe.useLayoutEffect=function(e,n){return fn.current.useLayoutEffect(e,n)};Pe.useMemo=function(e,n){return fn.current.useMemo(e,n)};Pe.useReducer=function(e,n,t){return fn.current.useReducer(e,n,t)};Pe.useRef=function(e){return fn.current.useRef(e)};Pe.useState=function(e){return fn.current.useState(e)};Pe.useSyncExternalStore=function(e,n,t){return fn.current.useSyncExternalStore(e,n,t)};Pe.useTransition=function(){return fn.current.useTransition()};Pe.version="18.2.0";lI.exports=Pe;var x=lI.exports;const ie=el(x),$O=fO({__proto__:null,default:ie},[x]);/**
|
|
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 MO=x,AO=Symbol.for("react.element"),jO=Symbol.for("react.fragment"),OO=Object.prototype.hasOwnProperty,DO=MO.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,RO={key:!0,ref:!0,__self:!0,__source:!0};function mI(e,n,t){var r,o={},s=null,i=null;t!==void 0&&(s=""+t),n.key!==void 0&&(s=""+n.key),n.ref!==void 0&&(i=n.ref);for(r in n)OO.call(n,r)&&!RO.hasOwnProperty(r)&&(o[r]=n[r]);if(e&&e.defaultProps)for(r in n=e.defaultProps,n)o[r]===void 0&&(o[r]=n[r]);return{$$typeof:AO,type:e,key:s,ref:i,props:o,_owner:DO.current}}af.Fragment=jO;af.jsx=mI;af.jsxs=mI;aI.exports=af;var p=aI.exports;function A(e,n={}){const t=typeof e=="string"?e:e.src;if(typeof n=="function")return n(t);const{baseUrl:r=""}=n;return t.startsWith("data:")||t.match(/^https?:\/\//)?t:`${r.replace(/\/$/,"")}/${t.replace(/^\.?\//,"")}`}function LO(e){return{fonts:{monospace:A("./fonts/IBMPlexMono-Medium.woff2",e),sansSerif:A("./fonts/IBMPlexSans-Medium.woff2",e),serif:A("./fonts/IBMPlexSerif-Medium.woff2",e),draw:A("./fonts/Shantell_Sans-Tldrawish.woff2",e)},icons:{"align-bottom-center":A("./icons/icon/align-bottom-center.svg",e),"align-bottom-left":A("./icons/icon/align-bottom-left.svg",e),"align-bottom-right":A("./icons/icon/align-bottom-right.svg",e),"align-bottom":A("./icons/icon/align-bottom.svg",e),"align-center-center":A("./icons/icon/align-center-center.svg",e),"align-center-horizontal":A("./icons/icon/align-center-horizontal.svg",e),"align-center-left":A("./icons/icon/align-center-left.svg",e),"align-center-right":A("./icons/icon/align-center-right.svg",e),"align-center-vertical":A("./icons/icon/align-center-vertical.svg",e),"align-left":A("./icons/icon/align-left.svg",e),"align-right":A("./icons/icon/align-right.svg",e),"align-top-center":A("./icons/icon/align-top-center.svg",e),"align-top-left":A("./icons/icon/align-top-left.svg",e),"align-top-right":A("./icons/icon/align-top-right.svg",e),"align-top":A("./icons/icon/align-top.svg",e),"arrow-left":A("./icons/icon/arrow-left.svg",e),"arrowhead-arrow":A("./icons/icon/arrowhead-arrow.svg",e),"arrowhead-bar":A("./icons/icon/arrowhead-bar.svg",e),"arrowhead-diamond":A("./icons/icon/arrowhead-diamond.svg",e),"arrowhead-dot":A("./icons/icon/arrowhead-dot.svg",e),"arrowhead-none":A("./icons/icon/arrowhead-none.svg",e),"arrowhead-square":A("./icons/icon/arrowhead-square.svg",e),"arrowhead-triangle-inverted":A("./icons/icon/arrowhead-triangle-inverted.svg",e),"arrowhead-triangle":A("./icons/icon/arrowhead-triangle.svg",e),"aspect-ratio":A("./icons/icon/aspect-ratio.svg",e),avatar:A("./icons/icon/avatar.svg",e),blob:A("./icons/icon/blob.svg",e),"bring-forward":A("./icons/icon/bring-forward.svg",e),"bring-to-front":A("./icons/icon/bring-to-front.svg",e),check:A("./icons/icon/check.svg",e),"checkbox-checked":A("./icons/icon/checkbox-checked.svg",e),"checkbox-empty":A("./icons/icon/checkbox-empty.svg",e),"chevron-down":A("./icons/icon/chevron-down.svg",e),"chevron-left":A("./icons/icon/chevron-left.svg",e),"chevron-right":A("./icons/icon/chevron-right.svg",e),"chevron-up":A("./icons/icon/chevron-up.svg",e),"chevrons-ne":A("./icons/icon/chevrons-ne.svg",e),"chevrons-sw":A("./icons/icon/chevrons-sw.svg",e),"clipboard-copied":A("./icons/icon/clipboard-copied.svg",e),"clipboard-copy":A("./icons/icon/clipboard-copy.svg",e),code:A("./icons/icon/code.svg",e),collab:A("./icons/icon/collab.svg",e),color:A("./icons/icon/color.svg",e),comment:A("./icons/icon/comment.svg",e),"cross-2":A("./icons/icon/cross-2.svg",e),cross:A("./icons/icon/cross.svg",e),"dash-dashed":A("./icons/icon/dash-dashed.svg",e),"dash-dotted":A("./icons/icon/dash-dotted.svg",e),"dash-draw":A("./icons/icon/dash-draw.svg",e),"dash-solid":A("./icons/icon/dash-solid.svg",e),discord:A("./icons/icon/discord.svg",e),"distribute-horizontal":A("./icons/icon/distribute-horizontal.svg",e),"distribute-vertical":A("./icons/icon/distribute-vertical.svg",e),dot:A("./icons/icon/dot.svg",e),"dots-horizontal":A("./icons/icon/dots-horizontal.svg",e),"dots-vertical":A("./icons/icon/dots-vertical.svg",e),"drag-handle-dots":A("./icons/icon/drag-handle-dots.svg",e),duplicate:A("./icons/icon/duplicate.svg",e),edit:A("./icons/icon/edit.svg",e),"external-link":A("./icons/icon/external-link.svg",e),file:A("./icons/icon/file.svg",e),"fill-none":A("./icons/icon/fill-none.svg",e),"fill-pattern":A("./icons/icon/fill-pattern.svg",e),"fill-semi":A("./icons/icon/fill-semi.svg",e),"fill-solid":A("./icons/icon/fill-solid.svg",e),follow:A("./icons/icon/follow.svg",e),following:A("./icons/icon/following.svg",e),"font-draw":A("./icons/icon/font-draw.svg",e),"font-mono":A("./icons/icon/font-mono.svg",e),"font-sans":A("./icons/icon/font-sans.svg",e),"font-serif":A("./icons/icon/font-serif.svg",e),"geo-arrow-down":A("./icons/icon/geo-arrow-down.svg",e),"geo-arrow-left":A("./icons/icon/geo-arrow-left.svg",e),"geo-arrow-right":A("./icons/icon/geo-arrow-right.svg",e),"geo-arrow-up":A("./icons/icon/geo-arrow-up.svg",e),"geo-check-box":A("./icons/icon/geo-check-box.svg",e),"geo-cloud":A("./icons/icon/geo-cloud.svg",e),"geo-diamond":A("./icons/icon/geo-diamond.svg",e),"geo-ellipse":A("./icons/icon/geo-ellipse.svg",e),"geo-hexagon":A("./icons/icon/geo-hexagon.svg",e),"geo-octagon":A("./icons/icon/geo-octagon.svg",e),"geo-oval":A("./icons/icon/geo-oval.svg",e),"geo-pentagon":A("./icons/icon/geo-pentagon.svg",e),"geo-rectangle":A("./icons/icon/geo-rectangle.svg",e),"geo-rhombus-2":A("./icons/icon/geo-rhombus-2.svg",e),"geo-rhombus":A("./icons/icon/geo-rhombus.svg",e),"geo-star":A("./icons/icon/geo-star.svg",e),"geo-trapezoid":A("./icons/icon/geo-trapezoid.svg",e),"geo-triangle":A("./icons/icon/geo-triangle.svg",e),"geo-x-box":A("./icons/icon/geo-x-box.svg",e),github:A("./icons/icon/github.svg",e),group:A("./icons/icon/group.svg",e),hidden:A("./icons/icon/hidden.svg",e),image:A("./icons/icon/image.svg",e),"info-circle":A("./icons/icon/info-circle.svg",e),leading:A("./icons/icon/leading.svg",e),link:A("./icons/icon/link.svg",e),"lock-small":A("./icons/icon/lock-small.svg",e),lock:A("./icons/icon/lock.svg",e),menu:A("./icons/icon/menu.svg",e),minus:A("./icons/icon/minus.svg",e),mixed:A("./icons/icon/mixed.svg",e),pack:A("./icons/icon/pack.svg",e),page:A("./icons/icon/page.svg",e),plus:A("./icons/icon/plus.svg",e),"question-mark-circle":A("./icons/icon/question-mark-circle.svg",e),"question-mark":A("./icons/icon/question-mark.svg",e),redo:A("./icons/icon/redo.svg",e),"reset-zoom":A("./icons/icon/reset-zoom.svg",e),"rotate-ccw":A("./icons/icon/rotate-ccw.svg",e),"rotate-cw":A("./icons/icon/rotate-cw.svg",e),ruler:A("./icons/icon/ruler.svg",e),search:A("./icons/icon/search.svg",e),"send-backward":A("./icons/icon/send-backward.svg",e),"send-to-back":A("./icons/icon/send-to-back.svg",e),"settings-horizontal":A("./icons/icon/settings-horizontal.svg",e),"settings-vertical-1":A("./icons/icon/settings-vertical-1.svg",e),"settings-vertical":A("./icons/icon/settings-vertical.svg",e),"share-1":A("./icons/icon/share-1.svg",e),"share-2":A("./icons/icon/share-2.svg",e),"size-extra-large":A("./icons/icon/size-extra-large.svg",e),"size-large":A("./icons/icon/size-large.svg",e),"size-medium":A("./icons/icon/size-medium.svg",e),"size-small":A("./icons/icon/size-small.svg",e),"spline-cubic":A("./icons/icon/spline-cubic.svg",e),"spline-line":A("./icons/icon/spline-line.svg",e),"stack-horizontal":A("./icons/icon/stack-horizontal.svg",e),"stack-vertical":A("./icons/icon/stack-vertical.svg",e),"status-offline":A("./icons/icon/status-offline.svg",e),"status-online":A("./icons/icon/status-online.svg",e),"stretch-horizontal":A("./icons/icon/stretch-horizontal.svg",e),"stretch-vertical":A("./icons/icon/stretch-vertical.svg",e),"text-align-center":A("./icons/icon/text-align-center.svg",e),"text-align-justify":A("./icons/icon/text-align-justify.svg",e),"text-align-left":A("./icons/icon/text-align-left.svg",e),"text-align-right":A("./icons/icon/text-align-right.svg",e),"tool-arrow":A("./icons/icon/tool-arrow.svg",e),"tool-embed":A("./icons/icon/tool-embed.svg",e),"tool-eraser":A("./icons/icon/tool-eraser.svg",e),"tool-frame":A("./icons/icon/tool-frame.svg",e),"tool-hand":A("./icons/icon/tool-hand.svg",e),"tool-highlight":A("./icons/icon/tool-highlight.svg",e),"tool-laser":A("./icons/icon/tool-laser.svg",e),"tool-line":A("./icons/icon/tool-line.svg",e),"tool-media":A("./icons/icon/tool-media.svg",e),"tool-note":A("./icons/icon/tool-note.svg",e),"tool-pencil":A("./icons/icon/tool-pencil.svg",e),"tool-pointer":A("./icons/icon/tool-pointer.svg",e),"tool-text":A("./icons/icon/tool-text.svg",e),trash:A("./icons/icon/trash.svg",e),"triangle-down":A("./icons/icon/triangle-down.svg",e),"triangle-up":A("./icons/icon/triangle-up.svg",e),twitter:A("./icons/icon/twitter.svg",e),undo:A("./icons/icon/undo.svg",e),ungroup:A("./icons/icon/ungroup.svg",e),"unlock-small":A("./icons/icon/unlock-small.svg",e),unlock:A("./icons/icon/unlock.svg",e),"vertical-align-center":A("./icons/icon/vertical-align-center.svg",e),"vertical-align-end":A("./icons/icon/vertical-align-end.svg",e),"vertical-align-start":A("./icons/icon/vertical-align-start.svg",e),visible:A("./icons/icon/visible.svg",e),"warning-triangle":A("./icons/icon/warning-triangle.svg",e),"zoom-in":A("./icons/icon/zoom-in.svg",e),"zoom-out":A("./icons/icon/zoom-out.svg",e)},translations:{ar:A("./translations/ar.json",e),ca:A("./translations/ca.json",e),cs:A("./translations/cs.json",e),da:A("./translations/da.json",e),de:A("./translations/de.json",e),en:A("./translations/en.json",e),es:A("./translations/es.json",e),fa:A("./translations/fa.json",e),fi:A("./translations/fi.json",e),fr:A("./translations/fr.json",e),gl:A("./translations/gl.json",e),he:A("./translations/he.json",e),"hi-in":A("./translations/hi-in.json",e),hr:A("./translations/hr.json",e),hu:A("./translations/hu.json",e),it:A("./translations/it.json",e),ja:A("./translations/ja.json",e),"ko-kr":A("./translations/ko-kr.json",e),ku:A("./translations/ku.json",e),languages:A("./translations/languages.json",e),main:A("./translations/main.json",e),my:A("./translations/my.json",e),ne:A("./translations/ne.json",e),no:A("./translations/no.json",e),pl:A("./translations/pl.json",e),"pt-br":A("./translations/pt-br.json",e),"pt-pt":A("./translations/pt-pt.json",e),ro:A("./translations/ro.json",e),ru:A("./translations/ru.json",e),sl:A("./translations/sl.json",e),sv:A("./translations/sv.json",e),te:A("./translations/te.json",e),th:A("./translations/th.json",e),tr:A("./translations/tr.json",e),uk:A("./translations/uk.json",e),vi:A("./translations/vi.json",e),"zh-cn":A("./translations/zh-cn.json",e),"zh-tw":A("./translations/zh-tw.json",e)},embedIcons:{codepen:A("./embed-icons/codepen.png",e),codesandbox:A("./embed-icons/codesandbox.png",e),excalidraw:A("./embed-icons/excalidraw.png",e),felt:A("./embed-icons/felt.png",e),figma:A("./embed-icons/figma.png",e),github_gist:A("./embed-icons/github_gist.png",e),google_calendar:A("./embed-icons/google_calendar.png",e),google_maps:A("./embed-icons/google_maps.png",e),google_slides:A("./embed-icons/google_slides.png",e),observable:A("./embed-icons/observable.png",e),replit:A("./embed-icons/replit.png",e),scratch:A("./embed-icons/scratch.png",e),spotify:A("./embed-icons/spotify.png",e),tldraw:A("./embed-icons/tldraw.png",e),val_town:A("./embed-icons/val_town.png",e),vimeo:A("./embed-icons/vimeo.png",e),youtube:A("./embed-icons/youtube.png",e)}}}async function NO(e,n){const{url:t,style:r="normal",weight:o="500",display:s,featureSettings:i,stretch:a,unicodeRange:l,variant:c,format:u}=n,d={style:r,weight:o,display:s,featureSettings:i,stretch:a,unicodeRange:l,variant:c},h=new FontFace(e,`url(${t})`,d);return await h.load(),document.fonts.add(h),h.$$_url=t,h.$$_fontface=`
|
|
18
|
+
@font-face {
|
|
19
|
+
font-family: ${h.family};
|
|
20
|
+
font-stretch: ${h.stretch};
|
|
21
|
+
font-weight: ${h.weight};
|
|
22
|
+
font-style: ${h.style};
|
|
23
|
+
src: url("${t}") format("${u}")
|
|
24
|
+
}`,h}function yI(e){return e&&typeof e=="object"&&"parents"in e}function SI(e){for(let n=0,t=e.parents.length;n<t;n++)if(e.parents[n].__unsafe__getWithoutCapture(!0),e.parents[n].lastChangedEpoch!==e.parentEpochs[n])return!0;return!1}const Qh=(e,n)=>{if(e.children.remove(n)&&e.children.isEmpty&&yI(e))for(let t=0,r=e.parents.length;t<r;t++)Qh(e.parents[t],e)},$v=(e,n)=>{if(e.children.add(n)&&yI(e))for(let t=0,r=e.parents.length;t<r;t++)$v(e.parents[t],e)};function vI(e,n){return e===n||Object.is(e,n)||!!(e&&n&&typeof e.equals=="function"&&e.equals(n))}function zs(e,n){const t=Symbol.for(`com.tldraw.state/${e}`),r=globalThis;return r[t]??(r[t]=n()),r[t]}const $s=zs("empty_array",()=>Object.freeze([])),kx=8;class wI{constructor(){m(this,"arraySize",0);m(this,"array",Array(kx));m(this,"set",null)}get isEmpty(){if(this.array)return this.arraySize===0;if(this.set)return this.set.size===0;throw new Error("no set or array")}add(n){if(this.array)return this.array.indexOf(n)!==-1?!1:this.arraySize<kx?(this.array[this.arraySize]=n,this.arraySize++,!0):(this.set=new Set(this.array),this.array=null,this.set.add(n),!0);if(this.set)return this.set.has(n)?!1:(this.set.add(n),!0);throw new Error("no set or array")}remove(n){if(this.array){const t=this.array.indexOf(n);return t===-1?!1:(this.array[t]=void 0,this.arraySize--,t!==this.arraySize&&(this.array[t]=this.array[this.arraySize],this.array[this.arraySize]=void 0),!0)}if(this.set)return this.set.has(n)?(this.set.delete(n),!0):!1;throw new Error("no set or array")}visit(n){if(this.array){for(let t=0;t<this.arraySize;t++){const r=this.array[t];typeof r<"u"&&n(r)}return}if(this.set){this.set.forEach(n);return}throw new Error("no set or array")}}const Xn=Symbol.for("com.tldraw.state/RESET_VALUE");class xI{constructor(n){m(this,"index",0);m(this,"buffer");this.capacity=n,this.buffer=new Array(n)}pushEntry(n,t,r){if(r!==void 0){if(r===Xn){this.clear();return}this.buffer[this.index]=[n,t,r],this.index=(this.index+1)%this.capacity}}clear(){this.index=0,this.buffer.fill(void 0)}getChangesSince(n){const{index:t,capacity:r,buffer:o}=this;for(let s=0;s<r;s++){const i=(t-1+r-s)%r,a=o[i];if(!a)return Xn;const[l,c]=a;if(s===0&&n>=c)return[];if(l<=n&&n<c){const u=s+1,d=new Array(u);for(let h=0;h<u;h++)d[h]=o[(i+h)%r][2];return d}}return Xn}}class FO{constructor(n,t){m(this,"offset",0);m(this,"numNewParents",0);m(this,"maybeRemoved");this.below=n,this.child=t}}const et=zs("capture",()=>({stack:null}));function bI(e){et.stack=new FO(et.stack,e)}function PI(){var t;const e=et.stack;if(et.stack=e.below,e.numNewParents>0||e.offset!==e.child.parents.length){for(let r=e.offset;r<e.child.parents.length;r++){const o=e.child.parents[r];e.child.parents.indexOf(o)>=e.offset&&Qh(o,e.child)}if(e.child.parents.length=e.offset,e.child.parentEpochs.length=e.offset,(t=et.stack)!=null&&t.maybeRemoved)for(let r=0;r<et.stack.maybeRemoved.length;r++){const o=et.stack.maybeRemoved[r];e.child.parents.indexOf(o)===-1&&Qh(o,e.child)}}}function Jh(e){if(et.stack){const n=et.stack.child.parents.indexOf(e);if(n<0&&(et.stack.numNewParents++,et.stack.child.isActivelyListening&&$v(e,et.stack.child)),n<0||n>=et.stack.offset){if(n!==et.stack.offset&&n>0){const t=et.stack.child.parents[et.stack.offset];et.stack.maybeRemoved?et.stack.maybeRemoved.indexOf(t)===-1&&et.stack.maybeRemoved.push(t):et.stack.maybeRemoved=[t]}et.stack.child.parents[et.stack.offset]=e,et.stack.child.parentEpochs[et.stack.offset]=e.lastChangedEpoch,et.stack.offset++}}}const ii=-1;class zO{constructor(n,t,r){m(this,"_isActivelyListening",!1);m(this,"lastTraversedEpoch",ii);m(this,"lastReactedEpoch",ii);m(this,"_scheduleCount",0);m(this,"parentEpochs",[]);m(this,"parents",[]);m(this,"_scheduleEffect");m(this,"maybeExecute",()=>{this._isActivelyListening&&this.execute()});this.name=n,this.runEffect=t,this._scheduleEffect=r==null?void 0:r.scheduleEffect}get isActivelyListening(){return this._isActivelyListening}get scheduleCount(){return this._scheduleCount}maybeScheduleEffect(){if(this._isActivelyListening&&this.lastReactedEpoch!==un()){if(this.parents.length&&!SI(this)){this.lastReactedEpoch=un();return}this.scheduleEffect()}}scheduleEffect(){this._scheduleCount++,this._scheduleEffect?this._scheduleEffect(this.maybeExecute):this.execute()}attach(){this._isActivelyListening=!0;for(let n=0,t=this.parents.length;n<t;n++)$v(this.parents[n],this)}detach(){this._isActivelyListening=!1;for(let n=0,t=this.parents.length;n<t;n++)Qh(this.parents[n],this)}execute(){try{bI(this);const n=this.runEffect(this.lastReactedEpoch);return this.lastReactedEpoch=un(),n}finally{PI()}}}const nl=zs("EffectScheduler",()=>zO);function gu(e,n,t){const r=new nl(e,n,t);return r.attach(),r.scheduleEffect(),()=>{r.detach()}}function BO(e,n,t){const r=new nl(e,n,t);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 UO{constructor(n){m(this,"initialAtomValues",new Map);this.parent=n}get isRoot(){return this.parent===null}commit(){if(this.isRoot){const n=this.initialAtomValues;this.initialAtomValues=new Map,CI(n.keys())}else this.initialAtomValues.forEach((n,t)=>{this.parent.initialAtomValues.has(t)||this.parent.initialAtomValues.set(t,n)})}abort(){Jt.globalEpoch++,this.initialAtomValues.forEach((n,t)=>{var r;t.set(n),(r=t.historyBuffer)==null||r.clear()}),this.commit()}}const Jt=zs("transactions",()=>({globalEpoch:ii+1,globalIsReacting:!1,currentTransaction:null}));function un(){return Jt.globalEpoch}function CI(e){if(Jt.globalIsReacting)throw new Error("cannot change atoms during reaction cycle");try{Jt.globalIsReacting=!0;const n=new Set,t=r=>{r.lastTraversedEpoch!==Jt.globalEpoch&&(r.lastTraversedEpoch=Jt.globalEpoch,r instanceof nl?n.add(r):r.children.visit(t))};for(const r of e)r.children.visit(t);for(const r of n)r.maybeScheduleEffect()}finally{Jt.globalIsReacting=!1}}function HO(e,n){Jt.currentTransaction?Jt.currentTransaction.initialAtomValues.has(e)||Jt.currentTransaction.initialAtomValues.set(e,n):CI([e])}function KO(){Jt.globalEpoch++}function VO(e){const n=new UO(Jt.currentTransaction);Jt.currentTransaction=n;try{let t=!1;const r=e(()=>t=!0);return t?n.abort():n.commit(),r}catch(t){throw n.abort(),t}finally{Jt.currentTransaction=Jt.currentTransaction.parent}}function Tr(e){return Jt.currentTransaction?e():VO(e)}class WO{constructor(n,t,r){m(this,"isEqual");m(this,"computeDiff");m(this,"lastChangedEpoch",un());m(this,"children",new wI);m(this,"historyBuffer");this.name=n,this.current=t,this.isEqual=(r==null?void 0:r.isEqual)??null,r&&(r.historyLength&&(this.historyBuffer=new xI(r.historyLength)),this.computeDiff=r.computeDiff)}__unsafe__getWithoutCapture(n){return this.current}get(){return Jh(this),this.current}set(n,t){var o,s;if(((o=this.isEqual)==null?void 0:o.call(this,this.current,n))??vI(this.current,n))return this.current;KO(),this.historyBuffer&&this.historyBuffer.pushEntry(this.lastChangedEpoch,un(),t??((s=this.computeDiff)==null?void 0:s.call(this,this.current,n,this.lastChangedEpoch,un()))??Xn),this.lastChangedEpoch=un();const r=this.current;return this.current=n,HO(this,r),n}update(n){return this.set(n(this.current))}getDiffSince(n){var t;return Jh(this),n>=this.lastChangedEpoch?$s:((t=this.historyBuffer)==null?void 0:t.getChangesSince(n))??Xn}}const GO=zs("Atom",()=>WO);function hn(e,n,t){return new GO(e,n,t)}let Tx=!1;function YO(){Tx||(Tx=!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.
|
|
25
|
+
|
|
26
|
+
// Before
|
|
27
|
+
@computed
|
|
28
|
+
get foo() {
|
|
29
|
+
return 'foo'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// After
|
|
33
|
+
@computed
|
|
34
|
+
getFoo() {
|
|
35
|
+
return 'foo'
|
|
36
|
+
}
|
|
37
|
+
`))}const Yl=Symbol.for("com.tldraw.state/UNINITIALIZED"),$a=e=>e===Yl,ky=zs("WithDiff",()=>class{constructor(n,t){this.value=n,this.diff=t}});function Xl(e,n){return new ky(e,n)}class XO{constructor(n,t,r){m(this,"lastChangedEpoch",ii);m(this,"lastTraversedEpoch",ii);m(this,"lastCheckedEpoch",ii);m(this,"parents",[]);m(this,"parentEpochs",[]);m(this,"children",new wI);m(this,"historyBuffer");m(this,"state",Yl);m(this,"error",null);m(this,"computeDiff");m(this,"isEqual");this.name=n,this.derive=t,r!=null&&r.historyLength&&(this.historyBuffer=new xI(r.historyLength)),this.computeDiff=r==null?void 0:r.computeDiff,this.isEqual=(r==null?void 0:r.isEqual)??vI}get isActivelyListening(){return!this.children.isEmpty}__unsafe__getWithoutCapture(n){var r;if(!(this.lastChangedEpoch===ii)&&(this.lastCheckedEpoch===un()||!SI(this)))if(this.lastCheckedEpoch=un(),this.error){if(n)return this.state;throw this.error.thrownValue}else return this.state;try{bI(this);const o=this.derive(this.state,this.lastCheckedEpoch),s=o instanceof ky?o.value:o,i=this.state===Yl;if(i||!this.isEqual(s,this.state)){if(this.historyBuffer&&!i){const a=o instanceof ky?o.diff:void 0;this.historyBuffer.pushEntry(this.lastChangedEpoch,un(),a??((r=this.computeDiff)==null?void 0:r.call(this,this.state,s,this.lastCheckedEpoch,un()))??Xn)}this.lastChangedEpoch=un(),this.state=s}return this.error=null,this.lastCheckedEpoch=un(),this.state}catch(o){if(this.state!==Yl&&(this.state=Yl,this.lastChangedEpoch=un()),this.lastCheckedEpoch=un(),this.historyBuffer&&this.historyBuffer.clear(),this.error={thrownValue:o},!n)throw o;return this.state}finally{PI()}}get(){try{return this.__unsafe__getWithoutCapture()}finally{Jh(this)}}getDiffSince(n){var t;return this.__unsafe__getWithoutCapture(!0),Jh(this),n>=this.lastChangedEpoch?$s:((t=this.historyBuffer)==null?void 0:t.getChangesSince(n))??Xn}}const Mv=zs("Computed",()=>XO);function qO(e={},n,t,r){const o=r.value,s=Symbol.for("__@tldraw/state__computed__"+t);return r.value=function(){let i=this[s];return i||(i=new Mv(t,o.bind(this),e),Object.defineProperty(this,s,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()},r.value[QO]=!0,r}function $x(e={},n,t,r){return r.get?(YO(),ZO(e,n,t,r)):qO(e,n,t,r)}function ZO(e={},n,t,r){const o=r.get,s=Symbol.for("__@tldraw/state__computed__"+t);return r.get=function(){let i=this[s];return i||(i=new Mv(t,o.bind(this),e),Object.defineProperty(this,s,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()},r}const QO="@@__isComputedMethod__@@";function Z(){if(arguments.length===1){const e=arguments[0];return(n,t,r)=>$x(e,n,t,r)}else return typeof arguments[0]=="string"?new Mv(arguments[0],arguments[1],arguments[2]):$x(void 0,arguments[0],arguments[1],arguments[2])}const II=1,JO=zs("apiVersion",()=>II);if(JO!==II)throw new Error("You have multiple incompatible versions of @tldraw/state in your app. Please deduplicate the package.");function lf(e,n){const t=ie.useRef(n);t.current=n;const[r,o,s]=ie.useMemo(()=>{let i=null;const a=u=>(i=u,()=>{i=null}),l=new nl(`useStateTracking(${e})`,()=>{var u;return(u=t.current)==null?void 0:u.call(t)},{scheduleEffect(){i==null||i()}});return[l,a,()=>l.scheduleCount]},[e]);return ie.useSyncExternalStore(o,s,s),ie.useEffect(()=>(r.attach(),r.maybeScheduleEffect(),()=>{r.detach()}),[r]),r.execute()}const Mx={apply(e,n,t){return lf(e.displayName??e.name??"tracked(???)",()=>e.apply(n,t))}},eD=Symbol.for("react.memo"),tD=Symbol.for("react.forward_ref");function Tt(e){let n=null;const t=e.$$typeof;return t===eD&&(e=e.type,n=e.compare),t===tD?x.memo(x.forwardRef(new Proxy(e.render,Mx))):x.memo(new Proxy(e,Mx),n)}function EI(){const e=arguments[0],n=arguments[1],t=arguments.length===3?void 0:arguments[2],r=arguments.length===3?arguments[2]:arguments[3];return x.useMemo(()=>Z(`useComputed(${e})`,n,t),r)}function fi(e,n,t=$s){x.useEffect(()=>{const r=new nl(e,n);return r.attach(),r.execute(),()=>{r.detach()}},t)}function K(){const e=arguments,n=e.length===3?e[2]:[e[0]],t=e.length===3?e[0]:`useValue(${e[0].name})`,r=x.useRef(!0);r.current=!0;const o=x.useMemo(()=>e.length===1?e[0]:Z(t,()=>{if(r.current)return e[1]();try{return e[1]()}catch{return{}}}),n);try{const{subscribe:s,getSnapshot:i}=x.useMemo(()=>({subscribe:a=>gu(`useValue(${t})`,()=>{o.get(),a()}),getSnapshot:()=>o.get()}),[o]);return x.useSyncExternalStore(s,i,i)}finally{r.current=!1}}class nh{constructor(n){m(this,"nextValue");m(this,"diff");this.previousValue=n}get(){var r,o,s,i;const n=((o=(r=this.diff)==null?void 0:r.removed)==null?void 0:o.size)??0,t=((i=(s=this.diff)==null?void 0:s.added)==null?void 0:i.size)??0;if(!(n===0&&t===0))return{value:this.nextValue,diff:this.diff}}_add(n,t){var r,o;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.add(n),this.diff??(this.diff={}),t?(r=this.diff.removed)==null||r.delete(n):((o=this.diff).added??(o.added=new Set),this.diff.added.add(n))}add(n){var o,s,i;const t=this.previousValue.has(n);if(t)return((s=(o=this.diff)==null?void 0:o.removed)==null?void 0:s.has(n))?this._add(n,t):void 0;(i=this.nextValue)!=null&&i.has(n)||this._add(n,t)}_remove(n,t){var r,o;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.delete(n),this.diff??(this.diff={}),t?((r=this.diff).removed??(r.removed=new Set),this.diff.removed.add(n)):(o=this.diff.added)==null||o.delete(n)}remove(n){var o,s,i,a;const t=this.previousValue.has(n);if(!t)return((s=(o=this.diff)==null?void 0:o.added)==null?void 0:s.has(n))?this._remove(n,t):void 0;(a=(i=this.diff)==null?void 0:i.removed)!=null&&a.has(n)||this._remove(n,t)}}function ep(e,n){const t=[];e:for(const r of e){for(const o of t)if(n?n(r,o):r===o)continue e;t.push(r)}return t}function ge(e){return e.filter(n=>n!=null)}function xn(e){return e[e.length-1]}function nD(e,n){let t,r=1/0;for(const o of e){const s=n(o);s<r&&(t=o,r=s)}return t}function rD(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!Object.is(e[t],n[t]))return!1;return!0}function _I(e){const n=(...t)=>{try{return e(...t)}catch(r){throw r instanceof Error&&Error.captureStackTrace&&Error.captureStackTrace(r,n),r}};return n}const ti={ok(e){return{ok:!0,value:e}},err(e){return{ok:!1,error:e}}};function Ai(e,n){const t=n&&e&&typeof e=="object"&&n in e?e[n]:e;throw new Error(`Unknown switch case ${t}`)}const Do=_I((e,n)=>{if(!e)throw new Error(n||"Assertion Error")}),ai=_I((e,n)=>{if(e==null)throw new Error(n??"value must be defined");return e});function kI(e,n){let t;const r=(...o)=>(t||(t={},t.promise=new Promise((s,i)=>{t.resolve=s,t.reject=i})),clearTimeout(t.timeout),t.latestArgs=o,t.timeout=setTimeout(()=>{const s=t;t=void 0;try{s.resolve(e(...s.latestArgs))}catch(i){s.reject(i)}},n),t.promise);return r.cancel=()=>{t&&clearTimeout(t.timeout)},r}const Ax=new WeakMap;function Av(e,n){if(typeof e!="object"||e===null)return;let t=Ax.get(e);t||(t={tags:{},extras:{}},Ax.set(e,t)),n.tags&&(t.tags={...t.tags,...n.tags}),n.extras&&(t.extras={...t.extras,...n.extras})}function Ty(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return n+""}function oD(e){const n=new DataView(e);let t=0;for(let r=0;r<n.byteLength;r++)t=(t<<5)-t+n.getUint8(r),t|=0;return t+""}let $y=[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"&&($y=new Int32Array($y));const sD=(e,n)=>{let t=n===0?0:~~n^-1;for(let r=0;r<e.length;r++)t=$y[(t^e[r])&255]^t>>>8;return t^-1},jx=4,Ox=4;class Qr{static isPng(n,t){return n.getUint8(t+0)===137&&n.getUint8(t+1)===80&&n.getUint8(t+2)===78&&n.getUint8(t+3)===71&&n.getUint8(t+4)===13&&n.getUint8(t+5)===10&&n.getUint8(t+6)===26&&n.getUint8(t+7)===10}static getChunkType(n,t){return[String.fromCharCode(n.getUint8(t)),String.fromCharCode(n.getUint8(t+1)),String.fromCharCode(n.getUint8(t+2)),String.fromCharCode(n.getUint8(t+3))].join("")}static readChunks(n,t=0){const r={};if(!Qr.isPng(n,t))throw new Error("Not a PNG");for(t+=8;t<=n.buffer.byteLength;){const o=t,s=n.getInt32(t);t+=4;const i=Qr.getChunkType(n,t);if(i==="IDAT"&&r[i]){t+=s+jx+Ox;continue}if(i==="IEND")break;r[i]={start:o,dataOffset:t+4,size:s},t+=s+jx+Ox}return r}static parsePhys(n,t){return{ppux:n.getUint32(t),ppuy:n.getUint32(t+4),unit:n.getUint8(t+4)}}static findChunk(n,t){return Qr.readChunks(n)[t]}static setPhysChunk(n,t=1,r){let o=46,s=0;const i=Qr.findChunk(n,"pHYs");i&&(o=i.start,s=i.size);const a=Qr.findChunk(n,"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*t),c.setInt32(12,u*t),c.setInt8(16,1);const d=new Uint8Array(l.slice(4,17));c.setInt32(17,sD(d));const h=n.buffer.slice(0,o),f=n.buffer.slice(o+s);return new Blob([h,l,f],r)}}class to{static loadVideo(n){return new Promise((t,r)=>{const o=document.createElement("video");o.onloadeddata=()=>t(o),o.onerror=s=>{console.error(s),r(new Error("Could not load video"))},o.crossOrigin="anonymous",o.src=n})}static loadImage(n){return new Promise((t,r)=>{const o=new Image;o.onload=()=>t(o),o.onerror=s=>{console.error(s),r(new Error("Could not load image"))},o.crossOrigin="anonymous",o.src=n})}static blobToDataUrl(n){return new Promise((t,r)=>{const o=new FileReader;o.onload=()=>t(o.result),o.onerror=s=>{console.error(s),r(new Error("Could not read blob"))},o.readAsDataURL(n)})}static async getVideoSize(n){return to.usingObjectURL(n,async t=>{const r=await to.loadVideo(t);return{w:r.videoWidth,h:r.videoHeight}})}static async getImageSize(n){const t=await to.usingObjectURL(n,to.loadImage);try{if(n.type==="image/png"){const r=new DataView(await n.arrayBuffer());if(Qr.isPng(r,0)){const o=Qr.findChunk(r,"pHYs");if(o){const s=Qr.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(t.naturalWidth/i),h:Math.round(t.naturalHeight/i)}}}}}}catch(r){return console.error(r),{w:t.naturalWidth,h:t.naturalHeight}}return{w:t.naturalWidth,h:t.naturalHeight}}static async usingObjectURL(n,t){const r=URL.createObjectURL(n);try{return await t(r)}finally{URL.revokeObjectURL(r)}}}function ws(e=""){let n=0,t=0,r=0,o=0;function s(){const i=n^n<<11;return n=t,t=r,r=o,o^=(o>>>19^i^i>>>8)>>>0,o/4294967296*2}for(let i=0;i<e.length+64;i++)n^=e.charCodeAt(i)|0,s();return s}function tp(e,n,t,r=!1){const[o,s]=n,[i,a]=t,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 ro(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function hr(e,n){if(ro(e,n))return e[n]}function pr(e){if(!e)return e;if(Array.isArray(e)){const n=[],t=e.length;for(let r=0;r<t;r++)n.push(pr(e[r]));return n}else if(typeof e=="object"){const n=Object.keys(e),t=n.length,r={};for(let o=0;o<t;o++){const s=n[o];r[s]=pr(e[s])}return r}return e}function Dx(e){return Object.keys(e)}function ot(e){return Object.values(e)}function oo(e){return Object.entries(e)}function jv(e){return Object.fromEntries(e)}function vg(e,n){const t={};let r=!1;for(const[o,s]of oo(e))n(o,s)?t[o]=s:r=!0;return r?t:e}function np(e,n){const t={};for(const[r,o]of oo(e)){const s=n(r,o);t[r]=s}return t}function TI(e,n){if(e===n)return!0;const t=new Set(Object.keys(e)),r=new Set(Object.keys(n));if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o)||!Object.is(e[o],n[o]))return!1;return!0}const iD=()=>typeof process<"u"&&!1,rp=[],aD=()=>{const e=rp.splice(0,rp.length);for(const n of e)n()};let wg;function lD(){wg||(wg=requestAnimationFrame(()=>{wg=void 0,aD()}))}function cD(e){if(iD())return e();rp.includes(e)||(rp.push(e),lD())}const Gn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",$I="a0",MI="A00000000000000000000000000";function AI(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 jI(e){if(e.length!==AI(e.charAt(0)))throw new Error("invalid integer part of index key: "+e)}function Rx(e){if(e===void 0)throw Error("n is undefined")}function Lx(e){jI(e);const[n,...t]=e.split("");let r=!0;for(let o=t.length-1;r&&o>=0;o--){const s=Gn.indexOf(t[o])+1;s===Gn.length?t[o]="0":(t[o]=Gn.charAt(s),r=!1)}if(r){if(n==="Z")return"a0";if(n==="z")return;const o=String.fromCharCode(n.charCodeAt(0)+1);return o>"a"?t.push("0"):t.pop(),o+t.join("")}else return n+t.join("")}function uD(e){jI(e);const[n,...t]=e.split("");let r=!0;for(let o=t.length-1;r&&o>=0;o--){const s=Gn.indexOf(t[o])-1;s===-1?t[o]=Gn.slice(-1):(t[o]=Gn.charAt(s),r=!1)}if(r){if(n==="a")return"Z"+Gn.slice(-1);if(n==="A")return;const o=String.fromCharCode(n.charCodeAt(0)-1);return o<"Z"?t.push(Gn.slice(-1)):t.pop(),o+t.join("")}else return n+t.join("")}function ua(e,n){if(n!==void 0&&e>=n)throw new Error(e+" >= "+n);if(e.slice(-1)==="0"||n&&n.slice(-1)==="0")throw new Error("trailing zero");if(n){let o=0;for(;(e.charAt(o)||"0")===n.charAt(o);)o++;if(o>0)return n.slice(0,o)+ua(e.slice(o),n.slice(o))}const t=e?Gn.indexOf(e.charAt(0)):0,r=n!==void 0?Gn.indexOf(n.charAt(0)):Gn.length;if(r-t>1){const o=Math.round(.5*(t+r));return Gn.charAt(o)}else return n&&n.length>1?n.slice(0,1):Gn.charAt(t)+ua(e.slice(1),void 0)}function ql(e){const n=AI(e.charAt(0));if(n>e.length)throw new Error("invalid index: "+e);return e.slice(0,n)}function My(e){if(e===MI)throw new Error("invalid index: "+e);const n=ql(e);if(e.slice(n.length).slice(-1)==="0")throw new Error("invalid index: "+e)}function Ki(e,n){if(e!==void 0&&My(e),n!==void 0&&My(n),e!==void 0&&n!==void 0&&e>=n)throw new Error(e+" >= "+n);if(e===void 0&&n===void 0)return $I;if(e===void 0){if(n===void 0)throw Error("b is undefined");const a=ql(n),l=n.slice(a.length);if(a===MI)return a+ua("",l);if(a<n)return a;const c=uD(a);return Rx(c),c}if(n===void 0){const a=ql(e),l=e.slice(a.length),c=Lx(a);return c===void 0?a+ua(l,void 0):c}const t=ql(e),r=e.slice(t.length),o=ql(n),s=n.slice(o.length);if(t===o)return t+ua(r,s);const i=Lx(t);return Rx(i),i<n?i:t+ua(r,void 0)}function Ms(e,n,t){if(t===0)return[];if(t===1)return[Ki(e,n)];if(n===void 0){let s=Ki(e,n);const i=[s];for(let a=0;a<t-1;a++)s=Ki(s,n),i.push(s);return i}if(e===void 0){let s=Ki(e,n);const i=[s];for(let a=0;a<t-1;a++)s=Ki(e,s),i.push(s);return i.reverse(),i}const r=Math.floor(t/2),o=Ki(e,n);return[...Ms(e,o,r),o,...Ms(o,n,t-r-1)]}const dD=$I;function hD(e){My(e)}function Ba(e,n,t){return Ms(e,n,t)}function xg(e,n){return Ms(e,void 0,n)}function oc(e,n){return Ms(e,n,1)[0]}function ko(e){return Ms(e,void 0,1)[0]}function pD(e){return Ms(void 0,e,1)[0]}function Pc(e,n="a1"){return[n,...Ms(n,void 0,e)]}function Rt(e,n){return e.index<n.index?-1:e.index>n.index?1:0}function fD(e,n){return e.id>n.id?1:-1}function gD(e){return e!==null}const Dr=typeof window<"u"&&window.structuredClone?window.structuredClone:e=>e&&JSON.parse(JSON.stringify(e));let cf=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((n,t)=>(t&=63,t<36?n+=t.toString(36):t<62?n+=(t-26).toString(36).toUpperCase():t>62?n+="-":n+="_",n),"");class Ov{constructor(n,t){m(this,"createDefaultProperties");m(this,"migrations");m(this,"validator");m(this,"scope");m(this,"isInstance",n=>(n==null?void 0:n.typeName)===this.typeName);this.typeName=n,this.createDefaultProperties=t.createDefaultProperties,this.migrations=t.migrations,this.validator=t.validator??{validate:r=>r},this.scope=t.scope??"document"}create(n){const t={...this.createDefaultProperties(),id:this.createId()};for(const[r,o]of Object.entries(n))o!==void 0&&(t[r]=o);return t.typeName=this.typeName,t}clone(n){return{...Dr(n),id:this.createId()}}createId(n){return this.typeName+":"+(n??cf())}createCustomId(n){return this.typeName+":"+n}parseId(n){if(!this.isId(n))throw new Error(`ID "${n}" is not a valid ID for type "${this.typeName}"`);return n.slice(this.typeName.length+1)}isId(n){if(!n)return!1;for(let t=0;t<this.typeName.length;t++)if(n[t]!==this.typeName[t])return!1;return n[this.typeName.length]===":"}withDefaultProperties(n){return new Ov(this.typeName,{createDefaultProperties:n,migrations:this.migrations,validator:this.validator,scope:this.scope})}validate(n,t){return t&&this.validator.validateUsingKnownGoodVersion?this.validator.validateUsingKnownGoodVersion(t,n):this.validator.validate(n)}}function Yo(e,n){return new Ov(e,{createDefaultProperties:()=>({}),migrations:n.migrations??{currentVersion:0,firstVersion:0,migrators:{}},validator:n.validator,scope:n.scope})}class Nx{constructor(){m(this,"items",new WeakMap)}get(n,t){return this.items.has(n)||this.items.set(n,t(n)),this.items.get(n)}}var op={exports:{}};op.exports;(function(e,n){var t=200,r="__lodash_hash_undefined__",o=1,s=2,i=9007199254740991,a="[object Arguments]",l="[object Array]",c="[object AsyncFunction]",u="[object Boolean]",d="[object Date]",h="[object Error]",f="[object Function]",y="[object GeneratorFunction]",g="[object Map]",v="[object Number]",S="[object Null]",w="[object Object]",C="[object Promise]",I="[object Proxy]",P="[object RegExp]",E="[object Set]",_="[object String]",k="[object Symbol]",M="[object Undefined]",T="[object WeakMap]",R="[object ArrayBuffer]",O="[object DataView]",U="[object Float32Array]",N="[object Float64Array]",L="[object Int8Array]",G="[object Int16Array]",X="[object Int32Array]",H="[object Uint8Array]",B="[object Uint8ClampedArray]",W="[object Uint16Array]",Y="[object Uint32Array]",J=/[\\^$.*+?()[\]{}|]/g,ke=/^\[object .+?Constructor\]$/,ve=/^(?:0|[1-9]\d*)$/,pe={};pe[U]=pe[N]=pe[L]=pe[G]=pe[X]=pe[H]=pe[B]=pe[W]=pe[Y]=!0,pe[a]=pe[l]=pe[R]=pe[u]=pe[O]=pe[d]=pe[h]=pe[f]=pe[g]=pe[v]=pe[w]=pe[P]=pe[E]=pe[_]=pe[T]=!1;var me=typeof en=="object"&&en&&en.Object===Object&&en,Xe=typeof self=="object"&&self&&self.Object===Object&&self,Ae=me||Xe||Function("return this")(),Ue=n&&!n.nodeType&&n,yt=Ue&&!0&&e&&!e.nodeType&&e,St=yt&&yt.exports===Ue,Le=St&&me.process,br=function(){try{return Le&&Le.binding&&Le.binding("util")}catch{}}(),Nn=br&&br.isTypedArray;function xt($,D){for(var V=-1,ee=$==null?0:$.length,qe=0,ye=[];++V<ee;){var ut=$[V];D(ut,V,$)&&(ye[qe++]=ut)}return ye}function pt($,D){for(var V=-1,ee=D.length,qe=$.length;++V<ee;)$[qe+V]=D[V];return $}function At($,D){for(var V=-1,ee=$==null?0:$.length;++V<ee;)if(D($[V],V,$))return!0;return!1}function vl($,D){for(var V=-1,ee=Array($);++V<$;)ee[V]=D(V);return ee}function wl($){return function(D){return $(D)}}function ug($,D){return $.has(D)}function Ui($,D){return $==null?void 0:$[D]}function cj($){var D=-1,V=Array($.size);return $.forEach(function(ee,qe){V[++D]=[qe,ee]}),V}function uj($,D){return function(V){return $(D(V))}}function dj($){var D=-1,V=Array($.size);return $.forEach(function(ee){V[++D]=ee}),V}var hj=Array.prototype,pj=Function.prototype,Uu=Object.prototype,dg=Ae["__core-js_shared__"],ax=pj.toString,Gr=Uu.hasOwnProperty,lx=function(){var $=/[^.]+$/.exec(dg&&dg.keys&&dg.keys.IE_PROTO||"");return $?"Symbol(src)_1."+$:""}(),cx=Uu.toString,fj=RegExp("^"+ax.call(Gr).replace(J,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ux=St?Ae.Buffer:void 0,Hu=Ae.Symbol,dx=Ae.Uint8Array,hx=Uu.propertyIsEnumerable,gj=hj.splice,qs=Hu?Hu.toStringTag:void 0,px=Object.getOwnPropertySymbols,mj=ux?ux.isBuffer:void 0,yj=uj(Object.keys,Object),hg=Hi(Ae,"DataView"),xl=Hi(Ae,"Map"),pg=Hi(Ae,"Promise"),fg=Hi(Ae,"Set"),gg=Hi(Ae,"WeakMap"),bl=Hi(Object,"create"),Sj=Js(hg),vj=Js(xl),wj=Js(pg),xj=Js(fg),bj=Js(gg),fx=Hu?Hu.prototype:void 0,mg=fx?fx.valueOf:void 0;function Zs($){var D=-1,V=$==null?0:$.length;for(this.clear();++D<V;){var ee=$[D];this.set(ee[0],ee[1])}}function Pj(){this.__data__=bl?bl(null):{},this.size=0}function Cj($){var D=this.has($)&&delete this.__data__[$];return this.size-=D?1:0,D}function Ij($){var D=this.__data__;if(bl){var V=D[$];return V===r?void 0:V}return Gr.call(D,$)?D[$]:void 0}function Ej($){var D=this.__data__;return bl?D[$]!==void 0:Gr.call(D,$)}function _j($,D){var V=this.__data__;return this.size+=this.has($)?0:1,V[$]=bl&&D===void 0?r:D,this}Zs.prototype.clear=Pj,Zs.prototype.delete=Cj,Zs.prototype.get=Ij,Zs.prototype.has=Ej,Zs.prototype.set=_j;function xo($){var D=-1,V=$==null?0:$.length;for(this.clear();++D<V;){var ee=$[D];this.set(ee[0],ee[1])}}function kj(){this.__data__=[],this.size=0}function Tj($){var D=this.__data__,V=Vu(D,$);if(V<0)return!1;var ee=D.length-1;return V==ee?D.pop():gj.call(D,V,1),--this.size,!0}function $j($){var D=this.__data__,V=Vu(D,$);return V<0?void 0:D[V][1]}function Mj($){return Vu(this.__data__,$)>-1}function Aj($,D){var V=this.__data__,ee=Vu(V,$);return ee<0?(++this.size,V.push([$,D])):V[ee][1]=D,this}xo.prototype.clear=kj,xo.prototype.delete=Tj,xo.prototype.get=$j,xo.prototype.has=Mj,xo.prototype.set=Aj;function Qs($){var D=-1,V=$==null?0:$.length;for(this.clear();++D<V;){var ee=$[D];this.set(ee[0],ee[1])}}function jj(){this.size=0,this.__data__={hash:new Zs,map:new(xl||xo),string:new Zs}}function Oj($){var D=Wu(this,$).delete($);return this.size-=D?1:0,D}function Dj($){return Wu(this,$).get($)}function Rj($){return Wu(this,$).has($)}function Lj($,D){var V=Wu(this,$),ee=V.size;return V.set($,D),this.size+=V.size==ee?0:1,this}Qs.prototype.clear=jj,Qs.prototype.delete=Oj,Qs.prototype.get=Dj,Qs.prototype.has=Rj,Qs.prototype.set=Lj;function Ku($){var D=-1,V=$==null?0:$.length;for(this.__data__=new Qs;++D<V;)this.add($[D])}function Nj($){return this.__data__.set($,r),this}function Fj($){return this.__data__.has($)}Ku.prototype.add=Ku.prototype.push=Nj,Ku.prototype.has=Fj;function ts($){var D=this.__data__=new xo($);this.size=D.size}function zj(){this.__data__=new xo,this.size=0}function Bj($){var D=this.__data__,V=D.delete($);return this.size=D.size,V}function Uj($){return this.__data__.get($)}function Hj($){return this.__data__.has($)}function Kj($,D){var V=this.__data__;if(V instanceof xo){var ee=V.__data__;if(!xl||ee.length<t-1)return ee.push([$,D]),this.size=++V.size,this;V=this.__data__=new Qs(ee)}return V.set($,D),this.size=V.size,this}ts.prototype.clear=zj,ts.prototype.delete=Bj,ts.prototype.get=Uj,ts.prototype.has=Hj,ts.prototype.set=Kj;function Vj($,D){var V=Gu($),ee=!V&&iO($),qe=!V&&!ee&&yg($),ye=!V&&!ee&&!qe&&Px($),ut=V||ee||qe||ye,Et=ut?vl($.length,String):[],jt=Et.length;for(var rt in $)(D||Gr.call($,rt))&&!(ut&&(rt=="length"||qe&&(rt=="offset"||rt=="parent")||ye&&(rt=="buffer"||rt=="byteLength"||rt=="byteOffset")||tO(rt,jt)))&&Et.push(rt);return Et}function Vu($,D){for(var V=$.length;V--;)if(vx($[V][0],D))return V;return-1}function Wj($,D,V){var ee=D($);return Gu($)?ee:pt(ee,V($))}function Pl($){return $==null?$===void 0?M:S:qs&&qs in Object($)?Jj($):sO($)}function gx($){return Cl($)&&Pl($)==a}function mx($,D,V,ee,qe){return $===D?!0:$==null||D==null||!Cl($)&&!Cl(D)?$!==$&&D!==D:Gj($,D,V,ee,mx,qe)}function Gj($,D,V,ee,qe,ye){var ut=Gu($),Et=Gu(D),jt=ut?l:ns($),rt=Et?l:ns(D);jt=jt==a?w:jt,rt=rt==a?w:rt;var Fn=jt==w,Pr=rt==w,Vt=jt==rt;if(Vt&&yg($)){if(!yg(D))return!1;ut=!0,Fn=!1}if(Vt&&!Fn)return ye||(ye=new ts),ut||Px($)?yx($,D,V,ee,qe,ye):Zj($,D,jt,V,ee,qe,ye);if(!(V&o)){var rr=Fn&&Gr.call($,"__wrapped__"),or=Pr&&Gr.call(D,"__wrapped__");if(rr||or){var rs=rr?$.value():$,bo=or?D.value():D;return ye||(ye=new ts),qe(rs,bo,V,ee,ye)}}return Vt?(ye||(ye=new ts),Qj($,D,V,ee,qe,ye)):!1}function Yj($){if(!bx($)||rO($))return!1;var D=wx($)?fj:ke;return D.test(Js($))}function Xj($){return Cl($)&&xx($.length)&&!!pe[Pl($)]}function qj($){if(!oO($))return yj($);var D=[];for(var V in Object($))Gr.call($,V)&&V!="constructor"&&D.push(V);return D}function yx($,D,V,ee,qe,ye){var ut=V&o,Et=$.length,jt=D.length;if(Et!=jt&&!(ut&&jt>Et))return!1;var rt=ye.get($);if(rt&&ye.get(D))return rt==D;var Fn=-1,Pr=!0,Vt=V&s?new Ku:void 0;for(ye.set($,D),ye.set(D,$);++Fn<Et;){var rr=$[Fn],or=D[Fn];if(ee)var rs=ut?ee(or,rr,Fn,D,$,ye):ee(rr,or,Fn,$,D,ye);if(rs!==void 0){if(rs)continue;Pr=!1;break}if(Vt){if(!At(D,function(bo,ei){if(!ug(Vt,ei)&&(rr===bo||qe(rr,bo,V,ee,ye)))return Vt.push(ei)})){Pr=!1;break}}else if(!(rr===or||qe(rr,or,V,ee,ye))){Pr=!1;break}}return ye.delete($),ye.delete(D),Pr}function Zj($,D,V,ee,qe,ye,ut){switch(V){case O:if($.byteLength!=D.byteLength||$.byteOffset!=D.byteOffset)return!1;$=$.buffer,D=D.buffer;case R:return!($.byteLength!=D.byteLength||!ye(new dx($),new dx(D)));case u:case d:case v:return vx(+$,+D);case h:return $.name==D.name&&$.message==D.message;case P:case _:return $==D+"";case g:var Et=cj;case E:var jt=ee&o;if(Et||(Et=dj),$.size!=D.size&&!jt)return!1;var rt=ut.get($);if(rt)return rt==D;ee|=s,ut.set($,D);var Fn=yx(Et($),Et(D),ee,qe,ye,ut);return ut.delete($),Fn;case k:if(mg)return mg.call($)==mg.call(D)}return!1}function Qj($,D,V,ee,qe,ye){var ut=V&o,Et=Sx($),jt=Et.length,rt=Sx(D),Fn=rt.length;if(jt!=Fn&&!ut)return!1;for(var Pr=jt;Pr--;){var Vt=Et[Pr];if(!(ut?Vt in D:Gr.call(D,Vt)))return!1}var rr=ye.get($);if(rr&&ye.get(D))return rr==D;var or=!0;ye.set($,D),ye.set(D,$);for(var rs=ut;++Pr<jt;){Vt=Et[Pr];var bo=$[Vt],ei=D[Vt];if(ee)var Cx=ut?ee(ei,bo,Vt,D,$,ye):ee(bo,ei,Vt,$,D,ye);if(!(Cx===void 0?bo===ei||qe(bo,ei,V,ee,ye):Cx)){or=!1;break}rs||(rs=Vt=="constructor")}if(or&&!rs){var Yu=$.constructor,Xu=D.constructor;Yu!=Xu&&"constructor"in $&&"constructor"in D&&!(typeof Yu=="function"&&Yu instanceof Yu&&typeof Xu=="function"&&Xu instanceof Xu)&&(or=!1)}return ye.delete($),ye.delete(D),or}function Sx($){return Wj($,cO,eO)}function Wu($,D){var V=$.__data__;return nO(D)?V[typeof D=="string"?"string":"hash"]:V.map}function Hi($,D){var V=Ui($,D);return Yj(V)?V:void 0}function Jj($){var D=Gr.call($,qs),V=$[qs];try{$[qs]=void 0;var ee=!0}catch{}var qe=cx.call($);return ee&&(D?$[qs]=V:delete $[qs]),qe}var eO=px?function($){return $==null?[]:($=Object($),xt(px($),function(D){return hx.call($,D)}))}:uO,ns=Pl;(hg&&ns(new hg(new ArrayBuffer(1)))!=O||xl&&ns(new xl)!=g||pg&&ns(pg.resolve())!=C||fg&&ns(new fg)!=E||gg&&ns(new gg)!=T)&&(ns=function($){var D=Pl($),V=D==w?$.constructor:void 0,ee=V?Js(V):"";if(ee)switch(ee){case Sj:return O;case vj:return g;case wj:return C;case xj:return E;case bj:return T}return D});function tO($,D){return D=D??i,!!D&&(typeof $=="number"||ve.test($))&&$>-1&&$%1==0&&$<D}function nO($){var D=typeof $;return D=="string"||D=="number"||D=="symbol"||D=="boolean"?$!=="__proto__":$===null}function rO($){return!!lx&&lx in $}function oO($){var D=$&&$.constructor,V=typeof D=="function"&&D.prototype||Uu;return $===V}function sO($){return cx.call($)}function Js($){if($!=null){try{return ax.call($)}catch{}try{return $+""}catch{}}return""}function vx($,D){return $===D||$!==$&&D!==D}var iO=gx(function(){return arguments}())?gx:function($){return Cl($)&&Gr.call($,"callee")&&!hx.call($,"callee")},Gu=Array.isArray;function aO($){return $!=null&&xx($.length)&&!wx($)}var yg=mj||dO;function lO($,D){return mx($,D)}function wx($){if(!bx($))return!1;var D=Pl($);return D==f||D==y||D==c||D==I}function xx($){return typeof $=="number"&&$>-1&&$%1==0&&$<=i}function bx($){var D=typeof $;return $!=null&&(D=="object"||D=="function")}function Cl($){return $!=null&&typeof $=="object"}var Px=Nn?wl(Nn):Xj;function cO($){return aO($)?Vj($):qj($)}function uO(){return[]}function dO(){return!1}e.exports=lO})(op,op.exports);var mD=op.exports;const yD=el(mD);function SD(e){if(e.length===0)return new Set;const n=e[0],t=e.slice(1),r=new Set;for(const o of n)t.every(s=>s.has(o))&&r.add(o);return r}function vD(e,n){const t={};for(const r of n)e.has(r)||(t.added??(t.added=new Set),t.added.add(r));for(const r of e)n.has(r)||(t.removed??(t.removed=new Set),t.removed.add(r));return t.added||t.removed?t:void 0}function Fx(e,n){for(const[t,r]of Object.entries(e)){const o=r,s=n[t];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 zx(e,n,t){const r=Object.fromEntries(Object.keys(t).map(o=>[o,new Set]));for(const[o,s]of Object.entries(t))if("eq"in s){const a=e.index(n,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(n,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(n,o);for(const[a,l]of i.get())if(a>s.gt)for(const c of l)r[o].add(c)}return SD(Object.values(r))}class wD{constructor(n,t){m(this,"indexCache",new Map);m(this,"historyCache",new Map);this.atoms=n,this.history=t}filterHistory(n){if(this.historyCache.has(n))return this.historyCache.get(n);const t=Z("filterHistory:"+n,(r,o)=>{if($a(r))return this.history.get();const s=this.history.getDiffSince(o);if(s===Xn)return this.history.get();const i={added:{},removed:{},updated:{}};let a=0,l=0,c=0;for(const u of s){for(const d of ot(u.added))if(d.typeName===n)if(i.removed[d.id]){const h=i.removed[d.id];delete i.removed[d.id],l--,h!==d&&(i.updated[d.id]=[h,d],c++)}else i.added[d.id]=d,a++;for(const[d,h]of ot(u.updated))h.typeName===n&&(i.added[h.id]?i.added[h.id]=h:i.updated[h.id]?i.updated[h.id]=[i.updated[h.id][0],h]:(i.updated[h.id]=[d,h],c++));for(const d of ot(u.removed))d.typeName===n&&(i.added[d.id]?(delete i.added[d.id],a--):i.updated[d.id]?(i.removed[d.id]=i.updated[d.id][0],delete i.updated[d.id],c--,l++):(i.removed[d.id]=d,l++))}return a||l||c?Xl(this.history.get(),i):r},{historyLength:100});return this.historyCache.set(n,t),t}index(n,t){const r=n+":"+t;if(this.indexCache.has(r))return this.indexCache.get(r);const o=this.__uncached_createIndex(n,t);return this.indexCache.set(r,o),o}__uncached_createIndex(n,t){const r=this.filterHistory(n),o=()=>{r.get();const s=new Map;for(const i of ot(this.atoms.get())){const a=i.get();if(a.typeName===n){const l=a[t];s.has(l)||s.set(l,new Set),s.get(l).add(a.id)}}return s};return Z("index:"+n+":"+t,(s,i)=>{if($a(s))return o();const a=r.getDiffSince(i);if(a===Xn)return o();const l=new Map,c=(f,y)=>{let g=l.get(f);g||(g=new nh(s.get(f)??new Set)),g.add(y),l.set(f,g)},u=(f,y)=>{let g=l.get(f);g||(g=new nh(s.get(f)??new Set)),g.remove(y),l.set(f,g)};for(const f of a){for(const y of ot(f.added))if(y.typeName===n){const g=y[t];c(g,y.id)}for(const[y,g]of ot(f.updated))if(g.typeName===n){const v=y[t],S=g[t];v!==S&&(u(v,g.id),c(S,g.id))}for(const y of ot(f.removed))if(y.typeName===n){const g=y[t];u(g,y.id)}}let d,h;for(const[f,y]of l){const g=y.get();g&&(d||(d=new Map(s)),h||(h=new Map),g.value.size===0?d.delete(f):d.set(f,g.value),h.set(f,g.diff))}return d&&h?Xl(d,h):s},{historyLength:100})}record(n,t=()=>({}),r="record:"+n+(t?":"+t.toString():"")){const o=this.ids(n,t,r);return Z(r,()=>{var s;for(const i of o.get())return(s=this.atoms.get()[i])==null?void 0:s.get()})}records(n,t=()=>({}),r="records:"+n+(t?":"+t.toString():"")){const o=this.ids(n,t,"ids:"+r);return Z(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(n,t=()=>({}),r="ids:"+n+(t?":"+t.toString():"")){const o=this.filterHistory(n),s=()=>{o.get();const l=t();return Object.keys(l).length===0?new Set(ot(this.atoms.get()).flatMap(c=>{const u=c.get();return u.typeName===n?u.id:[]})):zx(this,n,l)},i=l=>{const c=s(),u=vD(l,c);return u?Xl(c,u):l},a=Z("ids_query:"+r,t,{isEqual:yD});return Z("query:"+r,(l,c)=>{const u=a.get();if($a(l))return s();if(c<a.lastChangedEpoch)return i(l);const d=o.getDiffSince(c);if(d===Xn)return i(l);const h=new nh(l);for(const y of d){for(const g of ot(y.added))g.typeName===n&&Fx(u,g)&&h.add(g.id);for(const[g,v]of ot(y.updated))v.typeName===n&&(Fx(u,v)?h.add(v.id):h.remove(v.id));for(const g of ot(y.removed))g.typeName===n&&h.remove(g.id)}const f=h.get();return f?Xl(f.value,f.diff):l},{historyLength:50})}exec(n,t){const r=zx(this,n,t);if(r.size===0)return $s;const o=this.atoms.get();return[...r].map(s=>o[s].get())}}class OI{constructor(n){m(this,"id",cf());m(this,"atoms",hn("store_atoms",{}));m(this,"history",hn("history",0,{historyLength:1e3}));m(this,"query",new wD(this.atoms,this.history));m(this,"listeners",new Set);m(this,"historyAccumulator",new bD);m(this,"historyReactor");m(this,"schema");m(this,"props");m(this,"scopedTypes");m(this,"onBeforeCreate");m(this,"onAfterCreate");m(this,"onBeforeChange");m(this,"onAfterChange");m(this,"onBeforeDelete");m(this,"onAfterDelete");m(this,"_runCallbacks",!0);m(this,"put",(n,t)=>{Tr(()=>{const r={},o={},s=this.atoms.__unsafe__getWithoutCapture();let i=null,a,l=!1;const c=this.onBeforeCreate&&this._runCallbacks?this.onBeforeCreate:null,u=this.onBeforeChange&&this._runCallbacks?this.onBeforeChange:null,d=this.isMergingRemoteChanges?"remote":"user";for(let h=0,f=n.length;h<f;h++){a=n[h];const y=(i??s)[a.id];if(y){const g=y.__unsafe__getWithoutCapture();if(u&&(a=u(g,a,d)),this.schema.validateRecord(this,a,t??"updateRecord",g)===g)continue;y.set(a),l=!0,r[a.id]=[g,y.__unsafe__getWithoutCapture()]}else c&&(a=c(a,d)),l=!0,a=this.schema.validateRecord(this,a,t??"createRecord",null),o[a.id]=a,i||(i={...s}),i[a.id]=hn("atom:"+a.id,a)}if(i&&this.atoms.set(i),!!l&&(this.updateHistory({added:o,updated:r,removed:{}}),this._runCallbacks)){const{onAfterCreate:h,onAfterChange:f}=this;h&&Object.values(o).forEach(y=>{h(y,d)}),f&&Object.values(r).forEach(([y,g])=>{f(y,g,d)})}})});m(this,"remove",n=>{Tr(()=>{const t=[],r=this.isMergingRemoteChanges?"remote":"user";if(this.onBeforeDelete&&this._runCallbacks)for(const s of n){const i=this.atoms.__unsafe__getWithoutCapture()[s];i&&this.onBeforeDelete(i.get(),r)===!1&&t.push(s)}let o;if(this.atoms.update(s=>{let i;for(const a of n)t.includes(a)||a in s&&(i||(i={...s}),o||(o={}),delete i[a],o[a]=s[a].get());return i??s}),!!o&&(this.updateHistory({added:{},updated:{},removed:o}),this.onAfterDelete&&this._runCallbacks)){let s;for(let i=0,a=n.length;i<a;i++)s=o[n[i]],s&&this.onAfterDelete(s,r)}})});m(this,"get",n=>{var t;return(t=this.atoms.get()[n])==null?void 0:t.get()});m(this,"unsafeGetWithoutCapture",n=>{var t;return(t=this.atoms.get()[n])==null?void 0:t.__unsafe__getWithoutCapture()});m(this,"serialize",(n="document")=>{const t={};for(const[r,o]of oo(this.atoms.get())){const s=o.get();(n==="all"||this.scopedTypes[n].has(s.typeName))&&(t[r]=s)}return t});m(this,"allRecords",()=>ot(this.atoms.get()).map(n=>n.get()));m(this,"clear",()=>{this.remove(Dx(this.atoms.get()))});m(this,"update",(n,t)=>{const r=this.atoms.get()[n];if(!r){console.error(`Record ${n} not found. This is probably an error`);return}this.put([t(r.__unsafe__getWithoutCapture())])});m(this,"has",n=>!!this.atoms.get()[n]);m(this,"listen",(n,t)=>{this._flushHistory();const r={onHistory:n,filters:{source:(t==null?void 0:t.source)??"all",scope:(t==null?void 0:t.scope)??"all"}};return this.listeners.add(r),this.historyReactor.scheduler.isActivelyListening||this.historyReactor.start(),()=>{this.listeners.delete(r),this.listeners.size===0&&this.historyReactor.stop()}});m(this,"isMergingRemoteChanges",!1);m(this,"mergeRemoteChanges",n=>{if(this.isMergingRemoteChanges)return n();try{this.isMergingRemoteChanges=!0,Tr(n)}finally{this.isMergingRemoteChanges=!1}});m(this,"createComputedCache",(n,t,r)=>{const o=new Nx;return{get:s=>{const i=this.atoms.get()[s];if(i)return o.get(i,()=>{const a=r?Z(i.name+":equals",()=>i.get(),{isEqual:r}):i;return Z(n+":"+s,()=>t(a.get()))}).get()}}});m(this,"createSelectedComputedCache",(n,t,r)=>{const o=new Nx;return{get:s=>{const i=this.atoms.get()[s];if(!i)return;const a=Z(n+":"+s+":selector",()=>t(i.get()));return o.get(i,()=>Z(n+":"+s,()=>r(a.get()))).get()}}});m(this,"getRecordType",n=>{const t=this.schema.types[n.typeName];if(!t)throw new Error(`Record type ${n.typeName} not found`);return t});m(this,"_integrityChecker");m(this,"_isPossiblyCorrupted",!1);const{initialData:t,schema:r}=n;this.schema=r,this.props=n.props,t&&this.atoms.set(jv(oo(t).map(([o,s])=>[o,hn("atom:"+o,this.schema.validateRecord(this,s,"initialize",null))]))),this.historyReactor=BO("Store.historyReactor",()=>{this.history.get(),this._flushHistory()},{scheduleEffect:o=>cD(o)}),this.scopedTypes={document:new Set(ot(this.schema.types).filter(o=>o.scope==="document").map(o=>o.typeName)),session:new Set(ot(this.schema.types).filter(o=>o.scope==="session").map(o=>o.typeName)),presence:new Set(ot(this.schema.types).filter(o=>o.scope==="presence").map(o=>o.typeName))}}_flushHistory(){if(this.historyAccumulator.hasChanges()){const n=this.historyAccumulator.flush();for(const{changes:t,source:r}of n){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(t,"document")),!s)continue;a({changes:s,source:r})}else if(l.scope==="session"){if(o??(o=this.filterChangesByScope(t,"session")),!o)continue;a({changes:o,source:r})}else{if(i??(i=this.filterChangesByScope(t,"presence")),!i)continue;a({changes:i,source:r})}else a({changes:t,source:r})}}}filterChangesByScope(n,t){const r={added:vg(n.added,(o,s)=>this.scopedTypes[t].has(s.typeName)),updated:vg(n.updated,(o,s)=>this.scopedTypes[t].has(s[1].typeName)),removed:vg(n.removed,(o,s)=>this.scopedTypes[t].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(n){this.historyAccumulator.add({changes:n,source:this.isMergingRemoteChanges?"remote":"user"}),this.listeners.size===0&&this.historyAccumulator.clear(),this.history.set(this.history.get()+1,n)}validate(n){this.allRecords().forEach(t=>this.schema.validateRecord(this,t,n,null))}getSnapshot(n="document"){return{store:this.serialize(n),schema:this.schema.serialize()}}migrateSnapshot(n){const t=this.schema.migrateStoreSnapshot(n);if(t.type==="error")throw new Error(`Failed to migrate snapshot: ${t.reason}`);return{store:t.value,schema:this.schema.serialize()}}loadSnapshot(n){const t=this.schema.migrateStoreSnapshot(n);if(t.type==="error")throw new Error(`Failed to migrate snapshot: ${t.reason}`);Tr(()=>{this.clear(),this.put(Object.values(t.value)),this.ensureStoreIsUsable()})}extractingChanges(n){const t=[],r=this.historyAccumulator.intercepting(o=>t.push(o.changes));try{return Tr(n),uf(t)}finally{r()}}applyDiff(n,t=!0){const r=this._runCallbacks;try{this._runCallbacks=t,Tr(()=>{const o=ot(n.added).concat(ot(n.updated).map(([i,a])=>a)),s=Dx(n.removed);o.length&&this.put(o),s.length&&this.remove(s)})}finally{this._runCallbacks=r}}ensureStoreIsUsable(){var n;this._integrityChecker??(this._integrityChecker=this.schema.createIntegrityChecker(this)),(n=this._integrityChecker)==null||n.call(this)}markAsPossiblyCorrupted(){this._isPossiblyCorrupted=!0}isPossiblyCorrupted(){return this._isPossiblyCorrupted}}function uf(e){const n={added:{},removed:{},updated:{}};for(const t of e){for(const[r,o]of oo(t.added))if(n.removed[r]){const s=n.removed[r];delete n.removed[r],s!==o&&(n.updated[r]=[s,o])}else n.added[r]=o;for(const[r,[o,s]]of oo(t.updated)){if(n.added[r]){n.added[r]=s,delete n.updated[r],delete n.removed[r];continue}if(n.updated[r]){n.updated[r]=[n.updated[r][0],s],delete n.removed[r];continue}n.updated[r]=t.updated[r],delete n.removed[r]}for(const[r,o]of oo(t.removed))n.added[r]?delete n.added[r]:n.updated[r]?(n.removed[r]=n.updated[r][0],delete n.updated[r]):n.removed[r]=o}return n}function xD(e){const n=[];let t=e[0],r;for(let o=1,s=e.length;o<s;o++)r=e[o],t.source!==r.source?(n.push(t),t=r):t={source:t.source,changes:uf([t.changes,r.changes])};return n.push(t),n}class bD{constructor(){m(this,"_history",[]);m(this,"_interceptors",new Set)}intercepting(n){return this._interceptors.add(n),()=>{this._interceptors.delete(n)}}add(n){this._history.push(n);for(const t of this._interceptors)t(n)}flush(){const n=xD(this._history);return this._history=[],n}clear(){this._history=[]}hasChanges(){return this._history.length>0}}function PD(e){return typeof e=="object"&&e!==null&&"id"in e&&"typeName"in e}function Me(e){const{currentVersion:n,firstVersion:t,migrators:r={},subTypeKey:o,subTypeMigrations:s}=e;if(typeof n=="number"&&typeof t=="number"){if(n===t)throw Error("Current version is equal to initial version.");if(n<t)throw Error("Current version is lower than initial version.")}return{firstVersion:t??0,currentVersion:n??0,migrators:r,subTypeKey:o,subTypeMigrations:s}}var Zl=(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))(Zl||{});function Zu({record:e,migrations:n,fromVersion:t,toVersion:r}){let o=t;if(!PD(e))throw new Error("[migrateRecord] object is not a record");const{typeName:s,id:i,...a}=e;let l=a;for(;o<r;){const c=o+1,u=n.migrators[c];if(!u)return{type:"error",reason:"target-version-too-new"};l=u.up(l),o=c}for(;o>r;){const c=o-1,u=n.migrators[o];if(!u)return{type:"error",reason:"target-version-too-old"};l=u.down(l),o=c}return{type:"success",value:{...l,id:i,typeName:s}}}function Dv({value:e,migrations:n,fromVersion:t,toVersion:r}){let o=t;for(;o<r;){const s=o+1,i=n.migrators[s];if(!i)return{type:"error",reason:"target-version-too-new"};e=i.up(e),o=s}for(;o>r;){const s=o-1,i=n.migrators[o];if(!i)return{type:"error",reason:"target-version-too-old"};e=i.down(e),o=s}return{type:"success",value:e}}class Rv{constructor(n,t){this.types=n,this.options=t}static create(n,t){return new Rv(n,t??{})}get currentStoreVersion(){var n;return((n=this.options.snapshotMigrations)==null?void 0:n.currentVersion)??0}validateRecord(n,t,r,o){try{const s=hr(this.types,t.typeName);if(!s)throw new Error(`Missing definition for record type ${t.typeName}`);return s.validate(t,o??void 0)}catch(s){if(this.options.onValidationFailure)return this.options.onValidationFailure({store:n,record:t,phase:r,recordBefore:o,error:s});throw s}}migratePersistedRecord(n,t,r="up"){var d;const o=hr(this.types,n.typeName),s=t.recordVersions[n.typeName];if(!s||!o)return{type:"error",reason:Zl.UnknownType};const i=o.migrations.currentVersion,a=s.version;if(i!==a){const h=Zu(r==="up"?{record:n,migrations:o.migrations,fromVersion:a,toVersion:i}:{record:n,migrations:o.migrations,fromVersion:i,toVersion:a});if(h.type==="error")return h;n=h.value}if(!o.migrations.subTypeKey)return{type:"success",value:n};const l=(d=o.migrations.subTypeMigrations)==null?void 0:d[n[o.migrations.subTypeKey]],c="subTypeVersions"in s?s.subTypeVersions[n[o.migrations.subTypeKey]]:void 0;if(l===void 0)return{type:"error",reason:Zl.UnrecognizedSubtype};if(c===void 0)return{type:"error",reason:Zl.IncompatibleSubtype};const u=Zu(r==="up"?{record:n,migrations:l,fromVersion:c,toVersion:l.currentVersion}:{record:n,migrations:l,fromVersion:l.currentVersion,toVersion:c});return u.type==="error"?u:{type:"success",value:u.value}}migrateStoreSnapshot(n){let{store:t}=n;const r=this.options.snapshotMigrations;if(!r)return{type:"success",value:t};const o=r.currentVersion,s=n.schema.storeVersion??0;if(o<s)return{type:"error",reason:Zl.TargetVersionTooOld};if(o>s){const a=Dv({value:t,migrations:r,fromVersion:s,toVersion:o});if(a.type==="error")return a;t=a.value}const i=[];for(const a of ot(t)){const l=this.migratePersistedRecord(a,n.schema);if(l.type==="error")return l;l.value&&l.value!==a&&i.push(l.value)}if(i.length){t={...t};for(const a of i)t[a.id]=a}return{type:"success",value:t}}createIntegrityChecker(n){var t,r;return((r=(t=this.options).createIntegrityChecker)==null?void 0:r.call(t,n))??void 0}serialize(){var n;return{schemaVersion:1,storeVersion:((n=this.options.snapshotMigrations)==null?void 0:n.currentVersion)??0,recordVersions:Object.fromEntries(ot(this.types).map(t=>[t.typeName,t.migrations.subTypeKey&&t.migrations.subTypeMigrations?{version:t.migrations.currentVersion,subTypeKey:t.migrations.subTypeKey,subTypeVersions:t.migrations.subTypeMigrations?Object.fromEntries(Object.entries(t.migrations.subTypeMigrations).map(([r,o])=>[r,o.currentVersion])):void 0}:{version:t.migrations.currentVersion}]))}}serializeEarliestVersion(){var n;return{schemaVersion:1,storeVersion:((n=this.options.snapshotMigrations)==null?void 0:n.firstVersion)??0,recordVersions:Object.fromEntries(ot(this.types).map(t=>[t.typeName,t.migrations.subTypeKey&&t.migrations.subTypeMigrations?{version:t.migrations.firstVersion,subTypeKey:t.migrations.subTypeKey,subTypeVersions:t.migrations.subTypeMigrations?Object.fromEntries(Object.entries(t.migrations.subTypeMigrations).map(([r,o])=>[r,o.firstVersion])):void 0}:{version:t.migrations.firstVersion}]))}}}const CD=(e,n)=>{if(e.schemaVersion>n.schemaVersion)return 1;if(e.schemaVersion<n.schemaVersion)return-1;if(e.storeVersion>n.storeVersion)return 1;if(e.storeVersion<n.storeVersion)return-1;for(const t of Object.keys(e.recordVersions)){const r=e.recordVersions[t],o=n.recordVersions[t];if(r.version>o.version)return 1;if(r.version<o.version)return-1;if("subTypeVersions"in r&&!("subTypeVersions"in o))return 1;if(!("subTypeVersions"in r)&&"subTypeVersions"in o)return-1;if(!(!("subTypeVersions"in r)||!("subTypeVersions"in o)))for(const s of Object.keys(r.subTypeVersions)){const i=r.subTypeVersions[s],a=o.subTypeVersions[s];if(i>a)return 1;if(i<a)return-1}}return 0};function ID(e){if(!e.length)return null;let n="";for(const t of e)typeof t=="number"?n+=`.${t}`:t.startsWith("(")?n.endsWith(")")?n=`${n.slice(0,-1)}, ${t.slice(1)}`:n+=t:n+=`.${t}`;return n=n.replace(/id = [^,]+, /,"").replace(/id = [^)]+/,""),n.startsWith(".")?n.slice(1):n}class _e extends Error{constructor(t,r=[]){const o=ID(r),s=t.split(`
|
|
38
|
+
`).map((i,a)=>a===0?i:` ${i}`).join(`
|
|
39
|
+
`);super(r?`At ${o}: ${s}`:s);m(this,"name","ValidationError");this.rawMessage=t,this.path=r}}function Tn(e,n){try{return n()}catch(t){throw t instanceof _e?new _e(t.rawMessage,[e,...t.path]):new _e(t.toString(),[e])}}function As(e){if(e===null)return"null";if(Array.isArray(e))return"an array";const n=typeof e;switch(n){case"bigint":case"boolean":case"function":case"number":case"string":case"symbol":return`a ${n}`;case"object":return`an ${n}`;case"undefined":return"undefined";default:Ai(n)}}class gn{constructor(n,t){this.validationFn=n,this.validateUsingKnownGoodVersionFn=t}validate(n){return this.validationFn(n)}validateUsingKnownGoodVersion(n,t){return Object.is(n,t)?n:this.validateUsingKnownGoodVersionFn?this.validateUsingKnownGoodVersionFn(n,t):this.validate(t)}isValid(n){try{return this.validate(n),!0}catch{return!1}}nullable(){return $D(this)}optional(){return RI(this)}refine(n){return new gn(t=>n(this.validate(t)),(t,r)=>{const o=this.validateUsingKnownGoodVersion(t,r);return Object.is(t,o)?t:n(o)})}check(n,t){return typeof n=="string"?this.refine(r=>(Tn(`(check ${n})`,()=>t(r)),r)):this.refine(r=>(n(r),r))}}class ED extends gn{constructor(n){super(t=>{const r=Bx.validate(t);for(let o=0;o<r.length;o++)Tn(o,()=>n.validate(r[o]));return r},(t,r)=>{if(!n.validateUsingKnownGoodVersion)return this.validate(r);const o=Bx.validate(r);let s=t.length!==o.length;for(let i=0;i<o.length;i++){const a=o[i];if(i>=t.length){s=!0,Tn(i,()=>n.validate(a));continue}if(Object.is(t[i],a))continue;const l=Tn(i,()=>n.validateUsingKnownGoodVersion(t[i],a));Object.is(l,t[i])||(s=!0)}return s?r:t}),this.itemValidator=n}nonEmpty(){return this.check(n=>{if(n.length===0)throw new _e("Expected a non-empty array")})}lengthGreaterThan1(){return this.check(n=>{if(n.length<=1)throw new _e("Expected an array with length greater than 1")})}}class sp extends gn{constructor(n,t=!1){super(r=>{if(typeof r!="object"||r===null)throw new _e(`Expected object, got ${As(r)}`);for(const[o,s]of Object.entries(n))Tn(o,()=>{s.validate(hr(r,o))});if(!t){for(const o of Object.keys(r))if(!ro(n,o))throw new _e("Unexpected property",[o])}return r},(r,o)=>{if(typeof o!="object"||o===null)throw new _e(`Expected object, got ${As(o)}`);let s=!1;for(const[i,a]of Object.entries(n)){const l=hr(r,i),c=hr(o,i);if(Object.is(l,c))continue;const u=Tn(i,()=>{const d=a;return d.validateUsingKnownGoodVersion?d.validateUsingKnownGoodVersion(l,c):d.validate(c)});Object.is(u,l)||(s=!0)}if(!t){for(const i of Object.keys(o))if(!ro(n,i))throw new _e("Unexpected property",[i])}for(const i of Object.keys(r))if(!ro(o,i)){s=!0;break}return s?o:r}),this.config=n,this.shouldAllowUnknownProperties=t}allowUnknownProperties(){return new sp(this.config,!0)}extend(n){return new sp({...this.config,...n})}}class Lv extends gn{constructor(n,t,r){super(o=>{this.expectObject(o);const{matchingSchema:s,variant:i}=this.getMatchingSchemaAndVariant(o);return s===void 0?this.unknownValueValidation(o,i):Tn(`(${n} = ${i})`,()=>s.validate(o))},(o,s)=>{this.expectObject(s),this.expectObject(o);const{matchingSchema:i,variant:a}=this.getMatchingSchemaAndVariant(s);return i===void 0?this.unknownValueValidation(s,a):hr(o,n)!==hr(s,n)?Tn(`(${n} = ${a})`,()=>i.validate(s)):Tn(`(${n} = ${a})`,()=>i.validateUsingKnownGoodVersion?i.validateUsingKnownGoodVersion(o,s):i.validate(s))}),this.key=n,this.config=t,this.unknownValueValidation=r}expectObject(n){if(typeof n!="object"||n===null)throw new _e(`Expected an object, got ${As(n)}`,[])}getMatchingSchemaAndVariant(n){const t=hr(n,this.key);if(typeof t!="string")throw new _e(`Expected a string for key "${this.key}", got ${As(t)}`);return{matchingSchema:ro(this.config,t)?this.config[t]:void 0,variant:t}}validateUnknownVariants(n){return new Lv(this.key,this.config,n)}}class _D extends gn{constructor(n,t){super(r=>{if(typeof r!="object"||r===null)throw new _e(`Expected object, got ${As(r)}`);for(const[o,s]of Object.entries(r))Tn(o,()=>{n.validate(o),t.validate(s)});return r},(r,o)=>{if(typeof o!="object"||o===null)throw new _e(`Expected object, got ${As(o)}`);let s=!1;for(const[i,a]of Object.entries(o)){if(!ro(r,i)){s=!0,Tn(i,()=>{n.validate(i),t.validate(a)});continue}const l=hr(r,i),c=a;if(Object.is(l,c))continue;const u=Tn(i,()=>t.validateUsingKnownGoodVersion?t.validateUsingKnownGoodVersion(l,c):t.validate(c));Object.is(u,l)||(s=!0)}for(const i of Object.keys(r))if(!ro(o,i)){s=!0;break}return s?o:r}),this.keyValidator=n,this.valueValidator=t}}function Nv(e){return new gn(n=>{if(typeof n!==e)throw new _e(`Expected ${e}, got ${As(n)}`);return n})}const kD=new gn(e=>e),Se=Nv("string"),de=Nv("number").check(e=>{if(Number.isNaN(e))throw new _e("Expected a number, got NaN");if(!Number.isFinite(e))throw new _e(`Expected a finite number, got ${e}`)}),Fv=de.check(e=>{if(e<0)throw new _e(`Expected a positive number, got ${e}`)}),jn=de.check(e=>{if(e<=0)throw new _e(`Expected a non-zero positive number, got ${e}`)}),DI=de.check(e=>{if(!Number.isInteger(e))throw new _e(`Expected an integer, got ${e}`)}),Qu=DI.check(e=>{if(e<0)throw new _e(`Expected a positive integer, got ${e}`)}),TD=DI.check(e=>{if(e<=0)throw new _e(`Expected a non-zero positive integer, got ${e}`)}),xe=Nv("boolean");function On(e){return new gn(n=>{if(n!==e)throw new _e(`Expected ${e}, got ${JSON.stringify(n)}`);return e})}const Bx=new gn(e=>{if(!Array.isArray(e))throw new _e(`Expected an array, got ${As(e)}`);return e});function zt(e){return new ED(e)}function be(e){return new sp(e)}function Ay(e){return typeof e=="object"&&e!==null&&(e.constructor===Object||!e.constructor)}function jy(e){return e===null||typeof e=="number"||typeof e=="string"||typeof e=="boolean"?!0:Array.isArray(e)?e.every(jy):Ay(e)?Object.values(e).every(jy):!1}const dn=new gn(e=>{if(jy(e))return e;throw new _e(`Expected json serializable value, got ${typeof e}`)},(e,n)=>{if(Array.isArray(e)&&Array.isArray(n)){let t=e.length!==n.length;for(let r=0;r<n.length;r++){if(r>=e.length){t=!0,dn.validate(n[r]);continue}const o=e[r],s=n[r];if(Object.is(o,s))continue;const i=dn.validateUsingKnownGoodVersion(o,s);Object.is(i,o)||(t=!0)}return t?n:e}else if(Ay(e)&&Ay(n)){let t=!1;for(const r of Object.keys(n)){if(!ro(e,r)){t=!0,dn.validate(n[r]);continue}const o=e[r],s=n[r];if(Object.is(o,s))continue;const i=dn.validateUsingKnownGoodVersion(o,s);Object.is(i,o)||(t=!0)}for(const r of Object.keys(e))if(!ro(n,r)){t=!0;break}return t?n:e}else return dn.validate(n)});function Oy(e,n){return new _D(e,n)}function zv(e,n){return new Lv(e,n,(t,r)=>{throw new _e(`Expected one of ${Object.keys(n).map(o=>JSON.stringify(o)).join(" or ")}, got ${JSON.stringify(r)}`,[e])})}function Xo(e,n){return new gn(t=>Tn(e,()=>n.validate(t)),(t,r)=>Tn(e,()=>n.validateUsingKnownGoodVersion?n.validateUsingKnownGoodVersion(t,r):n.validate(r)))}function df(e){return new gn(n=>{if(!e.has(n)){const t=Array.from(e,r=>JSON.stringify(r)).join(" or ");throw new _e(`Expected ${t}, got ${n}`)}return n})}function RI(e){return new gn(n=>{if(n!==void 0)return e.validate(n)},(n,t)=>{if(!(n===void 0&&t===void 0)&&t!==void 0)return e.validateUsingKnownGoodVersion&&n!==void 0?e.validateUsingKnownGoodVersion(n,t):e.validate(t)})}function $D(e){return new gn(n=>n===null?null:e.validate(n),(n,t)=>t===null?null:e.validateUsingKnownGoodVersion&&n!==null?e.validateUsingKnownGoodVersion(n,t):e.validate(t))}function LI(...e){return df(new Set(e))}function NI(e){try{return new URL(e)}catch{if(e.startsWith("/")||e.startsWith("./"))try{return new URL(e,"http://example.com")}catch{throw new _e(`Expected a valid url, got ${JSON.stringify(e)}`)}throw new _e(`Expected a valid url, got ${JSON.stringify(e)}`)}}const MD=new Set(["http:","https:","mailto:"]),Qn=Se.check(e=>{if(e==="")return;const n=NI(e);if(!MD.has(n.protocol.toLowerCase()))throw new _e(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)}),AD=new Set(["http:","https:","data:"]),rl=Se.check(e=>{if(e==="")return;const n=NI(e);if(!AD.has(n.protocol.toLowerCase()))throw new _e(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)}),Bv=Se.refine(e=>{try{return hD(e),e}catch{throw new _e(`Expected an index key, got ${JSON.stringify(e)}`)}});function fr(e){return Se.refine(n=>{if(!n.startsWith(`${e}:`))throw new Error(`${e} ID must start with "${e}:"`);return n})}const hf=fr("asset");function Uv(e,n){return be({id:hf,typeName:On("asset"),type:On(e),props:n,meta:dn})}const jD=Xo("camera",be({typeName:On("camera"),id:fr("camera"),x:de,y:de,z:de,meta:dn})),Ux={AddMeta:1},OD=Me({currentVersion:Ux.AddMeta,migrators:{[Ux.AddMeta]:{up:e=>({...e,meta:{}}),down:({meta:e,...n})=>({...n})}}}),qt=Yo("camera",{validator:jD,migrations:OD,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,z:1,meta:{}})),Cc=be({x:de,y:de,z:de.optional()}),sc=be({x:de,y:de,w:de,h:de}),DD=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"]),FI=df(DD),RD=be({type:FI,rotation:de}),zI=de.check(e=>{if(e<0||e>1)throw new _e("Opacity must be between 0 and 1")}),LD=new Set(["accent","white","black","selection-stroke","selection-fill","laser","muted-1"]),ND=df(LD),FD=new Set(["starting","paused","active","stopping"]),BI=be({id:Se,points:zt(Cc),size:Fv,color:ND,opacity:de,state:df(FD),delay:de,shrink:de,taper:xe}),Ic=fr("page"),zD=Xo("page",be({typeName:On("page"),id:Ic,name:Se,index:Bv,meta:dn})),Hx={AddMeta:1},BD=Me({currentVersion:Hx.AddMeta,migrators:{[Hx.AddMeta]:{up:e=>({...e,meta:{}}),down:({meta:e,...n})=>({...n})}}}),zo=Yo("page",{validator:zD,migrations:BD,scope:"document"}).withDefaultProperties(()=>({meta:{}}));function wn(e){return zo.isId(e)}fr("instance");function UD(e){const n={};for(const[r,o]of e)n[r]=RI(o);const t=Xo("instance",be({typeName:On("instance"),id:fr("instance"),currentPageId:Ic,followingUserId:Se.nullable(),brush:sc.nullable(),opacityForNextShape:zI,stylesForNextShape:be(n),cursor:RD,scribbles:zt(BI),isFocusMode:xe,isDebugMode:xe,isToolLocked:xe,exportBackground:xe,screenBounds:sc,insets:zt(xe),zoomBrush:sc.nullable(),isPenMode:xe,isGridMode:xe,chatMessage:Se,isChatting:xe,highlightedUserIds:zt(Se),canMoveCamera:xe,isFocused:xe,devicePixelRatio:de,isCoarsePointer:xe,isHoveringCanvas:xe.nullable(),openMenus:zt(Se),isChangingStyle:xe,isReadonly:xe,meta:dn,duplicateProps:be({shapeIds:zt(fr("shape")),offset:be({x:de,y:de})}).nullable()}));return Yo("instance",{migrations:HD,validator:t,scope:"session"}).withDefaultProperties(()=>({followingUserId:null,opacityForNextShape:1,stylesForNextShape:{},brush:null,scribbles:[],cursor:{type:"default",rotation:0},isFocusMode:!1,exportBackground:!1,isDebugMode:!1,isToolLocked:!1,screenBounds:{x:0,y:0,w:1080,h:720},insets:[!1,!1,!1,!1],zoomBrush:null,isGridMode:!1,isPenMode:!1,chatMessage:"",isChatting:!1,highlightedUserIds:[],canMoveCamera:!0,isFocused:!1,devicePixelRatio:typeof window>"u"?1:window.devicePixelRatio,isCoarsePointer:!1,isHoveringCanvas:null,openMenus:[],isChangingStyle:!1,isReadonly:!1,meta:{},duplicateProps:null}))}const Ze={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},HD=Me({currentVersion:Ze.AddDuplicateProps,migrators:{[Ze.AddTransparentExportBgs]:{up:e=>({...e,exportBackground:!0}),down:({exportBackground:e,...n})=>n},[Ze.RemoveDialog]:{up:({dialog:e,...n})=>n,down:e=>({...e,dialog:null})},[Ze.AddToolLockMode]:{up:e=>({...e,isToolLocked:!1}),down:({isToolLocked:e,...n})=>n},[Ze.RemoveExtraPropsForNextShape]:{up:({propsForNextShape:e,...n})=>({...n,propsForNextShape:Object.fromEntries(Object.entries(e).filter(([t])=>["color","labelColor","dash","fill","size","font","align","verticalAlign","icon","geo","arrowheadStart","arrowheadEnd","spline"].includes(t)))}),down:e=>e},[Ze.AddLabelColor]:{up:({propsForNextShape:e,...n})=>({...n,propsForNextShape:{...e,labelColor:"black"}}),down:e=>{const{labelColor:n,...t}=e.propsForNextShape;return{...e,propsForNextShape:{...t}}}},[Ze.AddFollowingUserId]:{up:e=>({...e,followingUserId:null}),down:({followingUserId:e,...n})=>n},[Ze.RemoveAlignJustify]:{up:e=>{let n=e.propsForNextShape.align;return n==="justify"&&(n="start"),{...e,propsForNextShape:{...e.propsForNextShape,align:n}}},down:e=>({...e})},[Ze.AddZoom]:{up:e=>({...e,zoomBrush:null}),down:({zoomBrush:e,...n})=>n},[Ze.AddVerticalAlign]:{up:e=>({...e,propsForNextShape:{...e.propsForNextShape,verticalAlign:"middle"}}),down:e=>{const{verticalAlign:n,...t}=e.propsForNextShape;return{...e,propsForNextShape:t}}},[Ze.AddScribbleDelay]:{up:e=>e.scribble!==null?{...e,scribble:{...e.scribble,delay:0}}:{...e},down:e=>{if(e.scribble!==null){const{delay:n,...t}=e.scribble;return{...e,scribble:t}}return{...e}}},[Ze.RemoveUserId]:{up:({userId:e,...n})=>n,down:e=>({...e,userId:"user:none"})},[Ze.AddIsPenModeAndIsGridMode]:{up:e=>({...e,isPenMode:!1,isGridMode:!1}),down:({isPenMode:e,isGridMode:n,...t})=>t},[Ze.HoistOpacity]:{up:({propsForNextShape:{opacity:e,...n},...t})=>({...t,opacityForNextShape:Number(e??"1"),propsForNextShape:n}),down:({opacityForNextShape:e,...n})=>({...n,propsForNextShape:{...n.propsForNextShape,opacity:e<.175?"0.1":e<.375?"0.25":e<.625?"0.5":e<.875?"0.75":"1"}})},[Ze.AddChat]:{up:e=>({...e,chatMessage:"",isChatting:!1}),down:({chatMessage:e,isChatting:n,...t})=>t},[Ze.AddHighlightedUserIds]:{up:e=>({...e,highlightedUserIds:[]}),down:({highlightedUserIds:e,...n})=>n},[Ze.ReplacePropsForNextShapeWithStylesForNextShape]:{up:({propsForNextShape:e,...n})=>({...n,stylesForNextShape:{}}),down:({stylesForNextShape:e,...n})=>({...n,propsForNextShape:{color:"black",labelColor:"black",dash:"draw",fill:"none",size:"m",icon:"file",font:"draw",align:"middle",verticalAlign:"middle",geo:"rectangle",arrowheadStart:"none",arrowheadEnd:"arrow",spline:"line"}})},[Ze.AddMeta]:{up:e=>({...e,meta:{}}),down:({meta:e,...n})=>({...n})},[Ze.RemoveCursorColor]:{up:e=>{const{color:n,...t}=e.cursor;return{...e,cursor:t}},down:e=>({...e,cursor:{...e.cursor,color:"black"}})},[Ze.AddLonelyProperties]:{up:e=>({...e,canMoveCamera:!0,isFocused:!1,devicePixelRatio:1,isCoarsePointer:!1,openMenus:[],isChangingStyle:!1,isReadOnly:!1}),down:({canMoveCamera:e,isFocused:n,devicePixelRatio:t,isCoarsePointer:r,openMenus:o,isChangingStyle:s,isReadOnly:i,...a})=>({...a})},[Ze.ReadOnlyReadonly]:{up:({isReadOnly:e,...n})=>({...n,isReadonly:e}),down:({isReadonly:e,...n})=>({...n,isReadOnly:e})},[Ze.AddHoveringCanvas]:{up:e=>({...e,isHoveringCanvas:null}),down:({isHoveringCanvas:e,...n})=>({...n})},[Ze.AddScribbles]:{up:({scribble:e,...n})=>({...n,scribbles:[]}),down:({scribbles:e,...n})=>({...n,scribble:null})},[Ze.AddInset]:{up:e=>({...e,insets:[!1,!1,!1,!1]}),down:({insets:e,...n})=>({...n})},[Ze.AddDuplicateProps]:{up:e=>({...e,duplicateProps:null}),down:({duplicateProps:e,...n})=>({...n})}}}),Lt="instance:instance",KD=Se.refine(e=>{if(!e.startsWith("page:")&&!e.startsWith("shape:"))throw new Error('Parent ID must start with "page:" or "shape:"');return e}),Er=fr("shape");function VD(e,n,t){return be({id:Er,typeName:On("shape"),x:de,y:de,rotation:de,index:Bv,parentId:KD,type:On(e),isLocked:xe,opacity:zI,props:n?be(n):dn,meta:t?be(t):dn})}const WD=Xo("instance_page_state",be({typeName:On("instance_page_state"),id:fr("instance_page_state"),pageId:Ic,selectedShapeIds:zt(Er),hintingShapeIds:zt(Er),erasingShapeIds:zt(Er),hoveredShapeId:Er.nullable(),editingShapeId:Er.nullable(),croppingShapeId:Er.nullable(),focusedGroupId:Er.nullable(),meta:dn})),Vi={AddCroppingId:1,RemoveInstanceIdAndCameraId:2,AddMeta:3,RenameProperties:4,RenamePropertiesAgain:5},GD=Me({currentVersion:Vi.RenamePropertiesAgain,migrators:{[Vi.AddCroppingId]:{up(e){return{...e,croppingShapeId:null}},down({croppingShapeId:e,...n}){return n}},[Vi.RemoveInstanceIdAndCameraId]:{up({instanceId:e,cameraId:n,...t}){return t},down(e){return{...e,instanceId:Lt,cameraId:qt.createId("void")}}},[Vi.AddMeta]:{up:e=>({...e,meta:{}}),down:({meta:e,...n})=>({...n})},[Vi.RenameProperties]:{up:e=>{const{selectedShapeIds:n,hintingShapeIds:t,erasingShapeIds:r,hoveredShapeId:o,editingShapeId:s,croppingShapeId:i,focusedGroupId:a,...l}=e;return{selectedShapeIds:n,hintingShapeIds:t,erasingShapeIds:r,hoveredShapeId:o,editingShapeId:s,croppingShapeId:i,focusedGroupId:a,...l}},down:e=>{const{selectedShapeIds:n,hintingShapeIds:t,erasingShapeIds:r,hoveredShapeId:o,editingShapeId:s,croppingShapeId:i,focusedGroupId:a,...l}=e;return{selectedShapeIds:n,hintingShapeIds:t,erasingShapeIds:r,hoveredShapeId:o,editingShapeId:s,croppingShapeId:i,focusedGroupId:a,...l}}},[Vi.RenamePropertiesAgain]:{up:e=>{const{selectedIds:n,hintingIds:t,erasingIds:r,hoveredId:o,editingId:s,croppingShapeId:i,croppingId:a,focusLayerId:l,...c}=e;return{...c,selectedShapeIds:n,hintingShapeIds:t,erasingShapeIds:r,hoveredShapeId:o,editingShapeId:s,croppingShapeId:i??a??null,focusedGroupId:l}},down:e=>{const{selectedShapeIds:n,hintingShapeIds:t,erasingShapeIds:r,hoveredShapeId:o,editingShapeId:s,croppingShapeId:i,focusedGroupId:a,...l}=e;return{...l,selectedIds:n,hintingIds:t,erasingIds:r,hoveredId:o,editingId:s,croppingId:i,focusLayerId:a}}}}}),Zt=Yo("instance_page_state",{migrations:GD,validator:WD,scope:"session"}).withDefaultProperties(()=>({editingShapeId:null,croppingShapeId:null,selectedShapeIds:[],hoveredShapeId:null,erasingShapeIds:[],hintingShapeIds:[],focusedGroupId:null,meta:{}})),YD=Xo("pointer",be({typeName:On("pointer"),id:fr("pointer"),x:de,y:de,lastActivityTimestamp:de,meta:dn})),Kx={AddMeta:1},XD=Me({currentVersion:Kx.AddMeta,migrators:{[Kx.AddMeta]:{up:e=>({...e,meta:{}}),down:({meta:e,...n})=>({...n})}}}),Hv=Yo("pointer",{validator:YD,migrations:XD,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,lastActivityTimestamp:0,meta:{}})),ip=Hv.createId("pointer"),qD=Xo("instance_presence",be({typeName:On("instance_presence"),id:fr("instance_presence"),userId:Se,userName:Se,lastActivityTimestamp:de,followingUserId:Se.nullable(),cursor:be({x:de,y:de,type:FI,rotation:de}),color:Se,camera:be({x:de,y:de,z:de}),screenBounds:sc,selectedShapeIds:zt(fr("shape")),currentPageId:fr("page"),brush:sc.nullable(),scribbles:zt(BI),chatMessage:Se,meta:dn})),Wi={AddScribbleDelay:1,RemoveInstanceId:2,AddChatMessage:3,AddMeta:4,RenameSelectedShapeIds:5},ZD=Me({currentVersion:Wi.RenameSelectedShapeIds,migrators:{[Wi.AddScribbleDelay]:{up:e=>e.scribble!==null?{...e,scribble:{...e.scribble,delay:0}}:{...e},down:e=>{if(e.scribble!==null){const{delay:n,...t}=e.scribble;return{...e,scribble:t}}return{...e}}},[Wi.RemoveInstanceId]:{up:({instanceId:e,...n})=>n,down:e=>({...e,instanceId:Lt})},[Wi.AddChatMessage]:{up:e=>({...e,chatMessage:""}),down:({chatMessage:e,...n})=>n},[Wi.AddMeta]:{up:e=>({...e,meta:{}}),down:({meta:e,...n})=>({...n})},[Wi.RenameSelectedShapeIds]:{up:e=>{const{selectedShapeIds:n,...t}=e;return{selectedShapeIds:n,...t}},down:e=>{const{selectedShapeIds:n,...t}=e;return{selectedShapeIds:n,...t}}}}}),QD=Yo("instance_presence",{migrations:ZD,validator:qD,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:{}})),JD=Xo("document",be({typeName:On("document"),id:On("document:document"),gridSize:de,name:Se,meta:dn})),bg={AddName:1,AddMeta:2},eR=Me({currentVersion:bg.AddMeta,migrators:{[bg.AddName]:{up:e=>({...e,name:""}),down:({name:e,...n})=>n},[bg.AddMeta]:{up:e=>({...e,meta:{}}),down:({meta:e,...n})=>({...n})}}}),Kv=Yo("document",{migrations:eR,validator:JD,scope:"document"}).withDefaultProperties(()=>({gridSize:10,name:"",meta:{}})),Dy=Kv.createId("document");function tR(e,n){return e.index<n.index?-1:e.index>n.index?1:0}function Vx(e){e.typeName==="asset"&&("src"in e&&(e.src="<redacted>"),"src"in e.props&&(e.props.src="<redacted>"))}const nR=({error:e,phase:n,record:t,recordBefore:r})=>{throw Av(e,{tags:{origin:"store.validateRecord",storePhase:n,isExistingValidationIssue:n==="initialize"},extras:{recordBefore:r?Vx(Dr(r)):void 0,recordAfter:Vx(Dr(t))}}),e};function rR(){return[zo.create({id:"page:page",name:"Page 1",index:"a1",meta:{}})]}function oR(e){const n=e.query.ids("page"),t=()=>{if(!e.has(Dy))return e.put([Kv.create({id:Dy,name:e.props.defaultName})]),t();if(!e.has(ip))return e.put([Hv.create({id:ip})]),t();const r=n.get();if(r.size===0)return e.put(rR()),t();const o=()=>[...r].map(l=>e.get(l)).sort(tR)[0].id,s=e.get(Lt);if(s){if(!r.has(s.currentPageId))return e.put([{...s,currentPageId:o()}]),t()}else return e.put([e.schema.types.instance.create({id:Lt,currentPageId:o(),exportBackground:!0})]),t();const i=new Set,a=new Set;for(const l of r){const c=Zt.createId(l);e.has(c)||i.add(c);const u=qt.createId(l);e.has(u)||a.add(u)}i.size>0&&e.put([...i].map(l=>Zt.create({id:l,pageId:Zt.parseId(l)}))),a.size>0&&e.put([...a].map(l=>qt.create({id:l})))};return t}const sR=Uv("bookmark",be({title:Se,description:Se,image:Se,src:rl.nullable()})),Wx={MakeUrlsValid:1},iR=Me({currentVersion:Wx.MakeUrlsValid,migrators:{[Wx.MakeUrlsValid]:{up:e=>{const n=e.props.src;return n&&!rl.isValid(n)?{...e,props:{...e.props,src:""}}:e},down:e=>e}}}),aR=Uv("image",be({w:de,h:de,name:Se,isAnimated:xe,mimeType:Se.nullable(),src:rl.nullable()})),Ju={AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3},lR=Me({currentVersion:Ju.MakeUrlsValid,migrators:{[Ju.AddIsAnimated]:{up:e=>({...e,props:{...e.props,isAnimated:!1}}),down:e=>{const{isAnimated:n,...t}=e.props;return{...e,props:t}}},[Ju.RenameWidthHeight]:{up:e=>{const{width:n,height:t,...r}=e.props;return{...e,props:{w:n,h:t,...r}}},down:e=>{const{w:n,h:t,...r}=e.props;return{...e,props:{width:n,height:t,...r}}}},[Ju.MakeUrlsValid]:{up:e=>{const n=e.props.src;return n&&!rl.isValid(n)?{...e,props:{...e.props,src:""}}:e},down:e=>e}}}),cR=Uv("video",be({w:de,h:de,name:Se,isAnimated:xe,mimeType:Se.nullable(),src:rl.nullable()})),ed={AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3},uR=Me({currentVersion:ed.MakeUrlsValid,migrators:{[ed.AddIsAnimated]:{up:e=>({...e,props:{...e.props,isAnimated:!1}}),down:e=>{const{isAnimated:n,...t}=e.props;return{...e,props:t}}},[ed.RenameWidthHeight]:{up:e=>{const{width:n,height:t,...r}=e.props;return{...e,props:{w:n,h:t,...r}}},down:e=>{const{w:n,h:t,...r}=e.props;return{...e,props:{width:n,height:t,...r}}}},[ed.MakeUrlsValid]:{up:e=>{const n=e.props.src;return n&&!rl.isValid(n)?{...e,props:{...e.props,src:""}}:e},down:e=>e}}}),dR=Xo("asset",zv("type",{image:aR,video:cR,bookmark:sR})),Gx={AddMeta:1},hR=Me({subTypeKey:"type",subTypeMigrations:{image:lR,video:uR,bookmark:iR},currentVersion:Gx.AddMeta,migrators:{[Gx.AddMeta]:{up:e=>({...e,meta:{}}),down:({meta:e,...n})=>({...n})}}}),li=Yo("asset",{migrations:hR,validator:dR,scope:"document"}).withDefaultProperties(()=>({meta:{}}));class sn{constructor(n,t,r){this.id=n,this.defaultValue=t,this.type=r}static define(n,t){const{defaultValue:r,type:o=kD}=t;return new sn(n,r,o)}static defineEnum(n,t){const{defaultValue:r,values:o}=t;return new pR(n,r,o)}validate(n){return this.type.validate(n)}validateUsingKnownGoodVersion(n,t){return this.type.validateUsingKnownGoodVersion?this.type.validateUsingKnownGoodVersion(n,t):this.validate(t)}}class pR extends sn{constructor(n,t,r){super(n,t,LI(...r)),this.values=r}}const td={AddIsLocked:1,HoistOpacity:2,AddMeta:3},Pg=Me({currentVersion:td.AddMeta,migrators:{[td.AddIsLocked]:{up:e=>({...e,isLocked:!1}),down:e=>{const{isLocked:n,...t}=e;return{...t}}},[td.HoistOpacity]:{up:({props:{opacity:e,...n},...t})=>({...t,opacity:Number(e??"1"),props:n}),down:({opacity:e,...n})=>({...n,props:{...n.props,opacity:e<.175?"0.1":e<.375?"0.25":e<.625?"0.5":e<.875?"0.75":"1"}})},[td.AddMeta]:{up:e=>({...e,meta:{}}),down:({meta:e,...n})=>({...n})}}});function ci(e){return e?e.typeName==="shape":!1}function Hn(e){return e?e.startsWith("shape:"):!1}function We(e){return`shape:${e??cf()}`}function UI(e){const n=new Map;for(const[t,r]of Object.entries(e))if(r instanceof sn){if(n.has(r))throw new Error(`Duplicate style prop ${r.id}. Each style prop can only be used once within a shape.`);n.set(r,t)}return n}function fR(e){return Yo("shape",{migrations:Me({currentVersion:Pg.currentVersion,firstVersion:Pg.firstVersion,migrators:Pg.migrators,subTypeKey:"type",subTypeMigrations:np(e,(n,t)=>t.migrations??Me({}))}),scope:"document",validator:Xo("shape",zv("type",np(e,(n,{props:t,meta:r})=>VD(n,t,r))))}).withDefaultProperties(()=>({x:0,y:0,rotation:0,isLocked:!1,opacity:1,meta:{}}))}const HI=["black","grey","light-violet","violet","blue","light-blue","yellow","orange","green","light-green","light-red","red"],ap={lightMode:{id:"light",text:"#000000",background:"rgb(249, 250, 251)",solid:"#fcfffe",black:{solid:"#1d1d1d",semi:"#e8e8e8",pattern:"#494949",highlight:{srgb:"#fddd00",p3:"color(display-p3 0.972 0.8705 0.05)"}},blue:{solid:"#4263eb",semi:"#dce1f8",pattern:"#6681ee",highlight:{srgb:"#10acff",p3:"color(display-p3 0.308 0.6632 0.9996)"}},green:{solid:"#099268",semi:"#d3e9e3",pattern:"#39a785",highlight:{srgb:"#00ffc8",p3:"color(display-p3 0.2536 0.984 0.7981)"}},grey:{solid:"#adb5bd",semi:"#eceef0",pattern:"#bcc3c9",highlight:{srgb:"#cbe7f1",p3:"color(display-p3 0.8163 0.9023 0.9416)"}},"light-blue":{solid:"#4dabf7",semi:"#ddedfa",pattern:"#6fbbf8",highlight:{srgb:"#00f4ff",p3:"color(display-p3 0.1512 0.9414 0.9996)"}},"light-green":{solid:"#40c057",semi:"#dbf0e0",pattern:"#65cb78",highlight:{srgb:"#65f641",p3:"color(display-p3 0.563 0.9495 0.3857)"}},"light-red":{solid:"#ff8787",semi:"#f4dadb",pattern:"#fe9e9e",highlight:{srgb:"#ff7fa3",p3:"color(display-p3 0.9988 0.5301 0.6397)"}},"light-violet":{solid:"#e599f7",semi:"#f5eafa",pattern:"#e9acf8",highlight:{srgb:"#ff88ff",p3:"color(display-p3 0.9676 0.5652 0.9999)"}},orange:{solid:"#f76707",semi:"#f8e2d4",pattern:"#f78438",highlight:{srgb:"#ffa500",p3:"color(display-p3 0.9988 0.6905 0.266)"}},red:{solid:"#e03131",semi:"#f4dadb",pattern:"#e55959",highlight:{srgb:"#ff636e",p3:"color(display-p3 0.9992 0.4376 0.45)"}},violet:{solid:"#ae3ec9",semi:"#ecdcf2",pattern:"#bd63d3",highlight:{srgb:"#c77cff",p3:"color(display-p3 0.7469 0.5089 0.9995)"}},yellow:{solid:"#ffc078",semi:"#f9f0e6",pattern:"#fecb92",highlight:{srgb:"#fddd00",p3:"color(display-p3 0.972 0.8705 0.05)"}}},darkMode:{id:"dark",text:"hsl(210, 17%, 98%)",background:"hsl(240, 5%, 8%)",solid:"#010403",black:{solid:"#e1e1e1",semi:"#2c3036",pattern:"#989898",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.7225 0.0312)"}},blue:{solid:"#4263eb",semi:"#262d40",pattern:"#3a4b9e",highlight:{srgb:"#0079d2",p3:"color(display-p3 0.0032 0.4655 0.7991)"}},green:{solid:"#099268",semi:"#253231",pattern:"#366a53",highlight:{srgb:"#009774",p3:"color(display-p3 0.0085 0.582 0.4604)"}},grey:{solid:"#9398b0",semi:"#33373c",pattern:"#7c8187",highlight:{srgb:"#9cb4cb",p3:"color(display-p3 0.6299 0.7012 0.7856)"}},"light-blue":{solid:"#4dabf7",semi:"#2a3642",pattern:"#4d7aa9",highlight:{srgb:"#00bdc8",p3:"color(display-p3 0.0023 0.7259 0.7735)"}},"light-green":{solid:"#40c057",semi:"#2a3830",pattern:"#4e874e",highlight:{srgb:"#00a000",p3:"color(display-p3 0.2711 0.6172 0.0195)"}},"light-red":{solid:"#ff8787",semi:"#3b3235",pattern:"#a56767",highlight:{srgb:"#db005b",p3:"color(display-p3 0.7849 0.0585 0.3589)"}},"light-violet":{solid:"#e599f7",semi:"#383442",pattern:"#9770a9",highlight:{srgb:"#c400c7",p3:"color(display-p3 0.7024 0.0403 0.753)"}},orange:{solid:"#f76707",semi:"#3a2e2a",pattern:"#9f552d",highlight:{srgb:"#d07a00",p3:"color(display-p3 0.7699 0.4937 0.0085)"}},red:{solid:"#e03131",semi:"#36292b",pattern:"#8f3734",highlight:{srgb:"#de002c",p3:"color(display-p3 0.7978 0.0509 0.2035)"}},violet:{solid:"#ae3ec9",semi:"#31293c",pattern:"#763a8b",highlight:{srgb:"#9e00ee",p3:"color(display-p3 0.5651 0.0079 0.8986)"}},yellow:{solid:"#ffc034",semi:"#3c3934",pattern:"#fecb92",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.7225 0.0312)"}}}};function Dn(e){return e.isDarkMode?ap.darkMode:ap.lightMode}const mr=sn.defineEnum("tldraw:color",{defaultValue:"black",values:HI}),KI=sn.defineEnum("tldraw:labelColor",{defaultValue:"black",values:HI}),yi=sn.defineEnum("tldraw:dash",{defaultValue:"draw",values:["draw","solid","dashed","dotted"]}),Ua=sn.defineEnum("tldraw:fill",{defaultValue:"none",values:["none","semi","solid","pattern"]}),lo=sn.defineEnum("tldraw:font",{defaultValue:"draw",values:["draw","sans","serif","mono"]}),mu={draw:"'tldraw_draw', sans-serif",sans:"'tldraw_sans', sans-serif",serif:"'tldraw_serif', serif",mono:"'tldraw_mono', monospace"},co=sn.defineEnum("tldraw:size",{defaultValue:"m",values:["s","m","l","xl"]}),VI=["arrow","triangle","square","dot","pipe","diamond","inverted","bar","none"],lp=sn.defineEnum("tldraw:arrowheadStart",{defaultValue:"none",values:VI}),cp=sn.defineEnum("tldraw:arrowheadEnd",{defaultValue:"arrow",values:VI}),Yx=zv("type",{binding:be({type:On("binding"),boundShapeId:Er,normalizedAnchor:Cc,isExact:xe,isPrecise:xe}),point:be({type:On("point"),x:de,y:de})}),WI={labelColor:KI,color:mr,fill:Ua,dash:yi,size:co,arrowheadStart:lp,arrowheadEnd:cp,font:lo,start:Yx,end:Yx,bend:de,text:Se,labelPosition:de},nd={AddLabelColor:1,AddIsPrecise:2,AddLabelPosition:3},GI=Me({currentVersion:nd.AddLabelPosition,migrators:{[nd.AddLabelColor]:{up:e=>({...e,props:{...e.props,labelColor:"black"}}),down:e=>{const{labelColor:n,...t}=e.props;return{...e,props:t}}},[nd.AddIsPrecise]:{up:e=>{const{start:n,end:t}=e.props;return{...e,props:{...e.props,start:n.type==="binding"?{...n,isPrecise:!(n.normalizedAnchor.x===.5&&n.normalizedAnchor.y===.5)}:n,end:t.type==="binding"?{...t,isPrecise:!(t.normalizedAnchor.x===.5&&t.normalizedAnchor.y===.5)}:t}}},down:e=>{const{start:n,end:t}=e.props,r={...n},o={...t};return r.type==="binding"&&(r.isPrecise||(r.normalizedAnchor={x:.5,y:.5}),delete r.isPrecise),o.type==="binding"&&(o.isPrecise||(o.normalizedAnchor={x:.5,y:.5}),delete o.isPrecise),{...e,props:{...e.props,start:r,end:o}}}},[nd.AddLabelPosition]:{up:e=>({...e,props:{...e.props,labelPosition:.5}}),down:e=>{const{labelPosition:n,...t}=e.props;return{...e,props:t}}}}}),YI={w:jn,h:jn,assetId:hf.nullable(),url:Qn},Cg={NullAssetId:1,MakeUrlsValid:2},XI=Me({currentVersion:Cg.MakeUrlsValid,migrators:{[Cg.NullAssetId]:{up:e=>e.props.assetId===void 0?{...e,props:{...e.props,assetId:null}}:e,down:e=>{if(e.props.assetId===null){const{assetId:n,...t}=e.props;return{...e,props:t}}return e}},[Cg.MakeUrlsValid]:{up:e=>e.props.url!==""&&!Qn.isValid(e.props.url)?{...e,props:{...e.props,url:""}}:e,down:e=>e}}}),qI=be({type:LI("free","straight"),points:zt(Cc)}),ZI={color:mr,fill:Ua,dash:yi,size:co,segments:zt(qI),isComplete:xe,isClosed:xe,isPen:xe},Xx={AddInPen:1},QI=Me({currentVersion:Xx.AddInPen,migrators:{[Xx.AddInPen]:{up:e=>{const{points:n}=e.props.segments[0];if(n.length===0)return{...e,props:{...e.props,isPen:!1}};let t=!(n[0].z===0||n[0].z===.5);return n[1]&&(t=t&&!(n[1].z===0||n[1].z===.5)),{...e,props:{...e.props,isPen:t}}},down:e=>{const{isPen:n,...t}=e.props;return{...e,props:{...t}}}}}});var gR={};const qx=/(^\/r\/[^/]+\/?$)/,Ne=e=>{try{return new URL(e)}catch{return}},Ha=[{type:"tldraw",title:"tldraw",hostnames:["beta.tldraw.com","tldraw.com","localhost:3000"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,canUnmount:!0,overridePermissions:{"allow-top-navigation":!0},toEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(qx))return e},fromEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(qx))return e}},{type:"figma",title:"Figma",hostnames:["figma.com"],width:720,height:500,doesResize:!0,canUnmount:!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 n=Ne(e);if(n&&n.pathname.match(/^\/embed\/?$/)){const t=n.searchParams.get("url");if(t)return t}}},{type:"google_maps",title:"Google Maps",hostnames:["google.*"],width:720,height:500,doesResize:!0,canUnmount:!1,toEmbedUrl:e=>{if(e.includes("/maps/")){const n=e.match(/@(.*),(.*),(.*)z/);let t;if(n){const[,r,o,s]=n;t=`https://${new URL(e).host.replace("www.","")}/maps/embed/v1/view?key=${gR.NEXT_PUBLIC_GC_API_KEY}¢er=${r},${o}&zoom=${s}`}else t="";return t}},fromEmbedUrl:e=>{const n=Ne(e);if(!n)return;if(n.pathname.match(/^\/maps\/embed\/v1\/view\/?$/)&&n.searchParams.has("center")&&n.searchParams.get("zoom")){const r=n.searchParams.get("zoom"),[o,s]=n.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,canUnmount:!1,toEmbedUrl:e=>{const n=Ne(e),t=n&&n.pathname.match(/\/v\/([^/]+)\/?/);if(t)return`https://www.val.town/embed/${t[1]}`},fromEmbedUrl:e=>{const n=Ne(e),t=n&&n.pathname.match(/\/embed\/([^/]+)\/?/);if(t)return`https://www.val.town/v/${t[1]}`}},{type:"codesandbox",title:"CodeSandbox",hostnames:["codesandbox.io"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,canUnmount:!1,toEmbedUrl:e=>{const n=Ne(e),t=n&&n.pathname.match(/\/s\/([^/]+)\/?/);if(t)return`https://codesandbox.io/embed/${t[1]}`},fromEmbedUrl:e=>{const n=Ne(e),t=n&&n.pathname.match(/\/embed\/([^/]+)\/?/);if(t)return`https://codesandbox.io/s/${t[1]}`}},{type:"codepen",title:"Codepen",hostnames:["codepen.io"],minWidth:300,minHeight:300,width:520,height:400,doesResize:!0,canUnmount:!1,toEmbedUrl:e=>{const n=/https:\/\/codepen.io\/([^/]+)\/pen\/([^/]+)/,t=e.match(n);if(t){const[r,o,s]=t;return`https://codepen.io/${o}/embed/${s}`}},fromEmbedUrl:e=>{const n=/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/,t=e.match(n);if(t){const[r,o,s]=t;return`https://codepen.io/${o}/pen/${s}`}}},{type:"scratch",title:"Scratch",hostnames:["scratch.mit.edu"],width:520,height:400,doesResize:!1,canUnmount:!1,toEmbedUrl:e=>{const n=/https?:\/\/scratch.mit.edu\/projects\/([^/]+)/,t=e.match(n);if(t){const[r,o]=t;return`https://scratch.mit.edu/projects/embed/${o}`}},fromEmbedUrl:e=>{const n=/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/,t=e.match(n);if(t){const[r,o]=t;return`https://scratch.mit.edu/projects/${o}`}}},{type:"youtube",title:"YouTube",hostnames:["*.youtube.com","youtube.com","youtu.be"],width:800,height:450,doesResize:!0,canUnmount:!1,overridePermissions:{"allow-presentation":!0},isAspectRatioLocked:!0,toEmbedUrl:e=>{const n=Ne(e);if(!n)return;const t=n.hostname.replace(/^www./,"");if(t==="youtu.be")return`https://www.youtube.com/embed/${n.pathname.split("/").filter(Boolean)[0]}`;if((t==="youtube.com"||t==="m.youtube.com")&&n.pathname.match(/^\/watch/))return`https://www.youtube.com/embed/${n.searchParams.get("v")}`},fromEmbedUrl:e=>{const n=Ne(e);if(!n)return;if(n.hostname.replace(/^www./,"")==="youtube.com"){const r=n.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,canUnmount:!1,instructionLink:"https://support.google.com/calendar/answer/41207?hl=en",toEmbedUrl:e=>{const n=Ne(e),t=n==null?void 0:n.searchParams.get("cid");if(n!=null&&n.pathname.match(/\/calendar\/u\/0/)&&t){n.pathname="/calendar/embed";const r=Array.from(n.searchParams.keys());for(const o of r)n.searchParams.delete(o);return n.searchParams.set("src",t),n.href}},fromEmbedUrl:e=>{const n=Ne(e),t=n==null?void 0:n.searchParams.get("src");if(n!=null&&n.pathname.match(/\/calendar\/embed/)&&t){n.pathname="/calendar/u/0";const r=Array.from(n.searchParams.keys());for(const o of r)n.searchParams.delete(o);return n.searchParams.set("cid",t),n.href}}},{type:"google_slides",title:"Google Slides",hostnames:["docs.google.*"],width:720,height:500,minWidth:460,minHeight:360,doesResize:!0,canUnmount:!1,toEmbedUrl:e=>{const n=Ne(e);if(n!=null&&n.pathname.match(/^\/presentation/)&&(n!=null&&n.pathname.match(/\/pub\/?$/))){n.pathname=n.pathname.replace(/\/pub$/,"/embed");const t=Array.from(n.searchParams.keys());for(const r of t)n.searchParams.delete(r);return n.href}},fromEmbedUrl:e=>{const n=Ne(e);if(n!=null&&n.pathname.match(/^\/presentation/)&&(n!=null&&n.pathname.match(/\/embed\/?$/))){n.pathname=n.pathname.replace(/\/embed$/,"/pub");const t=Array.from(n.searchParams.keys());for(const r of t)n.searchParams.delete(r);return n.href}}},{type:"github_gist",title:"GitHub Gist",hostnames:["gist.github.com"],width:720,height:500,doesResize:!0,canUnmount:!0,toEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(/\/([^/]+)\/([^/]+)/))return e.split("/").pop()?e:void 0},fromEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(/\/([^/]+)\/([^/]+)/))return e.split("/").pop()?e:void 0}},{type:"replit",title:"Replit",hostnames:["replit.com"],width:720,height:500,doesResize:!0,canUnmount:!1,toEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(/\/@([^/]+)\/([^/]+)/))return`${e}?embed=true`},fromEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(/\/@([^/]+)\/([^/]+)/)&&n.searchParams.has("embed"))return n.searchParams.delete("embed"),n.href}},{type:"felt",title:"Felt",hostnames:["felt.com"],width:720,height:500,doesResize:!0,canUnmount:!1,toEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(/^\/map\//))return n.origin+"/embed"+n.pathname},fromEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(/^\/embed\/map\//))return n.pathname=n.pathname.replace(/^\/embed/,""),n.href}},{type:"spotify",title:"Spotify",hostnames:["open.spotify.com"],width:720,height:500,minHeight:500,overrideOutlineRadius:12,doesResize:!0,canUnmount:!1,toEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(/^\/(artist|album)\//))return n.origin+"/embed"+n.pathname},fromEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(/^\/embed\/(artist|album)\//))return n.origin+n.pathname.replace(/^\/embed/,"")}},{type:"vimeo",title:"Vimeo",hostnames:["vimeo.com","player.vimeo.com"],width:640,height:360,doesResize:!0,canUnmount:!1,isAspectRatioLocked:!0,toEmbedUrl:e=>{const n=Ne(e);if(n&&n.hostname==="vimeo.com"&&n.pathname.match(/^\/[0-9]+/))return"https://player.vimeo.com/video/"+n.pathname.split("/")[1]+"?title=0&byline=0"},fromEmbedUrl:e=>{const n=Ne(e);if(n&&n.hostname==="player.vimeo.com"){const t=n.pathname.match(/^\/video\/([^/]+)\/?$/);if(t)return"https://vimeo.com/"+t[1]}}},{type:"excalidraw",title:"Excalidraw",hostnames:["excalidraw.com"],width:720,height:500,doesResize:!0,canUnmount:!1,isAspectRatioLocked:!0,toEmbedUrl:e=>{const n=Ne(e);if(n&&n.hash.match(/#room=/))return e},fromEmbedUrl:e=>{const n=Ne(e);if(n&&n.hash.match(/#room=/))return e}},{type:"observable",title:"Observable",hostnames:["observablehq.com"],width:720,height:500,doesResize:!0,canUnmount:!1,isAspectRatioLocked:!1,backgroundColor:"#fff",toEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(/^\/@([^/]+)\/([^/]+)\/?$/))return`${n.origin}/embed${n.pathname}?cell=*`;if(n&&n.pathname.match(/^\/d\/([^/]+)\/?$/)){const t=n.pathname.replace(/^\/d/,"");return`${n.origin}/embed${t}?cell=*`}},fromEmbedUrl:e=>{const n=Ne(e);if(n&&n.pathname.match(/^\/embed\/@([^/]+)\/([^/]+)\/?$/))return`${n.origin}${n.pathname.replace("/embed","")}#cell-*`;if(n&&n.pathname.match(/^\/embed\/([^/]+)\/?$/))return`${n.origin}${n.pathname.replace("/embed","/d")}#cell-*`}}],mR={"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},JI={w:jn,h:jn,url:Se},Il={GenOriginalUrlInEmbed:1,RemoveDoesResize:2,RemoveTmpOldUrl:3,RemovePermissionOverrides:4},eE=Me({currentVersion:Il.RemovePermissionOverrides,migrators:{[Il.GenOriginalUrlInEmbed]:{up:e=>{const n=e.props.url,t=new URL(n).host.replace("www.","");let r;for(const o of Ha)if(o.hostnames.includes(t))try{r=o.fromEmbedUrl(n)}catch(s){console.warn(s)}return{...e,props:{...e.props,tmpOldUrl:e.props.url,url:r??""}}},down:e=>{let n=e.props.tmpOldUrl;if(!n||n===""){const o=e.props.url,s=new URL(o).host.replace("www.","");for(const i of Ha)if(i.hostnames.includes(s))try{n=i.toEmbedUrl(o)}catch(a){console.warn(a)}}const{tmpOldUrl:t,...r}=e.props;return{...e,props:{...r,url:n??""}}}},[Il.RemoveDoesResize]:{up:e=>{const{doesResize:n,...t}=e.props;return{...e,props:{...t}}},down:e=>({...e,props:{...e.props,doesResize:!0}})},[Il.RemoveTmpOldUrl]:{up:e=>{const{tmpOldUrl:n,...t}=e.props;return{...e,props:{...t}}},down:e=>({...e,props:{...e.props}})},[Il.RemovePermissionOverrides]:{up:e=>{const{overridePermissions:n,...t}=e.props;return{...e,props:{...t}}},down:e=>({...e,props:{...e.props}})}}}),tE={w:jn,h:jn,name:Se},nE=Me({}),Ec=sn.defineEnum("tldraw:horizontalAlign",{defaultValue:"middle",values:["start","middle","end","start-legacy","end-legacy","middle-legacy"]}),up=sn.defineEnum("tldraw:verticalAlign",{defaultValue:"middle",values:["start","middle","end"]}),so=sn.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"]}),rE={geo:so,labelColor:KI,color:mr,fill:Ua,dash:yi,size:co,font:lo,align:Ec,verticalAlign:up,url:Qn,w:jn,h:jn,growY:Fv,text:Se},Po={AddUrlProp:1,AddLabelColor:2,RemoveJustify:3,AddCheckBox:4,AddVerticalAlign:5,MigrateLegacyAlign:6,AddCloud:7,MakeUrlsValid:8},oE=Me({currentVersion:Po.MakeUrlsValid,migrators:{[Po.AddUrlProp]:{up:e=>({...e,props:{...e.props,url:""}}),down:e=>{const{url:n,...t}=e.props;return{...e,props:t}}},[Po.AddLabelColor]:{up:e=>({...e,props:{...e.props,labelColor:"black"}}),down:e=>{const{labelColor:n,...t}=e.props;return{...e,props:t}}},[Po.RemoveJustify]:{up:e=>{let n=e.props.align;return n==="justify"&&(n="start"),{...e,props:{...e.props,align:n}}},down:e=>({...e})},[Po.AddCheckBox]:{up:e=>({...e}),down:e=>({...e,props:{...e.props,geo:e.props.geo==="check-box"?"rectangle":e.props.geo}})},[Po.AddVerticalAlign]:{up:e=>({...e,props:{...e.props,verticalAlign:"middle"}}),down:e=>{const{verticalAlign:n,...t}=e.props;return{...e,props:t}}},[Po.MigrateLegacyAlign]:{up:e=>{let n;switch(e.props.align){case"start":n="start-legacy";break;case"end":n="end-legacy";break;default:n="middle-legacy";break}return{...e,props:{...e.props,align:n}}},down:e=>{let n;switch(e.props.align){case"start-legacy":n="start";break;case"end-legacy":n="end";break;case"middle-legacy":n="middle";break;default:n=e.props.align}return{...e,props:{...e.props,align:n}}}},[Po.AddCloud]:{up:e=>e,down:e=>{if(e.props.geo==="cloud")return{...e,props:{...e.props,geo:"rectangle"}}}},[Po.MakeUrlsValid]:{up:e=>e.props.url!==""&&!Qn.isValid(e.props.url)?{...e,props:{...e.props,url:""}}:e,down:e=>e}}}),sE={},iE=Me({}),aE={color:mr,size:co,segments:zt(qI),isComplete:xe,isPen:xe},lE=Me({}),yR=be({topLeft:Cc,bottomRight:Cc}),cE={w:jn,h:jn,playing:xe,url:Qn,assetId:hf.nullable(),crop:yR.nullable()},rd={AddUrlProp:1,AddCropProp:2,MakeUrlsValid:3},uE=Me({currentVersion:rd.MakeUrlsValid,migrators:{[rd.AddUrlProp]:{up:e=>({...e,props:{...e.props,url:""}}),down:e=>{const{url:n,...t}=e.props;return{...e,props:t}}},[rd.AddCropProp]:{up:e=>({...e,props:{...e.props,crop:null}}),down:e=>{const{crop:n,...t}=e.props;return{...e,props:t}}},[rd.MakeUrlsValid]:{up:e=>e.props.url!==""&&!Qn.isValid(e.props.url)?{...e,props:{...e.props,url:""}}:e,down:e=>e}}}),dp=sn.defineEnum("tldraw:spline",{defaultValue:"line",values:["cubic","line"]}),SR=be({id:Se,index:Bv,x:de,y:de}),dE={color:mr,dash:yi,size:co,spline:dp,points:Oy(Se,SR)},El={AddSnapHandles:1,RemoveExtraHandleProps:2,HandlesToPoints:3,PointIndexIds:4},hE=Me({currentVersion:El.PointIndexIds,migrators:{[El.AddSnapHandles]:{up:e=>{const n=pr(e.props.handles);for(const t in n)n[t].canSnap=!0;return{...e,props:{...e.props,handles:n}}},down:e=>{const n=pr(e.props.handles);for(const t in n)delete n[t].canSnap;return{...e,props:{...e.props,handles:n}}}},[El.RemoveExtraHandleProps]:{up:e=>({...e,props:{...e.props,handles:jv(Object.values(e.props.handles).map(n=>[n.index,{x:n.x,y:n.y}]))}}),down:e=>{const n=Object.entries(e.props.handles).map(([t,r])=>({index:t,...r})).sort(Rt);return{...e,props:{...e.props,handles:Object.fromEntries(n.map((t,r)=>{const o=r===0?"start":r===n.length-1?"end":`handle:${t.index}`;return[o,{id:o,type:"vertex",canBind:!1,canSnap:!0,index:t.index,x:t.x,y:t.y}]}))}}}},[El.HandlesToPoints]:{up:e=>{const{handles:n,...t}=e.props,r=Object.entries(n).map(([o,{x:s,y:i}])=>({x:s,y:i,index:o})).sort(Rt);return{...e,props:{...t,points:r.map(({x:o,y:s})=>({x:o,y:s}))}}},down:e=>{const{points:n,...t}=e.props,r=Pc(n.length);return{...e,props:{...t,handles:Object.fromEntries(n.map((o,s)=>[r[s],{x:o.x,y:o.y}]))}}}},[El.PointIndexIds]:{up:e=>{const{points:n,...t}=e.props,r=Pc(n.length);return{...e,props:{...t,points:Object.fromEntries(n.map((o,s)=>{const i=r[s];return[i,{id:i,index:i,x:o.x,y:o.y}]}))}}},down:e=>{const n=Object.values(e.props.points).sort(Rt);return{...e,props:{...e.props,points:n.map(({x:t,y:r})=>({x:t,y:r}))}}}}}}),pE={color:mr,size:co,font:lo,align:Ec,verticalAlign:up,growY:Fv,url:Qn,text:Se},Gi={AddUrlProp:1,RemoveJustify:2,MigrateLegacyAlign:3,AddVerticalAlign:4,MakeUrlsValid:5},fE=Me({currentVersion:Gi.MakeUrlsValid,migrators:{[Gi.AddUrlProp]:{up:e=>({...e,props:{...e.props,url:""}}),down:e=>{const{url:n,...t}=e.props;return{...e,props:t}}},[Gi.RemoveJustify]:{up:e=>{let n=e.props.align;return n==="justify"&&(n="start"),{...e,props:{...e.props,align:n}}},down:e=>({...e})},[Gi.MigrateLegacyAlign]:{up:e=>{let n;switch(e.props.align){case"start":n="start-legacy";break;case"end":n="end-legacy";break;default:n="middle-legacy";break}return{...e,props:{...e.props,align:n}}},down:e=>{let n;switch(e.props.align){case"start-legacy":n="start";break;case"end-legacy":n="end";break;case"middle-legacy":n="middle";break;default:n=e.props.align}return{...e,props:{...e.props,align:n}}}},[Gi.AddVerticalAlign]:{up:e=>({...e,props:{...e.props,verticalAlign:"middle"}}),down:e=>{const{verticalAlign:n,...t}=e.props;return{...e,props:t}}},[Gi.MakeUrlsValid]:{up:e=>e.props.url!==""&&!Qn.isValid(e.props.url)?{...e,props:{...e.props,url:""}}:e,down:e=>e}}}),gE={color:mr,size:co,font:lo,align:Ec,w:jn,text:Se,scale:jn,autoSize:xe},Zx={RemoveJustify:1},mE=Me({currentVersion:Zx.RemoveJustify,migrators:{[Zx.RemoveJustify]:{up:e=>{let n=e.props.align;return n==="justify"&&(n="start"),{...e,props:{...e.props,align:n}}},down:e=>({...e})}}}),yE={w:jn,h:jn,time:de,playing:xe,url:Qn,assetId:hf.nullable()},Ig={AddUrlProp:1,MakeUrlsValid:2},SE=Me({currentVersion:Ig.MakeUrlsValid,migrators:{[Ig.AddUrlProp]:{up:e=>({...e,props:{...e.props,url:""}}),down:e=>{const{url:n,...t}=e.props;return{...e,props:t}}},[Ig.MakeUrlsValid]:{up:e=>e.props.url!==""&&!Qn.isValid(e.props.url)?{...e,props:{...e.props,url:""}}:e,down:e=>e}}}),_l={RemoveCodeAndIconShapeTypes:1,AddInstancePresenceType:2,RemoveTLUserAndPresenceAndAddPointer:3,RemoveUserDocument:4},vR=Me({currentVersion:_l.RemoveUserDocument,migrators:{[_l.RemoveCodeAndIconShapeTypes]:{up:e=>Object.fromEntries(Object.entries(e).filter(([n,t])=>t.typeName!=="shape"||t.type!=="icon"&&t.type!=="code")),down:e=>e},[_l.AddInstancePresenceType]:{up:e=>e,down:e=>Object.fromEntries(Object.entries(e).filter(([n,t])=>t.typeName!=="instance_presence"))},[_l.RemoveTLUserAndPresenceAndAddPointer]:{up:e=>Object.fromEntries(Object.entries(e).filter(([n,t])=>!t.typeName.match(/^(user|user_presence)$/))),down:e=>Object.fromEntries(Object.entries(e).filter(([n,t])=>t.typeName!=="pointer"))},[_l.RemoveUserDocument]:{up:e=>Object.fromEntries(Object.entries(e).filter(([n,t])=>!t.typeName.match("user_document"))),down:e=>e}}}),wR={arrow:{migrations:GI,props:WI},bookmark:{migrations:XI,props:YI},draw:{migrations:QI,props:ZI},embed:{migrations:eE,props:JI},frame:{migrations:nE,props:tE},geo:{migrations:oE,props:rE},group:{migrations:iE,props:sE},highlight:{migrations:lE,props:aE},image:{migrations:uE,props:cE},line:{migrations:hE,props:dE},note:{migrations:fE,props:pE},text:{migrations:mE,props:gE},video:{migrations:SE,props:yE}};function xR({shapes:e=wR}={}){const n=new Map;for(const o of ot(e))for(const s of UI(o.props??{}).keys()){if(n.has(s.id)&&n.get(s.id)!==s)throw new Error(`Multiple StyleProp instances with the same id: ${s.id}`);n.set(s.id,s)}const t=fR(e),r=UD(n);return Rv.create({asset:li,camera:qt,document:Kv,instance:r,instance_page_state:Zt,page:zo,shape:t,instance_presence:QD,pointer:Hv},{snapshotMigrations:vR,onValidationFailure:nR,createIntegrityChecker:oR})}const _c=[{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 bR(){const e=typeof window<"u"?window.navigator.languages??["en"]:["en"];return PR(e)}function PR(e){for(const n of e){const t=CR(n);if(t)return t}return"en"}const Qx={zh:"zh-cn",pt:"pt-br",ko:"ko-kr",hi:"hi-in"};function CR(e){const n=_c.find(o=>o.locale===e.toLowerCase());if(n)return n.locale;const[t,r]=e.split(/[-_]/).map(o=>o.toLowerCase());if(r){const o=_c.find(s=>s.locale===t);if(o)return o.locale}return t in Qx?Qx[t]:null}var vE={exports:{}};/*!
|
|
40
|
+
Copyright (c) 2018 Jed Watson.
|
|
41
|
+
Licensed under the MIT License (MIT), see
|
|
42
|
+
http://jedwatson.github.io/classnames
|
|
43
|
+
*/(function(e){(function(){var n={}.hasOwnProperty;function t(){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 t.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)n.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?(t.default=t,e.exports=t):window.classNames=t})()})(vE);var IR=vE.exports;const fe=el(IR),ER={error:null};class wE extends x.Component{constructor(){super(...arguments);m(this,"state",ER)}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){var r,o;(o=(r=this.props).onError)==null||o.call(r,t)}render(){const{error:t}=this.state;if(t!==null){const{fallback:r}=this.props;return p.jsx(r,{error:t})}return this.props.children}}function kc({children:e,fallback:n,...t}){return n===null?p.jsx(p.Fragment,{children:e}):p.jsx(wE,{fallback:n,...t,children:e})}const Vv=ie.createContext({});function F(){return ie.useContext(Vv)}function _R(){return p.jsx("div",{className:"tl-background"})}function ol(e,n,t,r,o,s){x.useLayoutEffect(()=>{const i=e.current;if(!i||n===void 0)return;let a=`translate(${n}px, ${t}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 tn={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(n=0,t=0,r=1){this.x=n,this.y=t,this.z=r}get pressure(){return this.z}set(n=this.x,t=this.y,r=this.z){return this.x=n,this.y=t,this.z=r,this}setTo({x:n=0,y:t=0,z:r=1}){return this.x=n,this.y=t,this.z=r,this}rot(n){if(n===0)return this;const{x:t,y:r}=this,o=Math.sin(n),s=Math.cos(n);return this.x=t*s-r*o,this.y=t*o+r*s,this}rotWith(n,t){if(t===0)return this;const r=this.x-n.x,o=this.y-n.y,s=Math.sin(t),i=Math.cos(t);return this.x=n.x+(r*i-o*s),this.y=n.y+(r*s+o*i),this}clone(){const{x:n,y:t,z:r}=this;return new b(n,t,r)}sub(n){return this.x-=n.x,this.y-=n.y,this}subXY(n,t){return this.x-=n,this.y-=t,this}subScalar(n){return this.x-=n,this.y-=n,this}add(n){return this.x+=n.x,this.y+=n.y,this}addXY(n,t){return this.x+=n,this.y+=t,this}addScalar(n){return this.x+=n,this.y+=n,this}clamp(n,t){return this.x=Math.max(this.x,n),this.y=Math.max(this.y,n),t!==void 0&&(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t)),this}div(n){return this.x/=n,this.y/=n,this}divV(n){return this.x/=n.x,this.y/=n.y,this}mul(n){return this.x*=n,this.y*=n,this}mulV(n){return this.x*=n.x,this.y*=n.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(n,t){const r=b.Tan(n,this);return this.add(r.mul(t))}neg(){return this.x*=-1,this.y*=-1,this}cross(n){return this.x=this.y*n.z-this.z*n.y,this.y=this.z*n.x-this.x*n.z,this}dpr(n){return b.Dpr(this,n)}cpr(n){return b.Cpr(this,n)}len2(){return b.Len2(this)}len(){return b.Len(this)}pry(n){return b.Pry(this,n)}per(){const{x:n,y:t}=this;return this.x=t,this.y=-n,this}uni(){return b.Uni(this)}tan(n){return b.Tan(this,n)}dist(n){return b.Dist(this,n)}distanceToLineSegment(n,t){return b.DistanceToLineSegment(n,t,this)}slope(n){return b.Slope(this,n)}snapToGrid(n){return this.x=Math.round(this.x/n)*n,this.y=Math.round(this.y/n)*n,this}angle(n){return b.Angle(this,n)}toAngle(){return b.ToAngle(this)}lrp(n,t){return this.x=this.x+(n.x-this.x)*t,this.y=this.y+(n.y-this.y)*t,this}equals(n){return b.Equals(this,n)}equalsXY(n,t){return b.EqualsXY(this,n,t)}norm(){const n=this.len();return this.x=n===0?0:this.x/n,this.y=n===0?0:this.y/n,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(n,t){return new b(n.x+t.x,n.y+t.y)}static AddXY(n,t,r){return new b(n.x+t,n.y+r)}static Sub(n,t){return new b(n.x-t.x,n.y-t.y)}static SubXY(n,t,r){return new b(n.x-t,n.y-r)}static AddScalar(n,t){return new b(n.x+t,n.y+t)}static SubScalar(n,t){return new b(n.x-t,n.y-t)}static Div(n,t){return new b(n.x/t,n.y/t)}static Mul(n,t){return new b(n.x*t,n.y*t)}static DivV(n,t){return new b(n.x/t.x,n.y/t.y)}static MulV(n,t){return new b(n.x*t.x,n.y*t.y)}static Neg(n){return new b(-n.x,-n.y)}static Per(n){return new b(n.y,-n.x)}static Dist2(n,t){return b.Sub(n,t).len2()}static Abs(n){return new b(Math.abs(n.x),Math.abs(n.y))}static Dist(n,t){return Math.hypot(n.y-t.y,n.x-t.x)}static Dpr(n,t){return n.x*t.x+n.y*t.y}static Cross(n,t){return new b(n.y*t.z-n.z*t.y,n.z*t.x-n.x*t.z)}static Cpr(n,t){return n.x*t.y-t.x*n.y}static Len2(n){return n.x*n.x+n.y*n.y}static Len(n){return Math.hypot(n.x,n.y)}static Pry(n,t){return b.Dpr(n,t)/b.Len(t)}static Uni(n){return b.Div(n,b.Len(n))}static Tan(n,t){return b.Uni(b.Sub(n,t))}static Min(n,t){return new b(Math.min(n.x,t.x),Math.min(n.y,t.y))}static Max(n,t){return new b(Math.max(n.x,t.x),Math.max(n.y,t.y))}static From({x:n,y:t,z:r=1}){return new b(n,t,r)}static FromArray(n){return new b(n[0],n[1])}static Rot(n,t=0){const r=Math.sin(t),o=Math.cos(t);return new b(n.x*o-n.y*r,n.x*r+n.y*o)}static RotWith(n,t,r){const o=n.x-t.x,s=n.y-t.y,i=Math.sin(r),a=Math.cos(r);return new b(t.x+(o*a-s*i),t.y+(o*i+s*a))}static NearestPointOnLineThroughPoint(n,t,r){return b.Mul(t,b.Sub(r,n).pry(t)).add(n)}static NearestPointOnLineSegment(n,t,r,o=!0){const s=b.Tan(t,n),i=b.Add(n,b.Mul(s,b.Sub(r,n).pry(s)));if(o){if(i.x<Math.min(n.x,t.x))return b.Cast(n.x<t.x?n:t);if(i.x>Math.max(n.x,t.x))return b.Cast(n.x>t.x?n:t);if(i.y<Math.min(n.y,t.y))return b.Cast(n.y<t.y?n:t);if(i.y>Math.max(n.y,t.y))return b.Cast(n.y>t.y?n:t)}return i}static DistanceToLineThroughPoint(n,t,r){return b.Dist(r,b.NearestPointOnLineThroughPoint(n,t,r))}static DistanceToLineSegment(n,t,r,o=!0){return b.Dist(r,b.NearestPointOnLineSegment(n,t,r,o))}static Snap(n,t=1){return new b(Math.round(n.x/t)*t,Math.round(n.y/t)*t)}static Cast(n){return n instanceof b?n:b.From(n)}static Slope(n,t){return n.x===t.y?NaN:(n.y-t.y)/(n.x-t.x)}static IsNaN(n){return isNaN(n.x)||isNaN(n.y)}static Angle(n,t){return Math.atan2(t.y-n.y,t.x-n.x)}static Lrp(n,t,r){return b.Sub(t,n).mul(r).add(n)}static Med(n,t){return new b((n.x+t.x)/2,(n.y+t.y)/2)}static Equals(n,t){return Math.abs(n.x-t.x)<1e-4&&Math.abs(n.y-t.y)<1e-4}static EqualsXY(n,t,r){return n.x===t&&n.y===r}static Clockwise(n,t,r){return(r.x-n.x)*(t.y-n.y)-(t.x-n.x)*(r.y-n.y)<0}static Rescale(n,t){const r=b.Len(n);return new b(t*n.x/r,t*n.y/r)}static ScaleWithOrigin(n,t,r){return b.Sub(n,r).mul(t).add(r)}static ToFixed(n,t=2){return new b(+n.x.toFixed(t),+n.y.toFixed(t),+n.z.toFixed(t))}static Nudge(n,t,r){return b.Add(n,b.Tan(t,n).mul(r))}static ToString(n){return`${n.x}, ${n.y}`}static ToAngle(n){let t=Math.atan2(n.y,n.x);return t<0&&(t+=Math.PI*2),t}static FromAngle(n,t=1){return new b(Math.cos(n)*t,Math.sin(n)*t)}static ToArray(n){return[n.x,n.y,n.z]}static ToJson(n){const{x:t,y:r,z:o}=n;return{x:t,y:r,z:o}}static Average(n){const t=n.length,r=new b(0,0);for(let o=0;o<t;o++)r.add(n[o]);return r.div(t)}static Clamp(n,t,r){return r===void 0?new b(Math.min(Math.max(n.x,t)),Math.min(Math.max(n.y,t))):new b(Math.min(Math.max(n.x,t),r),Math.min(Math.max(n.y,t),r))}static PointsBetween(n,t,r=6){const o=[];for(let s=0;s<r;s++){const i=tn.easeInQuad(s/(r-1)),a=b.Lrp(n,t,i);a.z=Math.min(1,.5+Math.abs(.5-kR(i))*.65),o.push(a)}return o}static SnapToGrid(n,t=8){return new b(Math.round(n.x/t)*t,Math.round(n.y/t)*t)}}const kR=e=>e<.5?2*e*e:-1+(4-2*e)*e;function Nt(e){return`${j(e.x)},${j(e.y)} `}function Pn(e,n){return`${j((e.x+n.x)/2)},${j((e.y+n.y)/2)} `}const $e=Math.PI,Ke=$e/2,De=$e*2,TR=Math.sin;function ar(e,n,t){return Math.max(n,typeof t<"u"?Math.min(e,t):e)}function od(e,n=1e10){return e?Math.round(e*n)/n:0}function ic(e,n,t=1e-6){return Math.abs(e-n)<=t}function Tc(e,n){const t=Math.pow(e-n,2)/Math.pow(e+n,2);return $e*(e+n)*(1+3*t/(10+Math.sqrt(4-3*t)))}function Rr(e){return e=e%De,e<0?e=e+De:e===0&&(e=0),e}function yu(e,n){return e=Rr(e),n=Rr(n),e>n&&(n+=De),n-e}function xE(e,n){return De-yu(e,n)}function ac(e,n){const t=(n-e)%De;return 2*t%De-t}function Ry(e){return(De+e)%De}function hp(e,n){const t=De/n;let r=Math.floor((Ry(e)+t/2)/t)*t%De;return r<$e&&(r+=De),r>$e&&(r-=De),r}function bE(e,n){return e===n||ic(e%(Math.PI/2)-n%(Math.PI/2),0)}function $R(e){return e*$e/180}function MR(e){return e*180/$e}function Si(e,n,t){return new b(e.x,e.y).add(b.FromAngle(t,n))}function Eg(e,n,t){const r=e/2,o=n/2,s=[];let i=1/0,a=-1/0,l=1/0,c=-1/0;for(let y=0;y<t;y++){const g=De/t,v=-Ke+y*g,S=r+r*Math.cos(v),w=o+o*Math.sin(v);S<i&&(i=S),w<l&&(l=w),S>a&&(a=S),w>c&&(c=w),s.push(new b(S,w))}const u=a-i,d=c-l,h=e-u,f=n-d;if(h!==0||f!==0)for(let y=0;y<s.length;y++){const g=s[y];g.x=(g.x-i)/u*e,g.y=(g.y-l)/d*n}return s}function kl(e,n,t,r){return e<r&&t<n}function _r(e,n,t,r){const o=Math.max(e,t),s=Math.min(n,r);return o<=s?[o,s]:null}function Jx(e,n,t){return(n.x-e.x)*(t.y-e.y)-(t.x-e.x)*(n.y-e.y)}function Br(e,n){let t=0,r,o;for(let s=0;s<n.length;s++){if(r=n[s],r.x===e.x&&r.y===e.y||(o=n[(s+1)%n.length],b.Dist(e,r)+b.Dist(e,o)===b.Dist(r,o)))return!0;r.y<=e.y?o.y>e.y&&Jx(r,o,e)>0&&(t+=1):o.y<=e.y&&Jx(r,o,e)<0&&(t-=1)}return t!==0}function j(e){return+e.toFixed(4)}function pp(e){return+e.toFixed(2)}const eb=e=>Math.abs(e)<Number.MAX_SAFE_INTEGER;function us(e,n,t){return t<0?yu(e,n):xE(e,n)}function Ly(e,n,t,r){let o;if(Math.abs(e)>$e){o=ac(n,r);const s=ac(r,t);return Math.abs(o)<Math.abs(s)?o/e:(e-s)/e}else{o=ac(n,r);const s=o/e;return Math.sign(o)!==Math.sign(e)?Math.abs(s)>.5?1:0:s}}function AR(e,n,t,r){const o=2*((n-e)%De)%De-(n-e)%De;return r?(De-Math.abs(o))*(t?1:-1):o}const sd=({brush:e,color:n,opacity:t,className:r})=>{const o=x.useRef(null);ol(o,e.x,e.y);const s=j(Math.max(1,e.w)),i=j(Math.max(1,e.h));return p.jsx("svg",{className:"tl-overlays__item",ref:o,children:n?p.jsxs("g",{className:"tl-brush",opacity:t,children:[p.jsx("rect",{width:s,height:i,fill:n,opacity:.75}),p.jsx("rect",{width:s,height:i,fill:"none",stroke:n,opacity:.1})]}):p.jsx("rect",{className:`tl-brush tl-brush__default ${r}`,width:s,height:i})})},Co=2e3,fp=40,Mo=320,Yi=[.1,.25,.5,1,2,4,8],Tl=.1,ds=8,jR=.5,OR=.1,DR=.2,RR=.005,LR=.05,NR=450,FR=200,Ny=6,$c=4,zR=32,gp={};for(let e=1;e<=Math.ceil(ds);e++)gp[e+"_dark"]=`hash_pattern_zoom_${e}_dark`,gp[e+"_light"]=`hash_pattern_zoom_${e}_light`;const BR={duration:0,easing:tn.easeInOutCubic},rh=.09,tb=[{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}],UR=6e4,PE=3e3,HR=1200,nb={CAMERA_MOVE:-10},KR=64,VR=620,Ur=8,WR=20,GR=8,YR=12,CE=20,IE=12;var _g={};const XR={},EE=zn("pointerCaptureTrackingObject",{defaults:{all:new Map},shouldStoreForSession:!1}),Ft={preventDefaultLogging:zn("preventDefaultLogging",{defaults:{all:!1}}),pointerCaptureTracking:zn("pointerCaptureTracking",{defaults:{all:!1}}),elementRemovalLogging:zn("elementRemovalLogging",{defaults:{all:!1}}),debugSvg:zn("debugSvg",{defaults:{all:!1}}),showFps:zn("showFps",{defaults:{all:!1}}),throwToBlob:zn("throwToBlob",{defaults:{all:!1}}),resetConnectionEveryPing:zn("resetConnectionEveryPing",{defaults:{all:!1}}),debugCursors:zn("debugCursors",{defaults:{all:!1}}),forceSrgb:zn("forceSrgbColors",{defaults:{all:!1}}),debugGeometry:zn("debugGeometry",{defaults:{all:!1}}),hideShapes:zn("hideShapes",{defaults:{all:!1}}),documentName:zn("documentName",{defaults:{all:!1}})};if(typeof Element<"u"){const e=Element.prototype.removeChild;gu("element removal logging",()=>{Ft.elementRemovalLogging.get()?Element.prototype.removeChild=function(n){return console.warn("[tldraw] removing child:",n),e.call(this,n)}:Element.prototype.removeChild=e})}function zn(e,{defaults:n,shouldStoreForSession:t=!0}){return qR({name:e,defaults:n,shouldStoreForSession:t})}function qR(e){const n=QR(e),t=e.shouldStoreForSession?ZR(e.name):null,r=hn(`debug:${e.name}`,t??n);return typeof window<"u"&&(e.shouldStoreForSession&&gu(`debug:${e.name}`,()=>{const o=r.get();try{o===n?window.sessionStorage.removeItem(`tldraw_debug:${e.name}`):window.sessionStorage.setItem(`tldraw_debug:${e.name}`,JSON.stringify(o))}catch{}}),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 ZR(e){try{return JSON.parse((window==null?void 0:window.sessionStorage.getItem(`tldraw_debug:${e}`))??"null")}catch{return null}}function kg(e){try{return e()}catch{return null}}function QR(e){switch(kg(()=>_g.TLDRAW_ENV)??kg(()=>_g.VERCEL_PUBLIC_TLDRAW_ENV)??kg(()=>_g.NEXT_PUBLIC_TLDRAW_ENV)??"production"){case"production":return e.defaults.production??e.defaults.all;case"preview":case"staging":return e.defaults.staging??e.defaults.all;default:return e.defaults.development??e.defaults.all}}function mp(e){if(e instanceof HTMLElement)return e;if(e.parentElement)return mp(e.parentElement);throw Error("Could not find a parent element of an HTML type!")}function je(e){e.preventDefault(),Ft.preventDefaultLogging.get()&&console.warn("preventDefault called on event:",e)}function Su(e,n){if(e.setPointerCapture(n.pointerId),Ft.pointerCaptureTracking.get()){const t=EE.get();t.set(e,(t.get(e)??0)+1),console.warn("setPointerCapture called on element:",e,n)}}function vu(e,n){if(e.hasPointerCapture(n.pointerId)&&(e.releasePointerCapture(n.pointerId),Ft.pointerCaptureTracking.get())){const t=EE.get();t.get(e)===1?t.delete(e):t.has(e)?t.set(e,t.get(e)-1):console.warn("Release without capture"),console.warn("releasePointerCapture called on element:",e,n)}}const It=e=>e.stopPropagation();function In(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 JR(){const e=F();return x.useMemo(function(){let r,o;function s(g){if(!g.isKilled){if(g.button===2){e.dispatch({type:"pointer",target:"canvas",name:"right_click",...In(g)});return}g.button!==0&&g.button!==1&&g.button!==5||(Su(g.currentTarget,g),e.dispatch({type:"pointer",target:"canvas",name:"pointer_down",...In(g)}),e.getOpenMenus().length>0&&(e.updateInstanceState({openMenus:[]}),document.body.click(),e.getContainer().focus()))}}function i(g){g.isKilled||g.clientX===r&&g.clientY===o||(r=g.clientX,o=g.clientY,e.dispatch({type:"pointer",target:"canvas",name:"pointer_move",...In(g)}))}function a(g){g.isKilled||g.button!==0&&g.button!==1&&g.button!==2&&g.button!==5||(r=g.clientX,o=g.clientY,vu(g.currentTarget,g),e.dispatch({type:"pointer",target:"canvas",name:"pointer_up",...In(g)}))}function l(g){if(g.isKilled||e.getInstanceState().isPenMode&&g.pointerType!=="pen")return;const v=g.pointerType==="mouse"||g.pointerType==="pen";e.updateInstanceState({isHoveringCanvas:v?!0:null})}function c(g){if(g.isKilled||e.getInstanceState().isPenMode&&g.pointerType!=="pen")return;const v=g.pointerType==="mouse"||g.pointerType==="pen";e.updateInstanceState({isHoveringCanvas:v?!1:null})}function u(g){g.isKilled=!0,document.body.click(),je(g)}function d(g){g.isKilled=!0,g.target.tagName!=="A"&&g.target.tagName!=="TEXTAREA"&&je(g)}function h(g){je(g)}async function f(g){var S,w;if(je(g),!((w=(S=g.dataTransfer)==null?void 0:S.files)!=null&&w.length))return;const v=Array.from(g.dataTransfer.files);await e.putExternalContent({type:"files",files:v,point:e.screenToPage({x:g.clientX,y:g.clientY}),ignoreParent:!1})}function y(g){It(g)}return{onPointerDown:s,onPointerMove:i,onPointerUp:a,onPointerEnter:l,onPointerLeave:c,onDragOver:h,onDrop:f,onTouchStart:u,onTouchEnd:d,onClick:y}},[e])}function e3(){const e=F();x.useEffect(()=>{if(e.environment.isFirefox&&!e.environment.isAndroid&&!e.environment.isIos){e.updateInstanceState({isCoarsePointer:!1});return}if(window.matchMedia){const n=window.matchMedia("(pointer: coarse)"),t=()=>{e.updateInstanceState({isCoarsePointer:!!n.matches})};if(t(),n)return n.addEventListener("change",t),()=>n.removeEventListener("change",t)}},[e])}const _E=x.createContext(null);function t3({container:e,children:n}){return p.jsx(_E.Provider,{value:e,children:n})}function mn(){return ai(x.useContext(_E),"useContainer used outside of <Tldraw />")}function n3(){const e=F(),n=mn(),t=K("isFocused",()=>e.getInstanceState().isFocused,[e]);x.useEffect(()=>{if(typeof matchMedia===void 0)return;let r=null;const o=()=>{r!=null&&r();const s=`(resolution: ${window.devicePixelRatio}dppx)`,i=matchMedia(s),a=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]),x.useEffect(()=>{if(!t)return;const r=a=>{if(a.altKey&&(e.isIn("zoom")||!e.getPath().endsWith(".idle"))&&!id()&&je(a),a.isKilled)return;switch(a.isKilled=!0,a.key){case"=":case"-":case"0":{if(a.metaKey||a.ctrlKey){je(a);return}break}case"Tab":{if(id()||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(),n.focus());return}default:if(id()||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,id()||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(n.contains(a.target)){const u=a.touches[0].pageX,d=a.touches[0].radiusX||0;(u-d<10||u+d>e.getViewportScreenBounds().width-10)&&(((l=a.target)==null?void 0:l.tagName)==="BUTTON"&&((c=a.target)==null||c.click()),je(a))}}const i=a=>{n.contains(a.target)&&(a.ctrlKey||a.metaKey)&&je(a)};return n.addEventListener("touchstart",s,{passive:!1}),n.addEventListener("wheel",i,{passive:!1}),document.addEventListener("gesturestart",je),document.addEventListener("gesturechange",je),document.addEventListener("gestureend",je),n.addEventListener("keydown",r),n.addEventListener("keyup",o),()=>{n.removeEventListener("touchstart",s),n.removeEventListener("wheel",i),document.removeEventListener("gesturestart",je),document.removeEventListener("gesturechange",je),document.removeEventListener("gestureend",je),n.removeEventListener("keydown",r),n.removeEventListener("keyup",o)}},[e,n,t])}const r3=["input","select","button","textarea"];function id(){const{activeElement:e}=document;return!!(e&&(e.getAttribute("contenteditable")||r3.indexOf(e.tagName.toLowerCase())>-1))}const o3=["textarea","input"];function s3(e){const n=F();x.useEffect(()=>{const t=e.current;if(!t)return;const r=o=>{var s;if(o instanceof PointerEvent&&o.pointerType==="pen"){o.isKilled=!0;const{target:i}=o;if(o3.includes((s=i.tagName)==null?void 0:s.toLocaleLowerCase())||n.isIn("select.editing_shape"))return;je(o)}};return t.addEventListener("touchstart",r),t.addEventListener("touchend",r),()=>{t.removeEventListener("touchstart",r),t.removeEventListener("touchend",r)}},[n,e])}function i3(e,n,t){return Math.max(n,Math.min(e,t))}const Bt={toVector(e,n){return e===void 0&&(e=n),Array.isArray(e)?e:[e,e]},add(e,n){return[e[0]+n[0],e[1]+n[1]]},sub(e,n){return[e[0]-n[0],e[1]-n[1]]},addTo(e,n){e[0]+=n[0],e[1]+=n[1]},subTo(e,n){e[0]-=n[0],e[1]-=n[1]}};function rb(e,n,t){return n===0||Math.abs(n)===1/0?Math.pow(e,t*5):e*n*t/(n+t*e)}function ob(e,n,t,r=.15){return r===0?i3(e,n,t):e<n?-rb(n-e,t-n,r)+n:e>t?+rb(e-t,t-n,r)+t:e}function a3(e,[n,t],[r,o]){const[[s,i],[a,l]]=e;return[ob(n,s,i,r),ob(t,a,l,o)]}function l3(e,n){if(typeof e!="object"||e===null)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var r=t.call(e,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function c3(e){var n=l3(e,"string");return typeof n=="symbol"?n:String(n)}function Xt(e,n,t){return n=c3(n),n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function sb(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),t.push.apply(t,r)}return t}function it(e){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?sb(Object(t),!0).forEach(function(r){Xt(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):sb(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}const kE={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 ib(e){return e?e[0].toUpperCase()+e.slice(1):""}const u3=["enter","leave"];function d3(e=!1,n){return e&&!u3.includes(n)}function h3(e,n="",t=!1){const r=kE[e],o=r&&r[n]||n;return"on"+ib(e)+ib(o)+(d3(t,o)?"Capture":"")}const p3=["gotpointercapture","lostpointercapture"];function f3(e){let n=e.substring(2).toLowerCase();const t=!!~n.indexOf("passive");t&&(n=n.replace("passive",""));const r=p3.includes(n)?"capturecapture":"capture",o=!!~n.indexOf(r);return o&&(n=n.replace("capture","")),{device:n,capture:o,passive:t}}function g3(e,n=""){const t=kE[e],r=t&&t[n]||n;return e+r}function TE(e){return"touches"in e}function m3(e){return TE(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function y3(e){return Array.from(e.touches).filter(n=>{var t,r;return n.target===e.currentTarget||((t=e.currentTarget)===null||t===void 0||(r=t.contains)===null||r===void 0?void 0:r.call(t,n.target))})}function Fy(e,n){try{const t=n.clientX-e.clientX,r=n.clientY-e.clientY,o=(n.clientX+e.clientX)/2,s=(n.clientY+e.clientY)/2,i=Math.hypot(t,r);return{angle:-(Math.atan2(t,r)*180)/Math.PI,distance:i,origin:[o,s]}}catch{}return null}function S3(e){return y3(e).map(n=>n.identifier)}function ab(e,n){const[t,r]=Array.from(e.touches).filter(o=>n.includes(o.identifier));return Fy(t,r)}const lb=40,cb=800;function $E(e){let{deltaX:n,deltaY:t,deltaMode:r}=e;return r===1?(n*=lb,t*=lb):r===2&&(n*=cb,t*=cb),[n,t]}function v3(e){const n={};if("buttons"in e&&(n.buttons=e.buttons),"shiftKey"in e){const{shiftKey:t,altKey:r,metaKey:o,ctrlKey:s}=e;Object.assign(n,{shiftKey:t,altKey:r,metaKey:o,ctrlKey:s})}return n}function yp(e,...n){return typeof e=="function"?e(...n):e}function w3(){}function x3(...e){return e.length===0?w3:e.length===1?e[0]:function(){let n;for(const t of e)n=t.apply(this,arguments)||n;return n}}function ub(e,n){return Object.assign({},n,e||{})}const b3=32;class ME{constructor(n,t,r){this.ctrl=n,this.args=t,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(n){this.ctrl.state[this.key]=n}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:n,shared:t,ingKey:r,args:o}=this;t[r]=n._active=n.active=n._blocked=n._force=!1,n._step=[!1,!1],n.intentional=!1,n._movement=[0,0],n._distance=[0,0],n._direction=[0,0],n._delta=[0,0],n._bounds=[[-1/0,1/0],[-1/0,1/0]],n.args=o,n.axis=void 0,n.memo=void 0,n.elapsedTime=n.timeDelta=0,n.direction=[0,0],n.distance=[0,0],n.overflow=[0,0],n._movementBound=[!1,!1],n.velocity=[0,0],n.movement=[0,0],n.delta=[0,0],n.timeStamp=0}start(n){const t=this.state,r=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=n.target,t.currentTarget=n.currentTarget,t.lastOffset=r.from?yp(r.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=n.timeStamp)}computeValues(n){const t=this.state;t._values=n,t.values=this.config.transform(n)}computeInitial(){const n=this.state;n._initial=n._values,n.initial=n.values}compute(n){const{state:t,config:r,shared:o}=this;t.args=this.args;let s=0;if(n&&(t.event=n,r.preventDefault&&n.cancelable&&t.event.preventDefault(),t.type=n.type,o.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,o.locked=!!document.pointerLockElement,Object.assign(o,v3(n)),o.down=o.pressed=o.buttons%2===1||o.touches>0,s=n.timeStamp-t.timeStamp,t.timeStamp=n.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const E=t._delta.map(Math.abs);Bt.addTo(t._distance,E)}this.axisIntent&&this.axisIntent(n);const[i,a]=t._movement,[l,c]=r.threshold,{_step:u,values:d}=t;if(r.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(i)>=l&&d[0]),u[1]===!1&&(u[1]=Math.abs(a)>=c&&d[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)),t.intentional=u[0]!==!1||u[1]!==!1,!t.intentional)return;const h=[0,0];if(r.hasCustomTransform){const[E,_]=d;h[0]=u[0]!==!1?E-u[0]:0,h[1]=u[1]!==!1?_-u[1]:0}else h[0]=u[0]!==!1?i-u[0]:0,h[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(h);const f=t.offset,y=t._active&&!t._blocked||t.active;y&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=o[this.ingKey]=t._active,n&&(t.first&&("bounds"in r&&(t._bounds=yp(r.bounds,t)),this.setup&&this.setup()),t.movement=h,this.computeOffset()));const[g,v]=t.offset,[[S,w],[C,I]]=t._bounds;t.overflow=[g<S?-1:g>w?1:0,v<C?-1:v>I?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const P=t._active?r.rubberband||[0,0]:[0,0];if(t.offset=a3(t._bounds,t.offset,P),t.delta=Bt.sub(t.offset,f),this.computeMovement(),y&&(!t.last||s>b3)){t.delta=Bt.sub(t.offset,f);const E=t.delta.map(Math.abs);Bt.addTo(t.distance,E),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&s>0&&(t.velocity=[E[0]/s,E[1]/s],t.timeDelta=s)}}emit(){const n=this.state,t=this.shared,r=this.config;if(n._active||this.clean(),(n._blocked||!n.intentional)&&!n._force&&!r.triggerAllEvents)return;const o=this.handler(it(it(it({},t),n),{},{[this.aliasKey]:n.values}));o!==void 0&&(n.memo=o)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function P3([e,n],t){const r=Math.abs(e),o=Math.abs(n);if(r>o&&r>t)return"x";if(o>r&&o>t)return"y"}class C3 extends ME{constructor(...n){super(...n),Xt(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=Bt.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Bt.sub(this.state.offset,this.state.lastOffset)}axisIntent(n){const t=this.state,r=this.config;if(!t.axis&&n){const o=typeof r.axisThreshold=="object"?r.axisThreshold[m3(n)]:r.axisThreshold;t.axis=P3(t._movement,o)}t._blocked=(r.lockDirection||!!r.axis)&&!t.axis||!!r.axis&&r.axis!==t.axis}restrictToAxis(n){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":n[1]=0;break;case"y":n[0]=0;break}}}const I3=e=>e,db=.15,AE={enabled(e=!0){return e},eventOptions(e,n,t){return it(it({},t.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[db,db];case!1:return[0,0];default:return Bt.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return Bt.toVector(e)},transform(e,n,t){const r=e||t.shared.transform;return this.hasCustomTransform=!!r,r||I3},threshold(e){return Bt.toVector(e,0)}},E3=0,wu=it(it({},AE),{},{axis(e,n,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(e=E3){return e},bounds(e={}){if(typeof e=="function")return s=>wu.bounds(e(s));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:n=-1/0,right:t=1/0,top:r=-1/0,bottom:o=1/0}=e;return[[n,t],[r,o]]}}),xu=typeof window<"u"&&window.document&&window.document.createElement;function jE(){return xu&&"ontouchstart"in window}function _3(){return jE()||xu&&window.navigator.maxTouchPoints>1}function k3(){return xu&&"onpointerdown"in window}function T3(){return xu&&"exitPointerLock"in window.document}function $3(){try{return"constructor"in GestureEvent}catch{return!1}}const lr={isBrowser:xu,gesture:$3(),touch:jE(),touchscreen:_3(),pointer:k3(),pointerLock:T3()},M3=250,A3=180,j3=.5,O3=50,D3=250,R3=10,hb={mouse:0,touch:0,pen:8};it(it({},wu),{},{device(e,n,{pointer:{touch:t=!1,lock:r=!1,mouse:o=!1}={}}){return this.pointerLock=r&&lr.pointerLock,lr.touch&&t?"touch":this.pointerLock?"mouse":lr.pointer&&!o?"pointer":lr.touch?"touch":"mouse"},preventScrollAxis(e,n,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&e?M3:void 0,!(!lr.touchscreen||t===!1))return e||(t!==void 0?"y":void 0)},pointerCapture(e,n,{pointer:{capture:t=!0,buttons:r=1,keys:o=!0}={}}){return this.pointerButtons=r,this.keys=o,!this.pointerLock&&this.device==="pointer"&&t},threshold(e,n,{filterTaps:t=!1,tapsThreshold:r=3,axis:o=void 0}){const s=Bt.toVector(e,t?r:o?1:0);return this.filterTaps=t,this.tapsThreshold=r,s},swipe({velocity:e=j3,distance:n=O3,duration:t=D3}={}){return{velocity:this.transform(Bt.toVector(e)),distance:this.transform(Bt.toVector(n)),duration:t}},delay(e=0){switch(e){case!0:return A3;case!1:return 0;default:return e}},axisThreshold(e){return e?it(it({},hb),e):hb},keyboardDisplacement(e=R3){return e}});function OE(e){const[n,t]=e.overflow,[r,o]=e._delta,[s,i]=e._direction;(n<0&&r>0&&s<0||n>0&&r<0&&s>0)&&(e._movement[0]=e._movementBound[0]),(t<0&&o>0&&i<0||t>0&&o<0&&i>0)&&(e._movement[1]=e._movementBound[1])}const L3=30,N3=100;class F3 extends ME{constructor(...n){super(...n),Xt(this,"ingKey","pinching"),Xt(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const n=this.state;n._touchIds=[],n.canceled=!1,n.cancel=this.cancel.bind(this),n.turns=0}computeOffset(){const{type:n,movement:t,lastOffset:r}=this.state;n==="wheel"?this.state.offset=Bt.add(t,r):this.state.offset=[(1+t[0])*r[0],t[1]+r[1]]}computeMovement(){const{offset:n,lastOffset:t}=this.state;this.state.movement=[n[0]/t[0],n[1]-t[1]]}axisIntent(){const n=this.state,[t,r]=n._movement;if(!n.axis){const o=Math.abs(t)*L3-Math.abs(r);o<0?n.axis="angle":o>0&&(n.axis="scale")}}restrictToAxis(n){this.config.lockDirection&&(this.state.axis==="scale"?n[1]=0:this.state.axis==="angle"&&(n[0]=0))}cancel(){const n=this.state;n.canceled||setTimeout(()=>{n.canceled=!0,n._active=!1,this.compute(),this.emit()},0)}touchStart(n){this.ctrl.setEventIds(n);const t=this.state,r=this.ctrl.touchIds;if(t._active&&t._touchIds.every(s=>r.has(s))||r.size<2)return;this.start(n),t._touchIds=Array.from(r).slice(0,2);const o=ab(n,t._touchIds);o&&this.pinchStart(n,o)}pointerStart(n){if(n.buttons!=null&&n.buttons%2!==1)return;this.ctrl.setEventIds(n),n.target.setPointerCapture(n.pointerId);const t=this.state,r=t._pointerEvents,o=this.ctrl.pointerIds;if(t._active&&Array.from(r.keys()).every(i=>o.has(i))||(r.size<2&&r.set(n.pointerId,n),t._pointerEvents.size<2))return;this.start(n);const s=Fy(...Array.from(r.values()));s&&this.pinchStart(n,s)}pinchStart(n,t){const r=this.state;r.origin=t.origin,this.computeValues([t.distance,t.angle]),this.computeInitial(),this.compute(n),this.emit()}touchMove(n){if(!this.state._active)return;const t=ab(n,this.state._touchIds);t&&this.pinchMove(n,t)}pointerMove(n){const t=this.state._pointerEvents;if(t.has(n.pointerId)&&t.set(n.pointerId,n),!this.state._active)return;const r=Fy(...Array.from(t.values()));r&&this.pinchMove(n,r)}pinchMove(n,t){const r=this.state,o=r._values[1],s=t.angle-o;let i=0;Math.abs(s)>270&&(i+=Math.sign(s)),this.computeValues([t.distance,t.angle-360*i]),r.origin=t.origin,r.turns=i,r._movement=[r._values[0]/r._initial[0]-1,r._values[1]-r._initial[1]],this.compute(n),this.emit()}touchEnd(n){this.ctrl.setEventIds(n),this.state._active&&this.state._touchIds.some(t=>!this.ctrl.touchIds.has(t))&&(this.state._active=!1,this.compute(n),this.emit())}pointerEnd(n){const t=this.state;this.ctrl.setEventIds(n);try{n.target.releasePointerCapture(n.pointerId)}catch{}t._pointerEvents.has(n.pointerId)&&t._pointerEvents.delete(n.pointerId),t._active&&t._pointerEvents.size<2&&(t._active=!1,this.compute(n),this.emit())}gestureStart(n){n.cancelable&&n.preventDefault();const t=this.state;t._active||(this.start(n),this.computeValues([n.scale,n.rotation]),t.origin=[n.clientX,n.clientY],this.compute(n),this.emit())}gestureMove(n){if(n.cancelable&&n.preventDefault(),!this.state._active)return;const t=this.state;this.computeValues([n.scale,n.rotation]),t.origin=[n.clientX,n.clientY];const r=t._movement;t._movement=[n.scale-1,n.rotation],t._delta=Bt.sub(t._movement,r),this.compute(n),this.emit()}gestureEnd(n){this.state._active&&(this.state._active=!1,this.compute(n),this.emit())}wheel(n){const t=this.config.modifierKey;t&&(Array.isArray(t)?!t.find(r=>n[r]):!n[t])||(this.state._active?this.wheelChange(n):this.wheelStart(n),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(n){this.start(n),this.wheelChange(n)}wheelChange(n){"uv"in n||n.cancelable&&n.preventDefault();const r=this.state;r._delta=[-$E(n)[1]/N3*r.offset[0],0],Bt.addTo(r._movement,r._delta),OE(r),this.state.origin=[n.clientX,n.clientY],this.compute(n),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(n){const t=this.config.device;t&&(n(t,"start",this[t+"Start"].bind(this)),n(t,"change",this[t+"Move"].bind(this)),n(t,"end",this[t+"End"].bind(this)),n(t,"cancel",this[t+"End"].bind(this)),n("lostPointerCapture","",this[t+"End"].bind(this))),this.config.pinchOnWheel&&n("wheel","",this.wheel.bind(this),{passive:!1})}}const z3=it(it({},AE),{},{device(e,n,{shared:t,pointer:{touch:r=!1}={}}){if(t.target&&!lr.touch&&lr.gesture)return"gesture";if(lr.touch&&r)return"touch";if(lr.touchscreen){if(lr.pointer)return"pointer";if(lr.touch)return"touch"}},bounds(e,n,{scaleBounds:t={},angleBounds:r={}}){const o=i=>{const a=ub(yp(t,i),{min:-1/0,max:1/0});return[a.min,a.max]},s=i=>{const a=ub(yp(r,i),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof r!="function"?[o(),s()]:i=>[o(i),s(i)]},threshold(e,n,t){return this.lockDirection=t.axis==="lock",Bt.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});it(it({},wu),{},{mouseOnly:(e=!0)=>e});class B3 extends C3{constructor(...n){super(...n),Xt(this,"ingKey","wheeling")}wheel(n){this.state._active||this.start(n),this.wheelChange(n),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(n){const t=this.state;t._delta=$E(n),Bt.addTo(t._movement,t._delta),OE(t),this.compute(n),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(n){n("wheel","",this.wheel.bind(this))}}const U3=wu;it(it({},wu),{},{mouseOnly:(e=!0)=>e});const Wv=new Map,zy=new Map;function H3(e){Wv.set(e.key,e.engine),zy.set(e.key,e.resolver)}const K3={key:"pinch",engine:F3,resolver:z3},V3={key:"wheel",engine:B3,resolver:U3};function W3(e,n){if(e==null)return{};var t={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(n.indexOf(o)>=0)&&(t[o]=e[o]);return t}function G3(e,n){if(e==null)return{};var t=W3(e,n),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(t[r]=e[r])}return t}const Y3={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=lr.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:n=!1}={}){return{passive:e,capture:n}},transform(e){return e}},X3=["target","eventOptions","window","enabled","transform"];function oh(e={},n){const t={};for(const[r,o]of Object.entries(n))switch(typeof o){case"function":t[r]=o.call(t,e[r],r,e);break;case"object":t[r]=oh(e[r],o);break;case"boolean":o&&(t[r]=e[r]);break}return t}function q3(e,n,t={}){const r=e,{target:o,eventOptions:s,window:i,enabled:a,transform:l}=r,c=G3(r,X3);if(t.shared=oh({target:o,eventOptions:s,window:i,enabled:a,transform:l},Y3),n){const u=zy.get(n);t[n]=oh(it({shared:t.shared},c),u)}else for(const u in c){const d=zy.get(u);d&&(t[u]=oh(it({shared:t.shared},c[u]),d))}return t}class DE{constructor(n,t){Xt(this,"_listeners",new Set),this._ctrl=n,this._gestureKey=t}add(n,t,r,o,s){const i=this._listeners,a=g3(t,r),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},c=it(it({},l),s);n.addEventListener(a,o,c);const u=()=>{n.removeEventListener(a,o,c),i.delete(u)};return i.add(u),u}clean(){this._listeners.forEach(n=>n()),this._listeners.clear()}}class Z3{constructor(){Xt(this,"_timeouts",new Map)}add(n,t,r=140,...o){this.remove(n),this._timeouts.set(n,window.setTimeout(t,r,...o))}remove(n){const t=this._timeouts.get(n);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(n=>void window.clearTimeout(n)),this._timeouts.clear()}}class Q3{constructor(n){Xt(this,"gestures",new Set),Xt(this,"_targetEventStore",new DE(this)),Xt(this,"gestureEventStores",{}),Xt(this,"gestureTimeoutStores",{}),Xt(this,"handlers",{}),Xt(this,"config",{}),Xt(this,"pointerIds",new Set),Xt(this,"touchIds",new Set),Xt(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),J3(this,n)}setEventIds(n){if(TE(n))return this.touchIds=new Set(S3(n)),this.touchIds;if("pointerId"in n)return n.type==="pointerup"||n.type==="pointercancel"?this.pointerIds.delete(n.pointerId):n.type==="pointerdown"&&this.pointerIds.add(n.pointerId),this.pointerIds}applyHandlers(n,t){this.handlers=n,this.nativeHandlers=t}applyConfig(n,t){this.config=q3(n,t,this.config)}clean(){this._targetEventStore.clean();for(const n of this.gestures)this.gestureEventStores[n].clean(),this.gestureTimeoutStores[n].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...n){const t=this.config.shared,r={};let o;if(!(t.target&&(o=t.target(),!o))){if(t.enabled){for(const i of this.gestures){const a=this.config[i],l=pb(r,a.eventOptions,!!o);if(a.enabled){const c=Wv.get(i);new c(this,n,i).bind(l)}}const s=pb(r,t.eventOptions,!!o);for(const i in this.nativeHandlers)s(i,"",a=>this.nativeHandlers[i](it(it({},this.state.shared),{},{event:a,args:n})),void 0,!0)}for(const s in r)r[s]=x3(...r[s]);if(!o)return r;for(const s in r){const{device:i,capture:a,passive:l}=f3(s);this._targetEventStore.add(o,i,"",r[s],{capture:a,passive:l})}}}}function Xi(e,n){e.gestures.add(n),e.gestureEventStores[n]=new DE(e,n),e.gestureTimeoutStores[n]=new Z3}function J3(e,n){n.drag&&Xi(e,"drag"),n.wheel&&Xi(e,"wheel"),n.scroll&&Xi(e,"scroll"),n.move&&Xi(e,"move"),n.pinch&&Xi(e,"pinch"),n.hover&&Xi(e,"hover")}const pb=(e,n,t)=>(r,o,s,i={},a=!1)=>{var l,c;const u=(l=i.capture)!==null&&l!==void 0?l:n.capture,d=(c=i.passive)!==null&&c!==void 0?c:n.passive;let h=a?r:h3(r,o,u);t&&d&&(h+="Passive"),e[h]=e[h]||[],e[h].push(s)},eL=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function tL(e){const n={},t={},r=new Set;for(let o in e)eL.test(o)?(r.add(RegExp.lastMatch),t[o]=e[o]):n[o]=e[o];return[t,n,r]}function qi(e,n,t,r,o,s){if(!e.has(t)||!Wv.has(r))return;const i=t+"Start",a=t+"End",l=c=>{let u;return c.first&&i in n&&n[i](c),t in n&&(u=n[t](c)),c.last&&a in n&&n[a](c),u};o[r]=l,s[r]=s[r]||{}}function nL(e,n){const[t,r,o]=tL(e),s={};return qi(o,t,"onDrag","drag",s,n),qi(o,t,"onWheel","wheel",s,n),qi(o,t,"onScroll","scroll",s,n),qi(o,t,"onPinch","pinch",s,n),qi(o,t,"onMove","move",s,n),qi(o,t,"onHover","hover",s,n),{handlers:s,config:n,nativeHandlers:r}}function rL(e,n={},t,r){const o=ie.useMemo(()=>new Q3(e),[]);if(o.applyHandlers(e,r),o.applyConfig(n,t),ie.useEffect(o.effect.bind(o)),ie.useEffect(()=>o.clean.bind(o),[]),n.target===void 0)return o.bind.bind(o)}function oL(e){return e.forEach(H3),function(t,r){const{handlers:o,nativeHandlers:s,config:i}=nL(t,r||{});return rL(o,i,void 0,s)}}const fb=10,sL=/Mac|iPod|iPhone|iPad/.test(typeof window>"u"?"node":window.navigator.platform);function RE(e){let{deltaY:n,deltaX:t}=e,r=0;if(e.ctrlKey||e.altKey||e.metaKey){const o=Math.sign(e.deltaY),s=Math.abs(e.deltaY);let i=n;s>fb&&(i=fb*o),r=i/100}else e.shiftKey&&!sL&&(t=n,n=0);return{x:-t,y:-n,z:-r}}const iL=oL([V3,K3]);let Zi;const aL=e=>Zi===void 0?(Zi=e,!1):e-Zi>120&&e-Zi<160?(Zi=e,!0):(Zi=e,!1);function lL(e){const n=F(),t=x.useMemo(()=>{let r="not sure";const o=({event:g})=>{if(!n.getInstanceState().isFocused||(r="not sure",aL(Date.now())))return;const v=n.getEditingShapeId();if(v){const C=n.getShape(v);if(C&&n.getShapeUtil(C).canScroll(C)){const P=n.getShapePageBounds(v);if(P!=null&&P.containsPoint(n.inputs.currentPagePoint))return}}je(g);const S=RE(g);if(S.x===0&&S.y===0)return;const w={type:"wheel",name:"wheel",delta:S,point:new b(g.clientX,g.clientY),shiftKey:g.shiftKey,altKey:g.altKey,ctrlKey:g.metaKey||g.ctrlKey};n.dispatch(w)};let s=1,i=1,a=1,l=0;const c=new b,u=new b,d=g=>{const v=e.current;r="not sure";const{event:S,origin:w,da:C}=g;S instanceof WheelEvent||(S.target===v||v!=null&&v.contains(S.target))&&(u.x=w[0],u.y=w[1],c.x=w[0],c.y=w[1],s=C[0],i=n.getZoomLevel(),n.dispatch({type:"pinch",name:"pinch_start",point:{x:w[0],y:w[1],z:n.getZoomLevel()},delta:{x:0,y:0},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey}))},h=g=>{if(g&&(r="zooming"),r==="zooming")return;const v=Math.abs(l-s),S=b.Dist(c,u);switch(r){case"not sure":{v>24?r="zooming":S>16&&(r="panning");break}case"panning":{v>64&&(r="zooming");break}}};return{onWheel:o,onPinchStart:d,onPinchEnd:g=>{const v=e.current,{event:S,origin:w,offset:C}=g;if(S instanceof WheelEvent||!(S.target===v||v!=null&&v.contains(S.target)))return;const I=C[0];r="not sure",requestAnimationFrame(()=>{n.dispatch({type:"pinch",name:"pinch_end",point:{x:w[0],y:w[1],z:I},delta:{x:w[0],y:w[1]},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey})})},onPinch:g=>{const v=e.current,{event:S,origin:w,offset:C,da:I}=g;if(S instanceof WheelEvent||!(S.target===v||v!=null&&v.contains(S.target)))return;const P=g.type==="gesturechange"||g.type==="gestureend";l=I[0];const E=w[0]-u.x,_=w[1]-u.y;switch(u.x=w[0],u.y=w[1],h(P),r){case"zooming":{a=C[0],n.dispatch({type:"pinch",name:"pinch",point:{x:w[0],y:w[1],z:a},delta:{x:E,y:_},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey});break}case"panning":{n.dispatch({type:"pinch",name:"pinch",point:{x:w[0],y:w[1],z:i},delta:{x:E,y:_},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey});break}}}}},[n,e]);iL(t,{target:e,eventOptions:{passive:!1},pinch:{from:()=>[n.getZoomLevel(),0],scaleBounds:()=>({from:n.getZoomLevel(),max:8,min:.05})}})}function Tg(e,n,t){const r=e.getShape(n),o=e.getShapeHandles(r);return{shape:r,handle:o.find(s=>s.id===t)}}function cL(e,n){const t=F();return x.useMemo(()=>{const r=l=>{if(l.isKilled)return;const c=mp(l.currentTarget);Su(c,l);const{shape:u,handle:d}=Tg(t,e,n);d&&t.dispatch({type:"pointer",target:"handle",handle:d,shape:u,name:"pointer_down",...In(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}=Tg(t,e,n);u&&t.dispatch({type:"pointer",target:"handle",handle:u,shape:c,name:"pointer_move",...In(l)})},onPointerUp:l=>{if(l.isKilled)return;const c=mp(l.currentTarget);vu(c,l);const{shape:u,handle:d}=Tg(t,e,n);d&&t.dispatch({type:"pointer",target:"handle",handle:d,shape:u,name:"pointer_up",...In(l)})}}},[t,e,n])}var LE="Expected a function",gb=NaN,uL="[object Symbol]",dL=/^\s+|\s+$/g,hL=/^[-+]0x[0-9a-f]+$/i,pL=/^0b[01]+$/i,fL=/^0o[0-7]+$/i,gL=parseInt,mL=typeof en=="object"&&en&&en.Object===Object&&en,yL=typeof self=="object"&&self&&self.Object===Object&&self,SL=mL||yL||Function("return this")(),vL=Object.prototype,wL=vL.toString,xL=Math.max,bL=Math.min,$g=function(){return SL.Date.now()};function PL(e,n,t){var r,o,s,i,a,l,c=0,u=!1,d=!1,h=!0;if(typeof e!="function")throw new TypeError(LE);n=mb(n)||0,Sp(t)&&(u=!!t.leading,d="maxWait"in t,s=d?xL(mb(t.maxWait)||0,n):s,h="trailing"in t?!!t.trailing:h);function f(E){var _=r,k=o;return r=o=void 0,c=E,i=e.apply(k,_),i}function y(E){return c=E,a=setTimeout(S,n),u?f(E):i}function g(E){var _=E-l,k=E-c,M=n-_;return d?bL(M,s-k):M}function v(E){var _=E-l,k=E-c;return l===void 0||_>=n||_<0||d&&k>=s}function S(){var E=$g();if(v(E))return w(E);a=setTimeout(S,g(E))}function w(E){return a=void 0,h&&r?f(E):(r=o=void 0,i)}function C(){a!==void 0&&clearTimeout(a),c=0,r=l=o=a=void 0}function I(){return a===void 0?i:w($g())}function P(){var E=$g(),_=v(E);if(r=arguments,o=this,l=E,_){if(a===void 0)return y(l);if(d)return a=setTimeout(S,n),f(l)}return a===void 0&&(a=setTimeout(S,n)),i}return P.cancel=C,P.flush=I,P}function CL(e,n,t){var r=!0,o=!0;if(typeof e!="function")throw new TypeError(LE);return Sp(t)&&(r="leading"in t?!!t.leading:r,o="trailing"in t?!!t.trailing:o),PL(e,n,{leading:r,maxWait:n,trailing:o})}function Sp(e){var n=typeof e;return!!e&&(n=="object"||n=="function")}function IL(e){return!!e&&typeof e=="object"}function EL(e){return typeof e=="symbol"||IL(e)&&wL.call(e)==uL}function mb(e){if(typeof e=="number")return e;if(EL(e))return gb;if(Sp(e)){var n=typeof e.valueOf=="function"?e.valueOf():e;e=Sp(n)?n+"":n}if(typeof e!="string")return e===0?e:+e;e=e.replace(dL,"");var t=pL.test(e);return t||fL.test(e)?gL(e.slice(2),t?2:8):hL.test(e)?gb:+e}var _L=CL;const kL=el(_L),Je=class Je{constructor(n=0,t=0,r=0,o=0){m(this,"x",0);m(this,"y",0);m(this,"w",0);m(this,"h",0);this.x=n,this.y=t,this.w=r,this.h=o}get point(){return new b(this.x,this.y)}set point(n){this.x=n.x,this.y=n.y}get minX(){return this.x}set minX(n){this.x=n}get midX(){return this.x+this.w/2}get maxX(){return this.x+this.w}get minY(){return this.y}set minY(n){this.y=n}get midY(){return this.y+this.h/2}get maxY(){return this.y+this.h}get width(){return this.w}set width(n){this.w=n}get height(){return this.h}set height(n){this.h=n}get aspectRatio(){return this.width/this.height}get center(){return new b(this.midX,this.midY)}set center(n){this.minX=n.x-this.width/2,this.minY=n.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:n}=this;return[[n[0],n[1]],[n[1],n[2]],[n[2],n[3]],[n[3],n[0]]]}get size(){return new b(this.w,this.h)}toFixed(){return this.x=od(this.x),this.y=od(this.y),this.w=od(this.w),this.h=od(this.h),this}setTo(n){return this.x=n.x,this.y=n.y,this.w=n.w,this.h=n.h,this}set(n=0,t=0,r=0,o=0){return this.x=n,this.y=t,this.w=r,this.h=o,this}expand(n){const t=Math.min(this.minX,n.minX),r=Math.min(this.minY,n.minY),o=Math.max(this.maxX,n.maxX),s=Math.max(this.maxY,n.maxY);return this.x=t,this.y=r,this.w=o-t,this.h=s-r,this}expandBy(n){return this.x-=n,this.y-=n,this.w+=n*2,this.h+=n*2,this}scale(n){return this.x/=n,this.y/=n,this.w/=n,this.h/=n,this}clone(){const{x:n,y:t,w:r,h:o}=this;return new Je(n,t,r,o)}translate(n){return this.x+=n.x,this.y+=n.y,this}snapToGrid(n){const t=Math.round(this.minX/n)*n,r=Math.round(this.minY/n)*n,o=Math.round(this.maxX/n)*n,s=Math.round(this.maxY/n)*n;this.minX=t,this.minY=r,this.width=Math.max(1,o-t),this.height=Math.max(1,s-r)}collides(n){return Je.Collides(this,n)}contains(n){return Je.Contains(this,n)}includes(n){return Je.Includes(this,n)}containsPoint(n,t=0){return Je.ContainsPoint(this,n,t)}getHandlePoint(n){switch(n){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(n,t,r){const{minX:o,minY:s,maxX:i,maxY:a}=this;let{minX:l,minY:c,maxX:u,maxY:d}=this;switch(n){case"left":case"top_left":case"bottom_left":{l+=t;break}case"right":case"top_right":case"bottom_right":{u+=t;break}}switch(n){case"top":case"top_left":case"top_right":{c+=r;break}case"bottom":case"bottom_left":case"bottom_right":{d+=r;break}}const h=(u-l)/(i-o),f=(d-c)/(a-s),y=h<0,g=f<0;if(y){const v=u;u=l,l=v}if(g){const v=d;d=c,c=v}this.minX=l,this.minY=c,this.width=Math.abs(u-l),this.height=Math.abs(d-c)}union(n){const t=Math.min(this.minX,n.x),r=Math.min(this.minY,n.y),o=Math.max(this.maxX,n.w+n.x),s=Math.max(this.maxY,n.h+n.y);return this.x=t,this.y=r,this.width=o-t,this.height=s-r,this}static From(n){return new Je(n.x,n.y,n.w,n.h)}static FromCenter(n,t){return new Je(n.x-t.x/2,n.y-t.y/2,t.x,t.y)}static FromPoints(n){if(n.length===0)return new Je;let t=1/0,r=1/0,o=-1/0,s=-1/0,i;for(let a=0,l=n.length;a<l;a++)i=n[a],t=Math.min(i.x,t),r=Math.min(i.y,r),o=Math.max(i.x,o),s=Math.max(i.y,s);return new Je(t,r,o-t,s-r)}static Expand(n,t){const r=Math.min(t.minX,n.minX),o=Math.min(t.minY,n.minY),s=Math.max(t.maxX,n.maxX),i=Math.max(t.maxY,n.maxY);return new Je(r,o,s-r,i-o)}static ExpandBy(n,t){return new Je(n.minX-t,n.minY-t,n.width+t*2,n.height+t*2)}static Resize(n,t,r,o,s=!1){const{minX:i,minY:a,maxX:l,maxY:c}=n;let{minX:u,minY:d,maxX:h,maxY:f}=n;switch(t){case"left":case"top_left":case"bottom_left":{u+=r;break}case"right":case"top_right":case"bottom_right":{h+=r;break}}switch(t){case"top":case"top_left":case"top_right":{d+=o;break}case"bottom":case"bottom_left":case"bottom_right":{f+=o;break}}const y=(h-u)/(l-i),g=(f-d)/(c-a),v=y<0,S=g<0;if(s){const C=(l-i)/(c-a),I=Math.abs(h-u),P=Math.abs(f-d),E=I*(g<0?1:-1)*(1/C),_=P*(y<0?1:-1)*C,k=C<I/P;switch(t){case"top_left":{k?d=f+E:u=h+_;break}case"top_right":{k?d=f+E:h=u-_;break}case"bottom_right":{k?f=d-E:h=u-_;break}case"bottom_left":{k?f=d-E:u=h+_;break}case"bottom":case"top":{const M=(u+h)/2,T=P*C;u=M-T/2,h=M+T/2;break}case"left":case"right":{const M=(d+f)/2,T=I/C;d=M-T/2,f=M+T/2;break}}}if(v){const C=h;h=u,u=C}if(S){const C=f;f=d,d=C}const w=new Je(u,d,Math.abs(h-u),Math.abs(f-d));return{box:w,scaleX:+(w.width/n.width*(y>0?1:-1)).toFixed(5),scaleY:+(w.height/n.height*(g>0?1:-1)).toFixed(5)}}equals(n){return Je.Equals(this,n)}static Equals(n,t){return t.x===n.x&&t.y===n.y&&t.w===n.w&&t.h===n.h}zeroFix(){return this.w=Math.max(1,this.w),this.h=Math.max(1,this.h),this}static ZeroFix(n){return new Je(n.x,n.y,Math.max(1,n.w),Math.max(1,n.h))}};m(Je,"Collides",(n,t)=>!(n.maxX<t.minX||n.minX>t.maxX||n.maxY<t.minY||n.minY>t.maxY)),m(Je,"Contains",(n,t)=>n.minX<t.minX&&n.minY<t.minY&&n.maxY>t.maxY&&n.maxX>t.maxX),m(Je,"Includes",(n,t)=>Je.Collides(n,t)||Je.Contains(n,t)),m(Je,"ContainsPoint",(n,t,r=0)=>!(t.x<n.minX-r||t.y<n.minY-r||t.x>n.maxX+r||t.y>n.maxY+r)),m(Je,"Common",n=>{let t=1/0,r=1/0,o=-1/0,s=-1/0;for(let i=0;i<n.length;i++){const a=n[i];t=Math.min(t,a.minX),r=Math.min(r,a.minY),o=Math.max(o,a.maxX),s=Math.max(s,a.maxY)}return new Je(t,r,o-t,s-r)}),m(Je,"Sides",(n,t=0)=>{const{corners:r}=n;return[[r[0],r[1]],[r[1],r[2]],[r[2],r[3]],[r[3],r[0]]]});let ne=Je;function TL(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 $L(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 ML(e){return e==="top_left"||e==="top_right"||e==="bottom_right"||e==="bottom_left"}function AL(e){const n=F();x.useLayoutEffect(()=>{function t(){const l=e.current;if(!l)return null;const c=l.getBoundingClientRect();n.updateViewportScreenBounds(new ne(c.left||c.x,c.top||c.y,Math.max(c.width,1),Math.max(c.height,1)))}t();const r=kL(t,200,{trailing:!0}),o=setInterval(r,1e3);window.addEventListener("resize",r);const s=new ResizeObserver(l=>{l[0].contentRect&&r()}),i=e.current;let a=null;return i&&(s.observe(i),a=jL(i),a.addEventListener("scroll",r)),()=>{clearInterval(o),window.removeEventListener("resize",r),s.disconnect(),a==null||a.removeEventListener("scroll",r)}},[n,e])}/*!
|
|
44
|
+
* Author: excalidraw
|
|
45
|
+
* MIT License: https://github.com/excalidraw/excalidraw/blob/master/LICENSE
|
|
46
|
+
* https://github.com/excalidraw/excalidraw/blob/48c3465b19f10ec755b3eb84e21a01a468e96e43/packages/excalidraw/utils.ts#L600
|
|
47
|
+
*/const jL=e=>{let n=e.parentElement;for(;n;){if(n===document.body)return document;const{overflowY:t}=window.getComputedStyle(n);if(n.scrollHeight>n.clientHeight&&(t==="auto"||t==="scroll"||t==="overlay"))return n;n=n.parentElement}return document},Te=class Te{constructor(n,t,r,o,s,i){m(this,"a",1);m(this,"b",0);m(this,"c",0);m(this,"d",1);m(this,"e",0);m(this,"f",0);this.a=n,this.b=t,this.c=r,this.d=o,this.e=s,this.f=i}equals(n){return this.a===n.a&&this.b===n.b&&this.c===n.c&&this.d===n.d&&this.e===n.e&&this.f===n.f}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this}multiply(n){const t=n,{a:r,b:o,c:s,d:i,e:a,f:l}=this;return this.a=r*t.a+s*t.b,this.c=r*t.c+s*t.d,this.e=r*t.e+s*t.f+a,this.b=o*t.a+i*t.b,this.d=o*t.c+i*t.d,this.f=o*t.e+i*t.f+l,this}rotate(n,t,r){return n===0?this:t===void 0?this.multiply(Te.Rotate(n)):this.translate(t,r).multiply(Te.Rotate(n)).translate(-t,-r)}translate(n,t){return this.multiply(Te.Translate(n,t))}scale(n,t){return this.multiply(Te.Scale(n,t))}invert(){const{a:n,b:t,c:r,d:o,e:s,f:i}=this,a=n*o-t*r;return this.a=o/a,this.b=t/-a,this.c=r/-a,this.d=n/a,this.e=(o*s-r*i)/-a,this.f=(t*s-n*i)/a,this}applyToPoint(n){return Te.applyToPoint(this,n)}applyToPoints(n){return Te.applyToPoints(this,n)}rotation(){return Te.Rotation(this)}point(){return Te.Point(this)}decomposed(){return Te.Decompose(this)}toCssString(){return Te.toCssString(this)}setTo(n){return Object.assign(this,n),this}decompose(){return Te.Decompose(this)}clone(){return new Te(this.a,this.b,this.c,this.d,this.e,this.f)}static Identity(){return new Te(1,0,0,1,0,0)}static Translate(n,t){return new Te(1,0,0,1,n,t)}static Rotate(n,t,r){if(n===0)return Te.Identity();const o=Math.cos(n),s=Math.sin(n),i=new Te(o,s,-s,o,0,0);return t===void 0?i:Te.Compose(Te.Translate(t,r),i,Te.Translate(-t,-r))}static Multiply(n,t){return{a:n.a*t.a+n.c*t.b,c:n.a*t.c+n.c*t.d,e:n.a*t.e+n.c*t.f+n.e,b:n.b*t.a+n.d*t.b,d:n.b*t.c+n.d*t.d,f:n.b*t.e+n.d*t.f+n.f}}static Inverse(n){const t=n.a*n.d-n.b*n.c;return{a:n.d/t,b:n.b/-t,c:n.c/-t,d:n.a/t,e:(n.d*n.e-n.c*n.f)/-t,f:(n.b*n.e-n.a*n.f)/t}}static Absolute(n){const t=n.a*n.d-n.b*n.c;return{a:n.d/t,b:n.b/-t,c:n.c/-t,d:n.a/t,e:(n.d*n.e-n.c*n.f)/t,f:(n.b*n.e-n.a*n.f)/-t}}static Compose(...n){const t=Te.Identity();for(let r=0,o=n.length;r<o;r++)t.multiply(n[r]);return t}static Point(n){return new b(n.e,n.f)}static Rotation(n){let t;if(n.a!==0||n.c!==0){const r=Math.hypot(n.a,n.c);t=Math.acos(n.a/r)*(n.c>0?-1:1)}else if(n.b!==0||n.d!==0){const r=Math.hypot(n.b,n.d);t=Ke+Math.acos(n.b/r)*(n.d>0?-1:1)}else t=0;return Ry(t)}static Decompose(n){let t,r,o;if(n.a!==0||n.c!==0){const s=Math.hypot(n.a,n.c);t=s,r=(n.a*n.d-n.b*n.c)/s,o=Math.acos(n.a/s)*(n.c>0?-1:1)}else if(n.b!==0||n.d!==0){const s=Math.hypot(n.b,n.d);t=(n.a*n.d-n.b*n.c)/s,r=s,o=Ke+Math.acos(n.b/s)*(n.d>0?-1:1)}else t=0,r=0,o=0;return{x:n.e,y:n.f,scaleX:t,scaleY:r,rotation:Ry(o)}}static Smooth(n,t=1e10){return n.a=Math.round(n.a*t)/t,n.b=Math.round(n.b*t)/t,n.c=Math.round(n.c*t)/t,n.d=Math.round(n.d*t)/t,n.e=Math.round(n.e*t)/t,n.f=Math.round(n.f*t)/t,n}static toCssString(n){return`matrix(${j(n.a)}, ${j(n.b)}, ${j(n.c)}, ${j(n.d)}, ${j(n.e)}, ${j(n.f)})`}static applyToPoint(n,t){return new b(n.a*t.x+n.c*t.y+n.e,n.b*t.x+n.d*t.y+n.f,t.z)}static applyToXY(n,t,r){return[n.a*t+n.c*r+n.e,n.b*t+n.d*r+n.f]}static applyToPoints(n,t){return t.map(r=>new b(n.a*r.x+n.c*r.y+n.e,n.b*r.x+n.d*r.y+n.f,r.z))}static applyToBounds(n,t){return new ne(n.e+t.minX,n.f+t.minY,t.width,t.height)}static From(n){return new Te(n.a,n.b,n.c,n.d,n.e,n.f)}static Cast(n){return n instanceof Te?n:Te.From(n)}};m(Te,"Scale",(n,t,r,o)=>{const s=new Te(n,0,0,t,0,0);return r===void 0?s:Te.Compose(Te.Translate(r,o),s,Te.Translate(-r,-o))});let re=Te;class ji{constructor(n){m(this,"isFilled",!1);m(this,"isClosed",!0);m(this,"isLabel",!1);m(this,"debugColor");m(this,"ignore");m(this,"_vertices");m(this,"_bounds");m(this,"_area");this.isFilled=n.isFilled,this.isClosed=n.isClosed,this.isLabel=n.isLabel??!1,this.debugColor=n.debugColor,this.ignore=n.ignore}hitTestPoint(n,t=0,r=!1){return this.distanceToPoint(n,r)<=t}distanceToPoint(n,t=!1){const r=n.dist(this.nearestPoint(n));return this.isClosed&&(this.isFilled||t)&&Br(n,this.vertices)?-r:r}distanceToLineSegment(n,t){const r=this.nearestPointOnLineSegment(n,t),o=b.DistanceToLineSegment(n,t,r);return this.isClosed&&this.isFilled&&Br(r,this.vertices)?-o:o}hitTestLineSegment(n,t,r=0){return this.distanceToLineSegment(n,t)<=r}nearestPointOnLineSegment(n,t){let r=1/0,o;for(let s=0;s<this.vertices.length;s++){const i=this.vertices[s],a=b.DistanceToLineSegment(n,t,i);a<r&&(r=a,o=i)}if(!o)throw Error("nearest point not found");return o}isPointInBounds(n,t=0){const{bounds:r}=this;return!(n.x<r.minX-t||n.y<r.minY-t||n.x>r.maxX+t||n.y>r.maxY+t)}get vertices(){return this._vertices||(this._vertices=this.getVertices()),this._vertices}getBounds(){return ne.FromPoints(this.vertices)}get bounds(){return this._bounds||(this._bounds=this.getBounds()),this._bounds}get center(){return this.bounds.center}get area(){return this._area||(this._area=this.getArea()),this._area}getArea(){if(!this.isClosed)return 0;const{vertices:n}=this;let t=0;for(let r=0,o=n.length;r<o;r++){const s=n[r],i=n[(r+1)%o];t+=s.x*i.y-i.x*s.y}return t/2}toSimpleSvgPath(){let n="";const{vertices:t}=this,r=t.length;if(r===0)return n;n+=`M${t[0].x},${t[0].y}`;for(let o=1;o<r;o++)n+=`L${t[o].x},${t[o].y}`;return this.isClosed&&(n+="Z"),n}}class no extends ji{constructor(t){super({...t,isClosed:!0,isFilled:!1});m(this,"children",[]);m(this,"ignoredChildren",[]);for(const r of t.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(t=>!t.isLabel).flatMap(t=>t.vertices)}nearestPoint(t){let r=1/0,o;const{children:s}=this;if(s.length===0)throw Error("no children");for(const i of s){const a=i.nearestPoint(t),l=a.dist(t);l<r&&(r=l,o=a)}if(!o)throw Error("nearest point not found");return o}distanceToPoint(t,r=!1){return Math.min(...this.children.map((o,s)=>o.distanceToPoint(t,r||s>0)))}hitTestPoint(t,r,o){return!!this.children.filter(s=>!s.isLabel).find(s=>s.hitTestPoint(t,r,o))}hitTestLineSegment(t,r,o){return!!this.children.filter(s=>!s.isLabel).find(s=>s.hitTestLineSegment(t,r,o))}getArea(){return this.children[0].area}toSimpleSvgPath(){let t="";for(const o of this.children)t+=o.toSimpleSvgPath();const r=ne.FromPoints(this.vertices).corners;for(let o=0,s=r.length;o<s;o++){const i=r[o],a=r[(o-1+s)%s],l=i.dist(a),c=r[(o+1)%s],u=i.dist(c),d=i.clone().lrp(a,4/l),h=i,f=i.clone().lrp(c,4/u);t+=`M${d.x},${d.y} L${h.x},${h.y} L${f.x},${f.y} `}return t}}function OL(e=!0){const[n,t]=x.useState(0),r=F();x.useEffect(()=>{if(!e)return;const o=()=>t(s=>s+1);return r.on("tick",o),()=>{r.off("tick",o)}},[r,e])}const DL=Tt(function({showStroke:n=!0,showVertices:t=!0,showClosestPointOnOutline:r=!0}){const o=F();OL(r);const s=o.getZoomLevel(),i=o.getRenderingShapes(),{inputs:{currentPagePoint:a}}=o;return p.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),d=o.getShapePageTransform(c),h=o.getPointInShapeSpace(c,a),f=u.nearestPoint(h),y=u.distanceToPoint(h,!0),g=Math.abs(y)*s,v=y<0,{vertices:S}=u;return p.jsxs("g",{transform:d.toCssString(),strokeLinecap:"round",strokeLinejoin:"round",children:[n&&p.jsx(NE,{geometry:u}),t&&S.map((w,C)=>p.jsx("circle",{cx:w.x,cy:w.y,r:"2",fill:`hsl(${tp(C,[0,S.length-1],[120,200])}, 100%, 50%)`,stroke:"black",strokeWidth:"1"},`v${C}`)),r&&g<150&&p.jsx("line",{x1:f.x,y1:f.y,x2:h.x,y2:h.y,opacity:1-g/150,stroke:v?"goldenrod":"dodgerblue",strokeWidth:"2"})]},l.id+"_outline")})})});function NE({geometry:e}){return e instanceof no?p.jsx(p.Fragment,{children:[...e.children,...e.ignoredChildren].map((n,t)=>p.jsx(NE,{geometry:n},t))}):p.jsx("path",{stroke:e.debugColor??"red",strokeWidth:"2",fill:"none",opacity:"1",d:e.toSimpleSvgPath()})}var RL=200,Gv="__lodash_hash_undefined__",LL=1/0,NL="[object Function]",FL="[object GeneratorFunction]",zL=/[\\^$.*+?()[\]{}|]/g,BL=/^\[object .+?Constructor\]$/,UL=typeof en=="object"&&en&&en.Object===Object&&en,HL=typeof self=="object"&&self&&self.Object===Object&&self,Yv=UL||HL||Function("return this")();function KL(e,n){var t=e?e.length:0;return!!t&&GL(e,n,0)>-1}function VL(e,n,t){for(var r=-1,o=e?e.length:0;++r<o;)if(t(n,e[r]))return!0;return!1}function WL(e,n,t,r){for(var o=e.length,s=t+(r?1:-1);r?s--:++s<o;)if(n(e[s],s,e))return s;return-1}function GL(e,n,t){if(n!==n)return WL(e,YL,t);for(var r=t-1,o=e.length;++r<o;)if(e[r]===n)return r;return-1}function YL(e){return e!==e}function XL(e,n){return e.has(n)}function qL(e,n){return e==null?void 0:e[n]}function ZL(e){var n=!1;if(e!=null&&typeof e.toString!="function")try{n=!!(e+"")}catch{}return n}function FE(e){var n=-1,t=Array(e.size);return e.forEach(function(r){t[++n]=r}),t}var QL=Array.prototype,JL=Function.prototype,zE=Object.prototype,Mg=Yv["__core-js_shared__"],yb=function(){var e=/[^.]+$/.exec(Mg&&Mg.keys&&Mg.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),BE=JL.toString,Xv=zE.hasOwnProperty,e5=zE.toString,t5=RegExp("^"+BE.call(Xv).replace(zL,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),n5=QL.splice,r5=qv(Yv,"Map"),Ag=qv(Yv,"Set"),Mc=qv(Object,"create");function vi(e){var n=-1,t=e?e.length:0;for(this.clear();++n<t;){var r=e[n];this.set(r[0],r[1])}}function o5(){this.__data__=Mc?Mc(null):{}}function s5(e){return this.has(e)&&delete this.__data__[e]}function i5(e){var n=this.__data__;if(Mc){var t=n[e];return t===Gv?void 0:t}return Xv.call(n,e)?n[e]:void 0}function a5(e){var n=this.__data__;return Mc?n[e]!==void 0:Xv.call(n,e)}function l5(e,n){var t=this.__data__;return t[e]=Mc&&n===void 0?Gv:n,this}vi.prototype.clear=o5;vi.prototype.delete=s5;vi.prototype.get=i5;vi.prototype.has=a5;vi.prototype.set=l5;function sl(e){var n=-1,t=e?e.length:0;for(this.clear();++n<t;){var r=e[n];this.set(r[0],r[1])}}function c5(){this.__data__=[]}function u5(e){var n=this.__data__,t=pf(n,e);if(t<0)return!1;var r=n.length-1;return t==r?n.pop():n5.call(n,t,1),!0}function d5(e){var n=this.__data__,t=pf(n,e);return t<0?void 0:n[t][1]}function h5(e){return pf(this.__data__,e)>-1}function p5(e,n){var t=this.__data__,r=pf(t,e);return r<0?t.push([e,n]):t[r][1]=n,this}sl.prototype.clear=c5;sl.prototype.delete=u5;sl.prototype.get=d5;sl.prototype.has=h5;sl.prototype.set=p5;function il(e){var n=-1,t=e?e.length:0;for(this.clear();++n<t;){var r=e[n];this.set(r[0],r[1])}}function f5(){this.__data__={hash:new vi,map:new(r5||sl),string:new vi}}function g5(e){return ff(this,e).delete(e)}function m5(e){return ff(this,e).get(e)}function y5(e){return ff(this,e).has(e)}function S5(e,n){return ff(this,e).set(e,n),this}il.prototype.clear=f5;il.prototype.delete=g5;il.prototype.get=m5;il.prototype.has=y5;il.prototype.set=S5;function vp(e){var n=-1,t=e?e.length:0;for(this.__data__=new il;++n<t;)this.add(e[n])}function v5(e){return this.__data__.set(e,Gv),this}function w5(e){return this.__data__.has(e)}vp.prototype.add=vp.prototype.push=v5;vp.prototype.has=w5;function pf(e,n){for(var t=e.length;t--;)if(k5(e[t][0],n))return t;return-1}function x5(e){if(!UE(e)||I5(e))return!1;var n=T5(e)||ZL(e)?t5:BL;return n.test(E5(e))}function b5(e,n,t){var r=-1,o=KL,s=e.length,i=!0,a=[],l=a;if(t)i=!1,o=VL;else if(s>=RL){var c=n?null:P5(e);if(c)return FE(c);i=!1,o=XL,l=new vp}else l=n?[]:a;e:for(;++r<s;){var u=e[r],d=n?n(u):u;if(u=t||u!==0?u:0,i&&d===d){for(var h=l.length;h--;)if(l[h]===d)continue e;n&&l.push(d),a.push(u)}else o(l,d,t)||(l!==a&&l.push(d),a.push(u))}return a}var P5=Ag&&1/FE(new Ag([,-0]))[1]==LL?function(e){return new Ag(e)}:$5;function ff(e,n){var t=e.__data__;return C5(n)?t[typeof n=="string"?"string":"hash"]:t.map}function qv(e,n){var t=qL(e,n);return x5(t)?t:void 0}function C5(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}function I5(e){return!!yb&&yb in e}function E5(e){if(e!=null){try{return BE.call(e)}catch{}try{return e+""}catch{}}return""}function _5(e){return e&&e.length?b5(e):[]}function k5(e,n){return e===n||e!==e&&n!==n}function T5(e){var n=UE(e)?e5.call(e):"";return n==NL||n==FL}function UE(e){var n=typeof e;return!!e&&(n=="object"||n=="function")}function $5(){}var M5=_5;const A5=el(M5);function HE(e){return A5(e)}function j5(){const e=F(),n=x.useMemo(()=>e.store.query.records("instance_presence",()=>({userId:{neq:e.user.getId()}})),[e]),t=EI("userIds",()=>HE(n.get().map(r=>r.userId)).sort(),{isEqual:(r,o)=>{var s;return r.join(",")===((s=o.join)==null?void 0:s.call(o,","))}},[n]);return K(t)}function KE(e){const n=F(),t=x.useMemo(()=>n.store.query.records("instance_presence",()=>({userId:{eq:e}})),[n,e]);return K(`latestPresence:${e}`,()=>t.get().slice().sort((o,s)=>s.lastActivityTimestamp-o.lastActivityTimestamp)[0],[])??null}const O5=Tt(function(){const n=j5();return p.jsx(p.Fragment,{children:n.map(t=>p.jsx(D5,{collaboratorId:t},t))})}),D5=Tt(function({collaboratorId:n}){const t=F(),r=KE(n),o=L5(r);if(!(r&&r.currentPageId===t.getCurrentPageId()))return null;switch(o){case"inactive":{const{followingUserId:s,highlightedUserIds:i}=t.getInstanceState();if(!(s===r.userId||i.includes(r.userId)))return null;break}case"idle":{const{highlightedUserIds:s}=t.getInstanceState();if(r.followingUserId===t.user.getId()&&!(r.chatMessage||s.includes(r.userId)))return null;break}}return p.jsx(R5,{latestPresence:r})}),R5=Tt(function({latestPresence:n}){const t=F(),{CollaboratorBrush:r,CollaboratorScribble:o,CollaboratorCursor:s,CollaboratorHint:i,CollaboratorShapeIndicator:a}=Ge(),l=t.getZoomLevel(),c=t.getViewportPageBounds(),{userId:u,chatMessage:d,brush:h,scribbles:f,selectedShapeIds:y,userName:g,cursor:v,color:S}=n,w=!(v.x<c.minX-12/l||v.y<c.minY-16/l||v.x>c.maxX-12/l||v.y>c.maxY-16/l);return p.jsxs(p.Fragment,{children:[h&&r?p.jsx(r,{className:"tl-collaborator__brush",brush:h,color:S,opacity:.1},u+"_brush"):null,w&&s?p.jsx(s,{className:"tl-collaborator__cursor",point:v,color:S,zoom:l,name:g!=="New User"?g:null,chatMessage:d},u+"_cursor"):i?p.jsx(i,{className:"tl-collaborator__cursor-hint",point:v,color:S,zoom:l,viewport:c},u+"_cursor_hint"):null,o&&f.length?p.jsx(p.Fragment,{children:f.map(C=>p.jsx(o,{className:"tl-collaborator__scribble",scribble:C,color:S,zoom:l,opacity:C.color==="laser"?.5:.1},u+"_scribble_"+C.id))}):null,a&&y.map(C=>p.jsx(a,{className:"tl-collaborator__shape-indicator",shapeId:C,color:S,opacity:.5},u+"_"+C))]})});function Sb(e){return e>UR?"inactive":e>PE?"idle":"active"}function L5(e){const n=x.useRef((e==null?void 0:e.lastActivityTimestamp)??-1),[t,r]=x.useState(()=>Sb(Date.now()-n.current));return x.useEffect(()=>{const o=setInterval(()=>{r(Sb(Date.now()-n.current))},HR);return()=>clearInterval(o)},[]),e&&(n.current=e.lastActivityTimestamp),t}function VE(e,n){return n===0?e:VE(n,e%n)}function N5(e){const n=e.toString().split(".")[1];if(!n)return 1;const t=Math.pow(10,n.length),r=parseInt(n,10);return t/VE(r,t)}const WE=Tt(function({id:n,shape:t,util:r,index:o,backgroundIndex:s,opacity:i,isCulled:a}){const l=F(),{ShapeErrorFallback:c}=Ge(),u=x.useRef(null),d=x.useRef(null),h=x.useCallback((y,g)=>{var v,S;(v=u.current)==null||v.style.setProperty(y,g),(S=d.current)==null||S.style.setProperty(y,g)},[]);fi("set shape container transform position",()=>{if(!l.getShape(n))return;const g=l.getShapePageTransform(n),v=re.toCssString(g);h("transform",v)},[l,h]),fi("set shape container clip path",()=>{if(!l.getShape(n))return null;const g=l.getShapeClipPath(n);h("clip-path",g??"none")},[l,h]),fi("set shape height and width",()=>{const y=l.getShape(n);if(!y)return null;const g=l.getShapeGeometry(y).bounds,v=Math.floor(l.getInstanceState().devicePixelRatio*100)/100,S=N5(v),w=g.w%S,C=w===0?g.w:g.w+(S-w),I=g.h%S,P=I===0?g.h:g.h+(S-I);h("width",Math.max(C,S)+"px"),h("height",Math.max(P,S)+"px")},[l]),x.useLayoutEffect(()=>{var y,g;h("opacity",i+""),(y=u.current)==null||y.style.setProperty("z-index",o+""),(g=d.current)==null||g.style.setProperty("z-index",s+"")},[i,o,s,h]);const f=x.useCallback(y=>{l.annotateError(y,{origin:"react.shape",willCrashApp:!1})},[l]);return t?p.jsxs(p.Fragment,{children:[r.backgroundComponent&&p.jsx("div",{ref:d,className:"tl-shape tl-shape-background","data-shape-type":t.type,draggable:!1,children:!a&&p.jsx(kc,{fallback:c,onError:f,children:p.jsx(z5,{shape:t,util:r})})}),p.jsx("div",{ref:u,className:"tl-shape","data-shape-type":t.type,draggable:!1,children:a?p.jsx(B5,{shape:t}):p.jsx(kc,{fallback:c,onError:f,children:p.jsx(F5,{shape:t,util:r})})})]}):null}),F5=x.memo(function({shape:n,util:t}){return lf("InnerShape:"+n.type,()=>t.component(n))},(e,n)=>e.shape.props===n.shape.props&&e.shape.meta===n.shape.meta&&e.util===n.util),z5=x.memo(function({shape:n,util:t}){return lf("InnerShape:"+n.type,()=>{var r;return(r=t.backgroundComponent)==null?void 0:r.call(t,n)})},(e,n)=>e.shape.props===n.shape.props&&e.shape.meta===n.shape.meta),B5=x.memo(function({shape:n}){const r=F().getShapeGeometry(n).bounds;return p.jsx("div",{className:"tl-shape__culled",style:{transform:`translate(${j(r.minX)}px, ${j(r.minY)}px)`,width:Math.max(1,j(r.width)),height:Math.max(1,j(r.height))}})},()=>!0);function U5({className:e}){const n=F(),{Background:t,SvgDefs:r}=Ge(),o=ie.useRef(null),s=ie.useRef(null),i=ie.useRef(null);AL(o),n3(),e3(),lL(o),s3(o),fi("position layers",()=>{const h=s.current;if(!h)return;const f=i.current;if(!f)return;const{x:y,y:g,z:v}=n.getCamera(),S=v>=1?tp(v,[1,8],[.125,.5],!0):tp(v,[.1,1],[-2,.125],!0),w=`scale(${j(v)}) translate(${j(y+S)}px,${j(g+S)}px)`;h.style.setProperty("transform",w),f.style.setProperty("transform",w)},[n]);const a=JR(),l=K("shapeSvgDefs",()=>{const h=new Map;for(const f of ot(n.shapeUtils)){if(!f)return;const y=f.getCanvasSvgDefs();for(const{key:g,component:v}of y)h.has(g)||h.set(g,p.jsx(v,{},g))}return[...h.values()]},[n]),c=K("debug_shapes",()=>Ft.hideShapes.get(),[Ft]),u=K("debug_svg",()=>Ft.debugSvg.get(),[Ft]),d=K("debug_geometry",()=>Ft.debugGeometry.get(),[Ft]);return p.jsxs("div",{ref:o,draggable:!1,className:fe("tl-canvas",e),"data-testid":"canvas",...a,children:[p.jsx("svg",{className:"tl-svg-context",children:p.jsxs("defs",{children:[l,vb&&p.jsx(vb,{}),p.jsx(t6,{}),p.jsx(n6,{}),p.jsx(r6,{}),r&&p.jsx(r,{})]})}),t&&p.jsx(t,{}),p.jsx(H5,{}),p.jsxs("div",{ref:s,className:"tl-html-layer tl-shapes",draggable:!1,children:[p.jsx(a6,{}),p.jsx(i6,{}),c?null:u?p.jsx(q5,{}):p.jsx(Z5,{})]}),p.jsxs("div",{className:"tl-overlays",children:[p.jsxs("div",{ref:i,className:"tl-html-layer",children:[d?p.jsx(DL,{}):null,p.jsx(Y5,{}),p.jsx(V5,{}),p.jsx(K5,{}),p.jsx(W5,{}),p.jsx(Q5,{}),p.jsx(J5,{}),p.jsx(e6,{}),p.jsx(G5,{}),p.jsx(s6,{}),p.jsx(O5,{})]}),p.jsx(l6,{})]})]})}function H5(){const e=F(),n=K("gridSize",()=>e.getDocumentSettings().gridSize,[e]),{x:t,y:r,z:o}=K("camera",()=>e.getCamera(),[e]),s=K("isGridMode",()=>e.getInstanceState().isGridMode,[e]),{Grid:i}=Ge();return i&&s?p.jsx(i,{x:t,y:r,z:o,size:n}):null}function K5(){const e=F(),n=K("scribbles",()=>e.getInstanceState().scribbles,[e]),t=K("zoomLevel",()=>e.getZoomLevel(),[e]),{Scribble:r}=Ge();return r&&n.length?p.jsx(p.Fragment,{children:n.map(o=>p.jsx(r,{className:"tl-user-scribble",scribble:o,zoom:t},o.id))}):null}function V5(){const e=F(),n=K("brush",()=>e.getInstanceState().brush,[e]),{Brush:t}=Ge();return t&&n?p.jsx(t,{className:"tl-user-brush",brush:n}):null}function W5(){const e=F(),n=K("zoomBrush",()=>e.getInstanceState().zoomBrush,[e]),{ZoomBrush:t}=Ge();return t&&n?p.jsx(t,{className:"tl-user-brush tl-zoom-brush",brush:n}):null}function G5(){const e=F(),n=K("snapLines",()=>e.snaps.getIndicators(),[e]),t=K("zoomLevel",()=>e.getZoomLevel(),[e]),{SnapIndicator:r}=Ge();return r&&n.length>0?p.jsx(p.Fragment,{children:n.map(o=>p.jsx(r,{className:"tl-user-snapline",line:o,zoom:t},o.id))}):null}function Y5(){const e=F(),{Handles:n}=Ge(),t=K("zoomLevel",()=>e.getZoomLevel(),[e]),r=K("coarse pointer",()=>e.getInstanceState().isCoarsePointer,[e]),o=K("isChangingStyle",()=>e.getInstanceState().isReadonly,[e]),s=K("isChangingStyle",()=>e.getInstanceState().isChangingStyle,[e]),i=K("onlySelectedShape",()=>e.getOnlySelectedShape(),[e]),a=K("transform",()=>i?e.getShapePageTransform(i):null,[e,i]),l=K("handles",()=>{if(!i)return null;const c=e.getShapeHandles(i);if(!c)return null;const u=(r?CE:IE)/t*2;return c.filter(d=>d.type!=="virtual"||!c.some(h=>h!==d&&h.type==="vertex"&&b.Dist(d,h)<u)).sort(d=>d.type==="vertex"?1:-1)},[e,i,t,r]);return!n||!i||s||o||!l||!a?null:p.jsx(n,{children:p.jsx("g",{transform:re.toCssString(a),children:l.map(c=>p.jsx(X5,{shapeId:i.id,handle:c,zoom:t,isCoarse:r},c.id))})})}function X5({shapeId:e,handle:n,zoom:t,isCoarse:r}){const o=cL(e,n.id),{Handle:s}=Ge();return s?p.jsx("g",{"aria-label":"handle",transform:`translate(${n.x}, ${n.y})`,...o,children:p.jsx(s,{shapeId:e,handle:n,zoom:t,isCoarse:r})}):null}function q5(){const e=F(),n=K("rendering shapes",()=>e.getRenderingShapes(),[e]);return p.jsx(p.Fragment,{children:n.map(t=>p.jsxs(ie.Fragment,{children:[p.jsx(WE,{...t}),p.jsx(o6,{id:t.id})]},t.id+"_fragment"))})}function Z5(){const e=F(),n=K("rendering shapes",()=>e.getRenderingShapes(),[e]);return p.jsx(p.Fragment,{children:n.map(t=>p.jsx(WE,{...t},t.id+"_shape"))})}function Q5(){const e=F(),n=K("selectedShapeIds",()=>e.getSelectedShapeIds(),[e]),t=K("should display selected ids",()=>e.isInAny("select.idle","select.brushing","select.scribble_brushing","select.editing_shape","select.pointing_shape","select.pointing_selection","select.pointing_handle")&&!e.getInstanceState().isChangingStyle,[e]),{ShapeIndicator:r}=Ge();return!r||!t?null:p.jsx(p.Fragment,{children:n.map(o=>p.jsx(r,{className:"tl-user-indicator__selected",shapeId:o},o+"_indicator"))})}const J5=function(){const n=F(),{HoveredShapeIndicator:t}=Ge(),r=K("coarse pointer",()=>n.getInstanceState().isCoarsePointer,[n]),o=K("hovering canvas",()=>n.getInstanceState().isHoveringCanvas,[n]),s=K("hovered id",()=>n.getCurrentPageState().hoveredShapeId,[n]);return r||!o||!s||!t?null:p.jsx(t,{shapeId:s})},e6=Tt(function(){const n=F(),{ShapeIndicator:t}=Ge(),r=ep(n.getHintingShapeIds());return!r.length||!t?null:p.jsx(p.Fragment,{children:r.map(o=>p.jsx(t,{className:"tl-user-indicator__hint",shapeId:o},o+"_hinting"))})});function vb(){return p.jsxs("g",{id:"cursor",children:[p.jsxs("g",{fill:"rgba(0,0,0,.2)",transform:"translate(-11,-11)",children:[p.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),p.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),p.jsxs("g",{fill:"white",transform:"translate(-12,-12)",children:[p.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),p.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),p.jsxs("g",{fill:"currentColor",transform:"translate(-12,-12)",children:[p.jsx("path",{d:"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"}),p.jsx("path",{d:"m13 10.814v11.188l2.969-2.866.428-.139h4.768z"})]})]})}function t6(){return p.jsx("path",{id:"cursor_hint",fill:"currentColor",d:"M -2,-5 2,0 -2,5 Z"})}function n6(){return p.jsx("marker",{id:"arrowhead-dot",className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"0",children:p.jsx("circle",{cx:"3",cy:"3",r:"2",strokeDasharray:"100%"})})}function r6(){return p.jsxs("marker",{id:"arrowhead-cross",className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"auto",children:[p.jsx("line",{x1:"1.5",y1:"1.5",x2:"4.5",y2:"4.5",strokeDasharray:"100%"}),p.jsx("line",{x1:"1.5",y1:"4.5",x2:"4.5",y2:"1.5",strokeDasharray:"100%"})]})}const o6=Tt(function({id:n}){const t=F(),r=t.getShape(n),[o,s]=ie.useState(""),i=(r==null?void 0:r.parentId)===t.getCurrentPageId();return ie.useEffect(()=>{if(!i)return;let a=null;const l=gu("shape to svg",async()=>{const c=Math.random();a=c;const u=t.getShapePageBounds(n),d=await t.getSvg([n],{padding:0,background:t.getInstanceState().exportBackground});d&&u&&a===c&&(d.style.setProperty("overflow","visible"),d.setAttribute("preserveAspectRatio","xMidYMin slice"),d.style.setProperty("transform",`translate(${u.x}px, ${u.y+u.h+12}px)`),d.style.setProperty("border","1px solid black"),s(d==null?void 0:d.outerHTML))});return()=>{a=null,l()}},[t,n,i]),i?p.jsx("div",{style:{paddingTop:12,position:"absolute"},children:p.jsx("div",{style:{display:"flex"},dangerouslySetInnerHTML:{__html:o}})}):null});function s6(){const e=F(),n=K("selection rotation",()=>e.getSelectionRotation(),[e]),t=K("selection bounds",()=>e.getSelectionRotatedPageBounds(),[e]),{SelectionForeground:r}=Ge();return!t||!r?null:p.jsx(r,{bounds:t,rotation:n})}function i6(){const e=F(),n=K("selection rotation",()=>e.getSelectionRotation(),[e]),t=K("selection bounds",()=>e.getSelectionRotatedPageBounds(),[e]),{SelectionBackground:r}=Ge();return!t||!r?null:p.jsx(r,{bounds:t,rotation:n})}function a6(){const{OnTheCanvas:e}=Ge();return e?p.jsx(e,{}):null}function l6(){const{InFrontOfTheCanvas:e}=Ge();return e?p.jsx(e,{}):null}function c6({className:e,zoom:n,point:t,color:r,viewport:o,opacity:s=1}){const i=x.useRef(null);return ol(i,ar(t.x,o.minX+5/n,o.maxX-5/n),ar(t.y,o.minY+5/n,o.maxY-5/n),1/n,b.Angle(o.center,t)),p.jsxs("svg",{ref:i,className:fe("tl-overlays__item",e),children:[p.jsx("use",{href:"#cursor_hint",color:r,strokeWidth:3,stroke:"var(--color-background)"}),p.jsx("use",{href:"#cursor_hint",color:r,opacity:s})]})}const wb=x.memo(function({className:n,zoom:t,point:r,color:o,name:s,chatMessage:i}){const a=x.useRef(null);return ol(a,r==null?void 0:r.x,r==null?void 0:r.y,1/t),r?p.jsxs("div",{ref:a,className:fe("tl-overlays__item",n),children:[p.jsx("svg",{className:"tl-cursor",children:p.jsx("use",{href:"#cursor",color:o})}),i?p.jsxs(p.Fragment,{children:[s&&p.jsx("div",{className:"tl-nametag-title",style:{color:o},children:s}),p.jsx("div",{className:"tl-nametag-chat",style:{backgroundColor:o},children:i})]}):s&&p.jsx("div",{className:"tl-nametag",style:{backgroundColor:o},children:s})]}):null});function u6({x:e,y:n,z:t,size:r}){return p.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("defs",{children:tb.map(({min:o,mid:s,step:i},a)=>{const l=i*r*t,c=.5+e*t,u=.5+n*t,d=c>0?c%l:l+c%l,h=u>0?u%l:l+u%l,f=t<s?tp(t,[o,s],[0,1]):1;return p.jsx("pattern",{id:`grid-${i}`,width:l,height:l,patternUnits:"userSpaceOnUse",children:p.jsx("circle",{className:"tl-grid-dot",cx:d,cy:h,r:1,opacity:f})},`grid-pattern-${a}`)})}),tb.map(({step:o},s)=>p.jsx("rect",{width:"100%",height:"100%",fill:`url(#grid-${o})`},`grid-rect-${s}`))]})}function d6({handle:e,isCoarse:n,className:t,zoom:r}){const o=(n?CE:IE)/r,s=(e.type==="create"&&n?3:4)/r;return p.jsxs("g",{className:fe("tl-handle",{"tl-handle__virtual":e.type==="virtual","tl-handle__create":e.type==="create"},t),children:[p.jsx("circle",{className:"tl-handle__bg",r:o}),p.jsx("circle",{className:"tl-handle__fg",r:s})]})}const h6=({children:e})=>p.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:e});function p6({shapeId:e}){const{ShapeIndicator:n}=Ge();return n?p.jsx(n,{className:"tl-user-indicator__hovered",shapeId:e}):null}function bu(e,n=!0){const t=e.length;if(t<2)return"";let r=e[0],o=e[1];if(t===2)return`M${Nt(r)}L${Nt(o)}`;let s="";for(let i=2,a=t-1;i<a;i++)r=e[i],o=e[i+1],s+=Pn(r,o);return n?`M${Pn(e[0],e[1])}Q${Nt(e[1])}${Pn(e[1],e[2])}T${s}${Pn(e[t-1],e[0])}${Pn(e[0],e[1])}Z`:`M${Nt(e[0])}Q${Nt(e[1])}${Pn(e[1],e[2])}${e.length>3?"T":""}${s}L${Nt(e[t-1])}`}function xb({scribble:e,zoom:n,color:t,opacity:r,className:o}){return e.points.length?p.jsx("svg",{className:o&&fe("tl-overlays__item",o),children:p.jsx("path",{className:"tl-scribble",d:bu(e.points,!1),stroke:t??`var(--color-${e.color})`,fill:"none",strokeWidth:8/n,opacity:r??e.opacity})}):null}function GE({bounds:e,rotation:n}){const t=x.useRef(null);return ol(t,e.x,e.y,1,n),x.useLayoutEffect(()=>{const r=t.current;r&&(r.style.width=j(Math.max(1,e.width))+"px",r.style.height=j(Math.max(1,e.height))+"px")},[e.width,e.height]),p.jsx("div",{ref:t,className:"tl-selection__bg",draggable:!1})}function f6({bounds:e,rotation:n}){const t=F(),r=x.useRef(null),o=K("only selected shape",()=>t.getOnlySelectedShape(),[t]),s=o?t.getShapeUtil(o).expandSelectionOutlinePx(o):0;return ol(r,e==null?void 0:e.x,e==null?void 0:e.y,1,n,{x:-s,y:-s}),e=e.clone().expandBy(s).zeroFix(),p.jsx("svg",{ref:r,className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:p.jsx("rect",{className:fe("tl-selection__fg__outline"),width:j(e.width),height:j(e.height)})})}const g6=()=>p.jsx("div",{className:"tl-shape-error-boundary"});class m6{constructor(n){this.shape=n}equals(n){var t,r,o,s,i,a;return((t=this.shape)==null?void 0:t.isLocked)===((r=n==null?void 0:n.shape)==null?void 0:r.isLocked)&&((o=this.shape)==null?void 0:o.props)===((s=n==null?void 0:n.shape)==null?void 0:s.props)&&((i=this.shape)==null?void 0:i.meta)===((a=n==null?void 0:n.shape)==null?void 0:a.meta)}}const y6=({shape:e,util:n})=>lf("Indicator:"+e.type,()=>n.indicator(e)),S6=({editor:e,id:n})=>{const t=K("shape",()=>new m6(e.store.get(n)),[e,n]),{ShapeIndicatorErrorFallback:r}=Ge();return!t.shape||t.shape.isLocked?null:p.jsx(kc,{fallback:r,onError:o=>e.annotateError(o,{origin:"react.shapeIndicator",willCrashApp:!1}),children:p.jsx(y6,{shape:t.shape,util:e.getShapeUtil(t.shape)},t.shape.id)})},bb=x.memo(function({shapeId:n,className:t,color:r,opacity:o}){const s=F(),i=K("transform",()=>{const a=s.getShapePageTransform(n);return a?a.toCssString():""},[s,n]);return p.jsx("svg",{className:fe("tl-overlays__item",t),children:p.jsx("g",{className:"tl-shape-indicator",transform:i,stroke:r??"var(--color-selected)",opacity:o,children:p.jsx(S6,{editor:s,id:n})})})}),v6=()=>p.jsx("circle",{cx:4,cy:4,r:8,strokeWidth:"1",stroke:"red"});function w6({points:e,zoom:n}){const t=2.5/n,r=e.reduce((h,f)=>Math.min(h,f.x),1/0),o=e.reduce((h,f)=>Math.max(h,f.x),-1/0),s=e.reduce((h,f)=>Math.min(h,f.y),1/0),i=e.reduce((h,f)=>Math.max(h,f.y),-1/0),a=e.some(h=>h.x===r&&h.y===s);let l,c,u,d;return a?(l=r,c=s,u=o,d=i):(l=r,c=i,u=o,d=s),p.jsxs("g",{className:"tl-snap-indicator",stroke:"lime",children:[p.jsx("line",{x1:l,y1:c,x2:u,y2:d}),e.map((h,f)=>p.jsx("g",{transform:`translate(${h.x},${h.y})`,children:p.jsx("path",{className:"tl-snap-point",d:`M ${-t},${-t} L ${t},${t} M ${-t},${t} L ${t},${-t}`})},f))]})}function x6({gaps:e,direction:n,zoom:t}){const r=3.5/t;let o=[-1/0,1/0],s=null;const i=n==="horizontal";for(const l of e){if(s=_r(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=_r(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 p.jsx("g",{className:"tl-snap-indicator",stroke:"cyan",children:e.map(({startEdge:l,endEdge:c},u)=>p.jsx(x.Fragment,{children:i?p.jsxs(p.Fragment,{children:[p.jsx("line",{x1:l[0].x,y1:a-2*r,x2:l[1].x,y2:a+2*r}),p.jsx("line",{x1:c[0].x,y1:a-2*r,x2:c[1].x,y2:a+2*r}),p.jsx("line",{x1:l[0].x,y1:a,x2:c[0].x,y2:a}),p.jsx("line",{x1:(l[0].x+c[0].x)/2,y1:a-r,x2:(l[0].x+c[0].x)/2,y2:a+r})]}):p.jsxs(p.Fragment,{children:[p.jsx("line",{x1:a-2*r,y1:l[0].y,x2:a+2*r,y2:l[1].y}),p.jsx("line",{x1:a-2*r,y1:c[0].y,x2:a+2*r,y2:c[1].y}),p.jsx("line",{x1:a,y1:l[0].y,x2:a,y2:c[0].y}),p.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 b6({className:e,line:n,zoom:t}){return p.jsx("svg",{className:fe("tl-overlays__item",e),children:n.type==="points"?p.jsx(w6,{...n,zoom:t}):n.type==="gaps"?p.jsx(x6,{...n,zoom:t}):null})}function P6(){return p.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",children:p.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[p.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"var(--color-text-1)"}),p.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"var(--color-text-1)",children:p.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}const C6=()=>null;function YE(e,n){const t=x.useRef(e);return n(e,t.current)?t.current:(t.current=e,e)}function By(e){return YE(e,rD)}function Zv(e){return YE(e,TI)}const XE=x.createContext({});function I6({overrides:e={},children:n}){const t=Zv(e);return p.jsx(XE.Provider,{value:x.useMemo(()=>({Background:_R,SvgDefs:C6,Brush:sd,ZoomBrush:sd,ScreenshotBrush:sd,CollaboratorBrush:sd,Cursor:wb,CollaboratorCursor:wb,CollaboratorHint:c6,CollaboratorShapeIndicator:bb,Grid:u6,Scribble:xb,SnapIndicator:b6,Handles:h6,Handle:d6,CollaboratorScribble:xb,ErrorFallback:ZE,ShapeErrorFallback:g6,ShapeIndicatorErrorFallback:v6,Spinner:P6,SelectionBackground:GE,SelectionForeground:f6,HoveredShapeIndicator:p6,ShapeIndicator:bb,OnTheCanvas:null,InFrontOfTheCanvas:null,Canvas:U5,...t}),[t]),children:n})}function Ge(){return x.useContext(XE)}const Qv={openWindow:(e,n)=>window.open(e,n,"noopener noreferrer"),refreshPage:()=>window.location.reload(),hardReset:async()=>{var e;return await((e=window.__tldraw__hardReset)==null?void 0:e.call(window))}};function qE(){Qv.hardReset()}function E6(){Qv.refreshPage()}const _6="https://github.com/tldraw/tldraw/issues/new";function k6(){}const ZE=({error:e,editor:n})=>{const t=x.useRef(null),[r,o]=x.useState(!1),[s,i]=x.useState(!1),[a,l]=x.useState(!1),{Canvas:c}=Ge(),u=e instanceof Error?e.message:String(e),d=e instanceof Error?e.stack:null,h=K("isDarkMode",()=>{try{if(n)return n.user.getIsDarkMode()}catch{}return null},[n]),[f,y]=x.useState(null);x.useLayoutEffect(()=>{var P;h!==null&&y(h);let C=(P=t.current)==null?void 0:P.parentElement,I=!1;for(;C;){if(C.classList.contains("tl-theme__dark")||C.classList.contains("tl-theme__light")){I=!0;break}C=C.parentElement}if(I){y(null);return}y(window.matchMedia("(prefers-color-scheme: dark)").matches)},[h]),x.useEffect(()=>{if(s){const C=setTimeout(()=>{i(!1)},2e3);return()=>clearTimeout(C)}},[s]);const g=()=>{const C=document.createElement("textarea");C.value=d??u,document.body.appendChild(C),C.select(),document.execCommand("copy"),C.remove(),i(!0)},v=()=>{E6()},S=async()=>{qE()},w=new URL(_6);return w.searchParams.set("title",u),w.searchParams.set("labels","bug"),w.searchParams.set("body",`Hey, I ran into an error while using tldraw:
|
|
48
|
+
|
|
49
|
+
\`\`\`js
|
|
50
|
+
${d??u}
|
|
51
|
+
\`\`\`
|
|
52
|
+
|
|
53
|
+
My browser: ${navigator.userAgent}`),p.jsxs("div",{ref:t,className:fe("tl-container tl-error-boundary",f===null?"":f?"tl-theme__dark":"tl-theme__light"),children:[p.jsx("div",{className:"tl-error-boundary__overlay"}),n&&p.jsx(wE,{onError:k6,fallback:()=>null,children:p.jsx(Vv.Provider,{value:n,children:p.jsx("div",{className:"tl-overlay tl-error-boundary__canvas",children:c?p.jsx(c,{}):null})})}),p.jsx("div",{className:fe("tl-modal","tl-error-boundary__content",{"tl-error-boundary__content__expanded":r&&!a}),children:a?p.jsxs(p.Fragment,{children:[p.jsx("h2",{children:"Are you sure?"}),p.jsx("p",{children:"Resetting your data will delete your drawing and cannot be undone."}),p.jsxs("div",{className:"tl-error-boundary__content__actions",children:[p.jsx("button",{onClick:()=>l(!1),children:"Cancel"}),p.jsx("button",{className:"tl-error-boundary__reset",onClick:S,children:"Reset data"})]})]}):p.jsxs(p.Fragment,{children:[p.jsx("h2",{children:"Something's gone wrong."}),p.jsxs("p",{children:["Sorry, we encountered an error. Please refresh the page to continue. If you keep seeing this error, you can ",p.jsx("a",{href:w.toString(),children:"create a GitHub issue"})," or"," ",p.jsx("a",{href:"https://discord.gg/Cq6cPsTfNy",children:"ask for help on Discord"}),"."]}),r&&p.jsxs(p.Fragment,{children:["Message:",p.jsx("h4",{children:p.jsx("code",{children:u})}),"Stack trace:",p.jsxs("div",{className:"tl-error-boundary__content__error",children:[p.jsx("pre",{children:p.jsx("code",{children:d??u})}),p.jsx("button",{onClick:g,children:s?"Copied!":"Copy"})]})]}),p.jsxs("div",{className:"tl-error-boundary__content__actions",children:[p.jsx("button",{onClick:()=>o(!r),children:r?"Hide details":"Show details"}),p.jsxs("div",{className:"tl-error-boundary__content__actions__group",children:[p.jsx("button",{className:"tl-error-boundary__reset",onClick:()=>l(!0),children:"Reset data"}),p.jsx("button",{className:"tl-error-boundary__refresh",onClick:v,children:"Refresh Page"})]})]})]})})]})};function ze(){return cf()}const QE="TLDRAW_USER_DATA_v3",JE=be({id:Se,name:Se.nullable().optional(),locale:Se.nullable().optional(),color:Se.nullable().optional(),isDarkMode:xe.nullable().optional(),animationSpeed:de.nullable().optional(),edgeScrollSpeed:de.nullable().optional(),isSnapMode:xe.nullable().optional(),isWrapMode:xe.nullable().optional()}),Qi={AddAnimationSpeed:1,AddIsSnapMode:2,MakeFieldsNullable:3,AddEdgeScrollSpeed:4,AddExcalidrawSelectMode:5},wp=Me({currentVersion:Qi.AddExcalidrawSelectMode,migrators:{[Qi.AddAnimationSpeed]:{up:e=>({...e,animationSpeed:1}),down:({animationSpeed:e,...n})=>n},[Qi.AddIsSnapMode]:{up:e=>({...e,isSnapMode:!1}),down:({isSnapMode:e,...n})=>n},[Qi.MakeFieldsNullable]:{up:e=>e,down:e=>({id:e.id,name:e.name??bn.name,locale:e.locale??bn.locale,color:e.color??bn.color,animationSpeed:e.animationSpeed??bn.animationSpeed,isDarkMode:e.isDarkMode??bn.isDarkMode,isSnapMode:e.isSnapMode??bn.isSnapMode,isWrapMode:e.isWrapMode??bn.isWrapMode})},[Qi.AddEdgeScrollSpeed]:{up:e=>({...e,edgeScrollSpeed:1}),down:({edgeScrollSpeed:e,...n})=>n},[Qi.AddExcalidrawSelectMode]:{up:e=>({...e,isWrapMode:!1}),down:({isWrapMode:e,...n})=>n}}}),Pb=["#FF802B","#EC5E41","#F2555A","#F04F88","#E34BA9","#BD54C6","#9D5BD2","#7B66DC","#02B1CC","#11B3A3","#39B178","#55B467"];function T6(){return Pb[Math.floor(Math.random()*Pb.length)]}function $6(){var e,n;return typeof window>"u"?!1:((n=(e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)"))==null?void 0:n.matches)??!1}function M6(){var e,n;return typeof window>"u"?!1:((n=(e=window.matchMedia)==null?void 0:e.call(window,"(prefers-reduced-motion: reduce)"))==null?void 0:n.matches)??!1}const bn=Object.freeze({name:"New User",locale:bR(),color:T6(),isDarkMode:!1,edgeScrollSpeed:1,animationSpeed:M6()?0:1,isSnapMode:!1,isWrapMode:!1});function ad(){return{id:ze()}}function e_(e){if(e===null||typeof e!="object"||!("version"in e)||!("user"in e)||typeof e.version!="number")return ad();const n=Dv({value:e.user,fromVersion:e.version,toVersion:wp.currentVersion??0,migrations:wp});if(n.type==="error")return ad();try{JE.validate(n.value)}catch{return ad()}return n.value}function A6(){var n;const e=typeof window>"u"?null:JSON.parse(((n=window==null?void 0:window.localStorage)==null?void 0:n.getItem(QE))||"null")??null;return e_(e)}const Ac=hn("globalUserData",null);function j6(){typeof window<"u"&&window.localStorage&&window.localStorage.setItem(QE,JSON.stringify({version:wp.currentVersion,user:Ac.get()}))}function O6(e){JE.validate(e),Ac.set(e),j6(),R6()}const D6=typeof process<"u"&&!1,Ma=typeof BroadcastChannel<"u"&&!D6?new BroadcastChannel("tldraw-user-sync"):null;Ma==null||Ma.addEventListener("message",e=>{const n=e.data;(n==null?void 0:n.type)===n_&&(n==null?void 0:n.origin)!==t_()&&Ac.set(e_(n.data))});let jg=null;function t_(){return jg===null&&(jg=ze()),jg}const n_="tldraw-user-preferences-change";function R6(){Ma==null||Ma.postMessage({type:n_,origin:t_(),data:{user:r_(),version:wp.currentVersion}})}function r_(){let e=Ac.get();return e||(e=A6(),Ac.set(e)),e}function o_(e={}){return{derivePresenceState:e.derivePresenceState??(()=>Z("presence",()=>null)),userPreferences:e.userPreferences??Z("userPreferences",()=>r_()),setUserPreferences:e.setUserPreferences??O6}}var s_={exports:{}};(function(e){var n=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function o(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function s(l,c,u,d,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new o(u,d||l,h),y=t?t+c:c;return l._events[y]?l._events[y].fn?l._events[y]=[l._events[y],f]:l._events[y].push(f):(l._events[y]=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,d;if(this._eventsCount===0)return c;for(d in u=this._events)n.call(u,d)&&c.push(t?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},a.prototype.listeners=function(c){var u=t?t+c:c,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var h=0,f=d.length,y=new Array(f);h<f;h++)y[h]=d[h].fn;return y},a.prototype.listenerCount=function(c){var u=t?t+c:c,d=this._events[u];return d?d.fn?1:d.length:0},a.prototype.emit=function(c,u,d,h,f,y){var g=t?t+c:c;if(!this._events[g])return!1;var v=this._events[g],S=arguments.length,w,C;if(v.fn){switch(v.once&&this.removeListener(c,v.fn,void 0,!0),S){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,u),!0;case 3:return v.fn.call(v.context,u,d),!0;case 4:return v.fn.call(v.context,u,d,h),!0;case 5:return v.fn.call(v.context,u,d,h,f),!0;case 6:return v.fn.call(v.context,u,d,h,f,y),!0}for(C=1,w=new Array(S-1);C<S;C++)w[C-1]=arguments[C];v.fn.apply(v.context,w)}else{var I=v.length,P;for(C=0;C<I;C++)switch(v[C].once&&this.removeListener(c,v[C].fn,void 0,!0),S){case 1:v[C].fn.call(v[C].context);break;case 2:v[C].fn.call(v[C].context,u);break;case 3:v[C].fn.call(v[C].context,u,d);break;case 4:v[C].fn.call(v[C].context,u,d,h);break;default:if(!w)for(P=1,w=new Array(S-1);P<S;P++)w[P-1]=arguments[P];v[C].fn.apply(v[C].context,w)}}return!0},a.prototype.on=function(c,u,d){return s(this,c,u,d,!1)},a.prototype.once=function(c,u,d){return s(this,c,u,d,!0)},a.prototype.removeListener=function(c,u,d,h){var f=t?t+c:c;if(!this._events[f])return this;if(!u)return i(this,f),this;var y=this._events[f];if(y.fn)y.fn===u&&(!h||y.once)&&(!d||y.context===d)&&i(this,f);else{for(var g=0,v=[],S=y.length;g<S;g++)(y[g].fn!==u||h&&!y[g].once||d&&y[g].context!==d)&&v.push(y[g]);v.length?this._events[f]=v.length===1?v[0]:v:i(this,f)}return this},a.prototype.removeAllListeners=function(c){var u;return c?(u=t?t+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=t,a.EventEmitter=a,e.exports=a})(s_);var L6=s_.exports;function Vn({children:e,className:n="",...t}){return p.jsx("svg",{...t,className:`tl-svg-container ${n}`,children:e})}function Jv(e,n,t,r){const o=e.x-t.x,s=e.y-t.y,i=r.x-t.x,a=r.y-t.y,l=n.x-e.x,c=n.y-e.y,u=i*s-a*o,d=l*s-c*o,h=a*l-i*c;if(u===0||d===0||h===0)return null;if(h!==0){const f=u/h,y=d/h;if(0<=f&&f<=1&&0<=y&&y<=1)return b.AddXY(e,f*l,f*c)}return null}function gf(e,n,t,r){const o=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),s=2*((n.x-e.x)*(e.x-t.x)+(n.y-e.y)*(e.y-t.y)),i=t.x*t.x+t.y*t.y+e.x*e.x+e.y*e.y-2*(t.x*e.x+t.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 d=[];return 0<=c&&c<=1&&d.push(b.Lrp(e,n,c)),0<=u&&u<=1&&d.push(b.Lrp(e,n,u)),d.length===0?null:d}function i_(e,n,t){const r=[];let o;for(let s=0,i=t.length-1;s<i;s++)o=Jv(e,n,t[s],t[s+1]),o&&r.push(o);return r.length===0?null:r}function a_(e,n,t){const r=[];let o;for(let s=1,i=t.length;s<i+1;s++)o=Jv(e,n,t[s-1],t[s%t.length]),o&&r.push(o);return r.length===0?null:r}function N6(e,n,t,r){let o=t.x-e.x,s=t.y-e.y;const i=Math.sqrt(o*o+s*s),a=(i*i-r*r+n*n)/(2*i),l=Math.sqrt(n*n-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 Uy(e,n,t){const r=[];let o,s,i;for(let a=0,l=t.length;a<l;a++)o=t[a],s=t[(a+1)%t.length],i=gf(o,s,e,n),i&&r.push(...i);return r.length===0?null:r}function Cb(e,n,t){const r=[];let o,s,i;for(let a=1,l=t.length;a<l;a++)o=t[a-1],s=t[a],i=gf(o,s,e,n),i&&r.push(...i);return r.length===0?null:r}function ld(e,n,t){return(t.y-e.y)*(n.x-e.x)>(n.y-e.y)*(t.x-e.x)}function l_(e,n,t,r){return ld(e,t,r)!==ld(n,t,r)&&ld(e,n,t)!==ld(e,n,r)}function Hy(e,n){const t=new Map;let r,o,s,i;for(let a=0,l=e.length;a<l;a++)if(r=e[a],Br(r,n)){const c=Og(r);t.has(c)||t.set(c,r)}for(let a=0,l=n.length;a<l;a++)if(r=n[a],Br(r,e)){const c=Og(r);t.has(c)||t.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=n.length;c<u;c++){s=n[c],i=n[(c+1)%n.length];const d=Jv(r,o,s,i);if(d!==null){const h=Og(d);t.has(h)||t.set(h,d)}}}return t.size===0?null:F6([...t.values()])}function Og(e){return`${e.x},${e.y}`}function F6(e){const n=b.Average(e);return e.sort((t,r)=>b.Angle(n,t)-b.Angle(n,r))}function z6(e,n){let t,r,o,s;for(let i=0,a=e.length;i<a;i++){t=e[i],r=e[(i+1)%a];for(let l=0,c=n.length;l<c;l++)if(o=n[l],s=n[(l+1)%c],l_(t,r,o,s))return!0}return!1}class jc extends ji{constructor(t){super({...t,isClosed:!1,isFilled:!1});m(this,"start");m(this,"end");m(this,"d");m(this,"u");m(this,"ul");m(this,"_length");const{start:r,end:o}=t;this.start=r,this.end=o,this.d=r.clone().sub(o),this.u=this.d.clone().uni(),this.ul=this.u.len()}get length(){return this._length?this._length:this.d.len()}midPoint(){return this.start.lrp(this.end,.5)}getVertices(){return[this.start,this.end]}nearestPoint(t){const{start:r,end:o,u:s,ul:i}=this;if(i===0)return r;const a=b.Sub(t,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(t,r,o){return l_(t,r,this.start,this.end)}}class Oi extends ji{constructor(t){super({isClosed:!1,isFilled:!1,...t});m(this,"points");m(this,"_segments");m(this,"_length");const{points:r}=t;this.points=r}get segments(){if(!this._segments){this._segments=[];const{vertices:t}=this;for(let r=0,o=t.length-1;r<o;r++){const s=t[r],i=t[r+1];this._segments.push(new jc({start:s,end:i}))}this.isClosed&&this._segments.push(new jc({start:t[t.length-1],end:t[0]}))}return this._segments}get length(){return this._length||(this._length=this.segments.reduce((t,r)=>t+r.length,0)),this._length}getVertices(){return this.points}nearestPoint(t){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(t),a=i.dist(t),a<s&&(o=i,s=a);return o}hitTestLineSegment(t,r,o){return this.segments.some(s=>s.hitTestLineSegment(t,r,o))}}class vt extends Oi{constructor(n){super({...n}),this.isClosed=!0}}class js extends vt{constructor(t){const{x:r=0,y:o=0,width:s,height:i}=t;super({...t,points:[new b(r,o),new b(r+s,o),new b(r+s,o+i),new b(r,o+i)]});m(this,"x");m(this,"y");m(this,"w");m(this,"h");this.x=r,this.y=o,this.w=s,this.h=i}getBounds(){return new ne(this.x,this.y,this.w,this.h)}}class Lr{constructor(n){m(this,"canSnap",()=>!0);m(this,"canScroll",()=>!1);m(this,"canUnmount",()=>!0);m(this,"canBind",(n,t)=>!0);m(this,"canEdit",()=>!1);m(this,"canResize",()=>!0);m(this,"canEditInReadOnly",()=>!1);m(this,"canCrop",()=>!1);m(this,"hideResizeHandles",()=>!1);m(this,"hideRotateHandle",()=>!1);m(this,"hideSelectionBoundsBg",()=>!1);m(this,"hideSelectionBoundsFg",()=>!1);m(this,"isAspectRatioLocked",()=>!1);m(this,"onBeforeCreate");m(this,"onBeforeUpdate");m(this,"onDragShapesOver");m(this,"onDragShapesOut");m(this,"onDropShapesOver");m(this,"onResizeStart");m(this,"onResize");m(this,"onResizeEnd");m(this,"onTranslateStart");m(this,"onTranslate");m(this,"onTranslateEnd");m(this,"onHandleDrag");m(this,"onRotateStart");m(this,"onRotate");m(this,"onRotateEnd");m(this,"onBindingChange");m(this,"onChildrenChange");m(this,"onDoubleClickHandle");m(this,"onDoubleClickEdge");m(this,"onDoubleClick");m(this,"onClick");m(this,"onEditEnd");this.editor=n}providesBackgroundForChildren(n){return!1}canReceiveNewChildrenOfType(n,t){return!1}canDropShapes(n,t){return!1}expandSelectionOutlinePx(n){return 0}getCanvasSvgDefs(){return[]}getBoundsSnapGeometry(n){return{}}getHandleSnapGeometry(n){return{}}}m(Lr,"props"),m(Lr,"migrations"),m(Lr,"type");function B6(e,n,t={}){const{closed:r=!1,snap:o=1,start:s="outset",end:i="outset",lengthRatio:a=2,style:l="dashed"}=t;let c=0,u=0,d=1,h=0,f=0;switch(l){case"dashed":{d=1,c=Math.min(n*a,e/4);break}case"dotted":{d=100,c=n/d;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*d)),u-=u%o,u<3&&l==="dashed"?e/n<5?(c=e,u=1,h=0):(c=e*.333,h=e*.333):(u=Math.max(u,3),c=e/u/(2*d),r?(f=c/2,h=(e-u*c)/u):h=(e-u*c)/Math.max(1,u-1)),{strokeDasharray:[c,h].join(" "),strokeDashoffset:f.toString()}}function Ib({bounds:e,className:n}){const t=F(),r=K("zoom level",()=>t.getZoomLevel(),[t]);return p.jsx("g",{className:n,pointerEvents:"none",strokeLinecap:"round",strokeLinejoin:"round",children:e.sides.map((o,s)=>{const{strokeDasharray:i,strokeDashoffset:a}=B6(o[0].dist(o[1]),1/r,{style:"dashed",lengthRatio:4});return p.jsx("line",{x1:o[0].x,y1:o[0].y,x2:o[1].x,y2:o[1].y,strokeDasharray:i,strokeDashoffset:a},s)})})}class sh extends Lr{constructor(){super(...arguments);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"canBind",()=>!1);m(this,"onChildrenChange",t=>{const r=this.editor.getSortedChildIdsForParent(t.id);if(r.length===0){this.editor.getCurrentPageState().focusedGroupId===t.id&&this.editor.popFocusedGroupId(),this.editor.deleteShapes([t.id]);return}else if(r.length===1){this.editor.getCurrentPageState().focusedGroupId===t.id&&this.editor.popFocusedGroupId(),this.editor.reparentShapes(r,t.parentId),this.editor.deleteShapes([t.id]);return}})}getDefaultProps(){return{}}getGeometry(t){const r=this.editor.getSortedChildIdsForParent(t.id);return r.length===0?new js({width:1,height:1,isFilled:!1}):new no({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 Oi({points:a})})})}component(t){const r=this.editor.getErasingShapeIds().includes(t.id),{hintingShapeIds:o}=this.editor.getCurrentPageState(),s=o.length>0&&o.some(l=>l!==t.id&&this.editor.isShapeOfType(this.editor.getShape(l),"group")),i=this.editor.getCurrentPageState().focusedGroupId!==t.id;if(!r&&(i||s))return null;const a=this.editor.getShapeGeometry(t).bounds;return p.jsx(Vn,{id:t.id,children:p.jsx(Ib,{className:"tl-group",bounds:a})})}indicator(t){const r=this.editor.getShapeGeometry(t).bounds;return p.jsx(Ib,{className:"",bounds:r})}}m(sh,"type","group"),m(sh,"props",sE),m(sh,"migrations",iE);const c_=[sh],U6=new Set(c_.map(e=>e.type));function u_(e){const n=[...c_],t=new Set;for(const r of e){if(U6.has(r.type))throw new Error(`Shape type "${r.type}" is a core shapes type and cannot be overridden`);if(t.has(r.type))throw new Error(`Shape type "${r.type}" is defined more than once`);n.push(r),t.add(r.type)}return n}function Eb(e,n){if(!n)return!1;switch(e.type){case"mixed":return n.type==="mixed";case"shared":return n.type==="shared"&&e.value===n.value;default:throw Ai(e)}}class H6{constructor(n){m(this,"map");this.map=new Map(n)}get(n){return this.map.get(n)}getAsKnownValue(n){const t=this.get(n);if(t&&t.type!=="mixed")return t.value}get size(){return this.map.size}equals(n){if(this.size!==n.size)return!1;const t=new Set;for(const[r,o]of this){if(!Eb(o,n.get(r)))return!1;t.add(r)}for(const[r,o]of n)if(!t.has(r)&&!Eb(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 Ky extends H6{set(n,t){this.map.set(n,t)}applyValue(n,t){const r=this.get(n);if(!r){this.set(n,{type:"shared",value:t});return}switch(r.type){case"mixed":return;case"shared":r.value!==t&&this.set(n,{type:"mixed"});return;default:Ai(r,"type")}}}class e0{constructor(){m(this,"items",new WeakMap)}get(n,t){return this.items.has(n)||this.items.set(n,t(n)),this.items.get(n)}access(n){return this.items.get(n)}set(n,t){this.items.set(n,t)}has(n){return this.items.has(n)}invalidate(n){this.items.delete(n)}bust(){this.items=new WeakMap}}function K6(e,n,t){return fetch(e).then(function(r){return r.arrayBuffer()}).then(function(r){return new File([r],n,{type:t})})}function V6(e,n){var o;let t=e;const r=new Set(n);for(;r.has(t);)t=(o=/^.*(\d+)$/.exec(t))!=null&&o[1]?t.replace(/(\d+)(?=\D?)$/,s=>(+s+1).toString()):`${t} 1`;return t}function cd(e,n,t){if(t.length===0)return[];const r=new Map;for(const s of ge(t.map(i=>e.getShape(i)))){const{parentId:i}=s;r.has(i)||r.set(i,{children:ge(e.getSortedChildIdsForParent(i).map(a=>e.getShape(a))),moving:new Set}),r.get(i).moving.add(s)}const o=[];switch(n){case"toBack":{r.forEach(({moving:s,children:i})=>W6(s,i,o));break}case"toFront":{r.forEach(({moving:s,children:i})=>G6(s,i,o));break}case"forward":{r.forEach(({moving:s,children:i})=>Y6(s,i,o));break}case"backward":{r.forEach(({moving:s,children:i})=>X6(s,i,o));break}}return o}function W6(e,n,t){const r=n.length;if(e.size===r)return;let o,s;for(let i=0;i<r;i++){const a=n[i];if(e.has(a))o=a.index,e.delete(a);else{s=a.index;break}}if(e.size!==0){const i=Ba(o,s,e.size);t.push(...Array.from(e.values()).sort(Rt).map((a,l)=>({...a,index:i[l]})))}}function G6(e,n,t){const r=n.length;if(e.size===r)return;let o,s;for(let i=r-1;i>-1;i--){const a=n[i];if(e.has(a))s=a.index,e.delete(a);else{o=a.index;break}}if(e.size!==0){const i=Ba(o,s,e.size);t.push(...Array.from(e.values()).sort(Rt).map((a,l)=>({...a,index:i[l]})))}}function Y6(e,n,t){var s;const r=n.length;if(e.size===r)return;let o={name:"skipping"};for(let i=0;i<r;i++){const a=e.has(n[i]);switch(o.name){case"skipping":{if(!a)continue;o={name:"selecting",selectIndex:i};break}case"selecting":{if(a)continue;const{selectIndex:l}=o;Ba(n[i].index,(s=n[i+1])==null?void 0:s.index,i-l).forEach((c,u)=>t.push({...n[l+u],index:c})),o={name:"skipping"};break}}}}function X6(e,n,t){var s;const r=n.length;if(e.size===r)return;let o={name:"skipping"};for(let i=r-1;i>-1;i--){const a=e.has(n[i]);switch(o.name){case"skipping":{if(!a)continue;o={name:"selecting",selectIndex:i};break}case"selecting":{if(a)continue;Ba((s=n[i-1])==null?void 0:s.index,n[i].index,o.selectIndex-i).forEach((l,c)=>{t.push({...n[i+c+1],index:l})}),o={name:"skipping"};break}}}}function d_({editor:e}){const n=e.getSelectedShapes(),t=e.getSelectionRotation(),r=e.getSelectionRotatedPageBounds(),{inputs:{originPagePoint:o}}=e;if(!r)return null;const s=r.center.clone().rotWith(r.point,t);return{selectionPageCenter:s,initialCursorAngle:s.angle(o),initialSelectionRotation:t,shapeSnapshots:n.map(i=>({shape:Dr(i),initialPagePoint:e.getShapePageTransform(i.id).point()}))}}function ih({delta:e,editor:n,snapshot:t,stage:r}){const{selectionPageCenter:o,shapeSnapshots:s}=t;n.updateShapes(s.map(({shape:a,initialPagePoint:l})=>{const c=Hn(a.parentId)?n.getShapePageTransform(a.parentId):re.Identity(),u=b.RotWith(l,o,e),d=re.applyToPoint(re.Inverse(c),u),h=Rr(a.rotation+e);return{id:a.id,type:a.type,x:d.x,y:d.y,rotation:h}}));const i=[];s.forEach(({shape:a})=>{var d,h,f;const l=n.getShape(a.id);if(!l)return;const c=n.getShapeUtil(a);if(r==="start"||r==="one-off"){const y=(d=c.onRotateStart)==null?void 0:d.call(c,a);y&&i.push(y)}const u=(h=c.onRotate)==null?void 0:h.call(c,a,l);if(u&&i.push(u),r==="end"||r==="one-off"){const y=(f=c.onRotateEnd)==null?void 0:f.call(c,a,l);y&&i.push(y)}}),i.length>0&&n.updateShapes(i)}const q6=e=>{const{store:n}=e,t=n.query.filterHistory("shape"),r=n.query.records("shape",()=>({type:{eq:"arrow"}}));function o(){const s=r.get(),i={};for(const a of s){const{start:l,end:c}=a.props;if(l.type==="binding"){const u=i[l.boundShapeId];u?u.push({arrowId:a.id,handleId:"start"}):i[l.boundShapeId]=[{arrowId:a.id,handleId:"start"}]}if(c.type==="binding"){const u=i[c.boundShapeId];u?u.push({arrowId:a.id,handleId:"end"}):i[c.boundShapeId]=[{arrowId:a.id,handleId:"end"}]}}return i}return Z("arrowBindingsIndex",(s,i)=>{if($a(s))return o();const a=s,l=t.getDiffSince(i);if(l===Xn)return o();let c;function u(f){c||(c={...a}),c[f]?c[f]===a[f]&&(c[f]=[...c[f]]):c[f]=[]}function d(f,y,g){u(f),c[f]=c[f].filter(v=>v.arrowId!==y||v.handleId!==g),c[f].length===0&&delete c[f]}function h(f,y,g){u(f),c[f].push({arrowId:y,handleId:g})}for(const f of l){for(const y of Object.values(f.added))if(e.isShapeOfType(y,"arrow")){const{start:g,end:v}=y.props;g.type==="binding"&&h(g.boundShapeId,y.id,"start"),v.type==="binding"&&h(v.boundShapeId,y.id,"end")}for(const[y,g]of Object.values(f.updated))if(!(!e.isShapeOfType(y,"arrow")||!e.isShapeOfType(g,"arrow")))for(const v of["start","end"]){const S=y.props[v],w=g.props[v];S.type==="binding"&&w.type==="point"?d(S.boundShapeId,y.id,v):S.type==="point"&&w.type==="binding"?h(w.boundShapeId,g.id,v):S.type==="binding"&&w.type==="binding"&&S.boundShapeId!==w.boundShapeId&&(d(S.boundShapeId,y.id,v),h(w.boundShapeId,g.id,v))}for(const y of Object.values(f.removed))if(e.isShapeOfType(y,"arrow")){const{start:g,end:v}=y.props;g.type==="binding"&&d(g.boundShapeId,y.id,"start"),v.type==="binding"&&d(v.boundShapeId,y.id,"end")}}return c??a})},Z6=e=>{const n=e.query.ids("shape");function t(){const r={},o=n.get(),s=Array(o.size);return o.forEach(i=>s.push(e.get(i))),s.sort(Rt),s.forEach(i=>{r[i.parentId]||(r[i.parentId]=[]),r[i.parentId].push(i.id)}),r}return Z("parentsToChildrenWithIndexes",(r,o)=>{if($a(r))return t();const s=e.history.getDiffSince(o);if(s===Xn)return t();if(s.length===0)return r;let i=null;const a=u=>{i||(i={...r}),i[u]?i[u]===r[u]&&(i[u]=[...i[u]]):i[u]=[]},l=new Set;let c;for(let u=0,d=s.length;u<d;u++){c=s[u];for(const h of Object.values(c.added))ci(h)&&(a(h.parentId),i[h.parentId].push(h.id),l.add(i[h.parentId]));for(const[h,f]of Object.values(c.updated))if(ci(f)&&ci(h)){if(h.parentId!==f.parentId)a(h.parentId),a(f.parentId),i[h.parentId].splice(i[h.parentId].indexOf(f.id),1),i[f.parentId].push(f.id),l.add(i[f.parentId]);else if(h.index!==f.index){a(f.parentId);const y=i[f.parentId].indexOf(f.id);i[f.parentId][y]=f.id,l.add(i[f.parentId])}}for(const h of Object.values(c.removed))ci(h)&&(a(h.parentId),i[h.parentId].splice(i[h.parentId].indexOf(h.id),1))}for(const u of l){const d=ge(u.map(h=>e.get(h)));d.sort(Rt),u.splice(0,u.length,...d.map(h=>h.id))}return i??r})},Dg=(e,n,t)=>{for(;!wn(t.parentId);){const r=e.get(t.parentId);if(!r)return!1;t=r}return t.parentId===n},Q6=(e,n)=>{const t=e.query.ids("shape");let r=null;function o(){const s=n();return r=s,new Set([...t.get()].filter(i=>Dg(e,s,e.get(i))))}return Z("_shapeIdsInCurrentPage",(s,i)=>{if($a(s))return o();const a=n();if(a!==r)return o();const l=e.history.getDiffSince(i);if(l===Xn)return o();const c=new nh(s);for(const d of l){for(const h of Object.values(d.added))ci(h)&&Dg(e,a,h)&&c.add(h.id);for(const[h,f]of Object.values(d.updated))ci(f)&&(Dg(e,a,f)?c.add(f.id):c.remove(f.id));for(const h of Object.keys(d.removed))Hn(h)&&c.remove(h)}const u=c.get();return u?Xl(u.value,u.diff):s})},J6=40;class eN{constructor(n){m(this,"_clickId","");m(this,"_clickTimeout");m(this,"_clickScreenPoint");m(this,"_previousScreenPoint");m(this,"_getClickTimeout",(n,t=ze())=>{this._clickId=t,clearTimeout(this._clickTimeout),this._clickTimeout=setTimeout(()=>{if(this._clickState===n&&this._clickId===t){switch(this._clickState){case"pendingTriple":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"double_click",phase:"settle"});break}case"pendingQuadruple":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"triple_click",phase:"settle"});break}case"pendingOverflow":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"quadruple_click",phase:"settle"});break}}this._clickState="idle"}},n==="idle"||n==="pendingDouble"?NR:FR)});m(this,"_clickState","idle");m(this,"lastPointerInfo",{});m(this,"transformPointerDownEvent",n=>{if(!this._clickState)return n;switch(this._clickScreenPoint=b.From(n.point),this._previousScreenPoint&&this._previousScreenPoint.dist(this._clickScreenPoint)>J6&&(this._clickState="idle"),this._previousScreenPoint=this._clickScreenPoint,this.lastPointerInfo=n,this._clickState){case"idle":return this._clickState="pendingDouble",this._clickTimeout=this._getClickTimeout(this._clickState),n;case"pendingDouble":return this._clickState="pendingTriple",this._clickTimeout=this._getClickTimeout(this._clickState),{...n,type:"click",name:"double_click",phase:"down"};case"pendingTriple":return this._clickState="pendingQuadruple",this._clickTimeout=this._getClickTimeout(this._clickState),{...n,type:"click",name:"triple_click",phase:"down"};case"pendingQuadruple":return this._clickState="pendingOverflow",this._clickTimeout=this._getClickTimeout(this._clickState),{...n,type:"click",name:"quadruple_click",phase:"down"};case"pendingOverflow":return this._clickState="overflow",this._clickTimeout=this._getClickTimeout(this._clickState),n;default:return this._clickTimeout=this._getClickTimeout(this._clickState),n}});m(this,"transformPointerUpEvent",n=>{if(!this._clickState)return n;switch(this._clickScreenPoint=b.From(n.point),this._clickState){case"pendingTriple":return{...this.lastPointerInfo,type:"click",name:"double_click",phase:"up"};case"pendingQuadruple":return{...this.lastPointerInfo,type:"click",name:"triple_click",phase:"up"};case"pendingOverflow":return{...this.lastPointerInfo,type:"click",name:"quadruple_click",phase:"up"};default:return n}});m(this,"cancelDoubleClickTimeout",()=>{this._clickTimeout=clearTimeout(this._clickTimeout),this._clickState="idle"});m(this,"handleMove",()=>{this._clickState!=="idle"&&this._clickScreenPoint&&this._clickScreenPoint.dist(this.editor.inputs.currentScreenPoint)>(this.editor.getInstanceState().isCoarsePointer?Ny:$c)&&this.cancelDoubleClickTimeout()});this.editor=n}get clickState(){return this._clickState}}class tN{constructor(n){m(this,"isSafari");m(this,"isIos");m(this,"isChromeForIos");m(this,"isFirefox");m(this,"isAndroid");this.editor=n,typeof window<"u"&&"navigator"in window?(this.isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),this.isIos=!!navigator.userAgent.match(/iPad/i)||!!navigator.userAgent.match(/iPhone/i),this.isChromeForIos=/crios.*safari/i.test(navigator.userAgent),this.isFirefox=/firefox/i.test(navigator.userAgent),this.isAndroid=/android/i.test(navigator.userAgent)):(this.isSafari=!1,this.isIos=!1,this.isChromeForIos=!1,this.isFirefox=!1,this.isAndroid=!1)}}function ni(e){if(e){let n=_b;for(;e.length;)n=n.push(e.pop());return n}return _b}class nN{constructor(){m(this,"length",0);m(this,"head",null);m(this,"tail",this)}push(n){return new t0(n,this)}toArray(){return $s}[Symbol.iterator](){return{next(){return{value:void 0,done:!0}}}}}const _b=new nN;class t0{constructor(n,t){m(this,"length");this.head=n,this.tail=t,this.length=t.length+1}push(n){return new t0(n,this)}toArray(){return Array.from(this)}[Symbol.iterator](){let n=this;return{next(){if(n.length){const t=n.head;return n=n.tail,{value:t,done:!1}}else return{value:void 0,done:!0}}}}}class rN{constructor(n,t){m(this,"_undos",hn("HistoryManager.undos",ni()));m(this,"_redos",hn("HistoryManager.redos",ni()));m(this,"_batchDepth",0);m(this,"onBatchComplete",()=>{});m(this,"_commands",{});m(this,"createCommand",(n,t,r)=>{if(this._commands[n])throw new Error(`Duplicate command: ${n}`);this._commands[n]=r;const o=(...s)=>{if(!this._batchDepth)return this.batch(()=>o(...s)),this.ctx;const i=t(...s);if(!i)return this.ctx;const{data:a,ephemeral:l,squashing:c,preservesRedoStack:u}=i;if(this.ignoringUpdates((d,h)=>(r.do(a),{undos:d,redos:h})),!l){const d=this._undos.get().head;c&&d&&d.type==="command"&&d.name===n&&d.preservesRedoStack===u?this._undos.update(h=>h.tail.push({...d,id:ze(),data:r.squash(d.data,a)})):this._undos.update(h=>h.push({type:"command",name:n,data:a,id:ze(),preservesRedoStack:u})),i.preservesRedoStack||this._redos.set(ni()),this.ctx.emit("change-history",{reason:"push"})}return this.ctx};return o});m(this,"batch",n=>{try{this._batchDepth++,this._batchDepth===1?Tr(()=>{var r,o;const t=(r=this._undos.get().head)==null?void 0:r.id;n(),t!==((o=this._undos.get().head)==null?void 0:o.id)&&this.onBatchComplete()}):n()}catch(t){throw this.annotateError(t),t}finally{this._batchDepth--}return this});m(this,"ignoringUpdates",n=>{let t=this._undos.get(),r=this._redos.get();this._undos.set(ni()),this._redos.set(ni());try{({undos:t,redos:r}=Tr(()=>n(t,r)))}finally{this._undos.set(t),this._redos.set(r)}});m(this,"_undo",({pushToRedoStack:n,toMark:t=void 0})=>(this.ignoringUpdates((r,o)=>{var s;if(r.length===0)return{undos:r,redos:o};for(;((s=r.head)==null?void 0:s.type)==="STOP";){const i=r.head;if(r=r.tail,n&&(o=o.push(i)),i.id===t)return this.ctx.emit("change-history",n?{reason:"undo"}:{reason:"bail",markId:t}),{undos:r,redos:o}}if(r.length===0)return this.ctx.emit("change-history",n?{reason:"undo"}:{reason:"bail",markId:t}),{undos:r,redos:o};for(;r.head;){const i=r.head;if(r=r.tail,n&&(o=o.push(i)),i.type==="STOP"){if(i.onUndo&&(!t||i.id===t))return this.ctx.emit("change-history",n?{reason:"undo"}:{reason:"bail",markId:t}),{undos:r,redos:o}}else this._commands[i.name].undo(i.data)}return this.ctx.emit("change-history",n?{reason:"undo"}:{reason:"bail",markId:t}),{undos:r,redos:o}}),this));m(this,"undo",()=>(this._undo({pushToRedoStack:!0}),this));m(this,"redo",()=>(this.ignoringUpdates((n,t)=>{var r;if(t.length===0)return{undos:n,redos:t};for(;((r=t.head)==null?void 0:r.type)==="STOP";)n=n.push(t.head),t=t.tail;if(t.length===0)return this.ctx.emit("change-history",{reason:"redo"}),{undos:n,redos:t};for(;t.head;){const o=t.head;if(n=n.push(t.head),t=t.tail,o.type==="STOP"){if(o.onRedo)break}else{const s=this._commands[o.name];s.redo?s.redo(o.data):s.do(o.data)}}return this.ctx.emit("change-history",{reason:"redo"}),{undos:n,redos:t}}),this));m(this,"bail",()=>(this._undo({pushToRedoStack:!1}),this));m(this,"bailToMark",n=>(this._undo({pushToRedoStack:!1,toMark:n}),this));m(this,"mark",(n=ze(),t=!0,r=!0)=>{const o=this._undos.get().head;return o&&o.type==="STOP"&&o.id===n&&o.onUndo===t&&o.onRedo===r?o.id:(this._undos.update(s=>s.push({type:"STOP",id:n,onUndo:t,onRedo:r})),this.ctx.emit("mark-history",{id:n}),n)});this.ctx=n,this.annotateError=t}getNumUndos(){return this._undos.get().length}getNumRedos(){return this._redos.get().length}clear(){this._undos.set(ni()),this._redos.set(ni())}}class oN{constructor(n){m(this,"scribbleItems",new Map);m(this,"state","paused");m(this,"addScribble",(n,t=ze())=>{const r={id:t,scribble:{id:t,size:20,color:"accent",opacity:.8,delay:0,points:[],shrink:.1,taper:!0,...n,state:"starting"},timeoutMs:0,delayRemaining:n.delay??0,prev:null,next:null};return this.scribbleItems.set(t,r),this.state==="paused"&&this.resume(),r});m(this,"stop",n=>{const t=this.scribbleItems.get(n);if(!t)throw Error(`Scribble with id ${n} not found`);return t.delayRemaining=Math.min(t.delayRemaining,200),t.scribble.state="stopping",t});m(this,"addPoint",(n,t,r)=>{const o=this.scribbleItems.get(n);if(!o)throw Error(`Scribble with id ${n} not found`);const{prev:s}=o,i={x:t,y:r,z:.5};return(!s||b.Dist(s,i)>=1)&&(o.next=i),o});m(this,"tick",n=>{this.editor.batch(()=>{this.scribbleItems.forEach(t=>{if(t.scribble.state==="starting"){const{next:l,prev:c}=t;l&&l!==c&&(t.prev=l,t.scribble.points.push(l)),t.scribble.points.length>8&&(t.scribble.state="active");return}t.delayRemaining>0&&(t.delayRemaining=Math.max(0,t.delayRemaining-n)),t.timeoutMs+=n,t.timeoutMs>=16&&(t.timeoutMs=0);const{delayRemaining:r,timeoutMs:o,prev:s,next:i,scribble:a}=t;switch(a.state){case"active":{i&&i!==s?(t.prev=i,a.points.push(i),r===0&&a.points.length>8&&a.points.shift()):o===0&&(a.points.length>1?a.points.shift():t.delayRemaining=a.delay);break}case"stopping":{if(t.delayRemaining===0&&o===0){if(a.points.length===1){this.scribbleItems.delete(t.id);return}a.shrink&&(a.size=Math.max(1,a.size*(1-a.shrink))),a.points.shift()}break}}}),this.editor.updateInstanceState({scribbles:Array.from(this.scribbleItems.values()).map(({scribble:t})=>({...t,points:[...t.points]})).slice(-5)}),this.scribbleItems.size===0&&this.pause()})});this.editor=n}resume(){this.state="running",this.editor.addListener("tick",this.tick)}pause(){this.editor.removeListener("tick",this.tick),this.state="paused"}reset(){this.editor.updateInstanceState({scribbles:[]}),this.scribbleItems.clear(),this.pause()}}class sN{constructor(n){m(this,"_beforeCreateHandlers",{});m(this,"_afterCreateHandlers",{});m(this,"_beforeChangeHandlers",{});m(this,"_afterChangeHandlers",{});m(this,"_beforeDeleteHandlers",{});m(this,"_afterDeleteHandlers",{});m(this,"_batchCompleteHandlers",[]);this.editor=n,n.store.onBeforeCreate=(r,o)=>{const s=this._beforeCreateHandlers[r.typeName];if(s){let i=r;for(const a of s)i=a(i,o);return i}return r},n.store.onAfterCreate=(r,o)=>{const s=this._afterCreateHandlers[r.typeName];if(s)for(const i of s)i(r,o)},n.store.onBeforeChange=(r,o,s)=>{const i=this._beforeChangeHandlers[o.typeName];if(i){let a=o;for(const l of i)a=l(r,a,s);return a}return o};let t=0;n.store.onAfterChange=(r,o,s)=>{if(t++,t>1e3)console.error("[CleanupManager.onAfterChange] Maximum update depth exceeded, bailing out.");else{const i=this._afterChangeHandlers[o.typeName];if(i)for(const a of i)a(r,o,s)}t--},n.store.onBeforeDelete=(r,o)=>{const s=this._beforeDeleteHandlers[r.typeName];if(s){for(const i of s)if(i(r,o)===!1)return!1}},n.store.onAfterDelete=(r,o)=>{const s=this._afterDeleteHandlers[r.typeName];if(s)for(const i of s)i(r,o)},n.history.onBatchComplete=()=>{this._batchCompleteHandlers.forEach(r=>r())}}registerBeforeCreateHandler(n,t){return this._beforeCreateHandlers[n]||(this._beforeCreateHandlers[n]=[]),this._beforeCreateHandlers[n].push(t),()=>ri(this._beforeCreateHandlers[n],t)}registerAfterCreateHandler(n,t){return this._afterCreateHandlers[n]||(this._afterCreateHandlers[n]=[]),this._afterCreateHandlers[n].push(t),()=>ri(this._afterCreateHandlers[n],t)}registerBeforeChangeHandler(n,t){return this._beforeChangeHandlers[n]||(this._beforeChangeHandlers[n]=[]),this._beforeChangeHandlers[n].push(t),()=>ri(this._beforeChangeHandlers[n],t)}registerAfterChangeHandler(n,t){return this._afterChangeHandlers[n]||(this._afterChangeHandlers[n]=[]),this._afterChangeHandlers[n].push(t),()=>ri(this._afterChangeHandlers[n],t)}registerBeforeDeleteHandler(n,t){return this._beforeDeleteHandlers[n]||(this._beforeDeleteHandlers[n]=[]),this._beforeDeleteHandlers[n].push(t),()=>ri(this._beforeDeleteHandlers[n],t)}registerAfterDeleteHandler(n,t){return this._afterDeleteHandlers[n]||(this._afterDeleteHandlers[n]=[]),this._afterDeleteHandlers[n].push(t),()=>ri(this._afterDeleteHandlers[n],t)}registerBatchCompleteHandler(n){return this._batchCompleteHandlers.push(n),()=>ri(this._batchCompleteHandlers,n)}}function ri(e,n){const t=e.indexOf(n);t>=0&&e.splice(t,1)}var iN=Object.defineProperty,aN=Object.getOwnPropertyDescriptor,mf=(e,n,t,r)=>{for(var o=r>1?void 0:r?aN(n,t):n,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(r?i(n,t,o):i(o))||o);return r&&o&&iN(n,t,o),o};const ue=e=>Math.round(e*10**8)/10**8;function Io(e,n,t,r,o){const s=e.filter(a=>(r==="forward"?a.startNode.id===n:a.endNode.id===n)&&ue(a.length)===ue(t)&&_r(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=Io(e,l,t,r,_r(a.breadthIntersection[0],a.breadthIntersection[1],o[0],o[1]));s.push(...c)}}),s}function lN(e){e.sort((n,t)=>t.gaps.length-n.gaps.length);for(let n=e.length-1;n>0;n--){const t=e[n];for(let r=n-1;r>=0;r--){const o=e[r];if(o.direction===t.direction&&t.gaps.every(s=>o.gaps.some(i=>ue(s.startEdge[0].x)===ue(i.startEdge[0].x)&&ue(s.startEdge[0].y)===ue(i.startEdge[0].y)&&ue(s.startEdge[1].x)===ue(i.startEdge[1].x)&&ue(s.startEdge[1].y)===ue(i.startEdge[1].y))&&o.gaps.some(i=>ue(s.endEdge[0].x)===ue(i.endEdge[0].x)&&ue(s.endEdge[0].y)===ue(i.endEdge[0].y)&&ue(s.endEdge[1].x)===ue(i.endEdge[1].x)&&ue(s.endEdge[1].y)===ue(i.endEdge[1].y)))){e.splice(n,1);break}}}}class Pu{constructor(n){m(this,"editor");this.manager=n,this.editor=n.editor}getSnapPointsCache(){const{editor:n}=this;return n.store.createComputedCache("snapPoints",t=>{const r=n.getShapePageTransform(t.id);if(!r)return;const s=n.getShapeUtil(t).getBoundsSnapGeometry(t).points??n.getShapeGeometry(t).bounds.cornersAndCenter;if(!(!r||!s))return s.map((i,a)=>{const{x:l,y:c}=re.applyToPoint(r,i);return{x:l,y:c,id:`${t.id}:${a}`}})})}getSnapPoints(n){return this.getSnapPointsCache().get(n)??[]}getSnappablePoints(){const n=this.getSnapPointsCache(),t=this.manager.getSnappableShapes(),r=[];for(const o of t){const s=n.get(o);s&&r.push(...s)}return r}getSnappableGapNodes(){return Array.from(this.manager.getSnappableShapes(),n=>({id:n,pageBounds:ai(this.editor.getShapePageBounds(n))}))}getVisibleGaps(){const n=[],t=[];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&&kl(r.pageBounds.minY,r.pageBounds.maxY,o.pageBounds.minY,o.pageBounds.maxY)&&n.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:_r(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&&kl(r.pageBounds.minX,r.pageBounds.maxX,o.pageBounds.minX,o.pageBounds.maxX)&&t.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:_r(r.pageBounds.minX,r.pageBounds.maxX,o.pageBounds.minX,o.pageBounds.maxX)})}return{horizontal:n,vertical:t}}snapTranslateShapes({lockedAxis:n,initialSelectionPageBounds:t,initialSelectionSnapPoints:r,dragDelta:o}){var v,S;const s=this.manager.getSnapThreshold(),i=this.getSnappablePoints(),a=t.clone().translate(o),l=r.map(({x:w,y:C},I)=>({id:"selection:"+I,x:w+o.x,y:C+o.y})),c=i,u=[],d=[],h=new b(s,s);this.collectPointSnaps({minOffset:h,nearestSnapsX:u,nearestSnapsY:d,otherNodeSnapPoints:c,selectionSnapPoints:l}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d,minOffset:h});const f=new b(n==="x"?0:((v=u[0])==null?void 0:v.nudge)??0,n==="y"?0:((S=d[0])==null?void 0:S.nudge)??0);h.x=0,h.y=0,u.length=0,d.length=0,l.forEach(w=>{w.x+=f.x,w.y+=f.y}),a.translate(f),this.collectPointSnaps({minOffset:h,nearestSnapsX:u,nearestSnapsY:d,otherNodeSnapPoints:c,selectionSnapPoints:l}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d,minOffset:h});const y=this.getPointSnapLines({nearestSnapsX:u,nearestSnapsY:d}),g=this.getGapSnapLines({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d});return this.manager.setIndicators([...g,...y]),{nudge:f}}snapResizeShapes({initialSelectionPageBounds:n,dragDelta:t,handle:r,isAspectRatioLocked:o,isResizingFromCenter:s}){var _,k;const i=this.manager.getSnapThreshold(),{box:a,scaleX:l,scaleY:c}=ne.Resize(n,r,s?t.x*2:t.x,s?t.y*2:t.y,o);let u=r;l<0&&(u=$L(u)),c<0&&(u=TL(u)),s&&(a.center=n.center);const d=u==="top"||u==="bottom",h=u==="left"||u==="right",f=kb(u,a),y=this.getSnappablePoints(),g=[],v=[],S=new b(i,i);this.collectPointSnaps({minOffset:S,nearestSnapsX:g,nearestSnapsY:v,otherNodeSnapPoints:y,selectionSnapPoints:f});const w=new b(d?0:((_=g[0])==null?void 0:_.nudge)??0,h?0:((k=v[0])==null?void 0:k.nudge)??0);if(o&&ML(u)&&w.len()!==0){const M=g.length&&v.length?Math.abs(w.x)<Math.abs(w.y)?"x":"y":g.length?"x":"y",T=n.aspectRatio;M==="x"?(v.length=0,w.y=w.x/T,(u==="bottom_left"||u==="top_right")&&(w.y=-w.y)):(g.length=0,w.x=w.y*T,(u==="bottom_left"||u==="top_right")&&(w.x=-w.x))}const C=b.Add(t,w),{box:I}=ne.Resize(n,r,s?C.x*2:C.x,s?C.y*2:C.y,o);s&&(I.center=n.center);const P=kb("any",I);g.length=0,v.length=0,S.x=0,S.y=0,this.collectPointSnaps({minOffset:S,nearestSnapsX:g,nearestSnapsY:v,otherNodeSnapPoints:y,selectionSnapPoints:P});const E=this.getPointSnapLines({nearestSnapsX:g,nearestSnapsY:v});return this.manager.setIndicators([...E]),{nudge:w}}collectPointSnaps({selectionSnapPoints:n,otherNodeSnapPoints:t,minOffset:r,nearestSnapsX:o,nearestSnapsY:s}){for(const i of n)for(const a of t){const l=b.Sub(i,a),c=Math.abs(l.x),u=Math.abs(l.y);ue(c)<=ue(r.x)&&(ue(c)<ue(r.x)&&(o.length=0),o.push({type:"points",points:{thisPoint:i,otherPoint:a},nudge:a.x-i.x}),r.x=c),ue(u)<=ue(r.y)&&(ue(u)<ue(r.y)&&(s.length=0),s.push({type:"points",points:{thisPoint:i,otherPoint:a},nudge:a.y-i.y}),r.y=u)}}collectGapSnaps({selectionPageBounds:n,minOffset:t,nearestSnapsX:r,nearestSnapsY:o}){const{horizontal:s,vertical:i}=this.getVisibleGaps();for(const a of s){if(!kl(a.breadthIntersection[0],a.breadthIntersection[1],n.minY,n.maxY))continue;const c=a.startEdge[0].x+a.length/2-n.center.x;if(a.length>n.width&&ue(Math.abs(c))<=ue(t.x)){ue(Math.abs(c))<ue(t.x)&&(r.length=0),t.x=Math.abs(c);const S={type:"gap_center",gap:a,nudge:c},w=r.find(({type:I})=>I==="gap_center"),C=w&&_r(a.breadthIntersection[0],a.breadthIntersection[1],w.gap.breadthIntersection[0],w.gap.breadthIntersection[1]);w&&w.gap.length>a.length&&C?r[r.indexOf(w)]=S:(!w||!C)&&r.push(S)}const d=a.startNode.pageBounds.minX-a.length,h=n.maxX,f=d-h;ue(Math.abs(f))<=ue(t.x)&&(ue(Math.abs(f))<ue(t.x)&&(r.length=0),t.x=Math.abs(f),r.push({type:"gap_duplicate",gap:a,protrusionDirection:"left",nudge:f}));const y=a.endNode.pageBounds.maxX+a.length,g=n.minX,v=y-g;ue(Math.abs(v))<=ue(t.x)&&(ue(Math.abs(v))<ue(t.x)&&(r.length=0),t.x=Math.abs(v),r.push({type:"gap_duplicate",gap:a,protrusionDirection:"right",nudge:v}))}for(const a of i){if(!kl(a.breadthIntersection[0],a.breadthIntersection[1],n.minX,n.maxX))continue;const c=a.startEdge[0].y+a.length/2-n.center.y;if(a.length>n.height&&ue(Math.abs(c))<=ue(t.y)){ue(Math.abs(c))<ue(t.y)&&(o.length=0),t.y=Math.abs(c);const S={type:"gap_center",gap:a,nudge:c},w=o.find(({type:I})=>I==="gap_center"),C=w&&kl(w.gap.breadthIntersection[0],w.gap.breadthIntersection[1],a.breadthIntersection[0],a.breadthIntersection[1]);w&&w.gap.length>a.length&&C?o[o.indexOf(w)]=S:(!w||!C)&&o.push(S);continue}const d=a.startNode.pageBounds.minY-a.length,h=n.maxY,f=d-h;ue(Math.abs(f))<=ue(t.y)&&(ue(Math.abs(f))<ue(t.y)&&(o.length=0),t.y=Math.abs(f),o.push({type:"gap_duplicate",gap:a,protrusionDirection:"top",nudge:f}));const y=a.endNode.pageBounds.maxY+a.length,g=n.minY,v=y-g;ue(Math.abs(v))<=ue(t.y)&&(ue(Math.abs(v))<ue(t.y)&&(o.length=0),t.y=Math.abs(v),o.push({type:"gap_duplicate",gap:a,protrusionDirection:"bottom",nudge:v}))}}getPointSnapLines({nearestSnapsX:n,nearestSnapsY:t}){const r={},o={};if(n.length>0){for(const s of n)if(s.type==="points"){const i=ue(s.points.otherPoint.x);r[i]||(r[i]=[]),r[i].push(s.points)}}if(t.length>0){for(const s of t)if(s.type==="points"){const i=ue(s.points.otherPoint.y);o[i]||(o[i]=[]),o[i].push(s.points)}}return Object.values(r).concat(Object.values(o)).map(s=>({id:ze(),type:"points",points:ep(s.map(i=>b.From(i.otherPoint)).concat(s.map(i=>b.From(i.thisPoint))),(i,a)=>i.equals(a))}))}getGapSnapLines({selectionPageBounds:n,nearestSnapsX:t,nearestSnapsY:r}){const{vertical:o,horizontal:s}=this.getVisibleGaps(),i={top:n.sides[0],right:n.sides[1],bottom:[n.corners[3],n.corners[2]],left:[n.corners[0],n.corners[3]]},a=[];if(t.length>0)for(const l of t){if(l.type==="points")continue;const{gap:{breadthIntersection:c,startEdge:u,startNode:d,endNode:h,length:f,endEdge:y}}=l;switch(l.type){case"gap_center":{const g=(f-n.width)/2,v=_r(c[0],c[1],n.minY,n.maxY);a.push({type:"gaps",direction:"horizontal",id:ze(),gaps:[...Io(s,d.id,g,"backward",v),{startEdge:u,endEdge:i.left},{startEdge:i.right,endEdge:y},...Io(s,h.id,g,"forward",v)]});break}case"gap_duplicate":{const g=_r(c[0],c[1],n.minY,n.maxY);a.push({type:"gaps",direction:"horizontal",id:ze(),gaps:l.protrusionDirection==="left"?[{startEdge:i.right,endEdge:u.map(v=>v.clone().addXY(-d.pageBounds.width,0))},{startEdge:u,endEdge:y},...Io(s,h.id,f,"forward",g)]:[...Io(s,d.id,f,"backward",g),{startEdge:u,endEdge:y},{startEdge:y.map(v=>v.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:d,endNode:h,length:f,endEdge:y}}=l;switch(l.type){case"gap_center":{const g=(f-n.height)/2,v=_r(c[0],c[1],n.minX,n.maxX);a.push({type:"gaps",direction:"vertical",id:ze(),gaps:[...Io(o,d.id,g,"backward",v),{startEdge:u,endEdge:i.top},{startEdge:i.bottom,endEdge:y},...Io(o,l.gap.endNode.id,g,"forward",v)]});break}case"gap_duplicate":{const g=_r(c[0],c[1],n.minX,n.maxX);a.push({type:"gaps",direction:"vertical",id:ze(),gaps:l.protrusionDirection==="top"?[{startEdge:i.bottom,endEdge:u.map(v=>v.clone().addXY(0,-d.pageBounds.height))},{startEdge:u,endEdge:y},...Io(o,h.id,f,"forward",g)]:[...Io(o,d.id,f,"backward",g),{startEdge:u,endEdge:y},{startEdge:y.map(v=>v.clone().addXY(0,h.pageBounds.height)),endEdge:i.top}]})}break}}return lN(a),a}}mf([Z],Pu.prototype,"getSnapPointsCache",1);mf([Z],Pu.prototype,"getSnappablePoints",1);mf([Z],Pu.prototype,"getSnappableGapNodes",1);mf([Z],Pu.prototype,"getVisibleGaps",1);function kb(e,n){const{minX:t,maxX:r,minY:o,maxY:s}=n,i=[];switch(e){case"top":case"left":case"top_left":case"any":i.push({id:"top_left",handle:"top_left",x:t,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:t,y:s})}return i}var cN=Object.defineProperty,uN=Object.getOwnPropertyDescriptor,dN=(e,n,t,r)=>{for(var o=r>1?void 0:r?uN(n,t):n,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(r?i(n,t,o):i(o))||o);return r&&o&&cN(n,t,o),o};const hN=()=>null,pN=()=>[];class h_{constructor(n){m(this,"editor");this.manager=n,this.editor=n.editor}getSnapGeometryCache(){const{editor:n}=this;return n.store.createComputedCache("handle snap geometry",t=>{const r=n.getShapeUtil(t).getHandleSnapGeometry(t);return{outline:r.outline===void 0?n.getShapeGeometry(t):r.outline,points:r.points??[],getSelfSnapOutline:r.getSelfSnapOutline??hN,getSelfSnapPoints:r.getSelfSnapPoints??pN}})}*iterateSnapPointsInPageSpace(n,t){var o,s;const r=(o=this.getSnapGeometryCache().get(n))==null?void 0:o.getSelfSnapPoints(t);if(r&&r.length){const i=ai(this.editor.getShapePageTransform(n));for(const a of r)yield i.applyToPoint(a)}for(const i of this.manager.getSnappableShapes()){if(i===n)continue;const a=(s=this.getSnapGeometryCache().get(i))==null?void 0:s.points;if(!a||!a.length)continue;const l=ai(this.editor.getShapePageTransform(i));for(const c of a)yield l.applyToPoint(c)}}*iterateSnapOutlines(n,t){var o,s;const r=(o=this.getSnapGeometryCache().get(n))==null?void 0:o.getSelfSnapOutline(t);r&&(yield{shapeId:n,outline:r});for(const i of this.manager.getSnappableShapes()){if(i===n)continue;const a=(s=this.getSnapGeometryCache().get(i))==null?void 0:s.outline;a&&(yield{shapeId:i,outline:a})}}getHandleSnapPosition({currentShapeId:n,handle:t,handleInPageSpace:r}){const o=this.manager.getSnapThreshold();let s=o,i=null;for(const c of this.iterateSnapPointsInPageSpace(n,t)){const u=b.Dist(r,c);u<s&&(s=u,i=c)}if(i)return i;let a=o,l=null;for(const{shapeId:c,outline:u}of this.iterateSnapOutlines(n,t)){const d=ai(this.editor.getShapePageTransform(c)),h=this.editor.getPointInShapeSpace(c,r),f=u.nearestPoint(h),y=d.applyToPoint(f),g=b.Dist(r,y);g<a&&(a=g,l=y)}return l||null}snapHandle({currentShapeId:n,handle:t}){const o=ai(this.editor.getShapePageTransform(n)).applyToPoint(t),s=this.getHandleSnapPosition({currentShapeId:n,handle:t,handleInPageSpace:o});return s?(this.manager.setIndicators([{id:ze(),type:"points",points:[s]}]),{nudge:b.Sub(s,o)}):null}}dN([Z],h_.prototype,"getSnapGeometryCache",1);var fN=Object.defineProperty,gN=Object.getOwnPropertyDescriptor,n0=(e,n,t,r)=>{for(var o=r>1?void 0:r?gN(n,t):n,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(r?i(n,t,o):i(o))||o);return r&&o&&fN(n,t,o),o};class yf{constructor(n){m(this,"shapeBounds");m(this,"handles");m(this,"_snapIndicators",hn("snapLines",void 0));this.editor=n,this.shapeBounds=new Pu(this),this.handles=new h_(this)}getIndicators(){return this._snapIndicators.get()??$s}clearIndicators(){this.getIndicators().length&&this._snapIndicators.set(void 0)}setIndicators(n){this._snapIndicators.set(n)}getSnapThreshold(){return 8/this.editor.getZoomLevel()}getSnappableShapes(){const{editor:n}=this,t=n.getRenderingBounds(),r=n.getSelectedShapeIds(),o=new Set,s=i=>{if(Hn(i)){const l=n.getShape(i);l&&n.isShapeOfType(l,"frame")&&o.add(i)}const a=n.getSortedChildIdsForParent(i);for(const l of a){if(r.includes(l))continue;const c=n.getShape(l);if(!c||!n.getShapeUtil(c).canSnap(c))continue;const d=n.getShapePageBounds(l);if(d&&t.includes(d)){if(n.isShapeOfType(c,"group")){s(l);continue}o.add(l)}}};return s(this.getCurrentCommonAncestor()??n.getCurrentPageId()),o}getCurrentCommonAncestor(){return this.editor.findCommonAncestor(this.editor.getSelectedShapes())}}n0([Z],yf.prototype,"getSnapThreshold",1);n0([Z],yf.prototype,"getSnappableShapes",1);n0([Z],yf.prototype,"getCurrentCommonAncestor",1);const mN=/\r?\n|\r/g;function Tb(e){return e.replace(mN,`
|
|
54
|
+
`).split(`
|
|
55
|
+
`).map(n=>n||" ").join(`
|
|
56
|
+
`)}const yN={start:"left","start-legacy":"left",middle:"center","middle-legacy":"center",end:"right","end-legacy":"right"},SN=/\s/;class vN{constructor(n){m(this,"baseElm");m(this,"measureText",(n,t)=>{var s;const r=(s=this.baseElm)==null?void 0:s.cloneNode();this.baseElm.insertAdjacentElement("afterend",r),r.setAttribute("dir","ltr"),r.style.setProperty("font-family",t.fontFamily),r.style.setProperty("font-style",t.fontStyle),r.style.setProperty("font-weight",t.fontWeight),r.style.setProperty("font-size",t.fontSize+"px"),r.style.setProperty("line-height",t.lineHeight*t.fontSize+"px"),r.style.setProperty("max-width",t.maxWidth===null?null:t.maxWidth+"px"),r.style.setProperty("min-width",t.minWidth??null),r.style.setProperty("padding",t.padding),r.textContent=Tb(n);const o=r.getBoundingClientRect();return r.remove(),{x:0,y:0,w:o.width,h:o.height}});this.editor=n;const t=document.createElement("div");t.id="tldraw_text_measure",t.classList.add("tl-text"),t.classList.add("tl-text-measure"),t.tabIndex=-1,this.editor.getContainer().appendChild(t),this.baseElm=t}measureElementTextNodeSpans(n,{shouldTruncateToFirstLine:t=!1}={}){const r=[],o=n.getBoundingClientRect(),s=-o.left,i=-o.top,a=new Range,l=n.childNodes[0];let c=0,u=null,d=null,h=0,f=!1;for(const y of n.childNodes)if(y.nodeType===Node.TEXT_NODE)for(const g of y.textContent??""){a.setStart(l,c),a.setEnd(l,c+g.length);const v=a.getClientRects(),S=v[v.length-1],w=S.top+i,C=S.left+s,I=S.right+s,P=SN.test(g);if(P!==d||w!==h||!u){if(u){if(t&&w!==h){f=!0;break}r.push(u)}u={box:{x:C,y:w,w:S.width,h:S.height},text:g}}else u.box.w=I-u.box.x,u.text+=g;d=P,h=w,c+=g.length}return u&&r.push(u),{spans:r,didTruncate:f}}measureTextSpans(n,t){var c;if(n==="")return[];const r=(c=this.baseElm)==null?void 0:c.cloneNode();this.baseElm.insertAdjacentElement("afterend",r);const o=Math.ceil(t.width-t.padding*2);r.style.setProperty("width",`${o}px`),r.style.setProperty("height","min-content"),r.style.setProperty("dir","ltr"),r.style.setProperty("font-size",`${t.fontSize}px`),r.style.setProperty("font-family",t.fontFamily),r.style.setProperty("font-weight",t.fontWeight),r.style.setProperty("line-height",`${t.lineHeight*t.fontSize}px`),r.style.setProperty("text-align",yN[t.textAlign]);const s=t.overflow==="truncate-ellipsis"||t.overflow==="truncate-clip";s&&(r.style.setProperty("overflow-wrap","anywhere"),r.style.setProperty("word-break","break-all"));const i=Tb(n);r.textContent=i;const{spans:a,didTruncate:l}=this.measureElementTextNodeSpans(r,{shouldTruncateToFirstLine:s});if(t.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 d=this.measureElementTextNodeSpans(r,{shouldTruncateToFirstLine:!0}).spans,h=d[d.length-1];return d.push({text:"…",box:{x:Math.min(h.box.x+h.box.w,t.width-t.padding-u),y:h.box.y,w:u,h:h.box.h}}),d}return r.remove(),a}}class wN{constructor(n){m(this,"raf");m(this,"isPaused",!0);m(this,"last",0);m(this,"t",0);m(this,"start",()=>{this.isPaused=!1,cancelAnimationFrame(this.raf),this.raf=requestAnimationFrame(this.tick),this.last=Date.now()});m(this,"tick",()=>{if(this.isPaused)return;const n=Date.now(),t=n-this.last;if(this.last=n,this.t+=t,this.editor.emit("frame",t),this.t<16){this.raf=requestAnimationFrame(this.tick);return}this.t-=16,this.updatePointerVelocity(t),this.editor.emit("tick",t),this.raf=requestAnimationFrame(this.tick)});m(this,"dispose",()=>{this.isPaused=!0,cancelAnimationFrame(this.raf)});m(this,"prevPoint",new b);m(this,"updatePointerVelocity",n=>{const{prevPoint:t,editor:{inputs:{currentScreenPoint:r,pointerVelocity:o}}}=this;if(n===0)return;const s=b.Sub(r,t);this.prevPoint=r.clone();const i=s.len(),a=i?s.div(i):new b(0,0),l=o.clone().lrp(a.mul(i/n),.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=n,this.editor.disposables.add(this.dispose),this.start()}}var xN=Object.defineProperty,bN=Object.getOwnPropertyDescriptor,po=(e,n,t,r)=>{for(var o=r>1?void 0:r?bN(n,t):n,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(r?i(n,t,o):i(o))||o);return r&&o&&xN(n,t,o),o};class Kr{constructor(n,t){m(this,"updateUserPreferences",n=>{this.user.setUserPreferences({...this.user.userPreferences.get(),...n})});this.user=n,this.inferDarkMode=t}getUserPreferences(){return{id:this.getId(),name:this.getName(),locale:this.getLocale(),color:this.getColor(),animationSpeed:this.getAnimationSpeed(),isSnapMode:this.getIsSnapMode(),isDarkMode:this.getIsDarkMode(),isWrapMode:this.getIsWrapMode()}}getIsDarkMode(){return this.user.userPreferences.get().isDarkMode??(this.inferDarkMode?$6():!1)}getEdgeScrollSpeed(){return this.user.userPreferences.get().edgeScrollSpeed??bn.edgeScrollSpeed}getAnimationSpeed(){return this.user.userPreferences.get().animationSpeed??bn.animationSpeed}getId(){return this.user.userPreferences.get().id}getName(){return this.user.userPreferences.get().name??bn.name}getLocale(){return this.user.userPreferences.get().locale??bn.locale}getColor(){return this.user.userPreferences.get().color??bn.color}getIsSnapMode(){return this.user.userPreferences.get().isSnapMode??bn.isSnapMode}getIsWrapMode(){return this.user.userPreferences.get().isWrapMode??bn.isWrapMode}}po([Z],Kr.prototype,"getUserPreferences",1);po([Z],Kr.prototype,"getIsDarkMode",1);po([Z],Kr.prototype,"getEdgeScrollSpeed",1);po([Z],Kr.prototype,"getAnimationSpeed",1);po([Z],Kr.prototype,"getId",1);po([Z],Kr.prototype,"getName",1);po([Z],Kr.prototype,"getLocale",1);po([Z],Kr.prototype,"getColor",1);po([Z],Kr.prototype,"getIsSnapMode",1);po([Z],Kr.prototype,"getIsWrapMode",1);function $l(e){return Math.abs(e.props.bend)<8}function xp(e,n){if(n.type==="point")return;const t=e.getShape(n.boundShapeId),r=e.getShapePageTransform(t),o=e.getShapeGeometry(t),s=o instanceof no?o.children[0].vertices:o.vertices;return{shape:t,transform:r,isClosed:o.isClosed,isExact:n.isExact,didIntersect:!1,outline:s}}function $b(e,n,t,r){if(t.type==="point")return b.From(t);const o=e.getShape(t.boundShapeId);if(o){const{point:s,size:i}=e.getShapeGeometry(o).bounds,a=b.Add(s,b.MulV(t.isPrecise||r?t.normalizedAnchor:{x:.5,y:.5},i)),l=re.applyToPoint(e.getShapePageTransform(o),a);return re.applyToPoint(re.Inverse(n),l)}else return new b(0,0)}function Ar(e,n){const t=e.getShapePageTransform(n);let r,o;n.props.start.type==="binding"&&n.props.end.type==="binding"&&(r=n.props.start.boundShapeId,o=n.props.end.boundShapeId);const s=r0(e,r,o),i=$b(e,t,n.props.start,s==="double-bound"||s==="start-contains-end"),a=$b(e,t,n.props.end,s==="double-bound"||s==="end-contains-start");return{start:i,end:a}}const da=10,bp=10,PN=10,gs={s:2,m:3.5,l:5,xl:10};function r0(e,n,t){if(!n||!t)return"safe";if(n===t)return"double-bound";const r=e.getShapePageBounds(n),o=e.getShapePageBounds(t);if(r&&o){if(r.contains(o))return"start-contains-end";if(o.contains(r))return"end-contains-start"}return"safe"}function lc(e,n){const{start:t,end:r,arrowheadStart:o,arrowheadEnd:s}=n.props,i=Ar(e,n),a=i.start.clone(),l=i.end.clone(),c=b.Med(a,l);if(b.Equals(a,l))return{isStraight:!0,start:{handle:a,point:a,arrowhead:n.props.arrowheadStart},end:{handle:l,point:l,arrowhead:n.props.arrowheadEnd},middle:c,isValid:!1,length:0};const u=b.Sub(l,a).uni(),d=xp(e,t),h=xp(e,r),f=e.getShapePageTransform(n);Mb(l,i.start,f,h),Mb(a,i.end,f,d);let y=0,g=0,v=0,S=0,w=da;const C=d&&h&&d.shape===h.shape,I=d&&h?r0(e,d.shape.id,h.shape.id):"safe";I==="safe"&&d&&h&&!C&&!d.isExact&&!h.isExact&&(h.didIntersect&&!d.didIntersect?d.isClosed&&a.setTo(l.clone().add(u.clone().mul(da))):h.didIntersect||h.isClosed&&l.setTo(a.clone().sub(u.clone().mul(da))));const P=b.Sub(l,a),E=b.Len(P)?P.uni():b.From(P),_=!b.Equals(E,u);C||(I!=="start-contains-end"&&d&&o!=="none"&&!d.isExact&&(v=gs[n.props.size]/2+("size"in d.shape.props?gs[d.shape.props.size]/2:0),y=bp+v,w+=v),I!=="end-contains-start"&&h&&s!=="none"&&!h.isExact&&(S=gs[n.props.size]/2+("size"in h.shape.props?gs[h.shape.props.size]/2:0),g=bp+S,w+=S));const k=a.clone().add(E.clone().mul(y*(_?-1:1))),M=l.clone().sub(E.clone().mul(g*(_?-1:1)));b.Dist(k,M)<w&&(y!==0&&g!==0?(y*=-1.5,g*=-1.5):y!==0?y*=-1:g!==0&&(g*=-1)),a.add(E.clone().mul(y*(_?-1:1))),l.sub(E.clone().mul(g*(_?-1:1))),_?(d&&h&&l.setTo(b.Add(a,E.clone().mul(-da))),c.setTo(b.Med(i.start,i.end))):c.setTo(b.Med(a,l));const R=b.Dist(a,l);return{isStraight:!0,start:{handle:i.start,point:a,arrowhead:n.props.arrowheadStart},end:{handle:i.end,point:l,arrowhead:n.props.arrowheadEnd},middle:c,isValid:R>0,length:R}}function Mb(e,n,t,r){if(r===void 0||r.isExact)return;const o=re.applyToPoint(t,n),s=re.applyToPoint(t,e),i=re.applyToPoint(re.Inverse(r.transform),o),a=re.applyToPoint(re.Inverse(r.transform),s),l=r.isClosed,u=(l?a_:i_)(i,a,r.outline);let d;if(u!==null&&(d=u.sort((y,g)=>b.Dist(y,i)-b.Dist(g,i))[0]??(l?void 0:a)),d===void 0)return;const h=re.applyToPoint(r.transform,d),f=re.applyToPoint(re.Inverse(t),h);e.setTo(f),r.didIntersect=!0}function Rg(e,n,t=0){const{arrowheadEnd:r,arrowheadStart:o}=n.props,s=n.props.bend+t;if(Math.abs(s)>Math.abs(n.props.bend*PN))return lc(e,n);const i=Ar(e,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)),d=xp(e,n.props.start),h=xp(e,n.props.end),f=i.start.clone(),y=i.end.clone(),g=u.clone();if(b.Equals(f,y))return{isStraight:!0,start:{handle:f,point:f,arrowhead:n.props.arrowheadStart},end:{handle:y,point:y,arrowhead:n.props.arrowheadEnd},middle:g,isValid:!1,length:0};const v=n.props.bend<0,S=v?yu:xE,w=Ab(f,y,g),C=b.Angle(w.center,f),I=b.Angle(w.center,y),P=S(C,I);if(w.length===0||w.size===0||!eb(w.length)||!eb(w.size))return lc(e,n);const E=f.clone(),_=y.clone(),k=g.clone(),M=e.getShapePageTransform(n);let T=0,R=0,O=da;if(d&&!d.isExact){const Y=re.applyToPoint(M,E),J=re.applyToPoint(M,w.center),ke=re.applyToPoint(M,_),ve=re.Inverse(d.transform),pe=re.applyToPoint(ve,Y),me=re.applyToPoint(ve,J),Xe=re.applyToPoint(ve,ke),{isClosed:Ae}=d,Ue=Ae?Uy:Cb;let yt,St=Ue(me,w.radius,d.outline);if(St){const Le=me.angle(pe),br=me.angle(Xe),Nn=S(Le,br);St=St.filter(pt=>S(Le,me.angle(pt))<=Nn);const xt=Nn*.25;St.sort(Ae?(pt,At)=>Math.abs(S(Le,me.angle(pt))-xt)<Math.abs(S(Le,me.angle(At))-xt)?-1:1:(pt,At)=>S(Le,me.angle(pt))<S(Le,me.angle(At))?-1:1),yt=St[0]??(Ae?void 0:pe)}else yt=Ae?void 0:pe;if(yt&&(E.setTo(e.getPointInShapeSpace(n,re.applyToPoint(d.transform,yt))),d.didIntersect=!0,o!=="none")){const Le=gs[n.props.size]/2+("size"in d.shape.props?gs[d.shape.props.size]/2:0);T=bp+Le,O+=Le}}if(h&&!h.isExact){const Y=re.applyToPoint(M,E),J=re.applyToPoint(M,_),ke=re.applyToPoint(M,w.center),ve=re.Inverse(h.transform),pe=re.applyToPoint(ve,Y),me=re.applyToPoint(ve,ke),Xe=re.applyToPoint(ve,J),Ae=h.isClosed,Ue=Ae?Uy:Cb;let yt,St=Ue(me,w.radius,h.outline);if(St){const Le=me.angle(pe),br=me.angle(Xe),Nn=S(Le,br),xt=Nn*.75;St=St.filter(pt=>S(Le,me.angle(pt))<=Nn),St.sort(Ae?(pt,At)=>Math.abs(S(Le,me.angle(pt))-xt)<Math.abs(S(Le,me.angle(At))-xt)?-1:1:(pt,At)=>S(Le,me.angle(pt))<S(Le,me.angle(At))?-1:1),St[0]?yt=St[0]:yt=Ae?void 0:Xe}else yt=Ae?void 0:Xe;if(yt&&(_.setTo(e.getPointInShapeSpace(n,re.applyToPoint(h.transform,yt))),h.didIntersect=!0,r!=="none")){const Le=gs[n.props.size]/2+("size"in h.shape.props?gs[h.shape.props.size]/2:0);R=bp+Le,O+=Le}}let U=b.Angle(w.center,E),N=b.Angle(w.center,_),L=S(U,N),G=L*w.radius;const X=E.clone(),H=_.clone();if(T!==0){const Y=T/G*(v?1:-1),J=b.FromAngle(U+L*Y);X.setTo(w.center).add(J.mul(w.radius))}if(R!==0){const Y=R/G*(v?-1:1),J=b.FromAngle(N+L*Y);H.setTo(w.center).add(J.mul(w.radius))}if(b.Dist(X,H)<O&&(T!==0&&R!==0?(T*=-1.5,R*=-1.5):T!==0?T*=-2:R!==0&&(R*=-2)),T!==0){const Y=T/G*(v?1:-1),J=b.FromAngle(U+L*Y);E.setTo(w.center).add(J.mul(w.radius))}if(R!==0){const Y=R/G*(v?-1:1),J=b.FromAngle(N+L*Y);_.setTo(w.center).add(J.mul(w.radius))}if(d&&h&&!d.isExact&&!h.isExact){U=b.Angle(w.center,E),N=b.Angle(w.center,_),L=S(U,N),G=L*w.radius;const Y=r0(e,d.shape.id,h.shape.id);if(Y==="double-bound"&&G<30)E.setTo(f),_.setTo(y),k.setTo(g);else if(Y==="safe"&&(d&&!d.didIntersect&&E.setTo(f),h&&!h.didIntersect||S(C,U)>S(C,N))){const J=Math.min(.9,da/G)*(v?1:-1),ke=b.FromAngle(U+L*J);_.setTo(w.center).add(ke.mul(w.radius))}}CN(w.center,w.radius,E,_,k,P,v),E.equals(_)&&(E.setTo(k.clone().addXY(1,1)),_.setTo(k.clone().subXY(1,1))),f.setTo(E),y.setTo(_),g.setTo(k);const W=Ab(f,y,g);return{isStraight:!1,start:{point:f,handle:i.start,arrowhead:n.props.arrowheadStart},end:{point:y,handle:i.end,arrowhead:n.props.arrowheadEnd},middle:g,handleArc:w,bodyArc:W,isValid:W.length!==0&&isFinite(W.center.x)&&isFinite(W.center.y)}}function Ab(e,n,t){const r=-2*(e.x*(n.y-t.y)-e.y*(n.x-t.x)+n.x*t.y-t.x*n.y),o={x:((e.x*e.x+e.y*e.y)*(t.y-n.y)+(n.x*n.x+n.y*n.y)*(e.y-t.y)+(t.x*t.x+t.y*t.y)*(n.y-e.y))/r,y:((e.x*e.x+e.y*e.y)*(n.x-t.x)+(n.x*n.x+n.y*n.y)*(t.x-e.x)+(t.x*t.x+t.y*t.y)*(e.x-n.x))/r},s=b.Dist(o,e),i=+b.Clockwise(e,t,n),a=Math.hypot(e.y-n.y,e.x-n.x),l=Math.hypot(n.y-t.y,n.x-t.x),c=Math.hypot(t.y-e.y,t.x-e.x),u=Math.acos((l*l+c*c-a*a)/(2*l*c))*2,d=+($e>u),h=(De-u)*(i?1:-1),f=h*s;return{center:o,radius:s,size:h,length:f,largeArcFlag:d,sweepFlag:i}}function CN(e,n,t,r,o,s,i){const a=b.Angle(e,t),l=b.Angle(e,r);let c=yu(a,l);i||(c=De-c);const u=.5*(i?1:-1),d=b.FromAngle(a+c*u);if(o.setTo(e).add(d.mul(n)),c>s){o.rotWith(e,$e);const h=r.clone();r.setTo(t),t.setTo(h)}}const IN={wheel:"onWheel",pointer_down:"onPointerDown",pointer_move:"onPointerMove",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"};class oe{constructor(n,t){m(this,"id");m(this,"type");m(this,"shapeType");m(this,"initial");m(this,"children");m(this,"parent");m(this,"_path");m(this,"_current");m(this,"_isActive");m(this,"transition",(n,t={})=>{var s;const r=n.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(t,a),o._current.set(c),c.enter(t,(l==null?void 0:l.id)||"initial"),!c.getIsActive()))break;o=c}return this});m(this,"handleEvent",n=>{var o;const t=IN[n.name],r=this.getCurrent();(o=this[t])==null||o.call(this,n),this.getCurrent()===r&&this.getIsActive()&&(r==null||r.handleEvent(n))});m(this,"enter",(n,t)=>{var r;if(this._isActive.set(!0),(r=this.onEnter)==null||r.call(this,n,t),this.onTick&&this.editor.on("tick",this.onTick),this.children&&this.initial&&this.getIsActive()){const o=this.children[this.initial];this._current.set(o),o.enter(n,t)}});m(this,"exit",(n,t)=>{var r,o;this._isActive.set(!1),this.onTick&&this.editor.off("tick",this.onTick),(r=this.onExit)==null||r.call(this,n,t),this.getIsActive()||(o=this.getCurrent())==null||o.exit(n,t)});m(this,"_currentToolIdMask",hn("curent tool id mask",void 0));m(this,"onWheel");m(this,"onPointerDown");m(this,"onPointerMove");m(this,"onPointerUp");m(this,"onDoubleClick");m(this,"onTripleClick");m(this,"onQuadrupleClick");m(this,"onRightClick");m(this,"onMiddleClick");m(this,"onKeyDown");m(this,"onKeyUp");m(this,"onKeyRepeat");m(this,"onCancel");m(this,"onComplete");m(this,"onInterrupt");m(this,"onEnter");m(this,"onExit");m(this,"onTick");this.editor=n;const{id:r,children:o,initial:s}=this.constructor;this.id=r,this._isActive=hn("toolIsActive"+this.id,!1),this._current=hn("toolState"+this.id,void 0),this._path=Z("toolPath"+this.id,()=>{const i=this.getCurrent();return this.id+(i?`.${i.getPath()}`:"")}),this.parent=t??{},this.parent?o&&s?(this.type="branch",this.initial=s,this.children=Object.fromEntries(o().map(i=>[i.id,new i(this.editor,this)])),this._current.set(this.children[this.initial])):this.type="leaf":(this.type="root",o&&s&&(this.initial=s,this.children=Object.fromEntries(o().map(i=>[i.id,new i(this.editor,this)])),this._current.set(this.children[this.initial])))}getPath(){return this._path.get()}getCurrent(){return this._current.get()}getIsActive(){return this._isActive.get()}getCurrentToolIdMask(){return this._currentToolIdMask.get()}setCurrentToolIdMask(n){this._currentToolIdMask.set(n)}}m(oe,"id"),m(oe,"initial"),m(oe,"children");class ah extends oe{constructor(){super(...arguments);m(this,"onKeyDown",t=>{var r;switch(t.code){case"KeyZ":{if(!(t.shiftKey||t.ctrlKey)){const o=this.getCurrent();o&&((r=o.getCurrent())==null?void 0:r.id)==="idle"&&this.children.zoom&&this.editor.setCurrentTool("zoom",{...t,onInteractionEnd:o.id})}break}}})}}m(ah,"id","root"),m(ah,"initial",""),m(ah,"children",()=>[]);var EN=Object.defineProperty,_N=Object.getOwnPropertyDescriptor,ce=(e,n,t,r)=>{for(var o=r>1?void 0:r?_N(n,t):n,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(r?i(n,t,o):i(o))||o);return r&&o&&EN(n,t,o),o};class ae extends L6.EventEmitter{constructor({store:t,user:r,shapeUtils:o,tools:s,getContainer:i,initialState:a,inferDarkMode:l}){super();m(this,"store");m(this,"root");m(this,"disposables",new Set);m(this,"_tickManager",new wN(this));m(this,"snaps");m(this,"user");m(this,"textMeasure");m(this,"environment");m(this,"scribbles");m(this,"getContainer");m(this,"sideEffects");m(this,"shapeUtils");m(this,"styleProps");m(this,"history",new rN(this,t=>{this.annotateError(t,{origin:"history.batch",willCrashApp:!0}),this.crash(t)}));m(this,"_crashingError",null);m(this,"_updateInstanceState",this.history.createCommand("updateInstanceState",(t,r)=>{const o=this.store.get(this.getInstanceState().id),s={...o,...t};return{data:{prev:o,next:s},ephemeral:!1,squashing:!1,...r}},{do:({next:t})=>{this.store.put([t])},undo:({prev:t})=>{this.store.put([t])},squash({prev:t},{next:r}){return{prev:t,next:r}}}));m(this,"_isChangingStyleTimeout",-1);m(this,"setCursor",t=>(this.updateInstanceState({cursor:{...this.getInstanceState().cursor,...t}},{ephemeral:!0}),this));m(this,"_setInstancePageState",this.history.createCommand("setInstancePageState",(t,r)=>({data:{prev:this.store.get(t.id??this.getCurrentPageState().id),partial:t},...r}),{do:({prev:t,partial:r})=>{this.store.update(t.id,o=>({...o,...r}))},undo:({prev:t})=>{this.store.update(t.id,()=>t)}}));m(this,"_setSelectedShapes",this.history.createCommand("setSelectedShapes",(t,r)=>{const{selectedShapeIds:o}=this.getCurrentPageState(),s=new Set(o);return t.length===s.size&&t.every(i=>s.has(i))?null:{data:{selectedShapeIds:t,prevSelectedShapeIds:o},preservesRedoStack:!0,...r}},{do:({selectedShapeIds:t})=>{this.store.put([{...this.getCurrentPageState(),selectedShapeIds:t}])},undo:({prevSelectedShapeIds:t})=>{this.store.put([{...this.getCurrentPageState(),selectedShapeIds:t}])},squash({prevSelectedShapeIds:t},{selectedShapeIds:r}){return{selectedShapeIds:r,prevSelectedShapeIds:t}}}));m(this,"_setFocusedGroupId",this.history.createCommand("setFocusedGroupId",t=>{const r=this.getCurrentPageState().focusedGroupId;if(r!==t)return{data:{prev:r,next:t},preservesRedoStack:!0,squashing:!0}},{do:({next:t})=>{this.store.update(this.getCurrentPageState().id,r=>({...r,focusedGroupId:t}))},undo:({prev:t})=>{this.store.update(this.getCurrentPageState().id,r=>({...r,focusedGroupId:t}))},squash({prev:t},{next:r}){return{prev:t,next:r}}}));m(this,"_viewportAnimation",null);m(this,"_willSetInitialBounds",!0);m(this,"_wasInset",!1);m(this,"_cameraState",hn("camera state","idle"));m(this,"_cameraStateTimeoutRemaining",0);m(this,"_lastUpdateRenderingBoundsTimestamp",Date.now());m(this,"_decayCameraStateTimeout",t=>{this._cameraStateTimeoutRemaining-=t,this._cameraStateTimeoutRemaining<=0&&(this.off("tick",this._decayCameraStateTimeout),this._cameraState.set("idle"),this.updateRenderingBounds())});m(this,"_tickCameraState",()=>{this._cameraStateTimeoutRemaining=KR;const t=Date.now();this._cameraState.__unsafe__getWithoutCapture()==="idle"?(this._lastUpdateRenderingBoundsTimestamp=t,this._cameraState.set("moving"),this.on("tick",this._decayCameraStateTimeout)):t-this._lastUpdateRenderingBoundsTimestamp>VR&&this.updateRenderingBounds()});m(this,"_renderingBounds",hn("rendering viewport",new ne));m(this,"_renderingBoundsExpanded",hn("rendering viewport expanded",new ne));m(this,"renderingBoundsMargin",100);m(this,"_currentPageShapeIds");m(this,"_setCurrentPageId",this.history.createCommand("setCurrentPage",(t,r)=>{if(!this.store.has(t)){console.error("Tried to set the current page id to a page that doesn't exist.");return}return this.stopFollowingUser(),{data:{toId:t,fromId:this.getCurrentPageId()},squashing:!0,preservesRedoStack:!0,...r}},{do:({toId:t})=>{if(this.store.has(t)){if(!this.getPageStates().find(r=>r.pageId===t)){const r=qt.create({id:qt.createId(t)});this.store.put([r,Zt.create({id:Zt.createId(t),pageId:t})])}this.store.put([{...this.getInstanceState(),currentPageId:t}]),this.updateRenderingBounds()}},undo:({fromId:t})=>{this.store.has(t)&&(this.store.put([{...this.getInstanceState(),currentPageId:t}]),this.updateRenderingBounds())},squash:({fromId:t},{toId:r})=>({toId:r,fromId:t})}));m(this,"_updatePage",this.history.createCommand("updatePage",(t,r)=>{if(this.getInstanceState().isReadonly)return null;const o=this.getPage(t.id);return o?{data:{prev:o,partial:t},...r}:null},{do:({partial:t})=>{this.store.update(t.id,r=>({...r,...t}))},undo:({prev:t,partial:r})=>{this.store.update(r.id,()=>t)},squash(t,r){return{prev:{...t.prev,...r.prev},partial:r.partial}}}));m(this,"_createPage",this.history.createCommand("createPage",t=>{if(this.getInstanceState().isReadonly||this.getPages().length>=fp)return null;const r=this.getPages(),o=V6(t.name??"Page 1",r.map(c=>c.name));let s=t.index;(!s||r.some(c=>c.index===s))&&(s=ko(r[r.length-1].index));const i=zo.create({meta:{},...t,name:o,index:s}),a=qt.create({id:qt.createId(i.id)}),l=Zt.create({id:Zt.createId(i.id),pageId:i.id});return{data:{newPage:i,newTabPageState:l,newCamera:a}}},{do:({newPage:t,newTabPageState:r,newCamera:o})=>{this.store.put([t,o,r])},undo:({newPage:t,newTabPageState:r,newCamera:o})=>{this.getPages().length!==1&&this.store.remove([r.id,t.id,o.id])}}));m(this,"_deletePage",this.history.createCommand("delete_page",t=>{if(this.getInstanceState().isReadonly)return null;const r=this.getPages();if(r.length===1)return null;const o=this.getPage(t),s=this.getPageStates().filter(i=>i.pageId===t);if(!o)return null;if(t===this.getCurrentPageId()){const i=r.findIndex(l=>l.id===t),a=r[i-1]??r[i+1];this.setCurrentPage(a.id)}return{data:{id:t,deletedPage:o,deletedPageStates:s}}},{do:({deletedPage:t,deletedPageStates:r})=>{const o=this.getPages();if(o.length!==1){if(t.id===this.getCurrentPageId()){const s=o.findIndex(a=>a.id===t.id),i=o[s-1]??o[s+1];this.setCurrentPage(i.id)}this.store.remove(r.map(s=>s.id)),this.store.remove([t.id]),this.updateRenderingBounds()}},undo:({deletedPage:t,deletedPageStates:r})=>{this.store.put([t]),this.store.put(r),this.updateRenderingBounds()}}));m(this,"_createAssets",this.history.createCommand("createAssets",t=>this.getInstanceState().isReadonly||t.length<=0?null:{data:{assets:t}},{do:({assets:t})=>{this.store.put(t)},undo:({assets:t})=>{this.store.remove(t.map(r=>r.id))}}));m(this,"_updateAssets",this.history.createCommand("updateAssets",t=>this.getInstanceState().isReadonly||t.length<=0?void 0:{data:{snapshots:{},assets:t}},{do:({assets:t,snapshots:r})=>{this.store.put(t.map(o=>{const s=this.store.get(o.id);return r[o.id]=s,{...s,...o}}))},undo:({snapshots:t})=>{this.store.put(Object.values(t))}}));m(this,"_deleteAssets",this.history.createCommand("deleteAssets",t=>{if(this.getInstanceState().isReadonly||t.length<=0)return;const r=ge(t.map(o=>this.store.get(o)));return{data:{ids:t,prev:r}}},{do:({ids:t})=>{this.store.remove(t)},undo:({prev:t})=>{this.store.put(t)}}));m(this,"_parentIdsToChildIds");m(this,"_childIdsCache",new e0);m(this,"_createShapes",this.history.createCommand("createShapes",t=>{if(this.getInstanceState().isReadonly||t.length<=0)return null;const r=this.getCurrentPageShapeIds();if(t.length+r.size>Co){ud(this);return}return t.length===0?null:{data:{currentPageId:this.getCurrentPageId(),partials:t.map(s=>s.id?s:{...s,id:We()})}}},{do:({partials:t})=>{var a,l;const r=this.getFocusedGroupId(),o=this.getCurrentPageShapesSorted();t=t.map(c=>{if(!c.parentId||!(this.store.has(c.parentId)||t.some(u=>u.id===c.parentId))){let u=this.getFocusedGroupId();for(let h=o.length-1;h>=0;h--){const f=o[h];if(this.getShapeUtil(f).canReceiveNewChildrenOfType(f,c.type)&&this.isPointInShape(f,{x:c.x??0,y:c.y??0},{margin:0,hitInside:!0})){u=f.id;break}}const d=c.parentId;if(u===c.id&&(u=r),u!==d&&(c={...c},c.parentId=u,Hn(u))){const h=this.getPointInShapeSpace(this.getShape(u),{x:c.x??0,y:c.y??0});c.x=h.x,c.y=h.y,c.rotation=-this.getShapePageTransform(u).rotation()+(c.rotation??0)}}return c});const s=new Map,i=[];for(const c of t){const u=this.getShapeUtil(c);let d=c.index;if(!d){const g=c.parentId??r;s.has(g)||s.set(g,this.getHighestIndexForParent(g)),d=s.get(g),s.set(g,ko(d))}const h=u.getDefaultProps();for(const[g,v]of this.styleProps[c.type])h[v]=this.getStyleForNextShape(g);let f=this.store.schema.types.shape.create({...c,index:d,opacity:c.opacity??this.getInstanceState().opacityForNextShape,parentId:c.parentId??r,props:"props"in c?{...h,...c.props}:h});if(f.index===void 0)throw Error("no index!");const y=(l=(a=this.getShapeUtil(f)).onBeforeCreate)==null?void 0:l.call(a,f);y&&(f=y),i.push(f)}i.forEach(c=>{c.meta={...this.getInitialMetaForShape(c),...c.meta}}),this.store.put(i)},undo:({partials:t})=>{this.store.remove(t.map(r=>r.id))}}));m(this,"animatingShapes",new Map);m(this,"_updateShapes",this.history.createCommand("updateShapes",(t,r)=>{if(this.getInstanceState().isReadonly)return null;const o={},s={};let i,a;for(let l=0,c=t.length;l<c;l++){const u=t[l];u&&(i=this.getShape(u.id),i&&(a=Ml(i,u),a!==i&&(o[i.id]=i,s[i.id]=a)))}return{data:{snapshots:o,updates:s},...r}},{do:({updates:t})=>{this.store.put(ot(t).map(r=>{var s,i;const o=this.store.get(r.id);if(o){const a=(i=(s=this.getShapeUtil(r)).onBeforeUpdate)==null?void 0:i.call(s,o,r);if(a)return a}return r}))},undo:({snapshots:t})=>{this.store.put(Object.values(t))},squash(t,r){return{snapshots:{...r.snapshots,...t.snapshots},updates:{...t.updates,...r.updates}}}}));m(this,"_deleteShapes",this.history.createCommand("delete_shapes",t=>{if(this.getInstanceState().isReadonly||t.length===0)return null;const r=[...this.getCurrentPageState().selectedShapeIds],o=new Set(t);for(const c of t)this.visitDescendants(c,u=>{o.add(u)});const s=[...o],i=this._getArrowBindingsIndex().get(),a=ge(s.flatMap(c=>{const u=this.getShape(c),d=i[c];return d&&d.length>0?d.map(({arrowId:h})=>this.getShape(h)).concat(u):u})),l=r.filter(c=>!o.has(c));return{data:{deletedIds:s,snapshots:a,prevSelectedShapeIds:r,postSelectedShapeIds:l}}},{do:({deletedIds:t,postSelectedShapeIds:r})=>{this.store.remove(t),this.store.update(this.getCurrentPageState().id,o=>({...o,selectedShapeIds:r}))},undo:({snapshots:t,prevSelectedShapeIds:r})=>{this.store.put(t),this.store.update(this.getCurrentPageState().id,o=>({...o,selectedShapeIds:r}))}}));m(this,"externalAssetContentHandlers",{file:null,url:null});m(this,"externalContentHandlers",{text:null,files:null,embed:null,"svg-text":null,url:null});m(this,"inputs",{originPagePoint:new 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});m(this,"_clickManager",new eN(this));m(this,"_prevCursor","default");m(this,"_shiftKeyTimeout",-1);m(this,"_setShiftKeyTimeout",()=>{this.inputs.shiftKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Shift",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,code:"ShiftLeft"})});m(this,"_altKeyTimeout",-1);m(this,"_setAltKeyTimeout",()=>{this.inputs.altKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Alt",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,code:"AltLeft"})});m(this,"_ctrlKeyTimeout",-1);m(this,"_setCtrlKeyTimeout",()=>{this.inputs.ctrlKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Ctrl",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,code:"ControlLeft"})});m(this,"_restoreToolId","select");m(this,"_pinchStart",1);m(this,"_didPinch",!1);m(this,"_selectedShapeIdsAtPointerDown",[]);m(this,"capturedPointerId",null);m(this,"dispatch",t=>{if(this.getCrashingError())return this;const{inputs:r}=this,{type:o}=t;return this.batch(()=>{if(t.type==="misc"){(t.name==="cancel"||t.name==="complete")&&(this.inputs.isDragging=!1,this.inputs.isPanning&&(this.inputs.isPanning=!1,this.updateInstanceState({cursor:{type:this._prevCursor,rotation:0}}))),this.root.handleEvent(t);return}t.shiftKey?(clearInterval(this._shiftKeyTimeout),this._shiftKeyTimeout=-1,r.shiftKey=!0):!t.shiftKey&&r.shiftKey&&this._shiftKeyTimeout===-1&&(this._shiftKeyTimeout=setTimeout(this._setShiftKeyTimeout,150)),t.altKey?(clearInterval(this._altKeyTimeout),this._altKeyTimeout=-1,r.altKey=!0):!t.altKey&&r.altKey&&this._altKeyTimeout===-1&&(this._altKeyTimeout=setTimeout(this._setAltKeyTimeout,150)),t.ctrlKey?(clearInterval(this._ctrlKeyTimeout),this._ctrlKeyTimeout=-1,r.ctrlKey=!0):!t.ctrlKey&&r.ctrlKey&&this._ctrlKeyTimeout===-1&&(this._ctrlKeyTimeout=setTimeout(this._setCtrlKeyTimeout,150));const{originPagePoint:s,originScreenPoint:i,currentPagePoint:a,currentScreenPoint:l}=r;switch(r.isPointing||(r.isDragging=!1),o){case"pinch":{if(!this.getInstanceState().canMoveCamera)return;switch(this._updateInputsFromEvent(t),t.name){case"pinch_start":{if(r.isPinching)return;r.isEditing||(this._pinchStart=this.getCamera().z,this._selectedShapeIdsAtPointerDown.length||(this._selectedShapeIdsAtPointerDown=this.getSelectedShapeIds()),this._didPinch=!0,r.isPinching=!0,this.interrupt());return}case"pinch":{if(!r.isPinching)return;const{point:{z:c=1},delta:{x:u,y:d}}=t,{screenBounds:h}=this.store.unsafeGetWithoutCapture(Lt),{x:f,y}=b.SubXY(t.point,h.x,h.y),{x:g,y:v,z:S}=this.getCamera(),w=Math.min(ds,Math.max(Tl,c));this.setCamera({x:g+u/S-f/S+f/w,y:v+d/S-y/S+y/w,z:w});return}case"pinch_end":{if(!r.isPinching)return this;r.isPinching=!1;const{_selectedShapeIdsAtPointerDown:c}=this;this.setSelectedShapes(this._selectedShapeIdsAtPointerDown,{squashing:!0}),this._selectedShapeIdsAtPointerDown=[],this._didPinch&&(this._didPinch=!1,requestAnimationFrame(()=>{this._didPinch||this.setSelectedShapes(c,{squashing:!0})}));return}}}case"wheel":{if(!this.getInstanceState().canMoveCamera)return;if(this._updateInputsFromEvent(t),!this.getIsMenuOpen()){if(r.ctrlKey){const{x:c,y:u}=this.inputs.currentScreenPoint,{x:d,y:h,z:f}=this.getCamera(),y=Math.min(ds,Math.max(Tl,f+(t.delta.z??0)*f));this.setCamera({x:d+(c/y-c)-(c/f-c),y:h+(u/y-u)-(u/f-u),z:y});return}this.pan(t.delta),!r.isDragging&&r.isPointing&&s.dist(a)>(this.getInstanceState().isCoarsePointer?Ny:$c)/this.getZoomLevel()&&(r.isDragging=!0)}break}case"pointer":{if(r.isPinching)return;this._updateInputsFromEvent(t);const{isPen:c}=t;switch(t.name){case"pointer_down":{if(this.clearOpenMenus(),this._selectedShapeIdsAtPointerDown=this.getSelectedShapeIds(),t.button===0&&(this.capturedPointerId=t.pointerId),r.buttons.add(t.button),r.isPointing=!0,r.isDragging=!1,this.getInstanceState().isPenMode){if(!c)return}else c&&this.updateInstanceState({isPenMode:!0});if(t.button===5?(this._restoreToolId=this.getCurrentToolId(),this.complete(),this.setCurrentTool("eraser")):t.button===1&&(this.inputs.isPanning||(this._prevCursor=this.getInstanceState().cursor.type),this.inputs.isPanning=!0),this.inputs.isPanning)return this.stopCameraAnimation(),this.updateInstanceState({cursor:{type:"grabbing",rotation:0}}),this;i.setTo(l),s.setTo(a);break}case"pointer_move":{if(!c&&this.getInstanceState().isPenMode)return;if(this.inputs.isPanning&&this.inputs.isPointing){const{currentScreenPoint:u,previousScreenPoint:d}=this.inputs;this.pan(b.Sub(u,d));return}!r.isDragging&&r.isPointing&&s.dist(a)>(this.getInstanceState().isCoarsePointer?Ny:$c)/this.getZoomLevel()&&(r.isDragging=!0);break}case"pointer_up":{if(r.buttons.delete(t.button),r.isPointing=!1,r.isDragging=!1,this.getIsMenuOpen()||!c&&this.getInstanceState().isPenMode)return;this.capturedPointerId===t.pointerId&&(this.capturedPointerId=null,t.button=0),r.isPanning?t.button===1?this.inputs.keys.has(" ")?(this.slideCamera({speed:Math.min(2,this.inputs.pointerVelocity.len()),direction:this.inputs.pointerVelocity,friction:rh}),this.updateInstanceState({cursor:{type:"grab",rotation:0}})):(r.isPanning=!1,this.slideCamera({speed:Math.min(2,this.inputs.pointerVelocity.len()),direction:this.inputs.pointerVelocity,friction:rh}),this.updateInstanceState({cursor:{type:this._prevCursor,rotation:0}})):t.button===0&&(this.slideCamera({speed:Math.min(2,this.inputs.pointerVelocity.len()),direction:this.inputs.pointerVelocity,friction:rh}),this.updateInstanceState({cursor:{type:"grab",rotation:0}})):t.button===5&&(this.complete(),this.setCurrentTool(this._restoreToolId));break}}break}case"keyboard":{switch(t.key==="ShiftRight"&&(t.key="ShiftLeft"),t.key==="AltRight"&&(t.key="AltLeft"),t.code==="ControlRight"&&(t.code="ControlLeft"),t.name){case"key_down":{r.keys.add(t.code),!t.ctrlKey&&t.code==="Space"&&(this.inputs.isPanning||(this._prevCursor=this.getInstanceState().cursor.type),this.inputs.isPanning=!0,this.updateInstanceState({cursor:{type:this.inputs.isPointing?"grabbing":"grab",rotation:0}}));break}case"key_up":{r.keys.delete(t.code),t.code==="Space"&&!this.inputs.buttons.has(1)&&(this.inputs.isPanning=!1,this.updateInstanceState({cursor:{type:this._prevCursor,rotation:0}}));break}}break}}if(t.type==="pointer"&&(t.button===1?t.name="middle_click":t.button===2&&(t.name="right_click"),t.isPen===this.getInstanceState().isPenMode))switch(t.name){case"pointer_down":{const c=this._clickManager.transformPointerDownEvent(t);if(t.name!==c.name){this.root.handleEvent(t),this.emit("event",t),this.root.handleEvent(c),this.emit("event",c);return}break}case"pointer_up":{const c=this._clickManager.transformPointerUpEvent(t);if(t.name!==c.name){this.root.handleEvent(t),this.emit("event",t),this.root.handleEvent(c),this.emit("event",c);return}break}case"pointer_move":{this._clickManager.handleMove();break}}this.root.handleEvent(t),this.emit("event",t)}),this});this.store=t,this.snaps=new yf(this),this.user=new Kr(r??o_(),l??!1),this.getContainer=i??(()=>document.body),this.textMeasure=new vN(this);class c extends ah{}m(c,"initial",a??""),this.root=new c(this),this.root.children={};const u=u_(o),d=new Set(Object.keys(t.schema.types.shape.migrations.subTypeMigrations));for(const I of u){if(!d.has(I.type))throw Error(`Editor and store have different shapes: "${I.type}" was passed into the editor but not the schema`);d.delete(I.type)}if(d.size>0)throw Error(`Editor and store have different shapes: "${[...d][0]}" is present in the store schema but not provided to the editor`);const h={},f={},y=new Map;for(const I of u){const P=new I(this);h[I.type]=P;const E=UI(I.props??{});f[I.type]=E;for(const _ of E.keys())if(!y.has(_.id))y.set(_.id,_);else if(y.get(_.id)!==_)throw Error(`Multiple style props with id "${_.id}" in use. Style prop IDs must be unique.`)}this.shapeUtils=h,this.styleProps=f;for(const I of[...s]){if(ro(this.root.children,I.id))throw Error(`Can't override tool with id "${I.id}"`);this.root.children[I.id]=new I(this,this.root)}this.environment=new tN(this),this.scribbles=new oN(this);const g=new Set,v=I=>{var H;const P=this.getShape(I);if(!P)return;const{start:E,end:_}=P.props,k=E.type==="binding"?this.getShape(E.boundShapeId):void 0,M=_.type==="binding"?this.getShape(_.boundShapeId):void 0,T=this.getAncestorPageId(P);if(!T)return;let R;if(k&&M)R=this.findCommonAncestor([k,M])??T;else if(k||M){const B=(H=k||M)==null?void 0:H.parentId;B&&B===P.parentId?R=P.parentId:R=T}else return;R&&R!==P.parentId&&this.reparentShapes([I],R);const O=this.getShape(I);if(!O)throw Error("no reparented arrow");const U=this.getShapeNearestSibling(O,k),N=this.getShapeNearestSibling(O,M);let L;if(U&&N)L=U.index>N.index?U:N;else if(U&&!N)L=U;else if(N&&!U)L=N;else return;let G;const X=this.getSortedChildIdsForParent(L.parentId).map(B=>this.getShape(B)).filter(B=>B.index>L.index);if(X.length){const B=X.find(W=>W.type!=="arrow");if(O.index>L.index&&(!B||O.index<B.index))return;G=oc(L.index,X[0].index)}else G=ko(L.index);G!==O.index&&this.updateShapes([{id:I,type:"arrow",index:G}])},S=(I,P)=>{const{x:E,y:_}=Ar(this,I)[P];this.store.put([{...I,props:{...I.props,[P]:{type:"point",x:E,y:_}}}])},w=I=>{for(const P of["start","end"]){const E=I.props[P];if(E.type!=="binding")continue;const _=this.getShape(E.boundShapeId),k=this.getAncestorPageId(I)===this.getAncestorPageId(_);(!_||!k)&&S(I,P)}v(I.id)},C=(I,P)=>{let E=null;const _=I.selectedShapeIds.filter(T=>!P.has(T));_.length!==I.selectedShapeIds.length&&(E||(E={...I}),E.selectedShapeIds=_);const k=I.erasingShapeIds.filter(T=>!P.has(T));k.length!==I.erasingShapeIds.length&&(E||(E={...I}),E.erasingShapeIds=k),I.hoveredShapeId&&P.has(I.hoveredShapeId)&&(E||(E={...I}),E.hoveredShapeId=null),I.editingShapeId&&P.has(I.editingShapeId)&&(E||(E={...I}),E.editingShapeId=null);const M=I.hintingShapeIds.filter(T=>!P.has(T));return M.length!==I.hintingShapeIds.length&&(E||(E={...I}),E.hintingShapeIds=M),I.focusedGroupId&&P.has(I.focusedGroupId)&&(E||(E={...I}),E.focusedGroupId=null),E};if(this.sideEffects=new sN(this),this.sideEffects.registerBatchCompleteHandler(()=>{var I;for(const P of g){g.delete(P);const E=this.getShape(P);if(!E)continue;const _=this.getShapeUtil(E),k=(I=_.onChildrenChange)==null?void 0:I.call(_,E);k!=null&&k.length&&this.updateShapes(k,{squashing:!0})}this.emit("update")}),this.sideEffects.registerBeforeDeleteHandler("shape",I=>{I.parentId&&Hn(I.parentId)&&g.add(I.parentId);const P=this._getArrowBindingsIndex().get()[I.id];if(P!=null&&P.length)for(const{arrowId:k,handleId:M}of P){const T=this.getShape(k);T&&S(T,M)}const E=new Set([I.id]),_=ge(this.getPageStates().map(k=>C(k,E)));_.length&&this.store.put(_)}),this.sideEffects.registerBeforeDeleteHandler("page",I=>{var k;if(this.getInstanceState().currentPageId!==I.id)return;const P=(k=this.getPages().find(M=>M.id!==I.id))==null?void 0:k.id;if(!P)return;this.store.put([{...this.getInstanceState(),currentPageId:P}]);const E=qt.createId(I.id),_=Zt.createId(I.id);this.store.remove([E,_])}),this.sideEffects.registerAfterChangeHandler("shape",(I,P)=>{if(this.isShapeOfType(P,"arrow")&&w(P),I.parentId!==P.parentId){const E=_=>{const k=this._getArrowBindingsIndex().get()[_];if(k!=null&&k.length)for(const M of k)v(M.arrowId)};E(P.id),this.visitDescendants(P.id,E)}if(I.parentId!==P.parentId&&wn(P.parentId)){const E=new Set([I.id]);this.visitDescendants(I.id,_=>{E.add(_)});for(const _ of this.getPageStates()){if(_.pageId===P.parentId)continue;const k=C(_,E);k&&this.store.put([k])}}I.parentId&&Hn(I.parentId)&&g.add(I.parentId),P.parentId!==I.parentId&&Hn(P.parentId)&&g.add(P.parentId)}),this.sideEffects.registerAfterChangeHandler("instance_page_state",(I,P)=>{if((I==null?void 0:I.selectedShapeIds)!==(P==null?void 0:P.selectedShapeIds)){const E=P.selectedShapeIds.filter(k=>{var T,R;let M=(T=this.getShape(k))==null?void 0:T.parentId;for(;Hn(M);){if(P.selectedShapeIds.includes(M))return!1;M=(R=this.getShape(M))==null?void 0:R.parentId}return!0});let _=null;if(E.length>0){const k=this.findCommonAncestor(ge(E.map(M=>this.getShape(M))),M=>this.isShapeOfType(M,"group"));k&&(_=k)}else P!=null&&P.focusedGroupId&&(_=P.focusedGroupId);(E.length!==P.selectedShapeIds.length||_!==P.focusedGroupId)&&this.store.put([{...P,selectedShapeIds:E,focusedGroupId:_??null}])}}),this.sideEffects.registerAfterCreateHandler("shape",I=>{this.isShapeOfType(I,"arrow")&&w(I)}),this.sideEffects.registerAfterCreateHandler("page",I=>{const P=qt.createId(I.id),E=Zt.createId(I.id);this.store.has(P)||this.store.put([qt.create({id:P})]),this.store.has(E)||this.store.put([Zt.create({id:E,pageId:I.id})])}),this._currentPageShapeIds=Q6(this.store,()=>this.getCurrentPageId()),this._parentIdsToChildIds=Z6(this.store),this.disposables.add(this.store.listen(I=>{this.emit("change",I)})),this.store.ensureStoreIsUsable(),this._setInstancePageState({editingShapeId:null,hoveredShapeId:null,erasingShapeIds:[]},{ephemeral:!0}),a&&this.root.children[a]===void 0)throw Error(`No state found for initialState "${a}".`);this.root.enter(void 0,"initial"),this.getInstanceState().followingUserId&&this.stopFollowingUser(),this.updateRenderingBounds(),requestAnimationFrame(()=>{this._tickManager.start()})}dispose(){this.disposables.forEach(t=>t()),this.disposables.clear()}getShapeUtil(t){const r=typeof t=="string"?t:t.type,o=hr(this.shapeUtils,r);return Do(o,`No shape util found for type "${r}"`),o}undo(){return this.history.undo(),this}getCanUndo(){return this.history.getNumUndos()>0}redo(){return this.history.redo(),this}getCanRedo(){return this.history.getNumRedos()>0}mark(t,r,o){return this.history.mark(t,r,o),this}bail(){return this.history.bail(),this}bailToMark(t){return this.history.bailToMark(t),this}batch(t){return this.history.batch(t),this}_getArrowBindingsIndex(){return q6(this)}getArrowsBoundTo(t){return this._getArrowBindingsIndex().get()[t]||$s}getArrowInfoCache(){return this.store.createComputedCache("arrow infoCache",t=>$l(t)?lc(this,t):Rg(this,t))}getArrowInfo(t){const r=typeof t=="string"?t:t.id;return this.getArrowInfoCache().get(r)}annotateError(t,{origin:r,willCrashApp:o,tags:s,extras:i}){const a=this.createErrorAnnotations(r,o);return Av(t,{tags:{...a.tags,...s},extras:{...a.extras,...i}}),o&&this.store.markAsPossiblyCorrupted(),this}createErrorAnnotations(t,r){try{const o=this.getEditingShapeId();return{tags:{origin:t,willCrashApp:r},extras:{activeStateNode:this.root.getPath(),selectedShapes:this.getSelectedShapes(),editingShape:o?this.getShape(o):void 0,inputs:this.inputs}}}catch{return{tags:{origin:t,willCrashApp:r},extras:{}}}}getCrashingError(){return this._crashingError}crash(t){return this._crashingError=t,this.store.markAsPossiblyCorrupted(),this.emit("crash",{error:t}),this}getPath(){return this.root.getPath().split("root.")[1]}isIn(t){const r=t.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(...t){return t.some(r=>this.isIn(r))}setCurrentTool(t,r={}){return this.root.transition(t,r),this}getCurrentTool(){return this.root.getCurrent()}getCurrentToolId(){const t=this.getCurrentTool();return t?t.getCurrentToolIdMask()??t.id:""}getStateDescendant(t){var s;const r=t.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(Dy)}updateDocumentSettings(t){return this.store.put([{...this.getDocumentSettings(),...t}]),this}getInstanceState(){return this.store.get(Lt)}updateInstanceState(t,r){return this._updateInstanceState(t,{ephemeral:!0,squashing:!0,...r}),t.isChangingStyle!==void 0&&(clearTimeout(this._isChangingStyleTimeout),t.isChangingStyle===!0&&(this._isChangingStyleTimeout=setTimeout(()=>{this.updateInstanceState({isChangingStyle:!1},{ephemeral:!0})},2e3))),this}getOpenMenus(){return this.getInstanceState().openMenus}addOpenMenu(t){const r=new Set(this.getOpenMenus());return r.has(t)||(r.add(t),this.updateInstanceState({openMenus:[...r]})),this}deleteOpenMenu(t){const r=new Set(this.getOpenMenus());return r.has(t)&&(r.delete(t),this.updateInstanceState({openMenus:[...r]})),this}clearOpenMenus(){return this.getOpenMenus().length&&this.updateInstanceState({openMenus:[]}),this}getIsMenuOpen(){return this.getOpenMenus().length>0}getPageStates(){return this._getPageStatesQuery().get()}_getPageStatesQuery(){return this.store.query.records("instance_page_state")}getCurrentPageState(){return this.store.get(this._getCurrentPageStateId())}_getCurrentPageStateId(){return Zt.createId(this.getCurrentPageId())}updateCurrentPageState(t,r){return this._setInstancePageState(t,r),this}getSelectedShapeIds(){return this.getCurrentPageState().selectedShapeIds}getSelectedShapes(){const{selectedShapeIds:t}=this.getCurrentPageState();return ge(t.map(r=>this.store.get(r)))}setSelectedShapes(t,r){const o=t.map(s=>typeof s=="string"?s:s.id);return this._setSelectedShapes(o,r),this}isAncestorSelected(t){const r=typeof t=="string"?t:(t==null?void 0:t.id)??null,o=this.getShape(r);if(!o)return!1;const s=this.getSelectedShapeIds();return!!this.findShapeAncestor(o,i=>s.includes(i.id))}select(...t){const r=typeof t[0]=="string"?t:t.map(o=>o.id);return this.setSelectedShapes(r),this}deselect(...t){const r=typeof t[0]=="string"?t:t.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 t=this.getSortedChildIdsForParent(this.getCurrentPageId());return t.length<=0?this:(this.setSelectedShapes(this._getUnlockedShapeIds(t)),this)}selectNone(){return this.getSelectedShapeIds().length>0&&this.setSelectedShapes([]),this}getOnlySelectedShape(){const t=this.getSelectedShapes();return t.length===1?t[0]:null}getSelectionPageBounds(){const t=this.getCurrentPageState().selectedShapeIds;return t.length===0?null:ne.Common(ge(t.map(r=>this.getShapePageBounds(r))))}getSelectionRotation(){const t=this.getSelectedShapeIds();if(t.length===0)return 0;if(t.length===1)return this.getShapePageTransform(this.getSelectedShapeIds()[0]).rotation();const r=t.map(o=>this.getShapePageTransform(o).rotation());return r.every(o=>Math.abs(o-r[0])<Math.PI/180)?this.getShapePageTransform(t[0]).rotation():0}getSelectionRotatedPageBounds(){const t=this.getSelectedShapeIds();if(t.length===0)return;const r=this.getSelectionRotation();if(r===0)return this.getSelectionPageBounds();if(t.length===1){const s=this.getShapeGeometry(t[0]).bounds.clone(),i=this.getShapePageTransform(t[0]);return s.point=i.applyToPoint(s.point),s}const o=ne.FromPoints(this.getSelectedShapeIds().flatMap(s=>{const i=this.getShapePageTransform(s);return i?i.applyToPoints(this.getShapeGeometry(s).vertices):[]}).map(s=>b.Rot(s,-r)));return o.point=o.point.rot(r),o}getFocusedGroupId(){return this.getCurrentPageState().focusedGroupId??this.getCurrentPageId()}getFocusedGroup(){const t=this.getFocusedGroupId();return t?this.getShape(t):void 0}setFocusedGroup(t){const r=typeof t=="string"?t:(t==null?void 0:t.id)??null;if(r!==null){const o=this.getShape(r);if(!o)throw Error(`Editor.setFocusedGroup: Shape with id ${r} does not exist`);if(!this.isShapeOfType(o,"group"))throw Error(`Editor.setFocusedGroup: Cannot set focused group to shape of type ${o.type}`)}return r===this.getFocusedGroupId()?this:(this._setFocusedGroupId(r),this)}popFocusedGroupId(){const t=this.getFocusedGroup();if(t){const r=this.findShapeAncestor(t,o=>this.isShapeOfType(o,"group"));this.setFocusedGroup((r==null?void 0:r.id)??null),this.select(t.id)}else this.setFocusedGroup(null),this.selectNone();return this}getEditingShapeId(){return this.getCurrentPageState().editingShapeId}getEditingShape(){const t=this.getEditingShapeId();return t?this.getShape(t):void 0}setEditingShape(t){const r=typeof t=="string"?t:(t==null?void 0:t.id)??null;if(r!==this.getEditingShapeId()){if(r){const o=this.getShape(r);if(o&&this.getShapeUtil(o).canEdit(o))return this._setInstancePageState({editingShapeId:r}),this}this._setInstancePageState({editingShapeId:null})}return this}getHoveredShapeId(){return this.getCurrentPageState().hoveredShapeId}getHoveredShape(){const t=this.getHoveredShapeId();return t?this.getShape(t):void 0}setHoveredShape(t){const r=typeof t=="string"?t:(t==null?void 0:t.id)??null;return r===this.getHoveredShapeId()?this:(this.updateCurrentPageState({hoveredShapeId:r},{ephemeral:!0}),this)}getHintingShapeIds(){return this.getCurrentPageState().hintingShapeIds}getHintingShape(){const t=this.getHintingShapeIds();return ge(t.map(r=>this.getShape(r)))}setHintingShapes(t){const r=typeof t[0]=="string"?t:t.map(o=>o.id);return this.updateCurrentPageState({hintingShapeIds:ep(r)},{ephemeral:!0}),this}getErasingShapeIds(){return this.getCurrentPageState().erasingShapeIds}getErasingShapes(){const t=this.getErasingShapeIds();return ge(t.map(r=>this.getShape(r)))}setErasingShapes(t){const r=typeof t[0]=="string"?t:t.map(s=>s.id);r.sort();const o=this.getErasingShapeIds();if(r.length===o.length){for(let s=0;s<r.length;s++)if(r[s]!==o[s]){this._setInstancePageState({erasingShapeIds:r},{ephemeral:!0});break}}else this._setInstancePageState({erasingShapeIds:r},{ephemeral:!0});return this}getCroppingShapeId(){return this.getCurrentPageState().croppingShapeId}setCroppingShape(t){const r=typeof t=="string"?t:(t==null?void 0:t.id)??null;if(r!==this.getCroppingShapeId())if(!r)this.updateCurrentPageState({croppingShapeId:null});else{const o=this.getShape(r),s=this.getShapeUtil(o);o&&s.canCrop(o)&&this.updateCurrentPageState({croppingShapeId:r})}return this}getCameraId(){return qt.createId(this.getCurrentPageId())}getCamera(){return this.store.get(this.getCameraId())}getZoomLevel(){return this.getCamera().z}_setCamera(t){const r=this.getCamera();return r.x===t.x&&r.y===t.y&&r.z===t.z?this:(this.batch(()=>{this.store.put([{...r,...t}]);const{currentScreenPoint:o}=this.inputs,{screenBounds:s}=this.store.unsafeGetWithoutCapture(Lt);this.dispatch({type:"pointer",target:"canvas",name:"pointer_move",point:b.AddXY(o,s.x,s.y),pointerId:nb.CAMERA_MOVE,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,shiftKey:this.inputs.shiftKey,button:0,isPen:this.getInstanceState().isPenMode??!1}),this._tickCameraState()}),this)}setCamera(t,r){const o=Number.isFinite(t.x)?t.x:0,s=Number.isFinite(t.y)?t.y:0,i=Number.isFinite(t.z)?t.z:this.getZoomLevel();if(this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),r){const{width:a,height:l}=this.getViewportScreenBounds();return this._animateToViewport(new ne(-o,-s,a/i,l/i),r)}else this._setCamera({x:o,y:s,z:i});return this}centerOnPoint(t,r){if(!this.getInstanceState().canMoveCamera)return this;const{width:o,height:s}=this.getViewportPageBounds();return this.setCamera({x:-(t.x-o/2),y:-(t.y-s/2),z:this.getCamera().z},r),this}zoomToContent(){const t=this.getSelectionPageBounds()??this.getCurrentPageBounds();return t&&this.zoomToBounds(t,{targetZoom:Math.min(1,this.getZoomLevel()),duration:220}),this}zoomToFit(t){if(!this.getInstanceState().canMoveCamera)return this;const r=[...this.getCurrentPageShapeIds()];if(r.length<=0)return this;const o=ne.Common(ge(r.map(s=>this.getShapePageBounds(s))));return this.zoomToBounds(o,t),this}resetZoom(t=this.getViewportScreenCenter(),r){if(!this.getInstanceState().canMoveCamera)return this;const{x:o,y:s,z:i}=this.getCamera(),{x:a,y:l}=t;return this.setCamera({x:o+(a/1-a)-(a/i-a),y:s+(l/1-l)-(l/i-l),z:1},r),this}zoomIn(t=this.getViewportScreenCenter(),r){if(!this.getInstanceState().canMoveCamera)return this;const{x:o,y:s,z:i}=this.getCamera();let a=ds;for(let u=1;u<Yi.length;u++){const d=Yi[u-1],h=Yi[u];if(!(h-i<=(h-d)/2)){a=h;break}}const{x:l,y:c}=t;return this.setCamera({x:o+(l/a-l)-(l/i-l),y:s+(c/a-c)-(c/i-c),z:a},r),this}zoomOut(t=this.getViewportScreenCenter(),r){if(!this.getInstanceState().canMoveCamera)return this;const{x:o,y:s,z:i}=this.getCamera();let a=Tl;for(let u=Yi.length-1;u>0;u--){const d=Yi[u-1],h=Yi[u];if(!(h-i>=(h-d)/2)){a=d;break}}const{x:l,y:c}=t;return this.setCamera({x:o+(l/a-l)-(l/i-l),y:s+(c/a-c)-(c/i-c),z:a},r),this}zoomToSelection(t){if(!this.getInstanceState().canMoveCamera)return this;const r=this.getSelectionPageBounds();return r?(this.zoomToBounds(r,{targetZoom:Math.max(1,this.getZoomLevel()),...t}),this):this}panZoomIntoView(t,r){if(!this.getInstanceState().canMoveCamera)return this;if(t.length<=0)return this;const o=ne.Common(ge(t.map(i=>this.getShapePageBounds(i)))),s=this.getViewportPageBounds();if(s.h<o.h||s.w<o.w)return this.zoomToBounds(o,{targetZoom:this.getCamera().z,...r}),this;{const i=this.getViewportPageBounds().clone().expandBy(-32/this.getZoomLevel());let a=0,l=0;i.maxY<o.maxY?l=i.maxY-o.maxY:i.minY>o.minY&&(l=i.minY-o.minY),i.maxX<o.maxX?a=i.maxX-o.maxX:i.minX>o.minX&&(a=i.minX-o.minX);const c=this.getCamera();this.setCamera({x:c.x+a,y:c.y+l,z:c.z},r)}return this}zoomToBounds(t,r){if(!this.getInstanceState().canMoveCamera)return this;const o=this.getViewportScreenBounds(),s=(r==null?void 0:r.inset)??Math.min(256,o.width*.28);let i=ar(Math.min((o.width-s)/t.width,(o.height-s)/t.height),Tl,ds);return(r==null?void 0:r.targetZoom)!==void 0&&(i=Math.min(r.targetZoom,i)),this.setCamera({x:-t.minX+(o.width-t.width*i)/2/i,y:-t.minY+(o.height-t.height*i)/2/i,z:i},r),this}pan(t,r){if(!this.getInstanceState().canMoveCamera)return this;const{x:o,y:s,z:i}=this.getCamera();return this.setCamera({x:o+t.x/i,y:s+t.y/i,z:i},r),this}stopCameraAnimation(){return this.emit("stop-camera-animation"),this}_animateViewport(t){if(!this._viewportAnimation)return;const r=()=>{this.removeListener("tick",this._animateViewport),this.removeListener("stop-camera-animation",r),this._viewportAnimation=null};this.once("stop-camera-animation",r),this._viewportAnimation.elapsed+=t;const{elapsed:o,easing:s,duration:i,start:a,end:l}=this._viewportAnimation;if(o>i){this._setCamera({x:-l.x,y:-l.y,z:this.getViewportScreenBounds().width/l.width}),r();return}const c=i-o,u=s(1-c/i),d=a.minX+(l.minX-a.minX)*u,h=a.minY+(l.minY-a.minY)*u,f=a.maxX+(l.maxX-a.maxX)*u;this._setCamera({x:-d,y:-h,z:this.getViewportScreenBounds().width/(f-d)})}_animateToViewport(t,r={}){const{duration:o=0,easing:s=tn.easeInOutCubic}=r,i=this.user.getAnimationSpeed(),a=this.getViewportPageBounds();return this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),o===0||i===0?this._setCamera({x:-t.x,y:-t.y,z:this.getViewportScreenBounds().width/t.width}):(this._viewportAnimation={elapsed:0,duration:o/i,easing:s,start:a.clone(),end:t.clone()},this.addListener("tick",this._animateViewport),this)}slideCamera(t={}){if(!this.getInstanceState().canMoveCamera)return this;if(this.stopCameraAnimation(),this.user.getAnimationSpeed()===0)return this;const{speed:o,friction:s,direction:i,speedThreshold:a=.01}=t;let l=Math.min(o,1);const c=()=>{this.removeListener("tick",u),this.removeListener("stop-camera-animation",c)};this.once("stop-camera-animation",c);const u=d=>{const{x:h,y:f,z:y}=this.getCamera(),g=b.Mul(i,l*d/y);l*=1-s,l<a?c():this._setCamera({x:h+g.x,y:f+g.y,z:y})};return this.addListener("tick",u),this}animateToUser(t){const o=[...this.store.query.records("instance_presence",()=>({userId:{eq:t}})).get()].sort((s,i)=>s.lastActivityTimestamp-i.lastActivityTimestamp).pop();return o?(this.batch(()=>{this.getInstanceState().followingUserId!==null&&this.stopFollowingUser();const s=o.currentPageId===this.getCurrentPageId();s||this.setCurrentPage(o.currentPageId);const i=s?{duration:500}:void 0;this.centerOnPoint(o.cursor,i);const{highlightedUserIds:a}=this.getInstanceState();this.updateInstanceState({highlightedUserIds:[...a,t]}),setTimeout(()=>{const l=[...this.getInstanceState().highlightedUserIds],c=l.indexOf(t);c<0||(l.splice(c,1),this.updateInstanceState({highlightedUserIds:l}))},PE)}),this):this}animateToShape(t,r=BR){if(!this.getInstanceState().canMoveCamera)return this;const o=this.getViewportScreenBounds().clone().expandBy(-32),s=o.width/o.height,i=this.getShapePageBounds(t);if(!i)return this;const a=i.width/i.height,l=i.clone(),c=i.width/o.width;return l.width+=(o.minX+o.maxX)*c,l.height+=(o.minY+o.maxY)*c,l.x-=o.minX*c,l.y-=o.minY*c,a>s?(l.height=i.width/s,l.y-=(l.height-i.height)/2):(l.width=i.height*s,l.x-=(l.width-i.width)/2),this._animateToViewport(l,r)}updateViewportScreenBounds(t,r=!1){t.width=Math.max(t.width,1),t.height=Math.max(t.height,1);const o=[t.minY!==0,document.body.scrollWidth!==t.maxX,document.body.scrollHeight!==t.maxY,t.minX!==0],s=t.equals(this.getViewportScreenBounds()),{_willSetInitialBounds:i}=this;if(s)this._willSetInitialBounds=!1;else if(i)this._willSetInitialBounds=!1,this.updateInstanceState({screenBounds:t.toJson(),insets:o},{squashing:!0,ephemeral:!0});else if(r&&!this.getInstanceState().followingUserId){const a=this.getViewportPageCenter();this.updateInstanceState({screenBounds:t.toJson(),insets:o},{squashing:!0,ephemeral:!0}),this.centerOnPoint(a)}else this.updateInstanceState({screenBounds:t.toJson(),insets:o},{squashing:!0,ephemeral:!0});return this._tickCameraState(),this.updateRenderingBounds(),this}getViewportScreenBounds(){const{x:t,y:r,w:o,h:s}=this.getInstanceState().screenBounds;return new ne(t,r,o,s)}getViewportScreenCenter(){const t=this.getViewportScreenBounds();return new b(t.midX-t.minX,t.midY-t.minY)}getViewportPageBounds(){const{w:t,h:r}=this.getViewportScreenBounds(),{x:o,y:s,z:i}=this.getCamera();return new ne(-o,-s,t/i,r/i)}getViewportPageCenter(){return this.getViewportPageBounds().center}screenToPage(t){const{screenBounds:r}=this.store.unsafeGetWithoutCapture(Lt),{x:o,y:s,z:i=1}=this.getCamera();return{x:(t.x-r.x)/i-o,y:(t.y-r.y)/i-s,z:t.z??.5}}pageToScreen(t){const{screenBounds:r}=this.store.unsafeGetWithoutCapture(Lt),{x:o,y:s,z:i=1}=this.getCamera();return{x:(t.x+o)*i+r.x,y:(t.y+s)*i+r.y,z:t.z??.5}}startFollowingUser(t){const r=this.store.query.records("instance_presence",()=>({userId:{eq:t}})),o=this.user.getId();if(o||console.warn("You should set the userId for the current instance before following a user"),r.get().some(l=>l.followingUserId===o))return this;Tr(()=>{this.stopFollowingUser(),this.updateInstanceState({followingUserId:t},{ephemeral:!0})});const s=()=>{this.removeListener("frame",a),this.removeListener("stop-following",s)};let i=!1;const a=()=>{const l=[...r.get()].sort((U,N)=>U.lastActivityTimestamp-N.lastActivityTimestamp).pop();if(!l){this.stopFollowingUser();return}const c=l.currentPageId===this.getCurrentPageId(),u=c?jR:1;if(!c){this.stopFollowingUser(),this.setCurrentPage(l.currentPageId),this.startFollowingUser(t);return}const{center:d,width:h,height:f}=this.getViewportPageBounds(),y=ne.From(l.screenBounds),g=y.width/l.camera.z,v=y.height/l.camera.z,S=new b(g/2-l.camera.x,v/2-l.camera.y),w=l.followingUserId===o,C=h+(g-h)*u,I=f+(v-f)*u,P=w?f/I:Math.min(h/C,f/I),E=ar(this.getCamera().z*P,Tl,ds),_=this.getViewportScreenBounds().w/E,k=this.getViewportScreenBounds().h/E,M=S.sub(d),T=b.Add(d,b.Mul(M,u)),R=b.Sub(T,d).len(),O=Math.abs(E-this.getCamera().z);if(R<OR&&O<RR){i=!0;return}i&&R<DR&&O<LR||(i=!1,this.stopCameraAnimation(),this._setCamera({x:-(T.x-_/2),y:-(T.y-k/2),z:E}))};return this.once("stop-following",s),this.addListener("frame",a),this}stopFollowingUser(){return this.updateInstanceState({followingUserId:null},{ephemeral:!0}),this.emit("stop-following"),this}getCameraState(){return this._cameraState.get()}getUnorderedRenderingShapes(t){const r=[];let o=Co*2,s=Co;const i=this.getEditingShapeId(),a=this.getSelectedShapeIds(),l=this.getErasingShapeIds(),c=this.getRenderingBoundsExpanded(),u=Number.isFinite(this.renderingBoundsMargin),d=(f,y,g)=>{const v=this.getShape(f);if(!v)return;y*=v.opacity;let S=!1,w=!1;const C=this.getShapeUtil(v),I=this.getShapeMaskedPageBounds(f);t&&(w=!g&&l.includes(f),w&&(y*=.32),S=u&&C.canUnmount(v)&&i!==f&&(I===void 0||!c.includes(I)&&!a.includes(f))),r.push({id:f,shape:v,util:C,index:o,backgroundIndex:s,opacity:y,isCulled:S,maskedPageBounds:I}),o+=1,s+=1;const P=this.getSortedChildIdsForParent(f);if(!P.length)return;let E=null;C.providesBackgroundForChildren(v)&&(E=s,s=o,o+=Co);for(const _ of P)d(_,y,g||w);E!==null&&(s=E)},h=t?[this.getCurrentPage()]:this.getPages();for(const f of h)for(const y of this.getSortedChildIdsForParent(f.id))d(y,1,!1);return r}getRenderingShapes(){return this.getUnorderedRenderingShapes(!0).sort(fD)}getRenderingBounds(){return this._renderingBounds.get()}getRenderingBoundsExpanded(){return this._renderingBoundsExpanded.get()}updateRenderingBounds(){const t=this.getViewportPageBounds();return t.equals(this._renderingBounds.__unsafe__getWithoutCapture())?this:(this._renderingBounds.set(t.clone()),Number.isFinite(this.renderingBoundsMargin)?this._renderingBoundsExpanded.set(t.clone().expandBy(this.renderingBoundsMargin/this.getZoomLevel())):this._renderingBoundsExpanded.set(t),this)}_getAllPagesQuery(){return this.store.query.records("page")}getPages(){return this._getAllPagesQuery().get().sort(Rt)}getCurrentPage(){return this.getPage(this.getCurrentPageId())}getCurrentPageId(){return this.getInstanceState().currentPageId}getPage(t){return this.store.get(typeof t=="string"?t:t.id)}getCurrentPageShapeIds(){return this._currentPageShapeIds.get()}getPageShapeIds(t){const r=typeof t=="string"?t:t.id,o=this.store.query.exec("shape",{parentId:{eq:r}});return this.getShapeAndDescendantIds(o.map(s=>s.id))}setCurrentPage(t,r){const o=typeof t=="string"?t:t.id;return this._setCurrentPageId(o,r),this}updatePage(t,r){return this._updatePage(t,r),this}createPage(t){return this._createPage(t),this}deletePage(t){const r=typeof t=="string"?t:t.id;return this._deletePage(r),this}duplicatePage(t,r=zo.createId()){if(this.getPages().length>=fp)return this;const o=typeof t=="string"?t:t.id,s=this.getPage(o);if(!s)return this;const i={...this.getCamera()},a=this.getContentFromCurrentPage(this.getSortedChildIdsForParent(s.id));return this.batch(()=>{var u;const l=this.getPages(),c=oc(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(t,r,o){const s=typeof t=="string"?t:t.id;return this.getInstanceState().isReadonly?this:(this.updatePage({id:s,name:r},o),this)}_getAllAssetsQuery(){return this.store.query.records("asset")}getAssets(){return this._getAllAssetsQuery().get()}createAssets(t){return this._createAssets(t),this}updateAssets(t){return this._updateAssets(t),this}deleteAssets(t){const r=typeof t[0]=="string"?t:t.map(o=>o.id);return this._deleteAssets(r),this}getAsset(t){return this.store.get(typeof t=="string"?t:t.id)}_getShapeGeometryCache(){return this.store.createComputedCache("bounds",t=>this.getShapeUtil(t).getGeometry(t),(t,r)=>t.props===r.props)}getShapeGeometry(t){return this._getShapeGeometryCache().get(typeof t=="string"?t:t.id)}_getShapeHandlesCache(){return this.store.createComputedCache("handles",t=>{var r,o;return(o=(r=this.getShapeUtil(t)).getHandles)==null?void 0:o.call(r,t)})}getShapeHandles(t){return this._getShapeHandlesCache().get(typeof t=="string"?t:t.id)}getShapeLocalTransform(t){const r=typeof t=="string"?t:t.id,o=this.getShape(r);if(!o)throw Error("Editor.getTransform: shape not found");return re.Identity().translate(o.x,o.y).rotate(o.rotation)}_getShapePageTransformCache(){return this.store.createComputedCache("pageTransformCache",t=>{if(wn(t.parentId))return this.getShapeLocalTransform(t);const r=this._getShapePageTransformCache().get(t.parentId)??re.Identity();return re.Compose(r,this.getShapeLocalTransform(t))})}getShapeParentTransform(t){const r=typeof t=="string"?t:t.id,o=this.getShape(r);return!o||wn(o.parentId)?re.Identity():this._getShapePageTransformCache().get(o.parentId)??re.Identity()}getShapePageTransform(t){const r=typeof t=="string"?t:this.getShape(t).id;return this._getShapePageTransformCache().get(r)??re.Identity()}_getShapePageBoundsCache(){return this.store.createComputedCache("pageBoundsCache",t=>{const r=this._getShapePageTransformCache().get(t.id);return r?ne.FromPoints(re.applyToPoints(r,this.getShapeGeometry(t).vertices)):new ne})}getShapePageBounds(t){return this._getShapePageBoundsCache().get(typeof t=="string"?t:t.id)}_getShapeClipPathCache(){return this.store.createComputedCache("clipPathCache",t=>{const r=this._getShapeMaskCache().get(t.id);if(!r)return;if(r.length===0)return"polygon(0px 0px, 0px 0px, 0px 0px)";const o=this._getShapePageTransformCache().get(t.id);return o?`polygon(${re.applyToPoints(re.Inverse(o),r).map(i=>`${i.x}px ${i.y}px`).join(",")})`:void 0})}getShapeClipPath(t){return this._getShapeClipPathCache().get(typeof t=="string"?t:t.id)}_getShapeMaskCache(){return this.store.createComputedCache("pageMaskCache",t=>{if(wn(t.parentId))return;const r=this.getShapeAncestors(t.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=Hy(s,i);return a?a.map(b.Cast):[]})})}getShapeMask(t){return this._getShapeMaskCache().get(typeof t=="string"?t:t.id)}getShapeMaskedPageBounds(t){typeof t!="string"&&(t=t.id);const r=this._getShapePageBoundsCache().get(t);if(!r)return;const o=this._getShapeMaskCache().get(t);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=Hy(o,s);return i?ne.FromPoints(i):void 0}return r}getShapeAncestors(t,r=[]){const o=typeof t=="string"?t:t.id,s=this.getShape(o);if(!s)return r;const i=s.parentId;if(wn(i))return r.reverse(),r;const a=this.store.get(i);return a?(r.push(a),this.getShapeAncestors(a,r)):r}findShapeAncestor(t,r){const o=typeof t=="string"?t:t.id,s=this.getShape(o);if(!s)return;const i=s.parentId;if(wn(i))return;const a=this.getShape(i);if(a)return r(a)?a:this.findShapeAncestor(a,r)}hasAncestor(t,r){const o=typeof t=="string"?t:t==null?void 0:t.id,s=o&&this.getShape(o);return s?s.parentId===r?!0:this.hasAncestor(this.getShapeParent(s),r):!1}findCommonAncestor(t,r){var c;if(t.length===0)return;const o=typeof t[0]=="string"?t:t.map(u=>u.id),s=ge(o.map(u=>this.getShape(u)));if(s.length===1){const u=s[0].parentId;return wn(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(t){const r=typeof t=="string"?this.getShape(t):t;return r===void 0?!1:r.isLocked?!0:this.isShapeOrAncestorLocked(this.getShapeParent(r))}getCurrentPageBounds(){let t;return this.getCurrentPageShapeIds().forEach(r=>{const o=this.getShapeMaskedPageBounds(r);o&&(t?t=t.expand(o):t=o.clone())}),t}getSelectedShapeAtPoint(t){const r=this.getSelectedShapeIds();return this.getCurrentPageShapesSorted().filter(o=>o.type!=="group"&&r.includes(o.id)).reverse().find(o=>this.isPointInShape(o,t,{hitInside:!0,margin:0}))}getShapeAtPoint(t,r={}){const o=this.getZoomLevel(),s=this.getViewportPageBounds(),{filter:i,margin:a=0,hitLabels:l=!1,hitInside:c=!1,hitFrameInside:u=!1}=r;let d=1/0,h=null,f=1/0,y=null;const g=(r.renderingOnly?this.getCurrentPageRenderingShapesSorted():this.getCurrentPageShapesSorted()).filter(v=>{if(this.isShapeOfType(v,"group"))return!1;const S=this.getShapeMask(v);return S&&!Br(t,S)?!1:i?i(v):!0});for(let v=g.length-1;v>=0;v--){const S=g[v],w=this.getShapeGeometry(S),C=w instanceof no,I=this.getPointInShapeSpace(S,t);if((this.isShapeOfType(S,"arrow")||this.isShapeOfType(S,"geo")&&S.props.fill==="none")&&S.props.text.trim()){for(const E of w.children)if(E.isLabel&&E.isPointInBounds(I))return S}if(this.isShapeOfType(S,"frame")){const E=w.distanceToPoint(I,c);if(Math.abs(E)<=a)return y||S;if(w.hitTestPoint(I,0,!0))return y||h||(u?S:void 0);continue}let P;if(C){let E=1/0;for(const _ of w.children){if(_.isLabel&&!l)continue;const k=_.distanceToPoint(I,c);k<E&&(E=k)}P=E}else a===0&&(w.bounds.w<1||w.bounds.h<1)||w.bounds.containsPoint(I,a)?P=w.distanceToPoint(I,c):P=1/0;if(w.isClosed){if(P<=a){if(w.isFilled||C&&w.children[0].isFilled)return y||S;if(this.getShapePageBounds(S).contains(s))continue;if(Math.abs(P)<a)Math.abs(P)<f&&(f=Math.abs(P),y=S);else if(!y){const{area:E}=w;E<d&&(d=E,h=S)}}}else if(P<Ur/o)return S}return y||h||void 0}getShapesAtPoint(t,r={}){return this.getCurrentPageShapes().filter(o=>this.isPointInShape(o,t,r))}isPointInShape(t,r,o={}){const{hitInside:s=!1,margin:i=0}=o,a=typeof t=="string"?t:t.id,l=this.getShapeMask(a);return l&&!Br(r,l)?!1:this.getShapeGeometry(a).hitTestPoint(this.getPointInShapeSpace(t,r),i,s)}getPointInShapeSpace(t,r){const o=typeof t=="string"?t:t.id;return this._getShapePageTransformCache().get(o).clone().invert().applyToPoint(r)}getPointInParentSpace(t,r){const o=typeof t=="string"?t:t.id,s=this.getShape(o);if(!s)return new b(0,0);if(wn(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(),t=>this.store.get(t))}getCurrentPageShapesSorted(){const t=new Set(this.getCurrentPageShapes().sort(Rt)),r=[];function o(s){r.push(s),t.delete(s),t.forEach(i=>{i.parentId===s.id&&o(i)})}return t.forEach(s=>{const i=this.getShape(s.parentId);ci(i)||o(s)}),r}getCurrentPageRenderingShapesSorted(){return this.getRenderingShapes().filter(({isCulled:t})=>!t).sort((t,r)=>t.index-r.index).map(({shape:t})=>t)}isShapeOfType(t,r){return(typeof t=="string"?this.getShape(t):t).type===r}getShape(t){const r=typeof t=="string"?t:t.id;if(Hn(r))return this.store.get(r)}getShapeParent(t){const r=typeof t=="string"?t:t==null?void 0:t.id;if(!r)return;const o=this.getShape(r);if(!(o===void 0||!Hn(o.parentId)))return this.store.get(o.parentId)}getShapeNearestSibling(t,r){return r?r.parentId===t.parentId?r:this.findShapeAncestor(r,s=>s.parentId===t.parentId):void 0}isShapeInPage(t,r=this.getCurrentPageId()){const o=typeof t=="string"?t:t.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(t){const r=typeof t=="string"?t:t==null?void 0:t.id,o=r&&this.getShape(r);if(o)return wn(o.parentId)?o.parentId:this.getAncestorPageId(this.getShape(o.parentId))}reparentShapes(t,r,o){const s=typeof t[0]=="string"?t:t.map(y=>y.id);if(s.length===0)return this;const i=[],a=wn(r)?re.Identity():this.getShapePageTransform(r),l=a.rotation();let c=[];const u=ge(this.getSortedChildIdsForParent(r).map(y=>this.getShape(y)));if(o){const y=u.find(g=>g.index===o);if(y){const g=u[u.indexOf(y)+1];g?c=Ba(o,g.index,s.length):c=xg(o,s.length)}else{const g=u.sort(Rt).find(v=>v.index>o);g?c=Ba(o,g.index,s.length):c=xg(o,s.length)}}else{const y=u.length&&u[u.length-1];c=y?xg(y.index,s.length):Pc(s.length)}const d=a.clone().invert(),h=ge(s.map(y=>this.getShape(y))),f=h.filter(y=>y.isLocked);f.length&&this.updateShapes(f.map(({id:y,type:g})=>({id:y,type:g,isLocked:!1})));for(let y=0;y<h.length;y++){const g=h[y],v=this.getShapePageTransform(g);if(!v)continue;const S=v.point();if(!S)continue;const w=d.applyToPoint(S),C=v.rotation()-l;i.push({id:g.id,type:g.type,parentId:r,x:w.x,y:w.y,rotation:C,index:c[y],isLocked:g.isLocked})}return this.updateShapes(i),this}getHighestIndexForParent(t){const r=typeof t=="string"?t:t.id,o=this._parentIdsToChildIds.get()[r];if(!o||o.length===0)return"a1";const s=this.getShape(o[o.length-1]);return ko(s.index)}getSortedChildIdsForParent(t){const r=typeof t=="string"?t:t.id,o=this._parentIdsToChildIds.get()[r];return o?this._childIdsCache.get(o,()=>o):$s}visitDescendants(t,r){const o=typeof t=="string"?t:t.id,s=this.getSortedChildIdsForParent(o);for(const i of s)r(i)!==!1&&this.visitDescendants(i,r);return this}getShapeAndDescendantIds(t){const r=new Set,o=[...t];for(;o.length>0;){const s=o.pop();if(!s)break;if(!r.has(s)){r.add(s);for(const i of this.getSortedChildIdsForParent(s))o.push(i)}}return r}getDroppingOverShape(t,r=[]){const o=this.getCurrentPageShapesSorted();for(let s=o.length-1;s>=0;s--){const i=o[s];if(!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(t)&&this.getShapeGeometry(i).hitTestPoint(this.getPointInShapeSpace(i,t),0,!0))return i}}getOutermostSelectableShape(t,r){const o=typeof t=="string"?t:t.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}rotateShapesBy(t,r){if((typeof t[0]=="string"?t:t.map(i=>i.id)).length<=0)return this;const s=d_({editor:this});return s?(ih({delta:r,snapshot:s,editor:this,stage:"one-off"}),this):this}getChangesToTranslateShape(t,r){var i,a,l;let o=t;const s=this.getShapeUtil(t);return o=Ml(o,((i=s.onTranslateStart)==null?void 0:i.call(s,o))??void 0),o=Ml(o,{id:t.id,type:t.type,x:r.x,y:r.y}),o=Ml(o,((a=s.onTranslate)==null?void 0:a.call(s,t,o))??void 0),o=Ml(o,((l=s.onTranslateEnd)==null?void 0:l.call(s,t,o))??void 0),o}nudgeShapes(t,r,o){const s=typeof t[0]=="string"?t:t.map(a=>a.id);if(s.length<=0)return this;const i=[];for(const a of s){const l=this.getShape(a),c=b.From(r),u=this.getShapeParentTransform(l);u&&c.rot(-u.rotation()),i.push(this.getChangesToTranslateShape(l,c.add(l)))}return this.updateShapes(i,{squashing:!0,...o}),this}duplicateShapes(t,r){const o=typeof t[0]=="string"?t:t.map(u=>u.id);if(o.length<=0)return this;const s=new Set(o),i=[],a=[...o];for(;a.length>0;){const u=a.pop();if(!u)break;i.push(u),this.getSortedChildIdsForParent(u).forEach(d=>a.push(d))}i.reverse();const l=new Map(i.map(u=>[u,We()])),c=ge(i.map(u=>{const d=this.getShape(u);if(!d)return null;const h=l.get(u);let f=0,y=0;if(r&&s.has(u)){const E=this.getShapeParentTransform(d),_=new b(r.x,r.y).rot(-E.rotation());f=_.x,y=_.y}const g=d.parentId??this.getCurrentPageId(),v=this.getSortedChildIdsForParent(g),S=v.indexOf(d.id),w=v[S+1],C=w?this.getShape(w):null,I=C?oc(d.index,C.index):ko(d.index);let P=pr(d);if(this.isShapeOfType(d,"arrow")&&this.isShapeOfType(P,"arrow")){const E=this.getArrowInfo(d);let _,k;if(d.props.start.type==="binding"&&(_=l.get(d.props.start.boundShapeId),!_))if(E!=null&&E.isValid){const{x:T,y:R}=E.start.point;P.props.start={type:"point",x:T,y:R}}else{const{start:T}=Ar(this,d);P.props.start={type:"point",x:T.x,y:T.y}}if(d.props.end.type==="binding"&&(k=l.get(d.props.end.boundShapeId),!k))if(E!=null&&E.isValid){const{x:T,y:R}=E.end.point;P.props.end={type:"point",x:T,y:R}}else{const{end:T}=Ar(this,d);P.props.start={type:"point",x:T.x,y:T.y}}const M=$l(P)?lc(this,P):Rg(this,P);if(E!=null&&E.isValid&&(M!=null&&M.isValid)&&!$l(d)){const T=b.Med(E.start.handle,E.end.handle),R=b.Dist(E.middle,T),O=b.Dist(M.middle,T);P.props.bend<0?P.props.bend+=O-R:P.props.bend-=O-R}P.props.start.type==="binding"&&_&&(P.props.start.boundShapeId=_),P.props.end.type==="binding"&&k&&(P.props.end.boundShapeId=k)}return P={...P,id:h,x:d.x+f,y:d.y+y,index:I},P}));return c.forEach(u=>{Hn(u.parentId)&&l.has(u.parentId)&&(u.parentId=l.get(u.parentId))}),this.history.batch(()=>{const u=c.length+this.getCurrentPageShapeIds().size>Co;u&&ud(this);const d=u?c.slice(0,Co-this.getCurrentPageShapeIds().size):c,h=d.map(f=>f.id);if(this.createShapes(d),this.setSelectedShapes(h),r!==void 0){const f=this.getSelectionPageBounds(),y=this.getViewportPageBounds();f&&!y.contains(f)&&this.centerOnPoint(f.center,{duration:Mo})}}),this}moveShapesToPage(t,r){const o=typeof t[0]=="string"?t:t.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>Co)return ud(this,r),this;const a=this.getCamera().z;return this.history.batch(()=>{this.deleteShapes(o),this.setCurrentPage(r),this.setFocusedGroup(null),this.selectNone(),this.putContentOntoCurrentPage(i,{select:!0,preserveIds:!0,preservePosition:!0}),this.setCamera({...this.getCamera(),z:a}),this.centerOnPoint(this.getSelectionRotatedPageBounds().center)}),this}toggleLock(t){const r=typeof t[0]=="string"?t:t.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.batch(()=>{s?(this.updateShapes(i.map(a=>({id:a.id,type:a.type,isLocked:!0}))),this.setSelectedShapes([])):o?this.updateShapes(i.map(a=>({id:a.id,type:a.type,isLocked:!1}))):this.updateShapes(i.map(a=>({id:a.id,type:a.type,isLocked:!0})))}),this}sendToBack(t){const r=typeof t[0]=="string"?t:t.map(s=>s.id),o=cd(this,"toBack",r);return o&&this.updateShapes(o),this}sendBackward(t){const r=typeof t[0]=="string"?t:t.map(s=>s.id),o=cd(this,"backward",r);return o&&this.updateShapes(o),this}bringForward(t){const r=typeof t[0]=="string"?t:t.map(s=>s.id),o=cd(this,"forward",r);return o&&this.updateShapes(o),this}bringToFront(t){const r=typeof t[0]=="string"?t:t.map(s=>s.id),o=cd(this,"toFront",r);return o&&this.updateShapes(o),this}flipShapes(t,r){const o=typeof t[0]=="string"?t:t.map(a=>a.id);if(this.getInstanceState().isReadonly)return this;let s=ge(o.map(a=>this.getShape(a)));if(!s.length)return this;s=ge(s.map(a=>this.isShapeOfType(a,"group")?this.getSortedChildIdsForParent(a.id).map(l=>this.getShape(l)):a).flat());const i=ne.Common(ge(s.map(a=>this.getShapePageBounds(a)))).center;return this.batch(()=>{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",scaleOrigin:i,scaleAxisRotation:0})}}),this}stackShapes(t,r,o){const s=typeof t[0]=="string"?t:t.map(v=>v.id);if(this.getInstanceState().isReadonly)return this;const i=ge(s.map(v=>this.getShape(v)).filter(v=>!(!v||this.isShapeOfType(v,"arrow")&&(v.props.start.type==="binding"||v.props.end.type==="binding")))),a=i.length;if(o===0&&a<3||a<2)return this;const l=Object.fromEntries(i.map(v=>[v.id,this.getShapePageBounds(v)]));let c,u,d,h;r==="horizontal"?(c="x",u="minX",d="maxX",h="width"):(c="y",u="minY",d="maxY",h="height");let f;if(o===0){const v=[];i.sort((w,C)=>l[w.id][u]-l[C.id][u]);for(let w=0;w<a-1;w++){const C=i[w],I=i[w+1],P=l[C.id],_=l[I.id][u]-P[d],k=v.find(M=>M.gap===_);k?k.count++:v.push({gap:_,count:1})}let S=0;v.forEach(w=>{w.count>S&&(S=w.count,f=w.gap)}),S===1&&(f=Math.max(0,v.reduce((w,C)=>w+C.gap*C.count,0)/(a-1)))}else f=o;const y=[];let g=l[i[0].id][d];return i.forEach((v,S)=>{var E,_;if(S===0)return;const w={x:0,y:0};w[c]=g+f-l[v.id][c];const C=this.getShapeParent(v),I=C?b.Rot(w,-this.getShapePageTransform(C).decompose().rotation):w,P=(_=(E=this.getShapeUtil(v)).onTranslateStart)==null?void 0:_.call(E,v);y.push(P?{...P,[c]:v[c]+I[c]}:{id:v.id,type:v.type,[c]:v[c]+I[c]}),g+=l[v.id][h]+f}),this.updateShapes(y),this}packShapes(t,r){var _,k;const o=typeof t[0]=="string"?t:t.map(M=>M.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=ge(o.map(M=>this.getShape(M)).filter(M=>!(!M||this.isShapeOfType(M,"arrow")&&(M.props.start.type==="binding"||M.props.end.type==="binding")))),i={},a={};let l,c,u=0;for(let M=0;M<s.length;M++)l=s[M],c=this.getShapePageBounds(l),i[l.id]=c,a[l.id]=c.clone(),u+=c.width*c.height;const d=ne.Common(ge(Object.values(i))),h=d.width;s.sort((M,T)=>i[T.id].height-i[M.id].height);const f=Math.max(Math.ceil(Math.sqrt(u/.95)),h),y=[new ne(d.x,d.y,f,1/0)];let g=0,v=0,S,w;for(let M=0;M<s.length;M++){l=s[M],c=a[l.id];for(let T=y.length-1;T>=0;T--)if(S=y[T],!(c.width>S.width||c.height>S.height)){c.x=S.x,c.y=S.y,v=Math.max(v,c.maxY),g=Math.max(g,c.maxX),c.width===S.width&&c.height===S.height?(w=y.pop(),T<y.length&&(y[T]=w)):c.height===S.height?(S.x+=c.width+r,S.width-=c.width+r):c.width===S.width?(S.y+=c.height+r,S.height-=c.height+r):(y.push(new ne(S.x+(c.width+r),S.y,S.width-(c.width+r),c.height)),S.y+=c.height+r,S.height-=c.height+r);break}}const C=ne.Common(Object.values(a)),I=b.Sub(d.center,C.center);let P;const E=[];for(let M=0;M<s.length;M++){l=s[M],c=i[l.id],P=a[l.id];const T=b.Sub(P.point,c.point).add(I),R=this.getShapeParentTransform(l);R&&T.rot(-R.rotation());const O={id:l.id,type:l.type,x:l.x+T.x,y:l.y+T.y},U=(k=(_=this.getShapeUtil(l)).onTranslateStart)==null?void 0:k.call(_,{...l,...O});U?E.push({...O,...U}):E.push(O)}return E.length&&this.updateShapes(E),this}alignShapes(t,r){const o=typeof t[0]=="string"?t:t.map(c=>c.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=ge(o.map(c=>this.getShape(c))),i=Object.fromEntries(s.map(c=>[c.id,this.getShapePageBounds(c)])),a=ne.Common(ge(Object.values(i))),l=[];return s.forEach(c=>{const u=i[c.id];if(!u)return;const d={x:0,y:0};switch(r){case"top":{d.y=a.minY-u.minY;break}case"center-vertical":{d.y=a.midY-u.minY-u.height/2;break}case"bottom":{d.y=a.maxY-u.minY-u.height;break}case"left":{d.x=a.minX-u.minX;break}case"center-horizontal":{d.x=a.midX-u.minX-u.width/2;break}case"right":{d.x=a.maxX-u.minX-u.width;break}}const h=this.getShapeParent(c),f=h?b.Rot(d,-this.getShapePageTransform(h).decompose().rotation):d;l.push(this.getChangesToTranslateShape(c,b.Add(c,f)))}),this.updateShapes(l),this}distributeShapes(t,r){const o=typeof t[0]=="string"?t:t.map(C=>C.id);if(this.getInstanceState().isReadonly)return this;if(o.length<3)return this;const s=o.length,i=ge(o.map(C=>this.getShape(C))),a=Object.fromEntries(i.map(C=>[C.id,this.getShapePageBounds(C)]));let l,c,u,d,h;r==="horizontal"?(l="x",c="minX",u="maxX",d="midX",h="width"):(l="y",c="minY",u="maxY",d="midY",h="height");const f=[],y=i.sort((C,I)=>a[C.id][c]-a[I.id][c])[0],g=i.sort((C,I)=>a[I.id][u]-a[C.id][u])[0],v=a[y.id][d],S=(a[g.id][d]-v)/(s-1),w=v+S;return i.filter(C=>C!==y&&C!==g).sort((C,I)=>a[C.id][d]-a[I.id][d]).forEach((C,I)=>{const P={x:0,y:0};P[l]=w+S*I-a[C.id][h]/2-a[C.id][l];const E=this.getShapeParent(C),_=E?b.Rot(P,-this.getShapePageTransform(E).rotation()):P;f.push(this.getChangesToTranslateShape(C,b.Add(C,_)))}),this.updateShapes(f),this}stretchShapes(t,r){const o=typeof t[0]=="string"?t:t.map(c=>c.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=ge(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=ne.Common(ge(Object.values(a)));switch(r){case"vertical":{this.batch(()=>{for(const c of s){if(this.getShapePageTransform(c).rotation()%De)continue;const d=i[c.id],h=a[c.id],f=new b(0,l.minY-h.minY),y=this.getShapeParentTransform(c);y&&f.rot(-y.rotation());const{x:g,y:v}=b.Add(f,c);this.updateShapes([{id:c.id,type:c.type,x:g,y:v}],{squashing:!0});const S=new b(1,l.height/h.height);this.resizeShape(c.id,S,{initialBounds:d,scaleOrigin:new b(h.center.x,l.minY),scaleAxisRotation:0})}});break}case"horizontal":{this.batch(()=>{for(const c of s){const u=i[c.id],d=a[c.id];if(this.getShapePageTransform(c).rotation()%De)continue;const f=new b(l.minX-d.minX,0),y=this.getShapeParentTransform(c);y&&f.rot(-y.rotation());const{x:g,y:v}=b.Add(f,c);this.updateShapes([{id:c.id,type:c.type,x:g,y:v}],{squashing:!0});const S=new b(l.width/d.width,1);this.resizeShape(c.id,S,{initialBounds:u,scaleOrigin:new b(l.minX,d.center.y),scaleAxisRotation:0})}});break}}return this}resizeShape(t,r,o={}){var f;const s=typeof t=="string"?t:t.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??((f=this.getShapePageBounds(s))==null?void 0:f.center);if(!a)return this;const l=o.initialPageTransform?re.Cast(o.initialPageTransform):this.getShapePageTransform(s);if(!l)return this;const c=l.rotation();if(c==null)return this;const u=o.scaleAxisRotation??c,d=o.initialBounds??this.getShapeGeometry(s).bounds;if(!d)return this;if(!bE(c,u))return this._resizeUnalignedShape(s,r,{...o,initialBounds:d,scaleOrigin:a,scaleAxisRotation:u,initialPageTransform:l,initialShape:i});const h=this.getShapeUtil(i);if(h.isAspectRatioLocked(i)&&(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)),h.onResize&&h.canResize(i)){const y=this._scalePagePoint(re.applyToPoint(l,new b(0,0)),a,r,u),g=this.getPointInParentSpace(i.id,y),v=new b(r.x,r.y),S=ic((c-u)%Math.PI,0);v.x=S?r.x:r.y,v.y=S?r.y:r.x;const w=re.applyToPoint(l,new b),{x:C,y:I}=this.getPointInParentSpace(i.id,w);this.updateShapes([{id:s,type:i.type,x:g.x,y:g.y,...h.onResize({...i,x:C,y:I},{newPoint:g,handle:o.dragHandle??"bottom_right",mode:o.mode??"scale_shape",scaleX:v.x,scaleY:v.y,initialBounds:d,initialShape:i})}],{squashing:!0})}else{const y=re.applyToPoint(l,d.center),g=this._scalePagePoint(y,a,r,u),v=this.getPointInParentSpace(i.id,y),S=this.getPointInParentSpace(i.id,g),w=b.Sub(S,v);this.updateShapes([{id:s,type:i.type,x:i.x+w.x,y:i.y+w.y}],{squashing:!0})}return this}_scalePagePoint(t,r,o,s){const i=b.RotWith(t,r,-s).sub(r),a=b.MulV(i,o);return b.Add(a,r).rotWith(r,s)}_resizeUnalignedShape(t,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(t,i,{initialShape:o.initialShape,initialBounds:o.initialBounds}),Math.sign(r.x)*Math.sign(r.y)<0){let{rotation:S}=re.Decompose(o.initialPageTransform);S-=2*S,this.updateShapes([{id:t,type:s,rotation:S}],{squashing:!0})}const a=re.applyToPoint(o.initialPageTransform,o.initialBounds.center),l=this._scalePagePoint(a,o.scaleOrigin,r,o.scaleAxisRotation),c=this.getShapePageBounds(t),u=this.getShapePageTransform(t),d=c.center,h=u.point();if(!d||!h)return this;const f=b.Sub(l,d),y=b.Add(h,f),{x:g,y:v}=this.getPointInParentSpace(t,y);return this.updateShapes([{id:t,type:s,x:g,y:v}],{squashing:!0}),this}getInitialMetaForShape(t){return{}}createShape(t){return this._createShapes([t]),this}createShapes(t){if(!Array.isArray(t))throw Error("Editor.createShapes: must provide an array of shapes or shape partials");return this._createShapes(t),this}animateShape(t,r){return this.animateShapes([t],r)}animateShapes(t,r={}){const{duration:o=500,easing:s=tn.linear}=r,i=ze();let a=o,l;const c=[];let u,d;for(let y=0,g=t.length;y<g;y++){if(u=t[y],!u)continue;d={partial:u,values:[]};const v=this.getShape(u.id);if(v){for(const S of["x","y","rotation"])u[S]!==void 0&&v[S]!==u[S]&&d.values.push({prop:S,from:v[S],to:u[S]});c.push(d),this.animatingShapes.set(v.id,i)}}let h;const f=y=>{if(a-=y,a<0){const{animatingShapes:w}=this,C=t.filter(I=>I&&w.get(I.id)===i);C.length&&this.updateShapes(C,{squashing:!1}),this.removeListener("tick",f);return}l=s(1-a/o);const{animatingShapes:g}=this,v=[];let S;for(let w=0,C=c.length;w<C;w++)h=c[w],S=g.get(h.partial.id),S===i&&v.push({id:h.partial.id,type:h.partial.type,...h.values.reduce((I,{prop:P,from:E,to:_})=>(I[P]=E+(_-E)*l,I),{})});this._updateShapes(v,{squashing:!0})};return this.addListener("tick",f),this}groupShapes(t,r=We()){var f;if(!Array.isArray(t))throw Error("Editor.groupShapes: must provide an array of shapes or shape ids");if(this.getInstanceState().isReadonly)return this;const o=typeof t[0]=="string"?t:t.map(y=>y.id);if(o.length<=1)return this;const s=ge(this._getUnlockedShapeIds(o).map(y=>this.getShape(y))),i=s.sort(Rt).map(y=>y.id),a=ne.Common(ge(s.map(y=>this.getShapePageBounds(y)))),{x:l,y:c}=a.point,u=this.findCommonAncestor(s)??this.getCurrentPageId();if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const d=s.filter(y=>y.parentId===u).sort(Rt),h=(f=d[d.length-1])==null?void 0:f.index;return this.batch(()=>{this.createShapes([{id:r,type:"group",parentId:u,index:h,x:l,y:c,opacity:1,props:{}}]),this.reparentShapes(i,r),this.select(r)}),this}ungroupShapes(t){const r=typeof t[0]=="string"?t:t.map(a=>a.id);if(this.getInstanceState().isReadonly)return this;if(r.length===0)return this;if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const o=new Set,s=ge(r.map(a=>this.getShape(a))),i=[];return s.forEach(a=>{this.isShapeOfType(a,"group")?i.push(a):o.add(a.id)}),i.length===0?this:(this.batch(()=>{let a;for(let l=0,c=i.length;l<c;l++){a=i[l];const u=this.getSortedChildIdsForParent(a.id);for(let d=0,h=u.length;d<h;d++)o.add(u[d]);this.reparentShapes(u,a.parentId,a.index)}this.deleteShapes(i.map(l=>l.id)),this.select(...o)}),this)}updateShape(t,r){return this.updateShapes([t],r),this}updateShapes(t,r){const o=Array(t.length);for(let s=0,i=t.length;s<i;s++){const a=t[s];if(!a)continue;const l=this.getShape(a.id);l&&(this.isShapeOrAncestorLocked(l)&&!Object.hasOwn(a,"isLocked")||(this.animatingShapes.delete(a.id),o.push(a)))}return this._updateShapes(o,r),this}_getUnlockedShapeIds(t){return t.filter(r=>{var o;return!((o=this.getShape(r))!=null&&o.isLocked)})}deleteShapes(t){if(!Array.isArray(t))throw Error("Editor.deleteShapes: must provide an array of shapes or shapeIds");return this._deleteShapes(this._getUnlockedShapeIds(typeof t[0]=="string"?t:t.map(r=>r.id))),this}deleteShape(t){return this.deleteShapes([typeof t=="string"?t:t.id]),this}_extractSharedStyles(t,r){if(this.isShapeOfType(t,"group")){const o=this._parentIdsToChildIds.get()[t.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[t.type])r.applyValue(o,hr(t.props,s))}_getSelectionSharedStyles(){const t=this.getSelectedShapes(),r=new Ky;for(const o of t)this._extractSharedStyles(o,r);return r}getStyleForNextShape(t){const r=this.getInstanceState().stylesForNextShape[t.id];return r===void 0?t.defaultValue:r}getShapeStyleIfExists(t,r){const o=this.styleProps[t.type].get(r);if(o!==void 0)return hr(t.props,o)}getSharedStyles(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0)return this._getSelectionSharedStyles();const t=this.root.getCurrent(),r=new Ky;if(!t)return r;if(t.shapeType)for(const o of this.styleProps[t.shapeType].keys())r.applyValue(o,this.getStyleForNextShape(o));return r}getSharedOpacity(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0){const t=[],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 t.push(i)};for(const s of this.getSelectedShapeIds())r(s);let o=null;for(const s of t)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(t,r){return this.updateInstanceState({opacityForNextShape:t},r),this}setOpacityForSelectedShapes(t,r){const o=this.getSelectedShapes();if(o.length>0){const s=[],i=a=>{if(this.isShapeOfType(a,"group")){const l=this.getSortedChildIdsForParent(a);for(const c of l)i(this.getShape(c))}else s.push(a)};for(const a of o)i(a);this.updateShapes(s.map(a=>({id:a.id,type:a.type,opacity:t})),r)}return this}setStyleForNextShapes(t,r,o){const s=this.getInstanceState().stylesForNextShape;return this.updateInstanceState({stylesForNextShape:{...s,[t.id]:r}},o),this}setStyleForSelectedShapes(t,r,o){const s=this.getSelectedShapes();if(s.length>0){const i=[],a=l=>{if(this.isShapeOfType(l,"group")){const c=this.getSortedChildIdsForParent(l.id);for(const u of c)a(this.getShape(u))}else{const c=this.getShapeUtil(l),u=this.styleProps[l.type].get(t);if(u){const d={id:l.id,type:l.type,props:{[u]:r}};i.push({util:c,originalShape:l,updatePartial:d})}}};for(const l of s)a(l);this.updateShapes(i.map(({updatePartial:l})=>l),o)}return this}registerExternalAssetHandler(t,r){return this.externalAssetContentHandlers[t]=r,this}async getAssetForExternalContent(t){var r,o;return await((o=(r=this.externalAssetContentHandlers)[t.type])==null?void 0:o.call(r,t))}registerExternalContentHandler(t,r){return this.externalContentHandlers[t]=r,this}async putExternalContent(t){var r,o;return(o=(r=this.externalContentHandlers)[t.type])==null?void 0:o.call(r,t)}getContentFromCurrentPage(t){const r=typeof t[0]=="string"?t:t.map(l=>l.id);if(!r||r.length===0)return;const o={};let s=ep(r.map(l=>this.getShape(l)).sort(Rt).flatMap(l=>{const c=[l];return this.visitDescendants(l.id,u=>{c.push(this.getShape(u))}),c}));s=s.map(l=>{if(o[l.id]=this.getShapePageTransform(l.id),l=Dr(l),this.isShapeOfType(l,"arrow")){const c=l.props.start.type==="binding"?l.props.start.boundShapeId:void 0,u=l.props.end.type==="binding"?l.props.end.boundShapeId:void 0,d=this.getArrowInfo(l);if(l.props.start.type==="binding"&&!s.some(f=>f.id===c))if(d!=null&&d.isValid){const{x:f,y}=d.start.point;l.props.start={type:"point",x:f,y}}else{const{start:f}=Ar(this,l);l.props.start={type:"point",x:f.x,y:f.y}}if(l.props.end.type==="binding"&&!s.some(f=>f.id===u))if(d!=null&&d.isValid){const{x:f,y}=d.end.point;l.props.end={type:"point",x:f,y}}else{const{end:f}=Ar(this,l);l.props.end={type:"point",x:f.x,y:f.y}}const h=$l(l)?lc(this,l):Rg(this,l);if(d!=null&&d.isValid&&(h!=null&&h.isValid)&&!$l(l)){const f=b.Med(d.start.handle,d.end.handle),y=b.Dist(d.middle,f),g=b.Dist(h.middle,f);l.props.bend<0?l.props.bend+=g-y:l.props.bend-=g-y}return l}return l});const i=[];s.forEach(l=>{if(s.find(c=>c.id===l.parentId)===void 0){const c=this.getShapePageTransform(l.id),u=c.point(),d=c.rotation();l.x=u.x,l.y=u.y,l.rotation=d,l.parentId=this.getCurrentPageId(),i.push(l.id)}});const a=new Set;return s.forEach(l=>{"assetId"in l.props&&l.props.assetId!==null&&a.add(l.props.assetId)}),{shapes:s,rootShapeIds:i,schema:this.store.schema.serialize(),assets:ge(Array.from(a).map(l=>this.getAsset(l)))}}putContentOntoCurrentPage(t,r={}){if(this.getInstanceState().isReadonly)return this;if(!t.schema)throw Error(`Could not put content:
|
|
57
|
+
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}=t,u=[],d=[],h={store:{...Object.fromEntries(t.assets.map(k=>[k.id,k])),...Object.fromEntries(t.shapes.map(k=>[k.id,k]))},schema:t.schema},f=this.store.schema.migrateStoreSnapshot(h);if(f.type==="error")throw Error("Could not put content: could not migrate content");for(const k of Object.values(f.value))switch(k.typeName){case"asset":{u.push(k);break}case"shape":{d.push(k);break}}const y=new Map(d.map(k=>[k.id,We()]));let g=this.getCurrentPageId(),v=1/0,S=[];for(const k of this.getSelectedShapes()){if(v===0)break;const M=this.isShapeOfType(k,"frame"),T=this.getShapeAncestors(k);M&&T.push(k);const R=M?T.length+1:T.length;if(R<v)v=R,S=T,g=M?k.id:k.parentId;else if(R===v){if(S.length!==T.length)throw Error(`Ancestors: ${S.length} !== ${T.length}`);if(S.length===0){g=l;break}else{g=l;for(let O=0;O<S.length&&T[O]===S[O];O++)g=T[O].id}}}let w=!1;if(!wn(g)){const k=this.getShape(g);if(k){if(!this.getViewportPageBounds().includes(this.getShapePageBounds(k)))g=l;else if(c.length===1){const M=d.find(T=>T.id===c[0]);this.isShapeOfType(k,"frame")&&this.isShapeOfType(M,"frame")&&M.props.w===(k==null?void 0:k.props.w)&&M.props.h===(k==null?void 0:k.props.h)&&(w=!0)}}else g=l}w||(w=y.has(g)),w&&(g=this.getShape(g).parentId);let C=this.getHighestIndexForParent(g);const I=[],P=d.map(k=>{let M;if(s)M=pr(k),y.set(k.id,k.id);else{const T=y.get(k.id);M=pr({...k,id:T})}if(c.includes(k.id)&&(M.parentId=l,I.push(M)),y.has(M.parentId)?M.parentId=y.get(k.parentId):(c.push(M.id),M.index=C,C=ko(C)),this.isShapeOfType(M,"arrow")){if(M.props.start.type==="binding"){const T=y.get(M.props.start.boundShapeId);M.props.start=T?{...M.props.start,boundShapeId:T}:{type:"point",x:0,y:0}}if(M.props.end.type==="binding"){const T=y.get(M.props.end.boundShapeId);M.props.end=T?{...M.props.end,boundShapeId:T}:{type:"point",x:0,y:0}}}return M});if(P.length+this.getCurrentPageShapeIds().size>Co)return ud(this),this;let E=[];const _=[];return E=u.filter(k=>!this.store.has(k.id)).map(k=>{var M;return(k.type==="image"||k.type==="video")&&(k.props.src&&((M=k.props.src)!=null&&M.startsWith("data:image"))?(_.push(Dr(k)),k.props.src=null):_.push(Dr(k))),k}),Promise.allSettled(_.map(async k=>{const M=await K6(k.props.src,k.props.name,k.props.mimeType??"image/png"),T=await this.getAssetForExternalContent({type:"file",file:M});return T?[k,T]:null})).then(k=>{this.updateAssets(ge(k.map(M=>M.status==="fulfilled"&&M.value?{...M.value[1],id:M.value[0].id}:void 0)))}),this.batch(()=>{E.length>0&&this.createAssets(E),this.createShapes(P),o&&this.select(...I.map(O=>O.id)),g!==l&&this.reparentShapes(I.map(O=>O.id),g);const k=P.map(O=>this.getShape(O.id)),M=ne.Common(k.map(O=>this.getShapePageBounds(O)));if(a===void 0)if(wn(g)){const O=this.getViewportPageBounds();i||O.includes(ne.From(M))?a=M.center:a=O.center}else{const O=this.getShape(g);a=re.applyToPoint(this.getShapePageTransform(O),this.getShapeGeometry(O).bounds.center)}if(I.length===1){const O=I[0];if(this.isShapeOfType(O,"frame"))for(;this.getShapesAtPoint(a).some(U=>this.isShapeOfType(U,"frame")&&U.props.w===O.props.w&&U.props.h===O.props.h);)a.x+=M.w+16}const T=ne.Common(ge(I.map(({id:O})=>this.getShapePageBounds(O)))).center,R=b.Sub(a,T);this.updateShapes(I.map(({id:O})=>{const U=this.getShape(O),N=this.getShapeParentTransform(O).decompose().rotation,L=b.Rot(R,-N);return{id:U.id,type:U.type,x:U.x+L.x,y:U.y+L.y}}))}),this}async getSvg(t,r={}){var E,_;const o=typeof t[0]=="string"?t:t.map(k=>k.id);if(o.length===0)return;if(!window.document)throw Error("No document");const{scale:s=1,background:i=!1,padding:a=zR,preserveAspectRatio:l=!1}=r,c=r.darkMode??this.user.getIsDarkMode(),u=Dn({isDarkMode:c}),d=this.getShapeAndDescendantIds(o),h=this.getUnorderedRenderingShapes(!1).filter(({id:k})=>d.has(k));let f=null;if(r.bounds)f=r.bounds;else for(const{maskedPageBounds:k}of h)k&&(f?f.union(k):f=k.clone());if(!f)return;const y=o.length===1&&this.isShapeOfType(this.getShape(o[0]),"frame")?o[0]:null;y||f.expandBy(a);const g=f.width*s,v=f.height*s,S=window.document.createElementNS("http://www.w3.org/2000/svg","svg");l&&S.setAttribute("preserveAspectRatio",l),S.setAttribute("direction","ltr"),S.setAttribute("width",g+""),S.setAttribute("height",v+""),S.setAttribute("viewBox",`${f.minX} ${f.minY} ${f.width} ${f.height}`),S.setAttribute("stroke-linecap","round"),S.setAttribute("stroke-linejoin","round"),i?y?S.style.setProperty("background",u.solid):S.style.setProperty("background-color",u.background):S.style.setProperty("background-color","transparent");try{(_=(E=document.body).focus)==null||_.call(E)}catch{}const w=window.document.createElementNS("http://www.w3.org/2000/svg","defs");S.append(w);const C=new Map,I={isDarkMode:c,addExportDef:k=>{if(C.has(k.key))return;const M=(async()=>{const T=await k.getElement();if(!T)return;const R=document.createComment(`def: ${k.key}`);w.appendChild(R);for(const O of Array.isArray(T)?T:[T])w.appendChild(O)})();C.set(k.key,M)}},P=(await Promise.all(h.map(async({id:k,opacity:M,index:T,backgroundIndex:R})=>{var B,W;if(k===y)return[];const O=this.getShape(k);if(this.isShapeOfType(O,"group"))return[];const U=this.getShapeUtil(O);let N=await((B=U.toSvg)==null?void 0:B.call(U,O,I)),L=await((W=U.toBackgroundSvg)==null?void 0:W.call(U,O,I));if(N){const Y=document.createElementNS("http://www.w3.org/2000/svg","g");Y.appendChild(N),N=Y}if(L){const Y=document.createElementNS("http://www.w3.org/2000/svg","g");Y.appendChild(L),L=Y}if(!N&&!L){const Y=this.getShapePageBounds(O),J=window.document.createElementNS("http://www.w3.org/2000/svg","rect");J.setAttribute("width",Y.width+""),J.setAttribute("height",Y.height+""),J.setAttribute("fill",u.solid),J.setAttribute("stroke",u.grey.pattern),J.setAttribute("stroke-width","1"),N=J}let G=this.getShapePageTransform(O).toCssString();"scale"in O.props&&O.props.scale!==1&&(G=`${G} scale(${O.props.scale}, ${O.props.scale})`),N==null||N.setAttribute("transform",G),L==null||L.setAttribute("transform",G),N==null||N.setAttribute("opacity",M+""),L==null||L.setAttribute("opacity",M+"");const X=this.getShapeMask(O.id);if(X){const Y=document.createElementNS("http://www.w3.org/2000/svg","clipPath");w.appendChild(Y);const J=ze();Y.id=J;const ke=document.createElementNS("http://www.w3.org/2000/svg","path");if(ke.setAttribute("d",`M${X.map(({x:ve,y:pe})=>`${ve},${pe}`).join("L")}Z`),Y.appendChild(ke),N){const ve=document.createElementNS("http://www.w3.org/2000/svg","g");ve.setAttribute("clip-path",`url(#${J})`),ve.appendChild(N),N=ve}if(L){const ve=document.createElementNS("http://www.w3.org/2000/svg","g");ve.setAttribute("clip-path",`url(#${J})`),ve.appendChild(L),L=ve}}const H=[];return N&&H.push({zIndex:T,element:N}),L&&H.push({zIndex:R,element:L}),H}))).flat();await Promise.all(C.values());for(const{element:k}of P.sort((M,T)=>M.zIndex-T.zIndex))S.appendChild(k);return S}_updateInputsFromEvent(t){var y;const{previousScreenPoint:r,previousPagePoint:o,currentScreenPoint:s,currentPagePoint:i}=this.inputs,{screenBounds:a}=this.store.unsafeGetWithoutCapture(Lt),{x:l,y:c,z:u}=this.getCamera(),d=t.point.x-a.x,h=t.point.y-a.y,f=t.point.z;r.setTo(s),o.setTo(i),s.set(d,h),i.set(d/u-l,h/u-c,f??.5),this.inputs.isPen=t.type==="pointer"&&t.isPen,t.name==="pointer_down"&&this.inputs.pointerVelocity.set(0,0),this.store.put([{id:ip,typeName:"pointer",x:i.x,y:i.y,lastActivityTimestamp:t.type==="pointer"&&t.pointerId===nb.CAMERA_MOVE?((y=this.store.get(ip))==null?void 0:y.lastActivityTimestamp)??Date.now():Date.now(),meta:{}}])}cancel(){return this.dispatch({type:"misc",name:"cancel"}),this}interrupt(){return this.dispatch({type:"misc",name:"interrupt"}),this}complete(){return this.dispatch({type:"misc",name:"complete"}),this}cancelDoubleClick(){this._clickManager.cancelDoubleClickTimeout()}}ce([Z],ae.prototype,"getCanUndo",1);ce([Z],ae.prototype,"getCanRedo",1);ce([Z],ae.prototype,"_getArrowBindingsIndex",1);ce([Z],ae.prototype,"getArrowInfoCache",1);ce([Z],ae.prototype,"getPath",1);ce([Z],ae.prototype,"getCurrentTool",1);ce([Z],ae.prototype,"getCurrentToolId",1);ce([Z],ae.prototype,"getDocumentSettings",1);ce([Z],ae.prototype,"getInstanceState",1);ce([Z],ae.prototype,"getOpenMenus",1);ce([Z],ae.prototype,"getIsMenuOpen",1);ce([Z],ae.prototype,"getPageStates",1);ce([Z],ae.prototype,"_getPageStatesQuery",1);ce([Z],ae.prototype,"getCurrentPageState",1);ce([Z],ae.prototype,"_getCurrentPageStateId",1);ce([Z],ae.prototype,"getSelectedShapeIds",1);ce([Z],ae.prototype,"getSelectedShapes",1);ce([Z],ae.prototype,"getOnlySelectedShape",1);ce([Z],ae.prototype,"getSelectionPageBounds",1);ce([Z],ae.prototype,"getSelectionRotation",1);ce([Z],ae.prototype,"getSelectionRotatedPageBounds",1);ce([Z],ae.prototype,"getFocusedGroupId",1);ce([Z],ae.prototype,"getFocusedGroup",1);ce([Z],ae.prototype,"getEditingShapeId",1);ce([Z],ae.prototype,"getEditingShape",1);ce([Z],ae.prototype,"getHoveredShapeId",1);ce([Z],ae.prototype,"getHoveredShape",1);ce([Z],ae.prototype,"getHintingShapeIds",1);ce([Z],ae.prototype,"getHintingShape",1);ce([Z],ae.prototype,"getErasingShapeIds",1);ce([Z],ae.prototype,"getErasingShapes",1);ce([Z],ae.prototype,"getCameraId",1);ce([Z],ae.prototype,"getCamera",1);ce([Z],ae.prototype,"getZoomLevel",1);ce([Z],ae.prototype,"getViewportScreenBounds",1);ce([Z],ae.prototype,"getViewportScreenCenter",1);ce([Z],ae.prototype,"getViewportPageBounds",1);ce([Z],ae.prototype,"getViewportPageCenter",1);ce([Z],ae.prototype,"getRenderingShapes",1);ce([Z],ae.prototype,"_getAllPagesQuery",1);ce([Z],ae.prototype,"getPages",1);ce([Z],ae.prototype,"_getAllAssetsQuery",1);ce([Z],ae.prototype,"_getShapeGeometryCache",1);ce([Z],ae.prototype,"_getShapeHandlesCache",1);ce([Z],ae.prototype,"_getShapePageTransformCache",1);ce([Z],ae.prototype,"_getShapePageBoundsCache",1);ce([Z],ae.prototype,"_getShapeClipPathCache",1);ce([Z],ae.prototype,"_getShapeMaskCache",1);ce([Z],ae.prototype,"getCurrentPageBounds",1);ce([Z],ae.prototype,"getCurrentPageShapes",1);ce([Z],ae.prototype,"getCurrentPageShapesSorted",1);ce([Z],ae.prototype,"getCurrentPageRenderingShapesSorted",1);ce([Z],ae.prototype,"_getSelectionSharedStyles",1);ce([Z({isEqual:(e,n)=>e.equals(n)})],ae.prototype,"getSharedStyles",1);ce([Z],ae.prototype,"getSharedOpacity",1);function ud(e,n=e.getCurrentPageId()){const t=e.getPage(n).name;e.emit("max-shapes",{name:t,pageId:n,count:Co})}function Ml(e,n){if(!n)return e;let t=null;const r=Object.entries(n);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(t||(t={...e}),i==="props"||i==="meta"){t[i]={...e[i]};for(const[l,c]of Object.entries(a))c!==void 0&&(t[i][l]=c);continue}t[i]=a}}return t||e}function Sf(){const e=F();return K("isDarkMode",()=>e.user.getIsDarkMode(),[e])}const jb="<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'/>",Ob="<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'/>",dd='<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 os(e,n,t,r,o,s=16,i=16){const a=(-t-n)*($e/180),l=Math.sin(a),c=Math.cos(a),u=1*c-1*l,d=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='${d}' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(${n+t} 16 16)${r?" scale(-1,-1) translate(0, -32)":""}' filter='url(%23shadow)'>`+e.replaceAll('"',"'")+`</g></svg>") ${s} ${i}, pointer`}const kN=["default","pointer","cross","move","grab","grabbing","text","zoom-in","zoom-out"],TN={none:()=>"none","ew-resize":(e,n,t)=>os(Ob,e,0,n,t),"ns-resize":(e,n,t)=>os(Ob,e,90,n,t),"nesw-resize":(e,n,t)=>os(jb,e,0,n,t),"nwse-resize":(e,n,t)=>os(jb,e,90,n,t),"nwse-rotate":(e,n,t)=>os(dd,e,0,n,t),"nesw-rotate":(e,n,t)=>os(dd,e,90,n,t),"senw-rotate":(e,n,t)=>os(dd,e,180,n,t),"swne-rotate":(e,n,t)=>os(dd,e,270,n,t)};function Bn(e,n=0,t="black"){return TN[e](MR(n),!1,t)}function $N(){const e=F(),n=mn(),t=Sf();fi("useCursor",()=>{const{type:r,rotation:o}=e.getInstanceState().cursor;if(kN.includes(r)){n.style.setProperty("--tl-cursor",`var(--tl-cursor-${r})`);return}n.style.setProperty("--tl-cursor",Bn(r,o,t?"white":"black"))},[e,n,t])}function MN(){const e=F(),n=mn(),t=Sf(),r=K(Ft.forceSrgb);ie.useEffect(()=>{t?(n.setAttribute("data-color-mode","dark"),n.classList.remove("tl-theme__light"),n.classList.add("tl-theme__dark")):(n.setAttribute("data-color-mode","light"),n.classList.remove("tl-theme__dark"),n.classList.add("tl-theme__light")),r?n.classList.add("tl-theme__force-sRGB"):n.classList.remove("tl-theme__force-sRGB")},[e,n,r,t])}function AN(e){const n=x.useRef();return x.useLayoutEffect(()=>{n.current=e}),x.useDebugValue(e),x.useCallback((...t)=>{const r=n.current;return Do(r,"fn does not exist"),r(...t)},[])}function jN(e){const n=F(),t=mn();x.useLayoutEffect(()=>{e?(n.getInstanceState().isFocused||n.updateInstanceState({isFocused:!0}),n.getContainer().focus()):n.getInstanceState().isFocused&&n.updateInstanceState({isFocused:!1})},[n,t,e])}function ON(){const[e,n]=x.useState(0);x.useEffect(()=>n(t=>t+1),[])}const Aa="TLDRAW_TAB_ID_v2",En=globalThis.window;function DN(){return En?["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(En.navigator.platform)||En.navigator.userAgent.includes("Mac")&&"ontouchend"in document:!1}const Pp=En?En[Aa]??En.sessionStorage[Aa]??"TLDRAW_INSTANCE_STATE_V1_"+ze():"<error>";En&&(En[Aa]=Pp,DN()?En.sessionStorage[Aa]=Pp:delete En.sessionStorage[Aa]);En==null||En.addEventListener("beforeunload",()=>{En.sessionStorage[Aa]=Pp});const RN={Initial:0},Oc=RN.Initial,p_=be({version:de,currentPageId:Ic,isFocusMode:xe,exportBackground:xe,isDebugMode:xe,isToolLocked:xe,isGridMode:xe,pageStates:zt(be({pageId:Ic,camera:be({x:de,y:de,z:de}),selectedShapeIds:zt(Er),focusedGroupId:Er.nullable()}))}),LN=Me({currentVersion:Oc});function NN(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;const n=Dv({value:e,fromVersion:e.version,toVersion:Oc,migrations:LN});if(n.type==="error")return console.warn(n.reason),null;const t={...n.value,version:Oc};try{p_.validate(t)}catch(r){return console.warn(r),null}return t}function FN(e){const n=e.query.ids("page");return Z("sessionStateSnapshot",()=>{const t=e.get(Lt);if(!t)return null;const r=[...n.get()];return{version:Oc,currentPageId:t.currentPageId,exportBackground:t.exportBackground,isFocusMode:t.isFocusMode,isDebugMode:t.isDebugMode,isToolLocked:t.isToolLocked,isGridMode:t.isGridMode,pageStates:r.map(o=>{const s=e.get(Zt.createId(o)),i=e.get(qt.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 zN(e,n){const t=NN(n);if(!t)return;const r=e.allRecords().filter(i=>i.typeName==="instance_page_state"||i.typeName==="camera"),o={added:{},updated:{},removed:{...jv(r.map(i=>[i.id,i]))}};e.has(Lt)&&(o.removed[Lt]=e.get(Lt));const s={removed:{},updated:{},added:{[Lt]:e.schema.types.instance.create({id:Lt,currentPageId:t.currentPageId,isDebugMode:t.isDebugMode,isFocusMode:t.isFocusMode,isToolLocked:t.isToolLocked,isGridMode:t.isGridMode,exportBackground:t.exportBackground})}};for(const i of t.pageStates){const a=qt.createId(i.pageId),l=Zt.createId(i.pageId);s.added[a]=qt.create({id:qt.createId(i.pageId),x:i.camera.x,y:i.camera.y,z:i.camera.z}),s.added[l]=Zt.create({id:Zt.createId(i.pageId),pageId:i.pageId,selectedShapeIds:i.selectedShapeIds,focusedGroupId:i.focusedGroupId})}Tr(()=>{e.applyDiff(uf([o,s])),e.ensureStoreIsUsable()})}function BN(e){var o;const n=[];for(const s of Object.values(e))(o=s.typeName)!=null&&o.match(/^(instance.*|pointer|camera)$/)&&n.push(s);const t=n.filter(s=>s.typeName==="instance"&&s.id!==Lt)[0];if(!t)return null;const r={version:Oc,currentPageId:t.currentPageId,exportBackground:!!t.exportBackground,isFocusMode:!!t.isFocusMode,isDebugMode:!!t.isDebugMode,isToolLocked:!!t.isToolLocked,isGridMode:!1,pageStates:n.filter(s=>s.typeName==="instance_page_state"&&s.instanceId===t.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 p_.validate(r),r}catch{return null}}function UN(){window.alert(`Oops! We could not save changes to your browser's storage. We now need to reload the page and try again.
|
|
58
|
+
|
|
59
|
+
Keep seeing this message?
|
|
60
|
+
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.
|
|
61
|
+
• If your hard disk is full, try clearing up some space and then reload the page.`)}function HN(){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.
|
|
62
|
+
|
|
63
|
+
Keep seeing this message?
|
|
64
|
+
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.`)}const KN=(e,n)=>n.some(t=>e instanceof t);let Db,Rb;function VN(){return Db||(Db=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function WN(){return Rb||(Rb=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const f_=new WeakMap,Vy=new WeakMap,g_=new WeakMap,Lg=new WeakMap,o0=new WeakMap;function GN(e){const n=new Promise((t,r)=>{const o=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{t(Ro(e.result)),o()},i=()=>{r(e.error),o()};e.addEventListener("success",s),e.addEventListener("error",i)});return n.then(t=>{t instanceof IDBCursor&&f_.set(t,e)}).catch(()=>{}),o0.set(n,e),n}function YN(e){if(Vy.has(e))return;const n=new Promise((t,r)=>{const o=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{t(),o()},i=()=>{r(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)});Vy.set(e,n)}let Wy={get(e,n,t){if(e instanceof IDBTransaction){if(n==="done")return Vy.get(e);if(n==="objectStoreNames")return e.objectStoreNames||g_.get(e);if(n==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Ro(e[n])},set(e,n,t){return e[n]=t,!0},has(e,n){return e instanceof IDBTransaction&&(n==="done"||n==="store")?!0:n in e}};function XN(e){Wy=e(Wy)}function qN(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(n,...t){const r=e.call(Ng(this),n,...t);return g_.set(r,n.sort?n.sort():[n]),Ro(r)}:WN().includes(e)?function(...n){return e.apply(Ng(this),n),Ro(f_.get(this))}:function(...n){return Ro(e.apply(Ng(this),n))}}function ZN(e){return typeof e=="function"?qN(e):(e instanceof IDBTransaction&&YN(e),KN(e,VN())?new Proxy(e,Wy):e)}function Ro(e){if(e instanceof IDBRequest)return GN(e);if(Lg.has(e))return Lg.get(e);const n=ZN(e);return n!==e&&(Lg.set(e,n),o0.set(n,e)),n}const Ng=e=>o0.get(e);function QN(e,n,{blocked:t,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(e,n),a=Ro(i);return r&&i.addEventListener("upgradeneeded",l=>{r(Ro(i.result),l.oldVersion,l.newVersion,Ro(i.transaction),l)}),t&&i.addEventListener("blocked",l=>t(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 JN(e,{blocked:n}={}){const t=indexedDB.deleteDatabase(e);return n&&t.addEventListener("blocked",r=>n(r.oldVersion,r)),Ro(t).then(()=>{})}const eF=["get","getKey","getAll","getAllKeys","count"],tF=["put","add","delete","clear"],Fg=new Map;function Lb(e,n){if(!(e instanceof IDBDatabase&&!(n in e)&&typeof n=="string"))return;if(Fg.get(n))return Fg.get(n);const t=n.replace(/FromIndex$/,""),r=n!==t,o=tF.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(o||eF.includes(t)))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[t](...a),o&&l.done]))[0]};return Fg.set(n,s),s}XN(e=>({...e,get:(n,t,r)=>Lb(n,t)||e.get(n,t,r),has:(n,t)=>!!Lb(n,t)||e.has(n,t)}));const vf="TLDRAW_DOCUMENT_v2",m_="TLDRAW_DB_NAME_INDEX_v2",Oe={Records:"records",Schema:"schema",SessionState:"session_state"};async function wf(e,n){iF(e);const t=await QN(e,3,{upgrade(r){r.objectStoreNames.contains(Oe.Records)||r.createObjectStore(Oe.Records),r.objectStoreNames.contains(Oe.Schema)||r.createObjectStore(Oe.Schema),r.objectStoreNames.contains(Oe.SessionState)||r.createObjectStore(Oe.SessionState)}});try{return await n(t)}finally{t.close()}}async function nF({persistenceKey:e,sessionId:n,didCancel:t}){const r=vf+e;if(s0().includes(r))return await sF({persistenceKey:e,didCancel:t}),await wf(r,async o=>{var d,h;if(t!=null&&t())return;const s=o.transaction([Oe.Records,Oe.Schema,Oe.SessionState],"readonly"),i=s.objectStore(Oe.Records),a=s.objectStore(Oe.Schema),l=s.objectStore(Oe.SessionState);let c=n?(d=await l.get(n))==null?void 0:d.snapshot:null;c||(c=(h=(await l.getAll()).sort((y,g)=>y.updatedAt-g.updatedAt).pop())==null?void 0:h.snapshot);const u={records:await i.getAll(),schema:await a.get(Oe.Schema),sessionStateSnapshot:c};if(t!=null&&t()){s.abort();return}return await s.done,u})}async function rF({persistenceKey:e,schema:n,changes:t,sessionId:r,sessionStateSnapshot:o,didCancel:s}){const i=vf+e;await wf(i,async a=>{const l=a.transaction([Oe.Records,Oe.Schema,Oe.SessionState],"readwrite"),c=l.objectStore(Oe.Records),u=l.objectStore(Oe.Schema),d=l.objectStore(Oe.SessionState);for(const[h,f]of Object.entries(t.added))await c.put(f,h);for(const[h,f]of Object.values(t.updated))await c.put(f,f.id);for(const h of Object.keys(t.removed))await c.delete(h);if(u.put(n.serialize(),Oe.Schema),o&&r?d.put({snapshot:o,updatedAt:Date.now(),id:r},r):(o||r)&&console.error("sessionStateSnapshot and instanceId must be provided together"),s!=null&&s())return l.abort();await l.done})}async function oF({persistenceKey:e,schema:n,snapshot:t,sessionId:r,sessionStateSnapshot:o,didCancel:s}){const i=vf+e;await wf(i,async a=>{const l=a.transaction([Oe.Records,Oe.Schema,Oe.SessionState],"readwrite"),c=l.objectStore(Oe.Records),u=l.objectStore(Oe.Schema),d=l.objectStore(Oe.SessionState);await c.clear();for(const[h,f]of Object.entries(t))await c.put(f,h);if(u.put(n.serialize(),Oe.Schema),o&&r?d.put({snapshot:o,updatedAt:Date.now(),id:r},r):(o||r)&&console.error("sessionStateSnapshot and instanceId must be provided together"),s!=null&&s())return l.abort();await l.done})}async function sF({persistenceKey:e,didCancel:n}){await wf(vf+e,async t=>{const r=t.transaction([Oe.SessionState],"readwrite"),o=r.objectStore(Oe.SessionState),s=(await o.getAll()).sort((a,l)=>a.updatedAt-l.updatedAt);if(s.length<10){await r.done;return}const i=s.slice(0,s.length-10);for(const{id:a}of i)await o.delete(a);if(n!=null&&n())return r.abort();await r.done})}function s0(){const e=JSON.parse((window==null?void 0:window.localStorage.getItem(m_))||"[]")??[];return Array.isArray(e)?e:[]}function iF(e){const n=new Set(s0());n.add(e),window==null||window.localStorage.setItem(m_,JSON.stringify([...n]))}const aF=350,lF=1e4,Nb=Symbol("UPDATE_INSTANCE_STATE"),cF=e=>e;class uF{constructor(n){m(this,"onmessage")}postMessage(n){}close(){}}const dF=typeof BroadcastChannel>"u"?uF:BroadcastChannel;class hF{constructor(n,{persistenceKey:t,sessionId:r=Pp,onLoad:o,onLoadError:s},i=new dF(`tldraw-tab-sync-${t}`)){m(this,"disposables",new Set);m(this,"diffQueue",[]);m(this,"didDispose",!1);m(this,"shouldDoFullDBWrite",!0);m(this,"isReloading",!1);m(this,"persistenceKey");m(this,"sessionId");m(this,"serializedSchema");m(this,"isDebugging",!1);m(this,"documentTypes");m(this,"$sessionStateSnapshot");m(this,"initTime",Date.now());m(this,"isPersisting",!1);m(this,"didLastWriteError",!1);m(this,"scheduledPersistTimeout",null);this.store=n,this.channel=i,typeof window<"u"&&(window.tlsync=this),this.persistenceKey=t,this.sessionId=r,this.serializedSchema=this.store.schema.serialize(),this.$sessionStateSnapshot=FN(this.store),this.disposables.add(n.listen(({changes:a})=>{this.diffQueue.push(a),this.channel.postMessage(cF({type:"diff",storeId:this.store.id,changes:a,schema:this.serializedSchema})),this.schedulePersist()},{source:"user",scope:"document"})),this.disposables.add(n.listen(()=>{this.diffQueue.push(Nb),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(...n){this.isDebugging&&console.debug(...n)}async connect(n,t){this.debug("connecting");let r;try{r=await nF({persistenceKey:this.persistenceKey,sessionId:this.sessionId,didCancel:()=>this.didDispose})}catch(o){t(o),HN(),typeof window<"u"&&window.location.reload();return}if(this.debug("loaded data from store",r,"didDispose",this.didDispose),!this.didDispose)try{if(r){const o=Object.fromEntries(r.records.map(a=>[a.id,a])),s=r.sessionStateSnapshot??BN(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),t(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&&zN(this.store,s)}this.channel.onmessage=({data:o})=>{var a,l;this.debug("got message",o);const s=o,i=CD(this.serializedSchema,s.schema??this.store.schema.serializeEarliestVersion());if(i===-1){if(Date.now()-this.initTime<5e3){t(new Error("Schema mismatch, please close other tabs and reload the page"));return}this.debug("reloading"),this.isReloading=!0,(l=(a=window==null?void 0:window.location)==null?void 0:a.reload)==null||l.call(a);return}else if(i===1){this.debug("telling them to reload"),this.channel.postMessage({type:"announce",schema:this.serializedSchema}),this.shouldDoFullDBWrite=!0,this.persistIfNeeded();return}s.type==="diff"&&(this.debug("applying diff"),Tr(()=>{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()}),n(this)}catch(o){if(this.debug("error loading data from store",o),this.didDispose)return;t(o);return}}close(){this.debug("closing"),this.didDispose=!0,this.disposables.forEach(n=>n())}schedulePersist(){this.debug("schedulePersist",this.scheduledPersistTimeout),!this.scheduledPersistTimeout&&(this.scheduledPersistTimeout=setTimeout(()=>{this.scheduledPersistTimeout=null,this.persistIfNeeded()},this.didLastWriteError?lF:aF))}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(){Do(!this.isPersisting,"persist already in progress"),this.isPersisting=!0,this.debug("doPersist start");const n=this.diffQueue;this.diffQueue=[];try{if(this.shouldDoFullDBWrite)this.shouldDoFullDBWrite=!1,await oF({persistenceKey:this.persistenceKey,schema:this.store.schema,snapshot:this.store.serialize(),didCancel:()=>this.didDispose,sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()});else{const t=uf(n.filter(r=>r!==Nb));await rF({persistenceKey:this.persistenceKey,changes:t,schema:this.store.schema,didCancel:()=>this.didDispose,sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()})}this.didLastWriteError=!1}catch(t){this.shouldDoFullDBWrite=!0,this.didLastWriteError=!0,console.error("failed to store changes in indexed db",t),UN(),typeof window<"u"&&window.location.reload()}this.isPersisting=!1,this.debug("doPersist end"),this.schedulePersist()}}function y_({initialData:e,defaultName:n="",...t}){const r="schema"in t&&t.schema?t.schema:xR({shapes:pF(u_("shapeUtils"in t&&t.shapeUtils?t.shapeUtils:[]))});return new OI({schema:r,initialData:e,props:{defaultName:n}})}function pF(e){return Object.fromEntries(e.map(n=>[n.type,{props:n.props,migrations:n.migrations}]))}function Fb(e){const n=y_(e);return e.snapshot&&n.loadSnapshot(e.snapshot),{store:n,opts:e}}function S_(e){const[n,t]=x.useState(()=>Fb(e));if(!TI(n.opts,e)){const r=Fb(e);return t(r),r.store}return n.store}function fF({persistenceKey:e,sessionId:n,...t}){const[r,o]=x.useState(null),s=S_(t);return x.useEffect(()=>{const i=ze();if(!e){o({id:i,storeWithStatus:{status:"not-synced",store:s}});return}o({id:i,storeWithStatus:{status:"loading"}});const a=c=>{o(u=>(u==null?void 0:u.id)===i?{id:i,storeWithStatus:c}:u)},l=new hF(s,{sessionId:n,persistenceKey:e,onLoad(){a({store:s,status:"synced-local"})},onLoadError(c){a({status:"error",error:c})}});return()=>{o(c=>(c==null?void 0:c.id)===i?null:c),l.close()}},[e,s,n]),(r==null?void 0:r.storeWithStatus)??{status:"loading"}}let v_=!1;if(typeof window<"u"){const e=window.navigator.userAgent,n=!!e.match(/iPad/i)||!!e.match(/iPhone/i),t=!!e.match(/WebKit/i);v_=n&&t&&!e.match(/CriOS/i)}function gF(){const e=F();x.useEffect(()=>{if(!v_)return;function n(t){(t.target instanceof HTMLInputElement&&t.target.type==="text"||t.target instanceof HTMLTextAreaElement)&&e.complete()}return document.addEventListener("focusout",n),()=>document.removeEventListener("focusout",n)},[e])}function mF(){const e=F(),n=mn();x.useEffect(()=>{const t=s=>n.style.setProperty("--tl-zoom",s.toString()),r=kI(t,100),o=new nl("useZoomCss",()=>{e.getCurrentPageShapeIds().size<300?t(e.getZoomLevel()):r(e.getZoomLevel())});return o.attach(),o.execute(),()=>{o.detach()}},[e,n])}const yF=[],SF=[],vF=x.memo(function({store:n,components:t,className:r,user:o,...s}){const[i,a]=ie.useState(null),l=x.useMemo(()=>o??o_(),[o]),c=(t==null?void 0:t.ErrorFallback)===void 0?ZE:t==null?void 0:t.ErrorFallback,u={...s,shapeUtils:s.shapeUtils??yF,tools:s.tools??SF,components:t};return p.jsx("div",{ref:a,draggable:!1,className:fe("tl-container tl-theme__light",r),onPointerDown:It,tabIndex:-1,children:p.jsx(kc,{fallback:c,onError:d=>Av(d,{tags:{origin:"react.tldraw-before-app"}}),children:i&&p.jsx(t3,{container:i,children:p.jsx(I6,{overrides:t,children:n?n instanceof OI?p.jsx(x_,{...u,store:n,user:l}):p.jsx(w_,{...u,store:n,user:l}):p.jsx(wF,{...u,store:n,user:l})})})})})});function wF(e){const{defaultName:n,snapshot:t,initialData:r,shapeUtils:o,persistenceKey:s,sessionId:i,user:a}=e,l=fF({shapeUtils:o,initialData:r,persistenceKey:s,sessionId:i,defaultName:n,snapshot:t});return p.jsx(w_,{...e,store:l,user:a})}const w_=x.memo(function({store:n,user:t,...r}){const o=mn();x.useLayoutEffect(()=>{t.userPreferences.get().isDarkMode&&(o.classList.remove("tl-theme__light"),o.classList.add("tl-theme__dark"))},[o,t]);const{LoadingScreen:s}=Ge();switch(n.status){case"error":throw n.error;case"loading":return s?p.jsx(s,{}):null}return p.jsx(x_,{...r,store:n.store,user:t})});function x_({onMount:e,children:n,store:t,tools:r,shapeUtils:o,user:s,initialState:i,autoFocus:a=!0,inferDarkMode:l}){const{ErrorFallback:c}=Ge(),u=mn(),[d,h]=x.useState(null);x.useLayoutEffect(()=>{const g=new ae({store:t,shapeUtils:o,tools:r,getContainer:()=>u,user:s,initialState:i,inferDarkMode:l});return h(g),()=>{g.dispose()}},[u,o,r,t,s,i,l]);const f=x.useSyncExternalStore(x.useCallback(g=>d?(d.on("crash",g),()=>d.off("crash",g)):()=>{},[d]),()=>(d==null?void 0:d.getCrashingError())??null),{Canvas:y}=Ge();return d?p.jsx(kc,{fallback:c,onError:g=>d.annotateError(g,{origin:"react.tldraw",willCrashApp:!0}),children:f?p.jsx(bF,{crashingError:f}):p.jsx(Vv.Provider,{value:d,children:p.jsx(xF,{autoFocus:a,onMount:e,children:n??(y?p.jsx(y,{}):null)})})}):null}function xF({children:e,onMount:n,autoFocus:t}){return mF(),$N(),MN(),gF(),ON(),jN(t),PF(n),p.jsx(p.Fragment,{children:e})}function bF({crashingError:e}){throw e}function b_({children:e}){return p.jsx("div",{className:"tl-loading",children:e})}function P_({children:e}){return p.jsx("div",{className:"tl-loading",children:e})}function PF(e){const n=F(),t=AN(r=>{const o=e==null?void 0:e(r);return r.emit("mount"),window.tldrawReady=!0,o});ie.useLayoutEffect(()=>{if(n)return t==null?void 0:t(n)},[n,t])}function wi({children:e,className:n="",...t}){return p.jsx("div",{...t,className:`tl-html-container ${n}`,children:e})}function C_(e,n,t={}){const{newPoint:r,handle:o,scaleX:s,scaleY:i}=n,{minWidth:a=1,maxWidth:l=1/0,minHeight:c=1,maxHeight:u=1/0}=t;let d=e.props.w*s,h=e.props.h*i;const f=new b(0,0);if(d>0){if(d<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=d-a;break}case"top":case"bottom":{f.x=(d-a)/2;break}default:f.x=0}d=a}}else if(f.x=d,d=-d,d<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=-d;break}default:f.x=-a}d=a}if(h>0){if(h<c){switch(o){case"top_left":case"top":case"top_right":{f.y=h-c;break}case"right":case"left":{f.y=(h-c)/2;break}default:f.y=0}h=c}}else if(f.y=h,h=-h,h<c){switch(o){case"top_left":case"top":case"top_right":{f.y=-h;break}default:f.y=-c}h=c}const{x:y,y:g}=f.rot(e.rotation).add(r);return{x:y,y:g,props:{w:Math.min(l,d),h:Math.min(u,h)}}}class al extends Lr{constructor(){super(...arguments);m(this,"onResize",(t,r)=>C_(t,r))}getGeometry(t){return new js({width:t.props.w,height:t.props.h,isFilled:!0})}getHandleSnapGeometry(t){return{points:this.getGeometry(t).bounds.cornersAndCenter}}}var ly;let CF=(ly=class extends oe{constructor(){super(...arguments);m(this,"onPointerDown",t=>{this.parent.transition("pointing",t)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(ly,"id","idle"),ly);var cy;let IF=(cy=class extends oe{constructor(){super(...arguments);m(this,"markId","");m(this,"wasFocusedOnEnter",!1);m(this,"onEnter",()=>{this.wasFocusedOnEnter=!this.editor.getIsMenuOpen()});m(this,"onPointerMove",t=>{if(this.editor.inputs.isDragging){const{originPagePoint:r}=this.editor.inputs,o=this.parent.shapeType,s=We();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",{...t,target:"selection",handle:"bottom_right",isCreating:!0,creationCursorOffset:{x:1,y:1},onInteractionEnd:this.parent.id,onCreate:this.parent.onCreate})}});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()})}complete(){const{originPagePoint:t}=this.editor.inputs;if(!this.wasFocusedOnEnter)return;this.editor.mark(this.markId);const r=this.parent.shapeType,o=We();this.editor.mark(this.markId),this.editor.createShapes([{id:o,type:r,x:t.x,y:t.y}]);const s=this.editor.getShape(o),{w:i,h:a}=this.editor.getShapeUtil(s).getDefaultProps(),l=new b(i/2,a/2),c=this.editor.getShapeParentTransform(s);c&&l.rot(-c.rotation()),this.editor.updateShapes([{id:o,type:r,x:s.x-l.x,y:s.y-l.y}]),this.editor.setSelectedShapes([o]),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select.idle")}cancel(){this.parent.transition("idle")}},m(cy,"id","pointing"),cy);class lh extends oe{constructor(){super(...arguments);m(this,"onCreate")}}m(lh,"id","box"),m(lh,"initial","idle"),m(lh,"children",()=>[CF,IF]);function zb(e){const n=F();return K("isCropping",()=>n.getCroppingShapeId()===e,[n,e])}function xf(e){const n=F();return K("isEditing",()=>n.getEditingShapeId()===e,[n,e])}function qr(e){const n=F();return x.useMemo(function(){const o=c=>{if(c.isKilled)return;if(c.button===2){n.dispatch({type:"pointer",target:"selection",handle:e,name:"right_click",...In(c)});return}if(c.button!==0)return;const u=mp(c.currentTarget);function d(){u.removeEventListener("pointerup",d),vu(u,c)}Su(u,c),u.addEventListener("pointerup",d),n.dispatch({name:"pointer_down",type:"pointer",target:"selection",handle:e,...In(c)}),It(c)};let s,i;function a(c){c.isKilled||c.button===0&&(c.clientX===s&&c.clientY===i||(s=c.clientX,i=c.clientY,n.dispatch({name:"pointer_move",type:"pointer",target:"selection",handle:e,...In(c)})))}return{onPointerDown:o,onPointerMove:a,onPointerUp:c=>{c.isKilled||c.button===0&&n.dispatch({name:"pointer_up",type:"pointer",target:"selection",handle:e,...In(c)})}}},[n,e])}const EF=20,_F=8;function i0(e,n=EF){return Math.max(_F,Math.ceil(e/n))}class I_ extends ji{constructor(t){super({...t,isFilled:!1,isClosed:!1});m(this,"_center");m(this,"radius");m(this,"start");m(this,"end");m(this,"measure");m(this,"length");m(this,"angleStart");m(this,"angleEnd");const{center:r,radius:o,sweepFlag:s,largeArcFlag:i,start:a,end:l}=t;if(a.equals(l))throw Error("Arc must have different start and end points.");this.angleStart=b.Angle(r,a),this.angleEnd=b.Angle(r,l),this.measure=AR(this.angleStart,this.angleEnd,s,i),this.length=this.measure*o,this.start=a,this.end=l,this._center=r,this.radius=o}nearestPoint(t){const{_center:r,measure:o,radius:s,angleEnd:i,angleStart:a,start:l,end:c}=this,u=Ly(o,a,i,r.angle(t));if(u<=0)return l;if(u>=1)return c;const d=r.clone().add(t.clone().sub(r).uni().mul(s));let h=1/0,f;for(const y of[l,c,d])t.dist(y)<h&&(f=y,h=t.dist(y));if(!f)throw Error("nearest point not found");return f}hitTestLineSegment(t,r,o){const{_center:s,radius:i,measure:a,angleStart:l,angleEnd:c}=this,u=gf(t,r,s,i);return u===null?!1:u.some(d=>{const h=Ly(a,l,c,s.angle(d));return h>=0&&h<=1})}getVertices(){const{_center:t,measure:r,length:o,radius:s,angleStart:i}=this,a=[];for(let l=0,c=i0(Math.abs(o));l<c+1;l++){const u=l/c*r,d=i+u;a.push(Si(t,s,d))}return a}}class a0 extends ji{constructor(t){super({isClosed:!0,...t});m(this,"_center");m(this,"radius");m(this,"x");m(this,"y");this.config=t;const{x:r=0,y:o=0,radius:s}=t;this.x=r,this.y=o,this._center=new b(s+r,s+o),this.radius=s}getBounds(){return new ne(this.x,this.y,this.radius*2,this.radius*2)}getVertices(){const{_center:t,radius:r}=this,o=De*r,s=[];for(let i=0,a=i0(o);i<a;i++){const l=i/a*De;s.push(Si(t,r,l))}return s}nearestPoint(t){const{_center:r,radius:o}=this;return r.equals(t)?b.AddXY(r,o,0):r.clone().add(t.clone().sub(r).uni().mul(o))}hitTestLineSegment(t,r,o){const{_center:s,radius:i}=this;return gf(t,r,s,i)!==null}}class kF extends Oi{constructor(t){const{start:r,cp1:o,cp2:s,end:i}=t;super({...t,points:[r,i]});m(this,"a");m(this,"b");m(this,"c");m(this,"d");this.a=r,this.b=o,this.c=s,this.d=i}getVertices(){const t=[],{a:r,b:o,c:s,d:i}=this;for(let a=0,l=10;a<=l;a++){const c=a/l;t.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 t}midPoint(){return TF(this,.5)}nearestPoint(t){let r,o=1/0;for(const s of this.segments){const i=s.nearestPoint(t),a=i.dist(t);a<o&&(r=i,o=a)}if(!r)throw Error("nearest point not found");return r}}function TF(e,n){const{a:t,b:r,c:o,d:s}=e;return new b((1-n)*(1-n)*(1-n)*t.x+3*((1-n)*(1-n))*n*r.x+3*(1-n)*(n*n)*o.x+n*n*n*s.x,(1-n)*(1-n)*(1-n)*t.y+3*((1-n)*(1-n))*n*r.y+3*(1-n)*(n*n)*o.y+n*n*n*s.y)}class ch extends ji{constructor(t){super({...t,isClosed:!1,isFilled:!1});m(this,"points");m(this,"_segments");m(this,"_length");const{points:r}=t;this.points=r}get segments(){if(!this._segments){this._segments=[];const{points:t}=this,r=t.length,o=r-2,s=1.25;for(let i=0;i<r-1;i++){const a=i===0?t[0]:t[i-1],l=t[i],c=t[i+1],u=i===o?c:t[i+2],d=l,h=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),y=c;this._segments.push(new kF({start:d,cp1:h,cp2:f,end:y}))}}return this._segments}get length(){return this._length||(this._length=this.segments.reduce((t,r)=>t+r.length,0)),this._length}getVertices(){const t=this.segments.reduce((r,o)=>r.concat(o.vertices),[]);return t.push(this.points[this.points.length-1]),t}nearestPoint(t){let r,o=1/0;for(const s of this.segments){const i=s.nearestPoint(t),a=i.dist(t);a<o&&(r=i,o=a)}if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(t,r,o){return this.segments.some(s=>s.hitTestLineSegment(t,r,o))}}class E_ extends ji{constructor(t){super({...t,isClosed:!0});m(this,"w");m(this,"h");m(this,"_edges");this.config=t;const{width:r,height:o}=t;this.w=r,this.h=o}get edges(){if(!this._edges){const{vertices:t}=this;this._edges=[];for(let r=0,o=t.length;r<o;r++){const s=t[r],i=t[(r+1)%o];this._edges.push(new jc({start:s,end:i}))}}return this._edges}getVertices(){const t=Math.max(1,this.w),r=Math.max(1,this.h),o=t/2,s=r/2,i=Math.pow(o-s,2)/Math.pow(o+s,2),a=$e*(o+s)*(1+3*i/(10+Math.sqrt(4-3*i))),l=i0(a),c=De/l,u=Math.cos(c),d=Math.sin(c);let h=0,f=1,y=0,g=1;const v=Array(l);for(let S=0;S<l;S++)v[S]=new b(o+o*f,s+s*h),y=d*f+u*h,g=u*f-d*h,h=y,f=g;return v}nearestPoint(t){let r,o=1/0;for(const s of this.edges){const i=s.nearestPoint(t),a=i.dist(t);a<o&&(r=i,o=a)}if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(t,r,o){return this.edges.some(s=>s.hitTestLineSegment(t,r,o))}getBounds(){return new ne(0,0,this.w,this.h)}}class $F extends E_{constructor(n){super({...n}),this.config=n}getVertices(){const n=Math.max(1,this.w),t=Math.max(1,this.h),r=n/2,o=t/2,s=10,i=Array(s*2-2);if(t>n)for(let a=0;a<s-1;a++){const l=-$e+$e*a/(s-2),c=$e*a/(s-2);i[a]=new b(r+r*Math.cos(l),r+r*Math.sin(l)),i[a+(s-1)]=new b(r+r*Math.cos(c),t-r+r*Math.sin(c))}else for(let a=0;a<s-1;a++){const l=-Ke+$e*a/(s-2),c=Ke+$e*-a/(s-2);i[a]=new b(n-o+o*Math.cos(l),t-o+o*Math.sin(l)),i[a+(s-1)]=new b(o-o*Math.cos(c),t-o+o*Math.sin(c))}return i}}function Bb(e,n,t,r,o){const s=GR,i=t?YR:0,a=e-i,l=e+i,c=r?0:s,u=o?n:n-s;return a<c?Math.min(1,(c-a)/s):l>u?-Math.min(1,(l-u)/s):0}function l0(e){if(!e.inputs.isDragging||e.inputs.isPanning||!e.getInstanceState().canMoveCamera)return;const{inputs:{currentScreenPoint:{x:n,y:t}}}=e,r=e.getZoomLevel(),o=e.getViewportScreenBounds(),s=o.w<1e3?.612:1,i=o.h<1e3?.612:1,{isCoarsePointer:a,insets:[l,c,u,d]}=e.getInstanceState(),h=Bb(n,o.w,a,d,c),f=Bb(t,o.h,a,l,u);if(h===0&&f===0)return;const y=e.user.getEdgeScrollSpeed()*WR,g=y*h*s/r,v=y*f*i/r,S=e.getCamera();e.setCamera({x:S.x+g,y:S.y+v})}async function MF({shouldReload:e=!0}={}){sessionStorage.clear(),await Promise.all(s0().map(n=>JN(n))),localStorage.clear(),e&&window.location.reload()}typeof window<"u"&&(window.__tldraw__hardReset=MF);function AF(e,n="_blank"){Qv.openWindow(e,n)}var Al=function(e){return e&&e.Math===Math&&e},Rn=Al(typeof globalThis=="object"&&globalThis)||Al(typeof window=="object"&&window)||Al(typeof self=="object"&&self)||Al(typeof en=="object"&&en)||Al(typeof en=="object"&&en)||function(){return this}()||Function("return this")(),c0={},yn=function(e){try{return!!e()}catch{return!0}},jF=yn,Bs=!jF(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),OF=yn,bf=!OF(function(){var e=(function(){}).bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),DF=bf,hd=Function.prototype.call,qo=DF?hd.bind(hd):function(){return hd.apply(hd,arguments)},__={},k_={}.propertyIsEnumerable,T_=Object.getOwnPropertyDescriptor,RF=T_&&!k_.call({1:2},1);__.f=RF?function(n){var t=T_(this,n);return!!t&&t.enumerable}:k_;var $_=function(e,n){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:n}},M_=bf,A_=Function.prototype,Gy=A_.call,LF=M_&&A_.bind.bind(Gy,Gy),$t=M_?LF:function(e){return function(){return Gy.apply(e,arguments)}},j_=$t,NF=j_({}.toString),FF=j_("".slice),ll=function(e){return FF(NF(e),8,-1)},zF=$t,BF=yn,UF=ll,zg=Object,HF=zF("".split),KF=BF(function(){return!zg("z").propertyIsEnumerable(0)})?function(e){return UF(e)==="String"?HF(e,""):zg(e)}:zg,Pf=function(e){return e==null},VF=Pf,WF=TypeError,cl=function(e){if(VF(e))throw new WF("Can't call method on "+e);return e},GF=KF,YF=cl,Cf=function(e){return GF(YF(e))},Bg=typeof document=="object"&&document.all,Sn=typeof Bg>"u"&&Bg!==void 0?function(e){return typeof e=="function"||e===Bg}:function(e){return typeof e=="function"},XF=Sn,Di=function(e){return typeof e=="object"?e!==null:XF(e)},Ug=Rn,qF=Sn,ZF=function(e){return qF(e)?e:void 0},If=function(e,n){return arguments.length<2?ZF(Ug[e]):Ug[e]&&Ug[e][n]},QF=$t,O_=QF({}.isPrototypeOf),JF=typeof navigator<"u"&&String(navigator.userAgent)||"",D_=Rn,Hg=JF,Ub=D_.process,Hb=D_.Deno,Kb=Ub&&Ub.versions||Hb&&Hb.version,Vb=Kb&&Kb.v8,$r,Cp;Vb&&($r=Vb.split("."),Cp=$r[0]>0&&$r[0]<4?1:+($r[0]+$r[1]));!Cp&&Hg&&($r=Hg.match(/Edge\/(\d+)/),(!$r||$r[1]>=74)&&($r=Hg.match(/Chrome\/(\d+)/),$r&&(Cp=+$r[1])));var e4=Cp,Wb=e4,t4=yn,n4=Rn,r4=n4.String,R_=!!Object.getOwnPropertySymbols&&!t4(function(){var e=Symbol("symbol detection");return!r4(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Wb&&Wb<41}),o4=R_,L_=o4&&!Symbol.sham&&typeof Symbol.iterator=="symbol",s4=If,i4=Sn,a4=O_,l4=L_,c4=Object,N_=l4?function(e){return typeof e=="symbol"}:function(e){var n=s4("Symbol");return i4(n)&&a4(n.prototype,c4(e))},u4=String,d4=function(e){try{return u4(e)}catch{return"Object"}},h4=Sn,p4=d4,f4=TypeError,u0=function(e){if(h4(e))return e;throw new f4(p4(e)+" is not a function")},g4=u0,m4=Pf,d0=function(e,n){var t=e[n];return m4(t)?void 0:g4(t)},Kg=qo,Vg=Sn,Wg=Di,y4=TypeError,S4=function(e,n){var t,r;if(n==="string"&&Vg(t=e.toString)&&!Wg(r=Kg(t,e))||Vg(t=e.valueOf)&&!Wg(r=Kg(t,e))||n!=="string"&&Vg(t=e.toString)&&!Wg(r=Kg(t,e)))return r;throw new y4("Can't convert object to primitive value")},F_={exports:{}},Gb=Rn,v4=Object.defineProperty,h0=function(e,n){try{v4(Gb,e,{value:n,configurable:!0,writable:!0})}catch{Gb[e]=n}return n},w4=Rn,x4=h0,Yb="__core-js_shared__",Xb=F_.exports=w4[Yb]||x4(Yb,{});(Xb.versions||(Xb.versions=[])).push({version:"3.36.0",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.36.0/LICENSE",source:"https://github.com/zloirock/core-js"});var p0=F_.exports,qb=p0,f0=function(e,n){return qb[e]||(qb[e]=n||{})},b4=cl,P4=Object,Cu=function(e){return P4(b4(e))},C4=$t,I4=Cu,E4=C4({}.hasOwnProperty),Us=Object.hasOwn||function(n,t){return E4(I4(n),t)},_4=$t,k4=0,T4=Math.random(),$4=_4(1 .toString),z_=function(e){return"Symbol("+(e===void 0?"":e)+")_"+$4(++k4+T4,36)},M4=Rn,A4=f0,Zb=Us,j4=z_,O4=R_,D4=L_,ha=M4.Symbol,Gg=A4("wks"),R4=D4?ha.for||ha:ha&&ha.withoutSetter||j4,Zo=function(e){return Zb(Gg,e)||(Gg[e]=O4&&Zb(ha,e)?ha[e]:R4("Symbol."+e)),Gg[e]},L4=qo,Qb=Di,Jb=N_,N4=d0,F4=S4,z4=Zo,B4=TypeError,U4=z4("toPrimitive"),H4=function(e,n){if(!Qb(e)||Jb(e))return e;var t=N4(e,U4),r;if(t){if(n===void 0&&(n="default"),r=L4(t,e,n),!Qb(r)||Jb(r))return r;throw new B4("Can't convert object to primitive value")}return n===void 0&&(n="number"),F4(e,n)},K4=H4,V4=N_,B_=function(e){var n=K4(e,"string");return V4(n)?n:n+""},W4=Rn,e1=Di,Yy=W4.document,G4=e1(Yy)&&e1(Yy.createElement),U_=function(e){return G4?Yy.createElement(e):{}},Y4=Bs,X4=yn,q4=U_,H_=!Y4&&!X4(function(){return Object.defineProperty(q4("div"),"a",{get:function(){return 7}}).a!==7}),Z4=Bs,Q4=qo,J4=__,ez=$_,tz=Cf,nz=B_,rz=Us,oz=H_,t1=Object.getOwnPropertyDescriptor;c0.f=Z4?t1:function(n,t){if(n=tz(n),t=nz(t),oz)try{return t1(n,t)}catch{}if(rz(n,t))return ez(!Q4(J4.f,n,t),n[t])};var ul={},sz=Bs,iz=yn,K_=sz&&iz(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),az=Di,lz=String,cz=TypeError,Ri=function(e){if(az(e))return e;throw new cz(lz(e)+" is not an object")},uz=Bs,dz=H_,hz=K_,pd=Ri,n1=B_,pz=TypeError,Yg=Object.defineProperty,fz=Object.getOwnPropertyDescriptor,Xg="enumerable",qg="configurable",Zg="writable";ul.f=uz?hz?function(n,t,r){if(pd(n),t=n1(t),pd(r),typeof n=="function"&&t==="prototype"&&"value"in r&&Zg in r&&!r[Zg]){var o=fz(n,t);o&&o[Zg]&&(n[t]=r.value,r={configurable:qg in r?r[qg]:o[qg],enumerable:Xg in r?r[Xg]:o[Xg],writable:!1})}return Yg(n,t,r)}:Yg:function(n,t,r){if(pd(n),t=n1(t),pd(r),dz)try{return Yg(n,t,r)}catch{}if("get"in r||"set"in r)throw new pz("Accessors not supported");return"value"in r&&(n[t]=r.value),n};var gz=Bs,mz=ul,yz=$_,g0=gz?function(e,n,t){return mz.f(e,n,yz(1,t))}:function(e,n,t){return e[n]=t,e},V_={exports:{}},Xy=Bs,Sz=Us,W_=Function.prototype,vz=Xy&&Object.getOwnPropertyDescriptor,m0=Sz(W_,"name"),wz=m0&&(function(){}).name==="something",xz=m0&&(!Xy||Xy&&vz(W_,"name").configurable),bz={EXISTS:m0,PROPER:wz,CONFIGURABLE:xz},Pz=$t,Cz=Sn,qy=p0,Iz=Pz(Function.toString);Cz(qy.inspectSource)||(qy.inspectSource=function(e){return Iz(e)});var G_=qy.inspectSource,Ez=Rn,_z=Sn,r1=Ez.WeakMap,kz=_z(r1)&&/native code/.test(String(r1)),Tz=f0,$z=z_,o1=Tz("keys"),Y_=function(e){return o1[e]||(o1[e]=$z(e))},y0={},Mz=kz,X_=Rn,Az=Di,jz=g0,Qg=Us,Jg=p0,Oz=Y_,Dz=y0,s1="Object already initialized",Zy=X_.TypeError,Rz=X_.WeakMap,Ip,Dc,Ep,Lz=function(e){return Ep(e)?Dc(e):Ip(e,{})},Nz=function(e){return function(n){var t;if(!Az(n)||(t=Dc(n)).type!==e)throw new Zy("Incompatible receiver, "+e+" required");return t}};if(Mz||Jg.state){var Yr=Jg.state||(Jg.state=new Rz);Yr.get=Yr.get,Yr.has=Yr.has,Yr.set=Yr.set,Ip=function(e,n){if(Yr.has(e))throw new Zy(s1);return n.facade=e,Yr.set(e,n),n},Dc=function(e){return Yr.get(e)||{}},Ep=function(e){return Yr.has(e)}}else{var Ji=Oz("state");Dz[Ji]=!0,Ip=function(e,n){if(Qg(e,Ji))throw new Zy(s1);return n.facade=e,jz(e,Ji,n),n},Dc=function(e){return Qg(e,Ji)?e[Ji]:{}},Ep=function(e){return Qg(e,Ji)}}var q_={set:Ip,get:Dc,has:Ep,enforce:Lz,getterFor:Nz},S0=$t,Fz=yn,zz=Sn,fd=Us,Qy=Bs,Bz=bz.CONFIGURABLE,Uz=G_,Z_=q_,Hz=Z_.enforce,Kz=Z_.get,i1=String,uh=Object.defineProperty,Vz=S0("".slice),Wz=S0("".replace),Gz=S0([].join),Yz=Qy&&!Fz(function(){return uh(function(){},"length",{value:8}).length!==8}),Xz=String(String).split("String"),qz=V_.exports=function(e,n,t){Vz(i1(n),0,7)==="Symbol("&&(n="["+Wz(i1(n),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),t&&t.getter&&(n="get "+n),t&&t.setter&&(n="set "+n),(!fd(e,"name")||Bz&&e.name!==n)&&(Qy?uh(e,"name",{value:n,configurable:!0}):e.name=n),Yz&&t&&fd(t,"arity")&&e.length!==t.arity&&uh(e,"length",{value:t.arity});try{t&&fd(t,"constructor")&&t.constructor?Qy&&uh(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var r=Hz(e);return fd(r,"source")||(r.source=Gz(Xz,typeof n=="string"?n:"")),e};Function.prototype.toString=qz(function(){return zz(this)&&Kz(this).source||Uz(this)},"toString");var Zz=V_.exports,Qz=Sn,Jz=ul,e8=Zz,t8=h0,Q_=function(e,n,t,r){r||(r={});var o=r.enumerable,s=r.name!==void 0?r.name:n;if(Qz(t)&&e8(t,s,r),r.global)o?e[n]=t:t8(n,t);else{try{r.unsafe?e[n]&&(o=!0):delete e[n]}catch{}o?e[n]=t:Jz.f(e,n,{value:t,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},J_={},n8=Math.ceil,r8=Math.floor,o8=Math.trunc||function(n){var t=+n;return(t>0?r8:n8)(t)},s8=o8,Li=function(e){var n=+e;return n!==n||n===0?0:s8(n)},i8=Li,a8=Math.max,l8=Math.min,c8=function(e,n){var t=i8(e);return t<0?a8(t+n,0):l8(t,n)},u8=Li,d8=Math.min,ek=function(e){var n=u8(e);return n>0?d8(n,9007199254740991):0},h8=ek,Iu=function(e){return h8(e.length)},p8=Cf,f8=c8,g8=Iu,a1=function(e){return function(n,t,r){var o=p8(n),s=g8(o);if(s===0)return!e&&-1;var i=f8(r,s),a;if(e&&t!==t){for(;s>i;)if(a=o[i++],a!==a)return!0}else for(;s>i;i++)if((e||i in o)&&o[i]===t)return e||i||0;return!e&&-1}},m8={includes:a1(!0),indexOf:a1(!1)},y8=$t,em=Us,S8=Cf,v8=m8.indexOf,w8=y0,l1=y8([].push),tk=function(e,n){var t=S8(e),r=0,o=[],s;for(s in t)!em(w8,s)&&em(t,s)&&l1(o,s);for(;n.length>r;)em(t,s=n[r++])&&(~v8(o,s)||l1(o,s));return o},v0=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],x8=tk,b8=v0,P8=b8.concat("length","prototype");J_.f=Object.getOwnPropertyNames||function(n){return x8(n,P8)};var nk={};nk.f=Object.getOwnPropertySymbols;var C8=If,I8=$t,E8=J_,_8=nk,k8=Ri,T8=I8([].concat),$8=C8("Reflect","ownKeys")||function(n){var t=E8.f(k8(n)),r=_8.f;return r?T8(t,r(n)):t},c1=Us,M8=$8,A8=c0,j8=ul,O8=function(e,n,t){for(var r=M8(n),o=j8.f,s=A8.f,i=0;i<r.length;i++){var a=r[i];!c1(e,a)&&!(t&&c1(t,a))&&o(e,a,s(n,a))}},D8=yn,R8=Sn,L8=/#|\.prototype\./,Eu=function(e,n){var t=F8[N8(e)];return t===B8?!0:t===z8?!1:R8(n)?D8(n):!!n},N8=Eu.normalize=function(e){return String(e).replace(L8,".").toLowerCase()},F8=Eu.data={},z8=Eu.NATIVE="N",B8=Eu.POLYFILL="P",U8=Eu,gd=Rn,H8=c0.f,K8=g0,V8=Q_,W8=h0,G8=O8,Y8=U8,dl=function(e,n){var t=e.target,r=e.global,o=e.stat,s,i,a,l,c,u;if(r?i=gd:o?i=gd[t]||W8(t,{}):i=gd[t]&&gd[t].prototype,i)for(a in n){if(c=n[a],e.dontCallGetSet?(u=H8(i,a),l=u&&u.value):l=i[a],s=Y8(r?a:t+(o?".":"#")+a,e.forced),!s&&l!==void 0){if(typeof c==typeof l)continue;G8(c,l)}(e.sham||l&&l.sham)&&K8(c,"sham",!0),V8(i,a,c,e)}},rk={},X8=tk,q8=v0,Z8=Object.keys||function(n){return X8(n,q8)},Q8=Bs,J8=K_,e7=ul,t7=Ri,n7=Cf,r7=Z8;rk.f=Q8&&!J8?Object.defineProperties:function(n,t){t7(n);for(var r=n7(t),o=r7(t),s=o.length,i=0,a;s>i;)e7.f(n,a=o[i++],r[a]);return n};var o7=If,s7=o7("document","documentElement"),i7=Ri,a7=rk,u1=v0,l7=y0,c7=s7,u7=U_,d7=Y_,d1=">",h1="<",Jy="prototype",eS="script",ok=d7("IE_PROTO"),tm=function(){},sk=function(e){return h1+eS+d1+e+h1+"/"+eS+d1},p1=function(e){e.write(sk("")),e.close();var n=e.parentWindow.Object;return e=null,n},h7=function(){var e=u7("iframe"),n="java"+eS+":",t;return e.style.display="none",c7.appendChild(e),e.src=String(n),t=e.contentWindow.document,t.open(),t.write(sk("document.F=Object")),t.close(),t.F},md,dh=function(){try{md=new ActiveXObject("htmlfile")}catch{}dh=typeof document<"u"?document.domain&&md?p1(md):h7():p1(md);for(var e=u1.length;e--;)delete dh[Jy][u1[e]];return dh()};l7[ok]=!0;var ik=Object.create||function(n,t){var r;return n!==null?(tm[Jy]=i7(n),r=new tm,tm[Jy]=null,r[ok]=n):r=dh(),t===void 0?r:a7.f(r,t)},p7=Zo,f7=ik,g7=ul.f,tS=p7("unscopables"),nS=Array.prototype;nS[tS]===void 0&&g7(nS,tS,{configurable:!0,value:f7(null)});var w0=function(e){nS[tS][e]=!0},m7=dl,y7=Cu,S7=Iu,v7=Li,w7=w0;m7({target:"Array",proto:!0},{at:function(n){var t=y7(this),r=S7(t),o=v7(n),s=o>=0?o:r+o;return s<0||s>=r?void 0:t[s]}});w7("at");var x7=Rn,b7=$t,_u=function(e,n){return b7(x7[e].prototype[n])},P7=_u;P7("Array","at");var C7=ll,ak=Array.isArray||function(n){return C7(n)==="Array"},I7=TypeError,E7=9007199254740991,_7=function(e){if(e>E7)throw I7("Maximum allowed index exceeded");return e},k7=ll,T7=$t,$7=function(e){if(k7(e)==="Function")return T7(e)},f1=$7,M7=u0,A7=bf,j7=f1(f1.bind),O7=function(e,n){return M7(e),n===void 0?e:A7?j7(e,n):function(){return e.apply(n,arguments)}},D7=ak,R7=Iu,L7=_7,N7=O7,lk=function(e,n,t,r,o,s,i,a){for(var l=o,c=0,u=i?N7(i,a):!1,d,h;c<r;)c in t&&(d=u?u(t[c],c,n):t[c],s>0&&D7(d)?(h=R7(d),l=lk(e,n,d,h,l,s-1)-1):(L7(l+1),e[l]=d),l++),c++;return l},ck=lk,F7=Zo,z7=F7("toStringTag"),uk={};uk[z7]="z";var B7=String(uk)==="[object z]",U7=B7,H7=Sn,hh=ll,K7=Zo,V7=K7("toStringTag"),W7=Object,G7=hh(function(){return arguments}())==="Arguments",Y7=function(e,n){try{return e[n]}catch{}},dk=U7?hh:function(e){var n,t,r;return e===void 0?"Undefined":e===null?"Null":typeof(t=Y7(n=W7(e),V7))=="string"?t:G7?hh(n):(r=hh(n))==="Object"&&H7(n.callee)?"Arguments":r},X7=$t,q7=yn,hk=Sn,Z7=dk,Q7=If,J7=G_,pk=function(){},fk=Q7("Reflect","construct"),x0=/^\s*(?:class|function)\b/,eB=X7(x0.exec),tB=!x0.test(pk),jl=function(n){if(!hk(n))return!1;try{return fk(pk,[],n),!0}catch{return!1}},gk=function(n){if(!hk(n))return!1;switch(Z7(n)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return tB||!!eB(x0,J7(n))}catch{return!0}};gk.sham=!0;var nB=!fk||q7(function(){var e;return jl(jl.call)||!jl(Object)||!jl(function(){e=!0})||e})?gk:jl,g1=ak,rB=nB,oB=Di,sB=Zo,iB=sB("species"),m1=Array,aB=function(e){var n;return g1(e)&&(n=e.constructor,rB(n)&&(n===m1||g1(n.prototype))?n=void 0:oB(n)&&(n=n[iB],n===null&&(n=void 0))),n===void 0?m1:n},lB=aB,mk=function(e,n){return new(lB(e))(n===0?0:n)},cB=dl,uB=ck,dB=u0,hB=Cu,pB=Iu,fB=mk;cB({target:"Array",proto:!0},{flatMap:function(n){var t=hB(this),r=pB(t),o;return dB(n),o=fB(t,0),o.length=uB(o,t,t,r,0,1,n,arguments.length>1?arguments[1]:void 0),o}});var gB=w0;gB("flatMap");var mB=_u;mB("Array","flatMap");var yB=dl,SB=ck,vB=Cu,wB=Iu,xB=Li,bB=mk;yB({target:"Array",proto:!0},{flat:function(){var n=arguments.length?arguments[0]:void 0,t=vB(this),r=wB(t),o=bB(t,0);return o.length=SB(o,t,t,r,0,n===void 0?1:xB(n)),o}});var PB=w0;PB("flat");var CB=_u;CB("Array","flat");var IB=dk,EB=String,ku=function(e){if(IB(e)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return EB(e)},_B=dl,kB=$t,TB=cl,$B=Li,MB=ku,AB=yn,jB=kB("".charAt),OB=AB(function(){return"𠮷".at(-2)!=="\uD842"});_B({target:"String",proto:!0,forced:OB},{at:function(n){var t=MB(TB(this)),r=t.length,o=$B(n),s=o>=0?o:r+o;return s<0||s>=r?void 0:jB(t,s)}});var DB=_u;DB("String","at");var RB=Ri,yk=function(){var e=RB(this),n="";return e.hasIndices&&(n+="d"),e.global&&(n+="g"),e.ignoreCase&&(n+="i"),e.multiline&&(n+="m"),e.dotAll&&(n+="s"),e.unicode&&(n+="u"),e.unicodeSets&&(n+="v"),e.sticky&&(n+="y"),n},b0=yn,LB=Rn,P0=LB.RegExp,C0=b0(function(){var e=P0("a","y");return e.lastIndex=2,e.exec("abcd")!==null}),NB=C0||b0(function(){return!P0("a","y").sticky}),FB=C0||b0(function(){var e=P0("^r","gy");return e.lastIndex=2,e.exec("str")!==null}),zB={BROKEN_CARET:FB,MISSED_STICKY:NB,UNSUPPORTED_Y:C0},BB=yn,UB=Rn,HB=UB.RegExp,KB=BB(function(){var e=HB(".","s");return!(e.dotAll&&e.test(`
|
|
65
|
+
`)&&e.flags==="s")}),VB=yn,WB=Rn,GB=WB.RegExp,YB=VB(function(){var e=GB("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),pa=qo,Ef=$t,XB=ku,qB=yk,ZB=zB,QB=f0,JB=ik,e9=q_.get,t9=KB,n9=YB,r9=QB("native-string-replace",String.prototype.replace),_p=RegExp.prototype.exec,rS=_p,o9=Ef("".charAt),s9=Ef("".indexOf),i9=Ef("".replace),nm=Ef("".slice),oS=function(){var e=/a/,n=/b*/g;return pa(_p,e,"a"),pa(_p,n,"a"),e.lastIndex!==0||n.lastIndex!==0}(),Sk=ZB.BROKEN_CARET,sS=/()??/.exec("")[1]!==void 0,a9=oS||sS||Sk||t9||n9;a9&&(rS=function(n){var t=this,r=e9(t),o=XB(n),s=r.raw,i,a,l,c,u,d,h;if(s)return s.lastIndex=t.lastIndex,i=pa(rS,s,o),t.lastIndex=s.lastIndex,i;var f=r.groups,y=Sk&&t.sticky,g=pa(qB,t),v=t.source,S=0,w=o;if(y&&(g=i9(g,"y",""),s9(g,"g")===-1&&(g+="g"),w=nm(o,t.lastIndex),t.lastIndex>0&&(!t.multiline||t.multiline&&o9(o,t.lastIndex-1)!==`
|
|
66
|
+
`)&&(v="(?: "+v+")",w=" "+w,S++),a=new RegExp("^(?:"+v+")",g)),sS&&(a=new RegExp("^"+v+"$(?!\\s)",g)),oS&&(l=t.lastIndex),c=pa(_p,y?a:t,w),y?c?(c.input=nm(c.input,S),c[0]=nm(c[0],S),c.index=t.lastIndex,t.lastIndex+=c[0].length):t.lastIndex=0:oS&&c&&(t.lastIndex=t.global?c.index+c[0].length:l),sS&&c&&c.length>1&&pa(r9,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=d=JB(null),u=0;u<f.length;u++)h=f[u],d[h[0]]=c[h[1]];return c});var I0=rS,l9=dl,y1=I0;l9({target:"RegExp",proto:!0,forced:/./.exec!==y1},{exec:y1});var c9=bf,vk=Function.prototype,S1=vk.apply,v1=vk.call,u9=typeof Reflect=="object"&&Reflect.apply||(c9?v1.bind(S1):function(){return v1.apply(S1,arguments)}),w1=qo,x1=Q_,d9=I0,b1=yn,wk=Zo,h9=g0,p9=wk("species"),rm=RegExp.prototype,f9=function(e,n,t,r){var o=wk(e),s=!b1(function(){var c={};return c[o]=function(){return 7},""[e](c)!==7}),i=s&&!b1(function(){var c=!1,u=/a/;return e==="split"&&(u={},u.constructor={},u.constructor[p9]=function(){return u},u.flags="",u[o]=/./[o]),u.exec=function(){return c=!0,null},u[o](""),!c});if(!s||!i||t){var a=/./[o],l=n(o,""[e],function(c,u,d,h,f){var y=u.exec;return y===d9||y===rm.exec?s&&!f?{done:!0,value:w1(a,u,d,h)}:{done:!0,value:w1(c,d,u,h)}:{done:!1}});x1(String.prototype,e,l[0]),x1(rm,o,l[1])}r&&h9(rm[o],"sham",!0)},E0=$t,g9=Li,m9=ku,y9=cl,S9=E0("".charAt),P1=E0("".charCodeAt),v9=E0("".slice),C1=function(e){return function(n,t){var r=m9(y9(n)),o=g9(t),s=r.length,i,a;return o<0||o>=s?e?"":void 0:(i=P1(r,o),i<55296||i>56319||o+1===s||(a=P1(r,o+1))<56320||a>57343?e?S9(r,o):i:e?v9(r,o,o+2):(i-55296<<10)+(a-56320)+65536)}},w9={codeAt:C1(!1),charAt:C1(!0)},x9=w9.charAt,b9=function(e,n,t){return n+(t?x9(e,n).length:1)},_0=$t,P9=Cu,C9=Math.floor,om=_0("".charAt),I9=_0("".replace),sm=_0("".slice),E9=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,_9=/\$([$&'`]|\d{1,2})/g,xk=function(e,n,t,r,o,s){var i=t+e.length,a=r.length,l=_9;return o!==void 0&&(o=P9(o),l=E9),I9(s,l,function(c,u){var d;switch(om(u,0)){case"$":return"$";case"&":return e;case"`":return sm(n,0,t);case"'":return sm(n,i);case"<":d=o[sm(u,1,-1)];break;default:var h=+u;if(h===0)return c;if(h>a){var f=C9(h/10);return f===0?c:f<=a?r[f-1]===void 0?om(u,1):r[f-1]+om(u,1):c}d=r[h-1]}return d===void 0?"":d})},I1=qo,k9=Ri,T9=Sn,$9=ll,M9=I0,A9=TypeError,j9=function(e,n){var t=e.exec;if(T9(t)){var r=I1(t,e,n);return r!==null&&k9(r),r}if($9(e)==="RegExp")return I1(M9,e,n);throw new A9("RegExp#exec called on incompatible receiver")},O9=u9,E1=qo,_f=$t,D9=f9,R9=yn,L9=Ri,N9=Sn,F9=Pf,z9=Li,B9=ek,ea=ku,U9=cl,H9=b9,K9=d0,V9=xk,W9=j9,G9=Zo,iS=G9("replace"),Y9=Math.max,X9=Math.min,q9=_f([].concat),im=_f([].push),_1=_f("".indexOf),k1=_f("".slice),Z9=function(e){return e===void 0?e:String(e)},Q9=function(){return"a".replace(/./,"$0")==="$0"}(),T1=function(){return/./[iS]?/./[iS]("a","$0")==="":!1}(),J9=!R9(function(){var e=/./;return e.exec=function(){var n=[];return n.groups={a:"7"},n},"".replace(e,"$<a>")!=="7"});D9("replace",function(e,n,t){var r=T1?"$":"$0";return[function(s,i){var a=U9(this),l=F9(s)?void 0:K9(s,iS);return l?E1(l,s,a,i):E1(n,ea(a),s,i)},function(o,s){var i=L9(this),a=ea(o);if(typeof s=="string"&&_1(s,r)===-1&&_1(s,"$<")===-1){var l=t(n,i,a,s);if(l.done)return l.value}var c=N9(s);c||(s=ea(s));var u=i.global,d;u&&(d=i.unicode,i.lastIndex=0);for(var h=[],f;f=W9(i,a),!(f===null||(im(h,f),!u));){var y=ea(f[0]);y===""&&(i.lastIndex=H9(a,B9(i.lastIndex),d))}for(var g="",v=0,S=0;S<h.length;S++){f=h[S];for(var w=ea(f[0]),C=Y9(X9(z9(f.index),a.length),0),I=[],P,E=1;E<f.length;E++)im(I,Z9(f[E]));var _=f.groups;if(c){var k=q9([w],I,C,a);_!==void 0&&im(k,_),P=ea(O9(s,void 0,k))}else P=V9(w,a,C,I,_,s);C>=v&&(g+=k1(a,v,C)+P,v=C+w.length)}return g+k1(a,v)}]},!J9||!Q9||T1);var eU=Di,tU=ll,nU=Zo,rU=nU("match"),oU=function(e){var n;return eU(e)&&((n=e[rU])!==void 0?!!n:tU(e)==="RegExp")},sU=qo,iU=Us,aU=O_,lU=yk,$1=RegExp.prototype,cU=function(e){var n=e.flags;return n===void 0&&!("flags"in $1)&&!iU(e,"flags")&&aU($1,e)?sU(lU,e):n},uU=dl,dU=qo,k0=$t,M1=cl,hU=Sn,pU=Pf,fU=oU,Ol=ku,gU=d0,mU=cU,yU=xk,SU=Zo,vU=SU("replace"),wU=TypeError,am=k0("".indexOf);k0("".replace);var A1=k0("".slice),xU=Math.max;uU({target:"String",proto:!0},{replaceAll:function(n,t){var r=M1(this),o,s,i,a,l,c,u,d,h,f=0,y=0,g="";if(!pU(n)){if(o=fU(n),o&&(s=Ol(M1(mU(n))),!~am(s,"g")))throw new wU("`.replaceAll` does not allow non-global regexes");if(i=gU(n,vU),i)return dU(i,n,r,t)}for(a=Ol(r),l=Ol(n),c=hU(t),c||(t=Ol(t)),u=l.length,d=xU(1,u),f=am(a,l);f!==-1;)h=c?Ol(t(l,f,a)):yU(l,a,f,[],void 0,t),g+=A1(a,y,f)+h,y=f+u,f=f+d>a.length?-1:am(a,l,f+d);return y<a.length&&(g+=A1(a,y)),g}});var bU=_u;bU("String","replaceAll");function PU(e){return e.getSelectedShapeIds().map(r=>e.getShape(r)).filter(r=>!(!r||e.isShapeOfType(r,"arrow")&&r.props.start.type==="binding"||e.isShapeOfType(r,"arrow")&&r.props.end.type==="binding"))}const bk=()=>{const e=F();return K("threeStackableItems",()=>PU(e).length>2,[e])},Pk=()=>{const e=F();return K("allow group",()=>{const n=e.getSelectedShapes();if(n.length<2)return!1;for(const t of n)if(e.isShapeOfType(t,"arrow")){const{start:r,end:o}=t.props;if(r.type==="binding"&&!n.some(s=>s.id===r.boundShapeId)||o.type==="binding"&&!n.some(s=>s.id===o.boundShapeId))return!1}return!0},[e])},Ck=()=>{const e=F();return K("allowUngroup",()=>e.getSelectedShapeIds().some(n=>{var t;return((t=e.getShape(n))==null?void 0:t.type)==="group"}),[e])},CU=typeof window<"u"&&"navigator"in window&&!!navigator.clipboard&&!!navigator.clipboard.read;function IU(e,n){const t=F();return K("selectedShapes",()=>{const r=t.getSelectedShapes().length;return e===void 0?n===void 0?r:r<=n:n===void 0?r>=e:r>=e&&r<=n},[t,e,n])}function an(e,n){const t=F();return K("selectedShapes",()=>{const r=t.getSelectedShapes().filter(o=>!t.isShapeOrAncestorLocked(o)).length;return e===void 0?n===void 0?r:r<=n:n===void 0?r>=e:r>=e&&r<=n},[t])}function EU(){const e=F();return K("showAutoSizeToggle",()=>{const n=e.getSelectedShapes();return n.length===1&&e.isShapeOfType(n[0],"text")&&n[0].props.autoSize===!1},[e])}function Ik(){const e=F();return K("hasLinkShapeSelected",()=>{const n=e.getOnlySelectedShape();return!!(n&&n.type!=="embed"&&"url"in n.props)},[e])}function _U(){const e=F();return K("onlyFlippableShape",()=>{const n=e.getSelectedShapes();return n.length===1&&n.every(t=>e.isShapeOfType(t,"group")||e.isShapeOfType(t,"arrow")||e.isShapeOfType(t,"line")||e.isShapeOfType(t,"draw"))},[e])}function Ek(){const e=F();return K("useCanRedo",()=>e.getCanRedo(),[e])}function _k(){const e=F();return K("useCanUndo",()=>e.getCanUndo(),[e])}function kU({children:e}){const n=F();return K("shouldDisplayHandles",()=>n.isInAny("select.idle","select.pointing_handle"),[n])?p.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:e}):null}function TU({shapeId:e}){const n=F(),{ShapeIndicator:t}=Ge(),r=K("show hovered",()=>n.isIn("select.editing_shape")?n.getHoveredShapeId()!==n.getEditingShapeId():n.isInAny("select.idle"),[n]);return!t||!r?null:p.jsx(t,{className:"tl-user-indicator__hovered",shapeId:e})}const{PI:$U}=Math,ja=$U+1e-4;function kk(e,n={}){const{size:t=16,smoothing:r=.5}=n;if(e.length===0||t<=0)return{left:[],right:[]};const o=e[0],s=e[e.length-1],i=s.runningLength,a=Math.pow(t*r,2),l=[],c=[];let u=e[0].vector,d=e[0].point,h=d,f=d,y=h,g=!1,v;for(let S=0;S<e.length;S++){v=e[S];const{point:w,vector:C}=e[S],I=v.vector.dpr(u),P=(S<e.length-1?e[S+1]:e[S]).vector,E=S<e.length-1?P.dpr(v.vector):1,_=I<0&&!g,k=E!==null&&E<.2;if(_||k){if(E>-.62&&i-v.runningLength>v.radius){const T=u.clone().mul(v.radius);u.clone().cpr(P)<0?(f=b.Add(w,T),y=b.Sub(w,T)):(f=b.Sub(w,T),y=b.Add(w,T)),l.push(f),c.push(y)}else{const T=u.clone().mul(v.radius).per(),R=b.Sub(v.input,T);for(let O=1/13,U=0;U<1;U+=O)f=b.RotWith(R,v.input,ja*U),l.push(f),y=b.RotWith(R,v.input,ja+ja*-U),c.push(y)}d=f,h=y,k&&(g=!0);continue}if(g=!1,v===o||v===s){const T=b.Per(C).mul(v.radius);l.push(b.Sub(w,T)),c.push(b.Add(w,T));continue}const M=b.Lrp(P,C,E).per().mul(v.radius);f=b.Sub(w,M),(S<=1||b.Dist2(d,f)>a)&&(l.push(f),d=f),y=b.Add(w,M),(S<=1||b.Dist2(h,y)>a)&&(c.push(y),h=y),u=C}return{left:l,right:c}}function Tu(e,n={}){const{size:t=16,start:r={},end:o={},last:s=!1}=n,{cap:i=!0}=r,{cap:a=!0}=o;if(e.length===0||t<=0)return[];const l=e[0],c=e[e.length-1],u=c.runningLength,d=r.taper===!1?0:r.taper===!0?Math.max(t,u):r.taper,h=o.taper===!1?0:o.taper===!0?Math.max(t,u):o.taper,{left:f,right:y}=kk(e,n),g=l.point,v=e.length>1?e[e.length-1].point:b.AddXY(l.point,1,1);if(e.length===1&&(!(d||h)||s)){const I=b.Add(g,b.Sub(g,v).uni().per().mul(-l.radius)),P=[];for(let E=1/13,_=E;_<=1;_+=E)P.push(b.RotWith(I,g,ja*2*_));return P}const S=[];if(!(d||h&&e.length===1))if(i)for(let I=1/8,P=I;P<=1;P+=I){const E=b.RotWith(y[0],g,ja*P);S.push(E)}else{const I=b.Sub(f[0],y[0]),P=b.Mul(I,.5),E=b.Mul(I,.51);S.push(b.Sub(g,P),b.Sub(g,E),b.Add(g,E),b.Add(g,P))}const w=[],C=c.vector.clone().per().neg();if(h||d&&e.length===1)w.push(v);else if(a){const I=b.Add(v,b.Mul(C,c.radius));for(let P=1/29,E=P;E<1;E+=P)w.push(b.RotWith(I,v,ja*3*E))}else w.push(b.Add(v,b.Mul(C,c.radius)),b.Add(v,b.Mul(C,c.radius*.99)),b.Sub(v,b.Mul(C,c.radius*.99)),b.Sub(v,b.Mul(C,c.radius)));return f.concat(w,y.reverse(),S)}const MU=.025,AU=.01;function jr(e,n={}){var v;const{streamline:t=.5,size:r=16,simulatePressure:o=!1}=n;if(e.length===0)return[];const s=.15+(1-t)*.85;let i=e.map(b.From),a=0;if(!o){let S=i[0];for(;S&&!(S.z>=MU);)i.shift(),S=i[0]}if(!o){let S=i[i.length-1];for(;S&&!(S.z>=AU);)i.pop(),S=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.Dist(l,i[0])>r/3);)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.Dist(l,c)>r/3);)i.pop(),l=i[i.length-1],a++;i.push(c);const u=n.last||!n.simulatePressure||i.length>1&&b.Dist(i[i.length-1],i[i.length-2])<r||a>0;if(i.length===2&&n.simulatePressure){const S=i[1];i=i.slice(0,-1);for(let w=1;w<5;w++){const C=b.Lrp(i[0],S,w/4);C.z=(i[0].z+(S.z-i[0].z))*w/4,i.push(C)}}const d=[{point:i[0],input:i[0],pressure:o?.5:i[0].z,vector:new b(1,1),distance:0,runningLength:0,radius:1}];let h=0,f=d[0],y,g;u&&t>0&&i.push(i[i.length-1].clone());for(let S=1,w=i.length;S<w;S++)y=!s||n.last&&S===w-1?i[S].clone():i[S].clone().lrp(f.point,1-s),!f.point.equals(y)&&(g=b.Dist(y,f.point),h+=g,!(S<4&&h<r)&&(f={input:i[S],point:y,pressure:o?.5:i[S].z,vector:b.Sub(f.point,y).uni(),distance:g,runningLength:h,radius:1},d.push(f)));if((v=d[1])!=null&&v.vector&&(d[0].vector=d[1].vector.clone()),h<1){const S=Math.max(.5,...d.map(w=>w.pressure));d.forEach(w=>w.pressure=S)}return d}const{min:ss}=Math,lm=.275;function hl(e,n){const{size:t=16,thinning:r=.5,simulatePressure:o=!0,easing:s=v=>v,start:i={},end:a={}}=n,{easing:l=tn.easeOutQuad}=i,{easing:c=tn.easeOutCubic}=a,u=e[e.length-1].runningLength;let d,h=e[0].pressure,f;if(!o&&u<t){const v=e.reduce((S,w)=>Math.max(S,w.pressure),.5);return e.forEach(S=>{S.pressure=v,S.radius=t*s(.5-r*(.5-S.pressure))}),e}else{let v;for(let S=0,w=e.length;S<w&&(f=e[S],!(f.runningLength>t*5));S++){const C=ss(1,f.distance/t);if(o){const I=ss(1,1-C);v=ss(1,h+(I-h)*(C*lm))}else v=ss(1,h+(f.pressure-h)*.5);h=h+(v-h)*.5}for(let S=0;S<e.length;S++){if(f=e[S],r){let{pressure:w}=f;const C=ss(1,f.distance/t);if(o){const I=ss(1,1-C);w=ss(1,h+(I-h)*(C*lm))}else w=ss(1,h+(w-h)*(C*lm));f.radius=t*s(.5-r*(.5-w)),h=w}else f.radius=t/2;d===void 0&&(d=f.radius)}}const y=i.taper===!1?0:i.taper===!0?Math.max(t,u):i.taper,g=a.taper===!1?0:a.taper===!0?Math.max(t,u):a.taper;if(y||g)for(let v=0;v<e.length;v++){f=e[v];const{runningLength:S}=f,w=S<y?l(S/y):1,C=u-S<g?c((u-S)/g):1;f.radius=Math.max(.01,f.radius*Math.min(w,C))}return e}function jU(e,n={}){return Tu(hl(jr(e,n),n),n)}function j1({scribble:e,zoom:n,color:t,opacity:r,className:o}){if(!e.points.length)return null;const s=jU(e.points,{size:e.size/n,start:{taper:e.taper,easing:tn.linear},last:e.state==="stopping",simulatePressure:!1,streamline:.32});let i;if(s.length<4){const a=e.size/n/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=bu(s);return p.jsx("svg",{className:o&&fe("tl-overlays__item",o),children:p.jsx("path",{className:"tl-scribble",d:i,fill:t??`var(--color-${e.color})`,opacity:r??e.opacity})})}const OU=({bounds:e,rotation:n})=>{const t=F();return K("should display",()=>t.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_shape","select.pointing_selection","text.resizing"),[t])?p.jsx(GE,{bounds:e,rotation:n}):null};function fo(){const e=F();return K("isReadonlyMode",()=>e.getInstanceState().isReadonly,[e])}function DU({size:e,width:n,height:t,hideAlternateHandles:r}){const o=j(e/3),s=o/2;return p.jsxs("svg",{className:"tl-overlays__item",children:[p.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
67
|
+
${j(0-s)},${j(e)}
|
|
68
|
+
${j(0-s)},${j(0-s)}
|
|
69
|
+
${j(e)},${j(0-s)}`,strokeWidth:o,"data-testid":"selection.crop.top_left","aria-label":"top_left handle"}),p.jsx("line",{className:fe("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(n/2-e),y1:j(0-s),x2:j(n/2+e),y2:j(0-s),strokeWidth:o,"data-testid":"selection.crop.top","aria-label":"top handle"}),p.jsx("polyline",{className:fe("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
70
|
+
${j(n-e)},${j(0-s)}
|
|
71
|
+
${j(n+s)},${j(0-s)}
|
|
72
|
+
${j(n+s)},${j(e)}`,strokeWidth:o,"data-testid":"selection.crop.top_right","aria-label":"top_right handle"}),p.jsx("line",{className:fe("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(n+s),y1:j(t/2-e),x2:j(n+s),y2:j(t/2+e),strokeWidth:o,"data-testid":"selection.crop.right","aria-label":"right handle"}),p.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
73
|
+
${j(n+s)},${j(t-e)}
|
|
74
|
+
${j(n+s)},${j(t+s)}
|
|
75
|
+
${j(n-e)},${j(t+s)}`,strokeWidth:o,"data-testid":"selection.crop.bottom_right","aria-label":"bottom_right handle"}),p.jsx("line",{className:fe("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(n/2-e),y1:j(t+s),x2:j(n/2+e),y2:j(t+s),strokeWidth:o,"data-testid":"selection.crop.bottom","aria-label":"bottom handle"}),p.jsx("polyline",{className:fe("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
76
|
+
${j(0+e)},${j(t+s)}
|
|
77
|
+
${j(0-s)},${j(t+s)}
|
|
78
|
+
${j(0-s)},${j(t-e)}`,strokeWidth:o,"data-testid":"selection.crop.bottom_left","aria-label":"bottom_left handle"}),p.jsx("line",{className:fe("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(0-s),y1:j(t/2-e),x2:j(0-s),y2:j(t/2+e),strokeWidth:o,"data-testid":"selection.crop.left","aria-label":"left handle"})]})}const RU=Tt(function({bounds:n,rotation:t}){const r=F(),o=x.useRef(null),s=fo(),i=qr("top"),a=qr("right"),l=qr("bottom"),c=qr("left"),u=qr("top_left"),d=qr("top_right"),h=qr("bottom_right"),f=qr("bottom_left"),y=!r.getIsMenuOpen()&&r.getInstanceState().cursor.type==="default",g=r.getInstanceState().isCoarsePointer,v=r.getOnlySelectedShape(),S=v&&r.isShapeOrAncestorLocked(v),w=v?r.getShapeUtil(v).expandSelectionOutlinePx(v):0;if(ol(o,n==null?void 0:n.x,n==null?void 0:n.y,1,r.getSelectionRotation(),{x:-w,y:-w}),!n)return null;n=n.clone().expandBy(w).zeroFix();const C=r.getZoomLevel(),I=r.getInstanceState().isChangingStyle,P=n.width,E=n.height,_=8/C,k=P<_*2,M=E<_*2,T=P<_*4,R=E<_*4,O=P<_*5,U=E<_*5,N=g?1.75:1,L=6/C*N,G=(T?L/2:L)*(N*.75),X=(R?L/2:L)*(N*.75),H=(v?!r.getShapeUtil(v).hideSelectionBoundsFg(v):!0)&&!I;let B=H&&r.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_canvas","select.pointing_selection","select.pointing_shape","select.crop.idle","select.crop.pointing_crop","select.pointing_resize_handle","select.pointing_crop_handle")||H&&r.isIn("select.resizing")&&v&&r.isShapeOfType(v,"text");v&&B&&r.environment.isFirefox&&r.isShapeOfType(v,"embed")&&(B=!1);const W=r.isInAny("select.pointing_crop_handle","select.crop.idle","select.crop.pointing_crop")&&!I&&!s,Y=r.isInAny("select.idle","select.pointing_selection","select.pointing_shape","select.crop.idle")&&!I&&!s,J=!g&&!(k||M)&&(Y||W)&&(v?!r.getShapeUtil(v).hideRotateHandle(v):!0)&&!S,ke=g&&(!T||!R)&&(Y||W)&&(v?!r.getShapeUtil(v).hideRotateHandle(v):!0)&&!S,ve=Y&&(v?r.getShapeUtil(v).canResize(v)&&!r.getShapeUtil(v).hideResizeHandles(v):!0)&&!W&&!S,pe=k||M,me=k&&M,Xe=O||U,Ae=ve||W,Ue=!J,yt=!Y||!ke,St=!Y||!Ae,Le=!Y||!Ae||pe,br=!Y||!Ae||pe,Nn=!Y||!Ae||me&&!W;let xt=!0,pt=!0;if(W)xt=Xe,pt=Xe;else if(ve){xt=pe||me||g;const wl=g&&v&&v.type==="text";pt=xt&&!wl}const At=Math.min(24/C,E-X*3),vl=Y&&g&&v&&r.isShapeOfType(v,"text")&&At*C>=4;return p.jsx("svg",{className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:p.jsxs("g",{ref:o,children:[B&&p.jsx("rect",{className:"tl-selection__fg__outline",width:j(P),height:j(E)}),p.jsx(yd,{"data-testid":"selection.rotate.top-left",cx:0,cy:0,targetSize:L,corner:"top_left_rotate",cursor:y?Bn("nwse-rotate",t):void 0,isHidden:Ue}),p.jsx(yd,{"data-testid":"selection.rotate.top-right",cx:P+L*3,cy:0,targetSize:L,corner:"top_right_rotate",cursor:y?Bn("nesw-rotate",t):void 0,isHidden:Ue}),p.jsx(yd,{"data-testid":"selection.rotate.bottom-left",cx:0,cy:E+L*3,targetSize:L,corner:"bottom_left_rotate",cursor:y?Bn("swne-rotate",t):void 0,isHidden:Ue}),p.jsx(yd,{"data-testid":"selection.rotate.bottom-right",cx:P+L*3,cy:E+L*3,targetSize:L,corner:"bottom_right_rotate",cursor:y?Bn("senw-rotate",t):void 0,isHidden:Ue}),p.jsx(NU,{"data-testid":"selection.rotate.mobile",cx:T?-L*1.5:P/2,cy:T?E/2:-L*1.5,size:_,isHidden:yt}),p.jsx("rect",{className:fe("tl-transparent",{"tl-hidden":xt}),"data-testid":"selection.resize.top","aria-label":"top target",pointerEvents:"all",x:0,y:j(0-(R?X*2:X)),width:j(P),height:j(Math.max(1,X*2)),style:y?{cursor:Bn("ns-resize",t)}:void 0,...i}),p.jsx("rect",{className:fe("tl-transparent",{"tl-hidden":pt}),"data-testid":"selection.resize.right","aria-label":"right target",pointerEvents:"all",x:j(P-(T?0:G)),y:0,height:j(E),width:j(Math.max(1,G*2)),style:y?{cursor:Bn("ew-resize",t)}:void 0,...a}),p.jsx("rect",{className:fe("tl-transparent",{"tl-hidden":xt}),"data-testid":"selection.resize.bottom","aria-label":"bottom target",pointerEvents:"all",x:0,y:j(E-(R?0:X)),width:j(P),height:j(Math.max(1,X*2)),style:y?{cursor:Bn("ns-resize",t)}:void 0,...l}),p.jsx("rect",{className:fe("tl-transparent",{"tl-hidden":pt}),"data-testid":"selection.resize.left","aria-label":"left target",pointerEvents:"all",x:j(0-(T?G*2:G)),y:0,height:j(E),width:j(Math.max(1,G*2)),style:y?{cursor:Bn("ew-resize",t)}:void 0,...c}),p.jsx("rect",{className:fe("tl-transparent",{"tl-hidden":St}),"data-testid":"selection.target.top-left","aria-label":"top-left target",pointerEvents:"all",x:j(0-(T?G*2:G*1.5)),y:j(0-(R?X*2:X*1.5)),width:j(G*3),height:j(X*3),style:y?{cursor:Bn("nwse-resize",t)}:void 0,...u}),p.jsx("rect",{className:fe("tl-transparent",{"tl-hidden":Le}),"data-testid":"selection.target.top-right","aria-label":"top-right target",pointerEvents:"all",x:j(P-(T?0:G*1.5)),y:j(0-(R?X*2:X*1.5)),width:j(G*3),height:j(X*3),style:y?{cursor:Bn("nesw-resize",t)}:void 0,...d}),p.jsx("rect",{className:fe("tl-transparent",{"tl-hidden":Nn}),"data-testid":"selection.target.bottom-right","aria-label":"bottom-right target",pointerEvents:"all",x:j(P-(T?G:G*1.5)),y:j(E-(R?X:X*1.5)),width:j(G*3),height:j(X*3),style:y?{cursor:Bn("nwse-resize",t)}:void 0,...h}),p.jsx("rect",{className:fe("tl-transparent",{"tl-hidden":br}),"data-testid":"selection.target.bottom-left","aria-label":"bottom-left target",pointerEvents:"all",x:j(0-(T?G*3:G*1.5)),y:j(E-(R?0:X*1.5)),width:j(G*3),height:j(X*3),style:y?{cursor:Bn("nesw-resize",t)}:void 0,...f}),ve&&p.jsxs(p.Fragment,{children:[p.jsx("rect",{"data-testid":"selection.resize.top-left",className:fe("tl-corner-handle",{"tl-hidden":St}),"aria-label":"top_left handle",x:j(0-_/2),y:j(0-_/2),width:j(_),height:j(_)}),p.jsx("rect",{"data-testid":"selection.resize.top-right",className:fe("tl-corner-handle",{"tl-hidden":Le}),"aria-label":"top_right handle",x:j(P-_/2),y:j(0-_/2),width:j(_),height:j(_)}),p.jsx("rect",{"data-testid":"selection.resize.bottom-right",className:fe("tl-corner-handle",{"tl-hidden":Nn}),"aria-label":"bottom_right handle",x:j(P-_/2),y:j(E-_/2),width:j(_),height:j(_)}),p.jsx("rect",{"data-testid":"selection.resize.bottom-left",className:fe("tl-corner-handle",{"tl-hidden":br}),"aria-label":"bottom_left handle",x:j(0-_/2),y:j(E-_/2),width:j(_),height:j(_)})]}),vl&&p.jsxs(p.Fragment,{children:[p.jsx("rect",{"data-testid":"selection.text-resize.left.handle",className:"tl-text-handle","aria-label":"bottom_left handle",x:j(0-_/4),y:j(E/2-At/2),rx:_/4,width:j(_/2),height:j(At)}),p.jsx("rect",{"data-testid":"selection.text-resize.right.handle",className:"tl-text-handle","aria-label":"bottom_left handle",rx:_/4,x:j(P-_/4),y:j(E/2-At/2),width:j(_/2),height:j(At)})]}),W&&p.jsx(DU,{size:_,width:P,height:E,hideAlternateHandles:Xe})]})})}),yd=function({cx:n,cy:t,targetSize:r,corner:o,cursor:s,isHidden:i,"data-testid":a}){const l=qr(o);return p.jsx("rect",{className:fe("tl-transparent","tl-rotate-corner",{"tl-hidden":i}),"data-testid":a,"aria-label":`${o} target`,pointerEvents:"all",x:j(n-r*3),y:j(t-r*3),width:j(Math.max(1,r*3)),height:j(Math.max(1,r*3)),cursor:s,...l})},LU=Math.sqrt(Math.PI),NU=function({cx:n,cy:t,size:r,isHidden:o,"data-testid":s}){const i=qr("mobile_rotate"),a=F(),l=K("zoom level",()=>a.getZoomLevel(),[a]),c=Math.max(14*(1/l),20/Math.max(1,l));return p.jsxs("g",{children:[p.jsx("circle",{"data-testid":s,pointerEvents:"all",className:fe("tl-transparent","tl-mobile-rotate__bg",{"tl-hidden":o}),cx:n,cy:t,r:c,...i}),p.jsx("circle",{className:fe("tl-mobile-rotate__fg",{"tl-hidden":o}),cx:n,cy:t,r:r/LU})]})},Ut={lineHeight:1.35,fontWeight:"normal",fontVariant:"normal",fontStyle:"normal",padding:"0px"},Pt={s:2,m:3.5,l:5,xl:10},ms={s:18,m:24,l:36,xl:44},Ka={s:18,m:22,l:26,xl:32},hs={s:18,m:20,l:24,xl:28},Lo={draw:"var(--tl-font-draw)",sans:"var(--tl-font-sans)",serif:"var(--tl-font-serif)",mono:"var(--tl-font-mono)"},FU=20,zU=4.25;/*!
|
|
79
|
+
* canvas-size
|
|
80
|
+
* v1.2.6
|
|
81
|
+
* https://github.com/jhildenbiddle/canvas-size
|
|
82
|
+
* (c) 2015-2023 John Hildenbiddle <http://hildenbiddle.com>
|
|
83
|
+
* MIT license
|
|
84
|
+
*/function BU(e,n){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var r,o,s,i,a=[],l=!0,c=!1;try{if(s=(t=t.call(e)).next,n===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(r=s.call(t)).done)&&(a.push(r.value),a.length!==n);l=!0);}catch(u){c=!0,o=u}finally{try{if(!l&&t.return!=null&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return a}}function O1(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),t.push.apply(t,r)}return t}function Un(e){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?O1(Object(t),!0).forEach(function(r){UU(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O1(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function UU(e,n,t){return n=ZU(n),n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function HU(e,n){if(e==null)return{};var t={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(n.indexOf(o)>=0)&&(t[o]=e[o]);return t}function KU(e,n){if(e==null)return{};var t=HU(e,n),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(t[r]=e[r])}return t}function D1(e,n){return WU(e)||BU(e,n)||Tk(e,n)||XU()}function Sd(e){return VU(e)||GU(e)||Tk(e)||YU()}function VU(e){if(Array.isArray(e))return aS(e)}function WU(e){if(Array.isArray(e))return e}function GU(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Tk(e,n){if(e){if(typeof e=="string")return aS(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return aS(e,n)}}function aS(e,n){(n==null||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function YU(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
85
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function XU(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
86
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qU(e,n){if(typeof e!="object"||e===null)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var r=t.call(e,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function ZU(e){var n=qU(e,"string");return typeof n=="symbol"?n:String(n)}function cc(e){var n=e.sizes.shift(),t=Math.max(Math.ceil(n[0]),1),r=Math.max(Math.ceil(n[1]),1),o=[t-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(t,r)):(a=document.createElement("canvas"),a.width=1,a.height=1,l=document.createElement("canvas"),l.width=t,l.height=r);var c=a.getContext("2d"),u=l.getContext("2d");u&&(u.fillRect.apply(u,o),c.drawImage(l,t-1,r-1,1,1,0,0,1,1));var d=c&&c.getImageData(0,0,1,1).data[3]!==0,h=Date.now()-s;return[a,l].forEach(function(f){f.height=0,f.width=0}),i?(postMessage({width:t,height:r,benchmark:h,isTestPass:d}),!d&&e.sizes.length&&cc(e)):d?e.onSuccess(t,r,h):(e.onError(t,r,h),e.sizes.length&&cc(e)),d}var cm={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]},QU=["onError","onSuccess"],fa={max:null,min:1,sizes:[],step:1024,usePromise:!1,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},Dl={};function um(e){var n=e.width===e.height,t=e.height===1,r=e.width===1,o=[];if(!e.width||!e.height)e.sizes.forEach(function(u){var d=n||t?u:1,h=n||r?u:1;o.push([d,h])});else for(var s=e.min||fa.min,i=e.step||fa.step,a=Math.max(e.width,e.height);a>=s;){var l=n||t?a:1,c=n||r?a:1;o.push([l,c]),a-=i}return o}function vd(e){var n=window&&"HTMLCanvasElement"in window,t=window&&"OffscreenCanvas"in window,r=Date.now(),o=e.onError,s=e.onSuccess,i=KU(e,QU),a=null;if(!n)return!1;if(e.useWorker&&t){var l=`
|
|
87
|
+
var canvasTest = `.concat(cc.toString(),`;
|
|
88
|
+
onmessage = function(e) {
|
|
89
|
+
canvasTest(e.data);
|
|
90
|
+
};
|
|
91
|
+
`),c=new Blob([l],{type:"application/javascript"}),u=URL.createObjectURL(c);a=new Worker(u),URL.revokeObjectURL(u),a.onmessage=function(d){var h=d.data,f=h.width,y=h.height,g=h.benchmark,v=h.isTestPass;v?(Dl[r].onSuccess(f,y,g),delete Dl[r]):Dl[r].onError(f,y,g)}}if(e.usePromise)return new Promise(function(d,h){var f=Un(Un({},e),{},{onError:function(S,w,C){var I;if(e.sizes.length===0)I=!0;else{var P=e.sizes.slice(-1),E=D1(P,1),_=D1(E[0],2),k=_[0],M=_[1];I=S===k&&w===M}o(S,w,C),I&&h({width:S,height:w,benchmark:C})},onSuccess:function(S,w,C){s(S,w,C),d({width:S,height:w,benchmark:C})}});if(a){var y=f.onError,g=f.onSuccess;Dl[r]={onError:y,onSuccess:g},a.postMessage(i)}else cc(f)});if(a)Dl[r]={onError:o,onSuccess:s},a.postMessage(i);else return cc(e)}var dm={maxArea:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=um({width:n.max,height:n.max,min:n.min,step:n.step,sizes:Sd(cm.area)}),r=Un(Un(Un({},fa),n),{},{sizes:t});return vd(r)},maxHeight:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=um({width:1,height:n.max,min:n.min,step:n.step,sizes:Sd(cm.height)}),r=Un(Un(Un({},fa),n),{},{sizes:t});return vd(r)},maxWidth:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=um({width:n.max,height:1,min:n.min,step:n.step,sizes:Sd(cm.width)}),r=Un(Un(Un({},fa),n),{},{sizes:t});return vd(r)},test:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Un(Un({},fa),n);return t.sizes=Sd(t.sizes),t.width&&t.height&&(t.sizes=[[t.width,t.height]]),vd(t)}};let hm=null;function JU(){return hm||(hm=eH()),hm}async function eH(){const e=await dm.maxWidth({usePromise:!0}),n=await dm.maxHeight({usePromise:!0}),t=await dm.maxArea({usePromise:!0});return{maxWidth:e.width,maxHeight:n.height,maxArea:t.width*t.height}}const R1=8192,tH=4096*4096;async function $k(e,n){if(e<=R1&&n<=R1&&e*n<=tH)return[e,n];const{maxWidth:t,maxHeight:r,maxArea:o}=await JU(),s=e/n;if(e>t&&(e=t,n=e/s),n>r&&(n=r,e=n*s),e*n>o){const i=Math.sqrt(o/(e*n));e*=i,n*=i}return[e,n]}/*!
|
|
92
|
+
* MIT License
|
|
93
|
+
* Modified code originally from <https://github.com/qzb/is-animated>
|
|
94
|
+
* Copyright (c) 2016 Józef Sokołowski <j.k.sokolowski@gmail.com>
|
|
95
|
+
*/function L1(e,n){let t=0;for(;e[n+t];)t+=e[n+t]+1;return t+1}function nH(e){return new TextDecoder("ascii").decode(e.slice(0,3))==="GIF"}function rH(e){const n=new Uint8Array(e);let t,r,o=0,s=0;if(!nH(e))return!1;for(t=n[10]&128,r=n[10]&7,o+=6,o+=7,o+=t?3*Math.pow(2,r+1):0;s<2&&o<n.length;)switch(n[o]){case 44:s+=1,t=n[o+9]&128,r=n[o+9]&7,o+=10,o+=t?3*Math.pow(2,r+1):0,o+=L1(n,o+1)+1;break;case 33:o+=2,o+=L1(n,o);break;case 59:o=n.length;break;default:o=n.length;break}return s>1}function oH(e,n){const t=e.w/n.w,r=e.h/n.h;return t<=1&&r<=1?e:t>r?{w:e.w/t,h:e.h/t}:{w:e.w/r,h:e.h/r}}async function sH(e,n,t,r={}){const o=await to.usingObjectURL(e,to.loadImage),{type:s=e.type,quality:i=.92}=r,[a,l]=await $k(Math.min(n*2,o.naturalWidth),Math.min(t*2,o.naturalHeight)),c=document.createElement("canvas");c.width=a,c.height=l;const u=ai(c.getContext("2d",{willReadFrequently:!0}),"Could not get canvas context");return u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(o,0,0,a,l),new Promise((d,h)=>{c.toBlob(f=>{f?d(f):h(new Error("Could not resize image"))},s,i)})}async function iH(e){return rH(await e.arrayBuffer())}function aH(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function lH(e){const n=new URL(e).host.replace("www.","");for(const t of Ha)if(Mk(t.hostnames,n)){const r=t.fromEmbedUrl(e);if(r)return{definition:t,url:r,embedUrl:e}}}const cH=e=>e.split("*").map(n=>aH(n)).join(".+"),Mk=(e,n)=>!!e.find(t=>{const r=new RegExp(cH(t));return n.match(r)});function uH(e){const n=new URL(e).host.replace("www.","");for(const t of Ha)if(Mk(t.hostnames,n)){const r=t.toEmbedUrl(e);if(r)return{definition:t,embedUrl:r,url:e}}}function Ak(e){return uH(e)??lH(e)}function Ao(e){try{return Ak(e)}catch(n){console.error(n)}}/*!
|
|
96
|
+
* MIT License
|
|
97
|
+
* Adapted (mostly copied) the work of https://github.com/fregante/text-field-edit
|
|
98
|
+
* Copyright (c) Federico Brigante <opensource@bfred.it> (bfred.it)
|
|
99
|
+
*/const ga=" ",ln=class ln{static insertTextFirefox(n,t){n.setRangeText(t,n.selectionStart||0,n.selectionEnd||0,"end"),n.dispatchEvent(new InputEvent("input",{data:t,inputType:"insertText",isComposing:!1}))}static insert(n,t){const r=n.ownerDocument,o=r.activeElement;o!==n&&n.focus(),r.execCommand("insertText",!1,t)||ln.insertTextFirefox(n,t),o===r.body?n.blur():o instanceof HTMLElement&&o!==n&&o.focus()}static set(n,t){n.select(),ln.insert(n,t)}static getSelection(n){const{selectionStart:t,selectionEnd:r}=n;return n.value.slice(t||void 0,r||void 0)}static wrapSelection(n,t,r){const{selectionStart:o,selectionEnd:s}=n,i=ln.getSelection(n);ln.insert(n,t+i+(r??t)),n.selectionStart=(o||0)+t.length,n.selectionEnd=(s||0)+t.length}static replace(n,t,r){let o=0;n.value.replace(t,(...s)=>{const i=o+s[s.length-2],a=s[0].length;n.selectionStart=i,n.selectionEnd=i+a;const l=typeof r=="string"?r:r(...s);return ln.insert(n,l),n.selectionStart=i,o+=l.length-a,l})}static findLineEnd(n,t){const r=n.lastIndexOf(`
|
|
100
|
+
`,t-1)+1;return n.charAt(r)!==" "?t:r+1}static indent(n){var a;const{selectionStart:t,selectionEnd:r,value:o}=n,s=o.slice(t,r),i=(a=/\n/g.exec(s))==null?void 0:a.length;if(i&&i>0){const l=o.lastIndexOf(`
|
|
101
|
+
`,t-1)+1,c=n.value.slice(l,r-1),u=c.replace(/^|\n/g,`$&${ga}`),d=u.length-c.length;n.setSelectionRange(l,r-1),ln.insert(n,u),n.setSelectionRange(t+1,r+d)}else ln.insert(n,ga)}static unindent(n){const{selectionStart:t,selectionEnd:r,value:o}=n,s=o.lastIndexOf(`
|
|
102
|
+
`,t-1)+1,i=ln.findLineEnd(o,r),a=n.value.slice(s,i),l=a.replace(/(^|\n)(\t| {1,2})/g,"$1"),c=a.length-l.length;n.setSelectionRange(s,i),ln.insert(n,l);const u=/\t| {1,2}/.exec(o.slice(s,t)),d=u?u[0].length:0,h=t-d;n.setSelectionRange(t-d,Math.max(h,r-c))}static indentCE(n){var l;const t=window.getSelection(),r=n.innerText,o=wd(n)??0,s=wd(n)??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(`
|
|
103
|
+
`,o-1)+1,u=r.slice(c,s-1),h=u.replace(/^|\n/g,`$&${ga}`).length-u.length;t&&t.setBaseAndExtent(n,o+1,n,s+h)}else{const c=window.getSelection();n.innerText=r.slice(0,o)+ga+r.slice(o),c==null||c.setBaseAndExtent(n,o+1,n,o+2)}}static unindentCE(n){const t=window.getSelection(),r=n.innerText,o=wd(n)??0,s=wd(n)??0,i=r.lastIndexOf(`
|
|
104
|
+
`,o-1)+1,a=ln.findLineEnd(r,s),l=r.slice(i,a),c=l.replace(/(^|\n)(\t| {1,2})/g,"$1"),u=l.length-c.length;if(t){t.setBaseAndExtent(n,i,n,a);const d=/\t| {1,2}/.exec(r.slice(i,o)),h=d?d[0].length:0,f=o-h;t.setBaseAndExtent(n,o-h,n,Math.max(f,s-u))}}static normalizeText(n){return n.replace(ln.fixNewLines,`
|
|
105
|
+
`)}static normalizeTextForDom(n){return n.replace(ln.fixNewLines,`
|
|
106
|
+
`).split(`
|
|
107
|
+
`).map(t=>t||" ").join(`
|
|
108
|
+
`)}};m(ln,"fixNewLines",/\r?\n|\r/g);let xs=ln;function wd(e){if(typeof window.getSelection>"u")return;const n=window.getSelection();if(!n)return;let t=0;if(n.rangeCount!==0){const r=n.getRangeAt(0),o=r.cloneRange();o.selectNodeContents(e),o.setEnd(r.endContainer,r.endOffset),t=o.toString().length}return t}const dH=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;function hH(e){return dH.test(e)}function pH(e){return e.replace(/\t/g,ga)}function fH(e){const n=e.split(`
|
|
109
|
+
`);for(;n[0]&&n[0].trim().length===0;)n.shift();let t=1/0;for(const r of n)if(r.trim().length>0){const o=r.length-r.trimStart().length;t=Math.min(t,o)}return n.map(r=>r.slice(t)).join(`
|
|
110
|
+
`)}function gH(e){return e.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function mH(e){return gH(fH(pH(e)))}const uc=(e,n)=>e.length<=n?e:e.substring(0,n-3)+"...";function yH(e,{maxImageDimension:n,maxAssetSize:t,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),d=o.includes(c.type);Do(u||d,`File type not allowed: ${c.type}`),Do(c.size<=t,`File size too big: ${(c.size/1024).toFixed()}kb > ${(t/1024).toFixed()}kb`),c.type==="video/quicktime"&&(c=new Blob([c],{type:"video/mp4"}));let h=u?await to.getImageSize(c):await to.getVideoSize(c);const f=c.type==="image/gif"?await iH(c):d,y=await oD(await c.arrayBuffer());if(isFinite(n)){const S=oH(h,{w:n,h:n});h!==S&&(c.type==="image/jpeg"||c.type==="image/png")&&(h=S)}(c.type==="image/jpeg"||c.type==="image/png")&&(c=await sH(c,h.w,h.h,{type:c.type,quality:.92}));const g=li.createId(y);return li.create({id:g,type:u?"image":"video",typeName:"asset",props:{name:l,src:await to.blobToDataUrl(c),w:h.w,h:h.h,mimeType:c.type,isAnimated:f}})}),e.registerExternalAssetHandler("url",async({url:a})=>{var c,u,d;let l;try{const f=await(await fetch(a,{method:"GET",mode:"no-cors"})).text(),y=new DOMParser().parseFromString(f,"text/html");l={image:((c=y.head.querySelector('meta[property="og:image"]'))==null?void 0:c.getAttribute("content"))??"",title:((u=y.head.querySelector('meta[property="og:title"]'))==null?void 0:u.getAttribute("content"))??uc(a,32),description:((d=y.head.querySelector('meta[property="og:description"]'))==null?void 0:d.getAttribute("content"))??""}}catch(h){console.error(h),s.addToast({title:i("assets.url.failed")}),l={image:"",title:uc(a,32),description:""}}return{id:li.createId(Ty(a)),typeName:"asset",type:"bookmark",props:{src:a,description:l.description,image:l.image,title:l.title},meta:{}}}),e.registerExternalContentHandler("svg-text",async({point:a,text:l})=>{const c=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageCenter()),u=new DOMParser().parseFromString(l,"image/svg+xml").querySelector("svg");if(!u)throw new Error("No <svg/> element present");let d=parseFloat(u.getAttribute("width")||"0"),h=parseFloat(u.getAttribute("height")||"0");if(!(d&&h)){document.body.appendChild(u);const y=u.getBoundingClientRect();document.body.removeChild(u),d=y.width,h=y.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");N1(e,[f],c)}),e.registerExternalContentHandler("embed",({point:a,url:l,embed:c})=>{const u=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageCenter()),{width:d,height:h}=c,f=We(),y={id:f,type:"embed",x:u.x-(d||450)/2,y:u.y-(h||450)/2,props:{w:d,h,url:l}};e.createShapes([y]).select(f)}),e.registerExternalContentHandler("files",async({point:a,files:l})=>{const c=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageCenter()),u=new b(c.x,c.y),d=[];await Promise.all(l.map(async(h,f)=>{if(h.size>t)return console.warn(`File size too big: ${(h.size/1024).toFixed()}kb > ${(t/1024).toFixed()}kb`),null;if(!h.type)throw new Error("No mime type");if(!r.concat(o).includes(h.type))return console.warn(`${h.name} not loaded - Extension not allowed.`),null;try{const y=await e.getAssetForExternalContent({type:"file",file:h});if(!y)throw Error("Could not create an asset");d[f]=y}catch(y){return s.addToast({title:i("assets.files.upload-failed")}),console.error(y),null}})),N1(e,ge(d),u)}),e.registerExternalContentHandler("text",async({point:a,text:l})=>{const c=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageCenter()),u=e.getShapeUtil("text").getDefaultProps(),d=mH(l);let h,f,y,g="middle";const v=d.split(`
|
|
111
|
+
`).length>1,S=hH(d);v&&(g=v?S?"end":"start":"middle");const w=e.textMeasure.measureText(d,{...Ut,fontFamily:Lo[u.font],fontSize:ms[u.size],maxWidth:null}),C=Math.min(v?e.getViewportPageBounds().width*.9:920,Math.max(200,e.getViewportPageBounds().width*.9));if(w.w>C){const I=e.textMeasure.measureText(d,{...Ut,fontFamily:Lo[u.font],fontSize:ms[u.size],maxWidth:C});h=I.w,f=I.h,y=!1,g=S?"end":"start"}else h=w.w,f=w.h,y=!0;c.y-f/2<e.getViewportPageBounds().minY+40&&(c.y=e.getViewportPageBounds().minY+40+f/2),e.createShapes([{id:We(),type:"text",x:c.x-h/2,y:c.y-f/2,props:{text:d,align:g,autoSize:y,w:h}}])}),e.registerExternalContentHandler("url",async({point:a,url:l})=>{const c=Ao(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.getViewportPageCenter()),d=li.createId(Ty(l)),h=SH(e,l,u);let f=e.getAsset(d),y=!1;if(!f){y=!0;try{const g=await e.getAssetForExternalContent({type:"url",url:l});if(!g)throw Error("Could not create an asset");f=g}catch{s.addToast({title:i("assets.url.failed")});return}}e.batch(()=>{y&&e.createAssets([f]),e.updateShapes([{id:h.id,type:h.type,props:{assetId:f.id}}])})})}async function N1(e,n,t){if(!n.length)return[];const r=b.From(t),o=[];for(const s of n)switch(s.type){case"bookmark":{o.push({id:We(),type:"bookmark",x:r.x-150,y:r.y-160,opacity:1,props:{assetId:s.id,url:s.props.src}}),r.x+=300;break}case"image":{o.push({id:We(),type:"image",x:r.x-s.props.w/2,y:r.y-s.props.h/2,opacity:1,props:{assetId:s.id,w:s.props.w,h:s.props.h}}),r.x+=s.props.w;break}case"video":o.push({id:We(),type:"video",x:r.x-s.props.w/2,y:r.y-s.props.h/2,opacity:1,props:{assetId:s.id,w:s.props.w,h:s.props.h}}),r.x+=s.props.w}return e.batch(()=>{const s=n.filter(i=>!e.getAsset(i.id));s.length&&e.createAssets(s),e.createShapes(o).select(...o.map(i=>i.id)),jk(e,t)}),o.map(s=>s.id)}function jk(e,n){const t=e.getViewportPageBounds();let r=e.getSelectionPageBounds();if(r){const o=r.center.sub(n);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&&!t.contains(r)&&e.zoomToSelection()}function SH(e,n,t){const r={id:We(),type:"bookmark",x:t.x-150,y:t.y-160,opacity:1,props:{assetId:null,url:n}};return e.batch(()=>{e.createShapes([r]).select(r.id),jk(e,t)}),e.getShape(r.id)}var uy;let vH=(uy=class extends oe{constructor(){super(...arguments);m(this,"onPointerDown",t=>{this.parent.transition("pointing",t)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")});m(this,"onKeyUp",t=>{var r;if(t.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",{...t,target:"shape",shape:o}))}})}},m(uy,"id","idle"),uy);var dy;let wH=(dy=class extends oe{constructor(){super(...arguments);m(this,"shape");m(this,"markId","");m(this,"onEnter",()=>{this.didTimeout=!1;const t=this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{filter:r=>!r.isLocked&&this.editor.getShapeUtil(r).canBind(r),margin:0,hitInside:!0,renderingOnly:!0});t?this.editor.setHintingShapes([t.id]):this.createArrowShape(),this.startPreciseTimeout()});m(this,"onExit",()=>{this.shape=void 0,this.editor.setHintingShapes([]),this.clearPreciseTimeout()});m(this,"onPointerMove",()=>{if(this.editor.inputs.isDragging){if(this.shape||this.createArrowShape(),!this.shape)throw Error("expected shape");this.updateArrowShapeEndHandle(),this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,handle:this.editor.getShapeHandles(this.shape).find(t=>t.id==="end"),isCreating:!0,onInteractionEnd:"arrow"})}});m(this,"onPointerUp",()=>{this.cancel()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()});m(this,"preciseTimeout",-1);m(this,"didTimeout",!1)}cancel(){this.shape&&this.editor.bailToMark(this.markId),this.editor.setHintingShapes([]),this.parent.transition("idle")}createArrowShape(){var u,d;const{originPagePoint:t}=this.editor.inputs,r=We();this.markId=`creating:${r}`,this.editor.mark(this.markId),this.editor.createShapes([{id:r,type:"arrow",x:t.x,y:t.y}]);const o=this.editor.getShape(r);if(!o)throw Error("expected shape");const s=this.editor.getShapeHandles(o);if(!s)throw Error("expected handles for arrow");const i=this.editor.getShapeUtil("arrow"),a=this.shape,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});if(c){const h=(d=c.props)==null?void 0:d.start;(h==null?void 0:h.type)==="binding"&&this.editor.setHintingShapes([h.boundShapeId]),this.editor.updateShapes([c],{squashing:!0})}this.shape=this.editor.getShape(r),this.editor.select(r)}updateArrowShapeEndHandle(){var s,i,a;const t=this.shape;if(!t)throw Error("expected shape");const r=this.editor.getShapeHandles(t);if(!r)throw Error("expected handles for arrow");const o={...t,props:{...t.props,end:{...t.props.end,x:0,y:0}}};{const l=this.editor.getShapeUtil("arrow"),c=this.shape,u=this.editor.getPointInShapeSpace(t,this.editor.inputs.currentPagePoint),d=r.find(f=>f.id==="end"),h=(s=l.onHandleDrag)==null?void 0:s.call(l,o,{handle:{...d,x:u.x,y:u.y},isPrecise:!1,initial:c});if(h){const f=(i=h.props)==null?void 0:i.end;(f==null?void 0:f.type)==="binding"&&this.editor.setHintingShapes([f.boundShapeId]),this.editor.updateShapes([h],{squashing:!0})}}{const l=this.editor.getShapeUtil("arrow"),c=this.shape,u=r.find(h=>h.id==="start"),d=(a=l.onHandleDrag)==null?void 0:a.call(l,o,{handle:{...u,x:0,y:0},isPrecise:this.didTimeout,initial:c});d&&this.editor.updateShapes([d],{squashing:!0})}this.shape=this.editor.getShape(t.id)}startPreciseTimeout(){this.preciseTimeout=window.setTimeout(()=>{this.getIsActive()&&(this.didTimeout=!0)},320)}clearPreciseTimeout(){clearTimeout(this.preciseTimeout)}},m(dy,"id","pointing"),dy);class ph extends oe{constructor(){super(...arguments);m(this,"shapeType","arrow")}}m(ph,"id","arrow"),m(ph,"initial","idle"),m(ph,"children",()=>[vH,wH]);class T0 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"initialShape");m(this,"shapeType",this.parent.id==="highlight"?"highlight":"draw");m(this,"util",this.editor.getShapeUtil(this.shapeType));m(this,"isPen",!1);m(this,"segmentMode","free");m(this,"didJustShiftClickToExtendPreviousShapeLine",!1);m(this,"pagePointWhereCurrentSegmentChanged",{});m(this,"pagePointWhereNextSegmentChanged",null);m(this,"lastRecordedPoint",{});m(this,"mergeNextPoint",!1);m(this,"currentLineLength",0);m(this,"canDraw",!1);m(this,"markId",null);m(this,"onEnter",t=>{this.markId=null,this.info=t,this.canDraw=!this.editor.getIsMenuOpen(),this.lastRecordedPoint=this.editor.inputs.currentPagePoint.clone(),this.canDraw&&this.startShape()});m(this,"onPointerMove",()=>{const{editor:{inputs:t}}=this;if(this.isPen!==t.isPen){if(this.markId){this.editor.bailToMark(this.markId),this.startShape();return}}else!this.canDraw&&t.isDragging&&(this.startShape(),this.canDraw=!0);this.canDraw&&(t.isPen?b.Dist(t.currentPagePoint,this.lastRecordedPoint)>=1/this.editor.getZoomLevel()?(this.lastRecordedPoint=t.currentPagePoint.clone(),this.mergeNextPoint=!1):this.mergeNextPoint=!0:this.mergeNextPoint=!1,this.updateShapes())});m(this,"onKeyDown",t=>{if(t.key==="Shift")switch(this.segmentMode){case"free":{this.segmentMode="starting_straight",this.pagePointWhereNextSegmentChanged=this.editor.inputs.currentPagePoint.clone();break}case"starting_free":this.segmentMode="starting_straight"}this.updateShapes()});m(this,"onKeyUp",t=>{if(t.key==="Shift")switch(this.editor.snaps.clearIndicators(),this.segmentMode){case"straight":{this.segmentMode="starting_free",this.pagePointWhereNextSegmentChanged=this.editor.inputs.currentPagePoint.clone();break}case"starting_straight":{this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";break}}this.updateShapes()});m(this,"onExit",()=>{this.editor.snaps.clearIndicators(),this.pagePointWhereCurrentSegmentChanged=this.editor.inputs.currentPagePoint.clone()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.editor.inputs.isDragging||(this.markId&&this.editor.bailToMark(this.markId),this.cancel())})}canClose(){return this.shapeType!=="highlight"}getIsClosed(t,r){if(!this.canClose())return!1;const o=Pt[r],s=t[0].points[0],i=t[t.length-1],a=i.points[i.points.length-1];return s!==a&&this.currentLineLength>o*4&&b.Dist(s,a)<o*2}startShape(){const{inputs:{originPagePoint:t,isPen:r}}=this.editor;this.markId="draw start "+ze(),this.editor.mark(this.markId),this.isPen=r;const o=this.isPen?this.info.point.z*1.25:.5;if(this.segmentMode=this.editor.inputs.shiftKey?"straight":"free",this.didJustShiftClickToExtendPreviousShapeLine=!1,this.lastRecordedPoint=t.clone(),this.initialShape){const i=this.editor.getShape(this.initialShape.id);if(i&&this.segmentMode==="straight"){this.didJustShiftClickToExtendPreviousShapeLine=!0;const a=xn(i.props.segments);if(!a)throw Error("Expected a previous segment!");const l=xn(a.points);if(!l)throw Error("Expected a previous point!");const{x:c,y:u}=this.editor.getPointInShapeSpace(i,t).toFixed(),d=this.isPen?this.info.point.z*1.25:.5,h={type:this.segmentMode,points:[{x:l.x,y:l.y,z:+d.toFixed(2)},{x:c,y:u,z:+d.toFixed(2)}]},f=re.applyToPoint(this.editor.getShapePageTransform(i.id),l);this.pagePointWhereCurrentSegmentChanged=f,this.pagePointWhereNextSegmentChanged=null;const y=[...i.props.segments,h];this.currentLineLength=this.getLineLength(y);const g={id:i.id,type:this.shapeType,props:{segments:y}};this.canClose()&&(g.props.isClosed=this.getIsClosed(y,i.props.size)),this.editor.updateShapes([g]);return}}this.pagePointWhereCurrentSegmentChanged=t.clone();const s=We();this.editor.createShapes([{id:s,type:this.shapeType,x:t.x,y:t.y,props:{isPen:this.isPen,segments:[{type:this.segmentMode,points:[{x:0,y:0,z:+o.toFixed(2)}]}]}}]),this.currentLineLength=0,this.initialShape=this.editor.getShape(s)}updateShapes(){const{inputs:t}=this.editor,{initialShape:r}=this;if(!r)return;const{id:o,props:{size:s}}=r,i=this.editor.getShape(o);if(!i)return;const{segments:a}=i.props,{x:l,y:c,z:u}=this.editor.getPointInShapeSpace(i,t.currentPagePoint).toFixed(),d={x:l,y:c,z:this.isPen?+(u*1.25).toFixed(2):.5};switch(this.segmentMode){case"starting_straight":{const{pagePointWhereNextSegmentChanged:h}=this;if(h===null)throw Error("We should have a point where the segment changed");if(b.Dist(h,t.currentPagePoint)>$c){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="straight";const y=xn(a);if(!y)throw Error("Expected a previous segment!");const g=xn(y.points);if(!g)throw Error("Expected a previous last point!");let v;const S=this.editor.getPointInShapeSpace(i,this.pagePointWhereCurrentSegmentChanged).toFixed().toJson();if(y.type==="straight"){this.currentLineLength+=b.Dist(g,S),v={type:"straight",points:[{...g},S]};const C=this.editor.getShapePageTransform(i);this.pagePointWhereCurrentSegmentChanged=re.applyToPoint(C,g)}else v={type:"straight",points:[S,d]};const w={id:o,type:this.shapeType,props:{segments:[...a,v]}};this.canClose()&&(w.props.isClosed=this.getIsClosed(a,s)),this.editor.updateShapes([w],{squashing:!0})}break}case"starting_free":{const{pagePointWhereNextSegmentChanged:h}=this;if(h===null)throw Error("We should have a point where the segment changed");if(b.Dist(h,t.currentPagePoint)>$c){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";const y=a.slice(),g=y[y.length-1],v=xn(g.points);if(!v)throw Error("No previous point!");const S={type:"free",points:[...b.PointsBetween(v,d,6).map(I=>I.toFixed().toJson())]},w=[...y,S];this.currentLineLength=this.getLineLength(w);const C={id:o,type:this.shapeType,props:{segments:w}};this.canClose()&&(C.props.isClosed=this.getIsClosed(w,s)),this.editor.updateShapes([C],{squashing:!0})}break}case"straight":{const h=a.slice(),f=h[h.length-1],{pagePointWhereCurrentSegmentChanged:y}=this,{currentPagePoint:g,ctrlKey:v}=this.editor.inputs;if(!y)throw Error("We should have a point where the segment changed");let S,w=!1;this.didJustShiftClickToExtendPreviousShapeLine?this.editor.inputs.isDragging&&(w=!v,this.didJustShiftClickToExtendPreviousShapeLine=!1):w=!v;let C=this.editor.getPointInShapeSpace(i,g).toFixed().toJson(),I=!1,P;if((this.editor.user.getIsSnapMode()?!v:v)&&h.length>2){let k,M=8/this.editor.getZoomLevel();for(let T=0,R=a.length-2;T<R;T++){const O=a[T];if(!O)break;if(O.type==="free")continue;const U=O.points[0],N=xn(O.points);if(!(U&&N))continue;const L=b.NearestPointOnLineSegment(U,N,C),G=b.Dist(L,C);if(G<M){k=L.toFixed().toJson(),M=G,P=O;break}}k&&(I=!0,C=k)}if(I&&P){const k=this.editor.getShapePageTransform(i),M=P.points[0],T=xn(P.points);if(!T)throw Error("Expected a last point!");const R=re.applyToPoint(k,M),O=re.applyToPoint(k,T),U=re.applyToPoint(k,C);this.editor.snaps.setIndicators([{id:ze(),type:"points",points:[R,U,O]}])}else{if(this.editor.snaps.clearIndicators(),w){const k=b.Angle(y,g),T=hp(k,24)-k;S=b.RotWith(g,y,T)}else S=g;C=this.editor.getPointInShapeSpace(i,S).toFixed().toJson()}this.currentLineLength+=b.Dist(f.points[0],C),h[h.length-1]={...f,type:"straight",points:[f.points[0],C]};const _={id:o,type:this.shapeType,props:{segments:h}};this.canClose()&&(_.props.isClosed=this.getIsClosed(a,s)),this.editor.updateShapes([_],{squashing:!0});break}case"free":{const h=a.slice(),f=h[h.length-1],y=[...f.points];if(y.length&&this.mergeNextPoint){const{z:v}=y[y.length-1];y[y.length-1]={x:d.x,y:d.y,z:v?Math.max(v,d.z):d.z}}else this.currentLineLength+=b.Dist(y[y.length-1],d),y.push(d);h[h.length-1]={...f,points:y},this.currentLineLength=this.getLineLength(h);const g={id:o,type:this.shapeType,props:{segments:h}};if(this.canClose()&&(g.props.isClosed=this.getIsClosed(h,s)),this.editor.updateShapes([g],{squashing:!0}),y.length>500){this.editor.updateShapes([{id:o,type:this.shapeType,props:{isComplete:!0}}]);const{currentPagePoint:v}=this.editor.inputs,S=We();this.editor.createShapes([{id:S,type:this.shapeType,x:pp(v.x),y:pp(v.y),props:{isPen:this.isPen,segments:[{type:"free",points:[{x:0,y:0,z:this.isPen?+(u*1.25).toFixed():.5}]}]}}]),this.initialShape=Dr(this.editor.getShape(S)),this.mergeNextPoint=!1,this.lastRecordedPoint=this.editor.inputs.currentPagePoint.clone(),this.currentLineLength=0}break}}}getLineLength(t){let r=0;for(const o of t)for(let s=0;s<o.points.length-1;s++){const i=o.points[s],a=o.points[s+1];r+=b.Sub(a,i).len2()}return Math.sqrt(r)}complete(){if(!this.canDraw){this.cancel();return}const{initialShape:t}=this;t&&(this.editor.updateShapes([{id:t.id,type:t.type,props:{isComplete:!0}}]),this.parent.transition("idle"))}cancel(){this.parent.transition("idle",this.info)}}m(T0,"id","drawing");var hy;let Ok=(hy=class extends oe{constructor(){super(...arguments);m(this,"onPointerDown",t=>{this.parent.transition("drawing",t)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(hy,"id","idle"),hy);class fh extends oe{constructor(){super(...arguments);m(this,"shapeType","draw");m(this,"onExit",()=>{const t=this.children.drawing;t.initialShape=void 0})}}m(fh,"id","draw"),m(fh,"initial","idle"),m(fh,"children",()=>[Ok,T0]);class lS extends lh{constructor(){super(...arguments);m(this,"shapeType","frame");m(this,"onCreate",t=>{if(!t)return;const r=this.editor.getShapePageBounds(t),o=[],s=this.editor.getShapeAncestors(t).map(i=>i.id);this.editor.getSortedChildIdsForParent(t.parentId).map(i=>{const a=this.editor.getShape(i);if(!a||a.id===t.id||a.isLocked)return;const l=this.editor.getShapePageBounds(a);l&&r.contains(l)&&xH(a,s,t)&&o.push(a.id)}),this.editor.reparentShapes(o,t.id),this.editor.getInstanceState().isToolLocked?this.editor.setCurrentTool("frame"):this.editor.setCurrentTool("select.idle")})}}m(lS,"id","frame"),m(lS,"initial","idle");function xH(e,n,t){return n.includes(e.id)?!1:e.parentId===t.parentId}var py;let bH=(py=class extends oe{constructor(){super(...arguments);m(this,"onPointerDown",t=>{this.parent.transition("pointing",t)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onKeyUp",t=>{var r;if(t.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",{...t,target:"shape",shape:o}))}});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(py,"id","idle"),py);var fy;let PH=(fy=class extends oe{constructor(){super(...arguments);m(this,"markId","");m(this,"onPointerUp",()=>{this.complete()});m(this,"onPointerMove",t=>{if(this.editor.inputs.isDragging){const{originPagePoint:r}=this.editor.inputs,o=We();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(so)}}]).select(o).setCurrentTool("select.resizing",{...t,target:"selection",handle:"bottom_right",isCreating:!0,creationCursorOffset:{x:1,y:1},onInteractionEnd:"geo"})}});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()})}complete(){const{originPagePoint:t}=this.editor.inputs,r=We();this.markId=`creating:${r}`,this.editor.mark(this.markId),this.editor.createShapes([{id:r,type:"geo",x:t.x,y:t.y,props:{geo:this.editor.getStyleForNextShape(so),w:1,h:1}}]);const o=this.editor.getShape(r);if(!o)return;const s=o.props.geo==="star"?new ne(0,0,200,190):o.props.geo==="cloud"?new ne(0,0,300,180):new ne(0,0,200,200),i=s.center,a=this.editor.getShapeParentTransform(o);a&&i.rot(-a.rotation()),this.editor.select(r),this.editor.updateShapes([{id:o.id,type:"geo",x:o.x-i.x,y:o.y-i.y,props:{geo:this.editor.getStyleForNextShape(so),w:s.width,h:s.height}}]),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select",{})}cancel(){this.parent.transition("idle")}},m(fy,"id","pointing"),fy);class gh extends oe{constructor(){super(...arguments);m(this,"shapeType","geo")}}m(gh,"id","geo"),m(gh,"initial","idle"),m(gh,"children",()=>[bH,PH]);class mh extends oe{constructor(){super(...arguments);m(this,"shapeType","highlight");m(this,"onExit",()=>{const t=this.children.drawing;t.initialShape=void 0})}}m(mh,"id","highlight"),m(mh,"initial","idle"),m(mh,"children",()=>[Ok,T0]);var gy;let CH=(gy=class extends oe{constructor(){super(...arguments);m(this,"shapeId","");m(this,"onEnter",t=>{this.shapeId=t.shapeId,this.editor.setCursor({type:"cross",rotation:0})});m(this,"onPointerDown",()=>{this.parent.transition("pointing",{shapeId:this.shapeId})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(gy,"id","idle"),gy);const F1=2;var my;let IH=(my=class extends oe{constructor(){super(...arguments);m(this,"shape",{});m(this,"markId");m(this,"onEnter",t=>{const{inputs:r}=this.editor,{currentPagePoint:o}=r;this.markId=void 0;const s=t.shapeId&&this.editor.getShape(t.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(Rt),l=a[a.length-1],c=a[a.length-2],u=re.applyToPoint(this.editor.getShapeParentTransform(this.shape),new b(this.shape.x,this.shape.y)),d=b.Sub(o,u).addXY(.1,.1),h=Dr(this.shape.props.points);if(b.Dist(l,c)<F1||b.Dist(d,l)<F1)h[l.id]={id:l.id,index:l.index,x:d.x,y:d.y};else{const f=ko(l.index);h[f]={id:f,index:f,x:d.x,y:d.y}}this.editor.updateShapes([{id:this.shape.id,type:this.shape.type,props:{points:h}}])}else{const i=We();this.markId=`creating:${i}`,this.editor.mark(this.markId),this.editor.createShapes([{id:i,type:"line",x:o.x,y:o.y}]),this.editor.select(i),this.shape=this.editor.getShape(i)}});m(this,"onPointerMove",()=>{if(this.shape&&this.editor.inputs.isDragging){const t=this.editor.getShapeHandles(this.shape);if(!t)throw this.markId&&this.editor.bailToMark(this.markId),Error("No handles found");const r=xn(t);this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,isCreating:!0,handle:{...r,x:r.x-.1,y:r.y-.1},onInteractionEnd:"line"})}});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.parent.transition("idle"),this.markId&&this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators()})}complete(){this.parent.transition("idle",{shapeId:this.shape.id}),this.editor.snaps.clearIndicators()}cancel(){this.markId&&this.editor.bailToMark(this.markId),this.parent.transition("idle",{shapeId:this.shape.id}),this.editor.snaps.clearIndicators()}},m(my,"id","pointing"),my);class yh extends oe{constructor(){super(...arguments);m(this,"shapeType","line")}}m(yh,"id","line"),m(yh,"initial","idle"),m(yh,"children",()=>[CH,IH]);var yy;let EH=(yy=class extends oe{constructor(){super(...arguments);m(this,"onPointerDown",t=>{this.parent.transition("pointing",t)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(yy,"id","idle"),yy);var Sy;let _H=(Sy=class extends oe{constructor(){super(...arguments);m(this,"dragged",!1);m(this,"info",{});m(this,"wasFocusedOnEnter",!1);m(this,"markId","");m(this,"shape",{});m(this,"onEnter",()=>{this.wasFocusedOnEnter=!this.editor.getIsMenuOpen(),this.wasFocusedOnEnter&&(this.shape=this.createShape())});m(this,"onPointerMove",t=>{this.editor.inputs.isDragging&&(this.wasFocusedOnEnter||(this.shape=this.createShape()),this.editor.setCurrentTool("select.translating",{...t,target:"shape",shape:this.shape,onInteractionEnd:"note",isCreating:!0,onCreate:()=>{this.editor.setEditingShape(this.shape.id),this.editor.setCurrentTool("select.editing_shape")}}))});m(this,"onPointerUp",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()})}complete(){this.wasFocusedOnEnter&&(this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):(this.editor.setEditingShape(this.shape.id),this.editor.setCurrentTool("select.editing_shape",{...this.info,target:"shape",shape:this.shape})))}cancel(){this.editor.bailToMark(this.markId),this.parent.transition("idle",this.info)}createShape(){const{inputs:{originPagePoint:t}}=this.editor,r=We();this.markId=`creating:${r}`,this.editor.mark(this.markId),this.editor.createShapes([{id:r,type:"note",x:t.x,y:t.y}]).select(r);const o=this.editor.getShape(r),s=this.editor.getShapeGeometry(o).bounds;return this.editor.updateShapes([{id:r,type:"note",x:o.x-s.width/2,y:o.y-s.height/2}]),this.editor.getShape(r)}},m(Sy,"id","pointing"),Sy);class Sh extends oe{constructor(){super(...arguments);m(this,"shapeType","note")}}m(Sh,"id","note"),m(Sh,"initial","idle"),m(Sh,"children",()=>[EH,_H]);function Rc(e){const n=e.getShapeAtPoint(e.inputs.currentPagePoint,{hitInside:!1,hitLabels:!1,margin:Ur/e.getZoomLevel(),renderingOnly:!0});if(!n)return e.setHoveredShape(null);let t;const r=e.getOutermostSelectableShape(n);return r===n||r.id===e.getFocusedGroupId()||e.getSelectedShapeIds().includes(r.id)?t=n:t=r,e.setHoveredShape(t.id)}var vy;let kH=(vy=class extends oe{constructor(){super(...arguments);m(this,"onPointerMove",t=>{switch(t.target){case"shape":case"canvas":Rc(this.editor)}});m(this,"onPointerDown",t=>{this.parent.transition("pointing",t)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onKeyDown",t=>{var r;if(t.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",{...t,target:"shape",shape:o}))}});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(vy,"id","idle"),vy);var wy;let TH=(wy=class extends oe{constructor(){super(...arguments);m(this,"shape");m(this,"markId","");m(this,"onExit",()=>{this.editor.setHintingShapes([])});m(this,"onPointerMove",t=>{if(this.editor.inputs.isDragging){const{inputs:{originPagePoint:r}}=this.editor,o=We();if(this.markId=`creating:${o}`,this.editor.mark(this.markId),this.editor.createShapes([{id:o,type:"text",x:r.x,y:r.y,props:{text:"",autoSize:!1,w:20}}]),this.editor.select(o),this.shape=this.editor.getShape(o),!this.shape)return;const{shape:s}=this;this.editor.setCurrentTool("select.resizing",{...t,target:"selection",handle:"right",isCreating:!0,creationCursorOffset:{x:1,y:1},onInteractionEnd:"text",onCreate:()=>{this.editor.setEditingShape(s.id),this.editor.setCurrentTool("select.editing_shape")}})}});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.cancel()});m(this,"onCancel",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}complete(){var s;this.editor.mark("creating text shape");const t=We(),{x:r,y:o}=this.editor.inputs.currentPagePoint;this.editor.createShapes([{id:t,type:"text",x:r,y:o,props:{text:"",autoSize:!0}}]).select(t),this.editor.setEditingShape(t),this.editor.setCurrentTool("select"),(s=this.editor.root.getCurrent())==null||s.transition("editing_shape")}cancel(){this.parent.transition("idle"),this.editor.bailToMark(this.markId)}},m(wy,"id","pointing"),wy);class vh extends oe{constructor(){super(...arguments);m(this,"shapeType","text")}}m(vh,"id","text"),m(vh,"initial","idle"),m(vh,"children",()=>[kH,TH]);const $H=[vh,fh,gh,Sh,yh,lS,ph,mh];function Mt(){return Dn({isDarkMode:Sf()})}const ft=ie.memo(function({theme:n,d:t,color:r,fill:o}){switch(o){case"none":return null;case"solid":return p.jsx("path",{fill:n[r].semi,d:t});case"semi":return p.jsx("path",{fill:n.solid,d:t});case"pattern":return p.jsx(MH,{theme:n,color:r,fill:o,d:t})}}),MH=function({d:n,color:t,theme:r}){const o=F(),s=K("zoomLevel",()=>o.getZoomLevel(),[o]),i=Math.ceil(s),a=o.getZoomLevel()<=.18;return p.jsxs(p.Fragment,{children:[p.jsx("path",{fill:r[t].pattern,d:n}),p.jsx("path",{fill:a?r[t].semi:`url(#${gp[`${i}_${r.id}`]})`,d:n})]})};function er({d:e,color:n,fill:t,theme:r}){if(t==="none")return;if(t==="pattern"){const s=document.createElementNS("http://www.w3.org/2000/svg","g"),i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",e),i.setAttribute("fill",r[n].pattern);const a=document.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("d",e),a.setAttribute("fill","url(#hash_pattern)"),s.appendChild(i),s.appendChild(a),s}const o=document.createElementNS("http://www.w3.org/2000/svg","path");switch(o.setAttribute("d",e),t){case"semi":{o.setAttribute("fill",r.solid);break}case"solid":{o.setAttribute("fill",r[n].semi);break}}return o}function Vr(e,n){if(n){const t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.appendChild(n),t.appendChild(e),t}else return e}function AH(e){return e.replace(/\s/g," ")}function kf(e,n,t){const{padding:r=0}=t,o=document.createElementNS("http://www.w3.org/2000/svg","text");if(o.setAttribute("font-size",t.fontSize+"px"),o.setAttribute("font-family",t.fontFamily),o.setAttribute("font-style",t.fontStyle),o.setAttribute("font-weight",t.fontWeight),o.setAttribute("line-height",t.lineHeight*t.fontSize+"px"),o.setAttribute("dominant-baseline","mathematical"),o.setAttribute("alignment-baseline","mathematical"),n.length===0)return o;const s=ne.From(n[0].box);for(const{box:c}of n)s.union(c);const i=r+(t.offsetX??0),a=(t.offsetY??0)+t.fontSize/2+(t.verticalTextAlign==="start"?r:t.verticalTextAlign==="end"?t.height-r-s.height:(Math.ceil(t.height)-s.height)/2);let l=null;for(const{text:c,box:u}of n){if(l!==null&&u.y>l){const y=document.createElementNS("http://www.w3.org/2000/svg","tspan");y.setAttribute("alignment-baseline","mathematical"),y.setAttribute("x",i+"px"),y.setAttribute("y",u.y+a+"px"),y.textContent=`
|
|
112
|
+
`,o.appendChild(y)}const h=document.createElementNS("http://www.w3.org/2000/svg","tspan");h.setAttribute("alignment-baseline","mathematical"),h.setAttribute("x",u.x+i+"px"),h.setAttribute("y",u.y+a+"px");const f=AH(c);h.textContent=f,o.appendChild(h),l=u.y}return t.stroke&&t.strokeWidth&&(o.setAttribute("stroke",t.stroke),o.setAttribute("stroke-width",t.strokeWidth+"px")),t.fill&&o.setAttribute("fill",t.fill),o}function Tf(e){return{key:`${lo.id}:${e}`,getElement:async()=>{const n=jH(e);if(!n)return null;const t=n.$$_url,r=n.$$_fontface;if(!t||!r)return null;const o=await(await fetch(t)).blob(),s=await new Promise((l,c)=>{const u=new FileReader;u.onload=()=>l(u.result),u.onerror=c,u.readAsDataURL(o)}),i=r.replace(t,s),a=document.createElementNS("http://www.w3.org/2000/svg","style");return a.textContent=i,a}}}function jH(e){const n=mu[e];for(const t of document.fonts)if(n.includes(t.family))return t;return null}function $0(e,n){return{key:`${lo.id}:${e}`,getElement:async()=>{if(e!=="pattern")return null;const t=8/12,r=document.createElement("div");return r.innerHTML=`
|
|
113
|
+
<svg>
|
|
114
|
+
<defs>
|
|
115
|
+
<mask id="hash_pattern_mask">
|
|
116
|
+
<rect x="0" y="0" width="8" height="8" fill="white" />
|
|
117
|
+
<g
|
|
118
|
+
strokeLinecap="round"
|
|
119
|
+
stroke="black"
|
|
120
|
+
>
|
|
121
|
+
<line x1="${t*1}" y1="${t*3}" x2="${t*3}" y2="${t*1}" />
|
|
122
|
+
<line x1="${t*5}" y1="${t*7}" x2="${t*7}" y2="${t*5}" />
|
|
123
|
+
<line x1="${t*9}" y1="${t*11}" x2="${t*11}" y2="${t*9}" />
|
|
124
|
+
</g>
|
|
125
|
+
</mask>
|
|
126
|
+
<pattern
|
|
127
|
+
id="hash_pattern"
|
|
128
|
+
width="8"
|
|
129
|
+
height="8"
|
|
130
|
+
patternUnits="userSpaceOnUse"
|
|
131
|
+
>
|
|
132
|
+
<rect x="0" y="0" width="8" height="8" fill="${n.solid}" mask="url(#hash_pattern_mask)" />
|
|
133
|
+
</pattern>
|
|
134
|
+
</defs>
|
|
135
|
+
</svg>
|
|
136
|
+
`,Array.from(r.querySelectorAll("defs > *"))}}}function M0(){return{key:`${lo.id}:pattern`,component:RH}}const Ql=8,z1=(e,n,t)=>new Promise((r,o)=>{const s=Ql*n*e,i=document.createElement("canvas");i.width=s,i.height=s;const a=i.getContext("2d");if(!a)return;a.fillStyle=t?"#212529":"#f8f9fa",a.fillRect(0,0,s,s),a.globalCompositeOperation="destination-out",a.lineCap="round",a.lineWidth=1.25*n*e;const l=8/12,c=u=>u*n*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||Ft.throwToBlob.get()?o():r(u)})}),B1=(e,n)=>{const t=document.createElement("canvas");t.width=e[0],t.height=e[1];const r=t.getContext("2d");return r?(n(r),t.toDataURL()):""},OH=()=>{const e=[];for(let n=1;n<=Math.ceil(ds);n++){const t=B1([1,1],o=>{o.fillStyle=ap.lightMode.black.semi,o.fillRect(0,0,1,1)}),r=B1([1,1],o=>{o.fillStyle=ap.darkMode.black.semi,o.fillRect(0,0,1,1)});e.push({zoom:n,url:t,darkMode:!1}),e.push({zoom:n,url:r,darkMode:!0})}return e};function DH(){const n=F().getInstanceState().devicePixelRatio,[t,r]=x.useState(!1),o=x.useMemo(()=>OH(),[]),[s,i]=x.useState(o);return x.useEffect(()=>{const l=[];for(let u=1;u<=Math.ceil(ds);u++)l.push(z1(n,u,!1).then(d=>({zoom:u,url:URL.createObjectURL(d),darkMode:!1}))),l.push(z1(n,u,!0).then(d=>({zoom:u,url:URL.createObjectURL(d),darkMode:!0})));let c=!1;return Promise.all(l).then(u=>{c||(i(u),r(!0))}),()=>{c=!0,r(!1)}},[n]),{defs:p.jsx(p.Fragment,{children:s.map(l=>{const c=l.zoom+(l.darkMode?"_dark":"_light");return p.jsx("pattern",{id:gp[c],width:Ql,height:Ql,patternUnits:"userSpaceOnUse",children:p.jsx("image",{href:l.url,width:Ql,height:Ql})},c)})}),isReady:t}}function RH(){const e=F(),n=x.useRef(null),{defs:t,isReady:r}=DH();return x.useEffect(()=>{if(r&&e.environment.isSafari){const o=Dk(n.current);o&&requestAnimationFrame(()=>{o.style.display="none",requestAnimationFrame(()=>{o.style.display=""})})}},[e,r]),p.jsx("g",{ref:n,"data-testid":r?"ready-pattern-fill-defs":void 0,children:t})}function Dk(e){return e.classList.contains("tl-html-layer")?e:e.parentElement?Dk(e.parentElement):null}function nn(e,n,t={}){const{closed:r=!1,snap:o=1,start:s="outset",end:i="outset",lengthRatio:a=2,style:l="dashed"}=t;let c=0,u=0,d=1,h=0,f=0;switch(l){case"dashed":{d=1,c=Math.min(n*a,e/4);break}case"dotted":{d=100,c=n/d;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*d)),u-=u%o,u<3&&l==="dashed"?e/n<5?(c=e,u=1,h=0):(c=e*.333,h=e*.333):(u=Math.max(u,3),c=e/u/(2*d),r?(f=c/2,h=(e-u*c)/u):h=(e-u*c)/Math.max(1,u-1)),{strokeDasharray:[c,h].join(" "),strokeDashoffset:f.toString()}}const U1=new WeakMap;function A0(e,n){const t=U1.get(n);if(t)return t;const r=e.getArrowInfo(n);let o=0,s=0;const i=r.isStraight?new jc({start:b.From(r.start.point),end:b.From(r.end.point)}):new I_({center:b.Cast(r.handleArc.center),radius:r.handleArc.radius,start:b.Cast(r.start.point),end:b.Cast(r.end.point),sweepFlag:r.bodyArc.sweepFlag,largeArcFlag:r.bodyArc.largeArcFlag});if(n.props.text.trim()){const l=i.bounds,{w:c,h:u}=e.textMeasure.measureText(n.props.text,{...Ut,fontFamily:Lo[n.props.font],fontSize:hs[n.props.size],maxWidth:null});if(o=c,s=u,l.width>l.height){o=Math.max(Math.min(c,64),Math.min(l.width-64,c));const{w:d,h}=e.textMeasure.measureText(n.props.text,{...Ut,fontFamily:Lo[n.props.font],fontSize:hs[n.props.size],maxWidth:o});o=d,s=h}if(o>16*hs[n.props.size]){o=16*hs[n.props.size];const{w:d,h}=e.textMeasure.measureText(n.props.text,{...Ut,fontFamily:Lo[n.props.font],fontSize:hs[n.props.size],maxWidth:o});o=d,s=h}}const a=new b(o,s).addScalar(zU*2);return U1.set(n,a),a}function Rk(e,n){const t=Pt[n.props.size];return FU+(t-Pt.s)*2+(t===Pt.xl?20:0)}function LH(e,n,t){const r=A0(e,n),o=Rk(e,n),s=b.Nudge(t.start.point,t.end.point,o),i=b.Nudge(t.end.point,t.start.point,o),a=a_(s,i,ne.FromCenter(t.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(t.middle,l)),d=i.add(b.Sub(t.middle,c)),h=b.Dist(t.start.point,u)/t.length,f=b.Dist(t.start.point,d)/t.length;return{start:h,end:f}}function NH(e,n,t){const r=A0(e,n),o=Rk(e,n),s=Math.sign(n.props.bend),i=o/t.handleArc.radius*s,a=b.Angle(t.bodyArc.center,t.start.point)-i,l=b.Angle(t.bodyArc.center,t.end.point)+i,c=Si(t.bodyArc.center,t.bodyArc.radius,a),u=Si(t.bodyArc.center,t.bodyArc.radius,l),d=[],h=K1(t.bodyArc.center,t.bodyArc.radius,a,l,s,ne.FromCenter(c,r).corners);d.push(new vt({points:ne.FromCenter(c,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));const f=K1(t.bodyArc.center,t.bodyArc.radius,a,l,s,ne.FromCenter(u,r).corners);d.push(new vt({points:ne.FromCenter(u,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));for(const _ of[...h??[],...f??[],c,u])d.push(new a0({x:_.x-3,y:_.y-3,radius:3,isFilled:!1,debugColor:"magenta",ignore:!0}));const y=(h&&V1(t.start.point,h))??t.middle,g=(f&&V1(t.end.point,f))??t.middle,v=b.Angle(t.bodyArc.center,t.start.point),S=b.Angle(t.bodyArc.center,t.end.point),w=b.Angle(t.bodyArc.center,y),C=b.Angle(t.bodyArc.center,g);if(us(v,w,s)>us(v,C,s))return{start:.5,end:.5,dbg:d};const I=us(v,S,s),P=us(v,w,s)/I,E=us(v,C,s)/I;return{start:P,end:E,dbg:d}}function H1(e,n){let t;const r=[],o=e.getArrowInfo(n),s=o.start.arrowhead!=="none",i=o.end.arrowhead!=="none";if(o.isStraight){const l=LH(e,n,o);let c=ar(n.props.labelPosition,s?l.start:0,i?l.end:1);c=c>=.48&&c<=.52?.5:c,t=b.Lrp(o.start.point,o.end.point,c)}else{const l=NH(e,n,o);l.dbg&&r.push(...l.dbg);let c=ar(n.props.labelPosition,s?l.start:0,i?l.end:1);c=c>=.48&&c<=.52?.5:c;const u=FH(b.Angle(o.bodyArc.center,o.start.point),b.Angle(o.bodyArc.center,o.end.point),Math.sign(n.props.bend),c);t=Si(o.bodyArc.center,o.bodyArc.radius,u)}const a=A0(e,n);return{box:ne.FromCenter(t,a),debugGeom:r}}function K1(e,n,t,r,o,s){const i=Uy(e,n,s),a=us(t,r,o);return i==null?void 0:i.filter(l=>{const c=us(t,b.Angle(e,l),o);return c>=0&&c<=a})}function V1(e,n){let t=null,r=-1/0;for(const o of n){const s=b.Dist2(e,o);s>r&&(t=o,r=s)}return t}function FH(e,n,t,r){const o=us(e,n,t);return e+o*r*t*-1}function zH(e,n,t){const r=n==="end"?e.end.point:e.start.point,o=n==="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,t*3),t);let a;if(e.isStraight)a=b.Nudge(r,o,i);else{const l=N6(r,i,e.handleArc.center,e.handleArc.radius);a=n==="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 BH({point:e,int:n}){const t=b.RotWith(n,e,$e/6),r=b.RotWith(n,e,-$e/6);return`M ${t.x} ${t.y} L ${e.x} ${e.y} L ${r.x} ${r.y}`}function UH({point:e,int:n}){const t=b.RotWith(n,e,$e/6),r=b.RotWith(n,e,-$e/6);return`M ${t.x} ${t.y} L ${e.x} ${e.y} L ${r.x} ${r.y} Z`}function HH({point:e,int:n}){const t=b.Sub(n,e).div(2),r=b.Add(e,b.Rot(t,Ke)),o=b.Sub(e,b.Rot(t,Ke));return`M ${r.x} ${r.y} L ${n.x} ${n.y} L ${o.x} ${o.y} Z`}function KH({point:e,int:n}){const t=b.Lrp(e,n,.45),r=b.Dist(t,e);return`M ${t.x-r},${t.y}
|
|
137
|
+
a ${r},${r} 0 1,0 ${r*2},0
|
|
138
|
+
a ${r},${r} 0 1,0 -${r*2},0 `}function VH({point:e,int:n}){const t=b.Lrp(e,n,.75),r=b.RotWith(t,e,$e/4),o=b.RotWith(t,e,-$e/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 WH({int:e,point:n}){const t=b.Lrp(n,e,.85),r=b.Sub(t,n).div(2),o=b.Add(n,b.Rot(r,Ke)),s=b.Sub(n,b.Rot(r,Ke)),i=b.Add(t,b.Rot(r,Ke)),a=b.Sub(t,b.Rot(r,Ke));return`M ${o.x} ${o.y} L ${i.x} ${i.y} L ${a.x} ${a.y} L ${s.x} ${s.y} Z`}function GH({int:e,point:n}){const t=b.Sub(e,n).div(2),r=b.Add(n,b.Rot(t,Ke)),o=b.Sub(n,b.Rot(t,Ke));return`M ${r.x} ${r.y} L ${o.x} ${o.y}`}function ta(e,n,t){const r=n==="end"?e.end.arrowhead:e.start.arrowhead;if(r==="none")return;const o=zH(e,n,t);if(o){switch(r){case"bar":return GH(o);case"square":return WH(o);case"diamond":return VH(o);case"dot":return KH(o);case"inverted":return HH(o);case"arrow":return BH(o);case"triangle":return UH(o)}return""}}function YH(e){const{start:n,end:t,handleArc:{radius:r,largeArcFlag:o,sweepFlag:s}}=e;return`M${n.handle.x},${n.handle.y} A${r} ${r} 0 ${o} ${s} ${t.handle.x},${t.handle.y}`}function pm(e){const{start:n,end:t,bodyArc:{radius:r,largeArcFlag:o,sweepFlag:s}}=e;return`M${n.point.x},${n.point.y} A${r} ${r} 0 ${o} ${s} ${t.point.x},${t.point.y}`}function Lk(e,n){return`M${e.x},${e.y}L${n.x},${n.y}`}function XH(e){return Lk(e.start.handle,e.end.handle)}function fm(e){return Lk(e.start.point,e.end.point)}function j0(e,n,t){const r=F(),o=x.useRef(null),s=x.useRef(!1),i=x.useRef(),a=K("isEditing",()=>r.getEditingShapeId()===e,[r,e]);x.useEffect(()=>{const g=o.current;g&&a&&document.activeElement!==g&&g.focus()},[a]);const l=x.useCallback(()=>{const g=s.current;s.current=!1,requestAnimationFrame(()=>{const v=o.current;if(!v)return;const S=r.getShape(e);S&&(v.value=S.props.text,v.value.length&&!g&&v.select())})},[r,e]),c=x.useCallback(()=>{const g=i.current;requestAnimationFrame(()=>{var w;const v=o.current,S=r.getEditingShapeId();if(v&&S){if(S===e)if(g)if(!g.length)v.focus();else{s.current=!0,v.focus();const C=window.getSelection();C&&g.forEach(I=>C.addRange(I))}else v.focus()}else(w=window.getSelection())==null||w.removeAllRanges(),r.complete()})},[r,e]),u=x.useCallback(g=>{if(a)switch(g.key){case"Enter":{(g.ctrlKey||g.metaKey)&&r.complete();break}case"Tab":{je(g),g.shiftKey?xs.unindent(g.currentTarget):xs.indent(g.currentTarget);break}}},[r,a]),d=x.useCallback(g=>{if(!a)return;let v=xs.normalizeText(g.currentTarget.value);const S=v.replace(/\t/g,ga);if(S!==v){const w=g.currentTarget.selectionStart;g.currentTarget.value=S,g.currentTarget.selectionStart=w+(S.length-v.length),g.currentTarget.selectionEnd=w+(S.length-v.length),v=S}r.updateShapes([{id:e,type:n,props:{text:v}}])},[r,e,n,a]),h=t.trim().length===0;x.useEffect(()=>{if(!a)return;if(o.current){let v=function(){var w,C;const S=(w=window.getSelection)==null?void 0:w.call(window);if(S&&S.type!=="None"){const I=[];if(S)for(let P=0;P<S.rangeCount;P++)I.push((C=S.getRangeAt)==null?void 0:C.call(S,P));i.current=I}};return document.addEventListener("selectionchange",v),()=>{document.removeEventListener("selectionchange",v)}}},[a]);const f=x.useCallback(g=>{r.dispatch({...In(g),type:"pointer",name:"pointer_down",target:"shape",shape:r.getShape(e)}),It(g)},[r,e]);return{rInput:o,isEditing:a,handleFocus:l,handleBlur:c,handleKeyDown:u,handleChange:d,handleInputPointerDown:f,handleDoubleClick:It,isEmpty:h}}const qH=x.memo(function({id:n,text:t,size:r,font:o,position:s,width:i,labelColor:a}){const{rInput:l,isEditing:c,handleFocus:u,handleBlur:d,handleKeyDown:h,handleChange:f,isEmpty:y,handleInputPointerDown:g,handleDoubleClick:v}=j0(n,"arrow",t),w=xs.normalizeTextForDom(t).trim().length>0;return!c&&!w?null:p.jsx("div",{className:"tl-arrow-label","data-font":o,"data-align":"center","data-hastext":!y,"data-isediting":c,style:{textAlign:"center",fontSize:hs[r],lineHeight:hs[r]*Ut.lineHeight+"px",transform:`translate(${s.x}px, ${s.y}px)`,color:a},children:p.jsxs("div",{className:"tl-arrow-label__inner",children:[p.jsx("p",{style:{width:i||"9px"},children:t?xs.normalizeTextForDom(t):" "}),c&&p.jsx("textarea",{ref:l,className:"tl-text tl-text-input",name:"text",tabIndex:-1,autoComplete:"false",autoCapitalize:"false",autoCorrect:"false",autoSave:"false",autoFocus:!0,placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",datatype:"wysiwyg",defaultValue:t,onFocus:u,onChange:f,onKeyDown:h,onBlur:d,onTouchEnd:It,onContextMenu:It,onPointerDown:g,onDoubleClick:v})]})})});let ZH=0;class wh extends Lr{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"canBind",()=>!1);m(this,"canSnap",()=>!1);m(this,"hideResizeHandles",()=>!0);m(this,"hideRotateHandle",()=>!0);m(this,"hideSelectionBoundsBg",()=>!0);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"onHandleDrag",(t,{handle:r,isPrecise:o})=>{const s=r.id;if(s==="middle"){const{start:v,end:S}=Ar(this.editor,t),w=b.Sub(S,v),C=b.Per(w),I=b.Med(S,v),P=b.Sub(I,C),E=b.Add(I,C),_=b.NearestPointOnLineSegment(P,E,r,!1);let k=b.Dist(_,I);return b.Clockwise(_,S,I)&&(k*=-1),{id:t.id,type:t.type,props:{bend:k}}}const i=pr(t);if(this.editor.inputs.ctrlKey)return i.props[s]={type:"point",x:r.x,y:r.y},i;const a=this.editor.getShapePageTransform(t.id).applyToPoint(r),l=this.editor.getShapeAtPoint(a,{hitInside:!0,hitFrameInside:!0,margin:0,filter:v=>!v.isLocked&&this.editor.getShapeUtil(v).canBind(v)});if(!l)return i.props[s]={type:"point",x:r.x,y:r.y},i;const c=this.editor.getShapeGeometry(l),u=ne.ZeroFix(c.bounds),h=this.editor.getShapePageTransform(i.id).applyToPoint(r),f=this.editor.getPointInShapeSpace(l,h);let y=o;if(!y){const v=i.props[s];(v.type==="point"||v.type==="binding"&&l.id!==v.boundShapeId)&&(y=this.editor.inputs.pointerVelocity.len()<.5)}if(!o){c.isClosed||(y=!0);const v=i.props[s==="start"?"end":"start"];v.type==="binding"&&l.id===v.boundShapeId&&v.isPrecise&&(y=!0)}const g={x:(f.x-u.minX)/u.width,y:(f.y-u.minY)/u.height};return y&&b.Dist(f,u.center)<Math.max(4,Math.min(Math.min(u.width,u.height)*.15,16))/this.editor.getZoomLevel()&&(g.x=.5,g.y=.5),i.props[s]={type:"binding",boundShapeId:l.id,normalizedAnchor:g,isPrecise:y,isExact:this.editor.inputs.altKey},i.props.start.type==="binding"&&i.props.end.type==="binding"&&i.props.start.boundShapeId===i.props.end.boundShapeId&&b.Equals(i.props.start.normalizedAnchor,i.props.end.normalizedAnchor)&&(i.props.end.normalizedAnchor.x+=.05),i});m(this,"onTranslateStart",t=>{const r=t.props.start.type==="binding"?t.props.start.boundShapeId:null,o=t.props.end.type==="binding"?t.props.end.boundShapeId:null,s=Ar(this.editor,t),i=this.editor.getShapePageTransform(t.id),a=this.editor.getSelectedShapeIds();if(r&&(a.includes(r)||this.editor.isAncestorSelected(r))||o&&(a.includes(o)||this.editor.isAncestorSelected(o)))return;let l=t;Y1.set(t,{pagePosition:i.applyToPoint(t),terminalBindings:np(s,(c,u)=>{const d=t.props[c];return d.type!=="binding"?null:{binding:d,shapePosition:u,pagePosition:i.applyToPoint(u)}})});for(const c of["start","end"]){const u=t.props[c];u.type==="binding"&&(l={...t,props:{...t.props,[c]:{...u,isPrecise:!0}}})}return l});m(this,"onTranslate",(t,r)=>{const o=Y1.get(t);if(!o)return;const s=this.editor.getShapePageTransform(r.id),i=b.Sub(s.applyToPoint(r),o.pagePosition);let a=r;for(const[l,c]of oo(o.terminalBindings)){if(!c)continue;const u=b.Add(c.pagePosition,b.Mul(i,.5)),d=this.editor.getShapeAtPoint(u,{hitInside:!0,hitFrameInside:!0,margin:0,filter:h=>!h.isLocked&&this.editor.getShapeUtil(h).canBind(h)});if((d==null?void 0:d.id)===c.binding.boundShapeId){const h=ne.ZeroFix(this.editor.getShapeGeometry(d).bounds),f=this.editor.getPointInShapeSpace(d,u),y={x:(f.x-h.minX)/h.width,y:(f.y-h.minY)/h.height};a={...a,props:{...a.props,[l]:{...c.binding,isPrecise:!0,normalizedAnchor:y}}}}else a={...a,props:{...a.props,[l]:{type:"point",x:c.shapePosition.x,y:c.shapePosition.y}}}}return a});m(this,"onResize",(t,r)=>{const{scaleX:o,scaleY:s}=r,i=Ar(this.editor,t),{start:a,end:l}=pr(t.props);let{bend:c}=t.props;a.type==="point"&&(a.x=i.start.x*o,a.y=i.start.y*s),l.type==="point"&&(l.x=i.end.x*o,l.y=i.end.y*s);const u=Math.abs(o),d=Math.abs(s);return o<0&&s>=0?(c!==0&&(c*=-1,c*=Math.max(u,d)),a.type==="binding"&&(a.normalizedAnchor.x=1-a.normalizedAnchor.x),l.type==="binding"&&(l.normalizedAnchor.x=1-l.normalizedAnchor.x)):o>=0&&s<0?(c!==0&&(c*=-1,c*=Math.max(u,d)),a.type==="binding"&&(a.normalizedAnchor.y=1-a.normalizedAnchor.y),l.type==="binding"&&(l.normalizedAnchor.y=1-l.normalizedAnchor.y)):o>=0&&s>=0?c!==0&&(c*=Math.max(u,d)):o<0&&s<0&&(c!==0&&(c*=Math.max(u,d)),a.type==="binding"&&(a.normalizedAnchor.x=1-a.normalizedAnchor.x,a.normalizedAnchor.y=1-a.normalizedAnchor.y),l.type==="binding"&&(l.normalizedAnchor.x=1-l.normalizedAnchor.x,l.normalizedAnchor.y=1-l.normalizedAnchor.y)),{props:{start:a,end:l,bend:c}}});m(this,"onDoubleClickHandle",(t,r)=>{switch(r.id){case"start":return{id:t.id,type:t.type,props:{...t.props,arrowheadStart:t.props.arrowheadStart==="none"?"arrow":"none"}};case"end":return{id:t.id,type:t.type,props:{...t.props,arrowheadEnd:t.props.arrowheadEnd==="none"?"arrow":"none"}}}});m(this,"onEditEnd",t=>{const{id:r,type:o,props:{text:s}}=t;s.trimEnd()!==t.props.text&&this.editor.updateShapes([{id:r,type:o,props:{text:s.trimEnd()}}])})}getDefaultProps(){return{dash:"draw",size:"m",fill:"none",color:"black",labelColor:"black",bend:0,start:{type:"point",x:0,y:0},end:{type:"point",x:2,y:0},arrowheadStart:"none",arrowheadEnd:"arrow",text:"",labelPosition:.5,font:"draw"}}getGeometry(t){const r=this.editor.getArrowInfo(t),o=[],s=r.isStraight?new jc({start:b.From(r.start.point),end:b.From(r.end.point)}):new I_({center:b.Cast(r.handleArc.center),radius:r.handleArc.radius,start:b.Cast(r.start.point),end:b.Cast(r.end.point),sweepFlag:r.bodyArc.sweepFlag,largeArcFlag:r.bodyArc.largeArcFlag});let i;if(t.props.text.trim()){const a=H1(this.editor,t);o.push(...a.debugGeom),i=new js({x:a.box.x,y:a.box.y,width:a.box.w,height:a.box.h,isFilled:!0,isLabel:!0})}return new no({children:[...i?[s,i]:[s],...o]})}getLength(t){const r=this.editor.getArrowInfo(t);return r.isStraight?b.Dist(r.start.handle,r.end.handle):Math.abs(r.handleArc.length)}getHandles(t){const r=this.editor.getArrowInfo(t);return[{id:"start",type:"vertex",index:"a0",x:r.start.handle.x,y:r.start.handle.y,canBind:!0},{id:"middle",type:"virtual",index:"a2",x:r.middle.x,y:r.middle.y,canBind:!1},{id:"end",type:"vertex",index:"a3",x:r.end.handle.x,y:r.end.handle.y,canBind:!0}].filter(Boolean)}component(t){const r=Mt(),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=this.editor.getArrowInfo(t),a=ne.ZeroFix(this.editor.getShapeGeometry(t).bounds),l=ie.useMemo(()=>this.editor.environment.isSafari?ZH+=1:0,[t]);if(!(i!=null&&i.isValid))return null;const c=Pt[t.props.size],u=i.start.arrowhead&&ta(i,"start",c),d=i.end.arrowhead&&ta(i,"end",c),h=i.isStraight?fm(i):pm(i);let f=null;if(o===t&&s){const{strokeDasharray:P,strokeDashoffset:E}=nn(this.getLength(t),2,{end:"skip",start:"skip",lengthRatio:2.5});f=t.props.start.type==="binding"||t.props.end.type==="binding"?p.jsx("path",{className:"tl-arrow-hint",d:i.isStraight?XH(i):YH(i),strokeDasharray:P,strokeDashoffset:E,strokeWidth:2,markerStart:t.props.start.type==="binding"?t.props.start.isExact?"":t.props.start.isPrecise?"url(#arrowhead-cross)":"url(#arrowhead-dot)":"",markerEnd:t.props.end.type==="binding"?t.props.end.isExact?"":t.props.end.isPrecise?"url(#arrowhead-cross)":"url(#arrowhead-dot)":"",opacity:.16}):null}const{strokeDasharray:y,strokeDashoffset:g}=nn(i.isStraight?i.length:Math.abs(i.bodyArc.length),c,{style:t.props.dash}),v=H1(this.editor,t),S=!(i.start.arrowhead==="none"||i.start.arrowhead==="arrow"),w=!(i.end.arrowhead==="none"||i.end.arrowhead==="arrow"),C=(t.id+"_clip_"+l).replace(":","_");return p.jsxs(p.Fragment,{children:[p.jsxs(Vn,{id:t.id,style:{minWidth:50,minHeight:50},children:[p.jsx("defs",{children:p.jsxs("mask",{id:C,children:[p.jsx("rect",{x:j(-100+a.minX),y:j(-100+a.minY),width:j(a.width+200),height:j(a.height+200),fill:"white"}),t.props.text.trim()&&p.jsx("rect",{x:v.box.x,y:v.box.y,width:v.box.w,height:v.box.h,fill:"black",rx:4,ry:4}),u&&S&&p.jsx("path",{d:u,fill:i.start.arrowhead==="arrow"?"none":"black",stroke:"none"}),d&&w&&p.jsx("path",{d,fill:i.end.arrowhead==="arrow"?"none":"black",stroke:"none"})]})}),p.jsxs("g",{fill:"none",stroke:r[t.props.color].solid,strokeWidth:c,strokeLinejoin:"round",strokeLinecap:"round",pointerEvents:"none",children:[f,p.jsxs("g",{mask:`url(#${C})`,children:[p.jsx("rect",{x:j(a.minX-100),y:j(a.minY-100),width:j(a.width+200),height:j(a.height+200),opacity:0}),p.jsx("path",{d:h,strokeDasharray:y,strokeDashoffset:g})]}),u&&S&&t.props.fill!=="none"&&p.jsx(ft,{theme:r,d:u,color:t.props.color,fill:t.props.fill}),d&&w&&t.props.fill!=="none"&&p.jsx(ft,{theme:r,d,color:t.props.color,fill:t.props.fill}),u&&p.jsx("path",{d:u}),d&&p.jsx("path",{d})]})]}),p.jsx(qH,{id:t.id,text:t.props.text,font:t.props.font,size:t.props.size,position:v.box.center,width:v.box.w,labelColor:r[t.props.labelColor].solid})]})}indicator(t){const{start:r,end:o}=Ar(this.editor,t),s=this.editor.getArrowInfo(t),i=this.editor.getShapeGeometry(t),a=i.bounds,l=t.props.text.trim()?i.children[1]:null,c=xf(t.id);if(!s||b.Equals(r,o))return null;const u=Pt[t.props.size],d=s.start.arrowhead&&ta(s,"start",u),h=s.end.arrowhead&&ta(s,"end",u),f=s.isStraight?fm(s):pm(s),y=d&&s.start.arrowhead!=="arrow"||h&&s.end.arrowhead!=="arrow"||!!l,g=(t.id+"_clip").replace(":","_");return c&&l?p.jsx("rect",{x:j(l.x),y:j(l.y),width:l.w,height:l.h,rx:3.5,ry:3.5}):p.jsxs("g",{children:[y&&p.jsx("defs",{children:p.jsxs("mask",{id:g,children:[p.jsx("rect",{x:a.minX-100,y:a.minY-100,width:a.w+200,height:a.h+200,fill:"white"}),l&&p.jsx("rect",{x:j(l.x),y:j(l.y),width:l.w,height:l.h,fill:"black",rx:3.5,ry:3.5}),d&&p.jsx("path",{d,fill:s.start.arrowhead==="arrow"?"none":"black",stroke:"none"}),h&&p.jsx("path",{d:h,fill:s.end.arrowhead==="arrow"?"none":"black",stroke:"none"})]})}),p.jsxs("g",{...y?{mask:`url(#${g})`}:void 0,children:[y&&p.jsx("rect",{x:a.minX-100,y:a.minY-100,width:a.width+200,height:a.height+200,opacity:0}),p.jsx("path",{d:f})]}),d&&p.jsx("path",{d}),h&&p.jsx("path",{d:h}),l&&p.jsx("rect",{x:j(l.x),y:j(l.y),width:l.w,height:l.h,rx:3.5,ry:3.5})]})}toSvg(t,r){const o=Dn({isDarkMode:r.isDarkMode});r.addExportDef($0(t.props.fill,o));const s=o[t.props.color].solid,i=this.editor.getArrowInfo(t),a=Pt[t.props.size],l=document.createElementNS("http://www.w3.org/2000/svg","g");if(!i)return l;const c=i.start.arrowhead&&ta(i,"start",a),u=i.end.arrowhead&&ta(i,"end",a),d=this.editor.getShapeGeometry(t),h=d.bounds,f=t.props.text.trim()?d.children[1]:null,y=(t.id+"_clip").replace(":","_");if(c||u||f){const I=document.createElementNS("http://www.w3.org/2000/svg","defs"),P=document.createElementNS("http://www.w3.org/2000/svg","mask");P.id=y;const E=document.createElementNS("http://www.w3.org/2000/svg","rect");if(E.setAttribute("x",h.minX-100+""),E.setAttribute("y",h.minY-100+""),E.setAttribute("width",h.width+200+""),E.setAttribute("height",h.height+200+""),E.setAttribute("fill","white"),P.appendChild(E),c&&P.appendChild(W1(c,i.start.arrowhead)),u&&P.appendChild(W1(u,i.end.arrowhead)),f){const _=document.createElementNS("http://www.w3.org/2000/svg","rect");_.setAttribute("x",f.x+""),_.setAttribute("y",f.y+""),_.setAttribute("width",f.w+""),_.setAttribute("height",f.h+""),_.setAttribute("fill","black"),P.appendChild(_)}I.appendChild(P),l.appendChild(I)}const g=document.createElementNS("http://www.w3.org/2000/svg","g");g.setAttribute("mask",`url(#${y})`),l.appendChild(g);const v=document.createElementNS("http://www.w3.org/2000/svg","rect");v.setAttribute("x","-100"),v.setAttribute("y","-100"),v.setAttribute("width",h.width+200+""),v.setAttribute("height",h.height+200+""),v.setAttribute("fill","transparent"),v.setAttribute("stroke","none"),g.appendChild(v);const S=QH(i.isStraight?fm(i):pm(i),s,a),{strokeDasharray:w,strokeDashoffset:C}=nn(i.isStraight?i.length:Math.abs(i.bodyArc.length),a,{style:t.props.dash});if(S.setAttribute("stroke-dasharray",w),S.setAttribute("stroke-dashoffset",C),g.appendChild(S),c&&l.appendChild(G1(c,t.props.color,a,t.props.arrowheadStart==="arrow"?"none":t.props.fill,o)),u&&l.appendChild(G1(u,t.props.color,a,t.props.arrowheadEnd==="arrow"?"none":t.props.fill,o)),f){r.addExportDef(Tf(t.props.font));const I={fontSize:hs[t.props.size],lineHeight:Ut.lineHeight,fontFamily:mu[t.props.font],padding:0,textAlign:"middle",width:f.w-8,verticalTextAlign:"middle",height:f.h,fontStyle:"normal",fontWeight:"normal",overflow:"wrap"},P=kf(this.editor,this.editor.textMeasure.measureTextSpans(t.props.text,I),I);P.setAttribute("fill",o[t.props.labelColor].solid),Array.from(P.children).forEach(k=>{const M=parseFloat(k.getAttribute("x")||"0"),T=parseFloat(k.getAttribute("y")||"0");k.setAttribute("x",M+4+f.x+"px"),k.setAttribute("y",T+f.y+"px")});const _=P.cloneNode(!0);_.setAttribute("stroke-width","2"),_.setAttribute("fill",o.background),_.setAttribute("stroke",o.background),l.appendChild(_),l.appendChild(P)}return l}getCanvasSvgDefs(){return[M0()]}}m(wh,"type","arrow"),m(wh,"props",WI),m(wh,"migrations",GI);function W1(e,n){const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",e),t.setAttribute("fill",n==="arrow"?"none":"black"),t.setAttribute("stroke","none"),t}function QH(e,n,t){const r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d",e),r.setAttribute("fill","none"),r.setAttribute("stroke",n),r.setAttribute("stroke-width",t+""),r}function G1(e,n,t,r,o){const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",e),s.setAttribute("fill","none"),s.setAttribute("stroke",o[n].solid),s.setAttribute("stroke-width",t+"");const i=er({d:e,fill:r,color:n,theme:o});if(i){const a=document.createElementNS("http://www.w3.org/2000/svg","g");return a.appendChild(i),a.appendChild(s),a}else return s}const Y1=new WeakMap,X1="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 $u({url:e,zoomLevel:n}){return p.jsx("a",{className:fe("tl-hyperlink-button",{"tl-hyperlink-button__hidden":n<.32}),href:e,target:"_blank",rel:"noopener noreferrer",onPointerDown:It,onPointerUp:It,title:e,draggable:!1,children:p.jsx("div",{className:"tl-hyperlink-button__icon",style:{mask:`url("${X1}") center 100% / 100% no-repeat`,WebkitMask:`url("${X1}") center 100% / 100% no-repeat`}})})}const JH=[{offsetX:0,offsetY:2,blur:4,spread:0,color:"#00000029"},{offsetX:0,offsetY:3,blur:6,spread:0,color:"#0000001f"}];function O0(e){return JH.map(t=>{const{offsetX:r,offsetY:o,blur:s,spread:i,color:a}=t,l=new b(r,o),{x:c,y:u}=l.rot(-e);return`${c}px ${u}px ${s}px ${i}px ${a}`}).join(", ")}class xh extends al{constructor(){super(...arguments);m(this,"canResize",()=>!1);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"onBeforeCreate",t=>{q1(this.editor,t)});m(this,"onBeforeUpdate",(t,r)=>{if(t.props.url!==r.props.url)if(Qn.isValid(r.props.url))q1(this.editor,r);else return{...r,props:{...r.props,url:t.props.url}}})}getDefaultProps(){return{url:"",w:300,h:320,assetId:null}}component(t){const r=t.props.assetId?this.editor.getAsset(t.props.assetId):null,o=this.editor.getShapePageTransform(t).rotation(),s=eK(t);return p.jsx(wi,{children:p.jsxs("div",{className:"tl-bookmark__container",style:{boxShadow:O0(o)},children:[p.jsxs("div",{className:"tl-bookmark__image_container",children:[r!=null&&r.props.image?p.jsx("img",{className:"tl-bookmark__image",draggable:!1,src:r==null?void 0:r.props.image,alt:(r==null?void 0:r.props.title)||""}):p.jsx("div",{className:"tl-bookmark__placeholder"}),p.jsx($u,{url:t.props.url,zoomLevel:this.editor.getZoomLevel()})]}),p.jsxs("div",{className:"tl-bookmark__copy_container",children:[(r==null?void 0:r.props.title)&&p.jsx("h2",{className:"tl-bookmark__heading",children:uc((r==null?void 0:r.props.title)||"",54)}),(r==null?void 0:r.props.description)&&p.jsx("p",{className:"tl-bookmark__description",children:uc((r==null?void 0:r.props.description)||"",128)}),p.jsx("a",{className:"tl-bookmark__link",href:t.props.url||"",target:"_blank",rel:"noopener noreferrer",onPointerDown:It,onPointerUp:It,onClick:It,children:uc(s,45)})]})]})})}indicator(t){return p.jsx("rect",{width:j(t.props.w),height:j(t.props.h),rx:"6",ry:"6"})}}m(xh,"type","bookmark"),m(xh,"props",YI),m(xh,"migrations",XI);const eK=e=>{try{const n=new URL(e.props.url),t=n.pathname.replace(/\/*$/,"");return`${n.hostname}${t}`}catch{return e.props.url}};function q1(e,n){const{url:t}=n.props,r=li.createId(Ty(t));e.getAsset(r)?n.props.assetId!==r&&e.updateShapes([{id:n.id,type:n.type,props:{assetId:r}}]):(e.updateShapes([{id:n.id,type:n.type,props:{assetId:null}}]),tK(e,n))}const tK=kI(async(e,n)=>{const{url:t}=n.props,r=await e.getAssetForExternalContent({type:"url",url:t});r&&e.batch(()=>{e.createAssets([r]),e.updateShapes([{id:n.id,type:n.type,props:{assetId:r.id}}])})},500);function ys(e,n=!1){const t=e.length;if(t<2)return"";let r=e[0].point,o=e[1].point;if(t===2)return`M${Nt(r)}L${Nt(o)}`;let s="";for(let i=2,a=t-1;i<a;i++)r=e[i].point,o=e[i+1].point,s+=Pn(r,o);return n?`M${Pn(e[0].point,e[1].point)}Q${Nt(e[1].point)}${Pn(e[1].point,e[2].point)}T${s}${Pn(e[t-1].point,e[0].point)}${Pn(e[0].point,e[1].point)}Z`:`M${Nt(e[0].point)}Q${Nt(e[1].point)}${Pn(e[1].point,e[2].point)}${e.length>3?"T":""}${s}L${Nt(e[t-1].point)}`}function nK(e,n={}){const{start:t={},end:r={}}=n,{cap:o=!0}=t,{cap:s=!0}=r;Do(!t.taper&&!r.taper,"cap taper not supported here"),Do(!t.easing&&!r.easing,"cap easing not supported here"),Do(o&&s,"cap must be true");const i=jr(e,n);hl(i,n);const a=rK(i);let l="";for(const c of a)l+=sK(c,n);return l}function rK(e){if(e.length<=2)return[e];const n=[];let t=[e[0]];for(let r=1;r<e.length-1;r++){const o=e[r-1],s=e[r],i=e[r+1],a=b.Angle(o.point,s.point),l=b.Angle(s.point,i.point),c=Math.abs(ac(a,l))/Math.PI;if(c>.8){const y={...s,point:s.input};t.push(y),n.push(gm(t)),t=[y];continue}if(t.push(s),c<.25)continue;const u=(o.radius+s.radius+i.radius)/3,d=b.Dist(o.point,s.point)/u,h=b.Dist(s.point,i.point)/u;if(d+h<1.5){t.push(s),n.push(gm(t)),t=[s];continue}}return t.push(e[e.length-1]),n.push(gm(t)),n}function gm(e){const n=e[0];for(;e.length>2;){const r=e[1],o=b.Dist(n.point,r.point),s=(n.radius+r.radius)/2;if(o<s*.5)e.splice(1,1);else break}const t=e[e.length-1];for(;e.length>2;){const r=e[e.length-2],o=b.Dist(t.point,r.point),s=(t.radius+r.radius)/2;if(o<s*.5)e.splice(e.length-2,1);else break}return e.length>1&&(e[0]={...e[0],vector:b.FromAngle(b.Angle(e[1].point,e[0].point))},e[e.length-1]={...e[e.length-1],vector:b.FromAngle(b.Angle(e[e.length-1].point,e[e.length-2].point))}),e}function oK(e,n,t){return"M "+e+" "+n+" m -"+t+", 0 a "+t+","+t+" 0 1,1 "+t*2+",0 a "+t+","+t+" 0 1,1 -"+t*2+",0"}function sK(e,n={}){if(e.length===0)return"";if(e.length===1)return oK(e[0].point.x,e[0].point.y,e[0].radius);const{left:t,right:r}=kk(e,n);r.reverse();let o=`M${Nt(t[0])}T`;for(let s=1;s<t.length;s++)o+=Pn(t[s-1],t[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+=`${Nt(l)}A${j(i)},${j(i)} 0 0 1 ${Nt(c)}T`}for(let s=1;s<r.length;s++)o+=Pn(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+=`${Nt(l)}A${j(i)},${j(i)} 0 0 1 ${Nt(c)}Z`}return o}function kp(){const e=F();return K("zoom",()=>e.getZoomLevel()<.35,[e])}const iK=e=>e*.65+TR(e*$e/2)*.35,aK=e=>({size:1+e,thinning:.5,streamline:.62+(1+e)/8*.06,smoothing:.62,easing:tn.easeOutSine,simulatePressure:!0}),lK=e=>({size:1+e*1.2,thinning:.62,streamline:.62,smoothing:.62,simulatePressure:!1,easing:iK}),Z1=e=>({size:1+e,thinning:0,streamline:.62+(1+e)/8*.06,smoothing:.62,simulatePressure:!1,easing:tn.linear});function cS({strokeWidth:e,showAsComplete:n}){return{size:1+e,thinning:0,streamline:.5,smoothing:.5,simulatePressure:!1,easing:tn.easeOutSine,last:n}}function xd(e,n,t,r){return{...r?Z1(n):e.dash==="draw"?e.isPen?lK(n):aK(n):Z1(n),last:e.isComplete||t}}function ma(e){const n=[];for(const t of e)if(t.type==="free"||t.points.length<2)n.push(...t.points.map(b.Cast));else{const r=Math.max(4,Math.floor(b.Dist(t.points[0],t.points[1])/16));n.push(...b.PointsBetween(t.points[0],t.points[1],r))}return n}function Q1(e,n){return{draw:"none",solid:"none",dotted:`0.1 ${n*2}`,dashed:`${n*2} ${n*2}`}[e.props.dash]}class bh extends Lr{constructor(){super(...arguments);m(this,"hideResizeHandles",t=>ym(t));m(this,"hideRotateHandle",t=>ym(t));m(this,"hideSelectionBoundsFg",t=>ym(t));m(this,"onResize",(t,r)=>{const{scaleX:o,scaleY:s}=r,i=[];for(const a of t.props.segments)i.push({...a,points:a.points.map(({x:l,y:c,z:u})=>({x:pp(o*l),y:pp(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}}getGeometry(t){const r=ma(t.props.segments),o=Pt[t.props.size];if(t.props.segments.length===1){const i=ne.FromPoints(r);if(i.width<o*2&&i.height<o*2)return new a0({x:-o,y:-o,radius:o,isFilled:!0})}const s=jr(r,xd(t.props,o,!0,!0)).map(i=>i.point);return t.props.isClosed?new vt({points:s,isFilled:t.props.fill!=="none"}):new Oi({points:s})}component(t){var f;const r=Mt(),o=kp(),s=Pt[t.props.size],i=ma(t.props.segments),a=t.props.isComplete||((f=xn(t.props.segments))==null?void 0:f.type)==="straight";let l=s;!o&&!t.props.isPen&&t.props.dash==="draw"&&i.length===1&&(l+=ws(t.id)()*(s/6));const c=xd(t.props,l,a,o);if(!o&&t.props.dash==="draw")return p.jsxs(Vn,{id:t.id,children:[t.props.isClosed&&t.props.fill&&i.length>1?p.jsx(ft,{theme:r,fill:t.props.isClosed?t.props.fill:"none",color:t.props.color,d:ys(jr(i,c),t.props.isClosed)}):null,p.jsx("path",{d:nK(i,c),strokeLinecap:"round",fill:r[t.props.color].solid})]});const u=jr(i,c),d=u.length<2,h=d?mm(i[0],0):ys(u,t.props.isClosed);return p.jsxs(Vn,{id:t.id,children:[p.jsx(ft,{theme:r,color:t.props.color,fill:d||t.props.isClosed?t.props.fill:"none",d:h}),p.jsx("path",{d:h,strokeLinecap:"round",fill:d?r[t.props.color].solid:"none",stroke:r[t.props.color].solid,strokeWidth:s,strokeDasharray:d?"none":Q1(t,s),strokeDashoffset:"0"})]})}indicator(t){var d;const r=kp(),o=Pt[t.props.size],s=ma(t.props.segments);let i=o;!r&&!t.props.isPen&&t.props.dash==="draw"&&s.length===1&&(i+=ws(t.id)()*(o/6));const a=t.props.isComplete||((d=xn(t.props.segments))==null?void 0:d.type)==="straight",l=xd(t.props,i,a,!0),c=jr(s,l),u=c.length>1?ys(c,t.props.isClosed):mm(s[0],i);return p.jsx("path",{d:u})}toSvg(t,r){var g;const o=Dn({isDarkMode:r.isDarkMode});r.addExportDef($0(t.props.fill,o));const{color:s}=t.props,i=Pt[t.props.size],a=ma(t.props.segments),l=t.props.isComplete||((g=xn(t.props.segments))==null?void 0:g.type)==="straight";let c=i;!t.props.isPen&&t.props.dash==="draw"&&a.length===1&&(c+=ws(t.id)()*(i/6));const u=xd(t.props,c,l,!1),d=jr(a,u),h=d.length>1?ys(d,t.props.isClosed):mm(a[0],c);let f;if(t.props.dash==="draw"||d.length<2){hl(d,u);const v=Tu(d,u),S=document.createElementNS("http://www.w3.org/2000/svg","path");S.setAttribute("d",bu(v,!0)),S.setAttribute("fill",o[s].solid),S.setAttribute("stroke-linecap","round"),f=S}else{const v=document.createElementNS("http://www.w3.org/2000/svg","path");v.setAttribute("d",h),v.setAttribute("stroke",o[s].solid),v.setAttribute("fill","none"),v.setAttribute("stroke-linecap","round"),v.setAttribute("stroke-width",i.toString()),v.setAttribute("stroke-dasharray",Q1(t,i)),v.setAttribute("stroke-dashoffset","0"),f=v}const y=er({fill:t.props.isClosed?t.props.fill:"none",d:h,color:t.props.color,theme:o});if(y){const v=document.createElementNS("http://www.w3.org/2000/svg","g");return v.appendChild(y),v.appendChild(f),v}return f}getCanvasSvgDefs(){return[M0()]}expandSelectionOutlinePx(t){const r=t.props.dash==="draw"?1.6:1;return Pt[t.props.size]*r/2}}m(bh,"type","draw"),m(bh,"props",ZI),m(bh,"migrations",QI);function mm(e,n){const t=(n+1)*.5;return`M ${e.x} ${e.y} m -${t}, 0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0`}function ym(e){return e.props.segments.length===1&&e.props.segments[0].points.length<2}function cK(e,n,t={}){const{newPoint:r,handle:o,scaleX:s,scaleY:i}=n,{minWidth:a=1,maxWidth:l=1/0,minHeight:c=1,maxHeight:u=1/0}=t;let d=e.props.w*s,h=e.props.h*i;const f=new b(0,0);if(d>0){if(d<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=d-a;break}case"top":case"bottom":{f.x=(d-a)/2;break}default:f.x=0}d=a}}else if(f.x=d,d=-d,d<a){switch(o){case"top_left":case"left":case"bottom_left":{f.x=-d;break}default:f.x=-a}d=a}if(h>0){if(h<c){switch(o){case"top_left":case"top":case"top_right":{f.y=h-c;break}case"right":case"left":{f.y=(h-c)/2;break}default:f.y=0}h=c}}else if(f.y=h,h=-h,h<c){switch(o){case"top_left":case"top":case"top_right":{f.y=-h;break}default:f.y=-c}h=c}const{x:y,y:g}=f.rot(e.rotation).add(r);return{x:y,y:g,props:{w:Math.min(l,d),h:Math.min(u,h)}}}const uK=e=>Object.entries(e).filter(([n,t])=>t).map(([n])=>n).join(" ");class Ph extends al{constructor(){super(...arguments);m(this,"hideSelectionBoundsFg",t=>!this.canResize(t));m(this,"canEdit",()=>!0);m(this,"canUnmount",t=>{var r,o;return!!((o=(r=Ao(t.props.url))==null?void 0:r.definition)!=null&&o.canUnmount)});m(this,"canResize",t=>{var r,o;return!!((o=(r=Ao(t.props.url))==null?void 0:r.definition)!=null&&o.doesResize)});m(this,"canEditInReadOnly",()=>!0);m(this,"isAspectRatioLocked",t=>{const r=Ao(t.props.url);return(r==null?void 0:r.definition.isAspectRatioLocked)??!1});m(this,"onResize",(t,r)=>{const o=this.isAspectRatioLocked(t),s=Ao(t.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=t.props.w/t.props.h;l>1?i*=l:a/=l}return cK(t,r,{minWidth:i,minHeight:a})})}getDefaultProps(){return{w:300,h:300,url:""}}component(t){const{w:r,h:o,url:s}=t.props,i=xf(t.id),a=x.useMemo(()=>Ak(s),[s]),l=K("is hovering",()=>{const{editingShapeId:h,hoveredShapeId:f}=this.editor.getCurrentPageState();if(h&&f!==h){const y=this.editor.getShape(h);if(y&&this.editor.isShapeOfType(y,"embed"))return!0}return!1},[]),c=this.editor.getShapePageTransform(t).rotation(),u=i||l;if((a==null?void 0:a.definition.type)==="github_gist"){const h=a.url.split("/").pop();if(!h)throw Error("No gist id!");return p.jsx(wi,{className:"tl-embed-container",id:t.id,children:p.jsx(dK,{id:h,width:j(r),height:j(o),isInteractive:u,pageRotation:c})})}const d=uK({...mR,...(a==null?void 0:a.definition.overridePermissions)??{}});return p.jsx(wi,{className:"tl-embed-container",id:t.id,children:a!=null&&a.definition?p.jsx("iframe",{className:"tl-embed",sandbox:d,src:a.embedUrl,width:j(r),height:j(o),draggable:!1,frameBorder:"0",referrerPolicy:"no-referrer-when-downgrade",style:{border:0,pointerEvents:u?"auto":"none",zIndex:u?"":"-1",boxShadow:O0(c),borderRadius:(a==null?void 0:a.definition.overrideOutlineRadius)??8,background:a==null?void 0:a.definition.backgroundColor}}):null})}indicator(t){const r=x.useMemo(()=>Ao(t.props.url),[t.props.url]);return p.jsx("rect",{width:j(t.props.w),height:j(t.props.h),rx:(r==null?void 0:r.definition.overrideOutlineRadius)??8,ry:(r==null?void 0:r.definition.overrideOutlineRadius)??8})}}m(Ph,"type","embed"),m(Ph,"props",JI),m(Ph,"migrations",eE);function dK({id:e,file:n,isInteractive:t,width:r,height:o,style:s,pageRotation:i}){return p.jsx("iframe",{className:"tl-embed",draggable:!1,width:j(r),height:j(o),frameBorder:"0",scrolling:"no",seamless:!0,referrerPolicy:"no-referrer-when-downgrade",style:{...s,pointerEvents:t?"all":"none",zIndex:t?"":"-1",boxShadow:O0(i)},srcDoc:`
|
|
139
|
+
<html>
|
|
140
|
+
<head>
|
|
141
|
+
<base target="_blank">
|
|
142
|
+
</head>
|
|
143
|
+
<body>
|
|
144
|
+
<script src=${`https://gist.github.com/${e}.js${n?`?file=${n}`:""}`}><\/script>
|
|
145
|
+
<style type="text/css">
|
|
146
|
+
* { margin: 0px; }
|
|
147
|
+
table { height: 100%; background-color: red; }
|
|
148
|
+
.gist { background-color: none; height: 100%; }
|
|
149
|
+
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
|
|
150
|
+
</style>
|
|
151
|
+
</body>
|
|
152
|
+
</html>`})}const hK=x.forwardRef(({id:e,name:n,isEditing:t},r)=>{const o=F(),s=x.useCallback(l=>{l.key==="Enter"&&!l.nativeEvent.isComposing&&(It(l),l.currentTarget.blur(),o.setEditingShape(null))},[o]),i=x.useCallback(l=>{const c=o.getShape(e);if(!c)return;const u=c.props.name,d=l.currentTarget.value.trim();u!==d&&o.updateShapes([{id:e,type:"frame",props:{name:d}}],{squashing:!0})},[e,o]),a=x.useCallback(l=>{const c=o.getShape(e);if(!c)return;const u=c.props.name,d=l.currentTarget.value;u!==d&&o.updateShapes([{id:e,type:"frame",props:{name:d}}],{squashing:!0})},[e,o]);return p.jsxs("div",{className:`tl-frame-label ${t?"tl-frame-label__editing":""}`,children:[p.jsx("input",{className:"tl-frame-name-input",ref:r,style:{display:t?void 0:"none"},value:n,autoFocus:!0,onKeyDown:s,onBlur:i,onChange:a}),Nk(n,"Frame")+""]})}),pK=function({id:n,name:t,width:r,height:o}){const s=F(),i=K("shape rotation",()=>Rr(s.getShapePageTransform(n).rotation()),[s,n]),a=xf(n),l=x.useRef(null),c=x.useCallback(y=>{const g=In(y);s.getEditingShapeId()!==n&&(s.dispatch({type:"pointer",name:"pointer_down",target:"shape",shape:s.getShape(n),...g}),y.preventDefault())},[s,n]);x.useEffect(()=>{const y=l.current;y&&a&&(y.focus(),y.select(),requestAnimationFrame(()=>{document.activeElement!==y&&(y.focus(),y.select())}))},[l,a]);const d=((i+Math.PI/4)*(2/Math.PI)+4)%4,h=["top","left","bottom","right"][Math.floor(d)];let f;switch(h){case"top":f="";break;case"right":f=`translate(${j(r)}px, 0px) rotate(90deg)`;break;case"bottom":f=`translate(${j(r)}px, ${j(o)}px) rotate(180deg)`;break;case"left":f=`translate(0px, ${j(o)}px) rotate(270deg)`;break}return p.jsx("div",{className:"tl-frame-heading",style:{overflow:a?"visible":"hidden",maxWidth:`calc(var(--tl-zoom) * ${Math.ceil(h==="top"||h==="bottom"?r:o)}px + var(--space-5))`,bottom:"100%",transform:`${f} scale(var(--tl-scale)) translateX(calc(-1 * var(--space-3))`},onPointerDown:c,children:p.jsx("div",{className:"tl-frame-heading-hit-area",children:p.jsx(hK,{ref:l,id:n,name:t,isEditing:a})})})};function Nk(e,n){return e.match(/^\s*$/)?n:e}class Ch extends al{constructor(){super(...arguments);m(this,"canBind",()=>!0);m(this,"canEdit",()=>!0);m(this,"canReceiveNewChildrenOfType",(t,r)=>!t.isLocked);m(this,"canDropShapes",(t,r)=>!t.isLocked);m(this,"onDragShapesOver",(t,r)=>r.every(o=>o.parentId===t.id)?{shouldHint:!1}:(this.editor.reparentShapes(r.map(o=>o.id),t.id),{shouldHint:!0}));m(this,"onDragShapesOut",(t,r)=>{const o=this.editor.getShape(t.parentId);o&&this.editor.isShapeOfType(o,"group")?this.editor.reparentShapes(r,o.id):this.editor.reparentShapes(r,this.editor.getCurrentPageId())});m(this,"onResizeEnd",t=>{const r=this.editor.getShapePageBounds(t),o=this.editor.getSortedChildIdsForParent(t.id),s=[];for(const i of o){const a=this.editor.getShapePageBounds(i);r.includes(a)||s.push(i)}s.length>0&&this.editor.reparentShapes(s,this.editor.getCurrentPageId())});m(this,"onResize",(t,r)=>C_(t,r))}getDefaultProps(){return{w:160*2,h:90*2,name:""}}getGeometry(t){return new js({width:t.props.w,height:t.props.h,isFilled:!1})}component(t){const r=this.editor.getShapeGeometry(t).bounds,o=Mt(),s=K("is creating this shape",()=>{var l;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&&((l=this.editor.getOnlySelectedShape())==null?void 0:l.id)===t.id:!1},[t.id]);return p.jsxs(p.Fragment,{children:[p.jsx(Vn,{children:p.jsx("rect",{className:fe("tl-frame__body",{"tl-frame__creating":s}),width:r.width,height:r.height,fill:o.solid,stroke:o.text})}),s?null:p.jsx(pK,{id:t.id,name:t.props.name,width:r.width,height:r.height})]})}toSvg(t,r){const o=Dn({isDarkMode:r.isDarkMode}),s=document.createElementNS("http://www.w3.org/2000/svg","g"),i=document.createElementNS("http://www.w3.org/2000/svg","rect");i.setAttribute("width",t.props.w.toString()),i.setAttribute("height",t.props.h.toString()),i.setAttribute("fill",o.solid),i.setAttribute("stroke",o.black.solid),i.setAttribute("stroke-width","1"),i.setAttribute("rx","1"),i.setAttribute("ry","1"),s.appendChild(i);const c=((Rr(this.editor.getShapePageTransform(t.id).rotation())+Math.PI/4)*(2/Math.PI)+4)%4,u=["top","left","bottom","right"][Math.floor(c)];let d;switch(u){case"top":d="";break;case"right":d=`translate(${j(t.props.w)}px, 0px) rotate(90deg)`;break;case"bottom":d=`translate(${j(t.props.w)}px, ${j(t.props.h)}px) rotate(180deg)`;break;case"left":d=`translate(0px, ${j(t.props.h)}px) rotate(270deg)`;break;default:d=""}const h={fontSize:12,fontFamily:"Inter, sans-serif",textAlign:"start",width:t.props.w,height:32,padding:0,lineHeight:1,fontStyle:"normal",fontWeight:"normal",overflow:"truncate-ellipsis",verticalTextAlign:"middle"},f=this.editor.textMeasure.measureTextSpans(Nk(t.props.name,"Frame")+"",h),y=f[0],g=xn(f),v=g.box.w+g.box.x-y.box.x,S=kf(this.editor,f,{offsetY:-h.height-2,...h});S.style.setProperty("transform",d);const w=document.createElementNS("http://www.w3.org/2000/svg","rect");return w.setAttribute("x","-8px"),w.setAttribute("y",-h.height-4+"px"),w.setAttribute("width",v+16+"px"),w.setAttribute("height",`${h.height}px`),w.setAttribute("rx","4px"),w.setAttribute("ry","4px"),w.setAttribute("fill",o.background),s.appendChild(w),s.appendChild(S),s}indicator(t){const r=this.editor.getShapeGeometry(t).bounds;return p.jsx("rect",{width:j(r.width),height:j(r.height),className:"tl-frame-indicator"})}providesBackgroundForChildren(){return!0}}m(Ch,"type","frame"),m(Ch,"props",tE),m(Ch,"migrations",nE);function fK(e,n,t,r){if((e==="start-legacy"||e==="end-legacy")&&t.length!==0){const o=ne.From(t[0].box);for(const{box:s}of t)o.union(s);if(e==="start-legacy")return(r-2*n-o.width)/2;if(e==="end-legacy")return-(r-2*n-o.width)/2}}function gK(e){return e==="start-legacy"||e==="middle-legacy"||e==="end-legacy"}const Fk=ie.memo(function({id:n,type:t,text:r,size:o,labelColor:s,font:i,align:a,verticalAlign:l,wrap:c,bounds:u}){const{rInput:d,isEmpty:h,isEditing:f,handleFocus:y,handleChange:g,handleKeyDown:v,handleBlur:S,handleInputPointerDown:w,handleDoubleClick:C}=j0(n,t,r),I=xs.normalizeTextForDom(r),P=I.length>0,E=gK(a),_=Mt();return!f&&!P?null:p.jsx("div",{className:"tl-text-label","data-font":i,"data-align":a,"data-hastext":!h,"data-isediting":f,"data-textwrap":!!c,style:{justifyContent:a==="middle"||E?"center":a,alignItems:l==="middle"?"center":l,...u?{top:u.minY,left:u.minX,width:u.width,height:u.height,position:"absolute"}:{}},children:p.jsxs("div",{className:"tl-text-label__inner",style:{fontSize:Ka[o],lineHeight:Ka[o]*Ut.lineHeight+"px",minHeight:Ut.lineHeight+32,minWidth:0,color:_[s].solid},children:[p.jsx("div",{className:"tl-text tl-text-content",dir:"ltr",children:I}),f&&p.jsx("textarea",{ref:d,className:"tl-text tl-text-input",name:"text",tabIndex:-1,autoComplete:"false",autoCapitalize:"false",autoCorrect:"false",autoSave:"false",autoFocus:!0,placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",datatype:"wysiwyg",defaultValue:r,onFocus:y,onChange:g,onKeyDown:v,onBlur:S,onTouchEnd:It,onContextMenu:It,onPointerDown:w,onDoubleClick:C})]})})});function zk({bounds:e,editor:n,font:t,shape:r}){const s={fontSize:Ka[r.props.size],fontFamily:t,textAlign:r.props.align,verticalTextAlign:r.props.verticalAlign,width:Math.ceil(e.width),height:Math.ceil(e.height),padding:16,lineHeight:Ut.lineHeight,fontStyle:"normal",fontWeight:"normal",overflow:"wrap",offsetX:0},i=n.textMeasure.measureTextSpans(r.props.text,s),a=fK(r.props.align,16,i,e.width);return a&&(s.offsetX=a),kf(n,i,s)}function Yt(e){return`${j(e.x)},${j(e.y)} `}function Bk(e=""){let n=0,t=0,r=0,o=0;function s(){const i=n^n<<11;return n=t,t=r,r=o,o^=(o>>>19^i^i>>>8)>>>0,o/4294967296*2}for(let i=0;i<e.length+64;i++)n^=e.charCodeAt(i)|0,s();return s}function Lc(e){let n="M";const t=e.length;let r,o,s;for(let i=0,a=t;i<a;i+=3)r=e[i],o=e[i+1],s=e[i+2],n+=`${Yt(r)}L${Yt(o)}Q${Yt(s)}`;return n+=`${Yt(e[0])}`,n}function Nc(e,n,t,r,o){const s=[],i=Bk(e);let a=n[0],l;const c=n.length;for(let u=0,d=c*o;u<d;u++){l=b.AddXY(n[(u+1)%c],i()*t,i()*t);const h=b.Sub(l,a),f=b.Len(h),y=b.Div(h,f).mul(Math.min(f/4,r));s.push(b.Add(a,y),b.Add(l,y.neg()),l),a=l}return s}function Sm(e,n,t){let r=`M ${Yt(n[0])}L`,o=`M ${Yt(n[0])}L`;const s=t/3,i=t*2,a=Bk(e);let l=n[0],c,u=n[0],d;const h=n.length;for(let f=0,y=h-1;f<y;f++){c=n[f+1],d=b.AddXY(n[f+1],a()*s,a()*s);const g=b.Sub(c,l),v=b.Len(g),S=b.Div(g,v).mul(Math.min(v/4,i)),w=b.Add(l,S),C=b.Add(c,S.neg()),I=b.Sub(d,u),P=b.Len(I),E=b.Div(I,P).mul(Math.min(P/4,i)),_=b.Add(u,E),k=b.Add(d,E.neg());f===y-1?(r+=`${Yt(w)}L ${Yt(c)}`,o+=`${Yt(_)}L ${Yt(d)}`):(r+=`${Yt(w)}L ${Yt(C)}Q ${Yt(c)}`,o+=`${Yt(_)}L ${Yt(k)}Q ${Yt(d)}`,l=c,u=d)}return[r,r+o]}function J1(e,n){const t=Math.min(e,n)/2,r=Math.max(e,n)-t*2;return Math.PI*(t*2)+2*r}function mK(e,n,t){const r=Math.min(e,n)/2,o=Math.max(e,n)-r*2,i=(Math.PI*(r*2)+2*o)/t,a=e>n?[{type:"straight",start:new b(r,0),delta:new b(1,0)},{type:"arc",center:new b(e-r,r),startAngle:-$e/2},{type:"straight",start:new b(e-r,n),delta:new b(-1,0)},{type:"arc",center:new b(r,r),startAngle:$e/2}]:[{type:"straight",start:new b(e,r),delta:new b(0,1)},{type:"arc",center:new b(r,n-r),startAngle:0},{type:"straight",start:new b(0,n-r),delta:new b(0,-1)},{type:"arc",center:new b(r,r),startAngle:$e}];let l=0;const c=[];for(let u=0;u<t;u++){const d=a[0];d.type==="straight"?c.push(b.Add(d.start,b.Mul(d.delta,l))):c.push(Si(d.center,r,d.startAngle+l/r)),l+=i;let h=d.type==="straight"?o:$e*r;for(;l>h;)l-=h,a.push(a.shift()),h=a[0].type==="straight"?o:$e*r}return c}const yK=(e,n,t,r,o)=>{switch(e){case"s":return n;case"m":return t;case"l":return r;case"xl":return o}};function Mu(e,n,t,r){const o=ws(t),s=J1(e,n),i=Math.max(Math.ceil(s/yK(r,50,70,100,130)),6,Math.ceil(s/Math.min(e,n))),a=s/i*.2,l=Math.max(e-a*2,1),c=Math.max(n-a*2,1),u=(e-l)/2,d=(n-c)/2,h=J1(l,c)/i,f=mK(l,c,i).map(w=>w.addXY(u,d)),y=e<20?0:a*.3,g=n<20?0:a*.3,v=f.slice(0);for(let w=0;w<Math.floor(i/2);w++)v[w]=b.AddXY(v[w],o()*y,o()*g),v[i-w-1]=b.AddXY(v[i-w-1],o()*y,o()*g);const S=[];for(let w=0;w<v.length;w++){const C=w===v.length-1?0:w+1,I=v[w],P=v[C],E=f[w],_=f[C],k=b.Average([E,_]),M=b.Angle(E,_)-Math.PI/2,T=b.Dist(E,_),R=h-T,U=b.Dist(I,P)/T,N=(Math.max(u,d)+R)*U,L=b.Add(k,b.FromAngle(M,N));L.x<0?L.x=0:L.x>e&&(L.x=e),L.y<0?L.y=0:L.y>n&&(L.y=n);const G=Uk(I,P,L),X=b.Dist(G||b.Average([I,P]),I);S.push({leftPoint:I,rightPoint:P,arcPoint:L,center:G,radius:X})}return S}function Uk(e,n,t){const r=e.x*(n.y-t.y)-e.y*(n.x-t.x)+n.x*t.y-t.x*n.y,o=(e.x*e.x+e.y*e.y)*(t.y-n.y)+(n.x*n.x+n.y*n.y)*(e.y-t.y)+(t.x*t.x+t.y*t.y)*(n.y-e.y),s=(e.x*e.x+e.y*e.y)*(n.x-t.x)+(n.x*n.x+n.y*n.y)*(t.x-e.x)+(t.x*t.x+t.y*t.y)*(e.x-n.x),i=-o/(2*r),a=-s/(2*r);return!Number.isFinite(i)||!Number.isFinite(a)?null:new b(i,a)}function SK(e,n,t,r){const o=[],s=Mu(e,n,t,r);for(const{center:i,radius:a,leftPoint:l,rightPoint:c}of s)o.push(...vK(l,c,i,a,10));return o}function Au(e,n,t,r){const o=Mu(e,n,t,r);let s=`M${j(o[0].leftPoint.x)},${j(o[0].leftPoint.y)}`;for(const{leftPoint:i,rightPoint:a,radius:l,center:c}of o){if(c===null){s+=` L${j(a.x)},${j(a.y)}`;continue}const u=Kk(i,a,c)?"0":"1";s+=` A${j(l)},${j(l)} 0 ${u},1 ${j(a.x)},${j(a.y)}`}return s+=" Z",s}function Hk(e,n,t,r){const o=ws(t),s=r==="s"?.5:r==="m"?.7:r==="l"?.9:1.6,i=y=>y+o()*s*2,a=Mu(e,n,t,r),u=a.reduce((y,g)=>y+b.Dist(g.leftPoint,g.rightPoint),0)/a.length>s*15?y=>new b(i(y.x),i(y.y)):y=>y;let d=`M${j(a[0].leftPoint.x)},${j(a[0].leftPoint.y)}`,h=u(a[0].leftPoint),f=`M${j(h.x)},${j(h.y)}`;for(const{leftPoint:y,center:g,rightPoint:v,radius:S,arcPoint:w}of a){if(g===null){d+=` L${j(v.x)},${j(v.y)}`;const k=u(v);f+=` L${j(k.x)},${j(k.y)}`,h=k;continue}const C=Kk(y,v,g)?"0":"1";d+=` A${j(S)},${j(S)} 0 ${C},1 ${j(v.x)},${j(v.y)}`;const I=u(v),P=u(w),E=Uk(h,I,P);if(!E){f+=` L${j(I.x)},${j(I.y)}`,h=I;continue}const _=Math.abs(b.Dist(E,h));f+=` A${j(_)},${j(_)} 0 ${C},1 ${j(I.x)},${j(I.y)}`,h=I}return d+f+" Z"}function vK(e,n,t,r,o){if(t===null)return[b.From(e),b.From(n)];const s=[],i=b.Angle(t,e),a=b.Angle(t,n),l=yu(i,a);for(let c=0;c<o;c++){const u=c/(o-1),d=i+l*u,h=Si(t,r,d);s.push(h)}return s}function Kk(e,n,t){return(n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x)>0}const wK=x.memo(function({dash:n,fill:t,color:r,strokeWidth:o,w:s,h:i,id:a,size:l}){const c=Mt(),u=Au(s,i,a,l),d=Mu(s,i,a,l);return p.jsxs(p.Fragment,{children:[p.jsx(ft,{theme:c,d:u,fill:t,color:r}),p.jsx("g",{strokeWidth:o,stroke:c[r].solid,fill:"none",pointerEvents:"all",children:d.map(({leftPoint:h,rightPoint:f,center:y,radius:g},v)=>{const S=y?g*Rr(Rr(b.Angle(y,f))-Rr(b.Angle(y,h))):b.Dist(h,f),{strokeDasharray:w,strokeDashoffset:C}=nn(S,o,{style:n,start:"outset",end:"outset"});return p.jsx("path",{d:y?`M${h.x},${h.y}A${g},${g},0,0,1,${f.x},${f.y}`:`M${h.x},${h.y}L${f.x},${f.y}`,strokeDasharray:w,strokeDashoffset:C},v)})})]})});function xK({dash:e,fill:n,color:t,theme:r,strokeWidth:o,w:s,h:i,id:a,size:l}){const c=Au(s,i,a,l),u=Mu(s,i,a,l),d=document.createElementNS("http://www.w3.org/2000/svg","g");d.setAttribute("stroke-width",o.toString()),d.setAttribute("stroke",r[t].solid),d.setAttribute("fill","none");for(const{leftPoint:f,rightPoint:y,center:g,radius:v}of u){const S=g?v*Rr(Rr(b.Angle(g,y))-Rr(b.Angle(g,f))):b.Dist(f,y),{strokeDasharray:w,strokeDashoffset:C}=nn(S,o,{style:e,start:"outset",end:"outset"}),I=document.createElementNS("http://www.w3.org/2000/svg","path");I.setAttribute("d",g?`M${f.x},${f.y}A${v},${v},0,0,1,${y.x},${y.y}`:`M${f.x},${f.y}L${y.x},${y.y}`),I.setAttribute("stroke-dasharray",w.toString()),I.setAttribute("stroke-dashoffset",C.toString()),d.appendChild(I)}const h=er({d:c,fill:n,color:t,theme:r});return Vr(d,h)}const bK=x.memo(function({w:n,h:t,strokeWidth:r,dash:o,color:s,fill:i}){const a=Mt(),l=n/2,c=t/2,u=Math.max(0,l),d=Math.max(0,c),h=Tc(u,d),{strokeDasharray:f,strokeDashoffset:y}=nn(h<64?h*2:h,r,{style:o,snap:4,closed:!0}),g=`M${l-u},${c}a${u},${d},0,1,1,${u*2},0a${u},${d},0,1,1,-${u*2},0`;return p.jsxs(p.Fragment,{children:[p.jsx(ft,{theme:a,d:g,color:s,fill:i}),p.jsx("path",{d:g,strokeWidth:r,width:j(n),height:j(t),fill:"none",stroke:a[s].solid,strokeDasharray:f,strokeDashoffset:y,pointerEvents:"all"})]})});function PK({w:e,h:n,strokeWidth:t,dash:r,color:o,theme:s,fill:i}){const a=e/2,l=n/2,c=Math.max(0,a-t/2),u=Math.max(0,l-t/2),d=Tc(c,u),{strokeDasharray:h,strokeDashoffset:f}=nn(d<64?d*2:d,t,{style:r,snap:4,closed:!0}),y=`M${a-c},${l}a${c},${u},0,1,1,${c*2},0a${c},${u},0,1,1,-${c*2},0`,g=document.createElementNS("http://www.w3.org/2000/svg","path");g.setAttribute("d",y),g.setAttribute("stroke-width",t.toString()),g.setAttribute("width",e.toString()),g.setAttribute("height",n.toString()),g.setAttribute("fill","none"),g.setAttribute("stroke",s[o].solid),g.setAttribute("stroke-dasharray",h),g.setAttribute("stroke-dashoffset",f);const v=er({d:y,fill:i,color:o,theme:s});return Vr(g,v)}function Vk(e,n){if(n>e){const r=e/2;return`
|
|
153
|
+
M0,${r}
|
|
154
|
+
a${r},${r},0,1,1,${r*2},0
|
|
155
|
+
L${e},${n-r}
|
|
156
|
+
a${r},${r},0,1,1,-${r*2},0
|
|
157
|
+
Z`}const t=n/2;return`
|
|
158
|
+
M${t},0
|
|
159
|
+
L${e-t},0
|
|
160
|
+
a${t},${t},0,1,1,0,${t*2}
|
|
161
|
+
L${t},${n}
|
|
162
|
+
a${t},${t},0,1,1,0,${-t*2}
|
|
163
|
+
Z`}function Wk(e,n){if(e>n){const r=n/2;return Tc(r,r)+(e-r*2)*2}const t=e/2;return Tc(t,t)+(n-t*2)*2}const CK=x.memo(function({w:n,h:t,strokeWidth:r,dash:o,color:s,fill:i}){const a=Mt(),l=Vk(n,t),c=Wk(n,t),{strokeDasharray:u,strokeDashoffset:d}=nn(c<64?c*2:c,r,{style:o,snap:4,start:"outset",end:"outset",closed:!0});return p.jsxs(p.Fragment,{children:[p.jsx(ft,{theme:a,d:l,color:s,fill:i}),p.jsx("path",{d:l,strokeWidth:r,width:j(n),height:j(t),fill:"none",stroke:a[s].solid,strokeDasharray:u,strokeDashoffset:d,pointerEvents:"all"})]})});function eP({w:e,h:n,strokeWidth:t,dash:r,color:o,theme:s,fill:i}){const a=Vk(e,n),l=Wk(e,n),{strokeDasharray:c,strokeDashoffset:u}=nn(l<64?l*2:l,t,{style:r,snap:4,closed:!0}),d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("d",a),d.setAttribute("stroke-width",t.toString()),d.setAttribute("width",e.toString()),d.setAttribute("height",n.toString()),d.setAttribute("fill","none"),d.setAttribute("stroke",s[o].solid),d.setAttribute("stroke-dasharray",c),d.setAttribute("stroke-dashoffset",u);const h=er({d:a,fill:i,color:o,theme:s});return Vr(d,h)}const IK=x.memo(function({dash:n,fill:t,color:r,strokeWidth:o,outline:s,lines:i}){const a=Mt(),l="M"+s[0]+"L"+s.slice(1)+"Z";return p.jsxs(p.Fragment,{children:[p.jsx(ft,{theme:a,d:l,fill:t,color:r}),p.jsxs("g",{strokeWidth:o,stroke:a[r].solid,fill:"none",pointerEvents:"all",children:[Array.from(Array(s.length)).map((c,u)=>{const d=s[u],h=s[(u+1)%s.length],f=b.Dist(d,h),{strokeDasharray:y,strokeDashoffset:g}=nn(f,o,{style:n,start:"outset",end:"outset"});return p.jsx("line",{x1:d.x,y1:d.y,x2:h.x,y2:h.y,strokeDasharray:y,strokeDashoffset:g},u)}),i&&i.map(([c,u],d)=>{const h=b.Dist(c,u),{strokeDasharray:f,strokeDashoffset:y}=nn(h,o,{style:n,start:"skip",end:"outset",snap:n==="dotted"?4:void 0});return p.jsx("path",{d:`M${c.x},${c.y}L${u.x},${u.y}`,stroke:a[r].solid,strokeWidth:o,fill:"none",strokeDasharray:f,strokeDashoffset:y},`line_fg_${d}`)})]})]})});function EK({dash:e,fill:n,color:t,theme:r,strokeWidth:o,outline:s,lines:i}){const a=document.createElementNS("http://www.w3.org/2000/svg","g");if(a.setAttribute("stroke-width",o.toString()),a.setAttribute("stroke",r[t].solid),a.setAttribute("fill","none"),Array.from(Array(s.length)).forEach((c,u)=>{const d=s[u],h=s[(u+1)%s.length],f=b.Dist(d,h),{strokeDasharray:y,strokeDashoffset:g}=nn(f,o,{style:e}),v=document.createElementNS("http://www.w3.org/2000/svg","line");v.setAttribute("x1",d.x.toString()),v.setAttribute("y1",d.y.toString()),v.setAttribute("x2",h.x.toString()),v.setAttribute("y2",h.y.toString()),v.setAttribute("stroke-dasharray",y.toString()),v.setAttribute("stroke-dashoffset",g.toString()),a.appendChild(v)}),i)for(const[c,u]of i){const d=b.Dist(c,u),{strokeDasharray:h,strokeDashoffset:f}=nn(d,o,{style:e,start:"skip",end:"skip",snap:e==="dotted"?4:2}),y=document.createElementNS("http://www.w3.org/2000/svg","line");y.setAttribute("x1",c.x.toString()),y.setAttribute("y1",c.y.toString()),y.setAttribute("x2",u.x.toString()),y.setAttribute("y2",u.y.toString()),y.setAttribute("stroke-dasharray",h.toString()),y.setAttribute("stroke-dashoffset",f.toString()),a.appendChild(y)}const l=er({d:"M"+s[0]+"L"+s.slice(1)+"Z",fill:n,color:t,theme:r});return Vr(a,l)}const _K=x.memo(function({fill:n,color:t,strokeWidth:r,w:o,h:s,id:i,size:a}){const l=Mt(),c=Hk(o,s,i,a);return p.jsxs(p.Fragment,{children:[p.jsx(ft,{theme:l,d:c,fill:n,color:t}),p.jsx("path",{d:c,stroke:l[t].solid,strokeWidth:r,fill:"none"})]})});function kK({fill:e,color:n,strokeWidth:t,theme:r,w:o,h:s,id:i,size:a}){const l=Hk(o,s,i,a),c=document.createElementNS("http://www.w3.org/2000/svg","path");c.setAttribute("d",l),c.setAttribute("stroke-width",t.toString()),c.setAttribute("stroke",r[n].solid),c.setAttribute("fill","none");const u=er({d:l,fill:e,color:n,theme:r});return Vr(c,u)}x.memo(function({id:n,w:t,h:r,strokeWidth:o,fill:s,color:i}){const a=Mt(),l=D0(n,t,r,o),c=Xk(n,t,r,o);return p.jsxs(p.Fragment,{children:[p.jsx(ft,{theme:a,d:l,color:i,fill:s}),p.jsx("path",{d:c,fill:a[i].solid,strokeWidth:0,pointerEvents:"all"})]})});function TK({id:e,w:n,h:t,strokeWidth:r,fill:o,color:s,theme:i}){const a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d",Xk(e,n,t,r)),a.setAttribute("fill",i[s].solid);const l=er({d:D0(e,n,t,r),fill:o,color:s,theme:i});return Vr(a,l)}function Gk(e){return{size:1+e,thinning:.25,end:{taper:e},start:{taper:e},streamline:0,smoothing:1,simulatePressure:!1}}function Yk(e,n,t,r){const o=ws(e),s=n/2,i=t/2,a=Tc(s,i),l=[],c=De*o(),u=De+Ke/2+Math.abs(o())*Ke,d=Math.max(16,a/10);for(let h=0;h<d;h++){const f=h/(d-1),y=c+f*u,g=Math.cos(y),v=Math.sin(y);l.push(new b(s*g+n*.5+.05*o(),i*v+t/2+.05*o(),Math.min(1,.5+Math.abs(.5-(o()>0?tn.easeInOutSine(f):tn.easeInExpo(f)))/2)))}return jr(l,Gk(r))}function Xk(e,n,t,r){const o=Gk(r);return bu(Tu(hl(Yk(e,n,t,r),o),o))}function D0(e,n,t,r){return ys(Yk(e,n,t,r))}const $K=x.memo(function({id:n,outline:t,lines:r,fill:o,color:s,strokeWidth:i}){const a=Mt(),l=Nc(n,t,i/3,i*2,2);let c=Lc(l);if(r)for(const[h,f]of r)c+=`M${h.x},${h.y}L${f.x},${f.y}`;const u=Nc(n,t,0,i*2,1),d=Lc(u);return p.jsxs(p.Fragment,{children:[p.jsx(ft,{d,fill:o,color:s,theme:a}),p.jsx("path",{d:c,stroke:a[s].solid,strokeWidth:i,fill:"none"})]})});function MK({id:e,outline:n,lines:t,fill:r,color:o,theme:s,strokeWidth:i}){const a=Nc(e,n,i/3,i*2,2);let l=Lc(a);if(t)for(const[f,y]of t)l+=`M${f.x},${f.y}L${y.x},${y.y}`;const c=Nc(e,n,0,i*2,1),u=Lc(c),d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("d",l),d.setAttribute("fill","none"),d.setAttribute("stroke",s[o].solid),d.setAttribute("stroke-width",i.toString());const h=er({d:u,fill:r,color:o,theme:s});return Vr(d,h)}const AK=x.memo(function({fill:n,color:t,strokeWidth:r,w:o,h:s,id:i,size:a}){const l=Mt(),c=Au(o,s,i,a);return p.jsxs(p.Fragment,{children:[p.jsx(ft,{theme:l,d:c,fill:n,color:t}),p.jsx("path",{d:c,stroke:l[t].solid,strokeWidth:r,fill:"none"})]})});function jK({fill:e,color:n,strokeWidth:t,theme:r,w:o,h:s,id:i,size:a}){const l=Au(o,s,i,a),c=document.createElementNS("http://www.w3.org/2000/svg","path");c.setAttribute("d",l),c.setAttribute("stroke-width",t.toString()),c.setAttribute("stroke",r[n].solid),c.setAttribute("fill","none");const u=er({d:l,fill:e,color:n,theme:r});return Vr(c,u)}const tP=x.memo(function({w:n,h:t,strokeWidth:r,fill:o,color:s}){const i=Mt(),a=n/2,l=t/2,c=Math.max(0,a),u=Math.max(0,l),d=`M${a-c},${l}a${c},${u},0,1,1,${c*2},0a${c},${u},0,1,1,-${c*2},0`;return p.jsxs(p.Fragment,{children:[p.jsx(ft,{d,color:s,fill:o,theme:i}),p.jsx("path",{d,stroke:i[s].solid,strokeWidth:r,fill:"none"})]})});function OK({w:e,h:n,strokeWidth:t,fill:r,color:o,theme:s}){const i=e/2,a=n/2,l=Math.max(0,i),c=Math.max(0,a),u=`M${i-l},${a}a${l},${c},0,1,1,${l*2},0a${l},${c},0,1,1,-${l*2},0`,d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("d",u),d.setAttribute("stroke-width",t.toString()),d.setAttribute("width",e.toString()),d.setAttribute("height",n.toString()),d.setAttribute("fill","none"),d.setAttribute("stroke",s[o].solid);const h=er({d:u,fill:r,color:o,theme:s});return Vr(d,h)}const nP=x.memo(function({w:n,h:t,strokeWidth:r,fill:o,color:s}){const i=Mt(),a=R0(n,t);return p.jsxs(p.Fragment,{children:[p.jsx(ft,{d:a,color:s,fill:o,theme:i}),p.jsx("path",{d:a,stroke:i[s].solid,strokeWidth:r,fill:"none"})]})});function DK({w:e,h:n,strokeWidth:t,fill:r,color:o,theme:s}){const i=R0(e,n),a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d",i),a.setAttribute("stroke-width",t.toString()),a.setAttribute("width",e.toString()),a.setAttribute("height",n.toString()),a.setAttribute("fill","none"),a.setAttribute("stroke",s[o].solid);const l=er({d:i,fill:r,color:o,theme:s});return Vr(a,l)}function R0(e,n){let t;if(n>e){const r=e/2;t=`
|
|
164
|
+
M0,${r}
|
|
165
|
+
a${r},${r},0,1,1,${r*2},0
|
|
166
|
+
L${e},${n-r}
|
|
167
|
+
a${r},${r},0,1,1,-${r*2},0
|
|
168
|
+
Z`}else{const r=n/2;t=`
|
|
169
|
+
M${r},0
|
|
170
|
+
L${e-r},0
|
|
171
|
+
a${r},${r},0,1,1,0,${r*2}
|
|
172
|
+
L${r},${n}
|
|
173
|
+
a${r},${r},0,1,1,0,${-r*2}
|
|
174
|
+
Z`}return t}const RK=x.memo(function({outline:n,lines:t,fill:r,color:o,strokeWidth:s}){const i=Mt();let a="M"+n[0]+"L"+n.slice(1)+"Z";if(t)for(const[l,c]of t)a+=`M${l.x},${l.y}L${c.x},${c.y}`;return p.jsxs(p.Fragment,{children:[p.jsx(ft,{d:a,fill:r,color:o,theme:i}),p.jsx("path",{d:a,stroke:i[o].solid,strokeWidth:s,fill:"none"})]})});function LK({outline:e,lines:n,fill:t,color:r,strokeWidth:o,theme:s}){const i="M"+e[0]+"L"+e.slice(1)+"Z",a=i;let l=i;if(n)for(const[d,h]of n)l+=`M${d.x},${d.y}L${h.x},${h.y}`;const c=document.createElementNS("http://www.w3.org/2000/svg","path");c.setAttribute("d",l),c.setAttribute("stroke-width",o.toString()),c.setAttribute("stroke",s[r].solid),c.setAttribute("fill","none");const u=er({d:a,fill:t,color:r,theme:s});return Vr(c,u)}const vm=16,sr=17*3;class Ih extends al{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"onEditEnd",t=>{const{id:r,type:o,props:{text:s}}=t;s.trimEnd()!==t.props.text&&this.editor.updateShapes([{id:r,type:o,props:{text:s.trimEnd()}}])});m(this,"onResize",(t,{handle:r,newPoint:o,scaleX:s,scaleY:i,initialShape:a})=>{let l=a.props.w*s,c=(a.props.h+a.props.growY)*i,u=0,d=0;if(t.props.text.trim()){let g=Math.max(Math.abs(l),sr),v=Math.max(Math.abs(c),sr);g<sr&&v===sr&&(g=sr),g===sr&&v<sr&&(v=sr);const S=bd(this.editor,{...t,props:{...t.props,w:g,h:v}}),w=Math.max(Math.abs(l),S.w)*Math.sign(l),C=Math.max(Math.abs(c),S.h)*Math.sign(c);u=Math.abs(w)-Math.abs(l),d=Math.abs(C)-Math.abs(c),l=w,c=C}const h=new b(0,0);s<0&&(h.x+=l),(r==="left"||r==="top_left"||r==="bottom_left")&&(h.x+=s<0?u:-u),i<0&&(h.y+=c),(r==="top"||r==="top_left"||r==="top_right")&&(h.y+=i<0?d:-d);const{x:f,y}=h.rot(t.rotation).add(o);return{x:f,y,props:{w:Math.max(Math.abs(l),1),h:Math.max(Math.abs(c),1),growY:0}}});m(this,"onBeforeCreate",t=>{if(!t.props.text)return t.props.growY?{...t,props:{...t.props,growY:0}}:void 0;const r=t.props.h,o=bd(this.editor,t).h;let s=null;if(o>r?s=o-r:t.props.growY&&(s=0),s!==null)return{...t,props:{...t.props,growY:s}}});m(this,"onBeforeUpdate",(t,r)=>{const o=t.props.text,s=r.props.text;if(o===s&&t.props.font===r.props.font&&t.props.size===r.props.size)return;if(o&&!s)return{...r,props:{...r.props,growY:0}};const i=t.props.w,a=t.props.h,l=bd(this.editor,r),c=l.w,u=l.h;if(!o&&s&&s.length===1){let h=Math.max(i,c),f=Math.max(a,u);return t.props.w<sr&&t.props.h<sr&&(h=Math.max(h,sr),f=Math.max(f,sr),h=Math.max(h,f),f=Math.max(h,f)),{...r,props:{...r.props,w:h,h:f,growY:0}}}let d=null;if(u>a?d=u-a:t.props.growY&&(d=0),d!==null)return{...r,props:{...r.props,growY:d,w:Math.max(r.props.w,c)}};if(c>t.props.w)return{...r,props:{...r.props,w:c}}});m(this,"onDoubleClick",t=>{if(this.editor.inputs.altKey)switch(t.props.geo){case"rectangle":return{...t,props:{geo:"check-box"}};case"check-box":return{...t,props:{geo:"rectangle"}}}})}getDefaultProps(){return{w:100,h:100,geo:"rectangle",color:"black",labelColor:"black",fill:"none",dash:"draw",size:"m",font:"draw",text:"",align:"middle",verticalAlign:"middle",growY:0,url:""}}getGeometry(t){const r=Math.max(1,t.props.w),o=Math.max(1,t.props.h+t.props.growY),s=r/2,i=o/2,a=Pt[t.props.size],l=t.props.fill!=="none";let c;switch(t.props.geo){case"cloud":{c=new vt({points:SK(r,o,t.id,t.props.size),isFilled:l});break}case"triangle":{c=new vt({points:[new b(s,0),new b(r,o),new b(0,o)],isFilled:l});break}case"diamond":{c=new vt({points:[new b(s,0),new b(r,i),new b(s,o),new b(0,i)],isFilled:l});break}case"pentagon":{c=new vt({points:Eg(r,o,5),isFilled:l});break}case"hexagon":{c=new vt({points:Eg(r,o,6),isFilled:l});break}case"octagon":{c=new vt({points:Eg(r,o,8),isFilled:l});break}case"ellipse":{c=new E_({width:r,height:o,isFilled:l});break}case"oval":{c=new $F({width:r,height:o,isFilled:l});break}case"star":{const v=De/5/2,S=Math.floor(5/4)*2,w=5*2-S,C=0,I=Math.floor(5/2)*2,P=Math.cos(-Ke+S*v)*r/2,E=Math.cos(-Ke+w*v)*r/2,_=Math.sin(-Ke+C*v)*o/2,k=Math.sin(-Ke+I*v)*o/2,M=r-Math.abs(P-E),T=o-Math.abs(k-_),R=r/2+E-(r/2-P),O=o/2+_-(o/2-k),U=1,N=(r-R)/2,L=(o-O)/2,G=(r+M)/2,X=(o+T)/2,H=G*U/2,B=X*U/2;c=new vt({points:Array.from(Array(5*2)).map((W,Y)=>{const J=-Ke+Y*v;return new b(N+(Y%2?H:G)*Math.cos(J),L+(Y%2?B:X)*Math.sin(J))}),isFilled:l});break}case"rhombus":{const g=Math.min(r*.38,o*.38);c=new vt({points:[new b(g,0),new b(r,0),new b(r-g,o),new b(0,o)],isFilled:l});break}case"rhombus-2":{const g=Math.min(r*.38,o*.38);c=new vt({points:[new b(0,0),new b(r-g,0),new b(r,o),new b(g,o)],isFilled:l});break}case"trapezoid":{const g=Math.min(r*.38,o*.38);c=new vt({points:[new b(g,0),new b(r-g,0),new b(r,o),new b(0,o)],isFilled:l});break}case"arrow-right":{const g=Math.min(r,o)*.38,v=o*.16;c=new vt({points:[new b(0,v),new b(r-g,v),new b(r-g,0),new b(r,o/2),new b(r-g,o),new b(r-g,o-v),new b(0,o-v)],isFilled:l});break}case"arrow-left":{const g=Math.min(r,o)*.38,v=o*.16;c=new vt({points:[new b(g,0),new b(g,v),new b(r,v),new b(r,o-v),new b(g,o-v),new b(g,o),new b(0,o/2)],isFilled:l});break}case"arrow-up":{const g=r*.16,v=Math.min(r,o)*.38;c=new vt({points:[new b(r/2,0),new b(r,v),new b(r-g,v),new b(r-g,o),new b(g,o),new b(g,v),new b(0,v)],isFilled:l});break}case"arrow-down":{const g=r*.16,v=Math.min(r,o)*.38;c=new vt({points:[new b(g,0),new b(r-g,0),new b(r-g,o-v),new b(r,o-v),new b(r/2,o),new b(0,o-v),new b(g,o-v)],isFilled:l});break}case"check-box":case"x-box":case"rectangle":{c=new js({width:r,height:o,isFilled:l});break}}const u=bd(this.editor,t),d=Math.min(r,Math.max(u.w,Math.min(32,Math.max(1,r-8)))),h=Math.min(o,Math.max(u.h,Math.min(32,Math.max(1,r-8)))),f=Pd(t.props,a),y=f?f.map(g=>new Oi({points:g})):[];return new no({children:[c,new js({x:t.props.align==="start"?0:t.props.align==="end"?r-d:(r-d)/2,y:t.props.verticalAlign==="start"?0:t.props.verticalAlign==="end"?o-h:(o-h)/2,width:d,height:h,isFilled:!0,isLabel:!0}),...y]})}getHandleSnapGeometry(t){const r=this.getGeometry(t),o=r.children[0];switch(t.props.geo){case"arrow-down":case"arrow-left":case"arrow-right":case"arrow-up":case"check-box":case"diamond":case"hexagon":case"octagon":case"pentagon":case"rectangle":case"rhombus":case"rhombus-2":case"star":case"trapezoid":case"triangle":case"x-box":return{outline:o,points:[...o.getVertices(),r.bounds.center]};case"cloud":case"ellipse":case"oval":return{outline:o,points:[r.bounds.center]};default:Ai(t.props.geo)}}component(t){const{id:r,type:o,props:s}=t,i=Pt[s.size],{w:a,color:l,labelColor:c,fill:u,dash:d,growY:h,font:f,align:y,verticalAlign:g,size:v,text:S}=s,w=()=>{const C=s.h+h;switch(s.geo){case"cloud":{if(d==="solid")return p.jsx(AK,{color:l,fill:u,strokeWidth:i,w:a,h:C,id:r,size:v});if(d==="dashed"||d==="dotted")return p.jsx(wK,{color:l,fill:u,strokeWidth:i,w:a,h:C,id:r,size:v,dash:d});if(d==="draw")return p.jsx(_K,{color:l,fill:u,strokeWidth:i,w:a,h:C,id:r,size:v});break}case"ellipse":{if(d==="solid")return p.jsx(tP,{strokeWidth:i,w:a,h:C,color:l,fill:u});if(d==="dashed"||d==="dotted")return p.jsx(bK,{id:r,strokeWidth:i,w:a,h:C,dash:d,color:l,fill:u});if(d==="draw")return p.jsx(tP,{strokeWidth:i,w:a,h:C,color:l,fill:u});break}case"oval":{if(d==="solid")return p.jsx(nP,{strokeWidth:i,w:a,h:C,color:l,fill:u});if(d==="dashed"||d==="dotted")return p.jsx(CK,{id:r,strokeWidth:i,w:a,h:C,dash:d,color:l,fill:u});if(d==="draw")return p.jsx(nP,{strokeWidth:i,w:a,h:C,color:l,fill:u});break}default:{const I=this.editor.getShapeGeometry(t),P=I instanceof no?I.children[0].vertices:I.vertices,E=Pd(t.props,i);if(d==="solid")return p.jsx(RK,{fill:u,color:l,strokeWidth:i,outline:P,lines:E});if(d==="dashed"||d==="dotted")return p.jsx(IK,{dash:d,fill:u,color:l,strokeWidth:i,outline:P,lines:E});if(d==="draw")return p.jsx($K,{id:r,fill:u,color:l,strokeWidth:i,outline:P,lines:E})}}};return p.jsxs(p.Fragment,{children:[p.jsx(Vn,{id:r,children:w()}),p.jsxs(wi,{id:t.id,style:{overflow:"hidden",width:t.props.w,height:t.props.h+s.growY},children:[p.jsx(Fk,{id:r,type:o,font:f,fill:u,size:v,align:y,verticalAlign:g,text:S,labelColor:c,wrap:!0,bounds:s.geo==="cloud"?this.getGeometry(t).bounds:void 0}),t.props.url&&p.jsx($u,{url:t.props.url,zoomLevel:this.editor.getZoomLevel()})]})]})}indicator(t){const{id:r,props:o}=t,{w:s,size:i}=o,a=o.h+o.growY,l=Pt[i];switch(o.geo){case"ellipse":return o.dash==="draw"?p.jsx("path",{d:D0(r,s,a,l)}):p.jsx("ellipse",{cx:s/2,cy:a/2,rx:s/2,ry:a/2});case"oval":return p.jsx("path",{d:R0(s,a)});case"cloud":return p.jsx("path",{d:Au(s,a,r,i)});default:{const c=this.editor.getShapeGeometry(t),u=c instanceof no?c.children[0].vertices:c.vertices;let d;if(o.dash==="draw"){const f=Nc(r,u,0,l*2,1);d=Lc(f)}else d="M"+u[0]+"L"+u.slice(1)+"Z";const h=Pd(t.props,l);if(h)for(const[f,y]of h)d+=`M${f.x},${f.y}L${y.x},${y.y}`;return p.jsx("path",{d})}}}toSvg(t,r){const{id:o,props:s}=t,i=Pt[s.size],a=Dn({isDarkMode:r.isDarkMode});r.addExportDef($0(t.props.fill,a));let l;switch(s.geo){case"ellipse":{switch(s.dash){case"draw":l=TK({id:o,w:s.w,h:s.h,color:s.color,fill:s.fill,strokeWidth:i,theme:a});break;case"solid":l=OK({strokeWidth:i,w:s.w,h:s.h,color:s.color,fill:s.fill,theme:a});break;default:l=PK({id:o,strokeWidth:i,w:s.w,h:s.h,dash:s.dash,color:s.color,fill:s.fill,theme:a});break}break}case"oval":{switch(s.dash){case"draw":l=eP({id:o,strokeWidth:i,w:s.w,h:s.h,dash:s.dash,color:s.color,fill:s.fill,theme:a});break;case"solid":l=DK({strokeWidth:i,w:s.w,h:s.h,color:s.color,fill:s.fill,theme:a});break;default:l=eP({id:o,strokeWidth:i,w:s.w,h:s.h,dash:s.dash,color:s.color,fill:s.fill,theme:a})}break}case"cloud":{switch(s.dash){case"draw":l=kK({id:o,strokeWidth:i,w:s.w,h:s.h,color:s.color,fill:s.fill,size:s.size,theme:a});break;case"solid":l=jK({strokeWidth:i,w:s.w,h:s.h,color:s.color,fill:s.fill,size:s.size,id:o,theme:a});break;default:l=xK({id:o,strokeWidth:i,w:s.w,h:s.h,dash:s.dash,color:s.color,fill:s.fill,theme:a,size:s.size})}break}default:{const c=this.editor.getShapeGeometry(t),u=c instanceof no?c.children[0].vertices:c.vertices,d=Pd(t.props,i);switch(s.dash){case"draw":l=MK({id:o,fill:s.fill,color:s.color,strokeWidth:i,outline:u,lines:d,theme:a});break;case"solid":l=LK({fill:s.fill,color:s.color,strokeWidth:i,outline:u,lines:d,theme:a});break;default:l=EK({dash:s.dash,fill:s.fill,color:s.color,strokeWidth:i,outline:u,lines:d,theme:a});break}break}}if(s.text){const c=this.editor.getShapeGeometry(t).bounds;r.addExportDef(Tf(t.props.font));const u=zk({editor:this.editor,shape:t,font:mu[t.props.font],bounds:c}),d=u.cloneNode(!0);d.setAttribute("fill",a[t.props.labelColor].solid),d.setAttribute("stroke","none");const h=u.cloneNode(!0);h.setAttribute("stroke-width","2"),h.setAttribute("fill",a.background),h.setAttribute("stroke",a.background);const f=document.createElementNS("http://www.w3.org/2000/svg","g");if(f.append(h),f.append(d),l.nodeName==="g")return l.appendChild(f),l;{const y=document.createElementNS("http://www.w3.org/2000/svg","g");return y.appendChild(l),y.appendChild(f),y}}return l}getCanvasSvgDefs(){return[M0()]}}m(Ih,"type","geo"),m(Ih,"props",rE),m(Ih,"migrations",oE);function bd(e,n){const t=n.props.text;if(!t)return{w:0,h:0};const r=e.textMeasure.measureText("w",{...Ut,fontFamily:Lo[n.props.font],fontSize:Ka[n.props.size],maxWidth:100}),o={s:2,m:3.5,l:5,xl:10},s=e.textMeasure.measureText(t,{...Ut,fontFamily:Lo[n.props.font],fontSize:Ka[n.props.size],minWidth:r.w+"px",maxWidth:Math.max(0,Math.ceil(r.w+o[n.props.size]),Math.ceil(n.props.w-vm*2))});return{w:s.w+vm*2,h:s.h+vm*2}}function Pd(e,n){switch(e.geo){case"x-box":return NK(e.w,e.h,n,e.dash);case"check-box":return FK(e.w,e.h);default:return}}function NK(e,n,t,r){const o=r==="draw"?.62:0;if(r==="dashed")return[[new b(0,0),new b(e/2,n/2)],[new b(e,n),new b(e/2,n/2)],[new b(0,n),new b(e/2,n/2)],[new b(e,0),new b(e/2,n/2)]];const s=a=>Math.max(0,Math.min(e,a)),i=a=>Math.max(0,Math.min(n,a));return[[new b(s(t*o),i(t*o)),new b(s(e-t*o),i(n-t*o))],[new b(s(t*o),i(n-t*o)),new b(s(e-t*o),i(t*o))]]}function FK(e,n){const t=Math.min(e,n)*.82,r=(e-t)/2,o=(n-t)/2,s=a=>Math.max(0,Math.min(e,a)),i=a=>Math.max(0,Math.min(n,a));return[[new b(s(r+t*.25),i(o+t*.52)),new b(s(r+t*.45),i(o+t*.82))],[new b(s(r+t*.45),i(o+t*.82)),new b(s(r+t*.82),i(o+t*.22))]]}function zK(){const[e,n]=x.useState(!1);return x.useEffect(()=>{const r=CSS.supports("color","color(display-p3 1 1 1)"),o=matchMedia("(color-gamut: p3)");n(r&&o.matches);const s=()=>n(r&&o.matches);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[]),K(Ft.forceSrgb)||!e?"srgb":"p3"}const rP=.35,oP=.82;class Eh extends Lr{constructor(){super(...arguments);m(this,"hideResizeHandles",t=>Cd(t));m(this,"hideRotateHandle",t=>Cd(t));m(this,"hideSelectionBoundsFg",t=>Cd(t));m(this,"onResize",(t,r)=>{const{scaleX:o,scaleY:s}=r,i=[];for(const a of t.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}}getGeometry(t){const r=na(t);if(Cd(t))return new a0({x:-r/2,y:-r/2,radius:r/2,isFilled:!0});const{strokePoints:o,sw:s}=qk(t,r,!0),i=cS({strokeWidth:s,showAsComplete:!0});return hl(o,i),new vt({points:Tu(o,i),isFilled:!0})}component(t){return p.jsx(sP,{strokeWidth:na(t),shape:t,opacity:rP})}backgroundComponent(t){return p.jsx(sP,{strokeWidth:na(t),shape:t,opacity:oP})}indicator(t){var d;const r=kp(),o=na(t),s=ma(t.props.segments);let i=o;!r&&!t.props.isPen&&s.length===1&&(i+=ws(t.id)()*(o/6));const a=t.props.isComplete||((d=xn(t.props.segments))==null?void 0:d.type)==="straight",l=cS({strokeWidth:o,showAsComplete:a}),c=jr(s,l);let u;return c.length<2?u=UK(s[0],i):u=ys(c,!1),p.jsx("path",{d:u})}toSvg(t,r){const o=Dn({isDarkMode:r.isDarkMode});return iP(na(t),t,rP,o)}toBackgroundSvg(t){const r=Dn({isDarkMode:this.editor.user.getIsDarkMode()});return iP(na(t),t,oP,r)}}m(Eh,"type","highlight"),m(Eh,"props",aE),m(Eh,"migrations",lE);function BK(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 UK(e,n){const t=n/2;return`M ${e.x} ${e.y} m -${t}, 0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0`}function qk(e,n,t){var l;const r=ma(e.props.segments),o=e.props.isComplete||((l=xn(e.props.segments))==null?void 0:l.type)==="straight";let s=n;!t&&!e.props.isPen&&r.length===1&&(s+=ws(e.id)()*(n/6));const i=cS({strokeWidth:s,showAsComplete:o});return{strokePoints:jr(r,i),sw:s}}function Zk(e,n,t){const{strokePoints:r,sw:o}=qk(e,n,t);return{solidStrokePath:r.length>1?ys(r,!1):BK(e.props.segments[0].points[0]),sw:o}}function sP({strokeWidth:e,shape:n,opacity:t}){const r=Mt(),o=kp(),{solidStrokePath:s,sw:i}=Zk(n,e,o),a=zK(),l=r[n.props.color].highlight[a];return p.jsx(Vn,{id:n.id,style:{opacity:t},children:p.jsx("path",{d:s,strokeLinecap:"round",fill:"none",pointerEvents:"all",stroke:l,strokeWidth:i})})}function iP(e,n,t,r){const{solidStrokePath:o,sw:s}=Zk(n,e,!1),i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",o),i.setAttribute("fill","none"),i.setAttribute("stroke",r[n.props.color].highlight.srgb),i.setAttribute("stroke-width",`${s}`),i.setAttribute("opacity",`${t}`),i}function na(e){return ms[e.props.size]*1.12}function Cd(e){return e.props.segments.length===1&&e.props.segments[0].points.length<2}function Qk(){const[e,n]=x.useState(!1);return x.useEffect(()=>{const t=window.matchMedia("(prefers-reduced-motion: reduce)"),r=()=>{n(t.matches)};return r(),t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[]),e}const HK=async e=>new Promise((n,t)=>{const r=new Image;r.onload=()=>n(r),r.onerror=()=>t(new Error("Failed to load image")),r.crossOrigin="anonymous",r.src=e}),KK=async e=>{const n=await HK(e),t=document.createElement("canvas");t.width=n.width,t.height=n.height;const r=t.getContext("2d");if(r)return r.drawImage(n,0,0),t.toDataURL()};async function VK(e){const t=await(await fetch(e)).blob();return new Promise((r,o)=>{const s=new FileReader;s.onloadend=()=>r(s.result),s.onerror=o,s.readAsDataURL(t)})}class _h extends al{constructor(){super(...arguments);m(this,"isAspectRatioLocked",()=>!0);m(this,"canCrop",()=>!0);m(this,"onDoubleClick",t=>{const r=t.props.assetId?this.editor.getAsset(t.props.assetId):void 0;!r||!(r.props.src&&"mimeType"in r.props&&r.props.mimeType==="image/gif")||this.editor.updateShapes([{type:"image",id:t.id,props:{playing:!t.props.playing}}])});m(this,"onDoubleClickEdge",t=>{const r=t.props;if(!r||this.editor.getCroppingShapeId()!==t.id)return;const o=pr(r.crop)||{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},s=1/(o.bottomRight.x-o.topLeft.x)*t.props.w,i=1/(o.bottomRight.y-o.topLeft.y)*t.props.h,a=new b(o.topLeft.x*s,o.topLeft.y*i).rot(t.rotation),l={id:t.id,type:t.type,x:t.x-a.x,y:t.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}}component(t){var h,f;const r=aP(t),o=zb(t.id),s=Qk(),[i,a]=x.useState(""),l=t.props.assetId?this.editor.getAsset(t.props.assetId):void 0;if((l==null?void 0:l.type)==="bookmark")throw Error("Bookmark assets can't be rendered as images");const u=K("onlySelectedShape",()=>{var y;return t.id===((y=this.editor.getOnlySelectedShape())==null?void 0:y.id)},[this.editor])&&o&&this.editor.isInAny("select.crop","select.cropping","select.pointing_crop_handle"),d=s&&(((h=l==null?void 0:l.props.mimeType)==null?void 0:h.includes("video"))||((f=l==null?void 0:l.props.mimeType)==null?void 0:f.includes("gif")));return x.useEffect(()=>{if(l!=null&&l.props.src&&"mimeType"in l.props&&(l==null?void 0:l.props.mimeType)==="image/gif"){let y=!1;return(async()=>{const v=await KK(l.props.src);y||v&&a(v)})(),()=>{y=!0}}},[s,l==null?void 0:l.props]),p.jsxs(p.Fragment,{children:[(l==null?void 0:l.props.src)&&u&&p.jsx("div",{style:r,children:p.jsx("div",{className:"tl-image",style:{opacity:.1,backgroundImage:`url(${!t.props.playing||d?i:l.props.src})`},draggable:!1})}),p.jsxs(wi,{id:t.id,style:{overflow:"hidden",width:t.props.w,height:t.props.h},children:[p.jsxs("div",{className:"tl-image-container",style:r,children:[l!=null&&l.props.src?p.jsx("div",{className:"tl-image",style:{backgroundImage:`url(${!t.props.playing||d?i:l.props.src})`},draggable:!1}):null,(l==null?void 0:l.props.isAnimated)&&!t.props.playing&&p.jsx("div",{className:"tl-image__tg",children:"GIF"})]}),"url"in t.props&&t.props.url&&p.jsx($u,{url:t.props.url,zoomLevel:this.editor.getZoomLevel()})]})]})}indicator(t){return zb(t.id)?null:p.jsx("rect",{width:j(t.props.w),height:j(t.props.h)})}shouldGetDataURI(t){return t&&(t.startsWith("http")||t.startsWith("/")||t.startsWith("./"))}async toSvg(t){const r=document.createElementNS("http://www.w3.org/2000/svg","g"),o=t.props.assetId?this.editor.getAsset(t.props.assetId):null;let s=(o==null?void 0:o.props.src)||"";this.shouldGetDataURI(s)&&(s=await VK(s)||"");const i=document.createElementNS("http://www.w3.org/2000/svg","image");i.setAttributeNS("http://www.w3.org/1999/xlink","href",s);const a=aP(t),l=t.props.crop;if(a.transform&&l){const{transform:c,width:u,height:d}=a,h=(l.bottomRight.x-l.topLeft.x)*u,f=(l.bottomRight.y-l.topLeft.y)*d,y=[new b(0,0),new b(h,0),new b(h,f),new b(0,f)],g=document.createElementNS("http://www.w3.org/2000/svg","polygon");g.setAttribute("points",y.map(C=>`${C.x},${C.y}`).join(" "));const v=document.createElementNS("http://www.w3.org/2000/svg","clipPath");v.setAttribute("id","cropClipPath"),v.appendChild(g);const S=document.createElementNS("http://www.w3.org/2000/svg","defs");S.appendChild(v),r.appendChild(S);const w=document.createElementNS("http://www.w3.org/2000/svg","g");w.setAttribute("clip-path","url(#cropClipPath)"),i.setAttribute("width",u.toString()),i.setAttribute("height",d.toString()),i.style.transform=c,w.appendChild(i),r.appendChild(w)}else i.setAttribute("width",t.props.w.toString()),i.setAttribute("height",t.props.h.toString()),r.appendChild(i);return r}}m(_h,"type","image"),m(_h,"props",cE),m(_h,"migrations",uE);function aP(e){const n=e.props.crop,t=n==null?void 0:n.topLeft;if(!t)return{width:e.props.w,height:e.props.h};const r=1/(n.bottomRight.x-n.topLeft.x)*e.props.w,o=1/(n.bottomRight.y-n.topLeft.y)*e.props.h,s=-t.x*r,i=-t.y*o;return{transform:`translate(${s}px, ${i}px)`,width:r,height:o}}function uS(e,n){const{start:t,end:r}=e;return n?`M${j(t.x)},${j(t.y)} L${j(r.x)},${j(r.y)} `:`${j(r.x)},${j(r.y)} `}function dS(e,n){const{a:t,b:r,c:o,d:s}=e;return b.Equals(t,s)?"":`${n?`M${j(t.x)},${j(t.y)}`:""}C${j(r.x)},${j(r.y)} ${j(o.x)},${j(o.y)} ${j(s.x)},${j(s.y)}`}function Jk(e,n){let t=e.segments.reduce((r,o,s)=>r+dS(o,s===0),"");return n&&(t+="Z"),t}function WK(e,n){let t=e.segments.reduce((r,o,s)=>r+uS(o,s===0),"");return n&&(t+="Z"),t}function e2(e,n=!1){return e instanceof Oi?WK(e,n):Jk(e,n)}function t2(e){return{size:e,thinning:.4,streamline:0,smoothing:.5,simulatePressure:!0,last:!0}}function n2(e,n,t){const r=n.vertices,o=t2(t);return jr(r,o)}function GK(e,n,t){const r=t2(t);return Tu(hl(n2(e,n,t),r),r)}function lP(e,n,t){const r=GK(e,n,t);return bu(r)}function YK(e,n,t){if(e.props.dash==="draw"){const r=n2(e,n,t);return ys(r)}return e2(n)}const XK=new e0;class kh extends Lr{constructor(){super(...arguments);m(this,"hideResizeHandles",()=>!0);m(this,"hideRotateHandle",()=>!0);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"hideSelectionBoundsBg",()=>!0);m(this,"onResize",(t,r)=>{const{scaleX:o,scaleY:s}=r;return{props:{points:np(t.props.points,(i,{id:a,index:l,x:c,y:u})=>({id:a,index:l,x:c*o,y:u*s}))}}});m(this,"onHandleDrag",(t,{handle:r})=>{if(r.type==="vertex")return{...t,props:{...t.props,points:{...t.props.points,[r.id]:{id:r.id,index:r.index,x:r.x,y:r.y}}}}})}getDefaultProps(){const[t,r]=Pc(2);return{dash:"draw",size:"m",color:"black",spline:"line",points:{[t]:{id:t,index:t,x:0,y:0},[r]:{id:r,index:r,x:.1,y:.1}}}}getGeometry(t){return ra(t)}getHandles(t){return XK.get(t.props,()=>{const r=ra(t),o=hS(t),s=o.map(i=>({...i,id:i.index,type:"vertex",canSnap:!0}));for(let i=0;i<o.length-1;i++){const a=oc(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(Rt)})}component(t){const r=Mt(),o=ra(t),s=Pt[t.props.size],{dash:i,color:a}=t.props;if(t.props.spline==="line"){if(i==="solid"){const l=o.points,c="M"+l[0]+"L"+l.slice(1);return p.jsxs(Vn,{id:t.id,children:[p.jsx(ft,{d:c,fill:"none",color:a,theme:r}),p.jsx("path",{d:c,stroke:r[a].solid,strokeWidth:s,fill:"none"})]})}if(i==="dashed"||i==="dotted"){const l=o.points,c="M"+l[0]+"L"+l.slice(1);return p.jsxs(Vn,{id:t.id,children:[p.jsx(ft,{d:c,fill:"none",color:a,theme:r}),p.jsx("g",{stroke:r[a].solid,strokeWidth:s,children:o.segments.map((u,d)=>{const{strokeDasharray:h,strokeDashoffset:f}=nn(u.length,s,{style:i,start:d>0?"outset":"none",end:d<o.segments.length-1?"outset":"none"});return p.jsx("path",{strokeDasharray:h,strokeDashoffset:f,d:uS(u,!0),fill:"none"},d)})})]})}if(i==="draw"){const l=o.points,[c,u]=Sm(t.id,l,s);return p.jsxs(Vn,{id:t.id,children:[p.jsx(ft,{d:c,fill:"none",color:a,theme:r}),p.jsx("path",{d:u,stroke:r[a].solid,strokeWidth:s,fill:"none"})]})}}if(t.props.spline==="cubic"){const l=e2(o);if(i==="solid")return p.jsxs(Vn,{id:t.id,children:[p.jsx(ft,{d:l,fill:"none",color:a,theme:r}),p.jsx("path",{strokeWidth:s,stroke:r[a].solid,fill:"none",d:l})]});if(i==="dashed"||i==="dotted")return p.jsxs(Vn,{id:t.id,children:[p.jsx(ft,{d:l,fill:"none",color:a,theme:r}),p.jsx("g",{stroke:r[a].solid,strokeWidth:s,children:o.segments.map((c,u)=>{const{strokeDasharray:d,strokeDashoffset:h}=nn(c.length,s,{style:i,start:u>0?"outset":"none",end:u<o.segments.length-1?"outset":"none"});return p.jsx("path",{strokeDasharray:d,strokeDashoffset:h,d:dS(c,!0),fill:"none"},u)})})]});if(i==="draw")return p.jsxs(Vn,{id:t.id,children:[p.jsx(ft,{d:l,fill:"none",color:a,theme:r}),p.jsx("path",{d:lP(t,o,s),strokeWidth:1,stroke:r[a].solid,fill:r[a].solid})]})}}indicator(t){const r=Pt[t.props.size],o=ra(t),{dash:s}=t.props;let i;if(t.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]=Sm(t.id,a,r);i=l}}else i=YK(t,o,r);return p.jsx("path",{d:i})}toSvg(t,r){const s=Dn({isDarkMode:r.isDarkMode})[t.props.color].solid,i=ra(t),a=Pt[t.props.size];switch(t.props.dash){case"draw":{let l;if(i instanceof ch)l=lP(t,i,a);else{const[u,d]=Sm(t.id,i.points,a);l=d}const c=document.createElementNS("http://www.w3.org/2000/svg","path");return c.setAttribute("stroke-width",a+"px"),c.setAttribute("stroke",s),c.setAttribute("fill","none"),c.setAttribute("d",l),c}case"solid":{let l;if(i instanceof ch)l=Jk(i,!1);else{const u=i.points;l="M"+u[0]+"L"+u.slice(1)}const c=document.createElementNS("http://www.w3.org/2000/svg","path");return c.setAttribute("stroke-width",a+"px"),c.setAttribute("stroke",s),c.setAttribute("fill","none"),c.setAttribute("d",l),c}default:{const{segments:l}=i,c=document.createElementNS("http://www.w3.org/2000/svg","g");c.setAttribute("stroke",s),c.setAttribute("stroke-width",a.toString());const u=i instanceof ch?dS:uS;return l.forEach((d,h)=>{const f=document.createElementNS("http://www.w3.org/2000/svg","path"),{strokeDasharray:y,strokeDashoffset:g}=nn(d.length,a,{style:t.props.dash,start:h>0?"outset":"none",end:h<l.length-1?"outset":"none"});f.setAttribute("stroke-dasharray",y.toString()),f.setAttribute("stroke-dashoffset",g.toString()),f.setAttribute("d",u(d,!0)),f.setAttribute("fill","none"),c.appendChild(f)}),c}}}getHandleSnapGeometry(t){const r=hS(t);return{points:r,getSelfSnapPoints:o=>{const s=this.getHandles(t).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(t).filter(a=>a.type==="vertex").findIndex(a=>a.id===o.id),i=ra(t).segments.filter((a,l)=>l!==s-1&&l!==s);return i.length?new no({children:i}):null}}}}m(kh,"type","line"),m(kh,"props",dE),m(kh,"migrations",hE);function hS(e){return Object.values(e.props.points).sort(Rt)}function ra(e){const n=hS(e).map(b.From);switch(e.props.spline){case"cubic":return new ch({points:n});case"line":return new Oi({points:n})}}const To=200;class Th extends Lr{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"hideResizeHandles",()=>!0);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"onBeforeCreate",t=>cP(this.editor,t,t.props.growY));m(this,"onBeforeUpdate",(t,r)=>{if(!(t.props.text===r.props.text&&t.props.font===r.props.font&&t.props.size===r.props.size))return cP(this.editor,r,t.props.growY)});m(this,"onEditEnd",t=>{const{id:r,type:o,props:{text:s}}=t;s.trimEnd()!==t.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,url:""}}getHeight(t){return To+t.props.growY}getGeometry(t){const r=this.getHeight(t);return new js({width:To,height:r,isFilled:!0})}component(t){const{id:r,type:o,props:{color:s,font:i,size:a,align:l,text:c,verticalAlign:u}}=t,d=Mt(),h=s==="black"?"yellow":s;return p.jsxs(p.Fragment,{children:[p.jsx("div",{style:{position:"absolute",width:To,height:this.getHeight(t)},children:p.jsxs("div",{className:"tl-note__container",style:{color:d[h].solid,backgroundColor:d[h].solid},children:[p.jsx("div",{className:"tl-note__scrim"}),p.jsx(Fk,{id:r,type:o,font:i,size:a,align:l,verticalAlign:u,text:c,labelColor:"black",wrap:!0})]})}),"url"in t.props&&t.props.url&&p.jsx($u,{url:t.props.url,zoomLevel:this.editor.getZoomLevel()})]})}indicator(t){return p.jsx("rect",{rx:"6",width:j(To),height:j(this.getHeight(t))})}toSvg(t,r){r.addExportDef(Tf(t.props.font));const o=Dn({isDarkMode:r.isDarkMode}),s=this.editor.getShapeGeometry(t).bounds,i=document.createElementNS("http://www.w3.org/2000/svg","g"),a=t.props.color==="black"?"yellow":t.props.color,l=document.createElementNS("http://www.w3.org/2000/svg","rect");l.setAttribute("rx","10"),l.setAttribute("width",To.toString()),l.setAttribute("height",s.height.toString()),l.setAttribute("fill",o[a].solid),l.setAttribute("stroke",o[a].solid),l.setAttribute("stroke-width","1"),i.appendChild(l);const c=document.createElementNS("http://www.w3.org/2000/svg","rect");c.setAttribute("rx","10"),c.setAttribute("width",To.toString()),c.setAttribute("height",s.height.toString()),c.setAttribute("fill",o.background),c.setAttribute("opacity",".28"),i.appendChild(c);const u=zk({editor:this.editor,shape:t,font:mu[t.props.font],bounds:s});return u.setAttribute("fill",o.text),u.setAttribute("stroke","none"),i.appendChild(u),i}}m(Th,"type","note"),m(Th,"props",pE),m(Th,"migrations",fE);function cP(e,n,t=0){const s=e.textMeasure.measureText(n.props.text,{...Ut,fontFamily:Lo[n.props.font],fontSize:Ka[n.props.size],maxWidth:To-34}).h+17*2;let i=null;if(s>To?i=s-To:t&&(i=0),i!==null)return{...n,props:{...n.props,growY:i}}}function qK(e,{initialBounds:n,scaleX:t,scaleY:r,newPoint:o}){const s=Math.max(.01,Math.min(Math.abs(t),Math.abs(r))),i=new b(0,0);t<0&&(i.x=-(n.width*s)),r<0&&(i.y=-(n.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 ZK=new e0;class $h extends Lr{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"isAspectRatioLocked",()=>!0);m(this,"onResize",(t,r)=>{const{initialBounds:o,initialShape:s,scaleX:i,handle:a}=r;if(r.mode==="scale_shape"||a!=="right"&&a!=="left")return{id:t.id,type:t.type,...qK(t,r)};{const l=o.width;let c=l*i;const u=new b(0,0);c=Math.max(1,Math.abs(c)),a==="left"?(u.x=l-c,i<0&&(u.x+=c)):i<0&&(u.x-=c);const{x:d,y:h}=u.rot(t.rotation).add(s);return{id:t.id,type:t.type,x:d,y:h,props:{w:c/s.props.scale,autoSize:!1}}}});m(this,"onBeforeCreate",t=>{if(!t.props.autoSize||t.props.text.trim())return;const r=this.getMinDimensions(t);return{...t,x:t.x-r.width/2,y:t.y-r.height/2}});m(this,"onEditEnd",t=>{const{id:r,type:o,props:{text:s}}=t,i=t.props.text.trimEnd();i.length===0?this.editor.deleteShapes([t.id]):i!==t.props.text&&this.editor.updateShapes([{id:r,type:o,props:{text:s.trimEnd()}}])});m(this,"onBeforeUpdate",(t,r)=>{if(!r.props.autoSize)return;const o=t.props.size!==r.props.size||t.props.align!==r.props.align||t.props.font!==r.props.font||t.props.scale!==1&&r.props.scale===1,s=t.props.text!==r.props.text;if(!o&&!s)return;const i=this.getMinDimensions(t),a=uP(this.editor,r.props),l=i.width*t.props.scale,c=i.height*t.props.scale,u=a.width*r.props.scale,d=a.height*r.props.scale;let h;switch(r.props.align){case"middle":{h=new b((u-l)/2,s?0:(d-c)/2);break}case"end":{h=new b(u-l,s?0:(d-c)/2);break}default:{if(s)break;h=new b(0,(d-c)/2);break}}if(h){h.rot(r.rotation);const{x:f,y}=r;return{...r,x:f-h.x,y:y-h.y,props:{...r.props,w:u}}}else return{...r,props:{...r.props,w:u}}});m(this,"onDoubleClickEdge",t=>{if(!t.props.autoSize)return{id:t.id,type:t.type,props:{autoSize:!0}};if(t.props.scale!==1)return{id:t.id,type:t.type,props:{scale:1}}})}getDefaultProps(){return{color:"black",size:"m",w:8,text:"",font:"draw",align:"middle",autoSize:!0,scale:1}}getMinDimensions(t){return ZK.get(t.props,r=>uP(this.editor,r))}getGeometry(t){const{scale:r}=t.props,{width:o,height:s}=this.getMinDimensions(t);return new js({width:o*r,height:s*r,isFilled:!0})}component(t){const{id:r,type:o,props:{text:s,color:i}}=t,a=Dn({isDarkMode:this.editor.user.getIsDarkMode()}),{width:l,height:c}=this.getMinDimensions(t),{rInput:u,isEmpty:d,isEditing:h,handleFocus:f,handleChange:y,handleKeyDown:g,handleBlur:v,handleInputPointerDown:S,handleDoubleClick:w}=j0(r,o,s);return p.jsx(wi,{id:t.id,children:p.jsxs("div",{className:"tl-text-shape__wrapper tl-text-shadow","data-font":t.props.font,"data-align":t.props.align,"data-hastext":!d,"data-isediting":h,"data-textwrap":!0,style:{fontSize:ms[t.props.size],lineHeight:ms[t.props.size]*Ut.lineHeight+"px",transform:`scale(${t.props.scale})`,transformOrigin:"top left",width:Math.max(1,l),height:Math.max(ms[t.props.size]*Ut.lineHeight,c),color:a[i].solid},children:[p.jsx("div",{className:"tl-text tl-text-content",dir:"ltr",children:s}),h?p.jsx("textarea",{ref:u,className:"tl-text tl-text-input",name:"text",tabIndex:-1,autoComplete:"false",autoCapitalize:"false",autoCorrect:"false",autoSave:"false",autoFocus:!0,placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",datatype:"wysiwyg",defaultValue:s,onFocus:f,onChange:y,onKeyDown:g,onBlur:v,onTouchEnd:It,onContextMenu:It,onPointerDown:S,onDoubleClick:w}):null]})})}indicator(t){const r=this.editor.getShapeGeometry(t).bounds,o=F();return t.props.autoSize&&o.getEditingShapeId()===t.id?null:p.jsx("rect",{width:j(r.width),height:j(r.height)})}toSvg(t,r){r.addExportDef(Tf(t.props.font));const o=Dn({isDarkMode:r.isDarkMode}),s=this.editor.getShapeGeometry(t).bounds,i=t.props.text,a=s.width/(t.props.scale??1),l=s.height/(t.props.scale??1),c={fontSize:ms[t.props.size],fontFamily:mu[t.props.font],textAlign:t.props.align,verticalTextAlign:"middle",width:a,height:l,padding:0,lineHeight:Ut.lineHeight,fontStyle:"normal",fontWeight:"normal",overflow:"wrap"},u=o[t.props.color].solid,d=document.createElementNS("http://www.w3.org/2000/svg","g"),h=kf(this.editor,this.editor.textMeasure.measureTextSpans(i,c),{...c,stroke:o.background,strokeWidth:2,fill:o.background,padding:0}),f=h.cloneNode(!0);return f.setAttribute("fill",u),f.setAttribute("stroke","none"),d.append(h),d.append(f),d}}m($h,"type","text"),m($h,"props",gE),m($h,"migrations",mE);function uP(e,n){const{font:t,text:r,autoSize:o,size:s,w:i}=n,a=o?16:Math.max(16,i),l=ms[s],c=o?null:Math.floor(Math.max(a,i)),u=e.textMeasure.measureText(r,{...Ut,fontFamily:Lo[t],fontSize:l,maxWidth:c});return o&&(u.w+=1),{width:Math.max(a,u.w),height:Math.max(l,u.h)}}class Mh extends al{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"isAspectRatioLocked",()=>!0)}getDefaultProps(){return{w:100,h:100,assetId:null,time:0,playing:!0,url:""}}component(t){return p.jsx(JK,{shape:t,videoUtil:this})}indicator(t){return p.jsx("rect",{width:j(t.props.w),height:j(t.props.h)})}toSvg(t){const r=document.createElementNS("http://www.w3.org/2000/svg","g"),o=document.createElementNS("http://www.w3.org/2000/svg","image");return o.setAttributeNS("http://www.w3.org/1999/xlink","href",QK(t.id)),o.setAttribute("width",t.props.w.toString()),o.setAttribute("height",t.props.h.toString()),r.appendChild(o),r}}m(Mh,"type","video"),m(Mh,"props",yE),m(Mh,"migrations",SE);function QK(e){const n=e.split(":")[1],t=document.querySelector(`.tl-video-shape-${n}`);if(t){const r=document.createElement("canvas");return r.width=t.videoWidth,r.height=t.videoHeight,r.getContext("2d").drawImage(t,0,0),r.toDataURL("image/png")}else throw new Error("Video with not found when attempting serialization.")}const JK=Tt(function(n){const{shape:t,videoUtil:r}=n,o=r.editor.getShapeGeometry(t).bounds.w*r.editor.getZoomLevel()>=110,s=t.props.assetId?r.editor.getAsset(t.props.assetId):null,{time:i,playing:a}=t.props,l=xf(t.id),c=Qk(),u=ie.useRef(null),d=ie.useCallback(S=>{const w=S.currentTarget;r.editor.updateShapes([{type:"video",id:t.id,props:{playing:!0,time:w.currentTime}}])},[t.id,r.editor]),h=ie.useCallback(S=>{const w=S.currentTarget;r.editor.updateShapes([{type:"video",id:t.id,props:{playing:!1,time:w.currentTime}}])},[t.id,r.editor]),f=ie.useCallback(S=>{const w=S.currentTarget;l&&r.editor.updateShapes([{type:"video",id:t.id,props:{time:w.currentTime}}])},[l,t.id,r.editor]),[y,g]=ie.useState(!1),v=ie.useCallback(S=>{const w=S.currentTarget;i!==w.currentTime&&(w.currentTime=i),a||w.pause(),g(!0)},[a,i]);return ie.useEffect(()=>{const S=u.current;S&&(y&&!l&&i!==S.currentTime&&(S.currentTime=i),l&&document.activeElement!==S&&S.focus())},[l,y,i]),ie.useEffect(()=>{if(c){const S=u.current;S.pause(),S.currentTime=0}},[u,c]),p.jsxs(p.Fragment,{children:[p.jsx(wi,{id:t.id,children:p.jsx("div",{className:"tl-counter-scaled",children:s!=null&&s.props.src?p.jsx("video",{ref:u,style:l?{pointerEvents:"all"}:void 0,className:`tl-video tl-video-shape-${t.id.split(":")[1]}`,width:"100%",height:"100%",draggable:!1,playsInline:!0,autoPlay:!0,muted:!0,loop:!0,disableRemotePlayback:!0,disablePictureInPicture:!0,controls:l&&o,onPlay:d,onPause:h,onTimeUpdate:f,onLoadedData:v,hidden:!y,children:p.jsx("source",{src:s.props.src})}):null})}),"url"in t.props&&t.props.url&&p.jsx($u,{url:t.props.url,zoomLevel:r.editor.getZoomLevel()})]})}),r2=[$h,xh,bh,Ih,Th,kh,Ch,wh,Eh,Ph,_h,Mh];function eV(e){return[e.sideEffects.registerAfterChangeHandler("instance",(n,t)=>{n.isFocused!==t.isFocused&&(t.isFocused?e.getContainer().focus():(e.complete(),e.getContainer().blur()))}),e.sideEffects.registerAfterChangeHandler("instance_page_state",(n,t)=>{if(n.croppingShapeId!==t.croppingShapeId){const r=e.isInAny("select.crop","select.pointing_crop_handle","select.cropping");!n.croppingShapeId&&t.croppingShapeId?r||e.setCurrentTool("select.crop.idle"):n.croppingShapeId&&!t.croppingShapeId&&r&&e.setCurrentTool("select.idle")}n.editingShapeId!==t.editingShapeId&&(!n.editingShapeId&&t.editingShapeId?e.isIn("select.editing_shape")||e.setCurrentTool("select.editing_shape"):n.editingShapeId&&!t.editingShapeId&&e.isIn("select.editing_shape")&&e.setCurrentTool("select.idle"))})]}class o2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"scribbleId","id");m(this,"markId","");m(this,"excludedShapeIds",new Set);m(this,"onEnter",t=>{this.markId="erase scribble begin",this.editor.mark(this.markId),this.info=t;const{originPagePoint:r}=this.editor.inputs;this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(s=>{if(this.editor.isShapeOrAncestorLocked(s))return!0;if(this.editor.isShapeOfType(s,"group")||this.editor.isShapeOfType(s,"frame")){const i=this.editor.getPointInShapeSpace(s,r);return this.editor.getShapeGeometry(s).bounds.containsPoint(i)}return!1}).map(s=>s.id));const o=this.editor.scribbles.addScribble({color:"muted-1",size:12});this.scribbleId=o.id,this.update()});m(this,"pushPointToScribble",()=>{const{x:t,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,t,r)});m(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});m(this,"onPointerMove",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()})}update(){const t=this.editor.getErasingShapeIds(),r=this.editor.getZoomLevel(),o=this.editor.getCurrentPageShapes(),{inputs:{currentPagePoint:s,previousPagePoint:i}}=this.editor,{excludedShapeIds:a}=this;this.pushPointToScribble();const l=new Set(t);for(const c of o){if(this.editor.isShapeOfType(c,"group"))continue;const u=this.editor.getShapeMask(c.id);if(u&&!Br(s,u))continue;const d=this.editor.getShapeGeometry(c),h=this.editor.getPointInShapeSpace(c,i),f=this.editor.getPointInShapeSpace(c,s);d.hitTestLineSegment(h,f,Ur/r)&&l.add(this.editor.getOutermostSelectableShape(c).id)}this.editor.setErasingShapes([...l].filter(c=>!a.has(c)))}complete(){this.editor.deleteShapes(this.editor.getCurrentPageState().erasingShapeIds),this.editor.setErasingShapes([]),this.parent.transition("idle")}cancel(){this.editor.setErasingShapes([]),this.editor.bailToMark(this.markId),this.parent.transition("idle",this.info)}}m(o2,"id","erasing");var xy;let tV=(xy=class extends oe{constructor(){super(...arguments);m(this,"onPointerDown",t=>{this.parent.transition("pointing",t)});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(xy,"id","idle"),xy);var by;let nV=(by=class extends oe{constructor(){super(...arguments);m(this,"onEnter",()=>{const t=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:Ur/t})){const u=this.editor.getOutermostSelectableShape(c);if(this.editor.isShapeOfType(u,"frame")&&s.size>i)break;s.add(u.id)}}this.editor.setErasingShapes([...s])});m(this,"onPointerMove",t=>{this.editor.inputs.isDragging&&this.parent.transition("erasing",t)});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()})}complete(){const t=this.editor.getErasingShapeIds();t.length&&(this.editor.mark("erase end"),this.editor.deleteShapes(t)),this.editor.setErasingShapes([]),this.parent.transition("idle")}cancel(){this.editor.setErasingShapes([]),this.parent.transition("idle")}},m(by,"id","pointing"),by);class Ah extends oe{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})})}}m(Ah,"id","eraser"),m(Ah,"initial","idle"),m(Ah,"children",()=>[tV,nV,o2]);class s2 extends oe{constructor(){super(...arguments);m(this,"onEnter",()=>{this.update()});m(this,"onPointerMove",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()})}update(){const{currentScreenPoint:t,previousScreenPoint:r}=this.editor.inputs,o=b.Sub(t,r);(Math.abs(o.x)>0||Math.abs(o.y)>0)&&this.editor.pan(o)}complete(){this.editor.slideCamera({speed:Math.min(2,this.editor.inputs.pointerVelocity.len()),direction:this.editor.inputs.pointerVelocity,friction:rh}),this.parent.transition("idle")}}m(s2,"id","dragging");var Py;let rV=(Py=class extends oe{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.setCursor({type:"grab",rotation:0})});m(this,"onPointerDown",t=>{this.parent.transition("pointing",t)});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(Py,"id","idle"),Py);var Cy;let oV=(Cy=class extends oe{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.stopCameraAnimation(),this.editor.updateInstanceState({cursor:{type:"grabbing",rotation:0}},{ephemeral:!0})});m(this,"onPointerMove",t=>{this.editor.inputs.isDragging&&this.parent.transition("dragging",t)});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.complete()})}complete(){this.parent.transition("idle")}},m(Cy,"id","pointing"),Cy);class jh extends oe{constructor(){super(...arguments);m(this,"onDoubleClick",t=>{if(t.phase==="settle"){const{currentScreenPoint:r}=this.editor.inputs;this.editor.zoomIn(r,{duration:220,easing:tn.easeOutQuint})}});m(this,"onTripleClick",t=>{if(t.phase==="settle"){const{currentScreenPoint:r}=this.editor.inputs;this.editor.zoomOut(r,{duration:320,easing:tn.easeOutQuint})}});m(this,"onQuadrupleClick",t=>{if(t.phase==="settle"){const r=this.editor.getZoomLevel(),{inputs:{currentScreenPoint:o}}=this.editor;r===1?this.editor.zoomToFit({duration:400,easing:tn.easeOutQuint}):this.editor.resetZoom(o,{duration:320,easing:tn.easeOutQuint})}})}}m(jh,"id","hand"),m(jh,"initial","idle"),m(jh,"children",()=>[rV,oV,s2]);var Iy;let sV=(Iy=class extends oe{constructor(){super(...arguments);m(this,"onPointerDown",t=>{this.parent.transition("lasering",t)})}},m(Iy,"id","idle"),Iy);class i2 extends oe{constructor(){super(...arguments);m(this,"scribbleId","id");m(this,"onEnter",()=>{const t=this.editor.scribbles.addScribble({color:"laser",opacity:.7,size:4,delay:1200,shrink:.05,taper:!0});this.scribbleId=t.id,this.pushPointToScribble()});m(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});m(this,"onPointerMove",()=>{this.pushPointToScribble()});m(this,"onPointerUp",()=>{this.complete()});m(this,"pushPointToScribble",()=>{const{x:t,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,t,r)});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()})}complete(){this.parent.transition("idle")}cancel(){this.parent.transition("idle")}}m(i2,"id","lasering");class Oh extends oe{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})})}}m(Oh,"id","laser"),m(Oh,"initial","idle"),m(Oh,"children",()=>[sV,i2]);class a2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"brush",new ne);m(this,"initialSelectedShapeIds",[]);m(this,"excludedShapeIds",new Set);m(this,"isWrapMode",!1);m(this,"initialStartShape",null);m(this,"onEnter",t=>{const{altKey:r,currentPagePoint:o}=this.editor.inputs;if(this.isWrapMode=this.editor.user.getIsWrapMode(),r){this.parent.transition("scribble_brushing",t);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=t,this.initialSelectedShapeIds=this.editor.getSelectedShapeIds().slice(),this.initialStartShape=this.editor.getShapesAtPoint(o)[0],this.onPointerMove()});m(this,"onExit",()=>{this.initialSelectedShapeIds=[],this.editor.updateInstanceState({brush:null})});m(this,"onTick",()=>{l0(this.editor)});m(this,"onPointerMove",()=>{this.hitTestShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",t=>{this.editor.setSelectedShapes(this.initialSelectedShapeIds,{squashing:!0}),this.parent.transition("idle",t)});m(this,"onKeyDown",t=>{this.editor.inputs.altKey?this.parent.transition("scribble_brushing",t):this.hitTestShapes()});m(this,"onKeyUp",()=>{this.hitTestShapes()});m(this,"onInterrupt",()=>{this.editor.updateInstanceState({brush:null})})}complete(){this.parent.transition("idle")}hitTestShapes(){const t=this.editor.getZoomLevel(),r=this.editor.getCurrentPageShapes(),o=this.editor.getCurrentPageId(),{inputs:{originPagePoint:s,currentPagePoint:i,shiftKey:a,ctrlKey:l}}=this.editor;this.brush.setTo(ne.FromPoints([s,i]));const c=new Set(a?this.initialSelectedShapeIds:[]);let u,d,h,f,y,g;const{corners:v}=this.brush,{excludedShapeIds:S,isWrapMode:w}=this,C=w?!l:l;e:for(let I=0,P=r.length;I<P;I++){if(h=r[I],S.has(h.id)||c.has(h.id)||(f=this.editor.getShapePageBounds(h),!f))continue e;if(this.brush.contains(f)){this.handleHit(h,i,o,c,v);continue e}if(C||this.editor.isShapeOfType(h,"frame"))continue e;if(this.brush.collides(f)){const E=this.editor.getShapeGeometry(h);if(y=this.editor.getShapePageTransform(h),!y)continue e;g=y.clone().invert().applyToPoints(v);t:for(let _=0;_<g.length;_++)if(u=g[_],d=g[(_+1)%g.length],E.hitTestLineSegment(u,d,Ur/t)){this.handleHit(h,i,o,c,v);break t}}}this.editor.updateInstanceState({brush:{...this.brush.toJson()}}),this.editor.setSelectedShapes(Array.from(c),{squashing:!0})}handleHit(t,r,o,s,i){if(t.parentId===o){s.add(t.id);return}const a=this.editor.getOutermostSelectableShape(t),l=this.editor.getShapeMask(a.id);l&&!z6(l,i)&&!Br(r,l)||s.add(a.id)}}m(a2,"id","brushing");function L0(e){const n=e.getZoomLevel(),{inputs:{currentPagePoint:t}}=e;return e.getShapeAtPoint(t,{hitInside:!1,hitLabels:!1,margin:Ur/n,renderingOnly:!0})??e.getSelectedShapeAtPoint(t)}function l2(e,n,t){if(!n)throw Error("Needs to translate a cropped shape!");const{crop:r}=n.props;if(!r)return;const o=e.inputs.shiftKey?Math.abs(t.x)<Math.abs(t.y)?"x":"y":null;o==="x"?t.x=0:o==="y"&&(t.y=0),t.rot(-n.rotation);const s=1/(r.bottomRight.x-r.topLeft.x)*n.props.w,i=1/(r.bottomRight.y-r.topLeft.y)*n.props.h,a=r.bottomRight.y-r.topLeft.y,l=r.bottomRight.x-r.topLeft.x,c=pr(r);return c.topLeft.x=Math.min(1-l,Math.max(0,c.topLeft.x-t.x/s)),c.topLeft.y=Math.min(1-a,Math.max(0,c.topLeft.y-t.y/i)),c.bottomRight.x=c.topLeft.x+l,c.bottomRight.y=c.topLeft.y+a,{id:n.id,type:n.type,props:{crop:c}}}var Ey;let iV=(Ey=class extends oe{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0});const t=this.editor.getOnlySelectedShape();this.editor.on("change-history",this.cleanupCroppingState),t&&(this.editor.mark("crop"),this.editor.setCroppingShape(t.id))});m(this,"onExit",()=>{this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0}),this.editor.off("change-history",this.cleanupCroppingState)});m(this,"onCancel",()=>{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})});m(this,"onPointerDown",t=>{var r;if(!this.editor.getIsMenuOpen()){if(t.ctrlKey){this.cancel(),this.editor.root.handleEvent(t);return}switch(t.target){case"canvas":{const o=L0(this.editor);if(o&&!this.editor.isShapeOfType(o,"group")){this.onPointerDown({...t,shape:o,target:"shape"});return}this.cancel(),this.editor.root.handleEvent(t);break}case"shape":{if(t.shape.id===this.editor.getCroppingShapeId()){this.editor.setCurrentTool("select.crop.pointing_crop",t);return}else(r=this.editor.getShapeUtil(t.shape))!=null&&r.canCrop(t.shape)?(this.editor.setCroppingShape(t.shape.id),this.editor.setSelectedShapes([t.shape.id]),this.editor.setCurrentTool("select.crop.pointing_crop",t)):(this.cancel(),this.editor.root.handleEvent(t));break}case"selection":{switch(t.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",{...t,onInteractionEnd:"select.crop"});break}case"top":case"right":case"bottom":case"left":{this.editor.setCurrentTool("select.pointing_crop_handle",{...t,onInteractionEnd:"select.crop"});break}case"top_left":case"top_right":case"bottom_left":case"bottom_right":{this.editor.setCurrentTool("select.pointing_crop_handle",{...t,onInteractionEnd:"select.crop"});break}default:this.cancel()}break}}}});m(this,"onDoubleClick",t=>{var i;if(this.editor.inputs.shiftKey||t.phase!=="up")return;const r=this.editor.getCroppingShapeId();if(!r)return;const o=this.editor.getShape(r);if(!o)return;const s=this.editor.getShapeUtil(o);s&&t.target==="selection"&&((i=s.onDoubleClickEdge)==null||i.call(s,o))});m(this,"onKeyDown",()=>{this.nudgeCroppingImage(!1)});m(this,"onKeyRepeat",()=>{this.nudgeCroppingImage(!0)});m(this,"onKeyUp",t=>{switch(t.code){case"Enter":{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{});break}}});m(this,"cleanupCroppingState",()=>{this.editor.getCroppingShapeId()||this.editor.setCurrentTool("select.idle",{})})}cancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}nudgeCroppingImage(t=!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=l2(this.editor,i,s);a&&(t||this.editor.mark("translate crop"),this.editor.updateShapes([a]))}},m(Ey,"id","idle"),Ey);class c2 extends oe{constructor(){super(...arguments);m(this,"onCancel",()=>{this.editor.setCurrentTool("select.crop.idle",{})});m(this,"onPointerMove",t=>{this.editor.inputs.isDragging&&this.editor.setCurrentTool("select.crop.translating_crop",t)});m(this,"onPointerUp",t=>{this.editor.setCurrentTool("select.crop.idle",t)})}}m(c2,"id","pointing_crop");class u2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"markId","translating crop");m(this,"snapshot",{});m(this,"onEnter",t=>{this.info=t,this.snapshot=this.createSnapshot(),this.editor.mark(this.markId),this.editor.setCursor({type:"move",rotation:0}),this.updateShapes()});m(this,"onExit",()=>{this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})});m(this,"onPointerMove",()=>{this.updateShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onKeyDown",t=>{switch(t.key){case"Alt":case"Shift":{this.updateShapes();return}}});m(this,"onKeyUp",t=>{switch(t.key){case"Enter":{this.complete();return}case"Alt":case"Shift":this.updateShapes()}})}complete(){this.updateShapes(),this.editor.setCurrentTool("select.crop.idle",this.info)}cancel(){this.editor.bailToMark(this.markId),this.editor.setCurrentTool("select.crop.idle",this.info)}createSnapshot(){return{shape:this.editor.getOnlySelectedShape()}}updateShapes(){const t=this.snapshot.shape;if(!t)return;const{originPagePoint:r,currentPagePoint:o}=this.editor.inputs,s=o.clone().sub(r),i=l2(this.editor,t,s);i&&this.editor.updateShapes([i],{squashing:!0})}}m(u2,"id","translating_crop");class Dh extends oe{}m(Dh,"id","crop"),m(Dh,"initial","idle"),m(Dh,"children",()=>[iV,u2,c2]);const ir=8,Va={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 d2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",t=>{this.info=t,this.updateCursor()});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.parent.transition("resizing",this.info)});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}updateCursor(){const t=this.editor.getSelectedShapes(),r=Va[this.info.handle];this.editor.updateInstanceState({cursor:{type:r,rotation:t.length===1?t[0].rotation:0}})}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}m(d2,"id","pointing_resize_handle");class h2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"markId","");m(this,"snapshot",{});m(this,"onEnter",t=>{this.info=t,this.markId="cropping",this.editor.mark(this.markId),this.snapshot=this.createSnapshot(),this.updateShapes()});m(this,"onPointerMove",()=>{this.updateShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"getDefaultCrop",()=>({topLeft:{x:0,y:0},bottomRight:{x:1,y:1}}))}updateCursor(){const t=this.editor.getSelectedShapes()[0];if(!t)return;const r=Va[this.info.handle];this.editor.updateInstanceState({cursor:{type:r,rotation:t.rotation}})}updateShapes(){const{shape:t,cursorHandleOffset:r}=this.snapshot;if(!t||!this.editor.getShapeUtil("image"))return;const s=t.props,i=this.editor.inputs.currentPagePoint.clone().sub(r),a=this.editor.inputs.originPagePoint.clone().sub(r),l=i.clone().sub(a).rot(-t.rotation),c=s.crop??this.getDefaultCrop(),u=pr(c),d=new b(t.x,t.y),h=new b(0,0),f=1/(c.bottomRight.x-c.topLeft.x)*s.w,y=1/(c.bottomRight.y-c.topLeft.y)*s.h;let g=!1;switch(this.info.handle){case"top":case"top_left":case"top_right":{if(y<ir)break;g=!0,u.topLeft.y=u.topLeft.y+l.y/y,y*(u.bottomRight.y-u.topLeft.y)<ir?(u.topLeft.y=u.bottomRight.y-ir/y,h.y=(u.topLeft.y-c.topLeft.y)*y):u.topLeft.y<=0?(u.topLeft.y=0,h.y=(u.topLeft.y-c.topLeft.y)*y):h.y=l.y;break}case"bottom":case"bottom_left":case"bottom_right":{if(y<ir)break;g=!0,u.bottomRight.y=Math.min(1,u.bottomRight.y+l.y/y),y*(u.bottomRight.y-u.topLeft.y)<ir&&(u.bottomRight.y=u.topLeft.y+ir/y);break}}switch(this.info.handle){case"left":case"top_left":case"bottom_left":{if(f<ir)break;g=!0,u.topLeft.x=u.topLeft.x+l.x/f,f*(u.bottomRight.x-u.topLeft.x)<ir?(u.topLeft.x=u.bottomRight.x-ir/f,h.x=(u.topLeft.x-c.topLeft.x)*f):u.topLeft.x<=0?(u.topLeft.x=0,h.x=(u.topLeft.x-c.topLeft.x)*f):h.x=l.x;break}case"right":case"top_right":case"bottom_right":{if(f<ir)break;g=!0,u.bottomRight.x=Math.min(1,u.bottomRight.x+l.x/f),f*(u.bottomRight.x-u.topLeft.x)<ir&&(u.bottomRight.x=u.topLeft.x+ir/f);break}}if(!g)return;d.add(h.rot(t.rotation));const v={id:t.id,type:t.type,x:d.x,y:d.y,props:{crop:u,w:(u.bottomRight.x-u.topLeft.x)*f,h:(u.bottomRight.y-u.topLeft.y)*y}};this.editor.updateShapes([v],{squashing:!0}),this.updateCursor()}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))}createSnapshot(){const t=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,t),a=b.Sub(r,i);return{shape:o,cursorHandleOffset:a}}}m(h2,"id","cropping");class p2 extends oe{constructor(){super(...arguments);m(this,"shapeId","");m(this,"initialHandle",{});m(this,"initialAdjacentHandle",null);m(this,"initialPagePoint",{});m(this,"markId","");m(this,"initialPageTransform");m(this,"initialPageRotation");m(this,"info",{});m(this,"isPrecise",!1);m(this,"isPreciseId",null);m(this,"pointingId",null);m(this,"onEnter",t=>{const{shape:r,isCreating:o,handle:s}=t;if(this.info=t,this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.shapeId=r.id,this.markId=o?`creating:${r.id}`:"dragging handle",o||this.editor.mark(this.markId),this.initialHandle=Dr(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=Dr(c)}this.initialPageTransform=this.editor.getShapePageTransform(r),this.initialPageRotation=this.initialPageTransform.rotation(),this.initialPagePoint=this.editor.inputs.originPagePoint.clone(),this.editor.updateInstanceState({cursor:{type:o?"cross":"grabbing",rotation:0}},{ephemeral:!0});const i=this.editor.getShapeHandles(r).sort(Rt),a=i.findIndex(l=>l.id===t.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!==t.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!==t.handle.id){this.initialAdjacentHandle=c;break}}if(this.editor.isShapeOfType(r,"arrow")){const l=r.props[t.handle.id];this.isPrecise=!1,(l==null?void 0:l.type)==="binding"?(this.editor.setHintingShapes([l.boundShapeId]),this.isPrecise=l.isPrecise,this.isPrecise?this.isPreciseId=l.boundShapeId:this.resetExactTimeout()):this.editor.setHintingShapes([])}this.update(),this.editor.select(this.shapeId)});m(this,"exactTimeout",-1);m(this,"onPointerMove",()=>{this.update()});m(this,"onKeyDown",()=>{this.update()});m(this,"onKeyUp",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.setHintingShapes([]),this.editor.snaps.clearIndicators(),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})})}resetExactTimeout(){this.exactTimeout!==-1&&this.clearExactTimeout(),this.exactTimeout=setTimeout(()=>{this.getIsActive()&&!this.isPrecise&&(this.isPrecise=!0,this.isPreciseId=this.pointingId,this.update()),this.exactTimeout=-1},750)}clearExactTimeout(){this.exactTimeout!==-1&&(clearTimeout(this.exactTimeout),this.exactTimeout=-1)}complete(){this.editor.snaps.clearIndicators();const{onInteractionEnd:t}=this.info;if(this.editor.getInstanceState().isToolLocked&&t){this.editor.setCurrentTool(t,{shapeId:this.shapeId});return}this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators();const{onInteractionEnd:t}=this.info;if(t){this.editor.setCurrentTool(t,{shapeId:this.shapeId});return}this.parent.transition("idle")}update(){var _;const{editor:t,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:d,shiftKey:h,ctrlKey:f,altKey:y,pointerVelocity:g}}=t,v=this.info.shape,S=t.getShape(r);if(!S)return;const w=t.getShapeUtil(S);let C=d.clone().sub(o).rot(-i).add(s);if(h&&a&&s.id!=="middle"){const k=b.Angle(a,C),T=hp(k,24)-k;C=b.RotWith(C,a,T)}t.snaps.clearIndicators();let I={...s,x:C.x,y:C.y};if(s.canSnap&&(c?!f:f)){if(!t.getShapePageTransform(S.id))throw Error("Expected a page transform");const M=u.handles.snapHandle({currentShapeId:r,handle:I});M&&(M.nudge.rot(-t.getShapeParentTransform(S).rotation()),C.add(M.nudge),I={...s,x:C.x,y:C.y})}const P=(_=w.onHandleDrag)==null?void 0:_.call(w,S,{handle:I,isPrecise:this.isPrecise||y,initial:v}),E={...S,...P};if(s.canBind){const k=E.props[s.id];(k==null?void 0:k.type)==="binding"?l[0]!==k.boundShapeId&&(t.setHintingShapes([k.boundShapeId]),this.pointingId=k.boundShapeId,this.isPrecise=g.len()<.5||y,this.isPreciseId=this.isPrecise?k.boundShapeId:null,this.resetExactTimeout()):l.length>0&&(t.setHintingShapes([]),this.pointingId=null,this.isPrecise=!1,this.isPreciseId=null,this.resetExactTimeout())}P&&t.updateShapes([E],{squashing:!0})}}m(p2,"id","dragging_handle");class f2 extends oe{constructor(){super(...arguments);m(this,"onEnter",()=>{const t=this.editor.getEditingShape();if(!t)throw Error("Entered editing state without an editing shape");Rc(this.editor),this.editor.select(t)});m(this,"onExit",()=>{var s;const{editingShapeId:t}=this.editor.getCurrentPageState();if(!t)return;this.editor.setEditingShape(null);const r=this.editor.getShape(t),o=this.editor.getShapeUtil(r);(s=o.onEditEnd)==null||s.call(o,r)});m(this,"onPointerMove",t=>{switch(t.target){case"shape":case"canvas":{Rc(this.editor);return}}});m(this,"onPointerDown",t=>{switch(t.target){case"canvas":{const r=L0(this.editor);if(r){this.onPointerDown({...t,shape:r,target:"shape"});return}break}case"shape":{const{shape:r}=t,o=this.editor.getEditingShape();if(!o)throw Error("Expected an editing shape!");if(r.type===o.type)if(this.editor.isShapeOfType(r,"geo")||this.editor.isShapeOfType(r,"arrow")){const i=this.editor.getShapeUtil(r).getGeometry(r).children[1];if(i){const a=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint);if(i.bounds.containsPoint(a)){if(r.id===o.id)return;this.parent.transition("pointing_shape",t);return}}}else{if(r.id===o.id)this.editor.isShapeOfType(r,"frame")&&this.editor.setEditingShape(null);else{this.parent.transition("pointing_shape",t);return}return}break}}this.parent.transition("idle",t),this.editor.root.handleEvent(t)});m(this,"onComplete",t=>{this.parent.transition("idle",t)});m(this,"onCancel",t=>{this.parent.transition("idle",t)})}}m(f2,"id","editing_shape");function dP(e){const n=e.getOnlySelectedShape();return!!(n&&!e.isShapeOrAncestorLocked(n)&&e.getShapeUtil(n).canCrop(n))}function Tp(e){const n=e.getSelectedShapeIds(),{shiftKey:t,altKey:r,currentPagePoint:o}=e.inputs,s=e.getShapeAtPoint(o,{hitInside:!1,margin:Ur/e.getZoomLevel(),hitLabels:!0,renderingOnly:!0,filter:i=>!i.isLocked});if(s){const i=e.getOutermostSelectableShape(s);if(t&&!r)e.cancelDoubleClick(),n.includes(i.id)?(e.mark("deselecting shape"),e.deselect(i)):(e.mark("shift selecting shape"),e.setSelectedShapes([...n,i.id]));else{let a;i===s||i.id===e.getFocusedGroupId()||n.includes(i.id)?a=s:a=i,a&&!n.includes(a.id)&&(e.mark("selecting shape"),e.select(a.id))}}else{if(t)return;{n.length>0&&(e.mark("selecting none"),e.selectNone());const i=e.getFocusedGroupId();if(Hn(i)){const a=e.getShape(i);e.isPointInShape(a,o,{margin:0,hitInside:!0})||e.setFocusedGroup(null)}}}}var _y;let aV=(_y=class extends oe{constructor(){super(...arguments);m(this,"onEnter",()=>{this.parent.setCurrentToolIdMask(void 0),Rc(this.editor),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})});m(this,"onPointerMove",()=>{Rc(this.editor)});m(this,"onPointerDown",t=>{if(this.editor.getIsMenuOpen())return;const r=t.ctrlKey&&dP(this.editor);if(t.ctrlKey&&!r){if(t.target==="shape"&&this.isDarwin&&this.editor.inputs.keys.has("ControlLeft")&&!this.editor.isShapeOrAncestorLocked(t.shape)){this.parent.transition("pointing_shape",t);return}this.parent.transition("brushing",t);return}switch(t.target){case"canvas":{const o=L0(this.editor);if(o&&!o.isLocked){this.onPointerDown({...t,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))&&hP(this.editor,a)){this.onPointerDown({...t,target:"selection"});return}this.parent.transition("pointing_canvas",t);break}case"shape":{const{shape:o}=t;if(this.isOverArrowLabelTest(o)){this.parent.transition("pointing_arrow_label",t);break}if(this.editor.isShapeOrAncestorLocked(o)){this.parent.transition("pointing_canvas",t);break}this.parent.transition("pointing_shape",t);break}case"handle":{if(this.editor.getInstanceState().isReadonly)break;this.editor.inputs.altKey?this.parent.transition("pointing_shape",t):this.parent.transition("pointing_handle",t);break}case"selection":{switch(t.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",t);break}case"top":case"right":case"bottom":case"left":{r?this.parent.transition("pointing_crop_handle",t):this.parent.transition("pointing_resize_handle",t);break}case"top_left":case"top_right":case"bottom_left":case"bottom_right":{r?this.parent.transition("pointing_crop_handle",t):this.parent.transition("pointing_resize_handle",t);break}default:{const o=this.editor.getHoveredShape();if(o&&!this.editor.getSelectedShapeIds().includes(o.id)&&!o.isLocked){this.onPointerDown({...t,shape:o,target:"shape"});return}this.parent.transition("pointing_selection",t)}}break}}});m(this,"onDoubleClick",t=>{var r,o,s,i;if(!(this.editor.inputs.shiftKey||t.phase!=="up"))switch(t.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:Ur/this.editor.getZoomLevel(),hitInside:!1}),c=this.editor.getFocusedGroupId();if(l){if(this.editor.isShapeOfType(l,"group")){Tp(this.editor);return}else{const u=this.editor.getShape(l.parentId);if(u&&this.editor.isShapeOfType(u,"group")&&!(c&&u.id===c)){Tp(this.editor);return}}this.onDoubleClick({...t,shape:l,target:"shape"});return}this.editor.inputs.shiftKey||this.handleDoubleClickOnCanvas(t);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(t.handle==="right"||t.handle==="left"||t.handle==="top"||t.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]);return}}if(l.canCrop(a)&&!this.editor.isShapeOrAncestorLocked(a)){this.parent.transition("crop",t);return}this.shouldStartEditingShape(a)&&this.startEditingShape(a,t)}break}case"shape":{const{shape:a}=t,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=t.shape)==null?void 0:s.id),this.parent.transition("crop",t);return}}this.shouldStartEditingShape(a)?this.startEditingShape(a,t):this.handleDoubleClickOnCanvas(t);break}case"handle":{if(this.editor.getInstanceState().isReadonly)break;const{shape:a,handle:l}=t,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,t)}}});m(this,"onRightClick",t=>{switch(t.target){case"canvas":{const r=this.editor.getHoveredShape(),o=r&&!this.editor.isShapeOfType(r,"group")?r:this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{margin:Ur/this.editor.getZoomLevel(),hitInside:!1,hitLabels:!0,hitFrameInside:!1,renderingOnly:!0});if(o){this.onRightClick({...t,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))&&hP(this.editor,a)){this.onRightClick({...t,target:"selection"});return}this.editor.selectNone();break}case"shape":{const{selectedShapeIds:r}=this.editor.getCurrentPageState(),{shape:o}=t,s=this.editor.getOutermostSelectableShape(o,i=>!r.includes(i.id));r.includes(s.id)||(this.editor.mark("selecting shape"),this.editor.setSelectedShapes([s.id]));break}}});m(this,"onCancel",()=>{this.editor.getFocusedGroupId()!==this.editor.getCurrentPageId()&&this.editor.getSelectedShapeIds().length>0?this.editor.popFocusedGroupId():(this.editor.mark("clearing selection"),this.editor.selectNone())});m(this,"onKeyDown",t=>{switch(t.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!1);break}}});m(this,"onKeyRepeat",t=>{switch(t.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!0);break}}});m(this,"onKeyUp",t=>{switch(t.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,{...t,target:"shape",shape:o});return}dP(this.editor)&&this.parent.transition("crop",t);break}}});m(this,"isDarwin",window.navigator.userAgent.toLowerCase().indexOf("mac")>-1)}shouldStartEditingShape(t=this.editor.getOnlySelectedShape()){return!t||this.editor.isShapeOrAncestorLocked(t)&&t.type!=="embed"||!this.canInteractWithShapeInReadOnly(t)?!1:this.editor.getShapeUtil(t).canEdit(t)}startEditingShape(t,r){this.editor.isShapeOrAncestorLocked(t)&&t.type!=="embed"||(this.editor.mark("editing shape"),this.editor.setEditingShape(t.id),this.parent.transition("editing_shape",r))}isOverArrowLabelTest(t){if(!t)return!1;const r=this.editor.getPointInShapeSpace(t,this.editor.inputs.currentPagePoint);if(this.editor.isShapeOfType(t,"arrow")){const o=this.editor.getShapeGeometry(t).children[1];if(o&&Br(r,o.vertices))return!0}return!1}handleDoubleClickOnCanvas(t){if(this.editor.getInstanceState().isReadonly)return;this.editor.mark("creating text shape");const r=We(),{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",t))}nudgeSelectedShapes(t=!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;t||this.editor.mark("nudge shapes");const{gridSize:i}=this.editor.getDocumentSettings(),a=this.editor.getInstanceState().isGridMode?o?i*uV:i:o?lV:cV;this.editor.nudgeShapes(this.editor.getSelectedShapeIds(),s.mul(a))}canInteractWithShapeInReadOnly(t){return!!(!this.editor.getInstanceState().isReadonly||this.editor.getShapeUtil(t).canEditInReadOnly(t))}},m(_y,"id","idle"),_y);const lV=10,cV=1,uV=5;function hP(e,n){const t=e.getSelectionRotatedPageBounds();if(!t)return!1;const r=e.getSelectionRotation();return r?Br(n,t.corners.map(o=>b.RotWith(o,t.point,r))):t.containsPoint(n)}class g2 extends oe{constructor(){super(...arguments);m(this,"shapeId","");m(this,"markId","");m(this,"info",{});m(this,"onEnter",t=>{const{shape:r}=t;this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.info=t,this.shapeId=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])});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})});m(this,"_labelDragOffset",new b(0,0));m(this,"onPointerMove",()=>{const{isDragging:t}=this.editor.inputs;if(!t)return;const r=this.editor.getShape(this.shapeId);if(!r)return;const o=this.editor.getArrowInfo(r),s=this.editor.getShapeGeometry(r),i=s.children[0],a=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint),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:d,angleEnd:h,angleStart:f}=s.children[0];c=Ly(d,f,h,u.angle(l))}isNaN(c)&&(c=.5),this.editor.updateShape({id:r.id,type:r.type,props:{labelPosition:c}},{squashing:!0})});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}updateCursor(){this.editor.setCursor({type:"grabbing",rotation:0})}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}m(g2,"id","pointing_arrow_label");class m2 extends oe{constructor(){super(...arguments);m(this,"onEnter",()=>{const{inputs:t}=this.editor;t.shiftKey||this.editor.getSelectedShapeIds().length>0&&(this.editor.mark("selecting none"),this.editor.selectNone())});m(this,"onPointerMove",t=>{this.editor.inputs.isDragging&&this.parent.transition("brushing",t)});m(this,"onPointerUp",()=>{Tp(this.editor),this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.parent.transition("idle")})}complete(){this.parent.transition("idle")}}m(m2,"id","pointing_canvas");class y2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",t=>{this.info=t,this.parent.setCurrentToolIdMask(t.onInteractionEnd);const r=this.editor.getSelectedShapes()[0];r&&(this.updateCursor(r),this.editor.setCroppingShape(r.id))});m(this,"onExit",()=>{this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0}),this.parent.setCurrentToolIdMask(void 0)});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.parent.transition("cropping",{...this.info,onInteractionEnd:this.info.onInteractionEnd})});m(this,"onPointerUp",()=>{this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}updateCursor(t){const r=Va[this.info.handle];this.editor.updateInstanceState({cursor:{type:r,rotation:t.rotation}})}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))}}m(y2,"id","pointing_crop_handle");class S2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",t=>{this.info=t;const{shape:r}=t;if(this.editor.isShapeOfType(r,"arrow")){const o=r.props[t.handle.id];(o==null?void 0:o.type)==="binding"&&this.editor.setHintingShapes([o.boundShapeId])}this.editor.updateInstanceState({cursor:{type:"grabbing",rotation:0}},{ephemeral:!0})});m(this,"onExit",()=>{this.editor.setHintingShapes([]),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})});m(this,"onPointerUp",()=>{this.parent.transition("idle",this.info)});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.parent.transition("dragging_handle",this.info)});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}cancel(){this.parent.transition("idle")}}m(S2,"id","pointing_handle");class v2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",t=>{this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.info=t,this.updateCursor()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0})});m(this,"onPointerMove",()=>{const{isDragging:t}=this.editor.inputs;t&&this.parent.transition("rotating",this.info)});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}updateCursor(){const t=this.editor.getSelectionRotation();this.editor.updateInstanceState({cursor:{type:Va[this.info.handle],rotation:t}})}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}m(v2,"id","pointing_rotate_handle");class w2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",t=>{this.info=t});m(this,"onPointerUp",t=>{Tp(this.editor),this.parent.transition("idle",t)});m(this,"onPointerMove",t=>{if(this.editor.inputs.isDragging){if(this.editor.getInstanceState().isReadonly)return;this.parent.transition("translating",t)}});m(this,"onDoubleClick",t=>{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,{...t,target:"shape",shape:this.editor.getShape(o)});return}});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}cancel(){this.parent.transition("idle")}}m(w2,"id","pointing_selection");class x2 extends oe{constructor(){super(...arguments);m(this,"hitShape",{});m(this,"hitShapeForPointerUp",{});m(this,"didSelectOnEnter",!1);m(this,"onEnter",t=>{const r=this.editor.getSelectedShapeIds(),o=this.editor.getSelectionRotatedPageBounds(),s=this.editor.getFocusedGroupId(),{inputs:{currentPagePoint:i,shiftKey:a,altKey:l}}=this.editor;this.hitShape=t.shape;const c=this.editor.getOutermostSelectableShape(t.shape);if(this.editor.getShapeUtil(t.shape).onClick||c.id===s||r.includes(c.id)||this.editor.isAncestorSelected(c.id)||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]))});m(this,"onPointerUp",t=>{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:Ur/s,hitInside:!0,renderingOnly:!0})??this.hitShape,c=l?this.editor.getOutermostSelectableShape(l):this.hitShapeForPointerUp;if(c){const d=this.editor.getShapeUtil(c);if(d.onClick){const h=(u=d.onClick)==null?void 0:u.call(d,c);if(h){this.editor.mark("shape on click"),this.editor.updateShapes([h]),this.parent.transition("idle",t);return}}if(c.id===o){r.length>0?(this.editor.mark("clearing shape ids"),this.editor.setSelectedShapes([])):this.editor.popFocusedGroupId(),this.parent.transition("idle",t);return}}if(!this.didSelectOnEnter){const d=this.editor.getOutermostSelectableShape(l,h=>!r.includes(h.id));if(r.includes(d.id))if(a)this.editor.mark("deselecting on pointer up"),this.editor.deselect(c);else if(r.includes(c.id)){if(r.length===1&&(this.editor.isShapeOfType(c,"geo")||this.editor.isShapeOfType(c,"arrow"))){const f=this.editor.getShapeGeometry(c).children[1];if(f){const y=this.editor.getPointInShapeSpace(c,i);if(f.bounds.containsPoint(y,0)&&f.hitTestPoint(y)){this.editor.batch(()=>{this.editor.mark("editing on pointer up"),this.editor.select(c.id);const g=this.editor.getShapeUtil(c);this.editor.getInstanceState().isReadonly&&!g.canEditInReadOnly(c)||(this.editor.setEditingShape(c.id),this.editor.setCurrentTool("select.editing_shape"))});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 h=this.editor.getShapeAncestors(d);this.editor.mark("shift deselecting on pointer up"),this.editor.setSelectedShapes([...this.editor.getSelectedShapeIds().filter(f=>!h.find(y=>y.id===f)),d.id])}else this.editor.mark("selecting on pointer up"),this.editor.setSelectedShapes([d.id])}this.parent.transition("idle",t)});m(this,"onPointerMove",t=>{if(this.editor.inputs.isDragging){if(this.editor.getInstanceState().isReadonly)return;this.parent.transition("translating",t)}});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}cancel(){this.parent.transition("idle")}}m(x2,"id","pointing_shape");class b2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"markId","");m(this,"didHoldCommand",!1);m(this,"creationCursorOffset",{x:0,y:0});m(this,"snapshot",{});m(this,"onEnter",t=>{const{isCreating:r=!1,creationCursorOffset:o={x:0,y:0}}=t;this.info=t,this.didHoldCommand=!1,this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.creationCursorOffset=o,this.snapshot=this._createSnapshot(),r?(this.markId=`creating:${this.editor.getOnlySelectedShape().id}`,this.editor.updateInstanceState({cursor:{type:"cross",rotation:0}},{ephemeral:!0})):(this.markId="starting resizing",this.editor.mark(this.markId)),this.handleResizeStart(),this.updateShapes()});m(this,"onTick",()=>{l0(this.editor)});m(this,"onPointerMove",()=>{this.updateShapes()});m(this,"onKeyDown",()=>{this.updateShapes()});m(this,"onKeyUp",()=>{this.updateShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0}),this.editor.snaps.clearIndicators()});m(this,"_createSnapshot",()=>{const t=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=[];t.forEach(d=>{const h=this.editor.getShape(d);if(h){if(h.type==="frame"&&c.push({id:d,children:ge(this.editor.getSortedChildIdsForParent(h).map(f=>this.editor.getShape(f)))}),l.set(h.id,this._createShapeSnapshot(h)),this.editor.isShapeOfType(h,"frame")&&t.length===1)return;this.editor.visitDescendants(h.id,f=>{const y=this.editor.getShape(f);if(y&&(l.set(y.id,this._createShapeSnapshot(y)),this.editor.isShapeOfType(y,"frame")))return!1})}});const u=![...l.values()].some(d=>!bE(d.pageRotation,r)||d.isAspectRatioLocked);return{shapeSnapshots:l,selectionBounds:s,cursorHandleOffset:a,selectionRotation:r,selectedShapeIds:t,canShapesDeform:u,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:c}});m(this,"_createShapeSnapshot",t=>{const r=this.editor.getShapePageTransform(t),o=this.editor.getShapeUtil(t);return{shape:t,bounds:this.editor.getShapeGeometry(t).bounds,pageTransform:r,pageRotation:re.Decompose(r).rotation,isAspectRatioLocked:o.isAspectRatioLocked(t)}})}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}complete(){var t,r;if(this.handleResizeEnd(),this.info.isCreating&&this.info.onCreate){(r=(t=this.info).onCreate)==null||r.call(t,this.editor.getOnlySelectedShape());return}if(this.editor.getInstanceState().isToolLocked&&this.info.onInteractionEnd){this.editor.setCurrentTool(this.info.onInteractionEnd,{});return}this.parent.transition("idle")}handleResizeStart(){const{shapeSnapshots:t}=this.snapshot,r=[];t.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:t}=this.snapshot,r=[];t.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:t,shiftKey:r}=this.editor.inputs,{frames:o,shapeSnapshots:s,selectionBounds:i,cursorHandleOffset:a,selectedShapeIds:l,selectionRotation:c,canShapesDeform:u}=this.snapshot,d=r||!u,{ctrlKey:h}=this.editor.inputs,f=this.editor.inputs.currentPagePoint.clone().sub(a).sub(this.creationCursorOffset),y=this.editor.inputs.originPagePoint.clone().sub(a);if(this.editor.getInstanceState().isGridMode&&!h){const{gridSize:k}=this.editor.getDocumentSettings();f.snapToGrid(k)}const g=this.info.handle,v=pP(g,Math.PI);if(this.editor.snaps.clearIndicators(),(this.editor.user.getIsSnapMode()?!h:h)&&c%Ke===0){const{nudge:k}=this.editor.snaps.shapeBounds.snapResizeShapes({dragDelta:b.Sub(f,y),initialSelectionPageBounds:this.snapshot.initialSelectionPageBounds,handle:pP(g,c),isAspectRatioLocked:d,isResizingFromCenter:t});f.add(k)}const w=b.RotWith(t?i.center:i.getHandlePoint(v),i.point,c),C=b.Sub(f,w).rot(-c),I=b.Sub(y,w).rot(-c),P=b.DivV(C,I);Number.isFinite(P.x)||(P.x=1),Number.isFinite(P.y)||(P.y=1);const E=g==="top"||g==="bottom",_=g==="left"||g==="right";d?_?P.y=Math.abs(P.x):E?P.x=Math.abs(P.y):Math.abs(P.x)>Math.abs(P.y)?P.y=Math.abs(P.x)*(P.y<0?-1:1):P.x=Math.abs(P.y)*(P.x<0?-1:1):(E&&(P.x=1),_&&(P.y=1)),this.info.isCreating||this.updateCursor({dragHandle:g,isFlippedX:P.x<0,isFlippedY:P.y<0,rotation:c});for(const k of s.keys()){const M=s.get(k);this.editor.resizeShape(k,P,{initialShape:M.shape,initialBounds:M.bounds,initialPageTransform:M.pageTransform,dragHandle:g,mode:l.length===1&&k===l[0]?"resize_bounds":"scale_shape",scaleOrigin:w,scaleAxisRotation:c})}if(this.editor.inputs.ctrlKey){this.didHoldCommand=!0;for(const{id:k,children:M}of o){if(!M.length)continue;const T=s.get(k).shape,R=this.editor.getShape(k);if(!(T&&R))continue;const O=R.x-T.x,U=R.y-T.y,N=new b(O,U).rot(-T.rotation);if(N.x!==0||N.y!==0)for(const L of M)this.editor.updateShape({id:L.id,type:L.type,x:L.x-N.x,y:L.y-N.y})}}else if(this.didHoldCommand){this.didHoldCommand=!1;for(const{children:k}of o)if(k.length)for(const M of k)this.editor.updateShape({id:M.id,type:M.type,x:M.x,y:M.y})}}updateCursor({dragHandle:t,isFlippedX:r,isFlippedY:o,rotation:s}){const i={...this.editor.getInstanceState().cursor};switch(t){case"top_left":case"bottom_right":{i.type="nwse-resize",r!==o&&(i.type="nesw-resize");break}case"top_right":case"bottom_left":{i.type="nesw-resize",r!==o&&(i.type="nwse-resize");break}}i.rotation=s,this.editor.setCursor(i)}}m(b2,"id","resizing");const wm=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function pP(e,n){n=n%De;const t=Math.round(n/($e/4)),r=wm.indexOf(e);return wm[(r+t)%wm.length]}const fP=Math.PI/180;class P2 extends oe{constructor(){super(...arguments);m(this,"snapshot",{});m(this,"info",{});m(this,"markId","");m(this,"onEnter",t=>{this.info=t,this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.markId="rotate start",this.editor.mark(this.markId);const r=d_({editor:this.editor});if(!r)return this.parent.transition("idle",this.info);this.snapshot=r,this.handleStart()});m(this,"onExit",()=>{this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0),this.snapshot={}});m(this,"onPointerMove",()=>{this.update()});m(this,"onKeyDown",()=>{this.update()});m(this,"onKeyUp",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"update",()=>{const t=this._getRotationFromPointerPosition({snapToNearestDegree:!1});ih({editor:this.editor,delta:t,snapshot:this.snapshot,stage:"update"}),this.editor.updateInstanceState({cursor:{type:Va[this.info.handle],rotation:t+this.snapshot.initialSelectionRotation}})});m(this,"cancel",()=>{this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)});m(this,"complete",()=>{ih({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!0}),snapshot:this.snapshot,stage:"end"}),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)})}handleStart(){const t=this._getRotationFromPointerPosition({snapToNearestDegree:!1});ih({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"}),this.editor.updateInstanceState({cursor:{type:Va[this.info.handle],rotation:t+this.snapshot.initialSelectionRotation}})}_getRotationFromPointerPosition({snapToNearestDegree:t}){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 d=l+u;if(s)d=hp(d,24);else if(t&&(d=Math.round(d/fP)*fP,this.editor.getInstanceState().isCoarsePointer)){const h=hp(d,4),f=ac(d,h);Math.abs(f)<$R(5)&&(d=h)}return d-l}}m(P2,"id","rotating");class C2 extends oe{constructor(){super(...arguments);m(this,"hits",new Set);m(this,"size",0);m(this,"scribbleId","id");m(this,"initialSelectedShapeIds",new Set);m(this,"newlySelectedShapeIds",new Set);m(this,"onEnter",()=>{this.initialSelectedShapeIds=new Set(this.editor.inputs.shiftKey?this.editor.getSelectedShapeIds():[]),this.newlySelectedShapeIds=new Set,this.size=0,this.hits.clear();const t=this.editor.scribbles.addScribble({color:"selection-stroke",opacity:.32,size:12});this.scribbleId=t.id,this.updateScribbleSelection(!0),requestAnimationFrame(()=>{this.editor.updateInstanceState({brush:null})})});m(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});m(this,"onPointerMove",()=>{this.updateScribbleSelection(!0)});m(this,"onPointerUp",()=>{this.complete()});m(this,"onKeyDown",()=>{this.updateScribbleSelection(!1)});m(this,"onKeyUp",()=>{this.editor.inputs.altKey?this.updateScribbleSelection(!1):this.parent.transition("brushing")});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"pushPointToScribble",()=>{const{x:t,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,t,r)})}updateScribbleSelection(t){const r=this.editor.getZoomLevel(),o=this.editor.getCurrentPageShapes(),{inputs:{shiftKey:s,originPagePoint:i,previousPagePoint:a,currentPagePoint:l}}=this.editor,{newlySelectedShapeIds:c,initialSelectedShapeIds:u}=this;t&&this.pushPointToScribble();const d=o;let h,f,y,g;for(let v=0,S=d.length;v<S;v++)if(h=d[v],f=this.editor.getShapeGeometry(h),!(this.editor.isShapeOfType(h,"group")||c.has(h.id)||this.editor.isShapeOrAncestorLocked(h))){if(this.editor.isShapeOfType(h,"frame")){const w=this.editor.getPointInShapeSpace(h,i);if(f.bounds.containsPoint(w))continue}if(y=this.editor.getPointInShapeSpace(h,a),g=this.editor.getPointInShapeSpace(h,l),f.hitTestLineSegment(y,g,Ur/r)){const w=this.editor.getOutermostSelectableShape(h),C=this.editor.getShapeMask(w.id);if(C&&i_(a,l,C)!==null&&!Br(l,C))continue;c.add(w.id)}}this.editor.setSelectedShapes([...new Set(s?[...c,...u]:[...c])],{squashing:!0})}complete(){this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds],{squashing:!0}),this.parent.transition("idle")}}m(C2,"id","scribble_brushing");const gP=100;class dV{constructor(n){m(this,"prevDroppingShapeId",null);m(this,"droppingNodeTimer",null);m(this,"first",!0);m(this,"dispose",()=>{this.clear()});this.editor=n,n.disposables.add(this.dispose)}updateDroppingNode(n,t){var r;this.first&&(this.prevDroppingShapeId=((r=this.editor.getDroppingOverShape(this.editor.inputs.originPagePoint,n))==null?void 0:r.id)??null,this.first=!1),this.droppingNodeTimer===null?this.setDragTimer(n,gP*10,t):this.editor.inputs.pointerVelocity.len()>.5&&(clearInterval(this.droppingNodeTimer),this.setDragTimer(n,gP,t))}setDragTimer(n,t,r){this.droppingNodeTimer=setTimeout(()=>{this.editor.batch(()=>{this.handleDrag(this.editor.inputs.currentPagePoint,n,r)}),this.droppingNodeTimer=null},t)}handleDrag(n,t,r){var l,c,u,d,h;t=ge(t.map(f=>this.editor.getShape(f.id)));const o=((l=this.editor.getDroppingOverShape(n,t))==null?void 0:l.id)??null;if(o===this.prevDroppingShapeId)return;const{prevDroppingShapeId:s}=this,i=s&&this.editor.getShape(s),a=o&&this.editor.getShape(o);if(i&&((u=(c=this.editor.getShapeUtil(i)).onDragShapesOut)==null||u.call(c,i,t)),a){const f=(h=(d=this.editor.getShapeUtil(a)).onDragShapesOver)==null?void 0:h.call(d,a,t);f&&f.shouldHint&&this.editor.setHintingShapes([a.id])}else this.editor.setHintingShapes([]);r==null||r(),this.prevDroppingShapeId=o}dropShapes(n){var r,o;const{prevDroppingShapeId:t}=this;if(this.handleDrag(this.editor.inputs.currentPagePoint,n),t){const s=this.editor.getShape(t);if(!s)return;(o=(r=this.editor.getShapeUtil(s)).onDropShapesOver)==null||o.call(r,s,n)}}clear(){this.prevDroppingShapeId=null,this.droppingNodeTimer!==null&&clearInterval(this.droppingNodeTimer),this.droppingNodeTimer=null,this.editor.setHintingShapes([]),this.first=!0}}class I2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"selectionSnapshot",{});m(this,"snapshot",{});m(this,"markId","");m(this,"isCloning",!1);m(this,"isCreating",!1);m(this,"onCreate",()=>{});m(this,"dragAndDropManager",new dV(this.editor));m(this,"onEnter",t=>{const{isCreating:r=!1,onCreate:o=()=>{}}=t;if(this.info=t,this.parent.setCurrentToolIdMask(t.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=t,this.editor.setCursor({type:"move",rotation:0}),this.selectionSnapshot=mP(this.editor),!this.isCreating&&this.editor.inputs.altKey){this.startCloning();return}this.snapshot=this.selectionSnapshot,this.handleStart(),this.updateShapes()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.selectionSnapshot={},this.snapshot={},this.editor.snaps.clearIndicators(),this.editor.updateInstanceState({cursor:{type:"default",rotation:0}},{ephemeral:!0}),this.dragAndDropManager.clear()});m(this,"onTick",()=>{this.dragAndDropManager.updateDroppingNode(this.snapshot.movingShapes,this.updateParentTransforms),l0(this.editor)});m(this,"onPointerMove",()=>{this.updateShapes()});m(this,"onKeyDown",()=>{if(this.editor.inputs.altKey&&!this.isCloning){this.startCloning();return}this.updateShapes()});m(this,"onKeyUp",()=>{if(!this.editor.inputs.altKey&&this.isCloning){this.stopCloning();return}this.updateShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"updateParentTransforms",()=>{const{editor:t,snapshot:{shapeSnapshots:r}}=this;r.forEach(o=>{const s=t.getShape(o.shape.id);if(!s)return null;const i=wn(s.parentId)?null:re.Inverse(t.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=mP(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 t;this.updateShapes(),this.dragAndDropManager.dropShapes(this.snapshot.movingShapes),this.handleEnd(),this.editor.getInstanceState().isToolLocked&&this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd):this.isCreating?(t=this.onCreate)==null||t.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:t}=this.snapshot,r=[];t.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:t}=this.snapshot;if(this.isCloning){const o=b.Average(t.map(i=>this.editor.getShapePageTransform(i.id).point())),s=b.Sub(o,this.selectionSnapshot.averagePagePoint);this.editor.updateInstanceState({duplicateProps:{shapeIds:t.map(i=>i.id),offset:{x:s.x,y:s.y}}})}const r=[];t.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)}handleChange(){const{movingShapes:t}=this.snapshot,r=[];t.forEach(o=>{var l;const s=this.editor.getShape(o.id),i=this.editor.getShapeUtil(o),a=(l=i.onTranslate)==null?void 0:l.call(i,o,s);a&&r.push(a)}),r.length>0&&this.editor.updateShapes(r)}updateShapes(){const{snapshot:t}=this;this.dragAndDropManager.updateDroppingNode(t.movingShapes,this.updateParentTransforms),hV({editor:this.editor,shapeSnapshots:t.shapeSnapshots,averagePagePoint:t.averagePagePoint,initialSelectionPageBounds:t.initialPageBounds,initialSelectionSnapPoints:t.initialSnapPoints}),this.handleChange()}}m(I2,"id","translating");function mP(e){const n=[],t=[],r=ge(e.getSelectedShapeIds().map(s=>{const i=e.getShape(s);if(!i)return null;n.push(i);const a=e.getShapePageTransform(s).point();if(!a)return null;t.push(a);const l=zo.isId(i.parentId)?null:re.Inverse(e.getShapePageTransform(i.parentId));return{shape:i,pagePoint:a,parentTransform:l}}));let o=[];if(e.getSelectedShapeIds().length===1)o=e.snaps.shapeBounds.getSnapPoints(e.getSelectedShapeIds()[0]);else{const s=e.getSelectionPageBounds();s&&(o=s.cornersAndCenter.map((i,a)=>({id:"selection:"+a,x:i.x,y:i.y})))}return{averagePagePoint:b.Average(t),movingShapes:n,shapeSnapshots:r,initialPageBounds:e.getSelectionPageBounds(),initialSnapPoints:o}}function hV({editor:e,shapeSnapshots:n,averagePagePoint:t,initialSelectionPageBounds:r,initialSelectionSnapPoints:o}){const{inputs:s}=e,i=e.getInstanceState().isGridMode,a=e.getDocumentSettings().gridSize,l=b.Sub(s.currentPagePoint,s.originPagePoint),c=e.inputs.shiftKey?Math.abs(l.x)<Math.abs(l.y)?"x":"y":null;if(c==="x"?l.x=0:c==="y"&&(l.y=0),e.snaps.clearIndicators(),(e.user.getIsSnapMode()?!s.ctrlKey:s.ctrlKey)&&e.inputs.pointerVelocity.len()<.5){const{nudge:f}=e.snaps.shapeBounds.snapTranslateShapes({dragDelta:l,initialSelectionPageBounds:r,lockedAxis:c,initialSelectionSnapPoints:o});l.add(f)}const d=b.Add(t,l);i&&!s.ctrlKey&&d.snapToGrid(a);const h=b.Sub(d,t);e.updateShapes(ge(n.map(({shape:f,pagePoint:y,parentTransform:g})=>{const v=b.Add(y,h),S=g?re.applyToPoint(g,v):v;return{id:f.id,type:f.type,x:S.x,y:S.y}})),{squashing:!0})}class Rh extends oe{constructor(){super(...arguments);m(this,"reactor");m(this,"cleanUpDuplicateProps",()=>{const t=this.editor.getSelectedShapeIds(),r=this.editor.getInstanceState();if(!r.duplicateProps)return;const o=new Set(r.duplicateProps.shapeIds);t.length===o.size&&t.every(s=>o.has(s))||this.editor.updateInstanceState({duplicateProps:null})});m(this,"onEnter",()=>{this.reactor=gu("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(t){typeof process<"u",console.error(t)}})});m(this,"onExit",()=>{var t;(t=this.reactor)==null||t.call(this),this.editor.getCurrentPageState().editingShapeId&&this.editor.setEditingShape(null)})}}m(Rh,"id","select"),m(Rh,"initial","idle"),m(Rh,"children",()=>[Dh,h2,aV,m2,x2,I2,a2,C2,y2,w2,d2,f2,b2,P2,v2,g2,S2,p2]);class E2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",t=>{this.info=t});m(this,"onPointerDown",()=>{this.parent.transition("pointing",this.info)})}}m(E2,"id","idle");class _2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",t=>{this.info=t});m(this,"onPointerUp",()=>{this.complete()});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.parent.transition("zoom_brushing",this.info)});m(this,"onCancel",()=>{this.cancel()})}complete(){const{currentScreenPoint:t}=this.editor.inputs;this.editor.inputs.altKey?this.editor.zoomOut(t,{duration:220}):this.editor.zoomIn(t,{duration:220}),this.parent.transition("idle",this.info)}cancel(){this.parent.transition("idle",this.info)}}m(_2,"id","pointing");class k2 extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"zoomBrush",new ne);m(this,"onEnter",t=>{this.info=t,this.update()});m(this,"onExit",()=>{this.editor.updateInstanceState({zoomBrush:null})});m(this,"onPointerMove",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()})}update(){const{inputs:{originPagePoint:t,currentPagePoint:r}}=this.editor;this.zoomBrush.setTo(ne.FromPoints([t,r])),this.editor.updateInstanceState({zoomBrush:this.zoomBrush.toJson()})}cancel(){this.parent.transition("idle",this.info)}complete(){const{zoomBrush:t}=this,r=8/this.editor.getZoomLevel();if(t.width<r&&t.height<r){const o=this.editor.inputs.currentScreenPoint;this.editor.inputs.altKey?this.editor.zoomOut(o,{duration:220}):this.editor.zoomIn(o,{duration:220})}else{const o=this.editor.inputs.altKey?this.editor.getZoomLevel()/2:void 0;this.editor.zoomToBounds(t,{targetZoom:o,duration:220})}this.parent.transition("idle",this.info)}}m(k2,"id","zoom_brushing");class Lh extends oe{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",t=>{this.info=t,this.parent.setCurrentToolIdMask(t.onInteractionEnd),this.updateCursor()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({zoomBrush:null,cursor:{type:"default",rotation:0}},{ephemeral:!0}),this.parent.setCurrentToolIdMask(void 0)});m(this,"onKeyDown",()=>{this.updateCursor()});m(this,"onKeyUp",t=>{this.updateCursor(),t.code==="KeyZ"&&this.complete()});m(this,"onInterrupt",()=>{this.complete()})}complete(){this.info.onInteractionEnd&&this.info.onInteractionEnd!=="select"?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("select")}updateCursor(){this.editor.inputs.altKey?this.editor.updateInstanceState({cursor:{type:"zoom-out",rotation:0}},{ephemeral:!0}):this.editor.updateInstanceState({cursor:{type:"zoom-in",rotation:0}},{ephemeral:!0})}}m(Lh,"id","zoom"),m(Lh,"initial","idle"),m(Lh,"children",()=>[E2,k2,_2]);const pV=[Ah,jh,Oh,Lh,Rh];function Q(){return Q=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},Q.apply(this,arguments)}var T2={exports:{}},tr={},$2={exports:{}},M2={};/**
|
|
175
|
+
* @license React
|
|
176
|
+
* scheduler.production.min.js
|
|
177
|
+
*
|
|
178
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
179
|
+
*
|
|
180
|
+
* This source code is licensed under the MIT license found in the
|
|
181
|
+
* LICENSE file in the root directory of this source tree.
|
|
182
|
+
*/(function(e){function n(H,B){var W=H.length;H.push(B);e:for(;0<W;){var Y=W-1>>>1,J=H[Y];if(0<o(J,B))H[Y]=B,H[W]=J,W=Y;else break e}}function t(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var B=H[0],W=H.pop();if(W!==B){H[0]=W;e:for(var Y=0,J=H.length,ke=J>>>1;Y<ke;){var ve=2*(Y+1)-1,pe=H[ve],me=ve+1,Xe=H[me];if(0>o(pe,W))me<J&&0>o(Xe,pe)?(H[Y]=Xe,H[me]=W,Y=me):(H[Y]=pe,H[ve]=W,Y=ve);else if(me<J&&0>o(Xe,W))H[Y]=Xe,H[me]=W,Y=me;else break e}}return B}function o(H,B){var W=H.sortIndex-B.sortIndex;return W!==0?W:H.id-B.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,d=null,h=3,f=!1,y=!1,g=!1,v=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(H){for(var B=t(c);B!==null;){if(B.callback===null)r(c);else if(B.startTime<=H)r(c),B.sortIndex=B.expirationTime,n(l,B);else break;B=t(c)}}function I(H){if(g=!1,C(H),!y)if(t(l)!==null)y=!0,G(P);else{var B=t(c);B!==null&&X(I,B.startTime-H)}}function P(H,B){y=!1,g&&(g=!1,S(k),k=-1),f=!0;var W=h;try{for(C(B),d=t(l);d!==null&&(!(d.expirationTime>B)||H&&!R());){var Y=d.callback;if(typeof Y=="function"){d.callback=null,h=d.priorityLevel;var J=Y(d.expirationTime<=B);B=e.unstable_now(),typeof J=="function"?d.callback=J:d===t(l)&&r(l),C(B)}else r(l);d=t(l)}if(d!==null)var ke=!0;else{var ve=t(c);ve!==null&&X(I,ve.startTime-B),ke=!1}return ke}finally{d=null,h=W,f=!1}}var E=!1,_=null,k=-1,M=5,T=-1;function R(){return!(e.unstable_now()-T<M)}function O(){if(_!==null){var H=e.unstable_now();T=H;var B=!0;try{B=_(!0,H)}finally{B?U():(E=!1,_=null)}}else E=!1}var U;if(typeof w=="function")U=function(){w(O)};else if(typeof MessageChannel<"u"){var N=new MessageChannel,L=N.port2;N.port1.onmessage=O,U=function(){L.postMessage(null)}}else U=function(){v(O,0)};function G(H){_=H,E||(E=!0,U())}function X(H,B){k=v(function(){H(e.unstable_now())},B)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(H){H.callback=null},e.unstable_continueExecution=function(){y||f||(y=!0,G(P))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return t(l)},e.unstable_next=function(H){switch(h){case 1:case 2:case 3:var B=3;break;default:B=h}var W=h;h=B;try{return H()}finally{h=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,B){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var W=h;h=H;try{return B()}finally{h=W}},e.unstable_scheduleCallback=function(H,B,W){var Y=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?Y+W:Y):W=Y,H){case 1:var J=-1;break;case 2:J=250;break;case 5:J=1073741823;break;case 4:J=1e4;break;default:J=5e3}return J=W+J,H={id:u++,callback:B,priorityLevel:H,startTime:W,expirationTime:J,sortIndex:-1},W>Y?(H.sortIndex=W,n(c,H),t(l)===null&&H===t(c)&&(g?(S(k),k=-1):g=!0,X(I,W-Y))):(H.sortIndex=J,n(l,H),y||f||(y=!0,G(P))),H},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(H){var B=h;return function(){var W=h;h=B;try{return H.apply(this,arguments)}finally{h=W}}}})(M2);$2.exports=M2;var fV=$2.exports;/**
|
|
183
|
+
* @license React
|
|
184
|
+
* react-dom.production.min.js
|
|
185
|
+
*
|
|
186
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
187
|
+
*
|
|
188
|
+
* This source code is licensed under the MIT license found in the
|
|
189
|
+
* LICENSE file in the root directory of this source tree.
|
|
190
|
+
*/var A2=x,Jn=fV;function q(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,t=1;t<arguments.length;t++)n+="&args[]="+encodeURIComponent(arguments[t]);return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var j2=new Set,Fc={};function Ni(e,n){Wa(e,n),Wa(e+"Capture",n)}function Wa(e,n){for(Fc[e]=n,e=0;e<n.length;e++)j2.add(n[e])}var Bo=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),pS=Object.prototype.hasOwnProperty,gV=/^[: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]*$/,yP={},SP={};function mV(e){return pS.call(SP,e)?!0:pS.call(yP,e)?!1:gV.test(e)?SP[e]=!0:(yP[e]=!0,!1)}function yV(e,n,t,r){if(t!==null&&t.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return r?!1:t!==null?!t.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function SV(e,n,t,r){if(n===null||typeof n>"u"||yV(e,n,t,r))return!0;if(r)return!1;if(t!==null)switch(t.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function vn(e,n,t,r,o,s,i){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=t,this.propertyName=e,this.type=n,this.sanitizeURL=s,this.removeEmptyString=i}var Kt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Kt[e]=new vn(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];Kt[n]=new vn(n,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Kt[e]=new vn(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Kt[e]=new vn(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Kt[e]=new vn(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Kt[e]=new vn(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Kt[e]=new vn(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Kt[e]=new vn(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Kt[e]=new vn(e,5,!1,e.toLowerCase(),null,!1,!1)});var N0=/[\-:]([a-z])/g;function F0(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 n=e.replace(N0,F0);Kt[n]=new vn(n,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(N0,F0);Kt[n]=new vn(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(N0,F0);Kt[n]=new vn(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Kt[e]=new vn(e,1,!1,e.toLowerCase(),null,!1,!1)});Kt.xlinkHref=new vn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Kt[e]=new vn(e,1,!1,e.toLowerCase(),null,!0,!0)});function z0(e,n,t,r){var o=Kt.hasOwnProperty(n)?Kt[n]:null;(o!==null?o.type!==0:r||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(SV(n,t,o,r)&&(t=null),r||o===null?mV(n)&&(t===null?e.removeAttribute(n):e.setAttribute(n,""+t)):o.mustUseProperty?e[o.propertyName]=t===null?o.type===3?!1:"":t:(n=o.attributeName,r=o.attributeNamespace,t===null?e.removeAttribute(n):(o=o.type,t=o===3||o===4&&t===!0?"":""+t,r?e.setAttributeNS(r,n,t):e.setAttribute(n,t))))}var Qo=A2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Id=Symbol.for("react.element"),ya=Symbol.for("react.portal"),Sa=Symbol.for("react.fragment"),B0=Symbol.for("react.strict_mode"),fS=Symbol.for("react.profiler"),O2=Symbol.for("react.provider"),D2=Symbol.for("react.context"),U0=Symbol.for("react.forward_ref"),gS=Symbol.for("react.suspense"),mS=Symbol.for("react.suspense_list"),H0=Symbol.for("react.memo"),ls=Symbol.for("react.lazy"),R2=Symbol.for("react.offscreen"),vP=Symbol.iterator;function Rl(e){return e===null||typeof e!="object"?null:(e=vP&&e[vP]||e["@@iterator"],typeof e=="function"?e:null)}var ct=Object.assign,xm;function Jl(e){if(xm===void 0)try{throw Error()}catch(t){var n=t.stack.trim().match(/\n( *(at )?)/);xm=n&&n[1]||""}return`
|
|
191
|
+
`+xm+e}var bm=!1;function Pm(e,n){if(!e||bm)return"";bm=!0;var t=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(c){var r=c}Reflect.construct(e,[],n)}else{try{n.call()}catch(c){r=c}e.call(n.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(`
|
|
192
|
+
`),s=r.stack.split(`
|
|
193
|
+
`),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=`
|
|
194
|
+
`+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{bm=!1,Error.prepareStackTrace=t}return(e=e?e.displayName||e.name:"")?Jl(e):""}function vV(e){switch(e.tag){case 5:return Jl(e.type);case 16:return Jl("Lazy");case 13:return Jl("Suspense");case 19:return Jl("SuspenseList");case 0:case 2:case 15:return e=Pm(e.type,!1),e;case 11:return e=Pm(e.type.render,!1),e;case 1:return e=Pm(e.type,!0),e;default:return""}}function yS(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 Sa:return"Fragment";case ya:return"Portal";case fS:return"Profiler";case B0:return"StrictMode";case gS:return"Suspense";case mS:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case D2:return(e.displayName||"Context")+".Consumer";case O2:return(e._context.displayName||"Context")+".Provider";case U0:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H0:return n=e.displayName||null,n!==null?n:yS(e.type)||"Memo";case ls:n=e._payload,e=e._init;try{return yS(e(n))}catch{}}return null}function wV(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return yS(n);case 8:return n===B0?"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 n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Os(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function L2(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function xV(e){var n=L2(e)?"checked":"value",t=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),r=""+e[n];if(!e.hasOwnProperty(n)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var o=t.get,s=t.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return o.call(this)},set:function(i){r=""+i,s.call(this,i)}}),Object.defineProperty(e,n,{enumerable:t.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Ed(e){e._valueTracker||(e._valueTracker=xV(e))}function N2(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var t=n.getValue(),r="";return e&&(r=L2(e)?e.checked?"true":"false":e.value),e=r,e!==t?(n.setValue(e),!0):!1}function $p(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 SS(e,n){var t=n.checked;return ct({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??e._wrapperState.initialChecked})}function wP(e,n){var t=n.defaultValue==null?"":n.defaultValue,r=n.checked!=null?n.checked:n.defaultChecked;t=Os(n.value!=null?n.value:t),e._wrapperState={initialChecked:r,initialValue:t,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function F2(e,n){n=n.checked,n!=null&&z0(e,"checked",n,!1)}function vS(e,n){F2(e,n);var t=Os(n.value),r=n.type;if(t!=null)r==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+t):e.value!==""+t&&(e.value=""+t);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?wS(e,n.type,t):n.hasOwnProperty("defaultValue")&&wS(e,n.type,Os(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function xP(e,n,t){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var r=n.type;if(!(r!=="submit"&&r!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,t||n===e.value||(e.value=n),e.defaultValue=n}t=e.name,t!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,t!==""&&(e.name=t)}function wS(e,n,t){(n!=="number"||$p(e.ownerDocument)!==e)&&(t==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+t&&(e.defaultValue=""+t))}var ec=Array.isArray;function Oa(e,n,t,r){if(e=e.options,n){n={};for(var o=0;o<t.length;o++)n["$"+t[o]]=!0;for(t=0;t<e.length;t++)o=n.hasOwnProperty("$"+e[t].value),e[t].selected!==o&&(e[t].selected=o),o&&r&&(e[t].defaultSelected=!0)}else{for(t=""+Os(t),n=null,o=0;o<e.length;o++){if(e[o].value===t){e[o].selected=!0,r&&(e[o].defaultSelected=!0);return}n!==null||e[o].disabled||(n=e[o])}n!==null&&(n.selected=!0)}}function xS(e,n){if(n.dangerouslySetInnerHTML!=null)throw Error(q(91));return ct({},n,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function bP(e,n){var t=n.value;if(t==null){if(t=n.children,n=n.defaultValue,t!=null){if(n!=null)throw Error(q(92));if(ec(t)){if(1<t.length)throw Error(q(93));t=t[0]}n=t}n==null&&(n=""),t=n}e._wrapperState={initialValue:Os(t)}}function z2(e,n){var t=Os(n.value),r=Os(n.defaultValue);t!=null&&(t=""+t,t!==e.value&&(e.value=t),n.defaultValue==null&&e.defaultValue!==t&&(e.defaultValue=t)),r!=null&&(e.defaultValue=""+r)}function PP(e){var n=e.textContent;n===e._wrapperState.initialValue&&n!==""&&n!==null&&(e.value=n)}function B2(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 bS(e,n){return e==null||e==="http://www.w3.org/1999/xhtml"?B2(n):e==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var _d,U2=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,t,r,o){MSApp.execUnsafeLocalFunction(function(){return e(n,t,r,o)})}:e}(function(e,n){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=n;else{for(_d=_d||document.createElement("div"),_d.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=_d.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function zc(e,n){if(n){var t=e.firstChild;if(t&&t===e.lastChild&&t.nodeType===3){t.nodeValue=n;return}}e.textContent=n}var dc={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},bV=["Webkit","ms","Moz","O"];Object.keys(dc).forEach(function(e){bV.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),dc[n]=dc[e]})});function H2(e,n,t){return n==null||typeof n=="boolean"||n===""?"":t||typeof n!="number"||n===0||dc.hasOwnProperty(e)&&dc[e]?(""+n).trim():n+"px"}function K2(e,n){e=e.style;for(var t in n)if(n.hasOwnProperty(t)){var r=t.indexOf("--")===0,o=H2(t,n[t],r);t==="float"&&(t="cssFloat"),r?e.setProperty(t,o):e[t]=o}}var PV=ct({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 PS(e,n){if(n){if(PV[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(q(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(q(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(q(61))}if(n.style!=null&&typeof n.style!="object")throw Error(q(62))}}function CS(e,n){if(e.indexOf("-")===-1)return typeof n.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 IS=null;function K0(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ES=null,Da=null,Ra=null;function CP(e){if(e=Du(e)){if(typeof ES!="function")throw Error(q(280));var n=e.stateNode;n&&(n=Of(n),ES(e.stateNode,e.type,n))}}function V2(e){Da?Ra?Ra.push(e):Ra=[e]:Da=e}function W2(){if(Da){var e=Da,n=Ra;if(Ra=Da=null,CP(e),n)for(e=0;e<n.length;e++)CP(n[e])}}function G2(e,n){return e(n)}function Y2(){}var Cm=!1;function X2(e,n,t){if(Cm)return e(n,t);Cm=!0;try{return G2(e,n,t)}finally{Cm=!1,(Da!==null||Ra!==null)&&(Y2(),W2())}}function Bc(e,n){var t=e.stateNode;if(t===null)return null;var r=Of(t);if(r===null)return null;t=r[n];e:switch(n){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(t&&typeof t!="function")throw Error(q(231,n,typeof t));return t}var _S=!1;if(Bo)try{var Ll={};Object.defineProperty(Ll,"passive",{get:function(){_S=!0}}),window.addEventListener("test",Ll,Ll),window.removeEventListener("test",Ll,Ll)}catch{_S=!1}function CV(e,n,t,r,o,s,i,a,l){var c=Array.prototype.slice.call(arguments,3);try{n.apply(t,c)}catch(u){this.onError(u)}}var hc=!1,Mp=null,Ap=!1,kS=null,IV={onError:function(e){hc=!0,Mp=e}};function EV(e,n,t,r,o,s,i,a,l){hc=!1,Mp=null,CV.apply(IV,arguments)}function _V(e,n,t,r,o,s,i,a,l){if(EV.apply(this,arguments),hc){if(hc){var c=Mp;hc=!1,Mp=null}else throw Error(q(198));Ap||(Ap=!0,kS=c)}}function Fi(e){var n=e,t=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,n.flags&4098&&(t=n.return),e=n.return;while(e)}return n.tag===3?t:null}function q2(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function IP(e){if(Fi(e)!==e)throw Error(q(188))}function kV(e){var n=e.alternate;if(!n){if(n=Fi(e),n===null)throw Error(q(188));return n!==e?null:e}for(var t=e,r=n;;){var o=t.return;if(o===null)break;var s=o.alternate;if(s===null){if(r=o.return,r!==null){t=r;continue}break}if(o.child===s.child){for(s=o.child;s;){if(s===t)return IP(o),e;if(s===r)return IP(o),n;s=s.sibling}throw Error(q(188))}if(t.return!==r.return)t=o,r=s;else{for(var i=!1,a=o.child;a;){if(a===t){i=!0,t=o,r=s;break}if(a===r){i=!0,r=o,t=s;break}a=a.sibling}if(!i){for(a=s.child;a;){if(a===t){i=!0,t=s,r=o;break}if(a===r){i=!0,r=s,t=o;break}a=a.sibling}if(!i)throw Error(q(189))}}if(t.alternate!==r)throw Error(q(190))}if(t.tag!==3)throw Error(q(188));return t.stateNode.current===t?e:n}function Z2(e){return e=kV(e),e!==null?Q2(e):null}function Q2(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var n=Q2(e);if(n!==null)return n;e=e.sibling}return null}var J2=Jn.unstable_scheduleCallback,EP=Jn.unstable_cancelCallback,TV=Jn.unstable_shouldYield,$V=Jn.unstable_requestPaint,gt=Jn.unstable_now,MV=Jn.unstable_getCurrentPriorityLevel,V0=Jn.unstable_ImmediatePriority,eT=Jn.unstable_UserBlockingPriority,jp=Jn.unstable_NormalPriority,AV=Jn.unstable_LowPriority,tT=Jn.unstable_IdlePriority,$f=null,io=null;function jV(e){if(io&&typeof io.onCommitFiberRoot=="function")try{io.onCommitFiberRoot($f,e,void 0,(e.current.flags&128)===128)}catch{}}var Nr=Math.clz32?Math.clz32:RV,OV=Math.log,DV=Math.LN2;function RV(e){return e>>>=0,e===0?32:31-(OV(e)/DV|0)|0}var kd=64,Td=4194304;function tc(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 Op(e,n){var t=e.pendingLanes;if(t===0)return 0;var r=0,o=e.suspendedLanes,s=e.pingedLanes,i=t&268435455;if(i!==0){var a=i&~o;a!==0?r=tc(a):(s&=i,s!==0&&(r=tc(s)))}else i=t&~o,i!==0?r=tc(i):s!==0&&(r=tc(s));if(r===0)return 0;if(n!==0&&n!==r&&!(n&o)&&(o=r&-r,s=n&-n,o>=s||o===16&&(s&4194240)!==0))return n;if(r&4&&(r|=t&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=r;0<n;)t=31-Nr(n),o=1<<t,r|=e[t],n&=~o;return r}function LV(e,n){switch(e){case 1:case 2:case 4:return n+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 n+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 NV(e,n){for(var t=e.suspendedLanes,r=e.pingedLanes,o=e.expirationTimes,s=e.pendingLanes;0<s;){var i=31-Nr(s),a=1<<i,l=o[i];l===-1?(!(a&t)||a&r)&&(o[i]=LV(a,n)):l<=n&&(e.expiredLanes|=a),s&=~a}}function TS(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function nT(){var e=kd;return kd<<=1,!(kd&4194240)&&(kd=64),e}function Im(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}function ju(e,n,t){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Nr(n),e[n]=t}function FV(e,n){var t=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<t;){var o=31-Nr(t),s=1<<o;n[o]=0,r[o]=-1,e[o]=-1,t&=~s}}function W0(e,n){var t=e.entangledLanes|=n;for(e=e.entanglements;t;){var r=31-Nr(t),o=1<<r;o&n|e[r]&n&&(e[r]|=n),t&=~o}}var Re=0;function rT(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var oT,G0,sT,iT,aT,$S=!1,$d=[],bs=null,Ps=null,Cs=null,Uc=new Map,Hc=new Map,ps=[],zV="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 _P(e,n){switch(e){case"focusin":case"focusout":bs=null;break;case"dragenter":case"dragleave":Ps=null;break;case"mouseover":case"mouseout":Cs=null;break;case"pointerover":case"pointerout":Uc.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Hc.delete(n.pointerId)}}function Nl(e,n,t,r,o,s){return e===null||e.nativeEvent!==s?(e={blockedOn:n,domEventName:t,eventSystemFlags:r,nativeEvent:s,targetContainers:[o]},n!==null&&(n=Du(n),n!==null&&G0(n)),e):(e.eventSystemFlags|=r,n=e.targetContainers,o!==null&&n.indexOf(o)===-1&&n.push(o),e)}function BV(e,n,t,r,o){switch(n){case"focusin":return bs=Nl(bs,e,n,t,r,o),!0;case"dragenter":return Ps=Nl(Ps,e,n,t,r,o),!0;case"mouseover":return Cs=Nl(Cs,e,n,t,r,o),!0;case"pointerover":var s=o.pointerId;return Uc.set(s,Nl(Uc.get(s)||null,e,n,t,r,o)),!0;case"gotpointercapture":return s=o.pointerId,Hc.set(s,Nl(Hc.get(s)||null,e,n,t,r,o)),!0}return!1}function lT(e){var n=ui(e.target);if(n!==null){var t=Fi(n);if(t!==null){if(n=t.tag,n===13){if(n=q2(t),n!==null){e.blockedOn=n,aT(e.priority,function(){sT(t)});return}}else if(n===3&&t.stateNode.current.memoizedState.isDehydrated){e.blockedOn=t.tag===3?t.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Nh(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var t=MS(e.domEventName,e.eventSystemFlags,n[0],e.nativeEvent);if(t===null){t=e.nativeEvent;var r=new t.constructor(t.type,t);IS=r,t.target.dispatchEvent(r),IS=null}else return n=Du(t),n!==null&&G0(n),e.blockedOn=t,!1;n.shift()}return!0}function kP(e,n,t){Nh(e)&&t.delete(n)}function UV(){$S=!1,bs!==null&&Nh(bs)&&(bs=null),Ps!==null&&Nh(Ps)&&(Ps=null),Cs!==null&&Nh(Cs)&&(Cs=null),Uc.forEach(kP),Hc.forEach(kP)}function Fl(e,n){e.blockedOn===n&&(e.blockedOn=null,$S||($S=!0,Jn.unstable_scheduleCallback(Jn.unstable_NormalPriority,UV)))}function Kc(e){function n(o){return Fl(o,e)}if(0<$d.length){Fl($d[0],e);for(var t=1;t<$d.length;t++){var r=$d[t];r.blockedOn===e&&(r.blockedOn=null)}}for(bs!==null&&Fl(bs,e),Ps!==null&&Fl(Ps,e),Cs!==null&&Fl(Cs,e),Uc.forEach(n),Hc.forEach(n),t=0;t<ps.length;t++)r=ps[t],r.blockedOn===e&&(r.blockedOn=null);for(;0<ps.length&&(t=ps[0],t.blockedOn===null);)lT(t),t.blockedOn===null&&ps.shift()}var La=Qo.ReactCurrentBatchConfig,Dp=!0;function HV(e,n,t,r){var o=Re,s=La.transition;La.transition=null;try{Re=1,Y0(e,n,t,r)}finally{Re=o,La.transition=s}}function KV(e,n,t,r){var o=Re,s=La.transition;La.transition=null;try{Re=4,Y0(e,n,t,r)}finally{Re=o,La.transition=s}}function Y0(e,n,t,r){if(Dp){var o=MS(e,n,t,r);if(o===null)Dm(e,n,r,Rp,t),_P(e,r);else if(BV(o,e,n,t,r))r.stopPropagation();else if(_P(e,r),n&4&&-1<zV.indexOf(e)){for(;o!==null;){var s=Du(o);if(s!==null&&oT(s),s=MS(e,n,t,r),s===null&&Dm(e,n,r,Rp,t),s===o)break;o=s}o!==null&&r.stopPropagation()}else Dm(e,n,r,null,t)}}var Rp=null;function MS(e,n,t,r){if(Rp=null,e=K0(r),e=ui(e),e!==null)if(n=Fi(e),n===null)e=null;else if(t=n.tag,t===13){if(e=q2(n),e!==null)return e;e=null}else if(t===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null);return Rp=e,null}function cT(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(MV()){case V0:return 1;case eT:return 4;case jp:case AV:return 16;case tT:return 536870912;default:return 16}default:return 16}}var Ss=null,X0=null,Fh=null;function uT(){if(Fh)return Fh;var e,n=X0,t=n.length,r,o="value"in Ss?Ss.value:Ss.textContent,s=o.length;for(e=0;e<t&&n[e]===o[e];e++);var i=t-e;for(r=1;r<=i&&n[t-r]===o[s-r];r++);return Fh=o.slice(e,1<r?1-r:void 0)}function zh(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function Md(){return!0}function TP(){return!1}function nr(e){function n(t,r,o,s,i){this._reactName=t,this._targetInst=o,this.type=r,this.nativeEvent=s,this.target=i,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(t=e[a],this[a]=t?t(s):s[a]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?Md:TP,this.isPropagationStopped=TP,this}return ct(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var t=this.nativeEvent;t&&(t.preventDefault?t.preventDefault():typeof t.returnValue!="unknown"&&(t.returnValue=!1),this.isDefaultPrevented=Md)},stopPropagation:function(){var t=this.nativeEvent;t&&(t.stopPropagation?t.stopPropagation():typeof t.cancelBubble!="unknown"&&(t.cancelBubble=!0),this.isPropagationStopped=Md)},persist:function(){},isPersistent:Md}),n}var pl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},q0=nr(pl),Ou=ct({},pl,{view:0,detail:0}),VV=nr(Ou),Em,_m,zl,Mf=ct({},Ou,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Z0,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!==zl&&(zl&&e.type==="mousemove"?(Em=e.screenX-zl.screenX,_m=e.screenY-zl.screenY):_m=Em=0,zl=e),Em)},movementY:function(e){return"movementY"in e?e.movementY:_m}}),$P=nr(Mf),WV=ct({},Mf,{dataTransfer:0}),GV=nr(WV),YV=ct({},Ou,{relatedTarget:0}),km=nr(YV),XV=ct({},pl,{animationName:0,elapsedTime:0,pseudoElement:0}),qV=nr(XV),ZV=ct({},pl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),QV=nr(ZV),JV=ct({},pl,{data:0}),MP=nr(JV),eW={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},tW={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"},nW={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function rW(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=nW[e])?!!n[e]:!1}function Z0(){return rW}var oW=ct({},Ou,{key:function(e){if(e.key){var n=eW[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=zh(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?tW[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Z0,charCode:function(e){return e.type==="keypress"?zh(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?zh(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),sW=nr(oW),iW=ct({},Mf,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),AP=nr(iW),aW=ct({},Ou,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Z0}),lW=nr(aW),cW=ct({},pl,{propertyName:0,elapsedTime:0,pseudoElement:0}),uW=nr(cW),dW=ct({},Mf,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),hW=nr(dW),pW=[9,13,27,32],Q0=Bo&&"CompositionEvent"in window,pc=null;Bo&&"documentMode"in document&&(pc=document.documentMode);var fW=Bo&&"TextEvent"in window&&!pc,dT=Bo&&(!Q0||pc&&8<pc&&11>=pc),jP=" ",OP=!1;function hT(e,n){switch(e){case"keyup":return pW.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function pT(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var va=!1;function gW(e,n){switch(e){case"compositionend":return pT(n);case"keypress":return n.which!==32?null:(OP=!0,jP);case"textInput":return e=n.data,e===jP&&OP?null:e;default:return null}}function mW(e,n){if(va)return e==="compositionend"||!Q0&&hT(e,n)?(e=uT(),Fh=X0=Ss=null,va=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return dT&&n.locale!=="ko"?null:n.data;default:return null}}var yW={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 DP(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!yW[e.type]:n==="textarea"}function fT(e,n,t,r){V2(r),n=Lp(n,"onChange"),0<n.length&&(t=new q0("onChange","change",null,t,r),e.push({event:t,listeners:n}))}var fc=null,Vc=null;function SW(e){IT(e,0)}function Af(e){var n=ba(e);if(N2(n))return e}function vW(e,n){if(e==="change")return n}var gT=!1;if(Bo){var Tm;if(Bo){var $m="oninput"in document;if(!$m){var RP=document.createElement("div");RP.setAttribute("oninput","return;"),$m=typeof RP.oninput=="function"}Tm=$m}else Tm=!1;gT=Tm&&(!document.documentMode||9<document.documentMode)}function LP(){fc&&(fc.detachEvent("onpropertychange",mT),Vc=fc=null)}function mT(e){if(e.propertyName==="value"&&Af(Vc)){var n=[];fT(n,Vc,e,K0(e)),X2(SW,n)}}function wW(e,n,t){e==="focusin"?(LP(),fc=n,Vc=t,fc.attachEvent("onpropertychange",mT)):e==="focusout"&&LP()}function xW(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Af(Vc)}function bW(e,n){if(e==="click")return Af(n)}function PW(e,n){if(e==="input"||e==="change")return Af(n)}function CW(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var Hr=typeof Object.is=="function"?Object.is:CW;function Wc(e,n){if(Hr(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;for(r=0;r<t.length;r++){var o=t[r];if(!pS.call(n,o)||!Hr(e[o],n[o]))return!1}return!0}function NP(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function FP(e,n){var t=NP(e);e=0;for(var r;t;){if(t.nodeType===3){if(r=e+t.textContent.length,e<=n&&r>=n)return{node:t,offset:n-e};e=r}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=NP(t)}}function yT(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?yT(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ST(){for(var e=window,n=$p();n instanceof e.HTMLIFrameElement;){try{var t=typeof n.contentWindow.location.href=="string"}catch{t=!1}if(t)e=n.contentWindow;else break;n=$p(e.document)}return n}function J0(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function IW(e){var n=ST(),t=e.focusedElem,r=e.selectionRange;if(n!==t&&t&&t.ownerDocument&&yT(t.ownerDocument.documentElement,t)){if(r!==null&&J0(t)){if(n=r.start,e=r.end,e===void 0&&(e=n),"selectionStart"in t)t.selectionStart=n,t.selectionEnd=Math.min(e,t.value.length);else if(e=(n=t.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var o=t.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=FP(t,s);var i=FP(t,r);o&&i&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(n=n.createRange(),n.setStart(o.node,o.offset),e.removeAllRanges(),s>r?(e.addRange(n),e.extend(i.node,i.offset)):(n.setEnd(i.node,i.offset),e.addRange(n)))}}for(n=[],e=t;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t<n.length;t++)e=n[t],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var EW=Bo&&"documentMode"in document&&11>=document.documentMode,wa=null,AS=null,gc=null,jS=!1;function zP(e,n,t){var r=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;jS||wa==null||wa!==$p(r)||(r=wa,"selectionStart"in r&&J0(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}),gc&&Wc(gc,r)||(gc=r,r=Lp(AS,"onSelect"),0<r.length&&(n=new q0("onSelect","select",null,n,t),e.push({event:n,listeners:r}),n.target=wa)))}function Ad(e,n){var t={};return t[e.toLowerCase()]=n.toLowerCase(),t["Webkit"+e]="webkit"+n,t["Moz"+e]="moz"+n,t}var xa={animationend:Ad("Animation","AnimationEnd"),animationiteration:Ad("Animation","AnimationIteration"),animationstart:Ad("Animation","AnimationStart"),transitionend:Ad("Transition","TransitionEnd")},Mm={},vT={};Bo&&(vT=document.createElement("div").style,"AnimationEvent"in window||(delete xa.animationend.animation,delete xa.animationiteration.animation,delete xa.animationstart.animation),"TransitionEvent"in window||delete xa.transitionend.transition);function jf(e){if(Mm[e])return Mm[e];if(!xa[e])return e;var n=xa[e],t;for(t in n)if(n.hasOwnProperty(t)&&t in vT)return Mm[e]=n[t];return e}var wT=jf("animationend"),xT=jf("animationiteration"),bT=jf("animationstart"),PT=jf("transitionend"),CT=new Map,BP="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 Hs(e,n){CT.set(e,n),Ni(n,[e])}for(var Am=0;Am<BP.length;Am++){var jm=BP[Am],_W=jm.toLowerCase(),kW=jm[0].toUpperCase()+jm.slice(1);Hs(_W,"on"+kW)}Hs(wT,"onAnimationEnd");Hs(xT,"onAnimationIteration");Hs(bT,"onAnimationStart");Hs("dblclick","onDoubleClick");Hs("focusin","onFocus");Hs("focusout","onBlur");Hs(PT,"onTransitionEnd");Wa("onMouseEnter",["mouseout","mouseover"]);Wa("onMouseLeave",["mouseout","mouseover"]);Wa("onPointerEnter",["pointerout","pointerover"]);Wa("onPointerLeave",["pointerout","pointerover"]);Ni("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ni("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ni("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ni("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ni("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ni("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var nc="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(" "),TW=new Set("cancel close invalid load scroll toggle".split(" ").concat(nc));function UP(e,n,t){var r=e.type||"unknown-event";e.currentTarget=t,_V(r,n,void 0,e),e.currentTarget=null}function IT(e,n){n=(n&4)!==0;for(var t=0;t<e.length;t++){var r=e[t],o=r.event;r=r.listeners;e:{var s=void 0;if(n)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;UP(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;UP(o,a,c),s=l}}}if(Ap)throw e=kS,Ap=!1,kS=null,e}function Qe(e,n){var t=n[NS];t===void 0&&(t=n[NS]=new Set);var r=e+"__bubble";t.has(r)||(ET(n,e,2,!1),t.add(r))}function Om(e,n,t){var r=0;n&&(r|=4),ET(t,e,r,n)}var jd="_reactListening"+Math.random().toString(36).slice(2);function Gc(e){if(!e[jd]){e[jd]=!0,j2.forEach(function(t){t!=="selectionchange"&&(TW.has(t)||Om(t,!1,e),Om(t,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[jd]||(n[jd]=!0,Om("selectionchange",!1,n))}}function ET(e,n,t,r){switch(cT(n)){case 1:var o=HV;break;case 4:o=KV;break;default:o=Y0}t=o.bind(null,n,t,e),o=void 0,!_S||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(o=!0),r?o!==void 0?e.addEventListener(n,t,{capture:!0,passive:o}):e.addEventListener(n,t,!0):o!==void 0?e.addEventListener(n,t,{passive:o}):e.addEventListener(n,t,!1)}function Dm(e,n,t,r,o){var s=r;if(!(n&1)&&!(n&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=ui(a),i===null)return;if(l=i.tag,l===5||l===6){r=s=i;continue e}a=a.parentNode}}r=r.return}X2(function(){var c=s,u=K0(t),d=[];e:{var h=CT.get(e);if(h!==void 0){var f=q0,y=e;switch(e){case"keypress":if(zh(t)===0)break e;case"keydown":case"keyup":f=sW;break;case"focusin":y="focus",f=km;break;case"focusout":y="blur",f=km;break;case"beforeblur":case"afterblur":f=km;break;case"click":if(t.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":f=$P;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":f=GV;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":f=lW;break;case wT:case xT:case bT:f=qV;break;case PT:f=uW;break;case"scroll":f=VV;break;case"wheel":f=hW;break;case"copy":case"cut":case"paste":f=QV;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":f=AP}var g=(n&4)!==0,v=!g&&e==="scroll",S=g?h!==null?h+"Capture":null:h;g=[];for(var w=c,C;w!==null;){C=w;var I=C.stateNode;if(C.tag===5&&I!==null&&(C=I,S!==null&&(I=Bc(w,S),I!=null&&g.push(Yc(w,I,C)))),v)break;w=w.return}0<g.length&&(h=new f(h,y,null,t,u),d.push({event:h,listeners:g}))}}if(!(n&7)){e:{if(h=e==="mouseover"||e==="pointerover",f=e==="mouseout"||e==="pointerout",h&&t!==IS&&(y=t.relatedTarget||t.fromElement)&&(ui(y)||y[Uo]))break e;if((f||h)&&(h=u.window===u?u:(h=u.ownerDocument)?h.defaultView||h.parentWindow:window,f?(y=t.relatedTarget||t.toElement,f=c,y=y?ui(y):null,y!==null&&(v=Fi(y),y!==v||y.tag!==5&&y.tag!==6)&&(y=null)):(f=null,y=c),f!==y)){if(g=$P,I="onMouseLeave",S="onMouseEnter",w="mouse",(e==="pointerout"||e==="pointerover")&&(g=AP,I="onPointerLeave",S="onPointerEnter",w="pointer"),v=f==null?h:ba(f),C=y==null?h:ba(y),h=new g(I,w+"leave",f,t,u),h.target=v,h.relatedTarget=C,I=null,ui(u)===c&&(g=new g(S,w+"enter",y,t,u),g.target=C,g.relatedTarget=v,I=g),v=I,f&&y)t:{for(g=f,S=y,w=0,C=g;C;C=oa(C))w++;for(C=0,I=S;I;I=oa(I))C++;for(;0<w-C;)g=oa(g),w--;for(;0<C-w;)S=oa(S),C--;for(;w--;){if(g===S||S!==null&&g===S.alternate)break t;g=oa(g),S=oa(S)}g=null}else g=null;f!==null&&HP(d,h,f,g,!1),y!==null&&v!==null&&HP(d,v,y,g,!0)}}e:{if(h=c?ba(c):window,f=h.nodeName&&h.nodeName.toLowerCase(),f==="select"||f==="input"&&h.type==="file")var P=vW;else if(DP(h))if(gT)P=PW;else{P=xW;var E=wW}else(f=h.nodeName)&&f.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(P=bW);if(P&&(P=P(e,c))){fT(d,P,t,u);break e}E&&E(e,h,c),e==="focusout"&&(E=h._wrapperState)&&E.controlled&&h.type==="number"&&wS(h,"number",h.value)}switch(E=c?ba(c):window,e){case"focusin":(DP(E)||E.contentEditable==="true")&&(wa=E,AS=c,gc=null);break;case"focusout":gc=AS=wa=null;break;case"mousedown":jS=!0;break;case"contextmenu":case"mouseup":case"dragend":jS=!1,zP(d,t,u);break;case"selectionchange":if(EW)break;case"keydown":case"keyup":zP(d,t,u)}var _;if(Q0)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 va?hT(e,t)&&(k="onCompositionEnd"):e==="keydown"&&t.keyCode===229&&(k="onCompositionStart");k&&(dT&&t.locale!=="ko"&&(va||k!=="onCompositionStart"?k==="onCompositionEnd"&&va&&(_=uT()):(Ss=u,X0="value"in Ss?Ss.value:Ss.textContent,va=!0)),E=Lp(c,k),0<E.length&&(k=new MP(k,e,null,t,u),d.push({event:k,listeners:E}),_?k.data=_:(_=pT(t),_!==null&&(k.data=_)))),(_=fW?gW(e,t):mW(e,t))&&(c=Lp(c,"onBeforeInput"),0<c.length&&(u=new MP("onBeforeInput","beforeinput",null,t,u),d.push({event:u,listeners:c}),u.data=_))}IT(d,n)})}function Yc(e,n,t){return{instance:e,listener:n,currentTarget:t}}function Lp(e,n){for(var t=n+"Capture",r=[];e!==null;){var o=e,s=o.stateNode;o.tag===5&&s!==null&&(o=s,s=Bc(e,t),s!=null&&r.unshift(Yc(e,s,o)),s=Bc(e,n),s!=null&&r.push(Yc(e,s,o))),e=e.return}return r}function oa(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function HP(e,n,t,r,o){for(var s=n._reactName,i=[];t!==null&&t!==r;){var a=t,l=a.alternate,c=a.stateNode;if(l!==null&&l===r)break;a.tag===5&&c!==null&&(a=c,o?(l=Bc(t,s),l!=null&&i.unshift(Yc(t,l,a))):o||(l=Bc(t,s),l!=null&&i.push(Yc(t,l,a)))),t=t.return}i.length!==0&&e.push({event:n,listeners:i})}var $W=/\r\n?/g,MW=/\u0000|\uFFFD/g;function KP(e){return(typeof e=="string"?e:""+e).replace($W,`
|
|
195
|
+
`).replace(MW,"")}function Od(e,n,t){if(n=KP(n),KP(e)!==n&&t)throw Error(q(425))}function Np(){}var OS=null,DS=null;function RS(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var LS=typeof setTimeout=="function"?setTimeout:void 0,AW=typeof clearTimeout=="function"?clearTimeout:void 0,VP=typeof Promise=="function"?Promise:void 0,jW=typeof queueMicrotask=="function"?queueMicrotask:typeof VP<"u"?function(e){return VP.resolve(null).then(e).catch(OW)}:LS;function OW(e){setTimeout(function(){throw e})}function Rm(e,n){var t=n,r=0;do{var o=t.nextSibling;if(e.removeChild(t),o&&o.nodeType===8)if(t=o.data,t==="/$"){if(r===0){e.removeChild(o),Kc(n);return}r--}else t!=="$"&&t!=="$?"&&t!=="$!"||r++;t=o}while(t);Kc(n)}function Is(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?")break;if(n==="/$")return null}}return e}function WP(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var t=e.data;if(t==="$"||t==="$!"||t==="$?"){if(n===0)return e;n--}else t==="/$"&&n++}e=e.previousSibling}return null}var fl=Math.random().toString(36).slice(2),Jr="__reactFiber$"+fl,Xc="__reactProps$"+fl,Uo="__reactContainer$"+fl,NS="__reactEvents$"+fl,DW="__reactListeners$"+fl,RW="__reactHandles$"+fl;function ui(e){var n=e[Jr];if(n)return n;for(var t=e.parentNode;t;){if(n=t[Uo]||t[Jr]){if(t=n.alternate,n.child!==null||t!==null&&t.child!==null)for(e=WP(e);e!==null;){if(t=e[Jr])return t;e=WP(e)}return n}e=t,t=e.parentNode}return null}function Du(e){return e=e[Jr]||e[Uo],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ba(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(q(33))}function Of(e){return e[Xc]||null}var FS=[],Pa=-1;function Ks(e){return{current:e}}function tt(e){0>Pa||(e.current=FS[Pa],FS[Pa]=null,Pa--)}function Ve(e,n){Pa++,FS[Pa]=e.current,e.current=n}var Ds={},rn=Ks(Ds),$n=Ks(!1),xi=Ds;function Ga(e,n){var t=e.type.contextTypes;if(!t)return Ds;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===n)return r.__reactInternalMemoizedMaskedChildContext;var o={},s;for(s in t)o[s]=n[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=o),o}function Mn(e){return e=e.childContextTypes,e!=null}function Fp(){tt($n),tt(rn)}function GP(e,n,t){if(rn.current!==Ds)throw Error(q(168));Ve(rn,n),Ve($n,t)}function _T(e,n,t){var r=e.stateNode;if(n=n.childContextTypes,typeof r.getChildContext!="function")return t;r=r.getChildContext();for(var o in r)if(!(o in n))throw Error(q(108,wV(e)||"Unknown",o));return ct({},t,r)}function zp(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ds,xi=rn.current,Ve(rn,e),Ve($n,$n.current),!0}function YP(e,n,t){var r=e.stateNode;if(!r)throw Error(q(169));t?(e=_T(e,n,xi),r.__reactInternalMemoizedMergedChildContext=e,tt($n),tt(rn),Ve(rn,e)):tt($n),Ve($n,t)}var $o=null,Df=!1,Lm=!1;function kT(e){$o===null?$o=[e]:$o.push(e)}function LW(e){Df=!0,kT(e)}function Vs(){if(!Lm&&$o!==null){Lm=!0;var e=0,n=Re;try{var t=$o;for(Re=1;e<t.length;e++){var r=t[e];do r=r(!0);while(r!==null)}$o=null,Df=!1}catch(o){throw $o!==null&&($o=$o.slice(e+1)),J2(V0,Vs),o}finally{Re=n,Lm=!1}}return null}var Ca=[],Ia=0,Bp=null,Up=0,cr=[],ur=0,bi=null,jo=1,Oo="";function oi(e,n){Ca[Ia++]=Up,Ca[Ia++]=Bp,Bp=e,Up=n}function TT(e,n,t){cr[ur++]=jo,cr[ur++]=Oo,cr[ur++]=bi,bi=e;var r=jo;e=Oo;var o=32-Nr(r)-1;r&=~(1<<o),t+=1;var s=32-Nr(n)+o;if(30<s){var i=o-o%5;s=(r&(1<<i)-1).toString(32),r>>=i,o-=i,jo=1<<32-Nr(n)+o|t<<o|r,Oo=s+e}else jo=1<<s|t<<o|r,Oo=e}function ew(e){e.return!==null&&(oi(e,1),TT(e,1,0))}function tw(e){for(;e===Bp;)Bp=Ca[--Ia],Ca[Ia]=null,Up=Ca[--Ia],Ca[Ia]=null;for(;e===bi;)bi=cr[--ur],cr[ur]=null,Oo=cr[--ur],cr[ur]=null,jo=cr[--ur],cr[ur]=null}var qn=null,Yn=null,nt=!1,Mr=null;function $T(e,n){var t=dr(5,null,null,0);t.elementType="DELETED",t.stateNode=n,t.return=e,n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)}function XP(e,n){switch(e.tag){case 5:var t=e.type;return n=n.nodeType!==1||t.toLowerCase()!==n.nodeName.toLowerCase()?null:n,n!==null?(e.stateNode=n,qn=e,Yn=Is(n.firstChild),!0):!1;case 6:return n=e.pendingProps===""||n.nodeType!==3?null:n,n!==null?(e.stateNode=n,qn=e,Yn=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(t=bi!==null?{id:jo,overflow:Oo}:null,e.memoizedState={dehydrated:n,treeContext:t,retryLane:1073741824},t=dr(18,null,null,0),t.stateNode=n,t.return=e,e.child=t,qn=e,Yn=null,!0):!1;default:return!1}}function zS(e){return(e.mode&1)!==0&&(e.flags&128)===0}function BS(e){if(nt){var n=Yn;if(n){var t=n;if(!XP(e,n)){if(zS(e))throw Error(q(418));n=Is(t.nextSibling);var r=qn;n&&XP(e,n)?$T(r,t):(e.flags=e.flags&-4097|2,nt=!1,qn=e)}}else{if(zS(e))throw Error(q(418));e.flags=e.flags&-4097|2,nt=!1,qn=e}}}function qP(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;qn=e}function Dd(e){if(e!==qn)return!1;if(!nt)return qP(e),nt=!0,!1;var n;if((n=e.tag!==3)&&!(n=e.tag!==5)&&(n=e.type,n=n!=="head"&&n!=="body"&&!RS(e.type,e.memoizedProps)),n&&(n=Yn)){if(zS(e))throw MT(),Error(q(418));for(;n;)$T(e,n),n=Is(n.nextSibling)}if(qP(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(q(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8){var t=e.data;if(t==="/$"){if(n===0){Yn=Is(e.nextSibling);break e}n--}else t!=="$"&&t!=="$!"&&t!=="$?"||n++}e=e.nextSibling}Yn=null}}else Yn=qn?Is(e.stateNode.nextSibling):null;return!0}function MT(){for(var e=Yn;e;)e=Is(e.nextSibling)}function Ya(){Yn=qn=null,nt=!1}function nw(e){Mr===null?Mr=[e]:Mr.push(e)}var NW=Qo.ReactCurrentBatchConfig;function Ir(e,n){if(e&&e.defaultProps){n=ct({},n),e=e.defaultProps;for(var t in e)n[t]===void 0&&(n[t]=e[t]);return n}return n}var Hp=Ks(null),Kp=null,Ea=null,rw=null;function ow(){rw=Ea=Kp=null}function sw(e){var n=Hp.current;tt(Hp),e._currentValue=n}function US(e,n,t){for(;e!==null;){var r=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,r!==null&&(r.childLanes|=n)):r!==null&&(r.childLanes&n)!==n&&(r.childLanes|=n),e===t)break;e=e.return}}function Na(e,n){Kp=e,rw=Ea=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&n&&(_n=!0),e.firstContext=null)}function yr(e){var n=e._currentValue;if(rw!==e)if(e={context:e,memoizedValue:n,next:null},Ea===null){if(Kp===null)throw Error(q(308));Ea=e,Kp.dependencies={lanes:0,firstContext:e}}else Ea=Ea.next=e;return n}var di=null;function iw(e){di===null?di=[e]:di.push(e)}function AT(e,n,t,r){var o=n.interleaved;return o===null?(t.next=t,iw(n)):(t.next=o.next,o.next=t),n.interleaved=t,Ho(e,r)}function Ho(e,n){e.lanes|=n;var t=e.alternate;for(t!==null&&(t.lanes|=n),t=e,e=e.return;e!==null;)e.childLanes|=n,t=e.alternate,t!==null&&(t.childLanes|=n),t=e,e=e.return;return t.tag===3?t.stateNode:null}var cs=!1;function aw(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function jT(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function No(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Es(e,n,t){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ce&2){var o=r.pending;return o===null?n.next=n:(n.next=o.next,o.next=n),r.pending=n,Ho(e,t)}return o=r.interleaved,o===null?(n.next=n,iw(r)):(n.next=o.next,o.next=n),r.interleaved=n,Ho(e,t)}function Bh(e,n,t){if(n=n.updateQueue,n!==null&&(n=n.shared,(t&4194240)!==0)){var r=n.lanes;r&=e.pendingLanes,t|=r,n.lanes=t,W0(e,t)}}function ZP(e,n){var t=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,t===r)){var o=null,s=null;if(t=t.firstBaseUpdate,t!==null){do{var i={eventTime:t.eventTime,lane:t.lane,tag:t.tag,payload:t.payload,callback:t.callback,next:null};s===null?o=s=i:s=s.next=i,t=t.next}while(t!==null);s===null?o=s=n:s=s.next=n}else o=s=n;t={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=t;return}e=t.lastBaseUpdate,e===null?t.firstBaseUpdate=n:e.next=n,t.lastBaseUpdate=n}function Vp(e,n,t,r){var o=e.updateQueue;cs=!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 d=o.baseState;i=0,u=c=l=null,a=s;do{var h=a.lane,f=a.eventTime;if((r&h)===h){u!==null&&(u=u.next={eventTime:f,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var y=e,g=a;switch(h=n,f=t,g.tag){case 1:if(y=g.payload,typeof y=="function"){d=y.call(f,d,h);break e}d=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=g.payload,h=typeof y=="function"?y.call(f,d,h):y,h==null)break e;d=ct({},d,h);break e;case 2:cs=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=o.effects,h===null?o.effects=[a]:h.push(a))}else f={eventTime:f,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=f,l=d):u=u.next=f,i|=h;if(a=a.next,a===null){if(a=o.shared.pending,a===null)break;h=a,a=h.next,h.next=null,o.lastBaseUpdate=h,o.shared.pending=null}}while(!0);if(u===null&&(l=d),o.baseState=l,o.firstBaseUpdate=c,o.lastBaseUpdate=u,n=o.shared.interleaved,n!==null){o=n;do i|=o.lane,o=o.next;while(o!==n)}else s===null&&(o.shared.lanes=0);Ci|=i,e.lanes=i,e.memoizedState=d}}function QP(e,n,t){if(e=n.effects,n.effects=null,e!==null)for(n=0;n<e.length;n++){var r=e[n],o=r.callback;if(o!==null){if(r.callback=null,r=t,typeof o!="function")throw Error(q(191,o));o.call(r)}}}var OT=new A2.Component().refs;function HS(e,n,t,r){n=e.memoizedState,t=t(r,n),t=t==null?n:ct({},n,t),e.memoizedState=t,e.lanes===0&&(e.updateQueue.baseState=t)}var Rf={isMounted:function(e){return(e=e._reactInternals)?Fi(e)===e:!1},enqueueSetState:function(e,n,t){e=e._reactInternals;var r=pn(),o=ks(e),s=No(r,o);s.payload=n,t!=null&&(s.callback=t),n=Es(e,s,o),n!==null&&(Fr(n,e,o,r),Bh(n,e,o))},enqueueReplaceState:function(e,n,t){e=e._reactInternals;var r=pn(),o=ks(e),s=No(r,o);s.tag=1,s.payload=n,t!=null&&(s.callback=t),n=Es(e,s,o),n!==null&&(Fr(n,e,o,r),Bh(n,e,o))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var t=pn(),r=ks(e),o=No(t,r);o.tag=2,n!=null&&(o.callback=n),n=Es(e,o,r),n!==null&&(Fr(n,e,r,t),Bh(n,e,r))}};function JP(e,n,t,r,o,s,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,s,i):n.prototype&&n.prototype.isPureReactComponent?!Wc(t,r)||!Wc(o,s):!0}function DT(e,n,t){var r=!1,o=Ds,s=n.contextType;return typeof s=="object"&&s!==null?s=yr(s):(o=Mn(n)?xi:rn.current,r=n.contextTypes,s=(r=r!=null)?Ga(e,o):Ds),n=new n(t,s),e.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=Rf,e.stateNode=n,n._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=o,e.__reactInternalMemoizedMaskedChildContext=s),n}function eC(e,n,t,r){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(t,r),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(t,r),n.state!==e&&Rf.enqueueReplaceState(n,n.state,null)}function KS(e,n,t,r){var o=e.stateNode;o.props=t,o.state=e.memoizedState,o.refs=OT,aw(e);var s=n.contextType;typeof s=="object"&&s!==null?o.context=yr(s):(s=Mn(n)?xi:rn.current,o.context=Ga(e,s)),o.state=e.memoizedState,s=n.getDerivedStateFromProps,typeof s=="function"&&(HS(e,n,s,t),o.state=e.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(n=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),n!==o.state&&Rf.enqueueReplaceState(o,o.state,null),Vp(e,t,o,r),o.state=e.memoizedState),typeof o.componentDidMount=="function"&&(e.flags|=4194308)}function Bl(e,n,t){if(e=t.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(t._owner){if(t=t._owner,t){if(t.tag!==1)throw Error(q(309));var r=t.stateNode}if(!r)throw Error(q(147,e));var o=r,s=""+e;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===s?n.ref:(n=function(i){var a=o.refs;a===OT&&(a=o.refs={}),i===null?delete a[s]:a[s]=i},n._stringRef=s,n)}if(typeof e!="string")throw Error(q(284));if(!t._owner)throw Error(q(290,e))}return e}function Rd(e,n){throw e=Object.prototype.toString.call(n),Error(q(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e))}function tC(e){var n=e._init;return n(e._payload)}function RT(e){function n(S,w){if(e){var C=S.deletions;C===null?(S.deletions=[w],S.flags|=16):C.push(w)}}function t(S,w){if(!e)return null;for(;w!==null;)n(S,w),w=w.sibling;return null}function r(S,w){for(S=new Map;w!==null;)w.key!==null?S.set(w.key,w):S.set(w.index,w),w=w.sibling;return S}function o(S,w){return S=Ts(S,w),S.index=0,S.sibling=null,S}function s(S,w,C){return S.index=C,e?(C=S.alternate,C!==null?(C=C.index,C<w?(S.flags|=2,w):C):(S.flags|=2,w)):(S.flags|=1048576,w)}function i(S){return e&&S.alternate===null&&(S.flags|=2),S}function a(S,w,C,I){return w===null||w.tag!==6?(w=Km(C,S.mode,I),w.return=S,w):(w=o(w,C),w.return=S,w)}function l(S,w,C,I){var P=C.type;return P===Sa?u(S,w,C.props.children,I,C.key):w!==null&&(w.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===ls&&tC(P)===w.type)?(I=o(w,C.props),I.ref=Bl(S,w,C),I.return=S,I):(I=Gh(C.type,C.key,C.props,null,S.mode,I),I.ref=Bl(S,w,C),I.return=S,I)}function c(S,w,C,I){return w===null||w.tag!==4||w.stateNode.containerInfo!==C.containerInfo||w.stateNode.implementation!==C.implementation?(w=Vm(C,S.mode,I),w.return=S,w):(w=o(w,C.children||[]),w.return=S,w)}function u(S,w,C,I,P){return w===null||w.tag!==7?(w=mi(C,S.mode,I,P),w.return=S,w):(w=o(w,C),w.return=S,w)}function d(S,w,C){if(typeof w=="string"&&w!==""||typeof w=="number")return w=Km(""+w,S.mode,C),w.return=S,w;if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Id:return C=Gh(w.type,w.key,w.props,null,S.mode,C),C.ref=Bl(S,null,w),C.return=S,C;case ya:return w=Vm(w,S.mode,C),w.return=S,w;case ls:var I=w._init;return d(S,I(w._payload),C)}if(ec(w)||Rl(w))return w=mi(w,S.mode,C,null),w.return=S,w;Rd(S,w)}return null}function h(S,w,C,I){var P=w!==null?w.key:null;if(typeof C=="string"&&C!==""||typeof C=="number")return P!==null?null:a(S,w,""+C,I);if(typeof C=="object"&&C!==null){switch(C.$$typeof){case Id:return C.key===P?l(S,w,C,I):null;case ya:return C.key===P?c(S,w,C,I):null;case ls:return P=C._init,h(S,w,P(C._payload),I)}if(ec(C)||Rl(C))return P!==null?null:u(S,w,C,I,null);Rd(S,C)}return null}function f(S,w,C,I,P){if(typeof I=="string"&&I!==""||typeof I=="number")return S=S.get(C)||null,a(w,S,""+I,P);if(typeof I=="object"&&I!==null){switch(I.$$typeof){case Id:return S=S.get(I.key===null?C:I.key)||null,l(w,S,I,P);case ya:return S=S.get(I.key===null?C:I.key)||null,c(w,S,I,P);case ls:var E=I._init;return f(S,w,C,E(I._payload),P)}if(ec(I)||Rl(I))return S=S.get(C)||null,u(w,S,I,P,null);Rd(w,I)}return null}function y(S,w,C,I){for(var P=null,E=null,_=w,k=w=0,M=null;_!==null&&k<C.length;k++){_.index>k?(M=_,_=null):M=_.sibling;var T=h(S,_,C[k],I);if(T===null){_===null&&(_=M);break}e&&_&&T.alternate===null&&n(S,_),w=s(T,w,k),E===null?P=T:E.sibling=T,E=T,_=M}if(k===C.length)return t(S,_),nt&&oi(S,k),P;if(_===null){for(;k<C.length;k++)_=d(S,C[k],I),_!==null&&(w=s(_,w,k),E===null?P=_:E.sibling=_,E=_);return nt&&oi(S,k),P}for(_=r(S,_);k<C.length;k++)M=f(_,S,k,C[k],I),M!==null&&(e&&M.alternate!==null&&_.delete(M.key===null?k:M.key),w=s(M,w,k),E===null?P=M:E.sibling=M,E=M);return e&&_.forEach(function(R){return n(S,R)}),nt&&oi(S,k),P}function g(S,w,C,I){var P=Rl(C);if(typeof P!="function")throw Error(q(150));if(C=P.call(C),C==null)throw Error(q(151));for(var E=P=null,_=w,k=w=0,M=null,T=C.next();_!==null&&!T.done;k++,T=C.next()){_.index>k?(M=_,_=null):M=_.sibling;var R=h(S,_,T.value,I);if(R===null){_===null&&(_=M);break}e&&_&&R.alternate===null&&n(S,_),w=s(R,w,k),E===null?P=R:E.sibling=R,E=R,_=M}if(T.done)return t(S,_),nt&&oi(S,k),P;if(_===null){for(;!T.done;k++,T=C.next())T=d(S,T.value,I),T!==null&&(w=s(T,w,k),E===null?P=T:E.sibling=T,E=T);return nt&&oi(S,k),P}for(_=r(S,_);!T.done;k++,T=C.next())T=f(_,S,k,T.value,I),T!==null&&(e&&T.alternate!==null&&_.delete(T.key===null?k:T.key),w=s(T,w,k),E===null?P=T:E.sibling=T,E=T);return e&&_.forEach(function(O){return n(S,O)}),nt&&oi(S,k),P}function v(S,w,C,I){if(typeof C=="object"&&C!==null&&C.type===Sa&&C.key===null&&(C=C.props.children),typeof C=="object"&&C!==null){switch(C.$$typeof){case Id:e:{for(var P=C.key,E=w;E!==null;){if(E.key===P){if(P=C.type,P===Sa){if(E.tag===7){t(S,E.sibling),w=o(E,C.props.children),w.return=S,S=w;break e}}else if(E.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===ls&&tC(P)===E.type){t(S,E.sibling),w=o(E,C.props),w.ref=Bl(S,E,C),w.return=S,S=w;break e}t(S,E);break}else n(S,E);E=E.sibling}C.type===Sa?(w=mi(C.props.children,S.mode,I,C.key),w.return=S,S=w):(I=Gh(C.type,C.key,C.props,null,S.mode,I),I.ref=Bl(S,w,C),I.return=S,S=I)}return i(S);case ya:e:{for(E=C.key;w!==null;){if(w.key===E)if(w.tag===4&&w.stateNode.containerInfo===C.containerInfo&&w.stateNode.implementation===C.implementation){t(S,w.sibling),w=o(w,C.children||[]),w.return=S,S=w;break e}else{t(S,w);break}else n(S,w);w=w.sibling}w=Vm(C,S.mode,I),w.return=S,S=w}return i(S);case ls:return E=C._init,v(S,w,E(C._payload),I)}if(ec(C))return y(S,w,C,I);if(Rl(C))return g(S,w,C,I);Rd(S,C)}return typeof C=="string"&&C!==""||typeof C=="number"?(C=""+C,w!==null&&w.tag===6?(t(S,w.sibling),w=o(w,C),w.return=S,S=w):(t(S,w),w=Km(C,S.mode,I),w.return=S,S=w),i(S)):t(S,w)}return v}var Xa=RT(!0),LT=RT(!1),Ru={},ao=Ks(Ru),qc=Ks(Ru),Zc=Ks(Ru);function hi(e){if(e===Ru)throw Error(q(174));return e}function lw(e,n){switch(Ve(Zc,n),Ve(qc,e),Ve(ao,Ru),e=n.nodeType,e){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:bS(null,"");break;default:e=e===8?n.parentNode:n,n=e.namespaceURI||null,e=e.tagName,n=bS(n,e)}tt(ao),Ve(ao,n)}function qa(){tt(ao),tt(qc),tt(Zc)}function NT(e){hi(Zc.current);var n=hi(ao.current),t=bS(n,e.type);n!==t&&(Ve(qc,e),Ve(ao,t))}function cw(e){qc.current===e&&(tt(ao),tt(qc))}var st=Ks(0);function Wp(e){for(var n=e;n!==null;){if(n.tag===13){var t=n.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if(n.flags&128)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Nm=[];function uw(){for(var e=0;e<Nm.length;e++)Nm[e]._workInProgressVersionPrimary=null;Nm.length=0}var Uh=Qo.ReactCurrentDispatcher,Fm=Qo.ReactCurrentBatchConfig,Pi=0,lt=null,bt=null,_t=null,Gp=!1,mc=!1,Qc=0,FW=0;function Wt(){throw Error(q(321))}function dw(e,n){if(n===null)return!1;for(var t=0;t<n.length&&t<e.length;t++)if(!Hr(e[t],n[t]))return!1;return!0}function hw(e,n,t,r,o,s){if(Pi=s,lt=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,Uh.current=e===null||e.memoizedState===null?HW:KW,e=t(r,o),mc){s=0;do{if(mc=!1,Qc=0,25<=s)throw Error(q(301));s+=1,_t=bt=null,n.updateQueue=null,Uh.current=VW,e=t(r,o)}while(mc)}if(Uh.current=Yp,n=bt!==null&&bt.next!==null,Pi=0,_t=bt=lt=null,Gp=!1,n)throw Error(q(300));return e}function pw(){var e=Qc!==0;return Qc=0,e}function Zr(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return _t===null?lt.memoizedState=_t=e:_t=_t.next=e,_t}function Sr(){if(bt===null){var e=lt.alternate;e=e!==null?e.memoizedState:null}else e=bt.next;var n=_t===null?lt.memoizedState:_t.next;if(n!==null)_t=n,bt=e;else{if(e===null)throw Error(q(310));bt=e,e={memoizedState:bt.memoizedState,baseState:bt.baseState,baseQueue:bt.baseQueue,queue:bt.queue,next:null},_t===null?lt.memoizedState=_t=e:_t=_t.next=e}return _t}function Jc(e,n){return typeof n=="function"?n(e):n}function zm(e){var n=Sr(),t=n.queue;if(t===null)throw Error(q(311));t.lastRenderedReducer=e;var r=bt,o=r.baseQueue,s=t.pending;if(s!==null){if(o!==null){var i=o.next;o.next=s.next,s.next=i}r.baseQueue=o=s,t.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((Pi&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 d={lane:u,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=d,i=r):l=l.next=d,lt.lanes|=u,Ci|=u}c=c.next}while(c!==null&&c!==s);l===null?i=r:l.next=a,Hr(r,n.memoizedState)||(_n=!0),n.memoizedState=r,n.baseState=i,n.baseQueue=l,t.lastRenderedState=r}if(e=t.interleaved,e!==null){o=e;do s=o.lane,lt.lanes|=s,Ci|=s,o=o.next;while(o!==e)}else o===null&&(t.lanes=0);return[n.memoizedState,t.dispatch]}function Bm(e){var n=Sr(),t=n.queue;if(t===null)throw Error(q(311));t.lastRenderedReducer=e;var r=t.dispatch,o=t.pending,s=n.memoizedState;if(o!==null){t.pending=null;var i=o=o.next;do s=e(s,i.action),i=i.next;while(i!==o);Hr(s,n.memoizedState)||(_n=!0),n.memoizedState=s,n.baseQueue===null&&(n.baseState=s),t.lastRenderedState=s}return[s,r]}function FT(){}function zT(e,n){var t=lt,r=Sr(),o=n(),s=!Hr(r.memoizedState,o);if(s&&(r.memoizedState=o,_n=!0),r=r.queue,fw(HT.bind(null,t,r,e),[e]),r.getSnapshot!==n||s||_t!==null&&_t.memoizedState.tag&1){if(t.flags|=2048,eu(9,UT.bind(null,t,r,o,n),void 0,null),kt===null)throw Error(q(349));Pi&30||BT(t,n,o)}return o}function BT(e,n,t){e.flags|=16384,e={getSnapshot:n,value:t},n=lt.updateQueue,n===null?(n={lastEffect:null,stores:null},lt.updateQueue=n,n.stores=[e]):(t=n.stores,t===null?n.stores=[e]:t.push(e))}function UT(e,n,t,r){n.value=t,n.getSnapshot=r,KT(n)&&VT(e)}function HT(e,n,t){return t(function(){KT(n)&&VT(e)})}function KT(e){var n=e.getSnapshot;e=e.value;try{var t=n();return!Hr(e,t)}catch{return!0}}function VT(e){var n=Ho(e,1);n!==null&&Fr(n,e,1,-1)}function nC(e){var n=Zr();return typeof e=="function"&&(e=e()),n.memoizedState=n.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Jc,lastRenderedState:e},n.queue=e,e=e.dispatch=UW.bind(null,lt,e),[n.memoizedState,e]}function eu(e,n,t,r){return e={tag:e,create:n,destroy:t,deps:r,next:null},n=lt.updateQueue,n===null?(n={lastEffect:null,stores:null},lt.updateQueue=n,n.lastEffect=e.next=e):(t=n.lastEffect,t===null?n.lastEffect=e.next=e:(r=t.next,t.next=e,e.next=r,n.lastEffect=e)),e}function WT(){return Sr().memoizedState}function Hh(e,n,t,r){var o=Zr();lt.flags|=e,o.memoizedState=eu(1|n,t,void 0,r===void 0?null:r)}function Lf(e,n,t,r){var o=Sr();r=r===void 0?null:r;var s=void 0;if(bt!==null){var i=bt.memoizedState;if(s=i.destroy,r!==null&&dw(r,i.deps)){o.memoizedState=eu(n,t,s,r);return}}lt.flags|=e,o.memoizedState=eu(1|n,t,s,r)}function rC(e,n){return Hh(8390656,8,e,n)}function fw(e,n){return Lf(2048,8,e,n)}function GT(e,n){return Lf(4,2,e,n)}function YT(e,n){return Lf(4,4,e,n)}function XT(e,n){if(typeof n=="function")return e=e(),n(e),function(){n(null)};if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function qT(e,n,t){return t=t!=null?t.concat([e]):null,Lf(4,4,XT.bind(null,n,e),t)}function gw(){}function ZT(e,n){var t=Sr();n=n===void 0?null:n;var r=t.memoizedState;return r!==null&&n!==null&&dw(n,r[1])?r[0]:(t.memoizedState=[e,n],e)}function QT(e,n){var t=Sr();n=n===void 0?null:n;var r=t.memoizedState;return r!==null&&n!==null&&dw(n,r[1])?r[0]:(e=e(),t.memoizedState=[e,n],e)}function JT(e,n,t){return Pi&21?(Hr(t,n)||(t=nT(),lt.lanes|=t,Ci|=t,e.baseState=!0),n):(e.baseState&&(e.baseState=!1,_n=!0),e.memoizedState=t)}function zW(e,n){var t=Re;Re=t!==0&&4>t?t:4,e(!0);var r=Fm.transition;Fm.transition={};try{e(!1),n()}finally{Re=t,Fm.transition=r}}function e$(){return Sr().memoizedState}function BW(e,n,t){var r=ks(e);if(t={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null},t$(e))n$(n,t);else if(t=AT(e,n,t,r),t!==null){var o=pn();Fr(t,e,r,o),r$(t,n,r)}}function UW(e,n,t){var r=ks(e),o={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null};if(t$(e))n$(n,o);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=n.lastRenderedReducer,s!==null))try{var i=n.lastRenderedState,a=s(i,t);if(o.hasEagerState=!0,o.eagerState=a,Hr(a,i)){var l=n.interleaved;l===null?(o.next=o,iw(n)):(o.next=l.next,l.next=o),n.interleaved=o;return}}catch{}finally{}t=AT(e,n,o,r),t!==null&&(o=pn(),Fr(t,e,r,o),r$(t,n,r))}}function t$(e){var n=e.alternate;return e===lt||n!==null&&n===lt}function n$(e,n){mc=Gp=!0;var t=e.pending;t===null?n.next=n:(n.next=t.next,t.next=n),e.pending=n}function r$(e,n,t){if(t&4194240){var r=n.lanes;r&=e.pendingLanes,t|=r,n.lanes=t,W0(e,t)}}var Yp={readContext:yr,useCallback:Wt,useContext:Wt,useEffect:Wt,useImperativeHandle:Wt,useInsertionEffect:Wt,useLayoutEffect:Wt,useMemo:Wt,useReducer:Wt,useRef:Wt,useState:Wt,useDebugValue:Wt,useDeferredValue:Wt,useTransition:Wt,useMutableSource:Wt,useSyncExternalStore:Wt,useId:Wt,unstable_isNewReconciler:!1},HW={readContext:yr,useCallback:function(e,n){return Zr().memoizedState=[e,n===void 0?null:n],e},useContext:yr,useEffect:rC,useImperativeHandle:function(e,n,t){return t=t!=null?t.concat([e]):null,Hh(4194308,4,XT.bind(null,n,e),t)},useLayoutEffect:function(e,n){return Hh(4194308,4,e,n)},useInsertionEffect:function(e,n){return Hh(4,2,e,n)},useMemo:function(e,n){var t=Zr();return n=n===void 0?null:n,e=e(),t.memoizedState=[e,n],e},useReducer:function(e,n,t){var r=Zr();return n=t!==void 0?t(n):n,r.memoizedState=r.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},r.queue=e,e=e.dispatch=BW.bind(null,lt,e),[r.memoizedState,e]},useRef:function(e){var n=Zr();return e={current:e},n.memoizedState=e},useState:nC,useDebugValue:gw,useDeferredValue:function(e){return Zr().memoizedState=e},useTransition:function(){var e=nC(!1),n=e[0];return e=zW.bind(null,e[1]),Zr().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,t){var r=lt,o=Zr();if(nt){if(t===void 0)throw Error(q(407));t=t()}else{if(t=n(),kt===null)throw Error(q(349));Pi&30||BT(r,n,t)}o.memoizedState=t;var s={value:t,getSnapshot:n};return o.queue=s,rC(HT.bind(null,r,s,e),[e]),r.flags|=2048,eu(9,UT.bind(null,r,s,t,n),void 0,null),t},useId:function(){var e=Zr(),n=kt.identifierPrefix;if(nt){var t=Oo,r=jo;t=(r&~(1<<32-Nr(r)-1)).toString(32)+t,n=":"+n+"R"+t,t=Qc++,0<t&&(n+="H"+t.toString(32)),n+=":"}else t=FW++,n=":"+n+"r"+t.toString(32)+":";return e.memoizedState=n},unstable_isNewReconciler:!1},KW={readContext:yr,useCallback:ZT,useContext:yr,useEffect:fw,useImperativeHandle:qT,useInsertionEffect:GT,useLayoutEffect:YT,useMemo:QT,useReducer:zm,useRef:WT,useState:function(){return zm(Jc)},useDebugValue:gw,useDeferredValue:function(e){var n=Sr();return JT(n,bt.memoizedState,e)},useTransition:function(){var e=zm(Jc)[0],n=Sr().memoizedState;return[e,n]},useMutableSource:FT,useSyncExternalStore:zT,useId:e$,unstable_isNewReconciler:!1},VW={readContext:yr,useCallback:ZT,useContext:yr,useEffect:fw,useImperativeHandle:qT,useInsertionEffect:GT,useLayoutEffect:YT,useMemo:QT,useReducer:Bm,useRef:WT,useState:function(){return Bm(Jc)},useDebugValue:gw,useDeferredValue:function(e){var n=Sr();return bt===null?n.memoizedState=e:JT(n,bt.memoizedState,e)},useTransition:function(){var e=Bm(Jc)[0],n=Sr().memoizedState;return[e,n]},useMutableSource:FT,useSyncExternalStore:zT,useId:e$,unstable_isNewReconciler:!1};function Za(e,n){try{var t="",r=n;do t+=vV(r),r=r.return;while(r);var o=t}catch(s){o=`
|
|
196
|
+
Error generating stack: `+s.message+`
|
|
197
|
+
`+s.stack}return{value:e,source:n,stack:o,digest:null}}function Um(e,n,t){return{value:e,source:null,stack:t??null,digest:n??null}}function VS(e,n){try{console.error(n.value)}catch(t){setTimeout(function(){throw t})}}var WW=typeof WeakMap=="function"?WeakMap:Map;function o$(e,n,t){t=No(-1,t),t.tag=3,t.payload={element:null};var r=n.value;return t.callback=function(){qp||(qp=!0,tv=r),VS(e,n)},t}function s$(e,n,t){t=No(-1,t),t.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var o=n.value;t.payload=function(){return r(o)},t.callback=function(){VS(e,n)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(t.callback=function(){VS(e,n),typeof r!="function"&&(_s===null?_s=new Set([this]):_s.add(this));var i=n.stack;this.componentDidCatch(n.value,{componentStack:i!==null?i:""})}),t}function oC(e,n,t){var r=e.pingCache;if(r===null){r=e.pingCache=new WW;var o=new Set;r.set(n,o)}else o=r.get(n),o===void 0&&(o=new Set,r.set(n,o));o.has(t)||(o.add(t),e=iG.bind(null,e,n,t),n.then(e,e))}function sC(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function iC(e,n,t,r,o){return e.mode&1?(e.flags|=65536,e.lanes=o,e):(e===n?e.flags|=65536:(e.flags|=128,t.flags|=131072,t.flags&=-52805,t.tag===1&&(t.alternate===null?t.tag=17:(n=No(-1,1),n.tag=2,Es(t,n,1))),t.lanes|=1),e)}var GW=Qo.ReactCurrentOwner,_n=!1;function cn(e,n,t,r){n.child=e===null?LT(n,null,t,r):Xa(n,e.child,t,r)}function aC(e,n,t,r,o){t=t.render;var s=n.ref;return Na(n,o),r=hw(e,n,t,r,s,o),t=pw(),e!==null&&!_n?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~o,Ko(e,n,o)):(nt&&t&&ew(n),n.flags|=1,cn(e,n,r,o),n.child)}function lC(e,n,t,r,o){if(e===null){var s=t.type;return typeof s=="function"&&!Pw(s)&&s.defaultProps===void 0&&t.compare===null&&t.defaultProps===void 0?(n.tag=15,n.type=s,i$(e,n,s,r,o)):(e=Gh(t.type,null,r,n,n.mode,o),e.ref=n.ref,e.return=n,n.child=e)}if(s=e.child,!(e.lanes&o)){var i=s.memoizedProps;if(t=t.compare,t=t!==null?t:Wc,t(i,r)&&e.ref===n.ref)return Ko(e,n,o)}return n.flags|=1,e=Ts(s,r),e.ref=n.ref,e.return=n,n.child=e}function i$(e,n,t,r,o){if(e!==null){var s=e.memoizedProps;if(Wc(s,r)&&e.ref===n.ref)if(_n=!1,n.pendingProps=r=s,(e.lanes&o)!==0)e.flags&131072&&(_n=!0);else return n.lanes=e.lanes,Ko(e,n,o)}return WS(e,n,t,r,o)}function a$(e,n,t){var r=n.pendingProps,o=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(n.mode&1))n.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ve(ka,Kn),Kn|=t;else{if(!(t&1073741824))return e=s!==null?s.baseLanes|t:t,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,Ve(ka,Kn),Kn|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:t,Ve(ka,Kn),Kn|=r}else s!==null?(r=s.baseLanes|t,n.memoizedState=null):r=t,Ve(ka,Kn),Kn|=r;return cn(e,n,o,t),n.child}function l$(e,n){var t=n.ref;(e===null&&t!==null||e!==null&&e.ref!==t)&&(n.flags|=512,n.flags|=2097152)}function WS(e,n,t,r,o){var s=Mn(t)?xi:rn.current;return s=Ga(n,s),Na(n,o),t=hw(e,n,t,r,s,o),r=pw(),e!==null&&!_n?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~o,Ko(e,n,o)):(nt&&r&&ew(n),n.flags|=1,cn(e,n,t,o),n.child)}function cC(e,n,t,r,o){if(Mn(t)){var s=!0;zp(n)}else s=!1;if(Na(n,o),n.stateNode===null)Kh(e,n),DT(n,t,r),KS(n,t,r,o),r=!0;else if(e===null){var i=n.stateNode,a=n.memoizedProps;i.props=a;var l=i.context,c=t.contextType;typeof c=="object"&&c!==null?c=yr(c):(c=Mn(t)?xi:rn.current,c=Ga(n,c));var u=t.getDerivedStateFromProps,d=typeof u=="function"||typeof i.getSnapshotBeforeUpdate=="function";d||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(a!==r||l!==c)&&eC(n,i,r,c),cs=!1;var h=n.memoizedState;i.state=h,Vp(n,r,i,o),l=n.memoizedState,a!==r||h!==l||$n.current||cs?(typeof u=="function"&&(HS(n,t,u,r),l=n.memoizedState),(a=cs||JP(n,t,a,r,h,l,c))?(d||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(n.flags|=4194308)):(typeof i.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=r,n.memoizedState=l),i.props=r,i.state=l,i.context=c,r=a):(typeof i.componentDidMount=="function"&&(n.flags|=4194308),r=!1)}else{i=n.stateNode,jT(e,n),a=n.memoizedProps,c=n.type===n.elementType?a:Ir(n.type,a),i.props=c,d=n.pendingProps,h=i.context,l=t.contextType,typeof l=="object"&&l!==null?l=yr(l):(l=Mn(t)?xi:rn.current,l=Ga(n,l));var f=t.getDerivedStateFromProps;(u=typeof f=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(a!==d||h!==l)&&eC(n,i,r,l),cs=!1,h=n.memoizedState,i.state=h,Vp(n,r,i,o);var y=n.memoizedState;a!==d||h!==y||$n.current||cs?(typeof f=="function"&&(HS(n,t,f,r),y=n.memoizedState),(c=cs||JP(n,t,c,r,h,y,l)||!1)?(u||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,y,l),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,y,l)),typeof i.componentDidUpdate=="function"&&(n.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof i.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(n.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(n.flags|=1024),n.memoizedProps=r,n.memoizedState=y),i.props=r,i.state=y,i.context=l,r=c):(typeof i.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(n.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(n.flags|=1024),r=!1)}return GS(e,n,t,r,s,o)}function GS(e,n,t,r,o,s){l$(e,n);var i=(n.flags&128)!==0;if(!r&&!i)return o&&YP(n,t,!1),Ko(e,n,s);r=n.stateNode,GW.current=n;var a=i&&typeof t.getDerivedStateFromError!="function"?null:r.render();return n.flags|=1,e!==null&&i?(n.child=Xa(n,e.child,null,s),n.child=Xa(n,null,a,s)):cn(e,n,a,s),n.memoizedState=r.state,o&&YP(n,t,!0),n.child}function c$(e){var n=e.stateNode;n.pendingContext?GP(e,n.pendingContext,n.pendingContext!==n.context):n.context&&GP(e,n.context,!1),lw(e,n.containerInfo)}function uC(e,n,t,r,o){return Ya(),nw(o),n.flags|=256,cn(e,n,t,r),n.child}var YS={dehydrated:null,treeContext:null,retryLane:0};function XS(e){return{baseLanes:e,cachePool:null,transitions:null}}function u$(e,n,t){var r=n.pendingProps,o=st.current,s=!1,i=(n.flags&128)!==0,a;if((a=i)||(a=e!==null&&e.memoizedState===null?!1:(o&2)!==0),a?(s=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(o|=1),Ve(st,o&1),e===null)return BS(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(n.mode&1?e.data==="$!"?n.lanes=8:n.lanes=1073741824:n.lanes=1,null):(i=r.children,e=r.fallback,s?(r=n.mode,s=n.child,i={mode:"hidden",children:i},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=i):s=zf(i,r,0,null),e=mi(e,r,t,null),s.return=n,e.return=n,s.sibling=e,n.child=s,n.child.memoizedState=XS(t),n.memoizedState=YS,e):mw(n,i));if(o=e.memoizedState,o!==null&&(a=o.dehydrated,a!==null))return YW(e,n,i,r,a,o,t);if(s){s=r.fallback,i=n.mode,o=e.child,a=o.sibling;var l={mode:"hidden",children:r.children};return!(i&1)&&n.child!==o?(r=n.child,r.childLanes=0,r.pendingProps=l,n.deletions=null):(r=Ts(o,l),r.subtreeFlags=o.subtreeFlags&14680064),a!==null?s=Ts(a,s):(s=mi(s,i,t,null),s.flags|=2),s.return=n,r.return=n,r.sibling=s,n.child=r,r=s,s=n.child,i=e.child.memoizedState,i=i===null?XS(t):{baseLanes:i.baseLanes|t,cachePool:null,transitions:i.transitions},s.memoizedState=i,s.childLanes=e.childLanes&~t,n.memoizedState=YS,r}return s=e.child,e=s.sibling,r=Ts(s,{mode:"visible",children:r.children}),!(n.mode&1)&&(r.lanes=t),r.return=n,r.sibling=null,e!==null&&(t=n.deletions,t===null?(n.deletions=[e],n.flags|=16):t.push(e)),n.child=r,n.memoizedState=null,r}function mw(e,n){return n=zf({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Ld(e,n,t,r){return r!==null&&nw(r),Xa(n,e.child,null,t),e=mw(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function YW(e,n,t,r,o,s,i){if(t)return n.flags&256?(n.flags&=-257,r=Um(Error(q(422))),Ld(e,n,i,r)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(s=r.fallback,o=n.mode,r=zf({mode:"visible",children:r.children},o,0,null),s=mi(s,o,i,null),s.flags|=2,r.return=n,s.return=n,r.sibling=s,n.child=r,n.mode&1&&Xa(n,e.child,null,i),n.child.memoizedState=XS(i),n.memoizedState=YS,s);if(!(n.mode&1))return Ld(e,n,i,null);if(o.data==="$!"){if(r=o.nextSibling&&o.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(q(419)),r=Um(s,r,void 0),Ld(e,n,i,r)}if(a=(i&e.childLanes)!==0,_n||a){if(r=kt,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,Ho(e,o),Fr(r,e,o,-1))}return bw(),r=Um(Error(q(421))),Ld(e,n,i,r)}return o.data==="$?"?(n.flags|=128,n.child=e.child,n=aG.bind(null,e),o._reactRetry=n,null):(e=s.treeContext,Yn=Is(o.nextSibling),qn=n,nt=!0,Mr=null,e!==null&&(cr[ur++]=jo,cr[ur++]=Oo,cr[ur++]=bi,jo=e.id,Oo=e.overflow,bi=n),n=mw(n,r.children),n.flags|=4096,n)}function dC(e,n,t){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n),US(e.return,n,t)}function Hm(e,n,t,r,o){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:r,tail:t,tailMode:o}:(s.isBackwards=n,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=t,s.tailMode=o)}function d$(e,n,t){var r=n.pendingProps,o=r.revealOrder,s=r.tail;if(cn(e,n,r.children,t),r=st.current,r&2)r=r&1|2,n.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&dC(e,t,n);else if(e.tag===19)dC(e,t,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Ve(st,r),!(n.mode&1))n.memoizedState=null;else switch(o){case"forwards":for(t=n.child,o=null;t!==null;)e=t.alternate,e!==null&&Wp(e)===null&&(o=t),t=t.sibling;t=o,t===null?(o=n.child,n.child=null):(o=t.sibling,t.sibling=null),Hm(n,!1,o,t,s);break;case"backwards":for(t=null,o=n.child,n.child=null;o!==null;){if(e=o.alternate,e!==null&&Wp(e)===null){n.child=o;break}e=o.sibling,o.sibling=t,t=o,o=e}Hm(n,!0,t,null,s);break;case"together":Hm(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function Kh(e,n){!(n.mode&1)&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function Ko(e,n,t){if(e!==null&&(n.dependencies=e.dependencies),Ci|=n.lanes,!(t&n.childLanes))return null;if(e!==null&&n.child!==e.child)throw Error(q(153));if(n.child!==null){for(e=n.child,t=Ts(e,e.pendingProps),n.child=t,t.return=n;e.sibling!==null;)e=e.sibling,t=t.sibling=Ts(e,e.pendingProps),t.return=n;t.sibling=null}return n.child}function XW(e,n,t){switch(n.tag){case 3:c$(n),Ya();break;case 5:NT(n);break;case 1:Mn(n.type)&&zp(n);break;case 4:lw(n,n.stateNode.containerInfo);break;case 10:var r=n.type._context,o=n.memoizedProps.value;Ve(Hp,r._currentValue),r._currentValue=o;break;case 13:if(r=n.memoizedState,r!==null)return r.dehydrated!==null?(Ve(st,st.current&1),n.flags|=128,null):t&n.child.childLanes?u$(e,n,t):(Ve(st,st.current&1),e=Ko(e,n,t),e!==null?e.sibling:null);Ve(st,st.current&1);break;case 19:if(r=(t&n.childLanes)!==0,e.flags&128){if(r)return d$(e,n,t);n.flags|=128}if(o=n.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),Ve(st,st.current),r)break;return null;case 22:case 23:return n.lanes=0,a$(e,n,t)}return Ko(e,n,t)}var h$,qS,p$,f$;h$=function(e,n){for(var t=n.child;t!==null;){if(t.tag===5||t.tag===6)e.appendChild(t.stateNode);else if(t.tag!==4&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===n)break;for(;t.sibling===null;){if(t.return===null||t.return===n)return;t=t.return}t.sibling.return=t.return,t=t.sibling}};qS=function(){};p$=function(e,n,t,r){var o=e.memoizedProps;if(o!==r){e=n.stateNode,hi(ao.current);var s=null;switch(t){case"input":o=SS(e,o),r=SS(e,r),s=[];break;case"select":o=ct({},o,{value:void 0}),r=ct({},r,{value:void 0}),s=[];break;case"textarea":o=xS(e,o),r=xS(e,r),s=[];break;default:typeof o.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Np)}PS(t,r);var i;t=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)&&(t||(t={}),t[i]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(Fc.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)||(t||(t={}),t[i]="");for(i in l)l.hasOwnProperty(i)&&a[i]!==l[i]&&(t||(t={}),t[i]=l[i])}else t||(s||(s=[]),s.push(c,t)),t=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"&&(Fc.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&Qe("scroll",e),s||a===l||(s=[])):(s=s||[]).push(c,l))}t&&(s=s||[]).push("style",t);var c=s;(n.updateQueue=c)&&(n.flags|=4)}};f$=function(e,n,t,r){t!==r&&(n.flags|=4)};function Ul(e,n){if(!nt)switch(e.tailMode){case"hidden":n=e.tail;for(var t=null;n!==null;)n.alternate!==null&&(t=n),n=n.sibling;t===null?e.tail=null:t.sibling=null;break;case"collapsed":t=e.tail;for(var r=null;t!==null;)t.alternate!==null&&(r=t),t=t.sibling;r===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Gt(e){var n=e.alternate!==null&&e.alternate.child===e.child,t=0,r=0;if(n)for(var o=e.child;o!==null;)t|=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;)t|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,o.return=e,o=o.sibling;return e.subtreeFlags|=r,e.childLanes=t,n}function qW(e,n,t){var r=n.pendingProps;switch(tw(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gt(n),null;case 1:return Mn(n.type)&&Fp(),Gt(n),null;case 3:return r=n.stateNode,qa(),tt($n),tt(rn),uw(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Dd(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&!(n.flags&256)||(n.flags|=1024,Mr!==null&&(ov(Mr),Mr=null))),qS(e,n),Gt(n),null;case 5:cw(n);var o=hi(Zc.current);if(t=n.type,e!==null&&n.stateNode!=null)p$(e,n,t,r,o),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!r){if(n.stateNode===null)throw Error(q(166));return Gt(n),null}if(e=hi(ao.current),Dd(n)){r=n.stateNode,t=n.type;var s=n.memoizedProps;switch(r[Jr]=n,r[Xc]=s,e=(n.mode&1)!==0,t){case"dialog":Qe("cancel",r),Qe("close",r);break;case"iframe":case"object":case"embed":Qe("load",r);break;case"video":case"audio":for(o=0;o<nc.length;o++)Qe(nc[o],r);break;case"source":Qe("error",r);break;case"img":case"image":case"link":Qe("error",r),Qe("load",r);break;case"details":Qe("toggle",r);break;case"input":wP(r,s),Qe("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},Qe("invalid",r);break;case"textarea":bP(r,s),Qe("invalid",r)}PS(t,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&&Od(r.textContent,a,e),o=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(s.suppressHydrationWarning!==!0&&Od(r.textContent,a,e),o=["children",""+a]):Fc.hasOwnProperty(i)&&a!=null&&i==="onScroll"&&Qe("scroll",r)}switch(t){case"input":Ed(r),xP(r,s,!0);break;case"textarea":Ed(r),PP(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=Np)}r=o,n.updateQueue=r,r!==null&&(n.flags|=4)}else{i=o.nodeType===9?o:o.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=B2(t)),e==="http://www.w3.org/1999/xhtml"?t==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(t,{is:r.is}):(e=i.createElement(t),t==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,t),e[Jr]=n,e[Xc]=r,h$(e,n,!1,!1),n.stateNode=e;e:{switch(i=CS(t,r),t){case"dialog":Qe("cancel",e),Qe("close",e),o=r;break;case"iframe":case"object":case"embed":Qe("load",e),o=r;break;case"video":case"audio":for(o=0;o<nc.length;o++)Qe(nc[o],e);o=r;break;case"source":Qe("error",e),o=r;break;case"img":case"image":case"link":Qe("error",e),Qe("load",e),o=r;break;case"details":Qe("toggle",e),o=r;break;case"input":wP(e,r),o=SS(e,r),Qe("invalid",e);break;case"option":o=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},o=ct({},r,{value:void 0}),Qe("invalid",e);break;case"textarea":bP(e,r),o=xS(e,r),Qe("invalid",e);break;default:o=r}PS(t,o),a=o;for(s in a)if(a.hasOwnProperty(s)){var l=a[s];s==="style"?K2(e,l):s==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&U2(e,l)):s==="children"?typeof l=="string"?(t!=="textarea"||l!=="")&&zc(e,l):typeof l=="number"&&zc(e,""+l):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Fc.hasOwnProperty(s)?l!=null&&s==="onScroll"&&Qe("scroll",e):l!=null&&z0(e,s,l,i))}switch(t){case"input":Ed(e),xP(e,r,!1);break;case"textarea":Ed(e),PP(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Os(r.value));break;case"select":e.multiple=!!r.multiple,s=r.value,s!=null?Oa(e,!!r.multiple,s,!1):r.defaultValue!=null&&Oa(e,!!r.multiple,r.defaultValue,!0);break;default:typeof o.onClick=="function"&&(e.onclick=Np)}switch(t){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return Gt(n),null;case 6:if(e&&n.stateNode!=null)f$(e,n,e.memoizedProps,r);else{if(typeof r!="string"&&n.stateNode===null)throw Error(q(166));if(t=hi(Zc.current),hi(ao.current),Dd(n)){if(r=n.stateNode,t=n.memoizedProps,r[Jr]=n,(s=r.nodeValue!==t)&&(e=qn,e!==null))switch(e.tag){case 3:Od(r.nodeValue,t,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Od(r.nodeValue,t,(e.mode&1)!==0)}s&&(n.flags|=4)}else r=(t.nodeType===9?t:t.ownerDocument).createTextNode(r),r[Jr]=n,n.stateNode=r}return Gt(n),null;case 13:if(tt(st),r=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(nt&&Yn!==null&&n.mode&1&&!(n.flags&128))MT(),Ya(),n.flags|=98560,s=!1;else if(s=Dd(n),r!==null&&r.dehydrated!==null){if(e===null){if(!s)throw Error(q(318));if(s=n.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(q(317));s[Jr]=n}else Ya(),!(n.flags&128)&&(n.memoizedState=null),n.flags|=4;Gt(n),s=!1}else Mr!==null&&(ov(Mr),Mr=null),s=!0;if(!s)return n.flags&65536?n:null}return n.flags&128?(n.lanes=t,n):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(n.child.flags|=8192,n.mode&1&&(e===null||st.current&1?Ct===0&&(Ct=3):bw())),n.updateQueue!==null&&(n.flags|=4),Gt(n),null);case 4:return qa(),qS(e,n),e===null&&Gc(n.stateNode.containerInfo),Gt(n),null;case 10:return sw(n.type._context),Gt(n),null;case 17:return Mn(n.type)&&Fp(),Gt(n),null;case 19:if(tt(st),s=n.memoizedState,s===null)return Gt(n),null;if(r=(n.flags&128)!==0,i=s.rendering,i===null)if(r)Ul(s,!1);else{if(Ct!==0||e!==null&&e.flags&128)for(e=n.child;e!==null;){if(i=Wp(e),i!==null){for(n.flags|=128,Ul(s,!1),r=i.updateQueue,r!==null&&(n.updateQueue=r,n.flags|=4),n.subtreeFlags=0,r=t,t=n.child;t!==null;)s=t,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}),t=t.sibling;return Ve(st,st.current&1|2),n.child}e=e.sibling}s.tail!==null&>()>Qa&&(n.flags|=128,r=!0,Ul(s,!1),n.lanes=4194304)}else{if(!r)if(e=Wp(i),e!==null){if(n.flags|=128,r=!0,t=e.updateQueue,t!==null&&(n.updateQueue=t,n.flags|=4),Ul(s,!0),s.tail===null&&s.tailMode==="hidden"&&!i.alternate&&!nt)return Gt(n),null}else 2*gt()-s.renderingStartTime>Qa&&t!==1073741824&&(n.flags|=128,r=!0,Ul(s,!1),n.lanes=4194304);s.isBackwards?(i.sibling=n.child,n.child=i):(t=s.last,t!==null?t.sibling=i:n.child=i,s.last=i)}return s.tail!==null?(n=s.tail,s.rendering=n,s.tail=n.sibling,s.renderingStartTime=gt(),n.sibling=null,t=st.current,Ve(st,r?t&1|2:t&1),n):(Gt(n),null);case 22:case 23:return xw(),r=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(n.flags|=8192),r&&n.mode&1?Kn&1073741824&&(Gt(n),n.subtreeFlags&6&&(n.flags|=8192)):Gt(n),null;case 24:return null;case 25:return null}throw Error(q(156,n.tag))}function ZW(e,n){switch(tw(n),n.tag){case 1:return Mn(n.type)&&Fp(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return qa(),tt($n),tt(rn),uw(),e=n.flags,e&65536&&!(e&128)?(n.flags=e&-65537|128,n):null;case 5:return cw(n),null;case 13:if(tt(st),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(q(340));Ya()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return tt(st),null;case 4:return qa(),null;case 10:return sw(n.type._context),null;case 22:case 23:return xw(),null;case 24:return null;default:return null}}var Nd=!1,Qt=!1,QW=typeof WeakSet=="function"?WeakSet:Set,te=null;function _a(e,n){var t=e.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){dt(e,n,r)}else t.current=null}function ZS(e,n,t){try{t()}catch(r){dt(e,n,r)}}var hC=!1;function JW(e,n){if(OS=Dp,e=ST(),J0(e)){if("selectionStart"in e)var t={start:e.selectionStart,end:e.selectionEnd};else e:{t=(t=e.ownerDocument)&&t.defaultView||window;var r=t.getSelection&&t.getSelection();if(r&&r.rangeCount!==0){t=r.anchorNode;var o=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{t.nodeType,s.nodeType}catch{t=null;break e}var i=0,a=-1,l=-1,c=0,u=0,d=e,h=null;t:for(;;){for(var f;d!==t||o!==0&&d.nodeType!==3||(a=i+o),d!==s||r!==0&&d.nodeType!==3||(l=i+r),d.nodeType===3&&(i+=d.nodeValue.length),(f=d.firstChild)!==null;)h=d,d=f;for(;;){if(d===e)break t;if(h===t&&++c===o&&(a=i),h===s&&++u===r&&(l=i),(f=d.nextSibling)!==null)break;d=h,h=d.parentNode}d=f}t=a===-1||l===-1?null:{start:a,end:l}}else t=null}t=t||{start:0,end:0}}else t=null;for(DS={focusedElem:e,selectionRange:t},Dp=!1,te=n;te!==null;)if(n=te,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,te=e;else for(;te!==null;){n=te;try{var y=n.alternate;if(n.flags&1024)switch(n.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var g=y.memoizedProps,v=y.memoizedState,S=n.stateNode,w=S.getSnapshotBeforeUpdate(n.elementType===n.type?g:Ir(n.type,g),v);S.__reactInternalSnapshotBeforeUpdate=w}break;case 3:var C=n.stateNode.containerInfo;C.nodeType===1?C.textContent="":C.nodeType===9&&C.documentElement&&C.removeChild(C.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(q(163))}}catch(I){dt(n,n.return,I)}if(e=n.sibling,e!==null){e.return=n.return,te=e;break}te=n.return}return y=hC,hC=!1,y}function yc(e,n,t){var r=n.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&&ZS(n,t,s)}o=o.next}while(o!==r)}}function Nf(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var t=n=n.next;do{if((t.tag&e)===e){var r=t.create;t.destroy=r()}t=t.next}while(t!==n)}}function QS(e){var n=e.ref;if(n!==null){var t=e.stateNode;switch(e.tag){case 5:e=t;break;default:e=t}typeof n=="function"?n(e):n.current=e}}function g$(e){var n=e.alternate;n!==null&&(e.alternate=null,g$(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Jr],delete n[Xc],delete n[NS],delete n[DW],delete n[RW])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function m$(e){return e.tag===5||e.tag===3||e.tag===4}function pC(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||m$(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function JS(e,n,t){var r=e.tag;if(r===5||r===6)e=e.stateNode,n?t.nodeType===8?t.parentNode.insertBefore(e,n):t.insertBefore(e,n):(t.nodeType===8?(n=t.parentNode,n.insertBefore(e,t)):(n=t,n.appendChild(e)),t=t._reactRootContainer,t!=null||n.onclick!==null||(n.onclick=Np));else if(r!==4&&(e=e.child,e!==null))for(JS(e,n,t),e=e.sibling;e!==null;)JS(e,n,t),e=e.sibling}function ev(e,n,t){var r=e.tag;if(r===5||r===6)e=e.stateNode,n?t.insertBefore(e,n):t.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ev(e,n,t),e=e.sibling;e!==null;)ev(e,n,t),e=e.sibling}var Ot=null,kr=!1;function is(e,n,t){for(t=t.child;t!==null;)y$(e,n,t),t=t.sibling}function y$(e,n,t){if(io&&typeof io.onCommitFiberUnmount=="function")try{io.onCommitFiberUnmount($f,t)}catch{}switch(t.tag){case 5:Qt||_a(t,n);case 6:var r=Ot,o=kr;Ot=null,is(e,n,t),Ot=r,kr=o,Ot!==null&&(kr?(e=Ot,t=t.stateNode,e.nodeType===8?e.parentNode.removeChild(t):e.removeChild(t)):Ot.removeChild(t.stateNode));break;case 18:Ot!==null&&(kr?(e=Ot,t=t.stateNode,e.nodeType===8?Rm(e.parentNode,t):e.nodeType===1&&Rm(e,t),Kc(e)):Rm(Ot,t.stateNode));break;case 4:r=Ot,o=kr,Ot=t.stateNode.containerInfo,kr=!0,is(e,n,t),Ot=r,kr=o;break;case 0:case 11:case 14:case 15:if(!Qt&&(r=t.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)&&ZS(t,n,i),o=o.next}while(o!==r)}is(e,n,t);break;case 1:if(!Qt&&(_a(t,n),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(a){dt(t,n,a)}is(e,n,t);break;case 21:is(e,n,t);break;case 22:t.mode&1?(Qt=(r=Qt)||t.memoizedState!==null,is(e,n,t),Qt=r):is(e,n,t);break;default:is(e,n,t)}}function fC(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var t=e.stateNode;t===null&&(t=e.stateNode=new QW),n.forEach(function(r){var o=lG.bind(null,e,r);t.has(r)||(t.add(r),r.then(o,o))})}}function Cr(e,n){var t=n.deletions;if(t!==null)for(var r=0;r<t.length;r++){var o=t[r];try{var s=e,i=n,a=i;e:for(;a!==null;){switch(a.tag){case 5:Ot=a.stateNode,kr=!1;break e;case 3:Ot=a.stateNode.containerInfo,kr=!0;break e;case 4:Ot=a.stateNode.containerInfo,kr=!0;break e}a=a.return}if(Ot===null)throw Error(q(160));y$(s,i,o),Ot=null,kr=!1;var l=o.alternate;l!==null&&(l.return=null),o.return=null}catch(c){dt(o,n,c)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)S$(n,e),n=n.sibling}function S$(e,n){var t=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Cr(n,e),Xr(e),r&4){try{yc(3,e,e.return),Nf(3,e)}catch(g){dt(e,e.return,g)}try{yc(5,e,e.return)}catch(g){dt(e,e.return,g)}}break;case 1:Cr(n,e),Xr(e),r&512&&t!==null&&_a(t,t.return);break;case 5:if(Cr(n,e),Xr(e),r&512&&t!==null&&_a(t,t.return),e.flags&32){var o=e.stateNode;try{zc(o,"")}catch(g){dt(e,e.return,g)}}if(r&4&&(o=e.stateNode,o!=null)){var s=e.memoizedProps,i=t!==null?t.memoizedProps:s,a=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{a==="input"&&s.type==="radio"&&s.name!=null&&F2(o,s),CS(a,i);var c=CS(a,s);for(i=0;i<l.length;i+=2){var u=l[i],d=l[i+1];u==="style"?K2(o,d):u==="dangerouslySetInnerHTML"?U2(o,d):u==="children"?zc(o,d):z0(o,u,d,c)}switch(a){case"input":vS(o,s);break;case"textarea":z2(o,s);break;case"select":var h=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!s.multiple;var f=s.value;f!=null?Oa(o,!!s.multiple,f,!1):h!==!!s.multiple&&(s.defaultValue!=null?Oa(o,!!s.multiple,s.defaultValue,!0):Oa(o,!!s.multiple,s.multiple?[]:"",!1))}o[Xc]=s}catch(g){dt(e,e.return,g)}}break;case 6:if(Cr(n,e),Xr(e),r&4){if(e.stateNode===null)throw Error(q(162));o=e.stateNode,s=e.memoizedProps;try{o.nodeValue=s}catch(g){dt(e,e.return,g)}}break;case 3:if(Cr(n,e),Xr(e),r&4&&t!==null&&t.memoizedState.isDehydrated)try{Kc(n.containerInfo)}catch(g){dt(e,e.return,g)}break;case 4:Cr(n,e),Xr(e);break;case 13:Cr(n,e),Xr(e),o=e.child,o.flags&8192&&(s=o.memoizedState!==null,o.stateNode.isHidden=s,!s||o.alternate!==null&&o.alternate.memoizedState!==null||(vw=gt())),r&4&&fC(e);break;case 22:if(u=t!==null&&t.memoizedState!==null,e.mode&1?(Qt=(c=Qt)||u,Cr(n,e),Qt=c):Cr(n,e),Xr(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(d=te=u;te!==null;){switch(h=te,f=h.child,h.tag){case 0:case 11:case 14:case 15:yc(4,h,h.return);break;case 1:_a(h,h.return);var y=h.stateNode;if(typeof y.componentWillUnmount=="function"){r=h,t=h.return;try{n=r,y.props=n.memoizedProps,y.state=n.memoizedState,y.componentWillUnmount()}catch(g){dt(r,t,g)}}break;case 5:_a(h,h.return);break;case 22:if(h.memoizedState!==null){mC(d);continue}}f!==null?(f.return=h,te=f):mC(d)}u=u.sibling}e:for(u=null,d=e;;){if(d.tag===5){if(u===null){u=d;try{o=d.stateNode,c?(s=o.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(a=d.stateNode,l=d.memoizedProps.style,i=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=H2("display",i))}catch(g){dt(e,e.return,g)}}}else if(d.tag===6){if(u===null)try{d.stateNode.nodeValue=c?"":d.memoizedProps}catch(g){dt(e,e.return,g)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===e)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;d.sibling===null;){if(d.return===null||d.return===e)break e;u===d&&(u=null),d=d.return}u===d&&(u=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:Cr(n,e),Xr(e),r&4&&fC(e);break;case 21:break;default:Cr(n,e),Xr(e)}}function Xr(e){var n=e.flags;if(n&2){try{e:{for(var t=e.return;t!==null;){if(m$(t)){var r=t;break e}t=t.return}throw Error(q(160))}switch(r.tag){case 5:var o=r.stateNode;r.flags&32&&(zc(o,""),r.flags&=-33);var s=pC(e);ev(e,s,o);break;case 3:case 4:var i=r.stateNode.containerInfo,a=pC(e);JS(e,a,i);break;default:throw Error(q(161))}}catch(l){dt(e,e.return,l)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function eG(e,n,t){te=e,v$(e)}function v$(e,n,t){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||Nd;if(!i){var a=o.alternate,l=a!==null&&a.memoizedState!==null||Qt;a=Nd;var c=Qt;if(Nd=i,(Qt=l)&&!c)for(te=o;te!==null;)i=te,l=i.child,i.tag===22&&i.memoizedState!==null?yC(o):l!==null?(l.return=i,te=l):yC(o);for(;s!==null;)te=s,v$(s),s=s.sibling;te=o,Nd=a,Qt=c}gC(e)}else o.subtreeFlags&8772&&s!==null?(s.return=o,te=s):gC(e)}}function gC(e){for(;te!==null;){var n=te;if(n.flags&8772){var t=n.alternate;try{if(n.flags&8772)switch(n.tag){case 0:case 11:case 15:Qt||Nf(5,n);break;case 1:var r=n.stateNode;if(n.flags&4&&!Qt)if(t===null)r.componentDidMount();else{var o=n.elementType===n.type?t.memoizedProps:Ir(n.type,t.memoizedProps);r.componentDidUpdate(o,t.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=n.updateQueue;s!==null&&QP(n,s,r);break;case 3:var i=n.updateQueue;if(i!==null){if(t=null,n.child!==null)switch(n.child.tag){case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}QP(n,i,t)}break;case 5:var a=n.stateNode;if(t===null&&n.flags&4){t=a;var l=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&t.focus();break;case"img":l.src&&(t.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var c=n.alternate;if(c!==null){var u=c.memoizedState;if(u!==null){var d=u.dehydrated;d!==null&&Kc(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(q(163))}Qt||n.flags&512&&QS(n)}catch(h){dt(n,n.return,h)}}if(n===e){te=null;break}if(t=n.sibling,t!==null){t.return=n.return,te=t;break}te=n.return}}function mC(e){for(;te!==null;){var n=te;if(n===e){te=null;break}var t=n.sibling;if(t!==null){t.return=n.return,te=t;break}te=n.return}}function yC(e){for(;te!==null;){var n=te;try{switch(n.tag){case 0:case 11:case 15:var t=n.return;try{Nf(4,n)}catch(l){dt(n,t,l)}break;case 1:var r=n.stateNode;if(typeof r.componentDidMount=="function"){var o=n.return;try{r.componentDidMount()}catch(l){dt(n,o,l)}}var s=n.return;try{QS(n)}catch(l){dt(n,s,l)}break;case 5:var i=n.return;try{QS(n)}catch(l){dt(n,i,l)}}}catch(l){dt(n,n.return,l)}if(n===e){te=null;break}var a=n.sibling;if(a!==null){a.return=n.return,te=a;break}te=n.return}}var tG=Math.ceil,Xp=Qo.ReactCurrentDispatcher,yw=Qo.ReactCurrentOwner,gr=Qo.ReactCurrentBatchConfig,Ce=0,kt=null,wt=null,Ht=0,Kn=0,ka=Ks(0),Ct=0,tu=null,Ci=0,Ff=0,Sw=0,Sc=null,Cn=null,vw=0,Qa=1/0,Eo=null,qp=!1,tv=null,_s=null,Fd=!1,vs=null,Zp=0,vc=0,nv=null,Vh=-1,Wh=0;function pn(){return Ce&6?gt():Vh!==-1?Vh:Vh=gt()}function ks(e){return e.mode&1?Ce&2&&Ht!==0?Ht&-Ht:NW.transition!==null?(Wh===0&&(Wh=nT()),Wh):(e=Re,e!==0||(e=window.event,e=e===void 0?16:cT(e.type)),e):1}function Fr(e,n,t,r){if(50<vc)throw vc=0,nv=null,Error(q(185));ju(e,t,r),(!(Ce&2)||e!==kt)&&(e===kt&&(!(Ce&2)&&(Ff|=t),Ct===4&&fs(e,Ht)),An(e,r),t===1&&Ce===0&&!(n.mode&1)&&(Qa=gt()+500,Df&&Vs()))}function An(e,n){var t=e.callbackNode;NV(e,n);var r=Op(e,e===kt?Ht:0);if(r===0)t!==null&&EP(t),e.callbackNode=null,e.callbackPriority=0;else if(n=r&-r,e.callbackPriority!==n){if(t!=null&&EP(t),n===1)e.tag===0?LW(SC.bind(null,e)):kT(SC.bind(null,e)),jW(function(){!(Ce&6)&&Vs()}),t=null;else{switch(rT(r)){case 1:t=V0;break;case 4:t=eT;break;case 16:t=jp;break;case 536870912:t=tT;break;default:t=jp}t=_$(t,w$.bind(null,e))}e.callbackPriority=n,e.callbackNode=t}}function w$(e,n){if(Vh=-1,Wh=0,Ce&6)throw Error(q(327));var t=e.callbackNode;if(Fa()&&e.callbackNode!==t)return null;var r=Op(e,e===kt?Ht:0);if(r===0)return null;if(r&30||r&e.expiredLanes||n)n=Qp(e,r);else{n=r;var o=Ce;Ce|=2;var s=b$();(kt!==e||Ht!==n)&&(Eo=null,Qa=gt()+500,gi(e,n));do try{oG();break}catch(a){x$(e,a)}while(!0);ow(),Xp.current=s,Ce=o,wt!==null?n=0:(kt=null,Ht=0,n=Ct)}if(n!==0){if(n===2&&(o=TS(e),o!==0&&(r=o,n=rv(e,o))),n===1)throw t=tu,gi(e,0),fs(e,r),An(e,gt()),t;if(n===6)fs(e,r);else{if(o=e.current.alternate,!(r&30)&&!nG(o)&&(n=Qp(e,r),n===2&&(s=TS(e),s!==0&&(r=s,n=rv(e,s))),n===1))throw t=tu,gi(e,0),fs(e,r),An(e,gt()),t;switch(e.finishedWork=o,e.finishedLanes=r,n){case 0:case 1:throw Error(q(345));case 2:si(e,Cn,Eo);break;case 3:if(fs(e,r),(r&130023424)===r&&(n=vw+500-gt(),10<n)){if(Op(e,0)!==0)break;if(o=e.suspendedLanes,(o&r)!==r){pn(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=LS(si.bind(null,e,Cn,Eo),n);break}si(e,Cn,Eo);break;case 4:if(fs(e,r),(r&4194240)===r)break;for(n=e.eventTimes,o=-1;0<r;){var i=31-Nr(r);s=1<<i,i=n[i],i>o&&(o=i),r&=~s}if(r=o,r=gt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*tG(r/1960))-r,10<r){e.timeoutHandle=LS(si.bind(null,e,Cn,Eo),r);break}si(e,Cn,Eo);break;case 5:si(e,Cn,Eo);break;default:throw Error(q(329))}}}return An(e,gt()),e.callbackNode===t?w$.bind(null,e):null}function rv(e,n){var t=Sc;return e.current.memoizedState.isDehydrated&&(gi(e,n).flags|=256),e=Qp(e,n),e!==2&&(n=Cn,Cn=t,n!==null&&ov(n)),e}function ov(e){Cn===null?Cn=e:Cn.push.apply(Cn,e)}function nG(e){for(var n=e;;){if(n.flags&16384){var t=n.updateQueue;if(t!==null&&(t=t.stores,t!==null))for(var r=0;r<t.length;r++){var o=t[r],s=o.getSnapshot;o=o.value;try{if(!Hr(s(),o))return!1}catch{return!1}}}if(t=n.child,n.subtreeFlags&16384&&t!==null)t.return=n,n=t;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function fs(e,n){for(n&=~Sw,n&=~Ff,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var t=31-Nr(n),r=1<<t;e[t]=-1,n&=~r}}function SC(e){if(Ce&6)throw Error(q(327));Fa();var n=Op(e,0);if(!(n&1))return An(e,gt()),null;var t=Qp(e,n);if(e.tag!==0&&t===2){var r=TS(e);r!==0&&(n=r,t=rv(e,r))}if(t===1)throw t=tu,gi(e,0),fs(e,n),An(e,gt()),t;if(t===6)throw Error(q(345));return e.finishedWork=e.current.alternate,e.finishedLanes=n,si(e,Cn,Eo),An(e,gt()),null}function ww(e,n){var t=Ce;Ce|=1;try{return e(n)}finally{Ce=t,Ce===0&&(Qa=gt()+500,Df&&Vs())}}function Ii(e){vs!==null&&vs.tag===0&&!(Ce&6)&&Fa();var n=Ce;Ce|=1;var t=gr.transition,r=Re;try{if(gr.transition=null,Re=1,e)return e()}finally{Re=r,gr.transition=t,Ce=n,!(Ce&6)&&Vs()}}function xw(){Kn=ka.current,tt(ka)}function gi(e,n){e.finishedWork=null,e.finishedLanes=0;var t=e.timeoutHandle;if(t!==-1&&(e.timeoutHandle=-1,AW(t)),wt!==null)for(t=wt.return;t!==null;){var r=t;switch(tw(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Fp();break;case 3:qa(),tt($n),tt(rn),uw();break;case 5:cw(r);break;case 4:qa();break;case 13:tt(st);break;case 19:tt(st);break;case 10:sw(r.type._context);break;case 22:case 23:xw()}t=t.return}if(kt=e,wt=e=Ts(e.current,null),Ht=Kn=n,Ct=0,tu=null,Sw=Ff=Ci=0,Cn=Sc=null,di!==null){for(n=0;n<di.length;n++)if(t=di[n],r=t.interleaved,r!==null){t.interleaved=null;var o=r.next,s=t.pending;if(s!==null){var i=s.next;s.next=o,r.next=i}t.pending=r}di=null}return e}function x$(e,n){do{var t=wt;try{if(ow(),Uh.current=Yp,Gp){for(var r=lt.memoizedState;r!==null;){var o=r.queue;o!==null&&(o.pending=null),r=r.next}Gp=!1}if(Pi=0,_t=bt=lt=null,mc=!1,Qc=0,yw.current=null,t===null||t.return===null){Ct=1,tu=n,wt=null;break}e:{var s=e,i=t.return,a=t,l=n;if(n=Ht,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,u=a,d=u.tag;if(!(u.mode&1)&&(d===0||d===11||d===15)){var h=u.alternate;h?(u.updateQueue=h.updateQueue,u.memoizedState=h.memoizedState,u.lanes=h.lanes):(u.updateQueue=null,u.memoizedState=null)}var f=sC(i);if(f!==null){f.flags&=-257,iC(f,i,a,s,n),f.mode&1&&oC(s,c,n),n=f,l=c;var y=n.updateQueue;if(y===null){var g=new Set;g.add(l),n.updateQueue=g}else y.add(l);break e}else{if(!(n&1)){oC(s,c,n),bw();break e}l=Error(q(426))}}else if(nt&&a.mode&1){var v=sC(i);if(v!==null){!(v.flags&65536)&&(v.flags|=256),iC(v,i,a,s,n),nw(Za(l,a));break e}}s=l=Za(l,a),Ct!==4&&(Ct=2),Sc===null?Sc=[s]:Sc.push(s),s=i;do{switch(s.tag){case 3:s.flags|=65536,n&=-n,s.lanes|=n;var S=o$(s,l,n);ZP(s,S);break e;case 1:a=l;var w=s.type,C=s.stateNode;if(!(s.flags&128)&&(typeof w.getDerivedStateFromError=="function"||C!==null&&typeof C.componentDidCatch=="function"&&(_s===null||!_s.has(C)))){s.flags|=65536,n&=-n,s.lanes|=n;var I=s$(s,a,n);ZP(s,I);break e}}s=s.return}while(s!==null)}C$(t)}catch(P){n=P,wt===t&&t!==null&&(wt=t=t.return);continue}break}while(!0)}function b$(){var e=Xp.current;return Xp.current=Yp,e===null?Yp:e}function bw(){(Ct===0||Ct===3||Ct===2)&&(Ct=4),kt===null||!(Ci&268435455)&&!(Ff&268435455)||fs(kt,Ht)}function Qp(e,n){var t=Ce;Ce|=2;var r=b$();(kt!==e||Ht!==n)&&(Eo=null,gi(e,n));do try{rG();break}catch(o){x$(e,o)}while(!0);if(ow(),Ce=t,Xp.current=r,wt!==null)throw Error(q(261));return kt=null,Ht=0,Ct}function rG(){for(;wt!==null;)P$(wt)}function oG(){for(;wt!==null&&!TV();)P$(wt)}function P$(e){var n=E$(e.alternate,e,Kn);e.memoizedProps=e.pendingProps,n===null?C$(e):wt=n,yw.current=null}function C$(e){var n=e;do{var t=n.alternate;if(e=n.return,n.flags&32768){if(t=ZW(t,n),t!==null){t.flags&=32767,wt=t;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Ct=6,wt=null;return}}else if(t=qW(t,n,Kn),t!==null){wt=t;return}if(n=n.sibling,n!==null){wt=n;return}wt=n=e}while(n!==null);Ct===0&&(Ct=5)}function si(e,n,t){var r=Re,o=gr.transition;try{gr.transition=null,Re=1,sG(e,n,t,r)}finally{gr.transition=o,Re=r}return null}function sG(e,n,t,r){do Fa();while(vs!==null);if(Ce&6)throw Error(q(327));t=e.finishedWork;var o=e.finishedLanes;if(t===null)return null;if(e.finishedWork=null,e.finishedLanes=0,t===e.current)throw Error(q(177));e.callbackNode=null,e.callbackPriority=0;var s=t.lanes|t.childLanes;if(FV(e,s),e===kt&&(wt=kt=null,Ht=0),!(t.subtreeFlags&2064)&&!(t.flags&2064)||Fd||(Fd=!0,_$(jp,function(){return Fa(),null})),s=(t.flags&15990)!==0,t.subtreeFlags&15990||s){s=gr.transition,gr.transition=null;var i=Re;Re=1;var a=Ce;Ce|=4,yw.current=null,JW(e,t),S$(t,e),IW(DS),Dp=!!OS,DS=OS=null,e.current=t,eG(t),$V(),Ce=a,Re=i,gr.transition=s}else e.current=t;if(Fd&&(Fd=!1,vs=e,Zp=o),s=e.pendingLanes,s===0&&(_s=null),jV(t.stateNode),An(e,gt()),n!==null)for(r=e.onRecoverableError,t=0;t<n.length;t++)o=n[t],r(o.value,{componentStack:o.stack,digest:o.digest});if(qp)throw qp=!1,e=tv,tv=null,e;return Zp&1&&e.tag!==0&&Fa(),s=e.pendingLanes,s&1?e===nv?vc++:(vc=0,nv=e):vc=0,Vs(),null}function Fa(){if(vs!==null){var e=rT(Zp),n=gr.transition,t=Re;try{if(gr.transition=null,Re=16>e?16:e,vs===null)var r=!1;else{if(e=vs,vs=null,Zp=0,Ce&6)throw Error(q(331));var o=Ce;for(Ce|=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:yc(8,u,s)}var d=u.child;if(d!==null)d.return=u,te=d;else for(;te!==null;){u=te;var h=u.sibling,f=u.return;if(g$(u),u===c){te=null;break}if(h!==null){h.return=f,te=h;break}te=f}}}var y=s.alternate;if(y!==null){var g=y.child;if(g!==null){y.child=null;do{var v=g.sibling;g.sibling=null,g=v}while(g!==null)}}te=s}}if(s.subtreeFlags&2064&&i!==null)i.return=s,te=i;else e:for(;te!==null;){if(s=te,s.flags&2048)switch(s.tag){case 0:case 11:case 15:yc(9,s,s.return)}var S=s.sibling;if(S!==null){S.return=s.return,te=S;break e}te=s.return}}var w=e.current;for(te=w;te!==null;){i=te;var C=i.child;if(i.subtreeFlags&2064&&C!==null)C.return=i,te=C;else e:for(i=w;te!==null;){if(a=te,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:Nf(9,a)}}catch(P){dt(a,a.return,P)}if(a===i){te=null;break e}var I=a.sibling;if(I!==null){I.return=a.return,te=I;break e}te=a.return}}if(Ce=o,Vs(),io&&typeof io.onPostCommitFiberRoot=="function")try{io.onPostCommitFiberRoot($f,e)}catch{}r=!0}return r}finally{Re=t,gr.transition=n}}return!1}function vC(e,n,t){n=Za(t,n),n=o$(e,n,1),e=Es(e,n,1),n=pn(),e!==null&&(ju(e,1,n),An(e,n))}function dt(e,n,t){if(e.tag===3)vC(e,e,t);else for(;n!==null;){if(n.tag===3){vC(n,e,t);break}else if(n.tag===1){var r=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(_s===null||!_s.has(r))){e=Za(t,e),e=s$(n,e,1),n=Es(n,e,1),e=pn(),n!==null&&(ju(n,1,e),An(n,e));break}}n=n.return}}function iG(e,n,t){var r=e.pingCache;r!==null&&r.delete(n),n=pn(),e.pingedLanes|=e.suspendedLanes&t,kt===e&&(Ht&t)===t&&(Ct===4||Ct===3&&(Ht&130023424)===Ht&&500>gt()-vw?gi(e,0):Sw|=t),An(e,n)}function I$(e,n){n===0&&(e.mode&1?(n=Td,Td<<=1,!(Td&130023424)&&(Td=4194304)):n=1);var t=pn();e=Ho(e,n),e!==null&&(ju(e,n,t),An(e,t))}function aG(e){var n=e.memoizedState,t=0;n!==null&&(t=n.retryLane),I$(e,t)}function lG(e,n){var t=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(t=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(q(314))}r!==null&&r.delete(n),I$(e,t)}var E$;E$=function(e,n,t){if(e!==null)if(e.memoizedProps!==n.pendingProps||$n.current)_n=!0;else{if(!(e.lanes&t)&&!(n.flags&128))return _n=!1,XW(e,n,t);_n=!!(e.flags&131072)}else _n=!1,nt&&n.flags&1048576&&TT(n,Up,n.index);switch(n.lanes=0,n.tag){case 2:var r=n.type;Kh(e,n),e=n.pendingProps;var o=Ga(n,rn.current);Na(n,t),o=hw(null,n,r,e,o,t);var s=pw();return n.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Mn(r)?(s=!0,zp(n)):s=!1,n.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,aw(n),o.updater=Rf,n.stateNode=o,o._reactInternals=n,KS(n,r,e,t),n=GS(null,n,r,!0,s,t)):(n.tag=0,nt&&s&&ew(n),cn(null,n,o,t),n=n.child),n;case 16:r=n.elementType;e:{switch(Kh(e,n),e=n.pendingProps,o=r._init,r=o(r._payload),n.type=r,o=n.tag=uG(r),e=Ir(r,e),o){case 0:n=WS(null,n,r,e,t);break e;case 1:n=cC(null,n,r,e,t);break e;case 11:n=aC(null,n,r,e,t);break e;case 14:n=lC(null,n,r,Ir(r.type,e),t);break e}throw Error(q(306,r,""))}return n;case 0:return r=n.type,o=n.pendingProps,o=n.elementType===r?o:Ir(r,o),WS(e,n,r,o,t);case 1:return r=n.type,o=n.pendingProps,o=n.elementType===r?o:Ir(r,o),cC(e,n,r,o,t);case 3:e:{if(c$(n),e===null)throw Error(q(387));r=n.pendingProps,s=n.memoizedState,o=s.element,jT(e,n),Vp(n,r,null,t);var i=n.memoizedState;if(r=i.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},n.updateQueue.baseState=s,n.memoizedState=s,n.flags&256){o=Za(Error(q(423)),n),n=uC(e,n,r,t,o);break e}else if(r!==o){o=Za(Error(q(424)),n),n=uC(e,n,r,t,o);break e}else for(Yn=Is(n.stateNode.containerInfo.firstChild),qn=n,nt=!0,Mr=null,t=LT(n,null,r,t),n.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(Ya(),r===o){n=Ko(e,n,t);break e}cn(e,n,r,t)}n=n.child}return n;case 5:return NT(n),e===null&&BS(n),r=n.type,o=n.pendingProps,s=e!==null?e.memoizedProps:null,i=o.children,RS(r,o)?i=null:s!==null&&RS(r,s)&&(n.flags|=32),l$(e,n),cn(e,n,i,t),n.child;case 6:return e===null&&BS(n),null;case 13:return u$(e,n,t);case 4:return lw(n,n.stateNode.containerInfo),r=n.pendingProps,e===null?n.child=Xa(n,null,r,t):cn(e,n,r,t),n.child;case 11:return r=n.type,o=n.pendingProps,o=n.elementType===r?o:Ir(r,o),aC(e,n,r,o,t);case 7:return cn(e,n,n.pendingProps,t),n.child;case 8:return cn(e,n,n.pendingProps.children,t),n.child;case 12:return cn(e,n,n.pendingProps.children,t),n.child;case 10:e:{if(r=n.type._context,o=n.pendingProps,s=n.memoizedProps,i=o.value,Ve(Hp,r._currentValue),r._currentValue=i,s!==null)if(Hr(s.value,i)){if(s.children===o.children&&!$n.current){n=Ko(e,n,t);break e}}else for(s=n.child,s!==null&&(s.return=n);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=No(-1,t&-t),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|=t,l=s.alternate,l!==null&&(l.lanes|=t),US(s.return,t,n),a.lanes|=t;break}l=l.next}}else if(s.tag===10)i=s.type===n.type?null:s.child;else if(s.tag===18){if(i=s.return,i===null)throw Error(q(341));i.lanes|=t,a=i.alternate,a!==null&&(a.lanes|=t),US(i,t,n),i=s.sibling}else i=s.child;if(i!==null)i.return=s;else for(i=s;i!==null;){if(i===n){i=null;break}if(s=i.sibling,s!==null){s.return=i.return,i=s;break}i=i.return}s=i}cn(e,n,o.children,t),n=n.child}return n;case 9:return o=n.type,r=n.pendingProps.children,Na(n,t),o=yr(o),r=r(o),n.flags|=1,cn(e,n,r,t),n.child;case 14:return r=n.type,o=Ir(r,n.pendingProps),o=Ir(r.type,o),lC(e,n,r,o,t);case 15:return i$(e,n,n.type,n.pendingProps,t);case 17:return r=n.type,o=n.pendingProps,o=n.elementType===r?o:Ir(r,o),Kh(e,n),n.tag=1,Mn(r)?(e=!0,zp(n)):e=!1,Na(n,t),DT(n,r,o),KS(n,r,o,t),GS(null,n,r,!0,e,t);case 19:return d$(e,n,t);case 22:return a$(e,n,t)}throw Error(q(156,n.tag))};function _$(e,n){return J2(e,n)}function cG(e,n,t,r){this.tag=e,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,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 dr(e,n,t,r){return new cG(e,n,t,r)}function Pw(e){return e=e.prototype,!(!e||!e.isReactComponent)}function uG(e){if(typeof e=="function")return Pw(e)?1:0;if(e!=null){if(e=e.$$typeof,e===U0)return 11;if(e===H0)return 14}return 2}function Ts(e,n){var t=e.alternate;return t===null?(t=dr(e.tag,n,e.key,e.mode),t.elementType=e.elementType,t.type=e.type,t.stateNode=e.stateNode,t.alternate=e,e.alternate=t):(t.pendingProps=n,t.type=e.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=e.flags&14680064,t.childLanes=e.childLanes,t.lanes=e.lanes,t.child=e.child,t.memoizedProps=e.memoizedProps,t.memoizedState=e.memoizedState,t.updateQueue=e.updateQueue,n=e.dependencies,t.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},t.sibling=e.sibling,t.index=e.index,t.ref=e.ref,t}function Gh(e,n,t,r,o,s){var i=2;if(r=e,typeof e=="function")Pw(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Sa:return mi(t.children,o,s,n);case B0:i=8,o|=8;break;case fS:return e=dr(12,t,n,o|2),e.elementType=fS,e.lanes=s,e;case gS:return e=dr(13,t,n,o),e.elementType=gS,e.lanes=s,e;case mS:return e=dr(19,t,n,o),e.elementType=mS,e.lanes=s,e;case R2:return zf(t,o,s,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case O2:i=10;break e;case D2:i=9;break e;case U0:i=11;break e;case H0:i=14;break e;case ls:i=16,r=null;break e}throw Error(q(130,e==null?e:typeof e,""))}return n=dr(i,t,n,o),n.elementType=e,n.type=r,n.lanes=s,n}function mi(e,n,t,r){return e=dr(7,e,r,n),e.lanes=t,e}function zf(e,n,t,r){return e=dr(22,e,r,n),e.elementType=R2,e.lanes=t,e.stateNode={isHidden:!1},e}function Km(e,n,t){return e=dr(6,e,null,n),e.lanes=t,e}function Vm(e,n,t){return n=dr(4,e.children!==null?e.children:[],e.key,n),n.lanes=t,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function dG(e,n,t,r,o){this.tag=n,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=Im(0),this.expirationTimes=Im(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Im(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function Cw(e,n,t,r,o,s,i,a,l){return e=new dG(e,n,t,a,l),n===1?(n=1,s===!0&&(n|=8)):n=0,s=dr(3,null,null,n),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},aw(s),e}function hG(e,n,t){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ya,key:r==null?null:""+r,children:e,containerInfo:n,implementation:t}}function k$(e){if(!e)return Ds;e=e._reactInternals;e:{if(Fi(e)!==e||e.tag!==1)throw Error(q(170));var n=e;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(Mn(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(q(171))}if(e.tag===1){var t=e.type;if(Mn(t))return _T(e,t,n)}return n}function T$(e,n,t,r,o,s,i,a,l){return e=Cw(t,r,!0,e,o,s,i,a,l),e.context=k$(null),t=e.current,r=pn(),o=ks(t),s=No(r,o),s.callback=n??null,Es(t,s,o),e.current.lanes=o,ju(e,o,r),An(e,r),e}function Bf(e,n,t,r){var o=n.current,s=pn(),i=ks(o);return t=k$(t),n.context===null?n.context=t:n.pendingContext=t,n=No(s,i),n.payload={element:e},r=r===void 0?null:r,r!==null&&(n.callback=r),e=Es(o,n,i),e!==null&&(Fr(e,o,i,s),Bh(e,o,i)),i}function Jp(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 wC(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var t=e.retryLane;e.retryLane=t!==0&&t<n?t:n}}function Iw(e,n){wC(e,n),(e=e.alternate)&&wC(e,n)}function pG(){return null}var $$=typeof reportError=="function"?reportError:function(e){console.error(e)};function Ew(e){this._internalRoot=e}Uf.prototype.render=Ew.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(q(409));Bf(e,n,null,null)};Uf.prototype.unmount=Ew.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;Ii(function(){Bf(null,e,null,null)}),n[Uo]=null}};function Uf(e){this._internalRoot=e}Uf.prototype.unstable_scheduleHydration=function(e){if(e){var n=iT();e={blockedOn:null,target:e,priority:n};for(var t=0;t<ps.length&&n!==0&&n<ps[t].priority;t++);ps.splice(t,0,e),t===0&&lT(e)}};function _w(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Hf(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function xC(){}function fG(e,n,t,r,o){if(o){if(typeof r=="function"){var s=r;r=function(){var c=Jp(i);s.call(c)}}var i=T$(n,r,e,0,null,!1,!1,"",xC);return e._reactRootContainer=i,e[Uo]=i.current,Gc(e.nodeType===8?e.parentNode:e),Ii(),i}for(;o=e.lastChild;)e.removeChild(o);if(typeof r=="function"){var a=r;r=function(){var c=Jp(l);a.call(c)}}var l=Cw(e,0,!1,null,null,!1,!1,"",xC);return e._reactRootContainer=l,e[Uo]=l.current,Gc(e.nodeType===8?e.parentNode:e),Ii(function(){Bf(n,l,t,r)}),l}function Kf(e,n,t,r,o){var s=t._reactRootContainer;if(s){var i=s;if(typeof o=="function"){var a=o;o=function(){var l=Jp(i);a.call(l)}}Bf(n,i,e,o)}else i=fG(t,n,e,o,r);return Jp(i)}oT=function(e){switch(e.tag){case 3:var n=e.stateNode;if(n.current.memoizedState.isDehydrated){var t=tc(n.pendingLanes);t!==0&&(W0(n,t|1),An(n,gt()),!(Ce&6)&&(Qa=gt()+500,Vs()))}break;case 13:Ii(function(){var r=Ho(e,1);if(r!==null){var o=pn();Fr(r,e,1,o)}}),Iw(e,1)}};G0=function(e){if(e.tag===13){var n=Ho(e,134217728);if(n!==null){var t=pn();Fr(n,e,134217728,t)}Iw(e,134217728)}};sT=function(e){if(e.tag===13){var n=ks(e),t=Ho(e,n);if(t!==null){var r=pn();Fr(t,e,n,r)}Iw(e,n)}};iT=function(){return Re};aT=function(e,n){var t=Re;try{return Re=e,n()}finally{Re=t}};ES=function(e,n,t){switch(n){case"input":if(vS(e,t),n=t.name,t.type==="radio"&&n!=null){for(t=e;t.parentNode;)t=t.parentNode;for(t=t.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),n=0;n<t.length;n++){var r=t[n];if(r!==e&&r.form===e.form){var o=Of(r);if(!o)throw Error(q(90));N2(r),vS(r,o)}}}break;case"textarea":z2(e,t);break;case"select":n=t.value,n!=null&&Oa(e,!!t.multiple,n,!1)}};G2=ww;Y2=Ii;var gG={usingClientEntryPoint:!1,Events:[Du,ba,Of,V2,W2,ww]},Hl={findFiberByHostInstance:ui,bundleType:0,version:"18.2.0",rendererPackageName:"react-dom"},mG={bundleType:Hl.bundleType,version:Hl.version,rendererPackageName:Hl.rendererPackageName,rendererConfig:Hl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Qo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Z2(e),e===null?null:e.stateNode},findFiberByHostInstance:Hl.findFiberByHostInstance||pG,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.2.0-next-9e3b772b8-20220608"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zd.isDisabled&&zd.supportsFiber)try{$f=zd.inject(mG),io=zd}catch{}}tr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=gG;tr.createPortal=function(e,n){var t=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!_w(n))throw Error(q(200));return hG(e,n,null,t)};tr.createRoot=function(e,n){if(!_w(e))throw Error(q(299));var t=!1,r="",o=$$;return n!=null&&(n.unstable_strictMode===!0&&(t=!0),n.identifierPrefix!==void 0&&(r=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),n=Cw(e,1,!1,null,null,t,!1,r,o),e[Uo]=n.current,Gc(e.nodeType===8?e.parentNode:e),new Ew(n)};tr.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(q(188)):(e=Object.keys(e).join(","),Error(q(268,e)));return e=Z2(n),e=e===null?null:e.stateNode,e};tr.flushSync=function(e){return Ii(e)};tr.hydrate=function(e,n,t){if(!Hf(n))throw Error(q(200));return Kf(null,e,n,!0,t)};tr.hydrateRoot=function(e,n,t){if(!_w(e))throw Error(q(405));var r=t!=null&&t.hydratedSources||null,o=!1,s="",i=$$;if(t!=null&&(t.unstable_strictMode===!0&&(o=!0),t.identifierPrefix!==void 0&&(s=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),n=T$(n,null,e,1,t??null,o,!1,s,i),e[Uo]=n.current,Gc(e),r)for(e=0;e<r.length;e++)t=r[e],o=t._getVersion,o=o(t._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[t,o]:n.mutableSourceEagerHydrationData.push(t,o);return new Uf(n)};tr.render=function(e,n,t){if(!Hf(n))throw Error(q(200));return Kf(null,e,n,!1,t)};tr.unmountComponentAtNode=function(e){if(!Hf(e))throw Error(q(40));return e._reactRootContainer?(Ii(function(){Kf(null,null,e,!1,function(){e._reactRootContainer=null,e[Uo]=null})}),!0):!1};tr.unstable_batchedUpdates=ww;tr.unstable_renderSubtreeIntoContainer=function(e,n,t,r){if(!Hf(t))throw Error(q(200));if(e==null||e._reactInternals===void 0)throw Error(q(38));return Kf(e,n,t,!1,r)};tr.version="18.2.0-next-9e3b772b8-20220608";function M$(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(M$)}catch(e){console.error(e)}}M$(),T2.exports=tr;var gl=T2.exports;const yG=el(gl);function se(e,n,{checkForDefaultPrevented:t=!0}={}){return function(o){if(e==null||e(o),t===!1||!o.defaultPrevented)return n==null?void 0:n(o)}}function SG(e,n){typeof e=="function"?e(n):e!=null&&(e.current=n)}function Vf(...e){return n=>e.forEach(t=>SG(t,n))}function Ye(...e){return x.useCallback(Vf(...e),e)}function go(e,n=[]){let t=[];function r(s,i){const a=x.createContext(i),l=t.length;t=[...t,i];function c(d){const{scope:h,children:f,...y}=d,g=(h==null?void 0:h[e][l])||a,v=x.useMemo(()=>y,Object.values(y));return x.createElement(g.Provider,{value:v},f)}function u(d,h){const f=(h==null?void 0:h[e][l])||a,y=x.useContext(f);if(y)return y;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,u]}const o=()=>{const s=t.map(i=>x.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return x.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,vG(o,...n)]}function vG(...e){const n=e[0];if(e.length===1)return n;const t=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return x.useMemo(()=>({[`__scope${n.scopeName}`]:i}),[i])}};return t.scopeName=n.scopeName,t}const Ei=x.forwardRef((e,n)=>{const{children:t,...r}=e,o=x.Children.toArray(t),s=o.find(xG);if(s){const i=s.props.children,a=o.map(l=>l===s?x.Children.count(i)>1?x.Children.only(null):x.isValidElement(i)?i.props.children:null:l);return x.createElement(sv,Q({},r,{ref:n}),x.isValidElement(i)?x.cloneElement(i,void 0,a):null)}return x.createElement(sv,Q({},r,{ref:n}),t)});Ei.displayName="Slot";const sv=x.forwardRef((e,n)=>{const{children:t,...r}=e;return x.isValidElement(t)?x.cloneElement(t,{...bG(r,t.props),ref:n?Vf(n,t.ref):t.ref}):x.Children.count(t)>1?x.Children.only(null):null});sv.displayName="SlotClone";const wG=({children:e})=>x.createElement(x.Fragment,null,e);function xG(e){return x.isValidElement(e)&&e.type===wG}function bG(e,n){const t={...n};for(const r in n){const o=e[r],s=n[r];/^on[A-Z]/.test(r)?o&&s?t[r]=(...a)=>{s(...a),o(...a)}:o&&(t[r]=o):r==="style"?t[r]={...o,...s}:r==="className"&&(t[r]=[o,s].filter(Boolean).join(" "))}return{...e,...t}}function Wf(e){const n=e+"CollectionProvider",[t,r]=go(n),[o,s]=t(n,{collectionRef:{current:null},itemMap:new Map}),i=f=>{const{scope:y,children:g}=f,v=ie.useRef(null),S=ie.useRef(new Map).current;return ie.createElement(o,{scope:y,itemMap:S,collectionRef:v},g)},a=e+"CollectionSlot",l=ie.forwardRef((f,y)=>{const{scope:g,children:v}=f,S=s(a,g),w=Ye(y,S.collectionRef);return ie.createElement(Ei,{ref:w},v)}),c=e+"CollectionItemSlot",u="data-radix-collection-item",d=ie.forwardRef((f,y)=>{const{scope:g,children:v,...S}=f,w=ie.useRef(null),C=Ye(y,w),I=s(c,g);return ie.useEffect(()=>(I.itemMap.set(w,{ref:w,...S}),()=>void I.itemMap.delete(w))),ie.createElement(Ei,{[u]:"",ref:C},v)});function h(f){const y=s(e+"CollectionConsumer",f);return ie.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const S=Array.from(v.querySelectorAll(`[${u}]`));return Array.from(y.itemMap.values()).sort((I,P)=>S.indexOf(I.ref.current)-S.indexOf(P.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:l,ItemSlot:d},h,r]}const PG=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Be=PG.reduce((e,n)=>{const t=x.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Ei:n;return x.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),x.createElement(a,Q({},i,{ref:o}))});return t.displayName=`Primitive.${n}`,{...e,[n]:t}},{});function kw(e,n){e&&gl.flushSync(()=>e.dispatchEvent(n))}function on(e){const n=x.useRef(e);return x.useEffect(()=>{n.current=e}),x.useMemo(()=>(...t)=>{var r;return(r=n.current)===null||r===void 0?void 0:r.call(n,...t)},[])}function CG(e,n=globalThis==null?void 0:globalThis.document){const t=on(e);x.useEffect(()=>{const r=o=>{o.key==="Escape"&&t(o)};return n.addEventListener("keydown",r),()=>n.removeEventListener("keydown",r)},[t,n])}const iv="dismissableLayer.update",IG="dismissableLayer.pointerDownOutside",EG="dismissableLayer.focusOutside";let bC;const A$=x.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Gf=x.forwardRef((e,n)=>{var t;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...c}=e,u=x.useContext(A$),[d,h]=x.useState(null),f=(t=d==null?void 0:d.ownerDocument)!==null&&t!==void 0?t:globalThis==null?void 0:globalThis.document,[,y]=x.useState({}),g=Ye(n,k=>h(k)),v=Array.from(u.layers),[S]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),w=v.indexOf(S),C=d?v.indexOf(d):-1,I=u.layersWithOutsidePointerEventsDisabled.size>0,P=C>=w,E=kG(k=>{const M=k.target,T=[...u.branches].some(R=>R.contains(M));!P||T||(s==null||s(k),a==null||a(k),k.defaultPrevented||l==null||l())},f),_=TG(k=>{const M=k.target;[...u.branches].some(R=>R.contains(M))||(i==null||i(k),a==null||a(k),k.defaultPrevented||l==null||l())},f);return CG(k=>{C===u.layers.size-1&&(o==null||o(k),!k.defaultPrevented&&l&&(k.preventDefault(),l()))},f),x.useEffect(()=>{if(d)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(bC=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),PC(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=bC)}},[d,f,r,u]),x.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),PC())},[d,u]),x.useEffect(()=>{const k=()=>y({});return document.addEventListener(iv,k),()=>document.removeEventListener(iv,k)},[]),x.createElement(Be.div,Q({},c,{ref:g,style:{pointerEvents:I?P?"auto":"none":void 0,...e.style},onFocusCapture:se(e.onFocusCapture,_.onFocusCapture),onBlurCapture:se(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:se(e.onPointerDownCapture,E.onPointerDownCapture)}))}),_G=x.forwardRef((e,n)=>{const t=x.useContext(A$),r=x.useRef(null),o=Ye(n,r);return x.useEffect(()=>{const s=r.current;if(s)return t.branches.add(s),()=>{t.branches.delete(s)}},[t.branches]),x.createElement(Be.div,Q({},e,{ref:o}))});function kG(e,n=globalThis==null?void 0:globalThis.document){const t=on(e),r=x.useRef(!1),o=x.useRef(()=>{});return x.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let u=function(){j$(IG,t,c,{discrete:!0})};var l=u;const c={originalEvent:a};a.pointerType==="touch"?(n.removeEventListener("click",o.current),o.current=u,n.addEventListener("click",o.current,{once:!0})):u()}else n.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{n.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),n.removeEventListener("pointerdown",s),n.removeEventListener("click",o.current)}},[n,t]),{onPointerDownCapture:()=>r.current=!0}}function TG(e,n=globalThis==null?void 0:globalThis.document){const t=on(e),r=x.useRef(!1);return x.useEffect(()=>{const o=s=>{s.target&&!r.current&&j$(EG,t,{originalEvent:s},{discrete:!1})};return n.addEventListener("focusin",o),()=>n.removeEventListener("focusin",o)},[n,t]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function PC(){const e=new CustomEvent(iv);document.dispatchEvent(e)}function j$(e,n,t,{discrete:r}){const o=t.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:t});n&&o.addEventListener(e,n,{once:!0}),r?kw(o,s):o.dispatchEvent(s)}const $G=Gf,MG=_G,Yf=x.forwardRef((e,n)=>{var t;const{container:r=globalThis==null||(t=globalThis.document)===null||t===void 0?void 0:t.body,...o}=e;return r?yG.createPortal(x.createElement(Be.div,Q({},o,{ref:n})),r):null}),_i=globalThis!=null&&globalThis.document?x.useLayoutEffect:()=>{};function AG(e,n){return x.useReducer((t,r)=>{const o=n[t][r];return o??t},e)}const mo=e=>{const{present:n,children:t}=e,r=jG(n),o=typeof t=="function"?t({present:r.isPresent}):x.Children.only(t),s=Ye(r.ref,o.ref);return typeof t=="function"||r.isPresent?x.cloneElement(o,{ref:s}):null};mo.displayName="Presence";function jG(e){const[n,t]=x.useState(),r=x.useRef({}),o=x.useRef(e),s=x.useRef("none"),i=e?"mounted":"unmounted",[a,l]=AG(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const c=Bd(r.current);s.current=a==="mounted"?c:"none"},[a]),_i(()=>{const c=r.current,u=o.current;if(u!==e){const h=s.current,f=Bd(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&h!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),_i(()=>{if(n){const c=d=>{const f=Bd(r.current).includes(d.animationName);d.target===n&&f&&gl.flushSync(()=>l("ANIMATION_END"))},u=d=>{d.target===n&&(s.current=Bd(r.current))};return n.addEventListener("animationstart",u),n.addEventListener("animationcancel",c),n.addEventListener("animationend",c),()=>{n.removeEventListener("animationstart",u),n.removeEventListener("animationcancel",c),n.removeEventListener("animationend",c)}}else l("ANIMATION_END")},[n,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:x.useCallback(c=>{c&&(r.current=getComputedStyle(c)),t(c)},[])}}function Bd(e){return(e==null?void 0:e.animationName)||"none"}function Ws({prop:e,defaultProp:n,onChange:t=()=>{}}){const[r,o]=OG({defaultProp:n,onChange:t}),s=e!==void 0,i=s?e:r,a=on(t),l=x.useCallback(c=>{if(s){const d=typeof c=="function"?c(e):c;d!==e&&a(d)}else o(c)},[s,e,o,a]);return[i,l]}function OG({defaultProp:e,onChange:n}){const t=x.useState(e),[r]=t,o=x.useRef(r),s=on(n);return x.useEffect(()=>{o.current!==r&&(s(r),o.current=r)},[r,o,s]),t}const O$=x.forwardRef((e,n)=>x.createElement(Be.span,Q({},e,{ref:n,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}}))),D$="ToastProvider",[Tw,DG,RG]=Wf("Toast"),[R$,Tne]=go("Toast",[RG]),[LG,Xf]=R$(D$),L$=e=>{const{__scopeToast:n,label:t="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=x.useState(null),[c,u]=x.useState(0),d=x.useRef(!1),h=x.useRef(!1);return x.createElement(Tw.Provider,{scope:n},x.createElement(LG,{scope:n,label:t,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:x.useCallback(()=>u(f=>f+1),[]),onToastRemove:x.useCallback(()=>u(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:d,isClosePausedRef:h},i))};L$.propTypes={label(e){if(e.label&&typeof e.label=="string"&&!e.label.trim()){const n=`Invalid prop \`label\` supplied to \`${D$}\`. Expected non-empty \`string\`.`;return new Error(n)}return null}};const NG="ToastViewport",FG=["F8"],av="toast.viewportPause",lv="toast.viewportResume",zG=x.forwardRef((e,n)=>{const{__scopeToast:t,hotkey:r=FG,label:o="Notifications ({hotkey})",...s}=e,i=Xf(NG,t),a=DG(t),l=x.useRef(null),c=x.useRef(null),u=x.useRef(null),d=x.useRef(null),h=Ye(n,d,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),y=i.toastCount>0;x.useEffect(()=>{const v=S=>{var w;r.every(I=>S[I]||S.code===I)&&((w=d.current)===null||w===void 0||w.focus())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[r]),x.useEffect(()=>{const v=l.current,S=d.current;if(y&&v&&S){const w=()=>{if(!i.isClosePausedRef.current){const E=new CustomEvent(av);S.dispatchEvent(E),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const E=new CustomEvent(lv);S.dispatchEvent(E),i.isClosePausedRef.current=!1}},I=E=>{!v.contains(E.relatedTarget)&&C()},P=()=>{v.contains(document.activeElement)||C()};return v.addEventListener("focusin",w),v.addEventListener("focusout",I),v.addEventListener("pointermove",w),v.addEventListener("pointerleave",P),window.addEventListener("blur",w),window.addEventListener("focus",C),()=>{v.removeEventListener("focusin",w),v.removeEventListener("focusout",I),v.removeEventListener("pointermove",w),v.removeEventListener("pointerleave",P),window.removeEventListener("blur",w),window.removeEventListener("focus",C)}}},[y,i.isClosePausedRef]);const g=x.useCallback(({tabbingDirection:v})=>{const w=a().map(C=>{const I=C.ref.current,P=[I,...nY(I)];return v==="forwards"?P:P.reverse()});return(v==="forwards"?w.reverse():w).flat()},[a]);return x.useEffect(()=>{const v=d.current;if(v){const S=w=>{const C=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!C){const k=document.activeElement,M=w.shiftKey;if(w.target===v&&M){var P;(P=c.current)===null||P===void 0||P.focus();return}const O=g({tabbingDirection:M?"backwards":"forwards"}),U=O.findIndex(N=>N===k);if(Wm(O.slice(U+1)))w.preventDefault();else{var E,_;M?(E=c.current)===null||E===void 0||E.focus():(_=u.current)===null||_===void 0||_.focus()}}};return v.addEventListener("keydown",S),()=>v.removeEventListener("keydown",S)}},[a,g]),x.createElement(MG,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:y?void 0:"none"}},y&&x.createElement(CC,{ref:c,onFocusFromOutsideViewport:()=>{const v=g({tabbingDirection:"forwards"});Wm(v)}}),x.createElement(Tw.Slot,{scope:t},x.createElement(Be.ol,Q({tabIndex:-1},s,{ref:h}))),y&&x.createElement(CC,{ref:u,onFocusFromOutsideViewport:()=>{const v=g({tabbingDirection:"backwards"});Wm(v)}}))}),BG="ToastFocusProxy",CC=x.forwardRef((e,n)=>{const{__scopeToast:t,onFocusFromOutsideViewport:r,...o}=e,s=Xf(BG,t);return x.createElement(O$,Q({"aria-hidden":!0,tabIndex:0},o,{ref:n,style:{position:"fixed"},onFocus:i=>{var a;const l=i.relatedTarget;!((a=s.viewport)!==null&&a!==void 0&&a.contains(l))&&r()}}))}),qf="Toast",UG="toast.swipeStart",HG="toast.swipeMove",KG="toast.swipeCancel",VG="toast.swipeEnd",WG=x.forwardRef((e,n)=>{const{forceMount:t,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a=!0,l]=Ws({prop:r,defaultProp:o,onChange:s});return x.createElement(mo,{present:t||a},x.createElement(N$,Q({open:a},i,{ref:n,onClose:()=>l(!1),onPause:on(e.onPause),onResume:on(e.onResume),onSwipeStart:se(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:se(e.onSwipeMove,c=>{const{x:u,y:d}=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",`${d}px`)}),onSwipeCancel:se(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:se(e.onSwipeEnd,c=>{const{x:u,y:d}=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",`${d}px`),l(!1)})})))}),[GG,YG]=R$(qf,{onClose(){}}),N$=x.forwardRef((e,n)=>{const{__scopeToast:t,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:u,onSwipeMove:d,onSwipeCancel:h,onSwipeEnd:f,...y}=e,g=Xf(qf,t),[v,S]=x.useState(null),w=Ye(n,N=>S(N)),C=x.useRef(null),I=x.useRef(null),P=o||g.duration,E=x.useRef(0),_=x.useRef(P),k=x.useRef(0),{onToastAdd:M,onToastRemove:T}=g,R=on(()=>{var N;(v==null?void 0:v.contains(document.activeElement))&&((N=g.viewport)===null||N===void 0||N.focus()),i()}),O=x.useCallback(N=>{!N||N===1/0||(window.clearTimeout(k.current),E.current=new Date().getTime(),k.current=window.setTimeout(R,N))},[R]);x.useEffect(()=>{const N=g.viewport;if(N){const L=()=>{O(_.current),c==null||c()},G=()=>{const X=new Date().getTime()-E.current;_.current=_.current-X,window.clearTimeout(k.current),l==null||l()};return N.addEventListener(av,G),N.addEventListener(lv,L),()=>{N.removeEventListener(av,G),N.removeEventListener(lv,L)}}},[g.viewport,P,l,c,O]),x.useEffect(()=>{s&&!g.isClosePausedRef.current&&O(P)},[s,P,g.isClosePausedRef,O]),x.useEffect(()=>(M(),()=>T()),[M,T]);const U=x.useMemo(()=>v?U$(v):null,[v]);return g.viewport?x.createElement(x.Fragment,null,U&&x.createElement(XG,{__scopeToast:t,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0},U),x.createElement(GG,{scope:t,onClose:R},gl.createPortal(x.createElement(Tw.ItemSlot,{scope:t},x.createElement($G,{asChild:!0,onEscapeKeyDown:se(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||R(),g.isFocusedToastEscapeKeyDownRef.current=!1})},x.createElement(Be.li,Q({role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection},y,{ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:se(e.onKeyDown,N=>{N.key==="Escape"&&(a==null||a(N.nativeEvent),N.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,R()))}),onPointerDown:se(e.onPointerDown,N=>{N.button===0&&(C.current={x:N.clientX,y:N.clientY})}),onPointerMove:se(e.onPointerMove,N=>{if(!C.current)return;const L=N.clientX-C.current.x,G=N.clientY-C.current.y,X=!!I.current,H=["left","right"].includes(g.swipeDirection),B=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,W=H?B(0,L):0,Y=H?0:B(0,G),J=N.pointerType==="touch"?10:2,ke={x:W,y:Y},ve={originalEvent:N,delta:ke};X?(I.current=ke,Ud(HG,d,ve,{discrete:!1})):IC(ke,g.swipeDirection,J)?(I.current=ke,Ud(UG,u,ve,{discrete:!1}),N.target.setPointerCapture(N.pointerId)):(Math.abs(L)>J||Math.abs(G)>J)&&(C.current=null)}),onPointerUp:se(e.onPointerUp,N=>{const L=I.current,G=N.target;if(G.hasPointerCapture(N.pointerId)&&G.releasePointerCapture(N.pointerId),I.current=null,C.current=null,L){const X=N.currentTarget,H={originalEvent:N,delta:L};IC(L,g.swipeDirection,g.swipeThreshold)?Ud(VG,f,H,{discrete:!0}):Ud(KG,h,H,{discrete:!0}),X.addEventListener("click",B=>B.preventDefault(),{once:!0})}})})))),g.viewport))):null});N$.propTypes={type(e){if(e.type&&!["foreground","background"].includes(e.type)){const n=`Invalid prop \`type\` supplied to \`${qf}\`. Expected \`foreground | background\`.`;return new Error(n)}return null}};const XG=e=>{const{__scopeToast:n,children:t,...r}=e,o=Xf(qf,n),[s,i]=x.useState(!1),[a,l]=x.useState(!1);return eY(()=>i(!0)),x.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:x.createElement(Yf,{asChild:!0},x.createElement(O$,r,s&&x.createElement(x.Fragment,null,o.label," ",t)))},qG=x.forwardRef((e,n)=>{const{__scopeToast:t,...r}=e;return x.createElement(Be.div,Q({},r,{ref:n}))}),ZG=x.forwardRef((e,n)=>{const{__scopeToast:t,...r}=e;return x.createElement(Be.div,Q({},r,{ref:n}))}),QG="ToastAction",F$=x.forwardRef((e,n)=>{const{altText:t,...r}=e;return t?x.createElement(B$,{altText:t,asChild:!0},x.createElement(z$,Q({},r,{ref:n}))):null});F$.propTypes={altText(e){return e.altText?null:new Error(`Missing prop \`altText\` expected on \`${QG}\``)}};const JG="ToastClose",z$=x.forwardRef((e,n)=>{const{__scopeToast:t,...r}=e,o=YG(JG,t);return x.createElement(B$,{asChild:!0},x.createElement(Be.button,Q({type:"button"},r,{ref:n,onClick:se(e.onClick,o.onClose)})))}),B$=x.forwardRef((e,n)=>{const{__scopeToast:t,altText:r,...o}=e;return x.createElement(Be.div,Q({"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0},o,{ref:n}))});function U$(e){const n=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&n.push(r.textContent),tY(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&&n.push(i)}else n.push(...U$(r))}}),n}function Ud(e,n,t,{discrete:r}){const o=t.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:t});n&&o.addEventListener(e,n,{once:!0}),r?kw(o,s):o.dispatchEvent(s)}const IC=(e,n,t=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return n==="left"||n==="right"?s&&r>t:!s&&o>t};function eY(e=()=>{}){const n=on(e);_i(()=>{let t=0,r=0;return t=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(n)),()=>{window.cancelAnimationFrame(t),window.cancelAnimationFrame(r)}},[n])}function tY(e){return e.nodeType===e.ELEMENT_NODE}function nY(e){const n=[],t=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(;t.nextNode();)n.push(t.currentNode);return n}function Wm(e){const n=document.activeElement;return e.some(t=>t===n?!0:(t.focus(),document.activeElement!==n))}const rY=WG,oY=qG,sY=ZG,iY=F$,EC=z$,Gm=[0,390,428,468,580,640,840,1023];var ht=(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))(ht||{});const H$=ie.createContext(0);function aY({forceMobile:e=!1,children:n}){const t=F(),r=K("breakpoint",()=>{const{width:o}=t.getViewportScreenBounds(),s=e?ht.MOBILE_SM:Gm.length-1;for(let i=0;i<s;i++)if(o>Gm[i]&&o<=Gm[i+1])return i;return s},[t]);return p.jsx(H$.Provider,{value:r,children:n})}function Ln(){return x.useContext(H$)}const K$=x.createContext(null);function lY({assetUrls:e,children:n}){return p.jsx(K$.Provider,{value:e,children:n})}function $w(){const e=x.useContext(K$);if(!e)throw new Error("useAssetUrls must be used within an AssetUrlsProvider");return e}const cv={"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 all as JSON","action.export-all-as-png.short":"PNG","action.export-all-as-png":"Export all as PNG","action.export-all-as-svg.short":"SVG","action.export-all-as-svg":"Export all as SVG","action.fit-frame-to-content":"Fit to content","action.flip-horizontal":"Flip horizontally","action.flip-vertical":"Flip vertically","action.flip-horizontal.short":"Flip H","action.flip-vertical.short":"Flip V","action.fork-project":"Fork this project","action.group":"Group","action.insert-embed":"Insert embed","action.insert-media":"Upload media","action.leave-shared-project":"Leave shared project","action.new-project":"New project","action.new-shared-project":"New shared project","action.open-cursor-chat":"Cursor chat","action.open-file":"Open file","action.pack":"Pack","action.paste":"Paste","action.print":"Print","action.redo":"Redo","action.remove-frame":"Remove frame","action.rename":"Rename","action.rotate-ccw":"Rotate counterclockwise","action.rotate-cw":"Rotate clockwise","action.save-copy":"Save a copy","action.select-all":"Select all","action.select-none":"Select none","action.send-backward":"Send backward","action.send-to-back":"Send to back","action.share-project":"Share this project","action.stack-horizontal":"Stack horizontally","action.stack-vertical":"Stack vertically","action.stack-horizontal.short":"Stack H","action.stack-vertical.short":"Stack V","action.stop-following":"Stop following","action.stretch-horizontal":"Stretch horizontally","action.stretch-vertical":"Stretch vertically","action.stretch-horizontal.short":"Stretch H","action.stretch-vertical.short":"Stretch V","action.toggle-auto-size":"Toggle auto size","action.toggle-dark-mode.menu":"Dark mode","action.toggle-dark-mode":"Toggle dark mode","action.toggle-wrap-mode.menu":"Select on wrap","action.toggle-wrap-mode":"Toggle Select on wrap","action.toggle-reduce-motion.menu":"Reduce motion","action.toggle-reduce-motion":"Toggle reduce motion","action.toggle-edge-scrolling.menu":"Edge scrolling","action.toggle-edge-scrolling":"Toggle edge scrolling","action.toggle-debug-mode.menu":"Debug mode","action.toggle-debug-mode":"Toggle debug mode","action.toggle-focus-mode.menu":"Focus mode","action.toggle-focus-mode":"Toggle focus mode","action.toggle-grid.menu":"Show grid","action.toggle-grid":"Toggle grid","action.toggle-lock":"Toggle locked","action.toggle-snap-mode.menu":"Always snap","action.toggle-snap-mode":"Toggle always snap","action.toggle-tool-lock.menu":"Tool lock","action.toggle-tool-lock":"Toggle tool lock","action.toggle-transparent.context-menu":"Transparent","action.toggle-transparent.menu":"Transparent","action.toggle-transparent":"Toggle transparent background","action.undo":"Undo","action.ungroup":"Ungroup","action.zoom-in":"Zoom in","action.zoom-out":"Zoom out","action.zoom-to-100":"Zoom to 100%","action.zoom-to-fit":"Zoom to fit","action.zoom-to-selection":"Zoom to selection","assets.files.upload-failed":"Upload failed","assets.url.failed":"Couldn't load URL preview","color-style.black":"Black","color-style.blue":"Blue","color-style.green":"Green","color-style.grey":"Grey","color-style.light-blue":"Light blue","color-style.light-green":"Light green","color-style.light-red":"Light red","color-style.light-violet":"Light violet","color-style.orange":"Orange","color-style.red":"Red","color-style.violet":"Violet","color-style.yellow":"Yellow","fill-style.none":"None","document.default-name":"Untitled","fill-style.semi":"Semi","fill-style.solid":"Solid","fill-style.pattern":"Pattern","dash-style.dashed":"Dashed","dash-style.dotted":"Dotted","dash-style.draw":"Draw","dash-style.solid":"Solid","size-style.s":"Small","size-style.m":"Medium","size-style.l":"Large","size-style.xl":"Extra large","opacity-style.0.1":"10%","opacity-style.0.25":"25%","opacity-style.0.5":"50%","opacity-style.0.75":"75%","opacity-style.1":"100%","font-style.draw":"Draw","font-style.sans":"Sans","font-style.serif":"Serif","font-style.mono":"Mono","align-style.start":"Start","align-style.middle":"Middle","align-style.end":"End","align-style.justify":"Justify","verticalAlign-style.start":"Top","verticalAlign-style.middle":"Middle","verticalAlign-style.end":"Bottom","geo-style.arrow-down":"Arrow down","geo-style.arrow-left":"Arrow left","geo-style.arrow-right":"Arrow right","geo-style.arrow-up":"Arrow up","geo-style.diamond":"Diamond","geo-style.ellipse":"Ellipse","geo-style.hexagon":"Hexagon","geo-style.octagon":"Octagon","geo-style.oval":"Oval","geo-style.cloud":"Cloud","geo-style.pentagon":"Pentagon","geo-style.rectangle":"Rectangle","geo-style.rhombus-2":"Rhombus 2","geo-style.rhombus":"Rhombus","geo-style.star":"Star","geo-style.trapezoid":"Trapezoid","geo-style.triangle":"Triangle","geo-style.x-box":"X box","geo-style.check-box":"Check box","arrowheadStart-style.none":"None","arrowheadStart-style.arrow":"Arrow","arrowheadStart-style.bar":"Bar","arrowheadStart-style.diamond":"Diamond","arrowheadStart-style.dot":"Dot","arrowheadStart-style.inverted":"Inverted","arrowheadStart-style.pipe":"Pipe","arrowheadStart-style.square":"Square","arrowheadStart-style.triangle":"Triangle","arrowheadEnd-style.none":"None","arrowheadEnd-style.arrow":"Arrow","arrowheadEnd-style.bar":"Bar","arrowheadEnd-style.diamond":"Diamond","arrowheadEnd-style.dot":"Dot","arrowheadEnd-style.inverted":"Inverted","arrowheadEnd-style.pipe":"Pipe","arrowheadEnd-style.square":"Square","arrowheadEnd-style.triangle":"Triangle","spline-style.line":"Line","spline-style.cubic":"Cubic","tool.select":"Select","tool.hand":"Hand","tool.draw":"Draw","tool.eraser":"Eraser","tool.arrow-down":"Arrow down","tool.arrow-left":"Arrow left","tool.arrow-right":"Arrow right","tool.arrow-up":"Arrow up","tool.arrow":"Arrow","tool.cloud":"Cloud","tool.diamond":"Diamond","tool.ellipse":"Ellipse","tool.hexagon":"Hexagon","tool.highlight":"Highlight","tool.line":"Line","tool.octagon":"Octagon","tool.oval":"Oval","tool.pentagon":"Pentagon","tool.rectangle":"Rectangle","tool.rhombus":"Rhombus","tool.star":"Star","tool.trapezoid":"Trapezoid","tool.triangle":"Triangle","tool.x-box":"X box","tool.check-box":"Check box","tool.asset":"Asset","tool.frame":"Frame","tool.note":"Note","tool.laser":"Laser","tool.embed":"Embed","tool.text":"Text","menu.title":"Menu","menu.copy-as":"Copy as","menu.edit":"Edit","menu.shape":"Shape","menu.export-as":"Export as","menu.file":"File","menu.language":"Language","menu.preferences":"Preferences","menu.view":"View","context-menu.arrange":"Arrange","context-menu.copy-as":"Copy as","context-menu.export-as":"Export as","context-menu.export-all-as":"Export all as","context-menu.move-to-page":"Move to page","context-menu.reorder":"Reorder","page-menu.title":"Pages","page-menu.create-new-page":"Create new page","page-menu.max-page-count-reached":"Max pages reached","page-menu.new-page-initial-name":"Page 1","page-menu.edit-start":"Edit","page-menu.edit-done":"Done","page-menu.go-to-page":"Go to page","page-menu.submenu.rename":"Rename","page-menu.submenu.duplicate-page":"Duplicate","page-menu.submenu.title":"Menu","page-menu.submenu.move-down":"Move down","page-menu.submenu.move-up":"Move up","page-menu.submenu.delete":"Delete","share-menu.title":"Share","share-menu.save-note":"Download this project to your computer as a .tldr file.","share-menu.fork-note":"Create a new shared project based on this snapshot.","share-menu.share-project":"Share this project","share-menu.default-project-name":"Shared Project","share-menu.copy-link":"Copy share link","share-menu.readonly-link":"Read-only","share-menu.create-snapshot-link":"Copy snapshot link","share-menu.snapshot-link-note":"Capture and share this project as a read-only snapshot link.","share-menu.copy-readonly-link":"Copy read-only link","share-menu.offline-note":"Create a new shared project based on your current project.","share-menu.copy-link-note":"Anyone with the link will be able to view and edit this project.","share-menu.copy-readonly-link-note":"Anyone with the link will be able to view (but not edit) this project.","share-menu.project-too-large":"Sorry, this project can't be shared because it's too large. We're working on it!","share-menu.upload-failed":"Sorry, we couldn't upload your project at the moment. Please try again or let us know if the problem persists.","status.offline":"Offline","status.online":"Online","people-menu.title":"People","people-menu.change-name":"Change name","people-menu.change-color":"Change color","people-menu.follow":"Following","people-menu.following":"Following","people-menu.leading":"Following You","people-menu.user":"(You)","people-menu.invite":"Invite others","help-menu.title":"Help and resources","help-menu.about":"About","help-menu.discord":"Discord","help-menu.github":"GitHub","help-menu.keyboard-shortcuts":"Keyboard shortcuts","help-menu.twitter":"Twitter","actions-menu.title":"Actions","edit-link-dialog.title":"Edit link","edit-link-dialog.invalid-url":"A link must be a valid URL.","edit-link-dialog.detail":"Links will open in a new tab.","edit-link-dialog.url":"URL","edit-link-dialog.clear":"Clear","edit-link-dialog.save":"Continue","edit-link-dialog.cancel":"Cancel","embed-dialog.title":"Insert embed","embed-dialog.back":"Back","embed-dialog.create":"Create","embed-dialog.cancel":"Cancel","embed-dialog.url":"URL","embed-dialog.instruction":"Paste in the site's URL to create the embed.","embed-dialog.invalid-url":"We could not create an embed from that URL.","edit-pages-dialog.move-down":"Move down","edit-pages-dialog.move-up":"Move up","shortcuts-dialog.title":"Keyboard shortcuts","shortcuts-dialog.edit":"Edit","shortcuts-dialog.file":"File","shortcuts-dialog.preferences":"Preferences","shortcuts-dialog.tools":"Tools","shortcuts-dialog.transform":"Transform","shortcuts-dialog.view":"View","shortcuts-dialog.collaboration":"Collaboration","home-project-dialog.title":"Home project","home-project-dialog.description":"This is your local home project. It's just for you!","rename-project-dialog.title":"Rename project","rename-project-dialog.cancel":"Cancel","rename-project-dialog.rename":"Rename","home-project-dialog.ok":"Ok","style-panel.title":"Styles","style-panel.align":"Align","style-panel.vertical-align":"Vertical align","style-panel.position":"Position","style-panel.arrowheads":"Arrows","style-panel.arrowhead-start":"Start","style-panel.arrowhead-end":"End","style-panel.color":"Color","style-panel.dash":"Dash","style-panel.fill":"Fill","style-panel.font":"Font","style-panel.geo":"Shape","style-panel.mixed":"Mixed","style-panel.opacity":"Opacity","style-panel.size":"Size","style-panel.spline":"Spline","tool-panel.drawing":"Drawing","tool-panel.shapes":"Shapes","tool-panel.more":"More","debug-panel.more":"More","navigation-zone.toggle-minimap":"Toggle minimap","navigation-zone.zoom":"Zoom","focus-mode.toggle-focus-mode":"Toggle focus mode","toast.close":"Close","file-system.file-open-error.title":"Could not open file","file-system.file-open-error.not-a-tldraw-file":"The file you tried to open doesn't look like a tldraw file.","file-system.file-open-error.file-format-version-too-new":"The file you tried to open is from a newer version of tldraw. Please reload the page and try again.","file-system.file-open-error.generic-corrupted-file":"The file you tried to open is corrupted.","file-system.confirm-open.title":"Overwrite current project?","file-system.confirm-open.description":"Opening a file will replace your current project and any unsaved changes will be lost. Are you sure you want to continue?","file-system.confirm-open.cancel":"Cancel","file-system.confirm-open.open":"Open file","file-system.confirm-open.dont-show-again":"Don't ask again","file-system.confirm-clear.title":"Clear current project?","file-system.confirm-clear.description":"Creating a new project will clear your current project and any unsaved changes will be lost. Are you sure you want to continue?","file-system.confirm-clear.cancel":"Cancel","file-system.confirm-clear.continue":"Continue","file-system.confirm-clear.dont-show-again":"Don't ask again","file-system.shared-document-file-open-error.title":"Could not open file","file-system.shared-document-file-open-error.description":"Opening files from shared projects is not supported.","sharing.confirm-leave.title":"Leave current project?","sharing.confirm-leave.description":"Are you sure you want to leave this shared project? You can return to it by navigating to its URL.","sharing.confirm-leave.cancel":"Cancel","sharing.confirm-leave.leave":"Leave","sharing.confirm-leave.dont-show-again":"Don't ask again","toast.error.export-fail.title":"Failed export","toast.error.export-fail.desc":"Failed to export image","toast.error.copy-fail.title":"Failed copy","toast.error.copy-fail.desc":"Failed to copy image","context.pages.new-page":"New page","vscode.file-open.desc":"We've updated this document to work with the current version of tldraw. If you'd like to keep the original version (which will work on old.tldraw.com), click below to create a backup.","vscode.file-open.open":"Continue","vscode.file-open.backup":"Backup","vscode.file-open.backup-saved":"Backup saved","vscode.file-open.backup-failed":"Backup failed: this is not a .tldr file.","vscode.file-open.dont-show-again":"Don't ask again","cursor-chat.type-to-chat":"Type to chat..."},sa={locale:"en",label:"English",messages:cv};async function cY(e,n){if(!(await fetch(n.translations.en)).ok)return console.warn("No main translations found."),sa;if(e==="en")return sa;const r=_c.find(a=>a.locale===e);if(!r)return console.warn(`No translation found for locale ${e}`),sa;const s=await(await fetch(n.translations[r.locale])).json();if(!s)return console.warn(`No messages found for locale ${e}`),sa;const i=[];for(const a in sa.messages)s[a]||i.push(a);return i.length>0,{locale:e,label:r.label,messages:{...sa.messages,...s}}}const V$=x.createContext({}),uY=()=>x.useContext(V$),dY=Tt(function({overrides:n,children:t}){const o=F().user.getLocale(),s=$w(),[i,a]=x.useState(()=>n&&n.en?{locale:"en",label:"English",messages:{...cv,...n.en}}:{locale:"en",label:"English",messages:cv});return x.useEffect(()=>{let l=!1;async function c(){const u=await cY(o,s);u&&!l&&(n&&n[o]?a({...u,messages:{...u.messages,...n[o]}}):a(u))}return c(),()=>{l=!0}},[s,o,n]),p.jsx(V$.Provider,{value:i,children:t})});function Ee(){const e=uY();return x.useCallback(function(t){return e.messages[t]??t},[e])}const he=x.forwardRef(function({children:n,disabled:t,type:r,...o},s){const i=F(),a=s==null?void 0:s.current;return t&&a===document.activeElement&&i.getContainer().focus(),p.jsx("button",{ref:s,type:"button",draggable:!1,disabled:t,...o,className:fe("tlui-button",`tlui-button__${r}`,o.className),children:n})}),Rs=x.memo(function({small:n,invertIcon:t,icon:r,color:o,className:s,...i}){const a=$w(),l=a.icons[r]??a.icons["question-mark-circle"],c=x.useRef(null);return x.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]),p.jsx("div",{...i,ref:c,className:fe("tlui-icon",{"tlui-icon__small":n},s),style:{color:o,mask:`url(${l}) center 100% / 100% no-repeat`,transform:t?"scale(-1, 1)":void 0}})});function Ie({icon:e,small:n,invertIcon:t}){return p.jsx(Rs,{className:"tlui-button__icon",icon:e,small:n,invertIcon:t})}let Ym=0;function Mw(){x.useEffect(()=>{var e,n;const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(e=t[0])!==null&&e!==void 0?e:_C()),document.body.insertAdjacentElement("beforeend",(n=t[1])!==null&&n!==void 0?n:_C()),Ym++,()=>{Ym===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),Ym--}},[])}function _C(){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}const Xm="focusScope.autoFocusOnMount",qm="focusScope.autoFocusOnUnmount",kC={bubbles:!1,cancelable:!0},Aw=x.forwardRef((e,n)=>{const{loop:t=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=x.useState(null),c=on(o),u=on(s),d=x.useRef(null),h=Ye(n,g=>l(g)),f=x.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;x.useEffect(()=>{if(r){let w=function(E){if(f.paused||!a)return;const _=E.target;a.contains(_)?d.current=_:as(d.current,{select:!0})},C=function(E){if(f.paused||!a)return;const _=E.relatedTarget;_!==null&&(a.contains(_)||as(d.current,{select:!0}))},I=function(E){if(document.activeElement===document.body)for(const k of E)k.removedNodes.length>0&&as(a)};var g=w,v=C,S=I;document.addEventListener("focusin",w),document.addEventListener("focusout",C);const P=new MutationObserver(I);return a&&P.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",C),P.disconnect()}}},[r,a,f.paused]),x.useEffect(()=>{if(a){$C.add(f);const g=document.activeElement;if(!a.contains(g)){const S=new CustomEvent(Xm,kC);a.addEventListener(Xm,c),a.dispatchEvent(S),S.defaultPrevented||(hY(yY(W$(a)),{select:!0}),document.activeElement===g&&as(a))}return()=>{a.removeEventListener(Xm,c),setTimeout(()=>{const S=new CustomEvent(qm,kC);a.addEventListener(qm,u),a.dispatchEvent(S),S.defaultPrevented||as(g??document.body,{select:!0}),a.removeEventListener(qm,u),$C.remove(f)},0)}}},[a,c,u,f]);const y=x.useCallback(g=>{if(!t&&!r||f.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,S=document.activeElement;if(v&&S){const w=g.currentTarget,[C,I]=pY(w);C&&I?!g.shiftKey&&S===I?(g.preventDefault(),t&&as(C,{select:!0})):g.shiftKey&&S===C&&(g.preventDefault(),t&&as(I,{select:!0})):S===w&&g.preventDefault()}},[t,r,f.paused]);return x.createElement(Be.div,Q({tabIndex:-1},i,{ref:h,onKeyDown:y}))});function hY(e,{select:n=!1}={}){const t=document.activeElement;for(const r of e)if(as(r,{select:n}),document.activeElement!==t)return}function pY(e){const n=W$(e),t=TC(n,e),r=TC(n.reverse(),e);return[t,r]}function W$(e){const n=[],t=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(;t.nextNode();)n.push(t.currentNode);return n}function TC(e,n){for(const t of e)if(!fY(t,{upTo:n}))return t}function fY(e,{upTo:n}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(n!==void 0&&e===n)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function gY(e){return e instanceof HTMLInputElement&&"select"in e}function as(e,{select:n=!1}={}){if(e&&e.focus){const t=document.activeElement;e.focus({preventScroll:!0}),e!==t&&gY(e)&&n&&e.select()}}const $C=mY();function mY(){let e=[];return{add(n){const t=e[0];n!==t&&(t==null||t.pause()),e=MC(e,n),e.unshift(n)},remove(n){var t;e=MC(e,n),(t=e[0])===null||t===void 0||t.resume()}}}function MC(e,n){const t=[...e],r=t.indexOf(n);return r!==-1&&t.splice(r,1),t}function yY(e){return e.filter(n=>n.tagName!=="A")}const SY=$O.useId||(()=>{});let vY=0;function Fo(e){const[n,t]=x.useState(SY());return _i(()=>{e||t(r=>r??String(vY++))},[e]),e||(n?`radix-${n}`:"")}const wY=["top","right","bottom","left"],Ls=Math.min,Wn=Math.max,ef=Math.round,Hd=Math.floor,Ns=e=>({x:e,y:e}),xY={left:"right",right:"left",bottom:"top",top:"bottom"},bY={start:"end",end:"start"};function uv(e,n,t){return Wn(e,Ls(n,t))}function Vo(e,n){return typeof e=="function"?e(n):e}function Wo(e){return e.split("-")[0]}function ml(e){return e.split("-")[1]}function jw(e){return e==="x"?"y":"x"}function Ow(e){return e==="y"?"height":"width"}function yl(e){return["top","bottom"].includes(Wo(e))?"y":"x"}function Dw(e){return jw(yl(e))}function PY(e,n,t){t===void 0&&(t=!1);const r=ml(e),o=Dw(e),s=Ow(o);let i=o==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return n.reference[s]>n.floating[s]&&(i=tf(i)),[i,tf(i)]}function CY(e){const n=tf(e);return[dv(e),n,dv(n)]}function dv(e){return e.replace(/start|end/g,n=>bY[n])}function IY(e,n,t){const r=["left","right"],o=["right","left"],s=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return t?n?o:r:n?r:o;case"left":case"right":return n?s:i;default:return[]}}function EY(e,n,t,r){const o=ml(e);let s=IY(Wo(e),t==="start",r);return o&&(s=s.map(i=>i+"-"+o),n&&(s=s.concat(s.map(dv)))),s}function tf(e){return e.replace(/left|right|bottom|top/g,n=>xY[n])}function _Y(e){return{top:0,right:0,bottom:0,left:0,...e}}function G$(e){return typeof e!="number"?_Y(e):{top:e,right:e,bottom:e,left:e}}function nf(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function AC(e,n,t){let{reference:r,floating:o}=e;const s=yl(n),i=Dw(n),a=Ow(i),l=Wo(n),c=s==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,h=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:d};break;case"left":f={x:r.x-o.width,y:d};break;default:f={x:r.x,y:r.y}}switch(ml(n)){case"start":f[i]-=h*(t&&c?-1:1);break;case"end":f[i]+=h*(t&&c?-1:1);break}return f}const kY=async(e,n,t)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=t,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(n));let c=await i.getElementRects({reference:e,floating:n,strategy:o}),{x:u,y:d}=AC(c,r,l),h=r,f={},y=0;for(let g=0;g<a.length;g++){const{name:v,fn:S}=a[g],{x:w,y:C,data:I,reset:P}=await S({x:u,y:d,initialPlacement:r,placement:h,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:n}});u=w??u,d=C??d,f={...f,[v]:{...f[v],...I}},P&&y<=50&&(y++,typeof P=="object"&&(P.placement&&(h=P.placement),P.rects&&(c=P.rects===!0?await i.getElementRects({reference:e,floating:n,strategy:o}):P.rects),{x:u,y:d}=AC(c,h,l)),g=-1)}return{x:u,y:d,placement:h,strategy:o,middlewareData:f}};async function nu(e,n){var t;n===void 0&&(n={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:f=0}=Vo(n,e),y=G$(f),v=a[h?d==="floating"?"reference":"floating":d],S=nf(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(v)))==null||t?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),w=d==="floating"?{...i.floating,x:r,y:o}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),I=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},P=nf(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:C,strategy:l}):w);return{top:(S.top-P.top+y.top)/I.y,bottom:(P.bottom-S.bottom+y.bottom)/I.y,left:(S.left-P.left+y.left)/I.x,right:(P.right-S.right+y.right)/I.x}}const TY=e=>({name:"arrow",options:e,async fn(n){const{x:t,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=n,{element:c,padding:u=0}=Vo(e,n)||{};if(c==null)return{};const d=G$(u),h={x:t,y:r},f=Dw(o),y=Ow(f),g=await i.getDimensions(c),v=f==="y",S=v?"top":"left",w=v?"bottom":"right",C=v?"clientHeight":"clientWidth",I=s.reference[y]+s.reference[f]-h[f]-s.floating[y],P=h[f]-s.reference[f],E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let _=E?E[C]:0;(!_||!await(i.isElement==null?void 0:i.isElement(E)))&&(_=a.floating[C]||s.floating[y]);const k=I/2-P/2,M=_/2-g[y]/2-1,T=Ls(d[S],M),R=Ls(d[w],M),O=T,U=_-g[y]-R,N=_/2-g[y]/2+k,L=uv(O,N,U),G=!l.arrow&&ml(o)!=null&&N!==L&&s.reference[y]/2-(N<O?T:R)-g[y]/2<0,X=G?N<O?N-O:N-U:0;return{[f]:h[f]+X,data:{[f]:L,centerOffset:N-L-X,...G&&{alignmentOffset:X}},reset:G}}}),$Y=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var t,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=n,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:g=!0,...v}=Vo(e,n);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const S=Wo(o),w=Wo(a)===a,C=await(l.isRTL==null?void 0:l.isRTL(c.floating)),I=h||(w||!g?[tf(a)]:CY(a));!h&&y!=="none"&&I.push(...EY(a,g,y,C));const P=[a,...I],E=await nu(n,v),_=[];let k=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&_.push(E[S]),d){const O=PY(o,i,C);_.push(E[O[0]],E[O[1]])}if(k=[...k,{placement:o,overflows:_}],!_.every(O=>O<=0)){var M,T;const O=(((M=s.flip)==null?void 0:M.index)||0)+1,U=P[O];if(U)return{data:{index:O,overflows:k},reset:{placement:U}};let N=(T=k.filter(L=>L.overflows[0]<=0).sort((L,G)=>L.overflows[1]-G.overflows[1])[0])==null?void 0:T.placement;if(!N)switch(f){case"bestFit":{var R;const L=(R=k.map(G=>[G.placement,G.overflows.filter(X=>X>0).reduce((X,H)=>X+H,0)]).sort((G,X)=>G[1]-X[1])[0])==null?void 0:R[0];L&&(N=L);break}case"initialPlacement":N=a;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function jC(e,n){return{top:e.top-n.height,right:e.right-n.width,bottom:e.bottom-n.height,left:e.left-n.width}}function OC(e){return wY.some(n=>e[n]>=0)}const MY=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(n){const{rects:t}=n,{strategy:r="referenceHidden",...o}=Vo(e,n);switch(r){case"referenceHidden":{const s=await nu(n,{...o,elementContext:"reference"}),i=jC(s,t.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:OC(i)}}}case"escaped":{const s=await nu(n,{...o,altBoundary:!0}),i=jC(s,t.floating);return{data:{escapedOffsets:i,escaped:OC(i)}}}default:return{}}}}};async function AY(e,n){const{placement:t,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Wo(t),a=ml(t),l=yl(t)==="y",c=["left","top"].includes(i)?-1:1,u=s&&l?-1:1,d=Vo(n,e);let{mainAxis:h,crossAxis:f,alignmentAxis:y}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return a&&typeof y=="number"&&(f=a==="end"?y*-1:y),l?{x:f*u,y:h*c}:{x:h*c,y:f*u}}const jY=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var t,r;const{x:o,y:s,placement:i,middlewareData:a}=n,l=await AY(n,e);return i===((t=a.offset)==null?void 0:t.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},OY=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:t,y:r,placement:o}=n,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:v=>{let{x:S,y:w}=v;return{x:S,y:w}}},...l}=Vo(e,n),c={x:t,y:r},u=await nu(n,l),d=yl(Wo(o)),h=jw(d);let f=c[h],y=c[d];if(s){const v=h==="y"?"top":"left",S=h==="y"?"bottom":"right",w=f+u[v],C=f-u[S];f=uv(w,f,C)}if(i){const v=d==="y"?"top":"left",S=d==="y"?"bottom":"right",w=y+u[v],C=y-u[S];y=uv(w,y,C)}const g=a.fn({...n,[h]:f,[d]:y});return{...g,data:{x:g.x-t,y:g.y-r}}}}},DY=function(e){return e===void 0&&(e={}),{options:e,fn(n){const{x:t,y:r,placement:o,rects:s,middlewareData:i}=n,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Vo(e,n),u={x:t,y:r},d=yl(o),h=jw(d);let f=u[h],y=u[d];const g=Vo(a,n),v=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const C=h==="y"?"height":"width",I=s.reference[h]-s.floating[C]+v.mainAxis,P=s.reference[h]+s.reference[C]-v.mainAxis;f<I?f=I:f>P&&(f=P)}if(c){var S,w;const C=h==="y"?"width":"height",I=["top","left"].includes(Wo(o)),P=s.reference[d]-s.floating[C]+(I&&((S=i.offset)==null?void 0:S[d])||0)+(I?0:v.crossAxis),E=s.reference[d]+s.reference[C]+(I?0:((w=i.offset)==null?void 0:w[d])||0)-(I?v.crossAxis:0);y<P?y=P:y>E&&(y=E)}return{[h]:f,[d]:y}}}},RY=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){const{placement:t,rects:r,platform:o,elements:s}=n,{apply:i=()=>{},...a}=Vo(e,n),l=await nu(n,a),c=Wo(t),u=ml(t),d=yl(t)==="y",{width:h,height:f}=r.floating;let y,g;c==="top"||c==="bottom"?(y=c,g=u===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(g=c,y=u==="end"?"top":"bottom");const v=f-l[y],S=h-l[g],w=!n.middlewareData.shift;let C=v,I=S;if(d){const E=h-l.left-l.right;I=u||w?Ls(S,E):E}else{const E=f-l.top-l.bottom;C=u||w?Ls(v,E):E}if(w&&!u){const E=Wn(l.left,0),_=Wn(l.right,0),k=Wn(l.top,0),M=Wn(l.bottom,0);d?I=h-2*(E!==0||_!==0?E+_:Wn(l.left,l.right)):C=f-2*(k!==0||M!==0?k+M:Wn(l.top,l.bottom))}await i({...n,availableWidth:I,availableHeight:C});const P=await o.getDimensions(s.floating);return h!==P.width||f!==P.height?{reset:{rects:!0}}:{}}}};function Fs(e){return Y$(e)?(e.nodeName||"").toLowerCase():"#document"}function Zn(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function Jo(e){var n;return(n=(Y$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function Y$(e){return e instanceof Node||e instanceof Zn(e).Node}function Go(e){return e instanceof Element||e instanceof Zn(e).Element}function uo(e){return e instanceof HTMLElement||e instanceof Zn(e).HTMLElement}function DC(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Zn(e).ShadowRoot}function Lu(e){const{overflow:n,overflowX:t,overflowY:r,display:o}=vr(e);return/auto|scroll|overlay|hidden|clip/.test(n+r+t)&&!["inline","contents"].includes(o)}function LY(e){return["table","td","th"].includes(Fs(e))}function Rw(e){const n=Lw(),t=vr(e);return t.transform!=="none"||t.perspective!=="none"||(t.containerType?t.containerType!=="normal":!1)||!n&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!n&&(t.filter?t.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(t.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(t.contain||"").includes(r))}function NY(e){let n=Ja(e);for(;uo(n)&&!Zf(n);){if(Rw(n))return n;n=Ja(n)}return null}function Lw(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Zf(e){return["html","body","#document"].includes(Fs(e))}function vr(e){return Zn(e).getComputedStyle(e)}function Qf(e){return Go(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Ja(e){if(Fs(e)==="html")return e;const n=e.assignedSlot||e.parentNode||DC(e)&&e.host||Jo(e);return DC(n)?n.host:n}function X$(e){const n=Ja(e);return Zf(n)?e.ownerDocument?e.ownerDocument.body:e.body:uo(n)&&Lu(n)?n:X$(n)}function ru(e,n,t){var r;n===void 0&&(n=[]),t===void 0&&(t=!0);const o=X$(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Zn(o);return s?n.concat(i,i.visualViewport||[],Lu(o)?o:[],i.frameElement&&t?ru(i.frameElement):[]):n.concat(o,ru(o,[],t))}function q$(e){const n=vr(e);let t=parseFloat(n.width)||0,r=parseFloat(n.height)||0;const o=uo(e),s=o?e.offsetWidth:t,i=o?e.offsetHeight:r,a=ef(t)!==s||ef(r)!==i;return a&&(t=s,r=i),{width:t,height:r,$:a}}function Nw(e){return Go(e)?e:e.contextElement}function za(e){const n=Nw(e);if(!uo(n))return Ns(1);const t=n.getBoundingClientRect(),{width:r,height:o,$:s}=q$(n);let i=(s?ef(t.width):t.width)/r,a=(s?ef(t.height):t.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const FY=Ns(0);function Z$(e){const n=Zn(e);return!Lw()||!n.visualViewport?FY:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function zY(e,n,t){return n===void 0&&(n=!1),!t||n&&t!==Zn(e)?!1:n}function ki(e,n,t,r){n===void 0&&(n=!1),t===void 0&&(t=!1);const o=e.getBoundingClientRect(),s=Nw(e);let i=Ns(1);n&&(r?Go(r)&&(i=za(r)):i=za(e));const a=zY(s,t,r)?Z$(s):Ns(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,d=o.height/i.y;if(s){const h=Zn(s),f=r&&Go(r)?Zn(r):r;let y=h,g=y.frameElement;for(;g&&r&&f!==y;){const v=za(g),S=g.getBoundingClientRect(),w=vr(g),C=S.left+(g.clientLeft+parseFloat(w.paddingLeft))*v.x,I=S.top+(g.clientTop+parseFloat(w.paddingTop))*v.y;l*=v.x,c*=v.y,u*=v.x,d*=v.y,l+=C,c+=I,y=Zn(g),g=y.frameElement}}return nf({width:u,height:d,x:l,y:c})}const BY=[":popover-open",":modal"];function Q$(e){return BY.some(n=>{try{return e.matches(n)}catch{return!1}})}function UY(e){let{elements:n,rect:t,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Jo(r),a=n?Q$(n.floating):!1;if(r===i||a&&s)return t;let l={scrollLeft:0,scrollTop:0},c=Ns(1);const u=Ns(0),d=uo(r);if((d||!d&&!s)&&((Fs(r)!=="body"||Lu(i))&&(l=Qf(r)),uo(r))){const h=ki(r);c=za(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+u.x,y:t.y*c.y-l.scrollTop*c.y+u.y}}function HY(e){return Array.from(e.getClientRects())}function J$(e){return ki(Jo(e)).left+Qf(e).scrollLeft}function KY(e){const n=Jo(e),t=Qf(e),r=e.ownerDocument.body,o=Wn(n.scrollWidth,n.clientWidth,r.scrollWidth,r.clientWidth),s=Wn(n.scrollHeight,n.clientHeight,r.scrollHeight,r.clientHeight);let i=-t.scrollLeft+J$(e);const a=-t.scrollTop;return vr(r).direction==="rtl"&&(i+=Wn(n.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function VY(e,n){const t=Zn(e),r=Jo(e),o=t.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const c=Lw();(!c||c&&n==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a,y:l}}function WY(e,n){const t=ki(e,!0,n==="fixed"),r=t.top+e.clientTop,o=t.left+e.clientLeft,s=uo(e)?za(e):Ns(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 RC(e,n,t){let r;if(n==="viewport")r=VY(e,t);else if(n==="document")r=KY(Jo(e));else if(Go(n))r=WY(n,t);else{const o=Z$(e);r={...n,x:n.x-o.x,y:n.y-o.y}}return nf(r)}function eM(e,n){const t=Ja(e);return t===n||!Go(t)||Zf(t)?!1:vr(t).position==="fixed"||eM(t,n)}function GY(e,n){const t=n.get(e);if(t)return t;let r=ru(e,[],!1).filter(a=>Go(a)&&Fs(a)!=="body"),o=null;const s=vr(e).position==="fixed";let i=s?Ja(e):e;for(;Go(i)&&!Zf(i);){const a=vr(i),l=Rw(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Lu(i)&&!l&&eM(e,i))?r=r.filter(u=>u!==i):o=a,i=Ja(i)}return n.set(e,r),r}function YY(e){let{element:n,boundary:t,rootBoundary:r,strategy:o}=e;const i=[...t==="clippingAncestors"?GY(n,this._c):[].concat(t),r],a=i[0],l=i.reduce((c,u)=>{const d=RC(n,u,o);return c.top=Wn(d.top,c.top),c.right=Ls(d.right,c.right),c.bottom=Ls(d.bottom,c.bottom),c.left=Wn(d.left,c.left),c},RC(n,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function XY(e){const{width:n,height:t}=q$(e);return{width:n,height:t}}function qY(e,n,t){const r=uo(n),o=Jo(n),s=t==="fixed",i=ki(e,!0,s,n);let a={scrollLeft:0,scrollTop:0};const l=Ns(0);if(r||!r&&!s)if((Fs(n)!=="body"||Lu(o))&&(a=Qf(n)),r){const d=ki(n,!0,s,n);l.x=d.x+n.clientLeft,l.y=d.y+n.clientTop}else o&&(l.x=J$(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 LC(e,n){return!uo(e)||vr(e).position==="fixed"?null:n?n(e):e.offsetParent}function tM(e,n){const t=Zn(e);if(!uo(e)||Q$(e))return t;let r=LC(e,n);for(;r&&LY(r)&&vr(r).position==="static";)r=LC(r,n);return r&&(Fs(r)==="html"||Fs(r)==="body"&&vr(r).position==="static"&&!Rw(r))?t:r||NY(e)||t}const ZY=async function(e){const n=this.getOffsetParent||tM,t=this.getDimensions;return{reference:qY(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,...await t(e.floating)}}};function QY(e){return vr(e).direction==="rtl"}const JY={convertOffsetParentRelativeRectToViewportRelativeRect:UY,getDocumentElement:Jo,getClippingRect:YY,getOffsetParent:tM,getElementRects:ZY,getClientRects:HY,getDimensions:XY,getScale:za,isElement:Go,isRTL:QY};function eX(e,n){let t=null,r;const o=Jo(e);function s(){var a;clearTimeout(r),(a=t)==null||a.disconnect(),t=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const{left:c,top:u,width:d,height:h}=e.getBoundingClientRect();if(a||n(),!d||!h)return;const f=Hd(u),y=Hd(o.clientWidth-(c+d)),g=Hd(o.clientHeight-(u+h)),v=Hd(c),w={rootMargin:-f+"px "+-y+"px "+-g+"px "+-v+"px",threshold:Wn(0,Ls(1,l))||1};let C=!0;function I(P){const E=P[0].intersectionRatio;if(E!==l){if(!C)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},100)}C=!1}try{t=new IntersectionObserver(I,{...w,root:o.ownerDocument})}catch{t=new IntersectionObserver(I,w)}t.observe(e)}return i(!0),s}function tX(e,n,t,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=Nw(e),u=o||s?[...c?ru(c):[],...ru(n)]:[];u.forEach(S=>{o&&S.addEventListener("scroll",t,{passive:!0}),s&&S.addEventListener("resize",t)});const d=c&&a?eX(c,t):null;let h=-1,f=null;i&&(f=new ResizeObserver(S=>{let[w]=S;w&&w.target===c&&f&&(f.unobserve(n),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var C;(C=f)==null||C.observe(n)})),t()}),c&&!l&&f.observe(c),f.observe(n));let y,g=l?ki(e):null;l&&v();function v(){const S=ki(e);g&&(S.x!==g.x||S.y!==g.y||S.width!==g.width||S.height!==g.height)&&t(),g=S,y=requestAnimationFrame(v)}return t(),()=>{var S;u.forEach(w=>{o&&w.removeEventListener("scroll",t),s&&w.removeEventListener("resize",t)}),d==null||d(),(S=f)==null||S.disconnect(),f=null,l&&cancelAnimationFrame(y)}}const nX=OY,rX=$Y,oX=RY,sX=MY,NC=TY,iX=DY,aX=(e,n,t)=>{const r=new Map,o={platform:JY,...t},s={...o.platform,_c:r};return kY(e,n,{...o,platform:s})},lX=e=>{function n(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:e,fn(t){const{element:r,padding:o}=typeof e=="function"?e(t):e;return r&&n(r)?r.current!=null?NC({element:r.current,padding:o}).fn(t):{}:r?NC({element:r,padding:o}).fn(t):{}}}};var Yh=typeof document<"u"?x.useLayoutEffect:x.useEffect;function rf(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let t,r,o;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(t=e.length,t!==n.length)return!1;for(r=t;r--!==0;)if(!rf(e[r],n[r]))return!1;return!0}if(o=Object.keys(e),t=o.length,t!==Object.keys(n).length)return!1;for(r=t;r--!==0;)if(!{}.hasOwnProperty.call(n,o[r]))return!1;for(r=t;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!rf(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}function nM(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function FC(e,n){const t=nM(e);return Math.round(n*t)/t}function zC(e){const n=x.useRef(e);return Yh(()=>{n.current=e}),n}function cX(e){e===void 0&&(e={});const{placement:n="bottom",strategy:t="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=x.useState({x:0,y:0,strategy:t,placement:n,middlewareData:{},isPositioned:!1}),[h,f]=x.useState(r);rf(h,r)||f(r);const[y,g]=x.useState(null),[v,S]=x.useState(null),w=x.useCallback(X=>{X!==E.current&&(E.current=X,g(X))},[]),C=x.useCallback(X=>{X!==_.current&&(_.current=X,S(X))},[]),I=s||y,P=i||v,E=x.useRef(null),_=x.useRef(null),k=x.useRef(u),M=l!=null,T=zC(l),R=zC(o),O=x.useCallback(()=>{if(!E.current||!_.current)return;const X={placement:n,strategy:t,middleware:h};R.current&&(X.platform=R.current),aX(E.current,_.current,X).then(H=>{const B={...H,isPositioned:!0};U.current&&!rf(k.current,B)&&(k.current=B,gl.flushSync(()=>{d(B)}))})},[h,n,t,R]);Yh(()=>{c===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,d(X=>({...X,isPositioned:!1})))},[c]);const U=x.useRef(!1);Yh(()=>(U.current=!0,()=>{U.current=!1}),[]),Yh(()=>{if(I&&(E.current=I),P&&(_.current=P),I&&P){if(T.current)return T.current(I,P,O);O()}},[I,P,O,T,M]);const N=x.useMemo(()=>({reference:E,floating:_,setReference:w,setFloating:C}),[w,C]),L=x.useMemo(()=>({reference:I,floating:P}),[I,P]),G=x.useMemo(()=>{const X={position:t,left:0,top:0};if(!L.floating)return X;const H=FC(L.floating,u.x),B=FC(L.floating,u.y);return a?{...X,transform:"translate("+H+"px, "+B+"px)",...nM(L.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:H,top:B}},[t,a,L.floating,u.x,u.y]);return x.useMemo(()=>({...u,update:O,refs:N,elements:L,floatingStyles:G}),[u,O,N,L,G])}function rM(e){const[n,t]=x.useState(void 0);return _i(()=>{if(e){t({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;t({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else t(void 0)},[e]),n}const oM="Popper",[sM,Jf]=go(oM),[uX,iM]=sM(oM),dX=e=>{const{__scopePopper:n,children:t}=e,[r,o]=x.useState(null);return x.createElement(uX,{scope:n,anchor:r,onAnchorChange:o},t)},hX="PopperAnchor",pX=x.forwardRef((e,n)=>{const{__scopePopper:t,virtualRef:r,...o}=e,s=iM(hX,t),i=x.useRef(null),a=Ye(n,i);return x.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:x.createElement(Be.div,Q({},o,{ref:a}))}),aM="PopperContent",[fX,$ne]=sM(aM),gX=x.forwardRef((e,n)=>{var t,r,o,s,i,a,l,c;const{__scopePopper:u,side:d="bottom",sideOffset:h=0,align:f="center",alignOffset:y=0,arrowPadding:g=0,avoidCollisions:v=!0,collisionBoundary:S=[],collisionPadding:w=0,sticky:C="partial",hideWhenDetached:I=!1,updatePositionStrategy:P="optimized",onPlaced:E,..._}=e,k=iM(aM,u),[M,T]=x.useState(null),R=Ye(n,xt=>T(xt)),[O,U]=x.useState(null),N=rM(O),L=(t=N==null?void 0:N.width)!==null&&t!==void 0?t:0,G=(r=N==null?void 0:N.height)!==null&&r!==void 0?r:0,X=d+(f!=="center"?"-"+f:""),H=typeof w=="number"?w:{top:0,right:0,bottom:0,left:0,...w},B=Array.isArray(S)?S:[S],W=B.length>0,Y={padding:H,boundary:B.filter(mX),altBoundary:W},{refs:J,floatingStyles:ke,placement:ve,isPositioned:pe,middlewareData:me}=cX({strategy:"fixed",placement:X,whileElementsMounted:(...xt)=>tX(...xt,{animationFrame:P==="always"}),elements:{reference:k.anchor},middleware:[jY({mainAxis:h+G,alignmentAxis:y}),v&&nX({mainAxis:!0,crossAxis:!1,limiter:C==="partial"?iX():void 0,...Y}),v&&rX({...Y}),oX({...Y,apply:({elements:xt,rects:pt,availableWidth:At,availableHeight:vl})=>{const{width:wl,height:ug}=pt.reference,Ui=xt.floating.style;Ui.setProperty("--radix-popper-available-width",`${At}px`),Ui.setProperty("--radix-popper-available-height",`${vl}px`),Ui.setProperty("--radix-popper-anchor-width",`${wl}px`),Ui.setProperty("--radix-popper-anchor-height",`${ug}px`)}}),O&&lX({element:O,padding:g}),yX({arrowWidth:L,arrowHeight:G}),I&&sX({strategy:"referenceHidden",...Y})]}),[Xe,Ae]=lM(ve),Ue=on(E);_i(()=>{pe&&(Ue==null||Ue())},[pe,Ue]);const yt=(o=me.arrow)===null||o===void 0?void 0:o.x,St=(s=me.arrow)===null||s===void 0?void 0:s.y,Le=((i=me.arrow)===null||i===void 0?void 0:i.centerOffset)!==0,[br,Nn]=x.useState();return _i(()=>{M&&Nn(window.getComputedStyle(M).zIndex)},[M]),x.createElement("div",{ref:J.setFloating,"data-radix-popper-content-wrapper":"",style:{...ke,transform:pe?ke.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:br,"--radix-popper-transform-origin":[(a=me.transformOrigin)===null||a===void 0?void 0:a.x,(l=me.transformOrigin)===null||l===void 0?void 0:l.y].join(" ")},dir:e.dir},x.createElement(fX,{scope:u,placedSide:Xe,onArrowChange:U,arrowX:yt,arrowY:St,shouldHideArrow:Le},x.createElement(Be.div,Q({"data-side":Xe,"data-align":Ae},_,{ref:R,style:{..._.style,animation:pe?void 0:"none",opacity:(c=me.hide)!==null&&c!==void 0&&c.referenceHidden?0:void 0}}))))});function mX(e){return e!==null}const yX=e=>({name:"transformOrigin",options:e,fn(n){var t,r,o,s,i;const{placement:a,rects:l,middlewareData:c}=n,d=((t=c.arrow)===null||t===void 0?void 0:t.centerOffset)!==0,h=d?0:e.arrowWidth,f=d?0:e.arrowHeight,[y,g]=lM(a),v={start:"0%",center:"50%",end:"100%"}[g],S=((r=(o=c.arrow)===null||o===void 0?void 0:o.x)!==null&&r!==void 0?r:0)+h/2,w=((s=(i=c.arrow)===null||i===void 0?void 0:i.y)!==null&&s!==void 0?s:0)+f/2;let C="",I="";return y==="bottom"?(C=d?v:`${S}px`,I=`${-f}px`):y==="top"?(C=d?v:`${S}px`,I=`${l.floating.height+f}px`):y==="right"?(C=`${-f}px`,I=d?v:`${w}px`):y==="left"&&(C=`${l.floating.width+f}px`,I=d?v:`${w}px`),{data:{x:C,y:I}}}});function lM(e){const[n,t="center"]=e.split("-");return[n,t]}const Fw=dX,cM=pX,uM=gX;var SX=function(e){if(typeof document>"u")return null;var n=Array.isArray(e)?e[0]:e;return n.ownerDocument.body},ia=new WeakMap,Kd=new WeakMap,Vd={},Zm=0,dM=function(e){return e&&(e.host||dM(e.parentNode))},vX=function(e,n){return n.map(function(t){if(e.contains(t))return t;var r=dM(t);return r&&e.contains(r)?r:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(t){return!!t})},wX=function(e,n,t,r){var o=vX(n,Array.isArray(e)?e:[e]);Vd[t]||(Vd[t]=new WeakMap);var s=Vd[t],i=[],a=new Set,l=new Set(o),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};o.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(h){if(a.has(h))u(h);else{var f=h.getAttribute(r),y=f!==null&&f!=="false",g=(ia.get(h)||0)+1,v=(s.get(h)||0)+1;ia.set(h,g),s.set(h,v),i.push(h),g===1&&y&&Kd.set(h,!0),v===1&&h.setAttribute(t,"true"),y||h.setAttribute(r,"true")}})};return u(n),a.clear(),Zm++,function(){i.forEach(function(d){var h=ia.get(d)-1,f=s.get(d)-1;ia.set(d,h),s.set(d,f),h||(Kd.has(d)||d.removeAttribute(r),Kd.delete(d)),f||d.removeAttribute(t)}),Zm--,Zm||(ia=new WeakMap,ia=new WeakMap,Kd=new WeakMap,Vd={})}},zw=function(e,n,t){t===void 0&&(t="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=n||SX(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),wX(r,o,t,"aria-hidden")):function(){return null}},eo=function(){return eo=Object.assign||function(n){for(var t,r=1,o=arguments.length;r<o;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[s]=t[s])}return n},eo.apply(this,arguments)};function hM(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]]);return t}function xX(e,n,t){if(t||arguments.length===2)for(var r=0,o=n.length,s;r<o;r++)(s||!(r in n))&&(s||(s=Array.prototype.slice.call(n,0,r)),s[r]=n[r]);return e.concat(s||Array.prototype.slice.call(n))}var Xh="right-scroll-bar-position",qh="width-before-scroll-bar",bX="with-scroll-bars-hidden",PX="--removed-body-scroll-bar-size";function Qm(e,n){return typeof e=="function"?e(n):e&&(e.current=n),e}function CX(e,n){var t=x.useState(function(){return{value:e,callback:n,facade:{get current(){return t.value},set current(r){var o=t.value;o!==r&&(t.value=r,t.callback(r,o))}}}})[0];return t.callback=n,t.facade}var BC=new WeakMap;function IX(e,n){var t=CX(n||null,function(r){return e.forEach(function(o){return Qm(o,r)})});return x.useLayoutEffect(function(){var r=BC.get(t);if(r){var o=new Set(r),s=new Set(e),i=t.current;o.forEach(function(a){s.has(a)||Qm(a,null)}),s.forEach(function(a){o.has(a)||Qm(a,i)})}BC.set(t,e)},[e]),t}function EX(e){return e}function _X(e,n){n===void 0&&(n=EX);var t=[],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 t.length?t[t.length-1]:e},useMedium:function(s){var i=n(s,r);return t.push(i),function(){t=t.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;t.length;){var i=t;t=[],i.forEach(s)}t={push:function(a){return s(a)},filter:function(){return t}}},assignMedium:function(s){r=!0;var i=[];if(t.length){var a=t;t=[],a.forEach(s),i=t}var l=function(){var u=i;i=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),t={push:function(u){i.push(u),c()},filter:function(u){return i=i.filter(u),t}}}};return o}function kX(e){e===void 0&&(e={});var n=_X(null);return n.options=eo({async:!0,ssr:!1},e),n}var pM=function(e){var n=e.sideCar,t=hM(e,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=n.read();if(!r)throw new Error("Sidecar medium not found");return x.createElement(r,eo({},t))};pM.isSideCarExport=!0;function TX(e,n){return e.useMedium(n),pM}var fM=kX(),Jm=function(){},eg=x.forwardRef(function(e,n){var t=x.useRef(null),r=x.useState({onScrollCapture:Jm,onWheelCapture:Jm,onTouchMoveCapture:Jm}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,h=e.sideCar,f=e.noIsolation,y=e.inert,g=e.allowPinchZoom,v=e.as,S=v===void 0?"div":v,w=hM(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),C=h,I=IX([t,n]),P=eo(eo({},w),o);return x.createElement(x.Fragment,null,u&&x.createElement(C,{sideCar:fM,removeScrollBar:c,shards:d,noIsolation:f,inert:y,setCallbacks:s,allowPinchZoom:!!g,lockRef:t}),i?x.cloneElement(x.Children.only(a),eo(eo({},P),{ref:I})):x.createElement(S,eo({},P,{className:l,ref:I}),a))});eg.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};eg.classNames={fullWidth:qh,zeroRight:Xh};var $X=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function MX(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var n=$X();return n&&e.setAttribute("nonce",n),e}function AX(e,n){e.styleSheet?e.styleSheet.cssText=n:e.appendChild(document.createTextNode(n))}function jX(e){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(e)}var OX=function(){var e=0,n=null;return{add:function(t){e==0&&(n=MX())&&(AX(n,t),jX(n)),e++},remove:function(){e--,!e&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},DX=function(){var e=OX();return function(n,t){x.useEffect(function(){return e.add(n),function(){e.remove()}},[n&&t])}},gM=function(){var e=DX(),n=function(t){var r=t.styles,o=t.dynamic;return e(r,o),null};return n},RX={left:0,top:0,right:0,gap:0},ey=function(e){return parseInt(e||"",10)||0},LX=function(e){var n=window.getComputedStyle(document.body),t=n[e==="padding"?"paddingLeft":"marginLeft"],r=n[e==="padding"?"paddingTop":"marginTop"],o=n[e==="padding"?"paddingRight":"marginRight"];return[ey(t),ey(r),ey(o)]},NX=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return RX;var n=LX(e),t=document.documentElement.clientWidth,r=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,r-t+n[2]-n[0])}},FX=gM(),of="data-scroll-locked",zX=function(e,n,t,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return t===void 0&&(t="margin"),`
|
|
198
|
+
.`.concat(bX,` {
|
|
199
|
+
overflow: hidden `).concat(r,`;
|
|
200
|
+
padding-right: `).concat(a,"px ").concat(r,`;
|
|
201
|
+
}
|
|
202
|
+
body[`).concat(of,`] {
|
|
203
|
+
overflow: hidden `).concat(r,`;
|
|
204
|
+
overscroll-behavior: contain;
|
|
205
|
+
`).concat([n&&"position: relative ".concat(r,";"),t==="margin"&&`
|
|
206
|
+
padding-left: `.concat(o,`px;
|
|
207
|
+
padding-top: `).concat(s,`px;
|
|
208
|
+
padding-right: `).concat(i,`px;
|
|
209
|
+
margin-left:0;
|
|
210
|
+
margin-top:0;
|
|
211
|
+
margin-right: `).concat(a,"px ").concat(r,`;
|
|
212
|
+
`),t==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.`).concat(Xh,` {
|
|
216
|
+
right: `).concat(a,"px ").concat(r,`;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.`).concat(qh,` {
|
|
220
|
+
margin-right: `).concat(a,"px ").concat(r,`;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.`).concat(Xh," .").concat(Xh,` {
|
|
224
|
+
right: 0 `).concat(r,`;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.`).concat(qh," .").concat(qh,` {
|
|
228
|
+
margin-right: 0 `).concat(r,`;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
body[`).concat(of,`] {
|
|
232
|
+
`).concat(PX,": ").concat(a,`px;
|
|
233
|
+
}
|
|
234
|
+
`)},BX=function(e){var n=e.noRelative,t=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r,s=x.useMemo(function(){return NX(o)},[o]);return x.useEffect(function(){return document.body.setAttribute(of,""),function(){document.body.removeAttribute(of)}},[]),x.createElement(FX,{styles:zX(s,!n,o,t?"":"!important")})},hv=!1;if(typeof window<"u")try{var Wd=Object.defineProperty({},"passive",{get:function(){return hv=!0,!0}});window.addEventListener("test",Wd,Wd),window.removeEventListener("test",Wd,Wd)}catch{hv=!1}var aa=hv?{passive:!1}:!1,UX=function(e){return e.tagName==="TEXTAREA"},mM=function(e,n){var t=window.getComputedStyle(e);return t[n]!=="hidden"&&!(t.overflowY===t.overflowX&&!UX(e)&&t[n]==="visible")},HX=function(e){return mM(e,"overflowY")},KX=function(e){return mM(e,"overflowX")},UC=function(e,n){var t=n;do{typeof ShadowRoot<"u"&&t instanceof ShadowRoot&&(t=t.host);var r=yM(e,t);if(r){var o=SM(e,t),s=o[1],i=o[2];if(s>i)return!0}t=t.parentNode}while(t&&t!==document.body);return!1},VX=function(e){var n=e.scrollTop,t=e.scrollHeight,r=e.clientHeight;return[n,t,r]},WX=function(e){var n=e.scrollLeft,t=e.scrollWidth,r=e.clientWidth;return[n,t,r]},yM=function(e,n){return e==="v"?HX(n):KX(n)},SM=function(e,n){return e==="v"?VX(n):WX(n)},GX=function(e,n){return e==="h"&&n==="rtl"?-1:1},YX=function(e,n,t,r,o){var s=GX(e,window.getComputedStyle(n).direction),i=s*r,a=t.target,l=n.contains(a),c=!1,u=i>0,d=0,h=0;do{var f=SM(e,a),y=f[0],g=f[1],v=f[2],S=g-v-s*y;(y||S)&&yM(e,a)&&(d+=S,h+=y),a=a.parentNode}while(!l&&a!==document.body||l&&(n.contains(a)||n===a));return(u&&(o&&d===0||!o&&i>d)||!u&&(o&&h===0||!o&&-i>h))&&(c=!0),c},Gd=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},HC=function(e){return[e.deltaX,e.deltaY]},KC=function(e){return e&&"current"in e?e.current:e},XX=function(e,n){return e[0]===n[0]&&e[1]===n[1]},qX=function(e){return`
|
|
235
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
236
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
237
|
+
`)},ZX=0,la=[];function QX(e){var n=x.useRef([]),t=x.useRef([0,0]),r=x.useRef(),o=x.useState(ZX++)[0],s=x.useState(function(){return gM()})[0],i=x.useRef(e);x.useEffect(function(){i.current=e},[e]),x.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=xX([e.lockRef.current],(e.shards||[]).map(KC),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=x.useCallback(function(g,v){if("touches"in g&&g.touches.length===2)return!i.current.allowPinchZoom;var S=Gd(g),w=t.current,C="deltaX"in g?g.deltaX:w[0]-S[0],I="deltaY"in g?g.deltaY:w[1]-S[1],P,E=g.target,_=Math.abs(C)>Math.abs(I)?"h":"v";if("touches"in g&&_==="h"&&E.type==="range")return!1;var k=UC(_,E);if(!k)return!0;if(k?P=_:(P=_==="v"?"h":"v",k=UC(_,E)),!k)return!1;if(!r.current&&"changedTouches"in g&&(C||I)&&(r.current=P),!P)return!0;var M=r.current||P;return YX(M,v,g,M==="h"?C:I,!0)},[]),l=x.useCallback(function(g){var v=g;if(!(!la.length||la[la.length-1]!==s)){var S="deltaY"in v?HC(v):Gd(v),w=n.current.filter(function(P){return P.name===v.type&&P.target===v.target&&XX(P.delta,S)})[0];if(w&&w.should){v.cancelable&&v.preventDefault();return}if(!w){var C=(i.current.shards||[]).map(KC).filter(Boolean).filter(function(P){return P.contains(v.target)}),I=C.length>0?a(v,C[0]):!i.current.noIsolation;I&&v.cancelable&&v.preventDefault()}}},[]),c=x.useCallback(function(g,v,S,w){var C={name:g,delta:v,target:S,should:w};n.current.push(C),setTimeout(function(){n.current=n.current.filter(function(I){return I!==C})},1)},[]),u=x.useCallback(function(g){t.current=Gd(g),r.current=void 0},[]),d=x.useCallback(function(g){c(g.type,HC(g),g.target,a(g,e.lockRef.current))},[]),h=x.useCallback(function(g){c(g.type,Gd(g),g.target,a(g,e.lockRef.current))},[]);x.useEffect(function(){return la.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",l,aa),document.addEventListener("touchmove",l,aa),document.addEventListener("touchstart",u,aa),function(){la=la.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,aa),document.removeEventListener("touchmove",l,aa),document.removeEventListener("touchstart",u,aa)}},[]);var f=e.removeScrollBar,y=e.inert;return x.createElement(x.Fragment,null,y?x.createElement(s,{styles:qX(o)}):null,f?x.createElement(BX,{gapMode:"margin"}):null)}const JX=TX(fM,QX);var vM=x.forwardRef(function(e,n){return x.createElement(eg,eo({},e,{ref:n,sideCar:JX}))});vM.classNames=eg.classNames;const Bw=vM,wM="Popover",[xM,Mne]=go(wM,[Jf]),Uw=Jf(),[eq,Sl]=xM(wM),tq=e=>{const{__scopePopover:n,children:t,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=Uw(n),l=x.useRef(null),[c,u]=x.useState(!1),[d=!1,h]=Ws({prop:r,defaultProp:o,onChange:s});return x.createElement(Fw,a,x.createElement(eq,{scope:n,contentId:Fo(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(f=>!f),[h]),hasCustomAnchor:c,onCustomAnchorAdd:x.useCallback(()=>u(!0),[]),onCustomAnchorRemove:x.useCallback(()=>u(!1),[]),modal:i},t))},nq="PopoverTrigger",rq=x.forwardRef((e,n)=>{const{__scopePopover:t,...r}=e,o=Sl(nq,t),s=Uw(t),i=Ye(n,o.triggerRef),a=x.createElement(Be.button,Q({type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":CM(o.open)},r,{ref:i,onClick:se(e.onClick,o.onOpenToggle)}));return o.hasCustomAnchor?a:x.createElement(cM,Q({asChild:!0},s),a)}),bM="PopoverPortal",[oq,sq]=xM(bM,{forceMount:void 0}),iq=e=>{const{__scopePopover:n,forceMount:t,children:r,container:o}=e,s=Sl(bM,n);return x.createElement(oq,{scope:n,forceMount:t},x.createElement(mo,{present:t||s.open},x.createElement(Yf,{asChild:!0,container:o},r)))},ou="PopoverContent",aq=x.forwardRef((e,n)=>{const t=sq(ou,e.__scopePopover),{forceMount:r=t.forceMount,...o}=e,s=Sl(ou,e.__scopePopover);return x.createElement(mo,{present:r||s.open},s.modal?x.createElement(lq,Q({},o,{ref:n})):x.createElement(cq,Q({},o,{ref:n})))}),lq=x.forwardRef((e,n)=>{const t=Sl(ou,e.__scopePopover),r=x.useRef(null),o=Ye(n,r),s=x.useRef(!1);return x.useEffect(()=>{const i=r.current;if(i)return zw(i)},[]),x.createElement(Bw,{as:Ei,allowPinchZoom:!0},x.createElement(PM,Q({},e,{ref:o,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:se(e.onCloseAutoFocus,i=>{var a;i.preventDefault(),s.current||(a=t.triggerRef.current)===null||a===void 0||a.focus()}),onPointerDownOutside:se(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:se(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})))}),cq=x.forwardRef((e,n)=>{const t=Sl(ou,e.__scopePopover),r=x.useRef(!1),o=x.useRef(!1);return x.createElement(PM,Q({},e,{ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i;if((i=e.onCloseAutoFocus)===null||i===void 0||i.call(e,s),!s.defaultPrevented){var a;r.current||(a=t.triggerRef.current)===null||a===void 0||a.focus(),s.preventDefault()}r.current=!1,o.current=!1},onInteractOutside:s=>{var i,a;(i=e.onInteractOutside)===null||i===void 0||i.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=s.target;((a=t.triggerRef.current)===null||a===void 0?void 0:a.contains(l))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}}))}),PM=x.forwardRef((e,n)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,h=Sl(ou,t),f=Uw(t);return Mw(),x.createElement(Aw,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s},x.createElement(Gf,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1)},x.createElement(uM,Q({"data-state":CM(h.open),role:"dialog",id:h.contentId},f,d,{ref:n,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}))))});function CM(e){return e?"open":"closed"}const uq=tq,dq=rq,hq=iq,pq=aq,IM=()=>{},EM=x.createContext({});function fq({onEvent:e,children:n}){return p.jsx(EM.Provider,{value:e??IM,children:n})}function yo(){return x.useContext(EM)??IM}function Gs(e,n){const t=F(),r=x.useRef(!1),o=yo(),s=x.useCallback(a=>{r.current=a,t.batch(()=>{a?(t.complete(),t.addOpenMenu(e)):t.updateInstanceState({openMenus:t.getOpenMenus().filter(l=>!l.startsWith(e))}),n==null||n(a)})},[t,e,n]),i=K("is menu open",()=>t.getOpenMenus().includes(e),[t,e]);return x.useEffect(()=>(r.current&&(o("open-menu",{source:"unknown",id:e}),t.addOpenMenu(e)),()=>{r.current&&(t.deleteOpenMenu(e),t.getOpenMenus().forEach(a=>{a.startsWith(e)&&(o("close-menu",{source:"unknown",id:e}),t.deleteOpenMenu(a))}),r.current=!1)}),[t,e,o]),[i,s]}function Hw({id:e,children:n,onOpenChange:t,open:r}){const[o,s]=Gs(e,t);return p.jsx(uq,{onOpenChange:s,open:r||o,children:p.jsx("div",{className:"tlui-popover",children:n})})}function Kw({children:e}){return p.jsx(dq,{asChild:!0,dir:"ltr",children:e})}function Vw({side:e,children:n,align:t="center",sideOffset:r=8,alignOffset:o=0}){const s=mn();return p.jsx(hq,{container:s,children:p.jsx(pq,{className:"tlui-popover__content",side:e,sideOffset:r,align:t,alignOffset:o,dir:"ltr",children:n})})}const _M=x.createContext({type:"menu",sourceId:"main-menu"});function tg(){return x.useContext(_M)}function So({type:e,sourceId:n,children:t}){return p.jsx(_M.Provider,{value:{type:e,sourceId:n},children:t})}function gq(e,n){const t=ge(n.map(o=>e.getShape(o)).filter(o=>o&&e.isShapeOfType(o,"frame")));if(!t.length)return;const r=[];e.batch(()=>{t.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(n)})}const mq=50;function yq(e,n,t={}){const r=e.getShape(n);if(!r)return;const o=e.getSortedChildIdsForParent(r.id),s=ge(o.map(f=>e.getShape(f)));if(!s.length)return;const i=ne.FromPoints(s.flatMap(f=>{const y=e.getShapeGeometry(f.id);return e.getShapeLocalTransform(f).applyToPoints(y.vertices)})),{padding:a=mq}=t,l=i.w+2*a,c=i.h+2*a,u=a-i.minX,d=a-i.minY;if(u===0&&d===0&&r.props.w===l&&r.props.h===c)return;const h=new b(u,d).rot(r.rotation);e.batch(()=>{const f=o.map(y=>{const g=e.getShape(y);return{id:g.id,type:g.type,x:g.x+u,y:g.y+d}});f.push({id:r.id,type:r.type,x:r.x-h.x,y:r.y-h.y,props:{w:l,h:c}}),e.updateShapes(f)})}function mt({children:e}){return p.jsx("span",{className:"tlui-button__label",children:e})}const kM="Dialog",[TM,Ane]=go(kM),[Sq,es]=TM(kM),vq=e=>{const{__scopeDialog:n,children:t,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=x.useRef(null),l=x.useRef(null),[c=!1,u]=Ws({prop:r,defaultProp:o,onChange:s});return x.createElement(Sq,{scope:n,triggerRef:a,contentRef:l,contentId:Fo(),titleId:Fo(),descriptionId:Fo(),open:c,onOpenChange:u,onOpenToggle:x.useCallback(()=>u(d=>!d),[u]),modal:i},t)},$M="DialogPortal",[wq,MM]=TM($M,{forceMount:void 0}),xq=e=>{const{__scopeDialog:n,forceMount:t,children:r,container:o}=e,s=es($M,n);return x.createElement(wq,{scope:n,forceMount:t},x.Children.map(r,i=>x.createElement(mo,{present:t||s.open},x.createElement(Yf,{asChild:!0,container:o},i))))},pv="DialogOverlay",bq=x.forwardRef((e,n)=>{const t=MM(pv,e.__scopeDialog),{forceMount:r=t.forceMount,...o}=e,s=es(pv,e.__scopeDialog);return s.modal?x.createElement(mo,{present:r||s.open},x.createElement(Pq,Q({},o,{ref:n}))):null}),Pq=x.forwardRef((e,n)=>{const{__scopeDialog:t,...r}=e,o=es(pv,t);return x.createElement(Bw,{as:Ei,allowPinchZoom:!0,shards:[o.contentRef]},x.createElement(Be.div,Q({"data-state":jM(o.open)},r,{ref:n,style:{pointerEvents:"auto",...r.style}})))}),su="DialogContent",Cq=x.forwardRef((e,n)=>{const t=MM(su,e.__scopeDialog),{forceMount:r=t.forceMount,...o}=e,s=es(su,e.__scopeDialog);return x.createElement(mo,{present:r||s.open},s.modal?x.createElement(Iq,Q({},o,{ref:n})):x.createElement(Eq,Q({},o,{ref:n})))}),Iq=x.forwardRef((e,n)=>{const t=es(su,e.__scopeDialog),r=x.useRef(null),o=Ye(n,t.contentRef,r);return x.useEffect(()=>{const s=r.current;if(s)return zw(s)},[]),x.createElement(AM,Q({},e,{ref:o,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:se(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=t.triggerRef.current)===null||i===void 0||i.focus()}),onPointerDownOutside:se(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:se(e.onFocusOutside,s=>s.preventDefault())}))}),Eq=x.forwardRef((e,n)=>{const t=es(su,e.__scopeDialog),r=x.useRef(!1),o=x.useRef(!1);return x.createElement(AM,Q({},e,{ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i;if((i=e.onCloseAutoFocus)===null||i===void 0||i.call(e,s),!s.defaultPrevented){var a;r.current||(a=t.triggerRef.current)===null||a===void 0||a.focus(),s.preventDefault()}r.current=!1,o.current=!1},onInteractOutside:s=>{var i,a;(i=e.onInteractOutside)===null||i===void 0||i.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=s.target;((a=t.triggerRef.current)===null||a===void 0?void 0:a.contains(l))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}}))}),AM=x.forwardRef((e,n)=>{const{__scopeDialog:t,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=es(su,t),l=x.useRef(null),c=Ye(n,l);return Mw(),x.createElement(x.Fragment,null,x.createElement(Aw,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s},x.createElement(Gf,Q({role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":jM(a.open)},i,{ref:c,onDismiss:()=>a.onOpenChange(!1)}))),!1)}),_q="DialogTitle",kq=x.forwardRef((e,n)=>{const{__scopeDialog:t,...r}=e,o=es(_q,t);return x.createElement(Be.h2,Q({id:o.titleId},r,{ref:n}))});const Tq="DialogClose",$q=x.forwardRef((e,n)=>{const{__scopeDialog:t,...r}=e,o=es(Tq,t);return x.createElement(Be.button,Q({type:"button"},r,{ref:n,onClick:se(e.onClick,()=>o.onOpenChange(!1))}))});function jM(e){return e?"open":"closed"}const Mq=vq,Aq=xq,jq=bq,Oq=Cq;function ng({className:e,children:n}){return p.jsx("div",{className:fe("tlui-dialog__header",e),children:n})}function rg({className:e,children:n}){return p.jsx(kq,{dir:"ltr",className:fe("tlui-dialog__header__title",e),children:n})}function og(){return p.jsx("div",{className:"tlui-dialog__header__close",children:p.jsx($q,{"data-testid":"dialog.close",dir:"ltr",asChild:!0,children:p.jsx(he,{type:"icon","aria-label":"Close",onTouchEnd:e=>e.target.click(),children:p.jsx(Ie,{small:!0,icon:"cross-2"})})})})}function iu({className:e,children:n,style:t}){return p.jsx("div",{className:fe("tlui-dialog__body",e),style:t,children:n})}function Ww({className:e,children:n}){return p.jsx("div",{className:fe("tlui-dialog__footer",e),children:n})}const Gw=x.forwardRef(function({className:n,label:t,icon:r,iconLeft:o,autoselect:s=!1,autofocus:i=!1,defaultValue:a,placeholder:l,onComplete:c,onValueChange:u,onCancel:d,onBlur:h,shouldManuallyMaintainScrollPositionWhenFocused:f=!1,children:y,value:g},v){const S=F(),w=x.useRef(null);x.useImperativeHandle(v,()=>w.current);const C=Ee(),I=x.useRef(a??""),P=x.useRef(a??""),[E,_]=x.useState(!1),k=x.useCallback(O=>{_(!0);const U=O.currentTarget;P.current=U.value,requestAnimationFrame(()=>{s&&U.select()})},[s]),M=x.useCallback(O=>{const U=O.currentTarget.value;P.current=U,u==null||u(U)},[u]),T=x.useCallback(O=>{switch(O.key){case"Enter":{O.currentTarget.blur(),It(O),c==null||c(O.currentTarget.value);break}case"Escape":{O.currentTarget.value=I.current,O.currentTarget.blur(),It(O),d==null||d(O.currentTarget.value);break}}},[c,d]),R=x.useCallback(O=>{_(!1);const U=O.currentTarget.value;h==null||h(U)},[h]);return x.useEffect(()=>{if(!S.environment.isIos)return;const O=window.visualViewport;if(E&&f&&O){const U=()=>{var N;(N=w.current)==null||N.scrollIntoView({block:"center"})};return O.addEventListener("resize",U),O.addEventListener("scroll",U),requestAnimationFrame(()=>{var N;(N=w.current)==null||N.scrollIntoView({block:"center"})}),()=>{O.removeEventListener("resize",U),O.removeEventListener("scroll",U)}}},[S,E,f]),p.jsxs("div",{draggable:!1,className:"tlui-input__wrapper",children:[y,t&&p.jsx("label",{children:C(t)}),o&&p.jsx(Rs,{icon:o,className:"tlui-icon-left",small:!0}),p.jsx("input",{ref:w,className:fe("tlui-input",n),type:"text",defaultValue:a,onKeyUp:T,onChange:M,onFocus:k,onBlur:R,autoFocus:i,placeholder:l,value:g}),r&&p.jsx(Rs,{icon:r,small:!!t})]})});function VC(e){return Qn.isValid(e)?{isValid:!0,hasProtocol:!0}:Qn.isValid("https://"+e)?{isValid:!0,hasProtocol:!1}:{isValid:!1,hasProtocol:!1}}const Dq=Tt(function({onClose:n}){const r=F().getOnlySelectedShape();return r&&"url"in r.props&&typeof r.props.url=="string"?p.jsx(Rq,{onClose:n,selectedShape:r}):null}),Rq=Tt(function({onClose:n,selectedShape:t}){const r=F(),o=Ee(),s=x.useRef(null);x.useEffect(()=>{requestAnimationFrame(()=>{var y;return(y=s.current)==null?void 0:y.focus()})},[]);const i=x.useRef(t.props.url),[a,l]=x.useState(()=>{const y=VC(t.props.url),g=y.isValid===!0?y.hasProtocol?t.props.url:"https://"+t.props.url:"https://";return{actual:g,safe:g,valid:!0}}),c=x.useCallback(y=>{const g=y.replace(/https?:\/\/(https?:\/\/)/,(w,C)=>C),v=VC(g),S=v.isValid===!0?v.hasProtocol?g:"https://"+g:"https://";l({actual:g,safe:S,valid:v.isValid})},[]),u=x.useCallback(()=>{const y=r.getOnlySelectedShape();y&&(r.updateShapes([{id:y.id,type:y.type,props:{url:""}}]),n())},[r,n]),d=x.useCallback(()=>{const y=r.getOnlySelectedShape();y&&(y&&"url"in y.props&&y.props.url!==a.safe&&r.updateShapes([{id:y.id,type:y.type,props:{url:a.safe}}]),n())},[r,n,a]),h=x.useCallback(()=>{n()},[n]);if(!t)return n(),null;const f=i.current&&!a.valid;return p.jsxs(p.Fragment,{children:[p.jsxs(ng,{children:[p.jsx(rg,{children:o("edit-link-dialog.title")}),p.jsx(og,{})]}),p.jsx(iu,{children:p.jsxs("div",{className:"tlui-edit-link-dialog",children:[p.jsx(Gw,{ref:s,className:"tlui-edit-link-dialog__input",label:"edit-link-dialog.url",autofocus:!0,value:a.actual,onValueChange:c,onComplete:d,onCancel:h}),p.jsx("div",{children:a.valid?o("edit-link-dialog.detail"):o("edit-link-dialog.invalid-url")})]})}),p.jsxs(Ww,{className:"tlui-dialog__footer__actions",children:[p.jsx(he,{type:"normal",onClick:h,onTouchEnd:h,children:p.jsx(mt,{children:o("edit-link-dialog.cancel")})}),f?p.jsx(he,{type:"danger",onTouchEnd:u,onClick:u,children:p.jsx(mt,{children:o("edit-link-dialog.clear")})}):p.jsx(he,{type:"primary",disabled:!a.valid,onTouchEnd:d,onClick:d,children:p.jsx(mt,{children:o("edit-link-dialog.save")})})]})]})}),OM=Tt(function({onClose:n}){const t=F(),r=Ee(),o=$w(),[s,i]=x.useState(null),[a,l]=x.useState(""),[c,u]=x.useState(null),[d,h]=x.useState(!1),f=x.useRef(-1);return p.jsxs(p.Fragment,{children:[p.jsxs(ng,{children:[p.jsx(rg,{children:s?`${r("embed-dialog.title")} — ${s.title}`:r("embed-dialog.title")}),p.jsx(og,{})]}),s?p.jsxs(p.Fragment,{children:[p.jsxs(iu,{className:"tlui-embed-dialog__enter",children:[p.jsx(Gw,{className:"tlui-embed-dialog__input",label:"embed-url",placeholder:"http://example.com",autofocus:!0,onValueChange:y=>{l(y);const g=Ao(y);u(g&&g.definition.type===s.type?g:null),h(!1),clearTimeout(f.current),f.current=setTimeout(()=>h(!g),320)}}),a===""?p.jsxs("div",{className:"tlui-embed-dialog__instruction",children:[p.jsx("span",{children:r("embed-dialog.instruction")})," ",s.instructionLink&&p.jsxs("a",{target:"_blank",rel:"noopener noreferrer",href:s.instructionLink,className:"tlui-embed-dialog__instruction__link",children:["Learn more.",p.jsx(Rs,{icon:"external-link",small:!0})]})]}):p.jsx("div",{className:"tlui-embed-dialog__warning",children:d?r("embed-dialog.invalid-url"):" "})]}),p.jsxs(Ww,{className:"tlui-dialog__footer__actions",children:[p.jsx(he,{type:"normal",onClick:()=>{i(null),u(null),l("")},children:p.jsx(mt,{children:r("embed-dialog.back")})}),p.jsx("div",{className:"tlui-embed__spacer"}),p.jsx(he,{type:"normal",onClick:n,children:p.jsx(mt,{children:r("embed-dialog.cancel")})}),p.jsx(he,{type:"primary",disabled:!c,onClick:()=>{c&&(t.putExternalContent({type:"embed",url:a,point:t.getViewportPageCenter(),embed:c.definition}),n())},children:p.jsx(mt,{children:r("embed-dialog.create")})})]})]}):p.jsx(p.Fragment,{children:p.jsx(iu,{className:"tlui-embed-dialog__list",children:Ha.map(y=>p.jsxs(he,{type:"menu",onClick:()=>i(y),children:[p.jsx(mt,{children:y.title}),p.jsx("div",{className:"tlui-embed-dialog__item__image",style:{backgroundImage:`url(${o.embedIcons[y.type]})`}})]},y.type))})})]})});var Yw={exports:{}};Yw.exports;(function(e){var n=function(){var t=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 t(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),d=0,h=c.length;d<h;d++){var f=c.charCodeAt(d);u[d*2]=f>>>8,u[d*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,d=c.length;u<d;u++)c[u]=l[u*2]*256+l[u*2+1];var h=[];return c.forEach(function(f){h.push(t(f))}),a.decompress(h.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 t(c)})},_compress:function(l,c,u){if(l==null)return"";var d,h,f={},y={},g="",v="",S="",w=2,C=3,I=2,P=[],E=0,_=0,k;for(k=0;k<l.length;k+=1)if(g=l.charAt(k),Object.prototype.hasOwnProperty.call(f,g)||(f[g]=C++,y[g]=!0),v=S+g,Object.prototype.hasOwnProperty.call(f,v))S=v;else{if(Object.prototype.hasOwnProperty.call(y,S)){if(S.charCodeAt(0)<256){for(d=0;d<I;d++)E=E<<1,_==c-1?(_=0,P.push(u(E)),E=0):_++;for(h=S.charCodeAt(0),d=0;d<8;d++)E=E<<1|h&1,_==c-1?(_=0,P.push(u(E)),E=0):_++,h=h>>1}else{for(h=1,d=0;d<I;d++)E=E<<1|h,_==c-1?(_=0,P.push(u(E)),E=0):_++,h=0;for(h=S.charCodeAt(0),d=0;d<16;d++)E=E<<1|h&1,_==c-1?(_=0,P.push(u(E)),E=0):_++,h=h>>1}w--,w==0&&(w=Math.pow(2,I),I++),delete y[S]}else for(h=f[S],d=0;d<I;d++)E=E<<1|h&1,_==c-1?(_=0,P.push(u(E)),E=0):_++,h=h>>1;w--,w==0&&(w=Math.pow(2,I),I++),f[v]=C++,S=String(g)}if(S!==""){if(Object.prototype.hasOwnProperty.call(y,S)){if(S.charCodeAt(0)<256){for(d=0;d<I;d++)E=E<<1,_==c-1?(_=0,P.push(u(E)),E=0):_++;for(h=S.charCodeAt(0),d=0;d<8;d++)E=E<<1|h&1,_==c-1?(_=0,P.push(u(E)),E=0):_++,h=h>>1}else{for(h=1,d=0;d<I;d++)E=E<<1|h,_==c-1?(_=0,P.push(u(E)),E=0):_++,h=0;for(h=S.charCodeAt(0),d=0;d<16;d++)E=E<<1|h&1,_==c-1?(_=0,P.push(u(E)),E=0):_++,h=h>>1}w--,w==0&&(w=Math.pow(2,I),I++),delete y[S]}else for(h=f[S],d=0;d<I;d++)E=E<<1|h&1,_==c-1?(_=0,P.push(u(E)),E=0):_++,h=h>>1;w--,w==0&&(w=Math.pow(2,I),I++)}for(h=2,d=0;d<I;d++)E=E<<1|h&1,_==c-1?(_=0,P.push(u(E)),E=0):_++,h=h>>1;for(;;)if(E=E<<1,_==c-1){P.push(u(E));break}else _++;return P.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 d=[],h=4,f=4,y=3,g="",v=[],S,w,C,I,P,E,_,k={val:u(0),position:c,index:1};for(S=0;S<3;S+=1)d[S]=S;for(C=0,P=Math.pow(2,2),E=1;E!=P;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),C|=(I>0?1:0)*E,E<<=1;switch(C){case 0:for(C=0,P=Math.pow(2,8),E=1;E!=P;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),C|=(I>0?1:0)*E,E<<=1;_=t(C);break;case 1:for(C=0,P=Math.pow(2,16),E=1;E!=P;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),C|=(I>0?1:0)*E,E<<=1;_=t(C);break;case 2:return""}for(d[3]=_,w=_,v.push(_);;){if(k.index>l)return"";for(C=0,P=Math.pow(2,y),E=1;E!=P;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),C|=(I>0?1:0)*E,E<<=1;switch(_=C){case 0:for(C=0,P=Math.pow(2,8),E=1;E!=P;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),C|=(I>0?1:0)*E,E<<=1;d[f++]=t(C),_=f-1,h--;break;case 1:for(C=0,P=Math.pow(2,16),E=1;E!=P;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=c,k.val=u(k.index++)),C|=(I>0?1:0)*E,E<<=1;d[f++]=t(C),_=f-1,h--;break;case 2:return v.join("")}if(h==0&&(h=Math.pow(2,y),y++),d[_])g=d[_];else if(_===f)g=w+w.charAt(0);else return null;v.push(g),d[f++]=w+g.charAt(0),h--,w=g,h==0&&(h=Math.pow(2,y),y++)}}};return a}();e!=null?e.exports=n:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return n})})(Yw);var DM=Yw.exports;async function Lq(e,n,t){var S,w,C;const{elements:r,files:o}=n,s={shapes:[],rootShapeIds:[],assets:[],schema:e.store.schema.serialize()},i=new Map,a=new Map,l=e.getCurrentPageId(),c=new Map,u=[],d=new Set;r.forEach(I=>{if(c.set(I.id,We()),I.boundElements!==null)for(const P of I.boundElements)P.type==="text"&&d.add(P.id)});let h=dD;for(const I of r){if(d.has(I.id))continue;const P=c.get(I.id),E={id:P,typeName:"shape",parentId:l,index:h,x:I.x,y:I.y,rotation:0,isLocked:I.locked,opacity:Nq(I.opacity),meta:{}};switch(I.angle!==0&&a.set(P,I.angle),I.groupIds&&I.groupIds.length>0?i.has(I.groupIds[0])?(S=i.get(I.groupIds[0]))==null||S.push(P):i.set(I.groupIds[0],[P]):u.push(P),I.type){case"rectangle":case"ellipse":case"diamond":{let _="",k="middle";if(I.boundElements!==null){for(const T of I.boundElements)if(T.type==="text"){const R=r.find(O=>O.id===T.id);R&&(_=R.text,k=WC[R.textAlign])}}const M=I.backgroundColor==="transparent"?I.strokeColor:I.backgroundColor;s.shapes.push({...E,type:"geo",props:{geo:I.type,url:I.link??"",w:I.width,h:I.height,size:Yd[I.strokeWidth]??"draw",color:Kl[M]??"black",text:_,align:k,dash:Xd(I),fill:Vq(I)}});break}case"freedraw":{s.shapes.push({...E,type:"draw",props:{dash:Xd(I),size:Yd[I.strokeWidth],color:Kl[I.strokeColor]??"black",segments:[{type:"free",points:I.points.map(([_,k,M=.5])=>({x:_,y:k,z:M}))}]}});break}case"line":{const _=I.points[0],k=I.points[I.points.length-1],M=Pc(I.points.length);s.shapes.push({...E,type:"line",props:{dash:Xd(I),size:Yd[I.strokeWidth],color:Kl[I.strokeColor]??"black",spline:I.roundness?"cubic":"line",handles:{start:{id:"start",type:"vertex",index:M[0],x:_[0],y:_[1]},end:{id:"end",type:"vertex",index:M[M.length-1],x:k[0],y:k[1]},...Object.fromEntries(I.points.slice(1,-1).map(([T,R],O)=>{const U=ze();return[U,{id:U,type:"vertex",index:M[O+1],x:T,y:R}]}))}}});break}case"arrow":{let _="";if(I.boundElements!==null){for(const O of I.boundElements)if(O.type==="text"){const U=r.find(N=>N.id===O.id);U&&(_=U.text)}}const k=I.points[0],M=I.points[I.points.length-1],T=c.get((w=I.startBinding)==null?void 0:w.elementId),R=c.get((C=I.endBinding)==null?void 0:C.elementId);s.shapes.push({...E,type:"arrow",props:{text:_,bend:Kq(I,k,M),dash:Xd(I),size:Yd[I.strokeWidth]??"m",color:Kl[I.strokeColor]??"black",start:T?{type:"binding",boundShapeId:T,normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1}:{type:"point",x:k[0],y:k[1]},end:R?{type:"binding",boundShapeId:R,normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1}:{type:"point",x:M[0],y:M[1]},arrowheadEnd:GC[I.endArrowhead]??"none",arrowheadStart:GC[I.startArrowhead]??"none"}});break}case"text":{const{size:_,scale:k}=zq(I.fontSize);s.shapes.push({...E,type:"text",props:{size:_,scale:k,font:Bq[I.fontFamily]??"draw",color:Kl[I.strokeColor]??"black",text:I.text,align:WC[I.textAlign]}});break}case"image":{const _=o[I.fileId];if(!_)break;const k=li.createId();s.assets.push({id:k,typeName:"asset",type:"image",props:{w:I.width,h:I.height,name:I.id??"Untitled",isAnimated:!1,mimeType:_.mimeType,src:_.dataURL},meta:{}}),s.shapes.push({...E,type:"image",props:{w:I.width,h:I.height,assetId:k}})}}h=ko(h)}const f=t??(e.inputs.shiftKey?e.inputs.currentPagePoint:void 0);e.mark("paste"),e.putContentOntoCurrentPage(s,{point:f,select:!1,preserveIds:!0});for(const I of i.values())if(I.length>1){e.groupShapes(I);const P=e.getShape(I[0]);P!=null&&P.parentId&&Hn(P.parentId)&&u.push(P.parentId)}for(const[I,P]of a)e.select(I),e.rotateShapesBy([I],P);const y=ge(u.map(I=>e.getShape(I))),g=ne.Common(y.map(I=>e.getShapePageBounds(I))),v=e.getViewportPageBounds().center;e.updateShapes(y.map(I=>{const P={x:(I.x??0)-(g.x+g.w/2),y:(I.y??0)-(g.y+g.h/2)};return{id:I.id,type:I.type,x:v.x+P.x,y:v.y+P.y}})),e.setSelectedShapes(u)}const Nq=e=>{const n=e/100;return n<.2?.1:n<.4?.25:n<.6?.5:n<.8?.75:1},Yd={1:"s",2:"m",3:"l",4:"xl"},Fq={16:"s",20:"m",28:"l",36:"xl"};function zq(e){const n=Fq[e];return n?{size:n,scale:1}:e<16?{size:"s",scale:e/16}:e>36?{size:"xl",scale:e/36}:{size:"m",scale:1}}const Bq={1:"draw",2:"sans",3:"mono"},Kl={"#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"},Uq={solid:"draw",dashed:"dashed",dotted:"dotted"},Hq={"cross-hatch":"pattern",hachure:"pattern",solid:"solid"},WC={left:"start",center:"middle",right:"end"},GC={arrow:"arrow",dot:"dot",triangle:"triangle",bar:"pipe"};function Kq(e,n,t){let r=0;if(e.points.length>2){const o=new b(n[0],n[1]),s=new b(t[0],t[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),d=b.Add(c,l),h=b.NearestPointOnLineSegment(u,d,i,!1);r=b.Dist(h,c),b.Clockwise(h,s,c)&&(r*=-1)}return r}const Xd=e=>{let n=Uq[e.strokeStyle]??"draw";return n==="draw"&&e.roughness===0&&(n="solid"),n},Vq=e=>e.backgroundColor==="transparent"?"none":Hq[e.fillStyle]??"solid";async function RM(e,n,t,r){const s=(await Promise.all(n.map(async i=>await(await fetch(i)).blob()))).map(i=>new File([i],"tldrawFile",{type:i.type}));e.mark("paste"),await e.putExternalContent({type:"files",files:s,point:t,ignoreParent:!1,sources:r}),n.forEach(i=>URL.revokeObjectURL(i))}function Wq(e,n,t){const r=t??(e.inputs.shiftKey?e.inputs.currentPagePoint:void 0),o=e.getSelectionPageBounds();e.mark("paste"),e.putContentOntoCurrentPage(n,{point:r,select:!0});const s=e.getSelectionPageBounds();o&&s&&(o!=null&&o.collides(s))&&(e.updateInstanceState({isChangingStyle:!0},{ephemeral:!0}),setTimeout(()=>{e.updateInstanceState({isChangingStyle:!1},{ephemeral:!0})},150))}async function fv(e,n,t,r){var o;try{if(new URL(n).pathname.match(/\.(png|jpe?g|gif|svg|webp)$/i)&&(o=(await fetch(n,{method:"HEAD"})).headers.get("content-type"))!=null&&o.match(/^image\//)){e.mark("paste"),RM(e,[n]);return}}catch(s){s.message!=="Failed to fetch"&&console.error(s)}return e.mark("paste"),await e.putExternalContent({type:"url",point:t,url:n,sources:r})}function Gq(e){const n=document.implementation.createHTMLDocument("");return n.documentElement.innerHTML=e.trim(),n.body.textContent||n.body.innerText||""}const Yq=e=>{try{const n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}},Xq=e=>{const n=e.split(/[\n\s]/);for(const t of n)try{const r=new URL(t);if(!(r.protocol==="http:"||r.protocol==="https:"))return}catch{return}return HE(n)},qq=e=>/^<svg/.test(e),Zq=["input","select","textarea"];function Zh(e){const{activeElement:n}=document;return e.getIsMenuOpen()||n&&(n.getAttribute("contenteditable")||Zq.indexOf(n.tagName.toLowerCase())>-1)}async function ty(e){return new Promise((n,t)=>{const r=new FileReader;r.addEventListener("loadend",()=>{const o=r.result;n(o)}),r.addEventListener("error",()=>{t(r.error)}),r.readAsText(e)})}const Qq=e=>e.types.find(n=>n.match(/^image\//)),ny=(e,n,t,r)=>{const o=Xq(n);if(o)for(const s of o)fv(e,s,t);else Yq(n)?fv(e,n,t):qq(n)?(e.mark("paste"),e.putExternalContent({type:"svg-text",text:n,point:t,sources:r})):(e.mark("paste"),e.putExternalContent({type:"text",text:n,point:t,sources:r}))},Jq=async(e,n,t)=>{if(e.getEditingShapeId()!==null)return;if(!n)throw Error("No clipboard data");const r=[];for(const o of Object.values(n.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}}NM(e,r,t)},LM=async(e,n,t)=>{const r=[];for(const o of n){if(Qq(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:new Promise(s=>o.getType("text/html").then(i=>ty(i).then(s)))}),o.types.includes("text/uri-list")&&r.push({type:"url",source:new Promise(s=>o.getType("text/uri-list").then(i=>ty(i).then(s)))}),o.types.includes("text/plain")&&r.push({type:"text",source:new Promise(s=>o.getType("text/plain").then(i=>ty(i).then(s)))})}return await NM(e,r,t)};async function NM(e,n,t){const r=n.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 RM(e,i,t)}const o=await Promise.all(n.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(/<tldraw[^>]*>(.*)<\/tldraw>/))==null?void 0:u[1];if(c)try{const d=DM.decompressFromBase64(c);if(d===null){i({type:"error",data:d,reason:"found tldraw data comment but could not parse base64"});return}else{const h=JSON.parse(d);if(h.type!=="application/tldraw"&&i({type:"error",data:h,reason:`found tldraw data comment but JSON was of a different type: ${h.type}`}),typeof h.data=="string"){i({type:"error",data:h,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}i({type:"tldraw",data:h.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 d=JSON.parse(l);if(d.type==="excalidraw/clipboard"){i({type:"excalidraw",data:d});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"){Wq(e,s.data,t);return}for(const s of o)if(s.type==="excalidraw"){Lq(e,s.data,t);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");ny(e,c,t,o);return}if(!o.some(c=>c.type==="text"&&c.subtype!=="html")&&s.data.trim()){ny(e,Gq(s.data),t,o);return}}for(const s of o)if(s.type==="text"&&s.subtype==="url"){fv(e,s.data,t,o);return}for(const s of o)if(s.type==="text"&&s.subtype==="text"&&s.data.trim()){ny(e,s.data,t,o);return}}const sf=e=>{var r;const n=e.getContentFromCurrentPage(e.getSelectedShapeIds());if(!n){navigator&&navigator.clipboard&&navigator.clipboard.writeText("");return}const t=DM.compressToBase64(JSON.stringify({type:"application/tldraw",kind:"content",data:n}));if(!(typeof navigator>"u")){const o=n.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(gD);if((r=navigator.clipboard)!=null&&r.write){const s=new Blob([`<tldraw>${t}</tldraw>`],{type:"text/html"});let i=o.join(" ");i===""&&(i=" "),navigator.clipboard.write([new ClipboardItem({"text/html":s,"text/plain":new Blob([i],{type:"text/plain"})})])}else navigator.clipboard.writeText&&navigator.clipboard.writeText(`<tldraw>${t}</tldraw>`)}};function eZ(){const e=F(),n=yo(),t=x.useCallback(function(i){e.getSelectedShapeIds().length!==0&&(sf(e),n("copy",{source:i}))},[e,n]),r=x.useCallback(function(i){e.getSelectedShapeIds().length!==0&&(sf(e),e.deleteShapes(e.getSelectedShapeIds()),n("cut",{source:i}))},[e,n]),o=x.useCallback(async function(i,a,l){e.getEditingShapeId()!==null||Zh(e)||(Array.isArray(i)&&i[0]instanceof ClipboardItem?(LM(e,i,l),n("paste",{source:"menu"})):navigator.clipboard.read().then(c=>{o(c,a,l)}))},[e,n]);return{copy:t,cut:r,paste:o}}function tZ(){const e=F(),n=yo(),t=K("editor.isFocused",()=>e.getInstanceState().isFocused,[e]);x.useEffect(()=>{if(!t)return;const r=()=>{e.getSelectedShapeIds().length===0||e.getEditingShapeId()!==null||Zh(e)||(sf(e),n("copy",{source:"kbd"}))};function o(){e.getSelectedShapeIds().length===0||e.getEditingShapeId()!==null||Zh(e)||(sf(e),e.deleteShapes(e.getSelectedShapeIds()),n("cut",{source:"kbd"}))}let s=!1;const i=l=>{l.button===1&&(s=!0,requestAnimationFrame(()=>{s=!1}))},a=l=>{if(s){l.stopPropagation();return}e.getEditingShapeId()!==null||Zh(e)||(l.clipboardData&&!e.inputs.shiftKey?Jq(e,l.clipboardData):navigator.clipboard.read().then(c=>{Array.isArray(c)&&c[0]instanceof ClipboardItem&&LM(e,c,e.inputs.currentPagePoint)}),n("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,n,t])}async function FM(e,n,t){const{type:r,quality:o,scale:s}=t,i=+e.getAttribute("width"),a=+e.getAttribute("height");let[l,c]=await $k(i*s,a*s);l=Math.floor(l),c=Math.floor(c);const u=l/i,d=await Xw(e),h=URL.createObjectURL(new Blob([d],{type:"image/svg+xml"})),f=await new Promise(v=>{const S=new Image;S.crossOrigin="anonymous",S.onload=async()=>{n&&await new Promise(I=>setTimeout(I,250));const w=document.createElement("canvas"),C=w.getContext("2d");w.width=l,w.height=c,C.imageSmoothingEnabled=!0,C.imageSmoothingQuality="high",C.drawImage(S,0,0,l,c),URL.revokeObjectURL(h),v(w)},S.onerror=()=>{v(null)},S.src=h});if(!f)return null;const y=await new Promise(v=>f.toBlob(S=>{(!S||Ft.throwToBlob.get())&&v(null),v(S)},"image/"+r,o));if(!y)return null;const g=new DataView(await y.arrayBuffer());return Qr.setPhysChunk(g,u,{type:"image/"+r})}async function Xw(e){const n=e.cloneNode(!0);e.setAttribute("width",+e.getAttribute("width")+""),e.setAttribute("height",+e.getAttribute("height")+"");const t=new FileReader,r=Array.from(n.querySelectorAll("image"));for(const s of r){const i=s.getAttribute("xlink:href");if(i&&!i.startsWith("data:")){const a=await(await fetch(i)).blob(),l=await new Promise((c,u)=>{t.onload=()=>c(t.result),t.onerror=()=>u(t.error),t.readAsDataURL(a)});s.setAttribute("xlink:href",l)}}return new XMLSerializer().serializeToString(n).replaceAll(" ","").replaceAll(/((\s|")[0-9]*\.[0-9]{2})([0-9]*)(\b|"|\))/g,"$1")}async function zM(e,n,t){const r=await e.getSvg(n!=null&&n.length?n:[...e.getCurrentPageShapeIds()],{scale:1,background:e.getInstanceState().exportBackground,...t});if(!r)throw new Error("Could not construct SVG.");return r}async function gv(e,n,t,r={}){switch(t){case"svg":return Xw(await zM(e,n,r));case"json":{const o=e.getContentFromCurrentPage(n);return JSON.stringify(o)}default:Ai(t)}}async function BM({editor:e,ids:n,format:t,opts:r={}}){switch(t){case"svg":return new Blob([await gv(e,n,"svg",r)],{type:"text/plain"});case"json":return new Blob([await gv(e,n,"json",r)],{type:"text/plain"});case"jpeg":case"png":case"webp":{const o=await FM(await zM(e,n,r),e.environment.isSafari,{type:t,quality:1,scale:2});if(!o)throw new Error("Could not construct image.");return o}default:Ai(t)}}const nZ={jpeg:"image/jpeg",png:"image/png",webp:"image/webp",json:"text/plain",svg:"text/plain"};function rZ(e,n,t,r={}){return{blobPromise:BM({editor:e,ids:n,format:t,opts:r}),mimeType:nZ[t]}}function oZ(e,n,t="svg",r={}){if(!window.navigator.clipboard)return Promise.reject(new Error("Copy not supported"));if(window.navigator.clipboard.write){const{blobPromise:o,mimeType:s}=rZ(e,n,t,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(t){case"json":case"svg":return sZ(async()=>gv(e,n,t,r));case"jpeg":case"png":throw new Error("Copy not supported");default:Ai(t)}}async function sZ(e){var n,t;await((t=(n=navigator.clipboard)==null?void 0:n.writeText)==null?void 0:t.call(n,await e()))}const UM=x.createContext({});function iZ({children:e}){const[n,t]=x.useState([]),r=x.useCallback(i=>{const a=i.id??ze();return t(l=>[...l.filter(c=>c.id!==i.id),{...i,id:a}]),a},[]),o=x.useCallback(i=>(t(a=>a.filter(l=>l.id!==i)),i),[]),s=x.useCallback(()=>{t(()=>[])},[]);return p.jsx(UM.Provider,{value:{toasts:n,addToast:r,removeToast:o,clearToasts:s},children:e})}function Wr(){const e=x.useContext(UM);if(!e)throw new Error("useToasts must be used within a ToastsProvider");return e}function aZ(){const e=F(),{addToast:n}=Wr(),t=Ee();return x.useCallback((r,o="svg")=>{oZ(e,r,o).catch(()=>{n({id:"copy-fail",icon:"warning-triangle",title:t("toast.error.copy-fail.title"),description:t("toast.error.copy-fail.desc")})})},[e,n,t])}async function lZ(e,n,t="png",r,o={}){if(!r&&(r=`shapes at ${YC()}`,n.length===1)){const a=e.getShape(n[0]);e.isShapeOfType(a,"frame")?r=a.props.name??"frame":r=`${a.id.replace(/:/,"_")} at ${YC()}`}r+=`.${t}`;const s=await BM({editor:e,ids:n,format:t,opts:o}),i=new File([s],r,{type:s.type});cZ(i)}function YC(){const e=new Date,n=String(e.getFullYear()).slice(2),t=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`${n}-${t}-${r} ${o}.${s}.${i}`}function cZ(e){const n=document.createElement("a"),t=URL.createObjectURL(e);n.href=t,n.download=e.name,n.click(),URL.revokeObjectURL(t)}function uZ(){const e=F(),{addToast:n}=Wr(),t=Ee();return x.useCallback((r,o="png",s)=>{lZ(e,r,o,s,{scale:1,background:e.getInstanceState().exportBackground}).catch(i=>{console.error(i.message),n({id:"export-fail",title:t("toast.error.export-fail.title"),description:t("toast.error.export-fail.desc")})})},[e,n,t])}function HM(){const e=F(),n=x.useRef();return x.useEffect(()=>{const t=window.document.createElement("input");t.type="file",t.accept="image/jpeg,image/png,image/gif,image/svg+xml,video/mp4,video/quicktime",t.multiple=!0,n.current=t;async function r(o){const s=o.target.files;!s||s.length===0||(await e.putExternalContent({type:"files",files:Array.from(s),point:e.getViewportPageBounds().center,ignoreParent:!1}),t.value="")}return t.addEventListener("change",r),()=>{n.current=void 0,t.removeEventListener("change",r)}},[e]),x.useCallback(()=>{var t;(t=n.current)==null||t.click()},[n])}function dZ(){const e=F(),n=x.useRef(null),t=x.useRef(null);return x.useCallback(async function(){const o=document.createElement("div"),s=document.createElement("style"),i=(S,w)=>{S&&(S.innerHTML=""),w&&document.head.contains(w)&&document.head.removeChild(w),S&&document.body.contains(S)&&document.body.removeChild(S)};i(n.current,t.current),n.current=o,t.current=s;const a=`tl-print-surface-${ze()}`;o.className=a,s.innerHTML=`
|
|
238
|
+
.${a} {
|
|
239
|
+
display: none;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.${a} svg {
|
|
243
|
+
max-width: 100%;
|
|
244
|
+
height: 100%;
|
|
245
|
+
display: block;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@media print {
|
|
249
|
+
html, body {
|
|
250
|
+
min-height: 100%;
|
|
251
|
+
height: 100%;
|
|
252
|
+
margin: 0;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
body {
|
|
256
|
+
position: relative;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
body > * {
|
|
260
|
+
display: none;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.tldraw__editor {
|
|
264
|
+
display: none;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.${a} {
|
|
268
|
+
display: block !important;
|
|
269
|
+
background: white;
|
|
270
|
+
min-height: 100%;
|
|
271
|
+
height: 100%;
|
|
272
|
+
max-width: 100%;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.${a}__item {
|
|
276
|
+
padding: 10mm;
|
|
277
|
+
display: flex;
|
|
278
|
+
min-height: 100%;
|
|
279
|
+
flex-direction: column;
|
|
280
|
+
page-break-after: always;
|
|
281
|
+
position: relative;
|
|
282
|
+
overflow: hidden;
|
|
283
|
+
height: 100%;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.${a}__item__main {
|
|
287
|
+
flex: 1;
|
|
288
|
+
display: flex;
|
|
289
|
+
align-items: center;
|
|
290
|
+
justify-content: center;
|
|
291
|
+
max-height: 100%;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.${a}__item__header {
|
|
295
|
+
display: none;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.${a}__item__footer {
|
|
299
|
+
display: none;
|
|
300
|
+
text-align: right;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.${a}__item__footer__hide {
|
|
304
|
+
display: none;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
`;const l=()=>{document.head.appendChild(s),document.body.appendChild(o)},c=()=>{e.once("change-history",()=>{i(o,s)})};window.addEventListener("beforeprint",l),window.addEventListener("afterprint",c);function u(S,w,C){try{o.innerHTML+=`<div class="${a}__item">
|
|
311
|
+
<div class="${a}__item__header">
|
|
312
|
+
${S.replace(/</g,"<").replace(/>/g,">")}
|
|
313
|
+
</div>
|
|
314
|
+
<div class="${a}__item__main">
|
|
315
|
+
${C.outerHTML}
|
|
316
|
+
</div>
|
|
317
|
+
<div class="${a}__item__footer ${a}__item__footer__${w?"":"hide"}">
|
|
318
|
+
${w??""}
|
|
319
|
+
</div>
|
|
320
|
+
</div>`}catch(I){console.error(I)}}function d(){e.environment.isChromeForIos?(l(),window.print()):e.environment.isSafari?(l(),document.execCommand("print",!1)):window.print()}const h=e.getSelectedShapeIds(),f=e.getCurrentPageId(),y=e.getPages(),v={scale:1,background:!1,darkMode:!1,preserveAspectRatio:"xMidYMid meet"};if(e.getSelectedShapeIds().length>0){const S=await e.getSvg(h,v);if(S){const w=y.find(C=>C.id===f);u(`tldraw — ${w==null?void 0:w.name}`,null,S),d()}}else{const S=e.getCurrentPage(),w=await e.getSvg(e.getSortedChildIdsForParent(S.id),v);w&&(u(`tldraw — ${S.name}`,null,w),d())}window.removeEventListener("beforeprint",l),window.removeEventListener("afterprint",c)},[e])}const KM=x.createContext({});function hZ({children:e}){const n=F(),t=yo(),[r,o]=x.useState([]),s=x.useCallback(c=>{const u=c.id??ze();return o(d=>[...d.filter(h=>h.id!==c.id),{...c,id:u}]),t("open-menu",{source:"dialog",id:u}),n.addOpenMenu(u),u},[n,t]),i=x.useCallback((c,u)=>(o(d=>d.map(h=>h.id===c?{...h,...u}:h)),t("open-menu",{source:"dialog",id:c}),n.addOpenMenu(c),c),[n,t]),a=x.useCallback(c=>(o(u=>u.filter(d=>{var h;return d.id===c?((h=d.onClose)==null||h.call(d),!1):!0})),t("close-menu",{source:"dialog",id:c}),n.deleteOpenMenu(c),c),[n,t]),l=x.useCallback(()=>{o(c=>(c.forEach(u=>{var d;(d=u.onClose)==null||d.call(u),t("close-menu",{source:"dialog",id:u.id}),n.deleteOpenMenu(u.id)}),[]))},[n,t]);return p.jsx(KM.Provider,{value:{dialogs:r,addDialog:s,removeDialog:a,clearDialogs:l,updateDialog:i},children:e})}function zi(){const e=x.useContext(KM);if(!e)throw new Error("useDialogs must be used within a DialogsProvider");return e}const VM=x.createContext({});function pZ(e){return Object.fromEntries(e.map(n=>[n.id,n]))}function ca(e,n){if(e.getSelectedShapes().length===0)return e.getDocumentSettings().name||n}function fZ({overrides:e,children:n}){const t=F(),{addDialog:r,clearDialogs:o}=zi(),{clearToasts:s}=Wr(),i=Ee(),a=HM(),l=dZ(),{cut:c,copy:u,paste:d}=eZ(),h=aZ(),f=uZ(),y=i("document.default-name"),g=yo(),v=x.useMemo(()=>{function S(){return t.isIn("select")||(t.complete(),t.setCurrentTool("select")),!1}function w(){return t.isIn("select")&&t.getSelectedShapeIds().length>0}const I=pZ([{id:"edit-link",label:"action.edit-link",icon:"link",onSelect(P){w()&&(S()||(g("edit-link",{source:P}),t.mark("edit-link"),r({component:Dq})))}},{id:"insert-embed",label:"action.insert-embed",kbd:"$i",onSelect(P){g("insert-embed",{source:P}),r({component:OM})}},{id:"insert-media",label:"action.insert-media",kbd:"$u",onSelect(P){g("insert-media",{source:P}),a()}},{id:"undo",label:"action.undo",icon:"undo",kbd:"$z",onSelect(P){g("undo",{source:P}),t.undo()}},{id:"redo",label:"action.redo",icon:"redo",kbd:"$!z",onSelect(P){g("redo",{source:P}),t.redo()}},{id:"export-as-svg",label:{default:"action.export-as-svg",menu:"action.export-as-svg.short","context-menu":"action.export-as-svg.short"},readonlyOk:!0,onSelect(P){g("export-as",{format:"svg",source:P}),f(t.getSelectedShapeIds(),"svg",ca(t,y))}},{id:"export-as-png",label:{default:"action.export-as-png",menu:"action.export-as-png.short","context-menu":"action.export-as-png.short"},readonlyOk:!0,onSelect(P){g("export-as",{format:"png",source:P}),f(t.getSelectedShapeIds(),"png",ca(t,y))}},{id:"export-as-json",label:{default:"action.export-as-json",menu:"action.export-as-json.short","context-menu":"action.export-as-json.short"},readonlyOk:!0,onSelect(P){g("export-as",{format:"json",source:P}),f(t.getSelectedShapeIds(),"json",ca(t,y))}},{id:"export-all-as-svg",label:{default:"action.export-all-as-svg",menu:"action.export-all-as-svg.short","context-menu":"action.export-all-as-svg.short"},readonlyOk:!0,onSelect(P){g("export-all-as",{format:"svg",source:P}),f(Array.from(t.getCurrentPageShapeIds()),"svg",ca(t,y))}},{id:"export-all-as-png",label:{default:"action.export-all-as-png",menu:"action.export-all-as-png.short","context-menu":"action.export-all-as-png.short"},readonlyOk:!0,onSelect(P){g("export-all-as",{format:"png",source:P}),f(Array.from(t.getCurrentPageShapeIds()),"png",ca(t,y))}},{id:"export-all-as-json",label:{default:"action.export-all-as-json",menu:"action.export-all-as-json.short","context-menu":"action.export-all-as-json.short"},readonlyOk:!0,onSelect(P){g("export-all-as",{format:"json",source:P}),f(Array.from(t.getCurrentPageShapeIds()),"json",ca(t,y))}},{id:"copy-as-svg",label:{default:"action.copy-as-svg",menu:"action.copy-as-svg.short","context-menu":"action.copy-as-svg.short"},kbd:"$!c",readonlyOk:!0,onSelect(P){g("copy-as",{format:"svg",source:P}),h(t.getSelectedShapeIds(),"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(P){g("copy-as",{format:"png",source:P}),h(t.getSelectedShapeIds(),"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(P){g("copy-as",{format:"json",source:P}),h(t.getSelectedShapeIds(),"json")}},{id:"toggle-auto-size",label:"action.toggle-auto-size",onSelect(P){w()&&(S()||(g("toggle-auto-size",{source:P}),t.mark("toggling auto size"),t.updateShapes(t.getSelectedShapes().filter(E=>t.isShapeOfType(E,"text")&&E.props.autoSize===!1).map(E=>({id:E.id,type:E.type,props:{...E.props,w:8,autoSize:!0}})))))}},{id:"open-embed-link",label:"action.open-embed-link",readonlyOk:!0,onSelect(P){g("open-embed-link",{source:P});const E=t.getSelectedShapeIds(),_="No embed shapes selected";if(E.length!==1){console.error(_);return}const k=t.getShape(E[0]);if(!k||!t.isShapeOfType(k,"embed")){console.error(_);return}AF(k.props.url,"_blank")}},{id:"select-zoom-tool",readonlyOk:!0,kbd:"z",onSelect(P){var E,_;if(((E=t.root.getCurrent())==null?void 0:E.id)!=="zoom"&&(g("zoom-tool",{source:P}),!(t.inputs.shiftKey||t.inputs.ctrlKey))){const k=t.root.getCurrent();k&&((_=k.getCurrent())==null?void 0:_.id)==="idle"&&t.setCurrentTool("zoom",{onInteractionEnd:k.id,maskAs:"zoom"})}}},{id:"convert-to-bookmark",label:"action.convert-to-bookmark",onSelect(P){w()&&(S()||t.batch(()=>{g("convert-to-bookmark",{source:P});const E=t.getSelectedShapes(),_=[],k=[];for(const M of E){if(!M||!t.isShapeOfType(M,"embed")||!M.props.url)continue;const T=new b(M.x,M.y);T.rot(-M.rotation),T.add(new b(M.props.w/2-300/2,M.props.h/2-320/2)),T.rot(M.rotation);const R={id:We(),type:"bookmark",rotation:M.rotation,x:T.x,y:T.y,opacity:1,props:{url:M.props.url}};_.push(R),k.push(M.id)}t.mark("convert shapes to bookmark"),t.deleteShapes(k),t.createShapes(_)}))}},{id:"convert-to-embed",label:"action.convert-to-embed",onSelect(P){w()&&(S()||(g("convert-to-embed",{source:P}),t.batch(()=>{const E=t.getSelectedShapeIds(),_=ge(E.map(T=>t.getShape(T))),k=[],M=[];for(const T of _){if(!t.isShapeOfType(T,"bookmark"))continue;const{url:R}=T.props,O=Ao(T.props.url);if(!O||!O.definition)continue;const{width:U,height:N}=O.definition,L=new b(T.x,T.y);L.rot(-T.rotation),L.add(new b(T.props.w/2-U/2,T.props.h/2-N/2)),L.rot(T.rotation);const G={id:We(),type:"embed",x:L.x,y:L.y,rotation:T.rotation,props:{url:R,w:U,h:N}};k.push(G),M.push(T.id)}t.mark("convert shapes to embed"),t.deleteShapes(M),t.createShapes(k)})))}},{id:"duplicate",kbd:"$d",label:"action.duplicate",icon:"duplicate",onSelect(P){if(!w()||S())return;g("duplicate-shapes",{source:P});const E=t.getInstanceState();let _,k;if(E.duplicateProps)_=E.duplicateProps.shapeIds,k=E.duplicateProps.offset;else{_=t.getSelectedShapeIds();const M=ne.Common(ge(_.map(T=>t.getShapePageBounds(T))));k=E.canMoveCamera?{x:M.width+10,y:0}:{x:16/t.getZoomLevel(),y:16/t.getZoomLevel()}}t.mark("duplicate shapes"),t.duplicateShapes(_,k),E.duplicateProps&&t.updateInstanceState({duplicateProps:{...E.duplicateProps,shapeIds:t.getSelectedShapeIds()}})}},{id:"ungroup",label:"action.ungroup",kbd:"$!g",icon:"ungroup",onSelect(P){w()&&(S()||(g("ungroup-shapes",{source:P}),t.mark("ungroup"),t.ungroupShapes(t.getSelectedShapeIds())))}},{id:"group",label:"action.group",kbd:"$g",icon:"group",onSelect(P){if(!w()||S())return;g("group-shapes",{source:P});const E=t.getOnlySelectedShape();E&&t.isShapeOfType(E,"group")?(t.mark("ungroup"),t.ungroupShapes(t.getSelectedShapeIds())):(t.mark("group"),t.groupShapes(t.getSelectedShapeIds()))}},{id:"remove-frame",label:"action.remove-frame",kbd:"$!f",onSelect(P){if(!w())return;g("remove-frame",{source:P});const E=t.getSelectedShapes();E.length>0&&E.every(_=>t.isShapeOfType(_,"frame"))&&(t.mark("remove-frame"),gq(t,E.map(_=>_.id)))}},{id:"fit-frame-to-content",label:"action.fit-frame-to-content",onSelect(P){if(!w())return;g("fit-frame-to-content",{source:P});const E=t.getOnlySelectedShape();E&&t.isShapeOfType(E,"frame")&&(t.mark("fit-frame-to-content"),yq(t,E.id))}},{id:"align-left",label:"action.align-left",kbd:"?A",icon:"align-left",onSelect(P){w()&&(S()||(g("align-shapes",{operation:"left",source:P}),t.mark("align left"),t.alignShapes(t.getSelectedShapeIds(),"left")))}},{id:"align-center-horizontal",label:{default:"action.align-center-horizontal","context-menu":"action.align-center-horizontal.short"},kbd:"?H",icon:"align-center-horizontal",onSelect(P){w()&&(S()||(g("align-shapes",{operation:"center-horizontal",source:P}),t.mark("align center horizontal"),t.alignShapes(t.getSelectedShapeIds(),"center-horizontal")))}},{id:"align-right",label:"action.align-right",kbd:"?D",icon:"align-right",onSelect(P){w()&&(S()||(g("align-shapes",{operation:"right",source:P}),t.mark("align right"),t.alignShapes(t.getSelectedShapeIds(),"right")))}},{id:"align-center-vertical",label:{default:"action.align-center-vertical","context-menu":"action.align-center-vertical.short"},kbd:"?V",icon:"align-center-vertical",onSelect(P){w()&&(S()||(g("align-shapes",{operation:"center-vertical",source:P}),t.mark("align center vertical"),t.alignShapes(t.getSelectedShapeIds(),"center-vertical")))}},{id:"align-top",label:"action.align-top",icon:"align-top",kbd:"?W",onSelect(P){w()&&(S()||(g("align-shapes",{operation:"top",source:P}),t.mark("align top"),t.alignShapes(t.getSelectedShapeIds(),"top")))}},{id:"align-bottom",label:"action.align-bottom",icon:"align-bottom",kbd:"?S",onSelect(P){w()&&(S()||(g("align-shapes",{operation:"bottom",source:P}),t.mark("align bottom"),t.alignShapes(t.getSelectedShapeIds(),"bottom")))}},{id:"distribute-horizontal",label:{default:"action.distribute-horizontal","context-menu":"action.distribute-horizontal.short"},icon:"distribute-horizontal",kbd:"?!h",onSelect(P){w()&&(S()||(g("distribute-shapes",{operation:"horizontal",source:P}),t.mark("distribute horizontal"),t.distributeShapes(t.getSelectedShapeIds(),"horizontal")))}},{id:"distribute-vertical",label:{default:"action.distribute-vertical","context-menu":"action.distribute-vertical.short"},icon:"distribute-vertical",kbd:"?!V",onSelect(P){w()&&(S()||(g("distribute-shapes",{operation:"vertical",source:P}),t.mark("distribute vertical"),t.distributeShapes(t.getSelectedShapeIds(),"vertical")))}},{id:"stretch-horizontal",label:{default:"action.stretch-horizontal","context-menu":"action.stretch-horizontal.short"},icon:"stretch-horizontal",onSelect(P){w()&&(S()||(g("stretch-shapes",{operation:"horizontal",source:P}),t.mark("stretch horizontal"),t.stretchShapes(t.getSelectedShapeIds(),"horizontal")))}},{id:"stretch-vertical",label:{default:"action.stretch-vertical","context-menu":"action.stretch-vertical.short"},icon:"stretch-vertical",onSelect(P){w()&&(S()||(g("stretch-shapes",{operation:"vertical",source:P}),t.mark("stretch vertical"),t.stretchShapes(t.getSelectedShapeIds(),"vertical")))}},{id:"flip-horizontal",label:{default:"action.flip-horizontal","context-menu":"action.flip-horizontal.short"},kbd:"!h",onSelect(P){w()&&(S()||(g("flip-shapes",{operation:"horizontal",source:P}),t.mark("flip horizontal"),t.flipShapes(t.getSelectedShapeIds(),"horizontal")))}},{id:"flip-vertical",label:{default:"action.flip-vertical","context-menu":"action.flip-vertical.short"},kbd:"!v",onSelect(P){w()&&(S()||(g("flip-shapes",{operation:"vertical",source:P}),t.mark("flip vertical"),t.flipShapes(t.getSelectedShapeIds(),"vertical")))}},{id:"pack",label:"action.pack",icon:"pack",onSelect(P){w()&&(S()||(g("pack-shapes",{source:P}),t.mark("pack"),t.packShapes(t.getSelectedShapeIds(),16)))}},{id:"stack-vertical",label:{default:"action.stack-vertical","context-menu":"action.stack-vertical.short"},icon:"stack-vertical",onSelect(P){w()&&(S()||(g("stack-shapes",{operation:"vertical",source:P}),t.mark("stack-vertical"),t.stackShapes(t.getSelectedShapeIds(),"vertical",16)))}},{id:"stack-horizontal",label:{default:"action.stack-horizontal","context-menu":"action.stack-horizontal.short"},icon:"stack-horizontal",onSelect(P){w()&&(S()||(g("stack-shapes",{operation:"horizontal",source:P}),t.mark("stack-horizontal"),t.stackShapes(t.getSelectedShapeIds(),"horizontal",16)))}},{id:"bring-to-front",label:"action.bring-to-front",kbd:"]",icon:"bring-to-front",onSelect(P){w()&&(S()||(g("reorder-shapes",{operation:"toFront",source:P}),t.mark("bring to front"),t.bringToFront(t.getSelectedShapeIds())))}},{id:"bring-forward",label:"action.bring-forward",icon:"bring-forward",kbd:"?]",onSelect(P){w()&&(S()||(g("reorder-shapes",{operation:"forward",source:P}),t.mark("bring forward"),t.bringForward(t.getSelectedShapeIds())))}},{id:"send-backward",label:"action.send-backward",icon:"send-backward",kbd:"?[",onSelect(P){w()&&(S()||(g("reorder-shapes",{operation:"backward",source:P}),t.mark("send backward"),t.sendBackward(t.getSelectedShapeIds())))}},{id:"send-to-back",label:"action.send-to-back",icon:"send-to-back",kbd:"[",onSelect(P){w()&&(S()||(g("reorder-shapes",{operation:"toBack",source:P}),t.mark("send to back"),t.sendToBack(t.getSelectedShapeIds())))}},{id:"cut",label:"action.cut",kbd:"$x",onSelect(P){w()&&(S()||(t.mark("cut"),c(P)))}},{id:"copy",label:"action.copy",kbd:"$c",readonlyOk:!0,onSelect(P){w()&&(S()||u(P))}},{id:"paste",label:"action.paste",kbd:"$v",onSelect(P){var E;(E=navigator.clipboard)==null||E.read().then(_=>{d(_,P,P==="context-menu"?t.inputs.currentPagePoint:void 0)})}},{id:"select-all",label:"action.select-all",kbd:"$a",readonlyOk:!0,onSelect(P){t.batch(()=>{S()||(g("select-all-shapes",{source:P}),t.mark("select all kbd"),t.selectAll())})}},{id:"select-none",label:"action.select-none",readonlyOk:!0,onSelect(P){w()&&(S()||(g("select-none-shapes",{source:P}),t.mark("select none"),t.selectNone()))}},{id:"delete",label:"action.delete",kbd:"⌫,del,backspace",icon:"trash",onSelect(P){w()&&(S()||(g("delete-shapes",{source:P}),t.mark("delete"),t.deleteShapes(t.getSelectedShapeIds())))}},{id:"rotate-cw",label:"action.rotate-cw",icon:"rotate-cw",onSelect(P){if(!w()||S())return;g("rotate-cw",{source:P}),t.mark("rotate-cw");const E=t.getSelectionRotation()%(Ke/2),_=ic(E,0)||ic(E,Ke/2);t.rotateShapesBy(t.getSelectedShapeIds(),Ke/2-(_?0:E))}},{id:"rotate-ccw",label:"action.rotate-ccw",icon:"rotate-ccw",onSelect(P){if(!w()||S())return;g("rotate-ccw",{source:P}),t.mark("rotate-ccw");const E=t.getSelectionRotation()%(Ke/2),_=ic(E,0);t.rotateShapesBy(t.getSelectedShapeIds(),_?-(Ke/2):-E)}},{id:"zoom-in",label:"action.zoom-in",kbd:"$=,=",readonlyOk:!0,onSelect(P){g("zoom-in",{source:P}),t.zoomIn(t.getViewportScreenCenter(),{duration:Mo})}},{id:"zoom-out",label:"action.zoom-out",kbd:"$-,-",readonlyOk:!0,onSelect(P){g("zoom-out",{source:P}),t.zoomOut(t.getViewportScreenCenter(),{duration:Mo})}},{id:"zoom-to-100",label:"action.zoom-to-100",icon:"reset-zoom",kbd:"!0",readonlyOk:!0,onSelect(P){g("reset-zoom",{source:P}),t.resetZoom(t.getViewportScreenCenter(),{duration:Mo})}},{id:"zoom-to-fit",label:"action.zoom-to-fit",kbd:"!1",readonlyOk:!0,onSelect(P){g("zoom-to-fit",{source:P}),t.zoomToFit({duration:Mo})}},{id:"zoom-to-selection",label:"action.zoom-to-selection",kbd:"!2",readonlyOk:!0,onSelect(P){w()&&(S()||(g("zoom-to-selection",{source:P}),t.zoomToSelection({duration:Mo})))}},{id:"toggle-snap-mode",label:{default:"action.toggle-snap-mode",menu:"action.toggle-snap-mode.menu"},onSelect(P){g("toggle-snap-mode",{source:P}),t.user.updateUserPreferences({isSnapMode:!t.user.getIsSnapMode()})},checkbox:!0},{id:"toggle-dark-mode",label:{default:"action.toggle-dark-mode",menu:"action.toggle-dark-mode.menu"},kbd:"$/",readonlyOk:!0,onSelect(P){g("toggle-dark-mode",{source:P}),t.user.updateUserPreferences({isDarkMode:!t.user.getIsDarkMode()})},checkbox:!0},{id:"toggle-wrap-mode",label:{default:"action.toggle-wrap-mode",menu:"action.toggle-wrap-mode.menu"},readonlyOk:!0,onSelect(P){g("toggle-wrap-mode",{source:P}),t.user.updateUserPreferences({isWrapMode:!t.user.getIsWrapMode()})},checkbox:!0},{id:"toggle-reduce-motion",label:{default:"action.toggle-reduce-motion",menu:"action.toggle-reduce-motion.menu"},readonlyOk:!0,onSelect(P){g("toggle-reduce-motion",{source:P}),t.user.updateUserPreferences({animationSpeed:t.user.getAnimationSpeed()===0?1:0})},checkbox:!0},{id:"toggle-edge-scrolling",label:{default:"action.toggle-edge-scrolling",menu:"action.toggle-edge-scrolling.menu"},readonlyOk:!0,onSelect(P){g("toggle-edge-scrolling",{source:P}),t.user.updateUserPreferences({edgeScrollSpeed:t.user.getEdgeScrollSpeed()===0?1:0})},checkbox:!0},{id:"toggle-transparent",label:{default:"action.toggle-transparent",menu:"action.toggle-transparent.menu","context-menu":"action.toggle-transparent.context-menu"},readonlyOk:!0,onSelect(P){g("toggle-transparent",{source:P}),t.updateInstanceState({exportBackground:!t.getInstanceState().exportBackground},{ephemeral:!0})},checkbox:!0},{id:"toggle-tool-lock",label:{default:"action.toggle-tool-lock",menu:"action.toggle-tool-lock.menu"},kbd:"q",onSelect(P){g("toggle-tool-lock",{source:P}),t.updateInstanceState({isToolLocked:!t.getInstanceState().isToolLocked})},checkbox:!0},{id:"unlock-all",label:"action.unlock-all",onSelect(P){g("unlock-all",{source:P});const E=[];for(const _ of t.getCurrentPageShapes())_.isLocked&&E.push({id:_.id,type:_.type,isLocked:!1});E.length>0&&t.updateShapes(E)}},{id:"toggle-focus-mode",label:{default:"action.toggle-focus-mode",menu:"action.toggle-focus-mode.menu"},readonlyOk:!0,kbd:"$.",checkbox:!0,onSelect(P){requestAnimationFrame(()=>{t.batch(()=>{g("toggle-focus-mode",{source:P}),o(),s(),t.updateInstanceState({isFocusMode:!t.getInstanceState().isFocusMode})})})}},{id:"toggle-grid",label:{default:"action.toggle-grid",menu:"action.toggle-grid.menu"},readonlyOk:!0,kbd:"$'",onSelect(P){g("toggle-grid-mode",{source:P}),t.updateInstanceState({isGridMode:!t.getInstanceState().isGridMode})},checkbox:!0},{id:"toggle-debug-mode",label:{default:"action.toggle-debug-mode",menu:"action.toggle-debug-mode.menu"},readonlyOk:!0,onSelect(P){g("toggle-debug-mode",{source:P}),t.updateInstanceState({isDebugMode:!t.getInstanceState().isDebugMode})},checkbox:!0},{id:"print",label:"action.print",kbd:"$p",readonlyOk:!0,onSelect(P){g("print",{source:P}),l()}},{id:"exit-pen-mode",label:"action.exit-pen-mode",icon:"cross-2",readonlyOk:!0,onSelect(P){g("exit-pen-mode",{source:P}),t.updateInstanceState({isPenMode:!1})}},{id:"stop-following",label:"action.stop-following",icon:"cross-2",readonlyOk:!0,onSelect(P){g("stop-following",{source:P}),t.stopFollowingUser()}},{id:"back-to-content",label:"action.back-to-content",icon:"arrow-left",readonlyOk:!0,onSelect(P){g("zoom-to-content",{source:P}),t.zoomToContent()}},{id:"toggle-lock",label:"action.toggle-lock",kbd:"!l",onSelect(P){t.mark("locking"),g("toggle-lock",{source:P}),t.toggleLock(t.getSelectedShapeIds())}},{id:"new-page",label:"context.pages.new-page",onSelect(P){const E=zo.createId(),_=t.getSelectedShapeIds();t.batch(()=>{t.mark("move_shapes_to_page"),t.createPage({name:i("page-menu.new-page-initial-name"),id:E}),t.moveShapesToPage(_,E)}),g("new-page",{source:P})}}]);return e?e(t,I,void 0):I},[t,g,e,r,a,f,h,c,u,d,o,s,l,i,y]);return p.jsx(VM.Provider,{value:v,children:n})}function le(){const e=x.useContext(VM);if(!e)throw new Error("useTools must be used within a ToolProvider");return e}function au(e,n){return e?typeof e=="string"?e:n?e[n]??e.default:void 0:void 0}const gZ=x.createContext(void 0);function qw(e){const n=x.useContext(gZ);return e||n||"ltr"}const ry="rovingFocusGroup.onEntryFocus",mZ={bubbles:!1,cancelable:!0},Zw="RovingFocusGroup",[mv,WM,yZ]=Wf(Zw),[SZ,GM]=go(Zw,[yZ]),[vZ,wZ]=SZ(Zw),xZ=x.forwardRef((e,n)=>x.createElement(mv.Provider,{scope:e.__scopeRovingFocusGroup},x.createElement(mv.Slot,{scope:e.__scopeRovingFocusGroup},x.createElement(bZ,Q({},e,{ref:n}))))),bZ=x.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:t,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,...u}=e,d=x.useRef(null),h=Ye(n,d),f=qw(s),[y=null,g]=Ws({prop:i,defaultProp:a,onChange:l}),[v,S]=x.useState(!1),w=on(c),C=WM(t),I=x.useRef(!1),[P,E]=x.useState(0);return x.useEffect(()=>{const _=d.current;if(_)return _.addEventListener(ry,w),()=>_.removeEventListener(ry,w)},[w]),x.createElement(vZ,{scope:t,orientation:r,dir:f,loop:o,currentTabStopId:y,onItemFocus:x.useCallback(_=>g(_),[g]),onItemShiftTab:x.useCallback(()=>S(!0),[]),onFocusableItemAdd:x.useCallback(()=>E(_=>_+1),[]),onFocusableItemRemove:x.useCallback(()=>E(_=>_-1),[])},x.createElement(Be.div,Q({tabIndex:v||P===0?-1:0,"data-orientation":r},u,{ref:h,style:{outline:"none",...e.style},onMouseDown:se(e.onMouseDown,()=>{I.current=!0}),onFocus:se(e.onFocus,_=>{const k=!I.current;if(_.target===_.currentTarget&&k&&!v){const M=new CustomEvent(ry,mZ);if(_.currentTarget.dispatchEvent(M),!M.defaultPrevented){const T=C().filter(L=>L.focusable),R=T.find(L=>L.active),O=T.find(L=>L.id===y),N=[R,O,...T].filter(Boolean).map(L=>L.ref.current);YM(N)}}I.current=!1}),onBlur:se(e.onBlur,()=>S(!1))})))}),PZ="RovingFocusGroupItem",CZ=x.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:t,focusable:r=!0,active:o=!1,tabStopId:s,...i}=e,a=Fo(),l=s||a,c=wZ(PZ,t),u=c.currentTabStopId===l,d=WM(t),{onFocusableItemAdd:h,onFocusableItemRemove:f}=c;return x.useEffect(()=>{if(r)return h(),()=>f()},[r,h,f]),x.createElement(mv.ItemSlot,{scope:t,id:l,focusable:r,active:o},x.createElement(Be.span,Q({tabIndex:u?0:-1,"data-orientation":c.orientation},i,{ref:n,onMouseDown:se(e.onMouseDown,y=>{r?c.onItemFocus(l):y.preventDefault()}),onFocus:se(e.onFocus,()=>c.onItemFocus(l)),onKeyDown:se(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){c.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const g=_Z(y,c.orientation,c.dir);if(g!==void 0){y.preventDefault();let S=d().filter(w=>w.focusable).map(w=>w.ref.current);if(g==="last")S.reverse();else if(g==="prev"||g==="next"){g==="prev"&&S.reverse();const w=S.indexOf(y.currentTarget);S=c.loop?kZ(S,w+1):S.slice(w+1)}setTimeout(()=>YM(S))}})})))}),IZ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function EZ(e,n){return n!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function _Z(e,n,t){const r=EZ(e.key,t);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return IZ[r]}function YM(e){const n=document.activeElement;for(const t of e)if(t===n||(t.focus(),document.activeElement!==n))return}function kZ(e,n){return e.map((t,r)=>e[(n+r)%e.length])}const TZ=xZ,$Z=CZ,yv=["Enter"," "],MZ=["ArrowDown","PageUp","Home"],XM=["ArrowUp","PageDown","End"],AZ=[...MZ,...XM],jZ={ltr:[...yv,"ArrowRight"],rtl:[...yv,"ArrowLeft"]},OZ={ltr:["ArrowLeft"],rtl:["ArrowRight"]},sg="Menu",[lu,DZ,RZ]=Wf(sg),[Bi,ig]=go(sg,[RZ,Jf,GM]),ag=Jf(),qM=GM(),[ZM,Ys]=Bi(sg),[LZ,Nu]=Bi(sg),NZ=e=>{const{__scopeMenu:n,open:t=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ag(n),[l,c]=x.useState(null),u=x.useRef(!1),d=on(s),h=qw(o);return x.useEffect(()=>{const f=()=>{u.current=!0,document.addEventListener("pointerdown",y,{capture:!0,once:!0}),document.addEventListener("pointermove",y,{capture:!0,once:!0})},y=()=>u.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",y,{capture:!0}),document.removeEventListener("pointermove",y,{capture:!0})}},[]),x.createElement(Fw,a,x.createElement(ZM,{scope:n,open:t,onOpenChange:d,content:l,onContentChange:c},x.createElement(LZ,{scope:n,onClose:x.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:h,modal:i},r)))},QM=x.forwardRef((e,n)=>{const{__scopeMenu:t,...r}=e,o=ag(t);return x.createElement(cM,Q({},o,r,{ref:n}))}),JM="MenuPortal",[FZ,eA]=Bi(JM,{forceMount:void 0}),zZ=e=>{const{__scopeMenu:n,forceMount:t,children:r,container:o}=e,s=Ys(JM,n);return x.createElement(FZ,{scope:n,forceMount:t},x.createElement(mo,{present:t||s.open},x.createElement(Yf,{asChild:!0,container:o},r)))},zr="MenuContent",[BZ,Qw]=Bi(zr),UZ=x.forwardRef((e,n)=>{const t=eA(zr,e.__scopeMenu),{forceMount:r=t.forceMount,...o}=e,s=Ys(zr,e.__scopeMenu),i=Nu(zr,e.__scopeMenu);return x.createElement(lu.Provider,{scope:e.__scopeMenu},x.createElement(mo,{present:r||s.open},x.createElement(lu.Slot,{scope:e.__scopeMenu},i.modal?x.createElement(HZ,Q({},o,{ref:n})):x.createElement(KZ,Q({},o,{ref:n})))))}),HZ=x.forwardRef((e,n)=>{const t=Ys(zr,e.__scopeMenu),r=x.useRef(null),o=Ye(n,r);return x.useEffect(()=>{const s=r.current;if(s)return zw(s)},[]),x.createElement(Jw,Q({},e,{ref:o,trapFocus:t.open,disableOutsidePointerEvents:t.open,disableOutsideScroll:!0,onFocusOutside:se(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>t.onOpenChange(!1)}))}),KZ=x.forwardRef((e,n)=>{const t=Ys(zr,e.__scopeMenu);return x.createElement(Jw,Q({},e,{ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>t.onOpenChange(!1)}))}),Jw=x.forwardRef((e,n)=>{const{__scopeMenu:t,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:f,disableOutsideScroll:y,...g}=e,v=Ys(zr,t),S=Nu(zr,t),w=ag(t),C=qM(t),I=DZ(t),[P,E]=x.useState(null),_=x.useRef(null),k=Ye(n,_,v.onContentChange),M=x.useRef(0),T=x.useRef(""),R=x.useRef(0),O=x.useRef(null),U=x.useRef("right"),N=x.useRef(0),L=y?Bw:x.Fragment,G=y?{as:Ei,allowPinchZoom:!0}:void 0,X=B=>{var W,Y;const J=T.current+B,ke=I().filter(Ue=>!Ue.disabled),ve=document.activeElement,pe=(W=ke.find(Ue=>Ue.ref.current===ve))===null||W===void 0?void 0:W.textValue,me=ke.map(Ue=>Ue.textValue),Xe=oQ(me,J,pe),Ae=(Y=ke.find(Ue=>Ue.textValue===Xe))===null||Y===void 0?void 0:Y.ref.current;(function Ue(yt){T.current=yt,window.clearTimeout(M.current),yt!==""&&(M.current=window.setTimeout(()=>Ue(""),1e3))})(J),Ae&&setTimeout(()=>Ae.focus())};x.useEffect(()=>()=>window.clearTimeout(M.current),[]),Mw();const H=x.useCallback(B=>{var W,Y;return U.current===((W=O.current)===null||W===void 0?void 0:W.side)&&iQ(B,(Y=O.current)===null||Y===void 0?void 0:Y.area)},[]);return x.createElement(BZ,{scope:t,searchRef:T,onItemEnter:x.useCallback(B=>{H(B)&&B.preventDefault()},[H]),onItemLeave:x.useCallback(B=>{var W;H(B)||((W=_.current)===null||W===void 0||W.focus(),E(null))},[H]),onTriggerLeave:x.useCallback(B=>{H(B)&&B.preventDefault()},[H]),pointerGraceTimerRef:R,onPointerGraceIntentChange:x.useCallback(B=>{O.current=B},[])},x.createElement(L,G,x.createElement(Aw,{asChild:!0,trapped:o,onMountAutoFocus:se(s,B=>{var W;B.preventDefault(),(W=_.current)===null||W===void 0||W.focus()}),onUnmountAutoFocus:i},x.createElement(Gf,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:f},x.createElement(TZ,Q({asChild:!0},C,{dir:S.dir,orientation:"vertical",loop:r,currentTabStopId:P,onCurrentTabStopIdChange:E,onEntryFocus:se(l,B=>{S.isUsingKeyboardRef.current||B.preventDefault()})}),x.createElement(uM,Q({role:"menu","aria-orientation":"vertical","data-state":sA(v.open),"data-radix-menu-content":"",dir:S.dir},w,g,{ref:k,style:{outline:"none",...g.style},onKeyDown:se(g.onKeyDown,B=>{const Y=B.target.closest("[data-radix-menu-content]")===B.currentTarget,J=B.ctrlKey||B.altKey||B.metaKey,ke=B.key.length===1;Y&&(B.key==="Tab"&&B.preventDefault(),!J&&ke&&X(B.key));const ve=_.current;if(B.target!==ve||!AZ.includes(B.key))return;B.preventDefault();const me=I().filter(Xe=>!Xe.disabled).map(Xe=>Xe.ref.current);XM.includes(B.key)&&me.reverse(),nQ(me)}),onBlur:se(e.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(M.current),T.current="")}),onPointerMove:se(e.onPointerMove,cu(B=>{const W=B.target,Y=N.current!==B.clientX;if(B.currentTarget.contains(W)&&Y){const J=B.clientX>N.current?"right":"left";U.current=J,N.current=B.clientX}}))})))))))}),VZ=x.forwardRef((e,n)=>{const{__scopeMenu:t,...r}=e;return x.createElement(Be.div,Q({role:"group"},r,{ref:n}))}),Sv="MenuItem",XC="menu.itemSelect",tA=x.forwardRef((e,n)=>{const{disabled:t=!1,onSelect:r,...o}=e,s=x.useRef(null),i=Nu(Sv,e.__scopeMenu),a=Qw(Sv,e.__scopeMenu),l=Ye(n,s),c=x.useRef(!1),u=()=>{const d=s.current;if(!t&&d){const h=new CustomEvent(XC,{bubbles:!0,cancelable:!0});d.addEventListener(XC,f=>r==null?void 0:r(f),{once:!0}),kw(d,h),h.defaultPrevented?c.current=!1:i.onClose()}};return x.createElement(nA,Q({},o,{ref:l,disabled:t,onClick:se(e.onClick,u),onPointerDown:d=>{var h;(h=e.onPointerDown)===null||h===void 0||h.call(e,d),c.current=!0},onPointerUp:se(e.onPointerUp,d=>{var h;c.current||(h=d.currentTarget)===null||h===void 0||h.click()}),onKeyDown:se(e.onKeyDown,d=>{const h=a.searchRef.current!=="";t||h&&d.key===" "||yv.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})}))}),nA=x.forwardRef((e,n)=>{const{__scopeMenu:t,disabled:r=!1,textValue:o,...s}=e,i=Qw(Sv,t),a=qM(t),l=x.useRef(null),c=Ye(n,l),[u,d]=x.useState(!1),[h,f]=x.useState("");return x.useEffect(()=>{const y=l.current;if(y){var g;f(((g=y.textContent)!==null&&g!==void 0?g:"").trim())}},[s.children]),x.createElement(lu.ItemSlot,{scope:t,disabled:r,textValue:o??h},x.createElement($Z,Q({asChild:!0},a,{focusable:!r}),x.createElement(Be.div,Q({role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0},s,{ref:c,onPointerMove:se(e.onPointerMove,cu(y=>{r?i.onItemLeave(y):(i.onItemEnter(y),y.defaultPrevented||y.currentTarget.focus())})),onPointerLeave:se(e.onPointerLeave,cu(y=>i.onItemLeave(y))),onFocus:se(e.onFocus,()=>d(!0)),onBlur:se(e.onBlur,()=>d(!1))}))))}),WZ=x.forwardRef((e,n)=>{const{checked:t=!1,onCheckedChange:r,...o}=e;return x.createElement(XZ,{scope:e.__scopeMenu,checked:t},x.createElement(tA,Q({role:"menuitemcheckbox","aria-checked":vv(t)?"mixed":t},o,{ref:n,"data-state":tQ(t),onSelect:se(o.onSelect,()=>r==null?void 0:r(vv(t)?!0:!t),{checkForDefaultPrevented:!1})})))}),GZ="MenuRadioGroup";Bi(GZ,{value:void 0,onValueChange:()=>{}});const YZ="MenuItemIndicator",[XZ,jne]=Bi(YZ,{checked:!1}),rA="MenuSub",[qZ,oA]=Bi(rA),ZZ=e=>{const{__scopeMenu:n,children:t,open:r=!1,onOpenChange:o}=e,s=Ys(rA,n),i=ag(n),[a,l]=x.useState(null),[c,u]=x.useState(null),d=on(o);return x.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),x.createElement(Fw,i,x.createElement(ZM,{scope:n,open:r,onOpenChange:d,content:c,onContentChange:u},x.createElement(qZ,{scope:n,contentId:Fo(),triggerId:Fo(),trigger:a,onTriggerChange:l},t)))},qd="MenuSubTrigger",QZ=x.forwardRef((e,n)=>{const t=Ys(qd,e.__scopeMenu),r=Nu(qd,e.__scopeMenu),o=oA(qd,e.__scopeMenu),s=Qw(qd,e.__scopeMenu),i=x.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=x.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return x.useEffect(()=>u,[u]),x.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),x.createElement(QM,Q({asChild:!0},c),x.createElement(nA,Q({id:o.triggerId,"aria-haspopup":"menu","aria-expanded":t.open,"aria-controls":o.contentId,"data-state":sA(t.open)},e,{ref:Vf(n,o.onTriggerChange),onClick:d=>{var h;(h=e.onClick)===null||h===void 0||h.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),t.open||t.onOpenChange(!0))},onPointerMove:se(e.onPointerMove,cu(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!t.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{t.onOpenChange(!0),u()},100))})),onPointerLeave:se(e.onPointerLeave,cu(d=>{var h;u();const f=(h=t.content)===null||h===void 0?void 0:h.getBoundingClientRect();if(f){var y;const g=(y=t.content)===null||y===void 0?void 0:y.dataset.side,v=g==="right",S=v?-5:5,w=f[v?"left":"right"],C=f[v?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+S,y:d.clientY},{x:w,y:f.top},{x:C,y:f.top},{x:C,y:f.bottom},{x:w,y:f.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:se(e.onKeyDown,d=>{const h=s.searchRef.current!=="";if(!(e.disabled||h&&d.key===" ")&&jZ[r.dir].includes(d.key)){var f;t.onOpenChange(!0),(f=t.content)===null||f===void 0||f.focus(),d.preventDefault()}})})))}),JZ="MenuSubContent",eQ=x.forwardRef((e,n)=>{const t=eA(zr,e.__scopeMenu),{forceMount:r=t.forceMount,...o}=e,s=Ys(zr,e.__scopeMenu),i=Nu(zr,e.__scopeMenu),a=oA(JZ,e.__scopeMenu),l=x.useRef(null),c=Ye(n,l);return x.createElement(lu.Provider,{scope:e.__scopeMenu},x.createElement(mo,{present:r||s.open},x.createElement(lu.Slot,{scope:e.__scopeMenu},x.createElement(Jw,Q({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 d;i.isUsingKeyboardRef.current&&((d=l.current)===null||d===void 0||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:se(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:se(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:se(e.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),h=OZ[i.dir].includes(u.key);if(d&&h){var f;s.onOpenChange(!1),(f=a.trigger)===null||f===void 0||f.focus(),u.preventDefault()}})})))))});function sA(e){return e?"open":"closed"}function vv(e){return e==="indeterminate"}function tQ(e){return vv(e)?"indeterminate":e?"checked":"unchecked"}function nQ(e){const n=document.activeElement;for(const t of e)if(t===n||(t.focus(),document.activeElement!==n))return}function rQ(e,n){return e.map((t,r)=>e[(n+r)%e.length])}function oQ(e,n,t){const o=n.length>1&&Array.from(n).every(c=>c===n[0])?n[0]:n,s=t?e.indexOf(t):-1;let i=rQ(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==t));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==t?l:void 0}function sQ(e,n){const{x:t,y:r}=e;let o=!1;for(let s=0,i=n.length-1;s<n.length;i=s++){const a=n[s].x,l=n[s].y,c=n[i].x,u=n[i].y;l>r!=u>r&&t<(c-a)*(r-l)/(u-l)+a&&(o=!o)}return o}function iQ(e,n){if(!n)return!1;const t={x:e.clientX,y:e.clientY};return sQ(t,n)}function cu(e){return n=>n.pointerType==="mouse"?e(n):void 0}const iA=NZ,aA=QM,lA=zZ,cA=UZ,uA=VZ,dA=tA,hA=WZ,pA=ZZ,fA=QZ,gA=eQ,mA="ContextMenu",[aQ,One]=go(mA,[ig]),vo=ig(),[lQ,yA]=aQ(mA),cQ=e=>{const{__scopeContextMenu:n,children:t,onOpenChange:r,dir:o,modal:s=!0}=e,[i,a]=x.useState(!1),l=vo(n),c=on(r),u=x.useCallback(d=>{a(d),c(d)},[c]);return x.createElement(lQ,{scope:n,open:i,onOpenChange:u,modal:s},x.createElement(iA,Q({},l,{dir:o,open:i,onOpenChange:u,modal:s}),t))},uQ="ContextMenuTrigger",dQ=x.forwardRef((e,n)=>{const{__scopeContextMenu:t,disabled:r=!1,...o}=e,s=yA(uQ,t),i=vo(t),a=x.useRef({x:0,y:0}),l=x.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),c=x.useRef(0),u=x.useCallback(()=>window.clearTimeout(c.current),[]),d=h=>{a.current={x:h.clientX,y:h.clientY},s.onOpenChange(!0)};return x.useEffect(()=>u,[u]),x.useEffect(()=>void(r&&u()),[r,u]),x.createElement(x.Fragment,null,x.createElement(aA,Q({},i,{virtualRef:l})),x.createElement(Be.span,Q({"data-state":s.open?"open":"closed","data-disabled":r?"":void 0},o,{ref:n,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:se(e.onContextMenu,h=>{u(),d(h),h.preventDefault()}),onPointerDown:r?e.onPointerDown:se(e.onPointerDown,Zd(h=>{u(),c.current=window.setTimeout(()=>d(h),700)})),onPointerMove:r?e.onPointerMove:se(e.onPointerMove,Zd(u)),onPointerCancel:r?e.onPointerCancel:se(e.onPointerCancel,Zd(u)),onPointerUp:r?e.onPointerUp:se(e.onPointerUp,Zd(u))})))}),SA=e=>{const{__scopeContextMenu:n,...t}=e,r=vo(n);return x.createElement(lA,Q({},r,t))},hQ="ContextMenuContent",pQ=x.forwardRef((e,n)=>{const{__scopeContextMenu:t,...r}=e,o=yA(hQ,t),s=vo(t),i=x.useRef(!1);return x.createElement(cA,Q({},s,r,{ref:n,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var l;(l=e.onCloseAutoFocus)===null||l===void 0||l.call(e,a),!a.defaultPrevented&&i.current&&a.preventDefault(),i.current=!1},onInteractOutside:a=>{var l;(l=e.onInteractOutside)===null||l===void 0||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)"}}))}),fQ=x.forwardRef((e,n)=>{const{__scopeContextMenu:t,...r}=e,o=vo(t);return x.createElement(uA,Q({},o,r,{ref:n}))}),gQ=x.forwardRef((e,n)=>{const{__scopeContextMenu:t,...r}=e,o=vo(t);return x.createElement(dA,Q({},o,r,{ref:n}))}),mQ=x.forwardRef((e,n)=>{const{__scopeContextMenu:t,...r}=e,o=vo(t);return x.createElement(hA,Q({},o,r,{ref:n}))}),yQ=e=>{const{__scopeContextMenu:n,children:t,onOpenChange:r,open:o,defaultOpen:s}=e,i=vo(n),[a,l]=Ws({prop:o,defaultProp:s,onChange:r});return x.createElement(pA,Q({},i,{open:a,onOpenChange:l}),t)},SQ=x.forwardRef((e,n)=>{const{__scopeContextMenu:t,...r}=e,o=vo(t);return x.createElement(fA,Q({},o,r,{ref:n}))}),vQ=x.forwardRef((e,n)=>{const{__scopeContextMenu:t,...r}=e,o=vo(t);return x.createElement(gA,Q({},o,r,{ref:n,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))});function Zd(e){return n=>n.pointerType!=="mouse"?e(n):void 0}const wQ=cQ,xQ=dQ,bQ=SA,PQ=pQ,CQ=mQ,vA=typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("mac")>-1,IQ=vA?"⌘":"Ctrl",EQ=vA?"⌥":"Alt";function wA(e){return e.split(",")[0].split("").map(n=>{const t=n.replace(/\$/g,IQ).replace(/\?/g,EQ).replace(/!/g,"⇧");return t[0].toUpperCase()+t.slice(1)})}function uu(e){return"— "+wA(e).join(" ")}function _Q(e){return p.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",...e,children:p.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[p.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),p.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:p.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}const xA="DropdownMenu",[kQ,Dne]=go(xA,[ig]),wo=ig(),[TQ,bA]=kQ(xA),$Q=e=>{const{__scopeDropdownMenu:n,children:t,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=wo(n),c=x.useRef(null),[u=!1,d]=Ws({prop:o,defaultProp:s,onChange:i});return x.createElement(TQ,{scope:n,triggerId:Fo(),triggerRef:c,contentId:Fo(),open:u,onOpenChange:d,onOpenToggle:x.useCallback(()=>d(h=>!h),[d]),modal:a},x.createElement(iA,Q({},l,{open:u,onOpenChange:d,dir:r,modal:a}),t))},MQ="DropdownMenuTrigger",AQ=x.forwardRef((e,n)=>{const{__scopeDropdownMenu:t,disabled:r=!1,...o}=e,s=bA(MQ,t),i=wo(t);return x.createElement(aA,Q({asChild:!0},i),x.createElement(Be.button,Q({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:Vf(n,s.triggerRef),onPointerDown:se(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:se(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})))}),jQ=e=>{const{__scopeDropdownMenu:n,...t}=e,r=wo(n);return x.createElement(lA,Q({},r,t))},OQ="DropdownMenuContent",DQ=x.forwardRef((e,n)=>{const{__scopeDropdownMenu:t,...r}=e,o=bA(OQ,t),s=wo(t),i=x.useRef(!1);return x.createElement(cA,Q({id:o.contentId,"aria-labelledby":o.triggerId},s,r,{ref:n,onCloseAutoFocus:se(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)===null||l===void 0||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:se(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)"}}))}),RQ=x.forwardRef((e,n)=>{const{__scopeDropdownMenu:t,...r}=e,o=wo(t);return x.createElement(uA,Q({},o,r,{ref:n}))}),LQ=x.forwardRef((e,n)=>{const{__scopeDropdownMenu:t,...r}=e,o=wo(t);return x.createElement(dA,Q({},o,r,{ref:n}))}),NQ=x.forwardRef((e,n)=>{const{__scopeDropdownMenu:t,...r}=e,o=wo(t);return x.createElement(hA,Q({},o,r,{ref:n}))}),FQ=e=>{const{__scopeDropdownMenu:n,children:t,open:r,onOpenChange:o,defaultOpen:s}=e,i=wo(n),[a=!1,l]=Ws({prop:r,defaultProp:s,onChange:o});return x.createElement(pA,Q({},i,{open:a,onOpenChange:l}),t)},zQ=x.forwardRef((e,n)=>{const{__scopeDropdownMenu:t,...r}=e,o=wo(t);return x.createElement(fA,Q({},o,r,{ref:n}))}),BQ=x.forwardRef((e,n)=>{const{__scopeDropdownMenu:t,...r}=e,o=wo(t);return x.createElement(gA,Q({},o,r,{ref:n,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)"}}))}),ex=$Q,tx=AQ,lg=jQ,nx=DQ,UQ=RQ,HQ=LQ,KQ=NQ,VQ=FQ,WQ=zQ,GQ=BQ;function Ti({id:e,children:n,modal:t=!1,debugOpen:r=!1}){const[o,s]=Gs(e);return p.jsx(ex,{open:r||o,dir:"ltr",modal:t,onOpenChange:s,children:n})}function $i({children:e,...n}){return p.jsx(tx,{dir:"ltr",asChild:!0,onTouchEnd:t=>je(t),...n,children:e})}function Mi({side:e="bottom",align:n="start",sideOffset:t=8,alignOffset:r=8,children:o}){const s=mn();return p.jsx(lg,{container:s,children:p.jsx(nx,{className:"tlui-menu",side:e,sideOffset:t,align:n,alignOffset:r,collisionPadding:4,children:o})})}function YQ({id:e,children:n}){const[t,r]=Gs(e);return p.jsx(VQ,{open:t,onOpenChange:r,children:n})}function XQ({id:e,label:n,title:t,disabled:r}){return p.jsx(WQ,{dir:"ltr",asChild:!0,disabled:r,children:p.jsxs(he,{"data-testid":e,type:"menu",className:"tlui-menu__submenu__trigger",disabled:r,title:t,children:[p.jsx(mt,{children:n}),p.jsx(Ie,{icon:"chevron-right",small:!0})]})})}function qQ({id:e,alignOffset:n=-1,sideOffset:t=-4,size:r="small",children:o}){const s=mn();return p.jsx(lg,{container:s,children:p.jsx(GQ,{"data-testid":e,className:"tlui-menu tlui-menu__submenu__content",alignOffset:n,sideOffset:t,collisionPadding:4,"data-size":r,children:o})})}function ZQ({children:e}){return p.jsx(UQ,{dir:"ltr",className:"tlui-menu__group",children:e})}function du({noClose:e,children:n}){return p.jsx(HQ,{dir:"ltr",asChild:!0,onClick:e?je:void 0,children:n})}function wc({children:e,visibleOnMobileLayout:n=!1}){const t=Ln();return!n&&t<ht.MOBILE?null:p.jsx("kbd",{className:"tlui-kbd",children:wA(e).map((r,o)=>p.jsx("span",{children:r},o))})}function z({disabled:e=!1,spinner:n=!1,readonlyOk:t=!1,id:r,kbd:o,label:s,icon:i,onSelect:a,noClose:l}){const{type:c,sourceId:u}=tg(),d=Ee(),[h,f]=x.useState(!1);if(fo()&&!t)return null;const g=au(s,c),v=o?uu(o):void 0,S=g?d(g):void 0,w=S&&v?`${S} ${v}`:S;switch(c){case"menu":return p.jsx(du,{children:p.jsxs(he,{type:"menu","data-testid":`${u}.${r}`,disabled:e,title:w,onClick:C=>{l&&je(C),h?f(!1):a(u)},children:[p.jsx(mt,{children:S}),o&&p.jsx(wc,{children:o})]})});case"context-menu":return e?null:p.jsxs(gQ,{dir:"ltr",title:w,draggable:!1,className:"tlui-button tlui-button__menu","data-testid":`${u}.${r}`,onSelect:C=>{l&&je(C),h?f(!1):a(u)},children:[p.jsx("span",{className:"tlui-button__label",draggable:!1,children:S}),o&&p.jsx(wc,{children:o}),n&&p.jsx(_Q,{})]});case"panel":return p.jsxs(he,{"data-testid":`${u}.${r}`,type:"menu",title:w,disabled:e,onClick:()=>a(u),children:[p.jsx(mt,{children:S}),i&&p.jsx(Ie,{icon:i})]});case"small-icons":case"icons":return p.jsx(he,{"data-testid":`${u}.${r}`,type:"icon",title:w,disabled:e,onClick:()=>a(u),children:p.jsx(Ie,{icon:i,small:c==="small-icons"})});case"keyboard-shortcuts":return o?p.jsxs("div",{className:"tlui-shortcuts-dialog__key-pair","data-testid":`${u}.${r}`,children:[p.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__key",children:S}),p.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__value",children:p.jsx(wc,{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 p.jsxs(he,{type:"low",onClick:()=>a(u),children:[p.jsx(Ie,{icon:i}),p.jsx(mt,{children:S})]});default:return null}}function QQ(){return p.jsxs(p.Fragment,{children:[p.jsx(JQ,{}),p.jsx(eJ,{}),p.jsx(tJ,{}),p.jsx(nJ,{}),p.jsx(rJ,{}),p.jsx(iJ,{}),p.jsx(aJ,{}),p.jsx(lJ,{})]})}function JQ(){const e=le(),n=an(2);return p.jsxs(p.Fragment,{children:[p.jsx(z,{...e["align-left"],disabled:!n}),p.jsx(z,{...e["align-center-horizontal"],disabled:!n}),p.jsx(z,{...e["align-right"],disabled:!n}),p.jsx(z,{...e["stretch-horizontal"],disabled:!n}),p.jsx(z,{...e["align-top"],disabled:!n}),p.jsx(z,{...e["align-center-vertical"],disabled:!n}),p.jsx(z,{...e["align-bottom"],disabled:!n}),p.jsx(z,{...e["stretch-vertical"],disabled:!n})]})}function eJ(){const e=le(),n=an(3);return p.jsxs(p.Fragment,{children:[p.jsx(z,{...e["distribute-horizontal"],disabled:!n}),p.jsx(z,{...e["distribute-vertical"],disabled:!n})]})}function tJ(){const e=le(),n=bk();return p.jsxs(p.Fragment,{children:[p.jsx(z,{...e["stack-horizontal"],disabled:!n}),p.jsx(z,{...e["stack-vertical"],disabled:!n})]})}function nJ(){const e=le(),n=an(1);return p.jsxs(p.Fragment,{children:[p.jsx(z,{...e["send-to-back"],disabled:!n}),p.jsx(z,{...e["send-backward"],disabled:!n}),p.jsx(z,{...e["bring-forward"],disabled:!n}),p.jsx(z,{...e["bring-to-front"],disabled:!n})]})}function rJ(){return Ln()<ht.TABLET_SM?p.jsx(oJ,{}):p.jsx(sJ,{})}function oJ(){const e=le(),n=F(),t=K("zoom is 1",()=>n.getZoomLevel()===1,[n]);return p.jsx(z,{...e["zoom-to-100"],disabled:t})}function sJ(){const e=le(),n=an(1);return p.jsx(z,{...e["rotate-ccw"],disabled:!n})}function iJ(){const e=le(),n=an(1);return p.jsx(z,{...e["rotate-cw"],disabled:!n})}function aJ(){const e=le(),n=Ik();return p.jsx(z,{...e["edit-link"],disabled:!n})}function lJ(){const e=Pk(),n=Ck();return e?p.jsx(qC,{}):n?p.jsx(cJ,{}):p.jsx(qC,{})}function qC(){const e=le(),n=an(2);return p.jsx(z,{...e.group,disabled:!n})}function cJ(){const e=le();return p.jsx(z,{...e.ungroup})}const uJ=x.memo(function({children:n}){const t=Ee(),r=Ln(),o=fo(),s=F(),i=K("should display quick actions when in readonly",()=>s.isInAny("hand","zoom"),[s]),a=n??p.jsx(QQ,{});if(!(o&&!i))return p.jsxs(Hw,{id:"actions-menu",children:[p.jsx(Kw,{children:p.jsx(he,{type:"icon","data-testid":"actions-menu.button",title:t("actions-menu.title"),children:p.jsx(Ie,{icon:"dots-vertical",small:!0})})}),p.jsx(Vw,{side:r>=ht.TABLET?"bottom":"top",sideOffset:6,children:p.jsx("div",{className:"tlui-actions-menu tlui-buttons__grid","data-testid":"actions-menu.content",children:p.jsx(So,{type:"icons",sourceId:"actions-menu",children:a})})})]})});function wr({id:e,kbd:n,label:t,readonlyOk:r,onSelect:o,disabled:s=!1,checked:i=!1}){const{type:a,sourceId:l}=tg(),c=fo(),u=Ee();if(c&&!r)return null;const d=au(t,a),h=d?u(d):void 0;switch(a){case"menu":return p.jsxs(KQ,{dir:"ltr",className:"tlui-button tlui-button__menu tlui-button__checkbox",title:h,onSelect:f=>{o==null||o(l),je(f)},disabled:s,checked:i,children:[p.jsx(Rs,{small:!0,icon:i?"check":"checkbox-empty"}),h&&p.jsx("span",{className:"tlui-button__label",draggable:!1,children:h}),n&&p.jsx(wc,{children:n})]});case"context-menu":return p.jsxs(CQ,{className:"tlui-button tlui-button__menu tlui-button__checkbox",dir:"ltr",title:h,onSelect:f=>{o(l),je(f)},disabled:s,checked:i,children:[p.jsx(Rs,{small:!0,icon:i?"check":"checkbox-empty"}),h&&p.jsx("span",{className:"tlui-button__label",draggable:!1,children:h}),n&&p.jsx(wc,{children:n})]},e);default:return null}}function we({id:e,label:n,children:t}){const{type:r,sourceId:o}=tg(),s=Ee(),i=au(n,r),a=i?s(i):void 0;switch(r){case"panel":return p.jsx("div",{className:"tlui-menu__group","data-testid":`${o}-group.${e}`,children:t});case"menu":return p.jsx(ZQ,{"data-testid":`${o}-group.${e}`,children:t});case"context-menu":return p.jsx(fQ,{dir:"ltr",className:"tlui-menu__group","data-testid":`${o}-group.${e}`,children:t});case"keyboard-shortcuts":return p.jsxs("div",{className:"tlui-shortcuts-dialog__group","data-testid":`${o}-group.${e}`,children:[p.jsx("h2",{className:"tlui-shortcuts-dialog__group__title",children:a}),p.jsx("div",{className:"tlui-shortcuts-dialog__group__content",children:t})]});default:return t}}function xr({id:e,disabled:n=!1,label:t,size:r="small",children:o}){const{type:s,sourceId:i}=tg(),a=mn(),l=Ee(),c=t?typeof t=="string"?t:t[s]??t.default:void 0,u=c?l(c):void 0;switch(s){case"menu":return p.jsxs(YQ,{id:`${i}-sub.${e}`,children:[p.jsx(XQ,{id:`${i}-sub.${u?u.toLowerCase()+"-button":""}`,disabled:n,label:u,title:u}),p.jsx(qQ,{id:`${i}-sub.${u?u.toLowerCase()+"-content":""}`,size:r,children:o})]});case"context-menu":return n?null:p.jsxs(dJ,{id:`${i}-sub.${e}`,children:[p.jsx(SQ,{dir:"ltr",disabled:n,asChild:!0,children:p.jsxs(he,{"data-testid":`${i}-sub-trigger.${e}`,type:"menu",className:"tlui-menu__submenu__trigger",children:[p.jsx(mt,{children:u}),p.jsx(Ie,{icon:"chevron-right",small:!0})]})}),p.jsx(SA,{container:a,children:p.jsx(vQ,{"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 dJ({id:e,children:n}){const[t,r]=Gs(e);return p.jsx(yQ,{open:t,onOpenChange:r,children:n})}function PA(){const e=le(),n=EU();return p.jsx(z,{...e["toggle-auto-size"],disabled:!n})}function CA(){const e=le(),n=Ik();return p.jsx(z,{...e["edit-link"],disabled:!n})}function hJ(){const e=le(),n=an(1);return p.jsx(z,{...e.duplicate,disabled:!n})}function IA(){const e=le(),n=Pk();return p.jsx(z,{...e.group,disabled:!n})}function EA(){const e=le(),n=Ck();return p.jsx(z,{...e.ungroup,disabled:!n})}function _A(){const e=F(),n=le(),t=K("allow unframe",()=>{const r=e.getSelectedShapes();return r.length===0?!1:r.every(o=>e.isShapeOfType(o,"frame"))},[e]);return p.jsx(z,{...n["remove-frame"],disabled:!t})}function kA(){const e=F(),n=le(),t=K("allow fit frame to content",()=>{const r=e.getOnlySelectedShape();return r?e.isShapeOfType(r,"frame")&&e.getSortedChildIdsForParent(r).length>0:!1},[e]);return p.jsx(z,{...n["fit-frame-to-content"],disabled:!t})}function TA(){const e=F(),n=le(),t=K("selected shapes",()=>e.getSelectedShapes().length>0,[e]);return p.jsx(z,{...n["toggle-lock"],disabled:!t})}function $A(){const e=le(),n=F(),t=K("isTransparentBg",()=>!n.getInstanceState().exportBackground,[n]);return p.jsx(wr,{...e["toggle-transparent"],checked:t})}function pJ(){const e=F(),n=le(),t=K("any shapes",()=>e.getCurrentPageShapeIds().size>0,[e]);return p.jsx(z,{...n["unlock-all"],disabled:!t})}function MA(){const e=F(),n=K("zoomed to 100",()=>e.getZoomLevel()===1,[e]),t=le();return p.jsx(z,{...t["zoom-to-100"],noClose:!0,disabled:n})}function AA(){const e=F(),n=K("has shapes",()=>e.getCurrentPageShapeIds().size>0,[e]),t=le();return p.jsx(z,{...t["zoom-to-fit"],disabled:!n,"data-testid":"minimap.zoom-menu.zoom-to-fit",noClose:!0})}function jA(){const e=F(),n=K("has shapes",()=>e.getSelectedShapeIds().length>0,[e]),t=le();return p.jsx(z,{...t["zoom-to-selection"],disabled:!n,"data-testid":"minimap.zoom-menu.zoom-to-selection",noClose:!0})}function OA(){var r;const e=F(),n=le(),t=K("atLeastOneShapeOnPage",()=>e.getCurrentPageShapeIds().size>0,[]);return p.jsxs(we,{id:"clipboard",children:[p.jsx(fJ,{}),p.jsx(gJ,{}),p.jsxs(xr,{id:"copy-as",label:"context-menu.copy-as",size:"small",disabled:!t,children:[p.jsxs(we,{id:"copy-as-group",children:[p.jsx(z,{...n["copy-as-svg"]}),!!((r=window.navigator.clipboard)!=null&&r.write)&&p.jsx(z,{...n["copy-as-png"]}),p.jsx(z,{...n["copy-as-json"]})]}),p.jsx(we,{id:"copy-as-bg",children:p.jsx($A,{})})]}),p.jsx(hJ,{}),p.jsx(mJ,{}),p.jsx(yJ,{})]})}function fJ(){const e=le(),n=an(1);return p.jsx(z,{...e.cut,disabled:!n})}function gJ(){const e=le(),n=IU(1);return p.jsx(z,{...e.copy,disabled:!n})}function mJ(){const e=le(),n=CU;return p.jsx(z,{...e.paste,disabled:!n})}function DA(){const e=le(),n=an(1);return p.jsx(we,{id:"conversions",children:p.jsxs(xr,{id:"export-as",label:"context-menu.export-as",size:"small",disabled:!n,children:[p.jsxs(we,{id:"export-as-group",children:[p.jsx(z,{...e["export-as-svg"]}),p.jsx(z,{...e["export-as-png"]}),p.jsx(z,{...e["export-as-json"]})]}),p.jsx(we,{id:"export-as-bg",children:p.jsx($A,{})})]})})}function RA(){const e=le(),n=F(),t=K("atLeastOneShapeOnPage",()=>n.getCurrentPageShapeIds().size>0,[n]);return p.jsx(we,{id:"set-selection-group",children:p.jsx(z,{...e["select-all"],disabled:!t})})}function yJ(){const e=le(),n=an(1);return p.jsx(z,{...e.delete,disabled:!n})}function SJ(){const e=an(2),n=_U(),t=le();return e||n?p.jsxs(xr,{id:"arrange",label:"context-menu.arrange",size:"small",children:[e&&p.jsxs(we,{id:"align",children:[p.jsx(z,{...t["align-left"]}),p.jsx(z,{...t["align-center-horizontal"]}),p.jsx(z,{...t["align-right"]}),p.jsx(z,{...t["align-top"]}),p.jsx(z,{...t["align-center-vertical"]}),p.jsx(z,{...t["align-bottom"]})]}),p.jsx(vJ,{}),e&&p.jsxs(we,{id:"stretch",children:[p.jsx(z,{...t["stretch-horizontal"]}),p.jsx(z,{...t["stretch-vertical"]})]}),n&&p.jsxs(we,{id:"flip",children:[p.jsx(z,{...t["flip-horizontal"]}),p.jsx(z,{...t["flip-vertical"]})]}),p.jsx(wJ,{})]}):null}function vJ(){const e=le();return an(3)?p.jsxs(we,{id:"distribute",children:[p.jsx(z,{...e["distribute-horizontal"]}),p.jsx(z,{...e["distribute-vertical"]})]}):null}function wJ(){const e=le(),n=an(2),t=bk();return n?p.jsxs(we,{id:"order",children:[p.jsx(z,{...e.pack}),t&&p.jsx(z,{...e["stack-horizontal"]}),t&&p.jsx(z,{...e["stack-vertical"]})]}):null}function xJ(){const e=le();return an(1)?p.jsx(xr,{id:"reorder",label:"context-menu.reorder",size:"small",children:p.jsxs(we,{id:"reorder",children:[p.jsx(z,{...e["bring-to-front"]}),p.jsx(z,{...e["bring-forward"]}),p.jsx(z,{...e["send-backward"]}),p.jsx(z,{...e["send-to-back"]})]})}):null}function bJ(){const e=F(),n=K("pages",()=>e.getPages(),[e]),t=K("current page id",()=>e.getCurrentPageId(),[e]),{addToast:r}=Wr(),o=le(),s=yo();return an(1)?p.jsxs(xr,{id:"move-to-page",label:"context-menu.move-to-page",size:"small",children:[p.jsx(we,{id:"pages",children:n.map(a=>p.jsx(z,{id:a.id,disabled:t===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(t)}}]}),s("move-to-page",{source:"context-menu"})},title:a.name},a.id))}),p.jsx(we,{id:"new-page",children:p.jsx(z,{...o["new-page"]})})]}):null}function LA(){const e=F(),n=le(),t=K("oneEmbedSelected",()=>{const o=e.getOnlySelectedShape();return o?!!(e.isShapeOfType(o,"embed")&&o.props.url&&!e.isShapeOrAncestorLocked(o)):!1},[e]),r=K("oneEmbeddableBookmarkSelected",()=>{const o=e.getOnlySelectedShape();return o?!!(e.isShapeOfType(o,"bookmark")&&o.props.url&&Ao(o.props.url)&&!e.isShapeOrAncestorLocked(o)):!1},[e]);return p.jsxs(we,{id:"embeds",children:[p.jsx(z,{...n["convert-to-bookmark"],disabled:!t}),p.jsx(z,{...n["convert-to-embed"],disabled:!r})]})}function PJ(){const e=le(),n=F(),t=K("isSnapMode",()=>n.user.getIsSnapMode(),[n]);return p.jsx(wr,{...e["toggle-snap-mode"],checked:t})}function CJ(){const e=le(),n=F(),t=K("isToolLock",()=>n.getInstanceState().isToolLocked,[n]);return p.jsx(wr,{...e["toggle-tool-lock"],checked:t})}function IJ(){const e=le(),n=F(),t=K("isGridMode",()=>n.getInstanceState().isGridMode,[n]);return p.jsx(wr,{...e["toggle-grid"],checked:t})}function EJ(){const e=le(),n=F(),t=K("isWrapMode",()=>n.user.getIsWrapMode(),[n]);return p.jsx(wr,{...e["toggle-wrap-mode"],checked:t})}function _J(){const e=le(),n=F(),t=K("isDarkMode",()=>n.user.getIsDarkMode(),[n]);return p.jsx(wr,{...e["toggle-dark-mode"],checked:t})}function kJ(){const e=le(),n=F(),t=K("isFocusMode",()=>n.getInstanceState().isFocusMode,[n]);return p.jsx(wr,{...e["toggle-focus-mode"],checked:t})}function TJ(){const e=le(),n=F(),t=K("edgeScrollSpeed",()=>n.user.getEdgeScrollSpeed(),[n]);return p.jsx(wr,{...e["toggle-edge-scrolling"],checked:t===1})}function $J(){const e=le(),n=F(),t=K("animationSpeed",()=>n.user.getAnimationSpeed(),[n]);return p.jsx(wr,{...e["toggle-reduce-motion"],checked:t===0})}function MJ(){const e=le(),n=F(),t=K("isDebugMode",()=>n.getInstanceState().isDebugMode,[n]);return p.jsx(wr,{...e["toggle-debug-mode"],checked:t})}function AJ(){const e=F();return K("isSelectToolActive",()=>e.getCurrentToolId()==="select",[e])?p.jsxs(p.Fragment,{children:[p.jsxs(we,{id:"selection",children:[p.jsx(PA,{}),p.jsx(CA,{}),p.jsx(IA,{}),p.jsx(EA,{}),p.jsx(_A,{}),p.jsx(kA,{}),p.jsx(TA,{})]}),p.jsx(LA,{}),p.jsxs(we,{id:"modify",children:[p.jsx(SJ,{}),p.jsx(xJ,{}),p.jsx(bJ,{})]}),p.jsx(OA,{}),p.jsx(DA,{}),p.jsx(RA,{})]}):null}const jJ=x.memo(function({children:n}){const t=F(),{Canvas:r}=Ge(),o=x.useCallback(c=>{if(c){if(t.getInstanceState().isCoarsePointer){const u=t.getSelectedShapes(),{inputs:{currentPagePoint:d}}=t,h=t.getShapesAtPoint(d);if(!t.getSelectedShapes().length||!h.some(f=>u.includes(f))){const f=h.filter(y=>t.isShapeOrAncestorLocked(y));f.length&&t.select(...f.map(y=>y.id))}}}else{const u=t.getOnlySelectedShape();u&&t.isShapeOrAncestorLocked(u)&&t.setSelectedShapes([])}},[t]),s=mn(),[i,a]=Gs("context menu",o),l=n??p.jsx(AJ,{});return p.jsxs(wQ,{dir:"ltr",onOpenChange:a,modal:!1,children:[p.jsx(xQ,{onContextMenu:void 0,dir:"ltr",children:r?p.jsx(r,{}):null}),i&&p.jsx(bQ,{container:s,children:p.jsx(PQ,{className:"tlui-menu scrollable","data-testid":"context-menu",alignOffset:-4,collisionPadding:4,onContextMenu:je,children:p.jsx(So,{type:"context-menu",sourceId:"context-menu",children:l})})})]})});function wv({checked:e}){return p.jsx(Rs,{icon:e?"check":"checkbox-empty",className:"tlui-button__icon",small:!0})}function OJ(){const e=F(),{addToast:n}=Wr(),{addDialog:t}=zi(),[r,o]=ie.useState(!1);return p.jsxs(p.Fragment,{children:[p.jsxs(we,{id:"items",children:[p.jsx(z,{id:"add-toast",onSelect:()=>{n({id:ze(),title:"Something happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0}),n({id:ze(),title:"Something happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,actions:[{label:"Primary",type:"primary",onClick:()=>{}},{label:"Normal",type:"normal",onClick:()=>{}},{label:"Danger",type:"danger",onClick:()=>{}}]}),n({id:ze(),title:"Something happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,icon:"twitter",actions:[{label:"Primary",type:"primary",onClick:()=>{}},{label:"Normal",type:"normal",onClick:()=>{}},{label:"Danger",type:"danger",onClick:()=>{}}]})},label:"Show toast"}),p.jsx(z,{id:"show-dialog",label:"Show dialog",onSelect:()=>{t({component:({onClose:s})=>p.jsx(LJ,{displayDontShowAgain:!0,onCancel:()=>s(),onContinue:()=>s()}),onClose:()=>{}})}}),p.jsx(z,{id:"create-shapes",label:"Create 100 shapes",onSelect:()=>NJ(e,100)}),p.jsx(z,{id:"count-nodes",label:"Count shapes / nodes",onSelect:()=>{function s({children:u}){let d=0;if(!u.length)return 0;for(const h of[...u])d++,d+=s(h);return d}const i=e.getSelectedShapes(),a=i.length===0?e.getRenderingShapes():i,l=a.map(u=>document.getElementById(u.id).parentElement);let c=l.length;for(const u of l)c+=s(u);window.alert(`Shapes ${a.length}, DOM nodes:${c}`)}}),(()=>{if(r)throw Error("oh no!")})(),p.jsx(z,{id:"throw-error",onSelect:()=>o(!0),label:"Throw error"}),p.jsx(z,{id:"hard-reset",onSelect:qE,label:"Hard reset"})]}),p.jsxs(we,{id:"flags",children:[p.jsx(DJ,{}),p.jsx(RJ,{})]})]})}function DJ(){const e=Object.values(Ft);return e.length?p.jsx(xr,{id:"debug flags",label:"Debug Flags",children:p.jsx(we,{id:"debug flags",children:e.map(n=>p.jsx(NA,{flag:n},n.name))})}):null}function RJ(){const e=Object.values(XR);return e.length?p.jsx(xr,{id:"feature flags",label:"Feature Flags",children:p.jsx(we,{id:"feature flags",children:e.map(n=>p.jsx(NA,{flag:n},n.name))})}):null}function LJ({title:e="title",body:n="hello hello hello",cancel:t="Cancel",confirm:r="Continue",displayDontShowAgain:o=!1,onCancel:s,onContinue:i}){const[a,l]=ie.useState(!1);return p.jsxs(p.Fragment,{children:[p.jsxs(ng,{children:[p.jsx(rg,{children:e}),p.jsx(og,{})]}),p.jsx(iu,{style:{maxWidth:350},children:n}),p.jsxs(Ww,{className:"tlui-dialog__footer__actions",children:[o&&p.jsxs(he,{type:"normal",onClick:()=>l(!a),style:{marginRight:"auto"},children:[p.jsx(wv,{checked:a}),p.jsx(mt,{children:"Don't show again"})]}),p.jsx(he,{type:"normal",onClick:s,children:p.jsx(mt,{children:t})}),p.jsx(he,{type:"primary",onClick:async()=>i(),children:p.jsx(mt,{children:r})})]})]})}const NA=Tt(function({flag:n,onChange:t}){const r=n.get();return p.jsx(wr,{id:n.name,title:n.name,label:n.name.replace(/([a-z0-9])([A-Z])/g,o=>`${o[0]} ${o[1].toLowerCase()}`).replace(/^[a-z]/,o=>o.toUpperCase()),checked:r,onSelect:()=>{n.set(!r),t==null||t(!r)}})});let ZC=0;function NJ(e,n){const t=Array(n),r=Math.floor(Math.sqrt(n));for(let o=0;o<n;o++)ZC++,t[o]={id:We("box"+ZC),type:"geo",x:o%r*132,y:Math.floor(o/r)*132};e.batch(()=>{e.createShapes(t).setSelectedShapes(t.map(o=>o.id))})}function FJ({children:e}){const n=e??p.jsx(OJ,{});return p.jsxs(Ti,{id:"debug",children:[p.jsx($i,{children:p.jsx(he,{type:"icon",title:"Debug menu",children:p.jsx(Ie,{icon:"dots-horizontal"})})}),p.jsx(Mi,{side:"top",align:"end",alignOffset:0,children:p.jsx(So,{type:"menu",sourceId:"debug-panel",children:n})})]})}function zJ(){const e=F();return{languages:_c,currentLanguage:e.user.getLocale()}}const FA=Tt(function(){const n=F(),t=yo(),{languages:r,currentLanguage:o}=zJ();return p.jsx(xr,{id:"help menu language",label:"menu.language",children:p.jsx(we,{id:"languages",children:r.map(({locale:s,label:i})=>p.jsx(wr,{id:`language-${s}`,title:s,label:i,checked:s===o,onSelect:()=>{n.user.updateUserPreferences({locale:s}),t("change-language",{source:"menu",locale:s})}},s))})})});function BJ(){return p.jsxs(p.Fragment,{children:[p.jsx(FA,{}),p.jsx(UJ,{})]})}function UJ(){const{KeyboardShortcutsDialog:e}=Xs(),{addDialog:n}=zi();return e?p.jsx(z,{id:"keyboard-shortcuts-button",label:"help-menu.keyboard-shortcuts",readonlyOk:!0,onSelect:()=>{n({component:e})}}):null}const HJ=x.memo(function({children:n}){const t=Ee(),r=Ln(),o=n??p.jsx(BJ,{});return r<ht.MOBILE?null:p.jsx("div",{className:"tlui-help-menu",children:p.jsxs(Ti,{id:"help menu",children:[p.jsx($i,{children:p.jsx(he,{type:"help",title:t("help-menu.title"),"data-testid":"help-menu.button",children:p.jsx(Ie,{icon:"question-mark",small:!0})})}),p.jsx(Mi,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:p.jsx(So,{type:"menu",sourceId:"help-menu",children:o})})]})})});function KJ(){const e=F(),n=le(),[t,r]=x.useState(!1);return x.useEffect(()=>{let o=!1;const s=setInterval(()=>{const i=e.getRenderingShapes(),a=e.getRenderingBounds(),c=i.filter(u=>u.maskedPageBounds&&a.includes(u.maskedPageBounds)).length===0&&e.getCurrentPageShapes().length>0;o!==c&&(r(c),o=c)},1e3);return()=>{clearInterval(s)}},[e]),t?p.jsx(z,{...n["back-to-content"],onSelect:()=>{n["back-to-content"].onSelect("helper-buttons"),r(!1)}}):null}function VJ(){const e=F(),n=le();return K("is pen mode",()=>e.getInstanceState().isPenMode,[e])?p.jsx(z,{...n["exit-pen-mode"]}):null}function WJ(){const e=F(),n=le();return K("is following user",()=>!!e.getInstanceState().followingUserId,[e])?p.jsx(z,{...n["stop-following"]}):null}function GJ(){return p.jsxs(p.Fragment,{children:[p.jsx(VJ,{}),p.jsx(KJ,{}),p.jsx(WJ,{})]})}function YJ({children:e}){const n=e??p.jsx(GJ,{});return p.jsx("div",{className:"tlui-helper-buttons",children:p.jsx(So,{type:"helper-buttons",sourceId:"helper-buttons",children:n})})}const zA=x.createContext({});function XJ({overrides:e,children:n}){const t=F(),r=yo(),{addDialog:o}=zi(),s=HM(),i=x.useMemo(()=>{const a=[{id:"select",label:"tool.select",icon:"tool-pointer",kbd:"v",readonlyOk:!0,onSelect(c){t.setCurrentTool("select"),r("select-tool",{source:c,id:"select"})}},{id:"hand",label:"tool.hand",icon:"tool-hand",kbd:"h",readonlyOk:!0,onSelect(c){t.setCurrentTool("hand"),r("select-tool",{source:c,id:"hand"})}},{id:"eraser",label:"tool.eraser",icon:"tool-eraser",kbd:"e",onSelect(c){t.setCurrentTool("eraser"),r("select-tool",{source:c,id:"eraser"})}},{id:"draw",label:"tool.draw",icon:"tool-pencil",kbd:"d,b,x",onSelect(c){t.setCurrentTool("draw"),r("select-tool",{source:c,id:"draw"})}},...[...so.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){t.batch(()=>{t.updateInstanceState({stylesForNextShape:{...t.getInstanceState().stylesForNextShape,[so.id]:c}},{ephemeral:!0}),t.setCurrentTool("geo"),r("select-tool",{source:u,id:`geo-${c}`})})}})),{id:"arrow",label:"tool.arrow",icon:"tool-arrow",kbd:"a",onSelect(c){t.setCurrentTool("arrow"),r("select-tool",{source:c,id:"arrow"})}},{id:"line",label:"tool.line",icon:"tool-line",kbd:"l",onSelect(c){t.setCurrentTool("line"),r("select-tool",{source:c,id:"line"})}},{id:"frame",label:"tool.frame",icon:"tool-frame",kbd:"f",onSelect(c){t.setCurrentTool("frame"),r("select-tool",{source:c,id:"frame"})}},{id:"text",label:"tool.text",icon:"tool-text",kbd:"t",onSelect(c){t.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){t.setCurrentTool("note"),r("select-tool",{source:c,id:"note"})}},{id:"laser",label:"tool.laser",readonlyOk:!0,icon:"tool-laser",kbd:"k",onSelect(c){t.setCurrentTool("laser"),r("select-tool",{source:c,id:"laser"})}},{id:"embed",label:"tool.embed",icon:"tool-embed",onSelect(c){o({component:OM}),r("select-tool",{source:c,id:"embed"})}}];a.push({id:"highlight",label:"tool.highlight",icon:"tool-highlight",kbd:"!d",onSelect(c){t.setCurrentTool("highlight"),r("select-tool",{source:c,id:"highlight"})}});const l=Object.fromEntries(a.map(c=>[c.id,c]));return e?e(t,l,{insertMedia:s}):l},[e,t,r,s,o]);return p.jsx(zA.Provider,{value:i,children:n})}function rx(){const e=x.useContext(zA);if(!e)throw new Error("useTools must be used within a ToolProvider");return e}function qJ(){const e=le(),n=rx();return p.jsxs(p.Fragment,{children:[p.jsxs(we,{label:"shortcuts-dialog.tools",id:"tools",children:[p.jsx(z,{...e["toggle-tool-lock"]}),p.jsx(z,{...n.select}),p.jsx(z,{...n.draw}),p.jsx(z,{...n.eraser}),p.jsx(z,{...n.hand}),p.jsx(z,{...n.rectangle}),p.jsx(z,{...n.ellipse}),p.jsx(z,{...n.arrow}),p.jsx(z,{...n.line}),p.jsx(z,{...n.text}),p.jsx(z,{...n.frame}),p.jsx(z,{...n.note}),p.jsx(z,{...n.laser})]}),p.jsxs(we,{label:"shortcuts-dialog.file",id:"file",children:[p.jsx(z,{...e["insert-media"]}),p.jsx(z,{...e.print})]}),p.jsxs(we,{label:"shortcuts-dialog.preferences",id:"preferences",children:[p.jsx(z,{...e["toggle-dark-mode"]}),p.jsx(z,{...e["toggle-focus-mode"]}),p.jsx(z,{...e["toggle-grid"]})]}),p.jsxs(we,{label:"shortcuts-dialog.edit",id:"edit",children:[p.jsx(z,{...e.undo}),p.jsx(z,{...e.redo}),p.jsx(z,{...e.cut}),p.jsx(z,{...e.copy}),p.jsx(z,{...e.paste}),p.jsx(z,{...e["select-all"]}),p.jsx(z,{...e.delete}),p.jsx(z,{...e.duplicate})]}),p.jsxs(we,{label:"shortcuts-dialog.view",id:"view",children:[p.jsx(z,{...e["zoom-in"]}),p.jsx(z,{...e["zoom-out"]}),p.jsx(z,{...e["zoom-to-100"]}),p.jsx(z,{...e["zoom-to-fit"]}),p.jsx(z,{...e["zoom-to-selection"]})]}),p.jsxs(we,{label:"shortcuts-dialog.transform",id:"transform",children:[p.jsx(z,{...e["bring-to-front"]}),p.jsx(z,{...e["bring-forward"]}),p.jsx(z,{...e["send-backward"]}),p.jsx(z,{...e["send-to-back"]}),p.jsx(z,{...e.group}),p.jsx(z,{...e.ungroup}),p.jsx(z,{...e["flip-horizontal"]}),p.jsx(z,{...e["flip-vertical"]}),p.jsx(z,{...e["align-top"]}),p.jsx(z,{...e["align-center-vertical"]}),p.jsx(z,{...e["align-bottom"]}),p.jsx(z,{...e["align-left"]}),p.jsx(z,{...e["align-center-horizontal"]}),p.jsx(z,{...e["align-right"]})]})]})}const ZJ=x.memo(function({children:n}){const t=Ee(),r=Ln(),o=n??p.jsx(qJ,{});return p.jsxs(p.Fragment,{children:[p.jsxs(ng,{className:"tlui-shortcuts-dialog__header",children:[p.jsx(rg,{children:t("shortcuts-dialog.title")}),p.jsx(og,{})]}),p.jsx(iu,{className:fe("tlui-shortcuts-dialog__body",{"tlui-shortcuts-dialog__body__mobile":r<=ht.MOBILE_XS,"tlui-shortcuts-dialog__body__tablet":r<=ht.TABLET}),children:p.jsx(So,{type:"keyboard-shortcuts",sourceId:"kbd",children:o})}),p.jsx("div",{className:"tlui-dialog__scrim"})]})});function QJ(){return p.jsxs(p.Fragment,{children:[p.jsx(JJ,{}),p.jsx(eee,{}),p.jsx(see,{}),p.jsx(iee,{}),p.jsx(aee,{})]})}function JJ(){const e=F(),n=K("isSelectToolActive",()=>e.getCurrentToolId()==="select",[e]);return p.jsxs(xr,{id:"edit",label:"menu.edit",disabled:!n,children:[p.jsx(oee,{}),p.jsx(OA,{}),p.jsx(RA,{})]})}function eee(){const e=F(),n=K("isSelectToolActive",()=>e.getCurrentToolId()==="select",[e]);return p.jsxs(xr,{id:"shape",label:"menu.shape",disabled:!n,children:[p.jsx(DA,{}),p.jsx(ree,{}),p.jsx(tee,{}),p.jsx(LA,{}),p.jsx(nee,{})]})}function tee(){return p.jsxs(we,{id:"misc",children:[p.jsx(PA,{}),p.jsx(CA,{})]})}function nee(){return p.jsxs(we,{id:"lock",children:[p.jsx(TA,{}),p.jsx(pJ,{})]})}function ree(){return p.jsxs(we,{id:"multi-shape",children:[p.jsx(IA,{}),p.jsx(EA,{}),p.jsx(_A,{}),p.jsx(kA,{})]})}function oee(){const e=le(),n=_k(),t=Ek();return p.jsxs(we,{id:"undo-redo",children:[p.jsx(z,{...e.undo,disabled:!n}),p.jsx(z,{...e.redo,disabled:!t})]})}function see(){const e=le();return p.jsx(xr,{id:"view",label:"menu.view",children:p.jsxs(we,{id:"view-actions",children:[p.jsx(z,{...e["zoom-in"]}),p.jsx(z,{...e["zoom-out"]}),p.jsx(MA,{}),p.jsx(AA,{}),p.jsx(jA,{})]})})}function iee(){const e=le();return p.jsxs(we,{id:"extras",children:[p.jsx(z,{...e["insert-embed"]}),p.jsx(z,{...e["insert-media"]})]})}function aee(){return p.jsx(we,{id:"preferences",children:p.jsxs(xr,{id:"preferences",label:"menu.preferences",children:[p.jsxs(we,{id:"preferences-actions",children:[p.jsx(PJ,{}),p.jsx(CJ,{}),p.jsx(IJ,{}),p.jsx(EJ,{}),p.jsx(_J,{}),p.jsx(kJ,{}),p.jsx(TJ,{}),p.jsx($J,{}),p.jsx(MJ,{})]}),p.jsx(we,{id:"language",children:p.jsx(FA,{})})]})})}const lee=x.memo(function({children:n}){const t=mn(),[r,o]=Gs("main menu"),s=Ee(),i=n??p.jsx(QJ,{});return p.jsxs(ex,{dir:"ltr",open:r,onOpenChange:o,modal:!1,children:[p.jsx(tx,{asChild:!0,dir:"ltr",children:p.jsx(he,{type:"icon","data-testid":"main-menu.button",title:s("menu.title"),children:p.jsx(Ie,{icon:"menu",small:!0})})}),p.jsx(lg,{container:t,children:p.jsx(nx,{className:"tlui-menu",side:"bottom",align:"start",collisionPadding:4,alignOffset:0,sideOffset:6,children:p.jsx(So,{type:"menu",sourceId:"main-menu",children:i})})})]})}),cee=x.memo(function(){const n=Ln(),{MainMenu:t,QuickActions:r,ActionsMenu:o,PageMenu:s}=Xs();return!t&&!s&&n<6?null:p.jsx("div",{className:"tlui-menu-zone",children:p.jsxs("div",{className:"tlui-buttons__horizontal",children:[t&&p.jsx(t,{}),s&&p.jsx(s,{}),n<6?null:p.jsxs(p.Fragment,{children:[r&&p.jsx(r,{}),o&&p.jsx(o,{})]})]})})});class xc{constructor(n){m(this,"dpr",1);m(this,"colors",{shapeFill:"rgba(144, 144, 144, .1)",selectFill:"#2f80ed",viewportFill:"rgba(144, 144, 144, .1)"});m(this,"id",ze());m(this,"cvs",null);m(this,"pageBounds",[]);m(this,"collaborators",[]);m(this,"canvasScreenBounds",new ne);m(this,"canvasPageBounds",new ne);m(this,"contentPageBounds",new ne);m(this,"contentScreenBounds",new ne);m(this,"originPagePoint",new b);m(this,"originPageCenter",new b);m(this,"isInViewport",!1);m(this,"debug",!1);m(this,"updateContentScreenBounds",()=>{const{contentScreenBounds:n,contentPageBounds:t,canvasScreenBounds:r}=this;let{x:o,y:s,w:i,h:a}=n;if(t.w>t.h){const l=r.w/(t.w/t.h);l>r.h?(o=(r.w-r.w*(r.h/l))/2,s=0,i=r.w*(r.h/l),a=r.h):(o=0,s=(r.h-l)/2,i=r.w,a=l)}else if(t.w<t.h){const l=r.h/(t.h/t.w);o=(r.w-l)/2,s=0,i=l,a=r.h}else o=r.h/2,s=0,i=r.h,a=r.h;n.set(o,s,i,a)});m(this,"updateCanvasPageBounds",()=>{const{canvasPageBounds:n,canvasScreenBounds:t,contentPageBounds:r,contentScreenBounds:o}=this;n.set(0,0,r.width/(o.width/t.width),r.height/(o.height/t.height)),n.center=r.center});m(this,"getScreenPoint",(n,t)=>{const{canvasScreenBounds:r}=this,o=(n-r.minX)*this.dpr,s=(t-r.minY)*this.dpr;return{x:o,y:s}});m(this,"getPagePoint",(n,t)=>{const{contentPageBounds:r,contentScreenBounds:o,canvasPageBounds:s}=this,{x:i,y:a}=this.getScreenPoint(n,t);return new b(s.minX+i*r.width/o.width,s.minY+a*r.height/o.height,1)});m(this,"minimapScreenPointToPagePoint",(n,t,r=!1,o=!1)=>{const{editor:s}=this,i=s.getViewportPageBounds();let{x:a,y:l}=this.getPagePoint(n,t);if(o){const c=this.editor.getCurrentPageBounds(),u=i,d=((c==null?void 0:c.minX)??0)-u.width/2,h=((c==null?void 0:c.maxX)??0)+u.width/2,f=((c==null?void 0:c.minY)??0)-u.height/2,y=((c==null?void 0:c.maxY)??0)+u.height/2,g=Math.max(0,d+u.width-a),v=Math.max(0,-(h-u.width-a)),S=Math.max(0,f+u.height-l),w=Math.max(0,-(y-u.height-l)),C=Math.max(0,g-v),I=Math.max(0,v-g),P=Math.max(0,S-w),E=Math.max(0,w-S);C&&C>I?a+=C/2:I&&(a-=I/2),P&&P>E?l+=P/2:E&&(l-=E/2),a=ar(a,d,h),l=ar(l,f,y)}if(r){const{originPagePoint:c}=this,u=Math.abs(a-c.x),d=Math.abs(l-c.y);u>d?l=c.y:a=c.x}return new b(a,l)});m(this,"updateColors",()=>{const n=getComputedStyle(this.editor.getContainer());this.colors={shapeFill:n.getPropertyValue("--color-text-3").trim(),selectFill:n.getPropertyValue("--color-selected").trim(),viewportFill:n.getPropertyValue("--color-muted-1").trim()}});m(this,"render",()=>{const{cvs:n,pageBounds:t}=this;this.updateCanvasPageBounds();const{editor:r,canvasScreenBounds:o,canvasPageBounds:s,contentPageBounds:i,contentScreenBounds:a}=this,{width:l,height:c}=o,u=r.getSelectedShapeIds(),d=r.getViewportPageBounds();if(!n||!t)return;const h=n.getContext("2d");if(!h)throw new Error("Minimap (shapes): Could not get context");h.resetTransform(),h.globalAlpha=1,h.clearRect(0,0,l,c);const f=a.width/i.width,y=a.height/i.height;h.translate((l-a.width)/2,(c-a.height)/2),h.scale(f,y),h.translate(-i.minX,-i.minY);const g=8/f,v=8/f,S=1/f,w=1/f,C=g/4,I=v/4,P=new Path2D,E=new Path2D,{shapeFill:_,selectFill:k,viewportFill:M}=this.colors;let T;for(let L=0,G=t.length;L<G;L++)T=t[L],xc.roundedRect(u.includes(T.id)?E:P,T.minX,T.minY,T.width,T.height,ar(g,S,T.width/C),ar(v,w,T.height/I));if(h.fillStyle=_,h.fill(P),h.fillStyle=k,h.fill(E),this.debug){const L=ne.Common(t),{minX:G,minY:X,width:H,height:B}=L;h.strokeStyle="green",h.lineWidth=2/f,h.strokeRect(G+1/f,X+1/y,H-2/f,B-2/y)}{const{brush:L}=r.getInstanceState();if(L){const{x:G,y:X,w:H,h:B}=L;h.beginPath(),xc.sharpRect(h,G,X,H,B),h.closePath(),h.fillStyle=M,h.fill()}}{const{minX:L,minY:G,width:X,height:H}=d;h.beginPath();const B=12/f,W=12/f;xc.roundedRect(h,L,G,X,H,Math.min(X/4,B),Math.min(H/4,W)),h.closePath(),h.fillStyle=M,h.fill(),this.debug&&(h.strokeStyle="orange",h.strokeRect(L+1/f,G+1/y,X-2/f,H-2/y))}const R=2.5/f,O=2.5/y,U=r.getCurrentPageId();let N;for(let L=0;L<this.collaborators.length;L++)N=this.collaborators[L],N.currentPageId===U&&(h.beginPath(),h.ellipse(ar(N.cursor.x,s.minX+R,s.maxX-R),ar(N.cursor.y,s.minY+O,s.maxY-O),5/f,5/y,0,0,De),h.fillStyle=N.color,h.fill());if(this.debug){h.lineWidth=2/f;{const{minX:L,minY:G,width:X,height:H}=i;h.strokeStyle="red",h.strokeRect(L+1/f,G+1/y,X-2/f,H-2/y)}{const{minX:L,minY:G,width:X,height:H}=s;h.strokeStyle="blue",h.strokeRect(L+1/f,G+1/y,X-2/f,H-2/y)}}});this.editor=n}setDpr(n){this.dpr=+n.toFixed(2)}static roundedRect(n,t,r,o,s,i,a){if(i<1&&a<1){n.rect(t,r,o,s);return}n.moveTo(t+i,r),n.lineTo(t+o-i,r),n.quadraticCurveTo(t+o,r,t+o,r+a),n.lineTo(t+o,r+s-a),n.quadraticCurveTo(t+o,r+s,t+o-i,r+s),n.lineTo(t+i,r+s),n.quadraticCurveTo(t,r+s,t,r+s-a),n.lineTo(t,r+a),n.quadraticCurveTo(t,r,t+i,r)}static sharpRect(n,t,r,o,s,i,a){n.rect(t,r,o,s)}}function uee(){const e=F(),n=x.useRef(null),t=x.useRef(!1),r=Sf(),o=EI("dpr",()=>e.getInstanceState().devicePixelRatio,[e]),s=x.useMemo(()=>e.store.query.records("instance_presence"),[e]),i=x.useMemo(()=>new xc(e),[e]);x.useEffect(()=>{const d=requestAnimationFrame(()=>{i.updateColors(),i.render()});return()=>{cancelAnimationFrame(d)}},[e,i,r]);const a=x.useCallback(d=>{if(!e.getCurrentPageShapeIds().size)return;const h=i.minimapScreenPointToPagePoint(d.clientX,d.clientY,!1,!1),f=i.minimapScreenPointToPagePoint(d.clientX,d.clientY,!1,!0);i.originPagePoint.setTo(f),i.originPageCenter.setTo(e.getViewportPageBounds().center),e.centerOnPoint(h,{duration:Mo})},[e,i]),l=x.useCallback(d=>{const h=d.currentTarget;if(Su(h,d),!e.getCurrentPageShapeIds().size)return;t.current=!0,i.isInViewport=!1;const f=i.minimapScreenPointToPagePoint(d.clientX,d.clientY,!1,!1),y=i.minimapScreenPointToPagePoint(d.clientX,d.clientY,!1,!0),g=e.getViewportPageBounds();if(i.isInViewport=g.containsPoint(y),i.isInViewport)i.originPagePoint.setTo(y),i.originPageCenter.setTo(g.center);else{const S=b.Sub(g.center,g.point),w=b.Add(f,S);i.originPagePoint.setTo(w),i.originPageCenter.setTo(f),e.centerOnPoint(f,{duration:Mo})}function v(S){h&&vu(h,S),t.current=!1,document.body.removeEventListener("pointerup",v)}document.body.addEventListener("pointerup",v)},[e,i]),c=x.useCallback(d=>{const h=i.minimapScreenPointToPagePoint(d.clientX,d.clientY,d.shiftKey,!0);if(t.current){if(i.isInViewport){const v=i.originPagePoint.clone().sub(i.originPageCenter);e.centerOnPoint(b.Sub(h,v));return}e.centerOnPoint(h)}const f=i.getPagePoint(d.clientX,d.clientY),y=e.pageToScreen(f),g={type:"pointer",target:"canvas",name:"pointer_move",...In(d),point:y,isPen:e.getInstanceState().isPenMode};e.dispatch(g)},[e,i]),u=x.useCallback(d=>{const h=RE(d);e.dispatch({type:"wheel",name:"wheel",delta:h,point:new b(d.clientX,d.clientY),shiftKey:d.shiftKey,altKey:d.altKey,ctrlKey:d.metaKey||d.ctrlKey})},[e]);return fi("update when dpr changes",()=>{const d=o.get();i.setDpr(d);const h=n.current,f=h.getBoundingClientRect(),y=f.width*d,g=f.height*d;h.width=y,h.height=g,i.canvasScreenBounds.set(f.x,f.y,y,g),i.cvs=n.current},[o,i]),fi("minimap render when pagebounds or collaborators changes",()=>{const d=e.getCurrentPageShapeIds(),h=e.getCurrentPageBounds(),f=e.getViewportPageBounds();o.get(),i.contentPageBounds=h?ne.Expand(h,f):f,i.updateContentScreenBounds();const y=[];d.forEach(g=>{let v=e.getShapePageBounds(g);if(!v)return;const S=e.getShapeMask(g);if(S){const w=Hy(S,v.corners);if(!w)return;v=ne.FromPoints(w)}v&&(v.id=g,y.push(v))}),i.pageBounds=y,i.collaborators=s.get(),i.render()},[e,i]),p.jsx("div",{className:"tlui-minimap",children:p.jsx("canvas",{role:"img","aria-label":"minimap",ref:n,className:"tlui-minimap__canvas",onDoubleClick:a,onPointerMove:c,onPointerDown:l,onWheel:u})})}function dee(e,n){const[t,r]=ie.useState(n);ie.useLayoutEffect(()=>{const s=localStorage.getItem(e);if(s)try{r(JSON.parse(s))}catch{console.error(`Could not restore value ${e} from local storage.`)}},[e]);const o=ie.useCallback(s=>{r(i=>{const a=typeof s=="function"?s(i):s;return localStorage.setItem(e,JSON.stringify(a)),a})},[e]);return[t,o]}const hee=x.memo(function(){const n=le(),t=Ee(),r=Ln(),[o,s]=dee("minimap",!0),i=x.useCallback(()=>{s(c=>!c)},[s]),{ZoomMenu:a,Minimap:l}=Xs();return r<ht.MOBILE?null:p.jsxs("div",{className:"tlui-navigation-panel",children:[p.jsx("div",{className:"tlui-buttons__horizontal",children:a&&r<ht.TABLET?p.jsx(a,{}):o?p.jsxs(p.Fragment,{children:[a&&p.jsx(a,{}),l&&p.jsx(he,{type:"icon","data-testid":"minimap.toggle-button",title:t("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:i,children:p.jsx(Ie,{icon:o?"chevrons-ne":"chevrons-sw"})})]}):p.jsxs(p.Fragment,{children:[p.jsx(he,{type:"icon","data-testid":"minimap.zoom-out",title:`${t(au(n["zoom-out"].label))} ${uu(n["zoom-out"].kbd)}`,onClick:()=>n["zoom-out"].onSelect("navigation-zone"),children:p.jsx(Ie,{icon:"minus"})}),a&&p.jsx(a,{}),p.jsx(he,{type:"icon","data-testid":"minimap.zoom-in",title:`${t(au(n["zoom-in"].label))} ${uu(n["zoom-in"].kbd)}`,onClick:()=>n["zoom-in"].onSelect("navigation-zone"),children:p.jsx(Ie,{icon:"plus"})}),l&&p.jsx(he,{type:"icon","data-testid":"minimap.toggle-button",title:t("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:i,children:p.jsx(Ie,{icon:o?"chevrons-ne":"chevrons-sw"})})]})}),l&&r>=ht.TABLET&&!o&&p.jsx(l,{})]})}),pee=function({name:n,id:t,isCurrentPage:r}){const o=F(),s=x.useRef(null),i=x.useCallback(l=>{o.renamePage(t,l||"New Page",{ephemeral:!0})},[o,t]),a=x.useCallback(l=>{o.mark("rename page"),o.renamePage(t,l||"New Page",{ephemeral:!1})},[o,t]);return p.jsx(Gw,{className:"tlui-page-menu__item__input",ref:l=>s.current=l,defaultValue:n,onValueChange:i,onComplete:a,onCancel:a,shouldManuallyMaintainScrollPositionWhenFocused:!0,autofocus:r,autoselect:!0})},xv=(e,n,t,r)=>{let o;const s=e.getPages(),i=t>r?s[r-1]:s[r],a=t>r?s[r]:s[r+1];i&&!a?o=ko(i.index):!i&&a?o=pD(s[0].index):o=oc(i.index,a.index),o!==s[t].index&&(e.mark("moving page"),e.updatePage({id:n,index:o}))},QC=Tt(function({index:n,listSize:t,item:r,onRename:o}){const s=F(),i=Ee(),a=s.getPages(),l=x.useCallback(()=>{s.mark("creating page");const h=zo.createId();s.duplicatePage(r.id,h)},[s,r]),c=x.useCallback(()=>{xv(s,r.id,n,n-1)},[s,r,n]),u=x.useCallback(()=>{xv(s,r.id,n,n+1)},[s,r,n]),d=x.useCallback(()=>{s.mark("deleting page"),s.deletePage(r.id)},[s,r]);return p.jsxs(Ti,{id:`page item submenu ${n}`,children:[p.jsx($i,{children:p.jsx(he,{type:"icon",title:i("page-menu.submenu.title"),children:p.jsx(Ie,{icon:"dots-vertical"})})}),p.jsx(Mi,{alignOffset:0,side:"right",sideOffset:-4,children:p.jsxs(So,{type:"menu",sourceId:"page-menu",children:[p.jsxs(we,{id:"modify",children:[o&&p.jsx(z,{id:"rename",label:"page-menu.submenu.rename",onSelect:o}),p.jsx(z,{id:"duplicate",label:"page-menu.submenu.duplicate-page",onSelect:l,disabled:a.length>=fp}),n>0&&p.jsx(z,{id:"move-up",onSelect:c,label:"page-menu.submenu.move-up"}),n<t-1&&p.jsx(z,{id:"move-down",label:"page-menu.submenu.move-down",onSelect:u})]}),t>1&&p.jsx(we,{id:"delete",children:p.jsx(z,{id:"delete",onSelect:d,label:"page-menu.submenu.delete"})})]})})]})}),fee=x.memo(function(){const n=F(),t=Ee(),r=Ln(),o=x.useCallback(()=>v(!1),[]),[s,i]=Gs("page-menu",o),a=36,l=x.useRef(null),c=K("pages",()=>n.getPages(),[n]),u=K("currentPage",()=>n.getCurrentPage(),[n]),d=K("currentPageId",()=>n.getCurrentPageId(),[n]),h=fo(),f=K("maxPageCountReached",()=>n.getPages().length>=fp,[n]),y=K("isCoarsePointer",()=>n.getInstanceState().isCoarsePointer,[n]),[g,v]=x.useState(!1),S=x.useCallback(()=>{h||v(T=>!T)},[h]),w=x.useRef({isPointing:!1,status:"idle",pointing:null,startY:0,startIndex:0,dragIndex:0}),[C,I]=x.useState(Object.fromEntries(c.map((T,R)=>[T.id,{y:R*a,offsetY:0,isSelected:!1}])));x.useLayoutEffect(()=>{I(Object.fromEntries(c.map((T,R)=>[T.id,{y:R*a,offsetY:0,isSelected:!1}])))},[a,c]),x.useEffect(()=>{s&&requestAnimationFrame(()=>{const T=document.querySelector(`[data-testid="page-menu-item-${d}"]`);if(T){const R=l.current;if(!R)return;const O=T.offsetTop,U=R.scrollTop;O<U&&R.scrollTo({top:O});const N=O+a,L=R.scrollTop+R.offsetHeight;N>L&&R.scrollTo({top:N-R.offsetHeight})}})},[a,d,s]);const P=x.useCallback(T=>{const{clientY:R,currentTarget:O}=T,{dataset:{id:U,index:N}}=O;if(!U||!N)return;const L=w.current;Su(T.currentTarget,T),L.status="pointing",L.pointing={id:U,index:+N};const X=C[U].y;L.startY=R,L.startIndex=Math.max(0,Math.min(Math.round(X/a),c.length-1))},[a,c.length,C]),E=x.useCallback(T=>{const R=w.current;if(R.status==="pointing"){const{clientY:O}=T,U=O-R.startY;Math.abs(U)>5&&(R.status="dragging")}if(R.status==="dragging"){const{clientY:O}=T,U=O-R.startY,N=C[R.pointing.id],{startIndex:L,pointing:G}=R,X=N.y+U,H=Math.max(0,Math.min(Math.round(X/a),c.length-1)),B={...C};if(B[G.id]={y:N.y,offsetY:U,isSelected:!0},H!==R.dragIndex){R.dragIndex=H;for(let W=0;W<c.length;W++){const Y=c[W];if(Y.id===R.pointing.id)continue;let{y:J}=B[Y.id];H===L?J=W*a:H<L?H<=W&&W<L?J=(W+1)*a:J=W*a:H>L&&(H>=W&&W>L?J=(W-1)*a:J=W*a),J!==B[Y.id].y&&(B[Y.id]={y:J,offsetY:0,isSelected:!0})}}I(B)}},[a,c,C]),_=x.useCallback(T=>{const R=w.current;if(R.status==="dragging"){const{id:O,index:U}=R.pointing;xv(n,O,U,R.dragIndex)}vu(T.currentTarget,T),R.status="idle"},[n]),k=x.useCallback(T=>{const R=w.current;T.key==="Escape"&&(R.status==="dragging"&&I(Object.fromEntries(c.map((O,U)=>[O.id,{y:U*a,offsetY:0,isSelected:!1}]))),R.status="idle")},[a,c]),M=x.useCallback(()=>{h||n.batch(()=>{n.mark("creating page");const T=zo.createId();n.createPage({name:t("page-menu.new-page-initial-name"),id:T}),n.setCurrentPage(T),v(!0)})},[n,t,h]);return p.jsxs(Hw,{id:"pages",onOpenChange:i,open:s,children:[p.jsx(Kw,{"data-testid":"main.page-menu",children:p.jsxs(he,{type:"menu",title:u.name,"data-testid":"page-menu.button",className:"tlui-page-menu__trigger",children:[p.jsx("div",{className:"tlui-page-menu__name",children:u.name}),p.jsx(Ie,{icon:"chevron-down",small:!0})]})}),p.jsx(Vw,{side:"bottom",align:"start",sideOffset:6,children:p.jsxs("div",{className:"tlui-page-menu__wrapper",children:[p.jsxs("div",{className:"tlui-page-menu__header",children:[p.jsx("div",{className:"tlui-page-menu__header__title",children:t("page-menu.title")}),!h&&p.jsxs("div",{className:"tlui-buttons__horizontal",children:[p.jsx(he,{type:"icon","data-testid":"page-menu.edit",title:t(g?"page-menu.edit-done":"page-menu.edit-start"),onClick:S,children:p.jsx(Ie,{icon:g?"check":"edit"})}),p.jsx(he,{type:"icon","data-testid":"page-menu.create",title:t(f?"page-menu.max-page-count-reached":"page-menu.create-new-page"),disabled:f,onClick:M,children:p.jsx(Ie,{icon:"plus"})})]})]}),p.jsx("div",{"data-testid":"page-menu.list",className:"tlui-page-menu__list tlui-menu__group",style:{height:a*c.length+4},ref:l,children:c.map((T,R)=>{const O=C[T.id]??{position:R*40,offsetY:0};return g?p.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page_menu__item__sortable",style:{zIndex:T.id===u.id?888:R,transform:`translate(0px, ${O.y+O.offsetY}px)`},children:[p.jsx(he,{type:"icon",tabIndex:-1,className:"tlui-page_menu__item__sortable__handle",onPointerDown:P,onPointerUp:_,onPointerMove:E,onKeyDown:k,"data-id":T.id,"data-index":R,children:p.jsx(Ie,{icon:"drag-handle-dots"})}),r<ht.TABLET_SM&&y?p.jsxs(he,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>{const U=window.prompt("Rename page",T.name);U&&U!==T.name&&n.renamePage(T.id,U)},onDoubleClick:S,children:[p.jsx(wv,{checked:T.id===u.id}),p.jsx(mt,{children:T.name})]}):p.jsx("div",{className:"tlui-page_menu__item__sortable__title",style:{height:a},children:p.jsx(pee,{id:T.id,name:T.name,isCurrentPage:T.id===u.id})}),!h&&p.jsx("div",{className:"tlui-page_menu__item__submenu","data-isediting":g,children:p.jsx(QC,{index:R,item:T,listSize:c.length})})]},T.id+"_editing"):p.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page-menu__item",children:[p.jsxs(he,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>n.setCurrentPage(T.id),onDoubleClick:S,title:t("page-menu.go-to-page"),children:[p.jsx(wv,{checked:T.id===u.id}),p.jsx(mt,{children:T.name})]}),!h&&p.jsx("div",{className:"tlui-page_menu__item__submenu",children:p.jsx(QC,{index:R,item:T,listSize:c.length,onRename:()=>{if(n.environment.isIos){const U=window.prompt("Rename page",T.name);U&&U!==T.name&&n.renamePage(T.id,U)}else n.batch(()=>{v(!0),n.setCurrentPage(T.id)})}})})]},T.id)})})]})})]})});function gee(){const e=le(),n=F(),t=_k(),r=Ek(),o=an(1),s=fo(),i=K("should display quick actions",()=>n.isInAny("select","hand","zoom"),[n]);if(!(s&&!i))return p.jsxs(p.Fragment,{children:[p.jsx(z,{...e.undo,disabled:!t}),p.jsx(z,{...e.redo,disabled:!r}),p.jsx(z,{...e.delete,disabled:!o}),p.jsx(z,{...e.duplicate,disabled:!o})]})}const mee=x.memo(function({children:n}){const t=n??p.jsx(gee,{});return p.jsx(So,{type:"small-icons",sourceId:"quick-actions",children:t})}),yee=Object.freeze([mr,yi,Ua,co]);function BA(e=yee){const n=F();return K("getRelevantStyles",()=>{var s;const t=new Ky(n.getSharedStyles()),r=!!((s=n.root.getCurrent())!=null&&s.shapeType),o=n.isIn("select")&&n.getSelectedShapeIds().length>0;if(t.size===0&&n.isIn("select")&&n.getSelectedShapeIds().length===0)for(const i of e)t.applyValue(i,n.getStyleForNextShape(i));return r||o||t.size>0?t:null},[n])}const Or={color:[{value:"black",icon:"color"},{value:"grey",icon:"color"},{value:"light-violet",icon:"color"},{value:"violet",icon:"color"},{value:"blue",icon:"color"},{value:"light-blue",icon:"color"},{value:"yellow",icon:"color"},{value:"orange",icon:"color"},{value:"green",icon:"color"},{value:"light-green",icon:"color"},{value:"light-red",icon:"color"},{value:"red",icon:"color"}],fill:[{value:"none",icon:"fill-none"},{value:"semi",icon:"fill-semi"},{value:"solid",icon:"fill-solid"},{value:"pattern",icon:"fill-pattern"}],dash:[{value:"draw",icon:"dash-draw"},{value:"dashed",icon:"dash-dashed"},{value:"dotted",icon:"dash-dotted"},{value:"solid",icon:"dash-solid"}],size:[{value:"s",icon:"size-small"},{value:"m",icon:"size-medium"},{value:"l",icon:"size-large"},{value:"xl",icon:"size-extra-large"}],font:[{value:"draw",icon:"font-draw"},{value:"sans",icon:"font-sans"},{value:"serif",icon:"font-serif"},{value:"mono",icon:"font-mono"}],horizontalAlign:[{value:"start",icon:"text-align-left"},{value:"middle",icon:"text-align-center"},{value:"end",icon:"text-align-right"}],verticalAlign:[{value:"start",icon:"vertical-align-start"},{value:"middle",icon:"vertical-align-center"},{value:"end",icon:"vertical-align-end"}],geo:[{value:"rectangle",icon:"geo-rectangle"},{value:"ellipse",icon:"geo-ellipse"},{value:"cloud",icon:"geo-cloud"},{value:"triangle",icon:"geo-triangle"},{value:"diamond",icon:"geo-diamond"},{value:"pentagon",icon:"geo-pentagon"},{value:"hexagon",icon:"geo-hexagon"},{value:"octagon",icon:"geo-octagon"},{value:"star",icon:"geo-star"},{value:"rhombus",icon:"geo-rhombus"},{value:"rhombus-2",icon:"geo-rhombus-2"},{value:"oval",icon:"geo-oval"},{value:"trapezoid",icon:"geo-trapezoid"},{value:"arrow-right",icon:"geo-arrow-right"},{value:"arrow-left",icon:"geo-arrow-left"},{value:"arrow-up",icon:"geo-arrow-up"},{value:"arrow-down",icon:"geo-arrow-down"},{value:"x-box",icon:"geo-x-box"},{value:"check-box",icon:"geo-check-box"}],arrowheadStart:[{value:"none",icon:"arrowhead-none"},{value:"arrow",icon:"arrowhead-arrow"},{value:"triangle",icon:"arrowhead-triangle"},{value:"square",icon:"arrowhead-square"},{value:"dot",icon:"arrowhead-dot"},{value:"diamond",icon:"arrowhead-diamond"},{value:"inverted",icon:"arrowhead-triangle-inverted"},{value:"bar",icon:"arrowhead-bar"}],arrowheadEnd:[{value:"none",icon:"arrowhead-none"},{value:"arrow",icon:"arrowhead-arrow"},{value:"triangle",icon:"arrowhead-triangle"},{value:"square",icon:"arrowhead-square"},{value:"dot",icon:"arrowhead-dot"},{value:"diamond",icon:"arrowhead-diamond"},{value:"inverted",icon:"arrowhead-triangle-inverted"},{value:"bar",icon:"arrowhead-bar"}],spline:[{value:"line",icon:"spline-line"},{value:"cubic",icon:"spline-cubic"}]};function See(e){const{uiType:n,items:t,title:r,style:o,value:s,onValueChange:i}=e,a=F(),l=Ee(),c=x.useRef(!1),{handleButtonClick:u,handleButtonPointerDown:d,handleButtonPointerEnter:h,handleButtonPointerUp:f}=x.useMemo(()=>{const g=()=>{c.current=!1,window.removeEventListener("pointerup",g)};return{handleButtonClick:I=>{const{id:P}=I.currentTarget.dataset;s.type==="shared"&&s.value===P||(a.mark("point picker item"),i(o,P,!1))},handleButtonPointerDown:I=>{const{id:P}=I.currentTarget.dataset;a.mark("point picker item"),i(o,P,!0),c.current=!0,window.addEventListener("pointerup",g)},handleButtonPointerEnter:I=>{if(!c.current)return;const{id:P}=I.currentTarget.dataset;i(o,P,!0)},handleButtonPointerUp:I=>{const{id:P}=I.currentTarget.dataset;s.type==="shared"&&s.value===P||i(o,P,!1)}}},[s,a,i,o]),y=K("theme",()=>Dn({isDarkMode:a.user.getIsDarkMode()}),[a]);return p.jsx("div",{"data-testid":`style.${n}`,className:fe("tlui-buttons__grid"),children:t.map(g=>p.jsx(he,{type:"icon","data-id":g.value,"data-testid":`style.${n}.${g.value}`,"aria-label":g.value,"data-state":s.type==="shared"&&s.value===g.value?"hinted":void 0,title:r+" — "+l(`${n}-style.${g.value}`),className:fe("tlui-button-grid__button"),style:o===mr?{color:y[g.value].solid}:void 0,onPointerEnter:h,onPointerDown:d,onPointerUp:f,onClick:u,children:p.jsx(Ie,{icon:g.icon})},g.value))})}const Ta=x.memo(See);function UA(e,[n,t]){return Math.min(t,Math.max(n,e))}function vee(e){const n=x.useRef({value:e,previous:e});return x.useMemo(()=>(n.current.value!==e&&(n.current.previous=n.current.value,n.current.value=e),n.current.previous),[e])}const HA=["PageUp","PageDown"],KA=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],VA={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Fu="Slider",[bv,wee,xee]=Wf(Fu),[WA,Rne]=go(Fu,[xee]),[bee,cg]=WA(Fu),Pee=x.forwardRef((e,n)=>{const{name:t,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[r],value:u,onValueChange:d=()=>{},onValueCommit:h=()=>{},inverted:f=!1,...y}=e,[g,v]=x.useState(null),S=Ye(n,N=>v(N)),w=x.useRef(new Set),C=x.useRef(0),I=i==="horizontal",P=g?!!g.closest("form"):!0,E=I?Cee:Iee,[_=[],k]=Ws({prop:u,defaultProp:c,onChange:N=>{var L;(L=[...w.current][C.current])===null||L===void 0||L.focus(),d(N)}}),M=x.useRef(_);function T(N){const L=Oee(_,N);U(N,L)}function R(N){U(N,C.current)}function O(){const N=M.current[C.current];_[C.current]!==N&&h(_)}function U(N,L,{commit:G}={commit:!1}){const X=Nee(s),H=Fee(Math.round((N-r)/s)*s+r,X),B=UA(H,[r,o]);k((W=[])=>{const Y=Aee(W,B,L);if(Lee(Y,l*s)){C.current=Y.indexOf(B);const J=String(Y)!==String(W);return J&&G&&h(Y),J?Y:W}else return W})}return x.createElement(bee,{scope:e.__scopeSlider,disabled:a,min:r,max:o,valueIndexToChangeRef:C,thumbs:w.current,values:_,orientation:i},x.createElement(bv.Provider,{scope:e.__scopeSlider},x.createElement(bv.Slot,{scope:e.__scopeSlider},x.createElement(E,Q({"aria-disabled":a,"data-disabled":a?"":void 0},y,{ref:S,onPointerDown:se(y.onPointerDown,()=>{a||(M.current=_)}),min:r,max:o,inverted:f,onSlideStart:a?void 0:T,onSlideMove:a?void 0:R,onSlideEnd:a?void 0:O,onHomeKeyDown:()=>!a&&U(r,0,{commit:!0}),onEndKeyDown:()=>!a&&U(o,_.length-1,{commit:!0}),onStepKeyDown:({event:N,direction:L})=>{if(!a){const H=HA.includes(N.key)||N.shiftKey&&KA.includes(N.key)?10:1,B=C.current,W=_[B],Y=s*H*L;U(W+Y,B,{commit:!0})}}})))),P&&_.map((N,L)=>x.createElement(Mee,{key:L,name:t?t+(_.length>1?"[]":""):void 0,value:N})))}),[GA,YA]=WA(Fu,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Cee=x.forwardRef((e,n)=>{const{min:t,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:l,onStepKeyDown:c,...u}=e,[d,h]=x.useState(null),f=Ye(n,C=>h(C)),y=x.useRef(),g=qw(o),v=g==="ltr",S=v&&!s||!v&&s;function w(C){const I=y.current||d.getBoundingClientRect(),P=[0,I.width],_=ox(P,S?[t,r]:[r,t]);return y.current=I,_(C-I.left)}return x.createElement(GA,{scope:e.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width"},x.createElement(XA,Q({dir:g,"data-orientation":"horizontal"},u,{ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const I=w(C.clientX);i==null||i(I)},onSlideMove:C=>{const I=w(C.clientX);a==null||a(I)},onSlideEnd:()=>{y.current=void 0,l==null||l()},onStepKeyDown:C=>{const P=VA[S?"from-left":"from-right"].includes(C.key);c==null||c({event:C,direction:P?-1:1})}})))}),Iee=x.forwardRef((e,n)=>{const{min:t,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:l,...c}=e,u=x.useRef(null),d=Ye(n,u),h=x.useRef(),f=!o;function y(g){const v=h.current||u.current.getBoundingClientRect(),S=[0,v.height],C=ox(S,f?[r,t]:[t,r]);return h.current=v,C(g-v.top)}return x.createElement(GA,{scope:e.__scopeSlider,startEdge:f?"bottom":"top",endEdge:f?"top":"bottom",size:"height",direction:f?1:-1},x.createElement(XA,Q({"data-orientation":"vertical"},c,{ref:d,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:g=>{const v=y(g.clientY);s==null||s(v)},onSlideMove:g=>{const v=y(g.clientY);i==null||i(v)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:g=>{const S=VA[f?"from-bottom":"from-top"].includes(g.key);l==null||l({event:g,direction:S?-1:1})}})))}),XA=x.forwardRef((e,n)=>{const{__scopeSlider:t,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:l,...c}=e,u=cg(Fu,t);return x.createElement(Be.span,Q({},c,{ref:n,onKeyDown:se(e.onKeyDown,d=>{d.key==="Home"?(i(d),d.preventDefault()):d.key==="End"?(a(d),d.preventDefault()):HA.concat(KA).includes(d.key)&&(l(d),d.preventDefault())}),onPointerDown:se(e.onPointerDown,d=>{const h=d.target;h.setPointerCapture(d.pointerId),d.preventDefault(),u.thumbs.has(h)?h.focus():r(d)}),onPointerMove:se(e.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&o(d)}),onPointerUp:se(e.onPointerUp,d=>{const h=d.target;h.hasPointerCapture(d.pointerId)&&(h.releasePointerCapture(d.pointerId),s(d))})}))}),Eee="SliderTrack",_ee=x.forwardRef((e,n)=>{const{__scopeSlider:t,...r}=e,o=cg(Eee,t);return x.createElement(Be.span,Q({"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation},r,{ref:n}))}),JC="SliderRange",kee=x.forwardRef((e,n)=>{const{__scopeSlider:t,...r}=e,o=cg(JC,t),s=YA(JC,t),i=x.useRef(null),a=Ye(n,i),l=o.values.length,c=o.values.map(h=>qA(h,o.min,o.max)),u=l>1?Math.min(...c):0,d=100-Math.max(...c);return x.createElement(Be.span,Q({"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0},r,{ref:a,style:{...e.style,[s.startEdge]:u+"%",[s.endEdge]:d+"%"}}))}),eI="SliderThumb",Tee=x.forwardRef((e,n)=>{const t=wee(e.__scopeSlider),[r,o]=x.useState(null),s=Ye(n,a=>o(a)),i=x.useMemo(()=>r?t().findIndex(a=>a.ref.current===r):-1,[t,r]);return x.createElement($ee,Q({},e,{ref:s,index:i}))}),$ee=x.forwardRef((e,n)=>{const{__scopeSlider:t,index:r,...o}=e,s=cg(eI,t),i=YA(eI,t),[a,l]=x.useState(null),c=Ye(n,v=>l(v)),u=rM(a),d=s.values[r],h=d===void 0?0:qA(d,s.min,s.max),f=jee(r,s.values.length),y=u==null?void 0:u[i.size],g=y?Dee(y,h,i.direction):0;return x.useEffect(()=>{if(a)return s.thumbs.add(a),()=>{s.thumbs.delete(a)}},[a,s.thumbs]),x.createElement("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${h}% + ${g}px)`}},x.createElement(bv.ItemSlot,{scope:e.__scopeSlider},x.createElement(Be.span,Q({role:"slider","aria-label":e["aria-label"]||f,"aria-valuemin":s.min,"aria-valuenow":d,"aria-valuemax":s.max,"aria-orientation":s.orientation,"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,tabIndex:s.disabled?void 0:0},o,{ref:c,style:d===void 0?{display:"none"}:e.style,onFocus:se(e.onFocus,()=>{s.valueIndexToChangeRef.current=r})}))))}),Mee=e=>{const{value:n,...t}=e,r=x.useRef(null),o=vee(n);return x.useEffect(()=>{const s=r.current,i=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(i,"value").set;if(o!==n&&l){const c=new Event("input",{bubbles:!0});l.call(s,n),s.dispatchEvent(c)}},[o,n]),x.createElement("input",Q({style:{display:"none"}},t,{ref:r,defaultValue:n}))};function Aee(e=[],n,t){const r=[...e];return r[t]=n,r.sort((o,s)=>o-s)}function qA(e,n,t){const s=100/(t-n)*(e-n);return UA(s,[0,100])}function jee(e,n){return n>2?`Value ${e+1} of ${n}`:n===2?["Minimum","Maximum"][e]:void 0}function Oee(e,n){if(e.length===1)return 0;const t=e.map(o=>Math.abs(o-n)),r=Math.min(...t);return t.indexOf(r)}function Dee(e,n,t){const r=e/2,s=ox([0,50],[0,r]);return(r-s(n)*t)*t}function Ree(e){return e.slice(0,-1).map((n,t)=>e[t+1]-n)}function Lee(e,n){if(n>0){const t=Ree(e);return Math.min(...t)>=n}return!0}function ox(e,n){return t=>{if(e[0]===e[1]||n[0]===n[1])return n[0];const r=(n[1]-n[0])/(e[1]-e[0]);return n[0]+r*(t-e[0])}}function Nee(e){return(String(e).split(".")[1]||"").length}function Fee(e,n){const t=Math.pow(10,n);return Math.round(e*t)/t}const zee=Pee,Bee=_ee,Uee=kee,Hee=Tee,Kee=x.memo(function(n){const{title:t,steps:r,value:o,label:s,onValueChange:i}=n,a=F(),l=Ee(),c=x.useCallback(h=>{i(h[0],!0)},[i]),u=x.useCallback(()=>{a.mark("click slider")},[a]),d=x.useCallback(()=>{o&&i(o,!1)},[o,i]);return p.jsx("div",{className:"tlui-slider__container",children:p.jsxs(zee,{"data-testid":n["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:d,title:t+" — "+l(s),children:[p.jsx(Bee,{className:"tlui-slider__track",dir:"ltr",children:o!==null&&p.jsx(Uee,{className:"tlui-slider__range",dir:"ltr"})}),o!==null&&p.jsx(Hee,{className:"tlui-slider__thumb",dir:"ltr"})]})})});function Vee({label:e,uiTypeA:n,uiTypeB:t,labelA:r,labelB:o,itemsA:s,itemsB:i,styleA:a,styleB:l,valueA:c,valueB:u,onValueChange:d}){const h=Ee(),f=x.useMemo(()=>{var g;return((g=s.find(v=>c.type==="shared"&&c.value===v.value))==null?void 0:g.icon)??"mixed"},[s,c]),y=x.useMemo(()=>{var g;return((g=i.find(v=>u.type==="shared"&&u.value===v.value))==null?void 0:g.icon)??"mixed"},[i,u]);return c===void 0&&u===void 0?null:p.jsxs("div",{className:"tlui-style-panel__double-select-picker",children:[p.jsx("div",{title:h(e),className:"tlui-style-panel__double-select-picker-label",children:h(e)}),p.jsxs("div",{className:"tlui-buttons__horizontal",children:[p.jsxs(Ti,{id:`style panel ${n} A`,children:[p.jsx($i,{children:p.jsx(he,{type:"icon","data-testid":`style.${n}`,title:h(r)+" — "+(c===null||c.type==="mixed"?h("style-panel.mixed"):h(`${n}-style.${c.value}`)),children:p.jsx(Ie,{icon:f,small:!0,invertIcon:!0})})}),p.jsx(Mi,{side:"bottom",align:"end",sideOffset:0,alignOffset:-2,children:p.jsx("div",{className:"tlui-buttons__grid",children:s.map((g,v)=>p.jsx(du,{"data-testid":`style.${n}.${g.value}`,children:p.jsx(he,{type:"icon",onClick:()=>d(a,g.value,!1),title:`${h(r)} — ${h(`${n}-style.${g.value}`)}`,children:p.jsx(Ie,{icon:g.icon,invertIcon:!0})},g.value)},v))})})]}),p.jsxs(Ti,{id:`style panel ${t}`,children:[p.jsx($i,{children:p.jsx(he,{type:"icon","data-testid":`style.${t}`,title:h(o)+" — "+(u===null||u.type==="mixed"?h("style-panel.mixed"):h(`${t}-style.${u.value}`)),children:p.jsx(Ie,{icon:y,small:!0})})}),p.jsx(Mi,{side:"bottom",align:"end",sideOffset:0,alignOffset:-2,children:p.jsx("div",{className:"tlui-buttons__grid",children:i.map(g=>p.jsx(du,{children:p.jsx(he,{type:"icon",title:`${h(o)} — ${h(`${t}-style.${g.value}`)}`,"data-testid":`style.${t}.${g.value}`,onClick:()=>d(l,g.value,!1),children:p.jsx(Ie,{icon:g.icon})})},g.value))})})]})]})]})}const Wee=x.memo(Vee);function Gee({id:e,label:n,uiType:t,style:r,items:o,type:s,value:i,onValueChange:a}){const l=Ee(),c=F(),u=x.useMemo(()=>{var f;return(f=o.find(y=>i.type==="shared"&&y.value===i.value))==null?void 0:f.icon},[o,i]),d=i.type==="mixed"?l("style-panel.mixed"):l(`${t}-style.${i.value}`),h=n?l(n):"";return p.jsxs(Ti,{id:`style panel ${e}`,children:[p.jsx($i,{children:p.jsxs(he,{type:s,"data-testid":`style.${t}`,title:d,children:[p.jsx(mt,{children:h}),p.jsx(Ie,{icon:u??"mixed"})]})}),p.jsx(Mi,{side:"left",align:"center",alignOffset:0,children:p.jsx("div",{className:"tlui-buttons__grid",children:o.map(f=>p.jsx(du,{children:p.jsx(he,{type:"icon","data-testid":`style.${t}.${f.value}`,title:l(`${t}-style.${f.value}`),onClick:()=>{c.mark("select style dropdown item"),a(r,f.value,!1)},children:p.jsx(Ie,{icon:f.icon})})},f.value))})})]})}const sx=x.memo(Gee);function Yee({styles:e}){if(!e)return null;const n=e.get(so),t=e.get(cp),r=e.get(lp),o=e.get(dp),s=e.get(lo),i=n===void 0,a=t===void 0&&r===void 0,l=o===void 0,c=s===void 0;return p.jsxs(p.Fragment,{children:[p.jsx(Xee,{styles:e}),!c&&p.jsx(qee,{styles:e}),!(i&&a&&l)&&p.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[p.jsx(Zee,{styles:e}),p.jsx(Jee,{styles:e}),p.jsx(Qee,{styles:e})]})]})}function zu(){const e=F(),n=yo();return ie.useMemo(()=>function(r,o,s){e.batch(()=>{e.isIn("select")&&e.setStyleForSelectedShapes(r,o,{squashing:s}),e.setStyleForNextShapes(r,o,{squashing:s}),e.updateInstanceState({isChangingStyle:!0},{ephemeral:!0})}),n("set-style",{source:"style-panel",id:r.id,value:o})},[e,n])}function Xee({styles:e}){const n=Ee(),t=zu(),r=e.get(mr),o=e.get(Ua),s=e.get(yi),i=e.get(co),a=o!==void 0||s!==void 0||i!==void 0;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{tabIndex:-1,className:"tlui-style-panel__section__common","aria-label":"style panel styles","data-testid":"style.panel",children:[r===void 0?null:p.jsx(Ta,{title:n("style-panel.color"),uiType:"color",style:mr,items:Or.color,value:r,onValueChange:t}),p.jsx(ete,{})]}),a&&p.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[o===void 0?null:p.jsx(Ta,{title:n("style-panel.fill"),uiType:"fill",style:Ua,items:Or.fill,value:o,onValueChange:t}),s===void 0?null:p.jsx(Ta,{title:n("style-panel.dash"),uiType:"dash",style:yi,items:Or.dash,value:s,onValueChange:t}),i===void 0?null:p.jsx(Ta,{title:n("style-panel.size"),uiType:"size",style:co,items:Or.size,value:i,onValueChange:t})]})]})}function qee({styles:e}){const n=Ee(),t=zu(),r=e.get(lo),o=e.get(Ec),s=e.get(up);return r===void 0&&o===void 0?null:p.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel text",children:[r===void 0?null:p.jsx(Ta,{title:n("style-panel.font"),uiType:"font",style:lo,items:Or.font,value:r,onValueChange:t}),o===void 0?null:p.jsxs("div",{className:"tlui-style-panel__row",children:[p.jsx(Ta,{title:n("style-panel.align"),uiType:"align",style:Ec,items:Or.horizontalAlign,value:o,onValueChange:t}),p.jsx("div",{className:"tlui-style-panel__row__extra-button",children:s===void 0?p.jsx(he,{type:"icon",title:n("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:p.jsx(Ie,{icon:"vertical-align-center"})}):p.jsx(sx,{type:"icon",id:"geo-vertical-alignment",uiType:"verticalAlign",style:up,items:Or.verticalAlign,value:s,onValueChange:t})})]})]})}function Zee({styles:e}){const n=zu(),t=e.get(so);return t===void 0?null:p.jsx(sx,{id:"geo",type:"menu",label:"style-panel.geo",uiType:"geo",style:so,items:Or.geo,value:t,onValueChange:n})}function Qee({styles:e}){const n=zu(),t=e.get(dp);return t===void 0?null:p.jsx(sx,{id:"spline",type:"menu",label:"style-panel.spline",uiType:"spline",style:dp,items:Or.spline,value:t,onValueChange:n})}function Jee({styles:e}){const n=zu(),t=e.get(cp),r=e.get(lp);return!t||!r?null:p.jsx(Wee,{label:"style-panel.arrowheads",uiTypeA:"arrowheadStart",styleA:lp,itemsA:Or.arrowheadStart,valueA:r,uiTypeB:"arrowheadEnd",styleB:cp,itemsB:Or.arrowheadEnd,valueB:t,onValueChange:n,labelA:"style-panel.arrowhead-start",labelB:"style-panel.arrowhead-end"})}const Vl=[.1,.25,.5,.75,1];function ete(){const e=F(),n=K("opacity",()=>e.getSharedOpacity(),[e]),t=yo(),r=Ee(),o=ie.useCallback((i,a)=>{const l=Vl[i];e.batch(()=>{e.isIn("select")&&e.setOpacityForSelectedShapes(l,{squashing:a}),e.setOpacityForNextShapes(l,{squashing:a}),e.updateInstanceState({isChangingStyle:!0},{ephemeral:!0})}),t("set-style",{source:"style-panel",id:"opacity",value:i})},[e,t]);if(n===void 0)return null;const s=n.type==="mixed"?-1:Vl.indexOf(nD(Vl,i=>Math.abs(i-n.value)));return p.jsx(Kee,{"data-testid":"style.opacity",value:s>=0?s:Vl.length-1,label:n.type==="mixed"?"style-panel.mixed":`opacity-style.${n.value}`,onValueChange:o,steps:Vl.length-1,title:r("style-panel.opacity")})}const tte=x.memo(function({isMobile:n,children:t}){const r=F(),o=BA(),s=x.useCallback(()=>{n||r.updateInstanceState({isChangingStyle:!1},{ephemeral:!0})},[r,n]),i=t??p.jsx(Yee,{styles:o});return p.jsx("div",{className:fe("tlui-style-panel",{"tlui-style-panel__wrapper":!n}),"data-ismobile":n,onPointerLeave:s,children:i})}),oy=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function sy(e,n,t,r){e.addEventListener?e.addEventListener(n,t,r):e.attachEvent&&e.attachEvent("on".concat(n),t)}function Wl(e,n,t,r){e.removeEventListener?e.removeEventListener(n,t,r):e.detachEvent&&e.detachEvent("on".concat(n),t)}function ZA(e,n){const t=n.slice(0,n.length-1);for(let r=0;r<t.length;r++)t[r]=e[t[r].toLowerCase()];return t}function QA(e){typeof e!="string"&&(e=""),e=e.replace(/\s/g,"");const n=e.split(",");let t=n.lastIndexOf("");for(;t>=0;)n[t-1]+=",",n.splice(t,1),t=n.lastIndexOf("");return n}function nte(e,n){const t=e.length>=n.length?e:n,r=e.length>=n.length?n:e;let o=!0;for(let s=0;s<t.length;s++)r.indexOf(t[s])===-1&&(o=!1);return o}const hu={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,"-":oy?173:189,"=":oy?61:187,";":oy?59:186,"'":222,"[":219,"]":221,"\\":220},ho={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},Pv={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Dt={16:!1,18:!1,17:!1,91:!1},at={};for(let e=1;e<20;e++)hu["f".concat(e)]=111+e;let He=[],bc=null,JA="all";const _o=new Map,Bu=e=>hu[e.toLowerCase()]||ho[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),rte=e=>Object.keys(hu).find(n=>hu[n]===e),ote=e=>Object.keys(ho).find(n=>ho[n]===e);function ej(e){JA=e||"all"}function pu(){return JA||"all"}function ste(){return He.slice(0)}function ite(){return He.map(e=>rte(e)||ote(e)||String.fromCharCode(e))}function ate(){const e=[];return Object.keys(at).forEach(n=>{at[n].forEach(t=>{let{key:r,scope:o,mods:s,shortcut:i}=t;e.push({scope:o,shortcut:i,mods:s,keys:r.split("+").map(a=>Bu(a))})})}),e}function lte(e){const n=e.target||e.srcElement,{tagName:t}=n;let r=!0;const o=t==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(n.type);return(n.isContentEditable||(o||t==="TEXTAREA"||t==="SELECT")&&!n.readOnly)&&(r=!1),r}function cte(e){return typeof e=="string"&&(e=Bu(e)),He.indexOf(e)!==-1}function ute(e,n){let t,r;e||(e=pu());for(const o in at)if(Object.prototype.hasOwnProperty.call(at,o))for(t=at[o],r=0;r<t.length;)t[r].scope===e?t.splice(r,1).forEach(i=>{let{element:a}=i;return ix(a)}):r++;pu()===e&&ej(n||"all")}function dte(e){let n=e.keyCode||e.which||e.charCode;const t=He.indexOf(n);if(t>=0&&He.splice(t,1),e.key&&e.key.toLowerCase()==="meta"&&He.splice(0,He.length),(n===93||n===224)&&(n=91),n in Dt){Dt[n]=!1;for(const r in ho)ho[r]===n&&(kn[r]=!1)}}function tj(e){if(typeof e>"u")Object.keys(at).forEach(o=>{Array.isArray(at[o])&&at[o].forEach(s=>Qd(s)),delete at[o]}),ix(null);else if(Array.isArray(e))e.forEach(o=>{o.key&&Qd(o)});else if(typeof e=="object")e.key&&Qd(e);else if(typeof e=="string"){for(var n=arguments.length,t=new Array(n>1?n-1:0),r=1;r<n;r++)t[r-1]=arguments[r];let[o,s]=t;typeof o=="function"&&(s=o,o=""),Qd({key:e,scope:o,method:s,splitKey:"+"})}}const Qd=e=>{let{key:n,scope:t,method:r,splitKey:o="+"}=e;QA(n).forEach(i=>{const a=i.split(o),l=a.length,c=a[l-1],u=c==="*"?"*":Bu(c);if(!at[u])return;t||(t=pu());const d=l>1?ZA(ho,a):[],h=[];at[u]=at[u].filter(f=>{const g=(r?f.method===r:!0)&&f.scope===t&&nte(f.mods,d);return g&&h.push(f.element),!g}),h.forEach(f=>ix(f))})};function tI(e,n,t,r){if(n.element!==r)return;let o;if(n.scope===t||n.scope==="all"){o=n.mods.length>0;for(const s in Dt)Object.prototype.hasOwnProperty.call(Dt,s)&&(!Dt[s]&&n.mods.indexOf(+s)>-1||Dt[s]&&n.mods.indexOf(+s)===-1)&&(o=!1);(n.mods.length===0&&!Dt[16]&&!Dt[18]&&!Dt[17]&&!Dt[91]||o||n.shortcut==="*")&&(n.keys=[],n.keys=n.keys.concat(He),n.method(e,n)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function nI(e,n){const t=at["*"];let r=e.keyCode||e.which||e.charCode;if(!kn.filter.call(this,e))return;if((r===93||r===224)&&(r=91),He.indexOf(r)===-1&&r!==229&&He.push(r),["ctrlKey","altKey","shiftKey","metaKey"].forEach(a=>{const l=Pv[a];e[a]&&He.indexOf(l)===-1?He.push(l):!e[a]&&He.indexOf(l)>-1?He.splice(He.indexOf(l),1):a==="metaKey"&&e[a]&&He.length===3&&(e.ctrlKey||e.shiftKey||e.altKey||(He=He.slice(He.indexOf(l))))}),r in Dt){Dt[r]=!0;for(const a in ho)ho[a]===r&&(kn[a]=!0);if(!t)return}for(const a in Dt)Object.prototype.hasOwnProperty.call(Dt,a)&&(Dt[a]=e[Pv[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(He.indexOf(17)===-1&&He.push(17),He.indexOf(18)===-1&&He.push(18),Dt[17]=!0,Dt[18]=!0);const o=pu();if(t)for(let a=0;a<t.length;a++)t[a].scope===o&&(e.type==="keydown"&&t[a].keydown||e.type==="keyup"&&t[a].keyup)&&tI(e,t[a],o,n);if(!(r in at))return;const s=at[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),d=[];for(let h=0;h<u.length;h++)d.push(Bu(u[h]));d.sort().join("")===He.sort().join("")&&tI(e,l,o,n)}}function kn(e,n,t){He=[];const r=QA(e);let o=[],s="all",i=document,a=0,l=!1,c=!0,u="+",d=!1,h=!1;for(t===void 0&&typeof n=="function"&&(t=n),Object.prototype.toString.call(n)==="[object Object]"&&(n.scope&&(s=n.scope),n.element&&(i=n.element),n.keyup&&(l=n.keyup),n.keydown!==void 0&&(c=n.keydown),n.capture!==void 0&&(d=n.capture),typeof n.splitKey=="string"&&(u=n.splitKey),n.single===!0&&(h=!0)),typeof n=="string"&&(s=n),h&&tj(e,s);a<r.length;a++)e=r[a].split(u),o=[],e.length>1&&(o=ZA(ho,e)),e=e[e.length-1],e=e==="*"?"*":Bu(e),e in at||(at[e]=[]),at[e].push({keyup:l,keydown:c,scope:s,mods:o,shortcut:r[a],method:t,key:r[a],splitKey:u,element:i});if(typeof i<"u"&&window){if(!_o.has(i)){const f=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return nI(g,i)},y=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;nI(g,i),dte(g)};_o.set(i,{keydownListener:f,keyupListenr:y,capture:d}),sy(i,"keydown",f,d),sy(i,"keyup",y,d)}if(!bc){const f=()=>{He=[]};bc={listener:f,capture:d},sy(window,"focus",f,d)}}}function hte(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(at).forEach(t=>{at[t].filter(o=>o.scope===n&&o.shortcut===e).forEach(o=>{o&&o.method&&o.method()})})}function ix(e){const n=Object.values(at).flat();if(n.findIndex(r=>{let{element:o}=r;return o===e})<0){const{keydownListener:r,keyupListenr:o,capture:s}=_o.get(e)||{};r&&o&&(Wl(e,"keyup",o,s),Wl(e,"keydown",r,s),_o.delete(e))}if((n.length<=0||_o.size<=0)&&(Object.keys(_o).forEach(o=>{const{keydownListener:s,keyupListenr:i,capture:a}=_o.get(o)||{};s&&i&&(Wl(o,"keyup",i,a),Wl(o,"keydown",s,a),_o.delete(o))}),_o.clear(),Object.keys(at).forEach(o=>delete at[o]),bc)){const{listener:o,capture:s}=bc;Wl(window,"focus",o,s),bc=null}}const iy={getPressedKeyString:ite,setScope:ej,getScope:pu,deleteScope:ute,getPressedKeyCodes:ste,getAllKeyCodes:ate,isPressed:cte,filter:lte,trigger:hte,unbind:tj,keyMap:hu,modifier:ho,modifierMap:Pv};for(const e in iy)Object.prototype.hasOwnProperty.call(iy,e)&&(kn[e]=iy[e]);if(typeof window<"u"){const e=window.hotkeys;kn.noConflict=n=>(n&&window.hotkeys===kn&&(window.hotkeys=e),kn),window.hotkeys=kn}const rI=["copy","cut","paste","asset"];function pte(){const e=F(),n=fo(),t=le(),r=rx(),o=K("is focused",()=>e.getInstanceState().isFocused,[e]),{itemsInPanel:s}=oj();x.useEffect(()=>{if(!o)return;const i=e.getContainer();kn.setScope(e.store.id);const a=(c,u)=>{kn(c,{element:document.body,scope:e.store.id},u)},l=(c,u)=>{kn(c,{element:document.body,keyup:!0,keydown:!1,scope:e.store.id},u)};for(const c of Object.values(t))c.kbd&&(n&&!c.readonlyOk||rI.includes(c.id)||a(oI(c.kbd),u=>{rc(e)||(je(u),c.onSelect("kbd"))}));for(const c of Object.values(r))!c.kbd||!c.readonlyOk&&e.getInstanceState().isReadonly||rI.includes(c.id)||a(oI(c.kbd),u=>{rc(e)||(je(u),c.onSelect("kbd"))});return a(",",c=>{if(rc(e)||e.inputs.keys.has("Comma"))return;je(c),i.focus(),e.inputs.keys.add("Comma");const{x:u,y:d,z:h}=e.inputs.currentScreenPoint,f={type:"pointer",name:"pointer_down",point:{x:u,y:d,z:h},shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.metaKey||c.ctrlKey,pointerId:0,button:0,isPen:e.getInstanceState().isPenMode,target:"canvas"};e.dispatch(f)}),l(",",c=>{if(rc(e)||!e.inputs.keys.has("Comma"))return;e.inputs.keys.delete("Comma");const{x:u,y:d,z:h}=e.inputs.currentScreenPoint,f={type:"pointer",name:"pointer_up",point:{x:u,y:d,z:h},shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.metaKey||c.ctrlKey,pointerId:0,button:0,isPen:e.getInstanceState().isPenMode,target:"canvas"};e.dispatch(f)}),()=>{kn.deleteScope(e.store.id)}},[t,r,n,e,o,s])}function oI(e){return fte(e).map(n=>{let t="";const r=n.split("");return r.length===1?t=r[0]:r[0]==="!"?t=`shift+${r[1]}`:r[0]==="?"?r.length===3&&r[1]==="!"?t=`alt+shift+${r[2]}`:t=`alt+${r[1]}`:r[0]==="$"?r[1]==="!"?t=`cmd+shift+${r[2]},ctrl+shift+${r[2]}`:r[1]==="?"?t=`cmd+⌥+${r[2]},ctrl+alt+${r[2]}`:t=`cmd+${r[1]},ctrl+${r[1]}`:t=n,t}).join(",")}function fte(e){typeof e!="string"&&(e=""),e=e.replace(/\s/g,"");const n=e.split(",");let t=n.lastIndexOf("");for(;t>=0;)n[t-1]+=",",n.splice(t,1),t=n.lastIndexOf("");return n}function rc(e){return e.getIsMenuOpen()||e.getEditingShapeId()!==null||e.getCrashingError()}function Fe(e){return{id:e.id,type:"item",readonlyOk:e.readonlyOk,toolItem:e}}const nj=ie.createContext([]);function gte({overrides:e,children:n}){const t=F(),r=rx(),o=ie.useMemo(()=>{const s=ge([Fe(r.select),Fe(r.hand),Fe(r.draw),Fe(r.eraser),Fe(r.arrow),Fe(r.text),Fe(r.note),Fe(r.asset),Fe(r.rectangle),Fe(r.ellipse),Fe(r.diamond),Fe(r.triangle),Fe(r.trapezoid),Fe(r.rhombus),Fe(r.hexagon),Fe(r.cloud),Fe(r.star),Fe(r.oval),Fe(r["x-box"]),Fe(r["check-box"]),Fe(r["arrow-left"]),Fe(r["arrow-up"]),Fe(r["arrow-down"]),Fe(r["arrow-right"]),Fe(r.line),Fe(r.highlight),Fe(r.frame),Fe(r.laser)]);return e?e(t,s,{tools:r}):s},[t,e,r]);return p.jsx(nj.Provider,{value:o,children:n})}function rj(){const e=ie.useContext(nj);if(!e)throw new Error("useToolbarSchema must be used within a ToolbarSchemaProvider");return e}function mte(){const e=F(),n=Ee(),t=BA(),r=t==null?void 0:t.get(mr),o=Dn({isDarkMode:e.user.getIsDarkMode()}),s=((r==null?void 0:r.type)==="shared"?o[r.value]:o.black).solid,i=K("disable style panel",()=>e.isInAny("hand","zoom","eraser","laser"),[e]),a=x.useCallback(c=>{c||e.updateInstanceState({isChangingStyle:!1},{ephemeral:!0})},[e]),{StylePanel:l}=Xs();return l?p.jsxs(Hw,{id:"mobile style menu",onOpenChange:a,children:[p.jsx(Kw,{children:p.jsx(he,{type:"tool","data-testid":"mobile-styles.button",style:{color:i?"var(--color-muted-1)":s},title:n("style-panel.title"),disabled:i,children:p.jsx(Ie,{icon:i?"blob":(r==null?void 0:r.type)==="mixed"?"mixed":"blob"})})}),p.jsx(Vw,{side:"top",align:"end",children:l&&p.jsx(l,{isMobile:!0})})]}):null}const yte=["select","hand","draw","eraser","text","zoom","laser","highlight"];function Ste({activeToolId:e}){const n=F(),t=Ln(),r=Ee(),o=K("is tool locked",()=>n.getInstanceState().isToolLocked,[n]);return!e||yte.includes(e)?null:p.jsx(he,{type:"normal",title:r("action.toggle-tool-lock"),"data-testid":"tool-lock",className:fe("tlui-toolbar__lock-button",{"tlui-toolbar__lock-button__mobile":t<ht.TABLET_SM}),onClick:()=>n.updateInstanceState({isToolLocked:!o}),children:p.jsx(Ie,{icon:o?"lock":"unlock",small:!0})})}const vte=x.memo(function(){const n=F(),t=Ee(),r=Ln(),o=ie.useRef(void 0),s=fo(),i=rj(),a=K("current tool id",()=>n.getCurrentToolId(),[n]),l=K("geo",()=>n.getSharedStyles().getAsKnownValue(so),[n]),c=v=>v.label?`${t(v.label)} ${v.kbd?uu(v.kbd):""}`:"",u=i.find(v=>ay(v.toolItem,a,l)),{itemsInPanel:d,itemsInDropdown:h}=oj(),f=x.useMemo(()=>{let v=h.find(S=>S===u);return v||(o.current||(o.current=h[0]),v=o.current,h.includes(v)||(v=h[0])),o.current=v,v},[u,h]);x.useEffect(()=>{const v=[...d,f];for(let S=0;S<Math.min(10,v.length);S++){const w=`${S+1}`.slice(-1);kn(w,C=>{rc(n)||(je(C),v[S].toolItem.onSelect("kbd"))})}return()=>{kn.unbind("1,2,3,4,5,6,7,8,9,0")}},[f,n,d]);const{ActionsMenu:y,QuickActions:g}=Xs();return p.jsx("div",{className:"tlui-toolbar",children:p.jsxs("div",{className:"tlui-toolbar__inner",children:[p.jsxs("div",{className:"tlui-toolbar__left",children:[!s&&p.jsxs("div",{className:"tlui-toolbar__extras",children:[r<ht.TABLET&&p.jsxs("div",{className:"tlui-toolbar__extras__controls tlui-buttons__horizontal",children:[g&&p.jsx(g,{}),y&&p.jsx(y,{})]}),p.jsx(Ste,{activeToolId:a})]}),p.jsxs("div",{className:fe("tlui-toolbar__tools",{"tlui-toolbar__tools__mobile":r<ht.TABLET_SM}),children:[d.map(({toolItem:v})=>p.jsx(sI,{item:v,title:c(v),isSelected:ay(v,a,l)},v.id)),h.length?p.jsxs(p.Fragment,{children:[p.jsx(sI,{item:f.toolItem,title:c(f.toolItem),isSelected:ay(f.toolItem,a,l)},f.toolItem.id),p.jsxs(Ti,{id:"toolbar overflow",modal:!1,children:[p.jsx($i,{children:p.jsx(he,{title:t("tool-panel.more"),type:"tool",className:"tlui-toolbar__overflow","data-testid":"tools.more-button",children:p.jsx(Ie,{icon:"chevron-up"})})}),p.jsx(Mi,{side:"top",align:"center",children:p.jsx(wte,{toolbarItems:h})})]})]}):null]})]}),r<ht.TABLET_SM&&!s&&p.jsx("div",{className:"tlui-toolbar__tools",children:p.jsx(mte,{})})]})})}),wte=Tt(function({toolbarItems:n}){const t=Ee();return p.jsx("div",{className:"tlui-buttons__grid","data-testid":"tools.more-content",children:n.map(({toolItem:{id:r,meta:o,kbd:s,label:i,onSelect:a,icon:l}})=>p.jsx(du,{"data-tool":r,"data-geo":(o==null?void 0:o.geo)??"","aria-label":i,children:p.jsx(he,{type:"icon",className:"tlui-button-grid__button",onClick:()=>a("toolbar"),"data-testid":`tools.more.${r}`,title:i?`${t(i)} ${s?uu(s):""}`:"",children:p.jsx(Ie,{icon:l})})},r))})});function sI({item:e,title:n,isSelected:t}){var r;return p.jsx(he,{type:"tool","data-testid":`tools.${e.id}`,"data-tool":e.id,"data-geo":((r=e.meta)==null?void 0:r.geo)??"","aria-label":e.label,"data-state":t?"selected":void 0,onClick:()=>e.onSelect("toolbar"),title:n,onTouchStart:o=>{je(o),e.onSelect("toolbar")},children:p.jsx(Ie,{icon:e.icon})})}const ay=(e,n,t)=>{var r,o;return(r=e.meta)!=null&&r.geo?n==="geo"&&t===((o=e.meta)==null?void 0:o.geo):n===e.id};function oj(){const e=Ln(),n=rj(),t=fo();return x.useMemo(()=>{const r=n.filter(a=>!t||a.readonlyOk),o=Math.min(8,5+e),s=r.slice(0,o),i=r.slice(o);return i.length<=2?{itemsInPanel:r,itemsInDropdown:[]}:{itemsInPanel:s,itemsInDropdown:i}},[n,e,t])}function xte(){const e=le();return p.jsxs(p.Fragment,{children:[p.jsx(z,{...e["zoom-in"],noClose:!0}),p.jsx(z,{...e["zoom-out"],noClose:!0}),p.jsx(MA,{}),p.jsx(AA,{}),p.jsx(jA,{})]})}const bte=x.memo(function({children:n}){const t=mn(),[r,o]=Gs("zoom menu"),s=n??p.jsx(xte,{});return p.jsxs(ex,{dir:"ltr",open:r,onOpenChange:o,modal:!1,children:[p.jsx(tx,{asChild:!0,dir:"ltr",children:p.jsx(Pte,{})}),p.jsx(lg,{container:t,children:p.jsx(nx,{className:"tlui-menu",side:"top",align:"start",alignOffset:0,sideOffset:8,collisionPadding:4,children:p.jsx(So,{type:"menu",sourceId:"zoom-menu",children:s})})})]})}),Pte=x.forwardRef(function(n,t){const r=F(),o=Ln(),s=K("zoom",()=>r.getZoomLevel(),[r]),i=Ee(),a=x.useCallback(()=>{r.resetZoom(r.getViewportScreenCenter(),{duration:Mo})},[r]);return p.jsx(he,{ref:t,...n,type:"icon",title:`${i("navigation-zone.zoom")}`,"data-testid":"minimap.zoom-menu-button",className:o<ht.TABLET_SM?"tlui-zoom-menu__button":"tlui-zoom-menu__button__pct",onDoubleClick:a,icon:o<ht.MOBILE?"zoom-in":void 0,children:o<ht.MOBILE?null:p.jsxs("span",{style:{flexGrow:0,textAlign:"center"},children:[Math.floor(s*100),"%"]})})}),sj=x.createContext({});function Cte({overrides:e={},children:n}){const t=Zv(e);return p.jsx(sj.Provider,{value:x.useMemo(()=>({ContextMenu:jJ,ActionsMenu:uJ,HelpMenu:HJ,ZoomMenu:bte,MainMenu:lee,Minimap:uee,StylePanel:tte,PageMenu:fee,NavigationPanel:hee,Toolbar:vte,KeyboardShortcutsDialog:ZJ,QuickActions:mee,HelperButtons:YJ,DebugMenu:FJ,MenuPanel:cee,...t}),[t]),children:n})}function Xs(){return x.useContext(sj)}const Ite=x.memo(function(){const{DebugMenu:n}=Xs();return p.jsxs("div",{className:"tlui-debug-panel",children:[p.jsx(_te,{}),p.jsx(kte,{}),n&&p.jsx(n,{})]})});function Ete(e=!0){const[n,t]=x.useState(0),r=F();x.useEffect(()=>{if(!e)return;const o=()=>t(s=>s+1);return r.on("tick",o),()=>{r.off("tick",o)}},[r,e])}const _te=Tt(function(){Ete();const n=F(),t=n.getPath(),r=n.getHoveredShape(),o=n.getOnlySelectedShape(),s=t==="select.idle"||!t.includes("select.")?r:o,i=s&&t.includes("select.")?` / ${s.type||""}${"geo"in s.props?" / "+s.props.geo:""} / [${b.ToFixed(n.getPointInShapeSpace(s,n.inputs.currentPagePoint),0)}]`:"",a=t.startsWith("select.")&&!t.includes(".idle")?` / [${b.ToFixed(n.inputs.originPagePoint,0)}] → [${b.ToFixed(n.inputs.currentPagePoint,0)}] = ${b.Dist(n.inputs.originPagePoint,n.inputs.currentPagePoint).toFixed(0)}`:"";return p.jsx("div",{className:"tlui-debug-panel__current-state",children:`${t}${i}${a}`})});function kte(){const e=K("show_fps",()=>Ft.showFps.get(),[Ft]),n=x.useRef(null);return x.useEffect(()=>{if(!e)return;const t=250;let r=0,o=!1,s=performance.now(),i=0,a=0,l=!1;function c(){if(!o){if(a++,i=performance.now()-s,i>t){const u=Math.round(a*(t/i)*(1e3/t));u>r&&(r=u);const d=r*.75;(u<d&&!l||u>=d&&l)&&(l=!l),n.current.innerHTML=`FPS ${u.toString()}`,n.current.className="tlui-debug-panel__fps"+(l?" tlui-debug-panel__fps__slow":""),i-=t,a=0,s=performance.now()}requestAnimationFrame(c)}}return c(),()=>{o=!0}},[e]),e?p.jsx("div",{ref:n}):null}const Tte=({id:e,component:n,onClose:t})=>{const{removeDialog:r}=zi(),o=mn(),s=x.useCallback(i=>{if(!i){if(t)try{t()}catch(a){console.warn(a)}r(e)}},[e,t,r]);return p.jsx(Mq,{onOpenChange:s,defaultOpen:!0,children:p.jsx(Aq,{container:o,children:p.jsx(jq,{dir:"ltr",className:"tlui-dialog__overlay",onClick:i=>{i.target===i.currentTarget&&s(!1)},children:p.jsx(Oq,{dir:"ltr",className:"tlui-dialog__content",children:p.jsx(n,{onClose:()=>s(!1)})})})})})};function $te(){const{dialogs:e}=zi();return p.jsx(p.Fragment,{children:e.map(n=>p.jsx(Tte,{...n},n.id))})}const Mte=ie.memo($te);function Ate(){const e=F(),n=K("follow",()=>e.getInstanceState().followingUserId,[e]);return n?p.jsx(jte,{userId:n}):null}function jte({userId:e}){const n=KE(e);return n?p.jsx("div",{className:"tlui-following-indicator",style:{borderColor:n.color}}):null}function Ote({toast:e}){const{removeToast:n}=Wr(),t=Ee(),r=s=>{s||n(e.id)},o=e.actions&&e.actions.length>0;return p.jsxs(rY,{onOpenChange:r,className:"tlui-toast__container",duration:e.keepOpen?1/0:5e3,children:[e.icon&&p.jsx("div",{className:"tlui-toast__icon",children:p.jsx(Rs,{icon:e.icon})}),p.jsxs("div",{className:"tlui-toast__main",children:[p.jsxs("div",{className:"tlui-toast__content",children:[e.title&&p.jsx(oY,{className:"tlui-toast__title",children:e.title}),e.description&&p.jsx(sY,{className:"tlui-toast__description",children:e.description})]}),e.actions&&p.jsxs("div",{className:"tlui-toast__actions",children:[e.actions.map((s,i)=>p.jsx(iY,{altText:s.label,asChild:!0,onClick:s.onClick,children:p.jsx(he,{type:s.type,children:p.jsx(mt,{children:s.label})})},i)),p.jsx(EC,{asChild:!0,children:p.jsx(he,{type:"normal",className:"tlui-toast__close",style:{marginLeft:"auto"},children:p.jsx(mt,{children:e.closeLabel??t("toast.close")})})})]})]}),!o&&p.jsx(EC,{asChild:!0,children:p.jsx(he,{type:"normal",className:"tlui-toast__close",children:p.jsx(mt,{children:e.closeLabel??t("toast.close")})})})]})}function Dte(){const{toasts:e}=Wr();return p.jsx(p.Fragment,{children:e.map(n=>p.jsx(Ote,{toast:n},n.id))})}const Rte=x.memo(Dte);function Lte(){const{toasts:e}=Wr(),[n,t]=x.useState(!1);return x.useEffect(()=>{let r=!1;return e.length?t(!0):setTimeout(()=>{r||t(!1)},1e3),()=>{r=!0}},[e.length,t]),n?p.jsx(zG,{className:"tlui-toast__viewport"}):null}const pi="2.0.1";let Cv={fonts:{draw:`https://unpkg.com/@tldraw/assets@${pi}/fonts/Shantell_Sans-Tldrawish.woff2`,serif:`https://unpkg.com/@tldraw/assets@${pi}/fonts/IBMPlexSerif-Medium.woff2`,sansSerif:`https://unpkg.com/@tldraw/assets@${pi}/fonts/IBMPlexSans-Medium.woff2`,monospace:`https://unpkg.com/@tldraw/assets@${pi}/fonts/IBMPlexMono-Medium.woff2`}};function ij(e){return x.useMemo(()=>e?{fonts:{...Cv.fonts,...e==null?void 0:e.fonts}}:Cv,[e])}const Nte=["align-bottom-center","align-bottom-left","align-bottom-right","align-bottom","align-center-center","align-center-horizontal","align-center-left","align-center-right","align-center-vertical","align-left","align-right","align-top-center","align-top-left","align-top-right","align-top","arrow-left","arrowhead-arrow","arrowhead-bar","arrowhead-diamond","arrowhead-dot","arrowhead-none","arrowhead-square","arrowhead-triangle-inverted","arrowhead-triangle","aspect-ratio","avatar","blob","bring-forward","bring-to-front","check","checkbox-checked","checkbox-empty","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","code","collab","color","comment","cross-2","cross","dash-dashed","dash-dotted","dash-draw","dash-solid","discord","distribute-horizontal","distribute-vertical","dot","dots-horizontal","dots-vertical","drag-handle-dots","duplicate","edit","external-link","file","fill-none","fill-pattern","fill-semi","fill-solid","follow","following","font-draw","font-mono","font-sans","font-serif","geo-arrow-down","geo-arrow-left","geo-arrow-right","geo-arrow-up","geo-check-box","geo-cloud","geo-diamond","geo-ellipse","geo-hexagon","geo-octagon","geo-oval","geo-pentagon","geo-rectangle","geo-rhombus-2","geo-rhombus","geo-star","geo-trapezoid","geo-triangle","geo-x-box","github","group","hidden","image","info-circle","leading","link","lock-small","lock","menu","minus","mixed","pack","page","plus","question-mark-circle","question-mark","redo","reset-zoom","rotate-ccw","rotate-cw","ruler","search","send-backward","send-to-back","settings-horizontal","settings-vertical-1","settings-vertical","share-1","share-2","size-extra-large","size-large","size-medium","size-small","spline-cubic","spline-line","stack-horizontal","stack-vertical","status-offline","status-online","stretch-horizontal","stretch-vertical","text-align-center","text-align-justify","text-align-left","text-align-right","tool-arrow","tool-embed","tool-eraser","tool-frame","tool-hand","tool-highlight","tool-laser","tool-line","tool-media","tool-note","tool-pencil","tool-pointer","tool-text","trash","triangle-down","triangle-up","twitter","undo","ungroup","unlock-small","unlock","vertical-align-center","vertical-align-end","vertical-align-start","visible","warning-triangle","zoom-in","zoom-out"];let Gl={...Cv,icons:Object.fromEntries(Nte.map(e=>[e,`https://unpkg.com/@tldraw/assets@${pi}/icons/icon/${e}.svg`])),translations:Object.fromEntries(_c.map(e=>[e.locale,`https://unpkg.com/@tldraw/assets@${pi}/translations/${e.locale}.json`])),embedIcons:Object.fromEntries(Ha.map(e=>[e.type,`https://unpkg.com/@tldraw/assets@${pi}/embed-icons/${e.type}.png`]))};function Fte(e){return e?{fonts:Object.assign({...Gl.fonts},{...e==null?void 0:e.fonts}),icons:Object.assign({...Gl.icons},{...e==null?void 0:e.icons}),embedIcons:Object.assign({...Gl.embedIcons},{...e==null?void 0:e.embedIcons}),translations:Object.assign({...Gl.translations},{...e==null?void 0:e.translations})}:Gl}function zte(){const{addToast:e,removeToast:n,clearToasts:t}=Wr(),{addDialog:r,clearDialogs:o,removeDialog:s,updateDialog:i}=zi(),l=Ln()<ht.TABLET_SM,c=Ee();return x.useMemo(()=>({addToast:e,removeToast:n,clearToasts:t,addDialog:r,clearDialogs:o,removeDialog:s,updateDialog:i,msg:c,isMobile:l}),[r,e,o,t,c,s,n,i,l])}function Bte(e,n){const t={};for(const r of e)if(r.translations)for(const[o,s]of oo(r.translations)){let i=t[o];i||(i=t[o]={}),Object.assign(i,s)}return{actions:(r,o)=>{for(const s of e)s.actions&&(o=s.actions(r,o,n));return o},toolbar:(r,o,s)=>{for(const i of e)i.toolbar&&(o=i.toolbar(r,o,{...n,...s}));return o},tools:(r,o,s)=>{for(const i of e)i.tools&&(o=i.tools(r,o,{...n,...s}));return o},translations:t}}function aj(e){return x.useMemo(()=>e,e)}function Ute(e){const n=aj(e==null?[]:Array.isArray(e)?e:[e]);return x.useMemo(()=>{const t={};for(const r of n)if(r.translations)for(const[o,s]of oo(r.translations)){let i=t[o];i||(i=t[o]={}),Object.assign(i,s)}return t},[n])}function Hte(e){const n=zte(),t=aj(e==null?[]:Array.isArray(e)?e:[e]);return x.useMemo(()=>Bte(t,n),[t,n])}function Kte({overrides:e,components:n,assetUrls:t,onUiEvent:r,forceMobile:o,children:s}){return p.jsx(lY,{assetUrls:Fte(t),children:p.jsx(dY,{overrides:Ute(e),children:p.jsx(fq,{onEvent:r,children:p.jsx(iZ,{children:p.jsx(hZ,{children:p.jsx(aY,{forceMobile:o,children:p.jsx(Cte,{overrides:n,children:p.jsx(Vte,{overrides:e,children:s})})})})})})})})}function Vte({overrides:e,children:n}){const t=Hte(e);return p.jsx(fZ,{overrides:t.actions,children:p.jsx(XJ,{overrides:t.tools,children:p.jsx(gte,{overrides:t.toolbar,children:n})})})}function Wte(){const e=F(),{addToast:n}=Wr();x.useEffect(()=>{function t({name:r,count:o}){n({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.`})}return e.addListener("max-shapes",t),()=>{e.removeListener("max-shapes",t)}},[e,n])}const Gte=ie.memo(function({renderDebugMenuItems:n,children:t,hideUi:r,components:o,...s}){return p.jsx(Kte,{...s,components:o,children:p.jsx(Yte,{hideUi:r,renderDebugMenuItems:n,children:t})})}),Yte=ie.memo(function({children:n,hideUi:t,...r}){return p.jsxs(p.Fragment,{children:[n,t?null:p.jsx(Xte,{...r})]})}),Xte=ie.memo(function(){const n=F(),t=Ee(),r=Ln(),o=fo(),s=K("focus",()=>n.getInstanceState().isFocusMode,[n]),i=K("debug",()=>n.getInstanceState().isDebugMode,[n]),{SharePanel:a,TopPanel:l,MenuPanel:c,StylePanel:u,Toolbar:d,HelpMenu:h,NavigationPanel:f,HelperButtons:y}=Xs();pte(),tZ(),Wte();const{"toggle-focus-mode":g}=le();return p.jsx(L$,{children:p.jsxs("div",{className:fe("tlui-layout",{"tlui-layout__mobile":r<ht.TABLET_SM}),"data-breakpoint":r,children:[s?p.jsx("div",{className:"tlui-layout__top",children:p.jsx(he,{type:"icon",className:"tlui-focus-button",title:t("focus-mode.toggle-focus-mode"),onClick:()=>g.onSelect("menu"),children:p.jsx(Ie,{icon:"dot"})})}):p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"tlui-layout__top",children:[p.jsxs("div",{className:"tlui-layout__top__left",children:[c&&p.jsx(c,{}),y&&p.jsx(y,{})]}),p.jsx("div",{className:"tlui-layout__top__center",children:l&&p.jsx(l,{})}),p.jsxs("div",{className:"tlui-layout__top__right",children:[a&&p.jsx(a,{}),u&&r>=ht.TABLET_SM&&!o&&p.jsx(u,{})]})]}),p.jsxs("div",{className:"tlui-layout__bottom",children:[p.jsxs("div",{className:"tlui-layout__bottom__main",children:[f&&p.jsx(f,{}),d&&p.jsx(d,{}),h&&p.jsx(h,{})]}),i&&p.jsx(Ite,{})]})]}),p.jsx(Rte,{}),p.jsx(Mte,{}),p.jsx(Lte,{}),p.jsx(Ate,{})]})})}),Jd=(e,n)=>{const[t,r]=x.useState(2);return x.useEffect(()=>{let o=!1;return r(2),NO(e,n).then(()=>{o||r(0)}).catch(s=>{o||(console.error(s),r(1))}),()=>{o=!0}},[e,n]),t};function qte(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 lj(e){const n=x.useMemo(()=>qte(e),[e]),t=[Jd("tldraw_draw",n.draw),Jd("tldraw_serif",n.serif),Jd("tldraw_sans",n.sansSerif),Jd("tldraw_mono",n.monospace)];return{error:t.some(r=>r===1),done:!t.some(r=>r===2)}}function Zte(e){const{children:n,maxImageDimension:t,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i,components:a={},shapeUtils:l=[],tools:c=[],...u}=e,d=Zv(a),h=x.useMemo(()=>({Scribble:j1,CollaboratorScribble:j1,SelectionForeground:RU,SelectionBackground:OU,Handles:kU,HoveredShapeIndicator:TU,...d}),[d]),f=By(l),y=x.useMemo(()=>[...r2,...f],[f]),g=By(c),v=x.useMemo(()=>[...pV,...$H,...g],[g]),S=ij(u.assetUrls),{done:w,error:C}=lj(S);return C?p.jsx(P_,{children:"Could not load assets. Please refresh the page."}):w?p.jsx(vF,{initialState:"select",...u,components:h,shapeUtils:y,tools:v,children:p.jsxs(Gte,{...u,components:h,children:[p.jsx(ene,{maxImageDimension:t,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i}),n]})}):p.jsx(b_,{children:"Loading assets..."})}const Qte=Object.freeze(["image/jpeg","image/png","image/gif","image/svg+xml"]),Jte=Object.freeze(["video/mp4","video/quicktime"]);function ene({maxImageDimension:e=1e3,maxAssetSize:n=10*1024*1024,acceptedImageMimeTypes:t=Qte,acceptedVideoMimeTypes:r=Jte,onMount:o}){const s=F(),i=Wr(),a=Ee(),l=tne(d=>{const h=[];return h.push(...eV(d)),yH(d,{maxImageDimension:e,maxAssetSize:n,acceptedImageMimeTypes:t,acceptedVideoMimeTypes:r},{toasts:i,msg:a}),h.push(o==null?void 0:o(d)),()=>{h.forEach(f=>f==null?void 0:f())}});x.useLayoutEffect(()=>{if(s)return l==null?void 0:l(s)},[s,l]);const{Canvas:c}=Ge(),{ContextMenu:u}=Xs();return u?p.jsx(u,{}):c?p.jsx(c,{}):null}function tne(e){const n=x.useRef();return x.useLayoutEffect(()=>{n.current=e}),x.useDebugValue(e),x.useCallback((...t)=>{const r=n.current;return Do(r,"fn does not exist"),r(...t)},[])}x.memo(function(n){const[t,r]=x.useState(null),[o,s]=x.useState(null),i=By(n.shapeUtils??[]),a=x.useMemo(()=>[...r2,...i],[i]),l=S_({snapshot:n.snapshot,shapeUtils:a}),c=ij(),{done:u,error:d}=lj(c),{pageId:h,bounds:f,scale:y,background:g,padding:v,darkMode:S,preserveAspectRatio:w,format:C="svg"}=n;return x.useLayoutEffect(()=>{if(!o||!l||!u)return;let I=!1;const P=document.createElement("div");o.appendChild(P),o.classList.add("tl-container","tl-theme__light");const E=new ae({store:l,shapeUtils:a??[],tools:[],getContainer:()=>P});h&&E.setCurrentPage(h);const _=E.getCurrentPageShapeIds();async function k(){const M=await E.getSvg([..._],{bounds:f,scale:y,background:g,padding:v,darkMode:S,preserveAspectRatio:w});if(M&&!I){if(C==="svg"){const T=await Xw(M);if(!I){const R=new Blob([T],{type:"image/svg+xml"}),O=URL.createObjectURL(R);r(O)}}else if(C==="png"){const T=await FM(M,E.environment.isSafari,{type:C,quality:1,scale:2});if(T&&!I){const R=URL.createObjectURL(T);r(R)}}}E.dispose()}return k(),()=>{I=!0}},[C,o,l,a,h,f,y,g,v,S,w,u,d]),d?p.jsx(P_,{children:"Could not load assets."}):u?p.jsx("div",{ref:s,style:{position:"relative",width:"100%",height:"100%"},children:t&&p.jsx("img",{src:t,style:{width:"100%",height:"100%"}})}):p.jsx(b_,{children:"Loading assets..."})});const nne=1,rne=be({tldrawFileFormatVersion:TD,schema:be({schemaVersion:Qu,storeVersion:Qu,recordVersions:Oy(Se,be({version:Qu,subTypeVersions:Oy(Se,Qu).optional(),subTypeKey:Se.optional()}))}),records:zt(be({id:Se,typeName:Se}).allowUnknownProperties())});function one(e){var n;try{return!!((n=e.document)!=null&&n.version)}catch{return!1}}function sne({json:e,schema:n}){let t;try{t=rne.validate(JSON.parse(e))}catch(o){try{if(t=JSON.parse(e),one(t))return ti.err({type:"v1File",data:t})}catch{}return ti.err({type:"notATldrawFile",cause:o})}if(t.tldrawFileFormatVersion>nne)return ti.err({type:"fileFormatVersionTooNew",version:t.tldrawFileFormatVersion});let r;try{const o=Object.fromEntries(t.records.map(s=>[s.id,s]));r=n.migrateStoreSnapshot({store:o,schema:t.schema})}catch(o){return ti.err({type:"invalidRecords",cause:o})}if(r.type==="error")return ti.err({type:"migrationFailed",reason:r.reason});try{return ti.ok(y_({initialData:r.value,schema:n}))}catch(o){return ti.err({type:"invalidRecords",cause:o})}}function ine(){const[e,n]=x.useState();function t(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=sne({json:o,schema:r.store.schema});s.ok?(console.log("Loaded tldr file from local endpoint"),n(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 p.jsx("div",{style:{inset:0,position:"fixed"},children:p.jsx(Zte,{assetUrls:LO(),onMount:t,store:e})})}var Iv={},iI=gl;Iv.createRoot=iI.createRoot,Iv.hydrateRoot=iI.hydrateRoot;Iv.createRoot(document.querySelector("#root")).render(p.jsx(ie.StrictMode,{children:p.jsx(ine,{})}));
|