@kitschpatrol/tldraw-cli 4.5.4 → 4.5.5
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 +14 -9
- package/dist/.DS_Store +0 -0
- package/dist/lib/index.js +8 -6
- package/dist/tldraw/assets/index-Bn7aCEFI.js +325 -0
- package/dist/tldraw/icons/icon/geo-heart.svg +1 -0
- package/dist/tldraw/icons/icon/icon-names.json +3 -0
- package/dist/tldraw/icons/icon/spline-cubic.svg +1 -0
- package/dist/tldraw/icons/icon/spline-line.svg +1 -0
- package/dist/tldraw/index.html +1 -1
- package/package.json +10 -10
- package/dist/tldraw/assets/index-DGC_26df.js +0 -337
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
var KO=Object.defineProperty;var WO=(e,t,n)=>t in e?KO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var m=(e,t,n)=>(WO(e,typeof t!="symbol"?t+"":t,n),n);function GO(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const s=Object.getOwnPropertyDescriptor(r,o);s&&Object.defineProperty(e,o,s.get?s:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const s of o)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(o){const s={};return o.integrity&&(s.integrity=o.integrity),o.referrerPolicy&&(s.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?s.credentials="include":o.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(o){if(o.ep)return;o.ep=!0;const s=n(o);fetch(o.href,s)}})();var on=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function lc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var CI={exports:{}},lf={},II={exports:{}},xe={};/**
|
|
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 yu=Symbol.for("react.element"),VO=Symbol.for("react.portal"),YO=Symbol.for("react.fragment"),XO=Symbol.for("react.strict_mode"),qO=Symbol.for("react.profiler"),ZO=Symbol.for("react.provider"),QO=Symbol.for("react.context"),JO=Symbol.for("react.forward_ref"),eD=Symbol.for("react.suspense"),tD=Symbol.for("react.memo"),nD=Symbol.for("react.lazy"),zw=Symbol.iterator;function rD(e){return e===null||typeof e!="object"?null:(e=zw&&e[zw]||e["@@iterator"],typeof e=="function"?e:null)}var EI={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_I=Object.assign,kI={};function uc(e,t,n){this.props=e,this.context=t,this.refs=kI,this.updater=n||EI}uc.prototype.isReactComponent={};uc.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};uc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function TI(){}TI.prototype=uc.prototype;function Rv(e,t,n){this.props=e,this.context=t,this.refs=kI,this.updater=n||EI}var Lv=Rv.prototype=new TI;Lv.constructor=Rv;_I(Lv,uc.prototype);Lv.isPureReactComponent=!0;var Bw=Array.isArray,$I=Object.prototype.hasOwnProperty,Fv={current:null},MI={key:!0,ref:!0,__self:!0,__source:!0};function AI(e,t,n){var r,o={},s=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(s=""+t.key),t)$I.call(t,r)&&!MI.hasOwnProperty(r)&&(o[r]=t[r]);var a=arguments.length-2;if(a===1)o.children=n;else if(1<a){for(var c=Array(a),l=0;l<a;l++)c[l]=arguments[l+2];o.children=c}if(e&&e.defaultProps)for(r in a=e.defaultProps,a)o[r]===void 0&&(o[r]=a[r]);return{$$typeof:yu,type:e,key:s,ref:i,props:o,_owner:Fv.current}}function oD(e,t){return{$$typeof:yu,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Nv(e){return typeof e=="object"&&e!==null&&e.$$typeof===yu}function sD(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Uw=/\/+/g;function Eg(e,t){return typeof e=="object"&&e!==null&&e.key!=null?sD(""+e.key):t.toString(36)}function qd(e,t,n,r,o){var s=typeof e;(s==="undefined"||s==="boolean")&&(e=null);var i=!1;if(e===null)i=!0;else switch(s){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case yu:case VO:i=!0}}if(i)return i=e,o=o(i),e=r===""?"."+Eg(i,0):r,Bw(o)?(n="",e!=null&&(n=e.replace(Uw,"$&/")+"/"),qd(o,t,n,"",function(l){return l})):o!=null&&(Nv(o)&&(o=oD(o,n+(!o.key||i&&i.key===o.key?"":(""+o.key).replace(Uw,"$&/")+"/")+e)),t.push(o)),1;if(i=0,r=r===""?".":r+":",Bw(e))for(var a=0;a<e.length;a++){s=e[a];var c=r+Eg(s,a);i+=qd(s,t,n,c,o)}else if(c=rD(e),typeof c=="function")for(e=c.call(e),a=0;!(s=e.next()).done;)s=s.value,c=r+Eg(s,a++),i+=qd(s,t,n,c,o);else if(s==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return i}function Yu(e,t,n){if(e==null)return e;var r=[],o=0;return qd(e,r,"","",function(s){return t.call(n,s,o++)}),r}function iD(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var yn={current:null},Zd={transition:null},aD={ReactCurrentDispatcher:yn,ReactCurrentBatchConfig:Zd,ReactCurrentOwner:Fv};function jI(){throw Error("act(...) is not supported in production builds of React.")}xe.Children={map:Yu,forEach:function(e,t,n){Yu(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Yu(e,function(){t++}),t},toArray:function(e){return Yu(e,function(t){return t})||[]},only:function(e){if(!Nv(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};xe.Component=uc;xe.Fragment=YO;xe.Profiler=qO;xe.PureComponent=Rv;xe.StrictMode=XO;xe.Suspense=eD;xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=aD;xe.act=jI;xe.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=_I({},e.props),o=e.key,s=e.ref,i=e._owner;if(t!=null){if(t.ref!==void 0&&(s=t.ref,i=Fv.current),t.key!==void 0&&(o=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(c in t)$I.call(t,c)&&!MI.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&a!==void 0?a[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){a=Array(c);for(var l=0;l<c;l++)a[l]=arguments[l+2];r.children=a}return{$$typeof:yu,type:e.type,key:o,ref:s,props:r,_owner:i}};xe.createContext=function(e){return e={$$typeof:QO,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:ZO,_context:e},e.Consumer=e};xe.createElement=AI;xe.createFactory=function(e){var t=AI.bind(null,e);return t.type=e,t};xe.createRef=function(){return{current:null}};xe.forwardRef=function(e){return{$$typeof:JO,render:e}};xe.isValidElement=Nv;xe.lazy=function(e){return{$$typeof:nD,_payload:{_status:-1,_result:e},_init:iD}};xe.memo=function(e,t){return{$$typeof:tD,type:e,compare:t===void 0?null:t}};xe.startTransition=function(e){var t=Zd.transition;Zd.transition={};try{e()}finally{Zd.transition=t}};xe.unstable_act=jI;xe.useCallback=function(e,t){return yn.current.useCallback(e,t)};xe.useContext=function(e){return yn.current.useContext(e)};xe.useDebugValue=function(){};xe.useDeferredValue=function(e){return yn.current.useDeferredValue(e)};xe.useEffect=function(e,t){return yn.current.useEffect(e,t)};xe.useId=function(){return yn.current.useId()};xe.useImperativeHandle=function(e,t,n){return yn.current.useImperativeHandle(e,t,n)};xe.useInsertionEffect=function(e,t){return yn.current.useInsertionEffect(e,t)};xe.useLayoutEffect=function(e,t){return yn.current.useLayoutEffect(e,t)};xe.useMemo=function(e,t){return yn.current.useMemo(e,t)};xe.useReducer=function(e,t,n){return yn.current.useReducer(e,t,n)};xe.useRef=function(e){return yn.current.useRef(e)};xe.useState=function(e){return yn.current.useState(e)};xe.useSyncExternalStore=function(e,t,n){return yn.current.useSyncExternalStore(e,t,n)};xe.useTransition=function(){return yn.current.useTransition()};xe.version="18.3.1";II.exports=xe;var x=II.exports;const Se=lc(x),cD=GO({__proto__:null,default:Se},[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 lD=x,uD=Symbol.for("react.element"),dD=Symbol.for("react.fragment"),hD=Object.prototype.hasOwnProperty,pD=lD.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,fD={key:!0,ref:!0,__self:!0,__source:!0};function OI(e,t,n){var r,o={},s=null,i=null;n!==void 0&&(s=""+n),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(i=t.ref);for(r in t)hD.call(t,r)&&!fD.hasOwnProperty(r)&&(o[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)o[r]===void 0&&(o[r]=t[r]);return{$$typeof:uD,type:e,key:s,ref:i,props:o,_owner:pD.current}}lf.Fragment=dD;lf.jsx=OI;lf.jsxs=OI;CI.exports=lf;var h=CI.exports;function O(e,t={}){const n=typeof e=="string"?e:e.src;if(typeof t=="function")return t(n);const{baseUrl:r=""}=t;return n.startsWith("data:")||n.match(/^https?:\/\//)?n:`${r.replace(/\/$/,"")}/${n.replace(/^\.?\//,"")}`}function gD(e){return{fonts:{monospace:O("./fonts/IBMPlexMono-Medium.woff2",e),sansSerif:O("./fonts/IBMPlexSans-Medium.woff2",e),serif:O("./fonts/IBMPlexSerif-Medium.woff2",e),draw:O("./fonts/Shantell_Sans-Tldrawish.woff2",e)},icons:{"align-bottom":O("./icons/icon/align-bottom.svg",e),"align-center-horizontal":O("./icons/icon/align-center-horizontal.svg",e),"align-center-vertical":O("./icons/icon/align-center-vertical.svg",e),"align-left":O("./icons/icon/align-left.svg",e),"align-right":O("./icons/icon/align-right.svg",e),"align-top":O("./icons/icon/align-top.svg",e),"arrow-left":O("./icons/icon/arrow-left.svg",e),"arrowhead-arrow":O("./icons/icon/arrowhead-arrow.svg",e),"arrowhead-bar":O("./icons/icon/arrowhead-bar.svg",e),"arrowhead-diamond":O("./icons/icon/arrowhead-diamond.svg",e),"arrowhead-dot":O("./icons/icon/arrowhead-dot.svg",e),"arrowhead-none":O("./icons/icon/arrowhead-none.svg",e),"arrowhead-square":O("./icons/icon/arrowhead-square.svg",e),"arrowhead-triangle-inverted":O("./icons/icon/arrowhead-triangle-inverted.svg",e),"arrowhead-triangle":O("./icons/icon/arrowhead-triangle.svg",e),blob:O("./icons/icon/blob.svg",e),"bring-forward":O("./icons/icon/bring-forward.svg",e),"bring-to-front":O("./icons/icon/bring-to-front.svg",e),broken:O("./icons/icon/broken.svg",e),"check-circle":O("./icons/icon/check-circle.svg",e),check:O("./icons/icon/check.svg",e),"chevron-down":O("./icons/icon/chevron-down.svg",e),"chevron-left":O("./icons/icon/chevron-left.svg",e),"chevron-right":O("./icons/icon/chevron-right.svg",e),"chevron-up":O("./icons/icon/chevron-up.svg",e),"chevrons-ne":O("./icons/icon/chevrons-ne.svg",e),"chevrons-sw":O("./icons/icon/chevrons-sw.svg",e),"clipboard-copied":O("./icons/icon/clipboard-copied.svg",e),"clipboard-copy":O("./icons/icon/clipboard-copy.svg",e),color:O("./icons/icon/color.svg",e),"cross-2":O("./icons/icon/cross-2.svg",e),"cross-circle":O("./icons/icon/cross-circle.svg",e),"dash-dashed":O("./icons/icon/dash-dashed.svg",e),"dash-dotted":O("./icons/icon/dash-dotted.svg",e),"dash-draw":O("./icons/icon/dash-draw.svg",e),"dash-solid":O("./icons/icon/dash-solid.svg",e),disconnected:O("./icons/icon/disconnected.svg",e),discord:O("./icons/icon/discord.svg",e),"distribute-horizontal":O("./icons/icon/distribute-horizontal.svg",e),"distribute-vertical":O("./icons/icon/distribute-vertical.svg",e),dot:O("./icons/icon/dot.svg",e),"dots-horizontal":O("./icons/icon/dots-horizontal.svg",e),"dots-vertical":O("./icons/icon/dots-vertical.svg",e),"drag-handle-dots":O("./icons/icon/drag-handle-dots.svg",e),duplicate:O("./icons/icon/duplicate.svg",e),edit:O("./icons/icon/edit.svg",e),"external-link":O("./icons/icon/external-link.svg",e),"fill-none":O("./icons/icon/fill-none.svg",e),"fill-pattern":O("./icons/icon/fill-pattern.svg",e),"fill-semi":O("./icons/icon/fill-semi.svg",e),"fill-solid":O("./icons/icon/fill-solid.svg",e),follow:O("./icons/icon/follow.svg",e),following:O("./icons/icon/following.svg",e),"font-draw":O("./icons/icon/font-draw.svg",e),"font-mono":O("./icons/icon/font-mono.svg",e),"font-sans":O("./icons/icon/font-sans.svg",e),"font-serif":O("./icons/icon/font-serif.svg",e),"geo-arrow-down":O("./icons/icon/geo-arrow-down.svg",e),"geo-arrow-left":O("./icons/icon/geo-arrow-left.svg",e),"geo-arrow-right":O("./icons/icon/geo-arrow-right.svg",e),"geo-arrow-up":O("./icons/icon/geo-arrow-up.svg",e),"geo-check-box":O("./icons/icon/geo-check-box.svg",e),"geo-cloud":O("./icons/icon/geo-cloud.svg",e),"geo-diamond":O("./icons/icon/geo-diamond.svg",e),"geo-ellipse":O("./icons/icon/geo-ellipse.svg",e),"geo-hexagon":O("./icons/icon/geo-hexagon.svg",e),"geo-octagon":O("./icons/icon/geo-octagon.svg",e),"geo-oval":O("./icons/icon/geo-oval.svg",e),"geo-pentagon":O("./icons/icon/geo-pentagon.svg",e),"geo-rectangle":O("./icons/icon/geo-rectangle.svg",e),"geo-rhombus-2":O("./icons/icon/geo-rhombus-2.svg",e),"geo-rhombus":O("./icons/icon/geo-rhombus.svg",e),"geo-star":O("./icons/icon/geo-star.svg",e),"geo-trapezoid":O("./icons/icon/geo-trapezoid.svg",e),"geo-triangle":O("./icons/icon/geo-triangle.svg",e),"geo-x-box":O("./icons/icon/geo-x-box.svg",e),github:O("./icons/icon/github.svg",e),group:O("./icons/icon/group.svg",e),"horizontal-align-end":O("./icons/icon/horizontal-align-end.svg",e),"horizontal-align-middle":O("./icons/icon/horizontal-align-middle.svg",e),"horizontal-align-start":O("./icons/icon/horizontal-align-start.svg",e),"info-circle":O("./icons/icon/info-circle.svg",e),leading:O("./icons/icon/leading.svg",e),link:O("./icons/icon/link.svg",e),lock:O("./icons/icon/lock.svg",e),menu:O("./icons/icon/menu.svg",e),minus:O("./icons/icon/minus.svg",e),mixed:O("./icons/icon/mixed.svg",e),pack:O("./icons/icon/pack.svg",e),plus:O("./icons/icon/plus.svg",e),"question-mark-circle":O("./icons/icon/question-mark-circle.svg",e),"question-mark":O("./icons/icon/question-mark.svg",e),redo:O("./icons/icon/redo.svg",e),"reset-zoom":O("./icons/icon/reset-zoom.svg",e),"rotate-ccw":O("./icons/icon/rotate-ccw.svg",e),"rotate-cw":O("./icons/icon/rotate-cw.svg",e),"send-backward":O("./icons/icon/send-backward.svg",e),"send-to-back":O("./icons/icon/send-to-back.svg",e),"share-1":O("./icons/icon/share-1.svg",e),"size-extra-large":O("./icons/icon/size-extra-large.svg",e),"size-large":O("./icons/icon/size-large.svg",e),"size-medium":O("./icons/icon/size-medium.svg",e),"size-small":O("./icons/icon/size-small.svg",e),"stack-horizontal":O("./icons/icon/stack-horizontal.svg",e),"stack-vertical":O("./icons/icon/stack-vertical.svg",e),"stretch-horizontal":O("./icons/icon/stretch-horizontal.svg",e),"stretch-vertical":O("./icons/icon/stretch-vertical.svg",e),"text-align-center":O("./icons/icon/text-align-center.svg",e),"text-align-left":O("./icons/icon/text-align-left.svg",e),"text-align-right":O("./icons/icon/text-align-right.svg",e),"toggle-off":O("./icons/icon/toggle-off.svg",e),"toggle-on":O("./icons/icon/toggle-on.svg",e),"tool-arrow":O("./icons/icon/tool-arrow.svg",e),"tool-eraser":O("./icons/icon/tool-eraser.svg",e),"tool-frame":O("./icons/icon/tool-frame.svg",e),"tool-hand":O("./icons/icon/tool-hand.svg",e),"tool-highlight":O("./icons/icon/tool-highlight.svg",e),"tool-laser":O("./icons/icon/tool-laser.svg",e),"tool-line":O("./icons/icon/tool-line.svg",e),"tool-media":O("./icons/icon/tool-media.svg",e),"tool-note":O("./icons/icon/tool-note.svg",e),"tool-pencil":O("./icons/icon/tool-pencil.svg",e),"tool-pointer":O("./icons/icon/tool-pointer.svg",e),"tool-screenshot":O("./icons/icon/tool-screenshot.svg",e),"tool-text":O("./icons/icon/tool-text.svg",e),trash:O("./icons/icon/trash.svg",e),twitter:O("./icons/icon/twitter.svg",e),undo:O("./icons/icon/undo.svg",e),ungroup:O("./icons/icon/ungroup.svg",e),unlock:O("./icons/icon/unlock.svg",e),"vertical-align-end":O("./icons/icon/vertical-align-end.svg",e),"vertical-align-middle":O("./icons/icon/vertical-align-middle.svg",e),"vertical-align-start":O("./icons/icon/vertical-align-start.svg",e),"warning-triangle":O("./icons/icon/warning-triangle.svg",e),"zoom-in":O("./icons/icon/zoom-in.svg",e),"zoom-out":O("./icons/icon/zoom-out.svg",e)},translations:{ar:O("./translations/ar.json",e),ca:O("./translations/ca.json",e),cs:O("./translations/cs.json",e),da:O("./translations/da.json",e),de:O("./translations/de.json",e),en:O("./translations/en.json",e),es:O("./translations/es.json",e),fa:O("./translations/fa.json",e),fi:O("./translations/fi.json",e),fr:O("./translations/fr.json",e),gl:O("./translations/gl.json",e),he:O("./translations/he.json",e),"hi-in":O("./translations/hi-in.json",e),hr:O("./translations/hr.json",e),hu:O("./translations/hu.json",e),id:O("./translations/id.json",e),it:O("./translations/it.json",e),ja:O("./translations/ja.json",e),"ko-kr":O("./translations/ko-kr.json",e),ku:O("./translations/ku.json",e),languages:O("./translations/languages.json",e),main:O("./translations/main.json",e),my:O("./translations/my.json",e),ne:O("./translations/ne.json",e),no:O("./translations/no.json",e),pl:O("./translations/pl.json",e),"pt-br":O("./translations/pt-br.json",e),"pt-pt":O("./translations/pt-pt.json",e),ro:O("./translations/ro.json",e),ru:O("./translations/ru.json",e),sl:O("./translations/sl.json",e),sv:O("./translations/sv.json",e),te:O("./translations/te.json",e),th:O("./translations/th.json",e),tr:O("./translations/tr.json",e),uk:O("./translations/uk.json",e),vi:O("./translations/vi.json",e),"zh-cn":O("./translations/zh-cn.json",e),"zh-tw":O("./translations/zh-tw.json",e)},embedIcons:{codepen:O("./embed-icons/codepen.png",e),codesandbox:O("./embed-icons/codesandbox.png",e),desmos:O("./embed-icons/desmos.png",e),excalidraw:O("./embed-icons/excalidraw.png",e),felt:O("./embed-icons/felt.png",e),figma:O("./embed-icons/figma.png",e),github_gist:O("./embed-icons/github_gist.png",e),google_calendar:O("./embed-icons/google_calendar.png",e),google_maps:O("./embed-icons/google_maps.png",e),google_slides:O("./embed-icons/google_slides.png",e),observable:O("./embed-icons/observable.png",e),replit:O("./embed-icons/replit.png",e),scratch:O("./embed-icons/scratch.png",e),spotify:O("./embed-icons/spotify.png",e),tldraw:O("./embed-icons/tldraw.png",e),val_town:O("./embed-icons/val_town.png",e),vimeo:O("./embed-icons/vimeo.png",e),youtube:O("./embed-icons/youtube.png",e)}}}async function mD(e,t){const{url:n,style:r="normal",weight:o="500",display:s,featureSettings:i,stretch:a,unicodeRange:c,variant:l,format:u}=t,d={style:r,weight:o,display:s,featureSettings:i,stretch:a,unicodeRange:c,variant:l},p=new FontFace(e,`url(${n})`,d);return await p.load(),document.fonts.add(p),p.$$_url=n,p.$$_fontface=`
|
|
18
|
-
@font-face {
|
|
19
|
-
font-family: ${p.family};
|
|
20
|
-
font-stretch: ${p.stretch};
|
|
21
|
-
font-weight: ${p.weight};
|
|
22
|
-
font-style: ${p.style};
|
|
23
|
-
src: url("${n}") format("${u}")
|
|
24
|
-
}`,p}function DI(e){return e&&typeof e=="object"&&"parents"in e}function RI(e){for(let t=0,n=e.parents.length;t<n;t++)if(e.parents[t].__unsafe__getWithoutCapture(!0),e.parents[t].lastChangedEpoch!==e.parentEpochs[t])return!0;return!1}const qh=(e,t)=>{if(e.children.remove(t)&&e.children.isEmpty&&DI(e))for(let n=0,r=e.parents.length;n<r;n++)qh(e.parents[n],e)},zv=(e,t)=>{if(e.children.add(t)&&DI(e))for(let n=0,r=e.parents.length;n<r;n++)zv(e.parents[n],e)};function LI(e,t){return e===t||Object.is(e,t)||!!(e&&t&&typeof e.equals=="function"&&e.equals(t))}function Ws(e,t){const n=Symbol.for(`com.tldraw.state/${e}`),r=globalThis;return r[n]??(r[n]=t()),r[n]}const Do=Ws("empty_array",()=>Object.freeze([])),Hw=8;class Zh{constructor(){m(this,"arraySize",0);m(this,"array",Array(Hw));m(this,"set",null)}get isEmpty(){if(this.array)return this.arraySize===0;if(this.set)return this.set.size===0;throw new Error("no set or array")}add(t){if(this.array)return this.array.indexOf(t)!==-1?!1:this.arraySize<Hw?(this.array[this.arraySize]=t,this.arraySize++,!0):(this.set=new Set(this.array),this.array=null,this.set.add(t),!0);if(this.set)return this.set.has(t)?!1:(this.set.add(t),!0);throw new Error("no set or array")}remove(t){if(this.array){const n=this.array.indexOf(t);return n===-1?!1:(this.array[n]=void 0,this.arraySize--,n!==this.arraySize&&(this.array[n]=this.array[this.arraySize],this.array[this.arraySize]=void 0),!0)}if(this.set)return this.set.has(t)?(this.set.delete(t),!0):!1;throw new Error("no set or array")}visit(t){if(this.array){for(let n=0;n<this.arraySize;n++){const r=this.array[n];typeof r<"u"&&t(r)}return}if(this.set){this.set.forEach(t);return}throw new Error("no set or array")}has(t){return this.array?this.array.indexOf(t)!==-1:this.set.has(t)}clear(){this.set?this.set.clear():(this.arraySize=0,this.array=[])}size(){return this.set?this.set.size:this.arraySize}}const Xn=Symbol.for("com.tldraw.state/RESET_VALUE");class FI{constructor(t){m(this,"index",0);m(this,"buffer");this.capacity=t,this.buffer=new Array(t)}pushEntry(t,n,r){if(r!==void 0){if(r===Xn){this.clear();return}this.buffer[this.index]=[t,n,r],this.index=(this.index+1)%this.capacity}}clear(){this.index=0,this.buffer.fill(void 0)}getChangesSince(t){const{index:n,capacity:r,buffer:o}=this;for(let s=0;s<r;s++){const i=(n-1+r-s)%r,a=o[i];if(!a)return Xn;const[c,l]=a;if(s===0&&t>=l)return[];if(c<=t&&t<l){const u=s+1,d=new Array(u);for(let p=0;p<u;p++)d[p]=o[(i+p)%r][2];return d}}return Xn}}class yD{constructor(t,n){m(this,"offset",0);m(this,"maybeRemoved");this.below=t,this.child=n}}const xt=Ws("capture",()=>({stack:null}));function NI(e){xt.stack=new yD(xt.stack,e),e.parentSet.clear()}function zI(){const e=xt.stack;if(xt.stack=e.below,e.offset<e.child.parents.length){for(let t=e.offset;t<e.child.parents.length;t++){const n=e.child.parents[t];e.child.parentSet.has(n)||qh(n,e.child)}e.child.parents.length=e.offset,e.child.parentEpochs.length=e.offset}if(e.maybeRemoved)for(let t=0;t<e.maybeRemoved.length;t++){const n=e.maybeRemoved[t];e.child.parentSet.has(n)||qh(n,e.child)}}function Qh(e){if(xt.stack){if(xt.stack.child.parentSet.has(e))return;if(xt.stack.child.parentSet.add(e),xt.stack.child.isActivelyListening&&zv(e,xt.stack.child),xt.stack.offset<xt.stack.child.parents.length){const n=xt.stack.child.parents[xt.stack.offset];n!==e&&(xt.stack.maybeRemoved?xt.stack.maybeRemoved.push(n):xt.stack.maybeRemoved=[n])}xt.stack.child.parents[xt.stack.offset]=e,xt.stack.child.parentEpochs[xt.stack.offset]=e.lastChangedEpoch,xt.stack.offset++}}const bs=-1;class SD{constructor(t,n,r){m(this,"_isActivelyListening",!1);m(this,"lastTraversedEpoch",bs);m(this,"lastReactedEpoch",bs);m(this,"_scheduleCount",0);m(this,"parentSet",new Zh);m(this,"parentEpochs",[]);m(this,"parents",[]);m(this,"_scheduleEffect");m(this,"maybeExecute",()=>{this._isActivelyListening&&this.execute()});this.name=t,this.runEffect=n,this._scheduleEffect=r==null?void 0:r.scheduleEffect}get isActivelyListening(){return this._isActivelyListening}get scheduleCount(){return this._scheduleCount}maybeScheduleEffect(){if(this._isActivelyListening&&this.lastReactedEpoch!==Cn()){if(this.parents.length&&!RI(this)){this.lastReactedEpoch=Cn();return}this.scheduleEffect()}}scheduleEffect(){this._scheduleCount++,this._scheduleEffect?this._scheduleEffect(this.maybeExecute):this.execute()}attach(){this._isActivelyListening=!0;for(let t=0,n=this.parents.length;t<n;t++)zv(this.parents[t],this)}detach(){this._isActivelyListening=!1;for(let t=0,n=this.parents.length;t<n;t++)qh(this.parents[t],this)}execute(){try{NI(this);const t=Cn(),n=this.runEffect(this.lastReactedEpoch);return this.lastReactedEpoch=t,n}finally{zI()}}}const dc=Ws("EffectScheduler",()=>SD);function hc(e,t,n){const r=new dc(e,t,n);return r.attach(),r.scheduleEffect(),()=>{r.detach()}}function vD(e,t,n){const r=new dc(e,t,n);return{scheduler:r,start:o=>{const s=(o==null?void 0:o.force)??!1;r.attach(),s?r.scheduleEffect():r.maybeScheduleEffect()},stop:()=>{r.detach()}}}class xD{constructor(t){m(this,"initialAtomValues",new Map);this.parent=t}get isRoot(){return this.parent===null}commit(){this.isRoot?BI(this.initialAtomValues.keys()):this.initialAtomValues.forEach((t,n)=>{this.parent.initialAtomValues.has(n)||this.parent.initialAtomValues.set(n,t)})}abort(){Be.globalEpoch++,this.initialAtomValues.forEach((t,n)=>{var r;n.set(t),(r=n.historyBuffer)==null||r.clear()}),this.commit()}}const Be=Ws("transactions",()=>({globalEpoch:bs+1,globalIsReacting:!1,currentTransaction:null,cleanupReactors:null,reactionEpoch:bs+1}));function wD(){return Be.reactionEpoch}function Cn(){return Be.globalEpoch}function bD(){return Be.globalIsReacting}function Bv(e,t){t.lastTraversedEpoch!==Be.globalEpoch&&(t.lastTraversedEpoch=Be.globalEpoch,t instanceof dc?e.add(t):t.children.visit(n=>Bv(e,n)))}function BI(e){var t;if(Be.globalIsReacting)throw new Error("cannot change atoms during reaction cycle");try{Be.globalIsReacting=!0,Be.reactionEpoch=Be.globalEpoch;const n=new Set;for(const o of e)o.children.visit(s=>Bv(n,s));for(const o of n)o.maybeScheduleEffect();let r=0;for(;(t=Be.cleanupReactors)!=null&&t.size;){if(r++>1e3)throw new Error("Reaction update depth limit exceeded");const o=Be.cleanupReactors;Be.cleanupReactors=null;for(const s of o)s.maybeScheduleEffect()}}finally{Be.cleanupReactors=null,Be.globalIsReacting=!1}}function PD(e,t){if(Be.globalIsReacting){const n=Be.cleanupReactors??(Be.cleanupReactors=new Set);e.children.visit(r=>Bv(n,r))}else Be.currentTransaction?Be.currentTransaction.initialAtomValues.has(e)||Be.currentTransaction.initialAtomValues.set(e,t):BI([e])}function CD(){Be.globalEpoch++}function ID(e){const t=new xD(Be.currentTransaction);Be.currentTransaction=t;try{let n,r=!1;try{n=e(()=>r=!0)}catch(o){throw t.abort(),o}return r?t.abort():t.commit(),n}finally{Be.currentTransaction=Be.currentTransaction.parent}}function Ro(e){return Be.currentTransaction?e():ID(e)}class ED{constructor(t,n,r){m(this,"isEqual");m(this,"computeDiff");m(this,"lastChangedEpoch",Cn());m(this,"children",new Zh);m(this,"historyBuffer");this.name=t,this.current=n,this.isEqual=(r==null?void 0:r.isEqual)??null,r&&(r.historyLength&&(this.historyBuffer=new FI(r.historyLength)),this.computeDiff=r.computeDiff)}__unsafe__getWithoutCapture(t){return this.current}get(){return Qh(this),this.current}set(t,n){var o,s;if(((o=this.isEqual)==null?void 0:o.call(this,this.current,t))??LI(this.current,t))return this.current;CD(),this.historyBuffer&&this.historyBuffer.pushEntry(this.lastChangedEpoch,Cn(),n??((s=this.computeDiff)==null?void 0:s.call(this,this.current,t,this.lastChangedEpoch,Cn()))??Xn),this.lastChangedEpoch=Cn();const r=this.current;return this.current=t,PD(this,r),t}update(t){return this.set(t(this.current))}getDiffSince(t){var n;return Qh(this),t>=this.lastChangedEpoch?Do:((n=this.historyBuffer)==null?void 0:n.getChangesSince(t))??Xn}}const _D=Ws("Atom",()=>ED);function pn(e,t,n){return new _D(e,t,n)}let Kw=!1;function kD(){Kw||(Kw=!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 ol=Symbol.for("com.tldraw.state/UNINITIALIZED"),vi=e=>e===ol,Oy=Ws("WithDiff",()=>class{constructor(t,n){this.value=t,this.diff=n}});function sl(e,t){return new Oy(e,t)}class TD{constructor(t,n,r){m(this,"lastChangedEpoch",bs);m(this,"lastTraversedEpoch",bs);m(this,"lastCheckedEpoch",bs);m(this,"parentSet",new Zh);m(this,"parents",[]);m(this,"parentEpochs",[]);m(this,"children",new Zh);m(this,"historyBuffer");m(this,"state",ol);m(this,"error",null);m(this,"computeDiff");m(this,"isEqual");this.name=t,this.derive=n,r!=null&&r.historyLength&&(this.historyBuffer=new FI(r.historyLength)),this.computeDiff=r==null?void 0:r.computeDiff,this.isEqual=(r==null?void 0:r.isEqual)??LI}get isActivelyListening(){return!this.children.isEmpty}__unsafe__getWithoutCapture(t){var o;const n=this.lastChangedEpoch===bs,r=Cn();if(!n&&(this.lastCheckedEpoch===r||this.isActivelyListening&&bD()&&this.lastTraversedEpoch<wD()||!RI(this)))if(this.lastCheckedEpoch=r,this.error){if(t)return this.state;throw this.error.thrownValue}else return this.state;try{NI(this);const s=this.derive(this.state,this.lastCheckedEpoch),i=s instanceof Oy?s.value:s,a=this.state===ol;if(a||!this.isEqual(i,this.state)){if(this.historyBuffer&&!a){const c=s instanceof Oy?s.diff:void 0;this.historyBuffer.pushEntry(this.lastChangedEpoch,Cn(),c??((o=this.computeDiff)==null?void 0:o.call(this,this.state,i,this.lastCheckedEpoch,Cn()))??Xn)}this.lastChangedEpoch=Cn(),this.state=i}return this.error=null,this.lastCheckedEpoch=Cn(),this.state}catch(s){if(this.state!==ol&&(this.state=ol,this.lastChangedEpoch=Cn()),this.lastCheckedEpoch=Cn(),this.historyBuffer&&this.historyBuffer.clear(),this.error={thrownValue:s},!t)throw s;return this.state}finally{zI()}}get(){try{return this.__unsafe__getWithoutCapture()}finally{Qh(this)}}getDiffSince(t){var n;return this.__unsafe__getWithoutCapture(!0),Qh(this),t>=this.lastChangedEpoch?Do:((n=this.historyBuffer)==null?void 0:n.getChangesSince(t))??Xn}}const Uv=Ws("Computed",()=>TD);function $D(e={},t,n,r){const o=r.value,s=Symbol.for("__@tldraw/state__computed__"+n);return r.value=function(){let i=this[s];return i||(i=new Uv(n,o.bind(this),e),Object.defineProperty(this,s,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()},r.value[AD]=!0,r}function Ww(e={},t,n,r){return r.get?(kD(),MD(e,t,n,r)):$D(e,t,n,r)}function MD(e={},t,n,r){const o=r.get,s=Symbol.for("__@tldraw/state__computed__"+n);return r.get=function(){let i=this[s];return i||(i=new Uv(n,o.bind(this),e),Object.defineProperty(this,s,{enumerable:!1,configurable:!1,writable:!1,value:i})),i.get()},r}const AD="@@__isComputedMethod__@@";function G(){if(arguments.length===1){const e=arguments[0];return(t,n,r)=>Ww(e,t,n,r)}else return typeof arguments[0]=="string"?new Uv(arguments[0],arguments[1],arguments[2]):Ww(void 0,arguments[0],arguments[1],arguments[2])}const UI=1,jD=Ws("apiVersion",()=>UI);if(jD!==UI)throw new Error("You have multiple incompatible versions of @tldraw/state in your app. Please deduplicate the package.");function uf(e,t){const n=Se.useRef(t);n.current=t;const[r,o,s]=Se.useMemo(()=>{let i=null;const a=u=>(i=u,()=>{i=null}),c=new dc(`useStateTracking(${e})`,()=>{var u;return(u=n.current)==null?void 0:u.call(n)},{scheduleEffect(){i==null||i()}});return[c,a,()=>c.scheduleCount]},[e]);return Se.useSyncExternalStore(o,s,s),Se.useEffect(()=>(r.attach(),r.maybeScheduleEffect(),()=>{r.detach()}),[r]),r.execute()}const Gw={apply(e,t,n){return uf(e.displayName??e.name??"tracked(???)",()=>e.apply(t,n))}},OD=Symbol.for("react.memo"),DD=Symbol.for("react.forward_ref");function rr(e){let t=null;const n=e.$$typeof;return n===OD&&(e=e.type,t=e.compare),n===DD?x.memo(x.forwardRef(new Proxy(e.render,Gw))):x.memo(new Proxy(e,Gw),t)}function RD(){const e=arguments[0],t=arguments[1],n=arguments.length===3?void 0:arguments[2],r=arguments.length===3?arguments[2]:arguments[3];return x.useMemo(()=>G(`useComputed(${e})`,t,n),r)}function _s(e,t,n=Do){x.useEffect(()=>{const r=new dc(e,t);return r.attach(),r.execute(),()=>{r.detach()}},n)}function K(){const e=arguments,t=e.length===3?e[2]:[e[0]],n=e.length===3?e[0]:`useValue(${e[0].name})`,r=x.useRef(!0);r.current=!0;const o=x.useMemo(()=>e.length===1?e[0]:G(n,()=>{if(r.current)return e[1]();try{return e[1]()}catch{return{}}}),t);try{const{subscribe:s,getSnapshot:i}=x.useMemo(()=>({subscribe:a=>hc(`useValue(${n})`,()=>{o.get(),a()}),getSnapshot:()=>o.get()}),[o]);return x.useSyncExternalStore(s,i,i)}finally{r.current=!1}}class Qd{constructor(t){m(this,"nextValue");m(this,"diff");this.previousValue=t}get(){var r,o,s,i;const t=((o=(r=this.diff)==null?void 0:r.removed)==null?void 0:o.size)??0,n=((i=(s=this.diff)==null?void 0:s.added)==null?void 0:i.size)??0;if(!(t===0&&n===0))return{value:this.nextValue,diff:this.diff}}_add(t,n){var r,o;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.add(t),this.diff??(this.diff={}),n?(r=this.diff.removed)==null||r.delete(t):((o=this.diff).added??(o.added=new Set),this.diff.added.add(t))}add(t){var o,s,i;const n=this.previousValue.has(t);if(n)return((s=(o=this.diff)==null?void 0:o.removed)==null?void 0:s.has(t))?this._add(t,n):void 0;(i=this.nextValue)!=null&&i.has(t)||this._add(t,n)}_remove(t,n){var r,o;this.nextValue??(this.nextValue=new Set(this.previousValue)),this.nextValue.delete(t),this.diff??(this.diff={}),n?((r=this.diff).removed??(r.removed=new Set),this.diff.removed.add(t)):(o=this.diff.added)==null||o.delete(t)}remove(t){var o,s,i,a;const n=this.previousValue.has(t);if(!n)return((s=(o=this.diff)==null?void 0:o.added)==null?void 0:s.has(t))?this._remove(t,n):void 0;(a=(i=this.diff)==null?void 0:i.removed)!=null&&a.has(t)||this._remove(t,n)}}function Jh(e,t){const n=[];e:for(const r of e){for(const o of n)if(t?t(r,o):r===o)continue e;n.push(r)}return n}function fe(e){return e.filter(t=>t!=null)}function Bt(e){return e[e.length-1]}function LD(e,t){let n,r=1/0;for(const o of e){const s=t(o);s<r&&(n=o,r=s)}return n}function FD(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function ND(e,t){let n,r;return function(...o){return n||(n=!0,setTimeout(()=>n=!1,t),r=e(...o)),r}}function HI(e){const t=(...n)=>{try{return e(...n)}catch(r){throw r instanceof Error&&Error.captureStackTrace&&Error.captureStackTrace(r,t),r}};return t}function zD(){}const Wn={ok(e){return{ok:!0,value:e}},err(e){return{ok:!1,error:e}}};function fn(e,t){const n=t&&e&&typeof e=="object"&&t in e?e[t]:e;throw new Error(`Unknown switch case ${n}`)}const lt=HI((e,t)=>{if(!e)throw new Error(t||"Assertion Error")}),hi=HI((e,t)=>{if(e==null)throw new Error(t??"value must be defined");return e});function KI(e,t){let n;const r=(...o)=>(n||(n={},n.promise=new Promise((s,i)=>{n.resolve=s,n.reject=i})),clearTimeout(n.timeout),n.latestArgs=o,n.timeout=setTimeout(()=>{const s=n;n=void 0;try{s.resolve(e(...s.latestArgs))}catch(i){s.reject(i)}},t),n.promise);return r.cancel=()=>{n&&clearTimeout(n.timeout)},r}const Vw=new WeakMap;function Hv(e,t){if(typeof e!="object"||e===null)return;let n=Vw.get(e);n||(n={tags:{},extras:{}},Vw.set(e,n)),t.tags&&(n.tags={...n.tags,...t.tags}),t.extras&&(n.extras={...n.extras,...t.extras})}class Oa{static async dataUrlToArrayBuffer(t){return fetch(t).then(function(n){return n.arrayBuffer()})}static async blobToDataUrl(t){return await new Promise((n,r)=>{if(t){const o=new FileReader;o.onload=()=>n(o.result),o.onerror=s=>r(s),o.onabort=s=>r(s),o.readAsDataURL(t)}})}static async blobToText(t){return await new Promise((n,r)=>{if(t){const o=new FileReader;o.onload=()=>n(o.result),o.onerror=s=>r(s),o.onabort=s=>r(s),o.readAsText(t)}})}}function Dy(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t+""}function BD(e){const t=new DataView(e);let n=0;for(let r=0;r<t.byteLength;r++)n=(n<<5)-n+t.getUint8(r),n|=0;return n+""}let Ry=[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"&&(Ry=new Int32Array(Ry));const UD=(e,t)=>{let n=~~t^-1;for(let r=0;r<e.length;r++)n=Ry[(n^e[r])&255]^n>>>8;return n^-1},Yw=4,Xw=4;class Zr{static isPng(t,n){return t.getUint8(n+0)===137&&t.getUint8(n+1)===80&&t.getUint8(n+2)===78&&t.getUint8(n+3)===71&&t.getUint8(n+4)===13&&t.getUint8(n+5)===10&&t.getUint8(n+6)===26&&t.getUint8(n+7)===10}static getChunkType(t,n){return[String.fromCharCode(t.getUint8(n)),String.fromCharCode(t.getUint8(n+1)),String.fromCharCode(t.getUint8(n+2)),String.fromCharCode(t.getUint8(n+3))].join("")}static readChunks(t,n=0){const r={};if(!Zr.isPng(t,n))throw new Error("Not a PNG");for(n+=8;n<=t.buffer.byteLength;){const o=n,s=t.getInt32(n);n+=4;const i=Zr.getChunkType(t,n);if(i==="IDAT"&&r[i]){n+=s+Yw+Xw;continue}if(i==="IEND")break;r[i]={start:o,dataOffset:n+4,size:s},n+=s+Yw+Xw}return r}static parsePhys(t,n){return{ppux:t.getUint32(n),ppuy:t.getUint32(n+4),unit:t.getUint8(n+4)}}static findChunk(t,n){return Zr.readChunks(t)[n]}static setPhysChunk(t,n=1,r){let o=46,s=0;const i=Zr.findChunk(t,"pHYs");i&&(o=i.start,s=i.size);const a=Zr.findChunk(t,"IDAT");a&&(o=a.start,s=0);const c=new ArrayBuffer(21),l=new DataView(c);l.setUint32(0,9),l.setUint8(4,112),l.setUint8(5,72),l.setUint8(6,89),l.setUint8(7,115);const u=2835.5;l.setInt32(8,u*n),l.setInt32(12,u*n),l.setInt8(16,1);const d=new Uint8Array(c.slice(4,17));l.setInt32(17,UD(d));const p=t.buffer.slice(0,o),f=t.buffer.slice(o+s);return new Blob([p,c,f],r)}}class Ao{static loadVideo(t){return new Promise((n,r)=>{const o=document.createElement("video");o.onloadeddata=()=>n(o),o.onerror=s=>{console.error(s),r(new Error("Could not load video"))},o.crossOrigin="anonymous",o.src=t})}static loadImage(t){return new Promise((n,r)=>{const o=new Image;o.onload=()=>n(o),o.onerror=s=>{console.error(s),r(new Error("Could not load image"))},o.crossOrigin="anonymous",o.src=t})}static async getVideoSize(t){return Ao.usingObjectURL(t,async n=>{const r=await Ao.loadVideo(n);return{w:r.videoWidth,h:r.videoHeight}})}static async getImageSize(t){const n=await Ao.usingObjectURL(t,Ao.loadImage);try{if(t.type==="image/png"){const r=new DataView(await t.arrayBuffer());if(Zr.isPng(r,0)){const o=Zr.findChunk(r,"pHYs");if(o){const s=Zr.parsePhys(r,o.dataOffset);if(s.unit===0&&s.ppux===s.ppuy){const i=Math.max(s.ppux/2834.5,1);return{w:Math.round(n.naturalWidth/i),h:Math.round(n.naturalHeight/i)}}}}}}catch(r){return console.error(r),{w:n.naturalWidth,h:n.naturalHeight}}return{w:n.naturalWidth,h:n.naturalHeight}}static async usingObjectURL(t,n){const r=URL.createObjectURL(t);try{return await n(r)}finally{URL.revokeObjectURL(r)}}}function go(e=""){let t=0,n=0,r=0,o=0;function s(){const i=t^t<<11;return t=n,n=r,r=o,o^=(o>>>19^i^i>>>8)>>>0,o/4294967296*2}for(let i=0;i<e.length+64;i++)t^=e.charCodeAt(i)|0,s();return s}function ep(e,t,n,r=!1){const[o,s]=t,[i,a]=n,c=i+(e-o)/(s-o)*(a-i);return r?i<a?Math.max(Math.min(c,a),i):Math.max(Math.min(c,i),a):c}function no(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function qn(e,t){if(no(e,t))return e[t]}function qw(e){return Object.keys(e)}function _t(e){return Object.values(e)}function gn(e){return Object.entries(e)}function Kv(e){return Object.fromEntries(e)}function _g(e,t){const n={};let r=!1;for(const[o,s]of gn(e))t(o,s)?n[o]=s:r=!0;return r?n:e}function df(e,t){const n={};for(const[r,o]of gn(e)){const s=t(r,o);n[r]=s}return n}function WI(e,t){if(e===t)return!0;const n=new Set(Object.keys(e)),r=new Set(Object.keys(t));if(n.size!==r.size)return!1;for(const o of n)if(!r.has(o)||!Object.is(e[o],t[o]))return!1;return!0}const Vn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",GI="a0",VI="A00000000000000000000000000";function YI(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 XI(e){if(e.length!==YI(e.charAt(0)))throw new Error("invalid integer part of index key: "+e)}function Zw(e){if(e===void 0)throw Error("n is undefined")}function Qw(e){XI(e);const[t,...n]=e.split("");let r=!0;for(let o=n.length-1;r&&o>=0;o--){const s=Vn.indexOf(n[o])+1;s===Vn.length?n[o]="0":(n[o]=Vn.charAt(s),r=!1)}if(r){if(t==="Z")return"a0";if(t==="z")return;const o=String.fromCharCode(t.charCodeAt(0)+1);return o>"a"?n.push("0"):n.pop(),o+n.join("")}else return t+n.join("")}function HD(e){XI(e);const[t,...n]=e.split("");let r=!0;for(let o=n.length-1;r&&o>=0;o--){const s=Vn.indexOf(n[o])-1;s===-1?n[o]=Vn.slice(-1):(n[o]=Vn.charAt(s),r=!1)}if(r){if(t==="a")return"Z"+Vn.slice(-1);if(t==="A")return;const o=String.fromCharCode(t.charCodeAt(0)-1);return o<"Z"?n.push(Vn.slice(-1)):n.pop(),o+n.join("")}else return t+n.join("")}function pa(e,t){if(t!==void 0&&e>=t)throw new Error(e+" >= "+t);if(e.slice(-1)==="0"||t&&t.slice(-1)==="0")throw new Error("trailing zero");if(t){let o=0;for(;(e.charAt(o)||"0")===t.charAt(o);)o++;if(o>0)return t.slice(0,o)+pa(e.slice(o),t.slice(o))}const n=e?Vn.indexOf(e.charAt(0)):0,r=t!==void 0?Vn.indexOf(t.charAt(0)):Vn.length;if(r-n>1){const o=Math.round(.5*(n+r));return Vn.charAt(o)}else return t&&t.length>1?t.slice(0,1):Vn.charAt(n)+pa(e.slice(1),void 0)}function il(e){const t=YI(e.charAt(0));if(t>e.length)throw new Error("invalid index: "+e);return e.slice(0,t)}function Ly(e){if(e===VI)throw new Error("invalid index: "+e);const t=il(e);if(e.slice(t.length).slice(-1)==="0")throw new Error("invalid index: "+e)}function qi(e,t){if(e!==void 0&&Ly(e),t!==void 0&&Ly(t),e!==void 0&&t!==void 0&&e>=t)throw new Error(e+" >= "+t);if(e===void 0&&t===void 0)return GI;if(e===void 0){if(t===void 0)throw Error("b is undefined");const a=il(t),c=t.slice(a.length);if(a===VI)return a+pa("",c);if(a<t)return a;const l=HD(a);return Zw(l),l}if(t===void 0){const a=il(e),c=e.slice(a.length),l=Qw(a);return l===void 0?a+pa(c,void 0):l}const n=il(e),r=e.slice(n.length),o=il(t),s=t.slice(o.length);if(n===o)return n+pa(r,s);const i=Qw(n);return Zw(i),i<t?i:n+pa(r,void 0)}function Ls(e,t,n){if(n===0)return[];if(n===1)return[qi(e,t)];if(t===void 0){let s=qi(e,t);const i=[s];for(let a=0;a<n-1;a++)s=qi(s,t),i.push(s);return i}if(e===void 0){let s=qi(e,t);const i=[s];for(let a=0;a<n-1;a++)s=qi(e,s),i.push(s);return i.reverse(),i}const r=Math.floor(n/2),o=qi(e,t);return[...Ls(e,o,r),o,...Ls(o,t,n-r-1)]}const KD=GI;function WD(e){Ly(e)}function Va(e,t,n){return Ls(e,t,n)}function kg(e,t){return Ls(e,void 0,t)}function fl(e,t){return Ls(e,t,1)[0]}function $o(e){return Ls(e,void 0,1)[0]}function GD(e){return Ls(void 0,e,1)[0]}function Al(e,t="a1"){return[t,...Ls(t,void 0,e)]}function rn(e,t){return e.index<t.index?-1:e.index>t.index?1:0}function VD(e,t){return e.id>t.id?1:-1}function Wv(e){try{return localStorage.getItem(e)}catch{return null}}function Gv(e,t){try{localStorage.setItem(e,t)}catch{}}function YD(){try{localStorage.clear()}catch{}}function qI(e){try{return sessionStorage.getItem(e)}catch{return null}}function Vv(e,t){try{sessionStorage.setItem(e,t)}catch{}}function ZI(e){try{sessionStorage.removeItem(e)}catch{}}function XD(){try{sessionStorage.clear()}catch{}}const qD=()=>typeof process<"u"&&!1,fa=[],ZD=60,Jd=Math.ceil(1e3/ZD);let Oc,Tg=0,Fy=0;const QD=()=>{const e=fa.splice(0,fa.length);for(const t of e)t()};function QI(){if(Oc)return;const e=Date.now(),t=e-Fy;if(Tg+t<Jd){Oc=requestAnimationFrame(()=>{Oc=void 0,QI()});return}Oc=requestAnimationFrame(()=>{Oc=void 0,Fy=e,Tg=Math.min(Tg+t-Jd,Jd*10),QD()})}let Jw=!1;function JI(e){return qD()?(e(),()=>{}):(fa.includes(e)||(fa.push(e),Jw||(Jw=!0,Fy=Date.now()-Jd-1),QI()),()=>{const t=fa.indexOf(e);t>-1&&fa.splice(t,1)})}function JD(e){return e!==null}function eR(){return typeof globalThis<"u"&&globalThis.structuredClone?[globalThis.structuredClone,!0]:typeof global<"u"&&global.structuredClone?[global.structuredClone,!0]:typeof window<"u"&&window.structuredClone?[window.structuredClone,!0]:[e=>e&&JSON.parse(JSON.stringify(e)),!1]}const eE=eR(),Ge=eE[0];eE[1];const tR=Object.getPrototypeOf(Ge({}));let hf=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");class Yv{constructor(t,n){m(this,"createDefaultProperties");m(this,"validator");m(this,"ephemeralKeys");m(this,"ephemeralKeySet");m(this,"scope");m(this,"isInstance",t=>(t==null?void 0:t.typeName)===this.typeName);this.typeName=t,this.createDefaultProperties=n.createDefaultProperties,this.validator=n.validator??{validate:o=>o},this.scope=n.scope??"document",this.ephemeralKeys=n.ephemeralKeys;const r=new Set;if(n.ephemeralKeys)for(const[o,s]of gn(n.ephemeralKeys))s&&r.add(o);this.ephemeralKeySet=r}create(t){const n={...this.createDefaultProperties(),id:this.createId()};for(const[r,o]of Object.entries(t))o!==void 0&&(n[r]=o);return n.typeName=this.typeName,n}clone(t){return{...Ge(t),id:this.createId()}}createId(t){return this.typeName+":"+(t??hf())}createCustomId(t){return this.typeName+":"+t}parseId(t){if(!this.isId(t))throw new Error(`ID "${t}" is not a valid ID for type "${this.typeName}"`);return t.slice(this.typeName.length+1)}isId(t){if(!t)return!1;for(let n=0;n<this.typeName.length;n++)if(t[n]!==this.typeName[n])return!1;return t[this.typeName.length]===":"}withDefaultProperties(t){return new Yv(this.typeName,{createDefaultProperties:t,validator:this.validator,scope:this.scope,ephemeralKeys:this.ephemeralKeys})}validate(t,n){return n&&this.validator.validateUsingKnownGoodVersion?this.validator.validateUsingKnownGoodVersion(n,t):this.validator.validate(t)}}function Zo(e,t){return new Yv(e,{createDefaultProperties:()=>({}),validator:t.validator,scope:t.scope,ephemeralKeys:t.ephemeralKeys})}function Ny(){return{added:{},updated:{},removed:{}}}function eb(e){const t={added:e.removed,removed:e.added,updated:{}};for(const[n,r]of Object.values(e.updated))t.updated[n.id]=[r,n];return t}function tE(e){return Object.keys(e.added).length===0&&Object.keys(e.updated).length===0&&Object.keys(e.removed).length===0}function pf(e){const t={added:{},removed:{},updated:{}};return tp(t,e),t}function tp(e,t){for(const n of t){for(const[r,o]of gn(n.added))if(e.removed[r]){const s=e.removed[r];delete e.removed[r],s!==o&&(e.updated[r]=[s,o])}else e.added[r]=o;for(const[r,[o,s]]of gn(n.updated)){if(e.added[r]){e.added[r]=s,delete e.updated[r],delete e.removed[r];continue}if(e.updated[r]){e.updated[r]=[e.updated[r][0],s],delete e.removed[r];continue}e.updated[r]=n.updated[r],delete e.removed[r]}for(const[r,o]of gn(n.removed))e.added[r]?delete e.added[r]:e.updated[r]?(e.removed[r]=e.updated[r][0],delete e.updated[r]):e.removed[r]=o}}class tb{constructor(){m(this,"items",new WeakMap)}get(t,n){return this.items.has(t)||this.items.set(t,n(t)),this.items.get(t)}}var np={exports:{}};np.exports;(function(e,t){var n=200,r="__lodash_hash_undefined__",o=1,s=2,i=9007199254740991,a="[object Arguments]",c="[object Array]",l="[object AsyncFunction]",u="[object Boolean]",d="[object Date]",p="[object Error]",f="[object Function]",y="[object GeneratorFunction]",g="[object Map]",w="[object Number]",S="[object Null]",v="[object Object]",P="[object Promise]",I="[object Proxy]",C="[object RegExp]",E="[object Set]",_="[object String]",k="[object Symbol]",$="[object Undefined]",T="[object WeakMap]",A="[object ArrayBuffer]",B="[object DataView]",L="[object Float32Array]",R="[object Float64Array]",N="[object Int8Array]",X="[object Int16Array]",q="[object Int32Array]",H="[object Uint8Array]",U="[object Uint8ClampedArray]",W="[object Uint16Array]",Q="[object Uint32Array]",le=/[\\^$.*+?()[\]{}|]/g,be=/^\[object .+?Constructor\]$/,Ae=/^(?:0|[1-9]\d*)$/,ae={};ae[L]=ae[R]=ae[N]=ae[X]=ae[q]=ae[H]=ae[U]=ae[W]=ae[Q]=!0,ae[a]=ae[c]=ae[A]=ae[u]=ae[B]=ae[d]=ae[p]=ae[f]=ae[g]=ae[w]=ae[v]=ae[C]=ae[E]=ae[_]=ae[T]=!1;var je=typeof on=="object"&&on&&on.Object===Object&&on,Fe=typeof self=="object"&&self&&self.Object===Object&&self,it=je||Fe||Function("return this")(),Ee=t&&!t.nodeType&&t,gt=Ee&&!0&&e&&!e.nodeType&&e,We=gt&>.exports===Ee,ar=We&&je.process,Ln=function(){try{return ar&&ar.binding&&ar.binding("util")}catch{}}(),Fn=Ln&&Ln.isTypedArray;function Qe(M,D){for(var V=-1,J=M==null?0:M.length,Je=0,me=[];++V<J;){var mt=M[V];D(mt,V,M)&&(me[Je++]=mt)}return me}function Lt(M,D){for(var V=-1,J=D.length,Je=M.length;++V<J;)M[Je+V]=D[V];return M}function Po(M,D){for(var V=-1,J=M==null?0:M.length;++V<J;)if(D(M[V],V,M))return!0;return!1}function kc(M,D){for(var V=-1,J=Array(M);++V<M;)J[V]=D(V);return J}function Tc(M){return function(D){return M(D)}}function Sg(M,D){return M.has(D)}function Yi(M,D){return M==null?void 0:M[D]}function Bj(M){var D=-1,V=Array(M.size);return M.forEach(function(J,Je){V[++D]=[Je,J]}),V}function Uj(M,D){return function(V){return M(D(V))}}function Hj(M){var D=-1,V=Array(M.size);return M.forEach(function(J){V[++D]=J}),V}var Kj=Array.prototype,Wj=Function.prototype,zu=Object.prototype,vg=it["__core-js_shared__"],bw=Wj.toString,Gr=zu.hasOwnProperty,Pw=function(){var M=/[^.]+$/.exec(vg&&vg.keys&&vg.keys.IE_PROTO||"");return M?"Symbol(src)_1."+M:""}(),Cw=zu.toString,Gj=RegExp("^"+bw.call(Gr).replace(le,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Iw=We?it.Buffer:void 0,Bu=it.Symbol,Ew=it.Uint8Array,_w=zu.propertyIsEnumerable,Vj=Kj.splice,ni=Bu?Bu.toStringTag:void 0,kw=Object.getOwnPropertySymbols,Yj=Iw?Iw.isBuffer:void 0,Xj=Uj(Object.keys,Object),xg=Xi(it,"DataView"),$c=Xi(it,"Map"),wg=Xi(it,"Promise"),bg=Xi(it,"Set"),Pg=Xi(it,"WeakMap"),Mc=Xi(Object,"create"),qj=si(xg),Zj=si($c),Qj=si(wg),Jj=si(bg),eO=si(Pg),Tw=Bu?Bu.prototype:void 0,Cg=Tw?Tw.valueOf:void 0;function ri(M){var D=-1,V=M==null?0:M.length;for(this.clear();++D<V;){var J=M[D];this.set(J[0],J[1])}}function tO(){this.__data__=Mc?Mc(null):{},this.size=0}function nO(M){var D=this.has(M)&&delete this.__data__[M];return this.size-=D?1:0,D}function rO(M){var D=this.__data__;if(Mc){var V=D[M];return V===r?void 0:V}return Gr.call(D,M)?D[M]:void 0}function oO(M){var D=this.__data__;return Mc?D[M]!==void 0:Gr.call(D,M)}function sO(M,D){var V=this.__data__;return this.size+=this.has(M)?0:1,V[M]=Mc&&D===void 0?r:D,this}ri.prototype.clear=tO,ri.prototype.delete=nO,ri.prototype.get=rO,ri.prototype.has=oO,ri.prototype.set=sO;function Co(M){var D=-1,V=M==null?0:M.length;for(this.clear();++D<V;){var J=M[D];this.set(J[0],J[1])}}function iO(){this.__data__=[],this.size=0}function aO(M){var D=this.__data__,V=Hu(D,M);if(V<0)return!1;var J=D.length-1;return V==J?D.pop():Vj.call(D,V,1),--this.size,!0}function cO(M){var D=this.__data__,V=Hu(D,M);return V<0?void 0:D[V][1]}function lO(M){return Hu(this.__data__,M)>-1}function uO(M,D){var V=this.__data__,J=Hu(V,M);return J<0?(++this.size,V.push([M,D])):V[J][1]=D,this}Co.prototype.clear=iO,Co.prototype.delete=aO,Co.prototype.get=cO,Co.prototype.has=lO,Co.prototype.set=uO;function oi(M){var D=-1,V=M==null?0:M.length;for(this.clear();++D<V;){var J=M[D];this.set(J[0],J[1])}}function dO(){this.size=0,this.__data__={hash:new ri,map:new($c||Co),string:new ri}}function hO(M){var D=Ku(this,M).delete(M);return this.size-=D?1:0,D}function pO(M){return Ku(this,M).get(M)}function fO(M){return Ku(this,M).has(M)}function gO(M,D){var V=Ku(this,M),J=V.size;return V.set(M,D),this.size+=V.size==J?0:1,this}oi.prototype.clear=dO,oi.prototype.delete=hO,oi.prototype.get=pO,oi.prototype.has=fO,oi.prototype.set=gO;function Uu(M){var D=-1,V=M==null?0:M.length;for(this.__data__=new oi;++D<V;)this.add(M[D])}function mO(M){return this.__data__.set(M,r),this}function yO(M){return this.__data__.has(M)}Uu.prototype.add=Uu.prototype.push=mO,Uu.prototype.has=yO;function as(M){var D=this.__data__=new Co(M);this.size=D.size}function SO(){this.__data__=new Co,this.size=0}function vO(M){var D=this.__data__,V=D.delete(M);return this.size=D.size,V}function xO(M){return this.__data__.get(M)}function wO(M){return this.__data__.has(M)}function bO(M,D){var V=this.__data__;if(V instanceof Co){var J=V.__data__;if(!$c||J.length<n-1)return J.push([M,D]),this.size=++V.size,this;V=this.__data__=new oi(J)}return V.set(M,D),this.size=V.size,this}as.prototype.clear=SO,as.prototype.delete=vO,as.prototype.get=xO,as.prototype.has=wO,as.prototype.set=bO;function PO(M,D){var V=Wu(M),J=!V&&FO(M),Je=!V&&!J&&Ig(M),me=!V&&!J&&!Je&&Fw(M),mt=V||J||Je||me,$t=mt?kc(M.length,String):[],Ft=$t.length;for(var at in M)Gr.call(M,at)&&!(mt&&(at=="length"||Je&&(at=="offset"||at=="parent")||me&&(at=="buffer"||at=="byteLength"||at=="byteOffset")||jO(at,Ft)))&&$t.push(at);return $t}function Hu(M,D){for(var V=M.length;V--;)if(Ow(M[V][0],D))return V;return-1}function CO(M,D,V){var J=D(M);return Wu(M)?J:Lt(J,V(M))}function Ac(M){return M==null?M===void 0?$:S:ni&&ni in Object(M)?MO(M):LO(M)}function $w(M){return jc(M)&&Ac(M)==a}function Mw(M,D,V,J,Je){return M===D?!0:M==null||D==null||!jc(M)&&!jc(D)?M!==M&&D!==D:IO(M,D,V,J,Mw,Je)}function IO(M,D,V,J,Je,me){var mt=Wu(M),$t=Wu(D),Ft=mt?c:cs(M),at=$t?c:cs(D);Ft=Ft==a?v:Ft,at=at==a?v:at;var Nn=Ft==v,Er=at==v,qt=Ft==at;if(qt&&Ig(M)){if(!Ig(D))return!1;mt=!0,Nn=!1}if(qt&&!Nn)return me||(me=new as),mt||Fw(M)?Aw(M,D,V,J,Je,me):TO(M,D,Ft,V,J,Je,me);if(!(V&o)){var cr=Nn&&Gr.call(M,"__wrapped__"),lr=Er&&Gr.call(D,"__wrapped__");if(cr||lr){var ls=cr?M.value():M,Io=lr?D.value():D;return me||(me=new as),Je(ls,Io,V,J,me)}}return qt?(me||(me=new as),$O(M,D,V,J,Je,me)):!1}function EO(M){if(!Lw(M)||DO(M))return!1;var D=Dw(M)?Gj:be;return D.test(si(M))}function _O(M){return jc(M)&&Rw(M.length)&&!!ae[Ac(M)]}function kO(M){if(!RO(M))return Xj(M);var D=[];for(var V in Object(M))Gr.call(M,V)&&V!="constructor"&&D.push(V);return D}function Aw(M,D,V,J,Je,me){var mt=V&o,$t=M.length,Ft=D.length;if($t!=Ft&&!(mt&&Ft>$t))return!1;var at=me.get(M);if(at&&me.get(D))return at==D;var Nn=-1,Er=!0,qt=V&s?new Uu:void 0;for(me.set(M,D),me.set(D,M);++Nn<$t;){var cr=M[Nn],lr=D[Nn];if(J)var ls=mt?J(lr,cr,Nn,D,M,me):J(cr,lr,Nn,M,D,me);if(ls!==void 0){if(ls)continue;Er=!1;break}if(qt){if(!Po(D,function(Io,ii){if(!Sg(qt,ii)&&(cr===Io||Je(cr,Io,V,J,me)))return qt.push(ii)})){Er=!1;break}}else if(!(cr===lr||Je(cr,lr,V,J,me))){Er=!1;break}}return me.delete(M),me.delete(D),Er}function TO(M,D,V,J,Je,me,mt){switch(V){case B:if(M.byteLength!=D.byteLength||M.byteOffset!=D.byteOffset)return!1;M=M.buffer,D=D.buffer;case A:return!(M.byteLength!=D.byteLength||!me(new Ew(M),new Ew(D)));case u:case d:case w:return Ow(+M,+D);case p:return M.name==D.name&&M.message==D.message;case C:case _:return M==D+"";case g:var $t=Bj;case E:var Ft=J&o;if($t||($t=Hj),M.size!=D.size&&!Ft)return!1;var at=mt.get(M);if(at)return at==D;J|=s,mt.set(M,D);var Nn=Aw($t(M),$t(D),J,Je,me,mt);return mt.delete(M),Nn;case k:if(Cg)return Cg.call(M)==Cg.call(D)}return!1}function $O(M,D,V,J,Je,me){var mt=V&o,$t=jw(M),Ft=$t.length,at=jw(D),Nn=at.length;if(Ft!=Nn&&!mt)return!1;for(var Er=Ft;Er--;){var qt=$t[Er];if(!(mt?qt in D:Gr.call(D,qt)))return!1}var cr=me.get(M);if(cr&&me.get(D))return cr==D;var lr=!0;me.set(M,D),me.set(D,M);for(var ls=mt;++Er<Ft;){qt=$t[Er];var Io=M[qt],ii=D[qt];if(J)var Nw=mt?J(ii,Io,qt,D,M,me):J(Io,ii,qt,M,D,me);if(!(Nw===void 0?Io===ii||Je(Io,ii,V,J,me):Nw)){lr=!1;break}ls||(ls=qt=="constructor")}if(lr&&!ls){var Gu=M.constructor,Vu=D.constructor;Gu!=Vu&&"constructor"in M&&"constructor"in D&&!(typeof Gu=="function"&&Gu instanceof Gu&&typeof Vu=="function"&&Vu instanceof Vu)&&(lr=!1)}return me.delete(M),me.delete(D),lr}function jw(M){return CO(M,BO,AO)}function Ku(M,D){var V=M.__data__;return OO(D)?V[typeof D=="string"?"string":"hash"]:V.map}function Xi(M,D){var V=Yi(M,D);return EO(V)?V:void 0}function MO(M){var D=Gr.call(M,ni),V=M[ni];try{M[ni]=void 0;var J=!0}catch{}var Je=Cw.call(M);return J&&(D?M[ni]=V:delete M[ni]),Je}var AO=kw?function(M){return M==null?[]:(M=Object(M),Qe(kw(M),function(D){return _w.call(M,D)}))}:UO,cs=Ac;(xg&&cs(new xg(new ArrayBuffer(1)))!=B||$c&&cs(new $c)!=g||wg&&cs(wg.resolve())!=P||bg&&cs(new bg)!=E||Pg&&cs(new Pg)!=T)&&(cs=function(M){var D=Ac(M),V=D==v?M.constructor:void 0,J=V?si(V):"";if(J)switch(J){case qj:return B;case Zj:return g;case Qj:return P;case Jj:return E;case eO:return T}return D});function jO(M,D){return D=D??i,!!D&&(typeof M=="number"||Ae.test(M))&&M>-1&&M%1==0&&M<D}function OO(M){var D=typeof M;return D=="string"||D=="number"||D=="symbol"||D=="boolean"?M!=="__proto__":M===null}function DO(M){return!!Pw&&Pw in M}function RO(M){var D=M&&M.constructor,V=typeof D=="function"&&D.prototype||zu;return M===V}function LO(M){return Cw.call(M)}function si(M){if(M!=null){try{return bw.call(M)}catch{}try{return M+""}catch{}}return""}function Ow(M,D){return M===D||M!==M&&D!==D}var FO=$w(function(){return arguments}())?$w:function(M){return jc(M)&&Gr.call(M,"callee")&&!_w.call(M,"callee")},Wu=Array.isArray;function NO(M){return M!=null&&Rw(M.length)&&!Dw(M)}var Ig=Yj||HO;function zO(M,D){return Mw(M,D)}function Dw(M){if(!Lw(M))return!1;var D=Ac(M);return D==f||D==y||D==l||D==I}function Rw(M){return typeof M=="number"&&M>-1&&M%1==0&&M<=i}function Lw(M){var D=typeof M;return M!=null&&(D=="object"||D=="function")}function jc(M){return M!=null&&typeof M=="object"}var Fw=Fn?Tc(Fn):_O;function BO(M){return NO(M)?PO(M):kO(M)}function UO(){return[]}function HO(){return!1}e.exports=zO})(np,np.exports);var nR=np.exports;const rR=lc(nR);function oR(e){if(e.length===0)return new Set;const t=e[0],n=e.slice(1),r=new Set;for(const o of t)n.every(s=>s.has(o))&&r.add(o);return r}function sR(e,t){const n={};for(const r of t)e.has(r)||(n.added??(n.added=new Set),n.added.add(r));for(const r of e)t.has(r)||(n.removed??(n.removed=new Set),n.removed.add(r));return n.added||n.removed?n:void 0}function nb(e,t){for(const[n,r]of Object.entries(e)){const o=r,s=t[n];if("eq"in o&&s!==o.eq||"neq"in o&&s===o.neq||"gt"in o&&(typeof s!="number"||s<=o.gt))return!1}return!0}function rb(e,t,n){const r=Object.fromEntries(Object.keys(n).map(o=>[o,new Set]));for(const[o,s]of Object.entries(n))if("eq"in s){const a=e.index(t,o).get().get(s.eq);if(a)for(const c of a)r[o].add(c)}else if("neq"in s){const i=e.index(t,o);for(const[a,c]of i.get())if(a!==s.neq)for(const l of c)r[o].add(l)}else if("gt"in s){const i=e.index(t,o);for(const[a,c]of i.get())if(a>s.gt)for(const l of c)r[o].add(l)}return oR(Object.values(r))}class iR{constructor(t,n){m(this,"indexCache",new Map);m(this,"historyCache",new Map);this.atoms=t,this.history=n}filterHistory(t){if(this.historyCache.has(t))return this.historyCache.get(t);const n=G("filterHistory:"+t,(r,o)=>{if(vi(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,c=0,l=0;for(const u of s){for(const d of _t(u.added))if(d.typeName===t)if(i.removed[d.id]){const p=i.removed[d.id];delete i.removed[d.id],c--,p!==d&&(i.updated[d.id]=[p,d],l++)}else i.added[d.id]=d,a++;for(const[d,p]of _t(u.updated))p.typeName===t&&(i.added[p.id]?i.added[p.id]=p:i.updated[p.id]?i.updated[p.id]=[i.updated[p.id][0],p]:(i.updated[p.id]=[d,p],l++));for(const d of _t(u.removed))d.typeName===t&&(i.added[d.id]?(delete i.added[d.id],a--):i.updated[d.id]?(i.removed[d.id]=i.updated[d.id][0],delete i.updated[d.id],l--,c++):(i.removed[d.id]=d,c++))}return a||c||l?sl(this.history.get(),i):r},{historyLength:100});return this.historyCache.set(t,n),n}index(t,n){const r=t+":"+n;if(this.indexCache.has(r))return this.indexCache.get(r);const o=this.__uncached_createIndex(t,n);return this.indexCache.set(r,o),o}__uncached_createIndex(t,n){const r=this.filterHistory(t),o=()=>{r.get();const s=new Map;for(const i of _t(this.atoms.get())){const a=i.get();if(a.typeName===t){const c=a[n];s.has(c)||s.set(c,new Set),s.get(c).add(a.id)}}return s};return G("index:"+t+":"+n,(s,i)=>{if(vi(s))return o();const a=r.getDiffSince(i);if(a===Xn)return o();const c=new Map,l=(f,y)=>{let g=c.get(f);g||(g=new Qd(s.get(f)??new Set)),g.add(y),c.set(f,g)},u=(f,y)=>{let g=c.get(f);g||(g=new Qd(s.get(f)??new Set)),g.remove(y),c.set(f,g)};for(const f of a){for(const y of _t(f.added))if(y.typeName===t){const g=y[n];l(g,y.id)}for(const[y,g]of _t(f.updated))if(g.typeName===t){const w=y[n],S=g[n];w!==S&&(u(w,g.id),l(S,g.id))}for(const y of _t(f.removed))if(y.typeName===t){const g=y[n];u(g,y.id)}}let d,p;for(const[f,y]of c){const g=y.get();g&&(d||(d=new Map(s)),p||(p=new Map),g.value.size===0?d.delete(f):d.set(f,g.value),p.set(f,g.diff))}return d&&p?sl(d,p):s},{historyLength:100})}record(t,n=()=>({}),r="record:"+t+(n?":"+n.toString():"")){const o=this.ids(t,n,r);return G(r,()=>{var s;for(const i of o.get())return(s=this.atoms.get()[i])==null?void 0:s.get()})}records(t,n=()=>({}),r="records:"+t+(n?":"+n.toString():"")){const o=this.ids(t,n,"ids:"+r);return G(r,()=>[...o.get()].map(s=>{const i=this.atoms.get()[s];if(!i)throw new Error("no atom found for record id: "+s);return i.get()}))}ids(t,n=()=>({}),r="ids:"+t+(n?":"+n.toString():"")){const o=this.filterHistory(t),s=()=>{o.get();const c=n();return Object.keys(c).length===0?new Set(_t(this.atoms.get()).flatMap(l=>{const u=l.get();return u.typeName===t?u.id:[]})):rb(this,t,c)},i=c=>{const l=s(),u=sR(c,l);return u?sl(l,u):c},a=G("ids_query:"+r,n,{isEqual:rR});return G("query:"+r,(c,l)=>{const u=a.get();if(vi(c))return s();if(l<a.lastChangedEpoch)return i(c);const d=o.getDiffSince(l);if(d===Xn)return i(c);const p=new Qd(c);for(const y of d){for(const g of _t(y.added))g.typeName===t&&nb(u,g)&&p.add(g.id);for(const[g,w]of _t(y.updated))w.typeName===t&&(nb(u,w)?p.add(w.id):p.remove(w.id));for(const g of _t(y.removed))g.typeName===t&&p.remove(g.id)}const f=p.get();return f?sl(f.value,f.diff):c},{historyLength:50})}exec(t,n){const r=rb(this,t,n);if(r.size===0)return Do;const o=this.atoms.get();return[...r].map(s=>o[s].get())}}class nE{constructor(t){m(this,"id");m(this,"atoms",pn("store_atoms",{}));m(this,"history",pn("history",0,{historyLength:1e3}));m(this,"query",new iR(this.atoms,this.history));m(this,"listeners",new Set);m(this,"historyAccumulator",new cR);m(this,"historyReactor");m(this,"schema");m(this,"props");m(this,"scopedTypes");m(this,"onBeforeCreate");m(this,"onAfterCreate");m(this,"onBeforeChange");m(this,"onAfterChange");m(this,"onBeforeDelete");m(this,"onAfterDelete");m(this,"_runCallbacks",!0);m(this,"put",(t,n)=>{this.atomic(()=>{const r={},o={},s=this.atoms.__unsafe__getWithoutCapture();let i=null,a,c=!1;const l=this.onBeforeCreate&&this._runCallbacks?this.onBeforeCreate:null,u=this.onBeforeChange&&this._runCallbacks?this.onBeforeChange:null,d=this.isMergingRemoteChanges?"remote":"user";for(let p=0,f=t.length;p<f;p++){a=t[p];const y=(i??s)[a.id];if(y){const g=y.__unsafe__getWithoutCapture();if(u&&(a=u(g,a,d)),this.schema.validateRecord(this,a,n??"updateRecord",g)===g)continue;y.set(a),c=!0;const S=y.__unsafe__getWithoutCapture();r[a.id]=[g,S],this.addDiffForAfterEvent(g,S,d)}else l&&(a=l(a,d)),c=!0,a=this.schema.validateRecord(this,a,n??"createRecord",null),o[a.id]=a,this.addDiffForAfterEvent(null,a,d),i||(i={...s}),i[a.id]=pn("atom:"+a.id,a)}i&&this.atoms.set(i),c&&this.updateHistory({added:o,updated:r,removed:{}})})});m(this,"remove",t=>{this.atomic(()=>{const n=[],r=this.isMergingRemoteChanges?"remote":"user";if(this.onBeforeDelete&&this._runCallbacks)for(const s of t){const i=this.atoms.__unsafe__getWithoutCapture()[s];i&&this.onBeforeDelete(i.get(),r)===!1&&n.push(s)}let o;this.atoms.update(s=>{let i;for(const a of t){if(n.includes(a)||!(a in s))continue;i||(i={...s}),o||(o={}),delete i[a];const c=s[a].get();o[a]=c,this.addDiffForAfterEvent(c,null,r)}return i??s}),o&&this.updateHistory({added:{},updated:{},removed:o})})});m(this,"get",t=>{var n;return(n=this.atoms.get()[t])==null?void 0:n.get()});m(this,"unsafeGetWithoutCapture",t=>{var n;return(n=this.atoms.get()[t])==null?void 0:n.__unsafe__getWithoutCapture()});m(this,"serialize",(t="document")=>{const n={};for(const[r,o]of gn(this.atoms.get())){const s=o.get();(t==="all"||this.scopedTypes[t].has(s.typeName))&&(n[r]=s)}return n});m(this,"allRecords",()=>_t(this.atoms.get()).map(t=>t.get()));m(this,"clear",()=>{this.remove(qw(this.atoms.get()))});m(this,"update",(t,n)=>{const r=this.atoms.get()[t];if(!r){console.error(`Record ${t} not found. This is probably an error`);return}this.put([n(r.__unsafe__getWithoutCapture())])});m(this,"has",t=>!!this.atoms.get()[t]);m(this,"listen",(t,n)=>{this._flushHistory();const r={onHistory:t,filters:{source:(n==null?void 0:n.source)??"all",scope:(n==null?void 0:n.scope)??"all"}};return this.listeners.add(r),this.historyReactor.scheduler.isActivelyListening||this.historyReactor.start(),()=>{this.listeners.delete(r),this.listeners.size===0&&this.historyReactor.stop()}});m(this,"isMergingRemoteChanges",!1);m(this,"mergeRemoteChanges",t=>{if(this.isMergingRemoteChanges)return t();try{this.isMergingRemoteChanges=!0,Ro(t)}finally{this.isMergingRemoteChanges=!1}});m(this,"createComputedCache",(t,n,r)=>{const o=new tb;return{get:s=>{const i=this.atoms.get()[s];if(i)return o.get(i,()=>{const a=r?G(i.name+":equals",()=>i.get(),{isEqual:r}):i;return G(t+":"+s,()=>n(a.get()))}).get()}}});m(this,"createSelectedComputedCache",(t,n,r)=>{const o=new tb;return{get:s=>{const i=this.atoms.get()[s];if(!i)return;const a=G(t+":"+s+":selector",()=>n(i.get()));return o.get(i,()=>G(t+":"+s,()=>r(a.get()))).get()}}});m(this,"_integrityChecker");m(this,"_isPossiblyCorrupted",!1);m(this,"pendingAfterEvents",null);m(this,"_isInAtomicOp",!1);const{initialData:n,schema:r,id:o}=t;this.id=o??hf(),this.schema=r,this.props=t.props,n&&this.atoms.set(Kv(gn(n).map(([s,i])=>[s,pn("atom:"+s,this.schema.validateRecord(this,i,"initialize",null))]))),this.historyReactor=vD("Store.historyReactor",()=>{this.history.get(),this._flushHistory()},{scheduleEffect:s=>JI(s)}),this.scopedTypes={document:new Set(_t(this.schema.types).filter(s=>s.scope==="document").map(s=>s.typeName)),session:new Set(_t(this.schema.types).filter(s=>s.scope==="session").map(s=>s.typeName)),presence:new Set(_t(this.schema.types).filter(s=>s.scope==="presence").map(s=>s.typeName))}}_flushHistory(){if(this.historyAccumulator.hasChanges()){const t=this.historyAccumulator.flush();for(const{changes:n,source:r}of t){let o=null,s=null,i=null;for(const{onHistory:a,filters:c}of this.listeners)if(!(c.source!=="all"&&c.source!==r))if(c.scope!=="all")if(c.scope==="document"){if(s??(s=this.filterChangesByScope(n,"document")),!s)continue;a({changes:s,source:r})}else if(c.scope==="session"){if(o??(o=this.filterChangesByScope(n,"session")),!o)continue;a({changes:o,source:r})}else{if(i??(i=this.filterChangesByScope(n,"presence")),!i)continue;a({changes:i,source:r})}else a({changes:n,source:r})}}}filterChangesByScope(t,n){const r={added:_g(t.added,(o,s)=>this.scopedTypes[n].has(s.typeName)),updated:_g(t.updated,(o,s)=>this.scopedTypes[n].has(s[1].typeName)),removed:_g(t.removed,(o,s)=>this.scopedTypes[n].has(s.typeName))};return Object.keys(r.added).length===0&&Object.keys(r.updated).length===0&&Object.keys(r.removed).length===0?null:r}updateHistory(t){this.historyAccumulator.add({changes:t,source:this.isMergingRemoteChanges?"remote":"user"}),this.listeners.size===0&&this.historyAccumulator.clear(),this.history.set(this.history.get()+1,t)}validate(t){this.allRecords().forEach(n=>this.schema.validateRecord(this,n,t,null))}getSnapshot(t="document"){return{store:this.serialize(t),schema:this.schema.serialize()}}migrateSnapshot(t){const n=this.schema.migrateStoreSnapshot(t);if(n.type==="error")throw new Error(`Failed to migrate snapshot: ${n.reason}`);return{store:n.value,schema:this.schema.serialize()}}loadSnapshot(t){const n=this.schema.migrateStoreSnapshot(t);if(n.type==="error")throw new Error(`Failed to migrate snapshot: ${n.reason}`);const r=this._runCallbacks;try{this._runCallbacks=!1,this.atomic(()=>{this.clear(),this.put(Object.values(n.value)),this.ensureStoreIsUsable()})}finally{this._runCallbacks=r}}extractingChanges(t){const n=[],r=this.historyAccumulator.addInterceptor(o=>n.push(o.changes));try{return Ro(t),pf(n)}finally{r()}}applyDiff(t,{runCallbacks:n=!0,ignoreEphemeralKeys:r=!1}={}){this.atomic(()=>{const o=_t(t.added);for(const[i,a]of _t(t.updated)){const c=this.schema.getType(a.typeName);if(r&&c.ephemeralKeySet.size){const l=this.get(a.id);if(!l){o.push(a);continue}let u=null;for(const[d,p]of Object.entries(a))c.ephemeralKeySet.has(d)||Object.is(p,qn(l,d))||(u||(u={...l}),u[d]=p);u&&o.push(u)}else o.push(a)}const s=qw(t.removed);o.length&&this.put(o),s.length&&this.remove(s)},n)}ensureStoreIsUsable(){this.atomic(()=>{var t;this._integrityChecker??(this._integrityChecker=this.schema.createIntegrityChecker(this)),(t=this._integrityChecker)==null||t.call(this)})}markAsPossiblyCorrupted(){this._isPossiblyCorrupted=!0}isPossiblyCorrupted(){return this._isPossiblyCorrupted}addDiffForAfterEvent(t,n,r){if(lt(this.pendingAfterEvents,"must be in event operation"),t===n||(t&&n&<(t.id===n.id),!t&&!n))return;const o=(t||n).id,s=this.pendingAfterEvents.get(o);s?(lt(s.source===r,"source cannot change within a single event operation"),s.after=n):this.pendingAfterEvents.set(o,{before:t,after:n,source:r})}flushAtomicCallbacks(){var n,r,o;let t=0;for(;this.pendingAfterEvents;){const s=this.pendingAfterEvents;if(this.pendingAfterEvents=null,!!this._runCallbacks){if(t++,t>100)throw new Error("Maximum store update depth exceeded, bailing out");for(const{before:i,after:a,source:c}of s.values())i&&a?(n=this.onAfterChange)==null||n.call(this,i,a,c):i&&!a?(r=this.onAfterDelete)==null||r.call(this,i,c):!i&&a&&((o=this.onAfterCreate)==null||o.call(this,a,c))}}}atomic(t,n=!0){return Ro(()=>{if(this._isInAtomicOp)return this.pendingAfterEvents||(this.pendingAfterEvents=new Map),t();this.pendingAfterEvents=new Map;const r=this._runCallbacks;this._runCallbacks=n??r,this._isInAtomicOp=!0;try{const o=t();return this.flushAtomicCallbacks(),o}finally{this.pendingAfterEvents=null,this._runCallbacks=r,this._isInAtomicOp=!1}})}addHistoryInterceptor(t){return this.historyAccumulator.addInterceptor(n=>t(n,this.isMergingRemoteChanges?"remote":"user"))}}function aR(e){if(e.length===0)return[];const t=[];let n=[e[0]],r;for(let o=1,s=e.length;o<s;o++)r=e[o],n[0].source!==r.source&&(t.push(n),n=[]),n.push(r);return t.push(n),t.map(o=>({source:o[0].source,changes:pf(o.map(s=>s.changes))}))}class cR{constructor(){m(this,"_history",[]);m(this,"_interceptors",new Set)}addInterceptor(t){return this._interceptors.add(t),()=>{this._interceptors.delete(t)}}add(t){this._history.push(t);for(const n of this._interceptors)n(t)}flush(){const t=aR(this._history);return this._history=[],t}clear(){this._history=[]}hasChanges(){return this._history.length>0}}function lR(e){const t=[];for(let n=e.length-1;n>=0;n--){const r=e[n];if("id"in r)t.unshift(r);else{const o=r.dependsOn,s=t[0];s&&(t[0]={...s,dependsOn:o.concat(s.dependsOn??[])})}}return t}function gl({sequence:e,sequenceId:t,retroactive:n=!0}){const r={sequenceId:t,retroactive:n,sequence:lR(e)};return rE(r),r}function or(e,t){return Object.fromEntries(gn(t).map(([n,r])=>[n,`${e}/${r}`]))}function Pr(e){const t=e.sequenceId;return gl({sequenceId:t,retroactive:e.retroactive??!0,sequence:e.sequence.map(n=>"id"in n?{...n,scope:"record",filter:r=>{var o,s;return r.typeName===e.recordType&&(((o=n.filter)==null?void 0:o.call(n,r))??!0)&&(((s=e.filter)==null?void 0:s.call(e,r))??!0)}}:n)})}function uR(e){const t=new Map(e.map(s=>[s.id,s])),n=new Set,r=[];function o(s){lt(!n.has(s.id),`Circular dependency in migrations: ${s.id}`),n.add(s.id);const{version:i,sequenceId:a}=rp(s.id),c=t.get(`${a}/${i-1}`);if(c&&o(c),s.dependsOn)for(const l of s.dependsOn){const u=t.get(l);u&&o(u)}t.delete(s.id),r.push(s)}for(const s of t.values())o(s);return r}function rp(e){const[t,n]=e.split("/");return{sequenceId:t,version:parseInt(n)}}function ob(e,t){t&<(e.startsWith(t+"/"),`Every migration in sequence '${t}' must have an id starting with '${t}/'. Got invalid id: '${e}'`),lt(e.match(/^(.*?)\/(0|[1-9]\d*)$/),`Invalid migration id: '${e}'`)}function rE(e){if(lt(!e.sequenceId.includes("/"),`sequenceId cannot contain a '/', got ${e.sequenceId}`),lt(e.sequenceId.length,"sequenceId must be a non-empty string"),e.sequence.length===0)return;ob(e.sequence[0].id,e.sequenceId);let t=rp(e.sequence[0].id).version;lt(t===1,`Expected the first migrationId to be '${e.sequenceId}/1' but got '${e.sequence[0].id}'`);for(let n=1;n<e.sequence.length;n++){const r=e.sequence[n].id;ob(r,e.sequenceId);const o=rp(r).version;lt(o===t+1,`Migration id numbers must increase in increments of 1, expected ${e.sequenceId}/${t+1} but got '${e.sequence[n].id}'`),t=o}}var fs=(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))(fs||{});function dR(e){if(e.schemaVersion>2||e.schemaVersion<1)return Wn.err("Bad schema version");if(e.schemaVersion===2)return Wn.ok(e);const t={schemaVersion:2,sequences:{}};for(const[n,r]of Object.entries(e.recordVersions))if(t.sequences[`com.tldraw.${n}`]=r.version,"subTypeKey"in r)for(const[o,s]of Object.entries(r.subTypeVersions))t.sequences[`com.tldraw.${n}.${o}`]=s;return Wn.ok(t)}class Xv{constructor(t,n){m(this,"migrations",{});m(this,"sortedMigrations");var o;this.types=t,this.options=n;for(const s of n.migrations??[])lt(!this.migrations[s.sequenceId],`Duplicate migration sequenceId ${s.sequenceId}`),rE(s),this.migrations[s.sequenceId]=s;const r=Object.values(this.migrations).flatMap(s=>s.sequence);this.sortedMigrations=uR(r);for(const s of this.sortedMigrations)if((o=s.dependsOn)!=null&&o.length)for(const i of s.dependsOn){const a=r.find(c=>c.id===i);lt(a,`Migration '${s.id}' depends on missing migration '${i}'`)}}static create(t,n){return new Xv(t,n??{})}validateRecord(t,n,r,o){try{const s=qn(this.types,n.typeName);if(!s)throw new Error(`Missing definition for record type ${n.typeName}`);return s.validate(n,o??void 0)}catch(s){if(this.options.onValidationFailure)return this.options.onValidationFailure({store:t,record:n,phase:r,recordBefore:o,error:s});throw s}}getMigrationsSince(t){const n=dR(t);if(!n.ok)return n;const r=n.value,o=new Set(Object.keys(r.sequences).filter(i=>this.migrations[i]));for(const i in this.migrations)r.sequences[i]===void 0&&this.migrations[i].retroactive&&o.add(i);if(o.size===0)return Wn.ok([]);const s=new Set;for(const i of o){const a=r.sequences[i];if(typeof a!="number"&&this.migrations[i].retroactive||a===0){for(const u of this.migrations[i].sequence)s.add(u.id);continue}const c=`${i}/${a}`,l=this.migrations[i].sequence.findIndex(u=>u.id===c);if(l===-1)return Wn.err("Incompatible schema?");for(const u of this.migrations[i].sequence.slice(l+1))s.add(u.id)}return Wn.ok(this.sortedMigrations.filter(({id:i})=>s.has(i)))}migratePersistedRecord(t,n,r="up"){const o=this.getMigrationsSince(n);if(!o.ok)return console.error("Error migrating record",o.error),{type:"error",reason:fs.MigrationError};let s=o.value;if(s.length===0)return{type:"success",value:t};if(s.some(i=>i.scope==="store"))return{type:"error",reason:r==="down"?fs.TargetVersionTooOld:fs.TargetVersionTooNew};if(r==="down"){if(!s.every(i=>i.down))return{type:"error",reason:fs.TargetVersionTooOld};s=s.slice().reverse()}t=Ge(t);try{for(const i of s){if(i.scope==="store")throw new Error;if(!(i.filter?i.filter(t):!0))continue;const c=i[r](t);c&&(t=Ge(c))}}catch(i){return console.error("Error migrating record",i),{type:"error",reason:fs.MigrationError}}return{type:"success",value:t}}migrateStoreSnapshot(t){let{store:n}=t;const r=this.getMigrationsSince(t.schema);if(!r.ok)return console.error("Error migrating store",r.error),{type:"error",reason:fs.MigrationError};const o=r.value;if(o.length===0)return{type:"success",value:n};n=Ge(n);try{for(const s of o)if(s.scope==="record")for(const[i,a]of Object.entries(n)){if(!(s.filter?s.filter(a):!0))continue;const l=s.up(a);l&&(n[i]=Ge(l))}else if(s.scope==="store"){const i=s.up(n);i&&(n=Ge(i))}else fn(s)}catch(s){return console.error("Error migrating store",s),{type:"error",reason:fs.MigrationError}}return{type:"success",value:n}}createIntegrityChecker(t){var n,r;return((r=(n=this.options).createIntegrityChecker)==null?void 0:r.call(n,t))??void 0}serialize(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:t,sequence:n})=>[t,n.length?rp(n.at(-1).id).version:0]))}}serializeEarliestVersion(){return{schemaVersion:2,sequences:Object.fromEntries(Object.values(this.migrations).map(({sequenceId:t})=>[t,0]))}}getType(t){const n=qn(this.types,t);return lt(n,"record type does not exists"),n}}function hR(e){if(!e.length)return null;let t="";for(const n of e)typeof n=="number"?t+=`.${n}`:n.startsWith("(")?t.endsWith(")")?t=`${t.slice(0,-1)}, ${n.slice(1)}`:t+=n:t+=`.${n}`;return t=t.replace(/id = [^,]+, /,"").replace(/id = [^)]+/,""),t.startsWith(".")?t.slice(1):t}class Ie extends Error{constructor(n,r=[]){const o=hR(r),s=n.split(`
|
|
38
|
-
`).map((i,a)=>a===0?i:` ${i}`).join(`
|
|
39
|
-
`);super(r?`At ${o}: ${s}`:s);m(this,"name","ValidationError");this.rawMessage=n,this.path=r}}function $n(e,t){try{return t()}catch(n){throw n instanceof Ie?new Ie(n.rawMessage,[e,...n.path]):new Ie(n.toString(),[e])}}function Fs(e){if(e===null)return"null";if(Array.isArray(e))return"an array";const t=typeof e;switch(t){case"bigint":case"boolean":case"function":case"number":case"string":case"symbol":return`a ${t}`;case"object":return`an ${t}`;case"undefined":return"undefined";default:fn(t)}}class Sn{constructor(t,n){this.validationFn=t,this.validateUsingKnownGoodVersionFn=n}validate(t){return this.validationFn(t)}validateUsingKnownGoodVersion(t,n){return Object.is(t,n)?t:this.validateUsingKnownGoodVersionFn?this.validateUsingKnownGoodVersionFn(t,n):this.validate(n)}isValid(t){try{return this.validate(t),!0}catch{return!1}}nullable(){return SR(this)}optional(){return sE(this)}refine(t){return new Sn(n=>t(this.validate(n)),(n,r)=>{const o=this.validateUsingKnownGoodVersion(n,r);return Object.is(n,o)?n:t(o)})}check(t,n){return typeof t=="string"?this.refine(r=>($n(`(check ${t})`,()=>n(r)),r)):this.refine(r=>(t(r),r))}}class pR extends Sn{constructor(t){super(n=>{const r=sb.validate(n);for(let o=0;o<r.length;o++)$n(o,()=>t.validate(r[o]));return r},(n,r)=>{if(!t.validateUsingKnownGoodVersion)return this.validate(r);const o=sb.validate(r);let s=n.length!==o.length;for(let i=0;i<o.length;i++){const a=o[i];if(i>=n.length){s=!0,$n(i,()=>t.validate(a));continue}if(Object.is(n[i],a))continue;const c=$n(i,()=>t.validateUsingKnownGoodVersion(n[i],a));Object.is(c,n[i])||(s=!0)}return s?r:n}),this.itemValidator=t}nonEmpty(){return this.check(t=>{if(t.length===0)throw new Ie("Expected a non-empty array")})}lengthGreaterThan1(){return this.check(t=>{if(t.length<=1)throw new Ie("Expected an array with length greater than 1")})}}class op extends Sn{constructor(t,n=!1){super(r=>{if(typeof r!="object"||r===null)throw new Ie(`Expected object, got ${Fs(r)}`);for(const[o,s]of Object.entries(t))$n(o,()=>{s.validate(qn(r,o))});if(!n){for(const o of Object.keys(r))if(!no(t,o))throw new Ie("Unexpected property",[o])}return r},(r,o)=>{if(typeof o!="object"||o===null)throw new Ie(`Expected object, got ${Fs(o)}`);let s=!1;for(const[i,a]of Object.entries(t)){const c=qn(r,i),l=qn(o,i);if(Object.is(c,l))continue;const u=$n(i,()=>{const d=a;return d.validateUsingKnownGoodVersion?d.validateUsingKnownGoodVersion(c,l):d.validate(l)});Object.is(u,c)||(s=!0)}if(!n){for(const i of Object.keys(o))if(!no(t,i))throw new Ie("Unexpected property",[i])}for(const i of Object.keys(r))if(!no(o,i)){s=!0;break}return s?o:r}),this.config=t,this.shouldAllowUnknownProperties=n}allowUnknownProperties(){return new op(this.config,!0)}extend(t){return new op({...this.config,...t})}}class ff extends Sn{constructor(t,n,r,o){super(s=>{this.expectObject(s);const{matchingSchema:i,variant:a}=this.getMatchingSchemaAndVariant(s);return i===void 0?this.unknownValueValidation(s,a):$n(`(${t} = ${a})`,()=>i.validate(s))},(s,i)=>{this.expectObject(i),this.expectObject(s);const{matchingSchema:a,variant:c}=this.getMatchingSchemaAndVariant(i);return a===void 0?this.unknownValueValidation(i,c):qn(s,t)!==qn(i,t)?$n(`(${t} = ${c})`,()=>a.validate(i)):$n(`(${t} = ${c})`,()=>a.validateUsingKnownGoodVersion?a.validateUsingKnownGoodVersion(s,i):a.validate(i))}),this.key=t,this.config=n,this.unknownValueValidation=r,this.useNumberKeys=o}expectObject(t){if(typeof t!="object"||t===null)throw new Ie(`Expected an object, got ${Fs(t)}`,[])}getMatchingSchemaAndVariant(t){const n=qn(t,this.key);if(!this.useNumberKeys&&typeof n!="string")throw new Ie(`Expected a string for key "${this.key}", got ${Fs(n)}`);if(this.useNumberKeys&&!Number.isFinite(Number(n)))throw new Ie(`Expected a number for key "${this.key}", got "${n}"`);return{matchingSchema:no(this.config,n)?this.config[n]:void 0,variant:n}}validateUnknownVariants(t){return new ff(this.key,this.config,t,this.useNumberKeys)}}class fR extends Sn{constructor(t,n){super(r=>{if(typeof r!="object"||r===null)throw new Ie(`Expected object, got ${Fs(r)}`);for(const[o,s]of Object.entries(r))$n(o,()=>{t.validate(o),n.validate(s)});return r},(r,o)=>{if(typeof o!="object"||o===null)throw new Ie(`Expected object, got ${Fs(o)}`);let s=!1;for(const[i,a]of Object.entries(o)){if(!no(r,i)){s=!0,$n(i,()=>{t.validate(i),n.validate(a)});continue}const c=qn(r,i),l=a;if(Object.is(c,l))continue;const u=$n(i,()=>n.validateUsingKnownGoodVersion?n.validateUsingKnownGoodVersion(c,l):n.validate(l));Object.is(u,c)||(s=!0)}for(const i of Object.keys(r))if(!no(o,i)){s=!0;break}return s?o:r}),this.keyValidator=t,this.valueValidator=n}}function qv(e){return new Sn(t=>{if(typeof t!==e)throw new Ie(`Expected ${e}, got ${Fs(t)}`);return t})}const gR=new Sn(e=>e),ge=qv("string"),he=qv("number").check(e=>{if(Number.isNaN(e))throw new Ie("Expected a number, got NaN");if(!Number.isFinite(e))throw new Ie(`Expected a finite number, got ${e}`)}),sp=he.check(e=>{if(e<0)throw new Ie(`Expected a positive number, got ${e}`)}),On=he.check(e=>{if(e<=0)throw new Ie(`Expected a non-zero positive number, got ${e}`)}),oE=he.check(e=>{if(!Number.isInteger(e))throw new Ie(`Expected an integer, got ${e}`)}),eh=oE.check(e=>{if(e<0)throw new Ie(`Expected a positive integer, got ${e}`)}),mR=oE.check(e=>{if(e<=0)throw new Ie(`Expected a non-zero positive integer, got ${e}`)}),we=qv("boolean");function an(e){return new Sn(t=>{if(t!==e)throw new Ie(`Expected ${e}, got ${JSON.stringify(t)}`);return e})}const sb=new Sn(e=>{if(!Array.isArray(e))throw new Ie(`Expected an array, got ${Fs(e)}`);return e});function Ut(e){return new pR(e)}function ve(e){return new op(e)}function zy(e){return typeof e=="object"&&e!==null&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null||Object.getPrototypeOf(e)===tR)}function By(e){return e===null||typeof e=="number"||typeof e=="string"||typeof e=="boolean"?!0:Array.isArray(e)?e.every(By):zy(e)?Object.values(e).every(By):!1}const hn=new Sn(e=>{if(By(e))return e;throw new Ie(`Expected json serializable value, got ${typeof e}`)},(e,t)=>{if(Array.isArray(e)&&Array.isArray(t)){let n=e.length!==t.length;for(let r=0;r<t.length;r++){if(r>=e.length){n=!0,hn.validate(t[r]);continue}const o=e[r],s=t[r];if(Object.is(o,s))continue;const i=hn.validateUsingKnownGoodVersion(o,s);Object.is(i,o)||(n=!0)}return n?t:e}else if(zy(e)&&zy(t)){let n=!1;for(const r of Object.keys(t)){if(!no(e,r)){n=!0,hn.validate(t[r]);continue}const o=e[r],s=t[r];if(Object.is(o,s))continue;const i=hn.validateUsingKnownGoodVersion(o,s);Object.is(i,o)||(n=!0)}for(const r of Object.keys(e))if(!no(t,r)){n=!0;break}return n?t:e}else return hn.validate(t)});function ip(e,t){return new fR(e,t)}function Zv(e,t){return new ff(e,t,(n,r)=>{throw new Ie(`Expected one of ${Object.keys(t).map(o=>JSON.stringify(o)).join(" or ")}, got ${JSON.stringify(r)}`,[e])},!1)}function yR(e,t){return new ff(e,t,(n,r)=>{throw new Ie(`Expected one of ${Object.keys(t).map(o=>JSON.stringify(o)).join(" or ")}, got ${JSON.stringify(r)}`,[e])},!0)}function Qo(e,t){return new Sn(n=>$n(e,()=>t.validate(n)),(n,r)=>$n(e,()=>t.validateUsingKnownGoodVersion?t.validateUsingKnownGoodVersion(n,r):t.validate(r)))}function gf(e){return new Sn(t=>{if(!e.has(t)){const n=Array.from(e,r=>JSON.stringify(r)).join(" or ");throw new Ie(`Expected ${n}, got ${t}`)}return t})}function sE(e){return new Sn(t=>{if(t!==void 0)return e.validate(t)},(t,n)=>{if(!(t===void 0&&n===void 0)&&n!==void 0)return e.validateUsingKnownGoodVersion&&t!==void 0?e.validateUsingKnownGoodVersion(t,n):e.validate(n)})}function SR(e){return new Sn(t=>t===null?null:e.validate(t),(t,n)=>n===null?null:e.validateUsingKnownGoodVersion&&t!==null?e.validateUsingKnownGoodVersion(t,n):e.validate(n))}function iE(...e){return gf(new Set(e))}function aE(e){try{return new URL(e)}catch{if(e.startsWith("/")||e.startsWith("./"))try{return new URL(e,"http://example.com")}catch{throw new Ie(`Expected a valid url, got ${JSON.stringify(e)}`)}throw new Ie(`Expected a valid url, got ${JSON.stringify(e)}`)}}const vR=new Set(["http:","https:","mailto:"]),er=ge.check(e=>{if(e==="")return;const t=aE(e);if(!vR.has(t.protocol.toLowerCase()))throw new Ie(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)}),xR=new Set(["http:","https:","data:"]),pc=ge.check(e=>{if(e==="")return;const t=aE(e);if(!xR.has(t.protocol.toLowerCase()))throw new Ie(`Expected a valid url, got ${JSON.stringify(e)} (invalid protocol)`)}),Qv=ge.refine(e=>{try{return WD(e),e}catch{throw new Ie(`Expected an index key, got ${JSON.stringify(e)}`)}});function Sr(e){return ge.refine(t=>{if(!t.startsWith(`${e}:`))throw new Error(`${e} ID must start with "${e}:"`);return t})}const mf=Sr("asset");function Jv(e,t){return ve({id:mf,typeName:an("asset"),type:an(e),props:t,meta:hn})}const wR=Qo("camera",ve({typeName:an("camera"),id:Sr("camera"),x:he,y:he,z:he,meta:hn})),bR=or("com.tldraw.camera",{AddMeta:1}),PR=Pr({sequenceId:"com.tldraw.camera",recordType:"camera",sequence:[{id:bR.AddMeta,up:e=>{e.meta={}}}]}),Rr=Zo("camera",{validator:wR,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,z:1,meta:{}})),jl=ve({x:he,y:he,z:he.optional()}),ml=ve({x:he,y:he,w:he,h:he}),CR=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"]),cE=gf(CR),IR=ve({type:cE,rotation:he}),lE=he.check(e=>{if(e<0||e>1)throw new Ie("Opacity must be between 0 and 1")}),ER=new Set(["accent","white","black","selection-stroke","selection-fill","laser","muted-1"]),_R=gf(ER),kR=new Set(["starting","paused","active","stopping"]),uE=ve({id:ge,points:Ut(jl),size:sp,color:_R,opacity:he,state:gf(kR),delay:he,shrink:he,taper:we}),Ol=Sr("page"),TR=Qo("page",ve({typeName:an("page"),id:Ol,name:ge,index:Qv,meta:hn})),$R=or("com.tldraw.page",{AddMeta:1}),MR=Pr({sequenceId:"com.tldraw.page",recordType:"page",sequence:[{id:$R.AddMeta,up:e=>{e.meta={}}}]}),Bo=Zo("page",{validator:TR,scope:"document"}).withDefaultProperties(()=>({meta:{}}));function Pn(e){return Bo.isId(e)}Sr("instance");function AR(e){const t={};for(const[r,o]of e)t[r]=sE(o);const n=Qo("instance",ve({typeName:an("instance"),id:Sr("instance"),currentPageId:Ol,followingUserId:ge.nullable(),brush:ml.nullable(),opacityForNextShape:lE,stylesForNextShape:ve(t),cursor:IR,scribbles:Ut(uE),isFocusMode:we,isDebugMode:we,isToolLocked:we,exportBackground:we,screenBounds:ml,insets:Ut(we),zoomBrush:ml.nullable(),isPenMode:we,isGridMode:we,chatMessage:ge,isChatting:we,highlightedUserIds:Ut(ge),isFocused:we,devicePixelRatio:he,isCoarsePointer:we,isHoveringCanvas:we.nullable(),openMenus:Ut(ge),isChangingStyle:we,isReadonly:we,meta:hn,duplicateProps:ve({shapeIds:Ut(Sr("shape")),offset:ve({x:he,y:he})}).nullable()}));return Zo("instance",{validator:n,scope:"session",ephemeralKeys:{currentPageId:!1,meta:!1,followingUserId:!0,opacityForNextShape:!0,stylesForNextShape:!0,brush:!0,cursor:!0,scribbles:!0,isFocusMode:!0,isDebugMode:!0,isToolLocked:!0,exportBackground:!0,screenBounds:!0,insets:!0,zoomBrush:!0,isPenMode:!0,isGridMode:!0,chatMessage:!0,isChatting:!0,highlightedUserIds:!0,isFocused:!0,devicePixelRatio:!0,isCoarsePointer:!0,isHoveringCanvas:!0,openMenus:!0,isChangingStyle:!0,isReadonly:!0,duplicateProps:!0}}).withDefaultProperties(()=>({followingUserId:null,opacityForNextShape:1,stylesForNextShape:{},brush:null,scribbles:[],cursor:{type:"default",rotation:0},isFocusMode:!1,exportBackground:!1,isDebugMode:!1,isToolLocked:!1,screenBounds:{x:0,y:0,w:1080,h:720},insets:[!1,!1,!1,!1],zoomBrush:null,isGridMode:!1,isPenMode:!1,chatMessage:"",isChatting:!1,highlightedUserIds:[],isFocused:!1,devicePixelRatio:typeof window>"u"?1:window.devicePixelRatio,isCoarsePointer:!1,isHoveringCanvas:null,openMenus:[],isChangingStyle:!1,isReadonly:!1,meta:{},duplicateProps:null}))}const et=or("com.tldraw.instance",{AddTransparentExportBgs:1,RemoveDialog:2,AddToolLockMode:3,RemoveExtraPropsForNextShape:4,AddLabelColor:5,AddFollowingUserId:6,RemoveAlignJustify:7,AddZoom:8,AddVerticalAlign:9,AddScribbleDelay:10,RemoveUserId:11,AddIsPenModeAndIsGridMode:12,HoistOpacity:13,AddChat:14,AddHighlightedUserIds:15,ReplacePropsForNextShapeWithStylesForNextShape:16,AddMeta:17,RemoveCursorColor:18,AddLonelyProperties:19,ReadOnlyReadonly:20,AddHoveringCanvas:21,AddScribbles:22,AddInset:23,AddDuplicateProps:24,RemoveCanMoveCamera:25}),jR=Pr({sequenceId:"com.tldraw.instance",recordType:"instance",sequence:[{id:et.AddTransparentExportBgs,up:e=>({...e,exportBackground:!0})},{id:et.RemoveDialog,up:({dialog:e,...t})=>t},{id:et.AddToolLockMode,up:e=>({...e,isToolLocked:!1})},{id:et.RemoveExtraPropsForNextShape,up:({propsForNextShape:e,...t})=>({...t,propsForNextShape:Object.fromEntries(Object.entries(e).filter(([n])=>["color","labelColor","dash","fill","size","font","align","verticalAlign","icon","geo","arrowheadStart","arrowheadEnd","spline"].includes(n)))})},{id:et.AddLabelColor,up:({propsForNextShape:e,...t})=>({...t,propsForNextShape:{...e,labelColor:"black"}})},{id:et.AddFollowingUserId,up:e=>({...e,followingUserId:null})},{id:et.RemoveAlignJustify,up:e=>{let t=e.propsForNextShape.align;return t==="justify"&&(t="start"),{...e,propsForNextShape:{...e.propsForNextShape,align:t}}}},{id:et.AddZoom,up:e=>({...e,zoomBrush:null})},{id:et.AddVerticalAlign,up:e=>({...e,propsForNextShape:{...e.propsForNextShape,verticalAlign:"middle"}})},{id:et.AddScribbleDelay,up:e=>e.scribble!==null?{...e,scribble:{...e.scribble,delay:0}}:{...e}},{id:et.RemoveUserId,up:({userId:e,...t})=>t},{id:et.AddIsPenModeAndIsGridMode,up:e=>({...e,isPenMode:!1,isGridMode:!1})},{id:et.HoistOpacity,up:({propsForNextShape:{opacity:e,...t},...n})=>({...n,opacityForNextShape:Number(e??"1"),propsForNextShape:t})},{id:et.AddChat,up:e=>({...e,chatMessage:"",isChatting:!1})},{id:et.AddHighlightedUserIds,up:e=>({...e,highlightedUserIds:[]})},{id:et.ReplacePropsForNextShapeWithStylesForNextShape,up:({propsForNextShape:e,...t})=>({...t,stylesForNextShape:{}})},{id:et.AddMeta,up:e=>({...e,meta:{}})},{id:et.RemoveCursorColor,up:e=>{const{color:t,...n}=e.cursor;return{...e,cursor:n}}},{id:et.AddLonelyProperties,up:e=>({...e,canMoveCamera:!0,isFocused:!1,devicePixelRatio:1,isCoarsePointer:!1,openMenus:[],isChangingStyle:!1,isReadOnly:!1})},{id:et.ReadOnlyReadonly,up:({isReadOnly:e,...t})=>({...t,isReadonly:e})},{id:et.AddHoveringCanvas,up:e=>({...e,isHoveringCanvas:null})},{id:et.AddScribbles,up:({scribble:e,...t})=>({...t,scribbles:[]})},{id:et.AddInset,up:e=>({...e,insets:[!1,!1,!1,!1]}),down:({insets:e,...t})=>({...t})},{id:et.AddDuplicateProps,up:e=>({...e,duplicateProps:null}),down:({duplicateProps:e,...t})=>({...t})},{id:et.RemoveCanMoveCamera,up:({canMoveCamera:e,...t})=>({...t}),down:e=>({...e,canMoveCamera:!0})}]}),tn="instance:instance",OR=ge.refine(e=>{if(!e.startsWith("page:")&&!e.startsWith("shape:"))throw new Error('Parent ID must start with "page:" or "shape:"');return e}),Tr=Sr("shape");function DR(e,t,n){return ve({id:Tr,typeName:an("shape"),x:he,y:he,rotation:he,index:Qv,parentId:OR,type:an(e),isLocked:we,opacity:lE,props:t?ve(t):hn,meta:n?ve(n):hn})}const RR=Qo("instance_page_state",ve({typeName:an("instance_page_state"),id:Sr("instance_page_state"),pageId:Ol,selectedShapeIds:Ut(Tr),hintingShapeIds:Ut(Tr),erasingShapeIds:Ut(Tr),hoveredShapeId:Tr.nullable(),editingShapeId:Tr.nullable(),croppingShapeId:Tr.nullable(),focusedGroupId:Tr.nullable(),meta:hn})),Dc=or("com.tldraw.instance_page_state",{AddCroppingId:1,RemoveInstanceIdAndCameraId:2,AddMeta:3,RenameProperties:4,RenamePropertiesAgain:5}),LR=Pr({sequenceId:"com.tldraw.instance_page_state",recordType:"instance_page_state",sequence:[{id:Dc.AddCroppingId,up(e){e.croppingShapeId=null}},{id:Dc.RemoveInstanceIdAndCameraId,up(e){delete e.instanceId,delete e.cameraId}},{id:Dc.AddMeta,up:e=>{e.meta={}}},{id:Dc.RenameProperties,up:e=>{},down:e=>{}},{id:Dc.RenamePropertiesAgain,up:e=>{e.selectedShapeIds=e.selectedIds,delete e.selectedIds,e.hintingShapeIds=e.hintingIds,delete e.hintingIds,e.erasingShapeIds=e.erasingIds,delete e.erasingIds,e.hoveredShapeId=e.hoveredId,delete e.hoveredId,e.editingShapeId=e.editingId,delete e.editingId,e.croppingShapeId=e.croppingShapeId??e.croppingId??null,delete e.croppingId,e.focusedGroupId=e.focusLayerId,delete e.focusLayerId},down:e=>{e.selectedIds=e.selectedShapeIds,delete e.selectedShapeIds,e.hintingIds=e.hintingShapeIds,delete e.hintingShapeIds,e.erasingIds=e.erasingShapeIds,delete e.erasingShapeIds,e.hoveredId=e.hoveredShapeId,delete e.hoveredShapeId,e.editingId=e.editingShapeId,delete e.editingShapeId,e.croppingId=e.croppingShapeId,delete e.croppingShapeId,e.focusLayerId=e.focusedGroupId,delete e.focusedGroupId}}]}),gr=Zo("instance_page_state",{validator:RR,scope:"session",ephemeralKeys:{pageId:!1,selectedShapeIds:!1,editingShapeId:!1,croppingShapeId:!1,meta:!1,hintingShapeIds:!0,erasingShapeIds:!0,hoveredShapeId:!0,focusedGroupId:!0}}).withDefaultProperties(()=>({editingShapeId:null,croppingShapeId:null,selectedShapeIds:[],hoveredShapeId:null,erasingShapeIds:[],hintingShapeIds:[],focusedGroupId:null,meta:{}})),FR=Qo("pointer",ve({typeName:an("pointer"),id:Sr("pointer"),x:he,y:he,lastActivityTimestamp:he,meta:hn})),NR=or("com.tldraw.pointer",{AddMeta:1}),zR=Pr({sequenceId:"com.tldraw.pointer",recordType:"pointer",sequence:[{id:NR.AddMeta,up:e=>{e.meta={}}}]}),e0=Zo("pointer",{validator:FR,scope:"session"}).withDefaultProperties(()=>({x:0,y:0,lastActivityTimestamp:0,meta:{}})),ap=e0.createId("pointer"),BR=Qo("instance_presence",ve({typeName:an("instance_presence"),id:Sr("instance_presence"),userId:ge,userName:ge,lastActivityTimestamp:he,followingUserId:ge.nullable(),cursor:ve({x:he,y:he,type:cE,rotation:he}),color:ge,camera:ve({x:he,y:he,z:he}),screenBounds:ml,selectedShapeIds:Ut(Sr("shape")),currentPageId:Sr("page"),brush:ml.nullable(),scribbles:Ut(uE),chatMessage:ge,meta:hn})),Rc=or("com.tldraw.instance_presence",{AddScribbleDelay:1,RemoveInstanceId:2,AddChatMessage:3,AddMeta:4,RenameSelectedShapeIds:5}),UR=Pr({sequenceId:"com.tldraw.instance_presence",recordType:"instance_presence",sequence:[{id:Rc.AddScribbleDelay,up:e=>{e.scribble!==null&&(e.scribble.delay=0)}},{id:Rc.RemoveInstanceId,up:e=>{delete e.instanceId}},{id:Rc.AddChatMessage,up:e=>{e.chatMessage=""}},{id:Rc.AddMeta,up:e=>{e.meta={}}},{id:Rc.RenameSelectedShapeIds,up:e=>{}}]}),HR=Zo("instance_presence",{validator:BR,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:{}})),KR=Qo("document",ve({typeName:an("document"),id:an("document:document"),gridSize:he,name:ge,meta:hn})),ib=or("com.tldraw.document",{AddName:1,AddMeta:2}),WR=Pr({sequenceId:"com.tldraw.document",recordType:"document",sequence:[{id:ib.AddName,up:e=>{e.name=""},down:e=>{delete e.name}},{id:ib.AddMeta,up:e=>{e.meta={}}}]}),t0=Zo("document",{validator:KR,scope:"document"}).withDefaultProperties(()=>({gridSize:10,name:"",meta:{}})),Uy=t0.createId("document");function GR(e,t){return e.index<t.index?-1:e.index>t.index?1:0}function ab(e){e.typeName==="asset"&&("src"in e&&(e.src="<redacted>"),"src"in e.props&&(e.props.src="<redacted>"))}const VR=({error:e,phase:t,record:n,recordBefore:r})=>{throw Hv(e,{tags:{origin:"store.validateRecord",storePhase:t,isExistingValidationIssue:t==="initialize"},extras:{recordBefore:r?ab(Ge(r)):void 0,recordAfter:ab(Ge(n))}}),e};function YR(){return[Bo.create({id:"page:page",name:"Page 1",index:"a1",meta:{}})]}function XR(e){const t=e.query.ids("page"),n=()=>{if(!e.has(Uy))return e.put([t0.create({id:Uy,name:e.props.defaultName})]),n();if(!e.has(ap))return e.put([e0.create({id:ap})]),n();const r=t.get();if(r.size===0)return e.put(YR()),n();const o=()=>[...r].map(c=>e.get(c)).sort(GR)[0].id,s=e.get(tn);if(s){if(!r.has(s.currentPageId))return e.put([{...s,currentPageId:o()}]),n()}else return e.put([e.schema.types.instance.create({id:tn,currentPageId:o(),exportBackground:!0})]),n();const i=new Set,a=new Set;for(const c of r){const l=gr.createId(c);e.has(l)||i.add(l);const u=Rr.createId(c);e.has(u)||a.add(u)}i.size>0&&e.put([...i].map(c=>gr.create({id:c,pageId:gr.parseId(c)}))),a.size>0&&e.put([...a].map(c=>Rr.create({id:c})))};return n}const qR=Jv("bookmark",ve({title:ge,description:ge,image:ge,src:pc.nullable()})),ZR=or("com.tldraw.asset.bookmark",{MakeUrlsValid:1}),QR=Pr({sequenceId:"com.tldraw.asset.bookmark",recordType:"asset",filter:e=>e.type==="bookmark",sequence:[{id:ZR.MakeUrlsValid,up:e=>{pc.isValid(e.props.src)||(e.props.src="")},down:e=>{}}]}),JR=Jv("image",ve({w:he,h:he,name:ge,isAnimated:we,mimeType:ge.nullable(),src:pc.nullable()})),$g=or("com.tldraw.asset.image",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3}),e3=Pr({sequenceId:"com.tldraw.asset.image",recordType:"asset",filter:e=>e.type==="image",sequence:[{id:$g.AddIsAnimated,up:e=>{e.props.isAnimated=!1},down:e=>{delete e.props.isAnimated}},{id:$g.RenameWidthHeight,up:e=>{e.props.w=e.props.width,e.props.h=e.props.height,delete e.props.width,delete e.props.height},down:e=>{e.props.width=e.props.w,e.props.height=e.props.h,delete e.props.w,delete e.props.h}},{id:$g.MakeUrlsValid,up:e=>{pc.isValid(e.props.src)||(e.props.src="")},down:e=>{}}]}),t3=Jv("video",ve({w:he,h:he,name:ge,isAnimated:we,mimeType:ge.nullable(),src:pc.nullable()})),Mg=or("com.tldraw.asset.video",{AddIsAnimated:1,RenameWidthHeight:2,MakeUrlsValid:3}),n3=Pr({sequenceId:"com.tldraw.asset.video",recordType:"asset",filter:e=>e.type==="video",sequence:[{id:Mg.AddIsAnimated,up:e=>{e.props.isAnimated=!1},down:e=>{delete e.props.isAnimated}},{id:Mg.RenameWidthHeight,up:e=>{e.props.w=e.props.width,e.props.h=e.props.height,delete e.props.width,delete e.props.height},down:e=>{e.props.width=e.props.w,e.props.height=e.props.h,delete e.props.w,delete e.props.h}},{id:Mg.MakeUrlsValid,up:e=>{pc.isValid(e.props.src)||(e.props.src="")},down:e=>{}}]}),r3=Qo("asset",Zv("type",{image:JR,video:t3,bookmark:qR})),o3=or("com.tldraw.asset",{AddMeta:1}),s3=Pr({sequenceId:"com.tldraw.asset",recordType:"asset",sequence:[{id:o3.AddMeta,up:e=>{e.meta={}}}]}),pi=Zo("asset",{validator:r3,scope:"document"}).withDefaultProperties(()=>({meta:{}}));class Yt{constructor(t,n,r){this.id=t,this.defaultValue=n,this.type=r}static define(t,n){const{defaultValue:r,type:o=gR}=n;return new Yt(t,r,o)}static defineEnum(t,n){const{defaultValue:r,values:o}=n;return new i3(t,r,o)}validate(t){return this.type.validate(t)}validateUsingKnownGoodVersion(t,n){return this.type.validateUsingKnownGoodVersion?this.type.validateUsingKnownGoodVersion(t,n):this.validate(n)}}class i3 extends Yt{constructor(t,n,r){super(t,n,iE(...r)),this.values=r}}const Xu=or("com.tldraw.shape",{AddIsLocked:1,HoistOpacity:2,AddMeta:3,AddWhite:4}),a3=Pr({sequenceId:"com.tldraw.shape",recordType:"shape",sequence:[{id:Xu.AddIsLocked,up:e=>{e.isLocked=!1},down:e=>{delete e.isLocked}},{id:Xu.HoistOpacity,up:e=>{e.opacity=Number(e.props.opacity??"1"),delete e.props.opacity},down:e=>{const t=e.opacity;delete e.opacity,e.props.opacity=t<.175?"0.1":t<.375?"0.25":t<.625?"0.5":t<.875?"0.75":"1"}},{id:Xu.AddMeta,up:e=>{e.meta={}}},{id:Xu.AddWhite,up:e=>{},down:e=>{e.props.color==="white"&&(e.props.color="black")}}]});function ga(e){return e?e.typeName==="shape":!1}function Hn(e){return e?e.startsWith("shape:"):!1}function He(e){return`shape:${e??hf()}`}function dE(e){const t=new Map;for(const[n,r]of Object.entries(e))if(r instanceof Yt){if(t.has(r))throw new Error(`Duplicate style prop ${r.id}. Each style prop can only be used once within a shape.`);t.set(r,n)}return t}const St="retired";function mo(e,t){return df(t,(n,r)=>`com.tldraw.shape.${e}/${r}`)}function c3(e){const t=[];for(const[n,{migrations:r}]of Object.entries(e)){const o=`com.tldraw.shape.${n}`;r?"sequenceId"in r?(lt(o===r.sequenceId,`sequenceId mismatch for ${n} shape migrations. Expected '${o}', got '${r.sequenceId}'`),t.push(r)):"sequence"in r?t.push(gl({sequenceId:o,retroactive:!1,sequence:r.sequence.map(s=>"id"in s?{id:s.id,scope:"record",filter:i=>i.typeName==="shape"&&i.type===n,dependsOn:s.dependsOn,up:i=>{const a=s.up(i.props);a&&(i.props=a)},down:typeof s.down=="function"?i=>{const a=s.down(i.props);a&&(i.props=a)}:void 0}:s)})):t.push(gl({sequenceId:o,retroactive:!1,sequence:Object.keys(r.migrators).map(s=>Number(s)).sort((s,i)=>s-i).map(s=>({id:`${o}/${s}`,scope:"record",filter:i=>i.typeName==="shape"&&i.type===n,up:i=>{const a=r.migrators[s].up(i);if(a)return a},down:i=>{const a=r.migrators[s].down(i);if(a)return a}}))})):t.push(gl({sequenceId:o,retroactive:!1,sequence:[]}))}return t}function l3(e){return Zo("shape",{scope:"document",validator:Qo("shape",Zv("type",df(e,(t,{props:n,meta:r})=>DR(t,n,r))))}).withDefaultProperties(()=>({x:0,y:0,rotation:0,isLocked:!1,opacity:1,meta:{}}))}const hE=["black","grey","light-violet","violet","blue","light-blue","yellow","orange","green","light-green","light-red","red","white"],cp={lightMode:{id:"light",text:"#000000",background:"rgb(249, 250, 251)",solid:"#fcfffe",black:{solid:"#1d1d1d",note:{fill:"#FCE19C",text:"#000000"},semi:"#e8e8e8",pattern:"#494949",highlight:{srgb:"#fddd00",p3:"color(display-p3 0.972 0.8705 0.05)"}},blue:{solid:"#4465e9",note:{fill:"#8AA3FF",text:"#000000"},semi:"#dce1f8",pattern:"#6681ee",highlight:{srgb:"#10acff",p3:"color(display-p3 0.308 0.6632 0.9996)"}},green:{solid:"#099268",note:{fill:"#6FC896",text:"#000000"},semi:"#d3e9e3",pattern:"#39a785",highlight:{srgb:"#00ffc8",p3:"color(display-p3 0.2536 0.984 0.7981)"}},grey:{solid:"#9fa8b2",note:{fill:"#C0CAD3",text:"#000000"},semi:"#eceef0",pattern:"#bcc3c9",highlight:{srgb:"#cbe7f1",p3:"color(display-p3 0.8163 0.9023 0.9416)"}},"light-blue":{solid:"#4ba1f1",note:{fill:"#9BC4FD",text:"#000000"},semi:"#ddedfa",pattern:"#6fbbf8",highlight:{srgb:"#00f4ff",p3:"color(display-p3 0.1512 0.9414 0.9996)"}},"light-green":{solid:"#4cb05e",note:{fill:"#98D08A",text:"#000000"},semi:"#dbf0e0",pattern:"#65cb78",highlight:{srgb:"#65f641",p3:"color(display-p3 0.563 0.9495 0.3857)"}},"light-red":{solid:"#f87777",note:{fill:"#F7A5A1",text:"#000000"},semi:"#f4dadb",pattern:"#fe9e9e",highlight:{srgb:"#ff7fa3",p3:"color(display-p3 0.9988 0.5301 0.6397)"}},"light-violet":{solid:"#e085f4",note:{fill:"#DFB0F9",text:"#000000"},semi:"#f5eafa",pattern:"#e9acf8",highlight:{srgb:"#ff88ff",p3:"color(display-p3 0.9676 0.5652 0.9999)"}},orange:{solid:"#e16919",note:{fill:"#FAA475",text:"#000000"},semi:"#f8e2d4",pattern:"#f78438",highlight:{srgb:"#ffa500",p3:"color(display-p3 0.9988 0.6905 0.266)"}},red:{solid:"#e03131",note:{fill:"#FC8282",text:"#000000"},semi:"#f4dadb",pattern:"#e55959",highlight:{srgb:"#ff636e",p3:"color(display-p3 0.9992 0.4376 0.45)"}},violet:{solid:"#ae3ec9",note:{fill:"#DB91FD",text:"#000000"},semi:"#ecdcf2",pattern:"#bd63d3",highlight:{srgb:"#c77cff",p3:"color(display-p3 0.7469 0.5089 0.9995)"}},yellow:{solid:"#f1ac4b",note:{fill:"#FED49A",text:"#000000"},semi:"#f9f0e6",pattern:"#fecb92",highlight:{srgb:"#fddd00",p3:"color(display-p3 0.972 0.8705 0.05)"}},white:{solid:"#FFFFFF",semi:"#f5f5f5",pattern:"#f9f9f9",note:{fill:"#FFFFFF",text:"#000000"},highlight:{srgb:"#ffffff",p3:"color(display-p3 1 1 1)"}}},darkMode:{id:"dark",text:"hsl(210, 17%, 98%)",background:"hsl(240, 5%, 6.5%)",solid:"#010403",black:{solid:"#f2f2f2",note:{fill:"#2c2c2c",text:"#f2f2f2"},semi:"#2c3036",pattern:"#989898",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.7225 0.0312)"}},blue:{solid:"#4f72fc",note:{fill:"#2A3F98",text:"#f2f2f2"},semi:"#262d40",pattern:"#3a4b9e",highlight:{srgb:"#0079d2",p3:"color(display-p3 0.0032 0.4655 0.7991)"}},green:{solid:"#099268",note:{fill:"#014429",text:"#f2f2f2"},semi:"#253231",pattern:"#366a53",highlight:{srgb:"#009774",p3:"color(display-p3 0.0085 0.582 0.4604)"}},grey:{solid:"#9398b0",note:{fill:"#56595F",text:"#f2f2f2"},semi:"#33373c",pattern:"#7c8187",highlight:{srgb:"#9cb4cb",p3:"color(display-p3 0.6299 0.7012 0.7856)"}},"light-blue":{solid:"#4dabf7",note:{fill:"#1F5495",text:"#f2f2f2"},semi:"#2a3642",pattern:"#4d7aa9",highlight:{srgb:"#00bdc8",p3:"color(display-p3 0.0023 0.7259 0.7735)"}},"light-green":{solid:"#40c057",note:{fill:"#21581D",text:"#f2f2f2"},semi:"#2a3830",pattern:"#4e874e",highlight:{srgb:"#00a000",p3:"color(display-p3 0.2711 0.6172 0.0195)"}},"light-red":{solid:"#ff8787",note:{fill:"#923632",text:"#f2f2f2"},semi:"#3b3235",pattern:"#a56767",highlight:{srgb:"#db005b",p3:"color(display-p3 0.7849 0.0585 0.3589)"}},"light-violet":{solid:"#e599f7",note:{fill:"#762F8E",text:"#f2f2f2"},semi:"#383442",pattern:"#9770a9",highlight:{srgb:"#c400c7",p3:"color(display-p3 0.7024 0.0403 0.753)"}},orange:{solid:"#f76707",note:{fill:"#843906",text:"#f2f2f2"},semi:"#3a2e2a",pattern:"#9f552d",highlight:{srgb:"#d07a00",p3:"color(display-p3 0.7699 0.4937 0.0085)"}},red:{solid:"#e03131",note:{fill:"#89231A",text:"#f2f2f2"},semi:"#36292b",pattern:"#8f3734",highlight:{srgb:"#de002c",p3:"color(display-p3 0.7978 0.0509 0.2035)"}},violet:{solid:"#ae3ec9",note:{fill:"#681683",text:"#f2f2f2"},semi:"#31293c",pattern:"#763a8b",highlight:{srgb:"#9e00ee",p3:"color(display-p3 0.5651 0.0079 0.8986)"}},yellow:{solid:"#ffc034",note:{fill:"#98571B",text:"#f2f2f2"},semi:"#3c3934",pattern:"#fecb92",highlight:{srgb:"#d2b700",p3:"color(display-p3 0.8078 0.7225 0.0312)"}},white:{solid:"#f3f3f3",semi:"#f5f5f5",pattern:"#f9f9f9",note:{fill:"#eaeaea",text:"#1d1d1d"},highlight:{srgb:"#ffffff",p3:"color(display-p3 1 1 1)"}}}};function Jo(e){return e.isDarkMode?cp.darkMode:cp.lightMode}const tr=Yt.defineEnum("tldraw:color",{defaultValue:"black",values:hE}),pE=Yt.defineEnum("tldraw:labelColor",{defaultValue:"black",values:hE}),bi=Yt.defineEnum("tldraw:dash",{defaultValue:"draw",values:["draw","solid","dashed","dotted"]}),Ya=Yt.defineEnum("tldraw:fill",{defaultValue:"none",values:["none","semi","solid","pattern"]}),co=Yt.defineEnum("tldraw:font",{defaultValue:"draw",values:["draw","sans","serif","mono"]}),fE={draw:"'tldraw_draw', sans-serif",sans:"'tldraw_sans', sans-serif",serif:"'tldraw_serif', serif",mono:"'tldraw_mono', monospace"},lo=Yt.defineEnum("tldraw:size",{defaultValue:"m",values:["s","m","l","xl"]}),gE=["arrow","triangle","square","dot","pipe","diamond","inverted","bar","none"],lp=Yt.defineEnum("tldraw:arrowheadStart",{defaultValue:"none",values:gE}),up=Yt.defineEnum("tldraw:arrowheadEnd",{defaultValue:"arrow",values:gE}),cb=Zv("type",{binding:ve({type:an("binding"),boundShapeId:Tr,normalizedAnchor:jl,isExact:we,isPrecise:we}),point:ve({type:an("point"),x:he,y:he})}),mE={labelColor:pE,color:tr,fill:Ya,dash:bi,size:lo,arrowheadStart:lp,arrowheadEnd:up,font:co,start:cb,end:cb,bend:he,text:ge,labelPosition:he},Ag=mo("arrow",{AddLabelColor:1,AddIsPrecise:2,AddLabelPosition:3}),yE={sequence:[{id:Ag.AddLabelColor,up:e=>{e.labelColor="black"},down:St},{id:Ag.AddIsPrecise,up:({start:e,end:t})=>{e.type==="binding"&&(e.isPrecise=!(e.normalizedAnchor.x===.5&&e.normalizedAnchor.y===.5)),t.type==="binding"&&(t.isPrecise=!(t.normalizedAnchor.x===.5&&t.normalizedAnchor.y===.5))},down:({start:e,end:t})=>{e.type==="binding"&&(e.isPrecise||(e.normalizedAnchor={x:.5,y:.5}),delete e.isPrecise),t.type==="binding"&&(t.isPrecise||(t.normalizedAnchor={x:.5,y:.5}),delete t.isPrecise)}},{id:Ag.AddLabelPosition,up:e=>{e.labelPosition=.5},down:e=>{delete e.labelPosition}}]},SE={w:On,h:On,assetId:mf.nullable(),url:er},lb=mo("bookmark",{NullAssetId:1,MakeUrlsValid:2}),vE={sequence:[{id:lb.NullAssetId,up:e=>{e.assetId===void 0&&(e.assetId=null)},down:St},{id:lb.MakeUrlsValid,up:e=>{er.isValid(e.url)||(e.url="")},down:e=>{}}]},xE=ve({type:iE("free","straight"),points:Ut(jl)}),wE={color:tr,fill:Ya,dash:bi,size:lo,segments:Ut(xE),isComplete:we,isClosed:we,isPen:we},u3=mo("draw",{AddInPen:1}),bE={sequence:[{id:u3.AddInPen,up:e=>{const{points:t}=e.segments[0];if(t.length===0){e.isPen=!1;return}let n=!(t[0].z===0||t[0].z===.5);t[1]&&(n=n&&!(t[1].z===0||t[1].z===.5)),e.isPen=n},down:St}]};var d3={};const ub=/(^\/r\/[^/]+\/?$)/,Oe=e=>{try{return new URL(e)}catch{return}},Su=[{type:"tldraw",title:"tldraw",hostnames:["beta.tldraw.com","tldraw.com","localhost:3000"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,overridePermissions:{"allow-top-navigation":!0},toEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(ub))return e},fromEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(ub))return e}},{type:"figma",title:"Figma",hostnames:["figma.com"],width:720,height:500,doesResize:!0,toEmbedUrl:e=>{if(e.match(/https:\/\/([\w\.-]+\.)?figma.com\/(file|proto)\/([0-9a-zA-Z]{22,128})(?:\/.*)?$/)&&!e.includes("figma.com/embed"))return`https://www.figma.com/embed?embed_host=share&url=${e}`},fromEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(/^\/embed\/?$/)){const n=t.searchParams.get("url");if(n)return n}}},{type:"google_maps",title:"Google Maps",hostnames:["google.*"],width:720,height:500,doesResize:!0,overridePermissions:{"allow-presentation":!0},toEmbedUrl:e=>{if(e.includes("/maps/")){const t=e.match(/@(.*),(.*),(.*)z/);let n;if(t){const[,r,o,s]=t;n=`https://${new URL(e).host.replace("www.","")}/maps/embed/v1/view?key=${d3.NEXT_PUBLIC_GC_API_KEY}¢er=${r},${o}&zoom=${s}`}else n="";return n}},fromEmbedUrl:e=>{const t=Oe(e);if(!t)return;if(t.pathname.match(/^\/maps\/embed\/v1\/view\/?$/)&&t.searchParams.has("center")&&t.searchParams.get("zoom")){const r=t.searchParams.get("zoom"),[o,s]=t.searchParams.get("center").split(",");return`https://www.google.com/maps/@${o},${s},${r}z`}}},{type:"val_town",title:"Val Town",hostnames:["val.town"],minWidth:260,minHeight:100,width:720,height:500,doesResize:!0,toEmbedUrl:e=>{const t=Oe(e),n=t&&t.pathname.match(/\/v\/(.+)\/?/);if(n)return`https://www.val.town/embed/${n[1]}`},fromEmbedUrl:e=>{const t=Oe(e),n=t&&t.pathname.match(/\/embed\/(.+)\/?/);if(n)return`https://www.val.town/v/${n[1]}`}},{type:"codesandbox",title:"CodeSandbox",hostnames:["codesandbox.io"],minWidth:300,minHeight:300,width:720,height:500,doesResize:!0,toEmbedUrl:e=>{const t=Oe(e),n=t&&t.pathname.match(/\/s\/([^/]+)\/?/);if(n)return`https://codesandbox.io/embed/${n[1]}`},fromEmbedUrl:e=>{const t=Oe(e),n=t&&t.pathname.match(/\/embed\/([^/]+)\/?/);if(n)return`https://codesandbox.io/s/${n[1]}`}},{type:"codepen",title:"Codepen",hostnames:["codepen.io"],minWidth:300,minHeight:300,width:520,height:400,doesResize:!0,toEmbedUrl:e=>{const t=/https:\/\/codepen.io\/([^/]+)\/pen\/([^/]+)/,n=e.match(t);if(n){const[r,o,s]=n;return`https://codepen.io/${o}/embed/${s}`}},fromEmbedUrl:e=>{const t=/https:\/\/codepen.io\/([^/]+)\/embed\/([^/]+)/,n=e.match(t);if(n){const[r,o,s]=n;return`https://codepen.io/${o}/pen/${s}`}}},{type:"scratch",title:"Scratch",hostnames:["scratch.mit.edu"],width:520,height:400,doesResize:!1,toEmbedUrl:e=>{const t=/https?:\/\/scratch.mit.edu\/projects\/([^/]+)/,n=e.match(t);if(n){const[r,o]=n;return`https://scratch.mit.edu/projects/embed/${o}`}},fromEmbedUrl:e=>{const t=/https:\/\/scratch.mit.edu\/projects\/embed\/([^/]+)/,n=e.match(t);if(n){const[r,o]=n;return`https://scratch.mit.edu/projects/${o}`}}},{type:"youtube",title:"YouTube",hostnames:["*.youtube.com","youtube.com","youtu.be"],width:800,height:450,doesResize:!0,overridePermissions:{"allow-presentation":!0,"allow-popups-to-escape-sandbox":!0},isAspectRatioLocked:!0,toEmbedUrl:e=>{const t=Oe(e);if(!t)return;const n=t.hostname.replace(/^www./,"");if(n==="youtu.be")return`https://www.youtube.com/embed/${t.pathname.split("/").filter(Boolean)[0]}`;if((n==="youtube.com"||n==="m.youtube.com")&&t.pathname.match(/^\/watch/))return`https://www.youtube.com/embed/${t.searchParams.get("v")}`},fromEmbedUrl:e=>{const t=Oe(e);if(!t)return;if(t.hostname.replace(/^www./,"")==="youtube.com"){const r=t.pathname.match(/^\/embed\/([^/]+)\/?/);if(r)return`https://www.youtube.com/watch?v=${r[1]}`}}},{type:"google_calendar",title:"Google Calendar",hostnames:["calendar.google.*"],width:720,height:500,minWidth:460,minHeight:360,doesResize:!0,instructionLink:"https://support.google.com/calendar/answer/41207?hl=en",overridePermissions:{"allow-popups-to-escape-sandbox":!0},toEmbedUrl:e=>{const t=Oe(e),n=t==null?void 0:t.searchParams.get("cid");if(t!=null&&t.pathname.match(/\/calendar\/u\/0/)&&n){t.pathname="/calendar/embed";const r=Array.from(t.searchParams.keys());for(const o of r)t.searchParams.delete(o);return t.searchParams.set("src",n),t.href}},fromEmbedUrl:e=>{const t=Oe(e),n=t==null?void 0:t.searchParams.get("src");if(t!=null&&t.pathname.match(/\/calendar\/embed/)&&n){t.pathname="/calendar/u/0";const r=Array.from(t.searchParams.keys());for(const o of r)t.searchParams.delete(o);return t.searchParams.set("cid",n),t.href}}},{type:"google_slides",title:"Google Slides",hostnames:["docs.google.*"],width:720,height:500,minWidth:460,minHeight:360,doesResize:!0,overridePermissions:{"allow-popups-to-escape-sandbox":!0},toEmbedUrl:e=>{const t=Oe(e);if(t!=null&&t.pathname.match(/^\/presentation/)&&(t!=null&&t.pathname.match(/\/pub\/?$/))){t.pathname=t.pathname.replace(/\/pub$/,"/embed");const n=Array.from(t.searchParams.keys());for(const r of n)t.searchParams.delete(r);return t.href}},fromEmbedUrl:e=>{const t=Oe(e);if(t!=null&&t.pathname.match(/^\/presentation/)&&(t!=null&&t.pathname.match(/\/embed\/?$/))){t.pathname=t.pathname.replace(/\/embed$/,"/pub");const n=Array.from(t.searchParams.keys());for(const r of n)t.searchParams.delete(r);return t.href}}},{type:"github_gist",title:"GitHub Gist",hostnames:["gist.github.com"],width:720,height:500,doesResize:!0,toEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(/\/([^/]+)\/([^/]+)/))return e.split("/").pop()?e:void 0},fromEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(/\/([^/]+)\/([^/]+)/))return e.split("/").pop()?e:void 0}},{type:"replit",title:"Replit",hostnames:["replit.com"],width:720,height:500,doesResize:!0,toEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(/\/@([^/]+)\/([^/]+)/))return`${e}?embed=true`},fromEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(/\/@([^/]+)\/([^/]+)/)&&t.searchParams.has("embed"))return t.searchParams.delete("embed"),t.href}},{type:"felt",title:"Felt",hostnames:["felt.com"],width:720,height:500,doesResize:!0,toEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(/^\/map\//))return t.origin+"/embed"+t.pathname},fromEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(/^\/embed\/map\//))return t.pathname=t.pathname.replace(/^\/embed/,""),t.href}},{type:"spotify",title:"Spotify",hostnames:["open.spotify.com"],width:720,height:500,minHeight:500,overrideOutlineRadius:12,doesResize:!0,toEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(/^\/(artist|album)\//))return t.origin+"/embed"+t.pathname},fromEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(/^\/embed\/(artist|album)\//))return t.origin+t.pathname.replace(/^\/embed/,"")}},{type:"vimeo",title:"Vimeo",hostnames:["vimeo.com","player.vimeo.com"],width:640,height:360,doesResize:!0,isAspectRatioLocked:!0,toEmbedUrl:e=>{const t=Oe(e);if(t&&t.hostname==="vimeo.com"&&t.pathname.match(/^\/[0-9]+/))return"https://player.vimeo.com/video/"+t.pathname.split("/")[1]+"?title=0&byline=0"},fromEmbedUrl:e=>{const t=Oe(e);if(t&&t.hostname==="player.vimeo.com"){const n=t.pathname.match(/^\/video\/([^/]+)\/?$/);if(n)return"https://vimeo.com/"+n[1]}}},{type:"excalidraw",title:"Excalidraw",hostnames:["excalidraw.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!0,toEmbedUrl:e=>{const t=Oe(e);if(t&&t.hash.match(/#room=/))return e},fromEmbedUrl:e=>{const t=Oe(e);if(t&&t.hash.match(/#room=/))return e}},{type:"observable",title:"Observable",hostnames:["observablehq.com"],width:720,height:500,doesResize:!0,isAspectRatioLocked:!1,backgroundColor:"#fff",toEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(/^\/@([^/]+)\/([^/]+)\/?$/))return`${t.origin}/embed${t.pathname}?cell=*`;if(t&&t.pathname.match(/^\/d\/([^/]+)\/?$/)){const n=t.pathname.replace(/^\/d/,"");return`${t.origin}/embed${n}?cell=*`}},fromEmbedUrl:e=>{const t=Oe(e);if(t&&t.pathname.match(/^\/embed\/@([^/]+)\/([^/]+)\/?$/))return`${t.origin}${t.pathname.replace("/embed","")}#cell-*`;if(t&&t.pathname.match(/^\/embed\/([^/]+)\/?$/))return`${t.origin}${t.pathname.replace("/embed","/d")}#cell-*`}},{type:"desmos",title:"Desmos",hostnames:["desmos.com"],width:700,height:450,doesResize:!0,toEmbedUrl:e=>{const t=Oe(e);if(t&&t.hostname==="www.desmos.com"&&t.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&t.search===""&&t.hash==="")return`${e}?embed`},fromEmbedUrl:e=>{const t=Oe(e);if(t&&t.hostname==="www.desmos.com"&&t.pathname.match(/^\/calculator\/([^/]+)\/?$/)&&t.search==="?embed"&&t.hash==="")return e.replace("?embed","")}}],h3={"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},PE={w:On,h:On,url:ge},qu=mo("embed",{GenOriginalUrlInEmbed:1,RemoveDoesResize:2,RemoveTmpOldUrl:3,RemovePermissionOverrides:4}),CE={sequence:[{id:qu.GenOriginalUrlInEmbed,up:e=>{try{const t=e.url,n=new URL(t).host.replace("www.","");let r;for(const o of Su)if(o.hostnames.includes(n))try{r=o.fromEmbedUrl(t)}catch(s){console.warn(s)}e.tmpOldUrl=e.url,e.url=r??""}catch{e.url="",e.tmpOldUrl=e.url}},down:St},{id:qu.RemoveDoesResize,up:e=>{delete e.doesResize},down:St},{id:qu.RemoveTmpOldUrl,up:e=>{delete e.tmpOldUrl},down:St},{id:qu.RemovePermissionOverrides,up:e=>{delete e.overridePermissions},down:St}]},IE={w:On,h:On,name:ge},EE={sequence:[]},dp=Yt.defineEnum("tldraw:horizontalAlign",{defaultValue:"middle",values:["start","middle","end","start-legacy","end-legacy","middle-legacy"]}),hp=Yt.defineEnum("tldraw:verticalAlign",{defaultValue:"middle",values:["start","middle","end"]}),ro=Yt.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"]}),_E={geo:ro,labelColor:pE,color:tr,fill:Ya,dash:bi,size:lo,font:co,align:dp,verticalAlign:hp,url:er,w:On,h:On,growY:sp,text:ge},us=mo("geo",{AddUrlProp:1,AddLabelColor:2,RemoveJustify:3,AddCheckBox:4,AddVerticalAlign:5,MigrateLegacyAlign:6,AddCloud:7,MakeUrlsValid:8}),kE={sequence:[{id:us.AddUrlProp,up:e=>{e.url=""},down:St},{id:us.AddLabelColor,up:e=>{e.labelColor="black"},down:St},{id:us.RemoveJustify,up:e=>{e.align==="justify"&&(e.align="start")},down:St},{id:us.AddCheckBox,up:e=>{},down:St},{id:us.AddVerticalAlign,up:e=>{e.verticalAlign="middle"},down:St},{id:us.MigrateLegacyAlign,up:e=>{let t;switch(e.align){case"start":t="start-legacy";break;case"end":t="end-legacy";break;default:t="middle-legacy";break}e.align=t},down:St},{id:us.AddCloud,up:e=>{},down:St},{id:us.MakeUrlsValid,up:e=>{er.isValid(e.url)||(e.url="")},down:e=>{}}]},TE={},$E={sequence:[]},ME={color:tr,size:lo,segments:Ut(xE),isComplete:we,isPen:we},AE={sequence:[]},p3=ve({topLeft:jl,bottomRight:jl}),jE={w:On,h:On,playing:we,url:er,assetId:mf.nullable(),crop:p3.nullable()},jg=mo("image",{AddUrlProp:1,AddCropProp:2,MakeUrlsValid:3}),OE={sequence:[{id:jg.AddUrlProp,up:e=>{e.url=""},down:St},{id:jg.AddCropProp,up:e=>{e.crop=null},down:e=>{delete e.crop}},{id:jg.MakeUrlsValid,up:e=>{er.isValid(e.url)||(e.url="")},down:e=>{}}]},pp=Yt.defineEnum("tldraw:spline",{defaultValue:"line",values:["cubic","line"]}),f3=ve({id:ge,index:Qv,x:he,y:he}),DE={color:tr,dash:bi,size:lo,spline:pp,points:ip(ge,f3)},Zu=mo("line",{AddSnapHandles:1,RemoveExtraHandleProps:2,HandlesToPoints:3,PointIndexIds:4}),RE={sequence:[{id:Zu.AddSnapHandles,up:e=>{for(const t of Object.values(e.handles))t.canSnap=!0},down:St},{id:Zu.RemoveExtraHandleProps,up:e=>{e.handles=Kv(Object.values(e.handles).map(t=>[t.index,{x:t.x,y:t.y}]))},down:e=>{const t=Object.entries(e.handles).map(([n,r])=>({index:n,...r})).sort(rn);e.handles=Object.fromEntries(t.map((n,r)=>{const o=r===0?"start":r===t.length-1?"end":`handle:${n.index}`;return[o,{id:o,type:"vertex",canBind:!1,canSnap:!0,index:n.index,x:n.x,y:n.y}]}))}},{id:Zu.HandlesToPoints,up:e=>{const t=Object.entries(e.handles).map(([n,{x:r,y:o}])=>({x:r,y:o,index:n})).sort(rn);e.points=t.map(({x:n,y:r})=>({x:n,y:r})),delete e.handles},down:e=>{const t=Al(e.points.length);e.handles=Object.fromEntries(e.points.map((n,r)=>[t[r],{x:n.x,y:n.y}])),delete e.points}},{id:Zu.PointIndexIds,up:e=>{const t=Al(e.points.length);e.points=Object.fromEntries(e.points.map((n,r)=>{const o=t[r];return[o,{id:o,index:o,x:n.x,y:n.y}]}))},down:e=>{const t=Object.values(e.points).sort(rn);e.points=t.map(({x:n,y:r})=>({x:n,y:r}))}}]},LE={color:tr,size:lo,font:co,fontSizeAdjustment:sp,align:dp,verticalAlign:hp,growY:sp,url:er,text:ge},Zi=mo("note",{AddUrlProp:1,RemoveJustify:2,MigrateLegacyAlign:3,AddVerticalAlign:4,MakeUrlsValid:5,AddFontSizeAdjustment:6}),FE={sequence:[{id:Zi.AddUrlProp,up:e=>{e.url=""},down:St},{id:Zi.RemoveJustify,up:e=>{e.align==="justify"&&(e.align="start")},down:St},{id:Zi.MigrateLegacyAlign,up:e=>{switch(e.align){case"start":e.align="start-legacy";return;case"end":e.align="end-legacy";return;default:e.align="middle-legacy";return}},down:St},{id:Zi.AddVerticalAlign,up:e=>{e.verticalAlign="middle"},down:St},{id:Zi.MakeUrlsValid,up:e=>{er.isValid(e.url)||(e.url="")},down:e=>{}},{id:Zi.AddFontSizeAdjustment,up:e=>{e.fontSizeAdjustment=0},down:e=>{delete e.fontSizeAdjustment}}]},Hy=Yt.defineEnum("tldraw:textAlign",{defaultValue:"start",values:["start","middle","end"]}),NE={color:tr,size:lo,font:co,textAlign:Hy,w:On,text:ge,scale:On,autoSize:we},db=mo("text",{RemoveJustify:1,AddTextAlign:2}),zE={sequence:[{id:db.RemoveJustify,up:e=>{e.align==="justify"&&(e.align="start")},down:St},{id:db.AddTextAlign,up:e=>{e.textAlign=e.align,delete e.align},down:e=>{e.align=e.textAlign,delete e.textAlign}}]},BE={w:On,h:On,time:he,playing:we,url:er,assetId:mf.nullable()},hb=mo("video",{AddUrlProp:1,MakeUrlsValid:2}),UE={sequence:[{id:hb.AddUrlProp,up:e=>{e.url=""},down:St},{id:hb.MakeUrlsValid,up:e=>{er.isValid(e.url)||(e.url="")},down:e=>{}}]},Qu=or("com.tldraw.store",{RemoveCodeAndIconShapeTypes:1,AddInstancePresenceType:2,RemoveTLUserAndPresenceAndAddPointer:3,RemoveUserDocument:4}),g3=gl({sequenceId:"com.tldraw.store",retroactive:!1,sequence:[{id:Qu.RemoveCodeAndIconShapeTypes,scope:"store",up:e=>{for(const[t,n]of gn(e))n.typeName==="shape"&&(n.type==="icon"||n.type==="code")&&delete e[t]}},{id:Qu.AddInstancePresenceType,scope:"store",up(e){}},{id:Qu.RemoveTLUserAndPresenceAndAddPointer,scope:"store",up:e=>{for(const[t,n]of gn(e))n.typeName.match(/^(user|user_presence)$/)&&delete e[t]}},{id:Qu.RemoveUserDocument,scope:"store",up:e=>{for(const[t,n]of gn(e))n.typeName.match("user_document")&&delete e[t]}}]}),m3={arrow:{migrations:yE,props:mE},bookmark:{migrations:vE,props:SE},draw:{migrations:bE,props:wE},embed:{migrations:CE,props:PE},frame:{migrations:EE,props:IE},geo:{migrations:kE,props:_E},group:{migrations:$E,props:TE},highlight:{migrations:AE,props:ME},image:{migrations:OE,props:jE},line:{migrations:RE,props:DE},note:{migrations:FE,props:LE},text:{migrations:zE,props:NE},video:{migrations:UE,props:BE}};function y3({shapes:e=m3,migrations:t}={}){const n=new Map;for(const s of _t(e))for(const i of dE(s.props??{}).keys()){if(n.has(i.id)&&n.get(i.id)!==i)throw new Error(`Multiple StyleProp instances with the same id: ${i.id}`);n.set(i.id,i)}const r=l3(e),o=AR(n);return Xv.create({asset:pi,camera:Rr,document:t0,instance:o,instance_page_state:gr,page:Bo,instance_presence:HR,pointer:e0,shape:r},{migrations:[g3,s3,PR,WR,jR,LR,MR,UR,zR,a3,QR,e3,n3,...c3(e),...t??[]],onValidationFailure:VR,createIntegrityChecker:XR})}const Dl=[{locale:"id",label:"Bahasa Indonesia"},{locale:"ca",label:"Català"},{locale:"cs",label:"Čeština"},{locale:"da",label:"Danish"},{locale:"de",label:"Deutsch"},{locale:"en",label:"English"},{locale:"es",label:"Español"},{locale:"fr",label:"Français"},{locale:"gl",label:"Galego"},{locale:"hr",label:"Hrvatski"},{locale:"it",label:"Italiano"},{locale:"hu",label:"Magyar"},{locale:"no",label:"Norwegian"},{locale:"pl",label:"Polski"},{locale:"pt-br",label:"Português - Brasil"},{locale:"pt-pt",label:"Português - Europeu"},{locale:"ro",label:"Română"},{locale:"ru",label:"Russian"},{locale:"sl",label:"Slovenščina"},{locale:"fi",label:"Suomi"},{locale:"sv",label:"Svenska"},{locale:"vi",label:"Tiếng Việt"},{locale:"tr",label:"Türkçe"},{locale:"uk",label:"Ukrainian"},{locale:"he",label:"עברית"},{locale:"ar",label:"عربي"},{locale:"fa",label:"فارسی"},{locale:"ku",label:"کوردی"},{locale:"ne",label:"नेपाली"},{locale:"hi-in",label:"हिन्दी"},{locale:"te",label:"తెలుగు"},{locale:"th",label:"ภาษาไทย"},{locale:"my",label:"မြန်မာစာ"},{locale:"ko-kr",label:"한국어"},{locale:"ja",label:"日本語"},{locale:"zh-cn",label:"简体中文"},{locale:"zh-tw",label:"繁體中文 (台灣)"}];function S3(){const e=typeof window<"u"?window.navigator.languages??["en"]:["en"];return v3(e)}function v3(e){for(const t of e){const n=x3(t);if(n)return n}return"en"}const pb={zh:"zh-cn",pt:"pt-br",ko:"ko-kr",hi:"hi-in"};function x3(e){const t=Dl.find(o=>o.locale===e.toLowerCase());if(t)return t.locale;const[n,r]=e.split(/[-_]/).map(o=>o.toLowerCase());if(r){const o=Dl.find(s=>s.locale===n);if(o)return o.locale}return n in pb?pb[n]:null}var HE={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 t={}.hasOwnProperty;function n(){for(var s="",i=0;i<arguments.length;i++){var a=arguments[i];a&&(s=o(s,r(a)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var i="";for(var a in s)t.call(s,a)&&s[a]&&(i=o(i,a));return i}function o(s,i){return i?s?s+" "+i:s+i:s}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(HE);var w3=HE.exports;const ue=lc(w3),b3={error:null};class KE extends x.Component{constructor(){super(...arguments);m(this,"state",b3)}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n){var r,o;(o=(r=this.props).onError)==null||o.call(r,n)}render(){const{error:n}=this.state;if(n!==null){const{fallback:r}=this.props;return h.jsx(r,{error:n})}return this.props.children}}function Rl({children:e,fallback:t,...n}){return t===null?h.jsx(h.Fragment,{children:e}):h.jsx(KE,{fallback:t,...n,children:e})}const yf=Se.createContext({});function z(){return Se.useContext(yf)}function P3(){return h.jsx("div",{className:"tl-background"})}function fc(e,t,n,r,o,s){x.useLayoutEffect(()=>{const i=e.current;if(!i||t===void 0)return;let a=`translate(${t}px, ${n}px)`;r!==void 0&&(a+=` scale(${r})`),o!==void 0&&(a+=` rotate(${o}rad)`),s&&(a+=` translate(${s.x}px, ${s.y}px)`),i.style.transform=a})}const sn={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:-1+(4-2*e)*e,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1,easeInQuart:e=>e*e*e*e,easeOutQuart:e=>1- --e*e*e*e,easeInOutQuart:e=>e<.5?8*e*e*e*e:1-8*--e*e*e*e,easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>1+--e*e*e*e*e,easeInOutQuint:e=>e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e,easeInSine:e=>1-Math.cos(e*Math.PI/2),easeOutSine:e=>Math.sin(e*Math.PI/2),easeInOutSine:e=>-(Math.cos(Math.PI*e)-1)/2,easeInExpo:e=>e<=0?0:Math.pow(2,10*e-10),easeOutExpo:e=>e>=1?1:1-Math.pow(2,-10*e),easeInOutExpo:e=>e<=0?0:e>=1?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2};class b{constructor(t=0,n=0,r=1){this.x=t,this.y=n,this.z=r}get pressure(){return this.z}set(t=this.x,n=this.y,r=this.z){return this.x=t,this.y=n,this.z=r,this}setTo({x:t=0,y:n=0,z:r=1}){return this.x=t,this.y=n,this.z=r,this}rot(t){if(t===0)return this;const{x:n,y:r}=this,o=Math.sin(t),s=Math.cos(t);return this.x=n*s-r*o,this.y=n*o+r*s,this}rotWith(t,n){if(n===0)return this;const r=this.x-t.x,o=this.y-t.y,s=Math.sin(n),i=Math.cos(n);return this.x=t.x+(r*i-o*s),this.y=t.y+(r*s+o*i),this}clone(){const{x:t,y:n,z:r}=this;return new b(t,n,r)}sub(t){return this.x-=t.x,this.y-=t.y,this}subXY(t,n){return this.x-=t,this.y-=n,this}subScalar(t){return this.x-=t,this.y-=t,this}add(t){return this.x+=t.x,this.y+=t.y,this}addXY(t,n){return this.x+=t,this.y+=n,this}addScalar(t){return this.x+=t,this.y+=t,this}clamp(t,n){return this.x=Math.max(this.x,t),this.y=Math.max(this.y,t),n!==void 0&&(this.x=Math.min(this.x,n),this.y=Math.min(this.y,n)),this}div(t){return this.x/=t,this.y/=t,this}divV(t){return this.x/=t.x,this.y/=t.y,this}mul(t){return this.x*=t,this.y*=t,this}mulV(t){return this.x*=t.x,this.y*=t.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(t,n){const r=b.Tan(t,this);return this.add(r.mul(n))}neg(){return this.x*=-1,this.y*=-1,this}cross(t){return this.x=this.y*t.z-this.z*t.y,this.y=this.z*t.x-this.x*t.z,this}dpr(t){return b.Dpr(this,t)}cpr(t){return b.Cpr(this,t)}len2(){return b.Len2(this)}len(){return b.Len(this)}pry(t){return b.Pry(this,t)}per(){const{x:t,y:n}=this;return this.x=n,this.y=-t,this}uni(){return b.Uni(this)}tan(t){return b.Tan(this,t)}dist(t){return b.Dist(this,t)}distanceToLineSegment(t,n){return b.DistanceToLineSegment(t,n,this)}slope(t){return b.Slope(this,t)}snapToGrid(t){return this.x=Math.round(this.x/t)*t,this.y=Math.round(this.y/t)*t,this}angle(t){return b.Angle(this,t)}toAngle(){return b.ToAngle(this)}lrp(t,n){return this.x=this.x+(t.x-this.x)*n,this.y=this.y+(t.y-this.y)*n,this}equals(t){return b.Equals(this,t)}equalsXY(t,n){return b.EqualsXY(this,t,n)}norm(){const t=this.len();return this.x=t===0?0:this.x/t,this.y=t===0?0:this.y/t,this}toFixed(){return b.ToFixed(this)}toString(){return b.ToString(b.ToFixed(this))}toJson(){return b.ToJson(this)}toArray(){return b.ToArray(this)}static Add(t,n){return new b(t.x+n.x,t.y+n.y)}static AddXY(t,n,r){return new b(t.x+n,t.y+r)}static Sub(t,n){return new b(t.x-n.x,t.y-n.y)}static SubXY(t,n,r){return new b(t.x-n,t.y-r)}static AddScalar(t,n){return new b(t.x+n,t.y+n)}static SubScalar(t,n){return new b(t.x-n,t.y-n)}static Div(t,n){return new b(t.x/n,t.y/n)}static Mul(t,n){return new b(t.x*n,t.y*n)}static DivV(t,n){return new b(t.x/n.x,t.y/n.y)}static MulV(t,n){return new b(t.x*n.x,t.y*n.y)}static Neg(t){return new b(-t.x,-t.y)}static Per(t){return new b(t.y,-t.x)}static Abs(t){return new b(Math.abs(t.x),Math.abs(t.y))}static Dist(t,n){return((t.y-n.y)**2+(t.x-n.x)**2)**.5}static DistMin(t,n,r){return(t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y)<r**2}static Dist2(t,n){return(t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y)}static Dpr(t,n){return t.x*n.x+t.y*n.y}static Cross(t,n){return new b(t.y*n.z-t.z*n.y,t.z*n.x-t.x*n.z)}static Cpr(t,n){return t.x*n.y-n.x*t.y}static Len2(t){return t.x*t.x+t.y*t.y}static Len(t){return(t.x*t.x+t.y*t.y)**.5}static Pry(t,n){return b.Dpr(t,n)/b.Len(n)}static Uni(t){return b.Div(t,b.Len(t))}static Tan(t,n){return b.Uni(b.Sub(t,n))}static Min(t,n){return new b(Math.min(t.x,n.x),Math.min(t.y,n.y))}static Max(t,n){return new b(Math.max(t.x,n.x),Math.max(t.y,n.y))}static From({x:t,y:n,z:r=1}){return new b(t,n,r)}static FromArray(t){return new b(t[0],t[1])}static Rot(t,n=0){const r=Math.sin(n),o=Math.cos(n);return new b(t.x*o-t.y*r,t.x*r+t.y*o)}static RotWith(t,n,r){const o=t.x-n.x,s=t.y-n.y,i=Math.sin(r),a=Math.cos(r);return new b(n.x+(o*a-s*i),n.y+(o*i+s*a))}static NearestPointOnLineThroughPoint(t,n,r){return b.Mul(n,b.Sub(r,t).pry(n)).add(t)}static NearestPointOnLineSegment(t,n,r,o=!0){if(b.Equals(t,r)||b.Equals(n,r))return b.From(r);const s=b.Tan(n,t),i=b.Add(t,b.Mul(s,b.Sub(r,t).pry(s)));if(o){if(i.x<Math.min(t.x,n.x))return b.Cast(t.x<n.x?t:n);if(i.x>Math.max(t.x,n.x))return b.Cast(t.x>n.x?t:n);if(i.y<Math.min(t.y,n.y))return b.Cast(t.y<n.y?t:n);if(i.y>Math.max(t.y,n.y))return b.Cast(t.y>n.y?t:n)}return i}static DistanceToLineThroughPoint(t,n,r){return b.Dist(r,b.NearestPointOnLineThroughPoint(t,n,r))}static DistanceToLineSegment(t,n,r,o=!0){return b.Dist(r,b.NearestPointOnLineSegment(t,n,r,o))}static Snap(t,n=1){return new b(Math.round(t.x/n)*n,Math.round(t.y/n)*n)}static Cast(t){return t instanceof b?t:b.From(t)}static Slope(t,n){return t.x===n.y?NaN:(t.y-n.y)/(t.x-n.x)}static IsNaN(t){return isNaN(t.x)||isNaN(t.y)}static Angle(t,n){return Math.atan2(n.y-t.y,n.x-t.x)}static Lrp(t,n,r){return b.Sub(n,t).mul(r).add(t)}static Med(t,n){return new b((t.x+n.x)/2,(t.y+n.y)/2)}static Equals(t,n){return Math.abs(t.x-n.x)<1e-4&&Math.abs(t.y-n.y)<1e-4}static EqualsXY(t,n,r){return t.x===n&&t.y===r}static Clockwise(t,n,r){return(r.x-t.x)*(n.y-t.y)-(n.x-t.x)*(r.y-t.y)<0}static Rescale(t,n){const r=b.Len(t);return new b(n*t.x/r,n*t.y/r)}static ScaleWithOrigin(t,n,r){return b.Sub(t,r).mul(n).add(r)}static ToFixed(t,n=2){return new b(+t.x.toFixed(n),+t.y.toFixed(n),+t.z.toFixed(n))}static Nudge(t,n,r){return b.Add(t,b.Tan(n,t).mul(r))}static ToString(t){return`${t.x}, ${t.y}`}static ToAngle(t){let n=Math.atan2(t.y,t.x);return n<0&&(n+=Math.PI*2),n}static FromAngle(t,n=1){return new b(Math.cos(t)*n,Math.sin(t)*n)}static ToArray(t){return[t.x,t.y,t.z]}static ToJson(t){const{x:n,y:r,z:o}=t;return{x:n,y:r,z:o}}static Average(t){const n=t.length,r=new b(0,0);if(n===0)return r;for(let o=0;o<n;o++)r.add(t[o]);return r.div(n)}static Clamp(t,n,r){return r===void 0?new b(Math.min(Math.max(t.x,n)),Math.min(Math.max(t.y,n))):new b(Math.min(Math.max(t.x,n),r),Math.min(Math.max(t.y,n),r))}static PointsBetween(t,n,r=6){const o=[];for(let s=0;s<r;s++){const i=sn.easeInQuad(s/(r-1)),a=b.Lrp(t,n,i);a.z=Math.min(1,.5+Math.abs(.5-C3(i))*.65),o.push(a)}return o}static SnapToGrid(t,n=8){return new b(Math.round(t.x/n)*n,Math.round(t.y/n)*n)}}const C3=e=>e<.5?2*e*e:-1+(4-2*e)*e;function _e(e){return`${j(e.x)},${j(e.y)} `}function In(e,t){return`${j((e.x+t.x)/2)},${j((e.y+t.y)/2)} `}const Pe=Math.PI,Ue=Pe/2,Re=Pe*2,I3=Math.sin;function Mt(e,t,n){return Math.max(t,typeof n<"u"?Math.min(e,n):e)}function Ju(e,t=1e10){return e?Math.round(e*t)/t:0}function yl(e,t,n=1e-6){return Math.abs(e-t)<=n}function fp(e,t){const n=Math.pow(e-t,2)/Math.pow(e+t,2);return Pe*(e+t)*(1+3*n/(10+Math.sqrt(4-3*n)))}function ks(e){return e=e%Re,e<0?e=e+Re:e===0&&(e=0),e}function vu(e,t){return e=ks(e),t=ks(t),e>t&&(t+=Re),t-e}function WE(e,t){return Re-vu(e,t)}function th(e,t){const n=(t-e)%Re;return 2*n%Re-n}function Ky(e){return(Re+e)%Re}function gp(e,t){const n=Re/t;let r=Math.floor((Ky(e)+n/2)/n)*n%Re;return r<Pe&&(r+=Re),r>Pe&&(r-=Re),r}function GE(e,t){return e===t||yl(e%(Math.PI/2)-t%(Math.PI/2),0)}function E3(e){return e*Pe/180}function _3(e){return e*180/Pe}function Pi(e,t,n){return new b(e.x,e.y).add(b.FromAngle(n,t))}function Og(e,t,n){const r=e/2,o=t/2,s=[];let i=1/0,a=-1/0,c=1/0,l=-1/0;for(let y=0;y<n;y++){const g=Re/n,w=-Ue+y*g,S=r+r*Math.cos(w),v=o+o*Math.sin(w);S<i&&(i=S),v<c&&(c=v),S>a&&(a=S),v>l&&(l=v),s.push(new b(S,v))}const u=a-i,d=l-c,p=e-u,f=t-d;if(p!==0||f!==0)for(let y=0;y<s.length;y++){const g=s[y];g.x=(g.x-i)/u*e,g.y=(g.y-c)/d*t}return s}function Lc(e,t,n,r){return e<r&&n<t}function $r(e,t,n,r){const o=Math.max(e,n),s=Math.min(t,r);return o<=s?[o,s]:null}function fb(e,t,n){return(t.x-e.x)*(n.y-e.y)-(n.x-e.x)*(t.y-e.y)}function Zn(e,t){let n=0,r,o;for(let s=0;s<t.length;s++){if(r=t[s],r.x===e.x&&r.y===e.y||(o=t[(s+1)%t.length],b.Dist(e,r)+b.Dist(e,o)===b.Dist(r,o)))return!0;r.y<=e.y?o.y>e.y&&fb(r,o,e)>0&&(n+=1):o.y<=e.y&&fb(r,o,e)<0&&(n-=1)}return n!==0}function j(e){return Math.round(e*1e4)/1e4}function mp(e){return Math.round(e*100)/100}const gb=e=>Math.abs(e)<Number.MAX_SAFE_INTEGER;function vs(e,t,n){return n<0?vu(e,t):WE(e,t)}function Wy(e,t,n,r){let o;if(Math.abs(e)>Pe){o=th(t,r);const s=th(r,n);return Math.abs(o)<Math.abs(s)?o/e:(e-s)/e}else{o=th(t,r);const s=o/e;return Math.sign(o)!==Math.sign(e)?Math.abs(s)>.5?1:0:s}}function k3(e,t,n,r){const o=2*((t-e)%Re)%Re-(t-e)%Re;return r?(Re-Math.abs(o))*(n?1:-1):o}const ed=({brush:e,color:t,opacity:n,className:r})=>{const o=x.useRef(null);fc(o,e.x,e.y);const s=j(Math.max(1,e.w)),i=j(Math.max(1,e.h));return h.jsx("svg",{className:"tl-overlays__item",ref:o,children:t?h.jsxs("g",{className:"tl-brush",opacity:n,children:[h.jsx("rect",{width:s,height:i,fill:t,opacity:.75}),h.jsx("rect",{width:s,height:i,fill:"none",stroke:t,opacity:.1})]}):h.jsx("rect",{className:`tl-brush tl-brush__default ${r}`,width:s,height:i})})},gs=2e3,yp=40,Qr=320,mb={isLocked:!1,wheelBehavior:"pan",panSpeed:1,zoomSpeed:1,zoomSteps:[.1,.25,.5,1,2,4,8]},T3=.5,$3=.1,M3=.2,A3=.005,j3=.05,O3=450,D3=200,VE=36,Sp=16,R3=32,Dg={duration:0,easing:sn.easeInOutCubic},YE=.09,yb=[{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}],L3=6e4,XE=3e3,F3=1200,Sb={CAMERA_MOVE:-10},N3=64,Uo=8,z3=20,B3=8,U3=12,qE=20,ZE=12,H3=["top","right","bottom","left"],K3=500,vb=.35,xb=0,n0=2,td=1,wb=5;var Rg={};const W3={},QE=zn("pointerCaptureTrackingObject",{defaults:{all:new Map},shouldStoreForSession:!1}),jt={logPreventDefaults:zn("logPreventDefaults",{defaults:{all:!1}}),logPointerCaptures:zn("logPointerCaptures",{defaults:{all:!1}}),logElementRemoves:zn("logElementRemoves",{defaults:{all:!1}}),debugSvg:zn("debugSvg",{defaults:{all:!1}}),showFps:zn("showFps",{defaults:{all:!1}}),throwToBlob:zn("throwToBlob",{defaults:{all:!1}}),reconnectOnPing:zn("reconnectOnPing",{defaults:{all:!1}}),debugCursors:zn("debugCursors",{defaults:{all:!1}}),forceSrgb:zn("forceSrgbColors",{defaults:{all:!1}}),debugGeometry:zn("debugGeometry",{defaults:{all:!1}}),hideShapes:zn("hideShapes",{defaults:{all:!1}}),editOnType:zn("editOnType",{defaults:{all:!1}})};if(typeof Element<"u"){const e=Element.prototype.removeChild;hc("element removal logging",()=>{jt.logElementRemoves.get()?Element.prototype.removeChild=function(t){return console.warn("[tldraw] removing child:",t),e.call(this,t)}:Element.prototype.removeChild=e})}function zn(e,{defaults:t,shouldStoreForSession:n=!0}){return G3({name:e,defaults:t,shouldStoreForSession:n})}function G3(e){const t=Y3(e),n=e.shouldStoreForSession?V3(e.name):null,r=pn(`debug:${e.name}`,n??t);return typeof window<"u"&&(e.shouldStoreForSession&&hc(`debug:${e.name}`,()=>{const o=r.get();o===t?ZI(`tldraw_debug:${e.name}`):Vv(`tldraw_debug:${e.name}`,JSON.stringify(o))}),Object.defineProperty(window,`tldraw${e.name.replace(/^[a-z]/,o=>o.toUpperCase())}`,{get(){return r.get()},set(o){r.set(o)},configurable:!0})),Object.assign(r,e)}function V3(e){try{return JSON.parse(qI(`tldraw_debug:${e}`)??"null")}catch{return null}}function Lg(e){try{return e()}catch{return null}}function Y3(e){switch(Lg(()=>Rg.TLDRAW_ENV)??Lg(()=>Rg.VERCEL_PUBLIC_TLDRAW_ENV)??Lg(()=>Rg.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 vp(e){if(e instanceof HTMLElement)return e;if(e.parentElement)return vp(e.parentElement);throw Error("Could not find a parent element of an HTML type!")}function ke(e){e.preventDefault(),jt.logPreventDefaults.get()&&console.warn("preventDefault called on event:",e)}function xu(e,t){if(e.setPointerCapture(t.pointerId),jt.logPointerCaptures.get()){const n=QE.get();n.set(e,(n.get(e)??0)+1),console.warn("setPointerCapture called on element:",e,t)}}function wu(e,t){if(e.hasPointerCapture(t.pointerId)&&(e.releasePointerCapture(t.pointerId),jt.logPointerCaptures.get())){const n=QE.get();n.get(e)===1?n.delete(e):n.has(e)?n.set(e,n.get(e)-1):console.warn("Release without capture"),console.warn("releasePointerCapture called on element:",e,t)}}const Kt=e=>e.stopPropagation(),Jt=(e,t,n)=>{e&&e.style.setProperty(t,n)};function _n(e){return e.isKilled=!0,{point:{x:e.clientX,y:e.clientY,z:e.pressure},shiftKey:e.shiftKey,altKey:e.altKey,ctrlKey:e.metaKey||e.ctrlKey,pointerId:e.pointerId,button:e.button,isPen:e.pointerType==="pen"}}function X3(){const e=z();return x.useMemo(function(){let r,o;function s(g){if(!g.isKilled){if(g.button===n0){e.dispatch({type:"pointer",target:"canvas",name:"right_click",..._n(g)});return}g.button!==0&&g.button!==1&&g.button!==5||(xu(g.currentTarget,g),e.dispatch({type:"pointer",target:"canvas",name:"pointer_down",..._n(g)}),e.getOpenMenus().length>0&&(e.updateInstanceState({openMenus:[]}),document.body.click(),e.getContainer().focus()))}}function i(g){g.isKilled||g.clientX===r&&g.clientY===o||(r=g.clientX,o=g.clientY,e.dispatch({type:"pointer",target:"canvas",name:"pointer_move",..._n(g)}))}function a(g){g.isKilled||g.button!==0&&g.button!==1&&g.button!==2&&g.button!==5||(r=g.clientX,o=g.clientY,wu(g.currentTarget,g),e.dispatch({type:"pointer",target:"canvas",name:"pointer_up",..._n(g)}))}function c(g){if(g.isKilled||e.getInstanceState().isPenMode&&g.pointerType!=="pen")return;const w=g.pointerType==="mouse"||g.pointerType==="pen";e.updateInstanceState({isHoveringCanvas:w?!0:null})}function l(g){if(g.isKilled||e.getInstanceState().isPenMode&&g.pointerType!=="pen")return;const w=g.pointerType==="mouse"||g.pointerType==="pen";e.updateInstanceState({isHoveringCanvas:w?!1:null})}function u(g){g.isKilled=!0,document.body.click(),ke(g)}function d(g){g.isKilled=!0,g.target instanceof HTMLElement&&g.target.tagName!=="A"&&g.target.tagName!=="TEXTAREA"&&!(e.getEditingShape()&&g.target.className.includes("tl-text-content"))&&ke(g)}function p(g){ke(g)}async function f(g){var S,v;if(ke(g),!((v=(S=g.dataTransfer)==null?void 0:S.files)!=null&&v.length))return;const w=Array.from(g.dataTransfer.files);await e.putExternalContent({type:"files",files:w,point:e.screenToPage({x:g.clientX,y:g.clientY}),ignoreParent:!1})}function y(g){Kt(g)}return{onPointerDown:s,onPointerMove:i,onPointerUp:a,onPointerEnter:c,onPointerLeave:l,onDragOver:p,onDrop:f,onTouchStart:u,onTouchEnd:d,onClick:y}},[e])}function q3(){const e=z();x.useEffect(()=>{let t=e.getInstanceState().isCoarsePointer;const n=()=>{t||(t=!0,e.updateInstanceState({isCoarsePointer:!0}))},r=a=>{var c;t&&((c=a.sourceCapabilities)!=null&&c.firesTouchEvents||(t=!1,e.updateInstanceState({isCoarsePointer:!1})))};window.addEventListener("touchstart",n),window.addEventListener("mousemove",r);const o=window.matchMedia&&window.matchMedia("(any-pointer: coarse)"),s=e.environment.isFirefox&&!e.environment.isAndroid&&!e.environment.isIos,i=()=>{const a=s?!1:o.matches;t===a&&(t=a,e.updateInstanceState({isCoarsePointer:a}))};return o&&(o.addEventListener("change",i),i()),()=>{window.removeEventListener("touchstart",n),window.removeEventListener("mousemove",r),o&&o.removeEventListener("change",i)}},[e])}const JE=x.createContext(null);function Z3({container:e,children:t}){return h.jsx(JE.Provider,{value:e,children:t})}function Xt(){return hi(x.useContext(JE),"useContainer used outside of <Tldraw />")}function Q3(){const e=z(),t=Xt(),n=K("isFocused",()=>e.getInstanceState().isFocused,[e]);x.useEffect(()=>{if(typeof matchMedia===void 0)return;let r=null;const o=()=>{r!=null&&r();const s=`(resolution: ${window.devicePixelRatio}dppx)`,i=matchMedia(s),a=c=>{c.type==="change"&&o()};i.addEventListener?i.addEventListener("change",o):i.addListener&&i.addListener(a),r=()=>{i.removeEventListener?i.removeEventListener("change",o):i.removeListener&&i.removeListener(a)},e.updateInstanceState({devicePixelRatio:window.devicePixelRatio})};return o(),()=>{r==null||r()}},[e]),x.useEffect(()=>{if(!n)return;const r=a=>{if(a.altKey&&(e.isIn("zoom")||!e.getPath().endsWith(".idle"))&&!nd()&&ke(a),a.isKilled)return;switch(a.isKilled=!0,a.key){case"=":case"-":case"0":{if(a.metaKey||a.ctrlKey){ke(a);return}break}case"Tab":{if(nd()||e.getIsMenuOpen())return;break}case",":return;case"Escape":{if((e.getEditingShape()||e.getSelectedShapeIds().length>0)&&a.preventDefault(),e.getOpenMenus().length>0)return;e.inputs.keys.has("Escape")||(e.inputs.keys.add("Escape"),e.cancel(),t.focus());return}default:if(nd()||e.getIsMenuOpen())return}const c={type:"keyboard",name:a.repeat?"key_repeat":"key_down",key:a.key,code:a.code,shiftKey:a.shiftKey,altKey:a.altKey,ctrlKey:a.metaKey||a.ctrlKey};e.dispatch(c)},o=a=>{if(a.isKilled||(a.isKilled=!0,nd()||e.getIsMenuOpen())||a.key===",")return;const c={type:"keyboard",name:"key_up",key:a.key,code:a.code,shiftKey:a.shiftKey,altKey:a.altKey,ctrlKey:a.metaKey||a.ctrlKey};e.dispatch(c)};function s(a){var c,l;if(t.contains(a.target)){const u=a.touches[0].pageX,d=a.touches[0].radiusX||0;(u-d<10||u+d>e.getViewportScreenBounds().width-10)&&(((c=a.target)==null?void 0:c.tagName)==="BUTTON"&&((l=a.target)==null||l.click()),ke(a))}}const i=a=>{t.contains(a.target)&&(a.ctrlKey||a.metaKey)&&ke(a)};return t.addEventListener("touchstart",s,{passive:!1}),t.addEventListener("wheel",i,{passive:!1}),document.addEventListener("gesturestart",ke),document.addEventListener("gesturechange",ke),document.addEventListener("gestureend",ke),t.addEventListener("keydown",r),t.addEventListener("keyup",o),()=>{t.removeEventListener("touchstart",s),t.removeEventListener("wheel",i),document.removeEventListener("gesturestart",ke),document.removeEventListener("gesturechange",ke),document.removeEventListener("gestureend",ke),t.removeEventListener("keydown",r),t.removeEventListener("keyup",o)}},[e,t,n])}const J3=["input","select","button","textarea"];function nd(){const{activeElement:e}=document;return!!(e&&(e.getAttribute("contenteditable")||J3.indexOf(e.tagName.toLowerCase())>-1))}const eL=["textarea","input"];function tL(e){const t=z();x.useEffect(()=>{const n=e.current;if(!n)return;const r=o=>{var s;if(o instanceof PointerEvent&&o.pointerType==="pen"){o.isKilled=!0;const{target:i}=o;if(eL.includes((s=i.tagName)==null?void 0:s.toLocaleLowerCase())||t.isIn("select.editing_shape"))return;ke(o)}};return n.addEventListener("touchstart",r),n.addEventListener("touchend",r),()=>{n.removeEventListener("touchstart",r),n.removeEventListener("touchend",r)}},[t,e])}function nL(e,t,n){return Math.max(t,Math.min(e,n))}const Ht={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function bb(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function Pb(e,t,n,r=.15){return r===0?nL(e,t,n):e<t?-bb(t-e,n-t,r)+t:e>n?+bb(e-n,n-t,r)+n:e}function rL(e,[t,n],[r,o]){const[[s,i],[a,c]]=e;return[Pb(t,s,i,r),Pb(n,a,c,o)]}function oL(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function sL(e){var t=oL(e,"string");return typeof t=="symbol"?t:String(t)}function en(e,t,n){return t=sL(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Cb(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ut(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Cb(Object(n),!0).forEach(function(r){en(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cb(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}const e_={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 iL=["enter","leave"];function aL(e=!1,t){return e&&!iL.includes(t)}function cL(e,t="",n=!1){const r=e_[e],o=r&&r[t]||t;return"on"+Ib(e)+Ib(o)+(aL(n,o)?"Capture":"")}const lL=["gotpointercapture","lostpointercapture"];function uL(e){let t=e.substring(2).toLowerCase();const n=!!~t.indexOf("passive");n&&(t=t.replace("passive",""));const r=lL.includes(t)?"capturecapture":"capture",o=!!~t.indexOf(r);return o&&(t=t.replace("capture","")),{device:t,capture:o,passive:n}}function dL(e,t=""){const n=e_[e],r=n&&n[t]||t;return e+r}function t_(e){return"touches"in e}function hL(e){return t_(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function pL(e){return Array.from(e.touches).filter(t=>{var n,r;return t.target===e.currentTarget||((n=e.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,t.target))})}function Gy(e,t){try{const n=t.clientX-e.clientX,r=t.clientY-e.clientY,o=(t.clientX+e.clientX)/2,s=(t.clientY+e.clientY)/2,i=Math.hypot(n,r);return{angle:-(Math.atan2(n,r)*180)/Math.PI,distance:i,origin:[o,s]}}catch{}return null}function fL(e){return pL(e).map(t=>t.identifier)}function Eb(e,t){const[n,r]=Array.from(e.touches).filter(o=>t.includes(o.identifier));return Gy(n,r)}const _b=40,kb=800;function n_(e){let{deltaX:t,deltaY:n,deltaMode:r}=e;return r===1?(t*=_b,n*=_b):r===2&&(t*=kb,n*=kb),[t,n]}function gL(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:n,altKey:r,metaKey:o,ctrlKey:s}=e;Object.assign(t,{shiftKey:n,altKey:r,metaKey:o,ctrlKey:s})}return t}function xp(e,...t){return typeof e=="function"?e(...t):e}function mL(){}function yL(...e){return e.length===0?mL:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function Tb(e,t){return Object.assign({},t,e||{})}const SL=32;class r_{constructor(t,n,r){this.ctrl=t,this.args=n,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:n,ingKey:r,args:o}=this;n[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=o,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=t.target,n.currentTarget=t.currentTarget,n.lastOffset=r.from?xp(r.from,n):n.offset,n.offset=n.lastOffset,n.startTime=n.timeStamp=t.timeStamp)}computeValues(t){const n=this.state;n._values=t,n.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:n,config:r,shared:o}=this;n.args=this.args;let s=0;if(t&&(n.event=t,r.preventDefault&&t.cancelable&&n.event.preventDefault(),n.type=t.type,o.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,o.locked=!!document.pointerLockElement,Object.assign(o,gL(t)),o.down=o.pressed=o.buttons%2===1||o.touches>0,s=t.timeStamp-n.timeStamp,n.timeStamp=t.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const E=n._delta.map(Math.abs);Ht.addTo(n._distance,E)}this.axisIntent&&this.axisIntent(t);const[i,a]=n._movement,[c,l]=r.threshold,{_step:u,values:d}=n;if(r.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(i)>=c&&d[0]),u[1]===!1&&(u[1]=Math.abs(a)>=l&&d[1])):(u[0]===!1&&(u[0]=Math.abs(i)>=c&&Math.sign(i)*c),u[1]===!1&&(u[1]=Math.abs(a)>=l&&Math.sign(a)*l)),n.intentional=u[0]!==!1||u[1]!==!1,!n.intentional)return;const p=[0,0];if(r.hasCustomTransform){const[E,_]=d;p[0]=u[0]!==!1?E-u[0]:0,p[1]=u[1]!==!1?_-u[1]:0}else p[0]=u[0]!==!1?i-u[0]:0,p[1]=u[1]!==!1?a-u[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(p);const f=n.offset,y=n._active&&!n._blocked||n.active;y&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=o[this.ingKey]=n._active,t&&(n.first&&("bounds"in r&&(n._bounds=xp(r.bounds,n)),this.setup&&this.setup()),n.movement=p,this.computeOffset()));const[g,w]=n.offset,[[S,v],[P,I]]=n._bounds;n.overflow=[g<S?-1:g>v?1:0,w<P?-1:w>I?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const C=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=rL(n._bounds,n.offset,C),n.delta=Ht.sub(n.offset,f),this.computeMovement(),y&&(!n.last||s>SL)){n.delta=Ht.sub(n.offset,f);const E=n.delta.map(Math.abs);Ht.addTo(n.distance,E),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&s>0&&(n.velocity=[E[0]/s,E[1]/s],n.timeDelta=s)}}emit(){const t=this.state,n=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const o=this.handler(ut(ut(ut({},n),t),{},{[this.aliasKey]:t.values}));o!==void 0&&(t.memo=o)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function vL([e,t],n){const r=Math.abs(e),o=Math.abs(t);if(r>o&&r>n)return"x";if(o>r&&o>n)return"y"}class xL extends r_{constructor(...t){super(...t),en(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=Ht.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Ht.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const n=this.state,r=this.config;if(!n.axis&&t){const o=typeof r.axisThreshold=="object"?r.axisThreshold[hL(t)]:r.axisThreshold;n.axis=vL(n._movement,o)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const wL=e=>e,$b=.15,o_={enabled(e=!0){return e},eventOptions(e,t,n){return ut(ut({},n.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[$b,$b];case!1:return[0,0];default:return Ht.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return Ht.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||wL},threshold(e){return Ht.toVector(e,0)}},bL=0,bu=ut(ut({},o_),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(e=bL){return e},bounds(e={}){if(typeof e=="function")return s=>bu.bounds(e(s));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:n=1/0,top:r=-1/0,bottom:o=1/0}=e;return[[t,n],[r,o]]}}),Pu=typeof window<"u"&&window.document&&window.document.createElement;function s_(){return Pu&&"ontouchstart"in window}function PL(){return s_()||Pu&&window.navigator.maxTouchPoints>1}function CL(){return Pu&&"onpointerdown"in window}function IL(){return Pu&&"exitPointerLock"in window.document}function EL(){try{return"constructor"in GestureEvent}catch{return!1}}const hr={isBrowser:Pu,gesture:EL(),touch:s_(),touchscreen:PL(),pointer:CL(),pointerLock:IL()},_L=250,kL=180,TL=.5,$L=50,ML=250,AL=10,Mb={mouse:0,touch:0,pen:8};ut(ut({},bu),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:o=!1}={}}){return this.pointerLock=r&&hr.pointerLock,hr.touch&&n?"touch":this.pointerLock?"mouse":hr.pointer&&!o?"pointer":hr.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?_L:void 0,!(!hr.touchscreen||n===!1))return e||(n!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:n=!0,buttons:r=1,keys:o=!0}={}}){return this.pointerButtons=r,this.keys=o,!this.pointerLock&&this.device==="pointer"&&n},threshold(e,t,{filterTaps:n=!1,tapsThreshold:r=3,axis:o=void 0}){const s=Ht.toVector(e,n?r:o?1:0);return this.filterTaps=n,this.tapsThreshold=r,s},swipe({velocity:e=TL,distance:t=$L,duration:n=ML}={}){return{velocity:this.transform(Ht.toVector(e)),distance:this.transform(Ht.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return kL;case!1:return 0;default:return e}},axisThreshold(e){return e?ut(ut({},Mb),e):Mb},keyboardDisplacement(e=AL){return e}});function i_(e){const[t,n]=e.overflow,[r,o]=e._delta,[s,i]=e._direction;(t<0&&r>0&&s<0||t>0&&r<0&&s>0)&&(e._movement[0]=e._movementBound[0]),(n<0&&o>0&&i<0||n>0&&o<0&&i>0)&&(e._movement[1]=e._movementBound[1])}const jL=30,OL=100;class DL extends r_{constructor(...t){super(...t),en(this,"ingKey","pinching"),en(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const t=this.state;t._touchIds=[],t.canceled=!1,t.cancel=this.cancel.bind(this),t.turns=0}computeOffset(){const{type:t,movement:n,lastOffset:r}=this.state;t==="wheel"?this.state.offset=Ht.add(n,r):this.state.offset=[(1+n[0])*r[0],n[1]+r[1]]}computeMovement(){const{offset:t,lastOffset:n}=this.state;this.state.movement=[t[0]/n[0],t[1]-n[1]]}axisIntent(){const t=this.state,[n,r]=t._movement;if(!t.axis){const o=Math.abs(n)*jL-Math.abs(r);o<0?t.axis="angle":o>0&&(t.axis="scale")}}restrictToAxis(t){this.config.lockDirection&&(this.state.axis==="scale"?t[1]=0:this.state.axis==="angle"&&(t[0]=0))}cancel(){const t=this.state;t.canceled||setTimeout(()=>{t.canceled=!0,t._active=!1,this.compute(),this.emit()},0)}touchStart(t){this.ctrl.setEventIds(t);const n=this.state,r=this.ctrl.touchIds;if(n._active&&n._touchIds.every(s=>r.has(s))||r.size<2)return;this.start(t),n._touchIds=Array.from(r).slice(0,2);const o=Eb(t,n._touchIds);o&&this.pinchStart(t,o)}pointerStart(t){if(t.buttons!=null&&t.buttons%2!==1)return;this.ctrl.setEventIds(t),t.target.setPointerCapture(t.pointerId);const n=this.state,r=n._pointerEvents,o=this.ctrl.pointerIds;if(n._active&&Array.from(r.keys()).every(i=>o.has(i))||(r.size<2&&r.set(t.pointerId,t),n._pointerEvents.size<2))return;this.start(t);const s=Gy(...Array.from(r.values()));s&&this.pinchStart(t,s)}pinchStart(t,n){const r=this.state;r.origin=n.origin,this.computeValues([n.distance,n.angle]),this.computeInitial(),this.compute(t),this.emit()}touchMove(t){if(!this.state._active)return;const n=Eb(t,this.state._touchIds);n&&this.pinchMove(t,n)}pointerMove(t){const n=this.state._pointerEvents;if(n.has(t.pointerId)&&n.set(t.pointerId,t),!this.state._active)return;const r=Gy(...Array.from(n.values()));r&&this.pinchMove(t,r)}pinchMove(t,n){const r=this.state,o=r._values[1],s=n.angle-o;let i=0;Math.abs(s)>270&&(i+=Math.sign(s)),this.computeValues([n.distance,n.angle-360*i]),r.origin=n.origin,r.turns=i,r._movement=[r._values[0]/r._initial[0]-1,r._values[1]-r._initial[1]],this.compute(t),this.emit()}touchEnd(t){this.ctrl.setEventIds(t),this.state._active&&this.state._touchIds.some(n=>!this.ctrl.touchIds.has(n))&&(this.state._active=!1,this.compute(t),this.emit())}pointerEnd(t){const n=this.state;this.ctrl.setEventIds(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}n._pointerEvents.has(t.pointerId)&&n._pointerEvents.delete(t.pointerId),n._active&&n._pointerEvents.size<2&&(n._active=!1,this.compute(t),this.emit())}gestureStart(t){t.cancelable&&t.preventDefault();const n=this.state;n._active||(this.start(t),this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY],this.compute(t),this.emit())}gestureMove(t){if(t.cancelable&&t.preventDefault(),!this.state._active)return;const n=this.state;this.computeValues([t.scale,t.rotation]),n.origin=[t.clientX,t.clientY];const r=n._movement;n._movement=[t.scale-1,t.rotation],n._delta=Ht.sub(n._movement,r),this.compute(t),this.emit()}gestureEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}wheel(t){const n=this.config.modifierKey;n&&(Array.isArray(n)?!n.find(r=>t[r]):!t[n])||(this.state._active?this.wheelChange(t):this.wheelStart(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(t){this.start(t),this.wheelChange(t)}wheelChange(t){"uv"in t||t.cancelable&&t.preventDefault();const r=this.state;r._delta=[-n_(t)[1]/OL*r.offset[0],0],Ht.addTo(r._movement,r._delta),i_(r),this.state.origin=[t.clientX,t.clientY],this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){const n=this.config.device;n&&(t(n,"start",this[n+"Start"].bind(this)),t(n,"change",this[n+"Move"].bind(this)),t(n,"end",this[n+"End"].bind(this)),t(n,"cancel",this[n+"End"].bind(this)),t("lostPointerCapture","",this[n+"End"].bind(this))),this.config.pinchOnWheel&&t("wheel","",this.wheel.bind(this),{passive:!1})}}const RL=ut(ut({},o_),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!hr.touch&&hr.gesture)return"gesture";if(hr.touch&&r)return"touch";if(hr.touchscreen){if(hr.pointer)return"pointer";if(hr.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const o=i=>{const a=Tb(xp(n,i),{min:-1/0,max:1/0});return[a.min,a.max]},s=i=>{const a=Tb(xp(r,i),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof n!="function"&&typeof r!="function"?[o(),s()]:i=>[o(i),s(i)]},threshold(e,t,n){return this.lockDirection=n.axis==="lock",Ht.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});ut(ut({},bu),{},{mouseOnly:(e=!0)=>e});class LL extends xL{constructor(...t){super(...t),en(this,"ingKey","wheeling")}wheel(t){this.state._active||this.start(t),this.wheelChange(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(t){const n=this.state;n._delta=n_(t),Ht.addTo(n._movement,n._delta),i_(n),this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("wheel","",this.wheel.bind(this))}}const FL=bu;ut(ut({},bu),{},{mouseOnly:(e=!0)=>e});const r0=new Map,Vy=new Map;function NL(e){r0.set(e.key,e.engine),Vy.set(e.key,e.resolver)}const zL={key:"pinch",engine:DL,resolver:RL},BL={key:"wheel",engine:LL,resolver:FL};function UL(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function HL(e,t){if(e==null)return{};var n=UL(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const KL={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=hr.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},WL=["target","eventOptions","window","enabled","transform"];function nh(e={},t){const n={};for(const[r,o]of Object.entries(t))switch(typeof o){case"function":n[r]=o.call(n,e[r],r,e);break;case"object":n[r]=nh(e[r],o);break;case"boolean":o&&(n[r]=e[r]);break}return n}function GL(e,t,n={}){const r=e,{target:o,eventOptions:s,window:i,enabled:a,transform:c}=r,l=HL(r,WL);if(n.shared=nh({target:o,eventOptions:s,window:i,enabled:a,transform:c},KL),t){const u=Vy.get(t);n[t]=nh(ut({shared:n.shared},l),u)}else for(const u in l){const d=Vy.get(u);d&&(n[u]=nh(ut({shared:n.shared},l[u]),d))}return n}class a_{constructor(t,n){en(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=n}add(t,n,r,o,s){const i=this._listeners,a=dL(n,r),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},l=ut(ut({},c),s);t.addEventListener(a,o,l);const u=()=>{t.removeEventListener(a,o,l),i.delete(u)};return i.add(u),u}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class VL{constructor(){en(this,"_timeouts",new Map)}add(t,n,r=140,...o){this.remove(t),this._timeouts.set(t,window.setTimeout(n,r,...o))}remove(t){const n=this._timeouts.get(t);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(t=>void window.clearTimeout(t)),this._timeouts.clear()}}class YL{constructor(t){en(this,"gestures",new Set),en(this,"_targetEventStore",new a_(this)),en(this,"gestureEventStores",{}),en(this,"gestureTimeoutStores",{}),en(this,"handlers",{}),en(this,"config",{}),en(this,"pointerIds",new Set),en(this,"touchIds",new Set),en(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),XL(this,t)}setEventIds(t){if(t_(t))return this.touchIds=new Set(fL(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,n){this.handlers=t,this.nativeHandlers=n}applyConfig(t,n){this.config=GL(t,n,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const n=this.config.shared,r={};let o;if(!(n.target&&(o=n.target(),!o))){if(n.enabled){for(const i of this.gestures){const a=this.config[i],c=Ab(r,a.eventOptions,!!o);if(a.enabled){const l=r0.get(i);new l(this,t,i).bind(c)}}const s=Ab(r,n.eventOptions,!!o);for(const i in this.nativeHandlers)s(i,"",a=>this.nativeHandlers[i](ut(ut({},this.state.shared),{},{event:a,args:t})),void 0,!0)}for(const s in r)r[s]=yL(...r[s]);if(!o)return r;for(const s in r){const{device:i,capture:a,passive:c}=uL(s);this._targetEventStore.add(o,i,"",r[s],{capture:a,passive:c})}}}}function Qi(e,t){e.gestures.add(t),e.gestureEventStores[t]=new a_(e,t),e.gestureTimeoutStores[t]=new VL}function XL(e,t){t.drag&&Qi(e,"drag"),t.wheel&&Qi(e,"wheel"),t.scroll&&Qi(e,"scroll"),t.move&&Qi(e,"move"),t.pinch&&Qi(e,"pinch"),t.hover&&Qi(e,"hover")}const Ab=(e,t,n)=>(r,o,s,i={},a=!1)=>{var c,l;const u=(c=i.capture)!==null&&c!==void 0?c:t.capture,d=(l=i.passive)!==null&&l!==void 0?l:t.passive;let p=a?r:cL(r,o,u);n&&d&&(p+="Passive"),e[p]=e[p]||[],e[p].push(s)},qL=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function ZL(e){const t={},n={},r=new Set;for(let o in e)qL.test(o)?(r.add(RegExp.lastMatch),n[o]=e[o]):t[o]=e[o];return[n,t,r]}function Ji(e,t,n,r,o,s){if(!e.has(n)||!r0.has(r))return;const i=n+"Start",a=n+"End",c=l=>{let u;return l.first&&i in t&&t[i](l),n in t&&(u=t[n](l)),l.last&&a in t&&t[a](l),u};o[r]=c,s[r]=s[r]||{}}function QL(e,t){const[n,r,o]=ZL(e),s={};return Ji(o,n,"onDrag","drag",s,t),Ji(o,n,"onWheel","wheel",s,t),Ji(o,n,"onScroll","scroll",s,t),Ji(o,n,"onPinch","pinch",s,t),Ji(o,n,"onMove","move",s,t),Ji(o,n,"onHover","hover",s,t),{handlers:s,config:t,nativeHandlers:r}}function JL(e,t={},n,r){const o=Se.useMemo(()=>new YL(e),[]);if(o.applyHandlers(e,r),o.applyConfig(t,n),Se.useEffect(o.effect.bind(o)),Se.useEffect(()=>o.clean.bind(o),[]),t.target===void 0)return o.bind.bind(o)}function e5(e){return e.forEach(NL),function(n,r){const{handlers:o,nativeHandlers:s,config:i}=QL(n,r||{});return JL(o,i,void 0,s)}}const jb=10,t5=/Mac|iPod|iPhone|iPad/.test(typeof window>"u"?"node":window.navigator.platform);function c_(e){let{deltaY:t,deltaX:n}=e,r=0;return e.ctrlKey||e.altKey||e.metaKey?r=(Math.abs(t)>jb?jb*Math.sign(t):t)/100:e.shiftKey&&!t5&&(n=t,t=0),{x:-n,y:-t,z:-r}}const n5=e5([BL,zL]);let ea;const r5=e=>ea===void 0?(ea=e,!1):e-ea>120&&e-ea<160?(ea=e,!0):(ea=e,!1);function o5(e){const t=z(),n=x.useMemo(()=>{let r="not sure";const o=({event:g})=>{if(!t.getInstanceState().isFocused||(r="not sure",r5(Date.now())))return;const w=t.getEditingShapeId();if(w){const P=t.getShape(w);if(P&&t.getShapeUtil(P).canScroll(P)){const C=t.getShapePageBounds(w);if(C!=null&&C.containsPoint(t.inputs.currentPagePoint))return}}ke(g),Kt(g);const S=c_(g);if(S.x===0&&S.y===0)return;const v={type:"wheel",name:"wheel",delta:S,point:new b(g.clientX,g.clientY),shiftKey:g.shiftKey,altKey:g.altKey,ctrlKey:g.metaKey||g.ctrlKey};t.dispatch(v)};let s=1,i=1,a=1,c=0;const l=new b,u=new b,d=g=>{const w=e.current;r="not sure";const{event:S,origin:v,da:P}=g;S instanceof WheelEvent||(S.target===w||w!=null&&w.contains(S.target))&&(u.x=v[0],u.y=v[1],l.x=v[0],l.y=v[1],s=P[0],i=t.getZoomLevel(),t.dispatch({type:"pinch",name:"pinch_start",point:{x:v[0],y:v[1],z:t.getZoomLevel()},delta:{x:0,y:0},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey}))},p=g=>{if(g&&(r="zooming"),r==="zooming")return;const w=Math.abs(c-s),S=b.Dist(l,u);switch(r){case"not sure":{w>24?r="zooming":S>16&&(r="panning");break}case"panning":{w>64&&(r="zooming");break}}};return{onWheel:o,onPinchStart:d,onPinchEnd:g=>{const w=e.current,{event:S,origin:v,offset:P}=g;if(S instanceof WheelEvent||!(S.target===w||w!=null&&w.contains(S.target)))return;const I=P[0];r="not sure",requestAnimationFrame(()=>{t.dispatch({type:"pinch",name:"pinch_end",point:{x:v[0],y:v[1],z:I},delta:{x:v[0],y:v[1]},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey})})},onPinch:g=>{const w=e.current,{event:S,origin:v,offset:P,da:I}=g;if(S instanceof WheelEvent||!(S.target===w||w!=null&&w.contains(S.target)))return;const C=g.type==="gesturechange"||g.type==="gestureend";c=I[0];const E=v[0]-u.x,_=v[1]-u.y;switch(u.x=v[0],u.y=v[1],p(C),r){case"zooming":{a=P[0],t.dispatch({type:"pinch",name:"pinch",point:{x:v[0],y:v[1],z:a},delta:{x:E,y:_},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey});break}case"panning":{t.dispatch({type:"pinch",name:"pinch",point:{x:v[0],y:v[1],z:i},delta:{x:E,y:_},shiftKey:S.shiftKey,altKey:S.altKey,ctrlKey:S.metaKey||S.ctrlKey});break}}}}},[t,e]);n5(n,{target:e,eventOptions:{passive:!1},pinch:{from:()=>[t.getZoomLevel(),0],scaleBounds:()=>({from:t.getZoomLevel(),max:8,min:.05})}})}function Fg(e,t,n){const r=e.getShape(t),o=e.getShapeHandles(r);return{shape:r,handle:o.find(s=>s.id===n)}}function s5(e,t){const n=z();return x.useMemo(()=>{const r=c=>{if(c.isKilled)return;const l=vp(c.currentTarget);xu(l,c);const{shape:u,handle:d}=Fg(n,e,t);d&&n.dispatch({type:"pointer",target:"handle",handle:d,shape:u,name:"pointer_down",..._n(c)})};let o,s;return{onPointerDown:r,onPointerMove:c=>{if(c.isKilled||c.clientX===o&&c.clientY===s)return;o=c.clientX,s=c.clientY;const{shape:l,handle:u}=Fg(n,e,t);u&&n.dispatch({type:"pointer",target:"handle",handle:u,shape:l,name:"pointer_move",..._n(c)})},onPointerUp:c=>{if(c.isKilled)return;const l=vp(c.currentTarget);wu(l,c);const{shape:u,handle:d}=Fg(n,e,t);d&&n.dispatch({type:"pointer",target:"handle",handle:d,shape:u,name:"pointer_up",..._n(c)})}}},[n,e,t])}var l_="Expected a function",Ob=NaN,i5="[object Symbol]",a5=/^\s+|\s+$/g,c5=/^[-+]0x[0-9a-f]+$/i,l5=/^0b[01]+$/i,u5=/^0o[0-7]+$/i,d5=parseInt,h5=typeof on=="object"&&on&&on.Object===Object&&on,p5=typeof self=="object"&&self&&self.Object===Object&&self,f5=h5||p5||Function("return this")(),g5=Object.prototype,m5=g5.toString,y5=Math.max,S5=Math.min,Ng=function(){return f5.Date.now()};function v5(e,t,n){var r,o,s,i,a,c,l=0,u=!1,d=!1,p=!0;if(typeof e!="function")throw new TypeError(l_);t=Db(t)||0,wp(n)&&(u=!!n.leading,d="maxWait"in n,s=d?y5(Db(n.maxWait)||0,t):s,p="trailing"in n?!!n.trailing:p);function f(E){var _=r,k=o;return r=o=void 0,l=E,i=e.apply(k,_),i}function y(E){return l=E,a=setTimeout(S,t),u?f(E):i}function g(E){var _=E-c,k=E-l,$=t-_;return d?S5($,s-k):$}function w(E){var _=E-c,k=E-l;return c===void 0||_>=t||_<0||d&&k>=s}function S(){var E=Ng();if(w(E))return v(E);a=setTimeout(S,g(E))}function v(E){return a=void 0,p&&r?f(E):(r=o=void 0,i)}function P(){a!==void 0&&clearTimeout(a),l=0,r=c=o=a=void 0}function I(){return a===void 0?i:v(Ng())}function C(){var E=Ng(),_=w(E);if(r=arguments,o=this,c=E,_){if(a===void 0)return y(c);if(d)return a=setTimeout(S,t),f(c)}return a===void 0&&(a=setTimeout(S,t)),i}return C.cancel=P,C.flush=I,C}function x5(e,t,n){var r=!0,o=!0;if(typeof e!="function")throw new TypeError(l_);return wp(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),v5(e,t,{leading:r,maxWait:t,trailing:o})}function wp(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function w5(e){return!!e&&typeof e=="object"}function b5(e){return typeof e=="symbol"||w5(e)&&m5.call(e)==i5}function Db(e){if(typeof e=="number")return e;if(b5(e))return Ob;if(wp(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=wp(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(a5,"");var n=l5.test(e);return n||u5.test(e)?d5(e.slice(2),n?2:8):c5.test(e)?Ob:+e}var P5=x5;const C5=lc(P5),nt=class nt{constructor(t=0,n=0,r=0,o=0){m(this,"x",0);m(this,"y",0);m(this,"w",0);m(this,"h",0);this.x=t,this.y=n,this.w=r,this.h=o}get point(){return new b(this.x,this.y)}set point(t){this.x=t.x,this.y=t.y}get minX(){return this.x}set minX(t){this.x=t}get midX(){return this.x+this.w/2}get maxX(){return this.x+this.w}get minY(){return this.y}set minY(t){this.y=t}get midY(){return this.y+this.h/2}get maxY(){return this.y+this.h}get width(){return this.w}set width(t){this.w=t}get height(){return this.h}set height(t){this.h=t}get aspectRatio(){return this.width/this.height}get center(){return new b(this.midX,this.midY)}set center(t){this.minX=t.x-this.width/2,this.minY=t.y-this.height/2}get corners(){return[new b(this.minX,this.minY),new b(this.maxX,this.minY),new b(this.maxX,this.maxY),new b(this.minX,this.maxY)]}get cornersAndCenter(){return[new b(this.minX,this.minY),new b(this.maxX,this.minY),new b(this.maxX,this.maxY),new b(this.minX,this.maxY),this.center]}get sides(){const{corners:t}=this;return[[t[0],t[1]],[t[1],t[2]],[t[2],t[3]],[t[3],t[0]]]}get size(){return new b(this.w,this.h)}toFixed(){return this.x=Ju(this.x),this.y=Ju(this.y),this.w=Ju(this.w),this.h=Ju(this.h),this}setTo(t){return this.x=t.x,this.y=t.y,this.w=t.w,this.h=t.h,this}set(t=0,n=0,r=0,o=0){return this.x=t,this.y=n,this.w=r,this.h=o,this}expand(t){const n=Math.min(this.minX,t.minX),r=Math.min(this.minY,t.minY),o=Math.max(this.maxX,t.maxX),s=Math.max(this.maxY,t.maxY);return this.x=n,this.y=r,this.w=o-n,this.h=s-r,this}expandBy(t){return this.x-=t,this.y-=t,this.w+=t*2,this.h+=t*2,this}scale(t){return this.x/=t,this.y/=t,this.w/=t,this.h/=t,this}clone(){const{x:t,y:n,w:r,h:o}=this;return new nt(t,n,r,o)}translate(t){return this.x+=t.x,this.y+=t.y,this}snapToGrid(t){const n=Math.round(this.minX/t)*t,r=Math.round(this.minY/t)*t,o=Math.round(this.maxX/t)*t,s=Math.round(this.maxY/t)*t;this.minX=n,this.minY=r,this.width=Math.max(1,o-n),this.height=Math.max(1,s-r)}collides(t){return nt.Collides(this,t)}contains(t){return nt.Contains(this,t)}includes(t){return nt.Includes(this,t)}containsPoint(t,n=0){return nt.ContainsPoint(this,t,n)}getHandlePoint(t){switch(t){case"top_left":return new b(this.minX,this.minY);case"top_right":return new b(this.maxX,this.minY);case"bottom_left":return new b(this.minX,this.maxY);case"bottom_right":return new b(this.maxX,this.maxY);case"top":return new b(this.midX,this.minY);case"right":return new b(this.maxX,this.midY);case"bottom":return new b(this.midX,this.maxY);case"left":return new b(this.minX,this.midY)}}toJson(){return{x:this.minX,y:this.minY,w:this.w,h:this.h}}resize(t,n,r){const{minX:o,minY:s,maxX:i,maxY:a}=this;let{minX:c,minY:l,maxX:u,maxY:d}=this;switch(t){case"left":case"top_left":case"bottom_left":{c+=n;break}case"right":case"top_right":case"bottom_right":{u+=n;break}}switch(t){case"top":case"top_left":case"top_right":{l+=r;break}case"bottom":case"bottom_left":case"bottom_right":{d+=r;break}}const p=(u-c)/(i-o),f=(d-l)/(a-s),y=p<0,g=f<0;if(y){const w=u;u=c,c=w}if(g){const w=d;d=l,l=w}this.minX=c,this.minY=l,this.width=Math.abs(u-c),this.height=Math.abs(d-l)}union(t){const n=Math.min(this.minX,t.x),r=Math.min(this.minY,t.y),o=Math.max(this.maxX,t.w+t.x),s=Math.max(this.maxY,t.h+t.y);return this.x=n,this.y=r,this.width=o-n,this.height=s-r,this}static From(t){return new nt(t.x,t.y,t.w,t.h)}static FromCenter(t,n){return new nt(t.x-n.x/2,t.y-n.y/2,n.x,n.y)}static FromPoints(t){if(t.length===0)return new nt;let n=1/0,r=1/0,o=-1/0,s=-1/0,i;for(let a=0,c=t.length;a<c;a++)i=t[a],n=Math.min(i.x,n),r=Math.min(i.y,r),o=Math.max(i.x,o),s=Math.max(i.y,s);return new nt(n,r,o-n,s-r)}static Expand(t,n){const r=Math.min(n.minX,t.minX),o=Math.min(n.minY,t.minY),s=Math.max(n.maxX,t.maxX),i=Math.max(n.maxY,t.maxY);return new nt(r,o,s-r,i-o)}static ExpandBy(t,n){return new nt(t.minX-n,t.minY-n,t.width+n*2,t.height+n*2)}static Resize(t,n,r,o,s=!1){const{minX:i,minY:a,maxX:c,maxY:l}=t;let{minX:u,minY:d,maxX:p,maxY:f}=t;switch(n){case"left":case"top_left":case"bottom_left":{u+=r;break}case"right":case"top_right":case"bottom_right":{p+=r;break}}switch(n){case"top":case"top_left":case"top_right":{d+=o;break}case"bottom":case"bottom_left":case"bottom_right":{f+=o;break}}const y=(p-u)/(c-i),g=(f-d)/(l-a),w=y<0,S=g<0;if(s){const P=(c-i)/(l-a),I=Math.abs(p-u),C=Math.abs(f-d),E=I*(g<0?1:-1)*(1/P),_=C*(y<0?1:-1)*P,k=P<I/C;switch(n){case"top_left":{k?d=f+E:u=p+_;break}case"top_right":{k?d=f+E:p=u-_;break}case"bottom_right":{k?f=d-E:p=u-_;break}case"bottom_left":{k?f=d-E:u=p+_;break}case"bottom":case"top":{const $=(u+p)/2,T=C*P;u=$-T/2,p=$+T/2;break}case"left":case"right":{const $=(d+f)/2,T=I/P;d=$-T/2,f=$+T/2;break}}}if(w){const P=p;p=u,u=P}if(S){const P=f;f=d,d=P}const v=new nt(u,d,Math.abs(p-u),Math.abs(f-d));return{box:v,scaleX:+(v.width/t.width*(y>0?1:-1)).toFixed(5),scaleY:+(v.height/t.height*(g>0?1:-1)).toFixed(5)}}equals(t){return nt.Equals(this,t)}static Equals(t,n){return n.x===t.x&&n.y===t.y&&n.w===t.w&&n.h===t.h}zeroFix(){return this.w=Math.max(1,this.w),this.h=Math.max(1,this.h),this}static ZeroFix(t){return new nt(t.x,t.y,Math.max(1,t.w),Math.max(1,t.h))}};m(nt,"Collides",(t,n)=>!(t.maxX<n.minX||t.minX>n.maxX||t.maxY<n.minY||t.minY>n.maxY)),m(nt,"Contains",(t,n)=>t.minX<n.minX&&t.minY<n.minY&&t.maxY>n.maxY&&t.maxX>n.maxX),m(nt,"Includes",(t,n)=>nt.Collides(t,n)||nt.Contains(t,n)),m(nt,"ContainsPoint",(t,n,r=0)=>!(n.x<t.minX-r||n.y<t.minY-r||n.x>t.maxX+r||n.y>t.maxY+r)),m(nt,"Common",t=>{let n=1/0,r=1/0,o=-1/0,s=-1/0;for(let i=0;i<t.length;i++){const a=t[i];n=Math.min(n,a.minX),r=Math.min(r,a.minY),o=Math.max(o,a.maxX),s=Math.max(s,a.maxY)}return new nt(n,r,o-n,s-r)}),m(nt,"Sides",(t,n=0)=>{const{corners:r}=t;return[[r[0],r[1]],[r[1],r[2]],[r[2],r[3]],[r[3],r[0]]]});let te=nt;function I5(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 E5(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 _5(e){return e==="top_left"||e==="top_right"||e==="bottom_right"||e==="bottom_left"}function k5(e){const t=z();x.useLayoutEffect(()=>{let n=new te;function r(){const l=e.current;if(!l)return null;const u=l.getBoundingClientRect(),d=new te(u.left||u.x,u.top||u.y,Math.max(u.width,1),Math.max(u.height,1));n.equals(d)||(t.updateViewportScreenBounds(d),n=d)}r();const o=C5(r,200,{trailing:!0}),s=setInterval(o,1e3);window.addEventListener("resize",o);const i=new ResizeObserver(l=>{l[0].contentRect&&o()}),a=e.current;let c=null;return a&&(i.observe(a),c=T5(a),c.addEventListener("scroll",o)),()=>{clearInterval(s),window.removeEventListener("resize",o),i.disconnect(),c==null||c.removeEventListener("scroll",o)}},[t,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 T5=e=>{let t=e.parentElement;for(;t;){if(t===document.body)return document;const{overflowY:n}=window.getComputedStyle(t);if(t.scrollHeight>t.clientHeight&&(n==="auto"||n==="scroll"||n==="overlay"))return t;t=t.parentElement}return document},De=class De{constructor(t,n,r,o,s,i){m(this,"a",1);m(this,"b",0);m(this,"c",0);m(this,"d",1);m(this,"e",0);m(this,"f",0);this.a=t,this.b=n,this.c=r,this.d=o,this.e=s,this.f=i}equals(t){return this===t||this.a===t.a&&this.b===t.b&&this.c===t.c&&this.d===t.d&&this.e===t.e&&this.f===t.f}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this}multiply(t){const n=t,{a:r,b:o,c:s,d:i,e:a,f:c}=this;return this.a=r*n.a+s*n.b,this.c=r*n.c+s*n.d,this.e=r*n.e+s*n.f+a,this.b=o*n.a+i*n.b,this.d=o*n.c+i*n.d,this.f=o*n.e+i*n.f+c,this}rotate(t,n,r){return t===0?this:n===void 0?this.multiply(De.Rotate(t)):this.translate(n,r).multiply(De.Rotate(t)).translate(-n,-r)}translate(t,n){return this.multiply(De.Translate(t,n))}scale(t,n){return this.multiply(De.Scale(t,n))}invert(){const{a:t,b:n,c:r,d:o,e:s,f:i}=this,a=t*o-n*r;return this.a=o/a,this.b=n/-a,this.c=r/-a,this.d=t/a,this.e=(o*s-r*i)/-a,this.f=(n*s-t*i)/a,this}applyToPoint(t){return De.applyToPoint(this,t)}applyToPoints(t){return De.applyToPoints(this,t)}rotation(){return De.Rotation(this)}point(){return De.Point(this)}decomposed(){return De.Decompose(this)}toCssString(){return De.toCssString(this)}setTo(t){return Object.assign(this,t),this}decompose(){return De.Decompose(this)}clone(){return new De(this.a,this.b,this.c,this.d,this.e,this.f)}static Identity(){return new De(1,0,0,1,0,0)}static Translate(t,n){return new De(1,0,0,1,t,n)}static Rotate(t,n,r){if(t===0)return De.Identity();const o=Math.cos(t),s=Math.sin(t),i=new De(o,s,-s,o,0,0);return n===void 0?i:De.Compose(De.Translate(n,r),i,De.Translate(-n,-r))}static Multiply(t,n){return{a:t.a*n.a+t.c*n.b,c:t.a*n.c+t.c*n.d,e:t.a*n.e+t.c*n.f+t.e,b:t.b*n.a+t.d*n.b,d:t.b*n.c+t.d*n.d,f:t.b*n.e+t.d*n.f+t.f}}static Inverse(t){const n=t.a*t.d-t.b*t.c;return{a:t.d/n,b:t.b/-n,c:t.c/-n,d:t.a/n,e:(t.d*t.e-t.c*t.f)/-n,f:(t.b*t.e-t.a*t.f)/n}}static Absolute(t){const n=t.a*t.d-t.b*t.c;return{a:t.d/n,b:t.b/-n,c:t.c/-n,d:t.a/n,e:(t.d*t.e-t.c*t.f)/n,f:(t.b*t.e-t.a*t.f)/-n}}static Compose(...t){const n=De.Identity();for(let r=0,o=t.length;r<o;r++)n.multiply(t[r]);return n}static Point(t){return new b(t.e,t.f)}static Rotation(t){let n;if(t.a!==0||t.c!==0){const r=(t.a*t.a+t.c*t.c)**.5;n=Math.acos(t.a/r)*(t.c>0?-1:1)}else if(t.b!==0||t.d!==0){const r=(t.b*t.b+t.d*t.d)**.5;n=Ue+Math.acos(t.b/r)*(t.d>0?-1:1)}else n=0;return Ky(n)}static Decompose(t){let n,r,o;if(t.a!==0||t.c!==0){const s=(t.a*t.a+t.c*t.c)**.5;n=s,r=(t.a*t.d-t.b*t.c)/s,o=Math.acos(t.a/s)*(t.c>0?-1:1)}else if(t.b!==0||t.d!==0){const s=(t.b*t.b+t.d*t.d)**.5;n=(t.a*t.d-t.b*t.c)/s,r=s,o=Ue+Math.acos(t.b/s)*(t.d>0?-1:1)}else n=0,r=0,o=0;return{x:t.e,y:t.f,scaleX:n,scaleY:r,rotation:Ky(o)}}static Smooth(t,n=1e10){return t.a=Math.round(t.a*n)/n,t.b=Math.round(t.b*n)/n,t.c=Math.round(t.c*n)/n,t.d=Math.round(t.d*n)/n,t.e=Math.round(t.e*n)/n,t.f=Math.round(t.f*n)/n,t}static toCssString(t){return`matrix(${j(t.a)}, ${j(t.b)}, ${j(t.c)}, ${j(t.d)}, ${j(t.e)}, ${j(t.f)})`}static applyToPoint(t,n){return new b(t.a*n.x+t.c*n.y+t.e,t.b*n.x+t.d*n.y+t.f,n.z)}static applyToXY(t,n,r){return[t.a*n+t.c*r+t.e,t.b*n+t.d*r+t.f]}static applyToPoints(t,n){return n.map(r=>new b(t.a*r.x+t.c*r.y+t.e,t.b*r.x+t.d*r.y+t.f,r.z))}static applyToBounds(t,n){return new te(t.e+n.minX,t.f+n.minY,n.width,n.height)}static From(t){return new De(t.a,t.b,t.c,t.d,t.e,t.f)}static Cast(t){return t instanceof De?t:De.From(t)}};m(De,"Scale",(t,n,r,o)=>{const s=new De(t,0,0,n,0,0);return r===void 0?s:De.Compose(De.Translate(r,o),s,De.Translate(-r,-o))});let oe=De;function u_(e,t){return t===0?e:u_(t,e%t)}function d_(e){const t=e.toString().split(".")[1];if(!t)return 1;const n=Math.pow(10,t.length),r=parseInt(t,10);return n/u_(r,n)}class Fi{constructor(t){m(this,"isFilled",!1);m(this,"isClosed",!0);m(this,"isLabel",!1);m(this,"debugColor");m(this,"ignore");m(this,"_vertices");m(this,"_bounds");m(this,"_area");this.isFilled=t.isFilled,this.isClosed=t.isClosed,this.isLabel=t.isLabel??!1,this.debugColor=t.debugColor,this.ignore=t.ignore}hitTestPoint(t,n=0,r=!1){return this.isClosed&&(this.isFilled||r)&&Zn(t,this.vertices)?!0:b.Dist2(t,this.nearestPoint(t))<=n*n}distanceToPoint(t,n=!1){return t.dist(this.nearestPoint(t))*(this.isClosed&&(this.isFilled||n)&&Zn(t,this.vertices)?-1:1)}distanceToLineSegment(t,n){if(t.equals(n))return this.distanceToPoint(t);const{vertices:r}=this;let o,s=1/0,i,a,c;for(let l=0;l<r.length;l++)a=r[l],c=b.NearestPointOnLineSegment(t,n,a,!0),i=b.Dist2(a,c),i<s&&(s=i,o=c);if(!o)throw Error("nearest point not found");return this.isClosed&&this.isFilled&&Zn(o,this.vertices)?-s:s}hitTestLineSegment(t,n,r=0){return this.distanceToLineSegment(t,n)<=r}nearestPointOnLineSegment(t,n){const{vertices:r}=this;let o,s=1/0,i,a,c;for(let l=0;l<r.length;l++)a=r[l],c=b.NearestPointOnLineSegment(t,n,a,!0),i=b.Dist2(a,c),i<s&&(s=i,o=c);if(!o)throw Error("nearest point not found");return o}isPointInBounds(t,n=0){const{bounds:r}=this;return!(t.x<r.minX-n||t.y<r.minY-n||t.x>r.maxX+n||t.y>r.maxY+n)}get vertices(){return this._vertices||(this._vertices=this.getVertices()),this._vertices}getBounds(){return te.FromPoints(this.vertices)}get bounds(){return this._bounds||(this._bounds=this.getBounds()),this._bounds}get center(){return this.bounds.center}get area(){return this._area||(this._area=this.getArea()),this._area}getArea(){if(!this.isClosed)return 0;const{vertices:t}=this;let n=0;for(let r=0,o=t.length;r<o;r++){const s=t[r],i=t[(r+1)%o];n+=s.x*i.y-i.x*s.y}return n/2}toSimpleSvgPath(){let t="";const{vertices:n}=this,r=n.length;if(r===0)return t;t+=`M${n[0].x},${n[0].y}`;for(let o=1;o<r;o++)t+=`L${n[o].x},${n[o].y}`;return this.isClosed&&(t+="Z"),t}}class Br extends Fi{constructor(n){super({...n,isClosed:!0,isFilled:!1});m(this,"children",[]);m(this,"ignoredChildren",[]);for(const r of n.children)r.ignore?this.ignoredChildren.push(r):this.children.push(r);if(this.children.length===0)throw Error("Group2d must have at least one child")}getVertices(){return this.children.filter(n=>!n.isLabel).flatMap(n=>n.vertices)}nearestPoint(n){let r=1/0,o;const{children:s}=this;if(s.length===0)throw Error("no children");let i,a;for(const c of s)i=c.nearestPoint(n),a=b.Dist2(i,n),a<r&&(r=a,o=i);if(!o)throw Error("nearest point not found");return o}distanceToPoint(n,r=!1){return Math.min(...this.children.map((o,s)=>o.distanceToPoint(n,r||s>0)))}hitTestPoint(n,r,o){return!!this.children.filter(s=>!s.isLabel).find(s=>s.hitTestPoint(n,r,o))}hitTestLineSegment(n,r,o){return!!this.children.filter(s=>!s.isLabel).find(s=>s.hitTestLineSegment(n,r,o))}getArea(){return this.children[0].area}toSimpleSvgPath(){let n="";for(const o of this.children)n+=o.toSimpleSvgPath();const r=te.FromPoints(this.vertices).corners;for(let o=0,s=r.length;o<s;o++){const i=r[o],a=r[(o-1+s)%s],c=i.dist(a),l=r[(o+1)%s],u=i.dist(l),d=i.clone().lrp(a,4/c),p=i,f=i.clone().lrp(l,4/u);n+=`M${d.x},${d.y} L${p.x},${p.y} L${f.x},${f.y} `}return n}}function $5(e=!0){const[t,n]=x.useState(0),r=z();x.useEffect(()=>{if(!e)return;const o=()=>n(s=>s+1);return r.on("tick",o),()=>{r.off("tick",o)}},[r,e])}const M5=rr(function({showStroke:t=!0,showVertices:n=!0,showClosestPointOnOutline:r=!0}){const o=z();$5(r);const s=o.getZoomLevel(),i=o.getRenderingShapes(),{inputs:{currentPagePoint:a}}=o;return h.jsx("svg",{style:{position:"absolute",pointerEvents:"none",zIndex:999999999,top:0,left:0,overflow:"visible"},children:i.map(c=>{const l=o.getShape(c.id);if(l.type==="group")return null;const u=o.getShapeGeometry(l),d=o.getShapePageTransform(l),p=o.getPointInShapeSpace(l,a),f=u.nearestPoint(p),y=u.distanceToPoint(p,!0),g=Math.abs(y)*s,w=y<0,{vertices:S}=u;return h.jsxs("g",{transform:d.toCssString(),strokeLinecap:"round",strokeLinejoin:"round",children:[t&&h.jsx(h_,{geometry:u}),n&&S.map((v,P)=>h.jsx("circle",{cx:v.x,cy:v.y,r:"2",fill:`hsl(${ep(P,[0,S.length-1],[120,200])}, 100%, 50%)`,stroke:"black",strokeWidth:"1"},`v${P}`)),r&&g<150&&h.jsx("line",{x1:f.x,y1:f.y,x2:p.x,y2:p.y,opacity:1-g/150,stroke:w?"goldenrod":"dodgerblue",strokeWidth:"2"})]},c.id+"_outline")})})});function h_({geometry:e}){return e instanceof Br?h.jsx(h.Fragment,{children:[...e.children,...e.ignoredChildren].map((t,n)=>h.jsx(h_,{geometry:t},n))}):h.jsx("path",{stroke:e.debugColor??"red",strokeWidth:"2",fill:"none",opacity:"1",d:e.toSimpleSvgPath()})}var A5=200,o0="__lodash_hash_undefined__",j5=1/0,O5="[object Function]",D5="[object GeneratorFunction]",R5=/[\\^$.*+?()[\]{}|]/g,L5=/^\[object .+?Constructor\]$/,F5=typeof on=="object"&&on&&on.Object===Object&&on,N5=typeof self=="object"&&self&&self.Object===Object&&self,s0=F5||N5||Function("return this")();function z5(e,t){var n=e?e.length:0;return!!n&&U5(e,t,0)>-1}function B5(e,t,n,r){for(var o=e.length,s=n+-1;++s<o;)if(t(e[s],s,e))return s;return-1}function U5(e,t,n){if(t!==t)return B5(e,H5,n);for(var r=n-1,o=e.length;++r<o;)if(e[r]===t)return r;return-1}function H5(e){return e!==e}function K5(e,t){return e.has(t)}function W5(e,t){return e==null?void 0:e[t]}function G5(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function p_(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var V5=Array.prototype,Y5=Function.prototype,f_=Object.prototype,zg=s0["__core-js_shared__"],Rb=function(){var e=/[^.]+$/.exec(zg&&zg.keys&&zg.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),g_=Y5.toString,i0=f_.hasOwnProperty,X5=f_.toString,q5=RegExp("^"+g_.call(i0).replace(R5,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Z5=V5.splice,Q5=a0(s0,"Map"),Bg=a0(s0,"Set"),Ll=a0(Object,"create");function Ci(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function J5(){this.__data__=Ll?Ll(null):{}}function eF(e){return this.has(e)&&delete this.__data__[e]}function tF(e){var t=this.__data__;if(Ll){var n=t[e];return n===o0?void 0:n}return i0.call(t,e)?t[e]:void 0}function nF(e){var t=this.__data__;return Ll?t[e]!==void 0:i0.call(t,e)}function rF(e,t){var n=this.__data__;return n[e]=Ll&&t===void 0?o0:t,this}Ci.prototype.clear=J5;Ci.prototype.delete=eF;Ci.prototype.get=tF;Ci.prototype.has=nF;Ci.prototype.set=rF;function gc(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function oF(){this.__data__=[]}function sF(e){var t=this.__data__,n=Sf(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Z5.call(t,n,1),!0}function iF(e){var t=this.__data__,n=Sf(t,e);return n<0?void 0:t[n][1]}function aF(e){return Sf(this.__data__,e)>-1}function cF(e,t){var n=this.__data__,r=Sf(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}gc.prototype.clear=oF;gc.prototype.delete=sF;gc.prototype.get=iF;gc.prototype.has=aF;gc.prototype.set=cF;function mc(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function lF(){this.__data__={hash:new Ci,map:new(Q5||gc),string:new Ci}}function uF(e){return vf(this,e).delete(e)}function dF(e){return vf(this,e).get(e)}function hF(e){return vf(this,e).has(e)}function pF(e,t){return vf(this,e).set(e,t),this}mc.prototype.clear=lF;mc.prototype.delete=uF;mc.prototype.get=dF;mc.prototype.has=hF;mc.prototype.set=pF;function bp(e){var t=-1,n=e?e.length:0;for(this.__data__=new mc;++t<n;)this.add(e[t])}function fF(e){return this.__data__.set(e,o0),this}function gF(e){return this.__data__.has(e)}bp.prototype.add=bp.prototype.push=fF;bp.prototype.has=gF;function Sf(e,t){for(var n=e.length;n--;)if(PF(e[n][0],t))return n;return-1}function mF(e){if(!m_(e)||xF(e))return!1;var t=CF(e)||G5(e)?q5:L5;return t.test(wF(e))}function yF(e,t,n){var r=-1,o=z5,s=e.length,i=!0,a=[],c=a;if(s>=A5){var l=SF(e);if(l)return p_(l);i=!1,o=K5,c=new bp}else c=a;e:for(;++r<s;){var u=e[r],d=u;if(u=u!==0?u:0,i&&d===d){for(var p=c.length;p--;)if(c[p]===d)continue e;a.push(u)}else o(c,d,n)||(c!==a&&c.push(d),a.push(u))}return a}var SF=Bg&&1/p_(new Bg([,-0]))[1]==j5?function(e){return new Bg(e)}:IF;function vf(e,t){var n=e.__data__;return vF(t)?n[typeof t=="string"?"string":"hash"]:n.map}function a0(e,t){var n=W5(e,t);return mF(n)?n:void 0}function vF(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function xF(e){return!!Rb&&Rb in e}function wF(e){if(e!=null){try{return g_.call(e)}catch{}try{return e+""}catch{}}return""}function bF(e){return e&&e.length?yF(e):[]}function PF(e,t){return e===t||e!==e&&t!==t}function CF(e){var t=m_(e)?X5.call(e):"";return t==O5||t==D5}function m_(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function IF(){}var EF=bF;const _F=lc(EF);function y_(e){return _F(e)}function kF(){const e=z(),t=RD("userIds",()=>y_(e.getCollaborators().map(n=>n.userId)).sort(),{isEqual:(n,r)=>{var o;return n.join(",")===((o=r.join)==null?void 0:o.call(r,","))}},[e]);return K(t)}function S_(e){const t=z();return K(`latestPresence:${e}`,()=>t.getCollaborators().find(r=>r.userId===e),[t])??null}const TF=rr(function(){const t=kF();return h.jsx(h.Fragment,{children:t.map(n=>h.jsx($F,{collaboratorId:n},n))})}),$F=rr(function({collaboratorId:t}){const n=z(),r=S_(t),o=AF(r);if(!(r&&r.currentPageId===n.getCurrentPageId()))return null;switch(o){case"inactive":{const{followingUserId:s,highlightedUserIds:i}=n.getInstanceState();if(!(s===r.userId||i.includes(r.userId)))return null;break}case"idle":{const{highlightedUserIds:s}=n.getInstanceState();if(r.followingUserId===n.user.getId()&&!(r.chatMessage||s.includes(r.userId)))return null;break}}return h.jsx(MF,{latestPresence:r})}),MF=rr(function({latestPresence:t}){const n=z(),{CollaboratorBrush:r,CollaboratorScribble:o,CollaboratorCursor:s,CollaboratorHint:i,CollaboratorShapeIndicator:a}=pt(),c=n.getZoomLevel(),l=n.getViewportPageBounds(),{userId:u,chatMessage:d,brush:p,scribbles:f,selectedShapeIds:y,userName:g,cursor:w,color:S}=t,v=!(w.x<l.minX-12/c||w.y<l.minY-16/c||w.x>l.maxX-12/c||w.y>l.maxY-16/c);return h.jsxs(h.Fragment,{children:[p&&r?h.jsx(r,{className:"tl-collaborator__brush",brush:p,color:S,opacity:.1},u+"_brush"):null,v&&s?h.jsx(s,{className:"tl-collaborator__cursor",point:w,color:S,zoom:c,name:g!=="New User"?g:null,chatMessage:d},u+"_cursor"):i?h.jsx(i,{className:"tl-collaborator__cursor-hint",point:w,color:S,zoom:c,viewport:l},u+"_cursor_hint"):null,o&&f.length?h.jsx(h.Fragment,{children:f.map(P=>h.jsx(o,{className:"tl-collaborator__scribble",scribble:P,color:S,zoom:c,opacity:P.color==="laser"?.5:.1},u+"_scribble_"+P.id))}):null,a&&y.map(P=>h.jsx(a,{className:"tl-collaborator__shape-indicator",shapeId:P,color:S,opacity:.5},u+"_"+P))]})});function Lb(e){return e>L3?"inactive":e>XE?"idle":"active"}function AF(e){const t=x.useRef((e==null?void 0:e.lastActivityTimestamp)??-1),[n,r]=x.useState(()=>Lb(Date.now()-t.current));return x.useEffect(()=>{const o=setInterval(()=>{r(Lb(Date.now()-t.current))},F3);return()=>clearInterval(o)},[]),e&&(t.current=e.lastActivityTimestamp),n}const v_=x.memo(function({id:t,shape:n,util:r,index:o,backgroundIndex:s,opacity:i,dprMultiple:a}){const c=z(),{ShapeErrorFallback:l}=pt(),u=x.useRef(null),d=x.useRef(null),p=x.useRef({transform:"",clipPath:"none",width:0,height:0,x:0,y:0,isCulled:!1});_s("set shape stuff",()=>{const g=c.getShape(t);if(!g)return;const w=p.current,S=c.getShapeClipPath(t)??"none";S!==w.clipPath&&(Jt(u.current,"clip-path",S),Jt(d.current,"clip-path",S),w.clipPath=S);const v=c.getShapePageTransform(t),P=oe.toCssString(v),I=c.getShapeGeometry(g).bounds;P!==w.transform&&(Jt(u.current,"transform",P),Jt(d.current,"transform",P),w.transform=P);const C=I.w%a,E=I.h%a,_=C===0?I.w:I.w+(a-C),k=E===0?I.h:I.h+(a-E);(_!==w.width||k!==w.height)&&(Jt(u.current,"width",Math.max(_,a)+"px"),Jt(u.current,"height",Math.max(k,a)+"px"),Jt(d.current,"width",Math.max(_,a)+"px"),Jt(d.current,"height",Math.max(k,a)+"px"),w.width=_,w.height=k)},[c]),_s("set opacity and z-index",()=>{const g=u.current,w=d.current;Jt(g,"opacity",i),Jt(w,"opacity",i),Jt(g,"z-index",o),Jt(w,"z-index",s)},[i,o,s]),_s("set display",()=>{if(!c.getShape(t))return;const S=c.getCulledShapes().has(t);S!==p.current.isCulled&&(Jt(u.current,"display",S?"none":"block"),Jt(d.current,"display",S?"none":"block"),p.current.isCulled=S)},[c]);const f=x.useCallback(g=>c.annotateError(g,{origin:"shape",willCrashApp:!1}),[c]);if(!n)return null;const y="fill"in n.props&&n.props.fill!=="none";return h.jsxs(h.Fragment,{children:[r.backgroundComponent&&h.jsx("div",{ref:d,className:"tl-shape tl-shape-background","data-shape-type":n.type,draggable:!1,children:h.jsx(Rl,{fallback:l,onError:f,children:h.jsx(OF,{shape:n,util:r})})}),h.jsx("div",{ref:u,className:"tl-shape","data-shape-type":n.type,"data-shape-is-filled":y,draggable:!1,children:h.jsx(Rl,{fallback:l,onError:f,children:h.jsx(jF,{shape:n,util:r})})})]})}),jF=x.memo(function({shape:t,util:n}){return uf("InnerShape:"+t.type,()=>n.component(t))},(e,t)=>e.shape.props===t.shape.props&&e.shape.meta===t.shape.meta),OF=x.memo(function({shape:t,util:n}){return uf("InnerShape:"+t.type,()=>{var r;return(r=n.backgroundComponent)==null?void 0:r.call(n,t)})},(e,t)=>e.shape.props===t.shape.props&&e.shape.meta===t.shape.meta);function DF({className:e}){const t=z(),{Background:n,SvgDefs:r}=pt(),o=x.useRef(null),s=x.useRef(null),i=x.useRef(null),a=Xt();k5(o),Q3(),q3(),o5(o),tL(o);const c=x.useRef({lodDisableTextOutline:!1,allowTextOutline:!0});_s("position layers",function(){const{x:S,y:v,z:P}=t.getCamera();if(c.current.allowTextOutline&&t.environment.isSafari&&(a.style.setProperty("--tl-text-outline","none"),c.current.allowTextOutline=!1),c.current.allowTextOutline&&P<vb!==c.current.lodDisableTextOutline){const E=P<vb;a.style.setProperty("--tl-text-outline",E?"none":`0 var(--b) 0 var(--color-background), 0 var(--a) 0 var(--color-background),
|
|
48
|
-
var(--b) var(--b) 0 var(--color-background), var(--a) var(--b) 0 var(--color-background),
|
|
49
|
-
var(--a) var(--a) 0 var(--color-background), var(--b) var(--a) 0 var(--color-background)`),c.current.lodDisableTextOutline=E}const I=P>=1?ep(P,[1,8],[.125,.5],!0):ep(P,[.1,1],[-2,.125],!0),C=`scale(${j(P)}) translate(${j(S+I)}px,${j(v+I)}px)`;Jt(s.current,"transform",C),Jt(i.current,"transform",C)},[t,a]);const l=X3(),u=K("shapeSvgDefs",()=>{const w=new Map;for(const S of _t(t.shapeUtils)){if(!S)return;const v=S.getCanvasSvgDefs();for(const{key:P,component:I}of v)w.has(P)||w.set(P,h.jsx(I,{},P))}return[...w.values()]},[t]),d=K("debug_shapes",()=>jt.hideShapes.get(),[jt]),p=K("debug_svg",()=>jt.debugSvg.get(),[jt]),f=K("debug_geometry",()=>jt.debugGeometry.get(),[jt]),y=K("isEditingAnything",()=>t.getEditingShapeId()!==null,[t]),g=K("isSelectingAnything",()=>!!t.getSelectedShapeIds().length,[t]);return h.jsxs("div",{ref:o,draggable:!1,"data-iseditinganything":y,"data-isselectinganything":g,className:ue("tl-canvas",e),"data-testid":"canvas",...l,children:[h.jsx("svg",{className:"tl-svg-context",children:h.jsxs("defs",{children:[u,h.jsx(XF,{}),h.jsx(qF,{}),r&&h.jsx(r,{})]})}),n&&h.jsx("div",{className:"tl-background__wrapper",children:h.jsx(n,{})}),h.jsx(RF,{}),h.jsxs("div",{ref:s,className:"tl-html-layer tl-shapes",draggable:!1,children:[h.jsx(e6,{}),h.jsx(JF,{}),d?null:p?h.jsx(KF,{}):h.jsx(GF,{})]}),h.jsx("div",{className:"tl-overlays",children:h.jsxs("div",{ref:i,className:"tl-html-layer",children:[f?h.jsx(M5,{}):null,h.jsx(BF,{}),h.jsx(FF,{}),h.jsx(LF,{}),h.jsx(NF,{}),h.jsx(VF,{}),h.jsx(YF,{}),h.jsx(zF,{}),h.jsx(QF,{}),h.jsx(TF,{})]})}),h.jsx(t6,{})]})}function RF(){const e=z(),t=K("gridSize",()=>e.getDocumentSettings().gridSize,[e]),{x:n,y:r,z:o}=K("camera",()=>e.getCamera(),[e]),s=K("isGridMode",()=>e.getInstanceState().isGridMode,[e]),{Grid:i}=pt();return i&&s?h.jsx(i,{x:n,y:r,z:o,size:t}):null}function LF(){const e=z(),t=K("scribbles",()=>e.getInstanceState().scribbles,[e]),n=K("zoomLevel",()=>e.getZoomLevel(),[e]),{Scribble:r}=pt();return r&&t.length?h.jsx(h.Fragment,{children:t.map(o=>h.jsx(r,{className:"tl-user-scribble",scribble:o,zoom:n},o.id))}):null}function FF(){const e=z(),t=K("brush",()=>e.getInstanceState().brush,[e]),{Brush:n}=pt();return n&&t?h.jsx(n,{className:"tl-user-brush",brush:t}):null}function NF(){const e=z(),t=K("zoomBrush",()=>e.getInstanceState().zoomBrush,[e]),{ZoomBrush:n}=pt();return n&&t?h.jsx(n,{className:"tl-user-brush tl-zoom-brush",brush:t}):null}function zF(){const e=z(),t=K("snapLines",()=>e.snaps.getIndicators(),[e]),n=K("zoomLevel",()=>e.getZoomLevel(),[e]),{SnapIndicator:r}=pt();return r&&t.length>0?h.jsx(h.Fragment,{children:t.map(o=>h.jsx(r,{className:"tl-user-snapline",line:o,zoom:n},o.id))}):null}function BF(){const e=z(),t=K("handles shapeIdWithHandles",()=>{const{isReadonly:n,isChangingStyle:r}=e.getInstanceState();if(n||r)return!1;const o=e.getOnlySelectedShape();return!o||!e.getShapeHandles(o)?!1:o.id},[e]);return t?h.jsx(UF,{shapeId:t}):null}function UF({shapeId:e}){const t=z(),{Handles:n}=pt(),r=K("zoomLevel",()=>t.getZoomLevel(),[t]),o=K("coarse pointer",()=>t.getInstanceState().isCoarsePointer,[t]),s=K("handles transform",()=>t.getShapePageTransform(e),[t,e]),i=K("handles",()=>{const a=t.getShapeHandles(e);if(!a)return null;const c=(o?qE:ZE)/r*2;return a.filter(l=>l.type!=="virtual"||!a.some(u=>u!==l&&u.type==="vertex"&&b.Dist(l,u)<c)).sort(l=>l.type==="vertex"?1:-1)},[t,r,o,e]);return!n||!i||!s?null:h.jsx(n,{children:h.jsx("g",{transform:oe.toCssString(s),children:i.map(a=>h.jsx(HF,{shapeId:e,handle:a,zoom:r,isCoarse:o},a.id))})})}function HF({shapeId:e,handle:t,zoom:n,isCoarse:r}){const o=s5(e,t.id),{Handle:s}=pt();return s?h.jsx("g",{"aria-label":"handle",transform:`translate(${t.x}, ${t.y})`,...o,children:h.jsx(s,{shapeId:e,handle:t,zoom:n,isCoarse:r})}):null}function KF(){const e=z(),t=K("rendering shapes",()=>e.getRenderingShapes(),[e]),n=K("dpr multiple",()=>d_(Math.floor(e.getInstanceState().devicePixelRatio*100)/100),[e]);return h.jsx(h.Fragment,{children:t.map(r=>h.jsxs(x.Fragment,{children:[h.jsx(v_,{...r,dprMultiple:n}),h.jsx(ZF,{id:r.id})]},r.id+"_fragment"))})}function WF(){const e=z(),t=x.useRef(new Set);return _s("reflow for culled shapes",()=>{const n=e.getCulledShapes();if(t.current.size===n.size&&[...n].every(o=>t.current.has(o)))return;t.current=n;const r=document.getElementsByClassName("tl-canvas");r.length!==0&&r[0].offsetHeight},[e]),null}function GF(){const e=z(),t=K("rendering shapes",()=>e.getRenderingShapes(),[e]),n=K("dpr multiple",()=>d_(Math.floor(e.getInstanceState().devicePixelRatio*100)/100),[e]);return h.jsxs(h.Fragment,{children:[t.map(r=>h.jsx(v_,{...r,dprMultiple:n},r.id+"_shape")),e.environment.isSafari&&h.jsx(WF,{})]})}function VF(){const e=z(),t=K("rendering shapes",()=>e.getRenderingShapes(),[e]),n=x.useRef(new Set),r=K("should display selected ids",()=>{const s=n.current,i=new Set;if(e.isInAny("select.idle","select.brushing","select.scribble_brushing","select.editing_shape","select.pointing_shape","select.pointing_selection","select.pointing_handle")&&!e.getInstanceState().isChangingStyle){const a=e.getSelectedShapeIds();for(const c of a)i.add(c);if(e.isInAny("select.idle","select.editing_shape")){const c=e.getInstanceState();if(c.isHoveringCanvas&&!c.isCoarsePointer){const l=e.getHoveredShapeId();l&&i.add(l)}}}if(s.size!==i.size)return n.current=i,i;for(const a of i)if(!s.has(a))return n.current=i,i;return s},[e]),{ShapeIndicator:o}=pt();return o?h.jsx(h.Fragment,{children:t.map(({id:s})=>h.jsx(o,{shapeId:s,hidden:!r.has(s)},s+"_indicator"))}):null}function YF(){const e=z(),{ShapeIndicator:t}=pt(),n=K("hinting shape ids",()=>Jh(e.getHintingShapeIds()),[e]);return!n.length||!t?null:h.jsx(h.Fragment,{children:n.map(r=>h.jsx(t,{className:"tl-user-indicator__hint",shapeId:r},r+"_hinting"))})}function XF(){return h.jsxs("g",{id:"cursor",children:[h.jsxs("g",{fill:"rgba(0,0,0,.2)",transform:"translate(-11,-11)",children:[h.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),h.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),h.jsxs("g",{fill:"white",transform:"translate(-12,-12)",children:[h.jsx("path",{d:"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z"}),h.jsx("path",{d:"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z"})]}),h.jsxs("g",{fill:"currentColor",transform:"translate(-12,-12)",children:[h.jsx("path",{d:"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z"}),h.jsx("path",{d:"m13 10.814v11.188l2.969-2.866.428-.139h4.768z"})]})]})}function qF(){return h.jsx("path",{id:"cursor_hint",fill:"currentColor",d:"M -2,-5 2,0 -2,5 Z"})}function ZF({id:e}){const t=z(),[n,r]=x.useState(null),o=K("is in root",()=>{const s=t.getShape(e);return(s==null?void 0:s.parentId)===t.getCurrentPageId()},[t,e]);return x.useEffect(()=>{if(!o)return;let s=null;const i=hc("shape to svg",async()=>{const a=Math.random();s=a;const l=t.isShapeOfType(e,"frame")?0:10;let u=t.getShapePageBounds(e);if(!u)return;u=u.clone().expandBy(l);const d=await t.getSvgString([e],{padding:l,background:t.getInstanceState().exportBackground});if(s!==a||!d)return;const p=`data:image/svg+xml;utf8,${encodeURIComponent(d.svg)}`;r({src:p,bounds:u})});return()=>{s=null,i()}},[t,e,o]),!o||!n?null:h.jsx("img",{src:n.src,width:n.bounds.width,height:n.bounds.height,style:{position:"absolute",top:0,left:0,transform:`translate(${n.bounds.x}px, ${n.bounds.maxY+12}px)`,outline:"1px solid black",maxWidth:"none"}})}function QF(){const e=z(),t=K("selection rotation",()=>e.getSelectionRotation(),[e]),n=K("selection bounds",()=>e.getSelectionRotatedPageBounds(),[e]),{SelectionForeground:r}=pt();return!n||!r?null:h.jsx(r,{bounds:n,rotation:t})}function JF(){const e=z(),t=K("selection rotation",()=>e.getSelectionRotation(),[e]),n=K("selection bounds",()=>e.getSelectionRotatedPageBounds(),[e]),{SelectionBackground:r}=pt();return!n||!r?null:h.jsx(r,{bounds:n,rotation:t})}function e6(){const{OnTheCanvas:e}=pt();return e?h.jsx(e,{}):null}function t6(){const e=z(),t=K("camera state",()=>e.getCameraState(),[e]);return h.jsx("div",{className:ue("tl-hit-test-blocker",{"tl-hit-test-blocker__hidden":t==="idle"})})}function n6({className:e,zoom:t,point:n,color:r,viewport:o,opacity:s=1}){const i=x.useRef(null);return fc(i,Mt(n.x,o.minX+5/t,o.maxX-5/t),Mt(n.y,o.minY+5/t,o.maxY-5/t),1/t,b.Angle(o.center,n)),h.jsxs("svg",{ref:i,className:ue("tl-overlays__item",e),children:[h.jsx("use",{href:"#cursor_hint",color:r,strokeWidth:3,stroke:"var(--color-background)"}),h.jsx("use",{href:"#cursor_hint",color:r,opacity:s})]})}const Fb=x.memo(function({className:t,zoom:n,point:r,color:o,name:s,chatMessage:i}){const a=x.useRef(null);return fc(a,r==null?void 0:r.x,r==null?void 0:r.y,1/n),r?h.jsxs("div",{ref:a,className:ue("tl-overlays__item",t),children:[h.jsx("svg",{className:"tl-cursor",children:h.jsx("use",{href:"#cursor",color:o})}),i?h.jsxs(h.Fragment,{children:[s&&h.jsx("div",{className:"tl-nametag-title",style:{color:o},children:s}),h.jsx("div",{className:"tl-nametag-chat",style:{backgroundColor:o},children:i})]}):s&&h.jsx("div",{className:"tl-nametag",style:{backgroundColor:o},children:s})]}):null});function r6({x:e,y:t,z:n,size:r}){return h.jsxs("svg",{className:"tl-grid",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("defs",{children:yb.map(({min:o,mid:s,step:i},a)=>{const c=i*r*n,l=.5+e*n,u=.5+t*n,d=l>0?l%c:c+l%c,p=u>0?u%c:c+u%c,f=n<s?ep(n,[o,s],[0,1]):1;return h.jsx("pattern",{id:`grid-${i}`,width:c,height:c,patternUnits:"userSpaceOnUse",children:h.jsx("circle",{className:"tl-grid-dot",cx:d,cy:p,r:1,opacity:f})},`grid-pattern-${a}`)})}),yb.map(({step:o},s)=>h.jsx("rect",{width:"100%",height:"100%",fill:`url(#grid-${o})`},`grid-rect-${s}`))]})}function o6({handle:e,isCoarse:t,className:n,zoom:r}){const o=(t?qE:ZE)/r;if(e.type==="clone"){const i=3/Math.max(r,.35),a=`M0,${-i} A${i},${i} 0 0,1 0,${i}`,c=H3.indexOf(e.id);return h.jsxs("g",{className:ue(`tl-handle tl-handle__${e.type}`,n),children:[h.jsx("circle",{className:"tl-handle__bg",r:o}),h.jsx("path",{className:"tl-handle__fg",d:a,transform:`rotate(${-90+90*c})`})]})}const s=(e.type==="create"&&t?3:4)/Math.max(r,.35);return h.jsxs("g",{className:ue(`tl-handle tl-handle__${e.type}`,n),children:[h.jsx("circle",{className:"tl-handle__bg",r:o}),h.jsx("circle",{className:"tl-handle__fg",r:s})]})}const s6=({children:e})=>h.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:e});function c0(e,t=!0){const n=e.length;if(n<2)return"";let r=e[0],o=e[1];if(n===2)return`M${_e(r)}L${_e(o)}`;let s="";for(let i=2,a=n-1;i<a;i++)r=e[i],o=e[i+1],s+=In(r,o);return t?`M${In(e[0],e[1])}Q${_e(e[1])}${In(e[1],e[2])}T${s}${In(e[n-1],e[0])}${In(e[0],e[1])}Z`:`M${_e(e[0])}Q${_e(e[1])}${In(e[1],e[2])}${e.length>3?"T":""}${s}L${_e(e[n-1])}`}function Nb({scribble:e,zoom:t,color:n,opacity:r,className:o}){return e.points.length?h.jsx("svg",{className:o&&ue("tl-overlays__item",o),children:h.jsx("path",{className:"tl-scribble",d:c0(e.points,!1),stroke:n??`var(--color-${e.color})`,fill:"none",strokeWidth:8/t,opacity:r??e.opacity})}):null}function x_({bounds:e,rotation:t}){const n=x.useRef(null);return fc(n,e.x,e.y,1,t),x.useLayoutEffect(()=>{const r=n.current;r&&(r.style.width=j(Math.max(1,e.width))+"px",r.style.height=j(Math.max(1,e.height))+"px")},[e.width,e.height]),h.jsx("div",{ref:n,className:"tl-selection__bg",draggable:!1})}function i6({bounds:e,rotation:t}){const n=z(),r=x.useRef(null),o=K("only selected shape",()=>n.getOnlySelectedShape(),[n]),s=o?n.getShapeUtil(o).expandSelectionOutlinePx(o):0;return fc(r,e==null?void 0:e.x,e==null?void 0:e.y,1,t,{x:-s,y:-s}),e=e.clone().expandBy(s).zeroFix(),h.jsx("svg",{ref:r,className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:h.jsx("rect",{className:ue("tl-selection__fg__outline"),width:j(e.width),height:j(e.height)})})}const a6=()=>h.jsx("div",{className:"tl-shape-error-boundary"}),c6=({shape:e,util:t})=>uf("Indicator: "+e.type,()=>t.indicator(e)),l6=({editor:e,id:t})=>{const n=K("shape for indicator",()=>e.store.get(t),[e,t]),{ShapeIndicatorErrorFallback:r}=pt();return!n||n.isLocked?null:h.jsx(Rl,{fallback:r,onError:o=>e.annotateError(o,{origin:"react.shapeIndicator",willCrashApp:!1}),children:h.jsx(c6,{shape:n,util:e.getShapeUtil(n)},n.id)})},zb=x.memo(function({shapeId:t,className:n,color:r,hidden:o,opacity:s}){const i=z(),a=x.useRef(null);return _s("indicator transform",()=>{const c=a.current;if(!c)return;const l=i.getShapePageTransform(t);l&&c.style.setProperty("transform",l.toCssString())},[i,t]),x.useLayoutEffect(()=>{const c=a.current;c&&c.style.setProperty("display",o?"none":"block")},[o]),h.jsx("svg",{ref:a,className:ue("tl-overlays__item",n),children:h.jsx("g",{className:"tl-shape-indicator",stroke:r??"var(--color-selected)",opacity:s,children:h.jsx(l6,{editor:i,id:t})})})}),u6=()=>h.jsx("circle",{cx:4,cy:4,r:8,strokeWidth:"1",stroke:"red"});function d6({points:e,zoom:t}){const n=2.5/t,r=e.reduce((p,f)=>Math.min(p,f.x),1/0),o=e.reduce((p,f)=>Math.max(p,f.x),-1/0),s=e.reduce((p,f)=>Math.min(p,f.y),1/0),i=e.reduce((p,f)=>Math.max(p,f.y),-1/0),a=e.some(p=>p.x===r&&p.y===s);let c,l,u,d;return a?(c=r,l=s,u=o,d=i):(c=r,l=i,u=o,d=s),h.jsxs("g",{className:"tl-snap-indicator",stroke:"lime",children:[h.jsx("line",{x1:c,y1:l,x2:u,y2:d}),e.map((p,f)=>h.jsx("g",{transform:`translate(${p.x},${p.y})`,children:h.jsx("path",{className:"tl-snap-point",d:`M ${-n},${-n} L ${n},${n} M ${-n},${n} L ${n},${-n}`})},f))]})}function h6({gaps:e,direction:t,zoom:n}){const r=3.5/n;let o=[-1/0,1/0],s=null;const i=t==="horizontal";for(const c of e){if(s=$r(o[0],o[1],i?c.startEdge[0].y:c.startEdge[0].x,i?c.startEdge[1].y:c.startEdge[1].x),s)o=s;else continue;if(s=$r(o[0],o[1],i?c.endEdge[0].y:c.endEdge[0].x,i?c.endEdge[1].y:c.endEdge[1].x),s)o=s;else continue}if(o===null)return null;const a=(o[0]+o[1])/2;return h.jsx("g",{className:"tl-snap-indicator",stroke:"cyan",children:e.map(({startEdge:c,endEdge:l},u)=>h.jsx(x.Fragment,{children:i?h.jsxs(h.Fragment,{children:[h.jsx("line",{x1:c[0].x,y1:a-2*r,x2:c[1].x,y2:a+2*r}),h.jsx("line",{x1:l[0].x,y1:a-2*r,x2:l[1].x,y2:a+2*r}),h.jsx("line",{x1:c[0].x,y1:a,x2:l[0].x,y2:a}),h.jsx("line",{x1:(c[0].x+l[0].x)/2,y1:a-r,x2:(c[0].x+l[0].x)/2,y2:a+r})]}):h.jsxs(h.Fragment,{children:[h.jsx("line",{x1:a-2*r,y1:c[0].y,x2:a+2*r,y2:c[1].y}),h.jsx("line",{x1:a-2*r,y1:l[0].y,x2:a+2*r,y2:l[1].y}),h.jsx("line",{x1:a,y1:c[0].y,x2:a,y2:l[0].y}),h.jsx("line",{x1:a-r,y1:(c[0].y+l[0].y)/2,x2:a+r,y2:(c[0].y+l[0].y)/2})]})},u))})}function p6({className:e,line:t,zoom:n}){return h.jsx("svg",{className:ue("tl-overlays__item",e),children:t.type==="points"?h.jsx(d6,{...t,zoom:n}):t.type==="gaps"?h.jsx(h6,{...t,zoom:n}):null})}function f6(){return h.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",children:h.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[h.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"var(--color-text-1)"}),h.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"var(--color-text-1)",children:h.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}const g6=()=>null;function w_(e,t){const n=x.useRef(e);return t(e,n.current)?n.current:(n.current=e,e)}function Yy(e){return w_(e,FD)}function l0(e){return w_(e,WI)}const b_=x.createContext({});function m6({overrides:e={},children:t}){const n=l0(e);return h.jsx(b_.Provider,{value:x.useMemo(()=>({Background:P3,SvgDefs:g6,Brush:ed,ZoomBrush:ed,ScreenshotBrush:ed,CollaboratorBrush:ed,Cursor:Fb,CollaboratorCursor:Fb,CollaboratorHint:n6,CollaboratorShapeIndicator:zb,Grid:r6,Scribble:Nb,SnapIndicator:p6,Handles:s6,Handle:o6,CollaboratorScribble:Nb,ErrorFallback:C_,ShapeErrorFallback:a6,ShapeIndicatorErrorFallback:u6,Spinner:f6,SelectionBackground:x_,SelectionForeground:i6,ShapeIndicator:zb,OnTheCanvas:null,InFrontOfTheCanvas:null,Canvas:DF,...n}),[n]),children:t})}function pt(){return x.useContext(b_)}const u0={openWindow:(e,t)=>window.open(e,t,"noopener noreferrer"),refreshPage:()=>window.location.reload(),hardReset:async()=>{var e;return await((e=window.__tldraw__hardReset)==null?void 0:e.call(window))}};function P_(){u0.hardReset()}function y6(){u0.refreshPage()}const S6="https://github.com/tldraw/tldraw/issues/new";function v6(){}const C_=({error:e,editor:t})=>{const n=x.useRef(null),[r,o]=x.useState(!1),[s,i]=x.useState(!1),[a,c]=x.useState(!1),{Canvas:l}=pt(),u=e instanceof Error?e.message:String(e),d=e instanceof Error?e.stack:null,p=K("isDarkMode",()=>{try{if(t)return t.user.getIsDarkMode()}catch{}return null},[t]),[f,y]=x.useState(null);x.useLayoutEffect(()=>{var C;p!==null&&y(p);let P=(C=n.current)==null?void 0:C.parentElement,I=!1;for(;P;){if(P.classList.contains("tl-theme__dark")||P.classList.contains("tl-theme__light")){I=!0;break}P=P.parentElement}if(I){y(null);return}y(window.matchMedia("(prefers-color-scheme: dark)").matches)},[p]),x.useEffect(()=>{if(s){const P=setTimeout(()=>{i(!1)},2e3);return()=>clearTimeout(P)}},[s]);const g=()=>{const P=document.createElement("textarea");P.value=d??u,document.body.appendChild(P),P.select(),document.execCommand("copy"),P.remove(),i(!0)},w=()=>{y6()},S=async()=>{P_()},v=new URL(S6);return v.searchParams.set("title",u),v.searchParams.set("labels","bug"),v.searchParams.set("body",`Hey, I ran into an error while using tldraw:
|
|
50
|
-
|
|
51
|
-
\`\`\`js
|
|
52
|
-
${d??u}
|
|
53
|
-
\`\`\`
|
|
54
|
-
|
|
55
|
-
My browser: ${navigator.userAgent}`),h.jsxs("div",{ref:n,className:ue("tl-container tl-error-boundary",f===null?"":f?"tl-theme__dark":"tl-theme__light"),children:[h.jsx("div",{className:"tl-error-boundary__overlay"}),t&&h.jsx(KE,{onError:v6,fallback:()=>null,children:h.jsx(yf.Provider,{value:t,children:h.jsx("div",{className:"tl-overlay tl-error-boundary__canvas",children:l?h.jsx(l,{}):null})})}),h.jsx("div",{className:ue("tl-modal","tl-error-boundary__content",{"tl-error-boundary__content__expanded":r&&!a}),children:a?h.jsxs(h.Fragment,{children:[h.jsx("h2",{children:"Are you sure?"}),h.jsx("p",{children:"Resetting your data will delete your drawing and cannot be undone."}),h.jsxs("div",{className:"tl-error-boundary__content__actions",children:[h.jsx("button",{onClick:()=>c(!1),children:"Cancel"}),h.jsx("button",{className:"tl-error-boundary__reset",onClick:S,children:"Reset data"})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("h2",{children:"Something's gone wrong."}),h.jsxs("p",{children:["Sorry, we encountered an error. Please refresh the page to continue. If you keep seeing this error, you can ",h.jsx("a",{href:v.toString(),children:"create a GitHub issue"})," or"," ",h.jsx("a",{href:"https://discord.gg/Cq6cPsTfNy",children:"ask for help on Discord"}),"."]}),r&&h.jsxs(h.Fragment,{children:["Message:",h.jsx("h4",{children:h.jsx("code",{children:u})}),"Stack trace:",h.jsxs("div",{className:"tl-error-boundary__content__error",children:[h.jsx("pre",{children:h.jsx("code",{children:d??u})}),h.jsx("button",{onClick:g,children:s?"Copied!":"Copy"})]})]}),h.jsxs("div",{className:"tl-error-boundary__content__actions",children:[h.jsx("button",{onClick:()=>o(!r),children:r?"Hide details":"Show details"}),h.jsxs("div",{className:"tl-error-boundary__content__actions__group",children:[h.jsx("button",{className:"tl-error-boundary__reset",onClick:()=>c(!0),children:"Reset data"}),h.jsx("button",{className:"tl-error-boundary__refresh",onClick:w,children:"Refresh Page"})]})]})]})})]})};function rt(){return hf()}const I_="TLDRAW_USER_DATA_v3",E_=ve({id:ge,name:ge.nullable().optional(),locale:ge.nullable().optional(),color:ge.nullable().optional(),isDarkMode:we.nullable().optional(),animationSpeed:he.nullable().optional(),edgeScrollSpeed:he.nullable().optional(),isSnapMode:we.nullable().optional(),isWrapMode:we.nullable().optional()}),ua={AddAnimationSpeed:1,AddIsSnapMode:2,MakeFieldsNullable:3,AddEdgeScrollSpeed:4,AddExcalidrawSelectMode:5},d0=Math.max(...Object.values(ua));function x6(e){e.version<ua.AddAnimationSpeed&&(e.user.animationSpeed=1),e.version<ua.AddIsSnapMode&&(e.user.isSnapMode=!1),e.version<ua.MakeFieldsNullable,e.version<ua.AddEdgeScrollSpeed&&(e.user.edgeScrollSpeed=1),e.version<ua.AddExcalidrawSelectMode&&(e.user.isWrapMode=!1),e.version=d0}const Bb=["#FF802B","#EC5E41","#F2555A","#F04F88","#E34BA9","#BD54C6","#9D5BD2","#7B66DC","#02B1CC","#11B3A3","#39B178","#55B467"];function w6(){return Bb[Math.floor(Math.random()*Bb.length)]}function b6(){var e,t;return typeof window>"u"?!1:((t=(e=window.matchMedia)==null?void 0:e.call(window,"(prefers-color-scheme: dark)"))==null?void 0:t.matches)??!1}function P6(){var e,t;return typeof window>"u"?!1:((t=(e=window.matchMedia)==null?void 0:e.call(window,"(prefers-reduced-motion: reduce)"))==null?void 0:t.matches)??!1}const ai=Object.freeze({name:"New User",locale:S3(),color:w6(),isDarkMode:!1,edgeScrollSpeed:1,animationSpeed:P6()?0:1,isSnapMode:!1,isWrapMode:!1});function Ug(){return{id:rt()}}function __(e){if(e===null||typeof e!="object"||!("version"in e)||!("user"in e)||typeof e.version!="number")return Ug();const t=Ge(e);x6(t);try{return E_.validate(t.user)}catch{return Ug()}}function C6(){const e=JSON.parse(Wv(I_)||"null")??null;return __(e)}const Fl=pn("globalUserData",null);function I6(){Gv(I_,JSON.stringify({version:d0,user:Fl.get()}))}function E6(e){E_.validate(e),Fl.set(e),I6(),k6()}const _6=typeof process<"u"&&!1,Da=typeof BroadcastChannel<"u"&&!_6?new BroadcastChannel("tldraw-user-sync"):null;Da==null||Da.addEventListener("message",e=>{const t=e.data;(t==null?void 0:t.type)===T_&&(t==null?void 0:t.origin)!==k_()&&Fl.set(__(t.data))});let Hg=null;function k_(){return Hg===null&&(Hg=rt()),Hg}const T_="tldraw-user-preferences-change";function k6(){Da==null||Da.postMessage({type:T_,origin:k_(),data:{user:$_(),version:d0}})}function $_(){let e=Fl.get();return e||(e=C6(),Fl.set(e)),e}function M_(e={}){return{derivePresenceState:e.derivePresenceState??(()=>G("presence",()=>null)),userPreferences:e.userPreferences??G("userPreferences",()=>$_()),setUserPreferences:e.setUserPreferences??E6}}var A_={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function o(c,l,u){this.fn=c,this.context=l,this.once=u||!1}function s(c,l,u,d,p){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new o(u,d||c,p),y=n?n+l:l;return c._events[y]?c._events[y].fn?c._events[y]=[c._events[y],f]:c._events[y].push(f):(c._events[y]=f,c._eventsCount++),c}function i(c,l){--c._eventsCount===0?c._events=new r:delete c._events[l]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],u,d;if(this._eventsCount===0)return l;for(d in u=this._events)t.call(u,d)&&l.push(n?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},a.prototype.listeners=function(l){var u=n?n+l:l,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var p=0,f=d.length,y=new Array(f);p<f;p++)y[p]=d[p].fn;return y},a.prototype.listenerCount=function(l){var u=n?n+l:l,d=this._events[u];return d?d.fn?1:d.length:0},a.prototype.emit=function(l,u,d,p,f,y){var g=n?n+l:l;if(!this._events[g])return!1;var w=this._events[g],S=arguments.length,v,P;if(w.fn){switch(w.once&&this.removeListener(l,w.fn,void 0,!0),S){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,u),!0;case 3:return w.fn.call(w.context,u,d),!0;case 4:return w.fn.call(w.context,u,d,p),!0;case 5:return w.fn.call(w.context,u,d,p,f),!0;case 6:return w.fn.call(w.context,u,d,p,f,y),!0}for(P=1,v=new Array(S-1);P<S;P++)v[P-1]=arguments[P];w.fn.apply(w.context,v)}else{var I=w.length,C;for(P=0;P<I;P++)switch(w[P].once&&this.removeListener(l,w[P].fn,void 0,!0),S){case 1:w[P].fn.call(w[P].context);break;case 2:w[P].fn.call(w[P].context,u);break;case 3:w[P].fn.call(w[P].context,u,d);break;case 4:w[P].fn.call(w[P].context,u,d,p);break;default:if(!v)for(C=1,v=new Array(S-1);C<S;C++)v[C-1]=arguments[C];w[P].fn.apply(w[P].context,v)}}return!0},a.prototype.on=function(l,u,d){return s(this,l,u,d,!1)},a.prototype.once=function(l,u,d){return s(this,l,u,d,!0)},a.prototype.removeListener=function(l,u,d,p){var f=n?n+l:l;if(!this._events[f])return this;if(!u)return i(this,f),this;var y=this._events[f];if(y.fn)y.fn===u&&(!p||y.once)&&(!d||y.context===d)&&i(this,f);else{for(var g=0,w=[],S=y.length;g<S;g++)(y[g].fn!==u||p&&!y[g].once||d&&y[g].context!==d)&&w.push(y[g]);w.length?this._events[f]=w.length===1?w[0]:w:i(this,f)}return this},a.prototype.removeAllListeners=function(l){var u;return l?(u=n?n+l:l,this._events[u]&&i(this,u)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a})(A_);var T6=A_.exports,j_={exports:{}},sr={},O_={exports:{}},D_={};/**
|
|
56
|
-
* @license React
|
|
57
|
-
* scheduler.production.min.js
|
|
58
|
-
*
|
|
59
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
60
|
-
*
|
|
61
|
-
* This source code is licensed under the MIT license found in the
|
|
62
|
-
* LICENSE file in the root directory of this source tree.
|
|
63
|
-
*/(function(e){function t(H,U){var W=H.length;H.push(U);e:for(;0<W;){var Q=W-1>>>1,le=H[Q];if(0<o(le,U))H[Q]=U,H[W]=le,W=Q;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var U=H[0],W=H.pop();if(W!==U){H[0]=W;e:for(var Q=0,le=H.length,be=le>>>1;Q<be;){var Ae=2*(Q+1)-1,ae=H[Ae],je=Ae+1,Fe=H[je];if(0>o(ae,W))je<le&&0>o(Fe,ae)?(H[Q]=Fe,H[je]=W,Q=je):(H[Q]=ae,H[Ae]=W,Q=Ae);else if(je<le&&0>o(Fe,W))H[Q]=Fe,H[je]=W,Q=je;else break e}}return U}function o(H,U){var W=H.sortIndex-U.sortIndex;return W!==0?W:H.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var i=Date,a=i.now();e.unstable_now=function(){return i.now()-a}}var c=[],l=[],u=1,d=null,p=3,f=!1,y=!1,g=!1,w=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function P(H){for(var U=n(l);U!==null;){if(U.callback===null)r(l);else if(U.startTime<=H)r(l),U.sortIndex=U.expirationTime,t(c,U);else break;U=n(l)}}function I(H){if(g=!1,P(H),!y)if(n(c)!==null)y=!0,X(C);else{var U=n(l);U!==null&&q(I,U.startTime-H)}}function C(H,U){y=!1,g&&(g=!1,S(k),k=-1),f=!0;var W=p;try{for(P(U),d=n(c);d!==null&&(!(d.expirationTime>U)||H&&!A());){var Q=d.callback;if(typeof Q=="function"){d.callback=null,p=d.priorityLevel;var le=Q(d.expirationTime<=U);U=e.unstable_now(),typeof le=="function"?d.callback=le:d===n(c)&&r(c),P(U)}else r(c);d=n(c)}if(d!==null)var be=!0;else{var Ae=n(l);Ae!==null&&q(I,Ae.startTime-U),be=!1}return be}finally{d=null,p=W,f=!1}}var E=!1,_=null,k=-1,$=5,T=-1;function A(){return!(e.unstable_now()-T<$)}function B(){if(_!==null){var H=e.unstable_now();T=H;var U=!0;try{U=_(!0,H)}finally{U?L():(E=!1,_=null)}}else E=!1}var L;if(typeof v=="function")L=function(){v(B)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,N=R.port2;R.port1.onmessage=B,L=function(){N.postMessage(null)}}else L=function(){w(B,0)};function X(H){_=H,E||(E=!0,L())}function q(H,U){k=w(function(){H(e.unstable_now())},U)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(H){H.callback=null},e.unstable_continueExecution=function(){y||f||(y=!0,X(C))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(H){switch(p){case 1:case 2:case 3:var U=3;break;default:U=p}var W=p;p=U;try{return H()}finally{p=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,U){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var W=p;p=H;try{return U()}finally{p=W}},e.unstable_scheduleCallback=function(H,U,W){var Q=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?Q+W:Q):W=Q,H){case 1:var le=-1;break;case 2:le=250;break;case 5:le=1073741823;break;case 4:le=1e4;break;default:le=5e3}return le=W+le,H={id:u++,callback:U,priorityLevel:H,startTime:W,expirationTime:le,sortIndex:-1},W>Q?(H.sortIndex=W,t(l,H),n(c)===null&&H===n(l)&&(g?(S(k),k=-1):g=!0,q(I,W-Q))):(H.sortIndex=le,t(c,H),y||f||(y=!0,X(C))),H},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(H){var U=p;return function(){var W=p;p=U;try{return H.apply(this,arguments)}finally{p=W}}}})(D_);O_.exports=D_;var $6=O_.exports;/**
|
|
64
|
-
* @license React
|
|
65
|
-
* react-dom.production.min.js
|
|
66
|
-
*
|
|
67
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the MIT license found in the
|
|
70
|
-
* LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/var M6=x,nr=$6;function Y(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var R_=new Set,Nl={};function Ni(e,t){Xa(e,t),Xa(e+"Capture",t)}function Xa(e,t){for(Nl[e]=t,e=0;e<t.length;e++)R_.add(t[e])}var Ho=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xy=Object.prototype.hasOwnProperty,A6=/^[: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]*$/,Ub={},Hb={};function j6(e){return Xy.call(Hb,e)?!0:Xy.call(Ub,e)?!1:A6.test(e)?Hb[e]=!0:(Ub[e]=!0,!1)}function O6(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function D6(e,t,n,r){if(t===null||typeof t>"u"||O6(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function vn(e,t,n,r,o,s,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=i}var Vt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Vt[e]=new vn(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Vt[t]=new vn(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Vt[e]=new vn(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Vt[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){Vt[e]=new vn(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Vt[e]=new vn(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Vt[e]=new vn(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Vt[e]=new vn(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Vt[e]=new vn(e,5,!1,e.toLowerCase(),null,!1,!1)});var h0=/[\-:]([a-z])/g;function p0(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(h0,p0);Vt[t]=new vn(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(h0,p0);Vt[t]=new vn(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(h0,p0);Vt[t]=new vn(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Vt[e]=new vn(e,1,!1,e.toLowerCase(),null,!1,!1)});Vt.xlinkHref=new vn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Vt[e]=new vn(e,1,!1,e.toLowerCase(),null,!0,!0)});function f0(e,t,n,r){var o=Vt.hasOwnProperty(t)?Vt[t]:null;(o!==null?o.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(D6(t,n,o,r)&&(n=null),r||o===null?j6(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):o.mustUseProperty?e[o.propertyName]=n===null?o.type===3?!1:"":n:(t=o.attributeName,r=o.attributeNamespace,n===null?e.removeAttribute(t):(o=o.type,n=o===3||o===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var es=M6.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,rd=Symbol.for("react.element"),ma=Symbol.for("react.portal"),ya=Symbol.for("react.fragment"),g0=Symbol.for("react.strict_mode"),qy=Symbol.for("react.profiler"),L_=Symbol.for("react.provider"),F_=Symbol.for("react.context"),m0=Symbol.for("react.forward_ref"),Zy=Symbol.for("react.suspense"),Qy=Symbol.for("react.suspense_list"),y0=Symbol.for("react.memo"),ys=Symbol.for("react.lazy"),N_=Symbol.for("react.offscreen"),Kb=Symbol.iterator;function Fc(e){return e===null||typeof e!="object"?null:(e=Kb&&e[Kb]||e["@@iterator"],typeof e=="function"?e:null)}var ft=Object.assign,Kg;function al(e){if(Kg===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Kg=t&&t[1]||""}return`
|
|
72
|
-
`+Kg+e}var Wg=!1;function Gg(e,t){if(!e||Wg)return"";Wg=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(l){var r=l}Reflect.construct(e,[],t)}else{try{t.call()}catch(l){r=l}e.call(t.prototype)}else{try{throw Error()}catch(l){r=l}e()}}catch(l){if(l&&r&&typeof l.stack=="string"){for(var o=l.stack.split(`
|
|
73
|
-
`),s=r.stack.split(`
|
|
74
|
-
`),i=o.length-1,a=s.length-1;1<=i&&0<=a&&o[i]!==s[a];)a--;for(;1<=i&&0<=a;i--,a--)if(o[i]!==s[a]){if(i!==1||a!==1)do if(i--,a--,0>a||o[i]!==s[a]){var c=`
|
|
75
|
-
`+o[i].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=i&&0<=a);break}}}finally{Wg=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?al(e):""}function R6(e){switch(e.tag){case 5:return al(e.type);case 16:return al("Lazy");case 13:return al("Suspense");case 19:return al("SuspenseList");case 0:case 2:case 15:return e=Gg(e.type,!1),e;case 11:return e=Gg(e.type.render,!1),e;case 1:return e=Gg(e.type,!0),e;default:return""}}function Jy(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case ya:return"Fragment";case ma:return"Portal";case qy:return"Profiler";case g0:return"StrictMode";case Zy:return"Suspense";case Qy:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case F_:return(e.displayName||"Context")+".Consumer";case L_:return(e._context.displayName||"Context")+".Provider";case m0:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case y0:return t=e.displayName||null,t!==null?t:Jy(e.type)||"Memo";case ys:t=e._payload,e=e._init;try{return Jy(e(t))}catch{}}return null}function L6(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Jy(t);case 8:return t===g0?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Ns(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function z_(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function F6(e){var t=z_(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(i){r=""+i,s.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function od(e){e._valueTracker||(e._valueTracker=F6(e))}function B_(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=z_(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Pp(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 eS(e,t){var n=t.checked;return ft({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Wb(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Ns(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function U_(e,t){t=t.checked,t!=null&&f0(e,"checked",t,!1)}function tS(e,t){U_(e,t);var n=Ns(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?nS(e,t.type,n):t.hasOwnProperty("defaultValue")&&nS(e,t.type,Ns(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Gb(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function nS(e,t,n){(t!=="number"||Pp(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var cl=Array.isArray;function Ra(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o<n.length;o++)t["$"+n[o]]=!0;for(n=0;n<e.length;n++)o=t.hasOwnProperty("$"+e[n].value),e[n].selected!==o&&(e[n].selected=o),o&&r&&(e[n].defaultSelected=!0)}else{for(n=""+Ns(n),t=null,o=0;o<e.length;o++){if(e[o].value===n){e[o].selected=!0,r&&(e[o].defaultSelected=!0);return}t!==null||e[o].disabled||(t=e[o])}t!==null&&(t.selected=!0)}}function rS(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Y(91));return ft({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Vb(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Y(92));if(cl(n)){if(1<n.length)throw Error(Y(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Ns(n)}}function H_(e,t){var n=Ns(t.value),r=Ns(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Yb(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function K_(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 oS(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?K_(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var sd,W_=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,o){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,o)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(sd=sd||document.createElement("div"),sd.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=sd.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function zl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Sl={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},N6=["Webkit","ms","Moz","O"];Object.keys(Sl).forEach(function(e){N6.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Sl[t]=Sl[e]})});function G_(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Sl.hasOwnProperty(e)&&Sl[e]?(""+t).trim():t+"px"}function V_(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=G_(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var z6=ft({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 sS(e,t){if(t){if(z6[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Y(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Y(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Y(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Y(62))}}function iS(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var aS=null;function S0(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var cS=null,La=null,Fa=null;function Xb(e){if(e=Eu(e)){if(typeof cS!="function")throw Error(Y(280));var t=e.stateNode;t&&(t=Cf(t),cS(e.stateNode,e.type,t))}}function Y_(e){La?Fa?Fa.push(e):Fa=[e]:La=e}function X_(){if(La){var e=La,t=Fa;if(Fa=La=null,Xb(e),t)for(e=0;e<t.length;e++)Xb(t[e])}}function q_(e,t){return e(t)}function Z_(){}var Vg=!1;function Q_(e,t,n){if(Vg)return e(t,n);Vg=!0;try{return q_(e,t,n)}finally{Vg=!1,(La!==null||Fa!==null)&&(Z_(),X_())}}function Bl(e,t){var n=e.stateNode;if(n===null)return null;var r=Cf(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(Y(231,t,typeof n));return n}var lS=!1;if(Ho)try{var Nc={};Object.defineProperty(Nc,"passive",{get:function(){lS=!0}}),window.addEventListener("test",Nc,Nc),window.removeEventListener("test",Nc,Nc)}catch{lS=!1}function B6(e,t,n,r,o,s,i,a,c){var l=Array.prototype.slice.call(arguments,3);try{t.apply(n,l)}catch(u){this.onError(u)}}var vl=!1,Cp=null,Ip=!1,uS=null,U6={onError:function(e){vl=!0,Cp=e}};function H6(e,t,n,r,o,s,i,a,c){vl=!1,Cp=null,B6.apply(U6,arguments)}function K6(e,t,n,r,o,s,i,a,c){if(H6.apply(this,arguments),vl){if(vl){var l=Cp;vl=!1,Cp=null}else throw Error(Y(198));Ip||(Ip=!0,uS=l)}}function zi(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function J_(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function qb(e){if(zi(e)!==e)throw Error(Y(188))}function W6(e){var t=e.alternate;if(!t){if(t=zi(e),t===null)throw Error(Y(188));return t!==e?null:e}for(var n=e,r=t;;){var o=n.return;if(o===null)break;var s=o.alternate;if(s===null){if(r=o.return,r!==null){n=r;continue}break}if(o.child===s.child){for(s=o.child;s;){if(s===n)return qb(o),e;if(s===r)return qb(o),t;s=s.sibling}throw Error(Y(188))}if(n.return!==r.return)n=o,r=s;else{for(var i=!1,a=o.child;a;){if(a===n){i=!0,n=o,r=s;break}if(a===r){i=!0,r=o,n=s;break}a=a.sibling}if(!i){for(a=s.child;a;){if(a===n){i=!0,n=s,r=o;break}if(a===r){i=!0,r=s,n=o;break}a=a.sibling}if(!i)throw Error(Y(189))}}if(n.alternate!==r)throw Error(Y(190))}if(n.tag!==3)throw Error(Y(188));return n.stateNode.current===n?e:t}function ek(e){return e=W6(e),e!==null?tk(e):null}function tk(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=tk(e);if(t!==null)return t;e=e.sibling}return null}var nk=nr.unstable_scheduleCallback,Zb=nr.unstable_cancelCallback,G6=nr.unstable_shouldYield,V6=nr.unstable_requestPaint,wt=nr.unstable_now,Y6=nr.unstable_getCurrentPriorityLevel,v0=nr.unstable_ImmediatePriority,rk=nr.unstable_UserBlockingPriority,Ep=nr.unstable_NormalPriority,X6=nr.unstable_LowPriority,ok=nr.unstable_IdlePriority,xf=null,oo=null;function q6(e){if(oo&&typeof oo.onCommitFiberRoot=="function")try{oo.onCommitFiberRoot(xf,e,void 0,(e.current.flags&128)===128)}catch{}}var Lr=Math.clz32?Math.clz32:J6,Z6=Math.log,Q6=Math.LN2;function J6(e){return e>>>=0,e===0?32:31-(Z6(e)/Q6|0)|0}var id=64,ad=4194304;function ll(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 _p(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,s=e.pingedLanes,i=n&268435455;if(i!==0){var a=i&~o;a!==0?r=ll(a):(s&=i,s!==0&&(r=ll(s)))}else i=n&~o,i!==0?r=ll(i):s!==0&&(r=ll(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,s=t&-t,o>=s||o===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Lr(t),o=1<<n,r|=e[n],t&=~o;return r}function eN(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function tN(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,o=e.expirationTimes,s=e.pendingLanes;0<s;){var i=31-Lr(s),a=1<<i,c=o[i];c===-1?(!(a&n)||a&r)&&(o[i]=eN(a,t)):c<=t&&(e.expiredLanes|=a),s&=~a}}function dS(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function sk(){var e=id;return id<<=1,!(id&4194240)&&(id=64),e}function Yg(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Cu(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Lr(t),e[t]=n}function nN(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var o=31-Lr(n),s=1<<o;t[o]=0,r[o]=-1,e[o]=-1,n&=~s}}function x0(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Lr(n),o=1<<r;o&t|e[r]&t&&(e[r]|=t),n&=~o}}var ze=0;function ik(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var ak,w0,ck,lk,uk,hS=!1,cd=[],Ts=null,$s=null,Ms=null,Ul=new Map,Hl=new Map,xs=[],rN="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 Qb(e,t){switch(e){case"focusin":case"focusout":Ts=null;break;case"dragenter":case"dragleave":$s=null;break;case"mouseover":case"mouseout":Ms=null;break;case"pointerover":case"pointerout":Ul.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Hl.delete(t.pointerId)}}function zc(e,t,n,r,o,s){return e===null||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:s,targetContainers:[o]},t!==null&&(t=Eu(t),t!==null&&w0(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,o!==null&&t.indexOf(o)===-1&&t.push(o),e)}function oN(e,t,n,r,o){switch(t){case"focusin":return Ts=zc(Ts,e,t,n,r,o),!0;case"dragenter":return $s=zc($s,e,t,n,r,o),!0;case"mouseover":return Ms=zc(Ms,e,t,n,r,o),!0;case"pointerover":var s=o.pointerId;return Ul.set(s,zc(Ul.get(s)||null,e,t,n,r,o)),!0;case"gotpointercapture":return s=o.pointerId,Hl.set(s,zc(Hl.get(s)||null,e,t,n,r,o)),!0}return!1}function dk(e){var t=fi(e.target);if(t!==null){var n=zi(t);if(n!==null){if(t=n.tag,t===13){if(t=J_(n),t!==null){e.blockedOn=t,uk(e.priority,function(){ck(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function rh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=pS(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);aS=r,n.target.dispatchEvent(r),aS=null}else return t=Eu(n),t!==null&&w0(t),e.blockedOn=n,!1;t.shift()}return!0}function Jb(e,t,n){rh(e)&&n.delete(t)}function sN(){hS=!1,Ts!==null&&rh(Ts)&&(Ts=null),$s!==null&&rh($s)&&($s=null),Ms!==null&&rh(Ms)&&(Ms=null),Ul.forEach(Jb),Hl.forEach(Jb)}function Bc(e,t){e.blockedOn===t&&(e.blockedOn=null,hS||(hS=!0,nr.unstable_scheduleCallback(nr.unstable_NormalPriority,sN)))}function Kl(e){function t(o){return Bc(o,e)}if(0<cd.length){Bc(cd[0],e);for(var n=1;n<cd.length;n++){var r=cd[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Ts!==null&&Bc(Ts,e),$s!==null&&Bc($s,e),Ms!==null&&Bc(Ms,e),Ul.forEach(t),Hl.forEach(t),n=0;n<xs.length;n++)r=xs[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<xs.length&&(n=xs[0],n.blockedOn===null);)dk(n),n.blockedOn===null&&xs.shift()}var Na=es.ReactCurrentBatchConfig,kp=!0;function iN(e,t,n,r){var o=ze,s=Na.transition;Na.transition=null;try{ze=1,b0(e,t,n,r)}finally{ze=o,Na.transition=s}}function aN(e,t,n,r){var o=ze,s=Na.transition;Na.transition=null;try{ze=4,b0(e,t,n,r)}finally{ze=o,Na.transition=s}}function b0(e,t,n,r){if(kp){var o=pS(e,t,n,r);if(o===null)om(e,t,r,Tp,n),Qb(e,r);else if(oN(o,e,t,n,r))r.stopPropagation();else if(Qb(e,r),t&4&&-1<rN.indexOf(e)){for(;o!==null;){var s=Eu(o);if(s!==null&&ak(s),s=pS(e,t,n,r),s===null&&om(e,t,r,Tp,n),s===o)break;o=s}o!==null&&r.stopPropagation()}else om(e,t,r,null,n)}}var Tp=null;function pS(e,t,n,r){if(Tp=null,e=S0(r),e=fi(e),e!==null)if(t=zi(e),t===null)e=null;else if(n=t.tag,n===13){if(e=J_(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Tp=e,null}function hk(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(Y6()){case v0:return 1;case rk:return 4;case Ep:case X6:return 16;case ok:return 536870912;default:return 16}default:return 16}}var Ps=null,P0=null,oh=null;function pk(){if(oh)return oh;var e,t=P0,n=t.length,r,o="value"in Ps?Ps.value:Ps.textContent,s=o.length;for(e=0;e<n&&t[e]===o[e];e++);var i=n-e;for(r=1;r<=i&&t[n-r]===o[s-r];r++);return oh=o.slice(e,1<r?1-r:void 0)}function sh(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function ld(){return!0}function e1(){return!1}function ir(e){function t(n,r,o,s,i){this._reactName=n,this._targetInst=o,this.type=r,this.nativeEvent=s,this.target=i,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(s):s[a]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?ld:e1,this.isPropagationStopped=e1,this}return ft(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=ld)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=ld)},persist:function(){},isPersistent:ld}),t}var yc={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},C0=ir(yc),Iu=ft({},yc,{view:0,detail:0}),cN=ir(Iu),Xg,qg,Uc,wf=ft({},Iu,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:I0,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Uc&&(Uc&&e.type==="mousemove"?(Xg=e.screenX-Uc.screenX,qg=e.screenY-Uc.screenY):qg=Xg=0,Uc=e),Xg)},movementY:function(e){return"movementY"in e?e.movementY:qg}}),t1=ir(wf),lN=ft({},wf,{dataTransfer:0}),uN=ir(lN),dN=ft({},Iu,{relatedTarget:0}),Zg=ir(dN),hN=ft({},yc,{animationName:0,elapsedTime:0,pseudoElement:0}),pN=ir(hN),fN=ft({},yc,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),gN=ir(fN),mN=ft({},yc,{data:0}),n1=ir(mN),yN={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},SN={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"},vN={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function xN(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=vN[e])?!!t[e]:!1}function I0(){return xN}var wN=ft({},Iu,{key:function(e){if(e.key){var t=yN[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=sh(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?SN[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:I0,charCode:function(e){return e.type==="keypress"?sh(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?sh(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),bN=ir(wN),PN=ft({},wf,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),r1=ir(PN),CN=ft({},Iu,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:I0}),IN=ir(CN),EN=ft({},yc,{propertyName:0,elapsedTime:0,pseudoElement:0}),_N=ir(EN),kN=ft({},wf,{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}),TN=ir(kN),$N=[9,13,27,32],E0=Ho&&"CompositionEvent"in window,xl=null;Ho&&"documentMode"in document&&(xl=document.documentMode);var MN=Ho&&"TextEvent"in window&&!xl,fk=Ho&&(!E0||xl&&8<xl&&11>=xl),o1=" ",s1=!1;function gk(e,t){switch(e){case"keyup":return $N.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function mk(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Sa=!1;function AN(e,t){switch(e){case"compositionend":return mk(t);case"keypress":return t.which!==32?null:(s1=!0,o1);case"textInput":return e=t.data,e===o1&&s1?null:e;default:return null}}function jN(e,t){if(Sa)return e==="compositionend"||!E0&&gk(e,t)?(e=pk(),oh=P0=Ps=null,Sa=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return fk&&t.locale!=="ko"?null:t.data;default:return null}}var ON={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 i1(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!ON[e.type]:t==="textarea"}function yk(e,t,n,r){Y_(r),t=$p(t,"onChange"),0<t.length&&(n=new C0("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var wl=null,Wl=null;function DN(e){kk(e,0)}function bf(e){var t=wa(e);if(B_(t))return e}function RN(e,t){if(e==="change")return t}var Sk=!1;if(Ho){var Qg;if(Ho){var Jg="oninput"in document;if(!Jg){var a1=document.createElement("div");a1.setAttribute("oninput","return;"),Jg=typeof a1.oninput=="function"}Qg=Jg}else Qg=!1;Sk=Qg&&(!document.documentMode||9<document.documentMode)}function c1(){wl&&(wl.detachEvent("onpropertychange",vk),Wl=wl=null)}function vk(e){if(e.propertyName==="value"&&bf(Wl)){var t=[];yk(t,Wl,e,S0(e)),Q_(DN,t)}}function LN(e,t,n){e==="focusin"?(c1(),wl=t,Wl=n,wl.attachEvent("onpropertychange",vk)):e==="focusout"&&c1()}function FN(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return bf(Wl)}function NN(e,t){if(e==="click")return bf(t)}function zN(e,t){if(e==="input"||e==="change")return bf(t)}function BN(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ur=typeof Object.is=="function"?Object.is:BN;function Gl(e,t){if(Ur(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var o=n[r];if(!Xy.call(t,o)||!Ur(e[o],t[o]))return!1}return!0}function l1(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function u1(e,t){var n=l1(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=l1(n)}}function xk(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?xk(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function wk(){for(var e=window,t=Pp();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Pp(e.document)}return t}function _0(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function UN(e){var t=wk(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&xk(n.ownerDocument.documentElement,n)){if(r!==null&&_0(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,s=Math.min(r.start,o);r=r.end===void 0?s:Math.min(r.end,o),!e.extend&&s>r&&(o=r,r=s,s=o),o=u1(n,s);var i=u1(n,r);o&&i&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var HN=Ho&&"documentMode"in document&&11>=document.documentMode,va=null,fS=null,bl=null,gS=!1;function d1(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;gS||va==null||va!==Pp(r)||(r=va,"selectionStart"in r&&_0(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}),bl&&Gl(bl,r)||(bl=r,r=$p(fS,"onSelect"),0<r.length&&(t=new C0("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=va)))}function ud(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var xa={animationend:ud("Animation","AnimationEnd"),animationiteration:ud("Animation","AnimationIteration"),animationstart:ud("Animation","AnimationStart"),transitionend:ud("Transition","TransitionEnd")},em={},bk={};Ho&&(bk=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 Pf(e){if(em[e])return em[e];if(!xa[e])return e;var t=xa[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in bk)return em[e]=t[n];return e}var Pk=Pf("animationend"),Ck=Pf("animationiteration"),Ik=Pf("animationstart"),Ek=Pf("transitionend"),_k=new Map,h1="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 Gs(e,t){_k.set(e,t),Ni(t,[e])}for(var tm=0;tm<h1.length;tm++){var nm=h1[tm],KN=nm.toLowerCase(),WN=nm[0].toUpperCase()+nm.slice(1);Gs(KN,"on"+WN)}Gs(Pk,"onAnimationEnd");Gs(Ck,"onAnimationIteration");Gs(Ik,"onAnimationStart");Gs("dblclick","onDoubleClick");Gs("focusin","onFocus");Gs("focusout","onBlur");Gs(Ek,"onTransitionEnd");Xa("onMouseEnter",["mouseout","mouseover"]);Xa("onMouseLeave",["mouseout","mouseover"]);Xa("onPointerEnter",["pointerout","pointerover"]);Xa("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 ul="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(" "),GN=new Set("cancel close invalid load scroll toggle".split(" ").concat(ul));function p1(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,K6(r,t,void 0,e),e.currentTarget=null}function kk(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],o=r.event;r=r.listeners;e:{var s=void 0;if(t)for(var i=r.length-1;0<=i;i--){var a=r[i],c=a.instance,l=a.currentTarget;if(a=a.listener,c!==s&&o.isPropagationStopped())break e;p1(o,a,l),s=c}else for(i=0;i<r.length;i++){if(a=r[i],c=a.instance,l=a.currentTarget,a=a.listener,c!==s&&o.isPropagationStopped())break e;p1(o,a,l),s=c}}}if(Ip)throw e=uS,Ip=!1,uS=null,e}function tt(e,t){var n=t[xS];n===void 0&&(n=t[xS]=new Set);var r=e+"__bubble";n.has(r)||(Tk(t,e,2,!1),n.add(r))}function rm(e,t,n){var r=0;t&&(r|=4),Tk(n,e,r,t)}var dd="_reactListening"+Math.random().toString(36).slice(2);function Vl(e){if(!e[dd]){e[dd]=!0,R_.forEach(function(n){n!=="selectionchange"&&(GN.has(n)||rm(n,!1,e),rm(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[dd]||(t[dd]=!0,rm("selectionchange",!1,t))}}function Tk(e,t,n,r){switch(hk(t)){case 1:var o=iN;break;case 4:o=aN;break;default:o=b0}n=o.bind(null,t,n,e),o=void 0,!lS||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(o=!0),r?o!==void 0?e.addEventListener(t,n,{capture:!0,passive:o}):e.addEventListener(t,n,!0):o!==void 0?e.addEventListener(t,n,{passive:o}):e.addEventListener(t,n,!1)}function om(e,t,n,r,o){var s=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var i=r.tag;if(i===3||i===4){var a=r.stateNode.containerInfo;if(a===o||a.nodeType===8&&a.parentNode===o)break;if(i===4)for(i=r.return;i!==null;){var c=i.tag;if((c===3||c===4)&&(c=i.stateNode.containerInfo,c===o||c.nodeType===8&&c.parentNode===o))return;i=i.return}for(;a!==null;){if(i=fi(a),i===null)return;if(c=i.tag,c===5||c===6){r=s=i;continue e}a=a.parentNode}}r=r.return}Q_(function(){var l=s,u=S0(n),d=[];e:{var p=_k.get(e);if(p!==void 0){var f=C0,y=e;switch(e){case"keypress":if(sh(n)===0)break e;case"keydown":case"keyup":f=bN;break;case"focusin":y="focus",f=Zg;break;case"focusout":y="blur",f=Zg;break;case"beforeblur":case"afterblur":f=Zg;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":f=t1;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":f=uN;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":f=IN;break;case Pk:case Ck:case Ik:f=pN;break;case Ek:f=_N;break;case"scroll":f=cN;break;case"wheel":f=TN;break;case"copy":case"cut":case"paste":f=gN;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":f=r1}var g=(t&4)!==0,w=!g&&e==="scroll",S=g?p!==null?p+"Capture":null:p;g=[];for(var v=l,P;v!==null;){P=v;var I=P.stateNode;if(P.tag===5&&I!==null&&(P=I,S!==null&&(I=Bl(v,S),I!=null&&g.push(Yl(v,I,P)))),w)break;v=v.return}0<g.length&&(p=new f(p,y,null,n,u),d.push({event:p,listeners:g}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",f=e==="mouseout"||e==="pointerout",p&&n!==aS&&(y=n.relatedTarget||n.fromElement)&&(fi(y)||y[Ko]))break e;if((f||p)&&(p=u.window===u?u:(p=u.ownerDocument)?p.defaultView||p.parentWindow:window,f?(y=n.relatedTarget||n.toElement,f=l,y=y?fi(y):null,y!==null&&(w=zi(y),y!==w||y.tag!==5&&y.tag!==6)&&(y=null)):(f=null,y=l),f!==y)){if(g=t1,I="onMouseLeave",S="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(g=r1,I="onPointerLeave",S="onPointerEnter",v="pointer"),w=f==null?p:wa(f),P=y==null?p:wa(y),p=new g(I,v+"leave",f,n,u),p.target=w,p.relatedTarget=P,I=null,fi(u)===l&&(g=new g(S,v+"enter",y,n,u),g.target=P,g.relatedTarget=w,I=g),w=I,f&&y)t:{for(g=f,S=y,v=0,P=g;P;P=ta(P))v++;for(P=0,I=S;I;I=ta(I))P++;for(;0<v-P;)g=ta(g),v--;for(;0<P-v;)S=ta(S),P--;for(;v--;){if(g===S||S!==null&&g===S.alternate)break t;g=ta(g),S=ta(S)}g=null}else g=null;f!==null&&f1(d,p,f,g,!1),y!==null&&w!==null&&f1(d,w,y,g,!0)}}e:{if(p=l?wa(l):window,f=p.nodeName&&p.nodeName.toLowerCase(),f==="select"||f==="input"&&p.type==="file")var C=RN;else if(i1(p))if(Sk)C=zN;else{C=FN;var E=LN}else(f=p.nodeName)&&f.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(C=NN);if(C&&(C=C(e,l))){yk(d,C,n,u);break e}E&&E(e,p,l),e==="focusout"&&(E=p._wrapperState)&&E.controlled&&p.type==="number"&&nS(p,"number",p.value)}switch(E=l?wa(l):window,e){case"focusin":(i1(E)||E.contentEditable==="true")&&(va=E,fS=l,bl=null);break;case"focusout":bl=fS=va=null;break;case"mousedown":gS=!0;break;case"contextmenu":case"mouseup":case"dragend":gS=!1,d1(d,n,u);break;case"selectionchange":if(HN)break;case"keydown":case"keyup":d1(d,n,u)}var _;if(E0)e:{switch(e){case"compositionstart":var k="onCompositionStart";break e;case"compositionend":k="onCompositionEnd";break e;case"compositionupdate":k="onCompositionUpdate";break e}k=void 0}else Sa?gk(e,n)&&(k="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(k="onCompositionStart");k&&(fk&&n.locale!=="ko"&&(Sa||k!=="onCompositionStart"?k==="onCompositionEnd"&&Sa&&(_=pk()):(Ps=u,P0="value"in Ps?Ps.value:Ps.textContent,Sa=!0)),E=$p(l,k),0<E.length&&(k=new n1(k,e,null,n,u),d.push({event:k,listeners:E}),_?k.data=_:(_=mk(n),_!==null&&(k.data=_)))),(_=MN?AN(e,n):jN(e,n))&&(l=$p(l,"onBeforeInput"),0<l.length&&(u=new n1("onBeforeInput","beforeinput",null,n,u),d.push({event:u,listeners:l}),u.data=_))}kk(d,t)})}function Yl(e,t,n){return{instance:e,listener:t,currentTarget:n}}function $p(e,t){for(var n=t+"Capture",r=[];e!==null;){var o=e,s=o.stateNode;o.tag===5&&s!==null&&(o=s,s=Bl(e,n),s!=null&&r.unshift(Yl(e,s,o)),s=Bl(e,t),s!=null&&r.push(Yl(e,s,o))),e=e.return}return r}function ta(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function f1(e,t,n,r,o){for(var s=t._reactName,i=[];n!==null&&n!==r;){var a=n,c=a.alternate,l=a.stateNode;if(c!==null&&c===r)break;a.tag===5&&l!==null&&(a=l,o?(c=Bl(n,s),c!=null&&i.unshift(Yl(n,c,a))):o||(c=Bl(n,s),c!=null&&i.push(Yl(n,c,a)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var VN=/\r\n?/g,YN=/\u0000|\uFFFD/g;function g1(e){return(typeof e=="string"?e:""+e).replace(VN,`
|
|
76
|
-
`).replace(YN,"")}function hd(e,t,n){if(t=g1(t),g1(e)!==t&&n)throw Error(Y(425))}function Mp(){}var mS=null,yS=null;function SS(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var vS=typeof setTimeout=="function"?setTimeout:void 0,XN=typeof clearTimeout=="function"?clearTimeout:void 0,m1=typeof Promise=="function"?Promise:void 0,qN=typeof queueMicrotask=="function"?queueMicrotask:typeof m1<"u"?function(e){return m1.resolve(null).then(e).catch(ZN)}:vS;function ZN(e){setTimeout(function(){throw e})}function sm(e,t){var n=t,r=0;do{var o=n.nextSibling;if(e.removeChild(n),o&&o.nodeType===8)if(n=o.data,n==="/$"){if(r===0){e.removeChild(o),Kl(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=o}while(n);Kl(t)}function As(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function y1(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var Sc=Math.random().toString(36).slice(2),Jr="__reactFiber$"+Sc,Xl="__reactProps$"+Sc,Ko="__reactContainer$"+Sc,xS="__reactEvents$"+Sc,QN="__reactListeners$"+Sc,JN="__reactHandles$"+Sc;function fi(e){var t=e[Jr];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ko]||n[Jr]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=y1(e);e!==null;){if(n=e[Jr])return n;e=y1(e)}return t}e=n,n=e.parentNode}return null}function Eu(e){return e=e[Jr]||e[Ko],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function wa(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Y(33))}function Cf(e){return e[Xl]||null}var wS=[],ba=-1;function Vs(e){return{current:e}}function ot(e){0>ba||(e.current=wS[ba],wS[ba]=null,ba--)}function qe(e,t){ba++,wS[ba]=e.current,e.current=t}var zs={},cn=Vs(zs),Mn=Vs(!1),Ii=zs;function qa(e,t){var n=e.type.contextTypes;if(!n)return zs;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},s;for(s in n)o[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function An(e){return e=e.childContextTypes,e!=null}function Ap(){ot(Mn),ot(cn)}function S1(e,t,n){if(cn.current!==zs)throw Error(Y(168));qe(cn,t),qe(Mn,n)}function $k(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(Y(108,L6(e)||"Unknown",o));return ft({},n,r)}function jp(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||zs,Ii=cn.current,qe(cn,e),qe(Mn,Mn.current),!0}function v1(e,t,n){var r=e.stateNode;if(!r)throw Error(Y(169));n?(e=$k(e,t,Ii),r.__reactInternalMemoizedMergedChildContext=e,ot(Mn),ot(cn),qe(cn,e)):ot(Mn),qe(Mn,n)}var Mo=null,If=!1,im=!1;function Mk(e){Mo===null?Mo=[e]:Mo.push(e)}function ez(e){If=!0,Mk(e)}function Ys(){if(!im&&Mo!==null){im=!0;var e=0,t=ze;try{var n=Mo;for(ze=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Mo=null,If=!1}catch(o){throw Mo!==null&&(Mo=Mo.slice(e+1)),nk(v0,Ys),o}finally{ze=t,im=!1}}return null}var Pa=[],Ca=0,Op=null,Dp=0,pr=[],fr=0,Ei=null,jo=1,Oo="";function li(e,t){Pa[Ca++]=Dp,Pa[Ca++]=Op,Op=e,Dp=t}function Ak(e,t,n){pr[fr++]=jo,pr[fr++]=Oo,pr[fr++]=Ei,Ei=e;var r=jo;e=Oo;var o=32-Lr(r)-1;r&=~(1<<o),n+=1;var s=32-Lr(t)+o;if(30<s){var i=o-o%5;s=(r&(1<<i)-1).toString(32),r>>=i,o-=i,jo=1<<32-Lr(t)+o|n<<o|r,Oo=s+e}else jo=1<<s|n<<o|r,Oo=e}function k0(e){e.return!==null&&(li(e,1),Ak(e,1,0))}function T0(e){for(;e===Op;)Op=Pa[--Ca],Pa[Ca]=null,Dp=Pa[--Ca],Pa[Ca]=null;for(;e===Ei;)Ei=pr[--fr],pr[fr]=null,Oo=pr[--fr],pr[fr]=null,jo=pr[--fr],pr[fr]=null}var Qn=null,Yn=null,st=!1,jr=null;function jk(e,t){var n=mr(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function x1(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Qn=e,Yn=As(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Qn=e,Yn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ei!==null?{id:jo,overflow:Oo}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=mr(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Qn=e,Yn=null,!0):!1;default:return!1}}function bS(e){return(e.mode&1)!==0&&(e.flags&128)===0}function PS(e){if(st){var t=Yn;if(t){var n=t;if(!x1(e,t)){if(bS(e))throw Error(Y(418));t=As(n.nextSibling);var r=Qn;t&&x1(e,t)?jk(r,n):(e.flags=e.flags&-4097|2,st=!1,Qn=e)}}else{if(bS(e))throw Error(Y(418));e.flags=e.flags&-4097|2,st=!1,Qn=e}}}function w1(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Qn=e}function pd(e){if(e!==Qn)return!1;if(!st)return w1(e),st=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!SS(e.type,e.memoizedProps)),t&&(t=Yn)){if(bS(e))throw Ok(),Error(Y(418));for(;t;)jk(e,t),t=As(t.nextSibling)}if(w1(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Y(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Yn=As(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Yn=null}}else Yn=Qn?As(e.stateNode.nextSibling):null;return!0}function Ok(){for(var e=Yn;e;)e=As(e.nextSibling)}function Za(){Yn=Qn=null,st=!1}function $0(e){jr===null?jr=[e]:jr.push(e)}var tz=es.ReactCurrentBatchConfig;function Hc(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Y(309));var r=n.stateNode}if(!r)throw Error(Y(147,e));var o=r,s=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===s?t.ref:(t=function(i){var a=o.refs;i===null?delete a[s]:a[s]=i},t._stringRef=s,t)}if(typeof e!="string")throw Error(Y(284));if(!n._owner)throw Error(Y(290,e))}return e}function fd(e,t){throw e=Object.prototype.toString.call(t),Error(Y(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function b1(e){var t=e._init;return t(e._payload)}function Dk(e){function t(S,v){if(e){var P=S.deletions;P===null?(S.deletions=[v],S.flags|=16):P.push(v)}}function n(S,v){if(!e)return null;for(;v!==null;)t(S,v),v=v.sibling;return null}function r(S,v){for(S=new Map;v!==null;)v.key!==null?S.set(v.key,v):S.set(v.index,v),v=v.sibling;return S}function o(S,v){return S=Rs(S,v),S.index=0,S.sibling=null,S}function s(S,v,P){return S.index=P,e?(P=S.alternate,P!==null?(P=P.index,P<v?(S.flags|=2,v):P):(S.flags|=2,v)):(S.flags|=1048576,v)}function i(S){return e&&S.alternate===null&&(S.flags|=2),S}function a(S,v,P,I){return v===null||v.tag!==6?(v=pm(P,S.mode,I),v.return=S,v):(v=o(v,P),v.return=S,v)}function c(S,v,P,I){var C=P.type;return C===ya?u(S,v,P.props.children,I,P.key):v!==null&&(v.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===ys&&b1(C)===v.type)?(I=o(v,P.props),I.ref=Hc(S,v,P),I.return=S,I):(I=hh(P.type,P.key,P.props,null,S.mode,I),I.ref=Hc(S,v,P),I.return=S,I)}function l(S,v,P,I){return v===null||v.tag!==4||v.stateNode.containerInfo!==P.containerInfo||v.stateNode.implementation!==P.implementation?(v=fm(P,S.mode,I),v.return=S,v):(v=o(v,P.children||[]),v.return=S,v)}function u(S,v,P,I,C){return v===null||v.tag!==7?(v=wi(P,S.mode,I,C),v.return=S,v):(v=o(v,P),v.return=S,v)}function d(S,v,P){if(typeof v=="string"&&v!==""||typeof v=="number")return v=pm(""+v,S.mode,P),v.return=S,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case rd:return P=hh(v.type,v.key,v.props,null,S.mode,P),P.ref=Hc(S,null,v),P.return=S,P;case ma:return v=fm(v,S.mode,P),v.return=S,v;case ys:var I=v._init;return d(S,I(v._payload),P)}if(cl(v)||Fc(v))return v=wi(v,S.mode,P,null),v.return=S,v;fd(S,v)}return null}function p(S,v,P,I){var C=v!==null?v.key:null;if(typeof P=="string"&&P!==""||typeof P=="number")return C!==null?null:a(S,v,""+P,I);if(typeof P=="object"&&P!==null){switch(P.$$typeof){case rd:return P.key===C?c(S,v,P,I):null;case ma:return P.key===C?l(S,v,P,I):null;case ys:return C=P._init,p(S,v,C(P._payload),I)}if(cl(P)||Fc(P))return C!==null?null:u(S,v,P,I,null);fd(S,P)}return null}function f(S,v,P,I,C){if(typeof I=="string"&&I!==""||typeof I=="number")return S=S.get(P)||null,a(v,S,""+I,C);if(typeof I=="object"&&I!==null){switch(I.$$typeof){case rd:return S=S.get(I.key===null?P:I.key)||null,c(v,S,I,C);case ma:return S=S.get(I.key===null?P:I.key)||null,l(v,S,I,C);case ys:var E=I._init;return f(S,v,P,E(I._payload),C)}if(cl(I)||Fc(I))return S=S.get(P)||null,u(v,S,I,C,null);fd(v,I)}return null}function y(S,v,P,I){for(var C=null,E=null,_=v,k=v=0,$=null;_!==null&&k<P.length;k++){_.index>k?($=_,_=null):$=_.sibling;var T=p(S,_,P[k],I);if(T===null){_===null&&(_=$);break}e&&_&&T.alternate===null&&t(S,_),v=s(T,v,k),E===null?C=T:E.sibling=T,E=T,_=$}if(k===P.length)return n(S,_),st&&li(S,k),C;if(_===null){for(;k<P.length;k++)_=d(S,P[k],I),_!==null&&(v=s(_,v,k),E===null?C=_:E.sibling=_,E=_);return st&&li(S,k),C}for(_=r(S,_);k<P.length;k++)$=f(_,S,k,P[k],I),$!==null&&(e&&$.alternate!==null&&_.delete($.key===null?k:$.key),v=s($,v,k),E===null?C=$:E.sibling=$,E=$);return e&&_.forEach(function(A){return t(S,A)}),st&&li(S,k),C}function g(S,v,P,I){var C=Fc(P);if(typeof C!="function")throw Error(Y(150));if(P=C.call(P),P==null)throw Error(Y(151));for(var E=C=null,_=v,k=v=0,$=null,T=P.next();_!==null&&!T.done;k++,T=P.next()){_.index>k?($=_,_=null):$=_.sibling;var A=p(S,_,T.value,I);if(A===null){_===null&&(_=$);break}e&&_&&A.alternate===null&&t(S,_),v=s(A,v,k),E===null?C=A:E.sibling=A,E=A,_=$}if(T.done)return n(S,_),st&&li(S,k),C;if(_===null){for(;!T.done;k++,T=P.next())T=d(S,T.value,I),T!==null&&(v=s(T,v,k),E===null?C=T:E.sibling=T,E=T);return st&&li(S,k),C}for(_=r(S,_);!T.done;k++,T=P.next())T=f(_,S,k,T.value,I),T!==null&&(e&&T.alternate!==null&&_.delete(T.key===null?k:T.key),v=s(T,v,k),E===null?C=T:E.sibling=T,E=T);return e&&_.forEach(function(B){return t(S,B)}),st&&li(S,k),C}function w(S,v,P,I){if(typeof P=="object"&&P!==null&&P.type===ya&&P.key===null&&(P=P.props.children),typeof P=="object"&&P!==null){switch(P.$$typeof){case rd:e:{for(var C=P.key,E=v;E!==null;){if(E.key===C){if(C=P.type,C===ya){if(E.tag===7){n(S,E.sibling),v=o(E,P.props.children),v.return=S,S=v;break e}}else if(E.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===ys&&b1(C)===E.type){n(S,E.sibling),v=o(E,P.props),v.ref=Hc(S,E,P),v.return=S,S=v;break e}n(S,E);break}else t(S,E);E=E.sibling}P.type===ya?(v=wi(P.props.children,S.mode,I,P.key),v.return=S,S=v):(I=hh(P.type,P.key,P.props,null,S.mode,I),I.ref=Hc(S,v,P),I.return=S,S=I)}return i(S);case ma:e:{for(E=P.key;v!==null;){if(v.key===E)if(v.tag===4&&v.stateNode.containerInfo===P.containerInfo&&v.stateNode.implementation===P.implementation){n(S,v.sibling),v=o(v,P.children||[]),v.return=S,S=v;break e}else{n(S,v);break}else t(S,v);v=v.sibling}v=fm(P,S.mode,I),v.return=S,S=v}return i(S);case ys:return E=P._init,w(S,v,E(P._payload),I)}if(cl(P))return y(S,v,P,I);if(Fc(P))return g(S,v,P,I);fd(S,P)}return typeof P=="string"&&P!==""||typeof P=="number"?(P=""+P,v!==null&&v.tag===6?(n(S,v.sibling),v=o(v,P),v.return=S,S=v):(n(S,v),v=pm(P,S.mode,I),v.return=S,S=v),i(S)):n(S,v)}return w}var Qa=Dk(!0),Rk=Dk(!1),Rp=Vs(null),Lp=null,Ia=null,M0=null;function A0(){M0=Ia=Lp=null}function j0(e){var t=Rp.current;ot(Rp),e._currentValue=t}function CS(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function za(e,t){Lp=e,M0=Ia=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(kn=!0),e.firstContext=null)}function xr(e){var t=e._currentValue;if(M0!==e)if(e={context:e,memoizedValue:t,next:null},Ia===null){if(Lp===null)throw Error(Y(308));Ia=e,Lp.dependencies={lanes:0,firstContext:e}}else Ia=Ia.next=e;return t}var gi=null;function O0(e){gi===null?gi=[e]:gi.push(e)}function Lk(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,O0(t)):(n.next=o.next,o.next=n),t.interleaved=n,Wo(e,r)}function Wo(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Ss=!1;function D0(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Fk(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Lo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function js(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Te&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,Wo(e,n)}return o=r.interleaved,o===null?(t.next=t,O0(r)):(t.next=o.next,o.next=t),r.interleaved=t,Wo(e,n)}function ih(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,x0(e,n)}}function P1(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var o=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?o=s=i:s=s.next=i,n=n.next}while(n!==null);s===null?o=s=t:s=s.next=t}else o=s=t;n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Fp(e,t,n,r){var o=e.updateQueue;Ss=!1;var s=o.firstBaseUpdate,i=o.lastBaseUpdate,a=o.shared.pending;if(a!==null){o.shared.pending=null;var c=a,l=c.next;c.next=null,i===null?s=l:i.next=l,i=c;var u=e.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==i&&(a===null?u.firstBaseUpdate=l:a.next=l,u.lastBaseUpdate=c))}if(s!==null){var d=o.baseState;i=0,u=l=c=null,a=s;do{var p=a.lane,f=a.eventTime;if((r&p)===p){u!==null&&(u=u.next={eventTime:f,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var y=e,g=a;switch(p=t,f=n,g.tag){case 1:if(y=g.payload,typeof y=="function"){d=y.call(f,d,p);break e}d=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=g.payload,p=typeof y=="function"?y.call(f,d,p):y,p==null)break e;d=ft({},d,p);break e;case 2:Ss=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,p=o.effects,p===null?o.effects=[a]:p.push(a))}else f={eventTime:f,lane:p,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(l=u=f,c=d):u=u.next=f,i|=p;if(a=a.next,a===null){if(a=o.shared.pending,a===null)break;p=a,a=p.next,p.next=null,o.lastBaseUpdate=p,o.shared.pending=null}}while(!0);if(u===null&&(c=d),o.baseState=c,o.firstBaseUpdate=l,o.lastBaseUpdate=u,t=o.shared.interleaved,t!==null){o=t;do i|=o.lane,o=o.next;while(o!==t)}else s===null&&(o.shared.lanes=0);ki|=i,e.lanes=i,e.memoizedState=d}}function C1(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],o=r.callback;if(o!==null){if(r.callback=null,r=n,typeof o!="function")throw Error(Y(191,o));o.call(r)}}}var _u={},so=Vs(_u),ql=Vs(_u),Zl=Vs(_u);function mi(e){if(e===_u)throw Error(Y(174));return e}function R0(e,t){switch(qe(Zl,t),qe(ql,e),qe(so,_u),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:oS(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=oS(t,e)}ot(so),qe(so,t)}function Ja(){ot(so),ot(ql),ot(Zl)}function Nk(e){mi(Zl.current);var t=mi(so.current),n=oS(t,e.type);t!==n&&(qe(ql,e),qe(so,n))}function L0(e){ql.current===e&&(ot(so),ot(ql))}var ct=Vs(0);function Np(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var am=[];function F0(){for(var e=0;e<am.length;e++)am[e]._workInProgressVersionPrimary=null;am.length=0}var ah=es.ReactCurrentDispatcher,cm=es.ReactCurrentBatchConfig,_i=0,ht=null,kt=null,At=null,zp=!1,Pl=!1,Ql=0,nz=0;function Zt(){throw Error(Y(321))}function N0(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ur(e[n],t[n]))return!1;return!0}function z0(e,t,n,r,o,s){if(_i=s,ht=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,ah.current=e===null||e.memoizedState===null?iz:az,e=n(r,o),Pl){s=0;do{if(Pl=!1,Ql=0,25<=s)throw Error(Y(301));s+=1,At=kt=null,t.updateQueue=null,ah.current=cz,e=n(r,o)}while(Pl)}if(ah.current=Bp,t=kt!==null&&kt.next!==null,_i=0,At=kt=ht=null,zp=!1,t)throw Error(Y(300));return e}function B0(){var e=Ql!==0;return Ql=0,e}function Xr(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return At===null?ht.memoizedState=At=e:At=At.next=e,At}function wr(){if(kt===null){var e=ht.alternate;e=e!==null?e.memoizedState:null}else e=kt.next;var t=At===null?ht.memoizedState:At.next;if(t!==null)At=t,kt=e;else{if(e===null)throw Error(Y(310));kt=e,e={memoizedState:kt.memoizedState,baseState:kt.baseState,baseQueue:kt.baseQueue,queue:kt.queue,next:null},At===null?ht.memoizedState=At=e:At=At.next=e}return At}function Jl(e,t){return typeof t=="function"?t(e):t}function lm(e){var t=wr(),n=t.queue;if(n===null)throw Error(Y(311));n.lastRenderedReducer=e;var r=kt,o=r.baseQueue,s=n.pending;if(s!==null){if(o!==null){var i=o.next;o.next=s.next,s.next=i}r.baseQueue=o=s,n.pending=null}if(o!==null){s=o.next,r=r.baseState;var a=i=null,c=null,l=s;do{var u=l.lane;if((_i&u)===u)c!==null&&(c=c.next={lane:0,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null}),r=l.hasEagerState?l.eagerState:e(r,l.action);else{var d={lane:u,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null};c===null?(a=c=d,i=r):c=c.next=d,ht.lanes|=u,ki|=u}l=l.next}while(l!==null&&l!==s);c===null?i=r:c.next=a,Ur(r,t.memoizedState)||(kn=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){o=e;do s=o.lane,ht.lanes|=s,ki|=s,o=o.next;while(o!==e)}else o===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function um(e){var t=wr(),n=t.queue;if(n===null)throw Error(Y(311));n.lastRenderedReducer=e;var r=n.dispatch,o=n.pending,s=t.memoizedState;if(o!==null){n.pending=null;var i=o=o.next;do s=e(s,i.action),i=i.next;while(i!==o);Ur(s,t.memoizedState)||(kn=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function zk(){}function Bk(e,t){var n=ht,r=wr(),o=t(),s=!Ur(r.memoizedState,o);if(s&&(r.memoizedState=o,kn=!0),r=r.queue,U0(Kk.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||At!==null&&At.memoizedState.tag&1){if(n.flags|=2048,eu(9,Hk.bind(null,n,r,o,t),void 0,null),Dt===null)throw Error(Y(349));_i&30||Uk(n,t,o)}return o}function Uk(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=ht.updateQueue,t===null?(t={lastEffect:null,stores:null},ht.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Hk(e,t,n,r){t.value=n,t.getSnapshot=r,Wk(t)&&Gk(e)}function Kk(e,t,n){return n(function(){Wk(t)&&Gk(e)})}function Wk(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ur(e,n)}catch{return!0}}function Gk(e){var t=Wo(e,1);t!==null&&Fr(t,e,1,-1)}function I1(e){var t=Xr();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Jl,lastRenderedState:e},t.queue=e,e=e.dispatch=sz.bind(null,ht,e),[t.memoizedState,e]}function eu(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=ht.updateQueue,t===null?(t={lastEffect:null,stores:null},ht.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Vk(){return wr().memoizedState}function ch(e,t,n,r){var o=Xr();ht.flags|=e,o.memoizedState=eu(1|t,n,void 0,r===void 0?null:r)}function Ef(e,t,n,r){var o=wr();r=r===void 0?null:r;var s=void 0;if(kt!==null){var i=kt.memoizedState;if(s=i.destroy,r!==null&&N0(r,i.deps)){o.memoizedState=eu(t,n,s,r);return}}ht.flags|=e,o.memoizedState=eu(1|t,n,s,r)}function E1(e,t){return ch(8390656,8,e,t)}function U0(e,t){return Ef(2048,8,e,t)}function Yk(e,t){return Ef(4,2,e,t)}function Xk(e,t){return Ef(4,4,e,t)}function qk(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Zk(e,t,n){return n=n!=null?n.concat([e]):null,Ef(4,4,qk.bind(null,t,e),n)}function H0(){}function Qk(e,t){var n=wr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&N0(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Jk(e,t){var n=wr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&N0(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function eT(e,t,n){return _i&21?(Ur(n,t)||(n=sk(),ht.lanes|=n,ki|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,kn=!0),e.memoizedState=n)}function rz(e,t){var n=ze;ze=n!==0&&4>n?n:4,e(!0);var r=cm.transition;cm.transition={};try{e(!1),t()}finally{ze=n,cm.transition=r}}function tT(){return wr().memoizedState}function oz(e,t,n){var r=Ds(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},nT(e))rT(t,n);else if(n=Lk(e,t,n,r),n!==null){var o=mn();Fr(n,e,r,o),oT(n,t,r)}}function sz(e,t,n){var r=Ds(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(nT(e))rT(t,o);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var i=t.lastRenderedState,a=s(i,n);if(o.hasEagerState=!0,o.eagerState=a,Ur(a,i)){var c=t.interleaved;c===null?(o.next=o,O0(t)):(o.next=c.next,c.next=o),t.interleaved=o;return}}catch{}finally{}n=Lk(e,t,o,r),n!==null&&(o=mn(),Fr(n,e,r,o),oT(n,t,r))}}function nT(e){var t=e.alternate;return e===ht||t!==null&&t===ht}function rT(e,t){Pl=zp=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function oT(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,x0(e,n)}}var Bp={readContext:xr,useCallback:Zt,useContext:Zt,useEffect:Zt,useImperativeHandle:Zt,useInsertionEffect:Zt,useLayoutEffect:Zt,useMemo:Zt,useReducer:Zt,useRef:Zt,useState:Zt,useDebugValue:Zt,useDeferredValue:Zt,useTransition:Zt,useMutableSource:Zt,useSyncExternalStore:Zt,useId:Zt,unstable_isNewReconciler:!1},iz={readContext:xr,useCallback:function(e,t){return Xr().memoizedState=[e,t===void 0?null:t],e},useContext:xr,useEffect:E1,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ch(4194308,4,qk.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ch(4194308,4,e,t)},useInsertionEffect:function(e,t){return ch(4,2,e,t)},useMemo:function(e,t){var n=Xr();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Xr();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=oz.bind(null,ht,e),[r.memoizedState,e]},useRef:function(e){var t=Xr();return e={current:e},t.memoizedState=e},useState:I1,useDebugValue:H0,useDeferredValue:function(e){return Xr().memoizedState=e},useTransition:function(){var e=I1(!1),t=e[0];return e=rz.bind(null,e[1]),Xr().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ht,o=Xr();if(st){if(n===void 0)throw Error(Y(407));n=n()}else{if(n=t(),Dt===null)throw Error(Y(349));_i&30||Uk(r,t,n)}o.memoizedState=n;var s={value:n,getSnapshot:t};return o.queue=s,E1(Kk.bind(null,r,s,e),[e]),r.flags|=2048,eu(9,Hk.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Xr(),t=Dt.identifierPrefix;if(st){var n=Oo,r=jo;n=(r&~(1<<32-Lr(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Ql++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=nz++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},az={readContext:xr,useCallback:Qk,useContext:xr,useEffect:U0,useImperativeHandle:Zk,useInsertionEffect:Yk,useLayoutEffect:Xk,useMemo:Jk,useReducer:lm,useRef:Vk,useState:function(){return lm(Jl)},useDebugValue:H0,useDeferredValue:function(e){var t=wr();return eT(t,kt.memoizedState,e)},useTransition:function(){var e=lm(Jl)[0],t=wr().memoizedState;return[e,t]},useMutableSource:zk,useSyncExternalStore:Bk,useId:tT,unstable_isNewReconciler:!1},cz={readContext:xr,useCallback:Qk,useContext:xr,useEffect:U0,useImperativeHandle:Zk,useInsertionEffect:Yk,useLayoutEffect:Xk,useMemo:Jk,useReducer:um,useRef:Vk,useState:function(){return um(Jl)},useDebugValue:H0,useDeferredValue:function(e){var t=wr();return kt===null?t.memoizedState=e:eT(t,kt.memoizedState,e)},useTransition:function(){var e=um(Jl)[0],t=wr().memoizedState;return[e,t]},useMutableSource:zk,useSyncExternalStore:Bk,useId:tT,unstable_isNewReconciler:!1};function kr(e,t){if(e&&e.defaultProps){t=ft({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function IS(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:ft({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var _f={isMounted:function(e){return(e=e._reactInternals)?zi(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=mn(),o=Ds(e),s=Lo(r,o);s.payload=t,n!=null&&(s.callback=n),t=js(e,s,o),t!==null&&(Fr(t,e,o,r),ih(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=mn(),o=Ds(e),s=Lo(r,o);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=js(e,s,o),t!==null&&(Fr(t,e,o,r),ih(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=mn(),r=Ds(e),o=Lo(n,r);o.tag=2,t!=null&&(o.callback=t),t=js(e,o,r),t!==null&&(Fr(t,e,r,n),ih(t,e,r))}};function _1(e,t,n,r,o,s,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,s,i):t.prototype&&t.prototype.isPureReactComponent?!Gl(n,r)||!Gl(o,s):!0}function sT(e,t,n){var r=!1,o=zs,s=t.contextType;return typeof s=="object"&&s!==null?s=xr(s):(o=An(t)?Ii:cn.current,r=t.contextTypes,s=(r=r!=null)?qa(e,o):zs),t=new t(n,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=_f,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=o,e.__reactInternalMemoizedMaskedChildContext=s),t}function k1(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&_f.enqueueReplaceState(t,t.state,null)}function ES(e,t,n,r){var o=e.stateNode;o.props=n,o.state=e.memoizedState,o.refs={},D0(e);var s=t.contextType;typeof s=="object"&&s!==null?o.context=xr(s):(s=An(t)?Ii:cn.current,o.context=qa(e,s)),o.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(IS(e,t,s,n),o.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(t=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),t!==o.state&&_f.enqueueReplaceState(o,o.state,null),Fp(e,n,o,r),o.state=e.memoizedState),typeof o.componentDidMount=="function"&&(e.flags|=4194308)}function ec(e,t){try{var n="",r=t;do n+=R6(r),r=r.return;while(r);var o=n}catch(s){o=`
|
|
77
|
-
Error generating stack: `+s.message+`
|
|
78
|
-
`+s.stack}return{value:e,source:t,stack:o,digest:null}}function dm(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function _S(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var lz=typeof WeakMap=="function"?WeakMap:Map;function iT(e,t,n){n=Lo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Hp||(Hp=!0,LS=r),_S(e,t)},n}function aT(e,t,n){n=Lo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var o=t.value;n.payload=function(){return r(o)},n.callback=function(){_S(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){_S(e,t),typeof r!="function"&&(Os===null?Os=new Set([this]):Os.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function T1(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new lz;var o=new Set;r.set(t,o)}else o=r.get(t),o===void 0&&(o=new Set,r.set(t,o));o.has(n)||(o.add(n),e=Pz.bind(null,e,t,n),t.then(e,e))}function $1(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function M1(e,t,n,r,o){return e.mode&1?(e.flags|=65536,e.lanes=o,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Lo(-1,1),t.tag=2,js(n,t,1))),n.lanes|=1),e)}var uz=es.ReactCurrentOwner,kn=!1;function dn(e,t,n,r){t.child=e===null?Rk(t,null,n,r):Qa(t,e.child,n,r)}function A1(e,t,n,r,o){n=n.render;var s=t.ref;return za(t,o),r=z0(e,t,n,r,s,o),n=B0(),e!==null&&!kn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,Go(e,t,o)):(st&&n&&k0(t),t.flags|=1,dn(e,t,r,o),t.child)}function j1(e,t,n,r,o){if(e===null){var s=n.type;return typeof s=="function"&&!Z0(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,cT(e,t,s,r,o)):(e=hh(n.type,null,r,t,t.mode,o),e.ref=t.ref,e.return=t,t.child=e)}if(s=e.child,!(e.lanes&o)){var i=s.memoizedProps;if(n=n.compare,n=n!==null?n:Gl,n(i,r)&&e.ref===t.ref)return Go(e,t,o)}return t.flags|=1,e=Rs(s,r),e.ref=t.ref,e.return=t,t.child=e}function cT(e,t,n,r,o){if(e!==null){var s=e.memoizedProps;if(Gl(s,r)&&e.ref===t.ref)if(kn=!1,t.pendingProps=r=s,(e.lanes&o)!==0)e.flags&131072&&(kn=!0);else return t.lanes=e.lanes,Go(e,t,o)}return kS(e,t,n,r,o)}function lT(e,t,n){var r=t.pendingProps,o=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},qe(_a,Kn),Kn|=n;else{if(!(n&1073741824))return e=s!==null?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,qe(_a,Kn),Kn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,qe(_a,Kn),Kn|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,qe(_a,Kn),Kn|=r;return dn(e,t,o,n),t.child}function uT(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function kS(e,t,n,r,o){var s=An(n)?Ii:cn.current;return s=qa(t,s),za(t,o),n=z0(e,t,n,r,s,o),r=B0(),e!==null&&!kn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,Go(e,t,o)):(st&&r&&k0(t),t.flags|=1,dn(e,t,n,o),t.child)}function O1(e,t,n,r,o){if(An(n)){var s=!0;jp(t)}else s=!1;if(za(t,o),t.stateNode===null)lh(e,t),sT(t,n,r),ES(t,n,r,o),r=!0;else if(e===null){var i=t.stateNode,a=t.memoizedProps;i.props=a;var c=i.context,l=n.contextType;typeof l=="object"&&l!==null?l=xr(l):(l=An(n)?Ii:cn.current,l=qa(t,l));var u=n.getDerivedStateFromProps,d=typeof u=="function"||typeof i.getSnapshotBeforeUpdate=="function";d||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(a!==r||c!==l)&&k1(t,i,r,l),Ss=!1;var p=t.memoizedState;i.state=p,Fp(t,r,i,o),c=t.memoizedState,a!==r||p!==c||Mn.current||Ss?(typeof u=="function"&&(IS(t,n,u,r),c=t.memoizedState),(a=Ss||_1(t,n,a,r,p,c,l))?(d||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),i.props=r,i.state=c,i.context=l,r=a):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,Fk(e,t),a=t.memoizedProps,l=t.type===t.elementType?a:kr(t.type,a),i.props=l,d=t.pendingProps,p=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=xr(c):(c=An(n)?Ii:cn.current,c=qa(t,c));var f=n.getDerivedStateFromProps;(u=typeof f=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(a!==d||p!==c)&&k1(t,i,r,c),Ss=!1,p=t.memoizedState,i.state=p,Fp(t,r,i,o);var y=t.memoizedState;a!==d||p!==y||Mn.current||Ss?(typeof f=="function"&&(IS(t,n,f,r),y=t.memoizedState),(l=Ss||_1(t,n,l,r,p,y,c)||!1)?(u||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,y,c),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,y,c)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),i.props=r,i.state=y,i.context=c,r=l):(typeof i.componentDidUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return TS(e,t,n,r,s,o)}function TS(e,t,n,r,o,s){uT(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return o&&v1(t,n,!1),Go(e,t,s);r=t.stateNode,uz.current=t;var a=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=Qa(t,e.child,null,s),t.child=Qa(t,null,a,s)):dn(e,t,a,s),t.memoizedState=r.state,o&&v1(t,n,!0),t.child}function dT(e){var t=e.stateNode;t.pendingContext?S1(e,t.pendingContext,t.pendingContext!==t.context):t.context&&S1(e,t.context,!1),R0(e,t.containerInfo)}function D1(e,t,n,r,o){return Za(),$0(o),t.flags|=256,dn(e,t,n,r),t.child}var $S={dehydrated:null,treeContext:null,retryLane:0};function MS(e){return{baseLanes:e,cachePool:null,transitions:null}}function hT(e,t,n){var r=t.pendingProps,o=ct.current,s=!1,i=(t.flags&128)!==0,a;if((a=i)||(a=e!==null&&e.memoizedState===null?!1:(o&2)!==0),a?(s=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(o|=1),qe(ct,o&1),e===null)return PS(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(i=r.children,e=r.fallback,s?(r=t.mode,s=t.child,i={mode:"hidden",children:i},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=i):s=$f(i,r,0,null),e=wi(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=MS(n),t.memoizedState=$S,e):K0(t,i));if(o=e.memoizedState,o!==null&&(a=o.dehydrated,a!==null))return dz(e,t,i,r,a,o,n);if(s){s=r.fallback,i=t.mode,o=e.child,a=o.sibling;var c={mode:"hidden",children:r.children};return!(i&1)&&t.child!==o?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Rs(o,c),r.subtreeFlags=o.subtreeFlags&14680064),a!==null?s=Rs(a,s):(s=wi(s,i,n,null),s.flags|=2),s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,i=e.child.memoizedState,i=i===null?MS(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},s.memoizedState=i,s.childLanes=e.childLanes&~n,t.memoizedState=$S,r}return s=e.child,e=s.sibling,r=Rs(s,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function K0(e,t){return t=$f({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function gd(e,t,n,r){return r!==null&&$0(r),Qa(t,e.child,null,n),e=K0(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function dz(e,t,n,r,o,s,i){if(n)return t.flags&256?(t.flags&=-257,r=dm(Error(Y(422))),gd(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,o=t.mode,r=$f({mode:"visible",children:r.children},o,0,null),s=wi(s,o,i,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&Qa(t,e.child,null,i),t.child.memoizedState=MS(i),t.memoizedState=$S,s);if(!(t.mode&1))return gd(e,t,i,null);if(o.data==="$!"){if(r=o.nextSibling&&o.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(Y(419)),r=dm(s,r,void 0),gd(e,t,i,r)}if(a=(i&e.childLanes)!==0,kn||a){if(r=Dt,r!==null){switch(i&-i){case 4:o=2;break;case 16:o=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}o=o&(r.suspendedLanes|i)?0:o,o!==0&&o!==s.retryLane&&(s.retryLane=o,Wo(e,o),Fr(r,e,o,-1))}return q0(),r=dm(Error(Y(421))),gd(e,t,i,r)}return o.data==="$?"?(t.flags|=128,t.child=e.child,t=Cz.bind(null,e),o._reactRetry=t,null):(e=s.treeContext,Yn=As(o.nextSibling),Qn=t,st=!0,jr=null,e!==null&&(pr[fr++]=jo,pr[fr++]=Oo,pr[fr++]=Ei,jo=e.id,Oo=e.overflow,Ei=t),t=K0(t,r.children),t.flags|=4096,t)}function R1(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),CS(e.return,t,n)}function hm(e,t,n,r,o){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:o}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=o)}function pT(e,t,n){var r=t.pendingProps,o=r.revealOrder,s=r.tail;if(dn(e,t,r.children,n),r=ct.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&R1(e,n,t);else if(e.tag===19)R1(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(qe(ct,r),!(t.mode&1))t.memoizedState=null;else switch(o){case"forwards":for(n=t.child,o=null;n!==null;)e=n.alternate,e!==null&&Np(e)===null&&(o=n),n=n.sibling;n=o,n===null?(o=t.child,t.child=null):(o=n.sibling,n.sibling=null),hm(t,!1,o,n,s);break;case"backwards":for(n=null,o=t.child,t.child=null;o!==null;){if(e=o.alternate,e!==null&&Np(e)===null){t.child=o;break}e=o.sibling,o.sibling=n,n=o,o=e}hm(t,!0,n,null,s);break;case"together":hm(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function lh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Go(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ki|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Y(153));if(t.child!==null){for(e=t.child,n=Rs(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Rs(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function hz(e,t,n){switch(t.tag){case 3:dT(t),Za();break;case 5:Nk(t);break;case 1:An(t.type)&&jp(t);break;case 4:R0(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,o=t.memoizedProps.value;qe(Rp,r._currentValue),r._currentValue=o;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(qe(ct,ct.current&1),t.flags|=128,null):n&t.child.childLanes?hT(e,t,n):(qe(ct,ct.current&1),e=Go(e,t,n),e!==null?e.sibling:null);qe(ct,ct.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return pT(e,t,n);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),qe(ct,ct.current),r)break;return null;case 22:case 23:return t.lanes=0,lT(e,t,n)}return Go(e,t,n)}var fT,AS,gT,mT;fT=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};AS=function(){};gT=function(e,t,n,r){var o=e.memoizedProps;if(o!==r){e=t.stateNode,mi(so.current);var s=null;switch(n){case"input":o=eS(e,o),r=eS(e,r),s=[];break;case"select":o=ft({},o,{value:void 0}),r=ft({},r,{value:void 0}),s=[];break;case"textarea":o=rS(e,o),r=rS(e,r),s=[];break;default:typeof o.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Mp)}sS(n,r);var i;n=null;for(l in o)if(!r.hasOwnProperty(l)&&o.hasOwnProperty(l)&&o[l]!=null)if(l==="style"){var a=o[l];for(i in a)a.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else l!=="dangerouslySetInnerHTML"&&l!=="children"&&l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&l!=="autoFocus"&&(Nl.hasOwnProperty(l)?s||(s=[]):(s=s||[]).push(l,null));for(l in r){var c=r[l];if(a=o!=null?o[l]:void 0,r.hasOwnProperty(l)&&c!==a&&(c!=null||a!=null))if(l==="style")if(a){for(i in a)!a.hasOwnProperty(i)||c&&c.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in c)c.hasOwnProperty(i)&&a[i]!==c[i]&&(n||(n={}),n[i]=c[i])}else n||(s||(s=[]),s.push(l,n)),n=c;else l==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,a=a?a.__html:void 0,c!=null&&a!==c&&(s=s||[]).push(l,c)):l==="children"?typeof c!="string"&&typeof c!="number"||(s=s||[]).push(l,""+c):l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&(Nl.hasOwnProperty(l)?(c!=null&&l==="onScroll"&&tt("scroll",e),s||a===c||(s=[])):(s=s||[]).push(l,c))}n&&(s=s||[]).push("style",n);var l=s;(t.updateQueue=l)&&(t.flags|=4)}};mT=function(e,t,n,r){n!==r&&(t.flags|=4)};function Kc(e,t){if(!st)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Qt(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags&14680064,r|=o.flags&14680064,o.return=e,o=o.sibling;else for(o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,o.return=e,o=o.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function pz(e,t,n){var r=t.pendingProps;switch(T0(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Qt(t),null;case 1:return An(t.type)&&Ap(),Qt(t),null;case 3:return r=t.stateNode,Ja(),ot(Mn),ot(cn),F0(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(pd(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,jr!==null&&(zS(jr),jr=null))),AS(e,t),Qt(t),null;case 5:L0(t);var o=mi(Zl.current);if(n=t.type,e!==null&&t.stateNode!=null)gT(e,t,n,r,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Y(166));return Qt(t),null}if(e=mi(so.current),pd(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[Jr]=t,r[Xl]=s,e=(t.mode&1)!==0,n){case"dialog":tt("cancel",r),tt("close",r);break;case"iframe":case"object":case"embed":tt("load",r);break;case"video":case"audio":for(o=0;o<ul.length;o++)tt(ul[o],r);break;case"source":tt("error",r);break;case"img":case"image":case"link":tt("error",r),tt("load",r);break;case"details":tt("toggle",r);break;case"input":Wb(r,s),tt("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},tt("invalid",r);break;case"textarea":Vb(r,s),tt("invalid",r)}sS(n,s),o=null;for(var i in s)if(s.hasOwnProperty(i)){var a=s[i];i==="children"?typeof a=="string"?r.textContent!==a&&(s.suppressHydrationWarning!==!0&&hd(r.textContent,a,e),o=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(s.suppressHydrationWarning!==!0&&hd(r.textContent,a,e),o=["children",""+a]):Nl.hasOwnProperty(i)&&a!=null&&i==="onScroll"&&tt("scroll",r)}switch(n){case"input":od(r),Gb(r,s,!0);break;case"textarea":od(r),Yb(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=Mp)}r=o,t.updateQueue=r,r!==null&&(t.flags|=4)}else{i=o.nodeType===9?o:o.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=K_(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[Jr]=t,e[Xl]=r,fT(e,t,!1,!1),t.stateNode=e;e:{switch(i=iS(n,r),n){case"dialog":tt("cancel",e),tt("close",e),o=r;break;case"iframe":case"object":case"embed":tt("load",e),o=r;break;case"video":case"audio":for(o=0;o<ul.length;o++)tt(ul[o],e);o=r;break;case"source":tt("error",e),o=r;break;case"img":case"image":case"link":tt("error",e),tt("load",e),o=r;break;case"details":tt("toggle",e),o=r;break;case"input":Wb(e,r),o=eS(e,r),tt("invalid",e);break;case"option":o=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},o=ft({},r,{value:void 0}),tt("invalid",e);break;case"textarea":Vb(e,r),o=rS(e,r),tt("invalid",e);break;default:o=r}sS(n,o),a=o;for(s in a)if(a.hasOwnProperty(s)){var c=a[s];s==="style"?V_(e,c):s==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&W_(e,c)):s==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&zl(e,c):typeof c=="number"&&zl(e,""+c):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Nl.hasOwnProperty(s)?c!=null&&s==="onScroll"&&tt("scroll",e):c!=null&&f0(e,s,c,i))}switch(n){case"input":od(e),Gb(e,r,!1);break;case"textarea":od(e),Yb(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Ns(r.value));break;case"select":e.multiple=!!r.multiple,s=r.value,s!=null?Ra(e,!!r.multiple,s,!1):r.defaultValue!=null&&Ra(e,!!r.multiple,r.defaultValue,!0);break;default:typeof o.onClick=="function"&&(e.onclick=Mp)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Qt(t),null;case 6:if(e&&t.stateNode!=null)mT(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Y(166));if(n=mi(Zl.current),mi(so.current),pd(t)){if(r=t.stateNode,n=t.memoizedProps,r[Jr]=t,(s=r.nodeValue!==n)&&(e=Qn,e!==null))switch(e.tag){case 3:hd(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&hd(r.nodeValue,n,(e.mode&1)!==0)}s&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Jr]=t,t.stateNode=r}return Qt(t),null;case 13:if(ot(ct),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(st&&Yn!==null&&t.mode&1&&!(t.flags&128))Ok(),Za(),t.flags|=98560,s=!1;else if(s=pd(t),r!==null&&r.dehydrated!==null){if(e===null){if(!s)throw Error(Y(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(Y(317));s[Jr]=t}else Za(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Qt(t),s=!1}else jr!==null&&(zS(jr),jr=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||ct.current&1?Tt===0&&(Tt=3):q0())),t.updateQueue!==null&&(t.flags|=4),Qt(t),null);case 4:return Ja(),AS(e,t),e===null&&Vl(t.stateNode.containerInfo),Qt(t),null;case 10:return j0(t.type._context),Qt(t),null;case 17:return An(t.type)&&Ap(),Qt(t),null;case 19:if(ot(ct),s=t.memoizedState,s===null)return Qt(t),null;if(r=(t.flags&128)!==0,i=s.rendering,i===null)if(r)Kc(s,!1);else{if(Tt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=Np(e),i!==null){for(t.flags|=128,Kc(s,!1),r=i.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)s=n,e=r,s.flags&=14680066,i=s.alternate,i===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=i.childLanes,s.lanes=i.lanes,s.child=i.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=i.memoizedProps,s.memoizedState=i.memoizedState,s.updateQueue=i.updateQueue,s.type=i.type,e=i.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return qe(ct,ct.current&1|2),t.child}e=e.sibling}s.tail!==null&&wt()>tc&&(t.flags|=128,r=!0,Kc(s,!1),t.lanes=4194304)}else{if(!r)if(e=Np(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Kc(s,!0),s.tail===null&&s.tailMode==="hidden"&&!i.alternate&&!st)return Qt(t),null}else 2*wt()-s.renderingStartTime>tc&&n!==1073741824&&(t.flags|=128,r=!0,Kc(s,!1),t.lanes=4194304);s.isBackwards?(i.sibling=t.child,t.child=i):(n=s.last,n!==null?n.sibling=i:t.child=i,s.last=i)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=wt(),t.sibling=null,n=ct.current,qe(ct,r?n&1|2:n&1),t):(Qt(t),null);case 22:case 23:return X0(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Kn&1073741824&&(Qt(t),t.subtreeFlags&6&&(t.flags|=8192)):Qt(t),null;case 24:return null;case 25:return null}throw Error(Y(156,t.tag))}function fz(e,t){switch(T0(t),t.tag){case 1:return An(t.type)&&Ap(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ja(),ot(Mn),ot(cn),F0(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return L0(t),null;case 13:if(ot(ct),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Y(340));Za()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ot(ct),null;case 4:return Ja(),null;case 10:return j0(t.type._context),null;case 22:case 23:return X0(),null;case 24:return null;default:return null}}var md=!1,nn=!1,gz=typeof WeakSet=="function"?WeakSet:Set,ee=null;function Ea(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){yt(e,t,r)}else n.current=null}function jS(e,t,n){try{n()}catch(r){yt(e,t,r)}}var L1=!1;function mz(e,t){if(mS=kp,e=wk(),_0(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var i=0,a=-1,c=-1,l=0,u=0,d=e,p=null;t:for(;;){for(var f;d!==n||o!==0&&d.nodeType!==3||(a=i+o),d!==s||r!==0&&d.nodeType!==3||(c=i+r),d.nodeType===3&&(i+=d.nodeValue.length),(f=d.firstChild)!==null;)p=d,d=f;for(;;){if(d===e)break t;if(p===n&&++l===o&&(a=i),p===s&&++u===r&&(c=i),(f=d.nextSibling)!==null)break;d=p,p=d.parentNode}d=f}n=a===-1||c===-1?null:{start:a,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(yS={focusedElem:e,selectionRange:n},kp=!1,ee=t;ee!==null;)if(t=ee,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ee=e;else for(;ee!==null;){t=ee;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var g=y.memoizedProps,w=y.memoizedState,S=t.stateNode,v=S.getSnapshotBeforeUpdate(t.elementType===t.type?g:kr(t.type,g),w);S.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var P=t.stateNode.containerInfo;P.nodeType===1?P.textContent="":P.nodeType===9&&P.documentElement&&P.removeChild(P.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Y(163))}}catch(I){yt(t,t.return,I)}if(e=t.sibling,e!==null){e.return=t.return,ee=e;break}ee=t.return}return y=L1,L1=!1,y}function Cl(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var s=o.destroy;o.destroy=void 0,s!==void 0&&jS(t,n,s)}o=o.next}while(o!==r)}}function kf(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function OS(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function yT(e){var t=e.alternate;t!==null&&(e.alternate=null,yT(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Jr],delete t[Xl],delete t[xS],delete t[QN],delete t[JN])),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 ST(e){return e.tag===5||e.tag===3||e.tag===4}function F1(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ST(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 DS(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Mp));else if(r!==4&&(e=e.child,e!==null))for(DS(e,t,n),e=e.sibling;e!==null;)DS(e,t,n),e=e.sibling}function RS(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(RS(e,t,n),e=e.sibling;e!==null;)RS(e,t,n),e=e.sibling}var Nt=null,Mr=!1;function ds(e,t,n){for(n=n.child;n!==null;)vT(e,t,n),n=n.sibling}function vT(e,t,n){if(oo&&typeof oo.onCommitFiberUnmount=="function")try{oo.onCommitFiberUnmount(xf,n)}catch{}switch(n.tag){case 5:nn||Ea(n,t);case 6:var r=Nt,o=Mr;Nt=null,ds(e,t,n),Nt=r,Mr=o,Nt!==null&&(Mr?(e=Nt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Nt.removeChild(n.stateNode));break;case 18:Nt!==null&&(Mr?(e=Nt,n=n.stateNode,e.nodeType===8?sm(e.parentNode,n):e.nodeType===1&&sm(e,n),Kl(e)):sm(Nt,n.stateNode));break;case 4:r=Nt,o=Mr,Nt=n.stateNode.containerInfo,Mr=!0,ds(e,t,n),Nt=r,Mr=o;break;case 0:case 11:case 14:case 15:if(!nn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var s=o,i=s.destroy;s=s.tag,i!==void 0&&(s&2||s&4)&&jS(n,t,i),o=o.next}while(o!==r)}ds(e,t,n);break;case 1:if(!nn&&(Ea(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){yt(n,t,a)}ds(e,t,n);break;case 21:ds(e,t,n);break;case 22:n.mode&1?(nn=(r=nn)||n.memoizedState!==null,ds(e,t,n),nn=r):ds(e,t,n);break;default:ds(e,t,n)}}function N1(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new gz),t.forEach(function(r){var o=Iz.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function _r(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var o=n[r];try{var s=e,i=t,a=i;e:for(;a!==null;){switch(a.tag){case 5:Nt=a.stateNode,Mr=!1;break e;case 3:Nt=a.stateNode.containerInfo,Mr=!0;break e;case 4:Nt=a.stateNode.containerInfo,Mr=!0;break e}a=a.return}if(Nt===null)throw Error(Y(160));vT(s,i,o),Nt=null,Mr=!1;var c=o.alternate;c!==null&&(c.return=null),o.return=null}catch(l){yt(o,t,l)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)xT(t,e),t=t.sibling}function xT(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(_r(t,e),Vr(e),r&4){try{Cl(3,e,e.return),kf(3,e)}catch(g){yt(e,e.return,g)}try{Cl(5,e,e.return)}catch(g){yt(e,e.return,g)}}break;case 1:_r(t,e),Vr(e),r&512&&n!==null&&Ea(n,n.return);break;case 5:if(_r(t,e),Vr(e),r&512&&n!==null&&Ea(n,n.return),e.flags&32){var o=e.stateNode;try{zl(o,"")}catch(g){yt(e,e.return,g)}}if(r&4&&(o=e.stateNode,o!=null)){var s=e.memoizedProps,i=n!==null?n.memoizedProps:s,a=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{a==="input"&&s.type==="radio"&&s.name!=null&&U_(o,s),iS(a,i);var l=iS(a,s);for(i=0;i<c.length;i+=2){var u=c[i],d=c[i+1];u==="style"?V_(o,d):u==="dangerouslySetInnerHTML"?W_(o,d):u==="children"?zl(o,d):f0(o,u,d,l)}switch(a){case"input":tS(o,s);break;case"textarea":H_(o,s);break;case"select":var p=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!s.multiple;var f=s.value;f!=null?Ra(o,!!s.multiple,f,!1):p!==!!s.multiple&&(s.defaultValue!=null?Ra(o,!!s.multiple,s.defaultValue,!0):Ra(o,!!s.multiple,s.multiple?[]:"",!1))}o[Xl]=s}catch(g){yt(e,e.return,g)}}break;case 6:if(_r(t,e),Vr(e),r&4){if(e.stateNode===null)throw Error(Y(162));o=e.stateNode,s=e.memoizedProps;try{o.nodeValue=s}catch(g){yt(e,e.return,g)}}break;case 3:if(_r(t,e),Vr(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Kl(t.containerInfo)}catch(g){yt(e,e.return,g)}break;case 4:_r(t,e),Vr(e);break;case 13:_r(t,e),Vr(e),o=e.child,o.flags&8192&&(s=o.memoizedState!==null,o.stateNode.isHidden=s,!s||o.alternate!==null&&o.alternate.memoizedState!==null||(V0=wt())),r&4&&N1(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(nn=(l=nn)||u,_r(t,e),nn=l):_r(t,e),Vr(e),r&8192){if(l=e.memoizedState!==null,(e.stateNode.isHidden=l)&&!u&&e.mode&1)for(ee=e,u=e.child;u!==null;){for(d=ee=u;ee!==null;){switch(p=ee,f=p.child,p.tag){case 0:case 11:case 14:case 15:Cl(4,p,p.return);break;case 1:Ea(p,p.return);var y=p.stateNode;if(typeof y.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(g){yt(r,n,g)}}break;case 5:Ea(p,p.return);break;case 22:if(p.memoizedState!==null){B1(d);continue}}f!==null?(f.return=p,ee=f):B1(d)}u=u.sibling}e:for(u=null,d=e;;){if(d.tag===5){if(u===null){u=d;try{o=d.stateNode,l?(s=o.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(a=d.stateNode,c=d.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,a.style.display=G_("display",i))}catch(g){yt(e,e.return,g)}}}else if(d.tag===6){if(u===null)try{d.stateNode.nodeValue=l?"":d.memoizedProps}catch(g){yt(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:_r(t,e),Vr(e),r&4&&N1(e);break;case 21:break;default:_r(t,e),Vr(e)}}function Vr(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(ST(n)){var r=n;break e}n=n.return}throw Error(Y(160))}switch(r.tag){case 5:var o=r.stateNode;r.flags&32&&(zl(o,""),r.flags&=-33);var s=F1(e);RS(e,s,o);break;case 3:case 4:var i=r.stateNode.containerInfo,a=F1(e);DS(e,a,i);break;default:throw Error(Y(161))}}catch(c){yt(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function yz(e,t,n){ee=e,wT(e)}function wT(e,t,n){for(var r=(e.mode&1)!==0;ee!==null;){var o=ee,s=o.child;if(o.tag===22&&r){var i=o.memoizedState!==null||md;if(!i){var a=o.alternate,c=a!==null&&a.memoizedState!==null||nn;a=md;var l=nn;if(md=i,(nn=c)&&!l)for(ee=o;ee!==null;)i=ee,c=i.child,i.tag===22&&i.memoizedState!==null?U1(o):c!==null?(c.return=i,ee=c):U1(o);for(;s!==null;)ee=s,wT(s),s=s.sibling;ee=o,md=a,nn=l}z1(e)}else o.subtreeFlags&8772&&s!==null?(s.return=o,ee=s):z1(e)}}function z1(e){for(;ee!==null;){var t=ee;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:nn||kf(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!nn)if(n===null)r.componentDidMount();else{var o=t.elementType===t.type?n.memoizedProps:kr(t.type,n.memoizedProps);r.componentDidUpdate(o,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;s!==null&&C1(t,s,r);break;case 3:var i=t.updateQueue;if(i!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}C1(t,i,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var l=t.alternate;if(l!==null){var u=l.memoizedState;if(u!==null){var d=u.dehydrated;d!==null&&Kl(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Y(163))}nn||t.flags&512&&OS(t)}catch(p){yt(t,t.return,p)}}if(t===e){ee=null;break}if(n=t.sibling,n!==null){n.return=t.return,ee=n;break}ee=t.return}}function B1(e){for(;ee!==null;){var t=ee;if(t===e){ee=null;break}var n=t.sibling;if(n!==null){n.return=t.return,ee=n;break}ee=t.return}}function U1(e){for(;ee!==null;){var t=ee;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{kf(4,t)}catch(c){yt(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var o=t.return;try{r.componentDidMount()}catch(c){yt(t,o,c)}}var s=t.return;try{OS(t)}catch(c){yt(t,s,c)}break;case 5:var i=t.return;try{OS(t)}catch(c){yt(t,i,c)}}}catch(c){yt(t,t.return,c)}if(t===e){ee=null;break}var a=t.sibling;if(a!==null){a.return=t.return,ee=a;break}ee=t.return}}var Sz=Math.ceil,Up=es.ReactCurrentDispatcher,W0=es.ReactCurrentOwner,vr=es.ReactCurrentBatchConfig,Te=0,Dt=null,Et=null,Wt=0,Kn=0,_a=Vs(0),Tt=0,tu=null,ki=0,Tf=0,G0=0,Il=null,En=null,V0=0,tc=1/0,ko=null,Hp=!1,LS=null,Os=null,yd=!1,Cs=null,Kp=0,El=0,FS=null,uh=-1,dh=0;function mn(){return Te&6?wt():uh!==-1?uh:uh=wt()}function Ds(e){return e.mode&1?Te&2&&Wt!==0?Wt&-Wt:tz.transition!==null?(dh===0&&(dh=sk()),dh):(e=ze,e!==0||(e=window.event,e=e===void 0?16:hk(e.type)),e):1}function Fr(e,t,n,r){if(50<El)throw El=0,FS=null,Error(Y(185));Cu(e,n,r),(!(Te&2)||e!==Dt)&&(e===Dt&&(!(Te&2)&&(Tf|=n),Tt===4&&ws(e,Wt)),jn(e,r),n===1&&Te===0&&!(t.mode&1)&&(tc=wt()+500,If&&Ys()))}function jn(e,t){var n=e.callbackNode;tN(e,t);var r=_p(e,e===Dt?Wt:0);if(r===0)n!==null&&Zb(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Zb(n),t===1)e.tag===0?ez(H1.bind(null,e)):Mk(H1.bind(null,e)),qN(function(){!(Te&6)&&Ys()}),n=null;else{switch(ik(r)){case 1:n=v0;break;case 4:n=rk;break;case 16:n=Ep;break;case 536870912:n=ok;break;default:n=Ep}n=TT(n,bT.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function bT(e,t){if(uh=-1,dh=0,Te&6)throw Error(Y(327));var n=e.callbackNode;if(Ba()&&e.callbackNode!==n)return null;var r=_p(e,e===Dt?Wt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Wp(e,r);else{t=r;var o=Te;Te|=2;var s=CT();(Dt!==e||Wt!==t)&&(ko=null,tc=wt()+500,xi(e,t));do try{wz();break}catch(a){PT(e,a)}while(!0);A0(),Up.current=s,Te=o,Et!==null?t=0:(Dt=null,Wt=0,t=Tt)}if(t!==0){if(t===2&&(o=dS(e),o!==0&&(r=o,t=NS(e,o))),t===1)throw n=tu,xi(e,0),ws(e,r),jn(e,wt()),n;if(t===6)ws(e,r);else{if(o=e.current.alternate,!(r&30)&&!vz(o)&&(t=Wp(e,r),t===2&&(s=dS(e),s!==0&&(r=s,t=NS(e,s))),t===1))throw n=tu,xi(e,0),ws(e,r),jn(e,wt()),n;switch(e.finishedWork=o,e.finishedLanes=r,t){case 0:case 1:throw Error(Y(345));case 2:ui(e,En,ko);break;case 3:if(ws(e,r),(r&130023424)===r&&(t=V0+500-wt(),10<t)){if(_p(e,0)!==0)break;if(o=e.suspendedLanes,(o&r)!==r){mn(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=vS(ui.bind(null,e,En,ko),t);break}ui(e,En,ko);break;case 4:if(ws(e,r),(r&4194240)===r)break;for(t=e.eventTimes,o=-1;0<r;){var i=31-Lr(r);s=1<<i,i=t[i],i>o&&(o=i),r&=~s}if(r=o,r=wt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Sz(r/1960))-r,10<r){e.timeoutHandle=vS(ui.bind(null,e,En,ko),r);break}ui(e,En,ko);break;case 5:ui(e,En,ko);break;default:throw Error(Y(329))}}}return jn(e,wt()),e.callbackNode===n?bT.bind(null,e):null}function NS(e,t){var n=Il;return e.current.memoizedState.isDehydrated&&(xi(e,t).flags|=256),e=Wp(e,t),e!==2&&(t=En,En=n,t!==null&&zS(t)),e}function zS(e){En===null?En=e:En.push.apply(En,e)}function vz(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var o=n[r],s=o.getSnapshot;o=o.value;try{if(!Ur(s(),o))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ws(e,t){for(t&=~G0,t&=~Tf,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Lr(t),r=1<<n;e[n]=-1,t&=~r}}function H1(e){if(Te&6)throw Error(Y(327));Ba();var t=_p(e,0);if(!(t&1))return jn(e,wt()),null;var n=Wp(e,t);if(e.tag!==0&&n===2){var r=dS(e);r!==0&&(t=r,n=NS(e,r))}if(n===1)throw n=tu,xi(e,0),ws(e,t),jn(e,wt()),n;if(n===6)throw Error(Y(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,ui(e,En,ko),jn(e,wt()),null}function Y0(e,t){var n=Te;Te|=1;try{return e(t)}finally{Te=n,Te===0&&(tc=wt()+500,If&&Ys())}}function Ti(e){Cs!==null&&Cs.tag===0&&!(Te&6)&&Ba();var t=Te;Te|=1;var n=vr.transition,r=ze;try{if(vr.transition=null,ze=1,e)return e()}finally{ze=r,vr.transition=n,Te=t,!(Te&6)&&Ys()}}function X0(){Kn=_a.current,ot(_a)}function xi(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,XN(n)),Et!==null)for(n=Et.return;n!==null;){var r=n;switch(T0(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Ap();break;case 3:Ja(),ot(Mn),ot(cn),F0();break;case 5:L0(r);break;case 4:Ja();break;case 13:ot(ct);break;case 19:ot(ct);break;case 10:j0(r.type._context);break;case 22:case 23:X0()}n=n.return}if(Dt=e,Et=e=Rs(e.current,null),Wt=Kn=t,Tt=0,tu=null,G0=Tf=ki=0,En=Il=null,gi!==null){for(t=0;t<gi.length;t++)if(n=gi[t],r=n.interleaved,r!==null){n.interleaved=null;var o=r.next,s=n.pending;if(s!==null){var i=s.next;s.next=o,r.next=i}n.pending=r}gi=null}return e}function PT(e,t){do{var n=Et;try{if(A0(),ah.current=Bp,zp){for(var r=ht.memoizedState;r!==null;){var o=r.queue;o!==null&&(o.pending=null),r=r.next}zp=!1}if(_i=0,At=kt=ht=null,Pl=!1,Ql=0,W0.current=null,n===null||n.return===null){Tt=1,tu=t,Et=null;break}e:{var s=e,i=n.return,a=n,c=t;if(t=Wt,a.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var l=c,u=a,d=u.tag;if(!(u.mode&1)&&(d===0||d===11||d===15)){var p=u.alternate;p?(u.updateQueue=p.updateQueue,u.memoizedState=p.memoizedState,u.lanes=p.lanes):(u.updateQueue=null,u.memoizedState=null)}var f=$1(i);if(f!==null){f.flags&=-257,M1(f,i,a,s,t),f.mode&1&&T1(s,l,t),t=f,c=l;var y=t.updateQueue;if(y===null){var g=new Set;g.add(c),t.updateQueue=g}else y.add(c);break e}else{if(!(t&1)){T1(s,l,t),q0();break e}c=Error(Y(426))}}else if(st&&a.mode&1){var w=$1(i);if(w!==null){!(w.flags&65536)&&(w.flags|=256),M1(w,i,a,s,t),$0(ec(c,a));break e}}s=c=ec(c,a),Tt!==4&&(Tt=2),Il===null?Il=[s]:Il.push(s),s=i;do{switch(s.tag){case 3:s.flags|=65536,t&=-t,s.lanes|=t;var S=iT(s,c,t);P1(s,S);break e;case 1:a=c;var v=s.type,P=s.stateNode;if(!(s.flags&128)&&(typeof v.getDerivedStateFromError=="function"||P!==null&&typeof P.componentDidCatch=="function"&&(Os===null||!Os.has(P)))){s.flags|=65536,t&=-t,s.lanes|=t;var I=aT(s,a,t);P1(s,I);break e}}s=s.return}while(s!==null)}ET(n)}catch(C){t=C,Et===n&&n!==null&&(Et=n=n.return);continue}break}while(!0)}function CT(){var e=Up.current;return Up.current=Bp,e===null?Bp:e}function q0(){(Tt===0||Tt===3||Tt===2)&&(Tt=4),Dt===null||!(ki&268435455)&&!(Tf&268435455)||ws(Dt,Wt)}function Wp(e,t){var n=Te;Te|=2;var r=CT();(Dt!==e||Wt!==t)&&(ko=null,xi(e,t));do try{xz();break}catch(o){PT(e,o)}while(!0);if(A0(),Te=n,Up.current=r,Et!==null)throw Error(Y(261));return Dt=null,Wt=0,Tt}function xz(){for(;Et!==null;)IT(Et)}function wz(){for(;Et!==null&&!G6();)IT(Et)}function IT(e){var t=kT(e.alternate,e,Kn);e.memoizedProps=e.pendingProps,t===null?ET(e):Et=t,W0.current=null}function ET(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=fz(n,t),n!==null){n.flags&=32767,Et=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Tt=6,Et=null;return}}else if(n=pz(n,t,Kn),n!==null){Et=n;return}if(t=t.sibling,t!==null){Et=t;return}Et=t=e}while(t!==null);Tt===0&&(Tt=5)}function ui(e,t,n){var r=ze,o=vr.transition;try{vr.transition=null,ze=1,bz(e,t,n,r)}finally{vr.transition=o,ze=r}return null}function bz(e,t,n,r){do Ba();while(Cs!==null);if(Te&6)throw Error(Y(327));n=e.finishedWork;var o=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Y(177));e.callbackNode=null,e.callbackPriority=0;var s=n.lanes|n.childLanes;if(nN(e,s),e===Dt&&(Et=Dt=null,Wt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||yd||(yd=!0,TT(Ep,function(){return Ba(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=vr.transition,vr.transition=null;var i=ze;ze=1;var a=Te;Te|=4,W0.current=null,mz(e,n),xT(n,e),UN(yS),kp=!!mS,yS=mS=null,e.current=n,yz(n),V6(),Te=a,ze=i,vr.transition=s}else e.current=n;if(yd&&(yd=!1,Cs=e,Kp=o),s=e.pendingLanes,s===0&&(Os=null),q6(n.stateNode),jn(e,wt()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)o=t[n],r(o.value,{componentStack:o.stack,digest:o.digest});if(Hp)throw Hp=!1,e=LS,LS=null,e;return Kp&1&&e.tag!==0&&Ba(),s=e.pendingLanes,s&1?e===FS?El++:(El=0,FS=e):El=0,Ys(),null}function Ba(){if(Cs!==null){var e=ik(Kp),t=vr.transition,n=ze;try{if(vr.transition=null,ze=16>e?16:e,Cs===null)var r=!1;else{if(e=Cs,Cs=null,Kp=0,Te&6)throw Error(Y(331));var o=Te;for(Te|=4,ee=e.current;ee!==null;){var s=ee,i=s.child;if(ee.flags&16){var a=s.deletions;if(a!==null){for(var c=0;c<a.length;c++){var l=a[c];for(ee=l;ee!==null;){var u=ee;switch(u.tag){case 0:case 11:case 15:Cl(8,u,s)}var d=u.child;if(d!==null)d.return=u,ee=d;else for(;ee!==null;){u=ee;var p=u.sibling,f=u.return;if(yT(u),u===l){ee=null;break}if(p!==null){p.return=f,ee=p;break}ee=f}}}var y=s.alternate;if(y!==null){var g=y.child;if(g!==null){y.child=null;do{var w=g.sibling;g.sibling=null,g=w}while(g!==null)}}ee=s}}if(s.subtreeFlags&2064&&i!==null)i.return=s,ee=i;else e:for(;ee!==null;){if(s=ee,s.flags&2048)switch(s.tag){case 0:case 11:case 15:Cl(9,s,s.return)}var S=s.sibling;if(S!==null){S.return=s.return,ee=S;break e}ee=s.return}}var v=e.current;for(ee=v;ee!==null;){i=ee;var P=i.child;if(i.subtreeFlags&2064&&P!==null)P.return=i,ee=P;else e:for(i=v;ee!==null;){if(a=ee,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:kf(9,a)}}catch(C){yt(a,a.return,C)}if(a===i){ee=null;break e}var I=a.sibling;if(I!==null){I.return=a.return,ee=I;break e}ee=a.return}}if(Te=o,Ys(),oo&&typeof oo.onPostCommitFiberRoot=="function")try{oo.onPostCommitFiberRoot(xf,e)}catch{}r=!0}return r}finally{ze=n,vr.transition=t}}return!1}function K1(e,t,n){t=ec(n,t),t=iT(e,t,1),e=js(e,t,1),t=mn(),e!==null&&(Cu(e,1,t),jn(e,t))}function yt(e,t,n){if(e.tag===3)K1(e,e,n);else for(;t!==null;){if(t.tag===3){K1(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Os===null||!Os.has(r))){e=ec(n,e),e=aT(t,e,1),t=js(t,e,1),e=mn(),t!==null&&(Cu(t,1,e),jn(t,e));break}}t=t.return}}function Pz(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=mn(),e.pingedLanes|=e.suspendedLanes&n,Dt===e&&(Wt&n)===n&&(Tt===4||Tt===3&&(Wt&130023424)===Wt&&500>wt()-V0?xi(e,0):G0|=n),jn(e,t)}function _T(e,t){t===0&&(e.mode&1?(t=ad,ad<<=1,!(ad&130023424)&&(ad=4194304)):t=1);var n=mn();e=Wo(e,t),e!==null&&(Cu(e,t,n),jn(e,n))}function Cz(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),_T(e,n)}function Iz(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Y(314))}r!==null&&r.delete(t),_T(e,n)}var kT;kT=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Mn.current)kn=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return kn=!1,hz(e,t,n);kn=!!(e.flags&131072)}else kn=!1,st&&t.flags&1048576&&Ak(t,Dp,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;lh(e,t),e=t.pendingProps;var o=qa(t,cn.current);za(t,n),o=z0(null,t,r,e,o,n);var s=B0();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,An(r)?(s=!0,jp(t)):s=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,D0(t),o.updater=_f,t.stateNode=o,o._reactInternals=t,ES(t,r,e,n),t=TS(null,t,r,!0,s,n)):(t.tag=0,st&&s&&k0(t),dn(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(lh(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=_z(r),e=kr(r,e),o){case 0:t=kS(null,t,r,e,n);break e;case 1:t=O1(null,t,r,e,n);break e;case 11:t=A1(null,t,r,e,n);break e;case 14:t=j1(null,t,r,kr(r.type,e),n);break e}throw Error(Y(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:kr(r,o),kS(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:kr(r,o),O1(e,t,r,o,n);case 3:e:{if(dT(t),e===null)throw Error(Y(387));r=t.pendingProps,s=t.memoizedState,o=s.element,Fk(e,t),Fp(t,r,null,n);var i=t.memoizedState;if(r=i.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){o=ec(Error(Y(423)),t),t=D1(e,t,r,n,o);break e}else if(r!==o){o=ec(Error(Y(424)),t),t=D1(e,t,r,n,o);break e}else for(Yn=As(t.stateNode.containerInfo.firstChild),Qn=t,st=!0,jr=null,n=Rk(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Za(),r===o){t=Go(e,t,n);break e}dn(e,t,r,n)}t=t.child}return t;case 5:return Nk(t),e===null&&PS(t),r=t.type,o=t.pendingProps,s=e!==null?e.memoizedProps:null,i=o.children,SS(r,o)?i=null:s!==null&&SS(r,s)&&(t.flags|=32),uT(e,t),dn(e,t,i,n),t.child;case 6:return e===null&&PS(t),null;case 13:return hT(e,t,n);case 4:return R0(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Qa(t,null,r,n):dn(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:kr(r,o),A1(e,t,r,o,n);case 7:return dn(e,t,t.pendingProps,n),t.child;case 8:return dn(e,t,t.pendingProps.children,n),t.child;case 12:return dn(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,s=t.memoizedProps,i=o.value,qe(Rp,r._currentValue),r._currentValue=i,s!==null)if(Ur(s.value,i)){if(s.children===o.children&&!Mn.current){t=Go(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){i=s.child;for(var c=a.firstContext;c!==null;){if(c.context===r){if(s.tag===1){c=Lo(-1,n&-n),c.tag=2;var l=s.updateQueue;if(l!==null){l=l.shared;var u=l.pending;u===null?c.next=c:(c.next=u.next,u.next=c),l.pending=c}}s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),CS(s.return,n,t),a.lanes|=n;break}c=c.next}}else if(s.tag===10)i=s.type===t.type?null:s.child;else if(s.tag===18){if(i=s.return,i===null)throw Error(Y(341));i.lanes|=n,a=i.alternate,a!==null&&(a.lanes|=n),CS(i,n,t),i=s.sibling}else i=s.child;if(i!==null)i.return=s;else for(i=s;i!==null;){if(i===t){i=null;break}if(s=i.sibling,s!==null){s.return=i.return,i=s;break}i=i.return}s=i}dn(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,za(t,n),o=xr(o),r=r(o),t.flags|=1,dn(e,t,r,n),t.child;case 14:return r=t.type,o=kr(r,t.pendingProps),o=kr(r.type,o),j1(e,t,r,o,n);case 15:return cT(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:kr(r,o),lh(e,t),t.tag=1,An(r)?(e=!0,jp(t)):e=!1,za(t,n),sT(t,r,o),ES(t,r,o,n),TS(null,t,r,!0,e,n);case 19:return pT(e,t,n);case 22:return lT(e,t,n)}throw Error(Y(156,t.tag))};function TT(e,t){return nk(e,t)}function Ez(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mr(e,t,n,r){return new Ez(e,t,n,r)}function Z0(e){return e=e.prototype,!(!e||!e.isReactComponent)}function _z(e){if(typeof e=="function")return Z0(e)?1:0;if(e!=null){if(e=e.$$typeof,e===m0)return 11;if(e===y0)return 14}return 2}function Rs(e,t){var n=e.alternate;return n===null?(n=mr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function hh(e,t,n,r,o,s){var i=2;if(r=e,typeof e=="function")Z0(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case ya:return wi(n.children,o,s,t);case g0:i=8,o|=8;break;case qy:return e=mr(12,n,t,o|2),e.elementType=qy,e.lanes=s,e;case Zy:return e=mr(13,n,t,o),e.elementType=Zy,e.lanes=s,e;case Qy:return e=mr(19,n,t,o),e.elementType=Qy,e.lanes=s,e;case N_:return $f(n,o,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case L_:i=10;break e;case F_:i=9;break e;case m0:i=11;break e;case y0:i=14;break e;case ys:i=16,r=null;break e}throw Error(Y(130,e==null?e:typeof e,""))}return t=mr(i,n,t,o),t.elementType=e,t.type=r,t.lanes=s,t}function wi(e,t,n,r){return e=mr(7,e,r,t),e.lanes=n,e}function $f(e,t,n,r){return e=mr(22,e,r,t),e.elementType=N_,e.lanes=n,e.stateNode={isHidden:!1},e}function pm(e,t,n){return e=mr(6,e,null,t),e.lanes=n,e}function fm(e,t,n){return t=mr(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function kz(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yg(0),this.expirationTimes=Yg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yg(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function Q0(e,t,n,r,o,s,i,a,c){return e=new kz(e,t,n,a,c),t===1?(t=1,s===!0&&(t|=8)):t=0,s=mr(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},D0(s),e}function Tz(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ma,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function $T(e){if(!e)return zs;e=e._reactInternals;e:{if(zi(e)!==e||e.tag!==1)throw Error(Y(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(An(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Y(171))}if(e.tag===1){var n=e.type;if(An(n))return $k(e,n,t)}return t}function MT(e,t,n,r,o,s,i,a,c){return e=Q0(n,r,!0,e,o,s,i,a,c),e.context=$T(null),n=e.current,r=mn(),o=Ds(n),s=Lo(r,o),s.callback=t??null,js(n,s,o),e.current.lanes=o,Cu(e,o,r),jn(e,r),e}function Mf(e,t,n,r){var o=t.current,s=mn(),i=Ds(o);return n=$T(n),t.context===null?t.context=n:t.pendingContext=n,t=Lo(s,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=js(o,t,i),e!==null&&(Fr(e,o,i,s),ih(e,o,i)),i}function Gp(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 W1(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function J0(e,t){W1(e,t),(e=e.alternate)&&W1(e,t)}function $z(){return null}var AT=typeof reportError=="function"?reportError:function(e){console.error(e)};function ex(e){this._internalRoot=e}Af.prototype.render=ex.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Y(409));Mf(e,t,null,null)};Af.prototype.unmount=ex.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ti(function(){Mf(null,e,null,null)}),t[Ko]=null}};function Af(e){this._internalRoot=e}Af.prototype.unstable_scheduleHydration=function(e){if(e){var t=lk();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xs.length&&t!==0&&t<xs[n].priority;n++);xs.splice(n,0,e),n===0&&dk(e)}};function tx(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function jf(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function G1(){}function Mz(e,t,n,r,o){if(o){if(typeof r=="function"){var s=r;r=function(){var l=Gp(i);s.call(l)}}var i=MT(t,r,e,0,null,!1,!1,"",G1);return e._reactRootContainer=i,e[Ko]=i.current,Vl(e.nodeType===8?e.parentNode:e),Ti(),i}for(;o=e.lastChild;)e.removeChild(o);if(typeof r=="function"){var a=r;r=function(){var l=Gp(c);a.call(l)}}var c=Q0(e,0,!1,null,null,!1,!1,"",G1);return e._reactRootContainer=c,e[Ko]=c.current,Vl(e.nodeType===8?e.parentNode:e),Ti(function(){Mf(t,c,n,r)}),c}function Of(e,t,n,r,o){var s=n._reactRootContainer;if(s){var i=s;if(typeof o=="function"){var a=o;o=function(){var c=Gp(i);a.call(c)}}Mf(t,i,e,o)}else i=Mz(n,t,e,o,r);return Gp(i)}ak=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=ll(t.pendingLanes);n!==0&&(x0(t,n|1),jn(t,wt()),!(Te&6)&&(tc=wt()+500,Ys()))}break;case 13:Ti(function(){var r=Wo(e,1);if(r!==null){var o=mn();Fr(r,e,1,o)}}),J0(e,1)}};w0=function(e){if(e.tag===13){var t=Wo(e,134217728);if(t!==null){var n=mn();Fr(t,e,134217728,n)}J0(e,134217728)}};ck=function(e){if(e.tag===13){var t=Ds(e),n=Wo(e,t);if(n!==null){var r=mn();Fr(n,e,t,r)}J0(e,t)}};lk=function(){return ze};uk=function(e,t){var n=ze;try{return ze=e,t()}finally{ze=n}};cS=function(e,t,n){switch(t){case"input":if(tS(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var o=Cf(r);if(!o)throw Error(Y(90));B_(r),tS(r,o)}}}break;case"textarea":H_(e,n);break;case"select":t=n.value,t!=null&&Ra(e,!!n.multiple,t,!1)}};q_=Y0;Z_=Ti;var Az={usingClientEntryPoint:!1,Events:[Eu,wa,Cf,Y_,X_,Y0]},Wc={findFiberByHostInstance:fi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},jz={bundleType:Wc.bundleType,version:Wc.version,rendererPackageName:Wc.rendererPackageName,rendererConfig:Wc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:es.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=ek(e),e===null?null:e.stateNode},findFiberByHostInstance:Wc.findFiberByHostInstance||$z,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Sd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Sd.isDisabled&&Sd.supportsFiber)try{xf=Sd.inject(jz),oo=Sd}catch{}}sr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Az;sr.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!tx(t))throw Error(Y(200));return Tz(e,t,null,n)};sr.createRoot=function(e,t){if(!tx(e))throw Error(Y(299));var n=!1,r="",o=AT;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(o=t.onRecoverableError)),t=Q0(e,1,!1,null,null,n,!1,r,o),e[Ko]=t.current,Vl(e.nodeType===8?e.parentNode:e),new ex(t)};sr.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(Y(188)):(e=Object.keys(e).join(","),Error(Y(268,e)));return e=ek(t),e=e===null?null:e.stateNode,e};sr.flushSync=function(e){return Ti(e)};sr.hydrate=function(e,t,n){if(!jf(t))throw Error(Y(200));return Of(null,e,t,!0,n)};sr.hydrateRoot=function(e,t,n){if(!tx(e))throw Error(Y(405));var r=n!=null&&n.hydratedSources||null,o=!1,s="",i=AT;if(n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=MT(t,null,e,1,n??null,o,!1,s,i),e[Ko]=t.current,Vl(e),r)for(e=0;e<r.length;e++)n=r[e],o=n._getVersion,o=o(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,o]:t.mutableSourceEagerHydrationData.push(n,o);return new Af(t)};sr.render=function(e,t,n){if(!jf(t))throw Error(Y(200));return Of(null,e,t,!1,n)};sr.unmountComponentAtNode=function(e){if(!jf(e))throw Error(Y(40));return e._reactRootContainer?(Ti(function(){Of(null,null,e,!1,function(){e._reactRootContainer=null,e[Ko]=null})}),!0):!1};sr.unstable_batchedUpdates=Y0;sr.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!jf(n))throw Error(Y(200));if(e==null||e._reactInternals===void 0)throw Error(Y(38));return Of(e,t,n,!1,r)};sr.version="18.3.1-next-f1338f8080-20240426";function jT(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(jT)}catch(e){console.error(e)}}jT(),j_.exports=sr;var Bi=j_.exports;const Oz=lc(Bi);var BS={},OT,V1=Bi;OT=BS.createRoot=V1.createRoot,BS.hydrateRoot=V1.hydrateRoot;function Bs({children:e,className:t="",...n}){return h.jsx("svg",{...n,className:ue("tl-svg-container",t),children:e})}function nx(e,t,n,r){const o=e.x-n.x,s=e.y-n.y,i=r.x-n.x,a=r.y-n.y,c=t.x-e.x,l=t.y-e.y,u=i*s-a*o,d=c*s-l*o,p=a*c-i*l;if(u===0||d===0||p===0)return null;if(p!==0){const f=u/p,y=d/p;if(0<=f&&f<=1&&0<=y&&y<=1)return b.AddXY(e,f*c,f*l)}return null}function Df(e,t,n,r){const o=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y),s=2*((t.x-e.x)*(e.x-n.x)+(t.y-e.y)*(e.y-n.y)),i=n.x*n.x+n.y*n.y+e.x*e.x+e.y*e.y-2*(n.x*e.x+n.y*e.y)-r*r,a=s*s-4*o*i;if(a<0||a===0)return null;const c=Math.sqrt(a),l=(-s+c)/(2*o),u=(-s-c)/(2*o);if((l<0||l>1)&&(u<0||u>1))return null;const d=[];return 0<=l&&l<=1&&d.push(b.Lrp(e,t,l)),0<=u&&u<=1&&d.push(b.Lrp(e,t,u)),d.length===0?null:d}function Dz(e,t,n){const r=[];let o;for(let s=0,i=n.length-1;s<i;s++)o=nx(e,t,n[s],n[s+1]),o&&r.push(o);return r.length===0?null:r}function rx(e,t,n){const r=[];let o;for(let s=1,i=n.length;s<i+1;s++)o=nx(e,t,n[s-1],n[s%n.length]),o&&r.push(o);return r.length===0?null:r}function Rz(e,t,n,r){let o=n.x-e.x,s=n.y-e.y;const i=Math.sqrt(o*o+s*s),a=(i*i-r*r+t*t)/(2*i),c=Math.sqrt(t*t-a*a);return o/=i,s/=i,[new b(e.x+o*a-s*c,e.y+s*a+o*c),new b(e.x+o*a+s*c,e.y+s*a-o*c)]}function US(e,t,n){const r=[];let o,s,i;for(let a=0,c=n.length;a<c;a++)o=n[a],s=n[(a+1)%n.length],i=Df(o,s,e,t),i&&r.push(...i);return r.length===0?null:r}function Y1(e,t,n){const r=[];let o,s,i;for(let a=1,c=n.length;a<c;a++)o=n[a-1],s=n[a],i=Df(o,s,e,t),i&&r.push(...i);return r.length===0?null:r}function vd(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function ox(e,t,n,r){return vd(e,n,r)!==vd(t,n,r)&&vd(e,t,n)!==vd(e,t,r)}function X1(e,t){const n=new Map;let r,o,s,i;for(let a=0,c=e.length;a<c;a++)if(r=e[a],Zn(r,t)){const l=gm(r);n.has(l)||n.set(l,r)}for(let a=0,c=t.length;a<c;a++)if(r=t[a],Zn(r,e)){const l=gm(r);n.has(l)||n.set(l,r)}for(let a=0,c=e.length;a<c;a++){r=e[a],o=e[(a+1)%e.length];for(let l=0,u=t.length;l<u;l++){s=t[l],i=t[(l+1)%t.length];const d=nx(r,o,s,i);if(d!==null){const p=gm(d);n.has(p)||n.set(p,d)}}}return n.size===0?null:Lz([...n.values()])}function gm(e){return`${e.x},${e.y}`}function Lz(e){const t=b.Average(e);return e.sort((n,r)=>b.Angle(t,n)-b.Angle(t,r))}function DT(e,t){let n,r,o,s;for(let i=0,a=e.length;i<a;i++){n=e[i],r=e[(i+1)%a];for(let c=0,l=t.length;c<l;c++)if(o=t[c],s=t[(c+1)%l],ox(n,r,o,s))return!0}return!1}function Fz(e,t){let n,r,o,s;for(let i=0,a=e.length;i<a;i++){n=e[i],r=e[(i+1)%a];for(let c=1,l=t.length;c<l;c++)if(o=t[c-1],s=t[c],ox(n,r,o,s))return!0}return!1}class nu extends Fi{constructor(n){super({...n,isClosed:!1,isFilled:!1});m(this,"start");m(this,"end");m(this,"d");m(this,"u");m(this,"ul");m(this,"_length");const{start:r,end:o}=n;this.start=r,this.end=o,this.d=r.clone().sub(o),this.u=this.d.clone().uni(),this.ul=this.u.len()}get length(){return this._length?this._length:this.d.len()}midPoint(){return this.start.lrp(this.end,.5)}getVertices(){return[this.start,this.end]}nearestPoint(n){const{start:r,end:o,u:s,ul:i}=this;if(i===0)return r;const a=b.Sub(n,r).dpr(s)/i,c=r.x+s.x*a;if(c<Math.min(r.x,o.x))return r.x<o.x?r:o;if(c>Math.max(r.x,o.x))return r.x>o.x?r:o;const l=r.y+s.y*a;return l<Math.min(r.y,o.y)?r.y<o.y?r:o:l>Math.max(r.y,o.y)?r.y>o.y?r:o:new b(c,l)}hitTestLineSegment(n,r,o=0){return ox(n,r,this.start,this.end)||this.distanceToLineSegment(n,r)<=o}}class Ui extends Fi{constructor(n){super({isClosed:!1,isFilled:!1,...n});m(this,"points");m(this,"_segments");m(this,"_length");const{points:r}=n;this.points=r}get segments(){if(!this._segments){this._segments=[];const{vertices:n}=this;for(let r=0,o=n.length-1;r<o;r++){const s=n[r],i=n[r+1];this._segments.push(new nu({start:s,end:i}))}this.isClosed&&this._segments.push(new nu({start:n[n.length-1],end:n[0]}))}return this._segments}get length(){return this._length||(this._length=this.segments.reduce((n,r)=>n+r.length,0)),this._length}getVertices(){return this.points}nearestPoint(n){const{segments:r}=this;let o=this.points[0],s=1/0,i,a;for(let c=0;c<r.length;c++)i=r[c].nearestPoint(n),a=b.Dist2(i,n),a<s&&(o=i,s=a);if(!o)throw Error("nearest point not found");return o}hitTestLineSegment(n,r,o=0){const{segments:s}=this;for(let i=0,a=s.length;i<a;i++)if(s[i].hitTestLineSegment(n,r,o))return!0;return!1}}class Ct extends Ui{constructor(t){super({...t}),this.isClosed=!0}}class Vo extends Ct{constructor(n){const{x:r=0,y:o=0,width:s,height:i}=n;super({...n,points:[new b(r,o),new b(r+s,o),new b(r+s,o+i),new b(r,o+i)]});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 te(this.x,this.y,this.w,this.h)}}class Nr{constructor(t){m(this,"canSnap",()=>!0);m(this,"canScroll",()=>!1);m(this,"canBind",(t,n)=>!0);m(this,"canEdit",()=>!1);m(this,"canResize",()=>!0);m(this,"canEditInReadOnly",()=>!1);m(this,"canCrop",()=>!1);m(this,"hideResizeHandles",()=>!1);m(this,"hideRotateHandle",()=>!1);m(this,"hideSelectionBoundsBg",()=>!1);m(this,"hideSelectionBoundsFg",()=>!1);m(this,"isAspectRatioLocked",()=>!1);m(this,"onBeforeCreate");m(this,"onBeforeUpdate");m(this,"onDragShapesOver");m(this,"onDragShapesOut");m(this,"onDropShapesOver");m(this,"onResizeStart");m(this,"onResize");m(this,"onResizeEnd");m(this,"onTranslateStart");m(this,"onTranslate");m(this,"onTranslateEnd");m(this,"onHandleDrag");m(this,"onRotateStart");m(this,"onRotate");m(this,"onRotateEnd");m(this,"onBindingChange");m(this,"onChildrenChange");m(this,"onDoubleClickHandle");m(this,"onDoubleClickEdge");m(this,"onDoubleClick");m(this,"onClick");m(this,"onEditEnd");this.editor=t}providesBackgroundForChildren(t){return!1}canReceiveNewChildrenOfType(t,n){return!1}canDropShapes(t,n){return!1}expandSelectionOutlinePx(t){return 0}getCanvasSvgDefs(){return[]}getBoundsSnapGeometry(t){return{}}getHandleSnapGeometry(t){return{}}}m(Nr,"props"),m(Nr,"migrations"),m(Nr,"type");function Nz(e,t,n={}){const{closed:r=!1,snap:o=1,start:s="outset",end:i="outset",lengthRatio:a=2,style:c="dashed"}=n;let l=0,u=0,d=1,p=0,f=0;switch(c){case"dashed":{d=1,l=Math.min(t*a,e/4);break}case"dotted":{d=100,l=t/d;break}default:return{strokeDasharray:"none",strokeDashoffset:"none"}}return r||(s==="outset"?(e+=l/2,f+=l/2):s==="skip"&&(e-=l,f-=l),i==="outset"?e+=l/2:i==="skip"&&(e-=l)),u=Math.floor(e/l/(2*d)),u-=u%o,u<3&&c==="dashed"?e/t<5?(l=e,u=1,p=0):(l=e*.333,p=e*.333):(u=Math.max(u,3),l=e/u/(2*d),r?(f=l/2,p=(e-u*l)/u):p=(e-u*l)/Math.max(1,u-1)),{strokeDasharray:[l,p].join(" "),strokeDashoffset:f.toString()}}function q1({bounds:e,className:t}){const n=z(),r=K("zoom level",()=>n.getZoomLevel(),[n]);return h.jsx("g",{className:t,pointerEvents:"none",strokeLinecap:"round",strokeLinejoin:"round",children:e.sides.map((o,s)=>{const{strokeDasharray:i,strokeDashoffset:a}=Nz(o[0].dist(o[1]),1/r,{style:"dashed",lengthRatio:4});return h.jsx("line",{x1:o[0].x,y1:o[0].y,x2:o[1].x,y2:o[1].y,strokeDasharray:i,strokeDashoffset:a},s)})})}class ph extends Nr{constructor(){super(...arguments);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"canBind",()=>!1);m(this,"onChildrenChange",n=>{const r=this.editor.getSortedChildIdsForParent(n.id);if(r.length===0){this.editor.getCurrentPageState().focusedGroupId===n.id&&this.editor.popFocusedGroupId(),this.editor.deleteShapes([n.id]);return}else if(r.length===1){this.editor.getCurrentPageState().focusedGroupId===n.id&&this.editor.popFocusedGroupId(),this.editor.reparentShapes(r,n.parentId),this.editor.deleteShapes([n.id]);return}})}getDefaultProps(){return{}}getGeometry(n){const r=this.editor.getSortedChildIdsForParent(n.id);return r.length===0?new Vo({width:1,height:1,isFilled:!1}):new Br({children:r.map(o=>{const s=this.editor.getShape(o),i=this.editor.getShapeGeometry(o),a=this.editor.getShapeLocalTransform(s).applyToPoints(i.vertices);return i.isClosed?new Ct({points:a,isFilled:!0}):new Ui({points:a})})})}component(n){const r=this.editor.getErasingShapeIds().includes(n.id),{hintingShapeIds:o}=this.editor.getCurrentPageState(),s=o.length>0&&o.some(c=>c!==n.id&&this.editor.isShapeOfType(this.editor.getShape(c),"group")),i=this.editor.getCurrentPageState().focusedGroupId!==n.id;if(!r&&(i||s))return null;const a=this.editor.getShapeGeometry(n).bounds;return h.jsx(Bs,{id:n.id,children:h.jsx(q1,{className:"tl-group",bounds:a})})}indicator(n){const r=this.editor.getShapeGeometry(n).bounds;return h.jsx(q1,{className:"",bounds:r})}}m(ph,"type","group"),m(ph,"props",TE),m(ph,"migrations",$E);const RT=[ph],zz=new Set(RT.map(e=>e.type));function LT(e){const t=[...RT],n=new Set;for(const r of e){if(zz.has(r.type))throw new Error(`Shape type "${r.type}" is a core shapes type and cannot be overridden`);if(n.has(r.type))throw new Error(`Shape type "${r.type}" is defined more than once`);t.push(r),n.add(r.type)}return t}function Z1(e,t){if(!t)return!1;switch(e.type){case"mixed":return t.type==="mixed";case"shared":return t.type==="shared"&&e.value===t.value;default:throw fn(e)}}class Bz{constructor(t){m(this,"map");this.map=new Map(t)}get(t){return this.map.get(t)}getAsKnownValue(t){const n=this.get(t);if(n&&n.type!=="mixed")return n.value}get size(){return this.map.size}equals(t){if(this.size!==t.size)return!1;const n=new Set;for(const[r,o]of this){if(!Z1(o,t.get(r)))return!1;n.add(r)}for(const[r,o]of t)if(!n.has(r)&&!Z1(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 HS extends Bz{set(t,n){this.map.set(t,n)}applyValue(t,n){const r=this.get(t);if(!r){this.set(t,{type:"shared",value:n});return}switch(r.type){case"mixed":return;case"shared":r.value!==n&&this.set(t,{type:"mixed"});return;default:fn(r,"type")}}}class Rf{constructor(){m(this,"items",new WeakMap)}get(t,n){return this.items.has(t)||this.items.set(t,n(t)),this.items.get(t)}access(t){return this.items.get(t)}set(t,n){this.items.set(t,n)}has(t){return this.items.has(t)}invalidate(t){this.items.delete(t)}bust(){this.items=new WeakMap}}function Uz(e,t,n){return fetch(e).then(function(r){return r.arrayBuffer()}).then(function(r){return new File([r],t,{type:n})})}function Hz(e,t){var o;let n=e;const r=new Set(t);for(;r.has(n);)n=(o=/^.*(\d+)$/.exec(n))!=null&&o[1]?n.replace(/(\d+)(?=\D?)$/,s=>(+s+1).toString()):`${n} 1`;return n}function xd(e,t,n){if(n.length===0)return[];const r=new Map;for(const s of fe(n.map(i=>e.getShape(i)))){const{parentId:i}=s;r.has(i)||r.set(i,{children:fe(e.getSortedChildIdsForParent(i).map(a=>e.getShape(a))),moving:new Set}),r.get(i).moving.add(s)}const o=[];switch(t){case"toBack":{r.forEach(({moving:s,children:i})=>Kz(s,i,o));break}case"toFront":{r.forEach(({moving:s,children:i})=>Wz(s,i,o));break}case"forward":{r.forEach(({moving:s,children:i})=>Gz(s,i,o));break}case"backward":{r.forEach(({moving:s,children:i})=>Vz(s,i,o));break}}return o}function Kz(e,t,n){const r=t.length;if(e.size===r)return;let o,s;for(let i=0;i<r;i++){const a=t[i];if(e.has(a))o=a.index,e.delete(a);else{s=a.index;break}}if(e.size!==0){const i=Va(o,s,e.size);n.push(...Array.from(e.values()).sort(rn).map((a,c)=>({...a,index:i[c]})))}}function Wz(e,t,n){const r=t.length;if(e.size===r)return;let o,s;for(let i=r-1;i>-1;i--){const a=t[i];if(e.has(a))s=a.index,e.delete(a);else{o=a.index;break}}if(e.size!==0){const i=Va(o,s,e.size);n.push(...Array.from(e.values()).sort(rn).map((a,c)=>({...a,index:i[c]})))}}function Gz(e,t,n){var s;const r=t.length;if(e.size===r)return;let o={name:"skipping"};for(let i=0;i<r;i++){const a=e.has(t[i]);switch(o.name){case"skipping":{if(!a)continue;o={name:"selecting",selectIndex:i};break}case"selecting":{if(a)continue;const{selectIndex:c}=o;Va(t[i].index,(s=t[i+1])==null?void 0:s.index,i-c).forEach((l,u)=>n.push({...t[c+u],index:l})),o={name:"skipping"};break}}}}function Vz(e,t,n){var s;const r=t.length;if(e.size===r)return;let o={name:"skipping"};for(let i=r-1;i>-1;i--){const a=e.has(t[i]);switch(o.name){case"skipping":{if(!a)continue;o={name:"selecting",selectIndex:i};break}case"selecting":{if(a)continue;Va((s=t[i-1])==null?void 0:s.index,t[i].index,o.selectIndex-i).forEach((c,l)=>{n.push({...t[i+l+1],index:c})}),o={name:"skipping"};break}}}}function FT({editor:e}){const t=e.getSelectedShapes(),n=e.getSelectionRotation(),r=e.getSelectionRotatedPageBounds(),{inputs:{originPagePoint:o}}=e;if(!r)return null;const s=r.center.clone().rotWith(r.point,n);return{selectionPageCenter:s,initialCursorAngle:s.angle(o),initialSelectionRotation:n,shapeSnapshots:t.map(i=>({shape:Ge(i),initialPagePoint:e.getShapePageTransform(i.id).point()}))}}function fh({delta:e,editor:t,snapshot:n,stage:r}){const{selectionPageCenter:o,shapeSnapshots:s}=n;t.updateShapes(s.map(({shape:a,initialPagePoint:c})=>{const l=Hn(a.parentId)?t.getShapePageTransform(a.parentId):oe.Identity(),u=b.RotWith(c,o,e),d=oe.applyToPoint(oe.Inverse(l),u),p=ks(a.rotation+e);return{id:a.id,type:a.type,x:d.x,y:d.y,rotation:p}}));const i=[];s.forEach(({shape:a})=>{var d,p,f;const c=t.getShape(a.id);if(!c)return;const l=t.getShapeUtil(a);if(r==="start"||r==="one-off"){const y=(d=l.onRotateStart)==null?void 0:d.call(l,a);y&&i.push(y)}const u=(p=l.onRotate)==null?void 0:p.call(l,a,c);if(u&&i.push(u),r==="end"||r==="one-off"){const y=(f=l.onRotateEnd)==null?void 0:f.call(l,a,c);y&&i.push(y)}}),i.length>0&&t.updateShapes(i)}const Yz=e=>{const{store:t}=e,n=t.query.filterHistory("shape"),r=t.query.records("shape",()=>({type:{eq:"arrow"}}));function o(){const s=r.get(),i={};for(const a of s){const{start:c,end:l}=a.props;if(c.type==="binding"){const u=i[c.boundShapeId];u?u.push({arrowId:a.id,handleId:"start"}):i[c.boundShapeId]=[{arrowId:a.id,handleId:"start"}]}if(l.type==="binding"){const u=i[l.boundShapeId];u?u.push({arrowId:a.id,handleId:"end"}):i[l.boundShapeId]=[{arrowId:a.id,handleId:"end"}]}}return i}return G("arrowBindingsIndex",(s,i)=>{if(vi(s))return o();const a=s,c=n.getDiffSince(i);if(c===Xn)return o();let l;function u(f){l||(l={...a}),l[f]?l[f]===a[f]&&(l[f]=[...l[f]]):l[f]=[]}function d(f,y,g){u(f),l[f]=l[f].filter(w=>w.arrowId!==y||w.handleId!==g),l[f].length===0&&delete l[f]}function p(f,y,g){u(f),l[f].push({arrowId:y,handleId:g})}for(const f of c){for(const y of Object.values(f.added))if(e.isShapeOfType(y,"arrow")){const{start:g,end:w}=y.props;g.type==="binding"&&p(g.boundShapeId,y.id,"start"),w.type==="binding"&&p(w.boundShapeId,y.id,"end")}for(const[y,g]of Object.values(f.updated))if(!(!e.isShapeOfType(y,"arrow")||!e.isShapeOfType(g,"arrow")))for(const w of["start","end"]){const S=y.props[w],v=g.props[w];S.type==="binding"&&v.type==="point"?d(S.boundShapeId,y.id,w):S.type==="point"&&v.type==="binding"?p(v.boundShapeId,g.id,w):S.type==="binding"&&v.type==="binding"&&S.boundShapeId!==v.boundShapeId&&(d(S.boundShapeId,y.id,w),p(v.boundShapeId,g.id,w))}for(const y of Object.values(f.removed))if(e.isShapeOfType(y,"arrow")){const{start:g,end:w}=y.props;g.type==="binding"&&d(g.boundShapeId,y.id,"start"),w.type==="binding"&&d(w.boundShapeId,y.id,"end")}}return l??a})};function Xz(e,t,n){const r=e.getShapeMaskedPageBounds(t);return r===void 0?!0:!n.includes(r)}const qz=e=>{function t(n){const r=n.getCurrentPageShapeIds(),o=n.getViewportPageBounds(),s=new Set;return r.forEach(i=>{Xz(n,i,o)&&s.add(i)}),s}return G("getCulledShapes",n=>{if(vi(n))return t(e);const r=t(e);if(n.size!==r.size)return r;for(const o of n)if(!r.has(o))return r;return n})},Zz=e=>{const t=e.query.ids("shape"),n=e.query.filterHistory("shape");function r(){const o={},s=t.get(),i=Array(s.size);return s.forEach(a=>i.push(e.get(a))),i.sort(rn),i.forEach(a=>{o[a.parentId]||(o[a.parentId]=[]),o[a.parentId].push(a.id)}),o}return G("parentsToChildrenWithIndexes",(o,s)=>{if(vi(o))return r();const i=n.getDiffSince(s);if(i===Xn)return r();if(i.length===0)return o;let a=null;const c=d=>{a||(a={...o}),a[d]?a[d]===o[d]&&(a[d]=[...a[d]]):a[d]=[]},l=new Set;let u;for(let d=0,p=i.length;d<p;d++){u=i[d];for(const f of Object.values(u.added))ga(f)&&(c(f.parentId),a[f.parentId].push(f.id),l.add(a[f.parentId]));for(const[f,y]of Object.values(u.updated))if(ga(y)&&ga(f)){if(f.parentId!==y.parentId)c(f.parentId),c(y.parentId),a[f.parentId].splice(a[f.parentId].indexOf(y.id),1),a[y.parentId].push(y.id),l.add(a[y.parentId]);else if(f.index!==y.index){c(y.parentId);const g=a[y.parentId].indexOf(y.id);a[y.parentId][g]=y.id,l.add(a[y.parentId])}}for(const f of Object.values(u.removed))ga(f)&&(c(f.parentId),a[f.parentId].splice(a[f.parentId].indexOf(f.id),1))}for(const d of l){const p=fe(d.map(f=>e.get(f)));p.sort(rn),d.splice(0,d.length,...p.map(f=>f.id))}return a??o})},mm=(e,t,n)=>{for(;!Pn(n.parentId);){const r=e.get(n.parentId);if(!r)return!1;n=r}return n.parentId===t},Qz=(e,t)=>{const n=e.query.ids("shape");let r=null;function o(){const s=t();return r=s,new Set([...n.get()].filter(i=>mm(e,s,e.get(i))))}return G("_shapeIdsInCurrentPage",(s,i)=>{if(vi(s))return o();const a=t();if(a!==r)return o();const c=e.history.getDiffSince(i);if(c===Xn)return o();const l=new Qd(s);for(const d of c){for(const p of Object.values(d.added))ga(p)&&mm(e,a,p)&&l.add(p.id);for(const[p,f]of Object.values(d.updated))ga(f)&&(mm(e,a,f)?l.add(f.id):l.remove(f.id));for(const p of Object.keys(d.removed))Hn(p)&&l.remove(p)}const u=l.get();return u?sl(u.value,u.diff):s})},NT=x.createContext(null);function Jz({context:e,editor:t,children:n}){return h.jsx(yf.Provider,{value:t,children:h.jsx(NT.Provider,{value:e,children:n})})}function zT(){const e=x.useContext(NT);return e?{isDarkMode:e.isDarkMode}:null}async function e4(e,t,n={}){var C,E;const r=typeof t[0]=="string"?t:t.map(_=>_.id);if(r.length===0)return;if(!window.document)throw Error("No document");const{scale:o=1,background:s=!1,padding:i=R3,preserveAspectRatio:a=!1}=n,c=n.darkMode??e.user.getIsDarkMode(),l=Jo({isDarkMode:c}),u=e.getShapeAndDescendantIds(r),d=e.getUnorderedRenderingShapes(!1).filter(({id:_})=>u.has(_));let p=null;if(n.bounds)p=n.bounds;else for(const{id:_}of d){const k=e.getShapeMaskedPageBounds(_);k&&(p?p.union(k):p=k.clone())}if(!p)return;const f=r.length===1&&e.isShapeOfType(e.getShape(r[0]),"frame")?r[0]:null;f||p.expandBy(i);const y=p.width*o,g=p.height*o;try{(E=(C=document.body).focus)==null||E.call(C)}catch{}const w=[],S=new Map,v={isDarkMode:c,addExportDef:_=>{if(S.has(_.key))return;const k=(async()=>{const $=await _.getElement();$&&w.push(h.jsx(x.Fragment,{children:$},w.length))})();S.set(_.key,k)}},P=(await Promise.all(d.map(async({id:_,opacity:k,index:$,backgroundIndex:T})=>{var H,U;if(_===f)return[];const A=e.getShape(_);if(e.isShapeOfType(A,"group"))return[];const B=e.getShapeUtil(A);let L=await((H=B.toSvg)==null?void 0:H.call(B,A,v)),R=await((U=B.toBackgroundSvg)==null?void 0:U.call(B,A,v));if(!L&&!R){const W=e.getShapePageBounds(A);L=h.jsx("rect",{width:W.w,height:W.h,fill:l.solid,stroke:l.grey.pattern,strokeWidth:1})}let N=e.getShapePageTransform(A).toCssString();"scale"in A.props&&A.props.scale!==1&&(N=`${N} scale(${A.props.scale}, ${A.props.scale})`),L&&(L=h.jsx("g",{transform:N,opacity:k,children:L},A.id)),R&&(R=h.jsx("g",{transform:N,opacity:k,children:R},`bg_${A.id}`));const X=e.getShapeMask(A.id);if(X){const W=`mask_${A.id.replace(":","_")}`;w.push(h.jsx("clipPath",{id:W,children:h.jsx("path",{d:`M${X.map(({x:Q,y:le})=>`${Q},${le}`).join("L")}Z`})},w.length)),L&&(L=h.jsx("g",{clipPath:`url(#${W})`,children:L},A.id)),R&&(R=h.jsx("g",{clipPath:`url(#${W})`,children:R},`bg_${A.id}`))}const q=[];return L&&q.push({zIndex:$,element:L}),R&&q.push({zIndex:T,element:R}),q}))).flat();return await Promise.all(S.values()),{jsx:h.jsx(Jz,{editor:e,context:v,children:h.jsxs("svg",{preserveAspectRatio:a||void 0,direction:"ltr",width:y,height:g,viewBox:`${p.minX} ${p.minY} ${p.width} ${p.height}`,strokeLinecap:"round",strokeLinejoin:"round",style:{backgroundColor:s?f?l.solid:l.background:"transparent"},children:[h.jsx("defs",{children:w}),P.sort((_,k)=>_.zIndex-k.zIndex).map(({element:_})=>_)]})}),width:y,height:g}}const t4=40;class n4{constructor(t){m(this,"_clickId","");m(this,"_clickTimeout");m(this,"_clickScreenPoint");m(this,"_previousScreenPoint");m(this,"_getClickTimeout",(t,n=rt())=>{this._clickId=n,clearTimeout(this._clickTimeout),this._clickTimeout=setTimeout(()=>{if(this._clickState===t&&this._clickId===n){switch(this._clickState){case"pendingTriple":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"double_click",phase:"settle"});break}case"pendingQuadruple":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"triple_click",phase:"settle"});break}case"pendingOverflow":{this.editor.dispatch({...this.lastPointerInfo,type:"click",name:"quadruple_click",phase:"settle"});break}}this._clickState="idle"}},t==="idle"||t==="pendingDouble"?O3:D3)});m(this,"_clickState","idle");m(this,"lastPointerInfo",{});m(this,"handlePointerEvent",t=>{switch(t.name){case"pointer_down":{if(!this._clickState)return t;switch(this._clickScreenPoint=b.From(t.point),this._previousScreenPoint&&b.Dist2(this._previousScreenPoint,this._clickScreenPoint)>t4**2&&(this._clickState="idle"),this._previousScreenPoint=this._clickScreenPoint,this.lastPointerInfo=t,this._clickState){case"pendingDouble":return this._clickState="pendingTriple",this._clickTimeout=this._getClickTimeout(this._clickState),{...t,type:"click",name:"double_click",phase:"down"};case"pendingTriple":return this._clickState="pendingQuadruple",this._clickTimeout=this._getClickTimeout(this._clickState),{...t,type:"click",name:"triple_click",phase:"down"};case"pendingQuadruple":return this._clickState="pendingOverflow",this._clickTimeout=this._getClickTimeout(this._clickState),{...t,type:"click",name:"quadruple_click",phase:"down"};case"idle":{this._clickState="pendingDouble";break}case"pendingOverflow":{this._clickState="overflow";break}}return this._clickTimeout=this._getClickTimeout(this._clickState),t}case"pointer_up":{if(!this._clickState)return t;switch(this._clickScreenPoint=b.From(t.point),this._clickState){case"pendingTriple":return{...this.lastPointerInfo,type:"click",name:"double_click",phase:"up"};case"pendingQuadruple":return{...this.lastPointerInfo,type:"click",name:"triple_click",phase:"up"};case"pendingOverflow":return{...this.lastPointerInfo,type:"click",name:"quadruple_click",phase:"up"}}return t}case"pointer_move":return this._clickState!=="idle"&&this._clickScreenPoint&&b.Dist2(this._clickScreenPoint,this.editor.inputs.currentScreenPoint)>(this.editor.getInstanceState().isCoarsePointer?VE:Sp)&&this.cancelDoubleClickTimeout(),t}return t});m(this,"cancelDoubleClickTimeout",()=>{this._clickTimeout=clearTimeout(this._clickTimeout),this._clickState="idle"});this.editor=t}get clickState(){return this._clickState}}class r4{constructor(t){m(this,"isSafari");m(this,"isIos");m(this,"isChromeForIos");m(this,"isFirefox");m(this,"isAndroid");this.editor=t,typeof window<"u"&&"navigator"in window?(this.isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),this.isIos=!!navigator.userAgent.match(/iPad/i)||!!navigator.userAgent.match(/iPhone/i),this.isChromeForIos=/crios.*safari/i.test(navigator.userAgent),this.isFirefox=/firefox/i.test(navigator.userAgent),this.isAndroid=/android/i.test(navigator.userAgent)):(this.isSafari=!1,this.isIos=!1,this.isChromeForIos=!1,this.isFirefox=!1,this.isAndroid=!1)}}function Gc(e){return s4}class o4{constructor(){m(this,"length",0);m(this,"head",null);m(this,"tail",this)}push(t){return new sx(t,this)}toArray(){return Do}[Symbol.iterator](){return{next(){return{value:void 0,done:!0}}}}}const s4=new o4;class sx{constructor(t,n){m(this,"length");this.head=t,this.tail=n,this.length=n.length+1}push(t){return new sx(t,this)}toArray(){return Array.from(this)}[Symbol.iterator](){let t=this;return{next(){if(t.length){const n=t.head;return t=t.tail,{value:n,done:!1}}else return{value:void 0,done:!0}}}}}class i4{constructor(t){m(this,"store");m(this,"dispose");m(this,"state","recording");m(this,"pendingDiff",new c4);m(this,"stacks",pn("HistoryManager.stacks",{undos:Gc(),redos:Gc()},{isEqual:(t,n)=>t.undos===n.undos&&t.redos===n.redos}));m(this,"annotateError");m(this,"onBatchComplete",()=>{});m(this,"_isInBatch",!1);m(this,"batch",(t,n)=>{const r=this.state;r!=="paused"&&(n!=null&&n.history)&&(this.state=a4[n.history]);try{if(this._isInBatch)return t(),this;this._isInBatch=!0;try{Ro(()=>{t(),this.onBatchComplete()})}catch(o){throw this.annotateError(o),o}finally{this._isInBatch=!1}return this}finally{this.state=r}});m(this,"_undo",({pushToRedoStack:t,toMark:n=void 0})=>{var o;const r=this.state;this.state="paused";try{let{undos:s,redos:i}=this.stacks.get();const a=this.pendingDiff.clear(),c=tE(a),l=eb(a);t&&!c&&(i=i.push({type:"diff",diff:a}));let u=!1;if(c)for(;((o=s.head)==null?void 0:o.type)==="stop";){const d=s.head;if(s=s.tail,t&&(i=i.push(d)),d.id===n){u=!0;break}}if(!u)e:for(;s.head;){const d=s.head;switch(s=s.tail,t&&(i=i.push(d)),d.type){case"diff":tp(l,[eb(d.diff)]);break;case"stop":if(!n||d.id===n)break e;break;default:fn(d)}}this.store.applyDiff(l,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:s,redos:i})}finally{this.state=r}return this});m(this,"undo",()=>(this._undo({pushToRedoStack:!0}),this));m(this,"redo",()=>{var n;const t=this.state;this.state="paused";try{this.flushPendingDiff();let{undos:r,redos:o}=this.stacks.get();if(o.length===0)return;for(;((n=o.head)==null?void 0:n.type)==="stop";)r=r.push(o.head),o=o.tail;const s=Ny();for(;o.head;){const i=o.head;if(r=r.push(i),o=o.tail,i.type==="diff")tp(s,[i.diff]);else break}this.store.applyDiff(s,{ignoreEphemeralKeys:!0}),this.store.ensureStoreIsUsable(),this.stacks.set({undos:r,redos:o})}finally{this.state=t}return this});m(this,"bail",()=>(this._undo({pushToRedoStack:!1}),this));m(this,"bailToMark",t=>(this._undo({pushToRedoStack:!1,toMark:t}),this));m(this,"mark",(t=rt())=>(Ro(()=>{this.flushPendingDiff(),this.stacks.update(({undos:n,redos:r})=>({undos:n.push({type:"stop",id:t}),redos:r}))}),t));this.store=t.store,this.annotateError=t.annotateError??zD,this.dispose=this.store.addHistoryInterceptor((n,r)=>{if(r==="user")switch(this.state){case"recording":this.pendingDiff.apply(n.changes),this.stacks.update(({undos:o})=>({undos:o,redos:Gc()}));break;case"recordingPreserveRedoStack":this.pendingDiff.apply(n.changes);break;case"paused":break;default:fn(this.state)}})}flushPendingDiff(){if(this.pendingDiff.isEmpty())return;const t=this.pendingDiff.clear();this.stacks.update(({undos:n,redos:r})=>({undos:n.push({type:"diff",diff:t}),redos:r}))}getNumUndos(){return this.stacks.get().undos.length+(this.pendingDiff.isEmpty()?0:1)}getNumRedos(){return this.stacks.get().redos.length}ignore(t){return this.batch(t,{history:"ignore"})}clear(){this.stacks.set({undos:Gc(),redos:Gc()}),this.pendingDiff.clear()}debug(){const{undos:t,redos:n}=this.stacks.get();return{undos:t.toArray(),redos:n.toArray(),pendingDiff:this.pendingDiff.debug(),state:this.state}}}const a4={record:"recording","record-preserveRedoStack":"recordingPreserveRedoStack",ignore:"paused"};class c4{constructor(){m(this,"diff",Ny());m(this,"isEmptyAtom",pn("PendingDiff.isEmpty",!0))}clear(){const t=this.diff;return this.diff=Ny(),this.isEmptyAtom.set(!0),t}isEmpty(){return this.isEmptyAtom.get()}apply(t){tp(this.diff,[t]),this.isEmptyAtom.set(tE(this.diff))}debug(){return{diff:this.diff,isEmpty:this.isEmpty()}}}class l4{constructor(t){m(this,"scribbleItems",new Map);m(this,"state","paused");m(this,"addScribble",(t,n=rt())=>{const r={id:n,scribble:{id:n,size:20,color:"accent",opacity:.8,delay:0,points:[],shrink:.1,taper:!0,...t,state:"starting"},timeoutMs:0,delayRemaining:t.delay??0,prev:null,next:null};return this.scribbleItems.set(n,r),r});m(this,"stop",t=>{const n=this.scribbleItems.get(t);if(!n)throw Error(`Scribble with id ${t} not found`);return n.delayRemaining=Math.min(n.delayRemaining,200),n.scribble.state="stopping",n});m(this,"addPoint",(t,n,r)=>{const o=this.scribbleItems.get(t);if(!o)throw Error(`Scribble with id ${t} not found`);const{prev:s}=o,i={x:n,y:r,z:.5};return(!s||b.Dist(s,i)>=1)&&(o.next=i),o});m(this,"tick",t=>{this.scribbleItems.size!==0&&this.editor.batch(()=>{this.scribbleItems.forEach(n=>{if(n.scribble.state==="starting"){const{next:c,prev:l}=n;c&&c!==l&&(n.prev=c,n.scribble.points.push(c)),n.scribble.points.length>8&&(n.scribble.state="active");return}n.delayRemaining>0&&(n.delayRemaining=Math.max(0,n.delayRemaining-t)),n.timeoutMs+=t,n.timeoutMs>=16&&(n.timeoutMs=0);const{delayRemaining:r,timeoutMs:o,prev:s,next:i,scribble:a}=n;switch(a.state){case"active":{i&&i!==s?(n.prev=i,a.points.push(i),r===0&&a.points.length>8&&a.points.shift()):o===0&&(a.points.length>1?a.points.shift():n.delayRemaining=a.delay);break}case"stopping":{if(n.delayRemaining===0&&o===0){if(a.points.length===1){this.scribbleItems.delete(n.id);return}a.shrink&&(a.size=Math.max(1,a.size*(1-a.shrink))),a.points.shift()}break}}}),this.editor.updateInstanceState({scribbles:Array.from(this.scribbleItems.values()).map(({scribble:n})=>({...n,points:[...n.points]})).slice(-5)})})});this.editor=t}reset(){this.editor.updateInstanceState({scribbles:[]}),this.scribbleItems.clear()}}class u4{constructor(t){m(this,"_beforeCreateHandlers",{});m(this,"_afterCreateHandlers",{});m(this,"_beforeChangeHandlers",{});m(this,"_afterChangeHandlers",{});m(this,"_beforeDeleteHandlers",{});m(this,"_afterDeleteHandlers",{});m(this,"_batchCompleteHandlers",[]);this.editor=t,t.store.onBeforeCreate=(n,r)=>{const o=this._beforeCreateHandlers[n.typeName];if(o){let s=n;for(const i of o)s=i(s,r);return s}return n},t.store.onAfterCreate=(n,r)=>{const o=this._afterCreateHandlers[n.typeName];if(o)for(const s of o)s(n,r)},t.store.onBeforeChange=(n,r,o)=>{const s=this._beforeChangeHandlers[r.typeName];if(s){let i=r;for(const a of s)i=a(n,i,o);return i}return r},t.store.onAfterChange=(n,r,o)=>{const s=this._afterChangeHandlers[r.typeName];if(s)for(const i of s)i(n,r,o)},t.store.onBeforeDelete=(n,r)=>{const o=this._beforeDeleteHandlers[n.typeName];if(o){for(const s of o)if(s(n,r)===!1)return!1}},t.store.onAfterDelete=(n,r)=>{const o=this._afterDeleteHandlers[n.typeName];if(o)for(const s of o)s(n,r)},t.history.onBatchComplete=()=>{this._batchCompleteHandlers.forEach(n=>n())}}register(t){const n=[];for(const[r,o]of Object.entries(t))o!=null&&o.beforeCreate&&n.push(this.registerBeforeCreateHandler(r,o.beforeCreate)),o!=null&&o.afterCreate&&n.push(this.registerAfterCreateHandler(r,o.afterCreate)),o!=null&&o.beforeChange&&n.push(this.registerBeforeChangeHandler(r,o.beforeChange)),o!=null&&o.afterChange&&n.push(this.registerAfterChangeHandler(r,o.afterChange)),o!=null&&o.beforeDelete&&n.push(this.registerBeforeDeleteHandler(r,o.beforeDelete)),o!=null&&o.afterDelete&&n.push(this.registerAfterDeleteHandler(r,o.afterDelete));return()=>{for(const r of n)r()}}registerBeforeCreateHandler(t,n){return this._beforeCreateHandlers[t]||(this._beforeCreateHandlers[t]=[]),this._beforeCreateHandlers[t].push(n),()=>ci(this._beforeCreateHandlers[t],n)}registerAfterCreateHandler(t,n){return this._afterCreateHandlers[t]||(this._afterCreateHandlers[t]=[]),this._afterCreateHandlers[t].push(n),()=>ci(this._afterCreateHandlers[t],n)}registerBeforeChangeHandler(t,n){return this._beforeChangeHandlers[t]||(this._beforeChangeHandlers[t]=[]),this._beforeChangeHandlers[t].push(n),()=>ci(this._beforeChangeHandlers[t],n)}registerAfterChangeHandler(t,n){return this._afterChangeHandlers[t]||(this._afterChangeHandlers[t]=[]),this._afterChangeHandlers[t].push(n),()=>ci(this._afterChangeHandlers[t],n)}registerBeforeDeleteHandler(t,n){return this._beforeDeleteHandlers[t]||(this._beforeDeleteHandlers[t]=[]),this._beforeDeleteHandlers[t].push(n),()=>ci(this._beforeDeleteHandlers[t],n)}registerAfterDeleteHandler(t,n){return this._afterDeleteHandlers[t]||(this._afterDeleteHandlers[t]=[]),this._afterDeleteHandlers[t].push(n),()=>ci(this._afterDeleteHandlers[t],n)}registerBatchCompleteHandler(t){return this._batchCompleteHandlers.push(t),()=>ci(this._batchCompleteHandlers,t)}}function ci(e,t){const n=e.indexOf(t);n>=0&&e.splice(n,1)}var d4=Object.defineProperty,h4=Object.getOwnPropertyDescriptor,Lf=(e,t,n,r)=>{for(var o=h4(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&d4(t,n,o),o};const de=e=>Math.round(e*10**8)/10**8;function _o(e,t,n,r,o){const s=e.filter(a=>(r==="forward"?a.startNode.id===t:a.endNode.id===t)&&de(a.length)===de(n)&&$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 c=r==="forward"?a.endNode.id:a.startNode.id;if(!i.has(c)){i.add(c);const l=_o(e,c,n,r,$r(a.breadthIntersection[0],a.breadthIntersection[1],o[0],o[1]));s.push(...l)}}),s}function p4(e){e.sort((t,n)=>n.gaps.length-t.gaps.length);for(let t=e.length-1;t>0;t--){const n=e[t];for(let r=t-1;r>=0;r--){const o=e[r];if(o.direction===n.direction&&n.gaps.every(s=>o.gaps.some(i=>de(s.startEdge[0].x)===de(i.startEdge[0].x)&&de(s.startEdge[0].y)===de(i.startEdge[0].y)&&de(s.startEdge[1].x)===de(i.startEdge[1].x)&&de(s.startEdge[1].y)===de(i.startEdge[1].y))&&o.gaps.some(i=>de(s.endEdge[0].x)===de(i.endEdge[0].x)&&de(s.endEdge[0].y)===de(i.endEdge[0].y)&&de(s.endEdge[1].x)===de(i.endEdge[1].x)&&de(s.endEdge[1].y)===de(i.endEdge[1].y)))){e.splice(t,1);break}}}}class ku{constructor(t){m(this,"editor");this.manager=t,this.editor=t.editor}getSnapPointsCache(){const{editor:t}=this;return t.store.createComputedCache("snapPoints",n=>{const r=t.getShapePageTransform(n.id);if(!r)return;const s=t.getShapeUtil(n).getBoundsSnapGeometry(n).points??t.getShapeGeometry(n).bounds.cornersAndCenter;if(!(!r||!s))return s.map((i,a)=>{const{x:c,y:l}=oe.applyToPoint(r,i);return{x:c,y:l,id:`${n.id}:${a}`}})})}getSnapPoints(t){return this.getSnapPointsCache().get(t)??[]}getSnappablePoints(){const t=this.getSnapPointsCache(),n=this.manager.getSnappableShapes(),r=[];for(const o of n){const s=t.get(o);s&&r.push(...s)}return r}getSnappableGapNodes(){return Array.from(this.manager.getSnappableShapes(),t=>({id:t,pageBounds:hi(this.editor.getShapePageBounds(t))}))}getVisibleGaps(){const t=[],n=[];let r,o;const s=this.getSnappableGapNodes().sort((a,c)=>a.pageBounds.minX-c.pageBounds.minX);for(let a=0;a<s.length;a++){r=s[a];for(let c=a+1;c<s.length;c++)o=s[c],r.pageBounds.maxX<o.pageBounds.minX&&Lc(r.pageBounds.minY,r.pageBounds.maxY,o.pageBounds.minY,o.pageBounds.maxY)&&t.push({startNode:r,endNode:o,startEdge:[new b(r.pageBounds.maxX,r.pageBounds.minY),new b(r.pageBounds.maxX,r.pageBounds.maxY)],endEdge:[new b(o.pageBounds.minX,o.pageBounds.minY),new b(o.pageBounds.minX,o.pageBounds.maxY)],length:o.pageBounds.minX-r.pageBounds.maxX,breadthIntersection:$r(r.pageBounds.minY,r.pageBounds.maxY,o.pageBounds.minY,o.pageBounds.maxY)})}const i=s.sort((a,c)=>a.pageBounds.minY-c.pageBounds.minY);for(let a=0;a<i.length;a++){r=i[a];for(let c=a+1;c<i.length;c++)o=i[c],r.pageBounds.maxY<o.pageBounds.minY&&Lc(r.pageBounds.minX,r.pageBounds.maxX,o.pageBounds.minX,o.pageBounds.maxX)&&n.push({startNode:r,endNode:o,startEdge:[new b(r.pageBounds.minX,r.pageBounds.maxY),new b(r.pageBounds.maxX,r.pageBounds.maxY)],endEdge:[new b(o.pageBounds.minX,o.pageBounds.minY),new b(o.pageBounds.maxX,o.pageBounds.minY)],length:o.pageBounds.minY-r.pageBounds.maxY,breadthIntersection:$r(r.pageBounds.minX,r.pageBounds.maxX,o.pageBounds.minX,o.pageBounds.maxX)})}return{horizontal:t,vertical:n}}snapTranslateShapes({lockedAxis:t,initialSelectionPageBounds:n,initialSelectionSnapPoints:r,dragDelta:o}){var w,S;const s=this.manager.getSnapThreshold(),i=this.getSnappablePoints(),a=n.clone().translate(o),c=r.map(({x:v,y:P},I)=>({id:"selection:"+I,x:v+o.x,y:P+o.y})),l=i,u=[],d=[],p=new b(s,s);this.collectPointSnaps({minOffset:p,nearestSnapsX:u,nearestSnapsY:d,otherNodeSnapPoints:l,selectionSnapPoints:c}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d,minOffset:p});const f=new b(t==="x"?0:((w=u[0])==null?void 0:w.nudge)??0,t==="y"?0:((S=d[0])==null?void 0:S.nudge)??0);p.x=0,p.y=0,u.length=0,d.length=0,c.forEach(v=>{v.x+=f.x,v.y+=f.y}),a.translate(f),this.collectPointSnaps({minOffset:p,nearestSnapsX:u,nearestSnapsY:d,otherNodeSnapPoints:l,selectionSnapPoints:c}),this.collectGapSnaps({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d,minOffset:p});const y=this.getPointSnapLines({nearestSnapsX:u,nearestSnapsY:d}),g=this.getGapSnapLines({selectionPageBounds:a,nearestSnapsX:u,nearestSnapsY:d});return this.manager.setIndicators([...g,...y]),{nudge:f}}snapResizeShapes({initialSelectionPageBounds:t,dragDelta:n,handle:r,isAspectRatioLocked:o,isResizingFromCenter:s}){var _,k;const i=this.manager.getSnapThreshold(),{box:a,scaleX:c,scaleY:l}=te.Resize(t,r,s?n.x*2:n.x,s?n.y*2:n.y,o);let u=r;c<0&&(u=E5(u)),l<0&&(u=I5(u)),s&&(a.center=t.center);const d=u==="top"||u==="bottom",p=u==="left"||u==="right",f=Q1(u,a),y=this.getSnappablePoints(),g=[],w=[],S=new b(i,i);this.collectPointSnaps({minOffset:S,nearestSnapsX:g,nearestSnapsY:w,otherNodeSnapPoints:y,selectionSnapPoints:f});const v=new b(d?0:((_=g[0])==null?void 0:_.nudge)??0,p?0:((k=w[0])==null?void 0:k.nudge)??0);if(o&&_5(u)&&v.len()!==0){const $=g.length&&w.length?Math.abs(v.x)<Math.abs(v.y)?"x":"y":g.length?"x":"y",T=t.aspectRatio;$==="x"?(w.length=0,v.y=v.x/T,(u==="bottom_left"||u==="top_right")&&(v.y=-v.y)):(g.length=0,v.x=v.y*T,(u==="bottom_left"||u==="top_right")&&(v.x=-v.x))}const P=b.Add(n,v),{box:I}=te.Resize(t,r,s?P.x*2:P.x,s?P.y*2:P.y,o);s&&(I.center=t.center);const C=Q1("any",I);g.length=0,w.length=0,S.x=0,S.y=0,this.collectPointSnaps({minOffset:S,nearestSnapsX:g,nearestSnapsY:w,otherNodeSnapPoints:y,selectionSnapPoints:C});const E=this.getPointSnapLines({nearestSnapsX:g,nearestSnapsY:w});return this.manager.setIndicators([...E]),{nudge:v}}collectPointSnaps({selectionSnapPoints:t,otherNodeSnapPoints:n,minOffset:r,nearestSnapsX:o,nearestSnapsY:s}){for(const i of t)for(const a of n){const c=b.Sub(i,a),l=Math.abs(c.x),u=Math.abs(c.y);de(l)<=de(r.x)&&(de(l)<de(r.x)&&(o.length=0),o.push({type:"points",points:{thisPoint:i,otherPoint:a},nudge:a.x-i.x}),r.x=l),de(u)<=de(r.y)&&(de(u)<de(r.y)&&(s.length=0),s.push({type:"points",points:{thisPoint:i,otherPoint:a},nudge:a.y-i.y}),r.y=u)}}collectGapSnaps({selectionPageBounds:t,minOffset:n,nearestSnapsX:r,nearestSnapsY:o}){const{horizontal:s,vertical:i}=this.getVisibleGaps();for(const a of s){if(!Lc(a.breadthIntersection[0],a.breadthIntersection[1],t.minY,t.maxY))continue;const l=a.startEdge[0].x+a.length/2-t.center.x;if(a.length>t.width&&de(Math.abs(l))<=de(n.x)){de(Math.abs(l))<de(n.x)&&(r.length=0),n.x=Math.abs(l);const S={type:"gap_center",gap:a,nudge:l},v=r.find(({type:I})=>I==="gap_center"),P=v&&$r(a.breadthIntersection[0],a.breadthIntersection[1],v.gap.breadthIntersection[0],v.gap.breadthIntersection[1]);v&&v.gap.length>a.length&&P?r[r.indexOf(v)]=S:(!v||!P)&&r.push(S)}const d=a.startNode.pageBounds.minX-a.length,p=t.maxX,f=d-p;de(Math.abs(f))<=de(n.x)&&(de(Math.abs(f))<de(n.x)&&(r.length=0),n.x=Math.abs(f),r.push({type:"gap_duplicate",gap:a,protrusionDirection:"left",nudge:f}));const y=a.endNode.pageBounds.maxX+a.length,g=t.minX,w=y-g;de(Math.abs(w))<=de(n.x)&&(de(Math.abs(w))<de(n.x)&&(r.length=0),n.x=Math.abs(w),r.push({type:"gap_duplicate",gap:a,protrusionDirection:"right",nudge:w}))}for(const a of i){if(!Lc(a.breadthIntersection[0],a.breadthIntersection[1],t.minX,t.maxX))continue;const l=a.startEdge[0].y+a.length/2-t.center.y;if(a.length>t.height&&de(Math.abs(l))<=de(n.y)){de(Math.abs(l))<de(n.y)&&(o.length=0),n.y=Math.abs(l);const S={type:"gap_center",gap:a,nudge:l},v=o.find(({type:I})=>I==="gap_center"),P=v&&Lc(v.gap.breadthIntersection[0],v.gap.breadthIntersection[1],a.breadthIntersection[0],a.breadthIntersection[1]);v&&v.gap.length>a.length&&P?o[o.indexOf(v)]=S:(!v||!P)&&o.push(S);continue}const d=a.startNode.pageBounds.minY-a.length,p=t.maxY,f=d-p;de(Math.abs(f))<=de(n.y)&&(de(Math.abs(f))<de(n.y)&&(o.length=0),n.y=Math.abs(f),o.push({type:"gap_duplicate",gap:a,protrusionDirection:"top",nudge:f}));const y=a.endNode.pageBounds.maxY+a.length,g=t.minY,w=y-g;de(Math.abs(w))<=de(n.y)&&(de(Math.abs(w))<de(n.y)&&(o.length=0),n.y=Math.abs(w),o.push({type:"gap_duplicate",gap:a,protrusionDirection:"bottom",nudge:w}))}}getPointSnapLines({nearestSnapsX:t,nearestSnapsY:n}){const r={},o={};if(t.length>0){for(const s of t)if(s.type==="points"){const i=de(s.points.otherPoint.x);r[i]||(r[i]=[]),r[i].push(s.points)}}if(n.length>0){for(const s of n)if(s.type==="points"){const i=de(s.points.otherPoint.y);o[i]||(o[i]=[]),o[i].push(s.points)}}return Object.values(r).concat(Object.values(o)).map(s=>({id:rt(),type:"points",points:Jh(s.map(i=>b.From(i.otherPoint)).concat(s.map(i=>b.From(i.thisPoint))),(i,a)=>i.equals(a))}))}getGapSnapLines({selectionPageBounds:t,nearestSnapsX:n,nearestSnapsY:r}){const{vertical:o,horizontal:s}=this.getVisibleGaps(),i={top:t.sides[0],right:t.sides[1],bottom:[t.corners[3],t.corners[2]],left:[t.corners[0],t.corners[3]]},a=[];if(n.length>0)for(const c of n){if(c.type==="points")continue;const{gap:{breadthIntersection:l,startEdge:u,startNode:d,endNode:p,length:f,endEdge:y}}=c;switch(c.type){case"gap_center":{const g=(f-t.width)/2,w=$r(l[0],l[1],t.minY,t.maxY);a.push({type:"gaps",direction:"horizontal",id:rt(),gaps:[..._o(s,d.id,g,"backward",w),{startEdge:u,endEdge:i.left},{startEdge:i.right,endEdge:y},..._o(s,p.id,g,"forward",w)]});break}case"gap_duplicate":{const g=$r(l[0],l[1],t.minY,t.maxY);a.push({type:"gaps",direction:"horizontal",id:rt(),gaps:c.protrusionDirection==="left"?[{startEdge:i.right,endEdge:u.map(w=>w.clone().addXY(-d.pageBounds.width,0))},{startEdge:u,endEdge:y},..._o(s,p.id,f,"forward",g)]:[..._o(s,d.id,f,"backward",g),{startEdge:u,endEdge:y},{startEdge:y.map(w=>w.clone().addXY(c.gap.endNode.pageBounds.width,0)),endEdge:i.left}]});break}}}if(r.length>0)for(const c of r){if(c.type==="points")continue;const{gap:{breadthIntersection:l,startEdge:u,startNode:d,endNode:p,length:f,endEdge:y}}=c;switch(c.type){case"gap_center":{const g=(f-t.height)/2,w=$r(l[0],l[1],t.minX,t.maxX);a.push({type:"gaps",direction:"vertical",id:rt(),gaps:[..._o(o,d.id,g,"backward",w),{startEdge:u,endEdge:i.top},{startEdge:i.bottom,endEdge:y},..._o(o,c.gap.endNode.id,g,"forward",w)]});break}case"gap_duplicate":{const g=$r(l[0],l[1],t.minX,t.maxX);a.push({type:"gaps",direction:"vertical",id:rt(),gaps:c.protrusionDirection==="top"?[{startEdge:i.bottom,endEdge:u.map(w=>w.clone().addXY(0,-d.pageBounds.height))},{startEdge:u,endEdge:y},..._o(o,p.id,f,"forward",g)]:[..._o(o,d.id,f,"backward",g),{startEdge:u,endEdge:y},{startEdge:y.map(w=>w.clone().addXY(0,p.pageBounds.height)),endEdge:i.top}]})}break}}return p4(a),a}}Lf([G],ku.prototype,"getSnapPointsCache");Lf([G],ku.prototype,"getSnappablePoints");Lf([G],ku.prototype,"getSnappableGapNodes");Lf([G],ku.prototype,"getVisibleGaps");function Q1(e,t){const{minX:n,maxX:r,minY:o,maxY:s}=t,i=[];switch(e){case"top":case"left":case"top_left":case"any":i.push({id:"top_left",handle:"top_left",x:n,y:o})}switch(e){case"top":case"right":case"top_right":case"any":i.push({id:"top_right",handle:"top_right",x:r,y:o})}switch(e){case"bottom":case"right":case"bottom_right":case"any":i.push({id:"bottom_right",handle:"bottom_right",x:r,y:s})}switch(e){case"bottom":case"left":case"bottom_left":case"any":i.push({id:"bottom_left",handle:"bottom_left",x:n,y:s})}return i}var f4=Object.defineProperty,g4=Object.getOwnPropertyDescriptor,m4=(e,t,n,r)=>{for(var o=g4(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&f4(t,n,o),o};const y4=()=>null,S4=()=>[];class BT{constructor(t){m(this,"editor");this.manager=t,this.editor=t.editor}getSnapGeometryCache(){const{editor:t}=this;return t.store.createComputedCache("handle snap geometry",n=>{const r=t.getShapeUtil(n).getHandleSnapGeometry(n);return{outline:r.outline===void 0?t.getShapeGeometry(n):r.outline,points:r.points??[],getSelfSnapOutline:r.getSelfSnapOutline??y4,getSelfSnapPoints:r.getSelfSnapPoints??S4}})}*iterateSnapPointsInPageSpace(t,n){var o,s;const r=(o=this.getSnapGeometryCache().get(t))==null?void 0:o.getSelfSnapPoints(n);if(r&&r.length){const i=hi(this.editor.getShapePageTransform(t));for(const a of r)yield i.applyToPoint(a)}for(const i of this.manager.getSnappableShapes()){if(i===t)continue;const a=(s=this.getSnapGeometryCache().get(i))==null?void 0:s.points;if(!a||!a.length)continue;const c=hi(this.editor.getShapePageTransform(i));for(const l of a)yield c.applyToPoint(l)}}*iterateSnapOutlines(t,n){var o,s;const r=(o=this.getSnapGeometryCache().get(t))==null?void 0:o.getSelfSnapOutline(n);r&&(yield{shapeId:t,outline:r});for(const i of this.manager.getSnappableShapes()){if(i===t)continue;const a=(s=this.getSnapGeometryCache().get(i))==null?void 0:s.outline;a&&(yield{shapeId:i,outline:a})}}getHandleSnapPosition({currentShapeId:t,handle:n,handleInPageSpace:r}){const o=this.manager.getSnapThreshold();let s=o,i=null;for(const l of this.iterateSnapPointsInPageSpace(t,n))b.DistMin(r,l,s)&&(s=b.Dist(r,l),i=l);if(i)return i;let a=o,c=null;for(const{shapeId:l,outline:u}of this.iterateSnapOutlines(t,n)){const d=hi(this.editor.getShapePageTransform(l)),p=this.editor.getPointInShapeSpace(l,r),f=u.nearestPoint(p),y=d.applyToPoint(f);b.DistMin(r,y,a)&&(a=b.Dist(r,y),c=y)}return c||null}snapHandle({currentShapeId:t,handle:n}){const o=hi(this.editor.getShapePageTransform(t)).applyToPoint(n),s=this.getHandleSnapPosition({currentShapeId:t,handle:n,handleInPageSpace:o});return s?(this.manager.setIndicators([{id:rt(),type:"points",points:[s]}]),{nudge:b.Sub(s,o)}):null}}m4([G],BT.prototype,"getSnapGeometryCache");var v4=Object.defineProperty,x4=Object.getOwnPropertyDescriptor,ix=(e,t,n,r)=>{for(var o=x4(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&v4(t,n,o),o};class Ff{constructor(t){m(this,"shapeBounds");m(this,"handles");m(this,"_snapIndicators",pn("snapLines",void 0));this.editor=t,this.shapeBounds=new ku(this),this.handles=new BT(this)}getIndicators(){return this._snapIndicators.get()??Do}clearIndicators(){this.getIndicators().length&&this._snapIndicators.set(void 0)}setIndicators(t){this._snapIndicators.set(t)}getSnapThreshold(){return 8/this.editor.getZoomLevel()}getSnappableShapes(){const{editor:t}=this,n=t.getViewportPageBounds(),r=t.getSelectedShapeIds(),o=new Set,s=i=>{if(Hn(i)){const c=t.getShape(i);c&&t.isShapeOfType(c,"frame")&&o.add(i)}const a=t.getSortedChildIdsForParent(i);for(const c of a){if(r.includes(c))continue;const l=t.getShape(c);if(!l||!t.getShapeUtil(l).canSnap(l))continue;const d=t.getShapePageBounds(c);if(d&&n.includes(d)){if(t.isShapeOfType(l,"group")){s(c);continue}o.add(c)}}};return s(this.getCurrentCommonAncestor()??t.getCurrentPageId()),o}getCurrentCommonAncestor(){return this.editor.findCommonAncestor(this.editor.getSelectedShapes())}}ix([G],Ff.prototype,"getSnapThreshold");ix([G],Ff.prototype,"getSnappableShapes");ix([G],Ff.prototype,"getCurrentCommonAncestor");const w4=/\r?\n|\r/g;function J1(e){return e.replace(w4,`
|
|
79
|
-
`).split(`
|
|
80
|
-
`).map(t=>t||" ").join(`
|
|
81
|
-
`)}const b4={start:"left","start-legacy":"left",middle:"center","middle-legacy":"center",end:"right","end-legacy":"right"},P4=/\s/;class C4{constructor(t){m(this,"baseElm");m(this,"measureText",(t,n)=>{var i;const r=(i=this.baseElm)==null?void 0:i.cloneNode();this.baseElm.insertAdjacentElement("afterend",r),r.setAttribute("dir","auto"),r.style.setProperty("unicode-bidi","plaintext"),r.style.setProperty("font-family",n.fontFamily),r.style.setProperty("font-style",n.fontStyle),r.style.setProperty("font-weight",n.fontWeight),r.style.setProperty("font-size",n.fontSize+"px"),r.style.setProperty("line-height",n.lineHeight*n.fontSize+"px"),r.style.setProperty("max-width",n.maxWidth===null?null:n.maxWidth+"px"),r.style.setProperty("min-width",n.minWidth===null?null:n.minWidth+"px"),r.style.setProperty("padding",n.padding),r.style.setProperty("overflow-wrap",n.disableOverflowWrapBreaking?"normal":"break-word"),r.textContent=J1(t);const o=r.scrollWidth,s=r.getBoundingClientRect();return r.remove(),{x:0,y:0,w:s.width,h:s.height,scrollWidth:o}});var o;this.editor=t;const n=this.editor.getContainer();(o=n.querySelector("#tldraw_text_measure"))==null||o.remove();const r=document.createElement("div");r.id="tldraw_text_measure",r.classList.add("tl-text"),r.classList.add("tl-text-measure"),r.tabIndex=-1,n.appendChild(r),this.baseElm=r}measureElementTextNodeSpans(t,{shouldTruncateToFirstLine:n=!1}={}){const r=[],o=t.getBoundingClientRect(),s=-o.left,i=-o.top,a=new Range,c=t.childNodes[0];let l=0,u=null,d=null,p=0,f=0,y=!1;for(const g of t.childNodes)if(g.nodeType===Node.TEXT_NODE)for(const w of g.textContent??""){a.setStart(c,l),a.setEnd(c,l+w.length);const S=a.getClientRects(),v=S[S.length-1],P=v.top+i,I=v.left+s,C=v.right+s,E=I<f,_=P4.test(w);if(_!==d||P!==p||!u){if(u){if(n&&P!==p){y=!0;break}r.push(u)}u={box:{x:I,y:P,w:v.width,h:v.height},text:w},f=I}else E&&(u.box.x=I),u.box.w=E?u.box.w+v.width:C-u.box.x,u.text+=w;w===`
|
|
82
|
-
`&&(f=0),d=_,p=P,l+=w.length}return u&&r.push(u),{spans:r,didTruncate:y}}measureTextSpans(t,n){var l;if(t==="")return[];const r=(l=this.baseElm)==null?void 0:l.cloneNode();this.baseElm.insertAdjacentElement("afterend",r);const o=Math.ceil(n.width-n.padding*2);r.setAttribute("dir","auto"),r.style.setProperty("unicode-bidi","plaintext"),r.style.setProperty("width",`${o}px`),r.style.setProperty("height","min-content"),r.style.setProperty("font-size",`${n.fontSize}px`),r.style.setProperty("font-family",n.fontFamily),r.style.setProperty("font-weight",n.fontWeight),r.style.setProperty("line-height",`${n.lineHeight*n.fontSize}px`),r.style.setProperty("text-align",b4[n.textAlign]);const s=n.overflow==="truncate-ellipsis"||n.overflow==="truncate-clip";s&&(r.style.setProperty("overflow-wrap","anywhere"),r.style.setProperty("word-break","break-all"));const i=J1(t);r.textContent=i;const{spans:a,didTruncate:c}=this.measureElementTextNodeSpans(r,{shouldTruncateToFirstLine:s});if(n.overflow==="truncate-ellipsis"&&c){r.textContent="…";const u=Math.ceil(this.measureElementTextNodeSpans(r).spans[0].box.w);r.style.setProperty("width",`${o-u}px`),r.textContent=i;const d=this.measureElementTextNodeSpans(r,{shouldTruncateToFirstLine:!0}).spans,p=d[d.length-1];return d.push({text:"…",box:{x:Math.min(p.box.x+p.box.w,n.width-n.padding-u),y:p.box.y,w:u,h:p.box.h}}),d}return r.remove(),a}}const eP=(typeof process<"u",JI);class I4{constructor(t){m(this,"cancelRaf");m(this,"isPaused",!0);m(this,"now",0);m(this,"start",()=>{var t;this.isPaused=!1,(t=this.cancelRaf)==null||t.call(this),this.cancelRaf=eP(this.tick),this.now=Date.now()});m(this,"tick",()=>{if(this.isPaused)return;const t=Date.now(),n=t-this.now;this.now=t,this.updatePointerVelocity(n),this.editor.emit("frame",n),this.editor.emit("tick",n),this.cancelRaf=eP(this.tick)});m(this,"dispose",()=>{var t;this.isPaused=!0,(t=this.cancelRaf)==null||t.call(this)});m(this,"prevPoint",new b);m(this,"updatePointerVelocity",t=>{const{prevPoint:n,editor:{inputs:{currentScreenPoint:r,pointerVelocity:o}}}=this;if(t===0)return;const s=b.Sub(r,n);this.prevPoint=r.clone();const i=s.len(),a=i?s.div(i):new b(0,0),c=o.clone().lrp(a.mul(i/t),.5);Math.abs(c.x)<.01&&(c.x=0),Math.abs(c.y)<.01&&(c.y=0),o.equals(c)||(this.editor.inputs.pointerVelocity=c)});this.editor=t,this.editor.disposables.add(this.dispose),this.start()}}var E4=Object.defineProperty,_4=Object.getOwnPropertyDescriptor,yo=(e,t,n,r)=>{for(var o=_4(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&E4(t,n,o),o};class Kr{constructor(t,n){m(this,"updateUserPreferences",t=>{this.user.setUserPreferences({...this.user.userPreferences.get(),...t})});this.user=t,this.inferDarkMode=n}getUserPreferences(){return{id:this.getId(),name:this.getName(),locale:this.getLocale(),color:this.getColor(),animationSpeed:this.getAnimationSpeed(),isSnapMode:this.getIsSnapMode(),isDarkMode:this.getIsDarkMode(),isWrapMode:this.getIsWrapMode()}}getIsDarkMode(){return this.user.userPreferences.get().isDarkMode??(this.inferDarkMode?b6():!1)}getEdgeScrollSpeed(){return this.user.userPreferences.get().edgeScrollSpeed??ai.edgeScrollSpeed}getAnimationSpeed(){return this.user.userPreferences.get().animationSpeed??ai.animationSpeed}getId(){return this.user.userPreferences.get().id}getName(){return this.user.userPreferences.get().name??ai.name}getLocale(){return this.user.userPreferences.get().locale??ai.locale}getColor(){return this.user.userPreferences.get().color??ai.color}getIsSnapMode(){return this.user.userPreferences.get().isSnapMode??ai.isSnapMode}getIsWrapMode(){return this.user.userPreferences.get().isWrapMode??ai.isWrapMode}}yo([G],Kr.prototype,"getUserPreferences");yo([G],Kr.prototype,"getIsDarkMode");yo([G],Kr.prototype,"getEdgeScrollSpeed");yo([G],Kr.prototype,"getAnimationSpeed");yo([G],Kr.prototype,"getId");yo([G],Kr.prototype,"getName");yo([G],Kr.prototype,"getLocale");yo([G],Kr.prototype,"getColor");yo([G],Kr.prototype,"getIsSnapMode");yo([G],Kr.prototype,"getIsWrapMode");function Vc(e){return Math.abs(e.props.bend)<8}function Vp(e,t){if(t.type==="point")return;const n=e.getShape(t.boundShapeId);if(!n)return;const r=e.getShapePageTransform(n),o=e.getShapeGeometry(n),s=o instanceof Br?o.children[0].vertices:o.vertices;return{shape:n,transform:r,isClosed:o.isClosed,isExact:t.isExact,didIntersect:!1,outline:s}}function tP(e,t,n,r){if(n.type==="point")return b.From(n);const o=e.getShape(n.boundShapeId);if(o){const{point:s,size:i}=e.getShapeGeometry(o).bounds,a=b.Add(s,b.MulV(n.isPrecise||r?n.normalizedAnchor:{x:.5,y:.5},i)),c=oe.applyToPoint(e.getShapePageTransform(o),a);return oe.applyToPoint(oe.Inverse(t),c)}else return new b(0,0)}function Dr(e,t){const n=e.getShapePageTransform(t);let r,o;t.props.start.type==="binding"&&t.props.end.type==="binding"&&(r=t.props.start.boundShapeId,o=t.props.end.boundShapeId);const s=ax(e,r,o),i=tP(e,n,t.props.start,s==="double-bound"||s==="start-contains-end"),a=tP(e,n,t.props.end,s==="double-bound"||s==="end-contains-start");return{start:i,end:a}}const ka=10,Yp=10,k4=10,Is={s:2,m:3.5,l:5,xl:10};function ax(e,t,n){if(!t||!n)return"safe";if(t===n)return"double-bound";const r=e.getShapePageBounds(t),o=e.getShapePageBounds(n);if(r&&o){if(r.contains(o))return"start-contains-end";if(o.contains(r))return"end-contains-start"}return"safe"}function _l(e,t){const{start:n,end:r,arrowheadStart:o,arrowheadEnd:s}=t.props,i=Dr(e,t),a=i.start.clone(),c=i.end.clone(),l=b.Med(a,c);if(b.Equals(a,c))return{isStraight:!0,start:{handle:a,point:a,arrowhead:t.props.arrowheadStart},end:{handle:c,point:c,arrowhead:t.props.arrowheadEnd},middle:l,isValid:!1,length:0};const u=b.Sub(c,a).uni(),d=Vp(e,n),p=Vp(e,r),f=e.getShapePageTransform(t);nP(c,i.start,f,p),nP(a,i.end,f,d);let y=0,g=0,w=0,S=0,v=ka;const P=d&&p&&d.shape===p.shape,I=d&&p?ax(e,d.shape.id,p.shape.id):"safe";I==="safe"&&d&&p&&!P&&!d.isExact&&!p.isExact&&(p.didIntersect&&!d.didIntersect?d.isClosed&&a.setTo(c.clone().add(u.clone().mul(ka))):p.didIntersect||p.isClosed&&c.setTo(a.clone().sub(u.clone().mul(ka))));const C=b.Sub(c,a),E=b.Len(C)?C.uni():b.From(C),_=!b.Equals(E,u);P||(I!=="start-contains-end"&&d&&o!=="none"&&!d.isExact&&(w=Is[t.props.size]/2+("size"in d.shape.props?Is[d.shape.props.size]/2:0),y=Yp+w,v+=w),I!=="end-contains-start"&&p&&s!=="none"&&!p.isExact&&(S=Is[t.props.size]/2+("size"in p.shape.props?Is[p.shape.props.size]/2:0),g=Yp+S,v+=S));const k=a.clone().add(E.clone().mul(y*(_?-1:1))),$=c.clone().sub(E.clone().mul(g*(_?-1:1)));b.DistMin(k,$,v)&&(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))),c.sub(E.clone().mul(g*(_?-1:1))),_?(d&&p&&c.setTo(b.Add(a,E.clone().mul(-ka))),l.setTo(b.Med(i.start,i.end))):l.setTo(b.Med(a,c));const T=b.Dist(a,c);return{isStraight:!0,start:{handle:i.start,point:a,arrowhead:t.props.arrowheadStart},end:{handle:i.end,point:c,arrowhead:t.props.arrowheadEnd},middle:l,isValid:T>0,length:T}}function nP(e,t,n,r){if(r===void 0||r.isExact)return;const o=oe.applyToPoint(n,t),s=oe.applyToPoint(n,e),i=oe.applyToPoint(oe.Inverse(r.transform),o),a=oe.applyToPoint(oe.Inverse(r.transform),s),c=r.isClosed,u=(c?rx:Dz)(i,a,r.outline);let d;if(u!==null&&(d=u.sort((y,g)=>b.Dist2(y,i)-b.Dist2(g,i))[0]??(c?void 0:a)),d===void 0)return;const p=oe.applyToPoint(r.transform,d),f=oe.applyToPoint(oe.Inverse(n),p);e.setTo(f),r.didIntersect=!0}function ym(e,t,n=0){const{arrowheadEnd:r,arrowheadStart:o}=t.props,s=t.props.bend+n;if(Math.abs(s)>Math.abs(t.props.bend*k4))return _l(e,t);const i=Dr(e,t),a=b.Med(i.start,i.end),c=b.Sub(i.end,i.start),l=b.Len(c)?c.uni():b.From(c),u=b.Add(a,l.per().mul(-s)),d=Vp(e,t.props.start),p=Vp(e,t.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:t.props.arrowheadStart},end:{handle:y,point:y,arrowhead:t.props.arrowheadEnd},middle:g,isValid:!1,length:0};const w=t.props.bend<0,S=w?vu:WE,v=rP(f,y,g),P=b.Angle(v.center,f),I=b.Angle(v.center,y),C=S(P,I);if(v.length===0||v.size===0||!gb(v.length)||!gb(v.size))return _l(e,t);const E=f.clone(),_=y.clone(),k=g.clone(),$=e.getShapePageTransform(t);let T=0,A=0,B=ka;if(d&&!d.isExact){const W=oe.applyToPoint($,E),Q=oe.applyToPoint($,v.center),le=oe.applyToPoint($,_),be=oe.Inverse(d.transform),Ae=oe.applyToPoint(be,W),ae=oe.applyToPoint(be,Q),je=oe.applyToPoint(be,le),{isClosed:Fe}=d,it=Fe?US:Y1;let Ee,gt=it(ae,v.radius,d.outline);if(gt){const We=ae.angle(Ae),ar=ae.angle(je),Ln=S(We,ar);gt=gt.filter(Qe=>S(We,ae.angle(Qe))<=Ln);const Fn=Ln*.25;gt.sort(Fe?(Qe,Lt)=>Math.abs(S(We,ae.angle(Qe))-Fn)<Math.abs(S(We,ae.angle(Lt))-Fn)?-1:1:(Qe,Lt)=>S(We,ae.angle(Qe))<S(We,ae.angle(Lt))?-1:1),Ee=gt[0]??(Fe?void 0:Ae)}else Ee=Fe?void 0:Ae;if(Ee&&(E.setTo(e.getPointInShapeSpace(t,oe.applyToPoint(d.transform,Ee))),d.didIntersect=!0,o!=="none")){const We=Is[t.props.size]/2+("size"in d.shape.props?Is[d.shape.props.size]/2:0);T=Yp+We,B+=We}}if(p&&!p.isExact){const W=oe.applyToPoint($,E),Q=oe.applyToPoint($,_),le=oe.applyToPoint($,v.center),be=oe.Inverse(p.transform),Ae=oe.applyToPoint(be,W),ae=oe.applyToPoint(be,le),je=oe.applyToPoint(be,Q),Fe=p.isClosed,it=Fe?US:Y1;let Ee,gt=it(ae,v.radius,p.outline);if(gt){const We=ae.angle(Ae),ar=ae.angle(je),Ln=S(We,ar),Fn=Ln*.75;gt=gt.filter(Qe=>S(We,ae.angle(Qe))<=Ln),gt.sort(Fe?(Qe,Lt)=>Math.abs(S(We,ae.angle(Qe))-Fn)<Math.abs(S(We,ae.angle(Lt))-Fn)?-1:1:(Qe,Lt)=>S(We,ae.angle(Qe))<S(We,ae.angle(Lt))?-1:1),gt[0]?Ee=gt[0]:Ee=Fe?void 0:je}else Ee=Fe?void 0:je;if(Ee&&(_.setTo(e.getPointInShapeSpace(t,oe.applyToPoint(p.transform,Ee))),p.didIntersect=!0,r!=="none")){const We=Is[t.props.size]/2+("size"in p.shape.props?Is[p.shape.props.size]/2:0);A=Yp+We,B+=We}}let L=b.Angle(v.center,E),R=b.Angle(v.center,_),N=S(L,R),X=N*v.radius;const q=E.clone(),H=_.clone();if(T!==0){const W=T/X*(w?1:-1),Q=b.FromAngle(L+N*W);q.setTo(v.center).add(Q.mul(v.radius))}if(A!==0){const W=A/X*(w?-1:1),Q=b.FromAngle(R+N*W);H.setTo(v.center).add(Q.mul(v.radius))}if(b.DistMin(q,H,B)&&(T!==0&&A!==0?(T*=-1.5,A*=-1.5):T!==0?T*=-2:A!==0&&(A*=-2)),T!==0){const W=T/X*(w?1:-1),Q=b.FromAngle(L+N*W);E.setTo(v.center).add(Q.mul(v.radius))}if(A!==0){const W=A/X*(w?-1:1),Q=b.FromAngle(R+N*W);_.setTo(v.center).add(Q.mul(v.radius))}if(d&&p&&!d.isExact&&!p.isExact){L=b.Angle(v.center,E),R=b.Angle(v.center,_),N=S(L,R),X=N*v.radius;const W=ax(e,d.shape.id,p.shape.id);if(W==="double-bound"&&X<30)E.setTo(f),_.setTo(y),k.setTo(g);else if(W==="safe"&&(d&&!d.didIntersect&&E.setTo(f),p&&!p.didIntersect||S(P,L)>S(P,R))){const Q=Math.min(.9,ka/X)*(w?1:-1),le=b.FromAngle(L+N*Q);_.setTo(v.center).add(le.mul(v.radius))}}T4(v.center,v.radius,E,_,k,C,w),E.equals(_)&&(E.setTo(k.clone().addXY(1,1)),_.setTo(k.clone().subXY(1,1))),f.setTo(E),y.setTo(_),g.setTo(k);const U=rP(f,y,g);return{isStraight:!1,start:{point:f,handle:i.start,arrowhead:t.props.arrowheadStart},end:{point:y,handle:i.end,arrowhead:t.props.arrowheadEnd},middle:g,handleArc:v,bodyArc:U,isValid:U.length!==0&&isFinite(U.center.x)&&isFinite(U.center.y)}}function rP(e,t,n){const r=-2*(e.x*(t.y-n.y)-e.y*(t.x-n.x)+t.x*n.y-n.x*t.y),o={x:((e.x*e.x+e.y*e.y)*(n.y-t.y)+(t.x*t.x+t.y*t.y)*(e.y-n.y)+(n.x*n.x+n.y*n.y)*(t.y-e.y))/r,y:((e.x*e.x+e.y*e.y)*(t.x-n.x)+(t.x*t.x+t.y*t.y)*(n.x-e.x)+(n.x*n.x+n.y*n.y)*(e.x-t.x))/r},s=b.Dist(o,e),i=+b.Clockwise(e,n,t),a=((e.y-t.y)**2+(e.x-t.x)**2)**.5,c=((t.y-n.y)**2+(t.x-n.x)**2)**.5,l=((n.y-e.y)**2+(n.x-e.x)**2)**.5,u=Math.acos((c*c+l*l-a*a)/(2*c*l))*2,d=+(Pe>u),p=(Re-u)*(i?1:-1),f=p*s;return{center:o,radius:s,size:p,length:f,largeArcFlag:d,sweepFlag:i}}function T4(e,t,n,r,o,s,i){const a=b.Angle(e,n),c=b.Angle(e,r);let l=vu(a,c);i||(l=Re-l);const u=.5*(i?1:-1),d=b.FromAngle(a+l*u);if(o.setTo(e).add(d.mul(t)),l>s){o.rotWith(e,Pe);const p=r.clone();r.setTo(n),n.setTo(p)}}const $4={wheel:"onWheel",pointer_down:"onPointerDown",pointer_move:"onPointerMove",long_press:"onLongPress",pointer_up:"onPointerUp",right_click:"onRightClick",middle_click:"onMiddleClick",key_down:"onKeyDown",key_up:"onKeyUp",key_repeat:"onKeyRepeat",cancel:"onCancel",complete:"onComplete",interrupt:"onInterrupt",double_click:"onDoubleClick",triple_click:"onTripleClick",quadruple_click:"onQuadrupleClick",tick:"onTick"};class se{constructor(t,n){m(this,"id");m(this,"type");m(this,"shapeType");m(this,"initial");m(this,"children");m(this,"parent");m(this,"_path");m(this,"_current");m(this,"_isActive");m(this,"transition",(t,n={})=>{var s;const r=t.split(".");let o=this;for(let i=0;i<r.length;i++){const a=r[i],c=o.getCurrent(),l=(s=o.children)==null?void 0:s[a];if(!l)throw Error(`${o.id} - no child state exists with the id ${a}.`);if((c==null?void 0:c.id)!==l.id&&(c==null||c.exit(n,a),o._current.set(l),l.enter(n,(c==null?void 0:c.id)||"initial"),!l.getIsActive()))break;o=l}return this});m(this,"handleEvent",t=>{var o;const n=$4[t.name],r=this._current.__unsafe__getWithoutCapture();(o=this[n])==null||o.call(this,t),this._isActive.__unsafe__getWithoutCapture()&&r&&r===this._current.__unsafe__getWithoutCapture()&&r.handleEvent(t)});m(this,"enter",(t,n)=>{var r;if(this._isActive.set(!0),(r=this.onEnter)==null||r.call(this,t,n),this.children&&this.initial&&this.getIsActive()){const o=this.children[this.initial];this._current.set(o),o.enter(t,n)}});m(this,"exit",(t,n)=>{var r,o;this._isActive.set(!1),(r=this.onExit)==null||r.call(this,t,n),this.getIsActive()||(o=this.getCurrent())==null||o.exit(t,n)});m(this,"_currentToolIdMask",pn("curent tool id mask",void 0));m(this,"onWheel");m(this,"onPointerDown");m(this,"onPointerMove");m(this,"onLongPress");m(this,"onPointerUp");m(this,"onDoubleClick");m(this,"onTripleClick");m(this,"onQuadrupleClick");m(this,"onRightClick");m(this,"onMiddleClick");m(this,"onKeyDown");m(this,"onKeyUp");m(this,"onKeyRepeat");m(this,"onCancel");m(this,"onComplete");m(this,"onInterrupt");m(this,"onTick");m(this,"onEnter");m(this,"onExit");this.editor=t;const{id:r,children:o,initial:s}=this.constructor;this.id=r,this._isActive=pn("toolIsActive"+this.id,!1),this._current=pn("toolState"+this.id,void 0),this._path=G("toolPath"+this.id,()=>{const i=this.getCurrent();return this.id+(i?`.${i.getPath()}`:"")}),this.parent=n??{},this.parent?o&&s?(this.type="branch",this.initial=s,this.children=Object.fromEntries(o().map(i=>[i.id,new i(this.editor,this)])),this._current.set(this.children[this.initial])):this.type="leaf":(this.type="root",o&&s&&(this.initial=s,this.children=Object.fromEntries(o().map(i=>[i.id,new i(this.editor,this)])),this._current.set(this.children[this.initial])))}getPath(){return this._path.get()}getCurrent(){return this._current.get()}getIsActive(){return this._isActive.get()}getCurrentToolIdMask(){return this._currentToolIdMask.get()}setCurrentToolIdMask(t){this._currentToolIdMask.set(t)}}m(se,"id"),m(se,"initial"),m(se,"children");class gh extends se{constructor(){super(...arguments);m(this,"onKeyDown",n=>{var r;switch(n.code){case"KeyZ":{if(!(n.shiftKey||n.ctrlKey)){const o=this.getCurrent();o&&((r=o.getCurrent())==null?void 0:r.id)==="idle"&&this.children.zoom&&this.editor.setCurrentTool("zoom",{...n,onInteractionEnd:o.id})}break}}})}}m(gh,"id","root"),m(gh,"initial",""),m(gh,"children",()=>[]);var M4=Object.defineProperty,A4=Object.getOwnPropertyDescriptor,re=(e,t,n,r)=>{for(var o=A4(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&M4(t,n,o),o};class ne extends T6.EventEmitter{constructor({store:n,user:r,shapeUtils:o,tools:s,getContainer:i,cameraOptions:a,initialState:c,inferDarkMode:l}){super();m(this,"store");m(this,"root");m(this,"disposables",new Set);m(this,"_tickManager");m(this,"snaps");m(this,"user");m(this,"textMeasure");m(this,"environment");m(this,"scribbles");m(this,"sideEffects");m(this,"getContainer");m(this,"shapeUtils");m(this,"styleProps");m(this,"history");m(this,"_crashingError",null);m(this,"_updateInstanceState",(n,r)=>{this.batch(()=>{this.store.put([{...this.getInstanceState(),...n}])},r)});m(this,"_isChangingStyleTimeout",-1);m(this,"setCursor",n=>(this.updateInstanceState({cursor:{...this.getInstanceState().cursor,...n}}),this));m(this,"_updateCurrentPageState",(n,r)=>{this.batch(()=>{this.store.update(n.id??this.getCurrentPageState().id,o=>({...o,...n}))},r)});m(this,"_cameraOptions",pn("camera options",mb));m(this,"_viewportAnimation",null);m(this,"_willSetInitialBounds",!0);m(this,"_cameraState",pn("camera state","idle"));m(this,"_cameraStateTimeoutRemaining",0);m(this,"_decayCameraStateTimeout",n=>{this._cameraStateTimeoutRemaining-=n,!(this._cameraStateTimeoutRemaining>0)&&(this.off("tick",this._decayCameraStateTimeout),this._cameraState.set("idle"))});m(this,"_tickCameraState",()=>{this._cameraStateTimeoutRemaining=N3,this._cameraState.__unsafe__getWithoutCapture()==="idle"&&(this._cameraState.set("moving"),this.on("tick",this._decayCameraStateTimeout))});m(this,"_currentPageShapeIds");m(this,"_parentIdsToChildIds");m(this,"_childIdsCache",new Rf);m(this,"animatingShapes",new Map);m(this,"_updateShapes",n=>{this.getInstanceState().isReadonly||this.batch(()=>{var i,a;const r=[];let o,s;for(let c=0,l=n.length;c<l;c++){const u=n[c];u&&(o=this.getShape(u.id),o&&(s=Yc(o,u),s!==o&&(s=((a=(i=this.getShapeUtil(o)).onBeforeUpdate)==null?void 0:a.call(i,o,s))??s,r.push(s))))}this.store.put(r)})});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 n4(this));m(this,"_prevCursor","default");m(this,"_shiftKeyTimeout",-1);m(this,"_setShiftKeyTimeout",()=>{this.inputs.shiftKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Shift",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,code:"ShiftLeft"})});m(this,"_altKeyTimeout",-1);m(this,"_setAltKeyTimeout",()=>{this.inputs.altKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Alt",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,code:"AltLeft"})});m(this,"_ctrlKeyTimeout",-1);m(this,"_setCtrlKeyTimeout",()=>{this.inputs.ctrlKey=!1,this.dispatch({type:"keyboard",name:"key_up",key:"Ctrl",shiftKey:this.inputs.shiftKey,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,code:"ControlLeft"})});m(this,"_restoreToolId","select");m(this,"_pinchStart",1);m(this,"_didPinch",!1);m(this,"_selectedShapeIdsAtPointerDown",[]);m(this,"_longPressTimeout",-1);m(this,"capturedPointerId",null);m(this,"dispatch",n=>(this._pendingEventsForNextTick.push(n),n.type==="pointer"&&n.name==="pointer_move"||n.type==="wheel"||n.type==="pinch"||this._flushEventsForTick(0),this));m(this,"_pendingEventsForNextTick",[]);m(this,"_flushEventForTick",n=>{if(this.getCrashingError())return this;const{inputs:r}=this,{type:o}=n;if(n.type==="misc"){(n.name==="cancel"||n.name==="complete")&&(this.inputs.isDragging=!1,this.inputs.isPanning&&(this.inputs.isPanning=!1,this.setCursor({type:this._prevCursor,rotation:0}))),this.root.handleEvent(n);return}n.shiftKey?(clearInterval(this._shiftKeyTimeout),this._shiftKeyTimeout=-1,r.shiftKey=!0):!n.shiftKey&&r.shiftKey&&this._shiftKeyTimeout===-1&&(this._shiftKeyTimeout=setTimeout(this._setShiftKeyTimeout,150)),n.altKey?(clearInterval(this._altKeyTimeout),this._altKeyTimeout=-1,r.altKey=!0):!n.altKey&&r.altKey&&this._altKeyTimeout===-1&&(this._altKeyTimeout=setTimeout(this._setAltKeyTimeout,150)),n.ctrlKey?(clearInterval(this._ctrlKeyTimeout),this._ctrlKeyTimeout=-1,r.ctrlKey=!0):!n.ctrlKey&&r.ctrlKey&&this._ctrlKeyTimeout===-1&&(this._ctrlKeyTimeout=setTimeout(this._setCtrlKeyTimeout,150));const{originPagePoint:s,currentPagePoint:i}=r;r.isPointing||(r.isDragging=!1);const a=this.store.unsafeGetWithoutCapture(tn),c=this.store.get(this._getCurrentPageStateId()),l=this._cameraOptions.__unsafe__getWithoutCapture(),u=this.store.unsafeGetWithoutCapture(this.getCameraId());switch(o){case"pinch":{if(l.isLocked)return;switch(clearTimeout(this._longPressTimeout),this._updateInputsFromEvent(n),n.name){case"pinch_start":{if(r.isPinching)return;r.isEditing||(this._pinchStart=this.getCamera().z,this._selectedShapeIdsAtPointerDown.length||(this._selectedShapeIdsAtPointerDown=[...c.selectedShapeIds]),this._didPinch=!0,r.isPinching=!0,this.interrupt());return}case"pinch":{if(!r.isPinching)return;const{point:{z:d=1},delta:{x:p,y:f}}=n,{x:y,y:g}=b.SubXY(n.point,a.screenBounds.x,a.screenBounds.y),{x:w,y:S,z:v}=u;this.stopCameraAnimation(),a.followingUserId&&this.stopFollowingUser();const{panSpeed:P,zoomSpeed:I}=l;this._setCamera(new b(w+p*P/v-y/v+y/(d*I),S+f*P/v-g/v+g/(d*I),d*I),{immediate:!0});return}case"pinch_end":{if(!r.isPinching)return this;r.isPinching=!1;const{_selectedShapeIdsAtPointerDown:d}=this;this.setSelectedShapes(this._selectedShapeIdsAtPointerDown),this._selectedShapeIdsAtPointerDown=[],this._didPinch&&(this._didPinch=!1,d.length>0&&this.once("tick",()=>{this._didPinch||this.setSelectedShapes(d)}));return}}}case"wheel":{if(l.isLocked)return;if(this._updateInputsFromEvent(n),!this.getIsMenuOpen()){const{panSpeed:d,zoomSpeed:p,wheelBehavior:f}=l;if(f!=="none"){this.stopCameraAnimation(),a.followingUserId&&this.stopFollowingUser();const{x:y,y:g,z:w}=u,{x:S,y:v,z:P=0}=n.delta;let I=f;switch(r.ctrlKey&&(I=f==="pan"?"zoom":"pan"),I){case"zoom":{const{x:C,y:E}=this.inputs.currentScreenPoint;let _=P;f==="zoom"&&(Math.abs(v)>10?_=10*Math.sign(v)/100:_=v/100);const k=w+(_??0)*p*w;this._setCamera(new b(y+(C/k-C)-(C/w-C),g+(E/k-E)-(E/w-E),k),{immediate:!0});return}case"pan":{this._setCamera(new b(y+S*d/w,g+v*d/w,w),{immediate:!0});return}}}}break}case"pointer":{if(r.isPinching)return;this._updateInputsFromEvent(n);const{isPen:d}=n,{isPenMode:p}=a;switch(n.name){case"pointer_down":{if(p&&!d)return;if(this.clearOpenMenus(),this._longPressTimeout=setTimeout(()=>{this.dispatch({...n,name:"long_press"})},K3),this._selectedShapeIdsAtPointerDown=this.getSelectedShapeIds(),n.button===xb&&(this.capturedPointerId=n.pointerId),r.buttons.add(n.button),r.isPointing=!0,r.isDragging=!1,!p&&d&&this.updateInstanceState({isPenMode:!0}),n.button===wb?(this._restoreToolId=this.getCurrentToolId(),this.complete(),this.setCurrentTool("eraser")):n.button===td&&(this.inputs.isPanning||(this._prevCursor=this.getInstanceState().cursor.type),this.inputs.isPanning=!0,clearTimeout(this._longPressTimeout)),this.inputs.isPanning)return this.stopCameraAnimation(),this.setCursor({type:"grabbing",rotation:0}),this;break}case"pointer_move":{if(!d&&p)return;if(this.inputs.isPanning&&this.inputs.isPointing){const{currentScreenPoint:f,previousScreenPoint:y}=this.inputs,{x:g,y:w,z:S}=u,{panSpeed:v}=l,P=b.Sub(f,y);this.setCamera(new b(g+P.x*v/S,w+P.y*v/S,S),{immediate:!0});return}r.isPointing&&!r.isDragging&&b.Dist2(s,i)>(a.isCoarsePointer?VE:Sp)/u.z&&(r.isDragging=!0,clearTimeout(this._longPressTimeout));break}case"pointer_up":{if(r.isDragging=!1,r.isPointing=!1,clearTimeout(this._longPressTimeout),r.buttons.delete(n.button),this.getIsMenuOpen()||a.isPenMode&&!d)return;if(this.capturedPointerId===n.pointerId&&(this.capturedPointerId=null,n.button=0),r.isPanning){const f=this.inputs.pointerVelocity,y=Math.min(2,f.len());switch(n.button){case xb:{this.setCursor({type:"grab",rotation:0});break}case td:this.inputs.keys.has(" ")?this.setCursor({type:"grab",rotation:0}):this.setCursor({type:this._prevCursor,rotation:0})}y>0&&this.slideCamera({speed:y,direction:f,friction:YE})}else n.button===wb&&(this.complete(),this.setCurrentTool(this._restoreToolId));break}}break}case"keyboard":{switch(n.key==="ShiftRight"&&(n.key="ShiftLeft"),n.key==="AltRight"&&(n.key="AltLeft"),n.code==="ControlRight"&&(n.code="ControlLeft"),n.name){case"key_down":{r.keys.add(n.code),n.code==="Space"&&!n.ctrlKey&&(this.inputs.isPanning||(this._prevCursor=a.cursor.type),this.inputs.isPanning=!0,clearTimeout(this._longPressTimeout),this.setCursor({type:this.inputs.isPointing?"grabbing":"grab",rotation:0}));break}case"key_up":{r.keys.delete(n.code),n.code==="Space"&&(this.inputs.buttons.has(td)||(this.inputs.isPanning=!1,this.setCursor({type:this._prevCursor,rotation:0})));break}}break}}if(n.type==="pointer"){n.button===td?n.name="middle_click":n.button===n0&&(n.name="right_click");const{isPenMode:d}=this.store.unsafeGetWithoutCapture(tn);if(n.isPen===d){const p=this._clickManager.handlePointerEvent(n);if(n.name!==p.name){this.root.handleEvent(n),this.emit("event",n),this.root.handleEvent(p),this.emit("event",p);return}}}return this.root.handleEvent(n),this.emit("event",n),this});this.store=n,this.history=new i4({store:n,annotateError:I=>{this.annotateError(I,{origin:"history.batch",willCrashApp:!0}),this.crash(I)}}),this.snaps=new Ff(this),this._cameraOptions.set({...mb,...a}),this.user=new Kr(r??M_(),l??!1),this.getContainer=i??(()=>document.body),this.textMeasure=new C4(this),this._tickManager=new I4(this);class u extends gh{}m(u,"initial",c??""),this.root=new u(this),this.root.children={};const d=LT(o),p={},f={},y=new Map;for(const I of d){const C=new I(this);p[I.type]=C;const E=dE(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=p,this.styleProps=f;for(const I of[...s]){if(no(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 r4(this),this.scribbles=new l4(this);const g=new Set,w=I=>{var H;const C=this.getShape(I);if(!C)return;const{start:E,end:_}=C.props,k=E.type==="binding"?this.getShape(E.boundShapeId):void 0,$=_.type==="binding"?this.getShape(_.boundShapeId):void 0,T=this.getAncestorPageId(C);if(!T)return;let A;if(k&&$)A=this.findCommonAncestor([k,$])??T;else if(k||$){const U=(H=k||$)==null?void 0:H.parentId;U&&U===C.parentId?A=C.parentId:A=T}else return;A&&A!==C.parentId&&this.reparentShapes([I],A);const B=this.getShape(I);if(!B)throw Error("no reparented arrow");const L=this.getShapeNearestSibling(B,k),R=this.getShapeNearestSibling(B,$);let N;if(L&&R)N=L.index>R.index?L:R;else if(L&&!R)N=L;else if(R&&!L)N=R;else return;let X;const q=this.getSortedChildIdsForParent(N.parentId).map(U=>this.getShape(U)).filter(U=>U.index>N.index);if(q.length){const U=q.find(W=>W.type!=="arrow");if(B.index>N.index&&(!U||B.index<U.index))return;X=fl(N.index,q[0].index)}else X=$o(N.index);X!==B.index&&this.updateShapes([{id:I,type:"arrow",index:X}])},S=(I,C)=>{const{x:E,y:_}=Dr(this,I)[C];this.store.put([{...I,props:{...I.props,[C]:{type:"point",x:E,y:_}}}])},v=I=>{for(const C of["start","end"]){const E=I.props[C];if(E.type!=="binding")continue;const _=this.getShape(E.boundShapeId),k=this.getAncestorPageId(I)===this.getAncestorPageId(_);(!_||!k)&&S(I,C)}w(I.id)},P=(I,C)=>{let E=null;const _=I.selectedShapeIds.filter(T=>!C.has(T));_.length!==I.selectedShapeIds.length&&(E||(E={...I}),E.selectedShapeIds=_);const k=I.erasingShapeIds.filter(T=>!C.has(T));k.length!==I.erasingShapeIds.length&&(E||(E={...I}),E.erasingShapeIds=k),I.hoveredShapeId&&C.has(I.hoveredShapeId)&&(E||(E={...I}),E.hoveredShapeId=null),I.editingShapeId&&C.has(I.editingShapeId)&&(E||(E={...I}),E.editingShapeId=null);const $=I.hintingShapeIds.filter(T=>!C.has(T));return $.length!==I.hintingShapeIds.length&&(E||(E={...I}),E.hintingShapeIds=$),I.focusedGroupId&&C.has(I.focusedGroupId)&&(E||(E={...I}),E.focusedGroupId=null),E};if(this.sideEffects=new u4(this),this.disposables.add(this.sideEffects.registerBatchCompleteHandler(()=>{var I;for(const C of g){g.delete(C);const E=this.getShape(C);if(!E)continue;const _=this.getShapeUtil(E),k=(I=_.onChildrenChange)==null?void 0:I.call(_,E);k!=null&&k.length&&this.updateShapes(k)}this.emit("update")})),this.disposables.add(this.sideEffects.register({shape:{afterCreate:I=>{this.isShapeOfType(I,"arrow")&&v(I)},afterChange:(I,C)=>{if(this.isShapeOfType(C,"arrow")&&v(C),I.parentId!==C.parentId){const E=_=>{const k=this._getArrowBindingsIndex().get()[_];if(k!=null&&k.length)for(const $ of k)w($.arrowId)};E(C.id),this.visitDescendants(C.id,E)}if(I.parentId!==C.parentId&&Pn(C.parentId)){const E=new Set([I.id]);this.visitDescendants(I.id,_=>{E.add(_)});for(const _ of this.getPageStates()){if(_.pageId===C.parentId)continue;const k=P(_,E);k&&this.store.put([k])}}I.parentId&&Hn(I.parentId)&&g.add(I.parentId),C.parentId!==I.parentId&&Hn(C.parentId)&&g.add(C.parentId)},beforeDelete:I=>{I.parentId&&Hn(I.parentId)&&g.add(I.parentId);const C=this._getArrowBindingsIndex().get()[I.id];if(C!=null&&C.length)for(const{arrowId:k,handleId:$}of C){const T=this.getShape(k);T&&S(T,$)}const E=new Set([I.id]),_=fe(this.getPageStates().map(k=>P(k,E)));_.length&&this.store.put(_)}},page:{afterCreate:I=>{const C=Rr.createId(I.id),E=gr.createId(I.id);this.store.has(C)||this.store.put([Rr.create({id:C})]),this.store.has(E)||this.store.put([gr.create({id:E,pageId:I.id})])},afterDelete:(I,C)=>{var k,$;if(((k=this.getInstanceState())==null?void 0:k.currentPageId)===I.id){const T=($=this.getPages().find(A=>A.id!==I.id))==null?void 0:$.id;T?this.store.put([{...this.getInstanceState(),currentPageId:T}]):C==="user"&&this.store.ensureStoreIsUsable()}const E=Rr.createId(I.id),_=gr.createId(I.id);this.store.remove([E,_])}},instance:{afterChange:(I,C,E)=>{var _;if(!this.store.has(C.currentPageId)){const k=this.store.has(I.currentPageId)?I.currentPageId:(_=this.getPages()[0])==null?void 0:_.id;k?this.store.update(C.id,$=>({...$,currentPageId:k})):E==="user"&&this.store.ensureStoreIsUsable()}}},instance_page_state:{afterChange:(I,C)=>{if((I==null?void 0:I.selectedShapeIds)!==(C==null?void 0:C.selectedShapeIds)){const E=C.selectedShapeIds.filter(k=>{var T,A;let $=(T=this.getShape(k))==null?void 0:T.parentId;for(;Hn($);){if(C.selectedShapeIds.includes($))return!1;$=(A=this.getShape($))==null?void 0:A.parentId}return!0});let _=null;if(E.length>0){const k=this.findCommonAncestor(fe(E.map($=>this.getShape($))),$=>this.isShapeOfType($,"group"));k&&(_=k)}else C!=null&&C.focusedGroupId&&(_=C.focusedGroupId);(E.length!==C.selectedShapeIds.length||_!==C.focusedGroupId)&&this.store.put([{...C,selectedShapeIds:E,focusedGroupId:_??null}])}}}})),this._currentPageShapeIds=Qz(this.store,()=>this.getCurrentPageId()),this._parentIdsToChildIds=Zz(this.store),this.disposables.add(this.store.listen(I=>{this.emit("change",I)})),this.disposables.add(this.history.dispose),this.history.ignore(()=>{this.store.ensureStoreIsUsable(),this._updateCurrentPageState({editingShapeId:null,hoveredShapeId:null,erasingShapeIds:[]})}),c&&this.root.children[c]===void 0)throw Error(`No state found for initialState "${c}".`);this.root.enter(void 0,"initial"),this.getInstanceState().followingUserId&&this.stopFollowingUser(),this.on("tick",this._flushEventsForTick),requestAnimationFrame(()=>{this._tickManager.start()})}dispose(){this.disposables.forEach(n=>n()),this.disposables.clear()}getShapeUtil(n){const r=typeof n=="string"?n:n.type,o=qn(this.shapeUtils,r);return lt(o,`No shape util found for type "${r}"`),o}undo(){return this._flushEventsForTick(0),this.history.undo(),this}getCanUndo(){return this.history.getNumUndos()>0}redo(){return this._flushEventsForTick(0),this.history.redo(),this}getCanRedo(){return this.history.getNumRedos()>0}mark(n){return this.history.mark(n),this}bail(){return this.history.bail(),this}bailToMark(n){return this.history.bailToMark(n),this}batch(n,r){return this.history.batch(n,r),this}_getArrowBindingsIndex(){return Yz(this)}getArrowsBoundTo(n){return this._getArrowBindingsIndex().get()[n]||Do}getArrowInfoCache(){return this.store.createComputedCache("arrow infoCache",n=>Vc(n)?_l(this,n):ym(this,n))}getArrowInfo(n){const r=typeof n=="string"?n:n.id;return this.getArrowInfoCache().get(r)}annotateError(n,{origin:r,willCrashApp:o,tags:s,extras:i}){const a=this.createErrorAnnotations(r,o);return Hv(n,{tags:{...a.tags,...s},extras:{...a.extras,...i}}),o&&this.store.markAsPossiblyCorrupted(),this}createErrorAnnotations(n,r){try{const o=this.getEditingShapeId();return{tags:{origin:n,willCrashApp:r},extras:{activeStateNode:this.root.getPath(),selectedShapes:this.getSelectedShapes(),editingShape:o?this.getShape(o):void 0,inputs:this.inputs}}}catch{return{tags:{origin:n,willCrashApp:r},extras:{}}}}getCrashingError(){return this._crashingError}crash(n){return this._crashingError=n,this.store.markAsPossiblyCorrupted(),this.emit("crash",{error:n}),this}getPath(){return this.root.getPath().split("root.")[1]}isIn(n){const r=n.split(".").reverse();let o=this.root;for(;r.length>0;){const s=r.pop();if(!s)return!0;const i=o.getCurrent();if((i==null?void 0:i.id)===s){if(r.length===0)return!0;o=i;continue}else return!1}return!1}isInAny(...n){return n.some(r=>this.isIn(r))}setCurrentTool(n,r={}){return this.root.transition(n,r),this}getCurrentTool(){return this.root.getCurrent()}getCurrentToolId(){const n=this.getCurrentTool();return n?n.getCurrentToolIdMask()??n.id:""}getStateDescendant(n){var s;const r=n.split(".").reverse();let o=this.root;for(;r.length>0;){const i=r.pop();if(!i)return o;const a=(s=o.children)==null?void 0:s[i];if(!a)return;o=a}return o}getDocumentSettings(){return this.store.get(Uy)}updateDocumentSettings(n){return this.history.ignore(()=>{this.store.put([{...this.getDocumentSettings(),...n}])}),this}getInstanceState(){return this.store.get(tn)}updateInstanceState(n,r){return this._updateInstanceState(n,{history:"ignore",...r}),n.isChangingStyle!==void 0&&(clearTimeout(this._isChangingStyleTimeout),n.isChangingStyle===!0&&(this._isChangingStyleTimeout=setTimeout(()=>{this._updateInstanceState({isChangingStyle:!1},{history:"ignore"})},2e3))),this}getOpenMenus(){return this.getInstanceState().openMenus}addOpenMenu(n){const r=new Set(this.getOpenMenus());return r.has(n)||(r.add(n),this.updateInstanceState({openMenus:[...r]})),this}deleteOpenMenu(n){const r=new Set(this.getOpenMenus());return r.has(n)&&(r.delete(n),this.updateInstanceState({openMenus:[...r]})),this}clearOpenMenus(){return this.getOpenMenus().length&&this.updateInstanceState({openMenus:[]}),this}getIsMenuOpen(){return this.getOpenMenus().length>0}getPageStates(){return this._getPageStatesQuery().get()}_getPageStatesQuery(){return this.store.query.records("instance_page_state")}getCurrentPageState(){return this.store.get(this._getCurrentPageStateId())}_getCurrentPageStateId(){return gr.createId(this.getCurrentPageId())}updateCurrentPageState(n,r){return this._updateCurrentPageState(n,r),this}getSelectedShapeIds(){return this.getCurrentPageState().selectedShapeIds}getSelectedShapes(){const{selectedShapeIds:n}=this.getCurrentPageState();return fe(n.map(r=>this.store.get(r)))}setSelectedShapes(n){return this.batch(()=>{const r=n.map(i=>typeof i=="string"?i:i.id),{selectedShapeIds:o}=this.getCurrentPageState(),s=new Set(o);if(r.length===s.size&&r.every(i=>s.has(i)))return null;this.store.put([{...this.getCurrentPageState(),selectedShapeIds:r}])},{history:"record-preserveRedoStack"})}isAncestorSelected(n){const r=typeof n=="string"?n:(n==null?void 0:n.id)??null,o=this.getShape(r);if(!o)return!1;const s=this.getSelectedShapeIds();return!!this.findShapeAncestor(o,i=>s.includes(i.id))}select(...n){const r=typeof n[0]=="string"?n:n.map(o=>o.id);return this.setSelectedShapes(r),this}deselect(...n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=this.getSelectedShapeIds();return o.length>0&&r.length>0&&this.setSelectedShapes(o.filter(s=>!r.includes(s))),this}selectAll(){const n=this.getSortedChildIdsForParent(this.getCurrentPageId());return n.length<=0?this:(this.setSelectedShapes(this._getUnlockedShapeIds(n)),this)}selectNone(){return this.getSelectedShapeIds().length>0&&this.setSelectedShapes([]),this}getOnlySelectedShapeId(){var n;return((n=this.getOnlySelectedShape())==null?void 0:n.id)??null}getOnlySelectedShape(){const n=this.getSelectedShapes();return n.length===1?n[0]:null}getSelectionPageBounds(){const n=this.getCurrentPageState().selectedShapeIds;return n.length===0?null:te.Common(fe(n.map(r=>this.getShapePageBounds(r))))}getSelectionRotation(){const n=this.getSelectedShapeIds();let r=!1,o=0;for(let s=0,i=n.length;s<i;s++){const a=this.getShapePageTransform(n[s]);if(a)if(r){if(a.rotation()!==o)return 0}else r=!0,o=a.rotation()}return o}getSelectionRotatedPageBounds(){const n=this.getSelectedShapeIds();if(n.length===0)return;const r=this.getSelectionRotation();if(r===0)return this.getSelectionPageBounds();if(n.length===1){const s=this.getShapeGeometry(n[0]).bounds.clone(),i=this.getShapePageTransform(n[0]);return s.point=i.applyToPoint(s.point),s}const o=te.FromPoints(this.getSelectedShapeIds().flatMap(s=>{const i=this.getShapePageTransform(s);return i?i.applyToPoints(this.getShapeGeometry(s).bounds.corners):[]}).map(s=>s.rot(-r)));return o.point=o.point.rot(r),o}getSelectionRotatedScreenBounds(){const n=this.getSelectionRotatedPageBounds();if(!n)return;const{x:r,y:o}=this.pageToScreen(n.point),s=this.getZoomLevel();return new te(r,o,n.width*s,n.height*s)}getFocusedGroupId(){return this.getCurrentPageState().focusedGroupId??this.getCurrentPageId()}getFocusedGroup(){const n=this.getFocusedGroupId();return n?this.getShape(n):void 0}setFocusedGroup(n){const r=typeof n=="string"?n:(n==null?void 0:n.id)??null;if(r!==null){const o=this.getShape(r);if(!o)throw Error(`Editor.setFocusedGroup: Shape with id ${r} does not exist`);if(!this.isShapeOfType(o,"group"))throw Error(`Editor.setFocusedGroup: Cannot set focused group to shape of type ${o.type}`)}return r===this.getFocusedGroupId()?this:this.batch(()=>{this.store.update(this.getCurrentPageState().id,o=>({...o,focusedGroupId:r}))},{history:"record-preserveRedoStack"})}popFocusedGroupId(){const n=this.getFocusedGroup();if(n){const r=this.findShapeAncestor(n,o=>this.isShapeOfType(o,"group"));this.setFocusedGroup((r==null?void 0:r.id)??null),this.select(n.id)}else this.setFocusedGroup(null),this.selectNone();return this}getEditingShapeId(){return this.getCurrentPageState().editingShapeId}getEditingShape(){const n=this.getEditingShapeId();return n?this.getShape(n):void 0}setEditingShape(n){const r=typeof n=="string"?n:(n==null?void 0:n.id)??null;if(r!==this.getEditingShapeId()){if(r){const o=this.getShape(r);if(o&&this.getShapeUtil(o).canEdit(o))return this._updateCurrentPageState({editingShapeId:r}),this}this._updateCurrentPageState({editingShapeId:null})}return this}getHoveredShapeId(){return this.getCurrentPageState().hoveredShapeId}getHoveredShape(){const n=this.getHoveredShapeId();return n?this.getShape(n):void 0}setHoveredShape(n){const r=typeof n=="string"?n:(n==null?void 0:n.id)??null;return r===this.getHoveredShapeId()?this:(this.updateCurrentPageState({hoveredShapeId:r}),this)}getHintingShapeIds(){return this.getCurrentPageState().hintingShapeIds}getHintingShape(){const n=this.getHintingShapeIds();return fe(n.map(r=>this.getShape(r)))}setHintingShapes(n){const r=typeof n[0]=="string"?n:n.map(o=>o.id);return this.updateCurrentPageState({hintingShapeIds:Jh(r)},{history:"ignore"}),this}getErasingShapeIds(){return this.getCurrentPageState().erasingShapeIds}getErasingShapes(){const n=this.getErasingShapeIds();return fe(n.map(r=>this.getShape(r)))}setErasingShapes(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id);r.sort();const o=this.getErasingShapeIds();return this.history.ignore(()=>{if(r.length===o.length){for(let s=0;s<r.length;s++)if(r[s]!==o[s]){this._updateCurrentPageState({erasingShapeIds:r});break}}else this._updateCurrentPageState({erasingShapeIds:r})}),this}getCroppingShapeId(){return this.getCurrentPageState().croppingShapeId}setCroppingShape(n){const r=typeof n=="string"?n:(n==null?void 0:n.id)??null;if(r!==this.getCroppingShapeId())if(!r)this.updateCurrentPageState({croppingShapeId:null});else{const o=this.getShape(r),s=this.getShapeUtil(o);o&&s.canCrop(o)&&this.updateCurrentPageState({croppingShapeId:r})}return this}getCameraId(){return Rr.createId(this.getCurrentPageId())}getCamera(){return this.store.get(this.getCameraId())}getZoomLevel(){return this.getCamera().z}getInitialZoom(){const n=this.getCameraOptions();if(!n.constraints||n.constraints.initialZoom==="default")return 1;const{zx:r,zy:o}=oP(this,n);switch(n.constraints.initialZoom){case"fit-min":return Math.max(r,o);case"fit-max":return Math.min(r,o);case"fit-x":return r;case"fit-y":return o;case"fit-min-100":return Math.min(1,Math.max(r,o));case"fit-max-100":return Math.min(1,Math.min(r,o));case"fit-x-100":return Math.min(1,r);case"fit-y-100":return Math.min(1,o);default:throw fn(n.constraints.initialZoom)}}getBaseZoom(){const n=this.getCameraOptions();if(!n.constraints||n.constraints.baseZoom==="default")return 1;const{zx:r,zy:o}=oP(this,n);switch(n.constraints.baseZoom){case"fit-min":return Math.max(r,o);case"fit-max":return Math.min(r,o);case"fit-x":return r;case"fit-y":return o;case"fit-min-100":return Math.min(1,Math.max(r,o));case"fit-max-100":return Math.min(1,Math.min(r,o));case"fit-x-100":return Math.min(1,r);case"fit-y-100":return Math.min(1,o);default:throw fn(n.constraints.baseZoom)}}getCameraOptions(){return this._cameraOptions.get()}setCameraOptions(n){var o;const r=Ge({...this._cameraOptions.__unsafe__getWithoutCapture(),...n});return((o=r.zoomSteps)==null?void 0:o.length)<1&&(r.zoomSteps=[1]),this._cameraOptions.set(r),this}_setCamera(n,r){const o=this.getCamera();let{x:s,y:i,z:a=o.z}=n;if(!(r!=null&&r.force)){const c=this.getCameraOptions(),l=c.zoomSteps[0],u=Bt(c.zoomSteps),d=this.getViewportScreenBounds();if(c.constraints){const{constraints:p}=c,f=Math.min(p.padding.y,d.w/2),y=Math.min(p.padding.x,d.h/2),g=te.From(c.constraints.bounds),w=(d.w-y*2)/g.w,S=(d.h-f*2)/g.h,v=this.getBaseZoom(),P=u*v,I=l*v;if(r!=null&&r.reset&&(a=this.getInitialZoom()),a<I||a>P){const{x:L,y:R,z:N}=o,X=-L+d.w/N/2,q=-R+d.h/N/2;a=Mt(a,I,P);const H=-L+d.w/a/2,U=-R+d.h/a/2;s=L+H-X,i=R+U-q}const C=y/a-g.x,E=f/a-g.y,_=(d.w-y*2)/a-g.w,k=(d.h-f*2)/a-g.h,$=C+_*p.origin.x,T=E+k*p.origin.y,A=typeof p.behavior=="string"?p.behavior:p.behavior.x,B=typeof p.behavior=="string"?p.behavior:p.behavior.y;if(r!=null&&r.reset)s=$,i=T;else{switch(A){case"fixed":{s=$;break}case"contain":{a<w?s=$:s=Mt(s,C+_,C);break}case"inside":{a<w?s=Mt(s,C,(d.w-y)/a-g.w):s=Mt(s,C+_,C);break}case"outside":{s=Mt(s,y/a-g.w,(d.w-y)/a);break}case"free":break;default:throw fn(A)}switch(B){case"fixed":{i=T;break}case"contain":{a<S?i=T:i=Mt(i,E+k,E);break}case"inside":{a<S?i=Mt(i,E,(d.h-f)/a-g.h):i=Mt(i,E+k,E);break}case"outside":{i=Mt(i,f/a-g.h,(d.h-f)/a);break}case"free":break;default:throw fn(B)}}}else if(a>u||a<l){const{x:p,y:f,z:y}=o;a=Mt(a,l,u),s=p+(-p+d.w/a/2)-(-p+d.w/y/2),i=f+(-f+d.h/a/2)-(-f+d.h/y/2)}}return o.x===s&&o.y===i&&o.z===a?this:(this.batch(()=>{const c={...o,x:s,y:i,z:a};this.history.ignore(()=>{this.store.put([c])});const{currentScreenPoint:l,currentPagePoint:u}=this.inputs,{screenBounds:d}=this.store.unsafeGetWithoutCapture(tn);if(l.x/a-s!==u.x||l.y/a-i!==u.y){const p={type:"pointer",target:"canvas",name:"pointer_move",point:b.AddXY(l,d.x,d.y),pointerId:Sb.CAMERA_MOVE,ctrlKey:this.inputs.ctrlKey,altKey:this.inputs.altKey,shiftKey:this.inputs.shiftKey,button:0,isPen:this.getInstanceState().isPenMode??!1};r!=null&&r.immediate?this._flushEventForTick(p):this.dispatch(p)}this._tickCameraState()}),this)}setCamera(n,r){const{isLocked:o}=this._cameraOptions.__unsafe__getWithoutCapture();if(o&&!(r!=null&&r.force))return this;this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser();const s=b.Cast(n);if(Number.isFinite(s.x)||(s.x=0),Number.isFinite(s.y)||(s.y=0),(s.z===void 0||!Number.isFinite(s.z))&&(n.z=this.getZoomLevel()),r!=null&&r.animation){const{width:i,height:a}=this.getViewportScreenBounds();this._animateToViewport(new te(-n.x,-n.y,i/s.z,a/s.z),r)}else this._setCamera(s,r);return this}centerOnPoint(n,r){if(this.getCameraOptions().isLocked)return this;const{width:o,height:s}=this.getViewportPageBounds();return this.setCamera(new b(-(n.x-o/2),-(n.y-s/2),this.getCamera().z),r),this}zoomToFit(n){const r=[...this.getCurrentPageShapeIds()];if(r.length<=0)return this;const o=te.Common(fe(r.map(s=>this.getShapePageBounds(s))));return this.zoomToBounds(o,n),this}resetZoom(n=this.getViewportScreenCenter(),r){const{isLocked:o,constraints:s}=this.getCameraOptions();if(o)return this;const i=this.getCamera(),{x:a,y:c,z:l}=i,{x:u,y:d}=n;let p=1;if(s){const f=this.getInitialZoom();l!==f&&(p=f)}return this.setCamera(new b(a+(u/p-u)-(u/l-u),c+(d/p-d)-(d/l-d),p),r),this}zoomIn(n=this.getViewportScreenCenter(),r){if(this.getCameraOptions().isLocked)return this;const{x:o,y:s,z:i}=this.getCamera(),{zoomSteps:a}=this.getCameraOptions();if(a!==null&&a.length>1){const c=this.getBaseZoom();let l=Bt(a)*c;for(let u=1;u<a.length;u++){const d=a[u-1]*c,p=a[u]*c;if(!(p-i<=(p-d)/2)){l=p;break}}this.setCamera(new b(o+(n.x/l-n.x)-(n.x/i-n.x),s+(n.y/l-n.y)-(n.y/i-n.y),l),r)}return this}zoomOut(n=this.getViewportScreenCenter(),r){if(this.getCameraOptions().isLocked)return this;const{zoomSteps:o}=this.getCameraOptions();if(o!==null&&o.length>1){const s=this.getBaseZoom(),{x:i,y:a,z:c}=this.getCamera();let l=o[0]*s;for(let u=o.length-1;u>0;u--){const d=o[u-1]*s,p=o[u]*s;if(!(p-c>=(p-d)/2)){l=d;break}}this.setCamera(new b(i+(n.x/l-n.x)-(n.x/c-n.x),a+(n.y/l-n.y)-(n.y/c-n.y),l),r)}return this}zoomToSelection(n){if(this.getCameraOptions().isLocked)return this;const r=this.getSelectionPageBounds();return r&&this.zoomToBounds(r,{targetZoom:Math.max(1,this.getZoomLevel()),...n}),this}zoomToBounds(n,r){const o=this._cameraOptions.__unsafe__getWithoutCapture();if(o.isLocked)return this;const s=this.getViewportScreenBounds(),i=(r==null?void 0:r.inset)??Math.min(256,s.width*.28),a=this.getBaseZoom(),c=o.zoomSteps[0],l=Bt(o.zoomSteps);let u=Mt(Math.min((s.width-i)/n.w,(s.height-i)/n.h),c*a,l*a);return(r==null?void 0:r.targetZoom)!==void 0&&(u=Math.min(r.targetZoom,u)),this.setCamera(new b(-n.x+(s.width-n.w*u)/2/u,-n.y+(s.height-n.h*u)/2/u,u),r),this}stopCameraAnimation(){return this.emit("stop-camera-animation"),this}_animateViewport(n){if(!this._viewportAnimation)return;this._viewportAnimation.elapsed+=n;const{elapsed:r,easing:o,duration:s,start:i,end:a}=this._viewportAnimation;if(r>s){this.off("tick",this._animateViewport),this._viewportAnimation=null,this._setCamera(new b(-a.x,-a.y,this.getViewportScreenBounds().width/a.width));return}const c=s-r,l=o(1-c/s),u=i.minX+(a.minX-i.minX)*l,d=i.minY+(a.minY-i.minY)*l,p=i.maxX+(a.maxX-i.maxX)*l;this._setCamera(new b(-u,-d,this.getViewportScreenBounds().width/(p-u)),{force:!0})}_animateToViewport(n,r={animation:Dg}){const{animation:o,...s}=r;if(!o)return;const{duration:i=0,easing:a=sn.easeInOutCubic}=o,c=this.user.getAnimationSpeed(),l=this.getViewportPageBounds();return this.stopCameraAnimation(),this.getInstanceState().followingUserId&&this.stopFollowingUser(),i===0||c===0?this._setCamera(new b(-n.x,-n.y,this.getViewportScreenBounds().width/n.width),{...s}):(this._viewportAnimation={elapsed:0,duration:i/c,easing:a,start:l.clone(),end:n.clone()},this.once("stop-camera-animation",()=>{this.off("tick",this._animateViewport),this._viewportAnimation=null}),this.on("tick",this._animateViewport),this)}slideCamera(n={}){if(this.getCameraOptions().isLocked)return this;if(this.user.getAnimationSpeed()===0)return this;this.stopCameraAnimation();const{speed:o,friction:s,direction:i,speedThreshold:a=.01}=n;let c=Math.min(o,1);const l=()=>{this.off("tick",u),this.off("stop-camera-animation",l)};this.once("stop-camera-animation",l);const u=d=>{const{x:p,y:f,z:y}=this.getCamera(),g=b.Mul(i,c*d/y);c*=1-s,c<a?l():this._setCamera(new b(p+g.x,f+g.y,y))};return this.on("tick",u),this}zoomToUser(n,r={animation:{duration:500}}){const o=this.getCollaborators().find(s=>s.userId===n);return o?(this.batch(()=>{this.getInstanceState().followingUserId!==null&&this.stopFollowingUser();const s=o.currentPageId===this.getCurrentPageId();s||this.setCurrentPage(o.currentPageId),r&&r.animation&&!s&&(r.animation=void 0),this.centerOnPoint(o.cursor,r);const{highlightedUserIds:i}=this.getInstanceState();this.updateInstanceState({highlightedUserIds:[...i,n]}),setTimeout(()=>{const a=[...this.getInstanceState().highlightedUserIds],c=a.indexOf(n);c<0||(a.splice(c,1),this.updateInstanceState({highlightedUserIds:a}))},XE)}),this):this}updateViewportScreenBounds(n,r=!1){n.width=Math.max(n.width,1),n.height=Math.max(n.height,1);const o=[n.minY!==0,document.body.scrollWidth!==n.maxX,document.body.scrollHeight!==n.maxY,n.minX!==0],s=n.equals(this.getViewportScreenBounds()),{_willSetInitialBounds:i}=this;if(s)this._willSetInitialBounds=!1;else if(i)this._willSetInitialBounds=!1,this.updateInstanceState({screenBounds:n.toJson(),insets:o}),this.setCamera(this.getCamera());else if(r&&!this.getInstanceState().followingUserId){const a=this.getViewportPageBounds().center;this.updateInstanceState({screenBounds:n.toJson(),insets:o}),this.centerOnPoint(a)}else this.updateInstanceState({screenBounds:n.toJson(),insets:o}),this._setCamera(b.From({...this.getCamera()}));return this._tickCameraState(),this}getViewportScreenBounds(){const{x:n,y:r,w:o,h:s}=this.getInstanceState().screenBounds;return new te(n,r,o,s)}getViewportScreenCenter(){const n=this.getViewportScreenBounds();return new b(n.midX-n.minX,n.midY-n.minY)}getViewportPageBounds(){const{w:n,h:r}=this.getViewportScreenBounds(),{x:o,y:s,z:i}=this.getCamera();return new te(-o,-s,n/i,r/i)}screenToPage(n){const{screenBounds:r}=this.store.unsafeGetWithoutCapture(tn),{x:o,y:s,z:i=1}=this.getCamera();return new b((n.x-r.x)/i-o,(n.y-r.y)/i-s,n.z??.5)}pageToScreen(n){const{screenBounds:r}=this.store.unsafeGetWithoutCapture(tn),{x:o,y:s,z:i=1}=this.getCamera();return new b((n.x+o)*i+r.x,(n.y+s)*i+r.y,n.z??.5)}pageToViewport(n){const{x:r,y:o,z:s=1}=this.getCamera();return new b((n.x+r)*s,(n.y+o)*s,n.z??.5)}_getCollaboratorsQuery(){return this.store.query.records("instance_presence",()=>({userId:{neq:this.user.getId()}}))}getCollaborators(){const n=this._getCollaboratorsQuery().get();return n.length?[...new Set(n.map(o=>o.userId))].sort().map(o=>n.filter(i=>i.userId===o).sort((i,a)=>a.lastActivityTimestamp-i.lastActivityTimestamp)[0]):Do}getCollaboratorsOnCurrentPage(){const n=this.getCurrentPageId();return this.getCollaborators().filter(r=>r.currentPageId===n)}startFollowingUser(n){const r=this._getCollaboratorsQuery().get().filter(c=>c.userId===n),o=this.user.getId();if(o||console.warn("You should set the userId for the current instance before following a user"),r.some(c=>c.followingUserId===o))return this;Ro(()=>{this.stopFollowingUser(),this.updateInstanceState({followingUserId:n})});const s=()=>{this.off("frame",a),this.off("stop-following",s)};let i=!1;const a=()=>{Ro(()=>{const c=this._getCollaboratorsQuery().get().filter(q=>q.userId===n).sort((q,H)=>H.lastActivityTimestamp-q.lastActivityTimestamp)[0];if(!c){this.stopFollowingUser();return}const l=c.currentPageId===this.getCurrentPageId(),u=l?T3:1;if(!l){this.stopFollowingUser(),this.setCurrentPage(c.currentPageId),this.startFollowingUser(n);return}const{center:d,width:p,height:f}=this.getViewportPageBounds(),y=te.From(c.screenBounds),g=y.width/c.camera.z,w=y.height/c.camera.z,S=new b(g/2-c.camera.x,w/2-c.camera.y),v=c.followingUserId===o,P=p+(g-p)*u,I=f+(w-f)*u,C=v?f/I:Math.min(p/P,f/I),E=this.getBaseZoom(),{zoomSteps:_}=this.getCameraOptions(),k=_[0],$=Bt(_),T=Mt(this.getCamera().z*C,k*E,$*E),A=this.getViewportScreenBounds().w/T,B=this.getViewportScreenBounds().h/T,L=S.sub(d),R=b.Add(d,b.Mul(L,u)),N=b.Sub(R,d).len(),X=Math.abs(T-this.getCamera().z);if(N<$3&&X<A3){i=!0;return}i&&N<M3&&X<j3||(i=!1,this.stopCameraAnimation(),this._setCamera(new b(-(R.x-A/2),-(R.y-B/2),T)))})};return this.once("stop-following",s),this.on("frame",a),this}stopFollowingUser(){return this.updateInstanceState({followingUserId:null}),this.emit("stop-following"),this}getUnorderedRenderingShapes(n){const r=[];let o=gs*2,s=gs;const i=this.getErasingShapeIds(),a=(l,u,d)=>{const p=this.getShape(l);if(!p)return;u*=p.opacity;let f=!1;const y=this.getShapeUtil(p);n&&(f=!d&&i.includes(l),f&&(u*=.32)),r.push({id:l,shape:p,util:y,index:o,backgroundIndex:s,opacity:u}),o+=1,s+=1;const g=this.getSortedChildIdsForParent(l);if(!g.length)return;let w=null;y.providesBackgroundForChildren(p)&&(w=s,s=o,o+=gs);for(const S of g)a(S,u,d||f);w!==null&&(s=w)},c=n?[this.getCurrentPage()]:this.getPages();for(const l of c)for(const u of this.getSortedChildIdsForParent(l.id))a(u,1,!1);return r}getCameraState(){return this._cameraState.get()}getRenderingShapes(){return this.getUnorderedRenderingShapes(!0).sort(VD)}_getAllPagesQuery(){return this.store.query.records("page")}getPages(){return this._getAllPagesQuery().get().sort(rn)}getCurrentPage(){return this.getPage(this.getCurrentPageId())}getCurrentPageId(){return this.getInstanceState().currentPageId}getPage(n){return this.store.get(typeof n=="string"?n:n.id)}getCurrentPageShapeIds(){return this._currentPageShapeIds.get()}getCurrentPageShapeIdsSorted(){return Array.from(this.getCurrentPageShapeIds()).sort()}getPageShapeIds(n){const r=typeof n=="string"?n:n.id,o=this.store.query.exec("shape",{parentId:{eq:r}});return this.getShapeAndDescendantIds(o.map(s=>s.id))}setCurrentPage(n){const r=typeof n=="string"?n:n.id;return this.store.has(r)?(this.stopFollowingUser(),this.batch(()=>this.store.put([{...this.getInstanceState(),currentPageId:r}]),{history:"record-preserveRedoStack"})):(console.error("Tried to set the current page id to a page that doesn't exist."),this)}updatePage(n){return this.getInstanceState().isReadonly?this:this.getPage(n.id)?this.batch(()=>this.store.update(n.id,o=>({...o,...n}))):this}createPage(n){return this.history.batch(()=>{if(this.getInstanceState().isReadonly||this.getPages().length>=yp)return;const r=this.getPages(),o=Hz(n.name??"Page 1",r.map(a=>a.name));let s=n.index;(!s||r.some(a=>a.index===s))&&(s=$o(r[r.length-1].index));const i=Bo.create({meta:{},...n,name:o,index:s});this.store.put([i])}),this}deletePage(n){const r=typeof n=="string"?n:n.id;return this.batch(()=>{if(this.getInstanceState().isReadonly)return;const o=this.getPages();if(o.length===1)return;const s=this.getPage(r);if(s){if(r===this.getCurrentPageId()){const i=o.findIndex(c=>c.id===r),a=o[i-1]??o[i+1];this.setCurrentPage(a.id)}this.store.remove([s.id])}}),this}duplicatePage(n,r=Bo.createId()){if(this.getPages().length>=yp)return this;const o=typeof n=="string"?n:n.id,s=this.getPage(o);if(!s)return this;const i={...this.getCamera()},a=this.getContentFromCurrentPage(this.getSortedChildIdsForParent(s.id));return this.batch(()=>{var u;const c=this.getPages(),l=fl(s.index,(u=c[c.indexOf(s)+1])==null?void 0:u.index);if(this.createPage({name:s.name+" Copy",id:r,index:l}),this.setCurrentPage(r),this.setCamera(i),a)return this.putContentOntoCurrentPage(a)}),this}renamePage(n,r){const o=typeof n=="string"?n:n.id;return this.getInstanceState().isReadonly?this:(this.updatePage({id:o,name:r}),this)}_getAllAssetsQuery(){return this.store.query.records("asset")}getAssets(){return this._getAllAssetsQuery().get()}createAssets(n){return this.getInstanceState().isReadonly?this:n.length<=0?this:this.batch(()=>this.store.put(n))}updateAssets(n){return this.getInstanceState().isReadonly?this:n.length<=0?this:this.batch(()=>{this.store.put(n.map(r=>({...this.store.get(r.id),...r})))})}deleteAssets(n){if(this.getInstanceState().isReadonly)return this;const r=typeof n[0]=="string"?n:n.map(o=>o.id);return r.length<=0?this:this.batch(()=>this.store.remove(r))}getAsset(n){return this.store.get(typeof n=="string"?n:n.id)}_getShapeGeometryCache(){return this.store.createComputedCache("bounds",n=>this.getShapeUtil(n).getGeometry(n),(n,r)=>n.props===r.props)}getShapeGeometry(n){return this._getShapeGeometryCache().get(typeof n=="string"?n:n.id)}_getShapeHandlesCache(){return this.store.createComputedCache("handles",n=>{var r,o;return(o=(r=this.getShapeUtil(n)).getHandles)==null?void 0:o.call(r,n)})}getShapeHandles(n){return this._getShapeHandlesCache().get(typeof n=="string"?n:n.id)}getShapeLocalTransform(n){const r=typeof n=="string"?n:n.id,o=this.getShape(r);if(!o)throw Error("Editor.getTransform: shape not found");return oe.Identity().translate(o.x,o.y).rotate(o.rotation)}_getShapePageTransformCache(){return this.store.createComputedCache("pageTransformCache",n=>{if(Pn(n.parentId))return this.getShapeLocalTransform(n);const r=this._getShapePageTransformCache().get(n.parentId)??oe.Identity();return oe.Compose(r,this.getShapeLocalTransform(n))})}getShapeParentTransform(n){const r=typeof n=="string"?n:n.id,o=this.getShape(r);return!o||Pn(o.parentId)?oe.Identity():this._getShapePageTransformCache().get(o.parentId)??oe.Identity()}getShapePageTransform(n){const r=typeof n=="string"?n:n.id;return this._getShapePageTransformCache().get(r)??oe.Identity()}_getShapePageBoundsCache(){return this.store.createComputedCache("pageBoundsCache",n=>{const r=this._getShapePageTransformCache().get(n.id);return r?te.FromPoints(oe.applyToPoints(r,this.getShapeGeometry(n).vertices)):new te})}getShapePageBounds(n){return this._getShapePageBoundsCache().get(typeof n=="string"?n:n.id)}_getShapeClipPathCache(){return this.store.createComputedCache("clipPathCache",n=>{const r=this._getShapeMaskCache().get(n.id);if(!r)return;if(r.length===0)return"polygon(0px 0px, 0px 0px, 0px 0px)";const o=this._getShapePageTransformCache().get(n.id);return o?`polygon(${oe.applyToPoints(oe.Inverse(o),r).map(i=>`${i.x}px ${i.y}px`).join(",")})`:void 0})}getShapeClipPath(n){return this._getShapeClipPathCache().get(typeof n=="string"?n:n.id)}_getShapeMaskCache(){return this.store.createComputedCache("pageMaskCache",n=>{if(Pn(n.parentId))return;const r=this.getShapeAncestors(n.id).filter(s=>this.isShapeOfType(s,"frame"));return r.length===0?void 0:r.map(s=>this._getShapePageTransformCache().get(s.id).applyToPoints(this.getShapeGeometry(s).vertices)).reduce((s,i)=>{if(!(i&&s))return;const a=X1(s,i);return a?a.map(b.Cast):[]})})}getShapeMask(n){return this._getShapeMaskCache().get(typeof n=="string"?n:n.id)}getShapeMaskedPageBounds(n){return typeof n!="string"&&(n=n.id),this._getShapeMaskedPageBoundsCache().get(n)}_getShapeMaskedPageBoundsCache(){return this.store.createComputedCache("shapeMaskedPageBoundsCache",n=>{const r=this._getShapePageBoundsCache().get(n.id);if(!r)return;const o=this._getShapeMaskCache().get(n.id);if(o){if(o.length===0)return;const{corners:s}=r;if(s.every((a,c)=>a&&b.Equals(a,o[c])))return r.clone();const i=X1(o,s);return i?te.FromPoints(i):void 0}return r})}getShapeAncestors(n,r=[]){const o=typeof n=="string"?n:n.id,s=this.getShape(o);if(!s)return r;const i=s.parentId;if(Pn(i))return r.reverse(),r;const a=this.store.get(i);return a?(r.push(a),this.getShapeAncestors(a,r)):r}findShapeAncestor(n,r){const o=typeof n=="string"?n:n.id,s=this.getShape(o);if(!s)return;const i=s.parentId;if(Pn(i))return;const a=this.getShape(i);if(a)return r(a)?a:this.findShapeAncestor(a,r)}hasAncestor(n,r){const o=typeof n=="string"?n:n==null?void 0:n.id,s=o&&this.getShape(o);return s?s.parentId===r?!0:this.hasAncestor(this.getShapeParent(s),r):!1}findCommonAncestor(n,r){var l;if(n.length===0)return;const o=typeof n[0]=="string"?n:n.map(u=>u.id),s=fe(o.map(u=>this.getShape(u)));if(s.length===1){const u=s[0].parentId;return Pn(u)?void 0:r?(l=this.findShapeAncestor(s[0],r))==null?void 0:l.id:u}const[i,...a]=s;let c=this.getShapeParent(i);for(;c;){if(r&&!r(c)){c=this.getShapeParent(c);continue}if(a.every(u=>this.hasAncestor(u,c.id)))return c.id;c=this.getShapeParent(c)}}isShapeOrAncestorLocked(n){const r=typeof n=="string"?this.getShape(n):n;return r===void 0?!1:r.isLocked?!0:this.isShapeOrAncestorLocked(this.getShapeParent(r))}_notVisibleShapes(){return qz(this)}getCulledShapes(){const n=this._notVisibleShapes().get(),r=this.getSelectedShapeIds(),o=this.getEditingShapeId(),s=new Set(n);return o&&s.delete(o),r.forEach(i=>{s.delete(i)}),s}getCurrentPageBounds(){let n;return this.getCurrentPageShapeIdsSorted().forEach(r=>{const o=this.getShapeMaskedPageBounds(r);o&&(n?n=n.expand(o):n=o.clone())}),n}getSelectedShapeAtPoint(n){const r=this.getSelectedShapeIds();return this.getCurrentPageShapesSorted().filter(o=>o.type!=="group"&&r.includes(o.id)).reverse().find(o=>this.isPointInShape(o,n,{hitInside:!0,margin:0}))}getShapeAtPoint(n,r={}){const o=this.getZoomLevel(),s=this.getViewportPageBounds(),{filter:i,margin:a=0,hitLocked:c=!1,hitLabels:l=!1,hitInside:u=!1,hitFrameInside:d=!1}=r;let p=1/0,f=null,y=1/0,g=null;const w=(r.renderingOnly?this.getCurrentPageRenderingShapesSorted():this.getCurrentPageShapesSorted()).filter(S=>{if(S.isLocked&&!c||this.isShapeOfType(S,"group"))return!1;const v=this.getShapeMask(S);return v&&!Zn(n,v)?!1:i?i(S):!0});for(let S=w.length-1;S>=0;S--){const v=w[S],P=this.getShapeGeometry(v),I=P instanceof Br,C=this.getPointInShapeSpace(v,n);if((this.isShapeOfType(v,"arrow")||this.isShapeOfType(v,"geo")&&v.props.fill==="none")&&v.props.text.trim()){for(const _ of P.children)if(_.isLabel&&_.isPointInBounds(C))return v}if(this.isShapeOfType(v,"frame")){const _=P.distanceToPoint(C,u);if(Math.abs(_)<=a)return g||v;if(P.hitTestPoint(C,0,!0))return g||f||(d?v:void 0);continue}let E;if(I){let _=1/0;for(const k of P.children){if(k.isLabel&&!l)continue;const $=k.distanceToPoint(C,u);$<_&&(_=$)}E=_}else a===0&&(P.bounds.w<1||P.bounds.h<1)||P.bounds.containsPoint(C,a)?E=P.distanceToPoint(C,u):E=1/0;if(P.isClosed){if(E<=a){if(P.isFilled||I&&P.children[0].isFilled)return g||v;if(this.getShapePageBounds(v).contains(s))continue;if(Math.abs(E)<a)Math.abs(E)<y&&(y=Math.abs(E),g=v);else if(!g){const{area:_}=P;_<p&&(p=_,f=v)}}}else if(E<Uo/o)return v}return g||f||void 0}getShapesAtPoint(n,r={}){return this.getCurrentPageShapes().filter(o=>this.isPointInShape(o,n,r))}isPointInShape(n,r,o={}){const{hitInside:s=!1,margin:i=0}=o,a=typeof n=="string"?n:n.id,c=this.getShapeMask(a);return c&&!Zn(r,c)?!1:this.getShapeGeometry(a).hitTestPoint(this.getPointInShapeSpace(n,r),i,s)}getPointInShapeSpace(n,r){const o=typeof n=="string"?n:n.id;return this._getShapePageTransformCache().get(o).clone().invert().applyToPoint(r)}getPointInParentSpace(n,r){const o=typeof n=="string"?n:n.id,s=this.getShape(o);if(!s)return new b(0,0);if(Pn(s.parentId))return b.From(r);const i=this.getShapePageTransform(s.parentId);return i?i.clone().invert().applyToPoint(r):b.From(r)}getCurrentPageShapes(){return Array.from(this.getCurrentPageShapeIds(),n=>this.store.get(n))}getCurrentPageShapesSorted(){const n=[],r=this.getSortedChildIdsForParent(this.getCurrentPageId());for(let o=0,s=r.length;o<s;o++)UT(this,r[o],n);return n}getCurrentPageRenderingShapesSorted(){const n=this.getCulledShapes();return this.getCurrentPageShapesSorted().filter(({id:r})=>!n.has(r))}isShapeOfType(n,r){const o=typeof n=="string"?this.getShape(n):n;return o?o.type===r:!1}getShape(n){const r=typeof n=="string"?n:n.id;if(Hn(r))return this.store.get(r)}getShapeParent(n){const r=typeof n=="string"?n:n==null?void 0:n.id;if(!r)return;const o=this.getShape(r);if(!(o===void 0||!Hn(o.parentId)))return this.store.get(o.parentId)}getShapeNearestSibling(n,r){return r?r.parentId===n.parentId?r:this.findShapeAncestor(r,s=>s.parentId===n.parentId):void 0}isShapeInPage(n,r=this.getCurrentPageId()){const o=typeof n=="string"?n:n.id,s=this.getShape(o);if(!s)return!1;let i=!1;if(s.parentId===r)i=!0;else{let a=this.getShape(s.parentId);e:for(;a;){if(a.parentId===r){i=!0;break e}a=this.getShape(a.parentId)}}return i}getAncestorPageId(n){const r=typeof n=="string"?n:n==null?void 0:n.id,o=r&&this.getShape(r);if(o)return Pn(o.parentId)?o.parentId:this.getAncestorPageId(this.getShape(o.parentId))}reparentShapes(n,r,o){const s=typeof n[0]=="string"?n:n.map(y=>y.id);if(s.length===0)return this;const i=[],a=Pn(r)?oe.Identity():this.getShapePageTransform(r),c=a.rotation();let l=[];const u=fe(this.getSortedChildIdsForParent(r).map(y=>this.getShape(y)));if(o){const y=u.find(g=>g.index===o);if(y){const g=u[u.indexOf(y)+1];g?l=Va(o,g.index,s.length):l=kg(o,s.length)}else{const g=u.sort(rn).find(w=>w.index>o);g?l=Va(o,g.index,s.length):l=kg(o,s.length)}}else{const y=u.length&&u[u.length-1];l=y?kg(y.index,s.length):Al(s.length)}const d=a.clone().invert(),p=fe(s.map(y=>this.getShape(y))),f=p.filter(y=>y.isLocked);f.length&&this.updateShapes(f.map(({id:y,type:g})=>({id:y,type:g,isLocked:!1})));for(let y=0;y<p.length;y++){const g=p[y],w=this.getShapePageTransform(g);if(!w)continue;const S=w.point();if(!S)continue;const v=d.applyToPoint(S),P=w.rotation()-c;i.push({id:g.id,type:g.type,parentId:r,x:v.x,y:v.y,rotation:P,index:l[y],isLocked:g.isLocked})}return this.updateShapes(i),this}getHighestIndexForParent(n){const r=typeof n=="string"?n:n.id,o=this._parentIdsToChildIds.get()[r];if(!o||o.length===0)return"a1";const s=this.getShape(o[o.length-1]);return $o(s.index)}getSortedChildIdsForParent(n){const r=typeof n=="string"?n:n.id,o=this._parentIdsToChildIds.get()[r];return o?this._childIdsCache.get(o,()=>o):Do}visitDescendants(n,r){const o=typeof n=="string"?n:n.id,s=this.getSortedChildIdsForParent(o);for(const i of s)r(i)!==!1&&this.visitDescendants(i,r);return this}getShapeAndDescendantIds(n){const r=new Set,o=[...n];for(;o.length>0;){const s=o.pop();if(!s)break;if(!r.has(s)){r.add(s);for(const i of this.getSortedChildIdsForParent(s))o.push(i)}}return r}getDroppingOverShape(n,r=[]){const o=this.getCurrentPageShapesSorted();for(let s=o.length-1;s>=0;s--){const i=o[s];if(this.getSelectedShapeIds().includes(i.id)||!this.getShapeUtil(i).canDropShapes(i,r)||r.find(c=>c.id===i.id||this.hasAncestor(i,c.id)))continue;const a=this.getShapeMaskedPageBounds(i.id);if(a&&a.containsPoint(n)&&this.getShapeGeometry(i).hitTestPoint(this.getPointInShapeSpace(i,n),0,!0))return i}}getOutermostSelectableShape(n,r){const o=typeof n=="string"?n:n.id,s=this.getShape(o);let i=s,a=s;const c=this.getFocusedGroup();for(;a;){if(this.isShapeOfType(a,"group")&&(c==null?void 0:c.id)!==a.id&&!this.hasAncestor(c,a.id)&&((r==null?void 0:r(a))??!0))i=a;else if((c==null?void 0:c.id)===a.id)break;a=this.getShapeParent(a)}return i}rotateShapesBy(n,r){if((typeof n[0]=="string"?n:n.map(i=>i.id)).length<=0)return this;const s=FT({editor:this});return s?(fh({delta:r,snapshot:s,editor:this,stage:"one-off"}),this):this}getChangesToTranslateShape(n,r){var i,a,c;let o=n;const s=this.getShapeUtil(n);return o=Yc(o,((i=s.onTranslateStart)==null?void 0:i.call(s,o))??void 0),o=Yc(o,{id:n.id,type:n.type,x:r.x,y:r.y}),o=Yc(o,((a=s.onTranslate)==null?void 0:a.call(s,n,o))??void 0),o=Yc(o,((c=s.onTranslateEnd)==null?void 0:c.call(s,n,o))??void 0),o}nudgeShapes(n,r){const o=typeof n[0]=="string"?n:n.map(i=>i.id);if(o.length<=0)return this;const s=[];for(const i of o){const a=this.getShape(i),c=b.From(r),l=this.getShapeParentTransform(a);l&&c.rot(-l.rotation()),s.push(this.getChangesToTranslateShape(a,c.add(a)))}return this.updateShapes(s),this}duplicateShapes(n,r){const o=typeof n[0]=="string"?n:n.map(d=>d.id);if(o.length<=0)return this;if(n.length+this.getCurrentPageShapeIds().size>gs)return wd(this),this;const i=new Set(o),a=[],c=[...o];for(;c.length>0;){const d=c.pop();if(!d)break;a.push(d),this.getSortedChildIdsForParent(d).forEach(p=>c.push(p))}a.reverse();const l=new Map(a.map(d=>[d,He()])),u=fe(a.map(d=>{const p=this.getShape(d);if(!p)return null;const f=l.get(d);let y=0,g=0;if(r&&i.has(d)){const _=this.getShapeParentTransform(p),k=new b(r.x,r.y).rot(-_.rotation());y=k.x,g=k.y}const w=p.parentId??this.getCurrentPageId(),S=this.getSortedChildIdsForParent(w),v=S.indexOf(p.id),P=S[v+1],I=P?this.getShape(P):null,C=I?fl(p.index,I.index):$o(p.index);let E=Ge(p);if(this.isShapeOfType(p,"arrow")&&this.isShapeOfType(E,"arrow")){const _=this.getArrowInfo(p);let k,$;if(p.props.start.type==="binding"&&(k=l.get(p.props.start.boundShapeId),!k))if(_!=null&&_.isValid){const{x:A,y:B}=_.start.point;E.props.start={type:"point",x:A,y:B}}else{const{start:A}=Dr(this,p);E.props.start={type:"point",x:A.x,y:A.y}}if(p.props.end.type==="binding"&&($=l.get(p.props.end.boundShapeId),!$))if(_!=null&&_.isValid){const{x:A,y:B}=_.end.point;E.props.end={type:"point",x:A,y:B}}else{const{end:A}=Dr(this,p);E.props.start={type:"point",x:A.x,y:A.y}}const T=Vc(E)?_l(this,E):ym(this,E);if(_!=null&&_.isValid&&(T!=null&&T.isValid)&&!Vc(p)){const A=b.Med(_.start.handle,_.end.handle),B=b.Dist(_.middle,A),L=b.Dist(T.middle,A);E.props.bend<0?E.props.bend+=L-B:E.props.bend-=L-B}E.props.start.type==="binding"&&k&&(E.props.start.boundShapeId=k),E.props.end.type==="binding"&&$&&(E.props.end.boundShapeId=$)}return E={...E,id:f,x:p.x+y,y:p.y+g,index:C},E}));return u.forEach(d=>{Hn(d.parentId)&&l.has(d.parentId)&&(d.parentId=l.get(d.parentId))}),this.history.batch(()=>{const d=u.map(p=>p.id);if(this.createShapes(u),this.setSelectedShapes(d),r!==void 0){const p=this.getSelectionPageBounds(),f=this.getViewportPageBounds();p&&!f.contains(p)&&this.centerOnPoint(p.center,{animation:{duration:Qr}})}}),this}moveShapesToPage(n,r){const o=typeof n[0]=="string"?n:n.map(c=>c.id);if(o.length===0)return this;if(this.getInstanceState().isReadonly)return this;const s=this.getCurrentPageId();if(r===s)return this;if(!this.store.has(r))return this;const i=this.getContentFromCurrentPage(o);if(!i)return this;if(this.getPageShapeIds(r).size+i.shapes.length>gs)return wd(this,r),this;const a=this.getCamera().z;return this.history.batch(()=>{this.deleteShapes(o),this.setCurrentPage(r),this.setFocusedGroup(null),this.selectNone(),this.putContentOntoCurrentPage(i,{select:!0,preserveIds:!0,preservePosition:!0}),this.setCamera({...this.getCamera(),z:a}),this.centerOnPoint(this.getSelectionRotatedPageBounds().center)}),this}toggleLock(n){const r=typeof n[0]=="string"?n:n.map(a=>a.id);if(this.getInstanceState().isReadonly||r.length===0)return this;let o=!0,s=!0;const i=[];for(const a of r){const c=this.getShape(a);c&&(i.push(c),c.isLocked?s=!1:o=!1)}return this.batch(()=>{s?(this.updateShapes(i.map(a=>({id:a.id,type:a.type,isLocked:!0}))),this.setSelectedShapes([])):o?this.updateShapes(i.map(a=>({id:a.id,type:a.type,isLocked:!1}))):this.updateShapes(i.map(a=>({id:a.id,type:a.type,isLocked:!0})))}),this}sendToBack(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=xd(this,"toBack",r);return o&&this.updateShapes(o),this}sendBackward(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=xd(this,"backward",r);return o&&this.updateShapes(o),this}bringForward(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=xd(this,"forward",r);return o&&this.updateShapes(o),this}bringToFront(n){const r=typeof n[0]=="string"?n:n.map(s=>s.id),o=xd(this,"toFront",r);return o&&this.updateShapes(o),this}flipShapes(n,r){const o=typeof n[0]=="string"?n:n.map(a=>a.id);if(this.getInstanceState().isReadonly)return this;let s=fe(o.map(a=>this.getShape(a)));if(!s.length)return this;s=fe(s.map(a=>this.isShapeOfType(a,"group")?this.getSortedChildIdsForParent(a.id).map(c=>this.getShape(c)):a).flat());const i=te.Common(fe(s.map(a=>this.getShapePageBounds(a)))).center;return this.batch(()=>{for(const a of s){const c=this.getShapeGeometry(a).bounds,l=this.getShapePageTransform(a.id);l&&this.resizeShape(a.id,{x:r==="horizontal"?-1:1,y:r==="vertical"?-1:1},{initialBounds:c,initialPageTransform:l,initialShape:a,mode:"scale_shape",isAspectRatioLocked:this.getShapeUtil(a).isAspectRatioLocked(a),scaleOrigin:i,scaleAxisRotation:0})}}),this}stackShapes(n,r,o){const s=typeof n[0]=="string"?n:n.map(w=>w.id);if(this.getInstanceState().isReadonly)return this;const i=fe(s.map(w=>this.getShape(w)).filter(w=>!(!w||this.isShapeOfType(w,"arrow")&&(w.props.start.type==="binding"||w.props.end.type==="binding")))),a=i.length;if(o===0&&a<3||a<2)return this;const c=Object.fromEntries(i.map(w=>[w.id,this.getShapePageBounds(w)]));let l,u,d,p;r==="horizontal"?(l="x",u="minX",d="maxX",p="width"):(l="y",u="minY",d="maxY",p="height");let f;if(o===0){const w=[];i.sort((v,P)=>c[v.id][u]-c[P.id][u]);for(let v=0;v<a-1;v++){const P=i[v],I=i[v+1],C=c[P.id],_=c[I.id][u]-C[d],k=w.find($=>$.gap===_);k?k.count++:w.push({gap:_,count:1})}let S=0;w.forEach(v=>{v.count>S&&(S=v.count,f=v.gap)}),S===1&&(f=Math.max(0,w.reduce((v,P)=>v+P.gap*P.count,0)/(a-1)))}else f=o;const y=[];let g=c[i[0].id][d];return i.forEach((w,S)=>{var E,_;if(S===0)return;const v={x:0,y:0};v[l]=g+f-c[w.id][l];const P=this.getShapeParent(w),I=P?b.Rot(v,-this.getShapePageTransform(P).decompose().rotation):v,C=(_=(E=this.getShapeUtil(w)).onTranslateStart)==null?void 0:_.call(E,w);y.push(C?{...C,[l]:w[l]+I[l]}:{id:w.id,type:w.type,[l]:w[l]+I[l]}),g+=c[w.id][p]+f}),this.updateShapes(y),this}packShapes(n,r){var _,k;const o=typeof n[0]=="string"?n:n.map($=>$.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=fe(o.map($=>this.getShape($)).filter($=>!(!$||this.isShapeOfType($,"arrow")&&($.props.start.type==="binding"||$.props.end.type==="binding")))),i={},a={};let c,l,u=0;for(let $=0;$<s.length;$++)c=s[$],l=this.getShapePageBounds(c),i[c.id]=l,a[c.id]=l.clone(),u+=l.width*l.height;const d=te.Common(fe(Object.values(i))),p=d.width;s.sort(($,T)=>i[T.id].height-i[$.id].height);const f=Math.max(Math.ceil(Math.sqrt(u/.95)),p),y=[new te(d.x,d.y,f,1/0)];let g=0,w=0,S,v;for(let $=0;$<s.length;$++){c=s[$],l=a[c.id];for(let T=y.length-1;T>=0;T--)if(S=y[T],!(l.width>S.width||l.height>S.height)){l.x=S.x,l.y=S.y,w=Math.max(w,l.maxY),g=Math.max(g,l.maxX),l.width===S.width&&l.height===S.height?(v=y.pop(),T<y.length&&(y[T]=v)):l.height===S.height?(S.x+=l.width+r,S.width-=l.width+r):l.width===S.width?(S.y+=l.height+r,S.height-=l.height+r):(y.push(new te(S.x+(l.width+r),S.y,S.width-(l.width+r),l.height)),S.y+=l.height+r,S.height-=l.height+r);break}}const P=te.Common(Object.values(a)),I=b.Sub(d.center,P.center);let C;const E=[];for(let $=0;$<s.length;$++){c=s[$],l=i[c.id],C=a[c.id];const T=b.Sub(C.point,l.point).add(I),A=this.getShapeParentTransform(c);A&&T.rot(-A.rotation());const B={id:c.id,type:c.type,x:c.x+T.x,y:c.y+T.y},L=(k=(_=this.getShapeUtil(c)).onTranslateStart)==null?void 0:k.call(_,{...c,...B});L?E.push({...B,...L}):E.push(B)}return E.length&&this.updateShapes(E),this}alignShapes(n,r){const o=typeof n[0]=="string"?n:n.map(l=>l.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=fe(o.map(l=>this.getShape(l))),i=Object.fromEntries(s.map(l=>[l.id,this.getShapePageBounds(l)])),a=te.Common(fe(Object.values(i))),c=[];return s.forEach(l=>{const u=i[l.id];if(!u)return;const d={x:0,y:0};switch(r){case"top":{d.y=a.minY-u.minY;break}case"center-vertical":{d.y=a.midY-u.minY-u.height/2;break}case"bottom":{d.y=a.maxY-u.minY-u.height;break}case"left":{d.x=a.minX-u.minX;break}case"center-horizontal":{d.x=a.midX-u.minX-u.width/2;break}case"right":{d.x=a.maxX-u.minX-u.width;break}}const p=this.getShapeParent(l),f=p?b.Rot(d,-this.getShapePageTransform(p).decompose().rotation):d;c.push(this.getChangesToTranslateShape(l,b.Add(l,f)))}),this.updateShapes(c),this}distributeShapes(n,r){const o=typeof n[0]=="string"?n:n.map(P=>P.id);if(this.getInstanceState().isReadonly)return this;if(o.length<3)return this;const s=o.length,i=fe(o.map(P=>this.getShape(P))),a=Object.fromEntries(i.map(P=>[P.id,this.getShapePageBounds(P)]));let c,l,u,d,p;r==="horizontal"?(c="x",l="minX",u="maxX",d="midX",p="width"):(c="y",l="minY",u="maxY",d="midY",p="height");const f=[],y=i.sort((P,I)=>a[P.id][l]-a[I.id][l])[0],g=i.sort((P,I)=>a[I.id][u]-a[P.id][u])[0],w=a[y.id][d],S=(a[g.id][d]-w)/(s-1),v=w+S;return i.filter(P=>P!==y&&P!==g).sort((P,I)=>a[P.id][d]-a[I.id][d]).forEach((P,I)=>{const C={x:0,y:0};C[c]=v+S*I-a[P.id][p]/2-a[P.id][c];const E=this.getShapeParent(P),_=E?b.Rot(C,-this.getShapePageTransform(E).rotation()):C;f.push(this.getChangesToTranslateShape(P,b.Add(P,_)))}),this.updateShapes(f),this}stretchShapes(n,r){const o=typeof n[0]=="string"?n:n.map(l=>l.id);if(this.getInstanceState().isReadonly)return this;if(o.length<2)return this;const s=fe(o.map(l=>this.getShape(l))),i=Object.fromEntries(o.map(l=>[l,this.getShapeGeometry(l).bounds])),a=Object.fromEntries(o.map(l=>[l,this.getShapePageBounds(l)])),c=te.Common(fe(Object.values(a)));switch(r){case"vertical":{this.batch(()=>{for(const l of s){if(this.getShapePageTransform(l).rotation()%Re)continue;const d=i[l.id],p=a[l.id],f=new b(0,c.minY-p.minY),y=this.getShapeParentTransform(l);y&&f.rot(-y.rotation());const{x:g,y:w}=b.Add(f,l);this.updateShapes([{id:l.id,type:l.type,x:g,y:w}]);const S=new b(1,c.height/p.height);this.resizeShape(l.id,S,{initialBounds:d,scaleOrigin:new b(p.center.x,c.minY),isAspectRatioLocked:this.getShapeUtil(l).isAspectRatioLocked(l),scaleAxisRotation:0})}});break}case"horizontal":{this.batch(()=>{for(const l of s){const u=i[l.id],d=a[l.id];if(this.getShapePageTransform(l).rotation()%Re)continue;const f=new b(c.minX-d.minX,0),y=this.getShapeParentTransform(l);y&&f.rot(-y.rotation());const{x:g,y:w}=b.Add(f,l);this.updateShapes([{id:l.id,type:l.type,x:g,y:w}]);const S=new b(c.width/d.width,1);this.resizeShape(l.id,S,{initialBounds:u,scaleOrigin:new b(c.minX,d.center.y),isAspectRatioLocked:this.getShapeUtil(l).isAspectRatioLocked(l),scaleAxisRotation:0})}});break}}return this}resizeShape(n,r,o={}){var y;const s=typeof n=="string"?n:n.id;if(this.getInstanceState().isReadonly)return this;Number.isFinite(r.x)||(r=new b(1,r.y)),Number.isFinite(r.y)||(r=new b(r.x,1));const i=o.initialShape??this.getShape(s);if(!i)return this;const a=o.scaleOrigin??((y=this.getShapePageBounds(s))==null?void 0:y.center);if(!a)return this;const c=o.initialPageTransform?oe.Cast(o.initialPageTransform):this.getShapePageTransform(s);if(!c)return this;const l=c.rotation();if(l==null)return this;const u=o.scaleAxisRotation??l,d=o.initialBounds??this.getShapeGeometry(s).bounds;if(!d)return this;const p=o.isAspectRatioLocked??this.getShapeUtil(i).isAspectRatioLocked(i);if(!GE(l,u))return this._resizeUnalignedShape(s,r,{...o,initialBounds:d,scaleOrigin:a,scaleAxisRotation:u,initialPageTransform:c,isAspectRatioLocked:p,initialShape:i});const f=this.getShapeUtil(i);if(p&&(Math.abs(r.x)>Math.abs(r.y)?r=new b(r.x,Math.sign(r.y)*Math.abs(r.x)):r=new b(Math.sign(r.x)*Math.abs(r.y),r.y)),f.onResize&&f.canResize(i)){const g=this._scalePagePoint(oe.applyToPoint(c,new b(0,0)),a,r,u),w=this.getPointInParentSpace(i.id,g),S=new b(r.x,r.y),v=yl((l-u)%Math.PI,0);S.x=v?r.x:r.y,S.y=v?r.y:r.x;const P=oe.applyToPoint(c,new b),{x:I,y:C}=this.getPointInParentSpace(i.id,P);this.updateShapes([{id:s,type:i.type,x:w.x,y:w.y,...f.onResize({...i,x:I,y:C},{newPoint:w,handle:o.dragHandle??"bottom_right",mode:o.mode??"scale_shape",scaleX:S.x,scaleY:S.y,initialBounds:d,initialShape:i})}])}else{const g=oe.applyToPoint(c,d.center),w=this._scalePagePoint(g,a,r,u),S=this.getPointInParentSpace(i.id,g),v=this.getPointInParentSpace(i.id,w),P=b.Sub(v,S);this.updateShapes([{id:s,type:i.type,x:i.x+P.x,y:i.y+P.y}])}return this}_scalePagePoint(n,r,o,s){const i=b.RotWith(n,r,-s).sub(r),a=b.MulV(i,o);return b.Add(a,r).rotWith(r,s)}_resizeUnalignedShape(n,r,o){const{type:s}=o.initialShape,i=new b(r.x,r.y);if(Math.abs(r.x)>Math.abs(r.y)?i.x=Math.sign(r.x)*Math.abs(r.y):i.y=Math.sign(r.y)*Math.abs(r.x),this.resizeShape(n,i,{initialShape:o.initialShape,initialBounds:o.initialBounds,isAspectRatioLocked:o.isAspectRatioLocked}),Math.sign(r.x)*Math.sign(r.y)<0){let{rotation:S}=oe.Decompose(o.initialPageTransform);S-=2*S,this.updateShapes([{id:n,type:s,rotation:S}])}const a=oe.applyToPoint(o.initialPageTransform,o.initialBounds.center),c=this._scalePagePoint(a,o.scaleOrigin,r,o.scaleAxisRotation),l=this.getShapePageBounds(n),u=this.getShapePageTransform(n),d=l.center,p=u.point();if(!d||!p)return this;const f=b.Sub(c,d),y=b.Add(p,f),{x:g,y:w}=this.getPointInParentSpace(n,y);return this.updateShapes([{id:n,type:s,x:g,y:w}]),this}getInitialMetaForShape(n){return{}}createShape(n){return this.createShapes([n]),this}createShapes(n){if(!Array.isArray(n))throw Error("Editor.createShapes: must provide an array of shapes or shape partials");if(this.getInstanceState().isReadonly)return this;if(n.length<=0)return this;const r=this.getCurrentPageShapeIds();if(n.length+r.size>gs)return wd(this),this;const s=this.getFocusedGroupId();return this.batch(()=>{var d,p;const i=this.getCurrentPageShapesSorted(),a=n.map(f=>{if(f.id||(f={id:He(),...f}),!f.parentId||!(this.store.has(f.parentId)||n.some(y=>y.id===f.parentId))){let y=this.getFocusedGroupId();for(let w=i.length-1;w>=0;w--){const S=i[w];if(this.getShapeUtil(S).canReceiveNewChildrenOfType(S,f.type)&&this.isPointInShape(S,{x:f.x??0,y:f.y??0},{margin:0,hitInside:!0})){y=S.id;break}}const g=f.parentId;if(y===f.id&&(y=s),y!==g&&(f={...f},f.parentId=y,Hn(y))){const w=this.getPointInShapeSpace(this.getShape(y),{x:f.x??0,y:f.y??0});f.x=w.x,f.y=w.y,f.rotation=-this.getShapePageTransform(y).rotation()+(f.rotation??0)}}return f}),c=new Map,l=[],{opacityForNextShape:u}=this.getInstanceState();for(const f of a){const y=this.getShapeUtil(f);let g=f.index;if(!g){const P=f.parentId??s;c.has(P)||c.set(P,this.getHighestIndexForParent(P)),g=c.get(P),c.set(P,$o(g))}const w=y.getDefaultProps();for(const[P,I]of this.styleProps[f.type])w[I]=this.getStyleForNextShape(P);let S=this.store.schema.types.shape.create({...f,index:g,opacity:f.opacity??u,parentId:f.parentId??s,props:"props"in f?{...w,...f.props}:w});if(S.index===void 0)throw Error("no index!");const v=(p=(d=this.getShapeUtil(S)).onBeforeCreate)==null?void 0:p.call(d,S);v&&(S=v),l.push(S)}l.forEach(f=>{f.meta={...this.getInitialMetaForShape(f),...f.meta}}),this.store.put(l)})}animateShape(n,r={animation:Dg}){return this.animateShapes([n],r)}animateShapes(n,r={animation:Dg}){if(!r.animation)return this;const{duration:o=500,easing:s=sn.linear}=r.animation,i=rt();let a=o,c;const l=[];let u,d;for(let y=0,g=n.length;y<g;y++){if(u=n[y],!u)continue;d={partial:u,values:[]};const w=this.getShape(u.id);if(w){for(const S of["x","y","rotation"])u[S]!==void 0&&w[S]!==u[S]&&d.values.push({prop:S,from:w[S],to:u[S]});l.push(d),this.animatingShapes.set(w.id,i)}}let p;const f=y=>{if(a-=y,a<0){const{animatingShapes:v}=this,P=n.filter(I=>I&&v.get(I.id)===i);P.length&&this.updateShapes(P),this.off("tick",f);return}c=s(1-a/o);const{animatingShapes:g}=this,w=[];let S;for(let v=0,P=l.length;v<P;v++)p=l[v],S=g.get(p.partial.id),S===i&&w.push({id:p.partial.id,type:p.partial.type,...p.values.reduce((I,{prop:C,from:E,to:_})=>(I[C]=E+(_-E)*c,I),{})});this._updateShapes(w)};return this.on("tick",f),this}groupShapes(n,r=He()){var f;if(!Array.isArray(n))throw Error("Editor.groupShapes: must provide an array of shapes or shape ids");if(this.getInstanceState().isReadonly)return this;const o=typeof n[0]=="string"?n:n.map(y=>y.id);if(o.length<=1)return this;const s=fe(this._getUnlockedShapeIds(o).map(y=>this.getShape(y))),i=s.sort(rn).map(y=>y.id),a=te.Common(fe(s.map(y=>this.getShapePageBounds(y)))),{x:c,y:l}=a.point,u=this.findCommonAncestor(s)??this.getCurrentPageId();if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const d=s.filter(y=>y.parentId===u).sort(rn),p=(f=d[d.length-1])==null?void 0:f.index;return this.batch(()=>{this.createShapes([{id:r,type:"group",parentId:u,index:p,x:c,y:l,opacity:1,props:{}}]),this.reparentShapes(i,r),this.select(r)}),this}ungroupShapes(n){const r=typeof n[0]=="string"?n:n.map(a=>a.id);if(this.getInstanceState().isReadonly)return this;if(r.length===0)return this;if(this.getCurrentToolId()!=="select")return this;this.isIn("select.idle")||this.cancel();const o=new Set,s=fe(r.map(a=>this.getShape(a))),i=[];return s.forEach(a=>{this.isShapeOfType(a,"group")?i.push(a):o.add(a.id)}),i.length===0?this:(this.batch(()=>{let a;for(let c=0,l=i.length;c<l;c++){a=i[c];const u=this.getSortedChildIdsForParent(a.id);for(let d=0,p=u.length;d<p;d++)o.add(u[d]);this.reparentShapes(u,a.parentId,a.index)}this.deleteShapes(i.map(c=>c.id)),this.select(...o)}),this)}updateShape(n){return this.updateShapes([n]),this}updateShapes(n){const r=Array(n.length);for(let o=0,s=n.length;o<s;o++){const i=n[o];if(!i)continue;const a=this.getShape(i.id);a&&(this.isShapeOrAncestorLocked(a)&&!Object.hasOwn(i,"isLocked")||(this.animatingShapes.delete(i.id),r.push(i)))}return this._updateShapes(r),this}_getUnlockedShapeIds(n){return n.filter(r=>{var o;return!((o=this.getShape(r))!=null&&o.isLocked)})}deleteShapes(n){if(!Array.isArray(n))throw Error("Editor.deleteShapes: must provide an array of shapes or shapeIds");const r=this._getUnlockedShapeIds(typeof n[0]=="string"?n:n.map(i=>i.id));if(this.getInstanceState().isReadonly)return this;if(r.length===0)return this;const o=new Set(r);for(const i of r)this.visitDescendants(i,a=>{o.add(a)});const s=[...o];return this.batch(()=>this.store.remove(s))}deleteShape(n){return this.deleteShapes([typeof n=="string"?n:n.id]),this}_extractSharedStyles(n,r){if(this.isShapeOfType(n,"group")){const o=this._parentIdsToChildIds.get()[n.id];if(!o)return;for(let s=0,i=o.length;s<i;s++)this._extractSharedStyles(this.getShape(o[s]),r)}else for(const[o,s]of this.styleProps[n.type])r.applyValue(o,qn(n.props,s))}_getSelectionSharedStyles(){const n=this.getSelectedShapes(),r=new HS;for(const o of n)this._extractSharedStyles(o,r);return r}getStyleForNextShape(n){const r=this.getInstanceState().stylesForNextShape[n.id];return r===void 0?n.defaultValue:r}getShapeStyleIfExists(n,r){const o=this.styleProps[n.type].get(r);if(o!==void 0)return qn(n.props,o)}getSharedStyles(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0)return this._getSelectionSharedStyles();const n=this.root.getCurrent(),r=new HS;if(!n)return r;if(n.shapeType)for(const o of this.styleProps[n.shapeType].keys())r.applyValue(o,this.getStyleForNextShape(o));return r}getSharedOpacity(){if(this.isIn("select")&&this.getSelectedShapeIds().length>0){const n=[],r=s=>{const i=this.getShape(s);if(i)if(this.isShapeOfType(i,"group"))for(const a of this.getSortedChildIdsForParent(i.id))r(a);else n.push(i)};for(const s of this.getSelectedShapeIds())r(s);let o=null;for(const s of n)if(o===null)o=s.opacity;else if(o!==s.opacity)return{type:"mixed"};if(o!==null)return{type:"shared",value:o}}return{type:"shared",value:this.getInstanceState().opacityForNextShape}}setOpacityForNextShapes(n,r){return this.updateInstanceState({opacityForNextShape:n},r),this}setOpacityForSelectedShapes(n){const r=this.getSelectedShapes();if(r.length>0){const o=[],s=i=>{if(this.isShapeOfType(i,"group")){const a=this.getSortedChildIdsForParent(i);for(const c of a)s(this.getShape(c))}else o.push(i)};for(const i of r)s(i);this.updateShapes(o.map(i=>({id:i.id,type:i.type,opacity:n})))}return this}setStyleForNextShapes(n,r,o){const s=this.getInstanceState().stylesForNextShape;return this.updateInstanceState({stylesForNextShape:{...s,[n.id]:r}},o),this}setStyleForSelectedShapes(n,r){const o=this.getSelectedShapes();if(o.length>0){const s=[],i=a=>{if(this.isShapeOfType(a,"group")){const c=this.getSortedChildIdsForParent(a.id);for(const l of c)i(this.getShape(l))}else{const c=this.getShapeUtil(a),l=this.styleProps[a.type].get(n);if(l){const u={id:a.id,type:a.type,props:{[l]:r}};s.push({util:c,originalShape:a,updatePartial:u})}}};for(const a of o)i(a);this.updateShapes(s.map(({updatePartial:a})=>a))}return this}registerExternalAssetHandler(n,r){return this.externalAssetContentHandlers[n]=r,this}async getAssetForExternalContent(n){var r,o;return await((o=(r=this.externalAssetContentHandlers)[n.type])==null?void 0:o.call(r,n))}registerExternalContentHandler(n,r){return this.externalContentHandlers[n]=r,this}async putExternalContent(n){var r,o;return(o=(r=this.externalContentHandlers)[n.type])==null?void 0:o.call(r,n)}getContentFromCurrentPage(n){const r=typeof n[0]=="string"?n:n.map(c=>c.id);if(!r||r.length===0)return;const o={};let s=Jh(r.map(c=>this.getShape(c)).sort(rn).flatMap(c=>{const l=[c];return this.visitDescendants(c.id,u=>{l.push(this.getShape(u))}),l}));s=s.map(c=>{if(o[c.id]=this.getShapePageTransform(c.id),c=Ge(c),this.isShapeOfType(c,"arrow")){const l=c.props.start.type==="binding"?c.props.start.boundShapeId:void 0,u=c.props.end.type==="binding"?c.props.end.boundShapeId:void 0,d=this.getArrowInfo(c);if(c.props.start.type==="binding"&&!s.some(f=>f.id===l))if(d!=null&&d.isValid){const{x:f,y}=d.start.point;c.props.start={type:"point",x:f,y}}else{const{start:f}=Dr(this,c);c.props.start={type:"point",x:f.x,y:f.y}}if(c.props.end.type==="binding"&&!s.some(f=>f.id===u))if(d!=null&&d.isValid){const{x:f,y}=d.end.point;c.props.end={type:"point",x:f,y}}else{const{end:f}=Dr(this,c);c.props.end={type:"point",x:f.x,y:f.y}}const p=Vc(c)?_l(this,c):ym(this,c);if(d!=null&&d.isValid&&(p!=null&&p.isValid)&&!Vc(c)){const f=b.Med(d.start.handle,d.end.handle),y=b.Dist(d.middle,f),g=b.Dist(p.middle,f);c.props.bend<0?c.props.bend+=g-y:c.props.bend-=g-y}return c}return c});const i=[];s.forEach(c=>{if(s.find(l=>l.id===c.parentId)===void 0){const l=this.getShapePageTransform(c.id),u=l.point(),d=l.rotation();c.x=u.x,c.y=u.y,c.rotation=d,c.parentId=this.getCurrentPageId(),i.push(c.id)}});const a=new Set;return s.forEach(c=>{"assetId"in c.props&&c.props.assetId!==null&&a.add(c.props.assetId)}),{shapes:s,rootShapeIds:i,schema:this.store.schema.serialize(),assets:fe(Array.from(a).map(c=>this.getAsset(c)))}}putContentOntoCurrentPage(n,r={}){var k;if(this.getInstanceState().isReadonly)return this;if(!n.schema)throw Error(`Could not put content:
|
|
83
|
-
content is missing a schema.`);const{select:o=!1,preserveIds:s=!1,preservePosition:i=!1}=r;let{point:a=void 0}=r;const c=this.getCurrentPageId(),{rootShapeIds:l}=n,u=[],d=[],p={store:{...Object.fromEntries(n.assets.map($=>[$.id,$])),...Object.fromEntries(n.shapes.map($=>[$.id,$]))},schema:n.schema},f=this.store.schema.migrateStoreSnapshot(p);if(f.type==="error")throw Error("Could not put content: could not migrate content");for(const $ of Object.values(f.value))switch($.typeName){case"asset":{u.push($);break}case"shape":{d.push($);break}}const y=new Map(d.map($=>[$.id,He()]));let g=this.getCurrentPageId(),w=1/0,S=[];for(const $ of this.getSelectedShapes()){if(w===0)break;const T=this.isShapeOfType($,"frame"),A=this.getShapeAncestors($);T&&A.push($);const B=T?A.length+1:A.length;if(B<w)w=B,S=A,g=T?$.id:$.parentId;else if(B===w){if(S.length!==A.length)throw Error(`Ancestors: ${S.length} !== ${A.length}`);if(S.length===0){g=c;break}else{g=c;for(let L=0;L<S.length&&A[L]===S[L];L++)g=A[L].id}}}let v=!1;if(!Pn(g)){const $=this.getShape(g);if($){if(!this.getViewportPageBounds().includes(this.getShapePageBounds($)))g=c;else if(l.length===1){const T=d.find(A=>A.id===l[0]);this.isShapeOfType($,"frame")&&this.isShapeOfType(T,"frame")&&T.props.w===($==null?void 0:$.props.w)&&T.props.h===($==null?void 0:$.props.h)&&(v=!0)}}else g=c}v||(v=y.has(g)),v&&(g=this.getShape(g).parentId);let P=this.getHighestIndexForParent(g);const I=[],C=d.map($=>{let T;if(s)T=Ge($),y.set($.id,$.id);else{const A=y.get($.id);T=Ge({...$,id:A})}if(l.includes($.id)&&(T.parentId=c,I.push(T)),y.has(T.parentId)?T.parentId=y.get($.parentId):(l.push(T.id),T.index=P,P=$o(P)),this.isShapeOfType(T,"arrow")){if(T.props.start.type==="binding"){const A=y.get(T.props.start.boundShapeId);T.props.start=A?{...T.props.start,boundShapeId:A}:{type:"point",x:0,y:0}}if(T.props.end.type==="binding"){const A=y.get(T.props.end.boundShapeId);T.props.end=A?{...T.props.end,boundShapeId:A}:{type:"point",x:0,y:0}}}return T});if(C.length+this.getCurrentPageShapeIds().size>gs)return wd(this),this;const E=[],_=[];for(const $ of u)this.store.has($.id)||(($.type==="image"||$.type==="video")&&((k=$.props.src)!=null&&k.startsWith("data:image"))&&(_.push(Ge($)),$.props.src=null),E.push($));return Promise.allSettled(_.map(async $=>{const T=await Uz($.props.src,$.props.name,$.props.mimeType??"image/png"),A=await this.getAssetForExternalContent({type:"file",file:T});if(!A){this.deleteAssets([$.id]);return}this.updateAssets([{...A,id:$.id}])})),this.batch(()=>{E.length>0&&this.createAssets(E),this.createShapes(C),o&&this.select(...I.map(L=>L.id)),g!==c&&this.reparentShapes(I.map(L=>L.id),g);const $=C.map(L=>this.getShape(L.id)),T=te.Common($.map(L=>this.getShapePageBounds(L)));if(a===void 0)if(Pn(g)){const L=this.getViewportPageBounds();i||L.includes(te.From(T))?a=T.center:a=L.center}else{const L=this.getShape(g);a=oe.applyToPoint(this.getShapePageTransform(L),this.getShapeGeometry(L).bounds.center)}if(I.length===1){const L=I[0];if(this.isShapeOfType(L,"frame"))for(;this.getShapesAtPoint(a).some(R=>this.isShapeOfType(R,"frame")&&R.props.w===L.props.w&&R.props.h===L.props.h);)a.x+=T.w+16}const A=te.Common(fe(I.map(({id:L})=>this.getShapePageBounds(L)))).center,B=b.Sub(a,A);this.updateShapes(I.map(({id:L})=>{const R=this.getShape(L),N=this.getShapeParentTransform(L).decompose().rotation,X=b.Rot(B,-N);return{id:R.id,type:R.type,x:R.x+X.x,y:R.y+X.y}}))}),this}async getSvgElement(n,r={}){const o=await e4(this,n,r);if(!o)return;const s=document.createDocumentFragment(),i=OT(s);Bi.flushSync(()=>{i.render(o.jsx)});const a=s.firstElementChild;return lt(a instanceof SVGSVGElement,"Expected an SVG element"),i.unmount(),{svg:a,width:o.width,height:o.height}}async getSvgString(n,r={}){const o=await this.getSvgElement(n,r);return o?{svg:new XMLSerializer().serializeToString(o.svg),width:o.width,height:o.height}:void 0}async getSvg(n,r={}){const o=await this.getSvgElement(n,r);if(o)return o.svg}_updateInputsFromEvent(n){const{pointerVelocity:r,previousScreenPoint:o,previousPagePoint:s,currentScreenPoint:i,currentPagePoint:a}=this.inputs,{screenBounds:c}=this.store.unsafeGetWithoutCapture(tn),{x:l,y:u,z:d}=this.store.unsafeGetWithoutCapture(this.getCameraId()),p=n.point.x-c.x,f=n.point.y-c.y,y=n.point.z??.5;o.setTo(i),s.setTo(a),i.set(p,f);const g=p/d-l,w=f/d-u;isFinite(g)&&isFinite(w)&&a.set(g,w,y),this.inputs.isPen=n.type==="pointer"&&n.isPen,(n.name==="pointer_down"||this.inputs.isPinching)&&(r.set(0,0),this.inputs.originScreenPoint.setTo(i),this.inputs.originPagePoint.setTo(a)),this.history.ignore(()=>{var S;this.store.put([{id:ap,typeName:"pointer",x:a.x,y:a.y,lastActivityTimestamp:n.type==="pointer"&&n.pointerId===Sb.CAMERA_MOVE?((S=this.store.unsafeGetWithoutCapture(ap))==null?void 0:S.lastActivityTimestamp)??this._tickManager.now:this._tickManager.now,meta:{}}])})}cancel(){return this.dispatch({type:"misc",name:"cancel"}),this}interrupt(){return this.dispatch({type:"misc",name:"interrupt"}),this}complete(){return this.dispatch({type:"misc",name:"complete"}),this}cancelDoubleClick(){this._clickManager.cancelDoubleClickTimeout()}_flushEventsForTick(n){this.batch(()=>{if(this._pendingEventsForNextTick.length>0){const r=[...this._pendingEventsForNextTick];this._pendingEventsForNextTick.length=0;for(const o of r)this._flushEventForTick(o)}n>0&&this.root.handleEvent({type:"misc",name:"tick",elapsed:n}),this.scribbles.tick(n)})}}re([G],ne.prototype,"getCanUndo");re([G],ne.prototype,"getCanRedo");re([G],ne.prototype,"_getArrowBindingsIndex");re([G],ne.prototype,"getArrowInfoCache");re([G],ne.prototype,"getPath");re([G],ne.prototype,"getCurrentTool");re([G],ne.prototype,"getCurrentToolId");re([G],ne.prototype,"getDocumentSettings");re([G],ne.prototype,"getInstanceState");re([G],ne.prototype,"getOpenMenus");re([G],ne.prototype,"getIsMenuOpen");re([G],ne.prototype,"getPageStates");re([G],ne.prototype,"_getPageStatesQuery");re([G],ne.prototype,"getCurrentPageState");re([G],ne.prototype,"_getCurrentPageStateId");re([G],ne.prototype,"getSelectedShapeIds");re([G],ne.prototype,"getSelectedShapes");re([G],ne.prototype,"getOnlySelectedShapeId");re([G],ne.prototype,"getOnlySelectedShape");re([G],ne.prototype,"getSelectionPageBounds");re([G],ne.prototype,"getSelectionRotation");re([G],ne.prototype,"getSelectionRotatedPageBounds");re([G],ne.prototype,"getSelectionRotatedScreenBounds");re([G],ne.prototype,"getFocusedGroupId");re([G],ne.prototype,"getFocusedGroup");re([G],ne.prototype,"getEditingShapeId");re([G],ne.prototype,"getEditingShape");re([G],ne.prototype,"getHoveredShapeId");re([G],ne.prototype,"getHoveredShape");re([G],ne.prototype,"getHintingShapeIds");re([G],ne.prototype,"getHintingShape");re([G],ne.prototype,"getErasingShapeIds");re([G],ne.prototype,"getErasingShapes");re([G],ne.prototype,"getCameraId");re([G],ne.prototype,"getCamera");re([G],ne.prototype,"getZoomLevel");re([G],ne.prototype,"getViewportScreenBounds");re([G],ne.prototype,"getViewportScreenCenter");re([G],ne.prototype,"getViewportPageBounds");re([G],ne.prototype,"_getCollaboratorsQuery");re([G],ne.prototype,"getCollaborators");re([G],ne.prototype,"getCollaboratorsOnCurrentPage");re([G],ne.prototype,"getRenderingShapes");re([G],ne.prototype,"_getAllPagesQuery");re([G],ne.prototype,"getPages");re([G],ne.prototype,"getCurrentPageId");re([G],ne.prototype,"getCurrentPageShapeIdsSorted");re([G],ne.prototype,"_getAllAssetsQuery");re([G],ne.prototype,"_getShapeGeometryCache");re([G],ne.prototype,"_getShapeHandlesCache");re([G],ne.prototype,"_getShapePageTransformCache");re([G],ne.prototype,"_getShapePageBoundsCache");re([G],ne.prototype,"_getShapeClipPathCache");re([G],ne.prototype,"_getShapeMaskCache");re([G],ne.prototype,"_getShapeMaskedPageBoundsCache");re([G],ne.prototype,"_notVisibleShapes");re([G],ne.prototype,"getCulledShapes");re([G],ne.prototype,"getCurrentPageBounds");re([G],ne.prototype,"getCurrentPageShapes");re([G],ne.prototype,"getCurrentPageShapesSorted");re([G],ne.prototype,"getCurrentPageRenderingShapesSorted");re([G],ne.prototype,"_getSelectionSharedStyles");re([G({isEqual:(e,t)=>e.equals(t)})],ne.prototype,"getSharedStyles");re([G],ne.prototype,"getSharedOpacity");function wd(e,t=e.getCurrentPageId()){const n=e.getPage(t).name;e.emit("max-shapes",{name:n,pageId:t,count:gs})}function Yc(e,t){if(!t)return e;let n=null;const r=Object.entries(t);for(let o=0,s=r.length;o<s;o++){const[i,a]=r[o];if(a!==void 0&&!(i==="id"||i==="type"||i==="typeName")&&a!==e[i]){if(n||(n={...e}),i==="props"||i==="meta"){n[i]={...e[i]};for(const[c,l]of Object.entries(a))l!==void 0&&(n[i][c]=l);continue}n[i]=a}}return n||e}function UT(e,t,n){const r=e.getShape(t);if(!r)return;n.push(r);const o=e.getSortedChildIdsForParent(t);for(let s=0,i=o.length;s<i;s++)UT(e,o[s],n)}function oP(e,t){if(!t.constraints)throw Error("Should have constraints here");const{padding:{x:n,y:r}}=t.constraints,o=e.getViewportScreenBounds(),s=te.From(t.constraints.bounds),i=(o.w-n*2)/s.w,a=(o.h-r*2)/s.h;return{zx:i,zy:a}}function Tu(){const e=z(),t=zT();return K("isDarkMode",()=>(t==null?void 0:t.isDarkMode)??e.user.getIsDarkMode(),[t,e])}const sP="<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'/>",iP="<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'/>",bd='<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 hs(e,t,n,r,o,s=16,i=16){const a=(-n-t)*(Pe/180),c=Math.sin(a),l=Math.cos(a),u=1*l-1*c,d=1*c+1*l;return`url("data:image/svg+xml,<svg height='32' width='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg' style='color: ${o};'><defs><filter id='shadow' y='-40%' x='-40%' width='180px' height='180%' color-interpolation-filters='sRGB'><feDropShadow dx='${u}' dy='${d}' stdDeviation='1.2' flood-opacity='.5'/></filter></defs><g fill='none' transform='rotate(${t+n} 16 16)${r?" scale(-1,-1) translate(0, -32)":""}' filter='url(%23shadow)'>`+e.replaceAll('"',"'")+`</g></svg>") ${s} ${i}, pointer`}const j4=["default","pointer","cross","move","grab","grabbing","text","zoom-in","zoom-out"],O4={none:()=>"none","ew-resize":(e,t,n)=>hs(iP,e,0,t,n),"ns-resize":(e,t,n)=>hs(iP,e,90,t,n),"nesw-resize":(e,t,n)=>hs(sP,e,0,t,n),"nwse-resize":(e,t,n)=>hs(sP,e,90,t,n),"nwse-rotate":(e,t,n)=>hs(bd,e,0,t,n),"nesw-rotate":(e,t,n)=>hs(bd,e,90,t,n),"senw-rotate":(e,t,n)=>hs(bd,e,180,t,n),"swne-rotate":(e,t,n)=>hs(bd,e,270,t,n)};function Bn(e,t=0,n="black"){return O4[e](_3(t),!1,n)}function D4(){const e=z(),t=Xt(),n=Tu();_s("useCursor",()=>{const{type:r,rotation:o}=e.getInstanceState().cursor;if(j4.includes(r)){t.style.setProperty("--tl-cursor",`var(--tl-cursor-${r})`);return}t.style.setProperty("--tl-cursor",Bn(r,o,n?"white":"black"))},[e,t,n])}function R4(){const e=z(),t=Xt(),n=Tu(),r=K(jt.forceSrgb);Se.useEffect(()=>{n?(t.setAttribute("data-color-mode","dark"),t.classList.remove("tl-theme__light"),t.classList.add("tl-theme__dark")):(t.setAttribute("data-color-mode","light"),t.classList.remove("tl-theme__dark"),t.classList.add("tl-theme__light")),r?t.classList.add("tl-theme__force-sRGB"):t.classList.remove("tl-theme__force-sRGB")},[e,t,r,n])}function cx(e){const t=x.useRef();return x.useLayoutEffect(()=>{t.current=e}),x.useDebugValue(e),x.useCallback((...n)=>{const r=t.current;return lt(r,"fn does not exist"),r(...n)},[])}function L4(e){const t=z(),n=Xt();x.useLayoutEffect(()=>{e?(t.getInstanceState().isFocused||t.updateInstanceState({isFocused:!0}),t.getContainer().focus()):t.getInstanceState().isFocused&&t.updateInstanceState({isFocused:!1})},[t,n,e])}function F4(){const[e,t]=x.useState(0);x.useEffect(()=>t(n=>n+1),[])}const Ua="TLDRAW_TAB_ID_v2",io=globalThis.window;function N4(){return io?["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(io.navigator.platform)||io.navigator.userAgent.includes("Mac")&&"ontouchend"in document:!1}const Xp=io?io[Ua]??qI(Ua)??"TLDRAW_INSTANCE_STATE_V1_"+rt():"<error>";io&&(io[Ua]=Xp,N4()?Vv(Ua,Xp):ZI(Ua));io==null||io.addEventListener("beforeunload",()=>{Vv(Ua,Xp)});const HT={Initial:0},Nf=Math.max(...Object.values(HT));function z4(e){e.version<HT.Initial,e.version=Nf}const KT=ve({version:he,currentPageId:Ol,isFocusMode:we,exportBackground:we,isDebugMode:we,isToolLocked:we,isGridMode:we,pageStates:Ut(ve({pageId:Ol,camera:ve({x:he,y:he,z:he}),selectedShapeIds:Ut(Tr),focusedGroupId:Tr.nullable()}))});function B4(e){if(!e||typeof e!="object")return console.warn("Invalid instance state"),null;if(!("version"in e)||typeof e.version!="number")return console.warn("No version in instance state"),null;e.version!==Nf&&(e=Ge(e),z4(e));try{return KT.validate(e)}catch(t){return console.warn(t),null}}function U4(e){const t=e.query.ids("page");return G("sessionStateSnapshot",()=>{const n=e.get(tn);if(!n)return null;const r=[...t.get()];return{version:Nf,currentPageId:n.currentPageId,exportBackground:n.exportBackground,isFocusMode:n.isFocusMode,isDebugMode:n.isDebugMode,isToolLocked:n.isToolLocked,isGridMode:n.isGridMode,pageStates:r.map(o=>{const s=e.get(gr.createId(o)),i=e.get(Rr.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 H4(e,t){const n=B4(t);if(!n)return;const r=e.allRecords().filter(i=>i.typeName==="instance_page_state"||i.typeName==="camera"),o={added:{},updated:{},removed:{...Kv(r.map(i=>[i.id,i]))}};e.has(tn)&&(o.removed[tn]=e.get(tn));const s={removed:{},updated:{},added:{[tn]:e.schema.types.instance.create({id:tn,currentPageId:n.currentPageId,isDebugMode:n.isDebugMode,isFocusMode:n.isFocusMode,isToolLocked:n.isToolLocked,isGridMode:n.isGridMode,exportBackground:n.exportBackground})}};for(const i of n.pageStates){const a=Rr.createId(i.pageId),c=gr.createId(i.pageId);s.added[a]=Rr.create({id:Rr.createId(i.pageId),x:i.camera.x,y:i.camera.y,z:i.camera.z}),s.added[c]=gr.create({id:gr.createId(i.pageId),pageId:i.pageId,selectedShapeIds:i.selectedShapeIds,focusedGroupId:i.focusedGroupId})}Ro(()=>{e.applyDiff(pf([o,s])),e.ensureStoreIsUsable()})}function K4(e){var o;const t=[];for(const s of Object.values(e))(o=s.typeName)!=null&&o.match(/^(instance.*|pointer|camera)$/)&&t.push(s);const n=t.filter(s=>s.typeName==="instance"&&s.id!==tn)[0];if(!n)return null;const r={version:Nf,currentPageId:n.currentPageId,exportBackground:!!n.exportBackground,isFocusMode:!!n.isFocusMode,isDebugMode:!!n.isDebugMode,isToolLocked:!!n.isToolLocked,isGridMode:!1,pageStates:t.filter(s=>s.typeName==="instance_page_state"&&s.instanceId===n.id).map(s=>{const i=e[s.cameraId]??{x:0,y:0,z:1};return{pageId:s.pageId,camera:{x:i.x,y:i.y,z:i.z},selectedShapeIds:s.selectedShapeIds,focusedGroupId:s.focusedGroupId}})};try{return KT.validate(r),r}catch{return null}}function W4(){window.alert(`Oops! We could not save changes to your browser's storage. We now need to reload the page and try again.
|
|
84
|
-
|
|
85
|
-
Keep seeing this message?
|
|
86
|
-
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.
|
|
87
|
-
• If your hard disk is full, try clearing up some space and then reload the page.`)}function G4(){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.
|
|
88
|
-
|
|
89
|
-
Keep seeing this message?
|
|
90
|
-
• If you're using tldraw in a private or "incognito" window, try loading tldraw in a regular window or in a different browser.`)}const V4=(e,t)=>t.some(n=>e instanceof n);let aP,cP;function Y4(){return aP||(aP=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function X4(){return cP||(cP=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const WT=new WeakMap,KS=new WeakMap,GT=new WeakMap,Sm=new WeakMap,lx=new WeakMap;function q4(e){const t=new Promise((n,r)=>{const o=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{n(Fo(e.result)),o()},i=()=>{r(e.error),o()};e.addEventListener("success",s),e.addEventListener("error",i)});return t.then(n=>{n instanceof IDBCursor&&WT.set(n,e)}).catch(()=>{}),lx.set(t,e),t}function Z4(e){if(KS.has(e))return;const t=new Promise((n,r)=>{const o=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{n(),o()},i=()=>{r(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)});KS.set(e,t)}let WS={get(e,t,n){if(e instanceof IDBTransaction){if(t==="done")return KS.get(e);if(t==="objectStoreNames")return e.objectStoreNames||GT.get(e);if(t==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Fo(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Q4(e){WS=e(WS)}function J4(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...n){const r=e.call(vm(this),t,...n);return GT.set(r,t.sort?t.sort():[t]),Fo(r)}:X4().includes(e)?function(...t){return e.apply(vm(this),t),Fo(WT.get(this))}:function(...t){return Fo(e.apply(vm(this),t))}}function e8(e){return typeof e=="function"?J4(e):(e instanceof IDBTransaction&&Z4(e),V4(e,Y4())?new Proxy(e,WS):e)}function Fo(e){if(e instanceof IDBRequest)return q4(e);if(Sm.has(e))return Sm.get(e);const t=e8(e);return t!==e&&(Sm.set(e,t),lx.set(t,e)),t}const vm=e=>lx.get(e);function t8(e,t,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(e,t),a=Fo(i);return r&&i.addEventListener("upgradeneeded",c=>{r(Fo(i.result),c.oldVersion,c.newVersion,Fo(i.transaction),c)}),n&&i.addEventListener("blocked",c=>n(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),o&&c.addEventListener("versionchange",l=>o(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}function n8(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",r=>t(r.oldVersion,r)),Fo(n).then(()=>{})}const r8=["get","getKey","getAll","getAllKeys","count"],o8=["put","add","delete","clear"],xm=new Map;function lP(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(xm.get(t))return xm.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=o8.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(o||r8.includes(n)))return;const s=async function(i,...a){const c=this.transaction(i,o?"readwrite":"readonly");let l=c.store;return r&&(l=l.index(a.shift())),(await Promise.all([l[n](...a),o&&c.done]))[0]};return xm.set(t,s),s}Q4(e=>({...e,get:(t,n,r)=>lP(t,n)||e.get(t,n,r),has:(t,n)=>!!lP(t,n)||e.has(t,n)}));const zf="TLDRAW_DOCUMENT_v2",VT="TLDRAW_DB_NAME_INDEX_v2",Ne={Records:"records",Schema:"schema",SessionState:"session_state"};async function Bf(e,t){l8(e);const n=await t8(e,3,{upgrade(r){r.objectStoreNames.contains(Ne.Records)||r.createObjectStore(Ne.Records),r.objectStoreNames.contains(Ne.Schema)||r.createObjectStore(Ne.Schema),r.objectStoreNames.contains(Ne.SessionState)||r.createObjectStore(Ne.SessionState)}});try{return await t(n)}finally{n.close()}}async function s8({persistenceKey:e,sessionId:t,didCancel:n}){const r=zf+e;if(ux().includes(r))return await c8({persistenceKey:e,didCancel:n}),await Bf(r,async o=>{var d,p;if(n!=null&&n())return;const s=o.transaction([Ne.Records,Ne.Schema,Ne.SessionState],"readonly"),i=s.objectStore(Ne.Records),a=s.objectStore(Ne.Schema),c=s.objectStore(Ne.SessionState);let l=t?(d=await c.get(t))==null?void 0:d.snapshot:null;l||(l=(p=(await c.getAll()).sort((y,g)=>y.updatedAt-g.updatedAt).pop())==null?void 0:p.snapshot);const u={records:await i.getAll(),schema:await a.get(Ne.Schema),sessionStateSnapshot:l};if(n!=null&&n()){s.abort();return}return await s.done,u})}async function i8({persistenceKey:e,schema:t,changes:n,sessionId:r,sessionStateSnapshot:o,didCancel:s}){const i=zf+e;await Bf(i,async a=>{const c=a.transaction([Ne.Records,Ne.Schema,Ne.SessionState],"readwrite"),l=c.objectStore(Ne.Records),u=c.objectStore(Ne.Schema),d=c.objectStore(Ne.SessionState);for(const[p,f]of Object.entries(n.added))await l.put(f,p);for(const[p,f]of Object.values(n.updated))await l.put(f,f.id);for(const p of Object.keys(n.removed))await l.delete(p);if(u.put(t.serialize(),Ne.Schema),o&&r?d.put({snapshot:o,updatedAt:Date.now(),id:r},r):(o||r)&&console.error("sessionStateSnapshot and instanceId must be provided together"),s!=null&&s())return c.abort();await c.done})}async function a8({persistenceKey:e,schema:t,snapshot:n,sessionId:r,sessionStateSnapshot:o,didCancel:s}){const i=zf+e;await Bf(i,async a=>{const c=a.transaction([Ne.Records,Ne.Schema,Ne.SessionState],"readwrite"),l=c.objectStore(Ne.Records),u=c.objectStore(Ne.Schema),d=c.objectStore(Ne.SessionState);await l.clear();for(const[p,f]of Object.entries(n))await l.put(f,p);if(u.put(t.serialize(),Ne.Schema),o&&r?d.put({snapshot:o,updatedAt:Date.now(),id:r},r):(o||r)&&console.error("sessionStateSnapshot and instanceId must be provided together"),s!=null&&s())return c.abort();await c.done})}async function c8({persistenceKey:e,didCancel:t}){await Bf(zf+e,async n=>{const r=n.transaction([Ne.SessionState],"readwrite"),o=r.objectStore(Ne.SessionState),s=(await o.getAll()).sort((a,c)=>a.updatedAt-c.updatedAt);if(s.length<10){await r.done;return}const i=s.slice(0,s.length-10);for(const{id:a}of i)await o.delete(a);if(t!=null&&t())return r.abort();await r.done})}function ux(){const e=JSON.parse(Wv(VT)||"[]")??[];return Array.isArray(e)?e:[]}function l8(e){const t=new Set(ux());t.add(e),Gv(VT,JSON.stringify([...t]))}const u8=350,d8=1e4,uP=Symbol("UPDATE_INSTANCE_STATE"),h8=e=>e;class p8{constructor(t){m(this,"onmessage")}postMessage(t){}close(){}}const f8=typeof BroadcastChannel>"u"?p8:BroadcastChannel;class g8{constructor(t,{persistenceKey:n,sessionId:r=Xp,onLoad:o,onLoadError:s},i=new f8(`tldraw-tab-sync-${n}`)){m(this,"disposables",new Set);m(this,"diffQueue",[]);m(this,"didDispose",!1);m(this,"shouldDoFullDBWrite",!0);m(this,"isReloading",!1);m(this,"persistenceKey");m(this,"sessionId");m(this,"serializedSchema");m(this,"isDebugging",!1);m(this,"documentTypes");m(this,"$sessionStateSnapshot");m(this,"initTime",Date.now());m(this,"isPersisting",!1);m(this,"didLastWriteError",!1);m(this,"scheduledPersistTimeout",null);this.store=t,this.channel=i,typeof window<"u"&&(window.tlsync=this),this.persistenceKey=n,this.sessionId=r,this.serializedSchema=this.store.schema.serialize(),this.$sessionStateSnapshot=U4(this.store),this.disposables.add(t.listen(({changes:a})=>{this.diffQueue.push(a),this.channel.postMessage(h8({type:"diff",storeId:this.store.id,changes:a,schema:this.serializedSchema})),this.schedulePersist()},{source:"user",scope:"document"})),this.disposables.add(t.listen(()=>{this.diffQueue.push(uP),this.schedulePersist()},{scope:"session"})),this.connect(o,s),this.documentTypes=new Set(Object.values(this.store.schema.types).filter(a=>a.scope==="document").map(a=>a.typeName))}debug(...t){this.isDebugging&&console.debug(...t)}async connect(t,n){this.debug("connecting");let r;try{r=await s8({persistenceKey:this.persistenceKey,sessionId:this.sessionId,didCancel:()=>this.didDispose})}catch(o){n(o),G4(),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??K4(o),i=this.store.schema.migrateStoreSnapshot({store:o,schema:r.schema??this.store.schema.serializeEarliestVersion()});if(i.type==="error"){console.error("failed to migrate store",i),n(new Error(`Failed to migrate store: ${i.reason}`));return}this.store.mergeRemoteChanges(()=>{this.store.put(Object.values(i.value).filter(a=>this.documentTypes.has(a.typeName)),"initialize")}),s&&H4(this.store,s)}this.channel.onmessage=({data:o})=>{var a,c;this.debug("got message",o);const s=o,i=this.store.schema.getMigrationsSince(s.schema);if(i.ok){if(i.value.length>0){this.debug("telling them to reload"),this.channel.postMessage({type:"announce",schema:this.serializedSchema}),this.shouldDoFullDBWrite=!0,this.persistIfNeeded();return}}else{if(Date.now()-this.initTime<5e3){n(new Error("Schema mismatch, please close other tabs and reload the page"));return}this.debug("reloading"),this.isReloading=!0,(c=(a=window==null?void 0:window.location)==null?void 0:a.reload)==null||c.call(a);return}s.type==="diff"&&(this.debug("applying diff"),Ro(()=>{this.store.mergeRemoteChanges(()=>{this.store.applyDiff(s.changes),this.store.ensureStoreIsUsable()})}))},this.channel.postMessage({type:"announce",schema:this.serializedSchema}),this.disposables.add(()=>{this.channel.close()}),t(this)}catch(o){if(this.debug("error loading data from store",o),this.didDispose)return;n(o);return}}close(){this.debug("closing"),this.didDispose=!0,this.disposables.forEach(t=>t())}schedulePersist(){this.debug("schedulePersist",this.scheduledPersistTimeout),!this.scheduledPersistTimeout&&(this.scheduledPersistTimeout=setTimeout(()=>{this.scheduledPersistTimeout=null,this.persistIfNeeded()},this.didLastWriteError?d8:u8))}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(){lt(!this.isPersisting,"persist already in progress"),this.isPersisting=!0,this.debug("doPersist start");const t=this.diffQueue;this.diffQueue=[];try{if(this.shouldDoFullDBWrite)this.shouldDoFullDBWrite=!1,await a8({persistenceKey:this.persistenceKey,schema:this.store.schema,snapshot:this.store.serialize(),didCancel:()=>this.didDispose,sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()});else{const n=pf(t.filter(r=>r!==uP));await i8({persistenceKey:this.persistenceKey,changes:n,schema:this.store.schema,didCancel:()=>this.didDispose,sessionId:this.sessionId,sessionStateSnapshot:this.$sessionStateSnapshot.get()})}this.didLastWriteError=!1}catch(n){this.shouldDoFullDBWrite=!0,this.didLastWriteError=!0,console.error("failed to store changes in indexed db",n),W4(),typeof window<"u"&&window.location.reload()}this.isPersisting=!1,this.debug("doPersist end"),this.schedulePersist()}}function YT({initialData:e,defaultName:t="",id:n,...r}){const o="schema"in r&&r.schema?r.schema:y3({shapes:m8(LT("shapeUtils"in r&&r.shapeUtils?r.shapeUtils:[])),migrations:"migrations"in r?r.migrations:[]});return new nE({id:n,schema:o,initialData:e,props:{defaultName:t}})}function m8(e){return Object.fromEntries(e.map(t=>[t.type,{props:t.props,migrations:t.migrations}]))}function dP(e){const t=YT(e);return e.snapshot&&t.loadSnapshot(e.snapshot),{store:t,opts:e}}function XT(e){const[t,n]=x.useState(()=>dP(e));if(!WI(t.opts,e)){const r=dP(e);return n(r),r.store}return t.store}function y8({persistenceKey:e,sessionId:t,...n}){const[r,o]=x.useState(null),s=XT(n);return x.useEffect(()=>{const i=rt();if(!e){o({id:i,storeWithStatus:{status:"not-synced",store:s}});return}o({id:i,storeWithStatus:{status:"loading"}});const a=l=>{o(u=>(u==null?void 0:u.id)===i?{id:i,storeWithStatus:l}:u)},c=new g8(s,{sessionId:t,persistenceKey:e,onLoad(){a({store:s,status:"synced-local"})},onLoadError(l){a({status:"error",error:l})}});return()=>{o(l=>(l==null?void 0:l.id)===i?null:l),c.close()}},[e,s,t]),(r==null?void 0:r.storeWithStatus)??{status:"loading"}}let qT=!1;if(typeof window<"u"){const e=window.navigator.userAgent,t=!!e.match(/iPad/i)||!!e.match(/iPhone/i),n=!!e.match(/WebKit/i);qT=t&&n&&!e.match(/CriOS/i)}function S8(){const e=z();x.useEffect(()=>{if(!qT)return;function t(n){(n.target instanceof HTMLInputElement&&n.target.type==="text"||n.target instanceof HTMLTextAreaElement)&&e.complete()}return document.addEventListener("focusout",t),()=>document.removeEventListener("focusout",t)},[e])}function v8(){const e=z(),t=Xt();x.useEffect(()=>{const n=s=>t.style.setProperty("--tl-zoom",s.toString()),r=KI(n,100),o=new dc("useZoomCss",()=>{e.getCurrentPageShapeIds().size<300?n(e.getZoomLevel()):r(e.getZoomLevel())});return o.attach(),o.execute(),()=>{o.detach()}},[e,t])}const x8=[],w8=[],b8=x.memo(function({store:t,components:n,className:r,user:o,...s}){const[i,a]=Se.useState(null),c=x.useMemo(()=>o??M_(),[o]),l=(n==null?void 0:n.ErrorFallback)===void 0?C_:n==null?void 0:n.ErrorFallback,u={...s,shapeUtils:s.shapeUtils??x8,tools:s.tools??w8,components:n};return h.jsx("div",{ref:a,draggable:!1,className:ue("tl-container tl-theme__light",r),onPointerDown:Kt,tabIndex:-1,children:h.jsx(Rl,{fallback:l,onError:d=>Hv(d,{tags:{origin:"react.tldraw-before-app"}}),children:i&&h.jsx(Z3,{container:i,children:h.jsx(m6,{overrides:n,children:t?t instanceof nE?h.jsx(QT,{...u,store:t,user:c}):h.jsx(ZT,{...u,store:t,user:c}):h.jsx(P8,{...u,store:t,user:c})})})})})});function P8(e){const{defaultName:t,snapshot:n,initialData:r,shapeUtils:o,persistenceKey:s,sessionId:i,user:a}=e,c=y8({shapeUtils:o,initialData:r,persistenceKey:s,sessionId:i,defaultName:t,snapshot:n});return h.jsx(ZT,{...e,store:c,user:a})}const ZT=x.memo(function({store:t,user:n,...r}){const o=Xt();x.useLayoutEffect(()=>{n.userPreferences.get().isDarkMode&&(o.classList.remove("tl-theme__light"),o.classList.add("tl-theme__dark"))},[o,n]);const{LoadingScreen:s}=pt();switch(t.status){case"error":throw t.error;case"loading":return s?h.jsx(s,{}):null}return h.jsx(QT,{...r,store:t.store,user:n})});function QT({onMount:e,children:t,store:n,tools:r,shapeUtils:o,user:s,initialState:i,autoFocus:a=!0,inferDarkMode:c,cameraOptions:l}){const{ErrorFallback:u}=pt(),d=Xt(),[p,f]=x.useState(null);x.useLayoutEffect(()=>{const w=new ne({store:n,shapeUtils:o,tools:r,getContainer:()=>d,user:s,initialState:i,inferDarkMode:c,cameraOptions:l});return f(w),()=>{w.dispose()}},[d,o,r,n,s,i,c,l]);const y=x.useSyncExternalStore(x.useCallback(w=>p?(p.on("crash",w),()=>p.off("crash",w)):()=>{},[p]),()=>(p==null?void 0:p.getCrashingError())??null),{Canvas:g}=pt();return p?h.jsx(Rl,{fallback:u,onError:w=>p.annotateError(w,{origin:"react.tldraw",willCrashApp:!0}),children:y?h.jsx(E8,{crashingError:y}):h.jsx(yf.Provider,{value:p,children:h.jsx(C8,{autoFocus:a,onMount:e,children:t??(g?h.jsx(g,{}):null)})})}):null}function C8({children:e,onMount:t,autoFocus:n}){return v8(),D4(),R4(),S8(),F4(),L4(n),_8(t),h.jsxs(h.Fragment,{children:[e,h.jsx(I8,{})]})}function I8(){const{InFrontOfTheCanvas:e}=pt();return e?h.jsx("div",{className:"tl-front",children:h.jsx(e,{})}):null}function E8({crashingError:e}){throw e}function JT({children:e}){return h.jsx("div",{className:"tl-loading",children:e})}function e2({children:e}){return h.jsx("div",{className:"tl-loading",children:e})}function _8(e){const t=z(),n=cx(r=>{let o;return r.history.ignore(()=>{o=e==null?void 0:e(r),r.emit("mount")}),window.tldrawReady=!0,o});Se.useLayoutEffect(()=>{if(t)return n==null?void 0:n(t)},[t,n])}function $i({children:e,className:t="",...n}){return h.jsx("div",{...n,className:ue("tl-html-container",t),children:e})}function t2(e,t,n={}){const{newPoint:r,handle:o,scaleX:s,scaleY:i}=t,{minWidth:a=1,maxWidth:c=1/0,minHeight:l=1,maxHeight:u=1/0}=n;let d=e.props.w*s,p=e.props.h*i;const f=new 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(p>0){if(p<l){switch(o){case"top_left":case"top":case"top_right":{f.y=p-l;break}case"right":case"left":{f.y=(p-l)/2;break}default:f.y=0}p=l}}else if(f.y=p,p=-p,p<l){switch(o){case"top_left":case"top":case"top_right":{f.y=-p;break}default:f.y=-l}p=l}const{x:y,y:g}=f.rot(e.rotation).add(r);return{x:y,y:g,props:{w:Math.min(c,d),h:Math.min(u,p)}}}class vc extends Nr{constructor(){super(...arguments);m(this,"onResize",(n,r)=>t2(n,r))}getGeometry(n){return new Vo({width:n.props.w,height:n.props.h,isFilled:!0})}getHandleSnapGeometry(n){return{points:this.getGeometry(n).bounds.cornersAndCenter}}}var fy;let k8=(fy=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(fy,"id","idle"),fy);var gy;let T8=(gy=class extends se{constructor(){super(...arguments);m(this,"markId","");m(this,"wasFocusedOnEnter",!1);m(this,"onEnter",()=>{this.wasFocusedOnEnter=!this.editor.getIsMenuOpen()});m(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){const{originPagePoint:r}=this.editor.inputs,o=this.parent.shapeType,s=He();this.markId=`creating:${s}`,this.editor.mark(this.markId),this.editor.createShapes([{id:s,type:o,x:r.x,y:r.y,props:{w:1,h:1}}]).select(s),this.editor.setCurrentTool("select.resizing",{...n,target:"selection",handle:"bottom_right",isCreating:!0,creationCursorOffset:{x:1,y:1},onInteractionEnd:this.parent.id,onCreate:this.parent.onCreate})}});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()})}complete(){const{originPagePoint:n}=this.editor.inputs;if(!this.wasFocusedOnEnter)return;this.editor.mark(this.markId);const r=this.parent.shapeType,o=He();this.editor.mark(this.markId),this.editor.createShapes([{id:o,type:r,x:n.x,y:n.y}]);const s=this.editor.getShape(o),{w:i,h:a}=this.editor.getShapeUtil(s).getDefaultProps(),c=new b(i/2,a/2),l=this.editor.getShapeParentTransform(s);l&&c.rot(-l.rotation()),this.editor.updateShapes([{id:o,type:r,x:s.x-c.x,y:s.y-c.y}]),this.editor.setSelectedShapes([o]),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select.idle")}cancel(){this.parent.transition("idle")}},m(gy,"id","pointing"),gy);class mh extends se{constructor(){super(...arguments);m(this,"onCreate")}}m(mh,"id","box"),m(mh,"initial","idle"),m(mh,"children",()=>[k8,T8]);function Uf(e){const t=z();return K("isEditing",()=>t.getEditingShapeId()===e,[t,e])}function $8(){return x.useId().replace(/:/g,"_")}function qr(e){const t=z();return x.useMemo(function(){const o=l=>{if(l.isKilled)return;if(l.button===n0){t.dispatch({type:"pointer",target:"selection",handle:e,name:"right_click",..._n(l)});return}if(l.button!==0)return;const u=vp(l.currentTarget);function d(){u.removeEventListener("pointerup",d),wu(u,l)}xu(u,l),u.addEventListener("pointerup",d),t.dispatch({name:"pointer_down",type:"pointer",target:"selection",handle:e,..._n(l)}),Kt(l)};let s,i;function a(l){l.isKilled||l.button===0&&(l.clientX===s&&l.clientY===i||(s=l.clientX,i=l.clientY,t.dispatch({name:"pointer_move",type:"pointer",target:"selection",handle:e,..._n(l)})))}return{onPointerDown:o,onPointerMove:a,onPointerUp:l=>{l.isKilled||l.button===0&&t.dispatch({name:"pointer_up",type:"pointer",target:"selection",handle:e,..._n(l)})}}},[t,e])}const M8=20,A8=8;function dx(e,t=M8){return Math.max(A8,Math.ceil(e/t))}class n2 extends Fi{constructor(n){super({...n,isFilled:!1,isClosed:!1});m(this,"_center");m(this,"radius");m(this,"start");m(this,"end");m(this,"measure");m(this,"length");m(this,"angleStart");m(this,"angleEnd");const{center:r,radius:o,sweepFlag:s,largeArcFlag:i,start:a,end:c}=n;if(a.equals(c))throw Error("Arc must have different start and end points.");this.angleStart=b.Angle(r,a),this.angleEnd=b.Angle(r,c),this.measure=k3(this.angleStart,this.angleEnd,s,i),this.length=this.measure*o,this.start=a,this.end=c,this._center=r,this.radius=o}nearestPoint(n){const{_center:r,measure:o,radius:s,angleEnd:i,angleStart:a,start:c,end:l}=this,u=Wy(o,a,i,r.angle(n));if(u<=0)return c;if(u>=1)return l;const d=r.clone().add(n.clone().sub(r).uni().mul(s));let p,f=1/0,y;for(const g of[c,l,d])y=b.Dist2(n,g),y<f&&(p=g,f=y);if(!p)throw Error("nearest point not found");return p}hitTestLineSegment(n,r){const{_center:o,radius:s,measure:i,angleStart:a,angleEnd:c}=this,l=Df(n,r,o,s);return l===null?!1:l.some(u=>{const d=Wy(i,a,c,o.angle(u));return d>=0&&d<=1})}getVertices(){const{_center:n,measure:r,length:o,radius:s,angleStart:i}=this,a=[];for(let c=0,l=dx(Math.abs(o));c<l+1;c++){const u=c/l*r,d=i+u;a.push(Pi(n,s,d))}return a}}class hx extends Fi{constructor(n){super({isClosed:!0,...n});m(this,"_center");m(this,"radius");m(this,"x");m(this,"y");this.config=n;const{x:r=0,y:o=0,radius:s}=n;this.x=r,this.y=o,this._center=new b(s+r,s+o),this.radius=s}getBounds(){return new te(this.x,this.y,this.radius*2,this.radius*2)}getVertices(){const{_center:n,radius:r}=this,o=Re*r,s=[];for(let i=0,a=dx(o);i<a;i++){const c=i/a*Re;s.push(Pi(n,r,c))}return s}nearestPoint(n){const{_center:r,radius:o}=this;return r.equals(n)?b.AddXY(r,o,0):r.clone().add(n.clone().sub(r).uni().mul(o))}hitTestLineSegment(n,r,o=0){const{_center:s,radius:i}=this;return Df(n,r,s,i+o)!==null}}class j8 extends Ui{constructor(n){const{start:r,cp1:o,cp2:s,end:i}=n;super({...n,points:[r,i]});m(this,"a");m(this,"b");m(this,"c");m(this,"d");this.a=r,this.b=o,this.c=s,this.d=i}getVertices(){const n=[],{a:r,b:o,c:s,d:i}=this;for(let a=0,c=10;a<=c;a++){const l=a/c;n.push(new b((1-l)*(1-l)*(1-l)*r.x+3*((1-l)*(1-l))*l*o.x+3*(1-l)*(l*l)*s.x+l*l*l*i.x,(1-l)*(1-l)*(1-l)*r.y+3*((1-l)*(1-l))*l*o.y+3*(1-l)*(l*l)*s.y+l*l*l*i.y))}return n}midPoint(){return O8(this,.5)}nearestPoint(n){let r,o=1/0,s,i;for(const a of this.segments)i=a.nearestPoint(n),s=b.Dist2(i,n),s<o&&(r=i,o=s);if(!r)throw Error("nearest point not found");return r}}function O8(e,t){const{a:n,b:r,c:o,d:s}=e;return new b((1-t)*(1-t)*(1-t)*n.x+3*((1-t)*(1-t))*t*r.x+3*(1-t)*(t*t)*o.x+t*t*t*s.x,(1-t)*(1-t)*(1-t)*n.y+3*((1-t)*(1-t))*t*r.y+3*(1-t)*(t*t)*o.y+t*t*t*s.y)}class D8 extends Fi{constructor(n){super({...n,isClosed:!1,isFilled:!1});m(this,"points");m(this,"_segments");m(this,"_length");const{points:r}=n;this.points=r}get segments(){if(!this._segments){this._segments=[];const{points:n}=this,r=n.length,o=r-2,s=1.25;for(let i=0;i<r-1;i++){const a=i===0?n[0]:n[i-1],c=n[i],l=n[i+1],u=i===o?l:n[i+2],d=c,p=i===0?a:new b(c.x+(l.x-a.x)/6*s,c.y+(l.y-a.y)/6*s),f=i===o?l:new b(l.x-(u.x-c.x)/6*s,l.y-(u.y-c.y)/6*s),y=l;this._segments.push(new j8({start:d,cp1:p,cp2:f,end:y}))}}return this._segments}get length(){return this._length||(this._length=this.segments.reduce((n,r)=>n+r.length,0)),this._length}getVertices(){const n=this.segments.reduce((r,o)=>r.concat(o.vertices),[]);return n.push(this.points[this.points.length-1]),n}nearestPoint(n){let r,o=1/0,s,i;for(const a of this.segments)i=a.nearestPoint(n),s=b.Dist2(i,n),s<o&&(r=i,o=s);if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(n,r){return this.segments.some(o=>o.hitTestLineSegment(n,r))}}class r2 extends Fi{constructor(n){super({...n,isClosed:!0});m(this,"w");m(this,"h");m(this,"_edges");this.config=n;const{width:r,height:o}=n;this.w=r,this.h=o}get edges(){if(!this._edges){const{vertices:n}=this;this._edges=[];for(let r=0,o=n.length;r<o;r++){const s=n[r],i=n[(r+1)%o];this._edges.push(new nu({start:s,end:i}))}}return this._edges}getVertices(){const n=Math.max(1,this.w),r=Math.max(1,this.h),o=n/2,s=r/2,i=Math.pow(o-s,2)/Math.pow(o+s,2),a=Pe*(o+s)*(1+3*i/(10+Math.sqrt(4-3*i))),c=dx(a),l=Re/c,u=Math.cos(l),d=Math.sin(l);let p=0,f=1,y=0,g=1;const w=Array(c);for(let S=0;S<c;S++)w[S]=new b(o+o*f,s+s*p),y=d*f+u*p,g=u*f-d*p,p=y,f=g;return w}nearestPoint(n){let r,o=1/0,s,i;for(const a of this.edges)i=a.nearestPoint(n),s=b.Dist2(i,n),s<o&&(r=i,o=s);if(!r)throw Error("nearest point not found");return r}hitTestLineSegment(n,r){return this.edges.some(o=>o.hitTestLineSegment(n,r))}getBounds(){return new te(0,0,this.w,this.h)}}const Eo=18;class R8 extends r2{constructor(t){super({...t}),this.config=t}getVertices(){const t=Math.max(1,this.w),n=Math.max(1,this.h),r=t/2,o=n/2,s=Array(Eo);let i,a;if(n>t)for(let c=0;c<Eo-1;c++)i=-Pe+Pe*c/(Eo-2),a=Pe*c/(Eo-2),s[c]=new b(r+r*Math.cos(i),r+r*Math.sin(i)),s[c+(Eo-1)]=new b(r+r*Math.cos(a),n-r+r*Math.sin(a));else for(let c=0;c<Eo-1;c++)i=-Ue+Pe*c/(Eo-2),a=Ue+Pe*-c/(Eo-2),s[c]=new b(t-o+o*Math.cos(i),n-o+o*Math.sin(i)),s[c+(Eo-1)]=new b(o-o*Math.cos(a),n-o+o*Math.sin(a));return s}}function hP(e,t,n,r,o){const s=B3,i=n?U3:0,a=e-i,c=e+i,l=r?0:s,u=o?t:t-s;return a<l?Math.min(1,(l-a)/s):c>u?-Math.min(1,(c-u)/s):0}function px(e){if(!e.inputs.isDragging||e.inputs.isPanning||e.getCameraOptions().isLocked)return;const{inputs:{currentScreenPoint:{x:t,y:n}}}=e,r=e.getZoomLevel(),o=e.getViewportScreenBounds(),s=o.w<1e3?.612:1,i=o.h<1e3?.612:1,{isCoarsePointer:a,insets:[c,l,u,d]}=e.getInstanceState(),p=hP(t,o.w,a,d,l),f=hP(n,o.h,a,c,u);if(p===0&&f===0)return;const y=e.user.getEdgeScrollSpeed()*z3,g=y*p*s/r,w=y*f*i/r,S=e.getCamera();e.setCamera(new b(S.x+g,S.y+w,S.z))}async function L8({shouldReload:e=!0}={}){XD(),await Promise.all(ux().map(t=>n8(t))),YD(),e&&window.location.reload()}typeof window<"u"&&(window.__tldraw__hardReset=L8);function F8(e,t="_blank"){u0.openWindow(e,t)}var Xc=function(e){return e&&e.Math===Math&&e},Dn=Xc(typeof globalThis=="object"&&globalThis)||Xc(typeof window=="object"&&window)||Xc(typeof self=="object"&&self)||Xc(typeof on=="object"&&on)||Xc(typeof on=="object"&&on)||function(){return this}()||Function("return this")(),fx={},xn=function(e){try{return!!e()}catch{return!0}},N8=xn,Xs=!N8(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),z8=xn,Hf=!z8(function(){var e=(function(){}).bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),B8=Hf,Pd=Function.prototype.call,ts=B8?Pd.bind(Pd):function(){return Pd.apply(Pd,arguments)},o2={},s2={}.propertyIsEnumerable,i2=Object.getOwnPropertyDescriptor,U8=i2&&!s2.call({1:2},1);o2.f=U8?function(t){var n=i2(this,t);return!!n&&n.enumerable}:s2;var a2=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}},c2=Hf,l2=Function.prototype,GS=l2.call,H8=c2&&l2.bind.bind(GS,GS),Rt=c2?H8:function(e){return function(){return GS.apply(e,arguments)}},u2=Rt,K8=u2({}.toString),W8=u2("".slice),xc=function(e){return W8(K8(e),8,-1)},G8=Rt,V8=xn,Y8=xc,wm=Object,X8=G8("".split),q8=V8(function(){return!wm("z").propertyIsEnumerable(0)})?function(e){return Y8(e)==="String"?X8(e,""):wm(e)}:wm,Kf=function(e){return e==null},Z8=Kf,Q8=TypeError,wc=function(e){if(Z8(e))throw new Q8("Can't call method on "+e);return e},J8=q8,e7=wc,Wf=function(e){return J8(e7(e))},bm=typeof document=="object"&&document.all,wn=typeof bm>"u"&&bm!==void 0?function(e){return typeof e=="function"||e===bm}:function(e){return typeof e=="function"},t7=wn,Hi=function(e){return typeof e=="object"?e!==null:t7(e)},Pm=Dn,n7=wn,r7=function(e){return n7(e)?e:void 0},Gf=function(e,t){return arguments.length<2?r7(Pm[e]):Pm[e]&&Pm[e][t]},o7=Rt,d2=o7({}.isPrototypeOf),s7=typeof navigator<"u"&&String(navigator.userAgent)||"",h2=Dn,Cm=s7,pP=h2.process,fP=h2.Deno,gP=pP&&pP.versions||fP&&fP.version,mP=gP&&gP.v8,Or,qp;mP&&(Or=mP.split("."),qp=Or[0]>0&&Or[0]<4?1:+(Or[0]+Or[1]));!qp&&Cm&&(Or=Cm.match(/Edge\/(\d+)/),(!Or||Or[1]>=74)&&(Or=Cm.match(/Chrome\/(\d+)/),Or&&(qp=+Or[1])));var i7=qp,yP=i7,a7=xn,c7=Dn,l7=c7.String,p2=!!Object.getOwnPropertySymbols&&!a7(function(){var e=Symbol("symbol detection");return!l7(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&yP&&yP<41}),u7=p2,f2=u7&&!Symbol.sham&&typeof Symbol.iterator=="symbol",d7=Gf,h7=wn,p7=d2,f7=f2,g7=Object,g2=f7?function(e){return typeof e=="symbol"}:function(e){var t=d7("Symbol");return h7(t)&&p7(t.prototype,g7(e))},m7=String,y7=function(e){try{return m7(e)}catch{return"Object"}},S7=wn,v7=y7,x7=TypeError,gx=function(e){if(S7(e))return e;throw new x7(v7(e)+" is not a function")},w7=gx,b7=Kf,mx=function(e,t){var n=e[t];return b7(n)?void 0:w7(n)},Im=ts,Em=wn,_m=Hi,P7=TypeError,C7=function(e,t){var n,r;if(t==="string"&&Em(n=e.toString)&&!_m(r=Im(n,e))||Em(n=e.valueOf)&&!_m(r=Im(n,e))||t!=="string"&&Em(n=e.toString)&&!_m(r=Im(n,e)))return r;throw new P7("Can't convert object to primitive value")},m2={exports:{}},SP=Dn,I7=Object.defineProperty,yx=function(e,t){try{I7(SP,e,{value:t,configurable:!0,writable:!0})}catch{SP[e]=t}return t},E7=Dn,_7=yx,vP="__core-js_shared__",xP=m2.exports=E7[vP]||_7(vP,{});(xP.versions||(xP.versions=[])).push({version:"3.37.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Sx=m2.exports,wP=Sx,vx=function(e,t){return wP[e]||(wP[e]=t||{})},k7=wc,T7=Object,$u=function(e){return T7(k7(e))},$7=Rt,M7=$u,A7=$7({}.hasOwnProperty),qs=Object.hasOwn||function(t,n){return A7(M7(t),n)},j7=Rt,O7=0,D7=Math.random(),R7=j7(1 .toString),y2=function(e){return"Symbol("+(e===void 0?"":e)+")_"+R7(++O7+D7,36)},L7=Dn,F7=vx,bP=qs,N7=y2,z7=p2,B7=f2,Ta=L7.Symbol,km=F7("wks"),U7=B7?Ta.for||Ta:Ta&&Ta.withoutSetter||N7,ns=function(e){return bP(km,e)||(km[e]=z7&&bP(Ta,e)?Ta[e]:U7("Symbol."+e)),km[e]},H7=ts,PP=Hi,CP=g2,K7=mx,W7=C7,G7=ns,V7=TypeError,Y7=G7("toPrimitive"),X7=function(e,t){if(!PP(e)||CP(e))return e;var n=K7(e,Y7),r;if(n){if(t===void 0&&(t="default"),r=H7(n,e,t),!PP(r)||CP(r))return r;throw new V7("Can't convert object to primitive value")}return t===void 0&&(t="number"),W7(e,t)},q7=X7,Z7=g2,S2=function(e){var t=q7(e,"string");return Z7(t)?t:t+""},Q7=Dn,IP=Hi,VS=Q7.document,J7=IP(VS)&&IP(VS.createElement),v2=function(e){return J7?VS.createElement(e):{}},eB=Xs,tB=xn,nB=v2,x2=!eB&&!tB(function(){return Object.defineProperty(nB("div"),"a",{get:function(){return 7}}).a!==7}),rB=Xs,oB=ts,sB=o2,iB=a2,aB=Wf,cB=S2,lB=qs,uB=x2,EP=Object.getOwnPropertyDescriptor;fx.f=rB?EP:function(t,n){if(t=aB(t),n=cB(n),uB)try{return EP(t,n)}catch{}if(lB(t,n))return iB(!oB(sB.f,t,n),t[n])};var bc={},dB=Xs,hB=xn,w2=dB&&hB(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),pB=Hi,fB=String,gB=TypeError,Ki=function(e){if(pB(e))return e;throw new gB(fB(e)+" is not an object")},mB=Xs,yB=x2,SB=w2,Cd=Ki,_P=S2,vB=TypeError,Tm=Object.defineProperty,xB=Object.getOwnPropertyDescriptor,$m="enumerable",Mm="configurable",Am="writable";bc.f=mB?SB?function(t,n,r){if(Cd(t),n=_P(n),Cd(r),typeof t=="function"&&n==="prototype"&&"value"in r&&Am in r&&!r[Am]){var o=xB(t,n);o&&o[Am]&&(t[n]=r.value,r={configurable:Mm in r?r[Mm]:o[Mm],enumerable:$m in r?r[$m]:o[$m],writable:!1})}return Tm(t,n,r)}:Tm:function(t,n,r){if(Cd(t),n=_P(n),Cd(r),yB)try{return Tm(t,n,r)}catch{}if("get"in r||"set"in r)throw new vB("Accessors not supported");return"value"in r&&(t[n]=r.value),t};var wB=Xs,bB=bc,PB=a2,xx=wB?function(e,t,n){return bB.f(e,t,PB(1,n))}:function(e,t,n){return e[t]=n,e},b2={exports:{}},YS=Xs,CB=qs,P2=Function.prototype,IB=YS&&Object.getOwnPropertyDescriptor,wx=CB(P2,"name"),EB=wx&&(function(){}).name==="something",_B=wx&&(!YS||YS&&IB(P2,"name").configurable),kB={EXISTS:wx,PROPER:EB,CONFIGURABLE:_B},TB=Rt,$B=wn,XS=Sx,MB=TB(Function.toString);$B(XS.inspectSource)||(XS.inspectSource=function(e){return MB(e)});var C2=XS.inspectSource,AB=Dn,jB=wn,kP=AB.WeakMap,OB=jB(kP)&&/native code/.test(String(kP)),DB=vx,RB=y2,TP=DB("keys"),I2=function(e){return TP[e]||(TP[e]=RB(e))},bx={},LB=OB,E2=Dn,FB=Hi,NB=xx,jm=qs,Om=Sx,zB=I2,BB=bx,$P="Object already initialized",qS=E2.TypeError,UB=E2.WeakMap,Zp,ru,Qp,HB=function(e){return Qp(e)?ru(e):Zp(e,{})},KB=function(e){return function(t){var n;if(!FB(t)||(n=ru(t)).type!==e)throw new qS("Incompatible receiver, "+e+" required");return n}};if(LB||Om.state){var Yr=Om.state||(Om.state=new UB);Yr.get=Yr.get,Yr.has=Yr.has,Yr.set=Yr.set,Zp=function(e,t){if(Yr.has(e))throw new qS($P);return t.facade=e,Yr.set(e,t),t},ru=function(e){return Yr.get(e)||{}},Qp=function(e){return Yr.has(e)}}else{var na=zB("state");BB[na]=!0,Zp=function(e,t){if(jm(e,na))throw new qS($P);return t.facade=e,NB(e,na,t),t},ru=function(e){return jm(e,na)?e[na]:{}},Qp=function(e){return jm(e,na)}}var _2={set:Zp,get:ru,has:Qp,enforce:HB,getterFor:KB},Px=Rt,WB=xn,GB=wn,Id=qs,ZS=Xs,VB=kB.CONFIGURABLE,YB=C2,k2=_2,XB=k2.enforce,qB=k2.get,MP=String,yh=Object.defineProperty,ZB=Px("".slice),QB=Px("".replace),JB=Px([].join),e9=ZS&&!WB(function(){return yh(function(){},"length",{value:8}).length!==8}),t9=String(String).split("String"),n9=b2.exports=function(e,t,n){ZB(MP(t),0,7)==="Symbol("&&(t="["+QB(MP(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Id(e,"name")||VB&&e.name!==t)&&(ZS?yh(e,"name",{value:t,configurable:!0}):e.name=t),e9&&n&&Id(n,"arity")&&e.length!==n.arity&&yh(e,"length",{value:n.arity});try{n&&Id(n,"constructor")&&n.constructor?ZS&&yh(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var r=XB(e);return Id(r,"source")||(r.source=JB(t9,typeof t=="string"?t:"")),e};Function.prototype.toString=n9(function(){return GB(this)&&qB(this).source||YB(this)},"toString");var r9=b2.exports,o9=wn,s9=bc,i9=r9,a9=yx,T2=function(e,t,n,r){r||(r={});var o=r.enumerable,s=r.name!==void 0?r.name:t;if(o9(n)&&i9(n,s,r),r.global)o?e[t]=n:a9(t,n);else{try{r.unsafe?e[t]&&(o=!0):delete e[t]}catch{}o?e[t]=n:s9.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},$2={},c9=Math.ceil,l9=Math.floor,u9=Math.trunc||function(t){var n=+t;return(n>0?l9:c9)(n)},d9=u9,Wi=function(e){var t=+e;return t!==t||t===0?0:d9(t)},h9=Wi,p9=Math.max,f9=Math.min,g9=function(e,t){var n=h9(e);return n<0?p9(n+t,0):f9(n,t)},m9=Wi,y9=Math.min,M2=function(e){var t=m9(e);return t>0?y9(t,9007199254740991):0},S9=M2,Mu=function(e){return S9(e.length)},v9=Wf,x9=g9,w9=Mu,AP=function(e){return function(t,n,r){var o=v9(t),s=w9(o);if(s===0)return!e&&-1;var i=x9(r,s),a;if(e&&n!==n){for(;s>i;)if(a=o[i++],a!==a)return!0}else for(;s>i;i++)if((e||i in o)&&o[i]===n)return e||i||0;return!e&&-1}},b9={includes:AP(!0),indexOf:AP(!1)},P9=Rt,Dm=qs,C9=Wf,I9=b9.indexOf,E9=bx,jP=P9([].push),A2=function(e,t){var n=C9(e),r=0,o=[],s;for(s in n)!Dm(E9,s)&&Dm(n,s)&&jP(o,s);for(;t.length>r;)Dm(n,s=t[r++])&&(~I9(o,s)||jP(o,s));return o},Cx=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],_9=A2,k9=Cx,T9=k9.concat("length","prototype");$2.f=Object.getOwnPropertyNames||function(t){return _9(t,T9)};var j2={};j2.f=Object.getOwnPropertySymbols;var $9=Gf,M9=Rt,A9=$2,j9=j2,O9=Ki,D9=M9([].concat),R9=$9("Reflect","ownKeys")||function(t){var n=A9.f(O9(t)),r=j9.f;return r?D9(n,r(t)):n},OP=qs,L9=R9,F9=fx,N9=bc,z9=function(e,t,n){for(var r=L9(t),o=N9.f,s=F9.f,i=0;i<r.length;i++){var a=r[i];!OP(e,a)&&!(n&&OP(n,a))&&o(e,a,s(t,a))}},B9=xn,U9=wn,H9=/#|\.prototype\./,Au=function(e,t){var n=W9[K9(e)];return n===V9?!0:n===G9?!1:U9(t)?B9(t):!!t},K9=Au.normalize=function(e){return String(e).replace(H9,".").toLowerCase()},W9=Au.data={},G9=Au.NATIVE="N",V9=Au.POLYFILL="P",Y9=Au,Ed=Dn,X9=fx.f,q9=xx,Z9=T2,Q9=yx,J9=z9,eU=Y9,Pc=function(e,t){var n=e.target,r=e.global,o=e.stat,s,i,a,c,l,u;if(r?i=Ed:o?i=Ed[n]||Q9(n,{}):i=Ed[n]&&Ed[n].prototype,i)for(a in t){if(l=t[a],e.dontCallGetSet?(u=X9(i,a),c=u&&u.value):c=i[a],s=eU(r?a:n+(o?".":"#")+a,e.forced),!s&&c!==void 0){if(typeof l==typeof c)continue;J9(l,c)}(e.sham||c&&c.sham)&&q9(l,"sham",!0),Z9(i,a,l,e)}},O2={},tU=A2,nU=Cx,rU=Object.keys||function(t){return tU(t,nU)},oU=Xs,sU=w2,iU=bc,aU=Ki,cU=Wf,lU=rU;O2.f=oU&&!sU?Object.defineProperties:function(t,n){aU(t);for(var r=cU(n),o=lU(n),s=o.length,i=0,a;s>i;)iU.f(t,a=o[i++],r[a]);return t};var uU=Gf,dU=uU("document","documentElement"),hU=Ki,pU=O2,DP=Cx,fU=bx,gU=dU,mU=v2,yU=I2,RP=">",LP="<",QS="prototype",JS="script",D2=yU("IE_PROTO"),Rm=function(){},R2=function(e){return LP+JS+RP+e+LP+"/"+JS+RP},FP=function(e){e.write(R2("")),e.close();var t=e.parentWindow.Object;return e=null,t},SU=function(){var e=mU("iframe"),t="java"+JS+":",n;return e.style.display="none",gU.appendChild(e),e.src=String(t),n=e.contentWindow.document,n.open(),n.write(R2("document.F=Object")),n.close(),n.F},_d,Sh=function(){try{_d=new ActiveXObject("htmlfile")}catch{}Sh=typeof document<"u"?document.domain&&_d?FP(_d):SU():FP(_d);for(var e=DP.length;e--;)delete Sh[QS][DP[e]];return Sh()};fU[D2]=!0;var L2=Object.create||function(t,n){var r;return t!==null?(Rm[QS]=hU(t),r=new Rm,Rm[QS]=null,r[D2]=t):r=Sh(),n===void 0?r:pU.f(r,n)},vU=ns,xU=L2,wU=bc.f,ev=vU("unscopables"),tv=Array.prototype;tv[ev]===void 0&&wU(tv,ev,{configurable:!0,value:xU(null)});var Ix=function(e){tv[ev][e]=!0},bU=Pc,PU=$u,CU=Mu,IU=Wi,EU=Ix;bU({target:"Array",proto:!0},{at:function(t){var n=PU(this),r=CU(n),o=IU(t),s=o>=0?o:r+o;return s<0||s>=r?void 0:n[s]}});EU("at");var _U=Dn,kU=Rt,ju=function(e,t){return kU(_U[e].prototype[t])},TU=ju;TU("Array","at");var $U=xc,F2=Array.isArray||function(t){return $U(t)==="Array"},MU=TypeError,AU=9007199254740991,jU=function(e){if(e>AU)throw MU("Maximum allowed index exceeded");return e},OU=xc,DU=Rt,RU=function(e){if(OU(e)==="Function")return DU(e)},NP=RU,LU=gx,FU=Hf,NU=NP(NP.bind),zU=function(e,t){return LU(e),t===void 0?e:FU?NU(e,t):function(){return e.apply(t,arguments)}},BU=F2,UU=Mu,HU=jU,KU=zU,N2=function(e,t,n,r,o,s,i,a){for(var c=o,l=0,u=i?KU(i,a):!1,d,p;l<r;)l in n&&(d=u?u(n[l],l,t):n[l],s>0&&BU(d)?(p=UU(d),c=N2(e,t,d,p,c,s-1)-1):(HU(c+1),e[c]=d),c++),l++;return c},z2=N2,WU=ns,GU=WU("toStringTag"),B2={};B2[GU]="z";var VU=String(B2)==="[object z]",YU=VU,XU=wn,vh=xc,qU=ns,ZU=qU("toStringTag"),QU=Object,JU=vh(function(){return arguments}())==="Arguments",eH=function(e,t){try{return e[t]}catch{}},U2=YU?vh:function(e){var t,n,r;return e===void 0?"Undefined":e===null?"Null":typeof(n=eH(t=QU(e),ZU))=="string"?n:JU?vh(t):(r=vh(t))==="Object"&&XU(t.callee)?"Arguments":r},tH=Rt,nH=xn,H2=wn,rH=U2,oH=Gf,sH=C2,K2=function(){},W2=oH("Reflect","construct"),Ex=/^\s*(?:class|function)\b/,iH=tH(Ex.exec),aH=!Ex.test(K2),qc=function(t){if(!H2(t))return!1;try{return W2(K2,[],t),!0}catch{return!1}},G2=function(t){if(!H2(t))return!1;switch(rH(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return aH||!!iH(Ex,sH(t))}catch{return!0}};G2.sham=!0;var cH=!W2||nH(function(){var e;return qc(qc.call)||!qc(Object)||!qc(function(){e=!0})||e})?G2:qc,zP=F2,lH=cH,uH=Hi,dH=ns,hH=dH("species"),BP=Array,pH=function(e){var t;return zP(e)&&(t=e.constructor,lH(t)&&(t===BP||zP(t.prototype))?t=void 0:uH(t)&&(t=t[hH],t===null&&(t=void 0))),t===void 0?BP:t},fH=pH,V2=function(e,t){return new(fH(e))(t===0?0:t)},gH=Pc,mH=z2,yH=gx,SH=$u,vH=Mu,xH=V2;gH({target:"Array",proto:!0},{flatMap:function(t){var n=SH(this),r=vH(n),o;return yH(t),o=xH(n,0),o.length=mH(o,n,n,r,0,1,t,arguments.length>1?arguments[1]:void 0),o}});var wH=Ix;wH("flatMap");var bH=ju;bH("Array","flatMap");var PH=Pc,CH=z2,IH=$u,EH=Mu,_H=Wi,kH=V2;PH({target:"Array",proto:!0},{flat:function(){var t=arguments.length?arguments[0]:void 0,n=IH(this),r=EH(n),o=kH(n,0);return o.length=CH(o,n,n,r,0,t===void 0?1:_H(t)),o}});var TH=Ix;TH("flat");var $H=ju;$H("Array","flat");var MH=U2,AH=String,Ou=function(e){if(MH(e)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return AH(e)},jH=Pc,OH=Rt,DH=wc,RH=Wi,LH=Ou,FH=xn,NH=OH("".charAt),zH=FH(function(){return"𠮷".at(-2)!=="\uD842"});jH({target:"String",proto:!0,forced:zH},{at:function(t){var n=LH(DH(this)),r=n.length,o=RH(t),s=o>=0?o:r+o;return s<0||s>=r?void 0:NH(n,s)}});var BH=ju;BH("String","at");var UH=Ki,Y2=function(){var e=UH(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},_x=xn,HH=Dn,kx=HH.RegExp,Tx=_x(function(){var e=kx("a","y");return e.lastIndex=2,e.exec("abcd")!==null}),KH=Tx||_x(function(){return!kx("a","y").sticky}),WH=Tx||_x(function(){var e=kx("^r","gy");return e.lastIndex=2,e.exec("str")!==null}),GH={BROKEN_CARET:WH,MISSED_STICKY:KH,UNSUPPORTED_Y:Tx},VH=xn,YH=Dn,XH=YH.RegExp,qH=VH(function(){var e=XH(".","s");return!(e.dotAll&&e.test(`
|
|
91
|
-
`)&&e.flags==="s")}),ZH=xn,QH=Dn,JH=QH.RegExp,eK=ZH(function(){var e=JH("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),$a=ts,Vf=Rt,tK=Ou,nK=Y2,rK=GH,oK=vx,sK=L2,iK=_2.get,aK=qH,cK=eK,lK=oK("native-string-replace",String.prototype.replace),Jp=RegExp.prototype.exec,nv=Jp,uK=Vf("".charAt),dK=Vf("".indexOf),hK=Vf("".replace),Lm=Vf("".slice),rv=function(){var e=/a/,t=/b*/g;return $a(Jp,e,"a"),$a(Jp,t,"a"),e.lastIndex!==0||t.lastIndex!==0}(),X2=rK.BROKEN_CARET,ov=/()??/.exec("")[1]!==void 0,pK=rv||ov||X2||aK||cK;pK&&(nv=function(t){var n=this,r=iK(n),o=tK(t),s=r.raw,i,a,c,l,u,d,p;if(s)return s.lastIndex=n.lastIndex,i=$a(nv,s,o),n.lastIndex=s.lastIndex,i;var f=r.groups,y=X2&&n.sticky,g=$a(nK,n),w=n.source,S=0,v=o;if(y&&(g=hK(g,"y",""),dK(g,"g")===-1&&(g+="g"),v=Lm(o,n.lastIndex),n.lastIndex>0&&(!n.multiline||n.multiline&&uK(o,n.lastIndex-1)!==`
|
|
92
|
-
`)&&(w="(?: "+w+")",v=" "+v,S++),a=new RegExp("^(?:"+w+")",g)),ov&&(a=new RegExp("^"+w+"$(?!\\s)",g)),rv&&(c=n.lastIndex),l=$a(Jp,y?a:n,v),y?l?(l.input=Lm(l.input,S),l[0]=Lm(l[0],S),l.index=n.lastIndex,n.lastIndex+=l[0].length):n.lastIndex=0:rv&&l&&(n.lastIndex=n.global?l.index+l[0].length:c),ov&&l&&l.length>1&&$a(lK,l[0],a,function(){for(u=1;u<arguments.length-2;u++)arguments[u]===void 0&&(l[u]=void 0)}),l&&f)for(l.groups=d=sK(null),u=0;u<f.length;u++)p=f[u],d[p[0]]=l[p[1]];return l});var $x=nv,fK=Pc,UP=$x;fK({target:"RegExp",proto:!0,forced:/./.exec!==UP},{exec:UP});var gK=Hf,q2=Function.prototype,HP=q2.apply,KP=q2.call,mK=typeof Reflect=="object"&&Reflect.apply||(gK?KP.bind(HP):function(){return KP.apply(HP,arguments)}),WP=ts,GP=T2,yK=$x,VP=xn,Z2=ns,SK=xx,vK=Z2("species"),Fm=RegExp.prototype,xK=function(e,t,n,r){var o=Z2(e),s=!VP(function(){var l={};return l[o]=function(){return 7},""[e](l)!==7}),i=s&&!VP(function(){var l=!1,u=/a/;return e==="split"&&(u={},u.constructor={},u.constructor[vK]=function(){return u},u.flags="",u[o]=/./[o]),u.exec=function(){return l=!0,null},u[o](""),!l});if(!s||!i||n){var a=/./[o],c=t(o,""[e],function(l,u,d,p,f){var y=u.exec;return y===yK||y===Fm.exec?s&&!f?{done:!0,value:WP(a,u,d,p)}:{done:!0,value:WP(l,d,u,p)}:{done:!1}});GP(String.prototype,e,c[0]),GP(Fm,o,c[1])}r&&SK(Fm[o],"sham",!0)},Mx=Rt,wK=Wi,bK=Ou,PK=wc,CK=Mx("".charAt),YP=Mx("".charCodeAt),IK=Mx("".slice),XP=function(e){return function(t,n){var r=bK(PK(t)),o=wK(n),s=r.length,i,a;return o<0||o>=s?e?"":void 0:(i=YP(r,o),i<55296||i>56319||o+1===s||(a=YP(r,o+1))<56320||a>57343?e?CK(r,o):i:e?IK(r,o,o+2):(i-55296<<10)+(a-56320)+65536)}},EK={codeAt:XP(!1),charAt:XP(!0)},_K=EK.charAt,kK=function(e,t,n){return t+(n?_K(e,t).length:1)},Ax=Rt,TK=$u,$K=Math.floor,Nm=Ax("".charAt),MK=Ax("".replace),zm=Ax("".slice),AK=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,jK=/\$([$&'`]|\d{1,2})/g,Q2=function(e,t,n,r,o,s){var i=n+e.length,a=r.length,c=jK;return o!==void 0&&(o=TK(o),c=AK),MK(s,c,function(l,u){var d;switch(Nm(u,0)){case"$":return"$";case"&":return e;case"`":return zm(t,0,n);case"'":return zm(t,i);case"<":d=o[zm(u,1,-1)];break;default:var p=+u;if(p===0)return l;if(p>a){var f=$K(p/10);return f===0?l:f<=a?r[f-1]===void 0?Nm(u,1):r[f-1]+Nm(u,1):l}d=r[p-1]}return d===void 0?"":d})},qP=ts,OK=Ki,DK=wn,RK=xc,LK=$x,FK=TypeError,NK=function(e,t){var n=e.exec;if(DK(n)){var r=qP(n,e,t);return r!==null&&OK(r),r}if(RK(e)==="RegExp")return qP(LK,e,t);throw new FK("RegExp#exec called on incompatible receiver")},zK=mK,ZP=ts,Yf=Rt,BK=xK,UK=xn,HK=Ki,KK=wn,WK=Kf,GK=Wi,VK=M2,ra=Ou,YK=wc,XK=kK,qK=mx,ZK=Q2,QK=NK,JK=ns,sv=JK("replace"),eW=Math.max,tW=Math.min,nW=Yf([].concat),Bm=Yf([].push),QP=Yf("".indexOf),JP=Yf("".slice),rW=function(e){return e===void 0?e:String(e)},oW=function(){return"a".replace(/./,"$0")==="$0"}(),eC=function(){return/./[sv]?/./[sv]("a","$0")==="":!1}(),sW=!UK(function(){var e=/./;return e.exec=function(){var t=[];return t.groups={a:"7"},t},"".replace(e,"$<a>")!=="7"});BK("replace",function(e,t,n){var r=eC?"$":"$0";return[function(s,i){var a=YK(this),c=WK(s)?void 0:qK(s,sv);return c?ZP(c,s,a,i):ZP(t,ra(a),s,i)},function(o,s){var i=HK(this),a=ra(o);if(typeof s=="string"&&QP(s,r)===-1&&QP(s,"$<")===-1){var c=n(t,i,a,s);if(c.done)return c.value}var l=KK(s);l||(s=ra(s));var u=i.global,d;u&&(d=i.unicode,i.lastIndex=0);for(var p=[],f;f=QK(i,a),!(f===null||(Bm(p,f),!u));){var y=ra(f[0]);y===""&&(i.lastIndex=XK(a,VK(i.lastIndex),d))}for(var g="",w=0,S=0;S<p.length;S++){f=p[S];for(var v=ra(f[0]),P=eW(tW(GK(f.index),a.length),0),I=[],C,E=1;E<f.length;E++)Bm(I,rW(f[E]));var _=f.groups;if(l){var k=nW([v],I,P,a);_!==void 0&&Bm(k,_),C=ra(zK(s,void 0,k))}else C=ZK(v,a,P,I,_,s);P>=w&&(g+=JP(a,w,P)+C,w=P+v.length)}return g+JP(a,w)}]},!sW||!oW||eC);var iW=Hi,aW=xc,cW=ns,lW=cW("match"),uW=function(e){var t;return iW(e)&&((t=e[lW])!==void 0?!!t:aW(e)==="RegExp")},dW=ts,hW=qs,pW=d2,fW=Y2,tC=RegExp.prototype,gW=function(e){var t=e.flags;return t===void 0&&!("flags"in tC)&&!hW(e,"flags")&&pW(tC,e)?dW(fW,e):t},mW=Pc,yW=ts,jx=Rt,nC=wc,SW=wn,vW=Kf,xW=uW,Zc=Ou,wW=mx,bW=gW,PW=Q2,CW=ns,IW=CW("replace"),EW=TypeError,Um=jx("".indexOf);jx("".replace);var rC=jx("".slice),_W=Math.max;mW({target:"String",proto:!0},{replaceAll:function(t,n){var r=nC(this),o,s,i,a,c,l,u,d,p,f=0,y=0,g="";if(!vW(t)){if(o=xW(t),o&&(s=Zc(nC(bW(t))),!~Um(s,"g")))throw new EW("`.replaceAll` does not allow non-global regexes");if(i=wW(t,IW),i)return yW(i,t,r,n)}for(a=Zc(r),c=Zc(t),l=SW(n),l||(n=Zc(n)),u=c.length,d=_W(1,u),f=Um(a,c);f!==-1;)p=l?Zc(n(c,f,a)):PW(c,a,f,[],void 0,n),g+=rC(a,y,f)+p,y=f+u,f=f+d>a.length?-1:Um(a,c,f+d);return y<a.length&&(g+=rC(a,y)),g}});var kW=ju;kW("String","replaceAll");function TW(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 J2=()=>{const e=z();return K("threeStackableItems",()=>TW(e).length>2,[e])},e$=()=>{const e=z();return K("allow group",()=>{const t=e.getSelectedShapes();if(t.length<2)return!1;for(const n of t)if(e.isShapeOfType(n,"arrow")){const{start:r,end:o}=n.props;if(r.type==="binding"&&!t.some(s=>s.id===r.boundShapeId)||o.type==="binding"&&!t.some(s=>s.id===o.boundShapeId))return!1}return!0},[e])},t$=()=>{const e=z();return K("allowUngroup",()=>e.getSelectedShapeIds().some(t=>{var n;return((n=e.getShape(t))==null?void 0:n.type)==="group"}),[e])},$W=typeof window<"u"&&"navigator"in window&&!!navigator.clipboard&&!!navigator.clipboard.read;function MW(e,t){const n=z();return K("selectedShapes",()=>n.getSelectedShapes().length>=e,[n,e,t])}function bn(e,t){const n=z();return K("selectedShapes",()=>{const r=n.getSelectedShapes().filter(o=>!n.isShapeOrAncestorLocked(o)).length;return e===void 0?r:r>=e},[n])}function AW(){const e=z();return K("showAutoSizeToggle",()=>{const t=e.getSelectedShapes();return t.length===1&&e.isShapeOfType(t[0],"text")&&t[0].props.autoSize===!1},[e])}function n$(){const e=z();return K("hasLinkShapeSelected",()=>{const t=e.getOnlySelectedShape();return!!(t&&t.type!=="embed"&&"url"in t.props&&!t.isLocked)},[e])}function jW(){const e=z();return K("onlyFlippableShape",()=>{const t=e.getOnlySelectedShape();return t&&(e.isShapeOfType(t,"group")||e.isShapeOfType(t,"arrow")||e.isShapeOfType(t,"line")||e.isShapeOfType(t,"draw"))},[e])}function r$(){const e=z();return K("useCanRedo",()=>e.getCanRedo(),[e])}function o$(){const e=z();return K("useCanUndo",()=>e.getCanUndo(),[e])}function OW({children:e}){const t=z();return K("shouldDisplayHandles",()=>{if(t.isInAny("select.idle","select.pointing_handle","select.pointing_shape"))return!0;if(t.isInAny("select.editing_shape")){const r=t.getOnlySelectedShape();return r&&t.isShapeOfType(r,"note")}return!1},[t])?h.jsx("svg",{className:"tl-user-handles tl-overlays__item",children:e}):null}const{PI:DW}=Math,Ha=DW+1e-4;function s$(e,t={}){const{size:n=16,smoothing:r=.5}=t;if(e.length===0||n<=0)return{left:[],right:[]};const o=e[0],s=e[e.length-1],i=s.runningLength,a=Math.pow(n*r,2),c=[],l=[];let u=e[0].vector,d=e[0].point,p=d,f=d,y=p,g=!1,w;for(let S=0;S<e.length;S++){w=e[S];const{point:v,vector:P}=e[S],I=w.vector.dpr(u),C=(S<e.length-1?e[S+1]:e[S]).vector,E=S<e.length-1?C.dpr(w.vector):1,_=I<0&&!g,k=E!==null&&E<.2;if(_||k){if(E>-.62&&i-w.runningLength>w.radius){const T=u.clone().mul(w.radius);u.clone().cpr(C)<0?(f=b.Add(v,T),y=b.Sub(v,T)):(f=b.Sub(v,T),y=b.Add(v,T)),c.push(f),l.push(y)}else{const T=u.clone().mul(w.radius).per(),A=b.Sub(w.input,T);for(let B=1/13,L=0;L<1;L+=B)f=b.RotWith(A,w.input,Ha*L),c.push(f),y=b.RotWith(A,w.input,Ha+Ha*-L),l.push(y)}d=f,p=y,k&&(g=!0);continue}if(g=!1,w===o||w===s){const T=b.Per(P).mul(w.radius);c.push(b.Sub(v,T)),l.push(b.Add(v,T));continue}const $=b.Lrp(C,P,E).per().mul(w.radius);f=b.Sub(v,$),(S<=1||b.Dist2(d,f)>a)&&(c.push(f),d=f),y=b.Add(v,$),(S<=1||b.Dist2(p,y)>a)&&(l.push(y),p=y),u=P}return{left:c,right:l}}function Ox(e,t={}){const{size:n=16,start:r={},end:o={},last:s=!1}=t,{cap:i=!0}=r,{cap:a=!0}=o;if(e.length===0||n<=0)return[];const c=e[0],l=e[e.length-1],u=l.runningLength,d=r.taper===!1?0:r.taper===!0?Math.max(n,u):r.taper,p=o.taper===!1?0:o.taper===!0?Math.max(n,u):o.taper,{left:f,right:y}=s$(e,t),g=c.point,w=e.length>1?e[e.length-1].point:b.AddXY(c.point,1,1);if(e.length===1&&(!(d||p)||s)){const I=b.Add(g,b.Sub(g,w).uni().per().mul(-c.radius)),C=[];for(let E=1/13,_=E;_<=1;_+=E)C.push(b.RotWith(I,g,Ha*2*_));return C}const S=[];if(!(d||p&&e.length===1))if(i)for(let I=1/8,C=I;C<=1;C+=I){const E=b.RotWith(y[0],g,Ha*C);S.push(E)}else{const I=b.Sub(f[0],y[0]),C=b.Mul(I,.5),E=b.Mul(I,.51);S.push(b.Sub(g,C),b.Sub(g,E),b.Add(g,E),b.Add(g,C))}const v=[],P=l.vector.clone().per().neg();if(p||d&&e.length===1)v.push(w);else if(a){const I=b.Add(w,b.Mul(P,l.radius));for(let C=1/29,E=C;E<1;E+=C)v.push(b.RotWith(I,w,Ha*3*E))}else v.push(b.Add(w,b.Mul(P,l.radius)),b.Add(w,b.Mul(P,l.radius*.99)),b.Sub(w,b.Mul(P,l.radius*.99)),b.Sub(w,b.Mul(P,l.radius)));return f.concat(v,y.reverse(),S)}const RW=.025,LW=.01;function uo(e,t={}){var w;const{streamline:n=.5,size:r=16,simulatePressure:o=!1}=t;if(e.length===0)return[];const s=.15+(1-n)*.85;let i=e.map(b.From),a=0;if(!o){let S=i[0];for(;S&&!(S.z>=RW);)i.shift(),S=i[0]}if(!o){let S=i[i.length-1];for(;S&&!(S.z>=LW);)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 c=i[1];for(;c&&!(b.Dist2(c,i[0])>(r/3)**2);)i[0].z=Math.max(i[0].z,c.z),i.splice(1,1),c=i[1];const l=i.pop();for(c=i[i.length-1];c&&!(b.Dist2(c,l)>(r/3)**2);)i.pop(),c=i[i.length-1],a++;i.push(l);const u=t.last||!t.simulatePressure||i.length>1&&b.Dist2(i[i.length-1],i[i.length-2])<r**2||a>0;if(i.length===2&&t.simulatePressure){const S=i[1];i=i.slice(0,-1);for(let v=1;v<5;v++){const P=b.Lrp(i[0],S,v/4);P.z=(i[0].z+(S.z-i[0].z))*v/4,i.push(P)}}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 p=0,f=d[0],y,g;u&&n>0&&i.push(i[i.length-1].clone());for(let S=1,v=i.length;S<v;S++)y=!s||t.last&&S===v-1?i[S].clone():i[S].clone().lrp(f.point,1-s),!f.point.equals(y)&&(g=b.Dist(y,f.point),p+=g,!(S<4&&p<r)&&(f={input:i[S],point:y,pressure:o?.5:i[S].z,vector:b.Sub(f.point,y).uni(),distance:g,runningLength:p,radius:1},d.push(f)));if((w=d[1])!=null&&w.vector&&(d[0].vector=d[1].vector.clone()),p<1){const S=Math.max(.5,...d.map(v=>v.pressure));d.forEach(v=>v.pressure=S)}return d}const{min:ps}=Math,Hm=.275;function Xf(e,t){const{size:n=16,thinning:r=.5,simulatePressure:o=!0,easing:s=w=>w,start:i={},end:a={}}=t,{easing:c=sn.easeOutQuad}=i,{easing:l=sn.easeOutCubic}=a,u=e[e.length-1].runningLength;let d,p=e[0].pressure,f;if(!o&&u<n){const w=e.reduce((S,v)=>Math.max(S,v.pressure),.5);return e.forEach(S=>{S.pressure=w,S.radius=n*s(.5-r*(.5-S.pressure))}),e}else{let w;for(let S=0,v=e.length;S<v&&(f=e[S],!(f.runningLength>n*5));S++){const P=ps(1,f.distance/n);if(o){const I=ps(1,1-P);w=ps(1,p+(I-p)*(P*Hm))}else w=ps(1,p+(f.pressure-p)*.5);p=p+(w-p)*.5}for(let S=0;S<e.length;S++){if(f=e[S],r){let{pressure:v}=f;const P=ps(1,f.distance/n);if(o){const I=ps(1,1-P);v=ps(1,p+(I-p)*(P*Hm))}else v=ps(1,p+(v-p)*(P*Hm));f.radius=n*s(.5-r*(.5-v)),p=v}else f.radius=n/2;d===void 0&&(d=f.radius)}}const y=i.taper===!1?0:i.taper===!0?Math.max(n,u):i.taper,g=a.taper===!1?0:a.taper===!0?Math.max(n,u):a.taper;if(y||g)for(let w=0;w<e.length;w++){f=e[w];const{runningLength:S}=f,v=S<y?c(S/y):1,P=u-S<g?l((u-S)/g):1;f.radius=Math.max(.01,f.radius*Math.min(v,P))}return e}function FW(e,t={}){return Ox(Xf(uo(e,t),t),t)}function oC({scribble:e,zoom:t,color:n,opacity:r,className:o}){if(!e.points.length)return null;const s=FW(e.points,{size:e.size/t,start:{taper:e.taper,easing:sn.linear},last:e.state==="stopping",simulatePressure:!1,streamline:.32});let i;if(s.length<4){const a=e.size/t/2,{x:c,y:l}=e.points[e.points.length-1];i=`M ${c-a},${l} a ${a},${a} 0 1,0 ${a*2},0 a ${a},${a} 0 1,0 ${-a*2},0`}else i=c0(s);return h.jsx("svg",{className:o&&ue("tl-overlays__item",o),children:h.jsx("path",{className:"tl-scribble",d:i,fill:n??`var(--color-${e.color})`,opacity:r??e.opacity})})}const NW=({bounds:e,rotation:t})=>{const n=z();return K("should display",()=>n.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_shape","select.pointing_selection","text.resizing"),[n])?h.jsx(x_,{bounds:e,rotation:t}):null};function rs(){const e=z();return K("isReadonlyMode",()=>e.getInstanceState().isReadonly,[e])}function zW({size:e,width:t,height:n,hideAlternateHandles:r}){const o=j(e/3),s=o/2;return h.jsxs("svg",{className:"tl-overlays__item",children:[h.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
93
|
-
${j(0-s)},${j(e)}
|
|
94
|
-
${j(0-s)},${j(0-s)}
|
|
95
|
-
${j(e)},${j(0-s)}`,strokeWidth:o,"data-testid":"selection.crop.top_left","aria-label":"top_left handle"}),h.jsx("line",{className:ue("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(t/2-e),y1:j(0-s),x2:j(t/2+e),y2:j(0-s),strokeWidth:o,"data-testid":"selection.crop.top","aria-label":"top handle"}),h.jsx("polyline",{className:ue("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
96
|
-
${j(t-e)},${j(0-s)}
|
|
97
|
-
${j(t+s)},${j(0-s)}
|
|
98
|
-
${j(t+s)},${j(e)}`,strokeWidth:o,"data-testid":"selection.crop.top_right","aria-label":"top_right handle"}),h.jsx("line",{className:ue("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(t+s),y1:j(n/2-e),x2:j(t+s),y2:j(n/2+e),strokeWidth:o,"data-testid":"selection.crop.right","aria-label":"right handle"}),h.jsx("polyline",{className:"tl-corner-crop-handle",points:`
|
|
99
|
-
${j(t+s)},${j(n-e)}
|
|
100
|
-
${j(t+s)},${j(n+s)}
|
|
101
|
-
${j(t-e)},${j(n+s)}`,strokeWidth:o,"data-testid":"selection.crop.bottom_right","aria-label":"bottom_right handle"}),h.jsx("line",{className:ue("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(t/2-e),y1:j(n+s),x2:j(t/2+e),y2:j(n+s),strokeWidth:o,"data-testid":"selection.crop.bottom","aria-label":"bottom handle"}),h.jsx("polyline",{className:ue("tl-corner-crop-handle",{"tl-hidden":r}),points:`
|
|
102
|
-
${j(0+e)},${j(n+s)}
|
|
103
|
-
${j(0-s)},${j(n+s)}
|
|
104
|
-
${j(0-s)},${j(n-e)}`,strokeWidth:o,"data-testid":"selection.crop.bottom_left","aria-label":"bottom_left handle"}),h.jsx("line",{className:ue("tl-corner-crop-edge-handle",{"tl-hidden":r}),x1:j(0-s),y1:j(n/2-e),x2:j(0-s),y2:j(n/2+e),strokeWidth:o,"data-testid":"selection.crop.left","aria-label":"left handle"})]})}const BW=rr(function({bounds:t,rotation:n}){const r=z(),o=x.useRef(null),s=rs(),i=qr("top"),a=qr("right"),c=qr("bottom"),l=qr("left"),u=qr("top_left"),d=qr("top_right"),p=qr("bottom_right"),f=qr("bottom_left"),y=!r.getIsMenuOpen()&&r.getInstanceState().cursor.type==="default",g=r.getInstanceState().isCoarsePointer,w=r.getOnlySelectedShape(),S=w&&r.isShapeOrAncestorLocked(w),v=w?r.getShapeUtil(w).expandSelectionOutlinePx(w):0;if(fc(o,t==null?void 0:t.x,t==null?void 0:t.y,1,r.getSelectionRotation(),{x:-v,y:-v}),!t)return null;t=t.clone().expandBy(v).zeroFix();const P=r.getZoomLevel(),I=r.getInstanceState().isChangingStyle,C=t.width,E=t.height,_=8/P,k=C<_*2,$=E<_*2,T=C<_*4,A=E<_*4,B=C<_*5,L=E<_*5,R=g?1.75:1,N=6/P*R,X=(T?N/2:N)*(R*.75),q=(A?N/2:N)*(R*.75),H=(w?!r.getShapeUtil(w).hideSelectionBoundsFg(w):!0)&&!I;let U=H&&r.isInAny("select.idle","select.brushing","select.scribble_brushing","select.pointing_canvas","select.pointing_selection","select.pointing_shape","select.crop.idle","select.crop.pointing_crop","select.pointing_resize_handle","select.pointing_crop_handle")||H&&r.isIn("select.resizing")&&w&&r.isShapeOfType(w,"text");w&&U&&r.environment.isFirefox&&r.isShapeOfType(w,"embed")&&(U=!1);const W=r.isInAny("select.pointing_crop_handle","select.crop.idle","select.crop.pointing_crop")&&!I&&!s,Q=r.isInAny("select.idle","select.pointing_selection","select.pointing_shape","select.crop.idle")&&!I&&!s,le=!g&&!(k||$)&&(Q||W)&&(w?!r.getShapeUtil(w).hideRotateHandle(w):!0)&&!S,be=g&&(!T||!A)&&(Q||W)&&(w?!r.getShapeUtil(w).hideRotateHandle(w):!0)&&!S,Ae=Q&&(w?r.getShapeUtil(w).canResize(w)&&!r.getShapeUtil(w).hideResizeHandles(w):!0)&&!W&&!S,ae=k||$,je=k&&$,Fe=B||L,it=Ae||W,Ee=!le,gt=!Q||!be,We=!Q||!it,ar=!Q||!it||ae,Ln=!Q||!it||ae,Fn=!Q||!it||je&&!W;let Qe=!0,Lt=!0;if(W)Qe=Fe,Lt=Fe;else if(Ae){Qe=ae||je||g;const Tc=g&&w&&w.type==="text";Lt=Qe&&!Tc}const Po=Math.min(24/P,E-q*3),kc=Q&&g&&w&&r.isShapeOfType(w,"text")&&Po*P>=4;return h.jsx("svg",{className:"tl-overlays__item tl-selection__fg","data-testid":"selection-foreground",children:h.jsxs("g",{ref:o,children:[U&&h.jsx("rect",{className:"tl-selection__fg__outline",width:j(C),height:j(E)}),h.jsx(kd,{"data-testid":"selection.rotate.top-left",cx:0,cy:0,targetSize:N,corner:"top_left_rotate",cursor:y?Bn("nwse-rotate",n):void 0,isHidden:Ee}),h.jsx(kd,{"data-testid":"selection.rotate.top-right",cx:C+N*3,cy:0,targetSize:N,corner:"top_right_rotate",cursor:y?Bn("nesw-rotate",n):void 0,isHidden:Ee}),h.jsx(kd,{"data-testid":"selection.rotate.bottom-left",cx:0,cy:E+N*3,targetSize:N,corner:"bottom_left_rotate",cursor:y?Bn("swne-rotate",n):void 0,isHidden:Ee}),h.jsx(kd,{"data-testid":"selection.rotate.bottom-right",cx:C+N*3,cy:E+N*3,targetSize:N,corner:"bottom_right_rotate",cursor:y?Bn("senw-rotate",n):void 0,isHidden:Ee}),h.jsx(HW,{"data-testid":"selection.rotate.mobile",cx:T?-N*1.5:C/2,cy:T?E/2:-N*1.5,size:_,isHidden:gt}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":Qe}),"data-testid":"selection.resize.top","aria-label":"top target",pointerEvents:"all",x:0,y:j(0-(A?q*2:q)),width:j(C),height:j(Math.max(1,q*2)),style:y?{cursor:Bn("ns-resize",n)}:void 0,...i}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":Lt}),"data-testid":"selection.resize.right","aria-label":"right target",pointerEvents:"all",x:j(C-(T?0:X)),y:0,height:j(E),width:j(Math.max(1,X*2)),style:y?{cursor:Bn("ew-resize",n)}:void 0,...a}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":Qe}),"data-testid":"selection.resize.bottom","aria-label":"bottom target",pointerEvents:"all",x:0,y:j(E-(A?0:q)),width:j(C),height:j(Math.max(1,q*2)),style:y?{cursor:Bn("ns-resize",n)}:void 0,...c}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":Lt}),"data-testid":"selection.resize.left","aria-label":"left target",pointerEvents:"all",x:j(0-(T?X*2:X)),y:0,height:j(E),width:j(Math.max(1,X*2)),style:y?{cursor:Bn("ew-resize",n)}:void 0,...l}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":We}),"data-testid":"selection.target.top-left","aria-label":"top-left target",pointerEvents:"all",x:j(0-(T?X*2:X*1.5)),y:j(0-(A?q*2:q*1.5)),width:j(X*3),height:j(q*3),style:y?{cursor:Bn("nwse-resize",n)}:void 0,...u}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":ar}),"data-testid":"selection.target.top-right","aria-label":"top-right target",pointerEvents:"all",x:j(C-(T?0:X*1.5)),y:j(0-(A?q*2:q*1.5)),width:j(X*3),height:j(q*3),style:y?{cursor:Bn("nesw-resize",n)}:void 0,...d}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":Fn}),"data-testid":"selection.target.bottom-right","aria-label":"bottom-right target",pointerEvents:"all",x:j(C-(T?X:X*1.5)),y:j(E-(A?q:q*1.5)),width:j(X*3),height:j(q*3),style:y?{cursor:Bn("nwse-resize",n)}:void 0,...p}),h.jsx("rect",{className:ue("tl-transparent",{"tl-hidden":Ln}),"data-testid":"selection.target.bottom-left","aria-label":"bottom-left target",pointerEvents:"all",x:j(0-(T?X*3:X*1.5)),y:j(E-(A?0:q*1.5)),width:j(X*3),height:j(q*3),style:y?{cursor:Bn("nesw-resize",n)}:void 0,...f}),Ae&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{"data-testid":"selection.resize.top-left",className:ue("tl-corner-handle",{"tl-hidden":We}),"aria-label":"top_left handle",x:j(0-_/2),y:j(0-_/2),width:j(_),height:j(_)}),h.jsx("rect",{"data-testid":"selection.resize.top-right",className:ue("tl-corner-handle",{"tl-hidden":ar}),"aria-label":"top_right handle",x:j(C-_/2),y:j(0-_/2),width:j(_),height:j(_)}),h.jsx("rect",{"data-testid":"selection.resize.bottom-right",className:ue("tl-corner-handle",{"tl-hidden":Fn}),"aria-label":"bottom_right handle",x:j(C-_/2),y:j(E-_/2),width:j(_),height:j(_)}),h.jsx("rect",{"data-testid":"selection.resize.bottom-left",className:ue("tl-corner-handle",{"tl-hidden":Ln}),"aria-label":"bottom_left handle",x:j(0-_/2),y:j(E-_/2),width:j(_),height:j(_)})]}),kc&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{"data-testid":"selection.text-resize.left.handle",className:"tl-text-handle","aria-label":"bottom_left handle",x:j(0-_/4),y:j(E/2-Po/2),rx:_/4,width:j(_/2),height:j(Po)}),h.jsx("rect",{"data-testid":"selection.text-resize.right.handle",className:"tl-text-handle","aria-label":"bottom_left handle",rx:_/4,x:j(C-_/4),y:j(E/2-Po/2),width:j(_/2),height:j(Po)})]}),W&&h.jsx(zW,{size:_,width:C,height:E,hideAlternateHandles:Fe})]})})}),kd=function({cx:t,cy:n,targetSize:r,corner:o,cursor:s,isHidden:i,"data-testid":a}){const c=qr(o);return h.jsx("rect",{className:ue("tl-transparent","tl-rotate-corner",{"tl-hidden":i}),"data-testid":a,"aria-label":`${o} target`,pointerEvents:"all",x:j(t-r*3),y:j(n-r*3),width:j(Math.max(1,r*3)),height:j(Math.max(1,r*3)),cursor:s,...c})},UW=Math.sqrt(Math.PI),HW=function({cx:t,cy:n,size:r,isHidden:o,"data-testid":s}){const i=qr("mobile_rotate"),a=z(),c=K("zoom level",()=>a.getZoomLevel(),[a]),l=Math.max(14*(1/c),20/Math.max(1,c));return h.jsxs("g",{children:[h.jsx("circle",{"data-testid":s,pointerEvents:"all",className:ue("tl-transparent","tl-mobile-rotate__bg",{"tl-hidden":o}),cx:t,cy:n,r:l,...i}),h.jsx("circle",{className:ue("tl-mobile-rotate__fg",{"tl-hidden":o}),cx:t,cy:n,r:r/UW})]})},Gt={lineHeight:1.35,fontWeight:"normal",fontVariant:"normal",fontStyle:"normal",padding:"0px"},Ot={s:2,m:3.5,l:5,xl:10},nc={s:18,m:24,l:36,xl:44},No={s:18,m:22,l:26,xl:32},di={s:18,m:20,l:24,xl:28},ao={draw:"var(--tl-font-draw)",sans:"var(--tl-font-sans)",serif:"var(--tl-font-serif)",mono:"var(--tl-font-mono)"},KW=20,WW=4.25,Ar=16;/*!
|
|
105
|
-
* canvas-size
|
|
106
|
-
* v1.2.6
|
|
107
|
-
* https://github.com/jhildenbiddle/canvas-size
|
|
108
|
-
* (c) 2015-2023 John Hildenbiddle <http://hildenbiddle.com>
|
|
109
|
-
* MIT license
|
|
110
|
-
*/function GW(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,s,i,a=[],c=!0,l=!1;try{if(s=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(u){l=!0,o=u}finally{try{if(!c&&n.return!=null&&(i=n.return(),Object(i)!==i))return}finally{if(l)throw o}}return a}}function sC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function Un(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?sC(Object(n),!0).forEach(function(r){VW(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sC(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function VW(e,t,n){return t=nG(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function YW(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function XW(e,t){if(e==null)return{};var n=YW(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function iC(e,t){return ZW(e)||GW(e,t)||i$(e,t)||eG()}function Td(e){return qW(e)||QW(e)||i$(e)||JW()}function qW(e){if(Array.isArray(e))return iv(e)}function ZW(e){if(Array.isArray(e))return e}function QW(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function i$(e,t){if(e){if(typeof e=="string")return iv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return iv(e,t)}}function iv(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function JW(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
111
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function eG(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
112
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tG(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function nG(e){var t=tG(e,"string");return typeof t=="symbol"?t:String(t)}function kl(e){var t=e.sizes.shift(),n=Math.max(Math.ceil(t[0]),1),r=Math.max(Math.ceil(t[1]),1),o=[n-1,r-1,1,1],s=Date.now(),i=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,a,c;i?(a=new OffscreenCanvas(1,1),c=new OffscreenCanvas(n,r)):(a=document.createElement("canvas"),a.width=1,a.height=1,c=document.createElement("canvas"),c.width=n,c.height=r);var l=a.getContext("2d"),u=c.getContext("2d");u&&(u.fillRect.apply(u,o),l.drawImage(c,n-1,r-1,1,1,0,0,1,1));var d=l&&l.getImageData(0,0,1,1).data[3]!==0,p=Date.now()-s;return[a,c].forEach(function(f){f.height=0,f.width=0}),i?(postMessage({width:n,height:r,benchmark:p,isTestPass:d}),!d&&e.sizes.length&&kl(e)):d?e.onSuccess(n,r,p):(e.onError(n,r,p),e.sizes.length&&kl(e)),d}var Km={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]},rG=["onError","onSuccess"],Ma={max:null,min:1,sizes:[],step:1024,usePromise:!1,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},Qc={};function Wm(e){var t=e.width===e.height,n=e.height===1,r=e.width===1,o=[];if(!e.width||!e.height)e.sizes.forEach(function(u){var d=t||n?u:1,p=t||r?u:1;o.push([d,p])});else for(var s=e.min||Ma.min,i=e.step||Ma.step,a=Math.max(e.width,e.height);a>=s;){var c=t||n?a:1,l=t||r?a:1;o.push([c,l]),a-=i}return o}function $d(e){var t=window&&"HTMLCanvasElement"in window,n=window&&"OffscreenCanvas"in window,r=Date.now(),o=e.onError,s=e.onSuccess,i=XW(e,rG),a=null;if(!t)return!1;if(e.useWorker&&n){var c=`
|
|
113
|
-
var canvasTest = `.concat(kl.toString(),`;
|
|
114
|
-
onmessage = function(e) {
|
|
115
|
-
canvasTest(e.data);
|
|
116
|
-
};
|
|
117
|
-
`),l=new Blob([c],{type:"application/javascript"}),u=URL.createObjectURL(l);a=new Worker(u),URL.revokeObjectURL(u),a.onmessage=function(d){var p=d.data,f=p.width,y=p.height,g=p.benchmark,w=p.isTestPass;w?(Qc[r].onSuccess(f,y,g),delete Qc[r]):Qc[r].onError(f,y,g)}}if(e.usePromise)return new Promise(function(d,p){var f=Un(Un({},e),{},{onError:function(S,v,P){var I;if(e.sizes.length===0)I=!0;else{var C=e.sizes.slice(-1),E=iC(C,1),_=iC(E[0],2),k=_[0],$=_[1];I=S===k&&v===$}o(S,v,P),I&&p({width:S,height:v,benchmark:P})},onSuccess:function(S,v,P){s(S,v,P),d({width:S,height:v,benchmark:P})}});if(a){var y=f.onError,g=f.onSuccess;Qc[r]={onError:y,onSuccess:g},a.postMessage(i)}else kl(f)});if(a)Qc[r]={onError:o,onSuccess:s},a.postMessage(i);else return kl(e)}var Gm={maxArea:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Wm({width:t.max,height:t.max,min:t.min,step:t.step,sizes:Td(Km.area)}),r=Un(Un(Un({},Ma),t),{},{sizes:n});return $d(r)},maxHeight:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Wm({width:1,height:t.max,min:t.min,step:t.step,sizes:Td(Km.height)}),r=Un(Un(Un({},Ma),t),{},{sizes:n});return $d(r)},maxWidth:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Wm({width:t.max,height:1,min:t.min,step:t.step,sizes:Td(Km.width)}),r=Un(Un(Un({},Ma),t),{},{sizes:n});return $d(r)},test:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Un(Un({},Ma),t);return n.sizes=Td(n.sizes),n.width&&n.height&&(n.sizes=[[n.width,n.height]]),$d(n)}};let Vm=null;function oG(){return Vm||(Vm=sG()),Vm}async function sG(){const e=await Gm.maxWidth({usePromise:!0}),t=await Gm.maxHeight({usePromise:!0}),n=await Gm.maxArea({usePromise:!0});return{maxWidth:e.width,maxHeight:t.height,maxArea:n.width*n.height}}const aC=8192,iG=4096*4096;async function a$(e,t){if(e<=aC&&t<=aC&&e*t<=iG)return[e,t];const{maxWidth:n,maxHeight:r,maxArea:o}=await oG(),s=e/t;if(e>n&&(e=n,t=e/s),t>r&&(t=r,e=t*s),e*t>o){const i=Math.sqrt(o/(e*t));e*=i,t*=i}return[e,t]}/*!
|
|
118
|
-
* MIT License
|
|
119
|
-
* Modified code originally from <https://github.com/qzb/is-animated>
|
|
120
|
-
* Copyright (c) 2016 Józef Sokołowski <j.k.sokolowski@gmail.com>
|
|
121
|
-
*/function cC(e,t){let n=0;for(;e[t+n];)n+=e[t+n]+1;return n+1}function aG(e){return new TextDecoder("ascii").decode(e.slice(0,3))==="GIF"}function cG(e){const t=new Uint8Array(e);let n,r,o=0,s=0;if(!aG(e))return!1;for(n=t[10]&128,r=t[10]&7,o+=6,o+=7,o+=n?3*Math.pow(2,r+1):0;s<2&&o<t.length;)switch(t[o]){case 44:s+=1,n=t[o+9]&128,r=t[o+9]&7,o+=10,o+=n?3*Math.pow(2,r+1):0,o+=cC(t,o+1)+1;break;case 33:o+=2,o+=cC(t,o);break;case 59:o=t.length;break;default:o=t.length;break}return s>1}function lG(e,t){const n=e.w/t.w,r=e.h/t.h;return n<=1&&r<=1?e:n>r?{w:e.w/n,h:e.h/n}:{w:e.w/r,h:e.h/r}}async function uG(e,t,n,r={}){const o=await Ao.usingObjectURL(e,Ao.loadImage),{type:s=e.type,quality:i=.92}=r,[a,c]=await a$(Math.min(t*2,o.naturalWidth),Math.min(n*2,o.naturalHeight)),l=document.createElement("canvas");l.width=a,l.height=c;const u=hi(l.getContext("2d",{willReadFrequently:!0}),"Could not get canvas context");return u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(o,0,0,a,c),new Promise((d,p)=>{l.toBlob(f=>{f?d(f):p(new Error("Could not resize image"))},s,i)})}async function dG(e){return cG(await e.arrayBuffer())}function hG(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function pG(e){const t=new URL(e).host.replace("www.","");for(const n of Su)if(c$(n.hostnames,t)){const r=n.fromEmbedUrl(e);if(r)return{definition:n,url:r,embedUrl:e}}}const fG=e=>e.split("*").map(t=>hG(t)).join(".+"),c$=(e,t)=>!!e.find(n=>{const r=new RegExp(fG(n));return t.match(r)});function gG(e){const t=new URL(e).host.replace("www.","");for(const n of Su)if(c$(n.hostnames,t)){const r=n.toEmbedUrl(e);if(r)return{definition:n,embedUrl:r,url:e}}}function l$(e){return gG(e)??pG(e)}function Es(e){try{return l$(e)}catch(t){console.error(t)}}/*!
|
|
122
|
-
* MIT License
|
|
123
|
-
* Adapted (mostly copied) the work of https://github.com/fregante/text-field-edit
|
|
124
|
-
* Copyright (c) Federico Brigante <opensource@bfred.it> (bfred.it)
|
|
125
|
-
*/const Aa=" ",un=class un{static insertTextFirefox(t,n){t.setRangeText(n,t.selectionStart||0,t.selectionEnd||0,"end"),t.dispatchEvent(new InputEvent("input",{data:n,inputType:"insertText",isComposing:!1}))}static insert(t,n){const r=t.ownerDocument,o=r.activeElement;o!==t&&t.focus(),r.execCommand("insertText",!1,n)||un.insertTextFirefox(t,n),o===r.body?t.blur():o instanceof HTMLElement&&o!==t&&o.focus()}static set(t,n){t.select(),un.insert(t,n)}static getSelection(t){const{selectionStart:n,selectionEnd:r}=t;return t.value.slice(n||void 0,r||void 0)}static wrapSelection(t,n,r){const{selectionStart:o,selectionEnd:s}=t,i=un.getSelection(t);un.insert(t,n+i+(r??n)),t.selectionStart=(o||0)+n.length,t.selectionEnd=(s||0)+n.length}static replace(t,n,r){let o=0;t.value.replace(n,(...s)=>{const i=o+s[s.length-2],a=s[0].length;t.selectionStart=i,t.selectionEnd=i+a;const c=typeof r=="string"?r:r(...s);return un.insert(t,c),t.selectionStart=i,o+=c.length-a,c})}static findLineEnd(t,n){const r=t.lastIndexOf(`
|
|
126
|
-
`,n-1)+1;return t.charAt(r)!==" "?n:r+1}static indent(t){var a;const{selectionStart:n,selectionEnd:r,value:o}=t,s=o.slice(n,r),i=(a=/\n/g.exec(s))==null?void 0:a.length;if(i&&i>0){const c=o.lastIndexOf(`
|
|
127
|
-
`,n-1)+1,l=t.value.slice(c,r-1),u=l.replace(/^|\n/g,`$&${Aa}`),d=u.length-l.length;t.setSelectionRange(c,r-1),un.insert(t,u),t.setSelectionRange(n+1,r+d)}else un.insert(t,Aa)}static unindent(t){const{selectionStart:n,selectionEnd:r,value:o}=t,s=o.lastIndexOf(`
|
|
128
|
-
`,n-1)+1,i=un.findLineEnd(o,r),a=t.value.slice(s,i),c=a.replace(/(^|\n)(\t| {1,2})/g,"$1"),l=a.length-c.length;t.setSelectionRange(s,i),un.insert(t,c);const u=/\t| {1,2}/.exec(o.slice(s,n)),d=u?u[0].length:0,p=n-d;t.setSelectionRange(n-d,Math.max(p,r-l))}static indentCE(t){var c;const n=window.getSelection(),r=t.innerText,o=Md(t)??0,s=Md(t)??0,i=r.slice(o,s),a=(c=/\n/g.exec(i))==null?void 0:c.length;if(a&&a>0){const l=r.lastIndexOf(`
|
|
129
|
-
`,o-1)+1,u=r.slice(l,s-1),p=u.replace(/^|\n/g,`$&${Aa}`).length-u.length;n&&n.setBaseAndExtent(t,o+1,t,s+p)}else{const l=window.getSelection();t.innerText=r.slice(0,o)+Aa+r.slice(o),l==null||l.setBaseAndExtent(t,o+1,t,o+2)}}static unindentCE(t){const n=window.getSelection(),r=t.innerText,o=Md(t)??0,s=Md(t)??0,i=r.lastIndexOf(`
|
|
130
|
-
`,o-1)+1,a=un.findLineEnd(r,s),c=r.slice(i,a),l=c.replace(/(^|\n)(\t| {1,2})/g,"$1"),u=c.length-l.length;if(n){n.setBaseAndExtent(t,i,t,a);const d=/\t| {1,2}/.exec(r.slice(i,o)),p=d?d[0].length:0,f=o-p;n.setBaseAndExtent(t,o-p,t,Math.max(f,s-u))}}static normalizeText(t){return t.replace(un.fixNewLines,`
|
|
131
|
-
`)}static normalizeTextForDom(t){return t.replace(un.fixNewLines,`
|
|
132
|
-
`).split(`
|
|
133
|
-
`).map(n=>n||" ").join(`
|
|
134
|
-
`)}};m(un,"fixNewLines",/\r?\n|\r/g);let rc=un;function Md(e){if(typeof window.getSelection>"u")return;const t=window.getSelection();if(!t)return;let n=0;if(t.rangeCount!==0){const r=t.getRangeAt(0),o=r.cloneRange();o.selectNodeContents(e),o.setEnd(r.endContainer,r.endOffset),n=o.toString().length}return n}const mG=/[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;function u$(e){return mG.test(e)}function yG(e){return e.replace(/\t/g,Aa)}function SG(e){const t=e.split(`
|
|
135
|
-
`);for(;t[0]&&t[0].trim().length===0;)t.shift();let n=1/0;for(const r of t)if(r.trim().length>0){const o=r.length-r.trimStart().length;n=Math.min(n,o)}return t.map(r=>r.slice(n)).join(`
|
|
136
|
-
`)}function vG(e){return e.replace(/[ \t]+$/gm,"").replace(/\n+$/,"")}function xG(e){return vG(SG(yG(e)))}const Tl=(e,t)=>e.length<=t?e:e.substring(0,t-3)+"...";function wG(e,{maxImageDimension:t,maxAssetSize:n,acceptedImageMimeTypes:r,acceptedVideoMimeTypes:o},{toasts:s,msg:i}){e.registerExternalAssetHandler("file",async({file:a})=>{const c=a.name;let l=a;const u=r.includes(l.type),d=o.includes(l.type);lt(u||d,`File type not allowed: ${l.type}`),lt(l.size<=n,`File size too big: ${(l.size/1024).toFixed()}kb > ${(n/1024).toFixed()}kb`),l.type==="video/quicktime"&&(l=new Blob([l],{type:"video/mp4"}));let p=u?await Ao.getImageSize(l):await Ao.getVideoSize(l);const f=l.type==="image/gif"?await dG(l):d,y=await BD(await l.arrayBuffer());if(isFinite(t)){const S=lG(p,{w:t,h:t});p!==S&&(l.type==="image/jpeg"||l.type==="image/png")&&(p=S)}(l.type==="image/jpeg"||l.type==="image/png")&&(l=await uG(l,p.w,p.h,{type:l.type,quality:.92}));const g=pi.createId(y);return pi.create({id:g,type:u?"image":"video",typeName:"asset",props:{name:c,src:await Oa.blobToDataUrl(l),w:p.w,h:p.h,mimeType:l.type,isAnimated:f}})}),e.registerExternalAssetHandler("url",async({url:a})=>{var l,u,d;let c;try{const f=await(await fetch(a,{method:"GET",mode:"no-cors"})).text(),y=new DOMParser().parseFromString(f,"text/html");c={image:((l=y.head.querySelector('meta[property="og:image"]'))==null?void 0:l.getAttribute("content"))??"",title:((u=y.head.querySelector('meta[property="og:title"]'))==null?void 0:u.getAttribute("content"))??Tl(a,32),description:((d=y.head.querySelector('meta[property="og:description"]'))==null?void 0:d.getAttribute("content"))??""}}catch(p){console.error(p),s.addToast({title:i("assets.url.failed"),severity:"error"}),c={image:"",title:Tl(a,32),description:""}}return{id:pi.createId(Dy(a)),typeName:"asset",type:"bookmark",props:{src:a,description:c.description,image:c.image,title:c.title},meta:{}}}),e.registerExternalContentHandler("svg-text",async({point:a,text:c})=>{const l=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageBounds().center),u=new DOMParser().parseFromString(c,"image/svg+xml").querySelector("svg");if(!u)throw new Error("No <svg/> element present");let d=parseFloat(u.getAttribute("width")||"0"),p=parseFloat(u.getAttribute("height")||"0");if(!(d&&p)){document.body.appendChild(u);const y=u.getBoundingClientRect();document.body.removeChild(u),d=y.width,p=y.height}const f=await e.getAssetForExternalContent({type:"file",file:new File([c],"asset.svg",{type:"image/svg+xml"})});if(!f)throw Error("Could not create an asset");lC(e,[f],l)}),e.registerExternalContentHandler("embed",({point:a,url:c,embed:l})=>{const u=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageBounds().center),{width:d,height:p}=l,f=He(),y={id:f,type:"embed",x:u.x-(d||450)/2,y:u.y-(p||450)/2,props:{w:d,h:p,url:c}};e.createShapes([y]).select(f)}),e.registerExternalContentHandler("files",async({point:a,files:c})=>{const l=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageBounds().center),u=new b(l.x,l.y),d=[];await Promise.all(c.map(async(p,f)=>{if(p.size>n)return console.warn(`File size too big: ${(p.size/1024).toFixed()}kb > ${(n/1024).toFixed()}kb`),null;if(!p.type)throw new Error("No mime type");if(!r.concat(o).includes(p.type))return console.warn(`${p.name} not loaded - Extension not allowed.`),null;try{const y=await e.getAssetForExternalContent({type:"file",file:p});if(!y)throw Error("Could not create an asset");d[f]=y}catch(y){return s.addToast({title:i("assets.files.upload-failed"),severity:"error"}),console.error(y),null}})),lC(e,fe(d),u)}),e.registerExternalContentHandler("text",async({point:a,text:c})=>{const l=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageBounds().center),u=e.getShapeUtil("text").getDefaultProps(),d=xG(c),p=e.getOnlySelectedShape();if(p&&"text"in p.props){e.updateShapes([{id:p.id,type:p.type,props:{text:d}}]);return}let f,y,g,w="middle";const S=d.split(`
|
|
137
|
-
`).length>1,v=u$(d);S&&(w=S?v?"end":"start":"middle");const P=e.textMeasure.measureText(d,{...Gt,fontFamily:ao[u.font],fontSize:nc[u.size],maxWidth:null}),I=Math.min(S?e.getViewportPageBounds().width*.9:920,Math.max(200,e.getViewportPageBounds().width*.9));if(P.w>I){const C=e.textMeasure.measureText(d,{...Gt,fontFamily:ao[u.font],fontSize:nc[u.size],maxWidth:I});f=C.w,y=C.h,g=!1,w=v?"end":"start"}else f=P.w,y=P.h,g=!0;l.y-y/2<e.getViewportPageBounds().minY+40&&(l.y=e.getViewportPageBounds().minY+40+y/2),e.createShapes([{id:He(),type:"text",x:l.x-f/2,y:l.y-y/2,props:{text:d,textAlign:w,autoSize:g,w:f}}])}),e.registerExternalContentHandler("url",async({point:a,url:c})=>{const l=Es(c);if(l)return e.putExternalContent({type:"embed",url:l.url,point:a,embed:l.definition});const u=a??(e.inputs.shiftKey?e.inputs.currentPagePoint:e.getViewportPageBounds().center),d=pi.createId(Dy(c)),p=bG(e,c,u);let f=e.getAsset(d),y=!1;if(!f){y=!0;try{const g=await e.getAssetForExternalContent({type:"url",url:c});if(!g)throw Error("Could not create an asset");f=g}catch{s.addToast({title:i("assets.url.failed"),severity:"error"});return}}e.batch(()=>{y&&e.createAssets([f]),e.updateShapes([{id:p.id,type:p.type,props:{assetId:f.id}}])})})}async function lC(e,t,n){if(!t.length)return[];const r=b.From(n),o=[];for(const s of t)switch(s.type){case"bookmark":{o.push({id:He(),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:He(),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:He(),type:"video",x:r.x-s.props.w/2,y:r.y-s.props.h/2,opacity:1,props:{assetId:s.id,w:s.props.w,h:s.props.h}}),r.x+=s.props.w}return e.batch(()=>{const s=t.filter(i=>!e.getAsset(i.id));s.length&&e.createAssets(s),e.createShapes(o).select(...o.map(i=>i.id)),d$(e,n)}),o.map(s=>s.id)}function d$(e,t){const n=e.getViewportPageBounds();let r=e.getSelectionPageBounds();if(r){const o=r.center.sub(t);e.updateShapes(e.getSelectedShapes().map(s=>{const i=e.getShapeParentTransform(s).decompose().rotation,a=b.Rot(o,-i);return{id:s.id,type:s.type,x:s.x-a.x,y:s.y-a.y}}))}r=e.getSelectionPageBounds(),r&&!n.contains(r)&&e.zoomToSelection()}function bG(e,t,n){const r={id:He(),type:"bookmark",x:n.x-150,y:n.y-160,opacity:1,props:{assetId:null,url:t}};return e.batch(()=>{e.createShapes([r]).select(r.id),d$(e,n)}),e.getShape(r.id)}var my;let PG=(my=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")});m(this,"onKeyUp",n=>{var r;if(n.key==="Enter"){if(this.editor.getInstanceState().isReadonly)return null;const o=this.editor.getOnlySelectedShape();o&&this.editor.getShapeUtil(o).canEdit(o)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(o.id),(r=this.editor.root.getCurrent())==null||r.transition("editing_shape",{...n,target:"shape",shape:o}))}})}},m(my,"id","idle"),my);var yy;let CG=(yy=class extends se{constructor(){super(...arguments);m(this,"shape");m(this,"markId","");m(this,"onEnter",()=>{this.didTimeout=!1;const n=this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{filter:r=>!r.isLocked&&this.editor.getShapeUtil(r).canBind(r),margin:0,hitInside:!0,renderingOnly:!0});n?this.editor.setHintingShapes([n.id]):this.createArrowShape(),this.startPreciseTimeout()});m(this,"onExit",()=>{this.shape=void 0,this.editor.setHintingShapes([]),this.clearPreciseTimeout()});m(this,"onPointerMove",()=>{if(this.editor.inputs.isDragging){if(this.shape||this.createArrowShape(),!this.shape)throw Error("expected shape");this.updateArrowShapeEndHandle(),this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,handle:this.editor.getShapeHandles(this.shape).find(n=>n.id==="end"),isCreating:!0,onInteractionEnd:"arrow"})}});m(this,"onPointerUp",()=>{this.cancel()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()});m(this,"preciseTimeout",-1);m(this,"didTimeout",!1)}cancel(){this.shape&&this.editor.bailToMark(this.markId),this.editor.setHintingShapes([]),this.parent.transition("idle")}createArrowShape(){var u,d;const{originPagePoint:n}=this.editor.inputs,r=He();this.markId=`creating:${r}`,this.editor.mark(this.markId),this.editor.createShapes([{id:r,type:"arrow",x:n.x,y:n.y}]);const o=this.editor.getShape(r);if(!o)throw Error("expected shape");const s=this.editor.getShapeHandles(o);if(!s)throw Error("expected handles for arrow");const i=this.editor.getShapeUtil("arrow"),a=this.shape,c=s.find(p=>p.id==="start"),l=(u=i.onHandleDrag)==null?void 0:u.call(i,o,{handle:{...c,x:0,y:0},isPrecise:!0,initial:a});if(l){const p=(d=l.props)==null?void 0:d.start;(p==null?void 0:p.type)==="binding"&&this.editor.setHintingShapes([p.boundShapeId]),this.editor.updateShapes([l])}this.shape=this.editor.getShape(r),this.editor.select(r)}updateArrowShapeEndHandle(){var s,i,a;const n=this.shape;if(!n)throw Error("expected shape");const r=this.editor.getShapeHandles(n);if(!r)throw Error("expected handles for arrow");const o={...n,props:{...n.props,end:{...n.props.end,x:0,y:0}}};{const c=this.editor.getShapeUtil("arrow"),l=this.shape,u=this.editor.getPointInShapeSpace(n,this.editor.inputs.currentPagePoint),d=r.find(f=>f.id==="end"),p=(s=c.onHandleDrag)==null?void 0:s.call(c,o,{handle:{...d,x:u.x,y:u.y},isPrecise:!1,initial:l});if(p){const f=(i=p.props)==null?void 0:i.end;(f==null?void 0:f.type)==="binding"&&this.editor.setHintingShapes([f.boundShapeId]),this.editor.updateShapes([p])}}{const c=this.editor.getShapeUtil("arrow"),l=this.shape,u=r.find(p=>p.id==="start"),d=(a=c.onHandleDrag)==null?void 0:a.call(c,o,{handle:{...u,x:0,y:0},isPrecise:this.didTimeout,initial:l});d&&this.editor.updateShapes([d])}this.shape=this.editor.getShape(n.id)}startPreciseTimeout(){this.preciseTimeout=window.setTimeout(()=>{this.getIsActive()&&(this.didTimeout=!0)},320)}clearPreciseTimeout(){clearTimeout(this.preciseTimeout)}},m(yy,"id","pointing"),yy);class xh extends se{constructor(){super(...arguments);m(this,"shapeType","arrow")}}m(xh,"id","arrow"),m(xh,"initial","idle"),m(xh,"children",()=>[PG,CG]);class Dx extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"initialShape");m(this,"shapeType",this.parent.id==="highlight"?"highlight":"draw");m(this,"util",this.editor.getShapeUtil(this.shapeType));m(this,"isPen",!1);m(this,"isPenOrStylus",!1);m(this,"segmentMode","free");m(this,"didJustShiftClickToExtendPreviousShapeLine",!1);m(this,"pagePointWhereCurrentSegmentChanged",{});m(this,"pagePointWhereNextSegmentChanged",null);m(this,"lastRecordedPoint",{});m(this,"mergeNextPoint",!1);m(this,"currentLineLength",0);m(this,"canDraw",!1);m(this,"markId",null);m(this,"onEnter",n=>{this.markId=null,this.info=n,this.canDraw=!this.editor.getIsMenuOpen(),this.lastRecordedPoint=this.editor.inputs.currentPagePoint.clone(),this.canDraw&&this.startShape()});m(this,"onPointerMove",()=>{const{inputs:n}=this.editor;if(this.isPen&&!n.isPen){if(this.markId){this.editor.bailToMark(this.markId),this.startShape();return}}else!this.canDraw&&n.isDragging&&(this.startShape(),this.canDraw=!0);this.canDraw&&(this.isPenOrStylus?b.Dist(n.currentPagePoint,this.lastRecordedPoint)>=1/this.editor.getZoomLevel()?(this.lastRecordedPoint=n.currentPagePoint.clone(),this.mergeNextPoint=!1):this.mergeNextPoint=!0:this.mergeNextPoint=!1,this.updateDrawingShape())});m(this,"onKeyDown",n=>{if(n.key==="Shift")switch(this.segmentMode){case"free":{this.segmentMode="starting_straight",this.pagePointWhereNextSegmentChanged=this.editor.inputs.currentPagePoint.clone();break}case"starting_free":this.segmentMode="starting_straight"}this.updateDrawingShape()});m(this,"onKeyUp",n=>{if(n.key==="Shift")switch(this.editor.snaps.clearIndicators(),this.segmentMode){case"straight":{this.segmentMode="starting_free",this.pagePointWhereNextSegmentChanged=this.editor.inputs.currentPagePoint.clone();break}case"starting_straight":{this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";break}}this.updateDrawingShape()});m(this,"onExit",()=>{this.editor.snaps.clearIndicators(),this.pagePointWhereCurrentSegmentChanged=this.editor.inputs.currentPagePoint.clone()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.editor.inputs.isDragging||(this.markId&&this.editor.bailToMark(this.markId),this.cancel())})}canClose(){return this.shapeType!=="highlight"}getIsClosed(n,r){if(!this.canClose())return!1;const o=Ot[r],s=n[0].points[0],i=n[n.length-1],a=i.points[i.points.length-1];return s!==a&&this.currentLineLength>o*4&&b.DistMin(s,a,o*2)}startShape(){const{inputs:{originPagePoint:n,isPen:r}}=this.editor;this.markId="draw start "+rt(),this.editor.mark(this.markId);const o=this.info.point.z===void 0?.5:this.info.point.z;this.isPen=r,this.isPenOrStylus=r||o>0&&o<.5||o>.5&&o<1;const s=this.isPenOrStylus?o*1.25:.5;if(this.segmentMode=this.editor.inputs.shiftKey?"straight":"free",this.didJustShiftClickToExtendPreviousShapeLine=!1,this.lastRecordedPoint=n.clone(),this.initialShape){const a=this.editor.getShape(this.initialShape.id);if(a&&this.segmentMode==="straight"){this.didJustShiftClickToExtendPreviousShapeLine=!0;const c=Bt(a.props.segments);if(!c)throw Error("Expected a previous segment!");const l=Bt(c.points);if(!l)throw Error("Expected a previous point!");const{x:u,y:d}=this.editor.getPointInShapeSpace(a,n).toFixed(),p={type:this.segmentMode,points:[{x:l.x,y:l.y,z:+s.toFixed(2)},{x:u,y:d,z:+s.toFixed(2)}]},f=oe.applyToPoint(this.editor.getShapePageTransform(a.id),l);this.pagePointWhereCurrentSegmentChanged=f,this.pagePointWhereNextSegmentChanged=null;const y=[...a.props.segments,p];this.currentLineLength<Ot[a.props.size]*4&&(this.currentLineLength=this.getLineLength(y));const g={id:a.id,type:this.shapeType,props:{segments:y}};this.canClose()&&(g.props.isClosed=this.getIsClosed(y,a.props.size)),this.editor.updateShapes([g]);return}}this.pagePointWhereCurrentSegmentChanged=n.clone();const i=He();this.editor.createShapes([{id:i,type:this.shapeType,x:n.x,y:n.y,props:{isPen:this.isPenOrStylus,segments:[{type:this.segmentMode,points:[{x:0,y:0,z:+s.toFixed(2)}]}]}}]),this.currentLineLength=0,this.initialShape=this.editor.getShape(i)}updateDrawingShape(){const{initialShape:n}=this,{inputs:r}=this.editor;if(!n)return;const{id:o,props:{size:s}}=n,i=this.editor.getShape(o);if(!i)return;const{segments:a}=i.props,{x:c,y:l,z:u}=this.editor.getPointInShapeSpace(i,r.currentPagePoint).toFixed(),d={x:c,y:l,z:this.isPenOrStylus?+(u*1.25).toFixed(2):.5};switch(this.segmentMode){case"starting_straight":{const{pagePointWhereNextSegmentChanged:p}=this;if(p===null)throw Error("We should have a point where the segment changed");if(b.Dist2(p,r.currentPagePoint)>Sp){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="straight";const y=Bt(a);if(!y)throw Error("Expected a previous segment!");const g=Bt(y.points);if(!g)throw Error("Expected a previous last point!");let w;const S=this.editor.getPointInShapeSpace(i,this.pagePointWhereCurrentSegmentChanged).toFixed().toJson();if(y.type==="straight"){this.currentLineLength+=b.Dist(g,S),w={type:"straight",points:[{...g},S]};const P=this.editor.getShapePageTransform(i);this.pagePointWhereCurrentSegmentChanged=oe.applyToPoint(P,g)}else w={type:"straight",points:[S,d]};const v={id:o,type:this.shapeType,props:{segments:[...a,w]}};this.canClose()&&(v.props.isClosed=this.getIsClosed(a,s)),this.editor.updateShapes([v])}break}case"starting_free":{const{pagePointWhereNextSegmentChanged:p}=this;if(p===null)throw Error("We should have a point where the segment changed");if(b.Dist2(p,r.currentPagePoint)>Sp){this.pagePointWhereCurrentSegmentChanged=this.pagePointWhereNextSegmentChanged.clone(),this.pagePointWhereNextSegmentChanged=null,this.segmentMode="free";const y=a.slice(),g=y[y.length-1],w=Bt(g.points);if(!w)throw Error("No previous point!");const S={type:"free",points:[...b.PointsBetween(w,d,6).map(I=>I.toFixed().toJson())]},v=[...y,S];this.currentLineLength<Ot[i.props.size]*4&&(this.currentLineLength=this.getLineLength(v));const P={id:o,type:this.shapeType,props:{segments:v}};this.canClose()&&(P.props.isClosed=this.getIsClosed(v,s)),this.editor.updateShapes([P])}break}case"straight":{const p=a.slice(),f=p[p.length-1],{pagePointWhereCurrentSegmentChanged:y}=this,{ctrlKey:g,currentPagePoint:w}=this.editor.inputs;if(!y)throw Error("We should have a point where the segment changed");let S,v=!1;this.didJustShiftClickToExtendPreviousShapeLine?this.editor.inputs.isDragging&&(v=!g,this.didJustShiftClickToExtendPreviousShapeLine=!1):v=!g;let P=this.editor.getPointInShapeSpace(i,w).toFixed().toJson(),I=!1,C;if((this.editor.user.getIsSnapMode()?!g:g)&&p.length>2){let k,$=8/this.editor.getZoomLevel();for(let T=0,A=a.length-2;T<A;T++){const B=a[T];if(!B)break;if(B.type==="free")continue;const L=B.points[0],R=Bt(B.points);if(!(L&&R))continue;const N=b.NearestPointOnLineSegment(L,R,P);if(b.DistMin(N,P,$)){k=N.toFixed().toJson(),$=b.Dist(N,P),C=B;break}}k&&(I=!0,P=k)}if(I&&C){const k=this.editor.getShapePageTransform(i),$=C.points[0],T=Bt(C.points);if(!T)throw Error("Expected a last point!");const A=oe.applyToPoint(k,$),B=oe.applyToPoint(k,T),L=oe.applyToPoint(k,P);this.editor.snaps.setIndicators([{id:rt(),type:"points",points:[A,L,B]}])}else{if(this.editor.snaps.clearIndicators(),v){const k=b.Angle(y,w),T=gp(k,24)-k;S=b.RotWith(w,y,T)}else S=w;P=this.editor.getPointInShapeSpace(i,S).toFixed().toJson()}this.currentLineLength+=b.Dist(f.points[0],P),p[p.length-1]={...f,type:"straight",points:[f.points[0],P]};const _={id:o,type:this.shapeType,props:{segments:p}};this.canClose()&&(_.props.isClosed=this.getIsClosed(a,s)),this.editor.updateShapes([_]);break}case"free":{const p=a.slice(),f=p[p.length-1],y=[...f.points];if(y.length&&this.mergeNextPoint){const{z:w}=y[y.length-1];y[y.length-1]={x:d.x,y:d.y,z:w?Math.max(w,d.z):d.z}}else this.currentLineLength+=b.Dist(y[y.length-1],d),y.push(d);p[p.length-1]={...f,points:y},this.currentLineLength<Ot[i.props.size]*4&&(this.currentLineLength=this.getLineLength(p));const g={id:o,type:this.shapeType,props:{segments:p}};if(this.canClose()&&(g.props.isClosed=this.getIsClosed(p,s)),this.editor.updateShapes([g]),y.length>500){this.editor.updateShapes([{id:o,type:this.shapeType,props:{isComplete:!0}}]);const w=He();this.editor.createShapes([{id:w,type:this.shapeType,x:mp(r.currentPagePoint.x),y:mp(r.currentPagePoint.y),props:{isPen:this.isPenOrStylus,segments:[{type:"free",points:[{x:0,y:0,z:this.isPenOrStylus?+(u*1.25).toFixed():.5}]}]}}]),this.initialShape=Ge(this.editor.getShape(w)),this.mergeNextPoint=!1,this.lastRecordedPoint=r.currentPagePoint.clone(),this.currentLineLength=0}break}}}getLineLength(n){let r=0;for(const o of n)for(let s=0;s<o.points.length-1;s++){const i=o.points[s],a=o.points[s+1];r+=b.Dist2(a,i)}return Math.sqrt(r)}complete(){if(!this.canDraw){this.cancel();return}const{initialShape:n}=this;n&&(this.editor.updateShapes([{id:n.id,type:n.type,props:{isComplete:!0}}]),this.parent.transition("idle"))}cancel(){this.parent.transition("idle",this.info)}}m(Dx,"id","drawing");var Sy;let h$=(Sy=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("drawing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(Sy,"id","idle"),Sy);class wh extends se{constructor(){super(...arguments);m(this,"shapeType","draw");m(this,"onExit",()=>{const n=this.children.drawing;n.initialShape=void 0})}}m(wh,"id","draw"),m(wh,"initial","idle"),m(wh,"children",()=>[h$,Dx]);class av extends mh{constructor(){super(...arguments);m(this,"shapeType","frame");m(this,"onCreate",n=>{if(!n)return;const r=this.editor.getShapePageBounds(n),o=[],s=this.editor.getShapeAncestors(n).map(i=>i.id);this.editor.getSortedChildIdsForParent(n.parentId).map(i=>{const a=this.editor.getShape(i);if(!a||a.id===n.id||a.isLocked)return;const c=this.editor.getShapePageBounds(a);c&&r.contains(c)&&IG(a,s,n)&&o.push(a.id)}),this.editor.reparentShapes(o,n.id),this.editor.getInstanceState().isToolLocked?this.editor.setCurrentTool("frame"):this.editor.setCurrentTool("select.idle")})}}m(av,"id","frame"),m(av,"initial","idle");function IG(e,t,n){return t.includes(e.id)?!1:e.parentId===n.parentId}var vy;let EG=(vy=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onKeyUp",n=>{var r;if(n.key==="Enter"){if(this.editor.getInstanceState().isReadonly)return null;const o=this.editor.getOnlySelectedShape();o&&this.editor.getShapeUtil(o).canEdit(o)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(o.id),(r=this.editor.root.getCurrent())==null||r.transition("editing_shape",{...n,target:"shape",shape:o}))}});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(vy,"id","idle"),vy);var xy;let _G=(xy=class extends se{constructor(){super(...arguments);m(this,"markId","");m(this,"onPointerUp",()=>{this.complete()});m(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){const{originPagePoint:r}=this.editor.inputs,o=He();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(ro)}}]).select(o).setCurrentTool("select.resizing",{...n,target:"selection",handle:"bottom_right",isCreating:!0,creationCursorOffset:{x:1,y:1},onInteractionEnd:"geo"})}});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()})}complete(){const{originPagePoint:n}=this.editor.inputs,r=He();this.markId=`creating:${r}`,this.editor.mark(this.markId),this.editor.createShapes([{id:r,type:"geo",x:n.x,y:n.y,props:{geo:this.editor.getStyleForNextShape(ro),w:1,h:1}}]);const o=this.editor.getShape(r);if(!o)return;const s=o.props.geo==="star"?new te(0,0,200,190):o.props.geo==="cloud"?new te(0,0,300,180):new te(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(ro),w:s.width,h:s.height}}]),this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):this.editor.setCurrentTool("select",{})}cancel(){this.parent.transition("idle")}},m(xy,"id","pointing"),xy);class bh extends se{constructor(){super(...arguments);m(this,"shapeType","geo")}}m(bh,"id","geo"),m(bh,"initial","idle"),m(bh,"children",()=>[EG,_G]);class Ph extends se{constructor(){super(...arguments);m(this,"shapeType","highlight");m(this,"onExit",()=>{const n=this.children.drawing;n.initialShape=void 0})}}m(Ph,"id","highlight"),m(Ph,"initial","idle"),m(Ph,"children",()=>[h$,Dx]);var wy;let kG=(wy=class extends se{constructor(){super(...arguments);m(this,"shapeId","");m(this,"onEnter",n=>{this.shapeId=n.shapeId,this.editor.setCursor({type:"cross",rotation:0})});m(this,"onPointerDown",()=>{this.parent.transition("pointing",{shapeId:this.shapeId})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(wy,"id","idle"),wy);const uC=2;var by;let TG=(by=class extends se{constructor(){super(...arguments);m(this,"shape",{});m(this,"markId");m(this,"onEnter",n=>{const{inputs:r}=this.editor,{currentPagePoint:o}=r;this.markId=void 0;const s=n.shapeId&&this.editor.getShape(n.shapeId);if(s&&r.shiftKey){this.markId=`creating:${s.id}`,this.editor.mark(this.markId),this.shape=s;const i=this.editor.getShapeHandles(this.shape);if(!i)return;const a=i.filter(f=>f.type==="vertex").sort(rn),c=a[a.length-1],l=a[a.length-2],u=oe.applyToPoint(this.editor.getShapeParentTransform(this.shape),new b(this.shape.x,this.shape.y)),d=b.Sub(o,u).addXY(.1,.1),p=Ge(this.shape.props.points);if(b.DistMin(c,l,uC)||b.DistMin(d,c,uC))p[c.id]={id:c.id,index:c.index,x:d.x,y:d.y};else{const f=$o(c.index);p[f]={id:f,index:f,x:d.x,y:d.y}}this.editor.updateShapes([{id:this.shape.id,type:this.shape.type,props:{points:p}}])}else{const i=He();this.markId=`creating:${i}`,this.editor.mark(this.markId),this.editor.createShapes([{id:i,type:"line",x:o.x,y:o.y}]),this.editor.select(i),this.shape=this.editor.getShape(i)}});m(this,"onPointerMove",()=>{if(this.shape&&this.editor.inputs.isDragging){const n=this.editor.getShapeHandles(this.shape);if(!n)throw this.markId&&this.editor.bailToMark(this.markId),Error("No handles found");const r=Bt(n);this.editor.setCurrentTool("select.dragging_handle",{shape:this.shape,isCreating:!0,handle:{...r,x:r.x-.1,y:r.y-.1},onInteractionEnd:"line"})}});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.parent.transition("idle"),this.markId&&this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators()})}complete(){this.parent.transition("idle",{shapeId:this.shape.id}),this.editor.snaps.clearIndicators()}cancel(){this.markId&&this.editor.bailToMark(this.markId),this.parent.transition("idle",{shapeId:this.shape.id}),this.editor.snaps.clearIndicators()}},m(by,"id","pointing"),by);class Ch extends se{constructor(){super(...arguments);m(this,"shapeType","line")}}m(Ch,"id","line"),m(Ch,"initial","idle"),m(Ch,"children",()=>[kG,TG]);var Py;let $G=(Py=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(Py,"id","idle"),Py);function Ye(e,t){var o;const n=new Set;for(const s of t){const i=e.getShape(s);if(!i)continue;e.getShapeUtil(i).onDragShapesOut&&n.add(i);const a=e.getShape(i.parentId);a&&e.getShapeUtil(a).onDragShapesOut&&n.add(a)}const r=new Map;for(const s of n){const i=p$(e,s);i.length&&r.set(s,i)}for(const[s,i]of r){const a=e.getShapeUtil(s),c=fe(i.map(l=>e.getShape(l)));(o=a.onDragShapesOut)==null||o.call(a,s,c)}}function p$(e,t){const n=e.getSortedChildIdsForParent(t.id);if(n.length===0)return[];const r=e.getShapePageBounds(t);if(!r)return[];let o,s,i;const a=[];for(const c of n){const l=e.getShapePageBounds(c);if(!l)continue;if(!r.includes(l)){a.push(c);continue}o??(o=e.getShapeGeometry(t)),s??(s=e.getShapePageTransform(t)),i??(i=s.applyToPoints(o.vertices));const u=e.getShapePageTransform(c).clone().invert().applyToPoints(i),{vertices:d,isClosed:p}=e.getShapeGeometry(c);if(!d.some(f=>Zn(f,u))){if(p){if(DT(u,d))continue}else if(Fz(u,d))continue;a.push(c)}}return a}function ef(e,t,n=!1){e.select(t),e.setEditingShape(t),e.setCurrentTool("select.editing_shape",{target:"shape",shape:t}),n&&e.emit("select-all-text",{shapeId:t.id}),f$(e)}const MG=16;function f$(e){const t=e.getSelectionPageBounds(),n=e.getViewportPageBounds();if(t&&!n.contains(t)){const r=t.clone().expandBy(MG/e.getZoomLevel()).expand(n),o=n.clone().translate({x:(r.center.x-n.center.x)*2,y:(r.center.y-n.center.y)*2});e.zoomToBounds(o,{animation:{duration:Qr},inset:0})}}const ja=20,AG=0,$e=200,Rx={x:$e/2,y:$e/2},g$=10,jG={a1:new b($e*.5,$e*-.5-ja),a2:new b($e*1.5+ja,$e*.5),a3:new b($e*.5,$e*1.5+ja),a4:new b($e*-.5-ja,$e*.5)};function m$(e,t,n,r){return Object.fromEntries(Object.entries(jG).map(([o,s],i)=>{const a=s.clone();return i===0&&r?a.y-=r:i===2&&n&&(a.y+=n),[o,a.rot(t).add(e)]}))}function y$(e,t,n){const r=new Set(e.getSelectedShapeIds()),o=($e+ja+n)**2,s=new Map,i=[];for(const l of e.getCurrentPageShapes()){if(!e.isShapeOfType(l,"note")||r.has(l.id))continue;const u=e.getShapePageTransform(l.id);t===u.rotation()&&(s.set(l,e.getShapePageBounds(l).center),i.push(...Object.values(m$(u.point(),t,l.props.growY,n))))}const a=i.length;let c;for(const[l,u]of s)for(let d=0;d<a;d++)c=i[d],c&&(b.Dist2(u,c)>o||e.isPointInShape(l,c)&&(i[d]=void 0));return fe(i)}function S$(e,t,n,r,o=!1){let s;const i=e.getCurrentPageShapesSorted(),a=$e+ja**2;for(let c=i.length-1;c>=0;c--){const l=i[c];if(l.type==="note"&&l.id!==t.id){const u=e.getShapePageBounds(l);if(u&&b.Dist2(u.center,n)<a&&e.isPointInShape(l,n)){s=l;break}}}if(e.complete(),!s||o){e.mark("creating note shape");const c=He();e.createShape({id:c,type:"note",x:n.x,y:n.y,rotation:r,opacity:t.opacity,props:{...t.props,text:"",growY:0,fontSizeAdjustment:0,url:""}});const l=e.getShape(c),u=e.getPointInParentSpace(l,b.Sub(n,b.Rot(Rx,r)));e.updateShape({id:c,type:"note",x:u.x,y:u.y}),s=e.getShape(c)}return f$(e),s}var Cy;let OG=(Cy=class extends se{constructor(){super(...arguments);m(this,"dragged",!1);m(this,"info",{});m(this,"wasFocusedOnEnter",!1);m(this,"markId","");m(this,"shape",{});m(this,"onEnter",()=>{const{editor:n}=this;if(this.wasFocusedOnEnter=!n.getIsMenuOpen(),this.wasFocusedOnEnter){const r=He();this.markId=`creating:${r}`,n.mark(this.markId);const o=this.editor.inputs.originPagePoint.clone(),s=dC(this.editor,o);s&&o.sub(s),this.shape=hC(this.editor,r,o)}});m(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){if(!this.wasFocusedOnEnter){const r=He(),o=this.editor.inputs.originPagePoint.clone(),s=dC(this.editor,o);s&&o.sub(s),this.shape=hC(this.editor,r,o)}this.editor.setCurrentTool("select.translating",{...n,target:"shape",shape:this.shape,onInteractionEnd:"note",isCreating:!0,onCreate:()=>{this.editor.setEditingShape(this.shape.id),this.editor.setCurrentTool("select.editing_shape")}})}});m(this,"onPointerUp",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()})}complete(){this.wasFocusedOnEnter&&(this.editor.getInstanceState().isToolLocked?this.parent.transition("idle"):(this.editor.setEditingShape(this.shape.id),this.editor.setCurrentTool("select.editing_shape",{...this.info,target:"shape",shape:this.shape})))}cancel(){this.editor.bailToMark(this.markId),this.parent.transition("idle",this.info)}},m(Cy,"id","pointing"),Cy);function dC(e,t){let n=g$/e.getZoomLevel(),r;for(const o of y$(e,0,0)){const s=b.Sub(t,o),i=s.len();i<n&&(n=i,r=s)}return r}function hC(e,t,n){e.createShape({id:t,type:"note",x:n.x,y:n.y}).select(t);const r=e.getShape(t),o=e.getShapeGeometry(r).bounds;return e.updateShapes([{id:t,type:"note",x:r.x-o.width/2,y:r.y-o.height/2}]),e.getShape(t)}class Ih extends se{constructor(){super(...arguments);m(this,"shapeType","note")}}m(Ih,"id","note"),m(Ih,"initial","idle"),m(Ih,"children",()=>[$G,OG]);function DG(e){const t=e.getShapeAtPoint(e.inputs.currentPagePoint,{hitInside:!1,hitLabels:!1,margin:Uo/e.getZoomLevel(),renderingOnly:!0});if(!t)return e.setHoveredShape(null);let n;const r=e.getOutermostSelectableShape(t);return r===t||r.id===e.getFocusedGroupId()||e.getSelectedShapeIds().includes(r.id)?n=t:n=r,e.setHoveredShape(n.id)}const Ka=ND(DG,32);var Iy;let RG=(Iy=class extends se{constructor(){super(...arguments);m(this,"onPointerMove",n=>{switch(n.target){case"shape":case"canvas":Ka(this.editor)}});m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})});m(this,"onKeyDown",n=>{var r;if(n.key==="Enter"){if(this.editor.getInstanceState().isReadonly)return null;const o=this.editor.getOnlySelectedShape();o&&this.editor.getShapeUtil(o).canEdit(o)&&(this.editor.setCurrentTool("select"),this.editor.setEditingShape(o.id),(r=this.editor.root.getCurrent())==null||r.transition("editing_shape",{...n,target:"shape",shape:o}))}});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(Iy,"id","idle"),Iy);var Ey;let LG=(Ey=class extends se{constructor(){super(...arguments);m(this,"shape");m(this,"markId","");m(this,"onExit",()=>{this.editor.setHintingShapes([])});m(this,"onPointerMove",n=>{if(this.editor.inputs.isDragging){const{inputs:{originPagePoint:r}}=this.editor,o=He();if(this.markId=`creating:${o}`,this.editor.mark(this.markId),this.editor.createShapes([{id:o,type:"text",x:r.x,y:r.y,props:{text:"",autoSize:!1,w:20}}]),this.editor.select(o),this.shape=this.editor.getShape(o),!this.shape)return;const{shape:s}=this;this.editor.setCurrentTool("select.resizing",{...n,target:"selection",handle:"right",isCreating:!0,creationCursorOffset:{x:18,y:1},onInteractionEnd:"text",onCreate:()=>{this.editor.setEditingShape(s.id),this.editor.setCurrentTool("select.editing_shape")}})}});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.cancel()});m(this,"onCancel",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}complete(){var s;this.editor.mark("creating text shape");const n=He(),{x:r,y:o}=this.editor.inputs.currentPagePoint;this.editor.createShapes([{id:n,type:"text",x:r,y:o,props:{text:"",autoSize:!0}}]).select(n),this.editor.setEditingShape(n),this.editor.setCurrentTool("select"),(s=this.editor.root.getCurrent())==null||s.transition("editing_shape")}cancel(){this.parent.transition("idle"),this.editor.bailToMark(this.markId)}},m(Ey,"id","pointing"),Ey);class Eh extends se{constructor(){super(...arguments);m(this,"shapeType","text")}}m(Eh,"id","text"),m(Eh,"initial","idle"),m(Eh,"children",()=>[RG,LG]);const FG=[Eh,wh,bh,Ih,Ch,av,xh,Ph],oc={},Lx=6;for(let e=1;e<=Lx;e++)oc[e+"_dark"]=`hash_pattern_zoom_${e}_dark`,oc[e+"_light"]=`hash_pattern_zoom_${e}_light`;function sc(e){return{key:`${co.id}:${e}`,getElement:async()=>{const t=NG(e);if(!t)return null;const n=t.$$_url,r=t.$$_fontface;if(!n||!r)return null;const o=await(await fetch(n)).blob(),s=await Oa.blobToDataUrl(o),i=r.replace(n,s);return h.jsx("style",{children:i})}}}function NG(e){const t=fE[e];for(const n of document.fonts)if(t.includes(n.family))return n;return null}function Fx(e){return{key:`${co.id}:${e}`,getElement:async()=>e!=="pattern"?null:h.jsx(zG,{})}}function zG(){const e=Pt(),t=8/12;return h.jsxs(h.Fragment,{children:[h.jsxs("mask",{id:"hash_pattern_mask",children:[h.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:"white"}),h.jsxs("g",{strokeLinecap:"round",stroke:"black",children:[h.jsx("line",{x1:t*1,y1:t*3,x2:t*3,y2:t*1}),h.jsx("line",{x1:t*5,y1:t*7,x2:t*7,y2:t*5}),h.jsx("line",{x1:t*9,y1:t*11,x2:t*11,y2:t*9})]})]}),h.jsx("pattern",{id:oc[`1_${e.id}`],width:"8",height:"8",patternUnits:"userSpaceOnUse",children:h.jsx("rect",{x:"0",y:"0",width:"8",height:"8",fill:e.solid,mask:"url(#hash_pattern_mask)"})})]})}function Nx(){return{key:`${co.id}:pattern`,component:HG}}const dl=8,pC=(e,t,n)=>new Promise((r,o)=>{const s=dl*t*e,i=document.createElement("canvas");i.width=s,i.height=s;const a=i.getContext("2d");if(!a)return;a.fillStyle=n?"#212529":"#f8f9fa",a.fillRect(0,0,s,s),a.globalCompositeOperation="destination-out",a.lineCap="round",a.lineWidth=1.25*t*e;const c=8/12,l=u=>u*t*e;a.beginPath(),a.moveTo(l(c*1),l(c*3)),a.lineTo(l(c*3),l(c*1)),a.moveTo(l(c*5),l(c*7)),a.lineTo(l(c*7),l(c*5)),a.moveTo(l(c*9),l(c*11)),a.lineTo(l(c*11),l(c*9)),a.stroke(),i.toBlob(u=>{!u||jt.throwToBlob.get()?o():r(u)})}),fC=(e,t)=>{const n=document.createElement("canvas");n.width=e[0],n.height=e[1];const r=n.getContext("2d");return r?(t(r),n.toDataURL()):""},BG=()=>{const e=[];for(let t=1;t<=Lx;t++){const n=fC([1,1],o=>{o.fillStyle=cp.lightMode.black.semi,o.fillRect(0,0,1,1)}),r=fC([1,1],o=>{o.fillStyle=cp.darkMode.black.semi,o.fillRect(0,0,1,1)});e.push({zoom:t,url:n,darkMode:!1}),e.push({zoom:t,url:r,darkMode:!0})}return e};function UG(){const t=z().getInstanceState().devicePixelRatio,[n,r]=x.useState(!1),o=x.useMemo(()=>BG(),[]),[s,i]=x.useState(o);return x.useEffect(()=>{const c=[];for(let u=1;u<=Lx;u++)c.push(pC(t,u,!1).then(d=>({zoom:u,url:URL.createObjectURL(d),darkMode:!1}))),c.push(pC(t,u,!0).then(d=>({zoom:u,url:URL.createObjectURL(d),darkMode:!0})));let l=!1;return Promise.all(c).then(u=>{l||(i(u),r(!0))}),()=>{l=!0,r(!1)}},[t]),{defs:h.jsx(h.Fragment,{children:s.map(c=>{const l=c.zoom+(c.darkMode?"_dark":"_light");return h.jsx("pattern",{id:oc[l],width:dl,height:dl,patternUnits:"userSpaceOnUse",children:h.jsx("image",{href:c.url,width:dl,height:dl})},l)})}),isReady:n}}function HG(){const e=z(),t=x.useRef(null),{defs:n,isReady:r}=UG();return x.useEffect(()=>{if(r&&e.environment.isSafari){const o=v$(t.current);o&&requestAnimationFrame(()=>{o.style.display="none",requestAnimationFrame(()=>{o.style.display=""})})}},[e,r]),h.jsx("g",{ref:t,"data-testid":r?"ready-pattern-fill-defs":void 0,children:n})}function v$(e){return e.classList.contains("tl-html-layer")?e:e.parentElement?v$(e.parentElement):null}function Pt(){return Jo({isDarkMode:Tu()})}const It=Se.memo(function({theme:t,d:n,color:r,fill:o}){switch(o){case"none":return null;case"solid":return h.jsx("path",{fill:t[r].semi,d:n});case"semi":return h.jsx("path",{fill:t.solid,d:n});case"pattern":return h.jsx(KG,{theme:t,color:r,fill:o,d:n})}});function KG({d:e,color:t,theme:n}){const r=z(),o=zT(),s=K("zoomLevel",()=>r.getZoomLevel(),[r]),i=Math.ceil(s),a=r.getZoomLevel()<=.18;return h.jsxs(h.Fragment,{children:[h.jsx("path",{fill:n[t].pattern,d:e}),h.jsx("path",{fill:o?`url(#${oc[`1_${n.id}`]})`:a?n[t].semi:`url(#${oc[`${i}_${n.id}`]})`,d:e})]})}function WG(e){return e.replace(/\s/g," ")}function cv(e,t,n){const{padding:r=0}=n;if(t.length===0)return null;const o=te.From(t[0].box);for(const{box:l}of t)o.union(l);const s=r+(n.offsetX??0),i=(n.offsetY??0)+n.fontSize/2+(n.verticalTextAlign==="start"?r:n.verticalTextAlign==="end"?n.height-r-o.height:(Math.ceil(n.height)-o.height)/2);let a=null;const c=[];for(const{text:l,box:u}of t)a!==null&&u.y>a&&c.push(h.jsx("tspan",{alignmentBaseline:"mathematical",x:s,y:u.y+i,children:`
|
|
138
|
-
`},c.length)),c.push(h.jsx("tspan",{alignmentBaseline:"mathematical",x:u.x+s,y:u.y+i,unicodeBidi:"plaintext",children:WG(l)},c.length)),a=u.y;return h.jsx("text",{fontSize:n.fontSize,fontFamily:n.fontFamily,fontStyle:n.fontFamily,fontWeight:n.fontWeight,dominantBaseline:"mathematical",alignmentBaseline:"mathematical",stroke:n.stroke,strokeWidth:n.strokeWidth,fill:n.fill,children:c})}function GG(e,t,n,r){if((e==="start-legacy"||e==="end-legacy")&&n.length!==0){const o=te.From(n[0].box);for(const{box:s}of n)o.union(s);if(e==="start-legacy")return(r-2*t-o.width)/2;if(e==="end-legacy")return-(r-2*t-o.width)/2}}function VG(e){return e==="start-legacy"||e==="middle-legacy"||e==="end-legacy"}function qf({fontSize:e,font:t,align:n,verticalAlign:r,text:o,labelColor:s,bounds:i,padding:a=16,stroke:c=!0}){const l=z(),u=Pt(),d={fontSize:e,fontFamily:fE[t],textAlign:n,verticalTextAlign:r,width:Math.ceil(i.width),height:Math.ceil(i.height),padding:a,lineHeight:Gt.lineHeight,fontStyle:"normal",fontWeight:"normal",overflow:"wrap",offsetX:0,offsetY:0,fill:s,stroke:void 0,strokeWidth:void 0},p=l.textMeasure.measureTextSpans(o,d),f=GG(n,a,p,i.width);f&&(d.offsetX=f),d.offsetX+=i.x,d.offsetY+=i.y;const y=cv(l,p,d);let g=null;return c&&(d.fill=u.background,d.stroke=u.background,d.strokeWidth=2,g=cv(l,p,d)),h.jsxs(h.Fragment,{children:[g,y]})}function Yo(e,t,n={}){const{closed:r=!1,snap:o=1,start:s="outset",end:i="outset",lengthRatio:a=2,style:c="dashed"}=n;let l=0,u=0,d=1,p=0,f=0;switch(c){case"dashed":{d=1,l=Math.min(t*a,e/4);break}case"dotted":{d=100,l=t/d;break}default:return{strokeDasharray:"none",strokeDashoffset:"none"}}return r||(s==="outset"?(e+=l/2,f+=l/2):s==="skip"&&(e-=l,f-=l),i==="outset"?e+=l/2:i==="skip"&&(e-=l)),u=Math.floor(e/l/(2*d)),u-=u%o,u<3&&c==="dashed"?e/t<5?(l=e,u=1,p=0):(l=e*.333,p=e*.333):(u=Math.max(u,3),l=e/u/(2*d),r?(f=l/2,p=(e-u*l)/u):p=(e-u*l)/Math.max(1,u-1)),{strokeDasharray:[l,p].join(" "),strokeDashoffset:f.toString()}}const gC=new WeakMap;function zx(e,t){const n=gC.get(t);if(n)return n;const r=e.getArrowInfo(t);let o=0,s=0;const i=r.isStraight?new nu({start:b.From(r.start.point),end:b.From(r.end.point)}):new n2({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(t.props.text.trim()){const c=i.bounds,{w:l,h:u}=e.textMeasure.measureText(t.props.text,{...Gt,fontFamily:ao[t.props.font],fontSize:di[t.props.size],maxWidth:null});if(o=l,s=u,c.width>c.height){o=Math.max(Math.min(l,64),Math.min(c.width-64,l));const{w:d,h:p}=e.textMeasure.measureText(t.props.text,{...Gt,fontFamily:ao[t.props.font],fontSize:di[t.props.size],maxWidth:o});o=d,s=p}if(o>16*di[t.props.size]){o=16*di[t.props.size];const{w:d,h:p}=e.textMeasure.measureText(t.props.text,{...Gt,fontFamily:ao[t.props.font],fontSize:di[t.props.size],maxWidth:o});o=d,s=p}}const a=new b(o,s).addScalar(WW*2);return gC.set(t,a),a}function x$(e,t){const n=Ot[t.props.size];return KW+(n-Ot.s)*2+(n===Ot.xl?20:0)}function YG(e,t,n){const r=zx(e,t),o=x$(e,t),s=b.Nudge(n.start.point,n.end.point,o),i=b.Nudge(n.end.point,n.start.point,o),a=rx(s,i,te.FromCenter(n.middle,r).corners);if(!a||a.length!==2)return{start:.5,end:.5};let[c,l]=a;b.Dist2(c,s)>b.Dist2(l,s)&&([l,c]=a);const u=s.add(b.Sub(n.middle,c)),d=i.add(b.Sub(n.middle,l)),p=b.Dist(n.start.point,u)/n.length,f=b.Dist(n.start.point,d)/n.length;return{start:p,end:f}}function XG(e,t,n){const r=zx(e,t),o=x$(e,t),s=Math.sign(t.props.bend),i=o/n.handleArc.radius*s,a=b.Angle(n.bodyArc.center,n.start.point)-i,c=b.Angle(n.bodyArc.center,n.end.point)+i,l=Pi(n.bodyArc.center,n.bodyArc.radius,a),u=Pi(n.bodyArc.center,n.bodyArc.radius,c),d=[],p=mC(n.bodyArc.center,n.bodyArc.radius,a,c,s,te.FromCenter(l,r).corners);d.push(new Ct({points:te.FromCenter(l,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));const f=mC(n.bodyArc.center,n.bodyArc.radius,a,c,s,te.FromCenter(u,r).corners);d.push(new Ct({points:te.FromCenter(u,r).corners,debugColor:"lime",isFilled:!1,ignore:!0}));for(const _ of[...p??[],...f??[],l,u])d.push(new hx({x:_.x-3,y:_.y-3,radius:3,isFilled:!1,debugColor:"magenta",ignore:!0}));const y=(p&&yC(n.start.point,p))??n.middle,g=(f&&yC(n.end.point,f))??n.middle,w=b.Angle(n.bodyArc.center,n.start.point),S=b.Angle(n.bodyArc.center,n.end.point),v=b.Angle(n.bodyArc.center,y),P=b.Angle(n.bodyArc.center,g);if(vs(w,v,s)>vs(w,P,s))return{start:.5,end:.5,dbg:d};const I=vs(w,S,s),C=vs(w,v,s)/I,E=vs(w,P,s)/I;return{start:C,end:E,dbg:d}}function _h(e,t){let n;const r=[],o=e.getArrowInfo(t),s=t.props.start.type==="binding",i=t.props.end.type==="binding",a=o.start.arrowhead!=="none",c=o.end.arrowhead!=="none";if(o.isStraight){const u=YG(e,t,o);let d=Mt(t.props.labelPosition,a||s?u.start:0,c||i?u.end:1);d=d>=.48&&d<=.52?.5:d,n=b.Lrp(o.start.point,o.end.point,d)}else{const u=XG(e,t,o);u.dbg&&r.push(...u.dbg);let d=Mt(t.props.labelPosition,a||s?u.start:0,c||i?u.end:1);d=d>=.48&&d<=.52?.5:d;const p=qG(b.Angle(o.bodyArc.center,o.start.point),b.Angle(o.bodyArc.center,o.end.point),Math.sign(t.props.bend),d);n=Pi(o.bodyArc.center,o.bodyArc.radius,p)}const l=zx(e,t);return{box:te.FromCenter(n,l),debugGeom:r}}function mC(e,t,n,r,o,s){const i=US(e,t,s),a=vs(n,r,o);return i==null?void 0:i.filter(c=>{const l=vs(n,b.Angle(e,c),o);return l>=0&&l<=a})}function yC(e,t){let n=null,r=-1/0;for(const o of t){const s=b.Dist2(e,o);s>r&&(n=o,r=s)}return n}function qG(e,t,n,r){const o=vs(e,t,n);return e+o*r*n*-1}function ZG(e,t,n){const r=t==="end"?e.end.point:e.start.point,o=t==="end"?e.start.point:e.end.point,s=e.isStraight?b.Dist(o,r):Math.abs(e.bodyArc.length),i=Math.max(Math.min(s/5,n*3),n);let a;if(e.isStraight)a=b.Nudge(r,o,i);else{const c=Rz(r,i,e.handleArc.center,e.handleArc.radius);a=t==="end"?e.handleArc.sweepFlag?c[0]:c[1]:e.handleArc.sweepFlag?c[1]:c[0]}return b.IsNaN(a)&&(a=e.start.point),{point:r,int:a}}function QG({point:e,int:t}){const n=b.RotWith(t,e,Pe/6),r=b.RotWith(t,e,-Pe/6);return`M ${n.x} ${n.y} L ${e.x} ${e.y} L ${r.x} ${r.y}`}function JG({point:e,int:t}){const n=b.RotWith(t,e,Pe/6),r=b.RotWith(t,e,-Pe/6);return`M ${n.x} ${n.y} L ${e.x} ${e.y} L ${r.x} ${r.y} Z`}function eV({point:e,int:t}){const n=b.Sub(t,e).div(2),r=b.Add(e,b.Rot(n,Ue)),o=b.Sub(e,b.Rot(n,Ue));return`M ${r.x} ${r.y} L ${t.x} ${t.y} L ${o.x} ${o.y} Z`}function tV({point:e,int:t}){const n=b.Lrp(e,t,.45),r=b.Dist(n,e);return`M ${n.x-r},${n.y}
|
|
139
|
-
a ${r},${r} 0 1,0 ${r*2},0
|
|
140
|
-
a ${r},${r} 0 1,0 -${r*2},0 `}function nV({point:e,int:t}){const n=b.Lrp(e,t,.75),r=b.RotWith(n,e,Pe/4),o=b.RotWith(n,e,-Pe/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 rV({int:e,point:t}){const n=b.Lrp(t,e,.85),r=b.Sub(n,t).div(2),o=b.Add(t,b.Rot(r,Ue)),s=b.Sub(t,b.Rot(r,Ue)),i=b.Add(n,b.Rot(r,Ue)),a=b.Sub(n,b.Rot(r,Ue));return`M ${o.x} ${o.y} L ${i.x} ${i.y} L ${a.x} ${a.y} L ${s.x} ${s.y} Z`}function oV({int:e,point:t}){const n=b.Sub(e,t).div(2),r=b.Add(t,b.Rot(n,Ue)),o=b.Sub(t,b.Rot(n,Ue));return`M ${r.x} ${r.y} L ${o.x} ${o.y}`}function tf(e,t,n){const r=t==="end"?e.end.arrowhead:e.start.arrowhead;if(r==="none")return;const o=ZG(e,t,n);if(o){switch(r){case"bar":return oV(o);case"square":return rV(o);case"diamond":return nV(o);case"dot":return tV(o);case"inverted":return eV(o);case"arrow":return QG(o);case"triangle":return JG(o)}return""}}function sV(e){const{start:t,end:n,handleArc:{radius:r,largeArcFlag:o,sweepFlag:s}}=e;return`M${t.handle.x},${t.handle.y} A${r} ${r} 0 ${o} ${s} ${n.handle.x},${n.handle.y}`}function w$(e){const{start:t,end:n,bodyArc:{radius:r,largeArcFlag:o,sweepFlag:s}}=e;return`M${t.point.x},${t.point.y} A${r} ${r} 0 ${o} ${s} ${n.point.x},${n.point.y}`}function b$(e,t){return`M${e.x},${e.y}L${t.x},${t.y}`}function iV(e){return b$(e.start.handle,e.end.handle)}function P$(e){return b$(e.start.point,e.end.point)}const aV=x.forwardRef(function({isEditing:t,text:n,handleFocus:r,handleChange:o,handleKeyDown:s,handleBlur:i,handleInputPointerDown:a,handleDoubleClick:c},l){return h.jsx("textarea",{ref:l,className:"tl-text tl-text-input",name:"text",tabIndex:-1,readOnly:!t,autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",autoSave:"off",placeholder:"",spellCheck:"true",wrap:"off",dir:"auto",datatype:"wysiwyg",defaultValue:n,onFocus:r,onChange:o,onKeyDown:s,onBlur:i,onTouchEnd:Kt,onContextMenu:t?Kt:void 0,onPointerDown:a,onDoubleClick:c,onDragStart:ke})});function cV(e,t,n){const r=z(),o=x.useRef(null),s=x.useRef(),i=K("isEditing",()=>r.getEditingShapeId()===e,[r]),a=K("isEditingAnything",()=>!!r.getEditingShapeId(),[r]);x.useEffect(()=>{function p({shapeId:f}){requestAnimationFrame(()=>{if(f===e){const y=o.current;y&&(document.activeElement!==y&&y.focus(),y.select())}})}return r.on("select-all-text",p),()=>{r.off("select-all-text",p)}},[r,e]),x.useEffect(()=>{if(!i)return;const p=o.current;if(!p)return;document.activeElement!==p?(p.focus(),r.getInstanceState().isCoarsePointer&&p.select()):r.environment.isSafari&&(p.blur(),p.focus());function f(){var g,w;const y=(g=window.getSelection)==null?void 0:g.call(window);if(y&&y.type!=="None"){const S=[];for(let v=0;v<y.rangeCount;v++)S.push((w=y.getRangeAt)==null?void 0:w.call(y,v));s.current=S}}return document.addEventListener("selectionchange",f),()=>{document.removeEventListener("selectionchange",f)}},[r,i]);const c=x.useCallback(()=>{const p=s.current;requestAnimationFrame(()=>{var g;const f=o.current,y=r.getEditingShapeId();if(y){if(f&&y===e&&(f.focus(),p&&p.length)){const w=window.getSelection();w&&p.forEach(S=>w.addRange(S))}}else(g=window.getSelection())==null||g.removeAllRanges()})},[r,e]),l=x.useCallback(p=>{if(r.getEditingShapeId()===e)switch(p.key){case"Enter":{(p.ctrlKey||p.metaKey)&&r.complete();break}}},[r,e]),u=x.useCallback(p=>{if(r.getEditingShapeId()!==e)return;let f=rc.normalizeText(p.currentTarget.value);const y=f.replace(/\t/g,Aa);if(y!==f){const g=p.currentTarget.selectionStart;p.currentTarget.value=y,p.currentTarget.selectionStart=g+(y.length-f.length),p.currentTarget.selectionEnd=g+(y.length-f.length),f=y}r.updateShape({id:e,type:t,props:{text:f}})},[r,e,t]),d=x.useCallback(p=>{r.dispatch({..._n(p),type:"pointer",name:"pointer_down",target:"shape",shape:r.getShape(e)}),Kt(p)},[r,e]);return{rInput:o,handleFocus:lV,handleBlur:c,handleKeyDown:l,handleChange:u,handleInputPointerDown:d,handleDoubleClick:Kt,isEmpty:n.trim().length===0,isEditing:i,isEditingAnything:a}}function lV(){}const Zf=Se.memo(function({id:t,type:n,text:r,labelColor:o,font:s,fontSize:i,lineHeight:a,align:c,verticalAlign:l,wrap:u,isSelected:d,onKeyDown:p,classNamePrefix:f,style:y,textWidth:g,textHeight:w}){const{rInput:S,isEmpty:v,isEditing:P,isEditingAnything:I,...C}=cV(t,n,r),[E,_]=x.useState(r);x.useEffect(()=>{P||_(r)},[P,r]);const k=rc.normalizeTextForDom(r),$=k.length>0,T=VG(c);if(!P&&!$)return null;const A=f||"tl-text";return h.jsx("div",{className:`${A}-label tl-text-wrapper`,"data-font":s,"data-align":c,"data-hastext":!v,"data-isediting":P,"data-iseditinganything":I,"data-textwrap":!!u,"data-isselected":d,style:{justifyContent:c==="middle"||T?"center":c,alignItems:l==="middle"?"center":l,...y},children:h.jsxs("div",{className:`${A}-label__inner tl-text-content__wrapper`,style:{fontSize:i,lineHeight:i*a+"px",minHeight:a+32,minWidth:g||0,color:o,width:g,height:w},children:[h.jsx("div",{className:`${A} tl-text tl-text-content`,dir:"auto",children:k.split(`
|
|
141
|
-
`).map((B,L)=>h.jsx("div",{dir:"auto",children:B},L))}),(I||d)&&h.jsx(aV,{ref:S,text:r,isEditing:P,...C,handleKeyDown:p??C.handleKeyDown},E)]})})}),uV=x.memo(function({id:t,text:n,size:r,font:o,position:s,width:i,isSelected:a,labelColor:c}){const l=Pt();return h.jsx(Zf,{id:t,classNamePrefix:"tl-arrow",type:"arrow",font:o,fontSize:di[r],lineHeight:Gt.lineHeight,align:"middle",verticalAlign:"middle",text:n,labelColor:l[c].solid,textWidth:i,isSelected:a,style:{transform:`translate(${s.x}px, ${s.y}px)`}})});let dV=0;class kh extends Nr{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"canBind",()=>!1);m(this,"canSnap",()=>!1);m(this,"hideResizeHandles",()=>!0);m(this,"hideRotateHandle",()=>!0);m(this,"hideSelectionBoundsBg",()=>!0);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"onHandleDrag",(n,{handle:r,isPrecise:o})=>{const s=r.id;if(s==="middle"){const{start:w,end:S}=Dr(this.editor,n),v=b.Sub(S,w),P=b.Per(v),I=b.Med(S,w),C=b.Sub(I,P),E=b.Add(I,P),_=b.NearestPointOnLineSegment(C,E,r,!1);let k=b.Dist(_,I);return b.Clockwise(_,S,I)&&(k*=-1),{id:n.id,type:n.type,props:{bend:k}}}const i=Ge(n);if(this.editor.inputs.ctrlKey)return i.props[s]={type:"point",x:r.x,y:r.y},i;const a=this.editor.getShapePageTransform(n.id).applyToPoint(r),c=this.editor.getShapeAtPoint(a,{hitInside:!0,hitFrameInside:!0,margin:0,filter:w=>!w.isLocked&&this.editor.getShapeUtil(w).canBind(w)});if(!c)return i.props[s]={type:"point",x:r.x,y:r.y},i;const l=this.editor.getShapeGeometry(c),u=te.ZeroFix(l.bounds),p=this.editor.getShapePageTransform(i.id).applyToPoint(r),f=this.editor.getPointInShapeSpace(c,p);let y=o;if(!y){const w=i.props[s];(w.type==="point"||w.type==="binding"&&c.id!==w.boundShapeId)&&(y=this.editor.inputs.pointerVelocity.len()<.5)}if(!o){l.isClosed||(y=!0);const w=i.props[s==="start"?"end":"start"];w.type==="binding"&&c.id===w.boundShapeId&&w.isPrecise&&(y=!0)}const g={x:(f.x-u.minX)/u.width,y:(f.y-u.minY)/u.height};return y&&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:c.id,normalizedAnchor:g,isPrecise:y,isExact:this.editor.inputs.altKey},i.props.start.type==="binding"&&i.props.end.type==="binding"&&i.props.start.boundShapeId===i.props.end.boundShapeId&&b.Equals(i.props.start.normalizedAnchor,i.props.end.normalizedAnchor)&&(i.props.end.normalizedAnchor.x+=.05),i});m(this,"onTranslateStart",n=>{const r=n.props.start.type==="binding"?n.props.start.boundShapeId:null,o=n.props.end.type==="binding"?n.props.end.boundShapeId:null,s=Dr(this.editor,n),i=this.editor.getShapePageTransform(n.id),a=this.editor.getSelectedShapeIds(),c=new Set;r&&(c.add(r),this.editor.getShapeAncestors(r).forEach(u=>c.add(u.id))),o&&(c.add(o),this.editor.getShapeAncestors(o).forEach(u=>c.add(u.id)));for(const u of a)if(c.has(u))return;let l=n;vC.set(n,{pagePosition:i.applyToPoint(n),terminalBindings:df(s,(u,d)=>{const p=n.props[u];return p.type!=="binding"?null:{binding:p,shapePosition:d,pagePosition:i.applyToPoint(d)}})});for(const u of["start","end"]){const d=n.props[u];d.type==="binding"&&(l={...n,props:{...n.props,[u]:{...d,isPrecise:!0}}})}return l});m(this,"onTranslate",(n,r)=>{const o=vC.get(n);if(!o)return;const s=this.editor.getShapePageTransform(r.id),i=b.Sub(s.applyToPoint(r),o.pagePosition);let a=r;for(const[c,l]of gn(o.terminalBindings)){if(!l)continue;const u=b.Add(l.pagePosition,b.Mul(i,.5)),d=this.editor.getShapeAtPoint(u,{hitInside:!0,hitFrameInside:!0,margin:0,filter:p=>!p.isLocked&&this.editor.getShapeUtil(p).canBind(p)});if((d==null?void 0:d.id)===l.binding.boundShapeId){const p=te.ZeroFix(this.editor.getShapeGeometry(d).bounds),f=this.editor.getPointInShapeSpace(d,u),y={x:(f.x-p.minX)/p.width,y:(f.y-p.minY)/p.height};a={...a,props:{...a.props,[c]:{...l.binding,isPrecise:!0,normalizedAnchor:y}}}}else a={...a,props:{...a.props,[c]:{type:"point",x:l.shapePosition.x,y:l.shapePosition.y}}}}return a});m(this,"onResize",(n,r)=>{const{scaleX:o,scaleY:s}=r,i=Dr(this.editor,n),{start:a,end:c}=Ge(n.props);let{bend:l}=n.props;a.type==="point"&&(a.x=i.start.x*o,a.y=i.start.y*s),c.type==="point"&&(c.x=i.end.x*o,c.y=i.end.y*s);const u=Math.abs(o),d=Math.abs(s);return o<0&&s>=0?(l!==0&&(l*=-1,l*=Math.max(u,d)),a.type==="binding"&&(a.normalizedAnchor.x=1-a.normalizedAnchor.x),c.type==="binding"&&(c.normalizedAnchor.x=1-c.normalizedAnchor.x)):o>=0&&s<0?(l!==0&&(l*=-1,l*=Math.max(u,d)),a.type==="binding"&&(a.normalizedAnchor.y=1-a.normalizedAnchor.y),c.type==="binding"&&(c.normalizedAnchor.y=1-c.normalizedAnchor.y)):o>=0&&s>=0?l!==0&&(l*=Math.max(u,d)):o<0&&s<0&&(l!==0&&(l*=Math.max(u,d)),a.type==="binding"&&(a.normalizedAnchor.x=1-a.normalizedAnchor.x,a.normalizedAnchor.y=1-a.normalizedAnchor.y),c.type==="binding"&&(c.normalizedAnchor.x=1-c.normalizedAnchor.x,c.normalizedAnchor.y=1-c.normalizedAnchor.y)),{props:{start:a,end:c,bend:l}}});m(this,"onDoubleClickHandle",(n,r)=>{switch(r.id){case"start":return{id:n.id,type:n.type,props:{...n.props,arrowheadStart:n.props.arrowheadStart==="none"?"arrow":"none"}};case"end":return{id:n.id,type:n.type,props:{...n.props,arrowheadEnd:n.props.arrowheadEnd==="none"?"arrow":"none"}}}});m(this,"onEditEnd",n=>{const{id:r,type:o,props:{text:s}}=n;s.trimEnd()!==n.props.text&&this.editor.updateShapes([{id:r,type:o,props:{text:s.trimEnd()}}])})}getDefaultProps(){return{dash:"draw",size:"m",fill:"none",color:"black",labelColor:"black",bend:0,start:{type:"point",x:0,y:0},end:{type:"point",x:2,y:0},arrowheadStart:"none",arrowheadEnd:"arrow",text:"",labelPosition:.5,font:"draw"}}getGeometry(n){const r=this.editor.getArrowInfo(n),o=[],s=r.isStraight?new nu({start:b.From(r.start.point),end:b.From(r.end.point)}):new n2({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(n.props.text.trim()){const a=_h(this.editor,n);o.push(...a.debugGeom),i=new Vo({x:a.box.x,y:a.box.y,width:a.box.w,height:a.box.h,isFilled:!0,isLabel:!0})}return new Br({children:[...i?[s,i]:[s],...o]})}getHandles(n){const r=this.editor.getArrowInfo(n);return[{id:"start",type:"vertex",index:"a0",x:r.start.handle.x,y:r.start.handle.y,canBind:!0},{id:"middle",type:"virtual",index:"a2",x:r.middle.x,y:r.middle.y,canBind:!1},{id:"end",type:"vertex",index:"a3",x:r.end.handle.x,y:r.end.handle.y,canBind:!0}].filter(Boolean)}component(n){const r=this.editor.getOnlySelectedShape(),o=this.editor.isInAny("select.idle","select.pointing_handle","select.dragging_handle","select.translating","arrow.dragging")&&!this.editor.getInstanceState().isReadonly,s=this.editor.getArrowInfo(n);if(!(s!=null&&s.isValid))return null;const i=_h(this.editor,n),a=n.id===this.editor.getOnlySelectedShapeId(),l=this.editor.getEditingShapeId()===n.id||n.props.text;return h.jsxs(h.Fragment,{children:[h.jsx(Bs,{id:n.id,style:{minWidth:50,minHeight:50},children:h.jsx(SC,{shape:n,shouldDisplayHandles:o&&r===n})}),l&&h.jsx(uV,{id:n.id,text:n.props.text,font:n.props.font,size:n.props.size,position:i.box.center,width:i.box.w,isSelected:a,labelColor:n.props.labelColor})]})}indicator(n){const{start:r,end:o}=Dr(this.editor,n),s=this.editor.getArrowInfo(n),i=this.editor.getShapeGeometry(n),a=i.bounds,c=n.props.text.trim()?i.children[1]:null,l=Uf(n.id);if(!s||b.Equals(r,o))return null;const u=Ot[n.props.size],d=s.start.arrowhead&&tf(s,"start",u),p=s.end.arrowhead&&tf(s,"end",u),f=s.isStraight?P$(s):w$(s),y=d&&s.start.arrowhead!=="arrow"||p&&s.end.arrowhead!=="arrow"||!!c,g=(n.id+"_clip").replace(":","_");return l&&c?h.jsx("rect",{x:j(c.x),y:j(c.y),width:c.w,height:c.h,rx:3.5,ry:3.5}):h.jsxs("g",{children:[y&&h.jsx("defs",{children:h.jsxs("mask",{id:g,children:[h.jsx("rect",{x:a.minX-100,y:a.minY-100,width:a.w+200,height:a.h+200,fill:"white"}),c&&h.jsx("rect",{x:j(c.x),y:j(c.y),width:c.w,height:c.h,fill:"black",rx:3.5,ry:3.5}),d&&h.jsx("path",{d,fill:s.start.arrowhead==="arrow"?"none":"black",stroke:"none"}),p&&h.jsx("path",{d:p,fill:s.end.arrowhead==="arrow"?"none":"black",stroke:"none"})]})}),h.jsxs("g",{...y?{mask:`url(#${g})`}:void 0,children:[y&&h.jsx("rect",{x:a.minX-100,y:a.minY-100,width:a.width+200,height:a.height+200,opacity:0}),h.jsx("path",{d:f})]}),d&&h.jsx("path",{d}),p&&h.jsx("path",{d:p}),c&&h.jsx("rect",{x:j(c.x),y:j(c.y),width:c.w,height:c.h,rx:3.5,ry:3.5})]})}toSvg(n,r){r.addExportDef(Fx(n.props.fill)),n.props.text&&r.addExportDef(sc(n.props.font));const o=Jo(r);return h.jsxs(h.Fragment,{children:[h.jsx(SC,{shape:n,shouldDisplayHandles:!1}),h.jsx(qf,{fontSize:di[n.props.size],font:n.props.font,align:"middle",verticalAlign:"middle",text:n.props.text,labelColor:o[n.props.labelColor].solid,bounds:_h(this.editor,n).box,padding:4})]})}getCanvasSvgDefs(){return[Nx(),{key:"arrow:dot",component:pV},{key:"arrow:cross",component:fV}]}}m(kh,"type","arrow"),m(kh,"props",mE),m(kh,"migrations",yE);function hV(e,t){const n=e.getArrowInfo(t);return n.isStraight?b.Dist(n.start.handle,n.end.handle):Math.abs(n.handleArc.length)}const SC=rr(function({shape:t,shouldDisplayHandles:n}){const r=z(),o=Pt(),s=r.getArrowInfo(t),i=te.ZeroFix(r.getShapeGeometry(t).bounds),a=Se.useMemo(()=>r.environment.isSafari?dV+=1:0,[t]);if(!(s!=null&&s.isValid))return null;const c=Ot[t.props.size],l=s.start.arrowhead&&tf(s,"start",c),u=s.end.arrowhead&&tf(s,"end",c),d=s.isStraight?P$(s):w$(s);let p=null;if(n){const{strokeDasharray:I,strokeDashoffset:C}=Yo(hV(r,t),2,{end:"skip",start:"skip",lengthRatio:2.5});p=t.props.start.type==="binding"||t.props.end.type==="binding"?h.jsx("path",{className:"tl-arrow-hint",d:s.isStraight?iV(s):sV(s),strokeDasharray:I,strokeDashoffset:C,strokeWidth:2,markerStart:t.props.start.type==="binding"?t.props.start.isExact?"":t.props.start.isPrecise?"url(#arrowhead-cross)":"url(#arrowhead-dot)":"",markerEnd:t.props.end.type==="binding"?t.props.end.isExact?"":t.props.end.isPrecise?"url(#arrowhead-cross)":"url(#arrowhead-dot)":"",opacity:.16}):null}const{strokeDasharray:f,strokeDashoffset:y}=Yo(s.isStraight?s.length:Math.abs(s.bodyArc.length),c,{style:t.props.dash}),g=_h(r,t),w=!(s.start.arrowhead==="none"||s.start.arrowhead==="arrow"),S=!(s.end.arrowhead==="none"||s.end.arrowhead==="arrow"),v=(t.id+"_clip_"+a).replace(":","_");return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsxs("mask",{id:v,children:[h.jsx("rect",{x:j(-100+i.minX),y:j(-100+i.minY),width:j(i.width+200),height:j(i.height+200),fill:"white"}),t.props.text.trim()&&h.jsx("rect",{x:g.box.x,y:g.box.y,width:g.box.w,height:g.box.h,fill:"black",rx:4,ry:4}),l&&w&&h.jsx("path",{d:l,fill:s.start.arrowhead==="arrow"?"none":"black",stroke:"none"}),u&&S&&h.jsx("path",{d:u,fill:s.end.arrowhead==="arrow"?"none":"black",stroke:"none"})]})}),h.jsxs("g",{fill:"none",stroke:o[t.props.color].solid,strokeWidth:c,strokeLinejoin:"round",strokeLinecap:"round",pointerEvents:"none",children:[p,h.jsxs("g",{mask:`url(#${v})`,children:[h.jsx("rect",{x:j(i.minX-100),y:j(i.minY-100),width:j(i.width+200),height:j(i.height+200),opacity:0}),h.jsx("path",{d,strokeDasharray:f,strokeDashoffset:y})]}),l&&w&&t.props.fill!=="none"&&h.jsx(It,{theme:o,d:l,color:t.props.color,fill:t.props.fill}),u&&S&&t.props.fill!=="none"&&h.jsx(It,{theme:o,d:u,color:t.props.color,fill:t.props.fill}),l&&h.jsx("path",{d:l}),u&&h.jsx("path",{d:u})]})]})}),vC=new WeakMap;function pV(){return h.jsx("marker",{id:"arrowhead-dot",className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"0",children:h.jsx("circle",{cx:"3",cy:"3",r:"2",strokeDasharray:"100%"})})}function fV(){return h.jsxs("marker",{id:"arrowhead-cross",className:"tl-arrow-hint",refX:"3.0",refY:"3.0",orient:"auto",children:[h.jsx("line",{x1:"1.5",y1:"1.5",x2:"4.5",y2:"4.5",strokeDasharray:"100%"}),h.jsx("line",{x1:"1.5",y1:"4.5",x2:"4.5",y2:"1.5",strokeDasharray:"100%"})]})}const xC="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 ic({url:e,zoomLevel:t}){return h.jsx("a",{className:ue("tl-hyperlink-button",{"tl-hyperlink-button__hidden":t<.32}),href:e,target:"_blank",rel:"noopener noreferrer",onPointerDown:Kt,onPointerUp:Kt,title:e,draggable:!1,children:h.jsx("div",{className:"tl-hyperlink-button__icon",style:{mask:`url("${xC}") center 100% / 100% no-repeat`,WebkitMask:`url("${xC}") center 100% / 100% no-repeat`}})})}const gV=[{offsetX:0,offsetY:2,blur:4,spread:0,color:"#00000029"},{offsetX:0,offsetY:3,blur:6,spread:0,color:"#0000001f"}];function Bx(e){return gV.map(n=>{const{offsetX:r,offsetY:o,blur:s,spread:i,color:a}=n,c=new b(r,o),{x:l,y:u}=c.rot(-e);return`${l}px ${u}px ${s}px ${i}px ${a}`}).join(", ")}class Th extends vc{constructor(){super(...arguments);m(this,"canResize",()=>!1);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"onBeforeCreate",n=>{wC(this.editor,n)});m(this,"onBeforeUpdate",(n,r)=>{if(n.props.url!==r.props.url)if(er.isValid(r.props.url))wC(this.editor,r);else return{...r,props:{...r.props,url:n.props.url}}})}getDefaultProps(){return{url:"",w:300,h:320,assetId:null}}component(n){const r=n.props.assetId?this.editor.getAsset(n.props.assetId):null,o=this.editor.getShapePageTransform(n).rotation(),s=mV(n);return h.jsx($i,{children:h.jsxs("div",{className:"tl-bookmark__container",style:{boxShadow:Bx(o)},children:[h.jsxs("div",{className:"tl-bookmark__image_container",children:[r!=null&&r.props.image?h.jsx("img",{className:"tl-bookmark__image",draggable:!1,src:r==null?void 0:r.props.image,alt:(r==null?void 0:r.props.title)||""}):h.jsx("div",{className:"tl-bookmark__placeholder"}),h.jsx(ic,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]}),h.jsxs("div",{className:"tl-bookmark__copy_container",children:[(r==null?void 0:r.props.title)&&h.jsx("h2",{className:"tl-bookmark__heading",children:Tl((r==null?void 0:r.props.title)||"",54)}),(r==null?void 0:r.props.description)&&h.jsx("p",{className:"tl-bookmark__description",children:Tl((r==null?void 0:r.props.description)||"",128)}),h.jsx("a",{className:"tl-bookmark__link",href:n.props.url||"",target:"_blank",rel:"noopener noreferrer",onPointerDown:Kt,onPointerUp:Kt,onClick:Kt,children:Tl(s,45)})]})]})})}indicator(n){return h.jsx("rect",{width:j(n.props.w),height:j(n.props.h),rx:"6",ry:"6"})}}m(Th,"type","bookmark"),m(Th,"props",SE),m(Th,"migrations",vE);const mV=e=>{try{const t=new URL(e.props.url),n=t.pathname.replace(/\/*$/,"");return`${t.hostname}${n}`}catch{return e.props.url}};function wC(e,t){const{url:n}=t.props,r=pi.createId(Dy(n));e.getAsset(r)?t.props.assetId!==r&&e.updateShapes([{id:t.id,type:t.type,props:{assetId:r}}]):(e.updateShapes([{id:t.id,type:t.type,props:{assetId:null}}]),yV(e,t))}const yV=KI(async(e,t)=>{const{url:n}=t.props,r=await e.getAssetForExternalContent({type:"url",url:n});r&&e.batch(()=>{e.createAssets([r]),e.updateShapes([{id:t.id,type:t.type,props:{assetId:r.id}}])})},500);function Mi(e,t=!1){const n=e.length;if(n<2)return"";let r=e[0].point,o=e[1].point;if(n===2)return`M${_e(r)}L${_e(o)}`;let s="";for(let i=2,a=n-1;i<a;i++)r=e[i].point,o=e[i+1].point,s+=In(r,o);return t?`M${In(e[0].point,e[1].point)}Q${_e(e[1].point)}${In(e[1].point,e[2].point)}T${s}${In(e[n-1].point,e[0].point)}${In(e[0].point,e[1].point)}Z`:`M${_e(e[0].point)}Q${_e(e[1].point)}${In(e[1].point,e[2].point)}${e.length>3?"T":""}${s}L${_e(e[n-1].point)}`}function SV(e,t={}){const{start:n={},end:r={}}=t,{cap:o=!0}=n,{cap:s=!0}=r;lt(!n.taper&&!r.taper,"cap taper not supported here"),lt(!n.easing&&!r.easing,"cap easing not supported here"),lt(o&&s,"cap must be true");const i=uo(e,t);Xf(i,t);const a=vV(i);let c="";for(const l of a)c+=wV(l,t);return c}function vV(e){if(e.length<=2)return[e];const t=[];let n=[e[0]],r=b.Sub(e[1].point,e[0].point).uni(),o,s,i,a,c;for(let l=1,u=e.length;l<u-1;l++){if(i=e[l-1],a=e[l],c=e[l+1],o=b.Sub(c.point,a.point).uni(),s=b.Dpr(r,o),r=o,s<-.8){const d={...a,point:a.input};n.push(d),t.push(Ym(n)),n=[d];continue}if(n.push(a),!(s>.7)&&(b.Dist2(i.point,a.point)+b.Dist2(a.point,c.point))/((i.radius+a.radius+c.radius)/3)**2<1.5){n.push(a),t.push(Ym(n)),n=[a];continue}}return n.push(e[e.length-1]),t.push(Ym(n)),t}function Ym(e){const t=e[0];let n;for(;e.length>2&&(n=e[1],b.Dist2(t.point,n.point)<((t.radius+n.radius)/2*.5)**2);)e.splice(1,1);const r=e[e.length-1];let o;for(;e.length>2&&(o=e[e.length-2],b.Dist2(r.point,o.point)<((r.radius+o.radius)/2*.5)**2);)e.splice(e.length-2,1);return e.length>1&&(e[0]={...e[0],vector:b.Sub(e[0].point,e[1].point).uni()},e[e.length-1]={...e[e.length-1],vector:b.Sub(e[e.length-2].point,e[e.length-1].point).uni()}),e}function xV(e,t,n){return"M "+e+" "+t+" m -"+n+", 0 a "+n+","+n+" 0 1,1 "+n*2+",0 a "+n+","+n+" 0 1,1 -"+n*2+",0"}function wV(e,t={}){if(e.length===0)return"";if(e.length===1)return xV(e[0].point.x,e[0].point.y,e[0].radius);const{left:n,right:r}=s$(e,t);r.reverse();let o=`M${_e(n[0])}T`;for(let s=1;s<n.length;s++)o+=In(n[s-1],n[s]);{const s=e[e.length-1],i=s.radius,a=s.vector.clone().per().neg(),c=b.Add(s.point,b.Mul(a,i)),l=b.Add(s.point,b.Mul(a,-i));o+=`${_e(c)}A${j(i)},${j(i)} 0 0 1 ${_e(l)}T`}for(let s=1;s<r.length;s++)o+=In(r[s-1],r[s]);{const s=e[0],i=s.radius,a=s.vector.clone().per(),c=b.Add(s.point,b.Mul(a,i)),l=b.Add(s.point,b.Mul(a,-i));o+=`${_e(c)}A${j(i)},${j(i)} 0 0 1 ${_e(l)}Z`}return o}function ou(){const e=z();return K("zoom",()=>e.getZoomLevel()<.35,[e])}const bV=e=>e*.65+I3(e*Pe/2)*.35,PV=e=>({size:1+e,thinning:.5,streamline:.62+(1+e)/8*.06,smoothing:.62,easing:sn.easeOutSine,simulatePressure:!0}),CV=e=>({size:1+e*1.2,thinning:.62,streamline:.62,smoothing:.62,simulatePressure:!1,easing:bV}),bC=e=>({size:1+e,thinning:0,streamline:.62+(1+e)/8*.06,smoothing:.62,simulatePressure:!1,easing:sn.linear});function lv({strokeWidth:e,showAsComplete:t}){return{size:1+e,thinning:0,streamline:.5,smoothing:.5,simulatePressure:!1,easing:sn.easeOutSine,last:t}}function uv(e,t,n,r){return{...r?bC(t):e.dash==="draw"?e.isPen?CV(t):PV(t):bC(t),last:e.isComplete||n}}function su(e){const t=[];for(const n of e)if(n.type==="free"||n.points.length<2)t.push(...n.points.map(b.Cast));else{const r=Math.max(4,Math.floor(b.Dist(n.points[0],n.points[1])/16));t.push(...b.PointsBetween(n.points[0],n.points[1],r))}return t}function IV(e,t){return{draw:"none",solid:"none",dotted:`0.1 ${t*2}`,dashed:`${t*2} ${t*2}`}[e.props.dash]}class $h extends Nr{constructor(){super(...arguments);m(this,"hideResizeHandles",n=>Xm(n));m(this,"hideRotateHandle",n=>Xm(n));m(this,"hideSelectionBoundsFg",n=>Xm(n));m(this,"onResize",(n,r)=>{const{scaleX:o,scaleY:s}=r,i=[];for(const a of n.props.segments)i.push({...a,points:a.points.map(({x:c,y:l,z:u})=>({x:mp(o*c),y:mp(s*l),z:u}))});return{props:{segments:i}}})}getDefaultProps(){return{segments:[],color:"black",fill:"none",dash:"draw",size:"m",isComplete:!1,isClosed:!1,isPen:!1}}getGeometry(n){const r=su(n.props.segments),o=Ot[n.props.size];if(n.props.segments.length===1){const i=te.FromPoints(r);if(i.width<o*2&&i.height<o*2)return new hx({x:-o,y:-o,radius:o,isFilled:!0})}const s=uo(r,uv(n.props,o,!0,!0)).map(i=>i.point);return n.props.isClosed?new Ct({points:s,isFilled:n.props.fill!=="none"}):new Ui({points:s})}component(n){return h.jsx(Bs,{id:n.id,children:h.jsx(PC,{shape:n,forceSolid:ou()})})}indicator(n){var d;const r=ou(),o=Ot[n.props.size],s=su(n.props.segments);let i=o;!r&&!n.props.isPen&&n.props.dash==="draw"&&s.length===1&&(i+=go(n.id)()*(o/6));const a=n.props.isComplete||((d=Bt(n.props.segments))==null?void 0:d.type)==="straight",c=uv(n.props,i,a,!0),l=uo(s,c),u=l.length>1?Mi(l,n.props.isClosed):C$(s[0],i);return h.jsx("path",{d:u})}toSvg(n,r){return r.addExportDef(Fx(n.props.fill)),h.jsx(PC,{shape:n,forceSolid:!1})}getCanvasSvgDefs(){return[Nx()]}expandSelectionOutlinePx(n){const r=n.props.dash==="draw"?1.6:1;return Ot[n.props.size]*r/2}}m($h,"type","draw"),m($h,"props",wE),m($h,"migrations",bE);function C$(e,t){const n=(t+1)*.5;return`M ${e.x} ${e.y} m -${n}, 0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0`}function Xm(e){return e.props.segments.length===1&&e.props.segments[0].points.length<2}function PC({shape:e,forceSolid:t}){var d;const n=Pt(),r=Ot[e.props.size],o=su(e.props.segments),s=e.props.isComplete||((d=Bt(e.props.segments))==null?void 0:d.type)==="straight";let i=r;!t&&!e.props.isPen&&e.props.dash==="draw"&&o.length===1&&(i+=go(e.id)()*(r/6));const a=uv(e.props,i,s,t);if(!t&&e.props.dash==="draw")return h.jsxs(h.Fragment,{children:[e.props.isClosed&&e.props.fill&&o.length>1?h.jsx(It,{theme:n,fill:e.props.isClosed?e.props.fill:"none",color:e.props.color,d:Mi(uo(o,a),e.props.isClosed)}):null,h.jsx("path",{d:SV(o,a),strokeLinecap:"round",fill:n[e.props.color].solid})]});const c=uo(o,a),l=c.length<2,u=l?C$(o[0],0):Mi(c,e.props.isClosed);return h.jsxs(h.Fragment,{children:[h.jsx(It,{theme:n,color:e.props.color,fill:l||e.props.isClosed?e.props.fill:"none",d:u}),h.jsx("path",{d:u,strokeLinecap:"round",fill:l?n[e.props.color].solid:"none",stroke:n[e.props.color].solid,strokeWidth:r,strokeDasharray:l?"none":IV(e,r),strokeDashoffset:"0"})]})}function EV(e,t,n={}){const{newPoint:r,handle:o,scaleX:s,scaleY:i}=t,{minWidth:a=1,maxWidth:c=1/0,minHeight:l=1,maxHeight:u=1/0}=n;let d=e.props.w*s,p=e.props.h*i;const f=new 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(p>0){if(p<l){switch(o){case"top_left":case"top":case"top_right":{f.y=p-l;break}case"right":case"left":{f.y=(p-l)/2;break}default:f.y=0}p=l}}else if(f.y=p,p=-p,p<l){switch(o){case"top_left":case"top":case"top_right":{f.y=-p;break}default:f.y=-l}p=l}const{x:y,y:g}=f.rot(e.rotation).add(r);return{x:y,y:g,props:{w:Math.min(c,d),h:Math.min(u,p)}}}const _V=e=>Object.entries(e).filter(([t,n])=>n).map(([t])=>t).join(" ");class Mh extends vc{constructor(){super(...arguments);m(this,"hideSelectionBoundsFg",n=>!this.canResize(n));m(this,"canEdit",()=>!0);m(this,"canResize",n=>{var r,o;return!!((o=(r=Es(n.props.url))==null?void 0:r.definition)!=null&&o.doesResize)});m(this,"canEditInReadOnly",()=>!0);m(this,"isAspectRatioLocked",n=>{const r=Es(n.props.url);return(r==null?void 0:r.definition.isAspectRatioLocked)??!1});m(this,"onResize",(n,r)=>{const o=this.isAspectRatioLocked(n),s=Es(n.props.url);let i=(s==null?void 0:s.definition.minWidth)??200,a=(s==null?void 0:s.definition.minHeight)??200;if(o){const c=n.props.w/n.props.h;c>1?i*=c:a/=c}return EV(n,r,{minWidth:i,minHeight:a})})}getDefaultProps(){return{w:300,h:300,url:""}}component(n){const{w:r,h:o,url:s}=n.props,i=Uf(n.id),a=x.useMemo(()=>l$(s),[s]),c=K("is hovering",()=>{const{editingShapeId:f,hoveredShapeId:y}=this.editor.getCurrentPageState();if(f&&y!==f){const g=this.editor.getShape(f);if(g&&this.editor.isShapeOfType(g,"embed"))return!0}return!1},[]),l=this.editor.getShapePageTransform(n).rotation(),u=i||c;if(typeof window<"u"&&(window!==window.top||window.self!==window.parent)&&(a==null?void 0:a.definition.type)==="tldraw")return null;if((a==null?void 0:a.definition.type)==="github_gist"){const f=a.url.split("/").pop();if(!f)throw Error("No gist id!");return h.jsx($i,{className:"tl-embed-container",id:n.id,children:h.jsx(kV,{id:f,width:j(r),height:j(o),isInteractive:u,pageRotation:l})})}const p=_V({...h3,...(a==null?void 0:a.definition.overridePermissions)??{}});return h.jsx($i,{className:"tl-embed-container",id:n.id,children:a!=null&&a.definition?h.jsx("iframe",{className:"tl-embed",sandbox:p,src:a.embedUrl,width:j(r),height:j(o),draggable:!1,frameBorder:"0",referrerPolicy:"no-referrer-when-downgrade",style:{border:0,pointerEvents:u?"auto":"none",zIndex:u?"":"-1",boxShadow:Bx(l),borderRadius:(a==null?void 0:a.definition.overrideOutlineRadius)??8,background:a==null?void 0:a.definition.backgroundColor}}):null})}indicator(n){const r=x.useMemo(()=>Es(n.props.url),[n.props.url]);return h.jsx("rect",{width:j(n.props.w),height:j(n.props.h),rx:(r==null?void 0:r.definition.overrideOutlineRadius)??8,ry:(r==null?void 0:r.definition.overrideOutlineRadius)??8})}}m(Mh,"type","embed"),m(Mh,"props",PE),m(Mh,"migrations",CE);function kV({id:e,file:t,isInteractive:n,width:r,height:o,style:s,pageRotation:i}){return h.jsx("iframe",{className:"tl-embed",draggable:!1,width:j(r),height:j(o),frameBorder:"0",scrolling:"no",seamless:!0,referrerPolicy:"no-referrer-when-downgrade",style:{...s,pointerEvents:n?"all":"none",zIndex:n?"":"-1",boxShadow:Bx(i)},srcDoc:`
|
|
142
|
-
<html>
|
|
143
|
-
<head>
|
|
144
|
-
<base target="_blank">
|
|
145
|
-
</head>
|
|
146
|
-
<body>
|
|
147
|
-
<script src=${`https://gist.github.com/${e}.js${t?`?file=${t}`:""}`}><\/script>
|
|
148
|
-
<style type="text/css">
|
|
149
|
-
* { margin: 0px; }
|
|
150
|
-
table { height: 100%; background-color: red; }
|
|
151
|
-
.gist { background-color: none; height: 100%; }
|
|
152
|
-
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
|
|
153
|
-
</style>
|
|
154
|
-
</body>
|
|
155
|
-
</html>`})}const TV=x.forwardRef(({id:e,name:t,isEditing:n},r)=>{const o=z(),s=x.useCallback(c=>{c.key==="Enter"&&!c.nativeEvent.isComposing&&(Kt(c),c.currentTarget.blur(),o.setEditingShape(null))},[o]),i=x.useCallback(c=>{const l=o.getShape(e);if(!l)return;const u=l.props.name,d=c.currentTarget.value.trim();u!==d&&o.updateShapes([{id:e,type:"frame",props:{name:d}}])},[e,o]),a=x.useCallback(c=>{const l=o.getShape(e);if(!l)return;const u=l.props.name,d=c.currentTarget.value;u!==d&&o.updateShapes([{id:e,type:"frame",props:{name:d}}])},[e,o]);return h.jsxs("div",{className:`tl-frame-label ${n?"tl-frame-label__editing":""}`,children:[h.jsx("input",{className:"tl-frame-name-input",ref:r,style:{display:n?void 0:"none"},value:t,autoFocus:!0,onKeyDown:s,onBlur:i,onChange:a}),I$(t,"Frame")+""]})}),$V=function({id:t,name:n,width:r,height:o}){const s=z(),i=K("shape rotation",()=>ks(s.getShapePageTransform(t).rotation()),[s,t]),a=Uf(t),c=x.useRef(null),l=x.useCallback(y=>{const g=_n(y);s.getEditingShapeId()!==t&&(s.dispatch({type:"pointer",name:"pointer_down",target:"shape",shape:s.getShape(t),...g}),y.preventDefault())},[s,t]);x.useEffect(()=>{const y=c.current;y&&a&&(y.focus(),y.select(),requestAnimationFrame(()=>{document.activeElement!==y&&(y.focus(),y.select())}))},[c,a]);const d=((i+Math.PI/4)*(2/Math.PI)+4)%4,p=["top","left","bottom","right"][Math.floor(d)];let f;switch(p){case"top":f="";break;case"right":f=`translate(${j(r)}px, 0px) rotate(90deg)`;break;case"bottom":f=`translate(${j(r)}px, ${j(o)}px) rotate(180deg)`;break;case"left":f=`translate(0px, ${j(o)}px) rotate(270deg)`;break}return h.jsx("div",{className:"tl-frame-heading",style:{overflow:a?"visible":"hidden",maxWidth:`calc(var(--tl-zoom) * ${Math.ceil(p==="top"||p==="bottom"?r:o)}px + var(--space-5))`,bottom:"100%",transform:`${f} scale(var(--tl-scale)) translateX(calc(-1 * var(--space-3))`},onPointerDown:l,children:h.jsx("div",{className:"tl-frame-heading-hit-area",children:h.jsx(TV,{ref:c,id:t,name:n,isEditing:a})})})};function I$(e,t){return e.match(/^\s*$/)?t:e}class Ah extends vc{constructor(){super(...arguments);m(this,"canBind",()=>!0);m(this,"canEdit",()=>!0);m(this,"canReceiveNewChildrenOfType",(n,r)=>!n.isLocked);m(this,"canDropShapes",(n,r)=>!n.isLocked);m(this,"onDragShapesOver",(n,r)=>{r.every(o=>o.parentId===n.id)||this.editor.reparentShapes(r,n.id)});m(this,"onDragShapesOut",(n,r)=>{const o=this.editor.getShape(n.parentId);o&&this.editor.isShapeOfType(o,"group")?this.editor.reparentShapes(r,o.id):this.editor.reparentShapes(r,this.editor.getCurrentPageId())});m(this,"onResize",(n,r)=>t2(n,r))}getDefaultProps(){return{w:160*2,h:90*2,name:""}}getGeometry(n){return new Vo({width:n.props.w,height:n.props.h,isFilled:!1})}component(n){const r=this.editor.getShapeGeometry(n).bounds,o=Pt(),s=K("is creating this shape",()=>{const i=this.editor.getStateDescendant("select.resizing");if(!i||!i.getIsActive())return!1;const a=i==null?void 0:i.info;return a?a.isCreating&&this.editor.getOnlySelectedShapeId()===n.id:!1},[n.id]);return h.jsxs(h.Fragment,{children:[h.jsx(Bs,{children:h.jsx("rect",{className:ue("tl-frame__body",{"tl-frame__creating":s}),width:r.width,height:r.height,fill:o.solid,stroke:o.text})}),s?null:h.jsx($V,{id:n.id,name:n.props.name,width:r.width,height:r.height})]})}toSvg(n,r){const o=Jo({isDarkMode:r.isDarkMode}),a=((ks(this.editor.getShapePageTransform(n.id).rotation())+Math.PI/4)*(2/Math.PI)+4)%4,c=Math.floor(a);let l;switch(c){case 0:l="";break;case 3:l=`translate(${j(n.props.w)}, 0) rotate(90)`;break;case 2:l=`translate(${j(n.props.w)}, ${j(n.props.h)}) rotate(180)`;break;case 1:l=`translate(0, ${j(n.props.h)}) rotate(270)`;break;default:throw Error("labelSide out of bounds")}const u={fontSize:12,fontFamily:"Inter, sans-serif",textAlign:"start",width:n.props.w,height:32,padding:0,lineHeight:1,fontStyle:"normal",fontWeight:"normal",overflow:"truncate-ellipsis",verticalTextAlign:"middle"},d=this.editor.textMeasure.measureTextSpans(I$(n.props.name,"Frame")+"",u),p=d[0],f=Bt(d),y=f.box.w+f.box.x-p.box.x,g=cv(this.editor,d,{offsetY:-u.height-2,...u});return h.jsxs(h.Fragment,{children:[h.jsx("rect",{width:n.props.w,height:n.props.h,fill:o.solid,stroke:o.black.solid,strokeWidth:1,rx:1,ry:1}),h.jsxs("g",{transform:l,children:[h.jsx("rect",{x:-8,y:-u.height-4,width:y+16,height:u.height,fill:o.background,rx:4,ry:4}),g]})]})}indicator(n){const r=this.editor.getShapeGeometry(n).bounds;return h.jsx("rect",{width:j(r.width),height:j(r.height),className:"tl-frame-indicator"})}providesBackgroundForChildren(){return!0}}m(Ah,"type","frame"),m(Ah,"props",IE),m(Ah,"migrations",EE);function dv(e){let t="M";const n=e.length;let r,o,s;for(let i=0,a=n;i<a;i+=3)r=e[i],o=e[i+1],s=e[i+2],t+=`${_e(r)}L${_e(o)}Q${_e(s)}`;return t+=`${_e(e[0])}`,t}function hv(e,t,n,r,o){const s=[],i=go(e);let a=t[0],c;const l=t.length;for(let u=0,d=l*o;u<d;u++){c=b.AddXY(t[(u+1)%l],i()*n,i()*n);const p=b.Sub(c,a),f=b.Len(p),y=b.Div(p,f).mul(Math.min(f/4,r));s.push(b.Add(a,y),b.Add(c,y.neg()),c),a=c}return s}function E$(e,t,n){let r=`M ${_e(t[0])}L`,o=`M ${_e(t[0])}L`;const s=n/3,i=n*2,a=go(e);let c=t[0],l,u=t[0],d;const p=t.length;for(let f=0,y=p-1;f<y;f++){l=t[f+1],d=b.AddXY(t[f+1],a()*s,a()*s);const g=b.Sub(l,c),w=b.Len(g),S=b.Div(g,w).mul(Math.min(w/4,i)),v=b.Add(c,S),P=b.Add(l,S.neg()),I=b.Sub(d,u),C=b.Len(I),E=b.Div(I,C).mul(Math.min(C/4,i)),_=b.Add(u,E),k=b.Add(d,E.neg());f===y-1?(r+=`${_e(v)}L ${_e(l)}`,o+=`${_e(_)}L ${_e(d)}`):(r+=`${_e(v)}L ${_e(P)}Q ${_e(l)}`,o+=`${_e(_)}L ${_e(k)}Q ${_e(d)}`,c=l,u=d)}return[r,r+o]}function CC(e,t){const n=Math.min(e,t)/2,r=Math.max(e,t)-n*2;return Math.PI*(n*2)+2*r}function MV(e,t,n){const r=Math.min(e,t)/2,o=Math.max(e,t)-r*2,i=(Math.PI*(r*2)+2*o)/n,a=e>t?[{type:"straight",start:new b(r,0),delta:new b(1,0)},{type:"arc",center:new b(e-r,r),startAngle:-Pe/2},{type:"straight",start:new b(e-r,t),delta:new b(-1,0)},{type:"arc",center:new b(r,r),startAngle:Pe/2}]:[{type:"straight",start:new b(e,r),delta:new b(0,1)},{type:"arc",center:new b(r,t-r),startAngle:0},{type:"straight",start:new b(0,t-r),delta:new b(0,-1)},{type:"arc",center:new b(r,r),startAngle:Pe}];let c=0;const l=[];for(let u=0;u<n;u++){const d=a[0];d.type==="straight"?l.push(b.Add(d.start,b.Mul(d.delta,c))):l.push(Pi(d.center,r,d.startAngle+c/r)),c+=i;let p=d.type==="straight"?o:Pe*r;for(;c>p;)c-=p,a.push(a.shift()),p=a[0].type==="straight"?o:Pe*r}return l}const AV=(e,t,n,r,o)=>{switch(e){case"s":return t;case"m":return n;case"l":return r;case"xl":return o}};function Qf(e,t,n,r){const o=go(n),s=CC(e,t),i=Math.max(Math.ceil(s/AV(r,50,70,100,130)),6,Math.ceil(s/Math.min(e,t))),a=s/i*.2,c=Math.max(e-a*2,1),l=Math.max(t-a*2,1),u=(e-c)/2,d=(t-l)/2,p=CC(c,l)/i,f=MV(c,l,i).map(v=>v.addXY(u,d)),y=e<20?0:a*.3,g=t<20?0:a*.3,w=f.slice(0);for(let v=0;v<Math.floor(i/2);v++)w[v]=b.AddXY(w[v],o()*y,o()*g),w[i-v-1]=b.AddXY(w[i-v-1],o()*y,o()*g);const S=[];for(let v=0;v<w.length;v++){const P=v===w.length-1?0:v+1,I=w[v],C=w[P],E=f[v],_=f[P],k=b.Average([E,_]),$=b.Angle(E,_)-Math.PI/2,T=b.Dist(E,_),A=p-T,L=b.Dist(I,C)/T,R=(Math.max(u,d)+A)*L,N=b.Add(k,b.FromAngle($,R));N.x<0?N.x=0:N.x>e&&(N.x=e),N.y<0?N.y=0:N.y>t&&(N.y=t);const X=_$(I,C,N),q=b.Dist(X||b.Average([I,C]),I);S.push({leftPoint:I,rightPoint:C,arcPoint:N,center:X,radius:q})}return S}function _$(e,t,n){const r=e.x*(t.y-n.y)-e.y*(t.x-n.x)+t.x*n.y-n.x*t.y,o=(e.x*e.x+e.y*e.y)*(n.y-t.y)+(t.x*t.x+t.y*t.y)*(e.y-n.y)+(n.x*n.x+n.y*n.y)*(t.y-e.y),s=(e.x*e.x+e.y*e.y)*(t.x-n.x)+(t.x*t.x+t.y*t.y)*(n.x-e.x)+(n.x*n.x+n.y*n.y)*(e.x-t.x),i=-o/(2*r),a=-s/(2*r);return!Number.isFinite(i)||!Number.isFinite(a)?null:new b(i,a)}function jV(e,t,n,r){const o=[],s=Qf(e,t,n,r);for(const{center:i,radius:a,leftPoint:c,rightPoint:l}of s)o.push(...DV(c,l,i,a,10));return o}function Ux(e,t,n,r){const o=Qf(e,t,n,r);let s=`M${j(o[0].leftPoint.x)},${j(o[0].leftPoint.y)}`;for(const{leftPoint:i,rightPoint:a,radius:c,center:l}of o){if(l===null){s+=` L${j(a.x)},${j(a.y)}`;continue}const u=k$(i,a,l)?"0":"1";s+=` A${j(c)},${j(c)} 0 ${u},1 ${j(a.x)},${j(a.y)}`}return s+=" Z",s}function OV(e,t,n,r){const o=go(n),s=r==="s"?.5:r==="m"?.7:r==="l"?.9:1.6,i=y=>y+o()*s*2,a=Qf(e,t,n,r),u=a.reduce((y,g)=>y+b.Dist2(g.leftPoint,g.rightPoint),0)/a.length>(s*15)**2?y=>new b(i(y.x),i(y.y)):y=>y;let d=`M${j(a[0].leftPoint.x)},${j(a[0].leftPoint.y)}`,p=u(a[0].leftPoint),f=`M${j(p.x)},${j(p.y)}`;for(const{leftPoint:y,center:g,rightPoint:w,radius:S,arcPoint:v}of a){if(g===null){d+=` L${j(w.x)},${j(w.y)}`;const k=u(w);f+=` L${j(k.x)},${j(k.y)}`,p=k;continue}const P=k$(y,w,g)?"0":"1";d+=` A${j(S)},${j(S)} 0 ${P},1 ${j(w.x)},${j(w.y)}`;const I=u(w),C=u(v),E=_$(p,I,C);if(!E){f+=` L${j(I.x)},${j(I.y)}`,p=I;continue}const _=Math.abs(b.Dist(E,p));f+=` A${j(_)},${j(_)} 0 ${P},1 ${j(I.x)},${j(I.y)}`,p=I}return d+f+" Z"}function DV(e,t,n,r,o){if(n===null)return[b.From(e),b.From(t)];const s=[],i=b.Angle(n,e),a=b.Angle(n,t),c=vu(i,a);for(let l=0;l<o;l++){const u=l/(o-1),d=i+c*u,p=Pi(n,r,d);s.push(p)}return s}function k$(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)>0}function RV(e){return{size:1+e,thinning:.25,end:{taper:e},start:{taper:e},streamline:0,smoothing:1,simulatePressure:!1}}function LV(e,t,n,r){const o=go(e),s=t/2,i=n/2,a=fp(s,i),c=[],l=Re*o(),u=Re+Ue/2+Math.abs(o())*Ue,d=Math.max(16,a/10);for(let p=0;p<d;p++){const f=p/(d-1),y=l+f*u,g=Math.cos(y),w=Math.sin(y);c.push(new b(s*g+t*.5+.05*o(),i*w+n/2+.05*o(),Math.min(1,.5+Math.abs(.5-(o()>0?sn.easeInOutSine(f):sn.easeInExpo(f)))/2)))}return uo(c,RV(r))}function FV(e,t,n,r){return Mi(LV(e,t,n,r))}function pv(e,t){switch(e.geo){case"x-box":return NV(e.w,e.h,t,e.dash);case"check-box":return zV(e.w,e.h);default:return}}function NV(e,t,n,r){const o=r==="draw"?.62:0;if(r==="dashed")return[[new b(0,0),new b(e/2,t/2)],[new b(e,t),new b(e/2,t/2)],[new b(0,t),new b(e/2,t/2)],[new b(e,0),new b(e/2,t/2)]];const s=a=>Math.max(0,Math.min(e,a)),i=a=>Math.max(0,Math.min(t,a));return[[new b(s(n*o),i(n*o)),new b(s(e-n*o),i(t-n*o))],[new b(s(n*o),i(t-n*o)),new b(s(e-n*o),i(n*o))]]}function zV(e,t){const n=Math.min(e,t)*.82,r=(e-n)/2,o=(t-n)/2,s=a=>Math.max(0,Math.min(e,a)),i=a=>Math.max(0,Math.min(t,a));return[[new b(s(r+n*.25),i(o+n*.52)),new b(s(r+n*.45),i(o+n*.82))],[new b(s(r+n*.45),i(o+n*.82)),new b(s(r+n*.82),i(o+n*.22))]]}const BV=x.memo(function({dash:t,fill:n,color:r,strokeWidth:o,w:s,h:i,id:a,size:c}){const l=Pt(),u=Ux(s,i,a,c),d=Qf(s,i,a,c);return h.jsxs(h.Fragment,{children:[h.jsx(It,{theme:l,d:u,fill:n,color:r}),h.jsx("g",{strokeWidth:o,stroke:l[r].solid,fill:"none",pointerEvents:"all",children:d.map(({leftPoint:p,rightPoint:f,center:y,radius:g},w)=>{const S=y?g*ks(ks(b.Angle(y,f))-ks(b.Angle(y,p))):b.Dist(p,f),{strokeDasharray:v,strokeDashoffset:P}=Yo(S,o,{style:t,start:"outset",end:"outset"});return h.jsx("path",{d:y?`M${p.x},${p.y}A${g},${g},0,0,1,${f.x},${f.y}`:`M${p.x},${p.y}L${f.x},${f.y}`,strokeDasharray:v,strokeDashoffset:P},w)})})]})}),UV=x.memo(function({w:t,h:n,strokeWidth:r,dash:o,color:s,fill:i}){const a=Pt(),c=t/2,l=n/2,u=Math.max(0,c),d=Math.max(0,l),p=fp(u,d),{strokeDasharray:f,strokeDashoffset:y}=Yo(p<64?p*2:p,r,{style:o,snap:4,closed:!0}),g=`M${c-u},${l}a${u},${d},0,1,1,${u*2},0a${u},${d},0,1,1,-${u*2},0`;return h.jsxs(h.Fragment,{children:[h.jsx(It,{theme:a,d:g,color:s,fill:i}),h.jsx("path",{d:g,strokeWidth:r,width:j(t),height:j(n),fill:"none",stroke:a[s].solid,strokeDasharray:f,strokeDashoffset:y,pointerEvents:"all"})]})});function HV(e,t){if(t>e){const r=e/2;return`
|
|
156
|
-
M0,${r}
|
|
157
|
-
a${r},${r},0,1,1,${r*2},0
|
|
158
|
-
L${e},${t-r}
|
|
159
|
-
a${r},${r},0,1,1,-${r*2},0
|
|
160
|
-
Z`}const n=t/2;return`
|
|
161
|
-
M${n},0
|
|
162
|
-
L${e-n},0
|
|
163
|
-
a${n},${n},0,1,1,0,${n*2}
|
|
164
|
-
L${n},${t}
|
|
165
|
-
a${n},${n},0,1,1,0,${-n*2}
|
|
166
|
-
Z`}function KV(e,t){if(e>t){const r=t/2;return fp(r,r)+(e-r*2)*2}const n=e/2;return fp(n,n)+(t-n*2)*2}const WV=x.memo(function({w:t,h:n,strokeWidth:r,dash:o,color:s,fill:i}){const a=Pt(),c=HV(t,n),l=KV(t,n),{strokeDasharray:u,strokeDashoffset:d}=Yo(l<64?l*2:l,r,{style:o,snap:4,start:"outset",end:"outset",closed:!0});return h.jsxs(h.Fragment,{children:[h.jsx(It,{theme:a,d:c,color:s,fill:i}),h.jsx("path",{d:c,strokeWidth:r,width:j(t),height:j(n),fill:"none",stroke:a[s].solid,strokeDasharray:u,strokeDashoffset:d,pointerEvents:"all"})]})}),GV=x.memo(function({dash:t,fill:n,color:r,strokeWidth:o,outline:s,lines:i}){const a=Pt(),c="M"+s[0]+"L"+s.slice(1)+"Z";return h.jsxs(h.Fragment,{children:[h.jsx(It,{theme:a,d:c,fill:n,color:r}),h.jsxs("g",{strokeWidth:o,stroke:a[r].solid,fill:"none",pointerEvents:"all",children:[Array.from(Array(s.length)).map((l,u)=>{const d=s[u],p=s[(u+1)%s.length],f=b.Dist(d,p),{strokeDasharray:y,strokeDashoffset:g}=Yo(f,o,{style:t,start:"outset",end:"outset"});return h.jsx("line",{x1:d.x,y1:d.y,x2:p.x,y2:p.y,strokeDasharray:y,strokeDashoffset:g},u)}),i&&i.map(([l,u],d)=>{const p=b.Dist(l,u),{strokeDasharray:f,strokeDashoffset:y}=Yo(p,o,{style:t,start:"skip",end:"outset",snap:t==="dotted"?4:void 0});return h.jsx("path",{d:`M${l.x},${l.y}L${u.x},${u.y}`,stroke:a[r].solid,strokeWidth:o,fill:"none",strokeDasharray:f,strokeDashoffset:y},`line_fg_${d}`)})]})]})}),VV=x.memo(function({fill:t,color:n,strokeWidth:r,w:o,h:s,id:i,size:a}){const c=Pt(),l=OV(o,s,i,a);return h.jsxs(h.Fragment,{children:[h.jsx(It,{theme:c,d:l,fill:t,color:n}),h.jsx("path",{d:l,stroke:c[n].solid,strokeWidth:r,fill:"none"})]})}),YV=x.memo(function({id:t,outline:n,lines:r,fill:o,color:s,strokeWidth:i}){const a=Pt(),c=hv(t,n,i/3,i*2,2);let l=dv(c);if(r)for(const[p,f]of r)l+=`M${p.x},${p.y}L${f.x},${f.y}`;const u=hv(t,n,0,i*2,1),d=dv(u);return h.jsxs(h.Fragment,{children:[h.jsx(It,{d,fill:o,color:s,theme:a}),h.jsx("path",{d:l,stroke:a[s].solid,strokeWidth:i,fill:"none"})]})}),XV=x.memo(function({fill:t,color:n,strokeWidth:r,w:o,h:s,id:i,size:a}){const c=Pt(),l=Ux(o,s,i,a);return h.jsxs(h.Fragment,{children:[h.jsx(It,{theme:c,d:l,fill:t,color:n}),h.jsx("path",{d:l,stroke:c[n].solid,strokeWidth:r,fill:"none"})]})}),IC=x.memo(function({w:t,h:n,strokeWidth:r,fill:o,color:s}){const i=Pt(),a=t/2,c=n/2,l=Math.max(0,a),u=Math.max(0,c),d=`M${a-l},${c}a${l},${u},0,1,1,${l*2},0a${l},${u},0,1,1,-${l*2},0`;return h.jsxs(h.Fragment,{children:[h.jsx(It,{d,color:s,fill:o,theme:i}),h.jsx("path",{d,stroke:i[s].solid,strokeWidth:r,fill:"none"})]})}),EC=x.memo(function({w:t,h:n,strokeWidth:r,fill:o,color:s}){const i=Pt(),a=T$(t,n);return h.jsxs(h.Fragment,{children:[h.jsx(It,{d:a,color:s,fill:o,theme:i}),h.jsx("path",{d:a,stroke:i[s].solid,strokeWidth:r,fill:"none"})]})});function T$(e,t){let n;if(t>e){const r=e/2;n=`
|
|
167
|
-
M0,${r}
|
|
168
|
-
a${r},${r},0,1,1,${r*2},0
|
|
169
|
-
L${e},${t-r}
|
|
170
|
-
a${r},${r},0,1,1,-${r*2},0
|
|
171
|
-
Z`}else{const r=t/2;n=`
|
|
172
|
-
M${r},0
|
|
173
|
-
L${e-r},0
|
|
174
|
-
a${r},${r},0,1,1,0,${r*2}
|
|
175
|
-
L${r},${t}
|
|
176
|
-
a${r},${r},0,1,1,0,${-r*2}
|
|
177
|
-
Z`}return n}const qV=x.memo(function({outline:t,lines:n,fill:r,color:o,strokeWidth:s}){const i=Pt();let a="M"+t[0]+"L"+t.slice(1)+"Z";if(n)for(const[c,l]of n)a+=`M${c.x},${c.y}L${l.x},${l.y}`;return h.jsxs(h.Fragment,{children:[h.jsx(It,{d:a,fill:r,color:o,theme:i}),h.jsx("path",{d:a,stroke:i[o].solid,strokeWidth:s,fill:"none"})]})});function _C({shape:e}){const t=z(),{id:n,props:r}=e,{w:o,color:s,fill:i,dash:a,growY:c,size:l}=r,u=Ot[l],d=r.h+c;switch(r.geo){case"cloud":{if(a==="solid")return h.jsx(XV,{color:s,fill:i,strokeWidth:u,w:o,h:d,id:n,size:l});if(a==="dashed"||a==="dotted")return h.jsx(BV,{color:s,fill:i,strokeWidth:u,w:o,h:d,id:n,size:l,dash:a});if(a==="draw")return h.jsx(VV,{color:s,fill:i,strokeWidth:u,w:o,h:d,id:n,size:l});break}case"ellipse":{if(a==="solid")return h.jsx(IC,{strokeWidth:u,w:o,h:d,color:s,fill:i});if(a==="dashed"||a==="dotted")return h.jsx(UV,{id:n,strokeWidth:u,w:o,h:d,dash:a,color:s,fill:i});if(a==="draw")return h.jsx(IC,{strokeWidth:u,w:o,h:d,color:s,fill:i});break}case"oval":{if(a==="solid")return h.jsx(EC,{strokeWidth:u,w:o,h:d,color:s,fill:i});if(a==="dashed"||a==="dotted")return h.jsx(WV,{id:n,strokeWidth:u,w:o,h:d,dash:a,color:s,fill:i});if(a==="draw")return h.jsx(EC,{strokeWidth:u,w:o,h:d,color:s,fill:i});break}default:{const p=t.getShapeGeometry(e),f=p instanceof Br?p.children[0].vertices:p.vertices,y=pv(e.props,u);if(a==="solid")return h.jsx(qV,{fill:i,color:s,strokeWidth:u,outline:f,lines:y});if(a==="dashed"||a==="dotted")return h.jsx(GV,{dash:a,fill:i,color:s,strokeWidth:u,outline:f,lines:y});if(a==="draw")return h.jsx(YV,{id:n,fill:i,color:s,strokeWidth:u,outline:f,lines:y})}}}const ur=17*3;class jh extends vc{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"onEditEnd",n=>{const{id:r,type:o,props:{text:s}}=n;s.trimEnd()!==n.props.text&&this.editor.updateShapes([{id:r,type:o,props:{text:s.trimEnd()}}])});m(this,"onResize",(n,{handle:r,newPoint:o,scaleX:s,scaleY:i,initialShape:a})=>{let c=a.props.w*s,l=(a.props.h+a.props.growY)*i,u=0,d=0;if(n.props.text.trim()){let g=Math.max(Math.abs(c),ur),w=Math.max(Math.abs(l),ur);g<ur&&w===ur&&(g=ur),g===ur&&w<ur&&(w=ur);const S=Ad(this.editor,{...n,props:{...n.props,w:g,h:w}}),v=Math.max(Math.abs(c),S.w)*Math.sign(c),P=Math.max(Math.abs(l),S.h)*Math.sign(l);u=Math.abs(v)-Math.abs(c),d=Math.abs(P)-Math.abs(l),c=v,l=P}const p=new b(0,0);s<0&&(p.x+=c),(r==="left"||r==="top_left"||r==="bottom_left")&&(p.x+=s<0?u:-u),i<0&&(p.y+=l),(r==="top"||r==="top_left"||r==="top_right")&&(p.y+=i<0?d:-d);const{x:f,y}=p.rot(n.rotation).add(o);return{x:f,y,props:{w:Math.max(Math.abs(c),1),h:Math.max(Math.abs(l),1),growY:0}}});m(this,"onBeforeCreate",n=>{if(!n.props.text)return n.props.growY?{...n,props:{...n.props,growY:0}}:void 0;const r=n.props.h,o=Ad(this.editor,n).h;let s=null;if(o>r?s=o-r:n.props.growY&&(s=0),s!==null)return{...n,props:{...n.props,growY:s}}});m(this,"onBeforeUpdate",(n,r)=>{const o=n.props.text,s=r.props.text;if(o===s&&n.props.font===r.props.font&&n.props.size===r.props.size)return;if(o&&!s)return{...r,props:{...r.props,growY:0}};const i=n.props.w,a=n.props.h,c=Ad(this.editor,r),l=c.w,u=c.h;if(!o&&s&&s.length===1){let p=Math.max(i,l),f=Math.max(a,u);return n.props.w<ur&&n.props.h<ur&&(p=Math.max(p,ur),f=Math.max(f,ur),p=Math.max(p,f),f=Math.max(p,f)),{...r,props:{...r.props,w:p,h:f,growY:0}}}let d=null;if(u>a?d=u-a:n.props.growY&&(d=0),d!==null)return{...r,props:{...r.props,growY:d,w:Math.max(r.props.w,l)}};if(l>n.props.w)return{...r,props:{...r.props,w:l}}});m(this,"onDoubleClick",n=>{if(this.editor.inputs.altKey)switch(n.props.geo){case"rectangle":return{...n,props:{geo:"check-box"}};case"check-box":return{...n,props:{geo:"rectangle"}}}})}getDefaultProps(){return{w:100,h:100,geo:"rectangle",color:"black",labelColor:"black",fill:"none",dash:"draw",size:"m",font:"draw",text:"",align:"middle",verticalAlign:"middle",growY:0,url:""}}getGeometry(n){const r=Math.max(1,n.props.w),o=Math.max(1,n.props.h+n.props.growY),s=r/2,i=o/2,a=Ot[n.props.size],c=n.props.fill!=="none";let l;switch(n.props.geo){case"cloud":{l=new Ct({points:jV(r,o,n.id,n.props.size),isFilled:c});break}case"triangle":{l=new Ct({points:[new b(s,0),new b(r,o),new b(0,o)],isFilled:c});break}case"diamond":{l=new Ct({points:[new b(s,0),new b(r,i),new b(s,o),new b(0,i)],isFilled:c});break}case"pentagon":{l=new Ct({points:Og(r,o,5),isFilled:c});break}case"hexagon":{l=new Ct({points:Og(r,o,6),isFilled:c});break}case"octagon":{l=new Ct({points:Og(r,o,8),isFilled:c});break}case"ellipse":{l=new r2({width:r,height:o,isFilled:c});break}case"oval":{l=new R8({width:r,height:o,isFilled:c});break}case"star":{const v=Re/5/2,P=Math.floor(5/4)*2,I=5*2-P,C=0,E=Math.floor(5/2)*2,_=Math.cos(-Ue+P*v)*r/2,k=Math.cos(-Ue+I*v)*r/2,$=Math.sin(-Ue+C*v)*o/2,T=Math.sin(-Ue+E*v)*o/2,A=r-Math.abs(_-k),B=o-Math.abs(T-$),L=r/2+k-(r/2-_),R=o/2+$-(o/2-T),N=1,X=(r-L)/2,q=(o-R)/2,H=(r+A)/2,U=(o+B)/2,W=H*N/2,Q=U*N/2;l=new Ct({points:Array.from(Array(5*2)).map((le,be)=>{const Ae=-Ue+be*v;return new b(X+(be%2?W:H)*Math.cos(Ae),q+(be%2?Q:U)*Math.sin(Ae))}),isFilled:c});break}case"rhombus":{const S=Math.min(r*.38,o*.38);l=new Ct({points:[new b(S,0),new b(r,0),new b(r-S,o),new b(0,o)],isFilled:c});break}case"rhombus-2":{const S=Math.min(r*.38,o*.38);l=new Ct({points:[new b(0,0),new b(r-S,0),new b(r,o),new b(S,o)],isFilled:c});break}case"trapezoid":{const S=Math.min(r*.38,o*.38);l=new Ct({points:[new b(S,0),new b(r-S,0),new b(r,o),new b(0,o)],isFilled:c});break}case"arrow-right":{const S=Math.min(r,o)*.38,v=o*.16;l=new Ct({points:[new b(0,v),new b(r-S,v),new b(r-S,0),new b(r,o/2),new b(r-S,o),new b(r-S,o-v),new b(0,o-v)],isFilled:c});break}case"arrow-left":{const S=Math.min(r,o)*.38,v=o*.16;l=new Ct({points:[new b(S,0),new b(S,v),new b(r,v),new b(r,o-v),new b(S,o-v),new b(S,o),new b(0,o/2)],isFilled:c});break}case"arrow-up":{const S=r*.16,v=Math.min(r,o)*.38;l=new Ct({points:[new b(r/2,0),new b(r,v),new b(r-S,v),new b(r-S,o),new b(S,o),new b(S,v),new b(0,v)],isFilled:c});break}case"arrow-down":{const S=r*.16,v=Math.min(r,o)*.38;l=new Ct({points:[new b(S,0),new b(r-S,0),new b(r-S,o-v),new b(r,o-v),new b(r/2,o),new b(0,o-v),new b(S,o-v)],isFilled:c});break}case"check-box":case"x-box":case"rectangle":{l=new Vo({width:r,height:o,isFilled:c});break}}const u=Ad(this.editor,n),d=Math.min(100,r/2),p=Math.min(r,Math.max(u.w,Math.min(d,Math.max(1,r-8)))),f=Math.min(No[n.props.size]*Gt.lineHeight+Ar*2,o/2),y=Math.min(o,Math.max(u.h,Math.min(f,Math.max(1,r-8)))),g=pv(n.props,a),w=g?g.map(S=>new Ui({points:S})):[];return new Br({children:[l,new Vo({x:n.props.align==="start"?0:n.props.align==="end"?r-p:(r-p)/2,y:n.props.verticalAlign==="start"?0:n.props.verticalAlign==="end"?o-y:(o-y)/2,width:p,height:y,isFilled:!0,isLabel:!0}),...w]})}getHandleSnapGeometry(n){const r=this.getGeometry(n),o=r.children[0];switch(n.props.geo){case"arrow-down":case"arrow-left":case"arrow-right":case"arrow-up":case"check-box":case"diamond":case"hexagon":case"octagon":case"pentagon":case"rectangle":case"rhombus":case"rhombus-2":case"star":case"trapezoid":case"triangle":case"x-box":return{outline:o,points:[...o.getVertices(),r.bounds.center]};case"cloud":case"ellipse":case"oval":return{outline:o,points:[r.bounds.center]};default:fn(n.props.geo)}}component(n){const{id:r,type:o,props:s}=n,{fill:i,font:a,align:c,verticalAlign:l,size:u,text:d}=s,p=n.id===this.editor.getOnlySelectedShapeId(),f=Pt(),g=this.editor.getEditingShapeId()!==null||n.props.text;return h.jsxs(h.Fragment,{children:[h.jsx(Bs,{id:r,children:h.jsx(_C,{shape:n})}),g&&h.jsx($i,{style:{overflow:"hidden",width:n.props.w,height:n.props.h+s.growY},children:h.jsx(Zf,{id:r,type:o,font:a,fontSize:No[u],lineHeight:Gt.lineHeight,fill:i,align:c,verticalAlign:l,text:d,isSelected:p,labelColor:f[s.labelColor].solid,wrap:!0})}),n.props.url&&h.jsx(ic,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]})}indicator(n){const{id:r,props:o}=n,{w:s,size:i}=o,a=o.h+o.growY,c=Ot[i];switch(o.geo){case"ellipse":return o.dash==="draw"?h.jsx("path",{d:FV(r,s,a,c)}):h.jsx("ellipse",{cx:s/2,cy:a/2,rx:s/2,ry:a/2});case"oval":return h.jsx("path",{d:T$(s,a)});case"cloud":return h.jsx("path",{d:Ux(s,a,r,i)});default:{const l=this.editor.getShapeGeometry(n),u=l instanceof Br?l.children[0].vertices:l.vertices;let d;if(o.dash==="draw"){const f=hv(r,u,0,c*2,1);d=dv(f)}else d="M"+u[0]+"L"+u.slice(1)+"Z";const p=pv(n.props,c);if(p)for(const[f,y]of p)d+=`M${f.x},${f.y}L${y.x},${y.y}`;return h.jsx("path",{d})}}}toSvg(n,r){const{props:o}=n;r.addExportDef(Fx(n.props.fill));let s;if(o.text){r.addExportDef(sc(n.props.font));const i=Jo(r),a=this.editor.getShapeGeometry(n).bounds;s=h.jsx(qf,{fontSize:No[o.size],font:o.font,align:o.align,verticalAlign:o.verticalAlign,text:o.text,labelColor:i[o.labelColor].solid,bounds:a})}return h.jsxs(h.Fragment,{children:[h.jsx(_C,{shape:n}),s]})}getCanvasSvgDefs(){return[Nx()]}}m(jh,"type","geo"),m(jh,"props",_E),m(jh,"migrations",kE);function Ad(e,t){const n=t.props.text;if(!n)return{w:0,h:0};const r=e.textMeasure.measureText("w",{...Gt,fontFamily:ao[t.props.font],fontSize:No[t.props.size],maxWidth:100}),o={s:2,m:3.5,l:5,xl:10},s=e.textMeasure.measureText(n,{...Gt,fontFamily:ao[t.props.font],fontSize:No[t.props.size],minWidth:r.w,maxWidth:Math.max(0,Math.ceil(r.w+o[t.props.size]),Math.ceil(t.props.w-Ar*2))});return{w:s.w+Ar*2,h:s.h+Ar*2}}function ZV(){const[e,t]=x.useState(!1);return x.useEffect(()=>{const r=CSS.supports("color","color(display-p3 1 1 1)"),o=matchMedia("(color-gamut: p3)");t(r&&o.matches);const s=()=>t(r&&o.matches);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[]),K(jt.forceSrgb)||!e?"srgb":"p3"}const kC=.35,TC=.82;class Oh extends Nr{constructor(){super(...arguments);m(this,"hideResizeHandles",n=>Od(n));m(this,"hideRotateHandle",n=>Od(n));m(this,"hideSelectionBoundsFg",n=>Od(n));m(this,"onResize",(n,r)=>{const{scaleX:o,scaleY:s}=r,i=[];for(const a of n.props.segments)i.push({...a,points:a.points.map(({x:c,y:l,z:u})=>({x:o*c,y:s*l,z:u}))});return{props:{segments:i}}})}getDefaultProps(){return{segments:[],color:"black",size:"m",isComplete:!1,isPen:!1}}getGeometry(n){const r=oa(n);if(Od(n))return new hx({x:-r/2,y:-r/2,radius:r/2,isFilled:!0});const{strokePoints:o,sw:s}=$$(n,r,!0),i=lv({strokeWidth:s,showAsComplete:!0});return Xf(o,i),new Ct({points:Ox(o,i),isFilled:!0})}component(n){return h.jsx(Bs,{id:n.id,style:{opacity:kC},children:h.jsx(jd,{strokeWidth:oa(n),shape:n})})}backgroundComponent(n){return h.jsx(Bs,{id:n.id,style:{opacity:TC},children:h.jsx(jd,{strokeWidth:oa(n),shape:n})})}indicator(n){var d;const r=ou(),o=oa(n),s=su(n.props.segments);let i=o;!r&&!n.props.isPen&&s.length===1&&(i+=go(n.id)()*(o/6));const a=n.props.isComplete||((d=Bt(n.props.segments))==null?void 0:d.type)==="straight",c=lv({strokeWidth:o,showAsComplete:a}),l=uo(s,c);let u;return l.length<2?u=JV(s[0],i):u=Mi(l,!1),h.jsx("path",{d:u})}toSvg(n){return h.jsx(jd,{strokeWidth:oa(n),shape:n,opacity:kC})}toBackgroundSvg(n){return h.jsx(jd,{strokeWidth:oa(n),shape:n,opacity:TC})}}m(Oh,"type","highlight"),m(Oh,"props",ME),m(Oh,"migrations",AE);function QV(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 JV(e,t){const n=t/2;return`M ${e.x} ${e.y} m -${n}, 0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0`}function $$(e,t,n){var c;const r=su(e.props.segments),o=e.props.isComplete||((c=Bt(e.props.segments))==null?void 0:c.type)==="straight";let s=t;!n&&!e.props.isPen&&r.length===1&&(s+=go(e.id)()*(t/6));const i=lv({strokeWidth:s,showAsComplete:o});return{strokePoints:uo(r,i),sw:s}}function eY(e,t,n){const{strokePoints:r,sw:o}=$$(e,t,n);return{solidStrokePath:r.length>1?Mi(r,!1):QV(e.props.segments[0].points[0]),sw:o}}function jd({strokeWidth:e,shape:t,opacity:n}){const r=Pt(),o=ou(),{solidStrokePath:s,sw:i}=eY(t,e,o),a=ZV(),c=r[t.props.color].highlight[a];return h.jsx("path",{d:s,strokeLinecap:"round",fill:"none",pointerEvents:"all",stroke:c,strokeWidth:i,opacity:n})}function oa(e){return nc[e.props.size]*1.12}function Od(e){return e.props.segments.length===1&&e.props.segments[0].points.length<2}function M$(){return h.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 30 30",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h.jsx("path",{d:"M3,11 L3,3 11,3",strokeWidth:"2"}),h.jsx("path",{d:"M19,27 L27,27 L27,19",strokeWidth:"2"}),h.jsx("path",{d:"M27,3 L3,27",strokeWidth:"2"})]})}function A$(){const[e,t]=x.useState(!1);return x.useEffect(()=>{const n=window.matchMedia("(prefers-reduced-motion: reduce)"),r=()=>{t(n.matches)};return r(),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),e}async function tY(e){const n=await(await fetch(e)).blob();return Oa.blobToDataUrl(n)}class Dh extends vc{constructor(){super(...arguments);m(this,"isAspectRatioLocked",()=>!0);m(this,"canCrop",()=>!0);m(this,"onDoubleClick",n=>{const r=n.props.assetId?this.editor.getAsset(n.props.assetId):void 0;!r||!(r.props.src&&"mimeType"in r.props&&r.props.mimeType==="image/gif")||this.editor.updateShapes([{type:"image",id:n.id,props:{playing:!n.props.playing}}])});m(this,"onDoubleClickEdge",n=>{const r=n.props;if(!r||this.editor.getCroppingShapeId()!==n.id)return;const o=Ge(r.crop)||{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},s=1/(o.bottomRight.x-o.topLeft.x)*n.props.w,i=1/(o.bottomRight.y-o.topLeft.y)*n.props.h,a=new b(o.topLeft.x*s,o.topLeft.y*i).rot(n.rotation),c={id:n.id,type:n.type,x:n.x-a.x,y:n.y-a.y,props:{crop:{topLeft:{x:0,y:0},bottomRight:{x:1,y:1}},w:s,h:i}};this.editor.updateShapes([c])})}getDefaultProps(){return{w:100,h:100,assetId:null,playing:!0,url:"",crop:null}}component(n){var p,f;const r=this.editor.getCroppingShapeId()===n.id,o=A$(),[s,i]=x.useState(""),a=n.props.assetId?this.editor.getAsset(n.props.assetId):void 0,c=n.id===this.editor.getOnlySelectedShapeId();if(x.useEffect(()=>{if(a!=null&&a.props.src&&"mimeType"in a.props&&(a==null?void 0:a.props.mimeType)==="image/gif"){let y=!1;const g=a.props.src;if(!g)return;const w=new Image;return w.onload=()=>{if(y)return;const S=document.createElement("canvas");S.width=w.width,S.height=w.height;const v=S.getContext("2d");v&&(v.drawImage(w,0,0),i(S.toDataURL()))},w.crossOrigin="anonymous",w.src=g,()=>{y=!0}}},[o,a==null?void 0:a.props]),(a==null?void 0:a.type)==="bookmark")throw Error("Bookmark assets can't be rendered as images");const l=c&&r&&this.editor.isInAny("select.crop","select.cropping","select.pointing_crop_handle"),u=o&&(((p=a==null?void 0:a.props.mimeType)==null?void 0:p.includes("video"))||((f=a==null?void 0:a.props.mimeType)==null?void 0:f.includes("gif"))),d=$C(n);return a!=null&&a.props.src?h.jsxs(h.Fragment,{children:[l&&h.jsx("div",{style:d,children:h.jsx("div",{className:"tl-image",style:{opacity:.1,backgroundImage:`url(${!n.props.playing||u?s:a.props.src})`},draggable:!1})}),h.jsxs($i,{id:n.id,style:{overflow:"hidden",width:n.props.w,height:n.props.h},children:[h.jsxs("div",{className:"tl-image-container",style:d,children:[h.jsx("div",{className:"tl-image",style:{backgroundImage:`url(${!n.props.playing||u?s:a.props.src})`},draggable:!1}),a.props.isAnimated&&!n.props.playing&&h.jsx("div",{className:"tl-image__tg",children:"GIF"})]}),")",n.props.url&&h.jsx(ic,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]})]}):h.jsxs($i,{id:n.id,style:{overflow:"hidden",width:n.props.w,height:n.props.h,color:"var(--color-text-3)",backgroundColor:a?"transparent":"var(--color-low)",border:a?"none":"1px solid var(--color-low-border)"},children:[h.jsx("div",{className:"tl-image-container",style:d,children:a?null:h.jsx(M$,{})}),")","url"in n.props&&n.props.url&&h.jsx(ic,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]})}indicator(n){return this.editor.getCroppingShapeId()===n.id?null:h.jsx("rect",{width:j(n.props.w),height:j(n.props.h)})}async toSvg(n){const r=n.props.assetId?this.editor.getAsset(n.props.assetId):null;if(!r)return null;let o=(r==null?void 0:r.props.src)||"";(o.startsWith("http")||o.startsWith("/")||o.startsWith("./"))&&(o=await tY(o)||"");const s=$C(n),i=n.props.crop;if(s.transform&&i){const{transform:a,width:c,height:l}=s,u=(i.bottomRight.x-i.topLeft.x)*c,d=(i.bottomRight.y-i.topLeft.y)*l,p=[new b(0,0),new b(u,0),new b(u,d),new b(0,d)],f=`cropClipPath_${n.id.replace(":","_")}`;return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("clipPath",{id:f,children:h.jsx("polygon",{points:p.map(y=>`${y.x},${y.y}`).join(" ")})})}),h.jsx("g",{clipPath:"url(#{cropClipId})",children:h.jsx("image",{href:o,width:c,height:l,style:{transform:a}})})]})}else return h.jsx("image",{href:o,width:n.props.w,height:n.props.h})}}m(Dh,"type","image"),m(Dh,"props",jE),m(Dh,"migrations",OE);function $C(e){const t=e.props.crop,n=t==null?void 0:t.topLeft;if(!n)return{width:e.props.w,height:e.props.h};const r=1/(t.bottomRight.x-t.topLeft.x)*e.props.w,o=1/(t.bottomRight.y-t.topLeft.y)*e.props.h,s=-n.x*r,i=-n.y*o;return{transform:`translate(${s}px, ${i}px)`,width:r,height:o}}function j$(e,t){const{start:n,end:r}=e;return t?`M${j(n.x)},${j(n.y)} L${j(r.x)},${j(r.y)} `:`${j(r.x)},${j(r.y)} `}function O$(e,t){const{a:n,b:r,c:o,d:s}=e;return b.Equals(n,s)?"":`${t?`M${j(n.x)},${j(n.y)}`:""}C${j(r.x)},${j(r.y)} ${j(o.x)},${j(o.y)} ${j(s.x)},${j(s.y)}`}function nY(e,t){let n=e.segments.reduce((r,o,s)=>r+O$(o,s===0),"");return t&&(n+="Z"),n}function rY(e,t){let n=e.segments.reduce((r,o,s)=>r+j$(o,s===0),"");return t&&(n+="Z"),n}function D$(e,t=!1){return e instanceof Ui?rY(e,t):nY(e,t)}function R$(e){return{size:e,thinning:.4,streamline:0,smoothing:.5,simulatePressure:!0,last:!0}}function L$(e,t,n){const r=t.vertices,o=R$(n);return uo(r,o)}function oY(e,t,n){const r=R$(n);return Ox(Xf(L$(e,t,n),r),r)}function sY(e,t,n){const r=oY(e,t,n);return c0(r)}function iY(e,t,n){if(e.props.dash==="draw"){const r=L$(e,t,n);return Mi(r)}return D$(t)}const aY=new Rf;class Rh extends Nr{constructor(){super(...arguments);m(this,"hideResizeHandles",()=>!0);m(this,"hideRotateHandle",()=>!0);m(this,"hideSelectionBoundsFg",()=>!0);m(this,"hideSelectionBoundsBg",()=>!0);m(this,"onResize",(n,r)=>{const{scaleX:o,scaleY:s}=r;return{props:{points:df(n.props.points,(i,{id:a,index:c,x:l,y:u})=>({id:a,index:c,x:l*o,y:u*s}))}}});m(this,"onHandleDrag",(n,{handle:r})=>{if(r.type==="vertex")return{...n,props:{...n.props,points:{...n.props.points,[r.id]:{id:r.id,index:r.index,x:r.x,y:r.y}}}}})}getDefaultProps(){const[n,r]=Al(2);return{dash:"draw",size:"m",color:"black",spline:"line",points:{[n]:{id:n,index:n,x:0,y:0},[r]:{id:r,index:r,x:.1,y:.1}}}}getGeometry(n){return hl(n)}getHandles(n){return aY.get(n.props,()=>{const r=hl(n),o=fv(n),s=o.map(i=>({...i,id:i.index,type:"vertex",canSnap:!0}));for(let i=0;i<o.length-1;i++){const a=fl(o[i].index,o[i+1].index),l=r.segments[i].midPoint();s.push({id:a,type:"create",index:a,x:l.x,y:l.y,canSnap:!0})}return s.sort(rn)})}component(n){return h.jsx(Bs,{id:n.id,children:h.jsx(MC,{shape:n})})}indicator(n){const r=Ot[n.props.size],o=hl(n),{dash:s}=n.props;let i;if(n.props.spline==="line"){const a=o.points;if(s==="solid"||s==="dotted"||s==="dashed")i="M"+a[0]+"L"+a.slice(1);else{const[c]=E$(n.id,a,r);i=c}}else i=iY(n,o,r);return h.jsx("path",{d:i})}toSvg(n){return h.jsx(MC,{shape:n})}getHandleSnapGeometry(n){const r=fv(n);return{points:r,getSelfSnapPoints:o=>{const s=this.getHandles(n).filter(i=>i.type==="vertex").findIndex(i=>i.id===o.id);return r.filter((i,a)=>Math.abs(a-s)>1).map(b.From)},getSelfSnapOutline:o=>{const s=this.getHandles(n).filter(a=>a.type==="vertex").findIndex(a=>a.id===o.id),i=hl(n).segments.filter((a,c)=>c!==s-1&&c!==s);return i.length?new Br({children:i}):null}}}}m(Rh,"type","line"),m(Rh,"props",DE),m(Rh,"migrations",RE);function fv(e){return Object.values(e.props.points).sort(rn)}function hl(e){const t=fv(e).map(b.From);switch(e.props.spline){case"cubic":return new D8({points:t});case"line":return new Ui({points:t})}}function MC({shape:e}){const t=Pt(),n=hl(e),r=Ot[e.props.size],{dash:o,color:s}=e.props;if(e.props.spline==="line"){if(o==="solid"){const i=n.points,a="M"+i[0]+"L"+i.slice(1);return h.jsxs(h.Fragment,{children:[h.jsx(It,{d:a,fill:"none",color:s,theme:t}),h.jsx("path",{d:a,stroke:t[s].solid,strokeWidth:r,fill:"none"})]})}if(o==="dashed"||o==="dotted"){const i=n.points,a="M"+i[0]+"L"+i.slice(1);return h.jsxs(h.Fragment,{children:[h.jsx(It,{d:a,fill:"none",color:s,theme:t}),h.jsx("g",{stroke:t[s].solid,strokeWidth:r,children:n.segments.map((c,l)=>{const{strokeDasharray:u,strokeDashoffset:d}=Yo(c.length,r,{style:o,start:l>0?"outset":"none",end:l<n.segments.length-1?"outset":"none"});return h.jsx("path",{strokeDasharray:u,strokeDashoffset:d,d:j$(c,!0),fill:"none"},l)})})]})}if(o==="draw"){const i=n.points,[a,c]=E$(e.id,i,r);return h.jsxs(h.Fragment,{children:[h.jsx(It,{d:a,fill:"none",color:s,theme:t}),h.jsx("path",{d:c,stroke:t[s].solid,strokeWidth:r,fill:"none"})]})}}if(e.props.spline==="cubic"){const i=D$(n);if(o==="solid")return h.jsxs(h.Fragment,{children:[h.jsx(It,{d:i,fill:"none",color:s,theme:t}),h.jsx("path",{strokeWidth:r,stroke:t[s].solid,fill:"none",d:i})]});if(o==="dashed"||o==="dotted")return h.jsxs(h.Fragment,{children:[h.jsx(It,{d:i,fill:"none",color:s,theme:t}),h.jsx("g",{stroke:t[s].solid,strokeWidth:r,children:n.segments.map((a,c)=>{const{strokeDasharray:l,strokeDashoffset:u}=Yo(a.length,r,{style:o,start:c>0?"outset":"none",end:c<n.segments.length-1?"outset":"none"});return h.jsx("path",{strokeDasharray:l,strokeDashoffset:u,d:O$(a,!0),fill:"none"},c)})})]});if(o==="draw")return h.jsxs(h.Fragment,{children:[h.jsx(It,{d:i,fill:"none",color:s,theme:t}),h.jsx("path",{d:sY(e,n,r),strokeWidth:1,stroke:t[s].solid,fill:t[s].solid})]})}}const F$=x.createContext(null);function cY({assetUrls:e,children:t}){return x.useEffect(()=>{for(const n of Object.values(e.icons)){const r=new Image;r.src=n,r.decode()}for(const n of Object.values(e.embedIcons)){const r=new Image;r.src=n,r.decode()}},[e]),h.jsx(F$.Provider,{value:e,children:t})}function Hx(){const e=x.useContext(F$);if(!e)throw new Error("useAssetUrls must be used within an AssetUrlsProvider");return e}const gv={"action.convert-to-bookmark":"Convert to Bookmark","action.convert-to-embed":"Convert to Embed","action.open-embed-link":"Open link","action.align-bottom":"Align bottom","action.align-center-horizontal":"Align horizontally","action.align-center-vertical":"Align vertically","action.align-center-horizontal.short":"Align H","action.align-center-vertical.short":"Align V","action.align-left":"Align left","action.align-right":"Align right","action.align-top":"Align top","action.back-to-content":"Back to content","action.bring-forward":"Bring forward","action.bring-to-front":"Bring to front","action.copy-as-json.short":"JSON","action.copy-as-json":"Copy as JSON","action.copy-as-png.short":"PNG","action.copy-as-png":"Copy as PNG","action.copy-as-svg.short":"SVG","action.copy-as-svg":"Copy as SVG","action.copy":"Copy","action.cut":"Cut","action.delete":"Delete","action.unlock-all":"Unlock all","action.distribute-horizontal":"Distribute horizontally","action.distribute-vertical":"Distribute vertically","action.distribute-horizontal.short":"Distribute H","action.distribute-vertical.short":"Distribute V","action.duplicate":"Duplicate","action.edit-link":"Edit link","action.exit-pen-mode":"Exit pen mode","action.export-as-json.short":"JSON","action.export-as-json":"Export as JSON","action.export-as-png.short":"PNG","action.export-as-png":"Export as PNG","action.export-as-svg.short":"SVG","action.export-as-svg":"Export as SVG","action.export-all-as-json.short":"JSON","action.export-all-as-json":"Export as JSON","action.export-all-as-png.short":"PNG","action.export-all-as-png":"Export as PNG","action.export-all-as-svg.short":"SVG","action.export-all-as-svg":"Export as SVG","action.fit-frame-to-content":"Fit to content","action.flip-horizontal":"Flip horizontally","action.flip-vertical":"Flip vertically","action.flip-horizontal.short":"Flip H","action.flip-vertical.short":"Flip V","action.fork-project":"Fork this project","action.fork-project-on-tldraw":"Fork project on tldraw","action.group":"Group","action.insert-embed":"Insert embed","action.insert-media":"Upload media","action.leave-shared-project":"Leave shared project","action.new-project":"New project","action.new-shared-project":"New shared project","action.open-cursor-chat":"Cursor chat","action.open-file":"Open file","action.pack":"Pack","action.paste":"Paste","action.print":"Print","action.redo":"Redo","action.remove-frame":"Remove frame","action.rename":"Rename","action.rotate-ccw":"Rotate counterclockwise","action.rotate-cw":"Rotate clockwise","action.save-copy":"Save a copy","action.select-all":"Select all","action.select-none":"Select none","action.send-backward":"Send backward","action.send-to-back":"Send to back","action.share-project":"Share this project","action.stack-horizontal":"Stack horizontally","action.stack-vertical":"Stack vertically","action.stack-horizontal.short":"Stack H","action.stack-vertical.short":"Stack V","action.stop-following":"Stop following","action.stretch-horizontal":"Stretch horizontally","action.stretch-vertical":"Stretch vertically","action.stretch-horizontal.short":"Stretch H","action.stretch-vertical.short":"Stretch V","action.toggle-auto-size":"Toggle auto size","action.toggle-dark-mode.menu":"Dark mode","action.toggle-dark-mode":"Toggle dark mode","action.toggle-wrap-mode.menu":"Select on wrap","action.toggle-wrap-mode":"Toggle Select on wrap","action.toggle-reduce-motion.menu":"Reduce motion","action.toggle-reduce-motion":"Toggle reduce motion","action.toggle-edge-scrolling.menu":"Edge scrolling","action.toggle-edge-scrolling":"Toggle edge scrolling","action.toggle-debug-mode.menu":"Debug mode","action.toggle-debug-mode":"Toggle debug mode","action.toggle-focus-mode.menu":"Focus mode","action.toggle-focus-mode":"Toggle focus mode","action.toggle-grid.menu":"Show grid","action.toggle-grid":"Toggle grid","action.toggle-lock":"Toggle locked","action.toggle-snap-mode.menu":"Always snap","action.toggle-snap-mode":"Toggle always snap","action.toggle-tool-lock.menu":"Tool lock","action.toggle-tool-lock":"Toggle tool lock","action.toggle-transparent.context-menu":"Transparent","action.toggle-transparent.menu":"Transparent","action.toggle-transparent":"Toggle transparent background","action.undo":"Undo","action.ungroup":"Ungroup","action.zoom-in":"Zoom in","action.zoom-out":"Zoom out","action.zoom-to-100":"Zoom to 100%","action.zoom-to-fit":"Zoom to fit","action.zoom-to-selection":"Zoom to selection","assets.files.upload-failed":"Upload failed","assets.url.failed":"Couldn't load URL preview","color-style.white":"White","color-style.black":"Black","color-style.blue":"Blue","color-style.green":"Green","color-style.grey":"Grey","color-style.light-blue":"Light blue","color-style.light-green":"Light green","color-style.light-red":"Light red","color-style.light-violet":"Light violet","color-style.orange":"Orange","color-style.red":"Red","color-style.violet":"Violet","color-style.yellow":"Yellow","fill-style.none":"None","document.default-name":"Untitled","fill-style.semi":"Semi","fill-style.solid":"Solid","fill-style.pattern":"Pattern","dash-style.dashed":"Dashed","dash-style.dotted":"Dotted","dash-style.draw":"Draw","dash-style.solid":"Solid","size-style.s":"Small","size-style.m":"Medium","size-style.l":"Large","size-style.xl":"Extra large","opacity-style.0.1":"10%","opacity-style.0.25":"25%","opacity-style.0.5":"50%","opacity-style.0.75":"75%","opacity-style.1":"100%","font-style.draw":"Draw","font-style.sans":"Sans","font-style.serif":"Serif","font-style.mono":"Mono","align-style.start":"Start","align-style.middle":"Middle","align-style.end":"End","align-style.justify":"Justify","verticalAlign-style.start":"Top","verticalAlign-style.middle":"Middle","verticalAlign-style.end":"Bottom","geo-style.arrow-down":"Arrow down","geo-style.arrow-left":"Arrow left","geo-style.arrow-right":"Arrow right","geo-style.arrow-up":"Arrow up","geo-style.diamond":"Diamond","geo-style.ellipse":"Ellipse","geo-style.hexagon":"Hexagon","geo-style.octagon":"Octagon","geo-style.oval":"Oval","geo-style.cloud":"Cloud","geo-style.pentagon":"Pentagon","geo-style.rectangle":"Rectangle","geo-style.rhombus-2":"Rhombus 2","geo-style.rhombus":"Rhombus","geo-style.star":"Star","geo-style.trapezoid":"Trapezoid","geo-style.triangle":"Triangle","geo-style.x-box":"X box","geo-style.check-box":"Check box","arrowheadStart-style.none":"None","arrowheadStart-style.arrow":"Arrow","arrowheadStart-style.bar":"Bar","arrowheadStart-style.diamond":"Diamond","arrowheadStart-style.dot":"Dot","arrowheadStart-style.inverted":"Inverted","arrowheadStart-style.pipe":"Pipe","arrowheadStart-style.square":"Square","arrowheadStart-style.triangle":"Triangle","arrowheadEnd-style.none":"None","arrowheadEnd-style.arrow":"Arrow","arrowheadEnd-style.bar":"Bar","arrowheadEnd-style.diamond":"Diamond","arrowheadEnd-style.dot":"Dot","arrowheadEnd-style.inverted":"Inverted","arrowheadEnd-style.pipe":"Pipe","arrowheadEnd-style.square":"Square","arrowheadEnd-style.triangle":"Triangle","spline-style.line":"Line","spline-style.cubic":"Cubic","tool.select":"Select","tool.hand":"Hand","tool.draw":"Draw","tool.eraser":"Eraser","tool.arrow-down":"Arrow down","tool.arrow-left":"Arrow left","tool.arrow-right":"Arrow right","tool.arrow-up":"Arrow up","tool.arrow":"Arrow","tool.cloud":"Cloud","tool.diamond":"Diamond","tool.ellipse":"Ellipse","tool.hexagon":"Hexagon","tool.highlight":"Highlight","tool.line":"Line","tool.octagon":"Octagon","tool.oval":"Oval","tool.pentagon":"Pentagon","tool.rectangle":"Rectangle","tool.rhombus":"Rhombus","tool.star":"Star","tool.trapezoid":"Trapezoid","tool.triangle":"Triangle","tool.x-box":"X box","tool.check-box":"Check box","tool.asset":"Asset","tool.frame":"Frame","tool.note":"Note","tool.laser":"Laser","tool.embed":"Embed","tool.text":"Text","menu.title":"Menu","menu.copy-as":"Copy as","menu.edit":"Edit","menu.export-as":"Export as","menu.file":"File","menu.language":"Language","menu.preferences":"Preferences","menu.view":"View","context-menu.arrange":"Arrange","context-menu.copy-as":"Copy as","context-menu.export-as":"Export as","context-menu.export-all-as":"Export","context-menu.move-to-page":"Move to page","context-menu.reorder":"Reorder","page-menu.title":"Pages","page-menu.create-new-page":"Create new page","page-menu.max-page-count-reached":"Max pages reached","page-menu.new-page-initial-name":"Page 1","page-menu.edit-start":"Edit","page-menu.edit-done":"Done","page-menu.go-to-page":"Go to page","page-menu.submenu.rename":"Rename","page-menu.submenu.duplicate-page":"Duplicate","page-menu.submenu.title":"Menu","page-menu.submenu.move-down":"Move down","page-menu.submenu.move-up":"Move up","page-menu.submenu.delete":"Delete","share-menu.title":"Share","share-menu.save-note":"Download this project to your computer as a .tldr file.","share-menu.fork-note":"Create a new shared project based on this snapshot.","share-menu.share-project":"Share this project","share-menu.default-project-name":"Shared Project","share-menu.copy-link":"Copy share link","share-menu.readonly-link":"Read-only","share-menu.create-snapshot-link":"Copy snapshot link","share-menu.snapshot-link-note":"Capture and share this project as a read-only snapshot link.","share-menu.copy-readonly-link":"Copy read-only link","share-menu.offline-note":"Create a new shared project based on your current project.","share-menu.copy-link-note":"Anyone with the link will be able to view and edit this project.","share-menu.copy-readonly-link-note":"Anyone with the link will be able to access this project.","share-menu.project-too-large":"Sorry, this project can't be shared because it's too large. We're working on it!","share-menu.upload-failed":"Sorry, we couldn't upload your project at the moment. Please try again or let us know if the problem persists.","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..."},lY=new Set(["ar","fa","he","ur","ku"]),sa={locale:"en",label:"English",messages:gv,dir:"ltr"};async function uY(e,t){if(!(await fetch(t.translations.en)).ok)return console.warn("No main translations found."),sa;if(e==="en")return sa;const r=Dl.find(a=>a.locale===e);if(!r)return console.warn(`No translation found for locale ${e}`),sa;const s=await(await fetch(t.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,dir:lY.has(r.locale)?"rtl":"ltr",messages:{...sa.messages,...s}}}const N$=x.createContext({}),z$=()=>x.useContext(N$),dY=rr(function({overrides:t,children:n}){const o=z().user.getLocale(),s=Hx(),[i,a]=x.useState(()=>t&&t.en?{locale:"en",label:"English",dir:"ltr",messages:{...gv,...t.en}}:{locale:"en",label:"English",dir:"ltr",messages:gv});return x.useEffect(()=>{let c=!1;async function l(){const u=await uY(o,s);u&&!c&&(t&&t[o]?a({...u,messages:{...u.messages,...t[o]}}):a(u))}return l(),()=>{c=!0}},[s,o,t]),h.jsx(N$.Provider,{value:i,children:n})});function Me(){const e=z$();return x.useCallback(function(n){return e.messages[n]??n},[e])}const qm=[0,390,428,468,580,640,840,1023];var vt=(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))(vt||{});const B$=20;class Lh extends Nr{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"hideResizeHandles",()=>!0);m(this,"hideSelectionBoundsFg",()=>!1);m(this,"onBeforeCreate",n=>AC(this.editor,n));m(this,"onBeforeUpdate",(n,r)=>{if(!(n.props.text===r.props.text&&n.props.font===r.props.font&&n.props.size===r.props.size))return AC(this.editor,r)});m(this,"onEditEnd",n=>{const{id:r,type:o,props:{text:s}}=n;s.trimEnd()!==n.props.text&&this.editor.updateShapes([{id:r,type:o,props:{text:s.trimEnd()}}])})}getDefaultProps(){return{color:"black",size:"m",text:"",font:"draw",align:"middle",verticalAlign:"middle",growY:0,fontSizeAdjustment:0,url:""}}getGeometry(n){const r=Dd(n),{labelHeight:o,labelWidth:s}=U$(this.editor,n);return new Br({children:[new Vo({width:$e,height:r,isFilled:!0}),new Vo({x:n.props.align==="start"?0:n.props.align==="end"?$e-s:($e-s)/2,y:n.props.verticalAlign==="start"?0:n.props.verticalAlign==="end"?r-o:(r-o)/2,width:s,height:o,isFilled:!0,isLabel:!0})]})}getHandles(n){const r=this.editor.getZoomLevel(),o=AG/r,s=Dd(n),i=this.editor.getInstanceState().isCoarsePointer;return r<.25||i?[]:r<.5?[{id:"bottom",index:"a3",type:"clone",x:$e/2,y:s+o}]:[{id:"top",index:"a1",type:"clone",x:$e/2,y:-o},{id:"right",index:"a2",type:"clone",x:$e+o,y:s/2},{id:"bottom",index:"a3",type:"clone",x:$e/2,y:s+o},{id:"left",index:"a4",type:"clone",x:-o,y:s/2}]}component(n){const{id:r,type:o,props:{color:s,font:i,size:a,align:c,text:l,verticalAlign:u,fontSizeAdjustment:d}}=n,p=fY(r),f=Pt(),y=Dd(n),g=K("shape rotation",()=>{var v;return((v=this.editor.getShapePageTransform(r))==null?void 0:v.rotation())??0},[this.editor]),w=ou(),S=n.id===this.editor.getOnlySelectedShapeId();return h.jsxs(h.Fragment,{children:[h.jsx("div",{id:r,className:"tl-note__container",style:{width:$e,height:y,backgroundColor:f[s].note.fill,borderBottom:w?"3px solid rgb(15, 23, 31, .2)":"none",boxShadow:w?"none":gY(n.id,g)},children:h.jsx(Zf,{id:r,type:o,font:i,fontSize:d||No[a],lineHeight:Gt.lineHeight,align:c,verticalAlign:u,text:l,isNote:!0,isSelected:S,labelColor:f[s].note.text,wrap:!0,onKeyDown:p})}),"url"in n.props&&n.props.url&&h.jsx(ic,{url:n.props.url,zoomLevel:this.editor.getZoomLevel()})]})}indicator(n){return h.jsx("rect",{rx:"1",width:j($e),height:j(Dd(n))})}toSvg(n,r){r.addExportDef(sc(n.props.font)),n.props.text&&r.addExportDef(sc(n.props.font));const o=Jo({isDarkMode:r.isDarkMode}),s=this.editor.getShapeGeometry(n).bounds;return h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:5,y:5,rx:1,width:$e-10,height:s.h,fill:"rgba(0,0,0,.1)"}),h.jsx("rect",{rx:1,width:$e,height:s.h,fill:o[n.props.color].note.fill}),h.jsx(qf,{fontSize:n.props.fontSizeAdjustment||No[n.props.size],font:n.props.font,align:n.props.align,verticalAlign:n.props.verticalAlign,text:n.props.text,labelColor:o[n.props.color].note.text,bounds:s,stroke:!1})]})}}m(Lh,"type","note"),m(Lh,"props",LE),m(Lh,"migrations",FE);function AC(e,t){const{labelHeight:n,fontSizeAdjustment:r}=U$(e,t),o=Math.max(0,n-$e);if(o!==t.props.growY||r!==t.props.fontSizeAdjustment)return{...t,props:{...t.props,growY:o,fontSizeAdjustment:r}}}function hY(e,t){const n=t.props.text;if(!n)return{labelHeight:No[t.props.size]*Gt.lineHeight+Ar*2,labelWidth:100,fontSizeAdjustment:0};const r=No[t.props.size];let o=0,s=0,i=$e,a=$e;const c=1;do{o=Math.min(r,r-s);const l=e.textMeasure.measureText(n,{...Gt,fontFamily:ao[t.props.font],fontSize:o,maxWidth:$e-Ar*2-c,disableOverflowWrapBreaking:!0});if(i=l.h+Ar*2,a=l.w+Ar*2,o<=14){const u=e.textMeasure.measureText(n,{...Gt,fontFamily:ao[t.props.font],fontSize:o,maxWidth:$e-Ar*2-c});i=u.h+Ar*2,a=u.w+Ar*2;break}if(l.scrollWidth.toFixed(0)===l.w.toFixed(0))break}while(s++<50);return{labelHeight:i,labelWidth:a,fontSizeAdjustment:o}}const pY=new Rf;function U$(e,t){return pY.get(t,()=>hY(e,t))}function fY(e){const t=z(),n=z$();return x.useCallback(r=>{const o=t.getShape(e);if(!o)return;const s=r.key==="Tab",i=(r.metaKey||r.ctrlKey)&&r.key==="Enter";if(s||i){r.preventDefault();const a=t.getShapePageTransform(e),c=a.rotation(),l=!!(n.dir==="rtl"||u$(o.props.text)),u=$e+B$+(i&&!r.shiftKey?o.props.growY:0),d=new b(s?r.shiftKey!=l?-1:1:0,i?r.shiftKey?-1:1:0).mul(u).add(Rx).rot(c).add(a.point()),p=S$(t,o,d,c);p&&(t.mark("editing adjacent shape"),ef(t,p,!0))}},[e,t,n.dir])}function Dd(e){return $e+e.props.growY}function gY(e,t){const n=go(e),r=Math.abs(n())+.5,o=Math.cos(t);return`0px ${5-r}px 5px -5px rgba(15, 23, 31, .6),
|
|
178
|
-
0px ${(4+r*7)*Math.max(0,o)}px ${6+r*7}px -${4+r*6}px rgba(15, 23, 31, ${(.3+r*.1).toFixed(2)}),
|
|
179
|
-
0px 48px 10px -10px inset rgba(15, 23, 44, ${((.022+n()*.005)*((1+o)/2)).toFixed(2)})`}function mY(e,{initialBounds:t,scaleX:n,scaleY:r,newPoint:o}){const s=Math.max(.01,Math.min(Math.abs(n),Math.abs(r))),i=new b(0,0);n<0&&(i.x=-(t.width*s)),r<0&&(i.y=-(t.height*s));const{x:a,y:c}=b.Add(o,i.rot(e.rotation));return{x:a,y:c,props:{scale:s*e.props.scale}}}const yY=new Rf;class Fh extends Nr{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"isAspectRatioLocked",()=>!0);m(this,"onResize",(n,r)=>{const{newPoint:o,initialBounds:s,initialShape:i,scaleX:a,handle:c}=r;if(r.mode==="scale_shape"||c!=="right"&&c!=="left")return{id:n.id,type:n.type,...mY(n,r)};{const l=Math.max(1,Math.abs(s.width*a)),{x:u,y:d}=a<0?b.Sub(o,b.FromAngle(n.rotation).mul(l)):o;return{id:n.id,type:n.type,x:u,y:d,props:{w:l/i.props.scale,autoSize:!1}}}});m(this,"onBeforeCreate",n=>{if(!n.props.autoSize||n.props.text.trim())return;const r=this.getMinDimensions(n);return{...n,x:n.x-r.width/2,y:n.y-r.height/2}});m(this,"onEditEnd",n=>{const{id:r,type:o,props:{text:s}}=n,i=n.props.text.trimEnd();i.length===0?this.editor.deleteShapes([n.id]):i!==n.props.text&&this.editor.updateShapes([{id:r,type:o,props:{text:s.trimEnd()}}])});m(this,"onBeforeUpdate",(n,r)=>{if(!r.props.autoSize)return;const o=n.props.size!==r.props.size||n.props.textAlign!==r.props.textAlign||n.props.font!==r.props.font||n.props.scale!==1&&r.props.scale===1,s=n.props.text!==r.props.text;if(!o&&!s)return;const i=this.getMinDimensions(n),a=jC(this.editor,r.props),c=i.width*n.props.scale,l=i.height*n.props.scale,u=a.width*r.props.scale,d=a.height*r.props.scale;let p;switch(r.props.textAlign){case"middle":{p=new b((u-c)/2,s?0:(d-l)/2);break}case"end":{p=new b(u-c,s?0:(d-l)/2);break}default:{if(s)break;p=new b(0,(d-l)/2);break}}if(p){p.rot(r.rotation);const{x:f,y}=r;return{...r,x:f-p.x,y:y-p.y,props:{...r.props,w:u}}}else return{...r,props:{...r.props,w:u}}});m(this,"onDoubleClickEdge",n=>{if(!n.props.autoSize)return{id:n.id,type:n.type,props:{autoSize:!0}};if(n.props.scale!==1)return{id:n.id,type:n.type,props:{scale:1}}})}getDefaultProps(){return{color:"black",size:"m",w:8,text:"",font:"draw",textAlign:"start",autoSize:!0,scale:1}}getMinDimensions(n){return yY.get(n.props,r=>jC(this.editor,r))}getGeometry(n){const{scale:r}=n.props,{width:o,height:s}=this.getMinDimensions(n);return new Vo({width:o*r,height:s*r,isFilled:!0,isLabel:!0})}component(n){const{id:r,props:{font:o,size:s,text:i,color:a,scale:c,textAlign:l}}=n,{width:u,height:d}=this.getMinDimensions(n),p=n.id===this.editor.getOnlySelectedShapeId(),f=Pt(),y=SY(r);return h.jsx(Zf,{id:r,classNamePrefix:"tl-text-shape",type:"text",font:o,fontSize:nc[s],lineHeight:Gt.lineHeight,align:l,verticalAlign:"middle",text:i,labelColor:f[a].solid,isSelected:p,textWidth:u,textHeight:d,style:{transform:`scale(${c})`,transformOrigin:"top left"},wrap:!0,onKeyDown:y})}indicator(n){const r=this.editor.getShapeGeometry(n).bounds,o=z();return n.props.autoSize&&o.getEditingShapeId()===n.id?null:h.jsx("rect",{width:j(r.width),height:j(r.height)})}toSvg(n,r){r.addExportDef(sc(n.props.font)),n.props.text&&r.addExportDef(sc(n.props.font));const o=this.editor.getShapeGeometry(n).bounds,s=o.width/(n.props.scale??1),i=o.height/(n.props.scale??1),a=Jo(r);return h.jsx(qf,{fontSize:nc[n.props.size],font:n.props.font,align:n.props.textAlign,verticalAlign:"middle",text:n.props.text,labelColor:a[n.props.color].solid,bounds:new te(0,0,s,i),padding:0})}}m(Fh,"type","text"),m(Fh,"props",NE),m(Fh,"migrations",zE);function jC(e,t){const{font:n,text:r,autoSize:o,size:s,w:i}=t,a=o?16:Math.max(16,i),c=nc[s],l=o?null:Math.floor(Math.max(a,i)),u=e.textMeasure.measureText(r,{...Gt,fontFamily:ao[n],fontSize:c,maxWidth:l});return o&&(u.w+=1),{width:Math.max(a,u.w),height:Math.max(c,u.h)}}function SY(e){const t=z();return x.useCallback(n=>{if(t.getEditingShapeId()===e)switch(n.key){case"Enter":{(n.ctrlKey||n.metaKey)&&t.complete();break}case"Tab":{ke(n),n.shiftKey?rc.unindent(n.currentTarget):rc.indent(n.currentTarget);break}}},[t,e])}class Nh extends vc{constructor(){super(...arguments);m(this,"canEdit",()=>!0);m(this,"isAspectRatioLocked",()=>!0)}getDefaultProps(){return{w:100,h:100,assetId:null,time:0,playing:!0,url:""}}component(n){const{editor:r}=this,o=r.getShapeGeometry(n).bounds.w*r.getZoomLevel()>=110,s=n.props.assetId?r.getAsset(n.props.assetId):null,{time:i,playing:a}=n.props,c=Uf(n.id),l=A$(),u=x.useRef(null),d=x.useCallback(S=>{const v=S.currentTarget;v&&r.updateShapes([{type:"video",id:n.id,props:{playing:!0,time:v.currentTime}}])},[n.id,r]),p=x.useCallback(S=>{const v=S.currentTarget;v&&r.updateShapes([{type:"video",id:n.id,props:{playing:!1,time:v.currentTime}}])},[n.id,r]),f=x.useCallback(S=>{const v=S.currentTarget;v&&c&&r.updateShapes([{type:"video",id:n.id,props:{time:v.currentTime}}])},[c,n.id,r]),[y,g]=x.useState(!1),w=x.useCallback(S=>{const v=S.currentTarget;v&&(i!==v.currentTime&&(v.currentTime=i),a||v.pause(),g(!0))},[a,i]);return x.useEffect(()=>{const S=u.current;S&&(y&&!c&&i!==S.currentTime&&(S.currentTime=i),c&&document.activeElement!==S&&S.focus())},[c,y,i]),x.useEffect(()=>{if(l){const S=u.current;if(!S)return;S.pause(),S.currentTime=0}},[u,l]),h.jsxs(h.Fragment,{children:[h.jsx($i,{id:n.id,style:{color:"var(--color-text-3)",backgroundColor:s?"transparent":"var(--color-low)",border:s?"none":"1px solid var(--color-low-border)"},children:h.jsx("div",{className:"tl-counter-scaled",children:h.jsx("div",{className:"tl-video-container",children:s!=null&&s.props.src?h.jsx("video",{ref:u,style:c?{pointerEvents:"all"}:void 0,className:`tl-video tl-video-shape-${n.id.split(":")[1]}`,width:"100%",height:"100%",draggable:!1,playsInline:!0,autoPlay:!0,muted:!0,loop:!0,disableRemotePlayback:!0,disablePictureInPicture:!0,controls:c&&o,onPlay:d,onPause:p,onTimeUpdate:f,onLoadedData:w,hidden:!y,children:h.jsx("source",{src:s.props.src})}):h.jsx(M$,{})})})}),"url"in n.props&&n.props.url&&h.jsx(ic,{url:n.props.url,zoomLevel:r.getZoomLevel()})]})}indicator(n){return h.jsx("rect",{width:j(n.props.w),height:j(n.props.h)})}toSvg(n){return h.jsx("image",{href:vY(n.id),width:n.props.w,height:n.props.h})}}m(Nh,"type","video"),m(Nh,"props",BE),m(Nh,"migrations",UE);function vY(e){const t=e.split(":")[1],n=document.querySelector(`.tl-video-shape-${t}`);if(n){const r=document.createElement("canvas");return r.width=n.videoWidth,r.height=n.videoHeight,r.getContext("2d").drawImage(n,0,0),r.toDataURL("image/png")}else throw new Error("Video with not found when attempting serialization.")}const H$=[Fh,Th,$h,jh,Lh,Rh,Ah,kh,Oh,Mh,Dh,Nh];function xY(e){return[e.sideEffects.registerAfterChangeHandler("instance",(t,n)=>{t.isFocused!==n.isFocused&&(n.isFocused?e.getContainer().focus():(e.complete(),e.getContainer().blur()))}),e.sideEffects.registerAfterChangeHandler("instance_page_state",(t,n)=>{if(t.croppingShapeId!==n.croppingShapeId){const r=e.isInAny("select.crop","select.pointing_crop_handle","select.cropping");!t.croppingShapeId&&n.croppingShapeId?r||e.setCurrentTool("select.crop.idle"):t.croppingShapeId&&!n.croppingShapeId&&r&&e.setCurrentTool("select.idle")}t.editingShapeId!==n.editingShapeId&&(!t.editingShapeId&&n.editingShapeId?e.isIn("select.editing_shape")||e.setCurrentTool("select.editing_shape"):t.editingShapeId&&!n.editingShapeId&&e.isIn("select.editing_shape")&&e.setCurrentTool("select.idle"))})]}class K$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"scribbleId","id");m(this,"markId","");m(this,"excludedShapeIds",new Set);m(this,"onEnter",n=>{this.markId="erase scribble begin",this.editor.mark(this.markId),this.info=n;const{originPagePoint:r}=this.editor.inputs;this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(s=>{if(this.editor.isShapeOrAncestorLocked(s))return!0;if(this.editor.isShapeOfType(s,"group")||this.editor.isShapeOfType(s,"frame")){const i=this.editor.getPointInShapeSpace(s,r);return this.editor.getShapeGeometry(s).bounds.containsPoint(i)}return!1}).map(s=>s.id));const o=this.editor.scribbles.addScribble({color:"muted-1",size:12});this.scribbleId=o.id,this.update()});m(this,"pushPointToScribble",()=>{const{x:n,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,n,r)});m(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});m(this,"onPointerMove",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()})}update(){const{editor:n,excludedShapeIds:r}=this,o=n.getErasingShapeIds(),s=n.getZoomLevel(),i=n.getCurrentPageShapes(),{inputs:{currentPagePoint:a,previousPagePoint:c}}=n;this.pushPointToScribble();const l=new Set(o),u=Uo/s;for(const d of i){if(n.isShapeOfType(d,"group"))continue;const p=n.getShapeMask(d.id);if(p&&!Zn(a,p))continue;const f=n.getShapeGeometry(d),y=n.getShapePageTransform(d);if(!f||!y)continue;const g=y.clone().invert(),w=g.applyToPoint(c),S=g.applyToPoint(a),{bounds:v}=f;v.minX-u>Math.max(w.x,S.x)||v.minY-u>Math.max(w.y,S.y)||v.maxX+u<Math.min(w.x,S.x)||v.maxY+u<Math.min(w.y,S.y)||f.hitTestLineSegment(w,S,u)&&l.add(n.getOutermostSelectableShape(d).id)}this.editor.setErasingShapes([...l].filter(d=>!r.has(d)))}complete(){const{editor:n}=this;n.deleteShapes(n.getCurrentPageState().erasingShapeIds),n.setErasingShapes([]),this.parent.transition("idle")}cancel(){const{editor:n}=this;n.setErasingShapes([]),n.bailToMark(this.markId),this.parent.transition("idle",this.info)}}m(K$,"id","erasing");var _y;let wY=(_y=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(_y,"id","idle"),_y);var ky;let bY=(ky=class extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{const n=this.editor.getZoomLevel(),r=this.editor.getCurrentPageShapesSorted(),{inputs:{currentPagePoint:o}}=this.editor,s=new Set,i=s.size;for(let a=r.length,c=a-1;c>=0;c--){const l=r[c];if(!(this.editor.isShapeOrAncestorLocked(l)||this.editor.isShapeOfType(l,"group"))&&this.editor.isPointInShape(l,o,{hitInside:!1,margin:Uo/n})){const u=this.editor.getOutermostSelectableShape(l);if(this.editor.isShapeOfType(u,"frame")&&s.size>i)break;s.add(u.id)}}this.editor.setErasingShapes([...s])});m(this,"onLongPress",n=>{this.startErasing(n)});m(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.startErasing(n)});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.cancel()})}startErasing(n){this.parent.transition("erasing",n)}complete(){const n=this.editor.getErasingShapeIds();n.length&&(this.editor.mark("erase end"),this.editor.deleteShapes(n)),this.editor.setErasingShapes([]),this.parent.transition("idle")}cancel(){this.editor.setErasingShapes([]),this.parent.transition("idle")}},m(ky,"id","pointing"),ky);class zh extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})})}}m(zh,"id","eraser"),m(zh,"initial","idle"),m(zh,"children",()=>[wY,bY,K$]);class W$ extends se{constructor(){super(...arguments);m(this,"initialCamera",new b);m(this,"onEnter",()=>{this.initialCamera=b.From(this.editor.getCamera()),this.update()});m(this,"onPointerMove",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.parent.transition("idle")});m(this,"onComplete",()=>{this.complete()})}update(){const{initialCamera:n,editor:r}=this,{currentScreenPoint:o,originScreenPoint:s}=r.inputs,i=b.Sub(o,s).div(r.getZoomLevel());i.len2()!==0&&r.setCamera(n.clone().add(i))}complete(){const{editor:n}=this,{pointerVelocity:r}=n.inputs,o=Math.min(r.len(),2);o>.1&&this.editor.slideCamera({speed:o,direction:r,friction:YE}),this.parent.transition("idle")}}m(W$,"id","dragging");var Ty;let PY=(Ty=class extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.setCursor({type:"grab",rotation:0})});m(this,"onPointerDown",n=>{this.parent.transition("pointing",n)});m(this,"onCancel",()=>{this.editor.setCurrentTool("select")})}},m(Ty,"id","idle"),Ty);var $y;let CY=($y=class extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.stopCameraAnimation(),this.editor.setCursor({type:"grabbing",rotation:0})});m(this,"onLongPress",()=>{this.startDragging()});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startDragging()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.complete()})}startDragging(){this.parent.transition("dragging")}complete(){this.parent.transition("idle")}},m($y,"id","pointing"),$y);class Bh extends se{constructor(){super(...arguments);m(this,"onDoubleClick",n=>{if(n.phase==="settle"){const{currentScreenPoint:r}=this.editor.inputs;this.editor.zoomIn(r,{animation:{duration:220,easing:sn.easeOutQuint}})}});m(this,"onTripleClick",n=>{if(n.phase==="settle"){const{currentScreenPoint:r}=this.editor.inputs;this.editor.zoomOut(r,{animation:{duration:320,easing:sn.easeOutQuint}})}});m(this,"onQuadrupleClick",n=>{if(n.phase==="settle"){const r=this.editor.getZoomLevel(),{inputs:{currentScreenPoint:o}}=this.editor;r===1?this.editor.zoomToFit({animation:{duration:400,easing:sn.easeOutQuint}}):this.editor.resetZoom(o,{animation:{duration:320,easing:sn.easeOutQuint}})}})}}m(Bh,"id","hand"),m(Bh,"initial","idle"),m(Bh,"children",()=>[PY,CY,W$]);var My;let IY=(My=class extends se{constructor(){super(...arguments);m(this,"onPointerDown",n=>{this.parent.transition("lasering",n)})}},m(My,"id","idle"),My);class G$ extends se{constructor(){super(...arguments);m(this,"scribbleId","id");m(this,"onEnter",()=>{const n=this.editor.scribbles.addScribble({color:"laser",opacity:.7,size:4,delay:1200,shrink:.05,taper:!0});this.scribbleId=n.id,this.pushPointToScribble()});m(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});m(this,"onPointerMove",()=>{this.pushPointToScribble()});m(this,"onPointerUp",()=>{this.complete()});m(this,"pushPointToScribble",()=>{const{x:n,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,n,r)});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()})}complete(){this.parent.transition("idle")}cancel(){this.parent.transition("idle")}}m(G$,"id","lasering");class Uh extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.setCursor({type:"cross",rotation:0})})}}m(Uh,"id","laser"),m(Uh,"initial","idle"),m(Uh,"children",()=>[IY,G$]);class V$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"initialSelectedShapeIds",[]);m(this,"excludedShapeIds",new Set);m(this,"isWrapMode",!1);m(this,"initialStartShape",null);m(this,"onEnter",n=>{const{altKey:r,currentPagePoint:o}=this.editor.inputs;if(this.isWrapMode=this.editor.user.getIsWrapMode(),r){this.parent.transition("scribble_brushing",n);return}this.excludedShapeIds=new Set(this.editor.getCurrentPageShapes().filter(s=>this.editor.isShapeOfType(s,"group")||this.editor.isShapeOrAncestorLocked(s)).map(s=>s.id)),this.info=n,this.initialSelectedShapeIds=this.editor.getSelectedShapeIds().slice(),this.initialStartShape=this.editor.getShapesAtPoint(o)[0],this.hitTestShapes()});m(this,"onExit",()=>{this.initialSelectedShapeIds=[],this.editor.updateInstanceState({brush:null})});m(this,"onTick",()=>{px(this.editor)});m(this,"onPointerMove",()=>{this.hitTestShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",n=>{this.editor.setSelectedShapes(this.initialSelectedShapeIds),this.parent.transition("idle",n)});m(this,"onKeyDown",n=>{this.editor.inputs.altKey?this.parent.transition("scribble_brushing",n):this.hitTestShapes()});m(this,"onKeyUp",()=>{this.hitTestShapes()});m(this,"onInterrupt",()=>{this.editor.updateInstanceState({brush:null})})}complete(){this.hitTestShapes(),this.parent.transition("idle")}hitTestShapes(){const{editor:n,excludedShapeIds:r,isWrapMode:o}=this,{inputs:{originPagePoint:s,currentPagePoint:i,shiftKey:a,ctrlKey:c}}=n,l=new Set(a?this.initialSelectedShapeIds:[]),u=o?!c:c,d=te.FromPoints([s,i]),{corners:p}=d;let f,y,g,w,S,v;const P=n.getCurrentPageShapes(),I=n.getCurrentPageId();e:for(let _=0,k=P.length;_<k;_++){if(g=P[_],r.has(g.id)||l.has(g.id)||(w=n.getShapePageBounds(g),!w))continue e;if(d.contains(w)){this.handleHit(g,i,I,l,p);continue e}if(u||n.isShapeOfType(g,"frame"))continue e;if(d.collides(w)){if(S=n.getShapePageTransform(g),!S)continue e;v=S.clone().invert().applyToPoints(p);const $=n.getShapeGeometry(g);t:for(let T=0;T<4;T++)if(f=v[T],y=v[(T+1)%4],$.hitTestLineSegment(f,y,0)){this.handleHit(g,i,I,l,p);break t}}}n.getInstanceState().isCoarsePointer;const C=n.getInstanceState().brush;(!C||!d.equals(C))&&n.updateInstanceState({brush:{...d.toJson()}});const E=n.getSelectedShapeIds();(E.length!==l.size||E.some(_=>!l.has(_)))&&n.setSelectedShapes(Array.from(l))}handleHit(n,r,o,s,i){if(n.parentId===o){s.add(n.id);return}const a=this.editor.getOutermostSelectableShape(n),c=this.editor.getShapeMask(a.id);c&&!DT(c,i)&&!Zn(r,c)||s.add(a.id)}}m(V$,"id","brushing");function Kx(e,t=!1){const n=e.getZoomLevel(),{inputs:{currentPagePoint:r}}=e;return e.getShapeAtPoint(r,{hitInside:!1,hitLabels:t,margin:Uo/n,renderingOnly:!0})??e.getSelectedShapeAtPoint(r)}function Y$(e,t,n){if(!t)throw Error("Needs to translate a cropped shape!");const{crop:r}=t.props;if(!r)return;const o=e.inputs.shiftKey?Math.abs(n.x)<Math.abs(n.y)?"x":"y":null;o==="x"?n.x=0:o==="y"&&(n.y=0),n.rot(-t.rotation);const s=1/(r.bottomRight.x-r.topLeft.x)*t.props.w,i=1/(r.bottomRight.y-r.topLeft.y)*t.props.h,a=r.bottomRight.y-r.topLeft.y,c=r.bottomRight.x-r.topLeft.x,l=Ge(r);return l.topLeft.x=Math.min(1-c,Math.max(0,l.topLeft.x-n.x/s)),l.topLeft.y=Math.min(1-a,Math.max(0,l.topLeft.y-n.y/i)),l.bottomRight.x=l.topLeft.x+c,l.bottomRight.y=l.topLeft.y+a,{id:t.id,type:t.type,props:{crop:l}}}var Ay;let EY=(Ay=class extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.editor.setCursor({type:"default",rotation:0});const n=this.editor.getOnlySelectedShape();this.editor.on("tick",this.cleanupCroppingState),n&&(this.editor.mark("crop"),this.editor.setCroppingShape(n.id))});m(this,"onExit",()=>{this.editor.setCursor({type:"default",rotation:0}),this.editor.off("tick",this.cleanupCroppingState)});m(this,"onCancel",()=>{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})});m(this,"onPointerDown",n=>{var r;if(!this.editor.getIsMenuOpen()){if(n.ctrlKey){this.cancel(),this.editor.root.handleEvent(n);return}switch(n.target){case"canvas":{const o=Kx(this.editor);if(o&&!this.editor.isShapeOfType(o,"group")){this.onPointerDown({...n,shape:o,target:"shape"});return}this.cancel(),this.editor.root.handleEvent(n);break}case"shape":{if(n.shape.id===this.editor.getCroppingShapeId()){this.editor.setCurrentTool("select.crop.pointing_crop",n);return}else(r=this.editor.getShapeUtil(n.shape))!=null&&r.canCrop(n.shape)?(this.editor.setCroppingShape(n.shape.id),this.editor.setSelectedShapes([n.shape.id]),this.editor.setCurrentTool("select.crop.pointing_crop",n)):(this.cancel(),this.editor.root.handleEvent(n));break}case"selection":{switch(n.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{this.editor.setCurrentTool("select.pointing_rotate_handle",{...n,onInteractionEnd:"select.crop"});break}case"top":case"right":case"bottom":case"left":{this.editor.setCurrentTool("select.pointing_crop_handle",{...n,onInteractionEnd:"select.crop"});break}case"top_left":case"top_right":case"bottom_left":case"bottom_right":{this.editor.setCurrentTool("select.pointing_crop_handle",{...n,onInteractionEnd:"select.crop"});break}default:this.cancel()}break}}}});m(this,"onDoubleClick",n=>{var i;if(this.editor.inputs.shiftKey||n.phase!=="up")return;const r=this.editor.getCroppingShapeId();if(!r)return;const o=this.editor.getShape(r);if(!o)return;const s=this.editor.getShapeUtil(o);s&&n.target==="selection"&&((i=s.onDoubleClickEdge)==null||i.call(s,o))});m(this,"onKeyDown",()=>{this.nudgeCroppingImage(!1)});m(this,"onKeyRepeat",()=>{this.nudgeCroppingImage(!0)});m(this,"onKeyUp",n=>{switch(n.code){case"Enter":{this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{});break}}});m(this,"cleanupCroppingState",()=>{this.editor.getCroppingShapeId()||this.editor.setCurrentTool("select.idle",{})})}cancel(){this.editor.setCroppingShape(null),this.editor.setCurrentTool("select.idle",{})}nudgeCroppingImage(n=!1){const{editor:{inputs:{keys:r}}}=this,o=r.has("ShiftLeft"),s=new 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=Y$(this.editor,i,s);a&&(n||this.editor.mark("translate crop"),this.editor.updateShapes([a]))}},m(Ay,"id","idle"),Ay);class X$ extends se{constructor(){super(...arguments);m(this,"onCancel",()=>{this.editor.setCurrentTool("select.crop.idle",{})});m(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.editor.setCurrentTool("select.crop.translating_crop",n)});m(this,"onPointerUp",n=>{this.editor.setCurrentTool("select.crop.idle",n)})}}m(X$,"id","pointing_crop");class q$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"markId","translating crop");m(this,"snapshot",{});m(this,"onEnter",n=>{this.info=n,this.snapshot=this.createSnapshot(),this.editor.mark(this.markId),this.editor.setCursor({type:"move",rotation:0}),this.updateShapes()});m(this,"onExit",()=>{this.editor.setCursor({type:"default",rotation:0})});m(this,"onPointerMove",()=>{this.updateShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onKeyDown",n=>{switch(n.key){case"Alt":case"Shift":{this.updateShapes();return}}});m(this,"onKeyUp",n=>{switch(n.key){case"Enter":{this.complete();return}case"Alt":case"Shift":this.updateShapes()}})}complete(){this.updateShapes(),this.editor.setCurrentTool("select.crop.idle",this.info)}cancel(){this.editor.bailToMark(this.markId),this.editor.setCurrentTool("select.crop.idle",this.info)}createSnapshot(){return{shape:this.editor.getOnlySelectedShape()}}updateShapes(){const n=this.snapshot.shape;if(!n)return;const{originPagePoint:r,currentPagePoint:o}=this.editor.inputs,s=o.clone().sub(r),i=Y$(this.editor,n,s);i&&this.editor.updateShapes([i])}}m(q$,"id","translating_crop");class Hh extends se{}m(Hh,"id","crop"),m(Hh,"initial","idle"),m(Hh,"children",()=>[EY,q$,X$]);const dr=8,ac={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 Z$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n,this.updateCursor()});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startResizing()});m(this,"onLongPress",()=>{this.startResizing()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}updateCursor(){const n=this.editor.getSelectedShapes(),r=ac[this.info.handle];this.editor.setCursor({type:r,rotation:n.length===1?this.editor.getSelectionRotation():0})}startResizing(){this.editor.getInstanceState().isReadonly||this.parent.transition("resizing",this.info)}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}m(Z$,"id","pointing_resize_handle");class Q$ extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"markId","");m(this,"snapshot",{});m(this,"onEnter",n=>{this.info=n,this.markId="cropping",this.editor.mark(this.markId),this.snapshot=this.createSnapshot(),this.updateShapes()});m(this,"onPointerMove",()=>{this.updateShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"getDefaultCrop",()=>({topLeft:{x:0,y:0},bottomRight:{x:1,y:1}}))}updateCursor(){if(!this.editor.getSelectedShapes()[0])return;const r=ac[this.info.handle];this.editor.setCursor({type:r,rotation:this.editor.getSelectionRotation()})}updateShapes(){const{shape:n,cursorHandleOffset:r}=this.snapshot;if(!n||!this.editor.getShapeUtil("image"))return;const s=n.props,i=this.editor.inputs.currentPagePoint.clone().sub(r),a=this.editor.inputs.originPagePoint.clone().sub(r),c=i.clone().sub(a).rot(-n.rotation),l=s.crop??this.getDefaultCrop(),u=Ge(l),d=new b(n.x,n.y),p=new b(0,0),f=1/(l.bottomRight.x-l.topLeft.x)*s.w,y=1/(l.bottomRight.y-l.topLeft.y)*s.h;let g=!1;switch(this.info.handle){case"top":case"top_left":case"top_right":{if(y<dr)break;g=!0,u.topLeft.y=u.topLeft.y+c.y/y,y*(u.bottomRight.y-u.topLeft.y)<dr?(u.topLeft.y=u.bottomRight.y-dr/y,p.y=(u.topLeft.y-l.topLeft.y)*y):u.topLeft.y<=0?(u.topLeft.y=0,p.y=(u.topLeft.y-l.topLeft.y)*y):p.y=c.y;break}case"bottom":case"bottom_left":case"bottom_right":{if(y<dr)break;g=!0,u.bottomRight.y=Math.min(1,u.bottomRight.y+c.y/y),y*(u.bottomRight.y-u.topLeft.y)<dr&&(u.bottomRight.y=u.topLeft.y+dr/y);break}}switch(this.info.handle){case"left":case"top_left":case"bottom_left":{if(f<dr)break;g=!0,u.topLeft.x=u.topLeft.x+c.x/f,f*(u.bottomRight.x-u.topLeft.x)<dr?(u.topLeft.x=u.bottomRight.x-dr/f,p.x=(u.topLeft.x-l.topLeft.x)*f):u.topLeft.x<=0?(u.topLeft.x=0,p.x=(u.topLeft.x-l.topLeft.x)*f):p.x=c.x;break}case"right":case"top_right":case"bottom_right":{if(f<dr)break;g=!0,u.bottomRight.x=Math.min(1,u.bottomRight.x+c.x/f),f*(u.bottomRight.x-u.topLeft.x)<dr&&(u.bottomRight.x=u.topLeft.x+dr/f);break}}if(!g)return;d.add(p.rot(n.rotation));const w={id:n.id,type:n.type,x:d.x,y:d.y,props:{crop:u,w:(u.bottomRight.x-u.topLeft.x)*f,h:(u.bottomRight.y-u.topLeft.y)*y}};this.editor.updateShapes([w]),this.updateCursor()}complete(){this.updateShapes(),Ye(this.editor,[this.snapshot.shape.id]),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))}createSnapshot(){const n=this.editor.getSelectionRotation(),{inputs:{originPagePoint:r}}=this.editor,o=this.editor.getOnlySelectedShape(),s=this.editor.getSelectionRotatedPageBounds(),i=b.RotWith(s.getHandlePoint(this.info.handle),s.point,n),a=b.Sub(r,i);return{shape:o,cursorHandleOffset:a}}}m(Q$,"id","cropping");class J$ extends se{constructor(){super(...arguments);m(this,"shapeId","");m(this,"initialHandle",{});m(this,"initialAdjacentHandle",null);m(this,"initialPagePoint",{});m(this,"markId","");m(this,"initialPageTransform");m(this,"initialPageRotation");m(this,"info",{});m(this,"isPrecise",!1);m(this,"isPreciseId",null);m(this,"pointingId",null);m(this,"onEnter",n=>{const{shape:r,isCreating:o,handle:s}=n;if(this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.shapeId=r.id,this.markId=o?`creating:${r.id}`:"dragging handle",o||this.editor.mark(this.markId),this.initialHandle=Ge(s),this.editor.isShapeOfType(r,"line")&&this.initialHandle.type==="create"){this.editor.updateShape({...r,props:{points:{...r.props.points,[s.index]:{id:s.index,index:s.index,x:s.x,y:s.y}}}});const l=this.editor.getShapeHandles(r).find(u=>u.index===s.index);this.initialHandle=Ge(l)}this.initialPageTransform=this.editor.getShapePageTransform(r),this.initialPageRotation=this.initialPageTransform.rotation(),this.initialPagePoint=this.editor.inputs.originPagePoint.clone(),this.editor.setCursor({type:o?"cross":"grabbing",rotation:0});const i=this.editor.getShapeHandles(r).sort(rn),a=i.findIndex(c=>c.id===n.handle.id);this.initialAdjacentHandle=null;for(let c=a+1;c<i.length;c++){const l=i[c];if(l.type==="vertex"&&l.id!=="middle"&&l.id!==n.handle.id){this.initialAdjacentHandle=l;break}}if(!this.initialAdjacentHandle)for(let c=i.length-1;c>=0;c--){const l=i[c];if(l.type==="vertex"&&l.id!=="middle"&&l.id!==n.handle.id){this.initialAdjacentHandle=l;break}}if(this.editor.isShapeOfType(r,"arrow")){const c=r.props[n.handle.id];this.isPrecise=!1,(c==null?void 0:c.type)==="binding"?(this.editor.setHintingShapes([c.boundShapeId]),this.isPrecise=c.isPrecise,this.isPrecise?this.isPreciseId=c.boundShapeId:this.resetExactTimeout()):this.editor.setHintingShapes([])}this.update(),this.editor.select(this.shapeId)});m(this,"exactTimeout",-1);m(this,"onPointerMove",()=>{this.update()});m(this,"onKeyDown",()=>{this.update()});m(this,"onKeyUp",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.update(),this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.setHintingShapes([]),this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation: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(),Ye(this.editor,[this.shapeId]);const{onInteractionEnd:n}=this.info;if(this.editor.getInstanceState().isToolLocked&&n){this.editor.setCurrentTool(n,{shapeId:this.shapeId});return}this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId),this.editor.snaps.clearIndicators();const{onInteractionEnd:n}=this.info;if(n){this.editor.setCurrentTool(n,{shapeId:this.shapeId});return}this.parent.transition("idle")}update(){var _;const{editor:n,shapeId:r,initialPagePoint:o}=this,{initialHandle:s,initialPageRotation:i,initialAdjacentHandle:a}=this,c=this.editor.getHintingShapeIds(),l=this.editor.user.getIsSnapMode(),{snaps:u,inputs:{currentPagePoint:d,shiftKey:p,ctrlKey:f,altKey:y,pointerVelocity:g}}=n,w=this.info.shape,S=n.getShape(r);if(!S)return;const v=n.getShapeUtil(S);let P=d.clone().sub(o).rot(-i).add(s);if(p&&a&&s.id!=="middle"){const k=b.Angle(a,P),T=gp(k,24)-k;P=b.RotWith(P,a,T)}n.snaps.clearIndicators();let I={...s,x:P.x,y:P.y};if(s.canSnap&&(l?!f:f)){if(!n.getShapePageTransform(S.id))throw Error("Expected a page transform");const $=u.handles.snapHandle({currentShapeId:r,handle:I});$&&($.nudge.rot(-n.getShapeParentTransform(S).rotation()),P.add($.nudge),I={...s,x:P.x,y:P.y})}const C=(_=v.onHandleDrag)==null?void 0:_.call(v,S,{handle:I,isPrecise:this.isPrecise||y,initial:w}),E={...S,...C};if(s.canBind){const k=E.props[s.id];(k==null?void 0:k.type)==="binding"?c[0]!==k.boundShapeId&&(n.setHintingShapes([k.boundShapeId]),this.pointingId=k.boundShapeId,this.isPrecise=g.len()<.5||y,this.isPreciseId=this.isPrecise?k.boundShapeId:null,this.resetExactTimeout()):c.length>0&&(n.setHintingShapes([]),this.pointingId=null,this.isPrecise=!1,this.isPreciseId=null,this.resetExactTimeout())}C&&n.updateShapes([E])}}m(J$,"id","dragging_handle");function eM(e){return e.isLabel?[e]:e instanceof Br?e.children.filter(t=>t.isLabel):[]}class tM extends se{constructor(){super(...arguments);m(this,"hitShapeForPointerUp",null);m(this,"onEnter",()=>{const n=this.editor.getEditingShape();if(!n)throw Error("Entered editing state without an editing shape");this.hitShapeForPointerUp=null,Ka(this.editor),this.editor.select(n)});m(this,"onExit",()=>{var s;const{editingShapeId:n}=this.editor.getCurrentPageState();if(!n)return;this.editor.setEditingShape(null);const r=this.editor.getShape(n),o=this.editor.getShapeUtil(r);(s=o.onEditEnd)==null||s.call(o,r)});m(this,"onPointerMove",n=>{if(this.hitShapeForPointerUp&&this.editor.inputs.isDragging){if(this.editor.getInstanceState().isReadonly)return;this.editor.select(this.hitShapeForPointerUp),this.parent.transition("translating",n),this.hitShapeForPointerUp=null;return}switch(n.target){case"shape":case"canvas":{Ka(this.editor);return}}});m(this,"onPointerDown",n=>{switch(this.hitShapeForPointerUp=null,n.target){case"canvas":{const r=Kx(this.editor,!0);if(r){this.onPointerDown({...n,shape:r,target:"shape"});return}break}case"shape":{const{shape:r}=n,o=this.editor.getEditingShape();if(!o)throw Error("Expected an editing shape!");const s=this.editor.getShapeUtil(r).getGeometry(r),i=eM(s),a=i.length===1?i[0]:void 0,c=this.editor.isShapeOfType(o,"text")&&o.props.text.trim()==="";if(a&&!c){const l=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint);if(a.bounds.containsPoint(l,0)&&a.hitTestPoint(l)){if(r.id===o.id)return;this.hitShapeForPointerUp=r,this.editor.mark("editing on pointer up"),this.editor.select(r.id);return}}else{if(r.id===o.id)this.editor.isShapeOfType(r,"frame")&&this.editor.setEditingShape(null);else{this.parent.transition("pointing_shape",n);return}return}break}}this.parent.transition("idle",n),this.editor.root.handleEvent(n)});m(this,"onPointerUp",n=>{const r=this.hitShapeForPointerUp;if(!r)return;this.hitShapeForPointerUp=null;const o=this.editor.getShapeUtil(r);if(this.editor.getInstanceState().isReadonly&&!o.canEditInReadOnly(r)){this.parent.transition("pointing_shape",n);return}this.editor.select(r.id),this.editor.setEditingShape(r.id),Ka(this.editor)});m(this,"onComplete",n=>{this.parent.transition("idle",n)});m(this,"onCancel",n=>{this.parent.transition("idle",n)})}}m(tM,"id","editing_shape");function OC(e){const t=e.getOnlySelectedShape();return!!(t&&!e.isShapeOrAncestorLocked(t)&&e.getShapeUtil(t).canCrop(t))}function nf(e){const t=e.getSelectedShapeIds(),{shiftKey:n,altKey:r,currentPagePoint:o}=e.inputs,s=e.getShapeAtPoint(o,{hitInside:!1,margin:Uo/e.getZoomLevel(),hitLabels:!0,renderingOnly:!0,filter:i=>!i.isLocked});if(s){const i=e.getOutermostSelectableShape(s);if(n&&!r)e.cancelDoubleClick(),t.includes(i.id)?(e.mark("deselecting shape"),e.deselect(i)):(e.mark("shift selecting shape"),e.setSelectedShapes([...t,i.id]));else{let a;i===s||i.id===e.getFocusedGroupId()||t.includes(i.id)?a=s:a=i,a&&!t.includes(a.id)&&(e.mark("selecting shape"),e.select(a.id))}}else{if(n)return;{t.length>0&&(e.mark("selecting none"),e.selectNone());const i=e.getFocusedGroupId();if(Hn(i)){const a=e.getShape(i);e.isPointInShape(a,o,{margin:0,hitInside:!0})||e.setFocusedGroup(null)}}}}const _Y=["Delete","Backspace","[","]","Enter"," ","Shift","Tab"];var jy;let kY=(jy=class extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{this.parent.setCurrentToolIdMask(void 0),Ka(this.editor),this.editor.setCursor({type:"default",rotation:0})});m(this,"onPointerMove",()=>{Ka(this.editor)});m(this,"onPointerDown",n=>{if(this.editor.getIsMenuOpen())return;const r=n.ctrlKey&&OC(this.editor);if(n.ctrlKey&&!r){if(n.target==="shape"&&this.isDarwin&&this.editor.inputs.keys.has("ControlLeft")&&!this.editor.isShapeOrAncestorLocked(n.shape)){this.parent.transition("pointing_shape",n);return}this.parent.transition("brushing",n);return}switch(n.target){case"canvas":{const o=Kx(this.editor);if(o&&!o.isLocked){this.onPointerDown({...n,shape:o,target:"shape"});return}const s=this.editor.getSelectedShapeIds(),i=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:a}}=this.editor;if((s.length>1||i&&!this.editor.getShapeUtil(i).hideSelectionBoundsBg(i))&&DC(this.editor,a)){this.onPointerDown({...n,target:"selection"});return}this.parent.transition("pointing_canvas",n);break}case"shape":{const{shape:o}=n;if(this.isOverArrowLabelTest(o)){this.parent.transition("pointing_arrow_label",n);break}if(this.editor.isShapeOrAncestorLocked(o)){this.parent.transition("pointing_canvas",n);break}this.parent.transition("pointing_shape",n);break}case"handle":{if(this.editor.getInstanceState().isReadonly)break;this.editor.inputs.altKey?this.parent.transition("pointing_shape",n):this.parent.transition("pointing_handle",n);break}case"selection":{switch(n.handle){case"mobile_rotate":case"top_left_rotate":case"top_right_rotate":case"bottom_left_rotate":case"bottom_right_rotate":{this.parent.transition("pointing_rotate_handle",n);break}case"top":case"right":case"bottom":case"left":{r?this.parent.transition("pointing_crop_handle",n):this.parent.transition("pointing_resize_handle",n);break}case"top_left":case"top_right":case"bottom_left":case"bottom_right":{r?this.parent.transition("pointing_crop_handle",n):this.parent.transition("pointing_resize_handle",n);break}default:{const o=this.editor.getHoveredShape();if(o&&!this.editor.getSelectedShapeIds().includes(o.id)&&!o.isLocked){this.onPointerDown({...n,shape:o,target:"shape"});return}this.parent.transition("pointing_selection",n)}}break}}});m(this,"onDoubleClick",n=>{var r,o,s,i;if(!(this.editor.inputs.shiftKey||n.phase!=="up"))switch(n.target){case"canvas":{const a=this.editor.getHoveredShape(),c=a&&!this.editor.isShapeOfType(a,"group")?a:this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint)??this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{margin:Uo/this.editor.getZoomLevel(),hitInside:!1}),l=this.editor.getFocusedGroupId();if(c){if(this.editor.isShapeOfType(c,"group")){nf(this.editor);return}else{const u=this.editor.getShape(c.parentId);if(u&&this.editor.isShapeOfType(u,"group")&&!(l&&u.id===l)){nf(this.editor);return}}this.onDoubleClick({...n,shape:c,target:"shape"});return}this.editor.inputs.shiftKey||this.handleDoubleClickOnCanvas(n);break}case"selection":{if(this.editor.getInstanceState().isReadonly)break;const a=this.editor.getOnlySelectedShape();if(a){const c=this.editor.getShapeUtil(a);if(!this.canInteractWithShapeInReadOnly(a))return;if(n.handle==="right"||n.handle==="left"||n.handle==="top"||n.handle==="bottom"){const l=(r=c.onDoubleClickEdge)==null?void 0:r.call(c,a);if(l){this.editor.mark("double click edge"),this.editor.updateShapes([l]),Ye(this.editor,[a.id]);return}}if(c.canCrop(a)&&!this.editor.isShapeOrAncestorLocked(a)){this.parent.transition("crop",n);return}this.shouldStartEditingShape(a)&&this.startEditingShape(a,n,!0)}break}case"shape":{const{shape:a}=n,c=this.editor.getShapeUtil(a);if(a.type!=="video"&&a.type!=="embed"&&this.editor.getInstanceState().isReadonly)break;if(c.onDoubleClick){const l=(o=c.onDoubleClick)==null?void 0:o.call(c,a);if(l){this.editor.updateShapes([l]);return}else if(c.canCrop(a)&&!this.editor.isShapeOrAncestorLocked(a)){this.editor.mark("select and crop"),this.editor.select((s=n.shape)==null?void 0:s.id),this.parent.transition("crop",n);return}}this.shouldStartEditingShape(a)?this.startEditingShape(a,n,!0):this.handleDoubleClickOnCanvas(n);break}case"handle":{if(this.editor.getInstanceState().isReadonly)break;const{shape:a,handle:c}=n,l=this.editor.getShapeUtil(a),u=(i=l.onDoubleClickHandle)==null?void 0:i.call(l,a,c);u?this.editor.updateShapes([u]):this.shouldStartEditingShape(a)&&this.startEditingShape(a,n,!0)}}});m(this,"onRightClick",n=>{switch(n.target){case"canvas":{const r=this.editor.getHoveredShape(),o=r&&!this.editor.isShapeOfType(r,"group")?r:this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{margin:Uo/this.editor.getZoomLevel(),hitInside:!1,hitLabels:!0,hitLocked:!0,hitFrameInside:!1,renderingOnly:!0});if(o){this.onRightClick({...n,shape:o,target:"shape"});return}const s=this.editor.getSelectedShapeIds(),i=this.editor.getOnlySelectedShape(),{inputs:{currentPagePoint:a}}=this.editor;if((s.length>1||i&&!this.editor.getShapeUtil(i).hideSelectionBoundsBg(i))&&DC(this.editor,a)){this.onRightClick({...n,target:"selection"});return}this.editor.selectNone();break}case"shape":{const{selectedShapeIds:r}=this.editor.getCurrentPageState(),{shape:o}=n,s=this.editor.getOutermostSelectableShape(o,i=>!r.includes(i.id));r.includes(s.id)||(this.editor.mark("selecting shape"),this.editor.setSelectedShapes([s.id]));break}}});m(this,"onCancel",()=>{this.editor.getFocusedGroupId()!==this.editor.getCurrentPageId()&&this.editor.getSelectedShapeIds().length>0?this.editor.popFocusedGroupId():(this.editor.mark("clearing selection"),this.editor.selectNone())});m(this,"onKeyDown",n=>{switch(n.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!1);return}}if(jt.editOnType.get()&&!_Y.includes(n.key)&&!n.altKey&&!n.ctrlKey){const r=this.editor.getOnlySelectedShape();if(r&&this.editor.isShapeOfType(r,"note")&&this.shouldStartEditingShape(r)){this.startEditingShape(r,{...n,target:"shape",shape:r},!0);return}}});m(this,"onKeyRepeat",n=>{switch(n.code){case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{this.nudgeSelectedShapes(!0);break}}});m(this,"onKeyUp",n=>{switch(n.code){case"Enter":{const r=this.editor.getSelectedShapes();if(r.every(s=>this.editor.isShapeOfType(s,"group"))){this.editor.setSelectedShapes(r.flatMap(s=>this.editor.getSortedChildIdsForParent(s.id)));return}const o=this.editor.getOnlySelectedShape();if(o&&this.shouldStartEditingShape(o)){this.startEditingShape(o,{...n,target:"shape",shape:o},!0);return}OC(this.editor)&&this.parent.transition("crop",n);break}}});m(this,"isDarwin",window.navigator.userAgent.toLowerCase().indexOf("mac")>-1)}shouldStartEditingShape(n=this.editor.getOnlySelectedShape()){return!n||this.editor.isShapeOrAncestorLocked(n)&&n.type!=="embed"||!this.canInteractWithShapeInReadOnly(n)?!1:this.editor.getShapeUtil(n).canEdit(n)}startEditingShape(n,r,o){this.editor.isShapeOrAncestorLocked(n)&&n.type!=="embed"||(this.editor.mark("editing shape"),ef(this.editor,n,o),this.parent.transition("editing_shape",r))}isOverArrowLabelTest(n){if(!n)return!1;const r=this.editor.getPointInShapeSpace(n,this.editor.inputs.currentPagePoint);if(this.editor.isShapeOfType(n,"arrow")){const o=this.editor.getShapeGeometry(n).children[1];if(o&&Zn(r,o.vertices))return!0}return!1}handleDoubleClickOnCanvas(n){if(this.editor.getInstanceState().isReadonly)return;this.editor.mark("creating text shape");const r=He(),{x:o,y:s}=this.editor.inputs.currentPagePoint;this.editor.createShapes([{id:r,type:"text",x:o,y:s,props:{text:"",autoSize:!0}}]);const i=this.editor.getShape(r);if(!i)return;const a=this.editor.getShapeUtil(i);this.editor.getInstanceState().isReadonly&&!a.canEditInReadOnly(i)||(this.editor.setEditingShape(r),this.editor.select(r),this.parent.transition("editing_shape",n))}nudgeSelectedShapes(n=!1){const{editor:{inputs:{keys:r}}}=this,o=r.has("ShiftLeft"),s=new b(0,0);if(r.has("ArrowLeft")&&(s.x-=1),r.has("ArrowRight")&&(s.x+=1),r.has("ArrowUp")&&(s.y-=1),r.has("ArrowDown")&&(s.y+=1),s.equals(new b(0,0)))return;n||this.editor.mark("nudge shapes");const{gridSize:i}=this.editor.getDocumentSettings(),a=this.editor.getInstanceState().isGridMode?o?i*MY:i:o?TY:$Y,c=this.editor.getSelectedShapeIds();this.editor.nudgeShapes(c,s.mul(a)),Ye(this.editor,c)}canInteractWithShapeInReadOnly(n){return!!(!this.editor.getInstanceState().isReadonly||this.editor.getShapeUtil(n).canEditInReadOnly(n))}},m(jy,"id","idle"),jy);const TY=10,$Y=1,MY=5;function DC(e,t){const n=e.getSelectionRotatedPageBounds();if(!n)return!1;const r=e.getSelectionRotation();return r?Zn(t,n.corners.map(o=>b.RotWith(o,n.point,r))):n.containsPoint(t)}class nM extends se{constructor(){super(...arguments);m(this,"shapeId","");m(this,"markId","");m(this,"wasAlreadySelected",!1);m(this,"didDrag",!1);m(this,"info",{});m(this,"onEnter",n=>{const{shape:r}=n;this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.info=n,this.shapeId=r.id,this.didDrag=!1,this.wasAlreadySelected=this.editor.getOnlySelectedShapeId()===r.id,this.updateCursor();const s=this.editor.getShapeGeometry(r).children[1];if(!s)throw Error(`Expected to find an arrow label geometry for shape: ${r.id}`);const{currentPagePoint:i}=this.editor.inputs,a=this.editor.getPointInShapeSpace(r,i);this._labelDragOffset=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.setCursor({type:"default",rotation:0})});m(this,"_labelDragOffset",new b(0,0));m(this,"onPointerMove",()=>{const{isDragging:n}=this.editor.inputs;if(!n)return;const r=this.editor.getShape(this.shapeId);if(!r)return;const o=this.editor.getArrowInfo(r),s=this.editor.getShapeGeometry(r),i=s.children[0],a=this.editor.getPointInShapeSpace(r,this.editor.inputs.currentPagePoint),c=i.nearestPoint(b.Add(a,this._labelDragOffset));let l;if(o.isStraight){const u=b.Dist(o.start.point,o.end.point);l=1-b.Dist(o.end.point,c)/u}else{const{_center:u,measure:d,angleEnd:p,angleStart:f}=s.children[0];l=Wy(d,f,p,u.angle(c))}isNaN(l)&&(l=.5),this.didDrag=!0,this.editor.updateShape({id:r.id,type:r.type,props:{labelPosition:l}})});m(this,"onPointerUp",()=>{const n=this.editor.getShape(this.shapeId);n&&(this.didDrag||!this.wasAlreadySelected?this.complete():(this.editor.setEditingShape(n.id),this.editor.setCurrentTool("select.editing_shape")))});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}updateCursor(){this.editor.setCursor({type:"grabbing",rotation:0})}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}m(nM,"id","pointing_arrow_label");class rM extends se{constructor(){super(...arguments);m(this,"onEnter",()=>{const{inputs:n}=this.editor;n.shiftKey||this.editor.getSelectedShapeIds().length>0&&(this.editor.mark("selecting none"),this.editor.selectNone())});m(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.parent.transition("brushing",n)});m(this,"onPointerUp",()=>{nf(this.editor),this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onInterrupt",()=>{this.parent.transition("idle")})}complete(){this.parent.transition("idle")}}m(rM,"id","pointing_canvas");class oM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd);const r=this.editor.getSelectedShapes()[0];if(!r)return;const o=ac[this.info.handle];this.editor.setCursor({type:o,rotation:this.editor.getSelectionRotation()}),this.editor.setCroppingShape(r.id)});m(this,"onExit",()=>{this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0)});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startCropping()});m(this,"onLongPress",()=>{this.startCropping()});m(this,"onPointerUp",()=>{this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}startCropping(){this.editor.getInstanceState().isReadonly||this.parent.transition("cropping",{...this.info,onInteractionEnd:this.info.onInteractionEnd})}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):(this.editor.setCroppingShape(null),this.parent.transition("idle"))}}m(oM,"id","pointing_crop_handle");class sM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n;const{shape:r}=n;if(this.editor.isShapeOfType(r,"arrow")){const o=r.props[n.handle.id];(o==null?void 0:o.type)==="binding"&&this.editor.setHintingShapes([o.boundShapeId])}this.editor.setCursor({type:"grabbing",rotation:0})});m(this,"onExit",()=>{this.editor.setHintingShapes([]),this.editor.setCursor({type:"default",rotation:0})});m(this,"onPointerUp",()=>{const{shape:n,handle:r}=this.info;if(this.editor.isShapeOfType(n,"note")){const{editor:o}=this,s=RC(o,n,r,!1);if(s){ef(o,s,!0);return}}this.parent.transition("idle",this.info)});m(this,"onPointerMove",()=>{const{editor:n}=this;n.inputs.isDragging&&this.startDraggingHandle()});m(this,"onLongPress",()=>{this.startDraggingHandle()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}startDraggingHandle(){const{editor:n}=this;if(n.getInstanceState().isReadonly)return;const{shape:r,handle:o}=this.info;if(n.isShapeOfType(r,"note")){const s=RC(n,r,o,!0);if(s){const i=n.getPointInParentSpace(s,n.inputs.originPagePoint).sub(b.Rot(Rx,s.rotation));n.updateShape({...s,x:i.x,y:i.y}),n.setHoveredShape(s.id).select(s.id).setCurrentTool("select.translating",{...this.info,target:"shape",shape:n.getShape(s),onInteractionEnd:"note",isCreating:!0,onCreate:()=>{ef(n,s,!0)}});return}}this.parent.transition("dragging_handle",this.info)}cancel(){this.parent.transition("idle")}}m(sM,"id","pointing_handle");function RC(e,t,n,r){const o=e.getShapePageTransform(t.id),s=o.point(),i=o.rotation(),c=m$(s,i,t.props.growY,0)[n.index];if(c)return S$(e,t,c,i,r)}class iM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.info=n,this.updateCursor()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.setCursor({type:"default",rotation:0})});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.startRotating()});m(this,"onLongPress",()=>{this.startRotating()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}updateCursor(){this.editor.setCursor({type:ac[this.info.handle],rotation:this.editor.getSelectionRotation()})}startRotating(){this.editor.getInstanceState().isReadonly||this.parent.transition("rotating",this.info)}complete(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}cancel(){this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}}m(iM,"id","pointing_rotate_handle");class aM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n});m(this,"onPointerUp",n=>{nf(this.editor),this.parent.transition("idle",n)});m(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.startTranslating(n)});m(this,"onLongPress",n=>{this.startTranslating(n)});m(this,"onDoubleClick",n=>{var s,i;const r=this.editor.getHoveredShape(),o=r&&!this.editor.isShapeOfType(r,"group")?r:this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint,{hitInside:!0,margin:0,renderingOnly:!0});if(o){this.parent.transition("idle"),(i=(s=this.parent).onDoubleClick)==null||i.call(s,{...n,target:"shape",shape:this.editor.getShape(o)});return}});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}startTranslating(n){this.editor.getInstanceState().isReadonly||this.parent.transition("translating",n)}cancel(){this.parent.transition("idle")}}m(aM,"id","pointing_selection");class cM extends se{constructor(){super(...arguments);m(this,"hitShape",{});m(this,"hitShapeForPointerUp",{});m(this,"isDoubleClick",!1);m(this,"didSelectOnEnter",!1);m(this,"onEnter",n=>{const r=this.editor.getSelectedShapeIds(),o=this.editor.getSelectionRotatedPageBounds(),s=this.editor.getFocusedGroupId(),{inputs:{currentPagePoint:i,shiftKey:a,altKey:c}}=this.editor;this.hitShape=n.shape,this.isDoubleClick=!1;const l=this.editor.getOutermostSelectableShape(n.shape),u=this.editor.findShapeAncestor(l,d=>r.includes(d.id));if(this.editor.getShapeUtil(n.shape).onClick||l.id===s||r.includes(l.id)||u||r.length>1&&(o!=null&&o.containsPoint(i))){this.didSelectOnEnter=!1,this.hitShapeForPointerUp=l;return}this.didSelectOnEnter=!0,a&&!c?(this.editor.cancelDoubleClick(),r.includes(l.id)||(this.editor.mark("shift selecting shape"),this.editor.setSelectedShapes([...r,l.id]))):(this.editor.mark("selecting shape"),this.editor.setSelectedShapes([l.id]))});m(this,"onPointerUp",n=>{var u;const r=this.editor.getSelectedShapeIds(),o=this.editor.getFocusedGroupId(),s=this.editor.getZoomLevel(),{inputs:{currentPagePoint:i,shiftKey:a}}=this.editor,c=this.editor.getShapeAtPoint(i,{margin:Uo/s,hitInside:!0,renderingOnly:!0})??this.hitShape,l=c?this.editor.getOutermostSelectableShape(c):this.hitShapeForPointerUp;if(l){const d=this.editor.getShapeUtil(l);if(d.onClick){const p=(u=d.onClick)==null?void 0:u.call(d,l);if(p){this.editor.mark("shape on click"),this.editor.updateShapes([p]),this.parent.transition("idle",n);return}}if(l.id===o){r.length>0?(this.editor.mark("clearing shape ids"),this.editor.setSelectedShapes([])):this.editor.popFocusedGroupId(),this.parent.transition("idle",n);return}}if(!this.didSelectOnEnter){const d=this.editor.getOutermostSelectableShape(c,p=>!r.includes(p.id));if(r.includes(d.id))if(a)this.editor.mark("deselecting on pointer up"),this.editor.deselect(l);else if(r.includes(l.id)){if(r.length===1){const p=this.editor.getShapeUtil(l).getGeometry(l),f=eM(p),y=f.length===1?f[0]:void 0;if(y){const g=this.editor.getPointInShapeSpace(l,i);if(y.bounds.containsPoint(g,0)&&y.hitTestPoint(g)){this.editor.batch(()=>{this.editor.mark("editing on pointer up"),this.editor.select(l.id);const w=this.editor.getShapeUtil(l);this.editor.getInstanceState().isReadonly&&!w.canEditInReadOnly(l)||(this.editor.setEditingShape(l.id),this.editor.setCurrentTool("select.editing_shape"),this.isDoubleClick&&this.editor.emit("select-all-text",{shapeId:l.id}))});return}}}this.editor.mark("selecting on pointer up"),this.editor.select(l.id)}else this.editor.mark("selecting on pointer up"),this.editor.select(l);else if(a){const p=this.editor.getShapeAncestors(d);this.editor.mark("shift deselecting on pointer up"),this.editor.setSelectedShapes([...this.editor.getSelectedShapeIds().filter(f=>!p.find(y=>y.id===f)),d.id])}else this.editor.mark("selecting on pointer up"),this.editor.setSelectedShapes([d.id])}this.parent.transition("idle",n)});m(this,"onDoubleClick",()=>{this.isDoubleClick=!0});m(this,"onPointerMove",n=>{this.editor.inputs.isDragging&&this.startTranslating(n)});m(this,"onLongPress",n=>{this.startTranslating(n)});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.cancel()});m(this,"onInterrupt",()=>{this.cancel()})}startTranslating(n){this.editor.getInstanceState().isReadonly||(this.editor.getContainer().focus(),this.parent.transition("translating",n))}cancel(){this.parent.transition("idle")}}m(cM,"id","pointing_shape");class lM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"markId","");m(this,"didHoldCommand",!1);m(this,"creationCursorOffset",{x:0,y:0});m(this,"snapshot",{});m(this,"onEnter",n=>{const{isCreating:r=!1,creationCursorOffset:o={x:0,y:0}}=n;this.info=n,this.didHoldCommand=!1,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.creationCursorOffset=o,this.snapshot=this._createSnapshot(),r?(this.markId=`creating:${this.editor.getOnlySelectedShape().id}`,this.editor.setCursor({type:"cross",rotation:0})):(this.markId="starting resizing",this.editor.mark(this.markId)),this.handleResizeStart(),this.updateShapes()});m(this,"onTick",()=>{px(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.setCursor({type:"default",rotation:0}),this.editor.snaps.clearIndicators()});m(this,"_createSnapshot",()=>{const n=this.editor.getSelectedShapeIds(),r=this.editor.getSelectionRotation(),{inputs:{originPagePoint:o}}=this.editor,s=this.editor.getSelectionRotatedPageBounds(),i=b.RotWith(s.getHandlePoint(this.info.handle),s.point,r),a=b.Sub(o,i),c=new Map,l=[];n.forEach(d=>{const p=this.editor.getShape(d);if(p){if(p.type==="frame"&&l.push({id:d,children:fe(this.editor.getSortedChildIdsForParent(p).map(f=>this.editor.getShape(f)))}),c.set(p.id,this._createShapeSnapshot(p)),this.editor.isShapeOfType(p,"frame")&&n.length===1)return;this.editor.visitDescendants(p.id,f=>{const y=this.editor.getShape(f);if(y&&(c.set(y.id,this._createShapeSnapshot(y)),this.editor.isShapeOfType(y,"frame")))return!1})}});const u=![...c.values()].some(d=>!GE(d.pageRotation,r)||d.isAspectRatioLocked);return{shapeSnapshots:c,selectionBounds:s,cursorHandleOffset:a,selectionRotation:r,selectedShapeIds:n,canShapesDeform:u,initialSelectionPageBounds:this.editor.getSelectionPageBounds(),frames:l}});m(this,"_createShapeSnapshot",n=>{const r=this.editor.getShapePageTransform(n),o=this.editor.getShapeUtil(n);return{shape:n,bounds:this.editor.getShapeGeometry(n).bounds,pageTransform:r,pageRotation:oe.Decompose(r).rotation,isAspectRatioLocked:o.isAspectRatioLocked(n)}})}cancel(){this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,{}):this.parent.transition("idle")}complete(){var n,r;if(Ye(this.editor,this.snapshot.selectedShapeIds),this.handleResizeEnd(),this.info.isCreating&&this.info.onCreate){(r=(n=this.info).onCreate)==null||r.call(n,this.editor.getOnlySelectedShape());return}if(this.editor.getInstanceState().isToolLocked&&this.info.onInteractionEnd){this.editor.setCurrentTool(this.info.onInteractionEnd,{});return}this.parent.transition("idle")}handleResizeStart(){const{shapeSnapshots:n}=this.snapshot,r=[];n.forEach(({shape:o})=>{var a;const s=this.editor.getShapeUtil(o),i=(a=s.onResizeStart)==null?void 0:a.call(s,o);i&&r.push(i)}),r.length>0&&this.editor.updateShapes(r)}handleResizeEnd(){const{shapeSnapshots:n}=this.snapshot,r=[];n.forEach(({shape:o})=>{var c;const s=this.editor.getShape(o.id),i=this.editor.getShapeUtil(o),a=(c=i.onResizeEnd)==null?void 0:c.call(i,o,s);a&&r.push(a)}),r.length>0&&this.editor.updateShapes(r)}updateShapes(){const{altKey:n,shiftKey:r}=this.editor.inputs,{frames:o,shapeSnapshots:s,selectionBounds:i,cursorHandleOffset:a,selectedShapeIds:c,selectionRotation:l,canShapesDeform:u}=this.snapshot;let d=r||!u;if(s.size===1){const k=[...s.values()][0];this.editor.isShapeOfType(k.shape,"text")&&(d=!(this.info.handle==="left"||this.info.handle==="right"))}const{ctrlKey:p}=this.editor.inputs,f=this.editor.inputs.currentPagePoint.clone().sub(a).sub(this.creationCursorOffset),y=this.editor.inputs.originPagePoint.clone().sub(a);if(this.editor.getInstanceState().isGridMode&&!p){const{gridSize:k}=this.editor.getDocumentSettings();f.snapToGrid(k)}const g=this.info.handle,w=LC(g,Math.PI);if(this.editor.snaps.clearIndicators(),(this.editor.user.getIsSnapMode()?!p:p)&&l%Ue===0){const{nudge:k}=this.editor.snaps.shapeBounds.snapResizeShapes({dragDelta:b.Sub(f,y),initialSelectionPageBounds:this.snapshot.initialSelectionPageBounds,handle:LC(g,l),isAspectRatioLocked:d,isResizingFromCenter:n});f.add(k)}const v=b.RotWith(n?i.center:i.getHandlePoint(w),i.point,l),P=b.Sub(f,v).rot(-l),I=b.Sub(y,v).rot(-l),C=b.DivV(P,I);Number.isFinite(C.x)||(C.x=1),Number.isFinite(C.y)||(C.y=1);const E=g==="top"||g==="bottom",_=g==="left"||g==="right";d?_?C.y=Math.abs(C.x):E?C.x=Math.abs(C.y):Math.abs(C.x)>Math.abs(C.y)?C.y=Math.abs(C.x)*(C.y<0?-1:1):C.x=Math.abs(C.y)*(C.x<0?-1:1):(E&&(C.x=1),_&&(C.y=1)),this.info.isCreating||this.updateCursor({dragHandle:g,isFlippedX:C.x<0,isFlippedY:C.y<0,rotation:l});for(const k of s.keys()){const $=s.get(k);this.editor.resizeShape(k,C,{initialShape:$.shape,initialBounds:$.bounds,initialPageTransform:$.pageTransform,dragHandle:g,mode:c.length===1&&k===c[0]?"resize_bounds":"scale_shape",scaleOrigin:v,isAspectRatioLocked:d,scaleAxisRotation:l})}if(this.editor.inputs.ctrlKey){this.didHoldCommand=!0;for(const{id:k,children:$}of o){if(!$.length)continue;const T=s.get(k).shape,A=this.editor.getShape(k);if(!(T&&A))continue;const B=A.x-T.x,L=A.y-T.y,R=new b(B,L).rot(-T.rotation);if(R.x!==0||R.y!==0)for(const N of $)this.editor.updateShape({id:N.id,type:N.type,x:N.x-R.x,y:N.y-R.y})}}else if(this.didHoldCommand){this.didHoldCommand=!1;for(const{children:k}of o)if(k.length)for(const $ of k)this.editor.updateShape({id:$.id,type:$.type,x:$.x,y:$.y})}}updateCursor({dragHandle:n,isFlippedX:r,isFlippedY:o,rotation:s}){const i={...this.editor.getInstanceState().cursor};switch(n){case"top_left":case"bottom_right":{i.type="nwse-resize",r!==o&&(i.type="nesw-resize");break}case"top_right":case"bottom_left":{i.type="nesw-resize",r!==o&&(i.type="nwse-resize");break}}i.rotation=s,this.editor.setCursor(i)}}m(lM,"id","resizing");const Zm=["top","top_right","right","bottom_right","bottom","bottom_left","left","top_left"];function LC(e,t){t=t%Re;const n=Math.round(t/(Pe/4)),r=Zm.indexOf(e);return Zm[(r+n)%Zm.length]}const FC=Math.PI/180;class uM extends se{constructor(){super(...arguments);m(this,"snapshot",{});m(this,"info",{});m(this,"markId","");m(this,"onEnter",n=>{this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.markId="rotate start",this.editor.mark(this.markId);const r=FT({editor:this.editor});if(!r)return this.parent.transition("idle",this.info);this.snapshot=r;const o=this._getRotationFromPointerPosition({snapToNearestDegree:!1});fh({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!1}),snapshot:this.snapshot,stage:"start"}),this.editor.setCursor({type:ac[this.info.handle],rotation:o+this.snapshot.initialSelectionRotation})});m(this,"onExit",()=>{this.editor.setCursor({type:"default",rotation:0}),this.parent.setCurrentToolIdMask(void 0),this.snapshot={}});m(this,"onPointerMove",()=>{this.update()});m(this,"onKeyDown",()=>{this.update()});m(this,"onKeyUp",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"update",()=>{const n=this._getRotationFromPointerPosition({snapToNearestDegree:!1});fh({editor:this.editor,delta:n,snapshot:this.snapshot,stage:"update"}),this.editor.setCursor({type:ac[this.info.handle],rotation:n+this.snapshot.initialSelectionRotation})});m(this,"cancel",()=>{this.editor.bailToMark(this.markId),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)});m(this,"complete",()=>{fh({editor:this.editor,delta:this._getRotationFromPointerPosition({snapToNearestDegree:!0}),snapshot:this.snapshot,stage:"end"}),Ye(this.editor,this.snapshot.shapeSnapshots.map(n=>n.shape.id)),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("idle",this.info)})}_getRotationFromPointerPosition({snapToNearestDegree:n}){const r=this.editor.getSelectionRotation(),o=this.editor.getSelectionRotatedPageBounds(),{inputs:{shiftKey:s,currentPagePoint:i}}=this.editor,{initialCursorAngle:a,initialSelectionRotation:c}=this.snapshot;if(!o)return c;const u=o.center.clone().rotWith(o.point,r).angle(i)-a;let d=c+u;if(s)d=gp(d,24);else if(n&&(d=Math.round(d/FC)*FC,this.editor.getInstanceState().isCoarsePointer)){const p=gp(d,4),f=th(d,p);Math.abs(f)<E3(5)&&(d=p)}return d-c}}m(uM,"id","rotating");class dM extends se{constructor(){super(...arguments);m(this,"hits",new Set);m(this,"size",0);m(this,"scribbleId","id");m(this,"initialSelectedShapeIds",new Set);m(this,"newlySelectedShapeIds",new Set);m(this,"onEnter",()=>{this.initialSelectedShapeIds=new Set(this.editor.inputs.shiftKey?this.editor.getSelectedShapeIds():[]),this.newlySelectedShapeIds=new Set,this.size=0,this.hits.clear();const n=this.editor.scribbles.addScribble({color:"selection-stroke",opacity:.32,size:12});this.scribbleId=n.id,this.updateScribbleSelection(!0),this.editor.updateInstanceState({brush:null})});m(this,"onExit",()=>{this.editor.scribbles.stop(this.scribbleId)});m(this,"onPointerMove",()=>{this.updateScribbleSelection(!0)});m(this,"onPointerUp",()=>{this.complete()});m(this,"onKeyDown",()=>{this.updateScribbleSelection(!1)});m(this,"onKeyUp",()=>{this.editor.inputs.altKey?this.updateScribbleSelection(!1):this.parent.transition("brushing")});m(this,"onCancel",()=>{this.cancel()});m(this,"onComplete",()=>{this.complete()});m(this,"pushPointToScribble",()=>{const{x:n,y:r}=this.editor.inputs.currentPagePoint;this.editor.scribbles.addPoint(this.scribbleId,n,r)})}updateScribbleSelection(n){const{editor:r}=this,o=this.editor.getCurrentPageShapes(),{inputs:{shiftKey:s,originPagePoint:i,previousPagePoint:a,currentPagePoint:c}}=this.editor,{newlySelectedShapeIds:l,initialSelectedShapeIds:u}=this;n&&this.pushPointToScribble();const d=o;let p,f,y,g;const w=0;for(let P=0,I=d.length;P<I;P++){if(p=d[P],r.isShapeOfType(p,"group")||l.has(p.id)||r.isShapeOrAncestorLocked(p)||(f=r.getShapeGeometry(p),r.isShapeOfType(p,"frame")&&f.bounds.containsPoint(r.getPointInShapeSpace(p,i))))continue;const C=r.getShapePageTransform(p);if(!f||!C)continue;const E=C.clone().invert();y=E.applyToPoint(a),g=E.applyToPoint(c);const{bounds:_}=f;if(!(_.minX-w>Math.max(y.x,g.x)||_.minY-w>Math.max(y.y,g.y)||_.maxX+w<Math.min(y.x,g.x)||_.maxY+w<Math.min(y.y,g.y))&&f.hitTestLineSegment(y,g,w)){const k=this.editor.getOutermostSelectableShape(p),$=this.editor.getShapeMask(k.id);if($&&rx(a,c,$)!==null&&!Zn(c,$))continue;l.add(k.id)}}const S=r.getSelectedShapeIds(),v=new Set(s?[...l,...u]:[...l]);(S.length!==v.size||S.some(P=>!v.has(P)))&&this.editor.setSelectedShapes(Array.from(v))}complete(){this.updateScribbleSelection(!0),this.parent.transition("idle")}cancel(){this.editor.setSelectedShapes([...this.initialSelectedShapeIds]),this.parent.transition("idle")}}m(dM,"id","scribble_brushing");const AY=20,jY=100;class OY{constructor(t){m(this,"prevDroppingShapeId",null);m(this,"droppingNodeTimer",null);m(this,"first",!0);m(this,"dispose",()=>{this.clear()});this.editor=t,t.disposables.add(this.dispose)}updateDroppingNode(t,n){var r;this.first&&(this.editor.setHintingShapes(t.map(o=>this.editor.findShapeAncestor(o,s=>s.type!=="group")).filter(o=>o)),this.prevDroppingShapeId=((r=this.editor.getDroppingOverShape(this.editor.inputs.originPagePoint,t))==null?void 0:r.id)??null,this.first=!1),this.droppingNodeTimer===null?this.setDragTimer(t,AY,n):this.editor.inputs.pointerVelocity.len()>.5&&(clearInterval(this.droppingNodeTimer),this.setDragTimer(t,jY,n))}setDragTimer(t,n,r){this.droppingNodeTimer=setTimeout(()=>{this.editor.batch(()=>{this.handleDrag(this.editor.inputs.currentPagePoint,t,r)}),this.droppingNodeTimer=null},n)}handleDrag(t,n,r){var c,l,u,d,p;n=fe(n.map(f=>this.editor.getShape(f.id)));const o=((c=this.editor.getDroppingOverShape(t,n))==null?void 0:c.id)??null;if(o===this.prevDroppingShapeId){this.hintParents(n);return}const{prevDroppingShapeId:s}=this,i=s&&this.editor.getShape(s),a=o&&this.editor.getShape(o);i&&((u=(l=this.editor.getShapeUtil(i)).onDragShapesOut)==null||u.call(l,i,n)),a&&((p=(d=this.editor.getShapeUtil(a)).onDragShapesOver)==null||p.call(d,a,n)),this.hintParents(n),r==null||r(),this.prevDroppingShapeId=o}hintParents(t){const n=new Map;for(const o of t){const s=this.editor.findShapeAncestor(o,i=>i.type!=="group");s&&(n.has(s.id)||n.set(s.id,[]),n.get(s.id).push(o.id))}const r=[];for(const[o,s]of n){const i=this.editor.getShape(o);i&&p$(this.editor,i).length<s.length&&r.push(i.id)}this.editor.setHintingShapes(r)}dropShapes(t){var r,o;const{prevDroppingShapeId:n}=this;if(this.handleDrag(this.editor.inputs.currentPagePoint,t),n){const s=this.editor.getShape(n);if(!s)return;(o=(r=this.editor.getShapeUtil(s)).onDropShapesOver)==null||o.call(r,s,t)}}clear(){this.prevDroppingShapeId=null,this.droppingNodeTimer!==null&&clearInterval(this.droppingNodeTimer),this.droppingNodeTimer=null,this.editor.setHintingShapes([]),this.first=!0}}class hM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"selectionSnapshot",{});m(this,"snapshot",{});m(this,"markId","");m(this,"isCloning",!1);m(this,"isCreating",!1);m(this,"onCreate",()=>{});m(this,"dragAndDropManager",new OY(this.editor));m(this,"onEnter",n=>{var s;const{isCreating:r=!1,onCreate:o=()=>{}}=n;if(!((s=this.editor.getSelectedShapeIds())!=null&&s.length)){this.parent.transition("idle");return}if(this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.isCreating=r,this.onCreate=o,r?this.markId=`creating:${this.editor.getOnlySelectedShape().id}`:(this.markId="translating",this.editor.mark(this.markId)),this.isCloning=!1,this.info=n,this.editor.setCursor({type:"move",rotation:0}),this.selectionSnapshot=NC(this.editor),!this.isCreating&&this.editor.inputs.altKey){this.startCloning();return}this.snapshot=this.selectionSnapshot,this.handleStart(),this.updateShapes()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.selectionSnapshot={},this.snapshot={},this.editor.snaps.clearIndicators(),this.editor.setCursor({type:"default",rotation:0}),this.dragAndDropManager.clear()});m(this,"onTick",()=>{this.dragAndDropManager.updateDroppingNode(this.snapshot.movingShapes,this.updateParentTransforms),px(this.editor)});m(this,"onPointerMove",()=>{this.updateShapes()});m(this,"onKeyDown",()=>{if(this.editor.inputs.altKey&&!this.isCloning){this.startCloning();return}this.updateShapes()});m(this,"onKeyUp",()=>{if(!this.editor.inputs.altKey&&this.isCloning){this.stopCloning();return}this.updateShapes()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onComplete",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()});m(this,"updateParentTransforms",()=>{const{editor:n,snapshot:{shapeSnapshots:r}}=this;r.forEach(o=>{const s=n.getShape(o.shape.id);if(!s)return null;const i=Pn(s.parentId)?null:oe.Inverse(n.getShapePageTransform(s.parentId));o.parentTransform=i})})}startCloning(){this.isCreating||(this.isCloning=!0,this.reset(),this.markId="translating",this.editor.mark(this.markId),this.editor.duplicateShapes(Array.from(this.editor.getSelectedShapeIds())),this.snapshot=NC(this.editor),this.handleStart(),this.updateShapes())}stopCloning(){this.isCloning=!1,this.snapshot=this.selectionSnapshot,this.reset(),this.markId="translating",this.editor.mark(this.markId),this.updateShapes()}reset(){this.editor.bailToMark(this.markId)}complete(){var n;this.updateShapes(),this.dragAndDropManager.dropShapes(this.snapshot.movingShapes),Ye(this.editor,this.snapshot.movingShapes.map(r=>r.id)),this.handleEnd(),this.editor.getInstanceState().isToolLocked&&this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd):this.isCreating?(n=this.onCreate)==null||n.call(this,this.editor.getOnlySelectedShape()):this.parent.transition("idle")}cancel(){this.reset(),this.info.onInteractionEnd?this.editor.setCurrentTool(this.info.onInteractionEnd):this.parent.transition("idle",this.info)}handleStart(){const{movingShapes:n}=this.snapshot,r=[];n.forEach(o=>{var a;const s=this.editor.getShapeUtil(o),i=(a=s.onTranslateStart)==null?void 0:a.call(s,o);i&&r.push(i)}),r.length>0&&this.editor.updateShapes(r),this.editor.setHoveredShape(null)}handleEnd(){const{movingShapes:n}=this.snapshot;if(this.isCloning&&n.length>0){const o=b.Average(n.map(i=>this.editor.getShapePageTransform(i.id).point())),s=b.Sub(o,this.selectionSnapshot.averagePagePoint);b.IsNaN(s)||this.editor.updateInstanceState({duplicateProps:{shapeIds:n.map(i=>i.id),offset:{x:s.x,y:s.y}}})}const r=[];n.forEach(o=>{var c;const s=this.editor.getShape(o.id),i=this.editor.getShapeUtil(o),a=(c=i.onTranslateEnd)==null?void 0:c.call(i,o,s);a&&r.push(a)}),r.length>0&&this.editor.updateShapes(r)}updateShapes(){const{snapshot:n}=this;this.dragAndDropManager.updateDroppingNode(n.movingShapes,this.updateParentTransforms),DY({editor:this.editor,snapshot:n});const{movingShapes:r}=n,o=[];r.forEach(s=>{var l;const i=this.editor.getShape(s.id),a=this.editor.getShapeUtil(s),c=(l=a.onTranslate)==null?void 0:l.call(a,s,i);c&&o.push(c)}),o.length>0&&this.editor.updateShapes(o)}}m(hM,"id","translating");function NC(e){var d;const t=[],n=[],r=e.getSelectedShapeIds(),o=fe(r.map(p=>{const f=e.getShape(p);if(!f)return null;t.push(f);const y=e.getShapePageTransform(p),g=y.point(),w=y.rotation();n.push(g);const S=Bo.isId(f.parentId)?null:oe.Inverse(e.getShapePageTransform(f.parentId));return{shape:f,pagePoint:g,pageRotation:w,parentTransform:S}})),s=e.getOnlySelectedShape();let i=[];if(s)i=e.snaps.shapeBounds.getSnapPoints(s.id);else{const p=e.getSelectionPageBounds();p&&(i=p.cornersAndCenter.map((f,y)=>({id:"selection:"+y,x:f.x,y:f.y})))}let a,c;const{originPagePoint:l}=e.inputs,u=o.filter(p=>e.isShapeOfType(p.shape,"note")&&e.isPointInShape(p.shape,l));if(u.length!==0)if(u.length===1)c=u[0];else{const p=e.getCurrentPageShapesSorted();c=(d=u.map(f=>({snapshot:f,index:p.findIndex(y=>y.id===f.shape.id)})).sort((f,y)=>y.index-f.index)[0])==null?void 0:d.snapshot}return c&&(a=y$(e,c.pageRotation,c.shape.props.growY??0)),{averagePagePoint:b.Average(n),movingShapes:t,shapeSnapshots:o,initialPageBounds:e.getSelectionPageBounds(),initialSnapPoints:i,noteAdjacentPositions:a,noteSnapshot:c}}function DY({editor:e,snapshot:t}){const{inputs:n}=e,{noteSnapshot:r,noteAdjacentPositions:o,initialPageBounds:s,initialSnapPoints:i,shapeSnapshots:a,averagePagePoint:c}=t,l=e.getInstanceState().isGridMode,u=e.getDocumentSettings().gridSize,d=b.Sub(n.currentPagePoint,n.originPagePoint),p=e.inputs.shiftKey?Math.abs(d.x)<Math.abs(d.y)?"x":"y":null;if(p==="x"?d.x=0:p==="y"&&(d.y=0),e.snaps.clearIndicators(),(e.user.getIsSnapMode()?!n.ctrlKey:n.ctrlKey)&&e.inputs.pointerVelocity.len()<.5){const{nudge:w}=e.snaps.shapeBounds.snapTranslateShapes({dragDelta:d,initialSelectionPageBounds:s,lockedAxis:p,initialSelectionSnapPoints:i});d.add(w)}else if(r&&o){let w=g$/e.getZoomLevel(),S=new b(0,0);const v=b.Add(b.Add(r.pagePoint,d),new b($e/2,$e/2).rot(r.pageRotation));for(const P of o){const I=b.Sub(v,P),C=I.len();C<w&&(w=C,S=I)}d.sub(S)}const y=b.Add(c,d);l&&!n.ctrlKey&&y.snapToGrid(u);const g=b.Sub(y,c);e.updateShapes(fe(a.map(({shape:w,pagePoint:S,parentTransform:v})=>{const P=b.Add(S,g),I=v?oe.applyToPoint(v,P):P;return{id:w.id,type:w.type,x:I.x,y:I.y}})))}class Kh extends se{constructor(){super(...arguments);m(this,"reactor");m(this,"cleanUpDuplicateProps",()=>{const n=this.editor.getSelectedShapeIds(),r=this.editor.getInstanceState();if(!r.duplicateProps)return;const o=new Set(r.duplicateProps.shapeIds);n.length===o.size&&n.every(s=>o.has(s))||this.editor.updateInstanceState({duplicateProps:null})});m(this,"onEnter",()=>{this.reactor=hc("clean duplicate props",()=>{try{this.cleanUpDuplicateProps()}catch(n){typeof process<"u",console.error(n)}})});m(this,"onExit",()=>{var n;(n=this.reactor)==null||n.call(this),this.editor.getCurrentPageState().editingShapeId&&this.editor.setEditingShape(null)})}}m(Kh,"id","select"),m(Kh,"initial","idle"),m(Kh,"children",()=>[Hh,Q$,kY,rM,cM,hM,V$,dM,oM,aM,Z$,tM,lM,uM,iM,nM,sM,J$]);class pM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n});m(this,"onPointerDown",()=>{this.parent.transition("pointing",this.info)})}}m(pM,"id","idle");class fM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n});m(this,"onPointerUp",()=>{this.complete()});m(this,"onPointerMove",()=>{this.editor.inputs.isDragging&&this.parent.transition("zoom_brushing",this.info)});m(this,"onCancel",()=>{this.cancel()})}complete(){const{currentScreenPoint:n}=this.editor.inputs;this.editor.inputs.altKey?this.editor.zoomOut(n,{animation:{duration:220}}):this.editor.zoomIn(n,{animation:{duration:220}}),this.parent.transition("idle",this.info)}cancel(){this.parent.transition("idle",this.info)}}m(fM,"id","pointing");class gM extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"zoomBrush",new te);m(this,"onEnter",n=>{this.info=n,this.update()});m(this,"onExit",()=>{this.editor.updateInstanceState({zoomBrush:null})});m(this,"onPointerMove",()=>{this.update()});m(this,"onPointerUp",()=>{this.complete()});m(this,"onCancel",()=>{this.cancel()})}update(){const{inputs:{originPagePoint:n,currentPagePoint:r}}=this.editor;this.zoomBrush.setTo(te.FromPoints([n,r])),this.editor.updateInstanceState({zoomBrush:this.zoomBrush.toJson()})}cancel(){this.parent.transition("idle",this.info)}complete(){const{zoomBrush:n}=this,r=8/this.editor.getZoomLevel();if(n.width<r&&n.height<r){const o=this.editor.inputs.currentScreenPoint;this.editor.inputs.altKey?this.editor.zoomOut(o,{animation:{duration:220}}):this.editor.zoomIn(o,{animation:{duration:220}})}else{const o=this.editor.inputs.altKey?this.editor.getZoomLevel()/2:void 0;this.editor.zoomToBounds(n,{targetZoom:o,animation:{duration:220}})}this.parent.transition("idle",this.info)}}m(gM,"id","zoom_brushing");class Wh extends se{constructor(){super(...arguments);m(this,"info",{});m(this,"onEnter",n=>{this.info=n,this.parent.setCurrentToolIdMask(n.onInteractionEnd),this.updateCursor()});m(this,"onExit",()=>{this.parent.setCurrentToolIdMask(void 0),this.editor.updateInstanceState({zoomBrush:null,cursor:{type:"default",rotation:0}}),this.parent.setCurrentToolIdMask(void 0)});m(this,"onKeyDown",()=>{this.updateCursor()});m(this,"onKeyUp",n=>{this.updateCursor(),n.code==="KeyZ"&&this.complete()});m(this,"onInterrupt",()=>{this.complete()})}complete(){this.info.onInteractionEnd&&this.info.onInteractionEnd!=="select"?this.editor.setCurrentTool(this.info.onInteractionEnd,this.info):this.parent.transition("select")}updateCursor(){this.editor.inputs.altKey?this.editor.setCursor({type:"zoom-out",rotation:0}):this.editor.setCursor({type:"zoom-in",rotation:0})}}m(Wh,"id","zoom"),m(Wh,"initial","idle"),m(Wh,"children",()=>[pM,gM,fM]);const RY=[zh,Bh,Uh,Wh,Kh];function Z(){return Z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Z.apply(null,arguments)}function ie(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function LY(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function Jf(...e){return t=>e.forEach(n=>LY(n,t))}function Ze(...e){return x.useCallback(Jf(...e),e)}function So(e,t=[]){let n=[];function r(s,i){const a=x.createContext(i),c=n.length;n=[...n,i];function l(d){const{scope:p,children:f,...y}=d,g=(p==null?void 0:p[e][c])||a,w=x.useMemo(()=>y,Object.values(y));return x.createElement(g.Provider,{value:w},f)}function u(d,p){const f=(p==null?void 0:p[e][c])||a,y=x.useContext(f);if(y)return y;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${s}\``)}return l.displayName=s+"Provider",[l,u]}const o=()=>{const s=n.map(i=>x.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return x.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,FY(o,...t)]}function FY(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:c,scopeName:l})=>{const d=c(s)[`__scope${l}`];return{...a,...d}},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}const Ai=x.forwardRef((e,t)=>{const{children:n,...r}=e,o=x.Children.toArray(n),s=o.find(zY);if(s){const i=s.props.children,a=o.map(c=>c===s?x.Children.count(i)>1?x.Children.only(null):x.isValidElement(i)?i.props.children:null:c);return x.createElement(mv,Z({},r,{ref:t}),x.isValidElement(i)?x.cloneElement(i,void 0,a):null)}return x.createElement(mv,Z({},r,{ref:t}),n)});Ai.displayName="Slot";const mv=x.forwardRef((e,t)=>{const{children:n,...r}=e;return x.isValidElement(n)?x.cloneElement(n,{...BY(r,n.props),ref:t?Jf(t,n.ref):n.ref}):x.Children.count(n)>1?x.Children.only(null):null});mv.displayName="SlotClone";const NY=({children:e})=>x.createElement(x.Fragment,null,e);function zY(e){return x.isValidElement(e)&&e.type===NY}function BY(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function eg(e){const t=e+"CollectionProvider",[n,r]=So(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=f=>{const{scope:y,children:g}=f,w=Se.useRef(null),S=Se.useRef(new Map).current;return Se.createElement(o,{scope:y,itemMap:S,collectionRef:w},g)},a=e+"CollectionSlot",c=Se.forwardRef((f,y)=>{const{scope:g,children:w}=f,S=s(a,g),v=Ze(y,S.collectionRef);return Se.createElement(Ai,{ref:v},w)}),l=e+"CollectionItemSlot",u="data-radix-collection-item",d=Se.forwardRef((f,y)=>{const{scope:g,children:w,...S}=f,v=Se.useRef(null),P=Ze(y,v),I=s(l,g);return Se.useEffect(()=>(I.itemMap.set(v,{ref:v,...S}),()=>void I.itemMap.delete(v))),Se.createElement(Ai,{[u]:"",ref:P},w)});function p(f){const y=s(e+"CollectionConsumer",f);return Se.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${u}]`));return Array.from(y.itemMap.values()).sort((I,C)=>S.indexOf(I.ref.current)-S.indexOf(C.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:c,ItemSlot:d},p,r]}const UY=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Ve=UY.reduce((e,t)=>{const n=x.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Ai:t;return x.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),x.createElement(a,Z({},i,{ref:o}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Wx(e,t){e&&Bi.flushSync(()=>e.dispatchEvent(t))}function ln(e){const t=x.useRef(e);return x.useEffect(()=>{t.current=e}),x.useMemo(()=>(...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function HY(e,t=globalThis==null?void 0:globalThis.document){const n=ln(e);x.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)},[n,t])}const yv="dismissableLayer.update",KY="dismissableLayer.pointerDownOutside",WY="dismissableLayer.focusOutside";let zC;const mM=x.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),tg=x.forwardRef((e,t)=>{var n;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:a,onDismiss:c,...l}=e,u=x.useContext(mM),[d,p]=x.useState(null),f=(n=d==null?void 0:d.ownerDocument)!==null&&n!==void 0?n:globalThis==null?void 0:globalThis.document,[,y]=x.useState({}),g=Ze(t,k=>p(k)),w=Array.from(u.layers),[S]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=w.indexOf(S),P=d?w.indexOf(d):-1,I=u.layersWithOutsidePointerEventsDisabled.size>0,C=P>=v,E=VY(k=>{const $=k.target,T=[...u.branches].some(A=>A.contains($));!C||T||(s==null||s(k),a==null||a(k),k.defaultPrevented||c==null||c())},f),_=YY(k=>{const $=k.target;[...u.branches].some(A=>A.contains($))||(i==null||i(k),a==null||a(k),k.defaultPrevented||c==null||c())},f);return HY(k=>{P===u.layers.size-1&&(o==null||o(k),!k.defaultPrevented&&c&&(k.preventDefault(),c()))},f),x.useEffect(()=>{if(d)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(zC=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),BC(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=zC)}},[d,f,r,u]),x.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),BC())},[d,u]),x.useEffect(()=>{const k=()=>y({});return document.addEventListener(yv,k),()=>document.removeEventListener(yv,k)},[]),x.createElement(Ve.div,Z({},l,{ref:g,style:{pointerEvents:I?C?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,_.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,E.onPointerDownCapture)}))}),GY=x.forwardRef((e,t)=>{const n=x.useContext(mM),r=x.useRef(null),o=Ze(t,r);return x.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),x.createElement(Ve.div,Z({},e,{ref:o}))});function VY(e,t=globalThis==null?void 0:globalThis.document){const n=ln(e),r=x.useRef(!1),o=x.useRef(()=>{});return x.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let u=function(){yM(KY,n,l,{discrete:!0})};var c=u;const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function YY(e,t=globalThis==null?void 0:globalThis.document){const n=ln(e),r=x.useRef(!1);return x.useEffect(()=>{const o=s=>{s.target&&!r.current&&yM(WY,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function BC(){const e=new CustomEvent(yv);document.dispatchEvent(e)}function yM(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Wx(o,s):o.dispatchEvent(s)}const XY=tg,qY=GY,ng=x.forwardRef((e,t)=>{var n;const{container:r=globalThis==null||(n=globalThis.document)===null||n===void 0?void 0:n.body,...o}=e;return r?Oz.createPortal(x.createElement(Ve.div,Z({},o,{ref:t})),r):null}),ji=globalThis!=null&&globalThis.document?x.useLayoutEffect:()=>{};function ZY(e,t){return x.useReducer((n,r)=>{const o=t[n][r];return o??n},e)}const vo=e=>{const{present:t,children:n}=e,r=QY(t),o=typeof n=="function"?n({present:r.isPresent}):x.Children.only(n),s=Ze(r.ref,o.ref);return typeof n=="function"||r.isPresent?x.cloneElement(o,{ref:s}):null};vo.displayName="Presence";function QY(e){const[t,n]=x.useState(),r=x.useRef({}),o=x.useRef(e),s=x.useRef("none"),i=e?"mounted":"unmounted",[a,c]=ZY(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const l=Rd(r.current);s.current=a==="mounted"?l:"none"},[a]),ji(()=>{const l=r.current,u=o.current;if(u!==e){const p=s.current,f=Rd(l);e?c("MOUNT"):f==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(u&&p!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),ji(()=>{if(t){const l=d=>{const f=Rd(r.current).includes(d.animationName);d.target===t&&f&&Bi.flushSync(()=>c("ANIMATION_END"))},u=d=>{d.target===t&&(s.current=Rd(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",l),t.addEventListener("animationend",l),()=>{t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",l),t.removeEventListener("animationend",l)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:x.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function Rd(e){return(e==null?void 0:e.animationName)||"none"}function Zs({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=JY({defaultProp:t,onChange:n}),s=e!==void 0,i=s?e:r,a=ln(n),c=x.useCallback(l=>{if(s){const d=typeof l=="function"?l(e):l;d!==e&&a(d)}else o(l)},[s,e,o,a]);return[i,c]}function JY({defaultProp:e,onChange:t}){const n=x.useState(e),[r]=n,o=x.useRef(r),s=ln(t);return x.useEffect(()=>{o.current!==r&&(s(r),o.current=r)},[r,o,s]),n}const SM=x.forwardRef((e,t)=>x.createElement(Ve.span,Z({},e,{ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}))),vM="ToastProvider",[Gx,eX,tX]=eg("Toast"),[xM,Roe]=So("Toast",[tX]),[nX,rg]=xM(vM),wM=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,c]=x.useState(null),[l,u]=x.useState(0),d=x.useRef(!1),p=x.useRef(!1);return x.createElement(Gx.Provider,{scope:t},x.createElement(nX,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:l,viewport:a,onViewportChange:c,onToastAdd:x.useCallback(()=>u(f=>f+1),[]),onToastRemove:x.useCallback(()=>u(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:d,isClosePausedRef:p},i))};wM.propTypes={label(e){if(e.label&&typeof e.label=="string"&&!e.label.trim()){const t=`Invalid prop \`label\` supplied to \`${vM}\`. Expected non-empty \`string\`.`;return new Error(t)}return null}};const rX="ToastViewport",oX=["F8"],Sv="toast.viewportPause",vv="toast.viewportResume",sX=x.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=oX,label:o="Notifications ({hotkey})",...s}=e,i=rg(rX,n),a=eX(n),c=x.useRef(null),l=x.useRef(null),u=x.useRef(null),d=x.useRef(null),p=Ze(t,d,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),y=i.toastCount>0;x.useEffect(()=>{const w=S=>{var v;r.every(I=>S[I]||S.code===I)&&((v=d.current)===null||v===void 0||v.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[r]),x.useEffect(()=>{const w=c.current,S=d.current;if(y&&w&&S){const v=()=>{if(!i.isClosePausedRef.current){const E=new CustomEvent(Sv);S.dispatchEvent(E),i.isClosePausedRef.current=!0}},P=()=>{if(i.isClosePausedRef.current){const E=new CustomEvent(vv);S.dispatchEvent(E),i.isClosePausedRef.current=!1}},I=E=>{!w.contains(E.relatedTarget)&&P()},C=()=>{w.contains(document.activeElement)||P()};return w.addEventListener("focusin",v),w.addEventListener("focusout",I),w.addEventListener("pointermove",v),w.addEventListener("pointerleave",C),window.addEventListener("blur",v),window.addEventListener("focus",P),()=>{w.removeEventListener("focusin",v),w.removeEventListener("focusout",I),w.removeEventListener("pointermove",v),w.removeEventListener("pointerleave",C),window.removeEventListener("blur",v),window.removeEventListener("focus",P)}}},[y,i.isClosePausedRef]);const g=x.useCallback(({tabbingDirection:w})=>{const v=a().map(P=>{const I=P.ref.current,C=[I,...wX(I)];return w==="forwards"?C:C.reverse()});return(w==="forwards"?v.reverse():v).flat()},[a]);return x.useEffect(()=>{const w=d.current;if(w){const S=v=>{const P=v.altKey||v.ctrlKey||v.metaKey;if(v.key==="Tab"&&!P){const k=document.activeElement,$=v.shiftKey;if(v.target===w&&$){var C;(C=l.current)===null||C===void 0||C.focus();return}const B=g({tabbingDirection:$?"backwards":"forwards"}),L=B.findIndex(R=>R===k);if(Qm(B.slice(L+1)))v.preventDefault();else{var E,_;$?(E=l.current)===null||E===void 0||E.focus():(_=u.current)===null||_===void 0||_.focus()}}};return w.addEventListener("keydown",S),()=>w.removeEventListener("keydown",S)}},[a,g]),x.createElement(qY,{ref:c,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:y?void 0:"none"}},y&&x.createElement(UC,{ref:l,onFocusFromOutsideViewport:()=>{const w=g({tabbingDirection:"forwards"});Qm(w)}}),x.createElement(Gx.Slot,{scope:n},x.createElement(Ve.ol,Z({tabIndex:-1},s,{ref:p}))),y&&x.createElement(UC,{ref:u,onFocusFromOutsideViewport:()=>{const w=g({tabbingDirection:"backwards"});Qm(w)}}))}),iX="ToastFocusProxy",UC=x.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=rg(iX,n);return x.createElement(SM,Z({"aria-hidden":!0,tabIndex:0},o,{ref:t,style:{position:"fixed"},onFocus:i=>{var a;const c=i.relatedTarget;!((a=s.viewport)!==null&&a!==void 0&&a.contains(c))&&r()}}))}),og="Toast",aX="toast.swipeStart",cX="toast.swipeMove",lX="toast.swipeCancel",uX="toast.swipeEnd",dX=x.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a=!0,c]=Zs({prop:r,defaultProp:o,onChange:s});return x.createElement(vo,{present:n||a},x.createElement(bM,Z({open:a},i,{ref:t,onClose:()=>c(!1),onPause:ln(e.onPause),onResume:ln(e.onResume),onSwipeStart:ie(e.onSwipeStart,l=>{l.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,l=>{const{x:u,y:d}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","move"),l.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${d}px`)}),onSwipeCancel:ie(e.onSwipeCancel,l=>{l.currentTarget.setAttribute("data-swipe","cancel"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ie(e.onSwipeEnd,l=>{const{x:u,y:d}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","end"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${u}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${d}px`),c(!1)})})))}),[hX,pX]=xM(og,{onClose(){}}),bM=x.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:c,onResume:l,onSwipeStart:u,onSwipeMove:d,onSwipeCancel:p,onSwipeEnd:f,...y}=e,g=rg(og,n),[w,S]=x.useState(null),v=Ze(t,R=>S(R)),P=x.useRef(null),I=x.useRef(null),C=o||g.duration,E=x.useRef(0),_=x.useRef(C),k=x.useRef(0),{onToastAdd:$,onToastRemove:T}=g,A=ln(()=>{var R;(w==null?void 0:w.contains(document.activeElement))&&((R=g.viewport)===null||R===void 0||R.focus()),i()}),B=x.useCallback(R=>{!R||R===1/0||(window.clearTimeout(k.current),E.current=new Date().getTime(),k.current=window.setTimeout(A,R))},[A]);x.useEffect(()=>{const R=g.viewport;if(R){const N=()=>{B(_.current),l==null||l()},X=()=>{const q=new Date().getTime()-E.current;_.current=_.current-q,window.clearTimeout(k.current),c==null||c()};return R.addEventListener(Sv,X),R.addEventListener(vv,N),()=>{R.removeEventListener(Sv,X),R.removeEventListener(vv,N)}}},[g.viewport,C,c,l,B]),x.useEffect(()=>{s&&!g.isClosePausedRef.current&&B(C)},[s,C,g.isClosePausedRef,B]),x.useEffect(()=>($(),()=>T()),[$,T]);const L=x.useMemo(()=>w?EM(w):null,[w]);return g.viewport?x.createElement(x.Fragment,null,L&&x.createElement(fX,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0},L),x.createElement(hX,{scope:n,onClose:A},Bi.createPortal(x.createElement(Gx.ItemSlot,{scope:n},x.createElement(XY,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||A(),g.isFocusedToastEscapeKeyDownRef.current=!1})},x.createElement(Ve.li,Z({role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection},y,{ref:v,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,R=>{R.key==="Escape"&&(a==null||a(R.nativeEvent),R.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,A()))}),onPointerDown:ie(e.onPointerDown,R=>{R.button===0&&(P.current={x:R.clientX,y:R.clientY})}),onPointerMove:ie(e.onPointerMove,R=>{if(!P.current)return;const N=R.clientX-P.current.x,X=R.clientY-P.current.y,q=!!I.current,H=["left","right"].includes(g.swipeDirection),U=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,W=H?U(0,N):0,Q=H?0:U(0,X),le=R.pointerType==="touch"?10:2,be={x:W,y:Q},Ae={originalEvent:R,delta:be};q?(I.current=be,Ld(cX,d,Ae,{discrete:!1})):HC(be,g.swipeDirection,le)?(I.current=be,Ld(aX,u,Ae,{discrete:!1}),R.target.setPointerCapture(R.pointerId)):(Math.abs(N)>le||Math.abs(X)>le)&&(P.current=null)}),onPointerUp:ie(e.onPointerUp,R=>{const N=I.current,X=R.target;if(X.hasPointerCapture(R.pointerId)&&X.releasePointerCapture(R.pointerId),I.current=null,P.current=null,N){const q=R.currentTarget,H={originalEvent:R,delta:N};HC(N,g.swipeDirection,g.swipeThreshold)?Ld(uX,f,H,{discrete:!0}):Ld(lX,p,H,{discrete:!0}),q.addEventListener("click",U=>U.preventDefault(),{once:!0})}})})))),g.viewport))):null});bM.propTypes={type(e){if(e.type&&!["foreground","background"].includes(e.type)){const t=`Invalid prop \`type\` supplied to \`${og}\`. Expected \`foreground | background\`.`;return new Error(t)}return null}};const fX=e=>{const{__scopeToast:t,children:n,...r}=e,o=rg(og,t),[s,i]=x.useState(!1),[a,c]=x.useState(!1);return vX(()=>i(!0)),x.useEffect(()=>{const l=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(l)},[]),a?null:x.createElement(ng,{asChild:!0},x.createElement(SM,r,s&&x.createElement(x.Fragment,null,o.label," ",n)))},gX=x.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return x.createElement(Ve.div,Z({},r,{ref:t}))}),mX=x.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return x.createElement(Ve.div,Z({},r,{ref:t}))}),yX="ToastAction",PM=x.forwardRef((e,t)=>{const{altText:n,...r}=e;return n?x.createElement(IM,{altText:n,asChild:!0},x.createElement(CM,Z({},r,{ref:t}))):null});PM.propTypes={altText(e){return e.altText?null:new Error(`Missing prop \`altText\` expected on \`${yX}\``)}};const SX="ToastClose",CM=x.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=pX(SX,n);return x.createElement(IM,{asChild:!0},x.createElement(Ve.button,Z({type:"button"},r,{ref:t,onClick:ie(e.onClick,o.onClose)})))}),IM=x.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return x.createElement(Ve.div,Z({"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0},o,{ref:t}))});function EM(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),xX(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...EM(r))}}),t}function Ld(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Wx(o,s):o.dispatchEvent(s)}const HC=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function vX(e=()=>{}){const t=ln(e);ji(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function xX(e){return e.nodeType===e.ELEMENT_NODE}function wX(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Qm(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}const bX=dX,PX=gX,CX=mX,IX=PM,KC=CM,EX=cD.useId||(()=>{});let _X=0;function zo(e){const[t,n]=x.useState(EX());return ji(()=>{e||n(r=>r??String(_X++))},[e]),e||(t?`radix-${t}`:"")}const Jm="focusScope.autoFocusOnMount",ey="focusScope.autoFocusOnUnmount",WC={bubbles:!1,cancelable:!0},Vx=x.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=x.useState(null),l=ln(o),u=ln(s),d=x.useRef(null),p=Ze(t,g=>c(g)),f=x.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;x.useEffect(()=>{if(r){let v=function(E){if(f.paused||!a)return;const _=E.target;a.contains(_)?d.current=_:ms(d.current,{select:!0})},P=function(E){if(f.paused||!a)return;const _=E.relatedTarget;_!==null&&(a.contains(_)||ms(d.current,{select:!0}))},I=function(E){if(document.activeElement===document.body)for(const k of E)k.removedNodes.length>0&&ms(a)};var g=v,w=P,S=I;document.addEventListener("focusin",v),document.addEventListener("focusout",P);const C=new MutationObserver(I);return a&&C.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",P),C.disconnect()}}},[r,a,f.paused]),x.useEffect(()=>{if(a){VC.add(f);const g=document.activeElement;if(!a.contains(g)){const S=new CustomEvent(Jm,WC);a.addEventListener(Jm,l),a.dispatchEvent(S),S.defaultPrevented||(kX(jX(_M(a)),{select:!0}),document.activeElement===g&&ms(a))}return()=>{a.removeEventListener(Jm,l),setTimeout(()=>{const S=new CustomEvent(ey,WC);a.addEventListener(ey,u),a.dispatchEvent(S),S.defaultPrevented||ms(g??document.body,{select:!0}),a.removeEventListener(ey,u),VC.remove(f)},0)}}},[a,l,u,f]);const y=x.useCallback(g=>{if(!n&&!r||f.paused)return;const w=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,S=document.activeElement;if(w&&S){const v=g.currentTarget,[P,I]=TX(v);P&&I?!g.shiftKey&&S===I?(g.preventDefault(),n&&ms(P,{select:!0})):g.shiftKey&&S===P&&(g.preventDefault(),n&&ms(I,{select:!0})):S===v&&g.preventDefault()}},[n,r,f.paused]);return x.createElement(Ve.div,Z({tabIndex:-1},i,{ref:p,onKeyDown:y}))});function kX(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(ms(r,{select:t}),document.activeElement!==n)return}function TX(e){const t=_M(e),n=GC(t,e),r=GC(t.reverse(),e);return[n,r]}function _M(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function GC(e,t){for(const n of e)if(!$X(n,{upTo:t}))return n}function $X(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function MX(e){return e instanceof HTMLInputElement&&"select"in e}function ms(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&MX(e)&&t&&e.select()}}const VC=AX();function AX(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=YC(e,t),e.unshift(t)},remove(t){var n;e=YC(e,t),(n=e[0])===null||n===void 0||n.resume()}}}function YC(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function jX(e){return e.filter(t=>t.tagName!=="A")}let ty=0;function Yx(){x.useEffect(()=>{var e,t;const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(e=n[0])!==null&&e!==void 0?e:XC()),document.body.insertAdjacentElement("beforeend",(t=n[1])!==null&&t!==void 0?t:XC()),ty++,()=>{ty===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),ty--}},[])}function XC(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}var eo=function(){return eo=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},eo.apply(this,arguments)};function kM(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function OX(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var Gh="right-scroll-bar-position",Vh="width-before-scroll-bar",DX="with-scroll-bars-hidden",RX="--removed-body-scroll-bar-size";function ny(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function LX(e,t){var n=x.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var FX=typeof window<"u"?x.useLayoutEffect:x.useEffect,qC=new WeakMap;function NX(e,t){var n=LX(null,function(r){return e.forEach(function(o){return ny(o,r)})});return FX(function(){var r=qC.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ny(a,null)}),s.forEach(function(a){o.has(a)||ny(a,i)})}qC.set(n,e)},[e]),n}function zX(e){return e}function BX(e,t){t===void 0&&(t=zX);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var c=function(){var u=i;i=[],u.forEach(s)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(u){i.push(u),l()},filter:function(u){return i=i.filter(u),n}}}};return o}function UX(e){e===void 0&&(e={});var t=BX(null);return t.options=eo({async:!0,ssr:!1},e),t}var TM=function(e){var t=e.sideCar,n=kM(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return x.createElement(r,eo({},n))};TM.isSideCarExport=!0;function HX(e,t){return e.useMedium(t),TM}var $M=UX(),ry=function(){},sg=x.forwardRef(function(e,t){var n=x.useRef(null),r=x.useState({onScrollCapture:ry,onWheelCapture:ry,onTouchMoveCapture:ry}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,p=e.sideCar,f=e.noIsolation,y=e.inert,g=e.allowPinchZoom,w=e.as,S=w===void 0?"div":w,v=kM(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),P=p,I=NX([n,t]),C=eo(eo({},v),o);return x.createElement(x.Fragment,null,u&&x.createElement(P,{sideCar:$M,removeScrollBar:l,shards:d,noIsolation:f,inert:y,setCallbacks:s,allowPinchZoom:!!g,lockRef:n}),i?x.cloneElement(x.Children.only(a),eo(eo({},C),{ref:I})):x.createElement(S,eo({},C,{className:c,ref:I}),a))});sg.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};sg.classNames={fullWidth:Vh,zeroRight:Gh};var KX=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function WX(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=KX();return t&&e.setAttribute("nonce",t),e}function GX(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function VX(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var YX=function(){var e=0,t=null;return{add:function(n){e==0&&(t=WX())&&(GX(t,n),VX(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},XX=function(){var e=YX();return function(t,n){x.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},MM=function(){var e=XX(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},qX={left:0,top:0,right:0,gap:0},oy=function(e){return parseInt(e||"",10)||0},ZX=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[oy(n),oy(r),oy(o)]},QX=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return qX;var t=ZX(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},JX=MM(),Wa="data-scroll-locked",eq=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
180
|
-
.`.concat(DX,` {
|
|
181
|
-
overflow: hidden `).concat(r,`;
|
|
182
|
-
padding-right: `).concat(a,"px ").concat(r,`;
|
|
183
|
-
}
|
|
184
|
-
body[`).concat(Wa,`] {
|
|
185
|
-
overflow: hidden `).concat(r,`;
|
|
186
|
-
overscroll-behavior: contain;
|
|
187
|
-
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
188
|
-
padding-left: `.concat(o,`px;
|
|
189
|
-
padding-top: `).concat(s,`px;
|
|
190
|
-
padding-right: `).concat(i,`px;
|
|
191
|
-
margin-left:0;
|
|
192
|
-
margin-top:0;
|
|
193
|
-
margin-right: `).concat(a,"px ").concat(r,`;
|
|
194
|
-
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.`).concat(Gh,` {
|
|
198
|
-
right: `).concat(a,"px ").concat(r,`;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.`).concat(Vh,` {
|
|
202
|
-
margin-right: `).concat(a,"px ").concat(r,`;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.`).concat(Gh," .").concat(Gh,` {
|
|
206
|
-
right: 0 `).concat(r,`;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
.`).concat(Vh," .").concat(Vh,` {
|
|
210
|
-
margin-right: 0 `).concat(r,`;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
body[`).concat(Wa,`] {
|
|
214
|
-
`).concat(RX,": ").concat(a,`px;
|
|
215
|
-
}
|
|
216
|
-
`)},ZC=function(){var e=parseInt(document.body.getAttribute(Wa)||"0",10);return isFinite(e)?e:0},tq=function(){x.useEffect(function(){return document.body.setAttribute(Wa,(ZC()+1).toString()),function(){var e=ZC()-1;e<=0?document.body.removeAttribute(Wa):document.body.setAttribute(Wa,e.toString())}},[])},nq=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;tq();var s=x.useMemo(function(){return QX(o)},[o]);return x.createElement(JX,{styles:eq(s,!t,o,n?"":"!important")})},xv=!1;if(typeof window<"u")try{var Fd=Object.defineProperty({},"passive",{get:function(){return xv=!0,!0}});window.addEventListener("test",Fd,Fd),window.removeEventListener("test",Fd,Fd)}catch{xv=!1}var ia=xv?{passive:!1}:!1,rq=function(e){return e.tagName==="TEXTAREA"},AM=function(e,t){var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!rq(e)&&n[t]==="visible")},oq=function(e){return AM(e,"overflowY")},sq=function(e){return AM(e,"overflowX")},QC=function(e,t){var n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var r=jM(e,n);if(r){var o=OM(e,n),s=o[1],i=o[2];if(s>i)return!0}n=n.parentNode}while(n&&n!==document.body);return!1},iq=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},aq=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},jM=function(e,t){return e==="v"?oq(t):sq(t)},OM=function(e,t){return e==="v"?iq(t):aq(t)},cq=function(e,t){return e==="h"&&t==="rtl"?-1:1},lq=function(e,t,n,r,o){var s=cq(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,c=t.contains(a),l=!1,u=i>0,d=0,p=0;do{var f=OM(e,a),y=f[0],g=f[1],w=f[2],S=g-w-s*y;(y||S)&&jM(e,a)&&(d+=S,p+=y),a=a.parentNode}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(u&&(d===0||!o)||!u&&(p===0||!o))&&(l=!0),l},Nd=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},JC=function(e){return[e.deltaX,e.deltaY]},eI=function(e){return e&&"current"in e?e.current:e},uq=function(e,t){return e[0]===t[0]&&e[1]===t[1]},dq=function(e){return`
|
|
217
|
-
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
218
|
-
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
219
|
-
`)},hq=0,aa=[];function pq(e){var t=x.useRef([]),n=x.useRef([0,0]),r=x.useRef(),o=x.useState(hq++)[0],s=x.useState(function(){return MM()})[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=OX([e.lockRef.current],(e.shards||[]).map(eI),!0).filter(Boolean);return g.forEach(function(w){return w.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=x.useCallback(function(g,w){if("touches"in g&&g.touches.length===2)return!i.current.allowPinchZoom;var S=Nd(g),v=n.current,P="deltaX"in g?g.deltaX:v[0]-S[0],I="deltaY"in g?g.deltaY:v[1]-S[1],C,E=g.target,_=Math.abs(P)>Math.abs(I)?"h":"v";if("touches"in g&&_==="h"&&E.type==="range")return!1;var k=QC(_,E);if(!k)return!0;if(k?C=_:(C=_==="v"?"h":"v",k=QC(_,E)),!k)return!1;if(!r.current&&"changedTouches"in g&&(P||I)&&(r.current=C),!C)return!0;var $=r.current||C;return lq($,w,g,$==="h"?P:I,!0)},[]),c=x.useCallback(function(g){var w=g;if(!(!aa.length||aa[aa.length-1]!==s)){var S="deltaY"in w?JC(w):Nd(w),v=t.current.filter(function(C){return C.name===w.type&&C.target===w.target&&uq(C.delta,S)})[0];if(v&&v.should){w.cancelable&&w.preventDefault();return}if(!v){var P=(i.current.shards||[]).map(eI).filter(Boolean).filter(function(C){return C.contains(w.target)}),I=P.length>0?a(w,P[0]):!i.current.noIsolation;I&&w.cancelable&&w.preventDefault()}}},[]),l=x.useCallback(function(g,w,S,v){var P={name:g,delta:w,target:S,should:v};t.current.push(P),setTimeout(function(){t.current=t.current.filter(function(I){return I!==P})},1)},[]),u=x.useCallback(function(g){n.current=Nd(g),r.current=void 0},[]),d=x.useCallback(function(g){l(g.type,JC(g),g.target,a(g,e.lockRef.current))},[]),p=x.useCallback(function(g){l(g.type,Nd(g),g.target,a(g,e.lockRef.current))},[]);x.useEffect(function(){return aa.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:p}),document.addEventListener("wheel",c,ia),document.addEventListener("touchmove",c,ia),document.addEventListener("touchstart",u,ia),function(){aa=aa.filter(function(g){return g!==s}),document.removeEventListener("wheel",c,ia),document.removeEventListener("touchmove",c,ia),document.removeEventListener("touchstart",u,ia)}},[]);var f=e.removeScrollBar,y=e.inert;return x.createElement(x.Fragment,null,y?x.createElement(s,{styles:dq(o)}):null,f?x.createElement(nq,{gapMode:"margin"}):null)}const fq=HX($M,pq);var ig=x.forwardRef(function(e,t){return x.createElement(sg,eo({},e,{ref:t,sideCar:fq}))});ig.classNames=sg.classNames;var gq=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ca=new WeakMap,zd=new WeakMap,Bd={},sy=0,DM=function(e){return e&&(e.host||DM(e.parentNode))},mq=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=DM(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},yq=function(e,t,n,r){var o=mq(t,Array.isArray(e)?e:[e]);Bd[n]||(Bd[n]=new WeakMap);var s=Bd[n],i=[],a=new Set,c=new Set(o),l=function(d){!d||a.has(d)||(a.add(d),l(d.parentNode))};o.forEach(l);var u=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(p){if(a.has(p))u(p);else try{var f=p.getAttribute(r),y=f!==null&&f!=="false",g=(ca.get(p)||0)+1,w=(s.get(p)||0)+1;ca.set(p,g),s.set(p,w),i.push(p),g===1&&y&&zd.set(p,!0),w===1&&p.setAttribute(n,"true"),y||p.setAttribute(r,"true")}catch(S){console.error("aria-hidden: cannot operate on ",p,S)}})};return u(t),a.clear(),sy++,function(){i.forEach(function(d){var p=ca.get(d)-1,f=s.get(d)-1;ca.set(d,p),s.set(d,f),p||(zd.has(d)||d.removeAttribute(r),zd.delete(d)),f||d.removeAttribute(n)}),sy--,sy||(ca=new WeakMap,ca=new WeakMap,zd=new WeakMap,Bd={})}},Xx=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=gq(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),yq(r,o,n,"aria-hidden")):function(){return null}};const RM="Dialog",[LM,Loe]=So(RM),[Sq,os]=LM(RM),vq=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=x.useRef(null),c=x.useRef(null),[l=!1,u]=Zs({prop:r,defaultProp:o,onChange:s});return x.createElement(Sq,{scope:t,triggerRef:a,contentRef:c,contentId:zo(),titleId:zo(),descriptionId:zo(),open:l,onOpenChange:u,onOpenToggle:x.useCallback(()=>u(d=>!d),[u]),modal:i},n)},FM="DialogPortal",[xq,NM]=LM(FM,{forceMount:void 0}),wq=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=os(FM,t);return x.createElement(xq,{scope:t,forceMount:n},x.Children.map(r,i=>x.createElement(vo,{present:n||s.open},x.createElement(ng,{asChild:!0,container:o},i))))},wv="DialogOverlay",bq=x.forwardRef((e,t)=>{const n=NM(wv,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=os(wv,e.__scopeDialog);return s.modal?x.createElement(vo,{present:r||s.open},x.createElement(Pq,Z({},o,{ref:t}))):null}),Pq=x.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=os(wv,n);return x.createElement(ig,{as:Ai,allowPinchZoom:!0,shards:[o.contentRef]},x.createElement(Ve.div,Z({"data-state":BM(o.open)},r,{ref:t,style:{pointerEvents:"auto",...r.style}})))}),iu="DialogContent",Cq=x.forwardRef((e,t)=>{const n=NM(iu,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=os(iu,e.__scopeDialog);return x.createElement(vo,{present:r||s.open},s.modal?x.createElement(Iq,Z({},o,{ref:t})):x.createElement(Eq,Z({},o,{ref:t})))}),Iq=x.forwardRef((e,t)=>{const n=os(iu,e.__scopeDialog),r=x.useRef(null),o=Ze(t,n.contentRef,r);return x.useEffect(()=>{const s=r.current;if(s)return Xx(s)},[]),x.createElement(zM,Z({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)===null||i===void 0||i.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault())}))}),Eq=x.forwardRef((e,t)=>{const n=os(iu,e.__scopeDialog),r=x.useRef(!1),o=x.useRef(!1);return x.createElement(zM,Z({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i;if((i=e.onCloseAutoFocus)===null||i===void 0||i.call(e,s),!s.defaultPrevented){var a;r.current||(a=n.triggerRef.current)===null||a===void 0||a.focus(),s.preventDefault()}r.current=!1,o.current=!1},onInteractOutside:s=>{var i,a;(i=e.onInteractOutside)===null||i===void 0||i.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=s.target;((a=n.triggerRef.current)===null||a===void 0?void 0:a.contains(c))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}}))}),zM=x.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=os(iu,n),c=x.useRef(null),l=Ze(t,c);return Yx(),x.createElement(x.Fragment,null,x.createElement(Vx,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s},x.createElement(tg,Z({role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":BM(a.open)},i,{ref:l,onDismiss:()=>a.onOpenChange(!1)}))),!1)}),_q="DialogTitle",kq=x.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=os(_q,n);return x.createElement(Ve.h2,Z({id:o.titleId},r,{ref:t}))});const Tq="DialogClose",$q=x.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=os(Tq,n);return x.createElement(Ve.button,Z({type:"button"},r,{ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))}))});function BM(e){return e?"open":"closed"}const Mq=vq,Aq=wq,jq=bq,Oq=Cq,UM=()=>{},HM=x.createContext({});function Dq({onEvent:e,children:t}){return h.jsx(HM.Provider,{value:e??UM,children:t})}function xo(){return x.useContext(HM)??UM}const KM=x.createContext({});function Rq({children:e}){const t=z(),n=xo(),[r,o]=x.useState([]),s=x.useCallback(l=>{const u=l.id??rt();return o(d=>[...d.filter(p=>p.id!==l.id),{...l,id:u}]),n("open-menu",{source:"dialog",id:u}),t.addOpenMenu(u),u},[t,n]),i=x.useCallback((l,u)=>(o(d=>d.map(p=>p.id===l?{...p,...u}:p)),n("open-menu",{source:"dialog",id:l}),t.addOpenMenu(l),l),[t,n]),a=x.useCallback(l=>(o(u=>u.filter(d=>{var p;return d.id===l?((p=d.onClose)==null||p.call(d),!1):!0})),n("close-menu",{source:"dialog",id:l}),t.deleteOpenMenu(l),l),[t,n]),c=x.useCallback(()=>{o(l=>(l.forEach(u=>{var d;(d=u.onClose)==null||d.call(u),n("close-menu",{source:"dialog",id:u.id}),t.deleteOpenMenu(u.id)}),[]))},[t,n]);return h.jsx(KM.Provider,{value:{dialogs:r,addDialog:s,removeDialog:a,clearDialogs:c,updateDialog:i},children:e})}function Gi(){const e=x.useContext(KM);if(!e)throw new Error("useDialogs must be used within a DialogsProvider");return e}const Lq=({id:e,component:t,onClose:n})=>{const{removeDialog:r}=Gi(),o=Xt(),s=x.useCallback(i=>{if(!i){if(n)try{n()}catch(a){console.warn(a)}r(e)}},[e,n,r]);return h.jsx(Mq,{onOpenChange:s,defaultOpen:!0,children:h.jsx(Aq,{container:o,children:h.jsx(jq,{dir:"ltr",className:"tlui-dialog__overlay",onClick:i=>{i.target===i.currentTarget&&s(!1)},children:h.jsx(Oq,{dir:"ltr",className:"tlui-dialog__content",children:h.jsx(t,{onClose:()=>s(!1)})})})})})};function Fq(){const{dialogs:e}=Gi();return h.jsx(h.Fragment,{children:e.map(t=>h.jsx(Lq,{...t},t.id))})}const Nq=Se.memo(Fq);function zq(){const e=z(),t=K("follow",()=>e.getInstanceState().followingUserId,[e]);return t?h.jsx(Bq,{userId:t}):null}function Bq({userId:e}){const t=S_(e);return t?h.jsx("div",{className:"tlui-following-indicator",style:{borderColor:t.color}}):null}const WM=x.createContext({});function Uq({children:e}){const[t,n]=x.useState([]),r=x.useCallback(i=>{const a=i.id??rt();return n(c=>[...c.filter(l=>l.id!==i.id),{...i,id:a}]),a},[]),o=x.useCallback(i=>(n(a=>a.filter(c=>c.id!==i)),i),[]),s=x.useCallback(()=>{n(()=>[])},[]);return h.jsx(WM.Provider,{value:{toasts:t,addToast:r,removeToast:o,clearToasts:s},children:e})}function Wr(){const e=x.useContext(WM);if(!e)throw new Error("useToasts must be used within a ToastsProvider");return e}const pe=x.forwardRef(function({children:t,disabled:n,type:r,...o},s){const i=z(),a=s==null?void 0:s.current;return n&&a===document.activeElement&&i.getContainer().focus(),h.jsx("button",{ref:s,type:"button",draggable:!1,disabled:n,...o,className:ue("tlui-button",`tlui-button__${r}`,o.className),children:t})});function bt({children:e}){return h.jsx("span",{className:"tlui-button__label",children:e})}const Us=x.memo(function({small:t,invertIcon:n,icon:r,color:o,className:s,...i}){const a=Hx(),c=a.icons[r]??a.icons["question-mark-circle"],l=x.useRef(null);return x.useLayoutEffect(()=>{c||console.error(`Icon not found: ${r}. Add it to the assetUrls.icons object.`),l!=null&&l.current&&(l.current.style.webkitMask=`url(${c}) center 100% / 100% no-repeat`)},[l,c,r]),r==="none"?h.jsx("div",{className:ue("tlui-icon tlui-icon__placeholder",{"tlui-icon__small":t},s)}):h.jsx("div",{...i,ref:l,className:ue("tlui-icon",{"tlui-icon__small":t},s),style:{color:o,mask:`url(${c}) center 100% / 100% no-repeat`,transform:n?"scale(-1, 1)":void 0}})}),Hq={success:"check-circle",warning:"warning-triangle",error:"cross-circle",info:"info-circle"};function Kq({toast:e}){const{removeToast:t}=Wr(),n=Me(),r=i=>{i||t(e.id)},o=e.actions&&e.actions.length>0,s=e.icon||e.severity&&Hq[e.severity];return h.jsxs(bX,{onOpenChange:r,className:"tlui-toast__container",duration:e.keepOpen?1/0:5e3,"data-severity":e.severity,children:[s&&h.jsx("div",{className:"tlui-toast__icon",children:h.jsx(Us,{icon:s})}),h.jsxs("div",{className:"tlui-toast__main",children:[h.jsxs("div",{className:"tlui-toast__content",children:[e.title&&h.jsx(PX,{className:"tlui-toast__title",children:e.title}),e.description&&h.jsx(CX,{className:"tlui-toast__description",children:e.description})]}),e.actions&&h.jsxs("div",{className:"tlui-toast__actions",children:[e.actions.map((i,a)=>h.jsx(IX,{altText:i.label,asChild:!0,onClick:i.onClick,children:h.jsx(pe,{type:i.type,children:h.jsx(bt,{children:i.label})})},a)),h.jsx(KC,{asChild:!0,children:h.jsx(pe,{type:"normal",className:"tlui-toast__close",style:{marginLeft:"auto"},children:h.jsx(bt,{children:e.closeLabel??n("toast.close")})})})]})]}),!o&&h.jsx(KC,{asChild:!0,children:h.jsx(pe,{type:"normal",className:"tlui-toast__close",children:h.jsx(bt,{children:e.closeLabel??n("toast.close")})})})]})}function Wq(){const{toasts:e}=Wr();return h.jsx(h.Fragment,{children:e.map(t=>h.jsx(Kq,{toast:t},t.id))})}const Gq=x.memo(Wq);function Vq(){const{toasts:e}=Wr(),[t,n]=x.useState(!1);return x.useEffect(()=>{let r=!1;return e.length?n(!0):setTimeout(()=>{r||n(!1)},1e3),()=>{r=!0}},[e.length,n]),t?h.jsx(sX,{className:"tlui-toast__viewport"}):null}function Ce({icon:e,small:t,invertIcon:n}){return h.jsx(Us,{className:"tlui-button__icon",icon:e,small:t,invertIcon:n})}const yi="2.2.0-canary.ebc892a1a6b8";let bv={fonts:{draw:`https://unpkg.com/@tldraw/assets@${yi}/fonts/Shantell_Sans-Tldrawish.woff2`,serif:`https://unpkg.com/@tldraw/assets@${yi}/fonts/IBMPlexSerif-Medium.woff2`,sansSerif:`https://unpkg.com/@tldraw/assets@${yi}/fonts/IBMPlexSans-Medium.woff2`,monospace:`https://unpkg.com/@tldraw/assets@${yi}/fonts/IBMPlexMono-Medium.woff2`}};function GM(e){return x.useMemo(()=>e?{fonts:{...bv.fonts,...e==null?void 0:e.fonts}}:bv,[e])}const Yq=["align-bottom","align-center-horizontal","align-center-vertical","align-left","align-right","align-top","arrow-left","arrowhead-arrow","arrowhead-bar","arrowhead-diamond","arrowhead-dot","arrowhead-none","arrowhead-square","arrowhead-triangle-inverted","arrowhead-triangle","blob","bring-forward","bring-to-front","broken","check-circle","check","chevron-down","chevron-left","chevron-right","chevron-up","chevrons-ne","chevrons-sw","clipboard-copied","clipboard-copy","color","cross-2","cross-circle","dash-dashed","dash-dotted","dash-draw","dash-solid","disconnected","discord","distribute-horizontal","distribute-vertical","dot","dots-horizontal","dots-vertical","drag-handle-dots","duplicate","edit","external-link","fill-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","horizontal-align-end","horizontal-align-middle","horizontal-align-start","info-circle","leading","link","lock","menu","minus","mixed","pack","plus","question-mark-circle","question-mark","redo","reset-zoom","rotate-ccw","rotate-cw","send-backward","send-to-back","share-1","size-extra-large","size-large","size-medium","size-small","stack-horizontal","stack-vertical","stretch-horizontal","stretch-vertical","text-align-center","text-align-left","text-align-right","toggle-off","toggle-on","tool-arrow","tool-eraser","tool-frame","tool-hand","tool-highlight","tool-laser","tool-line","tool-media","tool-note","tool-pencil","tool-pointer","tool-screenshot","tool-text","trash","twitter","undo","ungroup","unlock","vertical-align-end","vertical-align-middle","vertical-align-start","warning-triangle","zoom-in","zoom-out"];let Jc={...bv,icons:Object.fromEntries(Yq.map(e=>[e,`https://unpkg.com/@tldraw/assets@${yi}/icons/icon/${e}.svg`])),translations:Object.fromEntries(Dl.map(e=>[e.locale,`https://unpkg.com/@tldraw/assets@${yi}/translations/${e.locale}.json`])),embedIcons:Object.fromEntries(Su.map(e=>[e.type,`https://unpkg.com/@tldraw/assets@${yi}/embed-icons/${e.type}.png`]))};function Xq(e){return e?{fonts:Object.assign({...Jc.fonts},{...e==null?void 0:e.fonts}),icons:Object.assign({...Jc.icons},{...e==null?void 0:e.icons}),embedIcons:Object.assign({...Jc.embedIcons},{...e==null?void 0:e.embedIcons}),translations:Object.assign({...Jc.translations},{...e==null?void 0:e.translations})}:Jc}function ag({className:e,children:t}){return h.jsx("div",{className:ue("tlui-dialog__header",e),children:t})}function cg({className:e,children:t}){return h.jsx(kq,{dir:"ltr",className:ue("tlui-dialog__header__title",e),children:t})}function lg(){return h.jsx("div",{className:"tlui-dialog__header__close",children:h.jsx($q,{"data-testid":"dialog.close",dir:"ltr",asChild:!0,children:h.jsx(pe,{type:"icon","aria-label":"Close",onTouchEnd:e=>e.target.click(),children:h.jsx(Ce,{small:!0,icon:"cross-2"})})})})}function au({className:e,children:t,style:n}){return h.jsx("div",{className:ue("tlui-dialog__body",e),style:n,children:t})}function qx({className:e,children:t}){return h.jsx("div",{className:ue("tlui-dialog__footer",e),children:t})}const Zx=x.forwardRef(function({className:t,label:n,icon:r,iconLeft:o,autoselect:s=!1,autofocus:i=!1,defaultValue:a,placeholder:c,onComplete:l,onValueChange:u,onCancel:d,onFocus:p,onBlur:f,shouldManuallyMaintainScrollPositionWhenFocused:y=!1,children:g,value:w},S){const v=z(),P=x.useRef(null);x.useImperativeHandle(S,()=>P.current);const I=Me(),C=x.useRef(a??""),E=x.useRef(a??""),[_,k]=x.useState(!1),$=x.useCallback(L=>{k(!0);const R=L.currentTarget;E.current=R.value,requestAnimationFrame(()=>{s&&R.select()}),p==null||p()},[s,p]),T=x.useCallback(L=>{const R=L.currentTarget.value;E.current=R,u==null||u(R)},[u]),A=x.useCallback(L=>{switch(L.key){case"Enter":{L.currentTarget.blur(),Kt(L),l==null||l(L.currentTarget.value);break}case"Escape":{L.currentTarget.value=C.current,L.currentTarget.blur(),Kt(L),d==null||d(L.currentTarget.value);break}}},[l,d]),B=x.useCallback(L=>{k(!1);const R=L.currentTarget.value;f==null||f(R)},[f]);return x.useEffect(()=>{if(!v.environment.isIos)return;const L=window.visualViewport;if(_&&y&&L){const R=()=>{var N;(N=P.current)==null||N.scrollIntoView({block:"center"})};return L.addEventListener("resize",R),L.addEventListener("scroll",R),requestAnimationFrame(()=>{var N;(N=P.current)==null||N.scrollIntoView({block:"center"})}),()=>{L.removeEventListener("resize",R),L.removeEventListener("scroll",R)}}},[v,_,y]),h.jsxs("div",{draggable:!1,className:"tlui-input__wrapper",children:[g,n&&h.jsx("label",{children:I(n)}),o&&h.jsx(Us,{icon:o,className:"tlui-icon-left",small:!0}),h.jsx("input",{ref:P,className:ue("tlui-input",t),type:"text",defaultValue:a,onKeyUp:A,onChange:T,onFocus:$,onBlur:B,autoFocus:i,placeholder:c,value:w}),r&&h.jsx(Us,{icon:r,small:!!n})]})}),VM=rr(function({onClose:t}){const n=z(),r=Me(),o=Hx(),[s,i]=x.useState(null),[a,c]=x.useState(""),[l,u]=x.useState(null),[d,p]=x.useState(!1),f=x.useRef(-1);return h.jsxs(h.Fragment,{children:[h.jsxs(ag,{children:[h.jsx(cg,{children:s?`${r("embed-dialog.title")} — ${s.title}`:r("embed-dialog.title")}),h.jsx(lg,{})]}),s?h.jsxs(h.Fragment,{children:[h.jsxs(au,{className:"tlui-embed-dialog__enter",children:[h.jsx(Zx,{className:"tlui-embed-dialog__input",label:"embed-dialog.url",placeholder:"http://example.com",autofocus:!0,onValueChange:y=>{c(y);const g=Es(y);u(g&&g.definition.type===s.type?g:null),p(!1),clearTimeout(f.current),f.current=setTimeout(()=>p(!g),320)}}),a===""?h.jsxs("div",{className:"tlui-embed-dialog__instruction",children:[h.jsx("span",{children:r("embed-dialog.instruction")})," ",s.instructionLink&&h.jsxs("a",{target:"_blank",rel:"noopener noreferrer",href:s.instructionLink,className:"tlui-embed-dialog__instruction__link",children:["Learn more.",h.jsx(Us,{icon:"external-link",small:!0})]})]}):h.jsx("div",{className:"tlui-embed-dialog__warning",children:d?r("embed-dialog.invalid-url"):" "})]}),h.jsxs(qx,{className:"tlui-dialog__footer__actions",children:[h.jsx(pe,{type:"normal",onClick:()=>{i(null),u(null),c("")},children:h.jsx(bt,{children:r("embed-dialog.back")})}),h.jsx("div",{className:"tlui-embed__spacer"}),h.jsx(pe,{type:"normal",onClick:t,children:h.jsx(bt,{children:r("embed-dialog.cancel")})}),h.jsx(pe,{type:"primary",disabled:!l,onClick:()=>{l&&(n.putExternalContent({type:"embed",url:a,point:n.getViewportPageBounds().center,embed:l.definition}),t())},children:h.jsx(bt,{children:r("embed-dialog.create")})})]})]}):h.jsx(h.Fragment,{children:h.jsx(au,{className:"tlui-embed-dialog__list",children:Su.map(y=>h.jsxs(pe,{type:"menu",onClick:()=>i(y),children:[h.jsx(bt,{children:y.title}),h.jsx("div",{className:"tlui-embed-dialog__item__image",style:{backgroundImage:`url(${o.embedIcons[y.type]})`}})]},y.type))})})]})});function YM(){const e=z(),t=x.useRef();return x.useEffect(()=>{const n=window.document.createElement("input");n.type="file",n.accept="image/jpeg,image/png,image/gif,image/svg+xml,video/mp4,video/quicktime",n.multiple=!0,t.current=n;async function r(o){const s=o.target.files;!s||s.length===0||(await e.putExternalContent({type:"files",files:Array.from(s),point:e.getViewportPageBounds().center,ignoreParent:!1}),n.value="")}return n.addEventListener("change",r),()=>{t.current=void 0,n.removeEventListener("change",r)}},[e]),x.useCallback(()=>{var n;(n=t.current)==null||n.click()},[t])}const XM=x.createContext({});function qq({overrides:e,children:t}){const n=z(),r=xo(),{addDialog:o}=Gi(),s=YM(),i=x.useMemo(()=>{const a=[{id:"select",label:"tool.select",icon:"tool-pointer",kbd:"v",readonlyOk:!0,onSelect(l){n.setCurrentTool("select"),r("select-tool",{source:l,id:"select"})}},{id:"hand",label:"tool.hand",icon:"tool-hand",kbd:"h",readonlyOk:!0,onSelect(l){n.setCurrentTool("hand"),r("select-tool",{source:l,id:"hand"})}},{id:"eraser",label:"tool.eraser",icon:"tool-eraser",kbd:"e",onSelect(l){n.setCurrentTool("eraser"),r("select-tool",{source:l,id:"eraser"})}},{id:"draw",label:"tool.draw",icon:"tool-pencil",kbd:"d,b,x",onSelect(l){n.setCurrentTool("draw"),r("select-tool",{source:l,id:"draw"})}},...[...ro.values].map(l=>({id:l,label:`tool.${l}`,meta:{geo:l},kbd:l==="rectangle"?"r":l==="ellipse"?"o":void 0,icon:"geo-"+l,onSelect(u){n.batch(()=>{n.setStyleForNextShapes(ro,l),n.setCurrentTool("geo"),r("select-tool",{source:u,id:`geo-${l}`})})}})),{id:"arrow",label:"tool.arrow",icon:"tool-arrow",kbd:"a",onSelect(l){n.setCurrentTool("arrow"),r("select-tool",{source:l,id:"arrow"})}},{id:"line",label:"tool.line",icon:"tool-line",kbd:"l",onSelect(l){n.setCurrentTool("line"),r("select-tool",{source:l,id:"line"})}},{id:"frame",label:"tool.frame",icon:"tool-frame",kbd:"f",onSelect(l){n.setCurrentTool("frame"),r("select-tool",{source:l,id:"frame"})}},{id:"text",label:"tool.text",icon:"tool-text",kbd:"t",onSelect(l){n.setCurrentTool("text"),r("select-tool",{source:l,id:"text"})}},{id:"asset",label:"tool.asset",icon:"tool-media",kbd:"$u",onSelect(l){s(),r("select-tool",{source:l,id:"media"})}},{id:"note",label:"tool.note",icon:"tool-note",kbd:"n",onSelect(l){n.setCurrentTool("note"),r("select-tool",{source:l,id:"note"})}},{id:"laser",label:"tool.laser",readonlyOk:!0,icon:"tool-laser",kbd:"k",onSelect(l){n.setCurrentTool("laser"),r("select-tool",{source:l,id:"laser"})}},{id:"embed",label:"tool.embed",icon:"dot",onSelect(l){o({component:VM}),r("select-tool",{source:l,id:"embed"})}},{id:"highlight",label:"tool.highlight",icon:"tool-highlight",kbd:"!d",onSelect(l){n.setCurrentTool("highlight"),r("select-tool",{source:l,id:"highlight"})}}];a.push();const c=Object.fromEntries(a.map(l=>[l.id,l]));return e?e(n,c,{insertMedia:s}):c},[e,n,r,s,o]);return h.jsx(XM.Provider,{value:i,children:t})}function Le(){const e=x.useContext(XM);if(!e)throw new Error("useTools must be used within a ToolProvider");return e}const qM=Se.createContext(0);function Zq({forceMobile:e=!1,children:t}){const n=z(),r=K("breakpoint",()=>{const{width:o}=n.getViewportScreenBounds(),s=e?vt.MOBILE_SM:qm.length-1;for(let i=0;i<s;i++)if(o>qm[i]&&o<=qm[i+1])return i;return s},[n]);return h.jsx(qM.Provider,{value:r,children:t})}function Rn(){return x.useContext(qM)}function Qq(){const{addToast:e,removeToast:t,clearToasts:n}=Wr(),{addDialog:r,clearDialogs:o,removeDialog:s,updateDialog:i}=Gi(),c=Rn()<vt.TABLET_SM,l=Me();return x.useMemo(()=>({addToast:e,removeToast:t,clearToasts:n,addDialog:r,clearDialogs:o,removeDialog:s,updateDialog:i,msg:l,isMobile:c}),[r,e,o,n,l,s,t,i,c])}function Jq(e,t){const n={};for(const r of e)if(r.translations)for(const[o,s]of gn(r.translations)){let i=n[o];i||(i=n[o]={}),Object.assign(i,s)}return{actions:(r,o)=>{for(const s of e)s.actions&&(o=s.actions(r,o,t));return o},tools:(r,o,s)=>{for(const i of e)i.tools&&(o=i.tools(r,o,{...t,...s}));return o},translations:n}}function ZM(e){return x.useMemo(()=>e,e)}function eZ(e){const t=ZM(e==null?[]:Array.isArray(e)?e:[e]);return x.useMemo(()=>{const n={};for(const r of t)if(r.translations)for(const[o,s]of gn(r.translations)){let i=n[o];i||(i=n[o]={}),Object.assign(i,s)}return n},[t])}function tZ(e){const t=Qq(),n=ZM(e==null?[]:Array.isArray(e)?e:[e]);return x.useMemo(()=>Jq(n,t),[n,t])}function nZ(e,t){const n=fe(t.map(o=>e.getShape(o)).filter(o=>o&&e.isShapeOfType(o,"frame")));if(!n.length)return;const r=[];e.batch(()=>{n.map(o=>{const s=e.getSortedChildIdsForParent(o.id);s.length&&(e.reparentShapes(s,o.parentId,o.index),r.push(...s))}),e.setSelectedShapes(r),e.deleteShapes(t)})}const rZ=50;function oZ(e,t,n={}){const r=e.getShape(t);if(!r)return;const o=e.getSortedChildIdsForParent(r.id),s=fe(o.map(f=>e.getShape(f)));if(!s.length)return;const i=te.FromPoints(s.flatMap(f=>{const y=e.getShapeGeometry(f.id);return e.getShapeLocalTransform(f).applyToPoints(y.vertices)})),{padding:a=rZ}=n,c=i.w+2*a,l=i.h+2*a,u=a-i.minX,d=a-i.minY;if(u===0&&d===0&&r.props.w===c&&r.props.h===l)return;const p=new 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-p.x,y:r.y-p.y,props:{w:c,h:l}}),e.updateShapes(f)})}function tI(e){return er.isValid(e)?{isValid:!0,hasProtocol:!0}:er.isValid("https://"+e)?{isValid:!0,hasProtocol:!1}:{isValid:!1,hasProtocol:!1}}const sZ=rr(function({onClose:t}){const r=z().getOnlySelectedShape();return r&&"url"in r.props&&typeof r.props.url=="string"?h.jsx(iZ,{onClose:t,selectedShape:r}):null}),iZ=rr(function({onClose:t,selectedShape:n}){const r=z(),o=Me(),s=x.useRef(null);x.useEffect(()=>{requestAnimationFrame(()=>{var y;return(y=s.current)==null?void 0:y.focus()})},[]);const i=x.useRef(n.props.url),[a,c]=x.useState(()=>{const y=tI(n.props.url),g=y.isValid===!0?y.hasProtocol?n.props.url:"https://"+n.props.url:"https://";return{actual:g,safe:g,valid:!0}}),l=x.useCallback(y=>{const g=y.replace(/https?:\/\/(https?:\/\/)/,(v,P)=>P),w=tI(g),S=w.isValid===!0?w.hasProtocol?g:"https://"+g:"https://";c({actual:g,safe:S,valid:w.isValid})},[]),u=x.useCallback(()=>{const y=r.getOnlySelectedShape();y&&(r.updateShapes([{id:y.id,type:y.type,props:{url:""}}]),t())},[r,t]),d=x.useCallback(()=>{const y=r.getOnlySelectedShape();y&&(y&&"url"in y.props&&y.props.url!==a.safe&&r.updateShapes([{id:y.id,type:y.type,props:{url:a.safe}}]),t())},[r,t,a]),p=x.useCallback(()=>{t()},[t]);if(!n)return t(),null;const f=i.current&&!a.valid;return h.jsxs(h.Fragment,{children:[h.jsxs(ag,{children:[h.jsx(cg,{children:o("edit-link-dialog.title")}),h.jsx(lg,{})]}),h.jsx(au,{children:h.jsxs("div",{className:"tlui-edit-link-dialog",children:[h.jsx(Zx,{ref:s,className:"tlui-edit-link-dialog__input",label:"edit-link-dialog.url",autofocus:!0,value:a.actual,onValueChange:l,onComplete:d,onCancel:p}),h.jsx("div",{children:a.valid?o("edit-link-dialog.detail"):o("edit-link-dialog.invalid-url")})]})}),h.jsxs(qx,{className:"tlui-dialog__footer__actions",children:[h.jsx(pe,{type:"normal",onClick:p,onTouchEnd:p,children:h.jsx(bt,{children:o("edit-link-dialog.cancel")})}),f?h.jsx(pe,{type:"danger",onTouchEnd:u,onClick:u,children:h.jsx(bt,{children:o("edit-link-dialog.clear")})}):h.jsx(pe,{type:"primary",disabled:!a.valid,onTouchEnd:d,onClick:d,children:h.jsx(bt,{children:o("edit-link-dialog.save")})})]})]})});var Qx={exports:{}};Qx.exports;(function(e){var t=function(){var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function i(c,l){if(!s[c]){s[c]={};for(var u=0;u<c.length;u++)s[c][c.charAt(u)]=u}return s[c][l]}var a={compressToBase64:function(c){if(c==null)return"";var l=a._compress(c,6,function(u){return r.charAt(u)});switch(l.length%4){default:case 0:return l;case 1:return l+"===";case 2:return l+"==";case 3:return l+"="}},decompressFromBase64:function(c){return c==null?"":c==""?null:a._decompress(c.length,32,function(l){return i(r,c.charAt(l))})},compressToUTF16:function(c){return c==null?"":a._compress(c,15,function(l){return n(l+32)})+" "},decompressFromUTF16:function(c){return c==null?"":c==""?null:a._decompress(c.length,16384,function(l){return c.charCodeAt(l)-32})},compressToUint8Array:function(c){for(var l=a.compress(c),u=new Uint8Array(l.length*2),d=0,p=l.length;d<p;d++){var f=l.charCodeAt(d);u[d*2]=f>>>8,u[d*2+1]=f%256}return u},decompressFromUint8Array:function(c){if(c==null)return a.decompress(c);for(var l=new Array(c.length/2),u=0,d=l.length;u<d;u++)l[u]=c[u*2]*256+c[u*2+1];var p=[];return l.forEach(function(f){p.push(n(f))}),a.decompress(p.join(""))},compressToEncodedURIComponent:function(c){return c==null?"":a._compress(c,6,function(l){return o.charAt(l)})},decompressFromEncodedURIComponent:function(c){return c==null?"":c==""?null:(c=c.replace(/ /g,"+"),a._decompress(c.length,32,function(l){return i(o,c.charAt(l))}))},compress:function(c){return a._compress(c,16,function(l){return n(l)})},_compress:function(c,l,u){if(c==null)return"";var d,p,f={},y={},g="",w="",S="",v=2,P=3,I=2,C=[],E=0,_=0,k;for(k=0;k<c.length;k+=1)if(g=c.charAt(k),Object.prototype.hasOwnProperty.call(f,g)||(f[g]=P++,y[g]=!0),w=S+g,Object.prototype.hasOwnProperty.call(f,w))S=w;else{if(Object.prototype.hasOwnProperty.call(y,S)){if(S.charCodeAt(0)<256){for(d=0;d<I;d++)E=E<<1,_==l-1?(_=0,C.push(u(E)),E=0):_++;for(p=S.charCodeAt(0),d=0;d<8;d++)E=E<<1|p&1,_==l-1?(_=0,C.push(u(E)),E=0):_++,p=p>>1}else{for(p=1,d=0;d<I;d++)E=E<<1|p,_==l-1?(_=0,C.push(u(E)),E=0):_++,p=0;for(p=S.charCodeAt(0),d=0;d<16;d++)E=E<<1|p&1,_==l-1?(_=0,C.push(u(E)),E=0):_++,p=p>>1}v--,v==0&&(v=Math.pow(2,I),I++),delete y[S]}else for(p=f[S],d=0;d<I;d++)E=E<<1|p&1,_==l-1?(_=0,C.push(u(E)),E=0):_++,p=p>>1;v--,v==0&&(v=Math.pow(2,I),I++),f[w]=P++,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,_==l-1?(_=0,C.push(u(E)),E=0):_++;for(p=S.charCodeAt(0),d=0;d<8;d++)E=E<<1|p&1,_==l-1?(_=0,C.push(u(E)),E=0):_++,p=p>>1}else{for(p=1,d=0;d<I;d++)E=E<<1|p,_==l-1?(_=0,C.push(u(E)),E=0):_++,p=0;for(p=S.charCodeAt(0),d=0;d<16;d++)E=E<<1|p&1,_==l-1?(_=0,C.push(u(E)),E=0):_++,p=p>>1}v--,v==0&&(v=Math.pow(2,I),I++),delete y[S]}else for(p=f[S],d=0;d<I;d++)E=E<<1|p&1,_==l-1?(_=0,C.push(u(E)),E=0):_++,p=p>>1;v--,v==0&&(v=Math.pow(2,I),I++)}for(p=2,d=0;d<I;d++)E=E<<1|p&1,_==l-1?(_=0,C.push(u(E)),E=0):_++,p=p>>1;for(;;)if(E=E<<1,_==l-1){C.push(u(E));break}else _++;return C.join("")},decompress:function(c){return c==null?"":c==""?null:a._decompress(c.length,32768,function(l){return c.charCodeAt(l)})},_decompress:function(c,l,u){var d=[],p=4,f=4,y=3,g="",w=[],S,v,P,I,C,E,_,k={val:u(0),position:l,index:1};for(S=0;S<3;S+=1)d[S]=S;for(P=0,C=Math.pow(2,2),E=1;E!=C;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),P|=(I>0?1:0)*E,E<<=1;switch(P){case 0:for(P=0,C=Math.pow(2,8),E=1;E!=C;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),P|=(I>0?1:0)*E,E<<=1;_=n(P);break;case 1:for(P=0,C=Math.pow(2,16),E=1;E!=C;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),P|=(I>0?1:0)*E,E<<=1;_=n(P);break;case 2:return""}for(d[3]=_,v=_,w.push(_);;){if(k.index>c)return"";for(P=0,C=Math.pow(2,y),E=1;E!=C;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),P|=(I>0?1:0)*E,E<<=1;switch(_=P){case 0:for(P=0,C=Math.pow(2,8),E=1;E!=C;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),P|=(I>0?1:0)*E,E<<=1;d[f++]=n(P),_=f-1,p--;break;case 1:for(P=0,C=Math.pow(2,16),E=1;E!=C;)I=k.val&k.position,k.position>>=1,k.position==0&&(k.position=l,k.val=u(k.index++)),P|=(I>0?1:0)*E,E<<=1;d[f++]=n(P),_=f-1,p--;break;case 2:return w.join("")}if(p==0&&(p=Math.pow(2,y),y++),d[_])g=d[_];else if(_===f)g=v+v.charAt(0);else return null;w.push(g),d[f++]=v+g.charAt(0),p--,v=g,p==0&&(p=Math.pow(2,y),y++)}}};return a}();e!=null?e.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})})(Qx);var QM=Qx.exports;async function aZ(e,t,n){var S,v,P;const{elements:r,files:o}=t,s={shapes:[],rootShapeIds:[],assets:[],schema:e.store.schema.serialize()},i=new Map,a=new Map,c=e.getCurrentPageId(),l=new Map,u=[],d=new Set;r.forEach(I=>{if(l.set(I.id,He()),I.boundElements!==null)for(const C of I.boundElements)C.type==="text"&&d.add(C.id)});let p=KD;for(const I of r){if(d.has(I.id))continue;const C=l.get(I.id),E={id:C,typeName:"shape",parentId:c,index:p,x:I.x,y:I.y,rotation:0,isLocked:I.locked,opacity:cZ(I.opacity),meta:{}};switch(I.angle!==0&&a.set(C,I.angle),I.groupIds&&I.groupIds.length>0?i.has(I.groupIds[0])?(S=i.get(I.groupIds[0]))==null||S.push(C):i.set(I.groupIds[0],[C]):u.push(C),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 A=r.find(B=>B.id===T.id);A&&(_=A.text,k=fZ[A.textAlign])}}const $=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:Ud[I.strokeWidth]??"draw",color:el[$]??"black",text:_,align:k,dash:Hd(I),fill:yZ(I)}});break}case"freedraw":{s.shapes.push({...E,type:"draw",props:{dash:Hd(I),size:Ud[I.strokeWidth],color:el[I.strokeColor]??"black",segments:[{type:"free",points:I.points.map(([_,k,$=.5])=>({x:_,y:k,z:$}))}]}});break}case"line":{const _=I.points[0],k=I.points[I.points.length-1],$=Al(I.points.length);s.shapes.push({...E,type:"line",props:{dash:Hd(I),size:Ud[I.strokeWidth],color:el[I.strokeColor]??"black",spline:I.roundness?"cubic":"line",handles:{start:{id:"start",type:"vertex",index:$[0],x:_[0],y:_[1]},end:{id:"end",type:"vertex",index:$[$.length-1],x:k[0],y:k[1]},...Object.fromEntries(I.points.slice(1,-1).map(([T,A],B)=>{const L=rt();return[L,{id:L,type:"vertex",index:$[B+1],x:T,y:A}]}))}}});break}case"arrow":{let _="";if(I.boundElements!==null){for(const B of I.boundElements)if(B.type==="text"){const L=r.find(R=>R.id===B.id);L&&(_=L.text)}}const k=I.points[0],$=I.points[I.points.length-1],T=l.get((v=I.startBinding)==null?void 0:v.elementId),A=l.get((P=I.endBinding)==null?void 0:P.elementId);s.shapes.push({...E,type:"arrow",props:{text:_,bend:mZ(I,k,$),dash:Hd(I),size:Ud[I.strokeWidth]??"m",color:el[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:A?{type:"binding",boundShapeId:A,normalizedAnchor:{x:.5,y:.5},isPrecise:!1,isExact:!1}:{type:"point",x:$[0],y:$[1]},arrowheadEnd:nI[I.endArrowhead]??"none",arrowheadStart:nI[I.startArrowhead]??"none"}});break}case"text":{const{size:_,scale:k}=uZ(I.fontSize);s.shapes.push({...E,type:"text",props:{size:_,scale:k,font:dZ[I.fontFamily]??"draw",color:el[I.strokeColor]??"black",text:I.text,textAlign:gZ[I.textAlign]}});break}case"image":{const _=o[I.fileId];if(!_)break;const k=pi.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}})}}p=$o(p)}const f=n??(e.inputs.shiftKey?e.inputs.currentPagePoint:void 0);e.mark("paste"),e.putContentOntoCurrentPage(s,{point:f,select:!1,preserveIds:!0});for(const I of i.values())if(I.length>1){e.groupShapes(I);const C=e.getShape(I[0]);C!=null&&C.parentId&&Hn(C.parentId)&&u.push(C.parentId)}for(const[I,C]of a)e.select(I),e.rotateShapesBy([I],C);const y=fe(u.map(I=>e.getShape(I))),g=te.Common(y.map(I=>e.getShapePageBounds(I))),w=e.getViewportPageBounds().center;e.updateShapes(y.map(I=>{const C={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:w.x+C.x,y:w.y+C.y}})),e.setSelectedShapes(u)}const cZ=e=>{const t=e/100;return t<.2?.1:t<.4?.25:t<.6?.5:t<.8?.75:1},Ud={1:"s",2:"m",3:"l",4:"xl"},lZ={16:"s",20:"m",28:"l",36:"xl"};function uZ(e){const t=lZ[e];return t?{size:t,scale:1}:e<16?{size:"s",scale:e/16}:e>36?{size:"xl",scale:e/36}:{size:"m",scale:1}}const dZ={1:"draw",2:"sans",3:"mono"},el={"#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"},hZ={solid:"draw",dashed:"dashed",dotted:"dotted"},pZ={"cross-hatch":"pattern",hachure:"pattern",solid:"solid"},fZ={left:"start",center:"middle",right:"end"},gZ={left:"start",center:"middle",right:"end"},nI={arrow:"arrow",dot:"dot",triangle:"triangle",bar:"pipe"};function mZ(e,t,n){let r=0;if(e.points.length>2){const o=new b(t[0],t[1]),s=new b(n[0],n[1]),i=new b(e.points[1][0],e.points[1][1]),a=b.Sub(s,o),c=b.Per(a),l=b.Med(s,o),u=b.Sub(l,c),d=b.Add(l,c),p=b.NearestPointOnLineSegment(u,d,i,!1);r=b.Dist(p,l),b.Clockwise(p,s,l)&&(r*=-1)}return r}const Hd=e=>{let t=hZ[e.strokeStyle]??"draw";return t==="draw"&&e.roughness===0&&(t="solid"),t},yZ=e=>e.backgroundColor==="transparent"?"none":pZ[e.fillStyle]??"solid";async function JM(e,t,n,r){const s=(await Promise.all(t.map(async i=>await(await fetch(i)).blob()))).map(i=>new File([i],"tldrawFile",{type:i.type}));e.mark("paste"),await e.putExternalContent({type:"files",files:s,point:n,ignoreParent:!1,sources:r}),t.forEach(i=>URL.revokeObjectURL(i))}function SZ(e,t,n){const r=n??(e.inputs.shiftKey?e.inputs.currentPagePoint:void 0),o=e.getSelectionPageBounds();e.mark("paste"),e.putContentOntoCurrentPage(t,{point:r,select:!0});const s=e.getSelectionPageBounds();o&&s&&(o!=null&&o.collides(s))&&(e.updateInstanceState({isChangingStyle:!0}),setTimeout(()=>{e.updateInstanceState({isChangingStyle:!1})},150))}async function Pv(e,t,n,r){var o;try{if(new URL(t).pathname.match(/\.(png|jpe?g|gif|svg|webp)$/i)&&(o=(await fetch(t,{method:"HEAD"})).headers.get("content-type"))!=null&&o.match(/^image\//)){e.mark("paste"),JM(e,[t]);return}}catch(s){s.message!=="Failed to fetch"&&console.error(s)}return e.mark("paste"),await e.putExternalContent({type:"url",point:n,url:t,sources:r})}function vZ(e){const t=document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=e.trim(),t.body.textContent||t.body.innerText||""}const xZ=e=>{try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},wZ=e=>{const t=e.split(/[\n\s]/);for(const n of t)try{const r=new URL(n);if(!(r.protocol==="http:"||r.protocol==="https:"))return}catch{return}return y_(t)},bZ=e=>/^<svg/.test(e),PZ=["input","select","textarea"];function iy(e){const{activeElement:t}=document;return e.getIsMenuOpen()||t&&(t.getAttribute("contenteditable")||PZ.indexOf(t.tagName.toLowerCase())>-1)}const CZ=e=>e.types.find(t=>t.match(/^image\//)),ay=(e,t,n,r)=>{const o=wZ(t);if(o)for(const s of o)Pv(e,s,n);else xZ(t)?Pv(e,t,n):bZ(t)?(e.mark("paste"),e.putExternalContent({type:"svg-text",text:t,point:n,sources:r})):(e.mark("paste"),e.putExternalContent({type:"text",text:t,point:n,sources:r}))},IZ=async(e,t,n)=>{if(e.getEditingShapeId()!==null)return;if(!t)throw Error("No clipboard data");const r=[];for(const o of Object.values(t.items))switch(o.kind){case"file":{r.push({type:"file",source:new Promise(s=>s(o.getAsFile()))});break}case"string":{o.type==="text/html"?r.push({type:"html",source:new Promise(s=>o.getAsString(s))}):o.type==="text/plain"?r.push({type:"text",source:new Promise(s=>o.getAsString(s))}):r.push({type:o.type,source:new Promise(s=>o.getAsString(s))});break}}tA(e,r,n)},eA=async(e,t,n)=>{const r=[];for(const o of t){if(CZ(o))for(const s of o.types)s.match(/^image\//)&&r.push({type:"blob",source:o.getType(s)});o.types.includes("text/html")&&r.push({type:"html",source:(async()=>{const s=await o.getType("text/html");return await Oa.blobToText(s)})()}),o.types.includes("text/uri-list")&&r.push({type:"url",source:(async()=>{const s=await o.getType("text/uri-list");return await Oa.blobToText(s)})()}),o.types.includes("text/plain")&&r.push({type:"text",source:(async()=>{const s=await o.getType("text/plain");return await Oa.blobToText(s)})()})}return await tA(e,r,n)};async function tA(e,t,n){const r=t.filter(s=>(s.type==="file"||s.type==="blob")&&s.source!==null);if(r.length){const i=(await Promise.all(r.map(a=>a.source))).filter(Boolean).map(a=>URL.createObjectURL(a));return await JM(e,i,n)}const o=await Promise.all(t.filter(s=>s.type!=="file").map(s=>new Promise(i=>{const a=s;if(a.type==="file"){i({type:"error",data:null,reason:"unexpected file"});return}a.source.then(c=>{var u;const l=(u=c.match(/<tldraw[^>]*>(.*)<\/tldraw>/))==null?void 0:u[1];if(l)try{const d=QM.decompressFromBase64(l);if(d===null){i({type:"error",data:d,reason:"found tldraw data comment but could not parse base64"});return}else{const p=JSON.parse(d);if(p.type!=="application/tldraw"&&i({type:"error",data:p,reason:`found tldraw data comment but JSON was of a different type: ${p.type}`}),typeof p.data=="string"){i({type:"error",data:p,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}i({type:"tldraw",data:p.data});return}}catch{i({type:"error",data:l,reason:"found tldraw json but data was a string instead of a TLClipboardModel object"});return}else{if(a.type==="html"){i({type:"text",data:c,subtype:"html"});return}if(a.type==="url"){i({type:"text",data:c,subtype:"url"});return}try{const d=JSON.parse(c);if(d.type==="excalidraw/clipboard"){i({type:"excalidraw",data:d});return}else{i({type:"text",data:c,subtype:"json"});return}}catch{i({type:"text",data:c,subtype:"text"});return}}i({type:"error",data:c,reason:"unhandled case"})})})));for(const s of o)if(s.type==="tldraw"){SZ(e,s.data,n);return}for(const s of o)if(s.type==="excalidraw"){aZ(e,s.data,n);return}for(const s of o)if(s.type==="text"&&s.subtype==="html"){const a=new DOMParser().parseFromString(s.data,"text/html").querySelector("body");if(a&&Array.from(a.children).filter(l=>l.nodeType===1).length===1&&a.firstElementChild&&a.firstElementChild.tagName==="A"&&a.firstElementChild.hasAttribute("href")&&a.firstElementChild.getAttribute("href")!==""){const l=a.firstElementChild.getAttribute("href");ay(e,l,n,o);return}if(!o.some(l=>l.type==="text"&&l.subtype!=="html")&&s.data.trim()){ay(e,vZ(s.data),n,o);return}}for(const s of o)if(s.type==="text"&&s.subtype==="url"){Pv(e,s.data,n,o);return}for(const s of o)if(s.type==="text"&&s.subtype==="text"&&s.data.trim()){ay(e,s.data,n,o);return}}const rf=e=>{var r;const t=e.getContentFromCurrentPage(e.getSelectedShapeIds());if(!t){navigator&&navigator.clipboard&&navigator.clipboard.writeText("");return}const n=QM.compressToBase64(JSON.stringify({type:"application/tldraw",kind:"content",data:t}));if(!(typeof navigator>"u")){const o=t.shapes.map(s=>e.isShapeOfType(s,"text")||e.isShapeOfType(s,"geo")||e.isShapeOfType(s,"arrow")?s.props.text:e.isShapeOfType(s,"bookmark")||e.isShapeOfType(s,"embed")?s.props.url:null).filter(JD);if((r=navigator.clipboard)!=null&&r.write){const s=new Blob([`<tldraw>${n}</tldraw>`],{type:"text/html"});let i=o.join(" ");i===""&&(i=" "),navigator.clipboard.write([new ClipboardItem({"text/html":s,"text/plain":new Blob([i],{type:"text/plain"})})])}else navigator.clipboard.writeText&&navigator.clipboard.writeText(`<tldraw>${n}</tldraw>`)}};function EZ(){const e=z(),t=xo(),n=x.useCallback(function(i){e.getSelectedShapeIds().length!==0&&(rf(e),t("copy",{source:i}))},[e,t]),r=x.useCallback(function(i){e.getSelectedShapeIds().length!==0&&(rf(e),e.deleteShapes(e.getSelectedShapeIds()),t("cut",{source:i}))},[e,t]),o=x.useCallback(async function(i,a,c){e.getEditingShapeId()===null&&(Array.isArray(i)&&i[0]instanceof ClipboardItem?(eA(e,i,c),t("paste",{source:"menu"})):navigator.clipboard.read().then(l=>{o(l,a,c)}))},[e,t]);return{copy:n,cut:r,paste:o}}function _Z(){const e=z(),t=xo(),n=K("editor.isFocused",()=>e.getInstanceState().isFocused,[e]);x.useEffect(()=>{if(!n)return;const r=c=>{e.getSelectedShapeIds().length===0||e.getEditingShapeId()!==null||iy(e)||(ke(c),rf(e),t("copy",{source:"kbd"}))};function o(c){e.getSelectedShapeIds().length===0||e.getEditingShapeId()!==null||iy(e)||(ke(c),rf(e),e.deleteShapes(e.getSelectedShapeIds()),t("cut",{source:"kbd"}))}let s=!1;const i=c=>{c.button===1&&(s=!0,requestAnimationFrame(()=>{s=!1}))},a=c=>{if(s){Kt(c);return}e.getEditingShapeId()!==null||iy(e)||(c.clipboardData&&!e.inputs.shiftKey?IZ(e,c.clipboardData):navigator.clipboard.read().then(l=>{Array.isArray(l)&&l[0]instanceof ClipboardItem&&eA(e,l,e.inputs.currentPagePoint)}),ke(c),t("paste",{source:"kbd"}))};return document.addEventListener("copy",r),document.addEventListener("cut",o),document.addEventListener("paste",a),document.addEventListener("pointerup",i),()=>{document.removeEventListener("copy",r),document.removeEventListener("cut",o),document.removeEventListener("paste",a),document.removeEventListener("pointerup",i)}},[e,t,n])}async function nA(e,t,n){const{type:r,quality:o,scale:s,width:i,height:a}=n;let[c,l]=await a$(i*s,a*s);c=Math.floor(c),l=Math.floor(l);const u=c/i,d=URL.createObjectURL(new Blob([e],{type:"image/svg+xml"})),p=await new Promise(y=>{const g=new Image;g.crossOrigin="anonymous",g.onload=async()=>{t&&await new Promise(v=>setTimeout(v,250));const w=document.createElement("canvas"),S=w.getContext("2d");w.width=c,w.height=l,S.imageSmoothingEnabled=!0,S.imageSmoothingQuality="high",S.drawImage(g,0,0,c,l),URL.revokeObjectURL(d),y(w)},g.onerror=()=>{y(null)},g.src=d});if(!p)return null;const f=await new Promise(y=>p.toBlob(g=>{(!g||jt.throwToBlob.get())&&y(null),y(g)},"image/"+r,o));if(!f)return null;if(r==="png"){const y=new DataView(await f.arrayBuffer());return Zr.setPhysChunk(y,u,{type:"image/"+r})}else return f}async function rA(e,t,n){const r=await e.getSvgString(t!=null&&t.length?t:[...e.getCurrentPageShapeIds()],{scale:1,background:e.getInstanceState().exportBackground,...n});if(!r)throw new Error("Could not construct SVG.");return r}async function Cv(e,t,n,r={}){var o;switch(n){case"svg":return(o=await rA(e,t,r))==null?void 0:o.svg;case"json":{const s=e.getContentFromCurrentPage(t);return JSON.stringify(s)}default:fn(n)}}async function oA({editor:e,ids:t,format:n,opts:r={}}){switch(n){case"svg":return new Blob([await Cv(e,t,"svg",r)],{type:"text/plain"});case"json":return new Blob([await Cv(e,t,"json",r)],{type:"text/plain"});case"jpeg":case"png":case"webp":{const o=await rA(e,t,r);if(!o)throw new Error("Could not construct image.");const s=await nA(o.svg,e.environment.isSafari,{type:n,quality:1,scale:2,width:o.width,height:o.height});if(!s)throw new Error("Could not construct image.");return s}default:fn(n)}}const kZ={jpeg:"image/jpeg",png:"image/png",webp:"image/webp",json:"text/plain",svg:"text/plain"};function TZ(e,t,n,r={}){return{blobPromise:oA({editor:e,ids:t,format:n,opts:r}),mimeType:kZ[n]}}function $Z(e,t,n="svg",r={}){if(!window.navigator.clipboard)return Promise.reject(new Error("Copy not supported"));if(window.navigator.clipboard.write){const{blobPromise:o,mimeType:s}=TZ(e,t,n,r);return window.navigator.clipboard.write([new ClipboardItem({[s]:o})]).catch(i=>(console.error(i),o.then(a=>window.navigator.clipboard.write([new ClipboardItem({[s]:a})]))))}switch(n){case"json":case"svg":return MZ(async()=>Cv(e,t,n,r));case"jpeg":case"png":throw new Error("Copy not supported");default:fn(n)}}async function MZ(e){var t,n;await((n=(t=navigator.clipboard)==null?void 0:t.writeText)==null?void 0:n.call(t,await e()))}function AZ(){const e=z(),{addToast:t}=Wr(),n=Me();return x.useCallback((r,o="svg")=>{$Z(e,r,o).catch(()=>{t({id:"copy-fail",severity:"warning",title:n("toast.error.copy-fail.title"),description:n("toast.error.copy-fail.desc")})})},[e,t,n])}async function jZ(e,t,n="png",r,o={}){if(!r&&(r=`shapes at ${rI()}`,t.length===1)){const a=e.getShape(t[0]);e.isShapeOfType(a,"frame")?r=a.props.name??"frame":r=`${a.id.replace(/:/,"_")} at ${rI()}`}r+=`.${n}`;const s=await oA({editor:e,ids:t,format:n,opts:o}),i=new File([s],r,{type:s.type});OZ(i)}function rI(){const e=new Date,t=String(e.getFullYear()).slice(2),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),s=String(e.getMinutes()).padStart(2,"0"),i=String(e.getSeconds()).padStart(2,"0");return`${t}-${n}-${r} ${o}.${s}.${i}`}function OZ(e){const t=document.createElement("a"),n=URL.createObjectURL(e);t.href=n,t.download=e.name,t.click(),URL.revokeObjectURL(n)}function DZ(){const e=z(),{addToast:t}=Wr(),n=Me();return x.useCallback((r,o="png",s)=>{jZ(e,r,o,s,{scale:1,background:e.getInstanceState().exportBackground}).catch(i=>{console.error(i.message),t({id:"export-fail",title:n("toast.error.export-fail.title"),description:n("toast.error.export-fail.desc"),severity:"error"})})},[e,t,n])}function RZ(){const e=z(),t=x.useRef(null),n=x.useRef(null);return x.useCallback(async function(){const o=document.createElement("div"),s=document.createElement("style"),i=(S,v)=>{S&&(S.innerHTML=""),v&&document.head.contains(v)&&document.head.removeChild(v),S&&document.body.contains(S)&&document.body.removeChild(S)};i(t.current,n.current),t.current=o,n.current=s;const a=`tl-print-surface-${rt()}`;o.className=a,s.innerHTML=`
|
|
220
|
-
.${a} {
|
|
221
|
-
display: none;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.${a} svg {
|
|
225
|
-
max-width: 100%;
|
|
226
|
-
height: 100%;
|
|
227
|
-
display: block;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
@media print {
|
|
231
|
-
html, body {
|
|
232
|
-
min-height: 100%;
|
|
233
|
-
height: 100%;
|
|
234
|
-
margin: 0;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
body {
|
|
238
|
-
position: relative;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
body > * {
|
|
242
|
-
display: none;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.tldraw__editor {
|
|
246
|
-
display: none;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.${a} {
|
|
250
|
-
display: block !important;
|
|
251
|
-
background: white;
|
|
252
|
-
min-height: 100%;
|
|
253
|
-
height: 100%;
|
|
254
|
-
max-width: 100%;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.${a}__item {
|
|
258
|
-
padding: 10mm;
|
|
259
|
-
display: flex;
|
|
260
|
-
min-height: 100%;
|
|
261
|
-
flex-direction: column;
|
|
262
|
-
page-break-after: always;
|
|
263
|
-
position: relative;
|
|
264
|
-
overflow: hidden;
|
|
265
|
-
height: 100%;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
.${a}__item__main {
|
|
269
|
-
flex: 1;
|
|
270
|
-
display: flex;
|
|
271
|
-
align-items: center;
|
|
272
|
-
justify-content: center;
|
|
273
|
-
max-height: 100%;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
.${a}__item__header {
|
|
277
|
-
display: none;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
.${a}__item__footer {
|
|
281
|
-
display: none;
|
|
282
|
-
text-align: right;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
.${a}__item__footer__hide {
|
|
286
|
-
display: none;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
`;const c=()=>{document.head.appendChild(s),document.body.appendChild(o)},l=()=>{e.once("tick",()=>{i(o,s)})};window.addEventListener("beforeprint",c),window.addEventListener("afterprint",l);function u(S,v,P){try{o.innerHTML+=`<div class="${a}__item">
|
|
293
|
-
<div class="${a}__item__header">
|
|
294
|
-
${S.replace(/</g,"<").replace(/>/g,">")}
|
|
295
|
-
</div>
|
|
296
|
-
<div class="${a}__item__main">
|
|
297
|
-
${P}
|
|
298
|
-
</div>
|
|
299
|
-
<div class="${a}__item__footer ${a}__item__footer__${v?"":"hide"}">
|
|
300
|
-
${v??""}
|
|
301
|
-
</div>
|
|
302
|
-
</div>`}catch(I){console.error(I)}}function d(){e.environment.isChromeForIos?(c(),window.print()):e.environment.isSafari?(c(),document.execCommand("print",!1)):window.print()}const p=e.getSelectedShapeIds(),f=e.getCurrentPageId(),y=e.getPages(),w={scale:1,background:!1,darkMode:!1,preserveAspectRatio:"xMidYMid meet"};if(e.getSelectedShapeIds().length>0){const S=await e.getSvgString(p,w);if(S){const v=y.find(P=>P.id===f);u(`tldraw — ${v==null?void 0:v.name}`,null,S.svg),d()}}else{const S=e.getCurrentPage(),v=await e.getSvgString(e.getSortedChildIdsForParent(S.id),w);v&&(u(`tldraw — ${S.name}`,null,v.svg),d())}window.removeEventListener("beforeprint",c),window.removeEventListener("afterprint",l)},[e])}const sA=x.createContext({});function LZ(e){return Object.fromEntries(e.map(t=>[t.id,t]))}function la(e,t){if(e.getSelectedShapes().length===0)return e.getDocumentSettings().name||t}function FZ({overrides:e,children:t}){const n=z(),{addDialog:r,clearDialogs:o}=Gi(),{clearToasts:s}=Wr(),i=Me(),a=YM(),c=RZ(),{cut:l,copy:u,paste:d}=EZ(),p=AZ(),f=DZ(),y=i("document.default-name"),g=xo(),w=x.useMemo(()=>{function S(){return n.isIn("select")||(n.complete(),n.setCurrentTool("select")),!1}function v(){return n.isIn("select")&&n.getSelectedShapeIds().length>0}const I=LZ([{id:"edit-link",label:"action.edit-link",icon:"link",onSelect(C){v()&&(S()||(g("edit-link",{source:C}),n.mark("edit-link"),r({component:sZ})))}},{id:"insert-embed",label:"action.insert-embed",kbd:"$i",onSelect(C){g("insert-embed",{source:C}),r({component:VM})}},{id:"insert-media",label:"action.insert-media",kbd:"$u",onSelect(C){g("insert-media",{source:C}),a()}},{id:"undo",label:"action.undo",icon:"undo",kbd:"$z",onSelect(C){g("undo",{source:C}),n.undo()}},{id:"redo",label:"action.redo",icon:"redo",kbd:"$!z",onSelect(C){g("redo",{source:C}),n.redo()}},{id:"export-as-svg",label:{default:"action.export-as-svg",menu:"action.export-as-svg.short","context-menu":"action.export-as-svg.short"},readonlyOk:!0,onSelect(C){let E=n.getSelectedShapeIds();E.length===0&&(E=Array.from(n.getCurrentPageShapeIds().values())),E.length!==0&&(g("export-as",{format:"svg",source:C}),f(E,"svg",la(n,y)))}},{id:"export-as-png",label:{default:"action.export-as-png",menu:"action.export-as-png.short","context-menu":"action.export-as-png.short"},readonlyOk:!0,onSelect(C){let E=n.getSelectedShapeIds();E.length===0&&(E=Array.from(n.getCurrentPageShapeIds().values())),E.length!==0&&(g("export-as",{format:"png",source:C}),f(E,"png",la(n,y)))}},{id:"export-as-json",label:{default:"action.export-as-json",menu:"action.export-as-json.short","context-menu":"action.export-as-json.short"},readonlyOk:!0,onSelect(C){let E=n.getSelectedShapeIds();E.length===0&&(E=Array.from(n.getCurrentPageShapeIds().values())),E.length!==0&&(g("export-as",{format:"json",source:C}),f(E,"json",la(n,y)))}},{id:"export-all-as-svg",label:{default:"action.export-all-as-svg",menu:"action.export-all-as-svg.short","context-menu":"action.export-all-as-svg.short"},readonlyOk:!0,onSelect(C){let E=n.getSelectedShapeIds();E.length===0&&(E=Array.from(n.getCurrentPageShapeIds().values())),E.length!==0&&(g("export-all-as",{format:"svg",source:C}),f(Array.from(n.getCurrentPageShapeIds()),"svg",la(n,y)))}},{id:"export-all-as-png",label:{default:"action.export-all-as-png",menu:"action.export-all-as-png.short","context-menu":"action.export-all-as-png.short"},readonlyOk:!0,onSelect(C){const E=Array.from(n.getCurrentPageShapeIds().values());E.length!==0&&(g("export-all-as",{format:"png",source:C}),f(E,"png",la(n,y)))}},{id:"export-all-as-json",label:{default:"action.export-all-as-json",menu:"action.export-all-as-json.short","context-menu":"action.export-all-as-json.short"},readonlyOk:!0,onSelect(C){const E=Array.from(n.getCurrentPageShapeIds().values());E.length!==0&&(g("export-all-as",{format:"json",source:C}),f(E,"json",la(n,y)))}},{id:"copy-as-svg",label:{default:"action.copy-as-svg",menu:"action.copy-as-svg.short","context-menu":"action.copy-as-svg.short"},kbd:"$!c",readonlyOk:!0,onSelect(C){let E=n.getSelectedShapeIds();E.length===0&&(E=Array.from(n.getCurrentPageShapeIds().values())),E.length!==0&&(g("copy-as",{format:"svg",source:C}),p(E,"svg"))}},{id:"copy-as-png",label:{default:"action.copy-as-png",menu:"action.copy-as-png.short","context-menu":"action.copy-as-png.short"},readonlyOk:!0,onSelect(C){let E=n.getSelectedShapeIds();E.length===0&&(E=Array.from(n.getCurrentPageShapeIds().values())),E.length!==0&&(g("copy-as",{format:"png",source:C}),p(E,"png"))}},{id:"copy-as-json",label:{default:"action.copy-as-json",menu:"action.copy-as-json.short","context-menu":"action.copy-as-json.short"},readonlyOk:!0,onSelect(C){let E=n.getSelectedShapeIds();E.length===0&&(E=Array.from(n.getCurrentPageShapeIds().values())),E.length!==0&&(g("copy-as",{format:"json",source:C}),p(E,"json"))}},{id:"toggle-auto-size",label:"action.toggle-auto-size",onSelect(C){if(!v()||S())return;g("toggle-auto-size",{source:C}),n.mark("toggling auto size");const E=n.getSelectedShapes().filter(_=>n.isShapeOfType(_,"text")&&_.props.autoSize===!1);n.updateShapes(E.map(_=>({id:_.id,type:_.type,props:{..._.props,w:8,autoSize:!0}}))),Ye(n,E.map(_=>_.id))}},{id:"open-embed-link",label:"action.open-embed-link",readonlyOk:!0,onSelect(C){g("open-embed-link",{source:C});const E=n.getSelectedShapeIds(),_="No embed shapes selected";if(E.length!==1){console.error(_);return}const k=n.getShape(E[0]);if(!k||!n.isShapeOfType(k,"embed")){console.error(_);return}F8(k.props.url,"_blank")}},{id:"select-zoom-tool",readonlyOk:!0,kbd:"z",onSelect(C){var E,_;if(((E=n.root.getCurrent())==null?void 0:E.id)!=="zoom"&&(g("zoom-tool",{source:C}),!(n.inputs.shiftKey||n.inputs.ctrlKey))){const k=n.root.getCurrent();k&&((_=k.getCurrent())==null?void 0:_.id)==="idle"&&n.setCurrentTool("zoom",{onInteractionEnd:k.id,maskAs:"zoom"})}}},{id:"convert-to-bookmark",label:"action.convert-to-bookmark",onSelect(C){v()&&(S()||n.batch(()=>{g("convert-to-bookmark",{source:C});const E=n.getSelectedShapes(),_=[],k=[];for(const $ of E){if(!$||!n.isShapeOfType($,"embed")||!$.props.url)continue;const T=new b($.x,$.y);T.rot(-$.rotation),T.add(new b($.props.w/2-300/2,$.props.h/2-320/2)),T.rot($.rotation);const A={id:He(),type:"bookmark",rotation:$.rotation,x:T.x,y:T.y,opacity:1,props:{url:$.props.url}};_.push(A),k.push($.id)}n.mark("convert shapes to bookmark"),n.deleteShapes(k),n.createShapes(_)}))}},{id:"convert-to-embed",label:"action.convert-to-embed",onSelect(C){v()&&(S()||(g("convert-to-embed",{source:C}),n.batch(()=>{const E=n.getSelectedShapeIds(),_=fe(E.map(T=>n.getShape(T))),k=[],$=[];for(const T of _){if(!n.isShapeOfType(T,"bookmark"))continue;const{url:A}=T.props,B=Es(T.props.url);if(!B||!B.definition)continue;const{width:L,height:R}=B.definition,N=new b(T.x,T.y);N.rot(-T.rotation),N.add(new b(T.props.w/2-L/2,T.props.h/2-R/2)),N.rot(T.rotation);const X={id:He(),type:"embed",x:N.x,y:N.y,rotation:T.rotation,props:{url:A,w:L,h:R}};k.push(X),$.push(T.id)}n.mark("convert shapes to embed"),n.deleteShapes($),n.createShapes(k)})))}},{id:"duplicate",kbd:"$d",label:"action.duplicate",icon:"duplicate",onSelect(C){if(!v()||S())return;g("duplicate-shapes",{source:C});const E=n.getInstanceState();let _,k;if(E.duplicateProps)_=E.duplicateProps.shapeIds,k=E.duplicateProps.offset;else{_=n.getSelectedShapeIds();const $=te.Common(fe(_.map(T=>n.getShapePageBounds(T))));k=n.getCameraOptions().isLocked?{x:20,y:20}:{x:$.width+20,y:0}}n.mark("duplicate shapes"),n.duplicateShapes(_,k),E.duplicateProps&&n.updateInstanceState({duplicateProps:{...E.duplicateProps,shapeIds:n.getSelectedShapeIds()}})}},{id:"ungroup",label:"action.ungroup",kbd:"$!g",icon:"ungroup",onSelect(C){v()&&(S()||(g("ungroup-shapes",{source:C}),n.mark("ungroup"),n.ungroupShapes(n.getSelectedShapeIds())))}},{id:"group",label:"action.group",kbd:"$g",icon:"group",onSelect(C){if(!v()||S())return;g("group-shapes",{source:C});const E=n.getOnlySelectedShape();E&&n.isShapeOfType(E,"group")?(n.mark("ungroup"),n.ungroupShapes(n.getSelectedShapeIds())):(n.mark("group"),n.groupShapes(n.getSelectedShapeIds()))}},{id:"remove-frame",label:"action.remove-frame",kbd:"$!f",onSelect(C){if(!v())return;g("remove-frame",{source:C});const E=n.getSelectedShapes();E.length>0&&E.every(_=>n.isShapeOfType(_,"frame"))&&(n.mark("remove-frame"),nZ(n,E.map(_=>_.id)))}},{id:"fit-frame-to-content",label:"action.fit-frame-to-content",onSelect(C){if(!v())return;g("fit-frame-to-content",{source:C});const E=n.getOnlySelectedShape();E&&n.isShapeOfType(E,"frame")&&(n.mark("fit-frame-to-content"),oZ(n,E.id))}},{id:"align-left",label:"action.align-left",kbd:"?A",icon:"align-left",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"left",source:C}),n.mark("align left");const E=n.getSelectedShapeIds();n.alignShapes(E,"left"),Ye(n,E)}},{id:"align-center-horizontal",label:{default:"action.align-center-horizontal","context-menu":"action.align-center-horizontal.short"},kbd:"?H",icon:"align-center-horizontal",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"center-horizontal",source:C}),n.mark("align center horizontal");const E=n.getSelectedShapeIds();n.alignShapes(E,"center-horizontal"),Ye(n,E)}},{id:"align-right",label:"action.align-right",kbd:"?D",icon:"align-right",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"right",source:C}),n.mark("align right");const E=n.getSelectedShapeIds();n.alignShapes(E,"right"),Ye(n,E)}},{id:"align-center-vertical",label:{default:"action.align-center-vertical","context-menu":"action.align-center-vertical.short"},kbd:"?V",icon:"align-center-vertical",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"center-vertical",source:C}),n.mark("align center vertical");const E=n.getSelectedShapeIds();n.alignShapes(E,"center-vertical"),Ye(n,E)}},{id:"align-top",label:"action.align-top",icon:"align-top",kbd:"?W",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"top",source:C}),n.mark("align top");const E=n.getSelectedShapeIds();n.alignShapes(E,"top"),Ye(n,E)}},{id:"align-bottom",label:"action.align-bottom",icon:"align-bottom",kbd:"?S",onSelect(C){if(!v()||S())return;g("align-shapes",{operation:"bottom",source:C}),n.mark("align bottom");const E=n.getSelectedShapeIds();n.alignShapes(E,"bottom"),Ye(n,E)}},{id:"distribute-horizontal",label:{default:"action.distribute-horizontal","context-menu":"action.distribute-horizontal.short"},icon:"distribute-horizontal",kbd:"?!h",onSelect(C){if(!v()||S())return;g("distribute-shapes",{operation:"horizontal",source:C}),n.mark("distribute horizontal");const E=n.getSelectedShapeIds();n.distributeShapes(E,"horizontal"),Ye(n,E)}},{id:"distribute-vertical",label:{default:"action.distribute-vertical","context-menu":"action.distribute-vertical.short"},icon:"distribute-vertical",kbd:"?!V",onSelect(C){if(!v()||S())return;g("distribute-shapes",{operation:"vertical",source:C}),n.mark("distribute vertical");const E=n.getSelectedShapeIds();n.distributeShapes(E,"vertical"),Ye(n,E)}},{id:"stretch-horizontal",label:{default:"action.stretch-horizontal","context-menu":"action.stretch-horizontal.short"},icon:"stretch-horizontal",onSelect(C){if(!v()||S())return;g("stretch-shapes",{operation:"horizontal",source:C}),n.mark("stretch horizontal");const E=n.getSelectedShapeIds();n.stretchShapes(E,"horizontal"),Ye(n,E)}},{id:"stretch-vertical",label:{default:"action.stretch-vertical","context-menu":"action.stretch-vertical.short"},icon:"stretch-vertical",onSelect(C){if(!v()||S())return;g("stretch-shapes",{operation:"vertical",source:C}),n.mark("stretch vertical");const E=n.getSelectedShapeIds();n.stretchShapes(E,"vertical"),Ye(n,E)}},{id:"flip-horizontal",label:{default:"action.flip-horizontal","context-menu":"action.flip-horizontal.short"},kbd:"!h",onSelect(C){if(!v()||S())return;g("flip-shapes",{operation:"horizontal",source:C}),n.mark("flip horizontal");const E=n.getSelectedShapeIds();n.flipShapes(E,"horizontal"),Ye(n,E)}},{id:"flip-vertical",label:{default:"action.flip-vertical","context-menu":"action.flip-vertical.short"},kbd:"!v",onSelect(C){if(!v()||S())return;g("flip-shapes",{operation:"vertical",source:C}),n.mark("flip vertical");const E=n.getSelectedShapeIds();n.flipShapes(E,"vertical"),Ye(n,E)}},{id:"pack",label:"action.pack",icon:"pack",onSelect(C){if(!v()||S())return;g("pack-shapes",{source:C}),n.mark("pack");const E=n.getSelectedShapeIds();n.packShapes(E,B$),Ye(n,E)}},{id:"stack-vertical",label:{default:"action.stack-vertical","context-menu":"action.stack-vertical.short"},icon:"stack-vertical",onSelect(C){if(!v()||S())return;g("stack-shapes",{operation:"vertical",source:C}),n.mark("stack-vertical");const E=n.getSelectedShapeIds();n.stackShapes(E,"vertical",16),Ye(n,E)}},{id:"stack-horizontal",label:{default:"action.stack-horizontal","context-menu":"action.stack-horizontal.short"},icon:"stack-horizontal",onSelect(C){if(!v()||S())return;g("stack-shapes",{operation:"horizontal",source:C}),n.mark("stack-horizontal");const E=n.getSelectedShapeIds();n.stackShapes(E,"horizontal",16),Ye(n,E)}},{id:"bring-to-front",label:"action.bring-to-front",kbd:"]",icon:"bring-to-front",onSelect(C){v()&&(S()||(g("reorder-shapes",{operation:"toFront",source:C}),n.mark("bring to front"),n.bringToFront(n.getSelectedShapeIds())))}},{id:"bring-forward",label:"action.bring-forward",icon:"bring-forward",kbd:"?]",onSelect(C){v()&&(S()||(g("reorder-shapes",{operation:"forward",source:C}),n.mark("bring forward"),n.bringForward(n.getSelectedShapeIds())))}},{id:"send-backward",label:"action.send-backward",icon:"send-backward",kbd:"?[",onSelect(C){v()&&(S()||(g("reorder-shapes",{operation:"backward",source:C}),n.mark("send backward"),n.sendBackward(n.getSelectedShapeIds())))}},{id:"send-to-back",label:"action.send-to-back",icon:"send-to-back",kbd:"[",onSelect(C){v()&&(S()||(g("reorder-shapes",{operation:"toBack",source:C}),n.mark("send to back"),n.sendToBack(n.getSelectedShapeIds())))}},{id:"cut",label:"action.cut",kbd:"$x",onSelect(C){v()&&(S()||(n.mark("cut"),l(C)))}},{id:"copy",label:"action.copy",kbd:"$c",readonlyOk:!0,onSelect(C){v()&&(S()||u(C))}},{id:"paste",label:"action.paste",kbd:"$v",onSelect(C){var E;(E=navigator.clipboard)==null||E.read().then(_=>{d(_,C,C==="context-menu"?n.inputs.currentPagePoint:void 0)})}},{id:"select-all",label:"action.select-all",kbd:"$a",readonlyOk:!0,onSelect(C){n.batch(()=>{S()||(g("select-all-shapes",{source:C}),n.mark("select all kbd"),n.selectAll())})}},{id:"select-none",label:"action.select-none",readonlyOk:!0,onSelect(C){v()&&(S()||(g("select-none-shapes",{source:C}),n.mark("select none"),n.selectNone()))}},{id:"delete",label:"action.delete",kbd:"⌫,del,backspace",icon:"trash",onSelect(C){v()&&(S()||(g("delete-shapes",{source:C}),n.mark("delete"),n.deleteShapes(n.getSelectedShapeIds())))}},{id:"rotate-cw",label:"action.rotate-cw",icon:"rotate-cw",onSelect(C){if(!v()||S())return;g("rotate-cw",{source:C}),n.mark("rotate-cw");const E=n.getSelectionRotation()%(Ue/2),_=yl(E,0)||yl(E,Ue/2),k=n.getSelectedShapeIds();n.rotateShapesBy(k,Ue/2-(_?0:E)),Ye(n,k)}},{id:"rotate-ccw",label:"action.rotate-ccw",icon:"rotate-ccw",onSelect(C){if(!v()||S())return;g("rotate-ccw",{source:C}),n.mark("rotate-ccw");const E=n.getSelectionRotation()%(Ue/2),_=yl(E,0),k=n.getSelectedShapeIds();n.rotateShapesBy(k,_?-(Ue/2):-E),Ye(n,k)}},{id:"zoom-in",label:"action.zoom-in",kbd:"$=,=",readonlyOk:!0,onSelect(C){g("zoom-in",{source:C}),n.zoomIn(void 0,{animation:{duration:Qr}})}},{id:"zoom-out",label:"action.zoom-out",kbd:"$-,-",readonlyOk:!0,onSelect(C){g("zoom-out",{source:C}),n.zoomOut(void 0,{animation:{duration:Qr}})}},{id:"zoom-to-100",label:"action.zoom-to-100",icon:"reset-zoom",kbd:"!0",readonlyOk:!0,onSelect(C){g("reset-zoom",{source:C}),n.resetZoom(void 0,{animation:{duration:Qr}})}},{id:"zoom-to-fit",label:"action.zoom-to-fit",kbd:"!1",readonlyOk:!0,onSelect(C){g("zoom-to-fit",{source:C}),n.zoomToFit({animation:{duration:Qr}})}},{id:"zoom-to-selection",label:"action.zoom-to-selection",kbd:"!2",readonlyOk:!0,onSelect(C){v()&&(S()||(g("zoom-to-selection",{source:C}),n.zoomToSelection({animation:{duration:Qr}})))}},{id:"toggle-snap-mode",label:{default:"action.toggle-snap-mode",menu:"action.toggle-snap-mode.menu"},onSelect(C){g("toggle-snap-mode",{source:C}),n.user.updateUserPreferences({isSnapMode:!n.user.getIsSnapMode()})},checkbox:!0},{id:"toggle-dark-mode",label:{default:"action.toggle-dark-mode",menu:"action.toggle-dark-mode.menu"},kbd:"$/",readonlyOk:!0,onSelect(C){g("toggle-dark-mode",{source:C}),n.user.updateUserPreferences({isDarkMode:!n.user.getIsDarkMode()})},checkbox:!0},{id:"toggle-wrap-mode",label:{default:"action.toggle-wrap-mode",menu:"action.toggle-wrap-mode.menu"},readonlyOk:!0,onSelect(C){g("toggle-wrap-mode",{source:C}),n.user.updateUserPreferences({isWrapMode:!n.user.getIsWrapMode()})},checkbox:!0},{id:"toggle-reduce-motion",label:{default:"action.toggle-reduce-motion",menu:"action.toggle-reduce-motion.menu"},readonlyOk:!0,onSelect(C){g("toggle-reduce-motion",{source:C}),n.user.updateUserPreferences({animationSpeed:n.user.getAnimationSpeed()===0?1:0})},checkbox:!0},{id:"toggle-edge-scrolling",label:{default:"action.toggle-edge-scrolling",menu:"action.toggle-edge-scrolling.menu"},readonlyOk:!0,onSelect(C){g("toggle-edge-scrolling",{source:C}),n.user.updateUserPreferences({edgeScrollSpeed:n.user.getEdgeScrollSpeed()===0?1:0})},checkbox:!0},{id:"toggle-transparent",label:{default:"action.toggle-transparent",menu:"action.toggle-transparent.menu","context-menu":"action.toggle-transparent.context-menu"},readonlyOk:!0,onSelect(C){g("toggle-transparent",{source:C}),n.updateInstanceState({exportBackground:!n.getInstanceState().exportBackground})},checkbox:!0},{id:"toggle-tool-lock",label:{default:"action.toggle-tool-lock",menu:"action.toggle-tool-lock.menu"},kbd:"q",onSelect(C){g("toggle-tool-lock",{source:C}),n.updateInstanceState({isToolLocked:!n.getInstanceState().isToolLocked})},checkbox:!0},{id:"unlock-all",label:"action.unlock-all",onSelect(C){g("unlock-all",{source:C});const E=[];for(const _ of n.getCurrentPageShapes())_.isLocked&&E.push({id:_.id,type:_.type,isLocked:!1});E.length>0&&n.updateShapes(E)}},{id:"toggle-focus-mode",label:{default:"action.toggle-focus-mode",menu:"action.toggle-focus-mode.menu"},readonlyOk:!0,kbd:"$.",checkbox:!0,onSelect(C){requestAnimationFrame(()=>{n.batch(()=>{g("toggle-focus-mode",{source:C}),o(),s(),n.updateInstanceState({isFocusMode:!n.getInstanceState().isFocusMode})})})}},{id:"toggle-grid",label:{default:"action.toggle-grid",menu:"action.toggle-grid.menu"},readonlyOk:!0,kbd:"$'",onSelect(C){g("toggle-grid-mode",{source:C}),n.updateInstanceState({isGridMode:!n.getInstanceState().isGridMode})},checkbox:!0},{id:"toggle-debug-mode",label:{default:"action.toggle-debug-mode",menu:"action.toggle-debug-mode.menu"},readonlyOk:!0,onSelect(C){g("toggle-debug-mode",{source:C}),n.updateInstanceState({isDebugMode:!n.getInstanceState().isDebugMode})},checkbox:!0},{id:"print",label:"action.print",kbd:"$p",readonlyOk:!0,onSelect(C){g("print",{source:C}),c()}},{id:"exit-pen-mode",label:"action.exit-pen-mode",icon:"cross-2",readonlyOk:!0,onSelect(C){g("exit-pen-mode",{source:C}),n.updateInstanceState({isPenMode:!1})}},{id:"stop-following",label:"action.stop-following",icon:"cross-2",readonlyOk:!0,onSelect(C){g("stop-following",{source:C}),n.stopFollowingUser()}},{id:"back-to-content",label:"action.back-to-content",icon:"arrow-left",readonlyOk:!0,onSelect(C){g("zoom-to-content",{source:C});const E=n.getSelectionPageBounds()??n.getCurrentPageBounds();E&&n.zoomToBounds(E,{targetZoom:Math.min(1,n.getZoomLevel()),animation:{duration:220}})}},{id:"toggle-lock",label:"action.toggle-lock",kbd:"!l",onSelect(C){n.mark("locking"),g("toggle-lock",{source:C}),n.toggleLock(n.getSelectedShapeIds())}},{id:"new-page",label:"context.pages.new-page",onSelect(C){const E=Bo.createId(),_=n.getSelectedShapeIds();n.batch(()=>{n.mark("move_shapes_to_page"),n.createPage({name:i("page-menu.new-page-initial-name"),id:E}),n.moveShapesToPage(_,E)}),g("new-page",{source:C})}},{id:"select-white-color",label:"color-style.white",kbd:"?t",onSelect(C){const E=tr;n.batch(()=>{n.mark("change-color"),n.isIn("select")&&n.setStyleForSelectedShapes(E,"white"),n.setStyleForNextShapes(E,"white"),n.updateInstanceState({isChangingStyle:!0})}),g("set-style",{source:C,id:E.id,value:"white"})}}]);return e?e(n,I,void 0):I},[n,g,e,r,a,f,p,l,u,d,o,s,c,i,y]);return h.jsx(sA.Provider,{value:w,children:t})}function ce(){const e=x.useContext(sA);if(!e)throw new Error("useTools must be used within a ToolProvider");return e}function cu(e,t){return e?typeof e=="string"?e:t?e[t]??e.default:void 0:void 0}const NZ=["top","right","bottom","left"],to=Math.min,Gn=Math.max,of=Math.round,Kd=Math.floor,Hs=e=>({x:e,y:e}),zZ={left:"right",right:"left",bottom:"top",top:"bottom"},BZ={start:"end",end:"start"};function Iv(e,t,n){return Gn(e,to(t,n))}function Xo(e,t){return typeof e=="function"?e(t):e}function qo(e){return e.split("-")[0]}function Cc(e){return e.split("-")[1]}function Jx(e){return e==="x"?"y":"x"}function ew(e){return e==="y"?"height":"width"}function Ic(e){return["top","bottom"].includes(qo(e))?"y":"x"}function tw(e){return Jx(Ic(e))}function UZ(e,t,n){n===void 0&&(n=!1);const r=Cc(e),o=tw(e),s=ew(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=sf(i)),[i,sf(i)]}function HZ(e){const t=sf(e);return[Ev(e),t,Ev(t)]}function Ev(e){return e.replace(/start|end/g,t=>BZ[t])}function KZ(e,t,n){const r=["left","right"],o=["right","left"],s=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?s:i;default:return[]}}function WZ(e,t,n,r){const o=Cc(e);let s=KZ(qo(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ev)))),s}function sf(e){return e.replace(/left|right|bottom|top/g,t=>zZ[t])}function GZ(e){return{top:0,right:0,bottom:0,left:0,...e}}function iA(e){return typeof e!="number"?GZ(e):{top:e,right:e,bottom:e,left:e}}function af(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function oI(e,t,n){let{reference:r,floating:o}=e;const s=Ic(t),i=tw(t),a=ew(i),c=qo(t),l=s==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let f;switch(c){case"top":f={x:u,y:r.y-o.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-o.width,y:d};break;default:f={x:r.x,y:r.y}}switch(Cc(t)){case"start":f[i]-=p*(n&&l?-1:1);break;case"end":f[i]+=p*(n&&l?-1:1);break}return f}const VZ=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=oI(l,r,c),p=r,f={},y=0;for(let g=0;g<a.length;g++){const{name:w,fn:S}=a[g],{x:v,y:P,data:I,reset:C}=await S({x:u,y:d,initialPlacement:r,placement:p,strategy:o,middlewareData:f,rects:l,platform:i,elements:{reference:e,floating:t}});u=v??u,d=P??d,f={...f,[w]:{...f[w],...I}},C&&y<=50&&(y++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(l=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:u,y:d}=oI(l,p,c)),g=-1)}return{x:u,y:d,placement:p,strategy:o,middlewareData:f}};async function lu(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:p=!1,padding:f=0}=Xo(t,e),y=iA(f),w=a[p?d==="floating"?"reference":"floating":d],S=af(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:l,rootBoundary:u,strategy:c})),v=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,P=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),I=await(s.isElement==null?void 0:s.isElement(P))?await(s.getScale==null?void 0:s.getScale(P))||{x:1,y:1}:{x:1,y:1},C=af(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:P,strategy:c}):v);return{top:(S.top-C.top+y.top)/I.y,bottom:(C.bottom-S.bottom+y.bottom)/I.y,left:(S.left-C.left+y.left)/I.x,right:(C.right-S.right+y.right)/I.x}}const YZ=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:l,padding:u=0}=Xo(e,t)||{};if(l==null)return{};const d=iA(u),p={x:n,y:r},f=tw(o),y=ew(f),g=await i.getDimensions(l),w=f==="y",S=w?"top":"left",v=w?"bottom":"right",P=w?"clientHeight":"clientWidth",I=s.reference[y]+s.reference[f]-p[f]-s.floating[y],C=p[f]-s.reference[f],E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let _=E?E[P]:0;(!_||!await(i.isElement==null?void 0:i.isElement(E)))&&(_=a.floating[P]||s.floating[y]);const k=I/2-C/2,$=_/2-g[y]/2-1,T=to(d[S],$),A=to(d[v],$),B=T,L=_-g[y]-A,R=_/2-g[y]/2+k,N=Iv(B,R,L),X=!c.arrow&&Cc(o)!=null&&R!==N&&s.reference[y]/2-(R<B?T:A)-g[y]/2<0,q=X?R<B?R-B:R-L:0;return{[f]:p[f]+q,data:{[f]:N,centerOffset:R-N-q,...X&&{alignmentOffset:q}},reset:X}}}),XZ=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:c,elements:l}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:g=!0,...w}=Xo(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const S=qo(o),v=qo(a)===a,P=await(c.isRTL==null?void 0:c.isRTL(l.floating)),I=p||(v||!g?[sf(a)]:HZ(a));!p&&y!=="none"&&I.push(...WZ(a,g,y,P));const C=[a,...I],E=await lu(t,w),_=[];let k=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&_.push(E[S]),d){const B=UZ(o,i,P);_.push(E[B[0]],E[B[1]])}if(k=[...k,{placement:o,overflows:_}],!_.every(B=>B<=0)){var $,T;const B=((($=s.flip)==null?void 0:$.index)||0)+1,L=C[B];if(L)return{data:{index:B,overflows:k},reset:{placement:L}};let R=(T=k.filter(N=>N.overflows[0]<=0).sort((N,X)=>N.overflows[1]-X.overflows[1])[0])==null?void 0:T.placement;if(!R)switch(f){case"bestFit":{var A;const N=(A=k.map(X=>[X.placement,X.overflows.filter(q=>q>0).reduce((q,H)=>q+H,0)]).sort((X,q)=>X[1]-q[1])[0])==null?void 0:A[0];N&&(R=N);break}case"initialPlacement":R=a;break}if(o!==R)return{reset:{placement:R}}}return{}}}};function sI(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function iI(e){return NZ.some(t=>e[t]>=0)}const qZ=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Xo(e,t);switch(r){case"referenceHidden":{const s=await lu(t,{...o,elementContext:"reference"}),i=sI(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:iI(i)}}}case"escaped":{const s=await lu(t,{...o,altBoundary:!0}),i=sI(s,n.floating);return{data:{escapedOffsets:i,escaped:iI(i)}}}default:return{}}}}};async function ZZ(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=qo(n),a=Cc(n),c=Ic(n)==="y",l=["left","top"].includes(i)?-1:1,u=s&&c?-1:1,d=Xo(t,e);let{mainAxis:p,crossAxis:f,alignmentAxis:y}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return a&&typeof y=="number"&&(f=a==="end"?y*-1:y),c?{x:f*u,y:p*l}:{x:p*l,y:f*u}}const QZ=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,c=await ZZ(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},JZ=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:w=>{let{x:S,y:v}=w;return{x:S,y:v}}},...c}=Xo(e,t),l={x:n,y:r},u=await lu(t,c),d=Ic(qo(o)),p=Jx(d);let f=l[p],y=l[d];if(s){const w=p==="y"?"top":"left",S=p==="y"?"bottom":"right",v=f+u[w],P=f-u[S];f=Iv(v,f,P)}if(i){const w=d==="y"?"top":"left",S=d==="y"?"bottom":"right",v=y+u[w],P=y-u[S];y=Iv(v,y,P)}const g=a.fn({...t,[p]:f,[d]:y});return{...g,data:{x:g.x-n,y:g.y-r}}}}},eQ=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:l=!0}=Xo(e,t),u={x:n,y:r},d=Ic(o),p=Jx(d);let f=u[p],y=u[d];const g=Xo(a,t),w=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const P=p==="y"?"height":"width",I=s.reference[p]-s.floating[P]+w.mainAxis,C=s.reference[p]+s.reference[P]-w.mainAxis;f<I?f=I:f>C&&(f=C)}if(l){var S,v;const P=p==="y"?"width":"height",I=["top","left"].includes(qo(o)),C=s.reference[d]-s.floating[P]+(I&&((S=i.offset)==null?void 0:S[d])||0)+(I?0:w.crossAxis),E=s.reference[d]+s.reference[P]+(I?0:((v=i.offset)==null?void 0:v[d])||0)-(I?w.crossAxis:0);y<C?y=C:y>E&&(y=E)}return{[p]:f,[d]:y}}}},tQ=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:o,elements:s}=t,{apply:i=()=>{},...a}=Xo(e,t),c=await lu(t,a),l=qo(n),u=Cc(n),d=Ic(n)==="y",{width:p,height:f}=r.floating;let y,g;l==="top"||l==="bottom"?(y=l,g=u===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(g=l,y=u==="end"?"top":"bottom");const w=f-c.top-c.bottom,S=p-c.left-c.right,v=to(f-c[y],w),P=to(p-c[g],S),I=!t.middlewareData.shift;let C=v,E=P;if(d?E=u||I?to(P,S):S:C=u||I?to(v,w):w,I&&!u){const k=Gn(c.left,0),$=Gn(c.right,0),T=Gn(c.top,0),A=Gn(c.bottom,0);d?E=p-2*(k!==0||$!==0?k+$:Gn(c.left,c.right)):C=f-2*(T!==0||A!==0?T+A:Gn(c.top,c.bottom))}await i({...t,availableWidth:E,availableHeight:C});const _=await o.getDimensions(s.floating);return p!==_.width||f!==_.height?{reset:{rects:!0}}:{}}}};function Ec(e){return aA(e)?(e.nodeName||"").toLowerCase():"#document"}function Jn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ss(e){var t;return(t=(aA(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function aA(e){return e instanceof Node||e instanceof Jn(e).Node}function ho(e){return e instanceof Element||e instanceof Jn(e).Element}function po(e){return e instanceof HTMLElement||e instanceof Jn(e).HTMLElement}function aI(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Jn(e).ShadowRoot}function Du(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Hr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function nQ(e){return["table","td","th"].includes(Ec(e))}function nw(e){const t=rw(),n=Hr(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function rQ(e){let t=Ks(e);for(;po(t)&&!cc(t);){if(nw(t))return t;t=Ks(t)}return null}function rw(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function cc(e){return["html","body","#document"].includes(Ec(e))}function Hr(e){return Jn(e).getComputedStyle(e)}function ug(e){return ho(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Ks(e){if(Ec(e)==="html")return e;const t=e.assignedSlot||e.parentNode||aI(e)&&e.host||ss(e);return aI(t)?t.host:t}function cA(e){const t=Ks(e);return cc(t)?e.ownerDocument?e.ownerDocument.body:e.body:po(t)&&Du(t)?t:cA(t)}function uu(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=cA(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Jn(o);return s?t.concat(i,i.visualViewport||[],Du(o)?o:[],i.frameElement&&n?uu(i.frameElement):[]):t.concat(o,uu(o,[],n))}function lA(e){const t=Hr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=po(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=of(n)!==s||of(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ow(e){return ho(e)?e:e.contextElement}function Ga(e){const t=ow(e);if(!po(t))return Hs(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=lA(t);let i=(s?of(n.width):n.width)/r,a=(s?of(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const oQ=Hs(0);function uA(e){const t=Jn(e);return!rw()||!t.visualViewport?oQ:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function sQ(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Jn(e)?!1:t}function Oi(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ow(e);let i=Hs(1);t&&(r?ho(r)&&(i=Ga(r)):i=Ga(e));const a=sQ(s,n,r)?uA(s):Hs(0);let c=(o.left+a.x)/i.x,l=(o.top+a.y)/i.y,u=o.width/i.x,d=o.height/i.y;if(s){const p=Jn(s),f=r&&ho(r)?Jn(r):r;let y=p,g=y.frameElement;for(;g&&r&&f!==y;){const w=Ga(g),S=g.getBoundingClientRect(),v=Hr(g),P=S.left+(g.clientLeft+parseFloat(v.paddingLeft))*w.x,I=S.top+(g.clientTop+parseFloat(v.paddingTop))*w.y;c*=w.x,l*=w.y,u*=w.x,d*=w.y,c+=P,l+=I,y=Jn(g),g=y.frameElement}}return af({width:u,height:d,x:c,y:l})}const iQ=[":popover-open",":modal"];function sw(e){return iQ.some(t=>{try{return e.matches(t)}catch{return!1}})}function aQ(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=ss(r),a=t?sw(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},l=Hs(1);const u=Hs(0),d=po(r);if((d||!d&&!s)&&((Ec(r)!=="body"||Du(i))&&(c=ug(r)),po(r))){const p=Oi(r);l=Ga(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x,y:n.y*l.y-c.scrollTop*l.y+u.y}}function cQ(e){return Array.from(e.getClientRects())}function dA(e){return Oi(ss(e)).left+ug(e).scrollLeft}function lQ(e){const t=ss(e),n=ug(e),r=e.ownerDocument.body,o=Gn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+dA(e);const a=-n.scrollTop;return Hr(r).direction==="rtl"&&(i+=Gn(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function uQ(e,t){const n=Jn(e),r=ss(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const l=rw();(!l||l&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}function dQ(e,t){const n=Oi(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=po(e)?Ga(e):Hs(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,l=r*s.y;return{width:i,height:a,x:c,y:l}}function cI(e,t,n){let r;if(t==="viewport")r=uQ(e,n);else if(t==="document")r=lQ(ss(e));else if(ho(t))r=dQ(t,n);else{const o=uA(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return af(r)}function hA(e,t){const n=Ks(e);return n===t||!ho(n)||cc(n)?!1:Hr(n).position==="fixed"||hA(n,t)}function hQ(e,t){const n=t.get(e);if(n)return n;let r=uu(e,[],!1).filter(a=>ho(a)&&Ec(a)!=="body"),o=null;const s=Hr(e).position==="fixed";let i=s?Ks(e):e;for(;ho(i)&&!cc(i);){const a=Hr(i),c=nw(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Du(i)&&!c&&hA(e,i))?r=r.filter(u=>u!==i):o=a,i=Ks(i)}return t.set(e,r),r}function pQ(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?sw(t)?[]:hQ(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((l,u)=>{const d=cI(t,u,o);return l.top=Gn(d.top,l.top),l.right=to(d.right,l.right),l.bottom=to(d.bottom,l.bottom),l.left=Gn(d.left,l.left),l},cI(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function fQ(e){const{width:t,height:n}=lA(e);return{width:t,height:n}}function gQ(e,t,n){const r=po(t),o=ss(t),s=n==="fixed",i=Oi(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=Hs(0);if(r||!r&&!s)if((Ec(t)!=="body"||Du(o))&&(a=ug(t)),r){const d=Oi(t,!0,s,t);c.x=d.x+t.clientLeft,c.y=d.y+t.clientTop}else o&&(c.x=dA(o));const l=i.left+a.scrollLeft-c.x,u=i.top+a.scrollTop-c.y;return{x:l,y:u,width:i.width,height:i.height}}function cy(e){return Hr(e).position==="static"}function lI(e,t){return!po(e)||Hr(e).position==="fixed"?null:t?t(e):e.offsetParent}function pA(e,t){const n=Jn(e);if(sw(e))return n;if(!po(e)){let o=Ks(e);for(;o&&!cc(o);){if(ho(o)&&!cy(o))return o;o=Ks(o)}return n}let r=lI(e,t);for(;r&&nQ(r)&&cy(r);)r=lI(r,t);return r&&cc(r)&&cy(r)&&!nw(r)?n:r||rQ(e)||n}const mQ=async function(e){const t=this.getOffsetParent||pA,n=this.getDimensions,r=await n(e.floating);return{reference:gQ(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yQ(e){return Hr(e).direction==="rtl"}const SQ={convertOffsetParentRelativeRectToViewportRelativeRect:aQ,getDocumentElement:ss,getClippingRect:pQ,getOffsetParent:pA,getElementRects:mQ,getClientRects:cQ,getDimensions:fQ,getScale:Ga,isElement:ho,isRTL:yQ};function vQ(e,t){let n=null,r;const o=ss(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const{left:l,top:u,width:d,height:p}=e.getBoundingClientRect();if(a||t(),!d||!p)return;const f=Kd(u),y=Kd(o.clientWidth-(l+d)),g=Kd(o.clientHeight-(u+p)),w=Kd(l),v={rootMargin:-f+"px "+-y+"px "+-g+"px "+-w+"px",threshold:Gn(0,to(1,c))||1};let P=!0;function I(C){const E=C[0].intersectionRatio;if(E!==c){if(!P)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}P=!1}try{n=new IntersectionObserver(I,{...v,root:o.ownerDocument})}catch{n=new IntersectionObserver(I,v)}n.observe(e)}return i(!0),s}function xQ(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,l=ow(e),u=o||s?[...l?uu(l):[],...uu(t)]:[];u.forEach(S=>{o&&S.addEventListener("scroll",n,{passive:!0}),s&&S.addEventListener("resize",n)});const d=l&&a?vQ(l,n):null;let p=-1,f=null;i&&(f=new ResizeObserver(S=>{let[v]=S;v&&v.target===l&&f&&(f.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var P;(P=f)==null||P.observe(t)})),n()}),l&&!c&&f.observe(l),f.observe(t));let y,g=c?Oi(e):null;c&&w();function w(){const S=Oi(e);g&&(S.x!==g.x||S.y!==g.y||S.width!==g.width||S.height!==g.height)&&n(),g=S,y=requestAnimationFrame(w)}return n(),()=>{var S;u.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),d==null||d(),(S=f)==null||S.disconnect(),f=null,c&&cancelAnimationFrame(y)}}const wQ=QZ,bQ=JZ,PQ=XZ,CQ=tQ,IQ=qZ,uI=YZ,EQ=eQ,_Q=(e,t,n)=>{const r=new Map,o={platform:SQ,...n},s={...o.platform,_c:r};return VZ(e,t,{...o,platform:s})};var Yh=typeof document<"u"?x.useLayoutEffect:x.useEffect;function cf(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!cf(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!cf(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function fA(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function dI(e,t){const n=fA(e);return Math.round(t*n)/n}function hI(e){const t=x.useRef(e);return Yh(()=>{t.current=e}),t}function kQ(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:c,open:l}=e,[u,d]=x.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,f]=x.useState(r);cf(p,r)||f(r);const[y,g]=x.useState(null),[w,S]=x.useState(null),v=x.useCallback(q=>{q!==E.current&&(E.current=q,g(q))},[]),P=x.useCallback(q=>{q!==_.current&&(_.current=q,S(q))},[]),I=s||y,C=i||w,E=x.useRef(null),_=x.useRef(null),k=x.useRef(u),$=c!=null,T=hI(c),A=hI(o),B=x.useCallback(()=>{if(!E.current||!_.current)return;const q={placement:t,strategy:n,middleware:p};A.current&&(q.platform=A.current),_Q(E.current,_.current,q).then(H=>{const U={...H,isPositioned:!0};L.current&&!cf(k.current,U)&&(k.current=U,Bi.flushSync(()=>{d(U)}))})},[p,t,n,A]);Yh(()=>{l===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,d(q=>({...q,isPositioned:!1})))},[l]);const L=x.useRef(!1);Yh(()=>(L.current=!0,()=>{L.current=!1}),[]),Yh(()=>{if(I&&(E.current=I),C&&(_.current=C),I&&C){if(T.current)return T.current(I,C,B);B()}},[I,C,B,T,$]);const R=x.useMemo(()=>({reference:E,floating:_,setReference:v,setFloating:P}),[v,P]),N=x.useMemo(()=>({reference:I,floating:C}),[I,C]),X=x.useMemo(()=>{const q={position:n,left:0,top:0};if(!N.floating)return q;const H=dI(N.floating,u.x),U=dI(N.floating,u.y);return a?{...q,transform:"translate("+H+"px, "+U+"px)",...fA(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:H,top:U}},[n,a,N.floating,u.x,u.y]);return x.useMemo(()=>({...u,update:B,refs:R,elements:N,floatingStyles:X}),[u,B,R,N,X])}const TQ=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?uI({element:r.current,padding:o}).fn(n):{}:r?uI({element:r,padding:o}).fn(n):{}}}},$Q=(e,t)=>({...wQ(e),options:[e,t]}),MQ=(e,t)=>({...bQ(e),options:[e,t]}),AQ=(e,t)=>({...EQ(e),options:[e,t]}),jQ=(e,t)=>({...PQ(e),options:[e,t]}),OQ=(e,t)=>({...CQ(e),options:[e,t]}),DQ=(e,t)=>({...IQ(e),options:[e,t]}),RQ=(e,t)=>({...TQ(e),options:[e,t]});function gA(e){const[t,n]=x.useState(void 0);return ji(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const c=s.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,a=l.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const mA="Popper",[yA,dg]=So(mA),[LQ,SA]=yA(mA),FQ=e=>{const{__scopePopper:t,children:n}=e,[r,o]=x.useState(null);return x.createElement(LQ,{scope:t,anchor:r,onAnchorChange:o},n)},NQ="PopperAnchor",zQ=x.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=SA(NQ,n),i=x.useRef(null),a=Ze(t,i);return x.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:x.createElement(Ve.div,Z({},o,{ref:a}))}),vA="PopperContent",[BQ,Foe]=yA(vA),UQ=x.forwardRef((e,t)=>{var n,r,o,s,i,a,c,l;const{__scopePopper:u,side:d="bottom",sideOffset:p=0,align:f="center",alignOffset:y=0,arrowPadding:g=0,avoidCollisions:w=!0,collisionBoundary:S=[],collisionPadding:v=0,sticky:P="partial",hideWhenDetached:I=!1,updatePositionStrategy:C="optimized",onPlaced:E,..._}=e,k=SA(vA,u),[$,T]=x.useState(null),A=Ze(t,Qe=>T(Qe)),[B,L]=x.useState(null),R=gA(B),N=(n=R==null?void 0:R.width)!==null&&n!==void 0?n:0,X=(r=R==null?void 0:R.height)!==null&&r!==void 0?r:0,q=d+(f!=="center"?"-"+f:""),H=typeof v=="number"?v:{top:0,right:0,bottom:0,left:0,...v},U=Array.isArray(S)?S:[S],W=U.length>0,Q={padding:H,boundary:U.filter(HQ),altBoundary:W},{refs:le,floatingStyles:be,placement:Ae,isPositioned:ae,middlewareData:je}=kQ({strategy:"fixed",placement:q,whileElementsMounted:(...Qe)=>xQ(...Qe,{animationFrame:C==="always"}),elements:{reference:k.anchor},middleware:[$Q({mainAxis:p+X,alignmentAxis:y}),w&&MQ({mainAxis:!0,crossAxis:!1,limiter:P==="partial"?AQ():void 0,...Q}),w&&jQ({...Q}),OQ({...Q,apply:({elements:Qe,rects:Lt,availableWidth:Po,availableHeight:kc})=>{const{width:Tc,height:Sg}=Lt.reference,Yi=Qe.floating.style;Yi.setProperty("--radix-popper-available-width",`${Po}px`),Yi.setProperty("--radix-popper-available-height",`${kc}px`),Yi.setProperty("--radix-popper-anchor-width",`${Tc}px`),Yi.setProperty("--radix-popper-anchor-height",`${Sg}px`)}}),B&&RQ({element:B,padding:g}),KQ({arrowWidth:N,arrowHeight:X}),I&&DQ({strategy:"referenceHidden",...Q})]}),[Fe,it]=xA(Ae),Ee=ln(E);ji(()=>{ae&&(Ee==null||Ee())},[ae,Ee]);const gt=(o=je.arrow)===null||o===void 0?void 0:o.x,We=(s=je.arrow)===null||s===void 0?void 0:s.y,ar=((i=je.arrow)===null||i===void 0?void 0:i.centerOffset)!==0,[Ln,Fn]=x.useState();return ji(()=>{$&&Fn(window.getComputedStyle($).zIndex)},[$]),x.createElement("div",{ref:le.setFloating,"data-radix-popper-content-wrapper":"",style:{...be,transform:ae?be.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ln,"--radix-popper-transform-origin":[(a=je.transformOrigin)===null||a===void 0?void 0:a.x,(c=je.transformOrigin)===null||c===void 0?void 0:c.y].join(" ")},dir:e.dir},x.createElement(BQ,{scope:u,placedSide:Fe,onArrowChange:L,arrowX:gt,arrowY:We,shouldHideArrow:ar},x.createElement(Ve.div,Z({"data-side":Fe,"data-align":it},_,{ref:A,style:{..._.style,animation:ae?void 0:"none",opacity:(l=je.hide)!==null&&l!==void 0&&l.referenceHidden?0:void 0}}))))});function HQ(e){return e!==null}const KQ=e=>({name:"transformOrigin",options:e,fn(t){var n,r,o,s,i;const{placement:a,rects:c,middlewareData:l}=t,d=((n=l.arrow)===null||n===void 0?void 0:n.centerOffset)!==0,p=d?0:e.arrowWidth,f=d?0:e.arrowHeight,[y,g]=xA(a),w={start:"0%",center:"50%",end:"100%"}[g],S=((r=(o=l.arrow)===null||o===void 0?void 0:o.x)!==null&&r!==void 0?r:0)+p/2,v=((s=(i=l.arrow)===null||i===void 0?void 0:i.y)!==null&&s!==void 0?s:0)+f/2;let P="",I="";return y==="bottom"?(P=d?w:`${S}px`,I=`${-f}px`):y==="top"?(P=d?w:`${S}px`,I=`${c.floating.height+f}px`):y==="right"?(P=`${-f}px`,I=d?w:`${v}px`):y==="left"&&(P=`${c.floating.width+f}px`,I=d?w:`${v}px`),{data:{x:P,y:I}}}});function xA(e){const[t,n="center"]=e.split("-");return[t,n]}const iw=FQ,wA=zQ,bA=UQ,PA="Popover",[CA,Noe]=So(PA,[dg]),aw=dg(),[WQ,_c]=CA(PA),GQ=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=e,a=aw(t),c=x.useRef(null),[l,u]=x.useState(!1),[d=!1,p]=Zs({prop:r,defaultProp:o,onChange:s});return x.createElement(iw,a,x.createElement(WQ,{scope:t,contentId:zo(),triggerRef:c,open:d,onOpenChange:p,onOpenToggle:x.useCallback(()=>p(f=>!f),[p]),hasCustomAnchor:l,onCustomAnchorAdd:x.useCallback(()=>u(!0),[]),onCustomAnchorRemove:x.useCallback(()=>u(!1),[]),modal:i},n))},VQ="PopoverTrigger",YQ=x.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=_c(VQ,n),s=aw(n),i=Ze(t,o.triggerRef),a=x.createElement(Ve.button,Z({type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":_A(o.open)},r,{ref:i,onClick:ie(e.onClick,o.onOpenToggle)}));return o.hasCustomAnchor?a:x.createElement(wA,Z({asChild:!0},s),a)}),IA="PopoverPortal",[XQ,qQ]=CA(IA,{forceMount:void 0}),ZQ=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,s=_c(IA,t);return x.createElement(XQ,{scope:t,forceMount:n},x.createElement(vo,{present:n||s.open},x.createElement(ng,{asChild:!0,container:o},r)))},du="PopoverContent",QQ=x.forwardRef((e,t)=>{const n=qQ(du,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,s=_c(du,e.__scopePopover);return x.createElement(vo,{present:r||s.open},s.modal?x.createElement(JQ,Z({},o,{ref:t})):x.createElement(eJ,Z({},o,{ref:t})))}),JQ=x.forwardRef((e,t)=>{const n=_c(du,e.__scopePopover),r=x.useRef(null),o=Ze(t,r),s=x.useRef(!1);return x.useEffect(()=>{const i=r.current;if(i)return Xx(i)},[]),x.createElement(ig,{as:Ai,allowPinchZoom:!0},x.createElement(EA,Z({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,i=>{var a;i.preventDefault(),s.current||(a=n.triggerRef.current)===null||a===void 0||a.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0,l=a.button===2||c;s.current=l},{checkForDefaultPrevented:!1}),onFocusOutside:ie(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})))}),eJ=x.forwardRef((e,t)=>{const n=_c(du,e.__scopePopover),r=x.useRef(!1),o=x.useRef(!1);return x.createElement(EA,Z({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i;if((i=e.onCloseAutoFocus)===null||i===void 0||i.call(e,s),!s.defaultPrevented){var a;r.current||(a=n.triggerRef.current)===null||a===void 0||a.focus(),s.preventDefault()}r.current=!1,o.current=!1},onInteractOutside:s=>{var i,a;(i=e.onInteractOutside)===null||i===void 0||i.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const c=s.target;((a=n.triggerRef.current)===null||a===void 0?void 0:a.contains(c))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}}))}),EA=x.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,p=_c(du,n),f=aw(n);return Yx(),x.createElement(Vx,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s},x.createElement(tg,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>p.onOpenChange(!1)},x.createElement(bA,Z({"data-state":_A(p.open),role:"dialog",id:p.contentId},f,d,{ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}))))});function _A(e){return e?"open":"closed"}const tJ=GQ,nJ=YQ,rJ=ZQ,oJ=QQ;function Qs(e,t){const n=z(),r=x.useRef(!1),o=xo(),s=x.useCallback(a=>{r.current=a,n.batch(()=>{a?(n.complete(),n.addOpenMenu(e)):n.updateInstanceState({openMenus:n.getOpenMenus().filter(c=>!c.startsWith(e))}),t==null||t(a)})},[n,e,t]),i=K("is menu open",()=>n.getOpenMenus().includes(e),[n,e]);return x.useEffect(()=>(r.current&&(o("open-menu",{source:"unknown",id:e}),n.addOpenMenu(e)),()=>{r.current&&(n.deleteOpenMenu(e),n.getOpenMenus().forEach(a=>{a.startsWith(e)&&(o("close-menu",{source:"unknown",id:e}),n.deleteOpenMenu(a))}),r.current=!1)}),[n,e,o]),[i,s]}function cw({id:e,children:t,onOpenChange:n,open:r}){const[o,s]=Qs(e,n);return h.jsx(tJ,{onOpenChange:s,open:r||o,children:h.jsx("div",{className:"tlui-popover",children:t})})}function lw({children:e}){return h.jsx(nJ,{asChild:!0,dir:"ltr",children:e})}function uw({side:e,children:t,align:n="center",sideOffset:r=8,alignOffset:o=0}){const s=Xt();return h.jsx(rJ,{container:s,children:h.jsx(oJ,{className:"tlui-popover__content",side:e,sideOffset:r,align:n,alignOffset:o,dir:"ltr",children:t})})}const kA=x.createContext({type:"menu",sourceId:"main-menu"});function hg(){return x.useContext(kA)}function br({type:e,sourceId:t,children:n}){return h.jsx(kA.Provider,{value:{type:e,sourceId:t},children:n})}const sJ=x.createContext(void 0);function dw(e){const t=x.useContext(sJ);return e||t||"ltr"}const ly="rovingFocusGroup.onEntryFocus",iJ={bubbles:!1,cancelable:!0},hw="RovingFocusGroup",[_v,TA,aJ]=eg(hw),[cJ,$A]=So(hw,[aJ]),[lJ,uJ]=cJ(hw),dJ=x.forwardRef((e,t)=>x.createElement(_v.Provider,{scope:e.__scopeRovingFocusGroup},x.createElement(_v.Slot,{scope:e.__scopeRovingFocusGroup},x.createElement(hJ,Z({},e,{ref:t}))))),hJ=x.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:l,...u}=e,d=x.useRef(null),p=Ze(t,d),f=dw(s),[y=null,g]=Zs({prop:i,defaultProp:a,onChange:c}),[w,S]=x.useState(!1),v=ln(l),P=TA(n),I=x.useRef(!1),[C,E]=x.useState(0);return x.useEffect(()=>{const _=d.current;if(_)return _.addEventListener(ly,v),()=>_.removeEventListener(ly,v)},[v]),x.createElement(lJ,{scope:n,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(Ve.div,Z({tabIndex:w||C===0?-1:0,"data-orientation":r},u,{ref:p,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{I.current=!0}),onFocus:ie(e.onFocus,_=>{const k=!I.current;if(_.target===_.currentTarget&&k&&!w){const $=new CustomEvent(ly,iJ);if(_.currentTarget.dispatchEvent($),!$.defaultPrevented){const T=P().filter(N=>N.focusable),A=T.find(N=>N.active),B=T.find(N=>N.id===y),R=[A,B,...T].filter(Boolean).map(N=>N.ref.current);MA(R)}}I.current=!1}),onBlur:ie(e.onBlur,()=>S(!1))})))}),pJ="RovingFocusGroupItem",fJ=x.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,...i}=e,a=zo(),c=s||a,l=uJ(pJ,n),u=l.currentTabStopId===c,d=TA(n),{onFocusableItemAdd:p,onFocusableItemRemove:f}=l;return x.useEffect(()=>{if(r)return p(),()=>f()},[r,p,f]),x.createElement(_v.ItemSlot,{scope:n,id:c,focusable:r,active:o},x.createElement(Ve.span,Z({tabIndex:u?0:-1,"data-orientation":l.orientation},i,{ref:t,onMouseDown:ie(e.onMouseDown,y=>{r?l.onItemFocus(c):y.preventDefault()}),onFocus:ie(e.onFocus,()=>l.onItemFocus(c)),onKeyDown:ie(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){l.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const g=yJ(y,l.orientation,l.dir);if(g!==void 0){y.preventDefault();let S=d().filter(v=>v.focusable).map(v=>v.ref.current);if(g==="last")S.reverse();else if(g==="prev"||g==="next"){g==="prev"&&S.reverse();const v=S.indexOf(y.currentTarget);S=l.loop?SJ(S,v+1):S.slice(v+1)}setTimeout(()=>MA(S))}})})))}),gJ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function mJ(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function yJ(e,t,n){const r=mJ(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return gJ[r]}function MA(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function SJ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const vJ=dJ,xJ=fJ,kv=["Enter"," "],wJ=["ArrowDown","PageUp","Home"],AA=["ArrowUp","PageDown","End"],bJ=[...wJ,...AA],PJ={ltr:[...kv,"ArrowRight"],rtl:[...kv,"ArrowLeft"]},CJ={ltr:["ArrowLeft"],rtl:["ArrowRight"]},pg="Menu",[hu,IJ,EJ]=eg(pg),[Vi,fg]=So(pg,[EJ,dg,$A]),gg=dg(),jA=$A(),[OA,Js]=Vi(pg),[_J,Ru]=Vi(pg),kJ=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=gg(t),[c,l]=x.useState(null),u=x.useRef(!1),d=ln(s),p=dw(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(iw,a,x.createElement(OA,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l},x.createElement(_J,{scope:t,onClose:x.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:p,modal:i},r)))},DA=x.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gg(n);return x.createElement(wA,Z({},o,r,{ref:t}))}),RA="MenuPortal",[TJ,LA]=Vi(RA,{forceMount:void 0}),$J=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Js(RA,t);return x.createElement(TJ,{scope:t,forceMount:n},x.createElement(vo,{present:n||s.open},x.createElement(ng,{asChild:!0,container:o},r)))},zr="MenuContent",[MJ,pw]=Vi(zr),AJ=x.forwardRef((e,t)=>{const n=LA(zr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Js(zr,e.__scopeMenu),i=Ru(zr,e.__scopeMenu);return x.createElement(hu.Provider,{scope:e.__scopeMenu},x.createElement(vo,{present:r||s.open},x.createElement(hu.Slot,{scope:e.__scopeMenu},i.modal?x.createElement(jJ,Z({},o,{ref:t})):x.createElement(OJ,Z({},o,{ref:t})))))}),jJ=x.forwardRef((e,t)=>{const n=Js(zr,e.__scopeMenu),r=x.useRef(null),o=Ze(t,r);return x.useEffect(()=>{const s=r.current;if(s)return Xx(s)},[]),x.createElement(fw,Z({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))}),OJ=x.forwardRef((e,t)=>{const n=Js(zr,e.__scopeMenu);return x.createElement(fw,Z({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))}),fw=x.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:p,onDismiss:f,disableOutsideScroll:y,...g}=e,w=Js(zr,n),S=Ru(zr,n),v=gg(n),P=jA(n),I=IJ(n),[C,E]=x.useState(null),_=x.useRef(null),k=Ze(t,_,w.onContentChange),$=x.useRef(0),T=x.useRef(""),A=x.useRef(0),B=x.useRef(null),L=x.useRef("right"),R=x.useRef(0),N=y?ig:x.Fragment,X=y?{as:Ai,allowPinchZoom:!0}:void 0,q=U=>{var W,Q;const le=T.current+U,be=I().filter(Ee=>!Ee.disabled),Ae=document.activeElement,ae=(W=be.find(Ee=>Ee.ref.current===Ae))===null||W===void 0?void 0:W.textValue,je=be.map(Ee=>Ee.textValue),Fe=YJ(je,le,ae),it=(Q=be.find(Ee=>Ee.textValue===Fe))===null||Q===void 0?void 0:Q.ref.current;(function Ee(gt){T.current=gt,window.clearTimeout($.current),gt!==""&&($.current=window.setTimeout(()=>Ee(""),1e3))})(le),it&&setTimeout(()=>it.focus())};x.useEffect(()=>()=>window.clearTimeout($.current),[]),Yx();const H=x.useCallback(U=>{var W,Q;return L.current===((W=B.current)===null||W===void 0?void 0:W.side)&&qJ(U,(Q=B.current)===null||Q===void 0?void 0:Q.area)},[]);return x.createElement(MJ,{scope:n,searchRef:T,onItemEnter:x.useCallback(U=>{H(U)&&U.preventDefault()},[H]),onItemLeave:x.useCallback(U=>{var W;H(U)||((W=_.current)===null||W===void 0||W.focus(),E(null))},[H]),onTriggerLeave:x.useCallback(U=>{H(U)&&U.preventDefault()},[H]),pointerGraceTimerRef:A,onPointerGraceIntentChange:x.useCallback(U=>{B.current=U},[])},x.createElement(N,X,x.createElement(Vx,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,U=>{var W;U.preventDefault(),(W=_.current)===null||W===void 0||W.focus()}),onUnmountAutoFocus:i},x.createElement(tg,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:p,onDismiss:f},x.createElement(vJ,Z({asChild:!0},P,{dir:S.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:E,onEntryFocus:ie(c,U=>{S.isUsingKeyboardRef.current||U.preventDefault()})}),x.createElement(bA,Z({role:"menu","aria-orientation":"vertical","data-state":UA(w.open),"data-radix-menu-content":"",dir:S.dir},v,g,{ref:k,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,U=>{const Q=U.target.closest("[data-radix-menu-content]")===U.currentTarget,le=U.ctrlKey||U.altKey||U.metaKey,be=U.key.length===1;Q&&(U.key==="Tab"&&U.preventDefault(),!le&&be&&q(U.key));const Ae=_.current;if(U.target!==Ae||!bJ.includes(U.key))return;U.preventDefault();const je=I().filter(Fe=>!Fe.disabled).map(Fe=>Fe.ref.current);AA.includes(U.key)&&je.reverse(),GJ(je)}),onBlur:ie(e.onBlur,U=>{U.currentTarget.contains(U.target)||(window.clearTimeout($.current),T.current="")}),onPointerMove:ie(e.onPointerMove,pu(U=>{const W=U.target,Q=R.current!==U.clientX;if(U.currentTarget.contains(W)&&Q){const le=U.clientX>R.current?"right":"left";L.current=le,R.current=U.clientX}}))})))))))}),DJ=x.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return x.createElement(Ve.div,Z({role:"group"},r,{ref:t}))}),Tv="MenuItem",pI="menu.itemSelect",FA=x.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=x.useRef(null),i=Ru(Tv,e.__scopeMenu),a=pw(Tv,e.__scopeMenu),c=Ze(t,s),l=x.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const p=new CustomEvent(pI,{bubbles:!0,cancelable:!0});d.addEventListener(pI,f=>r==null?void 0:r(f),{once:!0}),Wx(d,p),p.defaultPrevented?l.current=!1:i.onClose()}};return x.createElement(NA,Z({},o,{ref:c,disabled:n,onClick:ie(e.onClick,u),onPointerDown:d=>{var p;(p=e.onPointerDown)===null||p===void 0||p.call(e,d),l.current=!0},onPointerUp:ie(e.onPointerUp,d=>{var p;l.current||(p=d.currentTarget)===null||p===void 0||p.click()}),onKeyDown:ie(e.onKeyDown,d=>{const p=a.searchRef.current!=="";n||p&&d.key===" "||kv.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})}))}),NA=x.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=pw(Tv,n),a=jA(n),c=x.useRef(null),l=Ze(t,c),[u,d]=x.useState(!1),[p,f]=x.useState("");return x.useEffect(()=>{const y=c.current;if(y){var g;f(((g=y.textContent)!==null&&g!==void 0?g:"").trim())}},[s.children]),x.createElement(hu.ItemSlot,{scope:n,disabled:r,textValue:o??p},x.createElement(xJ,Z({asChild:!0},a,{focusable:!r}),x.createElement(Ve.div,Z({role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0},s,{ref:l,onPointerMove:ie(e.onPointerMove,pu(y=>{r?i.onItemLeave(y):(i.onItemEnter(y),y.defaultPrevented||y.currentTarget.focus())})),onPointerLeave:ie(e.onPointerLeave,pu(y=>i.onItemLeave(y))),onFocus:ie(e.onFocus,()=>d(!0)),onBlur:ie(e.onBlur,()=>d(!1))}))))}),RJ=x.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return x.createElement(NJ,{scope:e.__scopeMenu,checked:n},x.createElement(FA,Z({role:"menuitemcheckbox","aria-checked":$v(n)?"mixed":n},o,{ref:t,"data-state":WJ(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r($v(n)?!0:!n),{checkForDefaultPrevented:!1})})))}),LJ="MenuRadioGroup";Vi(LJ,{value:void 0,onValueChange:()=>{}});const FJ="MenuItemIndicator",[NJ,zoe]=Vi(FJ,{checked:!1}),zA="MenuSub",[zJ,BA]=Vi(zA),BJ=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:o}=e,s=Js(zA,t),i=gg(t),[a,c]=x.useState(null),[l,u]=x.useState(null),d=ln(o);return x.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),x.createElement(iw,i,x.createElement(OA,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u},x.createElement(zJ,{scope:t,contentId:zo(),triggerId:zo(),trigger:a,onTriggerChange:c},n)))},Wd="MenuSubTrigger",UJ=x.forwardRef((e,t)=>{const n=Js(Wd,e.__scopeMenu),r=Ru(Wd,e.__scopeMenu),o=BA(Wd,e.__scopeMenu),s=pw(Wd,e.__scopeMenu),i=x.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,l={__scopeMenu:e.__scopeMenu},u=x.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return x.useEffect(()=>u,[u]),x.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),c(null)}},[a,c]),x.createElement(DA,Z({asChild:!0},l),x.createElement(NA,Z({id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":UA(n.open)},e,{ref:Jf(t,o.onTriggerChange),onClick:d=>{var p;(p=e.onClick)===null||p===void 0||p.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ie(e.onPointerMove,pu(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:ie(e.onPointerLeave,pu(d=>{var p;u();const f=(p=n.content)===null||p===void 0?void 0:p.getBoundingClientRect();if(f){var y;const g=(y=n.content)===null||y===void 0?void 0:y.dataset.side,w=g==="right",S=w?-5:5,v=f[w?"left":"right"],P=f[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+S,y:d.clientY},{x:v,y:f.top},{x:P,y:f.top},{x:P,y:f.bottom},{x:v,y:f.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ie(e.onKeyDown,d=>{const p=s.searchRef.current!=="";if(!(e.disabled||p&&d.key===" ")&&PJ[r.dir].includes(d.key)){var f;n.onOpenChange(!0),(f=n.content)===null||f===void 0||f.focus(),d.preventDefault()}})})))}),HJ="MenuSubContent",KJ=x.forwardRef((e,t)=>{const n=LA(zr,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Js(zr,e.__scopeMenu),i=Ru(zr,e.__scopeMenu),a=BA(HJ,e.__scopeMenu),c=x.useRef(null),l=Ze(t,c);return x.createElement(hu.Provider,{scope:e.__scopeMenu},x.createElement(vo,{present:r||s.open},x.createElement(hu.Slot,{scope:e.__scopeMenu},x.createElement(fw,Z({id:a.contentId,"aria-labelledby":a.triggerId},o,{ref:l,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;i.isUsingKeyboardRef.current&&((d=c.current)===null||d===void 0||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ie(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ie(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:ie(e.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),p=CJ[i.dir].includes(u.key);if(d&&p){var f;s.onOpenChange(!1),(f=a.trigger)===null||f===void 0||f.focus(),u.preventDefault()}})})))))});function UA(e){return e?"open":"closed"}function $v(e){return e==="indeterminate"}function WJ(e){return $v(e)?"indeterminate":e?"checked":"unchecked"}function GJ(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function VJ(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function YJ(e,t,n){const o=t.length>1&&Array.from(t).every(l=>l===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=VJ(e,Math.max(s,0));o.length===1&&(i=i.filter(l=>l!==n));const c=i.find(l=>l.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function XJ(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s].x,c=t[s].y,l=t[i].x,u=t[i].y;c>r!=u>r&&n<(l-a)*(r-c)/(u-c)+a&&(o=!o)}return o}function qJ(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return XJ(n,t)}function pu(e){return t=>t.pointerType==="mouse"?e(t):void 0}const HA=kJ,KA=DA,WA=$J,GA=AJ,VA=DJ,YA=FA,XA=RJ,qA=BJ,ZA=UJ,QA=KJ,JA="ContextMenu",[ZJ,Boe]=So(JA,[fg]),wo=fg(),[QJ,ej]=ZJ(JA),JJ=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:o,modal:s=!0}=e,[i,a]=x.useState(!1),c=wo(t),l=ln(r),u=x.useCallback(d=>{a(d),l(d)},[l]);return x.createElement(QJ,{scope:t,open:i,onOpenChange:u,modal:s},x.createElement(HA,Z({},c,{dir:o,open:i,onOpenChange:u,modal:s}),n))},eee="ContextMenuTrigger",tee=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...o}=e,s=ej(eee,n),i=wo(n),a=x.useRef({x:0,y:0}),c=x.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),l=x.useRef(0),u=x.useCallback(()=>window.clearTimeout(l.current),[]),d=p=>{a.current={x:p.clientX,y:p.clientY},s.onOpenChange(!0)};return x.useEffect(()=>u,[u]),x.useEffect(()=>void(r&&u()),[r,u]),x.createElement(x.Fragment,null,x.createElement(KA,Z({},i,{virtualRef:c})),x.createElement(Ve.span,Z({"data-state":s.open?"open":"closed","data-disabled":r?"":void 0},o,{ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:ie(e.onContextMenu,p=>{u(),d(p),p.preventDefault()}),onPointerDown:r?e.onPointerDown:ie(e.onPointerDown,Gd(p=>{u(),l.current=window.setTimeout(()=>d(p),700)})),onPointerMove:r?e.onPointerMove:ie(e.onPointerMove,Gd(u)),onPointerCancel:r?e.onPointerCancel:ie(e.onPointerCancel,Gd(u)),onPointerUp:r?e.onPointerUp:ie(e.onPointerUp,Gd(u))})))}),tj=e=>{const{__scopeContextMenu:t,...n}=e,r=wo(t);return x.createElement(WA,Z({},r,n))},nee="ContextMenuContent",ree=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=ej(nee,n),s=wo(n),i=x.useRef(!1);return x.createElement(GA,Z({},s,r,{ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{var c;(c=e.onCloseAutoFocus)===null||c===void 0||c.call(e,a),!a.defaultPrevented&&i.current&&a.preventDefault(),i.current=!1},onInteractOutside:a=>{var c;(c=e.onInteractOutside)===null||c===void 0||c.call(e,a),!a.defaultPrevented&&!o.modal&&(i.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))}),oee=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=wo(n);return x.createElement(VA,Z({},o,r,{ref:t}))}),see=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=wo(n);return x.createElement(YA,Z({},o,r,{ref:t}))}),iee=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=wo(n);return x.createElement(XA,Z({},o,r,{ref:t}))}),aee=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,open:o,defaultOpen:s}=e,i=wo(t),[a,c]=Zs({prop:o,defaultProp:s,onChange:r});return x.createElement(qA,Z({},i,{open:a,onOpenChange:c}),n)},cee=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=wo(n);return x.createElement(ZA,Z({},o,r,{ref:t}))}),lee=x.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=wo(n);return x.createElement(QA,Z({},o,r,{ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))});function Gd(e){return t=>t.pointerType!=="mouse"?e(t):void 0}const uee=JJ,dee=tee,hee=tj,pee=ree,fee=iee,nj=typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("mac")>-1,gee=nj?"⌘":"Ctrl",mee=nj?"⌥":"Alt";function rj(e){return e.split(",")[0].split("").map(t=>{const n=t.replace(/\$/g,gee).replace(/\?/g,mee).replace(/!/g,"⇧");return n[0].toUpperCase()+n.slice(1)})}function Mv(e){return"— "+rj(e).join(" ")}function yee(e){return h.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",...e,children:h.jsxs("g",{strokeWidth:2,fill:"none",fillRule:"evenodd",children:[h.jsx("circle",{strokeOpacity:.25,cx:8,cy:8,r:7,stroke:"currentColor"}),h.jsx("path",{strokeLinecap:"round",d:"M15 8c0-4.5-4.5-7-7-7",stroke:"currentColor",children:h.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 8 8",to:"360 8 8",dur:"1s",repeatCount:"indefinite"})})]})})}const oj="DropdownMenu",[See,Uoe]=So(oj,[fg]),bo=fg(),[vee,sj]=See(oj),xee=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=bo(t),l=x.useRef(null),[u=!1,d]=Zs({prop:o,defaultProp:s,onChange:i});return x.createElement(vee,{scope:t,triggerId:zo(),triggerRef:l,contentId:zo(),open:u,onOpenChange:d,onOpenToggle:x.useCallback(()=>d(p=>!p),[d]),modal:a},x.createElement(HA,Z({},c,{open:u,onOpenChange:d,dir:r,modal:a}),n))},wee="DropdownMenuTrigger",bee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=sj(wee,n),i=bo(n);return x.createElement(KA,Z({asChild:!0},i),x.createElement(Ve.button,Z({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:Jf(t,s.triggerRef),onPointerDown:ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})))}),Pee=e=>{const{__scopeDropdownMenu:t,...n}=e,r=bo(t);return x.createElement(WA,Z({},r,n))},Cee="DropdownMenuContent",Iee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=sj(Cee,n),s=bo(n),i=x.useRef(!1);return x.createElement(GA,Z({id:o.contentId,"aria-labelledby":o.triggerId},s,r,{ref:t,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)===null||c===void 0||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ie(e.onInteractOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0,u=c.button===2||l;(!o.modal||u)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))}),Eee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bo(n);return x.createElement(VA,Z({},o,r,{ref:t}))}),_ee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bo(n);return x.createElement(YA,Z({},o,r,{ref:t}))}),kee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bo(n);return x.createElement(XA,Z({},o,r,{ref:t}))}),Tee=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:o,defaultOpen:s}=e,i=bo(t),[a=!1,c]=Zs({prop:r,defaultProp:s,onChange:o});return x.createElement(qA,Z({},i,{open:a,onOpenChange:c}),n)},$ee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bo(n);return x.createElement(ZA,Z({},o,r,{ref:t}))}),Mee=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bo(n);return x.createElement(QA,Z({},o,r,{ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))}),gw=xee,mw=bee,mg=Pee,yw=Iee,Aee=Eee,jee=_ee,Oee=kee,Dee=Tee,Ree=$ee,Lee=Mee;function Di({id:e,children:t,modal:n=!1,debugOpen:r=!1}){const[o,s]=Qs(e);return h.jsx(gw,{open:r||o,dir:"ltr",modal:n,onOpenChange:s,children:t})}function Ri({children:e,...t}){return h.jsx(mw,{dir:"ltr",asChild:!0,onTouchEnd:n=>ke(n),...t,children:e})}function Li({side:e="bottom",align:t="start",sideOffset:n=8,alignOffset:r=8,children:o}){const s=Xt();return h.jsx(mg,{container:s,children:h.jsx(yw,{className:"tlui-menu",side:e,sideOffset:n,align:t,alignOffset:r,collisionPadding:4,children:o})})}function Fee({id:e,children:t}){const[n,r]=Qs(e);return h.jsx(Dee,{open:n,onOpenChange:r,children:t})}function Nee({id:e,label:t,title:n,disabled:r}){return h.jsx(Ree,{dir:"ltr",asChild:!0,disabled:r,children:h.jsxs(pe,{"data-testid":e,type:"menu",className:"tlui-menu__submenu__trigger",disabled:r,title:n,children:[h.jsx(bt,{children:t}),h.jsx(Ce,{icon:"chevron-right",small:!0})]})})}function zee({id:e,alignOffset:t=-1,sideOffset:n=-4,size:r="small",children:o}){const s=Xt();return h.jsx(mg,{container:s,children:h.jsx(Lee,{"data-testid":e,className:"tlui-menu tlui-menu__submenu__content",alignOffset:t,sideOffset:n,collisionPadding:4,"data-size":r,children:o})})}function Bee({children:e}){return h.jsx(Aee,{dir:"ltr",className:"tlui-menu__group",children:e})}function fu({noClose:e,children:t}){return h.jsx(jee,{dir:"ltr",asChild:!0,onClick:e?ke:void 0,children:t})}function $l({children:e,visibleOnMobileLayout:t=!1}){const n=Rn();return!t&&n<vt.MOBILE?null:h.jsx("kbd",{className:"tlui-kbd",children:rj(e).map((r,o)=>h.jsx("span",{children:r},o))})}function F({disabled:e=!1,spinner:t=!1,readonlyOk:n=!1,id:r,kbd:o,label:s,icon:i,onSelect:a,noClose:c,isSelected:l}){const{type:u,sourceId:d}=hg(),p=Me(),[f,y]=x.useState(!1);if(rs()&&!n)return null;const w=cu(s,u),S=o?Mv(o):void 0,v=w?p(w):void 0,P=v&&S?`${v} ${S}`:v;switch(u){case"menu":return h.jsx(fu,{children:h.jsxs(pe,{type:"menu","data-testid":`${d}.${r}`,disabled:e,title:P,onClick:I=>{c&&ke(I),f?y(!1):a(d)},children:[h.jsx(bt,{children:v}),o&&h.jsx($l,{children:o})]})});case"context-menu":return e?null:h.jsxs(see,{dir:"ltr",title:P,draggable:!1,className:"tlui-button tlui-button__menu","data-testid":`${d}.${r}`,onSelect:I=>{c&&ke(I),f?y(!1):a(d)},children:[h.jsx("span",{className:"tlui-button__label",draggable:!1,children:v}),o&&h.jsx($l,{children:o}),t&&h.jsx(yee,{})]});case"panel":return h.jsxs(pe,{"data-testid":`${d}.${r}`,type:"menu",title:P,disabled:e,onClick:()=>a(d),children:[h.jsx(bt,{children:v}),i&&h.jsx(Ce,{icon:i})]});case"small-icons":case"icons":return h.jsx(pe,{"data-testid":`${d}.${r}`,type:"icon",title:P,disabled:e,onClick:()=>a(d),children:h.jsx(Ce,{icon:i,small:u==="small-icons"})});case"keyboard-shortcuts":return o?h.jsxs("div",{className:"tlui-shortcuts-dialog__key-pair","data-testid":`${d}.${r}`,children:[h.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__key",children:v}),h.jsx("div",{className:"tlui-shortcuts-dialog__key-pair__value",children:h.jsx($l,{visibleOnMobileLayout:!0,children:o})})]}):(console.warn(`Menu item '${s}' isn't shown in the keyboard shortcuts dialog because it doesn't have a keyboard shortcut.`),null);case"helper-buttons":return h.jsxs(pe,{type:"low",onClick:()=>a(d),children:[h.jsx(Ce,{icon:i}),h.jsx(bt,{children:v})]});case"toolbar":return h.jsx(pe,{type:"tool","data-testid":`tools.${r}`,"aria-label":w,"data-value":r,onClick:()=>a("toolbar"),title:P,onTouchStart:I=>{ke(I),a("toolbar")},role:"radio","aria-checked":l?"true":"false",children:h.jsx(Ce,{icon:i})});case"toolbar-overflow":return h.jsx(fu,{"aria-label":s,children:h.jsx(pe,{type:"icon",className:"tlui-button-grid__button",onClick:()=>{a("toolbar")},"data-testid":`tools.more.${r}`,title:P,role:"radio","aria-checked":l?"true":"false","data-value":r,children:h.jsx(Ce,{icon:i})})});default:throw fn(u)}}function Uee(){return h.jsxs(h.Fragment,{children:[h.jsx(Hee,{}),h.jsx(Kee,{}),h.jsx(Wee,{}),h.jsx(Gee,{}),h.jsx(Vee,{}),h.jsx(qee,{}),h.jsx(Zee,{}),h.jsx(Qee,{})]})}function Hee(){const e=ce(),t=bn(2);return h.jsxs(h.Fragment,{children:[h.jsx(F,{...e["align-left"],disabled:!t}),h.jsx(F,{...e["align-center-horizontal"],disabled:!t}),h.jsx(F,{...e["align-right"],disabled:!t}),h.jsx(F,{...e["stretch-horizontal"],disabled:!t}),h.jsx(F,{...e["align-top"],disabled:!t}),h.jsx(F,{...e["align-center-vertical"],disabled:!t}),h.jsx(F,{...e["align-bottom"],disabled:!t}),h.jsx(F,{...e["stretch-vertical"],disabled:!t})]})}function Kee(){const e=ce(),t=bn(3);return h.jsxs(h.Fragment,{children:[h.jsx(F,{...e["distribute-horizontal"],disabled:!t}),h.jsx(F,{...e["distribute-vertical"],disabled:!t})]})}function Wee(){const e=ce(),t=J2();return h.jsxs(h.Fragment,{children:[h.jsx(F,{...e["stack-horizontal"],disabled:!t}),h.jsx(F,{...e["stack-vertical"],disabled:!t})]})}function Gee(){const e=ce(),t=bn(1);return h.jsxs(h.Fragment,{children:[h.jsx(F,{...e["send-to-back"],disabled:!t}),h.jsx(F,{...e["send-backward"],disabled:!t}),h.jsx(F,{...e["bring-forward"],disabled:!t}),h.jsx(F,{...e["bring-to-front"],disabled:!t})]})}function Vee(){return Rn()<vt.TABLET_SM?h.jsx(Yee,{}):h.jsx(Xee,{})}function Yee(){const e=ce(),t=z(),n=K("zoom is 1",()=>t.getZoomLevel()===1,[t]);return h.jsx(F,{...e["zoom-to-100"],disabled:n})}function Xee(){const e=ce(),t=bn(1);return h.jsx(F,{...e["rotate-ccw"],disabled:!t})}function qee(){const e=ce(),t=bn(1);return h.jsx(F,{...e["rotate-cw"],disabled:!t})}function Zee(){const e=ce(),t=n$();return h.jsx(F,{...e["edit-link"],disabled:!t})}function Qee(){const e=e$(),t=t$();return e?h.jsx(fI,{}):t?h.jsx(Jee,{}):h.jsx(fI,{})}function fI(){const e=ce(),t=bn(2);return h.jsx(F,{...e.group,disabled:!t})}function Jee(){const e=ce();return h.jsx(F,{...e.ungroup})}const ete=x.memo(function({children:t}){const n=Me(),r=Rn(),o=rs(),s=z(),i=K("should display quick actions when in readonly",()=>s.isInAny("hand","zoom"),[s]),a=t??h.jsx(Uee,{});if(!(o&&!i))return h.jsxs(cw,{id:"actions-menu",children:[h.jsx(lw,{children:h.jsx(pe,{type:"icon","data-testid":"actions-menu.button",title:n("actions-menu.title"),children:h.jsx(Ce,{icon:"dots-vertical",small:!0})})}),h.jsx(uw,{side:r>=vt.TABLET?"bottom":"top",sideOffset:6,children:h.jsx("div",{className:"tlui-actions-menu tlui-buttons__grid","data-testid":"actions-menu.content",children:h.jsx(br,{type:"icons",sourceId:"actions-menu",children:a})})})]})});function Cr({id:e,kbd:t,label:n,readonlyOk:r,onSelect:o,toggle:s=!1,disabled:i=!1,checked:a=!1}){const{type:c,sourceId:l}=hg(),u=rs(),d=Me();if(u&&!r)return null;const p=cu(n,c),f=p?d(p):void 0;switch(c){case"menu":return h.jsxs(Oee,{dir:"ltr",className:"tlui-button tlui-button__menu tlui-button__checkbox",title:f,onSelect:y=>{o==null||o(l),ke(y)},disabled:i,checked:a,children:[h.jsx(Us,{small:!0,icon:s?a?"toggle-on":"toggle-off":a?"check":"none"}),f&&h.jsx("span",{className:"tlui-button__label",draggable:!1,children:f}),t&&h.jsx($l,{children:t})]});case"context-menu":return h.jsxs(fee,{className:"tlui-button tlui-button__menu tlui-button__checkbox",dir:"ltr",title:f,onSelect:y=>{o(l),ke(y)},disabled:i,checked:a,children:[h.jsx(Us,{small:!0,icon:s?a?"toggle-on":"toggle-off":a?"check":"none"}),f&&h.jsx("span",{className:"tlui-button__label",draggable:!1,children:f}),t&&h.jsx($l,{children:t})]},e);default:return null}}function ye({id:e,label:t,children:n}){const{type:r,sourceId:o}=hg(),s=Me(),i=cu(t,r),a=i?s(i):void 0;switch(r){case"panel":return h.jsx("div",{className:"tlui-menu__group","data-testid":`${o}-group.${e}`,children:n});case"menu":return h.jsx(Bee,{"data-testid":`${o}-group.${e}`,children:n});case"context-menu":return h.jsx(oee,{dir:"ltr",className:"tlui-menu__group","data-testid":`${o}-group.${e}`,children:n});case"keyboard-shortcuts":return h.jsxs("div",{className:"tlui-shortcuts-dialog__group","data-testid":`${o}-group.${e}`,children:[h.jsx("h2",{className:"tlui-shortcuts-dialog__group__title",children:a}),h.jsx("div",{className:"tlui-shortcuts-dialog__group__content",children:n})]});default:return n}}function Ir({id:e,disabled:t=!1,label:n,size:r="small",children:o}){const{type:s,sourceId:i}=hg(),a=Xt(),c=Me(),l=n?typeof n=="string"?n:n[s]??n.default:void 0,u=l?c(l):void 0;switch(s){case"menu":return h.jsxs(Fee,{id:`${i}-sub.${e}`,children:[h.jsx(Nee,{id:`${i}-sub.${u?u.toLowerCase()+"-button":""}`,disabled:t,label:u,title:u}),h.jsx(zee,{id:`${i}-sub.${u?u.toLowerCase()+"-content":""}`,size:r,children:o})]});case"context-menu":return t?null:h.jsxs(tte,{id:`${i}-sub.${e}`,children:[h.jsx(cee,{dir:"ltr",disabled:t,asChild:!0,children:h.jsxs(pe,{"data-testid":`${i}-sub-trigger.${e}`,type:"menu",className:"tlui-menu__submenu__trigger",children:[h.jsx(bt,{children:u}),h.jsx(Ce,{icon:"chevron-right",small:!0})]})}),h.jsx(tj,{container:a,children:h.jsx(lee,{"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 tte({id:e,children:t}){const[n,r]=Qs(e);return h.jsx(aee,{open:n,onOpenChange:r,children:t})}function ij(){const e=ce();return AW()?h.jsx(F,{...e["toggle-auto-size"]}):null}function aj(){const e=ce();return n$()?h.jsx(F,{...e["edit-link"]}):null}function nte(){const e=ce();return bn(1)?h.jsx(F,{...e.duplicate}):null}function cj(){const e=ce();return e$()?h.jsx(F,{...e.group}):null}function lj(){const e=ce();return t$()?h.jsx(F,{...e.ungroup}):null}function uj(){const e=z(),t=ce();return K("allow unframe",()=>{const r=e.getSelectedShapes();return r.length===0?!1:r.every(o=>e.isShapeOfType(o,"frame"))},[e])?h.jsx(F,{...t["remove-frame"]}):null}function dj(){const e=z(),t=ce();return K("allow fit frame to content",()=>{const r=e.getOnlySelectedShape();return r?e.isShapeOfType(r,"frame")&&e.getSortedChildIdsForParent(r).length>0:!1},[e])?h.jsx(F,{...t["fit-frame-to-content"]}):null}function hj(){const e=z(),t=ce();return K("selected shapes",()=>e.getSelectedShapes().length>0,[e])?h.jsx(F,{...t["toggle-lock"]}):null}function Sw(){const e=ce(),t=z(),n=K("isTransparentBg",()=>!t.getInstanceState().exportBackground,[t]);return h.jsx(Cr,{...e["toggle-transparent"],checked:n,toggle:!0})}function rte(){const e=z(),t=ce(),n=K("any shapes",()=>e.getCurrentPageShapeIds().size>0,[e]);return h.jsx(F,{...t["unlock-all"],disabled:!n})}function pj(){const e=z(),t=K("zoomed to 100",()=>e.getZoomLevel()===1,[e]),n=ce();return h.jsx(F,{...n["zoom-to-100"],noClose:!0,disabled:t})}function fj(){const e=z(),t=K("has shapes",()=>e.getCurrentPageShapeIds().size>0,[e]),n=ce();return h.jsx(F,{...n["zoom-to-fit"],disabled:!t,"data-testid":"minimap.zoom-menu.zoom-to-fit",noClose:!0})}function gj(){const e=z(),t=K("has shapes",()=>e.getSelectedShapeIds().length>0,[e]),n=ce();return h.jsx(F,{...n["zoom-to-selection"],disabled:!t,"data-testid":"minimap.zoom-menu.zoom-to-selection",noClose:!0})}function mj(){return h.jsxs(ye,{id:"clipboard",children:[h.jsx(ste,{}),h.jsx(ite,{}),h.jsx(ate,{}),h.jsx(nte,{}),h.jsx(cte,{})]})}function ote(){var r;const e=z(),t=ce(),n=K("atLeastOneShapeOnPage",()=>e.getCurrentPageShapeIds().size>0,[e]);return h.jsxs(Ir,{id:"copy-as",label:"context-menu.copy-as",size:"small",disabled:!n,children:[h.jsxs(ye,{id:"copy-as-group",children:[h.jsx(F,{...t["copy-as-svg"]}),!!((r=window.navigator.clipboard)!=null&&r.write)&&h.jsx(F,{...t["copy-as-png"]}),h.jsx(F,{...t["copy-as-json"]})]}),h.jsx(ye,{id:"copy-as-bg",children:h.jsx(Sw,{})})]})}function ste(){const e=ce(),t=bn(1);return h.jsx(F,{...e.cut,disabled:!t})}function ite(){const e=ce(),t=MW(1);return h.jsx(F,{...e.copy,disabled:!t})}function ate(){const e=ce(),t=$W;return h.jsx(F,{...e.paste,disabled:!t})}function yj(){const e=z(),t=ce();return K("atLeastOneShapeOnPage",()=>e.getCurrentPageShapeIds().size>0,[e])?h.jsxs(ye,{id:"conversions",children:[h.jsx(ote,{}),h.jsxs(Ir,{id:"export-as",label:"context-menu.export-as",size:"small",children:[h.jsxs(ye,{id:"export-as-group",children:[h.jsx(F,{...t["export-as-svg"]}),h.jsx(F,{...t["export-as-png"]}),h.jsx(F,{...t["export-as-json"]})]}),h.jsx(ye,{id:"export-as-bg",children:h.jsx(Sw,{})})]})]}):null}function Sj(){const e=ce(),t=z(),n=K("atLeastOneShapeOnPage",()=>t.getCurrentPageShapeIds().size>0,[t]);return h.jsx(F,{...e["select-all"],disabled:!n})}function cte(){const e=ce(),t=bn(1);return h.jsx(F,{...e.delete,disabled:!t})}function lte(){const e=bn(2),t=jW(),n=ce();return e||t?h.jsxs(Ir,{id:"arrange",label:"context-menu.arrange",size:"small",children:[e&&h.jsxs(ye,{id:"align",children:[h.jsx(F,{...n["align-left"]}),h.jsx(F,{...n["align-center-horizontal"]}),h.jsx(F,{...n["align-right"]}),h.jsx(F,{...n["align-top"]}),h.jsx(F,{...n["align-center-vertical"]}),h.jsx(F,{...n["align-bottom"]})]}),h.jsx(ute,{}),e&&h.jsxs(ye,{id:"stretch",children:[h.jsx(F,{...n["stretch-horizontal"]}),h.jsx(F,{...n["stretch-vertical"]})]}),(e||t)&&h.jsxs(ye,{id:"flip",children:[h.jsx(F,{...n["flip-horizontal"]}),h.jsx(F,{...n["flip-vertical"]})]}),h.jsx(dte,{})]}):null}function ute(){const e=ce();return bn(3)?h.jsxs(ye,{id:"distribute",children:[h.jsx(F,{...e["distribute-horizontal"]}),h.jsx(F,{...e["distribute-vertical"]})]}):null}function dte(){const e=ce(),t=bn(2),n=J2();return t?h.jsxs(ye,{id:"order",children:[h.jsx(F,{...e.pack}),n&&h.jsx(F,{...e["stack-horizontal"]}),n&&h.jsx(F,{...e["stack-vertical"]})]}):null}function hte(){const e=ce();return bn(1)?h.jsx(Ir,{id:"reorder",label:"context-menu.reorder",size:"small",children:h.jsxs(ye,{id:"reorder",children:[h.jsx(F,{...e["bring-to-front"]}),h.jsx(F,{...e["bring-forward"]}),h.jsx(F,{...e["send-backward"]}),h.jsx(F,{...e["send-to-back"]})]})}):null}function pte(){const e=z(),t=K("pages",()=>e.getPages(),[e]),n=K("current page id",()=>e.getCurrentPageId(),[e]),{addToast:r}=Wr(),o=ce(),s=xo();return bn(1)?h.jsxs(Ir,{id:"move-to-page",label:"context-menu.move-to-page",size:"small",children:[h.jsx(ye,{id:"pages",children:t.map(a=>h.jsx(F,{id:a.id,disabled:n===a.id,label:a.name,onSelect:()=>{e.mark("move_shapes_to_page"),e.moveShapesToPage(e.getSelectedShapeIds(),a.id);const c=e.getPage(a.id);c&&r({title:"Changed Page",description:`Moved to ${c.name}.`,actions:[{label:"Go Back",type:"primary",onClick:()=>{e.mark("change-page"),e.setCurrentPage(n)}}]}),s("move-to-page",{source:"context-menu"})}},a.id))}),h.jsx(ye,{id:"new-page",children:h.jsx(F,{...o["new-page"]})})]}):null}function vj(){const e=z(),t=ce();return K("oneEmbedSelected",()=>{const r=e.getOnlySelectedShape();return r?!!(e.isShapeOfType(r,"embed")&&r.props.url&&!e.isShapeOrAncestorLocked(r)):!1},[e])?h.jsx(F,{...t["convert-to-bookmark"]}):null}function xj(){const e=z(),t=ce();return K("oneEmbeddableBookmarkSelected",()=>{const r=e.getOnlySelectedShape();return r?!!(e.isShapeOfType(r,"bookmark")&&r.props.url&&Es(r.props.url)&&!e.isShapeOrAncestorLocked(r)):!1},[e])?h.jsx(F,{...t["convert-to-embed"]}):null}function fte(){const e=ce(),t=z(),n=K("isSnapMode",()=>t.user.getIsSnapMode(),[t]);return h.jsx(Cr,{...e["toggle-snap-mode"],checked:n})}function gte(){const e=ce(),t=z(),n=K("isToolLock",()=>t.getInstanceState().isToolLocked,[t]);return h.jsx(Cr,{...e["toggle-tool-lock"],checked:n})}function mte(){const e=ce(),t=z(),n=K("isGridMode",()=>t.getInstanceState().isGridMode,[t]);return h.jsx(Cr,{...e["toggle-grid"],checked:n})}function yte(){const e=ce(),t=z(),n=K("isWrapMode",()=>t.user.getIsWrapMode(),[t]);return h.jsx(Cr,{...e["toggle-wrap-mode"],checked:n})}function Ste(){const e=ce(),t=z(),n=K("isDarkMode",()=>t.user.getIsDarkMode(),[t]);return h.jsx(Cr,{...e["toggle-dark-mode"],checked:n})}function vte(){const e=ce(),t=z(),n=K("isFocusMode",()=>t.getInstanceState().isFocusMode,[t]);return h.jsx(Cr,{...e["toggle-focus-mode"],checked:n})}function xte(){const e=ce(),t=z(),n=K("edgeScrollSpeed",()=>t.user.getEdgeScrollSpeed(),[t]);return h.jsx(Cr,{...e["toggle-edge-scrolling"],checked:n===1})}function wte(){const e=ce(),t=z(),n=K("animationSpeed",()=>t.user.getAnimationSpeed(),[t]);return h.jsx(Cr,{...e["toggle-reduce-motion"],checked:n===0})}function bte(){const e=ce(),t=z(),n=K("isDebugMode",()=>t.getInstanceState().isDebugMode,[t]);return h.jsx(Cr,{...e["toggle-debug-mode"],checked:n})}function Pte(){const e=z();return K("isSelectToolActive",()=>e.getCurrentToolId()==="select",[e])?h.jsxs(h.Fragment,{children:[h.jsxs(ye,{id:"misc",children:[h.jsx(cj,{}),h.jsx(lj,{}),h.jsx(aj,{}),h.jsx(ij,{}),h.jsx(uj,{}),h.jsx(dj,{}),h.jsx(xj,{}),h.jsx(vj,{}),h.jsx(hj,{})]}),h.jsxs(ye,{id:"modify",children:[h.jsx(lte,{}),h.jsx(hte,{}),h.jsx(pte,{})]}),h.jsx(mj,{}),h.jsx(yj,{}),h.jsx(ye,{id:"select-all",children:h.jsx(Sj,{})})]}):null}const Cte=x.memo(function({children:t}){const n=z(),{Canvas:r}=pt(),o=x.useCallback(l=>{if(l){if(n.getInstanceState().isCoarsePointer){const u=n.getSelectedShapes(),{inputs:{currentPagePoint:d}}=n,p=n.getShapesAtPoint(d);if(!n.getSelectedShapes().length||!p.some(f=>u.includes(f))){const f=p.filter(y=>n.isShapeOrAncestorLocked(y));f.length&&n.select(...f.map(y=>y.id))}}}else{const u=n.getOnlySelectedShape();u&&n.isShapeOrAncestorLocked(u)&&n.setSelectedShapes([])}},[n]),s=Xt(),[i,a]=Qs("context menu",o),c=t??h.jsx(Pte,{});return h.jsxs(uee,{dir:"ltr",onOpenChange:a,modal:!1,children:[h.jsx(dee,{onContextMenu:void 0,dir:"ltr",children:r?h.jsx(r,{}):null}),i&&h.jsx(hee,{container:s,children:h.jsx(pee,{className:"tlui-menu scrollable","data-testid":"context-menu",alignOffset:-4,collisionPadding:4,onContextMenu:ke,children:h.jsx(br,{type:"context-menu",sourceId:"context-menu",children:c})})})]})});function Av({checked:e}){return h.jsx(Us,{icon:e?"check":"none",className:"tlui-button__icon",small:!0})}function Ite(){const e=z(),{addToast:t}=Wr(),{addDialog:n}=Gi(),[r,o]=Se.useState(!1);return h.jsxs(h.Fragment,{children:[h.jsxs(ye,{id:"items",children:[h.jsx(F,{id:"add-toast",onSelect:()=>{t({id:rt(),title:"Something good happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"success"}),t({id:rt(),title:"Something happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"info",actions:[{label:"Primary",type:"primary",onClick:()=>{}},{label:"Normal",type:"normal",onClick:()=>{}},{label:"Danger",type:"danger",onClick:()=>{}}]}),t({id:rt(),title:"Something maybe bad happened",description:"Hey, attend to this thing over here. It might be important!",keepOpen:!0,severity:"warning",actions:[{label:"Primary",type:"primary",onClick:()=>{}},{label:"Normal",type:"normal",onClick:()=>{}},{label:"Danger",type:"danger",onClick:()=>{}}]}),t({id:rt(),title:"Something bad happened",severity:"error",keepOpen:!0})},label:"Show toast"}),h.jsx(F,{id:"show-dialog",label:"Show dialog",onSelect:()=>{n({component:({onClose:s})=>h.jsx(kte,{displayDontShowAgain:!0,onCancel:()=>s(),onContinue:()=>s()}),onClose:()=>{}})}}),h.jsx(F,{id:"create-shapes",label:"Create 100 shapes",onSelect:()=>Tte(e,100)}),h.jsx(F,{id:"count-nodes",label:"Count shapes / nodes",onSelect:()=>{var a;const s=e.getSelectedShapes(),i=s.length===0?e.getRenderingShapes():s;window.alert(`Shapes ${i.length}, DOM nodes:${(a=document.querySelector(".tl-shapes").querySelectorAll("*"))==null?void 0:a.length}`)}}),(()=>{if(r)throw Error("oh no!");return null})(),h.jsx(F,{id:"throw-error",onSelect:()=>o(!0),label:"Throw error"}),h.jsx(F,{id:"hard-reset",onSelect:P_,label:"Hard reset"})]}),h.jsxs(ye,{id:"flags",children:[h.jsx(Ete,{}),h.jsx(_te,{})]})]})}function Ete(){const e=Object.values(jt);return e.length?h.jsx(Ir,{id:"debug flags",label:"Debug Flags",children:h.jsx(ye,{id:"debug flags",children:e.map(t=>h.jsx(wj,{flag:t},t.name))})}):null}function _te(){const e=Object.values(W3);return e.length?h.jsx(Ir,{id:"feature flags",label:"Feature Flags",children:h.jsx(ye,{id:"feature flags",children:e.map(t=>h.jsx(wj,{flag:t},t.name))})}):null}function kte({title:e="title",body:t="hello hello hello",cancel:n="Cancel",confirm:r="Continue",displayDontShowAgain:o=!1,onCancel:s,onContinue:i}){const[a,c]=Se.useState(!1);return h.jsxs(h.Fragment,{children:[h.jsxs(ag,{children:[h.jsx(cg,{children:e}),h.jsx(lg,{})]}),h.jsx(au,{style:{maxWidth:350},children:t}),h.jsxs(qx,{className:"tlui-dialog__footer__actions",children:[o&&h.jsxs(pe,{type:"normal",onClick:()=>c(!a),style:{marginRight:"auto"},children:[h.jsx(Av,{checked:a}),h.jsx(bt,{children:"Don't show again"})]}),h.jsx(pe,{type:"normal",onClick:s,children:h.jsx(bt,{children:n})}),h.jsx(pe,{type:"primary",onClick:async()=>i(),children:h.jsx(bt,{children:r})})]})]})}const wj=rr(function({flag:t,onChange:n}){const r=t.get();return h.jsx(Cr,{id:t.name,title:t.name,label:t.name.replace(/([a-z0-9])([A-Z])/g,o=>`${o[0]} ${o[1].toLowerCase()}`).replace(/^[a-z]/,o=>o.toUpperCase()),checked:r,onSelect:()=>{t.set(!r),n==null||n(!r)}})});let gI=0;function Tte(e,t){const n=Array(t),r=Math.floor(Math.sqrt(t));for(let o=0;o<t;o++)gI++,n[o]={id:He("box"+gI),type:"geo",x:o%r*132,y:Math.floor(o/r)*132};e.batch(()=>{e.createShapes(n).setSelectedShapes(n.map(o=>o.id))})}function $te({children:e}){const t=e??h.jsx(Ite,{});return h.jsxs(Di,{id:"debug",children:[h.jsx(Ri,{children:h.jsx(pe,{type:"icon",title:"Debug menu",children:h.jsx(Ce,{icon:"dots-horizontal"})})}),h.jsx(Li,{side:"top",align:"end",alignOffset:0,children:h.jsx(br,{type:"menu",sourceId:"debug-panel",children:t})})]})}const Mte=x.memo(function(){const{DebugMenu:t}=ti();return h.jsxs("div",{className:"tlui-debug-panel",children:[h.jsx(jte,{}),h.jsx(Ote,{}),t&&h.jsx(t,{})]})});function Ate(e=!0){const[t,n]=x.useState(0),r=z();x.useEffect(()=>{if(!e)return;const o=()=>n(s=>s+1);return r.on("tick",o),()=>{r.off("tick",o)}},[r,e])}const jte=rr(function(){Ate();const t=z(),n=t.getPath(),r=t.getHoveredShape(),o=t.getOnlySelectedShape(),s=n==="select.idle"||!n.includes("select.")?r:o,i=s&&n.includes("select.")?` / ${s.type||""}${"geo"in s.props?" / "+s.props.geo:""} / [${b.ToFixed(t.getPointInShapeSpace(s,t.inputs.currentPagePoint),0)}]`:"",a=n.startsWith("select.")&&!n.includes(".idle")?` / [${b.ToFixed(t.inputs.originPagePoint,0)}] → [${b.ToFixed(t.inputs.currentPagePoint,0)}] = ${b.Dist(t.inputs.originPagePoint,t.inputs.currentPagePoint).toFixed(0)}`:"";return h.jsx("div",{className:"tlui-debug-panel__current-state",children:`${n}${i}${a}`})});function Ote(){const e=K("show_fps",()=>jt.showFps.get(),[jt]),t=x.useRef(null);return x.useEffect(()=>{if(!e)return;const n=250;let r=0,o=!1,s=performance.now(),i=0,a=0,c=!1;function l(){if(!o){if(a++,i=performance.now()-s,i>n){const u=Math.round(a*(n/i)*(1e3/n));u>r&&(r=u);const d=r*.75;(u<d&&!c||u>=d&&c)&&(c=!c),t.current.innerHTML=`FPS ${u.toString()}`,t.current.className="tlui-debug-panel__fps"+(c?" tlui-debug-panel__fps__slow":""),i-=n,a=0,s=performance.now()}requestAnimationFrame(l)}}return l(),()=>{o=!0}},[e]),e?h.jsx("div",{ref:t}):null}function bj(){const e=z(),t=xo(),n=K("locale",()=>e.user.getLocale(),[e]);return h.jsx(Ir,{id:"help menu language",label:"menu.language",children:h.jsx(ye,{id:"languages",children:Dl.map(({locale:r,label:o})=>h.jsx(Cr,{id:`language-${r}`,title:r,label:o,checked:r===n,onSelect:()=>{e.user.updateUserPreferences({locale:r}),t("change-language",{source:"menu",locale:r})}},r))})})}function Dte(){return h.jsxs(h.Fragment,{children:[h.jsx(bj,{}),h.jsx(Rte,{})]})}function Rte(){const{KeyboardShortcutsDialog:e}=ti(),{addDialog:t}=Gi();return e?h.jsx(F,{id:"keyboard-shortcuts-button",label:"help-menu.keyboard-shortcuts",readonlyOk:!0,onSelect:()=>{t({component:e})}}):null}const Lte=x.memo(function({children:t}){const n=Me(),r=Rn(),o=t??h.jsx(Dte,{});return r<vt.MOBILE?null:h.jsx("div",{className:"tlui-help-menu",children:h.jsxs(Di,{id:"help menu",children:[h.jsx(Ri,{children:h.jsx(pe,{type:"help",title:n("help-menu.title"),"data-testid":"help-menu.button",children:h.jsx(Ce,{icon:"question-mark",small:!0})})}),h.jsx(Li,{side:"top",align:"end",alignOffset:0,sideOffset:8,children:h.jsx(br,{type:"menu",sourceId:"help-menu",children:o})})]})})});function Fte(){const e=z(),t=ce(),[n,r]=x.useState(!1),o=x.useRef(!1);return _s("toggle showback to content",()=>{const s=o.current,i=e.getCurrentPageShapeIds();let a=!1;i.size&&(a=i.size===e.getCulledShapes().size),s!==a&&(r(a),o.current=a)},[e]),n?h.jsx(F,{...t["back-to-content"],onSelect:()=>{t["back-to-content"].onSelect("helper-buttons"),r(!1)}}):null}function Nte(){const e=z(),t=ce();return K("is pen mode",()=>e.getInstanceState().isPenMode,[e])?h.jsx(F,{...t["exit-pen-mode"]}):null}function zte(){const e=z(),t=ce();return K("is following user",()=>!!e.getInstanceState().followingUserId,[e])?h.jsx(F,{...t["stop-following"]}):null}function Bte(){return h.jsxs(h.Fragment,{children:[h.jsx(Nte,{}),h.jsx(Fte,{}),h.jsx(zte,{})]})}function Ute({children:e}){const t=e??h.jsx(Bte,{});return h.jsx("div",{className:"tlui-helper-buttons",children:h.jsx(br,{type:"helper-buttons",sourceId:"helper-buttons",children:t})})}function Hte(){const e=ce(),t=Le();return h.jsxs(h.Fragment,{children:[h.jsxs(ye,{label:"shortcuts-dialog.tools",id:"tools",children:[h.jsx(F,{...e["toggle-tool-lock"]}),h.jsx(F,{...e["insert-media"]}),h.jsx(F,{...t.select}),h.jsx(F,{...t.draw}),h.jsx(F,{...t.eraser}),h.jsx(F,{...t.hand}),h.jsx(F,{...t.rectangle}),h.jsx(F,{...t.ellipse}),h.jsx(F,{...t.arrow}),h.jsx(F,{...t.line}),h.jsx(F,{...t.text}),h.jsx(F,{...t.frame}),h.jsx(F,{...t.note}),h.jsx(F,{...t.laser})]}),h.jsxs(ye,{label:"shortcuts-dialog.preferences",id:"preferences",children:[h.jsx(F,{...e["toggle-dark-mode"]}),h.jsx(F,{...e["toggle-focus-mode"]}),h.jsx(F,{...e["toggle-grid"]})]}),h.jsxs(ye,{label:"shortcuts-dialog.edit",id:"edit",children:[h.jsx(F,{...e.undo}),h.jsx(F,{...e.redo}),h.jsx(F,{...e.cut}),h.jsx(F,{...e.copy}),h.jsx(F,{...e.paste}),h.jsx(F,{...e["select-all"]}),h.jsx(F,{...e.delete}),h.jsx(F,{...e.duplicate})]}),h.jsxs(ye,{label:"shortcuts-dialog.view",id:"view",children:[h.jsx(F,{...e["zoom-in"]}),h.jsx(F,{...e["zoom-out"]}),h.jsx(F,{...e["zoom-to-100"]}),h.jsx(F,{...e["zoom-to-fit"]}),h.jsx(F,{...e["zoom-to-selection"]})]}),h.jsxs(ye,{label:"shortcuts-dialog.transform",id:"transform",children:[h.jsx(F,{...e["bring-to-front"]}),h.jsx(F,{...e["bring-forward"]}),h.jsx(F,{...e["send-backward"]}),h.jsx(F,{...e["send-to-back"]}),h.jsx(F,{...e.group}),h.jsx(F,{...e.ungroup}),h.jsx(F,{...e["flip-horizontal"]}),h.jsx(F,{...e["flip-vertical"]}),h.jsx(F,{...e["align-top"]}),h.jsx(F,{...e["align-center-vertical"]}),h.jsx(F,{...e["align-bottom"]}),h.jsx(F,{...e["align-left"]}),h.jsx(F,{...e["align-center-horizontal"]}),h.jsx(F,{...e["align-right"]})]})]})}const Kte=x.memo(function({children:t}){const n=Me(),r=Rn(),o=t??h.jsx(Hte,{});return h.jsxs(h.Fragment,{children:[h.jsxs(ag,{className:"tlui-shortcuts-dialog__header",children:[h.jsx(cg,{children:n("shortcuts-dialog.title")}),h.jsx(lg,{})]}),h.jsx(au,{className:ue("tlui-shortcuts-dialog__body",{"tlui-shortcuts-dialog__body__mobile":r<=vt.MOBILE_XS,"tlui-shortcuts-dialog__body__tablet":r<=vt.TABLET}),children:h.jsx(br,{type:"keyboard-shortcuts",sourceId:"kbd",children:o})}),h.jsx("div",{className:"tlui-dialog__scrim"})]})});function Wte(){return h.jsxs(h.Fragment,{children:[h.jsx(Vte,{}),h.jsx(Zte,{}),h.jsx(Gte,{}),h.jsx(Qte,{}),h.jsx(Jte,{})]})}function Gte(){const e=ce();return h.jsxs(Ir,{id:"export-all-as",label:"context-menu.export-all-as",size:"small",children:[h.jsxs(ye,{id:"export-all-as-group",children:[h.jsx(F,{...e["export-all-as-svg"]}),h.jsx(F,{...e["export-all-as-png"]}),h.jsx(F,{...e["export-all-as-json"]})]}),h.jsx(ye,{id:"export-all-as-bg",children:h.jsx(Sw,{})})]})}function Vte(){const e=z(),t=K("isSelectToolActive",()=>e.getCurrentToolId()==="select",[e]);return h.jsxs(Ir,{id:"edit",label:"menu.edit",disabled:!t,children:[h.jsx(qte,{}),h.jsx(mj,{}),h.jsx(yj,{}),h.jsx(Yte,{}),h.jsx(Xte,{}),h.jsx(ye,{id:"select-all",children:h.jsx(Sj,{})})]})}function Yte(){return h.jsxs(ye,{id:"misc",children:[h.jsx(cj,{}),h.jsx(lj,{}),h.jsx(aj,{}),h.jsx(ij,{}),h.jsx(uj,{}),h.jsx(dj,{}),h.jsx(xj,{}),h.jsx(vj,{})]})}function Xte(){return h.jsxs(ye,{id:"lock",children:[h.jsx(hj,{}),h.jsx(rte,{})]})}function qte(){const e=ce(),t=o$(),n=r$();return h.jsxs(ye,{id:"undo-redo",children:[h.jsx(F,{...e.undo,disabled:!t}),h.jsx(F,{...e.redo,disabled:!n})]})}function Zte(){const e=ce();return h.jsx(Ir,{id:"view",label:"menu.view",children:h.jsxs(ye,{id:"view-actions",children:[h.jsx(F,{...e["zoom-in"]}),h.jsx(F,{...e["zoom-out"]}),h.jsx(pj,{}),h.jsx(fj,{}),h.jsx(gj,{})]})})}function Qte(){const e=ce();return h.jsxs(ye,{id:"extras",children:[h.jsx(F,{...e["insert-embed"]}),h.jsx(F,{...e["insert-media"]})]})}function Jte(){return h.jsx(ye,{id:"preferences",children:h.jsxs(Ir,{id:"preferences",label:"menu.preferences",children:[h.jsxs(ye,{id:"preferences-actions",children:[h.jsx(fte,{}),h.jsx(gte,{}),h.jsx(mte,{}),h.jsx(yte,{}),h.jsx(Ste,{}),h.jsx(vte,{}),h.jsx(xte,{}),h.jsx(wte,{}),h.jsx(bte,{})]}),h.jsx(ye,{id:"language",children:h.jsx(bj,{})})]})})}const ene=x.memo(function({children:t}){const n=Xt(),[r,o]=Qs("main menu"),s=Me(),i=t??h.jsx(Wte,{});return h.jsxs(gw,{dir:"ltr",open:r,onOpenChange:o,modal:!1,children:[h.jsx(mw,{asChild:!0,dir:"ltr",children:h.jsx(pe,{type:"icon","data-testid":"main-menu.button",title:s("menu.title"),children:h.jsx(Ce,{icon:"menu",small:!0})})}),h.jsx(mg,{container:n,children:h.jsx(yw,{className:"tlui-menu",side:"bottom",align:"start",collisionPadding:4,alignOffset:0,sideOffset:6,children:h.jsx(br,{type:"menu",sourceId:"main-menu",children:i})})})]})}),tne=x.memo(function(){const t=Rn(),{MainMenu:n,QuickActions:r,ActionsMenu:o,PageMenu:s}=ti();return!n&&!s&&t<6?null:h.jsx("div",{className:"tlui-menu-zone",children:h.jsxs("div",{className:"tlui-buttons__horizontal",children:[n&&h.jsx(n,{}),s&&h.jsx(s,{}),t<6?null:h.jsxs(h.Fragment,{children:[r&&h.jsx(r,{}),o&&h.jsx(o,{})]})]})})}),uy={};function tl(e){if(uy[e])return uy[e];const n=document.createElement("canvas").getContext("2d");n.fillStyle=e,n.fillRect(0,0,1,1);const[r,o,s,i]=n.getImageData(0,0,1,1).data,a=new Float32Array([r/255,o/255,s/255,i/255]);return uy[e]=a,a}const Xh=10,Pj=4*6*Xh+12+4*12;function da(e,{center:t,radius:n,numArcSegments:r=20,startAngle:o=0,endAngle:s=Re,offset:i=0}){const a=(s-o)/r;let c=i;for(let l=o;l<s;l+=a)e[c++]=t.x,e[c++]=t.y,e[c++]=t.x+Math.cos(l)*n,e[c++]=t.y+Math.sin(l)*n,e[c++]=t.x+Math.cos(l+a)*n,e[c++]=t.y+Math.sin(l+a)*n;return e}function ha(e,t,n,r,o,s){e[t++]=n,e[t++]=r,e[t++]=n,e[t++]=r+s,e[t++]=n+o,e[t++]=r,e[t++]=n+o,e[t++]=r,e[t++]=n,e[t++]=r+s,e[t++]=n+o,e[t++]=r+s}function nne(e,t,n){const r=Xh;n=Math.min(n,Math.min(t.w,t.h)/2);const o=te.ExpandBy(t,-n);if(o.w<=0||o.h<=0)return da(e,{center:t.center,radius:n,numArcSegments:Xh*4}),Xh*4*6;let s=0;return ha(e,s,o.minX,o.minY,o.w,o.h),s+=12,ha(e,s,o.minX,t.minY,o.w,n),s+=12,ha(e,s,o.maxX,o.minY,n,o.h),s+=12,ha(e,s,o.minX,o.maxY,o.w,n),s+=12,ha(e,s,t.minX,o.minY,n,o.h),s+=12,da(e,{numArcSegments:r,offset:s,center:o.point,radius:n,startAngle:Pe,endAngle:Pe*1.5}),s+=r*6,da(e,{numArcSegments:r,offset:s,center:b.Add(o.point,new b(o.w,0)),radius:n,startAngle:Pe*1.5,endAngle:Re}),s+=r*6,da(e,{numArcSegments:r,offset:s,center:b.Add(o.point,o.size),radius:n,startAngle:0,endAngle:Ue}),s+=r*6,da(e,{numArcSegments:r,offset:s,center:b.Add(o.point,new b(0,o.h)),radius:n,startAngle:Ue,endAngle:Pe}),Pj}function rne(e){if(!e)throw new Error("Canvas element not found");const t=e.getContext("webgl2",{premultipliedAlpha:!1});if(!t)throw new Error("Failed to get webgl2 context");const n=`#version 300 es
|
|
303
|
-
precision mediump float;
|
|
304
|
-
|
|
305
|
-
in vec2 shapeVertexPosition;
|
|
306
|
-
|
|
307
|
-
uniform vec4 canvasPageBounds;
|
|
308
|
-
|
|
309
|
-
// taken (with thanks) from
|
|
310
|
-
// https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html
|
|
311
|
-
void main() {
|
|
312
|
-
// convert the position from pixels to 0.0 to 1.0
|
|
313
|
-
vec2 zeroToOne = (shapeVertexPosition - canvasPageBounds.xy) / canvasPageBounds.zw;
|
|
314
|
-
|
|
315
|
-
// convert from 0->1 to 0->2
|
|
316
|
-
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
317
|
-
|
|
318
|
-
// convert from 0->2 to -1->+1 (clipspace)
|
|
319
|
-
vec2 clipSpace = zeroToTwo - 1.0;
|
|
320
|
-
|
|
321
|
-
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
|
|
322
|
-
}`,r=t.createShader(t.VERTEX_SHADER);if(!r)throw new Error("Failed to create vertex shader");if(t.shaderSource(r,n),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error("Failed to compile vertex shader");const o=`#version 300 es
|
|
323
|
-
precision mediump float;
|
|
324
|
-
|
|
325
|
-
uniform vec4 fillColor;
|
|
326
|
-
out vec4 outputColor;
|
|
327
|
-
|
|
328
|
-
void main() {
|
|
329
|
-
outputColor = fillColor;
|
|
330
|
-
}`,s=t.createShader(t.FRAGMENT_SHADER);if(!s)throw new Error("Failed to create fragment shader");if(t.shaderSource(s,o),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw new Error("Failed to compile fragment shader");const i=t.createProgram();if(!i)throw new Error("Failed to create program");if(t.attachShader(i,r),t.attachShader(i,s),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS))throw new Error("Failed to link program");t.useProgram(i);const a=t.getAttribLocation(i,"shapeVertexPosition");if(a<0)throw new Error("Failed to get shapeVertexPosition attribute location");t.enableVertexAttribArray(a);const c=t.getUniformLocation(i,"canvasPageBounds"),l=t.getUniformLocation(i,"fillColor");if(!t.createBuffer())throw new Error("Failed to create buffer");if(!t.createBuffer())throw new Error("Failed to create buffer");return{context:t,selectedShapes:Vd(t,1024),unselectedShapes:Vd(t,4096),viewport:Vd(t,Pj),collaborators:Vd(t,1024),prepareTriangles(p,f){t.bindBuffer(t.ARRAY_BUFFER,p.buffer),t.bufferData(t.ARRAY_BUFFER,p.vertices,t.STATIC_DRAW,0,f),t.enableVertexAttribArray(a),t.vertexAttribPointer(a,2,t.FLOAT,!1,0,0)},drawTrianglesTransparently(p){t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.drawArrays(t.TRIANGLES,0,p/2),t.disable(t.BLEND)},drawTriangles(p){t.drawArrays(t.TRIANGLES,0,p/2)},setFillColor(p){t.uniform4fv(l,p)},setCanvasPageBounds(p){t.uniform4fv(c,p)}}}function Vd(e,t){const n=e.createBuffer();if(!n)throw new Error("Failed to create buffer");return{buffer:n,vertices:new Float32Array(t)}}function mI(e,t,n){let r=e.vertices.length;for(;r<t+n.length;)r*=2;if(r!=e.vertices.length){const o=new Float32Array(r);o.set(e.vertices),e.vertices=o}e.vertices.set(n,t)}var one=Object.defineProperty,sne=Object.getOwnPropertyDescriptor,ei=(e,t,n,r)=>{for(var o=sne(t,n),s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=i(t,n,o)||o);return o&&one(t,n,o),o};class is{constructor(t,n,r){m(this,"disposables",[]);m(this,"close",()=>this.disposables.forEach(t=>t()));m(this,"gl");m(this,"shapeGeometryCache");m(this,"colors");m(this,"id",rt());m(this,"canvasBoundingClientRect",pn("canvasBoundingClientRect",new te));m(this,"originPagePoint",new b);m(this,"originPageCenter",new b);m(this,"isInViewport",!1);m(this,"getMinimapPagePoint",(t,n)=>{const r=this.getCanvasPageBounds(),o=this.getCanvasScreenBounds();let s=t-o.x,i=n-o.y;return s*=r.width/o.width,i*=r.height/o.height,s+=r.minX,i+=r.minY,new b(s,i,1)});m(this,"minimapScreenPointToPagePoint",(t,n,r=!1,o=!1)=>{const{editor:s}=this,i=s.getViewportPageBounds();let{x:a,y:c}=this.getMinimapPagePoint(t,n);if(o){const l=this.editor.getCurrentPageBounds()??new te,u=l.minX-i.width/2,d=l.maxX+i.width/2,p=l.minY-i.height/2,f=l.maxY+i.height/2,y=Math.max(0,u+i.width-a),g=Math.max(0,-(d-i.width-a)),w=Math.max(0,p+i.height-c),S=Math.max(0,-(f-i.height-c));a+=(y-g)/2,c+=(w-S)/2,a=Mt(a,u,d),c=Mt(c,p,f)}if(r){const{originPagePoint:l}=this,u=Math.abs(a-l.x),d=Math.abs(c-l.y);u>d?c=l.y:a=l.x}return new b(a,c)});m(this,"render",()=>{const t=this.gl.context,n=this.getCanvasSize();this.gl.setCanvasPageBounds(this.getCanvasPageBoundsArray()),this.elem.width=n.x,this.elem.height=n.y,t.viewport(0,0,n.x,n.y),t.clearColor(this.colors.background[0],this.colors.background[1],this.colors.background[2],1),t.clear(t.COLOR_BUFFER_BIT);const r=new Set(this.editor.getSelectedShapeIds()),o=this.colors;let s=0,i=0;const a=this.editor.getCurrentPageShapeIdsSorted();for(let c=0,l=a.length;c<l;c++){const u=a[c],d=this.shapeGeometryCache.get(u);if(!d)continue;const p=d.length;r.has(u)?(mI(this.gl.selectedShapes,s,d),s+=p):(mI(this.gl.unselectedShapes,i,d),i+=p)}this.drawShapes(this.gl.unselectedShapes,i,o.shapeFill),this.drawShapes(this.gl.selectedShapes,s,o.selectFill),this.drawViewport(),this.drawCollaborators()});this.editor=t,this.elem=n,this.container=r,this.gl=rne(n),this.shapeGeometryCache=t.store.createComputedCache("webgl-geometry",o=>{const s=t.getShapeMaskedPageBounds(o.id);if(!s)return null;const i=new Float32Array(12);return ha(i,0,s.x,s.y,s.w,s.h),i}),this.colors=this._getColors(),this.disposables.push(this._listenForCanvasResize(),hc("minimap render",this.render))}_getColors(){const t=getComputedStyle(this.editor.getContainer());return{shapeFill:tl(t.getPropertyValue("--color-text-3").trim()),selectFill:tl(t.getPropertyValue("--color-selected").trim()),viewportFill:tl(t.getPropertyValue("--color-muted-1").trim()),background:tl(t.getPropertyValue("--color-low").trim())}}updateColors(){this.colors=this._getColors()}getDpr(){return this.editor.getInstanceState().devicePixelRatio}getContentPageBounds(){const t=this.editor.getViewportPageBounds(),n=this.editor.getCurrentPageBounds();return n?te.Expand(n,t):t}getContentScreenBounds(){const t=this.getContentPageBounds(),n=this.editor.pageToScreen(t.point),r=this.editor.pageToScreen(new b(t.maxX,t.maxY));return new te(n.x,n.y,r.x-n.x,r.y-n.y)}_getCanvasBoundingRect(){const{x:t,y:n,width:r,height:o}=this.elem.getBoundingClientRect();return new te(t,n,r,o)}getCanvasScreenBounds(){return this.canvasBoundingClientRect.get()}_listenForCanvasResize(){const t=new ResizeObserver(()=>{const n=this._getCanvasBoundingRect();this.canvasBoundingClientRect.set(n)});return t.observe(this.elem),t.observe(this.container),()=>t.disconnect()}getCanvasSize(){const t=this.canvasBoundingClientRect.get(),n=this.getDpr();return new b(t.width*n,t.height*n)}getCanvasClientPosition(){return this.canvasBoundingClientRect.get().point}getCanvasPageBounds(){const t=this.getCanvasScreenBounds(),n=this.getContentPageBounds(),r=t.width/t.height;let o=n.width,s=o/r;s<n.height&&(s=n.height,o=s*r);const i=new te(0,0,o,s);return i.center=n.center,i}getZoom(){return this.getCanvasPageBounds().width/this.getCanvasScreenBounds().width}getCanvasPageBoundsArray(){const{x:t,y:n,w:r,h:o}=this.getCanvasPageBounds();return new Float32Array([t,n,r,o])}drawShapes(t,n,r){this.gl.prepareTriangles(t,n),this.gl.setFillColor(r),this.gl.drawTriangles(n)}drawViewport(){const t=this.editor.getViewportPageBounds(),n=nne(this.gl.viewport.vertices,t,4*this.getZoom());this.gl.prepareTriangles(this.gl.viewport,n),this.gl.setFillColor(this.colors.viewportFill),this.gl.drawTrianglesTransparently(n),this.editor.environment.isSafari&&(this.gl.drawTrianglesTransparently(n),this.gl.drawTrianglesTransparently(n),this.gl.drawTrianglesTransparently(n))}drawCollaborators(){const t=this.editor.getCollaboratorsOnCurrentPage();if(!t.length)return;const n=20,r=n*6,o=r*t.length;this.gl.collaborators.vertices.length<o&&(this.gl.collaborators.vertices=new Float32Array(o));const s=this.gl.collaborators.vertices;let i=0;const a=this.getZoom();for(const{cursor:c}of t)da(s,{center:b.From(c),radius:3*a,offset:i,numArcSegments:n}),i+=r;this.gl.prepareTriangles(this.gl.collaborators,o),i=0;for(const{color:c}of t)this.gl.setFillColor(tl(c)),this.gl.context.drawArrays(this.gl.context.TRIANGLES,i/2,r/2),i+=r}}ei([G],is.prototype,"getDpr");ei([G],is.prototype,"getContentPageBounds");ei([G],is.prototype,"getContentScreenBounds");ei([G],is.prototype,"getCanvasSize");ei([G],is.prototype,"getCanvasClientPosition");ei([G],is.prototype,"getCanvasPageBounds");ei([G],is.prototype,"getZoom");ei([G],is.prototype,"getCanvasPageBoundsArray");function ine(){const e=z(),t=Xt(),n=x.useRef(null),r=x.useRef(!1),o=x.useRef();x.useEffect(()=>{try{const u=new is(e,n.current,t);return o.current=u,o.current.close}catch(u){e.annotateError(u,{origin:"minimap",willCrashApp:!1}),setTimeout(()=>{throw u})}},[e,t]);const s=x.useCallback(u=>{if(!e.getCurrentPageShapeIds().size||!o.current)return;const d=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!1),p=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!0);o.current.originPagePoint.setTo(p),o.current.originPageCenter.setTo(e.getViewportPageBounds().center),e.centerOnPoint(d,{animation:{duration:Qr}})},[e]),i=x.useCallback(u=>{if(!o.current)return;const d=u.currentTarget;if(xu(d,u),!e.getCurrentPageShapeIds().size)return;r.current=!0,o.current.isInViewport=!1;const p=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!1),f=e.getViewportPageBounds(),y=o.current.getContentPageBounds();if(new te(y.x-f.width/2,y.y-f.height/2,y.width+f.width,y.height+f.height).containsPoint(p)&&!f.containsPoint(p)){o.current.isInViewport=f.containsPoint(p);const S=b.Sub(f.center,f.point),v=b.Add(p,S);o.current.originPagePoint.setTo(v),o.current.originPageCenter.setTo(p),e.centerOnPoint(p,{animation:{duration:Qr}})}else{const S=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,!1,!0);o.current.isInViewport=f.containsPoint(S),o.current.originPagePoint.setTo(S),o.current.originPageCenter.setTo(f.center)}function w(S){d&&wu(d,S),r.current=!1,document.body.removeEventListener("pointerup",w)}document.body.addEventListener("pointerup",w)},[e]),a=x.useCallback(u=>{if(!o.current)return;const d=o.current.minimapScreenPointToPagePoint(u.clientX,u.clientY,u.shiftKey,!0);if(r.current){if(o.current.isInViewport){const g=o.current.originPagePoint.clone().sub(o.current.originPageCenter);e.centerOnPoint(b.Sub(d,g));return}e.centerOnPoint(d)}const p=o.current.getMinimapPagePoint(u.clientX,u.clientY),f=e.pageToScreen(p),y={type:"pointer",target:"canvas",name:"pointer_move",..._n(u),point:f,isPen:e.getInstanceState().isPenMode};e.dispatch(y)},[e]),c=x.useCallback(u=>{const d=c_(u);e.dispatch({type:"wheel",name:"wheel",delta:d,point:new b(u.clientX,u.clientY),shiftKey:u.shiftKey,altKey:u.altKey,ctrlKey:u.metaKey||u.ctrlKey})},[e]),l=Tu();return x.useEffect(()=>{setTimeout(()=>{var u,d;(u=o.current)==null||u.updateColors(),(d=o.current)==null||d.render()})},[l]),h.jsx("div",{className:"tlui-minimap",children:h.jsx("canvas",{role:"img","aria-label":"minimap",ref:n,className:"tlui-minimap__canvas",onDoubleClick:s,onPointerMove:a,onPointerDown:i,onWheel:c})})}function ane(e,t){const[n,r]=Se.useState(t);Se.useLayoutEffect(()=>{const s=Wv(e);if(s)try{r(JSON.parse(s))}catch{console.error(`Could not restore value ${e} from local storage.`)}},[e]);const o=Se.useCallback(s=>{r(i=>{const a=typeof s=="function"?s(i):s;return Gv(e,JSON.stringify(a)),a})},[e]);return[n,o]}const cne=x.memo(function(){const t=ce(),n=Me(),r=Rn(),[o,s]=ane("minimap",!0),i=x.useCallback(()=>{s(l=>!l)},[s]),{ZoomMenu:a,Minimap:c}=ti();return r<vt.MOBILE?null:h.jsxs("div",{className:"tlui-navigation-panel",children:[h.jsx("div",{className:"tlui-buttons__horizontal",children:a&&r<vt.TABLET?h.jsx(a,{}):o?h.jsxs(h.Fragment,{children:[a&&h.jsx(a,{}),c&&h.jsx(pe,{type:"icon","data-testid":"minimap.toggle-button",title:n("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:i,children:h.jsx(Ce,{icon:o?"chevrons-ne":"chevrons-sw"})})]}):h.jsxs(h.Fragment,{children:[h.jsx(pe,{type:"icon","data-testid":"minimap.zoom-out",title:`${n(cu(t["zoom-out"].label))} ${Mv(t["zoom-out"].kbd)}`,onClick:()=>t["zoom-out"].onSelect("navigation-zone"),children:h.jsx(Ce,{icon:"minus"})}),a&&h.jsx(a,{}),h.jsx(pe,{type:"icon","data-testid":"minimap.zoom-in",title:`${n(cu(t["zoom-in"].label))} ${Mv(t["zoom-in"].kbd)}`,onClick:()=>t["zoom-in"].onSelect("navigation-zone"),children:h.jsx(Ce,{icon:"plus"})}),c&&h.jsx(pe,{type:"icon","data-testid":"minimap.toggle-button",title:n("navigation-zone.toggle-minimap"),className:"tlui-navigation-panel__toggle",onClick:i,children:h.jsx(Ce,{icon:o?"chevrons-ne":"chevrons-sw"})})]})}),c&&r>=vt.TABLET&&!o&&h.jsx(c,{})]})}),lne=function({name:t,id:n,isCurrentPage:r}){const o=z(),s=x.useRef(null),i=x.useCallback(()=>{o.mark("rename page")},[o]),a=x.useCallback(c=>{o.renamePage(n,c||"New Page")},[o,n]);return h.jsx(Zx,{className:"tlui-page-menu__item__input",ref:c=>s.current=c,defaultValue:t,onValueChange:a,onFocus:i,shouldManuallyMaintainScrollPositionWhenFocused:!0,autofocus:r,autoselect:!0})},jv=(e,t,n,r)=>{let o;const s=e.getPages(),i=n>r?s[r-1]:s[r],a=n>r?s[r]:s[r+1];i&&!a?o=$o(i.index):!i&&a?o=GD(s[0].index):o=fl(i.index,a.index),o!==s[n].index&&(e.mark("moving page"),e.updatePage({id:t,index:o}))},yI=rr(function({index:t,listSize:n,item:r,onRename:o}){const s=z(),i=Me(),a=s.getPages(),c=x.useCallback(()=>{s.mark("creating page");const p=Bo.createId();s.duplicatePage(r.id,p)},[s,r]),l=x.useCallback(()=>{jv(s,r.id,t,t-1)},[s,r,t]),u=x.useCallback(()=>{jv(s,r.id,t,t+1)},[s,r,t]),d=x.useCallback(()=>{s.mark("deleting page"),s.deletePage(r.id)},[s,r]);return h.jsxs(Di,{id:`page item submenu ${t}`,children:[h.jsx(Ri,{children:h.jsx(pe,{type:"icon",title:i("page-menu.submenu.title"),children:h.jsx(Ce,{icon:"dots-vertical"})})}),h.jsx(Li,{alignOffset:0,side:"right",sideOffset:-4,children:h.jsxs(br,{type:"menu",sourceId:"page-menu",children:[h.jsxs(ye,{id:"modify",children:[o&&h.jsx(F,{id:"rename",label:"page-menu.submenu.rename",onSelect:o}),h.jsx(F,{id:"duplicate",label:"page-menu.submenu.duplicate-page",onSelect:c,disabled:a.length>=yp}),t>0&&h.jsx(F,{id:"move-up",onSelect:l,label:"page-menu.submenu.move-up"}),t<n-1&&h.jsx(F,{id:"move-down",label:"page-menu.submenu.move-down",onSelect:u})]}),n>1&&h.jsx(ye,{id:"delete",children:h.jsx(F,{id:"delete",onSelect:d,label:"page-menu.submenu.delete"})})]})})]})}),une=x.memo(function(){const t=z(),n=Me(),r=Rn(),o=x.useCallback(()=>w(!1),[]),[s,i]=Qs("page-menu",o),a=36,c=x.useRef(null),l=K("pages",()=>t.getPages(),[t]),u=K("currentPage",()=>t.getCurrentPage(),[t]),d=K("currentPageId",()=>t.getCurrentPageId(),[t]),p=rs(),f=K("maxPageCountReached",()=>t.getPages().length>=yp,[t]),y=K("isCoarsePointer",()=>t.getInstanceState().isCoarsePointer,[t]),[g,w]=x.useState(!1),S=x.useCallback(()=>{p||w(T=>!T)},[p]),v=x.useRef({isPointing:!1,status:"idle",pointing:null,startY:0,startIndex:0,dragIndex:0}),[P,I]=x.useState(Object.fromEntries(l.map((T,A)=>[T.id,{y:A*a,offsetY:0,isSelected:!1}])));x.useLayoutEffect(()=>{I(Object.fromEntries(l.map((T,A)=>[T.id,{y:A*a,offsetY:0,isSelected:!1}])))},[a,l]),x.useEffect(()=>{s&&requestAnimationFrame(()=>{const T=document.querySelector(`[data-testid="page-menu-item-${d}"]`);if(T){const A=c.current;if(!A)return;const B=T.offsetTop,L=A.scrollTop;B<L&&A.scrollTo({top:B});const R=B+a,N=A.scrollTop+A.offsetHeight;R>N&&A.scrollTo({top:R-A.offsetHeight})}})},[a,d,s]);const C=x.useCallback(T=>{const{clientY:A,currentTarget:B}=T,{dataset:{id:L,index:R}}=B;if(!L||!R)return;const N=v.current;xu(T.currentTarget,T),N.status="pointing",N.pointing={id:L,index:+R};const q=P[L].y;N.startY=A,N.startIndex=Math.max(0,Math.min(Math.round(q/a),l.length-1))},[a,l.length,P]),E=x.useCallback(T=>{const A=v.current;if(A.status==="pointing"){const{clientY:B}=T,L=B-A.startY;Math.abs(L)>5&&(A.status="dragging")}if(A.status==="dragging"){const{clientY:B}=T,L=B-A.startY,R=P[A.pointing.id],{startIndex:N,pointing:X}=A,q=R.y+L,H=Math.max(0,Math.min(Math.round(q/a),l.length-1)),U={...P};if(U[X.id]={y:R.y,offsetY:L,isSelected:!0},H!==A.dragIndex){A.dragIndex=H;for(let W=0;W<l.length;W++){const Q=l[W];if(Q.id===A.pointing.id)continue;let{y:le}=U[Q.id];H===N?le=W*a:H<N?H<=W&&W<N?le=(W+1)*a:le=W*a:H>N&&(H>=W&&W>N?le=(W-1)*a:le=W*a),le!==U[Q.id].y&&(U[Q.id]={y:le,offsetY:0,isSelected:!0})}}I(U)}},[a,l,P]),_=x.useCallback(T=>{const A=v.current;if(A.status==="dragging"){const{id:B,index:L}=A.pointing;jv(t,B,L,A.dragIndex)}wu(T.currentTarget,T),A.status="idle"},[t]),k=x.useCallback(T=>{const A=v.current;T.key==="Escape"&&(A.status==="dragging"&&I(Object.fromEntries(l.map((B,L)=>[B.id,{y:L*a,offsetY:0,isSelected:!1}]))),A.status="idle")},[a,l]),$=x.useCallback(()=>{p||t.batch(()=>{t.mark("creating page");const T=Bo.createId();t.createPage({name:n("page-menu.new-page-initial-name"),id:T}),t.setCurrentPage(T),w(!0)})},[t,n,p]);return h.jsxs(cw,{id:"pages",onOpenChange:i,open:s,children:[h.jsx(lw,{"data-testid":"main.page-menu",children:h.jsxs(pe,{type:"menu",title:u.name,"data-testid":"page-menu.button",className:"tlui-page-menu__trigger",children:[h.jsx("div",{className:"tlui-page-menu__name",children:u.name}),h.jsx(Ce,{icon:"chevron-down",small:!0})]})}),h.jsx(uw,{side:"bottom",align:"start",sideOffset:6,children:h.jsxs("div",{className:"tlui-page-menu__wrapper",children:[h.jsxs("div",{className:"tlui-page-menu__header",children:[h.jsx("div",{className:"tlui-page-menu__header__title",children:n("page-menu.title")}),!p&&h.jsxs("div",{className:"tlui-buttons__horizontal",children:[h.jsx(pe,{type:"icon","data-testid":"page-menu.edit",title:n(g?"page-menu.edit-done":"page-menu.edit-start"),onClick:S,children:h.jsx(Ce,{icon:g?"check":"edit"})}),h.jsx(pe,{type:"icon","data-testid":"page-menu.create",title:n(f?"page-menu.max-page-count-reached":"page-menu.create-new-page"),disabled:f,onClick:$,children:h.jsx(Ce,{icon:"plus"})})]})]}),h.jsx("div",{"data-testid":"page-menu.list",className:"tlui-page-menu__list tlui-menu__group",style:{height:a*l.length+4},ref:c,children:l.map((T,A)=>{const B=P[T.id]??{position:A*40,offsetY:0};return g?h.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page_menu__item__sortable",style:{zIndex:T.id===u.id?888:A,transform:`translate(0px, ${B.y+B.offsetY}px)`},children:[h.jsx(pe,{type:"icon",tabIndex:-1,className:"tlui-page_menu__item__sortable__handle",onPointerDown:C,onPointerUp:_,onPointerMove:E,onKeyDown:k,"data-id":T.id,"data-index":A,children:h.jsx(Ce,{icon:"drag-handle-dots"})}),r<vt.TABLET_SM&&y?h.jsxs(pe,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>{const L=window.prompt("Rename page",T.name);L&&L!==T.name&&t.renamePage(T.id,L)},onDoubleClick:S,children:[h.jsx(Av,{checked:T.id===u.id}),h.jsx(bt,{children:T.name})]}):h.jsx("div",{className:"tlui-page_menu__item__sortable__title",style:{height:a},children:h.jsx(lne,{id:T.id,name:T.name,isCurrentPage:T.id===u.id})}),!p&&h.jsx("div",{className:"tlui-page_menu__item__submenu","data-isediting":g,children:h.jsx(yI,{index:A,item:T,listSize:l.length})})]},T.id+"_editing"):h.jsxs("div",{"data-testid":"page-menu.item",className:"tlui-page-menu__item",children:[h.jsxs(pe,{type:"normal",className:"tlui-page-menu__item__button",onClick:()=>t.setCurrentPage(T.id),onDoubleClick:S,title:n("page-menu.go-to-page"),children:[h.jsx(Av,{checked:T.id===u.id}),h.jsx(bt,{children:T.name})]}),!p&&h.jsx("div",{className:"tlui-page_menu__item__submenu",children:h.jsx(yI,{index:A,item:T,listSize:l.length,onRename:()=>{if(t.environment.isIos){const L=window.prompt("Rename page",T.name);L&&L!==T.name&&t.renamePage(T.id,L)}else t.batch(()=>{w(!0),t.setCurrentPage(T.id)})}})})]},T.id)})})]})})]})});function dne(){const e=ce(),t=z(),n=o$(),r=r$(),o=bn(1),s=rs(),i=K("should display quick actions",()=>t.isInAny("select","hand","zoom"),[t]);if(!(s&&!i))return h.jsxs(h.Fragment,{children:[h.jsx(F,{...e.undo,disabled:!n}),h.jsx(F,{...e.redo,disabled:!r}),h.jsx(F,{...e.delete,disabled:!o}),h.jsx(F,{...e.duplicate,disabled:!o})]})}const hne=x.memo(function({children:t}){const n=t??h.jsx(dne,{});return h.jsx(br,{type:"small-icons",sourceId:"quick-actions",children:n})}),pne=Object.freeze([tr,bi,Ya,lo]);function Cj(e=pne){const t=z();return K("getRelevantStyles",()=>{var s;const n=new HS(t.getSharedStyles()),r=!!((s=t.root.getCurrent())!=null&&s.shapeType),o=t.isIn("select")&&t.getSelectedShapeIds().length>0;if(n.size===0&&t.isIn("select")&&t.getSelectedShapeIds().length===0)for(const i of e)n.applyValue(i,t.getStyleForNextShape(i));return r||o||n.size>0?n:null},[t])}const yr={color:[{value:"black",icon:"color"},{value:"grey",icon:"color"},{value:"light-violet",icon:"color"},{value:"violet",icon:"color"},{value:"blue",icon:"color"},{value:"light-blue",icon:"color"},{value:"yellow",icon:"color"},{value:"orange",icon:"color"},{value:"green",icon:"color"},{value:"light-green",icon:"color"},{value:"light-red",icon:"color"},{value:"red",icon:"color"}],fill:[{value:"none",icon:"fill-none"},{value:"semi",icon:"fill-semi"},{value:"solid",icon:"fill-solid"},{value:"pattern",icon:"fill-pattern"}],dash:[{value:"draw",icon:"dash-draw"},{value:"dashed",icon:"dash-dashed"},{value:"dotted",icon:"dash-dotted"},{value:"solid",icon:"dash-solid"}],size:[{value:"s",icon:"size-small"},{value:"m",icon:"size-medium"},{value:"l",icon:"size-large"},{value:"xl",icon:"size-extra-large"}],font:[{value:"draw",icon:"font-draw"},{value:"sans",icon:"font-sans"},{value:"serif",icon:"font-serif"},{value:"mono",icon:"font-mono"}],textAlign:[{value:"start",icon:"text-align-left"},{value:"middle",icon:"text-align-center"},{value:"end",icon:"text-align-right"}],horizontalAlign:[{value:"start",icon:"horizontal-align-start"},{value:"middle",icon:"horizontal-align-middle"},{value:"end",icon:"horizontal-align-end"}],verticalAlign:[{value:"start",icon:"vertical-align-start"},{value:"middle",icon:"vertical-align-middle"},{value:"end",icon:"vertical-align-end"}],geo:[{value:"rectangle",icon:"geo-rectangle"},{value:"ellipse",icon:"geo-ellipse"},{value:"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 fne(e){const{uiType:t,items:n,title:r,style:o,value:s,onValueChange:i,theme:a}=e,c=z(),l=Me(),u=x.useRef(!1),{handleButtonClick:d,handleButtonPointerDown:p,handleButtonPointerEnter:f,handleButtonPointerUp:y}=x.useMemo(()=>{const g=()=>{u.current=!1,window.removeEventListener("pointerup",g)};return{handleButtonClick:I=>{const{id:C}=I.currentTarget.dataset;s.type==="shared"&&s.value===C||(c.mark("point picker item"),i(o,C))},handleButtonPointerDown:I=>{const{id:C}=I.currentTarget.dataset;c.mark("point picker item"),i(o,C),u.current=!0,window.addEventListener("pointerup",g)},handleButtonPointerEnter:I=>{if(!u.current)return;const{id:C}=I.currentTarget.dataset;i(o,C)},handleButtonPointerUp:I=>{const{id:C}=I.currentTarget.dataset;s.type==="shared"&&s.value===C||i(o,C)}}},[s,c,i,o]);return h.jsx("div",{"data-testid":`style.${t}`,className:ue("tlui-buttons__grid"),children:n.map(g=>h.jsx(pe,{type:"icon","data-id":g.value,"data-testid":`style.${t}.${g.value}`,"aria-label":g.value,"data-state":s.type==="shared"&&s.value===g.value?"hinted":void 0,title:r+" — "+l(`${t}-style.${g.value}`),className:ue("tlui-button-grid__button"),style:o===tr?{color:a[g.value].solid}:void 0,onPointerEnter:f,onPointerDown:p,onPointerUp:y,onClick:d,children:h.jsx(Ce,{icon:g.icon})},g.value))})}const Si=x.memo(fne);function Ij(e,[t,n]){return Math.min(n,Math.max(t,e))}function gne(e){const t=x.useRef({value:e,previous:e});return x.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}const Ej=["PageUp","PageDown"],_j=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],kj={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Lu="Slider",[Ov,mne,yne]=eg(Lu),[Tj,Hoe]=So(Lu,[yne]),[Sne,yg]=Tj(Lu),vne=x.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:l=[r],value:u,onValueChange:d=()=>{},onValueCommit:p=()=>{},inverted:f=!1,...y}=e,[g,w]=x.useState(null),S=Ze(t,R=>w(R)),v=x.useRef(new Set),P=x.useRef(0),I=i==="horizontal",C=g?!!g.closest("form"):!0,E=I?xne:wne,[_=[],k]=Zs({prop:u,defaultProp:l,onChange:R=>{var N;(N=[...v.current][P.current])===null||N===void 0||N.focus(),d(R)}}),$=x.useRef(_);function T(R){const N=$ne(_,R);L(R,N)}function A(R){L(R,P.current)}function B(){const R=$.current[P.current];_[P.current]!==R&&p(_)}function L(R,N,{commit:X}={commit:!1}){const q=One(s),H=Dne(Math.round((R-r)/s)*s+r,q),U=Ij(H,[r,o]);k((W=[])=>{const Q=kne(W,U,N);if(jne(Q,c*s)){P.current=Q.indexOf(U);const le=String(Q)!==String(W);return le&&X&&p(Q),le?Q:W}else return W})}return x.createElement(Sne,{scope:e.__scopeSlider,disabled:a,min:r,max:o,valueIndexToChangeRef:P,thumbs:v.current,values:_,orientation:i},x.createElement(Ov.Provider,{scope:e.__scopeSlider},x.createElement(Ov.Slot,{scope:e.__scopeSlider},x.createElement(E,Z({"aria-disabled":a,"data-disabled":a?"":void 0},y,{ref:S,onPointerDown:ie(y.onPointerDown,()=>{a||($.current=_)}),min:r,max:o,inverted:f,onSlideStart:a?void 0:T,onSlideMove:a?void 0:A,onSlideEnd:a?void 0:B,onHomeKeyDown:()=>!a&&L(r,0,{commit:!0}),onEndKeyDown:()=>!a&&L(o,_.length-1,{commit:!0}),onStepKeyDown:({event:R,direction:N})=>{if(!a){const H=Ej.includes(R.key)||R.shiftKey&&_j.includes(R.key)?10:1,U=P.current,W=_[U],Q=s*H*N;L(W+Q,U,{commit:!0})}}})))),C&&_.map((R,N)=>x.createElement(_ne,{key:N,name:n?n+(_.length>1?"[]":""):void 0,value:R})))}),[$j,Mj]=Tj(Lu,{startEdge:"left",endEdge:"right",size:"width",direction:1}),xne=x.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:l,...u}=e,[d,p]=x.useState(null),f=Ze(t,P=>p(P)),y=x.useRef(),g=dw(o),w=g==="ltr",S=w&&!s||!w&&s;function v(P){const I=y.current||d.getBoundingClientRect(),C=[0,I.width],_=vw(C,S?[n,r]:[r,n]);return y.current=I,_(P-I.left)}return x.createElement($j,{scope:e.__scopeSlider,startEdge:S?"left":"right",endEdge:S?"right":"left",direction:S?1:-1,size:"width"},x.createElement(Aj,Z({dir:g,"data-orientation":"horizontal"},u,{ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:P=>{const I=v(P.clientX);i==null||i(I)},onSlideMove:P=>{const I=v(P.clientX);a==null||a(I)},onSlideEnd:()=>{y.current=void 0,c==null||c()},onStepKeyDown:P=>{const C=kj[S?"from-left":"from-right"].includes(P.key);l==null||l({event:P,direction:C?-1:1})}})))}),wne=x.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...l}=e,u=x.useRef(null),d=Ze(t,u),p=x.useRef(),f=!o;function y(g){const w=p.current||u.current.getBoundingClientRect(),S=[0,w.height],P=vw(S,f?[r,n]:[n,r]);return p.current=w,P(g-w.top)}return x.createElement($j,{scope:e.__scopeSlider,startEdge:f?"bottom":"top",endEdge:f?"top":"bottom",size:"height",direction:f?1:-1},x.createElement(Aj,Z({"data-orientation":"vertical"},l,{ref:d,style:{...l.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:g=>{const w=y(g.clientY);s==null||s(w)},onSlideMove:g=>{const w=y(g.clientY);i==null||i(w)},onSlideEnd:()=>{p.current=void 0,a==null||a()},onStepKeyDown:g=>{const S=kj[f?"from-bottom":"from-top"].includes(g.key);c==null||c({event:g,direction:S?-1:1})}})))}),Aj=x.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...l}=e,u=yg(Lu,n);return x.createElement(Ve.span,Z({},l,{ref:t,onKeyDown:ie(e.onKeyDown,d=>{d.key==="Home"?(i(d),d.preventDefault()):d.key==="End"?(a(d),d.preventDefault()):Ej.concat(_j).includes(d.key)&&(c(d),d.preventDefault())}),onPointerDown:ie(e.onPointerDown,d=>{const p=d.target;p.setPointerCapture(d.pointerId),d.preventDefault(),u.thumbs.has(p)?p.focus():r(d)}),onPointerMove:ie(e.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&o(d)}),onPointerUp:ie(e.onPointerUp,d=>{const p=d.target;p.hasPointerCapture(d.pointerId)&&(p.releasePointerCapture(d.pointerId),s(d))})}))}),bne="SliderTrack",Pne=x.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=yg(bne,n);return x.createElement(Ve.span,Z({"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation},r,{ref:t}))}),SI="SliderRange",Cne=x.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=yg(SI,n),s=Mj(SI,n),i=x.useRef(null),a=Ze(t,i),c=o.values.length,l=o.values.map(p=>jj(p,o.min,o.max)),u=c>1?Math.min(...l):0,d=100-Math.max(...l);return x.createElement(Ve.span,Z({"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0},r,{ref:a,style:{...e.style,[s.startEdge]:u+"%",[s.endEdge]:d+"%"}}))}),vI="SliderThumb",Ine=x.forwardRef((e,t)=>{const n=mne(e.__scopeSlider),[r,o]=x.useState(null),s=Ze(t,a=>o(a)),i=x.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return x.createElement(Ene,Z({},e,{ref:s,index:i}))}),Ene=x.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,...o}=e,s=yg(vI,n),i=Mj(vI,n),[a,c]=x.useState(null),l=Ze(t,w=>c(w)),u=gA(a),d=s.values[r],p=d===void 0?0:jj(d,s.min,s.max),f=Tne(r,s.values.length),y=u==null?void 0:u[i.size],g=y?Mne(y,p,i.direction):0;return x.useEffect(()=>{if(a)return s.thumbs.add(a),()=>{s.thumbs.delete(a)}},[a,s.thumbs]),x.createElement("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${p}% + ${g}px)`}},x.createElement(Ov.ItemSlot,{scope:e.__scopeSlider},x.createElement(Ve.span,Z({role:"slider","aria-label":e["aria-label"]||f,"aria-valuemin":s.min,"aria-valuenow":d,"aria-valuemax":s.max,"aria-orientation":s.orientation,"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,tabIndex:s.disabled?void 0:0},o,{ref:l,style:d===void 0?{display:"none"}:e.style,onFocus:ie(e.onFocus,()=>{s.valueIndexToChangeRef.current=r})}))))}),_ne=e=>{const{value:t,...n}=e,r=x.useRef(null),o=gne(t);return x.useEffect(()=>{const s=r.current,i=window.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(i,"value").set;if(o!==t&&c){const l=new Event("input",{bubbles:!0});c.call(s,t),s.dispatchEvent(l)}},[o,t]),x.createElement("input",Z({style:{display:"none"}},n,{ref:r,defaultValue:t}))};function kne(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function jj(e,t,n){const s=100/(n-t)*(e-t);return Ij(s,[0,100])}function Tne(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function $ne(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function Mne(e,t,n){const r=e/2,s=vw([0,50],[0,r]);return(r-s(t)*n)*n}function Ane(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function jne(e,t){if(t>0){const n=Ane(e);return Math.min(...n)>=t}return!0}function vw(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function One(e){return(String(e).split(".")[1]||"").length}function Dne(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}const Rne=vne,Lne=Pne,Fne=Cne,Nne=Ine,zne=x.memo(function(t){const{title:n,steps:r,value:o,label:s,onValueChange:i}=t,a=z(),c=Me(),l=x.useCallback(p=>{i(p[0])},[i]),u=x.useCallback(()=>{a.mark("click slider")},[a]),d=x.useCallback(()=>{o&&i(o)},[o,i]);return h.jsx("div",{className:"tlui-slider__container",children:h.jsxs(Rne,{"data-testid":t["data-testid"],className:"tlui-slider","area-label":"Opacity",dir:"ltr",min:0,max:r,step:1,value:o?[o]:void 0,onPointerDown:u,onValueChange:l,onPointerUp:d,title:n+" — "+c(s),children:[h.jsx(Lne,{className:"tlui-slider__track",dir:"ltr",children:o!==null&&h.jsx(Fne,{className:"tlui-slider__range",dir:"ltr"})}),o!==null&&h.jsx(Nne,{className:"tlui-slider__thumb",dir:"ltr"})]})})});function Bne({label:e,uiTypeA:t,uiTypeB:n,labelA:r,labelB:o,itemsA:s,itemsB:i,styleA:a,styleB:c,valueA:l,valueB:u,onValueChange:d}){const p=Me(),f=x.useMemo(()=>{var g;return((g=s.find(w=>l.type==="shared"&&l.value===w.value))==null?void 0:g.icon)??"mixed"},[s,l]),y=x.useMemo(()=>{var g;return((g=i.find(w=>u.type==="shared"&&u.value===w.value))==null?void 0:g.icon)??"mixed"},[i,u]);return l===void 0&&u===void 0?null:h.jsxs("div",{className:"tlui-style-panel__double-select-picker",children:[h.jsx("div",{title:p(e),className:"tlui-style-panel__double-select-picker-label",children:p(e)}),h.jsxs("div",{className:"tlui-buttons__horizontal",children:[h.jsxs(Di,{id:`style panel ${t} A`,children:[h.jsx(Ri,{children:h.jsx(pe,{type:"icon","data-testid":`style.${t}`,title:p(r)+" — "+(l===null||l.type==="mixed"?p("style-panel.mixed"):p(`${t}-style.${l.value}`)),children:h.jsx(Ce,{icon:f,small:!0,invertIcon:!0})})}),h.jsx(Li,{side:"left",align:"center",sideOffset:80,alignOffset:0,children:h.jsx("div",{className:"tlui-buttons__grid",children:s.map((g,w)=>h.jsx(fu,{"data-testid":`style.${t}.${g.value}`,children:h.jsx(pe,{type:"icon",onClick:()=>d(a,g.value),title:`${p(r)} — ${p(`${t}-style.${g.value}`)}`,children:h.jsx(Ce,{icon:g.icon,invertIcon:!0})},g.value)},w))})})]}),h.jsxs(Di,{id:`style panel ${n}`,children:[h.jsx(Ri,{children:h.jsx(pe,{type:"icon","data-testid":`style.${n}`,title:p(o)+" — "+(u===null||u.type==="mixed"?p("style-panel.mixed"):p(`${n}-style.${u.value}`)),children:h.jsx(Ce,{icon:y,small:!0})})}),h.jsx(Li,{side:"left",align:"center",sideOffset:116,alignOffset:0,children:h.jsx("div",{className:"tlui-buttons__grid",children:i.map(g=>h.jsx(fu,{children:h.jsx(pe,{type:"icon",title:`${p(o)} — ${p(`${n}-style.${g.value}`)}`,"data-testid":`style.${n}.${g.value}`,onClick:()=>d(c,g.value),children:h.jsx(Ce,{icon:g.icon})})},g.value))})})]})]})]})}const Une=x.memo(Bne);function Hne({id:e,label:t,uiType:n,style:r,items:o,type:s,value:i,onValueChange:a}){const c=Me(),l=z(),u=x.useMemo(()=>{var f;return(f=o.find(y=>i.type==="shared"&&y.value===i.value))==null?void 0:f.icon},[o,i]),d=i.type==="mixed"?c("style-panel.mixed"):c(`${n}-style.${i.value}`),p=t?c(t):"";return h.jsxs(Di,{id:`style panel ${e}`,children:[h.jsx(Ri,{children:h.jsxs(pe,{type:s,"data-testid":`style.${n}`,title:d,children:[h.jsx(bt,{children:p}),h.jsx(Ce,{icon:u??"mixed"})]})}),h.jsx(Li,{side:"left",align:"center",alignOffset:0,children:h.jsx("div",{className:"tlui-buttons__grid",children:o.map(f=>h.jsx(fu,{children:h.jsx(pe,{type:"icon","data-testid":`style.${n}.${f.value}`,title:c(`${n}-style.${f.value}`),onClick:()=>{l.mark("select style dropdown item"),a(r,f.value)},children:h.jsx(Ce,{icon:f.icon})})},f.value))})})]})}const xw=x.memo(Hne);function Kne({styles:e}){const t=Tu();if(!e)return null;const n=e.get(ro),r=e.get(up),o=e.get(lp),s=e.get(pp),i=e.get(co),a=n===void 0,c=r===void 0&&o===void 0,l=s===void 0,u=i===void 0,d=Jo({isDarkMode:t});return h.jsxs(h.Fragment,{children:[h.jsx(Wne,{theme:d,styles:e}),!u&&h.jsx(Gne,{theme:d,styles:e}),!(a&&c&&l)&&h.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[h.jsx(Vne,{styles:e}),h.jsx(Xne,{styles:e}),h.jsx(Yne,{styles:e})]})]})}function Fu(){const e=z(),t=xo();return Se.useMemo(()=>function(r,o){e.batch(()=>{e.isIn("select")&&e.setStyleForSelectedShapes(r,o),e.setStyleForNextShapes(r,o),e.updateInstanceState({isChangingStyle:!0})}),t("set-style",{source:"style-panel",id:r.id,value:o})},[e,t])}function Wne({styles:e,theme:t}){const n=Me(),r=z(),o=Fu(),s=e.get(tr),i=e.get(Ya),a=e.get(bi),c=e.get(lo),l=i!==void 0||a!==void 0||c!==void 0;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{tabIndex:-1,className:"tlui-style-panel__section__common","aria-label":"style panel styles","data-testid":"style.panel",children:[s===void 0?null:h.jsx(Si,{title:n("style-panel.color"),uiType:"color",style:tr,items:yr.color,value:s,onValueChange:o,theme:t}),h.jsx(qne,{})]}),l&&h.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel styles",children:[i===void 0?null:h.jsx(Si,{title:n("style-panel.fill"),uiType:"fill",style:Ya,items:yr.fill,value:i,onValueChange:o,theme:t}),a===void 0?null:h.jsx(Si,{title:n("style-panel.dash"),uiType:"dash",style:bi,items:yr.dash,value:a,onValueChange:o,theme:t}),c===void 0?null:h.jsx(Si,{title:n("style-panel.size"),uiType:"size",style:lo,items:yr.size,value:c,onValueChange:(u,d)=>{o(u,d);const p=r.getSelectedShapeIds();p.length>0&&Ye(r,p)},theme:t})]})]})}function Gne({theme:e,styles:t}){const n=Me(),r=Fu(),o=t.get(co),s=t.get(Hy),i=t.get(dp),a=t.get(hp);return o===void 0&&i===void 0?null:h.jsxs("div",{className:"tlui-style-panel__section","aria-label":"style panel text",children:[o===void 0?null:h.jsx(Si,{title:n("style-panel.font"),uiType:"font",style:co,items:yr.font,value:o,onValueChange:r,theme:e}),s===void 0?null:h.jsxs("div",{className:"tlui-style-panel__row",children:[h.jsx(Si,{title:n("style-panel.align"),uiType:"align",style:Hy,items:yr.textAlign,value:s,onValueChange:r,theme:e}),h.jsx("div",{className:"tlui-style-panel__row__extra-button",children:h.jsx(pe,{type:"icon",title:n("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:h.jsx(Ce,{icon:"vertical-align-middle"})})})]}),i===void 0?null:h.jsxs("div",{className:"tlui-style-panel__row",children:[h.jsx(Si,{title:n("style-panel.align"),uiType:"align",style:dp,items:yr.horizontalAlign,value:i,onValueChange:r,theme:e}),h.jsx("div",{className:"tlui-style-panel__row__extra-button",children:a===void 0?h.jsx(pe,{type:"icon",title:n("style-panel.vertical-align"),"data-testid":"vertical-align",disabled:!0,children:h.jsx(Ce,{icon:"vertical-align-middle"})}):h.jsx(xw,{type:"icon",id:"geo-vertical-alignment",uiType:"verticalAlign",style:hp,items:yr.verticalAlign,value:a,onValueChange:r})})]})]})}function Vne({styles:e}){const t=Fu(),n=e.get(ro);return n===void 0?null:h.jsx(xw,{id:"geo",type:"menu",label:"style-panel.geo",uiType:"geo",style:ro,items:yr.geo,value:n,onValueChange:t})}function Yne({styles:e}){const t=Fu(),n=e.get(pp);return n===void 0?null:h.jsx(xw,{id:"spline",type:"menu",label:"style-panel.spline",uiType:"spline",style:pp,items:yr.spline,value:n,onValueChange:t})}function Xne({styles:e}){const t=Fu(),n=e.get(up),r=e.get(lp);return!n||!r?null:h.jsx(Une,{label:"style-panel.arrowheads",uiTypeA:"arrowheadStart",styleA:lp,itemsA:yr.arrowheadStart,valueA:r,uiTypeB:"arrowheadEnd",styleB:up,itemsB:yr.arrowheadEnd,valueB:n,onValueChange:t,labelA:"style-panel.arrowhead-start",labelB:"style-panel.arrowhead-end"})}const nl=[.1,.25,.5,.75,1];function qne(){const e=z(),t=K("opacity",()=>e.getSharedOpacity(),[e]),n=xo(),r=Me(),o=Se.useCallback(i=>{const a=nl[i];e.batch(()=>{e.isIn("select")&&e.setOpacityForSelectedShapes(a),e.setOpacityForNextShapes(a),e.updateInstanceState({isChangingStyle:!0})}),n("set-style",{source:"style-panel",id:"opacity",value:i})},[e,n]);if(t===void 0)return null;const s=t.type==="mixed"?-1:nl.indexOf(LD(nl,i=>Math.abs(i-t.value)));return h.jsx(zne,{"data-testid":"style.opacity",value:s>=0?s:nl.length-1,label:t.type==="mixed"?"style-panel.mixed":`opacity-style.${t.value}`,onValueChange:o,steps:nl.length-1,title:r("style-panel.opacity")})}const Zne=x.memo(function({isMobile:t,children:n}){const r=z(),o=Cj(),s=x.useCallback(()=>{t||r.updateInstanceState({isChangingStyle:!1})},[r,t]),i=n??h.jsx(Kne,{styles:o});return h.jsx("div",{className:ue("tlui-style-panel",{"tlui-style-panel__wrapper":!t}),"data-ismobile":t,onPointerLeave:s,children:i})});function Qne(){const e=z(),t=Me(),n=Cj(),r=n==null?void 0:n.get(tr),o=Jo({isDarkMode:e.user.getIsDarkMode()}),s=((r==null?void 0:r.type)==="shared"?o[r.value]:o.black).solid,i=K("disable style panel",()=>e.isInAny("hand","zoom","eraser","laser"),[e]),a=x.useCallback(l=>{l||e.updateInstanceState({isChangingStyle:!1})},[e]),{StylePanel:c}=ti();return c?h.jsxs(cw,{id:"mobile style menu",onOpenChange:a,children:[h.jsx(lw,{children:h.jsx(pe,{type:"tool","data-testid":"mobile-styles.button",style:{color:i?"var(--color-muted-1)":s},title:t("style-panel.title"),disabled:i,children:h.jsx(Ce,{icon:i?"blob":(r==null?void 0:r.type)==="mixed"?"mixed":"blob"})})}),h.jsx(uw,{side:"top",align:"end",children:c&&h.jsx(c,{isMobile:!0})})]}):null}function Jne(){return h.jsxs(h.Fragment,{children:[h.jsx(ere,{}),h.jsx(tre,{}),h.jsx(nre,{}),h.jsx(rre,{}),h.jsx(ore,{}),h.jsx(sre,{}),h.jsx(ire,{}),h.jsx(are,{}),h.jsx(cre,{}),h.jsx(lre,{}),h.jsx(ure,{}),h.jsx(dre,{}),h.jsx(hre,{}),h.jsx(pre,{}),h.jsx(fre,{}),h.jsx(gre,{}),h.jsx(mre,{}),h.jsx(yre,{}),h.jsx(Sre,{}),h.jsx(vre,{}),h.jsx(xre,{}),h.jsx(wre,{}),h.jsx(bre,{}),h.jsx(Pre,{}),h.jsx(Cre,{}),h.jsx(Ire,{}),h.jsx(Ere,{}),h.jsx(_re,{})]})}function Ke(e){var r;const t=z(),n=(r=e.meta)==null?void 0:r.geo;return K("is tool selected",()=>{const o=t.getCurrentToolId(),s=t.getSharedStyles().getAsKnownValue(ro);return n?o==="geo"&&s===n:o===e.id},[t,e.id,n])}function ere(){const e=Le(),t=Ke(e.select);return h.jsx(F,{...e.select,isSelected:t})}function tre(){const e=Le(),t=Ke(e.hand);return h.jsx(F,{...e.hand,isSelected:t})}function nre(){const e=Le(),t=Ke(e.draw);return h.jsx(F,{...e.draw,isSelected:t})}function rre(){const e=Le(),t=Ke(e.eraser);return h.jsx(F,{...e.eraser,isSelected:t})}function ore(){const e=Le(),t=Ke(e.arrow);return h.jsx(F,{...e.arrow,isSelected:t})}function sre(){const e=Le(),t=Ke(e.text);return h.jsx(F,{...e.text,isSelected:t})}function ire(){const e=Le(),t=Ke(e.note);return h.jsx(F,{...e.note,isSelected:t})}function are(){const e=Le(),t=Ke(e.asset);return h.jsx(F,{...e.asset,isSelected:t})}function cre(){const e=Le(),t=Ke(e.rectangle);return h.jsx(F,{...e.rectangle,isSelected:t})}function lre(){const e=Le(),t=Ke(e.ellipse);return h.jsx(F,{...e.ellipse,isSelected:t})}function ure(){const e=Le(),t=Ke(e.diamond);return h.jsx(F,{...e.diamond,isSelected:t})}function dre(){const e=Le(),t=Ke(e.triangle);return h.jsx(F,{...e.triangle,isSelected:t})}function hre(){const e=Le(),t=Ke(e.trapezoid);return h.jsx(F,{...e.trapezoid,isSelected:t})}function pre(){const e=Le(),t=Ke(e.rhombus);return h.jsx(F,{...e.rhombus,isSelected:t})}function fre(){const e=Le(),t=Ke(e.hexagon);return h.jsx(F,{...e.hexagon,isSelected:t})}function gre(){const e=Le(),t=Ke(e.cloud);return h.jsx(F,{...e.cloud,isSelected:t})}function mre(){const e=Le(),t=Ke(e.star);return h.jsx(F,{...e.star,isSelected:t})}function yre(){const e=Le(),t=Ke(e.oval);return h.jsx(F,{...e.oval,isSelected:t})}function Sre(){const e=Le(),t=Ke(e["x-box"]);return h.jsx(F,{...e["x-box"],isSelected:t})}function vre(){const e=Le(),t=Ke(e["check-box"]);return h.jsx(F,{...e["check-box"],isSelected:t})}function xre(){const e=Le(),t=Ke(e["arrow-left"]);return h.jsx(F,{...e["arrow-left"],isSelected:t})}function wre(){const e=Le(),t=Ke(e["arrow-up"]);return h.jsx(F,{...e["arrow-up"],isSelected:t})}function bre(){const e=Le(),t=Ke(e["arrow-down"]);return h.jsx(F,{...e["arrow-down"],isSelected:t})}function Pre(){const e=Le(),t=Ke(e["arrow-right"]);return h.jsx(F,{...e["arrow-right"],isSelected:t})}function Cre(){const e=Le(),t=Ke(e.line);return h.jsx(F,{...e.line,isSelected:t})}function Ire(){const e=Le(),t=Ke(e.highlight);return h.jsx(F,{...e.highlight,isSelected:t})}function Ere(){const e=Le(),t=Ke(e.frame);return h.jsx(F,{...e.frame,isSelected:t})}function _re(){const e=Le(),t=Ke(e.laser);return h.jsx(F,{...e.laser,isSelected:t})}const dy=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function hy(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r):e.attachEvent&&e.attachEvent("on".concat(t),n)}function rl(e,t,n,r){e.removeEventListener?e.removeEventListener(t,n,r):e.detachEvent&&e.detachEvent("on".concat(t),n)}function Oj(e,t){const n=t.slice(0,t.length-1);for(let r=0;r<n.length;r++)n[r]=e[n[r].toLowerCase()];return n}function Dj(e){typeof e!="string"&&(e=""),e=e.replace(/\s/g,"");const t=e.split(",");let n=t.lastIndexOf("");for(;n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function kre(e,t){const n=e.length>=t.length?e:t,r=e.length>=t.length?t:e;let o=!0;for(let s=0;s<n.length;s++)r.indexOf(n[s])===-1&&(o=!1);return o}const gu={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,"-":dy?173:189,"=":dy?61:187,";":dy?59:186,"'":222,"[":219,"]":221,"\\":220},fo={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},Dv={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},zt={16:!1,18:!1,17:!1,91:!1},dt={};for(let e=1;e<20;e++)gu["f".concat(e)]=111+e;let Xe=[],Ml=null,Rj="all";const To=new Map,Nu=e=>gu[e.toLowerCase()]||fo[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),Tre=e=>Object.keys(gu).find(t=>gu[t]===e),$re=e=>Object.keys(fo).find(t=>fo[t]===e);function Lj(e){Rj=e||"all"}function mu(){return Rj||"all"}function Mre(){return Xe.slice(0)}function Are(){return Xe.map(e=>Tre(e)||$re(e)||String.fromCharCode(e))}function jre(){const e=[];return Object.keys(dt).forEach(t=>{dt[t].forEach(n=>{let{key:r,scope:o,mods:s,shortcut:i}=n;e.push({scope:o,shortcut:i,mods:s,keys:r.split("+").map(a=>Nu(a))})})}),e}function Ore(e){const t=e.target||e.srcElement,{tagName:n}=t;let r=!0;const o=n==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(o||n==="TEXTAREA"||n==="SELECT")&&!t.readOnly)&&(r=!1),r}function Dre(e){return typeof e=="string"&&(e=Nu(e)),Xe.indexOf(e)!==-1}function Rre(e,t){let n,r;e||(e=mu());for(const o in dt)if(Object.prototype.hasOwnProperty.call(dt,o))for(n=dt[o],r=0;r<n.length;)n[r].scope===e?n.splice(r,1).forEach(i=>{let{element:a}=i;return ww(a)}):r++;mu()===e&&Lj(t||"all")}function Lre(e){let t=e.keyCode||e.which||e.charCode;const n=Xe.indexOf(t);if(n>=0&&Xe.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&Xe.splice(0,Xe.length),(t===93||t===224)&&(t=91),t in zt){zt[t]=!1;for(const r in fo)fo[r]===t&&(Tn[r]=!1)}}function Fj(e){if(typeof e>"u")Object.keys(dt).forEach(o=>{Array.isArray(dt[o])&&dt[o].forEach(s=>Yd(s)),delete dt[o]}),ww(null);else if(Array.isArray(e))e.forEach(o=>{o.key&&Yd(o)});else if(typeof e=="object")e.key&&Yd(e);else if(typeof e=="string"){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];let[o,s]=n;typeof o=="function"&&(s=o,o=""),Yd({key:e,scope:o,method:s,splitKey:"+"})}}const Yd=e=>{let{key:t,scope:n,method:r,splitKey:o="+"}=e;Dj(t).forEach(i=>{const a=i.split(o),c=a.length,l=a[c-1],u=l==="*"?"*":Nu(l);if(!dt[u])return;n||(n=mu());const d=c>1?Oj(fo,a):[],p=[];dt[u]=dt[u].filter(f=>{const g=(r?f.method===r:!0)&&f.scope===n&&kre(f.mods,d);return g&&p.push(f.element),!g}),p.forEach(f=>ww(f))})};function xI(e,t,n,r){if(t.element!==r)return;let o;if(t.scope===n||t.scope==="all"){o=t.mods.length>0;for(const s in zt)Object.prototype.hasOwnProperty.call(zt,s)&&(!zt[s]&&t.mods.indexOf(+s)>-1||zt[s]&&t.mods.indexOf(+s)===-1)&&(o=!1);(t.mods.length===0&&!zt[16]&&!zt[18]&&!zt[17]&&!zt[91]||o||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(Xe),t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function wI(e,t){const n=dt["*"];let r=e.keyCode||e.which||e.charCode;if(!Tn.filter.call(this,e))return;if((r===93||r===224)&&(r=91),Xe.indexOf(r)===-1&&r!==229&&Xe.push(r),["ctrlKey","altKey","shiftKey","metaKey"].forEach(a=>{const c=Dv[a];e[a]&&Xe.indexOf(c)===-1?Xe.push(c):!e[a]&&Xe.indexOf(c)>-1?Xe.splice(Xe.indexOf(c),1):a==="metaKey"&&e[a]&&Xe.length===3&&(e.ctrlKey||e.shiftKey||e.altKey||(Xe=Xe.slice(Xe.indexOf(c))))}),r in zt){zt[r]=!0;for(const a in fo)fo[a]===r&&(Tn[a]=!0);if(!n)return}for(const a in zt)Object.prototype.hasOwnProperty.call(zt,a)&&(zt[a]=e[Dv[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(Xe.indexOf(17)===-1&&Xe.push(17),Xe.indexOf(18)===-1&&Xe.push(18),zt[17]=!0,zt[18]=!0);const o=mu();if(n)for(let a=0;a<n.length;a++)n[a].scope===o&&(e.type==="keydown"&&n[a].keydown||e.type==="keyup"&&n[a].keyup)&&xI(e,n[a],o,t);if(!(r in dt))return;const s=dt[r],i=s.length;for(let a=0;a<i;a++)if((e.type==="keydown"&&s[a].keydown||e.type==="keyup"&&s[a].keyup)&&s[a].key){const c=s[a],{splitKey:l}=c,u=c.key.split(l),d=[];for(let p=0;p<u.length;p++)d.push(Nu(u[p]));d.sort().join("")===Xe.sort().join("")&&xI(e,c,o,t)}}function Tn(e,t,n){Xe=[];const r=Dj(e);let o=[],s="all",i=document,a=0,c=!1,l=!0,u="+",d=!1,p=!1;for(n===void 0&&typeof t=="function"&&(n=t),Object.prototype.toString.call(t)==="[object Object]"&&(t.scope&&(s=t.scope),t.element&&(i=t.element),t.keyup&&(c=t.keyup),t.keydown!==void 0&&(l=t.keydown),t.capture!==void 0&&(d=t.capture),typeof t.splitKey=="string"&&(u=t.splitKey),t.single===!0&&(p=!0)),typeof t=="string"&&(s=t),p&&Fj(e,s);a<r.length;a++)e=r[a].split(u),o=[],e.length>1&&(o=Oj(fo,e)),e=e[e.length-1],e=e==="*"?"*":Nu(e),e in dt||(dt[e]=[]),dt[e].push({keyup:c,keydown:l,scope:s,mods:o,shortcut:r[a],method:n,key:r[a],splitKey:u,element:i});if(typeof i<"u"&&window){if(!To.has(i)){const f=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return wI(g,i)},y=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;wI(g,i),Lre(g)};To.set(i,{keydownListener:f,keyupListenr:y,capture:d}),hy(i,"keydown",f,d),hy(i,"keyup",y,d)}if(!Ml){const f=()=>{Xe=[]};Ml={listener:f,capture:d},hy(window,"focus",f,d)}}}function Fre(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(dt).forEach(n=>{dt[n].filter(o=>o.scope===t&&o.shortcut===e).forEach(o=>{o&&o.method&&o.method()})})}function ww(e){const t=Object.values(dt).flat();if(t.findIndex(r=>{let{element:o}=r;return o===e})<0){const{keydownListener:r,keyupListenr:o,capture:s}=To.get(e)||{};r&&o&&(rl(e,"keyup",o,s),rl(e,"keydown",r,s),To.delete(e))}if((t.length<=0||To.size<=0)&&(Object.keys(To).forEach(o=>{const{keydownListener:s,keyupListenr:i,capture:a}=To.get(o)||{};s&&i&&(rl(o,"keyup",i,a),rl(o,"keydown",s,a),To.delete(o))}),To.clear(),Object.keys(dt).forEach(o=>delete dt[o]),Ml)){const{listener:o,capture:s}=Ml;rl(window,"focus",o,s),Ml=null}}const py={getPressedKeyString:Are,setScope:Lj,getScope:mu,deleteScope:Rre,getPressedKeyCodes:Mre,getAllKeyCodes:jre,isPressed:Dre,filter:Ore,trigger:Fre,unbind:Fj,keyMap:gu,modifier:fo,modifierMap:Dv};for(const e in py)Object.prototype.hasOwnProperty.call(py,e)&&(Tn[e]=py[e]);if(typeof window<"u"){const e=window.hotkeys;Tn.noConflict=t=>(t&&window.hotkeys===Tn&&(window.hotkeys=e),Tn),window.hotkeys=Tn}const bI=["copy","cut","paste","asset"];function Nre(){const e=z(),t=rs(),n=ce(),r=Le(),o=K("is focused",()=>e.getInstanceState().isFocused,[e]);x.useEffect(()=>{if(!o)return;const s=e.getContainer();Tn.setScope(e.store.id);const i=(c,l)=>{Tn(c,{element:document.body,scope:e.store.id},l)},a=(c,l)=>{Tn(c,{element:document.body,keyup:!0,keydown:!1,scope:e.store.id},l)};for(const c of Object.values(n))c.kbd&&(t&&!c.readonlyOk||bI.includes(c.id)||i(PI(c.kbd),l=>{pl(e)||(ke(l),c.onSelect("kbd"))}));for(const c of Object.values(r))!c.kbd||!c.readonlyOk&&e.getInstanceState().isReadonly||bI.includes(c.id)||i(PI(c.kbd),l=>{pl(e)||(ke(l),c.onSelect("kbd"))});return i(",",c=>{if(pl(e)||e.inputs.keys.has("Comma"))return;ke(c),s.focus(),e.inputs.keys.add("Comma");const{x:l,y:u,z:d}=e.inputs.currentScreenPoint,p={type:"pointer",name:"pointer_down",point:{x:l,y:u,z:d},shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.metaKey||c.ctrlKey,pointerId:0,button:0,isPen:e.getInstanceState().isPenMode,target:"canvas"};e.dispatch(p)}),a(",",c=>{if(pl(e)||!e.inputs.keys.has("Comma"))return;e.inputs.keys.delete("Comma");const{x:l,y:u,z:d}=e.inputs.currentScreenPoint,p={type:"pointer",name:"pointer_up",point:{x:l,y:u,z:d},shiftKey:c.shiftKey,altKey:c.altKey,ctrlKey:c.metaKey||c.ctrlKey,pointerId:0,button:0,isPen:e.getInstanceState().isPenMode,target:"canvas"};e.dispatch(p)}),()=>{Tn.deleteScope(e.store.id)}},[n,r,t,e,o])}function PI(e){return zre(e).map(t=>{let n="";const r=t.split("");return r.length===1?n=r[0]:r[0]==="!"?n=`shift+${r[1]}`:r[0]==="?"?r.length===3&&r[1]==="!"?n=`alt+shift+${r[2]}`:n=`alt+${r[1]}`:r[0]==="$"?r[1]==="!"?n=`cmd+shift+${r[2]},ctrl+shift+${r[2]}`:r[1]==="?"?n=`cmd+⌥+${r[2]},ctrl+alt+${r[2]}`:n=`cmd+${r[1]},ctrl+${r[1]}`:n=t,n}).join(",")}function zre(e){typeof e!="string"&&(e=""),e=e.replace(/\s/g,"");const t=e.split(",");let n=t.lastIndexOf("");for(;n>=0;)t[n-1]+=",",t.splice(n,1),n=t.lastIndexOf("");return t}function pl(e){return e.getIsMenuOpen()||e.getEditingShapeId()!==null||e.getCrashingError()}const Bre=x.createContext(!1);function Ure({children:e}){const t=z(),n=$8(),r=Rn(),o=Me(),s=Math.min(8,5+r),[i,a]=x.useState(0),c=x.useRef(null),[l,u]=x.useState(null),d=x.useMemo(()=>{const f=[],y=[];l?f.push(`[data-value="${l}"]`):f.push(`:nth-child(${s+1})`);for(let g=0;g<s;g++)f.push(`:nth-child(${g+1})`),y.push(`:nth-child(${g+1})`);return`
|
|
331
|
-
#${n}_main > *:not(${f.join(", ")}) {
|
|
332
|
-
display: none;
|
|
333
|
-
}
|
|
334
|
-
${y.map(g=>`#${n}_more > *${g}`).join(", ")} {
|
|
335
|
-
display: none;
|
|
336
|
-
}
|
|
337
|
-
`},[l,n,s]),p=cx(()=>{if(!c.current)return;const f=Array.from(c.current.children);a(f.length),f.findIndex(w=>w.getAttribute("data-value")===l)<=s&&u(null);const g=Array.from(c.current.children).findIndex(w=>w.getAttribute("aria-checked")==="true");g!==-1&&g>=s&&u(f[g].getAttribute("data-value"))});return x.useLayoutEffect(()=>{p()}),x.useLayoutEffect(()=>{if(!c.current)return;const f=new MutationObserver(p);return f.observe(c.current,{childList:!0,subtree:!0,attributeFilter:["data-value","aria-checked"]}),()=>{f.disconnect()}},[p]),x.useEffect(()=>{const f=[["1",0],["2",1],["3",2],["4",3],["5",4],["6",5],["7",6],["8",7],["9",8],["0",9]];for(const[y,g]of f)Tn(y,w=>{var P;if(pl(t))return;ke(w);const v=Array.from(((P=c.current)==null?void 0:P.children)??[]).filter(I=>!(I instanceof HTMLElement)||I.tagName.toLowerCase()!=="button"?!1:!!(I.offsetWidth||I.offsetHeight))[g];v&&v.click()});return()=>{Tn.unbind("1,2,3,4,5,6,7,8,9,0")}},[t]),h.jsxs(h.Fragment,{children:[h.jsx("style",{children:d}),h.jsxs("div",{className:ue("tlui-toolbar__tools",{"tlui-toolbar__tools__mobile":r<vt.TABLET_SM}),role:"radiogroup",children:[h.jsx("div",{id:`${n}_main`,ref:c,className:"tlui-toolbar__tools__list",children:h.jsx(br,{type:"toolbar",sourceId:"toolbar",children:e})}),i>s&&h.jsx(Bre.Provider,{value:!0,children:h.jsxs(Di,{id:"toolbar overflow",modal:!1,children:[h.jsx(Ri,{children:h.jsx(pe,{title:o("tool-panel.more"),type:"tool",className:"tlui-toolbar__overflow","data-testid":"tools.more-button",children:h.jsx(Ce,{icon:"chevron-up"})})}),h.jsx(Li,{side:"top",align:"center",children:h.jsx("div",{className:"tlui-buttons__grid","data-testid":"tools.more-content",id:`${n}_more`,children:h.jsx(br,{type:"toolbar-overflow",sourceId:"toolbar",children:e})})})]})})]})]})}const Hre=["select","hand","draw","eraser","text","zoom","laser","highlight"];function Kre({activeToolId:e}){const t=z(),n=Rn(),r=Me(),o=K("is tool locked",()=>t.getInstanceState().isToolLocked,[t]);return!e||Hre.includes(e)?null:h.jsx(pe,{type:"normal",title:r("action.toggle-tool-lock"),"data-testid":"tool-lock",className:ue("tlui-toolbar__lock-button",{"tlui-toolbar__lock-button__mobile":n<vt.TABLET_SM}),onClick:()=>t.updateInstanceState({isToolLocked:!o}),children:h.jsx(Ce,{icon:o?"lock":"unlock",small:!0})})}const Wre=x.memo(function({children:t}){const n=z(),r=Rn(),o=rs(),s=K("current tool id",()=>n.getCurrentToolId(),[n]),{ActionsMenu:i,QuickActions:a}=ti();return h.jsx("div",{className:"tlui-toolbar",children:h.jsxs("div",{className:"tlui-toolbar__inner",children:[h.jsxs("div",{className:"tlui-toolbar__left",children:[!o&&h.jsxs("div",{className:"tlui-toolbar__extras",children:[r<vt.TABLET&&h.jsxs("div",{className:"tlui-toolbar__extras__controls tlui-buttons__horizontal",children:[a&&h.jsx(a,{}),i&&h.jsx(i,{})]}),h.jsx(Kre,{activeToolId:s})]}),h.jsx(Ure,{children:t??h.jsx(Jne,{})})]}),r<vt.TABLET_SM&&!o&&h.jsx("div",{className:"tlui-toolbar__tools",children:h.jsx(Qne,{})})]})})});function Gre(){const e=ce();return h.jsxs(h.Fragment,{children:[h.jsx(F,{...e["zoom-in"],noClose:!0}),h.jsx(F,{...e["zoom-out"],noClose:!0}),h.jsx(pj,{}),h.jsx(fj,{}),h.jsx(gj,{})]})}const Vre=x.memo(function({children:t}){const n=Xt(),[r,o]=Qs("zoom menu"),s=t??h.jsx(Gre,{});return h.jsxs(gw,{dir:"ltr",open:r,onOpenChange:o,modal:!1,children:[h.jsx(mw,{asChild:!0,dir:"ltr",children:h.jsx(Yre,{})}),h.jsx(mg,{container:n,children:h.jsx(yw,{className:"tlui-menu",side:"top",align:"start",alignOffset:0,sideOffset:8,collisionPadding:4,children:h.jsx(br,{type:"menu",sourceId:"zoom-menu",children:s})})})]})}),Yre=x.forwardRef(function(t,n){const r=z(),o=Rn(),s=K("zoom",()=>r.getZoomLevel(),[r]),i=Me(),a=x.useCallback(()=>{r.resetZoom(r.getViewportScreenCenter(),{animation:{duration:Qr}})},[r]);return h.jsx(pe,{ref:n,...t,type:"icon",title:`${i("navigation-zone.zoom")}`,"data-testid":"minimap.zoom-menu-button",className:o<vt.TABLET_SM?"tlui-zoom-menu__button":"tlui-zoom-menu__button__pct",onDoubleClick:a,icon:o<vt.MOBILE?"zoom-in":void 0,children:o<vt.MOBILE?null:h.jsxs("span",{style:{flexGrow:0,textAlign:"center"},children:[Math.floor(s*100),"%"]})})}),Nj=x.createContext({});function Xre({overrides:e={},children:t}){const n=l0(e);return h.jsx(Nj.Provider,{value:x.useMemo(()=>({ContextMenu:Cte,ActionsMenu:ete,HelpMenu:Lte,ZoomMenu:Vre,MainMenu:ene,Minimap:ine,StylePanel:Zne,PageMenu:une,NavigationPanel:cne,Toolbar:Wre,KeyboardShortcutsDialog:Kte,QuickActions:hne,HelperButtons:Ute,DebugPanel:Mte,DebugMenu:$te,MenuPanel:tne,...n}),[n]),children:t})}function ti(){return x.useContext(Nj)}function qre({overrides:e,components:t,assetUrls:n,onUiEvent:r,forceMobile:o,children:s}){return h.jsx(cY,{assetUrls:Xq(n),children:h.jsx(dY,{overrides:eZ(e),children:h.jsx(Dq,{onEvent:r,children:h.jsx(Uq,{children:h.jsx(Rq,{children:h.jsx(Zq,{forceMobile:o,children:h.jsx(Xre,{overrides:t,children:h.jsx(Zre,{overrides:e,children:s})})})})})})})})}function Zre({overrides:e,children:t}){const n=tZ(e);return h.jsx(FZ,{overrides:n.actions,children:h.jsx(qq,{overrides:n.tools,children:t})})}function Qre(){const e=z(),{addToast:t}=Wr();x.useEffect(()=>{function n({name:r,count:o}){t({title:"Maximum Shapes Reached",description:`You've reached the maximum number of shapes allowed on ${r} (${o}). Please delete some shapes or move to a different page to continue.`,severity:"warning"})}return e.addListener("max-shapes",n),()=>{e.removeListener("max-shapes",n)}},[e,t])}const Jre=Se.memo(function({renderDebugMenuItems:t,children:n,hideUi:r,components:o,...s}){return h.jsx(qre,{...s,components:o,children:h.jsx(eoe,{hideUi:r,renderDebugMenuItems:t,children:n})})}),eoe=Se.memo(function({children:t,hideUi:n,...r}){return h.jsxs(h.Fragment,{children:[t,n?null:h.jsx(toe,{...r})]})}),toe=Se.memo(function(){const t=z(),n=Me(),r=Rn(),o=rs(),s=K("focus",()=>t.getInstanceState().isFocusMode,[t]),i=K("debug",()=>t.getInstanceState().isDebugMode,[t]),{SharePanel:a,TopPanel:c,MenuPanel:l,StylePanel:u,Toolbar:d,HelpMenu:p,NavigationPanel:f,HelperButtons:y,DebugPanel:g}=ti();Nre(),_Z(),Qre();const{"toggle-focus-mode":w}=ce();return h.jsx(wM,{children:h.jsxs("div",{className:ue("tlui-layout",{"tlui-layout__mobile":r<vt.TABLET_SM}),"data-breakpoint":r,children:[s?h.jsx("div",{className:"tlui-layout__top",children:h.jsx(pe,{type:"icon",className:"tlui-focus-button",title:n("focus-mode.toggle-focus-mode"),onClick:()=>w.onSelect("menu"),children:h.jsx(Ce,{icon:"dot"})})}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"tlui-layout__top",children:[h.jsxs("div",{className:"tlui-layout__top__left",children:[l&&h.jsx(l,{}),y&&h.jsx(y,{})]}),h.jsx("div",{className:"tlui-layout__top__center",children:c&&h.jsx(c,{})}),h.jsxs("div",{className:"tlui-layout__top__right",children:[a&&h.jsx(a,{}),u&&r>=vt.TABLET_SM&&!o&&h.jsx(u,{})]})]}),h.jsxs("div",{className:"tlui-layout__bottom",children:[h.jsxs("div",{className:"tlui-layout__bottom__main",children:[f&&h.jsx(f,{}),d&&h.jsx(d,{}),p&&h.jsx(p,{})]}),i&&g&&h.jsx(g,{})]})]}),h.jsx(Gq,{}),h.jsx(Nq,{}),h.jsx(Vq,{}),h.jsx(zq,{})]})})}),Xd=(e,t)=>{const[n,r]=x.useState(2);return x.useEffect(()=>{let o=!1;return r(2),mD(e,t).then(()=>{o||r(0)}).catch(s=>{o||(console.error(s),r(1))}),()=>{o=!0}},[e,t]),n};function noe(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 zj(e){const t=x.useMemo(()=>noe(e),[e]),n=[Xd("tldraw_draw",t.draw),Xd("tldraw_serif",t.serif),Xd("tldraw_sans",t.sansSerif),Xd("tldraw_mono",t.monospace)];return{error:n.some(r=>r===1),done:!n.some(r=>r===2)}}function roe(e){const{children:t,maxImageDimension:n,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i,components:a={},shapeUtils:c=[],tools:l=[],...u}=e,d=l0(a),p=x.useMemo(()=>({Scribble:oC,CollaboratorScribble:oC,SelectionForeground:BW,SelectionBackground:NW,Handles:OW,...d}),[d]),f=Yy(c),y=x.useMemo(()=>[...H$,...f],[f]),g=Yy(l),w=x.useMemo(()=>[...RY,...FG,...g],[g]),S=GM(u.assetUrls),{done:v,error:P}=zj(S);return P?h.jsx(e2,{children:"Could not load assets. Please refresh the page."}):v?h.jsx(b8,{initialState:"select",...u,components:p,shapeUtils:y,tools:w,children:h.jsxs(Jre,{...u,components:p,children:[h.jsx(ioe,{maxImageDimension:n,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i}),t]})}):h.jsx(JT,{children:"Loading assets..."})}const ooe=Object.freeze(["image/jpeg","image/png","image/gif","image/svg+xml"]),soe=Object.freeze(["video/mp4","video/quicktime"]);function ioe({maxImageDimension:e=1e3,maxAssetSize:t=10*1024*1024,acceptedImageMimeTypes:n=ooe,acceptedVideoMimeTypes:r=soe,onMount:o}){const s=z(),i=Wr(),a=Me(),c=cx(d=>{const p=[];return p.push(...xY(d)),wG(d,{maxImageDimension:e,maxAssetSize:t,acceptedImageMimeTypes:n,acceptedVideoMimeTypes:r},{toasts:i,msg:a}),p.push(o==null?void 0:o(d)),()=>{p.forEach(f=>f==null?void 0:f())}});x.useLayoutEffect(()=>{if(s)return c==null?void 0:c(s)},[s,c]);const{Canvas:l}=pt(),{ContextMenu:u}=ti();return u?h.jsx(u,{}):l?h.jsx(l,{}):null}x.memo(function(t){const[n,r]=x.useState(null),[o,s]=x.useState(null),i=Yy(t.shapeUtils??[]),a=x.useMemo(()=>[...H$,...i],[i]),c=XT({snapshot:t.snapshot,shapeUtils:a}),l=GM(),{done:u,error:d}=zj(l),{pageId:p,bounds:f,scale:y,background:g,padding:w,darkMode:S,preserveAspectRatio:v,format:P="svg"}=t;return x.useLayoutEffect(()=>{if(!o||!c||!u)return;let I=!1;const C=document.createElement("div");o.appendChild(C),o.classList.add("tl-container","tl-theme__light");const E=new ne({store:c,shapeUtils:a??[],tools:[],getContainer:()=>C});p&&E.setCurrentPage(p);const _=E.getCurrentPageShapeIds();async function k(){const $=await E.getSvgString([..._],{bounds:f,scale:y,background:g,padding:w,darkMode:S,preserveAspectRatio:v});if($&&!I){if(P==="svg"){if(!I){const T=new Blob([$.svg],{type:"image/svg+xml"}),A=URL.createObjectURL(T);r(A)}}else if(P==="png"){const T=await nA($.svg,E.environment.isSafari,{type:P,quality:1,scale:2,width:$.width,height:$.height});if(T&&!I){const A=URL.createObjectURL(T);r(A)}}}E.dispose()}return k(),()=>{I=!0}},[P,o,c,a,p,f,y,g,w,S,v,u,d]),d?h.jsx(e2,{children:"Could not load assets."}):u?h.jsx("div",{ref:s,style:{position:"relative",width:"100%",height:"100%"},children:n&&h.jsx("img",{src:n,style:{width:"100%",height:"100%"}})}):h.jsx(JT,{children:"Loading assets..."})});const aoe=1,coe=ve({schemaVersion:an(1),storeVersion:eh,recordVersions:ip(ge,ve({version:eh,subTypeVersions:ip(ge,eh).optional(),subTypeKey:ge.optional()}))}),loe=ve({schemaVersion:an(2),sequences:ip(ge,eh)}),uoe=ve({tldrawFileFormatVersion:mR,schema:yR("schemaVersion",{1:coe,2:loe}),records:Ut(ve({id:ge,typeName:ge}).allowUnknownProperties())});function doe(e){var t;try{return!!((t=e.document)!=null&&t.version)}catch{return!1}}function hoe({json:e,schema:t}){let n;try{n=uoe.validate(JSON.parse(e))}catch(o){try{if(n=JSON.parse(e),doe(n))return Wn.err({type:"v1File",data:n})}catch{}return Wn.err({type:"notATldrawFile",cause:o})}if(n.tldrawFileFormatVersion>aoe)return Wn.err({type:"fileFormatVersionTooNew",version:n.tldrawFileFormatVersion});let r;try{const o=Object.fromEntries(n.records.map(s=>[s.id,s]));r=t.migrateStoreSnapshot({store:o,schema:n.schema})}catch(o){return Wn.err({type:"invalidRecords",cause:o})}if(r.type==="error")return Wn.err({type:"migrationFailed",reason:r.reason});try{return Wn.ok(YT({initialData:r.value,schema:t}))}catch(o){return Wn.err({type:"invalidRecords",cause:o})}}function poe(){const[e,t]=x.useState();function n(r){window.editor=r,e===void 0?fetch("/tldr-data").then(async o=>{if(!o.ok){console.log(`No tldr data to load from local endpoint (${o.status})`);return}return o.text()}).then(o=>{if(o===void 0)return;const s=hoe({json:o,schema:r.store.schema});s.ok?(console.log("Loaded tldr file from local endpoint"),t(s.value)):console.error(`Couldn't parse tldr file: ${String(s.error.type)}`)}).catch(o=>{console.error("Couldn't fetch data:",o)}):(r.zoomToFit(),r.clearOpenMenus())}return h.jsx("div",{style:{inset:0,position:"fixed"},children:h.jsx(roe,{assetUrls:gD(),onMount:n,store:e})})}BS.createRoot(document.querySelector("#root")).render(h.jsx(Se.StrictMode,{children:h.jsx(poe,{})}));
|