Files
Excalidraw/excalidraw/excalidraw-app/build/assets/index-2K3MavtT.js
T
Yuzhong Zhang b9ba07ea5d app init
2025-07-05 23:27:59 +08:00

373 lines
1.1 MiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var DA=Object.defineProperty;var OA=(e,t,n)=>t in e?DA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var M=(e,t,n)=>(OA(e,typeof t!="symbol"?t+"":t,n),n);function NA(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(r,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>r[i]})}}}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 i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();var ph=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var y5={exports:{}},y1={},v5={exports:{}},Te={};/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Ud=Symbol.for("react.element"),FA=Symbol.for("react.portal"),$A=Symbol.for("react.fragment"),BA=Symbol.for("react.strict_mode"),zA=Symbol.for("react.profiler"),HA=Symbol.for("react.provider"),UA=Symbol.for("react.context"),WA=Symbol.for("react.forward_ref"),VA=Symbol.for("react.suspense"),GA=Symbol.for("react.memo"),jA=Symbol.for("react.lazy"),Gw=Symbol.iterator;function YA(e){return e===null||typeof e!="object"?null:(e=Gw&&e[Gw]||e["@@iterator"],typeof e=="function"?e:null)}var E5={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w5=Object.assign,b5={};function ic(e,t,n){this.props=e,this.context=t,this.refs=b5,this.updater=n||E5}ic.prototype.isReactComponent={};ic.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")};ic.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function _5(){}_5.prototype=ic.prototype;function zy(e,t,n){this.props=e,this.context=t,this.refs=b5,this.updater=n||E5}var Hy=zy.prototype=new _5;Hy.constructor=zy;w5(Hy,ic.prototype);Hy.isPureReactComponent=!0;var jw=Array.isArray,x5=Object.prototype.hasOwnProperty,Uy={current:null},S5={key:!0,ref:!0,__self:!0,__source:!0};function k5(e,t,n){var r,i={},o=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(o=""+t.key),t)x5.call(t,r)&&!S5.hasOwnProperty(r)&&(i[r]=t[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1<a){for(var l=Array(a),c=0;c<a;c++)l[c]=arguments[c+2];i.children=l}if(e&&e.defaultProps)for(r in a=e.defaultProps,a)i[r]===void 0&&(i[r]=a[r]);return{$$typeof:Ud,type:e,key:o,ref:s,props:i,_owner:Uy.current}}function KA(e,t){return{$$typeof:Ud,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Wy(e){return typeof e=="object"&&e!==null&&e.$$typeof===Ud}function ZA(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Yw=/\/+/g;function Ng(e,t){return typeof e=="object"&&e!==null&&e.key!=null?ZA(""+e.key):t.toString(36)}function hf(e,t,n,r,i){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(o){case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case Ud:case FA:s=!0}}if(s)return s=e,i=i(s),e=r===""?"."+Ng(s,0):r,jw(i)?(n="",e!=null&&(n=e.replace(Yw,"$&/")+"/"),hf(i,t,n,"",function(c){return c})):i!=null&&(Wy(i)&&(i=KA(i,n+(!i.key||s&&s.key===i.key?"":(""+i.key).replace(Yw,"$&/")+"/")+e)),t.push(i)),1;if(s=0,r=r===""?".":r+":",jw(e))for(var a=0;a<e.length;a++){o=e[a];var l=r+Ng(o,a);s+=hf(o,t,n,l,i)}else if(l=YA(e),typeof l=="function")for(e=l.call(e),a=0;!(o=e.next()).done;)o=o.value,l=r+Ng(o,a++),s+=hf(o,t,n,l,i);else if(o==="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 s}function yh(e,t,n){if(e==null)return e;var r=[],i=0;return hf(e,r,"","",function(o){return t.call(n,o,i++)}),r}function XA(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 In={current:null},ff={transition:null},qA={ReactCurrentDispatcher:In,ReactCurrentBatchConfig:ff,ReactCurrentOwner:Uy};Te.Children={map:yh,forEach:function(e,t,n){yh(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return yh(e,function(){t++}),t},toArray:function(e){return yh(e,function(t){return t})||[]},only:function(e){if(!Wy(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Te.Component=ic;Te.Fragment=$A;Te.Profiler=zA;Te.PureComponent=zy;Te.StrictMode=BA;Te.Suspense=VA;Te.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=qA;Te.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=w5({},e.props),i=e.key,o=e.ref,s=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,s=Uy.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(l in t)x5.call(t,l)&&!S5.hasOwnProperty(l)&&(r[l]=t[l]===void 0&&a!==void 0?a[l]:t[l])}var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];r.children=a}return{$$typeof:Ud,type:e.type,key:i,ref:o,props:r,_owner:s}};Te.createContext=function(e){return e={$$typeof:UA,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:HA,_context:e},e.Consumer=e};Te.createElement=k5;Te.createFactory=function(e){var t=k5.bind(null,e);return t.type=e,t};Te.createRef=function(){return{current:null}};Te.forwardRef=function(e){return{$$typeof:WA,render:e}};Te.isValidElement=Wy;Te.lazy=function(e){return{$$typeof:jA,_payload:{_status:-1,_result:e},_init:XA}};Te.memo=function(e,t){return{$$typeof:GA,type:e,compare:t===void 0?null:t}};Te.startTransition=function(e){var t=ff.transition;ff.transition={};try{e()}finally{ff.transition=t}};Te.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};Te.useCallback=function(e,t){return In.current.useCallback(e,t)};Te.useContext=function(e){return In.current.useContext(e)};Te.useDebugValue=function(){};Te.useDeferredValue=function(e){return In.current.useDeferredValue(e)};Te.useEffect=function(e,t){return In.current.useEffect(e,t)};Te.useId=function(){return In.current.useId()};Te.useImperativeHandle=function(e,t,n){return In.current.useImperativeHandle(e,t,n)};Te.useInsertionEffect=function(e,t){return In.current.useInsertionEffect(e,t)};Te.useLayoutEffect=function(e,t){return In.current.useLayoutEffect(e,t)};Te.useMemo=function(e,t){return In.current.useMemo(e,t)};Te.useReducer=function(e,t,n){return In.current.useReducer(e,t,n)};Te.useRef=function(e){return In.current.useRef(e)};Te.useState=function(e){return In.current.useState(e)};Te.useSyncExternalStore=function(e,t,n){return In.current.useSyncExternalStore(e,t,n)};Te.useTransition=function(){return In.current.useTransition()};Te.version="18.2.0";v5.exports=Te;var _=v5.exports;const te=rc(_),QA=NA({__proto__:null,default:te},[_]);/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var JA=_,eL=Symbol.for("react.element"),tL=Symbol.for("react.fragment"),nL=Object.prototype.hasOwnProperty,rL=JA.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,iL={key:!0,ref:!0,__self:!0,__source:!0};function I5(e,t,n){var r,i={},o=null,s=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(s=t.ref);for(r in t)nL.call(t,r)&&!iL.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:eL,type:e,key:o,ref:s,props:i,_owner:rL.current}}y1.Fragment=tL;y1.jsx=I5;y1.jsxs=I5;y5.exports=y1;var Vy=y5.exports;const re=Vy.Fragment,f=Vy.jsx,k=Vy.jsxs;var C5={exports:{}},or={},T5={exports:{}},M5={};/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/(function(e){function t($,Y){var R=$.length;$.push(Y);e:for(;0<R;){var N=R-1>>>1,B=$[N];if(0<i(B,Y))$[N]=Y,$[R]=B,R=N;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var Y=$[0],R=$.pop();if(R!==Y){$[0]=R;e:for(var N=0,B=$.length,z=B>>>1;N<z;){var W=2*(N+1)-1,j=$[W],X=W+1,ee=$[X];if(0>i(j,R))X<B&&0>i(ee,j)?($[N]=ee,$[X]=R,N=X):($[N]=j,$[W]=R,N=W);else if(X<B&&0>i(ee,R))$[N]=ee,$[X]=R,N=X;else break e}}return Y}function i($,Y){var R=$.sortIndex-Y.sortIndex;return R!==0?R:$.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var s=Date,a=s.now();e.unstable_now=function(){return s.now()-a}}var l=[],c=[],u=1,d=null,h=3,m=!1,g=!1,p=!1,v=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w($){for(var Y=n(c);Y!==null;){if(Y.callback===null)r(c);else if(Y.startTime<=$)r(c),Y.sortIndex=Y.expirationTime,t(l,Y);else break;Y=n(c)}}function x($){if(p=!1,w($),!g)if(n(l)!==null)g=!0,q(C);else{var Y=n(c);Y!==null&&U(x,Y.startTime-$)}}function C($,Y){g=!1,p&&(p=!1,y(T),T=-1),m=!0;var R=h;try{for(w(Y),d=n(l);d!==null&&(!(d.expirationTime>Y)||$&&!F());){var N=d.callback;if(typeof N=="function"){d.callback=null,h=d.priorityLevel;var B=N(d.expirationTime<=Y);Y=e.unstable_now(),typeof B=="function"?d.callback=B:d===n(l)&&r(l),w(Y)}else r(l);d=n(l)}if(d!==null)var z=!0;else{var W=n(c);W!==null&&U(x,W.startTime-Y),z=!1}return z}finally{d=null,h=R,m=!1}}var S=!1,I=null,T=-1,L=5,A=-1;function F(){return!(e.unstable_now()-A<L)}function P(){if(I!==null){var $=e.unstable_now();A=$;var Y=!0;try{Y=I(!0,$)}finally{Y?O():(S=!1,I=null)}}else S=!1}var O;if(typeof E=="function")O=function(){E(P)};else if(typeof MessageChannel<"u"){var V=new MessageChannel,G=V.port2;V.port1.onmessage=P,O=function(){G.postMessage(null)}}else O=function(){v(P,0)};function q($){I=$,S||(S=!0,O())}function U($,Y){T=v(function(){$(e.unstable_now())},Y)}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($){$.callback=null},e.unstable_continueExecution=function(){g||m||(g=!0,q(C))},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(l)},e.unstable_next=function($){switch(h){case 1:case 2:case 3:var Y=3;break;default:Y=h}var R=h;h=Y;try{return $()}finally{h=R}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,Y){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var R=h;h=$;try{return Y()}finally{h=R}},e.unstable_scheduleCallback=function($,Y,R){var N=e.unstable_now();switch(typeof R=="object"&&R!==null?(R=R.delay,R=typeof R=="number"&&0<R?N+R:N):R=N,$){case 1:var B=-1;break;case 2:B=250;break;case 5:B=1073741823;break;case 4:B=1e4;break;default:B=5e3}return B=R+B,$={id:u++,callback:Y,priorityLevel:$,startTime:R,expirationTime:B,sortIndex:-1},R>N?($.sortIndex=R,t(c,$),n(l)===null&&$===n(c)&&(p?(y(T),T=-1):p=!0,U(x,R-N))):($.sortIndex=B,t(l,$),g||m||(g=!0,q(C))),$},e.unstable_shouldYield=F,e.unstable_wrapCallback=function($){var Y=h;return function(){var R=h;h=Y;try{return $.apply(this,arguments)}finally{h=R}}}})(M5);T5.exports=M5;var oL=T5.exports;/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var A5=_,ir=oL;function Q(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 L5=new Set,ju={};function La(e,t){Fl(e,t),Fl(e+"Capture",t)}function Fl(e,t){for(ju[e]=t,e=0;e<t.length;e++)L5.add(t[e])}var Zi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_0=Object.prototype.hasOwnProperty,sL=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Kw={},Zw={};function aL(e){return _0.call(Zw,e)?!0:_0.call(Kw,e)?!1:sL.test(e)?Zw[e]=!0:(Kw[e]=!0,!1)}function lL(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 cL(e,t,n,r){if(t===null||typeof t>"u"||lL(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 Cn(e,t,n,r,i,o,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=s}var Jt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Jt[e]=new Cn(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Jt[t]=new Cn(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Jt[e]=new Cn(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Jt[e]=new Cn(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){Jt[e]=new Cn(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Jt[e]=new Cn(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Jt[e]=new Cn(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Jt[e]=new Cn(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Jt[e]=new Cn(e,5,!1,e.toLowerCase(),null,!1,!1)});var Gy=/[\-:]([a-z])/g;function jy(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(Gy,jy);Jt[t]=new Cn(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(Gy,jy);Jt[t]=new Cn(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(Gy,jy);Jt[t]=new Cn(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Jt[e]=new Cn(e,1,!1,e.toLowerCase(),null,!1,!1)});Jt.xlinkHref=new Cn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Jt[e]=new Cn(e,1,!1,e.toLowerCase(),null,!0,!0)});function Yy(e,t,n,r){var i=Jt.hasOwnProperty(t)?Jt[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(cL(t,n,i,r)&&(n=null),r||i===null?aL(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:"":n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var io=A5.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,vh=Symbol.for("react.element"),tl=Symbol.for("react.portal"),nl=Symbol.for("react.fragment"),Ky=Symbol.for("react.strict_mode"),x0=Symbol.for("react.profiler"),P5=Symbol.for("react.provider"),R5=Symbol.for("react.context"),Zy=Symbol.for("react.forward_ref"),S0=Symbol.for("react.suspense"),k0=Symbol.for("react.suspense_list"),Xy=Symbol.for("react.memo"),Eo=Symbol.for("react.lazy"),D5=Symbol.for("react.offscreen"),Xw=Symbol.iterator;function kc(e){return e===null||typeof e!="object"?null:(e=Xw&&e[Xw]||e["@@iterator"],typeof e=="function"?e:null)}var ft=Object.assign,Fg;function iu(e){if(Fg===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Fg=t&&t[1]||""}return`
`+Fg+e}var $g=!1;function Bg(e,t){if(!e||$g)return"";$g=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(c){var r=c}Reflect.construct(e,[],t)}else{try{t.call()}catch(c){r=c}e.call(t.prototype)}else{try{throw Error()}catch(c){r=c}e()}}catch(c){if(c&&r&&typeof c.stack=="string"){for(var i=c.stack.split(`
`),o=r.stack.split(`
`),s=i.length-1,a=o.length-1;1<=s&&0<=a&&i[s]!==o[a];)a--;for(;1<=s&&0<=a;s--,a--)if(i[s]!==o[a]){if(s!==1||a!==1)do if(s--,a--,0>a||i[s]!==o[a]){var l=`
`+i[s].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}while(1<=s&&0<=a);break}}}finally{$g=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?iu(e):""}function uL(e){switch(e.tag){case 5:return iu(e.type);case 16:return iu("Lazy");case 13:return iu("Suspense");case 19:return iu("SuspenseList");case 0:case 2:case 15:return e=Bg(e.type,!1),e;case 11:return e=Bg(e.type.render,!1),e;case 1:return e=Bg(e.type,!0),e;default:return""}}function I0(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 nl:return"Fragment";case tl:return"Portal";case x0:return"Profiler";case Ky:return"StrictMode";case S0:return"Suspense";case k0:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case R5:return(e.displayName||"Context")+".Consumer";case P5:return(e._context.displayName||"Context")+".Provider";case Zy:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Xy:return t=e.displayName||null,t!==null?t:I0(e.type)||"Memo";case Eo:t=e._payload,e=e._init;try{return I0(e(t))}catch{}}return null}function dL(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 I0(t);case 8:return t===Ky?"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 is(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function O5(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function hL(e){var t=O5(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 i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,o.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Eh(e){e._valueTracker||(e._valueTracker=hL(e))}function N5(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=O5(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Qf(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 C0(e,t){var n=t.checked;return ft({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function qw(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=is(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 F5(e,t){t=t.checked,t!=null&&Yy(e,"checked",t,!1)}function T0(e,t){F5(e,t);var n=is(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")?M0(e,t.type,n):t.hasOwnProperty("defaultValue")&&M0(e,t.type,is(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Qw(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 M0(e,t,n){(t!=="number"||Qf(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ou=Array.isArray;function bl(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+is(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function A0(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Q(91));return ft({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Jw(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Q(92));if(ou(n)){if(1<n.length)throw Error(Q(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:is(n)}}function $5(e,t){var n=is(t.value),r=is(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 e3(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function B5(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 L0(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?B5(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var wh,z5=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(wh=wh||document.createElement("div"),wh.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=wh.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Yu(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Eu={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},fL=["Webkit","ms","Moz","O"];Object.keys(Eu).forEach(function(e){fL.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Eu[t]=Eu[e]})});function H5(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Eu.hasOwnProperty(e)&&Eu[e]?(""+t).trim():t+"px"}function U5(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=H5(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var mL=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 P0(e,t){if(t){if(mL[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Q(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Q(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Q(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Q(62))}}function R0(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 D0=null;function qy(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var O0=null,_l=null,xl=null;function t3(e){if(e=Gd(e)){if(typeof O0!="function")throw Error(Q(280));var t=e.stateNode;t&&(t=_1(t),O0(e.stateNode,e.type,t))}}function W5(e){_l?xl?xl.push(e):xl=[e]:_l=e}function V5(){if(_l){var e=_l,t=xl;if(xl=_l=null,t3(e),t)for(e=0;e<t.length;e++)t3(t[e])}}function G5(e,t){return e(t)}function j5(){}var zg=!1;function Y5(e,t,n){if(zg)return e(t,n);zg=!0;try{return G5(e,t,n)}finally{zg=!1,(_l!==null||xl!==null)&&(j5(),V5())}}function Ku(e,t){var n=e.stateNode;if(n===null)return null;var r=_1(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(Q(231,t,typeof n));return n}var N0=!1;if(Zi)try{var Ic={};Object.defineProperty(Ic,"passive",{get:function(){N0=!0}}),window.addEventListener("test",Ic,Ic),window.removeEventListener("test",Ic,Ic)}catch{N0=!1}function gL(e,t,n,r,i,o,s,a,l){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(u){this.onError(u)}}var wu=!1,Jf=null,em=!1,F0=null,pL={onError:function(e){wu=!0,Jf=e}};function yL(e,t,n,r,i,o,s,a,l){wu=!1,Jf=null,gL.apply(pL,arguments)}function vL(e,t,n,r,i,o,s,a,l){if(yL.apply(this,arguments),wu){if(wu){var c=Jf;wu=!1,Jf=null}else throw Error(Q(198));em||(em=!0,F0=c)}}function Pa(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 K5(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 n3(e){if(Pa(e)!==e)throw Error(Q(188))}function EL(e){var t=e.alternate;if(!t){if(t=Pa(e),t===null)throw Error(Q(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return n3(i),e;if(o===r)return n3(i),t;o=o.sibling}throw Error(Q(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,a=i.child;a;){if(a===n){s=!0,n=i,r=o;break}if(a===r){s=!0,r=i,n=o;break}a=a.sibling}if(!s){for(a=o.child;a;){if(a===n){s=!0,n=o,r=i;break}if(a===r){s=!0,r=o,n=i;break}a=a.sibling}if(!s)throw Error(Q(189))}}if(n.alternate!==r)throw Error(Q(190))}if(n.tag!==3)throw Error(Q(188));return n.stateNode.current===n?e:t}function Z5(e){return e=EL(e),e!==null?X5(e):null}function X5(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=X5(e);if(t!==null)return t;e=e.sibling}return null}var q5=ir.unstable_scheduleCallback,r3=ir.unstable_cancelCallback,wL=ir.unstable_shouldYield,bL=ir.unstable_requestPaint,_t=ir.unstable_now,_L=ir.unstable_getCurrentPriorityLevel,Qy=ir.unstable_ImmediatePriority,Q5=ir.unstable_UserBlockingPriority,tm=ir.unstable_NormalPriority,xL=ir.unstable_LowPriority,J5=ir.unstable_IdlePriority,v1=null,wi=null;function SL(e){if(wi&&typeof wi.onCommitFiberRoot=="function")try{wi.onCommitFiberRoot(v1,e,void 0,(e.current.flags&128)===128)}catch{}}var Wr=Math.clz32?Math.clz32:CL,kL=Math.log,IL=Math.LN2;function CL(e){return e>>>=0,e===0?32:31-(kL(e)/IL|0)|0}var bh=64,_h=4194304;function su(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 nm(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,o=e.pingedLanes,s=n&268435455;if(s!==0){var a=s&~i;a!==0?r=su(a):(o&=s,o!==0&&(r=su(o)))}else s=n&~i,s!==0?r=su(s):o!==0&&(r=su(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,o=t&-t,i>=o||i===16&&(o&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-Wr(t),i=1<<n,r|=e[n],t&=~i;return r}function TL(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 ML(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,o=e.pendingLanes;0<o;){var s=31-Wr(o),a=1<<s,l=i[s];l===-1?(!(a&n)||a&r)&&(i[s]=TL(a,t)):l<=t&&(e.expiredLanes|=a),o&=~a}}function $0(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function ex(){var e=bh;return bh<<=1,!(bh&4194240)&&(bh=64),e}function Hg(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Wd(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Wr(t),e[t]=n}function AL(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 i=31-Wr(n),o=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~o}}function Jy(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Wr(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var Ue=0;function tx(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var nx,ev,rx,ix,ox,B0=!1,xh=[],Wo=null,Vo=null,Go=null,Zu=new Map,Xu=new Map,So=[],LL="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 i3(e,t){switch(e){case"focusin":case"focusout":Wo=null;break;case"dragenter":case"dragleave":Vo=null;break;case"mouseover":case"mouseout":Go=null;break;case"pointerover":case"pointerout":Zu.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Xu.delete(t.pointerId)}}function Cc(e,t,n,r,i,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[i]},t!==null&&(t=Gd(t),t!==null&&ev(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function PL(e,t,n,r,i){switch(t){case"focusin":return Wo=Cc(Wo,e,t,n,r,i),!0;case"dragenter":return Vo=Cc(Vo,e,t,n,r,i),!0;case"mouseover":return Go=Cc(Go,e,t,n,r,i),!0;case"pointerover":var o=i.pointerId;return Zu.set(o,Cc(Zu.get(o)||null,e,t,n,r,i)),!0;case"gotpointercapture":return o=i.pointerId,Xu.set(o,Cc(Xu.get(o)||null,e,t,n,r,i)),!0}return!1}function sx(e){var t=Us(e.target);if(t!==null){var n=Pa(t);if(n!==null){if(t=n.tag,t===13){if(t=K5(n),t!==null){e.blockedOn=t,ox(e.priority,function(){rx(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 mf(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=z0(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);D0=r,n.target.dispatchEvent(r),D0=null}else return t=Gd(n),t!==null&&ev(t),e.blockedOn=n,!1;t.shift()}return!0}function o3(e,t,n){mf(e)&&n.delete(t)}function RL(){B0=!1,Wo!==null&&mf(Wo)&&(Wo=null),Vo!==null&&mf(Vo)&&(Vo=null),Go!==null&&mf(Go)&&(Go=null),Zu.forEach(o3),Xu.forEach(o3)}function Tc(e,t){e.blockedOn===t&&(e.blockedOn=null,B0||(B0=!0,ir.unstable_scheduleCallback(ir.unstable_NormalPriority,RL)))}function qu(e){function t(i){return Tc(i,e)}if(0<xh.length){Tc(xh[0],e);for(var n=1;n<xh.length;n++){var r=xh[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Wo!==null&&Tc(Wo,e),Vo!==null&&Tc(Vo,e),Go!==null&&Tc(Go,e),Zu.forEach(t),Xu.forEach(t),n=0;n<So.length;n++)r=So[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<So.length&&(n=So[0],n.blockedOn===null);)sx(n),n.blockedOn===null&&So.shift()}var Sl=io.ReactCurrentBatchConfig,rm=!0;function DL(e,t,n,r){var i=Ue,o=Sl.transition;Sl.transition=null;try{Ue=1,tv(e,t,n,r)}finally{Ue=i,Sl.transition=o}}function OL(e,t,n,r){var i=Ue,o=Sl.transition;Sl.transition=null;try{Ue=4,tv(e,t,n,r)}finally{Ue=i,Sl.transition=o}}function tv(e,t,n,r){if(rm){var i=z0(e,t,n,r);if(i===null)qg(e,t,r,im,n),i3(e,r);else if(PL(i,e,t,n,r))r.stopPropagation();else if(i3(e,r),t&4&&-1<LL.indexOf(e)){for(;i!==null;){var o=Gd(i);if(o!==null&&nx(o),o=z0(e,t,n,r),o===null&&qg(e,t,r,im,n),o===i)break;i=o}i!==null&&r.stopPropagation()}else qg(e,t,r,null,n)}}var im=null;function z0(e,t,n,r){if(im=null,e=qy(r),e=Us(e),e!==null)if(t=Pa(e),t===null)e=null;else if(n=t.tag,n===13){if(e=K5(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 im=e,null}function ax(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(_L()){case Qy:return 1;case Q5:return 4;case tm:case xL:return 16;case J5:return 536870912;default:return 16}default:return 16}}var Po=null,nv=null,gf=null;function lx(){if(gf)return gf;var e,t=nv,n=t.length,r,i="value"in Po?Po.value:Po.textContent,o=i.length;for(e=0;e<n&&t[e]===i[e];e++);var s=n-e;for(r=1;r<=s&&t[n-r]===i[o-r];r++);return gf=i.slice(e,1<r?1-r:void 0)}function pf(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 Sh(){return!0}function s3(){return!1}function sr(e){function t(n,r,i,o,s){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=o,this.target=s,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(o):o[a]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Sh:s3,this.isPropagationStopped=s3,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=Sh)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Sh)},persist:function(){},isPersistent:Sh}),t}var oc={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rv=sr(oc),Vd=ft({},oc,{view:0,detail:0}),NL=sr(Vd),Ug,Wg,Mc,E1=ft({},Vd,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:iv,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!==Mc&&(Mc&&e.type==="mousemove"?(Ug=e.screenX-Mc.screenX,Wg=e.screenY-Mc.screenY):Wg=Ug=0,Mc=e),Ug)},movementY:function(e){return"movementY"in e?e.movementY:Wg}}),a3=sr(E1),FL=ft({},E1,{dataTransfer:0}),$L=sr(FL),BL=ft({},Vd,{relatedTarget:0}),Vg=sr(BL),zL=ft({},oc,{animationName:0,elapsedTime:0,pseudoElement:0}),HL=sr(zL),UL=ft({},oc,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),WL=sr(UL),VL=ft({},oc,{data:0}),l3=sr(VL),GL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jL={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"},YL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function KL(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=YL[e])?!!t[e]:!1}function iv(){return KL}var ZL=ft({},Vd,{key:function(e){if(e.key){var t=GL[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=pf(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?jL[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:iv,charCode:function(e){return e.type==="keypress"?pf(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?pf(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),XL=sr(ZL),qL=ft({},E1,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),c3=sr(qL),QL=ft({},Vd,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:iv}),JL=sr(QL),e9=ft({},oc,{propertyName:0,elapsedTime:0,pseudoElement:0}),t9=sr(e9),n9=ft({},E1,{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}),r9=sr(n9),i9=[9,13,27,32],ov=Zi&&"CompositionEvent"in window,bu=null;Zi&&"documentMode"in document&&(bu=document.documentMode);var o9=Zi&&"TextEvent"in window&&!bu,cx=Zi&&(!ov||bu&&8<bu&&11>=bu),u3=" ",d3=!1;function ux(e,t){switch(e){case"keyup":return i9.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function dx(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var rl=!1;function s9(e,t){switch(e){case"compositionend":return dx(t);case"keypress":return t.which!==32?null:(d3=!0,u3);case"textInput":return e=t.data,e===u3&&d3?null:e;default:return null}}function a9(e,t){if(rl)return e==="compositionend"||!ov&&ux(e,t)?(e=lx(),gf=nv=Po=null,rl=!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 cx&&t.locale!=="ko"?null:t.data;default:return null}}var l9={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 h3(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!l9[e.type]:t==="textarea"}function hx(e,t,n,r){W5(r),t=om(t,"onChange"),0<t.length&&(n=new rv("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var _u=null,Qu=null;function c9(e){xx(e,0)}function w1(e){var t=sl(e);if(N5(t))return e}function u9(e,t){if(e==="change")return t}var fx=!1;if(Zi){var Gg;if(Zi){var jg="oninput"in document;if(!jg){var f3=document.createElement("div");f3.setAttribute("oninput","return;"),jg=typeof f3.oninput=="function"}Gg=jg}else Gg=!1;fx=Gg&&(!document.documentMode||9<document.documentMode)}function m3(){_u&&(_u.detachEvent("onpropertychange",mx),Qu=_u=null)}function mx(e){if(e.propertyName==="value"&&w1(Qu)){var t=[];hx(t,Qu,e,qy(e)),Y5(c9,t)}}function d9(e,t,n){e==="focusin"?(m3(),_u=t,Qu=n,_u.attachEvent("onpropertychange",mx)):e==="focusout"&&m3()}function h9(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return w1(Qu)}function f9(e,t){if(e==="click")return w1(t)}function m9(e,t){if(e==="input"||e==="change")return w1(t)}function g9(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Zr=typeof Object.is=="function"?Object.is:g9;function Ju(e,t){if(Zr(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!_0.call(t,i)||!Zr(e[i],t[i]))return!1}return!0}function g3(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function p3(e,t){var n=g3(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=g3(n)}}function gx(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?gx(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function px(){for(var e=window,t=Qf();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Qf(e.document)}return t}function sv(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 p9(e){var t=px(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&gx(n.ownerDocument.documentElement,n)){if(r!==null&&sv(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 i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!e.extend&&o>r&&(i=r,r=o,o=i),i=p3(n,o);var s=p3(n,r);i&&s&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.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 y9=Zi&&"documentMode"in document&&11>=document.documentMode,il=null,H0=null,xu=null,U0=!1;function y3(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;U0||il==null||il!==Qf(r)||(r=il,"selectionStart"in r&&sv(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}),xu&&Ju(xu,r)||(xu=r,r=om(H0,"onSelect"),0<r.length&&(t=new rv("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=il)))}function kh(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ol={animationend:kh("Animation","AnimationEnd"),animationiteration:kh("Animation","AnimationIteration"),animationstart:kh("Animation","AnimationStart"),transitionend:kh("Transition","TransitionEnd")},Yg={},yx={};Zi&&(yx=document.createElement("div").style,"AnimationEvent"in window||(delete ol.animationend.animation,delete ol.animationiteration.animation,delete ol.animationstart.animation),"TransitionEvent"in window||delete ol.transitionend.transition);function b1(e){if(Yg[e])return Yg[e];if(!ol[e])return e;var t=ol[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in yx)return Yg[e]=t[n];return e}var vx=b1("animationend"),Ex=b1("animationiteration"),wx=b1("animationstart"),bx=b1("transitionend"),_x=new Map,v3="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 ps(e,t){_x.set(e,t),La(t,[e])}for(var Kg=0;Kg<v3.length;Kg++){var Zg=v3[Kg],v9=Zg.toLowerCase(),E9=Zg[0].toUpperCase()+Zg.slice(1);ps(v9,"on"+E9)}ps(vx,"onAnimationEnd");ps(Ex,"onAnimationIteration");ps(wx,"onAnimationStart");ps("dblclick","onDoubleClick");ps("focusin","onFocus");ps("focusout","onBlur");ps(bx,"onTransitionEnd");Fl("onMouseEnter",["mouseout","mouseover"]);Fl("onMouseLeave",["mouseout","mouseover"]);Fl("onPointerEnter",["pointerout","pointerover"]);Fl("onPointerLeave",["pointerout","pointerover"]);La("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));La("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));La("onBeforeInput",["compositionend","keypress","textInput","paste"]);La("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));La("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));La("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var au="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(" "),w9=new Set("cancel close invalid load scroll toggle".split(" ").concat(au));function E3(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,vL(r,t,void 0,e),e.currentTarget=null}function xx(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var s=r.length-1;0<=s;s--){var a=r[s],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==o&&i.isPropagationStopped())break e;E3(i,a,c),o=l}else for(s=0;s<r.length;s++){if(a=r[s],l=a.instance,c=a.currentTarget,a=a.listener,l!==o&&i.isPropagationStopped())break e;E3(i,a,c),o=l}}}if(em)throw e=F0,em=!1,F0=null,e}function Qe(e,t){var n=t[Y0];n===void 0&&(n=t[Y0]=new Set);var r=e+"__bubble";n.has(r)||(Sx(t,e,2,!1),n.add(r))}function Xg(e,t,n){var r=0;t&&(r|=4),Sx(n,e,r,t)}var Ih="_reactListening"+Math.random().toString(36).slice(2);function ed(e){if(!e[Ih]){e[Ih]=!0,L5.forEach(function(n){n!=="selectionchange"&&(w9.has(n)||Xg(n,!1,e),Xg(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ih]||(t[Ih]=!0,Xg("selectionchange",!1,t))}}function Sx(e,t,n,r){switch(ax(t)){case 1:var i=DL;break;case 4:i=OL;break;default:i=tv}n=i.bind(null,t,n,e),i=void 0,!N0||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function qg(e,t,n,r,i){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var a=r.stateNode.containerInfo;if(a===i||a.nodeType===8&&a.parentNode===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&(l=s.stateNode.containerInfo,l===i||l.nodeType===8&&l.parentNode===i))return;s=s.return}for(;a!==null;){if(s=Us(a),s===null)return;if(l=s.tag,l===5||l===6){r=o=s;continue e}a=a.parentNode}}r=r.return}Y5(function(){var c=o,u=qy(n),d=[];e:{var h=_x.get(e);if(h!==void 0){var m=rv,g=e;switch(e){case"keypress":if(pf(n)===0)break e;case"keydown":case"keyup":m=XL;break;case"focusin":g="focus",m=Vg;break;case"focusout":g="blur",m=Vg;break;case"beforeblur":case"afterblur":m=Vg;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":m=a3;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=$L;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=JL;break;case vx:case Ex:case wx:m=HL;break;case bx:m=t9;break;case"scroll":m=NL;break;case"wheel":m=r9;break;case"copy":case"cut":case"paste":m=WL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=c3}var p=(t&4)!==0,v=!p&&e==="scroll",y=p?h!==null?h+"Capture":null:h;p=[];for(var E=c,w;E!==null;){w=E;var x=w.stateNode;if(w.tag===5&&x!==null&&(w=x,y!==null&&(x=Ku(E,y),x!=null&&p.push(td(E,x,w)))),v)break;E=E.return}0<p.length&&(h=new m(h,g,null,n,u),d.push({event:h,listeners:p}))}}if(!(t&7)){e:{if(h=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",h&&n!==D0&&(g=n.relatedTarget||n.fromElement)&&(Us(g)||g[Xi]))break e;if((m||h)&&(h=u.window===u?u:(h=u.ownerDocument)?h.defaultView||h.parentWindow:window,m?(g=n.relatedTarget||n.toElement,m=c,g=g?Us(g):null,g!==null&&(v=Pa(g),g!==v||g.tag!==5&&g.tag!==6)&&(g=null)):(m=null,g=c),m!==g)){if(p=a3,x="onMouseLeave",y="onMouseEnter",E="mouse",(e==="pointerout"||e==="pointerover")&&(p=c3,x="onPointerLeave",y="onPointerEnter",E="pointer"),v=m==null?h:sl(m),w=g==null?h:sl(g),h=new p(x,E+"leave",m,n,u),h.target=v,h.relatedTarget=w,x=null,Us(u)===c&&(p=new p(y,E+"enter",g,n,u),p.target=w,p.relatedTarget=v,x=p),v=x,m&&g)t:{for(p=m,y=g,E=0,w=p;w;w=Ha(w))E++;for(w=0,x=y;x;x=Ha(x))w++;for(;0<E-w;)p=Ha(p),E--;for(;0<w-E;)y=Ha(y),w--;for(;E--;){if(p===y||y!==null&&p===y.alternate)break t;p=Ha(p),y=Ha(y)}p=null}else p=null;m!==null&&w3(d,h,m,p,!1),g!==null&&v!==null&&w3(d,v,g,p,!0)}}e:{if(h=c?sl(c):window,m=h.nodeName&&h.nodeName.toLowerCase(),m==="select"||m==="input"&&h.type==="file")var C=u9;else if(h3(h))if(fx)C=m9;else{C=h9;var S=d9}else(m=h.nodeName)&&m.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(C=f9);if(C&&(C=C(e,c))){hx(d,C,n,u);break e}S&&S(e,h,c),e==="focusout"&&(S=h._wrapperState)&&S.controlled&&h.type==="number"&&M0(h,"number",h.value)}switch(S=c?sl(c):window,e){case"focusin":(h3(S)||S.contentEditable==="true")&&(il=S,H0=c,xu=null);break;case"focusout":xu=H0=il=null;break;case"mousedown":U0=!0;break;case"contextmenu":case"mouseup":case"dragend":U0=!1,y3(d,n,u);break;case"selectionchange":if(y9)break;case"keydown":case"keyup":y3(d,n,u)}var I;if(ov)e:{switch(e){case"compositionstart":var T="onCompositionStart";break e;case"compositionend":T="onCompositionEnd";break e;case"compositionupdate":T="onCompositionUpdate";break e}T=void 0}else rl?ux(e,n)&&(T="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(T="onCompositionStart");T&&(cx&&n.locale!=="ko"&&(rl||T!=="onCompositionStart"?T==="onCompositionEnd"&&rl&&(I=lx()):(Po=u,nv="value"in Po?Po.value:Po.textContent,rl=!0)),S=om(c,T),0<S.length&&(T=new l3(T,e,null,n,u),d.push({event:T,listeners:S}),I?T.data=I:(I=dx(n),I!==null&&(T.data=I)))),(I=o9?s9(e,n):a9(e,n))&&(c=om(c,"onBeforeInput"),0<c.length&&(u=new l3("onBeforeInput","beforeinput",null,n,u),d.push({event:u,listeners:c}),u.data=I))}xx(d,t)})}function td(e,t,n){return{instance:e,listener:t,currentTarget:n}}function om(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,o=i.stateNode;i.tag===5&&o!==null&&(i=o,o=Ku(e,n),o!=null&&r.unshift(td(e,o,i)),o=Ku(e,t),o!=null&&r.push(td(e,o,i))),e=e.return}return r}function Ha(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function w3(e,t,n,r,i){for(var o=t._reactName,s=[];n!==null&&n!==r;){var a=n,l=a.alternate,c=a.stateNode;if(l!==null&&l===r)break;a.tag===5&&c!==null&&(a=c,i?(l=Ku(n,o),l!=null&&s.unshift(td(n,l,a))):i||(l=Ku(n,o),l!=null&&s.push(td(n,l,a)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var b9=/\r\n?/g,_9=/\u0000|\uFFFD/g;function b3(e){return(typeof e=="string"?e:""+e).replace(b9,`
`).replace(_9,"")}function Ch(e,t,n){if(t=b3(t),b3(e)!==t&&n)throw Error(Q(425))}function sm(){}var W0=null,V0=null;function G0(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 j0=typeof setTimeout=="function"?setTimeout:void 0,x9=typeof clearTimeout=="function"?clearTimeout:void 0,_3=typeof Promise=="function"?Promise:void 0,S9=typeof queueMicrotask=="function"?queueMicrotask:typeof _3<"u"?function(e){return _3.resolve(null).then(e).catch(k9)}:j0;function k9(e){setTimeout(function(){throw e})}function Qg(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),qu(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);qu(t)}function jo(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 x3(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),pi="__reactFiber$"+sc,nd="__reactProps$"+sc,Xi="__reactContainer$"+sc,Y0="__reactEvents$"+sc,I9="__reactListeners$"+sc,C9="__reactHandles$"+sc;function Us(e){var t=e[pi];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Xi]||n[pi]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=x3(e);e!==null;){if(n=e[pi])return n;e=x3(e)}return t}e=n,n=e.parentNode}return null}function Gd(e){return e=e[pi]||e[Xi],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function sl(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Q(33))}function _1(e){return e[nd]||null}var K0=[],al=-1;function ys(e){return{current:e}}function rt(e){0>al||(e.current=K0[al],K0[al]=null,al--)}function Ze(e,t){al++,K0[al]=e.current,e.current=t}var os={},fn=ys(os),Fn=ys(!1),la=os;function $l(e,t){var n=e.type.contextTypes;if(!n)return os;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function $n(e){return e=e.childContextTypes,e!=null}function am(){rt(Fn),rt(fn)}function S3(e,t,n){if(fn.current!==os)throw Error(Q(168));Ze(fn,t),Ze(Fn,n)}function kx(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(Q(108,dL(e)||"Unknown",i));return ft({},n,r)}function lm(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||os,la=fn.current,Ze(fn,e),Ze(Fn,Fn.current),!0}function k3(e,t,n){var r=e.stateNode;if(!r)throw Error(Q(169));n?(e=kx(e,t,la),r.__reactInternalMemoizedMergedChildContext=e,rt(Fn),rt(fn),Ze(fn,e)):rt(Fn),Ze(Fn,n)}var $i=null,x1=!1,Jg=!1;function Ix(e){$i===null?$i=[e]:$i.push(e)}function T9(e){x1=!0,Ix(e)}function vs(){if(!Jg&&$i!==null){Jg=!0;var e=0,t=Ue;try{var n=$i;for(Ue=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}$i=null,x1=!1}catch(i){throw $i!==null&&($i=$i.slice(e+1)),q5(Qy,vs),i}finally{Ue=t,Jg=!1}}return null}var ll=[],cl=0,cm=null,um=0,dr=[],hr=0,ca=null,zi=1,Hi="";function Is(e,t){ll[cl++]=um,ll[cl++]=cm,cm=e,um=t}function Cx(e,t,n){dr[hr++]=zi,dr[hr++]=Hi,dr[hr++]=ca,ca=e;var r=zi;e=Hi;var i=32-Wr(r)-1;r&=~(1<<i),n+=1;var o=32-Wr(t)+i;if(30<o){var s=i-i%5;o=(r&(1<<s)-1).toString(32),r>>=s,i-=s,zi=1<<32-Wr(t)+i|n<<i|r,Hi=o+e}else zi=1<<o|n<<i|r,Hi=e}function av(e){e.return!==null&&(Is(e,1),Cx(e,1,0))}function lv(e){for(;e===cm;)cm=ll[--cl],ll[cl]=null,um=ll[--cl],ll[cl]=null;for(;e===ca;)ca=dr[--hr],dr[hr]=null,Hi=dr[--hr],dr[hr]=null,zi=dr[--hr],dr[hr]=null}var tr=null,qn=null,lt=!1,Br=null;function Tx(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 I3(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,tr=e,qn=jo(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,tr=e,qn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=ca!==null?{id:zi,overflow:Hi}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=mr(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,tr=e,qn=null,!0):!1;default:return!1}}function Z0(e){return(e.mode&1)!==0&&(e.flags&128)===0}function X0(e){if(lt){var t=qn;if(t){var n=t;if(!I3(e,t)){if(Z0(e))throw Error(Q(418));t=jo(n.nextSibling);var r=tr;t&&I3(e,t)?Tx(r,n):(e.flags=e.flags&-4097|2,lt=!1,tr=e)}}else{if(Z0(e))throw Error(Q(418));e.flags=e.flags&-4097|2,lt=!1,tr=e}}}function C3(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;tr=e}function Th(e){if(e!==tr)return!1;if(!lt)return C3(e),lt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!G0(e.type,e.memoizedProps)),t&&(t=qn)){if(Z0(e))throw Mx(),Error(Q(418));for(;t;)Tx(e,t),t=jo(t.nextSibling)}if(C3(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Q(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){qn=jo(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}qn=null}}else qn=tr?jo(e.stateNode.nextSibling):null;return!0}function Mx(){for(var e=qn;e;)e=jo(e.nextSibling)}function Bl(){qn=tr=null,lt=!1}function cv(e){Br===null?Br=[e]:Br.push(e)}var M9=io.ReactCurrentBatchConfig;function Dr(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}var dm=ys(null),hm=null,ul=null,uv=null;function dv(){uv=ul=hm=null}function hv(e){var t=dm.current;rt(dm),e._currentValue=t}function q0(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 kl(e,t){hm=e,uv=ul=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Rn=!0),e.firstContext=null)}function br(e){var t=e._currentValue;if(uv!==e)if(e={context:e,memoizedValue:t,next:null},ul===null){if(hm===null)throw Error(Q(308));ul=e,hm.dependencies={lanes:0,firstContext:e}}else ul=ul.next=e;return t}var Ws=null;function fv(e){Ws===null?Ws=[e]:Ws.push(e)}function Ax(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,fv(t)):(n.next=i.next,i.next=n),t.interleaved=n,qi(e,r)}function qi(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 wo=!1;function mv(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Lx(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 Wi(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Yo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Re&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,qi(e,n)}return i=r.interleaved,i===null?(t.next=t,fv(r)):(t.next=i.next,i.next=t),r.interleaved=t,qi(e,n)}function yf(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,Jy(e,n)}}function T3(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?i=o=s:o=o.next=s,n=n.next}while(n!==null);o===null?i=o=t:o=o.next=t}else i=o=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:o,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 fm(e,t,n,r){var i=e.updateQueue;wo=!1;var o=i.firstBaseUpdate,s=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,c=l.next;l.next=null,s===null?o=c:s.next=c,s=l;var u=e.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==s&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(o!==null){var d=i.baseState;s=0,u=c=l=null,a=o;do{var h=a.lane,m=a.eventTime;if((r&h)===h){u!==null&&(u=u.next={eventTime:m,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var g=e,p=a;switch(h=t,m=n,p.tag){case 1:if(g=p.payload,typeof g=="function"){d=g.call(m,d,h);break e}d=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=p.payload,h=typeof g=="function"?g.call(m,d,h):g,h==null)break e;d=ft({},d,h);break e;case 2:wo=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=i.effects,h===null?i.effects=[a]:h.push(a))}else m={eventTime:m,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=m,l=d):u=u.next=m,s|=h;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;h=a,a=h.next,h.next=null,i.lastBaseUpdate=h,i.shared.pending=null}}while(!0);if(u===null&&(l=d),i.baseState=l,i.firstBaseUpdate=c,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do s|=i.lane,i=i.next;while(i!==t)}else o===null&&(i.shared.lanes=0);da|=s,e.lanes=s,e.memoizedState=d}}function M3(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(Q(191,i));i.call(r)}}}var Px=new A5.Component().refs;function Q0(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 S1={isMounted:function(e){return(e=e._reactInternals)?Pa(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Sn(),i=Zo(e),o=Wi(r,i);o.payload=t,n!=null&&(o.callback=n),t=Yo(e,o,i),t!==null&&(Vr(t,e,i,r),yf(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Sn(),i=Zo(e),o=Wi(r,i);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=Yo(e,o,i),t!==null&&(Vr(t,e,i,r),yf(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Sn(),r=Zo(e),i=Wi(n,r);i.tag=2,t!=null&&(i.callback=t),t=Yo(e,i,r),t!==null&&(Vr(t,e,r,n),yf(t,e,r))}};function A3(e,t,n,r,i,o,s){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,s):t.prototype&&t.prototype.isPureReactComponent?!Ju(n,r)||!Ju(i,o):!0}function Rx(e,t,n){var r=!1,i=os,o=t.contextType;return typeof o=="object"&&o!==null?o=br(o):(i=$n(t)?la:fn.current,r=t.contextTypes,o=(r=r!=null)?$l(e,i):os),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=S1,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=o),t}function L3(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&&S1.enqueueReplaceState(t,t.state,null)}function J0(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs=Px,mv(e);var o=t.contextType;typeof o=="object"&&o!==null?i.context=br(o):(o=$n(t)?la:fn.current,i.context=$l(e,o)),i.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(Q0(e,t,o,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&S1.enqueueReplaceState(i,i.state,null),fm(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function Ac(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(Q(309));var r=n.stateNode}if(!r)throw Error(Q(147,e));var i=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(s){var a=i.refs;a===Px&&(a=i.refs={}),s===null?delete a[o]:a[o]=s},t._stringRef=o,t)}if(typeof e!="string")throw Error(Q(284));if(!n._owner)throw Error(Q(290,e))}return e}function Mh(e,t){throw e=Object.prototype.toString.call(t),Error(Q(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function P3(e){var t=e._init;return t(e._payload)}function Dx(e){function t(y,E){if(e){var w=y.deletions;w===null?(y.deletions=[E],y.flags|=16):w.push(E)}}function n(y,E){if(!e)return null;for(;E!==null;)t(y,E),E=E.sibling;return null}function r(y,E){for(y=new Map;E!==null;)E.key!==null?y.set(E.key,E):y.set(E.index,E),E=E.sibling;return y}function i(y,E){return y=Xo(y,E),y.index=0,y.sibling=null,y}function o(y,E,w){return y.index=w,e?(w=y.alternate,w!==null?(w=w.index,w<E?(y.flags|=2,E):w):(y.flags|=2,E)):(y.flags|=1048576,E)}function s(y){return e&&y.alternate===null&&(y.flags|=2),y}function a(y,E,w,x){return E===null||E.tag!==6?(E=sp(w,y.mode,x),E.return=y,E):(E=i(E,w),E.return=y,E)}function l(y,E,w,x){var C=w.type;return C===nl?u(y,E,w.props.children,x,w.key):E!==null&&(E.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Eo&&P3(C)===E.type)?(x=i(E,w.props),x.ref=Ac(y,E,w),x.return=y,x):(x=xf(w.type,w.key,w.props,null,y.mode,x),x.ref=Ac(y,E,w),x.return=y,x)}function c(y,E,w,x){return E===null||E.tag!==4||E.stateNode.containerInfo!==w.containerInfo||E.stateNode.implementation!==w.implementation?(E=ap(w,y.mode,x),E.return=y,E):(E=i(E,w.children||[]),E.return=y,E)}function u(y,E,w,x,C){return E===null||E.tag!==7?(E=na(w,y.mode,x,C),E.return=y,E):(E=i(E,w),E.return=y,E)}function d(y,E,w){if(typeof E=="string"&&E!==""||typeof E=="number")return E=sp(""+E,y.mode,w),E.return=y,E;if(typeof E=="object"&&E!==null){switch(E.$$typeof){case vh:return w=xf(E.type,E.key,E.props,null,y.mode,w),w.ref=Ac(y,null,E),w.return=y,w;case tl:return E=ap(E,y.mode,w),E.return=y,E;case Eo:var x=E._init;return d(y,x(E._payload),w)}if(ou(E)||kc(E))return E=na(E,y.mode,w,null),E.return=y,E;Mh(y,E)}return null}function h(y,E,w,x){var C=E!==null?E.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return C!==null?null:a(y,E,""+w,x);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case vh:return w.key===C?l(y,E,w,x):null;case tl:return w.key===C?c(y,E,w,x):null;case Eo:return C=w._init,h(y,E,C(w._payload),x)}if(ou(w)||kc(w))return C!==null?null:u(y,E,w,x,null);Mh(y,w)}return null}function m(y,E,w,x,C){if(typeof x=="string"&&x!==""||typeof x=="number")return y=y.get(w)||null,a(E,y,""+x,C);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case vh:return y=y.get(x.key===null?w:x.key)||null,l(E,y,x,C);case tl:return y=y.get(x.key===null?w:x.key)||null,c(E,y,x,C);case Eo:var S=x._init;return m(y,E,w,S(x._payload),C)}if(ou(x)||kc(x))return y=y.get(w)||null,u(E,y,x,C,null);Mh(E,x)}return null}function g(y,E,w,x){for(var C=null,S=null,I=E,T=E=0,L=null;I!==null&&T<w.length;T++){I.index>T?(L=I,I=null):L=I.sibling;var A=h(y,I,w[T],x);if(A===null){I===null&&(I=L);break}e&&I&&A.alternate===null&&t(y,I),E=o(A,E,T),S===null?C=A:S.sibling=A,S=A,I=L}if(T===w.length)return n(y,I),lt&&Is(y,T),C;if(I===null){for(;T<w.length;T++)I=d(y,w[T],x),I!==null&&(E=o(I,E,T),S===null?C=I:S.sibling=I,S=I);return lt&&Is(y,T),C}for(I=r(y,I);T<w.length;T++)L=m(I,y,T,w[T],x),L!==null&&(e&&L.alternate!==null&&I.delete(L.key===null?T:L.key),E=o(L,E,T),S===null?C=L:S.sibling=L,S=L);return e&&I.forEach(function(F){return t(y,F)}),lt&&Is(y,T),C}function p(y,E,w,x){var C=kc(w);if(typeof C!="function")throw Error(Q(150));if(w=C.call(w),w==null)throw Error(Q(151));for(var S=C=null,I=E,T=E=0,L=null,A=w.next();I!==null&&!A.done;T++,A=w.next()){I.index>T?(L=I,I=null):L=I.sibling;var F=h(y,I,A.value,x);if(F===null){I===null&&(I=L);break}e&&I&&F.alternate===null&&t(y,I),E=o(F,E,T),S===null?C=F:S.sibling=F,S=F,I=L}if(A.done)return n(y,I),lt&&Is(y,T),C;if(I===null){for(;!A.done;T++,A=w.next())A=d(y,A.value,x),A!==null&&(E=o(A,E,T),S===null?C=A:S.sibling=A,S=A);return lt&&Is(y,T),C}for(I=r(y,I);!A.done;T++,A=w.next())A=m(I,y,T,A.value,x),A!==null&&(e&&A.alternate!==null&&I.delete(A.key===null?T:A.key),E=o(A,E,T),S===null?C=A:S.sibling=A,S=A);return e&&I.forEach(function(P){return t(y,P)}),lt&&Is(y,T),C}function v(y,E,w,x){if(typeof w=="object"&&w!==null&&w.type===nl&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case vh:e:{for(var C=w.key,S=E;S!==null;){if(S.key===C){if(C=w.type,C===nl){if(S.tag===7){n(y,S.sibling),E=i(S,w.props.children),E.return=y,y=E;break e}}else if(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Eo&&P3(C)===S.type){n(y,S.sibling),E=i(S,w.props),E.ref=Ac(y,S,w),E.return=y,y=E;break e}n(y,S);break}else t(y,S);S=S.sibling}w.type===nl?(E=na(w.props.children,y.mode,x,w.key),E.return=y,y=E):(x=xf(w.type,w.key,w.props,null,y.mode,x),x.ref=Ac(y,E,w),x.return=y,y=x)}return s(y);case tl:e:{for(S=w.key;E!==null;){if(E.key===S)if(E.tag===4&&E.stateNode.containerInfo===w.containerInfo&&E.stateNode.implementation===w.implementation){n(y,E.sibling),E=i(E,w.children||[]),E.return=y,y=E;break e}else{n(y,E);break}else t(y,E);E=E.sibling}E=ap(w,y.mode,x),E.return=y,y=E}return s(y);case Eo:return S=w._init,v(y,E,S(w._payload),x)}if(ou(w))return g(y,E,w,x);if(kc(w))return p(y,E,w,x);Mh(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,E!==null&&E.tag===6?(n(y,E.sibling),E=i(E,w),E.return=y,y=E):(n(y,E),E=sp(w,y.mode,x),E.return=y,y=E),s(y)):n(y,E)}return v}var zl=Dx(!0),Ox=Dx(!1),jd={},bi=ys(jd),rd=ys(jd),id=ys(jd);function Vs(e){if(e===jd)throw Error(Q(174));return e}function gv(e,t){switch(Ze(id,t),Ze(rd,e),Ze(bi,jd),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:L0(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=L0(t,e)}rt(bi),Ze(bi,t)}function Hl(){rt(bi),rt(rd),rt(id)}function Nx(e){Vs(id.current);var t=Vs(bi.current),n=L0(t,e.type);t!==n&&(Ze(rd,e),Ze(bi,n))}function pv(e){rd.current===e&&(rt(bi),rt(rd))}var ut=ys(0);function mm(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 ep=[];function yv(){for(var e=0;e<ep.length;e++)ep[e]._workInProgressVersionPrimary=null;ep.length=0}var vf=io.ReactCurrentDispatcher,tp=io.ReactCurrentBatchConfig,ua=0,ht=null,Rt=null,Ht=null,gm=!1,Su=!1,od=0,A9=0;function nn(){throw Error(Q(321))}function vv(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Zr(e[n],t[n]))return!1;return!0}function Ev(e,t,n,r,i,o){if(ua=o,ht=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,vf.current=e===null||e.memoizedState===null?D9:O9,e=n(r,i),Su){o=0;do{if(Su=!1,od=0,25<=o)throw Error(Q(301));o+=1,Ht=Rt=null,t.updateQueue=null,vf.current=N9,e=n(r,i)}while(Su)}if(vf.current=pm,t=Rt!==null&&Rt.next!==null,ua=0,Ht=Rt=ht=null,gm=!1,t)throw Error(Q(300));return e}function wv(){var e=od!==0;return od=0,e}function ui(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ht===null?ht.memoizedState=Ht=e:Ht=Ht.next=e,Ht}function _r(){if(Rt===null){var e=ht.alternate;e=e!==null?e.memoizedState:null}else e=Rt.next;var t=Ht===null?ht.memoizedState:Ht.next;if(t!==null)Ht=t,Rt=e;else{if(e===null)throw Error(Q(310));Rt=e,e={memoizedState:Rt.memoizedState,baseState:Rt.baseState,baseQueue:Rt.baseQueue,queue:Rt.queue,next:null},Ht===null?ht.memoizedState=Ht=e:Ht=Ht.next=e}return Ht}function sd(e,t){return typeof t=="function"?t(e):t}function np(e){var t=_r(),n=t.queue;if(n===null)throw Error(Q(311));n.lastRenderedReducer=e;var r=Rt,i=r.baseQueue,o=n.pending;if(o!==null){if(i!==null){var s=i.next;i.next=o.next,o.next=s}r.baseQueue=i=o,n.pending=null}if(i!==null){o=i.next,r=r.baseState;var a=s=null,l=null,c=o;do{var u=c.lane;if((ua&u)===u)l!==null&&(l=l.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:e(r,c.action);else{var d={lane:u,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=d,s=r):l=l.next=d,ht.lanes|=u,da|=u}c=c.next}while(c!==null&&c!==o);l===null?s=r:l.next=a,Zr(r,t.memoizedState)||(Rn=!0),t.memoizedState=r,t.baseState=s,t.baseQueue=l,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do o=i.lane,ht.lanes|=o,da|=o,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function rp(e){var t=_r(),n=t.queue;if(n===null)throw Error(Q(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do o=e(o,s.action),s=s.next;while(s!==i);Zr(o,t.memoizedState)||(Rn=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Fx(){}function $x(e,t){var n=ht,r=_r(),i=t(),o=!Zr(r.memoizedState,i);if(o&&(r.memoizedState=i,Rn=!0),r=r.queue,bv(Hx.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||Ht!==null&&Ht.memoizedState.tag&1){if(n.flags|=2048,ad(9,zx.bind(null,n,r,i,t),void 0,null),Wt===null)throw Error(Q(349));ua&30||Bx(n,t,i)}return i}function Bx(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 zx(e,t,n,r){t.value=n,t.getSnapshot=r,Ux(t)&&Wx(e)}function Hx(e,t,n){return n(function(){Ux(t)&&Wx(e)})}function Ux(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Zr(e,n)}catch{return!0}}function Wx(e){var t=qi(e,1);t!==null&&Vr(t,e,1,-1)}function R3(e){var t=ui();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:sd,lastRenderedState:e},t.queue=e,e=e.dispatch=R9.bind(null,ht,e),[t.memoizedState,e]}function ad(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 Vx(){return _r().memoizedState}function Ef(e,t,n,r){var i=ui();ht.flags|=e,i.memoizedState=ad(1|t,n,void 0,r===void 0?null:r)}function k1(e,t,n,r){var i=_r();r=r===void 0?null:r;var o=void 0;if(Rt!==null){var s=Rt.memoizedState;if(o=s.destroy,r!==null&&vv(r,s.deps)){i.memoizedState=ad(t,n,o,r);return}}ht.flags|=e,i.memoizedState=ad(1|t,n,o,r)}function D3(e,t){return Ef(8390656,8,e,t)}function bv(e,t){return k1(2048,8,e,t)}function Gx(e,t){return k1(4,2,e,t)}function jx(e,t){return k1(4,4,e,t)}function Yx(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 Kx(e,t,n){return n=n!=null?n.concat([e]):null,k1(4,4,Yx.bind(null,t,e),n)}function _v(){}function Zx(e,t){var n=_r();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&vv(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Xx(e,t){var n=_r();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&vv(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function qx(e,t,n){return ua&21?(Zr(n,t)||(n=ex(),ht.lanes|=n,da|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Rn=!0),e.memoizedState=n)}function L9(e,t){var n=Ue;Ue=n!==0&&4>n?n:4,e(!0);var r=tp.transition;tp.transition={};try{e(!1),t()}finally{Ue=n,tp.transition=r}}function Qx(){return _r().memoizedState}function P9(e,t,n){var r=Zo(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Jx(e))eS(t,n);else if(n=Ax(e,t,n,r),n!==null){var i=Sn();Vr(n,e,r,i),tS(n,t,r)}}function R9(e,t,n){var r=Zo(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Jx(e))eS(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var s=t.lastRenderedState,a=o(s,n);if(i.hasEagerState=!0,i.eagerState=a,Zr(a,s)){var l=t.interleaved;l===null?(i.next=i,fv(t)):(i.next=l.next,l.next=i),t.interleaved=i;return}}catch{}finally{}n=Ax(e,t,i,r),n!==null&&(i=Sn(),Vr(n,e,r,i),tS(n,t,r))}}function Jx(e){var t=e.alternate;return e===ht||t!==null&&t===ht}function eS(e,t){Su=gm=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function tS(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Jy(e,n)}}var pm={readContext:br,useCallback:nn,useContext:nn,useEffect:nn,useImperativeHandle:nn,useInsertionEffect:nn,useLayoutEffect:nn,useMemo:nn,useReducer:nn,useRef:nn,useState:nn,useDebugValue:nn,useDeferredValue:nn,useTransition:nn,useMutableSource:nn,useSyncExternalStore:nn,useId:nn,unstable_isNewReconciler:!1},D9={readContext:br,useCallback:function(e,t){return ui().memoizedState=[e,t===void 0?null:t],e},useContext:br,useEffect:D3,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ef(4194308,4,Yx.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ef(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ef(4,2,e,t)},useMemo:function(e,t){var n=ui();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ui();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=P9.bind(null,ht,e),[r.memoizedState,e]},useRef:function(e){var t=ui();return e={current:e},t.memoizedState=e},useState:R3,useDebugValue:_v,useDeferredValue:function(e){return ui().memoizedState=e},useTransition:function(){var e=R3(!1),t=e[0];return e=L9.bind(null,e[1]),ui().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ht,i=ui();if(lt){if(n===void 0)throw Error(Q(407));n=n()}else{if(n=t(),Wt===null)throw Error(Q(349));ua&30||Bx(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,D3(Hx.bind(null,r,o,e),[e]),r.flags|=2048,ad(9,zx.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=ui(),t=Wt.identifierPrefix;if(lt){var n=Hi,r=zi;n=(r&~(1<<32-Wr(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=od++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=A9++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},O9={readContext:br,useCallback:Zx,useContext:br,useEffect:bv,useImperativeHandle:Kx,useInsertionEffect:Gx,useLayoutEffect:jx,useMemo:Xx,useReducer:np,useRef:Vx,useState:function(){return np(sd)},useDebugValue:_v,useDeferredValue:function(e){var t=_r();return qx(t,Rt.memoizedState,e)},useTransition:function(){var e=np(sd)[0],t=_r().memoizedState;return[e,t]},useMutableSource:Fx,useSyncExternalStore:$x,useId:Qx,unstable_isNewReconciler:!1},N9={readContext:br,useCallback:Zx,useContext:br,useEffect:bv,useImperativeHandle:Kx,useInsertionEffect:Gx,useLayoutEffect:jx,useMemo:Xx,useReducer:rp,useRef:Vx,useState:function(){return rp(sd)},useDebugValue:_v,useDeferredValue:function(e){var t=_r();return Rt===null?t.memoizedState=e:qx(t,Rt.memoizedState,e)},useTransition:function(){var e=rp(sd)[0],t=_r().memoizedState;return[e,t]},useMutableSource:Fx,useSyncExternalStore:$x,useId:Qx,unstable_isNewReconciler:!1};function Ul(e,t){try{var n="",r=t;do n+=uL(r),r=r.return;while(r);var i=n}catch(o){i=`
Error generating stack: `+o.message+`
`+o.stack}return{value:e,source:t,stack:i,digest:null}}function ip(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function e2(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var F9=typeof WeakMap=="function"?WeakMap:Map;function nS(e,t,n){n=Wi(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){vm||(vm=!0,u2=r),e2(e,t)},n}function rS(e,t,n){n=Wi(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){e2(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){e2(e,t),typeof r!="function"&&(Ko===null?Ko=new Set([this]):Ko.add(this));var s=t.stack;this.componentDidCatch(t.value,{componentStack:s!==null?s:""})}),n}function O3(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new F9;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=q9.bind(null,e,t,n),t.then(e,e))}function N3(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 F3(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,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=Wi(-1,1),t.tag=2,Yo(n,t,1))),n.lanes|=1),e)}var $9=io.ReactCurrentOwner,Rn=!1;function En(e,t,n,r){t.child=e===null?Ox(t,null,n,r):zl(t,e.child,n,r)}function $3(e,t,n,r,i){n=n.render;var o=t.ref;return kl(t,i),r=Ev(e,t,n,r,o,i),n=wv(),e!==null&&!Rn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Qi(e,t,i)):(lt&&n&&av(t),t.flags|=1,En(e,t,r,i),t.child)}function B3(e,t,n,r,i){if(e===null){var o=n.type;return typeof o=="function"&&!Av(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,iS(e,t,o,r,i)):(e=xf(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&i)){var s=o.memoizedProps;if(n=n.compare,n=n!==null?n:Ju,n(s,r)&&e.ref===t.ref)return Qi(e,t,i)}return t.flags|=1,e=Xo(o,r),e.ref=t.ref,e.return=t,t.child=e}function iS(e,t,n,r,i){if(e!==null){var o=e.memoizedProps;if(Ju(o,r)&&e.ref===t.ref)if(Rn=!1,t.pendingProps=r=o,(e.lanes&i)!==0)e.flags&131072&&(Rn=!0);else return t.lanes=e.lanes,Qi(e,t,i)}return t2(e,t,n,r,i)}function oS(e,t,n){var r=t.pendingProps,i=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ze(hl,Xn),Xn|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Ze(hl,Xn),Xn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,Ze(hl,Xn),Xn|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,Ze(hl,Xn),Xn|=r;return En(e,t,i,n),t.child}function sS(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function t2(e,t,n,r,i){var o=$n(n)?la:fn.current;return o=$l(t,o),kl(t,i),n=Ev(e,t,n,r,o,i),r=wv(),e!==null&&!Rn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,Qi(e,t,i)):(lt&&r&&av(t),t.flags|=1,En(e,t,n,i),t.child)}function z3(e,t,n,r,i){if($n(n)){var o=!0;lm(t)}else o=!1;if(kl(t,i),t.stateNode===null)wf(e,t),Rx(t,n,r),J0(t,n,r,i),r=!0;else if(e===null){var s=t.stateNode,a=t.memoizedProps;s.props=a;var l=s.context,c=n.contextType;typeof c=="object"&&c!==null?c=br(c):(c=$n(n)?la:fn.current,c=$l(t,c));var u=n.getDerivedStateFromProps,d=typeof u=="function"||typeof s.getSnapshotBeforeUpdate=="function";d||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(a!==r||l!==c)&&L3(t,s,r,c),wo=!1;var h=t.memoizedState;s.state=h,fm(t,r,s,i),l=t.memoizedState,a!==r||h!==l||Fn.current||wo?(typeof u=="function"&&(Q0(t,n,u,r),l=t.memoizedState),(a=wo||A3(t,n,a,r,h,l,c))?(d||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount()),typeof s.componentDidMount=="function"&&(t.flags|=4194308)):(typeof s.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),s.props=r,s.state=l,s.context=c,r=a):(typeof s.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{s=t.stateNode,Lx(e,t),a=t.memoizedProps,c=t.type===t.elementType?a:Dr(t.type,a),s.props=c,d=t.pendingProps,h=s.context,l=n.contextType,typeof l=="object"&&l!==null?l=br(l):(l=$n(n)?la:fn.current,l=$l(t,l));var m=n.getDerivedStateFromProps;(u=typeof m=="function"||typeof s.getSnapshotBeforeUpdate=="function")||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(a!==d||h!==l)&&L3(t,s,r,l),wo=!1,h=t.memoizedState,s.state=h,fm(t,r,s,i);var g=t.memoizedState;a!==d||h!==g||Fn.current||wo?(typeof m=="function"&&(Q0(t,n,m,r),g=t.memoizedState),(c=wo||A3(t,n,c,r,h,g,l)||!1)?(u||typeof s.UNSAFE_componentWillUpdate!="function"&&typeof s.componentWillUpdate!="function"||(typeof s.componentWillUpdate=="function"&&s.componentWillUpdate(r,g,l),typeof s.UNSAFE_componentWillUpdate=="function"&&s.UNSAFE_componentWillUpdate(r,g,l)),typeof s.componentDidUpdate=="function"&&(t.flags|=4),typeof s.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof s.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),s.props=r,s.state=g,s.context=l,r=c):(typeof s.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return n2(e,t,n,r,o,i)}function n2(e,t,n,r,i,o){sS(e,t);var s=(t.flags&128)!==0;if(!r&&!s)return i&&k3(t,n,!1),Qi(e,t,o);r=t.stateNode,$9.current=t;var a=s&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&s?(t.child=zl(t,e.child,null,o),t.child=zl(t,null,a,o)):En(e,t,a,o),t.memoizedState=r.state,i&&k3(t,n,!0),t.child}function aS(e){var t=e.stateNode;t.pendingContext?S3(e,t.pendingContext,t.pendingContext!==t.context):t.context&&S3(e,t.context,!1),gv(e,t.containerInfo)}function H3(e,t,n,r,i){return Bl(),cv(i),t.flags|=256,En(e,t,n,r),t.child}var r2={dehydrated:null,treeContext:null,retryLane:0};function i2(e){return{baseLanes:e,cachePool:null,transitions:null}}function lS(e,t,n){var r=t.pendingProps,i=ut.current,o=!1,s=(t.flags&128)!==0,a;if((a=s)||(a=e!==null&&e.memoizedState===null?!1:(i&2)!==0),a?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Ze(ut,i&1),e===null)return X0(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):(s=r.children,e=r.fallback,o?(r=t.mode,o=t.child,s={mode:"hidden",children:s},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=s):o=T1(s,r,0,null),e=na(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=i2(n),t.memoizedState=r2,e):xv(t,s));if(i=e.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return B9(e,t,s,r,a,i,n);if(o){o=r.fallback,s=t.mode,i=e.child,a=i.sibling;var l={mode:"hidden",children:r.children};return!(s&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=l,t.deletions=null):(r=Xo(i,l),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?o=Xo(a,o):(o=na(o,s,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,s=e.child.memoizedState,s=s===null?i2(n):{baseLanes:s.baseLanes|n,cachePool:null,transitions:s.transitions},o.memoizedState=s,o.childLanes=e.childLanes&~n,t.memoizedState=r2,r}return o=e.child,e=o.sibling,r=Xo(o,{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 xv(e,t){return t=T1({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ah(e,t,n,r){return r!==null&&cv(r),zl(t,e.child,null,n),e=xv(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function B9(e,t,n,r,i,o,s){if(n)return t.flags&256?(t.flags&=-257,r=ip(Error(Q(422))),Ah(e,t,s,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,i=t.mode,r=T1({mode:"visible",children:r.children},i,0,null),o=na(o,i,s,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&zl(t,e.child,null,s),t.child.memoizedState=i2(s),t.memoizedState=r2,o);if(!(t.mode&1))return Ah(e,t,s,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,o=Error(Q(419)),r=ip(o,r,void 0),Ah(e,t,s,r)}if(a=(s&e.childLanes)!==0,Rn||a){if(r=Wt,r!==null){switch(s&-s){case 4:i=2;break;case 16:i=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:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|s)?0:i,i!==0&&i!==o.retryLane&&(o.retryLane=i,qi(e,i),Vr(r,e,i,-1))}return Mv(),r=ip(Error(Q(421))),Ah(e,t,s,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=Q9.bind(null,e),i._reactRetry=t,null):(e=o.treeContext,qn=jo(i.nextSibling),tr=t,lt=!0,Br=null,e!==null&&(dr[hr++]=zi,dr[hr++]=Hi,dr[hr++]=ca,zi=e.id,Hi=e.overflow,ca=t),t=xv(t,r.children),t.flags|=4096,t)}function U3(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),q0(e.return,t,n)}function op(e,t,n,r,i){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i)}function cS(e,t,n){var r=t.pendingProps,i=r.revealOrder,o=r.tail;if(En(e,t,r.children,n),r=ut.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&&U3(e,n,t);else if(e.tag===19)U3(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(Ze(ut,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&mm(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),op(t,!1,i,n,o);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&mm(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}op(t,!0,n,null,o);break;case"together":op(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function wf(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Qi(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),da|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Q(153));if(t.child!==null){for(e=t.child,n=Xo(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Xo(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function z9(e,t,n){switch(t.tag){case 3:aS(t),Bl();break;case 5:Nx(t);break;case 1:$n(t.type)&&lm(t);break;case 4:gv(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Ze(dm,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Ze(ut,ut.current&1),t.flags|=128,null):n&t.child.childLanes?lS(e,t,n):(Ze(ut,ut.current&1),e=Qi(e,t,n),e!==null?e.sibling:null);Ze(ut,ut.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return cS(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ze(ut,ut.current),r)break;return null;case 22:case 23:return t.lanes=0,oS(e,t,n)}return Qi(e,t,n)}var uS,o2,dS,hS;uS=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}};o2=function(){};dS=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Vs(bi.current);var o=null;switch(n){case"input":i=C0(e,i),r=C0(e,r),o=[];break;case"select":i=ft({},i,{value:void 0}),r=ft({},r,{value:void 0}),o=[];break;case"textarea":i=A0(e,i),r=A0(e,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=sm)}P0(n,r);var s;n=null;for(c in i)if(!r.hasOwnProperty(c)&&i.hasOwnProperty(c)&&i[c]!=null)if(c==="style"){var a=i[c];for(s in a)a.hasOwnProperty(s)&&(n||(n={}),n[s]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(ju.hasOwnProperty(c)?o||(o=[]):(o=o||[]).push(c,null));for(c in r){var l=r[c];if(a=i!=null?i[c]:void 0,r.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(s in a)!a.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||(n={}),n[s]="");for(s in l)l.hasOwnProperty(s)&&a[s]!==l[s]&&(n||(n={}),n[s]=l[s])}else n||(o||(o=[]),o.push(c,n)),n=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(o=o||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(o=o||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(ju.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&Qe("scroll",e),o||a===l||(o=[])):(o=o||[]).push(c,l))}n&&(o=o||[]).push("style",n);var c=o;(t.updateQueue=c)&&(t.flags|=4)}};hS=function(e,t,n,r){n!==r&&(t.flags|=4)};function Lc(e,t){if(!lt)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 rn(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function H9(e,t,n){var r=t.pendingProps;switch(lv(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return rn(t),null;case 1:return $n(t.type)&&am(),rn(t),null;case 3:return r=t.stateNode,Hl(),rt(Fn),rt(fn),yv(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Th(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Br!==null&&(f2(Br),Br=null))),o2(e,t),rn(t),null;case 5:pv(t);var i=Vs(id.current);if(n=t.type,e!==null&&t.stateNode!=null)dS(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Q(166));return rn(t),null}if(e=Vs(bi.current),Th(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[pi]=t,r[nd]=o,e=(t.mode&1)!==0,n){case"dialog":Qe("cancel",r),Qe("close",r);break;case"iframe":case"object":case"embed":Qe("load",r);break;case"video":case"audio":for(i=0;i<au.length;i++)Qe(au[i],r);break;case"source":Qe("error",r);break;case"img":case"image":case"link":Qe("error",r),Qe("load",r);break;case"details":Qe("toggle",r);break;case"input":qw(r,o),Qe("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},Qe("invalid",r);break;case"textarea":Jw(r,o),Qe("invalid",r)}P0(n,o),i=null;for(var s in o)if(o.hasOwnProperty(s)){var a=o[s];s==="children"?typeof a=="string"?r.textContent!==a&&(o.suppressHydrationWarning!==!0&&Ch(r.textContent,a,e),i=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(o.suppressHydrationWarning!==!0&&Ch(r.textContent,a,e),i=["children",""+a]):ju.hasOwnProperty(s)&&a!=null&&s==="onScroll"&&Qe("scroll",r)}switch(n){case"input":Eh(r),Qw(r,o,!0);break;case"textarea":Eh(r),e3(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=sm)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{s=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=B5(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=s.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[pi]=t,e[nd]=r,uS(e,t,!1,!1),t.stateNode=e;e:{switch(s=R0(n,r),n){case"dialog":Qe("cancel",e),Qe("close",e),i=r;break;case"iframe":case"object":case"embed":Qe("load",e),i=r;break;case"video":case"audio":for(i=0;i<au.length;i++)Qe(au[i],e);i=r;break;case"source":Qe("error",e),i=r;break;case"img":case"image":case"link":Qe("error",e),Qe("load",e),i=r;break;case"details":Qe("toggle",e),i=r;break;case"input":qw(e,r),i=C0(e,r),Qe("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=ft({},r,{value:void 0}),Qe("invalid",e);break;case"textarea":Jw(e,r),i=A0(e,r),Qe("invalid",e);break;default:i=r}P0(n,i),a=i;for(o in a)if(a.hasOwnProperty(o)){var l=a[o];o==="style"?U5(e,l):o==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&z5(e,l)):o==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&Yu(e,l):typeof l=="number"&&Yu(e,""+l):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(ju.hasOwnProperty(o)?l!=null&&o==="onScroll"&&Qe("scroll",e):l!=null&&Yy(e,o,l,s))}switch(n){case"input":Eh(e),Qw(e,r,!1);break;case"textarea":Eh(e),e3(e);break;case"option":r.value!=null&&e.setAttribute("value",""+is(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?bl(e,!!r.multiple,o,!1):r.defaultValue!=null&&bl(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=sm)}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 rn(t),null;case 6:if(e&&t.stateNode!=null)hS(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Q(166));if(n=Vs(id.current),Vs(bi.current),Th(t)){if(r=t.stateNode,n=t.memoizedProps,r[pi]=t,(o=r.nodeValue!==n)&&(e=tr,e!==null))switch(e.tag){case 3:Ch(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ch(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[pi]=t,t.stateNode=r}return rn(t),null;case 13:if(rt(ut),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(lt&&qn!==null&&t.mode&1&&!(t.flags&128))Mx(),Bl(),t.flags|=98560,o=!1;else if(o=Th(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Q(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Q(317));o[pi]=t}else Bl(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;rn(t),o=!1}else Br!==null&&(f2(Br),Br=null),o=!0;if(!o)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||ut.current&1?Ot===0&&(Ot=3):Mv())),t.updateQueue!==null&&(t.flags|=4),rn(t),null);case 4:return Hl(),o2(e,t),e===null&&ed(t.stateNode.containerInfo),rn(t),null;case 10:return hv(t.type._context),rn(t),null;case 17:return $n(t.type)&&am(),rn(t),null;case 19:if(rt(ut),o=t.memoizedState,o===null)return rn(t),null;if(r=(t.flags&128)!==0,s=o.rendering,s===null)if(r)Lc(o,!1);else{if(Ot!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(s=mm(e),s!==null){for(t.flags|=128,Lc(o,!1),r=s.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,s=o.alternate,s===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=s.childLanes,o.lanes=s.lanes,o.child=s.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=s.memoizedProps,o.memoizedState=s.memoizedState,o.updateQueue=s.updateQueue,o.type=s.type,e=s.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Ze(ut,ut.current&1|2),t.child}e=e.sibling}o.tail!==null&&_t()>Wl&&(t.flags|=128,r=!0,Lc(o,!1),t.lanes=4194304)}else{if(!r)if(e=mm(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Lc(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!lt)return rn(t),null}else 2*_t()-o.renderingStartTime>Wl&&n!==1073741824&&(t.flags|=128,r=!0,Lc(o,!1),t.lanes=4194304);o.isBackwards?(s.sibling=t.child,t.child=s):(n=o.last,n!==null?n.sibling=s:t.child=s,o.last=s)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=_t(),t.sibling=null,n=ut.current,Ze(ut,r?n&1|2:n&1),t):(rn(t),null);case 22:case 23:return Tv(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Xn&1073741824&&(rn(t),t.subtreeFlags&6&&(t.flags|=8192)):rn(t),null;case 24:return null;case 25:return null}throw Error(Q(156,t.tag))}function U9(e,t){switch(lv(t),t.tag){case 1:return $n(t.type)&&am(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Hl(),rt(Fn),rt(fn),yv(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return pv(t),null;case 13:if(rt(ut),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Q(340));Bl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return rt(ut),null;case 4:return Hl(),null;case 10:return hv(t.type._context),null;case 22:case 23:return Tv(),null;case 24:return null;default:return null}}var Lh=!1,cn=!1,W9=typeof WeakSet=="function"?WeakSet:Set,ae=null;function dl(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 s2(e,t,n){try{n()}catch(r){yt(e,t,r)}}var W3=!1;function V9(e,t){if(W0=rm,e=px(),sv(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 i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var s=0,a=-1,l=-1,c=0,u=0,d=e,h=null;t:for(;;){for(var m;d!==n||i!==0&&d.nodeType!==3||(a=s+i),d!==o||r!==0&&d.nodeType!==3||(l=s+r),d.nodeType===3&&(s+=d.nodeValue.length),(m=d.firstChild)!==null;)h=d,d=m;for(;;){if(d===e)break t;if(h===n&&++c===i&&(a=s),h===o&&++u===r&&(l=s),(m=d.nextSibling)!==null)break;d=h,h=d.parentNode}d=m}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(V0={focusedElem:e,selectionRange:n},rm=!1,ae=t;ae!==null;)if(t=ae,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ae=e;else for(;ae!==null;){t=ae;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var p=g.memoizedProps,v=g.memoizedState,y=t.stateNode,E=y.getSnapshotBeforeUpdate(t.elementType===t.type?p:Dr(t.type,p),v);y.__reactInternalSnapshotBeforeUpdate=E}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Q(163))}}catch(x){yt(t,t.return,x)}if(e=t.sibling,e!==null){e.return=t.return,ae=e;break}ae=t.return}return g=W3,W3=!1,g}function ku(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var o=i.destroy;i.destroy=void 0,o!==void 0&&s2(t,n,o)}i=i.next}while(i!==r)}}function I1(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 a2(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 fS(e){var t=e.alternate;t!==null&&(e.alternate=null,fS(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[pi],delete t[nd],delete t[Y0],delete t[I9],delete t[C9])),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 mS(e){return e.tag===5||e.tag===3||e.tag===4}function V3(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||mS(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 l2(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=sm));else if(r!==4&&(e=e.child,e!==null))for(l2(e,t,n),e=e.sibling;e!==null;)l2(e,t,n),e=e.sibling}function c2(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(c2(e,t,n),e=e.sibling;e!==null;)c2(e,t,n),e=e.sibling}var Yt=null,Nr=!1;function ho(e,t,n){for(n=n.child;n!==null;)gS(e,t,n),n=n.sibling}function gS(e,t,n){if(wi&&typeof wi.onCommitFiberUnmount=="function")try{wi.onCommitFiberUnmount(v1,n)}catch{}switch(n.tag){case 5:cn||dl(n,t);case 6:var r=Yt,i=Nr;Yt=null,ho(e,t,n),Yt=r,Nr=i,Yt!==null&&(Nr?(e=Yt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Yt.removeChild(n.stateNode));break;case 18:Yt!==null&&(Nr?(e=Yt,n=n.stateNode,e.nodeType===8?Qg(e.parentNode,n):e.nodeType===1&&Qg(e,n),qu(e)):Qg(Yt,n.stateNode));break;case 4:r=Yt,i=Nr,Yt=n.stateNode.containerInfo,Nr=!0,ho(e,t,n),Yt=r,Nr=i;break;case 0:case 11:case 14:case 15:if(!cn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,s=o.destroy;o=o.tag,s!==void 0&&(o&2||o&4)&&s2(n,t,s),i=i.next}while(i!==r)}ho(e,t,n);break;case 1:if(!cn&&(dl(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)}ho(e,t,n);break;case 21:ho(e,t,n);break;case 22:n.mode&1?(cn=(r=cn)||n.memoizedState!==null,ho(e,t,n),cn=r):ho(e,t,n);break;default:ho(e,t,n)}}function G3(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new W9),t.forEach(function(r){var i=J9.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Tr(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var o=e,s=t,a=s;e:for(;a!==null;){switch(a.tag){case 5:Yt=a.stateNode,Nr=!1;break e;case 3:Yt=a.stateNode.containerInfo,Nr=!0;break e;case 4:Yt=a.stateNode.containerInfo,Nr=!0;break e}a=a.return}if(Yt===null)throw Error(Q(160));gS(o,s,i),Yt=null,Nr=!1;var l=i.alternate;l!==null&&(l.return=null),i.return=null}catch(c){yt(i,t,c)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)pS(t,e),t=t.sibling}function pS(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Tr(t,e),ii(e),r&4){try{ku(3,e,e.return),I1(3,e)}catch(p){yt(e,e.return,p)}try{ku(5,e,e.return)}catch(p){yt(e,e.return,p)}}break;case 1:Tr(t,e),ii(e),r&512&&n!==null&&dl(n,n.return);break;case 5:if(Tr(t,e),ii(e),r&512&&n!==null&&dl(n,n.return),e.flags&32){var i=e.stateNode;try{Yu(i,"")}catch(p){yt(e,e.return,p)}}if(r&4&&(i=e.stateNode,i!=null)){var o=e.memoizedProps,s=n!==null?n.memoizedProps:o,a=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{a==="input"&&o.type==="radio"&&o.name!=null&&F5(i,o),R0(a,s);var c=R0(a,o);for(s=0;s<l.length;s+=2){var u=l[s],d=l[s+1];u==="style"?U5(i,d):u==="dangerouslySetInnerHTML"?z5(i,d):u==="children"?Yu(i,d):Yy(i,u,d,c)}switch(a){case"input":T0(i,o);break;case"textarea":$5(i,o);break;case"select":var h=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m!=null?bl(i,!!o.multiple,m,!1):h!==!!o.multiple&&(o.defaultValue!=null?bl(i,!!o.multiple,o.defaultValue,!0):bl(i,!!o.multiple,o.multiple?[]:"",!1))}i[nd]=o}catch(p){yt(e,e.return,p)}}break;case 6:if(Tr(t,e),ii(e),r&4){if(e.stateNode===null)throw Error(Q(162));i=e.stateNode,o=e.memoizedProps;try{i.nodeValue=o}catch(p){yt(e,e.return,p)}}break;case 3:if(Tr(t,e),ii(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{qu(t.containerInfo)}catch(p){yt(e,e.return,p)}break;case 4:Tr(t,e),ii(e);break;case 13:Tr(t,e),ii(e),i=e.child,i.flags&8192&&(o=i.memoizedState!==null,i.stateNode.isHidden=o,!o||i.alternate!==null&&i.alternate.memoizedState!==null||(Iv=_t())),r&4&&G3(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(cn=(c=cn)||u,Tr(t,e),cn=c):Tr(t,e),ii(e),r&8192){if(c=e.memoizedState!==null,(e.stateNode.isHidden=c)&&!u&&e.mode&1)for(ae=e,u=e.child;u!==null;){for(d=ae=u;ae!==null;){switch(h=ae,m=h.child,h.tag){case 0:case 11:case 14:case 15:ku(4,h,h.return);break;case 1:dl(h,h.return);var g=h.stateNode;if(typeof g.componentWillUnmount=="function"){r=h,n=h.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(p){yt(r,n,p)}}break;case 5:dl(h,h.return);break;case 22:if(h.memoizedState!==null){Y3(d);continue}}m!==null?(m.return=h,ae=m):Y3(d)}u=u.sibling}e:for(u=null,d=e;;){if(d.tag===5){if(u===null){u=d;try{i=d.stateNode,c?(o=i.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(a=d.stateNode,l=d.memoizedProps.style,s=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=H5("display",s))}catch(p){yt(e,e.return,p)}}}else if(d.tag===6){if(u===null)try{d.stateNode.nodeValue=c?"":d.memoizedProps}catch(p){yt(e,e.return,p)}}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:Tr(t,e),ii(e),r&4&&G3(e);break;case 21:break;default:Tr(t,e),ii(e)}}function ii(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(mS(n)){var r=n;break e}n=n.return}throw Error(Q(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Yu(i,""),r.flags&=-33);var o=V3(e);c2(e,o,i);break;case 3:case 4:var s=r.stateNode.containerInfo,a=V3(e);l2(e,a,s);break;default:throw Error(Q(161))}}catch(l){yt(e,e.return,l)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function G9(e,t,n){ae=e,yS(e)}function yS(e,t,n){for(var r=(e.mode&1)!==0;ae!==null;){var i=ae,o=i.child;if(i.tag===22&&r){var s=i.memoizedState!==null||Lh;if(!s){var a=i.alternate,l=a!==null&&a.memoizedState!==null||cn;a=Lh;var c=cn;if(Lh=s,(cn=l)&&!c)for(ae=i;ae!==null;)s=ae,l=s.child,s.tag===22&&s.memoizedState!==null?K3(i):l!==null?(l.return=s,ae=l):K3(i);for(;o!==null;)ae=o,yS(o),o=o.sibling;ae=i,Lh=a,cn=c}j3(e)}else i.subtreeFlags&8772&&o!==null?(o.return=i,ae=o):j3(e)}}function j3(e){for(;ae!==null;){var t=ae;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:cn||I1(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!cn)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:Dr(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&M3(t,o,r);break;case 3:var s=t.updateQueue;if(s!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}M3(t,s,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var l=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var c=t.alternate;if(c!==null){var u=c.memoizedState;if(u!==null){var d=u.dehydrated;d!==null&&qu(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Q(163))}cn||t.flags&512&&a2(t)}catch(h){yt(t,t.return,h)}}if(t===e){ae=null;break}if(n=t.sibling,n!==null){n.return=t.return,ae=n;break}ae=t.return}}function Y3(e){for(;ae!==null;){var t=ae;if(t===e){ae=null;break}var n=t.sibling;if(n!==null){n.return=t.return,ae=n;break}ae=t.return}}function K3(e){for(;ae!==null;){var t=ae;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{I1(4,t)}catch(l){yt(t,n,l)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(l){yt(t,i,l)}}var o=t.return;try{a2(t)}catch(l){yt(t,o,l)}break;case 5:var s=t.return;try{a2(t)}catch(l){yt(t,s,l)}}}catch(l){yt(t,t.return,l)}if(t===e){ae=null;break}var a=t.sibling;if(a!==null){a.return=t.return,ae=a;break}ae=t.return}}var j9=Math.ceil,ym=io.ReactCurrentDispatcher,Sv=io.ReactCurrentOwner,pr=io.ReactCurrentBatchConfig,Re=0,Wt=null,Ct=null,Qt=0,Xn=0,hl=ys(0),Ot=0,ld=null,da=0,C1=0,kv=0,Iu=null,Pn=null,Iv=0,Wl=1/0,Ni=null,vm=!1,u2=null,Ko=null,Ph=!1,Ro=null,Em=0,Cu=0,d2=null,bf=-1,_f=0;function Sn(){return Re&6?_t():bf!==-1?bf:bf=_t()}function Zo(e){return e.mode&1?Re&2&&Qt!==0?Qt&-Qt:M9.transition!==null?(_f===0&&(_f=ex()),_f):(e=Ue,e!==0||(e=window.event,e=e===void 0?16:ax(e.type)),e):1}function Vr(e,t,n,r){if(50<Cu)throw Cu=0,d2=null,Error(Q(185));Wd(e,n,r),(!(Re&2)||e!==Wt)&&(e===Wt&&(!(Re&2)&&(C1|=n),Ot===4&&ko(e,Qt)),Bn(e,r),n===1&&Re===0&&!(t.mode&1)&&(Wl=_t()+500,x1&&vs()))}function Bn(e,t){var n=e.callbackNode;ML(e,t);var r=nm(e,e===Wt?Qt:0);if(r===0)n!==null&&r3(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&r3(n),t===1)e.tag===0?T9(Z3.bind(null,e)):Ix(Z3.bind(null,e)),S9(function(){!(Re&6)&&vs()}),n=null;else{switch(tx(r)){case 1:n=Qy;break;case 4:n=Q5;break;case 16:n=tm;break;case 536870912:n=J5;break;default:n=tm}n=kS(n,vS.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function vS(e,t){if(bf=-1,_f=0,Re&6)throw Error(Q(327));var n=e.callbackNode;if(Il()&&e.callbackNode!==n)return null;var r=nm(e,e===Wt?Qt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=wm(e,r);else{t=r;var i=Re;Re|=2;var o=wS();(Wt!==e||Qt!==t)&&(Ni=null,Wl=_t()+500,ta(e,t));do try{Z9();break}catch(a){ES(e,a)}while(!0);dv(),ym.current=o,Re=i,Ct!==null?t=0:(Wt=null,Qt=0,t=Ot)}if(t!==0){if(t===2&&(i=$0(e),i!==0&&(r=i,t=h2(e,i))),t===1)throw n=ld,ta(e,0),ko(e,r),Bn(e,_t()),n;if(t===6)ko(e,r);else{if(i=e.current.alternate,!(r&30)&&!Y9(i)&&(t=wm(e,r),t===2&&(o=$0(e),o!==0&&(r=o,t=h2(e,o))),t===1))throw n=ld,ta(e,0),ko(e,r),Bn(e,_t()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(Q(345));case 2:Cs(e,Pn,Ni);break;case 3:if(ko(e,r),(r&130023424)===r&&(t=Iv+500-_t(),10<t)){if(nm(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Sn(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=j0(Cs.bind(null,e,Pn,Ni),t);break}Cs(e,Pn,Ni);break;case 4:if(ko(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var s=31-Wr(r);o=1<<s,s=t[s],s>i&&(i=s),r&=~o}if(r=i,r=_t()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*j9(r/1960))-r,10<r){e.timeoutHandle=j0(Cs.bind(null,e,Pn,Ni),r);break}Cs(e,Pn,Ni);break;case 5:Cs(e,Pn,Ni);break;default:throw Error(Q(329))}}}return Bn(e,_t()),e.callbackNode===n?vS.bind(null,e):null}function h2(e,t){var n=Iu;return e.current.memoizedState.isDehydrated&&(ta(e,t).flags|=256),e=wm(e,t),e!==2&&(t=Pn,Pn=n,t!==null&&f2(t)),e}function f2(e){Pn===null?Pn=e:Pn.push.apply(Pn,e)}function Y9(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 i=n[r],o=i.getSnapshot;i=i.value;try{if(!Zr(o(),i))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 ko(e,t){for(t&=~kv,t&=~C1,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Wr(t),r=1<<n;e[n]=-1,t&=~r}}function Z3(e){if(Re&6)throw Error(Q(327));Il();var t=nm(e,0);if(!(t&1))return Bn(e,_t()),null;var n=wm(e,t);if(e.tag!==0&&n===2){var r=$0(e);r!==0&&(t=r,n=h2(e,r))}if(n===1)throw n=ld,ta(e,0),ko(e,t),Bn(e,_t()),n;if(n===6)throw Error(Q(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Cs(e,Pn,Ni),Bn(e,_t()),null}function Cv(e,t){var n=Re;Re|=1;try{return e(t)}finally{Re=n,Re===0&&(Wl=_t()+500,x1&&vs())}}function ha(e){Ro!==null&&Ro.tag===0&&!(Re&6)&&Il();var t=Re;Re|=1;var n=pr.transition,r=Ue;try{if(pr.transition=null,Ue=1,e)return e()}finally{Ue=r,pr.transition=n,Re=t,!(Re&6)&&vs()}}function Tv(){Xn=hl.current,rt(hl)}function ta(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,x9(n)),Ct!==null)for(n=Ct.return;n!==null;){var r=n;switch(lv(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&am();break;case 3:Hl(),rt(Fn),rt(fn),yv();break;case 5:pv(r);break;case 4:Hl();break;case 13:rt(ut);break;case 19:rt(ut);break;case 10:hv(r.type._context);break;case 22:case 23:Tv()}n=n.return}if(Wt=e,Ct=e=Xo(e.current,null),Qt=Xn=t,Ot=0,ld=null,kv=C1=da=0,Pn=Iu=null,Ws!==null){for(t=0;t<Ws.length;t++)if(n=Ws[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,o=n.pending;if(o!==null){var s=o.next;o.next=i,r.next=s}n.pending=r}Ws=null}return e}function ES(e,t){do{var n=Ct;try{if(dv(),vf.current=pm,gm){for(var r=ht.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}gm=!1}if(ua=0,Ht=Rt=ht=null,Su=!1,od=0,Sv.current=null,n===null||n.return===null){Ot=1,ld=t,Ct=null;break}e:{var o=e,s=n.return,a=n,l=t;if(t=Qt,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,u=a,d=u.tag;if(!(u.mode&1)&&(d===0||d===11||d===15)){var h=u.alternate;h?(u.updateQueue=h.updateQueue,u.memoizedState=h.memoizedState,u.lanes=h.lanes):(u.updateQueue=null,u.memoizedState=null)}var m=N3(s);if(m!==null){m.flags&=-257,F3(m,s,a,o,t),m.mode&1&&O3(o,c,t),t=m,l=c;var g=t.updateQueue;if(g===null){var p=new Set;p.add(l),t.updateQueue=p}else g.add(l);break e}else{if(!(t&1)){O3(o,c,t),Mv();break e}l=Error(Q(426))}}else if(lt&&a.mode&1){var v=N3(s);if(v!==null){!(v.flags&65536)&&(v.flags|=256),F3(v,s,a,o,t),cv(Ul(l,a));break e}}o=l=Ul(l,a),Ot!==4&&(Ot=2),Iu===null?Iu=[o]:Iu.push(o),o=s;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var y=nS(o,l,t);T3(o,y);break e;case 1:a=l;var E=o.type,w=o.stateNode;if(!(o.flags&128)&&(typeof E.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Ko===null||!Ko.has(w)))){o.flags|=65536,t&=-t,o.lanes|=t;var x=rS(o,a,t);T3(o,x);break e}}o=o.return}while(o!==null)}_S(n)}catch(C){t=C,Ct===n&&n!==null&&(Ct=n=n.return);continue}break}while(!0)}function wS(){var e=ym.current;return ym.current=pm,e===null?pm:e}function Mv(){(Ot===0||Ot===3||Ot===2)&&(Ot=4),Wt===null||!(da&268435455)&&!(C1&268435455)||ko(Wt,Qt)}function wm(e,t){var n=Re;Re|=2;var r=wS();(Wt!==e||Qt!==t)&&(Ni=null,ta(e,t));do try{K9();break}catch(i){ES(e,i)}while(!0);if(dv(),Re=n,ym.current=r,Ct!==null)throw Error(Q(261));return Wt=null,Qt=0,Ot}function K9(){for(;Ct!==null;)bS(Ct)}function Z9(){for(;Ct!==null&&!wL();)bS(Ct)}function bS(e){var t=SS(e.alternate,e,Xn);e.memoizedProps=e.pendingProps,t===null?_S(e):Ct=t,Sv.current=null}function _S(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=U9(n,t),n!==null){n.flags&=32767,Ct=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Ot=6,Ct=null;return}}else if(n=H9(n,t,Xn),n!==null){Ct=n;return}if(t=t.sibling,t!==null){Ct=t;return}Ct=t=e}while(t!==null);Ot===0&&(Ot=5)}function Cs(e,t,n){var r=Ue,i=pr.transition;try{pr.transition=null,Ue=1,X9(e,t,n,r)}finally{pr.transition=i,Ue=r}return null}function X9(e,t,n,r){do Il();while(Ro!==null);if(Re&6)throw Error(Q(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Q(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(AL(e,o),e===Wt&&(Ct=Wt=null,Qt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Ph||(Ph=!0,kS(tm,function(){return Il(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=pr.transition,pr.transition=null;var s=Ue;Ue=1;var a=Re;Re|=4,Sv.current=null,V9(e,n),pS(n,e),p9(V0),rm=!!W0,V0=W0=null,e.current=n,G9(n),bL(),Re=a,Ue=s,pr.transition=o}else e.current=n;if(Ph&&(Ph=!1,Ro=e,Em=i),o=e.pendingLanes,o===0&&(Ko=null),SL(n.stateNode),Bn(e,_t()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(vm)throw vm=!1,e=u2,u2=null,e;return Em&1&&e.tag!==0&&Il(),o=e.pendingLanes,o&1?e===d2?Cu++:(Cu=0,d2=e):Cu=0,vs(),null}function Il(){if(Ro!==null){var e=tx(Em),t=pr.transition,n=Ue;try{if(pr.transition=null,Ue=16>e?16:e,Ro===null)var r=!1;else{if(e=Ro,Ro=null,Em=0,Re&6)throw Error(Q(331));var i=Re;for(Re|=4,ae=e.current;ae!==null;){var o=ae,s=o.child;if(ae.flags&16){var a=o.deletions;if(a!==null){for(var l=0;l<a.length;l++){var c=a[l];for(ae=c;ae!==null;){var u=ae;switch(u.tag){case 0:case 11:case 15:ku(8,u,o)}var d=u.child;if(d!==null)d.return=u,ae=d;else for(;ae!==null;){u=ae;var h=u.sibling,m=u.return;if(fS(u),u===c){ae=null;break}if(h!==null){h.return=m,ae=h;break}ae=m}}}var g=o.alternate;if(g!==null){var p=g.child;if(p!==null){g.child=null;do{var v=p.sibling;p.sibling=null,p=v}while(p!==null)}}ae=o}}if(o.subtreeFlags&2064&&s!==null)s.return=o,ae=s;else e:for(;ae!==null;){if(o=ae,o.flags&2048)switch(o.tag){case 0:case 11:case 15:ku(9,o,o.return)}var y=o.sibling;if(y!==null){y.return=o.return,ae=y;break e}ae=o.return}}var E=e.current;for(ae=E;ae!==null;){s=ae;var w=s.child;if(s.subtreeFlags&2064&&w!==null)w.return=s,ae=w;else e:for(s=E;ae!==null;){if(a=ae,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:I1(9,a)}}catch(C){yt(a,a.return,C)}if(a===s){ae=null;break e}var x=a.sibling;if(x!==null){x.return=a.return,ae=x;break e}ae=a.return}}if(Re=i,vs(),wi&&typeof wi.onPostCommitFiberRoot=="function")try{wi.onPostCommitFiberRoot(v1,e)}catch{}r=!0}return r}finally{Ue=n,pr.transition=t}}return!1}function X3(e,t,n){t=Ul(n,t),t=nS(e,t,1),e=Yo(e,t,1),t=Sn(),e!==null&&(Wd(e,1,t),Bn(e,t))}function yt(e,t,n){if(e.tag===3)X3(e,e,n);else for(;t!==null;){if(t.tag===3){X3(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Ko===null||!Ko.has(r))){e=Ul(n,e),e=rS(t,e,1),t=Yo(t,e,1),e=Sn(),t!==null&&(Wd(t,1,e),Bn(t,e));break}}t=t.return}}function q9(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Sn(),e.pingedLanes|=e.suspendedLanes&n,Wt===e&&(Qt&n)===n&&(Ot===4||Ot===3&&(Qt&130023424)===Qt&&500>_t()-Iv?ta(e,0):kv|=n),Bn(e,t)}function xS(e,t){t===0&&(e.mode&1?(t=_h,_h<<=1,!(_h&130023424)&&(_h=4194304)):t=1);var n=Sn();e=qi(e,t),e!==null&&(Wd(e,t,n),Bn(e,n))}function Q9(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),xS(e,n)}function J9(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Q(314))}r!==null&&r.delete(t),xS(e,n)}var SS;SS=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Fn.current)Rn=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Rn=!1,z9(e,t,n);Rn=!!(e.flags&131072)}else Rn=!1,lt&&t.flags&1048576&&Cx(t,um,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;wf(e,t),e=t.pendingProps;var i=$l(t,fn.current);kl(t,n),i=Ev(null,t,r,e,i,n);var o=wv();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,$n(r)?(o=!0,lm(t)):o=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,mv(t),i.updater=S1,t.stateNode=i,i._reactInternals=t,J0(t,r,e,n),t=n2(null,t,r,!0,o,n)):(t.tag=0,lt&&o&&av(t),En(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(wf(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=tP(r),e=Dr(r,e),i){case 0:t=t2(null,t,r,e,n);break e;case 1:t=z3(null,t,r,e,n);break e;case 11:t=$3(null,t,r,e,n);break e;case 14:t=B3(null,t,r,Dr(r.type,e),n);break e}throw Error(Q(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Dr(r,i),t2(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Dr(r,i),z3(e,t,r,i,n);case 3:e:{if(aS(t),e===null)throw Error(Q(387));r=t.pendingProps,o=t.memoizedState,i=o.element,Lx(e,t),fm(t,r,null,n);var s=t.memoizedState;if(r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){i=Ul(Error(Q(423)),t),t=H3(e,t,r,n,i);break e}else if(r!==i){i=Ul(Error(Q(424)),t),t=H3(e,t,r,n,i);break e}else for(qn=jo(t.stateNode.containerInfo.firstChild),tr=t,lt=!0,Br=null,n=Ox(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Bl(),r===i){t=Qi(e,t,n);break e}En(e,t,r,n)}t=t.child}return t;case 5:return Nx(t),e===null&&X0(t),r=t.type,i=t.pendingProps,o=e!==null?e.memoizedProps:null,s=i.children,G0(r,i)?s=null:o!==null&&G0(r,o)&&(t.flags|=32),sS(e,t),En(e,t,s,n),t.child;case 6:return e===null&&X0(t),null;case 13:return lS(e,t,n);case 4:return gv(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=zl(t,null,r,n):En(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Dr(r,i),$3(e,t,r,i,n);case 7:return En(e,t,t.pendingProps,n),t.child;case 8:return En(e,t,t.pendingProps.children,n),t.child;case 12:return En(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,o=t.memoizedProps,s=i.value,Ze(dm,r._currentValue),r._currentValue=s,o!==null)if(Zr(o.value,s)){if(o.children===i.children&&!Fn.current){t=Qi(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var a=o.dependencies;if(a!==null){s=o.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(o.tag===1){l=Wi(-1,n&-n),l.tag=2;var c=o.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),q0(o.return,n,t),a.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(Q(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),q0(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}En(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,kl(t,n),i=br(i),r=r(i),t.flags|=1,En(e,t,r,n),t.child;case 14:return r=t.type,i=Dr(r,t.pendingProps),i=Dr(r.type,i),B3(e,t,r,i,n);case 15:return iS(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Dr(r,i),wf(e,t),t.tag=1,$n(r)?(e=!0,lm(t)):e=!1,kl(t,n),Rx(t,r,i),J0(t,r,i,n),n2(null,t,r,!0,e,n);case 19:return cS(e,t,n);case 22:return oS(e,t,n)}throw Error(Q(156,t.tag))};function kS(e,t){return q5(e,t)}function eP(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 eP(e,t,n,r)}function Av(e){return e=e.prototype,!(!e||!e.isReactComponent)}function tP(e){if(typeof e=="function")return Av(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Zy)return 11;if(e===Xy)return 14}return 2}function Xo(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 xf(e,t,n,r,i,o){var s=2;if(r=e,typeof e=="function")Av(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case nl:return na(n.children,i,o,t);case Ky:s=8,i|=8;break;case x0:return e=mr(12,n,t,i|2),e.elementType=x0,e.lanes=o,e;case S0:return e=mr(13,n,t,i),e.elementType=S0,e.lanes=o,e;case k0:return e=mr(19,n,t,i),e.elementType=k0,e.lanes=o,e;case D5:return T1(n,i,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case P5:s=10;break e;case R5:s=9;break e;case Zy:s=11;break e;case Xy:s=14;break e;case Eo:s=16,r=null;break e}throw Error(Q(130,e==null?e:typeof e,""))}return t=mr(s,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function na(e,t,n,r){return e=mr(7,e,r,t),e.lanes=n,e}function T1(e,t,n,r){return e=mr(22,e,r,t),e.elementType=D5,e.lanes=n,e.stateNode={isHidden:!1},e}function sp(e,t,n){return e=mr(6,e,null,t),e.lanes=n,e}function ap(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 nP(e,t,n,r,i){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=Hg(0),this.expirationTimes=Hg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Hg(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Lv(e,t,n,r,i,o,s,a,l){return e=new nP(e,t,n,a,l),t===1?(t=1,o===!0&&(t|=8)):t=0,o=mr(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},mv(o),e}function rP(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:tl,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function IS(e){if(!e)return os;e=e._reactInternals;e:{if(Pa(e)!==e||e.tag!==1)throw Error(Q(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if($n(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Q(171))}if(e.tag===1){var n=e.type;if($n(n))return kx(e,n,t)}return t}function CS(e,t,n,r,i,o,s,a,l){return e=Lv(n,r,!0,e,i,o,s,a,l),e.context=IS(null),n=e.current,r=Sn(),i=Zo(n),o=Wi(r,i),o.callback=t??null,Yo(n,o,i),e.current.lanes=i,Wd(e,i,r),Bn(e,r),e}function M1(e,t,n,r){var i=t.current,o=Sn(),s=Zo(i);return n=IS(n),t.context===null?t.context=n:t.pendingContext=n,t=Wi(o,s),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Yo(i,t,s),e!==null&&(Vr(e,i,s,o),yf(e,i,s)),s}function bm(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 q3(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Pv(e,t){q3(e,t),(e=e.alternate)&&q3(e,t)}function iP(){return null}var TS=typeof reportError=="function"?reportError:function(e){console.error(e)};function Rv(e){this._internalRoot=e}A1.prototype.render=Rv.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Q(409));M1(e,t,null,null)};A1.prototype.unmount=Rv.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ha(function(){M1(null,e,null,null)}),t[Xi]=null}};function A1(e){this._internalRoot=e}A1.prototype.unstable_scheduleHydration=function(e){if(e){var t=ix();e={blockedOn:null,target:e,priority:t};for(var n=0;n<So.length&&t!==0&&t<So[n].priority;n++);So.splice(n,0,e),n===0&&sx(e)}};function Dv(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function L1(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Q3(){}function oP(e,t,n,r,i){if(i){if(typeof r=="function"){var o=r;r=function(){var c=bm(s);o.call(c)}}var s=CS(t,r,e,0,null,!1,!1,"",Q3);return e._reactRootContainer=s,e[Xi]=s.current,ed(e.nodeType===8?e.parentNode:e),ha(),s}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var a=r;r=function(){var c=bm(l);a.call(c)}}var l=Lv(e,0,!1,null,null,!1,!1,"",Q3);return e._reactRootContainer=l,e[Xi]=l.current,ed(e.nodeType===8?e.parentNode:e),ha(function(){M1(t,l,n,r)}),l}function P1(e,t,n,r,i){var o=n._reactRootContainer;if(o){var s=o;if(typeof i=="function"){var a=i;i=function(){var l=bm(s);a.call(l)}}M1(t,s,e,i)}else s=oP(n,t,e,i,r);return bm(s)}nx=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=su(t.pendingLanes);n!==0&&(Jy(t,n|1),Bn(t,_t()),!(Re&6)&&(Wl=_t()+500,vs()))}break;case 13:ha(function(){var r=qi(e,1);if(r!==null){var i=Sn();Vr(r,e,1,i)}}),Pv(e,1)}};ev=function(e){if(e.tag===13){var t=qi(e,134217728);if(t!==null){var n=Sn();Vr(t,e,134217728,n)}Pv(e,134217728)}};rx=function(e){if(e.tag===13){var t=Zo(e),n=qi(e,t);if(n!==null){var r=Sn();Vr(n,e,t,r)}Pv(e,t)}};ix=function(){return Ue};ox=function(e,t){var n=Ue;try{return Ue=e,t()}finally{Ue=n}};O0=function(e,t,n){switch(t){case"input":if(T0(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 i=_1(r);if(!i)throw Error(Q(90));N5(r),T0(r,i)}}}break;case"textarea":$5(e,n);break;case"select":t=n.value,t!=null&&bl(e,!!n.multiple,t,!1)}};G5=Cv;j5=ha;var sP={usingClientEntryPoint:!1,Events:[Gd,sl,_1,W5,V5,Cv]},Pc={findFiberByHostInstance:Us,bundleType:0,version:"18.2.0",rendererPackageName:"react-dom"},aP={bundleType:Pc.bundleType,version:Pc.version,rendererPackageName:Pc.rendererPackageName,rendererConfig:Pc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:io.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Z5(e),e===null?null:e.stateNode},findFiberByHostInstance:Pc.findFiberByHostInstance||iP,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.2.0-next-9e3b772b8-20220608"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Rh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Rh.isDisabled&&Rh.supportsFiber)try{v1=Rh.inject(aP),wi=Rh}catch{}}or.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=sP;or.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Dv(t))throw Error(Q(200));return rP(e,t,null,n)};or.createRoot=function(e,t){if(!Dv(e))throw Error(Q(299));var n=!1,r="",i=TS;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=Lv(e,1,!1,null,null,n,!1,r,i),e[Xi]=t.current,ed(e.nodeType===8?e.parentNode:e),new Rv(t)};or.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(Q(188)):(e=Object.keys(e).join(","),Error(Q(268,e)));return e=Z5(t),e=e===null?null:e.stateNode,e};or.flushSync=function(e){return ha(e)};or.hydrate=function(e,t,n){if(!L1(t))throw Error(Q(200));return P1(null,e,t,!0,n)};or.hydrateRoot=function(e,t,n){if(!Dv(e))throw Error(Q(405));var r=n!=null&&n.hydratedSources||null,i=!1,o="",s=TS;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(s=n.onRecoverableError)),t=CS(t,null,e,1,n??null,i,!1,o,s),e[Xi]=t.current,ed(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new A1(t)};or.render=function(e,t,n){if(!L1(t))throw Error(Q(200));return P1(null,e,t,!1,n)};or.unmountComponentAtNode=function(e){if(!L1(e))throw Error(Q(40));return e._reactRootContainer?(ha(function(){P1(null,null,e,!1,function(){e._reactRootContainer=null,e[Xi]=null})}),!0):!1};or.unstable_batchedUpdates=Cv;or.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!L1(n))throw Error(Q(200));if(e==null||e._reactInternals===void 0)throw Error(Q(38));return P1(e,t,n,!1,r)};or.version="18.2.0-next-9e3b772b8-20220608";function MS(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(MS)}catch(e){console.error(e)}}MS(),C5.exports=or;var nr=C5.exports;const lP=rc(nr);var AS,J3=nr;AS=J3.createRoot,J3.hydrateRoot;const LS=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})};function cP(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function cd(e){"@babel/helpers - typeof";return cd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cd(e)}function uP(e,t){if(cd(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(cd(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function dP(e){var t=uP(e,"string");return cd(t)==="symbol"?t:String(t)}function eb(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,dP(r.key),r)}}function hP(e,t,n){return t&&eb(e.prototype,t),n&&eb(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var PS=[],fP=PS.forEach,mP=PS.slice;function gP(e){return fP.call(mP.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var tb=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,pP=function(t,n,r){var i=r||{};i.path=i.path||"/";var o=encodeURIComponent(n),s=t+"="+o;if(i.maxAge>0){var a=i.maxAge-0;if(isNaN(a))throw new Error("maxAge should be a Number");s+="; Max-Age="+Math.floor(a)}if(i.domain){if(!tb.test(i.domain))throw new TypeError("option domain is invalid");s+="; Domain="+i.domain}if(i.path){if(!tb.test(i.path))throw new TypeError("option path is invalid");s+="; Path="+i.path}if(i.expires){if(typeof i.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+="; Expires="+i.expires.toUTCString()}if(i.httpOnly&&(s+="; HttpOnly"),i.secure&&(s+="; Secure"),i.sameSite){var l=typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.sameSite;switch(l){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return s},nb={create:function(t,n,r,i){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+r*60*1e3)),i&&(o.domain=i),document.cookie=pP(t,encodeURIComponent(n),o)},read:function(t){for(var n=t+"=",r=document.cookie.split(";"),i=0;i<r.length;i++){for(var o=r[i];o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(n)===0)return o.substring(n.length,o.length)}return null},remove:function(t){this.create(t,"",-1)}},yP={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=nb.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&nb.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},vP={name:"querystring",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var i=r.substring(1),o=i.split("&"),s=0;s<o.length;s++){var a=o[s].indexOf("=");if(a>0){var l=o[s].substring(0,a);l===t.lookupQuerystring&&(n=o[s].substring(a+1))}}}return n}},Rc=null,rb=function(){if(Rc!==null)return Rc;try{Rc=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Rc=!1}return Rc},EP={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&rb()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&rb()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Dc=null,ib=function(){if(Dc!==null)return Dc;try{Dc=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Dc=!1}return Dc},wP={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&ib()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&ib()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},bP={name:"navigator",lookup:function(t){var n=[];if(typeof navigator<"u"){if(navigator.languages)for(var r=0;r<navigator.languages.length;r++)n.push(navigator.languages[r]);navigator.userLanguage&&n.push(navigator.userLanguage),navigator.language&&n.push(navigator.language)}return n.length>0?n:void 0}},_P={name:"htmlTag",lookup:function(t){var n,r=t.htmlTag||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(n=r.getAttribute("lang")),n}},xP={name:"path",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if(typeof t.lookupFromPathIndex=="number"){if(typeof r[t.lookupFromPathIndex]!="string")return;n=r[t.lookupFromPathIndex].replace("/","")}else n=r[0].replace("/","")}return n}},SP={name:"subdomain",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.href.match(/(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/gi);r instanceof Array&&(typeof t.lookupFromSubdomainIndex=="number"?n=r[t.lookupFromSubdomainIndex].replace("http://","").replace("https://","").replace(".",""):n=r[0].replace("http://","").replace("https://","").replace(".",""))}return n}};function kP(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"]}}var RS=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};cP(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return hP(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=n,this.options=gP(r,this.options||{},kP()),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=i,this.addDetector(yP),this.addDetector(vP),this.addDetector(EP),this.addDetector(wP),this.addDetector(bP),this.addDetector(_P),this.addDetector(xP),this.addDetector(SP)}},{key:"addDetector",value:function(n){this.detectors[n.name]=n}},{key:"detect",value:function(n){var r=this;n||(n=this.options.order);var i=[];return n.forEach(function(o){if(r.detectors[o]){var s=r.detectors[o].lookup(r.options);s&&typeof s=="string"&&(s=[s]),s&&(i=i.concat(s))}}),this.services.languageUtils.getBestMatchFromCodes?i:i.length>0?i[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var i=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(o){i.detectors[o]&&i.detectors[o].cacheUserLanguage(n,i.options)}))}}]),e}();RS.type="languageDetector";var IP={VITE_APP_BACKEND_V2_GET_URL:"https://json.excalidraw.com/api/v2/",VITE_APP_BACKEND_V2_POST_URL:"https://json.excalidraw.com/api/v2/post/",VITE_APP_LIBRARY_URL:"https://libraries.excalidraw.com",VITE_APP_LIBRARY_BACKEND:"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries",VITE_APP_PLUS_LP:"https://plus.excalidraw.com",VITE_APP_PLUS_APP:"https://app.excalidraw.com",VITE_APP_AI_BACKEND:"https://oss-ai.excalidraw.com",VITE_APP_WS_SERVER_URL:"https://oss-collab.excalidraw.com",VITE_APP_FIREBASE_CONFIG:'{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}',VITE_APP_DISABLE_TRACKING:"",VITE_APP_GIT_SHA:"",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const CP=["ai"],Ae=(e,t,n,r)=>{try{typeof window>"u"||IP.VITE_WORKER_ID;return}catch(i){console.error("error during analytics",i)}},TP="#ffffff",MP="#000000",AP=["#f8f9fa","#f1f3f5","#e9ecef","#dee2e6","#ced4da","#adb5bd","#868e96","#495057","#343a40","#212529"],LP=["#fff5f5","#ffe3e3","#ffc9c9","#ffa8a8","#ff8787","#ff6b6b","#fa5252","#f03e3e","#e03131","#c92a2a"],PP=["#fff0f6","#ffdeeb","#fcc2d7","#faa2c1","#f783ac","#f06595","#e64980","#d6336c","#c2255c","#a61e4d"],RP=["#f8f0fc","#f3d9fa","#eebefa","#e599f7","#da77f2","#cc5de8","#be4bdb","#ae3ec9","#9c36b5","#862e9c"],DP=["#f3f0ff","#e5dbff","#d0bfff","#b197fc","#9775fa","#845ef7","#7950f2","#7048e8","#6741d9","#5f3dc4"],OP=["#edf2ff","#dbe4ff","#bac8ff","#91a7ff","#748ffc","#5c7cfa","#4c6ef5","#4263eb","#3b5bdb","#364fc7"],NP=["#e7f5ff","#d0ebff","#a5d8ff","#74c0fc","#4dabf7","#339af0","#228be6","#1c7ed6","#1971c2","#1864ab"],FP=["#e3fafc","#c5f6fa","#99e9f2","#66d9e8","#3bc9db","#22b8cf","#15aabf","#1098ad","#0c8599","#0b7285"],$P=["#e6fcf5","#c3fae8","#96f2d7","#63e6be","#38d9a9","#20c997","#12b886","#0ca678","#099268","#087f5b"],BP=["#ebfbee","#d3f9d8","#b2f2bb","#8ce99a","#69db7c","#51cf66","#40c057","#37b24d","#2f9e44","#2b8a3e"],zP=["#f4fce3","#e9fac8","#d8f5a2","#c0eb75","#a9e34b","#94d82d","#82c91e","#74b816","#66a80f","#5c940d"],HP=["#fff9db","#fff3bf","#ffec99","#ffe066","#ffd43b","#fcc419","#fab005","#f59f00","#f08c00","#e67700"],UP=["#fff4e6","#ffe8cc","#ffd8a8","#ffc078","#ffa94d","#ff922b","#fd7e14","#f76707","#e8590c","#d9480f"],Ut={white:TP,black:MP,gray:AP,red:LP,pink:PP,grape:RP,violet:DP,indigo:OP,blue:NP,cyan:FP,teal:$P,green:BP,lime:zP,yellow:HP,orange:UP},WP=(e,t)=>t.reduce((n,r)=>(r in e&&(n[r]=e[r]),n),{}),VP=5,Qa=5,GP=4,lu=4,cu=1,Mr=[0,2,4,6,8],Ar=(e,t)=>t.map(n=>Ut[e][n]),ve={transparent:"transparent",black:"#1e1e1e",white:"#ffffff",gray:Ar("gray",Mr),red:Ar("red",Mr),pink:Ar("pink",Mr),grape:Ar("grape",Mr),violet:Ar("violet",Mr),blue:Ar("blue",Mr),cyan:Ar("cyan",Mr),teal:Ar("teal",Mr),green:Ar("green",Mr),yellow:Ar("yellow",Mr),orange:Ar("orange",Mr),bronze:["#f8f1ee","#eaddd7","#d2bab0","#a18072","#846358"]},DS=WP(ve,["cyan","blue","violet","grape","pink","green","teal","yellow","orange","red"]),OS=[ve.black,ve.red[lu],ve.green[lu],ve.blue[lu],ve.yellow[lu]],NS=[ve.transparent,ve.red[cu],ve.green[cu],ve.blue[cu],ve.yellow[cu]],FS=[ve.white,"#f8f9fa","#f5faff","#fffce8","#fdf8f6"],jP={transparent:ve.transparent,white:ve.white,gray:ve.gray,black:ve.black,bronze:ve.bronze,...DS},YP={transparent:ve.transparent,white:ve.white,gray:ve.gray,black:ve.black,bronze:ve.bronze,...DS},KP=e=>[ve.cyan[e],ve.blue[e],ve.violet[e],ve.grape[e],ve.pink[e],ve.green[e],ve.teal[e],ve.yellow[e],ve.orange[e],ve.red[e]],ZP=(e,t,n)=>`#${((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)}`,XP="invert(93%) hue-rotate(180deg)",qP="302px",$S={themeFilter:XP,rightSidebarWidth:qP},ki=/Mac|iPod|iPhone|iPad/.test(navigator.platform),BS=/^Win/.test(navigator.platform),R1="netscape"in window&&navigator.userAgent.indexOf("rv:")>1&&navigator.userAgent.indexOf("Gecko")>1,QP=navigator.userAgent.indexOf("Chrome")!==-1;!QP&&navigator.userAgent.indexOf("Safari");const JP=/iPad|iPhone/.test(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,eR=()=>{var e,t;return((t=(e=navigator.brave)==null?void 0:e.isBrave)==null?void 0:t.name)==="isBrave"},m2=typeof window<"u"&&"ResizeObserver"in window,Vi="Excalidraw",Ts=10,Sf=8,tR=5,ob=1,nR=30,ss=Math.PI/12,rR="red",Be={TEXT:"text",CROSSHAIR:"crosshair",GRABBING:"grabbing",GRAB:"grab",POINTER:"pointer",MOVE:"move",AUTO:""},xs={MAIN:0,WHEEL:1,SECONDARY:2,TOUCH:-1,ERASER:5},Ms={enabled:"all",disabled:"none",inheritFromUI:"var(--ui-pointerEvents)"};var Z=(e=>(e.COPY="copy",e.PASTE="paste",e.CUT="cut",e.KEYDOWN="keydown",e.KEYUP="keyup",e.MOUSE_MOVE="mousemove",e.RESIZE="resize",e.UNLOAD="unload",e.FOCUS="focus",e.BLUR="blur",e.DRAG_OVER="dragover",e.DROP="drop",e.GESTURE_END="gestureend",e.BEFORE_UNLOAD="beforeunload",e.GESTURE_START="gesturestart",e.GESTURE_CHANGE="gesturechange",e.POINTER_MOVE="pointermove",e.POINTER_DOWN="pointerdown",e.POINTER_UP="pointerup",e.STATE_CHANGE="statechange",e.WHEEL="wheel",e.TOUCH_START="touchstart",e.TOUCH_END="touchend",e.HASHCHANGE="hashchange",e.VISIBILITY_CHANGE="visibilitychange",e.SCROLL="scroll",e.EXCALIDRAW_LINK="excalidraw-link",e.MENU_ITEM_SELECT="menu.itemSelect",e.MESSAGE="message",e.FULLSCREENCHANGE="fullscreenchange",e))(Z||{});const Dh={UNSTARTED:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3,CUED:5},zS={SHAPE_ACTIONS_MENU:"App-menu__left"},Xt={Virgil:1,Helvetica:2,Cascadia:3,Assistant:4},Tt={LIGHT:"light",DARK:"dark"},vt={strokeColor:"#bbb",strokeWidth:2,strokeStyle:"solid",fillStyle:"solid",roughness:0,roundness:null,backgroundColor:"transparent",radius:8,nameOffsetY:3,nameColorLightTheme:"#999999",nameColorDarkTheme:"#7a7a7a",nameFontSize:14,nameLineHeight:1.25},sb="Segoe UI Emoji",Ov=1,Xr=20,oo=Xt.Virgil,D1="left",_m="top",HS="{version}",ud=2,Oh="#ffffff",iR="#1e1e1e",oR="#a2f1a6",Cl=20,Nv={svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif",jfif:"image/jfif"},sR=["text/plain","text/html"],de={json:"application/json",excalidraw:"application/vnd.excalidraw+json",excalidrawlib:"application/vnd.excalidrawlib+json","excalidraw.svg":"image/svg+xml","excalidraw.png":"image/png",binary:"application/octet-stream",...Nv},lp={png:"png",svg:"svg",clipboard:"clipboard"},yr={excalidraw:"excalidraw",excalidrawClipboard:"excalidraw/clipboard",excalidrawLibrary:"excalidrawlib",excalidrawClipboardWithAPI:"excalidraw-api/clipboard"},Fv=window.EXCALIDRAW_EXPORT_SOURCE||window.location.origin,aR=500,lR=300,cR=500,uR=1e4,dR=3e4,hR=100,dd=.1,US=.1,fR=300,ab=6e4,lb=3e3,$v=$S.themeFilter,g2={addLibrary:"addLibrary"},p2={addLibrary:"addLibrary"},cb={canvasActions:{changeViewBackgroundColor:!0,clearCanvas:!0,export:{saveFileToDisk:!0},loadScene:!0,saveToActiveFile:!0,toggleTheme:null,saveAsImage:!0},tools:{image:!0}},mR=730,gR=1e3,pR=500,yR=1229,vR=parseInt($S.rightSidebarWidth),Oc=2,Bv=[1,2,3],ac=10,ER=1440,ub=2*1024*1024,Ke="http://www.w3.org/2000/svg",WS=128,O1={excalidraw:2,excalidrawLibrary:2},Nt=5,wR=.7,bR=11,Qn={TOP:"top",MIDDLE:"middle",BOTTOM:"bottom"},hd={LEFT:"left",CENTER:"center",RIGHT:"right"},_R=20,cp=.25,xR=32,Vt={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},Do="__precedingElement__",VS={architect:0,artist:1,cartoonist:2},up={thin:1,bold:2,extraBold:4},dt={strokeColor:ve.black,backgroundColor:ve.transparent,fillStyle:"solid",strokeWidth:2,strokeStyle:"solid",roughness:VS.artist,opacity:100,locked:!1},zv="library",Tl={name:"default",defaultTab:zv},GS=new Set(["iframe","embeddable","image"]),zt={selection:"selection",rectangle:"rectangle",diamond:"diamond",ellipse:"ellipse",arrow:"arrow",line:"line",freedraw:"freedraw",text:"text",image:"image",eraser:"eraser",hand:"hand",frame:"frame",magicframe:"magicframe",embeddable:"embeddable",laser:"laser"},qo={OAI_API_KEY:"excalidraw-oai-api-key",MERMAID_TO_EXCALIDRAW:"mermaid-to-excalidraw",PUBLISH_LIBRARY:"publish-library-data"},jS="Untitled",SR=Bv.includes(devicePixelRatio)?devicePixelRatio:1,qr=()=>({showWelcomeScreen:!1,theme:Tt.LIGHT,collaborators:new Map,currentChartType:"bar",currentItemBackgroundColor:dt.backgroundColor,currentItemEndArrowhead:"arrow",currentItemFillStyle:dt.fillStyle,currentItemFontFamily:oo,currentItemFontSize:Xr,currentItemOpacity:dt.opacity,currentItemRoughness:dt.roughness,currentItemStartArrowhead:null,currentItemStrokeColor:dt.strokeColor,currentItemRoundness:"round",currentItemStrokeStyle:dt.strokeStyle,currentItemStrokeWidth:dt.strokeWidth,currentItemTextAlign:D1,cursorButton:"up",activeEmbeddable:null,draggingElement:null,editingElement:null,editingGroupId:null,editingLinearElement:null,activeTool:{type:"selection",customType:null,locked:dt.locked,lastActiveTool:null},penMode:!1,penDetected:!1,errorMessage:null,exportBackground:!0,exportScale:SR,exportEmbedScene:!1,exportWithDarkMode:!1,fileHandle:null,gridSize:null,isBindingEnabled:!0,defaultSidebarDockedPreference:!1,isLoading:!1,isResizing:!1,isRotating:!1,lastPointerDownWith:"mouse",multiElement:null,name:null,contextMenu:null,openMenu:null,openPopup:null,openSidebar:null,openDialog:null,pasteDialog:{shown:!1,data:null},previousSelectedElementIds:{},resizingElement:null,scrolledOutside:!1,scrollX:0,scrollY:0,selectedElementIds:{},selectedGroupIds:{},selectedElementsAreBeingDragged:!1,selectionElement:null,shouldCacheIgnoreZoom:!1,showStats:!1,startBoundElement:null,suggestedBindings:[],frameRendering:{enabled:!0,clip:!0,name:!0,outline:!0},frameToHighlight:null,editingFrame:null,elementsToHighlight:null,toast:null,viewBackgroundColor:ve.white,zenModeEnabled:!1,zoom:{value:1},viewModeEnabled:!1,pendingImageElementId:null,showHyperlinkPopup:!1,selectedLinearElement:null,snapLines:[],originSnapOffset:{x:0,y:0},objectsSnapModeEnabled:!1,userToFollow:null,followedBy:new Set}),kR=(e=>e)({showWelcomeScreen:{browser:!0,export:!1,server:!1},theme:{browser:!0,export:!1,server:!1},collaborators:{browser:!1,export:!1,server:!1},currentChartType:{browser:!0,export:!1,server:!1},currentItemBackgroundColor:{browser:!0,export:!1,server:!1},currentItemEndArrowhead:{browser:!0,export:!1,server:!1},currentItemFillStyle:{browser:!0,export:!1,server:!1},currentItemFontFamily:{browser:!0,export:!1,server:!1},currentItemFontSize:{browser:!0,export:!1,server:!1},currentItemRoundness:{browser:!0,export:!1,server:!1},currentItemOpacity:{browser:!0,export:!1,server:!1},currentItemRoughness:{browser:!0,export:!1,server:!1},currentItemStartArrowhead:{browser:!0,export:!1,server:!1},currentItemStrokeColor:{browser:!0,export:!1,server:!1},currentItemStrokeStyle:{browser:!0,export:!1,server:!1},currentItemStrokeWidth:{browser:!0,export:!1,server:!1},currentItemTextAlign:{browser:!0,export:!1,server:!1},cursorButton:{browser:!0,export:!1,server:!1},activeEmbeddable:{browser:!1,export:!1,server:!1},draggingElement:{browser:!1,export:!1,server:!1},editingElement:{browser:!1,export:!1,server:!1},editingGroupId:{browser:!0,export:!1,server:!1},editingLinearElement:{browser:!1,export:!1,server:!1},activeTool:{browser:!0,export:!1,server:!1},penMode:{browser:!0,export:!1,server:!1},penDetected:{browser:!0,export:!1,server:!1},errorMessage:{browser:!1,export:!1,server:!1},exportBackground:{browser:!0,export:!1,server:!1},exportEmbedScene:{browser:!0,export:!1,server:!1},exportScale:{browser:!0,export:!1,server:!1},exportWithDarkMode:{browser:!0,export:!1,server:!1},fileHandle:{browser:!1,export:!1,server:!1},gridSize:{browser:!0,export:!0,server:!0},height:{browser:!1,export:!1,server:!1},isBindingEnabled:{browser:!1,export:!1,server:!1},defaultSidebarDockedPreference:{browser:!0,export:!1,server:!1},isLoading:{browser:!1,export:!1,server:!1},isResizing:{browser:!1,export:!1,server:!1},isRotating:{browser:!1,export:!1,server:!1},lastPointerDownWith:{browser:!0,export:!1,server:!1},multiElement:{browser:!1,export:!1,server:!1},name:{browser:!0,export:!1,server:!1},offsetLeft:{browser:!1,export:!1,server:!1},offsetTop:{browser:!1,export:!1,server:!1},contextMenu:{browser:!1,export:!1,server:!1},openMenu:{browser:!0,export:!1,server:!1},openPopup:{browser:!1,export:!1,server:!1},openSidebar:{browser:!0,export:!1,server:!1},openDialog:{browser:!1,export:!1,server:!1},pasteDialog:{browser:!1,export:!1,server:!1},previousSelectedElementIds:{browser:!0,export:!1,server:!1},resizingElement:{browser:!1,export:!1,server:!1},scrolledOutside:{browser:!0,export:!1,server:!1},scrollX:{browser:!0,export:!1,server:!1},scrollY:{browser:!0,export:!1,server:!1},selectedElementIds:{browser:!0,export:!1,server:!1},selectedGroupIds:{browser:!0,export:!1,server:!1},selectedElementsAreBeingDragged:{browser:!1,export:!1,server:!1},selectionElement:{browser:!1,export:!1,server:!1},shouldCacheIgnoreZoom:{browser:!0,export:!1,server:!1},showStats:{browser:!0,export:!1,server:!1},startBoundElement:{browser:!1,export:!1,server:!1},suggestedBindings:{browser:!1,export:!1,server:!1},frameRendering:{browser:!1,export:!1,server:!1},frameToHighlight:{browser:!1,export:!1,server:!1},editingFrame:{browser:!1,export:!1,server:!1},elementsToHighlight:{browser:!1,export:!1,server:!1},toast:{browser:!1,export:!1,server:!1},viewBackgroundColor:{browser:!0,export:!0,server:!0},width:{browser:!1,export:!1,server:!1},zenModeEnabled:{browser:!0,export:!1,server:!1},zoom:{browser:!0,export:!1,server:!1},viewModeEnabled:{browser:!1,export:!1,server:!1},pendingImageElementId:{browser:!1,export:!1,server:!1},showHyperlinkPopup:{browser:!1,export:!1,server:!1},selectedLinearElement:{browser:!0,export:!1,server:!1},snapLines:{browser:!1,export:!1,server:!1},originSnapOffset:{browser:!1,export:!1,server:!1},objectsSnapModeEnabled:{browser:!0,export:!1,server:!1},userToFollow:{browser:!1,export:!1,server:!1},followedBy:{browser:!1,export:!1,server:!1}}),Hv=(e,t)=>{const n={};for(const r of Object.keys(e)){const i=kR[r];if(i!=null&&i[t]){const o=e[r];n[r]=o}}return n},YS=e=>Hv(e,"browser"),KS=e=>Hv(e,"export"),IR=e=>Hv(e,"server"),mi=({activeTool:e})=>e.type==="eraser",Vl=({activeTool:e})=>e.type==="hand",CR="modulepreload",TR=function(e){return"/"+e},db={},ie=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const o=document.getElementsByTagName("link");i=Promise.all(n.map(s=>{if(s=TR(s),s in db)return;db[s]=!0;const a=s.endsWith(".css"),l=a?'[rel="stylesheet"]':"";if(!!r)for(let d=o.length-1;d>=0;d--){const h=o[d];if(h.href===s&&(!a||h.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${l}`))return;const u=document.createElement("link");if(u.rel=a?"stylesheet":CR,a||(u.as="script",u.crossOrigin=""),u.href=s,document.head.appendChild(u),a)return new Promise((d,h)=>{u.addEventListener("load",d),u.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${s}`)))})}))}return i.then(()=>t()).catch(o=>{const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=o,window.dispatchEvent(s),!s.defaultPrevented)throw o})},MR=(e,t)=>{const n=e[t];return n?typeof n=="function"?n():Promise.resolve(n):new Promise((r,i)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(i.bind(null,new Error("Unknown variable dynamic import: "+t)))})},ZS={paste:"Paste",pasteAsPlaintext:"Paste as plaintext",pasteCharts:"Paste charts",selectAll:"Select all",multiSelect:"Add element to selection",moveCanvas:"Move canvas",cut:"Cut",copy:"Copy",copyAsPng:"Copy to clipboard as PNG",copyAsSvg:"Copy to clipboard as SVG",copyText:"Copy to clipboard as text",copySource:"Copy source to clipboard",convertToCode:"Convert to code",bringForward:"Bring forward",sendToBack:"Send to back",bringToFront:"Bring to front",sendBackward:"Send backward",delete:"Delete",copyStyles:"Copy styles",pasteStyles:"Paste styles",stroke:"Stroke",background:"Background",fill:"Fill",strokeWidth:"Stroke width",strokeStyle:"Stroke style",strokeStyle_solid:"Solid",strokeStyle_dashed:"Dashed",strokeStyle_dotted:"Dotted",sloppiness:"Sloppiness",opacity:"Opacity",textAlign:"Text align",edges:"Edges",sharp:"Sharp",round:"Round",arrowheads:"Arrowheads",arrowhead_none:"None",arrowhead_arrow:"Arrow",arrowhead_bar:"Bar",arrowhead_circle:"Circle",arrowhead_circle_outline:"Circle (outline)",arrowhead_triangle:"Triangle",arrowhead_triangle_outline:"Triangle (outline)",arrowhead_diamond:"Diamond",arrowhead_diamond_outline:"Diamond (outline)",fontSize:"Font size",fontFamily:"Font family",addWatermark:'Add "Made with Excalidraw"',handDrawn:"Hand-drawn",normal:"Normal",code:"Code",small:"Small",medium:"Medium",large:"Large",veryLarge:"Very large",solid:"Solid",hachure:"Hachure",zigzag:"Zigzag",crossHatch:"Cross-hatch",thin:"Thin",bold:"Bold",left:"Left",center:"Center",right:"Right",extraBold:"Extra bold",architect:"Architect",artist:"Artist",cartoonist:"Cartoonist",fileTitle:"File name",colorPicker:"Color picker",canvasColors:"Used on canvas",canvasBackground:"Canvas background",drawingCanvas:"Drawing canvas",layers:"Layers",actions:"Actions",language:"Language",liveCollaboration:"Live collaboration...",duplicateSelection:"Duplicate",untitled:"Untitled",name:"Name",yourName:"Your name",madeWithExcalidraw:"Made with Excalidraw",group:"Group selection",ungroup:"Ungroup selection",collaborators:"Collaborators",showGrid:"Show grid",addToLibrary:"Add to library",removeFromLibrary:"Remove from library",libraryLoadingMessage:"Loading library…",libraries:"Browse libraries",loadingScene:"Loading scene…",align:"Align",alignTop:"Align top",alignBottom:"Align bottom",alignLeft:"Align left",alignRight:"Align right",centerVertically:"Center vertically",centerHorizontally:"Center horizontally",distributeHorizontally:"Distribute horizontally",distributeVertically:"Distribute vertically",flipHorizontal:"Flip horizontal",flipVertical:"Flip vertical",viewMode:"View mode",share:"Share",showStroke:"Show stroke color picker",showBackground:"Show background color picker",toggleTheme:"Toggle theme",personalLib:"Personal Library",excalidrawLib:"Excalidraw Library",decreaseFontSize:"Decrease font size",increaseFontSize:"Increase font size",unbindText:"Unbind text",bindText:"Bind text to the container",createContainerFromText:"Wrap text in a container",link:{edit:"Edit link",editEmbed:"Edit link & embed",create:"Create link",createEmbed:"Create link & embed",label:"Link",labelEmbed:"Link & embed",empty:"No link is set"},lineEditor:{edit:"Edit line",exit:"Exit line editor"},elementLock:{lock:"Lock",unlock:"Unlock",lockAll:"Lock all",unlockAll:"Unlock all"},statusPublished:"Published",sidebarLock:"Keep sidebar open",selectAllElementsInFrame:"Select all elements in frame",removeAllElementsFromFrame:"Remove all elements from frame",eyeDropper:"Pick color from canvas",textToDiagram:"Text to diagram",prompt:"Prompt",followUs:"Follow us",discordChat:"Discord chat"},XS={noItems:"No items added yet...",hint_emptyLibrary:"Select an item on canvas to add it here, or install a library from the public repository, below.",hint_emptyPrivateLibrary:"Select an item on canvas to add it here."},qS={clearReset:"Reset the canvas",exportJSON:"Export to file",exportImage:"Export image...",export:"Save to...",copyToClipboard:"Copy to clipboard",save:"Save to current file",saveAs:"Save as",load:"Open",getShareableLink:"Get shareable link",close:"Close",selectLanguage:"Select language",scrollBackToContent:"Scroll back to content",zoomIn:"Zoom in",zoomOut:"Zoom out",resetZoom:"Reset zoom",menu:"Menu",done:"Done",edit:"Edit",undo:"Undo",redo:"Redo",resetLibrary:"Reset library",createNewRoom:"Create new room",fullScreen:"Full screen",darkMode:"Dark mode",lightMode:"Light mode",zenMode:"Zen mode",objectsSnapMode:"Snap to objects",exitZenMode:"Exit zen mode",cancel:"Cancel",clear:"Clear",remove:"Remove",embed:"Toggle embedding",publishLibrary:"Publish",submit:"Submit",confirm:"Confirm",embeddableInteractionButton:"Click to interact"},QS={clearReset:"This will clear the whole canvas. Are you sure?",couldNotCreateShareableLink:"Couldn't create shareable link.",couldNotCreateShareableLinkTooBig:"Couldn't create shareable link: the scene is too big",couldNotLoadInvalidFile:"Couldn't load invalid file",importBackendFailed:"Importing from backend failed.",cannotExportEmptyCanvas:"Cannot export empty canvas.",couldNotCopyToClipboard:"Couldn't copy to clipboard.",decryptFailed:"Couldn't decrypt data.",uploadedSecurly:"The upload has been secured with end-to-end encryption, which means that Excalidraw server and third parties can't read the content.",loadSceneOverridePrompt:"Loading external drawing will replace your existing content. Do you wish to continue?",collabStopOverridePrompt:`Stopping the session will overwrite your previous, locally stored drawing. Are you sure?
(If you want to keep your local drawing, simply close the browser tab instead.)`,errorAddingToLibrary:"Couldn't add item to the library",errorRemovingFromLibrary:"Couldn't remove item from the library",confirmAddLibrary:"This will add {{numShapes}} shape(s) to your library. Are you sure?",imageDoesNotContainScene:"This image does not seem to contain any scene data. Have you enabled scene embedding during export?",cannotRestoreFromImage:"Scene couldn't be restored from this image file",invalidSceneUrl:"Couldn't import scene from the supplied URL. It's either malformed, or doesn't contain valid Excalidraw JSON data.",resetLibrary:"This will clear your library. Are you sure?",removeItemsFromsLibrary:"Delete {{count}} item(s) from library?",invalidEncryptionKey:"Encryption key must be of 22 characters. Live collaboration is disabled.",collabOfflineWarning:`No internet connection available.
Your changes will not be saved!`},JS={unsupportedFileType:"Unsupported file type.",imageInsertError:"Couldn't insert image. Try again later...",fileTooBig:"File is too big. Maximum allowed size is {{maxSize}}.",svgImageInsertError:"Couldn't insert SVG image. The SVG markup looks invalid.",failedToFetchImage:"Failed to fetch image.",cannotResolveCollabServer:"Couldn't connect to the collab server. Please reload the page and try again.",importLibraryError:"Couldn't load library",saveLibraryError:"Couldn't save library to storage. Please save your library to a file locally to make sure you don't lose changes.",collabSaveFailed:"Couldn't save to the backend database. If problems persist, you should save your file locally to ensure you don't lose your work.",collabSaveFailed_sizeExceeded:"Couldn't save to the backend database, the canvas seems to be too big. You should save the file locally to ensure you don't lose your work.",imageToolNotSupported:"Images are disabled.",brave_measure_text_error:{line1:"Looks like you are using Brave browser with the <bold>Aggressively Block Fingerprinting</bold> setting enabled.",line2:"This could result in breaking the <bold>Text Elements</bold> in your drawings.",line3:"We strongly recommend disabling this setting. You can follow <link>these steps</link> on how to do so.",line4:"If disabling this setting doesn't fix the display of text elements, please open an <issueLink>issue</issueLink> on our GitHub, or write us on <discordLink>Discord</discordLink>"},libraryElementTypeError:{embeddable:"Embeddable elements cannot be added to the library.",iframe:"IFrame elements cannot be added to the library.",image:"Support for adding images to the library coming soon!"},asyncPasteFailedOnRead:"Couldn't paste (couldn't read from system clipboard).",asyncPasteFailedOnParse:"Couldn't paste.",copyToSystemClipboardFailed:"Couldn't copy to clipboard."},ek={selection:"Selection",image:"Insert image",rectangle:"Rectangle",diamond:"Diamond",ellipse:"Ellipse",arrow:"Arrow",line:"Line",freedraw:"Draw",text:"Text",library:"Library",lock:"Keep selected tool active after drawing",penMode:"Pen mode - prevent touch",link:"Add / Update link for a selected shape",eraser:"Eraser",frame:"Frame tool",magicframe:"Wireframe to code",embeddable:"Web Embed",laser:"Laser pointer",hand:"Hand (panning tool)",extraTools:"More tools",mermaidToExcalidraw:"Mermaid to Excalidraw",magicSettings:"AI settings"},tk={canvasActions:"Canvas actions",selectedShapeActions:"Selected shape actions",shapes:"Shapes"},nk={canvasPanning:"To move canvas, hold mouse wheel or spacebar while dragging, or use the hand tool",linearElement:"Click to start multiple points, drag for single line",freeDraw:"Click and drag, release when you're finished",text:"Tip: you can also add text by double-clicking anywhere with the selection tool",embeddable:"Click-drag to create a website embed",text_selected:"Double-click or press ENTER to edit text",text_editing:"Press Escape or CtrlOrCmd+ENTER to finish editing",linearElementMulti:"Click on last point or press Escape or Enter to finish",lockAngle:"You can constrain angle by holding SHIFT",resize:`You can constrain proportions by holding SHIFT while resizing,
hold ALT to resize from the center`,resizeImage:`You can resize freely by holding SHIFT,
hold ALT to resize from the center`,rotate:"You can constrain angles by holding SHIFT while rotating",lineEditor_info:"Hold CtrlOrCmd and Double-click or press CtrlOrCmd + Enter to edit points",lineEditor_pointSelected:`Press Delete to remove point(s),
CtrlOrCmd+D to duplicate, or drag to move`,lineEditor_nothingSelected:`Select a point to edit (hold SHIFT to select multiple),
or hold Alt and click to add new points`,placeImage:"Click to place the image, or click and drag to set its size manually",publishLibrary:"Publish your own library",bindTextToElement:"Press enter to add text",deepBoxSelect:"Hold CtrlOrCmd to deep select, and to prevent dragging",eraserRevert:"Hold Alt to revert the elements marked for deletion",firefox_clipboard_write:'This feature can likely be enabled by setting the "dom.events.asyncClipboard.clipboardItem" flag to "true". To change the browser flags in Firefox, visit the "about:config" page.',disableSnapping:"Hold CtrlOrCmd to disable snapping"},rk={cannotShowPreview:"Cannot show preview",canvasTooBig:"The canvas may be too big.",canvasTooBigTip:"Tip: try moving the farthest elements a bit closer together."},ik={headingMain:"Encountered an error. Try <button>reloading the page</button>.",clearCanvasMessage:"If reloading doesn't work, try <button>clearing the canvas</button>.",clearCanvasCaveat:" This will result in loss of work ",trackedToSentry:"The error with identifier {{eventId}} was tracked on our system.",openIssueMessage:"We were very cautious not to include your scene information on the error. If your scene is not private, please consider following up on our <button>bug tracker</button>. Please include information below by copying and pasting into the GitHub issue.",sceneContent:"Scene content:"},ok={or:"Or"},sk={desc_intro:"Invite people to collaborate on your drawing.",desc_privacy:"Don't worry, the session is end-to-end encrypted, and fully private. Not even our server can see what you draw.",button_startSession:"Start session",button_stopSession:"Stop session",desc_inProgressIntro:"Live-collaboration session is now in progress.",desc_shareLink:"Share this link with anyone you want to collaborate with:",desc_exitSession:"Stopping the session will disconnect you from the room, but you'll be able to continue working with the scene, locally. Note that this won't affect other people, and they'll still be able to collaborate on their version.",shareTitle:"Join a live collaboration session on Excalidraw"},ak={title:"Error"},lk={disk_title:"Save to disk",disk_details:"Export the scene data to a file from which you can import later.",disk_button:"Save to file",link_title:"Shareable link",link_details:"Export as a read-only link.",link_button:"Export to Link",excalidrawplus_description:"Save the scene to your Excalidraw+ workspace.",excalidrawplus_button:"Export",excalidrawplus_exportError:"Couldn't export to Excalidraw+ at this moment..."},ck={blog:"Read our blog",click:"click",deepSelect:"Deep select",deepBoxSelect:"Deep select within box, and prevent dragging",curvedArrow:"Curved arrow",curvedLine:"Curved line",documentation:"Documentation",doubleClick:"double-click",drag:"drag",editor:"Editor",editLineArrowPoints:"Edit line/arrow points",editText:"Edit text / add label",github:"Found an issue? Submit",howto:"Follow our guides",or:"or",preventBinding:"Prevent arrow binding",tools:"Tools",shortcuts:"Keyboard shortcuts",textFinish:"Finish editing (text editor)",textNewLine:"Add new line (text editor)",title:"Help",view:"View",zoomToFit:"Zoom to fit all elements",zoomToSelection:"Zoom to selection",toggleElementLock:"Lock/unlock selection",movePageUpDown:"Move page up/down",movePageLeftRight:"Move page left/right"},uk={title:"Clear canvas"},dk={title:"Publish library",itemName:"Item name",authorName:"Author name",githubUsername:"GitHub username",twitterUsername:"Twitter username",libraryName:"Library name",libraryDesc:"Library description",website:"Website",placeholder:{authorName:"Your name or username",libraryName:"Name of your library",libraryDesc:"Description of your library to help people understand its usage",githubHandle:"GitHub handle (optional), so you can edit the library once submitted for review",twitterHandle:"Twitter username (optional), so we know who to credit when promoting over Twitter",website:"Link to your personal website or elsewhere (optional)"},errors:{required:"Required",website:"Enter a valid URL"},noteDescription:"Submit your library to be included in the <link>public library repository</link> for other people to use in their drawings.",noteGuidelines:"The library needs to be manually approved first. Please read the <link>guidelines</link> before submitting. You will need a GitHub account to communicate and make changes if requested, but it is not strictly required.",noteLicense:"By submitting, you agree the library will be published under the <link>MIT License</link>, which in short means anyone can use them without restrictions.",noteItems:"Each library item must have its own name so it's filterable. The following library items will be included:",atleastOneLibItem:"Please select at least one library item to get started",republishWarning:"Note: some of the selected items are marked as already published/submitted. You should only resubmit items when updating an existing library or submission."},hk={title:"Library submitted",content:"Thank you {{authorName}}. Your library has been submitted for review. You can track the status <link>here</link>"},fk={resetLibrary:"Reset library",removeItemsFromLib:"Remove selected items from library"},mk={header:"Export image",label:{withBackground:"Background",onlySelected:"Only selected",darkMode:"Dark mode",embedScene:"Embed scene",scale:"Scale",padding:"Padding"},tooltip:{embedScene:`Scene data will be saved into the exported PNG/SVG file so that the scene can be restored from it.
Will increase exported file size.`},title:{exportToPng:"Export to PNG",exportToSvg:"Export to SVG",copyPngToClipboard:"Copy PNG to clipboard"},button:{exportToPng:"PNG",exportToSvg:"SVG",copyPngToClipboard:"Copy to clipboard"}},gk={tooltip:"Your drawings are end-to-end encrypted so Excalidraw's servers will never see them.",link:"Blog post on end-to-end encryption in Excalidraw"},pk={angle:"Angle",element:"Element",elements:"Elements",height:"Height",scene:"Scene",selected:"Selected",storage:"Storage",title:"Stats for nerds",total:"Total",version:"Version",versionCopy:"Click to copy",versionNotAvailable:"Version not available",width:"Width"},yk={addedToLibrary:"Added to library",copyStyles:"Copied styles.",copyToClipboard:"Copied to clipboard.",copyToClipboardAsPng:`Copied {{exportSelection}} to clipboard as PNG
({{exportColorScheme}})`,fileSaved:"File saved.",fileSavedToFilename:"Saved to {filename}",canvas:"canvas",selection:"selection",pasteAsSingleElement:`Use {{shortcut}} to paste as a single element,
or paste into an existing text editor`,unableToEmbed:"Embedding this url is currently not allowed. Raise an issue on GitHub to request the url whitelisted",unrecognizedLinkFormat:"The link you embedded does not match the expected format. Please try to paste the 'embed' string provided by the source site"},vk={transparent:"Transparent",black:"Black",white:"White",red:"Red",pink:"Pink",grape:"Grape",violet:"Violet",gray:"Gray",blue:"Blue",cyan:"Cyan",teal:"Teal",green:"Green",yellow:"Yellow",orange:"Orange",bronze:"Bronze"},Ek={app:{center_heading:"All your data is saved locally in your browser.",center_heading_plus:"Did you want to go to the Excalidraw+ instead?",menuHint:"Export, preferences, languages, ..."},defaults:{menuHint:"Export, preferences, and more...",center_heading:"Diagrams. Made. Simple.",toolbarHint:"Pick a tool & Start drawing!",helpHint:"Shortcuts & help"}},wk={mostUsedCustomColors:"Most used custom colors",colors:"Colors",shades:"Shades",hexCode:"Hex code",noShades:"No shades available for this color"},bk={action:{exportToImage:{title:"Export as image",button:"Export as image",description:"Export the scene data as an image from which you can import later."},saveToDisk:{title:"Save to disk",button:"Save to disk",description:"Export the scene data to a file from which you can import later."},excalidrawPlus:{title:"Excalidraw+",button:"Export to Excalidraw+",description:"Save the scene to your Excalidraw+ workspace."}},modal:{loadFromFile:{title:"Load from file",button:"Load from file",description:"Loading from a file will <bold>replace your existing content</bold>.<br></br>You can back up your drawing first using one of the options below."},shareableLink:{title:"Load from link",button:"Replace my content",description:"Loading external drawing will <bold>replace your existing content</bold>.<br></br>You can back up your drawing first by using one of the options below."}}},_k={title:"Mermaid to Excalidraw",button:"Insert",description:"Currently only <flowchartLink>Flowchart</flowchartLink>,<sequenceLink> Sequence, </sequenceLink> and <classLink>Class </classLink>Diagrams are supported. The other types will be rendered as image in Excalidraw.",syntax:"Mermaid Syntax",preview:"Preview"},xk={search:{placeholder:"Quick search",empty:"No users found"},hint:{text:"Click on user to follow",followStatus:"You're currently following this user",inCall:"User is in a voice call",micMuted:"User's microphone is muted",isSpeaking:"User is speaking"}},Uv={labels:ZS,library:XS,buttons:qS,alerts:QS,errors:JS,toolBar:ek,headings:tk,hints:nk,canvasError:rk,errorSplash:ik,shareDialog:ok,roomDialog:sk,errorDialog:ak,exportDialog:lk,helpDialog:ck,clearCanvasDialog:uk,publishDialog:dk,publishSuccessDialog:hk,confirmDialog:fk,imageExportDialog:mk,encrypted:gk,stats:pk,toast:yk,colors:vk,welcomeScreen:Ek,colorPicker:wk,overwriteConfirm:bk,mermaid:_k,userList:xk},AR=Object.freeze(Object.defineProperty({__proto__:null,alerts:QS,buttons:qS,canvasError:rk,clearCanvasDialog:uk,colorPicker:wk,colors:vk,confirmDialog:fk,default:Uv,encrypted:gk,errorDialog:ak,errorSplash:ik,errors:JS,exportDialog:lk,headings:tk,helpDialog:ck,hints:nk,imageExportDialog:mk,labels:ZS,library:XS,mermaid:_k,overwriteConfirm:bk,publishDialog:dk,publishSuccessDialog:hk,roomDialog:sk,shareDialog:ok,stats:pk,toast:yk,toolBar:ek,userList:xk,welcomeScreen:Ek},Symbol.toStringTag,{value:"Module"})),Sk=100,kk=36,Ik={"ar-SA":94,"az-AZ":17,"bg-BG":71,"bn-BD":52,"ca-ES":83,"cs-CZ":86,"da-DK":61,"de-DE":100,"el-GR":80,en:Sk,"es-ES":96,"eu-ES":97,"fa-IR":84,"fi-FI":76,"fr-FR":99,"gl-ES":86,"he-IL":77,"hi-IN":76,"hu-HU":76,"id-ID":91,"it-IT":98,"ja-JP":90,kaa:kk,"kab-KAB":76,"kk-KZ":18,"km-KH":83,"ko-KR":100,"ku-TR":87,"lt-LT":48,"lv-LV":77,"mr-IN":98,"my-MM":35,"nb-NO":93,"nl-NL":75,"nn-NO":67,"oc-FR":92,"pa-IN":78,"pl-PL":99,"pt-BR":91,"pt-PT":83,"ro-RO":99,"ru-RU":92,"si-LK":7,"sk-SK":100,"sl-SI":100,"sv-SE":100,"ta-IN":81,"th-TH":44,"tr-TR":87,"uk-UA":93,"vi-VN":49,"zh-CN":100,"zh-HK":22,"zh-TW":100},LR=Object.freeze(Object.defineProperty({__proto__:null,default:Ik,en:Sk,kaa:kk},Symbol.toStringTag,{value:"Module"}));let PR=0;function RR(e,t){const n=`atom${++PR}`,r={toString:()=>n};return typeof e=="function"?r.read=e:(r.init=e,r.read=i=>i(r),r.write=(i,o,s)=>o(r,typeof s=="function"?s(i(r)):s)),t&&(r.write=t),r}var Kn={VITE_APP_BACKEND_V2_GET_URL:"https://json.excalidraw.com/api/v2/",VITE_APP_BACKEND_V2_POST_URL:"https://json.excalidraw.com/api/v2/post/",VITE_APP_LIBRARY_URL:"https://libraries.excalidraw.com",VITE_APP_LIBRARY_BACKEND:"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries",VITE_APP_PLUS_LP:"https://plus.excalidraw.com",VITE_APP_PLUS_APP:"https://app.excalidraw.com",VITE_APP_AI_BACKEND:"https://oss-ai.excalidraw.com",VITE_APP_WS_SERVER_URL:"https://oss-collab.excalidraw.com",VITE_APP_FIREBASE_CONFIG:'{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}',VITE_APP_DISABLE_TRACKING:"",VITE_APP_GIT_SHA:"",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const as=Symbol(),y2=e=>!!e[as],Nh=e=>!e[as].c,Nc=e=>{var t;const{b:n,c:r}=e[as];r&&(r(),(t=OR.get(n))==null||t())},kf=(e,t)=>{const n=e[as].o,r=t[as].o;return n===r||e===r||y2(n)&&kf(n,t)},v2=(e,t)=>{const n={b:e,o:t,c:null},r=new Promise(i=>{n.c=()=>{n.c=null,i()},t.finally(n.c)});return r[as]=n,r},DR=e=>v2(e[as].b,e[as].o),OR=new WeakMap,Fh=e=>"init"in e,fd="r",xm="w",md="c",Sm="s",hb="h",NR="n",FR="l",$R="a",BR="m",Ck=e=>{const t=new WeakMap,n=new WeakMap,r=new Map;let i,o;if((Kn&&"production")!=="production"&&(i=new Set,o=new Set),e)for(const[R,N]of e){const B={v:N,r:0,y:!0,d:new Map};(Kn&&"production")!=="production"&&(Object.freeze(B),Fh(R)||console.warn("Found initial value for derived atom which can cause unexpected behavior",R)),t.set(R,B)}const s=new WeakMap,a=(R,N,B)=>{let z=s.get(N);z||(z=new Map,s.set(N,z)),B.then(()=>{z.get(R)===B&&(z.delete(R),z.size||s.delete(N))}),z.set(R,B)},l=R=>{const N=new Set,B=s.get(R);return B&&(s.delete(R),B.forEach((z,W)=>{Nc(z),N.add(W)})),N},c=new WeakMap,u=R=>{let N=c.get(R);return N||(N=new Map,c.set(R,N)),N},d=(R,N)=>{if(R){const B=u(R);let z=B.get(N);return z||(z=d(R.p,N),z&&"p"in z&&Nh(z.p)&&(z=void 0),z&&B.set(N,z)),z}return t.get(N)},h=(R,N,B)=>{if((Kn&&"production")!=="production"&&Object.freeze(B),R)u(R).set(N,B);else{const z=t.get(N);t.set(N,B),r.has(N)||r.set(N,z)}},m=(R,N=new Map,B)=>{if(!B)return N;const z=new Map;let W=!1;return B.forEach(j=>{var X;const ee=((X=d(R,j))==null?void 0:X.r)||0;z.set(j,ee),N.get(j)!==ee&&(W=!0)}),N.size===z.size&&!W?N:z},g=(R,N,B,z,W)=>{const j=d(R,N);if(j){if(W&&(!("p"in j)||!kf(j.p,W)))return j;"p"in j&&Nc(j.p)}const X={v:B,r:(j==null?void 0:j.r)||0,y:!0,d:m(R,j==null?void 0:j.d,z)};let ee=!(j!=null&&j.y);return!j||!("v"in j)||!Object.is(j.v,B)?(ee=!0,++X.r,X.d.has(N)&&(X.d=new Map(X.d).set(N,X.r))):X.d!==j.d&&(X.d.size!==j.d.size||!Array.from(X.d.keys()).every(xe=>j.d.has(xe)))&&(ee=!0,Promise.resolve().then(()=>{G(R)})),j&&!ee?j:(h(R,N,X),X)},p=(R,N,B,z,W)=>{const j=d(R,N);if(j){if(W&&(!("p"in j)||!kf(j.p,W)))return j;"p"in j&&Nc(j.p)}const X={e:B,r:((j==null?void 0:j.r)||0)+1,y:!0,d:m(R,j==null?void 0:j.d,z)};return h(R,N,X),X},v=(R,N,B,z)=>{const W=d(R,N);if(W&&"p"in W){if(kf(W.p,B)&&!Nh(W.p))return W.y?W:{...W,y:!0};Nc(W.p)}a(R,N,B);const j={p:B,r:((W==null?void 0:W.r)||0)+1,y:!0,d:m(R,W==null?void 0:W.d,z)};return h(R,N,j),j},y=(R,N,B,z)=>{if(B instanceof Promise){const W=v2(B,B.then(j=>{g(R,N,j,z,W)}).catch(j=>{if(j instanceof Promise)return y2(j)?j.then(()=>{w(R,N,!0)}):j;p(R,N,j,z,W)}));return v(R,N,W,z)}return g(R,N,B,z)},E=(R,N)=>{const B=d(R,N);if(B){const z={...B,y:!1};h(R,N,z)}else(Kn&&"production")!=="production"&&console.warn("[Bug] could not invalidate non existing atom",N)},w=(R,N,B)=>{if(!B){const W=d(R,N);if(W){if(W.y&&"p"in W&&!Nh(W.p))return W;if(W.d.forEach((j,X)=>{if(X!==N)if(!n.has(X))w(R,X);else{const ee=d(R,X);ee&&!ee.y&&w(R,X)}}),Array.from(W.d).every(([j,X])=>{const ee=d(R,j);return ee&&!("p"in ee)&&ee.r===X}))return W.y?W:{...W,y:!0}}}const z=new Set;try{const W=N.read(j=>{z.add(j);const X=j===N?d(R,j):w(R,j);if(X){if("e"in X)throw X.e;if("p"in X)throw X.p;return X.v}if(Fh(j))return j.init;throw new Error("no atom init")});return y(R,N,W,z)}catch(W){if(W instanceof Promise){const j=y2(W)&&Nh(W)?DR(W):v2(W,W);return v(R,N,j,z)}return p(R,N,W,z)}},x=(R,N)=>w(N,R),C=(R,N)=>{let B=n.get(N);return B||(B=P(R,N)),B},S=(R,N)=>!N.l.size&&(!N.t.size||N.t.size===1&&N.t.has(R)),I=(R,N)=>{const B=n.get(N);B&&S(N,B)&&O(R,N)},T=(R,N)=>{const B=n.get(N);B==null||B.t.forEach(z=>{z!==N&&(E(R,z),T(R,z))})},L=(R,N,B)=>{let z=!0;const W=(ee,xe)=>{const Fe=w(R,ee);if("e"in Fe)throw Fe.e;if("p"in Fe){if(xe!=null&&xe.unstable_promise)return Fe.p.then(()=>{const Se=d(R,ee);return Se&&"p"in Se&&Se.p===Fe.p?new Promise(Me=>setTimeout(Me)).then(()=>W(ee,xe)):W(ee,xe)});throw(Kn&&"production")!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",ee),Fe.p}if("v"in Fe)return Fe.v;throw(Kn&&"production")!=="production"&&console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.",ee),new Error("no value found")},j=(ee,xe)=>{let Fe;if(ee===N){if(!Fh(ee))throw new Error("atom not writable");l(ee).forEach(it=>{it!==R&&y(it,ee,xe)});const Me=d(R,ee),Et=y(R,ee,xe);Me!==Et&&T(R,ee)}else Fe=L(R,ee,xe);return z||G(R),Fe},X=N.write(W,j,B);return z=!1,X},A=(R,N,B)=>{const z=L(B,R,N);return G(B),z},F=R=>!!R.write,P=(R,N,B)=>{const z={t:new Set(B&&[B]),l:new Set};if(n.set(N,z),(Kn&&"production")!=="production"&&o.add(N),w(void 0,N).d.forEach((j,X)=>{const ee=n.get(X);ee?ee.t.add(N):X!==N&&P(R,X,N)}),F(N)&&N.onMount){const j=ee=>A(N,ee,R),X=N.onMount(j);R=void 0,X&&(z.u=X)}return z},O=(R,N)=>{var B;const z=(B=n.get(N))==null?void 0:B.u;z&&z(),n.delete(N),(Kn&&"production")!=="production"&&o.delete(N);const W=d(R,N);W?("p"in W&&Nc(W.p),W.d.forEach((j,X)=>{if(X!==N){const ee=n.get(X);ee&&(ee.t.delete(N),S(X,ee)&&O(R,X))}})):(Kn&&"production")!=="production"&&console.warn("[Bug] could not find atom state to unmount",N)},V=(R,N,B,z)=>{const W=new Set(B.d.keys());z==null||z.forEach((j,X)=>{if(W.has(X)){W.delete(X);return}const ee=n.get(X);ee&&(ee.t.delete(N),S(X,ee)&&O(R,X))}),W.forEach(j=>{const X=n.get(j);X?X.t.add(N):n.has(N)&&P(R,j,N)})},G=R=>{if(R){u(R).forEach((B,z)=>{const W=t.get(z);if(B!==W){const j=n.get(z);j==null||j.l.forEach(X=>X(R))}});return}for(;r.size;){const N=Array.from(r);r.clear(),N.forEach(([B,z])=>{const W=d(void 0,B);if(W&&W.d!==(z==null?void 0:z.d)&&V(void 0,B,W,z==null?void 0:z.d),z&&!z.y&&(W!=null&&W.y))return;const j=n.get(B);j==null||j.l.forEach(X=>X())})}(Kn&&"production")!=="production"&&i.forEach(N=>N())},q=R=>{u(R).forEach((B,z)=>{const W=t.get(z);(!W||B.r>W.r||B.y!==W.y||B.r===W.r&&B.d!==W.d)&&(t.set(z,B),B.d!==(W==null?void 0:W.d)&&V(R,z,B,W==null?void 0:W.d))})},U=(R,N)=>{N&&q(N),G(void 0)},$=(R,N,B)=>{const W=C(B,R).l;return W.add(N),()=>{W.delete(N),I(B,R)}},Y=(R,N)=>{for(const[B,z]of R)Fh(B)&&(y(N,B,z),T(N,B));G(N)};return(Kn&&"production")!=="production"?{[fd]:x,[xm]:A,[md]:U,[Sm]:$,[hb]:Y,[NR]:R=>(i.add(R),()=>{i.delete(R)}),[FR]:()=>o.values(),[$R]:R=>t.get(R),[BR]:R=>n.get(R)}:{[fd]:x,[xm]:A,[md]:U,[Sm]:$,[hb]:Y}},zR=e=>{const t=Ck(e),n=s=>{const a=t[fd](s);if("e"in a)throw a.e;if(!("p"in a))return a.v},r=s=>new Promise((a,l)=>{const c=t[fd](s);"e"in c?l(c.e):"p"in c?a(c.p.then(()=>r(s))):a(c.v)});return{get:n,asyncGet:r,set:(s,a)=>t[xm](s,a),sub:(s,a)=>t[Sm](s,a),SECRET_INTERNAL_store:t}},Tk=(e,t)=>({s:t?t(e).SECRET_INTERNAL_store:Ck(e)}),dp=new Map,Wv=e=>(dp.has(e)||dp.set(e,_.createContext(Tk())),dp.get(e)),Vv=({children:e,initialValues:t,scope:n,unstable_createStore:r,unstable_enableVersionedWrite:i})=>{const[o,s]=_.useState({});_.useEffect(()=>{const c=a.current;c.w&&(c.s[md](null,o),delete o.p,c.v=o)},[o]);const a=_.useRef();if(!a.current){const c=Tk(t,r);if(i){let u=0;c.w=d=>{s(h=>{const m=u?h:{p:h};return d(m),m})},c.v=o,c.r=d=>{++u,d(),--u}}a.current=c}const l=Wv(n);return _.createElement(l.Provider,{value:a.current},e)};function mt(e,t){return RR(e,t)}function Gl(e,t){const n=Wv(t),r=_.useContext(n),{s:i,v:o}=r,s=h=>{const m=i[fd](e,h);if((Kn&&"production")!=="production"&&!m.y)throw new Error("should not be invalidated");if("e"in m)throw m.e;if("p"in m)throw m.p;if("v"in m)return m.v;throw new Error("no atom value")},[[a,l,c],u]=_.useReducer((h,m)=>{const g=s(m);return Object.is(h[1],g)&&h[2]===e?h:[m,g,e]},o,h=>{const m=s(h);return[h,m,e]});let d=l;return c!==e&&(u(a),d=s(a)),_.useEffect(()=>{const{v:h}=r;h&&i[md](e,h);const m=i[Sm](e,u,h);return u(h),m},[i,e,r]),_.useEffect(()=>{i[md](e,a)}),_.useDebugValue(d),d}function lc(e,t){const n=Wv(t),{s:r,w:i}=_.useContext(n);return _.useCallback(s=>{if((Kn&&"production")!=="production"&&!("write"in e))throw new Error("not writable atom");const a=l=>r[xm](e,s,l);return i?i(a):a()},[r,i,e])}function ze(e,t){return"scope"in e&&(console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead."),t=e.scope),[Gl(e,t),lc(e,t)]}const en=Symbol(),_i=zR(),HR=(e,t)=>{const[n,r]=ze(e);return _.useLayoutEffect(()=>{r(typeof t=="function"?t():t)},[]),[n,r]},UR=85,Es={code:"en",label:"English"},Gv=[Es,...[{code:"ar-SA",label:"العربية",rtl:!0},{code:"bg-BG",label:"Български"},{code:"ca-ES",label:"Català"},{code:"cs-CZ",label:"Česky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"Ελληνικά"},{code:"es-ES",label:"Español"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"فارسی",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Français"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"עברית",rtl:!0},{code:"hi-IN",label:"हिन्दी"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"日本語"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"Қазақ тілі"},{code:"ko-KR",label:"한국어"},{code:"ku-TR",label:"Kurdî"},{code:"lt-LT",label:"Lietuvių"},{code:"lv-LV",label:"Latviešu"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokmål"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"ਪੰਜਾਬੀ"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Português Brasileiro"},{code:"pt-PT",label:"Português"},{code:"ro-RO",label:"Română"},{code:"ru-RU",label:"Русский"},{code:"sk-SK",label:"Slovenčina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Slovenščina"},{code:"tr-TR",label:"Türkçe"},{code:"uk-UA",label:"Українська"},{code:"zh-CN",label:"简体中文"},{code:"zh-TW",label:"繁體中文"},{code:"vi-VN",label:"Tiếng Việt"},{code:"mr-IN",label:"मराठी"}].filter(e=>Ik[e.code]>=UR).sort((e,t)=>e.label>t.label?1:-1)],Mk="__test__";let fl=Es,If={};const Ak=async e=>{if(fl=e,document.documentElement.dir=fl.rtl?"rtl":"ltr",document.documentElement.lang=fl.code,e.code.startsWith(Mk))If={};else try{If=await MR(Object.assign({"./locales/ar-SA.json":()=>ie(()=>import("./locales/ar-SA.json-SV43LhYq.js"),__vite__mapDeps([])),"./locales/az-AZ.json":()=>ie(()=>import("./locales/az-AZ.json-oLcB2OJI.js"),__vite__mapDeps([])),"./locales/bg-BG.json":()=>ie(()=>import("./locales/bg-BG.json-pnAjs09s.js"),__vite__mapDeps([])),"./locales/bn-BD.json":()=>ie(()=>import("./locales/bn-BD.json-xZvqmnH0.js"),__vite__mapDeps([])),"./locales/ca-ES.json":()=>ie(()=>import("./locales/ca-ES.json-YA_IC9xZ.js"),__vite__mapDeps([])),"./locales/cs-CZ.json":()=>ie(()=>import("./locales/cs-CZ.json-xA16rUn9.js"),__vite__mapDeps([])),"./locales/da-DK.json":()=>ie(()=>import("./locales/da-DK.json-IEeMktGi.js"),__vite__mapDeps([])),"./locales/de-DE.json":()=>ie(()=>import("./locales/de-DE.json-i3JZdkyf.js"),__vite__mapDeps([])),"./locales/el-GR.json":()=>ie(()=>import("./locales/el-GR.json-HpHJuTAr.js"),__vite__mapDeps([])),"./locales/en.json":()=>ie(()=>Promise.resolve().then(()=>AR),void 0),"./locales/es-ES.json":()=>ie(()=>import("./locales/es-ES.json-B52Lj-PT.js"),__vite__mapDeps([])),"./locales/eu-ES.json":()=>ie(()=>import("./locales/eu-ES.json-n0P55DpS.js"),__vite__mapDeps([])),"./locales/fa-IR.json":()=>ie(()=>import("./locales/fa-IR.json-Gtl9UWDE.js"),__vite__mapDeps([])),"./locales/fi-FI.json":()=>ie(()=>import("./locales/fi-FI.json-J5M8FnGK.js"),__vite__mapDeps([])),"./locales/fr-FR.json":()=>ie(()=>import("./locales/fr-FR.json-lfZo79tg.js"),__vite__mapDeps([])),"./locales/gl-ES.json":()=>ie(()=>import("./locales/gl-ES.json--WW2Ul2N.js"),__vite__mapDeps([])),"./locales/he-IL.json":()=>ie(()=>import("./locales/he-IL.json-4DiMSwaz.js"),__vite__mapDeps([])),"./locales/hi-IN.json":()=>ie(()=>import("./locales/hi-IN.json-nhvtlCpV.js"),__vite__mapDeps([])),"./locales/hu-HU.json":()=>ie(()=>import("./locales/hu-HU.json-bmZtU8U3.js"),__vite__mapDeps([])),"./locales/id-ID.json":()=>ie(()=>import("./locales/id-ID.json-XxPjS0Nx.js"),__vite__mapDeps([])),"./locales/it-IT.json":()=>ie(()=>import("./locales/it-IT.json-rBd68gJl.js"),__vite__mapDeps([])),"./locales/ja-JP.json":()=>ie(()=>import("./locales/ja-JP.json-2da-VeKb.js"),__vite__mapDeps([])),"./locales/kaa.json":()=>ie(()=>import("./locales/kaa.json-SGqCLwRa.js"),__vite__mapDeps([])),"./locales/kab-KAB.json":()=>ie(()=>import("./locales/kab-KAB.json-S8YedR0v.js"),__vite__mapDeps([])),"./locales/kk-KZ.json":()=>ie(()=>import("./locales/kk-KZ.json-3Sz1_kBi.js"),__vite__mapDeps([])),"./locales/km-KH.json":()=>ie(()=>import("./locales/km-KH.json-KP5HxHUN.js"),__vite__mapDeps([])),"./locales/ko-KR.json":()=>ie(()=>import("./locales/ko-KR.json-brzJvi-h.js"),__vite__mapDeps([])),"./locales/ku-TR.json":()=>ie(()=>import("./locales/ku-TR.json-3BiS76lb.js"),__vite__mapDeps([])),"./locales/lt-LT.json":()=>ie(()=>import("./locales/lt-LT.json-VZNCnPUp.js"),__vite__mapDeps([])),"./locales/lv-LV.json":()=>ie(()=>import("./locales/lv-LV.json-5aVXkl-5.js"),__vite__mapDeps([])),"./locales/mr-IN.json":()=>ie(()=>import("./locales/mr-IN.json-uScRhQ9i.js"),__vite__mapDeps([])),"./locales/my-MM.json":()=>ie(()=>import("./locales/my-MM.json-Rvx7mHUJ.js"),__vite__mapDeps([])),"./locales/nb-NO.json":()=>ie(()=>import("./locales/nb-NO.json-Jc97XkYt.js"),__vite__mapDeps([])),"./locales/nl-NL.json":()=>ie(()=>import("./locales/nl-NL.json-lulb62bF.js"),__vite__mapDeps([])),"./locales/nn-NO.json":()=>ie(()=>import("./locales/nn-NO.json-19EVdr9m.js"),__vite__mapDeps([])),"./locales/oc-FR.json":()=>ie(()=>import("./locales/oc-FR.json-mgdR7xZo.js"),__vite__mapDeps([])),"./locales/pa-IN.json":()=>ie(()=>import("./locales/pa-IN.json-6nU3HEBq.js"),__vite__mapDeps([])),"./locales/percentages.json":()=>ie(()=>Promise.resolve().then(()=>LR),void 0),"./locales/pl-PL.json":()=>ie(()=>import("./locales/pl-PL.json-e9P_Yfh8.js"),__vite__mapDeps([])),"./locales/pt-BR.json":()=>ie(()=>import("./locales/pt-BR.json-SvBckatZ.js"),__vite__mapDeps([])),"./locales/pt-PT.json":()=>ie(()=>import("./locales/pt-PT.json-kkhuggAD.js"),__vite__mapDeps([])),"./locales/ro-RO.json":()=>ie(()=>import("./locales/ro-RO.json-IuXq2Sgz.js"),__vite__mapDeps([])),"./locales/ru-RU.json":()=>ie(()=>import("./locales/ru-RU.json-AKny6SqI.js"),__vite__mapDeps([])),"./locales/si-LK.json":()=>ie(()=>import("./locales/si-LK.json-htW_YYt1.js"),__vite__mapDeps([])),"./locales/sk-SK.json":()=>ie(()=>import("./locales/sk-SK.json-9kwfDB_I.js"),__vite__mapDeps([])),"./locales/sl-SI.json":()=>ie(()=>import("./locales/sl-SI.json-ASsZh3wt.js"),__vite__mapDeps([])),"./locales/sv-SE.json":()=>ie(()=>import("./locales/sv-SE.json-lo_GRO0H.js"),__vite__mapDeps([])),"./locales/ta-IN.json":()=>ie(()=>import("./locales/ta-IN.json-heb0CKI9.js"),__vite__mapDeps([])),"./locales/th-TH.json":()=>ie(()=>import("./locales/th-TH.json-28RYlLeB.js"),__vite__mapDeps([])),"./locales/tr-TR.json":()=>ie(()=>import("./locales/tr-TR.json-EHF5lOjE.js"),__vite__mapDeps([])),"./locales/uk-UA.json":()=>ie(()=>import("./locales/uk-UA.json-opPb2znK.js"),__vite__mapDeps([])),"./locales/vi-VN.json":()=>ie(()=>import("./locales/vi-VN.json-lNqxPgt2.js"),__vite__mapDeps([])),"./locales/zh-CN.json":()=>ie(()=>import("./locales/zh-CN.json-I6DzD4ui.js"),__vite__mapDeps([])),"./locales/zh-HK.json":()=>ie(()=>import("./locales/zh-HK.json-0R3Wdr1t.js"),__vite__mapDeps([])),"./locales/zh-TW.json":()=>ie(()=>import("./locales/zh-TW.json-b9fBzTxw.js"),__vite__mapDeps([]))}),`./locales/${fl.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),If=Uv}_i.set(Lk,e.code)},Yd=()=>fl,fb=(e,t)=>{for(let n=0;n<t.length;++n){const r=t[n];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},b=(e,t,n)=>{if(fl.code.startsWith(Mk))return`[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]`;const r=e.split(".");let i=fb(If,r)||fb(Uv,r)||n;if(i===void 0){const o=`Can't find translation for ${e}`;return console.warn(o),""}if(t)for(const o in t)i=i.replace(`{{${o}}}`,String(t[o]));return i},Lk=mt(Es.code),xt=()=>{const e=Gl(Lk,en);return{t:b,langCode:e}};function Pk(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=Pk(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function se(){for(var e=0,t,n,r="";e<arguments.length;)(t=arguments[e++])&&(n=Pk(t))&&(r&&(r+=" "),r+=n);return r}const Rk=()=>{const[e,t]=_.useState(null),n=_.useCallback(r=>t(r),[]);return[e,n]};function E2(e,t,n){if(e&&e.length){const[r,i]=t,o=Math.PI/180*n,s=Math.cos(o),a=Math.sin(o);for(const l of e){const[c,u]=l;l[0]=(c-r)*s-(u-i)*a+r,l[1]=(c-r)*a+(u-i)*s+i}}}function WR(e,t,n){const r=[];e.forEach(i=>r.push(...i)),E2(r,t,n)}function VR(e,t){return e[0]===t[0]&&e[1]===t[1]}function GR(e,t,n,r=1){const i=n,o=Math.max(t,.1),s=e[0]&&e[0][0]&&typeof e[0][0]=="number"?[e]:e,a=[0,0];if(i)for(const c of s)E2(c,a,i);const l=jR(s,o,r);if(i){for(const c of s)E2(c,a,-i);WR(l,a,-i)}return l}function jR(e,t,n){const r=[];for(const c of e){const u=[...c];VR(u[0],u[u.length-1])||u.push([u[0][0],u[0][1]]),u.length>2&&r.push(u)}const i=[];t=Math.max(t,.1);const o=[];for(const c of r)for(let u=0;u<c.length-1;u++){const d=c[u],h=c[u+1];if(d[1]!==h[1]){const m=Math.min(d[1],h[1]);o.push({ymin:m,ymax:Math.max(d[1],h[1]),x:m===d[1]?d[0]:h[0],islope:(h[0]-d[0])/(h[1]-d[1])})}}if(o.sort((c,u)=>c.ymin<u.ymin?-1:c.ymin>u.ymin?1:c.x<u.x?-1:c.x>u.x?1:c.ymax===u.ymax?0:(c.ymax-u.ymax)/Math.abs(c.ymax-u.ymax)),!o.length)return i;let s=[],a=o[0].ymin,l=0;for(;s.length||o.length;){if(o.length){let c=-1;for(let d=0;d<o.length&&!(o[d].ymin>a);d++)c=d;o.splice(0,c+1).forEach(d=>{s.push({s:a,edge:d})})}if(s=s.filter(c=>!(c.edge.ymax<=a)),s.sort((c,u)=>c.edge.x===u.edge.x?0:(c.edge.x-u.edge.x)/Math.abs(c.edge.x-u.edge.x)),(n!==1||l%t===0)&&s.length>1)for(let c=0;c<s.length;c=c+2){const u=c+1;if(u>=s.length)break;const d=s[c].edge,h=s[u].edge;i.push([[Math.round(d.x),a],[Math.round(h.x),a]])}a+=n,s.forEach(c=>{c.edge.x=c.edge.x+n*c.edge.islope}),l++}return i}function Kd(e,t){var n;const r=t.hachureAngle+90;let i=t.hachureGap;i<0&&(i=t.strokeWidth*4),i=Math.max(i,.1);let o=1;return t.roughness>=1&&(((n=t.randomizer)===null||n===void 0?void 0:n.next())||Math.random())>.7&&(o=i),GR(e,i,r,o||1)}class jv{constructor(t){this.helper=t}fillPolygons(t,n){return this._fillPolygons(t,n)}_fillPolygons(t,n){const r=Kd(t,n);return{type:"fillSketch",ops:this.renderLines(r,n)}}renderLines(t,n){const r=[];for(const i of t)r.push(...this.helper.doubleLineOps(i[0][0],i[0][1],i[1][0],i[1][1],n));return r}}function N1(e){const t=e[0],n=e[1];return Math.sqrt(Math.pow(t[0]-n[0],2)+Math.pow(t[1]-n[1],2))}class YR extends jv{fillPolygons(t,n){let r=n.hachureGap;r<0&&(r=n.strokeWidth*4),r=Math.max(r,.1);const i=Object.assign({},n,{hachureGap:r}),o=Kd(t,i),s=Math.PI/180*n.hachureAngle,a=[],l=r*.5*Math.cos(s),c=r*.5*Math.sin(s);for(const[d,h]of o)N1([d,h])&&a.push([[d[0]-l,d[1]+c],[...h]],[[d[0]+l,d[1]-c],[...h]]);return{type:"fillSketch",ops:this.renderLines(a,n)}}}class KR extends jv{fillPolygons(t,n){const r=this._fillPolygons(t,n),i=Object.assign({},n,{hachureAngle:n.hachureAngle+90}),o=this._fillPolygons(t,i);return r.ops=r.ops.concat(o.ops),r}}class ZR{constructor(t){this.helper=t}fillPolygons(t,n){n=Object.assign({},n,{hachureAngle:0});const r=Kd(t,n);return this.dotsOnLines(r,n)}dotsOnLines(t,n){const r=[];let i=n.hachureGap;i<0&&(i=n.strokeWidth*4),i=Math.max(i,.1);let o=n.fillWeight;o<0&&(o=n.strokeWidth/2);const s=i/4;for(const a of t){const l=N1(a),c=l/i,u=Math.ceil(c)-1,d=l-u*i,h=(a[0][0]+a[1][0])/2-i/4,m=Math.min(a[0][1],a[1][1]);for(let g=0;g<u;g++){const p=m+d+g*i,v=h-s+Math.random()*2*s,y=p-s+Math.random()*2*s,E=this.helper.ellipse(v,y,o,o,n);r.push(...E.ops)}}return{type:"fillSketch",ops:r}}}class XR{constructor(t){this.helper=t}fillPolygons(t,n){const r=Kd(t,n);return{type:"fillSketch",ops:this.dashedLine(r,n)}}dashedLine(t,n){const r=n.dashOffset<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashOffset,i=n.dashGap<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashGap,o=[];return t.forEach(s=>{const a=N1(s),l=Math.floor(a/(r+i)),c=(a+i-l*(r+i))/2;let u=s[0],d=s[1];u[0]>d[0]&&(u=s[1],d=s[0]);const h=Math.atan((d[1]-u[1])/(d[0]-u[0]));for(let m=0;m<l;m++){const g=m*(r+i),p=g+r,v=[u[0]+g*Math.cos(h)+c*Math.cos(h),u[1]+g*Math.sin(h)+c*Math.sin(h)],y=[u[0]+p*Math.cos(h)+c*Math.cos(h),u[1]+p*Math.sin(h)+c*Math.sin(h)];o.push(...this.helper.doubleLineOps(v[0],v[1],y[0],y[1],n))}}),o}}class qR{constructor(t){this.helper=t}fillPolygons(t,n){const r=n.hachureGap<0?n.strokeWidth*4:n.hachureGap,i=n.zigzagOffset<0?r:n.zigzagOffset;n=Object.assign({},n,{hachureGap:r+i});const o=Kd(t,n);return{type:"fillSketch",ops:this.zigzagLines(o,i,n)}}zigzagLines(t,n,r){const i=[];return t.forEach(o=>{const s=N1(o),a=Math.round(s/(2*n));let l=o[0],c=o[1];l[0]>c[0]&&(l=o[1],c=o[0]);const u=Math.atan((c[1]-l[1])/(c[0]-l[0]));for(let d=0;d<a;d++){const h=d*2*n,m=(d+1)*2*n,g=Math.sqrt(2*Math.pow(n,2)),p=[l[0]+h*Math.cos(u),l[1]+h*Math.sin(u)],v=[l[0]+m*Math.cos(u),l[1]+m*Math.sin(u)],y=[p[0]+g*Math.cos(u+Math.PI/4),p[1]+g*Math.sin(u+Math.PI/4)];i.push(...this.helper.doubleLineOps(p[0],p[1],y[0],y[1],r),...this.helper.doubleLineOps(y[0],y[1],v[0],v[1],r))}}),i}}const An={};function QR(e,t){let n=e.fillStyle||"hachure";if(!An[n])switch(n){case"zigzag":An[n]||(An[n]=new YR(t));break;case"cross-hatch":An[n]||(An[n]=new KR(t));break;case"dots":An[n]||(An[n]=new ZR(t));break;case"dashed":An[n]||(An[n]=new XR(t));break;case"zigzag-line":An[n]||(An[n]=new qR(t));break;case"hachure":default:n="hachure",An[n]||(An[n]=new jv(t));break}return An[n]}function JR(){return Math.floor(Math.random()*2**31)}class Dk{constructor(t){this.seed=t}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}}const eD=0,w2=1,Ok=2,$h={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function tD(e){const t=new Array;for(;e!=="";)if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([aAcChHlLmMqQsStTvVzZ])/))t[t.length]={type:eD,text:RegExp.$1},e=e.substr(RegExp.$1.length);else if(e.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))t[t.length]={type:w2,text:`${parseFloat(RegExp.$1)}`},e=e.substr(RegExp.$1.length);else return[];return t[t.length]={type:Ok,text:""},t}function hp(e,t){return e.type===t}function Yv(e){const t=[],n=tD(e);let r="BOD",i=0,o=n[i];for(;!hp(o,Ok);){let s=0;const a=[];if(r==="BOD")if(o.text==="M"||o.text==="m")i++,s=$h[o.text],r=o.text;else return Yv("M0,0"+e);else hp(o,w2)?s=$h[r]:(i++,s=$h[o.text],r=o.text);if(i+s<n.length){for(let l=i;l<i+s;l++){const c=n[l];if(hp(c,w2))a[a.length]=+c.text;else throw new Error("Param not a number: "+r+","+c.text)}if(typeof $h[r]=="number"){const l={key:r,data:a};t.push(l),i+=s,o=n[i],r==="M"&&(r="L"),r==="m"&&(r="l")}else throw new Error("Bad segment: "+r)}else throw new Error("Path data ended short")}return t}function Nk(e){let t=0,n=0,r=0,i=0;const o=[];for(const{key:s,data:a}of e)switch(s){case"M":o.push({key:"M",data:[...a]}),[t,n]=a,[r,i]=a;break;case"m":t+=a[0],n+=a[1],o.push({key:"M",data:[t,n]}),r=t,i=n;break;case"L":o.push({key:"L",data:[...a]}),[t,n]=a;break;case"l":t+=a[0],n+=a[1],o.push({key:"L",data:[t,n]});break;case"C":o.push({key:"C",data:[...a]}),t=a[4],n=a[5];break;case"c":{const l=a.map((c,u)=>u%2?c+n:c+t);o.push({key:"C",data:l}),t=l[4],n=l[5];break}case"Q":o.push({key:"Q",data:[...a]}),t=a[2],n=a[3];break;case"q":{const l=a.map((c,u)=>u%2?c+n:c+t);o.push({key:"Q",data:l}),t=l[2],n=l[3];break}case"A":o.push({key:"A",data:[...a]}),t=a[5],n=a[6];break;case"a":t+=a[5],n+=a[6],o.push({key:"A",data:[a[0],a[1],a[2],a[3],a[4],t,n]});break;case"H":o.push({key:"H",data:[...a]}),t=a[0];break;case"h":t+=a[0],o.push({key:"H",data:[t]});break;case"V":o.push({key:"V",data:[...a]}),n=a[0];break;case"v":n+=a[0],o.push({key:"V",data:[n]});break;case"S":o.push({key:"S",data:[...a]}),t=a[2],n=a[3];break;case"s":{const l=a.map((c,u)=>u%2?c+n:c+t);o.push({key:"S",data:l}),t=l[2],n=l[3];break}case"T":o.push({key:"T",data:[...a]}),t=a[0],n=a[1];break;case"t":t+=a[0],n+=a[1],o.push({key:"T",data:[t,n]});break;case"Z":case"z":o.push({key:"Z",data:[]}),t=r,n=i;break}return o}function Fk(e){const t=[];let n="",r=0,i=0,o=0,s=0,a=0,l=0;for(const{key:c,data:u}of e){switch(c){case"M":t.push({key:"M",data:[...u]}),[r,i]=u,[o,s]=u;break;case"C":t.push({key:"C",data:[...u]}),r=u[4],i=u[5],a=u[2],l=u[3];break;case"L":t.push({key:"L",data:[...u]}),[r,i]=u;break;case"H":r=u[0],t.push({key:"L",data:[r,i]});break;case"V":i=u[0],t.push({key:"L",data:[r,i]});break;case"S":{let d=0,h=0;n==="C"||n==="S"?(d=r+(r-a),h=i+(i-l)):(d=r,h=i),t.push({key:"C",data:[d,h,...u]}),a=u[0],l=u[1],r=u[2],i=u[3];break}case"T":{const[d,h]=u;let m=0,g=0;n==="Q"||n==="T"?(m=r+(r-a),g=i+(i-l)):(m=r,g=i);const p=r+2*(m-r)/3,v=i+2*(g-i)/3,y=d+2*(m-d)/3,E=h+2*(g-h)/3;t.push({key:"C",data:[p,v,y,E,d,h]}),a=m,l=g,r=d,i=h;break}case"Q":{const[d,h,m,g]=u,p=r+2*(d-r)/3,v=i+2*(h-i)/3,y=m+2*(d-m)/3,E=g+2*(h-g)/3;t.push({key:"C",data:[p,v,y,E,m,g]}),a=d,l=h,r=m,i=g;break}case"A":{const d=Math.abs(u[0]),h=Math.abs(u[1]),m=u[2],g=u[3],p=u[4],v=u[5],y=u[6];d===0||h===0?(t.push({key:"C",data:[r,i,v,y,v,y]}),r=v,i=y):(r!==v||i!==y)&&($k(r,i,v,y,d,h,m,g,p).forEach(function(w){t.push({key:"C",data:w})}),r=v,i=y);break}case"Z":t.push({key:"Z",data:[]}),r=o,i=s;break}n=c}return t}function nD(e){return Math.PI*e/180}function Fc(e,t,n){const r=e*Math.cos(n)-t*Math.sin(n),i=e*Math.sin(n)+t*Math.cos(n);return[r,i]}function $k(e,t,n,r,i,o,s,a,l,c){const u=nD(s);let d=[],h=0,m=0,g=0,p=0;if(c)[h,m,g,p]=c;else{[e,t]=Fc(e,t,-u),[n,r]=Fc(n,r,-u);const P=(e-n)/2,O=(t-r)/2;let V=P*P/(i*i)+O*O/(o*o);V>1&&(V=Math.sqrt(V),i=V*i,o=V*o);const G=a===l?-1:1,q=i*i,U=o*o,$=q*U-q*O*O-U*P*P,Y=q*O*O+U*P*P,R=G*Math.sqrt(Math.abs($/Y));g=R*i*O/o+(e+n)/2,p=R*-o*P/i+(t+r)/2,h=Math.asin(parseFloat(((t-p)/o).toFixed(9))),m=Math.asin(parseFloat(((r-p)/o).toFixed(9))),e<g&&(h=Math.PI-h),n<g&&(m=Math.PI-m),h<0&&(h=Math.PI*2+h),m<0&&(m=Math.PI*2+m),l&&h>m&&(h=h-Math.PI*2),!l&&m>h&&(m=m-Math.PI*2)}let v=m-h;if(Math.abs(v)>Math.PI*120/180){const P=m,O=n,V=r;l&&m>h?m=h+Math.PI*120/180*1:m=h+Math.PI*120/180*-1,n=g+i*Math.cos(m),r=p+o*Math.sin(m),d=$k(n,r,O,V,i,o,s,0,l,[m,P,g,p])}v=m-h;const y=Math.cos(h),E=Math.sin(h),w=Math.cos(m),x=Math.sin(m),C=Math.tan(v/4),S=4/3*i*C,I=4/3*o*C,T=[e,t],L=[e+S*E,t-I*y],A=[n+S*x,r-I*w],F=[n,r];if(L[0]=2*T[0]-L[0],L[1]=2*T[1]-L[1],c)return[L,A,F].concat(d);{d=[L,A,F].concat(d);const P=[];for(let O=0;O<d.length;O+=3){const V=Fc(d[O][0],d[O][1],u),G=Fc(d[O+1][0],d[O+1][1],u),q=Fc(d[O+2][0],d[O+2][1],u);P.push([V[0],V[1],G[0],G[1],q[0],q[1]])}return P}}const rD={randOffset:lD,randOffsetWithRange:cD,ellipse:sD,doubleLineOps:uD};function Bk(e,t,n,r,i){return{type:"path",ops:Ji(e,t,n,r,i)}}function Cf(e,t,n){const r=(e||[]).length;if(r>2){const i=[];for(let o=0;o<r-1;o++)i.push(...Ji(e[o][0],e[o][1],e[o+1][0],e[o+1][1],n));return t&&i.push(...Ji(e[r-1][0],e[r-1][1],e[0][0],e[0][1],n)),{type:"path",ops:i}}else if(r===2)return Bk(e[0][0],e[0][1],e[1][0],e[1][1],n);return{type:"path",ops:[]}}function iD(e,t){return Cf(e,!0,t)}function oD(e,t,n,r,i){const o=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]];return iD(o,i)}function mb(e,t){let n=vb(e,1*(1+t.roughness*.2),t);if(!t.disableMultiStroke){const r=vb(e,1.5*(1+t.roughness*.22),dD(t));n=n.concat(r)}return{type:"path",ops:n}}function sD(e,t,n,r,i){const o=zk(n,r,i);return b2(e,t,i,o).opset}function zk(e,t,n){const r=Math.sqrt(Math.PI*2*Math.sqrt((Math.pow(e/2,2)+Math.pow(t/2,2))/2)),i=Math.ceil(Math.max(n.curveStepCount,n.curveStepCount/Math.sqrt(200)*r)),o=Math.PI*2/i;let s=Math.abs(e/2),a=Math.abs(t/2);const l=1-n.curveFitting;return s+=fe(s*l,n),a+=fe(a*l,n),{increment:o,rx:s,ry:a}}function b2(e,t,n,r){const[i,o]=Eb(r.increment,e,t,r.rx,r.ry,1,r.increment*km(.1,km(.4,1,n),n),n);let s=Im(i,null,n);if(!n.disableMultiStroke&&n.roughness!==0){const[a]=Eb(r.increment,e,t,r.rx,r.ry,1.5,0,n),l=Im(a,null,n);s=s.concat(l)}return{estimatedPoints:o,opset:{type:"path",ops:s}}}function gb(e,t,n,r,i,o,s,a,l){const c=e,u=t;let d=Math.abs(n/2),h=Math.abs(r/2);d+=fe(d*.01,l),h+=fe(h*.01,l);let m=i,g=o;for(;m<0;)m+=Math.PI*2,g+=Math.PI*2;g-m>Math.PI*2&&(m=0,g=Math.PI*2);const p=Math.PI*2/l.curveStepCount,v=Math.min(p/2,(g-m)/2),y=wb(v,c,u,d,h,m,g,1,l);if(!l.disableMultiStroke){const E=wb(v,c,u,d,h,m,g,1.5,l);y.push(...E)}return s&&(a?y.push(...Ji(c,u,c+d*Math.cos(m),u+h*Math.sin(m),l),...Ji(c,u,c+d*Math.cos(g),u+h*Math.sin(g),l)):y.push({op:"lineTo",data:[c,u]},{op:"lineTo",data:[c+d*Math.cos(m),u+h*Math.sin(m)]})),{type:"path",ops:y}}function pb(e,t){const n=Fk(Nk(Yv(e))),r=[];let i=[0,0],o=[0,0];for(const{key:s,data:a}of n)switch(s){case"M":{o=[a[0],a[1]],i=[a[0],a[1]];break}case"L":r.push(...Ji(o[0],o[1],a[0],a[1],t)),o=[a[0],a[1]];break;case"C":{const[l,c,u,d,h,m]=a;r.push(...hD(l,c,u,d,h,m,o,t)),o=[h,m];break}case"Z":r.push(...Ji(o[0],o[1],i[0],i[1],t)),o=[i[0],i[1]];break}return{type:"path",ops:r}}function fp(e,t){const n=[];for(const r of e)if(r.length){const i=t.maxRandomnessOffset||0,o=r.length;if(o>2){n.push({op:"move",data:[r[0][0]+fe(i,t),r[0][1]+fe(i,t)]});for(let s=1;s<o;s++)n.push({op:"lineTo",data:[r[s][0]+fe(i,t),r[s][1]+fe(i,t)]})}}return{type:"fillPath",ops:n}}function Ja(e,t){return QR(t,rD).fillPolygons(e,t)}function aD(e,t,n,r,i,o,s){const a=e,l=t;let c=Math.abs(n/2),u=Math.abs(r/2);c+=fe(c*.01,s),u+=fe(u*.01,s);let d=i,h=o;for(;d<0;)d+=Math.PI*2,h+=Math.PI*2;h-d>Math.PI*2&&(d=0,h=Math.PI*2);const m=(h-d)/s.curveStepCount,g=[];for(let p=d;p<=h;p=p+m)g.push([a+c*Math.cos(p),l+u*Math.sin(p)]);return g.push([a+c*Math.cos(h),l+u*Math.sin(h)]),g.push([a,l]),Ja([g],s)}function lD(e,t){return fe(e,t)}function cD(e,t,n){return km(e,t,n)}function uD(e,t,n,r,i){return Ji(e,t,n,r,i,!0)}function dD(e){const t=Object.assign({},e);return t.randomizer=void 0,e.seed&&(t.seed=e.seed+1),t}function Hk(e){return e.randomizer||(e.randomizer=new Dk(e.seed||0)),e.randomizer.next()}function km(e,t,n,r=1){return n.roughness*r*(Hk(n)*(t-e)+e)}function fe(e,t,n=1){return km(-e,e,t,n)}function Ji(e,t,n,r,i,o=!1){const s=o?i.disableMultiStrokeFill:i.disableMultiStroke,a=yb(e,t,n,r,i,!0,!1);if(s)return a;const l=yb(e,t,n,r,i,!0,!0);return a.concat(l)}function yb(e,t,n,r,i,o,s){const a=Math.pow(e-n,2)+Math.pow(t-r,2),l=Math.sqrt(a);let c=1;l<200?c=1:l>500?c=.4:c=-.0016668*l+1.233334;let u=i.maxRandomnessOffset||0;u*u*100>a&&(u=l/10);const d=u/2,h=.2+Hk(i)*.2;let m=i.bowing*i.maxRandomnessOffset*(r-t)/200,g=i.bowing*i.maxRandomnessOffset*(e-n)/200;m=fe(m,i,c),g=fe(g,i,c);const p=[],v=()=>fe(d,i,c),y=()=>fe(u,i,c),E=i.preserveVertices;return o&&(s?p.push({op:"move",data:[e+(E?0:v()),t+(E?0:v())]}):p.push({op:"move",data:[e+(E?0:fe(u,i,c)),t+(E?0:fe(u,i,c))]})),s?p.push({op:"bcurveTo",data:[m+e+(n-e)*h+v(),g+t+(r-t)*h+v(),m+e+2*(n-e)*h+v(),g+t+2*(r-t)*h+v(),n+(E?0:v()),r+(E?0:v())]}):p.push({op:"bcurveTo",data:[m+e+(n-e)*h+y(),g+t+(r-t)*h+y(),m+e+2*(n-e)*h+y(),g+t+2*(r-t)*h+y(),n+(E?0:y()),r+(E?0:y())]}),p}function vb(e,t,n){const r=[];r.push([e[0][0]+fe(t,n),e[0][1]+fe(t,n)]),r.push([e[0][0]+fe(t,n),e[0][1]+fe(t,n)]);for(let i=1;i<e.length;i++)r.push([e[i][0]+fe(t,n),e[i][1]+fe(t,n)]),i===e.length-1&&r.push([e[i][0]+fe(t,n),e[i][1]+fe(t,n)]);return Im(r,null,n)}function Im(e,t,n){const r=e.length,i=[];if(r>3){const o=[],s=1-n.curveTightness;i.push({op:"move",data:[e[1][0],e[1][1]]});for(let a=1;a+2<r;a++){const l=e[a];o[0]=[l[0],l[1]],o[1]=[l[0]+(s*e[a+1][0]-s*e[a-1][0])/6,l[1]+(s*e[a+1][1]-s*e[a-1][1])/6],o[2]=[e[a+1][0]+(s*e[a][0]-s*e[a+2][0])/6,e[a+1][1]+(s*e[a][1]-s*e[a+2][1])/6],o[3]=[e[a+1][0],e[a+1][1]],i.push({op:"bcurveTo",data:[o[1][0],o[1][1],o[2][0],o[2][1],o[3][0],o[3][1]]})}if(t&&t.length===2){const a=n.maxRandomnessOffset;i.push({op:"lineTo",data:[t[0]+fe(a,n),t[1]+fe(a,n)]})}}else r===3?(i.push({op:"move",data:[e[1][0],e[1][1]]}),i.push({op:"bcurveTo",data:[e[1][0],e[1][1],e[2][0],e[2][1],e[2][0],e[2][1]]})):r===2&&i.push(...Ji(e[0][0],e[0][1],e[1][0],e[1][1],n));return i}function Eb(e,t,n,r,i,o,s,a){const l=a.roughness===0,c=[],u=[];if(l){e=e/4,u.push([t+r*Math.cos(-e),n+i*Math.sin(-e)]);for(let d=0;d<=Math.PI*2;d=d+e){const h=[t+r*Math.cos(d),n+i*Math.sin(d)];c.push(h),u.push(h)}u.push([t+r*Math.cos(0),n+i*Math.sin(0)]),u.push([t+r*Math.cos(e),n+i*Math.sin(e)])}else{const d=fe(.5,a)-Math.PI/2;u.push([fe(o,a)+t+.9*r*Math.cos(d-e),fe(o,a)+n+.9*i*Math.sin(d-e)]);const h=Math.PI*2+d-.01;for(let m=d;m<h;m=m+e){const g=[fe(o,a)+t+r*Math.cos(m),fe(o,a)+n+i*Math.sin(m)];c.push(g),u.push(g)}u.push([fe(o,a)+t+r*Math.cos(d+Math.PI*2+s*.5),fe(o,a)+n+i*Math.sin(d+Math.PI*2+s*.5)]),u.push([fe(o,a)+t+.98*r*Math.cos(d+s),fe(o,a)+n+.98*i*Math.sin(d+s)]),u.push([fe(o,a)+t+.9*r*Math.cos(d+s*.5),fe(o,a)+n+.9*i*Math.sin(d+s*.5)])}return[u,c]}function wb(e,t,n,r,i,o,s,a,l){const c=o+fe(.1,l),u=[];u.push([fe(a,l)+t+.9*r*Math.cos(c-e),fe(a,l)+n+.9*i*Math.sin(c-e)]);for(let d=c;d<=s;d=d+e)u.push([fe(a,l)+t+r*Math.cos(d),fe(a,l)+n+i*Math.sin(d)]);return u.push([t+r*Math.cos(s),n+i*Math.sin(s)]),u.push([t+r*Math.cos(s),n+i*Math.sin(s)]),Im(u,null,l)}function hD(e,t,n,r,i,o,s,a){const l=[],c=[a.maxRandomnessOffset||1,(a.maxRandomnessOffset||1)+.3];let u=[0,0];const d=a.disableMultiStroke?1:2,h=a.preserveVertices;for(let m=0;m<d;m++)m===0?l.push({op:"move",data:[s[0],s[1]]}):l.push({op:"move",data:[s[0]+(h?0:fe(c[0],a)),s[1]+(h?0:fe(c[0],a))]}),u=h?[i,o]:[i+fe(c[m],a),o+fe(c[m],a)],l.push({op:"bcurveTo",data:[e+fe(c[m],a),t+fe(c[m],a),n+fe(c[m],a),r+fe(c[m],a),u[0],u[1]]});return l}function $c(e){return[...e]}function fD(e,t=0){const n=e.length;if(n<3)throw new Error("A curve must have at least three points.");const r=[];if(n===3)r.push($c(e[0]),$c(e[1]),$c(e[2]),$c(e[2]));else{const i=[];i.push(e[0],e[0]);for(let a=1;a<e.length;a++)i.push(e[a]),a===e.length-1&&i.push(e[a]);const o=[],s=1-t;r.push($c(i[0]));for(let a=1;a+2<i.length;a++){const l=i[a];o[0]=[l[0],l[1]],o[1]=[l[0]+(s*i[a+1][0]-s*i[a-1][0])/6,l[1]+(s*i[a+1][1]-s*i[a-1][1])/6],o[2]=[i[a+1][0]+(s*i[a][0]-s*i[a+2][0])/6,i[a+1][1]+(s*i[a][1]-s*i[a+2][1])/6],o[3]=[i[a+1][0],i[a+1][1]],r.push(o[1],o[2],o[3])}}return r}function mD(e,t){return Math.sqrt(Tf(e,t))}function Tf(e,t){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function gD(e,t,n){const r=Tf(t,n);if(r===0)return Tf(e,t);let i=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),Tf(e,As(t,n,i))}function As(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function pD(e,t){const n=e[t+0],r=e[t+1],i=e[t+2],o=e[t+3];let s=3*r[0]-2*n[0]-o[0];s*=s;let a=3*r[1]-2*n[1]-o[1];a*=a;let l=3*i[0]-2*o[0]-n[0];l*=l;let c=3*i[1]-2*o[1]-n[1];return c*=c,s<l&&(s=l),a<c&&(a=c),s+a}function _2(e,t,n,r){const i=r||[];if(pD(e,t)<n){const o=e[t+0];i.length?mD(i[i.length-1],o)>1&&i.push(o):i.push(o),i.push(e[t+3])}else{const s=e[t+0],a=e[t+1],l=e[t+2],c=e[t+3],u=As(s,a,.5),d=As(a,l,.5),h=As(l,c,.5),m=As(u,d,.5),g=As(d,h,.5),p=As(m,g,.5);_2([s,u,m,p],0,n,i),_2([p,g,h,c],0,n,i)}return i}function yD(e,t){return Cm(e,0,e.length,t)}function Cm(e,t,n,r,i){const o=i||[],s=e[t],a=e[n-1];let l=0,c=1;for(let u=t+1;u<n-1;++u){const d=gD(e[u],s,a);d>l&&(l=d,c=u)}return Math.sqrt(l)>r?(Cm(e,t,c+1,r,o),Cm(e,c,n,r,o)):(o.length||o.push(s),o.push(a)),o}function Uk(e,t=.15,n){const r=[],i=(e.length-1)/3;for(let o=0;o<i;o++){const s=o*3;_2(e,s,t,r)}return n&&n>0?Cm(r,0,r.length,n):r}function vD(e,t,n){const r=Yv(e),i=Fk(Nk(r)),o=[];let s=[],a=[0,0],l=[];const c=()=>{l.length>=4&&s.push(...Uk(l,t)),l=[]},u=()=>{c(),s.length&&(o.push(s),s=[])};for(const{key:h,data:m}of i)switch(h){case"M":u(),a=[m[0],m[1]],s.push(a);break;case"L":c(),s.push([m[0],m[1]]);break;case"C":if(!l.length){const g=s.length?s[s.length-1]:a;l.push([g[0],g[1]])}l.push([m[0],m[1]]),l.push([m[2],m[3]]),l.push([m[4],m[5]]);break;case"Z":c(),s.push([a[0],a[1]]);break}if(u(),!n)return o;const d=[];for(const h of o){const m=yD(h,n);m.length&&d.push(m)}return d}const Yn="none";class gd{constructor(t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=t||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return JR()}_o(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_d(t,n,r){return{shape:t,sets:n||[],options:r||this.defaultOptions}}line(t,n,r,i,o){const s=this._o(o);return this._d("line",[Bk(t,n,r,i,s)],s)}rectangle(t,n,r,i,o){const s=this._o(o),a=[],l=oD(t,n,r,i,s);if(s.fill){const c=[[t,n],[t+r,n],[t+r,n+i],[t,n+i]];s.fillStyle==="solid"?a.push(fp([c],s)):a.push(Ja([c],s))}return s.stroke!==Yn&&a.push(l),this._d("rectangle",a,s)}ellipse(t,n,r,i,o){const s=this._o(o),a=[],l=zk(r,i,s),c=b2(t,n,s,l);if(s.fill)if(s.fillStyle==="solid"){const u=b2(t,n,s,l).opset;u.type="fillPath",a.push(u)}else a.push(Ja([c.estimatedPoints],s));return s.stroke!==Yn&&a.push(c.opset),this._d("ellipse",a,s)}circle(t,n,r,i){const o=this.ellipse(t,n,r,r,i);return o.shape="circle",o}linearPath(t,n){const r=this._o(n);return this._d("linearPath",[Cf(t,!1,r)],r)}arc(t,n,r,i,o,s,a=!1,l){const c=this._o(l),u=[],d=gb(t,n,r,i,o,s,a,!0,c);if(a&&c.fill)if(c.fillStyle==="solid"){const h=Object.assign({},c);h.disableMultiStroke=!0;const m=gb(t,n,r,i,o,s,!0,!1,h);m.type="fillPath",u.push(m)}else u.push(aD(t,n,r,i,o,s,c));return c.stroke!==Yn&&u.push(d),this._d("arc",u,c)}curve(t,n){const r=this._o(n),i=[],o=mb(t,r);if(r.fill&&r.fill!==Yn&&t.length>=3)if(r.fillStyle==="solid"){const s=mb(t,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(s.ops)})}else{const s=fD(t),a=Uk(s,10,(1+r.roughness)/2);i.push(Ja([a],r))}return r.stroke!==Yn&&i.push(o),this._d("curve",i,r)}polygon(t,n){const r=this._o(n),i=[],o=Cf(t,!0,r);return r.fill&&(r.fillStyle==="solid"?i.push(fp([t],r)):i.push(Ja([t],r))),r.stroke!==Yn&&i.push(o),this._d("polygon",i,r)}path(t,n){const r=this._o(n),i=[];if(!t)return this._d("path",i,r);t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");const o=r.fill&&r.fill!=="transparent"&&r.fill!==Yn,s=r.stroke!==Yn,a=!!(r.simplification&&r.simplification<1),l=a?4-4*(r.simplification||1):(1+r.roughness)/2,c=vD(t,1,l),u=pb(t,r);if(o)if(r.fillStyle==="solid")if(c.length===1){const d=pb(t,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(d.ops)})}else i.push(fp(c,r));else i.push(Ja(c,r));return s&&(a?c.forEach(d=>{i.push(Cf(d,!1,r))}):i.push(u)),this._d("path",i,r)}opsToPath(t,n){let r="";for(const i of t.ops){const o=typeof n=="number"&&n>=0?i.data.map(s=>+s.toFixed(n)):i.data;switch(i.op){case"move":r+=`M${o[0]} ${o[1]} `;break;case"bcurveTo":r+=`C${o[0]} ${o[1]}, ${o[2]} ${o[3]}, ${o[4]} ${o[5]} `;break;case"lineTo":r+=`L${o[0]} ${o[1]} `;break}}return r.trim()}toPaths(t){const n=t.sets||[],r=t.options||this.defaultOptions,i=[];for(const o of n){let s=null;switch(o.type){case"path":s={d:this.opsToPath(o),stroke:r.stroke,strokeWidth:r.strokeWidth,fill:Yn};break;case"fillPath":s={d:this.opsToPath(o),stroke:Yn,strokeWidth:0,fill:r.fill||Yn};break;case"fillSketch":s=this.fillSketch(o,r);break}s&&i.push(s)}return i}fillSketch(t,n){let r=n.fillWeight;return r<0&&(r=n.strokeWidth/2),{d:this.opsToPath(t),stroke:n.fill||Yn,strokeWidth:r,fill:Yn}}_mergedShape(t){return t.filter((n,r)=>r===0?!0:n.op!=="move")}}class ED{constructor(t,n){this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new gd(n)}draw(t){const n=t.sets||[],r=t.options||this.getDefaultOptions(),i=this.ctx,o=t.options.fixedDecimalPlaceDigits;for(const s of n)switch(s.type){case"path":i.save(),i.strokeStyle=r.stroke==="none"?"transparent":r.stroke,i.lineWidth=r.strokeWidth,r.strokeLineDash&&i.setLineDash(r.strokeLineDash),r.strokeLineDashOffset&&(i.lineDashOffset=r.strokeLineDashOffset),this._drawToContext(i,s,o),i.restore();break;case"fillPath":{i.save(),i.fillStyle=r.fill||"";const a=t.shape==="curve"||t.shape==="polygon"||t.shape==="path"?"evenodd":"nonzero";this._drawToContext(i,s,o,a),i.restore();break}case"fillSketch":this.fillSketch(i,s,r);break}}fillSketch(t,n,r){let i=r.fillWeight;i<0&&(i=r.strokeWidth/2),t.save(),r.fillLineDash&&t.setLineDash(r.fillLineDash),r.fillLineDashOffset&&(t.lineDashOffset=r.fillLineDashOffset),t.strokeStyle=r.fill||"",t.lineWidth=i,this._drawToContext(t,n,r.fixedDecimalPlaceDigits),t.restore()}_drawToContext(t,n,r,i="nonzero"){t.beginPath();for(const o of n.ops){const s=typeof r=="number"&&r>=0?o.data.map(a=>+a.toFixed(r)):o.data;switch(o.op){case"move":t.moveTo(s[0],s[1]);break;case"bcurveTo":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"lineTo":t.lineTo(s[0],s[1]);break}}n.type==="fillPath"?t.fill(i):t.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(t,n,r,i,o){const s=this.gen.line(t,n,r,i,o);return this.draw(s),s}rectangle(t,n,r,i,o){const s=this.gen.rectangle(t,n,r,i,o);return this.draw(s),s}ellipse(t,n,r,i,o){const s=this.gen.ellipse(t,n,r,i,o);return this.draw(s),s}circle(t,n,r,i){const o=this.gen.circle(t,n,r,i);return this.draw(o),o}linearPath(t,n){const r=this.gen.linearPath(t,n);return this.draw(r),r}polygon(t,n){const r=this.gen.polygon(t,n);return this.draw(r),r}arc(t,n,r,i,o,s,a=!1,l){const c=this.gen.arc(t,n,r,i,o,s,a,l);return this.draw(c),c}curve(t,n){const r=this.gen.curve(t,n);return this.draw(r),r}path(t,n){const r=this.gen.path(t,n);return this.draw(r),r}}const Bh="http://www.w3.org/2000/svg";class wD{constructor(t,n){this.svg=t,this.gen=new gd(n)}draw(t){const n=t.sets||[],r=t.options||this.getDefaultOptions(),i=this.svg.ownerDocument||window.document,o=i.createElementNS(Bh,"g"),s=t.options.fixedDecimalPlaceDigits;for(const a of n){let l=null;switch(a.type){case"path":{l=i.createElementNS(Bh,"path"),l.setAttribute("d",this.opsToPath(a,s)),l.setAttribute("stroke",r.stroke),l.setAttribute("stroke-width",r.strokeWidth+""),l.setAttribute("fill","none"),r.strokeLineDash&&l.setAttribute("stroke-dasharray",r.strokeLineDash.join(" ").trim()),r.strokeLineDashOffset&&l.setAttribute("stroke-dashoffset",`${r.strokeLineDashOffset}`);break}case"fillPath":{l=i.createElementNS(Bh,"path"),l.setAttribute("d",this.opsToPath(a,s)),l.setAttribute("stroke","none"),l.setAttribute("stroke-width","0"),l.setAttribute("fill",r.fill||""),(t.shape==="curve"||t.shape==="polygon")&&l.setAttribute("fill-rule","evenodd");break}case"fillSketch":{l=this.fillSketch(i,a,r);break}}l&&o.appendChild(l)}return o}fillSketch(t,n,r){let i=r.fillWeight;i<0&&(i=r.strokeWidth/2);const o=t.createElementNS(Bh,"path");return o.setAttribute("d",this.opsToPath(n,r.fixedDecimalPlaceDigits)),o.setAttribute("stroke",r.fill||""),o.setAttribute("stroke-width",i+""),o.setAttribute("fill","none"),r.fillLineDash&&o.setAttribute("stroke-dasharray",r.fillLineDash.join(" ").trim()),r.fillLineDashOffset&&o.setAttribute("stroke-dashoffset",`${r.fillLineDashOffset}`),o}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(t,n){return this.gen.opsToPath(t,n)}line(t,n,r,i,o){const s=this.gen.line(t,n,r,i,o);return this.draw(s)}rectangle(t,n,r,i,o){const s=this.gen.rectangle(t,n,r,i,o);return this.draw(s)}ellipse(t,n,r,i,o){const s=this.gen.ellipse(t,n,r,i,o);return this.draw(s)}circle(t,n,r,i){const o=this.gen.circle(t,n,r,i);return this.draw(o)}linearPath(t,n){const r=this.gen.linearPath(t,n);return this.draw(r)}polygon(t,n){const r=this.gen.polygon(t,n);return this.draw(r)}arc(t,n,r,i,o,s,a=!1,l){const c=this.gen.arc(t,n,r,i,o,s,a,l);return this.draw(c)}curve(t,n){const r=this.gen.curve(t,n);return this.draw(r)}path(t,n){const r=this.gen.path(t,n);return this.draw(r)}}const ws={canvas(e,t){return new ED(e,t)},svg(e,t){return new wD(e,t)},generator(e){return new gd(e)},newSeed(){return gd.newSeed()}};let Kv=(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),"");const bb=()=>{const e=new Date,t=e.getFullYear(),n=`${e.getMonth()+1}`.padStart(2,"0"),r=`${e.getDate()}`.padStart(2,"0"),i=`${e.getHours()}`.padStart(2,"0"),o=`${e.getMinutes()}`.padStart(2,"0");return`${t}-${n}-${r}-${i}${o}`},Mf=e=>e.charAt(0).toUpperCase()+e.slice(1),bD=e=>e instanceof HTMLElement&&e.className.includes("ToolIcon"),Wk=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,_D=e=>Wk(e)||e instanceof Element&&!!e.closest("label, button"),Ns=e=>e instanceof HTMLElement&&e.dataset.type==="wysiwyg"||e instanceof HTMLBRElement||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&(e.type==="text"||e.type==="number"||e.type==="password"),Zv=({fontFamily:e})=>{for(const[t,n]of Object.entries(Xt))if(n===e)return`${t}, ${sb}`;return sb},Bt=({fontSize:e,fontFamily:t})=>`${e}px ${Zv({fontFamily:t})}`,fa=(e,t)=>{let n=0,r=null;const i=(...o)=>{r=o,clearTimeout(n),n=window.setTimeout(()=>{r=null,e(...o)},t)};return i.flush=()=>{if(clearTimeout(n),r){const o=r;r=null,e(...o)}},i.cancel=()=>{r=null,clearTimeout(n)},i},F1=(e,t)=>{let n=null,r=null,i=null;const o=a=>{n=window.requestAnimationFrame(()=>{n=null,e(...a),r=null,i&&(r=i,i=null,o(r))})},s=(...a)=>{r=a,n===null?o(r):t!=null&&t.trailing&&(i=a)};return s.flush=()=>{n!==null&&(cancelAnimationFrame(n),n=null),r&&(e(...i||r),r=i=null)},s.cancel=()=>{r=i=null,n!==null&&(cancelAnimationFrame(n),n=null)},s},ra=e=>1-Math.pow(1-e,4),_b=(e,t,n)=>(t-e)*ra(n)+e,xD=({fromValues:e,toValues:t,onStep:n,duration:r=250,interpolateValue:i,onStart:o,onEnd:s,onCancel:a})=>{let l=!1,c=0,u;function d(h){if(l)return;u===void 0&&(u=h,o==null||o());const m=Math.min(h-u,r),g=ra(m/r),p={};if(Object.keys(e).forEach(v=>{const y=v,E=(t[y]-e[y])*g+e[y];p[y]=E}),n(p),m<r){const v=m/r,y={};Object.keys(e).forEach(E=>{const w=E,x=e[w],C=t[w];let S;S=i?i(x,C,v,w):_b(x,C,v),S==null&&(S=_b(x,C,v)),y[w]=S}),n(y),c=window.requestAnimationFrame(d)}else n(t),s==null||s()}return c=window.requestAnimationFrame(d),()=>{a==null||a(),l=!0,window.cancelAnimationFrame(c)}},SD=(e,t)=>{if(!e.length||t<1)return[];let n=0,r=0;const i=Array(Math.ceil(e.length/t));for(;n<e.length;)i[r++]=e.slice(n,n+=t);return i},un=(e,t)=>Math.abs(e-t),bt=(e,t)=>t.type==="custom"?{...e.activeTool,type:"custom",customType:t.customType,locked:t.locked??e.activeTool.locked}:{...e.activeTool,lastActiveTool:t.lastActiveToolBeforeEraser===void 0?e.activeTool.lastActiveTool:t.lastActiveToolBeforeEraser,type:t.type,customType:null,locked:t.locked??e.activeTool.locked},K=e=>(e=e.replace(/\bAlt\b/i,"Alt").replace(/\bShift\b/i,"Shift").replace(/\b(Enter|Return)\b/i,"Enter"),ki?e.replace(/\bCtrlOrCmd\b/gi,"Cmd").replace(/\bAlt\b/i,"Option"):e.replace(/\bCtrlOrCmd\b/gi,"Ctrl")),et=({clientX:e,clientY:t},{zoom:n,offsetLeft:r,offsetTop:i,scrollX:o,scrollY:s})=>{const a=(e-r)/n.value-o,l=(t-i)/n.value-s;return{x:a,y:l}},Ur=({sceneX:e,sceneY:t},{zoom:n,offsetLeft:r,offsetTop:i,scrollX:o,scrollY:s})=>{const a=(e+o)*n.value+r,l=(t+s)*n.value+i;return{x:a,y:l}},zh=e=>getComputedStyle(document.documentElement).getPropertyValue(`--${e}`),kD="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿Ⰰ-﬜﷾-﹯﻽-￿",ID="֑-߿יִ-﷽ﹰ-ﻼ",CD=new RegExp(`^[^${kD}]*[${ID}]`),Vk=e=>CD.test(e),Oo=e=>{const[t,n]=e;return{x:t,y:n}},Gk=e=>{if((e==null?void 0:e.name)==="AbortError"){console.warn(e);return}throw e},jk=(e,t,n=0)=>{n<0&&(n=e.length+n),n=Math.min(e.length,Math.max(n,0));let r=n-1;for(;++r<e.length;)if(t(e[r],r,e))return r;return-1},Yk=(e,t,n=e.length-1)=>{n<0&&(n=e.length+n),n=Math.min(e.length-1,Math.max(n,0));let r=n+1;for(;--r>-1;)if(t(e[r],r,e))return r;return-1},Ei=e=>{const t=e.length===5&&e.substr(4,1)==="0",n=e.length===9&&e.substr(7,2)==="00";return t||n||e===ve.transparent},$1=()=>{let e,t;const n=new Promise((r,i)=>{e=r,t=i});return n.resolve=e,n.reject=t,n},xb=(e,t)=>{const n=[{value:1,symbol:"b"},{value:1e3,symbol:"k"},{value:1e6,symbol:"M"},{value:1e9,symbol:"G"}],r=/\.0+$|(\.[0-9]*[1-9])0+$/;let i;for(i=n.length-1;i>0&&!(e>=n[i].value);i--);return(e/n[i].value).toFixed(t).replace(r,"$1")+n[i].symbol},x2=()=>{var e;return((e=document.querySelector('meta[name="version"]'))==null?void 0:e.content)||HS},TD=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},MD=e=>{let t=e.parentElement;for(;t;){if(t.tabIndex>-1){t.focus();return}t=t.parentElement}},Xv=e=>{e.preventDefault(),e.returnValue=""},Kk=e=>Array.from(e).map(t=>`0${t.toString(16)}`.slice(-2)).join(""),cc=()=>Date.now(),be=e=>e instanceof Map?e:e.reduce((t,n)=>(t.set(typeof n=="string"?n:n.id,n),t),new Map),Zk=e=>e.reduce((t,n,r)=>(t.set(n.id,[n,r]),t),new Map),Xk=(e,t)=>new CustomEvent(e,{detail:{nativeEvent:t},cancelable:!0}),Af=(e,t)=>{let n=!1;for(const r in t){const i=t[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return n?{...e,...t}:e},Zd=()=>{try{return window.self===window.top?"top":"iframe"}catch{return"iframe"}},AD=()=>Zd()==="iframe",Xd=e=>!!e&&typeof e=="object"&&"then"in e&&"catch"in e&&"finally"in e,S2=e=>{const t=e==null?void 0:e.querySelectorAll("button, a, input, select, textarea, div[tabindex], label[tabindex]");return t?Array.from(t).filter(n=>n.tabIndex>-1&&!n.disabled):[]},Sb=(e,t)=>Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t,Jn=(e,t,n,r=!1)=>{const i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return r&&console.warn("%cisShallowEqual: objects don't have same properties ->","color: #8B4000",e,t),!1;if(n&&Array.isArray(n)){for(const s of n)if(!(e[s]===t[s]||Sb(e[s],t[s])))return r&&console.warn(`%cisShallowEqual: ${s} not equal ->`,"color: #8B4000",e[s],t[s]),!1;return!0}return i.every(s=>{const a=n==null?void 0:n[s],l=a?a(e[s],t[s]):e[s]===t[s]||Sb(e[s],t[s]);return!l&&r&&console.warn(`%cisShallowEqual: ${s} not equal ->`,"color: #8B4000",e[s],t[s]),l})},B1=(e,t,{checkForDefaultPrevented:n=!0}={})=>function(i){if(e==null||e(i),!n||!(i!=null&&i.defaultPrevented))return t==null?void 0:t(i)},jl=(e,t,n)=>{if(!t)return e;if(n)return console.error(t),e;throw new Error(t)},LD=e=>{let t,n;const r=function(i){const o=Object.entries(i);if(t){let a=!0;for(const[l,c]of o)if(t.get(l)!==c){a=!1;break}if(a)return n}const s=e(i);return t=new Map(o),n=s,s};return r.clear=()=>{t=void 0,n=void 0},r},k2=(e,t)=>e instanceof Set||e instanceof Map?e.has(t):"includes"in e?e.includes(t):e.hasOwnProperty(t),Yl=e=>JSON.parse(JSON.stringify(e)),kb=e=>typeof e=="number"&&Number.isFinite(e),mp=(e,t)=>Jn(e,t)?e:t;function gt(e,t,n,r){var i;return e?((i=e==null?void 0:e.addEventListener)==null||i.call(e,t,n,r),()=>{var o;(o=e==null?void 0:e.removeEventListener)==null||o.call(e,t,n,r)}):()=>{}}const Hh=(e,t)=>(e+t)/2;function PD(e,t=!0){const n=e.length;if(n<4)return"";let r=e[0],i=e[1];const o=e[2];let s=`M${r[0].toFixed(2)},${r[1].toFixed(2)} Q${i[0].toFixed(2)},${i[1].toFixed(2)} ${Hh(i[0],o[0]).toFixed(2)},${Hh(i[1],o[1]).toFixed(2)} T`;for(let a=2,l=n-1;a<l;a++)r=e[a],i=e[a+1],s+=`${Hh(r[0],i[0]).toFixed(2)},${Hh(r[1],i[1]).toFixed(2)} `;return t&&(s+="Z"),s}const qk=e=>e.replace(/\r?\n|\r/g,`
`),ma=e=>e,I2=async(e,...t)=>new Promise(n=>{n(e(...t))}),Ft=e=>!!e&&e.type==="image"&&!!e.fileId,Gi=e=>!!e&&e.type==="image",bn=e=>!!e&&e.type==="embeddable",Io=e=>!!e&&e.type==="iframe",fr=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),ce=e=>e!=null&&e.type==="text",pd=e=>e!=null&&e.type==="frame",uu=e=>e!=null&&e.type==="magicframe",pe=e=>e!=null&&(e.type==="frame"||e.type==="magicframe"),Hn=e=>e!=null&&RD(e.type),RD=e=>e==="freedraw",we=e=>e!=null&&qv(e.type),Ge=e=>e!=null&&e.type==="arrow",qv=e=>e==="arrow"||e==="line",dn=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&Qk(e.type),Qk=e=>e==="arrow",yd=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),ia=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||Ge(e)),Jk=e=>{const t=e==null?void 0:e.type;if(!t)return!1;switch(t){case"text":case"diamond":case"rectangle":case"iframe":case"embeddable":case"ellipse":case"arrow":case"freedraw":case"line":case"frame":case"magicframe":case"image":case"selection":return!0;default:return jl(t,null),!1}},ls=e=>{var t;return ia(e)&&!!((t=e.boundElements)!=null&&t.some(({type:n})=>n==="text"))},Mt=e=>e!==null&&"containerId"in e&&e.containerId!==null&&ce(e),uc=e=>e==="rectangle"||e==="embeddable"||e==="iframe"||e==="image",eI=e=>e==="line"||e==="arrow"||e==="diamond",DD=(e,t)=>!!((e===Vt.ADAPTIVE_RADIUS||e===Vt.LEGACY)&&uc(t.type)||e===Vt.PROPORTIONAL_RADIUS&&eI(t.type)),OD=e=>eI(e.type)?{type:Vt.PROPORTIONAL_RADIUS}:uc(e.type)?{type:Vt.ADAPTIVE_RADIUS}:null;let ND=new Dk(Date.now());const bs=()=>Math.floor(ND.next()*2**31),xr=()=>Kv(),Ib=e=>{const t=new Map,n=[];for(const r of e)r.isDeleted||(n.push(r),t.set(r.id,r));return{elementsMap:t,elements:n}},FD=e=>{const t=["includeBoundTextElement","includeElementsInFrames"];let n="";for(const r of t)n+=`${r}:${e[r]?"1":"0"}`;return n},Cb=e=>typeof e=="string",zs=class zs{constructor(){M(this,"callbacks",new Set);M(this,"nonDeletedElements",[]);M(this,"nonDeletedElementsMap",ma(new Map));M(this,"elements",[]);M(this,"nonDeletedFramesLikes",[]);M(this,"frames",[]);M(this,"elementsMap",ma(new Map));M(this,"selectedElementsCache",{selectedElementIds:null,elements:null,cache:new Map});M(this,"versionNonce");M(this,"addNewElement",t=>{t.frameId?this.insertElementAtIndex(t,this.getElementIndex(t.frameId)):this.replaceAllElements([...this.elements,t])});M(this,"getContainerElement",t=>t&&t.containerId&&this.getElement(t.containerId)||null)}static mapElementToScene(t,n){Cb(t)?this.sceneMapById.set(t,n):(this.sceneMapByElement.set(t,n),this.sceneMapById.set(t.id,n))}static getScene(t){return Cb(t)?this.sceneMapById.get(t)||null:this.sceneMapByElement.get(t)||null}getElementsMapIncludingDeleted(){return this.elementsMap}getNonDeletedElementsMap(){return this.nonDeletedElementsMap}getElementsIncludingDeleted(){return this.elements}getNonDeletedElements(){return this.nonDeletedElements}getFramesIncludingDeleted(){return this.frames}getSelectedElements(t){const n=FD(t),r=(t==null?void 0:t.elements)||this.nonDeletedElements;if(this.selectedElementsCache.elements===r&&this.selectedElementsCache.selectedElementIds===t.selectedElementIds){const o=this.selectedElementsCache.cache.get(n);if(o)return o}else(t==null?void 0:t.elements)==null&&this.selectedElementsCache.cache.clear();const i=qe(r,{selectedElementIds:t.selectedElementIds},t);return(t==null?void 0:t.elements)==null&&(this.selectedElementsCache.selectedElementIds=t.selectedElementIds,this.selectedElementsCache.elements=this.nonDeletedElements,this.selectedElementsCache.cache.set(n,i)),i}getNonDeletedFramesLikes(){return this.nonDeletedFramesLikes}getElement(t){return this.elementsMap.get(t)||null}getVersionNonce(){return this.versionNonce}getNonDeletedElement(t){const n=this.getElement(t);return n&&ty(n)?n:null}mapElements(t){let n=!1;const r=this.elements.map(i=>{const o=t(i);return o!==i&&(n=!0),o});return n&&this.replaceAllElements(r),n}replaceAllElements(t){this.elements=t instanceof Array?t:Array.from(t.values());const n=[];this.elementsMap.clear(),this.elements.forEach(i=>{pe(i)&&n.push(i),this.elementsMap.set(i.id,i),zs.mapElementToScene(i,this)});const r=Ib(this.elements);this.nonDeletedElements=r.elements,this.nonDeletedElementsMap=r.elementsMap,this.frames=n,this.nonDeletedFramesLikes=Ib(this.frames).elements,this.informMutation()}informMutation(){this.versionNonce=bs();for(const t of Array.from(this.callbacks))t()}addCallback(t){if(this.callbacks.has(t))throw new Error;return this.callbacks.add(t),()=>{if(!this.callbacks.has(t))throw new Error;this.callbacks.delete(t)}}destroy(){this.nonDeletedElements=[],this.elements=[],this.nonDeletedFramesLikes=[],this.frames=[],this.elementsMap.clear(),this.selectedElementsCache.selectedElementIds=null,this.selectedElementsCache.elements=null,this.selectedElementsCache.cache.clear(),zs.sceneMapById.forEach((t,n)=>{t===this&&zs.sceneMapById.delete(n)}),this.callbacks.clear()}insertElementAtIndex(t,n){if(!Number.isFinite(n)||n<0)throw new Error("insertElementAtIndex can only be called with index >= 0");const r=[...this.elements.slice(0,n),t,...this.elements.slice(n)];this.replaceAllElements(r)}insertElementsAtIndex(t,n){if(!Number.isFinite(n)||n<0)throw new Error("insertElementAtIndex can only be called with index >= 0");const r=[...this.elements.slice(0,n),...t,...this.elements.slice(n)];this.replaceAllElements(r)}getElementIndex(t){return this.elements.findIndex(n=>n.id===t)}};M(zs,"sceneMapByElement",new WeakMap),M(zs,"sceneMapById",new Map);let $t=zs;const tI=e=>{const t=e.map(r=>r[0]),n=e.map(r=>r[1]);return{width:Math.max(...t)-Math.min(...t),height:Math.max(...n)-Math.min(...n)}},Kl=(e,t,n,r)=>{const i=n.map(m=>m[e]),o=Math.max(...i),s=Math.min(...i),a=o-s,l=a===0?1:t/a;let c=1/0;const u=n.map(m=>{const g=m[e]*l,p=[...m];return p[e]=g,g<c&&(c=g),p});if(!r||u.length===2)return u;const d=s-c;return u.map(m=>m.map((g,p)=>p===e?g+d:g))},_e=(e,t,n,r,i)=>[(e-n)*Math.cos(i)-(t-r)*Math.sin(i)+n,(e-n)*Math.sin(i)+(t-r)*Math.cos(i)+r],st=(e,t,n)=>_e(e[0],e[1],t[0],t[1],n),nI=(e,t,n,r,i,o,s,a)=>{const l=Math.cos(r),c=Math.sin(r);return e.e&&e.w?t+=i+s:e.e?(t+=i*(1+l),n+=i*c,t+=s*(1-l),n+=s*-c):e.w&&(t+=i*(1-l),n+=i*-c,t+=s*(1+l),n+=s*c),e.n&&e.s?n+=o+a:e.n?(t+=o*c,n+=o*(1-l),t+=a*-c,n+=a*(1+l)):e.s&&(t+=o*-c,n+=o*(1+l),t+=a*c,n+=a*(1-l)),[t,n]},kt=(e,t,n,r)=>{const i=n-e,o=r-t;return Math.hypot(i,o)},C2=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],cs=(e,t=1)=>{if(e.length>=3){const[n,r]=[e[0],e[e.length-1]];return kt(n[0],n[1],r[0],r[1])<=Sf/t}return!1},Tb=(e,t,n)=>{const r=e.length;if(r<3)return!1;const i=[Number.MAX_SAFE_INTEGER,n],o=[t,n];let s=0;for(let a=0;a<r;a++){const l=e[a],c=e[(a+1)%r];if($D(l,c,o,i)){if(du(l,o,c)===0)return ml(l,o,c);s++}}return s%2===1},ml=(e,t,n)=>t[0]<=Math.max(e[0],n[0])&&t[0]>=Math.min(e[0],n[0])&&t[1]<=Math.max(e[1],n[1])&&t[1]>=Math.min(e[1],n[1]),du=(e,t,n)=>{const r=(t[1]-e[1])*(n[0]-t[0])-(t[0]-e[0])*(n[1]-t[1]);return r===0?0:r>0?1:2},$D=(e,t,n,r)=>{const i=du(e,t,n),o=du(e,t,r),s=du(n,r,e),a=du(n,r,t);return!!(i!==o&&s!==a||i===0&&ml(e,n,t)||o===0&&ml(e,r,t)||s===0&&ml(n,e,r)||a===0&&ml(n,t,r))},jt=(e,t,n)=>n?[Math.round(e/n)*n,Math.round(t/n)*n]:[e,t],oa=(e,t)=>{var n,r,i,o;if(((n=t.roundness)==null?void 0:n.type)===Vt.PROPORTIONAL_RADIUS||((r=t.roundness)==null?void 0:r.type)===Vt.LEGACY)return e*cp;if(((i=t.roundness)==null?void 0:i.type)===Vt.ADAPTIVE_RADIUS){const s=((o=t.roundness)==null?void 0:o.value)??xR,a=s/cp;return e<=a?e*cp:s}return 0},rI=(e,t)=>{const n=Xe.generateElementShape(e,null);if(!n)return null;const r=_s(n[0]);let i=[0,0],o=0,s=1/0,a=null;for(;o<r.length;){const{op:l,data:c}=r[o];if(l==="move"&&(i=c),l==="bcurveTo"){const u=i,d=[c[0],c[1]],h=[c[2],c[3]],m=[c[4],c[5]],g=kt(m[0],m[1],t[0],t[1]);g<s&&(s=g,a=[u,d,h,m]),i=m}o++}return a},iI=(e,t,n,r,i)=>{const o=(l,c)=>Math.pow(1-l,3)*r[c]+3*l*Math.pow(1-l,2)*n[c]+3*Math.pow(l,2)*(1-l)*t[c]+e[c]*Math.pow(l,3),s=o(i,0),a=o(i,1);return[s,a]},BD=(e,t)=>{const n=rI(e,t);if(!n)return[];const r=[];let i=1;for(;i>0;){const o=iI(n[0],n[1],n[2],n[3],i);r.push([o[0],o[1]]),i-=.05}return r.length&&sI(r.at(-1),t)&&r.push([t[0],t[1]]),r},oI=(e,t)=>{const n=[];n[0]=0;const r=BD(e,t);let i=0,o=0;for(;i<r.length-1;){const s=kt(r[i][0],r[i][1],r[i+1][0],r[i+1][1]);o+=s,n.push(o),i++}return n},zD=(e,t)=>oI(e,t).at(-1),HD=(e,t,n)=>{const r=oI(e,t),i=r.length-1,o=r.at(-1),s=n*o;let a=0,l=i,c=0;for(;a<l;)c=Math.floor(a+(l-a)/2),r[c]<s?a=c+1:l=c;return r[c]>s&&c--,r[c]===s?c/i:1-(c+(s-r[c])/(r[c+1]-r[c]))/i},sI=(e,t)=>e[0]===t[0]&&e[1]===t[1],UD=e=>Math.round(e/Math.PI*1e4)%5e3===0,Tm=([e,t],[n,r])=>e<=n?t>=n:e>=n?r>=e:!1,Mm=(e,t)=>{const n=Math.max(e[0],t[0]),r=Math.min(e[1],t[1]);return n<=r?[n,r]:null},Uh=(e,t,n)=>e>=t&&e<=n;function WD(e,t){return Math.sqrt(Lf(e,t))}function Lf(e,t){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function VD(e,t,n){const r=Lf(t,n);if(r===0)return Lf(e,t);let i=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),Lf(e,Ls(t,n,i))}function Ls(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function GD(e,t){const n=e[t+0],r=e[t+1],i=e[t+2],o=e[t+3];let s=3*r[0]-2*n[0]-o[0];s*=s;let a=3*r[1]-2*n[1]-o[1];a*=a;let l=3*i[0]-2*o[0]-n[0];l*=l;let c=3*i[1]-2*o[1]-n[1];return c*=c,s<l&&(s=l),a<c&&(a=c),s+a}function T2(e,t,n,r){const i=r||[];if(GD(e,t)<n){const o=e[t+0];i.length?WD(i[i.length-1],o)>1&&i.push(o):i.push(o),i.push(e[t+3])}else{const s=e[t+0],a=e[t+1],l=e[t+2],c=e[t+3],u=Ls(s,a,.5),d=Ls(a,l,.5),h=Ls(l,c,.5),m=Ls(u,d,.5),g=Ls(d,h,.5),p=Ls(m,g,.5);T2([s,u,m,p],0,n,i),T2([p,g,h,c],0,n,i)}return i}function jD(e,t){return Am(e,0,e.length,t)}function Am(e,t,n,r,i){const o=i||[],s=e[t],a=e[n-1];let l=0,c=1;for(let u=t+1;u<n-1;++u){const d=VD(e[u],s,a);d>l&&(l=d,c=u)}return Math.sqrt(l)>r?(Am(e,t,c+1,r,o),Am(e,c,n,r,o)):(o.length||o.push(s),o.push(a)),o}function YD(e,t=.15,n){const r=[],i=(e.length-1)/3;for(let o=0;o<i;o++){const s=o*3;T2(e,s,t,r)}return n&&n>0?Am(r,0,r.length,n):r}const gl=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",M2=e=>e!=="image"&&e!=="frame"&&e!=="magicframe",Mb=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",Ab=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",A2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="arrow"||e==="line"||e==="diamond"||e==="image",Lm=e=>e==="arrow",KD=(e,t)=>{let n=null;for(let r=e.length-1;r>=0;--r){const i=e[r];if(!i.isDeleted&&t(i)){n=i;break}}return n},ZD=(e,t)=>{const n=[];return e.filter(i=>!i.isDeleted&&t(i)?Io(i)?(n.push(i),!1):!0:!1).concat(n)},XD=e=>[8,8+e],aI=e=>[1.5,6+e];function qD(e){const t=e.roughness,n=Math.max(e.width,e.height),r=Math.min(e.width,e.height);return r>=20&&n>=50||r>=15&&e.roundness&&A2(e.type)||we(e)&&n>=50?t:Math.min(t/(n<10?3:2),2.5)}const ur=(e,t=!1)=>{const n={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?XD(e.strokeWidth):e.strokeStyle==="dotted"?aI(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:qD(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<VS.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return n.fillStyle=e.fillStyle,n.fill=Ei(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(n.curveFitting=1),n;case"line":case"freedraw":return cs(e.points)&&(n.fillStyle=e.fillStyle,n.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),n;case"arrow":return n;default:throw new Error(`Unimplemented type ${e.type}`)}},Lb=(e,t,n)=>fr(e)&&(t||bn(e)&&(n==null?void 0:n.get(e.id))!==!0)&&Ei(e.backgroundColor)&&Ei(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Io(e)?{...e,strokeColor:Ei(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Ei(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Pb=(e,t,n,r,i,o,s)=>{const a=hN(e,t,n,r);if(a===null)return[];switch(r){case"dot":case"circle":case"circle_outline":{const[l,c,u]=a;return delete o.strokeLineDash,[i.circle(l,c,u,{...o,fill:r==="circle_outline"?s:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,o.roughness||0)})]}case"triangle":case"triangle_outline":{const[l,c,u,d,h,m]=a;return delete o.strokeLineDash,[i.polygon([[l,c],[u,d],[h,m],[l,c]],{...o,fill:r==="triangle_outline"?s:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,o.roughness||0)})]}case"diamond":case"diamond_outline":{const[l,c,u,d,h,m,g,p]=a;return delete o.strokeLineDash,[i.polygon([[l,c],[u,d],[h,m],[g,p],[l,c]],{...o,fill:r==="diamond_outline"?s:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,o.roughness||0)})]}case"bar":case"arrow":default:{const[l,c,u,d,h,m]=a;if(e.strokeStyle==="dotted"){const g=aI(e.strokeWidth-1);o.strokeLineDash=[g[0],g[1]-1]}else delete o.strokeLineDash;return o.roughness=Math.min(1,o.roughness||0),[i.line(u,d,l,c,o),i.line(h,m,l,c,o)]}}},QD=(e,t,{isExporting:n,canvasBackgroundColor:r,embedsValidationStatus:i})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let o;if(e.roundness){const s=e.width,a=e.height,l=oa(Math.min(s,a),e);o=t.path(`M ${l} 0 L ${s-l} 0 Q ${s} 0, ${s} ${l} L ${s} ${a-l} Q ${s} ${a}, ${s-l} ${a} L ${l} ${a} Q 0 ${a}, 0 ${a-l} L 0 ${l} Q 0 0, ${l} 0`,ur(Lb(e,n,i),!0))}else o=t.rectangle(0,0,e.width,e.height,ur(Lb(e,n,i),!1));return o}case"diamond":{let o;const[s,a,l,c,u,d,h,m]=aN(e);if(e.roundness){const g=oa(Math.abs(s-h),e),p=oa(Math.abs(c-a),e);o=t.path(`M ${s+g} ${a+p} L ${l-g} ${c-p}
C ${l} ${c}, ${l} ${c}, ${l-g} ${c+p}
L ${u+g} ${d-p}
C ${u} ${d}, ${u} ${d}, ${u-g} ${d-p}
L ${h+g} ${m+p}
C ${h} ${m}, ${h} ${m}, ${h+g} ${m-p}
L ${s-g} ${a+p}
C ${s} ${a}, ${s} ${a}, ${s+g} ${a+p}`,ur(e,!0))}else o=t.polygon([[s,a],[l,c],[u,d],[h,m]],ur(e));return o}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,ur(e));case"line":case"arrow":{let o;const s=ur(e),a=e.points.length?e.points:[[0,0]];if(e.roundness?o=[t.curve(a,s)]:s.fill?o=[t.polygon(a,s)]:o=[t.linearPath(a,s)],e.type==="arrow"){const{startArrowhead:l=null,endArrowhead:c="arrow"}=e;if(l!==null){const u=Pb(e,o,"start",l,t,s,r);o.push(...u)}if(c!==null){const u=Pb(e,o,"end",c,t,s,r);o.push(...u)}}return o}case"freedraw":{let o;if(Rz(e),cs(e.points)){const s=jD(e.points,.75);o=t.curve(s,{...ur(e),stroke:"none"})}else o=null;return o}case"frame":case"magicframe":case"text":case"image":return null;default:return jl(e,`generateElementShape(): Unimplemented type ${e==null?void 0:e.type}`),null}},_n=(e,t)=>[0,0,0,0,t,e,1,0],lI=(e,t)=>[0,0,0,0,t,e,0,0],Ra=(e=0,t=0)=>{const n=[0,0,0,0,0,0,0,0];if(t<0||t>7)throw new Error(`Expected \`index\` between 0 and 7, got \`${t}\``);return e!==0&&(n[t]=e),n},z1=e=>[e[0],e[1],e[2],e[3],-e[4],-e[5],-e[6],-e[7]],JD=(e,t)=>Qv(t)?[e[0]+t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]+t[0],e[1]+t[1],e[2]+t[2],e[3]+t[3],e[4]+t[4],e[5]+t[5],e[6]+t[6],e[7]+t[7]],Pm=(e,t)=>Qv(t)?[e[0]-t,e[1],e[2],e[3],e[4],e[5],e[6],e[7]]:[e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3],e[4]-t[4],e[5]-t[5],e[6]-t[6],e[7]-t[7]],Zl=(e,t)=>Qv(t)?[e[0]*t,e[1]*t,e[2]*t,e[3]*t,e[4]*t,e[5]*t,e[6]*t,e[7]*t]:[eO(e,t),t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[7]*e[3]+t[0]*e[4]+t[6]*e[5]-t[5]*e[6]+t[3]*e[7],t[5]*e[0]-t[3]*e[1]+t[7]*e[2]+t[1]*e[3]-t[6]*e[4]+t[0]*e[5]+t[4]*e[6]+t[2]*e[7],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]+t[0]*e[7]],eO=(e,t)=>t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],tO=(e,t)=>[t[0]*e[0],t[1]*e[0]+t[0]*e[1],t[2]*e[0]+t[0]*e[2],t[3]*e[0]+t[0]*e[3],t[4]*e[0]+t[2]*e[1]-t[1]*e[2]+t[0]*e[4],t[5]*e[0]-t[3]*e[1]+t[1]*e[3]+t[0]*e[5],t[6]*e[0]+t[3]*e[2]-t[2]*e[3]+t[0]*e[6],t[7]*e[0]+t[6]*e[1]+t[5]*e[2]+t[4]*e[3]+t[3]*e[4]+t[2]*e[5]+t[1]*e[6]],cI=(e,t)=>[uI(e,t),e[1]*t[7]+e[4]*t[5]-e[5]*t[4]+e[7]*t[1],e[2]*t[7]-e[4]*t[6]+e[6]*t[4]+e[7]*t[2],e[3]*t[7]+e[5]*t[6]-e[6]*t[5]+e[7]*t[3],e[4]*t[7]+e[7]*t[4],e[5]*t[7]+e[7]*t[5],e[6]*t[7]+e[7]*t[6],e[7]*t[7]],uI=(e,t)=>e[0]*t[7]+e[1]*t[6]+e[2]*t[5]+e[3]*t[4]+e[4]*t[3]+e[5]*t[2]+e[6]*t[1]+e[7]*t[0],nO=(e,t)=>[t[0]*e[0]+t[2]*e[2]+t[3]*e[3]-t[6]*e[6],t[1]*e[0]+t[0]*e[1]-t[4]*e[2]+t[5]*e[3]+t[2]*e[4]-t[3]*e[5]-t[7]*e[6]-t[6]*e[7],t[2]*e[0]+t[0]*e[2]-t[6]*e[3]+t[3]*e[6],t[3]*e[0]+t[6]*e[2]+t[0]*e[3]-t[2]*e[6],t[4]*e[0]+t[7]*e[3]+t[0]*e[4]+t[3]*e[7],t[5]*e[0]+t[7]*e[2]+t[0]*e[5]+t[2]*e[7],t[6]*e[0]+t[0]*e[6],t[7]*e[0]+t[0]*e[7]],dI=e=>Math.sqrt(Math.abs(e[0]*e[0]-e[2]*e[2]-e[3]*e[3]+e[6]*e[6])),rO=e=>Math.sqrt(Math.abs(e[7]*e[7]-e[5]*e[5]-e[4]*e[4]+e[1]*e[1])),H1=e=>{const t=dI(e);if(t===0||t===1)return e;const n=e[6]<0?-1:1;return Zl(e,n/t)},iO=e=>{const t=rO(e);return t===0||t===1?e:Zl(e,1/t)},Qv=e=>typeof e=="number";Ra(1,1);Ra(1,2);Ra(1,3);Ra(1,4);Ra(1,5);Ra(1,6);Ra(1,7);const ga=(e,t,n)=>H1([0,n,e,t,0,0,0,0]),qd=(e,t)=>H1(cI(t,e)),oO=(e,t)=>nO(e,t),sO=(e,t)=>oO(qd(e,t),t),aO=e=>Math.sign(e[1]),pa=([e,t])=>[0,0,0,0,t,e,1,0],ya=e=>[e[5],e[4]],hI=e=>[0,0,0,0,Math.abs(e[4]),Math.abs(e[5]),1,0],lO=(e,t)=>H1(tO(e,t)),Rb=(e,t)=>dI(cI(e,t)),Qr=(e,t)=>uI(e,t),Jv=e=>[0,0,0,0,e[4],e[5],0,0],cO=(e,t)=>iO([0,0,0,0,t[4]-e[4],t[5]-e[5],0,0]),eE=(e,t)=>JD(Zl(e,Math.sin(t/2)),Math.cos(t/2)),uO=e=>[1,0,0,0,-(.5*e[5]),.5*e[4],0,0],dO=(e,t)=>{const n=.5*t;return[1,0,0,0,n*e[4],n*e[5],0,0]},hO=(e,t)=>Zl(t,e),Gr=(e,t)=>H1(Zl(Zl(e,t),z1(e))),Db={mouse:8,pen:16,touch:28},fO=16,fI={e:!0,s:!0,n:!0,w:!0},mO={e:!0,s:!0,n:!0,w:!0,rotation:!0},gO={e:!0,s:!0,n:!0,w:!0},Ob={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},gp={e:!0,s:!0,n:!0,w:!0},Li=(e,t,n,r,i,o,s)=>{const[a,l]=_e(e+n/2,t+r/2,i,o,s);return[a-n/2,l-r/2,n,r]},tE=([e,t,n,r,i,o],s,a,l,c={},u=4)=>{const d=Db[l],h=d/a.value,m=d/a.value,g=d/a.value,p=d/a.value,v=n-e,y=r-t,E=u/a.value,w=(d-ud*2)/(2*a.value),x={nw:c.nw?void 0:Li(e-E-g+w,t-E-p+w,h,m,i,o,s),ne:c.ne?void 0:Li(n+E-w,t-E-p+w,h,m,i,o,s),sw:c.sw?void 0:Li(e-E-g+w,r+E-w,h,m,i,o,s),se:c.se?void 0:Li(n+E-w,r+E-w,h,m,i,o,s),rotation:c.rotation?void 0:Li(e+v/2-h/2,t-E-p+w-fO/a.value,h,m,i,o,s)},C=5*Db.mouse/a.value;return Math.abs(v)>C&&(c.n||(x.n=Li(e+v/2-h/2,t-E-p+w,h,m,i,o,s)),c.s||(x.s=Li(e+v/2-h/2,r+E-w,h,m,i,o,s))),Math.abs(y)>C&&(c.w||(x.w=Li(e-E-g+w,t+y/2-m/2,h,m,i,o,s)),c.e||(x.e=Li(n+E-w,t+y/2-m/2,h,m,i,o,s))),x},mI=(e,t,n,r="mouse")=>{if(e.locked)return{};let i={};if(e.type==="freedraw"||we(e)){if(e.points.length===2){const[,s]=e.points;s[0]===0||s[1]===0?i=gp:s[0]>0&&s[1]<0?i=Ob:s[0]>0&&s[1]>0?i=gp:s[0]<0&&s[1]>0?i=Ob:s[0]<0&&s[1]<0&&(i=gp)}}else ce(e)?i=gO:pe(e)&&(i={rotation:!0});const o=we(e)?ud+8:ud;return tE(Ee(e,n,!0),e.angle,t,r,i,o)},nE=(e,t)=>{if(t.editingLinearElement)return!1;if(e.length>1)return!0;const n=e[0];return we(n)?n.points.length>2:!0},pO=e=>{if(e.type==="arrow")return!1;if(e.type==="freedraw")return!0;const t=!Ei(e.backgroundColor)||ls(e)||fr(e);return e.type==="line"?t&&cs(e.points):t||Gi(e)},Rm=(e,t,n,r,i,o)=>{const s=10/t.zoom.value,a=[r,i];if(yO(t,e)&&nE([e],t))return U1(e,o,a,s,n);const l=ke(e,o);return l&&Rm(l,t,n,r,i,o)?!0:vd(e,t,n,a,o)},pp=(e,t,n,r,i,o)=>{const s=10/t.zoom.value,a=ke(e,o);return a&&Rm(a,t,n,r,i,o)?!1:!vd(e,t,n,[r,i],o)&&U1(e,o,[r,i],s,n)},vd=(e,t,n,r,i)=>{const o=10/t.zoom.value,s=ce(e)?vO:pO(e)?Tu:EO;return rE({element:e,elementsMap:i,point:r,threshold:o,check:s,frameNameBoundsCache:n})},yO=(e,t)=>e.selectedElementIds[t.id],U1=(e,t,[n,r],i,o)=>{if(pe(e))return rE({element:e,elementsMap:t,point:[n,r],threshold:i,check:Tu,frameNameBoundsCache:o});const[s,a,l,c]=Ee(e,t),u=(s+l)/2,d=(a+c)/2,[h,m]=_e(n,r,u,d,-e.angle);return h>s-i&&h<l+i&&m>a-i&&m<c+i},gI=(e,{x:t,y:n},r)=>{const i=W1(e,e.width,e.height);return rE({element:e,elementsMap:r,point:[t,n],threshold:i,check:wO,frameNameBoundsCache:null})},W1=(e,t,n)=>{const i=(e.type==="diamond"?1/Math.sqrt(2):1)*Math.min(t,n);return Math.max(16,Math.min(.25*i,32))},rE=e=>{var t;switch(e.element.type){case"rectangle":case"iframe":case"embeddable":case"image":case"text":case"diamond":case"ellipse":const n=L2(e.element,e.point,e.elementsMap);return e.check(n,e.threshold);case"freedraw":return e.check(pI(e.element,e.point,e.elementsMap),e.threshold)?kO(e.element,e.point,e.threshold,e.elementsMap):!1;case"arrow":case"line":return IO(e);case"selection":return console.warn("This should not happen, we need to investigate why it does."),!1;case"frame":case"magicframe":{if(e.check(L2(e.element,e.point,e.elementsMap),e.threshold))return!0;const r=(t=e.frameNameBoundsCache)==null?void 0:t.get(e.element);return r?e.check(bO(r,e.point),e.threshold):!1}}},L2=(e,t,n)=>{switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return pI(e,t,n);case"diamond":return _O(e,t,n);case"ellipse":return xO(e,t,n)}},vO=(e,t)=>e<0,Tu=(e,t)=>e<t,EO=(e,t)=>Math.abs(e)<t,wO=(e,t)=>0<=e&&e<t,pI=(e,t,n)=>{const[,r,i,o]=V1(e,t,n);return Math.max(Qr(r,ga(0,1,-o)),Qr(r,ga(1,0,-i)))},bO=(e,t)=>{const[,n,r,i]=CO(t,e);return Math.max(Qr(n,ga(0,1,-i)),Qr(n,ga(1,0,-r)))},_O=(e,t,n)=>{const[,r,i,o]=V1(e,t,n),s=ga(o,i,-o*i);return Qr(r,s)},xO=(e,t,n)=>{const[r,i]=SO(e,t,n);return-aO(i)*Qr(r,i)},SO=(e,t,n)=>{const[,r,i,o]=V1(e,t,n),[s,a]=ya(r);let l=.707,c=.707;const u=i,d=o;[0,1,2,3].forEach(g=>{const p=u*l,v=d*c,y=(u*u-d*d)*l**3/u,E=(d*d-u*u)*c**3/d,w=p-y,x=v-E,C=s-y,S=a-E,I=Math.hypot(x,w),T=Math.hypot(S,C);l=Math.min(1,Math.max(0,(C*I/T+y)/u)),c=Math.min(1,Math.max(0,(S*I/T+E)/d));const L=Math.hypot(c,l);l/=L,c/=L});const h=_n(u*l,d*c),m=sO(r,h);return[r,m]},kO=(e,t,n,r)=>{let i,o;if(e.angle===0)i=t[0]-e.x,o=t[1]-e.y;else{const[u,d,h,m]=Ee(e,r),g=st(t,[u+(h-u)/2,d+(m-d)/2],-e.angle);i=g[0]-e.x,o=g[1]-e.y}let[s,a]=e.points,l;if(kt(s[0],s[1],i,o)<n||kt(a[0],a[1],i,o)<n)return!0;for(let u=0;u<e.points.length;u++){const d=[a[0]-s[0],a[1]-s[1]],h=Math.hypot(d[1],d[0]),m=[d[0]/h,d[1]/h],g=[i-s[0],o-s[1]],p=(g[0]*m[0]+g[1]*m[1])/Math.hypot(m[1],m[0]);l=[s[0]+m[0]*p,s[1]+m[1]*p];const v=kt(l[0],l[1],s[0],s[1]),y=kt(l[0],l[1],a[0],a[1]);if(l=y<v&&v>h?a:v<y&&y>h?s:l,Math.hypot(o-l[1],i-l[0])<n)return!0;s=a,a=e.points[u+1]}const c=Xe.get(e);return c&&c.sets.length?e.fillStyle==="solid"?oE(c,i,o,"round"):vI(c,i,o,n):!1},IO=e=>{const{element:t,threshold:n}=e;if(!Xe.get(t))return!1;const[r,i,o,s]=V1(e.element,e.point,e.elementsMap),a=ga(0,1,-s),l=ga(1,0,-o);if(!Tu(Qr(i,a),n)||!Tu(Qr(i,l),n))return!1;const[c,u]=ya(r),d=Xe.get(t);return d?e.check===Tu&&d.some(m=>oE(m,c,u,t.roundness?"round":"sharp"))?!0:d.some(h=>vI(h,c,u,n)):!1},V1=(e,t,n)=>{const r=pa(t),[i,o,s,a]=Ee(e,n),l=G1(i,o,s,a),c=eE(l,e.angle),u=Gr(c,r),d=Pm(u,Jv(l)),h=hI(d),m=lI(e.x,e.y),g=Pm(u,m),p=(s-i)/2,v=(a-o)/2;return[g,h,p,v]},CO=(e,t)=>{const n=pa(e),[r,i,o,s]=sN(t),a=G1(r,i,o,s),l=eE(a,t.angle),c=Gr(l,n),u=Pm(c,Jv(a)),d=hI(u),h=lI(t.x,t.y),m=Pm(c,h),g=(o-r)/2,p=(s-i)/2;return[m,d,g,p]},iE=(e,t)=>{const[n,r,i,o]=Ee(e,t),s=G1(n,r,i,o),a=eE(s,e.angle),l=z1(uO(Jv(s)));return hO(a,l)},G1=(e,t,n,r)=>_n((e+n)/2,(t+r)/2),TO=(e,t,n,r)=>{const i=iE(e,r),o=Gr(i,pa(t)),s=Gr(i,pa(n)),a=qd(o,s),l=e.height/e.width,c=e.width/2,u=e.height/2,d=a[2],h=a[3],m=a[1],g=Math.abs(h),p=Math.abs(d);let v;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":v=m/(c*(p+l*g));break;case"diamond":v=g<p?m/(p*c):m/(g*u);break;case"ellipse":v=m/(c*Math.sqrt(d**2+l**2*h**2));break}return v||0},MO=(e,t,n,r)=>{if(t===0){const[l,c,u,d]=Ee(e,r),h=G1(l,c,u,d);return ya(h)}const i=iE(e,r),o=Gr(i,pa(n)),s=z1(i);let a;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":a=FO(e,t,o);break;case"ellipse":a=NO(e,t,o);break}return ya(Gr(s,a))},AO=(e,t,n,r=0,i)=>{const o=iE(e,i),s=Gr(o,pa(t)),a=Gr(o,pa(n)),l=qd(s,a),c=z1(o);return LO(e,l,s,r).map(d=>ya(Gr(c,d)))},LO=(e,t,n,r=0)=>{let i;switch(e.type){case"rectangle":case"image":case"text":case"diamond":case"iframe":case"embeddable":case"frame":case"magicframe":const s=yI(e);i=s.flatMap((a,l)=>{const c=[a,s[(l+1)%4]];return PO(t,RO(c,r))}).concat(s.flatMap(a=>OO(a,r,t)));break;case"ellipse":i=DO(e,r,t);break}if(i.length<2)return[];const o=i.sort((s,a)=>Rb(s,n)-Rb(a,n));return[o[0],o[o.length-1]]},yI=(e,t=1)=>{const n=t*e.width/2,r=t*e.height/2;switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return[_n(n,r),_n(n,-r),_n(-n,-r),_n(-n,r)];case"diamond":return[_n(0,r),_n(n,0),_n(0,-r),_n(-n,0)]}},PO=(e,t)=>{const[n,r]=t,i=Qr(n,e),o=Qr(r,e);return i*o>=0?[]:[lO(e,qd(n,r))]},RO=(e,t)=>{const[n,r]=e,i=dO(cO(n,r),t);return[Gr(i,n),Gr(i,r)]},DO=(e,t,n)=>{const r=e.width/2+t,i=e.height/2+t,o=n[2],s=n[3],a=n[1],l=r*r*o*o+i*i*s*s,c=l-a*a;if(l===0||c<=0)return[];const u=Math.sqrt(c),d=-r*r*o*a,h=-i*i*s*a;return[_n((d+r*i*s*u)/l,(h-r*i*o*u)/l),_n((d-r*i*s*u)/l,(h+r*i*o*u)/l)]},OO=(e,t,n)=>{if(t===0)return Qr(n,e)===0?[e]:[];const r=n[2],i=n[3],o=n[1],[s,a]=ya(e),l=t,c=r*r+i*i,u=l*l*c-(r*s+i*a+o)**2;if(c===0||u<=0)return[];const d=Math.sqrt(u),h=s*i*i-a*r*i-r*o,m=a*r*r-s*r*i-i*o;return[_n((h+i*d)/c,(m-r*d)/c),_n((h-i*d)/c,(m+r*d)/c)]},NO=(e,t,n)=>{const r=Math.abs(t),i=e.width*r/2,o=e.height*r/2,s=Math.sign(t),[a,l]=ya(n),c=l===0?1e-4:l,u=a**2*o**2+c**2*i**2,d=(-a*o**2+s*c*Math.sqrt(Math.max(0,u-i**2*o**2)))/u;let h=(-d*a-1)/c;h===0&&(h=(Object.is(h,-0)?-1:1)*.01);const m=-(i**2*d)/(h**2*o**2+d**2*i**2);return _n(m,(-d*m-1)/h)},FO=(e,t,n)=>{const r=Math.abs(t),i=Math.sign(t),o=yI(e,r);let s=0,a=null;return o.forEach(l=>{const c=i*qd(n,l)[1];c>s&&(s=c,a=l)}),a},$O=(e,t,n,r,[i,o],s)=>{const a=(c,u)=>Math.pow(1-c,3)*r[u]+3*c*Math.pow(1-c,2)*n[u]+3*Math.pow(c,2)*(1-c)*t[u]+e[u]*Math.pow(c,3);let l=0;for(;l<=1;){const c=a(l,0),u=a(l,1);if(Math.sqrt(Math.pow(c-i,2)+Math.pow(u-o,2))<s)return!0;l+=.01}return!1},oE=(e,t,n,r)=>{const i=_s(e),o=[];let s=!1;for(const a of i)a.op==="move"?(s=!s,s&&o.push([a.data[0],a.data[1]])):a.op==="bcurveTo"?s&&(o.push([a.data[0],a.data[1]]),o.push([a.data[2],a.data[3]]),o.push([a.data[4],a.data[5]])):a.op==="lineTo"&&s&&o.push([a.data[0],a.data[1]]);if(o.length>=4){if(r==="sharp")return Tb(o,t,n);const a=YD(o,10,5);return Tb(a,t,n)}return!1},vI=(e,t,n,r)=>{const i=_s(e);let o=[0,0];return i.some(({op:s,data:a},l)=>{if(s==="move")o=a;else if(s==="bcurveTo"){const c=[a[0],a[1]],u=[a[2],a[3]],d=[a[4],a[5]],h=o;return o=d,$O(h,c,u,d,[t,n],r)}else{if(s==="lineTo")return oE(e,t,n,"sharp");s==="qcurveTo"&&console.warn("qcurveTo is not implemented yet")}return!1})},De={EQUAL:"Equal",MINUS:"Minus",NUM_ADD:"NumpadAdd",NUM_SUBTRACT:"NumpadSubtract",NUM_ZERO:"Numpad0",BRACKET_RIGHT:"BracketRight",BRACKET_LEFT:"BracketLeft",ONE:"Digit1",TWO:"Digit2",THREE:"Digit3",NINE:"Digit9",QUOTE:"Quote",ZERO:"Digit0",SLASH:"Slash",C:"KeyC",D:"KeyD",H:"KeyH",V:"KeyV",Z:"KeyZ",R:"KeyR",S:"KeyS"},D={ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown",BACKSPACE:"Backspace",ALT:"Alt",CTRL_OR_CMD:ki?"metaKey":"ctrlKey",DELETE:"Delete",ENTER:"Enter",ESCAPE:"Escape",QUESTION_MARK:"?",SPACE:" ",TAB:"Tab",CHEVRON_LEFT:"<",CHEVRON_RIGHT:">",PERIOD:".",COMMA:",",SUBTRACT:"-",A:"a",C:"c",D:"d",E:"e",F:"f",G:"g",H:"h",I:"i",L:"l",O:"o",P:"p",Q:"q",R:"r",S:"s",T:"t",V:"v",X:"x",Y:"y",Z:"z",K:"k",W:"w",0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9"},Pf=e=>e===D.ARROW_LEFT||e===D.ARROW_RIGHT||e===D.ARROW_DOWN||e===D.ARROW_UP,yp=e=>e.altKey,Bc=e=>e.shiftKey,Mu=e=>e.shiftKey,BO=e=>!e[D.CTRL_OR_CMD],Gs=e=>e.isBindingEnabled,EI=(e,t)=>{const n=[];return t.forEach(r=>{const i=e.getNonDeletedElement(r);i!=null&&n.push(i)}),n},dc=(e,t,n,r)=>{const i=new Set,o=new Set;Nb(e,t,n,"start",i,o,r),Nb(e,n,t,"end",i,o,r);const s=Array.from(o).filter(a=>!i.has(a));EI($t.getScene(e),s).forEach(a=>{var l;J(a,{boundElements:(l=a.boundElements)==null?void 0:l.filter(c=>c.type!=="arrow"||c.id!==e.id)})})},Nb=(e,t,n,r,i,o,s)=>{if(t!=="keep")if(t!=null)(n==null||(n==="keep"?!sE(e,t,r):r==="start"||n.id!==t.id))&&(Ed(e,t,r,s),i.add(t.id));else{const a=HO(e,r);a!=null&&o.add(a)}},P2=(e,t,n)=>{e.forEach(r=>{dn(r)?dc(r,Dm(r,"start",t,n),Dm(r,"end",t,n),n):yd(r)&&zO(r,n)})},zO=(e,t)=>{_I(e,t).forEach(([n,r])=>dc(n,r==="end"?"keep":e,r==="start"?"keep":e,t))},R2=(e,t,n,r,i)=>{t.startBoundElement!=null&&Ed(e,t.startBoundElement,"start",i);const o=No(r,n.getNonDeletedElements(),i);o!=null&&!sE(e,o,"end")&&Ed(e,o,"end",i)},Ed=(e,t,n,r)=>{J(e,{[n==="start"?"startBinding":"endBinding"]:{elementId:t.id,...UO(e,t,n,r)}}),be(t.boundElements||[]).has(e.id)||J(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},sE=(e,t,n)=>{const r=e[n==="start"?"endBinding":"startBinding"];return wI(e,r==null?void 0:r.elementId,t)},wI=(e,t,n)=>t===n.id&&e.points.length<3,D2=(e,t)=>{e.forEach(n=>{dn(n)&&dc(n,null,null,t)})},HO=(e,t)=>{const n=t==="start"?"startBinding":"endBinding",r=e[n];return r==null?null:(J(e,{[n]:null}),r.elementId)},No=(e,t,n)=>KD(t,i=>yd(i,!1)&&gI(i,e,n)),UO=(e,t,n,r)=>{const i=n==="start"?-1:1,o=i===-1?0:e.points.length-1,s=o-i,a=ue.getPointAtIndexGlobalCoordinates(e,o,r),l=ue.getPointAtIndexGlobalCoordinates(e,s,r);return{focus:TO(t,l,a,r),gap:Math.max(1,L2(t,a,r))}},us=(e,t,n)=>{const r=(e.boundElements??[]).filter(l=>l.type==="arrow");if(r.length===0)return;const{newSize:i,simultaneouslyUpdated:o}=n??{},s=VO(o),a=$t.getScene(e);EI(a,r.map(l=>l.id)).forEach(l=>{if(!we(l))return;const c=e;if(!WO(l,c))return;const u=$b(c,l.startBinding,i),d=$b(c,l.endBinding,i);if(s.has(l.id)){J(l,{startBinding:u,endBinding:d});return}Fb(l,"start",u,e,t),Fb(l,"end",d,e,t),ke(l,a.getNonDeletedElementsMap())&&j1(l,a.getNonDeletedElementsMap(),!1)})},WO=(e,t)=>{var n,r;return((n=e.startBinding)==null?void 0:n.elementId)===t.id||((r=e.endBinding)==null?void 0:r.elementId)===t.id},VO=e=>new Set((e||[]).map(t=>t.id)),Fb=(e,t,n,r,i)=>{if(n==null||n.elementId!==r.id&&e.points.length>2)return;const o=$t.getScene(e).getElement(n.elementId);if(o==null)return;const s=t==="start"?-1:1,a=s===-1?0:e.points.length-1,l=a-s,c=ue.getPointAtIndexGlobalCoordinates(e,l,i),u=MO(o,n.focus,c,i);let d;if(n.gap===0)d=u;else{const h=AO(o,c,u,n.gap,i);h.length===0?d=u:d=h[0]}ue.movePoints(e,[{index:a,point:ue.pointFromAbsoluteCoords(e,d,i)}],{[t==="start"?"startBinding":"endBinding"]:n})},$b=(e,t,n)=>{if(t==null||n==null)return t;const{gap:r,focus:i,elementId:o}=t,{width:s,height:a}=n,{width:l,height:c}=e,u=Math.max(1,Math.min(W1(e,s,a),r*(s<a?s/l:a/c)));return{elementId:o,gap:u,focus:i}},GO=(e,t,n)=>{const r=new Set(e.map(({id:i})=>i));return e.flatMap(i=>dn(i,!1)?jO(i,t,n).filter(o=>!r.has(o.id)):yd(i,!1)?_I(i,n).filter(o=>!r.has(o[0].id)):[])},jO=(e,t,n)=>[Dm(e,"start",t,n),Dm(e,"end",t,n)].filter(r=>r!=null),Dm=(e,t,n,r)=>No(bI(e,t,r),n,r),bI=(e,t,n)=>{const r=t==="start"?0:-1;return Oo(ue.getPointAtIndexGlobalCoordinates(e,r,n))},_I=(e,t)=>$t.getScene(e).getNonDeletedElements().map(r=>{if(!dn(r,!1))return null;const i=Bb(r,"start",e,t),o=Bb(r,"end",e,t);return!i&&!o?null:[r,i&&o?"both":i?"start":"end",e]}).filter(r=>r!=null),Bb=(e,t,n,r)=>e[t==="start"?"startBinding":"endBinding"]==null&&!sE(e,n,t)&&gI(n,bI(e,t,r),r),xI=(e,t,n,r)=>{const i=new Set,o=new Set,s=r==="duplicatesServeAsOld";t.forEach(a=>{const{boundElements:l}=a;if(l!=null&&l.length>0&&(l.forEach(c=>{s&&!n.has(c.id)&&i.add(c.id)}),o.add(n.get(a.id))),dn(a)){if(a.startBinding!=null){const{elementId:c}=a.startBinding;s&&!n.has(c)&&o.add(c)}if(a.endBinding!=null){const{elementId:c}=a.endBinding;s&&!n.has(c)&&o.add(c)}(a.startBinding!=null||a.endBinding!=null)&&i.add(n.get(a.id))}}),e.filter(({id:a})=>i.has(a)).forEach(a=>{const{startBinding:l,endBinding:c}=a;J(a,{startBinding:zb(l,n),endBinding:zb(c,n)})}),e.filter(({id:a})=>o.has(a)).forEach(a=>{const{boundElements:l}=a;l!=null&&l.length>0&&J(a,{boundElements:l.map(c=>n.has(c.id)?{id:n.get(c.id),type:c.type}:c)})})},zb=(e,t)=>{if(e==null)return null;const{elementId:n,focus:r,gap:i}=e;return{focus:r,gap:i,elementId:t.get(n)??n}},aE=(e,t)=>{const n=new Set(t.map(i=>i.id)),r=new Set;t.forEach(i=>{var o;yd(i)?(o=i.boundElements)==null||o.forEach(s=>{n.has(s.id)||r.add(s.id)}):dn(i)&&(i.startBinding&&r.add(i.startBinding.elementId),i.endBinding&&r.add(i.endBinding.elementId))}),e.filter(({id:i})=>r.has(i)).forEach(i=>{yd(i)?J(i,{boundElements:YO(i.boundElements,n)}):dn(i)&&J(i,{startBinding:Hb(i.startBinding,n),endBinding:Hb(i.endBinding,n)})})},Hb=(e,t)=>e==null||t.has(e.elementId)?null:e,YO=(e,t)=>e?e.filter(n=>!t.has(n.id)):null,Pi={version:null,points:[],zoom:null},le=class le{constructor(t){M(this,"elementId");M(this,"selectedPointsIndices");M(this,"pointerDownState");M(this,"isDragging");M(this,"lastUncommittedPoint");M(this,"pointerOffset");M(this,"startBindingElement");M(this,"endBindingElement");M(this,"hoverPointIndex");M(this,"segmentMidPointHoveredCoords");this.elementId=t.id,le.normalizePoints(t),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.startBindingElement="keep",this.endBindingElement="keep",this.pointerDownState={prevSelectedPointsIndices:null,lastClickedPoint:-1,origin:null,segmentMidpoint:{value:null,index:null,added:!1}},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null}static getElement(t,n){const r=n.get(t);return r||null}static handleBoxSelection(t,n,r,i){var p;if(!n.editingLinearElement||((p=n.draggingElement)==null?void 0:p.type)!=="selection")return!1;const{editingLinearElement:o}=n,{selectedPointsIndices:s,elementId:a}=o,l=le.getElement(a,i);if(!l)return!1;const[c,u,d,h]=Ee(n.draggingElement,i),g=le.getPointsGlobalCoordinates(l,i).reduce((v,y,E)=>((y[0]>=c&&y[0]<=d&&y[1]>=u&&y[1]<=h||t.shiftKey&&(s!=null&&s.includes(E)))&&v.push(E),v),[]);r({editingLinearElement:{...o,selectedPointsIndices:g.length?g:null}})}static handlePointDragging(t,n,r,i,o,s,a){if(!s)return!1;const{selectedPointsIndices:l,elementId:c}=s,u=le.getElement(c,a);if(!u)return!1;const d=u.points[s.pointerDownState.lastClickedPoint];if(l&&d){if(Mu(t)&&l.length===1&&u.points.length>1){const m=l[0],g=u.points[m===0?1:m-1],[p,v]=le._getShiftLockedDelta(u,a,g,[r,i],t[D.CTRL_OR_CMD]?null:n.gridSize);le.movePoints(u,[{index:m,point:[p+g[0],v+g[1]],isDragging:m===s.pointerDownState.lastClickedPoint}])}else{const m=le.createPointAt(u,a,r-s.pointerOffset.x,i-s.pointerOffset.y,t[D.CTRL_OR_CMD]?null:n.gridSize),g=m[0]-d[0],p=m[1]-d[1];le.movePoints(u,l.map(v=>{const y=v===s.pointerDownState.lastClickedPoint?le.createPointAt(u,a,r-s.pointerOffset.x,i-s.pointerOffset.y,t[D.CTRL_OR_CMD]?null:n.gridSize):[u.points[v][0]+g,u.points[v][1]+p];return{index:v,point:y,isDragging:v===s.pointerDownState.lastClickedPoint}}))}if(ke(u,a)&&j1(u,a,!1),dn(u,!1)){const m=[];l[0]===0&&m.push(Oo(le.getPointGlobalCoordinates(u,u.points[0],a)));const p=l[l.length-1];p===u.points.length-1&&m.push(Oo(le.getPointGlobalCoordinates(u,u.points[p],a))),m.length&&o(u,m)}return!0}return!1}static handlePointerUp(t,n,r,i,o){var h;const{elementId:s,selectedPointsIndices:a,isDragging:l,pointerDownState:c}=n,u=le.getElement(s,o);if(!u)return n;const d={};if(l&&a){for(const m of a)if(m===0||m===u.points.length-1){cs(u.points,r.zoom.value)&&le.movePoints(u,[{index:m,point:m===0?u.points[u.points.length-1]:u.points[0]}]);const g=Gs(r)?No(Oo(le.getPointAtIndexGlobalCoordinates(u,m,o)),i,o):null;d[m===0?"startBindingElement":"endBindingElement"]=g}}return{...n,...d,selectedPointsIndices:l||t.shiftKey?!l&&t.shiftKey&&((h=c.prevSelectedPointsIndices)!=null&&h.includes(c.lastClickedPoint))?a&&a.filter(m=>m!==c.lastClickedPoint):a:a!=null&&a.includes(c.lastClickedPoint)?[c.lastClickedPoint]:a,isDragging:!1,pointerOffset:{x:0,y:0}}}static isSegmentTooShort(t,n,r,i){let o=kt(n[0],n[1],r[0],r[1]);return t.points.length>2&&t.roundness&&(o=zD(t,r)),o*i.value<le.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,n,r,i,o){let s=C2(n,r);if(t.points.length>2&&t.roundness){const a=rI(t,t.points[i]);if(a){const l=HD(t,t.points[i],.5),[c,u]=iI(a[0],a[1],a[2],a[3],l);s=le.getPointGlobalCoordinates(t,[c,u],o)}}return s}static getSegmentMidPointIndex(t,n,r,i){const o=le.getElement(t.elementId,i);if(!o)return-1;const s=le.getEditorMidPoints(o,i,n);let a=0;for(;a<s.length;){if(le.arePointsEqual(r,s[a]))return a+1;a++}return-1}static handlePointerDown(t,n,r,i,o,s,a){var S;const l={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!o)return l;const{elementId:c}=o,u=le.getElement(c,a);if(!u)return l;const d=le.getSegmentMidpointHitCoords(o,i,n,a);let h=null;if(d&&(h=le.getSegmentMidPointIndex(o,n,d,a)),t.altKey&&n.editingLinearElement)return o.lastUncommittedPoint==null&&(J(u,{points:[...u.points,le.createPointAt(u,a,i.x,i.y,t[D.CTRL_OR_CMD]?null:n.gridSize)]}),l.didAddPoint=!0),r.resumeRecording(),l.linearElementEditor={...o,pointerDownState:{prevSelectedPointsIndices:o.selectedPointsIndices,lastClickedPoint:-1,origin:{x:i.x,y:i.y},segmentMidpoint:{value:d,index:h,added:!1}},selectedPointsIndices:[u.points.length-1],lastUncommittedPoint:null,endBindingElement:No(i,s,a)},l.didAddPoint=!0,l;const m=le.getPointIndexUnderCursor(u,a,n.zoom,i.x,i.y);if(m>=0||d)l.hitElement=u;else{const{startBindingElement:I,endBindingElement:T}=o;Gs(n)&&dn(u)&&dc(u,I,T,a)}const[g,p,v,y]=Ee(u,a),E=(g+v)/2,w=(p+y)/2,x=m>-1&&_e(u.x+u.points[m][0],u.y+u.points[m][1],E,w,u.angle),C=m>-1||t.shiftKey?t.shiftKey||(S=o.selectedPointsIndices)!=null&&S.includes(m)?KO([...o.selectedPointsIndices||[],m]):[m]:null;return l.linearElementEditor={...o,pointerDownState:{prevSelectedPointsIndices:o.selectedPointsIndices,lastClickedPoint:m,origin:{x:i.x,y:i.y},segmentMidpoint:{value:d,index:h,added:!1}},selectedPointsIndices:C,pointerOffset:x?{x:i.x-x[0],y:i.y-x[1]}:{x:0,y:0}},l}static arePointsEqual(t,n){return!t&&!n?!0:!t||!n?!1:sI(t,n)}static handlePointerMove(t,n,r,i,o){if(!i.editingLinearElement)return null;const{elementId:s,lastUncommittedPoint:a}=i.editingLinearElement,l=le.getElement(s,o);if(!l)return i.editingLinearElement;const{points:c}=l,u=c[c.length-1];if(!t.altKey)return u===a&&le.deletePoints(l,[c.length-1]),{...i.editingLinearElement,lastUncommittedPoint:null};let d;if(Mu(t)&&c.length>=2){const h=c[c.length-2],[m,g]=le._getShiftLockedDelta(l,o,h,[n,r],t[D.CTRL_OR_CMD]?null:i.gridSize);d=[m+h[0],g+h[1]]}else d=le.createPointAt(l,o,n-i.editingLinearElement.pointerOffset.x,r-i.editingLinearElement.pointerOffset.y,t[D.CTRL_OR_CMD]?null:i.gridSize);return u===a?le.movePoints(l,[{index:l.points.length-1,point:d}]):le.addPoints(l,i,[{point:d}]),{...i.editingLinearElement,lastUncommittedPoint:l.points[l.points.length-1]}}static getPointGlobalCoordinates(t,n,r){const[i,o,s,a]=Ee(t,r),l=(i+s)/2,c=(o+a)/2;let{x:u,y:d}=t;return[u,d]=_e(u+n[0],d+n[1],l,c,t.angle),[u,d]}static getPointsGlobalCoordinates(t,n){const[r,i,o,s]=Ee(t,n),a=(r+o)/2,l=(i+s)/2;return t.points.map(c=>{let{x:u,y:d}=t;return[u,d]=_e(u+c[0],d+c[1],a,l,t.angle),[u,d]})}static getPointAtIndexGlobalCoordinates(t,n,r){const i=n<0?t.points.length+n:n,[o,s,a,l]=Ee(t,r),c=(o+a)/2,u=(s+l)/2,d=t.points[i],{x:h,y:m}=t;return d?_e(h+d[0],m+d[1],c,u,t.angle):_e(h,m,c,u,t.angle)}static pointFromAbsoluteCoords(t,n,r){const[i,o,s,a]=Ee(t,r),l=(i+s)/2,c=(o+a)/2,[u,d]=_e(n[0],n[1],l,c,-t.angle);return[u-t.x,d-t.y]}static getPointIndexUnderCursor(t,n,r,i,o){const s=le.getPointsGlobalCoordinates(t,n);let a=s.length;for(;--a>-1;){const l=s[a];if(kt(i,o,l[0],l[1])*r.value<le.POINT_HANDLE_SIZE+1)return a}return-1}static createPointAt(t,n,r,i,o){const s=jt(r,i,o),[a,l,c,u]=Ee(t,n),d=(a+c)/2,h=(l+u)/2,[m,g]=_e(s[0],s[1],d,h,-t.angle);return[m-t.x,g-t.y]}static getNormalizedPoints(t){const{points:n}=t,r=n[0][0],i=n[0][1];return{points:n.map((o,s)=>[o[0]-r,o[1]-i]),x:t.x+r,y:t.y+i}}static normalizePoints(t){J(t,le.getNormalizedPoints(t))}static duplicateSelectedPoints(t,n){if(!t.editingLinearElement)return!1;const{selectedPointsIndices:r,elementId:i}=t.editingLinearElement,o=le.getElement(i,n);if(!o||r===null)return!1;const{points:s}=o,a=[];let l=!1,c=-1;const u=s.reduce((d,h,m)=>{if(++c,d.push(h),r.includes(m)){const p=s[m+1];p||(l=!0),d.push(p?[(h[0]+p[0])/2,(h[1]+p[1])/2]:[h[0],h[1]]),a.push(c+1),++c}return d},[]);if(J(o,{points:u}),l){const d=o.points[o.points.length-1];le.movePoints(o,[{index:o.points.length-1,point:[d[0]+30,d[1]+30]}])}return{appState:{...t,editingLinearElement:{...t.editingLinearElement,selectedPointsIndices:a}}}}static deletePoints(t,n){let r=0,i=0;if(n.includes(0)){const a=t.points.find((l,c)=>!n.includes(c));a&&(r=a[0],i=a[1])}const s=t.points.reduce((a,l,c)=>(n.includes(c)||a.push(a.length?[l[0]-r,l[1]-i]:[0,0]),a),[]);le._updatePoints(t,s,r,i)}static addPoints(t,n,r){const s=[...t.points,...r.map(a=>a.point)];le._updatePoints(t,s,0,0)}static movePoints(t,n,r){const{points:i}=t;let o=0,s=0;const a=n.find(({index:c})=>c===0);a&&(o=a.point[0]+i[a.index][0],s=a.point[1]+i[a.index][1]);const l=i.map((c,u)=>{const d=n.find(h=>h.index===u);if(d){if(a)return c;const h=d.point[0]-i[d.index][0],m=d.point[1]-i[d.index][1];return[c[0]+h,c[1]+m]}return o||s?[c[0]-o,c[1]-s]:c});le._updatePoints(t,l,o,s,r)}static shouldAddMidpoint(t,n,r,i){if(!le.getElement(t.elementId,i))return!1;const{segmentMidpoint:s}=t.pointerDownState;if(s.added||s.value===null||s.index===null||t.pointerDownState.origin===null)return!1;const a=t.pointerDownState.origin,l=kt(a.x,a.y,n.x,n.y);return!(!r.editingLinearElement&&l<Ts/r.zoom.value)}static addMidpoint(t,n,r,i,o){const s=le.getElement(t.elementId,o);if(!s)return;const{segmentMidpoint:a}=t.pointerDownState,l={pointerDownState:t.pointerDownState,selectedPointsIndices:t.selectedPointsIndices},c=le.createPointAt(s,o,n.x,n.y,i?r.gridSize:null),u=[...s.points.slice(0,a.index),c,...s.points.slice(a.index)];return J(s,{points:u}),l.pointerDownState={...t.pointerDownState,segmentMidpoint:{...t.pointerDownState.segmentMidpoint,added:!0},lastClickedPoint:a.index},l.selectedPointsIndices=[a.index],l}static _updatePoints(t,n,r,i,o){const s=Nm(t,n),a=Nm(t,t.points),l=(s[0]+s[2])/2,c=(s[1]+s[3])/2,u=(a[0]+a[2])/2,d=(a[1]+a[3])/2,h=u-l,m=d-c,g=_e(r,i,h,m,t.angle);J(t,{...o,points:n,x:t.x+g[0],y:t.y+g[1]})}static _getShiftLockedDelta(t,n,r,i,o){const s=le.getPointGlobalCoordinates(t,r,n),[a,l]=jt(i[0],i[1],o),{width:c,height:u}=J2(s[0],s[1],a,l);return st([c,u],[0,0],-t.angle)}};M(le,"POINT_HANDLE_SIZE",10),M(le,"getEditorMidPoints",(t,n,r)=>{const i=ke(t,n);return!r.editingLinearElement&&t.points.length>2&&!i?[]:(Pi.version===t.version&&Pi.zoom===r.zoom.value||le.updateEditorMidPointsCache(t,n,r),Pi.points)}),M(le,"updateEditorMidPointsCache",(t,n,r)=>{const i=le.getPointsGlobalCoordinates(t,n);let o=0;const s=[];for(;o<i.length-1;){if(le.isSegmentTooShort(t,t.points[o],t.points[o+1],r.zoom)){s.push(null),o++;continue}const a=le.getSegmentMidPoint(t,i[o],i[o+1],o+1,n);s.push(a),o++}Pi.points=s,Pi.version=t.version,Pi.zoom=r.zoom.value}),M(le,"getSegmentMidpointHitCoords",(t,n,r,i)=>{const{elementId:o}=t,s=le.getElement(o,i);if(!s||le.getPointIndexUnderCursor(s,i,r.zoom,n.x,n.y)>=0||le.getPointsGlobalCoordinates(s,i).length>=3&&!r.editingLinearElement)return null;const c=le.POINT_HANDLE_SIZE/r.zoom.value,u=t.segmentMidPointHoveredCoords;if(u&&kt(u[0],u[1],n.x,n.y)<=c)return u;let d=0;const h=le.getEditorMidPoints(s,i,r);for(;d<h.length;){if(h[d]!==null&&kt(h[d][0],h[d][1],n.x,n.y)<=c)return h[d];d++}return null}),M(le,"getBoundTextElementPosition",(t,n,r)=>{const i=le.getPointsGlobalCoordinates(t,r);i.length<2&&J(n,{isDeleted:!0});let o=0,s=0;if(t.points.length%2===1){const a=Math.floor(t.points.length/2),l=le.getPointGlobalCoordinates(t,t.points[a],r);o=l[0]-n.width/2,s=l[1]-n.height/2}else{const a=t.points.length/2-1;let l=Pi.points[a];t.points.length===2&&(l=C2(i[0],i[1])),(!l||Pi.version!==t.version)&&(l=le.getSegmentMidPoint(t,i[a],i[a+1],a+1,r)),o=l[0]-n.width/2,s=l[1]-n.height/2}return{x:o,y:s}}),M(le,"getMinMaxXYWithBoundText",(t,n,r,i)=>{let[o,s,a,l]=r;const c=(o+a)/2,u=(s+l)/2,{x:d,y:h}=le.getBoundTextElementPosition(t,i,n),m=d+i.width,g=h+i.height,p=st([o,s],[c,u],t.angle),v=st([a,s],[c,u],t.angle),y=st([d,h],[c,u],-t.angle),E=st([m,h],[c,u],-t.angle),w=st([d,g],[c,u],-t.angle),x=st([m,g],[c,u],-t.angle);return p[0]<v[0]&&p[1]>=v[1]?(o=Math.min(o,w[0]),a=Math.max(a,Math.max(E[0],x[0])),s=Math.min(s,y[1]),l=Math.max(l,x[1])):p[0]>=v[0]&&p[1]>v[1]?(o=Math.min(o,x[0]),a=Math.max(a,Math.max(y[0],E[0])),s=Math.min(s,w[1]),l=Math.max(l,E[1])):p[0]>=v[0]?(o=Math.min(o,E[0]),a=Math.max(a,w[0]),s=Math.min(s,x[1]),l=Math.max(l,y[1])):p[1]<=v[1]&&(o=Math.min(o,Math.min(E[0],y[0])),a=Math.max(a,x[0]),s=Math.min(s,E[1]),l=Math.max(l,w[1])),[o,s,a,l,c,u]}),M(le,"getElementAbsoluteCoords",(t,n,r=!1)=>{let i,o,s,a,l;if(t.points.length<2||!Xe.get(t)){const{minX:h,minY:m,maxX:g,maxY:p}=t.points.reduce((v,[y,E])=>(v.minY=Math.min(v.minY,E),v.minX=Math.min(v.minX,y),v.maxX=Math.max(v.maxX,y),v.maxY=Math.max(v.maxY,E),v),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});o=h+t.x,s=m+t.y,a=g+t.x,l=p+t.y}else{const h=Xe.generateElementShape(t,null),m=_s(h[0]),[g,p,v,y]=Z1(m);o=g+t.x,s=p+t.y,a=v+t.x,l=y+t.y}const c=(o+a)/2,u=(s+l)/2;if(i=[o,s,a,l,c,u],!r)return i;const d=ke(t,n);return d&&(i=le.getMinMaxXYWithBoundText(t,n,[o,s,a,l],d)),i});let ue=le;const KO=e=>{let t=[...new Set(e.filter(n=>n!==null&&n!==-1))];return t=t.sort((n,r)=>n-r),t.length?t:null},Xl={},Om=(e,t)=>{const n=Xl[e]||(Xl[e]={height:t});return n.height=t,n},SI=e=>{Xl[e]&&delete Xl[e]},ZO=e=>{var t;return((t=Xl[e])==null?void 0:t.height)??null},wd=e=>qk(e).replace(/\t/g," "),lE=e=>wd(e).split(`
`),Mi=(e,t,n)=>{let r;const i={x:e.x,y:e.y,text:e.text,width:e.width,height:e.height};i.text=e.text,t&&(r=Ii(t,e),i.text=Jd(e.originalText,Bt(e),r));const o=ds(i.text,Bt(e),e.lineHeight);if(i.width=o.width,i.height=o.height,t){const s=eh(t,e),a=Ii(t,e);if(!Ge(t)&&o.height>s){const d=Ea(o.height,t.type);J(t,{height:d}),Om(t.id,d)}if(o.width>a){const d=Ea(o.width,t.type);J(t,{width:d})}const l={...e,...i},{x:c,y:u}=Y1(t,l,n);i.x=c,i.y=u}J(e,i)},kI=(e,t,n)=>{const r=be(e);t.forEach(i=>{const o=n.get(i.id),s=va(i);if(s){const a=n.get(s);if(a){const l=r.get(o);l&&J(l,{boundElements:(i.boundElements||[]).filter(u=>u.id!==a&&u.id!==s).concat({type:"text",id:a})});const c=r.get(a);c&&ce(c)&&J(c,{containerId:l?o:null})}}})},j1=(e,t,n,r=!1)=>{if(!va(e))return;SI(e.id);const o=ke(e,t);if(o&&o.text){if(!e)return;let s=o.text,a=o.height,l=o.width;const c=Ii(e,o),u=eh(e,o);let d=e.height;if(r||n!=="n"&&n!=="s"){s&&(s=Jd(o.originalText,Bt(o),c));const h=ds(s,Bt(o),o.lineHeight);a=h.height,l=h.width}if(a>u){d=Ea(a,e.type);const h=d-e.height,m=!Ge(e)&&(n==="ne"||n==="nw"||n==="n")?e.y-h:e.y;J(e,{height:d,y:m})}J(o,{text:s,width:l,height:a}),Ge(e)||J(o,Y1(e,o,t))}},Y1=(e,t,n)=>{if(Ge(e))return ue.getBoundTextElementPosition(e,t,n);const r=LI(e),i=eh(e,t),o=Ii(e,t);let s,a;return t.verticalAlign===Qn.TOP?a=r.y:t.verticalAlign===Qn.BOTTOM?a=r.y+(i-t.height):a=r.y+(i/2-t.height/2),t.textAlign===hd.LEFT?s=r.x:t.textAlign===hd.RIGHT?s=r.x+(o-t.width):s=r.x+(o/2-t.width/2),{x:s,y:a}},ds=(e,t,n)=>{e=e.split(`
`).map(s=>s||" ").join(`
`);const r=parseFloat(t),i=qO(e,r,n);return{width:K1(e,t),height:i}},XO=e=>{const t=lE(e.text).length;return e.height/t/e.fontSize},Qd=(e,t)=>e*t,II=(e,t,n)=>{const{unitsPerEm:r,ascender:i,descender:o}=Wb[e]||Wb[Xt.Helvetica],s=t/r,a=n-s*i+s*o;return s*i+a},CI=(e,t)=>Qd(e,t)+Nt*2;let vp;const Au=(e,t)=>{vp||(vp=document.createElement("canvas"));const n=vp.getContext("2d");return n.font=t,n.measureText(e).width},K1=(e,t)=>{const n=lE(e);let r=0;return n.forEach(i=>{r=Math.max(r,Au(i,t))}),r},qO=(e,t,n)=>{const r=lE(e).length;return Qd(t,n)*r},QO=e=>{const t=e.split("-");return t.length>1&&t.forEach((n,r)=>{r!==t.length-1&&(t[r]=n+="-")}),t.join(" ").split(" ")},Jd=(e,t,n)=>{if(!Number.isFinite(n)||n<0)return e;const r=[],i=e.split(`
`),o=Au(" ",t);let s="",a=0;const l=u=>{u.trim()&&r.push(u)},c=()=>{s="",a=0};return i.forEach(u=>{if(K1(u,t)<=n){r.push(u);return}const h=QO(u);c();let m=0;for(;m<h.length;){const g=Au(h[m],t);if(g===n)l(h[m]),m++;else if(g>n){for(l(s),c();h[m].length>0;){const p=String.fromCodePoint(h[m].codePointAt(0)),v=TI.calculate(p,t);a+=v,h[m]=h[m].slice(p.length),a>=n?(l(s),s=p,a=v):s+=p}a+o>=n?(l(s),c()):s.endsWith("-")||(s+=" ",a+=o),m++}else for(;a<n&&m<h.length;){const p=h[m];if(a=Au(s+p,t),a>n){l(s),c();break}m++;const v=!p.endsWith("-");if(s+=p,v&&(s+=" "),a+o>=n){v?r.push(s.slice(0,-1)):r.push(s),c();break}}}s.slice(-1)===" "&&(s=s.slice(0,-1),l(s))}),r.join(`
`)},TI=(()=>{const e={};return{calculate:(r,i)=>{const o=r.charCodeAt(0);if(e[i]||(e[i]=[]),!e[i][o]){const s=Au(r,i);e[i][o]=s}return e[i][o]},getCache:r=>e[r]}})(),MI="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase(),AI=(e,t)=>{const n=JO(e);return n===0?ds(MI.split("").join(`
`),e,t).width+Nt*2:n+Nt*2},JO=e=>{const t=TI.getCache(e);if(!t)return 0;const n=t.filter(r=>r!==void 0);return Math.max(...n)},va=e=>{var t,n,r;return(t=e==null?void 0:e.boundElements)!=null&&t.length&&((r=(n=e==null?void 0:e.boundElements)==null?void 0:n.filter(i=>i.type==="text")[0])==null?void 0:r.id)||null},ke=(e,t)=>{if(!e)return null;const n=va(e);return n&&t.get(n)||null},kn=(e,t)=>e&&e.containerId&&t.get(e.containerId)||null,Ep=(e,t,n)=>{if(!Ge(e))return{x:e.x+e.width/2,y:e.y+e.height/2};const r=ue.getPointsGlobalCoordinates(e,n);if(r.length%2===1){const s=Math.floor(e.points.length/2),a=ue.getPointGlobalCoordinates(e,e.points[s],n);return{x:a[0],y:a[1]}}const i=e.points.length/2-1;let o=ue.getEditorMidPoints(e,n,t)[i];return o||(o=ue.getSegmentMidPoint(e,r[i],r[i+1],i+1,n)),{x:o[0],y:o[1]}},LI=e=>{let t=Nt,n=Nt;return e.type==="ellipse"&&(t+=e.width/2*(1-Math.sqrt(2)/2),n+=e.height/2*(1-Math.sqrt(2)/2)),e.type==="diamond"&&(t+=e.width/4,n+=e.height/4),{x:e.x+t,y:e.y+n}},eN=(e,t)=>!t||Ge(t)?e.angle:t.angle,tN=(e,t)=>e.some(n=>{if(Mt(n)){const r=kn(n,t);return!Ge(r)}return!1}),nN=(e,t)=>e.some(n=>{if(Mt(n)){const r=kn(n,t);return!Ge(r)}return ce(n)}),Ub=(e,t,n,r,i)=>{const o=qe(e,t);if(o.length===1)return ia(o[0],!1)?o[0]:null;let s=null;for(let a=e.length-1;a>=0;--a){if(e[a].isDeleted)continue;const[l,c,u,d]=Ee(e[a],i);if(Ge(e[a])&&vd(e[a],t,null,[n,r],i)){s=e[a];break}else if(l<n&&n<u&&c<r&&r<d){s=e[a];break}}return ia(s,!1)?s:null},rN=new Set(["rectangle","ellipse","diamond","arrow"]),iN=e=>rN.has(e.type),Ea=(e,t)=>{e=Math.ceil(e);const n=Nt*2;return t==="ellipse"?Math.round((e+n)/Math.sqrt(2)*2):t==="arrow"?e+n*8:t==="diamond"?2*(e+n):e+n},Ii=(e,t)=>{const{width:n}=e;if(Ge(e)){const r=((t==null?void 0:t.fontSize)??Xr)*bR;return Math.max(wR*n,r)}return e.type==="ellipse"?Math.round(n/2*Math.sqrt(2))-Nt*2:e.type==="diamond"?Math.round(n/2)-Nt*2:n-Nt*2},eh=(e,t)=>{const{height:n}=e;return Ge(e)?n-Nt*8*2<=0?t.height:n:e.type==="ellipse"?Math.round(n/2*Math.sqrt(2))-Nt*2:e.type==="diamond"?Math.round(n/2)-Nt*2:n-Nt*2},oN=()=>K1(MI,Bt({fontSize:Xr,fontFamily:oo}))>0,wp={[Xt.Virgil]:1.25,[Xt.Helvetica]:1.15,[Xt.Cascadia]:1.2},Wb={[Xt.Virgil]:{unitsPerEm:1e3,ascender:886,descender:-374},[Xt.Helvetica]:{unitsPerEm:2048,ascender:1577,descender:-471},[Xt.Cascadia]:{unitsPerEm:2048,ascender:1977,descender:-480},[Xt.Assistant]:{unitsPerEm:1e3,ascender:1021,descender:-287}},wa=e=>e in wp?wp[e]:wp[oo],wl=class wl{static getBounds(t,n){const r=wl.boundsCache.get(t);if(r!=null&&r.version&&r.version===t.version&&!Mt(t))return r.bounds;const i=wl.calculateBounds(t,n);return wl.boundsCache.set(t,{version:t.version,bounds:i}),i}static calculateBounds(t,n){let r;const[i,o,s,a,l,c]=Ee(t,n);if(Hn(t)){const[u,d,h,m]=cE(t.points.map(([g,p])=>_e(g,p,l-t.x,c-t.y,t.angle)));return[u+t.x,d+t.y,h+t.x,m+t.y]}else if(we(t))r=mN(t,l,c,n);else if(t.type==="diamond"){const[u,d]=_e(l,o,l,c,t.angle),[h,m]=_e(l,a,l,c,t.angle),[g,p]=_e(i,c,l,c,t.angle),[v,y]=_e(s,c,l,c,t.angle),E=Math.min(u,h,g,v),w=Math.min(d,m,p,y),x=Math.max(u,h,g,v),C=Math.max(d,m,p,y);r=[E,w,x,C]}else if(t.type==="ellipse"){const u=(s-i)/2,d=(a-o)/2,h=Math.cos(t.angle),m=Math.sin(t.angle),g=Math.hypot(u*h,d*m),p=Math.hypot(d*h,u*m);r=[l-g,c-p,l+g,c+p]}else{const[u,d]=_e(i,o,l,c,t.angle),[h,m]=_e(i,a,l,c,t.angle),[g,p]=_e(s,a,l,c,t.angle),[v,y]=_e(s,o,l,c,t.angle),E=Math.min(u,h,g,v),w=Math.min(d,m,p,y),x=Math.max(u,h,g,v),C=Math.max(d,m,p,y);r=[E,w,x,C]}return r}};M(wl,"boundsCache",new WeakMap);let O2=wl;const Ee=(e,t,n=!1)=>{if(Hn(e))return cN(e);if(we(e))return ue.getElementAbsoluteCoords(e,t,n);if(ce(e)){const r=t?kn(e,t):null;if(Ge(r)){const i=ue.getBoundTextElementPosition(r,e,t);return[i.x,i.y,i.x+e.width,i.y+e.height,i.x+e.width/2,i.y+e.height/2]}}return[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2]},Vb=(e,t)=>{const[n,r,i,o,s,a]=Ee(e,t),l=[s,a];if(we(e)||Hn(e)){const y=[];let E=0;for(;E<e.points.length-1;)y.push([st([e.points[E][0]+e.x,e.points[E][1]+e.y],l,e.angle),st([e.points[E+1][0]+e.x,e.points[E+1][1]+e.y],l,e.angle)]),E++;return y}const[c,u,d,h,m,g,p,v]=[[n,r],[i,r],[n,o],[i,o],[s,r],[s,o],[n,a],[i,a]].map(y=>st(y,l,e.angle));return e.type==="diamond"?[[m,p],[m,v],[g,p],[g,v]]:e.type==="ellipse"?[[m,p],[m,v],[g,p],[g,v],[m,p],[m,v],[g,p],[g,v]]:[[c,u],[d,h],[c,d],[u,h],[c,v],[d,v],[u,p],[h,p]]},sN=e=>[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2],aN=e=>{const t=Math.floor(e.width/2)+1,n=0,r=e.width,i=Math.floor(e.height/2)+1,o=t,s=e.height;return[t,n,r,i,o,s,0,i]},_s=e=>{for(const t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops},Gb=(e,t,n,r,i)=>{const o=1-e;return Math.pow(o,3)*t+3*Math.pow(o,2)*e*n+3*o*Math.pow(e,2)*r+Math.pow(e,3)*i},jb=(e,t,n,r)=>{const i=t-e,o=n-t,s=r-n,a=3*i-6*o+3*s,l=6*o-6*i,c=3*i,u=l*l-4*a*c;if(!(u>=0))return!1;let h=null,m=null,g=1/0,p=1/0;return a===0?g=p=-c/l:(g=(-l+Math.sqrt(u))/(2*a),p=(-l-Math.sqrt(u))/(2*a)),g>=0&&g<=1&&(h=Gb(g,e,t,n,r)),p>=0&&p<=1&&(m=Gb(p,e,t,n,r)),[h,m]},lN=(e,t,n,r)=>{const i=jb(e[0],t[0],n[0],r[0]),o=jb(e[1],t[1],n[1],r[1]);let s=Math.min(e[0],r[0]),a=Math.max(e[0],r[0]);if(i){const u=i.filter(d=>d!==null);s=Math.min(s,...u),a=Math.max(a,...u)}let l=Math.min(e[1],r[1]),c=Math.max(e[1],r[1]);if(o){const u=o.filter(d=>d!==null);l=Math.min(l,...u),c=Math.max(c,...u)}return[s,l,a,c]},Z1=(e,t)=>{let n=[0,0];const{minX:r,minY:i,maxX:o,maxY:s}=e.reduce((a,{op:l,data:c})=>{if(l==="move")n=c;else if(l==="bcurveTo"){const u=[c[0],c[1]],d=[c[2],c[3]],h=[c[4],c[5]],m=t?t(...u):u,g=t?t(...d):d,p=t?t(...h):h,v=t?t(...n):n;n=h;const[y,E,w,x]=lN(v,m,g,p);a.minX=Math.min(a.minX,y),a.minY=Math.min(a.minY,E),a.maxX=Math.max(a.maxX,w),a.maxY=Math.max(a.maxY,x)}return a},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return[r,i,o,s]},cE=e=>{let t=1/0,n=1/0,r=-1/0,i=-1/0;for(const[o,s]of e)t=Math.min(t,o),n=Math.min(n,s),r=Math.max(r,o),i=Math.max(i,s);return[t,n,r,i]},cN=e=>{const[t,n,r,i]=cE(e.points),o=t+e.x,s=n+e.y,a=r+e.x,l=i+e.y;return[o,s,a,l,(o+a)/2,(s+l)/2]},uN=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;default:return 15}},dN=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},hN=(e,t,n,r)=>{const i=_s(t[0]);if(i.length<1)return null;const o=n==="start"?1:i.length-1,s=i[o].data,a=[s[4],s[5]],l=[s[2],s[3]],c=[s[0],s[1]],u=i[o-1];let d=[0,0];u.op==="move"?d=u.data:u.op==="bcurveTo"&&(d=[u.data[4],u.data[5]]);const h=(G,q)=>Math.pow(1-G,3)*a[q]+3*G*Math.pow(1-G,2)*l[q]+3*Math.pow(G,2)*(1-G)*c[q]+d[q]*Math.pow(G,3),[m,g]=n==="start"?d:a,[p,v]=[h(.3,0),h(.3,1)],y=Math.hypot(m-p,g-v),E=(m-p)/y,w=(g-v)/y,x=uN(r);let C=0;{const[G,q]=n==="end"?e.points[e.points.length-1]:e.points[0],[U,$]=e.points.length>1?n==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(G-U,q-$)}const I=Math.min(x,C*(r==="diamond"||r==="diamond_outline"?.25:.5)),T=m-E*I,L=g-w*I;if(r==="dot"||r==="circle"||r==="circle_outline"){const G=Math.hypot(L-g,T-m)+e.strokeWidth-2;return[m,g,G]}const A=dN(r),[F,P]=_e(T,L,m,g,-A*Math.PI/180),[O,V]=_e(T,L,m,g,A*Math.PI/180);if(r==="diamond"||r==="diamond_outline"){let G,q;if(n==="start"){const[U,$]=e.points.length>1?e.points[1]:[0,0];[G,q]=_e(m+I*2,g,m,g,Math.atan2($-g,U-m))}else{const[U,$]=e.points.length>1?e.points[e.points.length-2]:[0,0];[G,q]=_e(m-I*2,g,m,g,Math.atan2(g-$,m-U))}return[m,g,F,P,G,q,O,V]}return[m,g,F,P,O,V]},fN=e=>{const t=ws.generator(),n=ur(e),r=e.roundness?"curve":n.fill?"polygon":"linearPath";return t[r](e.points,n)},mN=(e,t,n,r)=>{var d;const i=ke(e,r);if(e.points.length<2){const[h,m]=e.points[0],[g,p]=_e(e.x+h,e.y+m,t,n,e.angle);let v=[g,p,g,p];if(i){const y=ue.getMinMaxXYWithBoundText(e,r,[g,p,g,p],i);v=[y[0],y[1],y[2],y[3]]}return v}const s=((d=Xe.get(e))==null?void 0:d[0])??fN(e),a=_s(s),c=Z1(a,(h,m)=>_e(e.x+h,e.y+m,t,n,e.angle));let u=[c[0],c[1],c[2],c[3]];if(i){const h=ue.getMinMaxXYWithBoundText(e,r,u,i);u=[h[0],h[1],h[2],h[3]]}return u},ba=(e,t)=>O2.getBounds(e,t),nt=e=>{if(!e.length)return[0,0,0,0];let t=1/0,n=-1/0,r=1/0,i=-1/0;const o=be(e);return e.forEach(s=>{const[a,l,c,u]=ba(s,o);t=Math.min(t,a),r=Math.min(r,l),n=Math.max(n,c),i=Math.max(i,u)}),[t,r,n,i]},uE=(e,t)=>{const[n,r,i,o]=nt(e);return[n+t.x,r+t.y,i+t.x,o+t.y]},Lu=(e,t,n,r)=>{if(!(we(e)||Hn(e)))return[e.x,e.y,e.x+t,e.y+n];const i=Kl(0,t,Kl(1,n,e.points,r),r);let o;if(Hn(e))o=cE(i);else{const u=ws.generator(),d=e.roundness?u.curve(i,ur(e)):u.linearPath(i,ur(e)),h=_s(d);o=Z1(h)}const[s,a,l,c]=o;return[s+e.x,a+e.y,l+e.x,c+e.y]},Nm=(e,t)=>{const n=ws.generator(),r=e.roundness==null?n.linearPath(t,ur(e)):n.curve(t,ur(e)),i=_s(r),[o,s,a,l]=Z1(i);return[o+e.x,s+e.y,a+e.x,l+e.y]},gN=(e,t)=>{if(!e.length)return[0,0,0,0];let n=1/0,r=e[0];const i=be(e);return e.forEach(o=>{const[s,a,l,c]=ba(o,i),u=kt((s+l)/2,(a+c)/2,t.x,t.y);u<n&&(n=u,r=o)}),ba(r,i)},ji=e=>{const[t,n,r,i]=nt(e);return{minX:t,minY:n,maxX:r,maxY:i,width:r-t,height:i-n,midX:(t+r)/2,midY:(n+i)/2}},pN=({scrollX:e,scrollY:t,width:n,height:r,zoom:i})=>[-e,-t,-e+n/i.value,-t+r/i.value];function Yb(e,t,n,r=i=>i){return e*r(.5-t*(.5-n))}function yN(e){return[-e[0],-e[1]]}function Or(e,t){return[e[0]+t[0],e[1]+t[1]]}function cr(e,t){return[e[0]-t[0],e[1]-t[1]]}function Lr(e,t){return[e[0]*t,e[1]*t]}function vN(e,t){return[e[0]/t,e[1]/t]}function zc(e){return[e[1],-e[0]]}function Kb(e,t){return e[0]*t[0]+e[1]*t[1]}function EN(e,t){return e[0]===t[0]&&e[1]===t[1]}function wN(e){return Math.hypot(e[0],e[1])}function bN(e){return e[0]*e[0]+e[1]*e[1]}function Zb(e,t){return bN(cr(e,t))}function PI(e){return vN(e,wN(e))}function _N(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function Hc(e,t,n){let r=Math.sin(n),i=Math.cos(n),o=e[0]-t[0],s=e[1]-t[1],a=o*i-s*r,l=o*r+s*i;return[a+t[0],l+t[1]]}function N2(e,t,n){return Or(e,Lr(cr(t,e),n))}function Xb(e,t,n){return Or(e,Lr(t,n))}var{min:Ua,PI:xN}=Math,qb=.275,Uc=xN+1e-4;function SN(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:o=!0,easing:s=U=>U,start:a={},end:l={},last:c=!1}=t,{cap:u=!0,easing:d=U=>U*(2-U)}=a,{cap:h=!0,easing:m=U=>--U*U*U+1}=l;if(e.length===0||n<=0)return[];let g=e[e.length-1].runningLength,p=a.taper===!1?0:a.taper===!0?Math.max(n,g):a.taper,v=l.taper===!1?0:l.taper===!0?Math.max(n,g):l.taper,y=Math.pow(n*r,2),E=[],w=[],x=e.slice(0,10).reduce((U,$)=>{let Y=$.pressure;if(o){let R=Ua(1,$.distance/n),N=Ua(1,1-R);Y=Ua(1,U+(N-U)*(R*qb))}return(U+Y)/2},e[0].pressure),C=Yb(n,i,e[e.length-1].pressure,s),S,I=e[0].vector,T=e[0].point,L=T,A=T,F=L,P=!1;for(let U=0;U<e.length;U++){let{pressure:$}=e[U],{point:Y,vector:R,distance:N,runningLength:B}=e[U];if(U<e.length-1&&g-B<3)continue;if(i){if(o){let Se=Ua(1,N/n),Me=Ua(1,1-Se);$=Ua(1,x+(Me-x)*(Se*qb))}C=Yb(n,i,$,s)}else C=n/2;S===void 0&&(S=C);let z=B<p?d(B/p):1,W=g-B<v?m((g-B)/v):1;C=Math.max(.01,C*Math.min(z,W));let j=(U<e.length-1?e[U+1]:e[U]).vector,X=U<e.length-1?Kb(R,j):1,ee=Kb(R,I)<0&&!P,xe=X!==null&&X<0;if(ee||xe){let Se=Lr(zc(I),C);for(let Me=1/13,Et=0;Et<=1;Et+=Me)A=Hc(cr(Y,Se),Y,Uc*Et),E.push(A),F=Hc(Or(Y,Se),Y,Uc*-Et),w.push(F);T=A,L=F,xe&&(P=!0);continue}if(P=!1,U===e.length-1){let Se=Lr(zc(R),C);E.push(cr(Y,Se)),w.push(Or(Y,Se));continue}let Fe=Lr(zc(N2(j,R,X)),C);A=cr(Y,Fe),(U<=1||Zb(T,A)>y)&&(E.push(A),T=A),F=Or(Y,Fe),(U<=1||Zb(L,F)>y)&&(w.push(F),L=F),x=$,I=R}let O=e[0].point.slice(0,2),V=e.length>1?e[e.length-1].point.slice(0,2):Or(e[0].point,[1,1]),G=[],q=[];if(e.length===1){if(!(p||v)||c){let U=Xb(O,PI(zc(cr(O,V))),-(S||C)),$=[];for(let Y=1/13,R=Y;R<=1;R+=Y)$.push(Hc(U,O,Uc*2*R));return $}}else{if(!(p||v&&e.length===1))if(u)for(let $=1/13,Y=$;Y<=1;Y+=$){let R=Hc(w[0],O,Uc*Y);G.push(R)}else{let $=cr(E[0],w[0]),Y=Lr($,.5),R=Lr($,.51);G.push(cr(O,Y),cr(O,R),Or(O,R),Or(O,Y))}let U=zc(yN(e[e.length-1].vector));if(v||p&&e.length===1)q.push(V);else if(h){let $=Xb(V,U,C);for(let Y=1/29,R=Y;R<1;R+=Y)q.push(Hc($,V,Uc*3*R))}else q.push(Or(V,Lr(U,C)),Or(V,Lr(U,C*.99)),cr(V,Lr(U,C*.99)),cr(V,Lr(U,C)))}return E.concat(q,w.reverse(),G)}function kN(e,t={}){var n;let{streamline:r=.5,size:i=16,last:o=!1}=t;if(e.length===0)return[];let s=.15+(1-r)*.85,a=Array.isArray(e[0])?e:e.map(({x:m,y:g,pressure:p=.5})=>[m,g,p]);if(a.length===2){let m=a[1];a=a.slice(0,-1);for(let g=1;g<5;g++)a.push(N2(a[0],m,g/4))}a.length===1&&(a=[...a,[...Or(a[0],[1,1]),...a[0].slice(2)]]);let l=[{point:[a[0][0],a[0][1]],pressure:a[0][2]>=0?a[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],c=!1,u=0,d=l[0],h=a.length-1;for(let m=1;m<a.length;m++){let g=o&&m===h?a[m].slice(0,2):N2(d.point,a[m],s);if(EN(d.point,g))continue;let p=_N(g,d.point);if(u+=p,m<h&&!c){if(u<i)continue;c=!0}d={point:g,pressure:a[m][2]>=0?a[m][2]:.5,vector:PI(cr(d.point,g)),distance:p,runningLength:u},l.push(d)}return l[0].vector=((n=l[1])==null?void 0:n.vector)||[0,0],l}function IN(e,t={}){return SN(kN(e,t),t)}const RI=(e,t,n)=>{const r=n.reduce((i,o)=>(o.groupIds.includes(e)&&(i[o.id]=!0),i),{});return Object.keys(r).length<2?t.selectedGroupIds[e]||t.editingGroupId===e?{selectedElementIds:t.selectedElementIds,selectedGroupIds:{...t.selectedGroupIds,[e]:!1},editingGroupId:null}:t:{editingGroupId:t.editingGroupId,selectedGroupIds:{...t.selectedGroupIds,[e]:!0},selectedElementIds:{...t.selectedElementIds,...r}}},Zn=function(){let e=null,t=null,n=null;const r=(o,s,a,l)=>{if(n!==void 0&&s===t&&o===e&&a.editingGroupId===(n==null?void 0:n.editingGroupId))return n;const c={};for(const h of o){let m=h.groupIds;if(a.editingGroupId){const g=m.indexOf(a.editingGroupId);g>-1&&(m=m.slice(0,g))}if(m.length>0){const g=m[m.length-1];c[g]=!0}}const u={},d=s.reduce((h,m)=>{const g=m.groupIds.find(p=>c[p]);return g&&(h[m.id]=!0,Array.isArray(u[g])?u[g].push(m.id):u[g]=[m.id]),h},{});for(const h of Object.keys(u))u[h].length<2&&c[h]&&(c[h]=!1);return t=s,e=o,n={editingGroupId:a.editingGroupId,selectedGroupIds:c,selectedElementIds:$e({...a.selectedElementIds,...d},l)},n},i=(o,s,a,l)=>{const c=l?l.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,elements:s}):qe(s,o);return c.length?r(c,s,o,a):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:$e(o.selectedElementIds,a)}};return i.clearCache=()=>{t=null,e=null,n=null},i}(),DI=(e,t)=>OI(e,t)!=null,OI=(e,t)=>t.groupIds.filter(n=>n!==e.editingGroupId).find(n=>e.selectedGroupIds[n]),Ml=e=>Object.entries(e.selectedGroupIds).filter(([t,n])=>n).map(([t,n])=>t),NI=(e,t)=>{let n={...t,selectedGroupIds:{}};for(const r of e){let i=r.groupIds;if(t.editingGroupId){const o=i.indexOf(t.editingGroupId);o>-1&&(i=i.slice(0,o))}if(i.length>0){const o=i[i.length-1];n={...n,...RI(o,n,e)}}}return n.selectedGroupIds},CN=(e,t)=>({...e,editingGroupId:t.groupIds.length?t.groupIds[0]:null,selectedGroupIds:{},selectedElementIds:{[t.id]:!0}}),bd=(e,t)=>e.groupIds.includes(t),It=(e,t)=>{const n=[];for(const r of e.values())bd(r,t)&&n.push(r);return n},TN=(e,t)=>e.groupIds.find(n=>t[n]),MN=(e,t,n)=>{const r=[...e],i=t?e.indexOf(t):-1,o=i>-1?i:e.length;for(let s=0;s<o;s++)r[s]=n(r[s]);return r},AN=(e,t,n)=>{const r=[...e],i=n?r.indexOf(n):-1,o=i>-1?i:r.length;return r.splice(o,0,t),r},LN=(e,t)=>e.filter(n=>!t[n]),X1=(e,t)=>{const n=new Map;return e.forEach(r=>{const i=r.groupIds.length===0?r.id:r.groupIds[r.groupIds.length-1],o=n.get(i)||[],s=ke(r,t);s&&o.push(s),n.set(i,[...o,r])}),Array.from(n.values())};var dE={};Object.defineProperty(dE,"__esModule",{value:!0});var FI=dE.sanitizeUrl=void 0,PN=/^([^\w]*)(javascript|data|vbscript)/im,RN=/&#(\w+)(^\w|;)?/g,DN=/&(newline|tab);/gi,ON=/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim,NN=/^.+(:|&colon;)/gim,FN=[".","/"];function $N(e){return FN.indexOf(e[0])>-1}function BN(e){return e.replace(RN,function(t,n){return String.fromCharCode(n)})}function zN(e){var t=BN(e||"").replace(DN,"").replace(ON,"").trim();if(!t)return"about:blank";if($N(t))return t;var n=t.match(NN);if(!n)return t;var r=n[0];return PN.test(r)?"about:blank":t}FI=dE.sanitizeUrl=zN;const xi=e=>(e=e.trim(),e&&FI(e)),$I=e=>!!(e!=null&&e.includes(location.origin)||e!=null&&e.startsWith("/")),BI=e=>{if(e=xi(e),e.startsWith("/"))return`${location.origin}${e}`;try{new URL(e)}catch{return"about:blank"}return e};let F2=[];const ne=e=>(F2=F2.concat(e),e),zI='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',HN='<path d="M6.164 11.755a5.314 5.314 0 0 1-4.932-5.298 5.314 5.314 0 0 1 5.311-5.311 5.314 5.314 0 0 1 5.307 5.113l8.773 8.773a3.322 3.322 0 0 1 0 4.696l-.895.895a3.322 3.322 0 0 1-4.696 0l-8.868-8.868Z" style="fill:#fff"/>',HI='<path stroke="#1b1b1f" fill="#fff" d="m7.868 11.113 7.773 7.774a2.359 2.359 0 0 0 1.667.691 2.368 2.368 0 0 0 2.357-2.358c0-.625-.248-1.225-.69-1.667L11.201 7.78 9.558 9.469l-1.69 1.643v.001Zm10.273 3.606-3.333 3.333m-3.25-6.583 2 2m-7-7 3 3M3.664 3.625l1 1M2.529 6.922l1.407-.144m5.735-2.932-1.118.866M4.285 9.823l.758-1.194m1.863-6.207-.13 1.408"/>',UN=`data:${de.svg},${encodeURIComponent(`${zI}${HI}</svg>`)}`,WN=`data:${de.svg},${encodeURIComponent(`${zI}${HN}${HI}</svg>`)}`,Pr=e=>{e&&(e.style.cursor="")},He=(e,t)=>{e&&(e.style.cursor=t)};let oi,Qb;const UI=(e,t)=>{const r=()=>{const i=t===Tt.DARK;oi=document.createElement("canvas"),oi.theme=t,oi.height=20,oi.width=20;const o=oi.getContext("2d");o.lineWidth=1,o.beginPath(),o.arc(oi.width/2,oi.height/2,5,0,2*Math.PI),o.fillStyle=i?Ut.black:Ut.white,o.fill(),o.strokeStyle=i?Ut.white:Ut.black,o.stroke(),Qb=oi.toDataURL(de.svg)};(!oi||oi.theme!==t)&&r(),He(e,`url(${Qb}) ${20/2} ${20/2}, auto`)},di=(e,t)=>{if(e)if(t.activeTool.type==="selection")Pr(e);else if(Vl(t))e.style.cursor=Be.GRAB;else if(mi(t))UI(e,t.theme);else if(t.activeTool.type==="laser"){const n=t.theme===Tt.LIGHT?UN:WN;e.style.cursor=`url(${n}), auto`}else["image","custom"].includes(t.activeTool.type)?t.activeTool.type!=="image"&&(e.style.cursor=Be.AUTO):e.style.cursor=Be.CROSSHAIR},so=(e,{x:t,y:n,strokeColor:r=dt.strokeColor,backgroundColor:i=dt.backgroundColor,fillStyle:o=dt.fillStyle,strokeWidth:s=dt.strokeWidth,strokeStyle:a=dt.strokeStyle,roughness:l=dt.roughness,opacity:c=dt.opacity,width:u=0,height:d=0,angle:h=0,groupIds:m=[],frameId:g=null,roundness:p=null,boundElements:v=null,link:y=null,locked:E=dt.locked,...w})=>({id:w.id||xr(),type:e,x:t,y:n,width:u,height:d,angle:h,strokeColor:r,backgroundColor:i,fillStyle:o,strokeWidth:s,strokeStyle:a,roughness:l,opacity:c,groupIds:m,frameId:g,roundness:p,seed:w.seed??bs(),version:w.version||1,versionNonce:w.versionNonce??0,isDeleted:!1,boundElements:v,updated:cc(),link:y,locked:E,customData:w.customData}),hs=e=>so(e.type,e),Jb=e=>so("embeddable",e),VN=e=>({...so("iframe",e)}),WI=e=>ge({...so("frame",e),type:"frame",name:(e==null?void 0:e.name)||null},{}),$2=e=>ge({...so("magicframe",e),type:"magicframe",name:(e==null?void 0:e.name)||null},{}),VI=(e,t)=>({x:e.textAlign==="center"?t.width/2:e.textAlign==="right"?t.width:0,y:e.verticalAlign==="middle"?t.height/2:0}),Sr=e=>{const t=e.fontFamily||oo,n=e.fontSize||Xr,r=e.lineHeight||wa(t),i=wd(e.text),o=ds(i,Bt({fontFamily:t,fontSize:n}),r),s=e.textAlign||D1,a=e.verticalAlign||_m,l=VI({textAlign:s,verticalAlign:a},o);return ge({...so("text",e),text:i,fontSize:n,fontFamily:t,textAlign:s,verticalAlign:a,x:e.x-l.x,y:e.y-l.y,width:o.width,height:o.height,containerId:e.containerId||null,originalText:i,lineHeight:r},{})},GN=(e,t,n)=>{const{width:r,height:i}=ds(n,Bt(e),e.lineHeight),{textAlign:o,verticalAlign:s}=e;let a,l;if(o==="center"&&s===Qn.MIDDLE&&!e.containerId){const c=ds(e.text,Bt(e),e.lineHeight),u=VI(e,{width:r-c.width,height:i-c.height});a=e.x-u.x,l=e.y-u.y}else{const[c,u,d,h]=Ee(e,t),[m,g,p,v]=Lu(e,r,i,!1),y=(c-m)/2,E=(u-g)/2,w=(d-p)/2,x=(h-v)/2;[a,l]=nI({s:!0,e:o==="center"||o==="left",w:o==="center"||o==="right"},e.x,e.y,e.angle,y,E,w,x)}return{width:r,height:i,x:Number.isFinite(a)?a:e.x,y:Number.isFinite(l)?l:e.y}},hE=(e,t,n,r=e.text)=>{if(e.isDeleted)return;t&&(r=Jd(r,Bt(e),Ii(t,e)));const i=GN(e,n,r);return{text:r,...i}},jN=(e,t,n,{text:r,isDeleted:i,originalText:o})=>ge(e,{originalText:o,isDeleted:i??e.isDeleted,...hE(e,t,n,o)}),YN=e=>({...so(e.type,e),points:e.points||[],pressures:[],simulatePressure:e.simulatePressure,lastCommittedPoint:null}),Qo=e=>({...so(e.type,e),points:e.points||[],lastCommittedPoint:null,startBinding:null,endBinding:null,startArrowhead:e.startArrowhead||null,endArrowhead:e.endArrowhead||null}),GI=e=>({...so("image",e),strokeColor:"transparent",status:e.status??"pending",fileId:e.fileId??null,scale:e.scale??[1,1]}),Fm=(e,t=0)=>{if(e==null||typeof e!="object")return e;if(Object.prototype.toString.call(e)==="[object Object]"){const r=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(const i in e)if(e.hasOwnProperty(i)){if(t===0&&(i==="shape"||i==="canvas"))continue;r[i]=Fm(e[i],t+1)}return r}if(Array.isArray(e)){let r=e.length;const i=new Array(r);for(;r--;)i[r]=Fm(e[r],t+1);return i}return e},th=e=>Fm(e),$m=e=>xr(),jI=(e,t,n,r)=>{let i=th(n);return i.id=$m(i.id),i.boundElements=null,i.updated=cc(),i.seed=bs(),i.groupIds=MN(i.groupIds,e,o=>(t.has(o)||t.set(o,$m()),t.get(o))),r&&(i=Object.assign(i,r)),i},YI=(e,t)=>{const n=[],r=be(e),i=new Map,o=a=>{if(i.has(a))return i.get(a);if(r.has(a)){const l=$m();return i.set(a,l),l}return null},s=new Map;for(const a of e){const l=Fm(a);if(l.id=o(a.id),t!=null&&t.randomizeSeed&&(l.seed=bs(),pc(l)),l.groupIds&&(l.groupIds=l.groupIds.map(c=>(s.has(c)||s.set(c,$m()),s.get(c)))),"containerId"in l&&l.containerId){const c=o(l.containerId);l.containerId=c}if("boundElements"in l&&l.boundElements&&(l.boundElements=l.boundElements.reduce((c,u)=>{const d=o(u.id);return d&&c.push({...u,id:d}),c},[])),"endBinding"in l&&l.endBinding){const c=o(l.endBinding.elementId);l.endBinding=c?{...l.endBinding,elementId:c}:null}if("startBinding"in l&&l.startBinding){const c=o(l.startBinding.elementId);l.startBinding=c?{...l.startBinding,elementId:c}:null}l.frameId&&(l.frameId=o(l.frameId)),n.push(l)}return n},Ri=new Map,KN=/^(?:http(?:s)?:\/\/)?(?:www\.)?youtu(?:be\.com|\.be)\/(embed\/|watch\?v=|shorts\/|playlist\?list=|embed\/videoseries\?list=)?([a-zA-Z0-9_-]+)(?:\?t=|&t=|\?start=|&start=)?([a-zA-Z0-9_-]+)?[^\s]*$/,ZN=/^(?:http(?:s)?:\/\/)?(?:(?:w){3}.)?(?:player\.)?vimeo\.com\/(?:video\/)?([^?\s]+)(?:\?.*)?$/,XN=/^https:\/\/(?:www\.)?figma\.com/,qN=/^https:\/\/gist\.github\.com/,QN=/^<script[\s\S]*?\ssrc=["'](https:\/\/gist.github.com\/.*?)\.js["']/i,JN=/(?:http(?:s)?:\/\/)?(?:(?:w){3}.)?(?:twitter|x).com/,eF=/^<blockquote[\s\S]*?\shref=["'](https:\/\/(?:twitter|x).com\/[^"']*)/i,tF=/^https:\/\/(?:www\.)?val.town\/(v|embed)\/[a-zA-Z_$][0-9a-zA-Z_$]+\.[a-zA-Z_$][0-9a-zA-Z_$]+/,nF=/^<(?:iframe|blockquote)[\s\S]*?\s(?:src|href)=["']([^"']*)["'][\s\S]*?>$/i,e_=/giphy.com\/(?:clips|embed|gifs)\/[a-zA-Z0-9]*?-?([a-zA-Z0-9]+)(?:[^a-zA-Z0-9]|$)/,B2=new Set(["youtube.com","youtu.be","vimeo.com","player.vimeo.com","figma.com","link.excalidraw.com","gist.github.com","twitter.com","x.com","*.simplepdf.eu","stackblitz.com","val.town","giphy.com","dddice.com"]),pl=e=>`<html><body>${e}</body></html>`,yl=e=>{if(!e)return null;if(Ri.has(e))return Ri.get(e);const t=e;let n="generic",r={w:560,h:840};const i=e.match(KN);if(i!=null&&i[2]){const l=i[3]?`&start=${i[3]}`:"",c=e.includes("shorts");switch(n="video",i[1]){case"embed/":case"watch?v=":case"shorts/":e=`https://www.youtube.com/embed/${i[2]}?enablejsapi=1${l}`;break;case"playlist?list=":case"embed/videoseries?list=":e=`https://www.youtube.com/embed/videoseries?list=${i[2]}&enablejsapi=1${l}`;break;default:e=`https://www.youtube.com/embed/${i[2]}?enablejsapi=1${l}`;break}return r=c?{w:315,h:560}:{w:560,h:315},Ri.set(t,{link:e,intrinsicSize:r,type:n}),{link:e,intrinsicSize:r,type:n}}const o=e.match(ZN);if(o!=null&&o[1]){const l=o==null?void 0:o[1],c=/^\d+$/.test(l)?void 0:new URIError("Invalid embed link format");return n="video",e=`https://player.vimeo.com/video/${l}?api=1`,r={w:560,h:315},Ri.set(t,{link:e,intrinsicSize:r,type:n}),{link:e,intrinsicSize:r,type:n,error:c}}if(e.match(XN))return n="generic",e=`https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(e)}`,r={w:550,h:550},Ri.set(t,{link:e,intrinsicSize:r,type:n}),{link:e,intrinsicSize:r,type:n};const a=e.match(tF);if(a)return e=a[1]==="embed"?a[0]:a[0].replace("/v","/embed"),Ri.set(t,{link:e,intrinsicSize:r,type:n}),{link:e,intrinsicSize:r,type:n};if(JN.test(e)){e=e.replace(/\bx.com\b/,"twitter.com");let l;if(/<blockquote/.test(e)){const c=pl(e);l={type:"document",srcdoc:()=>c,intrinsicSize:{w:480,h:480}}}else l={type:"document",srcdoc:c=>pl(`<blockquote class="twitter-tweet" data-dnt="true" data-theme="${c}"><a href="${e}"></a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"><\/script>`),intrinsicSize:{w:480,h:480}};return Ri.set(t,l),l}if(qN.test(e)){let l;if(/<script>/.test(e)){const c=pl(e);l={type:"document",srcdoc:()=>c,intrinsicSize:{w:550,h:720}}}else l={type:"document",srcdoc:()=>pl(`
<script src="${e}.js"><\/script>
<style type="text/css">
* { margin: 0px; }
table, .gist { height: 100%; }
.gist .gist-file { height: calc(100vh - 2px); padding: 0px; display: grid; grid-template-rows: 1fr auto; }
</style>
`),intrinsicSize:{w:550,h:720}};return Ri.set(e,l),l}return Ri.set(e,{link:e,intrinsicSize:r,type:n}),{link:e,intrinsicSize:r,type:n}},KI=e=>{let t;Io(e)?t="IFrame element":t=!e.link||(e==null?void 0:e.link)===""?"Empty Web-Embed":e.link;const n=Math.max(Math.min(e.width/2,e.width/t.length),e.width/30),r=Xt.Helvetica,i=Bt({fontSize:n,fontFamily:r});return Sr({x:e.x+e.width/2,y:e.y+e.height/2,strokeColor:e.strokeColor!=="transparent"?e.strokeColor:"black",backgroundColor:"transparent",fontFamily:r,fontSize:n,text:Jd(t,i,e.width-20),textAlign:"center",verticalAlign:Qn.MIDDLE,angle:e.angle??0})};ne({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},perform:(e,t,n,r)=>{const i=bt(t,{type:"embeddable"});return di(r.canvas,{...t,activeTool:i}),{elements:e,appState:{...t,activeTool:bt(t,{type:"embeddable"})},commitToHistory:!1}}});const t_=(e,t)=>{try{const{hostname:n}=new URL(e),r=n.replace(/^www\./,""),i=r.replace(/^([^.]+)/,"*");if(t instanceof Set)return B2.has(r)||B2.has(i);if(r===t.replace(/^www\./,""))return!0}catch{}return!1},rF=e=>{const t=e.match(eF);if(t&&t.length===2)return t[1];const n=e.match(QN);if(n&&n.length===2)return n[1];if(e_.test(e))return`https://giphy.com/embed/${e_.exec(e)[1]}`;const r=e.match(nF);return r&&r.length===2?r[1]:e},Rf=(e,t)=>{if(!e)return!1;if(t!=null)if(typeof t=="function"){const n=t(e);if(typeof n=="boolean")return n}else{if(typeof t=="boolean")return t;if(t instanceof RegExp)return t.test(e);if(Array.isArray(t)){for(const n of t)if(n instanceof RegExp){if(e.match(n))return!0}else if(t_(e,n))return!0;return!1}}return t_(e,B2)},Wc=(e,t,n)=>{if(typeof n>"u")return e.draw(t);const r={sets:t.sets,shape:t.shape,options:{...t.options,fixedDecimalPlaceDigits:n}};return e.draw(r)},Vc=(e,t,n,r,i)=>{if(!r.enabled||!r.clip)return null;const o=rr(e,i);if(o){const s=t.ownerDocument.createElementNS(Ke,"g");return s.setAttributeNS(Ke,"clip-path",`url(#${o.id})`),n.forEach(a=>s.appendChild(a)),s}return null},z2=(e,t,n,r,i,o,s,a)=>{var w;const l={x:o,y:s},[c,u,d,h]=Ee(e,t);let m=(d-c)/2-(e.x-c),g=(h-u)/2-(e.y-u);if(ce(e)){const x=kn(e,t);if(Ge(x)){const[C,S,I,T]=Ee(x,t),L=ue.getBoundTextElementPosition(x,e,t);m=(I-C)/2-(L.x-C),g=(T-S)/2-(L.y-S),o=o+L.x-e.x,s=s+L.y-e.y}}const p=180*e.angle/Math.PI;let v=r;if(e.link){const x=r.ownerDocument.createElementNS(Ke,"a");x.setAttribute("href",xi(e.link)),v.appendChild(x),v=x}const y=(x,C)=>{v.appendChild(x)},E=(((w=rr(e,t))==null?void 0:w.opacity)??100)*e.opacity/1e4;switch(e.type){case"selection":throw new Error("Selection rendering is not supported for SVG");case"rectangle":case"diamond":case"ellipse":{const x=Xe.generateElementShape(e,null),C=Wc(n,x,Oc);E!==1&&(C.setAttribute("stroke-opacity",`${E}`),C.setAttribute("fill-opacity",`${E}`)),C.setAttribute("stroke-linecap","round"),C.setAttribute("transform",`translate(${o||0} ${s||0}) rotate(${p} ${m} ${g})`);const S=Vc(e,v,[C],a.frameRendering,t);y(S||C);break}case"iframe":case"embeddable":{const x=Xe.generateElementShape(e,a),C=Wc(n,x,Oc),S=e.opacity/100;S!==1&&(C.setAttribute("stroke-opacity",`${S}`),C.setAttribute("fill-opacity",`${S}`)),C.setAttribute("stroke-linecap","round"),C.setAttribute("transform",`translate(${o||0} ${s||0}) rotate(${p} ${m} ${g})`),y(C);const I=KI(e);z2(I,t,n,v,i,I.x+l.x-e.x,I.y+l.y-e.y,a);const T=Wc(n,x,Oc);for(T.setAttribute("stroke-linecap","round"),T.setAttribute("transform",`translate(${o||0} ${s||0}) rotate(${p} ${m} ${g})`);T.firstChild;)T.removeChild(T.firstChild);const L=oa(Math.min(e.width,e.height),e),A=yl(BI(e.link||""));if(a.renderEmbeddables===!1||(A==null?void 0:A.type)==="document"){const F=r.ownerDocument.createElementNS(Ke,"a");F.setAttribute("href",xi(e.link||"")),F.setAttribute("target","_blank"),F.setAttribute("rel","noopener noreferrer"),F.style.borderRadius=`${L}px`,T.appendChild(F)}else{const F=r.ownerDocument.createElementNS(Ke,"foreignObject");F.style.width=`${e.width}px`,F.style.height=`${e.height}px`,F.style.border="none";const P=F.ownerDocument.createElementNS(Ke,"div");P.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),P.style.width="100%",P.style.height="100%";const O=P.ownerDocument.createElement("iframe");O.src=(A==null?void 0:A.link)??"",O.style.width="100%",O.style.height="100%",O.style.border="none",O.style.borderRadius=`${L}px`,O.style.top="0",O.style.left="0",O.allowFullscreen=!0,P.appendChild(O),F.appendChild(P),T.appendChild(F)}y(T);break}case"line":case"arrow":{const x=ke(e,t),C=r.ownerDocument.createElementNS(Ke,"mask");if(x){C.setAttribute("id",`mask-${e.id}`);const L=r.ownerDocument.createElementNS(Ke,"rect");o=o||0,s=s||0,L.setAttribute("x","0"),L.setAttribute("y","0"),L.setAttribute("fill","#fff"),L.setAttribute("width",`${e.width+100+o}`),L.setAttribute("height",`${e.height+100+s}`),C.appendChild(L);const A=r.ownerDocument.createElementNS(Ke,"rect"),F=ue.getBoundTextElementPosition(e,x,t),P=o+F.x-e.x,O=s+F.y-e.y;A.setAttribute("x",P.toString()),A.setAttribute("y",O.toString()),A.setAttribute("fill","#000"),A.setAttribute("width",`${x.width}`),A.setAttribute("height",`${x.height}`),A.setAttribute("opacity","1"),C.appendChild(A)}const S=r.ownerDocument.createElementNS(Ke,"g");x&&S.setAttribute("mask",`url(#mask-${e.id})`),S.setAttribute("stroke-linecap","round"),Xe.generateElementShape(e,a).forEach(L=>{const A=Wc(n,L,Oc);E!==1&&(A.setAttribute("stroke-opacity",`${E}`),A.setAttribute("fill-opacity",`${E}`)),A.setAttribute("transform",`translate(${o||0} ${s||0}) rotate(${p} ${m} ${g})`),e.type==="line"&&cs(e.points)&&e.backgroundColor!=="transparent"&&A.setAttribute("fill-rule","evenodd"),S.appendChild(A)});const T=Vc(e,v,[S,C],a.frameRendering,t);T?(y(T),v.appendChild(T)):(y(S),v.append(C));break}case"freedraw":{const x=Xe.generateElementShape(e,a),C=x?Wc(n,x,Oc):r.ownerDocument.createElementNS(Ke,"g");E!==1&&(C.setAttribute("stroke-opacity",`${E}`),C.setAttribute("fill-opacity",`${E}`)),C.setAttribute("transform",`translate(${o||0} ${s||0}) rotate(${p} ${m} ${g})`),C.setAttribute("stroke","none");const S=r.ownerDocument.createElementNS(Ke,"path");S.setAttribute("fill",e.strokeColor),S.setAttribute("d",$T(e)),C.appendChild(S);const I=Vc(e,v,[C],a.frameRendering,t);y(I||C);break}case"image":{const x=Math.round(e.width),C=Math.round(e.height),S=Ft(e)&&i[e.fileId];if(S){const I=`image-${S.id}`;let T=r.querySelector(`#${I}`);if(!T){T=r.ownerDocument.createElementNS(Ke,"symbol"),T.id=I;const P=r.ownerDocument.createElementNS(Ke,"image");P.setAttribute("width","100%"),P.setAttribute("height","100%"),P.setAttribute("href",S.dataURL),T.appendChild(P),v.prepend(T)}const L=r.ownerDocument.createElementNS(Ke,"use");if(L.setAttribute("href",`#${I}`),a.exportWithDarkMode&&S.mimeType!==de.svg&&L.setAttribute("filter",LT),L.setAttribute("width",`${x}`),L.setAttribute("height",`${C}`),L.setAttribute("opacity",`${E}`),e.scale[0]!==1||e.scale[1]!==1){const P=e.scale[0]!==1?-x:0,O=e.scale[1]!==1?-C:0;L.setAttribute("transform",`scale(${e.scale[0]}, ${e.scale[1]}) translate(${P} ${O})`)}const A=r.ownerDocument.createElementNS(Ke,"g");if(A.appendChild(L),A.setAttribute("transform",`translate(${o||0} ${s||0}) rotate(${p} ${m} ${g})`),e.roundness){const P=r.ownerDocument.createElementNS(Ke,"clipPath");P.id=`image-clipPath-${e.id}`;const O=r.ownerDocument.createElementNS(Ke,"rect"),V=oa(Math.min(e.width,e.height),e);O.setAttribute("width",`${e.width}`),O.setAttribute("height",`${e.height}`),O.setAttribute("rx",`${V}`),O.setAttribute("ry",`${V}`),P.appendChild(O),y(P),A.setAttributeNS(Ke,"clip-path",`url(#${P.id})`)}const F=Vc(e,v,[A],a.frameRendering,t);y(F||A)}break}case"frame":case"magicframe":{if(a.frameRendering.enabled&&a.frameRendering.outline){const x=document.createElementNS(Ke,"rect");x.setAttribute("transform",`translate(${o||0} ${s||0}) rotate(${p} ${m} ${g})`),x.setAttribute("width",`${e.width}px`),x.setAttribute("height",`${e.height}px`),x.setAttribute("rx",vt.radius.toString()),x.setAttribute("ry",vt.radius.toString()),x.setAttribute("fill","none"),x.setAttribute("stroke",vt.strokeColor),x.setAttribute("stroke-width",vt.strokeWidth.toString()),y(x)}break}default:if(ce(e)){const x=r.ownerDocument.createElementNS(Ke,"g");E!==1&&(x.setAttribute("stroke-opacity",`${E}`),x.setAttribute("fill-opacity",`${E}`)),x.setAttribute("transform",`translate(${o||0} ${s||0}) rotate(${p} ${m} ${g})`);const C=e.text.replace(/\r\n?/g,`
`).split(`
`),S=Qd(e.fontSize,e.lineHeight),I=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,T=II(e.fontFamily,e.fontSize,S),L=Vk(e.text)?"rtl":"ltr",A=e.textAlign==="center"?"middle":e.textAlign==="right"||L==="rtl"?"end":"start";for(let P=0;P<C.length;P++){const O=r.ownerDocument.createElementNS(Ke,"text");O.textContent=C[P],O.setAttribute("x",`${I}`),O.setAttribute("y",`${P*S+T}`),O.setAttribute("font-family",Zv(e)),O.setAttribute("font-size",`${e.fontSize}px`),O.setAttribute("fill",e.strokeColor),O.setAttribute("text-anchor",A),O.setAttribute("style","white-space: pre;"),O.setAttribute("direction",L),O.setAttribute("dominant-baseline","alphabetic"),x.appendChild(O)}const F=Vc(e,v,[x],a.frameRendering,t);y(F||x)}else throw new Error(`Unimplemented type ${e.type}`)}},iF=(e,t,n,r,i,o)=>{r&&(e.filter(s=>!fr(s)).forEach(s=>{if(!s.isDeleted)try{z2(s,t,n,r,i,s.x+o.offsetX,s.y+o.offsetY,o)}catch(a){console.error(a)}}),e.filter(s=>fr(s)).forEach(s=>{if(!s.isDeleted)try{z2(s,t,n,r,i,s.x+o.offsetX,s.y+o.offsetY,o)}catch(a){console.error(a)}}))},Da=(()=>{if(typeof self>"u")return!1;if("top"in self&&self!==top)try{}catch{return!1}else if("showOpenFilePicker"in self)return"showOpenFilePicker";return!1})(),oF=ie(Da?()=>import("./file-open-002ab408-YYr_q30i.js"):()=>import("./file-open-7c801643-DzelrtLq.js"),__vite__mapDeps([]));async function sF(...e){return(await oF).default(...e)}ie(Da?()=>import("./directory-open-4ed118d0-LU9zN15H.js"):()=>import("./directory-open-01563666-cQgJ4y3t.js"),__vite__mapDeps([]));const aF=ie(Da?()=>import("./file-save-745eba88-h9NxcJsg.js"):()=>import("./file-save-3189631c-fOa8IYo3.js"),__vite__mapDeps([]));async function lF(...e){return(await aF).default(...e)}class cF extends Error{constructor(t="Couldn't export canvas.",n="CANVAS_ERROR"){super(),this.name=n,this.message=t}}class ql extends DOMException{constructor(t="Request Aborted"){super(t,"AbortError")}}class js extends Error{constructor(n="Image Scene Data Error",r="IMAGE_SCENE_DATA_ERROR"){super(n);M(this,"code");this.name="EncodingError",this.code=r}}const n_=500,fE=e=>{var r,i;const t=(r=e.extensions)==null?void 0:r.reduce((o,s)=>(o.push(de[s]),o),[]),n=(i=e.extensions)==null?void 0:i.reduce((o,s)=>s==="jpg"?o.concat(".jpg",".jpeg"):o.concat(`.${s}`),[]);return sF({description:e.description,extensions:n,mimeTypes:t,multiple:e.multiple??!1,legacySetup:(o,s,a)=>{const l=fa(s,n_),c=()=>{u(),document.addEventListener(Z.KEYUP,l),document.addEventListener(Z.POINTER_UP,l),l()},u=()=>{var h;if((h=a.files)!=null&&h.length){const m=e.multiple?[...a.files]:a.files[0];o(m)}};requestAnimationFrame(()=>{window.addEventListener(Z.FOCUS,c)});const d=window.setInterval(()=>{u()},n_);return h=>{clearInterval(d),l.cancel(),window.removeEventListener(Z.FOCUS,c),document.removeEventListener(Z.KEYUP,l),document.removeEventListener(Z.POINTER_UP,l),h&&(console.warn("Opening the file was canceled (legacy-fs)."),h(new ql))}}})},Bm=(e,t)=>lF(e,{fileName:`${t.name}.${t.extension}`,description:t.description,extensions:[`.${t.extension}`]},t.fileHandle),uF={selection:!0,text:!0,rectangle:!0,diamond:!0,ellipse:!0,line:!0,image:!0,arrow:!0,freedraw:!0,eraser:!1,custom:!0,frame:!0,embeddable:!0,hand:!0,laser:!1,magicframe:!1},dF=e=>Object.keys(Xt).includes(e)?Xt[e]:oo,r_=e=>e?{...e,focus:e.focus||0}:null,Wa=(e,t)=>{const n={type:t.type||e.type,version:e.version||1,versionNonce:e.versionNonce??0,isDeleted:e.isDeleted??!1,id:e.id||xr(),fillStyle:e.fillStyle||dt.fillStyle,strokeWidth:e.strokeWidth||dt.strokeWidth,strokeStyle:e.strokeStyle??dt.strokeStyle,roughness:e.roughness??dt.roughness,opacity:e.opacity==null?dt.opacity:e.opacity,angle:e.angle||0,x:t.x??e.x??0,y:t.y??e.y??0,strokeColor:e.strokeColor||dt.strokeColor,backgroundColor:e.backgroundColor||dt.backgroundColor,width:e.width||0,height:e.height||0,seed:e.seed??1,groupIds:e.groupIds??[],frameId:e.frameId??null,roundness:e.roundness?e.roundness:e.strokeSharpness==="round"?{type:uc(e.type)?Vt.LEGACY:Vt.PROPORTIONAL_RADIUS}:null,boundElements:e.boundElementIds?e.boundElementIds.map(r=>({type:"arrow",id:r})):e.boundElements??[],updated:e.updated??cc(),link:e.link?xi(e.link):null,locked:e.locked??!1};return("customData"in e||"customData"in t)&&(n.customData="customData"in t?t.customData:e.customData),Do in e&&(n[Do]=e[Do]),{...n,...BT(n),...t}},hF=e=>{switch(e.type){case"text":let t=e.fontSize,n=e.fontFamily;if("font"in e){const[o,s]=e.font.split(" ");t=parseFloat(o),n=dF(s)}const r=typeof e.text=="string"&&e.text||"",i=e.lineHeight||(e.height?XO(e):wa(e.fontFamily));return e=Wa(e,{fontSize:t,fontFamily:n,text:r,textAlign:e.textAlign||D1,verticalAlign:e.verticalAlign||_m,containerId:e.containerId??null,originalText:e.originalText||r,lineHeight:i}),!r&&!e.isDeleted&&(e={...e,originalText:r,isDeleted:!0},e=pc(e)),e;case"freedraw":return Wa(e,{points:e.points,lastCommittedPoint:null,simulatePressure:e.simulatePressure,pressures:e.pressures});case"image":return Wa(e,{status:e.status||"pending",fileId:e.fileId,scale:e.scale||[1,1]});case"line":case"draw":case"arrow":{const{startArrowhead:o=null,endArrowhead:s=e.type==="arrow"?"arrow":null}=e;let a=e.x,l=e.y,c=!Array.isArray(e.points)||e.points.length<2?[[0,0],[e.width,e.height]]:e.points;return(c[0][0]!==0||c[0][1]!==0)&&({points:c,x:a,y:l}=ue.getNormalizedPoints(e)),Wa(e,{type:e.type==="draw"?"line":e.type,startBinding:r_(e.startBinding),endBinding:r_(e.endBinding),lastCommittedPoint:null,startArrowhead:o,endArrowhead:s,points:c,x:a,y:l})}case"ellipse":case"rectangle":case"diamond":case"iframe":case"embeddable":return Wa(e,{});case"magicframe":case"frame":return Wa(e,{name:e.name??null})}return null},fF=(e,t)=>{if(e.boundElements){const n=e.boundElements.slice(),r=new Set;e.boundElements=n.reduce((i,o)=>{const s=t.get(o.id);if(s&&!r.has(o.id)){if(r.add(o.id),s.isDeleted)return i;i.push(o),ce(s)&&!s.containerId&&(s.containerId=e.id)}return i},[])}},mF=(e,t)=>{const n=e.containerId?t.get(e.containerId):null;if(!n){e.containerId=null;return}if(!e.isDeleted&&n.boundElements&&!n.boundElements.find(r=>r.id===e.id)){const r=(n.boundElements||(n.boundElements=[])).slice();r.push({type:"text",id:e.id}),n.boundElements=r}},gF=(e,t)=>{e.frameId&&(t.get(e.frameId)||(e.frameId=null))},nh=(e,t,n)=>{const r=new Set,i=t?be(t):null,o=(e||[]).reduce((a,l)=>{if(l.type!=="selection"&&!Ma(l)){let c=hF(l);if(c){const u=i==null?void 0:i.get(l.id);u&&u.version>c.version&&(c=pc(c,u.version)),r.has(c.id)&&(c={...c,id:xr()}),r.add(c.id),a.push(c)}}return a},[]);if(!(n!=null&&n.repairBindings))return o;const s=be(o);for(const a of o)a.frameId&&gF(a,s),ce(a)&&a.containerId?mF(a,s):a.boundElements&&fF(a,s),n.refreshDimensions&&ce(a)&&Object.assign(a,hE(a,kn(a,s),s));return o},pF=(e,t,n)=>{const r=t[e];return r!==void 0?r:n[e]},i_={isSidebarDocked:(e,t)=>["defaultSidebarDockedPreference",e.isSidebarDocked??pF("defaultSidebarDockedPreference",e,t)]},ZI=(e,t)=>{var i;e=e||{};const n=qr(),r={};for(const o of Object.keys(i_))if(o in e){const[s,a]=i_[o](e,n);r[s]=a}for(const[o,s]of Object.entries(n)){const a=e[o],l=t?t[o]:void 0;r[o]=a!==void 0?a:l!==void 0?l:s}return{...r,cursorButton:(t==null?void 0:t.cursorButton)||"up",penDetected:(t==null?void 0:t.penDetected)??(e.penMode?e.penDetected??!1:!1),activeTool:{...bt(n,r.activeTool.type&&uF[r.activeTool.type]?r.activeTool:{type:"selection"}),lastActiveTool:null,locked:r.activeTool.locked??!1},zoom:typeof e.zoom=="number"?{value:e.zoom}:(i=e.zoom)!=null&&i.value?e.zoom:n.zoom,openSidebar:typeof e.openSidebar=="string"?{name:Tl.name}:r.openSidebar}},_a=(e,t,n,r)=>({elements:nh(e==null?void 0:e.elements,n,r),appState:ZI(e==null?void 0:e.appState,t||null),files:(e==null?void 0:e.files)||{}}),o_=e=>{const t=nh(je(e.elements),null);return t.length?{...e,elements:t}:null},q1=(e=[],t)=>{const n=[];for(const r of e)if(Array.isArray(r)){const i=o_({status:t,elements:r,id:xr(),created:Date.now()});i&&n.push(i)}else{const i=r,o=o_({...i,id:i.id||xr(),status:i.status||t,created:i.created||Date.now()});o&&n.push(o)}return n},XI=async e=>{let t;if(e.type===de.png)try{return await(await ie(()=>Promise.resolve().then(()=>Wm),void 0)).decodePngMetadata(e)}catch(n){throw n.message==="INVALID"?new js("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new js("Error: cannot restore image")}else if("text"in Blob?t=await e.text():t=await new Promise(n=>{const r=new FileReader;r.readAsText(e,"utf8"),r.onloadend=()=>{r.readyState===FileReader.DONE&&n(r.result)}}),e.type===de.svg)try{return await(await ie(()=>Promise.resolve().then(()=>Wm),void 0)).decodeSvgMetadata({svg:t})}catch(n){throw n.message==="INVALID"?new js("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):new js("Error: cannot restore image")}return t},qI=e=>{var t;return e&&((t=e.name.match(/\.(json|excalidraw|png|svg)$/))==null?void 0:t[1])||null},yF=e=>e==="png"||e==="svg",mE=e=>{const t=qI(e);return t==="png"||t==="svg"},sa=e=>{const{type:t}=e||{};return!!t&&Object.values(Nv).includes(t)},QI=async(e,t,n,r)=>{const i=await XI(e);let o;try{try{o=JSON.parse(i)}catch(s){throw sa(e)?new js("Image doesn't contain scene","IMAGE_NOT_CONTAINS_SCENE_DATA"):s}if(IF(o))return{type:de.excalidraw,data:_a({elements:HT(o.elements||[]),appState:{theme:t==null?void 0:t.theme,fileHandle:r||e.handle||null,...KS(o.appState||{}),...t?Ld(o.elements||[],t):{}},files:o.files},t,n,{repairBindings:!0,refreshDimensions:!1})};if(tC(o))return{type:de.excalidrawlib,data:o};throw new Error("Error: invalid file")}catch(s){throw s instanceof js?s:new Error("Error: invalid file")}},gE=async(e,t,n,r)=>{const i=await QI(e,t,n,r);if(i.type!==de.excalidraw)throw new Error("Error: invalid file");return i.data},JI=(e,t="unpublished")=>{const n=JSON.parse(e);if(!tC(n))throw new Error("Invalid library");const r=n.libraryItems||n.library;return q1(r,t)},vF=async(e,t="unpublished")=>JI(await XI(e),t),_d=async e=>new Promise(async(t,n)=>{try{Xd(e)&&(e=await e),e.toBlob(r=>{if(!r)return n(new cF("Error: Canvas too big","CANVAS_POSSIBLY_TOO_BIG"));t(r)})}catch(r){n(r)}}),EF=async e=>{try{const t=await window.crypto.subtle.digest("SHA-1",await Fo(e));return Kk(new Uint8Array(t))}catch(t){return console.error(t),Kv(40)}},bp=async e=>new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const i=r.result;t(i)},r.onerror=i=>n(i),r.readAsDataURL(e)}),wF=(e,t="")=>{const n=e.indexOf(","),r=atob(e.slice(n+1)),i=e.slice(0,n).split(":")[1].split(";")[0],o=new ArrayBuffer(r.length),s=new Uint8Array(o);for(let a=0;a<r.length;a++)s[a]=r.charCodeAt(a);return new File([o],t,{type:i})},H2=async(e,t)=>{if(e.type===de.svg)return e;const[n,r]=await Promise.all([ie(()=>import("./pica-k97f9p3G.js").then(o=>o.p),__vite__mapDeps([0,1])).then(o=>o.default),ie(()=>import("./image-blob-reduce.esm-kuDQZwjv.js"),__vite__mapDeps([])).then(o=>o.default)]),i=r({pica:n({features:["js","wasm"]})});if(t.outputType){const{outputType:o}=t;i._create_blob=function(s){return this.pica.toBlob(s.out_canvas,o,.8).then(a=>(s.out_blob=a,s))}}if(!sa(e))throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"});return new File([await i.toBlob(e,{max:t.maxWidthOrHeight})],e.name,{type:t.outputType||e.type})},s_=(e,t="")=>new File([new TextEncoder().encode(e)],t,{type:de.svg}),bF=async(e,t="")=>{let n;try{n=await fetch(e)}catch{throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"})}if(!n.ok)throw new Error("Error: failed to fetch image",{cause:"FETCH_ERROR"});const r=await n.blob();if(r.type&&sa(r)){const i=t||r.name||"";return new File([r],i,{type:r.type})}throw new Error("Error: unsupported file type",{cause:"UNSUPPORTED"})},_F=async e=>{const t=e.dataTransfer.files.item(0),n=await xF(e);return{file:t?await pE(t):null,fileHandle:n}},xF=async e=>{if(Da)try{return await e.dataTransfer.items[0].getAsFileSystemHandle()||null}catch(t){return console.warn(t.name,t.message),null}return null},a_=e=>{let t=null;const n=`${[...new Uint8Array(e).slice(0,8)].join(" ")} `,r={png:"137 80 78 71 13 10 26 10 ",jpg:"255 216 255 ",gif:"71 73 70 56 57 97 "};return n===r.png?t=de.png:n.startsWith(r.jpg)?t=de.jpg:n.startsWith(r.gif)&&(t=de.gif),t},Wh=(e,t,n)=>new File([e],n||"",{type:t}),pE=async e=>{var t,n;if(e.type){if(sa(e)){const r=await Fo(e),i=a_(r);i&&i!==e.type&&(e=Wh(r,i,e.name))}}else if((t=e==null?void 0:e.name)!=null&&t.endsWith(".excalidrawlib"))e=Wh(await Fo(e),de.excalidrawlib,e.name);else if((n=e==null?void 0:e.name)!=null&&n.endsWith(".excalidraw"))e=Wh(await Fo(e),de.excalidraw,e.name);else{const r=await Fo(e),i=a_(r);i&&(e=Wh(r,i,e.name))}return e},Fo=e=>"arrayBuffer"in e?e.arrayBuffer():new Promise((t,n)=>{const r=new FileReader;r.onload=i=>{var o;if(!((o=i.target)!=null&&o.result))return n(new Error("Couldn't convert blob to ArrayBuffer"));t(i.target.result)},r.readAsArrayBuffer(e)}),SF=(e,t)=>{const n={};for(const r of e)!r.isDeleted&&"fileId"in r&&r.fileId&&t[r.fileId]&&(n[r.fileId]=t[r.fileId]);return n},hc=(e,t,n,r)=>{const i={type:yr.excalidraw,version:O1.excalidraw,source:Fv,elements:r==="local"?HT(e):eH(e),appState:r==="local"?KS(t):IR(t),files:r==="local"?SF(e,n):void 0};return JSON.stringify(i,null,2)},eC=async(e,t,n,r=t.name||jS)=>{const i=hc(e,t,n,"local"),o=new Blob([i],{type:de.excalidraw});return{fileHandle:await Bm(o,{name:r,extension:"excalidraw",description:"Excalidraw file",fileHandle:mE(t.fileHandle)?null:t.fileHandle})}},kF=async(e,t)=>{const n=await fE({description:"Excalidraw files"});return gE(await pE(n),e,t,n.handle)},IF=e=>(e==null?void 0:e.type)===yr.excalidraw&&(!e.elements||Array.isArray(e.elements)&&(!e.appState||typeof e.appState=="object")),tC=e=>typeof e=="object"&&e&&e.type===yr.excalidrawLibrary&&(e.version===1||e.version===2),nC=e=>{const t={type:yr.excalidrawLibrary,version:O1.excalidrawLibrary,source:Fv,libraryItems:e};return JSON.stringify(t,null,2)},CF=async e=>{const t=nC(e);await Bm(new Blob([t],{type:de.excalidrawlib}),{name:"library",extension:"excalidrawlib",description:"Excalidraw library file"})},rC=e=>new Promise((t,n)=>{const r=new Image;r.onload=()=>{t(r)},r.onerror=i=>{n(i)},r.src=e}),iC=async({fileIds:e,files:t,imageCache:n})=>{const r=new Map,i=new Map;return await Promise.all(e.reduce((o,s)=>{const a=t[s];return a&&!r.has(s)?(r.set(s,!0),o.concat((async()=>{try{if(a.mimeType===de.binary)throw new Error("Only images can be added to ImageCache");const l=rC(a.dataURL),c={image:l,mimeType:a.mimeType};n.set(s,c);const u=await l;n.set(s,{...c,image:u})}catch{i.set(s,!0)}})())):o},[])),{imageCache:n,updatedFiles:r,erroredFiles:i}},oC=e=>e.filter(t=>Ft(t)),TF=e=>(e==null?void 0:e.nodeName.toLowerCase())==="svg",MF=async e=>{const t=new DOMParser().parseFromString(e,de.svg),n=t.querySelector("svg");if(t.querySelector("parsererror")||!TF(n))throw new Error("Invalid SVG");if(n.hasAttribute("xmlns")||n.setAttribute("xmlns",Ke),!n.hasAttribute("width")||!n.hasAttribute("height")){const i=n.getAttribute("viewBox");let o=n.getAttribute("width")||"50",s=n.getAttribute("height")||"50";if(i){const a=i.match(/\d+ +\d+ +(\d+) +(\d+)/);a&&([,o,s]=a)}n.setAttribute("width",o),n.setAttribute("height",s)}return n.outerHTML},sC=document.createElement("img");sC.src=`data:${de.svg}, ${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1971c2" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>')}`;const yE=([e,t,n,r],i,o)=>{const s=Az,a=s/o.zoom.value,l=s/o.zoom.value,c=s/o.zoom.value,u=(e+n)/2,d=(t+r)/2,h=(s-8)/(2*o.zoom.value),m=4/o.zoom.value,g=n+m-h,p=t-m-c+h,[v,y]=_e(g+a/2,p+l/2,u,d,i);return[v-a/2,y-l/2,a,l]},aC=(e,t,n,[r,i])=>{const o=4/n.zoom.value,[s,a,l,c]=Ee(e,t),[u,d,h,m]=yE([s,a,l,c],e.angle,n);return r>u-o&&r<u+o+h&&i>d-o&&i<d+m+o},_p=(e,t,n,[r,i],o)=>{if(!e.link||n.selectedElementIds[e.id])return!1;const s=4/n.zoom.value;return!o&&n.viewModeEnabled&&U1(e,t,[r,i],s,null)?!0:aC(e,t,n,[r,i])},Q1=(e,t,n,r,i=!0)=>{e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fill(),i&&e.stroke()},lC=(e,t)=>[e.width/t,e.height/t],cC=({canvas:e,scale:t,normalizedWidth:n,normalizedHeight:r,theme:i,isExporting:o,viewBackgroundColor:s})=>{const a=e.getContext("2d");return a.setTransform(1,0,0,1,0,0),a.scale(t,t),o&&i==="dark"&&(a.filter=$v),typeof s=="string"?((s==="transparent"||s.length===5||s.length===9||/(hsla|rgba)\(/.test(s))&&a.clearRect(0,0,n,r),a.save(),a.fillStyle=s,a.fillRect(0,0,n,r),a.restore()):a.clearRect(0,0,n,r),a},AF=(e,t,n,r,i,o,s)=>{let l;(g=>{g.Bold="#cccccc",g.Regular="#e5e5e5"})(l||(l={}));const c=-Math.round(i.value/t)*t+n%t,u=-Math.round(i.value/t)*t+r%t,d=Math.min(1/i.value,1),h=1/i.value,m=[d*3,h+(d+h)];e.save(),e.lineWidth=d;for(let g=c;g<c+o+t*2;g+=t){const p=Math.round(g-n)%(5*t)===0;e.beginPath(),e.setLineDash(p?[]:m),e.strokeStyle=p?"#cccccc":"#e5e5e5",e.moveTo(g,u-t),e.lineTo(g,u+s+t*2),e.stroke()}for(let g=u;g<u+s+t*2;g+=t){const p=Math.round(g-r)%(5*t)===0;e.beginPath(),e.setLineDash(p?[]:m),e.strokeStyle=p?"#cccccc":"#e5e5e5",e.moveTo(c-t,g),e.lineTo(c+o+t*2,g),e.stroke()}e.restore()},l_=(e,t,n,r)=>{t.translate(e.x+r.scrollX,e.y+r.scrollY),t.beginPath(),t.roundRect?t.roundRect(0,0,e.width,e.height,vt.radius/r.zoom.value):t.rect(0,0,e.width,e.height),t.clip(),t.translate(-(e.x+r.scrollX),-(e.y+r.scrollY))};let Di;const c_=(e,t,n,r)=>{if(e.link&&!n.selectedElementIds[e.id]){const[i,o,s,a]=Ee(e,r),[l,c,u,d]=yE([i,o,s,a],e.angle,n),h=l+u/2,m=c+d/2;if(t.save(),t.translate(n.scrollX+h,n.scrollY+m),t.rotate(e.angle),!Di||Di.zoom!==n.zoom.value){Di=document.createElement("canvas"),Di.zoom=n.zoom.value,Di.width=u*window.devicePixelRatio*n.zoom.value,Di.height=d*window.devicePixelRatio*n.zoom.value;const g=Di.getContext("2d");g.scale(window.devicePixelRatio*n.zoom.value,window.devicePixelRatio*n.zoom.value),g.fillStyle="#fff",g.fillRect(0,0,u,d),g.drawImage(sC,0,0,u,d),g.restore(),t.drawImage(Di,l-h,c-m,u,d)}else t.drawImage(Di,l-h,c-m,u,d);t.restore()}},uC=({canvas:e,rc:t,elementsMap:n,allElementsMap:r,visibleElements:i,scale:o,appState:s,renderConfig:a})=>{if(e===null)return;const{renderGrid:l=!0,isExporting:c}=a,[u,d]=lC(e,o),h=cC({canvas:e,scale:o,normalizedWidth:u,normalizedHeight:d,theme:s.theme,isExporting:c,viewBackgroundColor:s.viewBackgroundColor});h.scale(s.zoom.value,s.zoom.value),l&&s.gridSize&&AF(h,s.gridSize,s.scrollX,s.scrollY,s.zoom,u/s.zoom.value,d/s.zoom.value);const m=new Set;i.forEach(g=>{g.groupIds.length>0&&s.frameToHighlight&&s.selectedElementIds[g.id]&&(Ta(g,s.frameToHighlight,n)||g.groupIds.find(p=>m.has(p)))&&g.groupIds.forEach(p=>m.add(p))}),i.filter(g=>!fr(g)).forEach(g=>{var p;try{if((g.frameId||((p=s.frameToHighlight)==null?void 0:p.id))&&s.frameRendering.enabled&&s.frameRendering.clip){h.save();const y=q2(g,n,s);y&&Ad(g,n,s)&&l_(y,h,a,s),Zh(g,n,r,t,h,a,s),h.restore()}else Zh(g,n,r,t,h,a,s);c||c_(g,h,s,n)}catch(v){console.error(v)}}),i.filter(g=>fr(g)).forEach(g=>{var p;try{const v=()=>{if(Zh(g,n,r,t,h,a,s),fr(g)&&(c||bn(g)&&a.embedsValidationStatus.get(g.id)!==!0)&&g.width&&g.height){const E=KI(g);Zh(E,n,r,t,h,a,s)}c||c_(g,h,s,n)};if((g.frameId||((p=s.frameToHighlight)==null?void 0:p.id))&&s.frameRendering.enabled&&s.frameRendering.clip){h.save();const E=q2(g,n,s);E&&Ad(g,n,s)&&l_(E,h,a,s),v(),h.restore()}else v()}catch(v){console.error(v)}})},dC=F1(e=>{uC(e)},{trailing:!0}),hC=(e,t)=>{if(t){dC(e);return}uC(e)};var xp={VITE_APP_BACKEND_V2_GET_URL:"https://json.excalidraw.com/api/v2/",VITE_APP_BACKEND_V2_POST_URL:"https://json.excalidraw.com/api/v2/post/",VITE_APP_LIBRARY_URL:"https://libraries.excalidraw.com",VITE_APP_LIBRARY_BACKEND:"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries",VITE_APP_PLUS_LP:"https://plus.excalidraw.com",VITE_APP_PLUS_APP:"https://app.excalidraw.com",VITE_APP_AI_BACKEND:"https://oss-ai.excalidraw.com",VITE_APP_WS_SERVER_URL:"https://oss-collab.excalidraw.com",VITE_APP_FIREBASE_CONFIG:'{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}',VITE_APP_DISABLE_TRACKING:"",VITE_APP_GIT_SHA:"",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const LF="<!-- svg-source:excalidraw -->",PF=(e,t)=>{if(e.width<=t)return e;const r=document.createElement("canvas").getContext("2d");r.font=Bt({fontFamily:e.fontFamily,fontSize:e.fontSize});let i=e.text;if(r.measureText(i).width>t)for(let s=i.length;s>0;s--){const a=`${i.slice(0,s)}...`;if(r.measureText(a).width<=t){i=a;break}}return ge(e,{text:i,width:t})},RF=(e,t)=>{const n=[];let r=0,i=0;for(const o of e){if(pe(o)){pd(o)?r++:i++;let s=Sr({x:o.x,y:o.y-vt.nameOffsetY,fontFamily:Xt.Assistant,fontSize:vt.nameFontSize,lineHeight:vt.nameLineHeight,strokeColor:t.exportWithDarkMode?vt.nameColorDarkTheme:vt.nameColorLightTheme,text:AT(o,pd(o)?r:i)});s.y-=s.height,s=PF(s,o.width),n.push(s)}n.push(o)}return n},fC=(e,t)=>(t=t||qr().frameRendering,{enabled:e?!0:t.enabled,outline:e?!1:t.outline,name:e?!1:t.name,clip:e?!0:t.clip}),mC=({elements:e,exportingFrame:t,frameRendering:n,exportWithDarkMode:r})=>{let i;return t?i=PE(e,t):n.enabled&&n.name?i=RF(e,{exportWithDarkMode:r}):i=e,i},gC=async(e,t,n,{exportBackground:r,exportPadding:i=ac,viewBackgroundColor:o,exportingFrame:s},a=(l,c)=>{const u=document.createElement("canvas");return u.width=l*t.exportScale,u.height=c*t.exportScale,{canvas:u,scale:t.exportScale}})=>{const l=fC(s??null,t.frameRendering??null),c=mC({elements:e,exportingFrame:s,exportWithDarkMode:t.exportWithDarkMode,frameRendering:l});s&&(i=0);const[u,d,h,m]=EE(s?[s]:CT(c),i),{canvas:g,scale:p=1}=a(h,m),v=qr(),{imageCache:y}=await iC({imageCache:new Map,fileIds:oC(c).map(E=>E.fileId),files:n});return hC({canvas:g,rc:ws.canvas(g),elementsMap:ma(be(c)),allElementsMap:ma(be(e)),visibleElements:c,scale:p,appState:{...t,frameRendering:l,viewBackgroundColor:r?o:null,scrollX:-u+i,scrollY:-d+i,zoom:v.zoom,shouldCacheIgnoreZoom:!1,theme:t.exportWithDarkMode?"dark":"light"},renderConfig:{canvasBackgroundColor:o,imageCache:y,renderGrid:!1,isExporting:!0,embedsValidationStatus:new Map,elementsPendingErasure:new Set}}),g},vE=async(e,t,n,r)=>{const i=fC((r==null?void 0:r.exportingFrame)??null,t.frameRendering??null);let{exportPadding:o=ac,exportWithDarkMode:s=!1,viewBackgroundColor:a,exportScale:l=1,exportEmbedScene:c}=t;const{exportingFrame:u=null}=r||{},d=mC({elements:e,exportingFrame:u,exportWithDarkMode:s,frameRendering:i});u&&(o=0);let h="";if(c)try{h=await(await ie(()=>Promise.resolve().then(()=>Wm),void 0)).encodeSvgMetadata({text:hc(e,t,n||{},"local")})}catch(A){console.error(A)}const[m,g,p,v]=EE(u?[u]:CT(d),o),y=document.createElementNS(Ke,"svg");y.setAttribute("version","1.1"),y.setAttribute("xmlns",Ke),y.setAttribute("viewBox",`0 0 ${p} ${v}`),y.setAttribute("width",`${p*l}`),y.setAttribute("height",`${v*l}`),s&&y.setAttribute("filter",$v);let E="https://excalidraw.com/";xp.VITE_IS_EXCALIDRAW_NPM_PACKAGE&&(E=window.EXCALIDRAW_ASSET_PATH||`https://unpkg.com/${xp.VITE_PKG_NAME}@${xp.PKG_VERSION}`,E!=null&&E.startsWith("/")&&(E=E.replace("/",`${window.location.origin}/`)),E=`${E}/dist/excalidraw-assets/`);const w=-m+o,x=-g+o,C=LE(e);let S="";const I=be(e);for(const A of C){const[F,P,O,V]=Ee(A,I),G=(O-F)/2-(A.x-F),q=(V-P)/2-(A.y-P);S+=`<clipPath id=${A.id}>
<rect transform="translate(${A.x+w} ${A.y+x}) rotate(${A.angle} ${G} ${q})"
width="${A.width}"
height="${A.height}"
>
</rect>
</clipPath>`}if(y.innerHTML=`
${LF}
${h}
<defs>
<style class="style-fonts">
@font-face {
font-family: "Virgil";
src: url("${E}Virgil.woff2");
}
@font-face {
font-family: "Cascadia";
src: url("${E}Cascadia.woff2");
}
@font-face {
font-family: "Assistant";
src: url("${E}Assistant-Regular.woff2");
}
</style>
${S}
</defs>
`,t.exportBackground&&a){const A=y.ownerDocument.createElementNS(Ke,"rect");A.setAttribute("x","0"),A.setAttribute("y","0"),A.setAttribute("width",`${p}`),A.setAttribute("height",`${v}`),A.setAttribute("fill",a),y.appendChild(A)}const T=ws.svg(y),L=(r==null?void 0:r.renderEmbeddables)??!1;return iF(d,ma(be(d)),T,y,n||{},{offsetX:w,offsetY:x,isExporting:!0,exportWithDarkMode:s,renderEmbeddables:L,frameRendering:i,canvasBackgroundColor:a,embedsValidationStatus:L?new Map(d.filter(A=>pe(A)).map(A=>[A.id,!0])):new Map}),y},EE=(e,t)=>{const[n,r,i,o]=nt(e),s=un(n,i)+t*2,a=un(r,o)+t*2;return[n,r,s,a]},DF=(e,t,n)=>{const[,,r,i]=EE(e,t).map(o=>Math.trunc(o*n));return[r,i]};var wE={};(function(e){(function(t){t(typeof DO_NOT_EXPORT_CRC>"u"?e:{})})(function(t){t.version="0.3.0";function n(){for(var c=0,u=new Array(256),d=0;d!=256;++d)c=d,c=c&1?-306674912^c>>>1:c>>>1,c=c&1?-306674912^c>>>1:c>>>1,c=c&1?-306674912^c>>>1:c>>>1,c=c&1?-306674912^c>>>1:c>>>1,c=c&1?-306674912^c>>>1:c>>>1,c=c&1?-306674912^c>>>1:c>>>1,c=c&1?-306674912^c>>>1:c>>>1,c=c&1?-306674912^c>>>1:c>>>1,u[d]=c;return typeof Int32Array<"u"?new Int32Array(u):u}var r=n(),i=typeof Buffer<"u";function o(c){if(c.length>32768&&i)return a(new Buffer(c));for(var u=-1,d=c.length-1,h=0;h<d;)u=r[(u^c.charCodeAt(h++))&255]^u>>>8,u=r[(u^c.charCodeAt(h++))&255]^u>>>8;return h===d&&(u=u>>>8^r[(u^c.charCodeAt(h))&255]),u^-1}function s(c){if(c.length>1e4)return a(c);for(var u=-1,d=0,h=c.length-3;d<h;)u=u>>>8^r[(u^c[d++])&255],u=u>>>8^r[(u^c[d++])&255],u=u>>>8^r[(u^c[d++])&255],u=u>>>8^r[(u^c[d++])&255];for(;d<h+3;)u=u>>>8^r[(u^c[d++])&255];return u^-1}function a(c){for(var u=-1,d=0,h=c.length-7;d<h;)u=u>>>8^r[(u^c[d++])&255],u=u>>>8^r[(u^c[d++])&255],u=u>>>8^r[(u^c[d++])&255],u=u>>>8^r[(u^c[d++])&255],u=u>>>8^r[(u^c[d++])&255],u=u>>>8^r[(u^c[d++])&255],u=u>>>8^r[(u^c[d++])&255],u=u>>>8^r[(u^c[d++])&255];for(;d<h+7;)u=u>>>8^r[(u^c[d++])&255];return u^-1}function l(c){for(var u=-1,d=0,h=c.length,m,g;d<h;)m=c.charCodeAt(d++),m<128?u=u>>>8^r[(u^m)&255]:m<2048?(u=u>>>8^r[(u^(192|m>>6&31))&255],u=u>>>8^r[(u^(128|m&63))&255]):m>=55296&&m<57344?(m=(m&1023)+64,g=c.charCodeAt(d++)&1023,u=u>>>8^r[(u^(240|m>>8&7))&255],u=u>>>8^r[(u^(128|m>>2&63))&255],u=u>>>8^r[(u^(128|g>>6&15|m&3))&255],u=u>>>8^r[(u^(128|g&63))&255]):(u=u>>>8^r[(u^(224|m>>12&15))&255],u=u>>>8^r[(u^(128|m>>6&63))&255],u=u>>>8^r[(u^(128|m&63))&255]);return u^-1}t.table=r,t.bstr=o,t.buf=s,t.str=l})})(wE);var OF=wE,NF=BF,hi=new Uint8Array(4),FF=new Int32Array(hi.buffer),$F=new Uint32Array(hi.buffer);function BF(e){if(e[0]!==137)throw new Error("Invalid .png file header");if(e[1]!==80)throw new Error("Invalid .png file header");if(e[2]!==78)throw new Error("Invalid .png file header");if(e[3]!==71)throw new Error("Invalid .png file header");if(e[4]!==13)throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");if(e[5]!==10)throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");if(e[6]!==26)throw new Error("Invalid .png file header");if(e[7]!==10)throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");for(var t=!1,n=[],r=8;r<e.length;){hi[3]=e[r++],hi[2]=e[r++],hi[1]=e[r++],hi[0]=e[r++];var i=$F[0]+4,o=new Uint8Array(i);o[0]=e[r++],o[1]=e[r++],o[2]=e[r++],o[3]=e[r++];var s=String.fromCharCode(o[0])+String.fromCharCode(o[1])+String.fromCharCode(o[2])+String.fromCharCode(o[3]);if(!n.length&&s!=="IHDR")throw new Error("IHDR header missing");if(s==="IEND"){t=!0,n.push({name:s,data:new Uint8Array(0)});break}for(var a=4;a<i;a++)o[a]=e[r++];hi[3]=e[r++],hi[2]=e[r++],hi[1]=e[r++],hi[0]=e[r++];var l=FF[0],c=OF.buf(o);if(c!==l)throw new Error("CRC values for "+s+" header do not match, PNG file is likely corrupted");var u=new Uint8Array(o.buffer.slice(4));n.push({name:s,data:u})}if(!t)throw new Error(".png file ended prematurely: no IEND header was found");return n}const pC=rc(NF);var J1={},zF=HF;function HF(e,t){if(e=String(e),t=String(t),!/^[\x00-\xFF]+$/.test(e)||!/^[\x00-\xFF]+$/.test(t))throw new Error("Only Latin-1 characters are permitted in PNG tEXt chunks. You might want to consider base64 encoding and/or zEXt compression");if(e.length>=80)throw new Error('Keyword "'+e+'" is longer than the 79-character limit imposed by the PNG specification');for(var n=e.length+t.length+1,r=new Uint8Array(n),i=0,o,s=0;s<e.length;s++){if(!(o=e.charCodeAt(s)))throw new Error("0x00 character is not permitted in tEXt keywords");r[i++]=o}r[i++]=0;for(var a=0;a<t.length;a++){if(!(o=t.charCodeAt(a)))throw new Error("0x00 character is not permitted in tEXt content");r[i++]=o}return{name:"tEXt",data:r}}var UF=WF;function WF(e){e.data&&e.name&&(e=e.data);for(var t=!0,n="",r="",i=0;i<e.length;i++){var o=e[i];if(t)o?r+=String.fromCharCode(o):t=!1;else if(o)n+=String.fromCharCode(o);else throw new Error("Invalid NULL character found. 0x00 character is not permitted in tEXt content")}return{keyword:r,text:n}}J1.encode=zF;J1.decode=UF;var VF=function(e,t,n){var r=[],i=e.length;if(i===0)return r;var o=t<0?Math.max(0,t+i):t||0;for(n!==void 0&&(i=n<0?n+i:n);i-- >o;)r[i-o]=e[i];return r},GF=VF,jF=wE,YF=XF,fi=new Uint8Array(4),KF=new Int32Array(fi.buffer),ZF=new Uint32Array(fi.buffer);function XF(e){var t=8,n=t,r;for(r=0;r<e.length;r++)t+=e[r].data.length,t+=12;var i=new Uint8Array(t);for(i[0]=137,i[1]=80,i[2]=78,i[3]=71,i[4]=13,i[5]=10,i[6]=26,i[7]=10,r=0;r<e.length;r++){var o=e[r],s=o.name,a=o.data,l=a.length,c=[s.charCodeAt(0),s.charCodeAt(1),s.charCodeAt(2),s.charCodeAt(3)];ZF[0]=l,i[n++]=fi[3],i[n++]=fi[2],i[n++]=fi[1],i[n++]=fi[0],i[n++]=c[0],i[n++]=c[1],i[n++]=c[2],i[n++]=c[3];for(var u=0;u<l;)i[n++]=a[u++];var d=c.concat(GF(a)),h=jF.buf(d);KF[0]=h,i[n++]=fi[3],i[n++]=fi[2],i[n++]=fi[1],i[n++]=fi[0]}return i}const qF=rc(YF);var ao={};(function(e){var t=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function n(o,s){return Object.prototype.hasOwnProperty.call(o,s)}e.assign=function(o){for(var s=Array.prototype.slice.call(arguments,1);s.length;){var a=s.shift();if(a){if(typeof a!="object")throw new TypeError(a+"must be non-object");for(var l in a)n(a,l)&&(o[l]=a[l])}}return o},e.shrinkBuf=function(o,s){return o.length===s?o:o.subarray?o.subarray(0,s):(o.length=s,o)};var r={arraySet:function(o,s,a,l,c){if(s.subarray&&o.subarray){o.set(s.subarray(a,a+l),c);return}for(var u=0;u<l;u++)o[c+u]=s[a+u]},flattenChunks:function(o){var s,a,l,c,u,d;for(l=0,s=0,a=o.length;s<a;s++)l+=o[s].length;for(d=new Uint8Array(l),c=0,s=0,a=o.length;s<a;s++)u=o[s],d.set(u,c),c+=u.length;return d}},i={arraySet:function(o,s,a,l,c){for(var u=0;u<l;u++)o[c+u]=s[a+u]},flattenChunks:function(o){return[].concat.apply([],o)}};e.setTyped=function(o){o?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,r)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)})(ao);var rh={},Ai={},fc={},QF=ao,JF=4,u_=0,d_=1,e$=2;function mc(e){for(var t=e.length;--t>=0;)e[t]=0}var t$=0,yC=1,n$=2,r$=3,i$=258,bE=29,ih=256,xd=ih+1+bE,Al=30,_E=19,vC=2*xd+1,Ys=15,Sp=16,o$=7,xE=256,EC=16,wC=17,bC=18,U2=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Df=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],s$=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],_C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],a$=512,Bi=new Array((xd+2)*2);mc(Bi);var Pu=new Array(Al*2);mc(Pu);var Sd=new Array(a$);mc(Sd);var kd=new Array(i$-r$+1);mc(kd);var SE=new Array(bE);mc(SE);var zm=new Array(Al);mc(zm);function kp(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}var xC,SC,kC;function Ip(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function IC(e){return e<256?Sd[e]:Sd[256+(e>>>7)]}function Id(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function Dn(e,t,n){e.bi_valid>Sp-n?(e.bi_buf|=t<<e.bi_valid&65535,Id(e,e.bi_buf),e.bi_buf=t>>Sp-e.bi_valid,e.bi_valid+=n-Sp):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function yi(e,t,n){Dn(e,n[t*2],n[t*2+1])}function CC(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function l$(e){e.bi_valid===16?(Id(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function c$(e,t){var n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length,c,u,d,h,m,g,p=0;for(h=0;h<=Ys;h++)e.bl_count[h]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<vC;c++)u=e.heap[c],h=n[n[u*2+1]*2+1]+1,h>l&&(h=l,p++),n[u*2+1]=h,!(u>r)&&(e.bl_count[h]++,m=0,u>=a&&(m=s[u-a]),g=n[u*2],e.opt_len+=g*(h+m),o&&(e.static_len+=g*(i[u*2+1]+m)));if(p!==0){do{for(h=l-1;e.bl_count[h]===0;)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[l]--,p-=2}while(p>0);for(h=l;h!==0;h--)for(u=e.bl_count[h];u!==0;)d=e.heap[--c],!(d>r)&&(n[d*2+1]!==h&&(e.opt_len+=(h-n[d*2+1])*n[d*2],n[d*2+1]=h),u--)}}function TC(e,t,n){var r=new Array(Ys+1),i=0,o,s;for(o=1;o<=Ys;o++)r[o]=i=i+n[o-1]<<1;for(s=0;s<=t;s++){var a=e[s*2+1];a!==0&&(e[s*2]=CC(r[a]++,a))}}function u$(){var e,t,n,r,i,o=new Array(Ys+1);for(n=0,r=0;r<bE-1;r++)for(SE[r]=n,e=0;e<1<<U2[r];e++)kd[n++]=r;for(kd[n-1]=r,i=0,r=0;r<16;r++)for(zm[r]=i,e=0;e<1<<Df[r];e++)Sd[i++]=r;for(i>>=7;r<Al;r++)for(zm[r]=i<<7,e=0;e<1<<Df[r]-7;e++)Sd[256+i++]=r;for(t=0;t<=Ys;t++)o[t]=0;for(e=0;e<=143;)Bi[e*2+1]=8,e++,o[8]++;for(;e<=255;)Bi[e*2+1]=9,e++,o[9]++;for(;e<=279;)Bi[e*2+1]=7,e++,o[7]++;for(;e<=287;)Bi[e*2+1]=8,e++,o[8]++;for(TC(Bi,xd+1,o),e=0;e<Al;e++)Pu[e*2+1]=5,Pu[e*2]=CC(e,5);xC=new kp(Bi,U2,ih+1,xd,Ys),SC=new kp(Pu,Df,0,Al,Ys),kC=new kp(new Array(0),s$,0,_E,o$)}function MC(e){var t;for(t=0;t<xd;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Al;t++)e.dyn_dtree[t*2]=0;for(t=0;t<_E;t++)e.bl_tree[t*2]=0;e.dyn_ltree[xE*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function AC(e){e.bi_valid>8?Id(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function d$(e,t,n,r){AC(e),r&&(Id(e,n),Id(e,~n)),QF.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function h_(e,t,n,r){var i=t*2,o=n*2;return e[i]<e[o]||e[i]===e[o]&&r[t]<=r[n]}function Cp(e,t,n){for(var r=e.heap[n],i=n<<1;i<=e.heap_len&&(i<e.heap_len&&h_(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!h_(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r}function f_(e,t,n){var r,i,o=0,s,a;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+o*2]<<8|e.pending_buf[e.d_buf+o*2+1],i=e.pending_buf[e.l_buf+o],o++,r===0?yi(e,i,t):(s=kd[i],yi(e,s+ih+1,t),a=U2[s],a!==0&&(i-=SE[s],Dn(e,i,a)),r--,s=IC(r),yi(e,s,n),a=Df[s],a!==0&&(r-=zm[s],Dn(e,r,a)));while(o<e.last_lit);yi(e,xE,t)}function W2(e,t){var n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems,s,a,l=-1,c;for(e.heap_len=0,e.heap_max=vC,s=0;s<o;s++)n[s*2]!==0?(e.heap[++e.heap_len]=l=s,e.depth[s]=0):n[s*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=l<2?++l:0,n[c*2]=1,e.depth[c]=0,e.opt_len--,i&&(e.static_len-=r[c*2+1]);for(t.max_code=l,s=e.heap_len>>1;s>=1;s--)Cp(e,n,s);c=o;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Cp(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,n[c*2]=n[s*2]+n[a*2],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,n[s*2+1]=n[a*2+1]=c,e.heap[1]=c++,Cp(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],c$(e,t),TC(n,l,e.bl_count)}function m_(e,t,n){var r,i=-1,o,s=t[0*2+1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)o=s,s=t[(r+1)*2+1],!(++a<l&&o===s)&&(a<c?e.bl_tree[o*2]+=a:o!==0?(o!==i&&e.bl_tree[o*2]++,e.bl_tree[EC*2]++):a<=10?e.bl_tree[wC*2]++:e.bl_tree[bC*2]++,a=0,i=o,s===0?(l=138,c=3):o===s?(l=6,c=3):(l=7,c=4))}function g_(e,t,n){var r,i=-1,o,s=t[0*2+1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),r=0;r<=n;r++)if(o=s,s=t[(r+1)*2+1],!(++a<l&&o===s)){if(a<c)do yi(e,o,e.bl_tree);while(--a!==0);else o!==0?(o!==i&&(yi(e,o,e.bl_tree),a--),yi(e,EC,e.bl_tree),Dn(e,a-3,2)):a<=10?(yi(e,wC,e.bl_tree),Dn(e,a-3,3)):(yi(e,bC,e.bl_tree),Dn(e,a-11,7));a=0,i=o,s===0?(l=138,c=3):o===s?(l=6,c=3):(l=7,c=4)}}function h$(e){var t;for(m_(e,e.dyn_ltree,e.l_desc.max_code),m_(e,e.dyn_dtree,e.d_desc.max_code),W2(e,e.bl_desc),t=_E-1;t>=3&&e.bl_tree[_C[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function f$(e,t,n,r){var i;for(Dn(e,t-257,5),Dn(e,n-1,5),Dn(e,r-4,4),i=0;i<r;i++)Dn(e,e.bl_tree[_C[i]*2+1],3);g_(e,e.dyn_ltree,t-1),g_(e,e.dyn_dtree,n-1)}function m$(e){var t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return u_;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return d_;for(n=32;n<ih;n++)if(e.dyn_ltree[n*2]!==0)return d_;return u_}var p_=!1;function g$(e){p_||(u$(),p_=!0),e.l_desc=new Ip(e.dyn_ltree,xC),e.d_desc=new Ip(e.dyn_dtree,SC),e.bl_desc=new Ip(e.bl_tree,kC),e.bi_buf=0,e.bi_valid=0,MC(e)}function LC(e,t,n,r){Dn(e,(t$<<1)+(r?1:0),3),d$(e,t,n,!0)}function p$(e){Dn(e,yC<<1,3),yi(e,xE,Bi),l$(e)}function y$(e,t,n,r){var i,o,s=0;e.level>0?(e.strm.data_type===e$&&(e.strm.data_type=m$(e)),W2(e,e.l_desc),W2(e,e.d_desc),s=h$(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=n+5,n+4<=i&&t!==-1?LC(e,t,n,r):e.strategy===JF||o===i?(Dn(e,(yC<<1)+(r?1:0),3),f_(e,Bi,Pu)):(Dn(e,(n$<<1)+(r?1:0),3),f$(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),f_(e,e.dyn_ltree,e.dyn_dtree)),MC(e),r&&AC(e)}function v$(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(kd[n]+ih+1)*2]++,e.dyn_dtree[IC(t)*2]++),e.last_lit===e.lit_bufsize-1}fc._tr_init=g$;fc._tr_stored_block=LC;fc._tr_flush_block=y$;fc._tr_tally=v$;fc._tr_align=p$;function E$(e,t,n,r){for(var i=e&65535|0,o=e>>>16&65535|0,s=0;n!==0;){s=n>2e3?2e3:n,n-=s;do i=i+t[r++]|0,o=o+i|0;while(--s);i%=65521,o%=65521}return i|o<<16|0}var PC=E$;function w$(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var b$=w$();function _$(e,t,n,r){var i=b$,o=r+n;e^=-1;for(var s=r;s<o;s++)e=e>>>8^i[(e^t[s])&255];return e^-1}var RC=_$,kE={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},xn=ao,vr=fc,DC=PC,go=RC,x$=kE,Oa=0,S$=1,k$=3,Jo=4,y_=5,vi=0,v_=1,Er=-2,I$=-3,Tp=-5,C$=-1,T$=1,Vh=2,M$=3,A$=4,L$=0,P$=2,eg=8,R$=9,D$=15,O$=8,N$=29,F$=256,V2=F$+1+N$,$$=30,B$=19,z$=2*V2+1,H$=15,Le=3,$o=258,jr=$o+Le+1,U$=32,tg=42,G2=69,Of=73,Nf=91,Ff=103,Ks=113,hu=666,Dt=1,oh=2,xa=3,gc=4,W$=3;function Bo(e,t){return e.msg=x$[t],t}function E_(e){return(e<<1)-(e>4?9:0)}function Co(e){for(var t=e.length;--t>=0;)e[t]=0}function po(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(xn.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function qt(e,t){vr._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,po(e.strm)}function Oe(e,t){e.pending_buf[e.pending++]=t}function Gc(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function V$(e,t,n,r){var i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,xn.arraySet(t,e.input,e.next_in,i,n),e.state.wrap===1?e.adler=DC(e.adler,t,i,n):e.state.wrap===2&&(e.adler=go(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)}function OC(e,t){var n=e.max_chain_length,r=e.strstart,i,o,s=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-jr?e.strstart-(e.w_size-jr):0,c=e.window,u=e.w_mask,d=e.prev,h=e.strstart+$o,m=c[r+s-1],g=c[r+s];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do if(i=t,!(c[i+s]!==g||c[i+s-1]!==m||c[i]!==c[r]||c[++i]!==c[r+1])){r+=2,i++;do;while(c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&r<h);if(o=$o-(h-r),r=h-$o,o>s){if(e.match_start=t,s=o,o>=a)break;m=c[r+s-1],g=c[r+s]}}while((t=d[t&u])>l&&--n!==0);return s<=e.lookahead?s:e.lookahead}function Sa(e){var t=e.w_size,n,r,i,o,s;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-jr)){xn.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do i=e.head[--n],e.head[n]=i>=t?i-t:0;while(--r);r=t,n=r;do i=e.prev[--n],e.prev[n]=i>=t?i-t:0;while(--r);o+=t}if(e.strm.avail_in===0)break;if(r=V$(e.strm,e.window,e.strstart+e.lookahead,o),e.lookahead+=r,e.lookahead+e.insert>=Le)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+Le-1])&e.hash_mask,e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<Le)););}while(e.lookahead<jr&&e.strm.avail_in!==0)}function G$(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Sa(e),e.lookahead===0&&t===Oa)return Dt;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,qt(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-jr&&(qt(e,!1),e.strm.avail_out===0))return Dt}return e.insert=0,t===Jo?(qt(e,!0),e.strm.avail_out===0?xa:gc):(e.strstart>e.block_start&&(qt(e,!1),e.strm.avail_out===0),Dt)}function Mp(e,t){for(var n,r;;){if(e.lookahead<jr){if(Sa(e),e.lookahead<jr&&t===Oa)return Dt;if(e.lookahead===0)break}if(n=0,e.lookahead>=Le&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Le-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-jr&&(e.match_length=OC(e,n)),e.match_length>=Le)if(r=vr._tr_tally(e,e.strstart-e.match_start,e.match_length-Le),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Le){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Le-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=vr._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(qt(e,!1),e.strm.avail_out===0))return Dt}return e.insert=e.strstart<Le-1?e.strstart:Le-1,t===Jo?(qt(e,!0),e.strm.avail_out===0?xa:gc):e.last_lit&&(qt(e,!1),e.strm.avail_out===0)?Dt:oh}function Va(e,t){for(var n,r,i;;){if(e.lookahead<jr){if(Sa(e),e.lookahead<jr&&t===Oa)return Dt;if(e.lookahead===0)break}if(n=0,e.lookahead>=Le&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Le-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Le-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-jr&&(e.match_length=OC(e,n),e.match_length<=5&&(e.strategy===T$||e.match_length===Le&&e.strstart-e.match_start>4096)&&(e.match_length=Le-1)),e.prev_length>=Le&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-Le,r=vr._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-Le),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+Le-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Le-1,e.strstart++,r&&(qt(e,!1),e.strm.avail_out===0))return Dt}else if(e.match_available){if(r=vr._tr_tally(e,0,e.window[e.strstart-1]),r&&qt(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Dt}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=vr._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Le-1?e.strstart:Le-1,t===Jo?(qt(e,!0),e.strm.avail_out===0?xa:gc):e.last_lit&&(qt(e,!1),e.strm.avail_out===0)?Dt:oh}function j$(e,t){for(var n,r,i,o,s=e.window;;){if(e.lookahead<=$o){if(Sa(e),e.lookahead<=$o&&t===Oa)return Dt;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Le&&e.strstart>0&&(i=e.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){o=e.strstart+$o;do;while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&i<o);e.match_length=$o-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Le?(n=vr._tr_tally(e,1,e.match_length-Le),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=vr._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(qt(e,!1),e.strm.avail_out===0))return Dt}return e.insert=0,t===Jo?(qt(e,!0),e.strm.avail_out===0?xa:gc):e.last_lit&&(qt(e,!1),e.strm.avail_out===0)?Dt:oh}function Y$(e,t){for(var n;;){if(e.lookahead===0&&(Sa(e),e.lookahead===0)){if(t===Oa)return Dt;break}if(e.match_length=0,n=vr._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(qt(e,!1),e.strm.avail_out===0))return Dt}return e.insert=0,t===Jo?(qt(e,!0),e.strm.avail_out===0?xa:gc):e.last_lit&&(qt(e,!1),e.strm.avail_out===0)?Dt:oh}function si(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}var vl;vl=[new si(0,0,0,0,G$),new si(4,4,8,4,Mp),new si(4,5,16,8,Mp),new si(4,6,32,32,Mp),new si(4,4,16,16,Va),new si(8,16,32,32,Va),new si(8,16,128,128,Va),new si(8,32,128,256,Va),new si(32,128,258,1024,Va),new si(32,258,258,4096,Va)];function K$(e){e.window_size=2*e.w_size,Co(e.head),e.max_lazy_match=vl[e.level].max_lazy,e.good_match=vl[e.level].good_length,e.nice_match=vl[e.level].nice_length,e.max_chain_length=vl[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Le-1,e.match_available=0,e.ins_h=0}function Z$(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=eg,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new xn.Buf16(z$*2),this.dyn_dtree=new xn.Buf16((2*$$+1)*2),this.bl_tree=new xn.Buf16((2*B$+1)*2),Co(this.dyn_ltree),Co(this.dyn_dtree),Co(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new xn.Buf16(H$+1),this.heap=new xn.Buf16(2*V2+1),Co(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new xn.Buf16(2*V2+1),Co(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function NC(e){var t;return!e||!e.state?Bo(e,Er):(e.total_in=e.total_out=0,e.data_type=P$,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?tg:Ks,e.adler=t.wrap===2?0:1,t.last_flush=Oa,vr._tr_init(t),vi)}function FC(e){var t=NC(e);return t===vi&&K$(e.state),t}function X$(e,t){return!e||!e.state||e.state.wrap!==2?Er:(e.state.gzhead=t,vi)}function $C(e,t,n,r,i,o){if(!e)return Er;var s=1;if(t===C$&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>R$||n!==eg||r<8||r>15||t<0||t>9||o<0||o>A$)return Bo(e,Er);r===8&&(r=9);var a=new Z$;return e.state=a,a.strm=e,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+Le-1)/Le),a.window=new xn.Buf8(a.w_size*2),a.head=new xn.Buf16(a.hash_size),a.prev=new xn.Buf16(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new xn.Buf8(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=t,a.strategy=o,a.method=n,FC(e)}function q$(e,t){return $C(e,t,eg,D$,O$,L$)}function Q$(e,t){var n,r,i,o;if(!e||!e.state||t>y_||t<0)return e?Bo(e,Er):Er;if(r=e.state,!e.output||!e.input&&e.avail_in!==0||r.status===hu&&t!==Jo)return Bo(e,e.avail_out===0?Tp:Er);if(r.strm=e,n=r.last_flush,r.last_flush=t,r.status===tg)if(r.wrap===2)e.adler=0,Oe(r,31),Oe(r,139),Oe(r,8),r.gzhead?(Oe(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Oe(r,r.gzhead.time&255),Oe(r,r.gzhead.time>>8&255),Oe(r,r.gzhead.time>>16&255),Oe(r,r.gzhead.time>>24&255),Oe(r,r.level===9?2:r.strategy>=Vh||r.level<2?4:0),Oe(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(Oe(r,r.gzhead.extra.length&255),Oe(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=go(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=G2):(Oe(r,0),Oe(r,0),Oe(r,0),Oe(r,0),Oe(r,0),Oe(r,r.level===9?2:r.strategy>=Vh||r.level<2?4:0),Oe(r,W$),r.status=Ks);else{var s=eg+(r.w_bits-8<<4)<<8,a=-1;r.strategy>=Vh||r.level<2?a=0:r.level<6?a=1:r.level===6?a=2:a=3,s|=a<<6,r.strstart!==0&&(s|=U$),s+=31-s%31,r.status=Ks,Gc(r,s),r.strstart!==0&&(Gc(r,e.adler>>>16),Gc(r,e.adler&65535)),e.adler=1}if(r.status===G2)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(r.gzhead.extra.length&65535)&&!(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=go(e.adler,r.pending_buf,r.pending-i,i)),po(e),i=r.pending,r.pending===r.pending_buf_size));)Oe(r,r.gzhead.extra[r.gzindex]&255),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(e.adler=go(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=Of)}else r.status=Of;if(r.status===Of)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=go(e.adler,r.pending_buf,r.pending-i,i)),po(e),i=r.pending,r.pending===r.pending_buf_size)){o=1;break}r.gzindex<r.gzhead.name.length?o=r.gzhead.name.charCodeAt(r.gzindex++)&255:o=0,Oe(r,o)}while(o!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=go(e.adler,r.pending_buf,r.pending-i,i)),o===0&&(r.gzindex=0,r.status=Nf)}else r.status=Nf;if(r.status===Nf)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=go(e.adler,r.pending_buf,r.pending-i,i)),po(e),i=r.pending,r.pending===r.pending_buf_size)){o=1;break}r.gzindex<r.gzhead.comment.length?o=r.gzhead.comment.charCodeAt(r.gzindex++)&255:o=0,Oe(r,o)}while(o!==0);r.gzhead.hcrc&&r.pending>i&&(e.adler=go(e.adler,r.pending_buf,r.pending-i,i)),o===0&&(r.status=Ff)}else r.status=Ff;if(r.status===Ff&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&po(e),r.pending+2<=r.pending_buf_size&&(Oe(r,e.adler&255),Oe(r,e.adler>>8&255),e.adler=0,r.status=Ks)):r.status=Ks),r.pending!==0){if(po(e),e.avail_out===0)return r.last_flush=-1,vi}else if(e.avail_in===0&&E_(t)<=E_(n)&&t!==Jo)return Bo(e,Tp);if(r.status===hu&&e.avail_in!==0)return Bo(e,Tp);if(e.avail_in!==0||r.lookahead!==0||t!==Oa&&r.status!==hu){var l=r.strategy===Vh?Y$(r,t):r.strategy===M$?j$(r,t):vl[r.level].func(r,t);if((l===xa||l===gc)&&(r.status=hu),l===Dt||l===xa)return e.avail_out===0&&(r.last_flush=-1),vi;if(l===oh&&(t===S$?vr._tr_align(r):t!==y_&&(vr._tr_stored_block(r,0,0,!1),t===k$&&(Co(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),po(e),e.avail_out===0))return r.last_flush=-1,vi}return t!==Jo?vi:r.wrap<=0?v_:(r.wrap===2?(Oe(r,e.adler&255),Oe(r,e.adler>>8&255),Oe(r,e.adler>>16&255),Oe(r,e.adler>>24&255),Oe(r,e.total_in&255),Oe(r,e.total_in>>8&255),Oe(r,e.total_in>>16&255),Oe(r,e.total_in>>24&255)):(Gc(r,e.adler>>>16),Gc(r,e.adler&65535)),po(e),r.wrap>0&&(r.wrap=-r.wrap),r.pending!==0?vi:v_)}function J$(e){var t;return!e||!e.state?Er:(t=e.state.status,t!==tg&&t!==G2&&t!==Of&&t!==Nf&&t!==Ff&&t!==Ks&&t!==hu?Bo(e,Er):(e.state=null,t===Ks?Bo(e,I$):vi))}function eB(e,t){var n=t.length,r,i,o,s,a,l,c,u;if(!e||!e.state||(r=e.state,s=r.wrap,s===2||s===1&&r.status!==tg||r.lookahead))return Er;for(s===1&&(e.adler=DC(e.adler,t,n,0)),r.wrap=0,n>=r.w_size&&(s===0&&(Co(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new xn.Buf8(r.w_size),xn.arraySet(u,t,n-r.w_size,r.w_size,0),t=u,n=r.w_size),a=e.avail_in,l=e.next_in,c=e.input,e.avail_in=n,e.next_in=0,e.input=t,Sa(r);r.lookahead>=Le;){i=r.strstart,o=r.lookahead-(Le-1);do r.ins_h=(r.ins_h<<r.hash_shift^r.window[i+Le-1])&r.hash_mask,r.prev[i&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=i,i++;while(--o);r.strstart=i,r.lookahead=Le-1,Sa(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=Le-1,r.match_available=0,e.next_in=l,e.input=c,e.avail_in=a,r.wrap=s,vi}Ai.deflateInit=q$;Ai.deflateInit2=$C;Ai.deflateReset=FC;Ai.deflateResetKeep=NC;Ai.deflateSetHeader=X$;Ai.deflate=Q$;Ai.deflateEnd=J$;Ai.deflateSetDictionary=eB;Ai.deflateInfo="pako deflate (from Nodeca project)";var Na={},ng=ao,BC=!0,zC=!0;try{String.fromCharCode.apply(null,[0])}catch{BC=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{zC=!1}var Cd=new ng.Buf8(256);for(var fo=0;fo<256;fo++)Cd[fo]=fo>=252?6:fo>=248?5:fo>=240?4:fo>=224?3:fo>=192?2:1;Cd[254]=Cd[254]=1;Na.string2buf=function(e){var t,n,r,i,o,s=e.length,a=0;for(i=0;i<s;i++)n=e.charCodeAt(i),(n&64512)===55296&&i+1<s&&(r=e.charCodeAt(i+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(t=new ng.Buf8(a),o=0,i=0;o<a;i++)n=e.charCodeAt(i),(n&64512)===55296&&i+1<s&&(r=e.charCodeAt(i+1),(r&64512)===56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?t[o++]=n:n<2048?(t[o++]=192|n>>>6,t[o++]=128|n&63):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|n&63):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|n&63);return t};function HC(e,t){if(t<65534&&(e.subarray&&zC||!e.subarray&&BC))return String.fromCharCode.apply(null,ng.shrinkBuf(e,t));for(var n="",r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n}Na.buf2binstring=function(e){return HC(e,e.length)};Na.binstring2buf=function(e){for(var t=new ng.Buf8(e.length),n=0,r=t.length;n<r;n++)t[n]=e.charCodeAt(n);return t};Na.buf2string=function(e,t){var n,r,i,o,s=t||e.length,a=new Array(s*2);for(r=0,n=0;n<s;){if(i=e[n++],i<128){a[r++]=i;continue}if(o=Cd[i],o>4){a[r++]=65533,n+=o-1;continue}for(i&=o===2?31:o===3?15:7;o>1&&n<s;)i=i<<6|e[n++]&63,o--;if(o>1){a[r++]=65533;continue}i<65536?a[r++]=i:(i-=65536,a[r++]=55296|i>>10&1023,a[r++]=56320|i&1023)}return HC(a,r)};Na.utf8border=function(e,t){var n;for(t=t||e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+Cd[e[n]]>t?n:t};function tB(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var UC=tB,Ru=Ai,Du=ao,j2=Na,Y2=kE,nB=UC,WC=Object.prototype.toString,rB=0,Ap=4,Ll=0,w_=1,b_=2,iB=-1,oB=0,sB=8;function ka(e){if(!(this instanceof ka))return new ka(e);this.options=Du.assign({level:iB,method:sB,chunkSize:16384,windowBits:15,memLevel:8,strategy:oB,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new nB,this.strm.avail_out=0;var n=Ru.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Ll)throw new Error(Y2[n]);if(t.header&&Ru.deflateSetHeader(this.strm,t.header),t.dictionary){var r;if(typeof t.dictionary=="string"?r=j2.string2buf(t.dictionary):WC.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=Ru.deflateSetDictionary(this.strm,r),n!==Ll)throw new Error(Y2[n]);this._dict_set=!0}}ka.prototype.push=function(e,t){var n=this.strm,r=this.options.chunkSize,i,o;if(this.ended)return!1;o=t===~~t?t:t===!0?Ap:rB,typeof e=="string"?n.input=j2.string2buf(e):WC.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new Du.Buf8(r),n.next_out=0,n.avail_out=r),i=Ru.deflate(n,o),i!==w_&&i!==Ll)return this.onEnd(i),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(o===Ap||o===b_))&&(this.options.to==="string"?this.onData(j2.buf2binstring(Du.shrinkBuf(n.output,n.next_out))):this.onData(Du.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&i!==w_);return o===Ap?(i=Ru.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Ll):(o===b_&&(this.onEnd(Ll),n.avail_out=0),!0)};ka.prototype.onData=function(e){this.chunks.push(e)};ka.prototype.onEnd=function(e){e===Ll&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Du.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function IE(e,t){var n=new ka(t);if(n.push(e,!0),n.err)throw n.msg||Y2[n.err];return n.result}function aB(e,t){return t=t||{},t.raw=!0,IE(e,t)}function lB(e,t){return t=t||{},t.gzip=!0,IE(e,t)}rh.Deflate=ka;rh.deflate=IE;rh.deflateRaw=aB;rh.gzip=lB;var sh={},ei={},Gh=30,cB=12,uB=function(t,n){var r,i,o,s,a,l,c,u,d,h,m,g,p,v,y,E,w,x,C,S,I,T,L,A,F;r=t.state,i=t.next_in,A=t.input,o=i+(t.avail_in-5),s=t.next_out,F=t.output,a=s-(n-t.avail_out),l=s+(t.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,h=r.wnext,m=r.window,g=r.hold,p=r.bits,v=r.lencode,y=r.distcode,E=(1<<r.lenbits)-1,w=(1<<r.distbits)-1;e:do{p<15&&(g+=A[i++]<<p,p+=8,g+=A[i++]<<p,p+=8),x=v[g&E];t:for(;;){if(C=x>>>24,g>>>=C,p-=C,C=x>>>16&255,C===0)F[s++]=x&65535;else if(C&16){S=x&65535,C&=15,C&&(p<C&&(g+=A[i++]<<p,p+=8),S+=g&(1<<C)-1,g>>>=C,p-=C),p<15&&(g+=A[i++]<<p,p+=8,g+=A[i++]<<p,p+=8),x=y[g&w];n:for(;;){if(C=x>>>24,g>>>=C,p-=C,C=x>>>16&255,C&16){if(I=x&65535,C&=15,p<C&&(g+=A[i++]<<p,p+=8,p<C&&(g+=A[i++]<<p,p+=8)),I+=g&(1<<C)-1,I>c){t.msg="invalid distance too far back",r.mode=Gh;break e}if(g>>>=C,p-=C,C=s-a,I>C){if(C=I-C,C>d&&r.sane){t.msg="invalid distance too far back",r.mode=Gh;break e}if(T=0,L=m,h===0){if(T+=u-C,C<S){S-=C;do F[s++]=m[T++];while(--C);T=s-I,L=F}}else if(h<C){if(T+=u+h-C,C-=h,C<S){S-=C;do F[s++]=m[T++];while(--C);if(T=0,h<S){C=h,S-=C;do F[s++]=m[T++];while(--C);T=s-I,L=F}}}else if(T+=h-C,C<S){S-=C;do F[s++]=m[T++];while(--C);T=s-I,L=F}for(;S>2;)F[s++]=L[T++],F[s++]=L[T++],F[s++]=L[T++],S-=3;S&&(F[s++]=L[T++],S>1&&(F[s++]=L[T++]))}else{T=s-I;do F[s++]=F[T++],F[s++]=F[T++],F[s++]=F[T++],S-=3;while(S>2);S&&(F[s++]=F[T++],S>1&&(F[s++]=F[T++]))}}else if(C&64){t.msg="invalid distance code",r.mode=Gh;break e}else{x=y[(x&65535)+(g&(1<<C)-1)];continue n}break}}else if(C&64)if(C&32){r.mode=cB;break e}else{t.msg="invalid literal/length code",r.mode=Gh;break e}else{x=v[(x&65535)+(g&(1<<C)-1)];continue t}break}}while(i<o&&s<l);S=p>>3,i-=S,p-=S<<3,g&=(1<<p)-1,t.next_in=i,t.next_out=s,t.avail_in=i<o?5+(o-i):5-(i-o),t.avail_out=s<l?257+(l-s):257-(s-l),r.hold=g,r.bits=p},__=ao,Ga=15,x_=852,S_=592,k_=0,Lp=1,I_=2,dB=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],hB=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],fB=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],mB=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],gB=function(t,n,r,i,o,s,a,l){var c=l.bits,u=0,d=0,h=0,m=0,g=0,p=0,v=0,y=0,E=0,w=0,x,C,S,I,T,L=null,A=0,F,P=new __.Buf16(Ga+1),O=new __.Buf16(Ga+1),V=null,G=0,q,U,$;for(u=0;u<=Ga;u++)P[u]=0;for(d=0;d<i;d++)P[n[r+d]]++;for(g=c,m=Ga;m>=1&&P[m]===0;m--);if(g>m&&(g=m),m===0)return o[s++]=1<<24|64<<16|0,o[s++]=1<<24|64<<16|0,l.bits=1,0;for(h=1;h<m&&P[h]===0;h++);for(g<h&&(g=h),y=1,u=1;u<=Ga;u++)if(y<<=1,y-=P[u],y<0)return-1;if(y>0&&(t===k_||m!==1))return-1;for(O[1]=0,u=1;u<Ga;u++)O[u+1]=O[u]+P[u];for(d=0;d<i;d++)n[r+d]!==0&&(a[O[n[r+d]]++]=d);if(t===k_?(L=V=a,F=19):t===Lp?(L=dB,A-=257,V=hB,G-=257,F=256):(L=fB,V=mB,F=-1),w=0,d=0,u=h,T=s,p=g,v=0,S=-1,E=1<<g,I=E-1,t===Lp&&E>x_||t===I_&&E>S_)return 1;for(;;){q=u-v,a[d]<F?(U=0,$=a[d]):a[d]>F?(U=V[G+a[d]],$=L[A+a[d]]):(U=96,$=0),x=1<<u-v,C=1<<p,h=C;do C-=x,o[T+(w>>v)+C]=q<<24|U<<16|$|0;while(C!==0);for(x=1<<u-1;w&x;)x>>=1;if(x!==0?(w&=x-1,w+=x):w=0,d++,--P[u]===0){if(u===m)break;u=n[r+a[d]]}if(u>g&&(w&I)!==S){for(v===0&&(v=g),T+=h,p=u-v,y=1<<p;p+v<m&&(y-=P[p+v],!(y<=0));)p++,y<<=1;if(E+=1<<p,t===Lp&&E>x_||t===I_&&E>S_)return 1;S=w&I,o[S]=g<<24|p<<16|T-s|0}}return w!==0&&(o[T+w]=u-v<<24|64<<16|0),l.bits=g,0},er=ao,K2=PC,ai=RC,pB=uB,Ou=gB,yB=0,VC=1,GC=2,C_=4,vB=5,jh=6,Ia=0,EB=1,wB=2,kr=-2,jC=-3,YC=-4,bB=-5,T_=8,KC=1,M_=2,A_=3,L_=4,P_=5,R_=6,D_=7,O_=8,N_=9,F_=10,Hm=11,Oi=12,Pp=13,$_=14,Rp=15,B_=16,z_=17,H_=18,U_=19,Yh=20,Kh=21,W_=22,V_=23,G_=24,j_=25,Y_=26,Dp=27,K_=28,Z_=29,ot=30,ZC=31,_B=32,xB=852,SB=592,kB=15,IB=kB;function X_(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function CB(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new er.Buf16(320),this.work=new er.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function XC(e){var t;return!e||!e.state?kr:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=KC,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new er.Buf32(xB),t.distcode=t.distdyn=new er.Buf32(SB),t.sane=1,t.back=-1,Ia)}function qC(e){var t;return!e||!e.state?kr:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,XC(e))}function QC(e,t){var n,r;return!e||!e.state||(r=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?kr:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,qC(e))}function JC(e,t){var n,r;return e?(r=new CB,e.state=r,r.window=null,n=QC(e,t),n!==Ia&&(e.state=null),n):kr}function TB(e){return JC(e,IB)}var q_=!0,Op,Np;function MB(e){if(q_){var t;for(Op=new er.Buf32(512),Np=new er.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Ou(VC,e.lens,0,288,Op,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Ou(GC,e.lens,0,32,Np,0,e.work,{bits:5}),q_=!1}e.lencode=Op,e.lenbits=9,e.distcode=Np,e.distbits=5}function eT(e,t,n,r){var i,o=e.state;return o.window===null&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new er.Buf8(o.wsize)),r>=o.wsize?(er.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>r&&(i=r),er.arraySet(o.window,t,n-r,i,o.wnext),r-=i,r?(er.arraySet(o.window,t,n-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0}function AB(e,t){var n,r,i,o,s,a,l,c,u,d,h,m,g,p,v=0,y,E,w,x,C,S,I,T,L=new er.Buf8(4),A,F,P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return kr;n=e.state,n.mode===Oi&&(n.mode=Pp),s=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,c=n.hold,u=n.bits,d=a,h=l,T=Ia;e:for(;;)switch(n.mode){case KC:if(n.wrap===0){n.mode=Pp;break}for(;u<16;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}if(n.wrap&2&&c===35615){n.check=0,L[0]=c&255,L[1]=c>>>8&255,n.check=ai(n.check,L,2,0),c=0,u=0,n.mode=M_;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=ot;break}if((c&15)!==T_){e.msg="unknown compression method",n.mode=ot;break}if(c>>>=4,u-=4,I=(c&15)+8,n.wbits===0)n.wbits=I;else if(I>n.wbits){e.msg="invalid window size",n.mode=ot;break}n.dmax=1<<I,e.adler=n.check=1,n.mode=c&512?F_:Oi,c=0,u=0;break;case M_:for(;u<16;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}if(n.flags=c,(n.flags&255)!==T_){e.msg="unknown compression method",n.mode=ot;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=ot;break}n.head&&(n.head.text=c>>8&1),n.flags&512&&(L[0]=c&255,L[1]=c>>>8&255,n.check=ai(n.check,L,2,0)),c=0,u=0,n.mode=A_;case A_:for(;u<32;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}n.head&&(n.head.time=c),n.flags&512&&(L[0]=c&255,L[1]=c>>>8&255,L[2]=c>>>16&255,L[3]=c>>>24&255,n.check=ai(n.check,L,4,0)),c=0,u=0,n.mode=L_;case L_:for(;u<16;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}n.head&&(n.head.xflags=c&255,n.head.os=c>>8),n.flags&512&&(L[0]=c&255,L[1]=c>>>8&255,n.check=ai(n.check,L,2,0)),c=0,u=0,n.mode=P_;case P_:if(n.flags&1024){for(;u<16;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}n.length=c,n.head&&(n.head.extra_len=c),n.flags&512&&(L[0]=c&255,L[1]=c>>>8&255,n.check=ai(n.check,L,2,0)),c=0,u=0}else n.head&&(n.head.extra=null);n.mode=R_;case R_:if(n.flags&1024&&(m=n.length,m>a&&(m=a),m&&(n.head&&(I=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),er.arraySet(n.head.extra,r,o,m,I)),n.flags&512&&(n.check=ai(n.check,r,m,o)),a-=m,o+=m,n.length-=m),n.length))break e;n.length=0,n.mode=D_;case D_:if(n.flags&2048){if(a===0)break e;m=0;do I=r[o+m++],n.head&&I&&n.length<65536&&(n.head.name+=String.fromCharCode(I));while(I&&m<a);if(n.flags&512&&(n.check=ai(n.check,r,m,o)),a-=m,o+=m,I)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=O_;case O_:if(n.flags&4096){if(a===0)break e;m=0;do I=r[o+m++],n.head&&I&&n.length<65536&&(n.head.comment+=String.fromCharCode(I));while(I&&m<a);if(n.flags&512&&(n.check=ai(n.check,r,m,o)),a-=m,o+=m,I)break e}else n.head&&(n.head.comment=null);n.mode=N_;case N_:if(n.flags&512){for(;u<16;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}if(c!==(n.check&65535)){e.msg="header crc mismatch",n.mode=ot;break}c=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Oi;break;case F_:for(;u<32;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}e.adler=n.check=X_(c),c=0,u=0,n.mode=Hm;case Hm:if(n.havedict===0)return e.next_out=s,e.avail_out=l,e.next_in=o,e.avail_in=a,n.hold=c,n.bits=u,wB;e.adler=n.check=1,n.mode=Oi;case Oi:if(t===vB||t===jh)break e;case Pp:if(n.last){c>>>=u&7,u-=u&7,n.mode=Dp;break}for(;u<3;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}switch(n.last=c&1,c>>>=1,u-=1,c&3){case 0:n.mode=$_;break;case 1:if(MB(n),n.mode=Yh,t===jh){c>>>=2,u-=2;break e}break;case 2:n.mode=z_;break;case 3:e.msg="invalid block type",n.mode=ot}c>>>=2,u-=2;break;case $_:for(c>>>=u&7,u-=u&7;u<32;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",n.mode=ot;break}if(n.length=c&65535,c=0,u=0,n.mode=Rp,t===jh)break e;case Rp:n.mode=B_;case B_:if(m=n.length,m){if(m>a&&(m=a),m>l&&(m=l),m===0)break e;er.arraySet(i,r,o,m,s),a-=m,o+=m,l-=m,s+=m,n.length-=m;break}n.mode=Oi;break;case z_:for(;u<14;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}if(n.nlen=(c&31)+257,c>>>=5,u-=5,n.ndist=(c&31)+1,c>>>=5,u-=5,n.ncode=(c&15)+4,c>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=ot;break}n.have=0,n.mode=H_;case H_:for(;n.have<n.ncode;){for(;u<3;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}n.lens[P[n.have++]]=c&7,c>>>=3,u-=3}for(;n.have<19;)n.lens[P[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,A={bits:n.lenbits},T=Ou(yB,n.lens,0,19,n.lencode,0,n.work,A),n.lenbits=A.bits,T){e.msg="invalid code lengths set",n.mode=ot;break}n.have=0,n.mode=U_;case U_:for(;n.have<n.nlen+n.ndist;){for(;v=n.lencode[c&(1<<n.lenbits)-1],y=v>>>24,E=v>>>16&255,w=v&65535,!(y<=u);){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}if(w<16)c>>>=y,u-=y,n.lens[n.have++]=w;else{if(w===16){for(F=y+2;u<F;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}if(c>>>=y,u-=y,n.have===0){e.msg="invalid bit length repeat",n.mode=ot;break}I=n.lens[n.have-1],m=3+(c&3),c>>>=2,u-=2}else if(w===17){for(F=y+3;u<F;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}c>>>=y,u-=y,I=0,m=3+(c&7),c>>>=3,u-=3}else{for(F=y+7;u<F;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}c>>>=y,u-=y,I=0,m=11+(c&127),c>>>=7,u-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=ot;break}for(;m--;)n.lens[n.have++]=I}}if(n.mode===ot)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=ot;break}if(n.lenbits=9,A={bits:n.lenbits},T=Ou(VC,n.lens,0,n.nlen,n.lencode,0,n.work,A),n.lenbits=A.bits,T){e.msg="invalid literal/lengths set",n.mode=ot;break}if(n.distbits=6,n.distcode=n.distdyn,A={bits:n.distbits},T=Ou(GC,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,A),n.distbits=A.bits,T){e.msg="invalid distances set",n.mode=ot;break}if(n.mode=Yh,t===jh)break e;case Yh:n.mode=Kh;case Kh:if(a>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=o,e.avail_in=a,n.hold=c,n.bits=u,pB(e,h),s=e.next_out,i=e.output,l=e.avail_out,o=e.next_in,r=e.input,a=e.avail_in,c=n.hold,u=n.bits,n.mode===Oi&&(n.back=-1);break}for(n.back=0;v=n.lencode[c&(1<<n.lenbits)-1],y=v>>>24,E=v>>>16&255,w=v&65535,!(y<=u);){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}if(E&&!(E&240)){for(x=y,C=E,S=w;v=n.lencode[S+((c&(1<<x+C)-1)>>x)],y=v>>>24,E=v>>>16&255,w=v&65535,!(x+y<=u);){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}c>>>=x,u-=x,n.back+=x}if(c>>>=y,u-=y,n.back+=y,n.length=w,E===0){n.mode=Y_;break}if(E&32){n.back=-1,n.mode=Oi;break}if(E&64){e.msg="invalid literal/length code",n.mode=ot;break}n.extra=E&15,n.mode=W_;case W_:if(n.extra){for(F=n.extra;u<F;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=V_;case V_:for(;v=n.distcode[c&(1<<n.distbits)-1],y=v>>>24,E=v>>>16&255,w=v&65535,!(y<=u);){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}if(!(E&240)){for(x=y,C=E,S=w;v=n.distcode[S+((c&(1<<x+C)-1)>>x)],y=v>>>24,E=v>>>16&255,w=v&65535,!(x+y<=u);){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}c>>>=x,u-=x,n.back+=x}if(c>>>=y,u-=y,n.back+=y,E&64){e.msg="invalid distance code",n.mode=ot;break}n.offset=w,n.extra=E&15,n.mode=G_;case G_:if(n.extra){for(F=n.extra;u<F;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=ot;break}n.mode=j_;case j_:if(l===0)break e;if(m=h-l,n.offset>m){if(m=n.offset-m,m>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=ot;break}m>n.wnext?(m-=n.wnext,g=n.wsize-m):g=n.wnext-m,m>n.length&&(m=n.length),p=n.window}else p=i,g=s-n.offset,m=n.length;m>l&&(m=l),l-=m,n.length-=m;do i[s++]=p[g++];while(--m);n.length===0&&(n.mode=Kh);break;case Y_:if(l===0)break e;i[s++]=n.length,l--,n.mode=Kh;break;case Dp:if(n.wrap){for(;u<32;){if(a===0)break e;a--,c|=r[o++]<<u,u+=8}if(h-=l,e.total_out+=h,n.total+=h,h&&(e.adler=n.check=n.flags?ai(n.check,i,h,s-h):K2(n.check,i,h,s-h)),h=l,(n.flags?c:X_(c))!==n.check){e.msg="incorrect data check",n.mode=ot;break}c=0,u=0}n.mode=K_;case K_:if(n.wrap&&n.flags){for(;u<32;){if(a===0)break e;a--,c+=r[o++]<<u,u+=8}if(c!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=ot;break}c=0,u=0}n.mode=Z_;case Z_:T=EB;break e;case ot:T=jC;break e;case ZC:return YC;case _B:default:return kr}return e.next_out=s,e.avail_out=l,e.next_in=o,e.avail_in=a,n.hold=c,n.bits=u,(n.wsize||h!==e.avail_out&&n.mode<ot&&(n.mode<Dp||t!==C_))&&eT(e,e.output,e.next_out,h-e.avail_out),d-=e.avail_in,h-=e.avail_out,e.total_in+=d,e.total_out+=h,n.total+=h,n.wrap&&h&&(e.adler=n.check=n.flags?ai(n.check,i,h,e.next_out-h):K2(n.check,i,h,e.next_out-h)),e.data_type=n.bits+(n.last?64:0)+(n.mode===Oi?128:0)+(n.mode===Yh||n.mode===Rp?256:0),(d===0&&h===0||t===C_)&&T===Ia&&(T=bB),T}function LB(e){if(!e||!e.state)return kr;var t=e.state;return t.window&&(t.window=null),e.state=null,Ia}function PB(e,t){var n;return!e||!e.state||(n=e.state,!(n.wrap&2))?kr:(n.head=t,t.done=!1,Ia)}function RB(e,t){var n=t.length,r,i,o;return!e||!e.state||(r=e.state,r.wrap!==0&&r.mode!==Hm)?kr:r.mode===Hm&&(i=1,i=K2(i,t,n,0),i!==r.check)?jC:(o=eT(e,t,n,n),o?(r.mode=ZC,YC):(r.havedict=1,Ia))}ei.inflateReset=qC;ei.inflateReset2=QC;ei.inflateResetKeep=XC;ei.inflateInit=TB;ei.inflateInit2=JC;ei.inflate=AB;ei.inflateEnd=LB;ei.inflateGetHeader=PB;ei.inflateSetDictionary=RB;ei.inflateInfo="pako inflate (from Nodeca project)";var tT={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};function DB(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var OB=DB,Pl=ei,Nu=ao,$f=Na,wt=tT,Z2=kE,NB=UC,FB=OB,nT=Object.prototype.toString;function Ca(e){if(!(this instanceof Ca))return new Ca(e);this.options=Nu.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new NB,this.strm.avail_out=0;var n=Pl.inflateInit2(this.strm,t.windowBits);if(n!==wt.Z_OK)throw new Error(Z2[n]);if(this.header=new FB,Pl.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=$f.string2buf(t.dictionary):nT.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Pl.inflateSetDictionary(this.strm,t.dictionary),n!==wt.Z_OK)))throw new Error(Z2[n])}Ca.prototype.push=function(e,t){var n=this.strm,r=this.options.chunkSize,i=this.options.dictionary,o,s,a,l,c,u=!1;if(this.ended)return!1;s=t===~~t?t:t===!0?wt.Z_FINISH:wt.Z_NO_FLUSH,typeof e=="string"?n.input=$f.binstring2buf(e):nT.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new Nu.Buf8(r),n.next_out=0,n.avail_out=r),o=Pl.inflate(n,wt.Z_NO_FLUSH),o===wt.Z_NEED_DICT&&i&&(o=Pl.inflateSetDictionary(this.strm,i)),o===wt.Z_BUF_ERROR&&u===!0&&(o=wt.Z_OK,u=!1),o!==wt.Z_STREAM_END&&o!==wt.Z_OK)return this.onEnd(o),this.ended=!0,!1;n.next_out&&(n.avail_out===0||o===wt.Z_STREAM_END||n.avail_in===0&&(s===wt.Z_FINISH||s===wt.Z_SYNC_FLUSH))&&(this.options.to==="string"?(a=$f.utf8border(n.output,n.next_out),l=n.next_out-a,c=$f.buf2string(n.output,a),n.next_out=l,n.avail_out=r-l,l&&Nu.arraySet(n.output,n.output,a,l,0),this.onData(c)):this.onData(Nu.shrinkBuf(n.output,n.next_out))),n.avail_in===0&&n.avail_out===0&&(u=!0)}while((n.avail_in>0||n.avail_out===0)&&o!==wt.Z_STREAM_END);return o===wt.Z_STREAM_END&&(s=wt.Z_FINISH),s===wt.Z_FINISH?(o=Pl.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===wt.Z_OK):(s===wt.Z_SYNC_FLUSH&&(this.onEnd(wt.Z_OK),n.avail_out=0),!0)};Ca.prototype.onData=function(e){this.chunks.push(e)};Ca.prototype.onEnd=function(e){e===wt.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Nu.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function CE(e,t){var n=new Ca(t);if(n.push(e,!0),n.err)throw n.msg||Z2[n.err];return n.result}function $B(e,t){return t=t||{},t.raw=!0,CE(e,t)}sh.Inflate=Ca;sh.inflate=CE;sh.inflateRaw=$B;sh.ungzip=CE;var BB=ao.assign,zB=rh,HB=sh,UB=tT,rT={};BB(rT,zB,HB,UB);var rg=rT;const Bf=12,WB=()=>{const e=new Uint8Array(Bf);return window.crypto.getRandomValues(e)},TE=async e=>{const t=await window.crypto.subtle.generateKey({name:"AES-GCM",length:WS},!0,["encrypt","decrypt"]);return e==="cryptoKey"?t:(await window.crypto.subtle.exportKey("jwk",t)).k},iT=(e,t)=>window.crypto.subtle.importKey("jwk",{alg:"A128GCM",ext:!0,k:e,key_ops:["encrypt","decrypt"],kty:"oct"},{name:"AES-GCM",length:WS},!1,[t]),ig=async(e,t)=>{const n=typeof e=="string"?await iT(e,"encrypt"):e,r=WB(),i=typeof t=="string"?new TextEncoder().encode(t):t instanceof Uint8Array?t:t instanceof Blob?await Fo(t):t;return{encryptedBuffer:await window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},n,i),iv:r}},Td=async(e,t,n)=>{const r=await iT(n,"decrypt");return window.crypto.subtle.decrypt({name:"AES-GCM",iv:e},r,t)},X2=e=>new Promise((t,n)=>{const r=typeof e=="string"?new Blob([new TextEncoder().encode(e)]):new Blob([e instanceof Uint8Array?e:new Uint8Array(e)]),i=new FileReader;i.onload=o=>{if(!o.target||typeof o.target.result!="string")return n(new Error("couldn't convert to byte string"));t(o.target.result)},i.readAsBinaryString(r)}),oT=e=>{const t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let r=0,i=e.length;r<i;r++)n[r]=e.charCodeAt(r);return t},sT=e=>new TextDecoder("utf-8").decode(oT(e)),VB=async(e,t=!1)=>t?window.btoa(e):window.btoa(await X2(e)),GB=async(e,t=!1)=>t?window.atob(e):sT(window.atob(e)),aT=async({text:e,compress:t})=>{let n;if(t!==!1)try{n=await X2(rg.deflate(e))}catch(r){console.error("encode: cannot deflate",r)}return{version:"1",encoding:"bstring",compressed:!!n,encoded:n||await X2(e)}},lT=async e=>{let t;switch(e.encoding){case"bstring":t=e.compressed?e.encoded:await sT(e.encoded);break;default:throw new Error(`decode: unknown encoding "${e.encoding}"`)}return e.compressed?rg.inflate(new Uint8Array(oT(t)),{to:"string"}):t},cT=1,zf=4,Rl=4,Fp={1:8,2:16,4:32};function Um(e,t,n,r){if(r!=null){if(r>Math.pow(2,Fp[t])-1)throw new Error(`attempting to set value higher than the allocated bytes (value: ${r}, bytes: ${t})`);const o=`setUint${Fp[t]}`;return new DataView(e.buffer)[o](n,r),e}const i=`getUint${Fp[t]}`;return new DataView(e.buffer)[i](n)}const Q_=(...e)=>{const t=new Uint8Array(zf+Rl*e.length+e.reduce((r,i)=>r+i.byteLength,0));let n=0;Um(t,zf,n,cT),n+=zf;for(const r of e)Um(t,Rl,n,r.byteLength),n+=Rl,t.set(r,n),n+=r.byteLength;return t},J_=e=>{const t=[];let n=0;const r=Um(e,Rl,n);if(r>cT)throw new Error(`invalid version ${r}`);for(n+=zf;;){const i=Um(e,Rl,n);if(n+=Rl,t.push(e.slice(n,n+i)),n+=i,n>=e.byteLength)break}return t},jB=async(e,t)=>{const{encryptedBuffer:n,iv:r}=await ig(t,rg.deflate(e));return{iv:r,buffer:new Uint8Array(n)}},uT=async(e,t)=>{const n={version:2,compression:"pako@1",encryption:"AES-GCM"},r=new TextEncoder().encode(JSON.stringify(n)),i=new TextEncoder().encode(JSON.stringify(t.metadata||null)),{iv:o,buffer:s}=await jB(Q_(i,e),t.encryptionKey);return Q_(r,o,s)},YB=async(e,t,n,r)=>(t=new Uint8Array(await Td(e,t,n)),r?rg.inflate(t):t),dT=async(e,t)=>{const[n,r,i]=J_(e),o=JSON.parse(new TextDecoder().decode(n));try{const[s,a]=J_(await YB(r,i,t.decryptionKey,!!o.compression));return{metadata:JSON.parse(new TextDecoder().decode(s)),data:a}}catch(s){throw console.error("Error during decompressing and decrypting the file.",o),s}},hT=async e=>{const n=pC(new Uint8Array(await Fo(e))).find(r=>r.name==="tEXt");return n?J1.decode(n.data):null},fT=async({blob:e,metadata:t})=>{const n=pC(new Uint8Array(await Fo(e))),r=J1.encode(de.excalidraw,JSON.stringify(await aT({text:t,compress:!0})));return n.splice(-1,0,r),new Blob([qF(n)],{type:de.png})},KB=async e=>{const t=await hT(e);if((t==null?void 0:t.keyword)===de.excalidraw)try{const n=JSON.parse(t.text);if(!("encoded"in n)){if("type"in n&&n.type===yr.excalidraw)return t.text;throw new Error("FAILED")}return await lT(n)}catch(n){throw console.error(n),new Error("FAILED")}throw new Error("INVALID")},ZB=async({text:e})=>{const t=await VB(JSON.stringify(await aT({text:e})),!0);let n="";return n+=`<!-- payload-type:${de.excalidraw} -->`,n+="<!-- payload-version:2 -->",n+="<!-- payload-start -->",n+=t,n+="<!-- payload-end -->",n},XB=async({svg:e})=>{if(e.includes(`payload-type:${de.excalidraw}`)){const t=e.match(/<!-- payload-start -->\s*(.+?)\s*<!-- payload-end -->/);if(!t)throw new Error("INVALID");const n=e.match(/<!-- payload-version:(\d+) -->/),i=((n==null?void 0:n[1])||"1")!=="1";try{const o=await GB(t[1],i),s=JSON.parse(o);if(!("encoded"in s)){if("type"in s&&s.type===yr.excalidraw)return o;throw new Error("FAILED")}return await lT(s)}catch(o){throw console.error(o),new Error("FAILED")}}throw new Error("INVALID")},Wm=Object.freeze(Object.defineProperty({__proto__:null,decodePngMetadata:KB,decodeSvgMetadata:XB,encodePngMetadata:fT,encodeSvgMetadata:ZB,getTEXtChunk:hT},Symbol.toStringTag,{value:"Module"})),zr=32,We=12,es=256,mT=50,Fs="NOT_SPREADSHEET",Md="VALID_SPREADSHEET",fu=e=>{const t=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,"")):null},$p=(e,t)=>e.slice(1).every(n=>fu(n[t])!==null),e6=e=>{const t=e[0].length;if(t>2)return{type:Fs,reason:"More than 2 columns"};if(t===1){if(!$p(e,0))return{type:Fs,reason:"Value is not numeric"};const l=fu(e[0][0])===null,c=(l?e.slice(1):e).map(u=>fu(u[0]));return c.length<2?{type:Fs,reason:"Less than two rows"}:{type:Md,spreadsheet:{title:l?e[0][0]:null,labels:null,values:c}}}const n=$p(e,0),r=$p(e,1);if(!n&&!r)return{type:Fs,reason:"Value is not numeric"};const[i,o]=r?[0,1]:[1,0],s=fu(e[0][o])===null,a=s?e.slice(1):e;return a.length<2?{type:Fs,reason:"Less than 2 rows"}:{type:Md,spreadsheet:{title:s?e[0][o]:null,labels:a.map(l=>l[i]),values:a.map(l=>fu(l[o]))}}},qB=e=>{const t=[];for(let n=0;n<e[0].length;n++){const r=[];for(let i=0;i<e.length;i++)r.push(e[i][n]);t.push(r)}return t},QB=e=>{let t=e.trim().split(`
`).map(o=>o.trim().split(" "));if(t.length&&t[0].length!==2&&(t=e.trim().split(`
`).map(o=>o.trim().split(","))),t.length===0)return{type:Fs,reason:"No values"};const n=t[0].length;if(!t.every(o=>o.length===n))return{type:Fs,reason:"All rows don't have same number of columns"};const i=e6(t);if(i.type!==Md){const o=e6(qB(t));if(o.type===Md)return o}return i},Vm=KP(GP),wr={fillStyle:"hachure",fontFamily:oo,fontSize:Xr,opacity:100,roughness:1,strokeColor:ve.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Qn.MIDDLE,locked:!1},gT=e=>{const t=(zr+We)*e.values.length+We,n=es+We*2;return{chartWidth:t,chartHeight:n}},JB=(e,t,n,r,i)=>{var o;return((o=e.labels)==null?void 0:o.map((s,a)=>Sr({groupIds:[r],backgroundColor:i,...wr,text:s.length>8?`${s.slice(0,5)}...`:s,x:t+a*(zr+We)+We*2,y:n+We/2,width:zr,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"})))||[]},ez=(e,t,n,r,i)=>{const o=Sr({groupIds:[r],backgroundColor:i,...wr,x:t-We,y:n-We,text:"0",textAlign:"right"}),s=Sr({groupIds:[r],backgroundColor:i,...wr,x:t-We,y:n-es-o.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[o,s]},tz=(e,t,n,r,i)=>{const{chartWidth:o,chartHeight:s}=gT(e),a=Qo({backgroundColor:i,groupIds:[r],...wr,type:"line",x:t,y:n,startArrowhead:null,endArrowhead:null,width:o,points:[[0,0],[o,0]]}),l=Qo({backgroundColor:i,groupIds:[r],...wr,type:"line",x:t,y:n,startArrowhead:null,endArrowhead:null,height:s,points:[[0,0],[0,-s]]}),c=Qo({backgroundColor:i,groupIds:[r],...wr,type:"line",x:t,y:n-es-We,startArrowhead:null,endArrowhead:null,strokeStyle:"dotted",width:o,opacity:mT,points:[[0,0],[o,0]]});return[a,l,c]},pT=(e,t,n,r,i,o)=>{const{chartWidth:s,chartHeight:a}=gT(e),l=e.title?Sr({backgroundColor:i,groupIds:[r],...wr,text:e.title,x:t+s/2,y:n-es-We*2-Xr,roundness:null,textAlign:"center"}):null,c=o?hs({backgroundColor:i,groupIds:[r],...wr,type:"rectangle",x:t,y:n-a,width:s,height:a,strokeColor:ve.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...l?[l]:[],...JB(e,t,n,r,i),...ez(e,t,n,r,i),...tz(e,t,n,r,i)]},nz=(e,t,n)=>{const r=Math.max(...e.values),i=xr(),o=Vm[Math.floor(Math.random()*Vm.length)];return[...e.values.map((a,l)=>{const c=a/r*es;return hs({backgroundColor:o,groupIds:[i],...wr,type:"rectangle",x:t+l*(zr+We)+We,y:n-c-We,width:zr,height:c})}),...pT(e,t,n,i,o,!1)]},rz=(e,t,n)=>{const r=Math.max(...e.values),i=xr(),o=Vm[Math.floor(Math.random()*Vm.length)];let s=0;const a=[];for(const p of e.values){const v=s*(zr+We),y=-(p/r)*es;a.push([v,y]),s++}const l=Math.max(...a.map(p=>p[0])),c=Math.max(...a.map(p=>p[1])),u=Math.min(...a.map(p=>p[0])),d=Math.min(...a.map(p=>p[1])),h=Qo({backgroundColor:o,groupIds:[i],...wr,type:"line",x:t+We+zr/2,y:n-We,startArrowhead:null,endArrowhead:null,height:c-d,width:l-u,strokeWidth:2,points:a}),m=e.values.map((p,v)=>{const y=v*(zr+We)+We/2,E=-(p/r)*es+We/2;return hs({backgroundColor:o,groupIds:[i],...wr,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:t+y+zr/2,y:n+E-We*2,width:We,height:We})}),g=e.values.map((p,v)=>{const y=v*(zr+We)+We/2,E=p/r*es+We/2+We;return Qo({backgroundColor:o,groupIds:[i],...wr,type:"line",x:t+y+zr/2+We/2,y:n-E,startArrowhead:null,endArrowhead:null,height:E,strokeStyle:"dotted",opacity:mT,points:[[0,0],[0,E]]})});return[...pT(e,t,n,i,o,!1),h,...g,...m]},iz=(e,t,n,r)=>e==="line"?rz(t,n,r):nz(t,n,r),ME="clipboard"in navigator&&"writeText"in navigator.clipboard,AE="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,oz=e=>!!([yr.excalidraw,yr.excalidrawClipboard,yr.excalidrawClipboardWithAPI].includes(e==null?void 0:e.type)&&Array.isArray(e.elements)),sz=({types:e,files:t})=>{var r,i,o,s;!e&&!t&&console.warn("createPasteEvent: no types or files provided");const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(const[a,l]of Object.entries(e))try{if((r=n.clipboardData)==null||r.setData(a,l),((i=n.clipboardData)==null?void 0:i.getData(a))!==l)throw new Error(`Failed to set "${a}" as clipboardData item`)}catch(c){throw new Error(c.message)}if(t){let a=-1;for(const l of t){a++;try{if((o=n.clipboardData)==null||o.items.add(l),((s=n.clipboardData)==null?void 0:s.files[a])!==l)throw new Error(`Failed to set file "${l.name}" as clipboardData item`)}catch(c){throw new Error(c.message)}}}return n},az=({elements:e,files:t})=>{const n=be(e),r=new Set(e.filter(a=>pe(a)));let i=!1;const o=e.reduce((a,l)=>(Ft(l)&&(i=!0,t&&t[l.fileId]&&(a[l.fileId]=t[l.fileId])),a),{});i&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");const s={type:yr.excalidrawClipboard,elements:e.map(a=>{if(rr(a,n)&&!r.has(rr(a,n))){const l=th(a);return J(l,{frameId:null}),l}return a}),files:t?o:void 0};return JSON.stringify(s)},lz=async(e,t,n)=>{await Fa(az({elements:e,files:t}),n)},cz=e=>{const t=QB(e);return t.type===Md?{spreadsheet:t.spreadsheet}:null};function yT(e){var n;let t=[];for(const r of e.childNodes)if(r.nodeType===3){const i=(n=r.textContent)==null?void 0:n.trim();i&&t.push({type:"text",value:i})}else if(r instanceof HTMLImageElement){const i=r.getAttribute("src");i&&i.startsWith("http")&&t.push({type:"imageUrl",value:i})}else t=t.concat(yT(r));return t}const uz=e=>{var n;const t=(n=e.clipboardData)==null?void 0:n.getData("text/html");if(!t)return null;try{const r=new DOMParser().parseFromString(t,"text/html"),i=yT(r.body);if(i.length)return{type:"mixedContent",value:i}}catch(r){console.error(`error in parseHTMLFromPaste: ${r.message}`)}return null},dz=async()=>{var n,r,i,o;const e={};try{if((n=navigator.clipboard)!=null&&n.readText)return{"text/plain":await((r=navigator.clipboard)==null?void 0:r.readText())}}catch(s){if((i=navigator.clipboard)!=null&&i.read)console.warn(`navigator.clipboard.readText() failed (${s.message}). Failling back to navigator.clipboard.read()`);else throw s}let t;try{t=await((o=navigator.clipboard)==null?void 0:o.read())}catch(s){if(s.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${s.message}`),e;throw s}for(const s of t)for(const a of s.types)if(k2(sR,a))try{e[a]=await(await s.getType(a)).text()}catch(l){console.warn(`Cannot retrieve ${a} from clipboardItem: ${l.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},hz=async(e,t=!1)=>{var n,r;try{const i=!t&&e&&uz(e);return i?i.value.every(s=>s.type==="text")?{type:"text",value:((n=e.clipboardData)==null?void 0:n.getData("text/plain"))||i.value.map(s=>s.value).join(`
`).trim()}:i:{type:"text",value:(((r=e.clipboardData)==null?void 0:r.getData("text/plain"))||"").trim()}}catch{return{type:"text",value:""}}},vT=async(e,t=!1)=>{const n=await hz(e,t);if(n.type==="mixedContent")return{mixedContent:n.value};try{const r=!t&&cz(n.value);if(r)return r}catch(r){console.error(r)}try{const r=JSON.parse(n.value),i=r.type===yr.excalidrawClipboardWithAPI;if(oz(r))return{elements:r.elements,files:r.files,text:t?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:i}}catch{}return{text:n.value}},fz=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[de.png]:e})])}catch(t){if(Xd(e))await navigator.clipboard.write([new window.ClipboardItem({[de.png]:await e})]);else throw t}},Fa=async(e,t)=>{var n,r;if(ME)try{await navigator.clipboard.writeText(e||"");return}catch(i){console.error(i)}try{if(t){if((n=t.clipboardData)==null||n.setData("text/plain",e||""),((r=t.clipboardData)==null?void 0:r.getData("text/plain"))!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(i){console.error(i)}if(!mz(e))throw new Error("Error copying to clipboard.")},mz=e=>{e||(e=" ");const t=document.documentElement.getAttribute("dir")==="rtl",n=document.createElement("textarea");n.style.border="0",n.style.padding="0",n.style.margin="0",n.style.position="absolute",n.style[t?"right":"left"]="-9999px";const r=window.pageYOffset||document.documentElement.scrollTop;n.style.top=`${r}px`,n.style.fontSize="12pt",n.setAttribute("readonly",""),n.value=e,document.body.appendChild(n);let i=!1;try{n.select(),n.setSelectionRange(0,n.value.length),i=document.execCommand("copy")}catch(o){console.error(o)}return n.remove(),i},og=({elements:e,appState:t,files:n,maxWidthOrHeight:r,getDimensions:i,exportPadding:o,exportingFrame:s})=>{const{elements:a,appState:l}=_a({elements:e,appState:t},null,null),{exportBackground:c,viewBackgroundColor:u}=l;return gC(a,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},n||{},{exportBackground:c,exportPadding:o,viewBackgroundColor:u,exportingFrame:s},(d,h)=>{const m=document.createElement("canvas");if(r){typeof i=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");const p=Math.max(d,h),v=r<p?r/p:(t==null?void 0:t.exportScale)??1;return m.width=d*v,m.height=h*v,{canvas:m,scale:v}}const g=(i==null?void 0:i(d,h))||{width:d,height:h};return m.width=g.width,m.height=g.height,{canvas:m,scale:g.scale??1}})},gz=async e=>{var i;let{mimeType:t=de.png,quality:n}=e;t===de.png&&typeof n=="number"&&console.warn(`"quality" will be ignored for "${de.png}" mimeType`),t==="image/jpg"&&(t=de.jpg),t===de.jpg&&!((i=e.appState)!=null&&i.exportBackground)&&(console.warn(`Defaulting "exportBackground" to "true" for "${de.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});const r=await og(e);return n=n||(/image\/jpe?g/.test(t)?.92:.8),new Promise((o,s)=>{r.toBlob(async a=>{var l;if(!a)return s(new Error("couldn't export to blob"));a&&t===de.png&&((l=e.appState)!=null&&l.exportEmbedScene)&&(a=await fT({blob:a,metadata:hc(e.elements,e.appState,e.files||{},"local")})),o(a)},t,n)})},ET=async({elements:e,appState:t=qr(),files:n={},exportPadding:r,renderEmbeddables:i,exportingFrame:o})=>{const{elements:s,appState:a}=_a({elements:e,appState:t},null,null),l={...a,exportPadding:r};return vE(s,l,n,{exportingFrame:o,renderEmbeddables:i})},pz=e=>e.type==="diamond"?[[e.width/2,0],[e.width,e.height/2],[e.width/2,e.height],[0,e.height/2]]:[[0,0],[0+e.width,0],[0+e.width,e.height],[0,e.height]],yz=e=>we(e)||Hn(e)?e.points:pz(e),t6=e=>{const t=e.reduce((n,[r,i])=>(n.minY=Math.min(n.minY,i),n.minX=Math.min(n.minX,r),n.maxX=Math.max(n.maxX,r),n.maxY=Math.max(n.maxY,i),n),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},wT=e=>{const t=yz(e),{cx:n,cy:r}=t6(t),i=[n,r],o=t.map(u=>st([u[0],u[1]],i,e.angle)),{minX:s,minY:a,maxX:l,maxY:c}=t6(o);return[s+e.x,a+e.y,l+e.x,c+e.y]},n6=(e,t,n=!1)=>{const r=wT(e),i=t[0]<=r[0]&&t[2]>=r[2]&&t[1]<=r[1]&&t[3]>=r[3];return n?i?!0:r[0]<=t[0]&&r[2]>=t[2]&&r[1]<=t[1]&&r[3]>=t[3]:i},vz=(e,t)=>{const n=wT(e);return(Uh(n[0],t[0],t[2])||Uh(t[0],n[0],n[2]))&&(Uh(n[1],t[1],t[3])||Uh(t[1],n[1],n[3]))},Ez=({elements:e,bounds:t,type:n,errorMargin:r=0})=>{var s;Jk(t)&&(t=ba(t,be(e)));const i=[t[0]-r,t[1]-r,t[2]+r,t[3]+r],o=new Set;for(const a of e){if(o.has(a.id))continue;if(n==="overlap"?vz(a,i):n==="inside"?n6(a,i):n6(a,i,!0)){if(o.add(a.id),a.boundElements)for(const c of a.boundElements)o.add(c.id);ce(a)&&a.containerId&&o.add(a.containerId),Ge(a)&&(a.startBinding&&o.add(a.startBinding.elementId),a.endBinding&&o.add((s=a.endBinding)==null?void 0:s.elementId))}}return e.filter(a=>o.has(a.id))};function r6(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function bT(e,t){return e[0]*t[1]-t[0]*e[1]}function wz(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}function Gm(e,t){return[e[0]-t[0],e[1]-t[1]]}const bz=1e-6;function i6(e,t){const n=Gm(e[1],e[0]),r=Gm(t,e[0]),i=bT(n,r);return Math.abs(i)<bz}function Bp(e,t){const n=Gm(e[1],e[0]),r=Gm(t,e[0]);return bT(n,r)<0}function o6(e,t){return i6(e,t[0])||i6(e,t[1])||(Bp(e,t[0])?!Bp(e,t[1]):Bp(e,t[1]))}function _z(e,t){return wz(r6(e),r6(t))&&o6(e,t)&&o6(t,e)}const _T=(e,t,n)=>{const r=be(e);for(const i of t)if(i.frameId){const o=n.get(i.id),s=n.get(i.frameId);if(o){const a=r.get(o);a&&J(a,{frameId:s??i.frameId},!1)}}};function xT(e,t,n){const r=Vb(t,n),i=Vb(e,n);return r.some(s=>i.some(a=>_z(s,a)))}const ST=(e,t,n)=>ag(NE(e,t,n,!1)).filter(r=>!pe(r)&&!r.frameId||r.frameId===t.id),kT=(e,t,n,r)=>NE(e,t,r).some(i=>i.id===n.id),IT=(e,t,n)=>{const[r,i,o,s]=Ee(t,n),[a,l,c,u]=nt(e);return r<=a&&i<=l&&o>=c&&s>=u},Ta=(e,t,n)=>IT([e],t,n)||xT(e,t,n)||kT([t],e,t,n),s6=(e,t,n)=>{const[r,i,o,s]=Ee(t,n);return ml([r,i],[e.x,e.y],[o,s])},xz=e=>{const t=new Map;for(const n of e){const r=pe(n)?n.id:n.frameId;r&&!t.has(r)&&t.set(r,eo(e,r))}return t},eo=(e,t)=>{const n=[];for(const r of e.values())r.frameId===t&&n.push(r);return n},LE=e=>e.filter(t=>pe(t)),CT=e=>{const t=be(LE(e));return e.filter(n=>t.has(n.id)||!n.frameId||!t.has(n.frameId))},Hf=(e,t,n,r)=>{const i=eo(e,t.id),o=new Set(i),s=new Set([...ST(e,t,r),...i.filter(h=>kT(e,h,t,r))]),a=i.filter(h=>!s.has(h)),l=new Set(Array.from(s).flatMap(h=>h.groupIds));for(const h of a)if(!xT(h,t,r))h.groupIds.length===0&&o.delete(h);else if(h.groupIds.length>0)for(const m of h.groupIds)l.add(m);for(const h of a)if(h.groupIds.length>0){let m=!0;for(const g of h.groupIds)l.has(g)&&(m=!1);m&&o.delete(h)}const c=Array.from(s).filter(h=>h.groupIds.length===0);for(const h of c)o.add(h);const u=Array.from(s).filter(h=>h.groupIds.length>0),d=NI(u,n);for(const[h,m]of Object.entries(d))if(m){const g=It(e,h);if(IT(g,t,r))for(const p of g)o.add(p)}return[...o].filter(h=>!(ce(h)&&h.containerId))},Sz=(e,t,n)=>ag(e,ST(e,t,n)),rr=(e,t)=>e.frameId&&t.get(e.frameId)||null,kz=(e,t)=>{const n=new Set,r=be(e);e=ag(e);for(const s of e)pe(s)&&s.id!==t.id&&n.add(s.id);const i=new Set,o=[];for(const s of e)if(!(pe(s)||s.frameId&&n.has(s.frameId)))if(s.groupIds.length){const a=s.groupIds.at(-1);if(!i.has(a)){i.add(a);const l=It(e,a);if(l.some(c=>Ta(c,t,r)))for(const c of l)o.push(c)}}else Ta(s,t,r)&&o.push(s);return o},Uf=(e,t,n)=>{const r=be(e),i=new Map;for(const l of e.values())l.frameId===n.id&&i.set(l.id,!0);const o=new Set(t.map(l=>l.id)),s=[],a=new Set;for(const l of t)pe(l)&&l.id!==n.id&&a.add(l.id);for(const l of ag(e,t)){if(pe(l)||l.frameId&&a.has(l.frameId))continue;i.has(l.id)||s.push(l);const c=ke(l,r);c&&!o.has(c.id)&&!i.has(c.id)&&s.push(c)}for(const l of s)J(l,{frameId:n.id},!1);return e},sg=(e,t)=>{const n=new Map,r=new Map;for(const i of e)if(i.frameId){n.set(i.id,i);const o=r.get(i.frameId)||[];o.push(i);const s=ke(i,t);s&&(n.set(s.id,s),o.push(s)),r.set(i.frameId,o)}for(const[,i]of n)J(i,{frameId:null},!1)},TT=(e,t)=>{const n=eo(e,t.id);return sg(n,be(e)),e},MT=(e,t,n,r)=>Uf(TT(e,n),t,n).slice(),Ql=(e,t,n)=>{const r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),i=new Set(r);if(t.editingGroupId)for(const a of r)a.groupIds.length===0?i.add(a):a.groupIds.flatMap(l=>It(e,l)).forEach(l=>i.add(l));const o=new Set,s=be(e);return i.forEach(a=>{a.frameId&&!pe(a)&&!Ad(a,s,t)&&o.add(a)}),o.size>0&&sg(o,s),e},ag=(e,t)=>{const n=new Set,r=t||e;for(const s of r.values()){const a=s.groupIds[s.groupIds.length-1];a&&n.add(a)}const i=new Set;for(const s of n)It(e,s).some(a=>pe(a))&&i.add(s);const o=[];for(const s of r.values())i.has(s.groupIds[s.groupIds.length-1])||o.push(s);return o},q2=(e,t,n)=>{const r=ce(e)&&kn(e,t)||e;return n.selectedElementIds[r.id]&&n.selectedElementsAreBeingDragged?n.frameToHighlight:rr(r,t)},Ad=(e,t,n)=>{const r=q2(e,t,n),i=ce(e)&&kn(e,t)||e;if(r){if(!n.selectedElementIds[e.id]||!n.selectedElementsAreBeingDragged)return!0;if(i.groupIds.length===0)return Ta(i,r,t);const o=new Set(i.groupIds.flatMap(s=>It(t,s)));if(n.editingGroupId&&n.selectedElementsAreBeingDragged){const s=new Set(qe(t,n));if(n.frameToHighlight!==null)return!0;s.forEach(l=>{o.delete(l)})}for(const s of o)if(pe(s))return!1;for(const s of o)if(Ta(s,r,t))return!0}return!1},AT=(e,t)=>e.name===null?pd(e)?`Frame ${t}`:`AI Frame $${t}`:e.name,PE=(e,t)=>Ez({elements:e,bounds:t,type:"overlap"}).filter(n=>!n.frameId||n.frameId===t.id);var Iz={VITE_APP_BACKEND_V2_GET_URL:"https://json.excalidraw.com/api/v2/",VITE_APP_BACKEND_V2_POST_URL:"https://json.excalidraw.com/api/v2/post/",VITE_APP_LIBRARY_URL:"https://libraries.excalidraw.com",VITE_APP_LIBRARY_BACKEND:"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries",VITE_APP_PLUS_LP:"https://plus.excalidraw.com",VITE_APP_PLUS_APP:"https://app.excalidraw.com",VITE_APP_AI_BACKEND:"https://oss-ai.excalidraw.com",VITE_APP_WS_SERVER_URL:"https://oss-collab.excalidraw.com",VITE_APP_FIREBASE_CONFIG:'{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}',VITE_APP_DISABLE_TRACKING:"",VITE_APP_GIT_SHA:"",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const LT="invert(100%) hue-rotate(180deg) saturate(1.25)",Cz=qr(),PT=(e,t)=>Ft(e)&&!t.imageCache.has(e.fileId),RT=(e,t,n)=>{var r;return n.theme==="dark"&&Ft(e)&&!PT(e,t)&&((r=t.imageCache.get(e.fileId))==null?void 0:r.mimeType)!==de.svg},lg=e=>e.type==="freedraw"?e.strokeWidth*12:20,DT=(e,t,n)=>{let r=((t==null?void 0:t.opacity)??100)*e.opacity/1e4;return(n.has(e.id)||t&&n.has(t.id))&&(r*=_R/100),r},Tz=(e,t,n)=>{const o=lg(e),[s,a,l,c]=Ee(e,t),u=we(e)||Hn(e)?un(s,l):e.width,d=we(e)||Hn(e)?un(a,c):e.height;let h=u*window.devicePixelRatio+o*2,m=d*window.devicePixelRatio+o*2,g=n.value;return(h*g>32767||m*g>32767)&&(g=Math.min(32767/h,32767/m)),h*m*g*g>16777216&&(g=Math.sqrt(16777216/(h*m))),h=Math.floor(h*g),m=Math.floor(m*g),{width:h,height:m,scale:g}},Mz=(e,t,n,r,i)=>{var g,p;const o=document.createElement("canvas"),s=o.getContext("2d"),a=lg(e),{width:l,height:c,scale:u}=Tz(e,t,n);o.width=l,o.height=c;let d=0,h=0;if(we(e)||Hn(e)){const[v,y]=Ee(e,t);d=e.x>v?un(e.x,v)*window.devicePixelRatio*u:0,h=e.y>y?un(e.y,y)*window.devicePixelRatio*u:0,s.translate(d,h)}s.save(),s.translate(a*u,a*u),s.scale(window.devicePixelRatio*u,window.devicePixelRatio*u);const m=ws.canvas(o);return RT(e,r,i)&&(s.filter=LT),Wf(e,m,s,r,i),s.restore(),{element:e,canvas:o,theme:i.theme,scale:u,zoomValue:n.value,canvasOffsetX:d,canvasOffsetY:h,boundTextElementVersion:((g=ke(e,t))==null?void 0:g.version)||null,containingFrameOpacity:((p=rr(e,t))==null?void 0:p.opacity)||100}},Az=14,OT=document.createElement("img");OT.src=`data:${de.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;const NT=document.createElement("img");NT.src=`data:${de.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;const Lz=(e,t,n)=>{t.fillStyle="#E7E7E7",t.fillRect(0,0,e.width,e.height);const r=Math.min(e.width,e.height),i=Math.min(r,Math.min(r*.4,100));t.drawImage(e.status==="error"?NT:OT,e.width/2-i/2,e.height/2-i/2,i,i)},Wf=(e,t,n,r,i)=>{var o;switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":{n.lineJoin="round",n.lineCap="round",t.draw(Xe.get(e));break}case"arrow":case"line":{n.lineJoin="round",n.lineCap="round",Xe.get(e).forEach(s=>{t.draw(s)});break}case"freedraw":{n.save(),n.fillStyle=e.strokeColor;const s=Dz(e),a=Xe.get(e);a&&t.draw(a),n.fillStyle=e.strokeColor,n.fill(s),n.restore();break}case"image":{const s=Ft(e)?(o=r.imageCache.get(e.fileId))==null?void 0:o.image:void 0;s!=null&&!(s instanceof Promise)?(e.roundness&&n.roundRect&&(n.beginPath(),n.roundRect(0,0,e.width,e.height,oa(Math.min(e.width,e.height),e)),n.clip()),n.drawImage(s,0,0,e.width,e.height)):Lz(e,n,i.zoom.value);break}default:if(ce(e)){const s=Vk(e.text),a=s&&!n.canvas.isConnected;a&&document.body.appendChild(n.canvas),n.canvas.setAttribute("dir",s?"rtl":"ltr"),n.save(),n.font=Bt(e),n.fillStyle=e.strokeColor,n.textAlign=e.textAlign;const l=e.text.replace(/\r\n?/g,`
`).split(`
`),c=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,u=Qd(e.fontSize,e.lineHeight),d=II(e.fontFamily,e.fontSize,u);for(let h=0;h<l.length;h++)n.fillText(l[h],c,h*u+d);n.restore(),a&&n.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},Q2=new WeakMap,a6=(e,t,n,r)=>{var c,u;const i=n?r.zoom:Cz.zoom,o=Q2.get(e),s=o&&o.zoomValue!==i.value&&!(r!=null&&r.shouldCacheIgnoreZoom),a=((c=ke(e,t))==null?void 0:c.version)||null,l=((u=rr(e,t))==null?void 0:u.opacity)||100;if(!o||s||o.theme!==r.theme||o.boundTextElementVersion!==a||o.containingFrameOpacity!==l){const d=Mz(e,t,i,n,r);return Q2.set(e,d),d}return o},l6=(e,t,n,r,i)=>{const o=e.element,s=lg(o),a=e.scale;let[l,c,u,d]=Ee(o,i);Hn(o)&&(l=Math.floor(l),u=Math.ceil(u),c=Math.floor(c),d=Math.ceil(d));const h=((l+u)/2+r.scrollX)*window.devicePixelRatio,m=((c+d)/2+r.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);const g=ke(o,i);if(Ge(o)&&g){const p=document.createElement("canvas"),v=p.getContext("2d"),y=Math.max(un(l,u),un(c,d));p.width=y*window.devicePixelRatio*a+s*e.scale*10,p.height=y*window.devicePixelRatio*a+s*e.scale*10;const E=(p.width-e.canvas.width)/2,w=(p.height-e.canvas.height)/2;v.translate(p.width/2,p.height/2),v.rotate(o.angle),v.drawImage(e.canvas,-e.canvas.width/2,-e.canvas.height/2,e.canvas.width,e.canvas.height);const[,,,,x,C]=Ee(g,i);v.rotate(-o.angle);const S=p.width/2-(x-l)*window.devicePixelRatio*a-E-s*a,I=p.height/2-(C-c)*window.devicePixelRatio*a-w-s*a;v.translate(-S,-I),v.clearRect(-(g.width/2+Nt)*window.devicePixelRatio*a,-(g.height/2+Nt)*window.devicePixelRatio*a,(g.width+Nt*2)*window.devicePixelRatio*a,(g.height+Nt*2)*window.devicePixelRatio*a),t.translate(h,m),t.drawImage(p,-(u-l)/2*window.devicePixelRatio-E/a-s,-(d-c)/2*window.devicePixelRatio-w/a-s,p.width/a,p.height/a)}else if(t.translate(h,m),t.rotate(o.angle),"scale"in e.element&&!PT(o,n)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-h,-m),t.drawImage(e.canvas,(l+r.scrollX)*window.devicePixelRatio-s*e.scale/e.scale,(c+r.scrollY)*window.devicePixelRatio-s*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),Iz.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&ls(o)){const p=ke(o,i),v=LI(o);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((v.x+r.scrollX)*window.devicePixelRatio,(v.y+r.scrollY)*window.devicePixelRatio,Ii(o,p)*window.devicePixelRatio,eh(o,p)*window.devicePixelRatio)}t.restore()},Pz=(e,t,n)=>{t.save(),t.translate(e.x+n.scrollX,e.y+n.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";const r=.5/n.zoom.value;t.fillRect(r,r,e.width,e.height),t.lineWidth=1/n.zoom.value,t.strokeStyle=" rgb(105, 101, 219)",t.strokeRect(r,r,e.width,e.height),t.restore()},Zh=(e,t,n,r,i,o,s)=>{switch(i.globalAlpha=DT(e,rr(e,t),o.elementsPendingErasure),e.type){case"magicframe":case"frame":{s.frameRendering.enabled&&s.frameRendering.outline&&(i.save(),i.translate(e.x+s.scrollX,e.y+s.scrollY),i.fillStyle="rgba(0, 0, 200, 0.04)",i.lineWidth=vt.strokeWidth/s.zoom.value,i.strokeStyle=vt.strokeColor,uu(e)&&(i.strokeStyle=s.theme==="light"?"#7affd7":"#1d8264"),i.roundRect?(i.beginPath(),i.roundRect(0,0,e.width,e.height,vt.radius/s.zoom.value),i.stroke(),i.closePath()):i.strokeRect(0,0,e.width,e.height),i.restore());break}case"freedraw":{if(Xe.generateElementShape(e,null),o.isExporting){const[a,l,c,u]=Ee(e,t),d=(a+c)/2+s.scrollX,h=(l+u)/2+s.scrollY,m=(c-a)/2-(e.x-a),g=(u-l)/2-(e.y-l);i.save(),i.translate(d,h),i.rotate(e.angle),i.translate(-m,-g),Wf(e,r,i,o,s),i.restore()}else{const a=a6(e,t,o,s);l6(a,i,o,s,n)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(Xe.generateElementShape(e,o),o.isExporting){const[a,l,c,u]=Ee(e,t),d=(a+c)/2+s.scrollX,h=(l+u)/2+s.scrollY;let m=(c-a)/2-(e.x-a),g=(u-l)/2-(e.y-l);if(ce(e)){const v=kn(e,t);if(Ge(v)){const y=ue.getBoundTextElementPosition(v,e,t);m=(c-a)/2-(y.x-a),g=(u-l)/2-(y.y-l)}}i.save(),i.translate(d,h),RT(e,o,s)&&(i.filter="none");const p=ke(e,t);if(Ge(e)&&p){const v=document.createElement("canvas"),y=v.getContext("2d"),E=Math.max(un(a,c),un(l,u)),w=lg(e);v.width=E*s.exportScale+w*10*s.exportScale,v.height=E*s.exportScale+w*10*s.exportScale,y.translate(v.width/2,v.height/2),y.scale(s.exportScale,s.exportScale),m=e.width/2-(e.x-a),g=e.height/2-(e.y-l),y.rotate(e.angle);const x=ws.canvas(v);y.translate(-m,-g),Wf(e,x,y,o,s),y.translate(m,g),y.rotate(-e.angle);const[,,,,C,S]=Ee(p,t),I=(a+c)/2-C,T=(l+u)/2-S;y.translate(-I,-T),y.clearRect(-p.width/2,-p.height/2,p.width,p.height),i.scale(1/s.exportScale,1/s.exportScale),i.drawImage(v,-v.width/2,-v.height/2,v.width,v.height)}else i.rotate(e.angle),e.type==="image"&&i.scale(e.scale[0],e.scale[1]),i.translate(-m,-g),Wf(e,r,i,o,s);i.restore()}else{const a=a6(e,t,o,s),l=i.imageSmoothingEnabled;!(s!=null&&s.shouldCacheIgnoreZoom)&&(!e.angle||UD(e.angle))&&(i.imageSmoothingEnabled=!1),l6(a,i,o,s,n),i.imageSmoothingEnabled=l}break}default:throw new Error(`Unimplemented type ${e.type}`)}i.globalAlpha=1},FT=new WeakMap([]);function Rz(e){const t=$T(e),n=new Path2D(t);return FT.set(e,n),n}function Dz(e){return FT.get(e)}function $T(e){const t=e.simulatePressure?e.points:e.points.length?e.points.map(([r,i],o)=>[r,i,e.pressures[o]]):[[0,0,.5]],n={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:r=>Math.sin(r*Math.PI/2),last:!!e.lastCommittedPoint};return Nz(IN(t,n))}function c6(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}const Oz=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function Nz(e){if(!e.length)return"";const t=e.length-1;return e.reduce((n,r,i,o)=>(i===t?n.push(r,c6(r,o[0]),"L",o[0],"Z"):n.push(r,c6(r,o[i+1])),n),["M",e[0],"Q"]).join(" ").replace(Oz,"$1")}const sn=class sn{};M(sn,"rg",new gd),M(sn,"cache",new WeakMap),M(sn,"get",t=>sn.cache.get(t)),M(sn,"set",(t,n)=>sn.cache.set(t,n)),M(sn,"delete",t=>sn.cache.delete(t)),M(sn,"destroy",()=>{sn.cache=new WeakMap}),M(sn,"generateElementShape",(t,n)=>{const r=n!=null&&n.isExporting?void 0:sn.get(t);if(r!==void 0)return r;Q2.delete(t);const i=QD(t,sn.rg,n||{isExporting:!1,canvasBackgroundColor:ve.white,embedsValidationStatus:null});return sn.cache.set(t,i),i});let Xe=sn;const J=(e,t,n=!0)=>{var s;let r=!1;const{points:i,fileId:o}=t;typeof i<"u"&&(t={...tI(i),...t});for(const a in t){const l=t[a];if(typeof l<"u"){if(e[a]===l&&(typeof l!="object"||l===null||a==="groupIds"||a==="scale"))continue;if(a==="scale"){const c=e[a],u=l;if(c[0]===u[0]&&c[1]===u[1])continue}else if(a==="points"){const c=e[a],u=l;if(c.length===u.length){let d=!1,h=c.length;for(;--h;){const m=c[h],g=u[h];if(m[0]!==g[0]||m[1]!==g[1]){d=!0;break}}if(!d)continue}}e[a]=l,r=!0}}return r&&((typeof t.height<"u"||typeof t.width<"u"||typeof o<"u"||typeof i<"u")&&Xe.delete(e),e.version++,e.versionNonce=bs(),e.updated=cc(),n&&((s=$t.getScene(e))==null||s.informMutation())),e},ge=(e,t)=>{let n=!1;for(const r in t){const i=t[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return n?{...e,...t,updated:cc(),version:e.version+1,versionNonce:bs()}:e},pc=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=bs(),e.updated=cc(),e),Ma=e=>we(e)||Hn(e)?e.points.length<2:e.width===0&&e.height===0,jm=(e,t,n,r,i)=>{const[o,s,a,l]=ba(e,i),c=et({clientX:r.offsetLeft,clientY:r.offsetTop},r),u=et({clientX:r.offsetLeft+t,clientY:r.offsetTop+n},r);return c.x<=a&&c.y<=l&&u.x>=o&&u.y>=s},u6=(e,t,n)=>{const r=Math.abs(t),i=Math.abs(n);if(e==="line"||e==="arrow"||e==="freedraw"){const o=Math.round(Math.atan(i/r)/ss)*ss;o===0?n=0:o===Math.PI/2?t=0:n=r*Math.tan(o)*Math.sign(n)||n}else e!=="selection"&&(n=r*Math.sign(n));return{width:t,height:n}},J2=(e,t,n,r)=>{let i=n-e,o=r-t;const s=Math.round(Math.atan(o/i)/ss)*ss;if(s===0)o=0;else if(s===Math.PI/2)i=0;else{const a=Math.tan(s),l=-1,c=t-a*e,u=-1/a,d=-1,h=r-u*n,m=(l*h-d*c)/(a*d-u*l),g=(c*u-h*a)/(a*d-u*l);i=m-e,o=g-t}return{width:i,height:o}},BT=e=>{const t={width:e.width,height:e.height,x:e.x,y:e.y};if(e.width<0){const n=Math.abs(e.width);t.width=n,t.x=e.x-n}if(e.height<0){const n=Math.abs(e.height);t.height=n,t.y=e.y-n}return t},ey=(e,t,n)=>t>=e[0]&&t<=e[0]+e[2]&&n>=e[1]&&n<=e[1]+e[3],Fz=(e,t,n,r,i,o,s)=>{if(!n.selectedElementIds[e.id])return!1;const{rotation:a,...l}=mI(e,o,t,s);if(a&&ey(a,r,i))return"rotation";const c=Object.keys(l).filter(u=>{const d=l[u];return d?ey(d,r,i):!1});return c.length>0?c[0]:!1},d6=(e,t,n,r,i,o,s)=>e.reduce((a,l)=>{if(a)return a;const c=Fz(l,s,t,n,r,i,o);return c?{element:l,transformHandleType:c}:null},null),h6=([e,t,n,r],i,o,s,a)=>{const l=tE([e,t,n,r,(e+n)/2,(t+r)/2],0,s,a,fI);return Object.keys(l).find(u=>{const d=l[u];return d&&ey(d,i,o)})||!1},zp=["ns","nesw","ew","nwse"],$z=(e,t)=>{const n=zp.indexOf(e);if(n>=0){const r=Math.round(t/(Math.PI/4));e=zp[(n+r)%zp.length]}return e},f6=e=>{const{element:t,transformHandleType:n}=e,r=t&&Math.sign(t.height)*Math.sign(t.width)===-1;let i=null;switch(n){case"n":case"s":i="ns";break;case"w":case"e":i="ew";break;case"nw":case"se":r?i="nesw":i="nwse";break;case"ne":case"sw":r?i="nwse":i="nesw";break;case"rotation":return"grab"}return i&&t&&(i=$z(i,t.angle)),i?`${i}-resize`:""},Ym=e=>e<0?e+2*Math.PI:e>=2*Math.PI?e-2*Math.PI:e,Bz=(e,t,n,r,i,o,s,a,l,c,u)=>{if(n.length===1){const[d]=n;return t==="rotation"?(zz(d,r,a,l,i),us(d,r)):ce(d)&&(t==="nw"||t==="ne"||t==="sw"||t==="se")?(Wz(d,r,t,o,a,l),us(d,r)):t&&Vz(e,s,d,r,t,o,a,l),!0}else if(n.length>1){if(t==="rotation")return Gz(e,n,r,a,l,i,c,u),!0;if(t==="nw"||t==="ne"||t==="sw"||t==="se")return zT(e,n,r,t,o,a,l),!0}return!1},zz=(e,t,n,r,i)=>{var m;const[o,s,a,l]=Ee(e,t),c=(o+a)/2,u=(s+l)/2;let d;pe(e)?d=0:(d=5*Math.PI/2+Math.atan2(r-u,n-c),i&&(d+=ss/2,d-=d%ss),d=Ym(d));const h=va(e);if(J(e,{angle:d}),h){const g=(m=$t.getScene(e))==null?void 0:m.getElement(h);g&&!Ge(e)&&J(g,{angle:d})}},Hz=(e,t,n,r)=>we(e)||Hn(e)?{points:Kl(0,t,Kl(1,n,e.points,r),r)}:{},RE=(e,t,n)=>{let r=e.width;if(Mt(e)){const s=kn(e,t);s&&(r=Ii(s,e))}const o=e.fontSize*(n/r);return o<Ov?null:{size:o}},Uz=(e,t)=>({n:/^(n|ne|nw)$/.test(e)||t&&/^(s|se|sw)$/.test(e),s:/^(s|se|sw)$/.test(e)||t&&/^(n|ne|nw)$/.test(e),w:/^(w|nw|sw)$/.test(e)||t&&/^(e|ne|se)$/.test(e),e:/^(e|ne|se)$/.test(e)||t&&/^(w|nw|sw)$/.test(e)}),Wz=(e,t,n,r,i,o)=>{const[s,a,l,c]=Ee(e,t),u=(s+l)/2,d=(a+c)/2,[h,m]=_e(i,o,u,d,-e.angle);let g;switch(n){case"se":g=Math.max((h-s)/(l-s),(m-a)/(c-a));break;case"nw":g=Math.max((l-h)/(l-s),(c-m)/(c-a));break;case"ne":g=Math.max((h-s)/(l-s),(c-m)/(c-a));break;case"sw":g=Math.max((l-h)/(l-s),(m-a)/(c-a));break}if(g>0){const p=e.width*g,v=e.height*g,y=RE(e,t,p);if(y===null)return;const[E,w,x,C]=Lu(e,p,v,!1),S=(s-E)/2,I=(a-w)/2,T=(l-x)/2,L=(c-C)/2,[A,F]=nI(Uz(n,r),e.x,e.y,e.angle,S,I,T,L);J(e,{fontSize:y.size,width:p,height:v,x:A,y:F})}},Vz=(e,t,n,r,i,o,s,a)=>{const l=e.get(n.id),[c,u,d,h]=Lu(l,l.width,l.height,!0),m=[c,u],g=[d,h],p=C2(m,g),v=st([s,a],p,-l.angle),[y,E,w,x]=Lu(n,n.width,n.height,!0),C=w-y,S=x-E,I=g[0]-m[0],T=g[1]-m[1];let L=I/C,A=T/S,F={};const P=ke(n,r);i.includes("e")&&(L=(v[0]-m[0])/C),i.includes("s")&&(A=(v[1]-m[1])/S),i.includes("w")&&(L=(g[0]-v[0])/C),i.includes("n")&&(A=(g[1]-v[1])/S);const O=l.width,V=l.height;let G=n.width*L,q=n.height*A;if(o&&(G=2*G-O,q=2*q-V),t){const tn=Math.abs(G)/O,Gn=Math.abs(q)/V;if(i.length===1&&(q*=tn,G*=Gn),i.length===2){const jn=Math.max(tn,Gn);G=O*jn*Math.sign(G),q=V*jn*Math.sign(q)}}if(P){const tn=e.get(P.id);if(tn&&(F={fontSize:tn.fontSize}),t){const Gn={...n,width:G,height:q},jn=RE(P,r,Ii(Gn,P));if(jn===null)return;F={fontSize:jn.size}}else{const Gn=AI(Bt(P),P.lineHeight),jn=CI(P.fontSize,P.lineHeight);G=Math.max(G,Gn),q=Math.max(q,jn)}}const[U,$,Y,R]=Lu(l,G,q,!0),N=Y-U,B=R-$;let z=[...m];if(["n","w","nw"].includes(i)&&(z=[g[0]-Math.abs(N),g[1]-Math.abs(B)]),i==="ne"){const tn=[m[0],g[1]];z=[tn[0],tn[1]-Math.abs(B)]}if(i==="sw"){const tn=[g[0],m[1]];z=[tn[0]-Math.abs(N),tn[1]]}t&&(["s","n"].includes(i)&&(z[0]=p[0]-N/2),["e","w"].includes(i)&&(z[1]=p[1]-B/2));const W=G<0,j=q<0;W&&(i.includes("e")&&(z[0]-=Math.abs(N)),i.includes("w")&&(z[0]+=Math.abs(N))),j&&(i.includes("s")&&(z[1]-=Math.abs(B)),i.includes("n")&&(z[1]+=Math.abs(B))),o&&(z[0]=p[0]-Math.abs(N)/2,z[1]=p[1]-Math.abs(B)/2);const X=l.angle,ee=st(z,p,X),xe=[z[0]+Math.abs(N)/2,z[1]+Math.abs(B)/2],Fe=st(xe,p,X);z=st(ee,Fe,-X);const Se=[...z],Me=l.x-U,Et=l.y-$;Se[0]+=Me,Se[1]+=Et;const it=Se[0],Og=Se[1];let mh,gh;(we(n)||Hn(n))&&(mh=Kl(1,q,l.points,!0),gh=Kl(0,G,mh,!0));const ri={width:Math.abs(G),height:Math.abs(q),x:it,y:Og,points:gh};if("scale"in n&&"scale"in l&&J(n,{scale:[(Math.sign(Y-l.x)||l.scale[0])*l.scale[0],(Math.sign(R-l.y)||l.scale[1])*l.scale[1]]}),Ge(n)&&P&&t){const tn=ri.width/n.width*P.fontSize;if(tn<Ov)return;F.fontSize=tn}ri.width!==0&&ri.height!==0&&Number.isFinite(ri.x)&&Number.isFinite(ri.y)&&(J(n,ri),us(n,r,{newSize:{width:ri.width,height:ri.height}}),P&&F!=null&&J(P,{fontSize:F.fontSize}),j1(n,r,i,t))},zT=(e,t,n,r,i,o,s)=>{var F;const a=t.reduce((P,O)=>{const V=e.get(O.id);return V&&P.push({orig:V,latest:O}),P},[]),l=a.reduce((P,{orig:O})=>{if(!we(O))return P;const V=va(O);if(!V)return P;const G=e.get(V)??null;if(!Mt(G))return P;const q=ue.getBoundTextElementPosition(O,G,n);return[...P,{...G,...q}]},[]),{minX:c,minY:u,maxX:d,maxY:h,midX:m,midY:g}=ji(a.map(({orig:P})=>P).concat(l)),p=r,v={ne:[c,h],se:[c,u],sw:[d,u],nw:[d,h]},[y,E]=i?[m,g]:v[p],w=Math.max(Math.abs(o-y)/(d-c)||0,Math.abs(s-E)/(h-u)||0)*(i?2:1);if(w===0)return;const x={ne:[o>=y,s<=E],se:[o>=y,s>=E],sw:[o<=y,s>=E],nw:[o<=y,s<=E]},[C,S]=x[p].map(P=>P?1:-1),I=C<0,T=S<0,L=[];for(const{orig:P,latest:O}of a){if(ce(P)&&Mt(P))continue;const V=P.width*w,G=P.height*w,q=Ym(P.angle*C*S),U=we(P)||Hn(P),$=P.x-y,Y=P.y-E,R=I&&!U?V:0,N=T&&!U?G:0,B=y+C*($*w+R),z=E+S*(Y*w+N),W=Hz(P,V*C,G*S,!1),j={x:B,y:z,width:V,height:G,angle:q,...W};if(Gi(P)&&a.length===1&&(j.scale=[P.scale[0]*C,P.scale[1]*S]),we(P)&&(I||T)){const ee=Nm(P,P.points),xe=Nm({...P,x:B,y:z},W.points),Fe=[P.x,P.y],Se=[B,z],Me=Et=>{const it=Et==="x"?0:1;return(xe[it+2]-Se[it]-(Fe[it]-ee[it])*w+(ee[it+2]-Fe[it])*w-(Se[it]-xe[it]))/2};I&&(j.x-=Me("x")),T&&(j.y-=Me("y"))}if(ce(P)){const ee=RE(P,n,V);if(!ee)return;j.fontSize=ee.size}const X=e.get(va(P)??"");if(X){const ee=X.fontSize*w;if(ee<Ov)return;j.boundTextFontSize=ee}L.push({element:O,update:j})}const A=L.map(({element:P})=>P);for(const{element:P,update:{boundTextFontSize:O,...V}}of L){const{width:G,height:q,angle:U}=V;J(P,V,!1),us(P,n,{simultaneouslyUpdated:A,newSize:{width:G,height:q}});const $=ke(P,n);$&&O&&(J($,{fontSize:O,angle:we(P)?void 0:U},!1),j1(P,n,r,!0))}(F=$t.getScene(L[0].element))==null||F.informMutation()},Gz=(e,t,n,r,i,o,s,a)=>{var c;let l=5*Math.PI/2+Math.atan2(i-a,r-s);o&&(l+=ss/2,l-=l%ss),t.filter(u=>!pe(u)).forEach(u=>{var C;const[d,h,m,g]=Ee(u,n),p=(d+m)/2,v=(h+g)/2,y=((C=e.get(u.id))==null?void 0:C.angle)??u.angle,[E,w]=_e(p,v,s,a,l+y-u.angle);J(u,{x:u.x+(E-p),y:u.y+(w-v),angle:Ym(l+y)},!1),us(u,n,{simultaneouslyUpdated:t});const x=ke(u,n);x&&!Ge(u)&&J(x,{x:x.x+(E-p),y:x.y+(w-v),angle:Ym(l+y)},!1)}),(c=$t.getScene(t[0]))==null||c.informMutation()},jz=(e,t,n,r,i)=>{const[o,s,a,l]=t.length===1?Ee(t[0],n):nt(t),c=(o+a)/2,u=(s+l)/2,d=t.length===1?t[0].angle:0;switch([r,i]=_e(r,i,c,u,-d),e){case"n":return _e(r-(o+a)/2,i-s,0,0,d);case"s":return _e(r-(o+a)/2,i-l,0,0,d);case"w":return _e(r-o,i-(s+l)/2,0,0,d);case"e":return _e(r-a,i-(s+l)/2,0,0,d);case"nw":return _e(r-o,i-s,0,0,d);case"ne":return _e(r-a,i-s,0,0,d);case"sw":return _e(r-o,i-l,0,0,d);case"se":return _e(r-a,i-l,0,0,d);default:return[0,0]}},Yz=(e,t)=>{const[,[n,r]]=t.points;return e==="nw"&&(n<0||r<0)||e==="ne"&&n>=0||e==="sw"&&n<=0||e==="se"&&(n>0||r>0)?"end":"origin"},Kz=(e,t,n,r,i,o,s)=>{const a=new Set(t),l=t.filter(d=>pe(d)).map(d=>d.id);if(l.length>0)for(const d of i.getNonDeletedElements())d.frameId!==null&&l.includes(d.frameId)&&a.add(d);const c=nt(Array.from(a).map(d=>e.originalElements.get(d.id)??d)),u=Zz(c,n,o,s);a.forEach(d=>{if(m6(e,d,u),!Ge(d)){const h=ke(d,i.getNonDeletedElementsMap());h&&m6(e,h,u)}us(d,i.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(a)})})},Zz=(e,t,n,r)=>{const[i,o]=e;let s=i+t.x+n.x,a=o+t.y+n.y;if(n.x===0||n.y===0){const[l,c]=jt(i+t.x,o+t.y,r);n.x===0&&(s=l),n.y===0&&(a=c)}return{x:s-i,y:a-o}},m6=(e,t,n)=>{const r=e.originalElements.get(t.id)??t,i=r.x+n.x,o=r.y+n.y;J(t,{x:i,y:o})},Xz=(e,t,n)=>{const[r,i]=nt(e);return[t-r,n-i]},g6=(e,t,n,r,i,o,s,a,l,c,u,d=null)=>{l&&e.type!=="selection"&&(u?a=s/u:(Math.abs(o-r)>Math.abs(i-n)?{width:s,height:a}=u6(t,a,i<n?-s:s):{width:s,height:a}=u6(t,s,o<r?-a:a),a<0&&(a=-a)));let h=i<n?n-s:n,m=o<r?r-a:r;c&&(s+=s,a+=a,h=n-s/2,m=r-a/2),s!==0&&a!==0&&J(e,{x:h+((d==null?void 0:d.x)??0),y:m+((d==null?void 0:d.y)??0),width:s,height:a})},DE=(e,t)=>!!(!e.viewModeEnabled&&(e.activeTool.type!=="custom"&&(e.editingElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||qe(t,e).length)),To=e=>e.reduce((t,n)=>t+n.version,0),qz=e=>{let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e[n].versionNonce;return t>>>0},Qz=e=>{let t=5381;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);t=(t<<5)+t+r}return t>>>0},Jz=e=>e.filter(t=>!t.isDeleted&&!Ma(t)),je=e=>e.filter(t=>!t.isDeleted),ty=e=>!e.isDeleted,OE=e=>je(e).map(t=>qv(t.type)?{...t,lastCommittedPoint:null}:t),eH=e=>OE(e),HT=e=>OE(e),UT=e=>OE(e),cg=e=>{const t=new Set;return e.forEach(n=>{pe(n)&&t.add(n.id)}),e.filter(n=>!(n.frameId&&t.has(n.frameId)))},NE=(e,t,n,r=!0)=>{const[i,o,s,a]=Ee(t,n);let l=e.filter(c=>{let[u,d,h,m]=ba(c,n);const g=rr(c,n);if(g){const[p,v,y,E]=ba(g,n);u=Math.max(p,u),d=Math.max(v,d),h=Math.min(y,h),m=Math.min(E,m)}return c.locked===!1&&c.type!=="selection"&&!Mt(c)&&i<=u&&o<=d&&s>=h&&a>=m});return l=r?cg(l):l,l=l.filter(c=>{const u=rr(c,n);return u?Ta(c,u,n):!0}),l},WT=(e,t,n,r)=>{const i=new Set(t.map(o=>o.id));return e.filter(o=>{const s=jm(o,n.width,n.height,n,r);return!i.has(o.id)&&s})},Lt=function(){let e=null,t=null,n=null;const r=(i,o)=>(n!=null&&i===e&&o.selectedElementIds===t||(n=i.some(s=>o.selectedElementIds[s.id]),e=i,t=o.selectedElementIds),n);return r.clearCache=()=>{e=null,t=null,n=null},r}(),tH=(e,t,n)=>{const r=Array.from(new Set(qe(e,t).map(i=>n(i))));return r.length===1?r[0]:null},qe=(e,t,n)=>{const r=[];for(const i of e.values()){if(t.selectedElementIds[i.id]){r.push(i);continue}if(n!=null&&n.includeBoundTextElement&&Mt(i)&&t.selectedElementIds[i==null?void 0:i.containerId]){r.push(i);continue}}if(n!=null&&n.includeElementsInFrames){const i=[];return r.forEach(o=>{pe(o)&&eo(e,o.id).forEach(s=>i.push(s)),i.push(o)}),i}return r},FE=(e,t)=>t.editingElement?[t.editingElement]:qe(e,t,{includeBoundTextElement:!0}),$e=(e,t)=>Jn(t.selectedElementIds,e)?t.selectedElementIds:e,nH=(e,t)=>{const[n,r,i,o]=t,{x:s,y:a}=Ur({sceneX:n,sceneY:r},e),{x:l,y:c}=Ur({sceneX:i,sceneY:o},e);return l-s>e.width||c-a>e.height},VT=({scenePoint:e,viewportDimensions:t,zoom:n})=>({scrollX:t.width/2/n.value-e.x,scrollY:t.height/2/n.value-e.y}),Ld=(e,t)=>{if(e=Jz(e),!e.length)return{scrollX:0,scrollY:0};let[n,r,i,o]=nt(e);nH(t,[n,r,i,o])&&([n,r,i,o]=gN(e,et({clientX:t.scrollX,clientY:t.scrollY},t)));const s=(n+i)/2,a=(r+o)/2;return VT({scenePoint:{x:s,y:a},viewportDimensions:{width:t.width,height:t.height},zoom:t.zoom})},Zs=e=>Math.max(US,Math.min(e,30)),Xs=({viewportX:e,viewportY:t,nextZoom:n},r)=>{const i=e-r.offsetLeft,o=t-r.offsetTop,s=r.zoom.value,a=r.scrollX+(i-i/s),l=r.scrollY+(o-o/s),c=-(i-i/n),u=-(o-o/n);return{scrollX:a+c,scrollY:l+u,zoom:{value:n}}},to=({size:e="1em",circleWidth:t=8,synchronized:n=!1})=>{const i=-(te.useRef(Date.now()).current%1600);return f("div",{className:"Spinner",children:f("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":n?`${i}ms`:0},children:f("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},Ce=te.forwardRef((e,t)=>{const{id:n}=uo(),r=te.useRef(null);te.useImperativeHandle(t,()=>r.current);const i=`ToolIcon_size_${e.size}`,[o,s]=_.useState(!1),a=_.useRef(!0),l=async u=>{var h;const d="onClick"in e&&((h=e.onClick)==null?void 0:h.call(e,u));if(Xd(d))try{s(!0),await d}catch(m){if(m instanceof ql)console.warn(m);else throw m}finally{a.current&&s(!1)}};_.useEffect(()=>(a.current=!0,()=>{a.current=!1}),[]);const c=_.useRef(null);if(e.type==="button"||e.type==="icon"||e.type==="submit"){const u=e.type==="icon"?"button":e.type;return k("button",{className:se("ToolIcon_type_button",i,e.className,e.visible&&!e.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!e.hidden,"ToolIcon--selected":e.selected,"ToolIcon--plain":e.type==="icon"}),style:e.style,"data-testid":e["data-testid"],hidden:e.hidden,title:e.title,"aria-label":e["aria-label"],type:u,onClick:l,ref:r,disabled:o||e.isLoading,children:[(e.icon||e.label)&&k("div",{className:"ToolIcon__icon","aria-hidden":"true",children:[e.icon||e.label,e.keyBindingLabel&&f("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel}),e.isLoading&&f(to,{})]}),e.showAriaLabel&&k("div",{className:"ToolIcon__label",children:[e["aria-label"]," ",o&&f(to,{})]}),e.children]})}return k("label",{className:se("ToolIcon",e.className),title:e.title,onPointerDown:u=>{var d;c.current=u.pointerType||null,(d=e.onPointerDown)==null||d.call(e,{pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{c.current=null})},children:[f("input",{className:`ToolIcon_type_radio ${i}`,type:"radio",name:e.name,"aria-label":e["aria-label"],"aria-keyshortcuts":e["aria-keyshortcuts"],"data-testid":e["data-testid"],id:`${n}-${e.id}`,onChange:()=>{var u;(u=e.onChange)==null||u.call(e,{pointerType:c.current})},checked:e.checked,ref:r}),k("div",{className:"ToolIcon__icon",children:[e.icon,e.keyBindingLabel&&f("span",{className:"ToolIcon__keybinding",children:e.keyBindingLabel})]})]})});Ce.defaultProps={visible:!0,className:"",size:"medium"};Ce.displayName="ToolButton";const Hr=e=>"var(--icon-fill-color)",GT=e=>e===Tt.LIGHT?Ut.white:"#1e1e1e",H=(e,t=512)=>{const{width:n=512,height:r=n,mirror:i,style:o,...s}=typeof t=="number"?{width:t}:t;return f("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${n} ${r}`,className:se({"rtl-mirror":i}),style:o,...s,children:typeof e=="string"?f("path",{fill:"currentColor",d:e}):e})},ye={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},he={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"};H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("rect",{x:3,y:8,width:18,height:4,rx:1}),f("line",{x1:12,y1:8,x2:12,y2:21}),f("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),f("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),ye);const rH=H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),f("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),f("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),f("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),f("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),ye),iH=H(k("svg",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),f("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),ye),oH=H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"12",cy:"12",r:"1"}),f("circle",{cx:"12",cy:"19",r:"1"}),f("circle",{cx:"12",cy:"5",r:"1"})]}),ye),sH=H(k("svg",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),f("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),f("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),ye),aH=H(k("g",{children:[f("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),f("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),f("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:f("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),f("g",{mask:"url(#UnlockedIcon)",children:f("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),he),lH=H(k("g",{strokeWidth:"1.25",children:[f("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),f("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),f("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),he),cH=H(k(re,{children:[f("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),f("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),uH=H(k(re,{children:[f("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),f("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),dH=H(k(re,{children:[f("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),f("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"});H(f("g",{fill:"currentColor",children:f("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"});const hH=H(k("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),f("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),fH=H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),ye),mH=H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),ye),gH=H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"12",cy:"12",r:"9"})]}),ye),pH=H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),f("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),f("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),ye),yH=H(f("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),he),vH=H(k("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),f("path",{d:"M16 7h4"}),f("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),ye),$E=H(k("g",{strokeWidth:"1.25",children:[f("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),f("path",{d:"m11.25 5.417 3.333 3.333"})]}),he),EH=H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),f("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),f("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),f("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),f("polyline",{points:"5 20 11 4 13 4 20 20"})]}),ye),wH=H(k("g",{strokeWidth:"1.25",children:[f("path",{d:"M12.5 6.667h.01"}),f("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),f("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),f("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),he),bH=H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),f("path",{d:"M18 13.3l-6.3 -6.3"})]}),ye),_H=H(f("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),he),xH=H(f("path",{d:"M5 10h10",strokeWidth:"1.25"}),he),ug=H(f("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),he),SH=H(k("g",{strokeWidth:"1.25",children:[f("polyline",{points:"12 16 18 10 12 4"}),f("polyline",{points:"8 4 2 10 8 16"})]}),he),kH=H(k("g",{strokeWidth:"1.25",children:[f("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),f("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),he),IH=H(f("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),he),CH=H(f("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:f("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),he),jT=H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),f("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),f("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),ye),YT=H(f("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),he),BE=H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"12",cy:"12",r:"9"}),f("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),f("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),ye),Hp=H(f("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),he),KT=H(f("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),he),TH=H(k("g",{strokeWidth:"1.25",children:[f("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),f("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),he),MH=H(k("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),f("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),ye),AH=H(f("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),zE=H(k("g",{strokeWidth:"1.25",children:[f("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),f("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),he),LH=H("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),PH=H("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),HE=H(f("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),he);H("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512});const RH=H("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),DH=H(k("g",{strokeWidth:"1.25",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M15 8h.01"}),f("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),f("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),f("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),f("path",{d:"M19 16v6"}),f("path",{d:"M22 19l-3 3l-3 -3"})]}),ye),OH=H("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512});H("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512});H("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512});const NH=H("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z");H("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z");const FH=H(f("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),he),$H=H(f("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),he),BH=H("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),ZT=H(f("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),he),zH=H("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),HH=H("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),UH=H(k(re,{children:[f("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),f("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64});H(f("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024});const WH=H(k(re,{children:[k("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{d:"M13.889 4.167H8.333c-.767 0-1.389.622-1.389 1.389v5.555c0 .767.622 1.389 1.39 1.389h5.555c.767 0 1.389-.622 1.389-1.389V5.556c0-.767-.622-1.39-1.39-1.39Z",fill:"currentColor"}),f("path",{d:"M12.5 12.5v1.389a1.389 1.389 0 0 1-1.389 1.389H5.556a1.389 1.389 0 0 1-1.39-1.39V8.334a1.389 1.389 0 0 1 1.39-1.389h1.388"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),VH=H(k(re,{children:[k("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.944 12.5H12.5v1.389a1.389 1.389 0 0 1-1.389 1.389H5.556a1.389 1.389 0 0 1-1.39-1.39V8.334a1.389 1.389 0 0 1 1.39-1.389h1.388",fill:"currentColor"}),f("path",{d:"M13.889 4.167H8.333c-.767 0-1.389.621-1.389 1.389v5.555c0 .767.622 1.389 1.39 1.389h5.555c.767 0 1.389-.622 1.389-1.389V5.556c0-.768-.622-1.39-1.39-1.39Z"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),GH=H(k(re,{children:[k("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M8.775 6.458h2.45a2.316 2.316 0 0 1 2.317 2.316v2.452a2.316 2.316 0 0 1-2.316 2.316H8.774a2.316 2.316 0 0 1-2.317-2.316V8.774a2.316 2.316 0 0 1 2.317-2.316Z",fill:"currentColor"}),f("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316ZM12.108 3.125h2.45a2.316 2.316 0 0 1 2.317 2.316v2.451a2.316 2.316 0 0 1-2.316 2.316h-2.451a2.316 2.316 0 0 1-2.316-2.316v-2.45a2.316 2.316 0 0 1 2.316-2.317Z"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),jH=H(k(re,{children:[k("g",{clipPath:"url(#a)",children:[f("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316Z",stroke:"currentColor",strokeWidth:"1.25"}),f("path",{d:"M5.441 9.792h2.451a2.316 2.316 0 0 1 2.316 2.316v2.45a2.316 2.316 0 0 1-2.316 2.317h-2.45a2.316 2.316 0 0 1-2.317-2.316v-2.451a2.316 2.316 0 0 1 2.316-2.316Z",stroke:"currentColor",strokeWidth:"1.25"}),f("mask",{id:"SendToBackIcon",fill:"#fff",children:f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.167 5.833v2.06a2.941 2.941 0 0 0 2.94 2.94h2.06v.393a2.941 2.941 0 0 1-2.941 2.94h-.393v-2.058a2.941 2.941 0 0 0-2.94-2.941h-2.06v-.393a2.941 2.941 0 0 1 2.942-2.94h.392Z"})}),f("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.167 5.833v2.06a2.941 2.941 0 0 0 2.94 2.94h2.06v.393a2.941 2.941 0 0 1-2.941 2.94h-.393v-2.058a2.941 2.941 0 0 0-2.94-2.941h-2.06v-.393a2.941 2.941 0 0 1 2.942-2.94h.392Z",fill:"currentColor"}),f("path",{d:"M9.167 5.833h1.25v-1.25h-1.25v1.25Zm5 5h1.25v-1.25h-1.25v1.25Zm-3.334 3.334h-1.25v1.25h1.25v-1.25Zm-5-5h-1.25v1.25h1.25v-1.25Zm2.084-3.334v2.06h2.5v-2.06h-2.5Zm0 2.06a4.191 4.191 0 0 0 4.19 4.19v-2.5a1.691 1.691 0 0 1-1.69-1.69h-2.5Zm4.19 4.19h2.06v-2.5h-2.06v2.5Zm.81-1.25v.393h2.5v-.393h-2.5Zm0 .393c0 .933-.758 1.69-1.691 1.69v2.5a4.191 4.191 0 0 0 4.19-4.19h-2.5Zm-1.691 1.69h-.393v2.5h.393v-2.5Zm.857 1.25v-2.058h-2.5v2.059h2.5Zm0-2.058a4.191 4.191 0 0 0-4.19-4.191v2.5c.933 0 1.69.757 1.69 1.69h2.5Zm-4.19-4.191h-2.06v2.5h2.06v-2.5Zm-.81 1.25v-.393h-2.5v.393h2.5Zm0-.393c0-.934.758-1.69 1.692-1.69v-2.5a4.191 4.191 0 0 0-4.192 4.19h2.5Zm1.692-1.69h.392v-2.5h-.392v2.5Z",fill:"currentColor",mask:"url(#SendToBackIcon)"}),f("path",{d:"M12.108 3.125h2.45a2.316 2.316 0 0 1 2.317 2.316v2.451a2.316 2.316 0 0 1-2.316 2.316h-2.451a2.316 2.316 0 0 1-2.316-2.316v-2.45a2.316 2.316 0 0 1 2.316-2.317Z",stroke:"currentColor",strokeWidth:"1.25"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),YH=H(k(re,{children:[k("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),KH=H(k(re,{children:[k("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),ZH=H(k(re,{children:[k("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),XH=H(k(re,{children:[k("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),qH=H(k(re,{children:[k("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),QH=H(k(re,{children:[k("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),JH=H(k("g",{stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),f("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),he),eU=H(k("g",{stroke:"currentColor",strokeWidth:"1.25",children:[f("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),f("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),f("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),he),dg=H(k("g",{strokeWidth:"1.5",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("circle",{cx:"9",cy:"7",r:"4"}),f("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),f("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),f("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),ye);H("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z");H("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z");const yc=H(k(re,{children:[f("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:f("path",{d:"M15 5 5 15M5 5l10 10"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),tU=H("M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z",{width:320,height:512,style:{marginLeft:"-0.2rem"},mirror:!0});H("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0});const nU=H("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24});H("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512});const rU=te.memo(({theme:e})=>H(k(re,{children:[f("path",{d:"M25 26H111V111H25",fill:Hr()}),f("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Hr(),strokeWidth:"2"}),f("path",{d:"M100 100H160V160H100",fill:Hr()}),f("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Hr(),strokeWidth:"2"}),k("g",{fill:GT(e),stroke:Hr(),strokeWidth:"6",children:[f("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),f("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),iU=te.memo(({theme:e})=>H(k(re,{children:[f("path",{d:"M25 26H111V111H25",fill:Hr()}),f("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Hr(),strokeWidth:"2"}),f("path",{d:"M100 100H160V160H100",fill:Hr()}),f("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Hr(),strokeWidth:"2"}),k("g",{fill:GT(e),stroke:Hr(),strokeWidth:"6",children:[f("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),f("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),f("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),f("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),f("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),oU=H(f("g",{strokeWidth:1.25,children:f("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),he),sU=H(k(re,{children:[f("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),f("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:f("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),f("g",{mask:"url(#FillHachureIcon)",children:f("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),he),aU=H(k(re,{children:[k("g",{clipPath:"url(#a)",children:[f("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),f("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:f("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),f("g",{mask:"url(#FillCrossHatchIcon)",children:f("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),lU=H(k(re,{children:[f("g",{clipPath:"url(#a)",children:f("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...he,fill:"currentColor"}),XT=H(f(re,{children:f("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),he),cU=H(f("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),he),uU=H(f("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),he);te.memo(({theme:e})=>H(f("path",{d:"M6 10H34",stroke:Hr(),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20}));const dU=H(k("g",{strokeWidth:"2",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 12h2"}),f("path",{d:"M17 12h2"}),f("path",{d:"M11 12h2"})]}),ye),hU=H(k("g",{strokeWidth:"2",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 12v.01"}),f("path",{d:"M8 12v.01"}),f("path",{d:"M12 12v.01"}),f("path",{d:"M16 12v.01"}),f("path",{d:"M20 12v.01"})]}),ye),fU=H(f("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),he),mU=H(f("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),he),gU=H(f("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),he),pU=H(k("svg",{strokeWidth:"1.5",children:[f("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),f("path",{d:"M13.3333 3.33331V3.34331"}),f("path",{d:"M16.6667 3.33331V3.34331"}),f("path",{d:"M16.6667 6.66669V6.67669"}),f("path",{d:"M16.6667 10V10.01"}),f("path",{d:"M3.33334 13.3333V13.3433"}),f("path",{d:"M16.6667 13.3333V13.3433"}),f("path",{d:"M3.33334 16.6667V16.6767"}),f("path",{d:"M6.66666 16.6667V16.6767"}),f("path",{d:"M10 16.6667V16.6767"}),f("path",{d:"M13.3333 16.6667V16.6767"}),f("path",{d:"M16.6667 16.6667V16.6767"})]}),he),yU=H(k("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),f("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),f("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),f("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),f("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),f("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),f("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),f("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),f("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),f("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),f("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),f("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),ye),vU=H(f("path",{d:"M6 10H34",stroke:"currentColor",strokeWidth:2,fill:"none"}),{width:40,height:20}),EU=te.memo(({flip:e=!1})=>H(k("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[f("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),f("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),p6=te.memo(({flip:e=!1})=>H(k("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[f("path",{d:"M32 10L6 10",strokeWidth:2}),f("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),wU=te.memo(({flip:e=!1})=>H(k("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[f("path",{d:"M26 10L6 10"}),f("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),bU=te.memo(({flip:e=!1})=>H(f("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:f("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),_U=te.memo(({flip:e=!1})=>H(k("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[f("path",{d:"M32 10L6 10",strokeWidth:2}),f("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),xU=te.memo(({flip:e=!1})=>H(k("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[f("path",{d:"M6,9.5H27"}),f("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),SU=te.memo(({flip:e=!1})=>H(k("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[f("path",{d:"M6,9.5H20"}),f("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),kU=te.memo(({flip:e=!1})=>H(k("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[f("path",{d:"M6,9.5H20"}),f("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),IU=H(k(re,{children:[f("g",{clipPath:"url(#a)",children:f("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),CU=H(k(re,{children:[f("g",{clipPath:"url(#a)",children:f("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),TU=H(k(re,{children:[f("g",{clipPath:"url(#a)",children:f("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),MU=H(f(re,{children:f("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),he),AU=H(f(re,{children:f("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:f("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),he),LU=H(k(re,{children:[f("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:f("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),f("defs",{children:f("clipPath",{id:"a",children:f("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),he),PU=H(k("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),f("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),f("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),ye),RU=H(k("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),f("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),f("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),ye),DU=H(k("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),f("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),f("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),ye),OU=te.memo(({theme:e})=>H(k("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),f("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),ye)),NU=te.memo(({theme:e})=>H(k("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),f("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),ye)),FU=te.memo(({theme:e})=>H(k("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),f("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),f("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),ye)),$U=H(f("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512});H(f("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"}));const BU=H(k("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),f("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),f("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),f("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),ye),y6=H(k(re,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),f("path",{d:"M7 11l5 5l5 -5"}),f("path",{d:"M12 4l0 12"})]}),ye),hg=H(k(re,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),f("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),ye),zU=H(k(re,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),f("path",{d:"M12 17l0 .01"}),f("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),ye),HU=H(k(re,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M7 4v16l13 -8z"})]}),ye),UU=H(k(re,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),ye),qT=H(k(re,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M5 12l5 5l10 -10"})]}),ye),WU=H(k(re,{children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),f("path",{d:"M12 9v4"}),f("path",{d:"M12 17h.01"})]}),ye),VU=H(k("g",{strokeWidth:1.25,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M11 7l6 6"}),f("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),ye),GU=H(k("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M12 3l-4 7h8z"}),f("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),f("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),ye),jU=H(k("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 7l16 0"}),f("path",{d:"M4 17l16 0"}),f("path",{d:"M7 4l0 16"}),f("path",{d:"M17 4l0 16"})]}),ye),YU=H(f("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),Vf=H(k("g",{strokeWidth:"1.25",children:[f("path",{d:"M4.16602 10H15.8327"}),f("path",{d:"M12.5 13.3333L15.8333 10"}),f("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),he),QT=H(k("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[f("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),f("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),UE=H(k("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z"}),f("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),f("path",{d:"M15 6l3 3"}),f("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),f("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),ye),ny=H(k("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),f("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),f("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),f("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),f("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),f("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),ye),KU=H(k("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),f("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),f("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),f("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),ye),JT=H(k("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),f("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),ye),ZU=H(k("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),f("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),f("path",{d:"M3 3l18 18"})]}),ye),XU=H(k("g",{stroke:"currentColor",fill:"none",children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),f("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),f("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),f("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),f("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),f("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),ye),qU=H(k("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),f("path",{d:"M21 21l-6 -6"})]}),ye),QU=H(k("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),f("path",{d:"M5 10a7 7 0 0 0 14 0"}),f("path",{d:"M8 21l8 0"}),f("path",{d:"M12 17l0 4"})]}),ye),JU=H(k("g",{strokeWidth:1.5,children:[f("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),f("path",{d:"M3 3l18 18"}),f("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),f("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),f("path",{d:"M8 21l8 0"}),f("path",{d:"M12 17l0 4"})]}),ye),eW=(e,t)=>{const n=new Set(qe(e.filter(r=>pe(r)),t).map(r=>r.id));return{elements:e.map(r=>t.selectedElementIds[r.id]?ge(r,{isDeleted:!0}):r.frameId&&n.has(r.frameId)?ge(r,{isDeleted:!0}):Mt(r)&&t.selectedElementIds[r.containerId]?ge(r,{isDeleted:!0}):r),appState:{...t,selectedElementIds:{},selectedGroupIds:{}}}},v6=(e,t)=>{if(e.editingGroupId){const n=It(je(t),e.editingGroupId);if(n.length)return{...e,selectedElementIds:{[n[0].id]:!0}}}return e},e8=ne({name:"deleteSelectedElements",trackEvent:{category:"element",action:"delete"},perform:(e,t,n,r)=>{if(t.editingLinearElement){const{elementId:s,selectedPointsIndices:a,startBindingElement:l,endBindingElement:c}=t.editingLinearElement,u=r.scene.getNonDeletedElementsMap(),d=ue.getElement(s,u);if(!d||a==null)return!1;if(d.points.length<2){const m=e.map(p=>p.id===d.id?ge(p,{isDeleted:!0}):p),g=v6(t,m);return{elements:m,appState:{...g,editingLinearElement:null},commitToHistory:!1}}const h={startBindingElement:a!=null&&a.includes(0)?null:l,endBindingElement:a!=null&&a.includes(d.points.length-1)?null:c};return ue.deletePoints(d,a),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...h,selectedPointsIndices:(a==null?void 0:a[0])>0?[a[0]-1]:[0]}},commitToHistory:!0}}let{elements:i,appState:o}=eW(e,t);return aE(i,e.filter(({id:s})=>t.selectedElementIds[s])),o=v6(o,i),{elements:i,appState:{...o,activeTool:bt(t,{type:"selection"}),multiElement:null,activeEmbeddable:null},commitToHistory:Lt(je(e),t)}},contextItemLabel:"labels.delete",keyTest:(e,t,n)=>(e.key===D.BACKSPACE||e.key===D.DELETE)&&!e[D.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:n})=>f(Ce,{type:"button",icon:ug,title:b("labels.delete"),"aria-label":b("labels.delete"),onClick:()=>n(null),visible:Lt(je(e),t)})}),ry=(e,t)=>e.frameId===t||e.id===t,t8=(e,t,n)=>{let r=[],i=[],o=null,s=-1;const a=be(n||qe(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++s<e.length;){const l=e[s];a.get(l.id)?(i.length&&(r=r.concat(i),i=[]),r.push(s),o=s+1):l.isDeleted&&o===s?(o=s+1,i.push(s)):i=[]}return r},tW=e=>{let t=0;return e.reduce((n,r,i)=>(i>0&&e[i-1]!==r-1&&(t=++t),(n[t]||(n[t]=[])).push(r),n),[])},E6=(e,t,n)=>{var r,i;if("containerId"in e&&e.containerId)if(n==="left"){const o=$t.getScene(e).getElement(e.containerId);if(o)return t.indexOf(o)}else return t.indexOf(e);else{const o=(i=(r=e.boundElements)==null?void 0:r.find(s=>s.type!=="arrow"))==null?void 0:i.id;if(o){if(n==="left")return t.indexOf(e);const s=$t.getScene(e).getElement(o);if(s)return t.indexOf(s)}}},nW=(e,t)=>{let n=-1,r=-1;return e.forEach((i,o)=>{ry(i,t)&&(n===-1&&(n=o),r=o)}),n===-1?[]:e.slice(n,r+1)},rW=(e,t,n,r,i)=>{const o=t[n],s=d=>d.isDeleted?!1:i?d.frameId===i:e.editingGroupId?d.groupIds.includes(e.editingGroupId):!0,a=r==="left"?Yk(t,d=>s(d),Math.max(0,n-1)):jk(t,d=>s(d),n+1),l=t[a];if(!l)return-1;if(e.editingGroupId){if((o==null?void 0:o.groupIds.join(""))===(l==null?void 0:l.groupIds.join("")))return E6(l,t,r)??a;if(!(l!=null&&l.groupIds.includes(e.editingGroupId)))return-1}if(!i&&(l.frameId||pe(l))){const d=nW(t,l.frameId||l.id);return r==="left"?t.indexOf(d[0]):t.indexOf(d[d.length-1])}if(!l.groupIds.length)return E6(l,t,r)??a;const c=e.editingGroupId?l.groupIds[l.groupIds.indexOf(e.editingGroupId)-1]:l.groupIds[l.groupIds.length-1],u=It(t,c);return u.length?r==="left"?t.indexOf(u[0]):t.indexOf(u[u.length-1]):a},n8=(e,t)=>t.reduce((n,r)=>{const i=e[r];return n[i.id]=i,n},{}),r8=(e,t,n)=>{const r=t8(e,t),i=n8(e,r);let o=tW(r);n==="right"&&(o=o.reverse());const s=new Set(r.filter(a=>pe(e[a])).map(a=>e[a].id));return o.forEach((a,l)=>{var E;const c=a[0],u=a[a.length-1],d=n==="left"?c:u,h=a.some(w=>{const x=e[w];return x.frameId&&s.has(x.frameId)})?null:(E=e[d])==null?void 0:E.frameId,m=rW(t,e,d,n,h);if(m===-1||d===m)return;const g=n==="left"?e.slice(0,m):e.slice(0,c),p=e.slice(c,u+1),v=n==="left"?e.slice(m,c):e.slice(u+1,m+1),y=n==="left"?e.slice(u+1):e.slice(m+1);e=n==="left"?[...g,...p,...v,...y]:[...g,...v,...p,...y]}),e.map(a=>i[a.id]?pc(a):a)},i8=(e,t,n,r,i)=>{const o=t8(e,t,i),s=n8(e,o),a=[];let l,c;if(n==="left"){if(r)l=jk(e,m=>ry(m,r));else if(t.editingGroupId){const m=It(e,t.editingGroupId);if(!m.length)return e;l=e.indexOf(m[0])}else l=0;c=o[o.length-1]}else{if(r)c=Yk(e,m=>ry(m,r));else if(t.editingGroupId){const m=It(e,t.editingGroupId);if(!m.length)return e;c=e.indexOf(m[m.length-1])}else c=e.length-1;l=o[0]}l===-1&&(l=0);for(let m=l;m<c+1;m++)o.includes(m)||a.push(e[m]);const u=Object.values(s).map(m=>pc(m)),d=e.slice(0,l),h=e.slice(c+1);return n==="left"?[...d,...u,...a,...h]:[...d,...a,...u,...h]};function o8(e,t,n,r){const i=be(qe(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),o={regularElements:[],frameChildren:new Map},s=new Set;for(const c of e)i.has(c.id)&&pe(c)&&s.add(c.id);for(const c of e)if(i.has(c.id))if(pe(c)||c.frameId&&s.has(c.frameId))o.regularElements.push(c);else if(!c.frameId)o.regularElements.push(c);else{const u=o.frameChildren.get(c.frameId)||[];u.push(c),o.frameChildren.set(c.frameId,u)}let a=e;const l=Array.from(o.frameChildren.entries());for(const[c,u]of l)a=r(e,t,n,c,u);return r(a,t,n,null,o.regularElements)}const iW=(e,t)=>r8(e,t,"left"),oW=(e,t)=>r8(e,t,"right"),sW=(e,t)=>o8(e,t,"left",i8),aW=(e,t)=>o8(e,t,"right",i8),lW=ne({name:"sendBackward",trackEvent:{category:"element"},perform:(e,t)=>({elements:iW(e,t),appState:t,commitToHistory:!0}),contextItemLabel:"labels.sendBackward",keyPriority:40,keyTest:e=>e[D.CTRL_OR_CMD]&&!e.shiftKey&&e.code===De.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>f("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.sendBackward")} — ${K("CtrlOrCmd+[")}`,children:VH})}),cW=ne({name:"bringForward",trackEvent:{category:"element"},perform:(e,t)=>({elements:oW(e,t),appState:t,commitToHistory:!0}),contextItemLabel:"labels.bringForward",keyPriority:40,keyTest:e=>e[D.CTRL_OR_CMD]&&!e.shiftKey&&e.code===De.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>f("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.bringForward")} — ${K("CtrlOrCmd+]")}`,children:WH})}),uW=ne({name:"sendToBack",trackEvent:{category:"element"},perform:(e,t)=>({elements:sW(e,t),appState:t,commitToHistory:!0}),contextItemLabel:"labels.sendToBack",keyTest:e=>ki?e[D.CTRL_OR_CMD]&&e.altKey&&e.code===De.BRACKET_LEFT:e[D.CTRL_OR_CMD]&&e.shiftKey&&e.code===De.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>f("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${b("labels.sendToBack")} — ${K(ki?"CtrlOrCmd+Alt+[":"CtrlOrCmd+Shift+[")}`,children:jH})}),dW=ne({name:"bringToFront",trackEvent:{category:"element"},perform:(e,t)=>({elements:aW(e,t),appState:t,commitToHistory:!0}),contextItemLabel:"labels.bringToFront",keyTest:e=>ki?e[D.CTRL_OR_CMD]&&e.altKey&&e.code===De.BRACKET_RIGHT:e[D.CTRL_OR_CMD]&&e.shiftKey&&e.code===De.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>f("button",{type:"button",className:"zIndexButton",onClick:n=>e(null),title:`${b("labels.bringToFront")} — ${K(ki?"CtrlOrCmd+Alt+]":"CtrlOrCmd+Shift+]")}`,children:GH})}),hW=ne({name:"selectAll",trackEvent:{category:"canvas"},perform:(e,t,n,r)=>{if(t.editingLinearElement)return!1;const i=cg(e.filter(o=>!o.isDeleted&&!(ce(o)&&o.containerId)&&!o.locked)).reduce((o,s)=>(o[s.id]=!0,o),{});return{appState:{...t,...Zn({editingGroupId:null,selectedElementIds:i},je(e),t,r),selectedLinearElement:Object.keys(i).length===1&&we(e[0])?new ue(e[0]):null},commitToHistory:!0}},contextItemLabel:"labels.selectAll",keyTest:e=>e[D.CTRL_OR_CMD]&&e.key===D.A}),fW=e=>{const t=e.slice(),n=new Set,r=o=>{var c,u,d;const s=(u=(c=o[0])==null?void 0:c.groupIds)==null?void 0:u.join(""),a=[o[0]],l=[];for(const h of o.slice(1))((d=h.groupIds)==null?void 0:d.join(""))===s?a.push(h):l.push(h);return l.length?[...a,...r(l)]:a},i=new Map;return t.forEach((o,s)=>{var a;if(!i.has(o.id))if((a=o.groupIds)!=null&&a.length){const l=o.groupIds[o.groupIds.length-1],c=t.slice(s).filter(u=>{var h;const d=(h=u==null?void 0:u.groupIds)==null?void 0:h.some(m=>m===l);return d&&i.set(u.id,!0),d});for(const u of r(c))n.add(u)}else n.add(o)}),n.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...n]},mW=e=>{const t=Zk(e),n=e.slice(),r=new Set;return n.forEach((i,o)=>{var s,a;if(i)if((s=i.boundElements)!=null&&s.length)r.add(i),n[o]=null,i.boundElements.forEach(l=>{const c=t.get(l.id);c&&l.type==="text"&&(r.add(c[0]),n[c[1]]=null)});else if(i.type==="text"&&i.containerId){const l=t.get(i.containerId);(a=l==null?void 0:l[0].boundElements)!=null&&a.find(c=>c.id===i.id)||(r.add(i),n[o]=null)}else r.add(i),n[o]=null}),r.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...r]},gW=e=>mW(fW(e)),pW=ne({name:"duplicateSelection",trackEvent:{category:"element"},perform:(e,t,n,r)=>{const i=r.scene.getNonDeletedElementsMap();if(t.editingLinearElement){const o=ue.duplicateSelectedPoints(t,i);return o?{elements:e,appState:o.appState,commitToHistory:!0}:!1}return{...yW(e,t),commitToHistory:!0}},contextItemLabel:"labels.duplicateSelection",keyTest:e=>e[D.CTRL_OR_CMD]&&e.key===D.D,PanelComponent:({elements:e,appState:t,updateData:n})=>f(Ce,{type:"button",icon:kH,title:`${b("labels.duplicateSelection")} — ${K("CtrlOrCmd+D")}`,"aria-label":b("labels.duplicateSelection"),onClick:()=>n(null),visible:Lt(je(e),t)})}),yW=(e,t)=>{const n=gW(e),r=new Map,i=[],o=[],s=new Map,a=y=>{const E=jI(t.editingGroupId,r,y,{x:y.x+Cl/2,y:y.y+Cl/2});return s.set(y.id,E.id),o.push(y),i.push(E),E},l=be(qe(n,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),c=new Map,u=y=>{for(const E of y)c.set(E.id,!0);return y},d=[];let h=-1;for(;++h<n.length;){const y=n[h];if(c.get(y.id))continue;const E=ke(y,be(e)),w=pe(y);if(l.get(y.id)){if(y.groupIds.length||E||w){const x=OI(t,y);if(x){const C=It(n,x).flatMap(S=>pe(S)?[...eo(e,S.id),S]:[S]);d.push(...u([...C,...C.map(S=>a(S))]));continue}if(E){d.push(...u([y,E,a(y),a(E)]));continue}if(w){const C=eo(n,y.id);d.push(...u([...C,y,...C.map(S=>a(S)),a(y)]));continue}}(!y.frameId||!l.has(y.frameId))&&d.push(...u([y,a(y)]))}else d.push(...u([y]))}const m=[],g=new Map;for(h=d.length;--h>=0;){const y=d[h];g.get(y.id)||(g.set(y.id,!0),m.push(y))}const p=m.reverse();kI(d,o,s),xI(d,o,s),_T(p,o,s);const v=cg(i);return{elements:p,appState:{...t,...Zn({editingGroupId:t.editingGroupId,selectedElementIds:v.reduce((y,E)=>(Mt(E)||(y[E.id]=!0),y),{})},je(p),t,null)}}},lo=e=>f("div",{className:"buttonList buttonListIcon",children:e.options.map(t=>e.type==="button"?f("button",{onClick:n=>e.onClick(t.value,n),className:se({active:t.active??e.value===t.value}),"data-testid":t.testId,title:t.text,children:t.icon},t.text):k("label",{className:se({active:e.value===t.value}),title:t.text,children:[f("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))}),vW=({onChange:e,type:t,activeColor:n,topPicks:r})=>{let i;return t==="elementStroke"&&(i=OS),t==="elementBackground"&&(i=NS),t==="canvasBackground"&&(i=FS),r&&(i=r),i?f("div",{className:"color-picker__top-picks",children:i.map(o=>f("button",{className:se("color-picker__button",{active:o===n,"is-transparent":o==="transparent"||!o}),style:{"--swatch-color":o},type:"button",title:o,onClick:()=>e(o),"data-testid":`color-top-pick-${o}`,children:f("div",{className:"color-picker__button-outline"})},o))}):(console.error("Invalid type for TopPicks"),null)},fg=({palette:e,color:t})=>{for(const[n,r]of Object.entries(e))if(Array.isArray(r)){const i=r.indexOf(t);if(i>-1)return{colorName:n,shade:i}}else if(r===t)return{colorName:n,shade:null};return null},iy=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),s8=({color:e,palette:t})=>!Object.values(t).flat().includes(e),EW=(e,t,n)=>{const r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},i=e.filter(s=>{if(s.isDeleted)return!1;const a=s[r[t]];return s8({color:a,palette:n})}),o=new Map;return i.forEach(s=>{const a=s[r[t]];o.has(a)?o.set(a,o.get(a)+1):o.set(a,1)}),[...o.entries()].sort((s,a)=>a[1]-s[1]).map(s=>s[0]).slice(0,VP)},vc=mt(null),w6=(e,t,n)=>(e*299+t*587+n*114)/1e3>=160?"black":"white",wW=(e,t)=>{if(t){const o=new Option().style;if(o.color=e,o.color){const s=o.color.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),a=parseInt(s[0]),l=parseInt(s[1]),c=parseInt(s[2]);return w6(a,l,c)}}if(e==="transparent")return"black";const n=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),i=parseInt(e.substring(5,7),16);return w6(n,r,i)},WE=({color:e,keyLabel:t,isCustomColor:n=!1,isShade:r=!1})=>k("div",{className:"color-picker__button__hotkey-label",style:{color:wW(e,n)},children:[r&&"⇧",t]}),bW=({hex:e,onChange:t,palette:n})=>{const r=fg({color:e||"transparent",palette:n}),[i,o]=ze(vc),s=_.useRef(null);if(_.useEffect(()=>{s.current&&i==="shades"&&s.current.focus()},[r,i]),r){const{colorName:a,shade:l}=r,c=n[a];if(Array.isArray(c))return f("div",{className:"color-picker-content--default shades",children:c.map((u,d)=>k("button",{ref:d===l&&i==="shades"?s:void 0,tabIndex:-1,type:"button",className:se("color-picker__button color-picker__button--large",{active:d===l}),"aria-label":"Shade",title:`${a} - ${d+1}`,style:u?{"--swatch-color":u}:void 0,onClick:()=>{t(u),o("shades")},children:[f("div",{className:"color-picker__button-outline"}),f(WE,{color:u,keyLabel:d+1,isShade:!0})]},d))})}return k("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[f("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),f("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:b("colorPicker.noShades")})]})},_W=({palette:e,color:t,onChange:n,label:r,activeShade:i})=>{const o=fg({color:t||"transparent",palette:e}),[s,a]=ze(vc),l=_.useRef(null);return _.useEffect(()=>{l.current&&s==="baseColors"&&l.current.focus()},[o==null?void 0:o.colorName,s]),f("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,u],d)=>{const h=(Array.isArray(u)?u[i]:u)||"transparent",m=iy[d],g=b(`colors.${c.replace(/\d+/,"")}`,null,"");return k("button",{ref:(o==null?void 0:o.colorName)===c?l:void 0,tabIndex:-1,type:"button",className:se("color-picker__button color-picker__button--large",{active:(o==null?void 0:o.colorName)===c,"is-transparent":h==="transparent"||!h}),onClick:()=>{n(h),a("baseColors")},title:`${g}${h.startsWith("#")?` ${h}`:""} — ${m}`,"aria-label":`${g} — ${m}`,style:h?{"--swatch-color":h}:void 0,"data-testid":`color-${c}`,children:[f("div",{className:"color-picker__button-outline"}),f(WE,{color:h,keyLabel:m})]},c)})})},xW=({colors:e,color:t,onChange:n,label:r})=>{const[i,o]=ze(vc),s=_.useRef(null);return _.useEffect(()=>{s.current&&s.current.focus()},[t,i]),f("div",{className:"color-picker-content--default",children:e.map((a,l)=>k("button",{ref:t===a?s:void 0,tabIndex:-1,type:"button",className:se("color-picker__button color-picker__button--large",{active:t===a,"is-transparent":a==="transparent"||!a}),onClick:()=>{n(a),o("custom")},title:a,"aria-label":r,style:{"--swatch-color":a},children:[f("div",{className:"color-picker__button-outline"}),f(WE,{color:a,keyLabel:l+1,isCustomColor:!0})]},l))})},Up=(e,t,n)=>{const r=Math.ceil(n/Qa);switch(t=t??-1,e){case"ArrowLeft":{const i=t-1;return i<0?n-1:i}case"ArrowRight":return(t+1)%n;case"ArrowDown":{const i=t+Qa;return i>=n?t%Qa:i}case"ArrowUp":{const i=t-Qa,o=i<0?Qa*r+i:i;return o>=n?void 0:o}}},SW=({e,colorObj:t,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:o,activeShade:s})=>{if((t==null?void 0:t.shade)!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){const a=Number(e.code.slice(-1))-1;return n(r[t.colorName][a]),o("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&i[Number(e.key)-1])return n(i[Number(e.key)-1]),o("custom"),!0;if(iy.includes(e.key)){const a=iy.indexOf(e.key),l=Object.keys(r)[a],c=r[l],u=Array.isArray(c)?c[s]:c;return n(u),o("baseColors"),!0}return!1},kW=({event:e,activeColorPickerSection:t,palette:n,color:r,onChange:i,customColors:o,setActiveColorPickerSection:s,updateData:a,activeShade:l,onEyeDropperToggle:c,onEscape:u})=>{if(e[D.CTRL_OR_CMD])return!1;if(e.key===D.ESCAPE)return u(e),!0;if(e.key===D.ALT)return c(!0),!0;if(e.key===D.I)return c(),!0;const d=fg({color:r,palette:n});if(e.key===D.TAB){const h={custom:!!o.length,baseColors:!0,shades:(d==null?void 0:d.shade)!=null,hex:!0},m=Object.entries(h).reduce((E,[w,x])=>(x&&E.push(w),E),[]),g=m.indexOf(t),p=e.shiftKey?-1:1,v=g+p>m.length-1?0:g+p<0?m.length-1:g+p,y=m[v];return y&&s(y),y==="custom"?i(o[0]):y==="baseColors"&&(Object.entries(n).find(([w,x])=>Array.isArray(x)?x.includes(r):x===r?w:null)||i(ve.black)),e.preventDefault(),e.stopPropagation(),!0}if(SW({e,colorObj:d,onChange:i,palette:n,customColors:o,setActiveColorPickerSection:s,activeShade:l}))return!0;if(t==="shades"&&d){const{shade:h}=d,m=Up(e.key,h,Qa);if(m!==void 0)return i(n[d.colorName][m]),!0}if(t==="baseColors"&&d){const{colorName:h}=d,m=Object.keys(n),g=m.indexOf(h),p=Up(e.key,g,m.length);if(p!==void 0){const v=m[p],y=n[v];return i(Array.isArray(y)?y[l]:y),!0}}if(t==="custom"){const h=o.indexOf(r),m=Up(e.key,h,o.length);if(m!==void 0){const g=o[m];return i(g),!0}}return!1},Gf=({children:e})=>f("div",{className:"color-picker__heading",children:e}),IW=({color:e,onChange:t,label:n,type:r,elements:i,palette:o,updateData:s,children:a,onEyeDropperToggle:l,onEscape:c})=>{const[u]=te.useState(()=>r==="canvasBackground"?[]:EW(i,r,o)),[d,h]=ze(vc),m=fg({color:e,palette:o});_.useEffect(()=>{if(!d){const y=s8({color:e,palette:o}),E=y&&!u.includes(e);h(E?"hex":y?"custom":(m==null?void 0:m.shade)!=null?"shades":"baseColors")}},[d,e,o,h,m,u]);const[g,p]=_.useState((m==null?void 0:m.shade)??(r==="elementBackground"?cu:lu));_.useEffect(()=>{(m==null?void 0:m.shade)!=null&&p(m.shade);const y=E=>{E.key===D.ALT&&l(!1)};return document.addEventListener(Z.KEYUP,y,{capture:!0}),()=>{document.removeEventListener(Z.KEYUP,y,{capture:!0})}},[m,l]);const v=te.useRef(null);return f("div",{role:"dialog","aria-modal":"true","aria-label":b("labels.colorPicker"),children:k("div",{ref:v,onKeyDown:y=>{kW({event:y,activeColorPickerSection:d,palette:o,color:e,onChange:t,onEyeDropperToggle:l,customColors:u,setActiveColorPickerSection:h,updateData:s,activeShade:g,onEscape:c})&&(y.preventDefault(),y.stopPropagation())},className:"color-picker-content",tabIndex:-1,children:[!!u.length&&k("div",{children:[f(Gf,{children:b("colorPicker.mostUsedCustomColors")}),f(xW,{colors:u,color:e,label:b("colorPicker.mostUsedCustomColors"),onChange:t})]}),k("div",{children:[f(Gf,{children:b("colorPicker.colors")}),f(_W,{color:e,label:n,palette:o,onChange:t,activeShade:g})]}),k("div",{children:[f(Gf,{children:b("colorPicker.shades")}),f(bW,{hex:e,onChange:t,palette:o})]}),a]})})};function Ye(){return Ye=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ye.apply(this,arguments)}function hn(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function CW(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function a8(...e){return t=>e.forEach(n=>CW(n,t))}function Ci(...e){return _.useCallback(a8(...e),e)}function ah(e,t=[]){let n=[];function r(o,s){const a=_.createContext(s),l=n.length;n=[...n,s];function c(d){const{scope:h,children:m,...g}=d,p=(h==null?void 0:h[e][l])||a,v=_.useMemo(()=>g,Object.values(g));return _.createElement(p.Provider,{value:v},m)}function u(d,h){const m=(h==null?void 0:h[e][l])||a,g=_.useContext(m);if(g)return g;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${o}\``)}return c.displayName=o+"Provider",[c,u]}const i=()=>{const o=n.map(s=>_.createContext(s));return function(a){const l=(a==null?void 0:a[e])||o;return _.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return i.scopeName=e,[r,TW(i,...t)]}function TW(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(o)[`__scope${c}`];return{...a,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}const Pd=_.forwardRef((e,t)=>{const{children:n,...r}=e,i=_.Children.toArray(n),o=i.find(AW);if(o){const s=o.props.children,a=i.map(l=>l===o?_.Children.count(s)>1?_.Children.only(null):_.isValidElement(s)?s.props.children:null:l);return _.createElement(oy,Ye({},r,{ref:t}),_.isValidElement(s)?_.cloneElement(s,void 0,a):null)}return _.createElement(oy,Ye({},r,{ref:t}),n)});Pd.displayName="Slot";const oy=_.forwardRef((e,t)=>{const{children:n,...r}=e;return _.isValidElement(n)?_.cloneElement(n,{...LW(r,n.props),ref:a8(t,n.ref)}):_.Children.count(n)>1?_.Children.only(null):null});oy.displayName="SlotClone";const MW=({children:e})=>_.createElement(_.Fragment,null,e);function AW(e){return _.isValidElement(e)&&e.type===MW}function LW(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...a)=>{o(...a),i(...a)}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}const PW=["a","button","div","h2","h3","img","label","li","nav","ol","p","span","svg","ul"],Un=PW.reduce((e,t)=>{const n=_.forwardRef((r,i)=>{const{asChild:o,...s}=r,a=o?Pd:t;return _.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),_.createElement(a,Ye({},s,{ref:i}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function RW(e,t){e&&nr.flushSync(()=>e.dispatchEvent(t))}function no(e){const t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function DW(e,t=globalThis==null?void 0:globalThis.document){const n=no(e);_.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)},[n,t])}const sy="dismissableLayer.update",OW="dismissableLayer.pointerDownOutside",NW="dismissableLayer.focusOutside";let b6;const FW=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),$W=_.forwardRef((e,t)=>{var n;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:a,onDismiss:l,...c}=e,u=_.useContext(FW),[d,h]=_.useState(null),m=(n=d==null?void 0:d.ownerDocument)!==null&&n!==void 0?n:globalThis==null?void 0:globalThis.document,[,g]=_.useState({}),p=Ci(t,T=>h(T)),v=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),E=v.indexOf(y),w=d?v.indexOf(d):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,C=w>=E,S=BW(T=>{const L=T.target,A=[...u.branches].some(F=>F.contains(L));!C||A||(o==null||o(T),a==null||a(T),T.defaultPrevented||l==null||l())},m),I=zW(T=>{const L=T.target;[...u.branches].some(F=>F.contains(L))||(s==null||s(T),a==null||a(T),T.defaultPrevented||l==null||l())},m);return DW(T=>{w===u.layers.size-1&&(i==null||i(T),!T.defaultPrevented&&l&&(T.preventDefault(),l()))},m),_.useEffect(()=>{if(d)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(b6=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),_6(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=b6)}},[d,m,r,u]),_.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),_6())},[d,u]),_.useEffect(()=>{const T=()=>g({});return document.addEventListener(sy,T),()=>document.removeEventListener(sy,T)},[]),_.createElement(Un.div,Ye({},c,{ref:p,style:{pointerEvents:x?C?"auto":"none":void 0,...e.style},onFocusCapture:hn(e.onFocusCapture,I.onFocusCapture),onBlurCapture:hn(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:hn(e.onPointerDownCapture,S.onPointerDownCapture)}))});function BW(e,t=globalThis==null?void 0:globalThis.document){const n=no(e),r=_.useRef(!1),i=_.useRef(()=>{});return _.useEffect(()=>{const o=a=>{if(a.target&&!r.current){let c=function(){l8(OW,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=c,t.addEventListener("click",i.current,{once:!0})):c()}r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",o),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function zW(e,t=globalThis==null?void 0:globalThis.document){const n=no(e),r=_.useRef(!1);return _.useEffect(()=>{const i=o=>{o.target&&!r.current&&l8(NW,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function _6(){const e=new CustomEvent(sy);document.dispatchEvent(e)}function l8(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?RW(i,o):i.dispatchEvent(o)}let Wp=0;function HW(){_.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:x6()),document.body.insertAdjacentElement("beforeend",(t=n[1])!==null&&t!==void 0?t:x6()),Wp++,()=>{Wp===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),Wp--}},[])}function x6(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",e}const Vp="focusScope.autoFocusOnMount",Gp="focusScope.autoFocusOnUnmount",S6={bubbles:!1,cancelable:!0},UW=_.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...s}=e,[a,l]=_.useState(null),c=no(i),u=no(o),d=_.useRef(null),h=Ci(t,p=>l(p)),m=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(r){let p=function(y){if(m.paused||!a)return;const E=y.target;a.contains(E)?d.current=E:Ps(d.current,{select:!0})},v=function(y){m.paused||!a||a.contains(y.relatedTarget)||Ps(d.current,{select:!0})};return document.addEventListener("focusin",p),document.addEventListener("focusout",v),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",v)}}},[r,a,m.paused]),_.useEffect(()=>{if(a){I6.add(m);const p=document.activeElement;if(!a.contains(p)){const y=new CustomEvent(Vp,S6);a.addEventListener(Vp,c),a.dispatchEvent(y),y.defaultPrevented||(WW(KW(c8(a)),{select:!0}),document.activeElement===p&&Ps(a))}return()=>{a.removeEventListener(Vp,c),setTimeout(()=>{const y=new CustomEvent(Gp,S6);a.addEventListener(Gp,u),a.dispatchEvent(y),y.defaultPrevented||Ps(p??document.body,{select:!0}),a.removeEventListener(Gp,u),I6.remove(m)},0)}}},[a,c,u,m]);const g=_.useCallback(p=>{if(!n&&!r||m.paused)return;const v=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,y=document.activeElement;if(v&&y){const E=p.currentTarget,[w,x]=VW(E);w&&x?!p.shiftKey&&y===x?(p.preventDefault(),n&&Ps(w,{select:!0})):p.shiftKey&&y===w&&(p.preventDefault(),n&&Ps(x,{select:!0})):y===E&&p.preventDefault()}},[n,r,m.paused]);return _.createElement(Un.div,Ye({tabIndex:-1},s,{ref:h,onKeyDown:g}))});function WW(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ps(r,{select:t}),document.activeElement!==n)return}function VW(e){const t=c8(e),n=k6(t,e),r=k6(t.reverse(),e);return[n,r]}function c8(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function k6(e,t){for(const n of e)if(!GW(n,{upTo:t}))return n}function GW(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 jW(e){return e instanceof HTMLInputElement&&"select"in e}function Ps(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&jW(e)&&t&&e.select()}}const I6=YW();function YW(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=C6(e,t),e.unshift(t)},remove(t){var n;e=C6(e,t),(n=e[0])===null||n===void 0||n.resume()}}}function C6(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function KW(e){return e.filter(t=>t.tagName!=="A")}const zo=globalThis!=null&&globalThis.document?_.useLayoutEffect:()=>{},ZW=QA.useId||(()=>{});let XW=0;function VE(e){const[t,n]=_.useState(ZW());return zo(()=>{e||n(r=>r??String(XW++))},[e]),e||(t?`radix-${t}`:"")}function $a(e){return e.split("-")[0]}function lh(e){return e.split("-")[1]}function Ec(e){return["top","bottom"].includes($a(e))?"x":"y"}function GE(e){return e==="y"?"height":"width"}function T6(e,t,n){let{reference:r,floating:i}=e;const o=r.x+r.width/2-i.width/2,s=r.y+r.height/2-i.height/2,a=Ec(t),l=GE(a),c=r[l]/2-i[l]/2,u=a==="x";let d;switch($a(t)){case"top":d={x:o,y:r.y-i.height};break;case"bottom":d={x:o,y:r.y+r.height};break;case"right":d={x:r.x+r.width,y:s};break;case"left":d={x:r.x-i.width,y:s};break;default:d={x:r.x,y:r.y}}switch(lh(t)){case"start":d[a]-=c*(n&&u?-1:1);break;case"end":d[a]+=c*(n&&u?-1:1)}return d}const qW=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=n,a=await(s.isRTL==null?void 0:s.isRTL(t));let l=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:c,y:u}=T6(l,r,a),d=r,h={},m=0;for(let g=0;g<o.length;g++){const{name:p,fn:v}=o[g],{x:y,y:E,data:w,reset:x}=await v({x:c,y:u,initialPlacement:r,placement:d,strategy:i,middlewareData:h,rects:l,platform:s,elements:{reference:e,floating:t}});c=y??c,u=E??u,h={...h,[p]:{...h[p],...w}},x&&m<=50&&(m++,typeof x=="object"&&(x.placement&&(d=x.placement),x.rects&&(l=x.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:c,y:u}=T6(l,d,a)),g=-1)}return{x:c,y:u,placement:d,strategy:i,middlewareData:h}};function u8(e){return typeof e!="number"?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(e):{top:e,right:e,bottom:e,left:e}}function Km(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}async function Rd(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:m=0}=t,g=u8(m),p=a[h?d==="floating"?"reference":"floating":d],v=Km(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(p)))==null||n?p:p.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),y=Km(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({rect:d==="floating"?{...s.floating,x:r,y:i}:s.reference,offsetParent:await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),strategy:l}):s[d]);return{top:v.top-y.top+g.top,bottom:y.bottom-v.bottom+g.bottom,left:v.left-y.left+g.left,right:y.right-v.right+g.right}}const QW=Math.min,Rs=Math.max;function ay(e,t,n){return Rs(e,QW(t,n))}const M6=e=>({name:"arrow",options:e,async fn(t){const{element:n,padding:r=0}=e??{},{x:i,y:o,placement:s,rects:a,platform:l}=t;if(n==null)return{};const c=u8(r),u={x:i,y:o},d=Ec(s),h=lh(s),m=GE(d),g=await l.getDimensions(n),p=d==="y"?"top":"left",v=d==="y"?"bottom":"right",y=a.reference[m]+a.reference[d]-u[d]-a.floating[m],E=u[d]-a.reference[d],w=await(l.getOffsetParent==null?void 0:l.getOffsetParent(n));let x=w?d==="y"?w.clientHeight||0:w.clientWidth||0:0;x===0&&(x=a.floating[m]);const C=y/2-E/2,S=c[p],I=x-g[m]-c[v],T=x/2-g[m]/2+C,L=ay(S,T,I),A=(h==="start"?c[p]:c[v])>0&&T!==L&&a.reference[m]<=a.floating[m];return{[d]:u[d]-(A?T<S?S-T:I-T:0),data:{[d]:L,centerOffset:T-L}}}}),JW={left:"right",right:"left",bottom:"top",top:"bottom"};function Zm(e){return e.replace(/left|right|bottom|top/g,t=>JW[t])}function eV(e,t,n){n===void 0&&(n=!1);const r=lh(e),i=Ec(e),o=GE(i);let s=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=Zm(s)),{main:s,cross:Zm(s)}}const tV={start:"end",end:"start"};function A6(e){return e.replace(/start|end/g,t=>tV[t])}const d8=["top","right","bottom","left"];d8.reduce((e,t)=>e.concat(t,t+"-start",t+"-end"),[]);const nV=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n;const{placement:r,middlewareData:i,rects:o,initialPlacement:s,platform:a,elements:l}=t,{mainAxis:c=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",flipAlignment:m=!0,...g}=e,p=$a(r),v=d||(p===s||!m?[Zm(s)]:function(T){const L=Zm(T);return[A6(T),L,A6(L)]}(s)),y=[s,...v],E=await Rd(t,g),w=[];let x=((n=i.flip)==null?void 0:n.overflows)||[];if(c&&w.push(E[p]),u){const{main:T,cross:L}=eV(r,o,await(a.isRTL==null?void 0:a.isRTL(l.floating)));w.push(E[T],E[L])}if(x=[...x,{placement:r,overflows:w}],!w.every(T=>T<=0)){var C,S;const T=((C=(S=i.flip)==null?void 0:S.index)!=null?C:0)+1,L=y[T];if(L)return{data:{index:T,overflows:x},reset:{placement:L}};let A="bottom";switch(h){case"bestFit":{var I;const F=(I=x.map(P=>[P,P.overflows.filter(O=>O>0).reduce((O,V)=>O+V,0)]).sort((P,O)=>P[1]-O[1])[0])==null?void 0:I[0].placement;F&&(A=F);break}case"initialPlacement":A=s}if(r!==A)return{reset:{placement:A}}}return{}}}};function L6(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function P6(e){return d8.some(t=>e[t]>=0)}const rV=function(e){let{strategy:t="referenceHidden",...n}=e===void 0?{}:e;return{name:"hide",async fn(r){const{rects:i}=r;switch(t){case"referenceHidden":{const o=L6(await Rd(r,{...n,elementContext:"reference"}),i.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:P6(o)}}}case"escaped":{const o=L6(await Rd(r,{...n,altBoundary:!0}),i.floating);return{data:{escapedOffsets:o,escaped:P6(o)}}}default:return{}}}}},iV=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){const{x:n,y:r}=t,i=await async function(o,s){const{placement:a,platform:l,elements:c}=o,u=await(l.isRTL==null?void 0:l.isRTL(c.floating)),d=$a(a),h=lh(a),m=Ec(a)==="x",g=["left","top"].includes(d)?-1:1,p=u&&m?-1:1,v=typeof s=="function"?s(o):s;let{mainAxis:y,crossAxis:E,alignmentAxis:w}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...v};return h&&typeof w=="number"&&(E=h==="end"?-1*w:w),m?{x:E*p,y:y*g}:{x:y*g,y:E*p}}(t,e);return{x:n+i.x,y:r+i.y,data:i}}}};function h8(e){return e==="x"?"y":"x"}const oV=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:v=>{let{x:y,y:E}=v;return{x:y,y:E}}},...l}=e,c={x:n,y:r},u=await Rd(t,l),d=Ec($a(i)),h=h8(d);let m=c[d],g=c[h];if(o){const v=d==="y"?"bottom":"right";m=ay(m+u[d==="y"?"top":"left"],m,m-u[v])}if(s){const v=h==="y"?"bottom":"right";g=ay(g+u[h==="y"?"top":"left"],g,g-u[v])}const p=a.fn({...t,[d]:m,[h]:g});return{...p,data:{x:p.x-n,y:p.y-r}}}}},sV=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=e,u={x:n,y:r},d=Ec(i),h=h8(d);let m=u[d],g=u[h];const p=typeof a=="function"?a({...o,placement:i}):a,v=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(l){const C=d==="y"?"height":"width",S=o.reference[d]-o.floating[C]+v.mainAxis,I=o.reference[d]+o.reference[C]-v.mainAxis;m<S?m=S:m>I&&(m=I)}if(c){var y,E,w,x;const C=d==="y"?"width":"height",S=["top","left"].includes($a(i)),I=o.reference[h]-o.floating[C]+(S&&(y=(E=s.offset)==null?void 0:E[h])!=null?y:0)+(S?0:v.crossAxis),T=o.reference[h]+o.reference[C]+(S?0:(w=(x=s.offset)==null?void 0:x[h])!=null?w:0)-(S?v.crossAxis:0);g<I?g=I:g>T&&(g=T)}return{[d]:m,[h]:g}}}},aV=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:o}=t,{apply:s,...a}=e,l=await Rd(t,a),c=$a(n),u=lh(n);let d,h;c==="top"||c==="bottom"?(d=c,h=u===(await(i.isRTL==null?void 0:i.isRTL(o.floating))?"start":"end")?"left":"right"):(h=c,d=u==="end"?"top":"bottom");const m=Rs(l.left,0),g=Rs(l.right,0),p=Rs(l.top,0),v=Rs(l.bottom,0),y={availableHeight:r.floating.height-(["left","right"].includes(n)?2*(p!==0||v!==0?p+v:Rs(l.top,l.bottom)):l[d]),availableWidth:r.floating.width-(["top","bottom"].includes(n)?2*(m!==0||g!==0?m+g:Rs(l.left,l.right)):l[h])},E=await i.getDimensions(o.floating);s==null||s({...t,...y});const w=await i.getDimensions(o.floating);return E.width!==w.width||E.height!==w.height?{reset:{rects:!0}}:{}}}};function f8(e){return e&&e.document&&e.location&&e.alert&&e.setInterval}function co(e){if(e==null)return window;if(!f8(e)){const t=e.ownerDocument;return t&&t.defaultView||window}return e}function ch(e){return co(e).getComputedStyle(e)}function Yi(e){return f8(e)?"":e?(e.nodeName||"").toLowerCase():""}function m8(){const e=navigator.userAgentData;return e!=null&&e.brands?e.brands.map(t=>t.brand+"/"+t.version).join(" "):navigator.userAgent}function Ti(e){return e instanceof co(e).HTMLElement}function fs(e){return e instanceof co(e).Element}function jE(e){return typeof ShadowRoot>"u"?!1:e instanceof co(e).ShadowRoot||e instanceof ShadowRoot}function mg(e){const{overflow:t,overflowX:n,overflowY:r}=ch(e);return/auto|scroll|overlay|hidden/.test(t+r+n)}function lV(e){return["table","td","th"].includes(Yi(e))}function R6(e){const t=/firefox/i.test(m8()),n=ch(e);return n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].includes(n.willChange)||t&&n.willChange==="filter"||t&&!!n.filter&&n.filter!=="none"}function g8(){return!/^((?!chrome|android).)*safari/i.test(m8())}const D6=Math.min,Fu=Math.max,Xm=Math.round;function Ki(e,t,n){var r,i,o,s;t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect();let l=1,c=1;t&&Ti(e)&&(l=e.offsetWidth>0&&Xm(a.width)/e.offsetWidth||1,c=e.offsetHeight>0&&Xm(a.height)/e.offsetHeight||1);const u=fs(e)?co(e):window,d=!g8()&&n,h=(a.left+(d&&(r=(i=u.visualViewport)==null?void 0:i.offsetLeft)!=null?r:0))/l,m=(a.top+(d&&(o=(s=u.visualViewport)==null?void 0:s.offsetTop)!=null?o:0))/c,g=a.width/l,p=a.height/c;return{width:g,height:p,top:m,right:h+g,bottom:m+p,left:h,x:h,y:m}}function ts(e){return(t=e,(t instanceof co(t).Node?e.ownerDocument:e.document)||window.document).documentElement;var t}function gg(e){return fs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function p8(e){return Ki(ts(e)).left+gg(e).scrollLeft}function cV(e,t,n){const r=Ti(t),i=ts(t),o=Ki(e,r&&function(l){const c=Ki(l);return Xm(c.width)!==l.offsetWidth||Xm(c.height)!==l.offsetHeight}(t),n==="fixed");let s={scrollLeft:0,scrollTop:0};const a={x:0,y:0};if(r||!r&&n!=="fixed")if((Yi(t)!=="body"||mg(i))&&(s=gg(t)),Ti(t)){const l=Ki(t,!0);a.x=l.x+t.clientLeft,a.y=l.y+t.clientTop}else i&&(a.x=p8(i));return{x:o.left+s.scrollLeft-a.x,y:o.top+s.scrollTop-a.y,width:o.width,height:o.height}}function y8(e){return Yi(e)==="html"?e:e.assignedSlot||e.parentNode||(jE(e)?e.host:null)||ts(e)}function O6(e){return Ti(e)&&getComputedStyle(e).position!=="fixed"?e.offsetParent:null}function ly(e){const t=co(e);let n=O6(e);for(;n&&lV(n)&&getComputedStyle(n).position==="static";)n=O6(n);return n&&(Yi(n)==="html"||Yi(n)==="body"&&getComputedStyle(n).position==="static"&&!R6(n))?t:n||function(r){let i=y8(r);for(jE(i)&&(i=i.host);Ti(i)&&!["html","body"].includes(Yi(i));){if(R6(i))return i;i=i.parentNode}return null}(e)||t}function N6(e){if(Ti(e))return{width:e.offsetWidth,height:e.offsetHeight};const t=Ki(e);return{width:t.width,height:t.height}}function v8(e){const t=y8(e);return["html","body","#document"].includes(Yi(t))?e.ownerDocument.body:Ti(t)&&mg(t)?t:v8(t)}function qm(e,t){var n;t===void 0&&(t=[]);const r=v8(e),i=r===((n=e.ownerDocument)==null?void 0:n.body),o=co(r),s=i?[o].concat(o.visualViewport||[],mg(r)?r:[]):r,a=t.concat(s);return i?a:a.concat(qm(s))}function F6(e,t,n){return t==="viewport"?Km(function(r,i){const o=co(r),s=ts(r),a=o.visualViewport;let l=s.clientWidth,c=s.clientHeight,u=0,d=0;if(a){l=a.width,c=a.height;const h=g8();(h||!h&&i==="fixed")&&(u=a.offsetLeft,d=a.offsetTop)}return{width:l,height:c,x:u,y:d}}(e,n)):fs(t)?function(r,i){const o=Ki(r,!1,i==="fixed"),s=o.top+r.clientTop,a=o.left+r.clientLeft;return{top:s,left:a,x:a,y:s,right:a+r.clientWidth,bottom:s+r.clientHeight,width:r.clientWidth,height:r.clientHeight}}(t,n):Km(function(r){var i;const o=ts(r),s=gg(r),a=(i=r.ownerDocument)==null?void 0:i.body,l=Fu(o.scrollWidth,o.clientWidth,a?a.scrollWidth:0,a?a.clientWidth:0),c=Fu(o.scrollHeight,o.clientHeight,a?a.scrollHeight:0,a?a.clientHeight:0);let u=-s.scrollLeft+p8(r);const d=-s.scrollTop;return ch(a||o).direction==="rtl"&&(u+=Fu(o.clientWidth,a?a.clientWidth:0)-l),{width:l,height:c,x:u,y:d}}(ts(e)))}function uV(e){const t=qm(e),n=["absolute","fixed"].includes(ch(e).position)&&Ti(e)?ly(e):e;return fs(n)?t.filter(r=>fs(r)&&function(i,o){const s=o.getRootNode==null?void 0:o.getRootNode();if(i.contains(o))return!0;if(s&&jE(s)){let a=o;do{if(a&&i===a)return!0;a=a.parentNode||a.host}while(a)}return!1}(r,n)&&Yi(r)!=="body"):[]}const dV={getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?uV(t):[].concat(n),r],s=o[0],a=o.reduce((l,c)=>{const u=F6(t,c,i);return l.top=Fu(u.top,l.top),l.right=D6(u.right,l.right),l.bottom=D6(u.bottom,l.bottom),l.left=Fu(u.left,l.left),l},F6(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{rect:t,offsetParent:n,strategy:r}=e;const i=Ti(n),o=ts(n);if(n===o)return t;let s={scrollLeft:0,scrollTop:0};const a={x:0,y:0};if((i||!i&&r!=="fixed")&&((Yi(n)!=="body"||mg(o))&&(s=gg(n)),Ti(n))){const l=Ki(n,!0);a.x=l.x+n.clientLeft,a.y=l.y+n.clientTop}return{...t,x:t.x-s.scrollLeft+a.x,y:t.y-s.scrollTop+a.y}},isElement:fs,getDimensions:N6,getOffsetParent:ly,getDocumentElement:ts,getElementRects:e=>{let{reference:t,floating:n,strategy:r}=e;return{reference:cV(t,ly(n),r),floating:{...N6(n),x:0,y:0}}},getClientRects:e=>Array.from(e.getClientRects()),isRTL:e=>ch(e).direction==="rtl"};function hV(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s=!0,animationFrame:a=!1}=r,l=i&&!a,c=o&&!a,u=l||c?[...fs(e)?qm(e):[],...qm(t)]:[];u.forEach(g=>{l&&g.addEventListener("scroll",n,{passive:!0}),c&&g.addEventListener("resize",n)});let d,h=null;if(s){let g=!0;h=new ResizeObserver(()=>{g||n(),g=!1}),fs(e)&&!a&&h.observe(e),h.observe(t)}let m=a?Ki(e):null;return a&&function g(){const p=Ki(e);!m||p.x===m.x&&p.y===m.y&&p.width===m.width&&p.height===m.height||n(),m=p,d=requestAnimationFrame(g)}(),n(),()=>{var g;u.forEach(p=>{l&&p.removeEventListener("scroll",n),c&&p.removeEventListener("resize",n)}),(g=h)==null||g.disconnect(),h=null,a&&cancelAnimationFrame(d)}}const fV=(e,t,n)=>qW(e,t,{platform:dV,...n});var cy=typeof document<"u"?_.useLayoutEffect:_.useEffect;function uy(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,i;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(!uy(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!uy(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function mV(e){const t=_.useRef(e);return cy(()=>{t.current=e}),t}function gV(e){let{middleware:t,placement:n="bottom",strategy:r="absolute",whileElementsMounted:i}=e===void 0?{}:e;const o=_.useRef(null),s=_.useRef(null),a=mV(i),l=_.useRef(null),[c,u]=_.useState({x:null,y:null,strategy:r,placement:n,middlewareData:{}}),[d,h]=_.useState(t);uy(d==null?void 0:d.map(w=>{let{options:x}=w;return x}),t==null?void 0:t.map(w=>{let{options:x}=w;return x}))||h(t);const m=_.useCallback(()=>{!o.current||!s.current||fV(o.current,s.current,{middleware:d,placement:n,strategy:r}).then(w=>{g.current&&nr.flushSync(()=>{u(w)})})},[d,n,r]);cy(()=>{g.current&&m()},[m]);const g=_.useRef(!1);cy(()=>(g.current=!0,()=>{g.current=!1}),[]);const p=_.useCallback(()=>{if(typeof l.current=="function"&&(l.current(),l.current=null),o.current&&s.current)if(a.current){const w=a.current(o.current,s.current,m);l.current=w}else m()},[m,a]),v=_.useCallback(w=>{o.current=w,p()},[p]),y=_.useCallback(w=>{s.current=w,p()},[p]),E=_.useMemo(()=>({reference:o,floating:s}),[]);return _.useMemo(()=>({...c,update:m,refs:E,reference:v,floating:y}),[c,m,E,v,y])}const pV=e=>{const{element:t,padding:n}=e;function r(i){return Object.prototype.hasOwnProperty.call(i,"current")}return{name:"arrow",options:e,fn(i){return r(t)?t.current!=null?M6({element:t.current,padding:n}).fn(i):{}:t?M6({element:t,padding:n}).fn(i):{}}}},yV=_.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...o}=e;return _.createElement(Un.svg,Ye({},o,{ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none"}),e.asChild?n:_.createElement("polygon",{points:"0,0 30,0 15,10"}))}),vV=yV;function EV(e){const[t,n]=_.useState(void 0);return zo(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];let s,a;if("borderBoxSize"in o){const l=o.borderBoxSize,c=Array.isArray(l)?l[0]:l;s=c.inlineSize,a=c.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const E8="Popper",[YE,w8]=ah(E8),[wV,b8]=YE(E8),bV=e=>{const{__scopePopper:t,children:n}=e,[r,i]=_.useState(null);return _.createElement(wV,{scope:t,anchor:r,onAnchorChange:i},n)},_V="PopperAnchor",xV=_.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,o=b8(_V,n),s=_.useRef(null),a=Ci(t,s);return _.useEffect(()=>{o.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:_.createElement(Un.div,Ye({},i,{ref:a}))}),Qm="PopperContent",[SV,kV]=YE(Qm),[IV,CV]=YE(Qm,{hasParent:!1,positionUpdateFns:new Set}),TV=_.forwardRef((e,t)=>{var n,r,i,o,s,a,l,c;const{__scopePopper:u,side:d="bottom",sideOffset:h=0,align:m="center",alignOffset:g=0,arrowPadding:p=0,collisionBoundary:v=[],collisionPadding:y=0,sticky:E="partial",hideWhenDetached:w=!1,avoidCollisions:x=!0,onPlaced:C,...S}=e,I=b8(Qm,u),[T,L]=_.useState(null),A=Ci(t,za=>L(za)),[F,P]=_.useState(null),O=EV(F),V=(n=O==null?void 0:O.width)!==null&&n!==void 0?n:0,G=(r=O==null?void 0:O.height)!==null&&r!==void 0?r:0,q=d+(m!=="center"?"-"+m:""),U=typeof y=="number"?y:{top:0,right:0,bottom:0,left:0,...y},$=Array.isArray(v)?v:[v],Y=$.length>0,R={padding:U,boundary:$.filter(RV),altBoundary:Y},{reference:N,floating:B,strategy:z,x:W,y:j,placement:X,middlewareData:ee,update:xe}=gV({strategy:"fixed",placement:q,whileElementsMounted:hV,middleware:[DV(),iV({mainAxis:h+G,alignmentAxis:g}),x?oV({mainAxis:!0,crossAxis:!1,limiter:E==="partial"?sV():void 0,...R}):void 0,F?pV({element:F,padding:p}):void 0,x?nV({...R}):void 0,aV({...R,apply:({elements:za,availableWidth:PA,availableHeight:RA})=>{za.floating.style.setProperty("--radix-popper-available-width",`${PA}px`),za.floating.style.setProperty("--radix-popper-available-height",`${RA}px`)}}),OV({arrowWidth:V,arrowHeight:G}),w?rV({strategy:"referenceHidden"}):void 0].filter(PV)});zo(()=>{N(I.anchor)},[N,I.anchor]);const Fe=W!==null&&j!==null,[Se,Me]=_8(X),Et=no(C);zo(()=>{Fe&&(Et==null||Et())},[Fe,Et]);const it=(i=ee.arrow)===null||i===void 0?void 0:i.x,Og=(o=ee.arrow)===null||o===void 0?void 0:o.y,mh=((s=ee.arrow)===null||s===void 0?void 0:s.centerOffset)!==0,[gh,ri]=_.useState();zo(()=>{T&&ri(window.getComputedStyle(T).zIndex)},[T]);const{hasParent:tn,positionUpdateFns:Gn}=CV(Qm,u),jn=!tn;_.useLayoutEffect(()=>{if(!jn)return Gn.add(xe),()=>{Gn.delete(xe)}},[jn,Gn,xe]),zo(()=>{jn&&Fe&&Array.from(Gn).reverse().forEach(za=>requestAnimationFrame(za))},[jn,Fe,Gn]);const Vw={"data-side":Se,"data-align":Me,...S,ref:A,style:{...S.style,animation:Fe?void 0:"none",opacity:(a=ee.hide)!==null&&a!==void 0&&a.referenceHidden?0:void 0}};return _.createElement("div",{ref:B,"data-radix-popper-content-wrapper":"",style:{position:z,left:0,top:0,transform:Fe?`translate3d(${Math.round(W)}px, ${Math.round(j)}px, 0)`:"translate3d(0, -200%, 0)",minWidth:"max-content",zIndex:gh,"--radix-popper-transform-origin":[(l=ee.transformOrigin)===null||l===void 0?void 0:l.x,(c=ee.transformOrigin)===null||c===void 0?void 0:c.y].join(" ")},dir:e.dir},_.createElement(SV,{scope:u,placedSide:Se,onArrowChange:P,arrowX:it,arrowY:Og,shouldHideArrow:mh},jn?_.createElement(IV,{scope:u,hasParent:!0,positionUpdateFns:Gn},_.createElement(Un.div,Vw)):_.createElement(Un.div,Vw)))}),MV="PopperArrow",AV={top:"bottom",right:"left",bottom:"top",left:"right"},LV=_.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,o=kV(MV,r),s=AV[o.placedSide];return _.createElement("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0}},_.createElement(vV,Ye({},i,{ref:n,style:{...i.style,display:"block"}})))});function PV(e){return e!==void 0}function RV(e){return e!==null}const DV=()=>({name:"anchorCssProperties",fn(e){const{rects:t,elements:n}=e,{width:r,height:i}=t.reference;return n.floating.style.setProperty("--radix-popper-anchor-width",`${r}px`),n.floating.style.setProperty("--radix-popper-anchor-height",`${i}px`),{}}}),OV=e=>({name:"transformOrigin",options:e,fn(t){var n,r,i,o,s;const{placement:a,rects:l,middlewareData:c}=t,d=((n=c.arrow)===null||n===void 0?void 0:n.centerOffset)!==0,h=d?0:e.arrowWidth,m=d?0:e.arrowHeight,[g,p]=_8(a),v={start:"0%",center:"50%",end:"100%"}[p],y=((r=(i=c.arrow)===null||i===void 0?void 0:i.x)!==null&&r!==void 0?r:0)+h/2,E=((o=(s=c.arrow)===null||s===void 0?void 0:s.y)!==null&&o!==void 0?o:0)+m/2;let w="",x="";return g==="bottom"?(w=d?v:`${y}px`,x=`${-m}px`):g==="top"?(w=d?v:`${y}px`,x=`${l.floating.height+m}px`):g==="right"?(w=`${-m}px`,x=d?v:`${E}px`):g==="left"&&(w=`${l.floating.width+m}px`,x=d?v:`${E}px`),{data:{x:w,y:x}}}});function _8(e){const[t,n="center"]=e.split("-");return[t,n]}const NV=bV,FV=xV,$V=TV,BV=LV,zV=_.forwardRef((e,t)=>{var n;const{container:r=globalThis==null||(n=globalThis.document)===null||n===void 0?void 0:n.body,...i}=e;return r?lP.createPortal(_.createElement(Un.div,Ye({},i,{ref:t})),r):null});function HV(e,t){return _.useReducer((n,r)=>{const i=t[n][r];return i??n},e)}const pg=e=>{const{present:t,children:n}=e,r=UV(t),i=typeof n=="function"?n({present:r.isPresent}):_.Children.only(n),o=Ci(r.ref,i.ref);return typeof n=="function"||r.isPresent?_.cloneElement(i,{ref:o}):null};pg.displayName="Presence";function UV(e){const[t,n]=_.useState(),r=_.useRef({}),i=_.useRef(e),o=_.useRef("none"),s=e?"mounted":"unmounted",[a,l]=HV(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return _.useEffect(()=>{const c=Xh(r.current);o.current=a==="mounted"?c:"none"},[a]),zo(()=>{const c=r.current,u=i.current;if(u!==e){const h=o.current,m=Xh(c);e?l("MOUNT"):m==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&h!==m?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),zo(()=>{if(t){const c=d=>{const m=Xh(r.current).includes(d.animationName);d.target===t&&m&&nr.flushSync(()=>l("ANIMATION_END"))},u=d=>{d.target===t&&(o.current=Xh(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",c),t.addEventListener("animationend",c),()=>{t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",c),t.removeEventListener("animationend",c)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:_.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function Xh(e){return(e==null?void 0:e.animationName)||"none"}function KE({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,i]=WV({defaultProp:t,onChange:n}),o=e!==void 0,s=o?e:r,a=no(n),l=_.useCallback(c=>{if(o){const d=typeof c=="function"?c(e):c;d!==e&&a(d)}else i(c)},[o,e,i,a]);return[s,l]}function WV({defaultProp:e,onChange:t}){const n=_.useState(e),[r]=n,i=_.useRef(r),o=no(t);return _.useEffect(()=>{i.current!==r&&(o(r),i.current=r)},[r,i,o]),n}var VV=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ja=new WeakMap,qh=new WeakMap,Qh={},jp=0,x8=function(e){return e&&(e.host||x8(e.parentNode))},GV=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=x8(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})},jV=function(e,t,n,r){var i=GV(t,Array.isArray(e)?e:[e]);Qh[n]||(Qh[n]=new WeakMap);var o=Qh[n],s=[],a=new Set,l=new Set(i),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};i.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(h){if(a.has(h))u(h);else{var m=h.getAttribute(r),g=m!==null&&m!=="false",p=(ja.get(h)||0)+1,v=(o.get(h)||0)+1;ja.set(h,p),o.set(h,v),s.push(h),p===1&&g&&qh.set(h,!0),v===1&&h.setAttribute(n,"true"),g||h.setAttribute(r,"true")}})};return u(t),a.clear(),jp++,function(){s.forEach(function(d){var h=ja.get(d)-1,m=o.get(d)-1;ja.set(d,h),o.set(d,m),h||(qh.has(d)||d.removeAttribute(r),qh.delete(d)),m||d.removeAttribute(n)}),jp--,jp||(ja=new WeakMap,ja=new WeakMap,qh=new WeakMap,Qh={})}},YV=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||VV(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live]"))),jV(r,i,n,"aria-hidden")):function(){return null}},dy=function(e,t){return dy=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},dy(e,t)};function KJ(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");dy(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Mo=function(){return Mo=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Mo.apply(this,arguments)};function KV(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 i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function ZJ(e,t,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(d){s(d)}}function l(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(e,t||[])).next())})}function XJ(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function qJ(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function QJ(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o}function ZV(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var jf="right-scroll-bar-position",Yf="width-before-scroll-bar",XV="with-scroll-bars-hidden",qV="--removed-body-scroll-bar-size";function QV(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function JV(e,t){var n=_.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}function eG(e,t){return JV(t||null,function(n){return e.forEach(function(r){return QV(r,n)})})}var Jm=function(){return Jm=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Jm.apply(this,arguments)};function tG(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 i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function nG(e){return e}function rG(e,t){t===void 0&&(t=nG);var n=[],r=!1,i={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(o){var s=t(o,r);return n.push(s),function(){n=n.filter(function(a){return a!==s})}},assignSyncMedium:function(o){for(r=!0;n.length;){var s=n;n=[],s.forEach(o)}n={push:function(a){return o(a)},filter:function(){return n}}},assignMedium:function(o){r=!0;var s=[];if(n.length){var a=n;n=[],a.forEach(o),s=n}var l=function(){var u=s;s=[],u.forEach(o)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){s.push(u),c()},filter:function(u){return s=s.filter(u),n}}}};return i}function iG(e){e===void 0&&(e={});var t=rG(null);return t.options=Jm({async:!0,ssr:!1},e),t}var S8=function(e){var t=e.sideCar,n=tG(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 _.createElement(r,Jm({},n))};S8.isSideCarExport=!0;function oG(e,t){return e.useMedium(t),S8}var k8=iG(),Yp=function(){},yg=_.forwardRef(function(e,t){var n=_.useRef(null),r=_.useState({onScrollCapture:Yp,onWheelCapture:Yp,onTouchMoveCapture:Yp}),i=r[0],o=r[1],s=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,h=e.sideCar,m=e.noIsolation,g=e.inert,p=e.allowPinchZoom,v=e.as,y=v===void 0?"div":v,E=KV(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),w=h,x=eG([n,t]),C=Mo(Mo({},E),i);return _.createElement(_.Fragment,null,u&&_.createElement(w,{sideCar:k8,removeScrollBar:c,shards:d,noIsolation:m,inert:g,setCallbacks:o,allowPinchZoom:!!p,lockRef:n}),s?_.cloneElement(_.Children.only(a),Mo(Mo({},C),{ref:x})):_.createElement(y,Mo({},C,{className:l,ref:x}),a))});yg.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};yg.classNames={fullWidth:Yf,zeroRight:jf};var $6,sG=function(){if($6)return $6;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function aG(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=sG();return t&&e.setAttribute("nonce",t),e}function lG(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function cG(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var uG=function(){var e=0,t=null;return{add:function(n){e==0&&(t=aG())&&(lG(t,n),cG(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},dG=function(){var e=uG();return function(t,n){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},I8=function(){var e=dG(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},hG={left:0,top:0,right:0,gap:0},Kp=function(e){return parseInt(e||"",10)||0},fG=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[Kp(n),Kp(r),Kp(i)]},mG=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return hG;var t=fG(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])}},gG=I8(),pG=function(e,t,n,r){var i=e.left,o=e.top,s=e.right,a=e.gap;return n===void 0&&(n="margin"),`
.`.concat(XV,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(a,"px ").concat(r,`;
}
body {
overflow: hidden `).concat(r,`;
overscroll-behavior: contain;
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
padding-left: `.concat(i,`px;
padding-top: `).concat(o,`px;
padding-right: `).concat(s,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(a,"px ").concat(r,`;
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
}
.`).concat(jf,` {
right: `).concat(a,"px ").concat(r,`;
}
.`).concat(Yf,` {
margin-right: `).concat(a,"px ").concat(r,`;
}
.`).concat(jf," .").concat(jf,` {
right: 0 `).concat(r,`;
}
.`).concat(Yf," .").concat(Yf,` {
margin-right: 0 `).concat(r,`;
}
body {
`).concat(qV,": ").concat(a,`px;
}
`)},yG=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r,o=_.useMemo(function(){return mG(i)},[i]);return _.createElement(gG,{styles:pG(o,!t,i,n?"":"!important")})},hy=!1;if(typeof window<"u")try{var Jh=Object.defineProperty({},"passive",{get:function(){return hy=!0,!0}});window.addEventListener("test",Jh,Jh),window.removeEventListener("test",Jh,Jh)}catch{hy=!1}var Ya=hy?{passive:!1}:!1,vG=function(e){return e.tagName==="TEXTAREA"},C8=function(e,t){var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!vG(e)&&n[t]==="visible")},EG=function(e){return C8(e,"overflowY")},wG=function(e){return C8(e,"overflowX")},B6=function(e,t){var n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var r=T8(e,n);if(r){var i=M8(e,n),o=i[1],s=i[2];if(o>s)return!0}n=n.parentNode}while(n&&n!==document.body);return!1},bG=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},_G=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},T8=function(e,t){return e==="v"?EG(t):wG(t)},M8=function(e,t){return e==="v"?bG(t):_G(t)},xG=function(e,t){return e==="h"&&t==="rtl"?-1:1},SG=function(e,t,n,r,i){var o=xG(e,window.getComputedStyle(t).direction),s=o*r,a=n.target,l=t.contains(a),c=!1,u=s>0,d=0,h=0;do{var m=M8(e,a),g=m[0],p=m[1],v=m[2],y=p-v-o*g;(g||y)&&T8(e,a)&&(d+=y,h+=g),a=a.parentNode}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&(i&&d===0||!i&&s>d)||!u&&(i&&h===0||!i&&-s>h))&&(c=!0),c},ef=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},z6=function(e){return[e.deltaX,e.deltaY]},H6=function(e){return e&&"current"in e?e.current:e},kG=function(e,t){return e[0]===t[0]&&e[1]===t[1]},IG=function(e){return`
.block-interactivity-`.concat(e,` {pointer-events: none;}
.allow-interactivity-`).concat(e,` {pointer-events: all;}
`)},CG=0,Ka=[];function TG(e){var t=_.useRef([]),n=_.useRef([0,0]),r=_.useRef(),i=_.useState(CG++)[0],o=_.useState(function(){return I8()})[0],s=_.useRef(e);_.useEffect(function(){s.current=e},[e]),_.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var p=ZV([e.lockRef.current],(e.shards||[]).map(H6),!0).filter(Boolean);return p.forEach(function(v){return v.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),p.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=_.useCallback(function(p,v){if("touches"in p&&p.touches.length===2)return!s.current.allowPinchZoom;var y=ef(p),E=n.current,w="deltaX"in p?p.deltaX:E[0]-y[0],x="deltaY"in p?p.deltaY:E[1]-y[1],C,S=p.target,I=Math.abs(w)>Math.abs(x)?"h":"v";if("touches"in p&&I==="h"&&S.type==="range")return!1;var T=B6(I,S);if(!T)return!0;if(T?C=I:(C=I==="v"?"h":"v",T=B6(I,S)),!T)return!1;if(!r.current&&"changedTouches"in p&&(w||x)&&(r.current=C),!C)return!0;var L=r.current||C;return SG(L,v,p,L==="h"?w:x,!0)},[]),l=_.useCallback(function(p){var v=p;if(!(!Ka.length||Ka[Ka.length-1]!==o)){var y="deltaY"in v?z6(v):ef(v),E=t.current.filter(function(C){return C.name===v.type&&C.target===v.target&&kG(C.delta,y)})[0];if(E&&E.should){v.cancelable&&v.preventDefault();return}if(!E){var w=(s.current.shards||[]).map(H6).filter(Boolean).filter(function(C){return C.contains(v.target)}),x=w.length>0?a(v,w[0]):!s.current.noIsolation;x&&v.cancelable&&v.preventDefault()}}},[]),c=_.useCallback(function(p,v,y,E){var w={name:p,delta:v,target:y,should:E};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(x){return x!==w})},1)},[]),u=_.useCallback(function(p){n.current=ef(p),r.current=void 0},[]),d=_.useCallback(function(p){c(p.type,z6(p),p.target,a(p,e.lockRef.current))},[]),h=_.useCallback(function(p){c(p.type,ef(p),p.target,a(p,e.lockRef.current))},[]);_.useEffect(function(){return Ka.push(o),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Ya),document.addEventListener("touchmove",l,Ya),document.addEventListener("touchstart",u,Ya),function(){Ka=Ka.filter(function(p){return p!==o}),document.removeEventListener("wheel",l,Ya),document.removeEventListener("touchmove",l,Ya),document.removeEventListener("touchstart",u,Ya)}},[]);var m=e.removeScrollBar,g=e.inert;return _.createElement(_.Fragment,null,g?_.createElement(o,{styles:IG(i)}):null,m?_.createElement(yG,{gapMode:"margin"}):null)}const MG=oG(k8,TG);var A8=_.forwardRef(function(e,t){return _.createElement(yg,Mo({},e,{ref:t,sideCar:MG}))});A8.classNames=yg.classNames;const AG=A8,L8="Popover",[P8,JJ]=ah(L8,[w8]),vg=w8(),[LG,wc]=P8(L8),PG=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!1}=e,a=vg(t),l=_.useRef(null),[c,u]=_.useState(!1),[d=!1,h]=KE({prop:r,defaultProp:i,onChange:o});return _.createElement(NV,a,_.createElement(LG,{scope:t,contentId:VE(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:_.useCallback(()=>h(m=>!m),[h]),hasCustomAnchor:c,onCustomAnchorAdd:_.useCallback(()=>u(!0),[]),onCustomAnchorRemove:_.useCallback(()=>u(!1),[]),modal:s},n))},RG="PopoverTrigger",DG=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=wc(RG,n),o=vg(n),s=Ci(t,i.triggerRef),a=_.createElement(Un.button,Ye({type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":O8(i.open)},r,{ref:s,onClick:hn(e.onClick,i.onOpenToggle)}));return i.hasCustomAnchor?a:_.createElement(FV,Ye({asChild:!0},o),a)}),R8="PopoverPortal",[OG,NG]=P8(R8,{forceMount:void 0}),FG=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,o=wc(R8,t);return _.createElement(OG,{scope:t,forceMount:n},_.createElement(pg,{present:n||o.open},_.createElement(zV,{asChild:!0,container:i},r)))},Dd="PopoverContent",$G=_.forwardRef((e,t)=>{const n=NG(Dd,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,o=wc(Dd,e.__scopePopover);return _.createElement(pg,{present:r||o.open},o.modal?_.createElement(BG,Ye({},i,{ref:t})):_.createElement(zG,Ye({},i,{ref:t})))}),BG=_.forwardRef((e,t)=>{const n=wc(Dd,e.__scopePopover),r=_.useRef(null),i=Ci(t,r),o=_.useRef(!1);return _.useEffect(()=>{const s=r.current;if(s)return YV(s)},[]),_.createElement(AG,{as:Pd,allowPinchZoom:!0},_.createElement(D8,Ye({},e,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:hn(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),o.current||(a=n.triggerRef.current)===null||a===void 0||a.focus()}),onPointerDownOutside:hn(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;o.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:hn(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})))}),zG=_.forwardRef((e,t)=>{const n=wc(Dd,e.__scopePopover),r=_.useRef(!1);return _.createElement(D8,Ye({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o;if((o=e.onCloseAutoFocus)===null||o===void 0||o.call(e,i),!i.defaultPrevented){var s;r.current||(s=n.triggerRef.current)===null||s===void 0||s.focus(),i.preventDefault()}r.current=!1},onInteractOutside:i=>{var o,s;(o=e.onInteractOutside)===null||o===void 0||o.call(e,i),i.defaultPrevented||(r.current=!0);const a=i.target;((s=n.triggerRef.current)===null||s===void 0?void 0:s.contains(a))&&i.preventDefault()}}))}),D8=_.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,h=wc(Dd,n),m=vg(n);return HW(),_.createElement(UW,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o},_.createElement($W,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1)},_.createElement($V,Ye({"data-state":O8(h.open),role:"dialog",id:h.contentId},m,d,{ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)"}}))))}),HG=_.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=vg(n);return _.createElement(BV,Ye({},i,r,{ref:t}))});function O8(e){return e?"open":"closed"}const Eg=PG,wg=DG,UG=FG,bg=$G,WG=HG,N8=te.createContext(null),mn=()=>te.useContext(N8),F8=e=>{const[t,n]=_.useState(null),r=gn(),{theme:i}=mn(),{container:o}=uo();return _.useLayoutEffect(()=>{var s;t&&(t.className="",t.classList.add("excalidraw",...((s=e==null?void 0:e.className)==null?void 0:s.split(/\s+/))||[]),t.classList.toggle("excalidraw--mobile",r.editor.isMobile),t.classList.toggle("theme--dark",i==="dark"))},[t,i,r.editor.isMobile,e==null?void 0:e.className]),_.useLayoutEffect(()=>{const s=e!=null&&e.parentSelector?o==null?void 0:o.querySelector(e.parentSelector):document.body;if(!s)return;const a=document.createElement("div");return s.appendChild(a),n(a),()=>{s.removeChild(a)}},[o,e==null?void 0:e.parentSelector]),t};function ZE(e,t,n){_.useEffect(()=>{function r(i){const o=i;if(!e.current)return;const s=n==null?void 0:n(o,e.current);if(s===!0)return;if(s===!1)return t(o);e.current.contains(o.target)||!document.documentElement.contains(o.target)||o.target.closest("[data-radix-portal]")||o.target===document.documentElement&&document.body.style.pointerEvents==="none"||o.target.closest("[data-prevent-outside-click]")||t(o)}return document.addEventListener(Z.POINTER_DOWN,r),document.addEventListener(Z.TOUCH_START,r),()=>{document.removeEventListener(Z.POINTER_DOWN,r),document.removeEventListener(Z.TOUCH_START,r)}},[e,t,n])}const $8=e=>{const t=_.useRef(e);return Object.assign(t.current,e),t.current},_g=mt(null),VG=({onCancel:e,onChange:t,onSelect:n,colorPickerType:r})=>{const i=F8({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),o=mn(),s=Ag(),a=xc(),l=qe(s,o),c=$8({app:a,onCancel:e,onChange:t,onSelect:n,selectedElements:l}),{container:u}=uo();_.useEffect(()=>{const h=d.current;if(!h||!a.canvas||!i)return;let m=!1;const g=a.canvas.getContext("2d"),p=({clientX:S,clientY:I})=>{const T=g.getImageData((S-o.offsetLeft)*window.devicePixelRatio,(I-o.offsetTop)*window.devicePixelRatio,1,1).data;return ZP(T[0],T[1],T[2])},v=({clientX:S,clientY:I,altKey:T})=>{h.style.top=`${I+20}px`,h.style.left=`${S+20}px`;const L=p({clientX:S,clientY:I});m&&c.onChange(r,L,c.selectedElements,{altKey:T}),h.style.background=L},y=()=>{c.onCancel()},E=(S,I)=>{c.onSelect(S,I)},w=S=>{m=!0,S.stopImmediatePropagation()},x=S=>{m=!1,u==null||u.focus(),S.stopImmediatePropagation(),S.preventDefault(),E(p(S),S)},C=S=>{S.key===D.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),y())};return i.tabIndex=-1,i.focus(),v({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),i.addEventListener(Z.KEYDOWN,C),i.addEventListener(Z.POINTER_DOWN,w),i.addEventListener(Z.POINTER_UP,x),window.addEventListener("pointermove",v,{passive:!0}),window.addEventListener(Z.BLUR,y),()=>{m=!1,i.removeEventListener(Z.KEYDOWN,C),i.removeEventListener(Z.POINTER_DOWN,w),i.removeEventListener(Z.POINTER_UP,x),window.removeEventListener("pointermove",v),window.removeEventListener(Z.BLUR,y)}},[c,a.canvas,i,r,u,o.offsetLeft,o.offsetTop]);const d=_.useRef(null);return ZE(d,()=>{e()},h=>!!h.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),i?nr.createPortal(f("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),i):null},GG=({color:e,onChange:t,label:n,colorPickerType:r})=>{const i=gn(),[o,s]=_.useState(e),[a,l]=ze(vc);_.useEffect(()=>{s(e)},[e]);const c=_.useCallback(g=>{const p=g.toLowerCase(),v=jG(p);v&&t(v),s(p)},[t]),u=_.useRef(null),d=_.useRef(null);_.useEffect(()=>{u.current&&u.current.focus()},[a]);const[h,m]=ze(_g,en);return _.useEffect(()=>()=>{m(null)},[m]),k("div",{className:"color-picker__input-label",children:[f("div",{className:"color-picker__input-hash",children:"#"}),f("input",{ref:a==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":n,onChange:g=>{c(g.target.value)},value:(o||"").replace(/^#/,""),onBlur:()=>{s(e)},tabIndex:-1,onFocus:()=>l("hex"),onKeyDown:g=>{var p;g.key!==D.TAB&&(g.key===D.ESCAPE&&((p=d.current)==null||p.focus()),g.stopPropagation())}}),!i.editor.isMobile&&k(re,{children:[f("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),f("div",{ref:d,className:se("excalidraw-eye-dropper-trigger",{selected:h}),onClick:()=>m(g=>g?null:{keepOpenOnAlt:!1,onSelect:p=>t(p),colorPickerType:r}),title:`${b("labels.eyeDropper")} — ${D.I.toLocaleUpperCase()} or ${K("Alt")} `,children:VU})]})]})},U6=e=>{const t=new Option().style;return t.color=e,!!t.color},jG=e=>Ei(e)?e:U6(`#${e}`)?`#${e}`:U6(e)?e:null,YG=({type:e,color:t,onChange:n,label:r,elements:i,palette:o=ve,updateData:s})=>{const[,a]=ze(vc),[l,c]=ze(_g,en),{container:u}=uo(),d=gn(),h=k("div",{children:[f(Gf,{children:b("colorPicker.hexCode")}),f(GG,{color:t,label:r,onChange:p=>{n(p)},colorPickerType:e})]}),m=_.useRef(null),g=()=>{var p,v;(v=(p=m.current)==null?void 0:p.querySelector(".color-picker-content"))==null||v.focus()};return f(UG,{container:u,children:k(bg,{ref:m,className:"focus-visible-none","data-prevent-outside-click":!0,onFocusOutside:p=>{g(),p.preventDefault()},onPointerDownOutside:p=>{l&&p.preventDefault()},onCloseAutoFocus:p=>{p.stopPropagation(),p.preventDefault(),u&&!_D(document.activeElement)&&u.focus(),s({openPopup:null}),a(null)},side:d.editor.isMobile&&!d.viewport.isLandscape?"bottom":"right",align:d.editor.isMobile&&!d.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-layerUI)",backgroundColor:"var(--popup-bg-color)",maxWidth:"208px",maxHeight:window.innerHeight,padding:"12px",borderRadius:"8px",boxSizing:"border-box",overflowY:"auto",boxShadow:"0px 7px 14px rgba(0, 0, 0, 0.05), 0px 0px 3.12708px rgba(0, 0, 0, 0.0798), 0px 0px 0.931014px rgba(0, 0, 0, 0.1702)"},children:[o?f(IW,{palette:o,color:t,onChange:p=>{n(p)},onEyeDropperToggle:p=>{c(v=>p?(v=v||{keepOpenOnAlt:!0,onSelect:n,colorPickerType:e},v.keepOpenOnAlt=!0,v):p===!1||v?null:{keepOpenOnAlt:!1,onSelect:n,colorPickerType:e})},onEscape:p=>{l?c(null):Ns(p.target)?g():s({openPopup:null})},label:r,type:e,elements:i,updateData:s,children:h}):h,f(WG,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})},KG=({label:e,color:t,type:n})=>f(wg,{type:"button",className:se("color-picker__button active-color",{"is-transparent":t==="transparent"||!t}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:b(n==="elementStroke"?"labels.showStroke":"labels.showBackground"),children:f("div",{className:"color-picker__button-outline"})}),XE=({type:e,color:t,onChange:n,label:r,elements:i,palette:o=ve,topPicks:s,updateData:a,appState:l})=>f("div",{children:k("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[f(vW,{activeColor:t,onChange:n,type:e,topPicks:s}),f("div",{style:{width:1,height:"100%",backgroundColor:"var(--default-border-color)",margin:"0 auto"}}),k(Eg,{open:l.openPopup===e,onOpenChange:c=>{a({openPopup:c?e:null})},children:[f(KG,{color:t,label:r,type:e}),l.openPopup===e&&f(YG,{type:e,color:t,onChange:n,label:r,elements:i,palette:o,updateData:a})]})]})}),B8=({children:e,left:t,top:n,onCloseRequest:r,fitInViewport:i=!1,offsetLeft:o=0,offsetTop:s=0,viewportWidth:a=window.innerWidth,viewportHeight:l=window.innerHeight})=>{const c=_.useRef(null);_.useEffect(()=>{const d=c.current;if(!d)return;d.contains(document.activeElement)||d.focus();const h=m=>{var g,p,v;if(m.key===D.TAB){const y=S2(d),{activeElement:E}=document,w=y.findIndex(x=>x===E);E===d?(m.shiftKey?(g=y[y.length-1])==null||g.focus():y[0].focus(),m.preventDefault(),m.stopImmediatePropagation()):w===0&&m.shiftKey?((p=y[y.length-1])==null||p.focus(),m.preventDefault(),m.stopImmediatePropagation()):w===y.length-1&&!m.shiftKey&&((v=y[0])==null||v.focus(),m.preventDefault(),m.stopImmediatePropagation())}};return d.addEventListener("keydown",h),()=>d.removeEventListener("keydown",h)},[]);const u=_.useRef(null);return _.useLayoutEffect(()=>{var d,h;if(i&&c.current&&n!=null&&t!=null){const m=c.current,{width:g,height:p}=m.getBoundingClientRect();if(((d=u.current)==null?void 0:d.top)===n&&((h=u.current)==null?void 0:h.left)===t)return;u.current={top:n,left:t},g>=a?(m.style.width=`${a}px`,m.style.left="0px",m.style.overflowX="scroll"):t+g-o>a?m.style.left=`${a-g-10}px`:m.style.left=`${t}px`,p>=l?(m.style.height=`${l-20}px`,m.style.top="10px",m.style.overflowY="scroll"):n+p-s>l?m.style.top=`${l-p}px`:m.style.top=`${n}px`}},[n,t,i,a,l,o,s]),_.useEffect(()=>{if(r){const d=h=>{var m;(m=c.current)!=null&&m.contains(h.target)||nr.unstable_batchedUpdates(()=>r(h))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),f("div",{className:"popover",ref:c,tabIndex:-1,children:e})};function ZG({options:e,value:t,label:n,onChange:r,onClose:i}){const o=te.useRef(),s=te.useRef(),a=te.useRef(null);return te.useEffect(()=>{s.current?s.current.focus():a.current&&a.current.focus()},[]),f("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":n,onKeyDown:c=>{const u=e.find(d=>d.keyBinding===c.key.toLowerCase());if(!(c.metaKey||c.altKey||c.ctrlKey)&&u){const d=e.indexOf(u);a.current.children[d].focus(),c.preventDefault()}else if(c.key===D.TAB)setTimeout(()=>{const d=s.current,h=document.activeElement;d!==h&&i()},0);else if(Pf(c.key)){const{activeElement:d}=document,h=Yd().rtl,m=Array.prototype.indexOf.call(a.current.children,d);if(m!==-1){const g=e.length;let p=m;switch(c.key){case(h?D.ARROW_LEFT:D.ARROW_RIGHT):case D.ARROW_DOWN:{p=(m+1)%g;break}case(h?D.ARROW_RIGHT:D.ARROW_LEFT):case D.ARROW_UP:{p=(g+m-1)%g;break}}a.current.children[p].focus()}c.preventDefault()}else(c.key===D.ESCAPE||c.key===D.ENTER)&&(c.preventDefault(),i());c.nativeEvent.stopImmediatePropagation(),c.stopPropagation()},children:f("div",{className:"picker-content",ref:a,children:e.map((c,u)=>k("button",{className:se("picker-option",{active:t===c.value}),onClick:d=>{d.currentTarget.focus(),r(c.value)},title:`${c.text} ${c.keyBinding&&`— ${c.keyBinding.toUpperCase()}`}`,"aria-label":c.text||"none","aria-keyshortcuts":c.keyBinding||void 0,ref:d=>{d&&u===0&&(o.current=d),d&&c.value===t&&(s.current=d)},onFocus:()=>{r(c.value)},children:[c.icon,c.keyBinding&&f("span",{className:"picker-keybinding",children:c.keyBinding})]},c.text))})})}function W6({value:e,label:t,options:n,onChange:r,group:i=""}){var c;const[o,s]=te.useState(!1),a=te.useRef(null),l=Yd().rtl;return k("div",{children:[f("button",{name:i,className:o?"active":"","aria-label":t,onClick:()=>s(!o),ref:a,children:(c=n.find(u=>u.value===e))==null?void 0:c.icon}),f(te.Suspense,{fallback:"",children:o?k(re,{children:[f(B8,{onCloseRequest:u=>u.target!==a.current&&s(!1),...l?{right:5.5}:{left:-5.5},children:f(ZG,{options:n.filter(u=>u.showInPicker!==!1),value:e,label:t,onChange:r,onClose:()=>{var u;s(!1),(u=a.current)==null||u.focus()}})}),f("div",{className:"picker-triangle"})]}):null})]})}const z8=.1,ar=(e,t,n,r=!1)=>{const i=be(qe(e,t,{includeBoundTextElement:r}));return e.map(o=>{var s;return i.get(o.id)||o.id===((s=t.editingElement)==null?void 0:s.id)?n(o):o})},Wn=function(e,t,n,r,i){const o=t.editingElement,s=je(e);let a=null;return o&&(a=n(o)),a||(Lt(s,t)?a=tH(r===!0?s:s.filter(c=>r(c)),t,n)??(typeof i=="function"?i(!0):i):a=typeof i=="function"?i(!1):i),a},XG=(e,t)=>Mt(t)?t:J(t,{x:e.textAlign==="left"?e.x:e.x+(e.width-t.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-t.height)/2},!1),qE=(e,t,n,r,i)=>{const o=new Set;return{elements:ar(e,t,s=>{if(ce(s)){const a=r(s);o.add(a);let l=ge(s,{fontSize:a});return Mi(l,n.scene.getContainerElement(s),n.scene.getNonDeletedElementsMap()),l=XG(s,l),l}return s},!0),appState:{...t,currentItemFontSize:o.size===1?[...o][0]:i??t.currentItemFontSize},commitToHistory:!0}};ne({name:"changeStrokeColor",trackEvent:!1,perform:(e,t,n)=>({...n.currentItemStrokeColor&&{elements:ar(e,t,r=>M2(r.type)?ge(r,{strokeColor:n.currentItemStrokeColor}):r,!0)},appState:{...t,...n},commitToHistory:!!n.currentItemStrokeColor}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:r})=>k(re,{children:[f("h3",{"aria-hidden":"true",children:b("labels.stroke")}),f(XE,{topPicks:OS,palette:jP,type:"elementStroke",label:b("labels.stroke"),color:Wn(e,t,i=>i.strokeColor,!0,t.currentItemStrokeColor),onChange:i=>n({currentItemStrokeColor:i}),elements:e,appState:t,updateData:n})]})});ne({name:"changeBackgroundColor",trackEvent:!1,perform:(e,t,n)=>({...n.currentItemBackgroundColor&&{elements:ar(e,t,r=>ge(r,{backgroundColor:n.currentItemBackgroundColor}))},appState:{...t,...n},commitToHistory:!!n.currentItemBackgroundColor}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:r})=>k(re,{children:[f("h3",{"aria-hidden":"true",children:b("labels.background")}),f(XE,{topPicks:NS,palette:YP,type:"elementBackground",label:b("labels.background"),color:Wn(e,t,i=>i.backgroundColor,!0,t.currentItemBackgroundColor),onChange:i=>n({currentItemBackgroundColor:i}),elements:e,appState:t,updateData:n})]})});ne({name:"changeFillStyle",trackEvent:!1,perform:(e,t,n,r)=>(Ae("element","changeFillStyle",`${n} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:ar(e,t,i=>ge(i,{fillStyle:n})),appState:{...t,currentItemFillStyle:n},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n})=>{const r=qe(e,t),i=r.length>0&&r.every(o=>o.fillStyle==="zigzag");return k("fieldset",{children:[f("legend",{children:b("labels.fill")}),f(lo,{type:"button",options:[{value:"hachure",text:`${b(i?"labels.zigzag":"labels.hachure")} (${K("Alt-Click")})`,icon:i?oU:sU,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:b("labels.crossHatch"),icon:aU,testId:"fill-cross-hatch"},{value:"solid",text:b("labels.solid"),icon:lU,testId:"fill-solid"}],value:Wn(e,t,o=>o.fillStyle,o=>o.hasOwnProperty("fillStyle"),o=>o?null:t.currentItemFillStyle),onClick:(o,s)=>{const a=s.altKey&&o==="hachure"&&r.every(l=>l.fillStyle==="hachure")?"zigzag":o;n(a)}})]})}});ne({name:"changeStrokeWidth",trackEvent:!1,perform:(e,t,n)=>({elements:ar(e,t,r=>ge(r,{strokeWidth:n})),appState:{...t,currentItemStrokeWidth:n},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n})=>k("fieldset",{children:[f("legend",{children:b("labels.strokeWidth")}),f(lo,{group:"stroke-width",options:[{value:up.thin,text:b("labels.thin"),icon:XT,testId:"strokeWidth-thin"},{value:up.bold,text:b("labels.bold"),icon:cU,testId:"strokeWidth-bold"},{value:up.extraBold,text:b("labels.extraBold"),icon:uU,testId:"strokeWidth-extraBold"}],value:Wn(e,t,r=>r.strokeWidth,r=>r.hasOwnProperty("strokeWidth"),r=>r?null:t.currentItemStrokeWidth),onChange:r=>n(r)})]})});ne({name:"changeSloppiness",trackEvent:!1,perform:(e,t,n)=>({elements:ar(e,t,r=>ge(r,{seed:bs(),roughness:n})),appState:{...t,currentItemRoughness:n},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n})=>k("fieldset",{children:[f("legend",{children:b("labels.sloppiness")}),f(lo,{group:"sloppiness",options:[{value:0,text:b("labels.architect"),icon:fU},{value:1,text:b("labels.artist"),icon:mU},{value:2,text:b("labels.cartoonist"),icon:gU}],value:Wn(e,t,r=>r.roughness,r=>r.hasOwnProperty("roughness"),r=>r?null:t.currentItemRoughness),onChange:r=>n(r)})]})});ne({name:"changeStrokeStyle",trackEvent:!1,perform:(e,t,n)=>({elements:ar(e,t,r=>ge(r,{strokeStyle:n})),appState:{...t,currentItemStrokeStyle:n},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n})=>k("fieldset",{children:[f("legend",{children:b("labels.strokeStyle")}),f(lo,{group:"strokeStyle",options:[{value:"solid",text:b("labels.strokeStyle_solid"),icon:XT},{value:"dashed",text:b("labels.strokeStyle_dashed"),icon:dU},{value:"dotted",text:b("labels.strokeStyle_dotted"),icon:hU}],value:Wn(e,t,r=>r.strokeStyle,r=>r.hasOwnProperty("strokeStyle"),r=>r?null:t.currentItemStrokeStyle),onChange:r=>n(r)})]})});ne({name:"changeOpacity",trackEvent:!1,perform:(e,t,n)=>({elements:ar(e,t,r=>ge(r,{opacity:n}),!0),appState:{...t,currentItemOpacity:n},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n})=>k("label",{className:"control-label",children:[b("labels.opacity"),f("input",{type:"range",min:"0",max:"100",step:"10",onChange:r=>n(+r.target.value),value:Wn(e,t,r=>r.opacity,!0,t.currentItemOpacity)??void 0})]})});ne({name:"changeFontSize",trackEvent:!1,perform:(e,t,n,r)=>qE(e,t,r,()=>n,n),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>k("fieldset",{children:[f("legend",{children:b("labels.fontSize")}),f(lo,{group:"font-size",options:[{value:16,text:b("labels.small"),icon:IU,testId:"fontSize-small"},{value:20,text:b("labels.medium"),icon:CU,testId:"fontSize-medium"},{value:28,text:b("labels.large"),icon:TU,testId:"fontSize-large"},{value:36,text:b("labels.veryLarge"),icon:MU,testId:"fontSize-veryLarge"}],value:Wn(e,t,i=>{if(ce(i))return i.fontSize;const o=ke(i,r.scene.getNonDeletedElementsMap());return o?o.fontSize:null},i=>ce(i)||ke(i,r.scene.getNonDeletedElementsMap())!==null,i=>i?null:t.currentItemFontSize||Xr),onChange:i=>n(i)})]})});const V6=ne({name:"decreaseFontSize",trackEvent:!1,perform:(e,t,n,r)=>qE(e,t,r,i=>Math.round(1/(1+z8)*i.fontSize)),keyTest:e=>e[D.CTRL_OR_CMD]&&e.shiftKey&&(e.key===D.CHEVRON_LEFT||e.key===D.COMMA)}),G6=ne({name:"increaseFontSize",trackEvent:!1,perform:(e,t,n,r)=>qE(e,t,r,i=>Math.round(i.fontSize*(1+z8))),keyTest:e=>e[D.CTRL_OR_CMD]&&e.shiftKey&&(e.key===D.CHEVRON_RIGHT||e.key===D.PERIOD)});ne({name:"changeFontFamily",trackEvent:!1,perform:(e,t,n,r)=>({elements:ar(e,t,i=>{if(ce(i)){const o=ge(i,{fontFamily:n,lineHeight:wa(n)});return Mi(o,r.scene.getContainerElement(i),r.scene.getNonDeletedElementsMap()),o}return i},!0),appState:{...t,currentItemFontFamily:n},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{const i=[{value:Xt.Virgil,text:b("labels.handDrawn"),icon:$E,testId:"font-family-virgil"},{value:Xt.Helvetica,text:b("labels.normal"),icon:AU,testId:"font-family-normal"},{value:Xt.Cascadia,text:b("labels.code"),icon:LU,testId:"font-family-code"}];return k("fieldset",{children:[f("legend",{children:b("labels.fontFamily")}),f(lo,{group:"font-family",options:i,value:Wn(e,t,o=>{if(ce(o))return o.fontFamily;const s=ke(o,r.scene.getNonDeletedElementsMap());return s?s.fontFamily:null},o=>ce(o)||ke(o,r.scene.getNonDeletedElementsMap())!==null,o=>o?null:t.currentItemFontFamily||oo),onChange:o=>n(o)})]})}});ne({name:"changeTextAlign",trackEvent:!1,perform:(e,t,n,r)=>({elements:ar(e,t,i=>{if(ce(i)){const o=ge(i,{textAlign:n});return Mi(o,r.scene.getContainerElement(i),r.scene.getNonDeletedElementsMap()),o}return i},!0),appState:{...t,currentItemTextAlign:n},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{const i=r.scene.getNonDeletedElementsMap();return k("fieldset",{children:[f("legend",{children:b("labels.textAlign")}),f(lo,{group:"text-align",options:[{value:"left",text:b("labels.left"),icon:PU,testId:"align-left"},{value:"center",text:b("labels.center"),icon:RU,testId:"align-horizontal-center"},{value:"right",text:b("labels.right"),icon:DU,testId:"align-right"}],value:Wn(e,t,o=>{if(ce(o))return o.textAlign;const s=ke(o,i);return s?s.textAlign:null},o=>ce(o)||ke(o,i)!==null,o=>o?null:t.currentItemTextAlign),onChange:o=>n(o)})]})}});ne({name:"changeVerticalAlign",trackEvent:{category:"element"},perform:(e,t,n,r)=>({elements:ar(e,t,i=>{if(ce(i)){const o=ge(i,{verticalAlign:n});return Mi(o,r.scene.getContainerElement(i),r.scene.getNonDeletedElementsMap()),o}return i},!0),appState:{...t},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>f("fieldset",{children:f(lo,{group:"text-align",options:[{value:Qn.TOP,text:b("labels.alignTop"),icon:f(OU,{theme:t.theme}),testId:"align-top"},{value:Qn.MIDDLE,text:b("labels.centerVertically"),icon:f(FU,{theme:t.theme}),testId:"align-middle"},{value:Qn.BOTTOM,text:b("labels.alignBottom"),icon:f(NU,{theme:t.theme}),testId:"align-bottom"}],value:Wn(e,t,i=>{if(ce(i)&&i.containerId)return i.verticalAlign;const o=ke(i,r.scene.getNonDeletedElementsMap());return o?o.verticalAlign:null},i=>ce(i)||ke(i,r.scene.getNonDeletedElementsMap())!==null,i=>i?null:Qn.MIDDLE),onChange:i=>n(i)})})});ne({name:"changeRoundness",trackEvent:!1,perform:(e,t,n)=>({elements:ar(e,t,r=>ge(r,{roundness:n==="round"?{type:uc(r.type)?Vt.ADAPTIVE_RADIUS:Vt.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:n},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n})=>{const i=FE(je(e),t).some(o=>{var s;return((s=o.roundness)==null?void 0:s.type)===Vt.LEGACY});return k("fieldset",{children:[f("legend",{children:b("labels.edges")}),f(lo,{group:"edges",options:[{value:"sharp",text:b("labels.sharp"),icon:pU},{value:"round",text:b("labels.round"),icon:yU}],value:Wn(e,t,o=>i?null:o.roundness?"round":"sharp",o=>o.hasOwnProperty("roundness"),o=>o?null:t.currentItemRoundness),onChange:o=>n(o)})]})}});const j6=e=>[{value:null,text:b("labels.arrowhead_none"),keyBinding:"q",icon:vU},{value:"arrow",text:b("labels.arrowhead_arrow"),keyBinding:"w",icon:f(EU,{flip:e})},{value:"bar",text:b("labels.arrowhead_bar"),keyBinding:"e",icon:f(bU,{flip:e})},{value:"dot",text:b("labels.arrowhead_circle"),keyBinding:null,icon:f(p6,{flip:e}),showInPicker:!1},{value:"circle",text:b("labels.arrowhead_circle"),keyBinding:"r",icon:f(p6,{flip:e}),showInPicker:!1},{value:"circle_outline",text:b("labels.arrowhead_circle_outline"),keyBinding:null,icon:f(wU,{flip:e}),showInPicker:!1},{value:"triangle",text:b("labels.arrowhead_triangle"),icon:f(_U,{flip:e}),keyBinding:"t"},{value:"triangle_outline",text:b("labels.arrowhead_triangle_outline"),icon:f(xU,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond",text:b("labels.arrowhead_diamond"),icon:f(SU,{flip:e}),keyBinding:null,showInPicker:!1},{value:"diamond_outline",text:b("labels.arrowhead_diamond_outline"),icon:f(kU,{flip:e}),keyBinding:null,showInPicker:!1}];ne({name:"changeArrowhead",trackEvent:!1,perform:(e,t,n)=>({elements:ar(e,t,r=>{if(we(r)){const{position:i,type:o}=n;if(i==="start")return ge(r,{startArrowhead:o});if(i==="end")return ge(r,{endArrowhead:o})}return r}),appState:{...t,[n.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:n.type},commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n})=>{const r=Yd().rtl;return k("fieldset",{children:[f("legend",{children:b("labels.arrowheads")}),k("div",{className:"iconSelectList buttonList",children:[f(W6,{label:"arrowhead_start",options:j6(!r),value:Wn(e,t,i=>we(i)&&Lm(i.type)?i.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:i=>n({position:"start",type:i})}),f(W6,{label:"arrowhead_end",group:"arrowheads",options:j6(!!r),value:Wn(e,t,i=>we(i)&&Lm(i.type)?i.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:i=>n({position:"end",type:i})})]})]})}});const $u=()=>{const e=document.querySelector(".excalidraw-tooltip");if(e)return e;const t=document.createElement("div");return document.body.appendChild(t),t.classList.add("excalidraw-tooltip"),t},H8=(e,t,n="bottom")=>{const r=e.getBoundingClientRect(),i=window.innerWidth,o=window.innerHeight,s=5;let a=t.left+t.width/2-r.width/2;a<0?a=s:a+r.width>=i&&(a=i-r.width-s);let l;n==="bottom"?(l=t.top+t.height+s,l+r.height>=o&&(l=t.top-r.height-s)):(l=t.top-r.height-s,l<0&&(l=t.top+t.height+s)),Object.assign(e.style,{top:`${l}px`,left:`${a}px`})},qG=(e,t,n,r)=>{t.classList.add("excalidraw-tooltip--visible"),t.style.minWidth=r?"50ch":"10ch",t.style.maxWidth=r?"50ch":"15ch",t.textContent=n;const i=e.getBoundingClientRect();H8(t,i)},ro=({children:e,label:t,long:n=!1,style:r,disabled:i})=>(_.useEffect(()=>()=>$u().classList.remove("excalidraw-tooltip--visible"),[]),i?null:f("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:o=>qG(o.currentTarget,$u(),t,n),onPointerLeave:()=>$u().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));ne({name:"changeViewBackgroundColor",trackEvent:!1,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,n)=>({appState:{...t,...n},commitToHistory:!!n.viewBackgroundColor}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:r})=>f(XE,{palette:null,topPicks:FS,label:b("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:i=>n({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:n})});const U8=ne({name:"clearCanvas",trackEvent:{category:"canvas"},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled,perform:(e,t,n,r)=>(r.imageCache.clear(),{elements:e.map(i=>ge(i,{isDeleted:!0})),appState:{...qr(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,showStats:t.showStats,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type==="image"?{...t.activeTool,type:"selection"}:t.activeTool},commitToHistory:!0})}),Y6=ne({name:"zoomIn",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,n,r)=>({appState:{...t,...Xs({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Zs(t.zoom.value+dd)},t),userToFollow:null},commitToHistory:!1}),PanelComponent:({updateData:e})=>f(Ce,{type:"button",className:"zoom-in-button zoom-button",icon:_H,title:`${b("buttons.zoomIn")} — ${K("CtrlOrCmd++")}`,"aria-label":b("buttons.zoomIn"),onClick:()=>{e(null)}}),keyTest:e=>(e.code===De.EQUAL||e.code===De.NUM_ADD)&&(e[D.CTRL_OR_CMD]||e.shiftKey)}),K6=ne({name:"zoomOut",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,n,r)=>({appState:{...t,...Xs({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Zs(t.zoom.value-dd)},t),userToFollow:null},commitToHistory:!1}),PanelComponent:({updateData:e})=>f(Ce,{type:"button",className:"zoom-out-button zoom-button",icon:xH,title:`${b("buttons.zoomOut")} — ${K("CtrlOrCmd+-")}`,"aria-label":b("buttons.zoomOut"),onClick:()=>{e(null)}}),keyTest:e=>(e.code===De.MINUS||e.code===De.NUM_SUBTRACT)&&(e[D.CTRL_OR_CMD]||e.shiftKey)});ne({name:"resetZoom",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,n,r)=>({appState:{...t,...Xs({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Zs(1)},t),userToFollow:null},commitToHistory:!1}),PanelComponent:({updateData:e,appState:t})=>f(ro,{label:b("buttons.resetZoom"),style:{height:"100%"},children:k(Ce,{type:"button",className:"reset-zoom-button zoom-button",title:b("buttons.resetZoom"),"aria-label":b("buttons.resetZoom"),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===De.ZERO||e.code===De.NUM_ZERO)&&(e[D.CTRL_OR_CMD]||e.shiftKey)});const QG=(e,t)=>{const[n,r,i,o]=e,s=i-n,a=t.width/s,l=o-r,c=t.height/l,u=Math.min(a,c),d=Math.floor(u/dd)*dd;return Math.min(Math.max(d,US),1)},W8=({bounds:e,appState:t,fitToViewport:n=!1,viewportZoomFactor:r=.7})=>{const[i,o,s,a]=e,l=(i+s)/2,c=(o+a)/2;let u,d,h;if(n){const m=s-i,g=a-o;u=Math.min(t.width/m,t.height/g)*Math.min(1,Math.max(r,.1)),u=Math.min(Math.max(u,.1),30);let p=t.width;if(t.openSidebar){const v=document.querySelector(".sidebar"),y=(v==null?void 0:v.offsetWidth)??0;p=document.documentElement.getAttribute("dir")==="rtl"?t.width+y:t.width-y}d=p/2*(1/u)-l,h=t.height/2*(1/u)-c}else{u=QG(e,{width:t.width,height:t.height});const m=VT({scenePoint:{x:l,y:c},viewportDimensions:{width:t.width,height:t.height},zoom:{value:u}});d=m.scrollX,h=m.scrollY}return{appState:{...t,scrollX:d,scrollY:h,zoom:{value:u}},commitToHistory:!1}},xg=({targetElements:e,appState:t,fitToViewport:n,viewportZoomFactor:r})=>{const i=nt(je(e));return W8({bounds:i,appState:t,fitToViewport:n,viewportZoomFactor:r})};ne({name:"zoomToFitSelectionInViewport",trackEvent:{category:"canvas"},perform:(e,t,n,r)=>{const i=r.scene.getSelectedElements(t);return xg({targetElements:i.length?i:e,appState:{...t,userToFollow:null},fitToViewport:!1})},keyTest:e=>e.code===De.TWO&&e.shiftKey&&!e.altKey&&!e[D.CTRL_OR_CMD]});ne({name:"zoomToFitSelection",trackEvent:{category:"canvas"},perform:(e,t,n,r)=>{const i=r.scene.getSelectedElements(t);return xg({targetElements:i.length?i:e,appState:{...t,userToFollow:null},fitToViewport:!0})},keyTest:e=>e.code===De.THREE&&e.shiftKey&&!e.altKey&&!e[D.CTRL_OR_CMD]});ne({name:"zoomToFit",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>xg({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1}),keyTest:e=>e.code===De.ONE&&e.shiftKey&&!e.altKey&&!e[D.CTRL_OR_CMD]});const Z6=ne({name:"toggleTheme",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,n)=>({appState:{...t,theme:n||(t.theme===Tt.LIGHT?Tt.DARK:Tt.LIGHT)},commitToHistory:!1}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===De.D,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.toggleTheme});ne({name:"toggleEraserTool",trackEvent:{category:"toolbar"},perform:(e,t)=>{let n;return mi(t)?n=bt(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):n=bt(t,{type:"eraser",lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},commitToHistory:!0}},keyTest:e=>e.key===D.E});const JG=ne({name:"toggleHandTool",trackEvent:{category:"toolbar"},perform:(e,t,n,r)=>{let i;return Vl(t)?i=bt(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(i=bt(t,{type:"hand",lastActiveToolBeforeEraser:t.activeTool}),He(r.interactiveCanvas,Be.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:i},commitToHistory:!0}},keyTest:e=>!e.altKey&&!e[D.CTRL_OR_CMD]&&e.key===D.H}),li=ne({name:"finalize",trackEvent:!1,perform:(e,t,n,{interactiveCanvas:r,focusContainer:i,scene:o})=>{var d;const s=o.getNonDeletedElementsMap();if(t.editingLinearElement){const{elementId:h,startBindingElement:m,endBindingElement:g}=t.editingLinearElement,p=ue.getElement(h,s);if(p)return dn(p)&&dc(p,m,g,s),{elements:p.points.length<2||Ma(p)?e.filter(v=>v.id!==p.id):void 0,appState:{...t,cursorButton:"up",editingLinearElement:null},commitToHistory:!0}}let a=e;const l=t.pendingImageElementId&&o.getElement(t.pendingImageElementId);l&&J(l,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&i();const c=t.multiElement?t.multiElement:((d=t.editingElement)==null?void 0:d.type)==="freedraw"?t.editingElement:null;if(c){if(c.type!=="freedraw"&&t.lastPointerDownWith!=="touch"){const{points:m,lastCommittedPoint:g}=c;(!g||m[m.length-1]!==g)&&J(c,{points:c.points.slice(0,-1)})}Ma(c)&&(a=a.filter(m=>m.id!==c.id));const h=cs(c.points,t.zoom.value);if((c.type==="line"||c.type==="freedraw")&&h){const m=c.points,g=m[0];J(c,{points:m.map((p,v)=>v===m.length-1?[g[0],g[1]]:p)})}if(dn(c)&&!h&&c.points.length>1){const[m,g]=ue.getPointAtIndexGlobalCoordinates(c,-1,be(e));R2(c,t,$t.getScene(c),{x:m,y:g},s)}}(!t.activeTool.locked&&t.activeTool.type!=="freedraw"||!c)&&Pr(r);let u;return t.activeTool.type==="eraser"?u=bt(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):u=bt(t,{type:"selection"}),{elements:a,appState:{...t,cursorButton:"up",activeTool:(t.activeTool.locked||t.activeTool.type==="freedraw")&&c?t.activeTool:u,activeEmbeddable:null,draggingElement:null,multiElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:c&&!t.activeTool.locked&&t.activeTool.type!=="freedraw"?{...t.selectedElementIds,[c.id]:!0}:t.selectedElementIds,selectedLinearElement:c&&we(c)?new ue(c):t.selectedLinearElement,pendingImageElementId:null},commitToHistory:t.activeTool.type==="freedraw"}},keyTest:(e,t)=>e.key===D.ESCAPE&&(t.editingLinearElement!==null||!t.draggingElement&&t.multiElement===null)||(e.key===D.ESCAPE||e.key===D.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:n})=>f(Ce,{type:"button",icon:NH,title:b("buttons.done"),"aria-label":b("buttons.done"),onClick:t,visible:e.multiElement!=null,size:(n==null?void 0:n.size)||"medium"})}),ej=e=>{const{id:t}=uo(),[n,r]=_.useState(e.value),i=s=>{e.ignoreFocus||MD(s.target);const a=s.target.value;a!==e.value&&e.onChange(a)},o=s=>{if(s.key===D.ENTER){if(s.preventDefault(),s.nativeEvent.isComposing||s.keyCode===229)return;s.currentTarget.blur()}};return k("div",{className:"ProjectName",children:[f("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),f("input",{type:"text",className:"TextInput",onBlur:i,onKeyDown:o,id:`${t}-filename`,value:n,onChange:s=>r(s.target.value)})]})},tj=e=>{const t=e.title||(e.value==="dark"?b("buttons.lightMode"):b("buttons.darkMode"));return f(Ce,{type:"icon",icon:e.value===Tt.LIGHT?X6.MOON:X6.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===Tt.DARK?Tt.LIGHT:Tt.DARK),"data-testid":"toggle-dark-mode"})},X6={SUN:f("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:f("path",{fill:"currentColor",d:"M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z"})}),MOON:f("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:f("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})},Sg=(e,{selectedElementIds:t},n)=>{e=je(e);const r=n&&Lt(e,{selectedElementIds:t});let i=null,o=r?qe(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return r&&(o.length===1&&pe(o[0])?(i=o[0],o=PE(e,i)):o.length>1&&(o=qe(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:i,exportedElements:Yl(o)}},kg=async(e,t,n,r,{exportBackground:i,exportPadding:o=ac,viewBackgroundColor:s,name:a=n.name||jS,fileHandle:l=null,exportingFrame:c=null})=>{if(t.length===0)throw new Error(b("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){const d=vE(t,{exportBackground:i,exportWithDarkMode:n.exportWithDarkMode,viewBackgroundColor:s,exportPadding:o,exportScale:n.exportScale,exportEmbedScene:n.exportEmbedScene&&e==="svg"},r,{exportingFrame:c});if(e==="svg")return Bm(d.then(h=>new Blob([h.outerHTML],{type:de.svg})),{description:"Export to SVG",name:a,extension:n.exportEmbedScene?"excalidraw.svg":"svg",fileHandle:l});if(e==="clipboard-svg"){const h=await d.then(m=>m.outerHTML);try{await Fa(h)}catch{throw new Error(b("errors.copyToSystemClipboardFailed"))}return}}const u=gC(t,n,r,{exportBackground:i,viewBackgroundColor:s,exportPadding:o,exportingFrame:c});if(e==="png"){let d=_d(u);return n.exportEmbedScene&&(d=d.then(h=>ie(()=>Promise.resolve().then(()=>Wm),void 0).then(({encodePngMetadata:m})=>m({blob:h,metadata:hc(t,n,r,"local")})))),Bm(d,{description:"Export to PNG",name:a,extension:"png",fileHandle:l})}else if(e==="clipboard")try{const d=_d(u);await fz(d)}catch(d){throw console.warn(d),d.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):R1&&d.name==="TypeError"?new Error(`${b("alerts.couldNotCopyToClipboard")}
${b("hints.firefox_clipboard_write")}`):new Error(b("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")},nj=async(e,t,n,r)=>{const{exportBackground:i,viewBackgroundColor:o,fileHandle:s}=t,a=qI(s);if(!s||!yF(a))throw new Error("fileHandle should exist and should be of type svg or png when resaving");t={...t,exportEmbedScene:!0};const{exportedElements:l,exportingFrame:c}=Sg(e,t,!1);return await kg(a,l,t,n,{exportBackground:i,viewBackgroundColor:o,name:r,fileHandle:s,exportingFrame:c}),{fileHandle:s}},Ig=({children:e,checked:t,onChange:n,className:r})=>k("div",{className:se("Checkbox",r,{"is-checked":t}),onClick:i=>{n(!t,i),i.currentTarget.querySelector(".Checkbox-box").focus()},children:[f("button",{className:"Checkbox-box",role:"checkbox","aria-checked":t,children:AH}),f("div",{className:"Checkbox-label",children:e})]}),rj=ne({name:"changeProjectName",trackEvent:!1,perform:(e,t,n)=>({appState:{...t,name:n},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t,appProps:n,data:r,app:i})=>f(ej,{label:b("labels.fileTitle"),value:i.getName(),onChange:o=>t(o),ignoreFocus:(r==null?void 0:r.ignoreFocus)??!1})}),ij=ne({name:"changeExportScale",trackEvent:{category:"export",action:"scale"},perform:(e,t,n)=>({appState:{...t,exportScale:n},commitToHistory:!1}),PanelComponent:({elements:e,appState:t,updateData:n})=>{const r=je(e),o=Lt(r,t)?qe(r,t):r;return f(re,{children:Bv.map(s=>{const[a,l]=DF(o,ac,s),c=`${b("imageExportDialog.label.scale")} ${s}x (${a}x${l})`;return f(Ce,{size:"small",type:"radio",icon:`${s}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:s===t.exportScale,onChange:()=>n(s)},s)})})}}),oj=ne({name:"changeExportBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,n)=>({appState:{...t,exportBackground:n},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>f(Ig,{checked:e.exportBackground,onChange:n=>t(n),children:b("imageExportDialog.label.withBackground")})}),V8=ne({name:"changeExportEmbedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,n)=>({appState:{...t,exportEmbedScene:n},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>k(Ig,{checked:e.exportEmbedScene,onChange:n=>t(n),children:[b("imageExportDialog.label.embedScene"),f(ro,{label:b("imageExportDialog.tooltip.embedScene"),long:!0,children:f("div",{className:"excalidraw-tooltip-icon",children:BH})})]})}),q6=ne({name:"saveToActiveFile",trackEvent:{category:"export"},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{const i=!!t.fileHandle;try{const{fileHandle:o}=mE(t.fileHandle)?await nj(e,t,r.files,r.getName()):await eC(e,t,r.files,r.getName());return{commitToHistory:!1,appState:{...t,fileHandle:o,toast:i?{message:o!=null&&o.name?b("toast.fileSavedToFilename").replace("{filename}",`"${o.name}"`):b("toast.fileSaved")}:null}}}catch(o){return(o==null?void 0:o.name)!=="AbortError"?console.error(o):console.warn(o),{commitToHistory:!1}}},keyTest:e=>e.key===D.S&&e[D.CTRL_OR_CMD]&&!e.shiftKey}),G8=ne({name:"saveFileToDisk",viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,n,r)=>{try{const{fileHandle:i}=await eC(e,{...t,fileHandle:null},r.files,r.getName());return{commitToHistory:!1,appState:{...t,openDialog:null,fileHandle:i,toast:{message:b("toast.fileSaved")}}}}catch(i){return(i==null?void 0:i.name)!=="AbortError"?console.error(i):console.warn(i),{commitToHistory:!1}}},keyTest:e=>e.key===D.S&&e.shiftKey&&e[D.CTRL_OR_CMD],PanelComponent:({updateData:e})=>f(Ce,{type:"button",icon:PH,title:b("buttons.saveAs"),"aria-label":b("buttons.saveAs"),showAriaLabel:gn().editor.isMobile,hidden:!Da,onClick:()=>e(null),"data-testid":"save-as-button"})}),fy=ne({name:"loadScene",trackEvent:{category:"export"},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{try{const{elements:i,appState:o,files:s}=await kF(t,e);return{elements:i,appState:o,files:s,commitToHistory:!0}}catch(i){return(i==null?void 0:i.name)==="AbortError"?(console.warn(i),!1):{elements:e,appState:{...t,errorMessage:i.message},files:r.files,commitToHistory:!1}}},keyTest:e=>e[D.CTRL_OR_CMD]&&e.key===D.O}),sj=ne({name:"exportWithDarkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,n)=>({appState:{...t,exportWithDarkMode:n},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>f("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:f(tj,{value:e.exportWithDarkMode?Tt.DARK:Tt.LIGHT,onChange:n=>{t(n===Tt.DARK)},title:b("imageExportDialog.label.darkMode")})})});let j8="{}";const aj=ne({name:"copyStyles",trackEvent:{category:"element"},perform:(e,t,n,r)=>{const i=[],o=e.find(s=>t.selectedElementIds[s.id]);if(i.push(o),o&&ls(o)){const s=ke(o,r.scene.getNonDeletedElementsMap());i.push(s)}return o&&(j8=JSON.stringify(i)),{appState:{...t,toast:{message:b("toast.copyStyles")}},commitToHistory:!1}},contextItemLabel:"labels.copyStyles",keyTest:e=>e[D.CTRL_OR_CMD]&&e.altKey&&e.code===De.C}),lj=ne({name:"pasteStyles",trackEvent:{category:"element"},perform:(e,t,n,r)=>{const i=JSON.parse(j8),o=i[0],s=i[1];if(!Jk(o))return{elements:e,commitToHistory:!1};const a=qe(e,t,{includeBoundTextElement:!0}),l=a.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let u=o;if(ce(c)&&c.containerId&&(u=s),!u)return c;let d=ge(c,{backgroundColor:u==null?void 0:u.backgroundColor,strokeWidth:u==null?void 0:u.strokeWidth,strokeColor:u==null?void 0:u.strokeColor,strokeStyle:u==null?void 0:u.strokeStyle,fillStyle:u==null?void 0:u.fillStyle,opacity:u==null?void 0:u.opacity,roughness:u==null?void 0:u.roughness,roundness:u.roundness?DD(u.roundness.type,c)?u.roundness:OD(c):null});if(ce(d)){const h=u.fontSize||Xr,m=u.fontFamily||oo;d=ge(d,{fontSize:h,fontFamily:m,textAlign:u.textAlign||D1,lineHeight:u.lineHeight||wa(m)});let g=null;d.containerId&&(g=a.find(p=>ce(d)&&p.id===d.containerId)||null),Mi(d,g,r.scene.getNonDeletedElementsMap())}return d.type==="arrow"&&Ge(u)&&(d=ge(d,{startArrowhead:u.startArrowhead,endArrowhead:u.endArrowhead})),pe(c)&&(d=ge(d,{roundness:null,backgroundColor:"transparent"})),d}return c}),commitToHistory:!0}},contextItemLabel:"labels.pasteStyles",keyTest:e=>e[D.CTRL_OR_CMD]&&e.altKey&&e.code===De.V});ne({name:"toggleCanvasMenu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="canvas"?null:"canvas"},commitToHistory:!1}),PanelComponent:({appState:e,updateData:t})=>f(Ce,{type:"button",icon:jT,"aria-label":b("buttons.menu"),onClick:t,selected:e.openMenu==="canvas"})});ne({name:"toggleEditMenu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="shape"?null:"shape"},commitToHistory:!1}),PanelComponent:({elements:e,appState:t,updateData:n})=>f(Ce,{visible:DE(t,je(e)),type:"button",icon:RH,"aria-label":b("buttons.edit"),onClick:n,selected:t.openMenu==="shape"})});const QE=ne({name:"toggleShortcuts",viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,n,{focusContainer:r})=>{var i,o;return((i=t.openDialog)==null?void 0:i.name)==="help"&&r(),{appState:{...t,openDialog:((o=t.openDialog)==null?void 0:o.name)==="help"?null:{name:"help"}},commitToHistory:!1}},keyTest:e=>e.key===D.QUESTION_MARK}),cj=e=>{if(e.length>=2){const t=e[0].groupIds;for(const n of t)if(e.reduce((r,i)=>r&&bd(i,n),!0))return!0}return!1},Q6=(e,t,n)=>{const r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!cj(r)},uj=ne({name:"group",trackEvent:{category:"element"},perform:(e,t,n,r)=>{const i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});if(i.length<2)return{appState:t,elements:e,commitToHistory:!1};const o=Ml(t);if(o.length===1){const p=o[0],v=new Set(It(e,p).map(w=>w.id)),y=new Set(i.map(w=>w.id));if(new Set([...Array.from(v),...Array.from(y)]).size===v.size)return{appState:t,elements:e,commitToHistory:!1}}let s=[...e];new Set(i.map(p=>p.frameId)).size>1&&xz(i).forEach((v,y)=>{sg(v,r.scene.getNonDeletedElementsMap())});const l=xr(),c=be(i);s=s.map(p=>c.get(p.id)?ge(p,{groupIds:AN(p.groupIds,l,t.editingGroupId)}):p);const u=It(s,l),d=u[u.length-1],h=s.lastIndexOf(d),m=s.slice(h+1);return s=[...s.slice(0,h).filter(p=>!bd(p,l)),...u,...m],{appState:{...t,...RI(l,{...t,selectedGroupIds:{}},je(s))},elements:s,commitToHistory:!0}},contextItemLabel:"labels.group",predicate:(e,t,n,r)=>Q6(e,t,r),keyTest:e=>!e.shiftKey&&e[D.CTRL_OR_CMD]&&e.key===D.G,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>f(Ce,{hidden:!Q6(e,t,r),type:"button",icon:f(rU,{theme:t.theme}),onClick:()=>n(null),title:`${b("labels.group")} — ${K("CtrlOrCmd+G")}`,"aria-label":b("labels.group"),visible:Lt(je(e),t)})}),dj=ne({name:"ungroup",trackEvent:{category:"element"},perform:(e,t,n,r)=>{const i=Ml(t),o=be(e);if(i.length===0)return{appState:t,elements:e,commitToHistory:!1};let s=[...e];const a=[];s=s.map(h=>{Mt(h)&&a.push(h.id);const m=LN(h.groupIds,t.selectedGroupIds);return m.length===h.groupIds.length?h:ge(h,{groupIds:m})});const l=Zn(t,je(s),t,null),c=r.scene.getSelectedElements(t),u=new Set(c.filter(h=>h.frameId).map(h=>h.frameId));return LE(e).filter(h=>u.has(h.id)).forEach(h=>{h&&(s=MT(s,Hf(s,h,t,o),h))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((h,[m,g])=>(g&&!a.includes(m)&&(h[m]=!0),h),{}),{appState:{...t,...l},elements:s,commitToHistory:!0}},keyTest:e=>e.shiftKey&&e[D.CTRL_OR_CMD]&&e.key===D.G.toUpperCase(),contextItemLabel:"labels.ungroup",predicate:(e,t)=>Ml(t).length>0,PanelComponent:({elements:e,appState:t,updateData:n})=>f(Ce,{type:"button",hidden:Ml(t).length===0,icon:f(iU,{theme:t.theme}),onClick:()=>n(null),title:`${b("labels.ungroup")} — ${K("CtrlOrCmd+Shift+G")}`,"aria-label":b("labels.ungroup"),visible:Lt(je(e),t)})}),Y8=(e,t,n,r,i,o,s)=>{e.beginPath(),e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+i-o),e.quadraticCurveTo(t+r,n+i,t+r-o,n+i),e.lineTo(t+o,n+i),e.quadraticCurveTo(t,n+i,t,n+i-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath(),e.fill(),s&&(e.strokeStyle=s),e.stroke()};var qs=(e=>(e.ACTIVE="active",e.AWAY="away",e.IDLE="idle",e))(qs||{});function hj(e){let t=0;if(e.length===0)return t;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);t=(t<<5)-t+r}return t}const Cg=(e,t)=>`hsl(${Math.abs(hj((t==null?void 0:t.id)||e))%37*10}, 100%, 83%)`,fj=e=>{var n;const t=(n=e==null?void 0:e.trim())==null?void 0:n.codePointAt(0);return(t?String.fromCodePoint(t):"?").toUpperCase()},mj=({context:e,renderConfig:t,appState:n,normalizedWidth:r,normalizedHeight:i})=>{for(const[o,s]of t.remotePointerViewportCoords){let{x:a,y:l}=s;const c=n.collaborators.get(o);a-=n.offsetLeft,l-=n.offsetTop;const u=11,d=14,h=a<0||a>r-u||l<0||l>i-d;a=Math.max(a,0),a=Math.min(a,r-u),l=Math.max(l,0),l=Math.min(l,i-d);const m=Cg(o,c);e.save(),e.strokeStyle=m,e.fillStyle=m;const g=t.remotePointerUserStates.get(o),p=h||g===qs.IDLE||g===qs.AWAY;p&&(e.globalAlpha=.3),t.remotePointerButton.get(o)==="down"&&(e.beginPath(),e.arc(a,l,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(a,l,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=m,e.stroke(),e.closePath());const v=n.theme===Tt.DARK?"#2f6330":oR,y=c==null?void 0:c.isSpeaking;y&&(e.fillStyle=v,e.strokeStyle=v,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(a,l),e.lineTo(a+0,l+14),e.lineTo(a+4,l+9),e.lineTo(a+11,l+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Oh,e.strokeStyle=Oh,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(a,l),e.lineTo(a+0,l+14),e.lineTo(a+4,l+9),e.lineTo(a+11,l+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=m,e.strokeStyle=m,e.lineWidth=2,e.lineJoin="round",e.beginPath(),p?(e.moveTo(a-1,l-1),e.lineTo(a-1,l+15),e.lineTo(a+5,l+10),e.lineTo(a+12,l+9),e.closePath(),e.fill()):(e.moveTo(a,l),e.lineTo(a+0,l+14),e.lineTo(a+4,l+9),e.lineTo(a+11,l+8),e.closePath(),e.fill(),e.stroke());const E=t.remotePointerUsernames.get(o)||"";if(!h&&E){e.font="600 12px sans-serif";const w=(y?a+0:a)+u/2,x=(y?l+0:l)+d+2,C=5,S=3,I=e.measureText(E),T=I.actualBoundingBoxDescent+I.actualBoundingBoxAscent,L=Math.max(T,12),A=w-1,F=x-1,P=I.width+2+C*2+2,O=L+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(A,F,P,O,8),e.fillStyle=m,e.fill(),e.strokeStyle=Oh,e.stroke(),y&&(e.beginPath(),e.roundRect(A-2,F-2,P+4,O+4,8),e.strokeStyle=v,e.stroke())):Y8(e,A,F,P,O,8,Oh),e.fillStyle=iR,e.fillText(E,w+C+1,x+S+I.actualBoundingBoxAscent+Math.floor((L-T)/2)+2),y){e.fillStyle=v;const V=8,G=8,q=5;e.fillRect(A+P+G,F+(O/2-V/2),2,V),e.fillRect(A+P+G+q,F+(O/2-V*2/2),2,V*2),e.fillRect(A+P+G+q*2,F+(O/2-V/2),2,V)}}e.restore(),e.closePath()}},J6=({color:e,onClick:t,name:n,src:r,className:i})=>{const o=fj(n),[s,a]=_.useState(!1),l=!s&&r,c=l?void 0:{background:e};return f("div",{className:se("Avatar",i),style:c,onClick:t,children:l?f("img",{className:"Avatar-img",src:r,alt:o,referrerPolicy:"no-referrer",onError:()=>a(!0)}):o})};ne({name:"goToCollaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,n)=>{var r;return!n.socketId||((r=t.userToFollow)==null?void 0:r.socketId)===n.socketId||n.isCurrentUser?{appState:{...t,userToFollow:null},commitToHistory:!1}:{appState:{...t,userToFollow:{socketId:n.socketId,username:n.username||""},openMenu:t.openMenu==="canvas"?null:t.openMenu},commitToHistory:!1}},PanelComponent:({updateData:e,data:t,appState:n})=>{const{socketId:r,collaborator:i,withName:o,isBeingFollowed:s}=t,a=Cg(r,i),l=se({"is-followed":s,"is-current-user":i.isCurrentUser===!0,"is-speaking":i.isSpeaking,"is-in-call":i.isInCall,"is-muted":i.isMuted}),c=i.isInCall?i.isSpeaking?k("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:b("userList.hint.isSpeaking"),children:[f("div",{}),f("div",{}),f("div",{})]}):i.isMuted?f("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:b("userList.hint.micMuted"),children:JU}):f("div",{title:b("userList.hint.inCall"),children:QU}):null;return o?k("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(i),children:[f(J6,{color:a,onClick:()=>{},name:i.username||"",src:i.avatarUrl,className:l}),f("div",{className:"UserList__collaborator-name",children:i.username}),k("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[s&&f("div",{className:"UserList__collaborator-status-icon-is-followed",title:b("userList.hint.followStatus"),children:JT}),c]})]}):k("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[f(J6,{color:a,onClick:()=>{e(i)},name:i.username||"",src:i.avatarUrl,className:l}),c&&f("div",{className:"UserList__collaborator-status-icon",children:c})]})}});const gj=ne({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,n,r)=>{const i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(const o of GS)if(i.some(s=>s.type===o))return{commitToHistory:!1,appState:{...t,errorMessage:b(`errors.libraryElementTypeError.${o}`)}};return r.library.getLatestLibrary().then(o=>r.library.setLibrary([{id:xr(),status:"unpublished",elements:i.map(th),created:Date.now()},...o])).then(()=>({commitToHistory:!1,appState:{...t,toast:{message:b("toast.addedToLibrary")}}})).catch(o=>({commitToHistory:!1,appState:{...t,errorMessage:o.message}}))},contextItemLabel:"labels.addToLibrary"}),pj=(e,t,n)=>{const r=X1(e,t),i=ji(e);return r.flatMap(o=>{const s=yj(o,i,n);return o.map(a=>ge(a,{x:a.x+s.x,y:a.y+s.y}))})},yj=(e,t,{axis:n,position:r})=>{const i=ji(e),[o,s]=n==="x"?["minX","maxX"]:["minY","maxY"],a={x:0,y:0};return r==="start"?{...a,[n]:t[o]-i[o]}:r==="end"?{...a,[n]:t[s]-i[s]}:{...a,[n]:(t[o]+t[s])/2-(i[o]+i[s])/2}},Ir=(e,t,n,r)=>{const i=r.scene.getSelectedElements(t);return i.length>1&&!i.some(o=>pe(o))},bc=(e,t,n,r)=>{const i=n.scene.getSelectedElements(t),o=be(e),s=pj(i,o,r),a=be(s);return Ql(e.map(l=>a.get(l.id)||l),t,n)};ne({name:"alignTop",trackEvent:{category:"element"},predicate:Ir,perform:(e,t,n,r)=>({appState:t,elements:bc(e,t,r,{position:"start",axis:"y"}),commitToHistory:!0}),keyTest:e=>e[D.CTRL_OR_CMD]&&e.shiftKey&&e.key===D.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>f(Ce,{hidden:!Ir(e,t,null,r),type:"button",icon:YH,onClick:()=>n(null),title:`${b("labels.alignTop")} — ${K("CtrlOrCmd+Shift+Up")}`,"aria-label":b("labels.alignTop"),visible:Lt(je(e),t)})});ne({name:"alignBottom",trackEvent:{category:"element"},predicate:Ir,perform:(e,t,n,r)=>({appState:t,elements:bc(e,t,r,{position:"end",axis:"y"}),commitToHistory:!0}),keyTest:e=>e[D.CTRL_OR_CMD]&&e.shiftKey&&e.key===D.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>f(Ce,{hidden:!Ir(e,t,null,r),type:"button",icon:KH,onClick:()=>n(null),title:`${b("labels.alignBottom")} — ${K("CtrlOrCmd+Shift+Down")}`,"aria-label":b("labels.alignBottom"),visible:Lt(je(e),t)})});ne({name:"alignLeft",trackEvent:{category:"element"},predicate:Ir,perform:(e,t,n,r)=>({appState:t,elements:bc(e,t,r,{position:"start",axis:"x"}),commitToHistory:!0}),keyTest:e=>e[D.CTRL_OR_CMD]&&e.shiftKey&&e.key===D.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>f(Ce,{hidden:!Ir(e,t,null,r),type:"button",icon:ZH,onClick:()=>n(null),title:`${b("labels.alignLeft")} — ${K("CtrlOrCmd+Shift+Left")}`,"aria-label":b("labels.alignLeft"),visible:Lt(je(e),t)})});ne({name:"alignRight",trackEvent:{category:"element"},predicate:Ir,perform:(e,t,n,r)=>({appState:t,elements:bc(e,t,r,{position:"end",axis:"x"}),commitToHistory:!0}),keyTest:e=>e[D.CTRL_OR_CMD]&&e.shiftKey&&e.key===D.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>f(Ce,{hidden:!Ir(e,t,null,r),type:"button",icon:XH,onClick:()=>n(null),title:`${b("labels.alignRight")} — ${K("CtrlOrCmd+Shift+Right")}`,"aria-label":b("labels.alignRight"),visible:Lt(je(e),t)})});ne({name:"alignVerticallyCentered",trackEvent:{category:"element"},predicate:Ir,perform:(e,t,n,r)=>({appState:t,elements:bc(e,t,r,{position:"center",axis:"y"}),commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>f(Ce,{hidden:!Ir(e,t,null,r),type:"button",icon:JH,onClick:()=>n(null),title:b("labels.centerVertically"),"aria-label":b("labels.centerVertically"),visible:Lt(je(e),t)})});ne({name:"alignHorizontallyCentered",trackEvent:{category:"element"},predicate:Ir,perform:(e,t,n,r)=>({appState:t,elements:bc(e,t,r,{position:"center",axis:"x"}),commitToHistory:!0}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>f(Ce,{hidden:!Ir(e,t,null,r),type:"button",icon:eU,onClick:()=>n(null),title:b("labels.centerHorizontally"),"aria-label":b("labels.centerHorizontally"),visible:Lt(je(e),t)})});const vj=(e,t,n)=>{const[r,i,o,s]=n.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],a=ji(e),l=X1(e,t).map(h=>[h,ji(h)]).sort((h,m)=>h[1][i]-m[1][i]);let c=0;for(const h of l)c+=h[1][s];const u=(a[s]-c)/(l.length-1);if(u<0){const h=l.findIndex(v=>v[1][r]===a[r]),m=l.findIndex(v=>v[1][o]===a[o]),g=(l[m][1][i]-l[h][1][i])/(l.length-1);let p=l[h][1][i];return l.flatMap(([v,y],E)=>{const w={x:0,y:0};return E!==h&&E!==m&&(p+=g,w[n.axis]=p-y[i]),v.map(x=>ge(x,{x:x.x+w.x,y:x.y+w.y}))})}let d=a[r];return l.flatMap(([h,m])=>{const g={x:0,y:0};return g[n.axis]=d-m[r],d+=u,d+=m[s],h.map(p=>ge(p,{x:p.x+g.x,y:p.y+g.y}))})},K8=(e,t)=>{const n=t.scene.getSelectedElements(e);return n.length>1&&!n.some(r=>pe(r))},Z8=(e,t,n,r)=>{const i=n.scene.getSelectedElements(t),o=vj(i,n.scene.getNonDeletedElementsMap(),r),s=be(o);return Ql(e.map(a=>s.get(a.id)||a),t,n)};ne({name:"distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,n,r)=>({appState:t,elements:Z8(e,t,r,{space:"between",axis:"x"}),commitToHistory:!0}),keyTest:e=>!e[D.CTRL_OR_CMD]&&e.altKey&&e.code===De.H,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>f(Ce,{hidden:!K8(t,r),type:"button",icon:qH,onClick:()=>n(null),title:`${b("labels.distributeHorizontally")} — ${K("Alt+H")}`,"aria-label":b("labels.distributeHorizontally"),visible:Lt(je(e),t)})});ne({name:"distributeVertically",trackEvent:{category:"element"},perform:(e,t,n,r)=>({appState:t,elements:Z8(e,t,r,{space:"between",axis:"y"}),commitToHistory:!0}),keyTest:e=>!e[D.CTRL_OR_CMD]&&e.altKey&&e.code===De.V,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>f(Ce,{hidden:!K8(t,r),type:"button",icon:QH,onClick:()=>n(null),title:`${b("labels.distributeVertically")} — ${K("Alt+V")}`,"aria-label":b("labels.distributeVertically"),visible:Lt(je(e),t)})});const Ej=ne({name:"flipHorizontal",trackEvent:{category:"element"},perform:(e,t,n,r)=>({elements:Ql(X8(e,r.scene.getNonDeletedElementsMap(),t,"horizontal"),t,r),appState:t,commitToHistory:!0}),keyTest:e=>e.shiftKey&&e.code===De.H,contextItemLabel:"labels.flipHorizontal"}),wj=ne({name:"flipVertical",trackEvent:{category:"element"},perform:(e,t,n,r)=>({elements:Ql(X8(e,r.scene.getNonDeletedElementsMap(),t,"vertical"),t,r),appState:t,commitToHistory:!0}),keyTest:e=>e.shiftKey&&e.code===De.V&&!e[D.CTRL_OR_CMD],contextItemLabel:"labels.flipVertical"}),X8=(e,t,n,r)=>{const i=qe(je(e),n,{includeBoundTextElement:!0,includeElementsInFrames:!0}),o=bj(i,e,t,n,r),s=be(o);return e.map(a=>s.get(a.id)||a)},bj=(e,t,n,r,i)=>{const{minX:o,minY:s,maxX:a,maxY:l}=ji(e);return zT(n,e,n,"nw",!0,i==="horizontal"?a:o,i==="horizontal"?s:l),Gs(r)?P2(e,t,n):D2(e,n),e},Kf=ne({name:"copy",trackEvent:{category:"element"},perform:async(e,t,n,r)=>{const i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await lz(i,r.files,n)}catch(o){return{commitToHistory:!1,appState:{...t,errorMessage:o.message}}}return{commitToHistory:!1}},contextItemLabel:"labels.copy",keyTest:void 0}),e4=ne({name:"paste",trackEvent:{category:"element"},perform:async(e,t,n,r)=>{let i;try{i=await dz()}catch(o){return o.name==="AbortError"||o.name==="NotAllowedError"?!1:(console.error(`actionPaste ${o.name}: ${o.message}`),R1?{commitToHistory:!1,appState:{...t,errorMessage:b("hints.firefox_clipboard_write")}}:{commitToHistory:!1,appState:{...t,errorMessage:b("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(sz({types:i}))}catch(o){return console.error(o),{commitToHistory:!1,appState:{...t,errorMessage:b("errors.asyncPasteFailedOnParse")}}}return{commitToHistory:!1}},contextItemLabel:"labels.paste",keyTest:void 0}),t4=ne({name:"cut",trackEvent:{category:"element"},perform:(e,t,n,r)=>(Kf.perform(e,t,n,r),e8.perform(e,t,null,r)),contextItemLabel:"labels.cut",keyTest:e=>e[D.CTRL_OR_CMD]&&e.key===D.X}),n4=ne({name:"copyAsSvg",trackEvent:{category:"element"},perform:async(e,t,n,r)=>{if(!r.canvas)return{commitToHistory:!1};const{exportedElements:i,exportingFrame:o}=Sg(e,t,!0);try{return await kg("clipboard-svg",i,t,r.files,{...t,exportingFrame:o,name:r.getName()}),{commitToHistory:!1}}catch(s){return console.error(s),{appState:{...t,errorMessage:s.message},commitToHistory:!1}}},predicate:e=>ME&&e.length>0,contextItemLabel:"labels.copyAsSvg"}),r4=ne({name:"copyAsPng",trackEvent:{category:"element"},perform:async(e,t,n,r)=>{if(!r.canvas)return{commitToHistory:!1};const i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:o,exportingFrame:s}=Sg(e,t,!0);try{return await kg("clipboard",o,t,r.files,{...t,exportingFrame:s,name:r.getName()}),{appState:{...t,toast:{message:b("toast.copyToClipboardAsPng",{exportSelection:i.length?b("toast.selection"):b("toast.canvas"),exportColorScheme:t.exportWithDarkMode?b("buttons.darkMode"):b("buttons.lightMode")})}},commitToHistory:!1}}catch(a){return console.error(a),{appState:{...t,errorMessage:a.message},commitToHistory:!1}}},predicate:e=>AE&&e.length>0,contextItemLabel:"labels.copyAsPng",keyTest:e=>e.code===De.C&&e.altKey&&e.shiftKey}),i4=ne({name:"copyText",trackEvent:{category:"element"},perform:(e,t,n,r)=>{const o=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).reduce((s,a)=>(ce(a)&&s.push(a.text),s),[]).join(`
`);try{Fa(o)}catch{throw new Error(b("errors.copyToSystemClipboardFailed"))}return{commitToHistory:!1}},predicate:(e,t,n,r)=>ME&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(ce),contextItemLabel:"labels.copyText"}),o4=ne({name:"gridMode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.gridSize},perform(e,t){return{appState:{...t,gridSize:this.checked(t)?null:Cl,objectsSnapModeEnabled:!1},commitToHistory:!1}},checked:e=>e.gridSize!==null,predicate:(e,t,n)=>typeof n.gridModeEnabled>"u",contextItemLabel:"labels.showGrid",keyTest:e=>e[D.CTRL_OR_CMD]&&e.code===De.QUOTE}),my=ne({name:"zenMode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},commitToHistory:!1}},checked:e=>e.zenModeEnabled,predicate:(e,t,n)=>typeof n.zenModeEnabled>"u",contextItemLabel:"buttons.zenMode",keyTest:e=>!e[D.CTRL_OR_CMD]&&e.altKey&&e.code===De.Z}),_j=ne({name:"objectsSnapMode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridSize:null},commitToHistory:!1}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,n)=>typeof n.objectsSnapModeEnabled>"u",contextItemLabel:"buttons.objectsSnapMode",keyTest:e=>!e[D.CTRL_OR_CMD]&&e.altKey&&e.code===De.S}),e1=ne({name:"stats",viewMode:!0,trackEvent:{category:"menu"},perform(e,t){return{appState:{...t,showStats:!this.checked(t)},commitToHistory:!1}},checked:e=>e.showStats,contextItemLabel:"stats.title",keyTest:e=>!e[D.CTRL_OR_CMD]&&e.altKey&&e.code===De.SLASH}),xj=ne({name:"unbindText",contextItemLabel:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,n,r)=>r.scene.getSelectedElements(t).some(o=>ls(o)),perform:(e,t,n,r)=>{const i=r.scene.getSelectedElements(t),o=r.scene.getNonDeletedElementsMap();return i.forEach(s=>{var l;const a=ke(s,o);if(a){const{width:c,height:u}=ds(a.originalText,Bt(a),a.lineHeight),d=ZO(s.id);SI(s.id);const{x:h,y:m}=Y1(s,a,o);J(a,{containerId:null,width:c,height:u,text:a.originalText,x:h,y:m}),J(s,{boundElements:(l=s.boundElements)==null?void 0:l.filter(g=>g.id!==a.id),height:d||s.height})}}),{elements:e,appState:t,commitToHistory:!0}}}),Sj=ne({name:"bindText",contextItemLabel:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,n,r)=>{const i=r.scene.getSelectedElements(t);if(i.length===2){const o=ce(i[0])||ce(i[1]);let s;if(ia(i[0])?s=i[0]:ia(i[1])&&(s=i[1]),o&&s&&ke(s,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,n,r)=>{const i=r.scene.getSelectedElements(t);let o,s;ce(i[0])&&ia(i[1])?(o=i[0],s=i[1]):(o=i[1],s=i[0]),J(o,{containerId:s.id,verticalAlign:Qn.MIDDLE,textAlign:hd.CENTER}),J(s,{boundElements:(s.boundElements||[]).concat({type:"text",id:o.id})});const a=s.height;return Mi(o,s,r.scene.getNonDeletedElementsMap()),Om(s.id,a),{elements:kj(e,s,o),appState:{...t,selectedElementIds:{[s.id]:!0}},commitToHistory:!0}}}),kj=(e,t,n)=>{const r=e.slice(),i=r.findIndex(s=>s.id===n.id);r.splice(i,1);const o=r.findIndex(s=>s.id===t.id);return r.splice(o+1,0,n),r},Ij=(e,t,n)=>{const r=e.slice(),i=r.findIndex(s=>s.id===t.id);r.splice(i,1);const o=r.findIndex(s=>s.id===n.id);return r.splice(o,0,t),r},Cj=ne({name:"wrapTextInContainer",contextItemLabel:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,n,r)=>{const i=r.scene.getSelectedElements(t),o=i.every(s=>ce(s));return i.length>0&&o},perform:(e,t,n,r)=>{var a;const i=r.scene.getSelectedElements(t);let o=e.slice();const s={};for(const l of i)if(ce(l)){const c=hs({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness==="round"?{type:uc("rectangle")?Vt.ADAPTIVE_RADIUS:Vt.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-Nt,y:l.y-Nt,width:Ea(l.width,"rectangle"),height:Ea(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if((a=l.boundElements)!=null&&a.length){const u=l.boundElements.filter(h=>h.type==="arrow").map(h=>h.id);o.filter(h=>u.includes(h.id)).forEach(h=>{let m=h.startBinding,g=h.endBinding;(m==null?void 0:m.elementId)===l.id&&(m={...m,elementId:c.id}),(g==null?void 0:g.elementId)===l.id&&(g={...g,elementId:c.id}),(m||g)&&J(h,{startBinding:m,endBinding:g},!1)})}J(l,{containerId:c.id,verticalAlign:Qn.MIDDLE,boundElements:null,textAlign:hd.CENTER},!1),Mi(l,c,r.scene.getNonDeletedElementsMap()),o=Ij([...o,c],c,l),s[c.id]=!0}return{elements:o,appState:{...t,selectedElementIds:s},commitToHistory:!0}}}),JE=320,q8=85,gy=5,Tj=42,Mj=500;let py=!1;const tf=new Map,Aj=({element:e,elementsMap:t,setAppState:n,onLinkOpen:r,setToast:i,updateEmbedValidationStatus:o})=>{const s=kw(),a=Sw(),l=e.link||"",[c,u]=_.useState(l),d=_.useRef(null),h=s.showHyperlinkPopup==="editor",m=_.useCallback(()=>{var w;if(!d.current)return;const E=xi(d.current.value)||null;if(!e.link&&E&&Ae("hyperlink","create"),bn(e)){if(((w=s.activeEmbeddable)==null?void 0:w.element)===e&&n({activeEmbeddable:null}),!E){J(e,{link:null}),o(e,!1);return}if(!Rf(E,a.validateEmbeddable))E&&i({message:b("toast.unableToEmbed"),closable:!0}),e.link&&tf.set(e.id,e.link),J(e,{link:E}),o(e,!1);else{const{width:x,height:C}=e,S=yl(E);(S==null?void 0:S.error)instanceof URIError&&i({message:b("toast.unrecognizedLinkFormat"),closable:!0});const I=S?S.intrinsicSize.w/S.intrinsicSize.h:1,T=tf.get(e.id)!==e.link;J(e,{...T?{width:(S==null?void 0:S.type)==="video"?x>C?x:C*I:x,height:(S==null?void 0:S.type)==="video"&&x>C?x/I:C}:{},link:E}),o(e,!0),tf.has(e.id)&&tf.delete(e.id)}}else J(e,{link:E})},[e,i,a.validateEmbeddable,s.activeEmbeddable,n,o]);_.useLayoutEffect(()=>()=>{m()},[m]),_.useEffect(()=>{let E=null;const w=x=>{if(h)return;E&&clearTimeout(E),Dj(e,t,s,[x.clientX,x.clientY])&&(E=window.setTimeout(()=>{n({showHyperlinkPopup:!1})},Mj))};return window.addEventListener(Z.POINTER_MOVE,w,!1),()=>{window.removeEventListener(Z.POINTER_MOVE,w,!1),E&&clearTimeout(E)}},[s,e,h,n,t]);const g=_.useCallback(()=>{Ae("hyperlink","delete"),J(e,{link:null}),h&&(d.current.value=""),n({showHyperlinkPopup:!1})},[n,e,h]),p=()=>{Ae("hyperlink","edit","popup-ui"),n({showHyperlinkPopup:"editor"})},{x:v,y}=Q8(e,s,t);return s.contextMenu||s.draggingElement||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:k("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${v}px`,width:JE,padding:gy},onClick:()=>{!e.link&&!h&&n({showHyperlinkPopup:"editor"})},children:[h?f("input",{className:se("excalidraw-hyperlinkContainer-input"),placeholder:"Type or paste your link here",ref:d,value:c,onChange:E=>u(E.target.value),autoFocus:!0,onKeyDown:E=>{E.stopPropagation(),E[D.CTRL_OR_CMD]&&E.key===D.K&&E.preventDefault(),(E.key===D.ENTER||E.key===D.ESCAPE)&&(m(),n({showHyperlinkPopup:"info"}))}}):e.link?f("a",{href:xi(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:$I(e.link)?"_self":"_blank",onClick:E=>{if(e.link&&r){const w=Xk(Z.EXCALIDRAW_LINK,E.nativeEvent);r({...e,link:xi(e.link)},w),w.defaultPrevented&&E.preventDefault()}},rel:"noopener noreferrer",children:e.link}):f("div",{className:"excalidraw-hyperlinkContainer-link",children:b("labels.link.empty")}),k("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!h&&f(Ce,{type:"button",title:b("buttons.edit"),"aria-label":b("buttons.edit"),label:b("buttons.edit"),onClick:p,className:"excalidraw-hyperlinkContainer--edit",icon:$E}),l&&!bn(e)&&f(Ce,{type:"button",title:b("buttons.remove"),"aria-label":b("buttons.remove"),label:b("buttons.remove"),onClick:g,className:"excalidraw-hyperlinkContainer--remove",icon:ug})]})]})},Q8=(e,t,n)=>{const[r,i]=Ee(e,n),{x:o,y:s}=Ur({sceneX:r+e.width/2,sceneY:i},t),a=o-t.offsetLeft-JE/2,l=s-t.offsetTop-q8;return{x:a,y:l}},s4=(e,t)=>{const n=qe(e,t);return n[0].link?bn(n[0])?"labels.link.editEmbed":"labels.link.edit":bn(n[0])?"labels.link.createEmbed":"labels.link.create"};let Bu=null;const Lj=(e,t,n)=>{Bu&&clearTimeout(Bu),Bu=window.setTimeout(()=>Pj(e,t,n),fR)},Pj=(e,t,n)=>{if(!e.link)return;const r=$u();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=e.link;const[i,o,s,a]=Ee(e,n),[l,c,u,d]=yE([i,o,s,a],e.angle,t),h=Ur({sceneX:l,sceneY:c},t);H8(r,{left:h.x,top:h.y,width:u,height:d},"top"),Ae("hyperlink","tooltip","link-icon"),py=!0},Rj=()=>{Bu&&clearTimeout(Bu),py&&(py=!1,$u().classList.remove("excalidraw-tooltip--visible"))},Dj=(e,t,n,[r,i])=>{const{x:o,y:s}=et({clientX:r,clientY:i},n),a=15/n.zoom.value;if(U1(e,t,[o,s],a,null))return!1;const[l,c,u]=Ee(e,t);if(o>=l&&o<=u&&s>=c-q8&&s<=c)return!1;const{x:d,y:h}=Q8(e,n,t);return!(r>=d-a&&r<=d+JE+gy*2+a&&i>=h-a&&i<=h+a+gy*2+Tj)},Oj=ne({name:"hyperlink",perform:(e,t)=>t.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},commitToHistory:!0},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[D.CTRL_OR_CMD]&&e.key===D.K,contextItemLabel:(e,t)=>s4(e,t),predicate:(e,t)=>qe(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:n})=>{const r=qe(e,t);return f(Ce,{type:"button",icon:zE,"aria-label":b(s4(e,t)),title:`${bn(e[0])?b("labels.link.labelEmbed"):b("labels.link.label")} - ${K("CtrlOrCmd+K")}`,onClick:()=>n(null),selected:r.length===1&&!!r[0].link})}}),a4=e=>e.every(t=>!t.locked),Nj=ne({name:"toggleElementLock",trackEvent:{category:"element"},predicate:(e,t,n,r)=>!r.scene.getSelectedElements(t).some(o=>o.locked&&o.frameId),perform:(e,t,n,r)=>{const i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!i.length)return!1;const o=a4(i),s=be(i);return{elements:e.map(a=>s.has(a.id)?ge(a,{locked:o}):a),appState:{...t,selectedLinearElement:o?null:t.selectedLinearElement},commitToHistory:!0}},contextItemLabel:(e,t,n)=>{const r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return r.length===1&&!pe(r[0])?r[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":a4(r)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},keyTest:(e,t,n,r)=>e.key.toLocaleLowerCase()===D.L&&e[D.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),Fj=ne({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,predicate:e=>e.some(t=>t.locked),perform:(e,t)=>{const n=e.filter(r=>r.locked);return{elements:e.map(r=>r.locked?ge(r,{locked:!1}):r),appState:{...t,selectedElementIds:Object.fromEntries(n.map(r=>[r.id,!0]))},commitToHistory:!0}},contextItemLabel:"labels.elementLock.unlockAll"}),$j=ne({name:"toggleLinearEditor",trackEvent:{category:"element"},predicate:(e,t,n,r)=>{const i=r.scene.getSelectedElements(t);return!!(i.length===1&&we(i[0]))},perform(e,t,n,r){var s;const i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],o=((s=t.editingLinearElement)==null?void 0:s.elementId)===i.id?null:new ue(i);return{appState:{...t,editingLinearElement:o},commitToHistory:!1}},contextItemLabel:(e,t,n)=>{var i;const r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return((i=t.editingLinearElement)==null?void 0:i.elementId)===r.id?"labels.lineEditor.exit":"labels.lineEditor.edit"}}),J8=(e,t,n)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingElement&&!t.draggingElement){const i=n();if(i===null)return{commitToHistory:!1};const o=be(e),s=i.elements,a=be(s),l=e.filter(u=>!a.has(u.id)),c=s.map(u=>ge(o.get(u.id)||u,u)).concat(l.map(u=>ge(u,{isDeleted:!0})));return aE(c,l),{elements:c,appState:{...t,...i.appState},commitToHistory:!1,syncHistory:!0}}return{commitToHistory:!1}},Bj=e=>({name:"undo",trackEvent:{category:"history"},perform:(t,n)=>J8(t,n,()=>e.undoOnce()),keyTest:t=>t[D.CTRL_OR_CMD]&&t.key.toLowerCase()===D.Z&&!t.shiftKey,PanelComponent:({updateData:t,data:n})=>f(Ce,{type:"button",icon:FH,"aria-label":b("buttons.undo"),onClick:t,size:(n==null?void 0:n.size)||"medium"}),commitToHistory:()=>!1}),zj=e=>({name:"redo",trackEvent:{category:"history"},perform:(t,n)=>J8(t,n,()=>e.redoOnce()),keyTest:t=>t[D.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===D.Z||BS&&t.ctrlKey&&!t.shiftKey&&t.key===D.Y,PanelComponent:({updateData:t,data:n})=>f(Ce,{type:"button",icon:$H,"aria-label":b("buttons.redo"),onClick:t,size:(n==null?void 0:n.size)||"medium"}),commitToHistory:()=>!1}),Zp=(e,t,n,r,i,o)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(n,r,o))&&Ae(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${i.device.editor.isMobile?"mobile":"desktop"})`)}catch(s){console.error("error while logging action:",s)}};class Hj{constructor(t,n,r,i){M(this,"actions",{});M(this,"updater");M(this,"getAppState");M(this,"getElementsIncludingDeleted");M(this,"app");M(this,"renderAction",(t,n)=>{const r=this.app.props.UIOptions.canvasActions;if(this.actions[t]&&"PanelComponent"in this.actions[t]&&(!(t in r)||r[t])){const i=this.actions[t],o=i.PanelComponent;o.displayName="PanelComponent";const s=this.getElementsIncludingDeleted(),a=this.getAppState(),l=c=>{Zp(i,"ui",a,s,this.app,c),this.updater(i.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return f(o,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:l,appProps:this.app.props,app:this.app,data:n})}return null});M(this,"isActionEnabled",t=>{const n=this.getElementsIncludingDeleted(),r=this.getAppState();return!t.predicate||t.predicate(n,r,this.app.props,this.app)});this.updater=o=>{if(Xd(o))o.then(s=>t(s));else return t(o)},this.getAppState=n,this.getElementsIncludingDeleted=r,this.app=i}registerAction(t){this.actions[t.name]=t}registerAll(t){t.forEach(n=>this.registerAction(n))}handleKeyDown(t){const n=this.app.props.UIOptions.canvasActions,r=Object.values(this.actions).sort((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in n?n[l.name]:!0)&&l.keyTest&&l.keyTest(t,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;const i=r[0];if(this.getAppState().viewModeEnabled&&i.viewMode!==!0)return!1;const o=this.getElementsIncludingDeleted(),s=this.getAppState(),a=null;return Zp(i,"keyboard",s,o,this.app,null),t.preventDefault(),t.stopPropagation(),this.updater(r[0].perform(o,s,a,this.app)),!0}executeAction(t,n="api",r=null){const i=this.getElementsIncludingDeleted(),o=this.getAppState();Zp(t,n,o,i,this.app,r),this.updater(t.perform(i,o,r,this.app))}}const e7=mt(new Map),l4=async e=>await ET({elements:e,appState:{exportBackground:!1,viewBackgroundColor:ve.white},files:null,renderEmbeddables:!1}),Uj=(e,t,n)=>{const[r,i]=_.useState();return _.useEffect(()=>{if(t)if(e){const o=n.get(e);o?i(o):(async()=>{var a;const s=await l4(t);(a=s.querySelector(".style-fonts"))==null||a.remove(),s&&(n.set(e,s),i(s))})()}else(async()=>{const o=await l4(t);i(o)})()},[e,t,n,i]),r},t7=()=>{const[e]=ze(e7,en);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(i=>e.delete(i))},svgCache:e}};class yo{constructor(){M(this,"subscribers",[])}on(...t){const n=t.flat().filter(r=>typeof r=="function");return this.subscribers.push(...n),()=>this.off(n)}once(...t){const n=t.flat().filter(i=>typeof i=="function");n.push(()=>r());const r=this.on(...n);return r}off(...t){const n=t.flat();this.subscribers=this.subscribers.filter(r=>!n.includes(r))}trigger(...t){for(const n of this.subscribers)n(...t);return this}clear(){this.subscribers=[]}}class Wj{constructor(){M(this,"jobs",[]);M(this,"running",!1)}tick(){if(this.running)return;const t=this.jobs.shift();t?(this.running=!0,t.promise.resolve(I2(t.jobFactory,...t.args).finally(()=>{this.running=!1,this.tick()}))):this.running=!1}push(t,...n){const r=$1();return this.jobs.push({jobFactory:t,promise:r,args:n}),this.tick(),r}}const n7=new yo,Od=mt({status:"loaded",isInitialized:!1,libraryItems:[]}),jc=e=>Yl(e),Vj=(e,t)=>!e.find(n=>n.elements.length!==t.elements.length?!1:n.elements.every((r,i)=>r.id===t.elements[i].id&&r.versionNonce===t.elements[i].versionNonce)),Gj=(e,t)=>{const n=[];for(const r of t)Vj(e,r)&&n.push(r);return[...n,...e]},r7=(e,t)=>{const n=be(t),r={deletedItems:new Map,addedItems:new Map};for(const o of e)n.has(o.id)||r.deletedItems.set(o.id,o);const i=be(e);for(const o of t)i.has(o.id)||r.addedItems.set(o.id,o);return r};class jj{constructor(t){M(this,"currLibraryItems",[]);M(this,"prevLibraryItems",jc(this.currLibraryItems));M(this,"app");M(this,"updateQueue",[]);M(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);M(this,"notifyListeners",()=>{var t,n;if(this.updateQueue.length>0)_i.set(Od,r=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:r.isInitialized}));else{_i.set(Od,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{const r=this.prevLibraryItems;this.prevLibraryItems=jc(this.currLibraryItems);const i=jc(this.currLibraryItems);(n=(t=this.app.props).onLibraryChange)==null||n.call(t,i),n7.trigger(r7(r,i),i)}catch(r){console.error(r)}}});M(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],_i.set(e7,new Map)});M(this,"resetLibrary",()=>this.setLibrary([]));M(this,"getLatestLibrary",()=>new Promise(async t=>{try{const n=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?t(this.getLatestLibrary()):t(jc(n))}catch{return t(this.currLibraryItems)}}));M(this,"updateLibrary",async({libraryItems:t,prompt:n=!1,merge:r=!1,openLibraryMenu:i=!1,defaultStatus:o="unpublished"})=>(i&&this.app.setState({openSidebar:{name:Tl.name,tab:zv}}),this.setLibrary(()=>new Promise(async(s,a)=>{try{const l=await(typeof t=="function"&&!(t instanceof Blob)?t(this.currLibraryItems):t);let c;l instanceof Blob?c=await vF(l,o):c=q1(l,o),!n||window.confirm(b("alerts.confirmAddLibrary",{numShapes:c.length}))?(n&&this.app.focusContainer(),s(r?Gj(this.currLibraryItems,c):c)):a(new ql)}catch(l){a(l)}}))));M(this,"setLibrary",t=>{const n=new Promise(async(r,i)=>{try{await this.getLastUpdateTask(),typeof t=="function"&&(t=t(this.currLibraryItems)),this.currLibraryItems=jc(await t),r(this.currLibraryItems)}catch(o){i(o)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==n),this.notifyListeners()});return this.updateQueue.push(n),this.notifyListeners(),n});this.app=t}}const i7=e=>{const n=Math.ceil(Math.sqrt(e.length)),r=[],i=m=>e.slice(m*n,m*n+n).reduce((p,v)=>{const{height:y}=ji(v.elements);return Math.max(p,y)},0),o=m=>{let g=0,p=0,v=0;for(const y of e){if(g%n===0&&(p=0),p===m){const{width:E}=ji(y.elements);v=Math.max(v,E)}g++,p++}return v};let s=0,a=0,l=0,c=0,u=0,d=0,h=0;for(const m of e){u&&u%n===0&&(a+=l+50,s=0,d=0,h++),d===0&&(l=i(h)),c=o(d);const{minX:g,minY:p,width:v,height:y}=ji(m.elements),E=(c-v)/2,w=(l-y)/2;r.push(...m.elements.map(x=>({...x,x:x.x+s+E-g,y:x.y+a+w-p}))),s+=c+50,u++,d++}return r},yy=()=>{const e=new URLSearchParams(window.location.hash.slice(1)).get(p2.addLibrary)||new URLSearchParams(window.location.search).get(g2.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:t}:null},_o=class _o{constructor(t){M(this,"adapter");this.adapter=t}static async getLibraryItems(t,n,r=!0){const i=()=>new Promise(async(o,s)=>{try{const a=await t.load({source:n});o(q1((a==null?void 0:a.libraryItems)||[],"published"))}catch(a){s(a)}});return r?_o.queue.push(i):i()}getLibraryItems(t){return _o.getLibraryItems(this.adapter,t,!1)}};M(_o,"queue",new Wj),M(_o,"run",async(t,n)=>{const r=new _o(t);return _o.queue.push(()=>n(r))});let Dl=_o,zu=0,t1=0;const vy=e=>Qz(e.map(t=>`${t.id}:${qz(t.elements)}`).sort().join()),c4=async(e,t)=>{try{return t1++,await Dl.run(e,async n=>{const r=be(await n.getLibraryItems("save"));for(const[a]of t.deletedItems)r.delete(a);const i=[];for(const[a,l]of t.addedItems)r.has(a)?r.set(a,l):i.push(l);const o=i.concat(Array.from(r.values())),s=vy(o);return s!==zu&&await e.save({libraryItems:o}),zu=s,o})}finally{t1--}},Yj=e=>{const{excalidrawAPI:t}=e,n=_.useRef(e);n.current=e;const r=_.useRef(!1);_.useEffect(()=>{if(!t)return;r.current=!1;const i=async({libraryUrl:a,idToken:l})=>{const c=new Promise(async(d,h)=>{try{const g=await(await fetch(decodeURIComponent(a))).blob();d(g)}catch(m){h(m)}}),u=l!==t.id;await(u&&document.hidden?new Promise(d=>{window.addEventListener("focus",()=>d(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:c,prompt:u,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(d){throw d}finally{if(window.location.hash.includes(p2.addLibrary)){const d=new URLSearchParams(window.location.hash.slice(1));d.delete(p2.addLibrary),window.history.replaceState({},Vi,`#${d.toString()}`)}else if(window.location.search.includes(g2.addLibrary)){const d=new URLSearchParams(window.location.search);d.delete(g2.addLibrary),window.history.replaceState({},Vi,`?${d.toString()}`)}}},o=a=>{a.preventDefault();const l=yy();l&&(a.stopImmediatePropagation(),window.history.replaceState({},"",a.oldURL),i(l))},s=yy();if(s&&i(s),"getInitialLibraryItems"in n.current&&n.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(n.current.getInitialLibraryItems()).then(a=>{t.updateLibrary({libraryItems:a,merge:!0})}).catch(a=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${a==null?void 0:a.message}`)})),"adapter"in n.current&&n.current.adapter){const a=n.current.adapter,l=n.current.migrationAdapter,c=$1();l?c.resolve(I2(l.load).then(async u=>{let d=null;try{if(!u)return Dl.getLibraryItems(a,"load");d=q1(u.libraryItems||[],"published");const h=await c4(a,r7([],d));try{await l.clear()}catch(m){console.error(`couldn't delete legacy library data: ${m.message}`)}return h}catch(h){return console.error(`couldn't migrate legacy library data: ${h.message}`),d}}).catch(u=>(console.error(`error during library migration: ${u.message}`),Dl.getLibraryItems(a,"load")))):c.resolve(I2(Dl.getLibraryItems,a,"load")),t.updateLibrary({libraryItems:c.then(u=>{const d=u||[];return zu=vy(d),d}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(Z.HASHCHANGE,o),()=>{window.removeEventListener(Z.HASHCHANGE,o)}},[t]),_.useEffect(()=>{const i=n7.on(async(s,a)=>{const l=r.current,c="adapter"in n.current&&n.current.adapter||null;try{c&&zu!==vy(a)&&await c4(c,s)}catch(u){console.error(`couldn't persist library update: ${u.message}`,s),l&&n.current.excalidrawAPI&&n.current.excalidrawAPI.updateScene({appState:{errorMessage:b("errors.saveLibraryError")}})}}),o=s=>{t1&&Xv(s)};return window.addEventListener(Z.BEFORE_UNLOAD,o),()=>{window.removeEventListener(Z.BEFORE_UNLOAD,o),i(),zu=0,t1=0}},[])},u4=e=>{const t=Array.from(e.values());return{x:h4(t,n=>n.x)/t.length,y:h4(t,n=>n.y)/t.length}},d4=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),h4=(e,t)=>e.reduce((n,r)=>n+t(r),0),Kj=e=>({selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,viewBackgroundColor:e.viewBackgroundColor,editingLinearElement:e.editingLinearElement,editingGroupId:e.editingGroupId,name:e.name});class Zj{constructor(){M(this,"elementCache",new Map);M(this,"recording",!0);M(this,"stateHistory",[]);M(this,"redoStack",[]);M(this,"lastEntry",null);M(this,"generateEntry",(t,n)=>this.dehydrateHistoryEntry({appState:Kj(t),elements:n.reduce((r,i)=>{if(we(i)&&t.multiElement&&t.multiElement.id===i.id){if(t.multiElement&&t.multiElement.id===i.id&&i.points.length<2)return r;r.push({...i,points:i.lastCommittedPoint!==i.points[i.points.length-1]?i.points.slice(0,-1):i.points})}else r.push(i);return r},[])}))}hydrateHistoryEntry({appState:t,elements:n}){return{appState:JSON.parse(t),elements:n.map(r=>{var o;const i=(o=this.elementCache.get(r.id))==null?void 0:o.get(r.versionNonce);if(!i)throw new Error(`Element not found: ${r.id}:${r.versionNonce}`);return i})}}dehydrateHistoryEntry({appState:t,elements:n}){return{appState:JSON.stringify(t),elements:n.map(r=>{this.elementCache.has(r.id)||this.elementCache.set(r.id,new Map);const i=this.elementCache.get(r.id);return i.has(r.versionNonce)||i.set(r.versionNonce,th(r)),{id:r.id,versionNonce:r.versionNonce}})}}getSnapshotForTest(){return{recording:this.recording,stateHistory:this.stateHistory.map(t=>this.hydrateHistoryEntry(t)),redoStack:this.redoStack.map(t=>this.hydrateHistoryEntry(t))}}clear(){this.stateHistory.length=0,this.redoStack.length=0,this.lastEntry=null,this.elementCache.clear()}shouldCreateEntry(t){var i,o;const{lastEntry:n}=this;if(!n||t.elements.length!==n.elements.length)return!0;for(let s=t.elements.length-1;s>-1;s--){const a=t.elements[s],l=n.elements[s];if(!a||!l||a.id!==l.id||a.versionNonce!==l.versionNonce)return!0}let r;for(r in t.appState)if(!(r==="editingLinearElement"&&((i=t.appState[r])==null?void 0:i.elementId)===((o=n.appState[r])==null?void 0:o.elementId))&&!(r==="selectedElementIds"||r==="selectedGroupIds")&&t.appState[r]!==n.appState[r])return!0;return!1}pushEntry(t,n){const r=this.generateEntry(t,n),i=this.hydrateHistoryEntry(r);if(i){if(!this.shouldCreateEntry(i))return;this.stateHistory.push(r),this.lastEntry=i,this.clearRedoStack()}}clearRedoStack(){this.redoStack.splice(0,this.redoStack.length)}redoOnce(){if(this.redoStack.length===0)return null;const t=this.redoStack.pop();return t!==void 0?(this.stateHistory.push(t),this.hydrateHistoryEntry(t)):null}undoOnce(){if(this.stateHistory.length===1)return null;const t=this.stateHistory.pop(),n=this.stateHistory[this.stateHistory.length-1];return t!==void 0?(this.redoStack.push(t),this.hydrateHistoryEntry(n)):null}setCurrentState(t,n){this.lastEntry=this.hydrateHistoryEntry(this.generateEntry(t,n))}resumeRecording(){this.recording=!0}record(t,n){this.recording&&(this.pushEntry(t,n),this.recording=!1)}}const o7=[{icon:hH,value:"selection",key:D.V,numericKey:D[1],fillable:!0},{icon:fH,value:"rectangle",key:D.R,numericKey:D[2],fillable:!0},{icon:mH,value:"diamond",key:D.D,numericKey:D[3],fillable:!0},{icon:gH,value:"ellipse",key:D.O,numericKey:D[4],fillable:!0},{icon:pH,value:"arrow",key:D.A,numericKey:D[5],fillable:!0},{icon:yH,value:"line",key:D.L,numericKey:D[6],fillable:!0},{icon:$E,value:"freedraw",key:[D.P,D.X],numericKey:D[7],fillable:!1},{icon:EH,value:"text",key:D.T,numericKey:D[8],fillable:!1},{icon:wH,value:"image",key:null,numericKey:D[9],fillable:!1},{icon:bH,value:"eraser",key:D.E,numericKey:D[0],fillable:!1}],Xj=e=>{const t=o7.find((n,r)=>n.numericKey!=null&&e===n.numericKey.toString()||n.key&&(typeof n.key=="string"?n.key===e:n.key.includes(e)));return(t==null?void 0:t.value)||null},qj={toggleTheme:[K("Shift+Alt+D")],saveScene:[K("CtrlOrCmd+S")],loadScene:[K("CtrlOrCmd+O")],clearCanvas:[K("CtrlOrCmd+Delete")],imageExport:[K("CtrlOrCmd+Shift+E")],cut:[K("CtrlOrCmd+X")],copy:[K("CtrlOrCmd+C")],paste:[K("CtrlOrCmd+V")],copyStyles:[K("CtrlOrCmd+Alt+C")],pasteStyles:[K("CtrlOrCmd+Alt+V")],selectAll:[K("CtrlOrCmd+A")],deleteSelectedElements:[K("Delete")],duplicateSelection:[K("CtrlOrCmd+D"),K(`Alt+${b("helpDialog.drag")}`)],sendBackward:[K("CtrlOrCmd+[")],bringForward:[K("CtrlOrCmd+]")],sendToBack:[K(ki?"CtrlOrCmd+Alt+[":"CtrlOrCmd+Shift+[")],bringToFront:[K(ki?"CtrlOrCmd+Alt+]":"CtrlOrCmd+Shift+]")],copyAsPng:[K("Shift+Alt+C")],copyAsSvg:[],group:[K("CtrlOrCmd+G")],ungroup:[K("CtrlOrCmd+Shift+G")],gridMode:[K("CtrlOrCmd+'")],zenMode:[K("Alt+Z")],objectsSnapMode:[K("Alt+S")],stats:[K("Alt+/")],addToLibrary:[],flipHorizontal:[K("Shift+H")],flipVertical:[K("Shift+V")],viewMode:[K("Alt+R")],hyperlink:[K("CtrlOrCmd+K")],toggleElementLock:[K("CtrlOrCmd+Shift+L")]},_c=e=>{const t=qj[e];return t&&t.length>0?t[0]:""},Ln="separator",Qj=te.memo(({actionManager:e,items:t,top:n,left:r,onClose:i})=>{const o=kw(),s=Ag(),a=t.reduce((l,c)=>(c&&(c===Ln||!c.predicate||c.predicate(s,o,e.app.props,e.app))&&l.push(c),l),[]);return f(B8,{onCloseRequest:()=>{i()},top:n,left:r,fitInViewport:!0,offsetLeft:o.offsetLeft,offsetTop:o.offsetTop,viewportWidth:o.width,viewportHeight:o.height,children:f("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:a.map((l,c)=>{var h;if(l===Ln)return!a[c-1]||a[c-1]===Ln?null:f("hr",{className:"context-menu-item-separator"},c);const u=l.name;let d="";return l.contextItemLabel&&(typeof l.contextItemLabel=="function"?d=b(l.contextItemLabel(s,o,e.app)):d=b(l.contextItemLabel)),f("li",{"data-testid":u,onClick:()=>{i(()=>{e.executeAction(l,"contextMenu")})},children:k("button",{className:se("context-menu-item",{dangerous:u==="deleteSelectedElements",checkmark:(h=l.checked)==null?void 0:h.call(l,o)}),children:[f("div",{className:"context-menu-item__label",children:d}),f("kbd",{className:"context-menu-item__shortcut",children:u?_c(u):""})]})},c)})})})}),Jj=_.forwardRef(({children:e,gap:t,align:n,justifyContent:r,className:i,style:o},s)=>f("div",{className:se("Stack Stack_horizontal",i),style:{"--gap":t,alignItems:n,justifyContent:r,...o},ref:s,children:e})),eY=_.forwardRef(({children:e,gap:t,align:n,justifyContent:r,className:i,style:o},s)=>f("div",{className:se("Stack Stack_vertical",i),style:{"--gap":t,justifyItems:n,justifyContent:r,...o},ref:s,children:e})),gr={Row:Jj,Col:eY},s7=({className:e="",children:t,onToggle:n,title:r,...i})=>{const o=gn(),s=se(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":o.editor.isMobile}).trim();return f("button",{"data-prevent-outside-click":!0,className:s,onClick:n,type:"button","data-testid":"dropdown-menu-button",title:r,...i,children:t})};s7.displayName="DropdownMenuTrigger";const a7=te.createContext({}),l7=(e="",t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${t?"dropdown-menu-item--selected":""}`.trim(),c7=(e,t)=>{const n=_.useContext(a7);return B1(e,r=>{var o;const i=new CustomEvent(Z.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});t==null||t(i),i.defaultPrevented||(o=n.onSelect)==null||o.call(n,i)})},u7=({icon:e,shortcut:t,children:n})=>{const r=gn();return k(re,{children:[f("div",{className:"dropdown-menu-item__icon",children:e}),f("div",{className:"dropdown-menu-item__text",children:n}),t&&!r.editor.isMobile&&f("div",{className:"dropdown-menu-item__shortcut",children:t})]})},ti=({icon:e,onSelect:t,children:n,shortcut:r,className:i,selected:o,...s})=>{const a=c7(s.onClick,t);return f("button",{...s,onClick:a,type:"button",className:l7(i,o),title:s.title??s["aria-label"],children:f(u7,{icon:e,shortcut:r,children:n})})};ti.displayName="DropdownMenuItem";const d7=({children:e})=>f("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",background:"pink",borderRadius:6,fontSize:9,color:"black",fontFamily:"Cascadia, monospace"},children:e});d7.displayName="DropdownMenuItemBadge";ti.Badge=d7;const h7=()=>f("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}});h7.displayName="DropdownMenuSeparator";const f7=({children:e,className:t="",style:n,title:r})=>k("div",{className:`dropdown-menu-group ${t}`,style:n,children:[r&&f("p",{className:"dropdown-menu-group-title",children:r}),e]});f7.displayName="DropdownMenuGroup";const Yr=te.forwardRef(({children:e,padding:t,className:n,style:r},i)=>f("div",{className:se("Island",n),style:{"--padding":t,...r},ref:i,children:e})),m7=({children:e,onClickOutside:t,className:n="",onSelect:r,style:i})=>{const o=gn(),s=_.useRef(null),a=$8({onClickOutside:t});ZE(s,()=>{var c;(c=a.onClickOutside)==null||c.call(a)}),_.useEffect(()=>{const c=u=>{var d;u.key===D.ESCAPE&&(u.stopImmediatePropagation(),(d=a.onClickOutside)==null||d.call(a))};return document.addEventListener(Z.KEYDOWN,c,{capture:!0}),()=>{document.removeEventListener(Z.KEYDOWN,c)}},[a]);const l=se(`dropdown-menu ${n}`,{"dropdown-menu--mobile":o.editor.isMobile}).trim();return f(a7.Provider,{value:{onSelect:r},children:f("div",{ref:s,className:l,style:i,"data-testid":"dropdown-menu",children:o.editor.isMobile?f(gr.Col,{className:"dropdown-menu-container",children:e}):f(Yr,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};m7.displayName="DropdownMenuContent";const Hu=({icon:e,shortcut:t,href:n,children:r,onSelect:i,className:o="",selected:s,...a})=>{const l=c7(a.onClick,i);return f("a",{...a,href:n,target:"_blank",rel:"noreferrer",className:l7(o,s),title:a.title??a["aria-label"],onClick:l,children:f(u7,{icon:e,shortcut:t,children:r})})};Hu.displayName="DropdownMenuItemLink";const tY=({children:e,className:t="",selected:n,...r})=>f("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${n?"dropdown-menu-item--selected":""}`.trim(),children:e}),nY=e=>{const t=te.Children.toArray(e).find(n=>te.isValidElement(n)&&typeof n.type!="string"&&(n==null?void 0:n.type.displayName)&&n.type.displayName==="DropdownMenuTrigger");return t||null},rY=e=>{const t=te.Children.toArray(e).find(n=>te.isValidElement(n)&&typeof n.type!="string"&&(n==null?void 0:n.type.displayName)&&n.type.displayName==="DropdownMenuContent");return t||null},Ie=({children:e,open:t})=>{const n=nY(e),r=rY(e);return k(re,{children:[n,t&&r]})};Ie.Trigger=s7;Ie.Content=m7;Ie.Item=ti;Ie.ItemLink=Hu;Ie.ItemCustom=tY;Ie.Group=f7;Ie.Separator=h7;Ie.displayName="DropdownMenu";var iY={VITE_APP_BACKEND_V2_GET_URL:"https://json.excalidraw.com/api/v2/",VITE_APP_BACKEND_V2_POST_URL:"https://json.excalidraw.com/api/v2/post/",VITE_APP_LIBRARY_URL:"https://libraries.excalidraw.com",VITE_APP_LIBRARY_BACKEND:"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries",VITE_APP_PLUS_LP:"https://plus.excalidraw.com",VITE_APP_PLUS_APP:"https://app.excalidraw.com",VITE_APP_AI_BACKEND:"https://oss-ai.excalidraw.com",VITE_APP_WS_SERVER_URL:"https://oss-collab.excalidraw.com",VITE_APP_FIREBASE_CONFIG:'{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}',VITE_APP_DISABLE_TRACKING:"",VITE_APP_GIT_SHA:"",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const f4=e=>{let t;const n=new Set,r=(l,c)=>{const u=typeof l=="function"?l(t):l;if(!Object.is(u,t)){const d=t;t=c??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(h=>h(t,d))}},i=()=>t,a={setState:r,getState:i,subscribe:l=>(n.add(l),()=>n.delete(l)),destroy:()=>{(iY?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}};return t=e(r,i,a),a},oY=e=>e?f4(e):f4;var g7={exports:{}},p7={},y7={exports:{}},v7={};/**
* @license React
* use-sync-external-store-shim.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Jl=_;function sY(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var aY=typeof Object.is=="function"?Object.is:sY,lY=Jl.useState,cY=Jl.useEffect,uY=Jl.useLayoutEffect,dY=Jl.useDebugValue;function hY(e,t){var n=t(),r=lY({inst:{value:n,getSnapshot:t}}),i=r[0].inst,o=r[1];return uY(function(){i.value=n,i.getSnapshot=t,Xp(i)&&o({inst:i})},[e,n,t]),cY(function(){return Xp(i)&&o({inst:i}),e(function(){Xp(i)&&o({inst:i})})},[e]),dY(n),n}function Xp(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!aY(e,n)}catch{return!0}}function fY(e,t){return t()}var mY=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?fY:hY;v7.useSyncExternalStore=Jl.useSyncExternalStore!==void 0?Jl.useSyncExternalStore:mY;y7.exports=v7;var gY=y7.exports;/**
* @license React
* use-sync-external-store-shim/with-selector.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Tg=_,pY=gY;function yY(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var vY=typeof Object.is=="function"?Object.is:yY,EY=pY.useSyncExternalStore,wY=Tg.useRef,bY=Tg.useEffect,_Y=Tg.useMemo,xY=Tg.useDebugValue;p7.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=wY(null);if(o.current===null){var s={hasValue:!1,value:null};o.current=s}else s=o.current;o=_Y(function(){function l(m){if(!c){if(c=!0,u=m,m=r(m),i!==void 0&&s.hasValue){var g=s.value;if(i(g,m))return d=g}return d=m}if(g=d,vY(u,m))return g;var p=r(m);return i!==void 0&&i(g,p)?g:(u=m,d=p)}var c=!1,u,d,h=n===void 0?null:n;return[function(){return l(t())},h===null?void 0:function(){return l(h())}]},[t,n,r,i]);var a=EY(e,o[0],o[1]);return bY(function(){s.hasValue=!0,s.value=a},[a]),xY(a),a};g7.exports=p7;var SY=g7.exports;const kY=rc(SY);var E7={VITE_APP_BACKEND_V2_GET_URL:"https://json.excalidraw.com/api/v2/",VITE_APP_BACKEND_V2_POST_URL:"https://json.excalidraw.com/api/v2/post/",VITE_APP_LIBRARY_URL:"https://libraries.excalidraw.com",VITE_APP_LIBRARY_BACKEND:"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries",VITE_APP_PLUS_LP:"https://plus.excalidraw.com",VITE_APP_PLUS_APP:"https://app.excalidraw.com",VITE_APP_AI_BACKEND:"https://oss-ai.excalidraw.com",VITE_APP_WS_SERVER_URL:"https://oss-collab.excalidraw.com",VITE_APP_FIREBASE_CONFIG:'{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}',VITE_APP_DISABLE_TRACKING:"",VITE_APP_GIT_SHA:"",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{useDebugValue:IY}=te,{useSyncExternalStoreWithSelector:CY}=kY;let m4=!1;function TY(e,t=e.getState,n){(E7?"production":void 0)!=="production"&&n&&!m4&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),m4=!0);const r=CY(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return IY(r),r}const g4=e=>{(E7?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?oY(e):e,n=(r,i)=>TY(t,r,i);return Object.assign(n,t),n},MY=e=>e?g4(e):g4;var p4,y4;const v4=typeof window<"u"&&((p4=window.document)!=null&&p4.createElement||((y4=window.navigator)==null?void 0:y4.product)==="ReactNative")?te.useLayoutEffect:te.useEffect;function ci(){const e=MY(t=>({current:new Array,version:0,set:t}));return{In:({children:t})=>{const n=e(i=>i.set),r=e(i=>i.version);return v4(()=>{n(i=>({version:i.version+1}))},[]),v4(()=>(n(({current:i})=>({current:[...i,t]})),()=>n(({current:i})=>({current:i.filter(o=>o!==t)}))),[t,r]),null},Out:()=>{const t=e(n=>n.current);return te.createElement(te.Fragment,null,t)}}}const w7=te.createContext(null),Tn=()=>te.useContext(w7),AY=()=>te.useMemo(()=>({MainMenuTunnel:ci(),WelcomeScreenMenuHintTunnel:ci(),WelcomeScreenToolbarHintTunnel:ci(),WelcomeScreenHelpHintTunnel:ci(),WelcomeScreenCenterTunnel:ci(),FooterCenterTunnel:ci(),DefaultSidebarTriggerTunnel:ci(),DefaultSidebarTabTriggersTunnel:ci(),OverwriteConfirmDialogTunnel:ci(),TTDDialogTriggerTunnel:ci(),jotaiScope:Symbol()}),[]),b7=({appState:e,elementsMap:t,renderAction:n})=>{var h;const r=FE(t,e);let i=!1;r.length===2&&(ls(r[0])||ls(r[1]))&&(i=!0);const o=!!e.editingElement,s=gn(),a=document.documentElement.getAttribute("dir")==="rtl",l=gl(e.activeTool.type)&&!Ei(e.currentItemBackgroundColor)||r.some(m=>gl(m.type)&&!Ei(m.backgroundColor)),c=gl(e.activeTool.type)||r.some(m=>gl(m.type)),u=r.length===1||i;let d=((h=r[0])==null?void 0:h.type)||null;for(const m of r)if(m.type!==d){d=null;break}return k("div",{className:"panelColumn",children:[f("div",{children:(M2(e.activeTool.type)&&e.activeTool.type!=="image"&&d!=="image"&&d!=="frame"&&d!=="magicframe"||r.some(m=>M2(m.type)))&&n("changeStrokeColor")}),c&&f("div",{children:n("changeBackgroundColor")}),l&&n("changeFillStyle"),(Mb(e.activeTool.type)||r.some(m=>Mb(m.type)))&&n("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(m=>m.type==="freedraw"))&&n("changeStrokeShape"),(Ab(e.activeTool.type)||r.some(m=>Ab(m.type)))&&k(re,{children:[n("changeStrokeStyle"),n("changeSloppiness")]}),(A2(e.activeTool.type)||r.some(m=>A2(m.type)))&&f(re,{children:n("changeRoundness")}),(e.activeTool.type==="text"||r.some(ce))&&k(re,{children:[n("changeFontSize"),n("changeFontFamily"),(e.activeTool.type==="text"||nN(r,t))&&n("changeTextAlign")]}),tN(r,t)&&n("changeVerticalAlign"),(Lm(e.activeTool.type)||r.some(m=>Lm(m.type)))&&f(re,{children:n("changeArrowhead")}),n("changeOpacity"),k("fieldset",{children:[f("legend",{children:b("labels.layers")}),k("div",{className:"buttonList",children:[n("sendToBack"),n("sendBackward"),n("bringToFront"),n("bringForward")]})]}),r.length>1&&!i&&k("fieldset",{children:[f("legend",{children:b("labels.align")}),k("div",{className:"buttonList",children:[a?k(re,{children:[n("alignRight"),n("alignHorizontallyCentered"),n("alignLeft")]}):k(re,{children:[n("alignLeft"),n("alignHorizontallyCentered"),n("alignRight")]}),r.length>2&&n("distributeHorizontally"),f("div",{style:{flexBasis:"100%",height:0}}),k("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[n("alignTop"),n("alignVerticallyCentered"),n("alignBottom"),r.length>2&&n("distributeVertically")]})]})]}),!o&&r.length>0&&k("fieldset",{children:[f("legend",{children:b("labels.actions")}),k("div",{className:"buttonList",children:[!s.editor.isMobile&&n("duplicateSelection"),!s.editor.isMobile&&n("deleteSelectedElements"),n("group"),n("ungroup"),u&&n("hyperlink")]})]})]})},_7=({activeTool:e,appState:t,app:n,UIOptions:r})=>{const[i,o]=_.useState(!1),s=e.type==="frame",a=e.type==="laser",l=e.type==="embeddable",{TTDDialogTriggerTunnel:c}=Tn();return k(re,{children:[o7.map(({value:u,icon:d,key:h,numericKey:m,fillable:g},p)=>{var w;if(((w=r.tools)==null?void 0:w[u])===!1)return null;const v=b(`toolBar.${u}`),y=h&&Mf(typeof h=="string"?h:h[0]),E=y?`${y} ${b("helpDialog.or")} ${m}`:`${m}`;return f(Ce,{className:se("Shape",{fillable:g}),type:"radio",icon:d,checked:e.type===u,name:"editor-current-shape",title:`${Mf(v)} — ${E}`,keyBindingLabel:m||y,"aria-label":Mf(v),"aria-keyshortcuts":E,"data-testid":`toolbar-${u}`,onPointerDown:({pointerType:x})=>{!t.penDetected&&x==="pen"&&n.togglePenMode(!0)},onChange:({pointerType:x})=>{t.activeTool.type!==u&&Ae("toolbar",u,"ui"),u==="image"?n.setActiveTool({type:u,insertOnCanvasDirectly:x!=="mouse"}):n.setActiveTool({type:u})}},u)}),f("div",{className:"App-toolbar__divider"}),k(Ie,{open:i,children:[k(Ie.Trigger,{className:se("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":s||l||a&&!n.props.isCollaborating}),onToggle:()=>o(!i),title:b("toolBar.extraTools"),children:[GU,n.props.aiEnabled!==!1&&f("div",{style:{display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:8,fontFamily:"Cascadia, monospace",position:"absolute",background:"pink",color:"black",bottom:3,right:4},children:"AI"})]}),k(Ie.Content,{onClickOutside:()=>o(!1),onSelect:()=>o(!1),className:"App-toolbar__extra-tools-dropdown",children:[f(Ie.Item,{onSelect:()=>n.setActiveTool({type:"frame"}),icon:jU,shortcut:D.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:s,children:b("toolBar.frame")}),f(Ie.Item,{onSelect:()=>n.setActiveTool({type:"embeddable"}),icon:SH,"data-testid":"toolbar-embeddable",selected:l,children:b("toolBar.embeddable")}),f(Ie.Item,{onSelect:()=>n.setActiveTool({type:"laser"}),icon:QT,"data-testid":"toolbar-laser",selected:a,shortcut:D.K.toLocaleUpperCase(),children:b("toolBar.laser")}),f("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),n.props.aiEnabled!==!1&&f(c.Out,{}),f(Ie.Item,{onSelect:()=>n.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:YU,"data-testid":"toolbar-embeddable",children:b("toolBar.mermaidToExcalidraw")}),n.props.aiEnabled!==!1&&k(re,{children:[k(Ie.Item,{onSelect:()=>n.onMagicframeToolSelect(),icon:UE,"data-testid":"toolbar-magicframe",children:[b("toolBar.magicframe"),f(Ie.Item.Badge,{children:"AI"})]}),f(Ie.Item,{onSelect:()=>{Ae("ai","open-settings","d2c"),n.setOpenDialog({name:"settings",source:"settings",tab:"diagram-to-code"})},icon:ny,"data-testid":"toolbar-magicSettings",children:b("toolBar.magicSettings")})]})]})]})]})},LY=({renderAction:e,zoom:t})=>f(gr.Col,{gap:1,className:"zoom-actions",children:k(gr.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),PY=({renderAction:e,className:t})=>k("div",{className:`undo-redo-buttons ${t}`,children:[f("div",{className:"undo-button-container",children:f(ro,{label:b("buttons.undo"),children:e("undo")})}),f("div",{className:"redo-button-container",children:k(ro,{label:b("buttons.redo"),children:[" ",e("redo")]})})]}),RY=({actionManager:e,showExitZenModeBtn:t})=>f("button",{className:se("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(my),children:b("buttons.exitZenMode")}),DY=({renderAction:e,className:t})=>f("div",{className:`finalize-button ${t}`,children:e("finalize",{size:"small"})}),OY=function({onChange:e,value:t,choices:n,name:r}){return f("div",{className:"RadioGroup",children:n.map(i=>k("div",{className:se("RadioGroup__choice",{active:i.value===t}),children:[f("input",{name:r,type:"radio",checked:i.value===t,onChange:()=>e(i.value)}),i.label]},i.label))})},nf=({title:e,name:t,checked:n,onChange:r,disabled:i=!1})=>f("div",{className:se("Switch",{toggled:n,disabled:i}),children:f("input",{name:t,id:t,title:e,type:"checkbox",checked:n,disabled:i,onChange:()=>r(!n),onKeyDown:o=>{o.key===" "&&r(!n)}})}),zn=_.forwardRef(({children:e,icon:t,onClick:n,label:r,variant:i="filled",color:o="primary",size:s="medium",fullWidth:a,className:l},c)=>{const[u,d]=_.useState(!1),h=async m=>{const g=n==null?void 0:n(m);if(Xd(g))try{d(!0),await g}catch(p){if(p instanceof ql)console.warn(p);else throw p}finally{d(!1)}};return f("button",{className:se("ExcButton",`ExcButton--color-${o}`,`ExcButton--variant-${i}`,`ExcButton--size-${s}`,{"ExcButton--fullWidth":a},l),onClick:h,type:"button","aria-label":r,ref:c,disabled:u,children:k("div",{className:"ExcButton__contents",children:[u&&f(to,{}),t&&f("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),i!=="icon"&&(e??r)]})})}),NY="filter"in document.createElement("canvas").getContext("2d"),FY=()=>k("div",{children:[f("h3",{children:b("canvasError.cannotShowPreview")}),f("p",{children:f("span",{children:b("canvasError.canvasTooBig")})}),k("em",{children:["(",b("canvasError.canvasTooBigTip"),")"]})]}),$Y=({appStateSnapshot:e,elementsSnapshot:t,files:n,actionManager:r,onExportImage:i,name:o})=>{const s=Lt(t,e),[a,l]=_.useState(o),[c,u]=_.useState(s),[d,h]=_.useState(e.exportBackground),[m,g]=_.useState(e.exportWithDarkMode),[p,v]=_.useState(e.exportEmbedScene),[y,E]=_.useState(e.exportScale),w=_.useRef(null),[x,C]=_.useState(null),{exportedElements:S,exportingFrame:I}=Sg(t,e,c);return _.useEffect(()=>{const T=w.current;if(!T)return;const L=T.offsetWidth,A=T.offsetHeight;L&&og({elements:S,appState:{...e,name:a,exportBackground:d,exportWithDarkMode:m,exportScale:y,exportEmbedScene:p},files:n,exportPadding:ac,maxWidthOrHeight:Math.max(L,A),exportingFrame:I}).then(F=>(C(null),_d(F).then(()=>{T.replaceChildren(F)}).catch(P=>{throw P.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):P}))).catch(F=>{console.error(F),C(F)})},[e,n,S,I,a,d,m,y,p]),k("div",{className:"ImageExportModal",children:[f("h3",{children:b("imageExportDialog.header")}),k("div",{className:"ImageExportModal__preview",children:[f("div",{className:"ImageExportModal__preview__canvas",ref:w,children:x&&f(FY,{})}),f("div",{className:"ImageExportModal__preview__filename",children:!Da&&f("input",{type:"text",className:"TextInput",value:a,style:{width:"30ch"},onChange:T=>{l(T.target.value),r.executeAction(rj,"ui",T.target.value)}})})]}),k("div",{className:"ImageExportModal__settings",children:[f("h3",{children:b("imageExportDialog.header")}),s&&f(Yc,{label:b("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:f(nf,{name:"exportOnlySelected",checked:c,onChange:T=>{u(T)}})}),f(Yc,{label:b("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:f(nf,{name:"exportBackgroundSwitch",checked:d,onChange:T=>{h(T),r.executeAction(oj,"ui",T)}})}),NY&&f(Yc,{label:b("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:f(nf,{name:"exportDarkModeSwitch",checked:m,onChange:T=>{g(T),r.executeAction(sj,"ui",T)}})}),f(Yc,{label:b("imageExportDialog.label.embedScene"),tooltip:b("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:f(nf,{name:"exportEmbedSwitch",checked:p,onChange:T=>{v(T),r.executeAction(V8,"ui",T)}})}),f(Yc,{label:b("imageExportDialog.label.scale"),name:"exportScale",children:f(OY,{name:"exportScale",value:y,onChange:T=>{E(T),r.executeAction(ij,"ui",T)},choices:Bv.map(T=>({value:T,label:`${T}×`}))})}),k("div",{className:"ImageExportModal__settings__buttons",children:[f(zn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.exportToPng"),onClick:()=>i(lp.png,S,{exportingFrame:I}),icon:y6,children:b("imageExportDialog.button.exportToPng")}),f(zn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.exportToSvg"),onClick:()=>i(lp.svg,S,{exportingFrame:I}),icon:y6,children:b("imageExportDialog.button.exportToSvg")}),(AE||R1)&&f(zn,{className:"ImageExportModal__settings__buttons__button",label:b("imageExportDialog.title.copyPngToClipboard"),onClick:()=>i(lp.clipboard,S,{exportingFrame:I}),icon:hg,children:b("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Yc=({label:e,children:t,tooltip:n,name:r})=>k("div",{className:"ImageExportModal__settings__setting",title:e,children:[k("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,n&&f(ro,{label:n,long:!0,children:zU})]}),f("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),BY=({elements:e,appState:t,files:n,actionManager:r,onExportImage:i,onCloseRequest:o,name:s})=>{const[{appStateSnapshot:a,elementsSnapshot:l}]=_.useState(()=>({appStateSnapshot:Yl(t),elementsSnapshot:Yl(e)}));return f(Vn,{onCloseRequest:o,size:"wide",title:!1,children:f($Y,{elementsSnapshot:l,appStateSnapshot:a,files:n,actionManager:r,onExportImage:i,name:s})})},x7=({children:e,side:t,className:n})=>f("div",{className:se("FixedSideContainer",`FixedSideContainer_side_${t}`,n),children:e}),zY=({appState:e,isMobile:t,device:n,app:r})=>{var u;const{activeTool:i,isResizing:o,isRotating:s,lastPointerDownWith:a}=e,l=e.multiElement!==null;if(e.openSidebar&&!n.editor.canFitSidebar)return null;if(mi(e))return b("hints.eraserRevert");if(i.type==="arrow"||i.type==="line")return b(l?"hints.linearElementMulti":"hints.linearElement");if(i.type==="freedraw")return b("hints.freeDraw");if(i.type==="text")return b("hints.text");if(i.type==="embeddable")return b("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return b("hints.placeImage");const c=r.scene.getSelectedElements(e);if(o&&a==="mouse"&&c.length===1){const d=c[0];return we(d)&&d.points.length===2?b("hints.lockAngle"):Gi(d)?b("hints.resizeImage"):b("hints.resize")}if(s&&a==="mouse")return b("hints.rotate");if(c.length===1&&ce(c[0]))return b("hints.text_selected");if(e.editingElement&&ce(e.editingElement))return b("hints.text_editing");if(i.type==="selection"){if(((u=e.draggingElement)==null?void 0:u.type)==="selection"&&!c.length&&!e.editingElement&&!e.editingLinearElement)return b("hints.deepBoxSelect");if(e.gridSize&&e.draggingElement)return b("hints.disableSnapping");if(!c.length&&!t)return b("hints.canvasPanning");if(c.length===1){if(we(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?b("hints.lineEditor_pointSelected"):b("hints.lineEditor_nothingSelected"):b("hints.lineEditor_info");if(!e.draggingElement&&ia(c[0]))return b("hints.bindTextToElement")}}return null},S7=({appState:e,isMobile:t,device:n,app:r})=>{let i=zY({appState:e,isMobile:t,device:n,app:r});return i?(i=K(i),f("div",{className:"HintViewer",children:f("span",{children:i})})):null},k7=({delay:e,theme:t})=>{const[n,r]=_.useState(!!e);return _.useEffect(()=>{if(!e)return;const i=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(i)},[e]),n?null:k("div",{className:se("LoadingMessage",{"LoadingMessage--dark":t===Tt.DARK}),children:[f("div",{children:f(to,{})}),f("div",{className:"LoadingMessage-text",children:b("labels.loadingScene")})]})},HY="medium",E4={CHECKED:lH,UNCHECKED:aH},I7=e=>k("label",{className:se("ToolIcon ToolIcon__lock",`ToolIcon_size_${HY}`,{"is-mobile":e.isMobile}),title:`${e.title} — Q`,children:[f("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),f("div",{className:"ToolIcon__icon",children:e.checked?E4.CHECKED:E4.UNCHECKED})]}),Nd=({heading:e,children:t,...n})=>{const{id:r}=uo(),i=f("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:b(`headings.${e}`)});return f("section",{...n,"aria-labelledby":`${r}-${e}-title`,children:typeof t=="function"?t(i):k(re,{children:[i,t]})})},gi=4,Ho=6,UY="rgba(0,0,0,0.3)",WY=(e,t,n,r)=>{if(!e.length)return{horizontal:null,vertical:null};const[i,o,s,a]=nt(e),l=t/r.zoom.value,c=n/r.zoom.value,u=t-l,d=n-c,h={top:parseInt(zh("sat"))||0,bottom:parseInt(zh("sab"))||0,left:parseInt(zh("sal"))||0,right:parseInt(zh("sar"))||0},m=Yd().rtl,g=-r.scrollX+u/2+h.left,p=-r.scrollY+d/2+h.top,v=g+l-h.right,y=p+c-h.bottom,E=Math.min(i,g),w=Math.min(o,p),x=Math.max(s,v),C=Math.max(a,y);return{horizontal:g===E&&v===x?null:{x:Math.max(h.left,gi)+(g-E)/(x-E)*t,y:n-Ho-Math.max(gi,h.bottom),width:(v-g)/(x-E)*t-Math.max(gi*2,h.left+h.right),height:Ho},vertical:p===w&&y===C?null:{x:m?Math.max(h.left,gi):t-Ho-Math.max(h.right,gi),y:(p-w)/(C-w)*n+Math.max(h.top,gi),width:Ho,height:(y-p)/(C-w)*n-Math.max(gi*2,h.top+h.bottom)}}},w4=(e,t,n)=>{const[r,i]=[e.horizontal,e.vertical].map(s=>s!=null&&s.x<=t&&t<=s.x+s.width&&s.y<=n&&n<=s.y+s.height);return{isOverEither:r||i,isOverHorizontal:r,isOverVertical:i}},VY="medium",C7=e=>e.penDetected?k("label",{className:se("ToolIcon ToolIcon__penMode",`ToolIcon_size_${VY}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[f("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),f("div",{className:"ToolIcon__icon",children:vH})]}):null,T7=e=>{var i;const t=nt(e.elements),n=FE(e.elements,e.appState),r=nt(n);return f("div",{className:"Stats",children:k(Yr,{padding:2,children:[f("div",{className:"close",onClick:e.onClose,children:yc}),f("h3",{children:b("stats.title")}),f("table",{children:k("tbody",{children:[f("tr",{children:f("th",{colSpan:2,children:b("stats.scene")})}),k("tr",{children:[f("td",{children:b("stats.elements")}),f("td",{children:e.elements.length})]}),k("tr",{children:[f("td",{children:b("stats.width")}),f("td",{children:Math.round(t[2])-Math.round(t[0])})]}),k("tr",{children:[f("td",{children:b("stats.height")}),f("td",{children:Math.round(t[3])-Math.round(t[1])})]}),n.length===1&&f("tr",{children:f("th",{colSpan:2,children:b("stats.element")})}),n.length>1&&k(re,{children:[f("tr",{children:f("th",{colSpan:2,children:b("stats.selected")})}),k("tr",{children:[f("td",{children:b("stats.elements")}),f("td",{children:n.length})]})]}),n.length>0&&k(re,{children:[k("tr",{children:[f("td",{children:"x"}),f("td",{children:Math.round(r[0])})]}),k("tr",{children:[f("td",{children:"y"}),f("td",{children:Math.round(r[1])})]}),k("tr",{children:[f("td",{children:b("stats.width")}),f("td",{children:Math.round(r[2]-r[0])})]}),k("tr",{children:[f("td",{children:b("stats.height")}),f("td",{children:Math.round(r[3]-r[1])})]})]}),n.length===1&&k("tr",{children:[f("td",{children:b("stats.angle")}),f("td",{children:`${Math.round(n[0].angle*180/Math.PI)}°`})]}),(i=e.renderCustomStats)==null?void 0:i.call(e,e.elements,e.appState)]})})]})})},M7=e=>f(Ce,{className:se("Shape",{fillable:!1}),type:"radio",icon:BU,name:"editor-current-shape",checked:e.checked,title:`${e.title} — H`,keyBindingLabel:e.isMobile?void 0:D.H.toLocaleUpperCase(),"aria-label":`${e.title} — H`,"aria-keyshortcuts":D.H,"data-testid":"toolbar-hand",onChange:()=>{var t;return(t=e.onChange)==null?void 0:t.call(e)}}),GY=({appState:e,elements:t,actionManager:n,setAppState:r,onLockToggle:i,onHandToolToggle:o,onPenModeToggle:s,renderTopRightUI:a,renderCustomStats:l,renderSidebars:c,device:u,renderWelcomeScreen:d,UIOptions:h,app:m})=>{const{WelcomeScreenCenterTunnel:g,MainMenuTunnel:p,DefaultSidebarTriggerTunnel:v}=Tn(),y=()=>k(x7,{side:"top",className:"App-top-bar",children:[d&&f(g.Out,{}),f(Nd,{heading:"shapes",children:w=>f(gr.Col,{gap:4,align:"center",children:k(gr.Row,{gap:1,className:"App-toolbar-container",children:[k(Yr,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[w,f(gr.Row,{gap:1,children:f(_7,{appState:e,activeTool:e.activeTool,UIOptions:h,app:m})})]}),a&&a(!0,e),k("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&f(v.Out,{}),f(C7,{checked:e.penMode,onChange:()=>s(null),title:b("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),f(I7,{checked:e.activeTool.locked,onChange:i,title:b("toolBar.lock"),isMobile:!0}),f(M7,{checked:Vl(e),onChange:()=>o(),title:b("toolBar.hand"),isMobile:!0})]})]})})}),f(S7,{appState:e,isMobile:!0,device:u,app:m})]}),E=()=>e.viewModeEnabled?f("div",{className:"App-toolbar-content",children:f(p.Out,{})}):k("div",{className:"App-toolbar-content",children:[f(p.Out,{}),n.renderAction("toggleEditMenu"),n.renderAction("undo"),n.renderAction("redo"),n.renderAction(e.multiElement?"finalize":"duplicateSelection"),n.renderAction("deleteSelectedElements")]});return k(re,{children:[c(),!e.viewModeEnabled&&y(),!e.openMenu&&e.showStats&&f(T7,{appState:e,setAppState:r,elements:t,onClose:()=>{n.executeAction(e1)},renderCustomStats:l}),f("div",{className:"App-bottom-bar",style:{marginBottom:Ho+gi*2,marginLeft:Ho+gi*2,marginRight:Ho+gi*2},children:k(Yr,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&DE(e,t)?f(Nd,{className:"App-mobile-menu",heading:"selectedShapeActions",children:f(b7,{appState:e,elementsMap:m.scene.getNonDeletedElementsMap(),renderAction:n.renderAction})}):null,k("footer",{className:"App-toolbar",children:[E(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&f("button",{className:"scroll-back-to-content",onClick:()=>{r(w=>({...Ld(t,w)}))},children:b("buttons.scrollBackToContent")})]})]})})]})},b4=e=>{const t=_.useRef(null),[n,r]=_.useState(null);return _.useLayoutEffect(()=>{if(!e.spreadsheet)return;const i=iz(e.chartType,e.spreadsheet,0,0);r(i);let o;const s=t.current;return(async()=>{var a;o=await vE(i,{exportBackground:!1,viewBackgroundColor:Ut.white},null),(a=o.querySelector(".style-fonts"))==null||a.remove(),s.replaceChildren(),s.appendChild(o),e.selected&&s.parentNode.focus()})(),()=>{s.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),f("button",{className:"ChartPreview",onClick:()=>{n&&e.onClick(e.chartType,n)},children:f("div",{ref:t})})},jY=({setAppState:e,appState:t,onClose:n})=>{const{onInsertElements:r}=xc(),i=te.useCallback(()=>{n&&n()},[n]),o=(s,a)=>{r(a),Ae("paste","chart",s),e({currentChartType:s,pasteDialog:{shown:!1,data:null}})};return f(Vn,{size:"small",onCloseRequest:i,title:b("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:k("div",{className:"container",children:[f(b4,{chartType:"bar",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="bar",onClick:o}),f(b4,{chartType:"line",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="line",onClick:o})]})})},YY=()=>k("div",{className:"HelpDialog__header",children:[k("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[b("helpDialog.documentation"),f("div",{className:"HelpDialog__link-icon",children:Hp})]}),k("a",{className:"HelpDialog__btn",href:"https://blog.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[b("helpDialog.blog"),f("div",{className:"HelpDialog__link-icon",children:Hp})]}),k("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[b("helpDialog.github"),f("div",{className:"HelpDialog__link-icon",children:Hp})]})]}),KY=e=>k(re,{children:[f("h3",{children:e.title}),f("div",{className:"HelpDialog__islands-container",children:e.children})]}),qp=e=>k("div",{className:`HelpDialog__island ${e.className}`,children:[f("h4",{className:"HelpDialog__island-title",children:e.caption}),f("div",{className:"HelpDialog__island-content",children:e.children})]});function*ZY(e,t){let n=!0;for(const r of e)n||(yield t),n=!1,yield r}const XY=e=>e.replace(/\b[a-z]\b/,t=>t.toUpperCase()),oe=({label:e,shortcuts:t,isOr:n=!0})=>{const r=t.map(i=>(i.endsWith("++")?[...i.slice(0,-2).split("+"),"+"]:i.split("+")).map(s=>f(qY,{children:XY(s)},s)));return k("div",{className:"HelpDialog__shortcut",children:[f("div",{children:e}),f("div",{className:"HelpDialog__key-container",children:[...ZY(r,n?b("helpDialog.or"):null)]})]})},qY=e=>f("kbd",{className:"HelpDialog__key",...e}),QY=({onClose:e})=>{const t=te.useCallback(()=>{e&&e()},[e]);return f(re,{children:k(Vn,{onCloseRequest:t,title:b("helpDialog.title"),className:"HelpDialog",children:[f(YY,{}),k(KY,{title:b("helpDialog.shortcuts"),children:[k(qp,{className:"HelpDialog__island--tools",caption:b("helpDialog.tools"),children:[f(oe,{label:b("toolBar.hand"),shortcuts:[D.H]}),f(oe,{label:b("toolBar.selection"),shortcuts:[D.V,D[1]]}),f(oe,{label:b("toolBar.rectangle"),shortcuts:[D.R,D[2]]}),f(oe,{label:b("toolBar.diamond"),shortcuts:[D.D,D[3]]}),f(oe,{label:b("toolBar.ellipse"),shortcuts:[D.O,D[4]]}),f(oe,{label:b("toolBar.arrow"),shortcuts:[D.A,D[5]]}),f(oe,{label:b("toolBar.line"),shortcuts:[D.L,D[6]]}),f(oe,{label:b("toolBar.freedraw"),shortcuts:[D.P,D[7]]}),f(oe,{label:b("toolBar.text"),shortcuts:[D.T,D[8]]}),f(oe,{label:b("toolBar.image"),shortcuts:[D[9]]}),f(oe,{label:b("toolBar.eraser"),shortcuts:[D.E,D[0]]}),f(oe,{label:b("toolBar.frame"),shortcuts:[D.F]}),f(oe,{label:b("toolBar.laser"),shortcuts:[D.K]}),f(oe,{label:b("labels.eyeDropper"),shortcuts:[D.I,"Shift+S","Shift+G"]}),f(oe,{label:b("helpDialog.editLineArrowPoints"),shortcuts:[K("CtrlOrCmd+Enter")]}),f(oe,{label:b("helpDialog.editText"),shortcuts:[K("Enter")]}),f(oe,{label:b("helpDialog.textNewLine"),shortcuts:[K("Enter"),K("Shift+Enter")]}),f(oe,{label:b("helpDialog.textFinish"),shortcuts:[K("Esc"),K("CtrlOrCmd+Enter")]}),f(oe,{label:b("helpDialog.curvedArrow"),shortcuts:["A",b("helpDialog.click"),b("helpDialog.click"),b("helpDialog.click")],isOr:!1}),f(oe,{label:b("helpDialog.curvedLine"),shortcuts:["L",b("helpDialog.click"),b("helpDialog.click"),b("helpDialog.click")],isOr:!1}),f(oe,{label:b("toolBar.lock"),shortcuts:[D.Q]}),f(oe,{label:b("helpDialog.preventBinding"),shortcuts:[K("CtrlOrCmd")]}),f(oe,{label:b("toolBar.link"),shortcuts:[K("CtrlOrCmd+K")]})]}),k(qp,{className:"HelpDialog__island--view",caption:b("helpDialog.view"),children:[f(oe,{label:b("buttons.zoomIn"),shortcuts:[K("CtrlOrCmd++")]}),f(oe,{label:b("buttons.zoomOut"),shortcuts:[K("CtrlOrCmd+-")]}),f(oe,{label:b("buttons.resetZoom"),shortcuts:[K("CtrlOrCmd+0")]}),f(oe,{label:b("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),f(oe,{label:b("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),f(oe,{label:b("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),f(oe,{label:b("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),f(oe,{label:b("buttons.zenMode"),shortcuts:[K("Alt+Z")]}),f(oe,{label:b("buttons.objectsSnapMode"),shortcuts:[K("Alt+S")]}),f(oe,{label:b("labels.showGrid"),shortcuts:[K("CtrlOrCmd+'")]}),f(oe,{label:b("labels.viewMode"),shortcuts:[K("Alt+R")]}),f(oe,{label:b("labels.toggleTheme"),shortcuts:[K("Alt+Shift+D")]}),f(oe,{label:b("stats.title"),shortcuts:[K("Alt+/")]})]}),k(qp,{className:"HelpDialog__island--editor",caption:b("helpDialog.editor"),children:[f(oe,{label:b("labels.moveCanvas"),shortcuts:[K(`Space+${b("helpDialog.drag")}`),K(`Wheel+${b("helpDialog.drag")}`)],isOr:!0}),f(oe,{label:b("buttons.clearReset"),shortcuts:[K("CtrlOrCmd+Delete")]}),f(oe,{label:b("labels.delete"),shortcuts:[K("Delete")]}),f(oe,{label:b("labels.cut"),shortcuts:[K("CtrlOrCmd+X")]}),f(oe,{label:b("labels.copy"),shortcuts:[K("CtrlOrCmd+C")]}),f(oe,{label:b("labels.paste"),shortcuts:[K("CtrlOrCmd+V")]}),f(oe,{label:b("labels.pasteAsPlaintext"),shortcuts:[K("CtrlOrCmd+Shift+V")]}),f(oe,{label:b("labels.selectAll"),shortcuts:[K("CtrlOrCmd+A")]}),f(oe,{label:b("labels.multiSelect"),shortcuts:[K(`Shift+${b("helpDialog.click")}`)]}),f(oe,{label:b("helpDialog.deepSelect"),shortcuts:[K(`CtrlOrCmd+${b("helpDialog.click")}`)]}),f(oe,{label:b("helpDialog.deepBoxSelect"),shortcuts:[K(`CtrlOrCmd+${b("helpDialog.drag")}`)]}),(AE||R1)&&f(oe,{label:b("labels.copyAsPng"),shortcuts:[K("Shift+Alt+C")]}),f(oe,{label:b("labels.copyStyles"),shortcuts:[K("CtrlOrCmd+Alt+C")]}),f(oe,{label:b("labels.pasteStyles"),shortcuts:[K("CtrlOrCmd+Alt+V")]}),f(oe,{label:b("labels.sendToBack"),shortcuts:[K(ki?"CtrlOrCmd+Alt+[":"CtrlOrCmd+Shift+[")]}),f(oe,{label:b("labels.bringToFront"),shortcuts:[K(ki?"CtrlOrCmd+Alt+]":"CtrlOrCmd+Shift+]")]}),f(oe,{label:b("labels.sendBackward"),shortcuts:[K("CtrlOrCmd+[")]}),f(oe,{label:b("labels.bringForward"),shortcuts:[K("CtrlOrCmd+]")]}),f(oe,{label:b("labels.alignTop"),shortcuts:[K("CtrlOrCmd+Shift+Up")]}),f(oe,{label:b("labels.alignBottom"),shortcuts:[K("CtrlOrCmd+Shift+Down")]}),f(oe,{label:b("labels.alignLeft"),shortcuts:[K("CtrlOrCmd+Shift+Left")]}),f(oe,{label:b("labels.alignRight"),shortcuts:[K("CtrlOrCmd+Shift+Right")]}),f(oe,{label:b("labels.duplicateSelection"),shortcuts:[K("CtrlOrCmd+D"),K(`Alt+${b("helpDialog.drag")}`)]}),f(oe,{label:b("helpDialog.toggleElementLock"),shortcuts:[K("CtrlOrCmd+Shift+L")]}),f(oe,{label:b("buttons.undo"),shortcuts:[K("CtrlOrCmd+Z")]}),f(oe,{label:b("buttons.redo"),shortcuts:BS?[K("CtrlOrCmd+Y"),K("CtrlOrCmd+Shift+Z")]:[K("CtrlOrCmd+Shift+Z")]}),f(oe,{label:b("labels.group"),shortcuts:[K("CtrlOrCmd+G")]}),f(oe,{label:b("labels.ungroup"),shortcuts:[K("CtrlOrCmd+Shift+G")]}),f(oe,{label:b("labels.flipHorizontal"),shortcuts:[K("Shift+H")]}),f(oe,{label:b("labels.flipVertical"),shortcuts:[K("Shift+V")]}),f(oe,{label:b("labels.showStroke"),shortcuts:[K("S")]}),f(oe,{label:b("labels.showBackground"),shortcuts:[K("G")]}),f(oe,{label:b("labels.decreaseFontSize"),shortcuts:[K("CtrlOrCmd+Shift+<")]}),f(oe,{label:b("labels.increaseFontSize"),shortcuts:[K("CtrlOrCmd+Shift+>")]})]})]})]})})},JY=4,eK=8,tK=({shouldWrap:e,children:t,username:n})=>e?f(ro,{label:n||"Unknown user",children:t}):f(te.Fragment,{children:t}),Qp=({actionManager:e,collaborator:t,socketId:n,withName:r=!1,shouldWrapWithTooltip:i=!1,isBeingFollowed:o})=>{const s={socketId:n,collaborator:t,withName:r,isBeingFollowed:o},a=e.renderAction("goToCollaborator",s);return f(tK,{username:t.username,shouldWrap:i,children:a},n)},nK=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],A7=te.memo(({className:e,mobile:t,collaborators:n,userToFollow:r})=>{const i=Cr(),o=new Map;n.forEach((v,y)=>{const E=v.id||y;o.set(E,{...v,socketId:y})});const s=Array.from(o.values()).filter(v=>{var y;return(y=v.username)==null?void 0:y.trim()}),[a,l]=te.useState(""),c=te.useRef(null);_.useLayoutEffect(()=>{if(c.current){const v=E=>{const w=Math.max(1,Math.min(8,Math.floor(E/38)));d(w)};if(v(c.current.clientWidth),!m2)return;const y=new ResizeObserver(E=>{for(const w of E){const{width:x}=w.contentRect;v(x)}});return y.observe(c.current),()=>{y.disconnect()}}},[]);const[u,d]=te.useState(JY),m=a.trim().toLowerCase()?s.filter(v=>{var y;return(y=v.username)==null?void 0:y.toLowerCase().includes(a)}):s,p=s.slice(0,u-1).map(v=>Qp({actionManager:i,collaborator:v,socketId:v.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:v.socketId===r}));return t?f("div",{className:se("UserList UserList_mobile",e),children:s.map(v=>Qp({actionManager:i,collaborator:v,socketId:v.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:v.socketId===r}))}):f("div",{className:"UserList-wrapper",ref:c,children:k("div",{className:se("UserList",e),style:{"--max-avatars":u},children:[p,s.length>u-1&&k(Eg,{onOpenChange:v=>{v||l("")},children:[k(wg,{className:"UserList__more",children:["+",s.length-u+1]}),f(bg,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:k(Yr,{style:{overflow:"hidden"},children:[s.length>=eK&&k("div",{className:"UserList__search-wrapper",children:[qU,f("input",{className:"UserList__search",type:"text",placeholder:b("userList.search.placeholder"),value:a,onChange:v=>{l(v.target.value)}})]}),k("div",{className:"dropdown-menu UserList__collaborators",children:[m.length===0&&f("div",{className:"UserList__collaborators__empty",children:b("userList.search.empty")}),f("div",{className:"UserList__hint",children:b("userList.hint.text")}),m.map(v=>Qp({actionManager:i,collaborator:v,socketId:v.socketId,withName:!0,isBeingFollowed:v.socketId===r}))]})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;const n=t.collaborators.keys();for(const[r,i]of e.collaborators){const o=t.collaborators.get(r);if(!o||r!==n.next().value||!Jn(i,o,nK))return!1}return!0}),Ey=({children:e,color:t})=>f("div",{className:"Card",style:{"--card-color":t==="primary"?"var(--color-primary)":Ut[t][7],"--card-color-darker":t==="primary"?"var(--color-primary-darker)":Ut[t][8],"--card-color-darkest":t==="primary"?"var(--color-primary-darkest)":Ut[t][9]},children:e}),rK=({elements:e,appState:t,setAppState:n,files:r,actionManager:i,exportOpts:o,canvas:s,onCloseRequest:a})=>{const{onExportToBackend:l}=o;return f("div",{className:"ExportDialog ExportDialog--json",children:k("div",{className:"ExportDialog-cards",children:[o.saveFileToDisk&&k(Ey,{color:"lime",children:[f("div",{className:"Card-icon",children:OH}),f("h2",{children:b("exportDialog.disk_title")}),k("div",{className:"Card-details",children:[b("exportDialog.disk_details"),!Da&&i.renderAction("changeProjectName")]}),f(Ce,{className:"Card-button",type:"button",title:b("exportDialog.disk_button"),"aria-label":b("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{i.executeAction(G8,"ui")}})]}),l&&k(Ey,{color:"pink",children:[f("div",{className:"Card-icon",children:zE}),f("h2",{children:b("exportDialog.link_title")}),f("div",{className:"Card-details",children:b("exportDialog.link_details")}),f(Ce,{className:"Card-button",type:"button",title:b("exportDialog.link_button"),"aria-label":b("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ae("export","link",`ui (${Zd()})`),await l(e,t,r),a()}catch(c){n({errorMessage:c.message})}}})]}),o.renderCustomUI&&o.renderCustomUI(e,t,r,s)]})})},iK=({elements:e,appState:t,files:n,actionManager:r,exportOpts:i,canvas:o,setAppState:s})=>{var l;const a=te.useCallback(()=>{s({openDialog:null})},[s]);return f(re,{children:((l=t.openDialog)==null?void 0:l.name)==="jsonExport"&&f(Vn,{onCloseRequest:a,title:b("buttons.export"),children:f(rK,{elements:e,appState:t,setAppState:s,files:n,actionManager:r,onCloseRequest:a,exportOpts:i,canvas:o})})})},oK=e=>f("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${b("helpDialog.title")} — ?`,"aria-label":b("helpDialog.title"),children:BE}),L7=({appState:e,actionManager:t,showExitZenModeBtn:n,renderWelcomeScreen:r})=>{const{FooterCenterTunnel:i,WelcomeScreenHelpHintTunnel:o}=Tn(),s=gn(),a=!e.viewModeEnabled&&e.multiElement&&s.isTouchScreen;return k("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[f("div",{className:se("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:f(gr.Col,{gap:2,children:k(Nd,{heading:"canvasActions",children:[f(LY,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&f(PY,{renderAction:t.renderAction,className:se("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),a&&f(DY,{renderAction:t.renderAction,className:se("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),f(i.Out,{}),f("div",{className:se("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:k("div",{style:{position:"relative"},children:[r&&f(o.Out,{}),f(oK,{onClick:()=>t.executeAction(QE)})]})}),f(RY,{actionManager:t,showExitZenModeBtn:n})]})};L7.displayName="Footer";const P7=te.createContext({}),Fd=({type:e="button",onSelect:t,selected:n,children:r,className:i="",...o})=>f("button",{onClick:B1(o.onClick,s=>{t()}),type:e,className:se("excalidraw-button",i,{selected:n}),...o,children:r}),R7=({children:e,className:t})=>{const n=gn(),r=_.useContext(P7),i=!!(n.editor.canFitSidebar&&r.shouldRenderDockButton);return k("div",{className:se("sidebar__header",t),"data-testid":"sidebar-header",children:[e,k("div",{className:"sidebar__header__buttons",children:[i&&f(ro,{label:b("labels.sidebarLock"),children:f(Fd,{onSelect:()=>{var o;return(o=r.onDock)==null?void 0:o.call(r,!r.docked)},selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":b("labels.sidebarLock"),children:sH})}),f(Fd,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":b("buttons.close"),children:yc})]})]})};R7.displayName="SidebarHeader";const D7=({name:e,tab:t,icon:n,title:r,children:i,onToggle:o,className:s,style:a})=>{var u;const l=Mn(),c=mn();return k("label",{title:r,className:"sidebar-trigger__label-element",children:[f("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{var m;(m=document.querySelector(".layer-ui__wrapper"))==null||m.classList.remove("animate");const h=d.target.checked;l({openSidebar:h?{name:e,tab:t}:null}),o==null||o(h)},checked:((u=c.openSidebar)==null?void 0:u.name)===e,"aria-label":r,"aria-keyshortcuts":"0"}),k("div",{className:se("sidebar-trigger",s),style:a,children:[n&&f("div",{children:n}),i&&f("div",{className:"sidebar-trigger__label",children:i})]})]})};D7.displayName="SidebarTrigger";function sK(e){const t=e+"CollectionProvider",[n,r]=ah(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=m=>{const{scope:g,children:p}=m,v=te.useRef(null),y=te.useRef(new Map).current;return te.createElement(i,{scope:g,itemMap:y,collectionRef:v},p)},a=e+"CollectionSlot",l=te.forwardRef((m,g)=>{const{scope:p,children:v}=m,y=o(a,p),E=Ci(g,y.collectionRef);return te.createElement(Pd,{ref:E},v)}),c=e+"CollectionItemSlot",u="data-radix-collection-item",d=te.forwardRef((m,g)=>{const{scope:p,children:v,...y}=m,E=te.useRef(null),w=Ci(g,E),x=o(c,p);return te.useEffect(()=>(x.itemMap.set(E,{ref:E,...y}),()=>void x.itemMap.delete(E))),te.createElement(Pd,{[u]:"",ref:w},v)});function h(m){const g=o(e+"CollectionConsumer",m);return te.useCallback(()=>{const v=g.collectionRef.current;if(!v)return[];const y=Array.from(v.querySelectorAll(`[${u}]`));return Array.from(g.itemMap.values()).sort((x,C)=>y.indexOf(x.ref.current)-y.indexOf(C.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:s,Slot:l,ItemSlot:d},h,r]}const aK=_.createContext(void 0);function O7(e){const t=_.useContext(aK);return e||t||"ltr"}const Jp="rovingFocusGroup.onEntryFocus",lK={bubbles:!1,cancelable:!0},ew="RovingFocusGroup",[wy,N7,cK]=sK(ew),[uK,F7]=ah(ew,[cK]),[dK,hK]=uK(ew),fK=_.forwardRef((e,t)=>_.createElement(wy.Provider,{scope:e.__scopeRovingFocusGroup},_.createElement(wy.Slot,{scope:e.__scopeRovingFocusGroup},_.createElement(mK,Ye({},e,{ref:t}))))),mK=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,...u}=e,d=_.useRef(null),h=Ci(t,d),m=O7(o),[g=null,p]=KE({prop:s,defaultProp:a,onChange:l}),[v,y]=_.useState(!1),E=no(c),w=N7(n),x=_.useRef(!1),[C,S]=_.useState(0);return _.useEffect(()=>{const I=d.current;if(I)return I.addEventListener(Jp,E),()=>I.removeEventListener(Jp,E)},[E]),_.createElement(dK,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:g,onItemFocus:_.useCallback(I=>p(I),[p]),onItemShiftTab:_.useCallback(()=>y(!0),[]),onFocusableItemAdd:_.useCallback(()=>S(I=>I+1),[]),onFocusableItemRemove:_.useCallback(()=>S(I=>I-1),[])},_.createElement(Un.div,Ye({tabIndex:v||C===0?-1:0,"data-orientation":r},u,{ref:h,style:{outline:"none",...e.style},onMouseDown:hn(e.onMouseDown,()=>{x.current=!0}),onFocus:hn(e.onFocus,I=>{const T=!x.current;if(I.target===I.currentTarget&&T&&!v){const L=new CustomEvent(Jp,lK);if(I.currentTarget.dispatchEvent(L),!L.defaultPrevented){const A=w().filter(G=>G.focusable),F=A.find(G=>G.active),P=A.find(G=>G.id===g),V=[F,P,...A].filter(Boolean).map(G=>G.ref.current);$7(V)}}x.current=!1}),onBlur:hn(e.onBlur,()=>y(!1))})))}),gK="RovingFocusGroupItem",pK=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:o,...s}=e,a=VE(),l=o||a,c=hK(gK,n),u=c.currentTabStopId===l,d=N7(n),{onFocusableItemAdd:h,onFocusableItemRemove:m}=c;return _.useEffect(()=>{if(r)return h(),()=>m()},[r,h,m]),_.createElement(wy.ItemSlot,{scope:n,id:l,focusable:r,active:i},_.createElement(Un.span,Ye({tabIndex:u?0:-1,"data-orientation":c.orientation},s,{ref:t,onMouseDown:hn(e.onMouseDown,g=>{r?c.onItemFocus(l):g.preventDefault()}),onFocus:hn(e.onFocus,()=>c.onItemFocus(l)),onKeyDown:hn(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){c.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const p=EK(g,c.orientation,c.dir);if(p!==void 0){g.preventDefault();let y=d().filter(E=>E.focusable).map(E=>E.ref.current);if(p==="last")y.reverse();else if(p==="prev"||p==="next"){p==="prev"&&y.reverse();const E=y.indexOf(g.currentTarget);y=c.loop?wK(y,E+1):y.slice(E+1)}setTimeout(()=>$7(y))}})})))}),yK={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function vK(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function EK(e,t,n){const r=vK(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return yK[r]}function $7(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function wK(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const bK=fK,_K=pK,B7="Tabs",[xK,eee]=ah(B7,[F7]),z7=F7(),[SK,tw]=xK(B7),kK=_.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:o,orientation:s="horizontal",dir:a,activationMode:l="automatic",...c}=e,u=O7(a),[d,h]=KE({prop:r,onChange:i,defaultProp:o});return _.createElement(SK,{scope:n,baseId:VE(),value:d,onValueChange:h,orientation:s,dir:u,activationMode:l},_.createElement(Un.div,Ye({dir:u,"data-orientation":s},c,{ref:t})))}),IK="TabsList",CK=_.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...i}=e,o=tw(IK,n),s=z7(n);return _.createElement(bK,Ye({asChild:!0},s,{orientation:o.orientation,dir:o.dir,loop:r}),_.createElement(Un.div,Ye({role:"tablist","aria-orientation":o.orientation},i,{ref:t})))}),TK="TabsTrigger",MK=_.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...o}=e,s=tw(TK,n),a=z7(n),l=H7(s.baseId,r),c=U7(s.baseId,r),u=r===s.value;return _.createElement(_K,Ye({asChild:!0},a,{focusable:!i,active:u}),_.createElement(Un.button,Ye({type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:l},o,{ref:t,onMouseDown:hn(e.onMouseDown,d=>{!i&&d.button===0&&d.ctrlKey===!1?s.onValueChange(r):d.preventDefault()}),onKeyDown:hn(e.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&s.onValueChange(r)}),onFocus:hn(e.onFocus,()=>{const d=s.activationMode!=="manual";!u&&!i&&d&&s.onValueChange(r)})})))}),AK="TabsContent",LK=_.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:i,children:o,...s}=e,a=tw(AK,n),l=H7(a.baseId,r),c=U7(a.baseId,r),u=r===a.value,d=_.useRef(u);return _.useEffect(()=>{const h=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(h)},[]),_.createElement(pg,{present:i||u},({present:h})=>_.createElement(Un.div,Ye({"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0},s,{ref:t,style:{...e.style,animationDuration:d.current?"0s":void 0}}),h&&o))});function H7(e,t){return`${e}-trigger-${t}`}function U7(e,t){return`${e}-content-${t}`}const W7=kK,V7=CK,G7=MK,j7=LK,Y7=({children:e,...t})=>f(V7,{className:"sidebar-triggers",...t,children:e});Y7.displayName="SidebarTabTriggers";const K7=({children:e,tab:t,onSelect:n,...r})=>f(G7,{value:t,asChild:!0,onSelect:n,children:f("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});K7.displayName="SidebarTabTrigger";const Z7=({children:e,...t})=>{const n=mn(),r=Mn();if(!n.openSidebar)return null;const{name:i}=n.openSidebar;return f(W7,{className:"sidebar-tabs-root",value:n.openSidebar.tab,onValueChange:o=>r(s=>({...s,openSidebar:{...s.openSidebar,name:i,tab:o}})),...t,children:e})};Z7.displayName="SidebarTabs";const X7=({tab:e,children:t,...n})=>f(j7,{...n,value:e,children:t});X7.displayName="SidebarTab";const nw=mt(!1),q7=_.forwardRef(({name:e,children:t,onDock:n,docked:r,className:i,...o},s)=>{const a=Mn(),l=lc(nw,en);_.useLayoutEffect(()=>(l(!!r),()=>{l(!1)}),[l,r]);const c=_.useRef({});c.current.onCloseRequest=()=>{a({openSidebar:null})},c.current.onDock=m=>n==null?void 0:n(m),c.current=Af(c.current,{docked:r,shouldRenderDockButton:!!n&&r!=null});const u=_.useRef(null);_.useImperativeHandle(s,()=>u.current);const d=gn(),h=_.useCallback(()=>{document.querySelector(".Dialog")||a({openSidebar:null})},[a]);return ZE(u,_.useCallback(m=>{m.target.closest(".sidebar-trigger")||(!r||!d.editor.canFitSidebar)&&h()},[h,r,d.editor.canFitSidebar])),_.useEffect(()=>{const m=g=>{g.key===D.ESCAPE&&(!r||!d.editor.canFitSidebar)&&h()};return document.addEventListener(Z.KEYDOWN,m),()=>{document.removeEventListener(Z.KEYDOWN,m)}},[h,r,d.editor.canFitSidebar]),f(Yr,{...o,className:se("sidebar",{"sidebar--docked":r},i),ref:u,children:f(P7.Provider,{value:c.current,children:t})})});q7.displayName="SidebarInner";const Ui=Object.assign(_.forwardRef((e,t)=>{var l;const n=mn(),{onStateChange:r}=e,i=_.useRef(n.openSidebar);_.useEffect(()=>{var c,u,d,h,m;(!n.openSidebar&&((c=i==null?void 0:i.current)==null?void 0:c.name)===e.name||((u=n.openSidebar)==null?void 0:u.name)===e.name&&((d=i==null?void 0:i.current)==null?void 0:d.name)!==e.name||((h=i.current)==null?void 0:h.name)===e.name)&&n.openSidebar!==i.current&&(r==null||r(((m=n.openSidebar)==null?void 0:m.name)!==e.name?null:n.openSidebar)),i.current=n.openSidebar},[n.openSidebar,r,e.name]);const[o,s]=_.useState(!1);return _.useLayoutEffect(()=>(s(!0),()=>s(!1)),[]),o&&((l=n.openSidebar)==null?void 0:l.name)===e.name?_.createElement(q7,{...e,ref:t,key:e.name}):null}),{Header:R7,TabTriggers:Y7,TabTrigger:K7,Tabs:Z7,Tab:X7,Trigger:D7});Ui.displayName="Sidebar";const n1=({label:e,onClick:t,className:n,children:r,actionType:i,type:o="button",isLoading:s,...a})=>{const l=i?`Dialog__action-button--${i}`:"";return k("button",{className:se("Dialog__action-button",l,n),type:o,"aria-label":e,onClick:t,...a,children:[r&&f("div",{style:s?{visibility:"hidden"}:{},children:r}),f("div",{style:s?{visibility:"hidden"}:{},children:e}),s&&f("div",{style:{position:"absolute",inset:0},children:f(to,{})})]})},PK=({theme:e,id:t,libraryReturnUrl:n})=>{const r=n||window.location.origin+window.location.pathname;return f("a",{className:"library-menu-browse-button",href:`https://libraries.excalidraw.com?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${t}&theme=${e}&version=${O1.excalidrawLibrary}`,target:"_excalidraw_libraries",children:b("labels.libraries")})},Q7=({libraryReturnUrl:e,theme:t,id:n,style:r,children:i,className:o})=>k("div",{className:se("library-menu-control-buttons",o),style:r,children:[f(PK,{id:n,libraryReturnUrl:e,theme:t}),i]}),RK=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,DK=/{{([\w-]+)}}/,OK=/<([\w-]+)>/,NK=/<\/([\w-]+)>/,FK=(e,t)=>{const n=[{name:"",children:[]}];return e.split(RK).filter(Boolean).forEach(r=>{const i=r.match(OK),o=r.match(NK),s=r.match(DK);if(i!==null){const a=i[1];t.hasOwnProperty(a)?n.push({name:a,children:[]}):console.warn(`Trans: missed to pass in prop ${a} for interpolating ${e}`)}else if(o!==null)if(o[1]===n[n.length-1].name){const l=n.pop(),c=te.createElement(te.Fragment,{},...l.children),u=t[l.name];typeof u=="function"&&n[n.length-1].children.push(u(c))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(s!==null){const a=s[1];t.hasOwnProperty(a)?n[n.length-1].children.push(t[a]):console.warn(`Trans: key ${a} not in props for interpolating ${e}`)}else n[n.length-1].children.push(r)}),n.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),n[0].children},On=({i18nKey:e,children:t,...n})=>{const{t:r}=xt();return te.createElement(te.Fragment,{},...FK(r(e),n))};class Si{static has(t){try{return!!window.localStorage.getItem(t)}catch(n){return console.warn(`localStorage.getItem error: ${n.message}`),!1}}static get(t){try{const n=window.localStorage.getItem(t);return n?JSON.parse(n):null}catch(n){return console.warn(`localStorage.getItem error: ${n.message}`),null}}}M(Si,"set",(t,n)=>{try{return window.localStorage.setItem(t,JSON.stringify(n)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),M(Si,"delete",t=>{try{window.localStorage.removeItem(t)}catch(n){console.warn(`localStorage.removeItem error: ${n.message}`)}});const $K=async e=>{const r=Math.round(8),i=Math.max(Math.round(128/64),2),o=SD(e,6),s=document.createElement("canvas");s.width=o[0].length*128+(o[0].length+1)*(r*2)-r*2,s.height=o.length*128+(o.length+1)*(r*2)-r*2;const a=s.getContext("2d");a.fillStyle=Ut.white,a.fillRect(0,0,s.width,s.height);for(const[l,c]of e.entries()){const u=await og({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:d,height:h}=u,m=Math.floor(l/6)*(128+r*2),g=l%6*(128+r*2);a.drawImage(u,g+(128-d)/2+r,m+(128-h)/2+r),a.lineWidth=i,a.strokeStyle=Ut.gray[4],a.strokeRect(g+r/2,m+r/2,128+r,128+r)}return await H2(new File([await _d(s)],"preview",{type:de.png}),{outputType:de.jpg,maxWidthOrHeight:5e3})},BK=({libItem:e,appState:t,index:n,onChange:r,onRemove:i})=>{const o=_.useRef(null),s=_.useRef(null);return _.useEffect(()=>{const a=o.current;a&&(async()=>{const l=await ET({elements:e.elements,appState:{...t,viewBackgroundColor:Ut.white,exportBackground:!0},files:null});a.innerHTML=l.outerHTML})()},[e.elements,t]),k("div",{className:"single-library-item",children:[e.status==="published"&&f("span",{className:"single-library-item-status",children:b("labels.statusPublished")}),f("div",{ref:o,className:"single-library-item__svg"}),f(Ce,{"aria-label":b("buttons.remove"),type:"button",icon:yc,className:"single-library-item--remove",onClick:i.bind(null,e.id),title:b("buttons.remove")}),k("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[k("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[k("div",{style:{padding:"0.5em 0"},children:[f("span",{style:{fontWeight:500,color:Ut.gray[6]},children:b("publishDialog.itemName")}),f("span",{"aria-hidden":"true",className:"required",children:"*"})]}),f("input",{type:"text",ref:s,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:a=>{r(a.target.value,n)}})]}),f("span",{className:"error",children:e.error})]})]})},zK=({onClose:e,libraryItems:t,appState:n,onSuccess:r,onError:i,updateItemsInStorage:o,onRemove:s})=>{const[a,l]=_.useState({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,u]=_.useState(!1);_.useEffect(()=>{const w=Si.get(qo.PUBLISH_LIBRARY);w&&l(w)},[]);const[d,h]=_.useState(t.slice());_.useEffect(()=>{h(t.slice())},[t]);const m=w=>{l({...a,[w.target.name]:w.target.value})},g=async w=>{w.preventDefault(),u(!0);const x=[];let C=!1;if(d.forEach(F=>{let P="";F.name||(P=b("publishDialog.errors.required"),C=!0),x.push({...F,error:P})}),C){h(x),u(!1);return}const S=await $K(d),I={type:yr.excalidrawLibrary,version:O1.excalidrawLibrary,source:Fv,libraryItems:d},T=JSON.stringify(I,null,2),L=new Blob([T],{type:"application/json"}),A=new FormData;A.append("excalidrawLib",L),A.append("previewImage",S),A.append("previewImageType",S.type),A.append("title",a.name),A.append("authorName",a.authorName),A.append("githubHandle",a.githubHandle),A.append("name",a.name),A.append("description",a.description),A.append("twitterHandle",a.twitterHandle),A.append("website",a.website),fetch("https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries/submit",{method:"post",body:A}).then(F=>F.ok?F.json().then(({url:P})=>{Si.delete(qo.PUBLISH_LIBRARY),r({url:P,authorName:a.authorName,items:d})}):F.json().catch(()=>{throw new Error(F.statusText||"something went wrong")}).then(P=>{throw new Error(P.message||F.statusText||"something went wrong")}),F=>{console.error(F),i(F),u(!1)}).catch(F=>{console.error(F),i(F),u(!1)})},p=()=>{const w=[];return d.forEach((x,C)=>{w.push(f("div",{className:"single-library-item-wrapper",children:f(BK,{libItem:x,appState:n,index:C,onChange:(S,I)=>{const T=d.slice();T[I].name=S,h(T)},onRemove:s})},C))}),f("div",{className:"selected-library-items",children:w})},v=_.useCallback(()=>{o(d),Si.set(qo.PUBLISH_LIBRARY,a),e()},[d,e,o,a]),y=!!t.length,E=t.some(w=>w.status==="published");return f(Vn,{onCloseRequest:v,title:b("publishDialog.title"),className:"publish-library",children:y?k("form",{onSubmit:g,children:[f("div",{className:"publish-library-note",children:f(On,{i18nKey:"publishDialog.noteDescription",link:w=>f("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:w})})}),f("span",{className:"publish-library-note",children:f(On,{i18nKey:"publishDialog.noteGuidelines",link:w=>f("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:w})})}),f("div",{className:"publish-library-note",children:b("publishDialog.noteItems")}),E&&f("span",{className:"publish-library-note publish-library-warning",children:b("publishDialog.republishWarning")}),p(),k("div",{className:"publish-library__fields",children:[k("label",{children:[k("div",{children:[f("span",{children:b("publishDialog.libraryName")}),f("span",{"aria-hidden":"true",className:"required",children:"*"})]}),f("input",{type:"text",name:"name",required:!0,value:a.name,onChange:m,placeholder:b("publishDialog.placeholder.libraryName")})]}),k("label",{style:{alignItems:"flex-start"},children:[k("div",{children:[f("span",{children:b("publishDialog.libraryDesc")}),f("span",{"aria-hidden":"true",className:"required",children:"*"})]}),f("textarea",{name:"description",rows:4,required:!0,value:a.description,onChange:m,placeholder:b("publishDialog.placeholder.libraryDesc")})]}),k("label",{children:[k("div",{children:[f("span",{children:b("publishDialog.authorName")}),f("span",{"aria-hidden":"true",className:"required",children:"*"})]}),f("input",{type:"text",name:"authorName",required:!0,value:a.authorName,onChange:m,placeholder:b("publishDialog.placeholder.authorName")})]}),k("label",{children:[f("span",{children:b("publishDialog.githubUsername")}),f("input",{type:"text",name:"githubHandle",value:a.githubHandle,onChange:m,placeholder:b("publishDialog.placeholder.githubHandle")})]}),k("label",{children:[f("span",{children:b("publishDialog.twitterUsername")}),f("input",{type:"text",name:"twitterHandle",value:a.twitterHandle,onChange:m,placeholder:b("publishDialog.placeholder.twitterHandle")})]}),k("label",{children:[f("span",{children:b("publishDialog.website")}),f("input",{type:"text",name:"website",pattern:"https?://.+",title:b("publishDialog.errors.website"),value:a.website,onChange:m,placeholder:b("publishDialog.placeholder.website")})]}),f("span",{className:"publish-library-note",children:f(On,{i18nKey:"publishDialog.noteLicense",link:w=>f("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:w})})})]}),k("div",{className:"publish-library__buttons",children:[f(n1,{label:b("buttons.cancel"),onClick:v,"data-testid":"cancel-clear-canvas-button"}),f(n1,{type:"submit",label:b("buttons.submit"),actionType:"primary",isLoading:c})]})]}):f("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:b("publishDialog.atleastOneLibItem")})})},HK=(e,t)=>e.filter(n=>t.includes(n.id)),UK=({setAppState:e,selectedItems:t,library:n,onRemoveFromLibrary:r,resetLibrary:i,onSelectItems:o,appState:s,className:a})=>{const[l]=ze(Od,en),[c,u]=ze(rw,en),d=()=>{const A=t.length?b("alerts.removeItemsFromsLibrary",{count:t.length}):b("alerts.resetLibrary"),F=t.length?b("confirmDialog.removeItemsFromLib"):b("confirmDialog.resetLibrary");return f(eM,{onConfirm:()=>{t.length?r():i(),m(!1)},onCancel:()=>{m(!1)},title:F,children:f("p",{children:A})})},[h,m]=_.useState(!1),g=!!t.length,p=g?l.libraryItems.filter(A=>t.includes(A.id)):l.libraryItems,v=b(g?"buttons.remove":"buttons.resetLibrary"),[y,E]=_.useState(!1),[w,x]=_.useState(null),C=_.useCallback(()=>k(Vn,{onCloseRequest:()=>x(null),title:b("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[f("p",{children:f(On,{i18nKey:"publishSuccessDialog.content",authorName:w.authorName,link:A=>f("a",{href:w==null?void 0:w.url,target:"_blank",rel:"noopener noreferrer",children:A})})}),f(Ce,{type:"button",title:b("buttons.close"),"aria-label":b("buttons.close"),label:b("buttons.close"),onClick:()=>x(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[x,w]),S=(A,F)=>{E(!1),x({url:A.url,authorName:A.authorName});const P=F.slice();P.forEach(O=>{t.includes(O.id)&&(O.status="published")}),n.setLibrary(P)},I=async()=>{try{await n.updateLibrary({libraryItems:fE({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(A){if((A==null?void 0:A.name)==="AbortError"){console.warn(A);return}e({errorMessage:b("errors.importLibraryError")})}},T=async()=>{const A=g?p:await n.getLatestLibrary();CF(A).catch(Gk).catch(F=>{e({errorMessage:F.message})})},L=()=>k(Ie,{open:c,children:[f(Ie.Trigger,{onToggle:()=>u(!c),children:oH}),k(Ie.Content,{onClickOutside:()=>u(!1),onSelect:()=>u(!1),className:"library-menu",children:[!g&&f(Ie.Item,{onSelect:I,icon:HE,"data-testid":"lib-dropdown--load",children:b("buttons.load")}),!!p.length&&f(Ie.Item,{onSelect:T,icon:YT,"data-testid":"lib-dropdown--export",children:b("buttons.export")}),!!p.length&&f(Ie.Item,{onSelect:()=>m(!0),icon:ug,children:v}),g&&f(Ie.Item,{icon:$U,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:b("buttons.publishLibrary")})]})]});return k("div",{className:se("library-menu-dropdown-container",a),children:[L(),t.length>0&&f("div",{className:"library-actions-counter",children:t.length}),h&&d(),y&&f(zK,{onClose:()=>E(!1),libraryItems:HK(l.libraryItems,t),appState:s,onSuccess:A=>S(A,l.libraryItems),onError:A=>window.alert(A),updateItemsInStorage:()=>n.setLibrary(l.libraryItems),onRemove:A=>o(t.filter(F=>F!==A))}),w&&C()]})},_4=({selectedItems:e,onSelectItems:t,className:n})=>{const{library:r}=xc(),{clearLibraryCache:i,deleteItemsFromLibraryCache:o}=t7(),s=mn(),a=Mn(),[l]=ze(Od,en),c=async d=>{const h=d.filter(m=>!e.includes(m.id));r.setLibrary(h).catch(()=>{a({errorMessage:b("alerts.errorRemovingFromLibrary")})}),o(e),t([])};return f(UK,{appState:s,setAppState:a,selectedItems:e,onSelectItems:t,library:r,onRemoveFromLibrary:()=>c(l.libraryItems),resetLibrary:()=>{r.resetLibrary(),i()},className:n})},WK=_.memo(({id:e,elements:t,isPending:n,onClick:r,selected:i,onToggle:o,onDrag:s,svgCache:a})=>{const l=_.useRef(null),c=Uj(e,t,a);_.useEffect(()=>{const g=l.current;if(g)return c&&(g.innerHTML=c.outerHTML),()=>{g.innerHTML=""}},[c]);const[u,d]=_.useState(!1),h=gn().editor.isMobile,m=n&&f("div",{className:"library-unit__adder",children:iH});return k("div",{className:se("library-unit",{"library-unit__active":t,"library-unit--hover":t&&u,"library-unit--selected":i,"library-unit--skeleton":!c}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[f("div",{className:se("library-unit__dragger",{"library-unit__pulse":!!n}),ref:l,draggable:!!t,onClick:t||n?g=>{e&&g.shiftKey?o(e,g):r(e)}:void 0,onDragStart:g=>{if(!e){g.preventDefault();return}d(!1),s(e,g)}}),m,e&&t&&(u||h||i)&&f(Ig,{checked:i,onChange:(g,p)=>o(e,p),className:"library-unit__checkbox"})]})}),VK=()=>f("div",{className:"library-unit library-unit--skeleton"});function GK(){return[!1,_.useCallback(t=>t(),[])]}const jK=te.useTransition||GK,x4=({children:e})=>f("div",{className:"library-menu-items-container__grid",children:e}),e0=_.memo(({items:e,onItemSelectToggle:t,onItemDrag:n,isItemSelected:r,onClick:i,svgCache:o,itemsRenderedPerBatch:s})=>{const[,a]=jK(),[l,c]=_.useState(0);return _.useEffect(()=>{l<e.length&&a(()=>{c(l+s)})},[l,e.length,a,s]),f(re,{children:e.map((u,d)=>d<l?f(WK,{elements:u==null?void 0:u.elements,isPending:!(u!=null&&u.id)&&!!(u!=null&&u.elements),onClick:i,svgCache:o,id:u==null?void 0:u.id,selected:r(u.id),onToggle:t,onDrag:n},(u==null?void 0:u.id)??d):f(VK,{},d))})});var J7="Expected a function",S4=NaN,YK="[object Symbol]",KK=/^\s+|\s+$/g,ZK=/^[-+]0x[0-9a-f]+$/i,XK=/^0b[01]+$/i,qK=/^0o[0-7]+$/i,QK=parseInt,JK=typeof ph=="object"&&ph&&ph.Object===Object&&ph,eZ=typeof self=="object"&&self&&self.Object===Object&&self,tZ=JK||eZ||Function("return this")(),nZ=Object.prototype,rZ=nZ.toString,iZ=Math.max,oZ=Math.min,t0=function(){return tZ.Date.now()};function sZ(e,t,n){var r,i,o,s,a,l,c=0,u=!1,d=!1,h=!0;if(typeof e!="function")throw new TypeError(J7);t=k4(t)||0,r1(n)&&(u=!!n.leading,d="maxWait"in n,o=d?iZ(k4(n.maxWait)||0,t):o,h="trailing"in n?!!n.trailing:h);function m(S){var I=r,T=i;return r=i=void 0,c=S,s=e.apply(T,I),s}function g(S){return c=S,a=setTimeout(y,t),u?m(S):s}function p(S){var I=S-l,T=S-c,L=t-I;return d?oZ(L,o-T):L}function v(S){var I=S-l,T=S-c;return l===void 0||I>=t||I<0||d&&T>=o}function y(){var S=t0();if(v(S))return E(S);a=setTimeout(y,p(S))}function E(S){return a=void 0,h&&r?m(S):(r=i=void 0,s)}function w(){a!==void 0&&clearTimeout(a),c=0,r=l=i=a=void 0}function x(){return a===void 0?s:E(t0())}function C(){var S=t0(),I=v(S);if(r=arguments,i=this,l=S,I){if(a===void 0)return g(l);if(d)return a=setTimeout(y,t),m(l)}return a===void 0&&(a=setTimeout(y,t)),s}return C.cancel=w,C.flush=x,C}function aZ(e,t,n){var r=!0,i=!0;if(typeof e!="function")throw new TypeError(J7);return r1(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),sZ(e,t,{leading:r,maxWait:t,trailing:i})}function r1(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function lZ(e){return!!e&&typeof e=="object"}function cZ(e){return typeof e=="symbol"||lZ(e)&&rZ.call(e)==YK}function k4(e){if(typeof e=="number")return e;if(cZ(e))return S4;if(r1(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=r1(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(KK,"");var n=XK.test(e);return n||qK.test(e)?QK(e.slice(2),n?2:8):ZK.test(e)?S4:+e}var uZ=aZ;const Qs=rc(uZ),dZ=mt(0),hZ=e=>{const[t,n]=ze(dZ);return _.useEffect(()=>{const{current:r}=e;if(!r)return;const i=Qs(()=>{const{scrollTop:o}=r;n(o)},200);return r.addEventListener("scroll",i),()=>{i.cancel(),r.removeEventListener("scroll",i)}},[e,n]),t},fZ=17,mZ=64;function gZ({isLoading:e,libraryItems:t,onAddToLibrary:n,onInsertLibraryItems:r,pendingElements:i,theme:o,id:s,libraryReturnUrl:a,onSelectItems:l,selectedItems:c}){const u=_.useRef(null),d=hZ(u);_.useEffect(()=>{var A;d>0&&((A=u.current)==null||A.scrollTo(0,d))},[]);const{svgCache:h}=t7(),m=_.useMemo(()=>t.filter(A=>A.status!=="published"),[t]),g=_.useMemo(()=>t.filter(A=>A.status==="published"),[t]),p=!t.length&&!i.length,v=!i.length&&!m.length&&!g.length,[y,E]=_.useState(null),w=_.useCallback((A,F)=>{const P=!c.includes(A),O=[...m,...g];if(P){if(F.shiftKey&&y){const V=O.findIndex($=>$.id===y),G=O.findIndex($=>$.id===A);if(V===-1||G===-1){l([...c,A]);return}const q=be(c),U=O.reduce(($,Y,R)=>((R>=V&&R<=G||q.has(Y.id))&&$.push(Y.id),$),[]);l(U)}else l([...c,A]);E(A)}else E(null),l(c.filter(V=>V!==A))},[y,l,g,c,m]),x=_.useCallback(A=>{let F;return c.includes(A)?F=t.filter(P=>c.includes(P.id)):F=t.filter(P=>P.id===A),F.map(P=>({...P,elements:YI(P.elements,{randomizeSeed:!0})}))},[t,c]),C=_.useCallback((A,F)=>{F.dataTransfer.setData(de.excalidrawlib,nC(x(A)))},[x]),S=_.useCallback(A=>A?c.includes(A):!1,[c]),I=_.useCallback(()=>{n(i)},[i,n]),T=_.useCallback(A=>{A&&r(x(A))},[x,r]),L=h.size>=t.length?mZ:fZ;return k("div",{className:"library-menu-items-container",style:i.length||m.length||g.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!v&&f(_4,{selectedItems:c,onSelectItems:l,className:"library-menu-dropdown-container--in-heading"}),k(gr.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:g.length>0?1:"0 1 auto",marginBottom:0},ref:u,children:[k(re,{children:[!v&&f("div",{className:"library-menu-items-container__header",children:b("labels.personalLib")}),e&&f("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:f(to,{})}),!i.length&&!m.length?k("div",{className:"library-menu-items__no-items",children:[f("div",{className:"library-menu-items__no-items__label",children:b("library.noItems")}),f("div",{className:"library-menu-items__no-items__hint",children:g.length>0?b("library.hint_emptyPrivateLibrary"):b("library.hint_emptyLibrary")})]}):k(x4,{children:[i.length>0&&f(e0,{itemsRenderedPerBatch:L,items:[{id:null,elements:i}],onItemSelectToggle:w,onItemDrag:C,onClick:I,isItemSelected:S,svgCache:h}),f(e0,{itemsRenderedPerBatch:L,items:m,onItemSelectToggle:w,onItemDrag:C,onClick:T,isItemSelected:S,svgCache:h})]})]}),k(re,{children:[(g.length>0||i.length>0||m.length>0)&&f("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:b("labels.excalidrawLib")}),g.length>0?f(x4,{children:f(e0,{itemsRenderedPerBatch:L,items:g,onItemSelectToggle:w,onItemDrag:C,onClick:T,isItemSelected:S,svgCache:h})}):m.length>0?f("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:b("library.noItems")}):null]}),p&&f(Q7,{style:{padding:"16px 0",width:"100%"},id:s,libraryReturnUrl:a,theme:o,children:f(_4,{selectedItems:c,onSelectItems:l})})]})]})}const rw=mt(!1),I4=({children:e})=>f("div",{className:"layer-ui__library",children:e}),pZ=({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:n,setAppState:r,libraryReturnUrl:i,library:o,id:s,theme:a,selectedItems:l,onSelectItems:c})=>{const[u]=ze(Od,en),d=_.useCallback(g=>{(async(v,y)=>{Ae("element","addToLibrary","ui");for(const w of GS)if(v.some(x=>x.type===w))return r({errorMessage:b(`errors.libraryElementTypeError.${w}`)});const E=[{status:"unpublished",elements:v,id:xr(),created:Date.now()},...y];n(),o.setLibrary(E).catch(()=>{r({errorMessage:b("alerts.errorAddingToLibrary")})})})(g,u.libraryItems)},[n,o,r,u.libraryItems]),h=_.useMemo(()=>u.libraryItems,[u]);if(u.status==="loading"&&!u.isInitialized)return f(I4,{children:f("div",{className:"layer-ui__library-message",children:k("div",{children:[f(to,{size:"2em"}),f("span",{children:b("labels.libraryLoadingMessage")})]})})});const m=u.libraryItems.length>0||t.length>0;return k(I4,{children:[f(gZ,{isLoading:u.status==="loading",libraryItems:h,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:t,id:s,libraryReturnUrl:i,theme:a,onSelectItems:c,selectedItems:l}),m&&f(Q7,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:s,libraryReturnUrl:i,theme:a})]})},yZ=(e,t)=>{const n=()=>qe(t,e,{includeBoundTextElement:!0,includeElementsInFrames:!0}),r=_.useRef(n()),i=_.useRef(e),o=_.useRef(t);return(!Jn(e.selectedElementIds,i.current.selectedElementIds)||!Jn(t,o.current))&&(r.current=n(),i.current=e,o.current=t),r.current},vZ=()=>{const{library:e,id:t,onInsertElements:n}=xc(),r=Sw(),i=mn(),o=Mn(),s=Ag(),[a,l]=_.useState([]),c=_.useMemo(()=>e,[e]),u=yZ(i,s),d=_.useCallback(m=>{n(i7(m))},[n]),h=_.useCallback(()=>{o({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[o]);return f(pZ,{pendingElements:u,onInsertLibraryItems:d,onAddToLibrary:h,setAppState:o,libraryReturnUrl:r.libraryReturnUrl,library:c,id:t,theme:i.theme,selectedItems:a,onSelectItems:l})},eM=e=>{const{onConfirm:t,onCancel:n,children:r,confirmText:i=b("buttons.confirm"),cancelText:o=b("buttons.cancel"),className:s="",...a}=e,l=Mn(),c=lc(rw,en),{container:u}=uo();return k(Vn,{onCloseRequest:n,size:"small",...a,className:`confirm-dialog ${s}`,children:[r,k("div",{className:"confirm-dialog-buttons",children:[f(n1,{label:o,onClick:()=>{l({openMenu:null}),c(!1),n(),u==null||u.focus()}}),f(n1,{label:i,onClick:()=>{l({openMenu:null}),c(!1),t(),u==null||u.focus()},actionType:"danger"})]})]})},iw=mt(null),EZ=()=>{const[e,t]=ze(iw,en),n=Cr();return e&&e==="clearCanvas"?f(eM,{onConfirm:()=>{n.executeAction(U8),t(null)},onCancel:()=>t(null),title:b("clearCanvasDialog.title"),children:k("p",{className:"clear-canvas__content",children:[" ",b("alerts.clearReset")]})}):null},tM=mt({active:!1});async function by({title:e,description:t,actionLabel:n,color:r}){return new Promise(i=>{_i.set(tM,{active:!0,onConfirm:()=>i(!0),onClose:()=>i(!1),onReject:()=>i(!1),title:e,description:t,actionLabel:n,color:r})})}const nM=()=>{const{t:e}=xt(),t=Cr(),n=Ag();return t.isActionEnabled(fy)?f(ti,{icon:HE,onSelect:async()=>{(!n.length||await by({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:f(On,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:i=>f("strong",{children:i}),br:()=>f("br",{})})}))&&t.executeAction(fy)},"data-testid":"load-button",shortcut:_c("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};nM.displayName="LoadScene";const rM=()=>{const{t:e}=xt(),t=Cr();return t.isActionEnabled(q6)?f(ti,{shortcut:_c("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(q6),icon:LH,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};rM.displayName="SaveToActiveFile";const iM=()=>{const e=Mn(),{t}=xt();return f(ti,{icon:DH,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:_c("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};iM.displayName="SaveAsImage";const oM=()=>{const{t:e}=xt(),t=Cr();return f(ti,{"data-testid":"help-menu-item",icon:BE,onSelect:()=>t.executeAction(QE),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};oM.displayName="Help";const sM=()=>{const{t:e}=xt(),t=lc(iw,en);return Cr().isActionEnabled(U8)?f(ti,{icon:ug,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};sM.displayName="ClearCanvas";const aM=()=>{const{t:e}=xt(),t=mn(),n=Cr();return n.isActionEnabled(Z6)?f(ti,{onSelect:r=>(r.preventDefault(),n.executeAction(Z6)),icon:t.theme==="dark"?CH:IH,"data-testid":"toggle-dark-mode",shortcut:_c("toggleTheme"),"aria-label":t.theme==="dark"?e("buttons.lightMode"):e("buttons.darkMode"),children:t.theme==="dark"?e("buttons.lightMode"):e("buttons.darkMode")}):null};aM.displayName="ToggleTheme";const lM=()=>{const{t:e}=xt(),t=mn(),n=Cr(),r=Sw();return t.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:k("div",{style:{marginTop:"0.5rem"},children:[f("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),f("div",{style:{padding:"0 0.625rem"},children:n.renderAction("changeViewBackgroundColor")})]})};lM.displayName="ChangeCanvasBackground";const cM=()=>{const{t:e}=xt(),t=Mn();return f(ti,{icon:YT,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};cM.displayName="Export";const uM=()=>{const{t:e}=xt();return k(re,{children:[f(Hu,{icon:KT,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),f(Hu,{icon:MH,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),f(Hu,{icon:TH,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};uM.displayName="Socials";const dM=({onSelect:e,isCollaborating:t})=>{const{t:n}=xt();return f(ti,{"data-testid":"collab-button",icon:dg,className:se({"active-collab":t}),onSelect:e,children:n("labels.liveCollaboration")})};dM.displayName="LiveCollaborationTrigger";const wZ=Object.freeze(Object.defineProperty({__proto__:null,ChangeCanvasBackground:lM,ClearCanvas:sM,Export:cM,Help:oM,LiveCollaborationTrigger:dM,LoadScene:nM,SaveAsImage:iM,SaveToActiveFile:rM,Socials:uM,ToggleTheme:aM},Symbol.toStringTag,{value:"Module"})),uh=(e,t)=>{const n=mt(0),r=i=>{const{jotaiScope:o}=Tn(),[,s]=ze(n,o),a=_.useRef({preferHost:!1,counter:0});return _.useLayoutEffect(()=>{const l=a.current;return s(c=>{const u=c+1;return l.counter=u,u}),()=>{s(c=>{const u=c-1;return l.counter=u,u||(l.preferHost=!1),u})}},[s]),i.__fallback||(a.current.preferHost=!0),!a.current.counter&&i.__fallback&&a.current.preferHost||a.current.counter>1&&i.__fallback?null:f(t,{...i})};return r.displayName=e,r},Ne=Object.assign(uh("MainMenu",({children:e,onSelect:t})=>{var a;const{MainMenuTunnel:n}=Tn(),r=gn(),i=mn(),o=Mn(),s=r.editor.isMobile?void 0:()=>o({openMenu:null});return f(n.In,{children:k(Ie,{open:i.openMenu==="canvas",children:[f(Ie.Trigger,{onToggle:()=>{o({openMenu:i.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:jT}),k(Ie.Content,{onClickOutside:s,onSelect:B1(t,()=>{o({openMenu:null})}),children:[e,r.editor.isMobile&&i.collaborators.size>0&&k("fieldset",{className:"UserList-Wrapper",children:[f("legend",{children:b("labels.collaborators")}),f(A7,{mobile:!0,collaborators:i.collaborators,userToFollow:((a=i.userToFollow)==null?void 0:a.socketId)||null})]})]})]})})}),{Trigger:Ie.Trigger,Item:Ie.Item,ItemLink:Ie.ItemLink,ItemCustom:Ie.ItemCustom,Group:Ie.Group,Separator:Ie.Separator,DefaultItems:wZ}),ow=({title:e,children:t,actionLabel:n,onClick:r})=>k("div",{className:"OverwriteConfirm__Actions__Action",children:[f("h4",{children:e}),f("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),f(zn,{variant:"outlined",color:"muted",label:n,size:"large",fullWidth:!0,onClick:r})]}),bZ=()=>{const{t:e}=xt(),t=Cr(),n=Mn();return f(ow,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction(V8,"ui",!0),n({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},_Z=()=>{const{t:e}=xt(),t=Cr();return f(ow,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction(G8,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},C4=Object.assign(({children:e})=>f("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:bZ,SaveToDisk:_Z}),Js=Object.assign(uh("OverwriteConfirmDialog",({children:e})=>{const{OverwriteConfirmDialogTunnel:t}=Tn(),[n,r]=ze(tM,en);if(!n.active)return null;const i=()=>{n.onClose(),r(s=>({...s,active:!1}))},o=()=>{n.onConfirm(),r(s=>({...s,active:!1}))};return f(t.In,{children:f(Vn,{onCloseRequest:i,title:!1,size:916,children:k("div",{className:"OverwriteConfirm",children:[f("h3",{children:n.title}),k("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${n.color}`,children:[f("div",{className:"OverwriteConfirm__Description__icon",children:WU}),f("div",{children:n.description}),f("div",{className:"OverwriteConfirm__Description__spacer"}),f(zn,{color:n.color,size:"large",label:n.actionLabel,onClick:o})]}),f(C4,{children:e})]})})})}),{Actions:C4,Action:ow}),hM=uh("DefaultSidebarTrigger",e=>{const{DefaultSidebarTriggerTunnel:t}=Tn();return f(t.In,{children:f(Ui.Trigger,{...e,className:"default-sidebar-trigger",name:Tl.name})})});hM.displayName="DefaultSidebarTrigger";const fM=({children:e,...t})=>{const{DefaultSidebarTabTriggersTunnel:n}=Tn();return f(n.In,{children:f(Ui.TabTriggers,{...t,children:e})})};fM.displayName="DefaultTabTriggers";const i1=Object.assign(uh("DefaultSidebar",({children:e,className:t,onDock:n,docked:r,...i})=>{const o=mn(),s=Mn(),{DefaultSidebarTabTriggersTunnel:a}=Tn();return _.createElement(Ui,{...i,name:"default",key:"default",className:se("default-sidebar",t),docked:r??o.defaultSidebarDockedPreference,onDock:n===!1||!n&&r!=null?void 0:B1(n,l=>{s({defaultSidebarDockedPreference:l})})},k(Ui.Tabs,{children:[k(Ui.Header,{children:[i.__fallback&&f("div",{style:{color:"var(--color-primary)",fontSize:"1.2em",fontWeight:"bold",textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",paddingRight:"1em"},children:b("toolBar.library")}),f(a.Out,{})]}),f(Ui.Tab,{tab:zv,children:f(vZ,{})}),e]}))}),{Trigger:hM,TabTriggers:fM}),xZ="small",SZ=e=>k("label",{className:se("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${xZ}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[f("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),f("div",{className:"ToolIcon__icon",children:QT})]}),Fr=_.forwardRef(({onChange:e,label:t,fullWidth:n,placeholder:r,readonly:i,selectOnRender:o,onKeyDown:s,isRedacted:a=!1,...l},c)=>{const u=_.useRef(null);_.useImperativeHandle(c,()=>u.current),_.useLayoutEffect(()=>{var m;o&&((m=u.current)==null||m.select())},[o]);const[d,h]=_.useState(!1);return k("div",{className:se("ExcTextField",{"ExcTextField--fullWidth":n}),onClick:()=>{var m;(m=u.current)==null||m.focus()},children:[f("div",{className:"ExcTextField__label",children:t}),k("div",{className:se("ExcTextField__input",{"ExcTextField__input--readonly":i}),children:[f("input",{className:se({"is-redacted":"value"in l&&l.value&&a&&!d}),readOnly:i,value:"value"in l?l.value:void 0,defaultValue:"defaultValue"in l?l.defaultValue:void 0,placeholder:r,ref:u,onChange:m=>e==null?void 0:e(m.target.value),onKeyDown:s}),a&&f(Fd,{onSelect:()=>h(!d),style:{border:0,userSelect:"none"},children:d?ZU:JT})]})]})}),Zf=({icon:e})=>f("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e}),Kc=e=>f("p",{className:"excalidraw__paragraph",style:e.style,children:e.children}),sw=e=>{const t=Mn(),n=_.useRef(null),r=_.useRef(0);return f(W7,{ref:n,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:i=>{var s;if(!i)return;const o=(s=n.current)==null?void 0:s.closest(".Modal__content");if(o){const a=o.offsetHeight||0;a>r.current&&(r.current=a,o.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="settings"&&k2(["text-to-diagram","diagram-to-code"],i)?t({openDialog:{name:e.dialog,tab:i,source:"settings"}}):e.dialog==="ttd"&&k2(["text-to-diagram","mermaid"],i)&&t({openDialog:{name:e.dialog,tab:i}})},children:e.children})};sw.displayName="TTDDialogTabs";const o1=({tab:e,children:t,...n})=>f(j7,{...n,value:e,children:t});o1.displayName="TTDDialogTab";const kZ=e=>{var a;const[t,n]=_.useState(e.openAIKey||""),[r,i]=_.useState(e.isPersisted),o=mn(),s=()=>{e.onConfirm(t.trim(),r)};return((a=o.openDialog)==null?void 0:a.name)!=="settings"?null:f(Vn,{onCloseRequest:()=>{e.onClose(),e.onConfirm(t.trim(),r)},title:k("div",{style:{display:"flex"},children:["Wireframe to Code (AI)"," ",f("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"0.1rem 0.5rem",marginLeft:"1rem",fontSize:14,borderRadius:"12px",color:"#000",background:"pink"},children:"Experimental"})]}),className:"MagicSettings",autofocus:!1,children:f(sw,{dialog:"settings",tab:o.openDialog.tab,children:k(o1,{tab:"diagram-to-code",children:[k(Kc,{children:["For the diagram-to-code feature we use"," ",f(Zf,{icon:ny}),"OpenAI."]}),k(Kc,{children:["While the OpenAI API is in beta, its use is strictly limited — as such we require you use your own API key. You can create an"," ",f("a",{href:"https://platform.openai.com/login?launch",rel:"noopener noreferrer",target:"_blank",children:"OpenAI account"}),", add a small credit (5 USD minimum), and"," ",f("a",{href:"https://platform.openai.com/api-keys",rel:"noopener noreferrer",target:"_blank",children:"generate your own API key"}),"."]}),f(Kc,{children:"Your OpenAI key does not leave the browser, and you can also set your own limit in your OpenAI account dashboard if needed."}),f(Fr,{isRedacted:!0,value:t,placeholder:"Paste your API key here",label:"OpenAI API key",onChange:l=>{n(l),e.onChange(l.trim(),r)},selectOnRender:!0,onKeyDown:l=>l.key===D.ENTER&&s()}),f(Kc,{children:"By default, your API token is not persisted anywhere so you'll need to insert it again after reload. But, you can persist locally in your browser below."}),f(Ig,{checked:r,onChange:i,children:"Persist API key in browser storage"}),k(Kc,{children:["Once API key is set, you can use the ",f(Zf,{icon:UE})," ","tool to wrap your elements in a frame that will then allow you to turn it into code. This dialog can be accessed using the"," ",f("b",{children:"AI Settings"})," ",f(Zf,{icon:ny}),"."]}),f(zn,{className:"MagicSettings__confirm",size:"large",label:"Confirm",onClick:s})]})})})},IZ=e=>{const[t,n]=_.useState(!0);return _.useEffect(()=>{const r=async()=>{await Ak(i),n(!1)},i=Gv.find(o=>o.code===e.langCode)||Es;r()},[e.langCode]),t?f(k7,{theme:e.theme}):e.children},mM=({children:e})=>{const{FooterCenterTunnel:t}=Tn(),n=mn();return f(t.In,{children:f("div",{className:se("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":n.zenModeEnabled}),children:e})})};mM.displayName="FooterCenter";const CZ=()=>f("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:f("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),TZ=()=>k("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[f("path",{d:"M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z",transform:"translate(-144.023 -51.76)"}),f("path",{d:"M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z",transform:"translate(-144.023 -51.76)"}),f("path",{d:"M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z",transform:"translate(-144.023 -51.76)"}),f("path",{d:"m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z",fill:"currentColor",transform:"translate(-144.023 -51.76)"})]}),gM=({style:e,size:t="small",withText:n})=>k("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[f(CZ,{}),n&&f(TZ,{})]}),aw=({icon:e,shortcut:t,children:n})=>{const r=gn();return k(re,{children:[f("div",{className:"welcome-screen-menu-item__icon",children:e}),f("div",{className:"welcome-screen-menu-item__text",children:n}),t&&!r.editor.isMobile&&f("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};aw.displayName="WelcomeScreenMenuItemContent";const dh=({onSelect:e,children:t,icon:n,shortcut:r,className:i="",...o})=>f("button",{...o,type:"button",className:`welcome-screen-menu-item ${i}`,onClick:e,children:f(aw,{icon:n,shortcut:r,children:t})});dh.displayName="WelcomeScreenMenuItem";const pM=({children:e,href:t,icon:n,shortcut:r,className:i="",...o})=>f("a",{...o,className:`welcome-screen-menu-item ${i}`,href:t,target:"_blank",rel:"noreferrer",children:f(aw,{icon:n,shortcut:r,children:e})});pM.displayName="WelcomeScreenMenuItemLink";const ni=({children:e})=>{const{WelcomeScreenCenterTunnel:t}=Tn();return f(t.In,{children:f("div",{className:"welcome-screen-center",children:e||k(re,{children:[f(lw,{}),f(cw,{children:b("welcomeScreen.defaults.center_heading")}),k(uw,{children:[f(hw,{}),f(dw,{})]})]})})})};ni.displayName="Center";const lw=({children:e})=>f("div",{className:"welcome-screen-center__logo virgil welcome-screen-decor",children:e||f(gM,{withText:!0})});lw.displayName="Logo";const cw=({children:e})=>f("div",{className:"welcome-screen-center__heading welcome-screen-decor virgil",children:e});cw.displayName="Heading";const uw=({children:e})=>f("div",{className:"welcome-screen-menu",children:e});uw.displayName="Menu";const dw=()=>{const e=Cr();return f(dh,{onSelect:()=>e.executeAction(QE),shortcut:"?",icon:BE,children:b("helpDialog.title")})};dw.displayName="MenuItemHelp";const hw=()=>{const e=mn(),t=Cr();return e.viewModeEnabled?null:f(dh,{onSelect:()=>t.executeAction(fy),shortcut:_c("loadScene"),icon:HE,children:b("buttons.load")})};hw.displayName="MenuItemLoadScene";const yM=({onSelect:e})=>{const{t}=xt();return f(dh,{shortcut:null,onSelect:e,icon:dg,children:t("labels.liveCollaboration")})};yM.displayName="MenuItemLiveCollaborationTrigger";ni.Logo=lw;ni.Heading=cw;ni.Menu=uw;ni.MenuItem=dh;ni.MenuItemLink=pM;ni.MenuItemHelp=dw;ni.MenuItemLoadScene=hw;ni.MenuItemLiveCollaborationTrigger=yM;const fw=({children:e})=>{const{WelcomeScreenMenuHintTunnel:t}=Tn();return f(t.In,{children:k("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[cH,f("div",{className:"welcome-screen-decor-hint__label",children:e||b("welcomeScreen.defaults.menuHint")})]})})};fw.displayName="MenuHint";const mw=({children:e})=>{const{WelcomeScreenToolbarHintTunnel:t}=Tn();return f(t.In,{children:k("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[f("div",{className:"welcome-screen-decor-hint__label",children:e||b("welcomeScreen.defaults.toolbarHint")}),dH]})})};mw.displayName="ToolbarHint";const gw=({children:e})=>{const{WelcomeScreenHelpHintTunnel:t}=Tn();return f(t.In,{children:k("div",{className:"virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[f("div",{children:e||b("welcomeScreen.defaults.helpHint")}),uH]})})};gw.displayName="HelpHint";const yn=e=>f(re,{children:e.children||k(re,{children:[f(ni,{}),f(fw,{}),f(mw,{}),f(gw,{})]})});yn.displayName="WelcomeScreen";yn.Center=ni;yn.Hints={MenuHint:fw,ToolbarHint:mw,HelpHint:gw};const vM=({isCollaborating:e,onSelect:t,...n})=>{const r=mn(),i=r.width<830;return k(Fd,{...n,className:se("collab-button",{active:e}),type:"button",onSelect:t,style:{position:"relative",width:i?void 0:"auto"},title:b("labels.liveCollaboration"),children:[i?ZT:b("labels.share"),r.collaborators.size>0&&f("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})};vM.displayName="LiveCollaborationTrigger";const EM=({children:e,icon:t})=>{const{TTDDialogTriggerTunnel:n}=Tn(),r=Mn();return f(n.In,{children:k(Ie.Item,{onSelect:()=>{Ae("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:t??XU,children:[e??b("labels.textToDiagram"),f(Ie.Item.Badge,{children:"AI"})]})})};EM.displayName="TTDDialogTrigger";const rf={width:100,height:0},Uo=100,MZ=(e,t,n)=>{const r=Sr({x:0,y:0,textAlign:hd.CENTER,verticalAlign:Qn.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),Mi(r,e,n),[e,r]},T4=(e,t,n,r,i)=>{let o,s;if(Object.assign(e,{startBinding:(e==null?void 0:e.startBinding)||null,endBinding:e.endBinding||null}),t){const u=(t==null?void 0:t.width)??Uo,d=(t==null?void 0:t.height)??Uo;let h;t.id&&(h=r.getElement(t.id),h||console.error(`No element for start binding with id ${t.id} found`));const m=t.x||e.x-u,g=t.y||e.y-d/2,p=h?h.type:t.type;if(p){if(p==="text"){let v="";h&&h.type==="text"?v=h.text:t.type==="text"&&(v=t.text),v||console.error(`No text found for start binding text element for ${e.id}`),o=Sr({x:m,y:g,type:"text",...h,...t,text:v}),Object.assign(o,{x:t.x||e.x-o.width,y:t.y||e.y-o.height/2})}else switch(p){case"rectangle":case"ellipse":case"diamond":{o=hs({x:m,y:g,width:u,height:d,...h,...t,type:p});break}default:jl(e,`Unhandled element start type "${t.type}"`,!0)}Ed(e,o,"start",i)}}if(n){const u=(n==null?void 0:n.height)??Uo,d=(n==null?void 0:n.width)??Uo;let h;n.id&&(h=r.getElement(n.id),h||console.error(`No element for end binding with id ${n.id} found`));const m=n.x||e.x+e.width,g=n.y||e.y-u/2,p=h?h.type:n.type;if(p){if(p==="text"){let v="";h&&h.type==="text"?v=h.text:n.type==="text"&&(v=n.text),v||console.error(`No text found for end binding text element for ${e.id}`),s=Sr({x:m,y:g,type:"text",...h,...n,text:v}),Object.assign(s,{y:n.y||e.y-s.height/2})}else switch(p){case"rectangle":case"ellipse":case"diamond":{s=hs({x:m,y:g,width:d,height:u,...h,...n,type:p});break}default:jl(e,`Unhandled element end type "${p}"`,!0)}Ed(e,s,"end",i)}}const a=e.points.length-1,l=.5,c=Yl(e.points);return e.points[a][0]>e.points[a-1][0]&&(c[0][0]=l,c[a][0]-=l),e.points[a][0]<e.points[a-1][0]&&(c[0][0]=-l,c[a][0]+=l),e.points[a][1]>e.points[a-1][1]&&(c[0][1]=l,c[a][1]-=l),e.points[a][1]<e.points[a-1][1]&&(c[0][1]=-l,c[a][1]+=l),Object.assign(e,{points:c}),{linearElement:e,startBoundElement:o,endBoundElement:s}};class AZ{constructor(){M(this,"excalidrawElements",new Map);M(this,"add",t=>{t&&this.excalidrawElements.set(t.id,t)});M(this,"getElements",()=>Array.from(this.excalidrawElements.values()));M(this,"getElementsMap",()=>ma(this.excalidrawElements));M(this,"getElement",t=>this.excalidrawElements.get(t))}}const wM=(e,t)=>{var a,l,c;if(!e)return[];const n=Yl(e),r=new AZ,i=new Map,o=new Map;for(const u of n){let d;const h=u.id;switch((t==null?void 0:t.regenerateIds)!==!1&&Object.assign(u,{id:xr()}),u.type){case"rectangle":case"ellipse":case"diamond":{const g=(a=u==null?void 0:u.label)!=null&&a.text&&u.width===void 0?0:(u==null?void 0:u.width)||Uo,p=(l=u==null?void 0:u.label)!=null&&l.text&&u.height===void 0?0:(u==null?void 0:u.height)||Uo;d=hs({...u,width:g,height:p});break}case"line":{const g=u.width||rf.width,p=u.height||rf.height;d=Qo({width:g,height:p,points:[[0,0],[g,p]],...u});break}case"arrow":{const g=u.width||rf.width,p=u.height||rf.height;d=Qo({width:g,height:p,endArrowhead:"arrow",points:[[0,0],[g,p]],...u}),Object.assign(d,tI(d.points));break}case"text":{const g=(u==null?void 0:u.fontFamily)||oo,p=(u==null?void 0:u.fontSize)||Xr,v=(u==null?void 0:u.lineHeight)||wa(g),y=u.text??"",E=wd(y),w=ds(E,Bt({fontFamily:g,fontSize:p}),v);d=Sr({width:w.width,height:w.height,fontFamily:g,fontSize:p,...u});break}case"image":{d=GI({width:(u==null?void 0:u.width)||Uo,height:(u==null?void 0:u.height)||Uo,...u});break}case"frame":{d=WI({x:0,y:0,...u});break}case"magicframe":{d=$2({x:0,y:0,...u});break}case"freedraw":case"iframe":case"embeddable":{d=u;break}default:d=u,jl(u,`Unhandled element type "${u.type}"`,!0)}r.getElement(d.id)?console.error(`Duplicate id found for ${d.id}`):(r.add(d),i.set(d.id,u),h&&o.set(h,d.id))}const s=r.getElementsMap();for(const[u,d]of i){const h=r.getElement(u);switch(d.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if((c=d.label)!=null&&c.text){let[m,g]=MZ(h,d==null?void 0:d.label,s);if(r.add(m),r.add(g),m.type==="arrow"){const p=d.type==="arrow"?d==null?void 0:d.start:void 0,v=d.type==="arrow"?d==null?void 0:d.end:void 0;if(p&&p.id){const x=o.get(p.id);x&&Object.assign(p,{id:x})}if(v&&v.id){const x=o.get(v.id);x&&Object.assign(v,{id:x})}const{linearElement:y,startBoundElement:E,endBoundElement:w}=T4(m,p,v,r,s);m=y,r.add(y),r.add(E),r.add(w)}}else switch(d.type){case"arrow":{const{start:m,end:g}=d;if(m&&m.id){const E=o.get(m.id);Object.assign(m,{id:E})}if(g&&g.id){const E=o.get(g.id);Object.assign(g,{id:E})}const{linearElement:p,startBoundElement:v,endBoundElement:y}=T4(h,m,g,r,s);r.add(p),r.add(v),r.add(y);break}}break}}}for(const[u,d]of i){if(d.type!=="frame"&&d.type!=="magicframe")continue;const h=r.getElement(u);if(!h)throw new Error(`Excalidraw element with id ${u} doesn't exist`);const m=[];d.children.forEach(C=>{var T;const S=o.get(C);if(!S)throw new Error(`Element with ${C} wasn't mapped correctly`);const I=r.getElement(S);if(!I)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(I,{frameId:h.id}),(T=I==null?void 0:I.boundElements)==null||T.forEach(L=>{const A=r.getElement(L.id);if(!A)throw new Error(`Bound element with id ${L.id} doesn't exist`);Object.assign(A,{frameId:h.id}),m.push(A)}),m.push(I)});let[g,p,v,y]=nt(m);const E=10;g=g-E,p=p-E,v=v+E,y=y+E;const w=Math.max(h==null?void 0:h.width,v-g),x=Math.max(h==null?void 0:h.height,y-p);Object.assign(h,{x:g,y:p,width:w,height:x})}return r.getElements()};LS();const LZ=e=>{var G,q,U,$;const{onChange:t,initialData:n,excalidrawAPI:r,isCollaborating:i=!1,onPointerUpdate:o,renderTopRightUI:s,langCode:a=Es.code,viewModeEnabled:l,zenModeEnabled:c,gridModeEnabled:u,libraryReturnUrl:d,theme:h,name:m,renderCustomStats:g,onPaste:p,detectScroll:v=!0,handleKeyboardGlobally:y=!1,onLibraryChange:E,autoFocus:w=!1,generateIdForFile:x,onLinkOpen:C,onPointerDown:S,onPointerUp:I,onScrollChange:T,children:L,validateEmbeddable:A,renderEmbeddable:F,aiEnabled:P}=e,O=(G=e.UIOptions)==null?void 0:G.canvasActions,V={...e.UIOptions,canvasActions:{...cb.canvasActions,...O},tools:{image:((U=(q=e.UIOptions)==null?void 0:q.tools)==null?void 0:U.image)??!0}};return O!=null&&O.export&&(V.canvasActions.export.saveFileToDisk=(($=O.export)==null?void 0:$.saveFileToDisk)??cb.canvasActions.export.saveFileToDisk),V.canvasActions.toggleTheme===null&&typeof h>"u"&&(V.canvasActions.toggleTheme=!0),_.useEffect(()=>{(async()=>{await ie(()=>import("./roundRect-CCyChLky.js"),__vite__mapDeps([]))})();const R=N=>{typeof N.scale=="number"&&N.scale!==1&&N.preventDefault()};return document.addEventListener("touchmove",R,{passive:!1}),()=>{document.removeEventListener("touchmove",R)}},[]),f(Vv,{unstable_createStore:()=>_i,scope:en,children:f(IZ,{langCode:a,theme:h,children:f(Iw,{onChange:t,initialData:n,excalidrawAPI:r,isCollaborating:i,onPointerUpdate:o,renderTopRightUI:s,langCode:a,viewModeEnabled:l,zenModeEnabled:c,gridModeEnabled:u,libraryReturnUrl:d,theme:h,name:m,renderCustomStats:g,UIOptions:V,onPaste:p,detectScroll:v,handleKeyboardGlobally:y,onLibraryChange:E,autoFocus:w,generateIdForFile:x,onLinkOpen:C,onPointerDown:S,onPointerUp:I,onScrollChange:T,validateEmbeddable:A,renderEmbeddable:F,aiEnabled:P!==!1,children:L})})})},PZ=(e,t)=>{if(e.children!==t.children)return!1;const{initialData:n,UIOptions:r={},...i}=e,{initialData:o,UIOptions:s={},...a}=t,l=Object.keys(r),c=Object.keys(s);return l.length!==c.length?!1:l.every(d=>d==="canvasActions"?Object.keys(r.canvasActions).every(m=>{var g,p,v,y;return m==="export"&&((g=r==null?void 0:r.canvasActions)!=null&&g.export)&&((p=s==null?void 0:s.canvasActions)!=null&&p.export)?r.canvasActions.export.saveFileToDisk===s.canvasActions.export.saveFileToDisk:((v=r==null?void 0:r.canvasActions)==null?void 0:v[m])===((y=s==null?void 0:s.canvasActions)==null?void 0:y[m])}):r[d]===s[d])&&Jn(i,a)},bM=te.memo(LZ,PZ);bM.displayName="Excalidraw";const RZ=({canvasRef:e,setError:t})=>{const n=e.current;if(!n)return;const r=n.parentElement;r&&(r.style.background="",t(null),n.replaceChildren())},_M=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:n,setError:r,data:i})=>{const o=e.current,s=o==null?void 0:o.parentElement;if(!(!o||!s)){if(!n){RZ({canvasRef:e,setError:r});return}try{const a=await t.api;let l;try{l=await a.parseMermaidToExcalidraw(n,{fontSize:Xr})}catch{l=await a.parseMermaidToExcalidraw(n.replace(/"/g,"'"),{fontSize:Xr})}const{elements:c,files:u}=l;r(null),i.current={elements:wM(c,{regenerateIds:!0}),files:u};const d=await og({elements:i.current.elements,files:i.current.files,exportPadding:ac,maxWidthOrHeight:Math.max(s.offsetWidth,s.offsetHeight)*window.devicePixelRatio});try{await _d(d)}catch(h){throw h.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(b("canvasError.canvasTooBig")):h}s.style.background="var(--default-bg-color)",o.replaceChildren(d)}catch(a){throw s.style.background="var(--default-bg-color)",n&&r(a),a}}},pw=e=>{Si.set(qo.MERMAID_TO_EXCALIDRAW,e)},xM=({app:e,data:t,text:n,shouldSaveMermaidDataToStorage:r})=>{const{elements:i,files:o}=t.current;i.length&&(e.addElementsFromPasteOrLibrary({elements:i,files:o,position:"center",fitToContent:!0}),e.setOpenDialog(null),r&&n&&pw(n))},SM=({children:e})=>f("div",{className:"ttd-dialog-panels",children:e}),s1=({label:e,children:t,panelAction:n,panelActionDisabled:r=!1,onTextSubmitInProgess:i,renderTopRight:o,renderSubmitShortcut:s,renderBottomRight:a})=>k("div",{className:"ttd-dialog-panel",children:[k("div",{className:"ttd-dialog-panel__header",children:[f("label",{children:e}),o==null?void 0:o()]}),t,k("div",{className:se("ttd-dialog-panel-button-container",{invisible:!n}),style:{display:"flex",alignItems:"center"},children:[k(Fd,{className:"ttd-dialog-panel-button",onSelect:n?n.action:()=>{},disabled:r||i,children:[k("div",{className:se({invisible:i}),children:[n==null?void 0:n.label,(n==null?void 0:n.icon)&&f("span",{children:n.icon})]}),i&&f(to,{})]}),!r&&!i&&(s==null?void 0:s()),a==null?void 0:a()]})]}),kM=({input:e,placeholder:t,onChange:n,onKeyboardSubmit:r})=>{const i=_.useRef(null),o=_.useRef(r);return o.current=r,_.useEffect(()=>{if(!o.current)return;const s=i.current;if(s){const a=l=>{var c;l[D.CTRL_OR_CMD]&&l.key===D.ENTER&&(l.preventDefault(),(c=o.current)==null||c.call(o))};return s.addEventListener(Z.KEYDOWN,a),()=>{s.removeEventListener(Z.KEYDOWN,a)}}},[]),f("textarea",{className:"ttd-dialog-input",onChange:n,value:e,placeholder:t,autoFocus:!0,ref:i})},DZ=({error:e})=>k("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",f("p",{children:e})]}),IM=({error:e,canvasRef:t,loaded:n})=>k("div",{className:"ttd-dialog-output-wrapper",children:[e&&f(DZ,{error:e.message}),n?f("div",{ref:t,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):f(to,{size:"2rem"})]}),CM=()=>k("div",{className:"ttd-dialog-submit-shortcut",children:[f("div",{className:"ttd-dialog-submit-shortcut__key",children:K("CtrlOrCmd")}),f("div",{className:"ttd-dialog-submit-shortcut__key",children:K("Enter")})]}),OZ=`flowchart TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[Car]`,M4=fa(pw,300),NZ=({mermaidToExcalidrawLib:e})=>{const[t,n]=_.useState(()=>Si.get(qo.MERMAID_TO_EXCALIDRAW)||OZ),r=_.useDeferredValue(t.trim()),[i,o]=_.useState(null),s=_.useRef(null),a=_.useRef({elements:[],files:null}),l=xc();_.useEffect(()=>{_M({canvasRef:s,data:a,mermaidToExcalidrawLib:e,setError:o,mermaidDefinition:r}).catch(()=>{}),M4(r)},[r,e]),_.useEffect(()=>()=>{M4.flush()},[]);const c=()=>{xM({app:l,data:a,text:t,shouldSaveMermaidDataToStorage:!0})};return k(re,{children:[f("div",{className:"ttd-dialog-desc",children:f(On,{i18nKey:"mermaid.description",flowchartLink:u=>f("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:u}),sequenceLink:u=>f("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:u}),classLink:u=>f("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:u})})}),k(SM,{children:[f(s1,{label:b("mermaid.syntax"),children:f(kM,{input:t,placeholder:"Write Mermaid diagram defintion here...",onChange:u=>n(u.target.value),onKeyboardSubmit:()=>{c()}})}),f(s1,{label:b("mermaid.preview"),panelAction:{action:()=>{c()},label:b("mermaid.button"),icon:Vf},renderSubmitShortcut:()=>f(CM,{}),children:f(IM,{canvasRef:s,loaded:e.loaded,error:i})})]})]})},TM=({children:e,...t})=>f(V7,{className:"ttd-dialog-triggers",...t,children:e});TM.displayName="TTDDialogTabTriggers";const _y=({children:e,tab:t,onSelect:n,...r})=>f(G7,{value:t,asChild:!0,onSelect:n,children:f("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});_y.displayName="TTDDialogTabTrigger";const n0=3,Za=1e3,FZ=mt(null),$Z=mt(null),MM=e=>{var n;const t=mn();return((n=t.openDialog)==null?void 0:n.name)!=="ttd"?null:f(BZ,{...e,tab:t.openDialog.tab})},BZ=uh("TTDDialogBase",({tab:e,...t})=>{const n=xc(),r=Mn(),i=_.useRef(null),[o,s]=ze($Z),[a,l]=_.useState((o==null?void 0:o.prompt)??""),c=a.trim(),u=S=>{l(S.target.value),s(I=>({generatedResponse:(I==null?void 0:I.generatedResponse)??null,prompt:S.target.value}))},[d,h]=_.useState(!1),[m,g]=ze(FZ),p=async()=>{if(c.length>Za||c.length<n0||d||(m==null?void 0:m.rateLimitRemaining)===0||"__fallback"in t){c.length<n0&&C(new Error(`Prompt is too short (min ${n0} characters)`)),c.length>Za&&C(new Error(`Prompt is too long (max ${Za} characters)`));return}try{h(!0),Ae("ai","generate","ttd");const{generatedResponse:S,error:I,rateLimit:T,rateLimitRemaining:L}=await t.onTextSubmit(c);if(typeof S=="string"&&s(A=>({generatedResponse:S,prompt:(A==null?void 0:A.prompt)??null})),kb(T)&&kb(L)&&g({rateLimit:T,rateLimitRemaining:L}),I){C(I);return}if(!S){C(new Error("Generation failed"));return}try{await _M({canvasRef:i,data:w,mermaidToExcalidrawLib:y,setError:C,mermaidDefinition:S}),Ae("ai","mermaid parse success","ttd")}catch(A){console.info(`%cTTD mermaid render errror: ${A.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
TTD mermaid definition render errror: ${A.message}`,"color: yellow"),Ae("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let I=S.message;(!I||I==="Failed to fetch")&&(I="Request failed"),C(new Error(I))}finally{h(!1)}},v=_.useRef(p);v.current=p;const[y,E]=_.useState({loaded:!1,api:ie(()=>import("./index-jpNTxDe4.js").then(S=>S.aN),__vite__mapDeps([]))});_.useEffect(()=>{(async()=>{await y.api,E(I=>({...I,loaded:!0}))})()},[y.api]);const w=_.useRef({elements:[],files:null}),[x,C]=_.useState(null);return f(Vn,{className:"ttd-dialog",onCloseRequest:()=>{n.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:k(sw,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?f("p",{className:"dialog-mermaid-title",children:b("mermaid.title")}):k(TM,{children:[f(_y,{tab:"text-to-diagram",children:k("div",{style:{display:"flex",alignItems:"center"},children:[b("labels.textToDiagram"),f("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"pink",color:"#000"},children:"AI Beta"})]})}),f(_y,{tab:"mermaid",children:"Mermaid"})]}),f(o1,{className:"ttd-dialog-content",tab:"mermaid",children:f(NZ,{mermaidToExcalidrawLib:y})}),!("__fallback"in t)&&k(o1,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[f("div",{className:"ttd-dialog-desc",children:"Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar."}),k(SM,{children:[f(s1,{label:b("labels.prompt"),panelAction:{action:p,label:"Generate",icon:Vf},onTextSubmitInProgess:d,panelActionDisabled:c.length>Za||(m==null?void 0:m.rateLimitRemaining)===0,renderTopRight:()=>m?k("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:m.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[m.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>f(CM,{}),renderBottomRight:()=>{if(typeof(o==null?void 0:o.generatedResponse)=="string")return k("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof(o==null?void 0:o.generatedResponse)=="string"&&(pw(o.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",f(Zf,{icon:Vf})]});const S=c.length/Za;return S>.8?k("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",Za]}):null},children:f(kM,{onChange:u,input:a,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{v.current()}})}),f(s1,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),xM({app:n,data:w})},label:"Insert",icon:Vf},children:f(IM,{canvasRef:i,error:x,loaded:y.loaded})})]})]})]})})}),zZ=({UIOptions:e})=>k(Ne,{__fallback:!0,children:[f(Ne.DefaultItems.LoadScene,{}),f(Ne.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&f(Ne.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&f(Ne.DefaultItems.SaveAsImage,{}),f(Ne.DefaultItems.Help,{}),f(Ne.DefaultItems.ClearCanvas,{}),f(Ne.Separator,{}),f(Ne.Group,{title:"Excalidraw links",children:f(Ne.DefaultItems.Socials,{})}),f(Ne.Separator,{}),f(Ne.DefaultItems.ToggleTheme,{}),f(Ne.DefaultItems.ChangeCanvasBackground,{})]}),HZ=()=>k(Js,{__fallback:!0,children:[f(Js.Actions.SaveToDisk,{}),f(Js.Actions.ExportToImage,{})]}),UZ=({actionManager:e,appState:t,files:n,setAppState:r,elements:i,canvas:o,onLockToggle:s,onHandToolToggle:a,onPenModeToggle:l,showExitZenModeBtn:c,renderTopRightUI:u,renderCustomStats:d,UIOptions:h,onExportImage:m,renderWelcomeScreen:g,children:p,app:v,isCollaborating:y,openAIKey:E,isOpenAIKeyPersisted:w,onOpenAIAPIKeyChange:x,onMagicSettingsConfirm:C})=>{var $,Y,R;const S=gn(),I=AY(),[T,L]=ze(_g,en),A=()=>h.canvasActions.export?f(iK,{elements:i,appState:t,files:n,actionManager:e,exportOpts:h.canvasActions.export,canvas:o,setAppState:r}):null,F=()=>{var N;return!h.canvasActions.saveAsImage||((N=t.openDialog)==null?void 0:N.name)!=="imageExport"?null:f(BY,{elements:i,appState:t,files:n,actionManager:e,onExportImage:m,onCloseRequest:()=>r({openDialog:null}),name:v.getName()})},P=()=>k("div",{style:{position:"relative"},children:[f(I.MainMenuTunnel.Out,{}),g&&f(I.WelcomeScreenMenuHintTunnel.Out,{})]}),O=()=>f(Nd,{heading:"selectedShapeActions",className:se("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:f(Yr,{className:zS.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:f(b7,{appState:t,elementsMap:v.scene.getNonDeletedElementsMap(),renderAction:e.renderAction})})}),V=()=>{var B,z;const N=DE(t,i);return f(x7,{side:"top",children:k("div",{className:"App-menu App-menu_top",children:[k(gr.Col,{gap:6,className:se("App-menu_top__left"),children:[P(),N&&O()]}),!t.viewModeEnabled&&f(Nd,{heading:"shapes",className:"shapes-section",children:W=>k("div",{style:{position:"relative"},children:[g&&f(I.WelcomeScreenToolbarHintTunnel.Out,{}),f(gr.Col,{gap:4,align:"start",children:k(gr.Row,{gap:1,className:se("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[k(Yr,{padding:1,className:se("App-toolbar",{"zen-mode":t.zenModeEnabled}),children:[f(S7,{appState:t,isMobile:S.editor.isMobile,device:S,app:v}),W,k(gr.Row,{gap:1,children:[f(C7,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>l(null),title:b("toolBar.penMode"),penDetected:t.penDetected}),f(I7,{checked:t.activeTool.locked,onChange:s,title:b("toolBar.lock")}),f("div",{className:"App-toolbar__divider"}),f(M7,{checked:Vl(t),onChange:()=>a(),title:b("toolBar.hand"),isMobile:!0}),f(_7,{appState:t,activeTool:t.activeTool,UIOptions:h,app:v})]})]}),y&&f(Yr,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:f(SZ,{title:b("toolBar.laser"),checked:t.activeTool.type===zt.laser,onChange:()=>v.setActiveTool({type:zt.laser}),isMobile:!0})})]})})]})}),k("div",{className:se("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&f(A7,{collaborators:t.collaborators,userToFollow:((B=t.userToFollow)==null?void 0:B.socketId)||null}),u==null?void 0:u(S.editor.isMobile,t),!t.viewModeEnabled&&(!q||((z=t.openSidebar)==null?void 0:z.name)!==Tl.name)&&f(I.DefaultSidebarTriggerTunnel.Out,{})]})]})})},G=()=>f(i1,{__fallback:!0,onDock:N=>{Ae("sidebar",`toggleDock (${N?"dock":"undock"})`,`(${S.editor.isMobile?"mobile":"desktop"})`)}}),q=Gl(nw,en),U=k(re,{children:[p,f(zZ,{UIOptions:h}),f(i1.Trigger,{__fallback:!0,icon:rH,title:Mf(b("toolBar.library")),onToggle:N=>{N&&Ae("sidebar",`${Tl.name} (open)`,`button (${S.editor.isMobile?"mobile":"desktop"})`)},tab:Tl.defaultTab,children:b("toolBar.library")}),f(HZ,{}),(($=t.openDialog)==null?void 0:$.name)==="ttd"&&f(MM,{__fallback:!0}),t.isLoading&&f(k7,{delay:250}),t.errorMessage&&f(Cw,{onClose:()=>r({errorMessage:null}),children:t.errorMessage}),T&&!S.editor.isMobile&&f(VG,{colorPickerType:T.colorPickerType,onCancel:()=>{L(null)},onChange:(N,B,z,{altKey:W})=>{var j;if(!(N!=="elementBackground"&&N!=="elementStroke"))if(z.length){for(const X of z)J(X,{[W&&T.swapPreviewOnAlt?N==="elementBackground"?"strokeColor":"backgroundColor":N==="elementBackground"?"backgroundColor":"strokeColor"]:B},!1),Xe.delete(X);(j=$t.getScene(z[0]))==null||j.informMutation()}else r(N==="elementBackground"?{currentItemBackgroundColor:B}:{currentItemStrokeColor:B})},onSelect:(N,B)=>{var z;L(W=>W!=null&&W.keepOpenOnAlt&&B.altKey?W:null),(z=T==null?void 0:T.onSelect)==null||z.call(T,N,B)}}),((Y=t.openDialog)==null?void 0:Y.name)==="help"&&f(QY,{onClose:()=>{r({openDialog:null})}}),((R=t.openDialog)==null?void 0:R.name)==="settings"&&f(kZ,{openAIKey:E,isPersisted:w,onChange:x,onConfirm:(N,B)=>{var W,j;const z=((W=t.openDialog)==null?void 0:W.name)==="settings"?(j=t.openDialog)==null?void 0:j.source:"settings";r({openDialog:null},()=>{C(N,B,z)})},onClose:()=>{r({openDialog:null})}}),f(EZ,{}),f(I.OverwriteConfirmDialogTunnel.Out,{}),F(),A(),t.pasteDialog.shown&&f(jY,{setAppState:r,appState:t,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),S.editor.isMobile&&f(GY,{app:v,appState:t,elements:i,actionManager:e,renderJSONExportDialog:A,renderImageExportDialog:F,setAppState:r,onLockToggle:s,onHandToolToggle:a,onPenModeToggle:l,renderTopRightUI:u,renderCustomStats:d,renderSidebars:G,device:S,renderWelcomeScreen:g,UIOptions:h}),!S.editor.isMobile&&k(re,{children:[k("div",{className:"layer-ui__wrapper",style:t.openSidebar&&q&&S.editor.canFitSidebar?{width:`calc(100% - ${vR}px)`}:{},children:[g&&f(I.WelcomeScreenCenterTunnel.Out,{}),V(),f(L7,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:g}),t.showStats&&f(T7,{appState:t,setAppState:r,elements:i,onClose:()=>{e.executeAction(e1)},renderCustomStats:d}),t.scrolledOutside&&f("button",{className:"scroll-back-to-content",onClick:()=>{r(N=>({...Ld(i,N)}))},children:b("buttons.scrollBackToContent")})]}),G()]})]});return f(N8.Provider,{value:t,children:f(Vv,{scope:I.jotaiScope,children:f(w7.Provider,{value:I,children:U})})})},A4=e=>{const{suggestedBindings:t,startBoundElement:n,cursorButton:r,scrollX:i,scrollY:o,...s}=e;return s},WZ=(e,t)=>{if(e.children!==t.children)return!1;const{canvas:n,appState:r,...i}=e,{canvas:o,appState:s,...a}=t;return Jn(A4(r),A4(s),{selectedElementIds:Jn,selectedGroupIds:Jn})&&Jn(i,a)},VZ=te.memo(UZ,WZ),GZ=5e3,jZ=({message:e,onClose:t,closable:n=!1,duration:r=GZ,style:i})=>{const o=_.useRef(0),s=r!==1/0,a=_.useCallback(()=>{s&&(o.current=window.setTimeout(()=>t(),r))},[t,r,s]);return _.useEffect(()=>{if(s)return a(),()=>clearTimeout(o.current)},[a,e,r,s]),k("div",{className:"Toast",onMouseEnter:s?()=>clearTimeout(o==null?void 0:o.current):void 0,onMouseLeave:s?a:void 0,style:i,children:[f("p",{className:"Toast__message",children:e}),n&&f(Ce,{icon:yc,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})},L4=ne({name:"viewMode",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},commitToHistory:!1}},checked:e=>e.viewModeEnabled,predicate:(e,t,n)=>typeof n.viewModeEnabled>"u",contextItemLabel:"labels.viewMode",keyTest:e=>!e[D.CTRL_OR_CMD]&&e.altKey&&e.code===De.R}),Gu=class Gu{constructor({scene:t,onSceneUpdated:n}){M(this,"scene");M(this,"onSceneUpdated");M(this,"onFontsLoaded",t=>{if(t.every(r=>{const i=`${r.family}-${r.style}-${r.weight}`;return Gu.loadedFontFaces.has(i)?!0:(Gu.loadedFontFaces.add(i),!1)}))return!1;let n=!1;this.scene.mapElements(r=>ce(r)&&!Mt(r)?(Xe.delete(r),n=!0,ge(r,{...hE(r,kn(r,this.scene.getNonDeletedElementsMap()),this.scene.getNonDeletedElementsMap())})):r),n&&this.onSceneUpdated()});M(this,"loadFontsForElements",async t=>{const n=await Promise.all([...new Set(t.filter(r=>ce(r)).map(r=>r.fontFamily))].map(r=>{var o,s,a,l;const i=Bt({fontFamily:r,fontSize:16});if(!((s=(o=document.fonts)==null?void 0:o.check)!=null&&s.call(o,i)))return(l=(a=document.fonts)==null?void 0:a.load)==null?void 0:l.call(a,i)}));this.onFontsLoaded(n.flat().filter(Boolean))});this.scene=t,this.onSceneUpdated=n}};M(Gu,"loadedFontFaces",new Set);let xy=Gu;const AM=(e,t)=>{const n=t.scene.getSelectedElements(e);return n.length===1&&pe(n[0])},YZ=ne({name:"selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,n,r)=>{const i=r.scene.getSelectedElements(t).at(0)||null;if(pe(i)){const o=eo(je(e),i.id).filter(s=>!(s.type==="text"&&s.containerId));return{elements:e,appState:{...t,selectedElementIds:o.reduce((s,a)=>(s[a.id]=!0,s),{})},commitToHistory:!1}}return{elements:e,appState:t,commitToHistory:!1}},contextItemLabel:"labels.selectAllElementsInFrame",predicate:(e,t,n,r)=>AM(t,r)}),KZ=ne({name:"removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,n,r)=>{const i=r.scene.getSelectedElements(t).at(0)||null;return pe(i)?{elements:TT(e,i),appState:{...t,selectedElementIds:{[i.id]:!0}},commitToHistory:!0}:{elements:e,appState:t,commitToHistory:!1}},contextItemLabel:"labels.removeAllElementsFromFrame",predicate:(e,t,n,r)=>AM(t,r)});ne({name:"updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},commitToHistory:!1}),contextItemLabel:"labels.updateFrameRendering",checked:e=>e.frameRendering.enabled});ne({name:"setFrameAsActiveTool",trackEvent:{category:"toolbar"},perform:(e,t,n,r)=>{const i=bt(t,{type:"frame"});return di(r.interactiveCanvas,{...t,activeTool:i}),{elements:e,appState:{...t,activeTool:bt(t,{type:"frame"})},commitToHistory:!1}},keyTest:e=>!e[D.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===D.F});const ZZ=8,P4=99999,Mg=e=>ZZ/e,pn=class pn{};M(pn,"referenceSnapPoints",null),M(pn,"visibleGaps",null),M(pn,"setReferenceSnapPoints",t=>{pn.referenceSnapPoints=t}),M(pn,"getReferenceSnapPoints",()=>pn.referenceSnapPoints),M(pn,"setVisibleGaps",t=>{pn.visibleGaps=t}),M(pn,"getVisibleGaps",()=>pn.visibleGaps),M(pn,"destroy",()=>{pn.referenceSnapPoints=null,pn.visibleGaps=null});let $r=pn;const ms=({event:e,appState:t,selectedElements:n})=>e?t.objectsSnapModeEnabled&&!e[D.CTRL_OR_CMD]||!t.objectsSnapModeEnabled&&e[D.CTRL_OR_CMD]&&t.gridSize===null:n.length===1&&n[0].type==="arrow"?!1:t.objectsSnapModeEnabled,XZ=(e,t,n=.01)=>Math.abs(e-t)<=n,$d=(e,t,{omitCenter:n,boundingBoxCorners:r,dragOffset:i}={omitCenter:!1,boundingBoxCorners:!1})=>{let o=[];if(e.length===1){const s=e[0];let[a,l,c,u,d,h]=Ee(s,t);i&&(a+=i.x,c+=i.x,d+=i.x,l+=i.y,u+=i.y,h+=i.y);const m=(c-a)/2,g=(u-l)/2;if((s.type==="diamond"||s.type==="ellipse")&&!r){const p=st([a,l+g],[d,h],s.angle),v=st([a+m,l],[d,h],s.angle),y=st([c,l+g],[d,h],s.angle),E=st([a+m,u],[d,h],s.angle);o=n?[p,v,y,E]:[p,v,y,E,[d,h]]}else{const p=st([a,l],[d,h],s.angle),v=st([c,l],[d,h],s.angle),y=st([a,u],[d,h],s.angle),E=st([c,u],[d,h],s.angle);o=n?[p,v,y,E]:[p,v,y,E,[d,h]]}}else if(e.length>1){const[s,a,l,c]=uE(e,i??{x:0,y:0}),u=l-s,d=c-a,h=[s,a],m=[l,a],g=[s,c],p=[l,c],v=[s+u/2,a+d/2];o=n?[h,m,g,p]:[h,m,g,p,v]}return o.map(s=>[at(s[0]),at(s[1])])},LM=(e,t,n,r)=>{const i=t.filter(o=>pe(o)).map(o=>o.id);return WT(e,t,n,r).filter(o=>!(o.frameId&&i.includes(o.frameId)))},qZ=(e,t,n,r)=>{const i=LM(e,t,n,r),o=X1(i,r).filter(d=>!(d.length===1&&Mt(d[0]))).map(d=>nt(d).map(h=>at(h))),s=o.sort((d,h)=>d[0]-h[0]),a=[];let l=0;e:for(let d=0;d<s.length;d++){const h=s[d];for(let m=d+1;m<s.length;m++){if(++l>P4)break e;const g=s[m],[,p,v,y]=h,[E,w,,x]=g;v<E&&Tm([p,y],[w,x])&&a.push({startBounds:h,endBounds:g,startSide:[[v,p],[v,y]],endSide:[[E,w],[E,x]],length:E-v,overlap:Mm([p,y],[w,x])})}}const c=o.sort((d,h)=>d[1]-h[1]),u=[];l=0;e:for(let d=0;d<c.length;d++){const h=c[d];for(let m=d+1;m<c.length;m++){if(++l>P4)break e;const g=c[m],[p,,v,y]=h,[E,w,x]=g;y<w&&Tm([p,v],[E,x])&&u.push({startBounds:h,endBounds:g,startSide:[[p,y],[v,y]],endSide:[[E,w],[x,w]],length:w-y,overlap:Mm([p,v],[E,x])})}}return{horizontalGaps:a,verticalGaps:u}},R4=(e,t,n,r,i,o,s)=>{if(!ms({appState:n,event:r,selectedElements:e}))return[];if(e.length===0)return[];const a=$r.getVisibleGaps();if(a){const{horizontalGaps:l,verticalGaps:c}=a,[u,d,h,m]=uE(e,t).map(v=>at(v)),g=(u+h)/2,p=(d+m)/2;for(const v of l){if(!Tm([d,m],v.overlap))continue;const y=v.startSide[0][0]+v.length/2,E=at(y-g);if(v.length>h-u&&Math.abs(E)<=s.x){Math.abs(E)<s.x&&(i.length=0),s.x=Math.abs(E);const A={type:"gap",direction:"center_horizontal",gap:v,offset:E};i.push(A);continue}const[,,x]=v.endBounds,C=u-x,S=at(v.length-C);if(Math.abs(S)<=s.x){Math.abs(S)<s.x&&(i.length=0),s.x=Math.abs(S);const A={type:"gap",direction:"side_right",gap:v,offset:S};i.push(A);continue}const[I,,,]=v.startBounds,T=I-h,L=at(T-v.length);if(Math.abs(L)<=s.x){Math.abs(L)<s.x&&(i.length=0),s.x=Math.abs(L);const A={type:"gap",direction:"side_left",gap:v,offset:L};i.push(A);continue}}for(const v of c){if(!Tm([u,h],v.overlap))continue;const y=v.startSide[0][1]+v.length/2,E=at(y-p);if(v.length>m-d&&Math.abs(E)<=s.y){Math.abs(E)<s.y&&(o.length=0),s.y=Math.abs(E);const A={type:"gap",direction:"center_vertical",gap:v,offset:E};o.push(A);continue}const[,x,,]=v.startBounds,C=x-m,S=at(C-v.length);if(Math.abs(S)<=s.y){Math.abs(S)<s.y&&(o.length=0),s.y=Math.abs(S);const A={type:"gap",direction:"side_top",gap:v,offset:S};o.push(A);continue}const[,,,I]=v.endBounds,T=at(d-I),L=v.length-T;if(Math.abs(L)<=s.y){Math.abs(L)<s.y&&(o.length=0),s.y=Math.abs(L);const A={type:"gap",direction:"side_bottom",gap:v,offset:L};o.push(A);continue}}}},QZ=(e,t,n,r)=>{const i=LM(e,t,n,r);return X1(i,r).filter(o=>!(o.length===1&&Mt(o[0]))).flatMap(o=>$d(o,r))},ec=(e,t,n,r,i,o,s)=>{if(!ms({appState:n,event:r,selectedElements:e})||e.length===0&&t.length===0)return[];const a=$r.getReferenceSnapPoints();if(a)for(const l of t)for(const c of a){const u=c[0]-l[0],d=c[1]-l[1];Math.abs(u)<=s.x&&(Math.abs(u)<s.x&&(i.length=0),i.push({type:"point",points:[l,c],offset:u}),s.x=Math.abs(u)),Math.abs(d)<=s.y&&(Math.abs(d)<s.y&&(o.length=0),o.push({type:"point",points:[l,c],offset:d}),s.y=Math.abs(d))}},JZ=(e,t,n,r,i)=>{var p,v;const o=qe(e,n);if(!ms({appState:n,event:r,selectedElements:o})||o.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=at(t.x),t.y=at(t.y);const s=[],a=[],l=Mg(n.zoom.value),c={x:l,y:l},u=$d(o,i,{dragOffset:t});ec(o,u,n,r,s,a,c),R4(o,t,n,r,s,a,c);const d={x:((p=s[0])==null?void 0:p.offset)??0,y:((v=a[0])==null?void 0:v.offset)??0};c.x=0,c.y=0,s.length=0,a.length=0;const h={x:at(t.x+d.x),y:at(t.y+d.y)};ec(o,$d(o,i,{dragOffset:h}),n,r,s,a,c),R4(o,h,n,r,s,a,c);const m=yw(s,a),g=tX(o,h,[...s,...a].filter(y=>y.type==="gap"));return{snapOffset:d,snapLines:[...m,...g]}},at=e=>Math.round(e*10**6)/10**6,D4=e=>{const t=new Map;for(const n of e){const r=n.join(",");t.has(r)||t.set(r,n)}return Array.from(t.values())},yw=(e,t)=>{const n={},r={};if(e.length>0){for(const i of e)if(i.type==="point"){const o=at(i.points[0][0]);n[o]||(n[o]=[]),n[o].push(...i.points.map(s=>[at(s[0]),at(s[1])]))}}if(t.length>0){for(const i of t)if(i.type==="point"){const o=at(i.points[0][1]);r[o]||(r[o]=[]),r[o].push(...i.points.map(s=>[at(s[0]),at(s[1])]))}}return Object.entries(n).map(([i,o])=>({type:"points",points:D4(o.map(s=>[Number(i),s[1]]).sort((s,a)=>s[1]-a[1]))})).concat(Object.entries(r).map(([i,o])=>({type:"points",points:D4(o.map(s=>[s[0],Number(i)]).sort((s,a)=>s[0]-a[0]))})))},eX=e=>{const t=new Map;for(const n of e){const r=n.points.flat().map(i=>[at(i)]).join(",");t.has(r)||t.set(r,n)}return Array.from(t.values())},tX=(e,t,n)=>{const[r,i,o,s]=uE(e,t),a=[];for(const l of n){const[c,u,d,h]=l.gap.startBounds,[m,g,p,v]=l.gap.endBounds,y=Mm([i,s],l.gap.overlap),E=Mm([r,o],l.gap.overlap);switch(l.direction){case"center_horizontal":{if(y){const w=(y[0]+y[1])/2;a.push({type:"gap",direction:"horizontal",points:[[l.gap.startSide[0][0],w],[r,w]]},{type:"gap",direction:"horizontal",points:[[o,w],[l.gap.endSide[0][0],w]]})}break}case"center_vertical":{if(E){const w=(E[0]+E[1])/2;a.push({type:"gap",direction:"vertical",points:[[w,l.gap.startSide[0][1]],[w,i]]},{type:"gap",direction:"vertical",points:[[w,s],[w,l.gap.endSide[0][1]]]})}break}case"side_right":{if(y){const w=(y[0]+y[1])/2;a.push({type:"gap",direction:"horizontal",points:[[d,w],[m,w]]},{type:"gap",direction:"horizontal",points:[[p,w],[r,w]]})}break}case"side_left":{if(y){const w=(y[0]+y[1])/2;a.push({type:"gap",direction:"horizontal",points:[[o,w],[c,w]]},{type:"gap",direction:"horizontal",points:[[d,w],[m,w]]})}break}case"side_top":{if(E){const w=(E[0]+E[1])/2;a.push({type:"gap",direction:"vertical",points:[[w,s],[w,u]]},{type:"gap",direction:"vertical",points:[[w,h],[w,g]]})}break}case"side_bottom":{if(E){const w=(E[0]+E[1])/2;a.push({type:"gap",direction:"vertical",points:[[w,h],[w,g]]},{type:"gap",direction:"vertical",points:[[w,v],[w,i]]})}break}}}return eX(a.map(l=>({...l,points:l.points.map(c=>[at(c[0]),at(c[1])])})))},nX=(e,t,n,r,i,o)=>{var S,I;if(!ms({event:r,selectedElements:e,appState:n})||e.length===0||e.length===1&&!XZ(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[s,a,l,c]=nt(t);o&&(o.includes("e")?l+=i.x:o.includes("w")&&(s+=i.x),o.includes("n")?a+=i.y:o.includes("s")&&(c+=i.y));const u=[];if(o)switch(o){case"e":{u.push([l,a],[l,c]);break}case"w":{u.push([s,a],[s,c]);break}case"n":{u.push([s,a],[l,a]);break}case"s":{u.push([s,c],[l,c]);break}case"ne":{u.push([l,a]);break}case"nw":{u.push([s,a]);break}case"se":{u.push([l,c]);break}case"sw":{u.push([s,c]);break}}const d=Mg(n.zoom.value),h={x:d,y:d},m=[],g=[];ec(t,u,n,r,m,g,h);const p={x:((S=m[0])==null?void 0:S.offset)??0,y:((I=g[0])==null?void 0:I.offset)??0};h.x=0,h.y=0,m.length=0,g.length=0;const[v,y,E,w]=nt(e).map(T=>at(T));ec(e,[[v,y],[v,w],[E,y],[E,w]],n,r,m,g,h);const C=yw(m,g);return{snapOffset:p,snapLines:C}},rX=(e,t,n,r,i,o)=>{var g,p;if(!ms({event:n,selectedElements:[e],appState:t}))return{snapOffset:{x:0,y:0},snapLines:[]};const s=[[r.x+i.x,r.y+i.y]],a=Mg(t.zoom.value),l={x:a,y:a},c=[],u=[];ec([e],s,t,n,c,u,l);const d={x:((g=c[0])==null?void 0:g.offset)??0,y:((p=u[0])==null?void 0:p.offset)??0};l.x=0,l.y=0,c.length=0,u.length=0;const h=$d([e],o,{boundingBoxCorners:!0,omitCenter:!0});ec([e],h,t,n,c,u,l);const m=yw(c,u);return{snapOffset:d,snapLines:m}},iX=(e,t,n,r,i)=>{if(!ms({event:r,selectedElements:[],appState:t}))return{originOffset:{x:0,y:0},snapLines:[]};const o=WT(e,[],t,i),s=Mg(t.zoom.value),a={x:s,y:s},l=[],c=[];for(const u of o){const d=$d([u],i);for(const h of d){const m=h[0]-n.x;Math.abs(m)<=Math.abs(a.x)&&(Math.abs(m)<Math.abs(a.x)&&(c.length=0),c.push({type:"pointer",points:[h,[h[0],n.y]],direction:"vertical"}),a.x=m);const g=h[1]-n.y;Math.abs(g)<=Math.abs(a.y)&&(Math.abs(g)<Math.abs(a.y)&&(l.length=0),l.push({type:"pointer",points:[h,[n.x,h[1]]],direction:"horizontal"}),a.y=g)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-n.x:0,y:l.length>0?l[0].points[0][1]-n.y:0},snapLines:[...c,...l]}},oX=e=>e===zt.rectangle||e===zt.ellipse||e===zt.diamond||e===zt.frame||e===zt.magicframe||e===zt.image,sX=()=>k("div",{"data-testid":"brave-measure-text-error",children:[f("p",{children:f(On,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>f("span",{style:{fontWeight:600},children:e})})}),f("p",{children:f(On,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>f("span",{style:{fontWeight:600},children:e})})}),f("p",{children:f(On,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>f("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),f("p",{children:f(On,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>f("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>k("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Je=e=>t=>{nr.unstable_batchedUpdates(e,t)},r0=e=>F1(t=>{nr.unstable_batchedUpdates(e,t)}),PM=(()=>{let e;try{const n=_.version.split(".");e=Number(n[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})(),aX="#ff6b6b",lX="#ff0000",O4=1,N4=2,cX=(e,t)=>{if(!t.snapLines.length)return;const n=t.theme==="light"||t.zenModeEnabled?aX:lX,r=(t.zenModeEnabled?O4*1.5:O4)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(const i of t.snapLines)i.type==="pointer"?(e.lineWidth=r,e.strokeStyle=n,dX(i,e,t)):i.type==="gap"?(e.lineWidth=r,e.strokeStyle=n,hX(i.points[0],i.points[1],i.direction,t,e)):i.type==="points"&&(e.lineWidth=r,e.strokeStyle=n,uX(i,e,t));e.restore()},uX=(e,t,n)=>{if(!n.zenModeEnabled){const r=e.points[0],i=e.points[e.points.length-1];lr(r,i,t)}for(const r of e.points)RM(r,n,t)},dX=(e,t,n)=>{RM(e.points[0],n,t),n.zenModeEnabled||lr(e.points[0],e.points[1],t)},RM=([e,t],n,r)=>{r.save();const i=(n.zenModeEnabled?N4*1.5:N4)/n.zoom.value;r.beginPath(),r.moveTo(e-i,t-i),r.lineTo(e+i,t+i),r.moveTo(e+i,t-i),r.lineTo(e-i,t+i),r.stroke(),r.restore()},lr=(e,t,n)=>{n.beginPath(),n.lineTo(...e),n.lineTo(...t),n.stroke()},hX=(e,t,n,r,i)=>{const o=8/r.zoom.value,s=o/2,a=o/4;if(n==="horizontal"){const l=[(e[0]+t[0])/2,e[1]];r.zenModeEnabled||lr([e[0],e[1]-o],[e[0],e[1]+o],i),lr([l[0]-a,l[1]-s],[l[0]-a,l[1]+s],i),lr([l[0]+a,l[1]-s],[l[0]+a,l[1]+s],i),r.zenModeEnabled||(lr([t[0],t[1]-o],[t[0],t[1]+o],i),lr(e,t,i))}else{const l=[e[0],(e[1]+t[1])/2];r.zenModeEnabled||lr([e[0]-o,e[1]],[e[0]+o,e[1]],i),lr([l[0]-s,l[1]-a],[l[0]+s,l[1]-a],i),lr([l[0]-s,l[1]+a],[l[0]+s,l[1]+a],i),r.zenModeEnabled||(lr([t[0]-o,t[1]],[t[0]+o,t[1]],i),lr(e,t,i))}},fX=(e,t,n)=>{var a,l;const{elementId:r,hoverPointIndex:i}=t.selectedLinearElement;if((l=(a=t.editingLinearElement)==null?void 0:a.selectedPointsIndices)!=null&&l.includes(i))return;const o=ue.getElement(r,n);if(!o)return;const s=ue.getPointAtIndexGlobalCoordinates(o,i,n);e.save(),e.translate(t.scrollX,t.scrollY),Sy(s,e,t),e.restore()},Sy=(e,t,n)=>{t.fillStyle="rgba(105, 101, 219, 0.4)",Q1(t,e[0],e[1],ue.POINT_HANDLE_SIZE/n.zoom.value,!1)},hh=(e,t,n,r,i,o,s,a,l=!1,c=0)=>{e.save(),e.translate(o,s),e.rotate(a),l&&e.fillRect(t-o,n-s,r,i),c&&e.roundRect?(e.beginPath(),e.roundRect(t-o,n-s,r,i,c),e.stroke(),e.closePath()):e.strokeRect(t-o,n-s,r,i),e.restore()},mX=(e,t,n,r,i,o)=>{e.save(),e.translate(r,i),e.rotate(o),e.beginPath(),e.moveTo(0,n/2),e.lineTo(t/2,0),e.lineTo(0,-n/2),e.lineTo(-t/2,0),e.closePath(),e.stroke(),e.restore()},of=(e,t,n,r,i,o=!1)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",i?e.fillStyle="rgba(134, 131, 226, 0.9)":o&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Q1(e,n[0],n[1],r/t.zoom.value,!o)},gX=(e,t,n,r,i,o)=>{e.beginPath(),e.ellipse(r,i,t/2,n/2,o,0,Math.PI*2),e.stroke()},pX=(e,t,n)=>{const[r,i,o,s]=Ee(t,n),a=o-r,l=s-i,c=W1(t,a,l),u=4;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=c-u;const d=u/2+c/2;switch(t.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":hh(e,r-d,i-d,a+d*2,l+d*2,r+a/2,i+l/2,t.angle);break;case"diamond":const h=Math.hypot(a,l),m=d*h/l,g=d*h/a;mX(e,a+m*2,l+g*2,r+a/2,i+l/2,t.angle);break;case"ellipse":gX(e,a+d*2,l+d*2,r+a/2,i+l/2,t.angle);break}},yX=(e,t,n)=>{const[r,i,o]=t,s=W1(o,o.width,o.height);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(l=>{const[c,u]=ue.getPointAtIndexGlobalCoordinates(r,l,n);Q1(e,c,u,s)})},DM=(e,t,n,r=ud*2)=>{const{angle:i,elementX1:o,elementY1:s,elementX2:a,elementY2:l,selectionColors:c,cx:u,cy:d,dashed:h,activeEmbeddable:m}=n,g=a-o,p=l-s,v=r/t.zoom.value,y=8/t.zoom.value,E=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(m?4:1)/t.zoom.value;const w=c.length;for(let x=0;x<w;++x)e.strokeStyle=c[x],h&&e.setLineDash([y,E+(y+E)*(w-1)]),e.lineDashOffset=(y+E)*x,hh(e,o-v,s-v,g+v*2,p+v*2,u,d,i);e.restore()},vX=(e,t,n,r)=>{const i=Array.isArray(n)?yX:pX;e.save(),e.translate(t.scrollX,t.scrollY),i(e,n,r),e.restore()},EX=(e,t,n,r)=>{const[i,o,s,a]=Ee(n,r),l=s-i,c=a-o;e.strokeStyle="rgb(0,118,255)",e.lineWidth=vt.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),hh(e,i,o,l,c,i+l/2,o+c/2,n.angle,!1,vt.radius/t.zoom.value),e.restore()},wX=(e,t,n)=>{const r=n.filter(a=>a.groupIds.length===0),i=n.filter(a=>a.groupIds.length>0),o=a=>{const[l,c,u,d]=nt(a);return{angle:0,elementX1:l,elementX2:u,elementY1:c,elementY2:d,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:l+(u-l)/2,cy:c+(d-c)/2,activeEmbeddable:!1}},s=a=>{const l=It(n,a);return o(l)};Object.entries(NI(i,t)).filter(([a,l])=>l).map(([a,l])=>a).map(a=>s(a)).concat(r.map(a=>o([a]))).forEach(a=>DM(e,t,a))},i0=(e,t,n,r)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;const i=ue.getPointsGlobalCoordinates(n,r),{POINT_HANDLE_SIZE:o}=ue,s=t.editingLinearElement?o:o/2;i.forEach((l,c)=>{var d,h;const u=!!((h=(d=t.editingLinearElement)==null?void 0:d.selectedPointsIndices)!=null&&h.includes(c));of(e,t,l,s,u)}),ue.getEditorMidPoints(n,r,t).filter(l=>l!==null).forEach(l=>{var c;(c=t==null?void 0:t.selectedLinearElement)!=null&&c.segmentMidPointHoveredCoords&&ue.arePointsEqual(l,t.selectedLinearElement.segmentMidPointHoveredCoords)?t.editingLinearElement?(of(e,t,l,s,!1),Sy(l,e,t)):(Sy(l,e,t),of(e,t,l,s,!1)):(t.editingLinearElement||i.length===2)&&of(e,t,l,o/2,!1,!0)}),e.restore()},F4=(e,t,n,r,i)=>{Object.keys(r).forEach(o=>{const s=r[o];if(s!==void 0){const[a,l,c,u]=s;e.save(),e.lineWidth=1/n.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),o==="rotation"?Q1(e,a+c/2,l+u/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(a,l,c,u,2/n.zoom.value),e.fill(),e.stroke()):hh(e,a,l,c,u,a+c/2,l+u/2,i,!0),e.restore()}})},OM=({canvas:e,elementsMap:t,visibleElements:n,selectedElements:r,scale:i,appState:o,renderConfig:s})=>{var m,g,p;if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};const[a,l]=lC(e,i),c=cC({canvas:e,scale:i,normalizedWidth:a,normalizedHeight:l});c.save(),c.scale(o.zoom.value,o.zoom.value);let u;if(n.forEach(v=>{var y;((y=o.editingLinearElement)==null?void 0:y.elementId)===v.id&&v&&(u=v)}),u&&i0(c,o,u,t),o.selectionElement)try{Pz(o.selectionElement,c,o)}catch(v){console.error(v)}o.isBindingEnabled&&o.suggestedBindings.filter(v=>v!=null).forEach(v=>{vX(c,o,v,t)}),o.frameToHighlight&&EX(c,o,o.frameToHighlight,t),o.elementsToHighlight&&wX(c,o,o.elementsToHighlight);const d=r.some(v=>pe(v));if(r.length===1&&((m=o.editingLinearElement)==null?void 0:m.elementId)===r[0].id&&i0(c,o,r[0],t),o.selectedLinearElement&&o.selectedLinearElement.hoverPointIndex>=0&&fX(c,o,t),!o.multiElement&&!o.editingLinearElement){const v=nE(r,o);r.length===1&&we(r[0])&&((g=o.selectedLinearElement)==null?void 0:g.elementId)===r[0].id&&!r[0].locked&&i0(c,o,r[0],t);const E=s.selectionColor||Ut.black;if(v){const w=be(r),x=[];for(const S of t.values()){const I=[];w.has(S.id)&&!DI(o,S)&&I.push(E);const T=s.remoteSelectedElementIds.get(S.id);if(T&&I.push(...T.map(L=>Cg(L,o.collaborators.get(L)))),I.length){const[L,A,F,P,O,V]=Ee(S,t,!0);x.push({angle:S.angle,elementX1:L,elementY1:A,elementX2:F,elementY2:P,selectionColors:I,dashed:!!T,cx:O,cy:V,activeEmbeddable:((p=o.activeEmbeddable)==null?void 0:p.element)===S&&o.activeEmbeddable.state==="active"})}}const C=S=>{const I=It(t,S),[T,L,A,F]=nt(I);x.push({angle:0,elementX1:T,elementX2:A,elementY1:L,elementY2:F,selectionColors:[Ut.black],dashed:!0,cx:T+(A-T)/2,cy:L+(F-L)/2,activeEmbeddable:!1})};for(const S of Ml(o))C(S);o.editingGroupId&&C(o.editingGroupId),x.forEach(S=>DM(c,o,S))}if(c.save(),c.translate(o.scrollX,o.scrollY),r.length===1){c.fillStyle=Ut.white;const w=mI(r[0],o.zoom,t,"mouse");!o.viewModeEnabled&&v&&F4(c,s,o,w,r[0].angle)}else if(r.length>1&&!o.isRotating){const w=ud*2/o.zoom.value;c.fillStyle=Ut.white;const[x,C,S,I]=nt(r),T=c.getLineDash();c.setLineDash([2/o.zoom.value]);const L=c.lineWidth;c.lineWidth=1/o.zoom.value,c.strokeStyle=E,hh(c,x-w,C-w,S-x+w*2,I-C+w*2,(x+S)/2,(C+I)/2,0),c.lineWidth=L,c.setLineDash(T);const A=tE([x,C,S,I,(x+S)/2,(C+I)/2],0,o.zoom,"mouse",d?mO:fI);r.some(F=>!F.locked)&&F4(c,s,o,A,0)}c.restore()}cX(c,o),c.restore(),mj({context:c,renderConfig:s,appState:o,normalizedWidth:a,normalizedHeight:l});let h;return s.renderScrollbars&&(h=WY(n,a,l,o),c.save(),c.fillStyle=UY,c.strokeStyle="rgba(255,255,255,0.8)",[h.horizontal,h.vertical].forEach(v=>{v&&Y8(c,v.x,v.y,v.width,v.height,Ho/2)}),c.restore()),{scrollBars:h,atLeastOneVisibleElement:n.length>0,elementsMap:t}},NM=F1(e=>{var n;const t=OM(e);(n=e.callback)==null||n.call(e,t)},{trailing:!0}),bX=(e,t)=>{if(t){NM(e);return}const n=OM(e);return e.callback(n),n},_X=e=>{const t=_.useRef(!1);return _.useEffect(()=>{var l;if(!t.current){t.current=!0;return}const n=new Map,r=new Map,i=new Map,o=new Map,s=new Map;e.appState.collaborators.forEach((c,u)=>{if(c.selectedElementIds)for(const d of Object.keys(c.selectedElementIds))i.has(d)||i.set(d,[]),i.get(d).push(u);!c.pointer||c.pointer.renderCursor===!1||(c.username&&o.set(u,c.username),c.userState&&s.set(u,c.userState),r.set(u,Ur({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),n.set(u,c.button))});const a=((l=e.containerRef)==null?void 0:l.current)&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";bX({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:n,remoteSelectedElementIds:i,remotePointerUsernames:o,remotePointerUserStates:s,selectionColor:a,renderScrollbars:!1},callback:e.renderInteractiveSceneCallback},PM())}),f("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Be.GRAB:Be.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:b("labels.drawingCanvas")})},$4=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,editingGroupId:e.editingGroupId,editingLinearElement:e.editingLinearElement,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled}),xX=(e,t)=>e.selectionNonce!==t.selectionNonce||e.versionNonce!==t.versionNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements?!1:Jn($4(e.appState),$4(t.appState)),SX=te.memo(_X,xX),kX=e=>{const t=_.useRef(null),n=_.useRef(!1);return _.useEffect(()=>{const r=t.current;if(!r)return;const i=e.canvas;n.current||(n.current=!0,r.replaceChildren(i),i.classList.add("excalidraw__canvas","static"));const o=`${e.appState.width}px`,s=`${e.appState.height}px`;i.style.width!==o&&(i.style.width=o),i.style.height!==s&&(i.style.height=s);const a=e.appState.width*e.scale,l=e.appState.height*e.scale;i.width!==a&&(i.width=a),i.height!==l&&(i.height=l),hC({canvas:i,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},PM())}),f("div",{className:"excalidraw__canvas-wrapper",ref:t})},B4=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId}),IX=(e,t)=>e.versionNonce!==t.versionNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:Jn(B4(e.appState),B4(t.appState))&&Jn(e.renderConfig,t.renderConfig),CX=te.memo(kX,IX);class z4{constructor(t){M(this,"scene");M(this,"getRenderableElements",(()=>{const t=({elementsMap:r,zoom:i,offsetLeft:o,offsetTop:s,scrollX:a,scrollY:l,height:c,width:u})=>{const d=[];for(const h of r.values())jm(h,u,c,{zoom:i,offsetLeft:o,offsetTop:s,scrollX:a,scrollY:l},r)&&d.push(h);return d},n=({elements:r,editingElement:i,pendingImageElementId:o})=>{const s=ma(new Map);for(const a of r)Gi(a)&&o===a.id||(!i||i.type!=="text"||a.id!==i.id)&&s.set(a.id,a);return s};return LD(({zoom:r,offsetLeft:i,offsetTop:o,scrollX:s,scrollY:a,height:l,width:c,editingElement:u,pendingImageElementId:d,versionNonce:h})=>{const m=this.scene.getNonDeletedElements(),g=n({elements:m,editingElement:u,pendingImageElementId:d}),p=t({elementsMap:g,zoom:r,offsetLeft:i,offsetTop:o,scrollX:s,scrollY:a,height:l,width:c});return{elementsMap:g,visibleElements:p}})})());this.scene=t}destroy(){NM.cancel(),dC.cancel(),this.getRenderableElements.clear()}}const TX=({trails:e})=>{const t=_.useRef(null);return _.useEffect(()=>{if(t.current)for(const n of e)n.start(t.current);return()=>{for(const n of e)n.stop()}},e),f("div",{className:"SVGLayer",children:f("svg",{ref:t})})},MX=5,AX=(e,t,n)=>{const[r,i]=Ee(e,n),{x:o,y:s}=Ur({sceneX:r+e.width,sceneY:i},t),a=o-t.offsetLeft+10,l=s-t.offsetTop;return{x:a,y:l}},H4=({children:e,element:t,elementsMap:n})=>{const r=kw();if(r.contextMenu||r.draggingElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;const{x:i,y:o}=AX(t,r,n);return f("div",{className:"excalidraw-canvas-buttons",style:{top:`${o}px`,left:`${i}px`,padding:MX},children:e})},LX=`You are a skilled front-end developer who builds interactive prototypes from wireframes, and is an expert at CSS Grid and Flex design.
Your role is to transform low-fidelity wireframes into working front-end HTML code.
YOU MUST FOLLOW FOLLOWING RULES:
- Use HTML, CSS, JavaScript to build a responsive, accessible, polished prototype
- Leverage Tailwind for styling and layout (import as script <script src="https://cdn.tailwindcss.com"><\/script>)
- Inline JavaScript when needed
- Fetch dependencies from CDNs when needed (using unpkg or skypack)
- Source images from Unsplash or create applicable placeholders
- Interpret annotations as intended vs literal UI
- Fill gaps using your expertise in UX and business logic
- generate primarily for desktop UI, but make it responsive.
- Use grid and flexbox wherever applicable.
- Convert the wireframe in its entirety, don't omit elements if possible.
If the wireframes, diagrams, or text is unclear or unreadable, refer to provided text for clarification.
Your goal is a production-ready prototype that brings the wireframes to life.
Please output JUST THE HTML file containing your best attempt at implementing the provided wireframes.`;async function PX({image:e,apiKey:t,text:n,theme:r="light"}){const i={model:"gpt-4-vision-preview",max_tokens:4096,temperature:.1,messages:[{role:"system",content:LX},{role:"user",content:[{type:"image_url",image_url:{url:e,detail:"high"}},{type:"text",text:`Above is the reference wireframe. Please make a new website based on these and return just the HTML file. Also, please make it for the ${r} theme. What follows are the wireframe's text annotations (if any)...`},{type:"text",text:n}]}]};let o;const s=await fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(i)});return s.ok?o={...await s.json(),ok:!0}:o={...await s.json(),ok:!1},o}const RX="small",o0=e=>k("label",{className:se("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${RX}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[f("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),f("div",{className:"ToolIcon__icon",children:e.icon})]}),DX=({height:e,width:t,userToFollow:n,onDisconnect:r})=>f("div",{className:"follow-mode",style:{width:t,height:e},children:k("div",{className:"follow-mode__badge",children:[k("div",{className:"follow-mode__badge__label",children:["Following"," ",f("span",{className:"follow-mode__badge__username",title:n.username,children:n.username})]}),f("button",{onClick:r,className:"follow-mode__disconnect-btn",children:yc})]})});class OX{constructor(){M(this,"targets",new WeakMap);M(this,"rafIds",new WeakMap)}register(t,n){this.targets.set(t,{callback:n,stopped:!0})}start(t){const n=this.targets.get(t);n&&(this.rafIds.has(t)||(this.targets.set(t,{...n,stopped:!1}),this.scheduleFrame(t)))}stop(t){const n=this.targets.get(t);n&&!n.stopped&&this.targets.set(t,{...n,stopped:!0}),this.cancelFrame(t)}constructFrame(t){return n=>{const r=this.targets.get(t);if(!r)return;const i=this.onFrame(r,n);!r.stopped&&!i?this.scheduleFrame(t):this.cancelFrame(t)}}scheduleFrame(t){const n=requestAnimationFrame(this.constructFrame(t));this.rafIds.set(t,n)}cancelFrame(t){if(this.rafIds.has(t)){const n=this.rafIds.get(t);cancelAnimationFrame(n)}this.rafIds.delete(t)}onFrame(t,n){return t.callback(n)??!1}}function NX(e,t,n,r){Object.defineProperty(e,t,{get:n,set:r,enumerable:!0,configurable:!0})}var FX={};NX(FX,"LaserPointer",()=>l1);function pt([e,t,n],[r,i,o]){return[e+r,t+i,n+o]}function mu([e,t,n],[r,i,o]){return[e-r,t-i,n-o]}function St([e,t,n],r){return[e*r,t*r,n*r]}function Xa([e,t,n]){return[e/Math.sqrt(e**2+t**2),t/Math.sqrt(e**2+t**2),n]}function on([e,t,n],r){return[Math.cos(r)*e-Math.sin(r)*t,Math.sin(r)*e+Math.cos(r)*t,n]}function $X(e,t,n){return pt(e,St(mu(t,e),n))}function U4(e,t,n){return Math.atan2(n[1]-e[1],n[0]-e[0])-Math.atan2(t[1]-e[1],t[0]-e[0])}function W4(e){return Math.atan2(Math.sin(e),Math.cos(e))}function V4([e,t]){return Math.sqrt(e**2+t**2)}function Ol([e,t],[n,r]){return Math.sqrt((n-e)**2+(r-t)**2)}function BX(e){if(e.length<2)return 0;let t=0;for(let n=1;n<=e.length-1;n++)t+=Ol(e[n-1],e[n]);return t+=Ol(e[e.length-2],e[e.length-1]),t}const zX=(e,t,n)=>Math.max(t,Math.min(n,e));function HX(e,t,n){const r=Ol(t,n);if(r===0)return Ol(e,t);const i=zX(((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r**2,0,1),o=[t[0]+i*(n[0]-t[0]),t[1]+i*(n[1]-t[1]),e[2]];return Ol(o,e)}function a1(e,t){if(t===0||e.length<=2)return e;const n=e[0],r=e[e.length-1],[i,o]=e.reduce(([s,a],l,c)=>{const u=HX(l,n,r);return u>s?[u,c]:[s,a]},[0,-1]);if(i>=t){const s=e[o];return[...a1([n,...e.slice(1,o),s],t).slice(0,-1),s,...a1([s,...e.slice(o,-1),r],t).slice(1)]}else return[n,r]}const xo=class xo{constructor(t){this.originalPoints=[],this.stablePoints=[],this.tailPoints=[],this.isFresh=!0,this.options=Object.assign({},xo.defaults,t)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(t){const n=this.originalPoints[this.originalPoints.length-1];if(!(n&&n[0]===t[0]&&n[1]===t[1])){if(this.originalPoints.push(t),this.isFresh){this.isFresh=!1,this.stablePoints.push(t);return}this.options.streamline>0&&(t=$X(this.lastPoint,t,1-this.options.streamline)),this.tailPoints.push(t),BX(this.tailPoints)>xo.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase=="tail")throw new Error("Not implemented yet");this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(t,n,r,i,o){return(t??this.options.size)*this.options.sizeMapping({pressure:n,runningLength:o,currentIndex:r,totalLength:i})}getStrokeOutline(t){if(this.isFresh)return[];let n=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase==="input"&&(n=a1(n,this.options.simplify));const r=n.length;if(r===0)return[];if(r===1){const I=n[0],T=this.getSize(t,I[2],0,r,0);if(T<.5)return[];const L=[];for(let A=0;A<=Math.PI*2;A+=Math.PI/16)L.push(pt(I,St(on([1,0,0],A),T)));return L.push(pt(I,St([1,0,0],this.getSize(t,I[2],0,r,0)))),L}if(r===2){const I=n[0],T=n[1],L=this.getSize(t,I[2],0,r,0),A=this.getSize(t,T[2],0,r,0);if(L<.5||A<.5)return[];const F=[],P=U4(I,[I[0],I[1]-100,I[2]],T);for(let O=P;O<=Math.PI+P;O+=Math.PI/16)F.push(pt(I,St(on([1,0,0],O),L)));for(let O=Math.PI+P;O<=Math.PI*2+P;O+=Math.PI/16)F.push(pt(T,St(on([1,0,0],O),A)));return F.push(F[0]),F}const i=[],o=[];let s=0,a=0,l=0,c=0;for(let I=1;I<r-1;I++){const T=n[I-1],L=n[I],A=n[I+1];let F=L[2];const P=Ol(T,L);c+=P,s=a+(P-a)*.2;const O=this.getSize(t,F,I,r,c);if(O===0){l=I+1;continue}const V=Xa(mu(T,L)),G=Xa(mu(A,L)),q=on(V,Math.PI/2),U=on(V,-Math.PI/2),$=on(G,Math.PI/2),Y=on(G,-Math.PI/2),R=pt(L,St(q,O)),N=pt(L,St(U,O)),B=pt(L,St($,O)),z=pt(L,St(Y,O)),W=pt(q,Y),j=pt(U,$),X=pt(L,St(V4(W)===0?V:Xa(W),O)),ee=pt(L,St(V4(j)===0?G:Xa(j),O)),xe=W4(U4(L,T,A)),Fe=xo.constants.cornerDetectionMaxAngle/180*Math.PI*xo.constants.cornerDetectionVariance(s);if(Math.abs(xe)<Fe){const Se=Math.abs(W4(Math.PI-xe));if(Se===0)continue;if(xe<0){o.push(N,ee);for(let Me=0;Me<=Se;Me+=Se/4)i.push(pt(L,on(St(q,O),Me)));for(let Me=Se;Me>=0;Me-=Se/4)o.push(pt(L,on(St(q,O),Me)));o.push(ee,B)}else{i.push(R,X);for(let Me=0;Me<=Se;Me+=Se/4)o.push(pt(L,on(St(q,-O),-Me)));for(let Me=Se;Me>=0;Me-=Se/4)i.push(pt(L,on(St(q,-O),-Me)));i.push(X,z)}}else i.push(X),o.push(ee);a=s}if(l>=r-2)if(this.options.keepHead){const I=n[r-1],T=[];for(let L=0;L<=Math.PI*2;L+=Math.PI/16)T.push(pt(I,St(on([1,0,0],L),this.options.size)));return T.push(pt(I,St([1,0,0],this.options.size))),T}else return[];const u=n[l],d=n[l+1],h=n[r-2],m=n[r-1],g=Xa(mu(d,u)),p=Xa(mu(h,m)),v=on(g,-Math.PI/2),y=on(p,Math.PI/2),E=this.getSize(t,u[2],0,r,0),w=[],x=this.options.keepHead?this.options.size:this.getSize(t,h[2],r-2,r,c),C=[];if(E>1){for(let I=0;I<=Math.PI;I+=Math.PI/16)w.unshift(pt(u,on(St(v,E),-I)));w.unshift(pt(u,St(v,-E)))}else w.push(u);for(let I=0;I<=Math.PI*3;I+=Math.PI/16)C.push(pt(m,on(St(y,-x),-I)));const S=[...w,...i,...C.reverse(),...o.reverse()];return w.length>0&&S.push(w[0]),this.options.simplify>0&&this.options.simplifyPhase==="output"?a1(S,this.options.simplify):S}};xo.defaults={size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1},xo.constants={cornerDetectionMaxAngle:75,cornerDetectionVariance:t=>t>35?.5:1,maxTailLength:50};let l1=xo;class ky{constructor(t,n,r){M(this,"currentTrail");M(this,"pastTrails",[]);M(this,"container");M(this,"trailElement");this.animationFrameHandler=t,this.app=n,this.options=r,this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Ke,"path")}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(t,n){if(this.currentTrail){const r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===t&&this.currentTrail.originalPoints[r-1][1]===n}return!1}start(t){t&&(this.container=t),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){var t;this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&((t=this.container)==null||t.removeChild(this.trailElement))}startPath(t,n){this.currentTrail=new l1(this.options),this.currentTrail.addPoint([t,n,performance.now()]),this.update()}addPointToPath(t,n){this.currentTrail&&(this.currentTrail.addPoint([t,n,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}update(){this.start()}onFrame(){const t=[];for(const r of this.pastTrails)t.push(this.drawTrail(r,this.app.state));if(this.currentTrail){const r=this.drawTrail(this.currentTrail,this.app.state);t.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),t.length===0&&this.stop();const n=t.join(" ").trim();this.trailElement.setAttribute("d",n),this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(t,n){const r=t.getStrokeOutline(t.options.size/n.zoom.value).map(([i,o])=>{const s=Ur({sceneX:i,sceneY:o},n);return[s.x,s.y]});return PD(r,!0)}}class UX{constructor(t,n){M(this,"localTrail");M(this,"collabTrails",new Map);M(this,"container");this.animationFrameHandler=t,this.app=n,this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new ky(t,n,{...this.getTrailOptions(),fill:()=>rR})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:t=>{const i=Math.max(0,1-(performance.now()-t.pressure)/1e3),o=(50-Math.min(50,t.totalLength-t.currentIndex))/50;return Math.min(ra(o),ra(i))}}}startPath(t,n){this.localTrail.startPath(t,n)}addPointToPath(t,n){this.localTrail.addPointToPath(t,n)}endPath(){this.localTrail.endPath()}start(t){this.container=t,this.animationFrameHandler.start(this),this.localTrail.start(t)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(const[t,n]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(t)?r=this.collabTrails.get(t):(r=new ky(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>{var i;return((i=n.pointer)==null?void 0:i.laserColor)||Cg(t,n)}}),r.start(this.container),this.collabTrails.set(t,r)),n.pointer&&n.pointer.tool==="laser"&&(n.button==="down"&&!r.hasCurrentTrail&&r.startPath(n.pointer.x,n.pointer.y),n.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(n.pointer.x,n.pointer.y)&&r.addPointToPath(n.pointer.x,n.pointer.y),n.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(n.pointer.x,n.pointer.y),r.endPath()))}for(const t of this.collabTrails.keys())this.app.state.collaborators.has(t)||(this.collabTrails.get(t).stop(),this.collabTrails.delete(t))}}}const WX=(e,t,n,r,i,o)=>{const{zoom:s}=r,a=180*n/Math.PI;let l=e*(s.value-1)/2,c=t*(s.value-1)/2;return e>i&&s.value!==1&&(l=i*(s.value-1)/2),t>o&&s.value!==1&&(c=o*(s.value-1)/2),`translate(${l}px, ${c}px) scale(${s.value}) rotate(${a}deg)`},VX=({id:e,onChange:t,onSubmit:n,getViewportCoords:r,element:i,canvas:o,excalidrawContainer:s,app:a})=>{const l=(P,O)=>{if(!O.style.fontFamily||!O.style.fontSize)return!1;const V=O.style.fontFamily.replace(/"/g,"");return Zv({fontFamily:P.fontFamily})!==V||`${P.fontSize}px`!==O.style.fontSize},c=()=>{var U;const P=a.state,O=(U=$t.getScene(i))==null?void 0:U.getElement(e);if(!O)return;const{textAlign:V,verticalAlign:G}=O,q=a.scene.getNonDeletedElementsMap();if(O&&ce(O)){let $=O.x,Y=O.y;const R=kn(O,a.scene.getNonDeletedElementsMap());let N=O.width,B=O.height,z=O.width;const W=O.height;if(R&&O.containerId){if(Ge(R)){const it=ue.getBoundTextElementPosition(R,O,q);$=it.x,Y=it.y}const Me=l(O,u);let Et;if(Me?Et=Om(R.id,R.height):(Et=Xl[R.id],Et||(Et=Om(R.id,R.height))),N=Ii(R,O),B=eh(R,O),!Ge(R)&&W>B){const it=Ea(W,R.type);J(R,{height:it});return}else if(!Ge(R)&&R.height>Et.height&&W<B){const it=Ea(W,R.type);J(R,{height:it})}else{const{y:it}=Y1(R,O,q);Y=it}}const[j,X]=r($,Y),ee=u.selectionStart,xe=u.selectionEnd,Fe=u.value.length;if(ee===xe&&xe!==Fe){const Me=Fe-xe;u.selectionStart=u.value.length-Me,u.selectionEnd=u.value.length-Me}R||(N=(P.width-8-j)/P.zoom.value,z=Math.min(z,N));const Se=(P.height-X)/P.zoom.value;Object.assign(u.style,{font:Bt(O),lineHeight:O.lineHeight,width:`${z}px`,height:`${W}px`,left:`${j}px`,top:`${X}px`,transform:WX(z,W,eN(O,R),P,N,Se),textAlign:V,verticalAlign:G,color:O.strokeColor,opacity:O.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Se}px`}),u.scrollTop=0,J(O,{x:$,y:Y})}},u=document.createElement("textarea");u.dir="auto",u.tabIndex=0,u.dataset.type="wysiwyg",u.wrap="off",u.classList.add("excalidraw-wysiwyg");let d="pre",h="normal";Mt(i)&&(d="pre-wrap",h="break-word"),Object.assign(u.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:h,whiteSpace:d,overflowWrap:"break-word",boxSizing:"content-box"}),u.value=i.originalText,c(),t&&(u.onpaste=async P=>{const O=await vT(P,!0);if(!O.text)return;const V=wd(O.text);if(!V)return;const G=kn(i,a.scene.getNonDeletedElementsMap()),q=Bt({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(G){const U=ke(G,a.scene.getNonDeletedElementsMap()),$=Jd(`${u.value}${V}`,q,Ii(G,U)),Y=K1($,q);u.style.width=`${Y}px`}},u.oninput=()=>{t(wd(u.value))}),u.onkeydown=P=>{if(!P.shiftKey&&Y6.keyTest(P))P.preventDefault(),a.actionManager.executeAction(Y6),c();else if(!P.shiftKey&&K6.keyTest(P))P.preventDefault(),a.actionManager.executeAction(K6),c();else if(V6.keyTest(P))a.actionManager.executeAction(V6);else if(G6.keyTest(P))a.actionManager.executeAction(G6);else if(P.key===D.ESCAPE)P.preventDefault(),x=!0,C();else if(P.key===D.ENTER&&P[D.CTRL_OR_CMD]){if(P.preventDefault(),P.isComposing||P.keyCode===229)return;x=!0,C()}else if(P.key===D.TAB||P[D.CTRL_OR_CMD]&&(P.code===De.BRACKET_LEFT||P.code===De.BRACKET_RIGHT)){if(P.preventDefault(),P.isComposing)return;P.shiftKey||P.code===De.BRACKET_LEFT?y():v(),u.dispatchEvent(new Event("input"))}};const m=4,g=" ".repeat(m),p=new RegExp(`^ {1,${m}}`),v=()=>{const{selectionStart:P,selectionEnd:O}=u,V=E();let G=u.value;V.forEach(q=>{const U=G.slice(0,q),$=G.slice(q);G=`${U}${g}${$}`}),u.value=G,u.selectionStart=P+m,u.selectionEnd=O+m*V.length},y=()=>{const{selectionStart:P,selectionEnd:O}=u,V=E(),G=[];let q=u.value;V.forEach(U=>{const $=q.slice(U,U+m).match(p);if($){const Y=q.slice(0,U),R=q.slice(U+$[0].length);q=`${Y}${R}`,G.push(U)}}),u.value=q,G.length&&(P>G[G.length-1]?u.selectionStart=Math.max(P-m,G[G.length-1]):u.selectionStart=P,u.selectionEnd=Math.max(u.selectionStart,O-m*G.length))},E=()=>{let{selectionStart:P,selectionEnd:O,value:V}=u;const G=V.slice(0,P).match(/[^\n]*$/)[0].length;return P=P-G,V.slice(P,O).split(`
`).reduce((U,$,Y,R)=>U.concat(Y?U[Y-1]+R[Y-1].length+1:P),[]).reverse()},w=P=>{P.preventDefault(),P.stopPropagation()};let x=!1;const C=()=>{var G,q;S();const P=(G=$t.getScene(i))==null?void 0:G.getElement(i.id);if(!P)return;let O=u.value;const V=kn(P,a.scene.getNonDeletedElementsMap());if(V){if(O=P.text,u.value.trim()){const U=va(V);!U||U!==i.id?J(V,{boundElements:(V.boundElements||[]).concat({type:"text",id:i.id})}):Ge(V)&&pc(V)}else J(V,{boundElements:(q=V.boundElements)==null?void 0:q.filter(U=>!ce(U))});Mi(P,V,a.scene.getNonDeletedElementsMap())}n({text:O,viaKeyboard:x,originalText:u.value})},S=()=>{A||(A=!0,u.onblur=null,u.oninput=null,u.onkeydown=null,F&&F.disconnect(),window.removeEventListener("resize",c),window.removeEventListener("wheel",w,!0),window.removeEventListener("pointerdown",T),window.removeEventListener("pointerup",I),window.removeEventListener("blur",C),window.removeEventListener("beforeunload",C),L(),u.remove())},I=P=>{window.removeEventListener("pointerup",I);const O=P==null?void 0:P.target,V=O instanceof HTMLElement&&O.classList.contains("active-color");setTimeout(()=>{if(u.onblur=C,V){const G=(U,$)=>{U.find(R=>{var N;return R.removedNodes.length>0&&((N=R.removedNodes[0].dataset)==null?void 0:N.radixPopperContentWrapper)!==void 0})&&(setTimeout(()=>{u.focus()}),$.disconnect())};new MutationObserver(G).observe(document.querySelector(".excalidraw-container"),{childList:!0})}V||u.focus()})},T=P=>{const O=P.target instanceof HTMLElement&&P.target.classList.contains("active-color");((P.target instanceof HTMLElement||P.target instanceof SVGElement)&&P.target.closest(`.${zS.SHAPE_ACTIONS_MENU}`)&&!Ns(P.target)||O)&&(u.onblur=null,window.addEventListener("pointerup",I),window.addEventListener("blur",C))},L=$t.getScene(i).addCallback(()=>{var O;c(),!!((O=document.activeElement)!=null&&O.closest(".color-picker-content"))||u.focus()});let A=!1;u.select(),I();let F=null;o&&"ResizeObserver"in window?(F=new window.ResizeObserver(()=>{c()}),F.observe(o)):window.addEventListener("resize",c),window.addEventListener("pointerdown",T),window.addEventListener("wheel",w,{passive:!1,capture:!0}),window.addEventListener("beforeunload",C),s==null||s.querySelector(".excalidraw-textEditorContainer").appendChild(u)},FM=te.createContext(null),$M=te.createContext(null),BM={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},vw=te.createContext(BM);vw.displayName="DeviceContext";const Ew=te.createContext({container:null,id:null});Ew.displayName="ExcalidrawContainerContext";const ww=te.createContext([]);ww.displayName="ExcalidrawElementsContext";const bw=te.createContext({...qr(),width:0,height:0,offsetLeft:0,offsetTop:0});bw.displayName="ExcalidrawAppStateContext";const _w=te.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});_w.displayName="ExcalidrawSetAppStateContext";const xw=te.createContext(null);xw.displayName="ExcalidrawActionManagerContext";const xc=()=>_.useContext(FM),Sw=()=>_.useContext($M),gn=()=>_.useContext(vw),uo=()=>_.useContext(Ew),Ag=()=>_.useContext(ww),kw=()=>_.useContext(bw),Mn=()=>_.useContext(_w),Cr=()=>_.useContext(xw);let Zc=!1,s0=0,Ss=!1,Xc=!1,a0=!1,l0={horizontal:null,vertical:null},mo=0,qc=!1;const c0=new Map;let sf=!1,G4=0,j4=!1,ks=null;const Pe={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null};class Iw extends te.Component{constructor(n){super(n);M(this,"canvas");M(this,"interactiveCanvas",null);M(this,"rc");M(this,"unmounted",!1);M(this,"actionManager");M(this,"device",BM);M(this,"excalidrawContainerRef",te.createRef());M(this,"scene");M(this,"renderer");M(this,"fonts");M(this,"resizeObserver");M(this,"nearestScrollableContainer");M(this,"library");M(this,"libraryItemsFromStorage");M(this,"id");M(this,"history");M(this,"excalidrawContainerValue");M(this,"files",{});M(this,"imageCache",new Map);M(this,"iFrameRefs",new Map);M(this,"embedsValidationStatus",new Map);M(this,"initializedEmbeds",new Set);M(this,"elementsPendingErasure",new Set);M(this,"hitLinkElement");M(this,"lastPointerDownEvent",null);M(this,"lastPointerUpEvent",null);M(this,"lastPointerMoveEvent",null);M(this,"lastViewportPosition",{x:0,y:0});M(this,"animationFrameHandler",new OX);M(this,"laserTrails",new UX(this.animationFrameHandler,this));M(this,"eraserTrail",new ky(this.animationFrameHandler,this,{streamline:.2,size:5,keepHead:!0,sizeMapping:n=>{const o=Math.max(0,1-(performance.now()-n.pressure)/200),s=(10-Math.min(10,n.totalLength-n.currentIndex))/10;return Math.min(ra(s),ra(o))},fill:()=>this.state.theme===Tt.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"}));M(this,"onChangeEmitter",new yo);M(this,"onPointerDownEmitter",new yo);M(this,"onPointerUpEmitter",new yo);M(this,"onUserFollowEmitter",new yo);M(this,"onScrollChangeEmitter",new yo);M(this,"missingPointerEventCleanupEmitter",new yo);M(this,"onRemoveEventListenersEmitter",new yo);M(this,"updateEmbedValidationStatus",(n,r)=>{this.embedsValidationStatus.set(n.id,r),Xe.delete(n)});M(this,"updateEmbeddables",()=>{const n=new Set;let r=!1;this.scene.getNonDeletedElements().filter(i=>{if(bn(i)){if(n.add(i.id),!this.embedsValidationStatus.has(i.id)){r=!0;const o=Rf(i.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(i,o)}}else Io(i)&&n.add(i.id);return!1}),r&&this.scene.informMutation(),this.iFrameRefs.forEach((i,o)=>{n.has(o)||this.iFrameRefs.delete(o)})});M(this,"getFrameNameDOMId",n=>`${this.id}-frame-name-${n.id}`);M(this,"frameNameBoundsCache",{get:n=>{let r=this.frameNameBoundsCache._cache.get(n.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==n.versionNonce){const i=document.getElementById(this.getFrameNameDOMId(n));if(i){const o=i.getBoundingClientRect(),s=et({clientX:o.x,clientY:o.y},this.state),a=et({clientX:o.right,clientY:o.bottom},this.state);return r={x:s.x,y:s.y,width:a.x-s.x,height:a.y-s.y,angle:0,zoom:this.state.zoom.value,versionNonce:n.versionNonce},this.frameNameBoundsCache._cache.set(n.id,r),r}return null}return r},_cache:new Map});M(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return null;const n=this.state.theme==="dark";let r=0,i=0;return this.scene.getNonDeletedFramesLikes().map(o=>{if(pd(o)?r++:i++,!jm(o,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return null;const{x:s,y:a}=Ur({sceneX:o.x,sceneY:o.y},this.state),l=6,c=()=>{var h;J(o,{name:((h=o.name)==null?void 0:h.trim())||null}),this.setState({editingFrame:null})};let u;const d=AT(o,pd(o)?r:i);if(o.id===this.state.editingFrame){const h=d;u=f("input",{autoFocus:!0,value:h,onChange:m=>{J(o,{name:m.target.value})},onFocus:m=>m.target.select(),onBlur:()=>c(),onKeyDown:m=>{(m.key===D.ESCAPE||m.key===D.ENTER)&&c()},style:{background:this.state.viewBackgroundColor,filter:n?$v:"none",zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:`translate(-${l}px, ${l}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-s-l}px`},size:h.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else u=d;return f("div",{id:this.getFrameNameDOMId(o),style:{position:"absolute",bottom:`${this.state.height+vt.nameOffsetY-a+this.state.offsetTop}px`,left:`${s-this.state.offsetLeft}px`,zIndex:2,fontSize:vt.nameFontSize,color:n?vt.nameColorDarkTheme:vt.nameColorLightTheme,lineHeight:vt.nameLineHeight,width:"max-content",maxWidth:`${o.width}px`,overflow:o.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Be.MOVE,pointerEvents:this.state.viewModeEnabled?Ms.disabled:Ms.enabled},onPointerDown:h=>this.handleCanvasPointerDown(h),onWheel:h=>this.handleWheel(h),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:o.id})},children:u},o.id)})});M(this,"focusContainer",()=>{var n;(n=this.excalidrawContainerRef.current)==null||n.focus()});M(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());M(this,"getSceneElements",()=>this.scene.getNonDeletedElements());M(this,"onInsertElements",n=>{this.addElementsFromPasteOrLibrary({elements:n,position:"center",files:null})});M(this,"onExportImage",async(n,r,i)=>{Ae("export",n,"ui");const o=await kg(n,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:i.exportingFrame}).catch(Gk).catch(s=>{console.error(s),this.setState({errorMessage:s.message})});this.state.exportEmbedScene&&o&&mE(o)&&this.setState({fileHandle:o})});M(this,"magicGenerations",new Map);M(this,"updateMagicGeneration",({frameElement:n,data:r})=>{r.status==="pending"?J(n,{customData:{generationData:void 0}},!1):J(n,{customData:{generationData:r}},!1),this.magicGenerations.set(n.id,r),this.onSceneUpdated()});M(this,"OPENAI_KEY",Si.get(qo.OAI_API_KEY));M(this,"OPENAI_KEY_IS_PERSISTED",Si.has(qo.OAI_API_KEY)||!1);M(this,"onOpenAIKeyChange",(n,r)=>{if(this.OPENAI_KEY=n||null,r){const i=Si.set(qo.OAI_API_KEY,n);this.OPENAI_KEY_IS_PERSISTED=i}else this.OPENAI_KEY_IS_PERSISTED=!1});M(this,"onMagicSettingsConfirm",(n,r,i)=>{if(this.OPENAI_KEY=n||null,this.onOpenAIKeyChange(this.OPENAI_KEY,r),i==="settings")return;const o=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});n?o.length?this.onMagicframeToolSelect():this.setActiveTool({type:"magicframe"}):uu(o[0])||this.setActiveTool({type:"magicframe"})});M(this,"onMagicframeToolSelect",()=>{if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"tool"}}),Ae("ai","tool-select (missing key)","d2c");return}const n=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(n.length===0)this.setActiveTool({type:zt.magicframe}),Ae("ai","tool-select (empty-selection)","d2c");else{const r=n.length===1&&uu(n[0])&&n[0];if(!r&&n.some(o=>pe(o)||o.frameId)){this.setActiveTool({type:zt.magicframe});return}Ae("ai","tool-select (existing selection)","d2c");let i;if(r)i=r;else{const[o,s,a,l]=nt(n),c=50;i=$2({...vt,x:o-c,y:s-c,width:a-o+c*2,height:l-s+c*2,opacity:100,locked:!1}),this.scene.addNewElement(i);for(const u of n)J(u,{frameId:i.id});this.setState({selectedElementIds:{[i.id]:!0}})}this.onMagicFrameGenerate(i,"upstream")}});M(this,"openEyeDropper",({type:n})=>{_i.set(_g,{swapPreviewOnAlt:!0,colorPickerType:n==="stroke"?"elementStroke":"elementBackground",onSelect:(r,i)=>{const o=n==="background"&&i.altKey||n==="stroke"&&!i.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?o?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},commitToHistory:!0}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},commitToHistory:!0}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(a=>this.state.selectedElementIds[a.id]?ge(a,{[o?"strokeColor":"backgroundColor"]:r}):a)})},keepOpenOnAlt:!1})});M(this,"syncActionResult",Je(n=>{var i,o,s,a,l,c,u;if(this.unmounted||n===!1)return;let r=null;if(n.elements&&(n.elements.forEach(d=>{var h;((h=this.state.editingElement)==null?void 0:h.id)===d.id&&this.state.editingElement!==d&&ty(d)&&(r=d)}),this.scene.replaceAllElements(n.elements),n.commitToHistory&&this.history.resumeRecording()),n.files&&(this.files=n.replaceFiles?n.files:{...this.files,...n.files},this.addNewImagesToImageCache()),n.appState||r||this.state.contextMenu){n.commitToHistory&&this.history.resumeRecording();let d=((i=n==null?void 0:n.appState)==null?void 0:i.viewModeEnabled)||!1,h=((o=n==null?void 0:n.appState)==null?void 0:o.zenModeEnabled)||!1,m=((s=n==null?void 0:n.appState)==null?void 0:s.gridSize)||null;const g=((a=n==null?void 0:n.appState)==null?void 0:a.theme)||this.props.theme||Tt.LIGHT,p=((l=n==null?void 0:n.appState)==null?void 0:l.name)??this.state.name,v=((c=n==null?void 0:n.appState)==null?void 0:c.errorMessage)??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(d=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(h=this.props.zenModeEnabled),typeof this.props.gridModeEnabled<"u"&&(m=this.props.gridModeEnabled?Cl:null),r=r||((u=n.appState)==null?void 0:u.editingElement)||null,r!=null&&r.isDeleted&&(r=null),this.setState(y=>Object.assign(n.appState||{},{contextMenu:null,editingElement:r,viewModeEnabled:d,zenModeEnabled:h,gridSize:m,theme:g,name:p,errorMessage:v}),()=>{n.syncHistory&&this.history.setCurrentState(this.state,this.scene.getElementsIncludingDeleted())})}}));M(this,"onBlur",Je(()=>{Ss=!1,this.setState({isBindingEnabled:!0})}));M(this,"onUnload",()=>{this.onBlur()});M(this,"disableEvent",n=>{n.preventDefault()});M(this,"resetHistory",()=>{this.history.clear()});M(this,"resetScene",Je(n=>{this.scene.replaceAllElements([]),this.setState(r=>({...qr(),isLoading:n!=null&&n.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetHistory()}));M(this,"initializeScene",async()=>{var i;"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async o=>{if(!o.files.length)return;const s=o.files[0],a=await s.getFile();this.loadFileToCanvas(new File([a],a.name||"",{type:a.type}),s)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let n=null;try{n=await this.props.initialData||null,n!=null&&n.libraryItems&&this.library.updateLibrary({libraryItems:n.libraryItems,merge:!0}).catch(o=>{console.error(o)})}catch(o){console.error(o),n={appState:{errorMessage:o.message||"Encountered an error during importing or restoring scene data"}}}const r=_a(n,null,null,{repairBindings:!0});r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:((i=r.appState)==null?void 0:i.openSidebar)||this.state.openSidebar,activeTool:r.appState.activeTool.type==="image"?{...r.appState.activeTool,type:"selection"}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},n!=null&&n.scrollToContent&&(r.appState={...r.appState,...Ld(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.fonts.loadFontsForElements(r.elements),this.resetHistory(),this.syncActionResult({...r,commitToHistory:!0})});M(this,"isMobileBreakpoint",(n,r)=>n<mR||r<pR&&n<gR);M(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;const{clientWidth:r,clientHeight:i}=document.body,o=this.device.viewport,s=Af(o,{isLandscape:r>i,isMobile:this.isMobileBreakpoint(r,i)});return o!==s?(this.device={...this.device,viewport:s},!0):!1});M(this,"refreshEditorBreakpoints",()=>{const n=this.excalidrawContainerRef.current;if(!n)return;const{width:r,height:i}=n.getBoundingClientRect(),o=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:yR,s=this.device.editor,a=Af(s,{isMobile:this.isMobileBreakpoint(r,i),canFitSidebar:r>o});return s!==a?(this.device={...this.device,editor:a},!0):!1});M(this,"onResize",Je(()=>{this.scene.getElementsIncludingDeleted().forEach(n=>Xe.delete(n)),this.refreshViewportBreakpoints(),this.updateDOMRect(),m2||this.refreshEditorBreakpoints(),this.setState({})}));M(this,"onFullscreenChange",()=>{var n;!document.fullscreenElement&&((n=this.state.activeEmbeddable)==null?void 0:n.state)==="active"&&this.setState({activeEmbeddable:null})});M(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:n,scrollBars:r,elementsMap:i})=>{r&&(l0=r);const o=ce(this.state.editingElement)?!1:!n&&i.size>0;this.state.scrolledOutside!==o&&this.setState({scrolledOutside:o}),this.scheduleImageRefresh()});M(this,"onScroll",fa(()=>{const{offsetTop:n,offsetLeft:r}=this.getCanvasOffsets();this.setState(i=>i.offsetLeft===r&&i.offsetTop===n?null:{offsetTop:n,offsetLeft:r})},hR));M(this,"onCut",Je(n=>{var i;!((i=this.excalidrawContainerRef.current)!=null&&i.contains(document.activeElement))||Ns(n.target)||(this.actionManager.executeAction(t4,"keyboard",n),n.preventDefault(),n.stopPropagation())}));M(this,"onCopy",Je(n=>{var i;!((i=this.excalidrawContainerRef.current)!=null&&i.contains(document.activeElement))||Ns(n.target)||(this.actionManager.executeAction(Kf,"keyboard",n),n.preventDefault(),n.stopPropagation())}));M(this,"onTouchStart",n=>{if(JP&&n.preventDefault(),!Zc){Zc=!0,clearTimeout(s0),s0=window.setTimeout(Iw.resetTapTwice,lR);return}if(Zc&&n.touches.length===1){const r=n.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),Zc=!1,clearTimeout(s0)}n.touches.length===2&&this.setState({selectedElementIds:$e({},this.state),activeEmbeddable:null})});M(this,"onTouchEnd",n=>{this.resetContextMenuTimer(),n.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:$e(this.state.previousSelectedElementIds,this.state)}):Pe.pointers.clear()});M(this,"pasteFromClipboard",Je(async n=>{var d,h;const r=!!sf,i=document.activeElement,o=(d=this.excalidrawContainerRef.current)==null?void 0:d.contains(i);if(n&&!o)return;const s=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(n&&(!(s instanceof HTMLCanvasElement)||Ns(i)))return;const{x:a,y:l}=et({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);let c=(h=n==null?void 0:n.clipboardData)==null?void 0:h.files[0];const u=await vT(n,r);if(!c&&!r){if(u.mixedContent)return this.addElementsFromMixedContentPaste(u.mixedContent,{isPlainPaste:r,sceneX:a,sceneY:l});if(u.text){const m=u.text.trim();m.startsWith("<svg")&&m.endsWith("</svg>")&&(c=s_(m))}}if(sa(c)&&!u.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:b("errors.imageToolNotSupported")});return}const m=this.createImageElement({sceneX:a,sceneY:l});this.insertImageElement(m,c),this.initializeImageDimensions(m),this.setState({selectedElementIds:$e({[m.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(u,n)===!1)return}catch(m){console.error(m)}if(u.errorMessage)this.setState({errorMessage:u.errorMessage});else if(u.spreadsheet&&!r)this.setState({pasteDialog:{data:u.spreadsheet,shown:!0}});else if(u.elements){const m=u.programmaticAPI?wM(u.elements):u.elements;this.addElementsFromPasteOrLibrary({elements:m,files:u.files||null,position:"cursor",retainSeed:r})}else if(u.text){const m=qk(u.text).split(/\n+/).map(p=>p.trim()).filter(Boolean),g=m.map(p=>rF(p)).filter(p=>{var v;return Rf(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||((v=yl(p))==null?void 0:v.type)==="video")});if(!sf&&g.length>0&&g.length===m.length){const p=[];for(const v of g){const y=p[p.length-1],E=this.insertEmbeddableElement({sceneX:y?y.x+y.width+20:a,sceneY:l,link:xi(v)});E&&p.push(E)}p.length&&this.setState({selectedElementIds:Object.fromEntries(p.map(v=>[v.id,!0]))});return}this.addTextFromPaste(u.text,r)}this.setActiveTool({type:"selection"}),n==null||n.preventDefault()}));M(this,"addElementsFromPasteOrLibrary",n=>{const r=nh(n.elements,null,void 0),[i,o,s,a]=nt(r),l=un(i,s)/2,c=un(o,a)/2,u=typeof n.position=="object"?n.position.clientX:n.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof n.position=="object"?n.position.clientY:n.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:h,y:m}=et({clientX:u,clientY:d},this.state),g=h-l,p=m-c,[v,y]=jt(g,p,this.state.gridSize),E=YI(r.map(S=>ge(S,{x:S.x+v-i,y:S.y+y-o})),{randomizeSeed:!n.retainSeed}),w=[...this.scene.getElementsIncludingDeleted(),...E],x=this.getTopLayerFrameAtSceneCoords({x:h,y:m});if(x){const S=kz(E,x);Uf(w,S,x)}this.scene.replaceAllElements(w),E.forEach(S=>{if(ce(S)&&Mt(S)){const I=kn(S,this.scene.getElementsMapIncludingDeleted());Mi(S,I,this.scene.getElementsMapIncludingDeleted())}}),n.files&&(this.files={...this.files,...n.files}),this.history.resumeRecording();const C=cg(E);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&_i.get(nw)?this.state.openSidebar:null,...Zn({editingGroupId:null,selectedElementIds:C.reduce((S,I)=>(Mt(I)||(S[I.id]=!0),S),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{n.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),n.fitToContent&&this.scrollToContent(E,{fitToContent:!0})});M(this,"setAppState",(n,r)=>{this.setState(n,r)});M(this,"removePointer",n=>{mo&&this.resetContextMenuTimer(),Pe.pointers.delete(n.pointerId)});M(this,"toggleLock",(n="ui")=>{this.state.activeTool.locked||Ae("toolbar","toggleLock",`${n} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...bt(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))});M(this,"updateFrameRendering",n=>{this.setState(r=>{const i=typeof n=="function"?n(r.frameRendering):n;return{frameRendering:{enabled:(i==null?void 0:i.enabled)??r.frameRendering.enabled,clip:(i==null?void 0:i.clip)??r.frameRendering.clip,name:(i==null?void 0:i.name)??r.frameRendering.name,outline:(i==null?void 0:i.outline)??r.frameRendering.outline}}})});M(this,"togglePenMode",n=>{this.setState(r=>({penMode:n??!r.penMode,penDetected:!0}))});M(this,"onHandToolToggle",()=>{this.actionManager.executeAction(JG)});M(this,"zoomCanvas",n=>{this.setState({...Xs({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:Zs(n)},this.state)})});M(this,"cancelInProgressAnimation",null);M(this,"scrollToContent",(n=this.scene.getNonDeletedElements(),r)=>{var l;(l=this.cancelInProgressAnimation)==null||l.call(this);const i=Array.isArray(n)?n:[n];let o=this.state.zoom,s=this.state.scrollX,a=this.state.scrollY;if(r!=null&&r.fitToContent||r!=null&&r.fitToViewport){const{appState:c}=xg({targetElements:i,appState:this.state,fitToViewport:!!(r!=null&&r.fitToViewport),viewportZoomFactor:r==null?void 0:r.viewportZoomFactor});o=c.zoom,s=c.scrollX,a=c.scrollY}else{const c=Ld(i,this.state);s=c.scrollX,a=c.scrollY}if(r!=null&&r.animate){const c=this.state.scrollX,u=this.state.scrollY,d=this.state.zoom.value,h=xD({fromValues:{scrollX:c,scrollY:u,zoom:d},toValues:{scrollX:s,scrollY:a,zoom:o.value},interpolateValue:(m,g,p,v)=>{if(v==="zoom")return m*Math.pow(g/m,ra(p))},onStep:({scrollX:m,scrollY:g,zoom:p})=>{this.setState({scrollX:m,scrollY:g,zoom:{value:p}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:(r==null?void 0:r.duration)??500});this.cancelInProgressAnimation=()=>{h(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:s,scrollY:a,zoom:o})});M(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});M(this,"translateCanvas",n=>{var r;(r=this.cancelInProgressAnimation)==null||r.call(this),this.maybeUnfollowRemoteUser(),this.setState(n)});M(this,"setToast",n=>{this.setState({toast:n})});M(this,"restoreFileFromShare",async()=>{try{const n=await caches.open("web-share-target"),r=await n.match("shared-file");if(r){const i=await r.blob(),o=new File([i],i.name||"",{type:i.type});this.loadFileToCanvas(o,null),await n.delete("shared-file"),window.history.replaceState(null,Vi,window.location.pathname)}}catch(n){this.setState({errorMessage:n.message})}});M(this,"addFiles",Je(n=>{const r=n.reduce((i,o)=>(i.set(o.id,o),i),new Map);this.files={...this.files,...Object.fromEntries(r)},this.scene.getNonDeletedElements().forEach(i=>{Ft(i)&&r.has(i.fileId)&&(this.imageCache.delete(i.fileId),Xe.delete(i))}),this.scene.informMutation(),this.addNewImagesToImageCache()}));M(this,"updateScene",Je(n=>{n.commitToHistory&&this.history.resumeRecording(),n.appState&&this.setState(n.appState),n.elements&&this.scene.replaceAllElements(n.elements),n.collaborators&&this.setState({collaborators:n.collaborators})}));M(this,"onSceneUpdated",()=>{this.setState({})});M(this,"toggleSidebar",({name:n,tab:r,force:i})=>{var s;let o;return i===void 0?o=((s=this.state.openSidebar)==null?void 0:s.name)===n?null:n:o=i?n:null,this.setState({openSidebar:o?{name:o,tab:r}:null}),!!o});M(this,"updateCurrentCursorPosition",Je(n=>{this.lastViewportPosition.x=n.clientX,this.lastViewportPosition.y=n.clientY}));M(this,"onKeyDown",Je(n=>{if("Proxy"in window&&(!n.shiftKey&&/^[A-Z]$/.test(n.key)||n.shiftKey&&/^[a-z]$/.test(n.key))&&(n=new Proxy(n,{get(s,a){const l=s[a];return typeof l=="function"?l.bind(s):a==="key"?n.shiftKey?s.key.toUpperCase():s.key.toLowerCase():l}})),n[D.CTRL_OR_CMD]&&n.key.toLowerCase()===D.V&&(sf=n.shiftKey,clearTimeout(G4),G4=window.setTimeout(()=>{sf=!1},100)),n[D.CTRL_OR_CMD]&&Ns(n.target)&&(n.code===De.MINUS||n.code===De.EQUAL)){n.preventDefault();return}if(Ns(n.target)&&n.key!==D.ESCAPE||Pf(n.key)&&Wk(n.target))return;if(n.key===D.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(n.key.toLowerCase()===D.E&&n.shiftKey&&n[D.CTRL_OR_CMD]){n.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(n.key===D.PAGE_UP||n.key===D.PAGE_DOWN){let s=(n.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;n.key===D.PAGE_DOWN&&(s=-s),n.shiftKey?this.translateCanvas(a=>({scrollX:a.scrollX+s})):this.translateCanvas(a=>({scrollY:a.scrollY+s}))}if(this.actionManager.handleKeyDown(n)||this.state.viewModeEnabled)return;if(n[D.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Pf(n.key)){const s=this.state.gridSize&&(n.shiftKey?ob:this.state.gridSize)||(n.shiftKey?tR:ob);let a=0,l=0;n.key===D.ARROW_LEFT?a=-s:n.key===D.ARROW_RIGHT?a=s:n.key===D.ARROW_UP?l=-s:n.key===D.ARROW_DOWN&&(l=s);const c=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});c.forEach(u=>{J(u,{x:u.x+a,y:u.y+l}),us(u,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:c})}),this.maybeSuggestBindingForAll(c),n.preventDefault()}else if(n.key===D.ENTER){const s=this.scene.getSelectedElements(this.state);if(s.length===1){const a=s[0];if(n[D.CTRL_OR_CMD])we(a)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==s[0].id)&&(this.history.resumeRecording(),this.setState({editingLinearElement:new ue(a)}));else if(ce(a)||iN(a)){let l;ce(a)||(l=a);const c=Ep(a,this.state,this.scene.getNonDeletedElementsMap()),u=c.x,d=c.y;this.startTextEditing({sceneX:u,sceneY:d,container:l}),n.preventDefault();return}else pe(a)&&this.setState({editingFrame:a.id})}}else if(!n.ctrlKey&&!n.altKey&&!n.metaKey&&this.state.draggingElement===null){const s=Xj(n.key);s?(this.state.activeTool.type!==s&&Ae("toolbar",s,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setActiveTool({type:s}),n.stopPropagation()):n.key===D.Q&&(this.toggleLock("keyboard"),n.stopPropagation())}if(n.key===D.SPACE&&Pe.pointers.size===0&&(Ss=!0,He(this.interactiveCanvas,Be.GRAB),n.preventDefault()),(n.key===D.G||n.key===D.S)&&!n.altKey&&!n[D.CTRL_OR_CMD]){const s=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!s.length)return;n.key===D.G&&(gl(this.state.activeTool.type)||s.some(a=>gl(a.type)))&&(this.setState({openPopup:"elementBackground"}),n.stopPropagation()),n.key===D.S&&(this.setState({openPopup:"elementStroke"}),n.stopPropagation())}if(n.key===D.K&&!n.altKey&&!n[D.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}n[D.CTRL_OR_CMD]&&(n.key===D.BACKSPACE||n.key===D.DELETE)&&_i.set(iw,"clearCanvas");const r=n.key.toLocaleLowerCase(),i=r===D.S&&n.shiftKey,o=n.key===D.I||r===D.G&&n.shiftKey;(i||o)&&this.openEyeDropper({type:i?"stroke":"background"})}));M(this,"onWheel",Je(n=>{!(n.target instanceof HTMLCanvasElement)&&n.ctrlKey&&n.preventDefault()}));M(this,"onKeyUp",Je(n=>{if(n.key===D.SPACE&&(this.state.viewModeEnabled?He(this.interactiveCanvas,Be.GRAB):this.state.activeTool.type==="selection"?Pr(this.interactiveCanvas):(di(this.interactiveCanvas,this.state),this.setState({selectedElementIds:$e({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Ss=!1),!n[D.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Pf(n.key)){const r=this.scene.getSelectedElements(this.state),i=this.scene.getNonDeletedElementsMap();Gs(this.state)?P2(r,this.scene.getNonDeletedElements(),i):D2(r,i),this.setState({suggestedBindings:[]})}}));M(this,"isToolSupported",n=>{var r;return((r=this.props.UIOptions.tools)==null?void 0:r[n])!==!1});M(this,"setActiveTool",n=>{if(!this.isToolSupported(n.type)){console.warn(`"${n.type}" tool is disabled via "UIOptions.canvasActions.tools.${n.type}"`);return}const r=bt(this.state,n);r.type==="hand"?He(this.interactiveCanvas,Be.GRAB):Ss||di(this.interactiveCanvas,this.state),bD(document.activeElement)&&this.focusContainer(),qv(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageAction({insertOnCanvasDirectly:(n.type==="image"&&n.insertOnCanvasDirectly)??!1}),this.setState(i=>{const o={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return r.type!=="selection"?{...i,activeTool:r,selectedElementIds:$e({},i),selectedGroupIds:$e({},i),editingGroupId:null,multiElement:null,...o}:{...i,activeTool:r,...o}})});M(this,"setOpenDialog",n=>{this.setState({openDialog:n})});M(this,"setCursor",n=>{He(this.interactiveCanvas,n)});M(this,"resetCursor",()=>{Pr(this.interactiveCanvas)});M(this,"isTouchScreenMultiTouchGesture",()=>Pe.pointers.size>=2);M(this,"getName",()=>this.state.name||this.props.name||`${b("labels.untitled")}-${bb()}`);M(this,"onGestureStart",Je(n=>{n.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:$e({},this.state),activeEmbeddable:null}),Pe.initialScale=this.state.zoom.value}));M(this,"onGestureChange",Je(n=>{if(n.preventDefault(),this.isTouchScreenMultiTouchGesture())return;const r=Pe.initialScale;r&&this.setState(i=>({...Xs({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Zs(r*n.scale)},i)}))}));M(this,"onGestureEnd",Je(n=>{n.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:$e(this.state.previousSelectedElementIds,this.state)}),Pe.initialScale=null}));M(this,"startTextEditing",({sceneX:n,sceneY:r,insertAtParentCenter:i=!0,container:o})=>{let s=!1,a=i&&this.getTextWysiwygSnappedToCenterPosition(n,r,this.state,o);o&&a&&(ke(o,this.scene.getNonDeletedElementsMap())||(s=!0));let l=null;const c=this.scene.getSelectedElements(this.state);c.length===1?ce(c[0])?l=c[0]:o?l=ke(c[0],this.scene.getNonDeletedElementsMap()):l=this.getTextElementAtPosition(n,r):l=this.getTextElementAtPosition(n,r);const u=(l==null?void 0:l.fontFamily)||this.state.currentItemFontFamily,d=(l==null?void 0:l.lineHeight)||wa(u),h=this.state.currentItemFontSize;if(!l&&s&&o&&!Ge(o)){const v=AI(Bt({fontSize:h,fontFamily:u}),d),y=CI(h,d),E=Math.max(o.height,y),w=Math.max(o.width,v);J(o,{height:E,width:w}),n=o.x+w/2,r=o.y+E/2,a&&(a=this.getTextWysiwygSnappedToCenterPosition(n,r,this.state,o))}const m=this.getTopLayerFrameAtSceneCoords({x:n,y:r}),g=l||Sr({x:a?a.elementCenterX:n,y:a?a.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:h,fontFamily:u,textAlign:a?"center":this.state.currentItemTextAlign,verticalAlign:a?Qn.MIDDLE:_m,containerId:s?o==null?void 0:o.id:void 0,groupIds:(o==null?void 0:o.groupIds)??[],lineHeight:d,angle:(o==null?void 0:o.angle)??0,frameId:m?m.id:null});if(!l&&s&&o&&J(o,{boundElements:(o.boundElements||[]).concat({type:"text",id:g.id})}),this.setState({editingElement:g}),!l)if(o&&s){const p=this.scene.getElementIndex(o.id);this.scene.insertElementAtIndex(g,p+1)}else this.scene.addNewElement(g);this.setState({editingElement:g}),this.handleTextWysiwyg(g,{isExistingElement:!!l})});M(this,"handleCanvasDoubleClick",n=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;const r=this.scene.getSelectedElements(this.state);if(r.length===1&&we(r[0])){if(n[D.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)){this.history.resumeRecording(),this.setState({editingLinearElement:new ue(r[0])});return}else if(this.state.editingLinearElement&&this.state.editingLinearElement.elementId===r[0].id)return}Pr(this.interactiveCanvas);let{x:i,y:o}=et(n,this.state);if(Ml(this.state).length>0){const a=this.getElementAtPosition(i,o),l=a&&TN(a,this.state.selectedGroupIds);if(l){this.setState(c=>({...c,...Zn({editingGroupId:l,selectedElementIds:{[a.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(Pr(this.interactiveCanvas),!n[D.CTRL_OR_CMD]&&!this.state.viewModeEnabled){const a=this.getElementAtPosition(i,o);if(fr(a)){this.setState({activeEmbeddable:{element:a,state:"active"}});return}const l=Ub(this.scene.getNonDeletedElements(),this.state,i,o,this.scene.getNonDeletedElementsMap());if(l&&(ls(l)||!Ei(l.backgroundColor)||vd(l,this.state,this.frameNameBoundsCache,[i,o],this.scene.getNonDeletedElementsMap()))){const c=Ep(l,this.state,this.scene.getNonDeletedElementsMap());i=c.x,o=c.y}this.startTextEditing({sceneX:i,sceneY:o,insertAtParentCenter:!n.altKey,container:l})}});M(this,"getElementLinkAtPosition",(n,r)=>{const i=this.scene.getNonDeletedElements().slice().reverse();let o=1/0;return i.find((s,a)=>(r&&s.id===r.id&&(o=a),s.link&&a<=o&&_p(s,this.scene.getNonDeletedElementsMap(),this.state,[n.x,n.y],this.device.editor.isMobile)))});M(this,"redirectToLink",(n,r)=>{const i=kt(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY,this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY);if(!this.hitLinkElement||r&&i>Ts||!r&&i!==0)return;const o=et(this.lastPointerDownEvent,this.state),s=this.scene.getNonDeletedElementsMap(),a=_p(this.hitLinkElement,s,this.state,[o.x,o.y],this.device.editor.isMobile),l=et(this.lastPointerUpEvent,this.state),c=_p(this.hitLinkElement,s,this.state,[l.x,l.y],this.device.editor.isMobile);if(a&&c){let u=this.hitLinkElement.link;if(u){u=xi(u);let d;if(this.props.onLinkOpen&&(d=Xk(Z.EXCALIDRAW_LINK,n.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:u},d)),!(d!=null&&d.defaultPrevented)){const h=$I(u)?"_self":"_blank",m=window.open(void 0,h);m&&(m.opener=null,m.location=u)}}}});M(this,"getTopLayerFrameAtSceneCoords",n=>{const r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(o=>s6(n,o,r));return i.length?i[i.length-1]:null});M(this,"handleCanvasPointerMove",n=>{var m;this.savePointer(n.clientX,n.clientY,this.state.cursorButton),this.lastPointerMoveEvent=n.nativeEvent,Pe.pointers.has(n.pointerId)&&Pe.pointers.set(n.pointerId,{x:n.clientX,y:n.clientY});const r=Pe.initialScale;if(Pe.pointers.size===2&&Pe.lastCenter&&r&&Pe.initialDistance){const g=u4(Pe.pointers),p=g.x-Pe.lastCenter.x,v=g.y-Pe.lastCenter.y;Pe.lastCenter=g;const y=d4(Array.from(Pe.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:y/Pe.initialDistance,w=E?Zs(r*E):this.state.zoom.value;this.setState(x=>{const C=Xs({viewportX:g.x,viewportY:g.y,nextZoom:w},x);this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+p/w,scrollY:C.scrollY+v/w,shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else Pe.lastCenter=Pe.initialDistance=Pe.initialScale=null;if(Ss||Xc||a0||Vl(this.state))return;const o=w4(l0,n.clientX-this.state.offsetLeft,n.clientY-this.state.offsetTop).isOverEither;!this.state.draggingElement&&!this.state.multiElement&&(o?Pr(this.interactiveCanvas):di(this.interactiveCanvas,this.state));const s=et(n,this.state),{x:a,y:l}=s;if(!this.state.draggingElement&&oX(this.state.activeTool.type)){const{originOffset:g,snapLines:p}=iX(this.scene.getNonDeletedElements(),this.state,{x:a,y:l},n,this.scene.getNonDeletedElementsMap());this.setState(v=>{const y=mp(v.snapLines,p),E=v.originSnapOffset?mp(v.originSnapOffset,g):g;return v.snapLines===y&&v.originSnapOffset===E?null:{snapLines:y,originSnapOffset:E}})}else this.state.draggingElement||this.setState(g=>g.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){const g=ue.handlePointerMove(n,a,l,this.state,this.scene.getNonDeletedElementsMap());g&&g!==this.state.editingLinearElement&&nr.flushSync(()=>{this.setState({editingLinearElement:g})}),(g==null?void 0:g.lastUncommittedPoint)!=null?this.maybeSuggestBindingAtCursor(s):nr.flushSync(()=>{this.setState({suggestedBindings:[]})})}if(Qk(this.state.activeTool.type)){const{draggingElement:g}=this.state;dn(g,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(g,[s],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(s)}if(this.state.multiElement){const{multiElement:g}=this.state,{x:p,y:v}=g,{points:y,lastCommittedPoint:E}=g,w=y[y.length-1];if(di(this.interactiveCanvas,this.state),w===E)kt(a-p,l-v,w[0],w[1])>=Sf?J(g,{points:[...y,[a-p,l-v]]}):He(this.interactiveCanvas,Be.POINTER);else if(y.length>2&&E&&kt(a-p,l-v,E[0],E[1])<Sf)He(this.interactiveCanvas,Be.POINTER),J(g,{points:y.slice(0,-1)});else{const[x,C]=jt(a,l,n[D.CTRL_OR_CMD]?null:this.state.gridSize),[S,I]=(g==null?void 0:g.lastCommittedPoint)??[0,0];let T=x-p-S,L=C-v-I;Mu(n)&&({width:T,height:L}=J2(S+p,I+v,x,C)),cs(y,this.state.zoom.value)&&He(this.interactiveCanvas,Be.POINTER),J(g,{points:[...y.slice(0,-1),[S+T,I+L]]})}return}if(!!n.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;const u=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!o&&!this.state.editingLinearElement){const g=d6(u,this.state,a,l,this.state.zoom,n.pointerType,this.scene.getNonDeletedElementsMap());if(g&&g.transformHandleType){He(this.interactiveCanvas,f6(g));return}}else if(d.length>1&&!o){const g=h6(nt(d),a,l,this.state.zoom,n.pointerType);if(g){He(this.interactiveCanvas,f6({transformHandleType:g}));return}}const h=this.getElementAtPosition(s.x,s.y);this.hitLinkElement=this.getElementLinkAtPosition(s,h),!mi(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(He(this.interactiveCanvas,Be.POINTER),Lj(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Rj(),h&&(h.link||bn(h))&&this.state.selectedElementIds[h.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?He(this.interactiveCanvas,ce(h)?Be.TEXT:Be.CROSSHAIR):this.state.viewModeEnabled?He(this.interactiveCanvas,Be.GRAB):o?He(this.interactiveCanvas,Be.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,a,l):n[D.CTRL_OR_CMD]?He(this.interactiveCanvas,Be.AUTO):(h||this.isHittingCommonBoundingBoxOfSelectedElements(s,d))&&!(h!=null&&h.locked)&&(h&&fr(h)&&this.isIframeLikeElementCenter(h,n,a,l)?(He(this.interactiveCanvas,Be.POINTER),this.setState({activeEmbeddable:{element:h,state:"hover"}})):(He(this.interactiveCanvas,Be.MOVE),((m=this.state.activeEmbeddable)==null?void 0:m.state)==="hover"&&this.setState({activeEmbeddable:null})))))});M(this,"handleEraser",(n,r,i)=>{this.eraserTrail.addPointToPath(i.x,i.y);let o=!1;const s=new Set,a=this.scene.getNonDeletedElements(),l=m=>{var g;for(const p of m){if(p.locked)return;if(n.altKey?this.elementsPendingErasure.delete(p.id)&&(o=!0):this.elementsPendingErasure.has(p.id)||(o=!0,this.elementsPendingErasure.add(p.id)),o&&((g=p.groupIds)!=null&&g.length)){const v=p.groupIds.at(-1);if(!s.has(v)){s.add(v);const y=It(a,v);for(const E of y)n.altKey?this.elementsPendingErasure.delete(E.id):this.elementsPendingErasure.add(E.id)}}}},c=kt(r.lastCoords.x,r.lastCoords.y,i.x,i.y),u=10/this.state.zoom.value,d={...r.lastCoords};let h=0;for(;h<=c;){const m=this.getElementsAtPosition(d.x,d.y);if(l(m),h===c)break;h=Math.min(h+u,c);const g=h/c,p=(1-g)*d.x+g*i.x,v=(1-g)*d.y+g*i.y;d.x=p,d.y=v}if(r.lastCoords.x=i.x,r.lastCoords.y=i.y,o){for(const m of this.scene.getNonDeletedElements())Mt(m)&&(this.elementsPendingErasure.has(m.id)||this.elementsPendingErasure.has(m.containerId))&&(n.altKey?(this.elementsPendingErasure.delete(m.id),this.elementsPendingErasure.delete(m.containerId)):(this.elementsPendingErasure.add(m.id),this.elementsPendingErasure.add(m.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.onSceneUpdated()}});M(this,"handleTouchMove",n=>{qc=!0});M(this,"handleCanvasPointerDown",n=>{var u,d;if(this.maybeCleanupAfterMissingPointerUp(n.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(n),n.pointerType==="touch"&&this.state.draggingElement&&this.state.draggingElement.type==="freedraw"){const h=this.state.draggingElement;this.updateScene({...h.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(m=>m.id!==h.id)}:{},appState:{draggingElement:null,editingElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:$e(Object.keys(this.state.selectedElementIds).filter(m=>m!==h.id).reduce((m,g)=>(m[g]=this.state.selectedElementIds[g],m),{}),this.state)}});return}const r=document.getSelection();if(r!=null&&r.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(n),!this.state.penDetected&&n.pointerType==="pen"&&this.setState(h=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(n.pointerType)&&(this.device=Af(this.device,{isTouchScreen:!0})),Xc||(this.lastPointerDownEvent=n,this.handleCanvasPanUsingWheelOrSpaceDrag(n)))return;if(this.setState({lastPointerDownWith:n.pointerType,cursorButton:"down"}),this.savePointer(n.clientX,n.clientY,"down"),n.button===xs.ERASER&&this.state.activeTool.type!==zt.eraser){this.setState({activeTool:bt(this.state,{type:zt.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(n);const h=()=>{m(),g==null||g(),mi(this.state)&&this.setState({activeTool:bt(this.state,{...this.state.activeTool.lastActiveTool||{type:zt.selection},lastActiveToolBeforeEraser:null})})},m=gt(window,Z.POINTER_UP,h,{once:!0});let g;requestAnimationFrame(()=>{g=this.missingPointerEventCleanupEmitter.once(h)})});return}if(n.button!==xs.MAIN&&n.button!==xs.TOUCH&&n.button!==xs.ERASER||Pe.pointers.size>1)return;const i=this.initialPointerDownState(n);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(n,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(n),this.handleSelectionOnPointerDown(n,i))||!(!this.state.penMode||n.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="text"){this.handleTextOnPointerDown(n,i);return}else if(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")this.handleLinearElementOnPointerDown(n,this.state.activeTool.type,i);else if(this.state.activeTool.type==="image"){He(this.interactiveCanvas,Be.CROSSHAIR);const h=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!h)return;this.setState({draggingElement:h,editingElement:h,pendingImageElementId:null,multiElement:null});const{x:m,y:g}=et(n,this.state),p=this.getTopLayerFrameAtSceneCoords({x:m,y:g});J(h,{x:m,y:g,frameId:p?p.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(n,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?di(this.interactiveCanvas,this.state):this.state.activeTool.type===zt.frame||this.state.activeTool.type===zt.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i);(d=(u=this.props)==null?void 0:u.onPointerDown)==null||d.call(u,this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,n),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);const s=this.onPointerMoveFromPointerDownHandler(i),a=this.onPointerUpFromPointerDownHandler(i),l=this.onKeyDownFromPointerDownHandler(i),c=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(h=>a(h||n.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(Z.POINTER_MOVE,s),window.addEventListener(Z.POINTER_UP,a),window.addEventListener(Z.KEYDOWN,l),window.addEventListener(Z.KEYUP,c),i.eventListeners.onMove=s,i.eventListeners.onUp=a,i.eventListeners.onKeyUp=c,i.eventListeners.onKeyDown=l)});M(this,"handleCanvasPointerUp",n=>{var o;this.removePointer(n),this.lastPointerUpEvent=n;const r=et({clientX:n.clientX,clientY:n.clientY},this.state),i=n.timeStamp-(((o=this.lastPointerDownEvent)==null?void 0:o.timeStamp)??0);if(this.device.editor.isMobile&&i<300){const s=this.getElementAtPosition(r.x,r.y);if(fr(s)&&this.isIframeLikeElementCenter(s,n,r.x,r.y)){this.handleEmbeddableCenterClick(s);return}}if(this.device.isTouchScreen){const s=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,s)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?i<300&&fr(this.hitLinkElement)&&!aC(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,[r.x,r.y])?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(n,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});M(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",n=>{n.pointerType==="touch"&&(qc=!1,mo?qc=!0:mo=window.setTimeout(()=>{mo=0,qc||this.handleCanvasContextMenu(n)},cR))});M(this,"resetContextMenuTimer",()=>{clearTimeout(mo),mo=0,qc=!1});M(this,"maybeCleanupAfterMissingPointerUp",n=>{ks==null||ks(),this.missingPointerEventCleanupEmitter.trigger(n).clear()});M(this,"handleCanvasPanUsingWheelOrSpaceDrag",n=>{if(!(Pe.pointers.size<=1&&(n.button===xs.WHEEL||n.button===xs.MAIN&&Ss||Vl(this.state)||this.state.viewModeEnabled))||ce(this.state.editingElement))return!1;Xc=!0,n.preventDefault();let r=!1;const i=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);He(this.interactiveCanvas,Be.GRABBING);let{clientX:o,clientY:s}=n;const a=r0(c=>{const u=o-c.clientX,d=s-c.clientY;if(o=c.clientX,s=c.clientY,i&&!r&&(Math.abs(u)>1||Math.abs(d)>1)){r=!0;const h=g=>{document.body.removeEventListener(Z.PASTE,h),g.stopPropagation()},m=()=>{setTimeout(()=>{document.body.removeEventListener(Z.PASTE,h),window.removeEventListener(Z.POINTER_UP,m)},100)};document.body.addEventListener(Z.PASTE,h),window.addEventListener(Z.POINTER_UP,m)}this.translateCanvas({scrollX:this.state.scrollX-u/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),l=Je(ks=()=>{ks=null,Xc=!1,Ss||(this.state.viewModeEnabled?He(this.interactiveCanvas,Be.GRAB):di(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(n.clientX,n.clientY,"up"),window.removeEventListener(Z.POINTER_MOVE,a),window.removeEventListener(Z.POINTER_UP,l),window.removeEventListener(Z.BLUR,l),a.flush()});return window.addEventListener(Z.BLUR,l),window.addEventListener(Z.POINTER_MOVE,a,{passive:!0}),window.addEventListener(Z.POINTER_UP,l),!0});M(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.setState({selectedElementIds:$e({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});M(this,"handleSelectionOnPointerDown",(n,r)=>{if(this.state.activeTool.type==="selection"){const i=this.scene.getNonDeletedElements(),o=this.scene.getNonDeletedElementsMap(),s=this.scene.getSelectedElements(this.state);if(s.length===1&&!this.state.editingLinearElement){const a=d6(i,this.state,r.origin.x,r.origin.y,this.state.zoom,n.pointerType,this.scene.getNonDeletedElementsMap());a!=null&&(this.setState({resizingElement:a.element}),r.resize.handleType=a.transformHandleType)}else s.length>1&&(r.resize.handleType=h6(nt(s),r.origin.x,r.origin.y,this.state.zoom,n.pointerType));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=Oo(jz(r.resize.handleType,s,o,r.origin.x,r.origin.y)),s.length===1&&we(s[0])&&s[0].points.length===2&&(r.resize.arrowDirection=Yz(r.resize.handleType,s[0]));else{if(this.state.selectedLinearElement){const c=this.state.editingLinearElement||this.state.selectedLinearElement,u=ue.handlePointerDown(n,this.state,this.history,r.origin,c,this.scene.getNonDeletedElements(),o);if(u.hitElement&&(r.hit.element=u.hitElement),u.linearElementEditor&&(this.setState({selectedLinearElement:u.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:u.linearElementEditor})),u.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=this.getElementsAtPosition(r.origin.x,r.origin.y);const a=r.hit.element,l=r.hit.allHitElements.some(c=>this.isASelectedElement(c));if((a===null||!l)&&!n.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(a),this.state.editingLinearElement)this.setState({selectedElementIds:$e({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(a!=null){if(n[D.CTRL_OR_CMD])return this.state.selectedElementIds[a.id]||(r.hit.wasAddedToSelection=!0),this.setState(c=>({...CN(c,a),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[a.id]||(this.state.editingGroupId&&!bd(a,this.state.editingGroupId)&&this.setState({selectedElementIds:$e({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!l&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(c=>{const u={...c.selectedElementIds,[a.id]:!0},d=[];if(Object.keys(c.selectedElementIds).forEach(h=>{const m=this.scene.getElement(h);m&&d.push(m)}),pe(a))eo(d,a.id).forEach(h=>{delete u[h.id]});else if(a.frameId)u[a.frameId]&&delete u[a.id];else{const h=a.groupIds,m=new Set(h.flatMap(g=>It(this.scene.getNonDeletedElements(),g)).filter(g=>pe(g)).map(g=>g.id));m.size>0&&d.forEach(g=>{g.frameId&&m.has(g.frameId)&&(delete u[g.id],g.groupIds.flatMap(p=>It(this.scene.getNonDeletedElements(),p)).forEach(p=>{delete u[p.id]}))})}return{...Zn({editingGroupId:c.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),c,this),showHyperlinkPopup:a.link||bn(a)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});M(this,"handleTextOnPointerDown",(n,r)=>{if(ce(this.state.editingElement))return;let i=r.origin.x,o=r.origin.y;const s=this.getElementAtPosition(i,o,{includeBoundTextElement:!0});let a=Ub(this.scene.getNonDeletedElements(),this.state,i,o,this.scene.getNonDeletedElementsMap());ls(s)&&(a=s,i=s.x+s.width/2,o=s.y+s.height/2),this.startTextEditing({sceneX:i,sceneY:o,insertAtParentCenter:!n.altKey,container:a}),Pr(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:bt(this.state,{type:"selection"})})});M(this,"handleFreeDrawElementOnPointerDown",(n,r,i)=>{const[o,s]=jt(i.origin.x,i.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:o,y:s}),l=YN({type:r,x:o,y:s,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:n.pressure===.5,locked:!1,frameId:a?a.id:null});this.setState(d=>{const h={...d.selectedElementIds};return delete h[l.id],{selectedElementIds:$e(h,d)}});const c=l.simulatePressure?l.pressures:[...l.pressures,n.pressure];J(l,{points:[[0,0]],pressures:c});const u=No(i.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.scene.addNewElement(l),this.setState({draggingElement:l,editingElement:l,startBoundElement:u,suggestedBindings:[]})});M(this,"insertIframeElement",({sceneX:n,sceneY:r,width:i,height:o})=>{var c;const[s,a]=jt(n,r,(c=this.lastPointerDownEvent)!=null&&c[D.CTRL_OR_CMD]?null:this.state.gridSize),l=VN({type:"iframe",x:s,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:i,height:o});return this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted(),l]),l});M(this,"insertEmbeddableElement",({sceneX:n,sceneY:r,link:i})=>{var c;const[o,s]=jt(n,r,(c=this.lastPointerDownEvent)!=null&&c[D.CTRL_OR_CMD]?null:this.state.gridSize),a=yl(i);if(!a)return;a.error instanceof URIError&&this.setToast({message:b("toast.unrecognizedLinkFormat"),closable:!0});const l=Jb({type:"embeddable",x:o,y:s,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:a.intrinsicSize.w,height:a.intrinsicSize.h,link:i});return this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted(),l]),l});M(this,"createImageElement",({sceneX:n,sceneY:r,addToFrameUnderCursor:i=!0})=>{var c;const[o,s]=jt(n,r,(c=this.lastPointerDownEvent)!=null&&c[D.CTRL_OR_CMD]?null:this.state.gridSize),a=i?this.getTopLayerFrameAtSceneCoords({x:o,y:s}):null;return GI({type:"image",x:o,y:s,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null})});M(this,"handleLinearElementOnPointerDown",(n,r,i)=>{if(this.state.multiElement){const{multiElement:o}=this.state;if(o.type==="line"&&cs(o.points,this.state.zoom.value)){J(o,{lastCommittedPoint:o.points[o.points.length-1]}),this.actionManager.executeAction(li);return}const{x:s,y:a,lastCommittedPoint:l}=o;if(o.points.length>1&&l&&kt(i.origin.x-s,i.origin.y-a,l[0],l[1])<Sf){this.actionManager.executeAction(li);return}this.setState(c=>({selectedElementIds:$e({...c.selectedElementIds,[o.id]:!0},c)})),J(o,{lastCommittedPoint:o.points[o.points.length-1]}),He(this.interactiveCanvas,Be.POINTER)}else{const[o,s]=jt(i.origin.x,i.origin.y,n[D.CTRL_OR_CMD]?null:this.state.gridSize),a=this.getTopLayerFrameAtSceneCoords({x:o,y:s}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[u,d]=r==="arrow"?[l,c]:[null,null],h=Qo({type:r,x:o,y:s,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:Vt.PROPORTIONAL_RADIUS}:null,startArrowhead:u,endArrowhead:d,locked:!1,frameId:a?a.id:null});this.setState(g=>{const p={...g.selectedElementIds};return delete p[h.id],{selectedElementIds:$e(p,g)}}),J(h,{points:[...h.points,[0,0]]});const m=No(i.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.scene.addNewElement(h),this.setState({draggingElement:h,editingElement:h,startBoundElement:m,suggestedBindings:[]})}});M(this,"createGenericElementOnPointerDown",(n,r)=>{var c;const[i,o]=jt(r.origin.x,r.origin.y,(c=this.lastPointerDownEvent)!=null&&c[D.CTRL_OR_CMD]?null:this.state.gridSize),s=this.getTopLayerFrameAtSceneCoords({x:i,y:o}),a={x:i,y:o,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(n),locked:!1,frameId:s?s.id:null};let l;n==="embeddable"?l=Jb({type:"embeddable",...a}):l=hs({type:n,...a}),l.type==="selection"?this.setState({selectionElement:l,draggingElement:l}):(this.scene.addNewElement(l),this.setState({multiElement:null,draggingElement:l,editingElement:l}))});M(this,"createFrameElementOnPointerDown",(n,r)=>{var l;const[i,o]=jt(n.origin.x,n.origin.y,(l=this.lastPointerDownEvent)!=null&&l[D.CTRL_OR_CMD]?null:this.state.gridSize),s={x:i,y:o,opacity:this.state.currentItemOpacity,locked:!1,...vt},a=r===zt.magicframe?$2(s):WI(s);this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted(),a]),this.setState({multiElement:null,draggingElement:a,editingElement:a})});M(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.onSceneUpdated()});M(this,"eraseElements",()=>{let n=!1;const r=this.scene.getElementsIncludingDeleted().map(i=>this.elementsPendingErasure.has(i.id)||i.frameId&&this.elementsPendingErasure.has(i.frameId)||Mt(i)&&this.elementsPendingErasure.has(i.containerId)?(n=!0,ge(i,{isDeleted:!0})):i);this.elementsPendingErasure=new Set,n&&(this.history.resumeRecording(),this.scene.replaceAllElements(r))});M(this,"initializeImage",async({imageFile:n,imageElement:r,showCursorImagePreview:i=!1})=>{var u,d,h,m;if(!sa(n))throw new Error(b("errors.unsupportedFileType"));const o=n.type;if(He(this.interactiveCanvas,"wait"),o===de.svg)try{n=s_(await MF(await n.text()),n.name)}catch(g){throw console.warn(g),new Error(b("errors.svgImageInsertError"))}const s=await(((d=(u=this.props).generateIdForFile)==null?void 0:d.call(u,n))||EF(n));if(!s)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(b("errors.imageInsertError"));const a=this.files[s];if(!(a!=null&&a.dataURL)){try{n=await H2(n,{maxWidthOrHeight:ER})}catch(g){console.error("Error trying to resizing image file on insertion",g)}if(n.size>ub)throw new Error(b("errors.fileTooBig",{maxSize:`${Math.trunc(ub/1024/1024)}MB`}))}if(i){const g=(h=this.files[s])==null?void 0:h.dataURL,p=g&&wF(g);this.setImagePreviewCursor(p||n)}const l=((m=this.files[s])==null?void 0:m.dataURL)||await bp(n),c=J(r,{fileId:s},!1);return new Promise(async(g,p)=>{var v;try{this.files={...this.files,[s]:{mimeType:o,id:s,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}};const y=this.imageCache.get(s);y||(this.addNewImagesToImageCache(),await this.updateImageCache([c])),(y==null?void 0:y.image)instanceof Promise&&await y.image,this.state.pendingImageElementId!==c.id&&((v=this.state.draggingElement)==null?void 0:v.id)!==c.id&&this.initializeImageDimensions(c,!0),g(c)}catch(y){console.error(y),p(new Error(b("errors.imageInsertError")))}finally{i||Pr(this.interactiveCanvas)}})});M(this,"insertImageElement",async(n,r,i)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:b("errors.imageToolNotSupported")});return}this.scene.addNewElement(n);try{return await this.initializeImage({imageFile:r,imageElement:n,showCursorImagePreview:i})}catch(o){return J(n,{isDeleted:!0}),this.actionManager.executeAction(li),this.setState({errorMessage:o.message||b("errors.imageInsertError")}),null}});M(this,"setImagePreviewCursor",async n=>{let i;try{i=await H2(n,{maxWidthOrHeight:96})}catch(s){throw s.cause==="UNSUPPORTED"?new Error(b("errors.unsupportedFileType")):s}let o=await bp(i);if(n.type===de.svg){const s=await rC(o);let a=Math.min(s.height,96),l=a*(s.width/s.height);l>96&&(l=96,a=l*(s.height/s.width));const c=document.createElement("canvas");c.height=a,c.width=l,c.getContext("2d").drawImage(s,0,0,l,a),o=c.toDataURL(de.svg)}this.state.pendingImageElementId&&He(this.interactiveCanvas,`url(${o}) 4 4, auto`)});M(this,"onImageAction",async({insertOnCanvasDirectly:n})=>{try{const r=this.state.width/2+this.state.offsetLeft,i=this.state.height/2+this.state.offsetTop,{x:o,y:s}=et({clientX:r,clientY:i},this.state),a=await fE({description:"Image",extensions:Object.keys(Nv)}),l=this.createImageElement({sceneX:o,sceneY:s,addToFrameUnderCursor:!1});n?(this.insertImageElement(l,a),this.initializeImageDimensions(l),this.setState({selectedElementIds:$e({[l.id]:!0},this.state)},()=>{this.actionManager.executeAction(li)})):this.setState({pendingImageElementId:l.id},()=>{this.insertImageElement(l,a,!0)})}catch(r){r.name!=="AbortError"?console.error(r):console.warn(r),this.setState({pendingImageElementId:null,editingElement:null,activeTool:bt(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(li)})}});M(this,"initializeImageDimensions",(n,r=!1)=>{var o;const i=Ft(n)&&((o=this.imageCache.get(n.fileId))==null?void 0:o.image);if(!i||i instanceof Promise){if(n.width<Ts/this.state.zoom.value&&n.height<Ts/this.state.zoom.value){const s=100/this.state.zoom.value;J(n,{x:n.x-s/2,y:n.y-s/2,width:s,height:s})}return}if(r||n.width<Ts/this.state.zoom.value&&n.height<Ts/this.state.zoom.value){const s=Math.max(this.state.height-120,160),a=Math.min(s,Math.floor(this.state.height*.5)/this.state.zoom.value),l=Math.min(i.naturalHeight,a),c=l*(i.naturalWidth/i.naturalHeight),u=n.x+n.width/2-c/2,d=n.y+n.height/2-l/2;J(n,{x:u,y:d,width:c,height:l})}});M(this,"updateImageCache",async(n,r=this.files)=>{const{updatedFiles:i,erroredFiles:o}=await iC({imageCache:this.imageCache,fileIds:n.map(s=>s.fileId),files:r});if(i.size||o.size)for(const s of n)i.has(s.fileId)&&Xe.delete(s);return o.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>Ft(s)&&o.has(s.fileId)?ge(s,{status:"error"}):s)),{updatedFiles:i,erroredFiles:o}});M(this,"addNewImagesToImageCache",async(n=oC(this.scene.getNonDeletedElements()),r=this.files)=>{const i=n.filter(o=>!o.isDeleted&&!this.imageCache.has(o.fileId));if(i.length){const{updatedFiles:o}=await this.updateImageCache(i,r);o.size&&this.scene.informMutation()}});M(this,"scheduleImageRefresh",Qs(()=>{this.addNewImagesToImageCache()},aR));M(this,"updateBindingEnabledOnPointerMove",n=>{const r=BO(n);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});M(this,"maybeSuggestBindingAtCursor",n=>{const r=No(n,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.setState({suggestedBindings:r!=null?[r]:[]})});M(this,"maybeSuggestBindingsForLinearElementAtCoords",(n,r,i)=>{if(!r.length)return;const o=r.reduce((s,a)=>{const l=No(a,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());return l!=null&&!wI(n,i==null?void 0:i.id,l)&&s.push(l),s},[]);this.setState({suggestedBindings:o})});M(this,"handleInteractiveCanvasRef",n=>{var r,i,o;n!==null?(this.interactiveCanvas=n,this.interactiveCanvas.addEventListener(Z.WHEEL,this.handleWheel),this.interactiveCanvas.addEventListener(Z.TOUCH_START,this.onTouchStart),this.interactiveCanvas.addEventListener(Z.TOUCH_END,this.onTouchEnd)):((r=this.interactiveCanvas)==null||r.removeEventListener(Z.WHEEL,this.handleWheel),(i=this.interactiveCanvas)==null||i.removeEventListener(Z.TOUCH_START,this.onTouchStart),(o=this.interactiveCanvas)==null||o.removeEventListener(Z.TOUCH_END,this.onTouchEnd))});M(this,"handleAppOnDrop",async n=>{var l,c,u,d;const{file:r,fileHandle:i}=await _F(n),{x:o,y:s}=et(n,this.state);try{if(sa(r)&&this.isToolSupported("image")){if((r==null?void 0:r.type)===de.png||(r==null?void 0:r.type)===de.svg)try{const m=await gE(r,this.state,this.scene.getElementsIncludingDeleted(),i);this.syncActionResult({...m,appState:{...m.appState||this.state,isLoading:!1},replaceFiles:!0,commitToHistory:!0});return}catch(m){if(m.name!=="EncodingError")throw new Error(b("alerts.couldNotLoadInvalidFile"))}const h=this.createImageElement({sceneX:o,sceneY:s});this.insertImageElement(h,r),this.initializeImageDimensions(h),this.setState({selectedElementIds:$e({[h.id]:!0},this.state)});return}}catch(h){return this.setState({isLoading:!1,errorMessage:h.message})}const a=n.dataTransfer.getData(de.excalidrawlib);if(a&&typeof a=="string"){try{const h=JI(a);this.addElementsFromPasteOrLibrary({elements:i7(h),position:n,files:null})}catch(h){this.setState({errorMessage:h.message})}return}if(r&&await this.loadFileToCanvas(r,i),(c=(l=n.dataTransfer)==null?void 0:l.types)!=null&&c.includes("text/plain")){const h=(u=n.dataTransfer)==null?void 0:u.getData("text");if(h&&Rf(h,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(h)||((d=yl(h))==null?void 0:d.type)==="video")){const m=this.insertEmbeddableElement({sceneX:o,sceneY:s,link:xi(h)});m&&this.setState({selectedElementIds:{[m.id]:!0}})}}});M(this,"loadFileToCanvas",async(n,r)=>{n=await pE(n);try{let i;try{i=await QI(n,this.state,this.scene.getElementsIncludingDeleted(),r)}catch(o){const s=o instanceof js;if(s&&o.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:b("errors.imageToolNotSupported")});return}const a=b(s?"alerts.cannotRestoreFromImage":"alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:a})}if(!i)return;i.type===de.excalidraw?(this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,commitToHistory:!0})):i.type===de.excalidrawlib&&await this.library.updateLibrary({libraryItems:n,merge:!0,openLibraryMenu:!0}).catch(o=>{console.error(o),this.setState({errorMessage:b("errors.importLibraryError")})})}catch(i){this.setState({isLoading:!1,errorMessage:i.message})}});M(this,"handleCanvasContextMenu",n=>{if(n.preventDefault(),("pointerType"in n.nativeEvent&&n.nativeEvent.pointerType==="touch"||"pointerType"in n.nativeEvent&&n.nativeEvent.pointerType==="pen"&&n.button!==xs.SECONDARY)&&this.state.activeTool.type!=="selection")return;const{x:r,y:i}=et(n,this.state),o=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),s=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:i},s),l=o||a?"element":"canvas",c=this.excalidrawContainerRef.current,{top:u,left:d}=c.getBoundingClientRect(),h=n.clientX-d,m=n.clientY-u;Ae("contextMenu","openContextMenu",l),this.setState({...o&&!this.state.selectedElementIds[o.id]?{...this.state,...Zn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[o.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:we(o)?new ue(o):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:m,left:h,items:this.getContextMenuItems(l)}})})});M(this,"maybeDragNewGenericElement",(n,r)=>{var s,a,l;const i=this.state.draggingElement,o=n.lastCoords;if(i)if(i.type==="selection"&&this.state.activeTool.type!=="eraser")g6(i,this.state.activeTool.type,n.origin.x,n.origin.y,o.x,o.y,un(n.origin.x,o.x),un(n.origin.y,o.y),Bc(r),yp(r));else{let[c,u]=jt(o.x,o.y,r[D.CTRL_OR_CMD]?null:this.state.gridSize);const d=Ft(i)&&((s=this.imageCache.get(i.fileId))==null?void 0:s.image),h=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(r,[i]);const{snapOffset:m,snapLines:g}=rX(i,this.state,r,{x:n.originInGrid.x+(((a=this.state.originSnapOffset)==null?void 0:a.x)??0),y:n.originInGrid.y+(((l=this.state.originSnapOffset)==null?void 0:l.y)??0)},{x:c-n.originInGrid.x,y:u-n.originInGrid.y},this.scene.getNonDeletedElementsMap());c+=m.x,u+=m.y,this.setState({snapLines:g}),g6(i,this.state.activeTool.type,n.originInGrid.x,n.originInGrid.y,c,u,un(n.originInGrid.x,c),un(n.originInGrid.y,u),Gi(i)?!Bc(r):Bc(r),yp(r),h,this.state.originSnapOffset),this.maybeSuggestBindingForAll([i]),(this.state.activeTool.type===zt.frame||this.state.activeTool.type===zt.magicframe)&&this.setState({elementsToHighlight:Hf(this.scene.getNonDeletedElements(),i,this.state,this.scene.getNonDeletedElementsMap())})}});M(this,"maybeHandleResize",(n,r)=>{const i=this.scene.getSelectedElements(this.state),o=i.filter(d=>pe(d)),s=n.resize.handleType;if(o.length>0&&s==="rotation")return!1;this.setState({isResizing:s&&s!=="rotation",isRotating:s==="rotation",activeEmbeddable:null});const a=n.lastCoords;let[l,c]=jt(a.x-n.resize.offset.x,a.y-n.resize.offset.y,r[D.CTRL_OR_CMD]?null:this.state.gridSize);const u=new Map;if(o.forEach(d=>{eo(this.scene.getNonDeletedElements(),d.id).forEach(m=>{u.set(d.id+m.id,{x:m.x-d.x,y:m.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){const[d,h]=jt(a.x,a.y,r[D.CTRL_OR_CMD]?null:this.state.gridSize),m={x:d-n.originInGrid.x,y:h-n.originInGrid.y},g=[...n.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,i);const{snapOffset:p,snapLines:v}=nX(i,qe(g,this.state),this.state,r,m,s);l+=p.x,c+=p.y,this.setState({snapLines:v})}if(Bz(n.originalElements,s,i,this.scene.getElementsMapIncludingDeleted(),Mu(r),yp(r),i.length===1&&Gi(i[0])?!Bc(r):Bc(r),l,c,n.resize.center.x,n.resize.center.y)){this.maybeSuggestBindingForAll(i);const d=new Set;return o.forEach(h=>{Hf(this.scene.getNonDeletedElements(),h,this.state,this.scene.getNonDeletedElementsMap()).forEach(m=>d.add(m))}),this.setState({elementsToHighlight:[...d]}),!0}return!1});M(this,"getContextMenuItems",n=>{const r=[];return r.push(r4,n4),n==="canvas"?this.state.viewModeEnabled?[...r,o4,my,L4,e1]:[e4,Ln,r4,n4,i4,Ln,hW,Fj,Ln,o4,_j,my,L4,e1]:(r.push(i4),this.state.viewModeEnabled?[Kf,...r]:[t4,Kf,e4,YZ,KZ,Ln,...r,Ln,aj,lj,Ln,uj,xj,Sj,Cj,dj,Ln,gj,Ln,lW,cW,uW,dW,Ln,Ej,wj,Ln,$j,Oj,pW,Nj,Ln,e8])});M(this,"handleWheel",Je(n=>{if(n.preventDefault(),Xc)return;const{deltaX:r,deltaY:i}=n;if(n.metaKey||n.ctrlKey){const o=Math.sign(i),s=dd*100,a=Math.abs(i);let l=i;a>s&&(l=s*o);let c=this.state.zoom.value-l/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-o*Math.min(1,a/20),this.translateCanvas(u=>({...Xs({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Zs(c)},u),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(n.shiftKey){this.translateCanvas(({zoom:o,scrollX:s})=>({scrollX:s-(i||r)/o.value}));return}this.translateCanvas(({zoom:o,scrollX:s,scrollY:a})=>({scrollX:s-r/o.value,scrollY:a-i/o.value}))}));M(this,"savePointer",(n,r,i)=>{var l,c;if(!n||!r)return;const{x:o,y:s}=et({clientX:n,clientY:r},this.state),a={x:o,y:s,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};(c=(l=this.props).onPointerUpdate)==null||c.call(l,{pointer:a,button:i,pointersMap:Pe.pointers})});M(this,"resetShouldCacheIgnoreZoomDebounced",fa(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));M(this,"updateDOMRect",n=>{var r;if((r=this.excalidrawContainerRef)!=null&&r.current){const i=this.excalidrawContainerRef.current,{width:o,height:s,left:a,top:l}=i.getBoundingClientRect(),{width:c,height:u,offsetTop:d,offsetLeft:h}=this.state;if(o===c&&s===u&&a===h&&l===d){n&&n();return}this.setState({width:o,height:s,offsetLeft:a,offsetTop:l},()=>{n&&n()})}});M(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});const r=qr(),{excalidrawAPI:i,viewModeEnabled:o=!1,zenModeEnabled:s=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:l=!1,theme:c=r.theme,name:u=`${b("labels.untitled")}-${bb()}`}=n;if(this.state={...r,theme:c,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:o,zenModeEnabled:s,objectsSnapModeEnabled:l,gridSize:a?Cl:null,name:u,width:window.innerWidth,height:window.innerHeight},this.id=Kv(),this.library=new jj(this),this.actionManager=new Hj(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new $t,this.canvas=document.createElement("canvas"),this.rc=ws.canvas(this.canvas),this.renderer=new z4(this.scene),i){const d={updateScene:this.updateScene,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:h=>{this.actionManager.registerAction(h)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:h=>this.onChangeEmitter.on(h),onPointerDown:h=>this.onPointerDownEmitter.on(h),onPointerUp:h=>this.onPointerUpEmitter.on(h),onScrollChange:h=>this.onScrollChangeEmitter.on(h),onUserFollow:h=>this.onUserFollowEmitter.on(h)};typeof i=="function"?i(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new xy({scene:this.scene,onSceneUpdated:this.onSceneUpdated}),this.history=new Zj,this.actionManager.registerAll(F2),this.actionManager.registerAction(Bj(this.history)),this.actionManager.registerAction(zj(this.history))}onWindowMessage(n){if(n.origin!=="https://player.vimeo.com"&&n.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(n.data)}catch{}if(r)switch(n.origin){case"https://player.vimeo.com":if(r.method==="paused"){let i=null;const o=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!o)break;for(const s of o)s.contentWindow===n.source&&(i=s.contentWindow);i==null||i.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){const i=r.id,o=r.info.playerState;Object.values(Dh).includes(o)&&c0.set(i,o)}break}}cacheEmbeddableRef(n,r){r&&this.iFrameRefs.set(n.id,r)}getHTMLIFrameElement(n){return this.iFrameRefs.get(n.id)}handleEmbeddableCenterClick(n){var i,o,s,a;if(((i=this.state.activeEmbeddable)==null?void 0:i.element)===n&&((o=this.state.activeEmbeddable)==null?void 0:o.state)==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:n,state:"active"},selectedElementIds:{[n.id]:!0},draggingElement:null,selectionElement:null})},100),Io(n)))return;const r=this.getHTMLIFrameElement(n);if(r!=null&&r.contentWindow){if(r.src.includes("youtube")){const l=c0.get(n.id);switch(l||(c0.set(n.id,Dh.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:n.id}),"*")),l){case Dh.PLAYING:case Dh.BUFFERING:(s=r.contentWindow)==null||s.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:(a=r.contentWindow)==null||a.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(n,r,i,o){var s,a;return n&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(((s=this.state.activeEmbeddable)==null?void 0:s.element)!==n||((a=this.state.activeEmbeddable)==null?void 0:a.state)==="hover"||!this.state.activeEmbeddable)&&i>=n.x+n.width/3&&i<=n.x+2*n.width/3&&o>=n.y+n.height/3&&o<=n.y+2*n.height/3}renderEmbeddables(){const n=this.state.zoom.value,r=this.state.width,i=this.state.height,o=this.scene.getNonDeletedElements().filter(s=>bn(s)&&this.embedsValidationStatus.get(s.id)===!0||Io(s));return f(re,{children:o.map(s=>{var p,v,y,E,w,x,C;const{x:a,y:l}=Ur({sceneX:s.x,sceneY:s.y},this.state),c=jm(s,r,i,this.state,this.scene.getNonDeletedElementsMap()),u=this.initializedEmbeds.has(s.id);if(c&&!u&&this.initializedEmbeds.add(s.id),!(c||u))return null;let h;if(Io(s)){h=null;const S=(((p=s.customData)==null?void 0:p.generationData)??this.magicGenerations.get(s.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(S.status==="done"){const I=S.html;h={intrinsicSize:{w:s.width,h:s.height},type:"document",srcdoc:()=>I}}else if(S.status==="pending")h={intrinsicSize:{w:s.width,h:s.height},type:"document",srcdoc:()=>pl(`
<style>
html, body {
width: 100%;
height: 100%;
color: ${this.state.theme==="dark"?"white":"black"};
}
body {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 1rem;
}
.Spinner {
display: flex;
align-items: center;
justify-content: center;
margin-left: auto;
margin-right: auto;
}
.Spinner svg {
animation: rotate 1.6s linear infinite;
transform-origin: center center;
width: 40px;
height: 40px;
}
.Spinner circle {
stroke: currentColor;
animation: dash 1.6s linear 0s infinite;
stroke-linecap: round;
}
@keyframes rotate {
100% {
transform: rotate(360deg);
}
}
@keyframes dash {
0% {
stroke-dasharray: 1, 300;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 150, 300;
stroke-dashoffset: -200;
}
100% {
stroke-dasharray: 1, 300;
stroke-dashoffset: -280;
}
}
</style>
<div class="Spinner">
<svg
viewBox="0 0 100 100"
>
<circle
cx="50"
cy="50"
r="46"
stroke-width="8"
fill="none"
stroke-miter-limit="10"
/>
</svg>
</div>
<div>Generating...</div>
`)};else{let I;S.code==="ERR_GENERATION_INTERRUPTED"?I="Generation was interrupted...":I=S.message||"Generation failed",h={intrinsicSize:{w:s.width,h:s.height},type:"document",srcdoc:()=>pl(`
<style>
html, body {
height: 100%;
}
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: ${ve.red[3]};
}
h1, h3 {
margin-top: 0;
margin-bottom: 0.5rem;
}
</style>
<h1>Error!</h1>
<h3>${I}</h3>
`)}}}else h=yl(BI(s.link||""));const m=((v=this.state.activeEmbeddable)==null?void 0:v.element)===s&&((y=this.state.activeEmbeddable)==null?void 0:y.state)==="active",g=((E=this.state.activeEmbeddable)==null?void 0:E.element)===s&&((w=this.state.activeEmbeddable)==null?void 0:w.state)==="hover";return f("div",{className:se("excalidraw__embeddable-container",{"is-hovered":g}),style:{transform:c?`translate(${a-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${n})`:"none",display:c?"block":"none",opacity:DT(s,rr(s,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure),"--embeddable-radius":`${oa(Math.min(s.width,s.height),s)}px`},children:k("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${s.width}px`:0,height:c?`${s.height}px`:0,transform:c?`rotate(${s.angle}rad)`:"none",pointerEvents:m?Ms.enabled:Ms.disabled},children:[g&&f("div",{className:"excalidraw__embeddable-hint",children:b("buttons.embeddableInteractionButton")}),f("div",{className:"excalidraw__embeddable__outer",style:{padding:`${s.strokeWidth}px`},children:(bn(s)?(C=(x=this.props).renderEmbeddable)==null?void 0:C.call(x,s,this.state):null)??f("iframe",{ref:S=>this.cacheEmbeddableRef(s,S),className:"excalidraw__embeddable",srcDoc:(h==null?void 0:h.type)==="document"?h.srcdoc(this.state.theme):void 0,src:(h==null?void 0:h.type)!=="document"?(h==null?void 0:h.link)??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:"allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads"})})]})},s.id)})})}toggleOverscrollBehavior(n){document.documentElement.style.overscrollBehaviorX=n.type==="pointerenter"?"none":"auto"}render(){var d,h,m,g,p;const n=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:i}=this.props,o=this.scene.getVersionNonce(),{elementsMap:s,visibleElements:a}=this.renderer.getRenderableElements({versionNonce:o,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingElement:this.state.editingElement,pendingImageElementId:this.state.pendingImageElementId}),l=this.scene.getNonDeletedElementsMap(),c=!(this.state.editingElement&&we(this.state.editingElement))&&(this.state.selectionElement||this.state.draggingElement||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down"||this.state.editingElement&&!ce(this.state.editingElement)),u=n[0];return f("div",{className:se("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled,"excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":c?Ms.disabled:Ms.enabled},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:f(FM.Provider,{value:this,children:f($M.Provider,{value:this.props,children:f(Ew.Provider,{value:this.excalidrawContainerValue,children:f(vw.Provider,{value:this.device,children:f(_w.Provider,{value:this.setAppState,children:f(bw.Provider,{value:this.state,children:k(ww.Provider,{value:this.scene.getNonDeletedElements(),children:[k(xw.Provider,{value:this.actionManager,children:[f(VZ,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Yd().code,renderTopRightUI:r,renderCustomStats:i,showExitZenModeBtn:typeof((d=this.props)==null?void 0:d.zenModeEnabled)>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,openAIKey:this.OPENAI_KEY,isOpenAIKeyPersisted:this.OPENAI_KEY_IS_PERSISTED,onOpenAIAPIKeyChange:this.onOpenAIKeyChange,onMagicSettingsConfirm:this.onMagicSettingsConfirm,children:this.props.children}),f("div",{className:"excalidraw-textEditorContainer"}),f("div",{className:"excalidraw-contextMenuContainer"}),f("div",{className:"excalidraw-eye-dropper-container"}),f(TX,{trails:[this.laserTrails,this.eraserTrail]}),n.length===1&&this.state.showHyperlinkPopup&&f(Aj,{element:u,elementsMap:l,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},u.id),this.props.aiEnabled!==!1&&n.length===1&&uu(u)&&f(H4,{element:u,elementsMap:s,children:f(o0,{title:b("labels.convertToCode"),icon:UE,checked:!1,onChange:()=>this.onMagicFrameGenerate(u,"button")})}),n.length===1&&Io(u)&&((m=(h=u.customData)==null?void 0:h.generationData)==null?void 0:m.status)==="done"&&k(H4,{element:u,elementsMap:s,children:[f(o0,{title:b("labels.copySource"),icon:hg,checked:!1,onChange:()=>this.onIframeSrcCopy(u)}),f(o0,{title:"Enter fullscreen",icon:KU,checked:!1,onChange:()=>{const v=this.getHTMLIFrameElement(u);if(v)try{v.requestFullscreen(),this.setState({activeEmbeddable:{element:u,state:"active"},selectedElementIds:{[u.id]:!0},draggingElement:null,selectionElement:null})}catch(y){console.warn(y),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&f(jZ,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&f(Qj,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:v=>{this.setState({contextMenu:null},()=>{this.focusContainer(),v==null||v()})}}),f(CX,{canvas:this.canvas,rc:this.rc,elementsMap:s,allElementsMap:l,visibleElements:a,versionNonce:o,selectionNonce:(g=this.state.selectionElement)==null?void 0:g.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!0,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure}}),f(SX,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:s,visibleElements:a,selectedElements:n,versionNonce:o,selectionNonce:(p=this.state.selectionElement)==null?void 0:p.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&f(DX,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}getTextFromElements(n){return n.reduce((i,o)=>(ce(o)&&i.push(o.text),i),[]).join(`
`)}async onMagicFrameGenerate(n,r){var h;if(!this.OPENAI_KEY){this.setState({openDialog:{name:"settings",tab:"diagram-to-code",source:"generation"}}),Ae("ai","generate (missing key)","d2c");return}const i=PE(this.scene.getNonDeletedElements(),n).filter(m=>!uu(m));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),Ae("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}const o=this.insertIframeElement({sceneX:n.x+n.width+30,sceneY:n.y,width:n.width,height:n.height});if(!o)return;this.updateMagicGeneration({frameElement:o,data:{status:"pending"}}),this.setState({selectedElementIds:{[o.id]:!0}});const s=await gz({elements:this.scene.getNonDeletedElements(),appState:{...this.state,exportBackground:!0,viewBackgroundColor:this.state.viewBackgroundColor},exportingFrame:n,files:this.files}),a=await bp(s),l=this.getTextFromElements(i);Ae("ai","generate (start)","d2c");const c=await PX({image:a,apiKey:this.OPENAI_KEY,text:l,theme:this.state.theme});if(!c.ok){Ae("ai","generate (failed)","d2c"),console.error(c.error),this.updateMagicGeneration({frameElement:o,data:{status:"error",code:"ERR_OAI",message:((h=c.error)==null?void 0:h.message)||"Unknown error during generation"}});return}if(Ae("ai","generate (success)","d2c"),c.choices[0].message.content==null){this.updateMagicGeneration({frameElement:o,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}const u=c.choices[0].message.content,d=u.slice(u.indexOf("<!DOCTYPE html>"),u.indexOf("</html>")+7);this.updateMagicGeneration({frameElement:o,data:{status:"done",html:d}})}onIframeSrcCopy(n){var r,i;((i=(r=n.customData)==null?void 0:r.generationData)==null?void 0:i.status)==="done"&&(Fa(n.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}async componentDidMount(){var r;this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,this.scene.addCallback(this.onSceneUpdated),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints(),m2&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),this.updateDOMRect()}),(r=this.resizeObserver)==null||r.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),eR()&&!oN()&&this.setState({errorMessage:f(sX,{})})}componentWillUnmount(){var n;this.renderer.destroy(),this.scene=new $t,this.renderer=new z4(this.scene),this.files={},this.imageCache.clear(),(n=this.resizeObserver)==null||n.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.scene.destroy(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),Xe.destroy(),$r.destroy(),clearTimeout(mo),Lt.clearCache(),Zn.clearCache(),mo=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(gt(document,Z.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(gt(this.excalidrawContainerRef.current,Z.WHEEL,this.onWheel,{passive:!1}),gt(window,Z.MESSAGE,this.onWindowMessage,!1),gt(document,Z.POINTER_UP,this.removePointer),gt(document,Z.COPY,this.onCopy),gt(document,Z.KEYUP,this.onKeyUp,{passive:!0}),gt(document,Z.MOUSE_MOVE,this.updateCurrentCursorPosition),gt(document.fonts,"loadingdone",n=>{const r=n.fontfaces;this.fonts.onFontsLoaded(r)}),gt(document,Z.GESTURE_START,this.onGestureStart,!1),gt(document,Z.GESTURE_CHANGE,this.onGestureChange,!1),gt(document,Z.GESTURE_END,this.onGestureEnd,!1),gt(window,Z.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null)})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(gt(document,Z.FULLSCREENCHANGE,this.onFullscreenChange),gt(document,Z.PASTE,this.pasteFromClipboard),gt(document,Z.CUT,this.onCut),gt(window,Z.RESIZE,this.onResize,!1),gt(window,Z.UNLOAD,this.onUnload,!1),gt(window,Z.BLUR,this.onBlur,!1),gt(this.excalidrawContainerRef.current,Z.DRAG_OVER,this.disableEvent,!1),gt(this.excalidrawContainerRef.current,Z.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(gt(TD(this.excalidrawContainerRef.current),Z.SCROLL,this.onScroll)))}componentDidUpdate(n,r){var l,c,u,d,h,m;this.updateEmbeddables();const i=this.scene.getElementsIncludingDeleted(),o=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!i.length&&this.setState({showWelcomeScreen:!0}),n.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.scrollY!==this.state.scrollY)&&((c=(l=this.props)==null?void 0:l.onScrollChange)==null||c.call(l,this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&mi(this.state)&&this.setState({activeTool:bt(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&UI(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),n.langCode!==this.props.langCode&&this.updateLanguage(),mi(r)&&!mi(this.state)&&this.eraserTrail.endPath(),n.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),n.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),n.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),n.gridModeEnabled!==this.props.gridModeEnabled&&this.setState({gridSize:this.props.gridModeEnabled?Cl:null}),(u=this.excalidrawContainerRef.current)==null||u.classList.toggle("theme--dark",this.state.theme==="dark"),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(li)}),(d=this.state.editingElement)!=null&&d.isDeleted&&this.setState({editingElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});const{multiElement:a}=r;r.activeTool!==this.state.activeTool&&a!=null&&Gs(this.state)&&dn(a,!1)&&R2(a,this.state,this.scene,Oo(ue.getPointAtIndexGlobalCoordinates(a,-1,o)),o),this.history.record(this.state,i),this.state.isLoading||((m=(h=this.props).onChange)==null||m.call(h,i,this.state,this.files),this.onChangeEmitter.trigger(i,this.state,this.files))}static resetTapTwice(){Zc=!1}async addElementsFromMixedContentPaste(n,{isPlainPaste:r,sceneX:i,sceneY:o}){if(!r&&n.some(s=>s.type==="imageUrl")&&this.isToolSupported("image")){const s=n.filter(h=>h.type==="imageUrl").map(h=>h.value),a=await Promise.all(s.map(async h=>{try{return{file:await bF(h)}}catch(m){let g=m.message;return m.cause==="FETCH_ERROR"?g=b("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(g=b("errors.unsupportedFileType")),{errorMessage:g}}}));let l=o,c=!1;const u={};for(const h of a)if(h.file){const m=this.createImageElement({sceneX:i,sceneY:l}),g=await this.insertImageElement(m,h.file);g&&(c||(c=!0,l-=g.height/2),J(g,{y:l},!1),l=m.y+m.height+25,u[m.id]=!0)}this.setState({selectedElementIds:$e(u,this.state)});const d=a.find(h=>!!h.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{const s=n.filter(a=>a.type==="text");s.length&&this.addTextFromPaste(s.map(a=>a.value).join(`
`),r)}}addTextFromPaste(n,r=!1){const{x:i,y:o}=et({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),s={x:i,y:o,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:n,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:this.state.currentItemTextAlign,verticalAlign:_m,locked:!1},a=10;let l=o;const c=r?[n]:n.split(`
`),u=c.reduce((h,m,g)=>{var y;const p=m.trim(),v=wa(s.fontFamily);if(p.length){const E=this.getTopLayerFrameAtSceneCoords({x:i,y:l}),w=Sr({...s,x:i,y:l,text:p,lineHeight:v,frameId:E?E.id:null});h.push(w),l+=w.height+a}else((y=c[g-1])==null?void 0:y.trim())&&(l+=Qd(s.fontSize,v)+a);return h},[]);if(u.length===0)return;const d=u[0].frameId;d?this.scene.insertElementsAtIndex(u,this.scene.getElementIndex(d)):this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted(),...u]),this.setState({selectedElementIds:$e(Object.fromEntries(u.map(h=>[h.id,!0])),this.state)}),!r&&u.length>1&&j4===!1&&!this.device.editor.isMobile&&(this.setToast({message:b("toast.pasteAsSingleElement",{shortcut:K("CtrlOrCmd+Shift+V")}),duration:5e3}),j4=!0),this.history.resumeRecording()}handleTextWysiwyg(n,{isExistingElement:r=!1}){const i=this.scene.getElementsMapIncludingDeleted(),o=(s,a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(c=>c.id===n.id&&ce(c)?jN(c,kn(c,i),i,{text:s,isDeleted:l,originalText:a}):c)])};VX({id:n.id,canvas:this.canvas,getViewportCoords:(s,a)=>{const{x:l,y:c}=Ur({sceneX:s,sceneY:a},this.state);return[l-this.state.offsetLeft,c-this.state.offsetTop]},onChange:Je(s=>{o(s,s,!1),ty(n)&&us(n,i)}),onSubmit:Je(({text:s,viaKeyboard:a,originalText:l})=>{const c=!s.trim();if(o(s,l,c),!c&&a){const u=n.containerId?n.containerId:n.id;this.setState(d=>({selectedElementIds:$e({...d.selectedElementIds,[u]:!0},d)}))}c&&aE(this.scene.getNonDeletedElements(),[n]),(!c||r)&&this.history.resumeRecording(),this.setState({draggingElement:null,editingElement:null}),this.state.activeTool.locked&&di(this.interactiveCanvas,this.state),this.focusContainer()}),element:n,excalidrawContainer:this.excalidrawContainerRef.current,app:this}),this.deselectElements(),o(n.text,n.originalText,!1)}deselectElements(){this.setState({selectedElementIds:$e({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(n,r){const i=this.getElementAtPosition(n,r,{includeBoundTextElement:!0});return i&&ce(i)&&!i.isDeleted?i:null}getElementAtPosition(n,r,i){const o=this.getElementsAtPosition(n,r,i==null?void 0:i.includeBoundTextElement,i==null?void 0:i.includeLockedElements);if(o.length>1){if(i!=null&&i.preferSelected){for(let a=o.length-1;a>-1;a--)if(this.state.selectedElementIds[o[a].id])return o[a]}const s=o[o.length-1];return pp(s,this.state,this.frameNameBoundsCache,n,r,this.scene.getNonDeletedElementsMap())?o[o.length-2]:s}return o.length===1?o[0]:null}getElementsAtPosition(n,r,i=!1,o=!1){const s=i&&o?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(l=>(o||!l.locked)&&(i||!(ce(l)&&l.containerId))),a=this.scene.getNonDeletedElementsMap();return ZD(s,l=>Rm(l,this.state,this.frameNameBoundsCache,n,r,a)).filter(l=>{const c=rr(l,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?s6({x:n,y:r},c,a):!0})}handleHoverSelectedLinearElement(n,r,i){const o=this.scene.getNonDeletedElementsMap(),s=ue.getElement(n.elementId,o),a=ke(s,o);if(s)if(this.state.selectedLinearElement){let l=-1,c=null;vd(s,this.state,this.frameNameBoundsCache,[r,i],o)?(l=ue.getPointIndexUnderCursor(s,o,this.state.zoom,r,i),c=ue.getSegmentMidpointHitCoords(n,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),l>=0||c?He(this.interactiveCanvas,Be.POINTER):He(this.interactiveCanvas,Be.MOVE)):nE([s],this.state)&&pp(s,this.state,this.frameNameBoundsCache,r,i,o)?He(this.interactiveCanvas,Be.MOVE):a&&Rm(a,this.state,this.frameNameBoundsCache,r,i,this.scene.getNonDeletedElementsMap())&&He(this.interactiveCanvas,Be.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),ue.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,c)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:c}})}else He(this.interactiveCanvas,Be.AUTO)}updateGestureOnPointerDown(n){Pe.pointers.set(n.pointerId,{x:n.clientX,y:n.clientY}),Pe.pointers.size===2&&(Pe.lastCenter=u4(Pe.pointers),Pe.initialScale=this.state.zoom.value,Pe.initialDistance=d4(Array.from(Pe.pointers.values())))}initialPointerDownState(n){const r=et(n,this.state),i=this.scene.getSelectedElements(this.state),[o,s,a,l]=nt(i);return{origin:r,withCmdOrCtrl:n[D.CTRL_OR_CMD],originInGrid:Oo(jt(r.x,r.y,n[D.CTRL_OR_CMD]?null:this.state.gridSize)),scrollbars:w4(l0,n.clientX-this.state.offsetLeft,n.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((c,u)=>(c.set(u.id,th(u)),c),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(a+o)/2,y:(l+s)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,i)},drag:{hasOccurred:!1,offset:null},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(n,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;a0=!0,r.lastCoords.x=n.clientX,r.lastCoords.y=n.clientY;const i=r0(s=>{s.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(s,r)}),o=Je(()=>{ks=null,a0=!1,di(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(n.clientX,n.clientY,"up"),window.removeEventListener(Z.POINTER_MOVE,i),window.removeEventListener(Z.POINTER_UP,o),i.flush()});return ks=o,window.addEventListener(Z.POINTER_MOVE,i),window.addEventListener(Z.POINTER_UP,o),!0}isASelectedElement(n){return n!=null&&this.state.selectedElementIds[n.id]}isHittingCommonBoundingBoxOfSelectedElements(n,r){if(r.length<2)return!1;const i=10/this.state.zoom.value,[o,s,a,l]=nt(r);return n.x>o-i&&n.x<a+i&&n.y>s-i&&n.y<l+i}getCurrentItemRoundness(n){return this.state.currentItemRoundness==="round"?{type:uc(n)?Vt.ADAPTIVE_RADIUS:Vt.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(n,r,i=!1){ms({event:n,appState:this.state,selectedElements:r})&&(i||!$r.getReferenceSnapPoints())&&$r.setReferenceSnapPoints(QZ(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(n,r,i=!1){ms({event:n,appState:this.state,selectedElements:r})&&(i||!$r.getVisibleGaps())&&$r.setVisibleGaps(qZ(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(n){return Je(r=>{this.maybeHandleResize(n,r)||this.maybeDragNewGenericElement(n,r)})}onKeyUpFromPointerDownHandler(n){return Je(r=>{r.key===D.ALT&&r.preventDefault(),!this.maybeHandleResize(n,r)&&this.maybeDragNewGenericElement(n,r)})}onPointerMoveFromPointerDownHandler(n){return r0(r=>{var h,m;if(n.drag.offset===null&&(n.drag.offset=Oo(Xz(this.scene.getSelectedElements(this.state),n.origin.x,n.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,n))return;const o=et(r,this.state);if(mi(this.state)){this.handleEraser(r,n,o);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(o.x,o.y);const[s,a]=jt(o.x,o.y,r[D.CTRL_OR_CMD]?null:this.state.gridSize);if(!n.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&kt(o.x,o.y,n.origin.x,n.origin.y)<Ts)return;if(n.resize.isResizing&&(n.lastCoords.x=o.x,n.lastCoords.y=o.y,this.maybeHandleResize(n,r)))return!0;const l=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){const g=this.state.editingLinearElement||this.state.selectedLinearElement;if(ue.shouldAddMidpoint(this.state.selectedLinearElement,o,this.state,l)){const v=ue.addMidpoint(this.state.selectedLinearElement,o,this.state,!r[D.CTRL_OR_CMD],l);if(!v)return;nr.flushSync(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:v.pointerDownState,selectedPointsIndices:v.selectedPointsIndices}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:v.pointerDownState,selectedPointsIndices:v.selectedPointsIndices}})});return}else if(g.pointerDownState.segmentMidpoint.value!==null&&!g.pointerDownState.segmentMidpoint.added)return;if(ue.handlePointDragging(r,this.state,o.x,o.y,(v,y)=>{this.maybeSuggestBindingsForLinearElementAtCoords(v,y)},g,this.scene.getNonDeletedElementsMap())){n.lastCoords.x=o.x,n.lastCoords.y=o.y,n.drag.hasOccurred=!0,this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging&&this.setState({editingLinearElement:{...this.state.editingLinearElement,isDragging:!0}}),this.state.selectedLinearElement.isDragging||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0}});return}}const c=n.hit.allHitElements.some(g=>this.isASelectedElement(g)),u=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===((h=n.hit.element)==null?void 0:h.id);if((c||n.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!u){const g=this.scene.getSelectedElements(this.state);if(g.every(y=>y.locked))return;const p=g.find(y=>pe(y)),v=this.getTopLayerFrameAtSceneCoords(o);if(this.setState({frameToHighlight:v&&!p?v:null}),n.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0}),g.length>0&&!n.withCmdOrCtrl&&!this.state.editingElement&&((m=this.state.activeEmbeddable)==null?void 0:m.state)!=="active"){const y={x:o.x-n.origin.x,y:o.y-n.origin.y},E=[...n.originalElements.values()],w=r.shiftKey;if(w){const S=Math.abs(y.x),I=Math.abs(y.y),T=w&&S<I,L=w&&S>I;T&&(y.x=0),L&&(y.y=0)}this.maybeCacheVisibleGaps(r,g),this.maybeCacheReferenceSnapPoints(r,g);const{snapOffset:x,snapLines:C}=JZ(E,y,this.state,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:C}),!this.state.editingFrame&&Kz(n,g,y,this.state,this.scene,x,r[D.CTRL_OR_CMD]?null:this.state.gridSize),this.maybeSuggestBindingForAll(g),r.altKey&&!n.hit.hasBeenDuplicated){n.hit.hasBeenDuplicated=!0;const S=[],I=[],T=new Map,L=new Map,A=n.hit.element,F=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).map(V=>V.id)),P=this.scene.getElementsIncludingDeleted();for(const V of P)if(F.has(V.id)||V.id===(A==null?void 0:A.id)&&n.hit.wasAddedToSelection){const G=jI(this.state.editingGroupId,T,V),q=n.originalElements.get(V.id);J(G,{x:q.x,y:q.y}),n.originalElements.set(G.id,G),S.push(G),I.push(V),L.set(V.id,G.id)}else S.push(V);const O=[...S,...I];kI(S,I,L),xI(O,I,L,"duplicatesServeAsOld"),_T(O,I,L),this.scene.replaceAllElements(O),this.maybeCacheVisibleGaps(r,g,!0),this.maybeCacheReferenceSnapPoints(r,g,!0)}return}}const d=this.state.draggingElement;if(d){if(d.type==="freedraw"){const g=d.points,p=o.x-d.x,v=o.y-d.y,y=g.length>0&&g[g.length-1];if(!(y&&y[0]===p&&y[1]===v)){const w=d.simulatePressure?d.pressures:[...d.pressures,r.pressure];J(d,{points:[...g,[p,v]],pressures:w})}}else if(we(d)){n.drag.hasOccurred=!0,this.setState({selectedElementsAreBeingDragged:!0});const g=d.points;let p=s-d.x,v=a-d.y;Mu(r)&&g.length===2&&({width:p,height:v}=J2(d.x,d.y,o.x,o.y)),g.length===1?J(d,{points:[...g,[p,v]]}):g.length===2&&J(d,{points:[...g.slice(0,-1),[p,v]]}),dn(d,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(d,[o],this.state.startBoundElement)}else n.lastCoords.x=o.x,n.lastCoords.y=o.y,this.maybeDragNewGenericElement(n,r);if(this.state.activeTool.type==="selection"){n.boxSelection.hasOccurred=!0;const g=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)ue.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let p=!0;!r.shiftKey&&Lt(g,this.state)&&(n.withCmdOrCtrl&&n.hit.element?this.setState(y=>Zn({...y,selectedElementIds:{[n.hit.element.id]:!0}},this.scene.getNonDeletedElements(),y,this)):p=!1);const v=NE(g,d,this.scene.getNonDeletedElementsMap());this.setState(y=>{const E={...p&&y.selectedElementIds,...v.reduce((w,x)=>(w[x.id]=!0,w),{})};return n.hit.element&&(v.length?delete E[n.hit.element.id]:E[n.hit.element.id]=!0),y=p?y:{...y,selectedGroupIds:{},editingGroupId:null},{...Zn({editingGroupId:y.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),y,this),selectedLinearElement:v.length===1&&we(v[0])?new ue(v[0]):null,showHyperlinkPopup:v.length===1&&(v[0].link||bn(v[0]))?"info":!1}})}}}})}handlePointerMoveOverScrollbars(n,r){if(r.scrollbars.isOverHorizontal){const i=n.clientX,o=i-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-o/this.state.zoom.value}),r.lastCoords.x=i,!0}if(r.scrollbars.isOverVertical){const i=n.clientY,o=i-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-o/this.state.zoom.value}),r.lastCoords.y=i,!0}return!1}onPointerUpFromPointerDownHandler(n){return Je(r=>{var g,p,v,y,E,w,x,C;this.removePointer(r),n.eventListeners.onMove&&n.eventListeners.onMove.flush();const{draggingElement:i,resizingElement:o,multiElement:s,activeTool:a,isResizing:l,isRotating:c}=this.state;this.setState(S=>({isResizing:!1,isRotating:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",editingElement:s||ce(this.state.editingElement)?this.state.editingElement:null,snapLines:mp(S.snapLines,[]),originSnapOffset:null})),$r.setReferenceSnapPoints(null),$r.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});const u=this.scene.getNonDeletedElementsMap();if(this.state.editingLinearElement)if(!n.boxSelection.hasOccurred&&((p=(g=n.hit)==null?void 0:g.element)==null?void 0:p.id)!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(li);else{const S=ue.handlePointerUp(r,this.state.editingLinearElement,this.state,this.scene.getNonDeletedElements(),u);S!==this.state.editingLinearElement&&this.setState({editingLinearElement:S,suggestedBindings:[]})}else if(this.state.selectedLinearElement)if(((y=(v=n.hit)==null?void 0:v.element)==null?void 0:y.id)!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{const S=ue.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene.getNonDeletedElements(),u),{startBindingElement:I,endBindingElement:T}=S,L=this.scene.getElement(S.elementId);dn(L)&&dc(L,I,T,u),S!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...S,selectedPointsIndices:null},suggestedBindings:[]})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(Z.POINTER_MOVE,n.eventListeners.onMove),window.removeEventListener(Z.POINTER_UP,n.eventListeners.onUp),window.removeEventListener(Z.KEYDOWN,n.eventListeners.onKeyDown),window.removeEventListener(Z.KEYUP,n.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),(w=(E=this.props)==null?void 0:E.onPointerUp)==null||w.call(E,a,n),this.onPointerUpEmitter.trigger(this.state.activeTool,n,r),(i==null?void 0:i.type)==="freedraw"){const S=et(r,this.state),I=i.points;let T=S.x-i.x,L=S.y-i.y;T===I[0][0]&&L===I[0][1]&&(L+=1e-4,T+=1e-4);const A=i.simulatePressure?[]:[...i.pressures,r.pressure];J(i,{points:[...I,[T,L]],pressures:A,lastCommittedPoint:[T,L]}),this.actionManager.executeAction(li);return}if(Gi(i)){const S=i;try{this.initializeImageDimensions(S),this.setState({selectedElementIds:$e({[S.id]:!0},this.state)},()=>{this.actionManager.executeAction(li)})}catch(I){console.error(I),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(T=>T.id!==S.id)),this.actionManager.executeAction(li)}return}if(we(i)){i.points.length>1&&this.history.resumeRecording();const S=et(r,this.state);!n.drag.hasOccurred&&i&&!s?(J(i,{points:[...i.points,[S.x-i.x,S.y-i.y]]}),this.setState({multiElement:i,editingElement:this.state.draggingElement})):n.drag.hasOccurred&&!s&&(Gs(this.state)&&dn(i,!1)&&R2(i,this.state,this.scene,S,u),this.setState({suggestedBindings:[],startBoundElement:null}),a.locked?this.setState(I=>({draggingElement:null})):(Pr(this.interactiveCanvas),this.setState(I=>({draggingElement:null,activeTool:bt(this.state,{type:"selection"}),selectedElementIds:$e({...I.selectedElementIds,[i.id]:!0},I),selectedLinearElement:new ue(i)}))));return}if(a.type!=="selection"&&i&&Ma(i)){this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(S=>S.id!==i.id)),this.setState({draggingElement:null});return}if(i){if(n.drag.hasOccurred){const S=et(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){const I=this.scene.getElement(this.state.selectedLinearElement.elementId);if(I!=null&&I.frameId){const T=rr(I,u);T&&I&&(Ta(I,T,this.scene.getNonDeletedElementsMap())||(J(I,{groupIds:[]}),sg([I],this.scene.getNonDeletedElementsMap()),this.scene.informMutation()))}}else{const I=this.getTopLayerFrameAtSceneCoords(S),T=this.scene.getSelectedElements(this.state);let L=this.scene.getElementsMapIncludingDeleted();const A=F=>{if(F.length>0){for(const P of F){const O=P.groupIds.indexOf(this.state.editingGroupId);J(P,{groupIds:P.groupIds.slice(0,O)},!1)}L.forEach(P=>{P.groupIds.length&&It(L,P.groupIds[P.groupIds.length-1]).length<2&&J(P,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(I&&!this.state.selectedElementIds[I.id]){const F=T.filter(P=>P.frameId!==I.id&&Ad(P,L,this.state));this.state.editingGroupId&&A(F),L=Uf(L,F,I)}else if(!I&&this.state.editingGroupId){const F=T.filter(P=>P.frameId&&!Ad(P,L,this.state));A(F)}L=Ql(L,this.state,this),this.scene.replaceAllElements(L)}}if(pe(i)){const S=Sz(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Uf(this.scene.getElementsMapIncludingDeleted(),S,i))}J(i,BT(i))}if(o&&this.history.resumeRecording(),o&&Ma(o)&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(S=>S.id!==o.id)),n.resize.isResizing){let S=Ql(this.scene.getElementsIncludingDeleted(),this.state,this);const I=this.scene.getSelectedElements(this.state).filter(T=>pe(T));for(const T of I)S=MT(S,Hf(this.scene.getElementsIncludingDeleted(),T,this.state,u),T);this.scene.replaceAllElements(S)}const d=n.hit.element;((x=this.state.selectedLinearElement)==null?void 0:x.elementId)!==(d==null?void 0:d.id)&&we(d)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new ue(d)});const h=this.lastPointerDownEvent,m=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(mi(this.state)&&h&&m){if(this.eraserTrail.endPath(),kt(h.clientX,h.clientY,m.clientX,m.clientY)===0){const I=et({clientX:m.clientX,clientY:m.clientY},this.state);this.getElementsAtPosition(I.x,I.y).forEach(L=>this.elementsPendingErasure.add(L.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(d&&!n.drag.hasOccurred&&!n.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!n.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[d.id]?DI(this.state,d)?this.setState(S=>{const I={...S.selectedElementIds};for(const T of d.groupIds.flatMap(L=>It(this.scene.getNonDeletedElements(),L)))delete I[T.id];return{selectedGroupIds:{...S.selectedElementIds,...d.groupIds.map(T=>({[T]:!1})).reduce((T,L)=>({...T,...L}),{})},selectedElementIds:$e(I,S)}}):(C=this.state.selectedLinearElement)!=null&&C.isDragging||this.setState(S=>{const I={...S.selectedElementIds};delete I[d.id];const T=qe(this.scene.getNonDeletedElements(),{selectedElementIds:I});return{...Zn({editingGroupId:S.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),S,this),selectedLinearElement:T.length===1&&we(T[0])?new ue(T[0]):S.selectedLinearElement}}):d.frameId&&this.state.selectedElementIds[d.frameId]?this.setState(S=>{var T;const I={...S.selectedElementIds,[d.id]:!0};return delete I[d.frameId],(((T=this.scene.getElement(d.frameId))==null?void 0:T.groupIds)??[]).flatMap(L=>It(this.scene.getNonDeletedElements(),L)).forEach(L=>{delete I[L.id]}),{...Zn({editingGroupId:S.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),S,this),showHyperlinkPopup:d.link||bn(d)?"info":!1}}):this.setState(S=>({selectedElementIds:$e({...S.selectedElementIds,[d.id]:!0},S)})):this.setState(S=>{var I;return{...Zn({editingGroupId:S.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),S,this),selectedLinearElement:we(d)&&((I=S.selectedLinearElement)==null?void 0:I.elementId)!==d.id?new ue(d):S.selectedLinearElement}})),!n.drag.hasOccurred&&!this.state.isResizing&&(d&&pp(d,this.state,this.frameNameBoundsCache,n.origin.x,n.origin.y,this.scene.getNonDeletedElementsMap())||!d&&n.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:$e({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null});return}if(!a.locked&&a.type!=="freedraw"&&i&&i.type!=="selection"&&this.setState(S=>({selectedElementIds:$e({...S.selectedElementIds,[i.id]:!0},S),showHyperlinkPopup:bn(i)&&!i.link?"editor":S.showHyperlinkPopup})),(a.type!=="selection"||Lt(this.scene.getNonDeletedElements(),this.state))&&this.history.resumeRecording(),(n.drag.hasOccurred||l||c)&&(Gs(this.state)?P2(this.scene.getSelectedElements(this.state),this.scene.getNonDeletedElements(),u):D2(this.scene.getSelectedElements(this.state),u)),a.type==="laser"){this.laserTrails.endPath();return}!a.locked&&a.type!=="freedraw"?(Pr(this.interactiveCanvas),this.setState({draggingElement:null,suggestedBindings:[],activeTool:bt(this.state,{type:"selection"})})):this.setState({draggingElement:null,suggestedBindings:[]}),d&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&Pe.pointers.size<=1&&fr(d)&&this.isIframeLikeElementCenter(d,this.lastPointerUpEvent,n.origin.x,n.origin.y)&&this.handleEmbeddableCenterClick(d)})}maybeSuggestBindingForAll(n){if(n.length>50)return;const r=GO(n,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.setState({suggestedBindings:r})}clearSelection(n){this.setState(r=>({selectedElementIds:$e({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&n!=null&&bd(n,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:$e({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(n,r,i,o){if(o){let s=o.x+o.width/2,a=o.y+o.height/2;const l=Ep(o,i,this.scene.getNonDeletedElementsMap());if(l&&(s=l.x,a=l.y),Math.hypot(n-s,r-a)<nR){const{x:d,y:h}=Ur({sceneX:s,sceneY:a},i);return{viewportX:d,viewportY:h,elementCenterX:s,elementCenterY:a}}}}getCanvasOffsets(){var n;if((n=this.excalidrawContainerRef)!=null&&n.current){const r=this.excalidrawContainerRef.current,{left:i,top:o}=r.getBoundingClientRect();return{offsetLeft:i,offsetTop:o}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){const n=Gv.find(r=>r.code===this.props.langCode)||Es;await Ak(n),this.setAppState({})}}const GX=e=>{const{closeOnClickOutside:t=!0}=e,n=F8({className:"excalidraw-modal-container"});if(!n)return null;const r=i=>{i.key===D.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return nr.createPortal(k("div",{className:se("Modal",e.className),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[f("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),f("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),n)};function jX(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}const Vn=e=>{const[t,n]=Rk(),[r]=_.useState(document.activeElement),{id:i}=uo(),o=gn().viewport.isMobile;_.useEffect(()=>{if(!t)return;const c=S2(t);c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus();const u=d=>{if(d.key===D.TAB){const h=S2(t),{activeElement:m}=document,g=h.findIndex(p=>p===m);g===0&&d.shiftKey?(h[h.length-1].focus(),d.preventDefault()):g===h.length-1&&!d.shiftKey&&(h[0].focus(),d.preventDefault())}};return t.addEventListener("keydown",u),()=>t.removeEventListener("keydown",u)},[t,e.autofocus]);const s=Mn(),a=lc(rw,en),l=()=>{s({openMenu:null}),a(!1),r.focus(),e.onCloseRequest()};return f(GX,{className:se("Dialog",e.className,{"Dialog--fullscreen":o}),labelledBy:"dialog-title",maxWidth:jX(e.size),onCloseRequest:l,closeOnClickOutside:e.closeOnClickOutside,children:k(Yr,{ref:n,children:[e.title&&f("h2",{id:`${i}-dialog-title`,className:"Dialog__title",children:f("span",{className:"Dialog__titleContent",children:e.title})}),f("button",{className:"Dialog__close",onClick:l,title:b("buttons.close"),"aria-label":b("buttons.close"),children:o?tU:yc}),f("div",{className:"Dialog__content",children:e.children})]})})},Cw=({children:e,onClose:t})=>{const[n,r]=_.useState(!!e),{container:i}=uo(),o=te.useCallback(()=>{r(!1),t&&t(),i==null||i.focus()},[t,i]);return f(re,{children:n&&f(Vn,{size:"small",onCloseRequest:o,title:b("errorDialog.title"),children:f("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var Iy=function(e,t){return Iy=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i])},Iy(e,t)};function Lg(e,t){Iy(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var tt=function(){return tt=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},tt.apply(this,arguments)};function Y4(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function YX(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o}function $s(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(YX(arguments[t]));return e}var ns;(function(e){e.Ok="ok",e.Exited="exited",e.Crashed="crashed",e.Abnormal="abnormal"})(ns||(ns={}));var Jr;(function(e){e.Fatal="fatal",e.Error="error",e.Warning="warning",e.Log="log",e.Info="info",e.Debug="debug",e.Critical="critical"})(Jr||(Jr={}));(function(e){function t(n){switch(n){case"debug":return e.Debug;case"info":return e.Info;case"warn":case"warning":return e.Warning;case"error":return e.Error;case"fatal":return e.Fatal;case"critical":return e.Critical;case"log":default:return e.Log}}e.fromString=t})(Jr||(Jr={}));var Aa;(function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.Invalid="invalid",e.Failed="failed"})(Aa||(Aa={}));(function(e){function t(n){return n>=200&&n<300?e.Success:n===429?e.RateLimit:n>=400&&n<500?e.Invalid:n>=500?e.Failed:e.Unknown}e.fromHttpCode=t})(Aa||(Aa={}));/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function KX(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o}function ZX(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(KX(arguments[t]));return e}/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var me=function(){return me=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},me.apply(this,arguments)};function XX(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o}function Ds(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(XX(arguments[t]));return e}function zM(e){switch(Object.prototype.toString.call(e)){case"[object Error]":return!0;case"[object Exception]":return!0;case"[object DOMException]":return!0;default:return gs(e,Error)}}function HM(e){return Object.prototype.toString.call(e)==="[object ErrorEvent]"}function K4(e){return Object.prototype.toString.call(e)==="[object DOMError]"}function qX(e){return Object.prototype.toString.call(e)==="[object DOMException]"}function tc(e){return Object.prototype.toString.call(e)==="[object String]"}function Bd(e){return e===null||typeof e!="object"&&typeof e!="function"}function Pg(e){return Object.prototype.toString.call(e)==="[object Object]"}function Tw(e){return typeof Event<"u"&&gs(e,Event)}function Z4(e){return typeof Element<"u"&&gs(e,Element)}function QX(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function Mw(e){return!!(e&&e.then&&typeof e.then=="function")}function JX(e){return Pg(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e}function gs(e,t){try{return e instanceof t}catch{return!1}}function c1(e){try{for(var t=e,n=5,r=80,i=[],o=0,s=0,a=" > ",l=a.length,c=void 0;t&&o++<n&&(c=eq(t),!(c==="html"||o>1&&s+i.length*l+c.length>=r));)i.push(c),s+=c.length,t=t.parentNode;return i.reverse().join(a)}catch{return"<unknown>"}}function eq(e){var t=e,n=[],r,i,o,s,a;if(!t||!t.tagName)return"";if(n.push(t.tagName.toLowerCase()),t.id&&n.push("#"+t.id),r=t.className,r&&tc(r))for(i=r.split(/\s+/),a=0;a<i.length;a++)n.push("."+i[a]);var l=["type","name","title","alt"];for(a=0;a<l.length;a++)o=l[a],s=t.getAttribute(o),s&&n.push("["+o+'="'+s+'"]');return n.join("")}/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var Cy=function(e,t){return Cy=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i])},Cy(e,t)};function tq(e,t){Cy(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Bs=function(){return Bs=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Bs.apply(this,arguments)};function UM(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function nq(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o}var rq=Object.setPrototypeOf||({__proto__:[]}instanceof Array?iq:oq);function iq(e,t){return e.__proto__=t,e}function oq(e,t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n]);return e}var Kt=function(e){tq(t,e);function t(n){var r=this.constructor,i=e.call(this,n)||this;return i.message=n,i.name=r.prototype.constructor.name,rq(i,r.prototype),i}return t}(Error),sq=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/,Qc="Invalid Dsn",WM=function(){function e(t){typeof t=="string"?this._fromString(t):this._fromComponents(t),this._validate()}return e.prototype.toString=function(t){t===void 0&&(t=!1);var n=this,r=n.host,i=n.path,o=n.pass,s=n.port,a=n.projectId,l=n.protocol,c=n.publicKey;return l+"://"+c+(t&&o?":"+o:"")+("@"+r+(s?":"+s:"")+"/"+(i&&i+"/")+a)},e.prototype._fromString=function(t){var n=sq.exec(t);if(!n)throw new Kt(Qc);var r=nq(n.slice(1),6),i=r[0],o=r[1],s=r[2],a=s===void 0?"":s,l=r[3],c=r[4],u=c===void 0?"":c,d=r[5],h="",m=d,g=m.split("/");if(g.length>1&&(h=g.slice(0,-1).join("/"),m=g.pop()),m){var p=m.match(/^\d+/);p&&(m=p[0])}this._fromComponents({host:l,pass:a,path:h,projectId:m,port:u,protocol:i,publicKey:o})},e.prototype._fromComponents=function(t){"user"in t&&!("publicKey"in t)&&(t.publicKey=t.user),this.user=t.publicKey||"",this.protocol=t.protocol,this.publicKey=t.publicKey||"",this.pass=t.pass||"",this.host=t.host,this.port=t.port||"",this.path=t.path||"",this.projectId=t.projectId},e.prototype._validate=function(){var t=this;if(["protocol","publicKey","host","projectId"].forEach(function(n){if(!t[n])throw new Kt(Qc+": "+n+" missing")}),!this.projectId.match(/^\d+$/))throw new Kt(Qc+": Invalid projectId "+this.projectId);if(this.protocol!=="http"&&this.protocol!=="https")throw new Kt(Qc+": Invalid protocol "+this.protocol);if(this.port&&isNaN(parseInt(this.port,10)))throw new Kt(Qc+": Invalid port "+this.port)},e}();function Aw(){return Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]"}function aq(e,t){return e.require(t)}function Uu(e,t){return t===void 0&&(t=0),typeof e!="string"||t===0||e.length<=t?e:e.substr(0,t)+"..."}function u1(e,t){if(!Array.isArray(e))return"";for(var n=[],r=0;r<e.length;r++){var i=e[r];try{n.push(String(i))}catch{n.push("[value cannot be serialized]")}}return n.join(t)}function u0(e,t){return tc(e)?QX(t)?t.test(e):typeof t=="string"?e.indexOf(t)!==-1:!1:!1}var lq={};function Pt(){return Aw()?global:typeof window<"u"?window:typeof self<"u"?self:lq}function Nl(){var e=Pt(),t=e.crypto||e.msCrypto;if(t!==void 0&&t.getRandomValues){var n=new Uint16Array(8);t.getRandomValues(n),n[3]=n[3]&4095|16384,n[4]=n[4]&16383|32768;var r=function(i){for(var o=i.toString(16);o.length<4;)o="0"+o;return o};return r(n[0])+r(n[1])+r(n[2])+r(n[3])+r(n[4])+r(n[5])+r(n[6])+r(n[7])}return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(i){var o=Math.random()*16|0,s=i==="x"?o:o&3|8;return s.toString(16)})}function d0(e){if(!e)return{};var t=e.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!t)return{};var n=t[6]||"",r=t[8]||"";return{host:t[4],path:t[5],protocol:t[2],relative:t[5]+n+r}}function Os(e){if(e.message)return e.message;if(e.exception&&e.exception.values&&e.exception.values[0]){var t=e.exception.values[0];return t.type&&t.value?t.type+": "+t.value:t.type||t.value||e.event_id||"<unknown>"}return e.event_id||"<unknown>"}function Xf(e){var t=Pt(),n=["debug","info","warn","error","log","assert"];if(!("console"in t))return e();var r=t.console,i={};n.forEach(function(s){s in t.console&&r[s].__sentry_original__&&(i[s]=r[s],r[s]=r[s].__sentry_original__)});var o=e();return Object.keys(i).forEach(function(s){r[s]=i[s]}),o}function Ty(e,t,n){e.exception=e.exception||{},e.exception.values=e.exception.values||[],e.exception.values[0]=e.exception.values[0]||{},e.exception.values[0].value=e.exception.values[0].value||t||"",e.exception.values[0].type=e.exception.values[0].type||n||"Error"}function nc(e,t){t===void 0&&(t={});try{e.exception.values[0].mechanism=e.exception.values[0].mechanism||{},Object.keys(t).forEach(function(n){e.exception.values[0].mechanism[n]=t[n]})}catch{}}function cq(){try{return document.location.href}catch{return""}}var X4=60*1e3;function uq(e,t){if(!t)return X4;var n=parseInt(""+t,10);if(!isNaN(n))return n*1e3;var r=Date.parse(""+t);return isNaN(r)?X4:r-e}var aa=Pt(),h0="Sentry Logger ",dq=function(){function e(){this._enabled=!1}return e.prototype.disable=function(){this._enabled=!1},e.prototype.enable=function(){this._enabled=!0},e.prototype.log=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._enabled&&Xf(function(){aa.console.log(h0+"[Log]: "+t.join(" "))})},e.prototype.warn=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._enabled&&Xf(function(){aa.console.warn(h0+"[Warn]: "+t.join(" "))})},e.prototype.error=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._enabled&&Xf(function(){aa.console.error(h0+"[Error]: "+t.join(" "))})},e}();aa.__SENTRY__=aa.__SENTRY__||{};var Ve=aa.__SENTRY__.logger||(aa.__SENTRY__.logger=new dq),hq=function(){function e(){this._hasWeakSet=typeof WeakSet=="function",this._inner=this._hasWeakSet?new WeakSet:[]}return e.prototype.memoize=function(t){if(this._hasWeakSet)return this._inner.has(t)?!0:(this._inner.add(t),!1);for(var n=0;n<this._inner.length;n++){var r=this._inner[n];if(r===t)return!0}return this._inner.push(t),!1},e.prototype.unmemoize=function(t){if(this._hasWeakSet)this._inner.delete(t);else for(var n=0;n<this._inner.length;n++)if(this._inner[n]===t){this._inner.splice(n,1);break}},e}(),f0="<anonymous>";function bo(e){try{return!e||typeof e!="function"?f0:e.name||f0}catch{return f0}}function Zt(e,t,n){if(t in e){var r=e[t],i=n(r);if(typeof i=="function")try{i.prototype=i.prototype||{},Object.defineProperties(i,{__sentry_original__:{enumerable:!1,value:r}})}catch{}e[t]=i}}function fq(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")}function VM(e){if(zM(e)){var t=e,n={message:t.message,name:t.name,stack:t.stack};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}if(Tw(e)){var i=e,o={};o.type=i.type;try{o.target=Z4(i.target)?c1(i.target):Object.prototype.toString.call(i.target)}catch{o.target="<unknown>"}try{o.currentTarget=Z4(i.currentTarget)?c1(i.currentTarget):Object.prototype.toString.call(i.currentTarget)}catch{o.currentTarget="<unknown>"}typeof CustomEvent<"u"&&gs(e,CustomEvent)&&(o.detail=i.detail);for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(o[r]=i);return o}return e}function mq(e){return~-encodeURI(e).split(/%..|./).length}function gq(e){return mq(JSON.stringify(e))}function GM(e,t,n){t===void 0&&(t=3),n===void 0&&(n=100*1024);var r=gu(e,t);return gq(r)>n?GM(e,t-1,n):r}function pq(e){var t=Object.prototype.toString.call(e);if(typeof e=="string")return e;if(t==="[object Object]")return"[Object]";if(t==="[object Array]")return"[Array]";var n=jM(e);return Bd(n)?n:t}function jM(e,t){return t==="domain"&&e&&typeof e=="object"&&e._events?"[Domain]":t==="domainEmitter"?"[DomainEmitter]":typeof global<"u"&&e===global?"[Global]":typeof window<"u"&&e===window?"[Window]":typeof document<"u"&&e===document?"[Document]":JX(e)?"[SyntheticEvent]":typeof e=="number"&&e!==e?"[NaN]":e===void 0?"[undefined]":typeof e=="function"?"[Function: "+bo(e)+"]":typeof e=="symbol"?"["+String(e)+"]":typeof e=="bigint"?"[BigInt: "+String(e)+"]":e}function YM(e,t,n,r){if(n===void 0&&(n=1/0),r===void 0&&(r=new hq),n===0)return pq(t);if(t!=null&&typeof t.toJSON=="function")return t.toJSON();var i=jM(t,e);if(Bd(i))return i;var o=VM(t),s=Array.isArray(t)?[]:{};if(r.memoize(t))return"[Circular ~]";for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(s[a]=YM(a,o[a],n-1,r));return r.unmemoize(t),s}function gu(e,t){try{return JSON.parse(JSON.stringify(e,function(n,r){return YM(n,r,t)}))}catch{return"**non-serializable**"}}function yq(e,t){t===void 0&&(t=40);var n=Object.keys(VM(e));if(n.sort(),!n.length)return"[object has no keys]";if(n[0].length>=t)return Uu(n[0],t);for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(", ");if(!(i.length>t))return r===n.length?i:Uu(i,t)}return""}function d1(e){var t,n;if(Pg(e)){var r=e,i={};try{for(var o=UM(Object.keys(r)),s=o.next();!s.done;s=o.next()){var a=s.value;typeof r[a]<"u"&&(i[a]=d1(r[a]))}}catch(l){t={error:l}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return i}return Array.isArray(e)?e.map(d1):e}function Lw(){if(!("fetch"in Pt()))return!1;try{return new Headers,new Request(""),new Response,!0}catch{return!1}}function My(e){return e&&/^function fetch\(\)\s+\{\s+\[native code\]\s+\}$/.test(e.toString())}function vq(){if(!Lw())return!1;var e=Pt();if(My(e.fetch))return!0;var t=!1,n=e.document;if(n&&typeof n.createElement=="function")try{var r=n.createElement("iframe");r.hidden=!0,n.head.appendChild(r),r.contentWindow&&r.contentWindow.fetch&&(t=My(r.contentWindow.fetch)),n.head.removeChild(r)}catch(i){Ve.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",i)}return t}function Eq(){if(!Lw())return!1;try{return new Request("_",{referrerPolicy:"origin"}),!0}catch{return!1}}function wq(){var e=Pt(),t=e.chrome,n=t&&t.app&&t.app.runtime,r="history"in e&&!!e.history.pushState&&!!e.history.replaceState;return!n&&r}var ct=Pt(),Wu={},q4={};function bq(e){if(!q4[e])switch(q4[e]=!0,e){case"console":_q();break;case"dom":Lq();break;case"xhr":Iq();break;case"fetch":xq();break;case"history":Cq();break;case"error":Pq();break;case"unhandledrejection":Rq();break;default:Ve.warn("unknown instrumentation type:",e)}}function Ao(e){!e||typeof e.type!="string"||typeof e.callback!="function"||(Wu[e.type]=Wu[e.type]||[],Wu[e.type].push(e.callback),bq(e.type))}function Kr(e,t){var n,r;if(!(!e||!Wu[e]))try{for(var i=UM(Wu[e]||[]),o=i.next();!o.done;o=i.next()){var s=o.value;try{s(t)}catch(a){Ve.error(`Error while triggering instrumentation handler.
Type: `+e+`
Name: `+bo(s)+`
Error: `+a)}}}catch(a){n={error:a}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}function _q(){"console"in ct&&["debug","info","warn","error","log","assert"].forEach(function(e){e in ct.console&&Zt(ct.console,e,function(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];Kr("console",{args:n,level:e}),t&&Function.prototype.apply.call(t,ct.console,n)}})})}function xq(){vq()&&Zt(ct,"fetch",function(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r={args:t,fetchData:{method:Sq(t),url:kq(t)},startTimestamp:Date.now()};return Kr("fetch",Bs({},r)),e.apply(ct,t).then(function(i){return Kr("fetch",Bs(Bs({},r),{endTimestamp:Date.now(),response:i})),i},function(i){throw Kr("fetch",Bs(Bs({},r),{endTimestamp:Date.now(),error:i})),i})}})}function Sq(e){return e===void 0&&(e=[]),"Request"in ct&&gs(e[0],Request)&&e[0].method?String(e[0].method).toUpperCase():e[1]&&e[1].method?String(e[1].method).toUpperCase():"GET"}function kq(e){return e===void 0&&(e=[]),typeof e[0]=="string"?e[0]:"Request"in ct&&gs(e[0],Request)?e[0].url:String(e[0])}function Iq(){if("XMLHttpRequest"in ct){var e=[],t=[],n=XMLHttpRequest.prototype;Zt(n,"open",function(r){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var s=this,a=i[1];s.__sentry_xhr__={method:tc(i[0])?i[0].toUpperCase():i[0],url:i[1]},tc(a)&&s.__sentry_xhr__.method==="POST"&&a.match(/sentry_key/)&&(s.__sentry_own_request__=!0);var l=function(){if(s.readyState===4){try{s.__sentry_xhr__&&(s.__sentry_xhr__.status_code=s.status)}catch{}try{var c=e.indexOf(s);if(c!==-1){e.splice(c);var u=t.splice(c)[0];s.__sentry_xhr__&&u[0]!==void 0&&(s.__sentry_xhr__.body=u[0])}}catch{}Kr("xhr",{args:i,endTimestamp:Date.now(),startTimestamp:Date.now(),xhr:s})}};return"onreadystatechange"in s&&typeof s.onreadystatechange=="function"?Zt(s,"onreadystatechange",function(c){return function(){for(var u=[],d=0;d<arguments.length;d++)u[d]=arguments[d];return l(),c.apply(s,u)}}):s.addEventListener("readystatechange",l),r.apply(s,i)}}),Zt(n,"send",function(r){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];return e.push(this),t.push(i),Kr("xhr",{args:i,startTimestamp:Date.now(),xhr:this}),r.apply(this,i)}})}}var af;function Cq(){if(!wq())return;var e=ct.onpopstate;ct.onpopstate=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=ct.location.href,o=af;if(af=i,Kr("history",{from:o,to:i}),e)return e.apply(this,n)};function t(n){return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=r.length>2?r[2]:void 0;if(o){var s=af,a=String(o);af=a,Kr("history",{from:s,to:a})}return n.apply(this,r)}}Zt(ct.history,"pushState",t),Zt(ct.history,"replaceState",t)}var Tq=1e3,lf,cf;function Mq(e,t){if(!e||e.type!==t.type)return!0;try{if(e.target!==t.target)return!0}catch{}return!1}function Aq(e){if(e.type!=="keypress")return!1;try{var t=e.target;if(!t||!t.tagName)return!0;if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable)return!1}catch{}return!0}function Q4(e,t){return t===void 0&&(t=!1),function(n){if(!(!n||cf===n)&&!Aq(n)){var r=n.type==="keypress"?"input":n.type;lf===void 0?(e({event:n,name:r,global:t}),cf=n):Mq(cf,n)&&(e({event:n,name:r,global:t}),cf=n),clearTimeout(lf),lf=ct.setTimeout(function(){lf=void 0},Tq)}}}function Lq(){if("document"in ct){var e=Kr.bind(null,"dom"),t=Q4(e,!0);ct.document.addEventListener("click",t,!1),ct.document.addEventListener("keypress",t,!1),["EventTarget","Node"].forEach(function(n){var r=ct[n]&&ct[n].prototype;!r||!r.hasOwnProperty||!r.hasOwnProperty("addEventListener")||(Zt(r,"addEventListener",function(i){return function(o,s,a){if(o==="click"||o=="keypress")try{var l=this,c=l.__sentry_instrumentation_handlers__=l.__sentry_instrumentation_handlers__||{},u=c[o]=c[o]||{refCount:0};if(!u.handler){var d=Q4(e);u.handler=d,i.call(this,o,d,a)}u.refCount+=1}catch{}return i.call(this,o,s,a)}}),Zt(r,"removeEventListener",function(i){return function(o,s,a){if(o==="click"||o=="keypress")try{var l=this,c=l.__sentry_instrumentation_handlers__||{},u=c[o];u&&(u.refCount-=1,u.refCount<=0&&(i.call(this,o,u.handler,a),u.handler=void 0,delete c[o]),Object.keys(c).length===0&&delete l.__sentry_instrumentation_handlers__)}catch{}return i.call(this,o,s,a)}}))})}}var m0=null;function Pq(){m0=ct.onerror,ct.onerror=function(e,t,n,r,i){return Kr("error",{column:r,error:i,line:n,msg:e,url:t}),m0?m0.apply(this,arguments):!1}}var g0=null;function Rq(){g0=ct.onunhandledrejection,ct.onunhandledrejection=function(e){return Kr("unhandledrejection",e),g0?g0.apply(this,arguments):!0}}var Fi;(function(e){e.PENDING="PENDING",e.RESOLVED="RESOLVED",e.REJECTED="REJECTED"})(Fi||(Fi={}));var Nn=function(){function e(t){var n=this;this._state=Fi.PENDING,this._handlers=[],this._resolve=function(r){n._setResult(Fi.RESOLVED,r)},this._reject=function(r){n._setResult(Fi.REJECTED,r)},this._setResult=function(r,i){if(n._state===Fi.PENDING){if(Mw(i)){i.then(n._resolve,n._reject);return}n._state=r,n._value=i,n._executeHandlers()}},this._attachHandler=function(r){n._handlers=n._handlers.concat(r),n._executeHandlers()},this._executeHandlers=function(){if(n._state!==Fi.PENDING){var r=n._handlers.slice();n._handlers=[],r.forEach(function(i){i.done||(n._state===Fi.RESOLVED&&i.onfulfilled&&i.onfulfilled(n._value),n._state===Fi.REJECTED&&i.onrejected&&i.onrejected(n._value),i.done=!0)})}};try{t(this._resolve,this._reject)}catch(r){this._reject(r)}}return e.resolve=function(t){return new e(function(n){n(t)})},e.reject=function(t){return new e(function(n,r){r(t)})},e.all=function(t){return new e(function(n,r){if(!Array.isArray(t)){r(new TypeError("Promise.all requires an array as input."));return}if(t.length===0){n([]);return}var i=t.length,o=[];t.forEach(function(s,a){e.resolve(s).then(function(l){o[a]=l,i-=1,i===0&&n(o)}).then(null,r)})})},e.prototype.then=function(t,n){var r=this;return new e(function(i,o){r._attachHandler({done:!1,onfulfilled:function(s){if(!t){i(s);return}try{i(t(s));return}catch(a){o(a);return}},onrejected:function(s){if(!n){o(s);return}try{i(n(s));return}catch(a){o(a);return}}})})},e.prototype.catch=function(t){return this.then(function(n){return n},t)},e.prototype.finally=function(t){var n=this;return new e(function(r,i){var o,s;return n.then(function(a){s=!1,o=a,t&&t()},function(a){s=!0,o=a,t&&t()}).then(function(){if(s){i(o);return}r(o)})})},e.prototype.toString=function(){return"[object SyncPromise]"},e}(),Dq=function(){function e(t){this._limit=t,this._buffer=[]}return e.prototype.isReady=function(){return this._limit===void 0||this.length()<this._limit},e.prototype.add=function(t){var n=this;return this.isReady()?(this._buffer.indexOf(t)===-1&&this._buffer.push(t),t.then(function(){return n.remove(t)}).then(null,function(){return n.remove(t).then(null,function(){})}),t):Nn.reject(new Kt("Not adding Promise due to buffer limit reached."))},e.prototype.remove=function(t){var n=this._buffer.splice(this._buffer.indexOf(t),1)[0];return n},e.prototype.length=function(){return this._buffer.length},e.prototype.drain=function(t){var n=this;return new Nn(function(r){var i=setTimeout(function(){t&&t>0&&r(!1)},t);Nn.all(n._buffer).then(function(){clearTimeout(i),r(!0)}).then(null,function(){r(!0)})})},e}(),Ay={nowSeconds:function(){return Date.now()/1e3}};function Oq(){var e=Pt().performance;if(!(!e||!e.now)){var t=Date.now()-e.now();return{now:function(){return e.now()},timeOrigin:t}}}function Nq(){try{var e=aq(module,"perf_hooks");return e.performance}catch{return}}var p0=Aw()?Nq():Oq(),J4=p0===void 0?Ay:{nowSeconds:function(){return(p0.timeOrigin+p0.now())/1e3}},Pw=Ay.nowSeconds.bind(Ay);J4.nowSeconds.bind(J4);(function(){var e=Pt().performance;if(e){var t=3600*1e3,n=e.timeOrigin&&Math.abs(e.timeOrigin+e.now()-Date.now())<t;if(n)return e.timeOrigin;var r=e.timing&&e.timing.navigationStart,i=typeof r=="number",o=i&&Math.abs(r+e.now()-Date.now())<t;return o?r:Date.now()}})();var h1=function(){function e(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._user={},this._tags={},this._extra={},this._contexts={}}return e.clone=function(t){var n=new e;return t&&(n._breadcrumbs=Ds(t._breadcrumbs),n._tags=me({},t._tags),n._extra=me({},t._extra),n._contexts=me({},t._contexts),n._user=t._user,n._level=t._level,n._span=t._span,n._session=t._session,n._transactionName=t._transactionName,n._fingerprint=t._fingerprint,n._eventProcessors=Ds(t._eventProcessors)),n},e.prototype.addScopeListener=function(t){this._scopeListeners.push(t)},e.prototype.addEventProcessor=function(t){return this._eventProcessors.push(t),this},e.prototype.setUser=function(t){return this._user=t||{},this._session&&this._session.update({user:t}),this._notifyScopeListeners(),this},e.prototype.getUser=function(){return this._user},e.prototype.setTags=function(t){return this._tags=me(me({},this._tags),t),this._notifyScopeListeners(),this},e.prototype.setTag=function(t,n){var r;return this._tags=me(me({},this._tags),(r={},r[t]=n,r)),this._notifyScopeListeners(),this},e.prototype.setExtras=function(t){return this._extra=me(me({},this._extra),t),this._notifyScopeListeners(),this},e.prototype.setExtra=function(t,n){var r;return this._extra=me(me({},this._extra),(r={},r[t]=n,r)),this._notifyScopeListeners(),this},e.prototype.setFingerprint=function(t){return this._fingerprint=t,this._notifyScopeListeners(),this},e.prototype.setLevel=function(t){return this._level=t,this._notifyScopeListeners(),this},e.prototype.setTransactionName=function(t){return this._transactionName=t,this._notifyScopeListeners(),this},e.prototype.setTransaction=function(t){return this.setTransactionName(t)},e.prototype.setContext=function(t,n){var r;return n===null?delete this._contexts[t]:this._contexts=me(me({},this._contexts),(r={},r[t]=n,r)),this._notifyScopeListeners(),this},e.prototype.setSpan=function(t){return this._span=t,this._notifyScopeListeners(),this},e.prototype.getSpan=function(){return this._span},e.prototype.getTransaction=function(){var t,n,r,i,o=this.getSpan();if(!((t=o)===null||t===void 0)&&t.transaction)return(n=o)===null||n===void 0?void 0:n.transaction;if(!((i=(r=o)===null||r===void 0?void 0:r.spanRecorder)===null||i===void 0)&&i.spans[0])return o.spanRecorder.spans[0]},e.prototype.setSession=function(t){return t?this._session=t:delete this._session,this._notifyScopeListeners(),this},e.prototype.getSession=function(){return this._session},e.prototype.update=function(t){if(!t)return this;if(typeof t=="function"){var n=t(this);return n instanceof e?n:this}return t instanceof e?(this._tags=me(me({},this._tags),t._tags),this._extra=me(me({},this._extra),t._extra),this._contexts=me(me({},this._contexts),t._contexts),t._user&&Object.keys(t._user).length&&(this._user=t._user),t._level&&(this._level=t._level),t._fingerprint&&(this._fingerprint=t._fingerprint)):Pg(t)&&(t=t,this._tags=me(me({},this._tags),t.tags),this._extra=me(me({},this._extra),t.extra),this._contexts=me(me({},this._contexts),t.contexts),t.user&&(this._user=t.user),t.level&&(this._level=t.level),t.fingerprint&&(this._fingerprint=t.fingerprint)),this},e.prototype.clear=function(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this},e.prototype.addBreadcrumb=function(t,n){var r=me({timestamp:Pw()},t);return this._breadcrumbs=n!==void 0&&n>=0?Ds(this._breadcrumbs,[r]).slice(-n):Ds(this._breadcrumbs,[r]),this._notifyScopeListeners(),this},e.prototype.clearBreadcrumbs=function(){return this._breadcrumbs=[],this._notifyScopeListeners(),this},e.prototype.applyToEvent=function(t,n){var r;if(this._extra&&Object.keys(this._extra).length&&(t.extra=me(me({},this._extra),t.extra)),this._tags&&Object.keys(this._tags).length&&(t.tags=me(me({},this._tags),t.tags)),this._user&&Object.keys(this._user).length&&(t.user=me(me({},this._user),t.user)),this._contexts&&Object.keys(this._contexts).length&&(t.contexts=me(me({},this._contexts),t.contexts)),this._level&&(t.level=this._level),this._transactionName&&(t.transaction=this._transactionName),this._span){t.contexts=me({trace:this._span.getTraceContext()},t.contexts);var i=(r=this._span.transaction)===null||r===void 0?void 0:r.name;i&&(t.tags=me({transaction:i},t.tags))}return this._applyFingerprint(t),t.breadcrumbs=Ds(t.breadcrumbs||[],this._breadcrumbs),t.breadcrumbs=t.breadcrumbs.length>0?t.breadcrumbs:void 0,this._notifyEventProcessors(Ds(KM(),this._eventProcessors),t,n)},e.prototype._notifyEventProcessors=function(t,n,r,i){var o=this;return i===void 0&&(i=0),new Nn(function(s,a){var l=t[i];if(n===null||typeof l!="function")s(n);else{var c=l(me({},n),r);Mw(c)?c.then(function(u){return o._notifyEventProcessors(t,u,r,i+1).then(s)}).then(null,a):o._notifyEventProcessors(t,c,r,i+1).then(s).then(null,a)}})},e.prototype._notifyScopeListeners=function(){var t=this;this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(function(n){n(t)}),this._notifyingListeners=!1)},e.prototype._applyFingerprint=function(t){t.fingerprint=t.fingerprint?Array.isArray(t.fingerprint)?t.fingerprint:[t.fingerprint]:[],this._fingerprint&&(t.fingerprint=t.fingerprint.concat(this._fingerprint)),t.fingerprint&&!t.fingerprint.length&&delete t.fingerprint},e}();function KM(){var e=Pt();return e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.globalEventProcessors=e.__SENTRY__.globalEventProcessors||[],e.__SENTRY__.globalEventProcessors}function Rg(e){KM().push(e)}var Fq=function(){function e(t){this.errors=0,this.sid=Nl(),this.timestamp=Date.now(),this.started=Date.now(),this.duration=0,this.status=ns.Ok,this.init=!0,t&&this.update(t)}return e.prototype.update=function(t){t===void 0&&(t={}),t.user&&(t.user.ip_address&&(this.ipAddress=t.user.ip_address),t.did||(this.did=t.user.id||t.user.email||t.user.username)),this.timestamp=t.timestamp||Date.now(),t.sid&&(this.sid=t.sid.length===32?t.sid:Nl()),t.init!==void 0&&(this.init=t.init),t.did&&(this.did=""+t.did),typeof t.started=="number"&&(this.started=t.started),typeof t.duration=="number"?this.duration=t.duration:this.duration=this.timestamp-this.started,t.release&&(this.release=t.release),t.environment&&(this.environment=t.environment),t.ipAddress&&(this.ipAddress=t.ipAddress),t.userAgent&&(this.userAgent=t.userAgent),typeof t.errors=="number"&&(this.errors=t.errors),t.status&&(this.status=t.status)},e.prototype.close=function(t){t?this.update({status:t}):this.status===ns.Ok?this.update({status:ns.Exited}):this.update()},e.prototype.toJSON=function(){return d1({sid:""+this.sid,init:this.init,started:new Date(this.started).toISOString(),timestamp:new Date(this.timestamp).toISOString(),status:this.status,errors:this.errors,did:typeof this.did=="number"||typeof this.did=="string"?""+this.did:void 0,duration:this.duration,attrs:d1({release:this.release,environment:this.environment,ip_address:this.ipAddress,user_agent:this.userAgent})})},e}(),Rw=3,$q=100,Bq=100,Dw=function(){function e(t,n,r){n===void 0&&(n=new h1),r===void 0&&(r=Rw),this._version=r,this._stack=[{}],this.getStackTop().scope=n,this.bindClient(t)}return e.prototype.isOlderThan=function(t){return this._version<t},e.prototype.bindClient=function(t){var n=this.getStackTop();n.client=t,t&&t.setupIntegrations&&t.setupIntegrations()},e.prototype.pushScope=function(){var t=h1.clone(this.getScope());return this.getStack().push({client:this.getClient(),scope:t}),t},e.prototype.popScope=function(){return this.getStack().length<=1?!1:!!this.getStack().pop()},e.prototype.withScope=function(t){var n=this.pushScope();try{t(n)}finally{this.popScope()}},e.prototype.getClient=function(){return this.getStackTop().client},e.prototype.getScope=function(){return this.getStackTop().scope},e.prototype.getStack=function(){return this._stack},e.prototype.getStackTop=function(){return this._stack[this._stack.length-1]},e.prototype.captureException=function(t,n){var r=this._lastEventId=Nl(),i=n;if(!n){var o=void 0;try{throw new Error("Sentry syntheticException")}catch(s){o=s}i={originalException:t,syntheticException:o}}return this._invokeClient("captureException",t,me(me({},i),{event_id:r})),r},e.prototype.captureMessage=function(t,n,r){var i=this._lastEventId=Nl(),o=r;if(!r){var s=void 0;try{throw new Error(t)}catch(a){s=a}o={originalException:t,syntheticException:s}}return this._invokeClient("captureMessage",t,n,me(me({},o),{event_id:i})),i},e.prototype.captureEvent=function(t,n){var r=this._lastEventId=Nl();return this._invokeClient("captureEvent",t,me(me({},n),{event_id:r})),r},e.prototype.lastEventId=function(){return this._lastEventId},e.prototype.addBreadcrumb=function(t,n){var r=this.getStackTop(),i=r.scope,o=r.client;if(!(!i||!o)){var s=o.getOptions&&o.getOptions()||{},a=s.beforeBreadcrumb,l=a===void 0?null:a,c=s.maxBreadcrumbs,u=c===void 0?$q:c;if(!(u<=0)){var d=Pw(),h=me({timestamp:d},t),m=l?Xf(function(){return l(h,n)}):h;m!==null&&i.addBreadcrumb(m,Math.min(u,Bq))}}},e.prototype.setUser=function(t){var n=this.getScope();n&&n.setUser(t)},e.prototype.setTags=function(t){var n=this.getScope();n&&n.setTags(t)},e.prototype.setExtras=function(t){var n=this.getScope();n&&n.setExtras(t)},e.prototype.setTag=function(t,n){var r=this.getScope();r&&r.setTag(t,n)},e.prototype.setExtra=function(t,n){var r=this.getScope();r&&r.setExtra(t,n)},e.prototype.setContext=function(t,n){var r=this.getScope();r&&r.setContext(t,n)},e.prototype.configureScope=function(t){var n=this.getStackTop(),r=n.scope,i=n.client;r&&i&&t(r)},e.prototype.run=function(t){var n=e5(this);try{t(this)}finally{e5(n)}},e.prototype.getIntegration=function(t){var n=this.getClient();if(!n)return null;try{return n.getIntegration(t)}catch{return Ve.warn("Cannot retrieve integration "+t.id+" from the current Hub"),null}},e.prototype.startSpan=function(t){return this._callExtensionMethod("startSpan",t)},e.prototype.startTransaction=function(t,n){return this._callExtensionMethod("startTransaction",t,n)},e.prototype.traceHeaders=function(){return this._callExtensionMethod("traceHeaders")},e.prototype.captureSession=function(t){if(t===void 0&&(t=!1),t)return this.endSession();this._sendSessionUpdate()},e.prototype.endSession=function(){var t,n,r,i,o;(r=(n=(t=this.getStackTop())===null||t===void 0?void 0:t.scope)===null||n===void 0?void 0:n.getSession())===null||r===void 0||r.close(),this._sendSessionUpdate(),(o=(i=this.getStackTop())===null||i===void 0?void 0:i.scope)===null||o===void 0||o.setSession()},e.prototype.startSession=function(t){var n=this.getStackTop(),r=n.scope,i=n.client,o=i&&i.getOptions()||{},s=o.release,a=o.environment,l=new Fq(me(me({release:s,environment:a},r&&{user:r.getUser()}),t));if(r){var c=r.getSession&&r.getSession();c&&c.status===ns.Ok&&c.update({status:ns.Exited}),this.endSession(),r.setSession(l)}return l},e.prototype._sendSessionUpdate=function(){var t=this.getStackTop(),n=t.scope,r=t.client;if(n){var i=n.getSession&&n.getSession();i&&r&&r.captureSession&&r.captureSession(i)}},e.prototype._invokeClient=function(t){for(var n,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=this.getStackTop(),s=o.scope,a=o.client;a&&a[t]&&(n=a)[t].apply(n,Ds(r,[s]))},e.prototype._callExtensionMethod=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=Dg(),o=i.__SENTRY__;if(o&&o.extensions&&typeof o.extensions[t]=="function")return o.extensions[t].apply(this,n);Ve.warn("Extension method "+t+" couldn't be found, doing nothing.")},e}();function Dg(){var e=Pt();return e.__SENTRY__=e.__SENTRY__||{extensions:{},hub:void 0},e}function e5(e){var t=Dg(),n=Lo(t);return Ow(t,e),n}function ln(){var e=Dg();return(!ZM(e)||Lo(e).isOlderThan(Rw))&&Ow(e,new Dw),Aw()?zq(e):Lo(e)}function zq(e){var t,n,r;try{var i=(r=(n=(t=Dg().__SENTRY__)===null||t===void 0?void 0:t.extensions)===null||n===void 0?void 0:n.domain)===null||r===void 0?void 0:r.active;if(!i)return Lo(e);if(!ZM(i)||Lo(i).isOlderThan(Rw)){var o=Lo(e).getStackTop();Ow(i,new Dw(o.client,h1.clone(o.scope)))}return Lo(i)}catch{return Lo(e)}}function ZM(e){return!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)}function Lo(e){return e&&e.__SENTRY__&&e.__SENTRY__.hub||(e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.hub=new Dw),e.__SENTRY__.hub}function Ow(e,t){return e?(e.__SENTRY__=e.__SENTRY__||{},e.__SENTRY__.hub=t,!0):!1}function XM(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=ln();if(r&&r[e])return r[e].apply(r,ZX(t));throw new Error("No hub defined or "+e+" was not found on the hub, please open a bug report.")}function qM(e,t){var n;try{throw new Error("Sentry syntheticException")}catch(r){n=r}return XM("captureException",e,{captureContext:t,originalException:e,syntheticException:n})}function QM(e){XM("withScope",e)}var t5="7",JM=function(){function e(t,n){n===void 0&&(n={}),this.dsn=t,this._dsnObject=new WM(t),this.metadata=n}return e.prototype.getDsn=function(){return this._dsnObject},e.prototype.getBaseApiEndpoint=function(){var t=this._dsnObject,n=t.protocol?t.protocol+":":"",r=t.port?":"+t.port:"";return n+"//"+t.host+r+(t.path?"/"+t.path:"")+"/api/"},e.prototype.getStoreEndpoint=function(){return this._getIngestEndpoint("store")},e.prototype.getStoreEndpointWithUrlEncodedAuth=function(){return this.getStoreEndpoint()+"?"+this._encodedAuth()},e.prototype.getEnvelopeEndpointWithUrlEncodedAuth=function(){return this._getEnvelopeEndpoint()+"?"+this._encodedAuth()},e.prototype.getStoreEndpointPath=function(){var t=this._dsnObject;return(t.path?"/"+t.path:"")+"/api/"+t.projectId+"/store/"},e.prototype.getRequestHeaders=function(t,n){var r=this._dsnObject,i=["Sentry sentry_version="+t5];return i.push("sentry_client="+t+"/"+n),i.push("sentry_key="+r.publicKey),r.pass&&i.push("sentry_secret="+r.pass),{"Content-Type":"application/json","X-Sentry-Auth":i.join(", ")}},e.prototype.getReportDialogEndpoint=function(t){t===void 0&&(t={});var n=this._dsnObject,r=this.getBaseApiEndpoint()+"embed/error-page/",i=[];i.push("dsn="+n.toString());for(var o in t)if(o!=="dsn")if(o==="user"){if(!t.user)continue;t.user.name&&i.push("name="+encodeURIComponent(t.user.name)),t.user.email&&i.push("email="+encodeURIComponent(t.user.email))}else i.push(encodeURIComponent(o)+"="+encodeURIComponent(t[o]));return i.length?r+"?"+i.join("&"):r},e.prototype._getEnvelopeEndpoint=function(){return this._getIngestEndpoint("envelope")},e.prototype._getIngestEndpoint=function(t){var n=this.getBaseApiEndpoint(),r=this._dsnObject;return""+n+r.projectId+"/"+t+"/"},e.prototype._encodedAuth=function(){var t=this._dsnObject,n={sentry_key:t.publicKey,sentry_version:t5};return fq(n)},e}();/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var vn=function(){return vn=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},vn.apply(this,arguments)};function Hq(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 i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Uq(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Wq(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o}function rs(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Wq(arguments[t]));return e}var n5=[];function Vq(e){var t=e.defaultIntegrations&&rs(e.defaultIntegrations)||[],n=e.integrations,r=[];if(Array.isArray(n)){var i=n.map(function(l){return l.name}),o=[];t.forEach(function(l){i.indexOf(l.name)===-1&&o.indexOf(l.name)===-1&&(r.push(l),o.push(l.name))}),n.forEach(function(l){o.indexOf(l.name)===-1&&(r.push(l),o.push(l.name))})}else typeof n=="function"?(r=n(t),r=Array.isArray(r)?r:[r]):r=rs(t);var s=r.map(function(l){return l.name}),a="Debug";return s.indexOf(a)!==-1&&r.push.apply(r,rs(r.splice(s.indexOf(a),1))),r}function Gq(e){n5.indexOf(e.name)===-1&&(e.setupOnce(Rg,ln),n5.push(e.name),Ve.log("Integration installed: "+e.name))}function jq(e){var t={};return Vq(e).forEach(function(n){t[n.name]=n,Gq(n)}),t}var Yq=function(){function e(t,n){this._integrations={},this._processing=0,this._backend=new t(n),this._options=n,n.dsn&&(this._dsn=new WM(n.dsn))}return e.prototype.captureException=function(t,n,r){var i=this,o=n&&n.event_id;return this._process(this._getBackend().eventFromException(t,n).then(function(s){return i._captureEvent(s,n,r)}).then(function(s){o=s})),o},e.prototype.captureMessage=function(t,n,r,i){var o=this,s=r&&r.event_id,a=Bd(t)?this._getBackend().eventFromMessage(String(t),n,r):this._getBackend().eventFromException(t,r);return this._process(a.then(function(l){return o._captureEvent(l,r,i)}).then(function(l){s=l})),s},e.prototype.captureEvent=function(t,n,r){var i=n&&n.event_id;return this._process(this._captureEvent(t,n,r).then(function(o){i=o})),i},e.prototype.captureSession=function(t){t.release?(this._sendSession(t),t.update({init:!1})):Ve.warn("Discarded session because of missing release")},e.prototype.getDsn=function(){return this._dsn},e.prototype.getOptions=function(){return this._options},e.prototype.flush=function(t){var n=this;return this._isClientProcessing(t).then(function(r){return n._getBackend().getTransport().close(t).then(function(i){return r&&i})})},e.prototype.close=function(t){var n=this;return this.flush(t).then(function(r){return n.getOptions().enabled=!1,r})},e.prototype.setupIntegrations=function(){this._isEnabled()&&(this._integrations=jq(this._options))},e.prototype.getIntegration=function(t){try{return this._integrations[t.id]||null}catch{return Ve.warn("Cannot retrieve integration "+t.id+" from the current Client"),null}},e.prototype._updateSessionFromEvent=function(t,n){var r,i,o=!1,s=!1,a,l=n.exception&&n.exception.values;if(l){s=!0;try{for(var c=Uq(l),u=c.next();!u.done;u=c.next()){var d=u.value,h=d.mechanism;if(h&&h.handled===!1){o=!0;break}}}catch(v){r={error:v}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}var m=n.user;if(!t.userAgent){var g=n.request?n.request.headers:{};for(var p in g)if(p.toLowerCase()==="user-agent"){a=g[p];break}}t.update(vn(vn({},o&&{status:ns.Crashed}),{user:m,userAgent:a,errors:t.errors+Number(s||o)})),this.captureSession(t)},e.prototype._sendSession=function(t){this._getBackend().sendSession(t)},e.prototype._isClientProcessing=function(t){var n=this;return new Nn(function(r){var i=0,o=1,s=setInterval(function(){n._processing==0?(clearInterval(s),r(!0)):(i+=o,t&&i>=t&&(clearInterval(s),r(!1)))},o)})},e.prototype._getBackend=function(){return this._backend},e.prototype._isEnabled=function(){return this.getOptions().enabled!==!1&&this._dsn!==void 0},e.prototype._prepareEvent=function(t,n,r){var i=this,o=this.getOptions().normalizeDepth,s=o===void 0?3:o,a=vn(vn({},t),{event_id:t.event_id||(r&&r.event_id?r.event_id:Nl()),timestamp:t.timestamp||Pw()});this._applyClientOptions(a),this._applyIntegrationsMetadata(a);var l=n;r&&r.captureContext&&(l=h1.clone(l).update(r.captureContext));var c=Nn.resolve(a);return l&&(c=l.applyToEvent(a,r)),c.then(function(u){return typeof s=="number"&&s>0?i._normalizeEvent(u,s):u})},e.prototype._normalizeEvent=function(t,n){if(!t)return null;var r=vn(vn(vn(vn(vn({},t),t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(function(i){return vn(vn({},i),i.data&&{data:gu(i.data,n)})})}),t.user&&{user:gu(t.user,n)}),t.contexts&&{contexts:gu(t.contexts,n)}),t.extra&&{extra:gu(t.extra,n)});return t.contexts&&t.contexts.trace&&(r.contexts.trace=t.contexts.trace),r},e.prototype._applyClientOptions=function(t){var n=this.getOptions(),r=n.environment,i=n.release,o=n.dist,s=n.maxValueLength,a=s===void 0?250:s;"environment"in t||(t.environment="environment"in n?r:"production"),t.release===void 0&&i!==void 0&&(t.release=i),t.dist===void 0&&o!==void 0&&(t.dist=o),t.message&&(t.message=Uu(t.message,a));var l=t.exception&&t.exception.values&&t.exception.values[0];l&&l.value&&(l.value=Uu(l.value,a));var c=t.request;c&&c.url&&(c.url=Uu(c.url,a))},e.prototype._applyIntegrationsMetadata=function(t){var n=t.sdk,r=Object.keys(this._integrations);n&&r.length>0&&(n.integrations=r)},e.prototype._sendEvent=function(t){this._getBackend().sendEvent(t)},e.prototype._captureEvent=function(t,n,r){return this._processEvent(t,n,r).then(function(i){return i.event_id},function(i){Ve.error(i)})},e.prototype._processEvent=function(t,n,r){var i=this,o=this.getOptions(),s=o.beforeSend,a=o.sampleRate;if(!this._isEnabled())return Nn.reject(new Kt("SDK not enabled, will not send event."));var l=t.type==="transaction";return!l&&typeof a=="number"&&Math.random()>a?Nn.reject(new Kt("Discarding event because it's not included in the random sample (sampling rate = "+a+")")):this._prepareEvent(t,r,n).then(function(c){if(c===null)throw new Kt("An event processor returned null, will not send event.");var u=n&&n.data&&n.data.__sentry__===!0;if(u||l||!s)return c;var d=s(c,n);if(typeof d>"u")throw new Kt("`beforeSend` method has to return `null` or a valid event.");return Mw(d)?d.then(function(h){return h},function(h){throw new Kt("beforeSend rejected with "+h)}):d}).then(function(c){if(c===null)throw new Kt("`beforeSend` returned `null`, will not send event.");var u=r&&r.getSession&&r.getSession();return!l&&u&&i._updateSessionFromEvent(u,c),i._sendEvent(c),c}).then(null,function(c){throw c instanceof Kt?c:(i.captureException(c,{data:{__sentry__:!0},originalException:c}),new Kt(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.
Reason: `+c))})},e.prototype._process=function(t){var n=this;this._processing+=1,t.then(function(r){return n._processing-=1,r},function(r){return n._processing-=1,r})},e}(),Kq=function(){function e(){}return e.prototype.sendEvent=function(t){return Nn.resolve({reason:"NoopTransport: Event has been skipped because no Dsn is configured.",status:Aa.Skipped})},e.prototype.close=function(t){return Nn.resolve(!0)},e}(),Zq=function(){function e(t){this._options=t,this._options.dsn||Ve.warn("No DSN provided, backend will not do anything."),this._transport=this._setupTransport()}return e.prototype.eventFromException=function(t,n){throw new Kt("Backend has to implement `eventFromException` method")},e.prototype.eventFromMessage=function(t,n,r){throw new Kt("Backend has to implement `eventFromMessage` method")},e.prototype.sendEvent=function(t){this._transport.sendEvent(t).then(null,function(n){Ve.error("Error while sending event: "+n)})},e.prototype.sendSession=function(t){if(!this._transport.sendSession){Ve.warn("Dropping session because custom transport doesn't implement sendSession");return}this._transport.sendSession(t).then(null,function(n){Ve.error("Error while sending session: "+n)})},e.prototype.getTransport=function(){return this._transport},e.prototype._setupTransport=function(){return new Kq},e}();function eA(e){if(!(!e.metadata||!e.metadata.sdk)){var t=e.metadata.sdk,n=t.name,r=t.version;return{name:n,version:r}}}function Xq(e,t){return t&&(e.sdk=e.sdk||{name:t.name,version:t.version},e.sdk.name=e.sdk.name||t.name,e.sdk.version=e.sdk.version||t.version,e.sdk.integrations=rs(e.sdk.integrations||[],t.integrations||[]),e.sdk.packages=rs(e.sdk.packages||[],t.packages||[])),e}function tA(e,t){var n=eA(t),r=JSON.stringify(vn({sent_at:new Date().toISOString()},n&&{sdk:n})),i=JSON.stringify({type:"session"});return{body:r+`
`+i+`
`+JSON.stringify(e),type:"session",url:t.getEnvelopeEndpointWithUrlEncodedAuth()}}function nA(e,t){var n=eA(t),r=e.type||"event",i=r==="transaction",o=e.debug_meta||{},s=o.transactionSampling,a=Hq(o,["transactionSampling"]),l=s||{},c=l.method,u=l.rate;Object.keys(a).length===0?delete e.debug_meta:e.debug_meta=a;var d={body:JSON.stringify(n?Xq(e,t.metadata.sdk):e),type:r,url:i?t.getEnvelopeEndpointWithUrlEncodedAuth():t.getStoreEndpointWithUrlEncodedAuth()};if(i){var h=JSON.stringify(vn({event_id:e.event_id,sent_at:new Date().toISOString()},n&&{sdk:n})),m=JSON.stringify({type:e.type,sample_rates:[{id:c,rate:u}]}),g=h+`
`+m+`
`+d.body;d.body=g}return d}function qq(e,t){t.debug===!0&&Ve.enable();var n=ln(),r=new e(t);n.bindClient(r)}var r5="6.2.5",i5,Qq=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(){i5=Function.prototype.toString,Function.prototype.toString=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=this.__sentry_original__||this;return i5.apply(r,t)}},e.id="FunctionToString",e}(),Jq=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/],eQ=function(){function e(t){t===void 0&&(t={}),this._options=t,this.name=e.id}return e.prototype.setupOnce=function(){Rg(function(t){var n=ln();if(!n)return t;var r=n.getIntegration(e);if(r){var i=n.getClient(),o=i?i.getOptions():{},s=r._mergeOptions(o);if(r._shouldDropEvent(t,s))return null}return t})},e.prototype._shouldDropEvent=function(t,n){return this._isSentryError(t,n)?(Ve.warn(`Event dropped due to being internal Sentry Error.
Event: `+Os(t)),!0):this._isIgnoredError(t,n)?(Ve.warn("Event dropped due to being matched by `ignoreErrors` option.\nEvent: "+Os(t)),!0):this._isDeniedUrl(t,n)?(Ve.warn("Event dropped due to being matched by `denyUrls` option.\nEvent: "+Os(t)+`.
Url: `+this._getEventFilterUrl(t)),!0):this._isAllowedUrl(t,n)?!1:(Ve.warn("Event dropped due to not being matched by `allowUrls` option.\nEvent: "+Os(t)+`.
Url: `+this._getEventFilterUrl(t)),!0)},e.prototype._isSentryError=function(t,n){if(!n.ignoreInternal)return!1;try{return t&&t.exception&&t.exception.values&&t.exception.values[0]&&t.exception.values[0].type==="SentryError"||!1}catch{return!1}},e.prototype._isIgnoredError=function(t,n){return!n.ignoreErrors||!n.ignoreErrors.length?!1:this._getPossibleEventMessages(t).some(function(r){return n.ignoreErrors.some(function(i){return u0(r,i)})})},e.prototype._isDeniedUrl=function(t,n){if(!n.denyUrls||!n.denyUrls.length)return!1;var r=this._getEventFilterUrl(t);return r?n.denyUrls.some(function(i){return u0(r,i)}):!1},e.prototype._isAllowedUrl=function(t,n){if(!n.allowUrls||!n.allowUrls.length)return!0;var r=this._getEventFilterUrl(t);return r?n.allowUrls.some(function(i){return u0(r,i)}):!0},e.prototype._mergeOptions=function(t){return t===void 0&&(t={}),{allowUrls:rs(this._options.whitelistUrls||[],this._options.allowUrls||[],t.whitelistUrls||[],t.allowUrls||[]),denyUrls:rs(this._options.blacklistUrls||[],this._options.denyUrls||[],t.blacklistUrls||[],t.denyUrls||[]),ignoreErrors:rs(this._options.ignoreErrors||[],t.ignoreErrors||[],Jq),ignoreInternal:typeof this._options.ignoreInternal<"u"?this._options.ignoreInternal:!0}},e.prototype._getPossibleEventMessages=function(t){if(t.message)return[t.message];if(t.exception)try{var n=t.exception.values&&t.exception.values[0]||{},r=n.type,i=r===void 0?"":r,o=n.value,s=o===void 0?"":o;return[""+s,i+": "+s]}catch{return Ve.error("Cannot extract message for event "+Os(t)),[]}return[]},e.prototype._getEventFilterUrl=function(t){try{if(t.stacktrace){var n=t.stacktrace.frames;return n&&n[n.length-1].filename||null}if(t.exception){var r=t.exception.values&&t.exception.values[0].stacktrace&&t.exception.values[0].stacktrace.frames;return r&&r[r.length-1].filename||null}return null}catch{return Ve.error("Cannot extract url for event "+Os(t)),null}},e.id="InboundFilters",e}(),pu="?",tQ=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,nQ=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,rQ=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,iQ=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,oQ=/\((\S*)(?::(\d+))(?::(\d+))\)/,sQ=/Minified React error #\d+;/i;function zd(e){var t=null,n=0;e&&(typeof e.framesToPop=="number"?n=e.framesToPop:sQ.test(e.message)&&(n=1));try{if(t=lQ(e),t)return o5(t,n)}catch{}try{if(t=aQ(e),t)return o5(t,n)}catch{}return{message:Nw(e),name:e&&e.name,stack:[],failed:!0}}function aQ(e){if(!e||!e.stack)return null;for(var t=[],n=e.stack.split(`
`),r,i,o,s,a=0;a<n.length;++a){if(o=tQ.exec(n[a])){var l=o[2]&&o[2].indexOf("native")===0;r=o[2]&&o[2].indexOf("eval")===0,r&&(i=oQ.exec(o[2]))&&(o[2]=i[1],o[3]=i[2],o[4]=i[3]),s={url:o[2]&&o[2].indexOf("address at ")===0?o[2].substr(11):o[2],func:o[1]||pu,args:l?[o[2]]:[],line:o[3]?+o[3]:null,column:o[4]?+o[4]:null}}else if(o=rQ.exec(n[a]))s={url:o[2],func:o[1]||pu,args:[],line:+o[3],column:o[4]?+o[4]:null};else if(o=nQ.exec(n[a]))r=o[3]&&o[3].indexOf(" > eval")>-1,r&&(i=iQ.exec(o[3]))?(o[1]=o[1]||"eval",o[3]=i[1],o[4]=i[2],o[5]=""):a===0&&!o[5]&&e.columnNumber!==void 0&&(t[0].column=e.columnNumber+1),s={url:o[3],func:o[1]||pu,args:o[2]?o[2].split(","):[],line:o[4]?+o[4]:null,column:o[5]?+o[5]:null};else continue;!s.func&&s.line&&(s.func=pu),t.push(s)}return t.length?{message:Nw(e),name:e.name,stack:t}:null}function lQ(e){if(!e||!e.stacktrace)return null;for(var t=e.stacktrace,n=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,r=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\((.*)\))? in (.*):\s*$/i,i=t.split(`
`),o=[],s,a=0;a<i.length;a+=2){var l=null;(s=n.exec(i[a]))?l={url:s[2],func:s[3],args:[],line:+s[1],column:null}:(s=r.exec(i[a]))&&(l={url:s[6],func:s[3]||s[4],args:s[5]?s[5].split(","):[],line:+s[1],column:+s[2]}),l&&(!l.func&&l.line&&(l.func=pu),o.push(l))}return o.length?{message:Nw(e),name:e.name,stack:o}:null}function o5(e,t){try{return tt(tt({},e),{stack:e.stack.slice(t)})}catch{return e}}function Nw(e){var t=e&&e.message;return t?t.error&&typeof t.error.message=="string"?t.error.message:t:"No error message"}var cQ=50;function rA(e){var t=Fw(e.stack),n={type:e.name,value:e.message};return t&&t.length&&(n.stacktrace={frames:t}),n.type===void 0&&n.value===""&&(n.value="Unrecoverable error caught"),n}function uQ(e,t,n){var r={exception:{values:[{type:Tw(e)?e.constructor.name:n?"UnhandledRejection":"Error",value:"Non-Error "+(n?"promise rejection":"exception")+" captured with keys: "+yq(e)}]},extra:{__serialized__:GM(e)}};if(t){var i=zd(t),o=Fw(i.stack);r.stacktrace={frames:o}}return r}function s5(e){var t=rA(e);return{exception:{values:[t]}}}function Fw(e){if(!e||!e.length)return[];var t=e,n=t[0].func||"",r=t[t.length-1].func||"";return(n.indexOf("captureMessage")!==-1||n.indexOf("captureException")!==-1)&&(t=t.slice(1)),r.indexOf("sentryWrapped")!==-1&&(t=t.slice(0,-1)),t.slice(0,cQ).map(function(i){return{colno:i.column===null?void 0:i.column,filename:i.url||t[0].url,function:i.func||"?",in_app:!0,lineno:i.line===null?void 0:i.line}}).reverse()}function dQ(e,t,n){var r=n&&n.syntheticException||void 0,i=Ly(t,r,{attachStacktrace:e.attachStacktrace});return nc(i,{handled:!0,type:"generic"}),i.level=Jr.Error,n&&n.event_id&&(i.event_id=n.event_id),Nn.resolve(i)}function hQ(e,t,n,r){n===void 0&&(n=Jr.Info);var i=r&&r.syntheticException||void 0,o=Py(t,i,{attachStacktrace:e.attachStacktrace});return o.level=n,r&&r.event_id&&(o.event_id=r.event_id),Nn.resolve(o)}function Ly(e,t,n){n===void 0&&(n={});var r;if(HM(e)&&e.error){var i=e;return e=i.error,r=s5(zd(e)),r}if(K4(e)||qX(e)){var o=e,s=o.name||(K4(o)?"DOMError":"DOMException"),a=o.message?s+": "+o.message:s;return r=Py(a,t,n),Ty(r,a),"code"in o&&(r.tags=tt(tt({},r.tags),{"DOMException.code":""+o.code})),r}if(zM(e))return r=s5(zd(e)),r;if(Pg(e)||Tw(e)){var l=e;return r=uQ(l,t,n.rejection),nc(r,{synthetic:!0}),r}return r=Py(e,t,n),Ty(r,""+e,void 0),nc(r,{synthetic:!0}),r}function Py(e,t,n){n===void 0&&(n={});var r={message:e};if(n.attachStacktrace&&t){var i=zd(t),o=Fw(i.stack);r.stacktrace={frames:o}}return r}var fQ={event:"error",transaction:"transaction",session:"session"},iA=function(){function e(t){this.options=t,this._buffer=new Dq(30),this._rateLimits={},this._api=new JM(t.dsn,t._metadata),this.url=this._api.getStoreEndpointWithUrlEncodedAuth()}return e.prototype.sendEvent=function(t){throw new Kt("Transport Class has to implement `sendEvent` method")},e.prototype.close=function(t){return this._buffer.drain(t)},e.prototype._handleResponse=function(t){var n=t.requestType,r=t.response,i=t.headers,o=t.resolve,s=t.reject,a=Aa.fromHttpCode(r.status),l=this._handleRateLimit(i);if(l&&Ve.warn("Too many requests, backing off until: "+this._disabledUntil(n)),a===Aa.Success){o({status:a});return}s(r)},e.prototype._disabledUntil=function(t){var n=fQ[t];return this._rateLimits[n]||this._rateLimits.all},e.prototype._isRateLimited=function(t){return this._disabledUntil(t)>new Date(Date.now())},e.prototype._handleRateLimit=function(t){var n,r,i,o,s=Date.now(),a=t["x-sentry-rate-limits"],l=t["retry-after"];if(a){try{for(var c=Y4(a.trim().split(",")),u=c.next();!u.done;u=c.next()){var d=u.value,h=d.split(":",2),m=parseInt(h[0],10),g=(isNaN(m)?60:m)*1e3;try{for(var p=(i=void 0,Y4(h[1].split(";"))),v=p.next();!v.done;v=p.next()){var y=v.value;this._rateLimits[y||"all"]=new Date(s+g)}}catch(E){i={error:E}}finally{try{v&&!v.done&&(o=p.return)&&o.call(p)}finally{if(i)throw i.error}}}}catch(E){n={error:E}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return!0}else if(l)return this._rateLimits.all=new Date(s+uq(s,l)),!0;return!1},e}();function mQ(){var e,t,n=Pt();if(My(n.fetch))return n.fetch.bind(n);var r=n.document,i=n.fetch;if(typeof((e=r)===null||e===void 0?void 0:e.createElement)=="function")try{var o=r.createElement("iframe");o.hidden=!0,r.head.appendChild(o),!((t=o.contentWindow)===null||t===void 0)&&t.fetch&&(i=o.contentWindow.fetch),r.head.removeChild(o)}catch(s){Ve.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",s)}return i.bind(n)}var gQ=function(e){Lg(t,e);function t(n,r){r===void 0&&(r=mQ());var i=e.call(this,n)||this;return i._fetch=r,i}return t.prototype.sendEvent=function(n){return this._sendRequest(nA(n,this._api),n)},t.prototype.sendSession=function(n){return this._sendRequest(tA(n,this._api),n)},t.prototype._sendRequest=function(n,r){var i=this;if(this._isRateLimited(n.type))return Promise.reject({event:r,type:n.type,reason:"Transport locked till "+this._disabledUntil(n.type)+" due to too many requests.",status:429});var o={body:n.body,method:"POST",referrerPolicy:Eq()?"origin":""};return this.options.fetchParameters!==void 0&&Object.assign(o,this.options.fetchParameters),this.options.headers!==void 0&&(o.headers=this.options.headers),this._buffer.add(new Nn(function(s,a){i._fetch(n.url,o).then(function(l){var c={"x-sentry-rate-limits":l.headers.get("X-Sentry-Rate-Limits"),"retry-after":l.headers.get("Retry-After")};i._handleResponse({requestType:n.type,response:l,headers:c,resolve:s,reject:a})}).catch(a)}))},t}(iA),pQ=function(e){Lg(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.sendEvent=function(n){return this._sendRequest(nA(n,this._api),n)},t.prototype.sendSession=function(n){return this._sendRequest(tA(n,this._api),n)},t.prototype._sendRequest=function(n,r){var i=this;return this._isRateLimited(n.type)?Promise.reject({event:r,type:n.type,reason:"Transport locked till "+this._disabledUntil(n.type)+" due to too many requests.",status:429}):this._buffer.add(new Nn(function(o,s){var a=new XMLHttpRequest;a.onreadystatechange=function(){if(a.readyState===4){var c={"x-sentry-rate-limits":a.getResponseHeader("X-Sentry-Rate-Limits"),"retry-after":a.getResponseHeader("Retry-After")};i._handleResponse({requestType:n.type,response:a,headers:c,resolve:o,reject:s})}},a.open("POST",n.url);for(var l in i.options.headers)i.options.headers.hasOwnProperty(l)&&a.setRequestHeader(l,i.options.headers[l]);a.send(n.body)}))},t}(iA),yQ=function(e){Lg(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.eventFromException=function(n,r){return dQ(this._options,n,r)},t.prototype.eventFromMessage=function(n,r,i){return r===void 0&&(r=Jr.Info),hQ(this._options,n,r,i)},t.prototype._setupTransport=function(){if(!this._options.dsn)return e.prototype._setupTransport.call(this);var n=tt(tt({},this._options.transportOptions),{dsn:this._options.dsn,_metadata:this._options._metadata});return this._options.transport?new this._options.transport(n):Lw()?new gQ(n):new pQ(n)},t}(Zq),Ry=0;function a5(){return Ry>0}function vQ(){Ry+=1,setTimeout(function(){Ry-=1})}function el(e,t,n){if(t===void 0&&(t={}),typeof e!="function")return e;try{if(e.__sentry__)return e;if(e.__sentry_wrapped__)return e.__sentry_wrapped__}catch{return e}var r=function(){var s=Array.prototype.slice.call(arguments);try{n&&typeof n=="function"&&n.apply(this,arguments);var a=s.map(function(l){return el(l,t)});return e.handleEvent?e.handleEvent.apply(this,a):e.apply(this,a)}catch(l){throw vQ(),QM(function(c){c.addEventProcessor(function(u){var d=tt({},u);return t.mechanism&&(Ty(d,void 0,void 0),nc(d,t.mechanism)),d.extra=tt(tt({},d.extra),{arguments:s}),d}),qM(l)}),l}};try{for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}catch{}e.prototype=e.prototype||{},r.prototype=e.prototype,Object.defineProperty(e,"__sentry_wrapped__",{enumerable:!1,value:r}),Object.defineProperties(r,{__sentry__:{enumerable:!1,value:!0},__sentry_original__:{enumerable:!1,value:e}});try{var o=Object.getOwnPropertyDescriptor(r,"name");o.configurable&&Object.defineProperty(r,"name",{get:function(){return e.name}})}catch{}return r}function EQ(e){if(e===void 0&&(e={}),!e.eventId){Ve.error("Missing eventId option in showReportDialog call");return}if(!e.dsn){Ve.error("Missing dsn option in showReportDialog call");return}var t=document.createElement("script");t.async=!0,t.src=new JM(e.dsn).getReportDialogEndpoint(e),e.onLoad&&(t.onload=e.onLoad),(document.head||document.body).appendChild(t)}var wQ=function(){function e(t){this.name=e.id,this._onErrorHandlerInstalled=!1,this._onUnhandledRejectionHandlerInstalled=!1,this._options=tt({onerror:!0,onunhandledrejection:!0},t)}return e.prototype.setupOnce=function(){Error.stackTraceLimit=50,this._options.onerror&&(Ve.log("Global Handler attached: onerror"),this._installGlobalOnErrorHandler()),this._options.onunhandledrejection&&(Ve.log("Global Handler attached: onunhandledrejection"),this._installGlobalOnUnhandledRejectionHandler())},e.prototype._installGlobalOnErrorHandler=function(){var t=this;this._onErrorHandlerInstalled||(Ao({callback:function(n){var r=n.error,i=ln(),o=i.getIntegration(e),s=r&&r.__sentry_own_request__===!0;if(!(!o||a5()||s)){var a=i.getClient(),l=Bd(r)?t._eventFromIncompleteOnError(n.msg,n.url,n.line,n.column):t._enhanceEventWithInitialFrame(Ly(r,void 0,{attachStacktrace:a&&a.getOptions().attachStacktrace,rejection:!1}),n.url,n.line,n.column);nc(l,{handled:!1,type:"onerror"}),i.captureEvent(l,{originalException:r})}},type:"error"}),this._onErrorHandlerInstalled=!0)},e.prototype._installGlobalOnUnhandledRejectionHandler=function(){var t=this;this._onUnhandledRejectionHandlerInstalled||(Ao({callback:function(n){var r=n;try{"reason"in n?r=n.reason:"detail"in n&&"reason"in n.detail&&(r=n.detail.reason)}catch{}var i=ln(),o=i.getIntegration(e),s=r&&r.__sentry_own_request__===!0;if(!o||a5()||s)return!0;var a=i.getClient(),l=Bd(r)?t._eventFromRejectionWithPrimitive(r):Ly(r,void 0,{attachStacktrace:a&&a.getOptions().attachStacktrace,rejection:!0});l.level=Jr.Error,nc(l,{handled:!1,type:"onunhandledrejection"}),i.captureEvent(l,{originalException:r})},type:"unhandledrejection"}),this._onUnhandledRejectionHandlerInstalled=!0)},e.prototype._eventFromIncompleteOnError=function(t,n,r,i){var o=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,s=HM(t)?t.message:t,a;if(tc(s)){var l=s.match(o);l&&(a=l[1],s=l[2])}var c={exception:{values:[{type:a||"Error",value:s}]}};return this._enhanceEventWithInitialFrame(c,n,r,i)},e.prototype._eventFromRejectionWithPrimitive=function(t){return{exception:{values:[{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(t)}]}}},e.prototype._enhanceEventWithInitialFrame=function(t,n,r,i){t.exception=t.exception||{},t.exception.values=t.exception.values||[],t.exception.values[0]=t.exception.values[0]||{},t.exception.values[0].stacktrace=t.exception.values[0].stacktrace||{},t.exception.values[0].stacktrace.frames=t.exception.values[0].stacktrace.frames||[];var o=isNaN(parseInt(i,10))?void 0:i,s=isNaN(parseInt(r,10))?void 0:r,a=tc(n)&&n.length>0?n:cq();return t.exception.values[0].stacktrace.frames.length===0&&t.exception.values[0].stacktrace.frames.push({colno:o,filename:a,function:"?",in_app:!0,lineno:s}),t},e.id="GlobalHandlers",e}(),bQ=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],_Q=function(){function e(t){this.name=e.id,this._options=tt({XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0},t)}return e.prototype.setupOnce=function(){var t=Pt();if(this._options.setTimeout&&Zt(t,"setTimeout",this._wrapTimeFunction.bind(this)),this._options.setInterval&&Zt(t,"setInterval",this._wrapTimeFunction.bind(this)),this._options.requestAnimationFrame&&Zt(t,"requestAnimationFrame",this._wrapRAF.bind(this)),this._options.XMLHttpRequest&&"XMLHttpRequest"in t&&Zt(XMLHttpRequest.prototype,"send",this._wrapXHR.bind(this)),this._options.eventTarget){var n=Array.isArray(this._options.eventTarget)?this._options.eventTarget:bQ;n.forEach(this._wrapEventTarget.bind(this))}},e.prototype._wrapTimeFunction=function(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=n[0];return n[0]=el(i,{mechanism:{data:{function:bo(t)},handled:!0,type:"instrument"}}),t.apply(this,n)}},e.prototype._wrapRAF=function(t){return function(n){return t.call(this,el(n,{mechanism:{data:{function:"requestAnimationFrame",handler:bo(t)},handled:!0,type:"instrument"}}))}},e.prototype._wrapEventTarget=function(t){var n=Pt(),r=n[t]&&n[t].prototype;!r||!r.hasOwnProperty||!r.hasOwnProperty("addEventListener")||(Zt(r,"addEventListener",function(i){return function(o,s,a){try{typeof s.handleEvent=="function"&&(s.handleEvent=el(s.handleEvent.bind(s),{mechanism:{data:{function:"handleEvent",handler:bo(s),target:t},handled:!0,type:"instrument"}}))}catch{}return i.call(this,o,el(s,{mechanism:{data:{function:"addEventListener",handler:bo(s),target:t},handled:!0,type:"instrument"}}),a)}}),Zt(r,"removeEventListener",function(i){return function(o,s,a){var l,c=s;try{var u=(l=c)===null||l===void 0?void 0:l.__sentry_wrapped__;u&&i.call(this,o,u,a)}catch{}return i.call(this,o,c,a)}}))},e.prototype._wrapXHR=function(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=this,o=["onload","onerror","onprogress","onreadystatechange"];return o.forEach(function(s){s in i&&typeof i[s]=="function"&&Zt(i,s,function(a){var l={mechanism:{data:{function:s,handler:bo(a)},handled:!0,type:"instrument"}};return a.__sentry_original__&&(l.mechanism.data.handler=bo(a.__sentry_original__)),el(a,l)})}),t.apply(this,n)}},e.id="TryCatch",e}(),oA=function(){function e(t){this.name=e.id,this._options=tt({console:!0,dom:!0,fetch:!0,history:!0,sentry:!0,xhr:!0},t)}return e.prototype.addSentryBreadcrumb=function(t){this._options.sentry&&ln().addBreadcrumb({category:"sentry."+(t.type==="transaction"?"transaction":"event"),event_id:t.event_id,level:t.level,message:Os(t)},{event:t})},e.prototype.setupOnce=function(){var t=this;this._options.console&&Ao({callback:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];t._consoleBreadcrumb.apply(t,$s(n))},type:"console"}),this._options.dom&&Ao({callback:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];t._domBreadcrumb.apply(t,$s(n))},type:"dom"}),this._options.xhr&&Ao({callback:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];t._xhrBreadcrumb.apply(t,$s(n))},type:"xhr"}),this._options.fetch&&Ao({callback:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];t._fetchBreadcrumb.apply(t,$s(n))},type:"fetch"}),this._options.history&&Ao({callback:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];t._historyBreadcrumb.apply(t,$s(n))},type:"history"})},e.prototype._consoleBreadcrumb=function(t){var n={category:"console",data:{arguments:t.args,logger:"console"},level:Jr.fromString(t.level),message:u1(t.args," ")};if(t.level==="assert")if(t.args[0]===!1)n.message="Assertion failed: "+(u1(t.args.slice(1)," ")||"console.assert"),n.data.arguments=t.args.slice(1);else return;ln().addBreadcrumb(n,{input:t.args,level:t.level})},e.prototype._domBreadcrumb=function(t){var n;try{n=t.event.target?c1(t.event.target):c1(t.event)}catch{n="<unknown>"}n.length!==0&&ln().addBreadcrumb({category:"ui."+t.name,message:n},{event:t.event,name:t.name,global:t.global})},e.prototype._xhrBreadcrumb=function(t){if(t.endTimestamp){if(t.xhr.__sentry_own_request__)return;var n=t.xhr.__sentry_xhr__||{},r=n.method,i=n.url,o=n.status_code,s=n.body;ln().addBreadcrumb({category:"xhr",data:{method:r,url:i,status_code:o},type:"http"},{xhr:t.xhr,input:s});return}},e.prototype._fetchBreadcrumb=function(t){t.endTimestamp&&(t.fetchData.url.match(/sentry_key/)&&t.fetchData.method==="POST"||(t.error?ln().addBreadcrumb({category:"fetch",data:t.fetchData,level:Jr.Error,type:"http"},{data:t.error,input:t.args}):ln().addBreadcrumb({category:"fetch",data:tt(tt({},t.fetchData),{status_code:t.response.status}),type:"http"},{input:t.args,response:t.response})))},e.prototype._historyBreadcrumb=function(t){var n=Pt(),r=t.from,i=t.to,o=d0(n.location.href),s=d0(r),a=d0(i);s.path||(s=o),o.protocol===a.protocol&&o.host===a.host&&(i=a.relative),o.protocol===s.protocol&&o.host===s.host&&(r=s.relative),ln().addBreadcrumb({category:"navigation",data:{from:r,to:i}})},e.id="Breadcrumbs",e}(),xQ="cause",SQ=5,kQ=function(){function e(t){t===void 0&&(t={}),this.name=e.id,this._key=t.key||xQ,this._limit=t.limit||SQ}return e.prototype.setupOnce=function(){Rg(function(t,n){var r=ln().getIntegration(e);return r?r._handler(t,n):t})},e.prototype._handler=function(t,n){if(!t.exception||!t.exception.values||!n||!gs(n.originalException,Error))return t;var r=this._walkErrorTree(n.originalException,this._key);return t.exception.values=$s(r,t.exception.values),t},e.prototype._walkErrorTree=function(t,n,r){if(r===void 0&&(r=[]),!gs(t[n],Error)||r.length+1>=this._limit)return r;var i=zd(t[n]),o=rA(i);return this._walkErrorTree(t[n],n,$s([o],r))},e.id="LinkedErrors",e}(),qa=Pt(),IQ=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(){Rg(function(t){var n,r,i;if(ln().getIntegration(e)){if(!qa.navigator&&!qa.location&&!qa.document)return t;var o=((n=t.request)===null||n===void 0?void 0:n.url)||((r=qa.location)===null||r===void 0?void 0:r.href),s=(qa.document||{}).referrer,a=(qa.navigator||{}).userAgent,l=tt(tt(tt({},(i=t.request)===null||i===void 0?void 0:i.headers),s&&{Referer:s}),a&&{"User-Agent":a}),c=tt(tt({},o&&{url:o}),{headers:l});return tt(tt({},t),{request:c})}return t})},e.id="UserAgent",e}(),CQ=function(e){Lg(t,e);function t(n){n===void 0&&(n={});var r=this;return n._metadata=n._metadata||{},n._metadata.sdk=n._metadata.sdk||{name:"sentry.javascript.browser",packages:[{name:"npm:@sentry/browser",version:r5}],version:r5},r=e.call(this,yQ,n)||this,r}return t.prototype.showReportDialog=function(n){n===void 0&&(n={});var r=Pt().document;if(r){if(!this._isEnabled()){Ve.error("Trying to call showReportDialog with Sentry Client disabled");return}EQ(tt(tt({},n),{dsn:n.dsn||this.getDsn()}))}},t.prototype._prepareEvent=function(n,r,i){return n.platform=n.platform||"javascript",e.prototype._prepareEvent.call(this,n,r,i)},t.prototype._sendEvent=function(n){var r=this.getIntegration(oA);r&&r.addSentryBreadcrumb(n),e.prototype._sendEvent.call(this,n)},t}(Yq),TQ=[new eQ,new Qq,new _Q,new oA,new wQ,new kQ,new IQ];function MQ(e){if(e===void 0&&(e={}),e.defaultIntegrations===void 0&&(e.defaultIntegrations=TQ),e.release===void 0){var t=Pt();t.SENTRY_RELEASE&&t.SENTRY_RELEASE.id&&(e.release=t.SENTRY_RELEASE.id)}e.autoSessionTracking===void 0&&(e.autoSessionTracking=!0),qq(CQ,e),e.autoSessionTracking&&AQ()}function AQ(){var e=Pt(),t=e.document;if(typeof t>"u"){Ve.warn("Session tracking in non-browser environment with @sentry/browser is not supported.");return}var n=ln();"startSession"in n&&(n.startSession(),n.captureSession(),Ao({callback:function(){n.startSession(),n.captureSession()},type:"history"}))}class LQ extends te.Component{constructor(){super(...arguments);M(this,"state",{hasError:!1,sentryEventId:"",localStorage:""})}render(){return this.state.hasError?this.errorSplash():this.props.children}componentDidCatch(n,r){const i={};for(const[o,s]of Object.entries({...localStorage}))try{i[o]=JSON.parse(s)}catch{i[o]=s}QM(o=>{o.setExtras(r);const s=qM(n);this.setState(a=>({hasError:!0,sentryEventId:s,localStorage:JSON.stringify(i)}))})}selectTextArea(n){n.target!==document.activeElement&&(n.preventDefault(),n.target.select())}async createGithubIssue(){let n="";try{const r=(await ie(()=>import("./bug-issue-template-RzHCT2ur.js"),__vite__mapDeps([]))).default;n=encodeURIComponent(r(this.state.sentryEventId))}catch(r){console.error(r)}window.open(`https://github.com/excalidraw/excalidraw/issues/new?body=${n}`)}errorSplash(){return f("div",{className:"ErrorSplash excalidraw",children:k("div",{className:"ErrorSplash-messageContainer",children:[f("div",{className:"ErrorSplash-paragraph bigger align-center",children:f(On,{i18nKey:"errorSplash.headingMain",button:n=>f("button",{onClick:()=>window.location.reload(),children:n})})}),k("div",{className:"ErrorSplash-paragraph align-center",children:[f(On,{i18nKey:"errorSplash.clearCanvasMessage",button:n=>f("button",{onClick:()=>{try{localStorage.clear(),window.location.reload()}catch(r){console.error(r)}},children:n})}),f("br",{}),k("div",{className:"smaller",children:[f("span",{role:"img","aria-label":"warning",children:"⚠️"}),b("errorSplash.clearCanvasCaveat"),f("span",{role:"img","aria-hidden":"true",children:"⚠️"})]})]}),k("div",{children:[f("div",{className:"ErrorSplash-paragraph",children:b("errorSplash.trackedToSentry",{eventId:this.state.sentryEventId})}),f("div",{className:"ErrorSplash-paragraph",children:f(On,{i18nKey:"errorSplash.openIssueMessage",button:n=>f("button",{onClick:()=>this.createGithubIssue(),children:n})})}),f("div",{className:"ErrorSplash-paragraph",children:k("div",{className:"ErrorSplash-details",children:[f("label",{children:b("errorSplash.sceneContent")}),f("textarea",{rows:5,onPointerDown:this.selectTextArea,readOnly:!0,value:this.state.localStorage})]})})]})]})})}}const PQ=300,RQ=5e3,DQ=300,OQ=500,l5=2e4,NQ=50,FQ=33,$Q=24*60*60*1e3,$w=3*1024*1024,BQ=31536e3,qf={SERVER_VOLATILE:"server-volatile-broadcast",SERVER:"server-broadcast",USER_FOLLOW_CHANGE:"user-follow",USER_FOLLOW_ROOM_CHANGE:"user-follow-room-change"};var wn=(e=>(e.INVALID_RESPONSE="INVALID_RESPONSE",e.INIT="SCENE_INIT",e.UPDATE="SCENE_UPDATE",e.MOUSE_LOCATION="MOUSE_LOCATION",e.IDLE_STATUS="IDLE_STATUS",e.USER_VISIBLE_SCENE_BOUNDS="USER_VISIBLE_SCENE_BOUNDS",e))(wn||{});const sA={shareLinkFiles:"/files/shareLinks",collabFiles:"/files/rooms"},zQ=10,At={LOCAL_STORAGE_ELEMENTS:"excalidraw",LOCAL_STORAGE_APP_STATE:"excalidraw-state",LOCAL_STORAGE_COLLAB:"excalidraw-collab",LOCAL_STORAGE_THEME:"excalidraw-theme",VERSION_DATA_STATE:"version-dataState",VERSION_FILES:"version-files",IDB_LIBRARY:"excalidraw-library",__LEGACY_LOCAL_STORAGE_LIBRARY:"excalidraw-library"},HQ={AUTH_STATE_COOKIE:"excplus-auth"},Bw=document.cookie.includes(HQ.AUTH_STATE_COOKIE);class aA{constructor({getFiles:t,saveFiles:n}){M(this,"fetchingFiles",new Map);M(this,"savingFiles",new Map);M(this,"savedFiles",new Map);M(this,"erroredFiles",new Map);M(this,"_getFiles");M(this,"_saveFiles");M(this,"isFileHandled",t=>this.savedFiles.has(t)||this.fetchingFiles.has(t)||this.savingFiles.has(t)||this.erroredFiles.has(t));M(this,"isFileSaved",t=>this.savedFiles.has(t));M(this,"saveFiles",async({elements:t,files:n})=>{const r=new Map;for(const i of t)Ft(i)&&n[i.fileId]&&!this.isFileHandled(i.fileId)&&(r.set(i.fileId,n[i.fileId]),this.savingFiles.set(i.fileId,!0));try{const{savedFiles:i,erroredFiles:o}=await this._saveFiles({addedFiles:r});for(const[s]of i)this.savedFiles.set(s,!0);return{savedFiles:i,erroredFiles:o}}finally{for(const[i]of r)this.savingFiles.delete(i)}});M(this,"getFiles",async t=>{if(!t.length)return{loadedFiles:[],erroredFiles:new Map};for(const n of t)this.fetchingFiles.set(n,!0);try{const{loadedFiles:n,erroredFiles:r}=await this._getFiles(t);for(const i of n)this.savedFiles.set(i.id,!0);for(const[i]of r)this.erroredFiles.set(i,!0);return{loadedFiles:n,erroredFiles:r}}finally{for(const n of t)this.fetchingFiles.delete(n)}});M(this,"shouldPreventUnload",t=>t.some(n=>Ft(n)&&!n.isDeleted&&this.savingFiles.has(n.fileId)));M(this,"shouldUpdateImageElementStatus",t=>Ft(t)&&this.isFileSaved(t.fileId)&&t.status==="pending");this._getFiles=t,this._saveFiles=n}reset(){this.fetchingFiles.clear(),this.savingFiles.clear(),this.savedFiles.clear(),this.erroredFiles.clear()}}const zw=async({files:e,maxBytes:t,encryptionKey:n})=>{const r=[];for(const[i,o]of e){const s=new TextEncoder().encode(o.dataURL),a=await uT(s,{encryptionKey:n,metadata:{id:i,mimeType:o.mimeType,created:Date.now(),lastRetrieved:Date.now()}});if(s.byteLength>t)throw new Error(b("errors.fileTooBig",{maxSize:`${Math.trunc(t/1024/1024)}MB`}));r.push({id:i,buffer:a})}return r},yu=e=>{e.erroredFiles.size&&e.excalidrawAPI.updateScene({elements:e.excalidrawAPI.getSceneElementsIncludingDeleted().map(t=>Ft(t)&&e.erroredFiles.has(t.fileId)?ge(t,{status:"error"}):t)})},UQ=(e,t,n)=>{var r,i,o;return!!(t&&(t.id===((r=e.editingElement)==null?void 0:r.id)||t.id===((i=e.resizingElement)==null?void 0:i.id)||t.id===((o=e.draggingElement)==null?void 0:o.id)||t.version>n.version||t.version===n.version&&t.versionNonce<n.versionNonce))},Hw=(e,t,n)=>{var u;const r=Zk(e),i=e.slice(),o=new WeakMap;let s=0,a=0,l=-1;for(const d of t){l++;const h=r.get(d.id);if(UQ(n,h==null?void 0:h[0],d)){d[Do]&&delete d[Do];continue}if(h){if(h[0]===d)continue;o.set(h[0],!0)}const m=d[Do]||((u=t[l-1])==null?void 0:u.id)||null;if(m!=null)if(delete d[Do],m==="^")a++,s===0?(i.unshift(d),r.set(d.id,[d,s-a])):(i.splice(s+1,0,d),r.set(d.id,[d,s+1-a]),s++);else{let g=r.has(m)?r.get(m)[1]:null;g!=null&&(g+=a),g!=null&&g>=s?(i.splice(g+1,0,d),a++,r.set(d.id,[d,g+1-a]),s=g+1):g!=null?(i.splice(s+1,0,d),a++,r.set(d.id,[d,s+1-a]),s++):(i.push(d),r.set(d.id,[d,i.length-1-a]))}else h?(i[h[1]]=d,r.set(d.id,[d,h[1]])):(i.push(d),r.set(d.id,[d,i.length-1-a]))}return i.filter(d=>!o.has(d))};let f1;try{f1=JSON.parse('{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}')}catch{console.warn('Error JSON parsing firebase config. Supplied value: {"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}'),f1={}}let y0=null,Jc=null,eu=null,c5=!1;const WQ=async()=>{const e=(await ie(()=>import("./index.esm-EExsODKC.js"),__vite__mapDeps([2,3]))).default;if(!c5){try{e.initializeApp(f1)}catch(t){if(t.code==="app/duplicate-app")console.warn(t.name,t.code);else throw t}c5=!0}return e},lA=async()=>(y0||(y0=WQ()),y0),cA=async()=>{const e=await lA();return Jc||(Jc=ie(()=>import("./index.esm-h2kZ9fZN.js"),__vite__mapDeps([4,3]))),Jc!==!0&&(await Jc,Jc=!0),e},uA=async()=>{const e=await lA();return eu||(eu=ie(()=>import("./index.esm-Aqyp0Gpy.js"),__vite__mapDeps([5,3]))),eu!==!0&&(await eu,eu=!0),e},VQ=async(e,t)=>{const n=JSON.stringify(t),r=new TextEncoder().encode(n),{encryptedBuffer:i,iv:o}=await ig(e,r);return{ciphertext:i,iv:o}},dA=async(e,t)=>{const n=e.ciphertext.toUint8Array(),r=e.iv.toUint8Array(),i=await Td(r,n,t),o=new TextDecoder("utf-8").decode(new Uint8Array(i));return JSON.parse(o)},Hs=class Hs{};M(Hs,"cache",new WeakMap),M(Hs,"get",t=>Hs.cache.get(t)),M(Hs,"set",(t,n)=>{Hs.cache.set(t,To(n))});let Hd=Hs;const hA=(e,t)=>{if(e.socket&&e.roomId&&e.roomKey){const n=To(t);return Hd.get(e.socket)===n}return!0},Uw=async({prefix:e,files:t})=>{const n=await uA(),r=new Map,i=new Map;return await Promise.all(t.map(async({id:o,buffer:s})=>{try{await n.storage().ref(`${e}/${o}`).put(new Blob([s],{type:de.binary}),{cacheControl:`public, max-age=${BQ}`}),i.set(o,!0)}catch{r.set(o,!0)}})),{savedFiles:i,erroredFiles:r}},u5=async(e,t,n)=>{const r=To(t),{ciphertext:i,iv:o}=await VQ(n,t);return{sceneVersion:r,ciphertext:e.firestore.Blob.fromUint8Array(new Uint8Array(i)),iv:e.firestore.Blob.fromUint8Array(o)}},GQ=async(e,t,n)=>{const{roomId:r,roomKey:i,socket:o}=e;if(!r||!i||!o||hA(e,t))return!1;const s=await cA(),a=s.firestore(),l=a.collection("scenes").doc(r),c=await a.runTransaction(async u=>{const d=await u.get(l);if(!d.exists){const v=await u5(s,t,i);return u.set(l,v),{elements:t,reconciledElements:null}}const h=d.data(),m=ea(await dA(h,i)),g=ea(Hw(t,m,n)),p=await u5(s,g,i);return u.update(l,p),{elements:t,reconciledElements:g}});return Hd.set(o,c.elements),{reconciledElements:c.reconciledElements}},jQ=async(e,t,n)=>{const s=await(await cA()).firestore().collection("scenes").doc(e).get();if(!s.exists)return null;const a=s.data(),l=ea(await dA(a,t));return n&&Hd.set(n,l),nh(l,null)},fA=async(e,t,n)=>{const r=[],i=new Map;return await Promise.all([...new Set(n)].map(async o=>{try{const s=`https://firebasestorage.googleapis.com/v0/b/${f1.storageBucket}/o/${encodeURIComponent(e.replace(/^\//,""))}%2F${o}`,a=await fetch(`${s}?alt=media`);if(a.status<400){const l=await a.arrayBuffer(),{data:c,metadata:u}=await dT(new Uint8Array(l),{decryptionKey:t}),d=new TextDecoder().decode(c);r.push({mimeType:u.mimeType||de.binary,id:o,dataURL:d,created:(u==null?void 0:u.created)||Date.now(),lastRetrieved:(u==null?void 0:u.created)||Date.now()})}else i.set(o,!0)}catch(s){i.set(o,!0),console.error(s)}})),{loadedFiles:r,erroredFiles:i}},mA=e=>e.isDeleted?e.updated>Date.now()-$Q:!Ma(e),ea=e=>e.filter(t=>mA(t)),YQ="https://json.excalidraw.com/api/v2/",KQ="https://json.excalidraw.com/api/v2/post/",ZQ=async()=>{const e=new Uint8Array(zQ);return window.crypto.getRandomValues(e),Kk(e)},gA=/^#room=([a-zA-Z0-9_-]+),([a-zA-Z0-9_-]+)$/,d5=e=>{const t=new URL(e).hash;return gA.test(t)},XQ=e=>{const n=new URL(e).hash.match(gA);return n&&n[2].length!==22?(window.alert(b("alerts.invalidEncryptionKey")),null):n?{roomId:n[1],roomKey:n[2]}:null},qQ=async()=>{const e=await ZQ(),t=await TE();if(!t)throw new Error("Couldn't generate room key");return{roomId:e,roomKey:t}},QQ=e=>`${window.location.origin}${window.location.pathname}#room=${e.roomId},${e.roomKey}`,JQ=async({buffer:e,decryptionKey:t})=>{let n;try{const o=e.slice(0,Bf),s=e.slice(Bf,e.byteLength);n=await Td(new Uint8Array(o),s,t)}catch{const s=new Uint8Array(Bf);n=await Td(s,e,t)}const r=new window.TextDecoder("utf-8").decode(new Uint8Array(n)),i=JSON.parse(r);return{elements:i.elements||null,appState:i.appState||null}},eJ=async(e,t)=>{try{const n=await fetch(`${YQ}${e}`);if(!n.ok)return window.alert(b("alerts.importBackendFailed")),{};const r=await n.arrayBuffer();try{const{data:i}=await dT(new Uint8Array(r),{decryptionKey:t}),o=JSON.parse(new TextDecoder().decode(i));return{elements:o.elements||null,appState:o.appState||null}}catch(i){return console.warn("error when decoding shareLink data using the new format:",i),JQ({buffer:r,decryptionKey:t})}}catch(n){return window.alert(b("alerts.importBackendFailed")),console.error(n),{}}},h5=async(e,t,n)=>{let r;return e!=null&&t!=null?r=_a(await eJ(e,t),n==null?void 0:n.appState,n==null?void 0:n.elements,{repairBindings:!0,refreshDimensions:!1}):r=_a(n||null,null,null,{repairBindings:!0}),{elements:r.elements,appState:r.appState,files:r.files,commitToHistory:!1}},tJ=async(e,t,n)=>{const r=await TE("string"),i=await uT(new TextEncoder().encode(hc(e,t,n,"database")),{encryptionKey:r});try{const o=new Map;for(const c of e)Ft(c)&&n[c.fileId]&&o.set(c.fileId,n[c.fileId]);const s=await zw({files:o,encryptionKey:r,maxBytes:$w}),l=await(await fetch(KQ,{method:"POST",body:i.buffer})).json();if(l.id){const c=new URL(window.location.href);c.hash=`json=${l.id},${r}`;const u=c.toString();return await Uw({prefix:`/files/shareLinks/${l.id}`,files:s}),{url:u,errorMessage:null}}else if(l.error_class==="RequestTooLargeError")return{url:null,errorMessage:b("alerts.couldNotCreateShareableLinkTooBig")};return{url:null,errorMessage:b("alerts.couldNotCreateShareableLink")}}catch(o){return console.error(o),{url:null,errorMessage:b("alerts.couldNotCreateShareableLink")}}},nJ=e=>{try{localStorage.setItem(At.LOCAL_STORAGE_COLLAB,JSON.stringify({username:e}))}catch(t){console.error(t)}},pA=()=>{try{const e=localStorage.getItem(At.LOCAL_STORAGE_COLLAB);if(e)return JSON.parse(e).username}catch(e){console.error(e)}return null},Dy=()=>{let e=null,t=null;try{e=localStorage.getItem(At.LOCAL_STORAGE_ELEMENTS),t=localStorage.getItem(At.LOCAL_STORAGE_APP_STATE)}catch(i){console.error(i)}let n=[];if(e)try{n=UT(JSON.parse(e))}catch(i){console.error(i)}let r=null;if(t)try{r={...qr(),...YS(JSON.parse(t))}}catch(i){console.error(i)}return{elements:n,appState:r}},yA=()=>{try{const e=localStorage.getItem(At.LOCAL_STORAGE_ELEMENTS);return(e==null?void 0:e.length)||0}catch(e){return console.error(e),0}},rJ=()=>{try{const e=localStorage.getItem(At.LOCAL_STORAGE_APP_STATE),t=localStorage.getItem(At.LOCAL_STORAGE_COLLAB),n=(e==null?void 0:e.length)||0,r=(t==null?void 0:t.length)||0;return n+r+yA()}catch(e){return console.error(e),0}};class iJ{constructor(t){M(this,"collab");M(this,"socket",null);M(this,"socketInitialized",!1);M(this,"roomId",null);M(this,"roomKey",null);M(this,"broadcastedElementVersions",new Map);M(this,"queueFileUpload",Qs(async()=>{try{await this.collab.fileManager.saveFiles({elements:this.collab.excalidrawAPI.getSceneElementsIncludingDeleted(),files:this.collab.excalidrawAPI.getFiles()})}catch(t){t.name!=="AbortError"&&this.collab.excalidrawAPI.updateScene({appState:{errorMessage:t.message}})}this.collab.excalidrawAPI.updateScene({elements:this.collab.excalidrawAPI.getSceneElementsIncludingDeleted().map(t=>this.collab.fileManager.shouldUpdateImageElementStatus(t)?ge(t,{status:"saved"}):t)})},DQ));M(this,"broadcastScene",async(t,n,r)=>{if(t===wn.INIT&&!r)throw new Error("syncAll must be true when sending SCENE.INIT");const i=n.reduce((s,a,l,c)=>{var u;return(r||!this.broadcastedElementVersions.has(a.id)||a.version>this.broadcastedElementVersions.get(a.id))&&mA(a)&&s.push({...a,[Do]:l===0?"^":(u=c[l-1])==null?void 0:u.id}),s},[]),o={type:t,payload:{elements:i}};for(const s of i)this.broadcastedElementVersions.set(s.id,s.version);this.queueFileUpload(),await this._broadcastSocketData(o)});M(this,"broadcastIdleChange",t=>{var n;if((n=this.socket)!=null&&n.id){const r={type:wn.IDLE_STATUS,payload:{socketId:this.socket.id,userState:t,username:this.collab.state.username}};return this._broadcastSocketData(r,!0)}});M(this,"broadcastMouseLocation",t=>{var n;if((n=this.socket)!=null&&n.id){const r={type:wn.MOUSE_LOCATION,payload:{socketId:this.socket.id,pointer:t.pointer,button:t.button||"up",selectedElementIds:this.collab.excalidrawAPI.getAppState().selectedElementIds,username:this.collab.state.username}};return this._broadcastSocketData(r,!0)}});M(this,"broadcastVisibleSceneBounds",(t,n)=>{var r;if((r=this.socket)!=null&&r.id){const i={type:wn.USER_VISIBLE_SCENE_BOUNDS,payload:{socketId:this.socket.id,username:this.collab.state.username,sceneBounds:t.sceneBounds}};return this._broadcastSocketData(i,!0,n)}});M(this,"broadcastUserFollowed",t=>{var n;(n=this.socket)!=null&&n.id&&this.socket.emit(qf.USER_FOLLOW_CHANGE,t)});this.collab=t}open(t,n,r){return this.socket=t,this.roomId=n,this.roomKey=r,this.socket.on("init-room",()=>{this.socket&&(this.socket.emit("join-room",this.roomId),Ae("share","room joined"))}),this.socket.on("new-user",async i=>{this.broadcastScene(wn.INIT,this.collab.getSceneElementsIncludingDeleted(),!0)}),this.socket.on("room-user-change",i=>{this.collab.setCollaborators(i)}),t}close(){this.socket&&(this.queueFileUpload.flush(),this.socket.close(),this.socket=null,this.roomId=null,this.roomKey=null,this.socketInitialized=!1,this.broadcastedElementVersions=new Map)}isOpen(){return!!(this.socketInitialized&&this.socket&&this.roomId&&this.roomKey)}async _broadcastSocketData(t,n=!1,r){var i;if(this.isOpen()){const o=JSON.stringify(t),s=new TextEncoder().encode(o),{encryptedBuffer:a,iv:l}=await ig(this.roomKey,s);(i=this.socket)==null||i.emit(n?qf.SERVER_VOLATILE:qf.SERVER,r??this.roomId,a,l)}}}const m1={[At.VERSION_DATA_STATE]:-1,[At.VERSION_FILES]:-1},f5=e=>JSON.parse(localStorage.getItem(e)||"-1")>m1[e],vA=e=>{const t=Date.now();try{localStorage.setItem(e,JSON.stringify(t)),m1[e]=t}catch(n){console.error("error while updating browser state verison",n)}},oJ=()=>{try{for(const e of Object.keys(m1))localStorage.setItem(e,JSON.stringify(-1)),m1[e]=-1}catch(e){console.error("error while resetting browser state verison",e)}};function sJ(){var e=!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent);if(!e||!indexedDB.databases)return Promise.resolve();var t;return new Promise(function(n){var r=function(){return indexedDB.databases().finally(n)};t=setInterval(r,100),r()}).finally(function(){return clearInterval(t)})}function Ba(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function fh(e,t){const n=sJ().then(()=>{const r=indexedDB.open(e);return r.onupgradeneeded=()=>r.result.createObjectStore(t),Ba(r)});return(r,i)=>n.then(o=>i(o.transaction(t,r).objectStore(t)))}let v0;function Sc(){return v0||(v0=fh("keyval-store","keyval")),v0}function Oy(e,t=Sc()){return t("readonly",n=>Ba(n.get(e)))}function El(e,t,n=Sc()){return n("readwrite",r=>(r.put(t,e),Ba(r.transaction)))}function aJ(e,t=Sc()){return t("readwrite",n=>(e.forEach(r=>n.put(r[1],r[0])),Ba(n.transaction)))}function lJ(e,t=Sc()){return t("readonly",n=>Promise.all(e.map(r=>Ba(n.get(r)))))}function Ny(e,t=Sc()){return t("readwrite",n=>(n.delete(e),Ba(n.transaction)))}function cJ(e,t){return e("readonly",n=>(n.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},Ba(n.transaction)))}function EA(e=Sc()){const t=[];return cJ(e,n=>t.push([n.key,n.value])).then(()=>t)}class uJ{constructor(){M(this,"locks",new Map);M(this,"lock",t=>{this.locks.set(t,!0)});M(this,"unlock",t=>(this.locks.delete(t),!this.isLocked()))}isLocked(t){return t?this.locks.has(t):!!this.locks.size}}const Vu=fh("files-db","files-store");class dJ extends aA{constructor(){super(...arguments);M(this,"clearObsoleteFiles",async n=>{await EA(Vu).then(r=>{for(const[i,o]of r)(!o.lastRetrieved||Date.now()-o.lastRetrieved>24*3600*1e3)&&!n.currentFileIds.includes(i)&&Ny(i,Vu)})})}}const hJ=(e,t)=>{try{localStorage.setItem(At.LOCAL_STORAGE_ELEMENTS,JSON.stringify(UT(e))),localStorage.setItem(At.LOCAL_STORAGE_APP_STATE,JSON.stringify(YS(t))),vA(At.VERSION_DATA_STATE)}catch(n){console.error(n)}},Gt=class Gt{};M(Gt,"_save",fa(async(t,n,r,i)=>{hJ(t,n),await Gt.fileStorage.saveFiles({elements:t,files:r}),i()},PQ)),M(Gt,"save",(t,n,r,i)=>{Gt.isSavePaused()||Gt._save(t,n,r,i)}),M(Gt,"flushSave",()=>{Gt._save.flush()}),M(Gt,"locker",new uJ),M(Gt,"pauseSave",t=>{Gt.locker.lock(t)}),M(Gt,"resumeSave",t=>{Gt.locker.unlock(t)}),M(Gt,"isSavePaused",()=>document.hidden||Gt.locker.isLocked()),M(Gt,"fileStorage",new dJ({getFiles(t){return lJ(t,Vu).then(async n=>{const r=[],i=new Map,o=[];n.forEach((s,a)=>{const l=t[a];if(s){const c={...s,lastRetrieved:Date.now()};o.push([l,c]),r.push(c)}else i.set(l,!0)});try{aJ(o,Vu)}catch(s){console.warn(s)}return{loadedFiles:r,erroredFiles:i}})},async saveFiles({addedFiles:t}){const n=new Map,r=new Map;return vA(At.VERSION_FILES),await Promise.all([...t].map(async([i,o])=>{try{await El(i,o,Vu),n.set(i,!0)}catch(s){console.error(s),r.set(i,!0)}})),{savedFiles:n,erroredFiles:r}}}));let an=Gt;const Rr=class Rr{static async load(){return await Oy(Rr.key,Rr.store)||null}static save(t){return El(Rr.key,t,Rr.store)}};M(Rr,"idb_name",At.IDB_LIBRARY),M(Rr,"key","libraryData"),M(Rr,"store",fh(`${Rr.idb_name}-db`,`${Rr.idb_name}-store`));let g1=Rr;class fJ{static load(){const t=localStorage.getItem(At.__LEGACY_LOCAL_STORAGE_LIBRARY);if(t!=null){const n=JSON.parse(t);if(n)return{libraryItems:n}}return null}static clear(){localStorage.removeItem(At.__LEGACY_LOCAL_STORAGE_LIBRARY)}}const Ww=mt(null),wA="excalidraw-storage-config-type",bA="excalidraw-storage-config-credentials",mJ=()=>{const e={type:"default"};try{const t=localStorage.getItem(wA),n=sessionStorage.getItem(bA),r=t?JSON.parse(t):{},i=n?JSON.parse(n):{};return{...e,...r,...i}}catch(t){return console.error("Failed to load storage config",t),e}},m5=mt(mJ()),_A=mt(e=>e(m5),(e,t,n)=>{const{type:r,kvAccountId:i,kvNamespaceId:o,kvApiToken:s,s3AccessKeyId:a,s3SecretAccessKey:l,s3Region:c,s3BucketName:u}=n,d={type:r},h={kvAccountId:i,kvNamespaceId:o,kvApiToken:s,s3AccessKeyId:a,s3SecretAccessKey:l,s3Region:c,s3BucketName:u};try{localStorage.setItem(wA,JSON.stringify(d)),sessionStorage.setItem(bA,JSON.stringify(h))}catch(m){console.error("Failed to save storage config",m)}t(m5,n)}),vo=_i,Fy=mt({message:null,nonce:0}),xA=({collabError:e})=>{const[t,n]=_.useState(!1),r=_.useRef();return _.useEffect(()=>(n(!0),r.current=setTimeout(()=>{n(!1)},1e3),()=>{clearTimeout(r.current)}),[e.message,e.nonce]),e.message?f(ro,{label:e.message,long:!0,children:f("div",{className:se("collab-errors-button",{"collab-errors-button-shake":t}),children:zH})}):null};xA.displayName="CollabError";const SA=mt(null),$y=mt(!1),kA=mt(!1),IA=mt(null);class gJ extends _.PureComponent{constructor(n){super(n);M(this,"portal");M(this,"fileManager");M(this,"excalidrawAPI");M(this,"activeIntervalId");M(this,"idleTimeoutId");M(this,"socketInitializationTimer");M(this,"lastBroadcastedOrReceivedSceneVersion",-1);M(this,"collaborators",new Map);M(this,"onUmmount",null);M(this,"onOfflineStatusToggle",()=>{vo.set(kA,!window.navigator.onLine)});M(this,"isCollaborating",()=>vo.get($y));M(this,"setIsCollaborating",n=>{vo.set($y,n)});M(this,"onUnload",()=>{this.destroySocketClient({isUnload:!0})});M(this,"beforeUnload",Je(n=>{const r=ea(this.getSceneElementsIncludingDeleted());this.isCollaborating()&&(this.fileManager.shouldPreventUnload(r)||!hA(this.portal,r))&&(this.saveCollabRoomToFirebase(r),Xv(n))}));M(this,"saveCollabRoomToFirebase",async n=>{try{const r=await GQ(this.portal,n,this.excalidrawAPI.getAppState());this.resetErrorIndicator(),this.isCollaborating()&&r&&r.reconciledElements&&this.handleRemoteSceneUpdate(this.reconcileElements(r.reconciledElements))}catch(r){const i=/is longer than.*?bytes/.test(r.message)?b("errors.collabSaveFailed_sizeExceeded"):b("errors.collabSaveFailed");(!this.state.dialogNotifiedErrors[i]||!this.isCollaborating())&&(this.setErrorDialog(i),this.setState({dialogNotifiedErrors:{...this.state.dialogNotifiedErrors,[i]:!0}})),this.isCollaborating()&&this.setErrorIndicator(i),console.error(r)}});M(this,"stopCollaboration",(n=!0)=>{if(this.queueBroadcastAllElements.cancel(),this.queueSaveToFirebase.cancel(),this.loadImageFiles.cancel(),this.resetErrorIndicator(!0),this.saveCollabRoomToFirebase(ea(this.excalidrawAPI.getSceneElementsIncludingDeleted())),this.portal.socket&&this.fallbackInitializationHandler&&this.portal.socket.off("connect_error",this.fallbackInitializationHandler),!n)an.fileStorage.reset(),this.destroySocketClient();else if(window.confirm(b("alerts.collabStopOverridePrompt"))){oJ(),window.history.pushState({},Vi,window.location.origin),this.destroySocketClient(),an.fileStorage.reset();const r=this.excalidrawAPI.getSceneElementsIncludingDeleted().map(i=>Gi(i)&&i.status==="saved"?ge(i,{status:"pending"}):i);this.excalidrawAPI.updateScene({elements:r,commitToHistory:!1})}});M(this,"destroySocketClient",n=>{this.lastBroadcastedOrReceivedSceneVersion=-1,this.portal.close(),this.fileManager.reset(),n!=null&&n.isUnload||(this.setIsCollaborating(!1),this.setActiveRoomLink(null),this.collaborators=new Map,this.excalidrawAPI.updateScene({collaborators:this.collaborators}),an.resumeSave("collaboration"))});M(this,"fetchImageFilesFromFirebase",async n=>{const r=n.elements.filter(i=>Ft(i)&&!this.fileManager.isFileHandled(i.fileId)&&!i.isDeleted&&(n.forceFetchFiles?i.status!=="pending"||Date.now()-i.updated>1e4:i.status==="saved")).map(i=>i.fileId);return await this.fileManager.getFiles(r)});M(this,"decryptPayload",async(n,r,i)=>{try{const o=await Td(n,r,i),s=new TextDecoder("utf-8").decode(new Uint8Array(o));return JSON.parse(s)}catch(o){return window.alert(b("alerts.decryptFailed")),console.error(o),{type:wn.INVALID_RESPONSE}}});M(this,"fallbackInitializationHandler",null);M(this,"startCollaboration",async n=>{if(this.state.username||ie(()=>import("./random-username.esm-K7eb4aAo.js"),__vite__mapDeps([])).then(({getRandomUsername:l})=>{const c=l();this.setUsername(c)}),this.portal.socket)return null;let r,i;n?{roomId:r,roomKey:i}=n:({roomId:r,roomKey:i}=await qQ(),window.history.pushState({},Vi,QQ({roomId:r,roomKey:i})));const o=$1();this.setIsCollaborating(!0),an.pauseSave("collaboration");const{default:s}=await ie(()=>import("./index-5Jz4PfUi.js"),__vite__mapDeps([])),a=()=>{this.initializeRoom({roomLinkData:n,fetchScene:!0}).then(l=>{o.resolve(l)})};this.fallbackInitializationHandler=a;try{this.portal.socket=this.portal.open(s("https://oss-collab.excalidraw.com",{transports:["websocket","polling"]}),r,i),this.portal.socket.once("connect_error",a)}catch(l){return console.error(l),this.setErrorDialog(l.message),null}if(!n){const l=this.excalidrawAPI.getSceneElements().map(c=>Gi(c)&&c.status==="saved"?ge(c,{status:"pending"}):c);this.excalidrawAPI.history.clear(),this.excalidrawAPI.updateScene({elements:l,commitToHistory:!0}),this.saveCollabRoomToFirebase(ea(l))}return this.socketInitializationTimer=window.setTimeout(a,RQ),this.portal.socket.on("client-broadcast",async(l,c)=>{var d;if(!this.portal.roomKey)return;const u=await this.decryptPayload(c,l,this.portal.roomKey);switch(u.type){case wn.INVALID_RESPONSE:return;case wn.INIT:{if(!this.portal.socketInitialized){this.initializeRoom({fetchScene:!1});const h=u.payload.elements,m=this.reconcileElements(h);this.handleRemoteSceneUpdate(m,{init:!0}),o.resolve({elements:m,scrollToContent:!0})}break}case wn.UPDATE:this.handleRemoteSceneUpdate(this.reconcileElements(u.payload.elements));break;case wn.MOUSE_LOCATION:{const{pointer:h,button:m,username:g,selectedElementIds:p}=u.payload,v=u.payload.socketId||u.payload.socketID;this.updateCollaborator(v,{pointer:h,button:m,selectedElementIds:p,username:g});break}case wn.USER_VISIBLE_SCENE_BOUNDS:{const{sceneBounds:h,socketId:m}=u.payload,g=this.excalidrawAPI.getAppState();if(((d=g.userToFollow)==null?void 0:d.socketId)!==m){console.warn(`receiving remote client's (from ${m}) viewport bounds even though we're not subscribed to it!`);return}if(g.userToFollow&&g.followedBy.has(g.userToFollow.socketId))return;this.excalidrawAPI.updateScene({appState:W8({appState:g,bounds:h,fitToViewport:!0,viewportZoomFactor:1}).appState});break}case wn.IDLE_STATUS:{const{userState:h,socketId:m,username:g}=u.payload;this.updateCollaborator(m,{userState:h,username:g});break}default:jl(u,null)}}),this.portal.socket.on("first-in-room",async()=>{this.portal.socket&&this.portal.socket.off("first-in-room");const l=await this.initializeRoom({fetchScene:!0,roomLinkData:n});o.resolve(l)}),this.portal.socket.on(qf.USER_FOLLOW_ROOM_CHANGE,l=>{this.excalidrawAPI.updateScene({appState:{followedBy:new Set(l)}}),this.relayVisibleSceneBounds({force:!0})}),this.initializeIdleDetector(),this.setActiveRoomLink(window.location.href),o});M(this,"initializeRoom",async({fetchScene:n,roomLinkData:r})=>{if(clearTimeout(this.socketInitializationTimer),this.portal.socket&&this.fallbackInitializationHandler&&this.portal.socket.off("connect_error",this.fallbackInitializationHandler),n&&r&&this.portal.socket){this.excalidrawAPI.resetScene();try{const i=await jQ(r.roomId,r.roomKey,this.portal.socket);if(i)return this.setLastBroadcastedOrReceivedSceneVersion(To(i)),{elements:i,scrollToContent:!0}}catch(i){console.error(i)}finally{this.portal.socketInitialized=!0}}else this.portal.socketInitialized=!0;return null});M(this,"reconcileElements",n=>{const r=this.getSceneElementsIncludingDeleted(),i=this.excalidrawAPI.getAppState();n=nh(n,null);const o=Hw(r,n,i);return this.setLastBroadcastedOrReceivedSceneVersion(To(o)),o});M(this,"loadImageFiles",Qs(async()=>{const{loadedFiles:n,erroredFiles:r}=await this.fetchImageFilesFromFirebase({elements:this.excalidrawAPI.getSceneElementsIncludingDeleted()});this.excalidrawAPI.addFiles(n),yu({excalidrawAPI:this.excalidrawAPI,erroredFiles:r,elements:this.excalidrawAPI.getSceneElementsIncludingDeleted()})},OQ));M(this,"handleRemoteSceneUpdate",(n,{init:r=!1}={})=>{this.excalidrawAPI.updateScene({elements:n,commitToHistory:!!r}),this.excalidrawAPI.history.clear(),this.loadImageFiles()});M(this,"onPointerMove",()=>{this.idleTimeoutId&&(window.clearTimeout(this.idleTimeoutId),this.idleTimeoutId=null),this.idleTimeoutId=window.setTimeout(this.reportIdle,ab),this.activeIntervalId||(this.activeIntervalId=window.setInterval(this.reportActive,lb))});M(this,"onVisibilityChange",()=>{document.hidden?(this.idleTimeoutId&&(window.clearTimeout(this.idleTimeoutId),this.idleTimeoutId=null),this.activeIntervalId&&(window.clearInterval(this.activeIntervalId),this.activeIntervalId=null),this.onIdleStateChange(qs.AWAY)):(this.idleTimeoutId=window.setTimeout(this.reportIdle,ab),this.activeIntervalId=window.setInterval(this.reportActive,lb),this.onIdleStateChange(qs.ACTIVE))});M(this,"reportIdle",()=>{this.onIdleStateChange(qs.IDLE),this.activeIntervalId&&(window.clearInterval(this.activeIntervalId),this.activeIntervalId=null)});M(this,"reportActive",()=>{this.onIdleStateChange(qs.ACTIVE)});M(this,"initializeIdleDetector",()=>{document.addEventListener(Z.POINTER_MOVE,this.onPointerMove),document.addEventListener(Z.VISIBILITY_CHANGE,this.onVisibilityChange)});M(this,"updateCollaborator",(n,r)=>{var s;const i=new Map(this.collaborators),o=Object.assign({},i.get(n),r,{isCurrentUser:n===((s=this.portal.socket)==null?void 0:s.id)});i.set(n,o),this.collaborators=i,this.excalidrawAPI.updateScene({collaborators:i})});M(this,"setLastBroadcastedOrReceivedSceneVersion",n=>{this.lastBroadcastedOrReceivedSceneVersion=n});M(this,"getLastBroadcastedOrReceivedSceneVersion",()=>this.lastBroadcastedOrReceivedSceneVersion);M(this,"getSceneElementsIncludingDeleted",()=>this.excalidrawAPI.getSceneElementsIncludingDeleted());M(this,"onPointerUpdate",Qs(n=>{n.pointersMap.size<2&&this.portal.socket&&this.portal.broadcastMouseLocation(n)},FQ));M(this,"relayVisibleSceneBounds",n=>{const r=this.excalidrawAPI.getAppState();this.portal.socket&&(r.followedBy.size>0||n!=null&&n.force)&&this.portal.broadcastVisibleSceneBounds({sceneBounds:pN(r)},`follow@${this.portal.socket.id}`)});M(this,"onIdleStateChange",n=>{this.portal.broadcastIdleChange(n)});M(this,"broadcastElements",n=>{To(n)>this.getLastBroadcastedOrReceivedSceneVersion()&&(this.portal.broadcastScene(wn.UPDATE,n,!1),this.lastBroadcastedOrReceivedSceneVersion=To(n),this.queueBroadcastAllElements())});M(this,"syncElements",n=>{this.broadcastElements(n),this.queueSaveToFirebase()});M(this,"queueBroadcastAllElements",Qs(()=>{this.portal.broadcastScene(wn.UPDATE,this.excalidrawAPI.getSceneElementsIncludingDeleted(),!0);const n=this.getLastBroadcastedOrReceivedSceneVersion(),r=Math.max(n,To(this.getSceneElementsIncludingDeleted()));this.setLastBroadcastedOrReceivedSceneVersion(r)},l5));M(this,"queueSaveToFirebase",Qs(()=>{this.portal.socketInitialized&&this.saveCollabRoomToFirebase(ea(this.excalidrawAPI.getSceneElementsIncludingDeleted()))},l5,{leading:!1}));M(this,"setUsername",n=>{this.setState({username:n}),nJ(n)});M(this,"getUsername",()=>this.state.username);M(this,"setActiveRoomLink",n=>{this.setState({activeRoomLink:n}),vo.set(IA,n)});M(this,"getActiveRoomLink",()=>this.state.activeRoomLink);M(this,"setErrorIndicator",n=>{vo.set(Fy,{message:n,nonce:Date.now()})});M(this,"resetErrorIndicator",(n=!1)=>{vo.set(Fy,{message:null,nonce:0}),n&&this.setState({dialogNotifiedErrors:{}})});M(this,"setErrorDialog",n=>{this.setState({errorMessage:n})});this.state={errorMessage:null,dialogNotifiedErrors:{},username:pA()||"",activeRoomLink:null},this.portal=new iJ(this),this.fileManager=new aA({getFiles:async r=>{const{roomId:i,roomKey:o}=this.portal;if(!i||!o)throw new ql;return fA(`files/rooms/${i}`,o,r)},saveFiles:async({addedFiles:r})=>{const{roomId:i,roomKey:o}=this.portal;if(!i||!o)throw new ql;return Uw({prefix:`${sA.collabFiles}/${i}`,files:await zw({files:r,encryptionKey:o,maxBytes:$w})})}}),this.excalidrawAPI=n.excalidrawAPI,this.activeIntervalId=null,this.idleTimeoutId=null}componentDidMount(){window.addEventListener(Z.BEFORE_UNLOAD,this.beforeUnload),window.addEventListener("online",this.onOfflineStatusToggle),window.addEventListener("offline",this.onOfflineStatusToggle),window.addEventListener(Z.UNLOAD,this.onUnload);const n=this.excalidrawAPI.onUserFollow(s=>{this.portal.socket&&this.portal.broadcastUserFollowed(s)}),r=F1(this.relayVisibleSceneBounds),i=this.excalidrawAPI.onScrollChange(()=>r());this.onUmmount=()=>{n(),i()},this.onOfflineStatusToggle();const o={isCollaborating:this.isCollaborating,onPointerUpdate:this.onPointerUpdate,startCollaboration:this.startCollaboration,syncElements:this.syncElements,fetchImageFilesFromFirebase:this.fetchImageFilesFromFirebase,stopCollaboration:this.stopCollaboration,setUsername:this.setUsername,getUsername:this.getUsername,getActiveRoomLink:this.getActiveRoomLink,setCollabError:this.setErrorDialog};vo.set(SA,o)}componentWillUnmount(){var n;window.removeEventListener("online",this.onOfflineStatusToggle),window.removeEventListener("offline",this.onOfflineStatusToggle),window.removeEventListener(Z.BEFORE_UNLOAD,this.beforeUnload),window.removeEventListener(Z.UNLOAD,this.onUnload),window.removeEventListener(Z.POINTER_MOVE,this.onPointerMove),window.removeEventListener(Z.VISIBILITY_CHANGE,this.onVisibilityChange),this.activeIntervalId&&(window.clearInterval(this.activeIntervalId),this.activeIntervalId=null),this.idleTimeoutId&&(window.clearTimeout(this.idleTimeoutId),this.idleTimeoutId=null),(n=this.onUmmount)==null||n.call(this)}setCollaborators(n){var i;const r=new Map;for(const o of n)r.set(o,Object.assign({},this.collaborators.get(o),{isCurrentUser:o===((i=this.portal.socket)==null?void 0:i.id)}));this.collaborators=r,this.excalidrawAPI.updateScene({collaborators:r})}render(){const{errorMessage:n}=this.state;return f(re,{children:n!=null&&f(Cw,{onClose:()=>this.setErrorDialog(null),children:n})})}}const pJ=500,g5=fa(e=>{e({scene:yA(),total:rJ()})},pJ),yJ=e=>{const[t,n]=_.useState({scene:0,total:0});_.useEffect(()=>{g5(s=>{n(s)})},[e.elements,e.appState]),_.useEffect(()=>()=>g5.cancel(),[]);const r=x2();let i,o;return r!==HS?(o=r.slice(0,16).replace("T"," "),i=r.slice(21)):o=b("stats.versionNotAvailable"),k(re,{children:[f("tr",{children:f("th",{colSpan:2,children:b("stats.storage")})}),k("tr",{children:[f("td",{children:b("stats.scene")}),f("td",{children:xb(t.scene,1)})]}),k("tr",{children:[f("td",{children:b("stats.total")}),f("td",{children:xb(t.total,1)})]}),f("tr",{children:f("th",{colSpan:2,children:b("stats.version")})}),f("tr",{children:k("td",{colSpan:2,style:{textAlign:"center",cursor:"pointer"},onClick:async()=>{try{await Fa(x2()),e.setToast(b("toast.copyToClipboard"))}catch{}},title:b("stats.versionCopy"),children:[o,f("br",{}),i]})})]})};let vJ=(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),"");const CA=async(e,t,n,r)=>{const i=await uA(),o=`${vJ(12)}`,s=await TE(),a=await ig(s,hc(e,t,n,"database")),l=new Blob([a.iv,new Uint8Array(a.encryptedBuffer)],{type:de.binary});await i.storage().ref(`/migrations/scenes/${o}`).put(l,{customMetadata:{data:JSON.stringify({version:2,name:r}),created:Date.now().toString()}});const c=new Map;for(const u of e)Ft(u)&&n[u.fileId]&&c.set(u.fileId,n[u.fileId]);if(c.size){const u=await zw({files:c,encryptionKey:s,maxBytes:$w});await Uw({prefix:`/migrations/files/scenes/${o}`,files:u})}window.open(`https://app.excalidraw.com/import?excalidraw=${o},${s}`)},EJ=({elements:e,appState:t,files:n,name:r,onError:i,onSuccess:o})=>{const{t:s}=xt();return k(Ey,{color:"primary",children:[f("div",{className:"Card-icon",children:f(gM,{style:{"--color-logo-icon":"#fff",width:"2.8rem",height:"2.8rem"}})}),f("h2",{children:"Excalidraw+"}),f("div",{className:"Card-details",children:s("exportDialog.excalidrawplus_description")}),f(Ce,{className:"Card-button",type:"button",title:s("exportDialog.excalidrawplus_button"),"aria-label":s("exportDialog.excalidrawplus_button"),showAriaLabel:!0,onClick:async()=>{try{Ae("export","eplus",`ui (${Zd()})`),await CA(e,t,n,r),o()}catch(a){console.error(a),a.name!=="AbortError"&&i(new Error(s("exportDialog.excalidrawplus_exportError")))}}})]})},wJ=({style:e})=>{const{t,langCode:n}=xt(),r=lc(AA);return f("select",{className:"dropdown-select dropdown-select__language",onChange:({target:i})=>r(i.value),value:n,"aria-label":t("buttons.selectLanguage"),style:e,children:Gv.map(i=>f("option",{value:i.code,children:i.label},i.code))})},bJ=te.memo(e=>{const[t,n]=ze(Ww),r=()=>{window.location.href="/auth/github/login"},i=()=>{localStorage.removeItem("token"),n(null),window.location.reload()};return k(Ne,{children:[f(Ne.DefaultItems.LoadScene,{}),f(Ne.DefaultItems.SaveToActiveFile,{}),f(Ne.DefaultItems.Export,{}),f(Ne.DefaultItems.SaveAsImage,{}),e.isCollabEnabled&&f(Ne.DefaultItems.LiveCollaborationTrigger,{isCollaborating:e.isCollaborating,onSelect:()=>e.onCollabDialogOpen()}),f(Ne.DefaultItems.Help,{}),f(Ne.DefaultItems.ClearCanvas,{}),f(Ne.Separator,{}),f(Ne.Item,{onSelect:e.onStorageSettingsClick,children:"Data Source Settings..."}),f(Ne.Separator,{}),t?k("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0 0.5rem",minWidth:"150px"},children:[f("img",{src:t.avatarUrl,alt:t.login,style:{width:"24px",height:"24px",borderRadius:"50%"}}),f("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name||t.login}),f(Ne.Item,{onSelect:i,children:"Logout"})]}):f(Ne.Item,{onSelect:r,children:"Login with GitHub"}),f(Ne.Separator,{}),f(Ne.DefaultItems.Socials,{}),f(Ne.Separator,{}),f(Ne.DefaultItems.ToggleTheme,{}),f(Ne.ItemCustom,{children:f(wJ,{style:{width:"100%"}})}),f(Ne.DefaultItems.ChangeCanvasBackground,{})]})}),_J=te.memo(e=>{const{t}=xt(),[n]=ze(Ww);let r;return Bw?r=t("welcomeScreen.app.center_heading_plus").split(/(Excalidraw\+)/).map((i,o)=>i==="Excalidraw+"?f("a",{style:{pointerEvents:Ms.inheritFromUI},href:"https://app.excalidraw.com?utm_source=excalidraw&utm_medium=app&utm_content=welcomeScreenSignedInUser",children:"Excalidraw+"},o):i):r=t("welcomeScreen.app.center_heading"),k(yn,{children:[f(yn.Hints.MenuHint,{children:t("welcomeScreen.app.menuHint")}),f(yn.Hints.ToolbarHint,{}),f(yn.Hints.HelpHint,{}),k(yn.Center,{children:[f(yn.Center.Logo,{}),f(yn.Center.Heading,{children:r}),k(yn.Center.Menu,{children:[f(yn.Center.MenuItemLoadScene,{}),f(yn.Center.MenuItemHelp,{}),e.isCollabEnabled&&f(yn.Center.MenuItemLiveCollaborationTrigger,{onSelect:()=>e.onCollabDialogOpen()}),!n&&f(yn.Center.MenuItem,{onSelect:()=>{window.location.href="/auth/github/login"},icon:KT,children:"Login with GitHub"})]})]})]})}),xJ=()=>{const{t:e}=xt();return f("a",{className:"encrypted-icon tooltip",href:"https://blog.excalidraw.com/end-to-end-encryption/",target:"_blank",rel:"noopener noreferrer","aria-label":e("encrypted.link"),children:f(ro,{label:e("encrypted.tooltip"),long:!0,children:nU})})},SJ=()=>Bw?f("a",{href:"https://app.excalidraw.com?utm_source=excalidraw&utm_medium=app&utm_content=signedInUserRedirectButton#excalidraw-redirect",target:"_blank",rel:"noreferrer",className:"plus-button",children:"Go to Excalidraw+"}):null,kJ=te.memo(()=>f(mM,{children:f("div",{style:{display:"flex",gap:".5rem",alignItems:"center"},children:Bw?f(SJ,{}):f(xJ,{})})}));class vu extends Error{}vu.prototype.name="InvalidTokenError";function IJ(e){return decodeURIComponent(atob(e).replace(/(.)/g,(t,n)=>{let r=n.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}function CJ(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return IJ(t)}catch{return atob(t)}}function TJ(e,t){if(typeof e!="string")throw new vu("Invalid token specified: must be a string");t||(t={});const n=t.header===!0?0:1,r=e.split(".")[n];if(typeof r!="string")throw new vu(`Invalid token specified: missing part #${n+1}`);let i;try{i=CJ(r)}catch(o){throw new vu(`Invalid token specified: invalid base64 for part #${n+1} (${o.message})`)}try{return JSON.parse(i)}catch(o){throw new vu(`Invalid token specified: invalid json for part #${n+1} (${o.message})`)}}const MJ=({link:e,onCloseRequest:t,setErrorMessage:n})=>{const{t:r}=xt(),[i,o]=_.useState(!1),s=_.useRef(0),a=_.useRef(null);return f(Vn,{onCloseRequest:t,title:!1,size:"small",children:k("div",{className:"ShareableLinkDialog",children:[f("h3",{children:"Shareable link"}),k("div",{className:"ShareableLinkDialog__linkRow",children:[f(Fr,{ref:a,label:"Link",readonly:!0,fullWidth:!0,value:e,selectOnRender:!0}),k(Eg,{open:i,children:[f(wg,{asChild:!0,children:f(zn,{size:"large",label:"Copy link",icon:hg,onClick:async()=>{var c;try{await Fa(e)}catch{n(r("errors.copyToSystemClipboardFailed"))}o(!0),s.current&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{o(!1)},3e3),(c=a.current)==null||c.select()}})}),k(bg,{onOpenAutoFocus:c=>c.preventDefault(),onCloseAutoFocus:c=>c.preventDefault(),className:"ShareableLinkDialog__popover",side:"top",align:"end",sideOffset:5.5,children:[qT," copied"]})]})]}),k("div",{className:"ShareableLinkDialog__description",children:["🔒 ",r("alerts.uploadedSecurly")]})]})})},TA=mt({isOpen:!1}),AJ=()=>{const e=window.navigator,t=/Apple/.test(e.vendor),n=e.appVersion.indexOf("Win")!==-1;return t?HH:n?UH:ZT},LJ=({collabAPI:e,activeRoomLink:t,handleClose:n})=>{const{t:r}=xt(),[i,o]=_.useState(!1),s=_.useRef(0),a=_.useRef(null),l="share"in navigator,c=async()=>{var d;try{await Fa(t)}catch{e.setCollabError(r("errors.copyToSystemClipboardFailed"))}o(!0),s.current&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{o(!1)},3e3),(d=a.current)==null||d.select()},u=async()=>{try{await navigator.share({title:r("roomDialog.shareTitle"),text:r("roomDialog.shareTitle"),url:t})}catch{}};return k(re,{children:[f("h3",{className:"ShareDialog__active__header",children:r("labels.liveCollaboration").replace(/\./g,"")}),f(Fr,{defaultValue:e.getUsername(),placeholder:"Your name",label:"Your name",onChange:e.setUsername,onKeyDown:d=>d.key===D.ENTER&&n()}),k("div",{className:"ShareDialog__active__linkRow",children:[f(Fr,{ref:a,label:"Link",readonly:!0,fullWidth:!0,value:t}),l&&f(zn,{size:"large",variant:"icon",label:"Share",icon:AJ(),className:"ShareDialog__active__share",onClick:u}),k(Eg,{open:i,children:[f(wg,{asChild:!0,children:f(zn,{size:"large",label:"Copy link",icon:hg,onClick:c})}),k(bg,{onOpenAutoFocus:d=>d.preventDefault(),onCloseAutoFocus:d=>d.preventDefault(),className:"ShareDialog__popover",side:"top",align:"end",sideOffset:5.5,children:[qT," copied"]})]})]}),k("div",{className:"ShareDialog__active__description",children:[k("p",{children:[k("span",{role:"img","aria-hidden":"true",className:"ShareDialog__active__description__emoji",children:["🔒"," "]}),r("roomDialog.desc_privacy")]}),f("p",{children:r("roomDialog.desc_exitSession")})]}),f("div",{className:"ShareDialog__active__actions",children:f(zn,{size:"large",variant:"outlined",color:"danger",label:r("roomDialog.button_stopSession"),icon:UU,onClick:()=>{Ae("share","room closed"),e.stopCollaboration(),e.isCollaborating()||n()}})})]})},PJ=e=>{const{t}=xt(),{collabAPI:n}=e,r=n?k(re,{children:[f("div",{className:"ShareDialog__picker__header",children:t("labels.liveCollaboration").replace(/\./g,"")}),k("div",{className:"ShareDialog__picker__description",children:[f("div",{style:{marginBottom:"1em"},children:t("roomDialog.desc_intro")}),t("roomDialog.desc_privacy")]}),f("div",{className:"ShareDialog__picker__button",children:f(zn,{size:"large",label:t("roomDialog.button_startSession"),icon:HU,onClick:()=>{Ae("share","room creation",`ui (${Zd()})`),n.startCollaboration(null)}})}),e.type==="share"&&f("div",{className:"ShareDialog__separator",children:f("span",{children:t("shareDialog.or")})})]}):null;return k(re,{children:[r,e.type==="share"&&k(re,{children:[f("div",{className:"ShareDialog__picker__header",children:t("exportDialog.link_title")}),f("div",{className:"ShareDialog__picker__description",children:t("exportDialog.link_details")}),f("div",{className:"ShareDialog__picker__button",children:f(zn,{size:"large",label:t("exportDialog.link_button"),icon:zE,onClick:async()=>{await e.onExportToBackend(),e.handleClose()}})})]})]})},RJ=e=>{const t=Gl(IA);return f(Vn,{size:"small",onCloseRequest:e.handleClose,title:!1,children:f("div",{className:"ShareDialog",children:e.collabAPI&&t?f(LJ,{collabAPI:e.collabAPI,activeRoomLink:t,handleClose:e.handleClose}):f(PJ,{...e})})})},DJ=e=>{const[t,n]=ze(TA);return t.isOpen?f(RJ,{handleClose:()=>n({isOpen:!1}),collabAPI:e.collabAPI,onExportToBackend:e.onExportToBackend,type:t.type}):null},OJ=({onClose:e})=>{const[t,n]=ze(_A),[r,i]=_.useState(t.type),[o,s]=_.useState(t.kvAccountId||""),[a,l]=_.useState(t.kvNamespaceId||""),[c,u]=_.useState(t.kvApiToken||""),[d,h]=_.useState(t.s3AccessKeyId||""),[m,g]=_.useState(t.s3SecretAccessKey||""),[p,v]=_.useState(t.s3Region||""),[y,E]=_.useState(t.s3BucketName||""),w=()=>{n({type:r,kvAccountId:o,kvNamespaceId:a,kvApiToken:c,s3AccessKeyId:d,s3SecretAccessKey:m,s3Region:p,s3BucketName:y}),e()};return f(Vn,{onCloseRequest:e,title:"Data Source Settings",className:"storage-settings-dialog",children:k("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[f("p",{children:"Security Warning: Sensitive keys are stored only in your browser's session storage and are cleared when you close the tab."}),k("select",{value:r,onChange:C=>i(C.target.value),style:{padding:"0.5rem",borderRadius:"var(--border-radius-lg)",border:"1px solid var(--color-border)"},children:[f("option",{value:"indexed-db",children:"Browser (IndexedDB)"}),f("option",{value:"default",children:"Default Backend (Online)"}),f("option",{value:"kv",children:"Cloudflare KV (Online)"}),f("option",{value:"s3",children:"Amazon S3 (Online)"})]}),f(Yr,{style:{padding:"1rem"},children:f("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:(()=>{switch(r){case"kv":return k(re,{children:[f(Fr,{label:"Account ID",value:o,placeholder:"Your Cloudflare Account ID",onChange:s}),f(Fr,{label:"Namespace ID",value:a,placeholder:"Your KV Namespace ID",onChange:l}),f(Fr,{label:"API Token",value:c,placeholder:"Your Cloudflare API Token",onChange:u})]});case"s3":return k(re,{children:[f(Fr,{label:"Access Key ID",value:d,placeholder:"Your AWS Access Key ID",onChange:h}),f(Fr,{label:"Secret Access Key",value:m,placeholder:"Your AWS Secret Access Key",onChange:g}),f(Fr,{label:"Region",value:p,placeholder:"e.g., us-east-1",onChange:v}),f(Fr,{label:"Bucket Name",value:y,placeholder:"Your S3 Bucket Name",onChange:E})]});case"indexed-db":return f("p",{children:"Your canvases are stored securely in your browser's local database. They are not synced online."});case"default":default:return f("p",{children:"Your data is stored on the default backend of this Excalidraw instance. This requires you to be logged in."})}})()})}),f("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem"},children:f(zn,{color:"primary",label:"Save",onClick:w})})]})})},tu="/api/v2/canvases",nu=()=>{const e=localStorage.getItem("token"),t={"Content-Type":"application/json"};return e&&(t.Authorization=`Bearer ${e}`),t};class NJ{async listCanvases(){const t=await fetch(tu,{method:"GET",headers:nu()});if(!t.ok){if(t.status===401||t.status===403)return[];throw new Error(`Failed to list canvases: ${t.statusText}`)}return t.json()}async loadCanvas(t){const n=await fetch(`${tu}/${t}`,{method:"GET",headers:nu()});if(n.status===404)return null;if(!n.ok)throw new Error(`Failed to load canvas: ${n.statusText}`);return n.json()}async saveCanvas(t,n){const r=await fetch(`${tu}/${t}`,{method:"PUT",headers:nu(),body:JSON.stringify(n)});if(!r.ok)throw new Error(`Failed to save canvas: ${r.statusText}`)}async createCanvas(t){const n=await fetch(tu,{method:"POST",headers:nu(),body:JSON.stringify(t)});if(!n.ok)throw new Error(`Failed to create canvas: ${n.statusText}`);return n.json()}async deleteCanvas(t){const n=await fetch(`${tu}/${t}`,{method:"DELETE",headers:nu()});if(!n.ok)throw new Error(`Failed to delete canvas: ${n.statusText}`)}}const ru=fh("excalidraw-canvases-metadata","metadata"),uf=fh("excalidraw-canvases-data","data");class FJ{async listCanvases(){return(await EA(ru)).map(([,n])=>n)}async loadCanvas(t){const n=await Oy(t,uf);return n===void 0?null:n}async saveCanvas(t,n){const r=await Oy(t,ru);if(!r)throw new Error("Canvas metadata not found. Cannot save.");const i={...r,name:n.appState.name||r.name,updatedAt:new Date().toISOString()};await El(t,i,ru),await El(t,n,uf)}async createCanvas(t){const n=window.crypto.randomUUID(),r=new Date().toISOString(),i={id:n,name:t.appState.name||"Untitled Canvas",createdAt:r,updatedAt:r,userId:0};return await El(n,i,ru),await El(n,t,uf),i}async deleteCanvas(t){await Ny(t,ru),await Ny(t,uf)}}const $J=({canvases:e,onCanvasSelect:t,onCanvasDelete:n,onCanvasCreate:r})=>k("div",{className:"my-creations-tab",children:[f("div",{style:{marginBottom:"1rem"},children:f(zn,{label:"Create New Canvas",onClick:r,fullWidth:!0,children:"Create New"})}),f("div",{className:"my-creations-tab__list",children:e.length===0?k("div",{className:"my-creations-tab__empty",children:[dg,f("p",{children:"You have no saved canvases yet."}),f("p",{children:"Create a new canvas to get started. It will be saved here in your browser."})]}):e.map(i=>k("div",{className:"my-creations-tab__item",onClick:()=>t(i.id),children:[f("span",{className:"my-creations-tab__item-name",children:i.name}),f("span",{className:"my-creations-tab__item-date",children:new Date(i.updatedAt).toLocaleDateString()}),f("button",{className:"my-creations-tab__item-delete",onClick:o=>{o.stopPropagation(),n(i.id)},children:"×"})]},i.id))})]});LS();window.EXCALIDRAW_THROTTLE_RENDER=!0;const E0="my-creations";let MA=!1;if(window.self!==window.top)try{const e=new URL(document.referrer),t=new URL(window.location.href);e.origin===t.origin&&(MA=!0)}catch{}const p1=new RS;p1.init({languageUtils:{}});const p5={title:b("overwriteConfirm.modal.shareableLink.title"),description:f(On,{i18nKey:"overwriteConfirm.modal.shareableLink.description",bold:e=>f("strong",{children:e}),br:()=>f("br",{})}),actionLabel:b("overwriteConfirm.modal.shareableLink.button"),color:"danger"},By=async e=>{var c,u;const n=new URLSearchParams(window.location.search).get("id"),r=window.location.hash.match(/^#json=([a-zA-Z0-9_-]+),([a-zA-Z0-9_-]+)$/),i=window.location.hash.match(/^#url=(.*)$/),o=Dy();let s=await h5(null,null,o),a=XQ(window.location.href);const l=!!(n||r||a);if(l)if(!s.elements.length||a||await by(p5))r&&(s=await h5(r[1],r[2],o)),s.scrollToContent=!0,a||window.history.replaceState({},Vi,window.location.origin);else{if(document.hidden)return new Promise((d,h)=>{window.addEventListener("focus",()=>By(e).then(d).catch(h),{once:!0})});a=null,window.history.replaceState({},Vi,window.location.origin)}else if(i){window.history.replaceState({},Vi,window.location.origin);const d=i[1];try{const h=await fetch(window.decodeURIComponent(d)),m=await gE(await h.blob(),null,null);if(!s.elements.length||await by(p5))return{scene:m,isExternalScene:l}}catch{return{scene:{appState:{errorMessage:b("alerts.invalidSceneUrl")}},isExternalScene:l}}}if(a&&e.collabAPI){const{excalidrawAPI:d}=e,h=await e.collabAPI.startCollaboration(a);return{scene:{...h,appState:{...ZI({...h==null?void 0:h.appState,theme:((c=o==null?void 0:o.appState)==null?void 0:c.theme)||((u=h==null?void 0:h.appState)==null?void 0:u.theme)},d.getAppState()),isLoading:!1},elements:Hw((h==null?void 0:h.elements)||[],d.getSceneElementsIncludingDeleted(),d.getAppState())},isExternalScene:!0,id:a.roomId,key:a.roomKey}}else if(s)return l&&r?{scene:s,isExternalScene:l,id:r[1],key:r[2]}:{scene:s,isExternalScene:!1};return{scene:null,isExternalScene:!1}},w0=p1.detect()||Es.code,AA=mt(Array.isArray(w0)?w0[0]:w0),BJ=()=>{const[e,t]=_.useState(""),[n,r]=ze(AA),[i,o]=ze(Ww),[s]=ze(_A),[a,l]=_.useState(!1),[c,u]=_.useState([]),d=AD(),h=_.useMemo(()=>s.type==="default"&&i?new NJ:new FJ,[s,i]),m=_.useRef({promise:null});m.current.promise||(m.current.promise=$1()),_.useEffect(()=>{Ae("load","frame",Zd()),setTimeout(()=>{Ae("load","version",x2())},dR)},[]);const[g,p]=Rk(),[,v]=ze(TA),[y]=ze(SA),[E]=HR($y,()=>d5(window.location.href)),w=Gl(Fy);Yj({excalidrawAPI:g,adapter:g1,migrationAdapter:fJ}),_.useEffect(()=>{const $=new URLSearchParams(window.location.search).get("token");$&&(localStorage.setItem("token",$),window.history.replaceState({},document.title,window.location.pathname));const Y=localStorage.getItem("token");if(Y)try{const R=TJ(Y);R.exp*1e3>Date.now()?o({id:R.userId,githubId:R.githubId,login:R.login,avatarUrl:R.avatarUrl,name:R.name}):localStorage.removeItem("token")}catch(R){console.error("Invalid token:",R),localStorage.removeItem("token")}},[o]);const x=_.useCallback(async()=>{try{const U=await h.listCanvases();u(U)}catch(U){console.error("Failed to fetch user canvases",U),t("Could not load your creations.")}},[h]);_.useEffect(()=>{var U;((U=g==null?void 0:g.getAppState().openSidebar)==null?void 0:U.tab)===E0&&x()},[g==null?void 0:g.getAppState().openSidebar,x]),_.useEffect(()=>{if(!g||!d&&!y)return;const U=(z,W=!1)=>{var j;if(z.scene)if(y!=null&&y.isCollaborating())z.scene.elements&&y.fetchImageFilesFromFirebase({elements:z.scene.elements,forceFetchFiles:!0}).then(({loadedFiles:X,erroredFiles:ee})=>{g.addFiles(X),yu({excalidrawAPI:g,erroredFiles:ee,elements:g.getSceneElementsIncludingDeleted()})});else{const X=((j=z.scene.elements)==null?void 0:j.reduce((ee,xe)=>Ft(xe)?ee.concat(xe.fileId):ee,[]))||[];z.isExternalScene?fA(`${sA.shareLinkFiles}/${z.id}`,z.key,X).then(({loadedFiles:ee,erroredFiles:xe})=>{g.addFiles(ee),yu({excalidrawAPI:g,erroredFiles:xe,elements:g.getSceneElementsIncludingDeleted()})}):W&&(X.length&&an.fileStorage.getFiles(X).then(({loadedFiles:ee,erroredFiles:xe})=>{ee.length&&g.addFiles(ee),yu({excalidrawAPI:g,erroredFiles:xe,elements:g.getSceneElementsIncludingDeleted()})}),an.fileStorage.clearObsoleteFiles({currentFileIds:X}))}};By({collabAPI:y,excalidrawAPI:g}).then(async z=>{U(z,!0),m.current.promise.resolve(z.scene)});const $=async z=>{z.preventDefault(),yy()||(y!=null&&y.isCollaborating()&&!d5(window.location.href)&&y.stopCollaboration(!1),g.updateScene({appState:{isLoading:!0}}),By({collabAPI:y,excalidrawAPI:g}).then(j=>{U(j),j.scene&&g.updateScene({...j.scene,..._a(j.scene,null,null,{repairBindings:!0}),commitToHistory:!0})}))},Y=setTimeout(()=>document.title=Vi,uR),R=fa(()=>{if(!document.hidden&&(y&&!y.isCollaborating()||d)){if(f5(At.VERSION_DATA_STATE)){const z=Dy(),W=pA();let j=p1.detect()||Es.code;Array.isArray(j)&&(j=j[0]),r(j),g.updateScene({...z}),g1.load().then(X=>{X&&g.updateLibrary({libraryItems:X.libraryItems})}),y==null||y.setUsername(W||"")}if(f5(At.VERSION_FILES)){const z=g.getSceneElementsIncludingDeleted(),W=g.getFiles(),j=(z==null?void 0:z.reduce((X,ee)=>Ft(ee)&&!W[ee.fileId]?X.concat(ee.fileId):X,[]))||[];j.length&&an.fileStorage.getFiles(j).then(({loadedFiles:X,erroredFiles:ee})=>{X.length&&g.addFiles(X),yu({excalidrawAPI:g,erroredFiles:ee,elements:g.getSceneElementsIncludingDeleted()})})}}},NQ),N=()=>{an.flushSave()},B=z=>{(z.type===Z.BLUR||document.hidden)&&an.flushSave(),(z.type===Z.VISIBILITY_CHANGE||z.type===Z.FOCUS)&&R()};return window.addEventListener(Z.HASHCHANGE,$,!1),window.addEventListener(Z.UNLOAD,N,!1),window.addEventListener(Z.BLUR,B,!1),document.addEventListener(Z.VISIBILITY_CHANGE,B,!1),window.addEventListener(Z.FOCUS,B,!1),()=>{window.removeEventListener(Z.HASHCHANGE,$,!1),window.removeEventListener(Z.UNLOAD,N,!1),window.removeEventListener(Z.BLUR,B,!1),window.removeEventListener(Z.FOCUS,B,!1),document.removeEventListener(Z.VISIBILITY_CHANGE,B,!1),clearTimeout(Y)}},[d,y,g,r,i]),_.useEffect(()=>{const U=$=>{an.flushSave(),g&&an.fileStorage.shouldPreventUnload(g.getSceneElements())&&Xv($)};return window.addEventListener(Z.BEFORE_UNLOAD,U),()=>{window.removeEventListener(Z.BEFORE_UNLOAD,U)}},[g]),_.useEffect(()=>{p1.cacheUserLanguage(n)},[n]);const[C,S]=_.useState(()=>{var U;return localStorage.getItem(At.LOCAL_STORAGE_THEME)||((U=Dy().appState)==null?void 0:U.theme)||Tt.LIGHT});_.useEffect(()=>{localStorage.setItem(At.LOCAL_STORAGE_THEME,C),document.documentElement.classList.toggle("dark",C===Tt.DARK)},[C]);const I=(U,$,Y)=>{y!=null&&y.isCollaborating()&&y.syncElements(U),S($.theme),an.isSavePaused()||an.save(U,$,Y,()=>{if(g){let R=!1;const N=g.getSceneElementsIncludingDeleted().map(B=>{if(an.fileStorage.shouldUpdateImageElementStatus(B)){const z=ge(B,{status:"saved"});return z!==B&&(R=!0),z}return B});R&&g.updateScene({elements:N})}})},[T,L]=_.useState(null),A=async(U,$,Y)=>{if(U.length===0)throw new Error(b("alerts.cannotExportEmptyCanvas"));try{const{url:R,errorMessage:N}=await tJ(U,{...$,viewBackgroundColor:$.exportBackground?$.viewBackgroundColor:qr().viewBackgroundColor},Y);if(N)throw new Error(N);R&&L(R)}catch(R){if(R.name!=="AbortError"){const{width:N,height:B}=$;throw console.error(R,{width:N,height:B,devicePixelRatio:window.devicePixelRatio}),new Error(R.message)}}},F=(U,$)=>f(yJ,{setToast:Y=>g.setToast({message:Y}),appState:$,elements:U}),P=Gl(kA),O=_.useCallback(()=>v({isOpen:!0,type:"collaborationOnly"}),[v]),V=async U=>{try{const $=await h.loadCanvas(U);$&&g&&(g.updateScene({appState:{openSidebar:null}}),g.addFiles(Object.values($.files)),g.updateScene({elements:$.elements,appState:$.appState,commitToHistory:!0}))}catch{t("Could not load the canvas.")}},G=async U=>{if(window.confirm("Are you sure you want to delete this canvas?"))try{await h.deleteCanvas(U),x()}catch{t("Could not delete the canvas.")}},q=async()=>{const U=window.prompt("Enter a name for your new canvas:","Untitled Canvas");if(U&&g){const $={...g.getAppState(),name:U},Y=g.getSceneElements(),R=g.getFiles();try{await h.createCanvas({elements:Y,appState:$,files:R}),await x(),g.resetScene(),g.updateScene({appState:{name:U}})}catch{t("Could not create new canvas.")}}};return MA?f("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",height:"100%"},children:f("h1",{children:"I'm not a pretzel!"})}):f("div",{style:{height:"100%"},className:se("excalidraw-app",{"is-collaborating":E}),children:k(bM,{excalidrawAPI:p,onChange:I,initialData:m.current.promise,isCollaborating:E,onPointerUpdate:y==null?void 0:y.onPointerUpdate,UIOptions:{canvasActions:{toggleTheme:!0,export:{onExportToBackend:A,renderCustomUI:g?(U,$,Y)=>f(EJ,{elements:U,appState:$,files:Y,name:g.getName(),onError:R=>{g==null||g.updateScene({appState:{errorMessage:R.message}})},onSuccess:()=>{g.updateScene({appState:{openDialog:null}})}}):void 0}}},langCode:n,renderCustomStats:F,detectScroll:!1,handleKeyboardGlobally:!0,autoFocus:!0,theme:C,renderTopRightUI:U=>U||!y||d?null:k("div",{className:"top-right-ui",children:[w.message&&f(xA,{collabError:w}),f(vM,{isCollaborating:E,onSelect:()=>v({isOpen:!0,type:"share"})})]}),children:[f(bJ,{onCollabDialogOpen:O,isCollaborating:E,isCollabEnabled:!d,onStorageSettingsClick:()=>l(!0)}),f(_J,{onCollabDialogOpen:O,isCollabEnabled:!d}),k(i1,{children:[f(Ui.Tab,{tab:E0,children:f($J,{canvases:c,onCanvasSelect:V,onCanvasDelete:G,onCanvasCreate:q})}),f(i1.TabTriggers,{children:f(Ui.Trigger,{name:"default",tab:E0,icon:dg,title:"My Canvases"})})]}),k(Js,{children:[f(Js.Actions.ExportToImage,{}),f(Js.Actions.SaveToDisk,{}),g&&f(Js.Action,{title:b("overwriteConfirm.action.excalidrawPlus.title"),actionLabel:b("overwriteConfirm.action.excalidrawPlus.button"),onClick:()=>{CA(g.getSceneElements(),g.getAppState(),g.getFiles(),g.getName())},children:b("overwriteConfirm.action.excalidrawPlus.description")})]}),f(kJ,{}),f(MM,{onTextSubmit:async U=>{try{const $=await fetch("https://oss-ai.excalidraw.com/v1/ai/text-to-diagram/generate",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({prompt:U})}),Y=$.headers.has("X-Ratelimit-Limit")?parseInt($.headers.get("X-Ratelimit-Limit")||"0",10):void 0,R=$.headers.has("X-Ratelimit-Remaining")?parseInt($.headers.get("X-Ratelimit-Remaining")||"0",10):void 0,N=await $.json();if(!$.ok){if($.status===429)return{rateLimit:Y,rateLimitRemaining:R,error:new Error("Too many requests today, please try again tomorrow!")};throw new Error(N.message||"Generation failed...")}const B=N.generatedResponse;if(!B)throw new Error("Generation failed...");return{generatedResponse:B,rateLimit:Y,rateLimitRemaining:R}}catch{throw new Error("Request failed")}}}),f(EM,{}),E&&P&&f("div",{className:"collab-offline-warning",children:b("alerts.collabOfflineWarning")}),T&&f(MJ,{link:T,onCloseRequest:()=>L(null),setErrorMessage:t}),g&&!d&&f(gJ,{excalidrawAPI:g}),f(DJ,{collabAPI:y,onExportToBackend:async()=>{if(g)try{await A(g.getSceneElements(),g.getAppState(),g.getFiles())}catch(U){t(U.message)}}}),a&&f(OJ,{onClose:()=>l(!1)}),e&&f(Cw,{onClose:()=>t(""),children:e})]})})},zJ=()=>f(LQ,{children:f(Vv,{unstable_createStore:()=>vo,children:f(BJ,{})})});function HJ(e={}){const{immediate:t=!1,onNeedRefresh:n,onOfflineReady:r,onRegistered:i,onRegisteredSW:o,onRegisterError:s}=e;let a,l;const c=async(d=!0)=>{await l};async function u(){if("serviceWorker"in navigator){const{Workbox:d}=await ie(()=>import("./workbox-window.prod.es5-prqDwDSL.js"),__vite__mapDeps([]));a=new d("/sw.js",{scope:"/",type:"classic"}),a.addEventListener("activated",h=>{(h.isUpdate||h.isExternal)&&window.location.reload()}),a.addEventListener("installed",h=>{h.isUpdate||r==null||r()}),a.register({immediate:t}).then(h=>{o?o("/sw.js",h):i==null||i(h)}).catch(h=>{s==null||s(h)})}}return l=u(),c}var df=Pt(),UJ=function(){function e(t){t===void 0&&(t={}),this.name=e.id,this._levels=["log","info","warn","error","debug","assert"],t.levels&&(this._levels=t.levels)}return e.prototype.setupOnce=function(t,n){"console"in df&&this._levels.forEach(function(r){r in df.console&&Zt(df.console,r,function(i){return function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=n();a.getIntegration(e)&&a.withScope(function(l){l.setLevel(Jr.fromString(r)),l.setExtra("arguments",o),l.addEventProcessor(function(u){return u.logger="console",u});var c=u1(o," ");r==="assert"?o[0]===!1&&(c="Assertion failed: "+(u1(o.slice(1)," ")||"console.assert"),l.setExtra("arguments",o.slice(1)),a.captureMessage(c)):a.captureMessage(c)}),i&&Function.prototype.apply.call(i,df.console,o)}})})},e.id="CaptureConsole",e}(),WJ={VITE_APP_BACKEND_V2_GET_URL:"https://json.excalidraw.com/api/v2/",VITE_APP_BACKEND_V2_POST_URL:"https://json.excalidraw.com/api/v2/post/",VITE_APP_LIBRARY_URL:"https://libraries.excalidraw.com",VITE_APP_LIBRARY_BACKEND:"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries",VITE_APP_PLUS_LP:"https://plus.excalidraw.com",VITE_APP_PLUS_APP:"https://app.excalidraw.com",VITE_APP_AI_BACKEND:"https://oss-ai.excalidraw.com",VITE_APP_WS_SERVER_URL:"https://oss-collab.excalidraw.com",VITE_APP_FIREBASE_CONFIG:'{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}',VITE_APP_DISABLE_TRACKING:"",VITE_APP_GIT_SHA:"",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const LA={"excalidraw.com":"production","vercel.app":"staging"},VJ=WJ.VITE_APP_DISABLE_SENTRY==="true",b0=!VJ&&Object.keys(LA).find(e=>window.location.hostname.indexOf(e)>=0);MQ({dsn:b0?"https://7bfc596a5bf945eda6b660d3015a5460@sentry.io/5179260":void 0,environment:b0?LA[b0]:void 0,release:"",ignoreErrors:["undefined is not an object (evaluating 'window.__pad.performLoop')"],integrations:[new UJ({levels:["error"]})],beforeSend(e){var t;return(t=e.request)!=null&&t.url&&(e.request.url=e.request.url.replace(/#.*$/,"")),e}});window.__EXCALIDRAW_SHA__="";const GJ=document.getElementById("root"),jJ=AS(GJ);HJ();jJ.render(f(_.StrictMode,{children:f(zJ,{})}));export{KJ as _,Mo as a,qJ as b,QJ as c,ZJ as d,XJ as e,ZV as f,rc as g,ph as h,ie as i};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
__vite__mapDeps.viteFileDeps = ["assets/pica-k97f9p3G.js","assets/_commonjs-dynamic-modules-h-SxKiO4.js","assets/index.esm-EExsODKC.js","assets/index.esm-J35DBGFx.js","assets/index.esm-h2kZ9fZN.js","assets/index.esm-Aqyp0Gpy.js"]
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
//# sourceMappingURL=index-2K3MavtT.js.map